svn commit: r222057 - in projects/pseries: conf powerpc/aim
powerpc/ofw
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Wed May 18 14:55:16 UTC 2011
Author: nwhitehorn
Date: Wed May 18 14:55:16 2011
New Revision: 222057
URL: http://svn.freebsd.org/changeset/base/222057
Log:
Rearrange the OF 32-bit call thunk for ppc64 to be in its own file instead
of aim/locore64.S and make an equivalent thunk for 32-bit platforms to
handle real mode. Add in similar stubs (untested) for RTAS calls and
fix the SLOF memory hack in ofw_machdep.c to not break Apple machines
with physical memory lists that are not in order.
This rearranges a bunch of OF-related stuff, but still boots on:
- POWER7 LPAR
- IBM Cell simulator
- iBook G4
- Powermac G3
- Xserve G5
Added:
projects/pseries/powerpc/ofw/ofwcall32.S
projects/pseries/powerpc/ofw/ofwcall64.S
projects/pseries/powerpc/ofw/ofwmagic.S
- copied unchanged from r221988, projects/pseries/powerpc/aim/ofwmagic.S
Deleted:
projects/pseries/powerpc/aim/ofwmagic.S
Modified:
projects/pseries/conf/files.powerpc
projects/pseries/powerpc/aim/locore32.S
projects/pseries/powerpc/aim/locore64.S
projects/pseries/powerpc/ofw/ofw_machdep.c
Modified: projects/pseries/conf/files.powerpc
==============================================================================
--- projects/pseries/conf/files.powerpc Wed May 18 14:02:33 2011 (r222056)
+++ projects/pseries/conf/files.powerpc Wed May 18 14:55:16 2011 (r222057)
@@ -86,7 +86,6 @@ powerpc/aim/moea64_if.m optional aim
powerpc/aim/moea64_native.c optional aim
powerpc/aim/mp_cpudep.c optional aim smp
powerpc/aim/nexus.c optional aim
-powerpc/aim/ofwmagic.S optional aim
powerpc/aim/slb.c optional aim powerpc64
powerpc/aim/swtch32.S optional aim powerpc
powerpc/aim/swtch64.S optional aim powerpc64
@@ -136,6 +135,9 @@ powerpc/ofw/ofw_pcibus.c optional pci ai
powerpc/ofw/ofw_pcib_pci.c optional pci aim
powerpc/ofw/ofw_real.c optional aim
powerpc/ofw/ofw_syscons.c optional sc aim
+powerpc/ofw/ofwcall32.S optional aim powerpc
+powerpc/ofw/ofwcall64.S optional aim powerpc64
+powerpc/ofw/ofwmagic.S optional aim
powerpc/powermac/ata_kauai.c optional powermac ata | powermac atamacio
powerpc/powermac/ata_macio.c optional powermac ata | powermac atamacio
powerpc/powermac/ata_dbdma.c optional powermac ata | powermac atamacio
Modified: projects/pseries/powerpc/aim/locore32.S
==============================================================================
--- projects/pseries/powerpc/aim/locore32.S Wed May 18 14:02:33 2011 (r222056)
+++ projects/pseries/powerpc/aim/locore32.S Wed May 18 14:55:16 2011 (r222057)
@@ -87,9 +87,6 @@ GLOBAL(tmpstk)
GLOBAL(esym)
.long 0 /* end of symbol table */
-GLOBAL(ofmsr)
- .long 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
-
#define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
GLOBAL(intrnames)
.space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
@@ -99,16 +96,6 @@ GLOBAL(intrcnt)
.space INTRCNT_COUNT * 4 * 2
GLOBAL(eintrcnt)
-/*
- * File-scope for locore.S
- */
-idle_u:
- .long 0 /* fake uarea during idle after exit */
-openfirmware_entry:
- .long 0 /* Open Firmware entry point */
-srsave:
- .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-
.text
.globl btext
btext:
Modified: projects/pseries/powerpc/aim/locore64.S
==============================================================================
--- projects/pseries/powerpc/aim/locore64.S Wed May 18 14:02:33 2011 (r222056)
+++ projects/pseries/powerpc/aim/locore64.S Wed May 18 14:55:16 2011 (r222057)
@@ -76,7 +76,6 @@
.set kernbase, KERNBASE
#define TMPSTKSZ 8192 /* 8K temporary stack */
-#define OFWSTKSZ 4096 /* 4K Open Firmware stack */
/*
* Globals
@@ -85,14 +84,9 @@
.align 4
GLOBAL(tmpstk)
.space TMPSTKSZ
-GLOBAL(ofwstk)
- .space OFWSTKSZ
GLOBAL(esym)
.llong 0 /* end of symbol table */
-GLOBAL(ofmsr)
- .llong 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
-
#define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
GLOBAL(intrnames)
.space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
@@ -102,16 +96,6 @@ GLOBAL(intrcnt)
.space INTRCNT_COUNT * 4 * 2
GLOBAL(eintrcnt)
-/*
- * File-scope for locore.S
- */
-idle_u:
- .llong 0 /* fake uarea during idle after exit */
-openfirmware_entry:
- .llong 0 /* Open Firmware entry point */
-srsave:
- .llong 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-
.text
.globl btext
btext:
@@ -208,122 +192,6 @@ tocbase:
.llong .TOC. at tocbase
/*
- * Open Firmware Real-mode Entry Point. This is a huge pain.
- */
-
-ASENTRY(ofw_32bit_mode_entry)
- mflr %r0
- std %r0,16(%r1)
- stdu %r1,-208(%r1)
-
- /*
- * We need to save the following, because OF's register save/
- * restore code assumes that the contents of registers are
- * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
- * get placed in that order in the stack.
- */
-
- mfcr %r4
- std %r4,48(%r1)
- std %r13,56(%r1)
- std %r14,64(%r1)
- std %r15,72(%r1)
- std %r16,80(%r1)
- std %r17,88(%r1)
- std %r18,96(%r1)
- std %r19,104(%r1)
- std %r20,112(%r1)
- std %r21,120(%r1)
- std %r22,128(%r1)
- std %r23,136(%r1)
- std %r24,144(%r1)
- std %r25,152(%r1)
- std %r26,160(%r1)
- std %r27,168(%r1)
- std %r28,176(%r1)
- std %r29,184(%r1)
- std %r30,192(%r1)
- std %r31,200(%r1)
-
- /* Record the old MSR */
- mfmsr %r6
-
- /* read client interface handler */
- lis %r4,openfirmware_entry at ha
- ld %r4,openfirmware_entry at l(%r4)
-
- /*
- * Set the MSR to the OF value. This has the side effect of disabling
- * exceptions, which is important for the next few steps.
- */
-
- lis %r5,ofmsr at ha
- ld %r5,ofmsr at l(%r5)
- mtmsrd %r5
- isync
-
- /*
- * 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 along with
- * the old MSR so we can get them back later.
- */
- mr %r5,%r1
- lis %r1,(ofwstk+OFWSTKSZ-32)@ha
- addi %r1,%r1,(ofwstk+OFWSTKSZ-32)@l
- std %r5,8(%r1) /* Save real stack pointer */
- std %r2,16(%r1) /* Save old TOC */
- std %r6,24(%r1) /* Save old MSR */
- li %r5,0
- stw %r5,4(%r1)
- stw %r5,0(%r1)
-
- /* Finally, branch to OF */
- mtctr %r4
- bctrl
-
- /* Reload stack pointer and MSR from the OFW stack */
- ld %r6,24(%r1)
- ld %r2,16(%r1)
- ld %r1,8(%r1)
-
- /* Now set the real MSR */
- mtmsrd %r6
- isync
-
- /* Sign-extend the return value from OF */
- extsw %r3,%r3
-
- /* Restore all the non-volatile registers */
- ld %r5,48(%r1)
- mtcr %r5
- ld %r13,56(%r1)
- ld %r14,64(%r1)
- ld %r15,72(%r1)
- ld %r16,80(%r1)
- ld %r17,88(%r1)
- ld %r18,96(%r1)
- ld %r19,104(%r1)
- ld %r20,112(%r1)
- ld %r21,120(%r1)
- ld %r22,128(%r1)
- ld %r23,136(%r1)
- ld %r24,144(%r1)
- ld %r25,152(%r1)
- ld %r26,160(%r1)
- ld %r27,168(%r1)
- ld %r28,176(%r1)
- ld %r29,184(%r1)
- ld %r30,192(%r1)
- ld %r31,200(%r1)
-
- /* Restore the stack and link register */
- ld %r1,0(%r1)
- ld %r0,16(%r1)
- mtlr %r0
- blr
-
-/*
* int setfault()
*
* Similar to setjmp to setup for handling faults on accesses to user memory.
Modified: projects/pseries/powerpc/ofw/ofw_machdep.c
==============================================================================
--- projects/pseries/powerpc/ofw/ofw_machdep.c Wed May 18 14:02:33 2011 (r222056)
+++ projects/pseries/powerpc/ofw/ofw_machdep.c Wed May 18 14:55:16 2011 (r222057)
@@ -65,11 +65,12 @@ static struct mem_region OFmem[OFMEM_REG
static struct mem_region OFfree[OFMEM_REGIONS + 3];
extern register_t ofmsr[5];
-static int (*ofwcall)(void *);
+extern void *openfirmware_entry;
static void *fdt;
int ofw_real_mode;
-int ofw_32bit_mode_entry(void *);
+int ofwcall(void *);
+int rtascall(void *);
static void ofw_quiesce(void);
static int openfirmware(void *args);
@@ -254,6 +255,7 @@ ofw_mem_regions(struct mem_region **memp
struct mem_region **availp, int *availsz)
{
phandle_t phandle;
+ vm_offset_t maxphysaddr;
int asz, msz, fsz;
int i, j;
int still_merging;
@@ -281,10 +283,14 @@ ofw_mem_regions(struct mem_region **memp
* available segment past the end of physical memory, so truncate that
* one.
*/
- if (OFavail[asz - 1].mr_start + OFavail[asz - 1].mr_size >
- OFmem[msz - 1].mr_start + OFmem[msz - 1].mr_size)
- OFavail[asz - 1].mr_size = (OFmem[msz - 1].mr_start +
- OFmem[msz - 1].mr_size) - OFavail[asz - 1].mr_start;
+ maxphysaddr = 0;
+ for (i = 0; i < msz; i++)
+ if (OFmem[i].mr_start + OFmem[i].mr_size > maxphysaddr)
+ maxphysaddr = OFmem[i].mr_start + OFmem[i].mr_size;
+
+ if (OFavail[asz - 1].mr_start + OFavail[asz - 1].mr_size > maxphysaddr)
+ OFavail[asz - 1].mr_size = maxphysaddr -
+ OFavail[asz - 1].mr_start;
/*
* OFavail may have overlapping regions - collapse these
@@ -328,19 +334,6 @@ OF_initial_setup(void *fdt_ptr, void *ju
else
ofw_real_mode = 1;
- ofwcall = NULL;
-
- #ifdef __powerpc64__
- /*
- * For PPC64, we need to use some hand-written
- * asm trampolines to get to OF.
- */
- if (openfirm != NULL)
- ofwcall = ofw_32bit_mode_entry;
- #else
- ofwcall = openfirm;
- #endif
-
fdt = fdt_ptr;
#ifdef FDT_DTB_STATIC
@@ -355,7 +348,7 @@ OF_bootstrap()
{
boolean_t status = FALSE;
- if (ofwcall != NULL) {
+ if (openfirmware_entry != NULL) {
if (ofw_real_mode) {
status = OF_install(OFW_STD_REAL, 0);
} else {
@@ -376,6 +369,10 @@ OF_bootstrap()
* background processes.
*/
ofw_quiesce();
+
+ /*
+ * If available, we need to instantiate RTAS.
+ */
} else if (fdt != NULL) {
status = OF_install(OFW_FDT, 0);
@@ -447,6 +444,7 @@ openfirmware_core(void *args)
#endif
result = ofwcall(args);
+ //result = ((int (*)(void *))(openfirmware_entry))(args);
ofw_sprg_restore();
intr_restore(oldmsr);
Added: projects/pseries/powerpc/ofw/ofwcall32.S
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/pseries/powerpc/ofw/ofwcall32.S Wed May 18 14:55:16 2011 (r222057)
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (C) 2009-2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/syscall.h>
+
+#include <machine/trap.h>
+#include <machine/param.h>
+#include <machine/spr.h>
+#include <machine/asm.h>
+
+#define OFWSTKSZ 4096 /* 4K Open Firmware stack */
+
+/*
+ * Globals
+ */
+ .data
+GLOBAL(ofmsr)
+ .long 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
+GLOBAL(rtasmsr)
+ .long 0
+GLOBAL(openfirmware_entry)
+ .long 0 /* Open Firmware entry point */
+GLOBAL(rtas_entry)
+ .long 0 /* RTAS entry point */
+
+ .align 4
+GLOBAL(ofwstk)
+ .space OFWSTKSZ
+
+/*
+ * Open Firmware Entry Point. May need to enter real mode.
+ *
+ * C prototype: int ofwcall(void *callbuffer);
+ */
+
+ASENTRY(ofwcall)
+ mflr %r0
+ stw %r0,4(%r1)
+
+ /* Record the old MSR */
+ mfmsr %r6
+
+ /* read client interface handler */
+ lis %r4,openfirmware_entry at ha
+ lwz %r4,openfirmware_entry at l(%r4)
+
+ /*
+ * Set the MSR to the OF value. This has the side effect of disabling
+ * exceptions, which prevents preemption later.
+ */
+
+ lis %r5,ofmsr at ha
+ lwz %r5,ofmsr at l(%r5)
+ mtmsr %r5
+ isync
+
+ /*
+ * Set up OF stack. This needs to be potentially accessible in real mode
+ * The pointer to the current kernel stack is placed at the very
+ * top of the stack along with the old MSR so we can get them back
+ * later.
+ */
+ mr %r5,%r1
+ lis %r1,(ofwstk+OFWSTKSZ-16)@ha
+ addi %r1,%r1,(ofwstk+OFWSTKSZ-16)@l
+ stw %r5,8(%r1) /* Save real stack pointer */
+ stw %r6,12(%r1) /* Save old MSR */
+ li %r5,0
+ stw %r5,4(%r1)
+ stw %r5,0(%r1)
+
+ /* Finally, branch to OF */
+ mtctr %r4
+ bctrl
+
+ /* Reload stack pointer and MSR from the OFW stack */
+ lwz %r6,12(%r1)
+ lwz %r1,8(%r1)
+
+ /* Now set the real MSR */
+ mtmsr %r6
+ isync
+
+ /* Return */
+ lwz %r0,4(%r1)
+ mtlr %r0
+ blr
+
+/*
+ * RTAS Entry Point. Similar to the OF one, but simpler (no separate stack)
+ *
+ * C prototype: int rtascall(void *callbuffer, void *rtas_privdat);
+ */
+
+ASENTRY(rtascall)
+ mflr %r0
+ stw %r0,4(%r1)
+
+ /* Record the old MSR just below the bottom of the stack */
+ mfmsr %r0
+ stw %r0,-4(%r1)
+
+ /* read client interface handler */
+ lis %r5,rtas_entry at ha
+ lwz %r5,rtas_entry at l(%r5)
+
+ /* Set the MSR to the RTAS value */
+ lis %r6,rtasmsr at ha
+ lwz %r6,rtasmsr at l(%r6)
+ mtmsr %r6
+ isync
+
+ /* Branch to RTAS */
+ mtctr %r5
+ bctrl
+
+ /* Now set the MSR back */
+ lwz %r6,-4(%r1)
+ mtmsr %r6
+ isync
+
+ /* And return */
+ lwz %r0,4(%r1)
+ mtlr %r0
+ blr
+
Added: projects/pseries/powerpc/ofw/ofwcall64.S
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/pseries/powerpc/ofw/ofwcall64.S Wed May 18 14:55:16 2011 (r222057)
@@ -0,0 +1,288 @@
+/*-
+ * Copyright (C) 2009-2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/syscall.h>
+
+#include <machine/trap.h>
+#include <machine/param.h>
+#include <machine/spr.h>
+#include <machine/asm.h>
+
+#define OFWSTKSZ 4096 /* 4K Open Firmware stack */
+
+/*
+ * Globals
+ */
+ .data
+ .align 4
+GLOBAL(ofwstk)
+ .space OFWSTKSZ
+GLOBAL(rtas_regsave)
+ .space 24 /* 3 * sizeof(register_t) */
+GLOBAL(ofmsr)
+ .llong 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
+GLOBAL(rtasmsr)
+ .llong 0
+GLOBAL(openfirmware_entry)
+ .llong 0 /* Open Firmware entry point */
+GLOBAL(rtas_entry)
+ .llong 0 /* RTAS entry point */
+
+/*
+ * Open Firmware Real-mode Entry Point. This is a huge pain.
+ */
+
+ASENTRY(ofwcall)
+ mflr %r0
+ std %r0,16(%r1)
+ stdu %r1,-208(%r1)
+
+ /*
+ * We need to save the following, because OF's register save/
+ * restore code assumes that the contents of registers are
+ * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
+ * get placed in that order in the stack.
+ */
+
+ mfcr %r4
+ std %r4,48(%r1)
+ std %r13,56(%r1)
+ std %r14,64(%r1)
+ std %r15,72(%r1)
+ std %r16,80(%r1)
+ std %r17,88(%r1)
+ std %r18,96(%r1)
+ std %r19,104(%r1)
+ std %r20,112(%r1)
+ std %r21,120(%r1)
+ std %r22,128(%r1)
+ std %r23,136(%r1)
+ std %r24,144(%r1)
+ std %r25,152(%r1)
+ std %r26,160(%r1)
+ std %r27,168(%r1)
+ std %r28,176(%r1)
+ std %r29,184(%r1)
+ std %r30,192(%r1)
+ std %r31,200(%r1)
+
+ /* Record the old MSR */
+ mfmsr %r6
+
+ /* read client interface handler */
+ lis %r4,openfirmware_entry at ha
+ ld %r4,openfirmware_entry at l(%r4)
+
+ /*
+ * Set the MSR to the OF value. This has the side effect of disabling
+ * exceptions, which is important for the next few steps.
+ */
+
+ lis %r5,ofmsr at ha
+ ld %r5,ofmsr at l(%r5)
+ mtmsrd %r5
+ isync
+
+ /*
+ * 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 along with
+ * the old MSR so we can get them back later.
+ */
+ mr %r5,%r1
+ lis %r1,(ofwstk+OFWSTKSZ-32)@ha
+ addi %r1,%r1,(ofwstk+OFWSTKSZ-32)@l
+ std %r5,8(%r1) /* Save real stack pointer */
+ std %r2,16(%r1) /* Save old TOC */
+ std %r6,24(%r1) /* Save old MSR */
+ li %r5,0
+ stw %r5,4(%r1)
+ stw %r5,0(%r1)
+
+ /* Finally, branch to OF */
+ mtctr %r4
+ bctrl
+
+ /* Reload stack pointer and MSR from the OFW stack */
+ ld %r6,24(%r1)
+ ld %r2,16(%r1)
+ ld %r1,8(%r1)
+
+ /* Now set the real MSR */
+ mtmsrd %r6
+ isync
+
+ /* Sign-extend the return value from OF */
+ extsw %r3,%r3
+
+ /* Restore all the non-volatile registers */
+ ld %r5,48(%r1)
+ mtcr %r5
+ ld %r13,56(%r1)
+ ld %r14,64(%r1)
+ ld %r15,72(%r1)
+ ld %r16,80(%r1)
+ ld %r17,88(%r1)
+ ld %r18,96(%r1)
+ ld %r19,104(%r1)
+ ld %r20,112(%r1)
+ ld %r21,120(%r1)
+ ld %r22,128(%r1)
+ ld %r23,136(%r1)
+ ld %r24,144(%r1)
+ ld %r25,152(%r1)
+ ld %r26,160(%r1)
+ ld %r27,168(%r1)
+ ld %r28,176(%r1)
+ ld %r29,184(%r1)
+ ld %r30,192(%r1)
+ ld %r31,200(%r1)
+
+ /* Restore the stack and link register */
+ ld %r1,0(%r1)
+ ld %r0,16(%r1)
+ mtlr %r0
+ blr
+
+/*
+ * RTAS 32-bit Entry Point. Similar to the OF one, but simpler (no separate
+ * stack)
+ *
+ * C prototype: int rtas_32bit_entry(void *callbuffer, void *rtas_privdat);
+ */
+
+ASENTRY(rtascall)
+ mflr %r0
+ std %r0,16(%r1)
+ stdu %r1,-208(%r1)
+
+ /*
+ * We need to save the following, because RTAS's register save/
+ * restore code assumes that the contents of registers are
+ * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
+ * get placed in that order in the stack.
+ */
+
+ mfcr %r5
+ std %r5,48(%r1)
+ std %r13,56(%r1)
+ std %r14,64(%r1)
+ std %r15,72(%r1)
+ std %r16,80(%r1)
+ std %r17,88(%r1)
+ std %r18,96(%r1)
+ std %r19,104(%r1)
+ std %r20,112(%r1)
+ std %r21,120(%r1)
+ std %r22,128(%r1)
+ std %r23,136(%r1)
+ std %r24,144(%r1)
+ std %r25,152(%r1)
+ std %r26,160(%r1)
+ std %r27,168(%r1)
+ std %r28,176(%r1)
+ std %r29,184(%r1)
+ std %r30,192(%r1)
+ std %r31,200(%r1)
+
+ /* Record the old MSR */
+ mfmsr %r6
+
+ /* read client interface handler */
+ lis %r5,rtas_entry at ha
+ ld %r5,rtas_entry at l(%r5)
+
+ /*
+ * Set the MSR to the RTAS value. This has the side effect of disabling
+ * exceptions, which is important for the next few steps.
+ */
+
+ lis %r7,rtasmsr at ha
+ ld %r7,rtasmsr at l(%r7)
+ mtmsrd %r7
+ isync
+
+ /*
+ * Set up RTAS register save area, so that we can get back all of
+ * our 64-bit pointers. Save our stack pointer, the TOC, and the MSR.
+ * Put this in r1, since RTAS is obliged to save it. Kernel globals
+ * are below 4 GB, so this is safe.
+ */
+ mr %r7,%r1
+ lis %r1,rtas_regsave at ha
+ addi %r1,%r1,rtas_regsave at l
+ std %r7,0(%r1) /* Save 64-bit stack pointer */
+ std %r2,8(%r1) /* Save TOC */
+ std %r6,16(%r1) /* Save MSR */
+
+ /* Finally, branch to RTAS */
+ mtctr %r5
+ bctrl
+
+ /*
+ * Reload stack pointer and MSR from the reg save area in r1. We are
+ * running in 32-bit mode at this point, so it doesn't matter if r1
+ * has become sign-extended.
+ */
+ ld %r6,16(%r1)
+ ld %r2,8(%r1)
+ ld %r1,0(%r1)
+
+ /* Now set the real MSR */
+ mtmsrd %r6
+ isync
+
+ /* Sign-extend the return value from RTAS */
+ extsw %r3,%r3
+
+ /* Restore all the non-volatile registers */
+ ld %r5,48(%r1)
+ mtcr %r5
+ ld %r13,56(%r1)
+ ld %r14,64(%r1)
+ ld %r15,72(%r1)
+ ld %r16,80(%r1)
+ ld %r17,88(%r1)
+ ld %r18,96(%r1)
+ ld %r19,104(%r1)
+ ld %r20,112(%r1)
+ ld %r21,120(%r1)
+ ld %r22,128(%r1)
+ ld %r23,136(%r1)
+ ld %r24,144(%r1)
+ ld %r25,152(%r1)
+ ld %r26,160(%r1)
+ ld %r27,168(%r1)
+ ld %r28,176(%r1)
+ ld %r29,184(%r1)
+ ld %r30,192(%r1)
+ ld %r31,200(%r1)
+
+ /* Restore the stack and link register */
+ ld %r1,0(%r1)
+ ld %r0,16(%r1)
+ mtlr %r0
+ blr
+
Copied: projects/pseries/powerpc/ofw/ofwmagic.S (from r221988, projects/pseries/powerpc/aim/ofwmagic.S)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/pseries/powerpc/ofw/ofwmagic.S Wed May 18 14:55:16 2011 (r222057, copy of r221988, projects/pseries/powerpc/aim/ofwmagic.S)
@@ -0,0 +1,68 @@
+/* $FreeBSD$ */
+/* $NetBSD: ofwmagic.S,v 1.2 1997/10/09 08:38:18 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Magic note section used by Open Firmware.
+ */
+
+ .section ".note"
+
+ /*# note header */
+
+ /*# length of name */
+ .long 8
+
+ /*# note descriptor size */
+ .long 20
+
+ /*# note type (IEEE 1275) */
+ .long 0x1275
+
+ /*# name of owner */
+ .asciz "PowerPC"
+ .balign 4
+
+
+ /*# note descriptor */
+
+ /*# real mode (-1) or virtual mode (0) */
+ .long 0
+
+ /*# real-base */
+ .long -1
+ /*# real-size */
+ .long -1
+
+ /*# virt-base */
+ .long -1
+ /*# virt-size */
+ .long -1
More information about the svn-src-projects
mailing list