place message buffer in low physical memory, so that it can survive a

warm boot. the sun4 boot program corrupts some memory there so adjust
upwards on the sun4. (from chuck)
This commit is contained in:
deraadt 1994-12-06 08:34:00 +00:00
parent 972ab0a594
commit 03cba26fa6
6 changed files with 65 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.18 1994/11/23 07:02:36 deraadt Exp $ */
/* $NetBSD: autoconf.c,v 1.19 1994/12/06 08:34:00 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -166,8 +166,17 @@ bootstrap()
#if defined(SUN4)
extern void oldmon_w_cmd();
extern struct msgbuf *msgbufp;
if (cputyp == CPU_SUN4) {
/*
* XXX
* Some boot programs mess up physical page 0, which
* is where we want to put the msgbuf. There's some
* room, so shift it over half a page.
*/
msgbufp = (struct msgbuf *)((caddr_t) msgbufp + 4096);
/*
* XXX:
* The promvec is bogus. We need to build a

View File

@ -223,11 +223,26 @@ sun4_notsup:
.text
/*
* The remaining two physical pages are currently unused. We need to
* map the interrupt enable register very early on in the boot process,
* so that we can handle NMIs (parity errors) halfway sensibly during
* boot. We use virtual address f8002000 (`page 2') for this, wasting
* 4096 bytes of physical memory.
* The first thing in the real text segment is the trap vector table,
* which must be aligned on a 4096 byte boundary. The text segment
* starts beyond page 0 of KERNBASE so that there is a red zone
* between user and kernel space. Since the boot ROM loads us at
* 0x4000, it is far easier to start at KERNBASE+0x4000 than to
* buck the trend. This is two or four pages in (depending on if
* pagesize is 8192 or 4096). We place two items in this area:
* the message buffer (phys addr 0) and the IE_reg (phys addr 0x2000).
* because the message buffer is in our "red zone" between user and
* kernel space we remap it in configure() to another location and
* invalidate the mapping at KERNBASE.
*/
.globl _msgbuf
_msgbuf = KERNBASE
/*
* We need to map the interrupt enable register very early on in the
* boot process, so that we can handle NMIs (parity errors) halfway
* sensibly during boot. We use virtual address f8002000 (`page 2')
* for this, wasting a page of physical memory.
*/
IE_reg_addr = KERNBASE + 8192 ! this page not used; points to IEreg
@ -566,20 +581,12 @@ _trapbase:
STRAP(0xff)
/*
* put the message buffer after the trap table.
* pad the trap table to max page size
* trap table size is 0x100 * 4instr * 4byte/instr = 4096 bytes
* need to .skip 4096 to pad to page size
*/
.skip 4096
.globl _msgbuf
msgbufsize = 4096 ! 1 page for msg buffer
_msgbuf:
.skip msgbufsize
/* and let's not put anything else in that page, on a sun4 */
.skip 4096
/* the message buffer is always mapped */
_msgbufmapped:
.word 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.36 1994/11/25 23:10:26 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.37 1994/12/06 08:34:08 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -244,6 +244,17 @@ cpu_startup()
* Configure the system. The cpu code will turn on the cache.
*/
configure();
/*
* fix message buffer mapping, note phys addr of msgbuf is 0
*/
pmap_enter(kernel_pmap, MSGBUF_VA, 0x0, VM_PROT_READ|VM_PROT_WRITE, 1);
if (cputyp == CPU_SUN4)
msgbufp = (struct msgbuf *)(MSGBUF_VA + 4096);
else
msgbufp = (struct msgbuf *)MSGBUF_VA;
pmap_redzone();
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.3 1994/11/20 20:54:30 deraadt Exp $ */
/* $NetBSD: mem.c,v 1.4 1994/12/06 08:34:10 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -54,6 +54,7 @@
#include <sys/buf.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sparc/sparc/vaddrs.h>
#include <vm/vm.h>
@ -115,10 +116,15 @@ mmrw(dev, uio, flags)
/* minor device 1 is kernel memory */
case 1:
va = (caddr_t)(int)uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!kernacc(va, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
return (EFAULT);
if (va >= (caddr_t)MSGBUF_VA &&
va < ((caddr_t)MSGBUF_VA)+NBPG) {
c = min(iov->iov_len, 4096);
} else {
c = min(iov->iov_len, MAXPHYS);
if (!kernacc(va, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
return (EFAULT);
}
error = uiomove(va, (int)c, uio);
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.22 1994/11/20 20:54:35 deraadt Exp $ */
/* $NetBSD: pmap.c,v 1.23 1994/12/06 08:34:12 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -1417,19 +1417,15 @@ pmap_bootstrap(nmmu, nctx)
* set red zone at kernel base; enable cache on message buffer.
*/
{
extern char etext[], msgbuf[];
extern char etext[];
#ifdef KGDB
register int mask = ~PG_NC; /* XXX chgkprot is busted */
#else
register int mask = ~(PG_W | PG_NC);
#endif
for (p = (caddr_t)roundup((int)msgbuf+1, NBPG); p < etext; p += NBPG)
for (p = (caddr_t)trapbase; p < etext; p += NBPG)
setpte(p, getpte(p) & mask);
p = (caddr_t)KERNBASE;
setpte(p, 0);
p += NBPG;
setpte(p, getpte(p) & ~PG_NC);
}
/*
@ -2843,3 +2839,8 @@ pmap_count_ptes(pm)
pm->pm_stats.resident_count = total;
return (total);
}
pmap_redzone()
{
setpte(KERNBASE, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vaddrs.h,v 1.4 1994/11/20 20:54:44 deraadt Exp $ */
/* $NetBSD: vaddrs.h,v 1.5 1994/12/06 08:34:14 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -72,7 +72,8 @@
#define ZS1_VA (IODEV_0 + 2*NBPG)
#define AUXREG_VA (IODEV_0 + 3*NBPG)
#define TMPMAP_VA (IODEV_0 + 4*NBPG)
#define IODEV_BASE (IODEV_0 + 5*NBPG)
#define MSGBUF_VA (IODEV_0 + 5*NBPG)
#define IODEV_BASE (IODEV_0 + 6*NBPG)
#define IODEV_END 0xff000000 /* 16 MB of iospace */
#define DVMA_BASE 0xfff00000