Use private (its own) segment registers in Open Firmware call,
instead of BAT register.
This commit is contained in:
parent
ef69721044
commit
a4de4218fd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: locore.S,v 1.10 1999/01/27 14:46:28 tsubai Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.11 1999/02/02 16:47:09 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -86,8 +86,6 @@ GLOBAL(intrcnt)
|
|||
.long 0,0,0,0
|
||||
GLOBAL(eintrcnt)
|
||||
|
||||
GLOBAL(ofbat)
|
||||
.long 0,0 /* batu, batl */
|
||||
GLOBAL(ofmsr)
|
||||
.long 0 /* msr used in Open Firmware */
|
||||
|
||||
|
@ -98,6 +96,8 @@ idle_u:
|
|||
.long 0 /* fake uarea during idle after exit */
|
||||
openfirmware_entry:
|
||||
.long 0 /* openfirmware entry point */
|
||||
srsave:
|
||||
.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
|
||||
/*
|
||||
* This symbol is here for the benefit of kvm_mkdb, and is supposed to
|
||||
|
@ -178,22 +178,46 @@ ENTRY(openfirmware)
|
|||
lwz 4,openfirmware_entry@l(4)
|
||||
mtlr 4
|
||||
|
||||
lis 4,_C_LABEL(ofbat)@ha /* map Open Firmware work area */
|
||||
lwz 4,_C_LABEL(ofbat)@l(4)
|
||||
mtibatu 2,4
|
||||
mtdbatu 2,4
|
||||
lis 4,_C_LABEL(ofbat)+4@ha
|
||||
lwz 4,_C_LABEL(ofbat)+4@l(4)
|
||||
mtibatl 2,4
|
||||
mtdbatl 2,4
|
||||
|
||||
lis 4,ofmsr@ha /* Open Firmware msr */
|
||||
lwz 4,ofmsr@l(4)
|
||||
mtmsr 4
|
||||
isync
|
||||
|
||||
lis 4,srsave@ha /* save old SR */
|
||||
addi 4,4,srsave@l
|
||||
li 5,0
|
||||
1: mfsrin 0,5
|
||||
stw 0,0(4)
|
||||
addi 4,4,4
|
||||
addis 5,5,0x10000000@h
|
||||
cmpwi 5,0
|
||||
bne 1b
|
||||
|
||||
lis 4,_C_LABEL(ofw_pmap)@ha /* load OFW SR */
|
||||
addi 4,4,_C_LABEL(ofw_pmap)@l
|
||||
lwz 0,PM_KERNELSR(4)
|
||||
cmpwi 0,0 /* pm_sr[KERNEL_SR] == 0? */
|
||||
beq 2f /* then skip (not initialized yet) */
|
||||
li 5,0
|
||||
1: lwz 0,0(4)
|
||||
mtsrin 0,5
|
||||
addi 4,4,4
|
||||
addis 5,5,0x10000000@h
|
||||
cmpwi 5,0
|
||||
bne 1b
|
||||
2:
|
||||
blrl /* call Open Firmware */
|
||||
|
||||
lis 4,srsave@ha /* restore saved SR */
|
||||
addi 4,4,srsave@l
|
||||
li 5,0
|
||||
1: mfsrin 0,5
|
||||
stw 0,0(4)
|
||||
addi 4,4,4
|
||||
addis 5,5,0x10000000@h
|
||||
cmpwi 5,0
|
||||
bne 1b
|
||||
|
||||
lwz 4,8(1) /* restore msr */
|
||||
mtmsr 4
|
||||
isync
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.30 1999/01/27 14:46:28 tsubai Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.31 1999/02/02 16:47:08 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -41,6 +41,7 @@
|
|||
#include "opt_natm.h"
|
||||
#include "opt_uvm.h"
|
||||
#include "opt_sysv.h"
|
||||
#include "adb.h"
|
||||
#include "ipkdb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -92,8 +93,6 @@
|
|||
#include <dev/cons.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
|
||||
#include "adb.h"
|
||||
|
||||
#if defined(UVM)
|
||||
vm_map_t exec_map = NULL;
|
||||
vm_map_t mb_map = NULL;
|
||||
|
@ -110,16 +109,17 @@ struct pmap *curpm;
|
|||
struct proc *fpuproc;
|
||||
|
||||
extern struct user *proc0paddr;
|
||||
extern int ofmsr;
|
||||
|
||||
struct bat battable[16];
|
||||
int astpending;
|
||||
char *bootpath;
|
||||
paddr_t msgbuf_paddr;
|
||||
static int chosen;
|
||||
struct pmap ofw_pmap;
|
||||
|
||||
int msgbufmapped = 0;
|
||||
|
||||
extern int ofmsr;
|
||||
|
||||
#ifdef NBUF
|
||||
int nbuf = NBUF;
|
||||
#else
|
||||
|
@ -134,8 +134,6 @@ int bufpages = 0;
|
|||
caddr_t allocsys __P((caddr_t));
|
||||
void install_extint __P((void (*)(void)));
|
||||
|
||||
extern struct bat ofbat;
|
||||
|
||||
int cold = 1;
|
||||
|
||||
void
|
||||
|
@ -162,20 +160,8 @@ initppc(startkernel, endkernel, args)
|
|||
extern void ext_intr __P((void));
|
||||
int exc, scratch;
|
||||
|
||||
int chosen, mmu, mode, exists;
|
||||
u_int32_t ofw_pa1, ofw_pa2;
|
||||
|
||||
/*
|
||||
* Read translations for Openfirmware call.
|
||||
*/
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "mmu", &mmu, 4);
|
||||
OF_call_method("translate", mmu, 1, 3,
|
||||
0xff800000, &ofw_pa1, &mode, &exists);
|
||||
OF_call_method("translate", mmu, 1, 3,
|
||||
0xff900000, &ofw_pa2, &mode, &exists);
|
||||
if (exists == 0)
|
||||
ofw_pa2 = -1;
|
||||
save_ofw_mapping();
|
||||
|
||||
proc0.p_addr = proc0paddr;
|
||||
bzero(proc0.p_addr, sizeof *proc0.p_addr);
|
||||
|
@ -215,6 +201,15 @@ initppc(startkernel, endkernel, args)
|
|||
battable[0].batl = BATL(0x00000000, BAT_M);
|
||||
battable[0].batu = BATU(0x00000000);
|
||||
|
||||
/*
|
||||
* Map PCI memory space.
|
||||
*/
|
||||
battable[8].batl = BATL(0x80000000, BAT_I);
|
||||
battable[8].batu = BATU(0x80000000);
|
||||
|
||||
battable[9].batl = BATL(0x90000000, BAT_I);
|
||||
battable[9].batu = BATU(0x90000000);
|
||||
|
||||
/*
|
||||
* Now setup fixed bat registers
|
||||
*
|
||||
|
@ -231,20 +226,6 @@ initppc(startkernel, endkernel, args)
|
|||
asm volatile ("mtdbatl 1,%0; mtdbatu 1,%1"
|
||||
:: "r"(0xf0000002 | BAT_I), "r"(0xf0000ffe));
|
||||
|
||||
/* BAT3 used temporarily for mapping video ram */
|
||||
/* (XXX upper half slots only...) */
|
||||
asm volatile ("mtdbatl 3,%0; mtdbatu 3,%1"
|
||||
:: "r"(BATL(0x80000000, BAT_I)), "r"(BATU(0x80000000)));
|
||||
|
||||
/* Open Firmware working area */
|
||||
/* iMac ff800000 - (00200000) -> XXe00000 */
|
||||
/* others ff800000 - (00100000) -> XXf00000 */
|
||||
ofbat.batl = ofw_pa1 | 0x02;
|
||||
if (ofw_pa2 == -1)
|
||||
ofbat.batu = 0xff80001e; /* 1MB */
|
||||
else
|
||||
ofbat.batu = 0xff80003e; /* 2MB (iMac) */
|
||||
|
||||
/*
|
||||
* Set up trap vectors
|
||||
*/
|
||||
|
@ -351,6 +332,59 @@ initppc(startkernel, endkernel, args)
|
|||
* Initialize pmap module.
|
||||
*/
|
||||
pmap_bootstrap(startkernel, endkernel);
|
||||
|
||||
restore_ofw_mapping();
|
||||
}
|
||||
|
||||
static int N_mapping;
|
||||
static struct {
|
||||
vaddr_t va;
|
||||
int len;
|
||||
paddr_t pa;
|
||||
int mode;
|
||||
} ofw_mapping[256];
|
||||
|
||||
int
|
||||
save_ofw_mapping()
|
||||
{
|
||||
int mmui, mmu;
|
||||
|
||||
OF_getprop(chosen, "mmu", &mmui, 4);
|
||||
mmu = OF_instance_to_package(mmui);
|
||||
bzero(ofw_mapping, sizeof(ofw_mapping));
|
||||
N_mapping =
|
||||
OF_getprop(mmu, "translations", ofw_mapping, sizeof(ofw_mapping));
|
||||
N_mapping /= sizeof(ofw_mapping[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
restore_ofw_mapping()
|
||||
{
|
||||
int i;
|
||||
|
||||
pmap_pinit(&ofw_pmap);
|
||||
|
||||
ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
|
||||
|
||||
for (i = 0; i < N_mapping; i++) {
|
||||
paddr_t pa = ofw_mapping[i].pa;
|
||||
vaddr_t va = ofw_mapping[i].va;
|
||||
int size = ofw_mapping[i].len;
|
||||
|
||||
if (va < 0xf8000000) /* XXX */
|
||||
continue;
|
||||
|
||||
while (size > 0) {
|
||||
pmap_enter(&ofw_pmap, va, pa, VM_PROT_ALL, 1);
|
||||
pa += NBPG;
|
||||
va += NBPG;
|
||||
size -= NBPG;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1089,13 +1123,9 @@ cninit()
|
|||
{
|
||||
struct consdev *cp;
|
||||
int l, node;
|
||||
int chosen, stdout;
|
||||
int stdout;
|
||||
char type[16];
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
if (chosen == -1)
|
||||
goto nocons;
|
||||
|
||||
l = OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
|
||||
if (l != sizeof(stdout))
|
||||
goto nocons;
|
||||
|
|
Loading…
Reference in New Issue