1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Convert this from mostly inline assembler to mostly C.

Submitted by:	Peter Grehan <peterg@ptree32.com.au>
This commit is contained in:
Benno Rice 2002-06-29 09:16:30 +00:00
parent 08db6efa75
commit 3f57c11ec5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99030
2 changed files with 50 additions and 114 deletions

View File

@ -53,6 +53,7 @@ static const char rcsid[] =
#include <vm/vm_page.h>
#include <machine/powerpc.h>
#include <machine/ofw_machdep.h>
#define OFMEM_REGIONS 32
static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
@ -106,42 +107,7 @@ openfirmware(void *args)
long oldmsr;
int result;
u_int srsave[16];
if (pmap_bootstrapped) {
__asm __volatile("mfsr %0,0" : "=r"(srsave[0]));
__asm __volatile("mfsr %0,1" : "=r"(srsave[1]));
__asm __volatile("mfsr %0,2" : "=r"(srsave[2]));
__asm __volatile("mfsr %0,3" : "=r"(srsave[3]));
__asm __volatile("mfsr %0,4" : "=r"(srsave[4]));
__asm __volatile("mfsr %0,5" : "=r"(srsave[5]));
__asm __volatile("mfsr %0,6" : "=r"(srsave[6]));
__asm __volatile("mfsr %0,7" : "=r"(srsave[7]));
__asm __volatile("mfsr %0,8" : "=r"(srsave[8]));
__asm __volatile("mfsr %0,9" : "=r"(srsave[9]));
__asm __volatile("mfsr %0,10" : "=r"(srsave[10]));
__asm __volatile("mfsr %0,11" : "=r"(srsave[11]));
__asm __volatile("mfsr %0,12" : "=r"(srsave[12]));
__asm __volatile("mfsr %0,13" : "=r"(srsave[13]));
__asm __volatile("mfsr %0,14" : "=r"(srsave[14]));
__asm __volatile("mfsr %0,15" : "=r"(srsave[15]));
__asm __volatile("mtsr 0,%0" :: "r"(ofw_pmap.pm_sr[0]));
__asm __volatile("mtsr 1,%0" :: "r"(ofw_pmap.pm_sr[1]));
__asm __volatile("mtsr 2,%0" :: "r"(ofw_pmap.pm_sr[2]));
__asm __volatile("mtsr 3,%0" :: "r"(ofw_pmap.pm_sr[3]));
__asm __volatile("mtsr 4,%0" :: "r"(ofw_pmap.pm_sr[4]));
__asm __volatile("mtsr 5,%0" :: "r"(ofw_pmap.pm_sr[5]));
__asm __volatile("mtsr 6,%0" :: "r"(ofw_pmap.pm_sr[6]));
__asm __volatile("mtsr 7,%0" :: "r"(ofw_pmap.pm_sr[7]));
__asm __volatile("mtsr 8,%0" :: "r"(ofw_pmap.pm_sr[8]));
__asm __volatile("mtsr 9,%0" :: "r"(ofw_pmap.pm_sr[9]));
__asm __volatile("mtsr 10,%0" :: "r"(ofw_pmap.pm_sr[10]));
__asm __volatile("mtsr 11,%0" :: "r"(ofw_pmap.pm_sr[11]));
__asm __volatile("mtsr 12,%0" :: "r"(ofw_pmap.pm_sr[12]));
__asm __volatile("mtsr 13,%0" :: "r"(ofw_pmap.pm_sr[13]));
__asm __volatile("mtsr 14,%0" :: "r"(ofw_pmap.pm_sr[14]));
__asm __volatile("mtsr 15,%0" :: "r"(ofw_pmap.pm_sr[15]));
}
u_int i;
__asm __volatile( "\t"
"sync\n\t"
@ -152,35 +118,37 @@ openfirmware(void *args)
: "r" (ofmsr)
);
if (pmap_bootstrapped) {
/*
* Swap the kernel's address space with OpenFirmware's
*/
for (i = 0; i < 16; i++) {
srsave[i] = mfsrin(i << ADDR_SR_SHFT);
mtsrin(i << ADDR_SR_SHFT, ofw_pmap.pm_sr[i]);
}
isync();
}
result = ofwcall(args);
if (pmap_bootstrapped) {
/*
* Restore the kernel's addr space. The isync() doesn;t
* work outside the loop unless mtsrin() is open-coded
* in an asm statement :(
*/
for (i = 0; i < 16; i++) {
mtsrin(i << ADDR_SR_SHFT, srsave[i]);
isync();
}
}
__asm( "\t"
"mtmsr %0\n\t"
"isync\n"
: : "r" (oldmsr)
);
if (pmap_bootstrapped) {
__asm __volatile("mtsr 0,%0" :: "r"(srsave[0]));
__asm __volatile("mtsr 1,%0" :: "r"(srsave[1]));
__asm __volatile("mtsr 2,%0" :: "r"(srsave[2]));
__asm __volatile("mtsr 3,%0" :: "r"(srsave[3]));
__asm __volatile("mtsr 4,%0" :: "r"(srsave[4]));
__asm __volatile("mtsr 5,%0" :: "r"(srsave[5]));
__asm __volatile("mtsr 6,%0" :: "r"(srsave[6]));
__asm __volatile("mtsr 7,%0" :: "r"(srsave[7]));
__asm __volatile("mtsr 8,%0" :: "r"(srsave[8]));
__asm __volatile("mtsr 9,%0" :: "r"(srsave[9]));
__asm __volatile("mtsr 10,%0" :: "r"(srsave[10]));
__asm __volatile("mtsr 11,%0" :: "r"(srsave[11]));
__asm __volatile("mtsr 12,%0" :: "r"(srsave[12]));
__asm __volatile("mtsr 13,%0" :: "r"(srsave[13]));
__asm __volatile("mtsr 14,%0" :: "r"(srsave[14]));
__asm __volatile("mtsr 15,%0" :: "r"(srsave[15]));
__asm __volatile("sync");
}
return (result);
}

View File

@ -53,6 +53,7 @@ static const char rcsid[] =
#include <vm/vm_page.h>
#include <machine/powerpc.h>
#include <machine/ofw_machdep.h>
#define OFMEM_REGIONS 32
static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
@ -106,42 +107,7 @@ openfirmware(void *args)
long oldmsr;
int result;
u_int srsave[16];
if (pmap_bootstrapped) {
__asm __volatile("mfsr %0,0" : "=r"(srsave[0]));
__asm __volatile("mfsr %0,1" : "=r"(srsave[1]));
__asm __volatile("mfsr %0,2" : "=r"(srsave[2]));
__asm __volatile("mfsr %0,3" : "=r"(srsave[3]));
__asm __volatile("mfsr %0,4" : "=r"(srsave[4]));
__asm __volatile("mfsr %0,5" : "=r"(srsave[5]));
__asm __volatile("mfsr %0,6" : "=r"(srsave[6]));
__asm __volatile("mfsr %0,7" : "=r"(srsave[7]));
__asm __volatile("mfsr %0,8" : "=r"(srsave[8]));
__asm __volatile("mfsr %0,9" : "=r"(srsave[9]));
__asm __volatile("mfsr %0,10" : "=r"(srsave[10]));
__asm __volatile("mfsr %0,11" : "=r"(srsave[11]));
__asm __volatile("mfsr %0,12" : "=r"(srsave[12]));
__asm __volatile("mfsr %0,13" : "=r"(srsave[13]));
__asm __volatile("mfsr %0,14" : "=r"(srsave[14]));
__asm __volatile("mfsr %0,15" : "=r"(srsave[15]));
__asm __volatile("mtsr 0,%0" :: "r"(ofw_pmap.pm_sr[0]));
__asm __volatile("mtsr 1,%0" :: "r"(ofw_pmap.pm_sr[1]));
__asm __volatile("mtsr 2,%0" :: "r"(ofw_pmap.pm_sr[2]));
__asm __volatile("mtsr 3,%0" :: "r"(ofw_pmap.pm_sr[3]));
__asm __volatile("mtsr 4,%0" :: "r"(ofw_pmap.pm_sr[4]));
__asm __volatile("mtsr 5,%0" :: "r"(ofw_pmap.pm_sr[5]));
__asm __volatile("mtsr 6,%0" :: "r"(ofw_pmap.pm_sr[6]));
__asm __volatile("mtsr 7,%0" :: "r"(ofw_pmap.pm_sr[7]));
__asm __volatile("mtsr 8,%0" :: "r"(ofw_pmap.pm_sr[8]));
__asm __volatile("mtsr 9,%0" :: "r"(ofw_pmap.pm_sr[9]));
__asm __volatile("mtsr 10,%0" :: "r"(ofw_pmap.pm_sr[10]));
__asm __volatile("mtsr 11,%0" :: "r"(ofw_pmap.pm_sr[11]));
__asm __volatile("mtsr 12,%0" :: "r"(ofw_pmap.pm_sr[12]));
__asm __volatile("mtsr 13,%0" :: "r"(ofw_pmap.pm_sr[13]));
__asm __volatile("mtsr 14,%0" :: "r"(ofw_pmap.pm_sr[14]));
__asm __volatile("mtsr 15,%0" :: "r"(ofw_pmap.pm_sr[15]));
}
u_int i;
__asm __volatile( "\t"
"sync\n\t"
@ -152,35 +118,37 @@ openfirmware(void *args)
: "r" (ofmsr)
);
if (pmap_bootstrapped) {
/*
* Swap the kernel's address space with OpenFirmware's
*/
for (i = 0; i < 16; i++) {
srsave[i] = mfsrin(i << ADDR_SR_SHFT);
mtsrin(i << ADDR_SR_SHFT, ofw_pmap.pm_sr[i]);
}
isync();
}
result = ofwcall(args);
if (pmap_bootstrapped) {
/*
* Restore the kernel's addr space. The isync() doesn;t
* work outside the loop unless mtsrin() is open-coded
* in an asm statement :(
*/
for (i = 0; i < 16; i++) {
mtsrin(i << ADDR_SR_SHFT, srsave[i]);
isync();
}
}
__asm( "\t"
"mtmsr %0\n\t"
"isync\n"
: : "r" (oldmsr)
);
if (pmap_bootstrapped) {
__asm __volatile("mtsr 0,%0" :: "r"(srsave[0]));
__asm __volatile("mtsr 1,%0" :: "r"(srsave[1]));
__asm __volatile("mtsr 2,%0" :: "r"(srsave[2]));
__asm __volatile("mtsr 3,%0" :: "r"(srsave[3]));
__asm __volatile("mtsr 4,%0" :: "r"(srsave[4]));
__asm __volatile("mtsr 5,%0" :: "r"(srsave[5]));
__asm __volatile("mtsr 6,%0" :: "r"(srsave[6]));
__asm __volatile("mtsr 7,%0" :: "r"(srsave[7]));
__asm __volatile("mtsr 8,%0" :: "r"(srsave[8]));
__asm __volatile("mtsr 9,%0" :: "r"(srsave[9]));
__asm __volatile("mtsr 10,%0" :: "r"(srsave[10]));
__asm __volatile("mtsr 11,%0" :: "r"(srsave[11]));
__asm __volatile("mtsr 12,%0" :: "r"(srsave[12]));
__asm __volatile("mtsr 13,%0" :: "r"(srsave[13]));
__asm __volatile("mtsr 14,%0" :: "r"(srsave[14]));
__asm __volatile("mtsr 15,%0" :: "r"(srsave[15]));
__asm __volatile("sync");
}
return (result);
}