MFC locore.S:r.1.22, ofw_machdep.c:1.14
> Copy SPRG0-3 registers at boot-time and restore when calling into > OpenFirmware. FreeBSD/ppc uses SPRG0 as the per-cpu data area pointer, > and SPRG1-3 as temporary registers during exception handling. There > have been a few instances where OpenFirmware does require these to > be part of it's context, such as cd-booting an eMac.
This commit is contained in:
parent
a4ba2270ec
commit
f7e8320445
@ -81,7 +81,7 @@ GLOBAL(esym)
|
||||
.long 0 /* end of symbol table */
|
||||
|
||||
GLOBAL(ofmsr)
|
||||
.long 0 /* msr used in Open Firmware */
|
||||
.long 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
|
||||
|
||||
GLOBAL(powersave)
|
||||
.long 0
|
||||
@ -154,8 +154,17 @@ __start:
|
||||
|
||||
mfmsr 0
|
||||
lis 9,ofmsr@ha
|
||||
stw 0,ofmsr@l(9)
|
||||
stwu 0,ofmsr@l(9)
|
||||
|
||||
mfsprg0 0 /* save SPRG0-3 */
|
||||
stw 0,4(9) /* ofmsr[1] = sprg0 */
|
||||
mfsprg1 0
|
||||
stw 0,8(9) /* ofmsr[2] = sprg1 */
|
||||
mfsprg2 0
|
||||
stw 0,12(9) /* ofmsr[3] = sprg2 */
|
||||
mfsprg3 0
|
||||
stw 0,16(9) /* ofmsr[4] = sprg3 */
|
||||
|
||||
bl OF_init
|
||||
|
||||
lis 4,end@ha
|
||||
|
@ -59,11 +59,49 @@ __FBSDID("$FreeBSD$");
|
||||
static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
|
||||
static struct mem_region OFfree[OFMEM_REGIONS + 3];
|
||||
|
||||
extern long ofmsr;
|
||||
extern register_t ofmsr[5];
|
||||
extern struct pcpu __pcpu[MAXCPU];
|
||||
extern struct pmap ofw_pmap;
|
||||
extern int pmap_bootstrapped;
|
||||
static int (*ofwcall)(void *);
|
||||
|
||||
/*
|
||||
* Saved SPRG0-3 from OpenFirmware. Will be restored prior to the callback.
|
||||
*/
|
||||
register_t ofw_sprg0_save;
|
||||
|
||||
static __inline void
|
||||
ofw_sprg_prepare(void)
|
||||
{
|
||||
/*
|
||||
* Assume that interrupt are disabled at this point, or
|
||||
* SPRG1-3 could be trashed
|
||||
*/
|
||||
__asm __volatile("mfsprg0 %0\n\t"
|
||||
"mtsprg0 %1\n\t"
|
||||
"mtsprg1 %2\n\t"
|
||||
"mtsprg2 %3\n\t"
|
||||
"mtsprg3 %4\n\t"
|
||||
: "=&r"(ofw_sprg0_save)
|
||||
: "r"(ofmsr[1]),
|
||||
"r"(ofmsr[2]),
|
||||
"r"(ofmsr[3]),
|
||||
"r"(ofmsr[4]));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ofw_sprg_restore(void)
|
||||
{
|
||||
/*
|
||||
* Note that SPRG1-3 contents are irrelevant. They are scratch
|
||||
* registers used in the early portion of trap handling when
|
||||
* interrupts are disabled.
|
||||
*
|
||||
* PCPU data cannot be used until this routine is called !
|
||||
*/
|
||||
__asm __volatile("mtsprg0 %0" :: "r"(ofw_sprg0_save));
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory region utilities: determine if two regions overlap,
|
||||
* and merge two overlapping regions into one
|
||||
@ -173,9 +211,11 @@ openfirmware(void *args)
|
||||
"mtmsr %1\n\t"
|
||||
"isync\n"
|
||||
: "=r" (oldmsr)
|
||||
: "r" (ofmsr)
|
||||
: "r" (ofmsr[0])
|
||||
);
|
||||
|
||||
ofw_sprg_prepare();
|
||||
|
||||
if (pmap_bootstrapped) {
|
||||
/*
|
||||
* Swap the kernel's address space with Open Firmware's
|
||||
@ -192,8 +232,8 @@ openfirmware(void *args)
|
||||
"mtdbatu 3, %0" : : "r" (0));
|
||||
isync();
|
||||
}
|
||||
|
||||
result = ofwcall(args);
|
||||
|
||||
result = ofwcall(args);
|
||||
|
||||
if (pmap_bootstrapped) {
|
||||
/*
|
||||
@ -207,6 +247,8 @@ openfirmware(void *args)
|
||||
}
|
||||
}
|
||||
|
||||
ofw_sprg_restore();
|
||||
|
||||
__asm( "\t"
|
||||
"mtmsr %0\n\t"
|
||||
"isync\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user