diff options
Diffstat (limited to 'sys/arch/sparc/sparc/machdep.c')
-rw-r--r-- | sys/arch/sparc/sparc/machdep.c | 161 |
1 files changed, 87 insertions, 74 deletions
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 9529ea31b0e..03dc4fc1a3b 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.45 1995/05/16 21:16:37 mycroft Exp $ */ +/* $NetBSD: machdep.c,v 1.64 1996/05/19 04:12:56 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -75,13 +75,16 @@ #include <sys/exec.h> #include <sys/sysctl.h> -#include <machine/bsd_openprom.h> +#include <vm/vm.h> +#include <vm/vm_kern.h> +#include <vm/vm_page.h> + #include <machine/autoconf.h> #include <machine/frame.h> #include <machine/cpu.h> - -#include <vm/vm_kern.h> -#include <vm/vm_page.h> +#include <machine/pmap.h> +#include <machine/oldmon.h> +#include <machine/bsd_openprom.h> #include <sparc/sparc/asm.h> #include <sparc/sparc/cache.h> @@ -109,7 +112,7 @@ int physmem; extern struct msgbuf msgbuf; struct msgbuf *msgbufp = &msgbuf; -int msgbufmapped = 0; /* maps late; so that printf works early */ +int msgbufmapped = 0; /* not mapped until pmap_bootstrap */ /* * safepri is a safe priority for sleep to set for a spin-wait @@ -125,7 +128,9 @@ vm_offset_t dvma_base, dvma_end; struct map *dvmamap; static int ndvmamap; /* # of entries in dvmamap */ -caddr_t allocsys(); +caddr_t allocsys __P((caddr_t)); +void dumpsys __P((void)); +void stackdump __P((void)); /* * Machine-dependent startup code @@ -166,8 +171,10 @@ cpu_startup() * and then give everything true virtual addresses. */ sz = (int)allocsys((caddr_t)0); + if ((v = (caddr_t)kmem_alloc(kernel_map, round_page(sz))) == 0) panic("startup: no room for tables"); + if (allocsys(v) - v != sz) panic("startup: table size inconsistency"); @@ -176,12 +183,15 @@ cpu_startup() * in that they usually occupy more virtual memory than physical. */ size = MAXBSIZE * nbuf; + buffer_map = kmem_suballoc(kernel_map, (vm_offset_t *)&buffers, &maxaddr, size, TRUE); + minaddr = (vm_offset_t)buffers; if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0, &minaddr, size, FALSE) != KERN_SUCCESS) panic("startup: cannot allocate buffers"); + base = bufpages / nbuf; residual = bufpages % nbuf; if (base >= MAXBSIZE) { @@ -189,6 +199,7 @@ cpu_startup() base = MAXBSIZE; residual = 0; } + for (i = 0; i < nbuf; i++) { vm_size_t curbufsize; vm_offset_t curbuf; @@ -211,23 +222,15 @@ cpu_startup() * limits the number of processes exec'ing at any time. */ exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - 16*NCARGS, TRUE); + 16*NCARGS, TRUE); /* * Allocate a map for physio. Others use a submap of the kernel * map, but we want one completely separate, even though it uses * the same pmap. */ -#if defined(SUN4M) && 0 - if (cputyp == CPU_SUN4M) { - dvma_base = DVMA4M_BASE; - dvma_end = (vm_offset_t)(0 - NBPG); /* want 4BG, but cant express */ - } else -#endif - { - dvma_base = DVMA_BASE; - dvma_end = DVMA_END; - } + dvma_base = CPU_ISSUN4M ? DVMA4M_BASE : DVMA_BASE; + dvma_end = CPU_ISSUN4M ? DVMA4M_END : DVMA_END; phys_map = vm_map_create(pmap_kernel(), dvma_base, dvma_end, 1); if (phys_map == NULL) panic("unable to create DVMA map"); @@ -261,7 +264,7 @@ cpu_startup() #ifdef DEBUG pmapdebug = opmapdebug; #endif - printf("avail mem = %d\n", ptoa(cnt.v_free_count)); + printf("avail mem = %ld\n", ptoa(cnt.v_free_count)); printf("using %d buffers containing %d bytes of memory\n", nbuf, bufpages * CLBYTES); @@ -280,7 +283,7 @@ cpu_startup() */ pmap_enter(pmap_kernel(), MSGBUF_VA, 0x0, VM_PROT_READ|VM_PROT_WRITE, 1); - if (cputyp == CPU_SUN4) + if (CPU_ISSUN4) msgbufp = (struct msgbuf *)(MSGBUF_VA + 4096); else msgbufp = (struct msgbuf *)MSGBUF_VA; @@ -320,7 +323,7 @@ allocsys(v) valloc(msghdrs, struct msg, msginfo.msgtql); valloc(msqids, struct msqid_ds, msginfo.msgmni); #endif - + /* * Determine how many buffers to allocate (enough to * hold 5% of total physical memory, but at least 16). @@ -386,9 +389,9 @@ setregs(p, pack, stack, retval) } bzero((caddr_t)tf, sizeof *tf); tf->tf_psr = psr; - tf->tf_pc = pack->ep_entry & ~3; + tf->tf_npc = pack->ep_entry & ~3; tf->tf_global[1] = (int)PS_STRINGS; - tf->tf_global[2] = tf->tf_global[7] = tf->tf_npc = tf->tf_pc+4; + tf->tf_global[2] = tf->tf_global[7] = tf->tf_npc; stack -= sizeof(struct rwindow); tf->tf_out[6] = stack; retval[1] = 0; @@ -417,6 +420,7 @@ struct sigframe { /* * machine dependent system variables. */ +int cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) int *name; u_int namelen; @@ -474,10 +478,10 @@ sendsig(catcher, sig, mask, code) #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig: %s[%d] sig %d newusp %x scp %x\n", + printf("sendsig: %s[%d] sig %d newusp %p scp %p\n", p->p_comm, p->p_pid, sig, fp, &fp->sf_sc); #endif - /* + /* * Now set up the signal frame. We build it in kernel space * and then copy it out. We probably ought to just build it * directly in user space.... @@ -527,7 +531,7 @@ sendsig(catcher, sig, mask, code) } #ifdef DEBUG if (sigdebug & SDB_FOLLOW) - printf("sendsig: %s[%d] sig %d scp %x\n", + printf("sendsig: %s[%d] sig %d scp %p\n", p->p_comm, p->p_pid, sig, &fp->sf_sc); #endif /* @@ -580,7 +584,7 @@ sys_sigreturn(p, v, retval) sigexit(p, SIGILL); #ifdef DEBUG if (sigdebug & SDB_FOLLOW) - printf("sigreturn: %s[%d], sigcntxp %x\n", + printf("sigreturn: %s[%d], sigcntxp %p\n", p->p_comm, p->p_pid, SCARG(uap, sigcntxp)); #endif scp = SCARG(uap, sigcntxp); @@ -617,9 +621,12 @@ boot(howto) { int i; static char str[4]; /* room for "-sd\0" */ - extern volatile void romhalt(void); - extern volatile void romboot(char *); - extern struct promvec *promvec; + extern int cold; + + if (cold) { + printf("halted\n\n"); + romhalt(); + } fb_unblank(); boothowto = howto; @@ -641,17 +648,15 @@ boot(howto) resettodr(); } (void) splhigh(); /* ??? */ - if (howto & RB_HALT) { + doshutdownhooks(); printf("halted\n\n"); -#if defined(SUN4M) || defined(SUN4C) - if (cputyp==CPU_SUN4M || cputyp==CPU_SUN4C) - *promvec->pv_synchook = NULL; -#endif romhalt(); } if (howto & RB_DUMP) dumpsys(); + + doshutdownhooks(); printf("rebooting\n\n"); i = 1; if (howto & RB_SINGLE) @@ -663,10 +668,6 @@ boot(howto) str[i] = 0; } else str[0] = 0; -#if defined(SUN4M) || defined(SUN4C) - if (cputyp==CPU_SUN4M || cputyp==CPU_SUN4C) - *promvec->pv_synchook = NULL; -#endif romboot(str); /*NOTREACHED*/ } @@ -675,6 +676,7 @@ u_long dumpmag = 0x8fca0101; /* magic number for savecore */ int dumpsize = 0; /* also for savecore */ long dumplo = 0; +void dumpconf() { register int nblks, nmem; @@ -729,6 +731,7 @@ reserve_dumppages(p) /* * Write a crash dump. */ +void dumpsys() { register int psize; @@ -755,7 +758,7 @@ dumpsys() dumpconf(); if (dumplo < 0) return; - printf("\ndumping to dev %x, offset %d\n", dumpdev, dumplo); + printf("\ndumping to dev %x, offset %ld\n", dumpdev, dumplo); psize = (*bdevsw[major(dumpdev)].d_psize)(dumpdev); printf("dump "); @@ -767,10 +770,17 @@ dumpsys() dump = bdevsw[major(dumpdev)].d_dump; for (mp = pmemarr, nmem = npmemarr; --nmem >= 0; mp++) { - register unsigned i, n; + register unsigned i = 0, n; register maddr = mp->addr; - for (i = 0; i < mp->len; i += n) { + if (maddr == 0) { + /* Skip first page at physical address 0 */ + maddr += NBPG; + i += NBPG; + blkno += btodb(NBPG); + } + + for (; i < mp->len; i += n) { n = mp->len - i; if (n > BYTES_PER_DUMP) n = BYTES_PER_DUMP; @@ -825,15 +835,16 @@ dumpsys() * get the fp and dump the stack as best we can. don't leave the * current stack page */ +void stackdump() { - struct frame *fp = (struct frame *)getfp(), *sfp; + struct frame *fp = getfp(), *sfp; sfp = fp; - printf("Frame pointer is at 0x%x\n", fp); + printf("Frame pointer is at %p\n", fp); printf("Call traceback:\n"); while (fp && ((u_long)fp >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { - printf(" pc = %x args = (%x, %x, %x, %x, %x, %x) fp = %x\n", + printf(" pc = %x args = (%x, %x, %x, %x, %x, %x, %x) fp = %p\n", fp->fr_pc, fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6], fp->fr_fp); @@ -846,28 +857,28 @@ int bt2pmt[] = { PMAP_OBIO, PMAP_VME16, PMAP_VME32, - PMAP_OBIO, PMAP_OBIO }; /* * Map an I/O device given physical address and size in bytes, e.g., * - * mydev = (struct mydev *)mapdev(myioaddr, 0, 0, - * sizeof(struct mydev), pmtype); - * + * mydev = (struct mydev *)mapdev(myioaddr, 0, + * 0, sizeof(struct mydev), pmtype); + * * See also machine/autoconf.h. */ void * -mapdev(rr, virt, offset, size, bustype) - register struct rom_reg *rr; +mapdev(phys, virt, offset, size, bustype) + register struct rom_reg *phys; register int offset, virt, size; register int bustype; { - register vm_offset_t v, pa; + register vm_offset_t v; + register vm_offset_t pa; register void *ret; static vm_offset_t iobase; - int pmtype; + unsigned int pmtype; if (iobase == NULL) iobase = IODEV_BASE; @@ -883,19 +894,17 @@ mapdev(rr, virt, offset, size, bustype) if (iobase > IODEV_END) /* unlikely */ panic("mapiodev"); } - ret = (void *)(v | (((u_long)rr->rr_paddr + offset) & PGOFSET)); + ret = (void *)(v | (((u_long)phys->rr_paddr + offset) & PGOFSET)); /* note: preserve page offset */ - pa = trunc_page(rr->rr_paddr + offset); -#ifdef notyet - pmtype = (cputyp == CPU_SUN4M) - ? (rr->rr_iospace << PMAP_SHFT4M) + + pa = trunc_page(phys->rr_paddr + offset); + pmtype = (CPU_ISSUN4M) + ? (phys->rr_iospace << PMAP_SHFT4M) : bt2pmt[bustype]; -#else - pmtype = bt2pmt[bustype]; -#endif + do { pmap_enter(pmap_kernel(), v, pa | pmtype | PMAP_NC, - VM_PROT_READ | VM_PROT_WRITE, 1); + VM_PROT_READ | VM_PROT_WRITE, 1); v += PAGE_SIZE; pa += PAGE_SIZE; } while ((size -= PAGE_SIZE) > 0); @@ -923,12 +932,10 @@ oldmon_w_trace(va) u_long va; { u_long stop; - extern u_long *par_err_reg; - volatile u_long *memreg = (u_long *) par_err_reg; struct frame *fp; if (curproc) - printf("curproc = %x, pid %d\n", curproc, curproc->p_pid); + printf("curproc = %p, pid %d\n", curproc, curproc->p_pid); else printf("no curproc\n"); @@ -939,19 +946,19 @@ oldmon_w_trace(va) #define round_up(x) (( (x) + (NBPG-1) ) & (~(NBPG-1)) ) - printf("\nstack trace with sp = %x\n", va); + printf("\nstack trace with sp = %lx\n", va); stop = round_up(va); - printf("stop at %x\n", stop); + printf("stop at %lx\n", stop); fp = (struct frame *) va; while (round_up((u_long) fp) == stop) { - printf(" %x(%x, %x, %x, %x, %x, %x) fp %x\n", fp->fr_pc, - fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], + printf(" %x(%x, %x, %x, %x, %x, %x, %x) fp %p\n", fp->fr_pc, + fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6], fp->fr_fp); fp = fp->fr_fp; if (fp == NULL) break; } - printf("end of stack trace\n"); + printf("end of stack trace\n"); } void @@ -968,7 +975,7 @@ oldmon_w_cmd(va, ar) printf("w: case 4\n"); break; default: - printf("w: unknown case %d\n", va); + printf("w: unknown case %ld\n", va); break; } break; @@ -981,15 +988,21 @@ oldmon_w_cmd(va, ar) } #endif /* SUN4 */ -u_int +int ldcontrolb(addr) caddr_t addr; { struct pcb *xpcb; extern struct user *proc0paddr; - u_long saveonfault, res; + u_long saveonfault; + int res; int s; + if (CPU_ISSUN4M) { + printf("warning: ldcontrolb called in sun4m\n"); + return 0; + } + s = splhigh(); if (curproc == NULL) xpcb = (struct pcb *)proc0paddr; @@ -997,7 +1010,7 @@ caddr_t addr; xpcb = &curproc->p_addr->u_pcb; saveonfault = (u_long)xpcb->pcb_onfault; - res = xldcontrolb(addr, xpcb); + res = xldcontrolb(addr, xpcb); xpcb->pcb_onfault = (caddr_t)saveonfault; splx(s); |