Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/yamt-km]: src/sys/arch change mac68k's kernel address space layout in or...
details: https://anonhg.NetBSD.org/src/rev/21f4c8d9f407
branches: yamt-km
changeset: 573353:21f4c8d9f407
user: yamt <yamt%NetBSD.org@localhost>
date: Wed Feb 23 07:48:23 2005 +0000
description:
change mac68k's kernel address space layout in order to simplify
interaction between upper layer of the vm during bootstrap.
- move Sysmap to the end of address space.
- move IOBase etc immediately after proc0 uarea.
- tweak virtual_avail/end accordingly.
tested by Chuck Silvers, on his quadra 950.
XXX this breaks other m68k platforms. i'll fix them later.
diffstat:
sys/arch/m68k/include/pmap_motorola.h | 3 +-
sys/arch/m68k/m68k/pmap_motorola.c | 25 +-----
sys/arch/mac68k/include/vmparam.h | 4 +-
sys/arch/mac68k/mac68k/pmap_bootstrap.c | 130 +++++++++++++------------------
4 files changed, 61 insertions(+), 101 deletions(-)
diffs (truncated from 381 to 300 lines):
diff -r ddf91b3e199d -r 21f4c8d9f407 sys/arch/m68k/include/pmap_motorola.h
--- a/sys/arch/m68k/include/pmap_motorola.h Fri Feb 18 14:38:28 2005 +0000
+++ b/sys/arch/m68k/include/pmap_motorola.h Wed Feb 23 07:48:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_motorola.h,v 1.6 2005/01/17 04:37:20 atatat Exp $ */
+/* $NetBSD: pmap_motorola.h,v 1.6.2.1 2005/02/23 07:48:23 yamt Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -183,7 +183,6 @@
extern pt_entry_t *Sysmap;
extern char *vmmap; /* map for mem, dumps, etc. */
-void pmap_init_md(void);
vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
void pmap_procwr(struct proc *, vaddr_t, size_t);
#define PMAP_NEED_PROCWR
diff -r ddf91b3e199d -r 21f4c8d9f407 sys/arch/m68k/m68k/pmap_motorola.c
--- a/sys/arch/m68k/m68k/pmap_motorola.c Fri Feb 18 14:38:28 2005 +0000
+++ b/sys/arch/m68k/m68k/pmap_motorola.c Wed Feb 23 07:48:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_motorola.c,v 1.12.4.3 2005/02/18 14:38:29 chs Exp $ */
+/* $NetBSD: pmap_motorola.c,v 1.12.4.4 2005/02/23 07:48:23 yamt Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.12.4.3 2005/02/18 14:38:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.12.4.4 2005/02/23 07:48:23 yamt Exp $");
#include "opt_compat_hpux.h"
@@ -374,27 +374,6 @@
caddr1_pte = pmap_pte(pmap_kernel(), CADDR1);
caddr2_pte = pmap_pte(pmap_kernel(), CADDR2);
- /*
- * Now that kernel map has been allocated, we can mark as
- * unavailable regions which we have mapped in pmap_bootstrap().
- */
-
- pmap_init_md();
- addr = (vaddr_t) Sysmap;
- if (uvm_map(kernel_map, &addr, M68K_MAX_PTSIZE,
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
- UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != 0) {
- /*
- * If this fails, it is probably because the static
- * portion of the kernel page table isn't big enough
- * and we overran the page table map.
- */
-
- panic("pmap_init: bogons in the VM system!");
- }
-
PMAP_DPRINTF(PDB_INIT,
("pmap_init: Sysseg %p, Sysmap %p, Sysptmap %p\n",
Sysseg, Sysmap, Sysptmap));
diff -r ddf91b3e199d -r 21f4c8d9f407 sys/arch/mac68k/include/vmparam.h
--- a/sys/arch/mac68k/include/vmparam.h Fri Feb 18 14:38:28 2005 +0000
+++ b/sys/arch/mac68k/include/vmparam.h Wed Feb 23 07:48:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmparam.h,v 1.34 2003/08/07 16:28:21 agc Exp $ */
+/* $NetBSD: vmparam.h,v 1.34.10.1 2005/02/23 07:48:23 yamt Exp $ */
/*
* Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -183,7 +183,7 @@
#define VM_MAXUSER_ADDRESS ((vaddr_t)(USRSTACK))
#define VM_MAX_ADDRESS ((vaddr_t)(0-(UPAGES*PAGE_SIZE)))
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0)
-#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE))
+#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG*2))
/* virtual sizes (bytes) for various kernel submaps */
#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE)
diff -r ddf91b3e199d -r 21f4c8d9f407 sys/arch/mac68k/mac68k/pmap_bootstrap.c
--- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c Fri Feb 18 14:38:28 2005 +0000
+++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c Wed Feb 23 07:48:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_bootstrap.c,v 1.61.4.1 2005/02/12 18:17:35 yamt Exp $ */
+/* $NetBSD: pmap_bootstrap.c,v 1.61.4.2 2005/02/23 07:48:23 yamt Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.61.4.1 2005/02/12 18:17:35 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.61.4.2 2005/02/23 07:48:23 yamt Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -122,7 +122,7 @@
void
pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
{
- paddr_t kstpa, kptpa, vidpa, iiopa, rompa, kptmpa, lkptpa, p0upa;
+ paddr_t kstpa, kptpa, kptmpa, lkptpa, p0upa;
u_int nptpages, kstsize;
paddr_t avail_next;
int avail_remaining;
@@ -144,15 +144,6 @@
* kptpa statically allocated
* kernel PT pages Sysptsize+ pages
*
- * vidpa internal video space for some machines
- * PT pages VIDMAPSIZE pages
- *
- * rompa ROM space
- * PT pages ROMMAPSIZE pages
- *
- * iiopa internal IO space
- * PT pages IIOMAPSIZE pages
- *
* [ Sysptsize is the number of pages of PT, IIOMAPSIZE and
* NBMAPSIZE are the number of PTEs, hence we need to round
* the total to a page boundary with IO maps at the end. ]
@@ -170,20 +161,16 @@
kstsize = 1;
kstpa = nextpa;
nextpa += kstsize * PAGE_SIZE;
- kptpa = nextpa;
- nptpages = Sysptsize +
- (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE + NPTEPG - 1) / NPTEPG;
- nextpa += nptpages * PAGE_SIZE;
- vidpa = nextpa - VIDMAPSIZE * sizeof(pt_entry_t);
- rompa = vidpa - ROMMAPSIZE * sizeof(pt_entry_t);
- iiopa = rompa - IIOMAPSIZE * sizeof(pt_entry_t);
kptmpa = nextpa;
nextpa += PAGE_SIZE;
lkptpa = nextpa;
nextpa += PAGE_SIZE;
p0upa = nextpa;
nextpa += USPACE;
-
+ kptpa = nextpa;
+ nptpages = Sysptsize +
+ (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE + NPTEPG - 1) / NPTEPG;
+ nextpa += nptpages * PAGE_SIZE;
for (i = 0; i < numranges; i++)
if (low[i] <= firstpa && firstpa < high[i])
@@ -239,11 +226,11 @@
* Initialize level 2 descriptors (which immediately
* follow the level 1 table). We need:
* NPTEPG / SG4_LEV3SIZE
- * level 2 descriptors to map each of the nptpages+1
+ * level 2 descriptors to map each of the nptpages
* pages of PTEs. Note that we set the "used" bit
* now to save the HW the expense of doing it.
*/
- num = (nptpages + 1) * (NPTEPG / SG4_LEV3SIZE);
+ num = nptpages * (NPTEPG / SG4_LEV3SIZE);
pte = &(PA2VA(kstpa, u_int *))[SG4_LEV1SIZE];
epte = &pte[num];
protoste = kptpa | SG_U | SG_RW | SG_V;
@@ -275,7 +262,13 @@
* descriptors to map the "last PT page".
*/
pte = &(PA2VA(kstpa, u_int*))
- [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE];
+ [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
+ epte = &pte[NPTEPG/SG4_LEV3SIZE];
+ protoste = kptmpa | SG_U | SG_RW | SG_V;
+ while (pte < epte) {
+ *pte++ = protoste;
+ protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
+ }
epte = &pte[NPTEPG/SG4_LEV3SIZE];
protoste = lkptpa | SG_U | SG_RW | SG_V;
while (pte < epte) {
@@ -285,34 +278,43 @@
/*
* Initialize Sysptmap
*/
+ pte = &(PA2VA(kstpa, u_int*))
+ [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
+ epte = &pte[NPTEPG/SG4_LEV3SIZE];
+ protoste = kptmpa | SG_U | SG_RW | SG_V;
+ while (pte < epte) {
+ *pte++ = protoste;
+ protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
+ }
pte = PA2VA(kptmpa, u_int *);
- epte = &pte[nptpages+1];
+ epte = &pte[nptpages];
protopte = kptpa | PG_RW | PG_CI | PG_V;
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;
}
/*
- * Invalidate all but the last remaining entries in both.
+ * Invalidate all but the last two remaining entries.
*/
- epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-1];
+ epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-2];
while (pte < epte) {
*pte++ = PG_NV;
}
/*
- * Initialize the last to point to the page
+ * Initialize the last ones to point to Sysptmap and the page
* table page allocated earlier.
*/
+ *pte = kptmpa | PG_RW | PG_CI | PG_V;
+ pte++;
*pte = lkptpa | PG_RW | PG_CI | PG_V;
} else {
/*
* Map the page table pages in both the HW segment table
- * and the software Sysptmap. Note that Sysptmap is also
- * considered a PT page hence the +1.
+ * and the software Sysptmap.
*/
ste = PA2VA(kstpa, u_int*);
pte = PA2VA(kptmpa, u_int*);
- epte = &pte[nptpages+1];
+ epte = &pte[nptpages];
protoste = kptpa | SG_RW | SG_V;
protopte = kptpa | PG_RW | PG_CI | PG_V;
while (pte < epte) {
@@ -322,17 +324,21 @@
protopte += PAGE_SIZE;
}
/*
- * Invalidate all but the last remaining entries in both.
+ * Invalidate all but the last two remaining entries in both.
*/
- epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-1];
+ epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-2];
while (pte < epte) {
*ste++ = SG_NV;
*pte++ = PG_NV;
}
/*
- * Initialize the last to point to point to the page
+ * Initialize the last ones to point to Sysptmap and the page
* table page allocated earlier.
*/
+ *ste = kptmpa | SG_RW | SG_V;
+ *pte = kptmpa | PG_RW | PG_CI | PG_V;
+ ste++;
+ pte++;
*ste = lkptpa | SG_RW | SG_V;
*pte = lkptpa | PG_RW | PG_CI | PG_V;
}
@@ -359,12 +365,14 @@
* Pages up to "start" must be writable for the ROM.
*/
pte = &(PA2VA(kptpa, u_int *))[m68k_btop(KERNBASE)];
+ /* XXX why KERNBASE relative? */
epte = &pte[m68k_btop(m68k_round_page(start))];
protopte = firstpa | PG_RW | PG_V;
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;
}
+ /* XXX why KERNBASE relative? */
epte = &pte[m68k_btop(m68k_trunc_page(&etext))];
protopte = (protopte & ~PG_PROT) | PG_RO;
while (pte < epte) {
@@ -387,36 +395,37 @@
*pte++ = protopte;
protopte += PAGE_SIZE;
}
- /*
- * Finally, validate the internal IO space, ROM space, and
- * framebuffer PTEs (RW+CI).
- */
- pte = PA2VA(iiopa, u_int *);
- epte = PA2VA(rompa, u_int *);
+
+#define PTE2VA(pte) m68k_ptob(pte - PA2VA(kptpa, pt_entry_t *))
+
protopte = IOBase | PG_RW | PG_CI | PG_V;
+ IOBase = PTE2VA(pte);
+ epte = &pte[IIOMAPSIZE];
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;
}
- pte = PA2VA(rompa, u_int *);
- epte = PA2VA(vidpa, u_int *);
- protopte = ((u_int) ROMBase) | PG_RO | PG_V;
+ protopte = (pt_entry_t)ROMBase | PG_RO | PG_V;
+ ROMBase = (caddr_t)PTE2VA(pte);
+ epte = &pte[ROMMAPSIZE];
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;
}
Home |
Main Index |
Thread Index |
Old Index