diff options
author | Xin LI <delphij@FreeBSD.org> | 2009-09-21 08:17:57 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2009-09-21 08:17:57 +0000 |
commit | 205d67b00d81bcc0c8e84f20f95b26ed94acb923 (patch) | |
tree | cb7019657600dfa7d0c10d79abcf3cb3b894cfb6 /sys/dev/dpms | |
parent | 91d345423d48c2bdcf7c872a0f240e435c56d3ff (diff) | |
download | src-205d67b00d81bcc0c8e84f20f95b26ed94acb923.tar.gz src-205d67b00d81bcc0c8e84f20f95b26ed94acb923.zip |
Collapase interrupt supporting functions to a new module, and switch from
x86emu to this new module.
This changeset also brings a fix for bugs introduced with the initial
x86emu commit, which prevents the user from using some display mode or
cause instant reboots during mode switch.
Submitted by: paradox <ddkprog yahoo com>
Notes
Notes:
svn path=/head/; revision=197383
Diffstat (limited to 'sys/dev/dpms')
-rw-r--r-- | sys/dev/dpms/dpms.c | 101 |
1 files changed, 13 insertions, 88 deletions
diff --git a/sys/dev/dpms/dpms.c b/sys/dev/dpms/dpms.c index ac729f9edd06..d21839b74f94 100644 --- a/sys/dev/dpms/dpms.c +++ b/sys/dev/dpms/dpms.c @@ -67,11 +67,7 @@ __FBSDID("$FreeBSD$"); #include <sys/libkern.h> #include <sys/module.h> -#include <vm/vm.h> -#include <vm/pmap.h> - -#include <contrib/x86emu/x86emu.h> -#include <contrib/x86emu/x86emu_regs.h> +#include <dev/x86bios/x86bios.h> /* * VESA DPMS States @@ -94,9 +90,6 @@ struct dpms_softc { int dpms_initial_state; }; -static struct x86emu vesa_emu; -static unsigned char *emumem = NULL; - static int dpms_attach(device_t); static int dpms_detach(device_t); static int dpms_get_supported_states(int *); @@ -126,59 +119,7 @@ static driver_t dpms_driver = { static devclass_t dpms_devclass; DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL); -MODULE_DEPEND(dpms, x86emu, 1, 1, 1); - -static uint8_t -vm86_emu_inb(struct x86emu *emu, uint16_t port) -{ - if (port == 0xb2) /* APM scratch register */ - return 0; - if (port >= 0x80 && port < 0x88) /* POST status register */ - return 0; - return inb(port); -} - -static uint16_t -vm86_emu_inw(struct x86emu *emu, uint16_t port) -{ - if (port >= 0x80 && port < 0x88) /* POST status register */ - return 0; - return inw(port); -} - -static uint32_t -vm86_emu_inl(struct x86emu *emu, uint16_t port) -{ - if (port >= 0x80 && port < 0x88) /* POST status register */ - return 0; - return inl(port); -} - -static void -vm86_emu_outb(struct x86emu *emu, uint16_t port, uint8_t val) -{ - if (port == 0xb2) /* APM scratch register */ - return; - if (port >= 0x80 && port < 0x88) /* POST status register */ - return; - outb(port, val); -} - -static void -vm86_emu_outw(struct x86emu *emu, uint16_t port, uint16_t val) -{ - if (port >= 0x80 && port < 0x88) /* POST status register */ - return; - outw(port, val); -} - -static void -vm86_emu_outl(struct x86emu *emu, uint16_t port, uint32_t val) -{ - if (port >= 0x80 && port < 0x88) /* POST status register */ - return; - outl(port, val); -} +MODULE_DEPEND(dpms, x86bios, 1, 1, 1); static void dpms_identify(driver_t *driver, device_t parent) @@ -192,7 +133,6 @@ dpms_identify(driver_t *driver, device_t parent) */ if (devclass_get_device(dpms_devclass, 0) == NULL) device_add_child(parent, "dpms", 0); - } static int @@ -200,21 +140,6 @@ dpms_probe(device_t dev) { int error, states; - emumem = pmap_mapbios(0x0, 0xc00000); - - memset(&vesa_emu, 0, sizeof(vesa_emu)); - x86emu_init_default(&vesa_emu); - - vesa_emu.emu_inb = vm86_emu_inb; - vesa_emu.emu_inw = vm86_emu_inw; - vesa_emu.emu_inl = vm86_emu_inl; - vesa_emu.emu_outb = vm86_emu_outb; - vesa_emu.emu_outw = vm86_emu_outw; - vesa_emu.emu_outl = vm86_emu_outl; - - vesa_emu.mem_base = (char *)emumem; - vesa_emu.mem_size = 1024 * 1024; - error = dpms_get_supported_states(&states); if (error) return (error); @@ -240,8 +165,6 @@ dpms_attach(device_t dev) static int dpms_detach(device_t dev) { - if (emumem) - pmap_unmapdev((vm_offset_t)emumem, 0xc00000); return (0); } @@ -267,17 +190,19 @@ dpms_resume(device_t dev) static int dpms_call_bios(int subfunction, int *bh) { - vesa_emu.x86.R_AX = VBE_DPMS_FUNCTION; - vesa_emu.x86.R_BL = subfunction; - vesa_emu.x86.R_BH = *bh; - vesa_emu.x86.R_ES = 0; - vesa_emu.x86.R_DI = 0; - x86emu_exec_intr(&vesa_emu, 0x10); - - if ((vesa_emu.x86.R_EAX & 0xffff) != 0x004f) + x86regs_t regs; + + regs.R_AX = VBE_DPMS_FUNCTION; + regs.R_BL = subfunction; + regs.R_BH = *bh; + regs.R_ES = 0; + regs.R_DI = 0; + x86biosCall(®s, 0x10); + + if ((regs.R_EAX & 0xffff) != 0x004f) return (ENXIO); - *bh = vesa_emu.x86.R_BH; + *bh = regs.R_BH; return (0); } |