diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2002-04-27 01:52:14 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2002-04-27 01:52:14 +0000 |
commit | 1d8c583bfbd54da9b80bed64cb21bd377c44dd13 (patch) | |
tree | a7e9b7b385ebc87f39407ab32baf4c406eaa13dc /sys/arch/mac68k | |
parent | 39ef332c31acac15b7bf742185a421ca104b5882 (diff) |
Lots of cleanup to catch up with other m68k-based ports and modern code,
including:
- use netisr_dispatch
- extract an allocsys() function from cpu_startup()
- updated cachectl()
- a few fixes in trap()
and more...
Diffstat (limited to 'sys/arch/mac68k')
-rw-r--r-- | sys/arch/mac68k/include/cpu.h | 23 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/machdep.c | 386 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/pmap_bootstrap.c | 19 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/sys_machdep.c | 98 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/trap.c | 63 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/vm_machdep.c | 79 |
6 files changed, 332 insertions, 336 deletions
diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h index 7507469a61b..a884cc13c27 100644 --- a/sys/arch/mac68k/include/cpu.h +++ b/sys/arch/mac68k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.25 2002/04/16 20:54:16 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.26 2002/04/27 01:52:10 miod Exp $ */ /* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */ /* @@ -304,16 +304,25 @@ u_int get_mapping(void); /* locore.s */ void m68881_restore(struct fpframe *); void m68881_save(struct fpframe *); +void DCIA(void); +void DCIS(void); +void DCIU(void); +void ICIA(void); +void ICPA(void); +void PCIA(void); void TBIA(void); void TBIAS(void); void TBIAU(void); void TBIS(vm_offset_t); -void DCFP(vm_offset_t); -void ICPP(vm_offset_t); -void DCIU(void); -void DCIS(void); -void ICIA(void); -void DCFL(vm_offset_t); +#if defined(M68040) +void DCFA(void); +void DCFP(paddr_t); +void DCFL(paddr_t); +void DCPL(paddr_t); +void DCPP(paddr_t); +void ICPL(paddr_t); +void ICPP(paddr_t); +#endif int suline(caddr_t, caddr_t); void savectx(struct pcb *); void proc_trampoline(void); diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index 4dc03b9d762..8108df138ac 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.98 2002/04/16 15:32:59 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.99 2002/04/27 01:52:13 miod Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -141,7 +141,7 @@ void netintr(void); #include "ether.h" /* The following is used externally (sysctl_hw) */ -char machine[] = "mac68k"; /* cpu "architecture" */ +char machine[] = MACHINE; /* from <machine/param.h> */ struct mac68k_machine_S mac68k_machine; @@ -227,16 +227,17 @@ unsigned short mac68k_statclockipl = PSL_S | PSL_IPL2; * The extent maps are not static! Machine-dependent NuBus and on-board * I/O routines need access to them for bus address space allocation. */ -static long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)]; +long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)]; struct extent *iomem_ex; int iomem_malloc_safe; /* XXX should be in locore.s for consistency */ int astpending = 0; -static void identifycpu(void); -static u_long get_physical(u_int, u_long *); +void identifycpu(void); +u_long get_physical(u_int, u_long *); +caddr_t allocsys(caddr_t); void initcpu(void); int cpu_dumpsize(void); int cpu_dump(int (*)(dev_t, daddr_t, caddr_t, size_t), daddr_t *); @@ -323,7 +324,7 @@ consinit(void) void cpu_startup(void) { - caddr_t v, firstaddr; + caddr_t v; unsigned i; int vers; int base, residual; @@ -341,10 +342,9 @@ cpu_startup(void) * high[numranges-1] was decremented in pmap_bootstrap. */ for (i = 0; i < btoc(MSGBUFSIZE); i++) - pmap_enter(pmap_kernel(), (vm_offset_t)msgbufp, + pmap_enter(pmap_kernel(), (vaddr_t)msgbufp + i * NBPG, high[numranges - 1] + i * NBPG, - VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED); + VM_PROT_ALL, VM_PROT_ALL|PMAP_WIRED); pmap_update(pmap_kernel()); initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE)); @@ -367,84 +367,16 @@ cpu_startup(void) printf("this kernel.\n\n"); for (delay = 0; delay < 1000000; delay++); } - printf("real mem = %d\n", ctob(physmem)); + printf("real mem = %u (%uK)\n", ctob(physmem), ctob(physmem)/1024); /* - * Allocate space for system data structures. - * The first available real memory address is in "firstaddr". - * The first available kernel virtual address is in "v". - * As pages of kernel virtual memory are allocated, "v" is incremented. - * As pages of memory are allocated and cleared, - * "firstaddr" is incremented. - * An index into the kernel page table corresponding to the - * virtual memory address maintained in "v" is kept in "mapaddr". + * Find out how much space we need, allocate it, + * and then give everything true virtual addressses. */ - /* - * Make two passes. The first pass calculates how much memory is - * needed and allocates it. The second pass assigns virtual - * addresses to the various data structures. - */ - firstaddr = 0; -again: - v = (caddr_t)firstaddr; - -#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 SYSVSHM - shminfo.shmmax = shmmaxpgs; - shminfo.shmall = shmmaxpgs; - shminfo.shmseg = shmseg; - 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. - * Use 10% of memory for the first 2 Meg, 5% of the remaining - * memory. Insure a minimum of 16 buffers. - * We allocate 3/4 as many swap buffer headers as file i/o buffers. - */ - if (bufpages == 0) { - if (physmem < btoc(2 * 1024 * 1024)) - bufpages = physmem / 10; - else - bufpages = (btoc(2 * 1024 * 1024) + physmem) / 20; - } - - if (nbuf == 0) { - nbuf = bufpages; - if (nbuf < 16) - nbuf = 16; - } - - valloc(buf, struct buf, nbuf); - - /* - * End of first pass, size has been calculated so allocate memory - */ - if (firstaddr == 0) { - size = (vm_size_t)(v - firstaddr); - firstaddr = (caddr_t)uvm_km_alloc(kernel_map, round_page(size)); - if (firstaddr == 0) - panic("startup: no room for tables"); - goto again; - } - /* - * End of second pass, addresses have been assigned - */ - if ((vm_size_t)(v - firstaddr) != size) + size = (vsize_t)allocsys((caddr_t)0); + if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0) + panic("startup: no room for tables"); + if ((allocsys(v) - v) != size) panic("startup: table size inconsistency"); /* @@ -452,16 +384,16 @@ again: * in that they usually occupy more virtual memory than physical. */ size = MAXBSIZE * nbuf; - if (uvm_map(kernel_map, (vm_offset_t *) &buffers, round_page(size), + if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size), NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0))) panic("startup: cannot allocate VM for buffers"); - minaddr = (vm_offset_t)buffers; + minaddr = (vaddr_t)buffers; base = bufpages / nbuf; residual = bufpages % nbuf; for (i = 0; i < nbuf; i++) { - vm_size_t curbufsize; - vm_offset_t curbuf; + vsize_t curbufsize; + vaddr_t curbuf; struct vm_page *pg; /* @@ -470,7 +402,7 @@ again: * for the first "residual" buffers, and then we allocate * "base" pages for the rest. */ - curbuf = (vm_offset_t) buffers + (i * MAXBSIZE); + curbuf = (vaddr_t) buffers + (i * MAXBSIZE); curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base); while (curbufsize) { @@ -485,6 +417,7 @@ again: } pmap_update(pmap_kernel()); } + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. @@ -498,9 +431,10 @@ again: phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, FALSE, NULL); - printf("avail mem = %ld\n", ptoa(uvmexp.free)); - printf("using %d buffers containing %d bytes of memory\n", - nbuf, bufpages * PAGE_SIZE); + printf("avail mem = %lu (%uK)\n", ptoa(uvmexp.free), + ptoa(uvmexp.free)/1024); + printf("using %d buffers containing %u bytes (%uK) of memory\n", + nbuf, bufpages * PAGE_SIZE, bufpages * PAGE_SIZE / 1024); /* * Set up CPU-specific registers, cache, etc. @@ -525,6 +459,64 @@ again: iomem_malloc_safe = 1; } +/* + * 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 then call + * allocsys() again with the correct base virtual address. + */ +caddr_t +allocsys(v) + caddr_t 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 SYSVSHM + shminfo.shmmax = shmmaxpgs; + shminfo.shmall = shmmaxpgs; + shminfo.shmseg = shmseg; + 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. + * Use 10% of memory for the first 2 Meg, then 5% of the remaining + * memory. Insure a minimum of 16 buffers. + */ + if (bufpages == 0) { + if (physmem < btoc(2 * 1024 * 1024)) + bufpages = physmem / 10; + else + bufpages = (btoc(2 * 1024 * 1024) + physmem) / 20; + } + + if (nbuf == 0) { + nbuf = bufpages; + if (nbuf < 16) + nbuf = 16; + } + valloc(buf, struct buf, nbuf); + return (v); +} + void initcpu() { @@ -569,7 +561,7 @@ void via_shutdown(void); */ void setregs(p, pack, stack, retval) - register struct proc *p; + struct proc *p; struct exec_package *pack; u_long stack; register_t *retval; @@ -619,17 +611,16 @@ setregs(p, pack, stack, retval) } int waittime = -1; -struct pcb dumppcb; void boot(howto) - register int howto; + int howto; { extern u_long maxaddr; /* take a snap shot before clobbering any registers */ - if (curproc) - savectx((struct pcb *)curproc->p_addr); + if (curproc && curproc->p_addr) + savectx(&curproc->p_addr->u_pcb); /* If system is cold, just halt. */ if (cold) { @@ -639,34 +630,25 @@ boot(howto) boothowto = howto; if ((howto & RB_NOSYNC) == 0 && waittime < 0) { - extern struct proc proc0; - /* kill the panic on that boot away */ - if (curproc == NULL) - curproc = &proc0; - waittime = 0; - - /* - * Release inodes, sync and unmount the filesystems. - */ vfs_shutdown(); -#ifdef notyet /* * If we've been adjusting the clock, the todr * will be out of synch; adjust it now unless * the system was sitting in ddb. */ if ((howto & RB_TIMEBAD) == 0) { +#ifdef notyet resettodr(); +#else +#ifdef DIAGNOSTIC + printf("OpenBSD/mac68k does not trust itself to update the clock on shutdown.\n"); +#endif +#endif } else { printf("WARNING: not updating battery clock\n"); } -#else -# ifdef DIAGNOSTIC - printf("OpenBSD/mac68k does not trust itself to update the clock on shutdown.\n"); -# endif -#endif } /* Disable interrupts. */ @@ -674,7 +656,6 @@ boot(howto) /* If rebooting and a dump is requested, do it. */ if (howto & RB_DUMP) { - savectx(&dumppcb); /* XXX this goes away soon */ dumpsys(); } @@ -703,7 +684,7 @@ haltsys: } /* Map the last physical page VA = PA for doboot() */ - pmap_enter(pmap_kernel(), (vm_offset_t)maxaddr, (vm_offset_t)maxaddr, + pmap_enter(pmap_kernel(), (vaddr_t)maxaddr, (vaddr_t)maxaddr, VM_PROT_ALL, VM_PROT_ALL|PMAP_WIRED); pmap_update(pmap_kernel()); @@ -795,42 +776,35 @@ void dumpconf() { cpu_kcore_hdr_t *h = &cpu_kcore_hdr; - int chdrsize; /* size of dump header */ int nblks; /* size of dump area */ int maj; int i; if (dumpdev == NODEV) return; - maj = major(dumpdev); if (maj < 0 || maj >= nblkdev) panic("dumpconf: bad dumpdev=0x%x", dumpdev); - if (bdevsw[maj].d_psize == NULL) { - printf ("dumpconf: returning for d_psize\n"); + if (bdevsw[maj].d_psize == NULL) return; - } nblks = (*bdevsw[maj].d_psize)(dumpdev); - chdrsize = cpu_dumpsize(); + if (nblks <= ctod(1)) + return; dumpsize = 0; for (i = 0; h->ram_segs[i].size && i < NPHYS_RAM_SEGS; i++) dumpsize += btoc(h->ram_segs[i].size); + dumpsize += cpu_dumpsize(); - /* - * Check to see if we will fit. Note we always skip the - * first block in case there is a disk label there. - */ - if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) { - dumpsize = 0; - dumplo = -1; - return; - } + /* Always skip the first block, in case there is a label there. */ + if (dumplo < ctod(1)) + dumplo = ctod(1); - /* - * Put dump at the end of the partition. - */ - dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize; + /* Put dump at end of partition, and make it fit. */ + if (dumpsize < dtoc(nblks - dumplo)) + dumpsize = dtoc(nblks - dumplo); + if (dumplo < nblks - ctod(dumpsize)) + dumplo = nblks - ctod(dumpsize); } void @@ -841,7 +815,7 @@ dumpsys() /* dump routine */ int (*dump)(dev_t, daddr_t, caddr_t, size_t); int pg; /* page being dumped */ - vm_offset_t maddr; /* PA being dumped */ + vaddr_t maddr; /* PA being dumped */ int seg; /* RAM segment being dumped */ int error; /* error code from (*dump)() */ extern int msgbufmapped; @@ -895,12 +869,12 @@ dumpsys() } maddr = h->ram_segs[seg].start; } - pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr, + pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr, VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); pmap_update(pmap_kernel()); error = (*dump)(dumpdev, blkno, vmmap, NBPG); - bad: +bad: switch (error) { case 0: maddr += NBPG; @@ -968,8 +942,6 @@ microtime(tvp) splx(s); } -void straytrap(int, int); - void straytrap(pc, evec) int pc; @@ -977,9 +949,11 @@ straytrap(pc, evec) { printf("unexpected trap; vector offset 0x%x from 0x%x.\n", (int) (evec & 0xfff), pc); +#ifdef DEBUG #ifdef DDB Debugger(); #endif +#endif } int *nofault; @@ -988,9 +962,9 @@ int badaddr(caddr_t); int badaddr(addr) - register caddr_t addr; + caddr_t addr; { - register int i; + int i; label_t faultbuf; nofault = (int *)&faultbuf; @@ -1005,16 +979,11 @@ badaddr(addr) int badbaddr(addr) - register caddr_t addr; + caddr_t addr; { - register int i; + int i; label_t faultbuf; -#ifdef lint - i = *addr; - if (i) - return (0); -#endif nofault = (int *)&faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *)0; @@ -1027,16 +996,11 @@ badbaddr(addr) int badwaddr(addr) - register caddr_t addr; + caddr_t addr; { - register int i; + int i; label_t faultbuf; -#ifdef lint - i = *addr; - if (i) - return (0); -#endif nofault = (int *)&faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *)0; @@ -1049,16 +1013,11 @@ badwaddr(addr) int badladdr(addr) - register caddr_t addr; + caddr_t addr; { - register int i; + int i; label_t faultbuf; -#ifdef lint - i = *addr; - if (i) - return (0); -#endif nofault = (int *)&faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *)0; @@ -1072,56 +1031,15 @@ badladdr(addr) void netintr() { -#ifdef INET -#if NETHER - if (netisr & (1 << NETISR_ARP)) { - netisr &= ~(1 << NETISR_ARP); - arpintr(); - } -#endif - if (netisr & (1 << NETISR_IP)) { - netisr &= ~(1 << NETISR_IP); - ipintr(); - } -#endif -#ifdef INET6 - if (netisr & (1 << NETISR_IPV6)) { - netisr &= ~(1 << NETISR_IPV6); - ip6intr(); - } -#endif -#ifdef NETATALK - if (netisr & (1 << NETISR_ATALK)) { - netisr &= ~(1 << NETISR_ATALK); - atintr(); - } -#endif -#ifdef NS - if (netisr & (1 << NETISR_NS)) { - netisr &= ~(1 << NETISR_NS); - nsintr(); - } -#endif -#ifdef ISO - if (netisr & (1 << NETISR_ISO)) { - netisr &= ~(1 << NETISR_ISO); - clnlintr(); - } -#endif -#include "ppp.h" -#if NPPP > 0 - if (netisr & (1 << NETISR_PPP)) { - netisr &= ~(1 << NETISR_PPP); - pppintr(); - } -#endif -#include "bridge.h" -#if NBRIDGE > 0 - if (netisr & (1 << NETISR_BRIDGE)) { - netisr &= ~(1 << NETISR_BRIDGE); - bridgeintr(); - } -#endif +#define DONETISR(bit, fn) \ + do { \ + if (netisr & (1 << (bit))) { \ + netisr &= ~(1 << (bit)); \ + (fn)(); \ + } \ + } while (0) +#include <net/netisr_dispatch.h> +#undef DONETISR } /* @@ -1135,10 +1053,10 @@ nmihand(frame) { static int nmihanddeep = 0; - if (nmihanddeep++) + if (nmihanddeep) return; -/* regdump(&(frame.F_t), 128); - dumptrace(); */ + nmihanddeep = 1; + #ifdef DIAGNOSTIC printf("Panic switch: PC is 0x%x.\n", frame.f_pc); #endif @@ -1146,6 +1064,7 @@ nmihand(frame) if (db_console) Debugger(); #endif + nmihanddeep = 0; } @@ -1225,8 +1144,8 @@ static char *envbuf = NULL; /* * getenvvars: Grab a few useful variables */ -void getenvvars(u_long, char *); -static long getenv(char *); +void getenvvars(u_long, char *); +long getenv(char *); void getenvvars(flag, buf) @@ -1302,11 +1221,13 @@ getenvvars(flag, buf) /* * Get end of symbols for kernel debugging */ +#if defined(DDB) || NKSYMS > 0 esym = getenv("END_SYM"); #ifndef SYMTAB_SPACE if (esym == 0) #endif esym = (long) &end; +#endif /* Get MacOS time */ macos_boottime = getenv("BOOTTIME"); @@ -1332,9 +1253,9 @@ getenvvars(flag, buf) mrg_ADBIntrPtr = (caddr_t)getenv("ADBINTERRUPT"); } -static char toupper(char); +char toupper(char); -static char +char toupper(c) char c; { @@ -1345,7 +1266,7 @@ toupper(c) } } -static long +long getenv(str) char *str; { @@ -1470,7 +1391,7 @@ getenv(str) * * Bob Nestor - <rnestor@metronet.com> */ -static romvec_t romvecs[] = +romvec_t romvecs[] = { /* Vectors verified for II, IIx, IIcx, SE/30 */ { /* 0 */ @@ -2059,7 +1980,6 @@ static romvec_t romvecs[] = /* Please fill these in! -BG */ }; - struct cpu_model_info cpu_models[] = { /* The first four. */ @@ -2343,9 +2263,9 @@ identifycpu() #endif } -static void get_machine_info(void); +void get_machine_info(void); -static void +void get_machine_info() { int i; @@ -2629,7 +2549,7 @@ mac68k_set_io_offsets(base) } #if GRAYBARS -static u_long gray_nextaddr = 0; +u_long gray_nextaddr = 0; void gray_bar() @@ -2678,7 +2598,7 @@ extern int get_pte(u_int addr, u_long pte[2], u_short * psr); * to look through MacOS page tables. */ -static u_long +u_long get_physical(u_int addr, u_long * phys) { u_long pte[2], ph, mask; @@ -2734,9 +2654,9 @@ get_physical(u_int addr, u_long * phys) return 1; } -static void check_video(char *, u_long, u_long); +void check_video(char *, u_long, u_long); -static void +void check_video(id, limit, maxm) char *id; u_long limit, maxm; @@ -2765,9 +2685,11 @@ check_video(id, limit, maxm) mac68k_vidlen += 32768; addr += 32768; } +#ifdef DIAGNOSTIC printf(" %s internal video at addr 0x%x (phys 0x%x), ", id, mac68k_vidlog, mac68k_vidphys); printf("len 0x%x.\n", mac68k_vidlen); +#endif } } @@ -2802,7 +2724,7 @@ get_mapping(void) high[numranges - 1] = phys + NBPG; } } -#if 1 +#ifdef DIAGNOSTIC printf("System RAM: %ld bytes in %ld pages.\n", addr, addr / NBPG); for (i = 0; i < numranges; i++) { printf(" Low = 0x%lx, high = 0x%lx\n", low[i], high[i]); @@ -2815,8 +2737,10 @@ get_mapping(void) * setmachdep() (by using intvid_info[]). Tell the user * what we know. */ +#ifdef DIAGNOSTIC printf("On-board video at addr 0x%x (phys 0x%x), len 0x%x.\n", mac68k_vidlog, mac68k_vidphys, mac68k_vidlen); +#endif } else { /* * We should now look through all of NuBus space to find where @@ -2911,7 +2835,9 @@ get_mapping(void) 21888, 21888); } else if (0x60000000 <= videoaddr && videoaddr < 0x70000000) { +#ifdef DIAGNOSTIC printf("Checking for Internal Video "); +#endif /* * Kludge for IIvx internal video (60b0 0000). * PB 520 (6000 0000) @@ -2933,15 +2859,19 @@ get_mapping(void) check_video("AV video (0x50100100)", 1 * 1024 * 1024, 1 * 1024 * 1024); } else { +#ifdef DIAGNOSTIC printf( " no internal video at address 0 -- " "videoaddr is 0x%lx.\n", videoaddr); +#endif } } else { +#ifdef DIAGNOSTIC printf(" Video address = 0x%lx\n", videoaddr); printf(" Int video starts at 0x%x\n", mac68k_vidlog); printf(" Length = 0x%x (%d) bytes\n", mac68k_vidlen, mac68k_vidlen); +#endif } } diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c index 0f8b35dc862..7fa50d88db2 100644 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.22 2002/04/16 20:54:47 miod Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.23 2002/04/27 01:52:13 miod Exp $ */ /* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */ /* @@ -242,19 +242,6 @@ bootstrap_mac68k(tc) } nextpa = load_addr + round_page((vaddr_t)esym); -#if MFS - if (boothowto & RB_MINIROOT) { - int v; - boothowto |= RB_DFLTROOT; - nextpa = round_page(nextpa); - if ((v = mfs_initminiroot((caddr_t) nextpa-load_addr)) == 0) { - printf("Error loading miniroot.\n"); - } - printf("Loaded %d byte miniroot.\n", v); - nextpa += v; - } -#endif - if (mac68k_machine.do_graybars) printf("Bootstrapping the pmap system.\n"); @@ -302,9 +289,9 @@ pmap_init_md() * Mark as unavailable the regions which we have mapped in * pmap_bootstrap(). */ - addr = (vaddr_t)IOBase; + addr = (vaddr_t)MACHINE_INTIOBASE; if (uvm_map(kernel_map, &addr, - m68k_ptob(IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE), + m68k_ptob(MACHINE_IIOMAPSIZE), NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_RANDOM, diff --git a/sys/arch/mac68k/mac68k/sys_machdep.c b/sys/arch/mac68k/mac68k/sys_machdep.c index 486f01fef6c..27952d4543f 100644 --- a/sys/arch/mac68k/mac68k/sys_machdep.c +++ b/sys/arch/mac68k/mac68k/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.6 2002/03/14 01:26:36 millert Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.7 2002/04/27 01:52:13 miod Exp $ */ /* $NetBSD: sys_machdep.c,v 1.9 1996/05/05 06:18:58 briggs Exp $ */ /* @@ -83,6 +83,8 @@ #include <sys/buf.h> #include <sys/mount.h> +#include <uvm/uvm_extern.h> + #include <sys/syscallargs.h> #include <machine/cpu.h> @@ -94,19 +96,98 @@ #define CC_EXTPURGE 0x80000000 /* XXX end should be */ -int cachectl(int, caddr_t, int); -void DCIU(void); -void ICIA(void); +int cachectl(int, vaddr_t, int); /*ARGSUSED1*/ int cachectl(req, addr, len) int req; - caddr_t addr; + vaddr_t addr; int len; { int error = 0; +#if defined(M68040) + if (mmutype == MMU_68040) { + int inc = 0; + int doall = 0; + paddr_t pa = 0; + vaddr_t end = 0; + + if (addr == 0 || + ((req & ~CC_EXTPURGE) != CC_PURGE && len > 2*NBPG)) + doall = 1; + + if (!doall) { + end = addr + len; + if (len <= 1024) { + addr = addr & ~0xF; + inc = 16; + } else { + addr = addr & ~PGOFSET; + inc = NBPG; + } + } + do { + /* + * Convert to physical address if needed. + * If translation fails, we perform operation on + * entire cache (XXX is this a rational thing to do?) + */ + if (!doall && + (pa == 0 || ((int)addr & PGOFSET) == 0)) { + if (pmap_extract( + curproc->p_vmspace->vm_map.pmap, + addr, &pa) == FALSE) + doall = 1; + } + switch (req) { + case CC_EXTPURGE|CC_IPURGE: + case CC_IPURGE: + if (doall) { + DCFA(); + ICPA(); + } else if (inc == 16) { + DCFL(pa); + ICPL(pa); + } else if (inc == NBPG) { + DCFP(pa); + ICPP(pa); + } + break; + + case CC_EXTPURGE|CC_PURGE: + case CC_PURGE: + if (doall) + DCFA(); /* note: flush not purge */ + else if (inc == 16) + DCPL(pa); + else if (inc == NBPG) + DCPP(pa); + break; + + case CC_EXTPURGE|CC_FLUSH: + case CC_FLUSH: + if (doall) + DCFA(); + else if (inc == 16) + DCFL(pa); + else if (inc == NBPG) + DCFP(pa); + break; + + default: + error = EINVAL; + break; + } + if (doall) + break; + pa += inc; + addr += inc; + } while (addr < end); + return(error); + } +#endif switch (req) { case CC_EXTPURGE|CC_PURGE: case CC_EXTPURGE|CC_FLUSH: @@ -127,13 +208,14 @@ cachectl(req, addr, len) return(error); } -int sys_sysarch(p, v, retval) +int +sys_sysarch(p, v, retval) struct proc *p; void *v; register_t *retval; { -#if 0 - struct sysarch_args /* { +#if 0 /* unused */ + struct sys_sysarch_args /* { syscallarg(int) op; syscallarg(char *) parms; } */ *uap = v; diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 87709b31667..ce27b71adf7 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.35 2002/03/14 01:26:36 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.36 2002/04/27 01:52:13 miod Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -237,9 +237,6 @@ trap(type, code, v, frame) struct frame frame; { extern char fubail[], subail[]; -#ifdef DDB - extern char trap0[], trap1[], trap2[], trap12[], trap15[], illinst[]; -#endif struct proc *p; int i, s; u_int ucode; @@ -251,13 +248,6 @@ trap(type, code, v, frame) p = curproc; ucode = 0; - if (USERMODE(frame.f_sr)) { - type |= T_USER; - sticks = p->p_sticks; - p->p_md.md_regs = frame.f_regs; - } else - sticks = 0; - /* I have verified that this DOES happen! -gwr */ if (p == NULL) p = &proc0; @@ -267,9 +257,16 @@ trap(type, code, v, frame) type, code, v); #endif + if (USERMODE(frame.f_sr)) { + type |= T_USER; + sticks = p->p_sticks; + p->p_md.md_regs = frame.f_regs; + } else + sticks = 0; + switch (type) { default: - dopanic: +dopanic: printf("trap type %d, code = 0x%x, v = 0x%x\n", type, code, v); printf("%s program counter = 0x%x\n", (type & T_USER) ? "user" : "kernel", frame.f_pc); @@ -288,7 +285,7 @@ trap(type, code, v, frame) (void)kdb_trap(type, (db_regs_t *)&frame); #endif #ifdef KGDB - kgdb_cont; +kgdb_cont: #endif splx(s); if (panicstr) { @@ -355,7 +352,9 @@ copyfault: case T_CHKINST|T_USER: /* CHK instruction trap */ ucode = frame.f_format; + type = FPE_FLTSUB; i = SIGFPE; + v = frame.f_pc; break; case T_TRAPVINST|T_USER: /* TRAPV instruction trap */ @@ -461,27 +460,11 @@ copyfault: * XXX: We should never get kernel-mode T_TRACE or T_TRAP15 * XXX: because locore.s now gives them special treatment. */ - case T_TRACE: /* Kernel trace trap */ - case T_TRAP15: /* SUN trace trap */ -#ifdef DDB - if (type == T_TRAP15 || - ((caddr_t) frame.f_pc != trap0 && - (caddr_t) frame.f_pc != trap1 && - (caddr_t) frame.f_pc != trap2 && - (caddr_t) frame.f_pc != trap12 && - (caddr_t) frame.f_pc != trap15 && - (caddr_t) frame.f_pc != illinst)) { - if (kdb_trap(type, (db_regs_t *) &frame)) - return; - } -#endif + case T_TRAP15: /* kernel breakpoint */ frame.f_sr &= ~PSL_T; - i = SIGTRAP; - typ = TRAP_TRACE; - break; + return; case T_TRACE|T_USER: /* user trace trap */ - case T_TRAP15|T_USER: /* Sun user trace trap */ #ifdef COMPAT_SUNOS /* * SunOS uses Trap #2 for a "CPU cache flush" @@ -495,6 +478,9 @@ copyfault: return; } #endif + /* FALLTHROUGH */ + case T_TRACE: /* Kernel trace trap */ + case T_TRAP15|T_USER: /* Sun user trace trap */ frame.f_sr &= ~PSL_T; i = SIGTRAP; typ = TRAP_TRACE; @@ -514,7 +500,7 @@ copyfault: * IPL while processing the SIR. */ spl1(); - /* fall into... */ + /* FALLTHROUGH */ case T_SSIR: /* Software interrupt */ case T_SSIR|T_USER: @@ -656,10 +642,8 @@ copyfault: break; } } - if (i) { - sv.sival_ptr = (void *)v; - trapsignal(p, i, ucode, typ, sv); - } + sv.sival_ptr = (void *)v; + trapsignal(p, i, ucode, typ, sv); if ((type & T_USER) == 0) return; out: @@ -684,7 +668,7 @@ char wberrstr[] = "WARNING: pid %d(%s) writeback [%s] failed, pc=%x fa=%x wba=%x wbd=%x\n"; #endif -static int +int writeback(fp, docachepush) struct frame *fp; int docachepush; @@ -925,7 +909,7 @@ writeback(fp, docachepush) } #ifdef DEBUG -static void +void dumpssw(ssw) u_short ssw; { @@ -952,7 +936,6 @@ dumpssw(ssw) f7tm[ssw & SSW4_TMMASK]); } -static void dumpwb(num, s, a, d) int num; @@ -1100,7 +1083,7 @@ syscall(code, frame) /* nothing to do */ break; default: - bad: +bad: if (p->p_emul->e_errno) error = p->p_emul->e_errno[error]; frame.f_regs[D0] = error; diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c index 0fe63089041..a3e95079f8a 100644 --- a/sys/arch/mac68k/mac68k/vm_machdep.c +++ b/sys/arch/mac68k/mac68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.29 2002/03/14 01:26:36 millert Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.30 2002/04/27 01:52:13 miod Exp $ */ /* $NetBSD: vm_machdep.c,v 1.29 1998/07/28 18:34:55 thorpej Exp $ */ /* @@ -88,17 +88,22 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) p2->p_md.md_flags = p1->p_md.md_flags; - /* Sync curpcb (which is presumably p1's PCB) and copy it to p2. */ - savectx(curpcb); + /* Copy pcb from proc p1 to p2. */ + if (p1 == curproc) { + /* Sync the PCB before we copy it. */ + savectx(curpcb); + } +#ifdef DIAGNOSTIC + else if (p1 != &proc0) + panic("cpu_fork: curproc"); +#endif *pcb = p1->p_addr->u_pcb; /* - * Copy the trap frame and arrange for the child to return directly - * through return_to_user(). + * Copy the trap frame. */ tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) -1; p2->p_md.md_regs = (int *)tf; - *tf = *(struct trapframe *)p1->p_md.md_regs; /* @@ -109,7 +114,6 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) sf = (struct switchframe *)tf - 1; sf->sf_pc = (u_int)proc_trampoline; - pcb->pcb_regs[6] = (int)func; /* A2 */ pcb->pcb_regs[7] = (int)arg; /* A3 */ pcb->pcb_regs[11] = (int)sf; /* SSP */ @@ -124,7 +128,7 @@ void switch_exit(struct proc *); * free our stack and user area and switch to another process. * Thus, we never return. */ -volatile void +void cpu_exit(p) struct proc *p; { @@ -132,7 +136,6 @@ cpu_exit(p) (void)splhigh(); uvmexp.swtch++; switch_exit(p); - for(;;); /* Get rid of a compile warning */ /* NOTREACHED */ } @@ -204,11 +207,11 @@ cpu_coredump(p, vp, cred, chdr) error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p); + if (error) + return error; - if (!error) - chdr->c_nseg++; - - return error; + chdr->c_nseg++; + return 0; } /* @@ -221,24 +224,23 @@ pagemove(from, to, size) caddr_t from, to; size_t size; { - vm_offset_t pa; + paddr_t pa; + boolean_t rv; #ifdef DEBUG - if (size % PAGE_SIZE) + if ((size & PAGE_MASK) != 0) panic("pagemove"); #endif while (size > 0) { - pmap_extract(pmap_kernel(), (vm_offset_t) from, &pa); + rv = pmap_extract(pmap_kernel(), (vaddr_t)from, &pa); #ifdef DEBUG -#if 0 - if (pa == 0) + if (rv == FALSE) panic("pagemove 2"); - if (pmap_extract(pmap_kernel(), (vm_offset_t)to, XXX) != 0) + if (pmap_extract(pmap_kernel(), (vaddr_t)to, NULL) == TRUE) panic("pagemove 3"); #endif -#endif pmap_kremove((vaddr_t)from, PAGE_SIZE); - pmap_kenter_pa((vaddr_t)to, pa, VM_PROT_READ|VM_PROT_WRITE); + pmap_kenter_pa((vaddr_t)to, pa, VM_PROT_READ | VM_PROT_WRITE); from += PAGE_SIZE; to += PAGE_SIZE; size -= PAGE_SIZE; @@ -292,7 +294,7 @@ kvtop(addr) { paddr_t pa; - if (pmap_extract(pmap_kernel(), (vm_offset_t)addr, &pa) == FALSE) + if (pmap_extract(pmap_kernel(), (vaddr_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); return((int)pa); } @@ -308,19 +310,21 @@ kvtop(addr) void vmapbuf(bp, len) struct buf *bp; - vm_size_t len; + vsize_t len; { struct pmap *upmap, *kpmap; - vm_offset_t uva; /* User VA (map from) */ - vm_offset_t kva; /* Kernel VA (new to) */ - vm_offset_t pa; /* physical address */ - vm_size_t off; + vaddr_t uva; /* User VA (map from) */ + vaddr_t kva; /* Kernel VA (new to) */ + vaddr_t pa; /* physical address */ + vsize_t off; +#ifdef DIAGNOSTIC if ((bp->b_flags & B_PHYS) == 0) panic("vmapbuf"); +#endif uva = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data)); - off = (vm_offset_t)bp->b_data - uva; + off = (vaddr_t)bp->b_data - uva; len = round_page(off + len); kva = uvm_km_valloc_wait(phys_map, len); bp->b_data = (caddr_t)(kva + off); @@ -330,7 +334,8 @@ vmapbuf(bp, len) do { if (pmap_extract(upmap, uva, &pa) == FALSE) panic("vmapbuf: null page frame"); - pmap_enter(kpmap, kva, pa, VM_PROT_READ|VM_PROT_WRITE, PMAP_WIRED); + pmap_enter(kpmap, kva, pa, VM_PROT_READ|VM_PROT_WRITE, + PMAP_WIRED); uva += PAGE_SIZE; kva += PAGE_SIZE; len -= PAGE_SIZE; @@ -344,22 +349,22 @@ vmapbuf(bp, len) void vunmapbuf(bp, len) struct buf *bp; - vm_size_t len; + vsize_t len; { - vm_offset_t kva; - vm_size_t off; + vaddr_t kva; + vsize_t off; +#ifdef DIAGNOSTIC if ((bp->b_flags & B_PHYS) == 0) panic("vunmapbuf"); +#endif kva = trunc_page((vaddr_t)bp->b_data); - off = (vm_offset_t)bp->b_data - kva; + off = (vaddr_t)bp->b_data - kva; len = round_page(off + len); - /* - * pmap_remove() is unnecessary here, as kmem_free_wakeup() - * will do it for us. - */ + pmap_remove(vm_map_pmap(phys_map), kva, kva + len); + pmap_update(pmap_kernel()); uvm_km_free_wakeup(phys_map, kva, len); bp->b_data = bp->b_saveaddr; bp->b_saveaddr = 0; |