This source file includes following definitions.
- _vga_attr_read
- _vga_attr_write
- _vga_ts_read
- _vga_ts_write
- _vga_gdc_read
- _vga_gdc_write
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include <sys/timeout.h>
32
33 struct vga_handle {
34 struct pcdisplay_handle vh_ph;
35 bus_space_handle_t vh_ioh_vga, vh_allmemh;
36 int vh_mono;
37 };
38 #define vh_iot vh_ph.ph_iot
39 #define vh_memt vh_ph.ph_memt
40 #define vh_ioh_6845 vh_ph.ph_ioh_6845
41 #define vh_memh vh_ph.ph_memh
42
43 struct vga_config {
44 struct vga_handle hdl;
45
46 struct device *vc_softc;
47 int vc_type;
48 int nscreens;
49 LIST_HEAD(, vgascreen) screens;
50 struct vgascreen *active;
51 const struct wsscreen_descr *currenttype;
52 int currentfontset1, currentfontset2;
53
54 struct vgafont *vc_fonts[8];
55
56 struct vgascreen *wantedscreen;
57 void (*switchcb)(void *, int, int);
58 void *switchcbarg;
59
60 paddr_t (*vc_mmap)(void *, off_t, int);
61
62 struct timeout vc_switch_timeout;
63 };
64
65 static inline u_int8_t _vga_attr_read(struct vga_handle *, int);
66 static inline void _vga_attr_write(struct vga_handle *, int, u_int8_t);
67 static inline u_int8_t _vga_ts_read(struct vga_handle *, int);
68 static inline void _vga_ts_write(struct vga_handle *, int, u_int8_t);
69 static inline u_int8_t _vga_gdc_read(struct vga_handle *, int);
70 static inline void _vga_gdc_write(struct vga_handle *, int, u_int8_t);
71
72 static inline u_int8_t _vga_attr_read(vh, reg)
73 struct vga_handle *vh;
74 int reg;
75 {
76 u_int8_t res;
77
78
79 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
80
81 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
82 res = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAR);
83
84
85 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
86
87
88 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
89
90 return (res);
91 }
92
93 static inline void _vga_attr_write(vh, reg, val)
94 struct vga_handle *vh;
95 int reg;
96 u_int8_t val;
97 {
98
99 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
100
101 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
102 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAW, val);
103
104
105 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
106
107
108 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
109 }
110
111 static inline u_int8_t _vga_ts_read(vh, reg)
112 struct vga_handle *vh;
113 int reg;
114 {
115 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
116 return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA));
117 }
118
119 static inline void _vga_ts_write(vh, reg, val)
120 struct vga_handle *vh;
121 int reg;
122 u_int8_t val;
123 {
124 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
125 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA, val);
126 }
127
128 static inline u_int8_t _vga_gdc_read(vh, reg)
129 struct vga_handle *vh;
130 int reg;
131 {
132 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
133 return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA));
134 }
135
136 static inline void _vga_gdc_write(vh, reg, val)
137 struct vga_handle *vh;
138 int reg;
139 u_int8_t val;
140 {
141 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
142 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA, val);
143 }
144
145 #define vga_attr_read(vh, reg) \
146 _vga_attr_read(vh, offsetof(struct reg_vgaattr, reg))
147 #define vga_attr_write(vh, reg, val) \
148 _vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val)
149 #define vga_ts_read(vh, reg) \
150 _vga_ts_read(vh, offsetof(struct reg_vgats, reg))
151 #define vga_ts_write(vh, reg, val) \
152 _vga_ts_write(vh, offsetof(struct reg_vgats, reg), val)
153 #define vga_gdc_read(vh, reg) \
154 _vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg))
155 #define vga_gdc_write(vh, reg, val) \
156 _vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val)
157
158 #define vga_6845_read(vh, reg) \
159 pcdisplay_6845_read(&(vh)->vh_ph, reg)
160 #define vga_6845_write(vh, reg, val) \
161 pcdisplay_6845_write(&(vh)->vh_ph, reg, val)
162
163 int vga_common_probe(bus_space_tag_t, bus_space_tag_t);
164 void vga_common_attach(struct device *, bus_space_tag_t,
165 bus_space_tag_t, int);
166 void vga_extended_attach(struct device *, bus_space_tag_t,
167 bus_space_tag_t, int, paddr_t (*)(void *, off_t, int));
168 int vga_is_console(bus_space_tag_t, int);
169 int vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int);
170
171 struct wsscreen_descr;
172 void vga_loadchars(struct vga_handle *, int, int, int, int, char *);
173 void vga_setfontset(struct vga_handle *, int, int);
174 void vga_setscreentype(struct vga_handle *,
175 const struct wsscreen_descr *);
176 #if NVGA_PCI > 0
177 int vga_pci_ioctl(void *, u_long, caddr_t, int, struct proc *);
178 #endif