summaryrefslogtreecommitdiff
path: root/util/x86emu
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2010-03-05 10:03:50 +0000
committerStefan Reinauer <stepan@openbios.org>2010-03-05 10:03:50 +0000
commit01ce601bdb4e664b502e8816a3e13e7b1d275e50 (patch)
treea79fb9dd4ab50ce103fb6d20177460c96445bdc9 /util/x86emu
parent5fa76e2864fada5a87d210a0b994a55f8a235024 (diff)
This patch is from 2009-10-20
Convert all DEBUG_SMBUS, DEBUG_SMI, and DEBUG_RAM_SETUP custom and local #defines into globally configurable kconfig options (and Options.lb options for as long as newconfig still exists) which can be enabled by the user in the "Debugging" menu. The respective menu items only appear if a board is selected where the chipset code actually provides such additional DEBUG output. All three variables default to 0 / off for now. Also, drop a small chunk of dead/useless code in the src/northbridge/via/cn700/raminit.c file, which would otherwise break compilation. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Reworked to still apply to trunk, added X86EMU_DEBUG (and make the x86emu/yabel code only work printf instead of a redefined version of printk and Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5185 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/x86emu')
-rw-r--r--util/x86emu/include/x86emu/fpu_regs.h2
-rw-r--r--util/x86emu/include/x86emu/regs.h9
-rw-r--r--util/x86emu/include/x86emu/x86emu.h18
-rw-r--r--util/x86emu/x86.c2
-rw-r--r--util/x86emu/x86_interrupts.c1
-rw-r--r--util/x86emu/x86emu/debug.c147
-rw-r--r--util/x86emu/x86emu/debug.h41
-rw-r--r--util/x86emu/x86emu/decode.c8
-rw-r--r--util/x86emu/x86emu/fpu.c16
-rw-r--r--util/x86emu/x86emu/ops.c6
-rw-r--r--util/x86emu/x86emu/ops2.c6
-rw-r--r--util/x86emu/x86emu/sys.c34
-rw-r--r--util/x86emu/x86emu/x86emui.h2
-rw-r--r--util/x86emu/yabel/biosemu.c62
-rw-r--r--util/x86emu/yabel/biosemu.h3
-rw-r--r--util/x86emu/yabel/compat/functions.c11
-rw-r--r--util/x86emu/yabel/debug.h17
-rw-r--r--util/x86emu/yabel/device.c14
-rw-r--r--util/x86emu/yabel/interrupt.c2
-rw-r--r--util/x86emu/yabel/io.c31
-rw-r--r--util/x86emu/yabel/mem.c8
-rw-r--r--util/x86emu/yabel/vbe.c52
22 files changed, 235 insertions, 257 deletions
diff --git a/util/x86emu/include/x86emu/fpu_regs.h b/util/x86emu/include/x86emu/fpu_regs.h
index 56e9a04d75..7c7df8562b 100644
--- a/util/x86emu/include/x86emu/fpu_regs.h
+++ b/util/x86emu/include/x86emu/fpu_regs.h
@@ -102,7 +102,7 @@ struct x86_fpu_registers {
#endif /* X86_FPU_SUPPORT */
-#ifdef DEBUG
+#if CONFIG_X86EMU_DEBUG
# define DECODE_PRINTINSTR32(t,mod,rh,rl) \
DECODE_PRINTF(t[(mod<<3)+(rh)]);
# define DECODE_PRINTINSTR256(t,mod,rh,rl) \
diff --git a/util/x86emu/include/x86emu/regs.h b/util/x86emu/include/x86emu/regs.h
index df5c6b2d90..516b2ea836 100644
--- a/util/x86emu/include/x86emu/regs.h
+++ b/util/x86emu/include/x86emu/regs.h
@@ -279,7 +279,7 @@ typedef struct {
u32 mode;
volatile int intr; /* mask of pending interrupts */
volatile int debug;
-#ifdef DEBUG
+#if CONFIG_X86EMU_DEBUG
int check;
u16 saved_ip;
u16 saved_cs;
@@ -365,13 +365,6 @@ extern X86EMU_sysEnv _X86EMU_env;
#define X86_CH M.x86.R_CH
#define X86_DH M.x86.R_DH
-
-/*-------------------------- Function Prototypes --------------------------*/
-
-/* Function to log information at runtime */
-
-//void printk(const char *fmt, ...);
-
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
diff --git a/util/x86emu/include/x86emu/x86emu.h b/util/x86emu/include/x86emu/x86emu.h
index 22e08a9542..493e494927 100644
--- a/util/x86emu/include/x86emu/x86emu.h
+++ b/util/x86emu/include/x86emu/x86emu.h
@@ -42,27 +42,15 @@
#ifndef __X86EMU_X86EMU_H
#define __X86EMU_X86EMU_H
-/* FIXME: redefine printk for the moment */
#include <stddef.h>
#include <console/console.h>
-#undef printk
-#define printk(x...) do_printk(BIOS_DEBUG, x)
-#if defined(CONFIG_YABEL_DEBUG_FLAGS) && (CONFIG_YABEL_DEBUG_FLAGS != 0)
+#if CONFIG_X86EMU_DEBUG
#define DEBUG
-#else
-#undef DEBUG
#endif
-#ifdef SCITECH
-#include "scitech.h"
-#define X86API _ASMAPI
-#define X86APIP _ASMAPIP
-typedef int X86EMU_pioAddr;
-#else
#include "types.h"
#define X86API
#define X86APIP *
-#endif
#include "regs.h"
/*---------------------- Macros and type definitions ----------------------*/
@@ -166,9 +154,9 @@ void X86EMU_setMemBase(void *base, size_t size);
void X86EMU_exec(void);
void X86EMU_halt_sys(void);
-#ifdef DEBUG
+#if CONFIG_X86EMU_DEBUG
#define HALT_SYS() \
- printk("halt_sys: in %s\n", __func__); \
+ printf("halt_sys: in %s\n", __func__); \
X86EMU_halt_sys();
#else
#define HALT_SYS() X86EMU_halt_sys()
diff --git a/util/x86emu/x86.c b/util/x86emu/x86.c
index 5644648b84..0690b71681 100644
--- a/util/x86emu/x86.c
+++ b/util/x86emu/x86.c
@@ -23,8 +23,6 @@
#include <arch/io.h>
#include <arch/registers.h>
#include <console/console.h>
-#define printk(x...) do_printk(x)
-
#include <arch/interrupt.h>
#define REALMODE_BASE ((void *)0x600)
diff --git a/util/x86emu/x86_interrupts.c b/util/x86emu/x86_interrupts.c
index a21a0ab988..95964f89f2 100644
--- a/util/x86emu/x86_interrupts.c
+++ b/util/x86emu/x86_interrupts.c
@@ -26,7 +26,6 @@
#include <console/console.h>
#include <arch/io.h>
#include <arch/registers.h>
-#define printk(x...) do_printk(x)
enum {
PCIBIOS_CHECK = 0xb101,
diff --git a/util/x86emu/x86emu/debug.c b/util/x86emu/x86emu/debug.c
index 026c03fddd..b3f4b6ebfb 100644
--- a/util/x86emu/x86emu/debug.c
+++ b/util/x86emu/x86emu/debug.c
@@ -38,7 +38,6 @@
****************************************************************************/
#include "x86emui.h"
-// #include <stdarg.h>
/*----------------------------- Implementation ----------------------------*/
@@ -59,7 +58,7 @@ void X86EMU_trace_regs (void)
}
}
if (DEBUG_DECODE() && ! DEBUG_DECODE_NOPRINT()) {
- printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
+ printf("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
print_decoded_instruction();
}
@@ -78,7 +77,7 @@ void x86emu_just_disassemble (void)
* This routine called if the flag DEBUG_DISASSEMBLE is set kind
* of a hack!
*/
- printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
+ printf("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
print_decoded_instruction();
}
@@ -162,13 +161,13 @@ void x86emu_inc_decoded_inst_len (int x)
M.x86.enc_pos += x;
}
-void x86emu_decode_printf (char *x)
+void x86emu_decode_printf (const char *x)
{
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
M.x86.enc_str_pos += strlen(x);
}
-void x86emu_decode_printf2 (char *x, int y)
+void x86emu_decode_printf2 (const char *x, int y)
{
char temp[100];
sprintf(temp,x,y);
@@ -189,12 +188,12 @@ static void print_encoded_bytes (u16 s, u16 o)
for (i=0; i< M.x86.enc_pos; i++) {
sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i));
}
- printk("%-20s ",buf1);
+ printf("%-20s ",buf1);
}
static void print_decoded_instruction (void)
{
- printk("%s", M.x86.decoded_buf);
+ printf("%s", M.x86.decoded_buf);
}
void x86emu_print_int_vect (u16 iv)
@@ -204,7 +203,7 @@ void x86emu_print_int_vect (u16 iv)
if (iv > 256) return;
seg = fetch_data_word_abs(0,iv*4);
off = fetch_data_word_abs(0,iv*4+2);
- printk("%04x:%04x ", seg, off);
+ printf("%04x:%04x ", seg, off);
}
void X86EMU_dump_memory (u16 seg, u16 off, u32 amt)
@@ -216,12 +215,12 @@ void X86EMU_dump_memory (u16 seg, u16 off, u32 amt)
current = start;
while (end <= off + amt) {
- printk("%04x:%04x ", seg, start);
+ printf("%04x:%04x ", seg, start);
for (i=start; i< off; i++)
- printk(" ");
+ printf(" ");
for ( ; i< end; i++)
- printk("%02x ", fetch_data_byte_abs(seg,i));
- printk("\n");
+ printf("%02x ", fetch_data_byte_abs(seg,i));
+ printf("\n");
start = end;
end = start + 16;
}
@@ -256,7 +255,7 @@ void x86emu_single_step (void)
done=0;
offset = M.x86.saved_ip;
while (!done) {
- printk("-");
+ printf("-");
p = fgets(s, 1023, stdin);
cmd = parse_line(s, ps, &ntok);
switch(cmd) {
@@ -310,7 +309,7 @@ void x86emu_single_step (void)
return;
case 'P':
noDecode = (noDecode)?0:1;
- printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE");
+ printf("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE");
break;
case 't':
case 0:
@@ -368,68 +367,68 @@ int parse_line (char *s, int *ps, int *n)
void x86emu_dump_regs (void)
{
- printk("\tAX=%04x ", M.x86.R_AX );
- printk("BX=%04x ", M.x86.R_BX );
- printk("CX=%04x ", M.x86.R_CX );
- printk("DX=%04x ", M.x86.R_DX );
- printk("SP=%04x ", M.x86.R_SP );
- printk("BP=%04x ", M.x86.R_BP );
- printk("SI=%04x ", M.x86.R_SI );
- printk("DI=%04x\n", M.x86.R_DI );
- printk("\tDS=%04x ", M.x86.R_DS );
- printk("ES=%04x ", M.x86.R_ES );
- printk("SS=%04x ", M.x86.R_SS );
- printk("CS=%04x ", M.x86.R_CS );
- printk("IP=%04x ", M.x86.R_IP );
- if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
- else printk("NV ");
- if (ACCESS_FLAG(F_DF)) printk("DN ");
- else printk("UP ");
- if (ACCESS_FLAG(F_IF)) printk("EI ");
- else printk("DI ");
- if (ACCESS_FLAG(F_SF)) printk("NG ");
- else printk("PL ");
- if (ACCESS_FLAG(F_ZF)) printk("ZR ");
- else printk("NZ ");
- if (ACCESS_FLAG(F_AF)) printk("AC ");
- else printk("NA ");
- if (ACCESS_FLAG(F_PF)) printk("PE ");
- else printk("PO ");
- if (ACCESS_FLAG(F_CF)) printk("CY ");
- else printk("NC ");
- printk("\n");
+ printf("\tAX=%04x ", M.x86.R_AX );
+ printf("BX=%04x ", M.x86.R_BX );
+ printf("CX=%04x ", M.x86.R_CX );
+ printf("DX=%04x ", M.x86.R_DX );
+ printf("SP=%04x ", M.x86.R_SP );
+ printf("BP=%04x ", M.x86.R_BP );
+ printf("SI=%04x ", M.x86.R_SI );
+ printf("DI=%04x\n", M.x86.R_DI );
+ printf("\tDS=%04x ", M.x86.R_DS );
+ printf("ES=%04x ", M.x86.R_ES );
+ printf("SS=%04x ", M.x86.R_SS );
+ printf("CS=%04x ", M.x86.R_CS );
+ printf("IP=%04x ", M.x86.R_IP );
+ if (ACCESS_FLAG(F_OF)) printf("OV "); /* CHECKED... */
+ else printf("NV ");
+ if (ACCESS_FLAG(F_DF)) printf("DN ");
+ else printf("UP ");
+ if (ACCESS_FLAG(F_IF)) printf("EI ");
+ else printf("DI ");
+ if (ACCESS_FLAG(F_SF)) printf("NG ");
+ else printf("PL ");
+ if (ACCESS_FLAG(F_ZF)) printf("ZR ");
+ else printf("NZ ");
+ if (ACCESS_FLAG(F_AF)) printf("AC ");
+ else printf("NA ");
+ if (ACCESS_FLAG(F_PF)) printf("PE ");
+ else printf("PO ");
+ if (ACCESS_FLAG(F_CF)) printf("CY ");
+ else printf("NC ");
+ printf("\n");
}
void x86emu_dump_xregs (void)
{
- printk("\tEAX=%08x ", M.x86.R_EAX );
- printk("EBX=%08x ", M.x86.R_EBX );
- printk("ECX=%08x ", M.x86.R_ECX );
- printk("EDX=%08x \n", M.x86.R_EDX );
- printk("\tESP=%08x ", M.x86.R_ESP );
- printk("EBP=%08x ", M.x86.R_EBP );
- printk("ESI=%08x ", M.x86.R_ESI );
- printk("EDI=%08x\n", M.x86.R_EDI );
- printk("\tDS=%04x ", M.x86.R_DS );
- printk("ES=%04x ", M.x86.R_ES );
- printk("SS=%04x ", M.x86.R_SS );
- printk("CS=%04x ", M.x86.R_CS );
- printk("EIP=%08x\n\t", M.x86.R_EIP );
- if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
- else printk("NV ");
- if (ACCESS_FLAG(F_DF)) printk("DN ");
- else printk("UP ");
- if (ACCESS_FLAG(F_IF)) printk("EI ");
- else printk("DI ");
- if (ACCESS_FLAG(F_SF)) printk("NG ");
- else printk("PL ");
- if (ACCESS_FLAG(F_ZF)) printk("ZR ");
- else printk("NZ ");
- if (ACCESS_FLAG(F_AF)) printk("AC ");
- else printk("NA ");
- if (ACCESS_FLAG(F_PF)) printk("PE ");
- else printk("PO ");
- if (ACCESS_FLAG(F_CF)) printk("CY ");
- else printk("NC ");
- printk("\n");
+ printf("\tEAX=%08x ", M.x86.R_EAX );
+ printf("EBX=%08x ", M.x86.R_EBX );
+ printf("ECX=%08x ", M.x86.R_ECX );
+ printf("EDX=%08x \n", M.x86.R_EDX );
+ printf("\tESP=%08x ", M.x86.R_ESP );
+ printf("EBP=%08x ", M.x86.R_EBP );
+ printf("ESI=%08x ", M.x86.R_ESI );
+ printf("EDI=%08x\n", M.x86.R_EDI );
+ printf("\tDS=%04x ", M.x86.R_DS );
+ printf("ES=%04x ", M.x86.R_ES );
+ printf("SS=%04x ", M.x86.R_SS );
+ printf("CS=%04x ", M.x86.R_CS );
+ printf("EIP=%08x\n\t", M.x86.R_EIP );
+ if (ACCESS_FLAG(F_OF)) printf("OV "); /* CHECKED... */
+ else printf("NV ");
+ if (ACCESS_FLAG(F_DF)) printf("DN ");
+ else printf("UP ");
+ if (ACCESS_FLAG(F_IF)) printf("EI ");
+ else printf("DI ");
+ if (ACCESS_FLAG(F_SF)) printf("NG ");
+ else printf("PL ");
+ if (ACCESS_FLAG(F_ZF)) printf("ZR ");
+ else printf("NZ ");
+ if (ACCESS_FLAG(F_AF)) printf("AC ");
+ else printf("NA ");
+ if (ACCESS_FLAG(F_PF)) printf("PE ");
+ else printf("PO ");
+ if (ACCESS_FLAG(F_CF)) printf("CY ");
+ else printf("NC ");
+ printf("\n");
}
diff --git a/util/x86emu/x86emu/debug.h b/util/x86emu/x86emu/debug.h
index f6bab3cf78..7aac995cc3 100644
--- a/util/x86emu/x86emu/debug.h
+++ b/util/x86emu/x86emu/debug.h
@@ -40,10 +40,11 @@
#ifndef __X86EMU_DEBUG_H
#define __X86EMU_DEBUG_H
-//#define DEBUG 0
-//#undef DEBUG
/*---------------------- Macros and type definitions ----------------------*/
+/* printf is not available in coreboot... use printk */
+#define printf(x...) printk(BIOS_DEBUG, x)
+
/* checks to be enabled for "runtime" */
#define CHECK_IP_FETCH_F 0x1
@@ -172,17 +173,17 @@
if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) \
- printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x);
+ printf("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x);
# define RETURN_TRACE(u,v,w,x,s) \
if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) \
- printk("%04x:%04x: RET %s %04x:%04x\n",u,v,s,w,x);
+ printf("%04x:%04x: RET %s %04x:%04x\n",u,v,s,w,x);
# define JMP_TRACE(u,v,w,x,s) \
if (DEBUG_TRACEJMPREGS()) \
x86emu_dump_regs(); \
if (DEBUG_TRACEJMP()) \
- printk("%04x:%04x: JMP %s%04x:%04x\n", u , v, s, w, x);
+ printf("%04x:%04x: JMP %s%04x:%04x\n", u , v, s, w, x);
#else
# define CALL_TRACE(u,v,w,x,s)
# define RETURN_TRACE(u,v,w,x,s)
@@ -201,20 +202,22 @@
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
-extern void x86emu_inc_decoded_inst_len (int x);
-extern void x86emu_decode_printf (char *x);
-extern void x86emu_decode_printf2 (char *x, int y);
-extern void x86emu_just_disassemble (void);
-extern void x86emu_single_step (void);
-extern void x86emu_end_instr (void);
-extern void x86emu_dump_regs (void);
-extern void x86emu_dump_xregs (void);
-extern void x86emu_print_int_vect (u16 iv);
-extern void x86emu_instrument_instruction (void);
-extern void x86emu_check_ip_access (void);
-extern void x86emu_check_sp_access (void);
-extern void x86emu_check_mem_access (u32 p);
-extern void x86emu_check_data_access (uint s, uint o);
+void x86emu_inc_decoded_inst_len (int x);
+void x86emu_decode_printf (const char *x);
+void x86emu_decode_printf2 (const char *x, int y);
+void x86emu_just_disassemble (void);
+void x86emu_single_step (void);
+void x86emu_end_instr (void);
+void x86emu_dump_regs (void);
+void x86emu_dump_xregs (void);
+void x86emu_print_int_vect (u16 iv);
+void x86emu_instrument_instruction (void);
+void x86emu_check_ip_access (void);
+void x86emu_check_sp_access (void);
+void x86emu_check_mem_access (u32 p);
+void x86emu_check_data_access (uint s, uint o);
+
+void disassemble_forward (u16 seg, u16 off, int n);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
diff --git a/util/x86emu/x86emu/decode.c b/util/x86emu/x86emu/decode.c
index 2cd62348d7..3d2ba23566 100644
--- a/util/x86emu/x86emu/decode.c
+++ b/util/x86emu/x86emu/decode.c
@@ -77,7 +77,7 @@ next instruction.
void x86emu_intr_raise(
u8 intrnum)
{
- printk("%s, rasing execption %x\n", __func__, intrnum);
+ printf("%s, raising exeception %x\n", __func__, intrnum);
x86emu_dump_regs();
M.x86.intno = intrnum;
M.x86.intr |= INTR_SYNCH;
@@ -105,12 +105,12 @@ DB( if (CHECK_IP_FETCH())
if (M.x86.intr) {
if (M.x86.intr & INTR_HALTED) {
DB( if (M.x86.R_SP != 0) {
- printk("halted\n");
+ printf("halted\n");
X86EMU_trace_regs();
}
else {
if (M.x86.debug)
- printk("Service completed successfully\n");
+ printf("Service completed successfully\n");
})
return;
}
@@ -286,7 +286,7 @@ _INLINE u32 get_data_segment(void)
return M.x86.R_SS;
default:
#ifdef DEBUG
- printk("error: should not happen: multiple overrides.\n");
+ printf("error: should not happen: multiple overrides.\n");
#endif
HALT_SYS();
return 0;
diff --git a/util/x86emu/x86emu/fpu.c b/util/x86emu/x86emu/fpu.c
index 85f55c8854..daa2ffa75a 100644
--- a/util/x86emu/x86emu/fpu.c
+++ b/util/x86emu/x86emu/fpu.c
@@ -52,7 +52,7 @@ void x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-static char *x86emu_fpu_op_d9_tab[] = {
+static const char *x86emu_fpu_op_d9_tab[] = {
"FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ",
"FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t",
@@ -63,7 +63,7 @@ static char *x86emu_fpu_op_d9_tab[] = {
"FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t",
};
-static char *x86emu_fpu_op_d9_tab1[] = {
+static const char *x86emu_fpu_op_d9_tab1[] = {
"FLD\t", "FLD\t", "FLD\t", "FLD\t",
"FLD\t", "FLD\t", "FLD\t", "FLD\t",
@@ -296,7 +296,7 @@ void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-char *x86emu_fpu_op_da_tab[] = {
+static const char *x86emu_fpu_op_da_tab[] = {
"FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ",
"FICOMP\tDWORD PTR ",
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
@@ -386,7 +386,7 @@ void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-char *x86emu_fpu_op_db_tab[] = {
+static const char *x86emu_fpu_op_db_tab[] = {
"FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ",
"ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ",
@@ -505,7 +505,7 @@ void x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1))
}
#ifdef DEBUG
-char *x86emu_fpu_op_dc_tab[] = {
+static const char *x86emu_fpu_op_dc_tab[] = {
"FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ",
"FCOMP\tQWORD PTR ",
"FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ",
@@ -620,7 +620,7 @@ void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-static char *x86emu_fpu_op_dd_tab[] = {
+static const char *x86emu_fpu_op_dd_tab[] = {
"FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ",
"FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t",
@@ -720,7 +720,7 @@ void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-static char *x86emu_fpu_op_de_tab[] =
+static const char *x86emu_fpu_op_de_tab[] =
{
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
"FICOMP\tWORD PTR ",
@@ -839,7 +839,7 @@ void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-static char *x86emu_fpu_op_df_tab[] = {
+static const char *x86emu_fpu_op_df_tab[] = {
/* mod == 00 */
"FILD\tWORD PTR ", "ESC_DF\t39\n", "FIST\tWORD PTR ", "FISTP\tWORD PTR ",
"FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ",
diff --git a/util/x86emu/x86emu/ops.c b/util/x86emu/x86emu/ops.c
index fd7ad32d22..c66da95760 100644
--- a/util/x86emu/x86emu/ops.c
+++ b/util/x86emu/x86emu/ops.c
@@ -77,7 +77,7 @@
/* constant arrays to do several instructions in just one function */
#ifdef DEBUG
-static char *x86emu_GenOpName[8] = {
+static const char *x86emu_GenOpName[8] = {
"ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"};
#endif
@@ -159,7 +159,7 @@ static u32 (*opcD1_long_operation[])(u32 s, u8 d) =
#ifdef DEBUG
-static char *opF6_names[8] =
+static const char *opF6_names[8] =
{ "TEST\t", "", "NOT\t", "NEG\t", "MUL\t", "IMUL\t", "DIV\t", "IDIV\t" };
#endif
@@ -178,7 +178,7 @@ static void x86emuOp_illegal_op(
if (M.x86.R_SP != 0) {
DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
TRACE_REGS();
- DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
+ DB( printf("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
M.x86.R_CS, M.x86.R_IP-1,op1));
HALT_SYS();
}
diff --git a/util/x86emu/x86emu/ops2.c b/util/x86emu/x86emu/ops2.c
index a749b59525..f5cb6498b1 100644
--- a/util/x86emu/x86emu/ops2.c
+++ b/util/x86emu/x86emu/ops2.c
@@ -54,7 +54,7 @@ static void x86emuOp2_illegal_op(u8 op2)
START_OF_INSTR();
DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
TRACE_REGS();
- printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
+ printf("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
M.x86.R_CS, M.x86.R_IP-2, op2);
HALT_SYS();
END_OF_INSTR();
@@ -105,7 +105,7 @@ static void x86emuOp2_opc_01(u8 op2)
default:
DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE IN 0F 01\n");
TRACE_REGS();
- printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
+ printf("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
M.x86.R_CS, M.x86.R_IP-2, op2);
HALT_SYS();
break;
@@ -1272,7 +1272,7 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
default:
DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
TRACE_REGS();
- printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
+ printf("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
M.x86.R_CS, M.x86.R_IP-3,op2, (mod<<6)|(rh<<3)|rl);
HALT_SYS();
}
diff --git a/util/x86emu/x86emu/sys.c b/util/x86emu/x86emu/sys.c
index b4bed43ba4..957e0ca63b 100644
--- a/util/x86emu/x86emu/sys.c
+++ b/util/x86emu/x86emu/sys.c
@@ -41,15 +41,11 @@
****************************************************************************/
/* $XFree86: xc/extras/x86emu/src/x86emu/sys.c,v 1.5 2000/08/23 22:10:01 tsi Exp $ */
+#include <arch/io.h>
#include <x86emu/x86emu.h>
#include <x86emu/regs.h>
#include "debug.h"
#include "prim_ops.h"
-#if 1 /* Coreboot needs to map prinkf to printk. */
-#include "arch/io.h"
-#else
-#include <sys/io.h>
-#endif
#ifdef IN_MODULE
#include "xf86_ansic.h"
@@ -69,11 +65,11 @@ static u8 *mem_ptr(u32 addr, int size)
u8 *retaddr = 0;
if (addr > M.mem_size - size) {
- DB(printk("mem_ptr: address %#x out of range!\n", addr);)
+ DB(printf("mem_ptr: address %#x out of range!\n", addr);)
HALT_SYS();
}
if (addr < 0x200) {
- //printk("%x:%x updating int vector 0x%x\n",
+ //printf("%x:%x updating int vector 0x%x\n",
// M.x86.R_CS, M.x86.R_IP, addr >> 2);
}
retaddr = (u8 *) (M.mem_base + addr);
@@ -100,7 +96,7 @@ u8 X86API rdb(u32 addr)
val = *ptr;
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 1 -> %#x\n", addr, val);)
+ printf("%#08x 1 -> %#x\n", addr, val);)
return val;
}
@@ -123,7 +119,7 @@ u16 X86API rdw(u32 addr)
val = *(u16 *) (ptr);
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 2 -> %#x\n", addr, val);)
+ printf("%#08x 2 -> %#x\n", addr, val);)
return val;
}
@@ -145,7 +141,7 @@ u32 X86API rdl(u32 addr)
val = *(u32 *) (ptr);
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 4 -> %#x\n", addr, val);)
+ printf("%#08x 4 -> %#x\n", addr, val);)
return val;
}
@@ -165,7 +161,7 @@ void X86API wrb(u32 addr, u8 val)
*(u8 *) (ptr) = val;
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 1 <- %#x\n", addr, val);)
+ printf("%#08x 1 <- %#x\n", addr, val);)
}
/****************************************************************************
@@ -184,7 +180,7 @@ void X86API wrw(u32 addr, u16 val)
*(u16 *) (ptr) = val;
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 2 <- %#x\n", addr, val);)
+ printf("%#08x 2 <- %#x\n", addr, val);)
}
/****************************************************************************
@@ -203,7 +199,7 @@ void X86API wrl(u32 addr, u32 val)
*(u32 *) (ptr) = val;
DB(if (DEBUG_MEM_TRACE())
- printk("%#08x 4 <- %#x\n", addr, val);)
+ printf("%#08x 4 <- %#x\n", addr, val);)
}
@@ -219,7 +215,7 @@ Default PIO byte read function. Doesn't perform real inb.
static u8 X86API p_inb(X86EMU_pioAddr addr)
{
DB(if (DEBUG_IO_TRACE())
- printk("inb %#04x \n", addr);)
+ printf("inb %#04x \n", addr);)
return inb(addr);
}
@@ -234,7 +230,7 @@ Default PIO word read function. Doesn't perform real inw.
static u16 X86API p_inw(X86EMU_pioAddr addr)
{
DB(if (DEBUG_IO_TRACE())
- printk("inw %#04x \n", addr);)
+ printf("inw %#04x \n", addr);)
return inw(addr);
}
@@ -249,7 +245,7 @@ Default PIO long read function. Doesn't perform real inl.
static u32 X86API p_inl(X86EMU_pioAddr addr)
{
DB(if (DEBUG_IO_TRACE())
- printk("inl %#04x \n", addr);)
+ printf("inl %#04x \n", addr);)
return inl(addr);
}
@@ -263,7 +259,7 @@ Default PIO byte write function. Doesn't perform real outb.
static void X86API p_outb(X86EMU_pioAddr addr, u8 val)
{
DB(if (DEBUG_IO_TRACE())
- printk("outb %#02x -> %#04x \n", val, addr);)
+ printf("outb %#02x -> %#04x \n", val, addr);)
outb(val, addr);
return;
}
@@ -278,7 +274,7 @@ Default PIO word write function. Doesn't perform real outw.
static void X86API p_outw(X86EMU_pioAddr addr, u16 val)
{
DB(if (DEBUG_IO_TRACE())
- printk("outw %#04x -> %#04x \n", val, addr);)
+ printf("outw %#04x -> %#04x \n", val, addr);)
outw(val, addr);
return;
}
@@ -293,7 +289,7 @@ Default PIO ;ong write function. Doesn't perform real outl.
static void X86API p_outl(X86EMU_pioAddr addr, u32 val)
{
DB(if (DEBUG_IO_TRACE())
- printk("outl %#08x -> %#04x \n", val, addr);)
+ printf("outl %#08x -> %#04x \n", val, addr);)
outl(val, addr);
return;
diff --git a/util/x86emu/x86emu/x86emui.h b/util/x86emu/x86emu/x86emui.h
index ff69d50565..d693e335f4 100644
--- a/util/x86emu/x86emu/x86emui.h
+++ b/util/x86emu/x86emu/x86emui.h
@@ -74,8 +74,6 @@
#ifdef IN_MODULE
#include <xf86_ansic.h>
#else
-//#include <stdio.h>
-//#include <stdlib.h>
#include <string.h>
#endif
/*--------------------------- Inline Functions ----------------------------*/
diff --git a/util/x86emu/yabel/biosemu.c b/util/x86emu/yabel/biosemu.c
index 09a98b50b6..294d81f279 100644
--- a/util/x86emu/yabel/biosemu.c
+++ b/util/x86emu/yabel/biosemu.c
@@ -1,6 +1,7 @@
/******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation
* Copyright (c) 2008, 2009 Pattrick Hueper <phueper@hueper.net>
+ * Copyright (c) 2010 coresystems GmbH
* All rights reserved.
* This program and the accompanying materials
* are made available under the terms of the BSD License
@@ -12,7 +13,6 @@
*****************************************************************************/
#include <string.h>
-
#include <types.h>
#include "debug.h"
@@ -28,9 +28,8 @@
#include "device.h"
#include "pmm.h"
-#include "compat/rtas.h"
-
#include <device/device.h>
+#include "compat/rtas.h"
static X86EMU_memFuncs my_mem_funcs = {
my_rdb, my_rdw, my_rdl,
@@ -57,13 +56,42 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
{
u8 *rom_image;
int i = 0;
-#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;
+#if CONFIG_X86EMU_DEBUG
+ debug_flags = 0;
+#if defined(CONFIG_X86EMU_DEBUG_JMP) && CONFIG_X86EMU_DEBUG_JMP
+ debug_flags |= DEBUG_JMP;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_TRACE) && CONFIG_X86EMU_DEBUG_TRACE
+ debug_flags |= DEBUG_TRACE_X86EMU;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_PNP) && CONFIG_X86EMU_DEBUG_PNP
+ debug_flags |= DEBUG_PNP;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_DISK) && CONFIG_X86EMU_DEBUG_DISK
+ debug_flags |= DEBUG_DISK;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_PMM) && CONFIG_X86EMU_DEBUG_PMM
+ debug_flags |= DEBUG_PMM;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_VBE) && CONFIG_X86EMU_DEBUG_VBE
+ debug_flags |= DEBUG_VBE;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_INT10) && CONFIG_X86EMU_DEBUG_INT10
+ debug_flags |= DEBUG_PRINT_INT10;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_INTERRUPTS) && CONFIG_X86EMU_DEBUG_INTERRUPTS
+ debug_flags |= DEBUG_INTR;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_CHECK_VMEM_ACCESS) && CONFIG_X86EMU_DEBUG_CHECK_VMEM_ACCESS
+ debug_flags |= DEBUG_CHECK_VMEM_ACCESS;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_MEM) && CONFIG_X86EMU_DEBUG_MEM
+ debug_flags |= DEBUG_MEM;
+#endif
+#if defined(CONFIG_X86EMU_DEBUG_IO) && CONFIG_X86EMU_DEBUG_IO
+ debug_flags |= DEBUG_IO;
+#endif
- /* use CONFIG_YABEL_DEBUG_FLAGS, too... */
- debug_flags |= CONFIG_YABEL_DEBUG_FLAGS;
#endif
if (biosmem_size < MIN_REQUIRED_VMEM_SIZE) {
printf("Error: Not enough virtual memory: %x, required: %x!\n",
@@ -200,11 +228,11 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
//TODO: check for further needed EBDA data...
// setup original ROM BIOS Area (F000:xxxx)
- char *date = "06/11/99";
+ const char *date = "06/11/99";
for (i = 0; date[i]; i++)
my_wrb(0xffff5 + i, date[i]);
// set up eisa ident string
- char *ident = "PCI_ISA";
+ const char *ident = "PCI_ISA";
for (i = 0; ident[i]; i++)
my_wrb(0xfffd9 + i, ident[i]);
@@ -250,14 +278,14 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
// push a HLT instruction and a pointer to it onto the stack
// any return will pop the pointer and jump to the HLT, thus
// exiting (more or less) cleanly
- push_word(0xf4f4); //F4=HLT
+ push_word(0xf4f4); // F4=HLT
push_word(M.x86.R_SS);
push_word(M.x86.R_SP + 2);
CHECK_DBG(DEBUG_TRACE_X86EMU) {
X86EMU_trace_on();
+#if 0
} else {
-#ifdef DEBUG
M.x86.debug |= DEBUG_SAVE_IP_CS_F;
M.x86.debug |= DEBUG_DECODE_F;
M.x86.debug |= DEBUG_DECODE_NOPRINT_F;
@@ -268,7 +296,7 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
M.x86.debug |= DEBUG_TRACEJMP_REGS_F;
M.x86.debug |= DEBUG_TRACECALL_F;
M.x86.debug |= DEBUG_TRACECALL_REGS_F;
- }
+ }
DEBUG_PRINTF("Executing Initialization Vector...\n");
X86EMU_exec();
@@ -278,7 +306,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 DEBUG
+#if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
DEBUG_PRINTF("Exit Status Decode:\n");
if (M.x86.R_AX & 0x100) { // bit 8
DEBUG_PRINTF
@@ -344,14 +372,12 @@ biosemu(u8 *biosmem, u32 biosmem_size, struct device * dev, unsigned long rom_ad
&& (M.x86.R_SP == STACK_START_OFFSET)) {
DEBUG_PRINTF("Stack is clean, initialization successfull!\n");
} else {
- DEBUG_PRINTF
- ("Stack unclean, initialization probably NOT COMPLETE!!\n");
+ printf("Stack unclean, initialization probably NOT COMPLETE!\n");
DEBUG_PRINTF("SS:SP = %04x:%04x, expected: %04x:%04x\n",
M.x86.R_SS, M.x86.R_SP, STACK_SEGMENT,
STACK_START_OFFSET);
}
-
// TODO: according to the BIOS Boot Spec initializations may be ended using INT18h and setting
// the status.
// We need to implement INT18 accordingly, pseudo code is in specsbbs101.pdf page 30
diff --git a/util/x86emu/yabel/biosemu.h b/util/x86emu/yabel/biosemu.h
index fb8dab2b24..09ace729ec 100644
--- a/util/x86emu/yabel/biosemu.h
+++ b/util/x86emu/yabel/biosemu.h
@@ -46,4 +46,7 @@
typedef int (* yabel_handleIntFunc)(void);
extern yabel_handleIntFunc yabel_intFuncArray[256];
+struct device;
+
+u32 biosemu(u8 *biosmem, u32 biosmem_size, struct device *dev, unsigned long rom_addr);
#endif
diff --git a/util/x86emu/yabel/compat/functions.c b/util/x86emu/yabel/compat/functions.c
index 599e82e54e..4d1f1e4fda 100644
--- a/util/x86emu/yabel/compat/functions.c
+++ b/util/x86emu/yabel/compat/functions.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <device/device.h>
#include "../debug.h"
+#include "../biosemu.h"
#define VMEM_SIZE (1024 * 1024) /* 1 MB */
@@ -30,8 +31,6 @@ u8* vmem = (u8 *) (16*1024*1024); /* default to 16MB */
u8* vmem = NULL;
#endif
-u32 biosemu(u8 *biosmem, u32 biosmem_size, struct device *dev,
- unsigned long rom_addr);
#if CONFIG_BOOTSPLASH
void vbe_set_graphics(void);
#endif
@@ -46,10 +45,10 @@ void run_bios(struct device * dev, unsigned long addr)
#endif
if (vmem != NULL) {
- printf("Copying legacy memory from 0x%08x to the lower 1MB\n", vmem);
- memcpy(0x00000, vmem + 0x00000, 0x400); // IVT
- memcpy(0x00400, vmem + 0x00400, 0x100); // BDA
- memcpy(0xc0000, vmem + 0xc0000, 0x10000); // VGA OPROM
+ printf("Copying legacy memory from %p to the lower 1MB\n", vmem);
+ memcpy((void *)0x00000, vmem + 0x00000, 0x400); // IVT
+ memcpy((void *)0x00400, vmem + 0x00400, 0x100); // BDA
+ memcpy((void *)0xc0000, vmem + 0xc0000, 0x10000); // VGA OPROM
}
}
diff --git a/util/x86emu/yabel/debug.h b/util/x86emu/yabel/debug.h
index 92e78782c3..d02930809d 100644
--- a/util/x86emu/yabel/debug.h
+++ b/util/x86emu/yabel/debug.h
@@ -21,21 +21,18 @@ extern void x86emu_dump_xregs(void);
/* printf is not available in coreboot... use printk */
#include <console/console.h>
-/* uurgs... yuck... x86emu/x86emu.h is redefining printk... we include it here
- * and use its redefinition of printk
- * TODO: FIX!!!! */
#include "x86emu/x86emu.h"
-#define printf printk
+#define printf(x...) printk(BIOS_DEBUG, x)
/* PH: empty versions of set/clr_ci
* TODO: remove! */
static inline void clr_ci(void) {};
static inline void set_ci(void) {};
-/* Set CONFIG_YABEL_DEBUG_FLAGS is a binary switch that allows you
- * to select the following items to debug. 1=on 0=off. After you
- * decide what you want to debug create the binary value, convert to hex
- * and set the Option (Ex. CONFIG_YABEL_DEBUG_FLAGS = 0x31FF //Debug All).
+/* debug_flags is a binary switch that allows you to select the following items
+ * to debug. 1=on 0=off. After you decide what you want to debug create the
+ * binary value, convert to hex and set the option. These options can be
+ * selected in Kconfig.
*
* |-DEBUG_JMP - print info about JMP and RETF opcodes from x86emu
* ||-DEBUG_TRACE_X86EMU - print _all_ opcodes that are executed by x86emu (WARNING: this will produce a LOT of output)
@@ -69,9 +66,7 @@ static inline void set_ci(void) {};
// set to enable tracing of JMPs in x86emu
#define DEBUG_JMP 0x2000
-//#define DEBUG
-//#undef DEBUG
-#ifdef DEBUG
+#if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
#define CHECK_DBG(_flag) if (debug_flags & _flag)
diff --git a/util/x86emu/yabel/device.c b/util/x86emu/yabel/device.c
index 929e97779b..7e71a45e97 100644
--- a/util/x86emu/yabel/device.c
+++ b/util/x86emu/yabel/device.c
@@ -40,7 +40,7 @@ typedef struct {
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
/* coreboot version */
-void
+static void
biosemu_dev_get_addr_info(void)
{
int taa_index = 0;
@@ -112,7 +112,7 @@ biosemu_dev_get_addr_info(void)
}
// store last entry index of translate_address_array
taa_last_entry = taa_index - 1;
-#ifdef DEBUG
+#if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
//dump translate_address_array
printf("translate_address_array: \n");
translate_address_t ta;
@@ -195,7 +195,7 @@ biosemu_dev_get_addr_info(void)
}
// store last entry index of translate_address_array
taa_last_entry = taa_index - 1;
-#ifdef DEBUG
+#if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
//dump translate_address_array
printf("translate_address_array: \n");
translate_address_t ta;
@@ -210,11 +210,12 @@ biosemu_dev_get_addr_info(void)
}
#endif
+#ifndef CONFIG_PCI_OPTION_ROM_RUN_YABEL
// to simulate accesses to legacy VGA Memory (0xA0000-0xBFFFF)
// we look for the first prefetchable memory BAR, if no prefetchable BAR found,
// we use the first memory BAR
// dev_translate_addr will translate accesses to the legacy VGA Memory into the found vmem BAR
-void
+static void
biosemu_dev_find_vmem_addr(void)
{
int i = 0;
@@ -257,7 +258,6 @@ biosemu_dev_find_vmem_addr(void)
//bios_device.vmem_size = 0;
}
-#ifndef CONFIG_PCI_OPTION_ROM_RUN_YABEL
void
biosemu_dev_get_puid(void)
{
@@ -267,7 +267,7 @@ biosemu_dev_get_puid(void)
}
#endif
-void
+static void
biosemu_dev_get_device_vendor_id(void)
{
@@ -334,7 +334,7 @@ biosemu_dev_check_exprom(unsigned long rom_base_addr)
memcpy(&pci_ds, (void *) (rom_base_addr + pci_ds_offset),
sizeof(pci_ds));
clr_ci();
-#ifdef DEBUG
+#if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
DEBUG_PRINTF("PCI Data Structure @%lx:\n",
rom_base_addr + pci_ds_offset);
dump((void *) &pci_ds, sizeof(pci_ds));
diff --git a/util/x86emu/yabel/interrupt.c b/util/x86emu/yabel/interrupt.c
index 79b0899a08..9dc33fa8d1 100644
--- a/util/x86emu/yabel/interrupt.c
+++ b/util/x86emu/yabel/interrupt.c
@@ -11,6 +11,7 @@
* IBM Corporation - initial implementation
*****************************************************************************/
+#include <types.h>
#include "compat/rtas.h"
#include "biosemu.h"
@@ -18,6 +19,7 @@
#include "device.h"
#include "debug.h"
#include "pmm.h"
+#include "interrupt.h"
#include <x86emu/x86emu.h>
#include "../x86emu/prim_ops.h"
diff --git a/util/x86emu/yabel/io.c b/util/x86emu/yabel/io.c
index 9bb2df4960..6d36e8078f 100644
--- a/util/x86emu/yabel/io.c
+++ b/util/x86emu/yabel/io.c
@@ -17,6 +17,7 @@
#include "device.h"
#include "debug.h"
#include <x86emu/x86emu.h>
+#include "io.h"
#ifdef CONFIG_PCI_OPTION_ROM_RUN_YABEL
#include <device/pci.h>
@@ -87,10 +88,7 @@ u8 my_inb(X86EMU_pioAddr addr)
u8 val;
val = inb(addr);
-#ifdef CONFIG_DEBUG
- if ((debug_flags & DEBUG_IO) && (addr != 0x40))
- printk("inb(0x%04x) = 0x%02x\n", addr, val);
-#endif
+ DEBUG_PRINTF_IO("inb(0x%04x) = 0x%02x\n", addr, val);
return val;
}
@@ -100,11 +98,8 @@ u16 my_inw(X86EMU_pioAddr addr)
u16 val;
val = inw(addr);
+ DEBUG_PRINTF_IO("inw(0x%04x) = 0x%04x\n", addr, val);
-#ifdef CONFIG_DEBUG
- if (debug_flags & DEBUG_IO)
- printk("inw(0x%04x) = 0x%04x\n", addr, val);
-#endif
return val;
}
@@ -113,38 +108,26 @@ u32 my_inl(X86EMU_pioAddr addr)
u32 val;
val = inl(addr);
+ DEBUG_PRINTF_IO("inl(0x%04x) = 0x%08x\n", addr, val);
-#ifdef CONFIG_DEBUG
- if (debug_flags & DEBUG_IO)
- printk("inl(0x%04x) = 0x%08x\n", addr, val);
-#endif
return val;
}
void my_outb(X86EMU_pioAddr addr, u8 val)
{
-#ifdef CONFIG_DEBUG
- if ((debug_flags & DEBUG_IO) && (addr != 0x43))
- printk("outb(0x%02x, 0x%04x)\n", val, addr);
-#endif
+ DEBUG_PRINTF_IO("outb(0x%02x, 0x%04x)\n", val, addr);
outb(val, addr);
}
void my_outw(X86EMU_pioAddr addr, u16 val)
{
-#ifdef CONFIG_DEBUG
- if (debug_flags & DEBUG_IO)
- printk("outw(0x%04x, 0x%04x)\n", val, addr);
-#endif
+ DEBUG_PRINTF_IO("outw(0x%04x, 0x%04x)\n", val, addr);
outw(val, addr);
}
void my_outl(X86EMU_pioAddr addr, u32 val)
{
-#ifdef CONFIG_DEBUG
- if (debug_flags & DEBUG_IO)
- printk("outl(0x%08x, 0x%04x)\n", val, addr);
-#endif
+ DEBUG_PRINTF_IO("outl(0x%08x, 0x%04x)\n", val, addr);
outl(val, addr);
}
diff --git a/util/x86emu/yabel/mem.c b/util/x86emu/yabel/mem.c
index 1cf66ddff7..c04f56bfac 100644
--- a/util/x86emu/yabel/mem.c
+++ b/util/x86emu/yabel/mem.c
@@ -16,10 +16,11 @@
#include "device.h"
#include "x86emu/x86emu.h"
#include "biosemu.h"
+#include "mem.h"
#include "compat/time.h"
// define a check for access to certain (virtual) memory regions (interrupt handlers, BIOS Data Area, ...)
-#ifdef DEBUG
+#if CONFIG_X86EMU_DEBUG
static u8 in_check = 0; // to avoid recursion...
u16 ebda_segment;
u32 ebda_size;
@@ -27,11 +28,6 @@ u32 ebda_size;
//TODO: these macros have grown so large, that they should be changed to an inline function,
//just for the sake of readability...
-//declare prototypes of the functions to follow, for use in DEBUG_CHECK_VMEM_ACCESS
-u8 my_rdb(u32);
-u16 my_rdw(u32);
-u32 my_rdl(u32);
-
#define DEBUG_CHECK_VMEM_READ(_addr, _rval) \
if ((debug_flags & DEBUG_CHECK_VMEM_ACCESS) && (in_check == 0)) { \
in_check = 1; \
diff --git a/util/x86emu/yabel/vbe.c b/util/x86emu/yabel/vbe.c
index 6814b1964f..11a1ece73d 100644
--- a/util/x86emu/yabel/vbe.c
+++ b/util/x86emu/yabel/vbe.c
@@ -154,7 +154,7 @@ vbe_prepare(void)
}
// VBE Function 00h
-u8
+static u8
vbe_info(vbe_info_t * info)
{
vbe_prepare();
@@ -223,7 +223,7 @@ vbe_info(vbe_info_t * info)
}
// VBE Function 01h
-u8
+static u8
vbe_get_mode_info(vbe_mode_info_t * mode_info)
{
vbe_prepare();
@@ -264,7 +264,7 @@ vbe_get_mode_info(vbe_mode_info_t * mode_info)
}
// VBE Function 02h
-u8
+static u8
vbe_set_mode(vbe_mode_info_t * mode_info)
{
vbe_prepare();
@@ -301,7 +301,7 @@ vbe_set_mode(vbe_mode_info_t * mode_info)
}
//VBE Function 08h
-u8
+static u8
vbe_set_palette_format(u8 format)
{
vbe_prepare();
@@ -337,7 +337,7 @@ vbe_set_palette_format(u8 format)
}
// VBE Function 09h
-u8
+static u8
vbe_set_color(u16 color_number, u32 color_value)
{
vbe_prepare();
@@ -379,7 +379,7 @@ vbe_set_color(u16 color_number, u32 color_value)
return 0;
}
-u8
+static u8
vbe_get_color(u16 color_number, u32 * color_value)
{
vbe_prepare();
@@ -422,7 +422,7 @@ vbe_get_color(u16 color_number, u32 * color_value)
}
// VBE Function 15h
-u8
+static u8
vbe_get_ddc_info(vbe_ddc_info_t * ddc_info)
{
vbe_prepare();
@@ -496,7 +496,7 @@ vbe_get_ddc_info(vbe_ddc_info_t * ddc_info)
return 0;
}
-u32
+static u32
vbe_get_info(void)
{
u8 rval;
@@ -571,7 +571,7 @@ vbe_get_info(void)
}
#endif
if (*((u64 *) ddc_info.edid_block_zero) !=
- (u64) 0x00FFFFFFFFFFFF00) {
+ (u64) 0x00FFFFFFFFFFFF00ULL) {
// invalid EDID signature... probably no monitor
output->display_type = 0x0;
@@ -599,36 +599,36 @@ vbe_get_info(void)
DEBUG_PRINTF_VBE("Video Mode 0x%04x available, %s\n",
mode_info.video_mode,
- (mode_info.attributes & 0x1) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x1) ==
0 ? "not supported" : "supported");
DEBUG_PRINTF_VBE("\tTTY: %s\n",
- (mode_info.attributes & 0x4) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x4) ==
0 ? "no" : "yes");
DEBUG_PRINTF_VBE("\tMode: %s %s\n",
- (mode_info.attributes & 0x8) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x8) ==
0 ? "monochrome" : "color",
- (mode_info.attributes & 0x10) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x10) ==
0 ? "text" : "graphics");
DEBUG_PRINTF_VBE("\tVGA: %s\n",
- (mode_info.attributes & 0x20) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x20) ==
0 ? "compatible" : "not compatible");
DEBUG_PRINTF_VBE("\tWindowed Mode: %s\n",
- (mode_info.attributes & 0x40) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x40) ==
0 ? "yes" : "no");
DEBUG_PRINTF_VBE("\tFramebuffer: %s\n",
- (mode_info.attributes & 0x80) ==
+ (le16_to_cpu(mode_info.vesa.mode_attributes) & 0x80) ==
0 ? "no" : "yes");
DEBUG_PRINTF_VBE("\tResolution: %dx%d\n",
- mode_info.x_resolution,
- mode_info.y_resolution);
+ le16_to_cpu(mode_info.vesa.x_resolution),
+ le16_to_cpu(mode_info.vesa.y_resolution));
DEBUG_PRINTF_VBE("\tChar Size: %dx%d\n",
- mode_info.x_charsize, mode_info.y_charsize);
+ mode_info.vesa.x_charsize, mode_info.vesa.y_charsize);
DEBUG_PRINTF_VBE("\tColor Depth: %dbpp\n",
- mode_info.bits_per_pixel);
+ mode_info.vesa.bits_per_pixel);
DEBUG_PRINTF_VBE("\tMemory Model: 0x%x\n",
- mode_info.memory_model);
+ mode_info.vesa.memory_model);
DEBUG_PRINTF_VBE("\tFramebuffer Offset: %08x\n",
- mode_info.framebuffer_address);
+ le32_to_cpu(mode_info.vesa.phys_base_ptr));
if ((mode_info.vesa.bits_per_pixel == input.color_depth)
&& (le16_to_cpu(mode_info.vesa.x_resolution) <= input.max_screen_width)
@@ -647,10 +647,10 @@ vbe_get_info(void)
DEBUG_PRINTF_VBE
("Best Video Mode found: 0x%x, %dx%d, %dbpp, framebuffer_address: 0x%x\n",
best_mode_info.video_mode,
- best_mode_info.x_resolution,
- best_mode_info.y_resolution,
- best_mode_info.bits_per_pixel,
- best_mode_info.framebuffer_address);
+ best_mode_info.vesa.x_resolution,
+ best_mode_info.vesa.y_resolution,
+ best_mode_info.vesa.bits_per_pixel,
+ le32_to_cpu(best_mode_info.vesa.phys_base_ptr));
//printf("Mode Info Dump:");
//dump(best_mode_info.mode_info_block, 64);