2 * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef VGA_NO_MODE_CHANGE
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/module.h>
38 #include <sys/malloc.h>
42 #include <vm/vm_extern.h>
43 #include <vm/vm_kern.h>
46 #include <machine/md_var.h>
47 #include <machine/vm86.h>
48 #include <machine/pc/bios.h>
49 #include <machine/pc/vesa.h>
51 #include <dev/fb/fbreg.h>
52 #include <dev/fb/vgareg.h>
55 #include <isa/isareg.h>
57 #include <i386/isa/isa.h>
64 /* VESA video adapter state buffer stub */
67 #define V_STATE_SIG 0x61736576
70 typedef struct adp_state adp_state_t;
72 /* VESA video adapter */
73 static video_adapter_t *vesa_adp = NULL;
74 static int vesa_state_buf_size = 0;
78 static int vesa_nop(void);
80 static int vesa_error(void);
81 static vi_probe_t vesa_probe;
82 static vi_init_t vesa_init;
83 static vi_get_info_t vesa_get_info;
84 static vi_query_mode_t vesa_query_mode;
85 static vi_set_mode_t vesa_set_mode;
86 static vi_save_font_t vesa_save_font;
87 static vi_load_font_t vesa_load_font;
88 static vi_show_font_t vesa_show_font;
89 static vi_save_palette_t vesa_save_palette;
90 static vi_load_palette_t vesa_load_palette;
91 static vi_set_border_t vesa_set_border;
92 static vi_save_state_t vesa_save_state;
93 static vi_load_state_t vesa_load_state;
94 static vi_set_win_org_t vesa_set_origin;
95 static vi_read_hw_cursor_t vesa_read_hw_cursor;
96 static vi_set_hw_cursor_t vesa_set_hw_cursor;
97 static vi_set_hw_cursor_shape_t vesa_set_hw_cursor_shape;
98 static vi_blank_display_t vesa_blank_display;
99 static vi_mmap_t vesa_mmap;
100 static vi_ioctl_t vesa_ioctl;
101 static vi_clear_t vesa_clear;
102 static vi_fill_rect_t vesa_fill_rect;
103 static vi_bitblt_t vesa_bitblt;
104 static vi_diag_t vesa_diag;
105 static int vesa_bios_info(int level);
106 static struct vm86context vesa_vmcontext;
108 static video_switch_t vesavidsw = {
125 vesa_set_hw_cursor_shape,
137 static video_switch_t *prevvidsw;
139 /* VESA BIOS video modes */
140 #define VESA_MAXMODES 64
144 #define MODE_TABLE_DELTA 8
146 static int vesa_vmode_max = 0;
147 static video_info_t vesa_vmode_empty = { EOT };
148 static video_info_t *vesa_vmode = &vesa_vmode_empty;
150 static int vesa_init_done = FALSE;
151 static int has_vesa_bios = FALSE;
152 static struct vesa_info *vesa_adp_info = NULL;
153 static u_int16_t *vesa_vmodetab = NULL;
154 static char *vesa_oemstr = NULL;
155 static char *vesa_venderstr = NULL;
156 static char *vesa_prodstr = NULL;
157 static char *vesa_revstr = NULL;
159 /* local macros and functions */
160 #define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
162 static int int10_set_mode(int mode);
163 static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode);
164 static int vesa_bios_set_mode(int mode);
165 static int vesa_bios_get_dac(void);
166 static int vesa_bios_set_dac(int bits);
167 static int vesa_bios_save_palette(int start, int colors, u_char *palette,
169 static int vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g,
170 u_char *b, int bits);
171 static int vesa_bios_load_palette(int start, int colors, u_char *palette,
174 static int vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g,
175 u_char *b, int bits);
180 #define STATE_HW (1<<0)
181 #define STATE_DATA (1<<1)
182 #define STATE_DAC (1<<2)
183 #define STATE_REG (1<<3)
184 #define STATE_MOST (STATE_HW | STATE_DATA | STATE_REG)
185 #define STATE_ALL (STATE_HW | STATE_DATA | STATE_DAC | STATE_REG)
186 static int vesa_bios_state_buf_size(void);
187 static int vesa_bios_save_restore(int code, void *p, size_t size);
188 static int vesa_bios_get_line_length(void);
189 static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines);
191 static int vesa_bios_get_start(int *x, int *y);
193 static int vesa_bios_set_start(int x, int y);
194 static int vesa_map_gen_mode_num(int type, int color, int mode);
195 static int vesa_translate_flags(u_int16_t vflags);
196 static int vesa_translate_mmodel(u_int8_t vmodel);
197 static void *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off,
199 static int vesa_bios_init(void);
200 static void vesa_clear_modes(video_info_t *info, int color);
201 static vm_offset_t vesa_map_buffer(u_int paddr, size_t size);
202 static void vesa_unmap_buffer(vm_offset_t vaddr, size_t size);
205 static int vesa_get_origin(video_adapter_t *adp, off_t *offset);
209 dump_buffer(u_char *buf, size_t len)
213 for(i = 0; i < len;) {
214 printf("%02x ", buf[i]);
220 /* INT 10 BIOS calls */
222 int10_set_mode(int mode)
224 struct vm86frame vmf;
226 bzero(&vmf, sizeof(vmf));
227 vmf.vmf_eax = 0x0000 | mode;
228 vm86_intcall(0x10, &vmf);
232 /* VESA BIOS calls */
234 vesa_bios_get_mode(int mode, struct vesa_mode *vmode)
236 struct vm86frame vmf;
240 bzero(&vmf, sizeof(vmf));
241 vmf.vmf_eax = 0x4f01;
243 buf = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
244 vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_di);
246 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
247 if ((err != 0) || (vmf.vmf_ax != 0x4f))
249 bcopy(buf, vmode, sizeof(*vmode));
254 vesa_bios_set_mode(int mode)
256 struct vm86frame vmf;
259 bzero(&vmf, sizeof(vmf));
260 vmf.vmf_eax = 0x4f02;
262 err = vm86_intcall(0x10, &vmf);
263 return ((err != 0) || (vmf.vmf_ax != 0x4f));
267 vesa_bios_get_dac(void)
269 struct vm86frame vmf;
272 bzero(&vmf, sizeof(vmf));
273 vmf.vmf_eax = 0x4f08;
274 vmf.vmf_ebx = 1; /* get DAC width */
275 err = vm86_intcall(0x10, &vmf);
276 if ((err != 0) || (vmf.vmf_ax != 0x4f))
278 return ((vmf.vmf_ebx >> 8) & 0x00ff);
282 vesa_bios_set_dac(int bits)
284 struct vm86frame vmf;
287 bzero(&vmf, sizeof(vmf));
288 vmf.vmf_eax = 0x4f08;
289 vmf.vmf_ebx = (bits << 8);
290 err = vm86_intcall(0x10, &vmf);
291 if ((err != 0) || (vmf.vmf_ax != 0x4f))
293 return ((vmf.vmf_ebx >> 8) & 0x00ff);
297 vesa_bios_save_palette(int start, int colors, u_char *palette, int bits)
299 struct vm86frame vmf;
304 bzero(&vmf, sizeof(vmf));
305 vmf.vmf_eax = 0x4f09;
306 vmf.vmf_ebx = 1; /* get primary palette data */
307 vmf.vmf_ecx = colors;
309 p = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
310 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
312 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
313 if ((err != 0) || (vmf.vmf_ax != 0x4f))
317 for (i = 0; i < colors; ++i) {
318 palette[i*3] = p[i*4 + 2] << bits;
319 palette[i*3 + 1] = p[i*4 + 1] << bits;
320 palette[i*3 + 2] = p[i*4] << bits;
326 vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
329 struct vm86frame vmf;
334 bzero(&vmf, sizeof(vmf));
335 vmf.vmf_eax = 0x4f09;
336 vmf.vmf_ebx = 1; /* get primary palette data */
337 vmf.vmf_ecx = colors;
339 p = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
340 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
342 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
343 if ((err != 0) || (vmf.vmf_ax != 0x4f))
347 for (i = 0; i < colors; ++i) {
348 r[i] = p[i*4 + 2] << bits;
349 g[i] = p[i*4 + 1] << bits;
350 b[i] = p[i*4] << bits;
356 vesa_bios_load_palette(int start, int colors, u_char *palette, int bits)
358 struct vm86frame vmf;
363 p = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
365 for (i = 0; i < colors; ++i) {
366 p[i*4] = palette[i*3 + 2] >> bits;
367 p[i*4 + 1] = palette[i*3 + 1] >> bits;
368 p[i*4 + 2] = palette[i*3] >> bits;
372 bzero(&vmf, sizeof(vmf));
373 vmf.vmf_eax = 0x4f09;
374 vmf.vmf_ebx = 0; /* set primary palette data */
375 vmf.vmf_ecx = colors;
377 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
379 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
380 return ((err != 0) || (vmf.vmf_ax != 0x4f));
385 vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
388 struct vm86frame vmf;
393 p = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
395 for (i = 0; i < colors; ++i) {
396 p[i*4] = b[i] >> bits;
397 p[i*4 + 1] = g[i] >> bits;
398 p[i*4 + 2] = r[i] >> bits;
402 bzero(&vmf, sizeof(vmf));
403 vmf.vmf_eax = 0x4f09;
404 vmf.vmf_ebx = 0; /* set primary palette data */
405 vmf.vmf_ecx = colors;
407 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
409 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
410 return ((err != 0) || (vmf.vmf_ax != 0x4f));
415 vesa_bios_state_buf_size(void)
417 struct vm86frame vmf;
420 bzero(&vmf, sizeof(vmf));
421 vmf.vmf_eax = 0x4f04;
422 vmf.vmf_ecx = STATE_MOST;
423 vmf.vmf_edx = STATE_SIZE;
424 err = vm86_intcall(0x10, &vmf);
425 if ((err != 0) || (vmf.vmf_ax != 0x4f))
427 return vmf.vmf_bx*64;
431 vesa_bios_save_restore(int code, void *p, size_t size)
433 struct vm86frame vmf;
437 bzero(&vmf, sizeof(vmf));
438 vmf.vmf_eax = 0x4f04;
439 vmf.vmf_ecx = STATE_MOST;
440 vmf.vmf_edx = code; /* STATE_SAVE/STATE_LOAD */
441 buf = (u_char *)vm86_getpage(&vesa_vmcontext, 1);
442 vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_di);
445 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
446 return ((err != 0) || (vmf.vmf_ax != 0x4f));
450 vesa_bios_get_line_length(void)
452 struct vm86frame vmf;
455 bzero(&vmf, sizeof(vmf));
456 vmf.vmf_eax = 0x4f06;
457 vmf.vmf_ebx = 1; /* get scan line length */
458 err = vm86_intcall(0x10, &vmf);
459 if ((err != 0) || (vmf.vmf_ax != 0x4f))
461 return vmf.vmf_bx; /* line length in bytes */
465 vesa_bios_set_line_length(int pixel, int *bytes, int *lines)
467 struct vm86frame vmf;
470 bzero(&vmf, sizeof(vmf));
471 vmf.vmf_eax = 0x4f06;
472 vmf.vmf_ebx = 0; /* set scan line length in pixel */
474 err = vm86_intcall(0x10, &vmf);
476 printf("bx:%d, cx:%d, dx:%d\n", vmf.vmf_bx, vmf.vmf_cx, vmf.vmf_dx);
478 if ((err != 0) || (vmf.vmf_ax != 0x4f))
489 vesa_bios_get_start(int *x, int *y)
491 struct vm86frame vmf;
494 bzero(&vmf, sizeof(vmf));
495 vmf.vmf_eax = 0x4f07;
496 vmf.vmf_ebx = 1; /* get display start */
497 err = vm86_intcall(0x10, &vmf);
498 if ((err != 0) || (vmf.vmf_ax != 0x4f))
507 vesa_bios_set_start(int x, int y)
509 struct vm86frame vmf;
512 bzero(&vmf, sizeof(vmf));
513 vmf.vmf_eax = 0x4f07;
514 vmf.vmf_ebx = 0x80; /* set display start */
517 err = vm86_intcall(0x10, &vmf);
518 return ((err != 0) || (vmf.vmf_ax != 0x4f));
521 /* map a generic video mode to a known mode */
523 vesa_map_gen_mode_num(int type, int color, int mode)
529 { M_TEXT_132x25, M_VESA_C132x25 },
530 { M_TEXT_132x43, M_VESA_C132x43 },
531 { M_TEXT_132x50, M_VESA_C132x50 },
532 { M_TEXT_132x60, M_VESA_C132x60 },
536 for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
537 if (mode_map[i].from == mode)
538 return mode_map[i].to;
544 vesa_translate_flags(u_int16_t vflags)
551 { V_MODECOLOR, V_INFO_COLOR, 0 },
552 { V_MODEGRAPHICS, V_INFO_GRAPHICS, 0 },
553 { V_MODELFB, V_INFO_LINEAR, 0 },
558 for (flags = 0, i = 0; i < sizeof(ftable)/sizeof(ftable[0]); ++i) {
559 flags |= (vflags & ftable[i].mask) ?
560 ftable[i].set : ftable[i].reset;
566 vesa_translate_mmodel(u_int8_t vmodel)
572 { V_MMTEXT, V_INFO_MM_TEXT },
573 { V_MMCGA, V_INFO_MM_CGA },
574 { V_MMHGC, V_INFO_MM_HGC },
575 { V_MMEGA, V_INFO_MM_PLANAR },
576 { V_MMPACKED, V_INFO_MM_PACKED },
577 { V_MMDIRCOLOR, V_INFO_MM_DIRECT },
581 for (i = 0; mtable[i].mmodel >= 0; ++i) {
582 if (mtable[i].vmodel == vmodel)
583 return mtable[i].mmodel;
585 return V_INFO_MM_OTHER;
589 *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, u_char *buf)
593 if (((p >> 16) == seg) && ((p & 0xffff) >= off))
594 return (void *)(buf + ((p & 0xffff) - off));
596 p = BIOS_SADDRTOLADDR(p);
597 return (void *)BIOS_PADDRTOVADDR(p);
604 static u_char buf[512];
605 struct vm86frame vmf;
606 struct vesa_mode vmode;
616 has_vesa_bios = FALSE;
617 vesa_adp_info = NULL;
619 vesa_vmode[0].vi_mode = EOT;
621 vmbuf = (u_char *)vm86_addpage(&vesa_vmcontext, 1, 0);
622 bzero(&vmf, sizeof(vmf)); /* paranoia */
623 bcopy("VBE2", vmbuf, 4); /* try for VBE2 data */
624 vmf.vmf_eax = 0x4f00;
625 vm86_getptr(&vesa_vmcontext, (vm_offset_t)vmbuf, &vmf.vmf_es, &vmf.vmf_di);
627 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
628 if ((err != 0) || (vmf.vmf_ax != 0x4f) || bcmp("VESA", vmbuf, 4))
630 bcopy(vmbuf, buf, sizeof(buf));
631 vesa_adp_info = (struct vesa_info *)buf;
633 printf("VESA: information block\n");
634 dump_buffer(buf, 64);
636 if (vesa_adp_info->v_flags & V_NONVGA)
638 if (vesa_adp_info->v_version < 0x0102) {
639 printf("VESA: VBE version %d.%d is not supported; "
640 "version 1.2 or later is required.\n",
641 ((vesa_adp_info->v_version & 0xf000) >> 12) * 10
642 + ((vesa_adp_info->v_version & 0x0f00) >> 8),
643 ((vesa_adp_info->v_version & 0x00f0) >> 4) * 10
644 + (vesa_adp_info->v_version & 0x000f));
648 /* fix string ptrs */
649 vesa_oemstr = (char *)vesa_fix_ptr(vesa_adp_info->v_oemstr,
650 vmf.vmf_es, vmf.vmf_di, buf);
651 if (vesa_adp_info->v_version >= 0x0200) {
653 (char *)vesa_fix_ptr(vesa_adp_info->v_venderstr,
654 vmf.vmf_es, vmf.vmf_di, buf);
656 (char *)vesa_fix_ptr(vesa_adp_info->v_prodstr,
657 vmf.vmf_es, vmf.vmf_di, buf);
659 (char *)vesa_fix_ptr(vesa_adp_info->v_revstr,
660 vmf.vmf_es, vmf.vmf_di, buf);
663 /* obtain video mode information */
664 vesa_vmodetab = (u_int16_t *)vesa_fix_ptr(vesa_adp_info->v_modetable,
665 vmf.vmf_es, vmf.vmf_di, buf);
666 if (vesa_vmodetab == NULL)
668 for (i = 0, modes = 0;
669 (i < (M_VESA_MODE_MAX - M_VESA_BASE + 1))
670 && (vesa_vmodetab[i] != 0xffff); ++i) {
671 if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode))
674 /* reject unsupported modes */
676 if ((vmode.v_modeattr & (V_MODESUPP | V_MODEOPTINFO
678 != (V_MODESUPP | V_MODEOPTINFO))
681 if ((vmode.v_modeattr & V_MODEOPTINFO) == 0) {
684 "Rejecting VESA %s mode: %d x %d x %d bpp attr = %x\n",
685 vmode.v_modeattr & V_MODEGRAPHICS ? "graphics" : "text",
686 vmode.v_width, vmode.v_height, vmode.v_bpp,
693 /* expand the array if necessary */
694 if (modes >= vesa_vmode_max) {
695 vesa_vmode_max += MODE_TABLE_DELTA;
696 p = malloc(sizeof(*vesa_vmode)*(vesa_vmode_max + 1),
699 printf("vesa_bios_init(): modes:%d, vesa_mode_max:%d\n",
700 modes, vesa_vmode_max);
703 bcopy(vesa_vmode, p, sizeof(*vesa_vmode)*modes);
704 free(vesa_vmode, M_DEVBUF);
710 printf("Found VESA %s mode: %d x %d x %d bpp\n",
711 vmode.v_modeattr & V_MODEGRAPHICS ? "graphics" : "text",
712 vmode.v_width, vmode.v_height, vmode.v_bpp);
714 /* copy some fields */
715 bzero(&vesa_vmode[modes], sizeof(vesa_vmode[modes]));
716 vesa_vmode[modes].vi_mode = vesa_vmodetab[i];
717 vesa_vmode[modes].vi_width = vmode.v_width;
718 vesa_vmode[modes].vi_height = vmode.v_height;
719 vesa_vmode[modes].vi_depth = vmode.v_bpp;
720 vesa_vmode[modes].vi_planes = vmode.v_planes;
721 vesa_vmode[modes].vi_cwidth = vmode.v_cwidth;
722 vesa_vmode[modes].vi_cheight = vmode.v_cheight;
723 vesa_vmode[modes].vi_window = (u_int)vmode.v_waseg << 4;
725 vesa_vmode[modes].vi_window_size = vmode.v_wsize*1024;
726 vesa_vmode[modes].vi_window_gran = vmode.v_wgran*1024;
727 if (vmode.v_modeattr & V_MODELFB)
728 vesa_vmode[modes].vi_buffer = vmode.v_lfb;
730 vesa_vmode[modes].vi_buffer = 0;
732 vesa_vmode[modes].vi_buffer_size
733 = vesa_adp_info->v_memsize*64*1024;
735 if (vmode.v_offscreen > vmode.v_lfb)
736 vesa_vmode[modes].vi_buffer_size
737 = vmode.v_offscreen + vmode.v_offscreensize*1024
740 vesa_vmode[modes].vi_buffer_size
741 = vmode.v_offscreen + vmode.v_offscreensize*1024
743 vesa_vmode[modes].vi_mem_model
744 = vesa_translate_mmodel(vmode.v_memmodel);
745 vesa_vmode[modes].vi_pixel_fields[0] = 0;
746 vesa_vmode[modes].vi_pixel_fields[1] = 0;
747 vesa_vmode[modes].vi_pixel_fields[2] = 0;
748 vesa_vmode[modes].vi_pixel_fields[3] = 0;
749 vesa_vmode[modes].vi_pixel_fsizes[0] = 0;
750 vesa_vmode[modes].vi_pixel_fsizes[1] = 0;
751 vesa_vmode[modes].vi_pixel_fsizes[2] = 0;
752 vesa_vmode[modes].vi_pixel_fsizes[3] = 0;
753 if (vesa_vmode[modes].vi_mem_model == V_INFO_MM_PACKED) {
754 vesa_vmode[modes].vi_pixel_size = (vmode.v_bpp + 7)/8;
755 } else if (vesa_vmode[modes].vi_mem_model == V_INFO_MM_DIRECT) {
756 vesa_vmode[modes].vi_pixel_size = (vmode.v_bpp + 7)/8;
757 vesa_vmode[modes].vi_pixel_fields[0]
758 = vmode.v_redfieldpos;
759 vesa_vmode[modes].vi_pixel_fields[1]
760 = vmode.v_greenfieldpos;
761 vesa_vmode[modes].vi_pixel_fields[2]
762 = vmode.v_bluefieldpos;
763 vesa_vmode[modes].vi_pixel_fields[3]
764 = vmode.v_resfieldpos;
765 vesa_vmode[modes].vi_pixel_fsizes[0]
766 = vmode.v_redmasksize;
767 vesa_vmode[modes].vi_pixel_fsizes[1]
768 = vmode.v_greenmasksize;
769 vesa_vmode[modes].vi_pixel_fsizes[2]
770 = vmode.v_bluemasksize;
771 vesa_vmode[modes].vi_pixel_fsizes[3]
772 = vmode.v_resmasksize;
774 vesa_vmode[modes].vi_pixel_size = 0;
777 vesa_vmode[modes].vi_flags
778 = vesa_translate_flags(vmode.v_modeattr) | V_INFO_VESA;
781 vesa_vmode[modes].vi_mode = EOT;
783 printf("VESA: %d mode(s) found\n", modes);
785 has_vesa_bios = (modes > 0);
786 return (has_vesa_bios ? 0 : 1);
790 vesa_clear_modes(video_info_t *info, int color)
792 while (info->vi_mode != EOT) {
793 if ((info->vi_flags & V_INFO_COLOR) != color)
800 vesa_map_buffer(u_int paddr, size_t size)
805 off = paddr - trunc_page(paddr);
806 vaddr = (vm_offset_t)pmap_mapdev(paddr - off, size + off);
808 printf("vesa_map_buffer: paddr:%x vaddr:%x size:%x off:%x\n",
809 paddr, vaddr, size, off);
811 return (vaddr + off);
815 vesa_unmap_buffer(vm_offset_t vaddr, size_t size)
818 printf("vesa_unmap_buffer: vaddr:%x size:%x\n", vaddr, size);
820 kmem_free(kernel_map, vaddr, size);
826 vesa_configure(int flags)
828 video_adapter_t *adp;
835 if (flags & VIO_PROBE_ONLY)
839 * If the VESA module has already been loaded, abort loading
840 * the module this time.
842 for (i = 0; (adp = vid_get_adapter(i)) != NULL; ++i) {
843 if (adp->va_flags & V_ADP_VESA)
845 if (adp->va_type == KD_VGA)
849 * The VGA adapter is not found. This is because either
850 * 1) the VGA driver has not been initialized, or 2) the VGA card
851 * is not present. If 1) is the case, we shall defer
852 * initialization for now and try again later.
855 vga_sub_configure = vesa_configure;
859 /* count number of registered adapters */
860 for (++i; vid_get_adapter(i) != NULL; ++i)
866 if (vesa_bios_init()) {
870 vesa_adp->va_flags |= V_ADP_VESA;
872 /* remove conflicting modes if we have more than one adapter */
874 vesa_clear_modes(vesa_vmode,
875 (vesa_adp->va_flags & V_ADP_COLOR) ?
879 if ((error = vesa_load_ioctl()) == 0) {
880 prevvidsw = vidsw[vesa_adp->va_index];
881 vidsw[vesa_adp->va_index] = &vesavidsw;
882 vesa_init_done = TRUE;
906 vesa_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
908 return (*prevvidsw->probe)(unit, adpp, arg, flags);
912 vesa_init(int unit, video_adapter_t *adp, int flags)
914 return (*prevvidsw->init)(unit, adp, flags);
918 vesa_get_info(video_adapter_t *adp, int mode, video_info_t *info)
922 if ((*prevvidsw->get_info)(adp, mode, info) == 0)
928 mode = vesa_map_gen_mode_num(vesa_adp->va_type,
929 vesa_adp->va_flags & V_ADP_COLOR, mode);
930 for (i = 0; vesa_vmode[i].vi_mode != EOT; ++i) {
931 if (vesa_vmode[i].vi_mode == NA)
933 if (vesa_vmode[i].vi_mode == mode) {
934 *info = vesa_vmode[i];
942 vesa_query_mode(video_adapter_t *adp, video_info_t *info)
946 if ((*prevvidsw->query_mode)(adp, info) == 0)
951 for (i = 0; vesa_vmode[i].vi_mode != EOT; ++i) {
952 if ((info->vi_width != 0)
953 && (info->vi_width != vesa_vmode[i].vi_width))
955 if ((info->vi_height != 0)
956 && (info->vi_height != vesa_vmode[i].vi_height))
958 if ((info->vi_cwidth != 0)
959 && (info->vi_cwidth != vesa_vmode[i].vi_cwidth))
961 if ((info->vi_cheight != 0)
962 && (info->vi_cheight != vesa_vmode[i].vi_cheight))
964 if ((info->vi_depth != 0)
965 && (info->vi_depth != vesa_vmode[i].vi_depth))
967 if ((info->vi_planes != 0)
968 && (info->vi_planes != vesa_vmode[i].vi_planes))
970 /* pixel format, memory model */
971 if ((info->vi_flags != 0)
972 && (info->vi_flags != vesa_vmode[i].vi_flags))
974 *info = vesa_vmode[i];
981 vesa_set_mode(video_adapter_t *adp, int mode)
987 return (*prevvidsw->set_mode)(adp, mode);
989 mode = vesa_map_gen_mode_num(adp->va_type,
990 adp->va_flags & V_ADP_COLOR, mode);
992 printf("VESA: set_mode(): %d(%x) -> %d(%x)\n",
993 adp->va_mode, adp->va_mode, mode, mode);
996 * If the current mode is a VESA mode and the new mode is not,
997 * restore the state of the adapter first by setting one of the
998 * standard VGA mode, so that non-standard, extended SVGA registers
999 * are set to the state compatible with the standard VGA modes.
1000 * Otherwise (*prevvidsw->set_mode)() may not be able to set up
1001 * the new mode correctly.
1003 if (VESA_MODE(adp->va_mode)) {
1004 if ((*prevvidsw->get_info)(adp, mode, &info) == 0) {
1005 int10_set_mode(adp->va_initial_bios_mode);
1006 if (adp->va_info.vi_flags & V_INFO_LINEAR)
1007 vesa_unmap_buffer(adp->va_buffer,
1008 vesa_adp_info->v_memsize*64*1024);
1010 * Once (*prevvidsw->get_info)() succeeded,
1011 * (*prevvidsw->set_mode)() below won't fail...
1016 /* we may not need to handle this mode after all... */
1017 if ((*prevvidsw->set_mode)(adp, mode) == 0)
1020 /* is the new mode supported? */
1021 if (vesa_get_info(adp, mode, &info))
1023 /* assert(VESA_MODE(mode)); */
1026 printf("VESA: about to set a VESA mode...\n");
1028 /* don't use the linear frame buffer for text modes. XXX */
1029 if (!(info.vi_flags & V_INFO_GRAPHICS))
1030 info.vi_flags &= ~V_INFO_LINEAR;
1032 if (vesa_bios_set_mode(mode | ((info.vi_flags & V_INFO_LINEAR) ? 0x4000 : 0)))
1035 if (adp->va_info.vi_flags & V_INFO_LINEAR)
1036 vesa_unmap_buffer(adp->va_buffer,
1037 vesa_adp_info->v_memsize*64*1024);
1040 printf("VESA: mode set!\n");
1042 vesa_adp->va_mode = mode;
1043 vesa_adp->va_flags &= ~V_ADP_COLOR;
1044 vesa_adp->va_flags |=
1045 (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
1046 vesa_adp->va_crtc_addr =
1047 (vesa_adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
1048 if (info.vi_flags & V_INFO_LINEAR) {
1050 printf("VESA: setting up LFB\n");
1052 vesa_adp->va_buffer =
1053 vesa_map_buffer(info.vi_buffer,
1054 vesa_adp_info->v_memsize*64*1024);
1055 vesa_adp->va_buffer_size = info.vi_buffer_size;
1056 vesa_adp->va_window = vesa_adp->va_buffer;
1057 vesa_adp->va_window_size = info.vi_buffer_size/info.vi_planes;
1058 vesa_adp->va_window_gran = info.vi_buffer_size/info.vi_planes;
1060 vesa_adp->va_buffer = 0;
1061 vesa_adp->va_buffer_size = info.vi_buffer_size;
1062 vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
1063 vesa_adp->va_window_size = info.vi_window_size;
1064 vesa_adp->va_window_gran = info.vi_window_gran;
1066 vesa_adp->va_window_orig = 0;
1067 len = vesa_bios_get_line_length();
1069 vesa_adp->va_line_width = len;
1070 } else if (info.vi_flags & V_INFO_GRAPHICS) {
1071 switch (info.vi_depth/info.vi_planes) {
1073 vesa_adp->va_line_width = info.vi_width/8;
1076 vesa_adp->va_line_width = info.vi_width/4;
1079 vesa_adp->va_line_width = info.vi_width/2;
1082 default: /* shouldn't happen */
1083 vesa_adp->va_line_width = info.vi_width;
1087 vesa_adp->va_line_width = info.vi_width;
1089 vesa_adp->va_disp_start.x = 0;
1090 vesa_adp->va_disp_start.y = 0;
1092 printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d\n",
1093 info.vi_width, len, vesa_adp->va_line_width);
1095 bcopy(&info, &vesa_adp->va_info, sizeof(vesa_adp->va_info));
1097 /* move hardware cursor out of the way */
1098 (*vidsw[vesa_adp->va_index]->set_hw_cursor)(vesa_adp, -1, -1);
1104 vesa_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
1107 return (*prevvidsw->save_font)(adp, page, fontsize, data, ch, count);
1111 vesa_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
1114 return (*prevvidsw->load_font)(adp, page, fontsize, data, ch, count);
1118 vesa_show_font(video_adapter_t *adp, int page)
1120 return (*prevvidsw->show_font)(adp, page);
1124 vesa_save_palette(video_adapter_t *adp, u_char *palette)
1129 if ((adp == vesa_adp) && (vesa_adp_info->v_flags & V_DAC8)
1130 && VESA_MODE(adp->va_mode)) {
1131 bits = vesa_bios_get_dac();
1132 error = vesa_bios_save_palette(0, 256, palette, bits);
1139 return (*prevvidsw->save_palette)(adp, palette);
1143 vesa_load_palette(video_adapter_t *adp, u_char *palette)
1149 if ((adp == vesa_adp) && (vesa_adp_info->v_flags & V_DAC8)
1150 && VESA_MODE(adp->va_mode) && ((bits = vesa_bios_set_dac(8)) > 6)) {
1151 error = vesa_bios_load_palette(0, 256, palette, bits);
1154 if (vesa_bios_set_dac(6) != 6)
1159 return (*prevvidsw->load_palette)(adp, palette);
1163 vesa_set_border(video_adapter_t *adp, int color)
1165 return (*prevvidsw->set_border)(adp, color);
1169 vesa_save_state(video_adapter_t *adp, void *p, size_t size)
1171 if (adp != vesa_adp)
1172 return (*prevvidsw->save_state)(adp, p, size);
1174 if (vesa_state_buf_size == 0)
1175 vesa_state_buf_size = vesa_bios_state_buf_size();
1177 return (sizeof(int) + vesa_state_buf_size);
1178 else if (size < (sizeof(int) + vesa_state_buf_size))
1181 ((adp_state_t *)p)->sig = V_STATE_SIG;
1182 bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
1183 return vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs,
1184 vesa_state_buf_size);
1188 vesa_load_state(video_adapter_t *adp, void *p)
1190 if ((adp != vesa_adp) || (((adp_state_t *)p)->sig != V_STATE_SIG))
1191 return (*prevvidsw->load_state)(adp, p);
1193 return vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs,
1194 vesa_state_buf_size);
1199 vesa_get_origin(video_adapter_t *adp, off_t *offset)
1201 struct vm86frame vmf;
1204 bzero(&vmf, sizeof(vmf));
1205 vmf.vmf_eax = 0x4f05;
1206 vmf.vmf_ebx = 0x10; /* WINDOW_A, XXX */
1207 err = vm86_intcall(0x10, &vmf);
1208 if ((err != 0) || (vmf.vmf_ax != 0x4f))
1210 *offset = vmf.vmf_dx*adp->va_window_gran;
1216 vesa_set_origin(video_adapter_t *adp, off_t offset)
1218 struct vm86frame vmf;
1222 * This function should return as quickly as possible to
1223 * maintain good performance of the system. For this reason,
1224 * error checking is kept minimal and let the VESA BIOS to
1227 if (adp != vesa_adp)
1228 return (*prevvidsw->set_win_org)(adp, offset);
1230 /* if this is a linear frame buffer, do nothing */
1231 if (adp->va_info.vi_flags & V_INFO_LINEAR)
1234 if (adp->va_window_gran == 0)
1237 bzero(&vmf, sizeof(vmf));
1238 vmf.vmf_eax = 0x4f05;
1239 vmf.vmf_ebx = 0; /* WINDOW_A, XXX */
1240 vmf.vmf_edx = offset/adp->va_window_gran;
1241 err = vm86_intcall(0x10, &vmf);
1242 if ((err != 0) || (vmf.vmf_ax != 0x4f))
1244 bzero(&vmf, sizeof(vmf));
1245 vmf.vmf_eax = 0x4f05;
1246 vmf.vmf_ebx = 1; /* WINDOW_B, XXX */
1247 vmf.vmf_edx = offset/adp->va_window_gran;
1248 err = vm86_intcall(0x10, &vmf);
1249 adp->va_window_orig = (offset/adp->va_window_gran)*adp->va_window_gran;
1254 vesa_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
1256 return (*prevvidsw->read_hw_cursor)(adp, col, row);
1260 vesa_set_hw_cursor(video_adapter_t *adp, int col, int row)
1262 return (*prevvidsw->set_hw_cursor)(adp, col, row);
1266 vesa_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
1267 int celsize, int blink)
1269 return (*prevvidsw->set_hw_cursor_shape)(adp, base, height, celsize,
1274 vesa_blank_display(video_adapter_t *adp, int mode)
1276 /* XXX: use VESA DPMS */
1277 return (*prevvidsw->blank_display)(adp, mode);
1281 vesa_mmap(video_adapter_t *adp, vm_offset_t offset, int prot)
1284 printf("vesa_mmap(): window:0x%x, buffer:0x%x, offset:0x%x\n",
1285 adp->va_info.vi_window, adp->va_info.vi_buffer, offset);
1288 if ((adp == vesa_adp) && (adp->va_info.vi_flags & V_INFO_LINEAR)) {
1289 /* va_window_size == va_buffer_size/vi_planes */
1290 /* XXX: is this correct? */
1291 if (offset > adp->va_window_size - PAGE_SIZE)
1294 return i386_btop(adp->va_info.vi_buffer + offset);
1296 #ifdef __alpha__ /* XXX */
1297 return alpha_btop(adp->va_info.vi_buffer + offset);
1300 return (*prevvidsw->mmap)(adp, offset, prot);
1305 vesa_clear(video_adapter_t *adp)
1307 return (*prevvidsw->clear)(adp);
1311 vesa_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
1313 return (*prevvidsw->fill_rect)(adp, val, x, y, cx, cy);
1317 vesa_bitblt(video_adapter_t *adp,...)
1324 get_palette(video_adapter_t *adp, int base, int count,
1325 u_char *red, u_char *green, u_char *blue, u_char *trans)
1333 if ((base < 0) || (base >= 256) || (base + count > 256))
1335 if (!(vesa_adp_info->v_flags & V_DAC8) || !VESA_MODE(adp->va_mode))
1338 bits = vesa_bios_get_dac();
1342 r = malloc(count*3, M_DEVBUF, M_WAITOK);
1345 error = vesa_bios_save_palette2(base, count, r, g, b, bits);
1347 copyout(r, red, count);
1348 copyout(g, green, count);
1349 copyout(b, blue, count);
1350 if (trans != NULL) {
1352 copyout(r, trans, count);
1357 /* if error && bits != 6 at this point, we are in in trouble... XXX */
1362 set_palette(video_adapter_t *adp, int base, int count,
1363 u_char *red, u_char *green, u_char *blue, u_char *trans)
1373 if ((base < 0) || (base >= 256) || (base + count > 256))
1375 if (!(vesa_adp_info->v_flags & V_DAC8) || !VESA_MODE(adp->va_mode)
1376 || ((bits = vesa_bios_set_dac(8)) <= 6))
1379 r = malloc(count*3, M_DEVBUF, M_WAITOK);
1382 copyin(red, r, count);
1383 copyin(green, g, count);
1384 copyin(blue, b, count);
1386 error = vesa_bios_load_palette2(base, count, r, g, b, bits);
1391 /* if the following call fails, we are in trouble... XXX */
1392 vesa_bios_set_dac(6);
1398 vesa_ioctl(video_adapter_t *adp, u_long cmd, caddr_t arg)
1402 if (adp != vesa_adp)
1403 return (*prevvidsw->ioctl)(adp, cmd, arg);
1406 case FBIO_SETWINORG: /* set frame buffer window origin */
1407 if (!VESA_MODE(adp->va_mode))
1408 return (*prevvidsw->ioctl)(adp, cmd, arg);
1409 return (vesa_set_origin(adp, *(off_t *)arg) ? ENODEV : 0);
1411 case FBIO_SETDISPSTART: /* set display start address */
1412 if (!VESA_MODE(adp->va_mode))
1413 return (*prevvidsw->ioctl)(adp, cmd, arg);
1414 if (vesa_bios_set_start(((video_display_start_t *)arg)->x,
1415 ((video_display_start_t *)arg)->y))
1417 adp->va_disp_start.x = ((video_display_start_t *)arg)->x;
1418 adp->va_disp_start.y = ((video_display_start_t *)arg)->y;
1421 case FBIO_SETLINEWIDTH: /* set line length in pixel */
1422 if (!VESA_MODE(adp->va_mode))
1423 return (*prevvidsw->ioctl)(adp, cmd, arg);
1424 if (vesa_bios_set_line_length(*(u_int *)arg, &bytes, NULL))
1426 adp->va_line_width = bytes;
1428 printf("new line width:%d\n", adp->va_line_width);
1432 case FBIO_GETPALETTE: /* get color palette */
1433 if (get_palette(adp, ((video_color_palette_t *)arg)->index,
1434 ((video_color_palette_t *)arg)->count,
1435 ((video_color_palette_t *)arg)->red,
1436 ((video_color_palette_t *)arg)->green,
1437 ((video_color_palette_t *)arg)->blue,
1438 ((video_color_palette_t *)arg)->transparent))
1439 return (*prevvidsw->ioctl)(adp, cmd, arg);
1443 case FBIO_SETPALETTE: /* set color palette */
1444 if (set_palette(adp, ((video_color_palette_t *)arg)->index,
1445 ((video_color_palette_t *)arg)->count,
1446 ((video_color_palette_t *)arg)->red,
1447 ((video_color_palette_t *)arg)->green,
1448 ((video_color_palette_t *)arg)->blue,
1449 ((video_color_palette_t *)arg)->transparent))
1450 return (*prevvidsw->ioctl)(adp, cmd, arg);
1453 case FBIOGETCMAP: /* get color palette */
1454 if (get_palette(adp, ((struct fbcmap *)arg)->index,
1455 ((struct fbcmap *)arg)->count,
1456 ((struct fbcmap *)arg)->red,
1457 ((struct fbcmap *)arg)->green,
1458 ((struct fbcmap *)arg)->blue, NULL))
1459 return (*prevvidsw->ioctl)(adp, cmd, arg);
1462 case FBIOPUTCMAP: /* set color palette */
1463 if (set_palette(adp, ((struct fbcmap *)arg)->index,
1464 ((struct fbcmap *)arg)->count,
1465 ((struct fbcmap *)arg)->red,
1466 ((struct fbcmap *)arg)->green,
1467 ((struct fbcmap *)arg)->blue, NULL))
1468 return (*prevvidsw->ioctl)(adp, cmd, arg);
1472 return (*prevvidsw->ioctl)(adp, cmd, arg);
1477 vesa_diag(video_adapter_t *adp, int level)
1481 /* call the previous handler first */
1482 error = (*prevvidsw->diag)(adp, level);
1486 if (adp != vesa_adp)
1496 vesa_bios_info(int level)
1499 struct vesa_mode vmode;
1503 /* general adapter information */
1504 printf("VESA: v%d.%d, %dk memory, flags:0x%x, mode table:%p (%x)\n",
1505 ((vesa_adp_info->v_version & 0xf000) >> 12) * 10
1506 + ((vesa_adp_info->v_version & 0x0f00) >> 8),
1507 ((vesa_adp_info->v_version & 0x00f0) >> 4) * 10
1508 + (vesa_adp_info->v_version & 0x000f),
1509 vesa_adp_info->v_memsize * 64, vesa_adp_info->v_flags,
1510 vesa_vmodetab, vesa_adp_info->v_modetable);
1512 if (vesa_oemstr != NULL)
1513 printf("VESA: %s\n", vesa_oemstr);
1518 if (vesa_adp_info->v_version >= 0x0200) {
1519 /* vender name, product name, product revision */
1520 printf("VESA: %s %s %s\n",
1521 (vesa_venderstr != NULL) ? vesa_venderstr : "unknown",
1522 (vesa_prodstr != NULL) ? vesa_prodstr : "unknown",
1523 (vesa_revstr != NULL) ? vesa_revstr : "?");
1527 /* mode information */
1529 (i < (M_VESA_MODE_MAX - M_VESA_BASE + 1))
1530 && (vesa_vmodetab[i] != 0xffff); ++i) {
1531 if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode))
1534 /* print something for diagnostic purpose */
1535 printf("VESA: mode:0x%03x, flags:0x%04x",
1536 vesa_vmodetab[i], vmode.v_modeattr);
1537 if (vmode.v_modeattr & V_MODEOPTINFO) {
1538 if (vmode.v_modeattr & V_MODEGRAPHICS) {
1539 printf(", G %dx%dx%d %d, ",
1540 vmode.v_width, vmode.v_height,
1541 vmode.v_bpp, vmode.v_planes);
1543 printf(", T %dx%d, ",
1544 vmode.v_width, vmode.v_height);
1546 printf("font:%dx%d, ",
1547 vmode.v_cwidth, vmode.v_cheight);
1548 printf("pages:%d, mem:%d",
1549 vmode.v_ipages + 1, vmode.v_memmodel);
1551 if (vmode.v_modeattr & V_MODELFB) {
1552 printf("\nVESA: LFB:0x%x, off:0x%x, off_size:0x%x",
1553 vmode.v_lfb, vmode.v_offscreen,
1554 vmode.v_offscreensize*1024);
1557 printf("VESA: window A:0x%x (%x), window B:0x%x (%x), ",
1558 vmode.v_waseg, vmode.v_waattr,
1559 vmode.v_wbseg, vmode.v_wbattr);
1560 printf("size:%dk, gran:%dk\n",
1561 vmode.v_wsize, vmode.v_wgran);
1563 #endif /* VESA_DEBUG > 1 */
1568 /* module loading */
1579 /* locate a VGA adapter */
1582 error = vesa_configure(0);
1586 vesa_bios_info(bootverbose);
1594 u_char palette[256*3];
1599 /* if the adapter is currently in a VESA mode, don't unload */
1600 if ((vesa_adp != NULL) && VESA_MODE(vesa_adp->va_mode))
1603 * FIXME: if there is at least one vty which is in a VESA mode,
1604 * we shouldn't be unloading! XXX
1608 if ((error = vesa_unload_ioctl()) == 0) {
1609 if (vesa_adp != NULL) {
1610 if (vesa_adp_info->v_flags & V_DAC8) {
1611 bits = vesa_bios_get_dac();
1613 vesa_bios_save_palette(0, 256,
1615 vesa_bios_set_dac(6);
1616 vesa_bios_load_palette(0, 256,
1620 vesa_adp->va_flags &= ~V_ADP_VESA;
1621 vidsw[vesa_adp->va_index] = prevvidsw;
1630 vesa_mod_event(module_t mod, int type, void *data)
1636 return vesa_unload();
1643 static moduledata_t vesa_mod = {
1649 DECLARE_MODULE(vesa, vesa_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
1651 #endif /* VGA_NO_MODE_CHANGE */