gets past enablertclock(), now time to deal with the mountroot mess

This commit is contained in:
glass 1993-08-22 21:26:15 +00:00
parent dc22f15a6d
commit 6041363205
14 changed files with 183 additions and 87 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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.

View File

@ -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)

View File

@ -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()

View File

@ -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();

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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.