void trmOpen(dev_t dev, int flag) { int d; struct tty *tp; struct device *addr; d = minor(dev); if (d >= NUM_TERMINALS) { u.u_error = ENXIO; return; } tp = &terminal[d]; addr = TERM_BASE + d; tp->t_addr = (caddr_t) addr; tp->t_oproc = xmtStart; if ((tp->t_state & ISOPEN) == 0) { tp->t_state = ISOPEN | CARR_ON; tp->t_flags = EVENP | ECHO | XTABS | CRMOD; ttychars(tp); } setISR(2 * d + 0, xmtISR); setISR(2 * d + 1, rcvISR); addr->xmtCtrl = XMT_RDY; addr->rcvCtrl = RCV_IEN; ttyopen(dev, tp); }
void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) { static int ctrlCFlag,ctrlBFlag; _PM_ctrlCPtr = (uchar*)&ctrlCFlag; _PM_ctrlBPtr = (uchar*)&ctrlBFlag; getISR(0x1B, &_PM_prevBreak, &prevRealBreak); getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC); _PM_breakHandler = bh; setISR(0x1B, _PM_breakISR); setISR(0x23, _PM_ctrlCISR); }
int main(void) { unsigned char c; int n; printf("Keyboard Test:\n"); printf("initializing interrupts...\n"); initInterrupts(); printf("setting kbd ISR...\n"); setISR(4, kbdISR); printf("enabling kbd interrupt mask bit...\n"); setMask(getMask() | (1 << 4)); printf("enabling interrupts in kbd controller...\n"); kbdEnable(); n = 0; while (1) { while (charAvail == 0) ; disable(); c = charRead; charAvail = 0; enable(); printf("%02X ", c); if (++n == 24) { n = 0; printf("\n"); } } return 0; }
void initInterrupts(void) { int i; for (i = 0; i < 32; i++) { setISR(i, defaultISR); } }
/* * Initialize the disk driver. * Read the partition table. */ static void ideInitialize(void) { unsigned int totalSectors; /* determine disk size */ waitDiskReady(); totalSectors = *DISK_CAP; if (totalSectors == 0) { panic("IDE disk not found"); } /* read partition table */ readPartitionTable(); if (debugIdeDisk) { printf("IDE disk has %d (0x%X) sectors\n", totalSectors, totalSectors); showPartitionTable(); } /* disk queue is empty */ ideTab.b_actf = NULL; ideTab.b_actl = NULL; /* no disk operation in progress, no errors */ ideTab.b_active = 0; ideTab.b_errcnt = 0; /* set ISR and enable interrupts */ setISR(DISK_IRQ, ideISR); setMask(getMask() | (1 << DISK_IRQ)); /* the disk is now initialized */ ideInitialized = TRUE; }
void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) { static short critBuf[2]; _PM_critPtr = (uchar*)critBuf; getISR(0x24, &_PM_prevCritical, &prevRealCritical); _PM_critHandler = ch; setISR(0x24, _PM_criticalISR); }
ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) { /* Save the old CMOS real time clock values */ _PM_oldCMOSRegA = _PM_readCMOS(0x0A); _PM_oldCMOSRegB = _PM_readCMOS(0x0B); /* Set the real time clock interrupt handler */ getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC); _PM_rtcHandler = th; setISR(0x70, _PM_rtcISR); /* Program the real time clock default frequency */ PM_setRealTimeClockFrequency(frequency); /* Unmask IRQ8 in the PIC2 */ _PM_oldRTCPIC2 = PM_inpb(0xA1); PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); return true; }
void PMAPI PM_setKey15Handler(PM_key15Handler kh) { getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15); _PM_key15Handler = kh; setISR(0x15, _PM_key15ISR); }
void PMAPI PM_setKeyHandler(PM_intHandler kh) { getISR(0x9, &_PM_prevKey, &_PM_prevRealKey); _PM_keyHandler = kh; setISR(0x9, _PM_keyISR); }
void PMAPI PM_setTimerHandler(PM_intHandler th) { getISR(0x8, &_PM_prevTimer, &_PM_prevRealTimer); _PM_timerHandler = th; setISR(0x8, _PM_timerISR); }