]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
bios_emulator: Allow x86 to use the emulator
authorSimon Glass <sjg@chromium.org>
Sat, 15 Nov 2014 03:56:39 +0000 (20:56 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 25 Nov 2014 14:11:16 +0000 (07:11 -0700)
There is an implicit assumption that x86 machines want to use raw I/O in the
BIOS emulator, but this should be selectable. Add an CONFIG_X86EMU_RAW_IO
option to control it instead.

Also fix a few bugs which cause warnings on x86 and adjust the Makefile to
remove the assumption that only PowerPC uses the emulator.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/bios_emulator/Makefile
drivers/bios_emulator/besys.c
drivers/bios_emulator/include/x86emu.h
drivers/bios_emulator/x86emu/debug.c

index e56356ee867f7b9d3e4ffffebe69941bd3118054..2ba43ac731842f0f1367ba5d604e1ba58f32c798 100644 (file)
@@ -9,4 +9,4 @@ obj-y = atibios.o biosemu.o besys.o bios.o \
        $(X86DIR)/debug.o
 
 ccflags-y := -I$(srctree)/$(src) -I$(srctree)/$(src)/include \
-       -D__PPC__  -D__BIG_ENDIAN__
+       $(if $(CONFIG_PPC),-D__PPC__  -D__BIG_ENDIAN__)
index ad88a53f0c435683dd4bd521e1df26aab9c917d9..70c472a16bbde97dc68160008e0a41f0e544207b 100644 (file)
@@ -54,7 +54,7 @@
 
 /*------------------------- Global Variables ------------------------------*/
 
-#ifndef __i386__
+#ifndef CONFIG_X86EMU_RAW_IO
 static char *BE_biosDate = "08/14/99";
 static u8 BE_model = 0xFC;
 static u8 BE_submodel = 0x00;
@@ -80,16 +80,18 @@ static u8 *BE_memaddr(u32 addr)
        if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) {
                return (u8*)(_BE_env.biosmem_base + addr - 0xC0000);
        } else if (addr > _BE_env.biosmem_limit && addr < 0xD0000) {
-               DB(printf("BE_memaddr: address %#lx may be invalid!\n", addr);)
-               return M.mem_base;
+               DB(printf("BE_memaddr: address %#lx may be invalid!\n",
+                         (ulong)addr);)
+               return (u8 *)M.mem_base;
        } else if (addr >= 0xA0000 && addr <= 0xBFFFF) {
                return (u8*)(_BE_env.busmem_base + addr - 0xA0000);
        }
-#ifdef __i386__
+#ifdef CONFIG_X86EMU_RAW_IO
        else if (addr >= 0xD0000 && addr <= 0xFFFFF) {
                /* We map the real System BIOS directly on real PC's */
-               DB(printf("BE_memaddr: System BIOS address %#lx\n", addr);)
-                   return _BE_env.busmem_base + addr - 0xA0000;
+               DB(printf("BE_memaddr: System BIOS address %#lx\n",
+                         (ulong)addr);)
+                   return (u8 *)_BE_env.busmem_base + addr - 0xA0000;
        }
 #else
        else if (addr >= 0xFFFF5 && addr < 0xFFFFE) {
@@ -108,10 +110,10 @@ static u8 *BE_memaddr(u32 addr)
 #endif
        else if (addr > M.mem_size - 1) {
                HALT_SYS();
-               return M.mem_base;
+               return (u8 *)M.mem_base;
        }
 
-       return M.mem_base + addr;
+       return (u8 *)(M.mem_base + addr);
 }
 
 /****************************************************************************
@@ -230,7 +232,7 @@ void X86API BE_wrl(u32 addr, u32 val)
        }
 }
 
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
 
 /* For Non-Intel machines we may need to emulate some I/O port accesses that
  * the BIOS may try to access, such as the PCI config registers.
@@ -560,7 +562,7 @@ u8 X86API BE_inb(X86EMU_pioAddr port)
 {
        u8 val = 0;
 
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
        if (IS_VGA_PORT(port)){
                /*seems reading port 0x3c3 return the high 16 bit of io port*/
                if(port == 0x3c3)
@@ -601,7 +603,7 @@ u16 X86API BE_inw(X86EMU_pioAddr port)
 {
        u16 val = 0;
 
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
        if (IS_PCI_PORT(port))
                val = PCI_inp(port, REG_READ_WORD);
        else if (port < 0x100) {
@@ -629,7 +631,7 @@ u32 X86API BE_inl(X86EMU_pioAddr port)
 {
        u32 val = 0;
 
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
        if (IS_PCI_PORT(port))
                val = PCI_inp(port, REG_READ_DWORD);
        else if (port < 0x100) {
@@ -652,7 +654,7 @@ through to the real hardware if we don't need to special case it.
 ****************************************************************************/
 void X86API BE_outb(X86EMU_pioAddr port, u8 val)
 {
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
        if (IS_VGA_PORT(port))
                VGA_outpb(port, val);
        else if (IS_TIMER_PORT(port))
@@ -683,7 +685,7 @@ through to the real hardware if we don't need to special case it.
 ****************************************************************************/
 void X86API BE_outw(X86EMU_pioAddr port, u16 val)
 {
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
                if (IS_VGA_PORT(port)) {
                        VGA_outpb(port, val);
                        VGA_outpb(port + 1, val >> 8);
@@ -710,7 +712,7 @@ through to the real hardware if we don't need to special case it.
 ****************************************************************************/
 void X86API BE_outl(X86EMU_pioAddr port, u32 val)
 {
-#if defined(DEBUG) || !defined(__i386__)
+#if !defined(CONFIG_X86EMU_RAW_IO)
        if (IS_PCI_PORT(port))
                PCI_outp(port, val, REG_WRITE_DWORD);
        else if (port < 0x100) {
index a70a76874b3587a8c38b18e785a49bc056699172..278f669a4bc403262575cb867eb817debdf3d579 100644 (file)
@@ -53,9 +53,9 @@ typedef u16 X86EMU_pioAddr;
 
 /*---------------------- Macros and type definitions ----------------------*/
 
-#if defined (CONFIG_ARM)
+#if defined(CONFIG_ARM)
 #define GAS_LINE_COMMENT       "@"
-#elif defined(CONFIG_MIPS) || defined(CONFIG_PPC)
+#elif defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_X86)
 #define GAS_LINE_COMMENT       "#"
 #elif defined (CONFIG_SH)
 #define GAS_LINE_COMMENT       "!"
index 2fa8050f6a52535fdf47d1f0680b626df2f382a8..2ec64c24ce794b4992c2435675bd47b23c9f8336 100644 (file)
@@ -211,9 +211,7 @@ void X86EMU_dump_memory(u16 seg, u16 off, u32 amt)
        u32 start = off & 0xfffffff0;
        u32 end = (off + 16) & 0xfffffff0;
        u32 i;
-       u32 current;
 
-       current = start;
        while (end <= off + amt) {
                printk("%04x:%04x ", seg, start);
                for (i = start; i < off; i++)
@@ -229,7 +227,7 @@ void X86EMU_dump_memory(u16 seg, u16 off, u32 amt)
 void x86emu_single_step(void)
 {
        char s[1024];
-       int ps[10];
+        int ps[10];
        int ntok;
        int cmd;
        int done;
@@ -238,8 +236,6 @@ void x86emu_single_step(void)
        static int breakpoint;
        static int noDecode = 1;
 
-       char *p;
-
        if (DEBUG_BREAK()) {
                if (M.x86.saved_ip != breakpoint) {
                        return;
@@ -255,6 +251,8 @@ void x86emu_single_step(void)
        offset = M.x86.saved_ip;
        while (!done) {
                printk("-");
+               ps[1] = 0; /* Avoid dodgy compiler warnings */
+               ps[2] = 0;
                cmd = x86emu_parse_line(s, ps, &ntok);
                switch (cmd) {
                case 'u':