diff options
Diffstat (limited to 'util/x86emu')
-rw-r--r-- | util/x86emu/yabel/compat/functions.c | 50 | ||||
-rw-r--r-- | util/x86emu/yabel/compat/time.h | 3 | ||||
-rw-r--r-- | util/x86emu/yabel/interrupt.c | 10 | ||||
-rw-r--r-- | util/x86emu/yabel/io.c | 49 | ||||
-rw-r--r-- | util/x86emu/yabel/mem.c | 3 | ||||
-rw-r--r-- | util/x86emu/yabel/vbe.c | 13 |
6 files changed, 65 insertions, 63 deletions
diff --git a/util/x86emu/yabel/compat/functions.c b/util/x86emu/yabel/compat/functions.c index 4d1f1e4fda..6367fb025d 100644 --- a/util/x86emu/yabel/compat/functions.c +++ b/util/x86emu/yabel/compat/functions.c @@ -18,6 +18,7 @@ #include <device/device.h> #include "../debug.h" #include "../biosemu.h" +#include "../compat/time.h" #define VMEM_SIZE (1024 * 1024) /* 1 MB */ @@ -52,6 +53,8 @@ void run_bios(struct device * dev, unsigned long addr) } } +unsigned long tb_freq = 0; + u64 get_time(void) { u64 act; @@ -64,50 +67,3 @@ u64 get_time(void) act = ((u64) edx << 32) | eax; return act; } - -unsigned int -read_io(void *addr, size_t sz) -{ - unsigned int ret; - /* since we are using inb instructions, we need the port number as 16bit value */ - u16 port = (u16)(u32) addr; - - switch (sz) { - case 1: - asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port)); - break; - case 2: - asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port)); - break; - case 4: - asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port)); - break; - default: - ret = 0; - } - - return ret; -} - -int -write_io(void *addr, unsigned int value, size_t sz) -{ - u16 port = (u16)(u32) addr; - switch (sz) { - /* since we are using inb instructions, we need the port number as 16bit value */ - case 1: - asm volatile ("outb %b0, %1" : : "a"(value), "d" (port)); - break; - case 2: - asm volatile ("outw %w0, %1" : : "a"(value), "d" (port)); - break; - case 4: - asm volatile ("outl %0, %1" : : "a"(value), "d" (port)); - break; - default: - return -1; - } - - return 0; -} - diff --git a/util/x86emu/yabel/compat/time.h b/util/x86emu/yabel/compat/time.h index c8432eca43..6f7099bd86 100644 --- a/util/x86emu/yabel/compat/time.h +++ b/util/x86emu/yabel/compat/time.h @@ -13,5 +13,6 @@ #define _BIOSEMU_COMPAT_TIME_H /* TODO: check how this works in x86 */ -static unsigned long tb_freq = 0; +extern unsigned long tb_freq; +u64 get_time(void); #endif diff --git a/util/x86emu/yabel/interrupt.c b/util/x86emu/yabel/interrupt.c index 9dc33fa8d1..9a796005bb 100644 --- a/util/x86emu/yabel/interrupt.c +++ b/util/x86emu/yabel/interrupt.c @@ -31,7 +31,7 @@ //setup to run the code at the address, that the Interrupt Vector points to... -void +static void setupInt(int intNum) { DEBUG_PRINTF_INTR("%s(%x): executing interrupt handler @%08x\n", @@ -50,7 +50,7 @@ setupInt(int intNum) } // handle int10 (VGA BIOS Interrupt) -void +static void handleInt10(void) { // the data for INT10 is stored in BDA (0000:0400h) offset 49h-66h @@ -207,7 +207,7 @@ static u8 keycode_table[256] = { ; -void +static void translate_keycode(u64 * keycode) { u8 scan_code = 0; @@ -233,7 +233,7 @@ translate_keycode(u64 * keycode) } // handle int16 (Keyboard BIOS Interrupt) -void +static void handleInt16(void) { // keyboard buffer is in BIOS Memory Area: @@ -319,7 +319,7 @@ handleInt16(void) } // handle int1a (PCI BIOS Interrupt) -void +static void handleInt1a(void) { // function number in AX diff --git a/util/x86emu/yabel/io.c b/util/x86emu/yabel/io.c index 6d36e8078f..38a5d32c7c 100644 --- a/util/x86emu/yabel/io.c +++ b/util/x86emu/yabel/io.c @@ -24,12 +24,51 @@ #include <device/pci_ops.h> #endif -// those are defined in net-snk/oflib/pci.c -extern unsigned int read_io(void *, size_t); -extern int write_io(void *, unsigned int, size_t); +static unsigned int +read_io(void *addr, size_t sz) +{ + unsigned int ret; + /* since we are using inb instructions, we need the port number as 16bit value */ + u16 port = (u16)(u32) addr; + + switch (sz) { + case 1: + asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port)); + break; + case 2: + asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port)); + break; + case 4: + asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port)); + break; + default: + ret = 0; + } + + return ret; +} -//defined in net-snk/kernel/timer.c -extern u64 get_time(void); +static int +write_io(void *addr, unsigned int value, size_t sz) +{ + u16 port = (u16)(u32) addr; + switch (sz) { + /* since we are using inb instructions, we need the port number as 16bit value */ + case 1: + asm volatile ("outb %b0, %1" : : "a"(value), "d" (port)); + break; + case 2: + asm volatile ("outw %w0, %1" : : "a"(value), "d" (port)); + break; + case 4: + asm volatile ("outl %0, %1" : : "a"(value), "d" (port)); + break; + default: + return -1; + } + + return 0; +} #ifdef CONFIG_ARCH_X86 #include <arch/io.h> diff --git a/util/x86emu/yabel/mem.c b/util/x86emu/yabel/mem.c index c04f56bfac..8bcc9e12c2 100644 --- a/util/x86emu/yabel/mem.c +++ b/util/x86emu/yabel/mem.c @@ -159,9 +159,6 @@ u32 ebda_size; #define DEBUG_CHECK_VMEM_WRITE(_addr, _val) #endif -//defined in net-snk/kernel/timer.c -extern u64 get_time(void); - void update_time(u32); #if !defined(CONFIG_YABEL_DIRECTHW) || (!CONFIG_YABEL_DIRECTHW) diff --git a/util/x86emu/yabel/vbe.c b/util/x86emu/yabel/vbe.c index 11a1ece73d..6326a9c214 100644 --- a/util/x86emu/yabel/vbe.c +++ b/util/x86emu/yabel/vbe.c @@ -570,8 +570,17 @@ vbe_get_info(void) sizeof(ddc_info.edid_block_zero)); } #endif - if (*((u64 *) ddc_info.edid_block_zero) != - (u64) 0x00FFFFFFFFFFFF00ULL) { +/* This could fail because of alignment issues, so use a longer form. + *((u64 *) ddc_info.edid_block_zero) != (u64) 0x00FFFFFFFFFFFF00ULL +*/ + if (ddc_info.edid_block_zero[0] != 0x00 || + ddc_info.edid_block_zero[1] != 0xFF || + ddc_info.edid_block_zero[2] != 0xFF || + ddc_info.edid_block_zero[3] != 0xFF || + ddc_info.edid_block_zero[4] != 0xFF || + ddc_info.edid_block_zero[5] != 0xFF || + ddc_info.edid_block_zero[6] != 0xFF || + ddc_info.edid_block_zero[7] != 0x00 ) { // invalid EDID signature... probably no monitor output->display_type = 0x0; |