vt_buffer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
  15. #include <asm/vga.h>
  16. #endif
  17. #ifndef VT_BUF_HAVE_RW
  18. #define scr_writew(val, addr) (*(addr) = (val))
  19. #define scr_readw(addr) (*(addr))
  20. #define scr_memcpyw(d, s, c) memcpy(d, s, c)
  21. #define scr_memmovew(d, s, c) memmove(d, s, c)
  22. #define VT_BUF_HAVE_MEMCPYW
  23. #define VT_BUF_HAVE_MEMMOVEW
  24. #endif
  25. #ifndef VT_BUF_HAVE_MEMSETW
  26. static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
  27. {
  28. count /= 2;
  29. while (count--)
  30. scr_writew(c, s++);
  31. }
  32. #endif
  33. #ifndef VT_BUF_HAVE_MEMCPYW
  34. static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
  35. {
  36. count /= 2;
  37. while (count--)
  38. scr_writew(scr_readw(s++), d++);
  39. }
  40. #endif
  41. #ifndef VT_BUF_HAVE_MEMMOVEW
  42. static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
  43. {
  44. if (d < s)
  45. scr_memcpyw(d, s, count);
  46. else {
  47. count /= 2;
  48. d += count;
  49. s += count;
  50. while (count--)
  51. scr_writew(scr_readw(--s), --d);
  52. }
  53. }
  54. #endif
  55. #endif