[coreboot-gerrit] New patch to review for coreboot: libpayload: Enable SSE and FPU on demand

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Sun Feb 12 13:04:34 CET 2017


Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18345

-gerrit

commit 953b58791878c2139d5c4b0a9848d426974ea261
Author: Patrick Rudolph <siro at das-labor.org>
Date:   Sun Jan 15 10:49:48 2017 +0100

    libpayload: Enable SSE and FPU on demand
    
    Use cpuid feature bits to detect and enable FPU and
    SSE instructions.
    
    Change-Id: I4a5fc633f158de421b70435a8bfdc0dcaa504c72
    Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 payloads/libpayload/arch/x86/main.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/payloads/libpayload/arch/x86/main.c b/payloads/libpayload/arch/x86/main.c
index fbd4dc4..9376264 100644
--- a/payloads/libpayload/arch/x86/main.c
+++ b/payloads/libpayload/arch/x86/main.c
@@ -29,6 +29,7 @@
 
 #include <exception.h>
 #include <libpayload.h>
+#include <arch/cpuid.h>
 
 unsigned long loader_eax;  /**< The value of EAX passed from the loader */
 unsigned long loader_ebx;  /**< The value of EBX passed from the loader */
@@ -47,6 +48,34 @@ void start_main(void)
 {
 	extern int main(int argc, char **argv);
 
+#if IS_ENABLED(CONFIG_LP_GPL)
+	/* Optionally set up cpuid */
+	get_cpuid();
+
+	/* Enable floating point processing */
+	if (cpu_id.fid.bits.fpu)
+		__asm__ __volatile__ (
+			"fninit\n\t"
+			"movl %%cr0, %%eax\n\t"
+			"andl $0xFFFFFFFB, %%eax\n\t"	/* clear EM */
+			"orl $0x00000022, %%eax\n\t"		/* set MP, NE */
+			"movl %%eax, %%cr0\n\t"
+			: :
+			: "ax"
+		);
+#ifdef __SSE__
+	/* Enable SSE instructions */
+	if (cpu_id.fid.bits.sse)
+		__asm__ __volatile__ (
+			"movl %%cr4, %%eax\n\t"
+			"orl $0x00000600, %%eax\n\t" /* set OSFXSR, OSXMMEXCPT */
+			"movl %%eax, %%cr4\n\t"
+			: :
+			: "ax"
+		);
+#endif
+#endif
+
 	/* Gather system information. */
 	lib_get_sysinfo();
 



More information about the coreboot-gerrit mailing list