vga.h 2.1 KB

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