Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh5/sh5 Numerous fixes, and some more debug instrum...
details: https://anonhg.NetBSD.org/src/rev/c9821f878199
branches: trunk
changeset: 536099:c9821f878199
user: scw <scw%NetBSD.org@localhost>
date: Fri Sep 06 16:20:48 2002 +0000
description:
Numerous fixes, and some more debug instrumentation.
NetBSD/sh5 now reaches multi-user, although there is still
an occasional wedging problem after a wee while of running.
diffstat:
sys/arch/sh5/sh5/pmap.c | 341 +++++++++++++++++++++++++++++++----------------
sys/arch/sh5/sh5/trap.c | 61 +++++---
2 files changed, 261 insertions(+), 141 deletions(-)
diffs (truncated from 761 to 300 lines):
diff -r 6b6dd51f73c0 -r c9821f878199 sys/arch/sh5/sh5/pmap.c
--- a/sys/arch/sh5/sh5/pmap.c Fri Sep 06 15:51:23 2002 +0000
+++ b/sys/arch/sh5/sh5/pmap.c Fri Sep 06 16:20:48 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.4 2002/09/04 15:30:12 scw Exp $ */
+/* $NetBSD: pmap.c,v 1.5 2002/09/06 16:20:49 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -122,6 +122,17 @@
#include <machine/memregion.h>
#include <machine/cacheops.h>
+
+#define PMAP_DIAG
+#ifdef PMAP_DIAG
+#ifndef DDB
+#define pmap_debugger() panic("")
+#else
+#include <machine/db_machdep.h>
+#define pmap_debugger() cpu_Debugger();
+#endif
+#endif
+
#ifdef DEBUG
static int pmap_debug = 0;
#define PMPRINTF(x) do { if (pmap_debug) printf x; } while (0)
@@ -129,6 +140,7 @@
#define PMPRINTF(x)
#endif
+
/*
* The basic SH5 MMU is just about as simple as these things can be,
* having two 64-entry TLBs; one for Data and one for Instructions.
@@ -915,6 +927,8 @@
pmap_asid_max = 255;
pmap_initialized = 1;
+ pmap_pinit(pmap_kernel());
+
splx(s);
}
@@ -1110,6 +1124,8 @@
if (!pmap_initialized)
panic("pmap_copy_page: pmap_initialized is false!");
+ PMPRINTF(("pmap_copy_page: copying 0x%08lx -> 0x%08lx\n", src, dst));
+
pmap_pa_map_kva(pmap_copy_page_src_kva, src);
pmap_pa_map_kva(pmap_copy_page_dst_kva, dst);
@@ -1164,11 +1180,12 @@
va &= SH5_PTEH_EPN_MASK;
- if (pm != pmap_kernel()) {
+ if (va < SH5_KSEG0_BASE) {
idx = va_to_pteg(pm->pm_vsid, va);
pvo_head = &pmap_upvo_table[idx];
} else {
- idx = kva_to_iptidx(va);
+ if ((idx = kva_to_iptidx(va)) < 0)
+ return (NULL);
pvo_head = &pmap_kpvo_table[idx];
}
@@ -1258,6 +1275,13 @@
va &= SH5_PTEH_EPN_MASK;
+#ifdef PMAP_DIAG
+ if (pm == pmap_kernel() && va < SH5_KSEG1_BASE) {
+ printf("pmap_pvo_enter: pmap_kernel() with va 0x%lx!!\n", va);
+ pmap_debugger();
+ }
+#endif
+
if (pm != pmap_kernel()) {
idx = va_to_pteg(pm->pm_vsid, va);
pvo_table_head = &pmap_upvo_table[idx];
@@ -1330,14 +1354,17 @@
* We hope this succeeds but it isn't required.
*/
i = pmap_pteg_insert(&pmap_pteg_table[idx], pvo);
- PMPRINTF(("pmap_pvo_enter: va 0x%x into group 0x%x (rv = %d)\n",
- (u_int)va, idx, i));
- PMPRINTF(("pmap_pvo_enter: group addr = %p, vsid = 0x%x\n",
- &pmap_pteg_table[idx], pm->pm_vsid));
+ PMPRINTF((
+ "pmap_pvo_enter: va 0x%lx, ptel 0x%lx, group 0x%x (idx %d)\n",
+ va, (u_long)ptel, idx, i));
if (i >= 0)
PVO_PTEGIDX_SET(pvo, i);
- } else
+ } else {
pmap_kernel_ipt[idx] = ptel;
+ PMPRINTF((
+ "pmap_pvo_enter: va 0x%lx, ptel 0x%lx, kipt (idx %d)\n",
+ va, (u_long)ptel, idx));
+ }
splx(s);
@@ -1347,6 +1374,7 @@
static void
pmap_pvo_remove(struct pvo_entry *pvo, int ptegidx)
{
+
if (pvo->pvo_pmap != pmap_kernel()) {
volatile pte_t *pt;
@@ -1360,9 +1388,17 @@
pmap_pteg_unset(pt, pvo);
PVO_PTEGIDX_CLR(pvo);
}
- } else
+ } else {
+#ifdef PMAP_DIAG
+ if (PVO_VADDR(pvo) < SH5_KSEG1_BASE) {
+ printf("pmap_pvo_remove: pmap_kernel() va 0x%lx!!\n",
+ PVO_VADDR(pvo));
+ pmap_debugger();
+ }
+#endif
pvo->pvo_ptel |=
pmap_pa_unmap_kva(pvo->pvo_vaddr) & PVO_REFMOD_MASK;
+ }
/*
* Update our statistics
@@ -1406,13 +1442,16 @@
ptel_t ptel;
int error;
-#ifdef DEBUG
- if (pm == pmap_kernel())
- PMPRINTF(("pmap_enter: pmap_kernel(): "));
- else
- PMPRINTF(("pmap_enter: %p: ", pm));
- PMPRINTF(("va=0x%08x, pa=0x%08x, prot=0x%08x, flags=0x%08x\n",
- (u_int)va, (u_int)pa, (u_int)prot, (u_int)flags));
+ PMPRINTF((
+ "pmap_enter: %p: va=0x%lx, pa=0x%lx, prot=0x%x, flags=0x%x\n",
+ pm, va, pa, (u_int)prot, (u_int)flags));
+
+#ifdef PMAP_DIAG
+ if (pm == pmap_kernel() && va < SH5_KSEG1_BASE) {
+ printf("pmap_enter: pmap_kernel() with va 0x%08x!!\n",
+ (u_int)va);
+ pmap_debugger();
+ }
#endif
pvo_head = pa_to_pvoh(pa, &pg);
@@ -1433,19 +1472,11 @@
}
}
-#ifdef DEBUG
- if (ptel == SH5_PTEL_CB_DEVICE)
- PMPRINTF(("pmap_enter: device memory\n"));
- else
- PMPRINTF(("pmap_enter: managed memory\n"));
-#endif
-
/* Pages are always readable */
ptel |= SH5_PTEL_PR_R;
if (pg) {
/* Only managed pages can be user-accessible */
- PMPRINTF(("pmap_enter: managed page: %p\n", pg));
if (va <= VM_MAXUSER_ADDRESS)
ptel |= SH5_PTEL_PR_U;
@@ -1500,13 +1531,13 @@
ptel |= SH5_PTEL_PR_R | SH5_PTEL_PR_W | (pa & SH5_PTEL_PPN_MASK);
+ PMPRINTF(("pmap_kenter_pa: va 0x%lx, pa 0x%lx, prot 0x%x, idx %d\n",
+ va, pa, (u_int)prot, idx));
+
KDASSERT(pmap_kernel_ipt[idx] == 0);
pmap_kernel_ipt[idx] = ptel;
- PMPRINTF(("pmap_kenter_pa: va=0x%08x, pa=0x%08x, prot=0x%08x\n",
- (u_int)va, (u_int)pa, (u_int)prot));
-
/* XXX: Cache */
}
@@ -1518,8 +1549,7 @@
if (va < pmap_kva_avail_start)
panic("pmap_kremove: Entering non-kernel VA: 0x%lx", va);
- PMPRINTF(("pmap_kremove: va=0x%08x, len=0x%x\n", (u_int)va,
- (u_int)len));
+ PMPRINTF(("pmap_kremove: va=0x%lx, len=0x%lx\n", va, len));
for (ptelp = &pmap_kernel_ipt[kva_to_iptidx(va)]; len;
len -= NBPG, va += NBPG) {
@@ -1542,12 +1572,14 @@
int ptegidx;
int s;
-#ifdef DEBUG
- if (pm == pmap_kernel())
- PMPRINTF(("pmap_remove: pmap_kernel(): "));
- else
- PMPRINTF(("pmap_remove: %p: ", pm));
- PMPRINTF(("va=0x%08x, endva=0x%08x\n", (u_int)va, (u_int)endva));
+ PMPRINTF(("pmap_remove: %p: va=0x%lx, endva=0x%lx\n", pm, va, endva));
+
+#ifdef PMAP_DIAG
+ if (pm == pmap_kernel() && va < SH5_KSEG1_BASE) {
+ printf("pmap_remove: pmap_kernel() with va 0x%08x!!\n",
+ (u_int)va);
+ pmap_debugger();
+ }
#endif
for (; va < endva; va += PAGE_SIZE) {
@@ -1578,35 +1610,39 @@
int s, idx;
boolean_t found = FALSE;
-#ifdef DEBUG
- if (pm == pmap_kernel())
- PMPRINTF(("pmap_extract: pmap_kernel(): va 0x%08x\n",
- (u_int)va));
- else
- PMPRINTF(("pmap_extract: %p: va 0x%08x\n", pm, (u_int)va));
+ PMPRINTF(("pmap_extract: %p: va 0x%lx - ", pm, va));
+
+#ifdef PMAP_DIAG
+ if (pm == pmap_kernel() && va < SH5_KSEG1_BASE) {
+ printf("pmap_extract: pmap_kernel() with va 0x%lx!!\n", va);
+ pmap_debugger();
+ }
#endif
s = splhigh();
- pvo = pmap_pvo_find_va(pm, va & SH5_PTEH_EPN_MASK, NULL);
+ pvo = pmap_pvo_find_va(pm, va, NULL);
if (pvo != NULL) {
*pap = (pvo->pvo_ptel & SH5_PTEL_PPN_MASK) |
(va & ~SH5_PTEH_EPN_MASK);
found = TRUE;
- PMPRINTF(("pmap_extract: managed pvo. pa=0x%08x\n",
- (u_int)*pap));
+ PMPRINTF(("managed pvo. pa 0x%lx\n", *pap));
} else
if (pm == pmap_kernel()) {
idx = kva_to_iptidx(va);
- if (pmap_kernel_ipt[idx]) {
+ if (idx >= 0 && pmap_kernel_ipt[idx]) {
*pap = (pmap_kernel_ipt[idx] & SH5_PTEL_PPN_MASK) |
(va & ~SH5_PTEH_EPN_MASK);
found = TRUE;
- PMPRINTF(("pmap_extract: no pvo, but found in kipt: 0x%08x\n", (u_int)*pap));
- } else
- PMPRINTF(("pmap_extract: no pvo, and not in kipt\n"));
- } else
- PMPRINTF(("pmap_extract: no pvo for non-kernel pmap\n"));
+ PMPRINTF(("no pvo, but kipt pa 0x%lx\n", *pap));
+ }
+ }
splx(s);
+
+#ifdef DEBUG
+ if (!found)
+ PMPRINTF(("not found.\n"));
+#endif
+
return (found);
}
@@ -1621,16 +1657,19 @@
{
struct pvo_entry *pvo;
volatile pte_t *pt;
+ ptel_t clrbits;
int ptegidx;
int s;
- if (pm == pmap_kernel())
- PMPRINTF(("pmap_protect: pmap_kernel(): va 0x%08x\n",
- (u_int)va));
- else
- PMPRINTF(("pmap_protect: %p: va 0x%08x\n", pm, (u_int)va));
- PMPRINTF(("va=0x%08x, endva=0x%08x, prot=0x%x\n",
- (u_int)va, (u_int)endva, (u_int)prot));
+ PMPRINTF(("pmap_protect: %p: va=0x%lx, endva=0x%lx, prot=0x%x\n",
+ pm, va, endva, (u_int)prot));
+
+#ifdef PMAP_DIAG
+ if (pm == pmap_kernel() && va < SH5_KSEG1_BASE) {
+ printf("pmap_protect: pmap_kernel() with va 0x%lx!!\n", va);
Home |
Main Index |
Thread Index |
Old Index