Major rewriting of pmap_bootstrap; CPU dependent allocations moved
to related file.
This commit is contained in:
parent
d3c61be30b
commit
33bd27fa3c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ka750.c,v 1.5 1995/03/30 21:25:21 ragge Exp $ */
|
||||
/* $NetBSD: ka750.c,v 1.6 1995/11/10 18:52:57 ragge Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1988 The Regents of the University of California.
|
||||
@ -37,15 +37,12 @@
|
||||
* @(#)autoconf.c 7.20 (Berkeley) 5/9/91
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
#if VAX750
|
||||
|
||||
#include "sys/param.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/device.h"
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "machine/ka750.h"
|
||||
#include "machine/nexus.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/mtpr.h"
|
||||
#include "vax/uba/ubavar.h"
|
||||
@ -54,43 +51,38 @@
|
||||
#include "mba.h"
|
||||
#include "uba.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "vax/include/pmap.h"
|
||||
|
||||
struct nexus *nexus;
|
||||
|
||||
int
|
||||
ka750_conf()
|
||||
{
|
||||
extern char cpu_model[];
|
||||
|
||||
strcpy(cpu_model,"VAX 11/750");
|
||||
config_rootfound("backplane",75);
|
||||
config_rootfound("backplane",(void*)75);
|
||||
}
|
||||
|
||||
int
|
||||
conf_750(){
|
||||
extern int cpu_type, nmba, numuba;
|
||||
extern int cpu_type;
|
||||
|
||||
printf(": 11/750, hardware rev %d, ucode rev %d\n",
|
||||
V750HARDW(cpu_type), V750UCODE(cpu_type));
|
||||
}
|
||||
|
||||
ka750_clock(){
|
||||
u_int i;
|
||||
/*
|
||||
* It's time to start clocks in system...
|
||||
* ka750_clock() makes the 11/750 interrupt clock and todr
|
||||
* register start counting.
|
||||
*/
|
||||
i=~10000; /* Complement of 10000 milliseconds */
|
||||
mtpr(i,PR_NICR); /* Load in count register */
|
||||
mtpr(0x51,PR_ICCS); /* Start clock and enable interrupt */
|
||||
if(mfpr(PR_TODR)){
|
||||
int
|
||||
ka750_clock() {
|
||||
|
||||
mtpr(-10000, PR_NICR); /* Load in count register */
|
||||
mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */
|
||||
if (mfpr(PR_TODR)) {
|
||||
/* todr running */
|
||||
return 0;
|
||||
} else {
|
||||
/* Start TODR register. */
|
||||
mtpr(1,PR_TODR);
|
||||
mtpr(1, PR_TODR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -105,15 +97,8 @@ mbainterrupt(){return;}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 750-specific code.
|
||||
*/
|
||||
|
||||
|
||||
#include "sys/param.h"
|
||||
|
||||
/* #include "mem.h" */
|
||||
|
||||
extern volatile caddr_t mcraddr[];
|
||||
|
||||
struct mcr750 {
|
||||
@ -233,4 +218,23 @@ ka750_mchk(cmcf)
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
ka750_steal_pages()
|
||||
{
|
||||
extern vm_offset_t avail_start, virtual_avail;
|
||||
extern struct nexus *nexus;
|
||||
int junk;
|
||||
|
||||
/*
|
||||
* We take away the pages we need, one for SCB and the rest
|
||||
* for UBA vectors == 1 + 2 will alloc all needed space.
|
||||
* We also set up virtual area for SBI.
|
||||
*/
|
||||
MAPPHYS(junk, V750PGS, VM_PROT_READ|VM_PROT_WRITE);
|
||||
MAPVIRT(nexus, btoc(NEX750SZ));
|
||||
pmap_map((vm_offset_t)nexus, NEX750, NEX750 + NEX750SZ,
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap.c,v 1.17 1995/08/22 04:34:17 ragge Exp $ */
|
||||
/* $NetBSD: pmap.c,v 1.18 1995/11/10 18:52:54 ragge Exp $ */
|
||||
#define DEBUG
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
@ -30,8 +30,6 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "sys/param.h"
|
||||
#include "sys/queue.h"
|
||||
@ -39,28 +37,32 @@
|
||||
#include "sys/proc.h"
|
||||
#include "sys/user.h"
|
||||
#include "sys/msgbuf.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_page.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "vax/include/pte.h"
|
||||
#include "vax/include/pcb.h"
|
||||
#include "vax/include/mtpr.h"
|
||||
#include "vax/include/loconf.h"
|
||||
#include "vax/include/macros.h"
|
||||
#include "vax/include/sid.h"
|
||||
|
||||
#include "uba.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/pcb.h"
|
||||
#include "machine/mtpr.h"
|
||||
#include "machine/macros.h"
|
||||
#include "machine/sid.h"
|
||||
#include "machine/uvaxII.h"
|
||||
#include "machine/cpu.h"
|
||||
#include "machine/scb.h"
|
||||
|
||||
|
||||
pt_entry_t *pmap_virt2pte(pmap_t, u_int);
|
||||
static pv_entry_t alloc_pv_entry();
|
||||
static void free_pv_entry();
|
||||
|
||||
|
||||
#define ISTACK_SIZE (4 * NBPG)
|
||||
#define PTE_TO_PV(pte) (PHYS_TO_PV((pte&PG_FRAME)<<PGSHIFT))
|
||||
|
||||
#define PTE_TO_PV(pte) (PHYS_TO_PV((pte&PG_FRAME)<<PG_SHIFT))
|
||||
|
||||
|
||||
struct pmap kernel_pmap_store;
|
||||
unsigned int gurkskit[50],istack;
|
||||
|
||||
static pv_entry_t alloc_pv_entry();
|
||||
static void free_pv_entry();
|
||||
|
||||
static int prot_array[]={ PG_NONE, PG_RO, PG_RW, PG_RW,
|
||||
PG_RO, PG_RO, PG_RW, PG_RW };
|
||||
@ -68,28 +70,21 @@ static int prot_array[]={ PG_NONE, PG_RO, PG_RW, PG_RW,
|
||||
static int kernel_prot[]={ PG_NONE, PG_KR, PG_KW, PG_KW,
|
||||
PG_RO,PG_KR,PG_KW,PG_URKW};
|
||||
|
||||
static pv_entry_t pv_head =NULL;
|
||||
static unsigned int pv_count=0;
|
||||
vm_offset_t ptemapstart,ptemapend;
|
||||
static pv_entry_t pv_head = NULL;
|
||||
static unsigned int pv_count = 0;
|
||||
|
||||
unsigned *pte_cmap;
|
||||
void *scratch;
|
||||
|
||||
extern uint etext;
|
||||
extern u_int *pte_cmap;
|
||||
extern int maxproc;
|
||||
extern struct vmspace vmspace0;
|
||||
extern int edata, end;
|
||||
uint* UMEMmap;
|
||||
void* Numem;
|
||||
void *scratch;
|
||||
uint sigsida;
|
||||
#ifdef DEBUG
|
||||
int startpmapdebug=0;
|
||||
extern int startsysc, faultdebug;
|
||||
int startpmapdebug = 0;
|
||||
extern int startsysc, faultdebug;
|
||||
#endif
|
||||
unsigned int *valueptr=gurkskit, vmmap;
|
||||
pt_entry_t *Sysmap;
|
||||
vm_map_t pte_map;
|
||||
|
||||
vm_offset_t avail_start, avail_end;
|
||||
unsigned int vmmap;
|
||||
vm_map_t pte_map;
|
||||
|
||||
vm_offset_t avail_start, avail_end;
|
||||
vm_offset_t virtual_avail, virtual_end; /* Available virtual memory */
|
||||
|
||||
/*
|
||||
@ -98,143 +93,148 @@ vm_offset_t virtual_avail, virtual_end; /* Available virtual memory */
|
||||
* Assumes that nothing is mapped, and that kernel stack is located
|
||||
* immediately after end.
|
||||
*/
|
||||
|
||||
void
|
||||
void
|
||||
pmap_bootstrap()
|
||||
{
|
||||
uint i;
|
||||
extern u_int sigcode, esigcode, proc0paddr;
|
||||
extern char *esym;
|
||||
struct pmap *p0pmap=&vmspace0.vm_pmap;
|
||||
vm_offset_t pend=0;
|
||||
#define ROUND_PAGE(x) (((uint)(x) + PAGE_SIZE-1)& ~(PAGE_SIZE - 1))
|
||||
unsigned int junk, sysptsize, istack;
|
||||
extern unsigned int proc0paddr, sigcode, esigcode, etext;
|
||||
extern struct vmspace vmspace0;
|
||||
struct pmap *p0pmap;
|
||||
|
||||
/* These are in phys memory */
|
||||
istack = ROUND_PAGE((uint)Sysmap + SYSPTSIZE * 4);
|
||||
(u_int)scratch = istack + ISTACK_SIZE;
|
||||
mtpr(scratch, PR_ISP); /* set interrupt stack pointer */
|
||||
msgbufp = (void *)(scratch + NBPG * 4);
|
||||
(u_int)pv_table = (int)ROUND_PAGE(sizeof(struct msgbuf)) +
|
||||
(u_int)msgbufp;
|
||||
p0pmap = &vmspace0.vm_pmap;
|
||||
|
||||
/* Count up phys memory */
|
||||
while (!badaddr(pend, 4))
|
||||
pend += NBPG * 128;
|
||||
sysptsize = SYSPTSIZE;
|
||||
/*
|
||||
* Virtual_* and avail_* is used for mapping of system page table.
|
||||
* First set them to their max values and then decrement them.
|
||||
*/
|
||||
virtual_avail = KERNBASE;
|
||||
virtual_end = KERNBASE + sysptsize * NBPG;
|
||||
avail_start = 0;
|
||||
while (!badaddr(avail_end, 4)) /* Memory is in 64K hunks */
|
||||
avail_end += NBPG * 128;
|
||||
|
||||
#if VAX630
|
||||
if (cpu_type == VAX_630)
|
||||
pend -= 8 * NBPG; /* Avoid console scratchpad */
|
||||
#endif
|
||||
#if VAX650
|
||||
if (cpu_type == VAX_650)
|
||||
pend -= 64 * NBPG;
|
||||
#endif
|
||||
/* These are virt only */
|
||||
vmmap = ROUND_PAGE(pv_table + (pend / PAGE_SIZE));
|
||||
(u_int)Numem = vmmap + NBPG * 2;
|
||||
|
||||
(pt_entry_t *)UMEMmap=kvtopte(Numem);
|
||||
(pt_entry_t *)pte_cmap=kvtopte(vmmap);
|
||||
|
||||
avail_start=ROUND_PAGE(vmmap)&0x7fffffff;
|
||||
avail_end=pend-ROUND_PAGE(sizeof(struct msgbuf));
|
||||
virtual_avail=ROUND_PAGE((uint)Numem+NUBA*NBPG*NBPG);
|
||||
virtual_end=SYSPTSIZE*NBPG+KERNBASE;
|
||||
#ifdef DEBUG
|
||||
printf("Sysmap %x, istack %x, scratch %x\n",Sysmap,istack,scratch);
|
||||
printf("etext %x, edata %x, end %x, esym %x\n",
|
||||
&etext,&edata, &end, esym);
|
||||
printf("SYSPTSIZE %x, USRPTSIZE %x\n",SYSPTSIZE,USRPTSIZE);
|
||||
printf("pv_table %x, vmmap %x, Numem %x, pte_cmap %x\n",
|
||||
pv_table,vmmap,Numem,pte_cmap);
|
||||
printf("avail_start %x, avail_end %x\n",avail_start,avail_end);
|
||||
printf("virtual_avail %x,virtual_end %x\n",virtual_avail,virtual_end);
|
||||
printf("clearomr: %x \n",(uint)vmmap-(uint)Sysmap);
|
||||
printf("faultdebug %x, startsysc %x\n",&faultdebug, &startsysc);
|
||||
printf("startpmapdebug %x\n",&startpmapdebug);
|
||||
#endif
|
||||
|
||||
blkclr(Sysmap,(uint)vmmap-(uint)Sysmap);
|
||||
pmap_map(0x80000000,0,2*NBPG,VM_PROT_READ|VM_PROT_WRITE);
|
||||
blkclr(Sysmap, sysptsize * 4); /* clear SPT before using it */
|
||||
/*
|
||||
* Map kernel. Kernel code is always readable for user,
|
||||
* it must be because of the emulation code that is somewhere
|
||||
* in there. And it doesn't hurt, /netbsd is also public readable.
|
||||
* There are also a couple of other things that must be in
|
||||
* physical memory and that isn't managed by the vm system.
|
||||
*/
|
||||
#ifdef DDB
|
||||
pmap_map(0x80000400,2*NBPG,(vm_offset_t)(&etext),
|
||||
MAPPHYS(junk, ((ROUND_PAGE(&etext) - KERNBASE) >> PGSHIFT),
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
#else
|
||||
pmap_map(0x80000400,2*NBPG,(vm_offset_t)(&etext),VM_PROT_EXECUTE);
|
||||
MAPPHYS(junk, ((ROUND_PAGE(&etext) - KERNBASE) >> PGSHIFT),
|
||||
VM_PROT_EXECUTE);
|
||||
#endif
|
||||
pmap_map((vm_offset_t)(&etext),(vm_offset_t)&etext,
|
||||
(vm_offset_t)Sysmap,VM_PROT_READ|VM_PROT_WRITE);
|
||||
pmap_map((vm_offset_t)Sysmap,(vm_offset_t)Sysmap,istack,
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
pmap_map(istack,istack,istack+NBPG,VM_PROT_NONE);/* Red zone */
|
||||
pmap_map(istack+NBPG,istack+NBPG,(vm_offset_t)scratch,
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
pmap_map((vm_offset_t)scratch,(vm_offset_t)scratch,
|
||||
(vm_offset_t)msgbufp, VM_PROT_READ|VM_PROT_WRITE);
|
||||
pmap_map((vm_offset_t)msgbufp, (vm_offset_t)msgbufp,
|
||||
(vm_offset_t)pv_table, VM_PROT_ALL);
|
||||
pmap_map((vm_offset_t)pv_table,(vm_offset_t)pv_table,vmmap,
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
MAPPHYS(junk, (((u_int)Sysmap - ROUND_PAGE(&etext)) >> PGSHIFT),
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/* Init kernel pmap */
|
||||
pmap_kernel()->ref_count = 1;
|
||||
simple_lock_init(&pmap_kernel()->pm_lock);
|
||||
p0pmap->pm_pcb=(struct pcb *)proc0paddr;
|
||||
/* Map System Page Table and zero it, Sysmap already set. */
|
||||
mtpr(avail_start, PR_SBR);
|
||||
MAPPHYS(junk, (ROUND_PAGE(sysptsize * 4) >> PGSHIFT),
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/* used for signal trampoline code */
|
||||
sigsida=(u_int)(scratch+NBPG)&0x7fffffff;
|
||||
bcopy(&sigcode, (void *)sigsida, (u_int)&esigcode-(u_int)&sigcode);
|
||||
/* Map Interrupt stack and set red zone */
|
||||
MAPPHYS(istack, (ISTACK_SIZE >> PGSHIFT), VM_PROT_READ|VM_PROT_WRITE);
|
||||
mtpr(istack + ISTACK_SIZE, PR_ISP);
|
||||
kvtopte(istack)->pg_v = 0;
|
||||
|
||||
p0pmap->pm_pcb->P1BR = (void *)0x80000000;
|
||||
p0pmap->pm_pcb->P0BR = 0;
|
||||
p0pmap->pm_pcb->P1LR = 0x200000;
|
||||
p0pmap->pm_pcb->P0LR = AST_PCB;
|
||||
mtpr(0x80000000, PR_P1BR);
|
||||
mtpr(0, PR_P0BR);
|
||||
mtpr(0x200000, PR_P1LR);
|
||||
mtpr(AST_PCB, PR_P0LR);
|
||||
/* Take four pages for scratch use */
|
||||
MAPPHYS(scratch, 4, VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/* Kernel message buffer */
|
||||
MAPPHYS(msgbufp, ((u_int)ROUND_PAGE(sizeof(struct msgbuf)) >> PGSHIFT),
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/* Physical-to-virtual translation table */
|
||||
MAPPHYS(pv_table, ((avail_end / PAGE_SIZE ) * sizeof(struct pv_entry))
|
||||
>> PGSHIFT, VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/* zero all mapped physical memory from Sysmap to here */
|
||||
blkclr((void *)istack, (avail_start | 0x80000000) - istack);
|
||||
|
||||
/* Now map up what is only needed in virtual memory. */
|
||||
MAPVIRT(vmmap, 2);
|
||||
(pt_entry_t *)pte_cmap = kvtopte(vmmap);
|
||||
|
||||
#ifdef VAX750
|
||||
/*
|
||||
* We move SCB here from physical address 0 to an address
|
||||
* somewhere else, so that we can dynamically allocate
|
||||
* space for interrupt vectors and other machine-specific
|
||||
* things. We move it here, but the rest of the allocation
|
||||
* is done in a cpu-specific routine.
|
||||
* avail_start is modified in the cpu-specific routine.
|
||||
*/
|
||||
scb = (struct scb *)virtual_avail;
|
||||
bcopy(0, (void *)avail_start, NBPG >> 1);
|
||||
mtpr(avail_start, PR_SCBB);
|
||||
bzero(0, NBPG >> 1);
|
||||
(cpu_calls[cpunumber].cpu_steal_pages)();
|
||||
#else
|
||||
#if VAX630
|
||||
if (cpu_type == VAX_630)
|
||||
avail_end -= 8 * NBPG; /* Avoid console scratchpad */
|
||||
#endif
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
printf("Sysmap %x, istack %x, scratch %x\n",Sysmap,istack,scratch);
|
||||
printf("etext %x\n", &etext);
|
||||
printf("SYSPTSIZE %x, USRPTSIZE %x\n",sysptsize,USRPTSIZE);
|
||||
printf("pv_table %x, vmmap %x, pte_cmap %x\n",
|
||||
pv_table,vmmap,pte_cmap);
|
||||
printf("avail_start %x, avail_end %x\n",avail_start,avail_end);
|
||||
printf("virtual_avail %x,virtual_end %x\n",virtual_avail,virtual_end);
|
||||
printf("clearomr: %x \n",(uint)vmmap-(uint)Sysmap);
|
||||
printf("faultdebug %x, startsysc %x\n",&faultdebug, &startsysc);
|
||||
printf("startpmapdebug %x\n",&startpmapdebug);
|
||||
#endif
|
||||
|
||||
|
||||
/* Init kernel pmap */
|
||||
pmap_kernel()->ref_count = 1;
|
||||
simple_lock_init(&pmap_kernel()->pm_lock);
|
||||
p0pmap->pm_pcb = (struct pcb *)proc0paddr;
|
||||
|
||||
p0pmap->pm_pcb->P1BR = (void *)0x80000000;
|
||||
p0pmap->pm_pcb->P0BR = 0;
|
||||
p0pmap->pm_pcb->P1LR = 0x200000;
|
||||
p0pmap->pm_pcb->P0LR = AST_PCB;
|
||||
mtpr(0x80000000, PR_P1BR);
|
||||
mtpr(0, PR_P0BR);
|
||||
mtpr(0x200000, PR_P1LR);
|
||||
mtpr(AST_PCB, PR_P0LR);
|
||||
/*
|
||||
* Now everything should be complete, start virtual memory.
|
||||
*/
|
||||
mtpr((uint)Sysmap&0x7fffffff,PR_SBR); /* Where is SPT? */
|
||||
mtpr(SYSPTSIZE,PR_SLR);
|
||||
mtpr(1,PR_MAPEN);
|
||||
bzero(valueptr, 200);
|
||||
mtpr(SYSPTSIZE, PR_SLR);
|
||||
mtpr(1, PR_MAPEN);
|
||||
}
|
||||
|
||||
/****************************************************************************** *
|
||||
* pmap_init()
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Called as part of vm init.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* pmap_init() is called as part of vm init after memory management
|
||||
* is enabled. It is meant to do machine-specific allocations.
|
||||
* Here we allocate virtual memory for user page tables.
|
||||
*/
|
||||
void
|
||||
pmap_init(s, e)
|
||||
vm_offset_t s,e;
|
||||
pmap_init(start, end)
|
||||
vm_offset_t start, end;
|
||||
{
|
||||
vm_offset_t ptemapstart,ptemapend;
|
||||
|
||||
/* reserve place on SPT for UPT */
|
||||
pte_map = kmem_suballoc(kernel_map, &ptemapstart, &ptemapend,
|
||||
USRPTSIZE * 4, TRUE);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* pmap_create()
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* pmap_t pmap_create(phys_size)
|
||||
*
|
||||
* Create a pmap for a new task.
|
||||
*
|
||||
* Allocate a pmap form kernel memory with malloc.
|
||||
* Clear the pmap.
|
||||
* Allocate a ptab for the pmap.
|
||||
*
|
||||
|
||||
/*
|
||||
* pmap_create() creates a pmap for a new task.
|
||||
* If not already allocated, malloc space for one.
|
||||
*/
|
||||
pmap_t
|
||||
pmap_create(phys_size)
|
||||
@ -245,9 +245,8 @@ pmap_create(phys_size)
|
||||
#ifdef DEBUG
|
||||
if(startpmapdebug)printf("pmap_create: phys_size %x\n",phys_size);
|
||||
#endif
|
||||
if(phys_size) return NULL;
|
||||
|
||||
/* Malloc place for pmap struct */
|
||||
if (phys_size)
|
||||
return NULL;
|
||||
|
||||
pmap = (pmap_t) malloc(sizeof(struct pmap), M_VMPMAP, M_WAITOK);
|
||||
pmap_pinit(pmap);
|
||||
@ -337,18 +336,18 @@ printf("pmap_enter: pmap: %x,virt %x, phys %x,pv %x prot %x\n",
|
||||
|
||||
if (v < 0x40000000) {
|
||||
patch = (int *)pmap->pm_pcb->P0BR;
|
||||
i = (v >> PG_SHIFT);
|
||||
i = (v >> PGSHIFT);
|
||||
if (i >= (pmap->pm_pcb->P0LR&~AST_MASK))
|
||||
pmap_expandp0(pmap, i);
|
||||
patch = (int *)pmap->pm_pcb->P0BR;
|
||||
} else if (v < (u_int)0x80000000) {
|
||||
patch = (int *)pmap->pm_pcb->P1BR;
|
||||
i = (v - 0x40000000) >> PG_SHIFT;
|
||||
i = (v - 0x40000000) >> PGSHIFT;
|
||||
if (i < pmap->pm_pcb->P1LR)
|
||||
panic("pmap_enter: must expand P1");
|
||||
} else {
|
||||
patch = (int *)Sysmap;
|
||||
i = (v - (u_int)0x80000000) >> PG_SHIFT;
|
||||
i = (v - (u_int)0x80000000) >> PGSHIFT;
|
||||
}
|
||||
|
||||
if ((patch[i] & PG_FRAME) == (pte & PG_FRAME)) { /* no map change */
|
||||
@ -419,7 +418,9 @@ pmap_map(virtuell, pstart, pend, prot)
|
||||
int *pentry;
|
||||
|
||||
#ifdef DEBUG
|
||||
if(startpmapdebug)printf("pmap_map: virt %x, pstart %x, pend %x\n",virtuell, pstart, pend);
|
||||
if(startpmapdebug)
|
||||
printf("pmap_map: virt %x, pstart %x, pend %x, Sysmap %x\n",
|
||||
virtuell, pstart, pend, Sysmap);
|
||||
#endif
|
||||
|
||||
pstart=(uint)pstart &0x7fffffff;
|
||||
@ -445,7 +446,7 @@ if(startpmapdebug)printf("pmap_extract: pmap %x, va %x\n",pmap, va);
|
||||
#endif
|
||||
|
||||
pte=(int *)pmap_virt2pte(pmap,va);
|
||||
if(pte) return(((*pte&PG_FRAME)<<PG_SHIFT)+((u_int)va&PGOFSET));
|
||||
if(pte) return(((*pte&PG_FRAME)<<PGSHIFT)+((u_int)va&PGOFSET));
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@ -471,14 +472,14 @@ if(startpmapdebug) printf("pmap_protect: pmap %x, start %x, end %x, prot %x\n",
|
||||
else pte=prot_array[prot];
|
||||
|
||||
if(end<0x40000000){
|
||||
while((end>>PG_SHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK))
|
||||
pmap_expandp0(pmap,(end>>PG_SHIFT));
|
||||
while((end>>PGSHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK))
|
||||
pmap_expandp0(pmap,(end>>PGSHIFT));
|
||||
} else if(end<(u_int)0x80000000){
|
||||
u_int i;
|
||||
i=(start&0x3fffffff)>>PG_SHIFT;
|
||||
i=(start&0x3fffffff)>>PGSHIFT;
|
||||
if(i<pmap->pm_pcb->P1LR)
|
||||
start=((pmap->pm_pcb->P1LR)<<PG_SHIFT)+0x40000000;
|
||||
i=(end&0x3fffffff)>>PG_SHIFT;
|
||||
start=((pmap->pm_pcb->P1LR)<<PGSHIFT)+0x40000000;
|
||||
i=(end&0x3fffffff)>>PGSHIFT;
|
||||
if(i<pmap->pm_pcb->P1LR) return;
|
||||
}
|
||||
while (start < end) {
|
||||
@ -519,17 +520,17 @@ if(startpmapdebug) printf("pmap_remove: pmap=0x %x, start=0x %x, slut=0x %x\n",
|
||||
/* First, get pte first address */
|
||||
if(start<0x40000000){ /* P0 */
|
||||
if(!(temp=pmap->pm_pcb->P0BR)) return; /* No page table */
|
||||
ptestart=&temp[start>>PG_SHIFT];
|
||||
pteslut=&temp[slut>>PG_SHIFT];
|
||||
ptestart=&temp[start>>PGSHIFT];
|
||||
pteslut=&temp[slut>>PGSHIFT];
|
||||
if(pteslut>&temp[(pmap->pm_pcb->P0LR&~AST_MASK)])
|
||||
pteslut=&temp[(pmap->pm_pcb->P0LR&~AST_MASK)];
|
||||
} else if(start>0x7fffffff){ /* System region */
|
||||
ptestart=(u_int *)&Sysmap[(start&0x3fffffff)>>PG_SHIFT];
|
||||
pteslut=(u_int *)&Sysmap[(slut&0x3fffffff)>>PG_SHIFT];
|
||||
ptestart=(u_int *)&Sysmap[(start&0x3fffffff)>>PGSHIFT];
|
||||
pteslut=(u_int *)&Sysmap[(slut&0x3fffffff)>>PGSHIFT];
|
||||
} else { /* P1 (stack) region */
|
||||
if(!(temp=pmap->pm_pcb->P1BR)) return; /* No page table */
|
||||
pteslut=&temp[(slut&0x3fffffff)>>PG_SHIFT];
|
||||
ptestart=&temp[(start&0x3fffffff)>>PG_SHIFT];
|
||||
pteslut=&temp[(slut&0x3fffffff)>>PGSHIFT];
|
||||
ptestart=&temp[(start&0x3fffffff)>>PGSHIFT];
|
||||
if(ptestart<&temp[pmap->pm_pcb->P1LR])
|
||||
ptestart=&temp[pmap->pm_pcb->P1LR];
|
||||
}
|
||||
@ -592,6 +593,7 @@ remove_pmap_from_mapping(pv, pmap)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef notyet
|
||||
void
|
||||
pmap_copy_page(src, dst)
|
||||
vm_offset_t src;
|
||||
@ -616,6 +618,37 @@ if(startpmapdebug)printf("pmap_copy_page: src %x, dst %x\n",src, dst);
|
||||
bcopy((void *)vmmap, (void *)vmmap+NBPG, NBPG);
|
||||
splx(s);
|
||||
}
|
||||
#else
|
||||
asm("
|
||||
|
||||
_pmap_copy_page:.globl _pmap_copy_page
|
||||
|
||||
.word 64
|
||||
mfpr $0x12, r6
|
||||
mtpr $0x16, $0x12 # splimp();
|
||||
movl _vmmap, r0
|
||||
movl _pte_cmap, r1
|
||||
|
||||
ashl $-9, 4(ap), r2 # pte_cmap[0]=(src>>PGSHIFT)|PG_V|PG_RO;
|
||||
bisl3 $0xf8000000, r2, (r1)
|
||||
addl2 $4, r1
|
||||
addl3 $1, r2, (r1)+
|
||||
|
||||
ashl $-9, 8(ap), r2 # pte_cmap[1]=(dst>>PGSHIFT)|PG_V|PG_KW;
|
||||
bisl3 $0xa0000000, r2, (r1)
|
||||
addl2 $4, r1
|
||||
addl3 $1, r2, (r1)
|
||||
|
||||
mtpr $0, $57 # mtpr(0, PR_TBIA);
|
||||
|
||||
addl3 $1024, r0, r1 # bcopy(vmmap, vmmap + 2 * NBPG, 2 * NBPG);
|
||||
movc3 $1024, (r0), (r1)
|
||||
|
||||
mtpr r6, $0x12
|
||||
ret
|
||||
|
||||
");
|
||||
#endif
|
||||
|
||||
pv_entry_t
|
||||
alloc_pv_entry()
|
||||
@ -625,6 +658,10 @@ alloc_pv_entry()
|
||||
if(!pv_head) {
|
||||
temporary=(pv_entry_t)malloc(sizeof(struct pv_entry),
|
||||
M_VMPVENT, M_NOWAIT);
|
||||
#ifdef DIAGNOSTIC
|
||||
if (temporary == 0)
|
||||
panic("alloc_pv_entry");
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
if(startpmapdebug) printf("alloc_pv_entry: %x\n",temporary);
|
||||
#endif
|
||||
@ -837,7 +874,7 @@ if(startpmapdebug)printf("pmap_zero_page(phys %x, vmmap %x, pte_cmap %x\n",
|
||||
phys,vmmap,pte_cmap);
|
||||
#endif
|
||||
s=splimp();
|
||||
pte_cmap[0]=(phys>>PG_SHIFT)|PG_V|PG_KW;
|
||||
pte_cmap[0]=(phys>>PGSHIFT)|PG_V|PG_KW;
|
||||
pte_cmap[1]=pte_cmap[0]+1;
|
||||
mtpr(vmmap,PR_TBIS);
|
||||
mtpr(vmmap+NBPG,PR_TBIS);
|
||||
@ -857,17 +894,17 @@ pmap_virt2pte(pmap,vaddr)
|
||||
|
||||
if(vaddr<0x40000000){
|
||||
pte=pmap->pm_pcb->P0BR;
|
||||
if((vaddr>>PG_SHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) return 0;
|
||||
if((vaddr>>PGSHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) return 0;
|
||||
} else if(vaddr<(u_int)0x80000000){
|
||||
pte=pmap->pm_pcb->P1BR;
|
||||
if(((vaddr&0x3fffffff)>>PG_SHIFT)<pmap->pm_pcb->P1LR) return 0;
|
||||
if(((vaddr&0x3fffffff)>>PGSHIFT)<pmap->pm_pcb->P1LR) return 0;
|
||||
} else {
|
||||
pte=(u_int *)Sysmap;
|
||||
}
|
||||
|
||||
vaddr&=(u_int)0x3fffffff;
|
||||
|
||||
return((pt_entry_t *)&pte[vaddr>>PG_SHIFT]);
|
||||
return((pt_entry_t *)&pte[vaddr>>PGSHIFT]);
|
||||
}
|
||||
|
||||
pmap_expandp0(pmap,ny_storlek)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uvaxII.c,v 1.2 1995/04/18 22:08:25 ragge Exp $ */
|
||||
/* $NetBSD: uvaxII.c,v 1.3 1995/11/10 18:52:58 ragge Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988 The Regents of the University of California.
|
||||
@ -37,34 +37,28 @@
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
#if VAX630 || VAX410
|
||||
|
||||
#include "sys/param.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/device.h"
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
|
||||
#include "machine/uvaxII.h"
|
||||
#include "machine/nexus.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/mtpr.h"
|
||||
#include "machine/sid.h"
|
||||
#include "vax/uba/ubavar.h"
|
||||
#include "vax/uba/ubareg.h"
|
||||
#include "machine/pmap.h"
|
||||
#include "machine/nexus.h"
|
||||
|
||||
#include "mba.h"
|
||||
#include "uba.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "vax/include/pmap.h"
|
||||
|
||||
struct nexus *nexus;
|
||||
struct uvaxIIcpu *uvaxIIcpu_ptr;
|
||||
|
||||
#if VAX630
|
||||
struct ka630clock *ka630clk_ptr;
|
||||
u_long ka630_clkread();
|
||||
void ka630_clkwrite();
|
||||
struct ka630clock *ka630clk_ptr;
|
||||
u_long ka630_clkread();
|
||||
void ka630_clkwrite();
|
||||
#endif
|
||||
extern int cpu_type, nmba, numuba;
|
||||
|
||||
extern int cpu_type;
|
||||
|
||||
int
|
||||
uvaxII_conf()
|
||||
@ -251,12 +245,48 @@ ka630_clkwrite(year_secs)
|
||||
claddr->min = t / MINSEC;
|
||||
claddr->sec = t % MINSEC;
|
||||
#ifndef lint
|
||||
{ int t = claddr->csr2; } /* ??? */
|
||||
{ int t = claddr->csr3; } /* ??? */
|
||||
{ volatile int t = claddr->csr2; } /* ??? */
|
||||
{ volatile int t = claddr->csr3; } /* ??? */
|
||||
#endif
|
||||
claddr->csr0 = KA630CLK_RATE;
|
||||
claddr->csr1 = KA630CLK_ENABLE;
|
||||
splx(s);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uvaxII_steal_pages()
|
||||
{
|
||||
extern vm_offset_t avail_start, virtual_avail, avail_end;
|
||||
int junk;
|
||||
|
||||
/*
|
||||
* MicroVAX II: get 10 pages from top of memory,
|
||||
* map in Qbus map registers, cpu and clock registers.
|
||||
*/
|
||||
avail_end -= 10;
|
||||
|
||||
MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE);
|
||||
MAPVIRT(nexus, btoc(0x400000));
|
||||
pmap_map((vm_offset_t)nexus, 0x20088000, 0x20090000,
|
||||
VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
MAPVIRT(uvaxIIcpu_ptr, 1);
|
||||
pmap_map((vm_offset_t)uvaxIIcpu_ptr, (vm_offset_t)UVAXIICPU,
|
||||
(vm_offset_t)UVAXIICPU + NBPG, VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
MAPVIRT(ka630clk_ptr, 1);
|
||||
pmap_map((vm_offset_t)ka630clk_ptr, (vm_offset_t)KA630CLK,
|
||||
(vm_offset_t)KA630CLK + NBPG, VM_PROT_READ|VM_PROT_WRITE);
|
||||
|
||||
/*
|
||||
* Clear restart and boot in progress flags
|
||||
* in the CPMBX.
|
||||
/
|
||||
ka630clk_ptr->cpmbx = (ka630clk_ptr->cpmbx & KA630CLK_LANG);
|
||||
|
||||
/*
|
||||
* Enable memory parity error detection and clear error bits.
|
||||
*/
|
||||
uvaxIIcpu_ptr->uvaxII_mser = (UVAXIIMSER_PEN | UVAXIIMSER_MERR |
|
||||
UVAXIIMSER_LEB);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user