| plan 9 kernel history: overview | file list | diff list |
1994/1108/pc/ns16552.h (diff list | history)
| pc/ns16552.h on 1994/0902 | ||
| 1994/0902 | /* * PC specific code for the ns16552. It includes support for the 2 built * in uarts plus up to 5 MP-008 8 uart ISA cards. */ enum { Maxcard= 5, /* max serial cards */ UartFREQ= 1843200, Serial= 0, Modem= 1, }; #define uartwrreg(u,r,v) outb((u)->port + r, (u)->sticky[r] | (v)) #define uartrdreg(u,r) inb((u)->port + r) | |
| 1994/1108 | void ns16552setup(ulong, ulong, char*); | |
| 1994/0902 | /* * definition of an optional serial card */ typedef struct Scard { ISAConf; /* card configuration */ int first; /* number of first port */ } Scard; static Scard *scard[Maxcard]; /* configs for the serial card */ /* power management currently only makes sense on the AT&T safari */ static void uartpower(int dev, int onoff) { switch(dev){ case Modem: if(modem(onoff) < 0) print("can't turn %s modem speaker\n", onoff?"on":"off"); break; case Serial: if(serial(onoff) < 0) print("can't turn %s serial port power\n", onoff?"on":"off"); break; } } /* * handle an interrupt to a single uart */ static void ns16552intrx(Ureg *ur, void *arg) { USED(ur); ns16552intr((ulong)arg); } /* * interrupts from the multiport card, MP-008. A polling port * tells which of 8 devices interrupted. */ static void mp008intr(Ureg *ur, void *arg) { int i, loops; uchar n; Scard *mp; USED(ur); mp = arg; | |
| 1994/1006 | for(loops = 0; loops < 1024; loops++){ | |
| 1994/0902 | n = ~inb(mp->mem); if(n == 0) return; for(i = 0; n; i++){ if(n & 1) | |
| 1994/1006 | ns16552intrx(ur, (void*)(mp->first+i)); | |
| 1994/0902 | n >>= 1; } } } /* * install the uarts (called by reset) */ | |
| 1994/1007 | void | |
| 1994/0902 | ns16552install(void) { int i, j, port; | |
| 1994/1007 | char *p; | |
| 1994/0902 | Scard *sc; | |
| 1994/1108 | char name[NAMELEN]; | |
| 1994/1007 | static int already; | |
| 1994/0902 | ||
| 1994/1007 | if(already) return; already = 1; | |
| 1994/0902 | /* first two ports are always there and always the normal frequency */ | |
| 1994/1108 | ns16552setup(0x3F8, UartFREQ, "eia0"); | |
| 1994/0902 | setvec(Uart0vec, ns16552intrx, (void*)0); | |
| 1994/1108 | ns16552setup(0x2F8, UartFREQ, "eia1"); | |
| 1994/0902 | setvec(Uart1vec, ns16552intrx, (void*)1); | |
| 1994/1007 | /* set up a serial console */ p = getconf("console"); if(p) ns16552special(atoi(p), 9600, &kbdq, &printq, kbdcr2nl); | |
| 1994/0902 | /* the rest come out of plan9.ini */ for(i = 0; i < Maxcard; i++){ sc = scard[i] = xalloc(sizeof(Scard)); if(isaconfig("serial", i, sc) == 0){ xfree(sc); break; } if(strcmp(sc->type, "MP008") == 0 || strcmp(sc->type, "mp008") == 0){ /* * port gives base port address for uarts * irq is interrupt * mem is the polling port * size is the number of serial ports on the same polling port * freq is the baud rate generator frequency */ if(sc->size == 0) sc->size = 8; if(sc->freq == 0) sc->freq = UartFREQ; sc->first = nuart; setvec(Int0vec+sc->irq, mp008intr, sc); port = sc->port; for(j=0; j < sc->size; j++){ | |
| 1994/1108 | sprint(name, "eia%d%2.2d", i, j); ns16552setup(port, sc->freq, name); | |
| 1994/0902 | port += 8; } | |
| 1994/1106 | } else if(strcmp(sc->type, "com") == 0 || strcmp(sc->type, "COM") == 0){ | |
| 1994/0902 | /* * port gives base port address for the uart * irq is interrupt * freq is the baud rate generator frequency */ | |
| 1994/1106 | if(sc->freq == 0) sc->freq = UartFREQ; | |
| 1994/1108 | sprint(name, "eia%d00", i); ns16552setup(sc->port, sc->freq, name); | |
| 1994/0902 | setvec(Int0vec+sc->irq, ns16552intrx, (void*)(nuart-1)); } } } int iprint(char *fmt, ...) { char buf[PRINTSIZE]; int n; n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; screenputs(buf, n); return n; } | |