Patchwork [U-Boot,RFC,07/36] x86 - Parametize location of Real Mode code

login
register
mail settings
Submitter Graeme Russ
Date Jan. 3, 2011, 7:46 p.m.
Message ID <1294084016-2674-8-git-send-email-graeme.russ@gmail.com>
Download mbox | patch
Permalink /patch/77314/
State Superseded
Delegated to: Graeme Russ
Headers show

Comments

Graeme Russ - Jan. 3, 2011, 7:46 p.m.
---
 arch/i386/config.mk      |    1 +
 arch/i386/cpu/u-boot.lds |    2 +-
 arch/i386/lib/realmode.c |    7 +++----
 3 files changed, 5 insertions(+), 5 deletions(-)

--
1.7.1.422.g049e9

Patch

diff --git a/arch/i386/config.mk b/arch/i386/config.mk
index f4689ec..7d1281b 100644
--- a/arch/i386/config.mk
+++ b/arch/i386/config.mk
@@ -32,6 +32,7 @@  PLATFORM_CPPFLAGS += $(call cc-option, -fno-toplevel-reorder,  $(call cc-option,
 PLATFORM_CPPFLAGS += $(call cc-option, -fno-stack-protector)
 PLATFORM_CPPFLAGS += $(call cc-option, -mpreferred-stack-boundary=2)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
+PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0

 PLATFORM_RELFLAGS += -ffunction-sections
 PLATFORM_RELFLAGS += -fvisibility=hidden
diff --git a/arch/i386/cpu/u-boot.lds b/arch/i386/cpu/u-boot.lds
index e712d26..98a548d 100644
--- a/arch/i386/cpu/u-boot.lds
+++ b/arch/i386/cpu/u-boot.lds
@@ -73,7 +73,7 @@  SECTIONS
 	/DISCARD/ : { *(.gnu*) }

 	/* 16bit realmode trampoline code */
-	.realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) }
+	.realmode REALMODE_BASE : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) }

 	__realmode_start = LOADADDR(.realmode);
 	__realmode_size = SIZEOF(.realmode);
diff --git a/arch/i386/lib/realmode.c b/arch/i386/lib/realmode.c
index 60fe181..3b56170 100644
--- a/arch/i386/lib/realmode.c
+++ b/arch/i386/lib/realmode.c
@@ -27,7 +27,6 @@ 
 #include <asm/realmode.h>


-#define REALMODE_BASE    ((char*)0x7c0)
 #define REALMODE_MAILBOX ((char*)0xe00)


@@ -41,13 +40,13 @@  int realmode_setup(void)
 	ulong realmode_size = (ulong)&__realmode_size;

 	/* copy the realmode switch code */
-	if (realmode_size > (REALMODE_MAILBOX-REALMODE_BASE)) {
+	if (realmode_size > (REALMODE_MAILBOX-(char*)REALMODE_BASE)) {
 		printf("realmode switch too large (%ld bytes, max is %d)\n",
-		       realmode_size, (REALMODE_MAILBOX-REALMODE_BASE));
+		       realmode_size, (REALMODE_MAILBOX-(char*)REALMODE_BASE));
 		return -1;
 	}

-	memcpy(REALMODE_BASE, (void*)realmode_start, realmode_size);
+	memcpy((char*)REALMODE_BASE, (void*)realmode_start, realmode_size);
 	asm("wbinvd\n");

 	return 0;