|
|
1.1 ! root 1: #include "slu6850.h" ! 2: /* Package to turn the write-only control register of each of up to MAXSLU ! 3: MC6850 SLUs into effectively read-write registers, and also initialize ! 4: the SLU for 8 bits, no parity, 1 stop bit, no interrupts. To be ! 5: effective, all references to the control registers need to go ! 6: through this package. */ ! 7: ! 8: /* space for 3 saved regs-- */ ! 9: #define MAXSLU 3 ! 10: ! 11: static struct { ! 12: struct csr *csrptr; /* which SLU this is */ ! 13: char csrval; /* its current control reg val */ ! 14: }soft_control_reg[MAXSLU] = {0}; ! 15: ! 16: slu_init6850(csrptr) ! 17: struct csr *csrptr; /* ptr to device csr */ ! 18: { ! 19: int i; ! 20: ! 21: csrptr->cstat = SLURESET; /* initialize the device */ ! 22: for (i=0;i<10;i++) ; /* wait a bit */ ! 23: csrptr->cstat = SLUDEFAULT; ! 24: ! 25: /* lookup csr or set up new spot in array-- */ ! 26: for (i=0;i<MAXSLU;i++) { ! 27: if (soft_control_reg[i].csrptr == (struct csr *)0) { ! 28: soft_control_reg[i].csrptr = csrptr; /* new spot */ ! 29: break; ! 30: } else if (soft_control_reg[i].csrptr == csrptr) ! 31: break; ! 32: } ! 33: if (i<MAXSLU) ! 34: soft_control_reg[i].csrval = SLUDEFAULT; ! 35: else ! 36: panic("Too many SLU devs for soft_control_reg table"); ! 37: } ! 38: ! 39: get_control_reg6850(csrptr) ! 40: struct csr *csrptr; /* ptr to device csr */ ! 41: { ! 42: int i; ! 43: ! 44: for (i=0;i<MAXSLU;i++) ! 45: if (soft_control_reg[i].csrptr == csrptr) ! 46: return soft_control_reg[i].csrval; ! 47: panic("Bad csrptr or uninitialized SLU"); ! 48: } ! 49: ! 50: /* must be called to change control reg, so that software var is maintained */ ! 51: set_control_reg6850(csrptr,new_control) ! 52: struct csr *csrptr; ! 53: char new_control; ! 54: { ! 55: int i; ! 56: ! 57: for (i=0;i<MAXSLU;i++) ! 58: if (soft_control_reg[i].csrptr == csrptr) { ! 59: soft_control_reg[i].csrval = new_control; ! 60: break; ! 61: } ! 62: if (i==MAXSLU) ! 63: panic("Bad csrptr or uninitialized SLU"); ! 64: ! 65: csrptr->cstat = new_control; /* 6850--just one reg */ ! 66: return 0; ! 67: } ! 68:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.