From 9067c13a4d4d2b9ce16749d68e592a01c1e503c4 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 17 Dec 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-12-17 --- carrera/dat.h | 1 - carrera/devether.c | 17 +++++++---- carrera/l.s | 12 +++++++- carrera/main.c | 70 ++++++++++++++++++++++++++++++++++++---------- carrera/trap.c | 1 - pc/devvga.c | 8 +++--- port/chan.c | 9 ++++++ port/devcons.c | 6 ++++ 8 files changed, 97 insertions(+), 27 deletions(-) diff --git a/carrera/dat.h b/carrera/dat.h index 19b25371d02bfcab1e8c217af37e55c228948da1..af09dce8180c41bd57c1c6c3ee5763816ecdeb2c 100644 --- a/carrera/dat.h +++ b/carrera/dat.h @@ -139,7 +139,6 @@ struct KMap KMap* next; KMap* konmach[MAXMACH]; Page* pg; - char inuse; /* number of procs using kmap */ }; #define VA(k) ((k)->virt) diff --git a/carrera/devether.c b/carrera/devether.c index 500d76292bee6bdf56f16e593d23c4aaa7936f5f..81c774f8c5a2c87fdc732fd7492eb5c2117754ee 100644 --- a/carrera/devether.c +++ b/carrera/devether.c @@ -15,8 +15,8 @@ #define SONICADDR ((Sonic*)Sonicbase) -#define RD(rn) (delay(1), *(ulong*)((ulong)&SONICADDR->rn^4)) -#define WR(rn, v) (delay(1), *(ulong*)((ulong)&SONICADDR->rn^4) = (v)) +#define RD(rn) (delay(0), *(ulong*)((ulong)&SONICADDR->rn^4)) +#define WR(rn, v) (delay(0), *(ulong*)((ulong)&SONICADDR->rn^4) = (v)) #define ISquad(s) if((ulong)s & 0x7) panic("sonic: Quad alignment"); typedef struct Pbuf Pbuf; @@ -74,8 +74,8 @@ typedef struct enum { - Nrb = 16, /* receive buffers */ - Ntb = 16, /* transmit buffers */ + Nrb = 8, /* receive buffers */ + Ntb = 8, /* transmit buffers */ }; enum @@ -530,8 +530,10 @@ etherintr(void) status &= ~Hbl; } if(status & Br){ - print("sonic: bus retry occurred\n"); + WR(cr, 0); + iprint("sonic: bus retry occurred\n"); status &= ~Br; + for(;;); } if(status & AllIntr) @@ -560,9 +562,10 @@ static void initbufs(Ether *c) { int i; - uchar *mem; + uchar *mem, *base; mem = xspanalloc(64*1024, BY2PG, 0); + base = mem; mem = CACHELINE(uchar, mem); /* @@ -595,6 +598,8 @@ initbufs(Ether *c) mem += sizeof(Pbuf); mem = QUAD(uchar, mem); } + if(mem >= base+64*1024) + panic("sonic init"); } void diff --git a/carrera/l.s b/carrera/l.s index eec3b94c7db726e75e256270d4fcb53488d30623..2cf998d4b5896973dd5e941959f8cc9b63943a17 100644 --- a/carrera/l.s +++ b/carrera/l.s @@ -12,7 +12,17 @@ #define CONST(x,r) MOVW $((x)&0xffff0000), r; OR $((x)&0xffff), r -#define RDBGSV CONST(0x80020000, R26); MOVW R29, 0(R26); MOVW M(EPC), R27; MOVW R27, 4(R26); MOVW R31, 8(R26) +#define RDBGSV CONST(0x80020000, R26); \ + MOVW R29, 0(R26); \ + MOVW M(EPC), R27; \ + MOVW R27, 4(R26); \ + MOVW R31, 8(R26); \ + MOVW M(CAUSE), R27; \ + MOVW R27, 12(R26); \ + MOVW M(STATUS), R27; \ + MOVW R27, 16(R26); \ + MOVW M(BADVADDR), R27; \ + MOVW R27, 20(R26) /* * R4000 instructions diff --git a/carrera/main.c b/carrera/main.c index 6a3346c52b13e054afe60127b1a4ec480e224930..91f8c35856703d476854310831cec4eb5d5f5435 100644 --- a/carrera/main.c +++ b/carrera/main.c @@ -37,8 +37,9 @@ extern ulong rdbglen; void main(void) { - tlbinit(); /* Very early to establish IO mappings */ - ioinit(1); + rdbginit(); + tlbinit(); + ioinit(1); /* Very early to establish IO mappings */ arginit(); confinit(); savefpregs(&initfp); @@ -62,6 +63,7 @@ main(void) schedinit(); } + /* * copy arguments passed by the boot kernel (or ROM) into a temporary buffer. * we do this because the arguments are in memory that may be allocated @@ -398,10 +400,15 @@ confinit(void) conf.copymode = 0; /* copy on write */ } +void +procsave(Proc *p) +{ + USED(p); -/* - * for the sake of devcons - */ + /* keep track of tlbfaults */ + up->counter[TLBCNTR] += m->tlbfault - m->otlbfault; + m->otlbfault = m->tlbfault; +} void buzz(int f, int d) @@ -410,18 +417,53 @@ buzz(int f, int d) USED(d); } -void -rdbginit(void) +/* + register offsets of ARCS prom jmpbuf + JB_PC 0 + JB_SP 1 + JB_FP 2 + JB_S0 3 + JB_S1 4 + JB_S2 5 + JB_S3 6 + JB_S4 7 + JB_S5 8 + JB_S6 9 + JB_S7 10 +*/ + +struct { - memmove((void*)0xA001C000, rdbgcode, rdbglen); -} + ulong pc; + ulong sp; + ulong fp; + ulong s[7]; +} Mipsjmpbuf; void -procsave(Proc *p) +rdbginit(void) { - USED(p); + uchar *vec; + ulong jba; - /* keep track of tlbfaults */ - up->counter[TLBCNTR] += m->tlbfault - m->otlbfault; - m->otlbfault = m->tlbfault; + /* Only interested in the PC */ + Mipsjmpbuf.pc = 0xA001C020; + + /* Link an NMI handler to the debugger + * - addresses from the ARCS rom source + */ + vec = (uchar*)0xA0000420; + jba = (ulong)UNCACHED(void, &Mipsjmpbuf); + + vec[0] = 'N'; + vec[1] = 'm'; + vec[2] = 'i'; + vec[3] = 's'; + vec[4] = jba>>24; + vec[5] = jba>>16; + vec[6] = jba>>8; + vec[7] = jba; + + /* Install the debugger code in a known place */ + memmove((void*)0xA001C000, rdbgcode, rdbglen); } diff --git a/carrera/trap.c b/carrera/trap.c index e20e330b90c956ab559ec942c9400bfae765775c..0d7eb87b54c21560e2d60bca09484026dea5f251 100644 --- a/carrera/trap.c +++ b/carrera/trap.c @@ -617,7 +617,6 @@ forkchild(Proc *p, Ureg *ur) memmove(cur, ur, sizeof(Ureg)); cur->pc += 4; - cur->status |= CU0; /* Things from bottom of syscall we never got to execute */ p->psstate = 0; diff --git a/pc/devvga.c b/pc/devvga.c index 2c22c1771f535c96b65ec8f8ecfbdf8b05c05ab5..e8b043b3bd34e29fb72ebc874f3fba5c9fcbe6c6 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -518,9 +518,9 @@ setscreen(int maxx, int maxy, int ldepth) } /* - * paste tile into soft screen. - * tile is at location r, first pixel in *data. tl is length of scan line to insert, - * l is amount to advance data after each scan line. + * paste tile into soft screen. + * tile is at location r, first pixel in *data. tl is length of scan line to insert, + * l is amount to advance data after each scan line. */ void screenload(Rectangle r, uchar *data, int tl, int l) @@ -588,7 +588,7 @@ screenload(Rectangle r, uchar *data, int tl, int l) } /* - * copy litte endian soft screen to big endian hard screen + * copy little endian soft screen to big endian hard screen */ void screenupdate(void) diff --git a/port/chan.c b/port/chan.c index 2e3e66773dc3ad0dd38a8c89f16b611b3dc5cce8..42c440f7d64cd2e6f5e5f1fac07dcd6e3bf1b777 100644 --- a/port/chan.c +++ b/port/chan.c @@ -195,11 +195,20 @@ mount(Chan *new, Chan *old, int flag, char *spec) } if(m == 0) { + /* + * nothing mounted here yet. create a mount + * head and add to the hash table. + */ m = smalloc(sizeof(Mhead)); m->from = old; incref(old); m->hash = *l; *l = m; + + /* + * if this is a union mount, add the old + * node to the mount chain. + */ if(order != MREPL) m->mount = newmount(m, old, 0, 0); } diff --git a/port/devcons.c b/port/devcons.c index 3ca32fd97714fe26a83fd57da15dab2f63470cd1..7456badfc5f420b8e4c64295d651bd33e477d69b 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -212,6 +212,12 @@ echo(Rune r, char *buf, int n) case 'r': exit(0); break; +case 'q': +print("%lux\n", *(ulong*)0xe0000004); +print("%lux\n", *(ulong*)0x80000420); +print("%lux\n", *(ulong*)0x80000424); +for(pid = 0; pid < 30; pid++) +print(":%lux\n", ((ulong*)0xbfc00000)[pid]); } break; case 3: