[coreboot-gerrit] New patch to review for coreboot: Port x86 assembler pieces over to x64 assembler

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Thu Jun 18 10:24:54 CEST 2015


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

-gerrit

commit ddb61b32ff7db3a2c4f4561fb276a81ada570dc8
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Thu Jun 18 01:23:48 2015 -0700

    Port x86 assembler pieces over to x64 assembler
    
    Change-Id: I26f1bbf027435be593f11bce4780111dcaf7cb86
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
    Signed-off-by: Scott Duplichan <scott at notabs.org>
---
 src/arch/x86/boot/boot.c           | 5 +++++
 src/arch/x86/boot/gdt.c            | 6 +++++-
 src/arch/x86/boot/wakeup.S         | 5 +++++
 src/arch/x86/include/arch/cpu.h    | 8 +++++++-
 src/arch/x86/include/arch/stages.h | 4 ++++
 src/arch/x86/lib/cpu.c             | 4 ++++
 src/arch/x86/lib/cpu_common.c      | 9 +++++++++
 7 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/arch/x86/boot/boot.c b/src/arch/x86/boot/boot.c
index d86a6c3..c19b600 100644
--- a/src/arch/x86/boot/boot.c
+++ b/src/arch/x86/boot/boot.c
@@ -140,7 +140,12 @@ void arch_prog_run(struct prog *prog)
 	if (ENV_RAMSTAGE)
 		try_payload(prog);
 	__asm__ volatile (
+#ifdef __x86_64__
+		"jmp  *%%rdi\n"
+#else
 		"jmp  *%%edi\n"
+#endif
+
 		:: "D"(prog_entry(prog))
 	);
 }
diff --git a/src/arch/x86/boot/gdt.c b/src/arch/x86/boot/gdt.c
index 44156ea..fd5817e 100644
--- a/src/arch/x86/boot/gdt.c
+++ b/src/arch/x86/boot/gdt.c
@@ -26,7 +26,11 @@
 /* i386 lgdt argument */
 struct gdtarg {
 	u16 limit;
+#ifdef __x86_64__
+	u64 base;
+#else
 	u32 base;
+#endif
 } __attribute__((packed));
 
 /* Copy GDT to new location and reload it.
@@ -49,7 +53,7 @@ static void move_gdt(int is_recovery)
 		memcpy((void*)newgdt, &gdt, num_gdt_bytes);
 	}
 
-	gdtarg.base = (u32)newgdt;
+	gdtarg.base = (intptr_t)newgdt;
 	gdtarg.limit = num_gdt_bytes - 1;
 
 	__asm__ __volatile__ ("lgdt %0\n\t" : : "m" (gdtarg));
diff --git a/src/arch/x86/boot/wakeup.S b/src/arch/x86/boot/wakeup.S
index a614b55..38d6ea4 100644
--- a/src/arch/x86/boot/wakeup.S
+++ b/src/arch/x86/boot/wakeup.S
@@ -24,7 +24,12 @@
 /* CR0 bits */
 #define PE		(1 << 0)
 
+#ifdef __x86_64__
+	.code64
+#else
 	.code32
+#endif
+
 	.globl __wakeup
 __wakeup:
 	/* First prepare the jmp to the resume vector */
diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h
index 851b58d..5c371d9 100644
--- a/src/arch/x86/include/arch/cpu.h
+++ b/src/arch/x86/include/arch/cpu.h
@@ -179,8 +179,14 @@ struct cpu_info {
 static inline struct cpu_info *cpu_info(void)
 {
 	struct cpu_info *ci;
-	__asm__("andl %%esp,%0; "
+	__asm__(
+#ifdef __x86_64__
+		"and %%rsp,%0; "
+		"or  %2, %0 "
+#else
+		"andl %%esp,%0; "
 		"orl  %2, %0 "
+#endif
 		:"=r" (ci)
 		: "0" (~(CONFIG_STACK_SIZE - 1)),
 		"r" (CONFIG_STACK_SIZE - sizeof(struct cpu_info))
diff --git a/src/arch/x86/include/arch/stages.h b/src/arch/x86/include/arch/stages.h
index 80df8e2..dfdb592 100644
--- a/src/arch/x86/include/arch/stages.h
+++ b/src/arch/x86/include/arch/stages.h
@@ -27,7 +27,11 @@ void asmlinkage copy_and_run(void);
 static inline void stage_exit(void *entry)
 {
 	__asm__ volatile (
+#ifdef __x86_64__
+		"jmp  *%%rdi\n"
+#else
 		"jmp  *%%edi\n"
+#endif
 		:: "D"(entry)
 	);
 }
diff --git a/src/arch/x86/lib/cpu.c b/src/arch/x86/lib/cpu.c
index db72695..3eb7b94 100644
--- a/src/arch/x86/lib/cpu.c
+++ b/src/arch/x86/lib/cpu.c
@@ -10,6 +10,7 @@
 #include <device/device.h>
 #include <smp/spinlock.h>
 
+#ifndef __x86_64__
 /* Standard macro to see if a specific flag is changeable */
 static inline int flag_is_changeable_p(uint32_t flag)
 {
@@ -78,6 +79,7 @@ static int deep_magic_nexgen_probe(void)
 		: "=a" (ret) : : "cx", "dx" );
 	return  ret;
 }
+#endif
 
 /* List of cpu vendor strings along with their normalized
  * id values.
@@ -131,6 +133,7 @@ static void identify_cpu(struct device *cpu)
 
 	vendor_name[0] = '\0'; /* Unset */
 
+#ifndef __x86_64__
 	/* Find the id and vendor_name */
 	if (!cpu_have_cpuid()) {
 		/* Its a 486 if we can modify the AC flag */
@@ -148,6 +151,7 @@ static void identify_cpu(struct device *cpu)
 			memcpy(vendor_name, "NexGenDriven", 13);
 		}
 	}
+#endif
 	if (cpu_have_cpuid()) {
 		int  cpuid_level;
 		struct cpuid_result result;
diff --git a/src/arch/x86/lib/cpu_common.c b/src/arch/x86/lib/cpu_common.c
index 6c5561d..af0ab2a 100644
--- a/src/arch/x86/lib/cpu_common.c
+++ b/src/arch/x86/lib/cpu_common.c
@@ -10,6 +10,7 @@
 #include <device/device.h>
 #include <smp/spinlock.h>
 
+#ifndef __x86_64__
 /* Standard macro to see if a specific flag is changeable */
 static inline int flag_is_changeable_p(uint32_t flag)
 {
@@ -37,6 +38,14 @@ int cpu_have_cpuid(void)
 	return flag_is_changeable_p(X86_EFLAGS_ID);
 }
 
+#else
+
+int cpu_have_cpuid(void)
+{
+	return 1;
+}
+#endif
+
 int cpu_cpuid_extended_level(void)
 {
 	return cpuid_eax(0x80000000);



More information about the coreboot-gerrit mailing list