[OpenBIOS] [commit] r963 - in trunk/openbios-devel: arch/ppc/qemu include/arch/ppc

repository service svn at openbios.org
Sun Nov 21 11:36:36 CET 2010


Author: afaerber
Date: Sun Nov 21 11:36:35 2010
New Revision: 963
URL: http://tracker.coreboot.org/trac/openbios/changeset/963

Log:
ppc: Use mtmsrd on ppc64

On ppc64 the mtmsr instruction only sets the low 32 bits of the MSR.
mtmsrd must be used to set the high bits such as Sixty-Four Bit Mode as well.

v2:
* Introduce MTMSRD macro as seen on Linux, suggested by Alex.
* Introduce inline functions {mfmsr,mtmsr} as suggested by Alex.

Signed-off-by: Alexander Graf <agraf at suse.de>
Signed-off-by: Andreas Färber <andreas.faerber at web.de>

Modified:
   trunk/openbios-devel/arch/ppc/qemu/ofmem.c
   trunk/openbios-devel/include/arch/ppc/asmdefs.h
   trunk/openbios-devel/include/arch/ppc/processor.h

Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c	Sat Nov 20 22:14:59 2010	(r962)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c	Sun Nov 21 11:36:35 2010	(r963)
@@ -387,7 +387,7 @@
 setup_mmu( unsigned long ramsize )
 {
 	ofmem_t *ofmem;
-	unsigned long sdr1, sr_base, msr;
+	unsigned long sdr1, sr_base;
 	unsigned long hash_base;
 	unsigned long hash_mask = 0xfff00000; /* alignment for ppc64 */
 	int i;
@@ -415,9 +415,7 @@
 
 	/* Enable MMU */
 
-	asm volatile("mfmsr %0" : "=r" (msr) : );
-	msr |= MSR_IR | MSR_DR;
-	asm volatile("mtmsr %0" :: "r" (msr) );
+	mtmsr(mfmsr() | MSR_IR | MSR_DR);
 }
 
 void

Modified: trunk/openbios-devel/include/arch/ppc/asmdefs.h
==============================================================================
--- trunk/openbios-devel/include/arch/ppc/asmdefs.h	Sat Nov 20 22:14:59 2010	(r962)
+++ trunk/openbios-devel/include/arch/ppc/asmdefs.h	Sun Nov 21 11:36:35 2010	(r963)
@@ -90,8 +90,10 @@
 
 #ifdef __powerpc64__
 #define RFI rfid
+#define MTMSRD(r) mtmsrd r
 #else
 #define RFI rfi
+#define MTMSRD(r) mtmsr  r
 #endif
 
 #ifndef __darwin__

Modified: trunk/openbios-devel/include/arch/ppc/processor.h
==============================================================================
--- trunk/openbios-devel/include/arch/ppc/processor.h	Sat Nov 20 22:14:59 2010	(r962)
+++ trunk/openbios-devel/include/arch/ppc/processor.h	Sun Nov 21 11:36:35 2010	(r963)
@@ -403,8 +403,28 @@
 
 /* C helpers */
 
+#ifndef __ASSEMBLER__
+
 #define __stringify_1(x)	#x
 #define __stringify(x)		__stringify_1(x)
 #define mtspr(rn, v)		asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
 
+static inline unsigned long mfmsr(void)
+{
+    unsigned long msr;
+    asm volatile("mfmsr %0" : "=r" (msr));
+    return msr;
+}
+
+static inline void mtmsr(unsigned long msr)
+{
+#ifdef __powerpc64__
+    asm volatile("mtmsrd %0" :: "r" (msr));
+#else
+    asm volatile("mtmsr  %0" :: "r" (msr));
+#endif
+}
+
+#endif /* !__ASSEMBLER__ */
+
 #endif   /* _H_PROCESSOR */



More information about the OpenBIOS mailing list