[coreboot] [commit] r5191 - in trunk: src/devices src/include/device util/x86emu/yabel util/x86emu/yabel/compat

repository service svn at coreboot.org
Fri Mar 5 19:27:20 CET 2010


Author: myles
Date: Fri Mar  5 19:27:19 2010
New Revision: 5191
URL: http://tracker.coreboot.org/trac/coreboot/changeset/5191

Log:
1. Move run_bios prototype to device.h
2. Use time.h for get_time() and move tb_freq into functions.c
3. Move read_io and write_io to io.c and make them static
4. Make a couple of functions static in interrupt.c
5. Refactor a cast from char[] to u64 to get rid of potential alignment problems and a warning

Signed-off-by: Myles Watson <mylesgw at gmail.com>
Acked-by: Stefan Reinauer <stepan at coresystems.de>

Modified:
   trunk/src/devices/pci_device.c
   trunk/src/include/device/device.h
   trunk/util/x86emu/yabel/compat/functions.c
   trunk/util/x86emu/yabel/compat/time.h
   trunk/util/x86emu/yabel/interrupt.c
   trunk/util/x86emu/yabel/io.c
   trunk/util/x86emu/yabel/mem.c
   trunk/util/x86emu/yabel/vbe.c

Modified: trunk/src/devices/pci_device.c
==============================================================================
--- trunk/src/devices/pci_device.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/src/devices/pci_device.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -652,7 +652,6 @@
 void pci_dev_init(struct device *dev)
 {
 #if CONFIG_PCI_ROM_RUN == 1 || CONFIG_VGA_ROM_RUN == 1
-	void run_bios(struct device *dev, unsigned long addr);
 	struct rom_header *rom, *ram;
 
 	if (CONFIG_PCI_ROM_RUN != 1 && /* Only execute VGA ROMs. */

Modified: trunk/src/include/device/device.h
==============================================================================
--- trunk/src/include/device/device.h	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/src/include/device/device.h	Fri Mar  5 19:27:19 2010	(r5191)
@@ -117,6 +117,9 @@
 void dev_set_enabled(device_t dev, int enable);
 void disable_children(struct bus *bus);
 
+/* Option ROM helper functions */
+void run_bios(struct device *dev, unsigned long addr);
+
 /* Helper functions */
 device_t find_dev_path(struct bus *parent, struct device_path *path);
 device_t alloc_find_dev(struct bus *parent, struct device_path *path);

Modified: trunk/util/x86emu/yabel/compat/functions.c
==============================================================================
--- trunk/util/x86emu/yabel/compat/functions.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/compat/functions.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -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 @@
 	}
 }
 
+unsigned long tb_freq = 0;
+
 u64 get_time(void)
 {
     u64 act;
@@ -64,50 +67,3 @@
     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;
-}
-

Modified: trunk/util/x86emu/yabel/compat/time.h
==============================================================================
--- trunk/util/x86emu/yabel/compat/time.h	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/compat/time.h	Fri Mar  5 19:27:19 2010	(r5191)
@@ -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 

Modified: trunk/util/x86emu/yabel/interrupt.c
==============================================================================
--- trunk/util/x86emu/yabel/interrupt.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/interrupt.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -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 @@
 }
 
 // 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 @@
 
 ;
 
-void
+static void
 translate_keycode(u64 * keycode)
 {
 	u8 scan_code = 0;
@@ -233,7 +233,7 @@
 }
 
 // handle int16 (Keyboard BIOS Interrupt)
-void
+static void
 handleInt16(void)
 {
 	// keyboard buffer is in BIOS Memory Area:
@@ -319,7 +319,7 @@
 }
 
 // handle int1a (PCI BIOS Interrupt)
-void
+static void
 handleInt1a(void)
 {
 	// function number in AX

Modified: trunk/util/x86emu/yabel/io.c
==============================================================================
--- trunk/util/x86emu/yabel/io.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/io.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -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;
 
-//defined in net-snk/kernel/timer.c
-extern u64 get_time(void);
+        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;
+}
+
+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>

Modified: trunk/util/x86emu/yabel/mem.c
==============================================================================
--- trunk/util/x86emu/yabel/mem.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/mem.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -159,9 +159,6 @@
 #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)

Modified: trunk/util/x86emu/yabel/vbe.c
==============================================================================
--- trunk/util/x86emu/yabel/vbe.c	Fri Mar  5 19:25:19 2010	(r5190)
+++ trunk/util/x86emu/yabel/vbe.c	Fri Mar  5 19:27:19 2010	(r5191)
@@ -570,8 +570,17 @@
 		     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;




More information about the coreboot mailing list