vt_buffer.h 1.5 KB

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