vesa.c (197022) | vesa.c (197025) |
---|---|
1/*- 2 * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 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. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 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. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/fb/vesa.c 197022 2009-09-09 07:45:08Z delphij $"); | 28__FBSDID("$FreeBSD: head/sys/dev/fb/vesa.c 197025 2009-09-09 09:50:31Z delphij $"); |
29 30#include "opt_vga.h" 31#include "opt_vesa.h" 32 33#ifndef VGA_NO_MODE_CHANGE 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/malloc.h> 40#include <sys/fbio.h> 41 42#include <vm/vm.h> 43#include <vm/vm_extern.h> 44#include <vm/vm_kern.h> 45#include <vm/vm_param.h> 46#include <vm/pmap.h> 47 | 29 30#include "opt_vga.h" 31#include "opt_vesa.h" 32 33#ifndef VGA_NO_MODE_CHANGE 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/malloc.h> 40#include <sys/fbio.h> 41 42#include <vm/vm.h> 43#include <vm/vm_extern.h> 44#include <vm/vm_kern.h> 45#include <vm/vm_param.h> 46#include <vm/pmap.h> 47 |
48#include <machine/md_var.h> 49#include <machine/vm86.h> 50#include <machine/pc/bios.h> 51#include <machine/pc/vesa.h> | 48#include <dev/fb/vesa.h> |
52 53#include <dev/fb/fbreg.h> 54#include <dev/fb/vgareg.h> 55 | 49 50#include <dev/fb/fbreg.h> 51#include <dev/fb/vgareg.h> 52 |
56#ifndef __i386__ | |
57#include <isa/isareg.h> | 53#include <isa/isareg.h> |
58#else 59#include <i386/isa/isa.h> 60#endif | 54#include <machine/cpufunc.h> |
61 | 55 |
56#include <contrib/x86emu/x86emu.h> 57#include <contrib/x86emu/x86emu_regs.h> 58 |
|
62#define VESA_VIA_CLE266 "VIA CLE266\r\n" 63 64#ifndef VESA_DEBUG 65#define VESA_DEBUG 0 66#endif 67 68/* VESA video adapter state buffer stub */ 69struct adp_state { 70 int sig; 71#define V_STATE_SIG 0x61736576 72 u_char regs[1]; 73}; 74typedef struct adp_state adp_state_t; 75 76/* VESA video adapter */ 77static video_adapter_t *vesa_adp = NULL; 78static int vesa_state_buf_size = 0; | 59#define VESA_VIA_CLE266 "VIA CLE266\r\n" 60 61#ifndef VESA_DEBUG 62#define VESA_DEBUG 0 63#endif 64 65/* VESA video adapter state buffer stub */ 66struct adp_state { 67 int sig; 68#define V_STATE_SIG 0x61736576 69 u_char regs[1]; 70}; 71typedef struct adp_state adp_state_t; 72 73/* VESA video adapter */ 74static video_adapter_t *vesa_adp = NULL; 75static int vesa_state_buf_size = 0; |
79#define VESA_VM86_BUFSIZE (3 * PAGE_SIZE) 80static void *vesa_vm86_buf; | 76#define VESA_X86EMU_BUFSIZE (3 * PAGE_SIZE) |
81 82/* VESA functions */ 83#if 0 84static int vesa_nop(void); 85#endif 86static int vesa_error(void); 87static vi_probe_t vesa_probe; 88static vi_init_t vesa_init; --- 15 unchanged lines hidden (view full) --- 104static vi_blank_display_t vesa_blank_display; 105static vi_mmap_t vesa_mmap; 106static vi_ioctl_t vesa_ioctl; 107static vi_clear_t vesa_clear; 108static vi_fill_rect_t vesa_fill_rect; 109static vi_bitblt_t vesa_bitblt; 110static vi_diag_t vesa_diag; 111static int vesa_bios_info(int level); | 77 78/* VESA functions */ 79#if 0 80static int vesa_nop(void); 81#endif 82static int vesa_error(void); 83static vi_probe_t vesa_probe; 84static vi_init_t vesa_init; --- 15 unchanged lines hidden (view full) --- 100static vi_blank_display_t vesa_blank_display; 101static vi_mmap_t vesa_mmap; 102static vi_ioctl_t vesa_ioctl; 103static vi_clear_t vesa_clear; 104static vi_fill_rect_t vesa_fill_rect; 105static vi_bitblt_t vesa_bitblt; 106static vi_diag_t vesa_diag; 107static int vesa_bios_info(int level); |
112static struct vm86context vesa_vmcontext; | |
113 | 108 |
109static struct x86emu vesa_emu; 110 |
|
114static video_switch_t vesavidsw = { 115 vesa_probe, 116 vesa_init, 117 vesa_get_info, 118 vesa_query_mode, 119 vesa_set_mode, 120 vesa_save_font, 121 vesa_load_font, --- 73 unchanged lines hidden (view full) --- 195static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines); 196#if 0 197static int vesa_bios_get_start(int *x, int *y); 198#endif 199static int vesa_bios_set_start(int x, int y); 200static int vesa_map_gen_mode_num(int type, int color, int mode); 201static int vesa_translate_flags(u_int16_t vflags); 202static int vesa_translate_mmodel(u_int8_t vmodel); | 111static video_switch_t vesavidsw = { 112 vesa_probe, 113 vesa_init, 114 vesa_get_info, 115 vesa_query_mode, 116 vesa_set_mode, 117 vesa_save_font, 118 vesa_load_font, --- 73 unchanged lines hidden (view full) --- 192static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines); 193#if 0 194static int vesa_bios_get_start(int *x, int *y); 195#endif 196static int vesa_bios_set_start(int x, int y); 197static int vesa_map_gen_mode_num(int type, int color, int mode); 198static int vesa_translate_flags(u_int16_t vflags); 199static int vesa_translate_mmodel(u_int8_t vmodel); |
203static void *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, 204 u_char *buf); | |
205static int vesa_bios_init(void); 206static void vesa_clear_modes(video_info_t *info, int color); 207static vm_offset_t vesa_map_buffer(u_int paddr, size_t size); 208static void vesa_unmap_buffer(vm_offset_t vaddr, size_t size); 209 210#if 0 211static int vesa_get_origin(video_adapter_t *adp, off_t *offset); 212#endif 213 | 200static int vesa_bios_init(void); 201static void vesa_clear_modes(video_info_t *info, int color); 202static vm_offset_t vesa_map_buffer(u_int paddr, size_t size); 203static void vesa_unmap_buffer(vm_offset_t vaddr, size_t size); 204 205#if 0 206static int vesa_get_origin(video_adapter_t *adp, off_t *offset); 207#endif 208 |
209#define SEG_ADDR(x) (((x) >> 4) & 0x00F000) 210#define SEG_OFF(x) ((x) & 0x0FFFF) 211 212#if _BYTE_ORDER == _LITTLE_ENDIAN 213#define B_O16(x) (x) 214#define B_O32(x) (x) 215#else 216#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) 217#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ 218 | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) 219#endif 220 221#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) 222#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff)) 223 224#define REALOFF(x) (x*4096) 225 226static unsigned char *emumem = NULL; 227 228static uint8_t 229vm86_emu_inb(struct x86emu *emu, uint16_t port) 230{ 231 if (port == 0xb2) /* APM scratch register */ 232 return 0; 233 if (port >= 0x80 && port < 0x88) /* POST status register */ 234 return 0; 235 return inb(port); 236} 237 238static uint16_t 239vm86_emu_inw(struct x86emu *emu, uint16_t port) 240{ 241 if (port >= 0x80 && port < 0x88) /* POST status register */ 242 return 0; 243 return inw(port); 244} 245 246static uint32_t 247vm86_emu_inl(struct x86emu *emu, uint16_t port) 248{ 249 if (port >= 0x80 && port < 0x88) /* POST status register */ 250 return 0; 251 return inl(port); 252} 253 |
|
214static void | 254static void |
255vm86_emu_outb(struct x86emu *emu, uint16_t port, uint8_t val) 256{ 257 if (port == 0xb2) /* APM scratch register */ 258 return; 259 if (port >= 0x80 && port < 0x88) /* POST status register */ 260 return; 261 outb(port, val); 262} 263 264static void 265vm86_emu_outw(struct x86emu *emu, uint16_t port, uint16_t val) 266{ 267 if (port >= 0x80 && port < 0x88) /* POST status register */ 268 return; 269 outw(port, val); 270} 271 272static void 273vm86_emu_outl(struct x86emu *emu, uint16_t port, uint32_t val) 274{ 275 if (port >= 0x80 && port < 0x88) /* POST status register */ 276 return; 277 outl(port, val); 278} 279 280static void |
|
215dump_buffer(u_char *buf, size_t len) 216{ 217 int i; 218 219 for(i = 0; i < len;) { 220 printf("%02x ", buf[i]); 221 if ((++i % 16) == 0) 222 printf("\n"); 223 } 224} 225 226/* INT 10 BIOS calls */ 227static int 228int10_set_mode(int mode) 229{ | 281dump_buffer(u_char *buf, size_t len) 282{ 283 int i; 284 285 for(i = 0; i < len;) { 286 printf("%02x ", buf[i]); 287 if ((++i % 16) == 0) 288 printf("\n"); 289 } 290} 291 292/* INT 10 BIOS calls */ 293static int 294int10_set_mode(int mode) 295{ |
230 struct vm86frame vmf; | 296 vesa_emu.x86.R_EAX = 0x0000 | mode; 297 x86emu_exec_intr(&vesa_emu, 0x10); |
231 | 298 |
232 bzero(&vmf, sizeof(vmf)); 233 vmf.vmf_eax = 0x0000 | mode; 234 vm86_intcall(0x10, &vmf); | |
235 return 0; 236} 237 238/* VESA BIOS calls */ 239static int 240vesa_bios_get_mode(int mode, struct vesa_mode *vmode) 241{ | 299 return 0; 300} 301 302/* VESA BIOS calls */ 303static int 304vesa_bios_get_mode(int mode, struct vesa_mode *vmode) 305{ |
242 struct vm86frame vmf; | |
243 u_char *buf; | 306 u_char *buf; |
244 int err; | |
245 | 307 |
246 bzero(&vmf, sizeof(vmf)); 247 vmf.vmf_eax = 0x4f01; 248 vmf.vmf_ecx = mode; 249 buf = vesa_vm86_buf; 250 vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_di); | 308 vesa_emu.x86.R_EAX = 0x4f01; 309 vesa_emu.x86.R_ECX = mode; |
251 | 310 |
252 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 253 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 311 buf = (emumem + REALOFF(3)); 312 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(3)); 313 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(3)); 314 315 x86emu_exec_intr(&vesa_emu, 0x10); 316 317 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
254 return 1; | 318 return 1; |
319 |
|
255 bcopy(buf, vmode, sizeof(*vmode)); | 320 bcopy(buf, vmode, sizeof(*vmode)); |
321 |
|
256 return 0; 257} 258 259static int 260vesa_bios_set_mode(int mode) 261{ | 322 return 0; 323} 324 325static int 326vesa_bios_set_mode(int mode) 327{ |
262 struct vm86frame vmf; 263 int err; | 328 vesa_emu.x86.R_EAX = 0x4f02; 329 vesa_emu.x86.R_EBX = mode; |
264 | 330 |
265 bzero(&vmf, sizeof(vmf)); 266 vmf.vmf_eax = 0x4f02; 267 vmf.vmf_ebx = mode; 268 err = vm86_intcall(0x10, &vmf); 269 return ((err != 0) || (vmf.vmf_ax != 0x4f)); | 331 x86emu_exec_intr(&vesa_emu, 0x10); 332 333 return ((vesa_emu.x86.R_AX & 0xff) != 0x4f); |
270} 271 272static int 273vesa_bios_get_dac(void) 274{ | 334} 335 336static int 337vesa_bios_get_dac(void) 338{ |
275 struct vm86frame vmf; 276 int err; | 339 vesa_emu.x86.R_EAX = 0x4f08; 340 vesa_emu.x86.R_EBX = 1; |
277 | 341 |
278 bzero(&vmf, sizeof(vmf)); 279 vmf.vmf_eax = 0x4f08; 280 vmf.vmf_ebx = 1; /* get DAC width */ 281 err = vm86_intcall(0x10, &vmf); 282 if ((err != 0) || (vmf.vmf_ax != 0x4f)) 283 return 6; /* XXX */ 284 return ((vmf.vmf_ebx >> 8) & 0x00ff); | 342 x86emu_exec_intr(&vesa_emu, 0x10); 343 344 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) 345 return 6; 346 347 return ((vesa_emu.x86.R_EBX >> 8) & 0x00ff); |
285} 286 287static int 288vesa_bios_set_dac(int bits) 289{ | 348} 349 350static int 351vesa_bios_set_dac(int bits) 352{ |
290 struct vm86frame vmf; 291 int err; | 353 vesa_emu.x86.R_EAX = 0x4f08; 354 vesa_emu.x86.R_EBX = (bits << 8); |
292 | 355 |
293 bzero(&vmf, sizeof(vmf)); 294 vmf.vmf_eax = 0x4f08; 295 vmf.vmf_ebx = (bits << 8); 296 err = vm86_intcall(0x10, &vmf); 297 if ((err != 0) || (vmf.vmf_ax != 0x4f)) 298 return 6; /* XXX */ 299 return ((vmf.vmf_ebx >> 8) & 0x00ff); | 356 x86emu_exec_intr(&vesa_emu, 0x10); 357 358 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) 359 return 6; 360 361 return ((vesa_emu.x86.R_EBX >> 8) & 0x00ff); |
300} 301 302static int 303vesa_bios_save_palette(int start, int colors, u_char *palette, int bits) 304{ | 362} 363 364static int 365vesa_bios_save_palette(int start, int colors, u_char *palette, int bits) 366{ |
305 struct vm86frame vmf; | |
306 u_char *p; | 367 u_char *p; |
307 int err; | |
308 int i; 309 | 368 int i; 369 |
310 bzero(&vmf, sizeof(vmf)); 311 vmf.vmf_eax = 0x4f09; 312 vmf.vmf_ebx = 1; /* get primary palette data */ 313 vmf.vmf_ecx = colors; 314 vmf.vmf_edx = start; 315 p = vesa_vm86_buf; 316 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di); | 370 vesa_emu.x86.R_EAX = 0x4f09; 371 vesa_emu.x86.R_EBX = 1; 372 vesa_emu.x86.R_ECX = colors; 373 vesa_emu.x86.R_EDX = start; |
317 | 374 |
318 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 319 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 375 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 376 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 377 378 p = emumem + REALOFF(2); 379 380 x86emu_exec_intr(&vesa_emu, 0x10); 381 382 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
320 return 1; 321 322 bits = 8 - bits; 323 for (i = 0; i < colors; ++i) { 324 palette[i*3] = p[i*4 + 2] << bits; 325 palette[i*3 + 1] = p[i*4 + 1] << bits; 326 palette[i*3 + 2] = p[i*4] << bits; 327 } 328 return 0; 329} 330 331static int 332vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g, u_char *b, 333 int bits) 334{ | 383 return 1; 384 385 bits = 8 - bits; 386 for (i = 0; i < colors; ++i) { 387 palette[i*3] = p[i*4 + 2] << bits; 388 palette[i*3 + 1] = p[i*4 + 1] << bits; 389 palette[i*3 + 2] = p[i*4] << bits; 390 } 391 return 0; 392} 393 394static int 395vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g, u_char *b, 396 int bits) 397{ |
335 struct vm86frame vmf; | |
336 u_char *p; | 398 u_char *p; |
337 int err; | |
338 int i; 339 | 399 int i; 400 |
340 bzero(&vmf, sizeof(vmf)); 341 vmf.vmf_eax = 0x4f09; 342 vmf.vmf_ebx = 1; /* get primary palette data */ 343 vmf.vmf_ecx = colors; 344 vmf.vmf_edx = start; 345 p = vesa_vm86_buf; 346 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di); | 401 vesa_emu.x86.R_EAX = 0x4f09; 402 vesa_emu.x86.R_EBX = 1; 403 vesa_emu.x86.R_ECX = colors; 404 vesa_emu.x86.R_EDX = start; |
347 | 405 |
348 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 349 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 406 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 407 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 408 409 p = emumem + REALOFF(2); 410 411 x86emu_exec_intr(&vesa_emu, 0x10); 412 413 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
350 return 1; 351 352 bits = 8 - bits; 353 for (i = 0; i < colors; ++i) { 354 r[i] = p[i*4 + 2] << bits; 355 g[i] = p[i*4 + 1] << bits; 356 b[i] = p[i*4] << bits; 357 } 358 return 0; 359} 360 361static int 362vesa_bios_load_palette(int start, int colors, u_char *palette, int bits) 363{ | 414 return 1; 415 416 bits = 8 - bits; 417 for (i = 0; i < colors; ++i) { 418 r[i] = p[i*4 + 2] << bits; 419 g[i] = p[i*4 + 1] << bits; 420 b[i] = p[i*4] << bits; 421 } 422 return 0; 423} 424 425static int 426vesa_bios_load_palette(int start, int colors, u_char *palette, int bits) 427{ |
364 struct vm86frame vmf; | |
365 u_char *p; | 428 u_char *p; |
366 int err; | |
367 int i; 368 | 429 int i; 430 |
369 p = vesa_vm86_buf; | 431 p = (emumem + REALOFF(2)); 432 |
370 bits = 8 - bits; 371 for (i = 0; i < colors; ++i) { 372 p[i*4] = palette[i*3 + 2] >> bits; 373 p[i*4 + 1] = palette[i*3 + 1] >> bits; 374 p[i*4 + 2] = palette[i*3] >> bits; 375 p[i*4 + 3] = 0; 376 } 377 | 433 bits = 8 - bits; 434 for (i = 0; i < colors; ++i) { 435 p[i*4] = palette[i*3 + 2] >> bits; 436 p[i*4 + 1] = palette[i*3 + 1] >> bits; 437 p[i*4 + 2] = palette[i*3] >> bits; 438 p[i*4 + 3] = 0; 439 } 440 |
378 bzero(&vmf, sizeof(vmf)); 379 vmf.vmf_eax = 0x4f09; 380 vmf.vmf_ebx = 0; /* set primary palette data */ 381 vmf.vmf_ecx = colors; 382 vmf.vmf_edx = start; 383 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di); | 441 vesa_emu.x86.R_EAX = 0x4f09; 442 vesa_emu.x86.R_EBX = 0; 443 vesa_emu.x86.R_ECX = colors; 444 vesa_emu.x86.R_EDX = start; |
384 | 445 |
385 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 386 return ((err != 0) || (vmf.vmf_ax != 0x4f)); | 446 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 447 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 448 449 x86emu_exec_intr(&vesa_emu, 0x10); 450 451 return ((vesa_emu.x86.R_AX & 0xff) != 0x4f); |
387} 388 389#ifdef notyet 390static int 391vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, u_char *b, 392 int bits) 393{ | 452} 453 454#ifdef notyet 455static int 456vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, u_char *b, 457 int bits) 458{ |
394 struct vm86frame vmf; | |
395 u_char *p; | 459 u_char *p; |
396 int err; | |
397 int i; 398 | 460 int i; 461 |
399 p = vesa_vm86_buf; | 462 p = (emumem + REALOFF(2)); 463 |
400 bits = 8 - bits; 401 for (i = 0; i < colors; ++i) { 402 p[i*4] = b[i] >> bits; 403 p[i*4 + 1] = g[i] >> bits; 404 p[i*4 + 2] = r[i] >> bits; 405 p[i*4 + 3] = 0; 406 } 407 | 464 bits = 8 - bits; 465 for (i = 0; i < colors; ++i) { 466 p[i*4] = b[i] >> bits; 467 p[i*4 + 1] = g[i] >> bits; 468 p[i*4 + 2] = r[i] >> bits; 469 p[i*4 + 3] = 0; 470 } 471 |
408 bzero(&vmf, sizeof(vmf)); 409 vmf.vmf_eax = 0x4f09; 410 vmf.vmf_ebx = 0; /* set primary palette data */ 411 vmf.vmf_ecx = colors; 412 vmf.vmf_edx = start; 413 vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di); | 472 vesa_emu.x86.R_EAX = 0x4f09; 473 vesa_emu.x86.R_EBX = 0; 474 vesa_emu.x86.R_ECX = colors; 475 vesa_emu.x86.R_EDX = start; |
414 | 476 |
415 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 416 return ((err != 0) || (vmf.vmf_ax != 0x4f)); | 477 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 478 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 479 480 x86emu_exec_intr(&vesa_emu, 0x10); 481 482 return ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
417} 418#endif 419 420static int 421vesa_bios_state_buf_size(void) 422{ | 483} 484#endif 485 486static int 487vesa_bios_state_buf_size(void) 488{ |
423 struct vm86frame vmf; 424 int err; | 489 vesa_emu.x86.R_EAX = 0x4f04; 490 vesa_emu.x86.R_ECX = STATE_ALL; 491 vesa_emu.x86.R_EDX = STATE_SIZE; |
425 | 492 |
426 bzero(&vmf, sizeof(vmf)); 427 vmf.vmf_eax = 0x4f04; 428 vmf.vmf_ecx = STATE_ALL; 429 vmf.vmf_edx = STATE_SIZE; 430 err = vm86_intcall(0x10, &vmf); 431 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 493 x86emu_exec_intr(&vesa_emu, 0x10); 494 495 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
432 return 0; | 496 return 0; |
433 return vmf.vmf_bx*64; | 497 498 return vesa_emu.x86.R_BX*64; |
434} 435 436static int 437vesa_bios_save_restore(int code, void *p, size_t size) 438{ | 499} 500 501static int 502vesa_bios_save_restore(int code, void *p, size_t size) 503{ |
439 struct vm86frame vmf; | |
440 u_char *buf; | 504 u_char *buf; |
441 int err; | |
442 | 505 |
443 if (size > VESA_VM86_BUFSIZE) | 506 if (size > VESA_X86EMU_BUFSIZE) |
444 return (1); 445 | 507 return (1); 508 |
446 bzero(&vmf, sizeof(vmf)); 447 vmf.vmf_eax = 0x4f04; 448 vmf.vmf_ecx = STATE_ALL; 449 vmf.vmf_edx = code; /* STATE_SAVE/STATE_LOAD */ 450 buf = vesa_vm86_buf; 451 vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_bx); | 509 vesa_emu.x86.R_EAX = 0x4f04; 510 vesa_emu.x86.R_ECX = STATE_ALL; 511 vesa_emu.x86.R_EDX = code; 512 513 buf = emumem + REALOFF(2); 514 515 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 516 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 517 |
452 bcopy(p, buf, size); 453 | 518 bcopy(p, buf, size); 519 |
454 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); | 520 x86emu_exec_intr(&vesa_emu, 0x10); 521 |
455 bcopy(buf, p, size); | 522 bcopy(buf, p, size); |
456 return ((err != 0) || (vmf.vmf_ax != 0x4f)); | 523 524 return ((vesa_emu.x86.R_AX & 0xff) != 0x4f); |
457} 458 459static int 460vesa_bios_get_line_length(void) 461{ | 525} 526 527static int 528vesa_bios_get_line_length(void) 529{ |
462 struct vm86frame vmf; 463 int err; | 530 vesa_emu.x86.R_EAX = 0x4f06; 531 vesa_emu.x86.R_EBX = 1; |
464 | 532 |
465 bzero(&vmf, sizeof(vmf)); 466 vmf.vmf_eax = 0x4f06; 467 vmf.vmf_ebx = 1; /* get scan line length */ 468 err = vm86_intcall(0x10, &vmf); 469 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 533 x86emu_exec_intr(&vesa_emu, 0x10); 534 535 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
470 return -1; | 536 return -1; |
471 return vmf.vmf_bx; /* line length in bytes */ | 537 return vesa_emu.x86.R_BX; |
472} 473 474static int 475vesa_bios_set_line_length(int pixel, int *bytes, int *lines) 476{ | 538} 539 540static int 541vesa_bios_set_line_length(int pixel, int *bytes, int *lines) 542{ |
477 struct vm86frame vmf; 478 int err; | 543 vesa_emu.x86.R_EAX = 0x4f06; 544 vesa_emu.x86.R_EBX = 0; 545 vesa_emu.x86.R_ECX = pixel; |
479 | 546 |
480 bzero(&vmf, sizeof(vmf)); 481 vmf.vmf_eax = 0x4f06; 482 vmf.vmf_ebx = 0; /* set scan line length in pixel */ 483 vmf.vmf_ecx = pixel; 484 err = vm86_intcall(0x10, &vmf); | 547 x86emu_exec_intr(&vesa_emu, 0x10); 548 |
485#if VESA_DEBUG > 1 | 549#if VESA_DEBUG > 1 |
486 printf("bx:%d, cx:%d, dx:%d\n", vmf.vmf_bx, vmf.vmf_cx, vmf.vmf_dx); | 550 printf("bx:%d, cx:%d, dx:%d\n", vesa_emu.x86.R_BX, vesa_emu.x86.R_CX, vesa_emu.x86.R_DX); |
487#endif | 551#endif |
488 if ((err != 0) || (vmf.vmf_ax != 0x4f)) 489 return 1; | 552 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) 553 return -1; 554 |
490 if (bytes) | 555 if (bytes) |
491 *bytes = vmf.vmf_bx; | 556 *bytes = vesa_emu.x86.R_BX; |
492 if (lines) | 557 if (lines) |
493 *lines = vmf.vmf_dx; | 558 *lines = vesa_emu.x86.R_DX; 559 |
494 return 0; 495} 496 497#if 0 498static int 499vesa_bios_get_start(int *x, int *y) 500{ | 560 return 0; 561} 562 563#if 0 564static int 565vesa_bios_get_start(int *x, int *y) 566{ |
501 struct vm86frame vmf; 502 int err; | 567 vesa_emu.x86.R_EAX = 0x4f07; 568 vesa_emu.x86.R_EBX = 1; |
503 | 569 |
504 bzero(&vmf, sizeof(vmf)); 505 vmf.vmf_eax = 0x4f07; 506 vmf.vmf_ebx = 1; /* get display start */ 507 err = vm86_intcall(0x10, &vmf); 508 if ((err != 0) || (vmf.vmf_ax != 0x4f)) 509 return 1; 510 *x = vmf.vmf_cx; 511 *y = vmf.vmf_dx; | 570 x86emu_exec_intr(&vesa_emu, 0x10); 571 572 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) 573 return -1; 574 575 *x = vesa_emu.x86.R_CX; 576 *y = vesa_emu.x86.R_DX; 577 |
512 return 0; 513} 514#endif 515 516static int 517vesa_bios_set_start(int x, int y) 518{ | 578 return 0; 579} 580#endif 581 582static int 583vesa_bios_set_start(int x, int y) 584{ |
519 struct vm86frame vmf; 520 int err; | 585 vesa_emu.x86.R_EAX = 0x4f07; 586 vesa_emu.x86.R_EBX = 0x80; 587 vesa_emu.x86.R_EDX = y; 588 vesa_emu.x86.R_ECX = x; |
521 | 589 |
522 bzero(&vmf, sizeof(vmf)); 523 vmf.vmf_eax = 0x4f07; 524 vmf.vmf_ebx = 0x80; /* set display start */ 525 vmf.vmf_edx = y; 526 vmf.vmf_ecx = x; 527 err = vm86_intcall(0x10, &vmf); 528 return ((err != 0) || (vmf.vmf_ax != 0x4f)); | 590 x86emu_exec_intr(&vesa_emu, 0x10); 591 592 return ((vesa_emu.x86.R_AX & 0xff) != 0x4f); |
529} 530 531/* map a generic video mode to a known mode */ 532static int 533vesa_map_gen_mode_num(int type, int color, int mode) 534{ 535 static struct { 536 int from; --- 53 unchanged lines hidden (view full) --- 590 591 for (i = 0; mtable[i].mmodel >= 0; ++i) { 592 if (mtable[i].vmodel == vmodel) 593 return mtable[i].mmodel; 594 } 595 return V_INFO_MM_OTHER; 596} 597 | 593} 594 595/* map a generic video mode to a known mode */ 596static int 597vesa_map_gen_mode_num(int type, int color, int mode) 598{ 599 static struct { 600 int from; --- 53 unchanged lines hidden (view full) --- 654 655 for (i = 0; mtable[i].mmodel >= 0; ++i) { 656 if (mtable[i].vmodel == vmodel) 657 return mtable[i].mmodel; 658 } 659 return V_INFO_MM_OTHER; 660} 661 |
598static void 599*vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, u_char *buf) 600{ 601 if (p == 0) 602 return NULL; 603 if (((p >> 16) == seg) && ((p & 0xffff) >= off)) 604 return (void *)(buf + ((p & 0xffff) - off)); 605 else { 606 p = BIOS_SADDRTOLADDR(p); 607 return (void *)BIOS_PADDRTOVADDR(p); 608 } 609} 610 | |
611static int 612vesa_bios_init(void) 613{ | 662static int 663vesa_bios_init(void) 664{ |
614 static u_char buf[512]; 615 struct vm86frame vmf; | 665 static struct vesa_info buf; |
616 struct vesa_mode vmode; 617 video_info_t *p; 618 u_char *vmbuf; 619 int is_via_cle266; 620 int modes; | 666 struct vesa_mode vmode; 667 video_info_t *p; 668 u_char *vmbuf; 669 int is_via_cle266; 670 int modes; |
621 int err; | |
622 int i; 623 624 if (vesa_init_done) 625 return 0; 626 627 has_vesa_bios = FALSE; 628 vesa_adp_info = NULL; 629 vesa_vmode_max = 0; 630 vesa_vmode[0].vi_mode = EOT; 631 | 671 int i; 672 673 if (vesa_init_done) 674 return 0; 675 676 has_vesa_bios = FALSE; 677 vesa_adp_info = NULL; 678 vesa_vmode_max = 0; 679 vesa_vmode[0].vi_mode = EOT; 680 |
632 /* Allocate a buffer and add each page to the vm86 context. */ 633 vesa_vm86_buf = malloc(VESA_VM86_BUFSIZE, M_DEVBUF, M_WAITOK | M_ZERO); 634 KASSERT(((vm_offset_t)vesa_vm86_buf & PAGE_MASK) == 0, 635 ("bad vesa_vm86_buf alignment")); 636 for (i = 0; i < howmany(VESA_VM86_BUFSIZE, PAGE_SIZE); i++) 637 vm86_addpage(&vesa_vmcontext, i + 1, 638 (vm_offset_t)vesa_vm86_buf + PAGE_SIZE * i); 639 640 vmbuf = vesa_vm86_buf; 641 bzero(&vmf, sizeof(vmf)); /* paranoia */ | 681 vmbuf = (emumem + REALOFF(2)); |
642 bcopy("VBE2", vmbuf, 4); /* try for VBE2 data */ | 682 bcopy("VBE2", vmbuf, 4); /* try for VBE2 data */ |
643 vmf.vmf_eax = 0x4f00; 644 vm86_getptr(&vesa_vmcontext, (vm_offset_t)vmbuf, &vmf.vmf_es, &vmf.vmf_di); | |
645 | 683 |
646 err = vm86_datacall(0x10, &vmf, &vesa_vmcontext); 647 if ((err != 0) || (vmf.vmf_ax != 0x4f) || bcmp("VESA", vmbuf, 4)) | 684 vesa_emu.x86.R_EAX = 0x4f00; 685 vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2)); 686 vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2)); 687 688 x86emu_exec_intr(&vesa_emu, 0x10); 689 690 if (((vesa_emu.x86.R_AX & 0xff) != 0x4f) || bcmp("VESA", vmbuf, 4)) |
648 return 1; | 691 return 1; |
649 bcopy(vmbuf, buf, sizeof(buf)); 650 vesa_adp_info = (struct vesa_info *)buf; | 692 693 bcopy(vmbuf, &buf, sizeof(buf)); 694 695 vesa_adp_info = &buf; |
651 if (bootverbose) { 652 printf("VESA: information block\n"); | 696 if (bootverbose) { 697 printf("VESA: information block\n"); |
653 dump_buffer(buf, 64); | 698 dump_buffer((u_char *)&buf, sizeof(buf)); |
654 } 655 if (vesa_adp_info->v_version < 0x0102) { 656 printf("VESA: VBE version %d.%d is not supported; " 657 "version 1.2 or later is required.\n", 658 ((vesa_adp_info->v_version & 0xf000) >> 12) * 10 659 + ((vesa_adp_info->v_version & 0x0f00) >> 8), 660 ((vesa_adp_info->v_version & 0x00f0) >> 4) * 10 661 + (vesa_adp_info->v_version & 0x000f)); 662 return 1; 663 } 664 | 699 } 700 if (vesa_adp_info->v_version < 0x0102) { 701 printf("VESA: VBE version %d.%d is not supported; " 702 "version 1.2 or later is required.\n", 703 ((vesa_adp_info->v_version & 0xf000) >> 12) * 10 704 + ((vesa_adp_info->v_version & 0x0f00) >> 8), 705 ((vesa_adp_info->v_version & 0x00f0) >> 4) * 10 706 + (vesa_adp_info->v_version & 0x000f)); 707 return 1; 708 } 709 |
665 /* fix string ptrs */ 666 vesa_oemstr = (char *)vesa_fix_ptr(vesa_adp_info->v_oemstr, 667 vmf.vmf_es, vmf.vmf_di, buf); | 710 vesa_oemstr = (char *)(emumem + L_ADD(vesa_adp_info->v_oemstr)); 711 |
668 is_via_cle266 = strcmp(vesa_oemstr, VESA_VIA_CLE266) == 0; 669 670 if (vesa_adp_info->v_version >= 0x0200) { | 712 is_via_cle266 = strcmp(vesa_oemstr, VESA_VIA_CLE266) == 0; 713 714 if (vesa_adp_info->v_version >= 0x0200) { |
671 vesa_venderstr = 672 (char *)vesa_fix_ptr(vesa_adp_info->v_venderstr, 673 vmf.vmf_es, vmf.vmf_di, buf); 674 vesa_prodstr = 675 (char *)vesa_fix_ptr(vesa_adp_info->v_prodstr, 676 vmf.vmf_es, vmf.vmf_di, buf); 677 vesa_revstr = 678 (char *)vesa_fix_ptr(vesa_adp_info->v_revstr, 679 vmf.vmf_es, vmf.vmf_di, buf); | 715 vesa_venderstr = (char *)(emumem+L_ADD(vesa_adp_info->v_venderstr)); 716 vesa_prodstr = (char *)(emumem+L_ADD(vesa_adp_info->v_prodstr)); 717 vesa_revstr = (char *)(emumem+L_ADD(vesa_adp_info->v_revstr)); |
680 } 681 | 718 } 719 |
682 /* obtain video mode information */ 683 vesa_vmodetab = (u_int16_t *)vesa_fix_ptr(vesa_adp_info->v_modetable, 684 vmf.vmf_es, vmf.vmf_di, buf); | 720 vesa_vmodetab = (u_int16_t *)(emumem+L_ADD(vesa_adp_info->v_modetable)); 721 |
685 if (vesa_vmodetab == NULL) 686 return 1; | 722 if (vesa_vmodetab == NULL) 723 return 1; |
724 |
|
687 for (i = 0, modes = 0; 688 (i < (M_VESA_MODE_MAX - M_VESA_BASE + 1)) 689 && (vesa_vmodetab[i] != 0xffff); ++i) { 690 if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode)) 691 continue; 692 693 /* reject unsupported modes */ 694#if 0 --- 134 unchanged lines hidden (view full) --- 829vesa_map_buffer(u_int paddr, size_t size) 830{ 831 vm_offset_t vaddr; 832 u_int off; 833 834 off = paddr - trunc_page(paddr); 835 vaddr = (vm_offset_t)pmap_mapdev(paddr - off, size + off); 836#if VESA_DEBUG > 1 | 725 for (i = 0, modes = 0; 726 (i < (M_VESA_MODE_MAX - M_VESA_BASE + 1)) 727 && (vesa_vmodetab[i] != 0xffff); ++i) { 728 if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode)) 729 continue; 730 731 /* reject unsupported modes */ 732#if 0 --- 134 unchanged lines hidden (view full) --- 867vesa_map_buffer(u_int paddr, size_t size) 868{ 869 vm_offset_t vaddr; 870 u_int off; 871 872 off = paddr - trunc_page(paddr); 873 vaddr = (vm_offset_t)pmap_mapdev(paddr - off, size + off); 874#if VESA_DEBUG > 1 |
837 printf("vesa_map_buffer: paddr:%x vaddr:%x size:%x off:%x\n", | 875 printf("vesa_map_buffer: paddr:%x vaddr:%tx size:%zx off:%x\n", |
838 paddr, vaddr, size, off); 839#endif 840 return (vaddr + off); 841} 842 843static void 844vesa_unmap_buffer(vm_offset_t vaddr, size_t size) 845{ 846#if VESA_DEBUG > 1 | 876 paddr, vaddr, size, off); 877#endif 878 return (vaddr + off); 879} 880 881static void 882vesa_unmap_buffer(vm_offset_t vaddr, size_t size) 883{ 884#if VESA_DEBUG > 1 |
847 printf("vesa_unmap_buffer: vaddr:%x size:%x\n", vaddr, size); | 885 printf("vesa_unmap_buffer: vaddr:%tx size:%zx\n", vaddr, size); |
848#endif 849 kmem_free(kernel_map, vaddr, size); 850} 851 852/* entry points */ 853 854static int 855vesa_configure(int flags) --- 227 unchanged lines hidden (view full) --- 1083 vesa_adp_info->v_memsize*64*1024); 1084 vesa_adp->va_buffer_size = info.vi_buffer_size; 1085 vesa_adp->va_window = vesa_adp->va_buffer; 1086 vesa_adp->va_window_size = info.vi_buffer_size/info.vi_planes; 1087 vesa_adp->va_window_gran = info.vi_buffer_size/info.vi_planes; 1088 } else { 1089 vesa_adp->va_buffer = 0; 1090 vesa_adp->va_buffer_size = info.vi_buffer_size; | 886#endif 887 kmem_free(kernel_map, vaddr, size); 888} 889 890/* entry points */ 891 892static int 893vesa_configure(int flags) --- 227 unchanged lines hidden (view full) --- 1121 vesa_adp_info->v_memsize*64*1024); 1122 vesa_adp->va_buffer_size = info.vi_buffer_size; 1123 vesa_adp->va_window = vesa_adp->va_buffer; 1124 vesa_adp->va_window_size = info.vi_buffer_size/info.vi_planes; 1125 vesa_adp->va_window_gran = info.vi_buffer_size/info.vi_planes; 1126 } else { 1127 vesa_adp->va_buffer = 0; 1128 vesa_adp->va_buffer_size = info.vi_buffer_size; |
1091 vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window); | 1129 vesa_adp->va_window = (vm_offset_t)(emumem+L_ADD(info.vi_window)); |
1092 vesa_adp->va_window_size = info.vi_window_size; 1093 vesa_adp->va_window_gran = info.vi_window_gran; 1094 } 1095 vesa_adp->va_window_orig = 0; 1096 len = vesa_bios_get_line_length(); 1097 if (len > 0) { 1098 vesa_adp->va_line_width = len; 1099 } else if (info.vi_flags & V_INFO_GRAPHICS) { --- 132 unchanged lines hidden (view full) --- 1232 return vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs, 1233 vesa_state_buf_size); 1234} 1235 1236#if 0 1237static int 1238vesa_get_origin(video_adapter_t *adp, off_t *offset) 1239{ | 1130 vesa_adp->va_window_size = info.vi_window_size; 1131 vesa_adp->va_window_gran = info.vi_window_gran; 1132 } 1133 vesa_adp->va_window_orig = 0; 1134 len = vesa_bios_get_line_length(); 1135 if (len > 0) { 1136 vesa_adp->va_line_width = len; 1137 } else if (info.vi_flags & V_INFO_GRAPHICS) { --- 132 unchanged lines hidden (view full) --- 1270 return vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs, 1271 vesa_state_buf_size); 1272} 1273 1274#if 0 1275static int 1276vesa_get_origin(video_adapter_t *adp, off_t *offset) 1277{ |
1240 struct vm86frame vmf; 1241 int err; | 1278 vesa_emu.x86.R_EAX = 0x4f05; 1279 vesa_emu.x86.R_EBX = 0x10; |
1242 | 1280 |
1243 bzero(&vmf, sizeof(vmf)); 1244 vmf.vmf_eax = 0x4f05; 1245 vmf.vmf_ebx = 0x10; /* WINDOW_A, XXX */ 1246 err = vm86_intcall(0x10, &vmf); 1247 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 1281 x86emu_exec_intr(&vesa_emu, 0x10); 1282 1283 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
1248 return 1; | 1284 return 1; |
1249 *offset = vmf.vmf_dx*adp->va_window_gran; | 1285 *offset = vesa_emu.x86.DX*adp->va_window_gran; 1286 |
1250 return 0; 1251} 1252#endif 1253 1254static int 1255vesa_set_origin(video_adapter_t *adp, off_t offset) 1256{ | 1287 return 0; 1288} 1289#endif 1290 1291static int 1292vesa_set_origin(video_adapter_t *adp, off_t offset) 1293{ |
1257 struct vm86frame vmf; 1258 int err; 1259 | |
1260 /* 1261 * This function should return as quickly as possible to 1262 * maintain good performance of the system. For this reason, 1263 * error checking is kept minimal and let the VESA BIOS to 1264 * detect error. 1265 */ 1266 if (adp != vesa_adp) 1267 return (*prevvidsw->set_win_org)(adp, offset); 1268 1269 /* if this is a linear frame buffer, do nothing */ 1270 if (adp->va_info.vi_flags & V_INFO_LINEAR) 1271 return 0; 1272 /* XXX */ 1273 if (adp->va_window_gran == 0) 1274 return 1; 1275 | 1294 /* 1295 * This function should return as quickly as possible to 1296 * maintain good performance of the system. For this reason, 1297 * error checking is kept minimal and let the VESA BIOS to 1298 * detect error. 1299 */ 1300 if (adp != vesa_adp) 1301 return (*prevvidsw->set_win_org)(adp, offset); 1302 1303 /* if this is a linear frame buffer, do nothing */ 1304 if (adp->va_info.vi_flags & V_INFO_LINEAR) 1305 return 0; 1306 /* XXX */ 1307 if (adp->va_window_gran == 0) 1308 return 1; 1309 |
1276 bzero(&vmf, sizeof(vmf)); 1277 vmf.vmf_eax = 0x4f05; 1278 vmf.vmf_ebx = 0; /* WINDOW_A, XXX */ 1279 vmf.vmf_edx = offset/adp->va_window_gran; 1280 err = vm86_intcall(0x10, &vmf); 1281 if ((err != 0) || (vmf.vmf_ax != 0x4f)) | 1310 vesa_emu.x86.R_EAX = 0x4f05; 1311 vesa_emu.x86.R_EBX = 0; 1312 vesa_emu.x86.R_EDX = offset/adp->va_window_gran; 1313 x86emu_exec_intr(&vesa_emu, 0x10); 1314 1315 if ((vesa_emu.x86.R_AX & 0xff) != 0x4f) |
1282 return 1; | 1316 return 1; |
1283 bzero(&vmf, sizeof(vmf)); 1284 vmf.vmf_eax = 0x4f05; 1285 vmf.vmf_ebx = 1; /* WINDOW_B, XXX */ 1286 vmf.vmf_edx = offset/adp->va_window_gran; 1287 err = vm86_intcall(0x10, &vmf); | 1317 1318 vesa_emu.x86.R_EAX = 0x4f05; 1319 vesa_emu.x86.R_EBX = 1; 1320 vesa_emu.x86.R_EDX = offset/adp->va_window_gran; 1321 x86emu_exec_intr(&vesa_emu, 0x10); 1322 |
1288 adp->va_window_orig = (offset/adp->va_window_gran)*adp->va_window_gran; 1289 return 0; /* XXX */ 1290} 1291 1292static int 1293vesa_read_hw_cursor(video_adapter_t *adp, int *col, int *row) 1294{ 1295 return (*prevvidsw->read_hw_cursor)(adp, col, row); --- 20 unchanged lines hidden (view full) --- 1316 return (*prevvidsw->blank_display)(adp, mode); 1317} 1318 1319static int 1320vesa_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr, 1321 int prot) 1322{ 1323#if VESA_DEBUG > 0 | 1323 adp->va_window_orig = (offset/adp->va_window_gran)*adp->va_window_gran; 1324 return 0; /* XXX */ 1325} 1326 1327static int 1328vesa_read_hw_cursor(video_adapter_t *adp, int *col, int *row) 1329{ 1330 return (*prevvidsw->read_hw_cursor)(adp, col, row); --- 20 unchanged lines hidden (view full) --- 1351 return (*prevvidsw->blank_display)(adp, mode); 1352} 1353 1354static int 1355vesa_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr, 1356 int prot) 1357{ 1358#if VESA_DEBUG > 0 |
1324 printf("vesa_mmap(): window:0x%x, buffer:0x%x, offset:0x%x\n", | 1359 printf("vesa_mmap(): window:0x%tx, buffer:0x%tx, offset:0x%tx\n", |
1325 adp->va_info.vi_window, adp->va_info.vi_buffer, offset); 1326#endif 1327 1328 if ((adp == vesa_adp) && (adp->va_info.vi_flags & V_INFO_LINEAR)) { 1329 /* va_window_size == va_buffer_size/vi_planes */ 1330 /* XXX: is this correct? */ 1331 if (offset > adp->va_window_size - PAGE_SIZE) 1332 return -1; --- 280 unchanged lines hidden (view full) --- 1613vesa_load(void) 1614{ 1615 int error; 1616 int s; 1617 1618 if (vesa_init_done) 1619 return 0; 1620 | 1360 adp->va_info.vi_window, adp->va_info.vi_buffer, offset); 1361#endif 1362 1363 if ((adp == vesa_adp) && (adp->va_info.vi_flags & V_INFO_LINEAR)) { 1364 /* va_window_size == va_buffer_size/vi_planes */ 1365 /* XXX: is this correct? */ 1366 if (offset > adp->va_window_size - PAGE_SIZE) 1367 return -1; --- 280 unchanged lines hidden (view full) --- 1648vesa_load(void) 1649{ 1650 int error; 1651 int s; 1652 1653 if (vesa_init_done) 1654 return 0; 1655 |
1656 /* Can `emumem' be NULL here? */ 1657 emumem = pmap_mapbios(0x0, 0xc00000); 1658 1659 memset(&vesa_emu, 0, sizeof(vesa_emu)); 1660 x86emu_init_default(&vesa_emu); 1661 1662 vesa_emu.emu_inb = vm86_emu_inb; 1663 vesa_emu.emu_inw = vm86_emu_inw; 1664 vesa_emu.emu_inl = vm86_emu_inl; 1665 vesa_emu.emu_outb = vm86_emu_outb; 1666 vesa_emu.emu_outw = vm86_emu_outw; 1667 vesa_emu.emu_outl = vm86_emu_outl; 1668 1669 vesa_emu.mem_base = (char *)emumem; 1670 vesa_emu.mem_size = 1024 * 1024; 1671 |
|
1621 /* locate a VGA adapter */ 1622 s = spltty(); 1623 vesa_adp = NULL; 1624 error = vesa_configure(0); 1625 splx(s); 1626 1627 if (error == 0) 1628 vesa_bios_info(bootverbose); --- 31 unchanged lines hidden (view full) --- 1660 } 1661 } 1662 vesa_adp->va_flags &= ~V_ADP_VESA; 1663 vidsw[vesa_adp->va_index] = prevvidsw; 1664 } 1665 } 1666 splx(s); 1667 | 1672 /* locate a VGA adapter */ 1673 s = spltty(); 1674 vesa_adp = NULL; 1675 error = vesa_configure(0); 1676 splx(s); 1677 1678 if (error == 0) 1679 vesa_bios_info(bootverbose); --- 31 unchanged lines hidden (view full) --- 1711 } 1712 } 1713 vesa_adp->va_flags &= ~V_ADP_VESA; 1714 vidsw[vesa_adp->va_index] = prevvidsw; 1715 } 1716 } 1717 splx(s); 1718 |
1668 if (vesa_vm86_buf != NULL) 1669 free(vesa_vm86_buf, M_DEVBUF); | 1719 if (emumem) 1720 pmap_unmapdev((vm_offset_t)emumem, 0xc00000); |
1670 1671 return error; 1672} 1673 1674static int 1675vesa_mod_event(module_t mod, int type, void *data) 1676{ 1677 switch (type) { --- 9 unchanged lines hidden (view full) --- 1687 1688static moduledata_t vesa_mod = { 1689 "vesa", 1690 vesa_mod_event, 1691 NULL, 1692}; 1693 1694DECLARE_MODULE(vesa, vesa_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); | 1721 1722 return error; 1723} 1724 1725static int 1726vesa_mod_event(module_t mod, int type, void *data) 1727{ 1728 switch (type) { --- 9 unchanged lines hidden (view full) --- 1738 1739static moduledata_t vesa_mod = { 1740 "vesa", 1741 vesa_mod_event, 1742 NULL, 1743}; 1744 1745DECLARE_MODULE(vesa, vesa_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); |
1746MODULE_DEPEND(vesa, x86emu, 1, 1, 1); |
|
1695 1696#endif /* VGA_NO_MODE_CHANGE */ | 1747 1748#endif /* VGA_NO_MODE_CHANGE */ |