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