//03F8-03FF ---- serial port (8250,8251,16450,16550,16550A,etc.)// same as 02E8,02F8 and 03E8
void serial_init (void) {
// Turn off the FIFO
outb(COM1+COM_FCR, 0); => outb(0x03FA,0)
// Set speed; requires DLAB latch(锁存器)
//Line Control Register, set Divisor latch access bit
outb(COM1+COM_LCR, COM_LCR_DLAB); => outb(0x03FB,0x80)
//Divisor Latch Low (DLAB=1)
outb(COM1+COM_DLL, (uint8_t)(115200/9600)); => outb(0x03F8,12)
//Divisor Latch High (DLAB=1)
outb(COM1+COM_DLM, 0); => outb(0x03F9,0)
// 8 data bits, 1 stop bit, parity off; turn off DLAB latch
outb(COM1+COM_LCR, COM_LCR_WLEN8 & ~COM_LCR_DLAB); => outb(0x03FB,0x03)
// set Modem Control Register: No modem controls
outb(COM1+COM_MCR, 0); => outb(0x03FC,0)
// set Interrupt Enable Register: Enable receiver data interrupt
outb(COM1+COM_IER, COM_IER_RDI); => outb(0x03F9,0x01)
// Clear any preexisting overrun indications and interrupts
// Serial port doesn't exist if COM_LSR returns 0xFF
serial_exists = (inb(COM1+COM_LSR) != 0xFF); => inb(0x03FD)
// ??
(void) inb(COM1+COM_IIR); => inb(0x03FA)
(void) inb(COM1+COM_RX); => inb(0x03F8)
}
阅读(1809) | 评论(0) | 转发(0) |