svn commit: r197798 - projects/ppc64/sys/powerpc/aim64

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Oct 6 03:53:30 UTC 2009


Author: nwhitehorn
Date: Tue Oct  6 03:53:29 2009
New Revision: 197798
URL: http://svn.freebsd.org/changeset/base/197798

Log:
  Set up a stack for Open Firmware to use. Make it real-mode accessible,
  and use the 32-bit ABI for the stack. This should prevent stack frame
  corruption during the OF thunk.

Modified:
  projects/ppc64/sys/powerpc/aim64/locore.S

Modified: projects/ppc64/sys/powerpc/aim64/locore.S
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/locore.S	Tue Oct  6 02:13:32 2009	(r197797)
+++ projects/ppc64/sys/powerpc/aim64/locore.S	Tue Oct  6 03:53:29 2009	(r197798)
@@ -78,6 +78,7 @@
         .set    kernbase, KERNBASE
 
 #define	TMPSTKSZ	8192		/* 8K temporary stack */
+#define	OFWSTKSZ	4096		/* 4K Open Firmware stack */
 
 /*
  * Globals
@@ -86,6 +87,8 @@
 	.align	4
 GLOBAL(tmpstk)
 	.space	TMPSTKSZ
+GLOBAL(ofwstk)
+	.space	OFWSTKSZ
 GLOBAL(esym)
 	.llong	0			/* end of symbol table */
 
@@ -253,6 +256,20 @@ ASENTRY(ofw_32bit_mode_entry)
 	lis	%r4,openfirmware_entry at ha
 	ld	%r4,openfirmware_entry at l(%r4) /* read client interface handler */
 
+	/*
+	 * Set up OF stack. This needs to be accessible in real mode and
+	 * use the 32-bit ABI stack frame format. The pointer to the current
+	 * kernel stack is placed at the very top of the stack so we
+	 * can get it back later.
+	 */
+	mr	%r5,%r1
+	lis	%r1,(ofwstk+OFWSTKSZ-16)@ha
+	addi	%r1,%r1,(ofwstk+OFWSTKSZ-16)@l
+	std	%r5,8(%r1)	/* Save real stack pointer */
+	li	%r5,0
+	stw	%r5,4(%r1)
+	stw	%r5,0(%r1)
+
 	/* Set MSR, branch to OF, and come back */
 	lis	%r5,ofmsr at ha
 	ld	%r5,ofmsr at l(%r5)
@@ -265,6 +282,8 @@ ASENTRY(ofw_32bit_mode_entry)
 	mtmsr	%r14
 	isync
 
+	ld	%r1,8(%r1)	/* Load real stack pointer */
+
 	/* Now we can use the stack again, so get the real MSR */
 	ld	%r5,216(%r1)
 	mtmsrd	%r5


More information about the svn-src-projects mailing list