Make internal functions staticdiff -r1.109 -r1.110 src/sys/dev/ic/vga.c
(mlelstv)
--- src/sys/dev/ic/vga.c 2012/08/09 23:56:35 1.109
+++ src/sys/dev/ic/vga.c 2013/01/21 19:49:15 1.110
@@ -1,1588 +1,1591 @@ | @@ -1,1588 +1,1591 @@ | |||
1 | /* $NetBSD: vga.c,v 1.109 2012/08/09 23:56:35 uwe Exp $ */ | 1 | /* $NetBSD: vga.c,v 1.110 2013/01/21 19:49:15 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | 4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Author: Chris G. Demetriou | 7 | * Author: Chris G. Demetriou | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify and distribute this software and | 9 | * Permission to use, copy, modify and distribute this software and | |
10 | * its documentation is hereby granted, provided that both the copyright | 10 | * its documentation is hereby granted, provided that both the copyright | |
11 | * notice and this permission notice appear in all copies of the | 11 | * notice and this permission notice appear in all copies of the | |
12 | * software, derivative works or modified versions, and any portions | 12 | * software, derivative works or modified versions, and any portions | |
13 | * thereof, and that both notices appear in supporting documentation. | 13 | * thereof, and that both notices appear in supporting documentation. | |
14 | * | 14 | * | |
15 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 15 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
16 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | 16 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | |
17 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | 17 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
18 | * | 18 | * | |
19 | * Carnegie Mellon requests users of this software to return to | 19 | * Carnegie Mellon requests users of this software to return to | |
20 | * | 20 | * | |
21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | 21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
22 | * School of Computer Science | 22 | * School of Computer Science | |
23 | * Carnegie Mellon University | 23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | 24 | * Pittsburgh PA 15213-3890 | |
25 | * | 25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie the | 26 | * any improvements or extensions that they make and grant Carnegie the | |
27 | * rights to redistribute these changes. | 27 | * rights to redistribute these changes. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.109 2012/08/09 23:56:35 uwe Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.110 2013/01/21 19:49:15 mlelstv Exp $"); | |
32 | 32 | |||
33 | /* for WSCONS_SUPPORT_PCVTFONTS */ | 33 | /* for WSCONS_SUPPORT_PCVTFONTS */ | |
34 | #include "opt_wsdisplay_compat.h" | 34 | #include "opt_wsdisplay_compat.h" | |
35 | /* for WSDISPLAY_CUSTOM_BORDER */ | 35 | /* for WSDISPLAY_CUSTOM_BORDER */ | |
36 | #include "opt_wsdisplay_border.h" | 36 | #include "opt_wsdisplay_border.h" | |
37 | /* for WSDISPLAY_CUSTOM_OUTPUT */ | 37 | /* for WSDISPLAY_CUSTOM_OUTPUT */ | |
38 | #include "opt_wsmsgattrs.h" | 38 | #include "opt_wsmsgattrs.h" | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/callout.h> | 42 | #include <sys/callout.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/device.h> | 44 | #include <sys/device.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/queue.h> | 46 | #include <sys/queue.h> | |
47 | #include <sys/bus.h> | 47 | #include <sys/bus.h> | |
48 | 48 | |||
49 | #include <dev/ic/mc6845reg.h> | 49 | #include <dev/ic/mc6845reg.h> | |
50 | #include <dev/ic/pcdisplayvar.h> | 50 | #include <dev/ic/pcdisplayvar.h> | |
51 | #include <dev/ic/vgareg.h> | 51 | #include <dev/ic/vgareg.h> | |
52 | #include <dev/ic/vgavar.h> | 52 | #include <dev/ic/vgavar.h> | |
53 | 53 | |||
54 | #include <dev/wscons/wsdisplayvar.h> | 54 | #include <dev/wscons/wsdisplayvar.h> | |
55 | #include <dev/wscons/wsconsio.h> | 55 | #include <dev/wscons/wsconsio.h> | |
56 | #include <dev/wscons/unicode.h> | 56 | #include <dev/wscons/unicode.h> | |
57 | #include <dev/wsfont/wsfont.h> | 57 | #include <dev/wsfont/wsfont.h> | |
58 | 58 | |||
59 | #include <dev/ic/pcdisplay.h> | 59 | #include <dev/ic/pcdisplay.h> | |
60 | 60 | |||
61 | int vga_no_builtinfont = 0; | 61 | int vga_no_builtinfont = 0; | |
62 | 62 | |||
63 | static struct wsdisplay_font _vga_builtinfont = { | 63 | static struct wsdisplay_font _vga_builtinfont = { | |
64 | "builtin", /* typeface name */ | 64 | "builtin", /* typeface name */ | |
65 | 0, /* firstchar */ | 65 | 0, /* firstchar */ | |
66 | 256, /* numbers */ | 66 | 256, /* numbers */ | |
67 | WSDISPLAY_FONTENC_IBM, /* encoding */ | 67 | WSDISPLAY_FONTENC_IBM, /* encoding */ | |
68 | 8, /* width */ | 68 | 8, /* width */ | |
69 | 16, /* height */ | 69 | 16, /* height */ | |
70 | 1, /* stride */ | 70 | 1, /* stride */ | |
71 | WSDISPLAY_FONTORDER_L2R, /* bit order */ | 71 | WSDISPLAY_FONTORDER_L2R, /* bit order */ | |
72 | 0, /* byte order */ | 72 | 0, /* byte order */ | |
73 | NULL /* data */ | 73 | NULL /* data */ | |
74 | }; | 74 | }; | |
75 | 75 | |||
76 | struct egavga_font { | 76 | struct egavga_font { | |
77 | struct wsdisplay_font *wsfont; | 77 | struct wsdisplay_font *wsfont; | |
78 | int cookie; /* wsfont handle, -1 invalid */ | 78 | int cookie; /* wsfont handle, -1 invalid */ | |
79 | int slot; /* in adapter RAM */ | 79 | int slot; /* in adapter RAM */ | |
80 | int usecount; | 80 | int usecount; | |
81 | TAILQ_ENTRY(egavga_font) next; /* LRU queue */ | 81 | TAILQ_ENTRY(egavga_font) next; /* LRU queue */ | |
82 | }; | 82 | }; | |
83 | 83 | |||
84 | static struct egavga_font vga_builtinfont = { | 84 | static struct egavga_font vga_builtinfont = { | |
85 | .wsfont = &_vga_builtinfont, | 85 | .wsfont = &_vga_builtinfont, | |
86 | .cookie = -1, | 86 | .cookie = -1, | |
87 | .slot = 0, | 87 | .slot = 0, | |
88 | }; | 88 | }; | |
89 | 89 | |||
90 | #ifdef VGA_CONSOLE_SCREENTYPE | 90 | #ifdef VGA_CONSOLE_SCREENTYPE | |
91 | static struct egavga_font vga_consolefont; | 91 | static struct egavga_font vga_consolefont; | |
92 | #endif | 92 | #endif | |
93 | 93 | |||
94 | struct vgascreen { | 94 | struct vgascreen { | |
95 | struct pcdisplayscreen pcs; | 95 | struct pcdisplayscreen pcs; | |
96 | 96 | |||
97 | LIST_ENTRY(vgascreen) next; | 97 | LIST_ENTRY(vgascreen) next; | |
98 | 98 | |||
99 | struct vga_config *cfg; | 99 | struct vga_config *cfg; | |
100 | 100 | |||
101 | /* videostate */ | 101 | /* videostate */ | |
102 | struct egavga_font *fontset1, *fontset2; | 102 | struct egavga_font *fontset1, *fontset2; | |
103 | /* font data */ | 103 | /* font data */ | |
104 | 104 | |||
105 | int mindispoffset, maxdispoffset; | 105 | int mindispoffset, maxdispoffset; | |
106 | int vga_rollover; | 106 | int vga_rollover; | |
107 | int visibleoffset; | 107 | int visibleoffset; | |
108 | }; | 108 | }; | |
109 | 109 | |||
110 | static int vgaconsole, vga_console_type, vga_console_attached; | 110 | static int vgaconsole, vga_console_type, vga_console_attached; | |
111 | static struct vgascreen vga_console_screen; | 111 | static struct vgascreen vga_console_screen; | |
112 | static struct vga_config vga_console_vc; | 112 | static struct vga_config vga_console_vc; | |
113 | 113 | |||
114 | struct egavga_font *egavga_getfont(struct vga_config *, struct vgascreen *, | 114 | static struct egavga_font *egavga_getfont(struct vga_config *, struct vgascreen *, | |
115 | const char *, int); | 115 | const char *, int); | |
116 | void egavga_unreffont(struct vga_config *, struct egavga_font *); | 116 | static void egavga_unreffont(struct vga_config *, struct egavga_font *); | |
117 | 117 | |||
118 | int vga_selectfont(struct vga_config *, struct vgascreen *, const char *, | 118 | static int vga_selectfont(struct vga_config *, struct vgascreen *, const char *, | |
119 | const char *); | 119 | const char *); | |
120 | void vga_init_screen(struct vga_config *, struct vgascreen *, | 120 | static void vga_init_screen(struct vga_config *, struct vgascreen *, | |
121 | const struct wsscreen_descr *, int, long *); | 121 | const struct wsscreen_descr *, int, long *); | |
122 | void vga_init(struct vga_config *, bus_space_tag_t, bus_space_tag_t); | 122 | static void vga_init(struct vga_config *, bus_space_tag_t, bus_space_tag_t); | |
123 | static void vga_setfont(struct vga_config *, struct vgascreen *); | 123 | static void vga_setfont(struct vga_config *, struct vgascreen *); | |
124 | 124 | |||
125 | static int vga_mapchar(void *, int, unsigned int *); | 125 | static int vga_mapchar(void *, int, unsigned int *); | |
126 | void vga_putchar(void *, int, int, u_int, long); | 126 | static void vga_putchar(void *, int, int, u_int, long); | |
127 | static int vga_allocattr(void *, int, int, int, long *); | 127 | static int vga_allocattr(void *, int, int, int, long *); | |
128 | static void vga_copyrows(void *, int, int, int); | 128 | static void vga_copyrows(void *, int, int, int); | |
129 | #ifdef WSDISPLAY_SCROLLSUPPORT | 129 | #ifdef WSDISPLAY_SCROLLSUPPORT | |
130 | void vga_scroll (void *, void *, int); | 130 | static void vga_scroll (void *, void *, int); | |
131 | #endif | 131 | #endif | |
132 | 132 | |||
133 | const struct wsdisplay_emulops vga_emulops = { | 133 | const struct wsdisplay_emulops vga_emulops = { | |
134 | pcdisplay_cursor, | 134 | pcdisplay_cursor, | |
135 | vga_mapchar, | 135 | vga_mapchar, | |
136 | vga_putchar, | 136 | vga_putchar, | |
137 | pcdisplay_copycols, | 137 | pcdisplay_copycols, | |
138 | pcdisplay_erasecols, | 138 | pcdisplay_erasecols, | |
139 | vga_copyrows, | 139 | vga_copyrows, | |
140 | pcdisplay_eraserows, | 140 | pcdisplay_eraserows, | |
141 | vga_allocattr, | 141 | vga_allocattr, | |
142 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | 142 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | |
143 | pcdisplay_replaceattr, | 143 | pcdisplay_replaceattr, | |
144 | #else | 144 | #else | |
145 | NULL, | 145 | NULL, | |
146 | #endif | 146 | #endif | |
147 | }; | 147 | }; | |
148 | 148 | |||
149 | /* | 149 | /* | |
150 | * translate WS(=ANSI) color codes to standard pc ones | 150 | * translate WS(=ANSI) color codes to standard pc ones | |
151 | */ | 151 | */ | |
152 | static const unsigned char fgansitopc[] = { | 152 | static const unsigned char fgansitopc[] = { | |
153 | #ifdef __alpha__ | 153 | #ifdef __alpha__ | |
154 | /* | 154 | /* | |
155 | * XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!! | 155 | * XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!! | |
156 | * XXX We should probably not bother with this | 156 | * XXX We should probably not bother with this | |
157 | * XXX (reinitialize the palette registers). | 157 | * XXX (reinitialize the palette registers). | |
158 | */ | 158 | */ | |
159 | FG_BLACK, FG_BLUE, FG_GREEN, FG_CYAN, FG_RED, | 159 | FG_BLACK, FG_BLUE, FG_GREEN, FG_CYAN, FG_RED, | |
160 | FG_MAGENTA, FG_BROWN, FG_LIGHTGREY | 160 | FG_MAGENTA, FG_BROWN, FG_LIGHTGREY | |
161 | #else | 161 | #else | |
162 | FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, | 162 | FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, | |
163 | FG_MAGENTA, FG_CYAN, FG_LIGHTGREY | 163 | FG_MAGENTA, FG_CYAN, FG_LIGHTGREY | |
164 | #endif | 164 | #endif | |
165 | }, bgansitopc[] = { | 165 | }, bgansitopc[] = { | |
166 | #ifdef __alpha__ | 166 | #ifdef __alpha__ | |
167 | BG_BLACK, BG_BLUE, BG_GREEN, BG_CYAN, BG_RED, | 167 | BG_BLACK, BG_BLUE, BG_GREEN, BG_CYAN, BG_RED, | |
168 | BG_MAGENTA, BG_BROWN, BG_LIGHTGREY | 168 | BG_MAGENTA, BG_BROWN, BG_LIGHTGREY | |
169 | #else | 169 | #else | |
170 | BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, | 170 | BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, | |
171 | BG_MAGENTA, BG_CYAN, BG_LIGHTGREY | 171 | BG_MAGENTA, BG_CYAN, BG_LIGHTGREY | |
172 | #endif | 172 | #endif | |
173 | }; | 173 | }; | |
174 | 174 | |||
175 | const struct wsscreen_descr vga_25lscreen = { | 175 | const struct wsscreen_descr vga_25lscreen = { | |
176 | "80x25", 80, 25, | 176 | "80x25", 80, 25, | |
177 | &vga_emulops, | 177 | &vga_emulops, | |
178 | 8, 16, | 178 | 8, 16, | |
179 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 179 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
180 | NULL, | 180 | NULL, | |
181 | }, vga_25lscreen_mono = { | 181 | }, vga_25lscreen_mono = { | |
182 | "80x25", 80, 25, | 182 | "80x25", 80, 25, | |
183 | &vga_emulops, | 183 | &vga_emulops, | |
184 | 8, 16, | 184 | 8, 16, | |
185 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 185 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
186 | NULL, | 186 | NULL, | |
187 | }, vga_25lscreen_bf = { | 187 | }, vga_25lscreen_bf = { | |
188 | "80x25bf", 80, 25, | 188 | "80x25bf", 80, 25, | |
189 | &vga_emulops, | 189 | &vga_emulops, | |
190 | 8, 16, | 190 | 8, 16, | |
191 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | 191 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | |
192 | NULL, | 192 | NULL, | |
193 | }, vga_40lscreen = { | 193 | }, vga_40lscreen = { | |
194 | "80x40", 80, 40, | 194 | "80x40", 80, 40, | |
195 | &vga_emulops, | 195 | &vga_emulops, | |
196 | 8, 10, | 196 | 8, 10, | |
197 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 197 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
198 | NULL, | 198 | NULL, | |
199 | }, vga_40lscreen_mono = { | 199 | }, vga_40lscreen_mono = { | |
200 | "80x40", 80, 40, | 200 | "80x40", 80, 40, | |
201 | &vga_emulops, | 201 | &vga_emulops, | |
202 | 8, 10, | 202 | 8, 10, | |
203 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 203 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
204 | NULL, | 204 | NULL, | |
205 | }, vga_40lscreen_bf = { | 205 | }, vga_40lscreen_bf = { | |
206 | "80x40bf", 80, 40, | 206 | "80x40bf", 80, 40, | |
207 | &vga_emulops, | 207 | &vga_emulops, | |
208 | 8, 10, | 208 | 8, 10, | |
209 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | 209 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | |
210 | NULL, | 210 | NULL, | |
211 | }, vga_50lscreen = { | 211 | }, vga_50lscreen = { | |
212 | "80x50", 80, 50, | 212 | "80x50", 80, 50, | |
213 | &vga_emulops, | 213 | &vga_emulops, | |
214 | 8, 8, | 214 | 8, 8, | |
215 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 215 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
216 | NULL, | 216 | NULL, | |
217 | }, vga_50lscreen_mono = { | 217 | }, vga_50lscreen_mono = { | |
218 | "80x50", 80, 50, | 218 | "80x50", 80, 50, | |
219 | &vga_emulops, | 219 | &vga_emulops, | |
220 | 8, 8, | 220 | 8, 8, | |
221 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 221 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
222 | NULL, | 222 | NULL, | |
223 | }, vga_50lscreen_bf = { | 223 | }, vga_50lscreen_bf = { | |
224 | "80x50bf", 80, 50, | 224 | "80x50bf", 80, 50, | |
225 | &vga_emulops, | 225 | &vga_emulops, | |
226 | 8, 8, | 226 | 8, 8, | |
227 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | 227 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | |
228 | NULL, | 228 | NULL, | |
229 | }, vga_24lscreen = { | 229 | }, vga_24lscreen = { | |
230 | "80x24", 80, 24, | 230 | "80x24", 80, 24, | |
231 | &vga_emulops, | 231 | &vga_emulops, | |
232 | 8, 16, | 232 | 8, 16, | |
233 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 233 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
234 | NULL, | 234 | NULL, | |
235 | }, vga_24lscreen_mono = { | 235 | }, vga_24lscreen_mono = { | |
236 | "80x24", 80, 24, | 236 | "80x24", 80, 24, | |
237 | &vga_emulops, | 237 | &vga_emulops, | |
238 | 8, 16, | 238 | 8, 16, | |
239 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 239 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
240 | NULL, | 240 | NULL, | |
241 | }, vga_24lscreen_bf = { | 241 | }, vga_24lscreen_bf = { | |
242 | "80x24bf", 80, 24, | 242 | "80x24bf", 80, 24, | |
243 | &vga_emulops, | 243 | &vga_emulops, | |
244 | 8, 16, | 244 | 8, 16, | |
245 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | 245 | WSSCREEN_WSCOLORS | WSSCREEN_BLINK, | |
246 | NULL, | 246 | NULL, | |
247 | }; | 247 | }; | |
248 | 248 | |||
249 | #define VGA_SCREEN_CANTWOFONTS(type) (!((type)->capabilities & WSSCREEN_HILIT)) | 249 | #define VGA_SCREEN_CANTWOFONTS(type) (!((type)->capabilities & WSSCREEN_HILIT)) | |
250 | 250 | |||
251 | const struct wsscreen_descr *_vga_scrlist[] = { | 251 | const struct wsscreen_descr *_vga_scrlist[] = { | |
252 | &vga_25lscreen, | 252 | &vga_25lscreen, | |
253 | &vga_25lscreen_bf, | 253 | &vga_25lscreen_bf, | |
254 | &vga_40lscreen, | 254 | &vga_40lscreen, | |
255 | &vga_40lscreen_bf, | 255 | &vga_40lscreen_bf, | |
256 | &vga_50lscreen, | 256 | &vga_50lscreen, | |
257 | &vga_50lscreen_bf, | 257 | &vga_50lscreen_bf, | |
258 | &vga_24lscreen, | 258 | &vga_24lscreen, | |
259 | &vga_24lscreen_bf, | 259 | &vga_24lscreen_bf, | |
260 | /* XXX other formats, graphics screen? */ | 260 | /* XXX other formats, graphics screen? */ | |
261 | }, *_vga_scrlist_mono[] = { | 261 | }, *_vga_scrlist_mono[] = { | |
262 | &vga_25lscreen_mono, | 262 | &vga_25lscreen_mono, | |
263 | &vga_40lscreen_mono, | 263 | &vga_40lscreen_mono, | |
264 | &vga_50lscreen_mono, | 264 | &vga_50lscreen_mono, | |
265 | &vga_24lscreen_mono, | 265 | &vga_24lscreen_mono, | |
266 | /* XXX other formats, graphics screen? */ | 266 | /* XXX other formats, graphics screen? */ | |
267 | }; | 267 | }; | |
268 | 268 | |||
269 | const struct wsscreen_list vga_screenlist = { | 269 | const struct wsscreen_list vga_screenlist = { | |
270 | sizeof(_vga_scrlist) / sizeof(struct wsscreen_descr *), | 270 | sizeof(_vga_scrlist) / sizeof(struct wsscreen_descr *), | |
271 | _vga_scrlist | 271 | _vga_scrlist | |
272 | }, vga_screenlist_mono = { | 272 | }, vga_screenlist_mono = { | |
273 | sizeof(_vga_scrlist_mono) / sizeof(struct wsscreen_descr *), | 273 | sizeof(_vga_scrlist_mono) / sizeof(struct wsscreen_descr *), | |
274 | _vga_scrlist_mono | 274 | _vga_scrlist_mono | |
275 | }; | 275 | }; | |
276 | 276 | |||
277 | static int vga_ioctl(void *, void *, u_long, void *, int, struct lwp *); | 277 | static int vga_ioctl(void *, void *, u_long, void *, int, struct lwp *); | |
278 | static paddr_t vga_mmap(void *, void *, off_t, int); | 278 | static paddr_t vga_mmap(void *, void *, off_t, int); | |
279 | static int vga_alloc_screen(void *, const struct wsscreen_descr *, | 279 | static int vga_alloc_screen(void *, const struct wsscreen_descr *, | |
280 | void **, int *, int *, long *); | 280 | void **, int *, int *, long *); | |
281 | static void vga_free_screen(void *, void *); | 281 | static void vga_free_screen(void *, void *); | |
282 | static int vga_show_screen(void *, void *, int, | 282 | static int vga_show_screen(void *, void *, int, | |
283 | void (*)(void *, int, int), void *); | 283 | void (*)(void *, int, int), void *); | |
284 | static int vga_load_font(void *, void *, struct wsdisplay_font *); | 284 | static int vga_load_font(void *, void *, struct wsdisplay_font *); | |
285 | #ifdef WSDISPLAY_CUSTOM_BORDER | 285 | #ifdef WSDISPLAY_CUSTOM_BORDER | |
286 | static int vga_getborder(struct vga_config *, u_int *); | 286 | static int vga_getborder(struct vga_config *, u_int *); | |
287 | static int vga_setborder(struct vga_config *, u_int); | 287 | static int vga_setborder(struct vga_config *, u_int); | |
288 | #endif /* WSDISPLAY_CUSTOM_BORDER */ | 288 | #endif /* WSDISPLAY_CUSTOM_BORDER */ | |
289 | 289 | |||
290 | void vga_doswitch(struct vga_config *); | 290 | static void vga_doswitch(struct vga_config *); | |
291 | static void vga_save_palette(struct vga_config *); | |||
292 | static void vga_restore_palette(struct vga_config *); | |||
293 | ||||
291 | 294 | |||
292 | const struct wsdisplay_accessops vga_accessops = { | 295 | const struct wsdisplay_accessops vga_accessops = { | |
293 | vga_ioctl, | 296 | vga_ioctl, | |
294 | vga_mmap, | 297 | vga_mmap, | |
295 | vga_alloc_screen, | 298 | vga_alloc_screen, | |
296 | vga_free_screen, | 299 | vga_free_screen, | |
297 | vga_show_screen, | 300 | vga_show_screen, | |
298 | vga_load_font, | 301 | vga_load_font, | |
299 | NULL, | 302 | NULL, | |
300 | #ifdef WSDISPLAY_SCROLLSUPPORT | 303 | #ifdef WSDISPLAY_SCROLLSUPPORT | |
301 | vga_scroll, | 304 | vga_scroll, | |
302 | #else | 305 | #else | |
303 | NULL, | 306 | NULL, | |
304 | #endif | 307 | #endif | |
305 | }; | 308 | }; | |
306 | 309 | |||
307 | /* | 310 | /* | |
308 | * We want at least ASCII 32..127 be present in the | 311 | * We want at least ASCII 32..127 be present in the | |
309 | * first font slot. | 312 | * first font slot. | |
310 | */ | 313 | */ | |
311 | #define vga_valid_primary_font(f) \ | 314 | #define vga_valid_primary_font(f) \ | |
312 | (f->wsfont->encoding == WSDISPLAY_FONTENC_IBM || \ | 315 | (f->wsfont->encoding == WSDISPLAY_FONTENC_IBM || \ | |
313 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO || \ | 316 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO || \ | |
314 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO2 || \ | 317 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO2 || \ | |
315 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO7 || \ | 318 | f->wsfont->encoding == WSDISPLAY_FONTENC_ISO7 || \ | |
316 | f->wsfont->encoding == WSDISPLAY_FONTENC_KOI8_R) | 319 | f->wsfont->encoding == WSDISPLAY_FONTENC_KOI8_R) | |
317 | 320 | |||
318 | struct egavga_font * | 321 | static struct egavga_font * | |
319 | egavga_getfont(struct vga_config *vc, struct vgascreen *scr, const char *name, | 322 | egavga_getfont(struct vga_config *vc, struct vgascreen *scr, const char *name, | |
320 | int primary) | 323 | int primary) | |
321 | { | 324 | { | |
322 | struct egavga_font *f; | 325 | struct egavga_font *f; | |
323 | int cookie; | 326 | int cookie; | |
324 | struct wsdisplay_font *wf; | 327 | struct wsdisplay_font *wf; | |
325 | 328 | |||
326 | TAILQ_FOREACH(f, &vc->vc_fontlist, next) { | 329 | TAILQ_FOREACH(f, &vc->vc_fontlist, next) { | |
327 | if (wsfont_matches(f->wsfont, name, | 330 | if (wsfont_matches(f->wsfont, name, | |
328 | 8, scr->pcs.type->fontheight, 0, WSFONT_FIND_BITMAP) && | 331 | 8, scr->pcs.type->fontheight, 0, WSFONT_FIND_BITMAP) && | |
329 | (!primary || vga_valid_primary_font(f))) { | 332 | (!primary || vga_valid_primary_font(f))) { | |
330 | #ifdef VGAFONTDEBUG | 333 | #ifdef VGAFONTDEBUG | |
331 | if (scr != &vga_console_screen || vga_console_attached) | 334 | if (scr != &vga_console_screen || vga_console_attached) | |
332 | printf("vga_getfont: %s already present\n", | 335 | printf("vga_getfont: %s already present\n", | |
333 | name ? name : "<default>"); | 336 | name ? name : "<default>"); | |
334 | #endif | 337 | #endif | |
335 | goto found; | 338 | goto found; | |
336 | } | 339 | } | |
337 | } | 340 | } | |
338 | 341 | |||
339 | cookie = wsfont_find(name, 8, scr->pcs.type->fontheight, 0, | 342 | cookie = wsfont_find(name, 8, scr->pcs.type->fontheight, 0, | |
340 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | 343 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | |
341 | /* XXX obey "primary" */ | 344 | /* XXX obey "primary" */ | |
342 | if (cookie == -1) { | 345 | if (cookie == -1) { | |
343 | #ifdef VGAFONTDEBUG | 346 | #ifdef VGAFONTDEBUG | |
344 | if (scr != &vga_console_screen || vga_console_attached) | 347 | if (scr != &vga_console_screen || vga_console_attached) | |
345 | printf("vga_getfont: %s not found\n", | 348 | printf("vga_getfont: %s not found\n", | |
346 | name ? name : "<default>"); | 349 | name ? name : "<default>"); | |
347 | #endif | 350 | #endif | |
348 | return (0); | 351 | return (0); | |
349 | } | 352 | } | |
350 | 353 | |||
351 | if (wsfont_lock(cookie, &wf)) | 354 | if (wsfont_lock(cookie, &wf)) | |
352 | return (0); | 355 | return (0); | |
353 | 356 | |||
354 | #ifdef VGA_CONSOLE_SCREENTYPE | 357 | #ifdef VGA_CONSOLE_SCREENTYPE | |
355 | if (scr == &vga_console_screen) | 358 | if (scr == &vga_console_screen) | |
356 | f = &vga_consolefont; | 359 | f = &vga_consolefont; | |
357 | else | 360 | else | |
358 | #endif | 361 | #endif | |
359 | f = malloc(sizeof(struct egavga_font), M_DEVBUF, M_NOWAIT); | 362 | f = malloc(sizeof(struct egavga_font), M_DEVBUF, M_NOWAIT); | |
360 | if (!f) { | 363 | if (!f) { | |
361 | wsfont_unlock(cookie); | 364 | wsfont_unlock(cookie); | |
362 | return (0); | 365 | return (0); | |
363 | } | 366 | } | |
364 | f->wsfont = wf; | 367 | f->wsfont = wf; | |
365 | f->cookie = cookie; | 368 | f->cookie = cookie; | |
366 | f->slot = -1; /* not yet loaded */ | 369 | f->slot = -1; /* not yet loaded */ | |
367 | f->usecount = 0; /* incremented below */ | 370 | f->usecount = 0; /* incremented below */ | |
368 | TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next); | 371 | TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next); | |
369 | 372 | |||
370 | found: | 373 | found: | |
371 | f->usecount++; | 374 | f->usecount++; | |
372 | #ifdef VGAFONTDEBUG | 375 | #ifdef VGAFONTDEBUG | |
373 | if (scr != &vga_console_screen || vga_console_attached) | 376 | if (scr != &vga_console_screen || vga_console_attached) | |
374 | printf("vga_getfont: usecount=%d\n", f->usecount); | 377 | printf("vga_getfont: usecount=%d\n", f->usecount); | |
375 | #endif | 378 | #endif | |
376 | return (f); | 379 | return (f); | |
377 | } | 380 | } | |
378 | 381 | |||
379 | void | 382 | static void | |
380 | egavga_unreffont(struct vga_config *vc, struct egavga_font *f) | 383 | egavga_unreffont(struct vga_config *vc, struct egavga_font *f) | |
381 | { | 384 | { | |
382 | 385 | |||
383 | f->usecount--; | 386 | f->usecount--; | |
384 | #ifdef VGAFONTDEBUG | 387 | #ifdef VGAFONTDEBUG | |
385 | printf("vga_unreffont: usecount=%d\n", f->usecount); | 388 | printf("vga_unreffont: usecount=%d\n", f->usecount); | |
386 | #endif | 389 | #endif | |
387 | if (f->usecount == 0 && f->cookie != -1) { | 390 | if (f->usecount == 0 && f->cookie != -1) { | |
388 | TAILQ_REMOVE(&vc->vc_fontlist, f, next); | 391 | TAILQ_REMOVE(&vc->vc_fontlist, f, next); | |
389 | if (f->slot != -1) { | 392 | if (f->slot != -1) { | |
390 | KASSERT(vc->vc_fonts[f->slot] == f); | 393 | KASSERT(vc->vc_fonts[f->slot] == f); | |
391 | vc->vc_fonts[f->slot] = 0; | 394 | vc->vc_fonts[f->slot] = 0; | |
392 | } | 395 | } | |
393 | wsfont_unlock(f->cookie); | 396 | wsfont_unlock(f->cookie); | |
394 | #ifdef VGA_CONSOLE_SCREENTYPE | 397 | #ifdef VGA_CONSOLE_SCREENTYPE | |
395 | if (f != &vga_consolefont) | 398 | if (f != &vga_consolefont) | |
396 | #endif | 399 | #endif | |
397 | free(f, M_DEVBUF); | 400 | free(f, M_DEVBUF); | |
398 | } | 401 | } | |
399 | } | 402 | } | |
400 | 403 | |||
401 | int | 404 | static int | |
402 | vga_selectfont(struct vga_config *vc, struct vgascreen *scr, const char *name1, | 405 | vga_selectfont(struct vga_config *vc, struct vgascreen *scr, const char *name1, | |
403 | const char *name2) | 406 | const char *name2) | |
404 | { | 407 | { | |
405 | const struct wsscreen_descr *type = scr->pcs.type; | 408 | const struct wsscreen_descr *type = scr->pcs.type; | |
406 | struct egavga_font *f1, *f2; | 409 | struct egavga_font *f1, *f2; | |
407 | 410 | |||
408 | f1 = egavga_getfont(vc, scr, name1, 1); | 411 | f1 = egavga_getfont(vc, scr, name1, 1); | |
409 | if (!f1) | 412 | if (!f1) | |
410 | return (ENXIO); | 413 | return (ENXIO); | |
411 | 414 | |||
412 | if (VGA_SCREEN_CANTWOFONTS(type) && name2) { | 415 | if (VGA_SCREEN_CANTWOFONTS(type) && name2) { | |
413 | f2 = egavga_getfont(vc, scr, name2, 0); | 416 | f2 = egavga_getfont(vc, scr, name2, 0); | |
414 | if (!f2) { | 417 | if (!f2) { | |
415 | egavga_unreffont(vc, f1); | 418 | egavga_unreffont(vc, f1); | |
416 | return (ENXIO); | 419 | return (ENXIO); | |
417 | } | 420 | } | |
418 | } else | 421 | } else | |
419 | f2 = 0; | 422 | f2 = 0; | |
420 | 423 | |||
421 | #ifdef VGAFONTDEBUG | 424 | #ifdef VGAFONTDEBUG | |
422 | if (scr != &vga_console_screen || vga_console_attached) { | 425 | if (scr != &vga_console_screen || vga_console_attached) { | |
423 | printf("vga (%s): font1=%s (slot %d)", type->name, | 426 | printf("vga (%s): font1=%s (slot %d)", type->name, | |
424 | f1->wsfont->name, f1->slot); | 427 | f1->wsfont->name, f1->slot); | |
425 | if (f2) | 428 | if (f2) | |
426 | printf(", font2=%s (slot %d)", | 429 | printf(", font2=%s (slot %d)", | |
427 | f2->wsfont->name, f2->slot); | 430 | f2->wsfont->name, f2->slot); | |
428 | printf("\n"); | 431 | printf("\n"); | |
429 | } | 432 | } | |
430 | #endif | 433 | #endif | |
431 | if (scr->fontset1) | 434 | if (scr->fontset1) | |
432 | egavga_unreffont(vc, scr->fontset1); | 435 | egavga_unreffont(vc, scr->fontset1); | |
433 | scr->fontset1 = f1; | 436 | scr->fontset1 = f1; | |
434 | if (scr->fontset2) | 437 | if (scr->fontset2) | |
435 | egavga_unreffont(vc, scr->fontset2); | 438 | egavga_unreffont(vc, scr->fontset2); | |
436 | scr->fontset2 = f2; | 439 | scr->fontset2 = f2; | |
437 | return (0); | 440 | return (0); | |
438 | } | 441 | } | |
439 | 442 | |||
440 | void | 443 | static void | |
441 | vga_init_screen(struct vga_config *vc, struct vgascreen *scr, | 444 | vga_init_screen(struct vga_config *vc, struct vgascreen *scr, | |
442 | const struct wsscreen_descr *type, int existing, long *attrp) | 445 | const struct wsscreen_descr *type, int existing, long *attrp) | |
443 | { | 446 | { | |
444 | int cpos; | 447 | int cpos; | |
445 | int res; | 448 | int res; | |
446 | 449 | |||
447 | scr->cfg = vc; | 450 | scr->cfg = vc; | |
448 | scr->pcs.hdl = (struct pcdisplay_handle *)&vc->hdl; | 451 | scr->pcs.hdl = (struct pcdisplay_handle *)&vc->hdl; | |
449 | scr->pcs.type = type; | 452 | scr->pcs.type = type; | |
450 | scr->pcs.active = existing; | 453 | scr->pcs.active = existing; | |
451 | scr->mindispoffset = 0; | 454 | scr->mindispoffset = 0; | |
452 | if (vc->vc_quirks & VGA_QUIRK_NOFASTSCROLL) | 455 | if (vc->vc_quirks & VGA_QUIRK_NOFASTSCROLL) | |
453 | scr->maxdispoffset = 0; | 456 | scr->maxdispoffset = 0; | |
454 | else | 457 | else | |
455 | scr->maxdispoffset = 0x8000 - type->nrows * type->ncols * 2; | 458 | scr->maxdispoffset = 0x8000 - type->nrows * type->ncols * 2; | |
456 | 459 | |||
457 | if (existing) { | 460 | if (existing) { | |
458 | vc->active = scr; | 461 | vc->active = scr; | |
459 | 462 | |||
460 | cpos = vga_6845_read(&vc->hdl, cursorh) << 8; | 463 | cpos = vga_6845_read(&vc->hdl, cursorh) << 8; | |
461 | cpos |= vga_6845_read(&vc->hdl, cursorl); | 464 | cpos |= vga_6845_read(&vc->hdl, cursorl); | |
462 | 465 | |||
463 | /* make sure we have a valid cursor position */ | 466 | /* make sure we have a valid cursor position */ | |
464 | if (cpos < 0 || cpos >= type->nrows * type->ncols) | 467 | if (cpos < 0 || cpos >= type->nrows * type->ncols) | |
465 | cpos = 0; | 468 | cpos = 0; | |
466 | 469 | |||
467 | scr->pcs.dispoffset = vga_6845_read(&vc->hdl, startadrh) << 9; | 470 | scr->pcs.dispoffset = vga_6845_read(&vc->hdl, startadrh) << 9; | |
468 | scr->pcs.dispoffset |= vga_6845_read(&vc->hdl, startadrl) << 1; | 471 | scr->pcs.dispoffset |= vga_6845_read(&vc->hdl, startadrl) << 1; | |
469 | 472 | |||
470 | /* make sure we have a valid memory offset */ | 473 | /* make sure we have a valid memory offset */ | |
471 | if (scr->pcs.dispoffset < scr->mindispoffset || | 474 | if (scr->pcs.dispoffset < scr->mindispoffset || | |
472 | scr->pcs.dispoffset > scr->maxdispoffset) | 475 | scr->pcs.dispoffset > scr->maxdispoffset) | |
473 | scr->pcs.dispoffset = scr->mindispoffset; | 476 | scr->pcs.dispoffset = scr->mindispoffset; | |
474 | 477 | |||
475 | if (type != vc->currenttype) { | 478 | if (type != vc->currenttype) { | |
476 | vga_setscreentype(&vc->hdl, type); | 479 | vga_setscreentype(&vc->hdl, type); | |
477 | vc->currenttype = type; | 480 | vc->currenttype = type; | |
478 | } | 481 | } | |
479 | } else { | 482 | } else { | |
480 | cpos = 0; | 483 | cpos = 0; | |
481 | scr->pcs.dispoffset = scr->mindispoffset; | 484 | scr->pcs.dispoffset = scr->mindispoffset; | |
482 | } | 485 | } | |
483 | 486 | |||
484 | scr->pcs.visibleoffset = scr->pcs.dispoffset; | 487 | scr->pcs.visibleoffset = scr->pcs.dispoffset; | |
485 | scr->vga_rollover = 0; | 488 | scr->vga_rollover = 0; | |
486 | 489 | |||
487 | scr->pcs.cursorrow = cpos / type->ncols; | 490 | scr->pcs.cursorrow = cpos / type->ncols; | |
488 | scr->pcs.cursorcol = cpos % type->ncols; | 491 | scr->pcs.cursorcol = cpos % type->ncols; | |
489 | pcdisplay_cursor_init(&scr->pcs, existing); | 492 | pcdisplay_cursor_init(&scr->pcs, existing); | |
490 | 493 | |||
491 | #ifdef __alpha__ | 494 | #ifdef __alpha__ | |
492 | if (!vc->hdl.vh_mono) | 495 | if (!vc->hdl.vh_mono) | |
493 | /* | 496 | /* | |
494 | * DEC firmware uses a blue background. | 497 | * DEC firmware uses a blue background. | |
495 | * XXX These should be specified as kernel options for | 498 | * XXX These should be specified as kernel options for | |
496 | * XXX alpha only, not hardcoded here (which is wrong | 499 | * XXX alpha only, not hardcoded here (which is wrong | |
497 | * XXX anyway because the emulation layer will assume | 500 | * XXX anyway because the emulation layer will assume | |
498 | * XXX the default attribute is white on black). | 501 | * XXX the default attribute is white on black). | |
499 | */ | 502 | */ | |
500 | res = vga_allocattr(scr, WSCOL_WHITE, WSCOL_BLUE, | 503 | res = vga_allocattr(scr, WSCOL_WHITE, WSCOL_BLUE, | |
501 | WSATTR_WSCOLORS, attrp); | 504 | WSATTR_WSCOLORS, attrp); | |
502 | else | 505 | else | |
503 | #endif | 506 | #endif | |
504 | res = vga_allocattr(scr, 0, 0, 0, attrp); | 507 | res = vga_allocattr(scr, 0, 0, 0, attrp); | |
505 | #ifdef DIAGNOSTIC | 508 | #ifdef DIAGNOSTIC | |
506 | if (res) | 509 | if (res) | |
507 | panic("vga_init_screen: attribute botch"); | 510 | panic("vga_init_screen: attribute botch"); | |
508 | #endif | 511 | #endif | |
509 | 512 | |||
510 | scr->pcs.mem = NULL; | 513 | scr->pcs.mem = NULL; | |
511 | 514 | |||
512 | scr->fontset1 = scr->fontset2 = 0; | 515 | scr->fontset1 = scr->fontset2 = 0; | |
513 | if (vga_selectfont(vc, scr, 0, 0)) { | 516 | if (vga_selectfont(vc, scr, 0, 0)) { | |
514 | if (scr == &vga_console_screen) | 517 | if (scr == &vga_console_screen) | |
515 | panic("vga_init_screen: no font"); | 518 | panic("vga_init_screen: no font"); | |
516 | else | 519 | else | |
517 | printf("vga_init_screen: no font\n"); | 520 | printf("vga_init_screen: no font\n"); | |
518 | } | 521 | } | |
519 | if (existing) | 522 | if (existing) | |
520 | vga_setfont(vc, scr); | 523 | vga_setfont(vc, scr); | |
521 | 524 | |||
522 | vc->nscreens++; | 525 | vc->nscreens++; | |
523 | LIST_INSERT_HEAD(&vc->screens, scr, next); | 526 | LIST_INSERT_HEAD(&vc->screens, scr, next); | |
524 | } | 527 | } | |
525 | 528 | |||
526 | void | 529 | static void | |
527 | vga_init(struct vga_config *vc, bus_space_tag_t iot, bus_space_tag_t memt) | 530 | vga_init(struct vga_config *vc, bus_space_tag_t iot, bus_space_tag_t memt) | |
528 | { | 531 | { | |
529 | struct vga_handle *vh = &vc->hdl; | 532 | struct vga_handle *vh = &vc->hdl; | |
530 | uint8_t mor; | 533 | uint8_t mor; | |
531 | int i; | 534 | int i; | |
532 | 535 | |||
533 | vh->vh_iot = iot; | 536 | vh->vh_iot = iot; | |
534 | vh->vh_memt = memt; | 537 | vh->vh_memt = memt; | |
535 | 538 | |||
536 | if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) | 539 | if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) | |
537 | panic("vga_init: couldn't map vga io"); | 540 | panic("vga_init: couldn't map vga io"); | |
538 | 541 | |||
539 | /* read "misc output register" */ | 542 | /* read "misc output register" */ | |
540 | mor = vga_raw_read(vh, VGA_MISC_DATAR); | 543 | mor = vga_raw_read(vh, VGA_MISC_DATAR); | |
541 | vh->vh_mono = !(mor & 1); | 544 | vh->vh_mono = !(mor & 1); | |
542 | 545 | |||
543 | if (bus_space_map(vh->vh_iot, (vh->vh_mono ? 0x3b0 : 0x3d0), 0x10, 0, | 546 | if (bus_space_map(vh->vh_iot, (vh->vh_mono ? 0x3b0 : 0x3d0), 0x10, 0, | |
544 | &vh->vh_ioh_6845)) | 547 | &vh->vh_ioh_6845)) | |
545 | panic("vga_init: couldn't map 6845 io"); | 548 | panic("vga_init: couldn't map 6845 io"); | |
546 | 549 | |||
547 | if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh)) | 550 | if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh)) | |
548 | panic("vga_init: couldn't map memory"); | 551 | panic("vga_init: couldn't map memory"); | |
549 | 552 | |||
550 | if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh, | 553 | if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh, | |
551 | (vh->vh_mono ? 0x10000 : 0x18000), 0x8000, &vh->vh_memh)) | 554 | (vh->vh_mono ? 0x10000 : 0x18000), 0x8000, &vh->vh_memh)) | |
552 | panic("vga_init: mem subrange failed"); | 555 | panic("vga_init: mem subrange failed"); | |
553 | 556 | |||
554 | /* should only reserve the space (no need to map - save KVM) */ | 557 | /* should only reserve the space (no need to map - save KVM) */ | |
555 | vc->vc_biostag = memt; | 558 | vc->vc_biostag = memt; | |
556 | if (bus_space_map(vc->vc_biostag, 0xc0000, 0x8000, 0, &vc->vc_bioshdl)) | 559 | if (bus_space_map(vc->vc_biostag, 0xc0000, 0x8000, 0, &vc->vc_bioshdl)) | |
557 | vc->vc_biosmapped = 0; | 560 | vc->vc_biosmapped = 0; | |
558 | else | 561 | else | |
559 | vc->vc_biosmapped = 1; | 562 | vc->vc_biosmapped = 1; | |
560 | 563 | |||
561 | vc->nscreens = 0; | 564 | vc->nscreens = 0; | |
562 | LIST_INIT(&vc->screens); | 565 | LIST_INIT(&vc->screens); | |
563 | vc->active = NULL; | 566 | vc->active = NULL; | |
564 | vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen; | 567 | vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen; | |
565 | callout_init(&vc->vc_switch_callout, 0); | 568 | callout_init(&vc->vc_switch_callout, 0); | |
566 | 569 | |||
567 | wsfont_init(); | 570 | wsfont_init(); | |
568 | if (vga_no_builtinfont) { | 571 | if (vga_no_builtinfont) { | |
569 | struct wsdisplay_font *wf; | 572 | struct wsdisplay_font *wf; | |
570 | int cookie; | 573 | int cookie; | |
571 | 574 | |||
572 | cookie = wsfont_find(NULL, 8, 16, 0, | 575 | cookie = wsfont_find(NULL, 8, 16, 0, | |
573 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | 576 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | |
574 | if (cookie == -1 || wsfont_lock(cookie, &wf)) | 577 | if (cookie == -1 || wsfont_lock(cookie, &wf)) | |
575 | panic("vga_init: can't load console font"); | 578 | panic("vga_init: can't load console font"); | |
576 | vga_loadchars(&vc->hdl, 0, wf->firstchar, wf->numchars, | 579 | vga_loadchars(&vc->hdl, 0, wf->firstchar, wf->numchars, | |
577 | wf->fontheight, wf->data); | 580 | wf->fontheight, wf->data); | |
578 | vga_builtinfont.wsfont = wf; | 581 | vga_builtinfont.wsfont = wf; | |
579 | vga_builtinfont.cookie = cookie; | 582 | vga_builtinfont.cookie = cookie; | |
580 | vga_builtinfont.slot = 0; | 583 | vga_builtinfont.slot = 0; | |
581 | } | 584 | } | |
582 | vc->vc_fonts[0] = &vga_builtinfont; | 585 | vc->vc_fonts[0] = &vga_builtinfont; | |
583 | for (i = 1; i < 8; i++) | 586 | for (i = 1; i < 8; i++) | |
584 | vc->vc_fonts[i] = 0; | 587 | vc->vc_fonts[i] = 0; | |
585 | TAILQ_INIT(&vc->vc_fontlist); | 588 | TAILQ_INIT(&vc->vc_fontlist); | |
586 | TAILQ_INSERT_HEAD(&vc->vc_fontlist, &vga_builtinfont, next); | 589 | TAILQ_INSERT_HEAD(&vc->vc_fontlist, &vga_builtinfont, next); | |
587 | 590 | |||
588 | vc->currentfontset1 = vc->currentfontset2 = 0; | 591 | vc->currentfontset1 = vc->currentfontset2 = 0; | |
589 | 592 | |||
590 | if (!vh->vh_mono && (u_int)WSDISPLAY_BORDER_COLOR < sizeof(fgansitopc)) | 593 | if (!vh->vh_mono && (u_int)WSDISPLAY_BORDER_COLOR < sizeof(fgansitopc)) | |
591 | _vga_attr_write(vh, VGA_ATC_OVERSCAN, | 594 | _vga_attr_write(vh, VGA_ATC_OVERSCAN, | |
592 | fgansitopc[WSDISPLAY_BORDER_COLOR]); | 595 | fgansitopc[WSDISPLAY_BORDER_COLOR]); | |
593 | vga_save_palette(vc); | 596 | vga_save_palette(vc); | |
594 | } | 597 | } | |
595 | 598 | |||
596 | void | 599 | void | |
597 | vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot, | 600 | vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot, | |
598 | bus_space_tag_t memt, int type, int quirks, | 601 | bus_space_tag_t memt, int type, int quirks, | |
599 | const struct vga_funcs *vf) | 602 | const struct vga_funcs *vf) | |
600 | { | 603 | { | |
601 | int console; | 604 | int console; | |
602 | struct vga_config *vc; | 605 | struct vga_config *vc; | |
603 | struct wsemuldisplaydev_attach_args aa; | 606 | struct wsemuldisplaydev_attach_args aa; | |
604 | 607 | |||
605 | console = vga_is_console(iot, type); | 608 | console = vga_is_console(iot, type); | |
606 | 609 | |||
607 | if (console) { | 610 | if (console) { | |
608 | vc = &vga_console_vc; | 611 | vc = &vga_console_vc; | |
609 | vga_console_attached = 1; | 612 | vga_console_attached = 1; | |
610 | } else { | 613 | } else { | |
611 | vc = malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK); | 614 | vc = malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK); | |
612 | vga_init(vc, iot, memt); | 615 | vga_init(vc, iot, memt); | |
613 | } | 616 | } | |
614 | 617 | |||
615 | if (quirks & VGA_QUIRK_ONEFONT) { | 618 | if (quirks & VGA_QUIRK_ONEFONT) { | |
616 | vc->vc_nfontslots = 1; | 619 | vc->vc_nfontslots = 1; | |
617 | #ifndef VGA_CONSOLE_ATI_BROKEN_FONTSEL | 620 | #ifndef VGA_CONSOLE_ATI_BROKEN_FONTSEL | |
618 | /* | 621 | /* | |
619 | * XXX maybe invalidate font in slot > 0, but this can | 622 | * XXX maybe invalidate font in slot > 0, but this can | |
620 | * only be happen with VGA_CONSOLE_SCREENTYPE, and then | 623 | * only be happen with VGA_CONSOLE_SCREENTYPE, and then | |
621 | * we require VGA_CONSOLE_ATI_BROKEN_FONTSEL anyway. | 624 | * we require VGA_CONSOLE_ATI_BROKEN_FONTSEL anyway. | |
622 | */ | 625 | */ | |
623 | #endif | 626 | #endif | |
624 | } else { | 627 | } else { | |
625 | vc->vc_nfontslots = 8; | 628 | vc->vc_nfontslots = 8; | |
626 | #ifndef VGA_CONSOLE_ATI_BROKEN_FONTSEL | 629 | #ifndef VGA_CONSOLE_ATI_BROKEN_FONTSEL | |
627 | /* | 630 | /* | |
628 | * XXX maybe validate builtin font shifted to slot 1 if | 631 | * XXX maybe validate builtin font shifted to slot 1 if | |
629 | * slot 0 got overwritten because of VGA_CONSOLE_SCREENTYPE, | 632 | * slot 0 got overwritten because of VGA_CONSOLE_SCREENTYPE, | |
630 | * but it will be reloaded anyway if needed. | 633 | * but it will be reloaded anyway if needed. | |
631 | */ | 634 | */ | |
632 | #endif | 635 | #endif | |
633 | } | 636 | } | |
634 | 637 | |||
635 | /* | 638 | /* | |
636 | * Save the builtin font to memory. In case it got overwritten | 639 | * Save the builtin font to memory. In case it got overwritten | |
637 | * in console initialization, use the copy in slot 1. | 640 | * in console initialization, use the copy in slot 1. | |
638 | */ | 641 | */ | |
639 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | 642 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | |
640 | #define BUILTINFONTLOC (vga_builtinfont.slot == -1 ? 1 : 0) | 643 | #define BUILTINFONTLOC (vga_builtinfont.slot == -1 ? 1 : 0) | |
641 | #else | 644 | #else | |
642 | KASSERT(vga_builtinfont.slot == 0); | 645 | KASSERT(vga_builtinfont.slot == 0); | |
643 | #define BUILTINFONTLOC (0) | 646 | #define BUILTINFONTLOC (0) | |
644 | #endif | 647 | #endif | |
645 | if (!vga_no_builtinfont) { | 648 | if (!vga_no_builtinfont) { | |
646 | char *data = | 649 | char *data = | |
647 | malloc(256 * vga_builtinfont.wsfont->fontheight, | 650 | malloc(256 * vga_builtinfont.wsfont->fontheight, | |
648 | M_DEVBUF, M_WAITOK); | 651 | M_DEVBUF, M_WAITOK); | |
649 | vga_readoutchars(&vc->hdl, BUILTINFONTLOC, 0, 256, | 652 | vga_readoutchars(&vc->hdl, BUILTINFONTLOC, 0, 256, | |
650 | vga_builtinfont.wsfont->fontheight, data); | 653 | vga_builtinfont.wsfont->fontheight, data); | |
651 | vga_builtinfont.wsfont->data = data; | 654 | vga_builtinfont.wsfont->data = data; | |
652 | } | 655 | } | |
653 | 656 | |||
654 | vc->vc_type = type; | 657 | vc->vc_type = type; | |
655 | vc->vc_funcs = vf; | 658 | vc->vc_funcs = vf; | |
656 | vc->vc_quirks = quirks; | 659 | vc->vc_quirks = quirks; | |
657 | 660 | |||
658 | sc->sc_vc = vc; | 661 | sc->sc_vc = vc; | |
659 | vc->softc = sc; | 662 | vc->softc = sc; | |
660 | 663 | |||
661 | aa.console = console; | 664 | aa.console = console; | |
662 | aa.scrdata = (vc->hdl.vh_mono ? &vga_screenlist_mono : &vga_screenlist); | 665 | aa.scrdata = (vc->hdl.vh_mono ? &vga_screenlist_mono : &vga_screenlist); | |
663 | aa.accessops = &vga_accessops; | 666 | aa.accessops = &vga_accessops; | |
664 | aa.accesscookie = vc; | 667 | aa.accesscookie = vc; | |
665 | 668 | |||
666 | config_found_ia(sc->sc_dev, "wsemuldisplaydev", &aa, wsemuldisplaydevprint); | 669 | config_found_ia(sc->sc_dev, "wsemuldisplaydev", &aa, wsemuldisplaydevprint); | |
667 | } | 670 | } | |
668 | 671 | |||
669 | int | 672 | int | |
670 | vga_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check) | 673 | vga_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check) | |
671 | { | 674 | { | |
672 | long defattr; | 675 | long defattr; | |
673 | const struct wsscreen_descr *scr; | 676 | const struct wsscreen_descr *scr; | |
674 | 677 | |||
675 | if (check && !vga_common_probe(iot, memt)) | 678 | if (check && !vga_common_probe(iot, memt)) | |
676 | return (ENXIO); | 679 | return (ENXIO); | |
677 | 680 | |||
678 | /* set up bus-independent VGA configuration */ | 681 | /* set up bus-independent VGA configuration */ | |
679 | vga_init(&vga_console_vc, iot, memt); | 682 | vga_init(&vga_console_vc, iot, memt); | |
680 | #ifdef VGA_CONSOLE_SCREENTYPE | 683 | #ifdef VGA_CONSOLE_SCREENTYPE | |
681 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | 684 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | |
682 | &vga_screenlist_mono : &vga_screenlist, VGA_CONSOLE_SCREENTYPE); | 685 | &vga_screenlist_mono : &vga_screenlist, VGA_CONSOLE_SCREENTYPE); | |
683 | if (!scr) | 686 | if (!scr) | |
684 | panic("vga_cnattach: invalid screen type"); | 687 | panic("vga_cnattach: invalid screen type"); | |
685 | #else | 688 | #else | |
686 | scr = vga_console_vc.currenttype; | 689 | scr = vga_console_vc.currenttype; | |
687 | #endif | 690 | #endif | |
688 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | 691 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | |
689 | /* | 692 | /* | |
690 | * On some (most/all?) ATI cards, only font slot 0 is usable. | 693 | * On some (most/all?) ATI cards, only font slot 0 is usable. | |
691 | * vga_init_screen() might need font slot 0 for a non-default | 694 | * vga_init_screen() might need font slot 0 for a non-default | |
692 | * console font, so save the builtin VGA font to another font slot. | 695 | * console font, so save the builtin VGA font to another font slot. | |
693 | * The attach() code will take care later. | 696 | * The attach() code will take care later. | |
694 | */ | 697 | */ | |
695 | vga_console_vc.vc_quirks |= VGA_QUIRK_ONEFONT; /* redundant */ | 698 | vga_console_vc.vc_quirks |= VGA_QUIRK_ONEFONT; /* redundant */ | |
696 | vga_copyfont01(&vga_console_vc.hdl); | 699 | vga_copyfont01(&vga_console_vc.hdl); | |
697 | vga_console_vc.vc_nfontslots = 1; | 700 | vga_console_vc.vc_nfontslots = 1; | |
698 | #else | 701 | #else | |
699 | vga_console_vc.vc_nfontslots = 8; | 702 | vga_console_vc.vc_nfontslots = 8; | |
700 | #endif | 703 | #endif | |
701 | #ifdef notdef | 704 | #ifdef notdef | |
702 | /* until we know better, assume "fast scrolling" does not work */ | 705 | /* until we know better, assume "fast scrolling" does not work */ | |
703 | vga_console_vc.vc_quirks |= VGA_QUIRK_NOFASTSCROLL; | 706 | vga_console_vc.vc_quirks |= VGA_QUIRK_NOFASTSCROLL; | |
704 | #endif | 707 | #endif | |
705 | 708 | |||
706 | vga_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, &defattr); | 709 | vga_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, &defattr); | |
707 | 710 | |||
708 | wsdisplay_cnattach(scr, &vga_console_screen, | 711 | wsdisplay_cnattach(scr, &vga_console_screen, | |
709 | vga_console_screen.pcs.cursorcol, | 712 | vga_console_screen.pcs.cursorcol, | |
710 | vga_console_screen.pcs.cursorrow, defattr); | 713 | vga_console_screen.pcs.cursorrow, defattr); | |
711 | 714 | |||
712 | vgaconsole = 1; | 715 | vgaconsole = 1; | |
713 | vga_console_type = type; | 716 | vga_console_type = type; | |
714 | return (0); | 717 | return (0); | |
715 | } | 718 | } | |
716 | 719 | |||
717 | int | 720 | int | |
718 | vga_cndetach(void) | 721 | vga_cndetach(void) | |
719 | { | 722 | { | |
720 | struct vga_config *vc; | 723 | struct vga_config *vc; | |
721 | struct vga_handle *vh; | 724 | struct vga_handle *vh; | |
722 | 725 | |||
723 | vc = &vga_console_vc; | 726 | vc = &vga_console_vc; | |
724 | vh = &vc->hdl; | 727 | vh = &vc->hdl; | |
725 | 728 | |||
726 | if (vgaconsole) { | 729 | if (vgaconsole) { | |
727 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_vga, 0x10); | 730 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_vga, 0x10); | |
728 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10); | 731 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10); | |
729 | 732 | |||
730 | return 1; | 733 | return 1; | |
731 | } | 734 | } | |
732 | 735 | |||
733 | return 0; | 736 | return 0; | |
734 | } | 737 | } | |
735 | 738 | |||
736 | int | 739 | int | |
737 | vga_is_console(bus_space_tag_t iot, int type) | 740 | vga_is_console(bus_space_tag_t iot, int type) | |
738 | { | 741 | { | |
739 | if (vgaconsole && | 742 | if (vgaconsole && | |
740 | !vga_console_attached && | 743 | !vga_console_attached && | |
741 | bus_space_is_equal(iot, vga_console_vc.hdl.vh_iot) && | 744 | bus_space_is_equal(iot, vga_console_vc.hdl.vh_iot) && | |
742 | (vga_console_type == -1 || (type == vga_console_type))) | 745 | (vga_console_type == -1 || (type == vga_console_type))) | |
743 | return (1); | 746 | return (1); | |
744 | return (0); | 747 | return (0); | |
745 | } | 748 | } | |
746 | 749 | |||
747 | static int | 750 | static int | |
748 | vga_get_video(struct vga_config *vc) | 751 | vga_get_video(struct vga_config *vc) | |
749 | { | 752 | { | |
750 | 753 | |||
751 | return (vga_ts_read(&vc->hdl, mode) & VGA_TS_MODE_BLANK) == 0; | 754 | return (vga_ts_read(&vc->hdl, mode) & VGA_TS_MODE_BLANK) == 0; | |
752 | } | 755 | } | |
753 | 756 | |||
754 | static void | 757 | static void | |
755 | vga_set_video(struct vga_config *vc, int state) | 758 | vga_set_video(struct vga_config *vc, int state) | |
756 | { | 759 | { | |
757 | int val; | 760 | int val; | |
758 | 761 | |||
759 | vga_ts_write(&vc->hdl, syncreset, 0x01); | 762 | vga_ts_write(&vc->hdl, syncreset, 0x01); | |
760 | if (state) { /* unblank screen */ | 763 | if (state) { /* unblank screen */ | |
761 | val = vga_ts_read(&vc->hdl, mode); | 764 | val = vga_ts_read(&vc->hdl, mode); | |
762 | vga_ts_write(&vc->hdl, mode, val & ~VGA_TS_MODE_BLANK); | 765 | vga_ts_write(&vc->hdl, mode, val & ~VGA_TS_MODE_BLANK); | |
763 | #ifndef VGA_NO_VBLANK | 766 | #ifndef VGA_NO_VBLANK | |
764 | val = vga_6845_read(&vc->hdl, mode); | 767 | val = vga_6845_read(&vc->hdl, mode); | |
765 | vga_6845_write(&vc->hdl, mode, val | 0x80); | 768 | vga_6845_write(&vc->hdl, mode, val | 0x80); | |
766 | #endif | 769 | #endif | |
767 | } else { /* blank screen */ | 770 | } else { /* blank screen */ | |
768 | val = vga_ts_read(&vc->hdl, mode); | 771 | val = vga_ts_read(&vc->hdl, mode); | |
769 | vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK); | 772 | vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK); | |
770 | #ifndef VGA_NO_VBLANK | 773 | #ifndef VGA_NO_VBLANK | |
771 | val = vga_6845_read(&vc->hdl, mode); | 774 | val = vga_6845_read(&vc->hdl, mode); | |
772 | vga_6845_write(&vc->hdl, mode, val & ~0x80); | 775 | vga_6845_write(&vc->hdl, mode, val & ~0x80); | |
773 | #endif | 776 | #endif | |
774 | } | 777 | } | |
775 | vga_ts_write(&vc->hdl, syncreset, 0x03); | 778 | vga_ts_write(&vc->hdl, syncreset, 0x03); | |
776 | } | 779 | } | |
777 | 780 | |||
778 | int | 781 | static int | |
779 | vga_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) | 782 | vga_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) | |
780 | { | 783 | { | |
781 | struct vga_config *vc = v; | 784 | struct vga_config *vc = v; | |
782 | struct vgascreen *scr = vs; | 785 | struct vgascreen *scr = vs; | |
783 | const struct vga_funcs *vf = vc->vc_funcs; | 786 | const struct vga_funcs *vf = vc->vc_funcs; | |
784 | 787 | |||
785 | switch (cmd) { | 788 | switch (cmd) { | |
786 | case WSDISPLAYIO_SMODE: | 789 | case WSDISPLAYIO_SMODE: | |
787 | if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) | 790 | if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) | |
788 | vga_restore_palette(vc); | 791 | vga_restore_palette(vc); | |
789 | return 0; | 792 | return 0; | |
790 | 793 | |||
791 | case WSDISPLAYIO_GTYPE: | 794 | case WSDISPLAYIO_GTYPE: | |
792 | *(int *)data = vc->vc_type; | 795 | *(int *)data = vc->vc_type; | |
793 | return 0; | 796 | return 0; | |
794 | 797 | |||
795 | case WSDISPLAYIO_GINFO: | 798 | case WSDISPLAYIO_GINFO: | |
796 | /* XXX should get detailed hardware information here */ | 799 | /* XXX should get detailed hardware information here */ | |
797 | return EPASSTHROUGH; | 800 | return EPASSTHROUGH; | |
798 | 801 | |||
799 | case WSDISPLAYIO_GVIDEO: | 802 | case WSDISPLAYIO_GVIDEO: | |
800 | *(int *)data = (vga_get_video(vc) ? | 803 | *(int *)data = (vga_get_video(vc) ? | |
801 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF); | 804 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF); | |
802 | return 0; | 805 | return 0; | |
803 | 806 | |||
804 | case WSDISPLAYIO_SVIDEO: | 807 | case WSDISPLAYIO_SVIDEO: | |
805 | vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON); | 808 | vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON); | |
806 | return 0; | 809 | return 0; | |
807 | 810 | |||
808 | case WSDISPLAYIO_GETWSCHAR: | 811 | case WSDISPLAYIO_GETWSCHAR: | |
809 | KASSERT(scr != NULL); | 812 | KASSERT(scr != NULL); | |
810 | return pcdisplay_getwschar(&scr->pcs, | 813 | return pcdisplay_getwschar(&scr->pcs, | |
811 | (struct wsdisplay_char *)data); | 814 | (struct wsdisplay_char *)data); | |
812 | 815 | |||
813 | case WSDISPLAYIO_PUTWSCHAR: | 816 | case WSDISPLAYIO_PUTWSCHAR: | |
814 | KASSERT(scr != NULL); | 817 | KASSERT(scr != NULL); | |
815 | return pcdisplay_putwschar(&scr->pcs, | 818 | return pcdisplay_putwschar(&scr->pcs, | |
816 | (struct wsdisplay_char *)data); | 819 | (struct wsdisplay_char *)data); | |
817 | 820 | |||
818 | #ifdef WSDISPLAY_CUSTOM_BORDER | 821 | #ifdef WSDISPLAY_CUSTOM_BORDER | |
819 | case WSDISPLAYIO_GBORDER: | 822 | case WSDISPLAYIO_GBORDER: | |
820 | return (vga_getborder(vc, (u_int *)data)); | 823 | return (vga_getborder(vc, (u_int *)data)); | |
821 | 824 | |||
822 | case WSDISPLAYIO_SBORDER: | 825 | case WSDISPLAYIO_SBORDER: | |
823 | return (vga_setborder(vc, *(u_int *)data)); | 826 | return (vga_setborder(vc, *(u_int *)data)); | |
824 | #endif | 827 | #endif | |
825 | 828 | |||
826 | case WSDISPLAYIO_GETCMAP: | 829 | case WSDISPLAYIO_GETCMAP: | |
827 | case WSDISPLAYIO_PUTCMAP: | 830 | case WSDISPLAYIO_PUTCMAP: | |
828 | case WSDISPLAYIO_GCURPOS: | 831 | case WSDISPLAYIO_GCURPOS: | |
829 | case WSDISPLAYIO_SCURPOS: | 832 | case WSDISPLAYIO_SCURPOS: | |
830 | case WSDISPLAYIO_GCURMAX: | 833 | case WSDISPLAYIO_GCURMAX: | |
831 | case WSDISPLAYIO_GCURSOR: | 834 | case WSDISPLAYIO_GCURSOR: | |
832 | case WSDISPLAYIO_SCURSOR: | 835 | case WSDISPLAYIO_SCURSOR: | |
833 | /* NONE of these operations are by the generic VGA driver. */ | 836 | /* NONE of these operations are by the generic VGA driver. */ | |
834 | return EPASSTHROUGH; | 837 | return EPASSTHROUGH; | |
835 | } | 838 | } | |
836 | 839 | |||
837 | if (vc->vc_funcs == NULL) | 840 | if (vc->vc_funcs == NULL) | |
838 | return (EPASSTHROUGH); | 841 | return (EPASSTHROUGH); | |
839 | 842 | |||
840 | if (vf->vf_ioctl == NULL) | 843 | if (vf->vf_ioctl == NULL) | |
841 | return (EPASSTHROUGH); | 844 | return (EPASSTHROUGH); | |
842 | 845 | |||
843 | return ((*vf->vf_ioctl)(v, cmd, data, flag, l)); | 846 | return ((*vf->vf_ioctl)(v, cmd, data, flag, l)); | |
844 | } | 847 | } | |
845 | 848 | |||
846 | static paddr_t | 849 | static paddr_t | |
847 | vga_mmap(void *v, void *vs, off_t offset, int prot) | 850 | vga_mmap(void *v, void *vs, off_t offset, int prot) | |
848 | { | 851 | { | |
849 | struct vga_config *vc = v; | 852 | struct vga_config *vc = v; | |
850 | const struct vga_funcs *vf = vc->vc_funcs; | 853 | const struct vga_funcs *vf = vc->vc_funcs; | |
851 | 854 | |||
852 | if (vc->vc_funcs == NULL) | 855 | if (vc->vc_funcs == NULL) | |
853 | return (-1); | 856 | return (-1); | |
854 | 857 | |||
855 | if (vf->vf_mmap == NULL) | 858 | if (vf->vf_mmap == NULL) | |
856 | return (-1); | 859 | return (-1); | |
857 | 860 | |||
858 | return ((*vf->vf_mmap)(v, offset, prot)); | 861 | return ((*vf->vf_mmap)(v, offset, prot)); | |
859 | } | 862 | } | |
860 | 863 | |||
861 | int | 864 | static int | |
862 | vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, | 865 | vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, | |
863 | int *curxp, int *curyp, long *defattrp) | 866 | int *curxp, int *curyp, long *defattrp) | |
864 | { | 867 | { | |
865 | struct vga_config *vc = v; | 868 | struct vga_config *vc = v; | |
866 | struct vgascreen *scr; | 869 | struct vgascreen *scr; | |
867 | 870 | |||
868 | if (vc->nscreens == 1) { | 871 | if (vc->nscreens == 1) { | |
869 | struct vgascreen *scr1 = vc->screens.lh_first; | 872 | struct vgascreen *scr1 = vc->screens.lh_first; | |
870 | /* | 873 | /* | |
871 | * When allocating the second screen, get backing store | 874 | * When allocating the second screen, get backing store | |
872 | * for the first one too. | 875 | * for the first one too. | |
873 | * XXX We could be more clever and use video RAM. | 876 | * XXX We could be more clever and use video RAM. | |
874 | */ | 877 | */ | |
875 | scr1->pcs.mem = | 878 | scr1->pcs.mem = | |
876 | malloc(scr1->pcs.type->ncols * scr1->pcs.type->nrows * 2, | 879 | malloc(scr1->pcs.type->ncols * scr1->pcs.type->nrows * 2, | |
877 | M_DEVBUF, M_WAITOK); | 880 | M_DEVBUF, M_WAITOK); | |
878 | } | 881 | } | |
879 | 882 | |||
880 | scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK); | 883 | scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK); | |
881 | vga_init_screen(vc, scr, type, vc->nscreens == 0, defattrp); | 884 | vga_init_screen(vc, scr, type, vc->nscreens == 0, defattrp); | |
882 | 885 | |||
883 | if (vc->nscreens > 1) { | 886 | if (vc->nscreens > 1) { | |
884 | scr->pcs.mem = malloc(type->ncols * type->nrows * 2, | 887 | scr->pcs.mem = malloc(type->ncols * type->nrows * 2, | |
885 | M_DEVBUF, M_WAITOK); | 888 | M_DEVBUF, M_WAITOK); | |
886 | pcdisplay_eraserows(&scr->pcs, 0, type->nrows, *defattrp); | 889 | pcdisplay_eraserows(&scr->pcs, 0, type->nrows, *defattrp); | |
887 | } | 890 | } | |
888 | 891 | |||
889 | *cookiep = scr; | 892 | *cookiep = scr; | |
890 | *curxp = scr->pcs.cursorcol; | 893 | *curxp = scr->pcs.cursorcol; | |
891 | *curyp = scr->pcs.cursorrow; | 894 | *curyp = scr->pcs.cursorrow; | |
892 | 895 | |||
893 | return (0); | 896 | return (0); | |
894 | } | 897 | } | |
895 | 898 | |||
896 | void | 899 | static void | |
897 | vga_free_screen(void *v, void *cookie) | 900 | vga_free_screen(void *v, void *cookie) | |
898 | { | 901 | { | |
899 | struct vgascreen *vs = cookie; | 902 | struct vgascreen *vs = cookie; | |
900 | struct vga_config *vc = vs->cfg; | 903 | struct vga_config *vc = vs->cfg; | |
901 | 904 | |||
902 | LIST_REMOVE(vs, next); | 905 | LIST_REMOVE(vs, next); | |
903 | vc->nscreens--; | 906 | vc->nscreens--; | |
904 | if (vs->fontset1) | 907 | if (vs->fontset1) | |
905 | egavga_unreffont(vc, vs->fontset1); | 908 | egavga_unreffont(vc, vs->fontset1); | |
906 | if (vs->fontset2) | 909 | if (vs->fontset2) | |
907 | egavga_unreffont(vc, vs->fontset2); | 910 | egavga_unreffont(vc, vs->fontset2); | |
908 | 911 | |||
909 | if (vs != &vga_console_screen) | 912 | if (vs != &vga_console_screen) | |
910 | free(vs, M_DEVBUF); | 913 | free(vs, M_DEVBUF); | |
911 | else | 914 | else | |
912 | panic("vga_free_screen: console"); | 915 | panic("vga_free_screen: console"); | |
913 | 916 | |||
914 | if (vc->active == vs) | 917 | if (vc->active == vs) | |
915 | vc->active = 0; | 918 | vc->active = 0; | |
916 | } | 919 | } | |
917 | 920 | |||
918 | static void vga_usefont(struct vga_config *, struct egavga_font *); | 921 | static void vga_usefont(struct vga_config *, struct egavga_font *); | |
919 | 922 | |||
920 | static void | 923 | static void | |
921 | vga_usefont(struct vga_config *vc, struct egavga_font *f) | 924 | vga_usefont(struct vga_config *vc, struct egavga_font *f) | |
922 | { | 925 | { | |
923 | int slot; | 926 | int slot; | |
924 | struct egavga_font *of; | 927 | struct egavga_font *of; | |
925 | 928 | |||
926 | if (f->slot != -1) | 929 | if (f->slot != -1) | |
927 | goto toend; | 930 | goto toend; | |
928 | 931 | |||
929 | for (slot = 0; slot < vc->vc_nfontslots; slot++) { | 932 | for (slot = 0; slot < vc->vc_nfontslots; slot++) { | |
930 | if (!vc->vc_fonts[slot]) | 933 | if (!vc->vc_fonts[slot]) | |
931 | goto loadit; | 934 | goto loadit; | |
932 | } | 935 | } | |
933 | 936 | |||
934 | /* have to kick out another one */ | 937 | /* have to kick out another one */ | |
935 | TAILQ_FOREACH(of, &vc->vc_fontlist, next) { | 938 | TAILQ_FOREACH(of, &vc->vc_fontlist, next) { | |
936 | if (of->slot != -1) { | 939 | if (of->slot != -1) { | |
937 | KASSERT(vc->vc_fonts[of->slot] == of); | 940 | KASSERT(vc->vc_fonts[of->slot] == of); | |
938 | slot = of->slot; | 941 | slot = of->slot; | |
939 | of->slot = -1; | 942 | of->slot = -1; | |
940 | goto loadit; | 943 | goto loadit; | |
941 | } | 944 | } | |
942 | } | 945 | } | |
943 | panic("vga_usefont"); | 946 | panic("vga_usefont"); | |
944 | 947 | |||
945 | loadit: | 948 | loadit: | |
946 | vga_loadchars(&vc->hdl, slot, f->wsfont->firstchar, | 949 | vga_loadchars(&vc->hdl, slot, f->wsfont->firstchar, | |
947 | f->wsfont->numchars, f->wsfont->fontheight, f->wsfont->data); | 950 | f->wsfont->numchars, f->wsfont->fontheight, f->wsfont->data); | |
948 | f->slot = slot; | 951 | f->slot = slot; | |
949 | vc->vc_fonts[slot] = f; | 952 | vc->vc_fonts[slot] = f; | |
950 | 953 | |||
951 | toend: | 954 | toend: | |
952 | TAILQ_REMOVE(&vc->vc_fontlist, f, next); | 955 | TAILQ_REMOVE(&vc->vc_fontlist, f, next); | |
953 | TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next); | 956 | TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next); | |
954 | } | 957 | } | |
955 | 958 | |||
956 | static void | 959 | static void | |
957 | vga_setfont(struct vga_config *vc, struct vgascreen *scr) | 960 | vga_setfont(struct vga_config *vc, struct vgascreen *scr) | |
958 | { | 961 | { | |
959 | int fontslot1, fontslot2; | 962 | int fontslot1, fontslot2; | |
960 | 963 | |||
961 | if (scr->fontset1) | 964 | if (scr->fontset1) | |
962 | vga_usefont(vc, scr->fontset1); | 965 | vga_usefont(vc, scr->fontset1); | |
963 | if (scr->fontset2) | 966 | if (scr->fontset2) | |
964 | vga_usefont(vc, scr->fontset2); | 967 | vga_usefont(vc, scr->fontset2); | |
965 | 968 | |||
966 | fontslot1 = (scr->fontset1 ? scr->fontset1->slot : 0); | 969 | fontslot1 = (scr->fontset1 ? scr->fontset1->slot : 0); | |
967 | fontslot2 = (scr->fontset2 ? scr->fontset2->slot : fontslot1); | 970 | fontslot2 = (scr->fontset2 ? scr->fontset2->slot : fontslot1); | |
968 | if (vc->currentfontset1 != fontslot1 || | 971 | if (vc->currentfontset1 != fontslot1 || | |
969 | vc->currentfontset2 != fontslot2) { | 972 | vc->currentfontset2 != fontslot2) { | |
970 | vga_setfontset(&vc->hdl, fontslot1, fontslot2); | 973 | vga_setfontset(&vc->hdl, fontslot1, fontslot2); | |
971 | vc->currentfontset1 = fontslot1; | 974 | vc->currentfontset1 = fontslot1; | |
972 | vc->currentfontset2 = fontslot2; | 975 | vc->currentfontset2 = fontslot2; | |
973 | } | 976 | } | |
974 | } | 977 | } | |
975 | 978 | |||
976 | int | 979 | static int | |
977 | vga_show_screen(void *v, void *cookie, int waitok, | 980 | vga_show_screen(void *v, void *cookie, int waitok, | |
978 | void (*cb)(void *, int, int), void *cbarg) | 981 | void (*cb)(void *, int, int), void *cbarg) | |
979 | { | 982 | { | |
980 | struct vgascreen *scr = cookie, *oldscr; | 983 | struct vgascreen *scr = cookie, *oldscr; | |
981 | struct vga_config *vc = scr->cfg; | 984 | struct vga_config *vc = scr->cfg; | |
982 | 985 | |||
983 | oldscr = vc->active; /* can be NULL! */ | 986 | oldscr = vc->active; /* can be NULL! */ | |
984 | if (scr == oldscr) { | 987 | if (scr == oldscr) { | |
985 | return (0); | 988 | return (0); | |
986 | } | 989 | } | |
987 | 990 | |||
988 | vc->wantedscreen = cookie; | 991 | vc->wantedscreen = cookie; | |
989 | vc->switchcb = cb; | 992 | vc->switchcb = cb; | |
990 | vc->switchcbarg = cbarg; | 993 | vc->switchcbarg = cbarg; | |
991 | if (cb) { | 994 | if (cb) { | |
992 | callout_reset(&vc->vc_switch_callout, 0, | 995 | callout_reset(&vc->vc_switch_callout, 0, | |
993 | (void(*)(void *))vga_doswitch, vc); | 996 | (void(*)(void *))vga_doswitch, vc); | |
994 | return (EAGAIN); | 997 | return (EAGAIN); | |
995 | } | 998 | } | |
996 | 999 | |||
997 | vga_doswitch(vc); | 1000 | vga_doswitch(vc); | |
998 | return (0); | 1001 | return (0); | |
999 | } | 1002 | } | |
1000 | 1003 | |||
1001 | void | 1004 | static void | |
1002 | vga_doswitch(struct vga_config *vc) | 1005 | vga_doswitch(struct vga_config *vc) | |
1003 | { | 1006 | { | |
1004 | struct vgascreen *scr, *oldscr; | 1007 | struct vgascreen *scr, *oldscr; | |
1005 | struct vga_handle *vh = &vc->hdl; | 1008 | struct vga_handle *vh = &vc->hdl; | |
1006 | const struct wsscreen_descr *type; | 1009 | const struct wsscreen_descr *type; | |
1007 | 1010 | |||
1008 | scr = vc->wantedscreen; | 1011 | scr = vc->wantedscreen; | |
1009 | if (!scr) { | 1012 | if (!scr) { | |
1010 | printf("vga_doswitch: disappeared\n"); | 1013 | printf("vga_doswitch: disappeared\n"); | |
1011 | (*vc->switchcb)(vc->switchcbarg, EIO, 0); | 1014 | (*vc->switchcb)(vc->switchcbarg, EIO, 0); | |
1012 | return; | 1015 | return; | |
1013 | } | 1016 | } | |
1014 | type = scr->pcs.type; | 1017 | type = scr->pcs.type; | |
1015 | oldscr = vc->active; /* can be NULL! */ | 1018 | oldscr = vc->active; /* can be NULL! */ | |
1016 | #ifdef DIAGNOSTIC | 1019 | #ifdef DIAGNOSTIC | |
1017 | if (oldscr) { | 1020 | if (oldscr) { | |
1018 | if (!oldscr->pcs.active) | 1021 | if (!oldscr->pcs.active) | |
1019 | panic("vga_show_screen: not active"); | 1022 | panic("vga_show_screen: not active"); | |
1020 | if (oldscr->pcs.type != vc->currenttype) | 1023 | if (oldscr->pcs.type != vc->currenttype) | |
1021 | panic("vga_show_screen: bad type"); | 1024 | panic("vga_show_screen: bad type"); | |
1022 | } | 1025 | } | |
1023 | #endif | 1026 | #endif | |
1024 | if (scr == oldscr) { | 1027 | if (scr == oldscr) { | |
1025 | return; | 1028 | return; | |
1026 | } | 1029 | } | |
1027 | #ifdef DIAGNOSTIC | 1030 | #ifdef DIAGNOSTIC | |
1028 | if (scr->pcs.active) | 1031 | if (scr->pcs.active) | |
1029 | panic("vga_show_screen: active"); | 1032 | panic("vga_show_screen: active"); | |
1030 | #endif | 1033 | #endif | |
1031 | 1034 | |||
1032 | if (oldscr) { | 1035 | if (oldscr) { | |
1033 | const struct wsscreen_descr *oldtype = oldscr->pcs.type; | 1036 | const struct wsscreen_descr *oldtype = oldscr->pcs.type; | |
1034 | 1037 | |||
1035 | oldscr->pcs.active = 0; | 1038 | oldscr->pcs.active = 0; | |
1036 | bus_space_read_region_2(vh->vh_memt, vh->vh_memh, | 1039 | bus_space_read_region_2(vh->vh_memt, vh->vh_memh, | |
1037 | oldscr->pcs.dispoffset, oldscr->pcs.mem, | 1040 | oldscr->pcs.dispoffset, oldscr->pcs.mem, | |
1038 | oldtype->ncols * oldtype->nrows); | 1041 | oldtype->ncols * oldtype->nrows); | |
1039 | } | 1042 | } | |
1040 | 1043 | |||
1041 | if (vc->currenttype != type) { | 1044 | if (vc->currenttype != type) { | |
1042 | vga_setscreentype(vh, type); | 1045 | vga_setscreentype(vh, type); | |
1043 | vc->currenttype = type; | 1046 | vc->currenttype = type; | |
1044 | } | 1047 | } | |
1045 | 1048 | |||
1046 | vga_setfont(vc, scr); | 1049 | vga_setfont(vc, scr); | |
1047 | vga_restore_palette(vc); | 1050 | vga_restore_palette(vc); | |
1048 | 1051 | |||
1049 | scr->pcs.visibleoffset = scr->pcs.dispoffset = scr->mindispoffset; | 1052 | scr->pcs.visibleoffset = scr->pcs.dispoffset = scr->mindispoffset; | |
1050 | if (!oldscr || (scr->pcs.dispoffset != oldscr->pcs.dispoffset)) { | 1053 | if (!oldscr || (scr->pcs.dispoffset != oldscr->pcs.dispoffset)) { | |
1051 | vga_6845_write(vh, startadrh, scr->pcs.dispoffset >> 9); | 1054 | vga_6845_write(vh, startadrh, scr->pcs.dispoffset >> 9); | |
1052 | vga_6845_write(vh, startadrl, scr->pcs.dispoffset >> 1); | 1055 | vga_6845_write(vh, startadrl, scr->pcs.dispoffset >> 1); | |
1053 | } | 1056 | } | |
1054 | 1057 | |||
1055 | bus_space_write_region_2(vh->vh_memt, vh->vh_memh, | 1058 | bus_space_write_region_2(vh->vh_memt, vh->vh_memh, | |
1056 | scr->pcs.dispoffset, scr->pcs.mem, type->ncols * type->nrows); | 1059 | scr->pcs.dispoffset, scr->pcs.mem, type->ncols * type->nrows); | |
1057 | scr->pcs.active = 1; | 1060 | scr->pcs.active = 1; | |
1058 | 1061 | |||
1059 | vc->active = scr; | 1062 | vc->active = scr; | |
1060 | 1063 | |||
1061 | pcdisplay_cursor(&scr->pcs, scr->pcs.cursoron, | 1064 | pcdisplay_cursor(&scr->pcs, scr->pcs.cursoron, | |
1062 | scr->pcs.cursorrow, scr->pcs.cursorcol); | 1065 | scr->pcs.cursorrow, scr->pcs.cursorcol); | |
1063 | 1066 | |||
1064 | vc->wantedscreen = 0; | 1067 | vc->wantedscreen = 0; | |
1065 | if (vc->switchcb) | 1068 | if (vc->switchcb) | |
1066 | (*vc->switchcb)(vc->switchcbarg, 0, 0); | 1069 | (*vc->switchcb)(vc->switchcbarg, 0, 0); | |
1067 | } | 1070 | } | |
1068 | 1071 | |||
1069 | static int | 1072 | static int | |
1070 | vga_load_font(void *v, void *cookie, struct wsdisplay_font *data) | 1073 | vga_load_font(void *v, void *cookie, struct wsdisplay_font *data) | |
1071 | { | 1074 | { | |
1072 | struct vga_config *vc = v; | 1075 | struct vga_config *vc = v; | |
1073 | struct vgascreen *scr = cookie; | 1076 | struct vgascreen *scr = cookie; | |
1074 | char *name2; | 1077 | char *name2; | |
1075 | int res; | 1078 | int res; | |
1076 | 1079 | |||
1077 | if (scr) { | 1080 | if (scr) { | |
1078 | name2 = NULL; | 1081 | name2 = NULL; | |
1079 | if (data->name) { | 1082 | if (data->name) { | |
1080 | name2 = strchr(data->name, ','); | 1083 | name2 = strchr(data->name, ','); | |
1081 | if (name2) | 1084 | if (name2) | |
1082 | *name2++ = '\0'; | 1085 | *name2++ = '\0'; | |
1083 | } | 1086 | } | |
1084 | res = vga_selectfont(vc, scr, data->name, name2); | 1087 | res = vga_selectfont(vc, scr, data->name, name2); | |
1085 | if (!res && scr->pcs.active) | 1088 | if (!res && scr->pcs.active) | |
1086 | vga_setfont(vc, scr); | 1089 | vga_setfont(vc, scr); | |
1087 | return (res); | 1090 | return (res); | |
1088 | } | 1091 | } | |
1089 | 1092 | |||
1090 | return (0); | 1093 | return (0); | |
1091 | } | 1094 | } | |
1092 | 1095 | |||
1093 | static int | 1096 | static int | |
1094 | vga_allocattr(void *id, int fg, int bg, int flags, long *attrp) | 1097 | vga_allocattr(void *id, int fg, int bg, int flags, long *attrp) | |
1095 | { | 1098 | { | |
1096 | struct vgascreen *scr = id; | 1099 | struct vgascreen *scr = id; | |
1097 | struct vga_config *vc = scr->cfg; | 1100 | struct vga_config *vc = scr->cfg; | |
1098 | 1101 | |||
1099 | if (__predict_false((unsigned int)fg >= sizeof(fgansitopc) || | 1102 | if (__predict_false((unsigned int)fg >= sizeof(fgansitopc) || | |
1100 | (unsigned int)bg >= sizeof(bgansitopc))) | 1103 | (unsigned int)bg >= sizeof(bgansitopc))) | |
1101 | return (EINVAL); | 1104 | return (EINVAL); | |
1102 | 1105 | |||
1103 | if (vc->hdl.vh_mono) { | 1106 | if (vc->hdl.vh_mono) { | |
1104 | if (flags & WSATTR_WSCOLORS) | 1107 | if (flags & WSATTR_WSCOLORS) | |
1105 | return (EINVAL); | 1108 | return (EINVAL); | |
1106 | if (flags & WSATTR_REVERSE) | 1109 | if (flags & WSATTR_REVERSE) | |
1107 | *attrp = 0x70; | 1110 | *attrp = 0x70; | |
1108 | else | 1111 | else | |
1109 | *attrp = 0x07; | 1112 | *attrp = 0x07; | |
1110 | if (flags & WSATTR_UNDERLINE) | 1113 | if (flags & WSATTR_UNDERLINE) | |
1111 | *attrp |= FG_UNDERLINE; | 1114 | *attrp |= FG_UNDERLINE; | |
1112 | if (flags & WSATTR_HILIT) | 1115 | if (flags & WSATTR_HILIT) | |
1113 | *attrp |= FG_INTENSE; | 1116 | *attrp |= FG_INTENSE; | |
1114 | } else { | 1117 | } else { | |
1115 | if (flags & (WSATTR_UNDERLINE | WSATTR_REVERSE)) | 1118 | if (flags & (WSATTR_UNDERLINE | WSATTR_REVERSE)) | |
1116 | return (EINVAL); | 1119 | return (EINVAL); | |
1117 | if (flags & WSATTR_WSCOLORS) | 1120 | if (flags & WSATTR_WSCOLORS) | |
1118 | *attrp = fgansitopc[fg] | bgansitopc[bg]; | 1121 | *attrp = fgansitopc[fg] | bgansitopc[bg]; | |
1119 | else | 1122 | else | |
1120 | *attrp = 7; | 1123 | *attrp = 7; | |
1121 | if (flags & WSATTR_HILIT) | 1124 | if (flags & WSATTR_HILIT) | |
1122 | *attrp += 8; | 1125 | *attrp += 8; | |
1123 | } | 1126 | } | |
1124 | if (flags & WSATTR_BLINK) | 1127 | if (flags & WSATTR_BLINK) | |
1125 | *attrp |= FG_BLINK; | 1128 | *attrp |= FG_BLINK; | |
1126 | return (0); | 1129 | return (0); | |
1127 | } | 1130 | } | |
1128 | 1131 | |||
1129 | static void | 1132 | static void | |
1130 | vga_copyrows(void *id, int srcrow, int dstrow, int nrows) | 1133 | vga_copyrows(void *id, int srcrow, int dstrow, int nrows) | |
1131 | { | 1134 | { | |
1132 | struct vgascreen *scr = id; | 1135 | struct vgascreen *scr = id; | |
1133 | bus_space_tag_t memt = scr->pcs.hdl->ph_memt; | 1136 | bus_space_tag_t memt = scr->pcs.hdl->ph_memt; | |
1134 | bus_space_handle_t memh = scr->pcs.hdl->ph_memh; | 1137 | bus_space_handle_t memh = scr->pcs.hdl->ph_memh; | |
1135 | int ncols = scr->pcs.type->ncols; | 1138 | int ncols = scr->pcs.type->ncols; | |
1136 | bus_size_t srcoff, dstoff; | 1139 | bus_size_t srcoff, dstoff; | |
1137 | 1140 | |||
1138 | srcoff = srcrow * ncols + 0; | 1141 | srcoff = srcrow * ncols + 0; | |
1139 | dstoff = dstrow * ncols + 0; | 1142 | dstoff = dstrow * ncols + 0; | |
1140 | 1143 | |||
1141 | if (scr->pcs.active) { | 1144 | if (scr->pcs.active) { | |
1142 | if (dstrow == 0 && (srcrow + nrows == scr->pcs.type->nrows)) { | 1145 | if (dstrow == 0 && (srcrow + nrows == scr->pcs.type->nrows)) { | |
1143 | #ifdef PCDISPLAY_SOFTCURSOR | 1146 | #ifdef PCDISPLAY_SOFTCURSOR | |
1144 | int cursoron = scr->pcs.cursoron; | 1147 | int cursoron = scr->pcs.cursoron; | |
1145 | 1148 | |||
1146 | if (cursoron) | 1149 | if (cursoron) | |
1147 | pcdisplay_cursor(&scr->pcs, 0, | 1150 | pcdisplay_cursor(&scr->pcs, 0, | |
1148 | scr->pcs.cursorrow, scr->pcs.cursorcol); | 1151 | scr->pcs.cursorrow, scr->pcs.cursorcol); | |
1149 | #endif | 1152 | #endif | |
1150 | /* scroll up whole screen */ | 1153 | /* scroll up whole screen */ | |
1151 | if ((scr->pcs.dispoffset + srcrow * ncols * 2) | 1154 | if ((scr->pcs.dispoffset + srcrow * ncols * 2) | |
1152 | <= scr->maxdispoffset) { | 1155 | <= scr->maxdispoffset) { | |
1153 | scr->pcs.dispoffset += srcrow * ncols * 2; | 1156 | scr->pcs.dispoffset += srcrow * ncols * 2; | |
1154 | } else { | 1157 | } else { | |
1155 | bus_space_copy_region_2(memt, memh, | 1158 | bus_space_copy_region_2(memt, memh, | |
1156 | scr->pcs.dispoffset + srcoff * 2, | 1159 | scr->pcs.dispoffset + srcoff * 2, | |
1157 | memh, scr->mindispoffset, nrows * ncols); | 1160 | memh, scr->mindispoffset, nrows * ncols); | |
1158 | scr->pcs.dispoffset = scr->mindispoffset; | 1161 | scr->pcs.dispoffset = scr->mindispoffset; | |
1159 | } | 1162 | } | |
1160 | vga_6845_write(&scr->cfg->hdl, startadrh, | 1163 | vga_6845_write(&scr->cfg->hdl, startadrh, | |
1161 | scr->pcs.dispoffset >> 9); | 1164 | scr->pcs.dispoffset >> 9); | |
1162 | vga_6845_write(&scr->cfg->hdl, startadrl, | 1165 | vga_6845_write(&scr->cfg->hdl, startadrl, | |
1163 | scr->pcs.dispoffset >> 1); | 1166 | scr->pcs.dispoffset >> 1); | |
1164 | #ifdef PCDISPLAY_SOFTCURSOR | 1167 | #ifdef PCDISPLAY_SOFTCURSOR | |
1165 | if (cursoron) | 1168 | if (cursoron) | |
1166 | pcdisplay_cursor(&scr->pcs, 1, | 1169 | pcdisplay_cursor(&scr->pcs, 1, | |
1167 | scr->pcs.cursorrow, scr->pcs.cursorcol); | 1170 | scr->pcs.cursorrow, scr->pcs.cursorcol); | |
1168 | #endif | 1171 | #endif | |
1169 | } else { | 1172 | } else { | |
1170 | bus_space_copy_region_2(memt, memh, | 1173 | bus_space_copy_region_2(memt, memh, | |
1171 | scr->pcs.dispoffset + srcoff * 2, | 1174 | scr->pcs.dispoffset + srcoff * 2, | |
1172 | memh, scr->pcs.dispoffset + dstoff * 2, | 1175 | memh, scr->pcs.dispoffset + dstoff * 2, | |
1173 | nrows * ncols); | 1176 | nrows * ncols); | |
1174 | } | 1177 | } | |
1175 | } else | 1178 | } else | |
1176 | memcpy(&scr->pcs.mem[dstoff], &scr->pcs.mem[srcoff], | 1179 | memcpy(&scr->pcs.mem[dstoff], &scr->pcs.mem[srcoff], | |
1177 | nrows * ncols * 2); | 1180 | nrows * ncols * 2); | |
1178 | } | 1181 | } | |
1179 | 1182 | |||
1180 | #ifdef WSCONS_SUPPORT_PCVTFONTS | 1183 | #ifdef WSCONS_SUPPORT_PCVTFONTS | |
1181 | 1184 | |||
1182 | #define NOTYET 0xffff | 1185 | #define NOTYET 0xffff | |
1183 | static const uint16_t pcvt_unichars[0xa0] = { | 1186 | static const uint16_t pcvt_unichars[0xa0] = { | |
1184 | /* 0 */ _e006U, /* N/L control */ | 1187 | /* 0 */ _e006U, /* N/L control */ | |
1185 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1188 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1186 | NOTYET, | 1189 | NOTYET, | |
1187 | 0x2409, /* SYMBOL FOR HORIZONTAL TABULATION */ | 1190 | 0x2409, /* SYMBOL FOR HORIZONTAL TABULATION */ | |
1188 | 0x240a, /* SYMBOL FOR LINE FEED */ | 1191 | 0x240a, /* SYMBOL FOR LINE FEED */ | |
1189 | 0x240b, /* SYMBOL FOR VERTICAL TABULATION */ | 1192 | 0x240b, /* SYMBOL FOR VERTICAL TABULATION */ | |
1190 | 0x240c, /* SYMBOL FOR FORM FEED */ | 1193 | 0x240c, /* SYMBOL FOR FORM FEED */ | |
1191 | 0x240d, /* SYMBOL FOR CARRIAGE RETURN */ | 1194 | 0x240d, /* SYMBOL FOR CARRIAGE RETURN */ | |
1192 | NOTYET, NOTYET, | 1195 | NOTYET, NOTYET, | |
1193 | /* 1 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1196 | /* 1 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1194 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1197 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1195 | /* 2 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1198 | /* 2 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1196 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1199 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1197 | /* 3 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1200 | /* 3 */ NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1198 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | 1201 | NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, NOTYET, | |
1199 | /* 4 */ 0x03c1, /* GREEK SMALL LETTER RHO */ | 1202 | /* 4 */ 0x03c1, /* GREEK SMALL LETTER RHO */ | |
1200 | 0x03c8, /* GREEK SMALL LETTER PSI */ | 1203 | 0x03c8, /* GREEK SMALL LETTER PSI */ | |
1201 | 0x2202, /* PARTIAL DIFFERENTIAL */ | 1204 | 0x2202, /* PARTIAL DIFFERENTIAL */ | |
1202 | 0x03bb, /* GREEK SMALL LETTER LAMDA */ | 1205 | 0x03bb, /* GREEK SMALL LETTER LAMDA */ | |
1203 | 0x03b9, /* GREEK SMALL LETTER IOTA */ | 1206 | 0x03b9, /* GREEK SMALL LETTER IOTA */ | |
1204 | 0x03b7, /* GREEK SMALL LETTER ETA */ | 1207 | 0x03b7, /* GREEK SMALL LETTER ETA */ | |
1205 | 0x03b5, /* GREEK SMALL LETTER EPSILON */ | 1208 | 0x03b5, /* GREEK SMALL LETTER EPSILON */ | |
1206 | 0x03c7, /* GREEK SMALL LETTER CHI */ | 1209 | 0x03c7, /* GREEK SMALL LETTER CHI */ | |
1207 | 0x2228, /* LOGICAL OR */ | 1210 | 0x2228, /* LOGICAL OR */ | |
1208 | 0x2227, /* LOGICAL AND */ | 1211 | 0x2227, /* LOGICAL AND */ | |
1209 | 0x222a, /* UNION */ | 1212 | 0x222a, /* UNION */ | |
1210 | 0x2283, /* SUPERSET OF */ | 1213 | 0x2283, /* SUPERSET OF */ | |
1211 | 0x2282, /* SUBSET OF */ | 1214 | 0x2282, /* SUBSET OF */ | |
1212 | 0x03a5, /* GREEK CAPITAL LETTER UPSILON */ | 1215 | 0x03a5, /* GREEK CAPITAL LETTER UPSILON */ | |
1213 | 0x039e, /* GREEK CAPITAL LETTER XI */ | 1216 | 0x039e, /* GREEK CAPITAL LETTER XI */ | |
1214 | 0x03a8, /* GREEK CAPITAL LETTER PSI */ | 1217 | 0x03a8, /* GREEK CAPITAL LETTER PSI */ | |
1215 | /* 5 */ 0x03a0, /* GREEK CAPITAL LETTER PI */ | 1218 | /* 5 */ 0x03a0, /* GREEK CAPITAL LETTER PI */ | |
1216 | 0x21d2, /* RIGHTWARDS DOUBLE ARROW */ | 1219 | 0x21d2, /* RIGHTWARDS DOUBLE ARROW */ | |
1217 | 0x21d4, /* LEFT RIGHT DOUBLE ARROW */ | 1220 | 0x21d4, /* LEFT RIGHT DOUBLE ARROW */ | |
1218 | 0x039b, /* GREEK CAPITAL LETTER LAMDA */ | 1221 | 0x039b, /* GREEK CAPITAL LETTER LAMDA */ | |
1219 | 0x0398, /* GREEK CAPITAL LETTER THETA */ | 1222 | 0x0398, /* GREEK CAPITAL LETTER THETA */ | |
1220 | 0x2243, /* ASYMPTOTICALLY EQUAL TO */ | 1223 | 0x2243, /* ASYMPTOTICALLY EQUAL TO */ | |
1221 | 0x2207, /* NABLA */ | 1224 | 0x2207, /* NABLA */ | |
1222 | 0x2206, /* INCREMENT */ | 1225 | 0x2206, /* INCREMENT */ | |
1223 | 0x221d, /* PROPORTIONAL TO */ | 1226 | 0x221d, /* PROPORTIONAL TO */ | |
1224 | 0x2234, /* THEREFORE */ | 1227 | 0x2234, /* THEREFORE */ | |
1225 | 0x222b, /* INTEGRAL */ | 1228 | 0x222b, /* INTEGRAL */ | |
1226 | 0x2215, /* DIVISION SLASH */ | 1229 | 0x2215, /* DIVISION SLASH */ | |
1227 | 0x2216, /* SET MINUS */ | 1230 | 0x2216, /* SET MINUS */ | |
1228 | _e00eU, /* angle? */ | 1231 | _e00eU, /* angle? */ | |
1229 | _e00dU, /* inverted angle? */ | 1232 | _e00dU, /* inverted angle? */ | |
1230 | _e00bU, /* braceleftmid */ | 1233 | _e00bU, /* braceleftmid */ | |
1231 | /* 6 */ _e00cU, /* bracerightmid */ | 1234 | /* 6 */ _e00cU, /* bracerightmid */ | |
1232 | _e007U, /* bracelefttp */ | 1235 | _e007U, /* bracelefttp */ | |
1233 | _e008U, /* braceleftbt */ | 1236 | _e008U, /* braceleftbt */ | |
1234 | _e009U, /* bracerighttp */ | 1237 | _e009U, /* bracerighttp */ | |
1235 | _e00aU, /* bracerightbt */ | 1238 | _e00aU, /* bracerightbt */ | |
1236 | 0x221a, /* SQUARE ROOT */ | 1239 | 0x221a, /* SQUARE ROOT */ | |
1237 | 0x03c9, /* GREEK SMALL LETTER OMEGA */ | 1240 | 0x03c9, /* GREEK SMALL LETTER OMEGA */ | |
1238 | 0x00a5, /* YEN SIGN */ | 1241 | 0x00a5, /* YEN SIGN */ | |
1239 | 0x03be, /* GREEK SMALL LETTER XI */ | 1242 | 0x03be, /* GREEK SMALL LETTER XI */ | |
1240 | 0x00fd, /* LATIN SMALL LETTER Y WITH ACUTE */ | 1243 | 0x00fd, /* LATIN SMALL LETTER Y WITH ACUTE */ | |
1241 | 0x00fe, /* LATIN SMALL LETTER THORN */ | 1244 | 0x00fe, /* LATIN SMALL LETTER THORN */ | |
1242 | 0x00f0, /* LATIN SMALL LETTER ETH */ | 1245 | 0x00f0, /* LATIN SMALL LETTER ETH */ | |
1243 | 0x00de, /* LATIN CAPITAL LETTER THORN */ | 1246 | 0x00de, /* LATIN CAPITAL LETTER THORN */ | |
1244 | 0x00dd, /* LATIN CAPITAL LETTER Y WITH ACUTE */ | 1247 | 0x00dd, /* LATIN CAPITAL LETTER Y WITH ACUTE */ | |
1245 | 0x00d7, /* MULTIPLICATION SIGN */ | 1248 | 0x00d7, /* MULTIPLICATION SIGN */ | |
1246 | 0x00d0, /* LATIN CAPITAL LETTER ETH */ | 1249 | 0x00d0, /* LATIN CAPITAL LETTER ETH */ | |
1247 | /* 7 */ 0x00be, /* VULGAR FRACTION THREE QUARTERS */ | 1250 | /* 7 */ 0x00be, /* VULGAR FRACTION THREE QUARTERS */ | |
1248 | 0x00b8, /* CEDILLA */ | 1251 | 0x00b8, /* CEDILLA */ | |
1249 | 0x00b4, /* ACUTE ACCENT */ | 1252 | 0x00b4, /* ACUTE ACCENT */ | |
1250 | 0x00af, /* MACRON */ | 1253 | 0x00af, /* MACRON */ | |
1251 | 0x00ae, /* REGISTERED SIGN */ | 1254 | 0x00ae, /* REGISTERED SIGN */ | |
1252 | 0x00ad, /* SOFT HYPHEN */ | 1255 | 0x00ad, /* SOFT HYPHEN */ | |
1253 | 0x00ac, /* NOT SIGN */ | 1256 | 0x00ac, /* NOT SIGN */ | |
1254 | 0x00a8, /* DIAERESIS */ | 1257 | 0x00a8, /* DIAERESIS */ | |
1255 | 0x2260, /* NOT EQUAL TO */ | 1258 | 0x2260, /* NOT EQUAL TO */ | |
1256 | 0x23bd, /* scan 9 */ | 1259 | 0x23bd, /* scan 9 */ | |
1257 | 0x23bc, /* scan 7 */ | 1260 | 0x23bc, /* scan 7 */ | |
1258 | 0x2500, /* scan 5 */ | 1261 | 0x2500, /* scan 5 */ | |
1259 | 0x23bb, /* scan 3 */ | 1262 | 0x23bb, /* scan 3 */ | |
1260 | 0x23ba, /* scan 1 */ | 1263 | 0x23ba, /* scan 1 */ | |
1261 | 0x03c5, /* GREEK SMALL LETTER UPSILON */ | 1264 | 0x03c5, /* GREEK SMALL LETTER UPSILON */ | |
1262 | 0x00f8, /* LATIN SMALL LETTER O WITH STROKE */ | 1265 | 0x00f8, /* LATIN SMALL LETTER O WITH STROKE */ | |
1263 | /* 8 */ 0x0153, /* LATIN SMALL LIGATURE OE */ | 1266 | /* 8 */ 0x0153, /* LATIN SMALL LIGATURE OE */ | |
1264 | 0x00f5, /* LATIN SMALL LETTER O WITH TILDE !!!doc bug */ | 1267 | 0x00f5, /* LATIN SMALL LETTER O WITH TILDE !!!doc bug */ | |
1265 | 0x00e3, /* LATIN SMALL LETTER A WITH TILDE */ | 1268 | 0x00e3, /* LATIN SMALL LETTER A WITH TILDE */ | |
1266 | 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ | 1269 | 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ | |
1267 | 0x00db, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ | 1270 | 0x00db, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ | |
1268 | 0x00da, /* LATIN CAPITAL LETTER U WITH ACUTE */ | 1271 | 0x00da, /* LATIN CAPITAL LETTER U WITH ACUTE */ | |
1269 | 0x00d9, /* LATIN CAPITAL LETTER U WITH GRAVE */ | 1272 | 0x00d9, /* LATIN CAPITAL LETTER U WITH GRAVE */ | |
1270 | 0x00d8, /* LATIN CAPITAL LETTER O WITH STROKE */ | 1273 | 0x00d8, /* LATIN CAPITAL LETTER O WITH STROKE */ | |
1271 | 0x0152, /* LATIN CAPITAL LIGATURE OE */ | 1274 | 0x0152, /* LATIN CAPITAL LIGATURE OE */ | |
1272 | 0x00d5, /* LATIN CAPITAL LETTER O WITH TILDE */ | 1275 | 0x00d5, /* LATIN CAPITAL LETTER O WITH TILDE */ | |
1273 | 0x00d4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ | 1276 | 0x00d4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ | |
1274 | 0x00d3, /* LATIN CAPITAL LETTER O WITH ACUTE */ | 1277 | 0x00d3, /* LATIN CAPITAL LETTER O WITH ACUTE */ | |
1275 | 0x00d2, /* LATIN CAPITAL LETTER O WITH GRAVE */ | 1278 | 0x00d2, /* LATIN CAPITAL LETTER O WITH GRAVE */ | |
1276 | 0x00cf, /* LATIN CAPITAL LETTER I WITH DIAERESIS */ | 1279 | 0x00cf, /* LATIN CAPITAL LETTER I WITH DIAERESIS */ | |
1277 | 0x00ce, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ | 1280 | 0x00ce, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ | |
1278 | 0x00cd, /* LATIN CAPITAL LETTER I WITH ACUTE */ | 1281 | 0x00cd, /* LATIN CAPITAL LETTER I WITH ACUTE */ | |
1279 | /* 9 */ 0x00cc, /* LATIN CAPITAL LETTER I WITH GRAVE */ | 1282 | /* 9 */ 0x00cc, /* LATIN CAPITAL LETTER I WITH GRAVE */ | |
1280 | 0x00cb, /* LATIN CAPITAL LETTER E WITH DIAERESIS */ | 1283 | 0x00cb, /* LATIN CAPITAL LETTER E WITH DIAERESIS */ | |
1281 | 0x00ca, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ | 1284 | 0x00ca, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ | |
1282 | 0x00c8, /* LATIN CAPITAL LETTER E WITH GRAVE */ | 1285 | 0x00c8, /* LATIN CAPITAL LETTER E WITH GRAVE */ | |
1283 | 0x00c3, /* LATIN CAPITAL LETTER A WITH TILDE */ | 1286 | 0x00c3, /* LATIN CAPITAL LETTER A WITH TILDE */ | |
1284 | 0x00c2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ | 1287 | 0x00c2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ | |
1285 | 0x00c1, /* LATIN CAPITAL LETTER A WITH ACUTE */ | 1288 | 0x00c1, /* LATIN CAPITAL LETTER A WITH ACUTE */ | |
1286 | 0x00c0, /* LATIN CAPITAL LETTER A WITH GRAVE */ | 1289 | 0x00c0, /* LATIN CAPITAL LETTER A WITH GRAVE */ | |
1287 | 0x00b9, /* SUPERSCRIPT ONE */ | 1290 | 0x00b9, /* SUPERSCRIPT ONE */ | |
1288 | 0x00b7, /* MIDDLE DOT */ | 1291 | 0x00b7, /* MIDDLE DOT */ | |
1289 | 0x03b6, /* GREEK SMALL LETTER ZETA */ | 1292 | 0x03b6, /* GREEK SMALL LETTER ZETA */ | |
1290 | 0x00b3, /* SUPERSCRIPT THREE */ | 1293 | 0x00b3, /* SUPERSCRIPT THREE */ | |
1291 | 0x00a9, /* COPYRIGHT SIGN */ | 1294 | 0x00a9, /* COPYRIGHT SIGN */ | |
1292 | 0x00a4, /* CURRENCY SIGN */ | 1295 | 0x00a4, /* CURRENCY SIGN */ | |
1293 | 0x03ba, /* GREEK SMALL LETTER KAPPA */ | 1296 | 0x03ba, /* GREEK SMALL LETTER KAPPA */ | |
1294 | _e000U /* mirrored question mark? */ | 1297 | _e000U /* mirrored question mark? */ | |
1295 | }; | 1298 | }; | |
1296 | 1299 | |||
1297 | static int vga_pcvt_mapchar(int, u_int *); | 1300 | static int vga_pcvt_mapchar(int, u_int *); | |
1298 | 1301 | |||
1299 | static int | 1302 | static int | |
1300 | vga_pcvt_mapchar(int uni, u_int *index) | 1303 | vga_pcvt_mapchar(int uni, u_int *index) | |
1301 | { | 1304 | { | |
1302 | int i; | 1305 | int i; | |
1303 | 1306 | |||
1304 | for (i = 0; i < 0xa0; i++) /* 0xa0..0xff are reserved */ | 1307 | for (i = 0; i < 0xa0; i++) /* 0xa0..0xff are reserved */ | |
1305 | if (uni == pcvt_unichars[i]) { | 1308 | if (uni == pcvt_unichars[i]) { | |
1306 | *index = i; | 1309 | *index = i; | |
1307 | return (5); | 1310 | return (5); | |
1308 | } | 1311 | } | |
1309 | *index = 0x99; /* middle dot */ | 1312 | *index = 0x99; /* middle dot */ | |
1310 | return (0); | 1313 | return (0); | |
1311 | } | 1314 | } | |
1312 | 1315 | |||
1313 | #endif /* WSCONS_SUPPORT_PCVTFONTS */ | 1316 | #endif /* WSCONS_SUPPORT_PCVTFONTS */ | |
1314 | 1317 | |||
1315 | #ifdef WSCONS_SUPPORT_ISO7FONTS | 1318 | #ifdef WSCONS_SUPPORT_ISO7FONTS | |
1316 | 1319 | |||
1317 | static int | 1320 | static int | |
1318 | vga_iso7_mapchar(int uni, u_int *index) | 1321 | vga_iso7_mapchar(int uni, u_int *index) | |
1319 | { | 1322 | { | |
1320 | 1323 | |||
1321 | /* | 1324 | /* | |
1322 | * U+0384 (GREEK TONOS) to | 1325 | * U+0384 (GREEK TONOS) to | |
1323 | * U+03ce (GREEK SMALL LETTER OMEGA WITH TONOS) | 1326 | * U+03ce (GREEK SMALL LETTER OMEGA WITH TONOS) | |
1324 | * map directly to the iso-9 font | 1327 | * map directly to the iso-9 font | |
1325 | */ | 1328 | */ | |
1326 | if (uni >= 0x0384 && uni <= 0x03ce) { | 1329 | if (uni >= 0x0384 && uni <= 0x03ce) { | |
1327 | /* U+0384 is at offset 0xb4 in the font */ | 1330 | /* U+0384 is at offset 0xb4 in the font */ | |
1328 | *index = uni - 0x0384 + 0xb4; | 1331 | *index = uni - 0x0384 + 0xb4; | |
1329 | return (5); | 1332 | return (5); | |
1330 | } | 1333 | } | |
1331 | 1334 | |||
1332 | /* XXX more chars in the iso-9 font */ | 1335 | /* XXX more chars in the iso-9 font */ | |
1333 | 1336 | |||
1334 | *index = 0xa4; /* shaded rectangle */ | 1337 | *index = 0xa4; /* shaded rectangle */ | |
1335 | return (0); | 1338 | return (0); | |
1336 | } | 1339 | } | |
1337 | 1340 | |||
1338 | #endif /* WSCONS_SUPPORT_ISO7FONTS */ | 1341 | #endif /* WSCONS_SUPPORT_ISO7FONTS */ | |
1339 | 1342 | |||
1340 | static const uint16_t iso2_unichars[0x60] = { | 1343 | static const uint16_t iso2_unichars[0x60] = { | |
1341 | 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, | 1344 | 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, | |
1342 | 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, | 1345 | 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, | |
1343 | 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, | 1346 | 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, | |
1344 | 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, | 1347 | 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, | |
1345 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, | 1348 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, | |
1346 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, | 1349 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, | |
1347 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, | 1350 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, | |
1348 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, | 1351 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, | |
1349 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, | 1352 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, | |
1350 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, | 1353 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, | |
1351 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, | 1354 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, | |
1352 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 | 1355 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 | |
1353 | }; | 1356 | }; | |
1354 | 1357 | |||
1355 | static const uint16_t koi8_unichars[0x40] = { | 1358 | static const uint16_t koi8_unichars[0x40] = { | |
1356 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, | 1359 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, | |
1357 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, | 1360 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, | |
1358 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, | 1361 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, | |
1359 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, | 1362 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, | |
1360 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, | 1363 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, | |
1361 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, | 1364 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, | |
1362 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, | 1365 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, | |
1363 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A | 1366 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A | |
1364 | }; | 1367 | }; | |
1365 | 1368 | |||
1366 | static int _vga_mapchar(void *, const struct egavga_font *, int, u_int *); | 1369 | static int _vga_mapchar(void *, const struct egavga_font *, int, u_int *); | |
1367 | 1370 | |||
1368 | static int | 1371 | static int | |
1369 | _vga_mapchar(void *id, const struct egavga_font *font, int uni, u_int *index) | 1372 | _vga_mapchar(void *id, const struct egavga_font *font, int uni, u_int *index) | |
1370 | { | 1373 | { | |
1371 | 1374 | |||
1372 | switch (font->wsfont->encoding) { | 1375 | switch (font->wsfont->encoding) { | |
1373 | case WSDISPLAY_FONTENC_ISO: | 1376 | case WSDISPLAY_FONTENC_ISO: | |
1374 | if (uni < 256) { | 1377 | if (uni < 256) { | |
1375 | *index = uni; | 1378 | *index = uni; | |
1376 | return (5); | 1379 | return (5); | |
1377 | } else { | 1380 | } else { | |
1378 | *index = ' '; | 1381 | *index = ' '; | |
1379 | return (0); | 1382 | return (0); | |
1380 | } | 1383 | } | |
1381 | case WSDISPLAY_FONTENC_ISO2: | 1384 | case WSDISPLAY_FONTENC_ISO2: | |
1382 | if (uni < 0xa0) { | 1385 | if (uni < 0xa0) { | |
1383 | *index = uni; | 1386 | *index = uni; | |
1384 | return (5); | 1387 | return (5); | |
1385 | } else { | 1388 | } else { | |
1386 | int i; | 1389 | int i; | |
1387 | for (i = 0; i < 0x60; i++) { | 1390 | for (i = 0; i < 0x60; i++) { | |
1388 | if (uni == iso2_unichars[i]) { | 1391 | if (uni == iso2_unichars[i]) { | |
1389 | *index = i + 0xa0; | 1392 | *index = i + 0xa0; | |
1390 | return (5); | 1393 | return (5); | |
1391 | } | 1394 | } | |
1392 | } | 1395 | } | |
1393 | *index = 0xa4; /* currency sign */ | 1396 | *index = 0xa4; /* currency sign */ | |
1394 | return (0); | 1397 | return (0); | |
1395 | } | 1398 | } | |
1396 | case WSDISPLAY_FONTENC_KOI8_R: | 1399 | case WSDISPLAY_FONTENC_KOI8_R: | |
1397 | if (uni < 0x80) { | 1400 | if (uni < 0x80) { | |
1398 | *index = uni; | 1401 | *index = uni; | |
1399 | return (5); | 1402 | return (5); | |
1400 | } else { | 1403 | } else { | |
1401 | int i; | 1404 | int i; | |
1402 | for (i = 0; i < 0x40; i++) { | 1405 | for (i = 0; i < 0x40; i++) { | |
1403 | if (uni == koi8_unichars[i]) { | 1406 | if (uni == koi8_unichars[i]) { | |
1404 | *index = i + 0xc0; | 1407 | *index = i + 0xc0; | |
1405 | return (5); | 1408 | return (5); | |
1406 | } | 1409 | } | |
1407 | } | 1410 | } | |
1408 | *index = 0x94; /* box */ | 1411 | *index = 0x94; /* box */ | |
1409 | return (0); | 1412 | return (0); | |
1410 | } | 1413 | } | |
1411 | case WSDISPLAY_FONTENC_IBM: | 1414 | case WSDISPLAY_FONTENC_IBM: | |
1412 | return (pcdisplay_mapchar(id, uni, index)); | 1415 | return (pcdisplay_mapchar(id, uni, index)); | |
1413 | #ifdef WSCONS_SUPPORT_PCVTFONTS | 1416 | #ifdef WSCONS_SUPPORT_PCVTFONTS | |
1414 | case WSDISPLAY_FONTENC_PCVT: | 1417 | case WSDISPLAY_FONTENC_PCVT: | |
1415 | return (vga_pcvt_mapchar(uni, index)); | 1418 | return (vga_pcvt_mapchar(uni, index)); | |
1416 | #endif | 1419 | #endif | |
1417 | #ifdef WSCONS_SUPPORT_ISO7FONTS | 1420 | #ifdef WSCONS_SUPPORT_ISO7FONTS | |
1418 | case WSDISPLAY_FONTENC_ISO7: | 1421 | case WSDISPLAY_FONTENC_ISO7: | |
1419 | return (vga_iso7_mapchar(uni, index)); | 1422 | return (vga_iso7_mapchar(uni, index)); | |
1420 | #endif | 1423 | #endif | |
1421 | default: | 1424 | default: | |
1422 | #ifdef VGAFONTDEBUG | 1425 | #ifdef VGAFONTDEBUG | |
1423 | printf("_vga_mapchar: encoding=%d\n", font->wsfont->encoding); | 1426 | printf("_vga_mapchar: encoding=%d\n", font->wsfont->encoding); | |
1424 | #endif | 1427 | #endif | |
1425 | *index = ' '; | 1428 | *index = ' '; | |
1426 | return (0); | 1429 | return (0); | |
1427 | } | 1430 | } | |
1428 | } | 1431 | } | |
1429 | 1432 | |||
1430 | static int | 1433 | static int | |
1431 | vga_mapchar(void *id, int uni, u_int *index) | 1434 | vga_mapchar(void *id, int uni, u_int *index) | |
1432 | { | 1435 | { | |
1433 | struct vgascreen *scr = id; | 1436 | struct vgascreen *scr = id; | |
1434 | u_int idx1, idx2; | 1437 | u_int idx1, idx2; | |
1435 | int res1, res2; | 1438 | int res1, res2; | |
1436 | 1439 | |||
1437 | res1 = 0; | 1440 | res1 = 0; | |
1438 | idx1 = ' '; /* space */ | 1441 | idx1 = ' '; /* space */ | |
1439 | if (scr->fontset1) | 1442 | if (scr->fontset1) | |
1440 | res1 = _vga_mapchar(id, scr->fontset1, uni, &idx1); | 1443 | res1 = _vga_mapchar(id, scr->fontset1, uni, &idx1); | |
1441 | res2 = -1; | 1444 | res2 = -1; | |
1442 | if (scr->fontset2) { | 1445 | if (scr->fontset2) { | |
1443 | KASSERT(VGA_SCREEN_CANTWOFONTS(scr->pcs.type)); | 1446 | KASSERT(VGA_SCREEN_CANTWOFONTS(scr->pcs.type)); | |
1444 | res2 = _vga_mapchar(id, scr->fontset2, uni, &idx2); | 1447 | res2 = _vga_mapchar(id, scr->fontset2, uni, &idx2); | |
1445 | } | 1448 | } | |
1446 | if (res2 > res1) { | 1449 | if (res2 > res1) { | |
1447 | *index = idx2 | 0x0800; /* attribute bit 3 */ | 1450 | *index = idx2 | 0x0800; /* attribute bit 3 */ | |
1448 | return (res2); | 1451 | return (res2); | |
1449 | } | 1452 | } | |
1450 | *index = idx1; | 1453 | *index = idx1; | |
1451 | return (res1); | 1454 | return (res1); | |
1452 | } | 1455 | } | |
1453 | 1456 | |||
1454 | #ifdef WSDISPLAY_SCROLLSUPPORT | 1457 | #ifdef WSDISPLAY_SCROLLSUPPORT | |
1455 | void | 1458 | static void | |
1456 | vga_scroll(void *v, void *cookie, int lines) | 1459 | vga_scroll(void *v, void *cookie, int lines) | |
1457 | { | 1460 | { | |
1458 | struct vga_config *vc = v; | 1461 | struct vga_config *vc = v; | |
1459 | struct vgascreen *scr = cookie; | 1462 | struct vgascreen *scr = cookie; | |
1460 | struct vga_handle *vh = &vc->hdl; | 1463 | struct vga_handle *vh = &vc->hdl; | |
1461 | 1464 | |||
1462 | if (lines == 0) { | 1465 | if (lines == 0) { | |
1463 | if (scr->pcs.visibleoffset == scr->pcs.dispoffset) | 1466 | if (scr->pcs.visibleoffset == scr->pcs.dispoffset) | |
1464 | return; | 1467 | return; | |
1465 | 1468 | |||
1466 | scr->pcs.visibleoffset = scr->pcs.dispoffset; | 1469 | scr->pcs.visibleoffset = scr->pcs.dispoffset; | |
1467 | } | 1470 | } | |
1468 | else { | 1471 | else { | |
1469 | int vga_scr_end; | 1472 | int vga_scr_end; | |
1470 | int margin = scr->pcs.type->ncols * 2; | 1473 | int margin = scr->pcs.type->ncols * 2; | |
1471 | int ul, we, p, st; | 1474 | int ul, we, p, st; | |
1472 | 1475 | |||
1473 | vga_scr_end = (scr->pcs.dispoffset + scr->pcs.type->ncols * | 1476 | vga_scr_end = (scr->pcs.dispoffset + scr->pcs.type->ncols * | |
1474 | scr->pcs.type->nrows * 2); | 1477 | scr->pcs.type->nrows * 2); | |
1475 | if (scr->vga_rollover > vga_scr_end + margin) { | 1478 | if (scr->vga_rollover > vga_scr_end + margin) { | |
1476 | ul = vga_scr_end; | 1479 | ul = vga_scr_end; | |
1477 | we = scr->vga_rollover + scr->pcs.type->ncols * 2; | 1480 | we = scr->vga_rollover + scr->pcs.type->ncols * 2; | |
1478 | } else { | 1481 | } else { | |
1479 | ul = 0; | 1482 | ul = 0; | |
1480 | we = 0x8000; | 1483 | we = 0x8000; | |
1481 | } | 1484 | } | |
1482 | p = (scr->pcs.visibleoffset - ul + we) % we + lines * | 1485 | p = (scr->pcs.visibleoffset - ul + we) % we + lines * | |
1483 | (scr->pcs.type->ncols * 2); | 1486 | (scr->pcs.type->ncols * 2); | |
1484 | st = (scr->pcs.dispoffset - ul + we) % we; | 1487 | st = (scr->pcs.dispoffset - ul + we) % we; | |
1485 | if (p < margin) | 1488 | if (p < margin) | |
1486 | p = 0; | 1489 | p = 0; | |
1487 | if (p > st - margin) | 1490 | if (p > st - margin) | |
1488 | p = st; | 1491 | p = st; | |
1489 | scr->pcs.visibleoffset = (p + ul) % we; | 1492 | scr->pcs.visibleoffset = (p + ul) % we; | |
1490 | } | 1493 | } | |
1491 | 1494 | |||
1492 | vga_6845_write(vh, startadrh, scr->pcs.visibleoffset >> 9); | 1495 | vga_6845_write(vh, startadrh, scr->pcs.visibleoffset >> 9); | |
1493 | vga_6845_write(vh, startadrl, scr->pcs.visibleoffset >> 1); | 1496 | vga_6845_write(vh, startadrl, scr->pcs.visibleoffset >> 1); | |
1494 | } | 1497 | } | |
1495 | #endif | 1498 | #endif | |
1496 | 1499 | |||
1497 | void | 1500 | static void | |
1498 | vga_putchar(void *c, int row, int col, u_int uc, long attr) | 1501 | vga_putchar(void *c, int row, int col, u_int uc, long attr) | |
1499 | { | 1502 | { | |
1500 | 1503 | |||
1501 | pcdisplay_putchar(c, row, col, uc, attr); | 1504 | pcdisplay_putchar(c, row, col, uc, attr); | |
1502 | } | 1505 | } | |
1503 | 1506 | |||
1504 | #ifdef WSDISPLAY_CUSTOM_BORDER | 1507 | #ifdef WSDISPLAY_CUSTOM_BORDER | |
1505 | static int | 1508 | static int | |
1506 | vga_getborder(struct vga_config *vc, u_int *valuep) | 1509 | vga_getborder(struct vga_config *vc, u_int *valuep) | |
1507 | { | 1510 | { | |
1508 | struct vga_handle *vh = &vc->hdl; | 1511 | struct vga_handle *vh = &vc->hdl; | |
1509 | u_int idx; | 1512 | u_int idx; | |
1510 | uint8_t value; | 1513 | uint8_t value; | |
1511 | 1514 | |||
1512 | if (vh->vh_mono) | 1515 | if (vh->vh_mono) | |
1513 | return ENODEV; | 1516 | return ENODEV; | |
1514 | 1517 | |||
1515 | value = _vga_attr_read(vh, VGA_ATC_OVERSCAN); | 1518 | value = _vga_attr_read(vh, VGA_ATC_OVERSCAN); | |
1516 | for (idx = 0; idx < sizeof(fgansitopc); idx++) { | 1519 | for (idx = 0; idx < sizeof(fgansitopc); idx++) { | |
1517 | if (fgansitopc[idx] == value) { | 1520 | if (fgansitopc[idx] == value) { | |
1518 | *valuep = idx; | 1521 | *valuep = idx; | |
1519 | return (0); | 1522 | return (0); | |
1520 | } | 1523 | } | |
1521 | } | 1524 | } | |
1522 | return (EIO); | 1525 | return (EIO); | |
1523 | } | 1526 | } | |
1524 | 1527 | |||
1525 | static int | 1528 | static int | |
1526 | vga_setborder(struct vga_config *vc, u_int value) | 1529 | vga_setborder(struct vga_config *vc, u_int value) | |
1527 | { | 1530 | { | |
1528 | struct vga_handle *vh = &vc->hdl; | 1531 | struct vga_handle *vh = &vc->hdl; | |
1529 | 1532 | |||
1530 | if (vh->vh_mono) | 1533 | if (vh->vh_mono) | |
1531 | return ENODEV; | 1534 | return ENODEV; | |
1532 | if (value >= sizeof(fgansitopc)) | 1535 | if (value >= sizeof(fgansitopc)) | |
1533 | return EINVAL; | 1536 | return EINVAL; | |
1534 | 1537 | |||
1535 | _vga_attr_write(vh, VGA_ATC_OVERSCAN, fgansitopc[value]); | 1538 | _vga_attr_write(vh, VGA_ATC_OVERSCAN, fgansitopc[value]); | |
1536 | return (0); | 1539 | return (0); | |
1537 | } | 1540 | } | |
1538 | #endif /* WSDISPLAY_CUSTOM_BORDER */ | 1541 | #endif /* WSDISPLAY_CUSTOM_BORDER */ | |
1539 | 1542 | |||
1540 | void | 1543 | void | |
1541 | vga_resume(struct vga_softc *sc) | 1544 | vga_resume(struct vga_softc *sc) | |
1542 | { | 1545 | { | |
1543 | #ifdef VGA_RESET_ON_RESUME | 1546 | #ifdef VGA_RESET_ON_RESUME | |
1544 | vga_initregs(&sc->sc_vc->hdl); | 1547 | vga_initregs(&sc->sc_vc->hdl); | |
1545 | #endif | 1548 | #endif | |
1546 | #ifdef PCDISPLAY_SOFTCURSOR | 1549 | #ifdef PCDISPLAY_SOFTCURSOR | |
1547 | /* Disable the hardware cursor */ | 1550 | /* Disable the hardware cursor */ | |
1548 | vga_6845_write(&sc->sc_vc->hdl, curstart, 0x20); | 1551 | vga_6845_write(&sc->sc_vc->hdl, curstart, 0x20); | |
1549 | vga_6845_write(&sc->sc_vc->hdl, curend, 0x00); | 1552 | vga_6845_write(&sc->sc_vc->hdl, curend, 0x00); | |
1550 | #endif | 1553 | #endif | |
1551 | } | 1554 | } | |
1552 | 1555 | |||
1553 | void | 1556 | static void | |
1554 | vga_save_palette(struct vga_config *vc) | 1557 | vga_save_palette(struct vga_config *vc) | |
1555 | { | 1558 | { | |
1556 | struct vga_handle *vh = &vc->hdl; | 1559 | struct vga_handle *vh = &vc->hdl; | |
1557 | size_t i; | 1560 | size_t i; | |
1558 | uint8_t *palette = vc->palette; | 1561 | uint8_t *palette = vc->palette; | |
1559 | 1562 | |||
1560 | if (vh->vh_mono) | 1563 | if (vh->vh_mono) | |
1561 | return; | 1564 | return; | |
1562 | 1565 | |||
1563 | vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); | 1566 | vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); | |
1564 | vga_raw_write(vh, VGA_DAC_ADDRR, 0x00); | 1567 | vga_raw_write(vh, VGA_DAC_ADDRR, 0x00); | |
1565 | for (i = 0; i < sizeof(vc->palette); i++) | 1568 | for (i = 0; i < sizeof(vc->palette); i++) | |
1566 | *palette++ = vga_raw_read(vh, VGA_DAC_PALETTE); | 1569 | *palette++ = vga_raw_read(vh, VGA_DAC_PALETTE); | |
1567 | 1570 | |||
1568 | vga_reset_state(vh); /* reset flip/flop */ | 1571 | vga_reset_state(vh); /* reset flip/flop */ | |
1569 | } | 1572 | } | |
1570 | 1573 | |||
1571 | void | 1574 | static void | |
1572 | vga_restore_palette(struct vga_config *vc) | 1575 | vga_restore_palette(struct vga_config *vc) | |
1573 | { | 1576 | { | |
1574 | struct vga_handle *vh = &vc->hdl; | 1577 | struct vga_handle *vh = &vc->hdl; | |
1575 | size_t i; | 1578 | size_t i; | |
1576 | uint8_t *palette = vc->palette; | 1579 | uint8_t *palette = vc->palette; | |
1577 | 1580 | |||
1578 | if (vh->vh_mono) | 1581 | if (vh->vh_mono) | |
1579 | return; | 1582 | return; | |
1580 | 1583 | |||
1581 | vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); | 1584 | vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); | |
1582 | vga_raw_write(vh, VGA_DAC_ADDRW, 0x00); | 1585 | vga_raw_write(vh, VGA_DAC_ADDRW, 0x00); | |
1583 | for (i = 0; i < sizeof(vc->palette); i++) | 1586 | for (i = 0; i < sizeof(vc->palette); i++) | |
1584 | vga_raw_write(vh, VGA_DAC_PALETTE, *palette++); | 1587 | vga_raw_write(vh, VGA_DAC_PALETTE, *palette++); | |
1585 | 1588 | |||
1586 | vga_reset_state(vh); /* reset flip/flop */ | 1589 | vga_reset_state(vh); /* reset flip/flop */ | |
1587 | vga_enable(vh); | 1590 | vga_enable(vh); | |
1588 | } | 1591 | } |
--- src/sys/dev/ic/vga_raster.c 2012/01/11 20:41:28 1.35
+++ src/sys/dev/ic/vga_raster.c 2013/01/21 19:49:15 1.36
@@ -1,1490 +1,1490 @@ | @@ -1,1490 +1,1490 @@ | |||
1 | /* $NetBSD: vga_raster.c,v 1.35 2012/01/11 20:41:28 macallan Exp $ */ | 1 | /* $NetBSD: vga_raster.c,v 1.36 2013/01/21 19:49:15 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002 Bang Jun-Young | 4 | * Copyright (c) 2001, 2002 Bang Jun-Young | |
5 | * Copyright (c) 2004 Julio M. Merino Vidal | 5 | * Copyright (c) 2004 Julio M. Merino Vidal | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * 3. The name of the author may not be used to endorse or promote products | 16 | * 3. The name of the author may not be used to endorse or promote products | |
17 | * derived from this software without specific prior written permission. | 17 | * derived from this software without specific prior written permission. | |
18 | * | 18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | /* | 31 | /* | |
32 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | 32 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | |
33 | * All rights reserved. | 33 | * All rights reserved. | |
34 | * | 34 | * | |
35 | * Author: Chris G. Demetriou | 35 | * Author: Chris G. Demetriou | |
36 | * | 36 | * | |
37 | * Permission to use, copy, modify and distribute this software and | 37 | * Permission to use, copy, modify and distribute this software and | |
38 | * its documentation is hereby granted, provided that both the copyright | 38 | * its documentation is hereby granted, provided that both the copyright | |
39 | * notice and this permission notice appear in all copies of the | 39 | * notice and this permission notice appear in all copies of the | |
40 | * software, derivative works or modified versions, and any portions | 40 | * software, derivative works or modified versions, and any portions | |
41 | * thereof, and that both notices appear in supporting documentation. | 41 | * thereof, and that both notices appear in supporting documentation. | |
42 | * | 42 | * | |
43 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 43 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
44 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | 44 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | |
45 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | 45 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
46 | * | 46 | * | |
47 | * Carnegie Mellon requests users of this software to return to | 47 | * Carnegie Mellon requests users of this software to return to | |
48 | * | 48 | * | |
49 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | 49 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
50 | * School of Computer Science | 50 | * School of Computer Science | |
51 | * Carnegie Mellon University | 51 | * Carnegie Mellon University | |
52 | * Pittsburgh PA 15213-3890 | 52 | * Pittsburgh PA 15213-3890 | |
53 | * | 53 | * | |
54 | * any improvements or extensions that they make and grant Carnegie the | 54 | * any improvements or extensions that they make and grant Carnegie the | |
55 | * rights to redistribute these changes. | 55 | * rights to redistribute these changes. | |
56 | */ | 56 | */ | |
57 | 57 | |||
58 | #include <sys/cdefs.h> | 58 | #include <sys/cdefs.h> | |
59 | __KERNEL_RCSID(0, "$NetBSD: vga_raster.c,v 1.35 2012/01/11 20:41:28 macallan Exp $"); | 59 | __KERNEL_RCSID(0, "$NetBSD: vga_raster.c,v 1.36 2013/01/21 19:49:15 mlelstv Exp $"); | |
60 | 60 | |||
61 | #include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */ | 61 | #include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */ | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/systm.h> | 64 | #include <sys/systm.h> | |
65 | #include <sys/callout.h> | 65 | #include <sys/callout.h> | |
66 | #include <sys/kernel.h> | 66 | #include <sys/kernel.h> | |
67 | #include <sys/device.h> | 67 | #include <sys/device.h> | |
68 | #include <sys/malloc.h> | 68 | #include <sys/malloc.h> | |
69 | #include <sys/queue.h> | 69 | #include <sys/queue.h> | |
70 | #include <sys/bus.h> | 70 | #include <sys/bus.h> | |
71 | 71 | |||
72 | #include <dev/ic/mc6845reg.h> | 72 | #include <dev/ic/mc6845reg.h> | |
73 | #include <dev/ic/pcdisplayvar.h> | 73 | #include <dev/ic/pcdisplayvar.h> | |
74 | #include <dev/ic/vgareg.h> | 74 | #include <dev/ic/vgareg.h> | |
75 | #include <dev/ic/vgavar.h> | 75 | #include <dev/ic/vgavar.h> | |
76 | #include <dev/videomode/videomode.h> | 76 | #include <dev/videomode/videomode.h> | |
77 | 77 | |||
78 | #include <dev/wscons/wsdisplayvar.h> | 78 | #include <dev/wscons/wsdisplayvar.h> | |
79 | #include <dev/wscons/wsconsio.h> | 79 | #include <dev/wscons/wsconsio.h> | |
80 | #include <dev/wsfont/wsfont.h> | 80 | #include <dev/wsfont/wsfont.h> | |
81 | 81 | |||
82 | #include <dev/ic/pcdisplay.h> | 82 | #include <dev/ic/pcdisplay.h> | |
83 | 83 | |||
84 | int vga_no_builtinfont = 0; | 84 | int vga_no_builtinfont = 0; | |
85 | 85 | |||
86 | u_int8_t builtinfont_data[256 * 16]; | 86 | u_int8_t builtinfont_data[256 * 16]; | |
87 | 87 | |||
88 | struct wsdisplay_font builtinfont = { | 88 | struct wsdisplay_font builtinfont = { | |
89 | "builtin", /* typeface name */ | 89 | "builtin", /* typeface name */ | |
90 | 0, /* firstchar */ | 90 | 0, /* firstchar */ | |
91 | 256, /* numchars */ | 91 | 256, /* numchars */ | |
92 | WSDISPLAY_FONTENC_IBM, /* encoding */ | 92 | WSDISPLAY_FONTENC_IBM, /* encoding */ | |
93 | 8, /* width */ | 93 | 8, /* width */ | |
94 | 16, /* height */ | 94 | 16, /* height */ | |
95 | 1, /* stride */ | 95 | 1, /* stride */ | |
96 | WSDISPLAY_FONTORDER_L2R, /* bit order */ | 96 | WSDISPLAY_FONTORDER_L2R, /* bit order */ | |
97 | WSDISPLAY_FONTORDER_L2R, /* byte order */ | 97 | WSDISPLAY_FONTORDER_L2R, /* byte order */ | |
98 | builtinfont_data /* data */ | 98 | builtinfont_data /* data */ | |
99 | }; | 99 | }; | |
100 | 100 | |||
101 | struct vga_scrmem { | 101 | struct vga_scrmem { | |
102 | u_int16_t ch; | 102 | u_int16_t ch; | |
103 | u_int8_t attr; | 103 | u_int8_t attr; | |
104 | u_int8_t second; /* XXXBJY should be u_int8_t len; */ | 104 | u_int8_t second; /* XXXBJY should be u_int8_t len; */ | |
105 | u_int8_t enc; | 105 | u_int8_t enc; | |
106 | }; | 106 | }; | |
107 | 107 | |||
108 | #ifdef VGA_CONSOLE_SCREENTYPE | 108 | #ifdef VGA_CONSOLE_SCREENTYPE | |
109 | #define VGA_SCRMEM_SIZE (80 * 30) | 109 | #define VGA_SCRMEM_SIZE (80 * 30) | |
110 | #else | 110 | #else | |
111 | #define VGA_SCRMEM_SIZE (80 * 25) | 111 | #define VGA_SCRMEM_SIZE (80 * 25) | |
112 | #endif | 112 | #endif | |
113 | 113 | |||
114 | struct vga_scrmem boot_scrmem[VGA_SCRMEM_SIZE]; | 114 | struct vga_scrmem boot_scrmem[VGA_SCRMEM_SIZE]; | |
115 | 115 | |||
116 | struct vga_raster_font { | 116 | struct vga_raster_font { | |
117 | LIST_ENTRY(vga_raster_font) next; | 117 | LIST_ENTRY(vga_raster_font) next; | |
118 | struct wsdisplay_font *font; | 118 | struct wsdisplay_font *font; | |
119 | }; | 119 | }; | |
120 | 120 | |||
121 | struct vgascreen { | 121 | struct vgascreen { | |
122 | LIST_ENTRY(vgascreen) next; | 122 | LIST_ENTRY(vgascreen) next; | |
123 | struct vga_config *cfg; | 123 | struct vga_config *cfg; | |
124 | struct vga_handle *hdl; | 124 | struct vga_handle *hdl; | |
125 | const struct wsscreen_descr *type; | 125 | const struct wsscreen_descr *type; | |
126 | 126 | |||
127 | int active; | 127 | int active; | |
128 | struct vga_scrmem *mem; | 128 | struct vga_scrmem *mem; | |
129 | int encoding; | 129 | int encoding; | |
130 | 130 | |||
131 | int dispoffset; | 131 | int dispoffset; | |
132 | int mindispoffset; | 132 | int mindispoffset; | |
133 | int maxdispoffset; | 133 | int maxdispoffset; | |
134 | 134 | |||
135 | int cursoron; /* Is cursor displayed? */ | 135 | int cursoron; /* Is cursor displayed? */ | |
136 | int cursorcol; /* Current cursor column */ | 136 | int cursorcol; /* Current cursor column */ | |
137 | int cursorrow; /* Current cursor row */ | 137 | int cursorrow; /* Current cursor row */ | |
138 | struct vga_scrmem cursortmp; | 138 | struct vga_scrmem cursortmp; | |
139 | int cursorstride; | 139 | int cursorstride; | |
140 | 140 | |||
141 | LIST_HEAD(, vga_raster_font) fontset; | 141 | LIST_HEAD(, vga_raster_font) fontset; | |
142 | }; | 142 | }; | |
143 | 143 | |||
144 | struct vga_moderegs { | 144 | struct vga_moderegs { | |
145 | u_int8_t miscout; /* Misc. output */ | 145 | u_int8_t miscout; /* Misc. output */ | |
146 | u_int8_t crtc[MC6845_NREGS]; /* CRTC controller */ | 146 | u_int8_t crtc[MC6845_NREGS]; /* CRTC controller */ | |
147 | u_int8_t atc[VGA_ATC_NREGS]; /* Attribute controller */ | 147 | u_int8_t atc[VGA_ATC_NREGS]; /* Attribute controller */ | |
148 | u_int8_t ts[VGA_TS_NREGS]; /* Time sequencer */ | 148 | u_int8_t ts[VGA_TS_NREGS]; /* Time sequencer */ | |
149 | u_int8_t gdc[VGA_GDC_NREGS]; /* Graphics display controller */ | 149 | u_int8_t gdc[VGA_GDC_NREGS]; /* Graphics display controller */ | |
150 | }; | 150 | }; | |
151 | 151 | |||
152 | static int vgaconsole, vga_console_type, vga_console_attached; | 152 | static int vgaconsole, vga_console_type, vga_console_attached; | |
153 | static struct vgascreen vga_console_screen; | 153 | static struct vgascreen vga_console_screen; | |
154 | static struct vga_config vga_console_vc; | 154 | static struct vga_config vga_console_vc; | |
155 | static struct vga_raster_font vga_console_fontset_ascii; | 155 | static struct vga_raster_font vga_console_fontset_ascii; | |
156 | static struct videomode vga_console_modes[2] = { | 156 | static struct videomode vga_console_modes[2] = { | |
157 | /* 640x400 for 80x25, 80x40 and 80x50 modes */ | 157 | /* 640x400 for 80x25, 80x40 and 80x50 modes */ | |
158 | { | 158 | { | |
159 | 25175, 640, 664, 760, 800, 400, 409, 411, 450, 0, NULL, | 159 | 25175, 640, 664, 760, 800, 400, 409, 411, 450, 0, NULL, | |
160 | }, | 160 | }, | |
161 | /* 640x480 for 80x30 mode */ | 161 | /* 640x480 for 80x30 mode */ | |
162 | { | 162 | { | |
163 | 25175, 640, 664, 760, 800, 480, 491, 493, 525, 0, NULL, | 163 | 25175, 640, 664, 760, 800, 480, 491, 493, 525, 0, NULL, | |
164 | } | 164 | } | |
165 | }; | 165 | }; | |
166 | 166 | |||
167 | static void vga_raster_init(struct vga_config *, bus_space_tag_t, | 167 | static void vga_raster_init(struct vga_config *, bus_space_tag_t, | |
168 | bus_space_tag_t); | 168 | bus_space_tag_t); | |
169 | static void vga_raster_init_screen(struct vga_config *, struct vgascreen *, | 169 | static void vga_raster_init_screen(struct vga_config *, struct vgascreen *, | |
170 | const struct wsscreen_descr *, int, long *); | 170 | const struct wsscreen_descr *, int, long *); | |
171 | static void vga_raster_setup_font(struct vga_config *, struct vgascreen *); | 171 | static void vga_raster_setup_font(struct vga_config *, struct vgascreen *); | |
172 | static void vga_setup_regs(struct videomode *, struct vga_moderegs *); | 172 | static void vga_setup_regs(struct videomode *, struct vga_moderegs *); | |
173 | static void vga_set_mode(struct vga_handle *, struct vga_moderegs *); | 173 | static void vga_set_mode(struct vga_handle *, struct vga_moderegs *); | |
174 | static void vga_restore_screen(struct vgascreen *, | 174 | static void vga_restore_screen(struct vgascreen *, | |
175 | const struct wsscreen_descr *, struct vga_scrmem *); | 175 | const struct wsscreen_descr *, struct vga_scrmem *); | |
176 | static void vga_raster_cursor_init(struct vgascreen *, int); | 176 | static void vga_raster_cursor_init(struct vgascreen *, int); | |
177 | static void _vga_raster_putchar(void *, int, int, u_int, long, | 177 | static void _vga_raster_putchar(void *, int, int, u_int, long, | |
178 | struct vga_raster_font *); | 178 | struct vga_raster_font *); | |
179 | 179 | |||
180 | static void vga_raster_cursor(void *, int, int, int); | 180 | static void vga_raster_cursor(void *, int, int, int); | |
181 | static int vga_raster_mapchar(void *, int, u_int *); | 181 | static int vga_raster_mapchar(void *, int, u_int *); | |
182 | static void vga_raster_putchar(void *, int, int, u_int, long); | 182 | static void vga_raster_putchar(void *, int, int, u_int, long); | |
183 | static void vga_raster_copycols(void *, int, int, int, int); | 183 | static void vga_raster_copycols(void *, int, int, int, int); | |
184 | static void vga_raster_erasecols(void *, int, int, int, long); | 184 | static void vga_raster_erasecols(void *, int, int, int, long); | |
185 | static void vga_raster_copyrows(void *, int, int, int); | 185 | static void vga_raster_copyrows(void *, int, int, int); | |
186 | static void vga_raster_eraserows(void *, int, int, long); | 186 | static void vga_raster_eraserows(void *, int, int, long); | |
187 | static int vga_raster_allocattr(void *, int, int, int, long *); | 187 | static int vga_raster_allocattr(void *, int, int, int, long *); | |
188 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | 188 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | |
189 | static void vga_raster_replaceattr(void *, long, long); | 189 | static void vga_raster_replaceattr(void *, long, long); | |
190 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | 190 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | |
191 | 191 | |||
192 | const struct wsdisplay_emulops vga_raster_emulops = { | 192 | const struct wsdisplay_emulops vga_raster_emulops = { | |
193 | vga_raster_cursor, | 193 | vga_raster_cursor, | |
194 | vga_raster_mapchar, | 194 | vga_raster_mapchar, | |
195 | vga_raster_putchar, | 195 | vga_raster_putchar, | |
196 | vga_raster_copycols, | 196 | vga_raster_copycols, | |
197 | vga_raster_erasecols, | 197 | vga_raster_erasecols, | |
198 | vga_raster_copyrows, | 198 | vga_raster_copyrows, | |
199 | vga_raster_eraserows, | 199 | vga_raster_eraserows, | |
200 | vga_raster_allocattr, | 200 | vga_raster_allocattr, | |
201 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | 201 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | |
202 | vga_raster_replaceattr, | 202 | vga_raster_replaceattr, | |
203 | #else /* WSDISPLAY_CUSTOM_OUTPUT */ | 203 | #else /* WSDISPLAY_CUSTOM_OUTPUT */ | |
204 | NULL, | 204 | NULL, | |
205 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | 205 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | |
206 | }; | 206 | }; | |
207 | 207 | |||
208 | /* | 208 | /* | |
209 | * translate WS(=ANSI) color codes to standard pc ones | 209 | * translate WS(=ANSI) color codes to standard pc ones | |
210 | */ | 210 | */ | |
211 | static const unsigned char fgansitopc[] = { | 211 | static const unsigned char fgansitopc[] = { | |
212 | #ifdef __alpha__ | 212 | #ifdef __alpha__ | |
213 | /* | 213 | /* | |
214 | * XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!! | 214 | * XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!! | |
215 | * XXX We should probably not bother with this | 215 | * XXX We should probably not bother with this | |
216 | * XXX (reinitialize the palette registers). | 216 | * XXX (reinitialize the palette registers). | |
217 | */ | 217 | */ | |
218 | FG_BLACK, FG_BLUE, FG_GREEN, FG_CYAN, FG_RED, | 218 | FG_BLACK, FG_BLUE, FG_GREEN, FG_CYAN, FG_RED, | |
219 | FG_MAGENTA, FG_BROWN, FG_LIGHTGREY | 219 | FG_MAGENTA, FG_BROWN, FG_LIGHTGREY | |
220 | #else | 220 | #else | |
221 | FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, | 221 | FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, | |
222 | FG_MAGENTA, FG_CYAN, FG_LIGHTGREY | 222 | FG_MAGENTA, FG_CYAN, FG_LIGHTGREY | |
223 | #endif | 223 | #endif | |
224 | }, bgansitopc[] = { | 224 | }, bgansitopc[] = { | |
225 | #ifdef __alpha__ | 225 | #ifdef __alpha__ | |
226 | BG_BLACK, BG_BLUE, BG_GREEN, BG_CYAN, BG_RED, | 226 | BG_BLACK, BG_BLUE, BG_GREEN, BG_CYAN, BG_RED, | |
227 | BG_MAGENTA, BG_BROWN, BG_LIGHTGREY | 227 | BG_MAGENTA, BG_BROWN, BG_LIGHTGREY | |
228 | #else | 228 | #else | |
229 | BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, | 229 | BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, | |
230 | BG_MAGENTA, BG_CYAN, BG_LIGHTGREY | 230 | BG_MAGENTA, BG_CYAN, BG_LIGHTGREY | |
231 | #endif | 231 | #endif | |
232 | }; | 232 | }; | |
233 | 233 | |||
234 | const struct wsscreen_descr vga_25lscreen = { | 234 | const struct wsscreen_descr vga_25lscreen = { | |
235 | "80x25", 80, 25, | 235 | "80x25", 80, 25, | |
236 | &vga_raster_emulops, | 236 | &vga_raster_emulops, | |
237 | 8, 16, | 237 | 8, 16, | |
238 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 238 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
239 | &vga_console_modes[0] | 239 | &vga_console_modes[0] | |
240 | }, vga_25lscreen_mono = { | 240 | }, vga_25lscreen_mono = { | |
241 | "80x25", 80, 25, | 241 | "80x25", 80, 25, | |
242 | &vga_raster_emulops, | 242 | &vga_raster_emulops, | |
243 | 8, 16, | 243 | 8, 16, | |
244 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 244 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
245 | &vga_console_modes[0] | 245 | &vga_console_modes[0] | |
246 | }, vga_30lscreen = { | 246 | }, vga_30lscreen = { | |
247 | "80x30", 80, 30, | 247 | "80x30", 80, 30, | |
248 | &vga_raster_emulops, | 248 | &vga_raster_emulops, | |
249 | 8, 16, | 249 | 8, 16, | |
250 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 250 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
251 | &vga_console_modes[1] | 251 | &vga_console_modes[1] | |
252 | }, vga_30lscreen_mono = { | 252 | }, vga_30lscreen_mono = { | |
253 | "80x30", 80, 30, | 253 | "80x30", 80, 30, | |
254 | &vga_raster_emulops, | 254 | &vga_raster_emulops, | |
255 | 8, 16, | 255 | 8, 16, | |
256 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 256 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
257 | &vga_console_modes[1] | 257 | &vga_console_modes[1] | |
258 | }, vga_40lscreen = { | 258 | }, vga_40lscreen = { | |
259 | "80x40", 80, 40, | 259 | "80x40", 80, 40, | |
260 | &vga_raster_emulops, | 260 | &vga_raster_emulops, | |
261 | 8, 10, | 261 | 8, 10, | |
262 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 262 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
263 | &vga_console_modes[0] | 263 | &vga_console_modes[0] | |
264 | }, vga_40lscreen_mono = { | 264 | }, vga_40lscreen_mono = { | |
265 | "80x40", 80, 40, | 265 | "80x40", 80, 40, | |
266 | &vga_raster_emulops, | 266 | &vga_raster_emulops, | |
267 | 8, 10, | 267 | 8, 10, | |
268 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 268 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
269 | &vga_console_modes[0] | 269 | &vga_console_modes[0] | |
270 | }, vga_50lscreen = { | 270 | }, vga_50lscreen = { | |
271 | "80x50", 80, 50, | 271 | "80x50", 80, 50, | |
272 | &vga_raster_emulops, | 272 | &vga_raster_emulops, | |
273 | 8, 8, | 273 | 8, 8, | |
274 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | 274 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_BLINK, | |
275 | &vga_console_modes[0] | 275 | &vga_console_modes[0] | |
276 | }, vga_50lscreen_mono = { | 276 | }, vga_50lscreen_mono = { | |
277 | "80x50", 80, 50, | 277 | "80x50", 80, 50, | |
278 | &vga_raster_emulops, | 278 | &vga_raster_emulops, | |
279 | 8, 8, | 279 | 8, 8, | |
280 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | 280 | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_BLINK | WSSCREEN_REVERSE, | |
281 | &vga_console_modes[0] | 281 | &vga_console_modes[0] | |
282 | }; | 282 | }; | |
283 | 283 | |||
284 | const struct wsscreen_descr *_vga_scrlist[] = { | 284 | const struct wsscreen_descr *_vga_scrlist[] = { | |
285 | &vga_25lscreen, | 285 | &vga_25lscreen, | |
286 | &vga_30lscreen, | 286 | &vga_30lscreen, | |
287 | &vga_40lscreen, | 287 | &vga_40lscreen, | |
288 | &vga_50lscreen, | 288 | &vga_50lscreen, | |
289 | }, *_vga_scrlist_mono[] = { | 289 | }, *_vga_scrlist_mono[] = { | |
290 | &vga_25lscreen_mono, | 290 | &vga_25lscreen_mono, | |
291 | &vga_30lscreen_mono, | 291 | &vga_30lscreen_mono, | |
292 | &vga_40lscreen_mono, | 292 | &vga_40lscreen_mono, | |
293 | &vga_50lscreen_mono, | 293 | &vga_50lscreen_mono, | |
294 | }; | 294 | }; | |
295 | 295 | |||
296 | const struct wsscreen_list vga_screenlist = { | 296 | const struct wsscreen_list vga_screenlist = { | |
297 | sizeof(_vga_scrlist) / sizeof(struct wsscreen_descr *), | 297 | sizeof(_vga_scrlist) / sizeof(struct wsscreen_descr *), | |
298 | _vga_scrlist | 298 | _vga_scrlist | |
299 | }, vga_screenlist_mono = { | 299 | }, vga_screenlist_mono = { | |
300 | sizeof(_vga_scrlist_mono) / sizeof(struct wsscreen_descr *), | 300 | sizeof(_vga_scrlist_mono) / sizeof(struct wsscreen_descr *), | |
301 | _vga_scrlist_mono | 301 | _vga_scrlist_mono | |
302 | }; | 302 | }; | |
303 | 303 | |||
304 | static int vga_raster_ioctl(void *, void *, u_long, void *, int, | 304 | static int vga_raster_ioctl(void *, void *, u_long, void *, int, | |
305 | struct lwp *); | 305 | struct lwp *); | |
306 | static paddr_t vga_raster_mmap(void *, void *, off_t, int); | 306 | static paddr_t vga_raster_mmap(void *, void *, off_t, int); | |
307 | static int vga_raster_alloc_screen(void *, const struct wsscreen_descr *, | 307 | static int vga_raster_alloc_screen(void *, const struct wsscreen_descr *, | |
308 | void **, int *, int *, long *); | 308 | void **, int *, int *, long *); | |
309 | static void vga_raster_free_screen(void *, void *); | 309 | static void vga_raster_free_screen(void *, void *); | |
310 | static int vga_raster_show_screen(void *, void *, int, | 310 | static int vga_raster_show_screen(void *, void *, int, | |
311 | void (*)(void *, int, int), void *); | 311 | void (*)(void *, int, int), void *); | |
312 | static int vga_raster_load_font(void *, void *, struct wsdisplay_font *); | 312 | static int vga_raster_load_font(void *, void *, struct wsdisplay_font *); | |
313 | 313 | |||
314 | static void vga_switch_screen(struct vga_config *); | 314 | static void vga_switch_screen(struct vga_config *); | |
315 | static void vga_raster_setscreentype(struct vga_config *, | 315 | static void vga_raster_setscreentype(struct vga_config *, | |
316 | const struct wsscreen_descr *); | 316 | const struct wsscreen_descr *); | |
317 | 317 | |||
318 | const struct wsdisplay_accessops vga_raster_accessops = { | 318 | const struct wsdisplay_accessops vga_raster_accessops = { | |
319 | vga_raster_ioctl, | 319 | vga_raster_ioctl, | |
320 | vga_raster_mmap, | 320 | vga_raster_mmap, | |
321 | vga_raster_alloc_screen, | 321 | vga_raster_alloc_screen, | |
322 | vga_raster_free_screen, | 322 | vga_raster_free_screen, | |
323 | vga_raster_show_screen, | 323 | vga_raster_show_screen, | |
324 | vga_raster_load_font, | 324 | vga_raster_load_font, | |
325 | NULL, /* pollc */ | 325 | NULL, /* pollc */ | |
326 | NULL, /* scroll */ | 326 | NULL, /* scroll */ | |
327 | }; | 327 | }; | |
328 | 328 | |||
329 | int | 329 | int | |
330 | vga_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check) | 330 | vga_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check) | |
331 | { | 331 | { | |
332 | long defattr; | 332 | long defattr; | |
333 | const struct wsscreen_descr *scr; | 333 | const struct wsscreen_descr *scr; | |
334 | #ifdef VGA_CONSOLE_SCREENTYPE | 334 | #ifdef VGA_CONSOLE_SCREENTYPE | |
335 | const char *typestr = NULL; | 335 | const char *typestr = NULL; | |
336 | #endif | 336 | #endif | |
337 | 337 | |||
338 | if (check && !vga_common_probe(iot, memt)) | 338 | if (check && !vga_common_probe(iot, memt)) | |
339 | return (ENXIO); | 339 | return (ENXIO); | |
340 | 340 | |||
341 | /* set up bus-independent VGA configuration */ | 341 | /* set up bus-independent VGA configuration */ | |
342 | vga_raster_init(&vga_console_vc, iot, memt); | 342 | vga_raster_init(&vga_console_vc, iot, memt); | |
343 | #ifdef VGA_CONSOLE_SCREENTYPE | 343 | #ifdef VGA_CONSOLE_SCREENTYPE | |
344 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | 344 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | |
345 | &vga_screenlist_mono : &vga_screenlist, VGA_CONSOLE_SCREENTYPE); | 345 | &vga_screenlist_mono : &vga_screenlist, VGA_CONSOLE_SCREENTYPE); | |
346 | if (!scr) | 346 | if (!scr) | |
347 | /* Invalid screen type, continue with the default mode. */ | 347 | /* Invalid screen type, continue with the default mode. */ | |
348 | typestr = "80x25"; | 348 | typestr = "80x25"; | |
349 | else if (scr->nrows > 30) | 349 | else if (scr->nrows > 30) | |
350 | /* Unsupported screen type, try 80x30. */ | 350 | /* Unsupported screen type, try 80x30. */ | |
351 | typestr = "80x30"; | 351 | typestr = "80x30"; | |
352 | if (typestr) | 352 | if (typestr) | |
353 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | 353 | scr = wsdisplay_screentype_pick(vga_console_vc.hdl.vh_mono ? | |
354 | &vga_screenlist_mono : &vga_screenlist, typestr); | 354 | &vga_screenlist_mono : &vga_screenlist, typestr); | |
355 | if (scr != vga_console_vc.currenttype) | 355 | if (scr != vga_console_vc.currenttype) | |
356 | vga_console_vc.currenttype = scr; | 356 | vga_console_vc.currenttype = scr; | |
357 | #else | 357 | #else | |
358 | scr = vga_console_vc.currenttype; | 358 | scr = vga_console_vc.currenttype; | |
359 | #endif | 359 | #endif | |
360 | vga_raster_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, | 360 | vga_raster_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, | |
361 | &defattr); | 361 | &defattr); | |
362 | 362 | |||
363 | vga_console_screen.active = 1; | 363 | vga_console_screen.active = 1; | |
364 | vga_console_vc.active = &vga_console_screen; | 364 | vga_console_vc.active = &vga_console_screen; | |
365 | 365 | |||
366 | wsdisplay_cnattach(scr, &vga_console_screen, | 366 | wsdisplay_cnattach(scr, &vga_console_screen, | |
367 | vga_console_screen.cursorcol, vga_console_screen.cursorrow, | 367 | vga_console_screen.cursorcol, vga_console_screen.cursorrow, | |
368 | defattr); | 368 | defattr); | |
369 | 369 | |||
370 | vgaconsole = 1; | 370 | vgaconsole = 1; | |
371 | vga_console_type = type; | 371 | vga_console_type = type; | |
372 | return (0); | 372 | return (0); | |
373 | } | 373 | } | |
374 | 374 | |||
375 | void | 375 | static void | |
376 | vga_raster_init(struct vga_config *vc, bus_space_tag_t iot, | 376 | vga_raster_init(struct vga_config *vc, bus_space_tag_t iot, | |
377 | bus_space_tag_t memt) | 377 | bus_space_tag_t memt) | |
378 | { | 378 | { | |
379 | struct vga_handle *vh = &vc->hdl; | 379 | struct vga_handle *vh = &vc->hdl; | |
380 | u_int8_t mor; | 380 | u_int8_t mor; | |
381 | struct vga_raster_font *vf; | 381 | struct vga_raster_font *vf; | |
382 | 382 | |||
383 | vh->vh_iot = iot; | 383 | vh->vh_iot = iot; | |
384 | vh->vh_memt = memt; | 384 | vh->vh_memt = memt; | |
385 | 385 | |||
386 | if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) | 386 | if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) | |
387 | panic("vga_raster_init: couldn't map vga io"); | 387 | panic("vga_raster_init: couldn't map vga io"); | |
388 | 388 | |||
389 | /* read "misc output register" */ | 389 | /* read "misc output register" */ | |
390 | mor = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAR); | 390 | mor = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAR); | |
391 | vh->vh_mono = !(mor & 1); | 391 | vh->vh_mono = !(mor & 1); | |
392 | 392 | |||
393 | if (bus_space_map(vh->vh_iot, (vh->vh_mono ? 0x3b0 : 0x3d0), 0x10, 0, | 393 | if (bus_space_map(vh->vh_iot, (vh->vh_mono ? 0x3b0 : 0x3d0), 0x10, 0, | |
394 | &vh->vh_ioh_6845)) | 394 | &vh->vh_ioh_6845)) | |
395 | panic("vga_raster_init: couldn't map 6845 io"); | 395 | panic("vga_raster_init: couldn't map 6845 io"); | |
396 | 396 | |||
397 | if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh)) | 397 | if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh)) | |
398 | panic("vga_raster_init: couldn't map memory"); | 398 | panic("vga_raster_init: couldn't map memory"); | |
399 | 399 | |||
400 | if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh, 0, 0x10000, | 400 | if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh, 0, 0x10000, | |
401 | &vh->vh_memh)) | 401 | &vh->vh_memh)) | |
402 | panic("vga_raster_init: mem subrange failed"); | 402 | panic("vga_raster_init: mem subrange failed"); | |
403 | 403 | |||
404 | /* should only reserve the space (no need to map - save KVM) */ | 404 | /* should only reserve the space (no need to map - save KVM) */ | |
405 | vc->vc_biostag = memt; | 405 | vc->vc_biostag = memt; | |
406 | if (bus_space_map(vc->vc_biostag, 0xc0000, 0x8000, 0, &vc->vc_bioshdl)) | 406 | if (bus_space_map(vc->vc_biostag, 0xc0000, 0x8000, 0, &vc->vc_bioshdl)) | |
407 | vc->vc_biosmapped = 0; | 407 | vc->vc_biosmapped = 0; | |
408 | else | 408 | else | |
409 | vc->vc_biosmapped = 1; | 409 | vc->vc_biosmapped = 1; | |
410 | 410 | |||
411 | vc->nscreens = 0; | 411 | vc->nscreens = 0; | |
412 | LIST_INIT(&vc->screens); | 412 | LIST_INIT(&vc->screens); | |
413 | vc->active = NULL; | 413 | vc->active = NULL; | |
414 | vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen; | 414 | vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen; | |
415 | callout_init(&vc->vc_switch_callout, 0); | 415 | callout_init(&vc->vc_switch_callout, 0); | |
416 | 416 | |||
417 | wsfont_init(); | 417 | wsfont_init(); | |
418 | vc->nfonts = 1; | 418 | vc->nfonts = 1; | |
419 | LIST_INIT(&vc->vc_fontlist); | 419 | LIST_INIT(&vc->vc_fontlist); | |
420 | vf = &vga_console_fontset_ascii; | 420 | vf = &vga_console_fontset_ascii; | |
421 | if (vga_no_builtinfont) { | 421 | if (vga_no_builtinfont) { | |
422 | struct wsdisplay_font *wf; | 422 | struct wsdisplay_font *wf; | |
423 | int cookie; | 423 | int cookie; | |
424 | 424 | |||
425 | /* prefer 8x16 pixel font */ | 425 | /* prefer 8x16 pixel font */ | |
426 | cookie = wsfont_find(NULL, 8, 16, 0, WSDISPLAY_FONTORDER_L2R, | 426 | cookie = wsfont_find(NULL, 8, 16, 0, WSDISPLAY_FONTORDER_L2R, | |
427 | 0, WSFONT_FIND_BITMAP); | 427 | 0, WSFONT_FIND_BITMAP); | |
428 | if (cookie == -1) | 428 | if (cookie == -1) | |
429 | cookie = wsfont_find(NULL, 0, 0, 0, | 429 | cookie = wsfont_find(NULL, 0, 0, 0, | |
430 | WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R, | 430 | WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R, | |
431 | WSFONT_FIND_BITMAP); | 431 | WSFONT_FIND_BITMAP); | |
432 | if (cookie == -1 || wsfont_lock(cookie, &wf)) | 432 | if (cookie == -1 || wsfont_lock(cookie, &wf)) | |
433 | panic("vga_raster_init: can't load console font"); | 433 | panic("vga_raster_init: can't load console font"); | |
434 | vf->font = wf; | 434 | vf->font = wf; | |
435 | } else { | 435 | } else { | |
436 | vga_load_builtinfont(vh, builtinfont_data, 0, 256); | 436 | vga_load_builtinfont(vh, builtinfont_data, 0, 256); | |
437 | vf->font = &builtinfont; | 437 | vf->font = &builtinfont; | |
438 | } | 438 | } | |
439 | LIST_INSERT_HEAD(&vc->vc_fontlist, vf, next); | 439 | LIST_INSERT_HEAD(&vc->vc_fontlist, vf, next); | |
440 | } | 440 | } | |
441 | 441 | |||
442 | void | 442 | static void | |
443 | vga_raster_init_screen(struct vga_config *vc, struct vgascreen *scr, | 443 | vga_raster_init_screen(struct vga_config *vc, struct vgascreen *scr, | |
444 | const struct wsscreen_descr *type, int existing, long *attrp) | 444 | const struct wsscreen_descr *type, int existing, long *attrp) | |
445 | { | 445 | { | |
446 | int cpos; | 446 | int cpos; | |
447 | int res; | 447 | int res; | |
448 | struct vga_handle *vh; | 448 | struct vga_handle *vh; | |
449 | 449 | |||
450 | scr->cfg = vc; | 450 | scr->cfg = vc; | |
451 | scr->hdl = &vc->hdl; | 451 | scr->hdl = &vc->hdl; | |
452 | scr->type = type; | 452 | scr->type = type; | |
453 | scr->mindispoffset = 0; | 453 | scr->mindispoffset = 0; | |
454 | scr->maxdispoffset = scr->dispoffset + | 454 | scr->maxdispoffset = scr->dispoffset + | |
455 | type->nrows * type->ncols * type->fontheight; | 455 | type->nrows * type->ncols * type->fontheight; | |
456 | vh = &vc->hdl; | 456 | vh = &vc->hdl; | |
457 | 457 | |||
458 | LIST_INIT(&scr->fontset); | 458 | LIST_INIT(&scr->fontset); | |
459 | vga_raster_setup_font(vc, scr); | 459 | vga_raster_setup_font(vc, scr); | |
460 | 460 | |||
461 | if (existing) { | 461 | if (existing) { | |
462 | int i; | 462 | int i; | |
463 | 463 | |||
464 | cpos = vga_6845_read(vh, cursorh) << 8; | 464 | cpos = vga_6845_read(vh, cursorh) << 8; | |
465 | cpos |= vga_6845_read(vh, cursorl); | 465 | cpos |= vga_6845_read(vh, cursorl); | |
466 | 466 | |||
467 | /* make sure we have a valid cursor position */ | 467 | /* make sure we have a valid cursor position */ | |
468 | if (cpos < 0 || cpos >= type->nrows * type->ncols) | 468 | if (cpos < 0 || cpos >= type->nrows * type->ncols) | |
469 | cpos = 0; | 469 | cpos = 0; | |
470 | 470 | |||
471 | scr->dispoffset = vga_6845_read(vh, startadrh) << 9; | 471 | scr->dispoffset = vga_6845_read(vh, startadrh) << 9; | |
472 | scr->dispoffset |= vga_6845_read(vh, startadrl) << 1; | 472 | scr->dispoffset |= vga_6845_read(vh, startadrl) << 1; | |
473 | 473 | |||
474 | /* make sure we have a valid memory offset */ | 474 | /* make sure we have a valid memory offset */ | |
475 | if (scr->dispoffset < scr->mindispoffset || | 475 | if (scr->dispoffset < scr->mindispoffset || | |
476 | scr->dispoffset > scr->maxdispoffset) | 476 | scr->dispoffset > scr->maxdispoffset) | |
477 | scr->dispoffset = scr->mindispoffset; | 477 | scr->dispoffset = scr->mindispoffset; | |
478 | 478 | |||
479 | scr->mem = boot_scrmem; | 479 | scr->mem = boot_scrmem; | |
480 | scr->active = 1; | 480 | scr->active = 1; | |
481 | 481 | |||
482 | /* Save the current screen to memory. XXXBJY assume 80x25 */ | 482 | /* Save the current screen to memory. XXXBJY assume 80x25 */ | |
483 | for (i = 0; i < 80 * 25; i++) { | 483 | for (i = 0; i < 80 * 25; i++) { | |
484 | scr->mem[i].ch = bus_space_read_1(vh->vh_memt, | 484 | scr->mem[i].ch = bus_space_read_1(vh->vh_memt, | |
485 | vh->vh_allmemh, 0x18000 + i * 2); | 485 | vh->vh_allmemh, 0x18000 + i * 2); | |
486 | scr->mem[i].attr = bus_space_read_1(vh->vh_memt, | 486 | scr->mem[i].attr = bus_space_read_1(vh->vh_memt, | |
487 | vh->vh_allmemh, 0x18000 + i * 2 + 1); | 487 | vh->vh_allmemh, 0x18000 + i * 2 + 1); | |
488 | scr->mem[i].enc = scr->encoding; | 488 | scr->mem[i].enc = scr->encoding; | |
489 | } | 489 | } | |
490 | 490 | |||
491 | vga_raster_setscreentype(vc, type); | 491 | vga_raster_setscreentype(vc, type); | |
492 | 492 | |||
493 | /* Clear the entire screen. */ | 493 | /* Clear the entire screen. */ | |
494 | vga_gdc_write(vh, mode, 0x02); | 494 | vga_gdc_write(vh, mode, 0x02); | |
495 | bus_space_set_region_4(vh->vh_memt, vh->vh_allmemh, 0, 0, | 495 | bus_space_set_region_4(vh->vh_memt, vh->vh_allmemh, 0, 0, | |
496 | 0x4000); | 496 | 0x4000); | |
497 | 497 | |||
498 | vga_restore_screen(scr, type, scr->mem); | 498 | vga_restore_screen(scr, type, scr->mem); | |
499 | } else { | 499 | } else { | |
500 | cpos = 0; | 500 | cpos = 0; | |
501 | scr->dispoffset = scr->mindispoffset; | 501 | scr->dispoffset = scr->mindispoffset; | |
502 | scr->mem = NULL; | 502 | scr->mem = NULL; | |
503 | scr->active = 0; | 503 | scr->active = 0; | |
504 | } | 504 | } | |
505 | 505 | |||
506 | scr->cursorrow = cpos / type->ncols; | 506 | scr->cursorrow = cpos / type->ncols; | |
507 | scr->cursorcol = cpos % type->ncols; | 507 | scr->cursorcol = cpos % type->ncols; | |
508 | vga_raster_cursor_init(scr, existing); | 508 | vga_raster_cursor_init(scr, existing); | |
509 | 509 | |||
510 | #ifdef __alpha__ | 510 | #ifdef __alpha__ | |
511 | if (!vc->hdl.vh_mono) | 511 | if (!vc->hdl.vh_mono) | |
512 | /* | 512 | /* | |
513 | * DEC firmware uses a blue background. | 513 | * DEC firmware uses a blue background. | |
514 | */ | 514 | */ | |
515 | res = vga_raster_allocattr(scr, WSCOL_WHITE, WSCOL_BLUE, | 515 | res = vga_raster_allocattr(scr, WSCOL_WHITE, WSCOL_BLUE, | |
516 | WSATTR_WSCOLORS, attrp); | 516 | WSATTR_WSCOLORS, attrp); | |
517 | else | 517 | else | |
518 | #endif | 518 | #endif | |
519 | res = vga_raster_allocattr(scr, 0, 0, 0, attrp); | 519 | res = vga_raster_allocattr(scr, 0, 0, 0, attrp); | |
520 | #ifdef DIAGNOSTIC | 520 | #ifdef DIAGNOSTIC | |
521 | if (res) | 521 | if (res) | |
522 | panic("vga_raster_init_screen: attribute botch"); | 522 | panic("vga_raster_init_screen: attribute botch"); | |
523 | #endif | 523 | #endif | |
524 | 524 | |||
525 | vc->nscreens++; | 525 | vc->nscreens++; | |
526 | LIST_INSERT_HEAD(&vc->screens, scr, next); | 526 | LIST_INSERT_HEAD(&vc->screens, scr, next); | |
527 | } | 527 | } | |
528 | 528 | |||
529 | void | 529 | void | |
530 | vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot, | 530 | vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot, | |
531 | bus_space_tag_t memt, int type, int quirks, | 531 | bus_space_tag_t memt, int type, int quirks, | |
532 | const struct vga_funcs *vf) | 532 | const struct vga_funcs *vf) | |
533 | { | 533 | { | |
534 | int console; | 534 | int console; | |
535 | struct vga_config *vc; | 535 | struct vga_config *vc; | |
536 | struct wsemuldisplaydev_attach_args aa; | 536 | struct wsemuldisplaydev_attach_args aa; | |
537 | 537 | |||
538 | console = vga_is_console(iot, type); | 538 | console = vga_is_console(iot, type); | |
539 | 539 | |||
540 | if (console) { | 540 | if (console) { | |
541 | vc = &vga_console_vc; | 541 | vc = &vga_console_vc; | |
542 | vga_console_attached = 1; | 542 | vga_console_attached = 1; | |
543 | } else { | 543 | } else { | |
544 | vc = malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK); | 544 | vc = malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK); | |
545 | vga_raster_init(vc, iot, memt); | 545 | vga_raster_init(vc, iot, memt); | |
546 | } | 546 | } | |
547 | 547 | |||
548 | vc->vc_type = type; | 548 | vc->vc_type = type; | |
549 | vc->vc_funcs = vf; | 549 | vc->vc_funcs = vf; | |
550 | 550 | |||
551 | sc->sc_vc = vc; | 551 | sc->sc_vc = vc; | |
552 | vc->softc = sc; | 552 | vc->softc = sc; | |
553 | 553 | |||
554 | aa.console = console; | 554 | aa.console = console; | |
555 | aa.scrdata = (vc->hdl.vh_mono ? &vga_screenlist_mono : &vga_screenlist); | 555 | aa.scrdata = (vc->hdl.vh_mono ? &vga_screenlist_mono : &vga_screenlist); | |
556 | aa.accessops = &vga_raster_accessops; | 556 | aa.accessops = &vga_raster_accessops; | |
557 | aa.accesscookie = vc; | 557 | aa.accesscookie = vc; | |
558 | 558 | |||
559 | config_found(sc->sc_dev, &aa, wsemuldisplaydevprint); | 559 | config_found(sc->sc_dev, &aa, wsemuldisplaydevprint); | |
560 | } | 560 | } | |
561 | 561 | |||
562 | int | 562 | int | |
563 | vga_cndetach(void) | 563 | vga_cndetach(void) | |
564 | { | 564 | { | |
565 | struct vga_config *vc; | 565 | struct vga_config *vc; | |
566 | struct vga_handle *vh; | 566 | struct vga_handle *vh; | |
567 | 567 | |||
568 | vc = &vga_console_vc; | 568 | vc = &vga_console_vc; | |
569 | vh = &vc->hdl; | 569 | vh = &vc->hdl; | |
570 | 570 | |||
571 | if (vgaconsole) { | 571 | if (vgaconsole) { | |
572 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_vga, 0x10); | 572 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_vga, 0x10); | |
573 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10); | 573 | bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10); | |
574 | 574 | |||
575 | return 1; | 575 | return 1; | |
576 | } | 576 | } | |
577 | 577 | |||
578 | return 0; | 578 | return 0; | |
579 | } | 579 | } | |
580 | 580 | |||
581 | int | 581 | int | |
582 | vga_is_console(bus_space_tag_t iot, int type) | 582 | vga_is_console(bus_space_tag_t iot, int type) | |
583 | { | 583 | { | |
584 | if (vgaconsole && | 584 | if (vgaconsole && | |
585 | !vga_console_attached && | 585 | !vga_console_attached && | |
586 | iot == vga_console_vc.hdl.vh_iot && | 586 | iot == vga_console_vc.hdl.vh_iot && | |
587 | (vga_console_type == -1 || (type == vga_console_type))) | 587 | (vga_console_type == -1 || (type == vga_console_type))) | |
588 | return (1); | 588 | return (1); | |
589 | return (0); | 589 | return (0); | |
590 | } | 590 | } | |
591 | 591 | |||
592 | static int | 592 | static int | |
593 | vga_get_video(struct vga_config *vc) | 593 | vga_get_video(struct vga_config *vc) | |
594 | { | 594 | { | |
595 | 595 | |||
596 | return (vga_ts_read(&vc->hdl, mode) & VGA_TS_MODE_BLANK) == 0; | 596 | return (vga_ts_read(&vc->hdl, mode) & VGA_TS_MODE_BLANK) == 0; | |
597 | } | 597 | } | |
598 | 598 | |||
599 | static void | 599 | static void | |
600 | vga_set_video(struct vga_config *vc, int state) | 600 | vga_set_video(struct vga_config *vc, int state) | |
601 | { | 601 | { | |
602 | int val; | 602 | int val; | |
603 | 603 | |||
604 | vga_ts_write(&vc->hdl, syncreset, 0x01); | 604 | vga_ts_write(&vc->hdl, syncreset, 0x01); | |
605 | if (state) { /* unblank screen */ | 605 | if (state) { /* unblank screen */ | |
606 | val = vga_ts_read(&vc->hdl, mode); | 606 | val = vga_ts_read(&vc->hdl, mode); | |
607 | vga_ts_write(&vc->hdl, mode, val & ~VGA_TS_MODE_BLANK); | 607 | vga_ts_write(&vc->hdl, mode, val & ~VGA_TS_MODE_BLANK); | |
608 | #ifndef VGA_NO_VBLANK | 608 | #ifndef VGA_NO_VBLANK | |
609 | val = vga_6845_read(&vc->hdl, mode); | 609 | val = vga_6845_read(&vc->hdl, mode); | |
610 | vga_6845_write(&vc->hdl, mode, val | 0x80); | 610 | vga_6845_write(&vc->hdl, mode, val | 0x80); | |
611 | #endif | 611 | #endif | |
612 | } else { /* blank screen */ | 612 | } else { /* blank screen */ | |
613 | val = vga_ts_read(&vc->hdl, mode); | 613 | val = vga_ts_read(&vc->hdl, mode); | |
614 | vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK); | 614 | vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK); | |
615 | #ifndef VGA_NO_VBLANK | 615 | #ifndef VGA_NO_VBLANK | |
616 | val = vga_6845_read(&vc->hdl, mode); | 616 | val = vga_6845_read(&vc->hdl, mode); | |
617 | vga_6845_write(&vc->hdl, mode, val & ~0x80); | 617 | vga_6845_write(&vc->hdl, mode, val & ~0x80); | |
618 | #endif | 618 | #endif | |
619 | } | 619 | } | |
620 | vga_ts_write(&vc->hdl, syncreset, 0x03); | 620 | vga_ts_write(&vc->hdl, syncreset, 0x03); | |
621 | } | 621 | } | |
622 | 622 | |||
623 | int | 623 | int | |
624 | vga_raster_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, | 624 | vga_raster_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, | |
625 | struct lwp *l) | 625 | struct lwp *l) | |
626 | { | 626 | { | |
627 | struct vga_config *vc = v; | 627 | struct vga_config *vc = v; | |
628 | const struct vga_funcs *vf = vc->vc_funcs; | 628 | const struct vga_funcs *vf = vc->vc_funcs; | |
629 | 629 | |||
630 | switch (cmd) { | 630 | switch (cmd) { | |
631 | case WSDISPLAYIO_GTYPE: | 631 | case WSDISPLAYIO_GTYPE: | |
632 | *(int *)data = vc->vc_type; | 632 | *(int *)data = vc->vc_type; | |
633 | return 0; | 633 | return 0; | |
634 | 634 | |||
635 | case WSDISPLAYIO_GINFO: | 635 | case WSDISPLAYIO_GINFO: | |
636 | /* XXX should get detailed hardware information here */ | 636 | /* XXX should get detailed hardware information here */ | |
637 | return EPASSTHROUGH; | 637 | return EPASSTHROUGH; | |
638 | 638 | |||
639 | case WSDISPLAYIO_GVIDEO: | 639 | case WSDISPLAYIO_GVIDEO: | |
640 | #if 1 | 640 | #if 1 | |
641 | *(int *)data = (vga_get_video(vc) ? | 641 | *(int *)data = (vga_get_video(vc) ? | |
642 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF); | 642 | WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF); | |
643 | return 0; | 643 | return 0; | |
644 | #endif | 644 | #endif | |
645 | 645 | |||
646 | case WSDISPLAYIO_SVIDEO: | 646 | case WSDISPLAYIO_SVIDEO: | |
647 | #if 1 | 647 | #if 1 | |
648 | vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON); | 648 | vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON); | |
649 | return 0; | 649 | return 0; | |
650 | #endif | 650 | #endif | |
651 | 651 | |||
652 | case WSDISPLAYIO_GETCMAP: | 652 | case WSDISPLAYIO_GETCMAP: | |
653 | case WSDISPLAYIO_PUTCMAP: | 653 | case WSDISPLAYIO_PUTCMAP: | |
654 | case WSDISPLAYIO_GCURPOS: | 654 | case WSDISPLAYIO_GCURPOS: | |
655 | case WSDISPLAYIO_SCURPOS: | 655 | case WSDISPLAYIO_SCURPOS: | |
656 | case WSDISPLAYIO_GCURMAX: | 656 | case WSDISPLAYIO_GCURMAX: | |
657 | case WSDISPLAYIO_GCURSOR: | 657 | case WSDISPLAYIO_GCURSOR: | |
658 | case WSDISPLAYIO_SCURSOR: | 658 | case WSDISPLAYIO_SCURSOR: | |
659 | /* NONE of these operations are by the generic VGA driver. */ | 659 | /* NONE of these operations are by the generic VGA driver. */ | |
660 | return EPASSTHROUGH; | 660 | return EPASSTHROUGH; | |
661 | } | 661 | } | |
662 | 662 | |||
663 | if (vc->vc_funcs == NULL) | 663 | if (vc->vc_funcs == NULL) | |
664 | return (EPASSTHROUGH); | 664 | return (EPASSTHROUGH); | |
665 | 665 | |||
666 | if (vf->vf_ioctl == NULL) | 666 | if (vf->vf_ioctl == NULL) | |
667 | return (EPASSTHROUGH); | 667 | return (EPASSTHROUGH); | |
668 | 668 | |||
669 | return ((*vf->vf_ioctl)(v, cmd, data, flag, l)); | 669 | return ((*vf->vf_ioctl)(v, cmd, data, flag, l)); | |
670 | } | 670 | } | |
671 | 671 | |||
672 | static paddr_t | 672 | static paddr_t | |
673 | vga_raster_mmap(void *v, void *vs, off_t offset, int prot) | 673 | vga_raster_mmap(void *v, void *vs, off_t offset, int prot) | |
674 | { | 674 | { | |
675 | struct vga_config *vc = v; | 675 | struct vga_config *vc = v; | |
676 | const struct vga_funcs *vf = vc->vc_funcs; | 676 | const struct vga_funcs *vf = vc->vc_funcs; | |
677 | 677 | |||
678 | if (vc->vc_funcs == NULL) | 678 | if (vc->vc_funcs == NULL) | |
679 | return (-1); | 679 | return (-1); | |
680 | 680 | |||
681 | if (vf->vf_mmap == NULL) | 681 | if (vf->vf_mmap == NULL) | |
682 | return (-1); | 682 | return (-1); | |
683 | 683 | |||
684 | return ((*vf->vf_mmap)(v, offset, prot)); | 684 | return ((*vf->vf_mmap)(v, offset, prot)); | |
685 | } | 685 | } | |
686 | 686 | |||
687 | int | 687 | static int | |
688 | vga_raster_alloc_screen(void *v, const struct wsscreen_descr *type, | 688 | vga_raster_alloc_screen(void *v, const struct wsscreen_descr *type, | |
689 | void **cookiep, int *curxp, int *curyp, long *defattrp) | 689 | void **cookiep, int *curxp, int *curyp, long *defattrp) | |
690 | { | 690 | { | |
691 | struct vga_config *vc = v; | 691 | struct vga_config *vc = v; | |
692 | struct vgascreen *scr; | 692 | struct vgascreen *scr; | |
693 | 693 | |||
694 | if (vc->nscreens == 1) { | 694 | if (vc->nscreens == 1) { | |
695 | vc->screens.lh_first->mem = boot_scrmem; | 695 | vc->screens.lh_first->mem = boot_scrmem; | |
696 | } | 696 | } | |
697 | 697 | |||
698 | scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK); | 698 | scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK); | |
699 | vga_raster_init_screen(vc, scr, type, vc->nscreens == 0, defattrp); | 699 | vga_raster_init_screen(vc, scr, type, vc->nscreens == 0, defattrp); | |
700 | 700 | |||
701 | if (vc->nscreens == 1) { | 701 | if (vc->nscreens == 1) { | |
702 | scr->active = 1; | 702 | scr->active = 1; | |
703 | vc->active = scr; | 703 | vc->active = scr; | |
704 | vc->currenttype = type; | 704 | vc->currenttype = type; | |
705 | } else { | 705 | } else { | |
706 | scr->mem = malloc(sizeof(struct vga_scrmem) * | 706 | scr->mem = malloc(sizeof(struct vga_scrmem) * | |
707 | type->ncols * type->nrows, M_DEVBUF, M_WAITOK); | 707 | type->ncols * type->nrows, M_DEVBUF, M_WAITOK); | |
708 | vga_raster_eraserows(scr, 0, type->nrows, *defattrp); | 708 | vga_raster_eraserows(scr, 0, type->nrows, *defattrp); | |
709 | } | 709 | } | |
710 | 710 | |||
711 | *cookiep = scr; | 711 | *cookiep = scr; | |
712 | *curxp = scr->cursorcol; | 712 | *curxp = scr->cursorcol; | |
713 | *curyp = scr->cursorrow; | 713 | *curyp = scr->cursorrow; | |
714 | 714 | |||
715 | return (0); | 715 | return (0); | |
716 | } | 716 | } | |
717 | 717 | |||
718 | void | 718 | static void | |
719 | vga_raster_free_screen(void *v, void *cookie) | 719 | vga_raster_free_screen(void *v, void *cookie) | |
720 | { | 720 | { | |
721 | struct vgascreen *vs = cookie; | 721 | struct vgascreen *vs = cookie; | |
722 | struct vga_config *vc = vs->cfg; | 722 | struct vga_config *vc = vs->cfg; | |
723 | 723 | |||
724 | LIST_REMOVE(vs, next); | 724 | LIST_REMOVE(vs, next); | |
725 | vc->nscreens--; | 725 | vc->nscreens--; | |
726 | if (vs != &vga_console_screen) | 726 | if (vs != &vga_console_screen) | |
727 | free(vs, M_DEVBUF); | 727 | free(vs, M_DEVBUF); | |
728 | else | 728 | else | |
729 | panic("vga_raster_free_screen: console"); | 729 | panic("vga_raster_free_screen: console"); | |
730 | 730 | |||
731 | if (vc->active == vs) | 731 | if (vc->active == vs) | |
732 | vc->active = 0; | 732 | vc->active = 0; | |
733 | } | 733 | } | |
734 | 734 | |||
735 | int | 735 | static int | |
736 | vga_raster_show_screen(void *v, void *cookie, int waitok, | 736 | vga_raster_show_screen(void *v, void *cookie, int waitok, | |
737 | void (*cb)(void *, int, int), void *cbarg) | 737 | void (*cb)(void *, int, int), void *cbarg) | |
738 | { | 738 | { | |
739 | struct vgascreen *scr = cookie, *oldscr; | 739 | struct vgascreen *scr = cookie, *oldscr; | |
740 | struct vga_config *vc = scr->cfg; | 740 | struct vga_config *vc = scr->cfg; | |
741 | 741 | |||
742 | oldscr = vc->active; /* can be NULL! */ | 742 | oldscr = vc->active; /* can be NULL! */ | |
743 | if (scr == oldscr) { | 743 | if (scr == oldscr) { | |
744 | return (0); | 744 | return (0); | |
745 | } | 745 | } | |
746 | 746 | |||
747 | vc->wantedscreen = cookie; | 747 | vc->wantedscreen = cookie; | |
748 | vc->switchcb = cb; | 748 | vc->switchcb = cb; | |
749 | vc->switchcbarg = cbarg; | 749 | vc->switchcbarg = cbarg; | |
750 | if (cb) { | 750 | if (cb) { | |
751 | callout_reset(&vc->vc_switch_callout, 0, | 751 | callout_reset(&vc->vc_switch_callout, 0, | |
752 | (void(*)(void *))vga_switch_screen, vc); | 752 | (void(*)(void *))vga_switch_screen, vc); | |
753 | return (EAGAIN); | 753 | return (EAGAIN); | |
754 | } | 754 | } | |
755 | 755 | |||
756 | vga_switch_screen(vc); | 756 | vga_switch_screen(vc); | |
757 | return (0); | 757 | return (0); | |
758 | } | 758 | } | |
759 | 759 | |||
760 | void | 760 | static void | |
761 | vga_switch_screen(struct vga_config *vc) | 761 | vga_switch_screen(struct vga_config *vc) | |
762 | { | 762 | { | |
763 | struct vgascreen *scr, *oldscr; | 763 | struct vgascreen *scr, *oldscr; | |
764 | struct vga_handle *vh = &vc->hdl; | 764 | struct vga_handle *vh = &vc->hdl; | |
765 | const struct wsscreen_descr *type; | 765 | const struct wsscreen_descr *type; | |
766 | 766 | |||
767 | scr = vc->wantedscreen; | 767 | scr = vc->wantedscreen; | |
768 | if (!scr) { | 768 | if (!scr) { | |
769 | printf("vga_switch_screen: disappeared\n"); | 769 | printf("vga_switch_screen: disappeared\n"); | |
770 | (*vc->switchcb)(vc->switchcbarg, EIO, 0); | 770 | (*vc->switchcb)(vc->switchcbarg, EIO, 0); | |
771 | return; | 771 | return; | |
772 | } | 772 | } | |
773 | type = scr->type; | 773 | type = scr->type; | |
774 | oldscr = vc->active; /* can be NULL! */ | 774 | oldscr = vc->active; /* can be NULL! */ | |
775 | #ifdef DIAGNOSTIC | 775 | #ifdef DIAGNOSTIC | |
776 | if (oldscr) { | 776 | if (oldscr) { | |
777 | if (!oldscr->active) | 777 | if (!oldscr->active) | |
778 | panic("vga_raster_show_screen: not active"); | 778 | panic("vga_raster_show_screen: not active"); | |
779 | if (oldscr->type != vc->currenttype) | 779 | if (oldscr->type != vc->currenttype) | |
780 | panic("vga_raster_show_screen: bad type"); | 780 | panic("vga_raster_show_screen: bad type"); | |
781 | } | 781 | } | |
782 | #endif | 782 | #endif | |
783 | if (scr == oldscr) { | 783 | if (scr == oldscr) { | |
784 | return; | 784 | return; | |
785 | } | 785 | } | |
786 | #ifdef DIAGNOSTIC | 786 | #ifdef DIAGNOSTIC | |
787 | if (scr->active) | 787 | if (scr->active) | |
788 | panic("vga_raster_show_screen: active"); | 788 | panic("vga_raster_show_screen: active"); | |
789 | #endif | 789 | #endif | |
790 | 790 | |||
791 | if (oldscr) | 791 | if (oldscr) | |
792 | oldscr->active = 0; | 792 | oldscr->active = 0; | |
793 | 793 | |||
794 | if (vc->currenttype != type) { | 794 | if (vc->currenttype != type) { | |
795 | vga_raster_setscreentype(vc, type); | 795 | vga_raster_setscreentype(vc, type); | |
796 | vc->currenttype = type; | 796 | vc->currenttype = type; | |
797 | } | 797 | } | |
798 | 798 | |||
799 | scr->dispoffset = scr->mindispoffset; | 799 | scr->dispoffset = scr->mindispoffset; | |
800 | 800 | |||
801 | if (!oldscr || (scr->dispoffset != oldscr->dispoffset)) { | 801 | if (!oldscr || (scr->dispoffset != oldscr->dispoffset)) { | |
802 | vga_6845_write(vh, startadrh, scr->dispoffset >> 8); | 802 | vga_6845_write(vh, startadrh, scr->dispoffset >> 8); | |
803 | vga_6845_write(vh, startadrl, scr->dispoffset); | 803 | vga_6845_write(vh, startadrl, scr->dispoffset); | |
804 | } | 804 | } | |
805 | 805 | |||
806 | /* Clear the entire screen. */ | 806 | /* Clear the entire screen. */ | |
807 | vga_gdc_write(vh, mode, 0x02); | 807 | vga_gdc_write(vh, mode, 0x02); | |
808 | bus_space_set_region_4(vh->vh_memt, vh->vh_allmemh, 0, 0, 0x2000); | 808 | bus_space_set_region_4(vh->vh_memt, vh->vh_allmemh, 0, 0, 0x2000); | |
809 | 809 | |||
810 | scr->active = 1; | 810 | scr->active = 1; | |
811 | vga_restore_screen(scr, type, scr->mem); | 811 | vga_restore_screen(scr, type, scr->mem); | |
812 | 812 | |||
813 | vc->active = scr; | 813 | vc->active = scr; | |
814 | 814 | |||
815 | vga_raster_cursor(scr, scr->cursoron, scr->cursorrow, scr->cursorcol); | 815 | vga_raster_cursor(scr, scr->cursoron, scr->cursorrow, scr->cursorcol); | |
816 | 816 | |||
817 | vc->wantedscreen = 0; | 817 | vc->wantedscreen = 0; | |
818 | if (vc->switchcb) | 818 | if (vc->switchcb) | |
819 | (*vc->switchcb)(vc->switchcbarg, 0, 0); | 819 | (*vc->switchcb)(vc->switchcbarg, 0, 0); | |
820 | } | 820 | } | |
821 | 821 | |||
822 | static int | 822 | static int | |
823 | vga_raster_load_font(void *v, void *id, | 823 | vga_raster_load_font(void *v, void *id, | |
824 | struct wsdisplay_font *data) | 824 | struct wsdisplay_font *data) | |
825 | { | 825 | { | |
826 | /* XXX */ | 826 | /* XXX */ | |
827 | printf("vga_raster_load_font: called\n"); | 827 | printf("vga_raster_load_font: called\n"); | |
828 | 828 | |||
829 | return (0); | 829 | return (0); | |
830 | } | 830 | } | |
831 | 831 | |||
832 | void | 832 | static void | |
833 | vga_raster_setup_font(struct vga_config *vc, struct vgascreen *scr) | 833 | vga_raster_setup_font(struct vga_config *vc, struct vgascreen *scr) | |
834 | { | 834 | { | |
835 | struct vga_raster_font *vf; | 835 | struct vga_raster_font *vf; | |
836 | struct wsdisplay_font *wf; | 836 | struct wsdisplay_font *wf; | |
837 | int cookie; | 837 | int cookie; | |
838 | 838 | |||
839 | LIST_FOREACH(vf, &vc->vc_fontlist, next) { | 839 | LIST_FOREACH(vf, &vc->vc_fontlist, next) { | |
840 | if (wsfont_matches(vf->font, 0, 0, scr->type->fontheight, 0, | 840 | if (wsfont_matches(vf->font, 0, 0, scr->type->fontheight, 0, | |
841 | WSFONT_FIND_BITMAP)) { | 841 | WSFONT_FIND_BITMAP)) { | |
842 | scr->encoding = vf->font->encoding; | 842 | scr->encoding = vf->font->encoding; | |
843 | LIST_INSERT_HEAD(&scr->fontset, vf, next); | 843 | LIST_INSERT_HEAD(&scr->fontset, vf, next); | |
844 | return; | 844 | return; | |
845 | } | 845 | } | |
846 | } | 846 | } | |
847 | 847 | |||
848 | cookie = wsfont_find(NULL, 0, scr->type->fontheight, 0, | 848 | cookie = wsfont_find(NULL, 0, scr->type->fontheight, 0, | |
849 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | 849 | WSDISPLAY_FONTORDER_L2R, 0, WSFONT_FIND_BITMAP); | |
850 | if (cookie == -1) | 850 | if (cookie == -1) | |
851 | return; | 851 | return; | |
852 | 852 | |||
853 | if (wsfont_lock(cookie, &wf)) | 853 | if (wsfont_lock(cookie, &wf)) | |
854 | return; | 854 | return; | |
855 | 855 | |||
856 | vf = malloc(sizeof(struct vga_raster_font), M_DEVBUF, M_NOWAIT); | 856 | vf = malloc(sizeof(struct vga_raster_font), M_DEVBUF, M_NOWAIT); | |
857 | if (!vf) { | 857 | if (!vf) { | |
858 | wsfont_unlock(cookie); | 858 | wsfont_unlock(cookie); | |
859 | return; | 859 | return; | |
860 | } | 860 | } | |
861 | 861 | |||
862 | vf->font = wf; | 862 | vf->font = wf; | |
863 | scr->encoding = vf->font->encoding; | 863 | scr->encoding = vf->font->encoding; | |
864 | LIST_INSERT_HEAD(&scr->fontset, vf, next); | 864 | LIST_INSERT_HEAD(&scr->fontset, vf, next); | |
865 | } | 865 | } | |
866 | 866 | |||
867 | void | 867 | static void | |
868 | vga_setup_regs(struct videomode *mode, struct vga_moderegs *regs) | 868 | vga_setup_regs(struct videomode *mode, struct vga_moderegs *regs) | |
869 | { | 869 | { | |
870 | int i; | 870 | int i; | |
871 | int depth = 4; /* XXXBJY hardcoded for now */ | 871 | int depth = 4; /* XXXBJY hardcoded for now */ | |
872 | const u_int8_t palette[] = { | 872 | const u_int8_t palette[] = { | |
873 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, | 873 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, | |
874 | 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f | 874 | 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f | |
875 | }; | 875 | }; | |
876 | 876 | |||
877 | /* | 877 | /* | |
878 | * Compute hsync and vsync polarity. | 878 | * Compute hsync and vsync polarity. | |
879 | */ | 879 | */ | |
880 | if ((mode->flags & (VID_PHSYNC | VID_NHSYNC)) | 880 | if ((mode->flags & (VID_PHSYNC | VID_NHSYNC)) | |
881 | && (mode->flags & (VID_PVSYNC | VID_NVSYNC))) { | 881 | && (mode->flags & (VID_PVSYNC | VID_NVSYNC))) { | |
882 | regs->miscout = 0x23; | 882 | regs->miscout = 0x23; | |
883 | if (mode->flags & VID_NHSYNC) | 883 | if (mode->flags & VID_NHSYNC) | |
884 | regs->miscout |= 0x40; | 884 | regs->miscout |= 0x40; | |
885 | if (mode->flags & VID_NVSYNC) | 885 | if (mode->flags & VID_NVSYNC) | |
886 | regs->miscout |= 0x80; | 886 | regs->miscout |= 0x80; | |
887 | } else { | 887 | } else { | |
888 | if (mode->flags & VID_DBLSCAN) | 888 | if (mode->flags & VID_DBLSCAN) | |
889 | mode->vdisplay *= 2; | 889 | mode->vdisplay *= 2; | |
890 | if (mode->vdisplay < 400) | 890 | if (mode->vdisplay < 400) | |
891 | regs->miscout = 0xa3; | 891 | regs->miscout = 0xa3; | |
892 | else if (mode->vdisplay < 480) | 892 | else if (mode->vdisplay < 480) | |
893 | regs->miscout = 0x63; | 893 | regs->miscout = 0x63; | |
894 | else if (mode->vdisplay < 768) | 894 | else if (mode->vdisplay < 768) | |
895 | regs->miscout = 0xe3; | 895 | regs->miscout = 0xe3; | |
896 | else | 896 | else | |
897 | regs->miscout = 0x23; | 897 | regs->miscout = 0x23; | |
898 | } | 898 | } | |
899 | 899 | |||
900 | /* | 900 | /* | |
901 | * Time sequencer | 901 | * Time sequencer | |
902 | */ | 902 | */ | |
903 | if (depth == 4) | 903 | if (depth == 4) | |
904 | regs->ts[0] = 0x02; | 904 | regs->ts[0] = 0x02; | |
905 | else | 905 | else | |
906 | regs->ts[0] = 0x00; | 906 | regs->ts[0] = 0x00; | |
907 | if (mode->flags & VID_CLKDIV2) | 907 | if (mode->flags & VID_CLKDIV2) | |
908 | regs->ts[1] = 0x09; | 908 | regs->ts[1] = 0x09; | |
909 | else | 909 | else | |
910 | regs->ts[1] = 0x01; | 910 | regs->ts[1] = 0x01; | |
911 | regs->ts[2] = 0x0f; | 911 | regs->ts[2] = 0x0f; | |
912 | regs->ts[3] = 0x00; | 912 | regs->ts[3] = 0x00; | |
913 | if (depth < 8) | 913 | if (depth < 8) | |
914 | regs->ts[4] = 0x06; | 914 | regs->ts[4] = 0x06; | |
915 | else | 915 | else | |
916 | regs->ts[4] = 0x0e; | 916 | regs->ts[4] = 0x0e; | |
917 | 917 | |||
918 | /* | 918 | /* | |
919 | * CRTC controller | 919 | * CRTC controller | |
920 | */ | 920 | */ | |
921 | regs->crtc[0] = (mode->htotal >> 3) - 5; | 921 | regs->crtc[0] = (mode->htotal >> 3) - 5; | |
922 | regs->crtc[1] = (mode->hdisplay >> 3) - 1; | 922 | regs->crtc[1] = (mode->hdisplay >> 3) - 1; | |
923 | regs->crtc[2] = (mode->hsync_start >> 3) - 1; | 923 | regs->crtc[2] = (mode->hsync_start >> 3) - 1; | |
924 | regs->crtc[3] = (((mode->hsync_end >> 3) - 1) & 0x1f) | 0x80; | 924 | regs->crtc[3] = (((mode->hsync_end >> 3) - 1) & 0x1f) | 0x80; | |
925 | regs->crtc[4] = mode->hsync_start >> 3; | 925 | regs->crtc[4] = mode->hsync_start >> 3; | |
926 | regs->crtc[5] = ((((mode->hsync_end >> 3) - 1) & 0x20) << 2) | 926 | regs->crtc[5] = ((((mode->hsync_end >> 3) - 1) & 0x20) << 2) | |
927 | | (((mode->hsync_end >> 3)) & 0x1f); | 927 | | (((mode->hsync_end >> 3)) & 0x1f); | |
928 | regs->crtc[6] = (mode->vtotal - 2) & 0xff; | 928 | regs->crtc[6] = (mode->vtotal - 2) & 0xff; | |
929 | regs->crtc[7] = (((mode->vtotal - 2) & 0x100) >> 8) | 929 | regs->crtc[7] = (((mode->vtotal - 2) & 0x100) >> 8) | |
930 | | (((mode->vdisplay - 1) & 0x100) >> 7) | 930 | | (((mode->vdisplay - 1) & 0x100) >> 7) | |
931 | | ((mode->vsync_start & 0x100) >> 6) | 931 | | ((mode->vsync_start & 0x100) >> 6) | |
932 | | (((mode->vsync_start - 1) & 0x100) >> 5) | 932 | | (((mode->vsync_start - 1) & 0x100) >> 5) | |
933 | | 0x10 | 933 | | 0x10 | |
934 | | (((mode->vtotal - 2) & 0x200) >> 4) | 934 | | (((mode->vtotal - 2) & 0x200) >> 4) | |
935 | | (((mode->vdisplay - 1) & 0x200) >> 3) | 935 | | (((mode->vdisplay - 1) & 0x200) >> 3) | |
936 | | ((mode->vsync_start & 0x200) >> 2); | 936 | | ((mode->vsync_start & 0x200) >> 2); | |
937 | regs->crtc[8] = 0x00; | 937 | regs->crtc[8] = 0x00; | |
938 | regs->crtc[9] = (((mode->vsync_start - 1) & 0x200) >> 4) | 0x40; | 938 | regs->crtc[9] = (((mode->vsync_start - 1) & 0x200) >> 4) | 0x40; | |
939 | if (mode->flags & VID_DBLSCAN) | 939 | if (mode->flags & VID_DBLSCAN) | |
940 | regs->crtc[9] |= 0x80; | 940 | regs->crtc[9] |= 0x80; | |
941 | regs->crtc[10] = 0x00; | 941 | regs->crtc[10] = 0x00; | |
942 | regs->crtc[11] = 0x00; | 942 | regs->crtc[11] = 0x00; | |
943 | regs->crtc[12] = 0x00; | 943 | regs->crtc[12] = 0x00; | |
944 | regs->crtc[13] = 0x00; | 944 | regs->crtc[13] = 0x00; | |
945 | regs->crtc[14] = 0x00; | 945 | regs->crtc[14] = 0x00; | |
946 | regs->crtc[15] = 0x00; | 946 | regs->crtc[15] = 0x00; | |
947 | regs->crtc[16] = mode->vsync_start & 0xff; | 947 | regs->crtc[16] = mode->vsync_start & 0xff; | |
948 | regs->crtc[17] = (mode->vsync_end & 0x0f) | 0x20; | 948 | regs->crtc[17] = (mode->vsync_end & 0x0f) | 0x20; | |
949 | regs->crtc[18] = (mode->vdisplay - 1) & 0xff; | 949 | regs->crtc[18] = (mode->vdisplay - 1) & 0xff; | |
950 | regs->crtc[19] = mode->hdisplay >> 4; /* XXXBJY */ | 950 | regs->crtc[19] = mode->hdisplay >> 4; /* XXXBJY */ | |
951 | regs->crtc[20] = 0x00; | 951 | regs->crtc[20] = 0x00; | |
952 | regs->crtc[21] = (mode->vsync_start - 1) & 0xff; | 952 | regs->crtc[21] = (mode->vsync_start - 1) & 0xff; | |
953 | regs->crtc[22] = (mode->vsync_end - 1) & 0xff; | 953 | regs->crtc[22] = (mode->vsync_end - 1) & 0xff; | |
954 | if (depth < 8) | 954 | if (depth < 8) | |
955 | regs->crtc[23] = 0xe3; | 955 | regs->crtc[23] = 0xe3; | |
956 | else | 956 | else | |
957 | regs->crtc[23] = 0xc3; | 957 | regs->crtc[23] = 0xc3; | |
958 | regs->crtc[24] = 0xff; | 958 | regs->crtc[24] = 0xff; | |
959 | 959 | |||
960 | /* | 960 | /* | |
961 | * Graphics display controller | 961 | * Graphics display controller | |
962 | */ | 962 | */ | |
963 | regs->gdc[0] = 0x00; | 963 | regs->gdc[0] = 0x00; | |
964 | regs->gdc[1] = 0x00; | 964 | regs->gdc[1] = 0x00; | |
965 | regs->gdc[2] = 0x00; | 965 | regs->gdc[2] = 0x00; | |
966 | regs->gdc[3] = 0x00; | 966 | regs->gdc[3] = 0x00; | |
967 | regs->gdc[4] = 0x00; | 967 | regs->gdc[4] = 0x00; | |
968 | if (depth == 4) | 968 | if (depth == 4) | |
969 | regs->gdc[5] = 0x02; | 969 | regs->gdc[5] = 0x02; | |
970 | else | 970 | else | |
971 | regs->gdc[5] = 0x40; | 971 | regs->gdc[5] = 0x40; | |
972 | regs->gdc[6] = 0x01; | 972 | regs->gdc[6] = 0x01; | |
973 | regs->gdc[7] = 0x0f; | 973 | regs->gdc[7] = 0x0f; | |
974 | regs->gdc[8] = 0xff; | 974 | regs->gdc[8] = 0xff; | |
975 | 975 | |||
976 | /* | 976 | /* | |
977 | * Attribute controller | 977 | * Attribute controller | |
978 | */ | 978 | */ | |
979 | /* Set palette registers. */ | 979 | /* Set palette registers. */ | |
980 | for (i = 0; i < 16; i++) | 980 | for (i = 0; i < 16; i++) | |
981 | regs->atc[i] = palette[i]; | 981 | regs->atc[i] = palette[i]; | |
982 | if (depth == 4) | 982 | if (depth == 4) | |
983 | regs->atc[16] = 0x01; /* XXXBJY was 0x81 in XFree86 */ | 983 | regs->atc[16] = 0x01; /* XXXBJY was 0x81 in XFree86 */ | |
984 | else | 984 | else | |
985 | regs->atc[16] = 0x41; | 985 | regs->atc[16] = 0x41; | |
986 | regs->atc[17] = 0x00; /* XXXBJY just a guess */ | 986 | regs->atc[17] = 0x00; /* XXXBJY just a guess */ | |
987 | regs->atc[18] = 0x0f; | 987 | regs->atc[18] = 0x0f; | |
988 | regs->atc[19] = 0x00; | 988 | regs->atc[19] = 0x00; | |
989 | regs->atc[20] = 0x00; | 989 | regs->atc[20] = 0x00; | |
990 | } | 990 | } | |
991 | 991 | |||
992 | void | 992 | static void | |
993 | vga_set_mode(struct vga_handle *vh, struct vga_moderegs *regs) | 993 | vga_set_mode(struct vga_handle *vh, struct vga_moderegs *regs) | |
994 | { | 994 | { | |
995 | int i; | 995 | int i; | |
996 | 996 | |||
997 | /* Disable display. */ | 997 | /* Disable display. */ | |
998 | vga_ts_write(vh, mode, vga_ts_read(vh, mode) | VGA_TS_MODE_BLANK); | 998 | vga_ts_write(vh, mode, vga_ts_read(vh, mode) | VGA_TS_MODE_BLANK); | |
999 | 999 | |||
1000 | /* Write misc output register. */ | 1000 | /* Write misc output register. */ | |
1001 | bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAW, | 1001 | bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAW, | |
1002 | regs->miscout); | 1002 | regs->miscout); | |
1003 | 1003 | |||
1004 | /* Set synchronous reset. */ | 1004 | /* Set synchronous reset. */ | |
1005 | vga_ts_write(vh, syncreset, 0x01); | 1005 | vga_ts_write(vh, syncreset, 0x01); | |
1006 | vga_ts_write(vh, mode, regs->ts[1] | VGA_TS_MODE_BLANK); | 1006 | vga_ts_write(vh, mode, regs->ts[1] | VGA_TS_MODE_BLANK); | |
1007 | for (i = 2; i < VGA_TS_NREGS; i++) | 1007 | for (i = 2; i < VGA_TS_NREGS; i++) | |
1008 | _vga_ts_write(vh, i, regs->ts[i]); | 1008 | _vga_ts_write(vh, i, regs->ts[i]); | |
1009 | /* Clear synchronous reset. */ | 1009 | /* Clear synchronous reset. */ | |
1010 | vga_ts_write(vh, syncreset, 0x03); | 1010 | vga_ts_write(vh, syncreset, 0x03); | |
1011 | 1011 | |||
1012 | /* Unprotect CRTC registers 0-7. */ | 1012 | /* Unprotect CRTC registers 0-7. */ | |
1013 | vga_6845_write(vh, vsynce, vga_6845_read(vh, vsynce) & ~0x80); | 1013 | vga_6845_write(vh, vsynce, vga_6845_read(vh, vsynce) & ~0x80); | |
1014 | /* Write CRTC registers. */ | 1014 | /* Write CRTC registers. */ | |
1015 | for (i = 0; i < MC6845_NREGS; i++) | 1015 | for (i = 0; i < MC6845_NREGS; i++) | |
1016 | _vga_6845_write(vh, i, regs->crtc[i]); | 1016 | _vga_6845_write(vh, i, regs->crtc[i]); | |
1017 | 1017 | |||
1018 | /* Write graphics display registers. */ | 1018 | /* Write graphics display registers. */ | |
1019 | for (i = 0; i < VGA_GDC_NREGS; i++) | 1019 | for (i = 0; i < VGA_GDC_NREGS; i++) | |
1020 | _vga_gdc_write(vh, i, regs->gdc[i]); | 1020 | _vga_gdc_write(vh, i, regs->gdc[i]); | |
1021 | 1021 | |||
1022 | /* Write attribute controller registers. */ | 1022 | /* Write attribute controller registers. */ | |
1023 | for (i = 0; i < VGA_ATC_NREGS; i++) | 1023 | for (i = 0; i < VGA_ATC_NREGS; i++) | |
1024 | _vga_attr_write(vh, i, regs->atc[i]); | 1024 | _vga_attr_write(vh, i, regs->atc[i]); | |
1025 | 1025 | |||
1026 | /* Enable display. */ | 1026 | /* Enable display. */ | |
1027 | vga_ts_write(vh, mode, vga_ts_read(vh, mode) & ~VGA_TS_MODE_BLANK); | 1027 | vga_ts_write(vh, mode, vga_ts_read(vh, mode) & ~VGA_TS_MODE_BLANK); | |
1028 | } | 1028 | } | |
1029 | 1029 | |||
1030 | void | 1030 | static void | |
1031 | vga_raster_cursor_init(struct vgascreen *scr, int existing) | 1031 | vga_raster_cursor_init(struct vgascreen *scr, int existing) | |
1032 | { | 1032 | { | |
1033 | struct vga_handle *vh = scr->hdl; | 1033 | struct vga_handle *vh = scr->hdl; | |
1034 | bus_space_tag_t memt; | 1034 | bus_space_tag_t memt; | |
1035 | bus_space_handle_t memh; | 1035 | bus_space_handle_t memh; | |
1036 | int off; | 1036 | int off; | |
1037 | 1037 | |||
1038 | if (existing) { | 1038 | if (existing) { | |
1039 | /* | 1039 | /* | |
1040 | * This is the first screen. At this point, scr->active is | 1040 | * This is the first screen. At this point, scr->active is | |
1041 | * false, so we can't use vga_raster_cursor() to do this. | 1041 | * false, so we can't use vga_raster_cursor() to do this. | |
1042 | */ | 1042 | */ | |
1043 | memt = vh->vh_memt; | 1043 | memt = vh->vh_memt; | |
1044 | memh = vh->vh_memh; | 1044 | memh = vh->vh_memh; | |
1045 | off = (scr->cursorrow * scr->type->ncols + scr->cursorcol) + | 1045 | off = (scr->cursorrow * scr->type->ncols + scr->cursorcol) + | |
1046 | scr->dispoffset / 8; | 1046 | scr->dispoffset / 8; | |
1047 | 1047 | |||
1048 | scr->cursortmp = scr->mem[off]; | 1048 | scr->cursortmp = scr->mem[off]; | |
1049 | vga_raster_putchar(scr, scr->cursorrow, scr->cursorcol, | 1049 | vga_raster_putchar(scr, scr->cursorrow, scr->cursorcol, | |
1050 | scr->cursortmp.ch, scr->cursortmp.attr ^ 0x77); | 1050 | scr->cursortmp.ch, scr->cursortmp.attr ^ 0x77); | |
1051 | } else { | 1051 | } else { | |
1052 | scr->cursortmp.ch = 0; | 1052 | scr->cursortmp.ch = 0; | |
1053 | scr->cursortmp.attr = 0; | 1053 | scr->cursortmp.attr = 0; | |
1054 | scr->cursortmp.second = 0; | 1054 | scr->cursortmp.second = 0; | |
1055 | scr->cursortmp.enc = scr->encoding; | 1055 | scr->cursortmp.enc = scr->encoding; | |
1056 | } | 1056 | } | |
1057 | 1057 | |||
1058 | scr->cursoron = 1; | 1058 | scr->cursoron = 1; | |
1059 | } | 1059 | } | |
1060 | 1060 | |||
1061 | void | 1061 | static void | |
1062 | vga_raster_cursor(void *id, int on, int row, int col) | 1062 | vga_raster_cursor(void *id, int on, int row, int col) | |
1063 | { | 1063 | { | |
1064 | struct vgascreen *scr = id; | 1064 | struct vgascreen *scr = id; | |
1065 | int off, tmp; | 1065 | int off, tmp; | |
1066 | 1066 | |||
1067 | /* Remove old cursor image */ | 1067 | /* Remove old cursor image */ | |
1068 | if (scr->cursoron) { | 1068 | if (scr->cursoron) { | |
1069 | off = scr->cursorrow * scr->type->ncols + scr->cursorcol; | 1069 | off = scr->cursorrow * scr->type->ncols + scr->cursorcol; | |
1070 | if (scr->active) { | 1070 | if (scr->active) { | |
1071 | tmp = scr->encoding; | 1071 | tmp = scr->encoding; | |
1072 | scr->encoding = scr->cursortmp.enc; | 1072 | scr->encoding = scr->cursortmp.enc; | |
1073 | if (scr->cursortmp.second) | 1073 | if (scr->cursortmp.second) | |
1074 | vga_raster_putchar(id, scr->cursorrow, | 1074 | vga_raster_putchar(id, scr->cursorrow, | |
1075 | scr->cursorcol - 1, scr->cursortmp.ch, | 1075 | scr->cursorcol - 1, scr->cursortmp.ch, | |
1076 | scr->cursortmp.attr); | 1076 | scr->cursortmp.attr); | |
1077 | else | 1077 | else | |
1078 | vga_raster_putchar(id, scr->cursorrow, | 1078 | vga_raster_putchar(id, scr->cursorrow, | |
1079 | scr->cursorcol, scr->cursortmp.ch, | 1079 | scr->cursorcol, scr->cursortmp.ch, | |
1080 | scr->cursortmp.attr); | 1080 | scr->cursortmp.attr); | |
1081 | scr->encoding = tmp; | 1081 | scr->encoding = tmp; | |
1082 | } | 1082 | } | |
1083 | } | 1083 | } | |
1084 | 1084 | |||
1085 | scr->cursorrow = row; | 1085 | scr->cursorrow = row; | |
1086 | scr->cursorcol = col; | 1086 | scr->cursorcol = col; | |
1087 | 1087 | |||
1088 | if ((scr->cursoron = on) == 0) | 1088 | if ((scr->cursoron = on) == 0) | |
1089 | return; | 1089 | return; | |
1090 | 1090 | |||
1091 | off = scr->cursorrow * scr->type->ncols + scr->cursorcol; | 1091 | off = scr->cursorrow * scr->type->ncols + scr->cursorcol; | |
1092 | scr->cursortmp = scr->mem[off]; | 1092 | scr->cursortmp = scr->mem[off]; | |
1093 | if (scr->active) { | 1093 | if (scr->active) { | |
1094 | tmp = scr->encoding; | 1094 | tmp = scr->encoding; | |
1095 | scr->encoding = scr->cursortmp.enc; | 1095 | scr->encoding = scr->cursortmp.enc; | |
1096 | if (scr->cursortmp.second) | 1096 | if (scr->cursortmp.second) | |
1097 | vga_raster_putchar(id, scr->cursorrow, | 1097 | vga_raster_putchar(id, scr->cursorrow, | |
1098 | scr->cursorcol - 1, scr->cursortmp.ch, | 1098 | scr->cursorcol - 1, scr->cursortmp.ch, | |
1099 | scr->cursortmp.attr ^ 0x77); | 1099 | scr->cursortmp.attr ^ 0x77); | |
1100 | else | 1100 | else | |
1101 | vga_raster_putchar(id, scr->cursorrow, | 1101 | vga_raster_putchar(id, scr->cursorrow, | |
1102 | scr->cursorcol, scr->cursortmp.ch, | 1102 | scr->cursorcol, scr->cursortmp.ch, | |
1103 | scr->cursortmp.attr ^ 0x77); | 1103 | scr->cursortmp.attr ^ 0x77); | |
1104 | scr->encoding = tmp; | 1104 | scr->encoding = tmp; | |
1105 | } | 1105 | } | |
1106 | } | 1106 | } | |
1107 | 1107 | |||
1108 | static int | 1108 | static int | |
1109 | vga_raster_mapchar(void *id, int uni, u_int *index) | 1109 | vga_raster_mapchar(void *id, int uni, u_int *index) | |
1110 | { | 1110 | { | |
1111 | struct vgascreen *scr = id; | 1111 | struct vgascreen *scr = id; | |
1112 | 1112 | |||
1113 | if (scr->encoding == WSDISPLAY_FONTENC_IBM) | 1113 | if (scr->encoding == WSDISPLAY_FONTENC_IBM) | |
1114 | return pcdisplay_mapchar(id, uni, index); | 1114 | return pcdisplay_mapchar(id, uni, index); | |
1115 | else { | 1115 | else { | |
1116 | *index = uni; | 1116 | *index = uni; | |
1117 | return 5; | 1117 | return 5; | |
1118 | } | 1118 | } | |
1119 | } | 1119 | } | |
1120 | 1120 | |||
1121 | void | 1121 | static void | |
1122 | vga_raster_putchar(void *id, int row, int col, u_int c, long attr) | 1122 | vga_raster_putchar(void *id, int row, int col, u_int c, long attr) | |
1123 | { | 1123 | { | |
1124 | struct vgascreen *scr = id; | 1124 | struct vgascreen *scr = id; | |
1125 | size_t off; | 1125 | size_t off; | |
1126 | struct vga_raster_font *fs; | 1126 | struct vga_raster_font *fs; | |
1127 | u_int tmp_ch; | 1127 | u_int tmp_ch; | |
1128 | 1128 | |||
1129 | off = row * scr->type->ncols + col; | 1129 | off = row * scr->type->ncols + col; | |
1130 | 1130 | |||
1131 | if (__predict_false(off >= (scr->type->ncols * scr->type->nrows))) | 1131 | if (__predict_false(off >= (scr->type->ncols * scr->type->nrows))) | |
1132 | return; | 1132 | return; | |
1133 | 1133 | |||
1134 | LIST_FOREACH(fs, &scr->fontset, next) { | 1134 | LIST_FOREACH(fs, &scr->fontset, next) { | |
1135 | if ((scr->encoding == fs->font->encoding) && | 1135 | if ((scr->encoding == fs->font->encoding) && | |
1136 | (c >= fs->font->firstchar) && | 1136 | (c >= fs->font->firstchar) && | |
1137 | (c < fs->font->firstchar + fs->font->numchars) && | 1137 | (c < fs->font->firstchar + fs->font->numchars) && | |
1138 | (scr->type->fontheight == fs->font->fontheight)) { | 1138 | (scr->type->fontheight == fs->font->fontheight)) { | |
1139 | if (scr->active) { | 1139 | if (scr->active) { | |
1140 | tmp_ch = c - fs->font->firstchar; | 1140 | tmp_ch = c - fs->font->firstchar; | |
1141 | _vga_raster_putchar(scr, row, col, tmp_ch, | 1141 | _vga_raster_putchar(scr, row, col, tmp_ch, | |
1142 | attr, fs); | 1142 | attr, fs); | |
1143 | } | 1143 | } | |
1144 | 1144 | |||
1145 | scr->mem[off].ch = c; | 1145 | scr->mem[off].ch = c; | |
1146 | scr->mem[off].attr = attr; | 1146 | scr->mem[off].attr = attr; | |
1147 | scr->mem[off].second = 0; | 1147 | scr->mem[off].second = 0; | |
1148 | scr->mem[off].enc = fs->font->encoding; | 1148 | scr->mem[off].enc = fs->font->encoding; | |
1149 | 1149 | |||
1150 | if (fs->font->stride == 2) { | 1150 | if (fs->font->stride == 2) { | |
1151 | scr->mem[off + 1].ch = c; | 1151 | scr->mem[off + 1].ch = c; | |
1152 | scr->mem[off + 1].attr = attr; | 1152 | scr->mem[off + 1].attr = attr; | |
1153 | scr->mem[off + 1].second = 1; | 1153 | scr->mem[off + 1].second = 1; | |
1154 | scr->mem[off + 1].enc = fs->font->encoding; | 1154 | scr->mem[off + 1].enc = fs->font->encoding; | |
1155 | } | 1155 | } | |
1156 | 1156 | |||
1157 | return; | 1157 | return; | |
1158 | } | 1158 | } | |
1159 | } | 1159 | } | |
1160 | 1160 | |||
1161 | /* | 1161 | /* | |
1162 | * No match found. | 1162 | * No match found. | |
1163 | */ | 1163 | */ | |
1164 | if (scr->active) | 1164 | if (scr->active) | |
1165 | /* | 1165 | /* | |
1166 | * Put a single width space character no matter what the | 1166 | * Put a single width space character no matter what the | |
1167 | * actual width of the character is. | 1167 | * actual width of the character is. | |
1168 | */ | 1168 | */ | |
1169 | _vga_raster_putchar(scr, row, col, ' ', attr, | 1169 | _vga_raster_putchar(scr, row, col, ' ', attr, | |
1170 | &vga_console_fontset_ascii); | 1170 | &vga_console_fontset_ascii); | |
1171 | scr->mem[off].ch = c; | 1171 | scr->mem[off].ch = c; | |
1172 | scr->mem[off].attr = attr; | 1172 | scr->mem[off].attr = attr; | |
1173 | scr->mem[off].second = 0; | 1173 | scr->mem[off].second = 0; | |
1174 | scr->mem[off].enc = scr->encoding; | 1174 | scr->mem[off].enc = scr->encoding; | |
1175 | } | 1175 | } | |
1176 | 1176 | |||
1177 | static void | 1177 | static void | |
1178 | _vga_raster_putchar(void *id, int row, int col, u_int c, long attr, | 1178 | _vga_raster_putchar(void *id, int row, int col, u_int c, long attr, | |
1179 | struct vga_raster_font *fs) | 1179 | struct vga_raster_font *fs) | |
1180 | { | 1180 | { | |
1181 | struct vgascreen *scr = id; | 1181 | struct vgascreen *scr = id; | |
1182 | struct vga_handle *vh = scr->hdl; | 1182 | struct vga_handle *vh = scr->hdl; | |
1183 | bus_space_tag_t memt = vh->vh_memt; | 1183 | bus_space_tag_t memt = vh->vh_memt; | |
1184 | bus_space_handle_t memh = vh->vh_memh; | 1184 | bus_space_handle_t memh = vh->vh_memh; | |
1185 | int i; | 1185 | int i; | |
1186 | int rasoff, rasoff2; | 1186 | int rasoff, rasoff2; | |
1187 | int fheight = scr->type->fontheight; | 1187 | int fheight = scr->type->fontheight; | |
1188 | volatile u_int8_t dummy, pattern; | 1188 | volatile u_int8_t dummy, pattern; | |
1189 | u_int8_t fgcolor, bgcolor; | 1189 | u_int8_t fgcolor, bgcolor; | |
1190 | 1190 | |||
1191 | rasoff = scr->dispoffset + row * scr->type->ncols * fheight + col; | 1191 | rasoff = scr->dispoffset + row * scr->type->ncols * fheight + col; | |
1192 | rasoff2 = rasoff; | 1192 | rasoff2 = rasoff; | |
1193 | 1193 | |||
1194 | #if 0 | 1194 | #if 0 | |
1195 | bgcolor = bgansitopc[attr >> 4]; | 1195 | bgcolor = bgansitopc[attr >> 4]; | |
1196 | fgcolor = fgansitopc[attr & 0x0f]; | 1196 | fgcolor = fgansitopc[attr & 0x0f]; | |
1197 | #else | 1197 | #else | |
1198 | bgcolor = ((attr >> 4) & 0x0f); | 1198 | bgcolor = ((attr >> 4) & 0x0f); | |
1199 | fgcolor = attr & 0x0f; | 1199 | fgcolor = attr & 0x0f; | |
1200 | #endif | 1200 | #endif | |
1201 | 1201 | |||
1202 | if (fs->font->stride == 1) { | 1202 | if (fs->font->stride == 1) { | |
1203 | /* Paint background. */ | 1203 | /* Paint background. */ | |
1204 | vga_gdc_write(vh, mode, 0x02); | 1204 | vga_gdc_write(vh, mode, 0x02); | |
1205 | for (i = 0; i < fheight; i++) { | 1205 | for (i = 0; i < fheight; i++) { | |
1206 | bus_space_write_1(memt, memh, rasoff, bgcolor); | 1206 | bus_space_write_1(memt, memh, rasoff, bgcolor); | |
1207 | rasoff += scr->type->ncols; | 1207 | rasoff += scr->type->ncols; | |
1208 | } | 1208 | } | |
1209 | 1209 | |||
1210 | /* Draw a single width character. */ | 1210 | /* Draw a single width character. */ | |
1211 | vga_gdc_write(vh, mode, 0x03); | 1211 | vga_gdc_write(vh, mode, 0x03); | |
1212 | vga_gdc_write(vh, setres, fgcolor); | 1212 | vga_gdc_write(vh, setres, fgcolor); | |
1213 | for (i = 0; i < fheight; i++) { | 1213 | for (i = 0; i < fheight; i++) { | |
1214 | pattern = ((u_int8_t *)fs->font->data)[c * fheight + i]; | 1214 | pattern = ((u_int8_t *)fs->font->data)[c * fheight + i]; | |
1215 | /* When pattern is 0, skip output for speed-up. */ | 1215 | /* When pattern is 0, skip output for speed-up. */ | |
1216 | if (pattern != 0) { | 1216 | if (pattern != 0) { | |
1217 | dummy = bus_space_read_1(memt, memh, rasoff2); | 1217 | dummy = bus_space_read_1(memt, memh, rasoff2); | |
1218 | bus_space_write_1(memt, memh, rasoff2, pattern); | 1218 | bus_space_write_1(memt, memh, rasoff2, pattern); | |
1219 | } | 1219 | } | |
1220 | rasoff2 += scr->type->ncols; | 1220 | rasoff2 += scr->type->ncols; | |
1221 | } | 1221 | } | |
1222 | } else if (fs->font->stride == 2) { | 1222 | } else if (fs->font->stride == 2) { | |
1223 | /* Paint background. */ | 1223 | /* Paint background. */ | |
1224 | vga_gdc_write(vh, mode, 0x02); | 1224 | vga_gdc_write(vh, mode, 0x02); | |
1225 | for (i = 0; i < fheight; i++) { | 1225 | for (i = 0; i < fheight; i++) { | |
1226 | bus_space_write_1(memt, memh, rasoff, bgcolor); | 1226 | bus_space_write_1(memt, memh, rasoff, bgcolor); | |
1227 | bus_space_write_1(memt, memh, rasoff + 1, bgcolor); | 1227 | bus_space_write_1(memt, memh, rasoff + 1, bgcolor); | |
1228 | rasoff += scr->type->ncols; | 1228 | rasoff += scr->type->ncols; | |
1229 | } | 1229 | } | |
1230 | 1230 | |||
1231 | /* Draw a double width character. */ | 1231 | /* Draw a double width character. */ | |
1232 | vga_gdc_write(vh, mode, 0x03); | 1232 | vga_gdc_write(vh, mode, 0x03); | |
1233 | vga_gdc_write(vh, setres, fgcolor); | 1233 | vga_gdc_write(vh, setres, fgcolor); | |
1234 | for (i = 0; i < fheight; i++) { | 1234 | for (i = 0; i < fheight; i++) { | |
1235 | pattern = ((u_int8_t *)fs->font->data) | 1235 | pattern = ((u_int8_t *)fs->font->data) | |
1236 | [(c * fheight + i) * 2]; | 1236 | [(c * fheight + i) * 2]; | |
1237 | if (pattern != 0) { | 1237 | if (pattern != 0) { | |
1238 | dummy = bus_space_read_1(memt, memh, rasoff2); | 1238 | dummy = bus_space_read_1(memt, memh, rasoff2); | |
1239 | bus_space_write_1(memt, memh, rasoff2, pattern); | 1239 | bus_space_write_1(memt, memh, rasoff2, pattern); | |
1240 | } | 1240 | } | |
1241 | pattern = ((u_int8_t *)fs->font->data) | 1241 | pattern = ((u_int8_t *)fs->font->data) | |
1242 | [(c * fheight + i) * 2 + 1]; | 1242 | [(c * fheight + i) * 2 + 1]; | |
1243 | if (pattern != 0) { | 1243 | if (pattern != 0) { | |
1244 | rasoff2++; | 1244 | rasoff2++; | |
1245 | dummy = bus_space_read_1(memt, memh, rasoff2); | 1245 | dummy = bus_space_read_1(memt, memh, rasoff2); | |
1246 | bus_space_write_1(memt, memh, rasoff2, pattern); | 1246 | bus_space_write_1(memt, memh, rasoff2, pattern); | |
1247 | rasoff2--; | 1247 | rasoff2--; | |
1248 | } | 1248 | } | |
1249 | rasoff2 += scr->type->ncols; | 1249 | rasoff2 += scr->type->ncols; | |
1250 | } | 1250 | } | |
1251 | } | 1251 | } | |
1252 | } | 1252 | } | |
1253 | 1253 | |||
1254 | void | 1254 | static void | |
1255 | vga_raster_copycols(void *id, int row, int srccol, int dstcol, int ncols) | 1255 | vga_raster_copycols(void *id, int row, int srccol, int dstcol, int ncols) | |
1256 | { | 1256 | { | |
1257 | struct vgascreen *scr = id; | 1257 | struct vgascreen *scr = id; | |
1258 | struct vga_handle *vh = scr->hdl; | 1258 | struct vga_handle *vh = scr->hdl; | |
1259 | bus_space_tag_t memt = vh->vh_memt; | 1259 | bus_space_tag_t memt = vh->vh_memt; | |
1260 | bus_space_handle_t memh = vh->vh_memh; | 1260 | bus_space_handle_t memh = vh->vh_memh; | |
1261 | bus_size_t srcoff, dstoff; | 1261 | bus_size_t srcoff, dstoff; | |
1262 | bus_size_t rassrcoff, rasdstoff; | 1262 | bus_size_t rassrcoff, rasdstoff; | |
1263 | int i; | 1263 | int i; | |
1264 | int fheight = scr->type->fontheight; | 1264 | int fheight = scr->type->fontheight; | |
1265 | 1265 | |||
1266 | srcoff = row * scr->type->ncols + srccol; | 1266 | srcoff = row * scr->type->ncols + srccol; | |
1267 | dstoff = row * scr->type->ncols + dstcol; | 1267 | dstoff = row * scr->type->ncols + dstcol; | |
1268 | rassrcoff = scr->dispoffset + row * scr->type->ncols * fheight + srccol; | 1268 | rassrcoff = scr->dispoffset + row * scr->type->ncols * fheight + srccol; | |
1269 | rasdstoff = scr->dispoffset + row * scr->type->ncols * fheight + dstcol; | 1269 | rasdstoff = scr->dispoffset + row * scr->type->ncols * fheight + dstcol; | |
1270 | 1270 | |||
1271 | memcpy(&scr->mem[dstoff], &scr->mem[srcoff], | 1271 | memcpy(&scr->mem[dstoff], &scr->mem[srcoff], | |
1272 | ncols * sizeof(struct vga_scrmem)); | 1272 | ncols * sizeof(struct vga_scrmem)); | |
1273 | 1273 | |||
1274 | vga_gdc_write(vh, mode, 0x01); | 1274 | vga_gdc_write(vh, mode, 0x01); | |
1275 | if (scr->active) { | 1275 | if (scr->active) { | |
1276 | for (i = 0; i < fheight; i++) { | 1276 | for (i = 0; i < fheight; i++) { | |
1277 | bus_space_copy_region_1(memt, memh, | 1277 | bus_space_copy_region_1(memt, memh, | |
1278 | rassrcoff + i * scr->type->ncols, memh, | 1278 | rassrcoff + i * scr->type->ncols, memh, | |
1279 | rasdstoff + i * scr->type->ncols, ncols); | 1279 | rasdstoff + i * scr->type->ncols, ncols); | |
1280 | } | 1280 | } | |
1281 | } | 1281 | } | |
1282 | } | 1282 | } | |
1283 | 1283 | |||
1284 | void | 1284 | static void | |
1285 | vga_raster_erasecols(void *id, int row, int startcol, int ncols, long fillattr) | 1285 | vga_raster_erasecols(void *id, int row, int startcol, int ncols, long fillattr) | |
1286 | { | 1286 | { | |
1287 | struct vgascreen *scr = id; | 1287 | struct vgascreen *scr = id; | |
1288 | int i; | 1288 | int i; | |
1289 | 1289 | |||
1290 | if (scr->active == 0) | 1290 | if (scr->active == 0) | |
1291 | return; | 1291 | return; | |
1292 | 1292 | |||
1293 | for (i = startcol; i < startcol + ncols; i++) | 1293 | for (i = startcol; i < startcol + ncols; i++) | |
1294 | vga_raster_putchar(id, row, i, ' ', fillattr); | 1294 | vga_raster_putchar(id, row, i, ' ', fillattr); | |
1295 | } | 1295 | } | |
1296 | 1296 | |||
1297 | void | 1297 | static void | |
1298 | vga_raster_copyrows(void *id, int srcrow, int dstrow, int nrows) | 1298 | vga_raster_copyrows(void *id, int srcrow, int dstrow, int nrows) | |
1299 | { | 1299 | { | |
1300 | struct vgascreen *scr = id; | 1300 | struct vgascreen *scr = id; | |
1301 | struct vga_handle *vh = scr->hdl; | 1301 | struct vga_handle *vh = scr->hdl; | |
1302 | bus_space_tag_t memt = vh->vh_memt; | 1302 | bus_space_tag_t memt = vh->vh_memt; | |
1303 | bus_space_handle_t memh = vh->vh_memh; | 1303 | bus_space_handle_t memh = vh->vh_memh; | |
1304 | int ncols; | 1304 | int ncols; | |
1305 | bus_size_t srcoff, dstoff; | 1305 | bus_size_t srcoff, dstoff; | |
1306 | bus_size_t rassrcoff, rasdstoff; | 1306 | bus_size_t rassrcoff, rasdstoff; | |
1307 | int fheight; | 1307 | int fheight; | |
1308 | 1308 | |||
1309 | ncols = scr->type->ncols; | 1309 | ncols = scr->type->ncols; | |
1310 | fheight = scr->type->fontheight; | 1310 | fheight = scr->type->fontheight; | |
1311 | 1311 | |||
1312 | srcoff = srcrow * ncols; | 1312 | srcoff = srcrow * ncols; | |
1313 | dstoff = dstrow * ncols; | 1313 | dstoff = dstrow * ncols; | |
1314 | rassrcoff = srcoff * fheight; | 1314 | rassrcoff = srcoff * fheight; | |
1315 | rasdstoff = dstoff * fheight; | 1315 | rasdstoff = dstoff * fheight; | |
1316 | 1316 | |||
1317 | if (scr->active) { | 1317 | if (scr->active) { | |
1318 | vga_gdc_write(vh, mode, 0x01); | 1318 | vga_gdc_write(vh, mode, 0x01); | |
1319 | if (dstrow == 0 && (srcrow + nrows == scr->type->nrows)) { | 1319 | if (dstrow == 0 && (srcrow + nrows == scr->type->nrows)) { | |
1320 | int cursoron = scr->cursoron; | 1320 | int cursoron = scr->cursoron; | |
1321 | 1321 | |||
1322 | if (cursoron) | 1322 | if (cursoron) | |
1323 | /* Disable cursor. */ | 1323 | /* Disable cursor. */ | |
1324 | vga_raster_cursor(scr, 0, | 1324 | vga_raster_cursor(scr, 0, | |
1325 | scr->cursorrow, scr->cursorcol); | 1325 | scr->cursorrow, scr->cursorcol); | |
1326 | 1326 | |||
1327 | /* scroll up whole screen */ | 1327 | /* scroll up whole screen */ | |
1328 | if ((scr->dispoffset + srcrow * ncols * fheight) | 1328 | if ((scr->dispoffset + srcrow * ncols * fheight) | |
1329 | <= scr->maxdispoffset) | 1329 | <= scr->maxdispoffset) | |
1330 | scr->dispoffset += srcrow * ncols * fheight; | 1330 | scr->dispoffset += srcrow * ncols * fheight; | |
1331 | else { | 1331 | else { | |
1332 | bus_space_copy_region_1(memt, memh, | 1332 | bus_space_copy_region_1(memt, memh, | |
1333 | scr->dispoffset + rassrcoff, | 1333 | scr->dispoffset + rassrcoff, | |
1334 | memh, scr->mindispoffset, | 1334 | memh, scr->mindispoffset, | |
1335 | nrows * ncols * fheight); | 1335 | nrows * ncols * fheight); | |
1336 | scr->dispoffset = scr->mindispoffset; | 1336 | scr->dispoffset = scr->mindispoffset; | |
1337 | } | 1337 | } | |
1338 | vga_6845_write(vh, startadrh, scr->dispoffset >> 8); | 1338 | vga_6845_write(vh, startadrh, scr->dispoffset >> 8); | |
1339 | vga_6845_write(vh, startadrl, scr->dispoffset); | 1339 | vga_6845_write(vh, startadrl, scr->dispoffset); | |
1340 | 1340 | |||
1341 | if (cursoron) | 1341 | if (cursoron) | |
1342 | /* Enable cursor. */ | 1342 | /* Enable cursor. */ | |
1343 | vga_raster_cursor(scr, 1, scr->cursorrow, | 1343 | vga_raster_cursor(scr, 1, scr->cursorrow, | |
1344 | scr->cursorcol); | 1344 | scr->cursorcol); | |
1345 | } else | 1345 | } else | |
1346 | bus_space_copy_region_1(memt, memh, | 1346 | bus_space_copy_region_1(memt, memh, | |
1347 | scr->dispoffset + rassrcoff, memh, | 1347 | scr->dispoffset + rassrcoff, memh, | |
1348 | scr->dispoffset + rasdstoff, | 1348 | scr->dispoffset + rasdstoff, | |
1349 | nrows * ncols * fheight); | 1349 | nrows * ncols * fheight); | |
1350 | } | 1350 | } | |
1351 | memcpy(&scr->mem[dstoff], &scr->mem[srcoff], | 1351 | memcpy(&scr->mem[dstoff], &scr->mem[srcoff], | |
1352 | nrows * ncols * sizeof(struct vga_scrmem)); | 1352 | nrows * ncols * sizeof(struct vga_scrmem)); | |
1353 | } | 1353 | } | |
1354 | 1354 | |||
1355 | void | 1355 | static void | |
1356 | vga_raster_eraserows(void *id, int startrow, int nrows, long fillattr) | 1356 | vga_raster_eraserows(void *id, int startrow, int nrows, long fillattr) | |
1357 | { | 1357 | { | |
1358 | struct vgascreen *scr = id; | 1358 | struct vgascreen *scr = id; | |
1359 | struct vga_handle *vh = scr->hdl; | 1359 | struct vga_handle *vh = scr->hdl; | |
1360 | bus_space_tag_t memt = vh->vh_memt; | 1360 | bus_space_tag_t memt = vh->vh_memt; | |
1361 | bus_space_handle_t memh = vh->vh_memh; | 1361 | bus_space_handle_t memh = vh->vh_memh; | |
1362 | bus_size_t off, count; | 1362 | bus_size_t off, count; | |
1363 | bus_size_t rasoff, rascount; | 1363 | bus_size_t rasoff, rascount; | |
1364 | int i; | 1364 | int i; | |
1365 | 1365 | |||
1366 | off = startrow * scr->type->ncols; | 1366 | off = startrow * scr->type->ncols; | |
1367 | count = nrows * scr->type->ncols; | 1367 | count = nrows * scr->type->ncols; | |
1368 | rasoff = off * scr->type->fontheight; | 1368 | rasoff = off * scr->type->fontheight; | |
1369 | rascount = count * scr->type->fontheight; | 1369 | rascount = count * scr->type->fontheight; | |
1370 | 1370 | |||
1371 | if (scr->active) { | 1371 | if (scr->active) { | |
1372 | u_int8_t bgcolor = (fillattr >> 4) & 0x0F; | 1372 | u_int8_t bgcolor = (fillattr >> 4) & 0x0F; | |
1373 | 1373 | |||
1374 | /* Paint background. */ | 1374 | /* Paint background. */ | |
1375 | vga_gdc_write(vh, mode, 0x02); | 1375 | vga_gdc_write(vh, mode, 0x02); | |
1376 | if (scr->type->ncols % 4 == 0) { | 1376 | if (scr->type->ncols % 4 == 0) { | |
1377 | u_int32_t fill = bgcolor | (bgcolor << 8) | | 1377 | u_int32_t fill = bgcolor | (bgcolor << 8) | | |
1378 | (bgcolor << 16) | (bgcolor << 24); | 1378 | (bgcolor << 16) | (bgcolor << 24); | |
1379 | /* We can speed up I/O */ | 1379 | /* We can speed up I/O */ | |
1380 | for (i = rasoff; i < rasoff + rascount; i += 4) | 1380 | for (i = rasoff; i < rasoff + rascount; i += 4) | |
1381 | bus_space_write_4(memt, memh, | 1381 | bus_space_write_4(memt, memh, | |
1382 | scr->dispoffset + i, fill); | 1382 | scr->dispoffset + i, fill); | |
1383 | } else { | 1383 | } else { | |
1384 | u_int16_t fill = bgcolor | (bgcolor << 8); | 1384 | u_int16_t fill = bgcolor | (bgcolor << 8); | |
1385 | for (i = rasoff; i < rasoff + rascount; i += 2) | 1385 | for (i = rasoff; i < rasoff + rascount; i += 2) | |
1386 | bus_space_write_2(memt, memh, | 1386 | bus_space_write_2(memt, memh, | |
1387 | scr->dispoffset + i, fill); | 1387 | scr->dispoffset + i, fill); | |
1388 | } | 1388 | } | |
1389 | } | 1389 | } | |
1390 | for (i = 0; i < count; i++) { | 1390 | for (i = 0; i < count; i++) { | |
1391 | scr->mem[off + i].ch = ' '; | 1391 | scr->mem[off + i].ch = ' '; | |
1392 | scr->mem[off + i].attr = fillattr; | 1392 | scr->mem[off + i].attr = fillattr; | |
1393 | scr->mem[off + i].second = 0; | 1393 | scr->mem[off + i].second = 0; | |
1394 | scr->mem[off + i].enc = scr->encoding; | 1394 | scr->mem[off + i].enc = scr->encoding; | |
1395 | } | 1395 | } | |
1396 | } | 1396 | } | |
1397 | 1397 | |||
1398 | static int | 1398 | static int | |
1399 | vga_raster_allocattr(void *id, int fg, int bg, int flags, long *attrp) | 1399 | vga_raster_allocattr(void *id, int fg, int bg, int flags, long *attrp) | |
1400 | { | 1400 | { | |
1401 | struct vgascreen *scr = id; | 1401 | struct vgascreen *scr = id; | |
1402 | struct vga_config *vc = scr->cfg; | 1402 | struct vga_config *vc = scr->cfg; | |
1403 | 1403 | |||
1404 | if (__predict_false((unsigned int)fg >= sizeof(fgansitopc) || | 1404 | if (__predict_false((unsigned int)fg >= sizeof(fgansitopc) || | |
1405 | (unsigned int)bg >= sizeof(bgansitopc))) | 1405 | (unsigned int)bg >= sizeof(bgansitopc))) | |
1406 | return (EINVAL); | 1406 | return (EINVAL); | |
1407 | 1407 | |||
1408 | if (vc->hdl.vh_mono) { | 1408 | if (vc->hdl.vh_mono) { | |
1409 | if (flags & WSATTR_WSCOLORS) | 1409 | if (flags & WSATTR_WSCOLORS) | |
1410 | return (EINVAL); | 1410 | return (EINVAL); | |
1411 | if (flags & WSATTR_REVERSE) | 1411 | if (flags & WSATTR_REVERSE) | |
1412 | *attrp = 0x70; | 1412 | *attrp = 0x70; | |
1413 | else | 1413 | else | |
1414 | *attrp = 0x07; | 1414 | *attrp = 0x07; | |
1415 | if (flags & WSATTR_UNDERLINE) | 1415 | if (flags & WSATTR_UNDERLINE) | |
1416 | *attrp |= FG_UNDERLINE; | 1416 | *attrp |= FG_UNDERLINE; | |
1417 | if (flags & WSATTR_HILIT) | 1417 | if (flags & WSATTR_HILIT) | |
1418 | *attrp |= FG_INTENSE; | 1418 | *attrp |= FG_INTENSE; | |
1419 | } else { | 1419 | } else { | |
1420 | if (flags & (WSATTR_UNDERLINE | WSATTR_REVERSE)) | 1420 | if (flags & (WSATTR_UNDERLINE | WSATTR_REVERSE)) | |
1421 | return (EINVAL); | 1421 | return (EINVAL); | |
1422 | if (flags & WSATTR_WSCOLORS) | 1422 | if (flags & WSATTR_WSCOLORS) | |
1423 | *attrp = fgansitopc[fg] | bgansitopc[bg]; | 1423 | *attrp = fgansitopc[fg] | bgansitopc[bg]; | |
1424 | else | 1424 | else | |
1425 | *attrp = 7; | 1425 | *attrp = 7; | |
1426 | if (flags & WSATTR_HILIT) | 1426 | if (flags & WSATTR_HILIT) | |
1427 | *attrp += 8; | 1427 | *attrp += 8; | |
1428 | } | 1428 | } | |
1429 | if (flags & WSATTR_BLINK) | 1429 | if (flags & WSATTR_BLINK) | |
1430 | *attrp |= FG_BLINK; | 1430 | *attrp |= FG_BLINK; | |
1431 | return (0); | 1431 | return (0); | |
1432 | } | 1432 | } | |
1433 | 1433 | |||
1434 | void | 1434 | static void | |
1435 | vga_restore_screen(struct vgascreen *scr, | 1435 | vga_restore_screen(struct vgascreen *scr, | |
1436 | const struct wsscreen_descr *type, struct vga_scrmem *mem) | 1436 | const struct wsscreen_descr *type, struct vga_scrmem *mem) | |
1437 | { | 1437 | { | |
1438 | int i, j, off, tmp; | 1438 | int i, j, off, tmp; | |
1439 | 1439 | |||
1440 | tmp = scr->encoding; | 1440 | tmp = scr->encoding; | |
1441 | for (i = 0; i < type->nrows; i++) { | 1441 | for (i = 0; i < type->nrows; i++) { | |
1442 | for (j = 0; j < type->ncols; j++) { | 1442 | for (j = 0; j < type->ncols; j++) { | |
1443 | off = i * type->ncols + j; | 1443 | off = i * type->ncols + j; | |
1444 | if (mem[off].second != 1) { | 1444 | if (mem[off].second != 1) { | |
1445 | scr->encoding = mem[off].enc; | 1445 | scr->encoding = mem[off].enc; | |
1446 | vga_raster_putchar(scr, i, j, mem[off].ch, | 1446 | vga_raster_putchar(scr, i, j, mem[off].ch, | |
1447 | mem[off].attr); | 1447 | mem[off].attr); | |
1448 | } | 1448 | } | |
1449 | } | 1449 | } | |
1450 | } | 1450 | } | |
1451 | scr->encoding = tmp; | 1451 | scr->encoding = tmp; | |
1452 | } | 1452 | } | |
1453 | 1453 | |||
1454 | void | 1454 | static void | |
1455 | vga_raster_setscreentype(struct vga_config *vc, | 1455 | vga_raster_setscreentype(struct vga_config *vc, | |
1456 | const struct wsscreen_descr *type) | 1456 | const struct wsscreen_descr *type) | |
1457 | { | 1457 | { | |
1458 | struct vga_handle *vh = &vc->hdl; | 1458 | struct vga_handle *vh = &vc->hdl; | |
1459 | struct vga_moderegs moderegs; | 1459 | struct vga_moderegs moderegs; | |
1460 | 1460 | |||
1461 | vga_setup_regs((struct videomode *)type->modecookie, &moderegs); | 1461 | vga_setup_regs((struct videomode *)type->modecookie, &moderegs); | |
1462 | vga_set_mode(vh, &moderegs); | 1462 | vga_set_mode(vh, &moderegs); | |
1463 | } | 1463 | } | |
1464 | 1464 | |||
1465 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | 1465 | #ifdef WSDISPLAY_CUSTOM_OUTPUT | |
1466 | void | 1466 | static void | |
1467 | vga_raster_replaceattr(void *id, long oldattr, long newattr) | 1467 | vga_raster_replaceattr(void *id, long oldattr, long newattr) | |
1468 | { | 1468 | { | |
1469 | struct vgascreen *scr = id; | 1469 | struct vgascreen *scr = id; | |
1470 | const struct wsscreen_descr *type = scr->type; | 1470 | const struct wsscreen_descr *type = scr->type; | |
1471 | int off; | 1471 | int off; | |
1472 | 1472 | |||
1473 | for (off = 0; off < type->nrows * type->ncols; off++) { | 1473 | for (off = 0; off < type->nrows * type->ncols; off++) { | |
1474 | if (scr->mem[off].attr == oldattr) | 1474 | if (scr->mem[off].attr == oldattr) | |
1475 | scr->mem[off].attr = newattr; | 1475 | scr->mem[off].attr = newattr; | |
1476 | } | 1476 | } | |
1477 | 1477 | |||
1478 | /* Repaint the whole screen, if needed */ | 1478 | /* Repaint the whole screen, if needed */ | |
1479 | if (scr->active) | 1479 | if (scr->active) | |
1480 | vga_restore_screen(scr, type, scr->mem); | 1480 | vga_restore_screen(scr, type, scr->mem); | |
1481 | } | 1481 | } | |
1482 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | 1482 | #endif /* WSDISPLAY_CUSTOM_OUTPUT */ | |
1483 | 1483 | |||
1484 | void | 1484 | void | |
1485 | vga_resume(struct vga_softc *sc) | 1485 | vga_resume(struct vga_softc *sc) | |
1486 | { | 1486 | { | |
1487 | #ifdef VGA_RESET_ON_RESUME | 1487 | #ifdef VGA_RESET_ON_RESUME | |
1488 | vga_initregs(&sc->sc_vc->hdl); | 1488 | vga_initregs(&sc->sc_vc->hdl); | |
1489 | #endif | 1489 | #endif | |
1490 | } | 1490 | } |
--- src/sys/dev/ic/vgavar.h 2010/12/09 23:33:30 1.29
+++ src/sys/dev/ic/vgavar.h 2013/01/21 19:49:15 1.30
@@ -1,223 +1,221 @@ | @@ -1,223 +1,221 @@ | |||
1 | /* $NetBSD: vgavar.h,v 1.29 2010/12/09 23:33:30 christos Exp $ */ | 1 | /* $NetBSD: vgavar.h,v 1.30 2013/01/21 19:49:15 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | 4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Author: Chris G. Demetriou | 7 | * Author: Chris G. Demetriou | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify and distribute this software and | 9 | * Permission to use, copy, modify and distribute this software and | |
10 | * its documentation is hereby granted, provided that both the copyright | 10 | * its documentation is hereby granted, provided that both the copyright | |
11 | * notice and this permission notice appear in all copies of the | 11 | * notice and this permission notice appear in all copies of the | |
12 | * software, derivative works or modified versions, and any portions | 12 | * software, derivative works or modified versions, and any portions | |
13 | * thereof, and that both notices appear in supporting documentation. | 13 | * thereof, and that both notices appear in supporting documentation. | |
14 | * | 14 | * | |
15 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 15 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
16 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | 16 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | |
17 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | 17 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
18 | * | 18 | * | |
19 | * Carnegie Mellon requests users of this software to return to | 19 | * Carnegie Mellon requests users of this software to return to | |
20 | * | 20 | * | |
21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | 21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
22 | * School of Computer Science | 22 | * School of Computer Science | |
23 | * Carnegie Mellon University | 23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | 24 | * Pittsburgh PA 15213-3890 | |
25 | * | 25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie the | 26 | * any improvements or extensions that they make and grant Carnegie the | |
27 | * rights to redistribute these changes. | 27 | * rights to redistribute these changes. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <sys/callout.h> | 30 | #include <sys/callout.h> | |
31 | 31 | |||
32 | #include "opt_vga.h" | 32 | #include "opt_vga.h" | |
33 | 33 | |||
34 | struct vga_handle { | 34 | struct vga_handle { | |
35 | struct pcdisplay_handle vh_ph; | 35 | struct pcdisplay_handle vh_ph; | |
36 | bus_space_handle_t vh_ioh_vga, vh_allmemh; | 36 | bus_space_handle_t vh_ioh_vga, vh_allmemh; | |
37 | int vh_mono; | 37 | int vh_mono; | |
38 | }; | 38 | }; | |
39 | #define vh_iot vh_ph.ph_iot | 39 | #define vh_iot vh_ph.ph_iot | |
40 | #define vh_memt vh_ph.ph_memt | 40 | #define vh_memt vh_ph.ph_memt | |
41 | #define vh_ioh_6845 vh_ph.ph_ioh_6845 | 41 | #define vh_ioh_6845 vh_ph.ph_ioh_6845 | |
42 | #define vh_memh vh_ph.ph_memh | 42 | #define vh_memh vh_ph.ph_memh | |
43 | 43 | |||
44 | struct vga_funcs { | 44 | struct vga_funcs { | |
45 | int (*vf_ioctl)(void *, u_long, void *, int, struct lwp *); | 45 | int (*vf_ioctl)(void *, u_long, void *, int, struct lwp *); | |
46 | paddr_t (*vf_mmap)(void *, off_t, int); | 46 | paddr_t (*vf_mmap)(void *, off_t, int); | |
47 | }; | 47 | }; | |
48 | 48 | |||
49 | struct vga_config { | 49 | struct vga_config { | |
50 | struct vga_handle hdl; | 50 | struct vga_handle hdl; | |
51 | struct vga_softc *softc; | 51 | struct vga_softc *softc; | |
52 | 52 | |||
53 | int nscreens; | 53 | int nscreens; | |
54 | LIST_HEAD(, vgascreen) screens; | 54 | LIST_HEAD(, vgascreen) screens; | |
55 | struct vgascreen *active; /* current display */ | 55 | struct vgascreen *active; /* current display */ | |
56 | const struct wsscreen_descr *currenttype; | 56 | const struct wsscreen_descr *currenttype; | |
57 | 57 | |||
58 | int vc_biosmapped; | 58 | int vc_biosmapped; | |
59 | bus_space_tag_t vc_biostag; | 59 | bus_space_tag_t vc_biostag; | |
60 | bus_space_handle_t vc_bioshdl; | 60 | bus_space_handle_t vc_bioshdl; | |
61 | 61 | |||
62 | struct vgascreen *wantedscreen; | 62 | struct vgascreen *wantedscreen; | |
63 | void (*switchcb)(void *, int, int); | 63 | void (*switchcb)(void *, int, int); | |
64 | void *switchcbarg; | 64 | void *switchcbarg; | |
65 | 65 | |||
66 | struct callout vc_switch_callout; | 66 | struct callout vc_switch_callout; | |
67 | int vc_quirks; | 67 | int vc_quirks; | |
68 | int vc_type; | 68 | int vc_type; | |
69 | const struct vga_funcs *vc_funcs; | 69 | const struct vga_funcs *vc_funcs; | |
70 | 70 | |||
71 | u_int8_t palette[256 * 3]; | 71 | u_int8_t palette[256 * 3]; | |
72 | #ifndef VGA_RASTERCONSOLE | 72 | #ifndef VGA_RASTERCONSOLE | |
73 | int currentfontset1, currentfontset2; | 73 | int currentfontset1, currentfontset2; | |
74 | int vc_nfontslots; | 74 | int vc_nfontslots; | |
75 | struct egavga_font *vc_fonts[8]; /* currently loaded */ | 75 | struct egavga_font *vc_fonts[8]; /* currently loaded */ | |
76 | TAILQ_HEAD(, egavga_font) vc_fontlist; /* LRU queue */ | 76 | TAILQ_HEAD(, egavga_font) vc_fontlist; /* LRU queue */ | |
77 | #else | 77 | #else | |
78 | int nfonts; | 78 | int nfonts; | |
79 | LIST_HEAD(, vga_raster_font) vc_fontlist; | 79 | LIST_HEAD(, vga_raster_font) vc_fontlist; | |
80 | #endif /* !VGA_RASTERCONSOLE */ | 80 | #endif /* !VGA_RASTERCONSOLE */ | |
81 | }; | 81 | }; | |
82 | 82 | |||
83 | struct vga_softc { | 83 | struct vga_softc { | |
84 | device_t sc_dev; | 84 | device_t sc_dev; | |
85 | struct vga_config *sc_vc; | 85 | struct vga_config *sc_vc; | |
86 | }; | 86 | }; | |
87 | 87 | |||
88 | static __inline u_int8_t _vga_attr_read(struct vga_handle *, int); | 88 | static __inline u_int8_t _vga_attr_read(struct vga_handle *, int); | |
89 | static __inline void _vga_attr_write(struct vga_handle *, int, u_int8_t); | 89 | static __inline void _vga_attr_write(struct vga_handle *, int, u_int8_t); | |
90 | static __inline u_int8_t _vga_ts_read(struct vga_handle *, int); | 90 | static __inline u_int8_t _vga_ts_read(struct vga_handle *, int); | |
91 | static __inline void _vga_ts_write(struct vga_handle *, int, u_int8_t); | 91 | static __inline void _vga_ts_write(struct vga_handle *, int, u_int8_t); | |
92 | static __inline u_int8_t _vga_gdc_read(struct vga_handle *, int); | 92 | static __inline u_int8_t _vga_gdc_read(struct vga_handle *, int); | |
93 | static __inline void _vga_gdc_write(struct vga_handle *, int, u_int8_t); | 93 | static __inline void _vga_gdc_write(struct vga_handle *, int, u_int8_t); | |
94 | 94 | |||
95 | #define vga_raw_read(vh, reg) \ | 95 | #define vga_raw_read(vh, reg) \ | |
96 | bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, reg) | 96 | bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, reg) | |
97 | #define vga_raw_write(vh, reg, value) \ | 97 | #define vga_raw_write(vh, reg, value) \ | |
98 | bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, reg, value) | 98 | bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, reg, value) | |
99 | 99 | |||
100 | #define vga_enable(vh) \ | 100 | #define vga_enable(vh) \ | |
101 | vga_raw_write(vh, 0, 0x20) | 101 | vga_raw_write(vh, 0, 0x20) | |
102 | 102 | |||
103 | #define vga_reset_state(vh) \ | 103 | #define vga_reset_state(vh) \ | |
104 | (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10) | 104 | (void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10) | |
105 | 105 | |||
106 | static __inline u_int8_t | 106 | static __inline u_int8_t | |
107 | _vga_attr_read(struct vga_handle *vh, int reg) | 107 | _vga_attr_read(struct vga_handle *vh, int reg) | |
108 | { | 108 | { | |
109 | u_int8_t res; | 109 | u_int8_t res; | |
110 | 110 | |||
111 | /* reset state */ | 111 | /* reset state */ | |
112 | vga_reset_state(vh); | 112 | vga_reset_state(vh); | |
113 | 113 | |||
114 | vga_raw_write(vh, VGA_ATC_INDEX, reg); | 114 | vga_raw_write(vh, VGA_ATC_INDEX, reg); | |
115 | res = vga_raw_read(vh, VGA_ATC_DATAR); | 115 | res = vga_raw_read(vh, VGA_ATC_DATAR); | |
116 | 116 | |||
117 | /* XXX unneeded? */ | 117 | /* XXX unneeded? */ | |
118 | vga_reset_state(vh); | 118 | vga_reset_state(vh); | |
119 | 119 | |||
120 | vga_enable(vh); | 120 | vga_enable(vh); | |
121 | 121 | |||
122 | return res; | 122 | return res; | |
123 | } | 123 | } | |
124 | 124 | |||
125 | static __inline void | 125 | static __inline void | |
126 | _vga_attr_write(struct vga_handle *vh, int reg, u_int8_t val) | 126 | _vga_attr_write(struct vga_handle *vh, int reg, u_int8_t val) | |
127 | { | 127 | { | |
128 | 128 | |||
129 | vga_reset_state(vh); | 129 | vga_reset_state(vh); | |
130 | 130 | |||
131 | vga_raw_write(vh, VGA_ATC_INDEX, reg); | 131 | vga_raw_write(vh, VGA_ATC_INDEX, reg); | |
132 | vga_raw_write(vh, VGA_ATC_DATAW, val); | 132 | vga_raw_write(vh, VGA_ATC_DATAW, val); | |
133 | 133 | |||
134 | /* XXX unneeded? */ | 134 | /* XXX unneeded? */ | |
135 | vga_reset_state(vh); | 135 | vga_reset_state(vh); | |
136 | 136 | |||
137 | vga_enable(vh); | 137 | vga_enable(vh); | |
138 | } | 138 | } | |
139 | 139 | |||
140 | static __inline u_int8_t | 140 | static __inline u_int8_t | |
141 | _vga_ts_read(struct vga_handle *vh, int reg) | 141 | _vga_ts_read(struct vga_handle *vh, int reg) | |
142 | { | 142 | { | |
143 | 143 | |||
144 | vga_raw_write(vh, VGA_TS_INDEX, reg); | 144 | vga_raw_write(vh, VGA_TS_INDEX, reg); | |
145 | return vga_raw_read(vh, VGA_TS_DATA); | 145 | return vga_raw_read(vh, VGA_TS_DATA); | |
146 | } | 146 | } | |
147 | 147 | |||
148 | static __inline void | 148 | static __inline void | |
149 | _vga_ts_write(struct vga_handle *vh, int reg, u_int8_t val) | 149 | _vga_ts_write(struct vga_handle *vh, int reg, u_int8_t val) | |
150 | { | 150 | { | |
151 | 151 | |||
152 | vga_raw_write(vh, VGA_TS_INDEX, reg); | 152 | vga_raw_write(vh, VGA_TS_INDEX, reg); | |
153 | vga_raw_write(vh, VGA_TS_DATA, val); | 153 | vga_raw_write(vh, VGA_TS_DATA, val); | |
154 | } | 154 | } | |
155 | 155 | |||
156 | static __inline u_int8_t | 156 | static __inline u_int8_t | |
157 | _vga_gdc_read(struct vga_handle *vh, int reg) | 157 | _vga_gdc_read(struct vga_handle *vh, int reg) | |
158 | { | 158 | { | |
159 | 159 | |||
160 | vga_raw_write(vh, VGA_GDC_INDEX, reg); | 160 | vga_raw_write(vh, VGA_GDC_INDEX, reg); | |
161 | return vga_raw_read(vh, VGA_GDC_DATA); | 161 | return vga_raw_read(vh, VGA_GDC_DATA); | |
162 | } | 162 | } | |
163 | 163 | |||
164 | static __inline void | 164 | static __inline void | |
165 | _vga_gdc_write(struct vga_handle *vh, int reg, u_int8_t val) | 165 | _vga_gdc_write(struct vga_handle *vh, int reg, u_int8_t val) | |
166 | { | 166 | { | |
167 | 167 | |||
168 | vga_raw_write(vh, VGA_GDC_INDEX, reg); | 168 | vga_raw_write(vh, VGA_GDC_INDEX, reg); | |
169 | vga_raw_write(vh, VGA_GDC_DATA, val); | 169 | vga_raw_write(vh, VGA_GDC_DATA, val); | |
170 | } | 170 | } | |
171 | 171 | |||
172 | #define vga_attr_read(vh, reg) \ | 172 | #define vga_attr_read(vh, reg) \ | |
173 | _vga_attr_read(vh, offsetof(struct reg_vgaattr, reg)) | 173 | _vga_attr_read(vh, offsetof(struct reg_vgaattr, reg)) | |
174 | #define vga_attr_write(vh, reg, val) \ | 174 | #define vga_attr_write(vh, reg, val) \ | |
175 | _vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val) | 175 | _vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val) | |
176 | #define vga_ts_read(vh, reg) \ | 176 | #define vga_ts_read(vh, reg) \ | |
177 | _vga_ts_read(vh, offsetof(struct reg_vgats, reg)) | 177 | _vga_ts_read(vh, offsetof(struct reg_vgats, reg)) | |
178 | #define vga_ts_write(vh, reg, val) \ | 178 | #define vga_ts_write(vh, reg, val) \ | |
179 | _vga_ts_write(vh, offsetof(struct reg_vgats, reg), val) | 179 | _vga_ts_write(vh, offsetof(struct reg_vgats, reg), val) | |
180 | #define vga_gdc_read(vh, reg) \ | 180 | #define vga_gdc_read(vh, reg) \ | |
181 | _vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg)) | 181 | _vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg)) | |
182 | #define vga_gdc_write(vh, reg, val) \ | 182 | #define vga_gdc_write(vh, reg, val) \ | |
183 | _vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val) | 183 | _vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val) | |
184 | 184 | |||
185 | #define vga_6845_read(vh, reg) \ | 185 | #define vga_6845_read(vh, reg) \ | |
186 | pcdisplay_6845_read(&(vh)->vh_ph, reg) | 186 | pcdisplay_6845_read(&(vh)->vh_ph, reg) | |
187 | #define vga_6845_write(vh, reg, val) \ | 187 | #define vga_6845_write(vh, reg, val) \ | |
188 | pcdisplay_6845_write(&(vh)->vh_ph, reg, val) | 188 | pcdisplay_6845_write(&(vh)->vh_ph, reg, val) | |
189 | #define _vga_6845_read(vh, reg) \ | 189 | #define _vga_6845_read(vh, reg) \ | |
190 | _pcdisplay_6845_read(&(vh)->vh_ph, reg) | 190 | _pcdisplay_6845_read(&(vh)->vh_ph, reg) | |
191 | #define _vga_6845_write(vh, reg, val) \ | 191 | #define _vga_6845_write(vh, reg, val) \ | |
192 | _pcdisplay_6845_write(&(vh)->vh_ph, reg, val) | 192 | _pcdisplay_6845_write(&(vh)->vh_ph, reg, val) | |
193 | 193 | |||
194 | int vga_common_probe(bus_space_tag_t, bus_space_tag_t); | 194 | int vga_common_probe(bus_space_tag_t, bus_space_tag_t); | |
195 | void vga_common_attach(struct vga_softc *, bus_space_tag_t, | 195 | void vga_common_attach(struct vga_softc *, bus_space_tag_t, | |
196 | bus_space_tag_t, int, int, const struct vga_funcs *); | 196 | bus_space_tag_t, int, int, const struct vga_funcs *); | |
197 | #define VGA_QUIRK_ONEFONT 0x01 | 197 | #define VGA_QUIRK_ONEFONT 0x01 | |
198 | #define VGA_QUIRK_NOFASTSCROLL 0x02 | 198 | #define VGA_QUIRK_NOFASTSCROLL 0x02 | |
199 | int vga_is_console(bus_space_tag_t, int); | 199 | int vga_is_console(bus_space_tag_t, int); | |
200 | 200 | |||
201 | int vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int); | 201 | int vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int); | |
202 | int vga_cndetach(void); | 202 | int vga_cndetach(void); | |
203 | 203 | |||
204 | void vga_resume(struct vga_softc *); | 204 | void vga_resume(struct vga_softc *); | |
205 | 205 | |||
206 | #ifndef VGA_RASTERCONSOLE | 206 | #ifndef VGA_RASTERCONSOLE | |
207 | struct wsscreen_descr; | 207 | struct wsscreen_descr; | |
208 | void vga_loadchars(struct vga_handle *, int, int, int, int, const char *); | 208 | void vga_loadchars(struct vga_handle *, int, int, int, int, const char *); | |
209 | void vga_readoutchars(struct vga_handle *, int, int, int, int, char *); | 209 | void vga_readoutchars(struct vga_handle *, int, int, int, int, char *); | |
210 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | 210 | #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL | |
211 | void vga_copyfont01(struct vga_handle *); | 211 | void vga_copyfont01(struct vga_handle *); | |
212 | #endif | 212 | #endif | |
213 | void vga_setfontset(struct vga_handle *, int, int); | 213 | void vga_setfontset(struct vga_handle *, int, int); | |
214 | void vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *); | 214 | void vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *); | |
215 | #else /* !VGA_RASTERCONSOLE */ | 215 | #else /* !VGA_RASTERCONSOLE */ | |
216 | void vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int); | 216 | void vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int); | |
217 | #endif /* !VGA_RASTERCONSOLE */ | 217 | #endif /* !VGA_RASTERCONSOLE */ | |
218 | void vga_reset(struct vga_handle *, void (*)(struct vga_handle *)); | 218 | void vga_reset(struct vga_handle *, void (*)(struct vga_handle *)); | |
219 | void vga_initregs(struct vga_handle *); | 219 | void vga_initregs(struct vga_handle *); | |
220 | void vga_save_palette(struct vga_config *); | |||
221 | void vga_restore_palette(struct vga_config *); | |||
222 | 220 | |||
223 | extern int vga_no_builtinfont; | 221 | extern int vga_no_builtinfont; |