Use allocsys(), mips_init_msgbuf(), and mips_init_proc0(), plus small

changes for MACHINE_NEW_NONCONTIG.
This commit is contained in:
thorpej 1998-02-25 23:28:25 +00:00
parent d184112bd5
commit 477d46784e
2 changed files with 64 additions and 336 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.6 1998/02/25 23:28:25 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 1998/02/25 23:28:25 thorpej Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@ -59,7 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
#include <sys/reboot.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/clist.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@ -74,15 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/kcore.h>
#ifdef SYSVMSG
#include <sys/msg.h>
#endif
#ifdef SYSVSEM
#include <sys/sem.h>
#endif
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
#include <vm/vm_kern.h>
#include <ufs/mfs/mfs_extern.h> /* mfs_initminiroot() */
@ -110,25 +100,10 @@ char cpu_model[30];
vm_map_t buffer_map;
/*
* Declare these as initialized data so we can patch them.
*/
int nswbuf = 0;
#ifdef NBUF
int nbuf = NBUF;
#else
int nbuf = 0;
#endif
#ifdef BUFPAGES
int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
caddr_t msgbufaddr;
int maxmem; /* max memory per process */
int physmem; /* max supported memory, changes to actual */
phys_ram_seg_t mem_clusters[1]; /* XXX VM_PHYSSEG_MAX */
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
/*
@ -186,9 +161,6 @@ extern void stacktrace __P((void)); /*XXX*/
*/
int safepri = MIPS3_PSL_LOWIPL; /* XXX */
struct user *proc0paddr;
struct proc nullproc; /* for use by switch_exit() */
struct idrom idrom;
/* locore callback-vector setup */
@ -207,9 +179,9 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
int x_maxmem;
{
register int i;
register unsigned firstaddr;
register caddr_t v;
caddr_t start;
u_long first, last;
caddr_t kernend, v;
vm_size_t size;
extern u_long bootdev;
extern char edata[], end[];
@ -221,8 +193,8 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
*(int *)(MIPS_PHYS_TO_KSEG1(MACH_BOOTSW_ADDR)) = x_boothowto;
/* clear the BSS segment */
v = (caddr_t)mips_round_page(end);
bzero(edata, v - edata);
kernend = (caddr_t)mips_round_page(end);
bzero(edata, kernend - edata);
/*
* Set the VM page size.
@ -267,79 +239,40 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
*/
if (boothowto & RB_MINIROOT) {
boothowto |= RB_DFLTROOT;
v += mfs_initminiroot(v);
kernend += round_page(mfs_initminiroot(kernend));
}
#endif
/*
* Init mapping for u page(s) for proc[0], pm_tlbpid 1.
* Init mapping for u page(s) for proc0, pm_tlbpid 1.
* This also initializes nullproc for switch_exit().
*/
start = v;
proc0.p_addr = proc0paddr = (struct user *)v;
curpcb = (struct pcb *)proc0.p_addr;
proc0.p_md.md_regs = proc0paddr->u_pcb.pcb_regs;
firstaddr = MIPS_KSEG0_TO_PHYS(v);
mips_init_proc0(kernend);
if (CPUISMIPS3) for (i = 0; i < UPAGES; i+=2) {
struct tlb tlb;
tlb.tlb_mask = MIPS3_PG_SIZE_4K;
tlb.tlb_hi = mips3_vad_to_vpn((UADDR + (i << PGSHIFT))) | 1;
tlb.tlb_lo0 = vad_to_pfn(firstaddr) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
tlb.tlb_lo1 = vad_to_pfn(firstaddr + NBPG) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
proc0.p_md.md_upte[i] = tlb.tlb_lo0;
proc0.p_md.md_upte[i+1] = tlb.tlb_lo1;
mips3_TLBWriteIndexedVPS(i,&tlb);
firstaddr += NBPG * 2;
}
else for (i = 0; i < UPAGES; i++) {
mips1_TLBWriteIndexed(i,
(UADDR + (i << PGSHIFT)) | (1 << MIPS1_TLB_PID_SHIFT),
proc0.p_md.md_upte[i] = firstaddr |
MIPS1_PG_V | MIPS1_PG_M);
firstaddr += NBPG;
}
v += UPAGES * NBPG;
MachSetPID(1);
kernend += 2 * UPAGES * PAGE_SIZE;
/*
* init nullproc for switch_exit().
* init mapping for u page(s), pm_tlbpid 0
* This could be used for an idle process.
* Load the rest of the available pages into the VM system.
*/
nullproc.p_addr = (struct user *)v;
nullproc.p_md.md_regs = nullproc.p_addr->u_pcb.pcb_regs;
bcopy("nullproc", nullproc.p_comm, sizeof("nullproc"));
if (CPUISMIPS3) {
/* mips3 */
for (i = 0; i < UPAGES; i+=2) {
nullproc.p_md.md_upte[i] = vad_to_pfn(firstaddr) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
nullproc.p_md.md_upte[i+1] =
vad_to_pfn(firstaddr + NBPG) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
firstaddr += NBPG * 2;
}
} else {
/* mips1 */
for (i = 0; i < UPAGES; i++) {
nullproc.p_md.md_upte[i] = firstaddr |
MIPS1_PG_V | MIPS1_PG_M;
firstaddr += NBPG;
}
}
first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
last = mem_clusters[0].start + mem_clusters[0].size;
vm_page_physload(atop(first), atop(last), atop(first), atop(last));
v += UPAGES * NBPG;
/*
* Initialize error message buffer (at end of core).
*/
mips_init_msgbuf();
/* clear pages for u areas */
bzero(start, v - start);
if (CPUISMIPS3) {
mips3_FlushDCache(MIPS_KSEG0_TO_PHYS(start), v - start);
mips3_HitFlushDCache(UADDR, UPAGES * NBPG);
}
/*
* Allocate space for system data structures. These data structures
* are allocated here instead of cpu_startup() because physical
* memory is directly addressable. We don't have to map these into
* virtual address space.
*/
size = (vm_size_t)allocsys(0);
v = (caddr_t)pmap_steal_memory(size, NULL, NULL);
if ((allocsys(v) - v) != size)
panic("mach_init: table size inconsistency");
/*
* Determine what model of computer we are running on.
@ -371,79 +304,10 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
cpu_reboot(RB_HALT | RB_NOSYNC, NULL);
}
/*
* Initialize error message buffer (at end of core).
*/
maxmem -= btoc(MSGBUFSIZE);
msgbufaddr = (caddr_t)(MIPS_PHYS_TO_KSEG0(maxmem << PGSHIFT));
initmsgbuf(msgbufaddr, mips_round_page(MSGBUFSIZE));
/*
* Allocate space for system data structures.
* The first available kernel virtual address is in "v".
* As pages of kernel virtual memory are allocated, "v" is incremented.
*
* These data structures are allocated here instead of cpu_startup()
* because physical memory is directly addressable. We don't have
* to map these into virtual address space.
*/
start = v;
#define valloc(name, type, num) \
(name) = (type *)v; v = (caddr_t)((name)+(num))
#define valloclim(name, type, num, lim) \
(name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
#ifdef REAL_CLISTS
valloc(cfree, struct cblock, nclist);
#endif
valloc(callout, struct callout, ncallout);
#ifdef SYSVSHM
valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
#endif
#ifdef SYSVSEM
valloc(sema, struct semid_ds, seminfo.semmni);
valloc(sem, struct sem, seminfo.semmns);
/* This is pretty disgusting! */
valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
#endif
#ifdef SYSVMSG
valloc(msgpool, char, msginfo.msgmax);
valloc(msgmaps, struct msgmap, msginfo.msgseg);
valloc(msghdrs, struct msg, msginfo.msgtql);
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
/*
* Determine how many buffers to allocate.
* We allocate more buffer space than the BSD standard of
* using 10% of memory for the first 2 Meg, 5% of remaining.
* We just allocate a flat 10%. Ensure a minimum of 16 buffers.
* We allocate 1/2 as many swap buffer headers as file i/o buffers.
*/
if (bufpages == 0)
bufpages = physmem / 10 / CLSIZE;
if (nbuf == 0) {
nbuf = bufpages;
if (nbuf < 16)
nbuf = 16;
}
if (nswbuf == 0) {
nswbuf = (nbuf / 2) &~ 1; /* force even */
if (nswbuf > 256)
nswbuf = 256; /* sanity */
}
valloc(swbuf, struct buf, nswbuf);
valloc(buf, struct buf, nbuf);
/*
* Clear allocated memory.
*/
bzero(start, v - start);
/*
* Initialize the virtual memory system.
*/
pmap_bootstrap((vm_offset_t)v);
pmap_bootstrap();
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.6 1998/02/25 23:28:25 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 1998/02/25 23:28:25 thorpej Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@ -59,7 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
#include <sys/reboot.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/clist.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@ -74,15 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 1998/02/23 20:05:09 thorpej Exp $");
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/kcore.h>
#ifdef SYSVMSG
#include <sys/msg.h>
#endif
#ifdef SYSVSEM
#include <sys/sem.h>
#endif
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
#include <vm/vm_kern.h>
#include <ufs/mfs/mfs_extern.h> /* mfs_initminiroot() */
@ -110,25 +100,10 @@ char cpu_model[30];
vm_map_t buffer_map;
/*
* Declare these as initialized data so we can patch them.
*/
int nswbuf = 0;
#ifdef NBUF
int nbuf = NBUF;
#else
int nbuf = 0;
#endif
#ifdef BUFPAGES
int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
caddr_t msgbufaddr;
int maxmem; /* max memory per process */
int physmem; /* max supported memory, changes to actual */
phys_ram_seg_t mem_clusters[1]; /* XXX VM_PHYSSEG_MAX */
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
/*
@ -186,9 +161,6 @@ extern void stacktrace __P((void)); /*XXX*/
*/
int safepri = MIPS3_PSL_LOWIPL; /* XXX */
struct user *proc0paddr;
struct proc nullproc; /* for use by switch_exit() */
struct idrom idrom;
/* locore callback-vector setup */
@ -207,9 +179,9 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
int x_maxmem;
{
register int i;
register unsigned firstaddr;
register caddr_t v;
caddr_t start;
u_long first, last;
caddr_t kernend, v;
vm_size_t size;
extern u_long bootdev;
extern char edata[], end[];
@ -221,8 +193,8 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
*(int *)(MIPS_PHYS_TO_KSEG1(MACH_BOOTSW_ADDR)) = x_boothowto;
/* clear the BSS segment */
v = (caddr_t)mips_round_page(end);
bzero(edata, v - edata);
kernend = (caddr_t)mips_round_page(end);
bzero(edata, kernend - edata);
/*
* Set the VM page size.
@ -267,79 +239,40 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
*/
if (boothowto & RB_MINIROOT) {
boothowto |= RB_DFLTROOT;
v += mfs_initminiroot(v);
kernend += round_page(mfs_initminiroot(kernend));
}
#endif
/*
* Init mapping for u page(s) for proc[0], pm_tlbpid 1.
* Init mapping for u page(s) for proc0, pm_tlbpid 1.
* This also initializes nullproc for switch_exit().
*/
start = v;
proc0.p_addr = proc0paddr = (struct user *)v;
curpcb = (struct pcb *)proc0.p_addr;
proc0.p_md.md_regs = proc0paddr->u_pcb.pcb_regs;
firstaddr = MIPS_KSEG0_TO_PHYS(v);
mips_init_proc0(kernend);
if (CPUISMIPS3) for (i = 0; i < UPAGES; i+=2) {
struct tlb tlb;
tlb.tlb_mask = MIPS3_PG_SIZE_4K;
tlb.tlb_hi = mips3_vad_to_vpn((UADDR + (i << PGSHIFT))) | 1;
tlb.tlb_lo0 = vad_to_pfn(firstaddr) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
tlb.tlb_lo1 = vad_to_pfn(firstaddr + NBPG) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
proc0.p_md.md_upte[i] = tlb.tlb_lo0;
proc0.p_md.md_upte[i+1] = tlb.tlb_lo1;
mips3_TLBWriteIndexedVPS(i,&tlb);
firstaddr += NBPG * 2;
}
else for (i = 0; i < UPAGES; i++) {
mips1_TLBWriteIndexed(i,
(UADDR + (i << PGSHIFT)) | (1 << MIPS1_TLB_PID_SHIFT),
proc0.p_md.md_upte[i] = firstaddr |
MIPS1_PG_V | MIPS1_PG_M);
firstaddr += NBPG;
}
v += UPAGES * NBPG;
MachSetPID(1);
kernend += 2 * UPAGES * PAGE_SIZE;
/*
* init nullproc for switch_exit().
* init mapping for u page(s), pm_tlbpid 0
* This could be used for an idle process.
* Load the rest of the available pages into the VM system.
*/
nullproc.p_addr = (struct user *)v;
nullproc.p_md.md_regs = nullproc.p_addr->u_pcb.pcb_regs;
bcopy("nullproc", nullproc.p_comm, sizeof("nullproc"));
if (CPUISMIPS3) {
/* mips3 */
for (i = 0; i < UPAGES; i+=2) {
nullproc.p_md.md_upte[i] = vad_to_pfn(firstaddr) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
nullproc.p_md.md_upte[i+1] =
vad_to_pfn(firstaddr + NBPG) |
MIPS3_PG_V | MIPS3_PG_M | MIPS3_PG_CACHED;
firstaddr += NBPG * 2;
}
} else {
/* mips1 */
for (i = 0; i < UPAGES; i++) {
nullproc.p_md.md_upte[i] = firstaddr |
MIPS1_PG_V | MIPS1_PG_M;
firstaddr += NBPG;
}
}
first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
last = mem_clusters[0].start + mem_clusters[0].size;
vm_page_physload(atop(first), atop(last), atop(first), atop(last));
v += UPAGES * NBPG;
/*
* Initialize error message buffer (at end of core).
*/
mips_init_msgbuf();
/* clear pages for u areas */
bzero(start, v - start);
if (CPUISMIPS3) {
mips3_FlushDCache(MIPS_KSEG0_TO_PHYS(start), v - start);
mips3_HitFlushDCache(UADDR, UPAGES * NBPG);
}
/*
* Allocate space for system data structures. These data structures
* are allocated here instead of cpu_startup() because physical
* memory is directly addressable. We don't have to map these into
* virtual address space.
*/
size = (vm_size_t)allocsys(0);
v = (caddr_t)pmap_steal_memory(size, NULL, NULL);
if ((allocsys(v) - v) != size)
panic("mach_init: table size inconsistency");
/*
* Determine what model of computer we are running on.
@ -371,79 +304,10 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem)
cpu_reboot(RB_HALT | RB_NOSYNC, NULL);
}
/*
* Initialize error message buffer (at end of core).
*/
maxmem -= btoc(MSGBUFSIZE);
msgbufaddr = (caddr_t)(MIPS_PHYS_TO_KSEG0(maxmem << PGSHIFT));
initmsgbuf(msgbufaddr, mips_round_page(MSGBUFSIZE));
/*
* Allocate space for system data structures.
* The first available kernel virtual address is in "v".
* As pages of kernel virtual memory are allocated, "v" is incremented.
*
* These data structures are allocated here instead of cpu_startup()
* because physical memory is directly addressable. We don't have
* to map these into virtual address space.
*/
start = v;
#define valloc(name, type, num) \
(name) = (type *)v; v = (caddr_t)((name)+(num))
#define valloclim(name, type, num, lim) \
(name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
#ifdef REAL_CLISTS
valloc(cfree, struct cblock, nclist);
#endif
valloc(callout, struct callout, ncallout);
#ifdef SYSVSHM
valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
#endif
#ifdef SYSVSEM
valloc(sema, struct semid_ds, seminfo.semmni);
valloc(sem, struct sem, seminfo.semmns);
/* This is pretty disgusting! */
valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
#endif
#ifdef SYSVMSG
valloc(msgpool, char, msginfo.msgmax);
valloc(msgmaps, struct msgmap, msginfo.msgseg);
valloc(msghdrs, struct msg, msginfo.msgtql);
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
/*
* Determine how many buffers to allocate.
* We allocate more buffer space than the BSD standard of
* using 10% of memory for the first 2 Meg, 5% of remaining.
* We just allocate a flat 10%. Ensure a minimum of 16 buffers.
* We allocate 1/2 as many swap buffer headers as file i/o buffers.
*/
if (bufpages == 0)
bufpages = physmem / 10 / CLSIZE;
if (nbuf == 0) {
nbuf = bufpages;
if (nbuf < 16)
nbuf = 16;
}
if (nswbuf == 0) {
nswbuf = (nbuf / 2) &~ 1; /* force even */
if (nswbuf > 256)
nswbuf = 256; /* sanity */
}
valloc(swbuf, struct buf, nswbuf);
valloc(buf, struct buf, nbuf);
/*
* Clear allocated memory.
*/
bzero(start, v - start);
/*
* Initialize the virtual memory system.
*/
pmap_bootstrap((vm_offset_t)v);
pmap_bootstrap();
}
/*