From 390610134e0998653055d5501a608d5529e87ae0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 9 Feb 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-02-09 --- carrera/l.s | 33 +++++-- carrera/mem.h | 66 ++++++------- carrera/memmove.s | 247 ++++++++++++++++++++++++++++++++++++++++++++++ carrera/memset.s | 13 +-- carrera/trap.c | 2 +- pc/ether509.c | 31 +++--- 6 files changed, 325 insertions(+), 67 deletions(-) create mode 100644 carrera/memmove.s diff --git a/carrera/l.s b/carrera/l.s index 05ccaf08d2af19a34956e2907722b6e0c4c56cb4..9b13d8fcf1ce684593176ed1ecb16b415e334db3 100644 --- a/carrera/l.s +++ b/carrera/l.s @@ -1,10 +1,10 @@ #include "mem.h" -#define SP R29 +#define SP R29 -#define PROM (KSEG1+0x1C000000) +#define PROM (KSEG1+0x1C000000) #define NOOP WORD $0x27 -#define FCRNOOP NOOP; NOOP; NOOP +#define FCRNOOP NOOP; NOOP; NOOP #define WAIT NOOP; NOOP #define NOOP4 NOOP; NOOP; NOOP; NOOP @@ -27,8 +27,8 @@ /* * R4000 instructions */ -#define LD(base, rt) WORD $((067<<26)|((base)<<21)|((rt)<<16)) -#define STD(rt, base) WORD $((077<<26)|((base)<<21)|((rt)<<16)) +#define LD(offset, base, rt) WORD $((067<<26)|((base)<<21)|((rt)<<16)|((offset)&0xFFFF)) +#define STD(rt, offset, base) WORD $((077<<26)|((base)<<21)|((rt)<<16)|((offset)&0xFFFF)) #define DSLL(sa, rt, rd) WORD $(((rt)<<16)|((rd)<<11)|((sa)<<6)|070) #define DSRA(sa, rt, rd) WORD $(((rt)<<16)|((rd)<<11)|((sa)<<6)|073) #define LL(base, rt) WORD $((060<<26)|((base)<<21)|((rt)<<16)) @@ -491,6 +491,12 @@ TEXT forkret(SB), $0 TEXT saveregs(SB), $-4 MOVW R1, 0x9C(SP) MOVW R2, 0x98(SP) + /* save R5, R6 as 64 bits */ + ADDU $(UREGSIZE-16), SP, R1 + MOVW $~7, R2 /* don't let him use R28 */ + AND R2, R1 + STD (5, 0,(1)) + STD (6, 8,(1)) ADDU $8, SP, R1 MOVW R1, 0x04(SP) /* arg to base of regs */ MOVW M(STATUS), R1 @@ -567,14 +573,23 @@ TEXT restregs(SB), $-4 MOVW 0x7C(SP), R9 MOVW 0x80(SP), R8 MOVW 0x84(SP), R7 - MOVW 0x88(SP), R6 - MOVW 0x8C(SP), R5 + /* + * restored below + * MOVW 0x88(SP), R6 + * MOVW 0x8C(SP), R5 + */ MOVW 0x90(SP), R4 MOVW 0x94(SP), R3 MOVW 0x24(SP), R2 MOVW 0x20(SP), R1 MOVW R2, LO MOVW R1, HI + /* restore 64-bit R5, R6 */ + ADDU $(UREGSIZE-16), SP, R1 + MOVW $~7, R2 /* don't let him use R28 */ + AND R2, R1 + LD (0,(1), 5) + LD (8,(1), 6) MOVW 0x08(SP), R1 MOVW 0x98(SP), R2 MOVW R1, M(STATUS) @@ -842,7 +857,7 @@ TEXT uvmove(SB), $-4 BNE R2, uvgetuna /* aligned load */ - LD (1,2) + LD (0,(1), 2) WAIT MOVW R2, R1 DSLL (16,1,1) @@ -854,7 +869,7 @@ uvput: BNE R4, uvputuna /* aligned store */ - STD (2,3) + STD (2, 0,(3)) NOP RET diff --git a/carrera/mem.h b/carrera/mem.h index b7bc7e976cd6883fa47d80d1be1d52bb7a712120..7995e4df9ebdabde43c6c75e5d81738b04542965 100644 --- a/carrera/mem.h +++ b/carrera/mem.h @@ -7,20 +7,20 @@ */ #define BI2BY 8 /* bits per byte */ -#define BI2WD 32 /* bits per word */ +#define BI2WD 32 /* bits per word */ #define BY2WD 4 /* bytes per word */ #define BY2PG 4096 /* bytes per page */ #define WD2PG (BY2PG/BY2WD) /* words per page */ #define PGSHIFT 12 /* log(BY2PG) */ -#define PGROUND(s) (((s)+(BY2PG-1))&~(BY2PG-1)) +#define PGROUND(s) (((s)+(BY2PG-1))&~(BY2PG-1)) #define MAXMACH 1 /* max # cpus system can run */ -#define KSTACK 4096 /* Size of kernel stack */ +#define KSTACK 4096 /* Size of kernel stack */ /* * Time */ -#define HZ 100 /* clock frequency */ +#define HZ 100 /* clock frequency */ #define MS2HZ (1000/HZ) /* millisec per clock tick */ #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */ #define TK2MS(t) ((t)*MS2HZ) /* ticks to milliseconds */ @@ -96,53 +96,53 @@ * Fundamental addresses */ #define MACHADDR (KTZERO-MAXMACH*BY2PG) /* warning: rdbg is near here */ -#define UREGSIZE 0xA0 /* Sizeof(Ureg)+retpc & ur */ +#define UREGSIZE 0xC0 /* Sizeof(Ureg)+R5,R6+16 bytes slop+retpc & ur */ #define MACHP(n) ((Mach *)(MACHADDR+(n)*BY2PG)) /* * MMU */ -#define PGSZ4K (0x00<<13) -#define PGSZ64K (0x0F<<13) -#define PGSZ256K (0x3F<<13) -#define PGSZ1M (0xFF<<13) +#define PGSZ4K (0x00<<13) +#define PGSZ64K (0x0F<<13) +#define PGSZ256K (0x3F<<13) +#define PGSZ1M (0xFF<<13) #define KUSEG 0x00000000 -#define KSEG0 0x80000000 -#define KSEG1 0xA0000000 +#define KSEG0 0x80000000 +#define KSEG1 0xA0000000 #define KSEG2 0xC0000000 #define KSEG3 0xE0000000 #define KSEGM 0xE0000000 /* mask to check which seg */ -#define PIDXSHFT 12 -#define PIDX (0x7<>PIDXSHFT)&7) +#define KMAPMASK 0xFF000000 +#define KMAPSHIFT 15 +#define NCOLOR 8 +#define getpgcolor(a) (((ulong)(a)>>PIDXSHFT)&7) #define PTEGLOBL (1<<0) #define PTEVALID (1<<1) #define PTEWRITE (1<<2) -#define PTERONLY 0 -#define PTEALGMASK (7<<3) -#define PTEUNCACHED (2<<3) -#define PTENONCOHER (3<<3) -#define PTECOHERXCL (4<<3) -#define PTECOHERXCLW (5<<3) -#define PTECOHERUPDW (6<<3) -#define IOPTE (PTEGLOBL|PTEVALID|PTEWRITE|PTEUNCACHED) +#define PTERONLY 0 +#define PTEALGMASK (7<<3) +#define PTEUNCACHED (2<<3) +#define PTENONCOHER (3<<3) +#define PTECOHERXCL (4<<3) +#define PTECOHERXCLW (5<<3) +#define PTECOHERUPDW (6<<3) +#define IOPTE (PTEGLOBL|PTEVALID|PTEWRITE|PTEUNCACHED) #define PTEPID(n) (n) -#define TLBPID(n) ((n)&0xFF) -#define PTEMAPMEM (1024*1024) +#define TLBPID(n) ((n)&0xFF) +#define PTEMAPMEM (1024*1024) #define PTEPERTAB (PTEMAPMEM/BY2PG) -#define STLBLOG 13 -#define STLBSIZE (1<sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Ureg)+2*BY2WD); + p->sched.sp = (ulong)p->kstack+KSTACK-UREGSIZE; p->sched.pc = (ulong)forkret; cur = (Ureg*)(p->sched.sp+2*BY2WD); diff --git a/pc/ether509.c b/pc/ether509.c index 9663076f947f969afec2c9fb8a9133ac0c171142..5b9768ac87fc9138879b3a89a65099b5f9666bb2 100644 --- a/pc/ether509.c +++ b/pc/ether509.c @@ -54,6 +54,7 @@ enum { TxFreeBytes = 0x0C, /* window 1 */ TxStatus = 0x0B, + Timer = 0x0A, RxStatus = 0x08, Fifo = 0x00, @@ -388,23 +389,23 @@ activate(Ether *ether) idseq(); /* - * 3. Read the Product ID from the EEPROM. - * This is done by writing the IDPort with 0x83 (0x80 - * is the 'read EEPROM command, 0x03 is the offset of - * the Product ID field in the EEPROM). + * 3. Read the Manufacturer ID from the EEPROM. + * This is done by writing the IDPort with 0x87 (0x80 + * is the 'read EEPROM command, 0x07 is the offset of + * the Manufacturer ID field in the EEPROM). * The data comes back 1 bit at a time. * We seem to need a delay here between reading the bits. * * If the ID doesn't match the 3C509 ID code, the adapter * probably isn't there, so barf. */ - outb(IDport, 0x83); + outb(IDport, 0x87); for(x = 0, i = 0; i < 16; i++){ delay(5); x <<= 1; x |= inb(IDport) & 0x01; } - if((x & 0xF0FF) != 0x9050) + if((x & 0xF0FF) != 0x6D50) return -1; /* @@ -430,7 +431,7 @@ activate(Ether *ether) ether->port = (acr & 0x1F)*0x10 + 0x200; outb(ether->port+ConfigControl, 0x01); - return 0; + return ether->port; } /* @@ -447,14 +448,18 @@ reset(Ether *ether) /* * Switch out to 509 activation code if a port is supplied and is * not in the EISA slot space, otherwise check the EISA card is there. + * Port is set to either the newly activated ISA card address or + * the EISA slot configuration info where Window0 is always mapped. */ - if(ether->port < 0x1000 && activate(ether) < 0) - return -1; - else if((ins(ether->port+ProductID) & 0xF0FF) != 0x9050) + if(ether->port < 0x1000){ + if((port = activate(ether)) < 0) + return -1; + } + else if(ins(ether->port+ManufacturerID) == 0x6D50) + port = ether->port+0xC80; + else return -1; - port = ether->port; - /* * Read the IRQ from the Resource Configuration Register, * the ethernet address from the EEPROM, and the address configuration. @@ -474,6 +479,8 @@ reset(Ether *ether) } acr = ins(port+AddressConfig); + port = ether->port; + /* * Finished with window 0. Now set the ethernet address * in window 2.