- Move MachSetPID(1) call to pmap_bootstrap() adajacent to kernel pmap

initialization code.
- Abandon mips_init_proc0() and do the 4 lines straightly in MD mach_init().
- Restore a block of code accidentally lost in prevous commit.
- Change the term 'tlbpid' to a MIPS3 nomenclature 'asid'.
- Hide PTE size exposures by symbolic names in locore.S
This commit is contained in:
nisimura 1999-05-18 01:36:51 +00:00
parent dbdf646ecf
commit c99765853f
8 changed files with 113 additions and 90 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.29 1999/03/23 22:04:01 simonb Exp $ */
/* $NetBSD: cpu.h,v 1.30 1999/05/18 01:36:51 nisimura Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -184,7 +184,6 @@ caddr_t allocsys __P((caddr_t));
void dumpsys __P((void));
int savectx __P((struct user *));
void mips_init_msgbuf __P((void));
void mips_init_proc0 __P((caddr_t));
/* locore.S */
void savefpregs __P((struct proc *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.26 1999/04/24 08:10:36 simonb Exp $ */
/* $NetBSD: pmap.h,v 1.27 1999/05/18 01:36:51 nisimura Exp $ */
/*
* Copyright (c) 1987 Carnegie-Mellon University
@ -85,8 +85,8 @@ typedef struct pmap {
int pm_count; /* pmap reference count */
simple_lock_data_t pm_lock; /* lock on pmap */
struct pmap_statistics pm_stats; /* pmap statistics */
int pm_tlbpid; /* address space tag */
u_int pm_tlbgen; /* TLB PID generation number */
unsigned pm_asid; /* TLB address space tag */
unsigned pm_asidgen; /* its generation number */
struct segtab *pm_segtab; /* pointers to pages of PTEs */
} *pmap_t;
@ -98,7 +98,7 @@ typedef struct pmap {
typedef struct pv_entry {
struct pv_entry *pv_next; /* next pv_entry */
struct pmap *pv_pmap; /* pmap where mapping lies */
vaddr_t pv_va; /* virtual address for mapping */
vaddr_t pv_va; /* virtual address for mapping */
int pv_flags; /* some flags for the mapping */
} *pv_entry_t;
@ -109,11 +109,11 @@ typedef struct pv_entry {
#ifdef _KERNEL
char *pmap_attributes; /* reference and modify bits */
struct pmap kernel_pmap_store;
extern char *pmap_attributes; /* reference and modify bits */
extern struct pmap kernel_pmap_store;
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
#define pmap_kernel() (&kernel_pmap_store)
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
/*

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.11 1999/03/26 03:40:41 tsubai Exp $
# $NetBSD: genassym.cf,v 1.12 1999/05/18 01:36:52 nisimura Exp $
#
# Copyright (c) 1997
# Jonathan Stone. All rights reserved.
@ -61,7 +61,8 @@ define P_PRIORITY offsetof(struct proc, p_priority)
define P_ADDR offsetof(struct proc, p_addr)
define P_MD_REGS offsetof(struct proc, p_md.md_regs)
define P_MD_UPTE offsetof(struct proc, p_md.md_upte)
define P_MD_UPTE_0 offsetof(struct proc, p_md.md_upte[0])
define P_MD_UPTE_1 offsetof(struct proc, p_md.md_upte[1])
define U_PCB_FPREGS offsetof(struct user, u_pcb.pcb_fpregs)
define U_PCB_CONTEXT offsetof(struct user, u_pcb.pcb_context)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.71 1999/05/07 01:30:26 nisimura Exp $ */
/* $NetBSD: locore.S,v 1.72 1999/05/18 01:36:52 nisimura Exp $ */
/*
* Copyright (c) 1992, 1993
@ -322,16 +322,16 @@ sw1:
* Switch to new context.
*/
sw zero, _C_LABEL(want_resched)
jal _C_LABEL(pmap_alloc_tlbpid) # v0 = TLB PID
jal _C_LABEL(pmap_alloc_asid) # v0 = new proc's ASID
move s0, a0 # BDSLOT: save p
lw a0, P_ADDR(s0) # a0 = p_addr
lw a1, P_MD_UPTE+0(s0) # a1 = first u. pte
lw a2, P_MD_UPTE+4(s0) # a2 = 2nd u. pte
lw a1, P_MD_UPTE_0(s0) # a1 = first u. pte
lw a2, P_MD_UPTE_1(s0) # a2 = 2nd u. pte
lw s1, _C_LABEL(mips_locore_jumpvec) + MIPSX_CPU_SWITCH_RESUME
sw s0, _C_LABEL(curproc) # set curproc
sw a0, _C_LABEL(curpcb) # set curpcb
jal ra, s1 # CPU-specific: resume process
move a3, v0 # BDSLOT: a3 = TLB PID
move a3, v0 # BDSLOT: a3 = ASID
REG_PROLOGUE
REG_L v0, U_PCB_CONTEXT+SF_REG_ST(a0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips_machdep.c,v 1.51 1999/04/25 02:56:28 simonb Exp $ */
/* $NetBSD: mips_machdep.c,v 1.52 1999/05/18 01:36:52 nisimura Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -52,7 +52,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.51 1999/04/25 02:56:28 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.52 1999/05/18 01:36:52 nisimura Exp $");
#include "opt_bufcache.h"
#include "opt_compat_netbsd.h"
@ -1216,24 +1216,3 @@ mips_init_msgbuf()
"in last cluster (%d used)\n",
round_page(MSGBUFSIZE), sz);
}
/*
* Initialize the U-area for proc0. Since these need to be set up
* before we can probe for memory, we have to use stolen pages before
* they're loaded into the VM system.
*
* "space" is USPACE in size, must be page aligned, and in KSEG0.
*/
void
mips_init_proc0(space)
caddr_t space;
{
/* XXX Flush cache?? */
memset(space, 0, USPACE);
proc0.p_addr = proc0paddr = (struct user *)space;
curpcb = &proc0.p_addr->u_pcb;
MachSetPID(1); /* Also establishes context using curpcb */
proc0.p_md.md_regs = (void *)((struct frame *)((int)curpcb+USPACE) - 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.59 1999/05/17 11:12:44 nisimura Exp $ */
/* $NetBSD: pmap.c,v 1.60 1999/05/18 01:36:51 nisimura Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 1999/05/17 11:12:44 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60 1999/05/18 01:36:51 nisimura Exp $");
/*
* Manages physical address maps.
@ -185,10 +185,10 @@ struct pv_entry *pv_table;
int pv_table_npages;
struct segtab *free_segtab; /* free list kept locally */
u_int tlbpid_gen = 1; /* TLB PID generation count */
int tlbpid_cnt = 2; /* next available TLB PID */
pt_entry_t *Sysmap; /* kernel pte table */
u_int Sysmapsize; /* number of pte's in Sysmap */
unsigned Sysmapsize; /* number of pte's in Sysmap */
unsigned pmap_next_asid = 2; /* next available ASID */
unsigned pmap_asid_generation = 1; /* ASID generation count */
boolean_t pmap_initialized = FALSE;
@ -213,7 +213,7 @@ boolean_t pmap_initialized = FALSE;
/* Forward function declarations */
int pmap_remove_pv __P((pmap_t pmap, vaddr_t va, paddr_t pa));
int pmap_alloc_tlbpid __P((struct proc *p));
int pmap_alloc_asid __P((struct proc *p));
void pmap_zero_page __P((paddr_t phys));
void pmap_enter_pv __P((pmap_t, vaddr_t, paddr_t, u_int *));
pt_entry_t *pmap_pte __P((pmap_t, vaddr_t));
@ -250,9 +250,41 @@ mips_flushcache_allpvh(paddr_t pa)
*/
void
pmap_bootstrap()
{
extern int physmem;
/*
* Initialize `FYI' variables. Note we're relying on
* Figure out how many PTE's are necessary to map the kernel.
* The '2048' comes from PAGER_MAP_SIZE in vm_pager_init().
* This should be kept in sync.
* We also reserve space for kmem_alloc_pageable() for vm_fork().
*/
Sysmapsize = (VM_KMEM_SIZE + VM_PHYS_SIZE +
nbuf * MAXBSIZE + 16 * NCARGS) / NBPG + 2048 +
(maxproc * UPAGES);
#ifdef SYSVSHM
Sysmapsize += shminfo.shmall;
#endif
Sysmap = (pt_entry_t *)
pmap_steal_memory(sizeof(pt_entry_t) * Sysmapsize, NULL, NULL);
/*
* Allocate memory for the pv_heads. (A few more of the latter
* are allocated than are needed.)
*
* We could do this in pmap_init when we know the actual
* managed page pool size, but its better to use kseg0
* addresses rather than kernel virtual addresses mapped
* through the TLB.
*/
pv_table_npages = physmem;
pv_table = (struct pv_entry *)
pmap_steal_memory(sizeof(struct pv_entry) * pv_table_npages,
NULL, NULL);
/*
* Initialize `FYI' variables. Note we're relying on
* the fact that BSEARCH sorts the vm_physmem[] array
* for us.
*/
@ -269,8 +301,10 @@ pmap_bootstrap()
*/
simple_lock_init(&pmap_kernel()->pm_lock);
pmap_kernel()->pm_count = 1;
pmap_kernel()->pm_tlbpid = 1;
pmap_kernel()->pm_tlbgen = tlbpid_gen;
pmap_kernel()->pm_asid = 1;
pmap_kernel()->pm_asidgen = pmap_asid_generation;
MachSetPID(1);
#if 0 /* no need, no good, no use */
proc0paddr->u_pcb.pcb_segtab = pmap_kernel()->pm_segtab = NULL;
@ -504,8 +538,8 @@ pmap_pinit(pmap)
if (pmap->pm_segtab->seg_tab[i] != 0)
panic("pmap_pinit: pm_segtab != 0");
#endif
pmap->pm_tlbpid = 0;
pmap->pm_tlbgen = 0;
pmap->pm_asid = 0;
pmap->pm_asidgen = 0;
}
/*
@ -625,8 +659,8 @@ pmap_activate(p)
p->p_addr->u_pcb.pcb_segtab = pmap->pm_segtab;
if (p == curproc) {
int tlbpid = pmap_alloc_tlbpid(p);
MachSetPID(tlbpid);
int asid = pmap_alloc_asid(p);
MachSetPID(asid);
#ifdef MIPS3
if (CPUISMIPS3) {
mips3_write_xcontext_upper((u_int32_t)pmap->pm_segtab);
@ -747,8 +781,8 @@ pmap_remove(pmap, sva, eva)
/*
* Flush the TLB for the given address.
*/
if (pmap->pm_tlbgen == tlbpid_gen) {
MachTLBFlushAddr(sva | (pmap->pm_tlbpid <<
if (pmap->pm_asidgen == pmap_asid_generation) {
MachTLBFlushAddr(sva | (pmap->pm_asid <<
MIPS_TLB_PID_SHIFT));
#ifdef DEBUG
remove_stats.flushes++;
@ -910,8 +944,8 @@ pmap_protect(pmap, sva, eva, prot)
/*
* Update the TLB if the given address is in the cache.
*/
if (pmap->pm_tlbgen == tlbpid_gen)
MachTLBUpdate(sva | (pmap->pm_tlbpid <<
if (pmap->pm_asidgen == pmap_asid_generation)
MachTLBUpdate(sva | (pmap->pm_asid <<
MIPS_TLB_PID_SHIFT), entry);
}
}
@ -1020,10 +1054,10 @@ pmap_page_cache(pa, mode)
entry = (entry & ~MIPS3_PG_CACHEMODE)
| newmode;
pte->pt_entry = entry;
if (pv->pv_pmap->pm_tlbgen ==
tlbpid_gen)
if (pv->pv_pmap->pm_asidgen ==
pmap_asid_generation)
MachTLBUpdate(pv->pv_va |
(pv->pv_pmap->pm_tlbpid <<
(pv->pv_pmap->pm_asid <<
MIPS3_TLB_PID_SHIFT),
entry);
}
@ -1233,8 +1267,8 @@ pmap_enter(pmap, va, pa, prot, wired, access_type)
#ifdef DEBUG
if (pmapdebug & PDB_ENTER) {
printf("pmap_enter: new pte %x", npte);
if (pmap->pm_tlbgen == tlbpid_gen)
printf(" tlbpid %d", pmap->pm_tlbpid);
if (pmap->pm_asidgen == pmap_asid_generation)
printf(" asid %d", pmap->pm_asid);
printf("\n");
}
#endif
@ -1249,8 +1283,8 @@ pmap_enter(pmap, va, pa, prot, wired, access_type)
if (!mips_pg_v(pte->pt_entry))
pmap->pm_stats.resident_count++;
pte->pt_entry = npte;
if (pmap->pm_tlbgen == tlbpid_gen)
MachTLBUpdate(va | (pmap->pm_tlbpid <<
if (pmap->pm_asidgen == pmap_asid_generation)
MachTLBUpdate(va | (pmap->pm_asid <<
MIPS_TLB_PID_SHIFT), npte);
va += NBPG;
npte += vad_to_pfn(NBPG);
@ -1737,46 +1771,46 @@ pmap_phys_address(ppn)
*/
/*
* Allocate a hardware PID and return it.
* Allocate TLB address space tag (called ASID or TLBPID) and return it.
* It takes almost as much or more time to search the TLB for a
* specific PID and flush those entries as it does to flush the entire TLB.
* Therefore, when we allocate a new PID, we just take the next number. When
* specific ASID and flush those entries as it does to flush the entire TLB.
* Therefore, when we allocate a new ASID, we just take the next number. When
* we run out of numbers, we flush the TLB, increment the generation count
* and start over. PID zero is reserved for kernel use.
* and start over. ASID zero is reserved for kernel use.
*/
int
pmap_alloc_tlbpid(p)
pmap_alloc_asid(p)
struct proc *p;
{
pmap_t pmap;
pmap = p->p_vmspace->vm_map.pmap;
if (pmap->pm_tlbgen == tlbpid_gen)
if (pmap->pm_asidgen == pmap_asid_generation)
;
else {
if (tlbpid_cnt == MIPS_TLB_NUM_PIDS) {
if (pmap_next_asid == MIPS_TLB_NUM_PIDS) {
MachTLBFlush();
/* reserve tlbpid_gen == 0 to alway mean invalid */
if (++tlbpid_gen == 0)
tlbpid_gen = 1;
tlbpid_cnt = 1;
/* reserve == 0 to always mean invalid */
if (++pmap_asid_generation == 0)
pmap_asid_generation = 1;
pmap_next_asid = 1;
}
pmap->pm_tlbpid = tlbpid_cnt++;
pmap->pm_tlbgen = tlbpid_gen;
pmap->pm_asid = pmap_next_asid++;
pmap->pm_asidgen = pmap_asid_generation;
}
#ifdef DEBUG
if (pmapdebug & (PDB_FOLLOW|PDB_TLBPID)) {
if (curproc)
printf("pmap_alloc_tlbpid: curproc %d '%s' ",
printf("pmap_alloc_asid: curproc %d '%s' ",
curproc->p_pid, curproc->p_comm);
else
printf("pmap_alloc_tlbpid: curproc <none> ");
printf("segtab %p tlbpid %d pid %d '%s'\n",
pmap->pm_segtab, pmap->pm_tlbpid, p->p_pid, p->p_comm);
printf("pmap_alloc_asid: curproc <none> ");
printf("segtab %p asid %d pid %d '%s'\n",
pmap->pm_segtab, pmap->pm_asid, p->p_pid, p->p_comm);
}
#endif
return (pmap->pm_tlbpid);
return (pmap->pm_asid);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.25 1999/04/11 04:04:08 chs Exp $ */
/* $NetBSD: machdep.c,v 1.26 1999/05/18 01:36:52 nisimura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.25 1999/04/11 04:04:08 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 1999/05/18 01:36:52 nisimura Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@ -174,6 +174,8 @@ struct idrom idrom;
/* locore callback-vector setup */
extern void mips_vector_init __P((void));
extern struct user *proc0paddr;
/*
* Do all the stuff that locore normally does before calling main().
* Process arguments passed to us by the prom monitor.
@ -252,9 +254,13 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
#endif
/*
* Init mapping for u page(s) for proc0, pm_tlbpid 1.
* Alloc u pages for proc0 stealing KSEG0 memory.
*/
mips_init_proc0(kernend);
proc0.p_addr = proc0paddr = (struct user *)kernend;
proc0.p_md.md_regs =
(struct frame *)((caddr_t)kernend + UPAGES * PAGE_SIZE) - 1;
curpcb = &proc0.p_addr->u_pcb;
memset(kernend, 0, UPAGES * PAGE_SIZE);
kernend += UPAGES * PAGE_SIZE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.141 1999/05/11 05:06:35 nisimura Exp $ */
/* $NetBSD: machdep.c,v 1.142 1999/05/18 01:36:51 nisimura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.141 1999/05/11 05:06:35 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.142 1999/05/18 01:36:51 nisimura Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@ -189,6 +189,7 @@ struct platform platform = {
};
extern caddr_t esym;
extern struct user *proc0paddr;
extern struct consdev promcd;
/*
@ -351,11 +352,14 @@ mach_init(argc, argv, code, cv, bim, bip)
if (boothowto & RB_KDB)
Debugger();
#endif
/*
* Init mapping for u page(s) for proc0, pm_tlbpid 1.
* Alloc u pages for proc0 stealing KSEG0 memory.
*/
mips_init_proc0(kernend);
proc0.p_addr = proc0paddr = (struct user *)kernend;
proc0.p_md.md_regs =
(struct frame *)((caddr_t)kernend + UPAGES * PAGE_SIZE) - 1;
curpcb = &proc0.p_addr->u_pcb;
memset(kernend, 0, UPAGES * PAGE_SIZE);
kernend += UPAGES * PAGE_SIZE;