vga.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Access to VGA videoram
  3. *
  4. * (c) 1998 Martin Mares <mj@ucw.cz>
  5. */
  6. #ifndef _LINUX_ASM_VGA_H_
  7. #define _LINUX_ASM_VGA_H_
  8. #include <asm/io.h>
  9. #define VT_BUF_HAVE_RW
  10. #define VT_BUF_HAVE_MEMSETW
  11. #define VT_BUF_HAVE_MEMCPYW
  12. static inline void scr_writew(u16 val, volatile u16 *addr)
  13. {
  14. if (__is_ioaddr(addr))
  15. __raw_writew(val, (volatile u16 __iomem *) addr);
  16. else
  17. *addr = val;
  18. }
  19. static inline u16 scr_readw(volatile const u16 *addr)
  20. {
  21. if (__is_ioaddr(addr))
  22. return __raw_readw((volatile const u16 __iomem *) addr);
  23. else
  24. return *addr;
  25. }
  26. static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
  27. {
  28. if (__is_ioaddr(s))
  29. memsetw_io((u16 __iomem *) s, c, count);
  30. else
  31. memsetw(s, c, count);
  32. }
  33. /* Do not trust that the usage will be correct; analyze the arguments. */
  34. extern void scr_memcpyw(u16 *d, const u16 *s, unsigned int count);
  35. /* ??? These are currently only used for downloading character sets. As
  36. such, they don't need memory barriers. Is this all they are intended
  37. to be used for? */
  38. #define vga_readb(a) readb((u8 __iomem *)(a))
  39. #define vga_writeb(v,a) writeb(v, (u8 __iomem *)(a))
  40. #ifdef CONFIG_VGA_HOSE
  41. #include <linux/ioport.h>
  42. #include <linux/pci.h>
  43. extern struct pci_controller *pci_vga_hose;
  44. # define __is_port_vga(a) \
  45. (((a) >= 0x3b0) && ((a) < 0x3e0) && \
  46. ((a) != 0x3b3) && ((a) != 0x3d3))
  47. # define __is_mem_vga(a) \
  48. (((a) >= 0xa0000) && ((a) <= 0xc0000))
  49. # define FIXUP_IOADDR_VGA(a) do { \
  50. if (pci_vga_hose && __is_port_vga(a)) \
  51. (a) += pci_vga_hose->io_space->start; \
  52. } while(0)
  53. # define FIXUP_MEMADDR_VGA(a) do { \
  54. if (pci_vga_hose && __is_mem_vga(a)) \
  55. (a) += pci_vga_hose->mem_space->start; \
  56. } while(0)
  57. #else /* CONFIG_VGA_HOSE */
  58. # define pci_vga_hose 0
  59. # define __is_port_vga(a) 0
  60. # define __is_mem_vga(a) 0
  61. # define FIXUP_IOADDR_VGA(a)
  62. # define FIXUP_MEMADDR_VGA(a)
  63. #endif /* CONFIG_VGA_HOSE */
  64. #define VGA_MAP_MEM(x,s) ((unsigned long) ioremap(x, s))
  65. #endif