summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>1999-11-25 18:46:07 +0000
committermickey <mickey@openbsd.org>1999-11-25 18:46:07 +0000
commit014190bd0742dd5caa0dd179e162fc2d32aa9c8f (patch)
tree62cb0f9bcfc44fe936d05d6fbbdf650934721590
parentit forks, it execs, it syscalls (diff)
downloadwireguard-openbsd-014190bd0742dd5caa0dd179e162fc2d32aa9c8f.tar.xz
wireguard-openbsd-014190bd0742dd5caa0dd179e162fc2d32aa9c8f.zip
bus stuff is in mainbus now, the rest is rewritten many ways
-rw-r--r--sys/arch/hppa/hppa/machdep.c744
1 files changed, 229 insertions, 515 deletions
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 91abef0ff5d..8899fbec5cb 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: machdep.c,v 1.14 1999/09/20 21:40:14 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.15 1999/11/25 18:46:07 mickey Exp $ */
/*
- * Copyright (c) 1998,1999 Michael Shalayeff
+ * Copyright (c) 1999 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,72 +14,24 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by Michael Shalayeff.
+ * This product includes software developed by Michael Shalayeff.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * 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.
- * All Rights Reserved
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation.
- *
- * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
- * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * (c) Copyright 1988 HEWLETT-PACKARD COMPANY
- *
- * To anyone who acknowledges that this file is provided "AS IS"
- * without any express or implied warranty:
- * permission to use, copy, modify, and distribute this file
- * for any purpose is hereby granted without fee, provided that
- * the above copyright notice and this notice appears in all
- * copies, and that the name of Hewlett-Packard Company not be
- * used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission.
- * Hewlett-Packard Company makes no representations about the
- * suitability of this software for any purpose.
- */
-/*
- * Copyright (c) 1990,1991,1992,1994 The University of Utah and
- * the Computer Systems Laboratory (CSL). All rights reserved.
- *
- * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
- * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM ITS USE.
- *
- * CSL requests users of this software to return to csl-dist@cs.utah.edu any
- * improvements that they make and grant CSL redistribution rights.
- *
- * Utah $Hdr: model_dep.c 1.34 94/12/14$
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY 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.
*/
-#undef BTLBDEBUG
+#undef BTLBDEBUG
#include <sys/param.h>
#include <sys/systm.h>
@@ -165,144 +117,156 @@ int bufpages = 0;
* Different kinds of flags used throughout the kernel.
*/
int cold = 1; /* unset when engine is up to go */
-int kernelmapped; /* set when kernel is mapped */
int msgbufmapped; /* set when safe to use msgbuf */
-int hppa_malloc_ok; /* set when safe to use malloc */
-int intr_recurse; /* interrupt/trap recursion level */
/*
- * used in locore.S
+ * things to kill
*/
int icache_stride;
int dcache_stride;
int dcache_line_mask;
-int dcache_size;
-double fpu_zero = 0.0;
/*
- * CPU params
+ * CPU params (should be the same for all cpus in the system)
*/
struct pdc_cache pdc_cache PDC_ALIGNMENT;
struct pdc_btlb pdc_btlb PDC_ALIGNMENT;
-
-/* the following is used externally (sysctl_hw) */
+ /* w/ a little deviation should be the same for all installed cpus */
+u_int cpu_ticksnum, cpu_ticksdenom, cpu_hzticks;
+ /* exported info */
char machine[] = MACHINE_ARCH;
char cpu_model[128];
#ifdef COMPAT_HPUX
-int cpu_model_hpux; /* contains HPUX_SYSCONF_CPU* kind of value */
+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;
+int totalphysmem, resvmem, physmem, esym;
+/*
+ * Things for MI glue to stick on.
+ */
struct user *proc0paddr;
struct proc *fpu_curproc;
-int copr_sfu_config;
-
-#ifdef TLB_STATS
-struct dtlb_stats dtlb_stats;
-struct itlb_stats itlb_stats;
-struct tlbd_stats tlbd_stats;
-#endif
+long mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
+struct extent *hppa_ex;
vm_map_t exec_map = NULL;
vm_map_t mb_map = NULL;
vm_map_t phys_map = NULL;
-struct extent *hppa_ex;
-static long mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
void delay_init __P((void));
-static __inline void fall __P((int, int, int, int, int));
+static __inline void fall __P((int, int, int, int, int));
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 */
+/*
+ * wide used hardware params
+ */
struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT;
struct pdc_coproc pdc_coproc PDC_ALIGNMENT;
struct pdc_coherence pdc_coherence PDC_ALIGNMENT;
+#ifdef DEBUG
+int sigdebug;
+pid_t sigpid;
+#define SDB_FOLLOW 0x01
+#endif
+
+
void
hppa_init(start)
paddr_t start;
{
extern int kernel_text;
vaddr_t v, vstart, vend;
- register int pdcerr;
- int usehpt;
+ register int error;
+ int hptsize; /* size of HPT table if supported */
- /* init PDC iface, so we can call em easy */
- pdc_init();
+ pdc_init(); /* init PDC iface, so we can call em easy */
- /* calculate cpu speed */
cpu_hzticks = (PAGE0->mem_10msec * 100) / hz;
- delay_init();
+ delay_init(); /* calculate cpu clock ratio */
- /*
- * get cache parameters from the PDC
- */
- if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT,
- &pdc_cache)) < 0) {
+ /* cache parameters */
+ if ((error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT,
+ &pdc_cache)) < 0) {
#ifdef DEBUG
- printf("Warning: PDC_CACHE call Ret'd %d\n", pdcerr);
+ printf("WARNING: PDC_CACHE error %d\n", error);
#endif
}
+ /* XXX these gonna die */
dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1;
- dcache_size = pdc_cache.dc_size;
dcache_stride = pdc_cache.dc_stride;
icache_stride = pdc_cache.ic_stride;
- /*
- * get cache coherence parameters
- */
- pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_SETCS,
- &pdc_coherence, 1, 1, 1, 1);
+ /* cache coherence params (pbably available for 8k only) */
+ error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_SETCS,
+ &pdc_coherence, 1, 1, 1, 1);
#ifdef DEBUG
printf ("PDC_CACHE_SETCS: %d, %d, %d, %d (%d)\n",
- pdc_coherence.ia_cst, pdc_coherence.da_cst,
- pdc_coherence.ita_cst, pdc_coherence.dta_cst,
- pdcerr);
+ pdc_coherence.ia_cst, pdc_coherence.da_cst,
+ pdc_coherence.ita_cst, pdc_coherence.dta_cst, error);
#endif
- /*
- * Fetch BTLB params
- */
- if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,
- PDC_BTLB_DEFAULT, &pdc_btlb)) < 0) {
-#ifdef DEBUG
- printf("WARNING: PDC_BTLB call Ret'd %d\n", pdcerr);
-#endif
- }
+ /* BTLB params */
+ if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,
+ PDC_BTLB_DEFAULT, &pdc_btlb)) < 0)
+ panic("WARNING: PDC_BTLB error %d", error);
- /*
- * purge TLBs and flush caches
- */
+ /* purge TLBs and caches */
if (pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_PURGE_ALL) < 0)
printf("WARNING: BTLB purge failed\n");
+
ptlball();
fcacheall();
totalphysmem = PAGE0->imm_max_mem / NBPG;
- resvmem = ((vm_offset_t)&kernel_text) / NBPG;
+ resvmem = ((vaddr_t)&kernel_text) / NBPG;
+
+ /* calculate HPT size */
+ for (hptsize = 1; hptsize < totalphysmem; hptsize *= 2);
+ mtctl(hptsize - 1, CR_HPTMASK);
+
+ if (pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb) &&
+ !pdc_hwtlb.min_size && !pdc_hwtlb.max_size) {
+ printf("WARNING: no HPT support, fine!\n");
+ hptsize = 0;
+ } else {
+ if (hptsize > pdc_hwtlb.max_size)
+ hptsize = pdc_hwtlb.max_size;
+ else if (hptsize < pdc_hwtlb.min_size)
+ hptsize = pdc_hwtlb.min_size;
+ /* have to reload after adjustment */
+ mtctl(hptsize - 1, CR_HPTMASK);
+ }
- /* calculate buffer cache size */
+ /* we hope this won't fail */
+ hppa_ex = extent_create("mem", 0x0, 0xffffffff, M_DEVBUF,
+ (caddr_t)mem_ex_storage, sizeof(mem_ex_storage),
+ EX_NOCOALESCE|EX_NOWAIT);
+ if (extent_alloc_region(hppa_ex, 0, (vaddr_t)PAGE0->imm_max_mem,
+ EX_NOWAIT))
+ panic("cannot reserve main memory");
+
+ vstart = hppa_round_page(start);
+ vend = VM_MAX_KERNEL_ADDRESS;
+
+ /*
+ * Now allocate kernel dynamic variables
+ */
+
+ /* buffer cache parameters */
#ifndef BUFCACHEPERCENT
#define BUFCACHEPERCENT 10
#endif /* BUFCACHEPERCENT */
- if (bufpages == 0) {
- if (totalphysmem <= 0x1000) /* 16M */
- bufpages = totalphysmem / 100 * 5;
- else
- bufpages = totalphysmem / 100 * BUFCACHEPERCENT;
- }
- if (nbuf == 0) {
- nbuf = bufpages;
- if (nbuf < 16)
- nbuf = 16;
- }
+ if (bufpages == 0)
+ bufpages = totalphysmem / 100 *
+ (totalphysmem <= 0x1000? 5 : BUFCACHEPERCENT);
+
+ if (nbuf == 0)
+ nbuf = bufpages < 16? 16 : bufpages;
/* Restrict to at most 70% filled kvm */
if (nbuf * MAXBSIZE >
@@ -310,7 +274,7 @@ hppa_init(start)
nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
MAXBSIZE * 7 / 10;
- /* More buffer pages than fits into the buffers is senseless. */
+ /* More buffer pages than fits into the buffers is senseless. */
if (bufpages > nbuf * MAXBSIZE / CLBYTES)
bufpages = nbuf * MAXBSIZE / CLBYTES;
@@ -319,60 +283,23 @@ hppa_init(start)
if (nswbuf > 256)
nswbuf = 256;
}
-
- /* calculate HPT size */
- for (usehpt = 1; usehpt < totalphysmem; usehpt *= 2);
- mtctl(usehpt - 1, CR_HPTMASK);
-
- /*
- * If we want to use the HW TLB support, ensure that it exists.
- */
- if (pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb) &&
- !pdc_hwtlb.min_size && !pdc_hwtlb.max_size) {
- printf("WARNING: no HW tlb walker\n");
- usehpt = 0;
- } else {
-#ifdef PMAPDEBUG
- printf("hwtlb: %u-%u, %u/",
- pdc_hwtlb.min_size, pdc_hwtlb.max_size, usehpt);
-#endif
- if (usehpt > pdc_hwtlb.max_size)
- usehpt = pdc_hwtlb.max_size;
- else if (usehpt < pdc_hwtlb.min_size)
- usehpt = pdc_hwtlb.min_size;
-#ifdef PMAPDEBUG
- printf("%u\n", usehpt);
-#endif
- mtctl(usehpt - 1, CR_HPTMASK);
- }
- vstart = hppa_round_page(start);
- vend = VM_MAX_KERNEL_ADDRESS;
-
- /* we hope this won't fail */
- hppa_ex = extent_create("mem", 0x0, 0xffffffff, M_DEVBUF,
- (caddr_t)mem_ex_storage,
- sizeof(mem_ex_storage),
- EX_NOCOALESCE|EX_NOWAIT);
- if (extent_alloc_region(hppa_ex, 0, (vm_offset_t)PAGE0->imm_max_mem,
- EX_NOWAIT))
- panic("cannot reserve main memory");
-
v = vstart;
-#define valloc(name, type, num) (name) = (type *)v; v = (vaddr_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
-#ifdef SYSVSEM
+#ifdef SYSVSEM
valloc(sema, struct semid_ds, seminfo.semmni);
- valloc(sem, struct sem, seminfo.semmns);
+ valloc(sem, struct sem, seminfo.semmns);
/* This is pretty disgusting! */
valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
#endif
@@ -383,6 +310,7 @@ hppa_init(start)
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
#undef valloc
+
v = hppa_round_page(v);
bzero ((void *)vstart, (v - vstart));
vstart = v;
@@ -392,70 +320,56 @@ hppa_init(start)
/* alloc msgbuf */
if (!(msgbufp = (void *)pmap_steal_memory(sizeof(struct msgbuf),
- NULL, NULL)))
+ NULL, NULL)))
panic("cannot allocate msgbuf");
msgbufmapped = 1;
-#ifdef PMAPDEBUG
- printf("mem: %x+%x, %x\n", physmem, resvmem, totalphysmem);
-#endif
/* Turn on the HW TLB assist */
- if (usehpt) {
- int hpt, hptsize;
+ if (hptsize) {
+ u_int hpt;
+
mfctl(CR_VTOP, hpt);
- mfctl(CR_HPTMASK, hptsize);
- hptsize++;
- if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_TLB,
- PDC_TLB_CONFIG, &pdc_hwtlb, hpt,
- hptsize, PDC_TLB_CURRPDE)) < 0) {
- printf("Warning: HW TLB init failed (%d), disabled\n",
- pdcerr);
- } else
+ if ((error = pdc_call((iodcio_t)pdc, 0, PDC_TLB,
+ PDC_TLB_CONFIG, &pdc_hwtlb, hpt, hptsize,
+ PDC_TLB_CURRPDE)) < 0) {
+#ifdef DEBUG
+ printf("WARNING: HPT init error %d\n", error);
+#endif
+ } else {
#ifdef PMAPDEBUG
- printf("HW TLB(%d entries at 0x%x) initialized (%d)\n",
- hptsize / sizeof(struct hpt_entry), hpt, pdcerr);
+ printf("HPT: %d entries @ 0x%x\n",
+ hptsize / sizeof(struct hpt_entry), hpt);
#endif
+ }
}
- /*
- * Locate any coprocessors and enable them by setting up the CCR.
- * SFU's are ignored (since we dont have any). Also, initialize
- * the floating point registers here.
- */
- if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT,
- &pdc_coproc)) < 0)
- printf("WARNING: PDC_COPROC call Ret'd %d\n", pdcerr);
+ /* locate coprocessors and SFUs */
+ if ((error = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT,
+ &pdc_coproc)) < 0)
+ printf("WARNING: PDC_COPROC error %d\n", error);
else {
#ifdef DEBUG
printf("pdc_coproc: %x, %x\n", pdc_coproc.ccr_enable,
- pdc_coproc.ccr_present);
+ pdc_coproc.ccr_present);
#endif
+ mtctl(pdc_coproc.ccr_enable & CCR_MASK, CR_CCR);
}
- copr_sfu_config = pdc_coproc.ccr_enable;
- mtctl(copr_sfu_config & CCR_MASK, CR_CCR);
- /*
- * Clear the FAULT light (so we know when we get a real one)
- * PDC_COPROC apparently turns it on (for whatever reason).
- */
- pdcerr = PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0;
- (void) (*pdc)(PDC_CHASSIS, PDC_CHASSIS_DISP, pdcerr);
+ /* they say PDC_COPROC might turn fault light on */
+ pdc_call((iodcio_t)pdc, PDC_CHASSIS, PDC_CHASSIS_DISP,
+ PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0);
#ifdef DDB
ddb_init();
#endif
-#ifdef DEBUG
- printf("hppa_init: leaving\n");
-#endif
- kernelmapped++;
}
void
cpu_startup()
{
struct pdc_model pdc_model PDC_ALIGNMENT;
- vm_offset_t minaddr, maxaddr;
- vm_size_t size;
+ vaddr_t minaddr, maxaddr;
+ vsize_t size;
int base, residual;
int err, i;
#ifdef DEBUG
@@ -470,9 +384,9 @@ cpu_startup()
/* identify system type */
if ((err = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_INFO,
- &pdc_model)) < 0) {
+ &pdc_model)) < 0) {
#ifdef DEBUG
- printf("WARNING: PDC_MODEL failed (%d)\n", err);
+ printf("WARNING: PDC_MODEL error %d\n", err);
#endif
} else {
const char *p, *q;
@@ -509,7 +423,25 @@ cpu_startup()
}
printf("real mem = %d (%d reserved for PROM, %d used by OpenBSD)\n",
- ctob(totalphysmem), ctob(resvmem), ctob(physmem));
+ ctob(totalphysmem), ctob(resvmem), ctob(physmem));
+
+ /*
+ * Kludge for STI graphics, which may have rom outside the IO space
+ */
+#include "sti.h"
+#if NSTI > 0
+ {
+ vaddr_t addr = PAGE0->pd_resv2[1];
+
+ /* reserve virtual address space for the sti rom */
+ if (addr && addr < 0xf0000000 &&
+ uvm_map(kernel_map, &addr, 0x1000000, NULL,
+ UVM_UNKNOWN_OFFSET, UVM_MAPFLAG(UVM_PROT_NONE,
+ UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL,
+ UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ panic("cpu_startup: cannot allocate VM for buffers");
+ }
+#endif
/*
* Now allocate buffers proper. They are different than the above
@@ -517,9 +449,8 @@ cpu_startup()
*/
size = MAXBSIZE * nbuf;
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
- NULL, UVM_UNKNOWN_OFFSET,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ NULL, UVM_UNKNOWN_OFFSET, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
+ UVM_INH_NONE, UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vaddr_t)buffers;
base = bufpages / nbuf;
@@ -542,11 +473,10 @@ cpu_startup()
while (curbufsize) {
if ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL)
panic("cpu_startup: not enough memory for "
- "buffer cache");
+ "buffer cache");
pmap_enter(kernel_map->pmap, curbuf,
- VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ|VM_PROT_WRITE, TRUE,
- VM_PROT_READ|VM_PROT_WRITE);
+ VM_PAGE_TO_PHYS(pg), VM_PROT_READ|VM_PROT_WRITE,
+ TRUE, VM_PROT_READ|VM_PROT_WRITE);
curbuf += PAGE_SIZE;
curbufsize -= PAGE_SIZE;
}
@@ -557,23 +487,23 @@ cpu_startup()
* limits the number of processes exec'ing at any time.
*/
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
- 16*NCARGS, TRUE, FALSE, NULL);
+ 16*NCARGS, TRUE, FALSE, NULL);
/*
* Allocate a submap for physio
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
- VM_PHYS_SIZE, TRUE, FALSE, NULL);
+ VM_PHYS_SIZE, TRUE, FALSE, NULL);
/*
* Finally, allocate mbuf pool. Since mclrefcnt is an off-size
* we use the more space efficient malloc in place of kmem_alloc.
*/
mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES,
- M_MBUF, M_NOWAIT);
+ M_MBUF, M_NOWAIT);
bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES);
- mb_map = uvm_km_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
- VM_MBUF_SIZE, FALSE, FALSE, NULL);
+ mb_map = uvm_km_suballoc(kernel_map, (vaddr_t *)&mbutl, &maxaddr,
+ VM_MBUF_SIZE, FALSE, FALSE, NULL);
/*
* Initialize callouts
@@ -588,7 +518,7 @@ cpu_startup()
#endif
printf("avail mem = %ld\n", ptoa(uvmexp.free));
printf("using %d buffers containing %d bytes of memory\n",
- nbuf, bufpages * CLBYTES);
+ nbuf, bufpages * CLBYTES);
/*
* Set up buffers, so they can be used to read disk labels.
@@ -605,13 +535,11 @@ cpu_startup()
printf("kernel does not support -c; continuing..\n");
#endif
}
- hppa_malloc_ok = 1;
configure();
}
/*
- * compute cpu_ticksdenom and cpu_ticksnum such as:
- *
+ * compute cpu clock ratio such as:
* cpu_ticksnum / cpu_ticksdenom = t + delta
* delta -> 0
*/
@@ -663,50 +591,44 @@ delay(us)
static __inline void
fall(c_base, c_count, c_loop, c_stride, data)
- int c_base, c_count, c_loop, c_stride, data;
+ int c_base, c_count, c_loop, c_stride, data;
{
- register int loop; /* Internal vars */
+ register int loop;
- for (; c_count--; c_base += c_stride)
- for (loop = c_loop; loop--; )
+ for (; c_count--; c_base += c_stride)
+ for (loop = c_loop; loop--; )
if (data)
fdce(0, c_base);
else
fice(0, c_base);
-
}
void
fcacheall()
{
- /*
- * Flush the instruction, then data cache.
- */
- fall (pdc_cache.ic_base, pdc_cache.ic_count,
- pdc_cache.ic_loop, pdc_cache.ic_stride, 0);
+ /*
+ * Flush the instruction, then data cache.
+ */
+ fall(pdc_cache.ic_base, pdc_cache.ic_count, pdc_cache.ic_loop,
+ pdc_cache.ic_stride, 0);
sync_caches();
- fall (pdc_cache.dc_base, pdc_cache.dc_count,
- pdc_cache.dc_loop, pdc_cache.dc_stride, 1);
+ fall(pdc_cache.dc_base, pdc_cache.dc_count, pdc_cache.dc_loop,
+ pdc_cache.dc_stride, 1);
sync_caches();
}
void
ptlball()
{
- register pa_space_t sp;
- register vm_offset_t off;
- register int six, oix, lix;
- int sixend, oixend, lixend;
+ register pa_space_t sp;
+ register int i, j, k;
/* instruction TLB */
- sixend = pdc_cache.it_sp_count;
- oixend = pdc_cache.it_off_count;
- lixend = pdc_cache.it_loop;
sp = pdc_cache.it_sp_base;
- for (six = 0; six < sixend; six++) {
- off = pdc_cache.it_off_base;
- for (oix = 0; oix < oixend; oix++) {
- for (lix = 0; lix < lixend; lix++)
+ for (i = 0; i < pdc_cache.it_sp_count; i++) {
+ register vaddr_t off = pdc_cache.it_off_base;
+ for (j = 0; j < pdc_cache.it_off_count; j++) {
+ for (k = 0; k < pdc_cache.it_loop; k++)
pitlbe(sp, off);
off += pdc_cache.it_off_stride;
}
@@ -714,14 +636,11 @@ ptlball()
}
/* data TLB */
- sixend = pdc_cache.dt_sp_count;
- oixend = pdc_cache.dt_off_count;
- lixend = pdc_cache.dt_loop;
sp = pdc_cache.dt_sp_base;
- for (six = 0; six < sixend; six++) {
- off = pdc_cache.dt_off_base;
- for (oix = 0; oix < oixend; oix++) {
- for (lix = 0; lix < lixend; lix++)
+ for (i = 0; i < pdc_cache.dt_sp_count; i++) {
+ register vaddr_t off = pdc_cache.dt_off_base;
+ for (j = 0; j < pdc_cache.dt_off_count; j++) {
+ for (k = 0; k < pdc_cache.dt_loop; k++)
pdtlbe(sp, off);
off += pdc_cache.dt_off_stride;
}
@@ -734,12 +653,12 @@ btlb_insert(space, va, pa, lenp, prot)
pa_space_t space;
vaddr_t va;
paddr_t pa;
- vm_size_t *lenp;
+ vsize_t *lenp;
u_int prot;
{
static u_int32_t mask;
- register vm_size_t len;
- register int pdcerr, i;
+ register vsize_t len;
+ register int error, i;
/* align size */
for (len = pdc_btlb.min_size << PGSHIFT; len < *lenp; len <<= 1);
@@ -748,7 +667,7 @@ btlb_insert(space, va, pa, lenp, prot)
if (len > pdc_btlb.max_size || i < 0) {
#ifdef BTLBDEBUG
printf("btln_insert: too big (%u < %u < %u)\n",
- pdc_btlb.min_size, len, pdc_btlb.max_size);
+ pdc_btlb.min_size, len, pdc_btlb.max_size);
#endif
return -(ENOMEM);
}
@@ -765,13 +684,12 @@ btlb_insert(space, va, pa, lenp, prot)
prot |= TLB_UNCACHEABLE;
#ifdef BTLBDEBUG
- printf ("btlb_insert(%d): %x:%x=%x[%x,%x]\n",
- i, space, va, pa, len, prot);
+ printf("btlb_insert(%d): %x:%x=%x[%x,%x]\n", i, space, va, pa, len, prot);
#endif
- if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,PDC_BTLB_INSERT,
- space, va, pa, len, prot, i)) < 0) {
+ if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,PDC_BTLB_INSERT,
+ space, va, pa, len, prot, i)) < 0) {
#ifdef BTLBDEBUG
- printf("WARNING: BTLB insert failed (%d)\n", pdcerr);
+ printf("WARNING: BTLB insert failed (%d)\n", error);
#endif
return -(EINVAL);
}
@@ -780,228 +698,6 @@ btlb_insert(space, va, pa, lenp, prot)
return i;
}
-int
-bus_space_map (t, bpa, size, cacheable, bshp)
- bus_space_tag_t t;
- bus_addr_t bpa;
- bus_size_t size;
- int cacheable;
- bus_space_handle_t *bshp;
-{
- register int error;
-
- bpa += HPPA_BUS_TAG_BASE(t);
- if ((error = extent_alloc_region(hppa_ex, bpa, size, EX_NOWAIT |
- (hppa_malloc_ok? EX_MALLOCOK : 0))))
- return (error);
-
- if ((error = bus_mem_add_mapping(bpa, size, cacheable, bshp))) {
- if (extent_free(hppa_ex, bpa, size, EX_NOWAIT |
- (hppa_malloc_ok? EX_MALLOCOK : 0))) {
- printf ("bus_space_map: pa 0x%lx, size 0x%lx\n",
- bpa, size);
- printf ("bus_space_map: can't free region\n");
- }
- }
-
- return 0;
-}
-
-void
-bus_space_unmap (t, bsh, size)
- bus_space_tag_t t;
- bus_space_handle_t bsh;
- bus_size_t size;
-{
- register u_long sva, eva;
- register bus_addr_t bpa;
-
- sva = hppa_trunc_page(bsh);
- eva = hppa_round_page(bsh + size);
-
-#ifdef DIAGNOSTIC
- if (eva <= sva)
- panic("bus_space_unmap: overflow");
-#endif
-
- bpa = kvtop((caddr_t)bsh);
- if (bpa != bsh)
- uvm_km_free(kernel_map, sva, eva - sva);
-
- if (extent_free(hppa_ex, bpa, size, EX_NOWAIT |
- (hppa_malloc_ok? EX_MALLOCOK : 0))) {
- printf("bus_space_unmap: ps 0x%lx, size 0x%lx\n",
- bpa, size);
- printf("bus_space_unmap: can't free region\n");
- }
-}
-
-int
-bus_space_alloc (t, rstart, rend, size, align, bndary, cacheable, addrp, bshp)
- bus_space_tag_t t;
- bus_addr_t rstart, rend;
- bus_size_t size, align, bndary;
- int cacheable;
- bus_addr_t *addrp;
- bus_space_handle_t *bshp;
-{
- u_long bpa;
- int error;
-
- if (rstart < hppa_ex->ex_start || rend > hppa_ex->ex_end)
- panic("bus_space_alloc: bad region start/end");
-
- if ((error = extent_alloc_subregion(hppa_ex, rstart, rend, size,
- align, bndary, EX_NOWAIT |
- (hppa_malloc_ok? EX_MALLOCOK:0),
- &bpa)))
- return (error);
-
- if ((error = bus_mem_add_mapping(bpa, size, cacheable, bshp))) {
- if (extent_free(hppa_ex, bpa, size, EX_NOWAIT |
- (hppa_malloc_ok ? EX_MALLOCOK : 0))) {
- printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n",
- bpa, size);
- printf("bus_space_alloc: can't free region\n");
- }
- }
-
- *addrp = bpa;
-
- return error;
-}
-
-void
-bus_space_free(t, bsh, size)
- bus_space_tag_t t;
- bus_space_handle_t bsh;
- bus_size_t size;
-{
- /* bus_space_unmap() does all that we need to do. */
- bus_space_unmap(t, bsh, size);
-}
-
-int
-bus_mem_add_mapping(bpa, size, cacheable, bshp)
- bus_addr_t bpa;
- bus_size_t size;
- int cacheable;
- bus_space_handle_t *bshp;
-{
- extern u_int virtual_avail;
- register u_int64_t spa, epa;
- int bank, off;
-
- if (bpa > 0 && bpa < virtual_avail)
- *bshp = bpa;
- else if ((bank = vm_physseg_find(atop(bpa), &off)) < 0) {
- /*
- * determine if we are mapping IO space, or beyond the physmem
- * region. use block mapping then
- *
- * we map the whole bus module (there are 1024 of those max)
- * so, check here if it's mapped already, map if needed.
- * all mappings a equal mappings.
- */
- static u_int8_t bmm[1024/8];
- int flex = HPPA_FLEX(bpa);
-
- /* need a new mapping */
- if (!(bmm[flex / 8] & (1 << (flex & 3)))) {
- spa = bpa & FLEX_MASK;
- epa = ((u_long)((u_int64_t)bpa + size +
- ~FLEX_MASK - 1) & FLEX_MASK) - 1;
-#ifdef BTLBDEBUG
- printf ("bus_mem_add_mapping: adding flex=%x "
- "%qx-%qx, ", flex, spa, epa);
-#endif
- while (spa < epa) {
- vm_size_t len = epa - spa;
- u_int64_t pa;
- if (len > pdc_btlb.max_size << PGSHIFT)
- len = pdc_btlb.max_size << PGSHIFT;
- if (btlb_insert(kernel_pmap->pmap_space, spa,
- spa, &len,
- kernel_pmap->pmap_pid |
- pmap_prot(kernel_pmap,
- VM_PROT_ALL)) < 0)
- return -1;
- pa = spa + len - 1;
-#ifdef BTLBDEBUG
- printf ("------ %d/%d, %qx, %qx-%qx",
- flex, HPPA_FLEX(pa), pa, spa, epa);
-#endif
- /* do the mask */
- for (; flex <= HPPA_FLEX(pa); flex++) {
-#ifdef BTLBDEBUG
- printf ("mask %x ", flex);
-#endif
- bmm[flex / 8] |= (1 << (flex & 3));
- }
- spa = pa;
- }
-#ifdef BTLBDEBUG
- printf ("\n");
-#endif
- }
- *bshp = bpa;
- } else {
- register vm_offset_t va;
-
-#ifdef PMAPDEBUG
- printf ("%d, %d, %x\n", bank, off, vm_physmem[0].end);
-#endif
- spa = hppa_trunc_page(bpa);
- epa = hppa_round_page(bpa + size);
-
-#ifdef DIAGNOSTIC
- if (epa <= spa)
- panic("bus_mem_add_mapping: overflow");
-#endif
-
- if (!(va = uvm_km_valloc(kernel_map, epa - spa)))
- return (ENOMEM);
-
- *bshp = (bus_space_handle_t)(va + (bpa & PGOFSET));
-
- for (; spa < epa; spa += NBPG, va += NBPG) {
- pmap_enter(pmap_kernel(), va, spa,
- VM_PROT_READ | VM_PROT_WRITE, TRUE, 0);
- if (!cacheable)
- pmap_changebit(spa, TLB_UNCACHEABLE, ~0);
- else
- pmap_changebit(spa, 0, ~TLB_UNCACHEABLE);
- }
- }
-
- return 0;
-}
-
-#if 0
-void
-flush_cache(tag, h, off, l, op)
- bus_space_tag_t tag;
- bus_space_handle_t h;
- bus_addr_t off;
- bus_size_t l;
- int op;
-{
- if (l) {
- register u_int32_t p = h + off;
-
- do {
- if (op == BUS_SPACE_BARRIER_READ)
- __asm __volatile ("pdc (%%sr0,%0)":: "r" (p));
- else
- __asm __volatile ("fdc (%%sr0,%0)":: "r" (p));
- __asm __volatile ("fic,m %2(%%sr0,%0)": "=r" (p)
- : "0" (p), "r" (dcache_stride));
- } while (p < (h + off + l));
- sync_caches();
- }
-}
-#endif
-
int waittime = -1;
void
@@ -1009,7 +705,7 @@ boot(howto)
int howto;
{
if (cold)
- howto |= RB_HALT;
+ /* XXX howto |= RB_HALT */;
else {
boothowto = howto | (boothowto & RB_HALT);
@@ -1041,14 +737,12 @@ boot(howto)
if (howto & RB_HALT) {
printf("System halted!\n");
__asm __volatile("stwas %0, 0(%1)"
- :: "r" (CMD_STOP),
- "r" (LBCAST_ADDR + iomod_command));
+ :: "r" (CMD_STOP), "r" (LBCAST_ADDR + iomod_command));
} else {
printf("rebooting...");
DELAY(1000000);
__asm __volatile("stwas %0, 0(%1)"
- :: "r" (CMD_RESET),
- "r" (LBCAST_ADDR + iomod_command));
+ :: "r" (CMD_RESET), "r" (LBCAST_ADDR + iomod_command));
}
for(;;); /* loop while bus reset is comming up */
@@ -1096,7 +790,7 @@ cpu_dump()
/* nothing for now */
return (bdevsw[major(dumpdev)].d_dump)
- (dumpdev, dumplo, (caddr_t)buf, dbtob(1));
+ (dumpdev, dumplo, (caddr_t)buf, dbtob(1));
}
/*
@@ -1148,7 +842,7 @@ dumpsys()
/* Limit size for next transfer. */
if (n > BYTES_PER_DUMP)
- n = BYTES_PER_DUMP;
+ n = BYTES_PER_DUMP;
if ((error = (*dump)(dumpdev, blkno, maddr, n)))
break;
@@ -1175,9 +869,9 @@ kcopy(from, to, size)
void *to;
size_t size;
{
- register void *oldh = curproc->p_addr->u_pcb.pcb_onfault;
+ register u_int oldh = curproc->p_addr->u_pcb.pcb_onfault;
- curproc->p_addr->u_pcb.pcb_onfault = &copy_on_fault;
+ curproc->p_addr->u_pcb.pcb_onfault = (u_int)&copy_on_fault;
bcopy(from, to, size);
curproc->p_addr->u_pcb.pcb_onfault = oldh;
@@ -1191,8 +885,7 @@ copystr(src, dst, size, lenp)
size_t size;
size_t *lenp;
{
- return spstrcpy(HPPA_SID_KERNEL, src,
- HPPA_SID_KERNEL, dst, size, lenp);
+ return spstrcpy(HPPA_SID_KERNEL, src, HPPA_SID_KERNEL, dst, size, lenp);
}
int
@@ -1203,7 +896,7 @@ copyinstr(src, dst, size, lenp)
size_t *lenp;
{
return spstrcpy(curproc->p_addr->u_pcb.pcb_space, src,
- HPPA_SID_KERNEL, dst, size, lenp);
+ HPPA_SID_KERNEL, dst, size, lenp);
}
@@ -1215,7 +908,7 @@ copyoutstr(src, dst, size, lenp)
size_t *lenp;
{
return spstrcpy(HPPA_SID_KERNEL, src,
- curproc->p_addr->u_pcb.pcb_space, dst, size, lenp);
+ curproc->p_addr->u_pcb.pcb_space, dst, size, lenp);
}
@@ -1226,7 +919,7 @@ copyin(src, dst, size)
size_t size;
{
return spcopy(curproc->p_addr->u_pcb.pcb_space, src,
- HPPA_SID_KERNEL, dst, size);
+ HPPA_SID_KERNEL, dst, size);
}
int
@@ -1236,7 +929,7 @@ copyout(src, dst, size)
size_t size;
{
return spcopy(HPPA_SID_KERNEL, src,
- curproc->p_addr->u_pcb.pcb_space, dst, size);
+ curproc->p_addr->u_pcb.pcb_space, dst, size);
}
/*
@@ -1250,16 +943,23 @@ setregs(p, pack, stack, retval)
register_t *retval;
{
register struct trapframe *tf;
-
+#ifdef DEBUG
+ /*extern int pmapdebug;*/
+ /*pmapdebug = 13;*/
+ printf("setregs(%p, %p, %x, %p), ep=%x\n",
+ p, pack, stack, retval, pack->ep_entry);
+#endif
/* FPU: setup regs */
tf = p->p_md.md_regs;
- /* tf->tf_r??? = PS_STRINGS */
+ /* tf->tf_r?? = PS_STRINGS */
tf->tf_ipsw = PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I;
- tf->tf_iioq_head = tf->tf_iioq_tail = pack->ep_entry;
+ tf->tf_iioq_head = tf->tf_iioq_tail =
+ pack->ep_entry | HPPA_PC_PRIV_USER;
tf->tf_iisq_head = tf->tf_iisq_tail = p->p_addr->u_pcb.pcb_space;
- tf->tf_sp = stack;
tf->tf_rp = 0;
+ tf->tf_arg0 = stack;
+ tf->tf_arg1 = tf->tf_arg2 = 0; /* XXX dynload stuff */
tf->tf_eiem = 0;
tf->tf_sr4 = p->p_addr->u_pcb.pcb_space;
tf->tf_sr5 = p->p_addr->u_pcb.pcb_space;
@@ -1270,6 +970,12 @@ setregs(p, pack, stack, retval)
tf->tf_pidr3 = p->p_vmspace->vm_map.pmap->pmap_pid;
tf->tf_pidr4 = p->p_vmspace->vm_map.pmap->pmap_pid;
+ /* setup terminal stack frame */
+ stack += HPPA_FRAME_SIZE;
+ copyout(&tf->tf_rp, (caddr_t)(stack + HPPA_FRAME_PSP),
+ sizeof(tf->tf_rp));
+ tf->tf_sp = stack;
+
retval[1] = 0;
}
@@ -1284,12 +990,20 @@ sendsig(catcher, sig, mask, code, type, val)
int type;
union sigval val;
{
+ struct proc *p = curproc;
+
+#ifdef DEBUG
+ if ((sigdebug | SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
+ printf("sendsig: %s[%d] sig %d catcher %p\n",
+ p->p_comm, p->p_pid, sig, catcher);
+#endif
+
/* TODO send signal */
}
int
sys_sigreturn(p, v, retval)
- struct proc *p;
+ struct proc *p;
void *v;
register_t *retval;
{
@@ -1313,15 +1027,15 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
dev_t consdev;
/* all sysctl names at this level are terminal */
if (namelen != 1)
- return (ENOTDIR); /* overloaded */
+ return (ENOTDIR); /* overloaded */
switch (name[0]) {
- case CPU_CONSDEV:
+ case CPU_CONSDEV:
if (cn_tab != NULL)
consdev = cn_tab->cn_dev;
else
consdev = NODEV;
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
- sizeof consdev));
+ sizeof consdev));
default:
return (EOPNOTSUPP);
}