diff options
author | jkim <jkim@FreeBSD.org> | 2009-10-19 20:58:10 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2009-10-19 20:58:10 +0000 |
commit | 99279734b833c18edb9cfc47db1c920327e97fde (patch) | |
tree | d4a62e4e5d88debc2e3a4761c8ceea077f9a2ac1 /sys/dev/dpms | |
parent | 8f9031d9fe5f0fb11cd72dd010fbdac9560df819 (diff) | |
download | FreeBSD-src-99279734b833c18edb9cfc47db1c920327e97fde.zip FreeBSD-src-99279734b833c18edb9cfc47db1c920327e97fde.tar.gz |
Rewrite x86bios and update its dependent drivers.
- Do not map entire real mode memory (1MB). Instead, we map IVT/BDA and
ROM area separately. Most notably, ROM area is mapped as device memory
(uncacheable) as it should be. User memory is dynamically allocated and
free'ed with contigmalloc(9) and contigfree(9). Remove now redundant and
potentially dangerous x86bios_alloc.c. If this emulator ever grows to
support non-PC hardware, we may implement it with rman(9) later.
- Move all host-specific initializations from x86emu_util.c to x86bios.c and
remove now unnecessary x86emu_util.c. Currently, non-PC hardware is not
supported. We may use bus_space(9) later when the KPI is fixed.
- Replace all bzero() calls for emulated registers with more obviously named
x86bios_init_regs(). This function also initializes DS and SS properly.
- Add x86bios_get_intr(). This function checks if the interrupt vector is
available for the platform. It is not necessary for PC-compatible hardware
but it may be needed later. ;-)
- Do not try turning off monitor if DPMS does not support the state.
- Allocate stable memory for VESA OEM strings instead of just holding
pointers to them. They may or may not be accessible always. Fix a memory
leak of video mode table while I am here.
- Add (experimental) BIOS POST call for vesa(4). This function calls VGA
BIOS POST code from the current VGA option ROM. Some video controllers
cannot save and restore the state properly even if it is claimed to be
supported. Usually the symptom is blank display after resuming from suspend
state. If the video mode does not match the previous mode after restoring,
we try BIOS POST and force the known good initial state. Some magic was
taken from NetBSD (and it was taken from vbetool, I believe.)
- Add a loader tunable for vgapci(4) to give a hint to dpms(4) and vesa(4)
to identify who owns the VESA BIOS. This is very useful for multi-display
adapter setup. By default, the POST video controller is automatically
probed and the tunable "hw.pci.default_vgapci_unit" is set to corresponding
vgapci unit number. You may override it from loader but it is very unlikely
to be necessary. Unfortunately only AGP/PCI/PCI-E controllers can be
matched because ISA controller does not have necessary device IDs.
- Fix a long standing bug in state save/restore function. The state buffer
pointer should be ES:BX, not ES:DI according to VBE 3.0. If it ever worked,
that's because BX was always zero. :-)
- Clean up register initializations more clearer per VBE 3.0.
- Fix a lot of style issues with vesa(4).
Diffstat (limited to 'sys/dev/dpms')
-rw-r--r-- | sys/dev/dpms/dpms.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/sys/dev/dpms/dpms.c b/sys/dev/dpms/dpms.c index c0476c5..58e2f37 100644 --- a/sys/dev/dpms/dpms.c +++ b/sys/dev/dpms/dpms.c @@ -125,13 +125,13 @@ static void dpms_identify(driver_t *driver, device_t parent) { - /* - * XXX: The DPMS VBE only allows for manipulating a single - * monitor, but we don't know which one. Just attach to the - * first vgapci(4) device we encounter and hope it is the - * right one. - */ - if (devclass_get_device(dpms_devclass, 0) == NULL) + /* The DPMS VBE only allows for manipulating a single monitor. */ + if (devclass_get_device(dpms_devclass, 0) != NULL) + return; + + if ((x86bios_match_device(0xc0000, parent) && + device_get_flags(parent) != 0) || + x86bios_get_orm(0xc0000) != NULL) device_add_child(parent, "dpms", 0); } @@ -172,8 +172,11 @@ dpms_detach(device_t dev) static int dpms_suspend(device_t dev) { + struct dpms_softc *sc; - dpms_set_state(DPMS_OFF); + sc = device_get_softc(dev); + if ((sc->dpms_supported_states & DPMS_OFF) != 0) + dpms_set_state(DPMS_OFF); return (0); } @@ -192,15 +195,16 @@ dpms_call_bios(int subfunction, int *bh) { x86regs_t regs; - bzero(®s, sizeof(regs)); + if (x86bios_get_intr(0x10) == 0) + return (ENXIO); + + x86bios_init_regs(®s); regs.R_AX = VBE_DPMS_FUNCTION; regs.R_BL = subfunction; regs.R_BH = *bh; - regs.R_ES = 0; - regs.R_DI = 0; x86bios_intr(®s, 0x10); - if ((regs.R_EAX & 0xffff) != 0x004f) + if (regs.R_AX != 0x004f) return (ENXIO); *bh = regs.R_BH; |