summaryrefslogtreecommitdiffstats
path: root/sys/contrib/x86emu
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-10-19 20:58:10 +0000
committerjkim <jkim@FreeBSD.org>2009-10-19 20:58:10 +0000
commit99279734b833c18edb9cfc47db1c920327e97fde (patch)
treed4a62e4e5d88debc2e3a4761c8ceea077f9a2ac1 /sys/contrib/x86emu
parent8f9031d9fe5f0fb11cd72dd010fbdac9560df819 (diff)
downloadFreeBSD-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/contrib/x86emu')
-rw-r--r--sys/contrib/x86emu/x86emu_util.c211
1 files changed, 0 insertions, 211 deletions
diff --git a/sys/contrib/x86emu/x86emu_util.c b/sys/contrib/x86emu/x86emu_util.c
deleted file mode 100644
index 4172f94..0000000
--- a/sys/contrib/x86emu/x86emu_util.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* $OpenBSD: x86emu_util.c,v 1.5 2009/06/18 14:19:21 pirofti Exp $ */
-/* $NetBSD: x86emu_util.c,v 1.2 2007/12/04 17:32:22 joerg Exp $ */
-
-/*
- *
- * Realmode X86 Emulator Library
- *
- * Copyright (C) 1996-1999 SciTech Software, Inc.
- * Copyright (C) David Mosberger-Tang
- * Copyright (C) 1999 Egbert Eich
- * Copyright (C) 2007 Joerg Sonnenberger
- *
- * ========================================================================
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of the authors not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. The authors makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/endian.h>
-
-#include <contrib/x86emu/x86emu.h>
-#include <contrib/x86emu/x86emu_regs.h>
-
-
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- *
- * RETURNS:
- * Byte value read from emulator memory.
- *
- * REMARKS:
- * Reads a byte value from the emulator memory.
- */
-static uint8_t
-rdb(struct x86emu *emu, uint32_t addr)
-{
- if (addr > emu->mem_size - 1)
- x86emu_halt_sys(emu);
- return emu->mem_base[addr];
-}
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- *
- * RETURNS:
- * Word value read from emulator memory.
- *
- * REMARKS:
- * Reads a word value from the emulator memory.
- */
-static uint16_t
-rdw(struct x86emu *emu, uint32_t addr)
-{
- if (addr > emu->mem_size - 2)
- x86emu_halt_sys(emu);
-#ifdef __STRICT_ALIGNMENT
- if (addr & 1) {
- u_int8_t *a = emu->mem_base + addr;
- u_int16_t r;
-
- r = ((*(a + 0) << 0) & 0x00ff) |
- ((*(a + 1) << 8) & 0xff00);
- return r;
- } else
- return le32toh(*(u_int32_t *)(emu->mem_base + addr));
-#else
- return le16toh(*(u_int16_t *)(emu->mem_base + addr));
-#endif
-}
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- *
- * RETURNS:
- * Long value read from emulator memory.
- * REMARKS:
- * Reads a long value from the emulator memory.
- */
-static uint32_t
-rdl(struct x86emu *emu, uint32_t addr)
-{
- if (addr > emu->mem_size - 4)
- x86emu_halt_sys(emu);
-#ifdef __STRICT_ALIGNMENT
- if (addr & 3) {
- u_int8_t *a = emu->mem_base + addr;
- u_int32_t r;
-
- r = ((*(a + 0) << 0) & 0x000000ff) |
- ((*(a + 1) << 8) & 0x0000ff00) |
- ((*(a + 2) << 16) & 0x00ff0000) |
- ((*(a + 3) << 24) & 0xff000000);
- return r;
- } else
- return le32toh(*(u_int32_t *)(emu->mem_base + addr));
-#else
- return le32toh(*(u_int32_t *)(emu->mem_base + addr));
-#endif
-}
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- * val - Value to store
- *
- * REMARKS:
- * Writes a byte value to emulator memory.
- */
-static void
-wrb(struct x86emu *emu, uint32_t addr, uint8_t val)
-{
- if (addr > emu->mem_size - 1)
- x86emu_halt_sys(emu);
- emu->mem_base[addr] = val;
-}
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- * val - Value to store
- *
- * REMARKS:
- * Writes a word value to emulator memory.
- */
-static void
-wrw(struct x86emu *emu, uint32_t addr, uint16_t val)
-{
- if (addr > emu->mem_size - 2)
- x86emu_halt_sys(emu);
-#ifdef __STRICT_ALIGNMENT
- if (addr & 1) {
- u_int8_t *a = emu->mem_base + addr;
-
- *((a + 0)) = (val >> 0) & 0xff;
- *((a + 1)) = (val >> 8) & 0xff;
- } else
- *((u_int16_t *)(emu->mem_base + addr)) = htole16(val);
-#else
- *((u_int16_t *)(emu->mem_base + addr)) = htole16(val);
-#endif
-}
-
-/*
- * PARAMETERS:
- * addr - Emulator memory address to read
- * val - Value to store
- *
- * REMARKS:
- * Writes a long value to emulator memory.
- */
-static void
-wrl(struct x86emu *emu, uint32_t addr, uint32_t val)
-{
- if (addr > emu->mem_size - 4)
- x86emu_halt_sys(emu);
-#ifdef __STRICT_ALIGNMENT
- if (addr & 3) {
- u_int8_t *a = emu->mem_base + addr;
-
- *((a + 0) = (val >> 0) & 0xff;
- *((a + 1) = (val >> 8) & 0xff;
- *((a + 2) = (val >> 16) & 0xff;
- *((a + 3) = (val >> 24) & 0xff;
- } else
- *((u_int32_t *)(emu->mem_base + addr)) = htole32(val);
-#else
- *((u_int32_t *)(emu->mem_base + addr)) = htole32(val);
-#endif
-}
-
-/* Setup */
-
-void
-x86emu_init_default(struct x86emu *emu)
-{
- int i;
-
- emu->emu_rdb = rdb;
- emu->emu_rdw = rdw;
- emu->emu_rdl = rdl;
- emu->emu_wrb = wrb;
- emu->emu_wrw = wrw;
- emu->emu_wrl = wrl;
-
- for (i = 0; i < 256; i++)
- emu->_x86emu_intrTab[i] = NULL;
-}
OpenPOWER on IntegriCloud