summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-01-05 22:20:23 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-01-05 22:20:23 +0000
commit0366f9ef3969200de0b1cf0264b860fdac62b384 (patch)
tree5560083bb41caa7146aec7c5e48b7873b33bdcf2 /sys
parent6481ccefe1fb3cbca0a95beb18a4fee6d2b82ffc (diff)
Pass pmap_bootstrap() the memory range used by the PROM/BUG/firmware/whatever,
instead of assuming it is ``everything below the kernel image''.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/aviion/aviion/machdep.c4
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c4
-rw-r--r--sys/arch/m88k/include/pmap.h4
-rw-r--r--sys/arch/m88k/m88k/pmap.c67
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c4
5 files changed, 47 insertions, 36 deletions
diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c
index 5c2428218c5..edde6db5654 100644
--- a/sys/arch/aviion/aviion/machdep.c
+++ b/sys/arch/aviion/aviion/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.41 2011/01/02 13:39:37 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.42 2011/01/05 22:20:19 miod Exp $ */
/*
* Copyright (c) 2007 Miodrag Vallat.
*
@@ -765,7 +765,7 @@ aviion_bootstrap()
initmsgbuf((caddr_t)pmap_steal_memory(MSGBUFSIZE, NULL, NULL),
MSGBUFSIZE);
- pmap_bootstrap();
+ pmap_bootstrap(0, 0); /* ROM image is on top of physical memory */
/* Initialize the "u-area" pages. */
bzero((caddr_t)curpcb, USPACE);
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index a5e6d7c9408..2340641b315 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.74 2011/01/02 13:39:38 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.75 2011/01/05 22:20:22 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -968,7 +968,7 @@ luna88k_bootstrap()
initmsgbuf((caddr_t)pmap_steal_memory(MSGBUFSIZE, NULL, NULL),
MSGBUFSIZE);
- pmap_bootstrap();
+ pmap_bootstrap(0, 0x20000); /* ROM needs 128KB */
/* Initialize the "u-area" pages. */
bzero((caddr_t)curpcb, USPACE);
diff --git a/sys/arch/m88k/include/pmap.h b/sys/arch/m88k/include/pmap.h
index 8bbfb0914f8..5f94e37bf9a 100644
--- a/sys/arch/m88k/include/pmap.h
+++ b/sys/arch/m88k/include/pmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.h,v 1.18 2010/12/31 21:38:08 miod Exp $ */
+/* $OpenBSD: pmap.h,v 1.19 2011/01/05 22:20:22 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1991 Carnegie Mellon University
@@ -59,7 +59,7 @@ extern apr_t default_apr;
#define pmap_clear_modify(pg) pmap_unsetbit(pg, PG_M)
#define pmap_clear_reference(pg) pmap_unsetbit(pg, PG_U)
-void pmap_bootstrap(void);
+void pmap_bootstrap(paddr_t, paddr_t);
void pmap_bootstrap_cpu(cpuid_t);
void pmap_cache_ctrl(vaddr_t, vaddr_t, u_int);
#define pmap_unuse_final(p) /* nothing */
diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c
index 002c28e19ee..a20bd5cebe3 100644
--- a/sys/arch/m88k/m88k/pmap.c
+++ b/sys/arch/m88k/m88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.62 2011/01/05 22:18:46 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.63 2011/01/05 22:20:22 miod Exp $ */
/*
* Copyright (c) 2001-2004, 2010, Miodrag Vallat.
@@ -617,7 +617,7 @@ pmap_map(paddr_t pa, psize_t sz, vm_prot_t prot, u_int cmode)
DPRINTF(CD_MAP, ("pmap_map(%p, %p, %x, %x)\n",
pa, sz, prot, cmode));
#ifdef DIAGNOSTIC
- if (pa < VM_MAX_KERNEL_ADDRESS)
+ if (pa != 0 && pa < VM_MAX_KERNEL_ADDRESS)
panic("pmap_map: virtual range %p-%p overlaps KVM",
pa, pa + sz);
#endif
@@ -646,14 +646,14 @@ pmap_map(paddr_t pa, psize_t sz, vm_prot_t prot, u_int cmode)
* Initialize kernel translation tables.
*/
void
-pmap_bootstrap()
+pmap_bootstrap(paddr_t s_rom, paddr_t e_rom)
{
paddr_t s_text, e_text;
unsigned int nsdt, npdt;
unsigned int i;
sdt_entry_t *sdt;
- pt_entry_t *pdt;
- paddr_t pa, epdtpa;
+ pt_entry_t *pdt, template;
+ paddr_t pa, sptpa, eptpa;
const struct pmap_table *ptable;
extern void *kernelstart;
extern void *etext;
@@ -681,9 +681,10 @@ pmap_bootstrap()
pdt = (pt_entry_t *)
uvm_pageboot_alloc(round_page(npdt * sizeof(pt_entry_t)));
DPRINTF(CD_BOOT, ("kernel sdt %p", sdt));
+ sptpa = (paddr_t)sdt;
pmap_kernel()->pm_stab = sdt;
pa = (paddr_t)pdt;
- epdtpa = pa + round_page(npdt * sizeof(pt_entry_t));
+ eptpa = pa + round_page(npdt * sizeof(pt_entry_t));
for (i = nsdt; i != 0; i--) {
*sdt++ = pa | SG_SO | SG_RW | PG_M | SG_V;
pa += PAGE_SIZE;
@@ -693,26 +694,35 @@ pmap_bootstrap()
*sdt++ = SG_NV;
KDASSERT((vaddr_t)sdt == (vaddr_t)pdt);
DPRINTF(CD_BOOT, ("kernel pdt %p", pdt));
- for (pa = 0; pa != avail_end; pa += PAGE_SIZE) {
- if (s_text != 0 && pa < s_text)
- /* PROM */
- *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_W | PG_V | CACHE_INH;
- else if (pa < e_text)
- /* kernel text */
- *pdt++ = pa | PG_SO | PG_RO | PG_W | PG_V;
- else if (pa < (paddr_t)pmap_kernel()->pm_stab)
- /* kernel data */
- *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_W | PG_V;
- else if (pa < epdtpa) {
- /* kernel page tables */
- *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_W | PG_V |
- (CPU_IS88100 ? CACHE_INH : CACHE_WT);
- } else
- /* regular memory */
- *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_V;
+
+ /* memory below the kernel image */
+ for (i = atop(s_text); i != 0; i--)
+ *pdt++ = PG_NV;
+ /* kernel text */
+ pa = s_text;
+ for (i = atop(e_text) - atop(pa); i != 0; i--) {
+ *pdt++ = pa | PG_SO | PG_RO | PG_W | PG_V;
+ pa += PAGE_SIZE;
+ }
+ /* kernel data */
+ for (i = atop(sptpa) - atop(pa); i != 0; i--) {
+ *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_W | PG_V;
+ pa += PAGE_SIZE;
+ }
+ /* kernel page tables */
+ template = PG_SO | PG_RW | PG_M_U | PG_W | PG_V |
+ (CPU_IS88100 ? CACHE_INH : CACHE_WT);
+ for (i = atop(eptpa) - atop(pa); i != 0; i--) {
+ *pdt++ = pa | template;
+ pa += PAGE_SIZE;
+ }
+ /* regular memory */
+ for (i = atop(avail_end) - atop(pa); i != 0; i--) {
+ *pdt++ = pa | PG_SO | PG_RW | PG_M_U | PG_V;
+ pa += PAGE_SIZE;
}
DPRINTF(CD_BOOT, ("-%p, pa %08x\n", pdt, pa));
- while (((vaddr_t)pdt & ~PG_FRAME) != 0)
+ for (i = (pt_entry_t *)round_page((vaddr_t)pdt) - pdt; i != 0; i--)
*pdt++ = PG_NV;
/*
@@ -722,9 +732,11 @@ pmap_bootstrap()
* XXX VM_MAX_KERNEL_ADDRESS.
*/
+ if (e_rom != s_rom)
+ pmap_map(s_rom, e_rom - s_rom, UVM_PROT_RW, CACHE_INH);
for (ptable = pmap_table_build(); ptable->size != (vsize_t)-1; ptable++)
if (ptable->size != 0)
- (void)pmap_map(ptable->start, ptable->size,
+ pmap_map(ptable->start, ptable->size,
ptable->prot, ptable->cacheability);
/*
@@ -736,11 +748,10 @@ pmap_bootstrap()
default_apr &= ~CACHE_GLOBAL;
#endif
pmap_kernel()->pm_count = 1;
- pmap_kernel()->pm_apr = ((vaddr_t)pmap_kernel()->pm_stab) |
- default_apr | kernel_apr_cmode;
+ pmap_kernel()->pm_apr = sptpa | default_apr | kernel_apr_cmode;
DPRINTF(CD_BOOT, ("default apr %08x kernel apr %08x\n",
- default_apr, pmap_kernel()->pm_apr));
+ default_apr, sptpa));
pmap_bootstrap_cpu(cpu_number());
}
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index b410c696537..2adf88190f4 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.240 2010/12/31 21:38:08 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.241 2011/01/05 22:20:22 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -1009,7 +1009,7 @@ mvme_bootstrap()
}
#endif /* defined (MVME187) || defined (MVME197) */
- pmap_bootstrap();
+ pmap_bootstrap(0, 0x10000); /* BUG needs 64KB */
#if defined (MVME187) || defined (MVME197)
if (etherlen != 0)