mips pmap_activate:
* prototype and definition for pmap_activate(p). Updates the segtab, and changes the active ASID if p == curproc. * Make reserved fixed-address (UADDR) kernelstack PTEs global, so we still have a kernel stack after pmap_activate() on curproc. * make KSEG2 mappings for p_addr global (see above.) Seems to detune contextswitch and NTP resolution (by 60 ms), but thepmap_activate() interface is mandatory. Needs more thought.
This commit is contained in:
parent
cbb2b5d0fb
commit
003ccf3b1c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap.h,v 1.14 1997/07/29 01:43:26 mhitch Exp $ */
|
||||
/* $NetBSD: pmap.h,v 1.15 1997/08/09 03:41:02 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 Carnegie-Mellon University
|
||||
@ -122,6 +122,8 @@ void pmap_prefer __P((vm_offset_t, vm_offset_t *));
|
||||
#endif /* MIPS3 */
|
||||
|
||||
|
||||
void pmap_activate __P((register struct proc *p));
|
||||
|
||||
/*
|
||||
* Kernel cache operations for the user-space API
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.44 1997/08/08 06:52:59 jonathan Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.45 1997/08/09 03:41:03 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -760,13 +760,13 @@ sw1:
|
||||
jal _C_LABEL(pmap_alloc_tlbpid) # v0 = TLB PID
|
||||
move s0, a0 # BDSLOT: save p
|
||||
sw s0, _C_LABEL(curproc) # set curproc
|
||||
lw t0, P_MD_UPTE+0(s0) # t0 = first u. pte
|
||||
lw t1, P_MD_UPTE+4(s0) # t1 = 2nd u. pte
|
||||
lw s0, P_ADDR(s0)
|
||||
lw a1, P_MD_UPTE+0(s0) # a1 = first u. pte
|
||||
lw a2, P_MD_UPTE+4(s0) # a2 = 2nd u. pte
|
||||
lw a0, P_ADDR(s0) # a0 = p_addr
|
||||
lw s1, _C_LABEL(mips_locore_jumpvec) + MIPSX_CPU_SWITCH_RESUME
|
||||
sw s0, _C_LABEL(curpcb) # set curpcb
|
||||
sw a0, _C_LABEL(curpcb) # set curpcb
|
||||
jr s1 # CPU-specific: resume process
|
||||
nop
|
||||
move a3, v0 # BDSLOT: a3 = TLB PID
|
||||
END(cpu_switch)
|
||||
|
||||
/*
|
||||
@ -1492,17 +1492,18 @@ END(splx)
|
||||
*
|
||||
* Return the current value of the cause register.
|
||||
*
|
||||
* mips_read_causereg(void)
|
||||
* int mips_read_causereg(void)
|
||||
*
|
||||
* Results:
|
||||
* current value of Cause register.None.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
* Not profiled, skews CPU-clock measurement to uselessness.
|
||||
*
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
LEAF(mips_read_causereg)
|
||||
NLEAF(mips_read_causereg)
|
||||
mfc0 v0, MIPS_COP_0_CAUSE_REG
|
||||
j ra
|
||||
nop
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore_r2000.S,v 1.39 1997/07/20 19:48:13 jonathan Exp $ */
|
||||
/* $NetBSD: locore_r2000.S,v 1.40 1997/08/09 03:41:05 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -1645,9 +1645,10 @@ END(mips1_switch_exit)
|
||||
* Also, there should be no TLB faults at this point.
|
||||
*
|
||||
* Entered from CPU-common cpu_switch()
|
||||
* v0 = TLB Process ID for this process
|
||||
* t0 = First u.pte
|
||||
* t1 = Second u.pte
|
||||
* a0 = p_addr [curpcb]
|
||||
* a1 = First u.pte
|
||||
* a2 = Second u.pte
|
||||
* a3 = TLB Process ID for this process
|
||||
*/
|
||||
/*
|
||||
* XXXX - almost done with the UADDR mapping; only the kernel stack should
|
||||
@ -1656,27 +1657,29 @@ END(mips1_switch_exit)
|
||||
* map the current u-area. Also, any current mapping for the u-area
|
||||
* address space needs to be flushed as well.
|
||||
*
|
||||
* Both the UADDR and u-area are now mapped global.
|
||||
*
|
||||
* NB: cannot be profiled due to weird argument-assing convention.
|
||||
* mcount would trash v0, t0, t1.
|
||||
*/
|
||||
NLEAF(mips1_cpu_switch_resume)
|
||||
sll v0, v0, MIPS1_TLB_PID_SHIFT # v0 = aligned PID
|
||||
or v0, v0, UADDR # v0 = first HI entry
|
||||
sll a3, a3, MIPS1_TLB_PID_SHIFT # a3 = aligned PID
|
||||
li v0, UADDR # HI entry; PID = 0
|
||||
ori a1, MIPS1_PG_G # Global
|
||||
ori a2, MIPS1_PG_G # Global
|
||||
mtc0 zero, MIPS_COP_0_TLB_INDEX # set the index register
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # init high entry
|
||||
mtc0 t0, MIPS_COP_0_TLB_LOW # init low entry
|
||||
mtc0 a1, MIPS_COP_0_TLB_LOW # init low entry
|
||||
li s1, 1 << MIPS1_TLB_INDEX_SHIFT
|
||||
tlbwi # Write the TLB entry.
|
||||
addu v0, v0, NBPG # 2nd HI entry
|
||||
mtc0 s1, MIPS_COP_0_TLB_INDEX # set the index register
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # init high entry
|
||||
mtc0 t1, MIPS_COP_0_TLB_LOW # init low entry
|
||||
mtc0 a2, MIPS_COP_0_TLB_LOW # init low entry
|
||||
nop
|
||||
tlbwi # Write the TLB entry.
|
||||
# now map p_addr; may need to flush random TLB entries
|
||||
andi v0, MIPS1_TLB_PID # mask PID
|
||||
or v0, s0 # insert p_addr
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # PID = 0
|
||||
nop
|
||||
tlbp # probe for entry
|
||||
mfc0 s1, MIPS_COP_0_TLB_INDEX # see if we found it
|
||||
@ -1688,15 +1691,15 @@ NLEAF(mips1_cpu_switch_resume)
|
||||
nop
|
||||
tlbwi
|
||||
nop
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # restore High
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # restore High
|
||||
1:
|
||||
li s1, 2 << MIPS1_TLB_INDEX_SHIFT
|
||||
mtc0 s1, MIPS_COP_0_TLB_INDEX
|
||||
mtc0 t0, MIPS_COP_0_TLB_LOW
|
||||
mtc0 a1, MIPS_COP_0_TLB_LOW
|
||||
nop
|
||||
tlbwi
|
||||
addu v0, v0, NBPG
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI
|
||||
addu a0, a0, NBPG
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # second page of p_addr
|
||||
nop
|
||||
tlbp # probe for entry
|
||||
mfc0 s1, MIPS_COP_0_TLB_INDEX # see if we found it
|
||||
@ -1708,13 +1711,14 @@ NLEAF(mips1_cpu_switch_resume)
|
||||
nop
|
||||
tlbwi
|
||||
nop
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # restore High
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # restore High
|
||||
1:
|
||||
li s1, 3 << MIPS1_TLB_INDEX_SHIFT
|
||||
mtc0 s1, MIPS_COP_0_TLB_INDEX
|
||||
mtc0 t1, MIPS_COP_0_TLB_LOW
|
||||
mtc0 a2, MIPS_COP_0_TLB_LOW
|
||||
nop
|
||||
tlbwi
|
||||
mtc0 a3, MIPS_COP_0_TLB_HI # set PID [UADDR/pcb GLOBAL]
|
||||
/*
|
||||
* Now running on new u struct.
|
||||
* Restore registers and return.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore_r4000.S,v 1.40 1997/07/20 19:48:08 jonathan Exp $ */
|
||||
/* $NetBSD: locore_r4000.S,v 1.41 1997/08/09 03:41:07 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
|
||||
@ -2155,9 +2155,10 @@ END(mips3_switch_exit)
|
||||
* Also, there should be no TLB faults at this point.
|
||||
*
|
||||
* Entered from CPU-common cpu_switch()
|
||||
* v0 = Address Space Identifier (TLB PID) for this process
|
||||
* t0 = First u.pte
|
||||
* t1 = Second u.pte
|
||||
* a0 = p_addr [curpcb]
|
||||
* a1 = First u.pte
|
||||
* a2 = Second u.pte
|
||||
* a3 = Address Space Identifier (TLB PID) for this process
|
||||
*/
|
||||
/*
|
||||
* XXXX - almost done with the UADDR mapping; only the kernel stack should
|
||||
@ -2168,15 +2169,19 @@ END(mips3_switch_exit)
|
||||
* begins on an even or odd page. Also, any current mapping for the u-area
|
||||
* address space needs to be flushed as well.
|
||||
*
|
||||
* Both UADDR and p_addr are mapped global.
|
||||
*
|
||||
* NB: cannot be profiled due to weird argument-assing convention.
|
||||
* mcount would trash v0, t0, t1.
|
||||
*/
|
||||
NLEAF(mips3_cpu_switch_resume)
|
||||
or v0, v0, UADDR # v0 = first HI entry
|
||||
li v0, UADDR # Hi entry = UADD, ASID = 0
|
||||
ori a1, MIPS3_PG_G # set PG_G
|
||||
ori a2, MIPS3_PG_G # set PG_G
|
||||
mtc0 zero, MIPS_COP_0_TLB_INDEX # set the index register
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # init high entry
|
||||
mtc0 t0, MIPS_COP_0_TLB_LO0 # init low entry 0
|
||||
mtc0 t1, MIPS_COP_0_TLB_LO1 # init low entry 1
|
||||
mtc0 a1, MIPS_COP_0_TLB_LO0 # init low entry 0
|
||||
mtc0 a2, MIPS_COP_0_TLB_LO1 # init low entry 1
|
||||
nop
|
||||
nop
|
||||
tlbwi # Write the TLB entry.
|
||||
@ -2185,17 +2190,13 @@ NLEAF(mips3_cpu_switch_resume)
|
||||
nop
|
||||
nop
|
||||
# now map the p_addr pages
|
||||
andi v0, PG_ASID
|
||||
or v0, s0
|
||||
ori t0, MIPS3_PG_G # XXX set PG_G
|
||||
ori t1, MIPS3_PG_G # XXX set PG_G
|
||||
li s1, MIPS3_PG_ODDPG
|
||||
and s1, v0 # does p_addr start on odd page
|
||||
and s1, a0 # does p_addr start on odd page
|
||||
beq s1, zero, 1f # no, only one TLB entry needed
|
||||
# p_addr starts on an odd page, need to set up 2 TLB entries
|
||||
addu v0, v0, MIPS3_PG_ODDPG # map second page
|
||||
addu a0, a0, MIPS3_PG_ODDPG # map second page
|
||||
# see if this address currently exists in TLB
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI
|
||||
nop
|
||||
tlbp # probe for existing entry
|
||||
nop
|
||||
@ -2211,22 +2212,22 @@ NLEAF(mips3_cpu_switch_resume)
|
||||
nop
|
||||
tlbwi
|
||||
nop
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # restore high entry
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # restore high entry
|
||||
2:
|
||||
mtc0 t1, MIPS_COP_0_TLB_LO0 # even page to LO0
|
||||
li s1, MIPS3_PG_G # XXX set PG_G
|
||||
mtc0 a2, MIPS_COP_0_TLB_LO0 # even page to LO0
|
||||
li s1, MIPS3_PG_G # invalid page set PG_G
|
||||
mtc0 s1, MIPS_COP_0_TLB_LO1 # invalid page to LO1
|
||||
li s1, 2 # use TLB entry 2 for even page
|
||||
mtc0 s1, MIPS_COP_0_TLB_INDEX
|
||||
nop
|
||||
tlbwi # write odd page TLB entry
|
||||
move t1, t0 # odd page to LO1
|
||||
li t0, MIPS3_PG_G # XXX PG_G # clear LO0
|
||||
addi v0, v0, -NBPG * 2 # backup to odd page mapping
|
||||
move a2, a1 # odd page to LO1
|
||||
li a1, MIPS3_PG_G # LO0
|
||||
addi a0, a0, -NBPG * 2 # backup to odd page mapping
|
||||
# set up TLB entry 1
|
||||
1:
|
||||
# see if this address currently exists in TLB
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI
|
||||
nop
|
||||
tlbp # probe for existing entry
|
||||
nop
|
||||
@ -2242,14 +2243,17 @@ NLEAF(mips3_cpu_switch_resume)
|
||||
nop
|
||||
tlbwi
|
||||
nop
|
||||
mtc0 v0, MIPS_COP_0_TLB_HI # restore high entry
|
||||
mtc0 a0, MIPS_COP_0_TLB_HI # restore high entry
|
||||
2:
|
||||
mtc0 t0, MIPS_COP_0_TLB_LO0 # first page
|
||||
mtc0 t1, MIPS_COP_0_TLB_LO1 # second page
|
||||
mtc0 a1, MIPS_COP_0_TLB_LO0 # first page
|
||||
mtc0 a2, MIPS_COP_0_TLB_LO1 # second page
|
||||
li s1, 1 # use TLB entry 1
|
||||
mtc0 s1, MIPS_COP_0_TLB_INDEX
|
||||
nop
|
||||
tlbwi # write TLB entry
|
||||
nop
|
||||
|
||||
mtc0 a3, MIPS_COP_0_TLB_HI # set current ASID
|
||||
/*
|
||||
* Now running on new u struct.
|
||||
* Restore registers and return.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap.c,v 1.30 1997/07/29 01:41:46 mhitch Exp $ */
|
||||
/* $NetBSD: pmap.c,v 1.31 1997/08/09 03:41:08 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -511,6 +511,21 @@ pmap_reference(pmap)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a new pmap (vmspace) active for the given process.
|
||||
*/
|
||||
void
|
||||
pmap_activate(register struct proc *p)
|
||||
{
|
||||
p->p_addr->u_pcb.pcb_segtab =
|
||||
p->p_vmspace->vm_map.pmap->pm_segtab;
|
||||
if (p == curproc) {
|
||||
register int tlbpid = pmap_alloc_tlbpid(p);
|
||||
MachSetPID(tlbpid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove the given range of addresses from the specified map.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user