int scrollDown( void ) { byte high, low; word address; int ret = 0; outByte( 0x3D4u, 0x0Cu ); high = inByte( 0x3D5u ); outByte( 0x3D4u, 0x0Du ); low = inByte( 0x3D5u ); address = (high << 8 | low ); address += 0x50u; if( address > 0x3e80u ) { address = 0; ret = 1; } outByte( 0x3D4u, 0x0Cu ); outByte( 0x3D5u, address >> 8 ); outByte( 0x3D4u, 0x0Du ); outByte( 0x3D5u, address & 0xFFu ); return ret; }
void init_serial(void) { outByte(combase + 3, inByte(combase + 3) | 0x80u); // Set DLAB for // DLLB access outByte(combase, 0x03u); /* 38400 baud */ outByte(combase + 1, 0u); // Disable interrupts outByte(combase + 3, inByte(combase + 3) & 0x7fu); // Clear DLAB outByte(combase + 3, 3u); // 8-N-1 }
void intHandler2e() { inByte(REG_STATUS); outByte(0x20, 0xA0); isHardDiskReady = TRUE; return; }
void putDebugChar(int ch) { while (!(inByte(combase + 5) & 0x20u)); outByte(combase, (byte) ch); /* if( ch == '\r' ) { sx=0; sy++; if( sy >= SCREEN_HEIGHT ) scrollDown(); } else if( ch == '\t' ) { sx +=8; } else { putChar(ch,sx,sy); sx++; } if( sx >= SCREEN_WIDTH ) { sx=0; sy++; if( sy >= SCREEN_HEIGHT ) scrollDown(); } */ }
void intHandler21() { outByte(PIC0_OCW2, 0x61); u8 data = inByte(PORT_KEYDATA); putQueueBuffer(&systemBuffer, data+1024); return; }
void waitKBCReady() { while (TRUE) { if ((inByte(PORT_KEYSTAT) & KEYSTA_SEND_NOTREADY) == 0) { break; } } return; }
void intHandler2c() { u32 data; outByte(PIC1_OCW2, 0x64); outByte(PIC0_OCW2, 0x62); data = inByte(PORT_KEYDATA) + 2048; putQueueBuffer(&systemBuffer, data); switchKernelProcess(); }
bool waitForStatus(int mask, int val, int timeout) { long time = getTime(); while((getTime() - time)<timeout) { if ((inByte(REG_STATUS) & mask) == val) { return TRUE; } } return FALSE; }
void scrollUp( void ) { byte high, low; word address; outByte( 0x3D4u, 0x0Cu ); high = inByte( 0x3D5u ); outByte( 0x3D4u, 0x0Du ); low = inByte( 0x3D5u ); address = (high << 8 | low ); if( address == 0 ) address = 0x3fc0u; else address -= 0x50u; outByte( 0x3D4u, 0x0Cu ); outByte( 0x3D5u, address >> 8 ); outByte( 0x3D4u, 0x0Du ); outByte( 0x3D5u, address & 0xFFu ); }
void disableIRQ( unsigned int irq ) { byte data; if( irq > 15 ) return; if( irq < 8 ) { data = inByte( (word)0x21 ); ioWait(); outByte( (word)0x21, data | (byte)(1u << irq)); ioWait(); } else { data = inByte( (word)0xA1 ); ioWait(); outByte( (word)0xA1, data | (byte)(1u << (irq-8))); ioWait(); } }
void enableIRQ( unsigned int irq ) { byte data; if( irq > 15 ) return; if( irq < 8 ) { data = inByte( (word)0x21u ); ioWait(); outByte( (word)0x21u, data & (byte)~(1u << irq)); ioWait(); } else { data = inByte( (word)0xA1u ); ioWait(); outByte( (word)0xA1u, data & (byte)~(1u << (irq-8))); ioWait(); } }
byte ser_read_intid(word port) { return inByte(port + INT_ID); }
byte ser_line_stat(word port) { return inByte(port + LINE_STATUS); }
void set_dlab(byte bit, word port) { bit &= 1; outByte(LINE_CTRL + port, (inByte(LINE_CTRL + port) & 0x7F) | (bit << 7)); }
byte ser_read_buffer(word port) { set_dlab(0, port); return inByte(port + RECEIVER_BUFF); }
int getDebugChar(void) { while (!(inByte(combase + 5) & 0x01u)); return inByte(combase); }