vga.h 2.0 KB

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