diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-06-12 18:13:19 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-06-12 18:13:19 +0000 |
commit | 930c6b5ae867fd629875b5d5b31e5bd039f3cc67 (patch) | |
tree | 12f5789f002cdc60a2cc95895e2986ee07b0ddac /sys/arch | |
parent | 7d31b18b09786618f9192c86a4dcf7e7cf1ccc5a (diff) |
hppa_init() now takes an argument from locore,
meaning the start of available memory.
cleanup machdep somewhat.
fix vm_map.pmap vs vm_pmap isue; 10x art@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/hppa/hppa/machdep.c | 159 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/vm_machdep.c | 4 | ||||
-rw-r--r-- | sys/arch/hppa/include/cpu.h | 16 |
3 files changed, 84 insertions, 95 deletions
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index c0ffd2796e4..d5cb62da41b 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,7 +1,7 @@ -/* $OpenBSD: machdep.c,v 1.8 1999/05/23 19:11:19 mickey Exp $ */ +/* $OpenBSD: machdep.c,v 1.9 1999/06/12 18:13:18 mickey Exp $ */ /* - * Copyright (c) 1998 Michael Shalayeff + * Copyright (c) 1998,1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,6 +28,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * follows are the copyrights of other sources used in this file. */ /* * Copyright 1996 1995 by Open Software Foundation, Inc. @@ -143,9 +145,19 @@ #include <hppa/dev/cpudevs_data.h> /* - * Declare these as initialized data so we can patch them. + * Patchable buffer cache parameters */ -int nswbuf = 0; +int nswbuf = 0; +#ifdef NBUF +int nbuf = NBUF; +#else +int nbuf = 0; +#endif +#ifdef BUFPAGES +int bufpages = BUFPAGES; +#else +int bufpages = 0; +#endif /* * Different kinds of flags used throughout the kernel. @@ -172,18 +184,19 @@ struct pdc_cache pdc_cache PDC_ALIGNMENT; struct pdc_btlb pdc_btlb PDC_ALIGNMENT; /* the following is used externally (sysctl_hw) */ -char machine[] = "hppa"; +char machine[] = MACHINE_ARCH; char cpu_model[128]; #ifdef COMPAT_HPUX int cpu_model_hpux; /* contains HPUX_SYSCONF_CPU* kind of value */ #endif + u_int cpu_ticksnum, cpu_ticksdenom, cpu_hzticks; dev_t bootdev; int totalphysmem, physmem, resvmem, esym; + struct user *proc0paddr; struct proc *fpu_curproc; int copr_sfu_config; -int fpcopr_version; #ifdef TLB_STATS struct dtlb_stats dtlb_stats; @@ -204,13 +217,16 @@ void dumpsys __P((void)); int bus_mem_add_mapping __P((bus_addr_t bpa, bus_size_t size, int cacheable, bus_space_handle_t *bshp)); +/* wide used hardware params */ +struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT; +struct pdc_coproc pdc_coproc PDC_ALIGNMENT; + void -hppa_init() +hppa_init(start) + paddr_t start; { - extern int kernel_text, end; - struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT; - struct pdc_coproc pdc_coproc PDC_ALIGNMENT; - vm_offset_t v, vstart, vend; + extern int kernel_text; + vaddr_t v, vstart, vend; register int pdcerr; int usehpt; @@ -254,8 +270,39 @@ hppa_init() ptlball(); fcacheall(); + totalphysmem = PAGE0->imm_max_mem / NBPG; + resvmem = ((vm_offset_t)&kernel_text) / NBPG; + + /* calculate buffer cache size */ +#ifndef BUFCACHEPERCENT +#define BUFCACHEPERCENT 10 +#endif /* BUFCACHEPERCENT */ + if (bufpages == 0) + bufpages = totalphysmem / 100 * BUFCACHEPERCENT; + if (nbuf == 0) { + nbuf = bufpages; + if (nbuf < 16) + nbuf = 16; + } + + /* Restrict to at most 70% filled kvm */ + if (nbuf * MAXBSIZE > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10) + nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + MAXBSIZE * 7 / 10; + + /* More buffer pages than fits into the buffers is senseless. */ + if (bufpages > nbuf * MAXBSIZE / CLBYTES) + bufpages = nbuf * MAXBSIZE / CLBYTES; + + if (nswbuf == 0) { + nswbuf = (nbuf / 2) &~ 1; + if (nswbuf > 256) + nswbuf = 256; + } + /* calculate HPT size */ - hpt_hashsize = PAGE0->imm_max_mem / NBPG; + hpt_hashsize = totalphysmem; mtctl(hpt_hashsize - 1, CR_HPTMASK); /* @@ -267,7 +314,7 @@ hppa_init() usehpt = 0; } else { usehpt = 1; -#ifdef DEBUG +#ifdef PMAPDEBUG printf("hwtlb: %u-%u, %u/", pdc_hwtlb.min_size, pdc_hwtlb.max_size, hpt_hashsize); #endif @@ -275,16 +322,13 @@ hppa_init() hpt_hashsize = pdc_hwtlb.max_size; else if (hpt_hashsize < pdc_hwtlb.min_size) hpt_hashsize = pdc_hwtlb.min_size; -#ifdef DEBUG +#ifdef PMAPDEBUG printf("%u (0x%x)\n", hpt_hashsize, hpt_hashsize * sizeof(struct hpt_entry)); #endif } - totalphysmem = PAGE0->imm_max_mem / NBPG; - resvmem = ((vm_offset_t)&kernel_text) / NBPG; - - vstart = hppa_round_page(&end); + vstart = hppa_round_page(start); vend = VM_MAX_KERNEL_ADDRESS; /* we hope this won't fail */ @@ -296,24 +340,15 @@ hppa_init() EX_NOWAIT)) panic("cannot reserve main memory"); - /* - * Allocate space for system data structures. We are given - * a starting virtual address and we return a final virtual - * address; along the way we set each data structure pointer. - * - * We call allocsys() with 0 to find out how much space we want, - * allocate that much and fill it with zeroes, and the call - * allocsys() again with the correct base virtual address. - */ - v = vstart; -#define valloc(name, type, num) \ - (name) = (type *)v; v = (vm_offset_t)((name)+(num)) +#define valloc(name, type, num) (name) = (type *)v; v = (vaddr_t)((name)+(num)) #ifdef REAL_CLISTS valloc(cfree, struct cblock, nclist); #endif valloc(callout, struct callout, ncallout); + valloc(buf, struct buf, nbuf); + #ifdef SYSVSHM valloc(shmsegs, struct shmid_ds, shminfo.shmmni); #endif @@ -329,40 +364,8 @@ hppa_init() valloc(msghdrs, struct msg, msginfo.msgtql); valloc(msqids, struct msqid_ds, msginfo.msgmni); #endif - -#ifndef BUFCACHEPERCENT -#define BUFCACHEPERCENT 10 -#endif /* BUFCACHEPERCENT */ - - if (bufpages == 0) - bufpages = totalphysmem / BUFCACHEPERCENT / CLSIZE; - if (nbuf == 0) { - nbuf = bufpages; - if (nbuf < 16) - nbuf = 16; - } - - /* Restrict to at most 70% filled kvm */ - if (nbuf * MAXBSIZE > - (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10) - nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / - MAXBSIZE * 7 / 10; - - /* More buffer pages than fits into the buffers is senseless. */ - if (bufpages > nbuf * MAXBSIZE / CLBYTES) - bufpages = nbuf * MAXBSIZE / CLBYTES; - - if (nswbuf == 0) { - nswbuf = (nbuf / 2) & ~1; /* force even */ - if (nswbuf > 256) - nswbuf = 256; /* sanity */ - } - -#ifndef UVM - valloc(swbuf, struct buf, nswbuf); -#endif - valloc(buf, struct buf, nbuf); #undef valloc + v = hppa_round_page(v); bzero ((void *)vstart, (v - vstart)); vstart = v; @@ -408,11 +411,7 @@ hppa_init() } copr_sfu_config = pdc_coproc.ccr_enable; mtctl(copr_sfu_config & CCR_MASK, CR_CCR); -/* - fprinit(&fpcopr_version); - fpcopr_version = (fpcopr_version & 0x003ff800) >> 11; - mtctl(CR_CCR, 0); -*/ + /* * Clear the FAULT light (so we know when we get a real one) * PDC_COPROC apparently turns it on (for whatever reason). @@ -522,12 +521,8 @@ cpu_startup() if ((pg = uvm_pagealloc(NULL, 0, NULL)) == NULL) panic("cpu_startup: not enough memory for " "buffer cache"); -#ifdef PMAP_NEW - pmap_kenter_pgs(curbuf, &pg, 1); -#else pmap_enter(kernel_map->pmap, curbuf, VM_PAGE_TO_PHYS(pg), VM_PROT_ALL, TRUE); -#endif curbuf += PAGE_SIZE; curbufsize -= PAGE_SIZE; } @@ -588,12 +583,6 @@ cpu_startup() } hppa_malloc_ok = 1; configure(); -#if 0 - /* TODO: map SysCall gateways page once for everybody */ - pmap_enter_pv(pmap_kernel(), SYSCALLGATE, TLB_GATE_PROT, - tlbbtop((paddr_t)&gateway_page), - pmap_find_va(HPPA_SID_KERNEL, SYSCALLGATE)); -#endif } /* @@ -630,7 +619,7 @@ delay(us) mfctl(CR_ITMR, start); while (us) { - n = min(100, us); + n = min(1000, us); end = start + n * cpu_ticksnum / cpu_ticksdenom; /* N.B. Interval Timer may wrap around */ @@ -1251,10 +1240,10 @@ setregs(p, pack, stack, retval) tf->tf_sr5 = p->p_addr->u_pcb.pcb_space; tf->tf_sr6 = p->p_addr->u_pcb.pcb_space; tf->tf_sr7 = HPPA_SID_KERNEL; - tf->tf_pidr1 = p->p_vmspace->vm_pmap.pmap_pid; - tf->tf_pidr2 = p->p_vmspace->vm_pmap.pmap_pid; - tf->tf_pidr3 = p->p_vmspace->vm_pmap.pmap_pid; - tf->tf_pidr4 = p->p_vmspace->vm_pmap.pmap_pid; + tf->tf_pidr1 = p->p_vmspace->vm_map.pmap->pmap_pid; + tf->tf_pidr2 = p->p_vmspace->vm_map.pmap->pmap_pid; + tf->tf_pidr3 = p->p_vmspace->vm_map.pmap->pmap_pid; + tf->tf_pidr4 = p->p_vmspace->vm_map.pmap->pmap_pid; retval[1] = 0; } @@ -1270,7 +1259,7 @@ sendsig(catcher, sig, mask, code, type, val) int type; union sigval val; { - /* TODO */ + /* TODO send signal */ } int @@ -1279,7 +1268,7 @@ sys_sigreturn(p, v, retval) void *v; register_t *retval; { - /* TODO */ + /* TODO sigreturn */ return EINVAL; } diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index 9279192d540..10d330ce81f 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.5 1999/05/21 17:49:47 mickey Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.6 1999/06/12 18:13:18 mickey Exp $ */ #include <sys/param.h> #include <sys/systm.h> @@ -113,7 +113,7 @@ cpu_fork(p1, p2) pcbp = &p2->p_addr->u_pcb; *pcbp = p1->p_addr->u_pcb; /* space is cached for the copy{in,out}'s pleasure */ - pcbp->pcb_space = p2->p_vmspace->vm_pmap.pmap_space; + pcbp->pcb_space = p2->p_vmspace->vm_map.pmap->pmap_space; #ifdef DIAGNOSTIC if (round_page(sizeof(struct user)) >= USPACE) diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h index 24ce6c58b6f..0a72fa5ab5c 100644 --- a/sys/arch/hppa/include/cpu.h +++ b/sys/arch/hppa/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.8 1999/05/02 03:41:08 mickey Exp $ */ +/* $OpenBSD: cpu.h,v 1.9 1999/06/12 18:13:16 mickey Exp $ */ /* * Copyright (c) 1988-1994, The University of Utah and @@ -61,19 +61,19 @@ #ifdef _KERNEL #define DELAY(x) delay(x) -void delay __P((u_int)); -void hppa_init __P((void)); -void trap __P((int, struct trapframe *)); -int kvtop __P((const caddr_t)); -int dma_cachectl __P((caddr_t, int)); +void delay __P((u_int us)); +void hppa_init __P((paddr_t start)); +void trap __P((int type, struct trapframe *frame)); +int kvtop __P((const caddr_t va)); +int dma_cachectl __P((caddr_t p, int size)); int spcopy __P((pa_space_t ssp, const void *src, pa_space_t dsp, void *dst, size_t size)); int spstrcpy __P((pa_space_t ssp, const void *src, pa_space_t dsp, void *dst, size_t size, size_t *rsize)); int copy_on_fault __P((void)); -void child_return __P((struct proc *)); +void child_return __P((struct proc *p)); void switch_trampoline __P((void)); -void switch_exit __P((struct proc *)); +void switch_exit __P((struct proc *p)); #define cpu_wait(p) /* so, nobody uses it nomore */ #if 0 #define cpu_swapin(p) /* nothing */ |