[coreboot] Patch set updated for coreboot: ad43871 Fix Yabel compilation on non-x86 platforms

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Sat Dec 8 02:03:09 CET 2012


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2002

-gerrit

commit ad43871368f5d2fb03393b0c086a7c0429812e6b
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Fri Dec 7 16:55:12 2012 -0800

    Fix Yabel compilation on non-x86 platforms
    
    Mostly preventing inb/outb being used on non-x86
    
    Change-Id: I0434df4ce477c262337672867dc6ce398ff95279
    Signed-off-by: Stefan Reinauer <reinauer at google.com>
---
 src/device/Kconfig                        |  2 +-
 src/device/oprom/include/io.h             |  9 +++++++++
 src/device/oprom/x86emu/sys.c             |  1 +
 src/device/oprom/yabel/compat/functions.c |  4 +++-
 src/device/oprom/yabel/device.h           |  8 ++++----
 src/device/oprom/yabel/io.c               | 16 ++++++++++------
 6 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/device/Kconfig b/src/device/Kconfig
index 700516b..d542bf1 100644
--- a/src/device/Kconfig
+++ b/src/device/Kconfig
@@ -157,7 +157,7 @@ config YABEL_VIRTMEM_LOCATION
 config YABEL_DIRECTHW
 	prompt "Direct hardware access"
 	bool
-	depends on PCI_OPTION_ROM_RUN_YABEL
+	depends on PCI_OPTION_ROM_RUN_YABEL && ARCH_X86
 	help
 	  YABEL consists of two parts: It uses x86emu for the CPU emulation and
 	  additionally provides a PC system emulation that filters bad device
diff --git a/src/device/oprom/include/io.h b/src/device/oprom/include/io.h
new file mode 100644
index 0000000..d9b2139
--- /dev/null
+++ b/src/device/oprom/include/io.h
@@ -0,0 +1,9 @@
+void outb(u8 val, u16 port);
+void outw(u16 val, u16 port);
+void outl(u32 val, u16 port);
+
+u8 inb(u16 port);
+u16 inw(u16 port);
+u32 inl(u16 port);
+
+
diff --git a/src/device/oprom/x86emu/sys.c b/src/device/oprom/x86emu/sys.c
index 7a9e392..b3b3cd7 100644
--- a/src/device/oprom/x86emu/sys.c
+++ b/src/device/oprom/x86emu/sys.c
@@ -44,6 +44,7 @@
 #include <arch/io.h>
 #include <x86emu/x86emu.h>
 #include <x86emu/regs.h>
+#include <device/oprom/include/io.h>
 #include "debug.h"
 #include "prim_ops.h"
 
diff --git a/src/device/oprom/yabel/compat/functions.c b/src/device/oprom/yabel/compat/functions.c
index 542c81f..f693d7b 100644
--- a/src/device/oprom/yabel/compat/functions.c
+++ b/src/device/oprom/yabel/compat/functions.c
@@ -47,7 +47,8 @@ unsigned long tb_freq = 0;
 
 u64 get_time(void)
 {
-    u64 act;
+    u64 act = 0;
+#if CONFIG_ARCH_X86
     u32 eax, edx;
 
     __asm__ __volatile__(
@@ -55,5 +56,6 @@ u64 get_time(void)
         : "=a"(eax), "=d"(edx)
         : /* no inputs, no clobber */);
     act = ((u64) edx << 32) | eax;
+#endif
     return act;
 }
diff --git a/src/device/oprom/yabel/device.h b/src/device/oprom/yabel/device.h
index edee44d..017aab9 100644
--- a/src/device/oprom/yabel/device.h
+++ b/src/device/oprom/yabel/device.h
@@ -128,7 +128,7 @@ u8 biosemu_dev_translate_address(int type, unsigned long * addr);
 static inline void
 out32le(void *addr, u32 val)
 {
-#ifdef __i386
+#if CONFIG_ARCH_X86 || CONFIG_ARCH_ARMV7
 	*((u32*) addr) = cpu_to_le32(val);
 #else
 	asm volatile ("stwbrx  %0, 0, %1"::"r" (val), "r"(addr));
@@ -139,7 +139,7 @@ static inline u32
 in32le(void *addr)
 {
 	u32 val;
-#ifdef __i386
+#if CONFIG_ARCH_X86 || CONFIG_ARCH_ARMV7
 	val = cpu_to_le32(*((u32 *) addr));
 #else
 	asm volatile ("lwbrx  %0, 0, %1":"=r" (val):"r"(addr));
@@ -150,7 +150,7 @@ in32le(void *addr)
 static inline void
 out16le(void *addr, u16 val)
 {
-#ifdef __i386
+#if CONFIG_ARCH_X86 || CONFIG_ARCH_ARMV7
 	*((u16*) addr) = cpu_to_le16(val);
 #else
 	asm volatile ("sthbrx  %0, 0, %1"::"r" (val), "r"(addr));
@@ -161,7 +161,7 @@ static inline u16
 in16le(void *addr)
 {
 	u16 val;
-#ifdef __i386
+#if CONFIG_ARCH_X86 || CONFIG_ARCH_ARMV7
 	val = cpu_to_le16(*((u16*) addr));
 #else
 	asm volatile ("lhbrx %0, 0, %1":"=r" (val):"r"(addr));
diff --git a/src/device/oprom/yabel/io.c b/src/device/oprom/yabel/io.c
index 5c19b51..d1172dc 100644
--- a/src/device/oprom/yabel/io.c
+++ b/src/device/oprom/yabel/io.c
@@ -17,6 +17,7 @@
 #include "device.h"
 #include "debug.h"
 #include <x86emu/x86emu.h>
+#include <device/oprom/include/io.h>
 #include "io.h"
 
 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
@@ -74,6 +75,9 @@ inl(u16 port)
 	HALT_SYS();
 	return 0;
 }
+
+#ifndef CONFIG_PCI
+#endif
 #endif
 
 #if CONFIG_YABEL_DIRECTHW
@@ -136,13 +140,13 @@ read_io(void *addr, size_t sz)
 
         switch (sz) {
         case 1:
-		asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port));
+		ret = inb(port);
                 break;
         case 2:
-		asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port));
+		ret = inw(port);
                 break;
         case 4:
-		asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port));
+		ret = inl(port);
                 break;
         default:
                 ret = 0;
@@ -158,13 +162,13 @@ write_io(void *addr, unsigned int value, size_t sz)
         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));
+		outb(value, port);
                 break;
         case 2:
-		asm volatile ("outw %w0, %1" : : "a"(value), "d" (port));
+		outw(value, port);
                 break;
         case 4:
-		asm volatile ("outl %0, %1" : : "a"(value), "d" (port));
+		outl(value, port);
                 break;
         default:
                 return -1;




More information about the coreboot mailing list