From 37cdcabe2f146e37ea4af57ade588674bccefa80 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 25 Feb 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-02-25 --- carrera/devrtc.c | 6 +----- carrera/io.h | 35 +++++++++++++++++++++++++++++++++++ carrera/main.c | 40 ++++++++++++++++++++++++++++++++++++++++ carrera/trap.c | 22 +++++++++++++++++++--- port/portdat.h | 46 +++++++++++++++++++++++----------------------- port/portfns.h | 20 ++++++++++---------- 6 files changed, 128 insertions(+), 41 deletions(-) diff --git a/carrera/devrtc.c b/carrera/devrtc.c index 1b21ebdb7cc949eb61ffef2089799fed5b53923d..f4180e12eca4e3b419eaa3da5e6c91daa34b4063 100644 --- a/carrera/devrtc.c +++ b/carrera/devrtc.c @@ -116,13 +116,11 @@ static uchar bcd2binary(int reg) { uchar x; -/* + x = (*(uchar*)Rtcindex)&~0x7f; *(uchar*)Rtcindex = x|reg; x = *(uchar*)Rtcdata; return (x&0xf) + 10*(x>>4); -/**/ - return 0; } long @@ -191,11 +189,9 @@ static void binary2bcd(int reg, uchar val) { uchar x; -/* x = (*(uchar*)Rtcindex)&~0x7f; *(uchar*)Rtcindex = x|reg; *(uchar*)Rtcdata = (val % 10) | (((val / 10) % 10)<<4); -/**/ } diff --git a/carrera/io.h b/carrera/io.h index 7cb04db246a20b1fd5e554f273fd154bd079a5c5..64af74efcd5524b1d997a6f521028d1df353c7be 100644 --- a/carrera/io.h +++ b/carrera/io.h @@ -69,6 +69,11 @@ enum Ntranslation = 4096, /* Number of translation registers */ }; +enum +{ + SB16pcm = 100, +}; + typedef struct Tte Tte; struct Tte { @@ -86,3 +91,33 @@ struct Tte #define EISAINW(port) (*(ushort*)((EisaControl+(port))^6)) #define EISAOUTB(port, v) EISAINB(port) = v #define EISAOUTW(port, v) EISAINW(port) = v + +/* + * 8259 interrupt controllers + */ +enum +{ + Int0vec= 0, /* first 8259 */ + Clockvec= Int0vec+0, /* clock interrupts */ + Kbdvec= Int0vec+1, /* keyboard interrupts */ + Uart1vec= Int0vec+3, /* modem line */ + Uart0vec= Int0vec+4, /* serial line */ + PCMCIAvec= Int0vec+5, /* PCMCIA card change */ + Floppyvec= Int0vec+6, /* floppy interrupts */ + Parallelvec= Int0vec+7, /* parallel port interrupts */ + Int1vec= Int0vec+8, /* second 8259 */ + Ethervec= Int0vec+10, /* ethernet interrupt */ + Mousevec= Int0vec+12, /* mouse interrupt */ + Matherr2vec= Int0vec+13, /* math coprocessor */ + Hardvec= Int0vec+14, /* hard disk */ + + Int0ctl= 0x20, /* control port (ICW1, OCW2, OCW3) */ + Int0aux= 0x21, /* everything else (ICW2, ICW3, ICW4, OCW1) */ + Int1ctl= 0xA0, /* control port */ + Int1aux= 0xA1, /* everything else (ICW2, ICW3, ICW4, OCW1) */ + + EOI= 0x20, /* non-specific end of interrupt */ +}; + +extern int int0mask; /* interrupts enabled for first 8259 */ +extern int int1mask; /* interrupts enabled for second 8259 */ diff --git a/carrera/main.c b/carrera/main.c index 207be43d2715d25cd09b760dba7795b5945c248f..a33b680474cb2429ae30ebda0a7ccff67aa453a2 100644 --- a/carrera/main.c +++ b/carrera/main.c @@ -31,6 +31,9 @@ Softtlb stlb[MAXMACH][STLBSIZE]; Conf conf; FPsave initfp; +int int0mask = 0xff; /* interrupts enabled for first 8259 */ +int int1mask = 0xff; /* interrupts enabled for second 8259 */ + extern uchar rdbgcode[]; extern ulong rdbglen; @@ -217,6 +220,43 @@ ioinit(int mapeisa) ptec = PPN(VideoCTL)|PTEGLOBL|PTEVALID|PTEWRITE|PTEUNCACHED; ptes = PPN(VideoMEM)|PTEGLOBL|PTEVALID|PTEWRITE|PTEUNCACHED; puttlbx(4, Screenvirt, ptes, ptec, PGSZ4M); + + /* for PC weenies */ + /* + * Set up the first 8259 interrupt processor. + * Make 8259 interrupts start at CPU vector Int0vec. + * Set the 8259 as master with edge triggered + * input with fully nested interrupts. + */ + EISAOUTB(Int0ctl, 0x11); /* ICW1 - edge triggered, master, + ICW4 will be sent */ + EISAOUTB(Int0aux, Int0vec); /* ICW2 - interrupt vector offset */ + EISAOUTB(Int0aux, 0x04); /* ICW3 - have slave on level 2 */ + EISAOUTB(Int0aux, 0x01); /* ICW4 - 8086 mode, not buffered */ + + /* + * Set up the second 8259 interrupt processor. + * Make 8259 interrupts start at CPU vector Int0vec. + * Set the 8259 as master with edge triggered + * input with fully nested interrupts. + */ + EISAOUTB(Int1ctl, 0x11); /* ICW1 - edge triggered, master, + ICW4 will be sent */ + EISAOUTB(Int1aux, Int1vec); /* ICW2 - interrupt vector offset */ + EISAOUTB(Int1aux, 0x02); /* ICW3 - I am a slave on level 2 */ + EISAOUTB(Int1aux, 0x01); /* ICW4 - 8086 mode, not buffered */ + + /* + * pass #2 8259 interrupts to #1 + */ + int0mask &= ~0x04; + EISAOUTB(Int0aux, int0mask); + + /* enable all PC interrupts except the clock */ + int0mask |= 1<<(Clockvec&7); + EISAOUTB(Int0aux, int0mask); + int1mask = 0; + EISAOUTB(Int1aux, int1mask); } /* diff --git a/carrera/trap.c b/carrera/trap.c index 57fb0fd5df3910c97da4e7fd6479fefcb0724e0a..6a349db49630905561a10412fae9178a3f582385 100644 --- a/carrera/trap.c +++ b/carrera/trap.c @@ -289,7 +289,7 @@ intr(Ureg *ur) { static uchar devint; ulong cause = ur->cause; - ulong isr; + ulong isr, vec; m->intr++; cause &= INTR7|INTR6|INTR5|INTR4|INTR3|INTR2|INTR1|INTR0; @@ -319,8 +319,9 @@ intr(Ureg *ur) } if(cause & INTR2) { isr = IO(ulong, R4030Isr); + if(isr & (1<<5)) { - audiointr(); + audiodmaintr(); isr &= ~(1<<5); } if(isr) { @@ -334,7 +335,22 @@ intr(Ureg *ur) } if(cause & INTR4) { devint = IO(uchar, I386ack); - iprint("i386ACK #%lux\n", devint); + vec = devint&~0x7; + + /* reenable the 8259 interrupt */ + if(vec == Int0vec || vec == Int1vec){ + EISAOUTB(Int0ctl, EOI); + if(vec == Int1vec) + EISAOUTB(Int1ctl, EOI); + } + switch(devint) { + default: + iprint("i386ACK #%lux\n", devint); + break; + case 5: + audiosbintr(); + break; + } cause &= ~INTR4; } if(cause & INTR7) { diff --git a/port/portdat.h b/port/portdat.h index b7280027f996df7fc40b470f3c07edf177077af4..33eff1c36396b30b76935dad7f177131a086da85 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -112,17 +112,17 @@ enum struct Path { Ref; - Path *hash; - Path *parent; - Pthash *pthash; + Path* hash; + Path* parent; + Pthash* pthash; char elem[NAMELEN]; }; struct Chan { Ref; - Chan *next; /* allocation */ - Chan *link; + Chan* next; /* allocation */ + Chan* link; ulong offset; /* in file */ ushort type; ushort dev; @@ -130,20 +130,20 @@ struct Chan ushort flag; Qid qid; int fid; /* for devmnt */ - Path *path; - Mount *mnt; /* mount point that derived Chan */ - Mount *xmnt; /* Last mount point crossed */ + Path* path; + Mount* mnt; /* mount point that derived Chan */ + Mount* xmnt; /* Last mount point crossed */ ulong mountid; Mntcache *mcp; /* Mount cache pointer */ union { - void *aux; + void* aux; Qid pgrpid; /* for #p/notepg */ - Mnt *mntptr; /* for devmnt */ + Mnt* mntptr; /* for devmnt */ ulong mid; /* for ns in devproc */ }; - Chan *mchan; /* channel to mounted server */ + Chan* mchan; /* channel to mounted server */ Qid mqid; /* qid of root of mount point */ - Session *session; + Session*session; }; struct Dev @@ -182,32 +182,32 @@ struct Pthash { QLock; int npt; - Path *root; - Path *hash[NSCACHE]; + Path* root; + Path* hash[NSCACHE]; }; -struct Mntwalk +struct Mntwalk /* state for /proc/#/ns */ { ulong id; - Mhead *mh; - Mount *cm; + Mhead* mh; + Mount* cm; }; struct Mount { ulong mountid; - Mount *next; - Mhead *head; - Chan *to; /* channel replacing channel */ + Mount* next; + Mhead* head; + Chan* to; /* channel replacing channel */ int flag; char spec[NAMELEN]; }; struct Mhead { - Chan *from; /* channel mounted upon */ - Mount *mount; /* what's mounted upon it */ - Mhead *hash; /* Hash chain */ + Chan* from; /* channel mounted upon */ + Mount* mount; /* what's mounted upon it */ + Mhead* hash; /* Hash chain */ }; struct Mnt diff --git a/port/portfns.h b/port/portfns.h index 7c4937f27ad6f8e5928045f1481159a9e4a3ce72..723a2fb42f3a5893b1b9e642c1fe9ea833c6abe6 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -24,6 +24,7 @@ void chandevreset(void); void chanfree(Chan*); void chanrec(Mnt*); void checkalarms(void); +void cinit(void); Chan* clone(Chan*, Chan*); void close(Chan*); void closeegrp(Egrp*); @@ -35,9 +36,13 @@ void confinit(void); void confinit1(int); int consactive(void); void consdebug(void); +void copen(Chan*); void copypage(Page*, Page*); +int cread(Chan*, uchar*, int, ulong); +void cupdate(Chan*, uchar*, int, ulong); void cursoroff(int); void cursoron(int); +void cwrite(Chan*, uchar*, int, ulong); int decref(Ref*); int decrypt(void*, void*, int); void delay(int); @@ -84,8 +89,8 @@ void gotolabel(Label*); int haswaitq(void*); long hostdomainwrite(char*, int); long hostownerwrite(char*, int); -void hwcursset(ulong*, ulong*, int, int); void hwcursmove(int, int); +void hwcursset(ulong*, ulong*, int, int); void iallocinit(void); long ibrk(ulong, int); int incref(Ref*); @@ -124,14 +129,14 @@ void mmurelease(Proc*); void mmuswitch(Proc*); void mntdump(void); void mntrepl(char*); -int mouseputc(int); -void mousetrack(int, int, int); int mount(Chan*, Chan*, int, char*); void mountfree(Mount*); void mousebuttons(int); void mouseclock(void); void mousectl(char*); +int mouseputc(int); void mousescreenupdate(void); +void mousetrack(int, int, int); int msize(void*); Chan* namec(char*, int, int, ulong); void nameok(char*); @@ -215,6 +220,7 @@ int screenbits(void); void screenupdate(void); int scsiexec(Target*, int, uchar*, int, void*, int); int scsiinv(int, int, Target**, uchar**, char*); +Target* scsiunit(int, int); long seconds(void); ulong segattach(Proc*, ulong, char *, ulong, ulong); void segpage(Segment*, Page*); @@ -249,6 +255,7 @@ Chan* walk(Chan*, char*, int); void wlock(RWlock*); void wunlock(RWlock*); void* xalloc(ulong); +void* xallocz(ulong, int); void xfree(void*); void xhole(ulong, ulong); void xinit(void); @@ -258,10 +265,3 @@ Segment* data2txt(Segment*); Segment* dupseg(Segment**, int, int); Segment* newseg(int, ulong, ulong); Segment* seg(Proc*, ulong, int); - - -int cread(Chan*, uchar*, int, ulong); -void cupdate(Chan*, uchar*, int, ulong); -void cwrite(Chan*, uchar*, int, ulong); -void copen(Chan*); -void cinit(void);