YABEL update
[coreboot.git] / util / x86emu / yabel / biosemu.c
index 74772e86429bfd45d8e8731b3a8ebac7d46d3383..09a98b50b6f9c698eb7abb2fa968845736ef0119 100644 (file)
 #include <string.h>
 
 #include <types.h>
-#ifndef CONFIG_COREBOOT_V2
-#include <cpu.h>
-#endif
 
 #include "debug.h"
 
 #include <x86emu/x86emu.h>
 #include <x86emu/regs.h>
-#ifdef CONFIG_COREBOOT_V2
 #include "../x86emu/prim_ops.h"
-#else
-#include <x86emu/prim_ops.h>   // for push_word
-#endif
 
 #include "biosemu.h"
 #include "io.h"
 #include "device.h"
 #include "pmm.h"
 
-#ifdef CONFIG_COREBOOT_V2
 #include "compat/rtas.h"
-#else
-#include <rtas.h>
-#endif
 
 #include <device/device.h>
 
@@ -56,8 +45,6 @@ static X86EMU_pioFuncs my_pio_funcs = {
 /* interrupt function override array (see biosemu.h) */
 yabel_handleIntFunc yabel_intFuncArray[256];
 
-void dump(u8 * addr, u32 len);
-
 /* main entry into YABEL biosemu, arguments are:
  * *biosmem = pointer to virtual memory
  * biosmem_size = size of the virtual memory
@@ -70,7 +57,7 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
 {
        u8 *rom_image;
        int i = 0;
-#ifdef CONFIG_DEBUG
+#ifdef DEBUG
        debug_flags = 0;//DEBUG_PRINT_INT10 | DEBUG_PNP | DEBUG_INTR | DEBUG_CHECK_VMEM_ACCESS | DEBUG_MEM | DEBUG_IO;
                // | DEBUG_CHECK_VMEM_ACCESS | DEBUG_MEM | DEBUG_IO;
                // | DEBUG_TRACE_X86EMU | DEBUG_JMP;
@@ -99,10 +86,15 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
 
        // in case we jump somewhere unexpected, or execution is finished,
        // fill the biosmem with hlt instructions (0xf4)
-       memset(biosmem, 0xf4, biosmem_size);
+       // But we have to be careful: If biosmem is 0x00000000 we're running
+       // in the lower 1MB and we must not wipe memory like that.
+       if (biosmem) {
+               DEBUG_PRINTF("Clearing biosmem\n");
+               memset(biosmem, 0xf4, biosmem_size);
+       }
+
+       X86EMU_setMemBase(biosmem, biosmem_size);
 
-       M.mem_base = (long) biosmem;
-       M.mem_size = biosmem_size;
        DEBUG_PRINTF("membase set: %08x, size: %08x\n", (int) M.mem_base,
                     (int) M.mem_size);
 
@@ -265,7 +257,7 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
        CHECK_DBG(DEBUG_TRACE_X86EMU) {
                X86EMU_trace_on();
        } else {
-#ifdef CONFIG_DEBUG
+#ifdef DEBUG
                M.x86.debug |= DEBUG_SAVE_IP_CS_F;
                M.x86.debug |= DEBUG_DECODE_F;
                M.x86.debug |= DEBUG_DECODE_NOPRINT_F;
@@ -286,7 +278,7 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
         * some boot device status in AX (see PNP BIOS Spec Section 3.3
         */
        DEBUG_PRINTF_CS_IP("Option ROM Exit Status: %04x\n", M.x86.R_AX);
-#ifdef CONFIG_DEBUG
+#ifdef DEBUG
        DEBUG_PRINTF("Exit Status Decode:\n");
        if (M.x86.R_AX & 0x100) {       // bit 8
                DEBUG_PRINTF