vt_buffer.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * include/linux/vt_buffer.h -- Access to VT screen buffer
  4. *
  5. * (c) 1998 Martin Mares <mj@ucw.cz>
  6. *
  7. * This is a set of macros and functions which are used in the
  8. * console driver and related code to access the screen buffer.
  9. * In most cases the console works with simple in-memory buffer,
  10. * but when handling hardware text mode consoles, we store
  11. * the foreground console directly in video memory.
  12. */
  13. #ifndef _LINUX_VT_BUFFER_H_
  14. #define _LINUX_VT_BUFFER_H_
  15. #include <linux/string.h>
  16. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
  17. #include <asm/vga.h>
  18. #endif
  19. #ifndef VT_BUF_HAVE_RW
  20. #define scr_writew(val, addr) (*(addr) = (val))
  21. #define scr_readw(addr) (*(addr))
  22. #endif
  23. #ifndef VT_BUF_HAVE_MEMSETW
  24. static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
  25. {
  26. #ifdef VT_BUF_HAVE_RW
  27. count /= 2;
  28. while (count--)
  29. scr_writew(c, s++);
  30. #else
  31. memset16(s, c, count / 2);
  32. #endif
  33. }
  34. #endif
  35. #ifndef VT_BUF_HAVE_MEMCPYW
  36. static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
  37. {
  38. #ifdef VT_BUF_HAVE_RW
  39. count /= 2;
  40. while (count--)
  41. scr_writew(scr_readw(s++), d++);
  42. #else
  43. memcpy(d, s, count);
  44. #endif
  45. }
  46. #endif
  47. #ifndef VT_BUF_HAVE_MEMMOVEW
  48. static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
  49. {
  50. #ifdef VT_BUF_HAVE_RW
  51. if (d < s)
  52. scr_memcpyw(d, s, count);
  53. else {
  54. count /= 2;
  55. d += count;
  56. s += count;
  57. while (count--)
  58. scr_writew(scr_readw(--s), --d);
  59. }
  60. #else
  61. memmove(d, s, count);
  62. #endif
  63. }
  64. #endif
  65. #endif