vgavar.h revision 1.3 1 /* $NetBSD: vgavar.h,v 1.3 1999/01/13 16:48:58 drochner Exp $ */
2
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 struct vga_handle {
31 struct pcdisplay_handle vh_ph;
32 bus_space_handle_t vh_ioh_vga, vh_allmemh;
33 int vh_mono;
34 };
35 #define vh_iot vh_ph.ph_iot
36 #define vh_memt vh_ph.ph_memt
37 #define vh_ioh_6845 vh_ph.ph_ioh_6845
38 #define vh_memh vh_ph.ph_memh
39
40 static inline u_int8_t _vga_attr_read __P((struct vga_handle *, int));
41 static inline void _vga_attr_write __P((struct vga_handle *, int, u_int8_t));
42 static inline u_int8_t _vga_ts_read __P((struct vga_handle *, int));
43 static inline void _vga_ts_write __P((struct vga_handle *, int, u_int8_t));
44 static inline u_int8_t _vga_gdc_read __P((struct vga_handle *, int));
45 static inline void _vga_gdc_write __P((struct vga_handle *, int, u_int8_t));
46
47 static inline u_int8_t _vga_attr_read(vh, reg)
48 struct vga_handle *vh;
49 int reg;
50 {
51 u_int8_t res;
52
53 /* reset state */
54 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
55
56 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
57 res = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAR);
58
59 /* reset state XXX unneeded? */
60 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
61
62 /* enable */
63 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
64
65 return (res);
66 }
67
68 static inline void _vga_attr_write(vh, reg, val)
69 struct vga_handle *vh;
70 int reg;
71 u_int8_t val;
72 {
73 /* reset state */
74 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
75
76 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
77 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAW, val);
78
79 /* reset state XXX unneeded? */
80 (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
81
82 /* enable */
83 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
84 }
85
86 static inline u_int8_t _vga_ts_read(vh, reg)
87 struct vga_handle *vh;
88 int reg;
89 {
90 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
91 return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA));
92 }
93
94 static inline void _vga_ts_write(vh, reg, val)
95 struct vga_handle *vh;
96 int reg;
97 u_int8_t val;
98 {
99 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
100 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA, val);
101 }
102
103 static inline u_int8_t _vga_gdc_read(vh, reg)
104 struct vga_handle *vh;
105 int reg;
106 {
107 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
108 return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA));
109 }
110
111 static inline void _vga_gdc_write(vh, reg, val)
112 struct vga_handle *vh;
113 int reg;
114 u_int8_t val;
115 {
116 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
117 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA, val);
118 }
119
120 #define vga_attr_read(vh, reg) \
121 _vga_attr_read(vh, offsetof(struct reg_vgaattr, reg))
122 #define vga_attr_write(vh, reg, val) \
123 _vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val)
124 #define vga_ts_read(vh, reg) \
125 _vga_ts_read(vh, offsetof(struct reg_vgats, reg))
126 #define vga_ts_write(vh, reg, val) \
127 _vga_ts_write(vh, offsetof(struct reg_vgats, reg), val)
128 #define vga_gdc_read(vh, reg) \
129 _vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg))
130 #define vga_gdc_write(vh, reg, val) \
131 _vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val)
132
133 #define vga_6845_read(vh, reg) \
134 pcdisplay_6845_read(&(vh)->vh_ph, reg)
135 #define vga_6845_write(vh, reg, val) \
136 pcdisplay_6845_write(&(vh)->vh_ph, reg, val)
137
138 int vga_common_probe __P((bus_space_tag_t, bus_space_tag_t));
139 void vga_common_attach __P((struct device *, bus_space_tag_t,
140 bus_space_tag_t, int));
141 int vga_is_console __P((bus_space_tag_t, int));
142
143 int vga_cnattach __P((bus_space_tag_t, bus_space_tag_t, int, int));
144
145 struct wsscreen_descr;
146 void vga_loadchars __P((struct vga_handle *, int, int, int, int, char *));
147 void vga_setfontset __P((struct vga_handle *, int, int));
148 void vga_setscreentype __P((struct vga_handle *,
149 const struct wsscreen_descr *));
150