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
diff --git a/util/x86emu/yabel/biosemu.c b/util/x86emu/yabel/biosemu.c
index 09a98b5..294d81f 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 @@
{
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 @@
//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 @@
// 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 @@
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 @@
* 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 @@
&& (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 fb8dab2..09ace72 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 599e82e..4d1f1e4 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 = 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 @@
#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 92e7878..d029308 100644
--- a/util/x86emu/yabel/debug.h
+++ b/util/x86emu/yabel/debug.h
@@ -21,21 +21,18 @@
/* 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 @@
// 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 929e977..7e71a45 100644
--- a/util/x86emu/yabel/device.c
+++ b/util/x86emu/yabel/device.c
@@ -40,7 +40,7 @@
#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 @@
}
// 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 @@
}
// 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 @@
}
#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 @@
//bios_device.vmem_size = 0;
}
-#ifndef CONFIG_PCI_OPTION_ROM_RUN_YABEL
void
biosemu_dev_get_puid(void)
{
@@ -267,7 +267,7 @@
}
#endif
-void
+static void
biosemu_dev_get_device_vendor_id(void)
{
@@ -334,7 +334,7 @@
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 79b0899..9dc33fa 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 9bb2df4..6d36e80 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 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 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 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 1cf66dd..c04f56b 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 @@
//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 6814b19..11a1ece7 100644
--- a/util/x86emu/yabel/vbe.c
+++ b/util/x86emu/yabel/vbe.c
@@ -154,7 +154,7 @@
}
// VBE Function 00h
-u8
+static u8
vbe_info(vbe_info_t * info)
{
vbe_prepare();
@@ -223,7 +223,7 @@
}
// VBE Function 01h
-u8
+static u8
vbe_get_mode_info(vbe_mode_info_t * mode_info)
{
vbe_prepare();
@@ -264,7 +264,7 @@
}
// VBE Function 02h
-u8
+static u8
vbe_set_mode(vbe_mode_info_t * mode_info)
{
vbe_prepare();
@@ -301,7 +301,7 @@
}
//VBE Function 08h
-u8
+static u8
vbe_set_palette_format(u8 format)
{
vbe_prepare();
@@ -337,7 +337,7 @@
}
// VBE Function 09h
-u8
+static u8
vbe_set_color(u16 color_number, u32 color_value)
{
vbe_prepare();
@@ -379,7 +379,7 @@
return 0;
}
-u8
+static u8
vbe_get_color(u16 color_number, u32 * color_value)
{
vbe_prepare();
@@ -422,7 +422,7 @@
}
// VBE Function 15h
-u8
+static u8
vbe_get_ddc_info(vbe_ddc_info_t * ddc_info)
{
vbe_prepare();
@@ -496,7 +496,7 @@
return 0;
}
-u32
+static u32
vbe_get_info(void)
{
u8 rval;
@@ -571,7 +571,7 @@
}
#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 @@
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 @@
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);