From 0ea653bb395fbec68c63ab2bcb9047c739da8387 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 11 Jul 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-07-11 --- gnot/main.c | 2 +- pc/clock.c | 6 +- pc/dat.h | 42 ++++++++---- pc/fault386.c | 1 + pc/fns.h | 10 ++- pc/kbd.c | 8 --- pc/l.s | 31 ++++++--- pc/main.c | 170 +++++++++++++++++++++++++++++++++++++++++++++--- pc/mem.h | 6 +- pc/mmu.c | 28 ++++++++ pc/segment.h | 20 ++++++ pc/trap.c | 20 ++---- port/malloc.c | 2 +- port/qlock.c | 2 + power/dat.h | 2 +- power/l.s | 19 ++++-- power/main.c | 2 +- power/mem.h | 2 +- power/trap.c | 4 +- ss/clock.c | 7 +- ss/faultsparc.c | 1 + ss/main.c | 4 +- ss/trap.c | 27 ++++++-- 23 files changed, 329 insertions(+), 87 deletions(-) create mode 100644 pc/segment.h diff --git a/gnot/main.c b/gnot/main.c index 9223daace9709c20bff1726bb73a14f0b48a90e2..d4ecb0897ead2a0cb8e0fec99e25a80fe31cd864 100644 --- a/gnot/main.c +++ b/gnot/main.c @@ -158,7 +158,7 @@ userinit(void) * Kernel Stack */ p->sched.pc = (ulong)init0; - p->sched.sp = USERADDR+BY2PG-20; /* BUG */ + p->sched.sp = USERADDR+BY2PG-MAXSYSARG*BY2WD; p->sched.sr = SUPER|SPL(0); p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); diff --git a/pc/clock.c b/pc/clock.c index 769e8bfdb4402c2b70eeb0220aa04d2602927458..5c9f44d7386ebbf4d5cd906d057e73ca20a7fee8 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -43,12 +43,14 @@ void clock(Ureg *ur) { Proc *p; - static int last; m->ticks++; + + checkalarms(); + p = m->proc; if(p){ - p->pc = ur->eip; + p->pc = ur->pc; if (p->state==Running) p->time[p->insyscall]++; } diff --git a/pc/dat.h b/pc/dat.h index 0f37468082dbcca06142088a20f269457238f811..93b5a1d1e08caceca680902a2ba66e3e57508d8a 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -31,9 +31,21 @@ struct Label ulong pc; }; -struct FPsave + +/* + * FPsave.fpstatus + */ +enum +{ + FPinit, + FPactive, + FPinactive, +}; + +struct FPsave /* ??? needs to be fixed ??? */ { - int type; + long fpreg[32]; + long fpstatus; }; struct Conf @@ -41,14 +53,13 @@ struct Conf ulong nmach; /* processors */ ulong nproc; /* processes */ ulong npgrp; /* process groups */ - ulong npage0; /* total physical pages of memory, bank 0 */ - ulong npage1; /* total physical pages of memory, bank 1 */ - ulong base0; /* base of bank 0 */ - ulong base1; /* base of bank 1 */ + ulong npage0; /* total physical pages in bank0 */ + ulong npage1; /* total physical pages in bank1 */ ulong npage; /* total physical pages of memory */ - ulong norig; /* origins */ - ulong npte; /* contiguous page table entries */ - ulong nmod; /* single (modifying) page table entries */ + ulong nseg; /* number of segments */ + ulong nimage; /* number of page cache image headers */ + ulong npagetab; /* number of pte tables */ + ulong nswap; /* number of swap pages */ ulong nalarm; /* alarms */ ulong nchan; /* channels */ ulong nenv; /* distinct environment values */ @@ -66,16 +77,19 @@ struct Conf ulong nbitmap; /* bitmap structs (devbit.c) */ ulong nbitbyte; /* bytes of bitmap data (devbit.c) */ ulong nfont; /* font structs (devbit.c) */ + ulong nnoifc; /* number of nonet interfaces */ + ulong nnoconv; /* number of nonet conversations/ifc */ ulong nurp; /* max urp conversations */ ulong nasync; /* number of async protocol modules */ ulong npipe; /* number of pipes */ - ulong nservice; /* number of services */ - ulong nfsyschan; /* number of filsys open channels */ ulong maxialloc; /* maximum bytes used by ialloc */ + ulong base0; /* base of bank 0 */ + ulong base1; /* base of bank 1 */ ulong copymode; /* 0 is copy on write, 1 is copy on reference */ - ulong portispaged; /* ??? */ - ulong nnoifc; - ulong nnoconv; + ulong ipif; /* Ip protocol interfaces */ + ulong ip; /* Ip conversations per interface */ + ulong arp; /* Arp table size */ + ulong frag; /* Ip fragment assemble queue size */ ulong cntrlp; /* panic on ^P */ }; diff --git a/pc/fault386.c b/pc/fault386.c index b49235fc44d21be9f35e89d015b2360bd7a331af..457f2ab54d87ed380b9631368b323d099dbb1a42 100644 --- a/pc/fault386.c +++ b/pc/fault386.c @@ -4,6 +4,7 @@ #include "dat.h" #include "fns.h" #include "ureg.h" +#include "io.h" void faultinit(void) diff --git a/pc/fns.h b/pc/fns.h index 5cdd80268d5d9182e083b513f85e434a5510ea6d..21240c916857999ddc9424ce25c0f7cc41cf4ff8 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -1,13 +1,15 @@ #include "../port/portfns.h" +#define clearmmucache() /* 386 doesn't have one */ void clock(Ureg*); void clockinit(void); void delay(int); +#define evenaddr(x) /* 386 doesn't care */ void fault386(Ureg*); void floppyinit(void); void floppyintr(Ureg*); -void floppystart(int); -void floppystop(int); +long floppyseek(int, ulong); +#define flushvirt(); void idle(void); int inb(int); void intr0(void); @@ -43,11 +45,15 @@ void lidt(Segdesc*, int); void mmuinit(void); void outb(int, int); void prhex(ulong); +#define procrestore(x,y) +#define procsave(x,y) +#define procsetup(p) ((p)->fpstate = FPinit) void screeninit(void); void screenputc(int); void screenputs(char*, int); void setvec(int, void (*)(Ureg*), int); void systrap(void); +void touser(void); void trapinit(void); int tas(Lock*); #define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1])) diff --git a/pc/kbd.c b/pc/kbd.c index 85577ec00050b256ceab5a9efb4bdcbbf0f0e04a..71f5b2e5e10a12814df2258e8e28d19693988d2d 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -241,14 +241,6 @@ kbdinit(void) setvec(Kbdvec, kbdintr, SEGIG); } -int -kbdputc(IOQ* q, int c) -{ - if(c==0x10) - panic("^p"); - putc(q, c); -} - /* * keyboard interrupt */ diff --git a/pc/l.s b/pc/l.s index b7065e0cfa42a9acac63e4220f4ed8ebdd68c498..dafa995ab8d7bfa63da021aadfb79c62922d46ef 100644 --- a/pc/l.s +++ b/pc/l.s @@ -103,33 +103,43 @@ TEXT mode32bit(SB),$0 /* * make a bottom level page table page that maps the first - * 4 meg of physical memory + * 16 meg of physical memory */ LEAL tpt-KZERO(SB),AX /* get phys addr of temporary page table */ ADDL $(BY2PG-1),AX /* must be page alligned */ ANDL $(~(BY2PG-1)),AX /* ... */ - MOVL $1024,CX /* pte's per page */ - MOVL $(((1024-1)<<12)|PTEVALID|PTEKERNEL|PTEWRITE),BX + MOVL $(4*1024),CX /* pte's per page */ + MOVL $((((4*1024)-1)<>22)&(BY2PG-1))(AX) + MOVL BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+0)(AX) + ADDL $BY2PG,BX + MOVL BX,4(AX) + MOVL BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+4)(AX) + ADDL $BY2PG,BX + MOVL BX,8(AX) + MOVL BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+8)(AX) + ADDL $BY2PG,BX + MOVL BX,12(AX) + MOVL BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+12)(AX) /* * point processor to top level page & turn on paging */ MOVL AX,CR3 MOVL CR0,AX - ORL $1,AX + ORL $0X80000000,AX MOVL AX,CR0 /* @@ -149,7 +159,7 @@ loop: GLOBL mach0+0(SB), $MACHSIZE GLOBL u(SB), $4 GLOBL m(SB), $4 -GLOBL tpt(SB), $(BY2PG*3) +GLOBL tpt(SB), $(BY2PG*6) /* * gdt to get us to 32-bit/segmented/unpaged mode @@ -407,3 +417,6 @@ TEXT setlabel(SB),$0 MOVL 0(SP),BX /* store return pc */ MOVL BX,4(AX) RET + +TEXT touser(SB),$0 + RET diff --git a/pc/main.c b/pc/main.c index fbdff93b3b3aadb49fe9e4fe098016515e6d06c9..48549a6fcf69032cb9161369307ebb5d491d9e7c 100644 --- a/pc/main.c +++ b/pc/main.c @@ -5,29 +5,54 @@ #include "fns.h" #include "io.h" + +char sysname[NAMELEN]; +Conf conf; +char user[NAMELEN] = "bootes"; + +extern ulong edata; + main(void) { + int i; + + machinit(); + confinit(); screeninit(); + print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1); + print("edata == %lux, end == %lux\n", &edata, &end); trapinit(); + mmuinit(); + clockinit(); + alarminit(); kbdinit(); clockinit(); - mmuinit(); floppyinit(); spllo(); - floppystart(0); - for(;;){ + + for(i=0; i<100; i++){ int c; c = getc(&kbdq); if(c!=-1) screenputc(c); idle(); - if((TK2SEC(m->ticks)%5)==0) - if((TK2SEC(m->ticks)%10)==0) - floppystop(0); - else - floppystart(0); + floppyseek(0, 0); + floppyseek(0, 18*512*20); } + for(;;); +} + +void +machinit(void) +{ + int n; + + n = m->machno; + memset(m, 0, sizeof(Mach)); + m->machno = n; + m->mmask = 1<machno; + active.machs = 1; } void @@ -36,11 +61,95 @@ delay(int l) int i; while(--l){ - for(i=0; i < 100; i++) + for(i=0; i < 404; i++) ; } } +void +confinit(void) +{ + long x, i, j, *l; + int mul; + + /* + * size memory + */ + x = 0x12345678; + for(i=1; i<16; i++){ + /* + * write the word + */ + l = (long*)(KZERO|(i*1024L*1024L)); + *l = x; + /* + * take care of wraps + */ + for(j = 0; j < i; j++){ + l = (long*)(KZERO|(j*1024L*1024L)); + *l = 0; + } + /* + * check + */ + l = (long*)(KZERO|(i*1024L*1024L)); + if(*l != x) + break; + x += 0x3141526; + } + + /* + * the first 640k is the standard useful memory + */ + conf.npage0 = 640/4; + conf.base0 = 0; + + /* + * the last 128k belongs to the roms + */ + conf.npage1 = (i)*1024/4; + conf.base1 = 1024/4; + + conf.npage = conf.npage0 + conf.npage1; + conf.maxialloc = (640*1024-256*1024-BY2PG); + + mul = 1; + conf.nproc = 20 + 50*mul; + conf.npgrp = conf.nproc/2; + conf.nseg = conf.nproc*3; + conf.npagetab = (conf.nseg*14)/10; + conf.nswap = conf.nproc*80; + conf.nimage = 50; + conf.nalarm = 1000; + conf.nchan = 4*conf.nproc; + conf.nenv = 4*conf.nproc; + conf.nenvchar = 8000*mul; + conf.npgenv = 200*mul; + conf.nmtab = 50*mul; + conf.nmount = 80*mul; + conf.nmntdev = 15*mul; + conf.nmntbuf = conf.nmntdev+3; + conf.nmnthdr = 2*conf.nmntdev; + conf.nsrv = 16*mul; /* was 32 */ + conf.nbitmap = 512*mul; + conf.nbitbyte = conf.nbitmap*1024*screenbits(); + conf.nfont = 10*mul; + conf.nnoifc = 1; + conf.nnoconv = 32; + conf.nurp = 32; + conf.nasync = 1; + conf.nstream = (conf.nproc*3)/2; + conf.nqueue = 5 * conf.nstream; + conf.nblock = 24 * conf.nstream; + conf.npipe = conf.nstream/2; + conf.copymode = 0; /* copy on write */ + conf.ipif = 8; + conf.ip = 64; + conf.arp = 32; + conf.frag = 32; + conf.cntrlp = 0; +} + int sprint(char *s, char *fmt, ...) { @@ -73,7 +182,50 @@ panic(char *fmt, ...) idle(); } +int +kbdputc(IOQ* q, int c) +{ + if(c==0x10) + panic("^p"); + putc(q, c); +} + +struct Palloc palloc; + +void* +ialloc(ulong n, int align) +{ + ulong p; + + if(palloc.active && n!=0) + print("ialloc bad\n"); + if(palloc.addr == 0) + palloc.addr = ((ulong)&end)&~KZERO; + if(align) + palloc.addr = PGROUND(palloc.addr); + + memset((void*)(palloc.addr|KZERO), 0, n); + p = palloc.addr; + palloc.addr += n; + if(align) + palloc.addr = PGROUND(palloc.addr); + + if(palloc.addr >= conf.maxialloc) + panic("keep bill joy away"); + + return (void*)(p|KZERO); +} + void sched(void) +{ } + +void +ready(Proc*p) +{ } + +int +postnote(Proc*p, int x, char* y, int z) { + panic("postnote"); } diff --git a/pc/mem.h b/pc/mem.h index e34d89d65b601e5023c1b760c680f8eddb0d8ca4..994c4993c3a6294a035b2b9b71a7487af7810083 100644 --- a/pc/mem.h +++ b/pc/mem.h @@ -10,7 +10,7 @@ #define BY2WD 4 /* bytes per word */ #define BY2PG 4096 /* bytes per page */ #define WD2PG (BY2PG/BY2WD) /* words per page */ -#define PGSHIFT 13 /* log(BY2PG) */ +#define PGSHIFT 12 /* log(BY2PG) */ #define PGROUND(s) (((s)+(BY2PG-1))&~(BY2PG-1)) #define MAXMACH 1 /* max # cpus system can run */ @@ -47,7 +47,7 @@ #define MACHSIZE 4096 -#define isphys(x) ((x)&KZERO) +#define isphys(x) (((ulong)x)&KZERO) /* * known 80386 segments (in GDT) and their selectors @@ -101,11 +101,11 @@ #define PTEMAPMEM (1024*1024) /* ??? */ #define SEGMAPSIZE 16 /* ??? */ #define PTEPERTAB (PTEMAPMEM/BY2PG) /* ??? */ +#define PPN(x) ((x)&~(BY2PG-1)) /* * physical MMU */ -#define PPN(x) ((x)&~(BY2PG-1)) #define PTEVALID (1<<0) #define PTEUNCACHED 0 /* everything is uncached */ #define PTEWRITE (1<<1) diff --git a/pc/mmu.c b/pc/mmu.c index 0f43875fadaea1d45a535c60546009943a86647b..46860b961e84a64752bf9718c20441c0f3c1f0f4 100644 --- a/pc/mmu.c +++ b/pc/mmu.c @@ -67,14 +67,42 @@ Segdesc gdt[] = [RESEG] E16SEG(0), /* reboot code */ }; +extern ulong tpt[]; + void mmuinit(void) { + gdt[SYSGATE].d0 = ((ulong)systrap)&0xFFFF|(KESEL<<16); gdt[SYSGATE].d1 = ((ulong)systrap)&0xFFFF0000|SEGP|SEGPL(3)|SEGCG; lgdt(gdt, sizeof gdt); } +void +mapstack(Proc *p) +{ +} + +void +flushmmu(void) +{ +} + +void +mmurelease(Proc *p) +{ +} + +void +putmmu(ulong x, ulong y, Page*z) +{ +} + +void +invalidateu(void) +{ +} + void systrap(void) { diff --git a/pc/segment.h b/pc/segment.h new file mode 100644 index 0000000000000000000000000000000000000000..09583003a19e98469bbee8ab55e4700cb0d6cbe9 --- /dev/null +++ b/pc/segment.h @@ -0,0 +1,20 @@ +/* + * Attach segment types + */ + +typedef struct Physseg Physseg; +struct Physseg +{ + ulong attr; /* Segment attributes */ + char *name; /* Attach name */ + ulong pa; /* Physical address */ + ulong size; /* Maximum segment size in pages */ + Page *(*pgalloc)(ulong); /* Allocation if we need it */ + void (*pgfree)(Page*); +}physseg[] = { + { SG_SHARED, "lock", 0, SEGMAXSIZE, &snewpage, &putpage }, + { SG_SHARED, "shared", 0, SEGMAXSIZE, &snewpage, &putpage }, + { SG_PHYSICAL, "kmem", KZERO, SEGMAXSIZE, 0, 0 }, + { SG_BSS, "memory", 0, SEGMAXSIZE, &snewpage, &putpage }, + { 0, 0, 0, 0, 0, 0 }, +}; diff --git a/pc/trap.c b/pc/trap.c index 13eabd4ef5b3bcd9c1d390789558ca54c0bf70df..1df80c7ec88ec7ada6a3b9446bc6bc6e548503fd 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -124,7 +124,7 @@ void trap(Ureg *ur) { if(ur->trap>=256 || ivec[ur->trap] == 0) - panic("bad trap type %d\n", ur->trap); + panic("bad trap type %d %lux\n", ur->trap, ur->pc); /* * call the trap routine @@ -147,25 +147,13 @@ syscall(Ureg *ur) panic("syscall"); } -#include "errstr.h" - -void -error(int code) -{ - strncpy(u->error, errstrtab[code], ERRLEN); - nexterror(); -} - void -errors(char *err) +dumpstack(void) { - strncpy(u->error, err, ERRLEN); - nexterror(); } - void -nexterror(void) +execpc(ulong entry) { - gotolabel(&u->errlab[--u->nerrlab]); + ((Ureg*)UREGADDR)->pc = entry; } diff --git a/port/malloc.c b/port/malloc.c index fb601c6d388d8e7f67afac47f66777312a1d1b93..71b0bd9f9a2502616df5324262904257b7ff33fb 100644 --- a/port/malloc.c +++ b/port/malloc.c @@ -423,7 +423,7 @@ cached(Store *p) void *calloc(ulong n, ulong size){ void *p; - size *= n; + size = size*n; p = malloc(size); memset(p, 0, size); return p; diff --git a/port/qlock.c b/port/qlock.c index ed4b1ff32205595817d99618acca46c43a0b3d8d..5dceace5faba4e34496d0e28f8e68b4e1b17867c 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -17,6 +17,8 @@ qlock(QLock *q) unlock(&q->queue); return; } + if(u == 0) + panic("qlock"); p = q->tail; if(p == 0) q->head = u->p; diff --git a/power/dat.h b/power/dat.h index 40d11c1f0cb6018f856aa9ec215a6e0118f5d791..08d7c2afb17c8e7d2d12136e93b2929ac0aa4773 100644 --- a/power/dat.h +++ b/power/dat.h @@ -136,7 +136,7 @@ struct Mach Proc *pidproc[NTLBPID]; /* process that owns this tlbpid on this mach */ Page *ufreeme; /* address of upage of exited process */ - int tlbfault; + int tlbfault; /* this offset known in l.s/utlbmiss() */ int tlbpurge; int pfault; int cs; diff --git a/power/l.s b/power/l.s index 3a993d482425739738e27a4931355c25a2a8a254..bdf4e88568a20b94b89fa54314a1685837ced655 100644 --- a/power/l.s +++ b/power/l.s @@ -243,26 +243,30 @@ TEXT vector0(SB), $-4 MOVW $utlbmiss(SB), R26 MOVW M(TLBVIRT), R27 - SRL $(6-3), R27 /* delay slot fodder, right adjust */ JMP (R26) TEXT utlbmiss(SB), $-4 - SRL $6, R27, R26 /* right adjusted vpn */ - SLL $(STLBLOG-6), R27 /* left adjusted pid */ + MOVW R27, R26 + SLL $1, R26 + SRL $12, R27 XOR R26, R27 - AND $((STLBSIZE-1)<<3), R27 + AND $(STLBSIZE-1), R27 + SLL $8, R27 + /* R27 = (((tlbvirt<<1)^(tlbvirt>>12)) & (STLBSIZE-1)) << 8 (8 to clear zero in TLBPHYS) */ MOVW R27, M(TLBPHYS) /* scratch register, store */ - MOVW $((MACHADDR+4) & 0xffff0000), R26 - MOVW $MPID, R27 + MOVW $((MACHADDR+4) & 0xffff0000), R26 /* get &mach[0].stb BUG */ + OR $((MACHADDR+4) & 0xffff), R26 + MOVW $MPID, R27 /* add BY2PG*machno */ MOVB 3(R27), R27 AND $7, R27 SLL $PGSHIFT, R27 ADDU R27, R26 MOVW M(TLBPHYS), R27 /* scratch register, load */ - MOVW ((MACHADDR+4) & 0xffff)(R26), R26 + MOVW (R26), R26 + SRL $5, R27 /* R27 is now index * 8 */ ADDU R26, R27 MOVW 4(R27), R26 MOVW R26, M(TLBPHYS) @@ -279,6 +283,7 @@ stlbm: MOVW $exception(SB), R26 JMP (R26) + TEXT exception(SB), $-4 MOVW M(STATUS), R26 diff --git a/power/main.c b/power/main.c index 1dce208ce966b886a03dc6cb713e6ac9bac59a79..c6137435f0990f72590032ef39ab229a0f1bc58d 100644 --- a/power/main.c +++ b/power/main.c @@ -261,7 +261,7 @@ userinit(void) * Kernel Stack */ p->sched.pc = (ulong)init0; - p->sched.sp = USERADDR+BY2PG-24; /* BUG */ + p->sched.sp = USERADDR+BY2PG-(1+MAXSYSARG)*BY2WD; p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF)); /* diff --git a/power/mem.h b/power/mem.h index bf2c0a569b15390577c15a5ea6618f82c7347d2f..63d80fe332fea63ea89a8aaee2f9091082cc2f15 100644 --- a/power/mem.h +++ b/power/mem.h @@ -103,7 +103,7 @@ #define TLBPID(n) (((n)>>6)&0x3F) #define PTEMAPMEM (1024*1024) #define PTEPERTAB (PTEMAPMEM/BY2PG) -#define STLBLOG 11 +#define STLBLOG 13 #define STLBSIZE (1<(USTKTOP-6*BY2WD)) - validaddr(sp, 6*BY2WD, 0); + if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD)) + validaddr(sp, (1+MAXSYSARG)*BY2WD, 0); ret = (*systab[r1])((ulong*)(sp+BY2WD)); } ur->pc += 4; diff --git a/ss/clock.c b/ss/clock.c index 3b50adbe9b9583ac8df4f11d9d15a90506bd8ffb..fb44f8735a3e421d35990877dcffaffac7c5bb85 100644 --- a/ss/clock.c +++ b/ss/clock.c @@ -59,7 +59,10 @@ clock(Ureg *ur) if((ur->psr&SPL(0xF))==0 && p && p->state==Running){ if(anyready()) sched(); - if(u->nnote && (ur->psr&PSRPSUPER)==0) - notify(ur); + if((ur->psr&PSRPSUPER) == 0){ + *(ulong*)(USTKTOP-BY2WD) += TK2MS(1); + if(u->nnote) + notify(ur); + } } } diff --git a/ss/faultsparc.c b/ss/faultsparc.c index a2c2f5b932de6ef30dbe131e3166f0618362a20c..8cef7e483a37e89073d59e643f5b87295b823cd0 100644 --- a/ss/faultsparc.c +++ b/ss/faultsparc.c @@ -25,6 +25,7 @@ faultsparc(Ureg *ur) read = 0; } spllo(); +print("fault %lux %lux %d\n", ur->pc, addr, read); if(u == 0){ dumpregs(ur); panic("fault u==0 pc=%lux addr=%lux", ur->pc, addr); diff --git a/ss/main.c b/ss/main.c index 9e4f980d175d64117e6f71739c78050c45073864..e9bdfa97e3194cbfdab48907a265d7d441d68435 100644 --- a/ss/main.c +++ b/ss/main.c @@ -111,7 +111,7 @@ init0(void) u->dot = clone(u->slash, 0); kickpager(); - touser(USTKTOP-5*BY2WD); + touser(USTKTOP-(1+MAXSYSARG)*BY2WD); } FPsave initfp; @@ -137,7 +137,7 @@ userinit(void) * Kernel Stack */ p->sched.pc = (((ulong)init0) - 8); /* 8 because of RETURN in gotolabel */ - p->sched.sp = USERADDR+BY2PG-20; /* BUG */ + p->sched.sp = USERADDR+BY2PG-(1+MAXSYSARG)*BY2WD; p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF)); /* diff --git a/ss/trap.c b/ss/trap.c index 3a025c73d1c45f203a72c81ad64820660b57330a..93b49d01b1944eb77ba33c2e2aa2128b4d2e05b2 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -174,14 +174,22 @@ void dumpstack(void) { ulong l, v; + int i; extern ulong etext; +print("no dumpstack\n"); +return; - if(u) + if(u){ + i = 0; for(l=(ulong)&l; lp->insyscall = 1; ur = aur; - u->p->pc = ur->pc; - if(ur->psr & PSRPSUPER) + if(ur->psr & PSRPSUPER){ + dumpregs(ur); panic("recursive system call"); + } + u->p->insyscall = 1; + u->p->pc = ur->pc; /* * since the system call interface does not @@ -330,8 +340,9 @@ syscall(Ureg *aur) u->p->fpstate = FPinit; ur->psr &= ~PSREF; } - +print("syscall %d\n", ur->r7); spllo(); +print("got low in syscall\n"); r7 = ur->r7; sp = ur->usp; @@ -350,6 +361,10 @@ syscall(Ureg *aur) msg = "sys: odd stack"; goto Bad; } + if(((ulong*)ur->pc)[-2] != 0x82206004){ /* new calling convention: look for ADD $-4, SP */ + pprint("new system call linkage\n"); + sp -= BY2WD; + } if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(2+MAXSYSARG)*BY2WD)) validaddr(sp, ((2+MAXSYSARG)*BY2WD), 0); ret = (*systab[r7])((ulong*)(sp+2*BY2WD));