M gnot/fault68020.c => gnot/fault68020.c +0 -1
@@ 99,7 99,6 @@ fault68020(Ureg *ur, FFrame *f)
}
dumpregs(ur);
panic("fault: 0x%lux", badvaddr);
- exit();
}
u->p->insyscall = insyscall;
}
M gnot/main.c => gnot/main.c +4 -2
@@ 259,7 259,7 @@ bootargs(ulong base)
}
void
-exit(void)
+exit(int ispanic)
{
int i;
@@ 269,6 269,8 @@ exit(void)
for(i=0; i<1000; i++)
;
splhi();
+ if(ispanic)
+ for(;;);
firmware();
}
@@ 332,7 334,7 @@ confinit(void)
conf.nimage = 50;
conf.copymode = 0; /* copy on write */
conf.portispaged = 0;
- conf.nconc = 2;
+ confinit1(mul);
}
/*
M gnot/trap.c => gnot/trap.c +1 -1
@@ 121,7 121,7 @@ trap(Ureg *ur)
}else{
print("kernel trap %s pc=0x%lux\n", excname(ur->vo, ur->pc), ur->pc);
dumpregs(ur);
- exit();
+ exit(1);
}
if(user)
M pc/main.c => pc/main.c +3 -1
@@ 411,10 411,12 @@ meminit(void)
* reset the i387 chip
*/
void
-exit(void)
+exit(int ispanic)
{
u = 0;
print("exiting\n");
+ if(ispanic)
+ for(;;);
switch(machtype){
case Attnsx:
headreset(); /* via headland chip */
M port/devcons.c => port/devcons.c +3 -6
@@ 171,10 171,7 @@ panic(char *fmt, ...)
buf[n] = '\n';
putstrn(buf, n+1);
dumpstack();
- if(cpuserver)
- exit();
- else
- for(;;);
+ exit(1);
}
int
pprint(char *fmt, ...)
@@ 218,7 215,7 @@ echo(Rune r, char *buf, int n)
* ^p hack
*/
if(r==0x10 && cpuserver)
- panic("^p");
+ exit(0);
/*
* ^t hack BUG
@@ 241,7 238,7 @@ echo(Rune r, char *buf, int n)
procdump();
return;
case 'r':
- exit();
+ exit(0);
break;
}
}else if(r == 0x14){
M port/fault.c => port/fault.c +1 -1
@@ 282,7 282,7 @@ okaddr(ulong addr, ulong len, int write)
return 1;
}
}
- pprint("suicide: invalid address 0x%lux in sys call pc=0x%.8lux\n", addr, userpc());
+ pprint("suicide: invalid address 0x%lux in sys call pc=0x%lux\n", addr, userpc());
return 0;
}
M port/portfns.h => port/portfns.h +1 -1
@@ 56,7 56,7 @@ int eqqid(Qid, Qid);
void error(char*);
long execregs(ulong, ulong, ulong);
void exhausted(char*);
-void exit(void);
+void exit(int);
Block* expandb(Block*, int);
int fault(ulong, int);
void fdclose(int, int);
M port/streboot.c => port/streboot.c +1 -1
@@ 42,7 42,7 @@ rebootiput(Queue *q, Block *bp)
{
if(bp->type == M_HANGUP){
print("lost connection to fs, rebooting");
- exit();
+ exit(0);
}
PUTNEXT(q, bp);
}
M power/clock.c => power/clock.c +1 -1
@@ 110,7 110,7 @@ clock(Ureg *ur)
duartslave();
if(active.exiting && active.machs&(1<<m->machno)){
print("someone's exiting\n");
- exit();
+ exit(0);
}
checkalarms();
kproftimer(ur->pc);
M power/main.c => power/main.c +2 -1
@@ 328,10 328,11 @@ online(void)
}
void
-exit(void)
+exit(int ispanic)
{
int i;
+ USED(ispanic);
u = 0;
lock(&active);
active.machs &= ~(1<<m->machno);
M ss/faultsparc.c => ss/faultsparc.c +0 -1
@@ 52,7 52,6 @@ faultsparc(Ureg *ur)
}
dumpregs(ur);
panic("fault: 0x%lux", badvaddr);
- exit();
}
splhi();
}
M ss/fns.h => ss/fns.h +2 -1
@@ 34,6 34,7 @@ KMap* kmap(Page*);
void kmapinit(void);
KMap* kmappa(ulong, ulong);
KMap* kmapperm(Page*);
+ulong kmapregion(ulong, ulong, ulong);
int kprint(char*, ...);
void kproftimer(ulong);
void kunmap(KMap*);
@@ 55,7 56,7 @@ void puttbr(ulong);
void putw4(ulong, ulong); /* needed only at boot time */
void systemreset(void);
void restfpregs(FPsave*, ulong);
-void screeninit(void);
+void screeninit(char*);
void screenputc(int);
void screenputs(char*, int);
void scsiintr(void);
M ss/l.s => ss/l.s +10 -2
@@ 15,6 15,7 @@ TEXT start(SB), $-4
MOVB R9, (R7, 3)
/* now mapped correctly. jmpl to where we want to be */
MOVW $setSB(SB), R2
+
MOVW $startvirt(SB), R7
JMPL (R7)
MOVW $_mul(SB), R0 /* touch _mul etc.; doesn't need to execute */
@@ 25,6 26,12 @@ TEXT startvirt(SB), $-4
MOVW $rom(SB), R7
MOVW R8, (R7) /* romvec passed in %i0==R8 */
+ /* turn off the cache */
+ MOVW $ENAB, R7
+ MOVB (R7, 2), R8
+ ANDN $ENABCACHE, R8
+ MOVB R8, (R7, 2)
+
MOVW $BOOTSTACK, R1
MOVW $(SPL(0xF)|PSREF|PSRSUPER), R7
@@ 461,8 468,9 @@ GLOBL mach0+0(SB), $MACHSIZE
GLOBL fsr+0(SB), $BY2WD
/*
- * Interface to ROM. Must save and restore state because
- * of different calling conventions.
+ * Interface to OPEN BOOT ROM. Must save and restore state because
+ * of different calling conventions. We don't use it, but it's here
+ * for reference..
*/
TEXT call(SB), $16
M ss/main.c => ss/main.c +57 -29
@@ 16,21 16,20 @@ int cpuserver;
ulong romputcxsegm;
ulong bank[2];
char mempres[256];
-ulong fbsz;
char fbstr[32];
-char fbcrap[BY2PG];
Label catch;
+int NKLUDGE;
typedef struct Sysparam Sysparam;
struct Sysparam
{
int id; /* Model type from id prom */
char *name; /* System name */
- char ss2; /* Is sparcstation 2 ? */
+ char ss2; /* Is Sparcstation 2? */
int vacsize; /* Cache size */
int vacline; /* Cache line size */
int ncontext; /* Number of MMU contexts */
- int npmeg; /* Number of process maps */
+ int npmeg; /* Number of page map entry groups */
char cachebug; /* Machine needs cache bug work around */
int memscan; /* Number of Meg to scan looking for memory */
}
@@ 60,9 59,10 @@ main(void)
confinit();
xinit();
mmuinit();
- screeninit();
- printinit();
kmapinit();
+ if(conf.monitor)
+ screeninit(fbstr);
+ printinit();
ioinit();
if(conf.monitor == 0)
sccspecial(2, &printq, &kbdq, 9600);
@@ 138,7 138,8 @@ init0(void)
print("Sun Sparcstation %s\n", sparam->name);
print("bank 0: %dM 1: %dM\n", bank[0], bank[1]);
- print("frame buffer id %lux %lux %s\n", conf.monitor, fbsz, fbstr);
+ print("frame buffer id %lux %s\n", conf.monitor, fbstr);
+ print("NKLUDGE %d\n", NKLUDGE);
u->slash = (*devtab[0].attach)(0);
u->dot = clone(u->slash, 0);
@@ 223,7 224,7 @@ userinit(void)
}
void
-exit(void)
+exit(int ispanic)
{
int i;
@@ 234,6 235,8 @@ exit(void)
for(i=0; i<1000; i++)
;
splhi();
+ if(ispanic)
+ for(;;);
systemreset();
}
@@ 282,36 285,44 @@ confinit(void)
/* map id prom */
va = 1*MB-BY2PG;
- putw4(va, PPN(EEPROM)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
+ putw4(va, PPN(EEPROM)|PTEPROBEIO);
memmove(idprom, (char*)(va+0x7d8), 32);
if(idprom[0]!=1 || (idprom[1]&0xF0)!=0x50)
*(ulong*)va = 0;
putw4(va, INVALIDPTE);
/* map frame buffer id; we expect it to be in SBUS slot 3 */
- putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
+ putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
conf.monitor = 0;
/* if frame buffer not present, we will trap, so prepare to catch it */
if(setlabel(&catch) == 0){
conf.monitor = *(ulong*)va;
-putw4(va, (((FRAMEBUFID+BY2PG)>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
-memmove(fbcrap, (void*)va, BY2PG);
- j = *(ulong*)(va+4);
- fbsz = j;
- j = BY2PG - 8; /* for safety */
- for(i=0; i<j && fbstr[0]==0; i++)
- switch(*(uchar*)(va+i)){
- case 'b':
- if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
- strcpy(fbstr, "bwtwo");
- break;
- case 'c':
- if(strncmp((char*)(va+i), "cgthree", 7) == 0)
- strcpy(fbstr, "cgthree");
- if(strncmp((char*)(va+i), "cgsix", 5) == 0)
- strcpy(fbstr, "cgsix");
- break;
- }
+ switch(conf.monitor){
+ case 0xFE010101:
+ strcpy(fbstr, "cgthree");
+ break;
+ case 0xFE010104:
+ strcpy(fbstr, "bwtwo");
+ break;
+ }
+ if(fbstr[0] == 0){
+ j = *(ulong*)(va+4);
+ if(j > BY2PG-8)
+ j = BY2PG - 8; /* -8 for safety */
+ for(i=0; i<j && fbstr[0]==0; i++)
+ switch(*(uchar*)(va+i)){
+ case 'b':
+ if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
+ strcpy(fbstr, "bwtwo");
+ break;
+ case 'c':
+ if(strncmp((char*)(va+i), "cgthree", 7) == 0)
+ strcpy(fbstr, "cgthree");
+ if(strncmp((char*)(va+i), "cgsix", 5) == 0)
+ strcpy(fbstr, "cgsix");
+ break;
+ }
+ }
}
catch.pc = 0;
putw4(va, INVALIDPTE);
@@ 328,6 339,8 @@ memmove(fbcrap, (void*)va, BY2PG);
conf.vacsize = sparam->vacsize;
conf.vaclinesize = sparam->vacline;
conf.ncontext = sparam->ncontext;
+ if(conf.ncontext > 8)
+ conf.ncontext = 8; /* BUG to enlarge NKLUDGE */
conf.npmeg = sparam->npmeg;
conf.ss2cachebug = sparam->cachebug;
@@ 353,7 366,22 @@ memmove(fbcrap, (void*)va, BY2PG);
bank[0] = conf.npage0*BY2PG/MB;
bank[1] = conf.npage1*BY2PG/MB;
-
+
+ if(bank[1] == 0){
+ /*
+ * This split of memory into 2 banks fools the allocator into
+ * allocating low memory pages from bank 0 for the ethernet since
+ * it has only a 24bit address counter.
+ * NB. Suns must have at LEAST 8Mbytes.
+ */
+ conf.npage1 = conf.npage0 - (4*MB)/BY2PG;
+ conf.base1 = 4*MB;
+ conf.npage0 = (4*MB)/BY2PG;
+ conf.base0 = 0;
+ bank[1] = bank[0]-4;
+ bank[0] = 4;
+ }
+
conf.npage = conf.npage0+conf.npage1;
conf.upages = (conf.npage*70)/100;
if(cpuserver){
M ss/mem.h => ss/mem.h +14 -15
@@ 67,16 67,14 @@
*/
#define INVALIDSEGM 0xFFFC0000 /* highest seg of VA reserved as invalid */
#define INVALIDPMEG (conf.npmeg-1)
-#define SCREENSEGM 0xFFF80000
-#define SCREENPMEG (conf.npmeg-2)
+#define ROMPMEG (conf.npmeg-2)
#define ROMSEGM 0xFFE80000
#define ROMEND 0xFFEC0000
#define PG2ROM ((ROMEND-ROMSEGM)/BY2PG)
-#define IOSEGM0 ROMSEGM /* see mmuinit() */
-#define NIOSEGM ((SCREENSEGM-ROMSEGM)/BY2SEGM)
-#define IOPMEG0 (SCREENPMEG-NIOSEGM)
-#define IOSEGM ROMEND
-#define IOEND SCREENSEGM
+#define NIOSEGM ((MB/BY2SEGM) + 4) /* 1M for screen + overhead */
+#define IOSEGM0 (ROMSEGM-NIOSEGM*BY2SEGM)
+#define IOPMEG0 (ROMPMEG-NIOSEGM)
+#define IOEND ROMSEGM
#define TOPPMEG IOPMEG0
/*
@@ 92,6 90,7 @@
#define PTEACCESS (1<<25)
#define PTEMODIFY (1<<24)
#define PTEPROBEMEM (PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEMAINMEM)
+#define PTEPROBEIO (PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEIO)
#define PTEUNCACHED 0
#define PTEMAPMEM (1024*1024)
@@ 102,15 101,15 @@
#define PPN(pa) ((pa>>12)&0xFFFF)
/*
- * Weird addresses in various ASI's
+ * Weird addresses etc. in System ASI (2)
*/
-#define CACHETAGS 0x80000000 /* ASI 2 */
-#define CACHEDATA 0x90000000 /* ASI 2 */
-#define SER 0x60000000 /* ASI 2 */
-#define SEVAR 0x60000004 /* ASI 2 */
-#define ASER 0x60000008 /* ASI 2 */
-#define ASEVAR 0x6000000C /* ASI 2 */
-#define ENAB 0x40000000 /* ASI 2 */
+#define CACHETAGS 0x80000000
+#define CACHEDATA 0x90000000
+#define SER 0x60000000
+#define SEVAR 0x60000004
+#define ASER 0x60000008
+#define ASEVAR 0x6000000C
+#define ENAB 0x40000000
#define ENABRESET 0x04
#define ENABCACHE 0x10
#define ENABDMA 0x20
M ss/mmu.c => ss/mmu.c +33 -18
@@ 24,10 24,10 @@ struct
Lock;
int lowpmeg;
KMap *free;
- KMap arena[(IOEND-IOSEGM)/BY2PG];
+ KMap arena[(IOEND-IOSEGM0)/BY2PG];
}kmapalloc;
-#define NKLUDGE 11 /* <= ((TOPPMEG-kmap.lowpmeg)/NCONTEXT) */
+int NKLUDGE;
/*
* On SPARC, tlbpid i == context i-1 so that 0 means unallocated
@@ 163,6 163,8 @@ mmuinit(void)
putcxsegm(c, KZERO+i*BY2SEGM, i);
kmapalloc.lowpmeg = i;
+ if(PADDR(ktop) & (BY2SEGM-1))
+ kmapalloc.lowpmeg++;
/*
* Make sure cache is turned on for kernel
@@ 189,19 191,9 @@ mmuinit(void)
putsegm(l, INVALIDPMEG);
/*
- * One segment for screen
+ * Map ROM
*/
- putsegm(SCREENSEGM, SCREENPMEG);
- if(c == 0){
- pte = PTEVALID|PTEWRITE|PTEKERNEL|PTENOCACHE|
- PTEIO|((DISPLAYRAM>>PGSHIFT)&0xFFFF);
- for(i=0; i<PG2SEGM; i++)
- putpmeg(SCREENSEGM+i*BY2PG, pte+i);
- }
- /*
- * First page of IO space includes ROM; be careful
- */
- putsegm(IOSEGM0, IOPMEG0); /* IOSEGM == ROMSEGM */
+ putsegm(ROMSEGM, ROMPMEG);
if(c == 0){
pte = PTEVALID|PTEKERNEL|PTENOCACHE|
PTEIO|((EPROM>>PGSHIFT)&0xFFFF);
@@ 211,9 203,9 @@ mmuinit(void)
putpmeg(IOSEGM0+i*BY2PG, INVALIDPTE);
}
/*
- * Remaining segments for IO and kmap
+ * Segments for IO and kmap
*/
- for(j=1; j<NIOSEGM; j++){
+ for(j=0; j<NIOSEGM; j++){
putsegm(IOSEGM0+j*BY2SEGM, IOPMEG0+j);
if(c == 0)
for(i=0; i<PG2SEGM; i++)
@@ 221,6 213,8 @@ mmuinit(void)
}
}
putcontext(0);
+ NKLUDGE = ((TOPPMEG-kmapalloc.lowpmeg)/conf.ncontext);
+if(NKLUDGE>11)NKLUDGE=11;
}
void
@@ 331,8 325,8 @@ kmapinit(void)
kmapalloc.free = 0;
k = kmapalloc.arena;
- for(i=0; i<(IOEND-IOSEGM)/BY2PG; i++,k++){
- k->va = IOSEGM+i*BY2PG;
+ for(i=0; i<(IOEND-IOSEGM0)/BY2PG; i++,k++){
+ k->va = IOSEGM0+i*BY2PG;
kunmap(k);
}
}
@@ 358,6 352,27 @@ kmappa(ulong pa, ulong flag)
return k;
}
+ulong
+kmapregion(ulong pa, ulong n, ulong flag)
+{
+ KMap *k;
+ ulong va;
+ int i, j;
+
+ /*
+ * kmap's are initially in reverse order so rearrange them.
+ */
+ i = (n+(BY2PG-1))/BY2PG;
+ va = 0;
+ for(j=i-1; j>=0; j--){
+ k = kmappa(pa+j*BY2PG, flag);
+ if(va && va != k->va+BY2PG)
+ systemreset();
+ va = k->va;
+ }
+ return va;
+}
+
KMap*
kmap(Page *pg)
{
M ss/screen.c => ss/screen.c +10 -6
@@ 26,24 26,27 @@ GBitmap gscreen;
struct screens
{
- ulong type;
+ char *type;
int x;
int y;
int ld;
}screens[] = {
- { 0xFE010104, 1152, 900, 0 },
+ { "bwtwo", 1152, 900, 0 },
+ { "cgsix", 1152, 900, 3 },
+ { "cgthree", 1152, 900, 3 },
0
};
Lock screenlock;
void
-screeninit(void)
+screeninit(char *str)
{
struct screens *s;
+ ulong n;
for(s=screens; s->type; s++)
- if(s->type == conf.monitor)
+ if(strcmp(s->type, str) == 0)
goto found;
/* default is 0th element of table */
if(conf.monitor){
@@ 54,9 57,10 @@ screeninit(void)
return;
found:
- gscreen.base = (ulong*)SCREENSEGM;
gscreen.zero = 0;
- gscreen.width = (s->x<<s->ld)/32;
+ gscreen.width = (s->x<<s->ld)/(8*sizeof(ulong));
+ n = sizeof(ulong) * gscreen.width * s->y;
+ gscreen.base = (ulong*)kmapregion(DISPLAYRAM, n, PTENOCACHE|PTEIO);
gscreen.ldepth = s->ld;
gscreen.r = Rect(0, 0, s->x, s->y);
gscreen.clipr = gscreen.r;
M ss/scsi.c => ss/scsi.c +3 -2
@@ 89,7 89,9 @@ resetscsi(void)
dma = ioaddr.dma;
dev->cmd = Reset;
- dev->cmd = Nop;
+ dev->cmd = Dma|Nop; /* 2 are necessary */
+ dev->cmd = Dma|Nop;
+
dev->countlo = 0;
dev->counthi = 0;
dev->timeout = 146;
@@ 106,7 108,6 @@ resetscsi(void)
dmatype = (dma->csr>>28) & 0xF;
putenab(getenab()|ENABDMA); /**/
-print("scsi config #%2.2ux\n", dev->config);
}
void