summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2009-03-01 10:08:06 +0000
committerStefan Reinauer <stefan.reinauer@coreboot.org>2009-03-01 10:08:06 +0000
commitbe57458c77a5675d676859fb32031babb609c8a8 (patch)
treece5b4bf4983329fbabd7898c339723b53d207d71
parentcc295dd73a20f340cfab7e82a0a1d2a0a3b37edf (diff)
downloadcoreboot-be57458c77a5675d676859fb32031babb609c8a8.tar.gz
coreboot-be57458c77a5675d676859fb32031babb609c8a8.tar.bz2
coreboot-be57458c77a5675d676859fb32031babb609c8a8.zip
This patch contains the necessary changes to util/x86emu of the v3 tree to use
it in the v2 tree as well. Requires the yabel-prereq.diff patch in order to work in v2. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Joseph Smith <joe@settoplinux.org> git-svn-id: svn://coreboot.org/repository/coreboot-v3@1141 f3766cd6-281f-0410-b1cd-43a5c92072e9
-rw-r--r--util/x86emu/Config.lb17
-rw-r--r--util/x86emu/biosemu.c20
-rw-r--r--util/x86emu/pcbios/Config.lb1
-rw-r--r--util/x86emu/pcbios/pcibios.c8
-rw-r--r--util/x86emu/vm86.c15
-rw-r--r--util/x86emu/vm86_gdt.c6
-rw-r--r--util/x86emu/x86emu/Config.lb7
-rw-r--r--util/x86emu/x86emu/sys.c4
-rw-r--r--util/x86emu/yabel/Config.lb9
-rw-r--r--util/x86emu/yabel/biosemu.c10
-rw-r--r--util/x86emu/yabel/compat/Config.lb1
-rw-r--r--util/x86emu/yabel/compat/functions.c4
-rw-r--r--util/x86emu/yabel/debug.c2
-rw-r--r--util/x86emu/yabel/debug.h4
-rw-r--r--util/x86emu/yabel/device.c14
-rw-r--r--util/x86emu/yabel/device.h7
-rw-r--r--util/x86emu/yabel/interrupt.c9
-rw-r--r--util/x86emu/yabel/io.c26
-rw-r--r--util/x86emu/yabel/mem.c6
-rw-r--r--util/x86emu/yabel/pmm.c4
-rw-r--r--util/x86emu/yabel/vbe.c7
21 files changed, 165 insertions, 16 deletions
diff --git a/util/x86emu/Config.lb b/util/x86emu/Config.lb
new file mode 100644
index 000000000000..3f925f76cd83
--- /dev/null
+++ b/util/x86emu/Config.lb
@@ -0,0 +1,17 @@
+uses CONFIG_PCI_OPTION_ROM_RUN_YABEL
+uses CONFIG_PCI_OPTION_ROM_RUN_VM86
+
+if CONFIG_PCI_OPTION_ROM_RUN_YABEL
+ dir yabel
+ dir x86emu
+else
+ if CONFIG_PCI_OPTION_ROM_RUN_VM86
+ object vm86.o
+ object vm86_gdt.o
+ else
+ object biosemu.o
+ dir pcbios
+ dir x86emu
+ end
+end
+
diff --git a/util/x86emu/biosemu.c b/util/x86emu/biosemu.c
index b00b58ac0e58..5837400e52ea 100644
--- a/util/x86emu/biosemu.c
+++ b/util/x86emu/biosemu.c
@@ -20,6 +20,7 @@
* This file is part of the coreboot project.
*
* (c) Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
+ * Copyright (C) 2009 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,8 +36,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#if COREBOOT_V2
+#include <arch/io.h>
+#include <console/console.h>
+#else
#include <io.h>
#include <console.h>
+#endif
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
@@ -96,9 +102,10 @@ u8 x_inb(u16 port)
u8 val;
val = inb(port);
-
+#ifdef DEBUG
if (port != 0x40)
printk("inb(0x%04x) = 0x%02x\n", port, val);
+#endif
return val;
}
@@ -109,7 +116,9 @@ u16 x_inw(u16 port)
val = inw(port);
+#ifdef DEBUG
printk("inw(0x%04x) = 0x%04x\n", port, val);
+#endif
return val;
}
@@ -119,26 +128,34 @@ u32 x_inl(u16 port)
val = inl(port);
+#ifdef DEBUG
printk("inl(0x%04x) = 0x%08x\n", port, val);
+#endif
return val;
}
void x_outb(u16 port, u8 val)
{
+#ifdef DEBUG
if (port != 0x43)
printk("outb(0x%02x, 0x%04x)\n", val, port);
+#endif
outb(val, port);
}
void x_outw(u16 port, u16 val)
{
+#ifdef DEBUG
printk("outw(0x%04x, 0x%04x)\n", val, port);
+#endif
outw(val, port);
}
void x_outl(u16 port, u32 val)
{
+#ifdef DEBUG
printk("outl(0x%08x, 0x%04x)\n", val, port);
+#endif
outl(val, port);
}
@@ -324,6 +341,7 @@ void run_bios(struct device * dev, unsigned long addr)
unsigned short initialcs = (addr & 0xF0000) >> 4;
unsigned short initialip = (addr + 3) & 0xFFFF;
unsigned short devfn = dev->bus->secondary << 8 | dev->path.pci.devfn;
+
X86EMU_intrFuncs intFuncs[256];
X86EMU_setMemBase(0, 0x100000);
diff --git a/util/x86emu/pcbios/Config.lb b/util/x86emu/pcbios/Config.lb
new file mode 100644
index 000000000000..231b6629b542
--- /dev/null
+++ b/util/x86emu/pcbios/Config.lb
@@ -0,0 +1 @@
+object pcibios.o \ No newline at end of file
diff --git a/util/x86emu/pcbios/pcibios.c b/util/x86emu/pcbios/pcibios.c
index 42224939e62a..3ac92a68c1d7 100644
--- a/util/x86emu/pcbios/pcibios.c
+++ b/util/x86emu/pcbios/pcibios.c
@@ -35,7 +35,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#if COREBOOT_V2
+#include <console/console.h>
+#else
#include <console.h>
+#endif
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
@@ -61,7 +65,11 @@ int pcibios_handler(void)
break;
case FIND_PCI_DEVICE:
/* FixME: support SI != 0 */
+#if COREBOOT_V2
+ dev = dev_find_device(X86_DX, X86_CX, dev);
+#else
dev = dev_find_pci_device(X86_DX, X86_CX, dev);
+#endif
if (dev != 0) {
X86_BH = dev->bus->secondary;
X86_BL = dev->path.pci.devfn;
diff --git a/util/x86emu/vm86.c b/util/x86emu/vm86.c
index c097b723e464..86f856972ac7 100644
--- a/util/x86emu/vm86.c
+++ b/util/x86emu/vm86.c
@@ -4,7 +4,7 @@
* Copyright (C) 2000 Scyld Computing Corporation
* Copyright (C) 2001 University of California. LA-CC Number 01-67.
* Copyright (C) 2005 Nick.Barker9@btinternet.com
- * Copyright (C) 2007 coresystems GmbH
+ * Copyright (C) 2007-2009 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,9 +25,15 @@
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
-#include <console.h>
#include <string.h>
+#if COREBOOT_V2
+#include <console/console.h>
+#include <arch/io.h>
+#define printk(lvl, x...) printk_debug(x)
+#else
+#include <console.h>
#include <io.h>
+#endif
/* The address arguments to this function are PHYSICAL ADDRESSES */
static void real_mode_switch_call_vga(unsigned long devfn)
@@ -539,7 +545,6 @@ void run_bios(struct device *dev, unsigned long addr)
*(unsigned char *) i = 0;
}
setup_realmode_idt();
-
real_mode_switch_call_vga((dev->bus->secondary << 8) | dev->path.pci.devfn);
}
@@ -586,7 +591,11 @@ pcibios(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp,
vendorid = *pedx;
devindex = *pesi;
dev = 0;
+#if COREBOOT_V2
+ while ((dev = dev_find_device(vendorid, devid, dev))) {
+#else
while ((dev = dev_find_pci_device(vendorid, devid, dev))) {
+#endif
if (devindex <= 0)
break;
devindex--;
diff --git a/util/x86emu/vm86_gdt.c b/util/x86emu/vm86_gdt.c
index 3ffe8b181e06..3398f3120485 100644
--- a/util/x86emu/vm86_gdt.c
+++ b/util/x86emu/vm86_gdt.c
@@ -33,7 +33,11 @@ __asm__ (
" .globl gdtarg\n"
"gdtarg: \n"
" .word gdt_limit \n"
+#if COREBOOT_V2
+ " .long gdt \n"
+#else
" .long gdtptr \n"
+#endif
/* compute the table limit */
"__mygdt_limit = __mygdt_end - __mygdt - 1 \n"
@@ -74,6 +78,7 @@ __asm__ (
"__mygdt_end: \n"
+#if !COREBOOT_V2
/* FIXME: This does probably not belong here */
" .globl idtarg\n"
"idtarg:\n"
@@ -83,6 +88,7 @@ __asm__ (
"_idt:\n"
" .fill 20, 8, 0\n" // # idt is unitiailzed
"_idt_end:\n"
+#endif
/* Declare a pointer to where our idt is going to be i.e. at mem zero */
" .globl __myidt\n"
diff --git a/util/x86emu/x86emu/Config.lb b/util/x86emu/x86emu/Config.lb
new file mode 100644
index 000000000000..20e80722043d
--- /dev/null
+++ b/util/x86emu/x86emu/Config.lb
@@ -0,0 +1,7 @@
+object debug.o
+object decode.o
+object fpu.o
+object ops.o
+object ops2.o
+object prim_ops.o
+object sys.o
diff --git a/util/x86emu/x86emu/sys.c b/util/x86emu/x86emu/sys.c
index b9ca7a838752..e11f769cd3f6 100644
--- a/util/x86emu/x86emu/sys.c
+++ b/util/x86emu/x86emu/sys.c
@@ -46,7 +46,11 @@
#include "debug.h"
#include "prim_ops.h"
#if 1 /* Coreboot needs to map prinkf to printk. */
+#if COREBOOT_V2
+#include "arch/io.h"
+#else
#include "io.h"
+#endif
#else
#include <sys/io.h>
#endif
diff --git a/util/x86emu/yabel/Config.lb b/util/x86emu/yabel/Config.lb
new file mode 100644
index 000000000000..54f0f6e0fcf7
--- /dev/null
+++ b/util/x86emu/yabel/Config.lb
@@ -0,0 +1,9 @@
+object biosemu.o
+object debug.o
+object device.o
+object interrupt.o
+object io.o
+object mem.o
+object pmm.o
+object vbe.o
+dir compat
diff --git a/util/x86emu/yabel/biosemu.c b/util/x86emu/yabel/biosemu.c
index c188e2baaa10..ca486138ba99 100644
--- a/util/x86emu/yabel/biosemu.c
+++ b/util/x86emu/yabel/biosemu.c
@@ -13,13 +13,19 @@
#include <string.h>
#include <types.h>
+#if !COREBOOT_V2
#include <cpu.h>
+#endif
#include "debug.h"
#include <x86emu/x86emu.h>
#include <x86emu/regs.h>
+#if COREBOOT_V2
+#include "../x86emu/prim_ops.h"
+#else
#include <x86emu/prim_ops.h> // for push_word
+#endif
#include "biosemu.h"
#include "io.h"
@@ -28,7 +34,11 @@
#include "device.h"
#include "pmm.h"
+#if COREBOOT_V2
+#include "compat/rtas.h"
+#else
#include <rtas.h>
+#endif
#include <device/device.h>
diff --git a/util/x86emu/yabel/compat/Config.lb b/util/x86emu/yabel/compat/Config.lb
new file mode 100644
index 000000000000..919526d16b8f
--- /dev/null
+++ b/util/x86emu/yabel/compat/Config.lb
@@ -0,0 +1 @@
+object functions.o
diff --git a/util/x86emu/yabel/compat/functions.c b/util/x86emu/yabel/compat/functions.c
index 64e9d40f09f9..6702dcc76d32 100644
--- a/util/x86emu/yabel/compat/functions.c
+++ b/util/x86emu/yabel/compat/functions.c
@@ -14,8 +14,10 @@
*/
#include <types.h>
-#include <device/device.h>
+#if !COREBOOT_V2
#include <config.h>
+#endif
+#include <device/device.h>
#define VMEM_SIZE 1024 *1024 /* 1 MB */
diff --git a/util/x86emu/yabel/debug.c b/util/x86emu/yabel/debug.c
index 5d7085febeb8..c3768fcc5aa4 100644
--- a/util/x86emu/yabel/debug.c
+++ b/util/x86emu/yabel/debug.c
@@ -10,7 +10,9 @@
* IBM Corporation - initial implementation
*****************************************************************************/
+#if !COREBOOT_V2
#include <cpu.h>
+#endif
#include "debug.h"
diff --git a/util/x86emu/yabel/debug.h b/util/x86emu/yabel/debug.h
index e9317a3ed3da..de44c36b761b 100644
--- a/util/x86emu/yabel/debug.h
+++ b/util/x86emu/yabel/debug.h
@@ -19,7 +19,11 @@ extern u32 debug_flags;
extern void x86emu_dump_xregs(void);
/* printf is not available in coreboot... use printk */
+#if COREBOOT_V2
+#include <console/console.h>
+#else
#include <console.h>
+#endif
/* uurgs... yuck... x86emu/x86emu.h is redefining printk... we include it here
* and use its redefinition of printk
* TODO: FIX!!!! */
diff --git a/util/x86emu/yabel/device.c b/util/x86emu/yabel/device.c
index 602a4dec8792..515531eb0e05 100644
--- a/util/x86emu/yabel/device.c
+++ b/util/x86emu/yabel/device.c
@@ -12,13 +12,17 @@
#include "device.h"
+#if COREBOOT_V2
+#include "compat/rtas.h"
+#else
#include "rtas.h"
+#endif
#include <string.h>
#include "debug.h"
#include <device/device.h>
-#include <device/pci_ops.h>
#include <device/pci.h>
+#include <device/pci_ops.h>
#include <device/resource.h>
/* the device we are working with... */
@@ -47,6 +51,10 @@ biosemu_dev_get_addr_info(void)
struct resource *r;
u8 bus = bios_device.dev->bus->link;
u16 devfn = bios_device.dev->path.pci.devfn;
+
+ bios_device.bus = bus;
+ bios_device.devfn = devfn;
+
DEBUG_PRINTF("bus: %x, devfn: %x\n", bus, devfn);
for (i = 0; i < bios_device.dev->resources; i++) {
r = &bios_device.dev->resource[i];
@@ -388,7 +396,11 @@ biosemu_dev_init(struct device * device)
{
u8 rval = 0;
//init bios_device struct
+#if COREBOOT_V2
+ DEBUG_PRINTF("%s\n", __func__);
+#else
DEBUG_PRINTF("%s(%s)\n", __func__, device->dtsname);
+#endif
memset(&bios_device, 0, sizeof(bios_device));
#ifndef CONFIG_PCI_OPTION_ROM_RUN_YABEL
diff --git a/util/x86emu/yabel/device.h b/util/x86emu/yabel/device.h
index 5fc5c17eb6e7..c8e78db88607 100644
--- a/util/x86emu/yabel/device.h
+++ b/util/x86emu/yabel/device.h
@@ -14,11 +14,16 @@
#define DEVICE_LIB_H
#include <types.h>
+#if COREBOOT_V2
+#include <arch/byteorder.h>
+#include "compat/of.h"
+#else
#include <cpu.h>
+#include <byteorder.h>
#include "of.h"
+#endif
#include "debug.h"
-#include <byteorder.h>
// a Expansion Header Struct as defined in Plug and Play BIOS Spec 1.0a Chapter 3.2
typedef struct {
diff --git a/util/x86emu/yabel/interrupt.c b/util/x86emu/yabel/interrupt.c
index c6e8fccb63b3..39708984f6e4 100644
--- a/util/x86emu/yabel/interrupt.c
+++ b/util/x86emu/yabel/interrupt.c
@@ -10,7 +10,11 @@
* IBM Corporation - initial implementation
*****************************************************************************/
+#if COREBOOT_V2
+#include "compat/rtas.h"
+#else
#include <rtas.h>
+#endif
#include "biosemu.h"
#include "mem.h"
@@ -19,9 +23,14 @@
#include "pmm.h"
#include <x86emu/x86emu.h>
+#if COREBOOT_V2
+#include "../x86emu/prim_ops.h"
+#else
#include <x86emu/prim_ops.h>
+#endif
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
+#include <device/pci.h>
#include <device/pci_ops.h>
#endif
diff --git a/util/x86emu/yabel/io.c b/util/x86emu/yabel/io.c
index fa77b8ae4a52..a3d9f40c0c4c 100644
--- a/util/x86emu/yabel/io.c
+++ b/util/x86emu/yabel/io.c
@@ -10,16 +10,21 @@
* IBM Corporation - initial implementation
*****************************************************************************/
+#include <types.h>
+#if COREBOOT_V2
+#include "compat/rtas.h"
+#include "compat/time.h"
+#else
#include <cpu.h>
-#include "device.h"
#include "rtas.h"
-#include "debug.h"
+#include <time.h>
+#endif
#include "device.h"
-#include <types.h>
+#include "debug.h"
#include <x86emu/x86emu.h>
-#include <time.h>
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
+#include <device/pci.h>
#include <device/pci_ops.h>
#endif
@@ -359,10 +364,15 @@ pci_cfg_read(X86EMU_pioAddr addr, u8 size)
|| (devfn != bios_device.devfn)) {
// fail accesses to any device but ours...
printf
- ("Config access invalid! bus: %x, devfn: %x, offs: %x\n",
- bus, devfn, offs);
+ ("Config read access invalid! PCI device %x:%x.%x, offs: %x\n",
+ bus, devfn >> 3, devfn & 7, offs);
+#ifdef CONFIG_YABEL_NO_ILLEGAL_ACCESS
HALT_SYS();
} else {
+#else
+ }
+ {
+#endif
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
switch (size) {
case 1:
@@ -410,8 +420,8 @@ pci_cfg_write(X86EMU_pioAddr addr, u32 val, u8 size)
|| (devfn != bios_device.devfn)) {
// fail accesses to any device but ours...
printf
- ("Config access invalid! bus: %x, devfn: %x, offs: %x\n",
- bus, devfn, offs);
+ ("Config write access invalid! PCI device %x:%x.%x, offs: %x\n",
+ bus, devfn >> 3, devfn & 7, offs);
HALT_SYS();
} else {
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
diff --git a/util/x86emu/yabel/mem.c b/util/x86emu/yabel/mem.c
index 0f653e968d0c..af096bf3e5a2 100644
--- a/util/x86emu/yabel/mem.c
+++ b/util/x86emu/yabel/mem.c
@@ -11,12 +11,18 @@
*****************************************************************************/
#include <types.h>
+#if !COREBOOT_V2
#include <cpu.h>
+#endif
#include "debug.h"
#include "device.h"
#include "x86emu/x86emu.h"
#include "biosemu.h"
+#if COREBOOT_V2
+#include "compat/time.h"
+#else
#include <time.h>
+#endif
// define a check for access to certain (virtual) memory regions (interrupt handlers, BIOS Data Area, ...)
#ifdef DEBUG
diff --git a/util/x86emu/yabel/pmm.c b/util/x86emu/yabel/pmm.c
index 13b8e1a4dd4c..0186db92f566 100644
--- a/util/x86emu/yabel/pmm.c
+++ b/util/x86emu/yabel/pmm.c
@@ -10,7 +10,11 @@
****************************************************************************/
#include <x86emu/x86emu.h>
+#if COREBOOT_V2
+#include "../x86emu/prim_ops.h"
+#else
#include <x86emu/prim_ops.h>
+#endif
#include <string.h>
#include "biosemu.h"
diff --git a/util/x86emu/yabel/vbe.c b/util/x86emu/yabel/vbe.c
index 13612dea1937..5fbf36c63f88 100644
--- a/util/x86emu/yabel/vbe.c
+++ b/util/x86emu/yabel/vbe.c
@@ -11,15 +11,20 @@
*****************************************************************************/
#include <string.h>
-
#include <types.h>
+#if !COREBOOT_V2
#include <cpu.h>
+#endif
#include "debug.h"
#include <x86emu/x86emu.h>
#include <x86emu/regs.h>
+#if COREBOOT_V2
+#include "../x86emu/prim_ops.h"
+#else
#include <x86emu/prim_ops.h> // for push_word
+#endif
#include "biosemu.h"
#include "io.h"