diff --git a/sys/arch/sun3/conf/TIMESINK b/sys/arch/sun3/conf/TIMESINK index bfbdb6870407..a519bc8d1937 100644 --- a/sys/arch/sun3/conf/TIMESINK +++ b/sys/arch/sun3/conf/TIMESINK @@ -19,7 +19,9 @@ options "TCP_COMPAT_42" options SWAPPAGER, VNODEPAGER, DEVPAGER options KTRACE options INET -config netbsd swap generic +options NFSSERVER +options NFSCLIENT +config netbsd swap nfs le0 at obio? addr ? level 3 #zs0 at obio? addr 0x00000 level 3 diff --git a/sys/arch/sun3/sun3/genassym.c b/sys/arch/sun3/sun3/genassym.c index 9e5358540e27..9697a0dfa2ac 100644 --- a/sys/arch/sun3/sun3/genassym.c +++ b/sys/arch/sun3/sun3/genassym.c @@ -68,6 +68,7 @@ main() printf("#define\tPSL_LOWIPL %d\n", PSL_LOWIPL); printf("#define\tPSL_HIGHIPL %d\n", PSL_HIGHIPL); printf("#define\tPSL_IPL7 %d\n", PSL_IPL7); + printf("#define\tPSL_USER %d\n", PSL_USER); printf("#define\tSPL1 %d\n", PSL_S | PSL_IPL1); printf("#define\tFC_CONTROL %d\n", FC_CONTROL); @@ -82,9 +83,10 @@ main() /* sun3 memory map */ printf("#define\tMAINMEM_MONMAP %d\n", MAINMEM_MONMAP); printf("#define\tMONSHORTSEG %d\n", MONSHORTSEG); + printf("#define\tUSRSTACK %d\n", USRSTACK); /* kernel-isms */ - printf("#define\tKERNBASE %d\n", KERNBASE); - printf("#define\tUPAGES %d\n", UPAGES); + printf("#define\tKERNBASE %d\n", KERNBASE); + printf("#define\tUPAGES %d\n", UPAGES); printf("#define\tUPAGE_ADDR %d\n", MONSHORTSEG); printf("#define\tKSTACK_ADDR %d\n", MONSHORTSEG); /* errno-isms */ diff --git a/sys/arch/sun3/sun3/interrupt.s b/sys/arch/sun3/sun3/interrupt.s index e82263c246f7..4c8794e0fd79 100644 --- a/sys/arch/sun3/sun3/interrupt.s +++ b/sys/arch/sun3/sun3/interrupt.s @@ -3,20 +3,22 @@ .data .globl _intrcnt _intrcnt: - /* 0 1 2 3 4 5 6 7, spurious */ - .long 0, 0, 0, 0, 0, 0, 0, 0, 0 + /* spurious 1 2 3 4 5 6 7*/ + .long 0, 0, 0, 0, 0, 0, 0, 0 .text #define INTERRUPT_HANDLE(interrupt_num) \ - addql #1,_intrcnt+interrupt_num ;\ + clrw sp@- ; /* ???? stack alignment?*/\ + moveml #0xC0C0,sp@- ; /* save a0 a1, d0, d1 */\ + addql #1,_intrcnt+interrupt_num ;/*increment interrupt counter */\ movw sr,sp@- ; /* push current SR value */\ clrw sp@- ; /* padded to longword */\ jbsr _intrhand ; /* handle interrupt */\ addql #4,sp ; /* pop SR */\ - moveml sp@+,#0x0303 ; \ - addql #2,sp ; \ - addql #1, _cnt+V_INTR ; \ + moveml sp@+,#0x0303 ; /* restore a0, a1, d0, d1*/\ + addql #2,sp ; /* undo stack alignment? hanck*/\ + addql #1, _cnt+V_INTR ; /* more statistics gathering */\ jra rei .globl _level0intr, _level1intr, _level2intr, _level3intr, _level4intr diff --git a/sys/arch/sun3/sun3/locore.s b/sys/arch/sun3/sun3/locore.s index efc51f8c6d5a..a5a52afaedd2 100644 --- a/sys/arch/sun3/sun3/locore.s +++ b/sys/arch/sun3/sun3/locore.s @@ -8,7 +8,8 @@ .data .space NBPG tmpstk: - +.set _kstack,MONSHORTSEG +.globl _kstack .text .globl start; .globl _start @@ -66,13 +67,35 @@ bsszero: clrl a0@ addql #4, a0 cmpl a0, a1 bne bsszero - movw #PSL_LOWIPL, sr | nothing blocked - movl #tmpstk, sp - jsr _sun3_bootstrap - movl #KSTACK_ADDR, a1 | proc0 kernel stack + +final_before_main: + + lea tmpstk, sp | switch to tmpstack + jsr _sun3_bootstrap | init everything but calling main() + lea _kstack, a1 | proc0 kernel stack lea a1@(UPAGES*NBPG-4),sp | set kernel stack to end of area + pea _kstack_fall_off | push something to fall back on :) + movl #USRSTACK-4, a2 + movl a2, usp | set user stack + movl _proc0paddr,a1 | get proc0 pcb addr + movl a1,_curpcb | proc0 is running + clrw a1@(PCB_FLAGS) | clear flags +#ifdef FPCOPROC + clrl a1@(PCB_FPCTX) | ensure null FP context + movl a1,sp@- + jbsr _m68881_restore | restore it (does not kill a1) + addql #4,sp +#endif + movw #PSL_LOWIPL, sr | nothing blocked jsr _main - rts |should never get here +/* proc[1] == init now running here; + * create a null exception frame and return to user mode in icode + */ +post_main: + clrw sp@- | vector offset/frame type + clrl sp@- | return to icode location 0 + movw #PSL_USER,sp@- | in user mode + rte |should get here :) .text /* * Icode is copied out to process 1 to exec init. diff --git a/sys/arch/sun3/sun3/locore2.c b/sys/arch/sun3/sun3/locore2.c index 3638b912072b..e820883cff3f 100644 --- a/sys/arch/sun3/sun3/locore2.c +++ b/sys/arch/sun3/sun3/locore2.c @@ -34,7 +34,7 @@ extern int physmem; unsigned char *interrupt_reg; unsigned int orig_nmi_vector; vm_offset_t u_area_va; -vm_offset_t u_area_pa; +vm_offset_t proc0_user_pa; struct user *proc0paddr; extern struct pcb *curpcb; @@ -125,6 +125,7 @@ void sun3_context_equiv() } void u_area_bootstrap(u_va, u_pa) + vm_offset_t u_va, u_pa; { vm_offset_t pte_proto, pa, va; @@ -133,6 +134,7 @@ void u_area_bootstrap(u_va, u_pa) for (va = u_va, pa = u_pa; va < u_va+NBPG*UPAGES; va+=NBPG, pa+=NBPG) set_pte(va, pte_proto|PA_PGNUM(pa)); } + void sun3_vm_init() { unsigned int monitor_memory = 0; @@ -301,22 +303,42 @@ void sun3_vm_init() set_segmap(va, SEGINV); va = sun3_round_up_seg(va); } - sun3_context_equiv(); /* My sincere apologies for this crud -- glass*/ - u_area_va = high_segment_alloc(UPAGES); + u_area_va = high_segment_alloc(UPAGES*2); if (u_area_va != MONSHORTSEG) /* pg 3,4,5 */ mon_printf("sun3_vm_init: not at right location for upage\n"); - avail_end -= UPAGES*NBPG; - u_area_pa = avail_end; - u_area_bootstrap(u_area_va, u_area_pa); - proc0paddr = (struct user *) u_area_va; - save_u_area(&proc0paddr->u_pcb, u_area_va); + avail_end -= UPAGES*NBPG; /* steal the UPAGES for proc0 u-area */ + proc0_user_pa = avail_end; /* UPAGES physical for proc0 u-area */ + + /* + * first UPAGES are used for u-area standard mapping + * second UPAGES are used for proc0's personal u-area, and will be mapped + * to real pages + * + * then the standard u-area will be loaded with proc0's u-area + */ + + proc0paddr = (struct user *) (u_area_va+UPAGES*NBPG);/* proc0's u-are va */ + /* need to load proc0paddr area with the physical pages stolen before */ + u_area_bootstrap((vm_offset_t) proc0paddr, proc0_user_pa); + bzero(proc0paddr, UPAGES*NBPG); + save_u_area(&proc0paddr->u_pcb, proc0paddr); + load_u_area(&proc0paddr->u_pcb); + pte = get_pte(proc0paddr); + mon_printf(" proc0paddr: \n"); + pte_print(pte); pte = get_pte(u_area_va); - printf(" u_area_pte: \n"); + mon_printf(" u_area_va: \n"); pte_print(pte); curpcb = &proc0paddr->u_pcb; - /* load_u_area(&proc0paddr->u_pcb);*/ + mon_printf("curpcb == %x\nproc0paddr == %x\n", curpcb, proc0paddr); + sun3_context_equiv(); +} + +void kstack_fall_off() +{ + mon_printf("kstack: fell off\n"); } void idprom_etheraddr(eaddrp) diff --git a/sys/arch/sun3/sun3/machdep.c b/sys/arch/sun3/sun3/machdep.c index 254975142884..0cf7ffbcc91e 100644 --- a/sys/arch/sun3/sun3/machdep.c +++ b/sys/arch/sun3/sun3/machdep.c @@ -41,7 +41,7 @@ extern char *cpu_string; int physmem; int cold; - +extern char kstack[]; /* * Declare these as initialized data so we can patch them. */ @@ -57,8 +57,6 @@ int bufpages = BUFPAGES; int bufpages = 0; #endif -char *kstack = (char *) MONSHORTSEG; - extern vm_offset_t u_area_va; void identifycpu() diff --git a/sys/arch/sun3/sun3/pmap.c b/sys/arch/sun3/sun3/pmap.c index f76626ca3ab0..283241da8e8d 100644 --- a/sys/arch/sun3/sun3/pmap.c +++ b/sys/arch/sun3/sun3/pmap.c @@ -1408,6 +1408,7 @@ void pmap_activate(pmap, pcbp) int s; PMAP_LOCK(); + printf("pmap_activate called\n"); if (pmap->pm_context) { set_context(pmap->pm_context->context_num); PMAP_UNLOCK(); diff --git a/sys/arch/sun3/sun3/process.s b/sys/arch/sun3/sun3/process.s index 6a6014944f25..2ee15674c063 100644 --- a/sys/arch/sun3/sun3/process.s +++ b/sys/arch/sun3/sun3/process.s @@ -133,6 +133,7 @@ Lbadsw: /* * Swtch() * + * Hacked for sun3 */ ENTRY(swtch) movl _curpcb,a0 | current pcb @@ -203,6 +204,7 @@ Lsw2: moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers movl usp,a2 | grab USP (a2 has been saved) movl a2,a1@(PCB_USP) | and save it +/* movl _CMAP2,a1@(PCB_CMAP2) | save temporary map PTE no-cmap shit*/ #ifdef FPCOPROC lea a1@(PCB_FPCTX),a2 | pointer to FP save area fsave a2@ | save FP state @@ -237,53 +239,17 @@ Lswnofpsave: addql #8,sp movl _curpcb,a1 | restore p_addr Lswnochg: -#if 0 -/* this stuff was ifdefed out because it can't work under our clock level - * configuration + it knows about the hp300 clock hardware - */ -#ifdef PROFTIMER -#ifdef notdef - movw #SPL6,sr | protect against clock interrupts -#endif - bclr #0,_profon | clear user profiling bit, was set? - jeq Lskipoff | no, clock off or doing kernel only -#ifdef GPROF - tstb _profon | kernel profiling also enabled? - jlt Lskipoff | yes, nothing more to do -#endif - CLKADDR(a0) - movb #0,a0@(CLKCR2) | no, just user, select CR3 - movb #0,a0@(CLKCR3) | and turn it off -Lskipoff: -#endif /* PROFTIMER */ -#endif /* if 0*/ - pea a1@ - jbsr _load_u_area - addql #8,sp - movl _curpcb,a1 | restore p_addr lea tmpstk,sp | now goto a tmp stack for NMI + pea a1@ | push essentially p_addr + jbsr _load_u_area | load_u_area(pcb_addr) + addql #4,sp | pop argument + movl _curpcb,a1 | restore p_addr (just in case + | load_u_area() trashes a1 + Lcxswdone: moveml a1@(PCB_REGS),#0xFCFC | and registers movl a1@(PCB_USP),a0 movl a0,usp | and USP -#if 0 -/* profiling support currently borken */ -#ifdef PROFTIMER - tstl a1@(U_PROFSCALE) | process being profiled? - jeq Lskipon | no, do nothing - orb #1,_profon | turn on user profiling bit -#ifdef GPROF - jlt Lskipon | already profiling kernel, all done -#endif - CLKADDR(a0) - movl _profint,d1 | profiling interval - subql #1,d1 | adjusted - movepw d1,a0@(CLKMSB3) | set interval - movb #0,a0@(CLKCR2) | select CR3 - movb #64,a0@(CLKCR3) | turn it on -Lskipon: -#endif /*proftimer*/ -#endif /* if 0 */ #ifdef FPCOPROC lea a1@(PCB_FPCTX),a0 | pointer to FP save area @@ -309,6 +275,7 @@ ENTRY(savectx) movl usp,a0 | grab USP movl a0,a1@(PCB_USP) | and save it moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers +/* movl _CMAP2,a1@(PCB_CMAP2) | save temporary map PTE*/ #ifdef FPCOPROC lea a1@(PCB_FPCTX),a0 | pointer to FP save area fsave a0@ | save FP state @@ -321,7 +288,7 @@ Lsvnofpsave: tstl sp@(8) | altreturn? jeq Lsavedone movl sp,d0 | relocate current sp relative to a1 - subl #KSTACK_ADDR,d0 | (sp is relative to kstack): + subl #_kstack,d0 | (sp is relative to kstack): addl d0,a1 | a1 += sp - kstack; movl sp@,a1@ | write return pc at (relocated) sp@ Lsavedone: diff --git a/sys/arch/sun3/sun3/softint.s b/sys/arch/sun3/sun3/softint.s index 89a9742cce64..a2df3f872ffc 100644 --- a/sys/arch/sun3/sun3/softint.s +++ b/sys/arch/sun3/sun3/softint.s @@ -1,3 +1,4 @@ +/* this code is un-altered from the hp300 code */ /* * Emulation of VAX REI instruction. * @@ -92,6 +93,7 @@ Lnosir: Ldorte: rte | real return +/* this code is un-altered from the hp300 version */ /* * Set processor priority level calls. Most are implemented with * inline asm expansions. However, spl0 requires special handling diff --git a/sys/arch/sun3/sun3/stub.c b/sys/arch/sun3/sun3/stub.c index 6d01b70d5ee3..62de27aa136c 100644 --- a/sys/arch/sun3/sun3/stub.c +++ b/sys/arch/sun3/sun3/stub.c @@ -1,10 +1,7 @@ -char *memcpy(char *from, char *to, unsigned int size) +char *memcpy(char *to, char *from, unsigned int size) { - bcopy(to, from, size); + bcopy(from, to, size); return to; } - -extern int ufs_mountroot(); -int (*mountroot)() = ufs_mountroot; diff --git a/sys/arch/sun3/sun3/sun3_startup.c b/sys/arch/sun3/sun3/sun3_startup.c index 3638b912072b..e820883cff3f 100644 --- a/sys/arch/sun3/sun3/sun3_startup.c +++ b/sys/arch/sun3/sun3/sun3_startup.c @@ -34,7 +34,7 @@ extern int physmem; unsigned char *interrupt_reg; unsigned int orig_nmi_vector; vm_offset_t u_area_va; -vm_offset_t u_area_pa; +vm_offset_t proc0_user_pa; struct user *proc0paddr; extern struct pcb *curpcb; @@ -125,6 +125,7 @@ void sun3_context_equiv() } void u_area_bootstrap(u_va, u_pa) + vm_offset_t u_va, u_pa; { vm_offset_t pte_proto, pa, va; @@ -133,6 +134,7 @@ void u_area_bootstrap(u_va, u_pa) for (va = u_va, pa = u_pa; va < u_va+NBPG*UPAGES; va+=NBPG, pa+=NBPG) set_pte(va, pte_proto|PA_PGNUM(pa)); } + void sun3_vm_init() { unsigned int monitor_memory = 0; @@ -301,22 +303,42 @@ void sun3_vm_init() set_segmap(va, SEGINV); va = sun3_round_up_seg(va); } - sun3_context_equiv(); /* My sincere apologies for this crud -- glass*/ - u_area_va = high_segment_alloc(UPAGES); + u_area_va = high_segment_alloc(UPAGES*2); if (u_area_va != MONSHORTSEG) /* pg 3,4,5 */ mon_printf("sun3_vm_init: not at right location for upage\n"); - avail_end -= UPAGES*NBPG; - u_area_pa = avail_end; - u_area_bootstrap(u_area_va, u_area_pa); - proc0paddr = (struct user *) u_area_va; - save_u_area(&proc0paddr->u_pcb, u_area_va); + avail_end -= UPAGES*NBPG; /* steal the UPAGES for proc0 u-area */ + proc0_user_pa = avail_end; /* UPAGES physical for proc0 u-area */ + + /* + * first UPAGES are used for u-area standard mapping + * second UPAGES are used for proc0's personal u-area, and will be mapped + * to real pages + * + * then the standard u-area will be loaded with proc0's u-area + */ + + proc0paddr = (struct user *) (u_area_va+UPAGES*NBPG);/* proc0's u-are va */ + /* need to load proc0paddr area with the physical pages stolen before */ + u_area_bootstrap((vm_offset_t) proc0paddr, proc0_user_pa); + bzero(proc0paddr, UPAGES*NBPG); + save_u_area(&proc0paddr->u_pcb, proc0paddr); + load_u_area(&proc0paddr->u_pcb); + pte = get_pte(proc0paddr); + mon_printf(" proc0paddr: \n"); + pte_print(pte); pte = get_pte(u_area_va); - printf(" u_area_pte: \n"); + mon_printf(" u_area_va: \n"); pte_print(pte); curpcb = &proc0paddr->u_pcb; - /* load_u_area(&proc0paddr->u_pcb);*/ + mon_printf("curpcb == %x\nproc0paddr == %x\n", curpcb, proc0paddr); + sun3_context_equiv(); +} + +void kstack_fall_off() +{ + mon_printf("kstack: fell off\n"); } void idprom_etheraddr(eaddrp) diff --git a/sys/arch/sun3/sun3/swapgeneric.c b/sys/arch/sun3/sun3/swapgeneric.c index 9050d9e7ae01..a229bfac9810 100644 --- a/sys/arch/sun3/sun3/swapgeneric.c +++ b/sys/arch/sun3/sun3/swapgeneric.c @@ -69,6 +69,62 @@ struct genericconf { setconf() { + register struct genericconf *gc; + register char *cp; + int unit, swaponroot = 0; + + if (rootdev != NODEV) + goto doswap; + unit = 0; + if (boothowto & RB_ASKNAME) { + char name[128]; +retry: + printf("root device? "); + gets(name); + for (gc = genericconf; gc->gc_driver; gc++) + if (gc->gc_name[0] == name[0] && + gc->gc_name[1] == name[1]) + goto gotit; + printf("use one of:"); + for (gc = genericconf; gc->gc_driver; gc++) + printf(" %s%%d", gc->gc_name); + printf("\n"); + goto retry; +gotit: + if (*++cp < '0' || *cp > '9') { + printf("bad/missing unit number\n"); + goto retry; + } + while (*cp >= '0' && *cp <= '9') + unit = 10 * unit + *cp++ - '0'; + if (*cp == '*') + swaponroot++; + goto found; + } + for (gc = genericconf; gc->gc_driver; gc++) { +#if 0 + for (hd = hp_dinit; hd->hp_driver; hd++) { + if (hd->hp_alive == 0) + continue; + if (hd->hp_unit == 0 && hd->hp_driver == + (struct driver *)gc->gc_driver) { + printf("root on %s0\n", hd->hp_driver->d_name); + goto found; + } + } +#endif + } + printf("no suitable root\n"); + sun3_stop(); +found: + gc->gc_root = makedev(major(gc->gc_root), unit*8); + rootdev = gc->gc_root; +doswap: + swdevt[0].sw_dev = argdev = dumpdev = + makedev(major(rootdev), minor(rootdev)+1); + /* swap size and dumplo set during autoconfigure */ + if (swaponroot) + rootdev = dumpdev; } gets(cp) diff --git a/sys/arch/sun3/sun3/trap.c b/sys/arch/sun3/sun3/trap.c index 54b8674e6fda..a8736c251b3b 100644 --- a/sys/arch/sun3/sun3/trap.c +++ b/sys/arch/sun3/sun3/trap.c @@ -430,6 +430,8 @@ out: p->p_stats->p_ru.ru_nivcsw++; swtch(); splx(s); + printf("trap: survived the switch\n"); + tracedump(); while (i = CURSIG(p)) psig(i); } diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index e3d0d3029040..c9d214d5cfb4 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -27,7 +27,7 @@ cpu_fork(p1, p2) register struct user *up = p2->p_addr; int offset; extern caddr_t getsp(); - extern char *kstack; + extern char kstack[]; /* * Copy pcb and stack from proc p1 to p2.