#include "serial.h" /** serial_configure_line: * Configures the line of the given serial port. The port is set to have a * data length of 8 bits, no parity bits, one stop bit and break control * disabled. * * @param com The serial port to configure */ void serial_configure_line(unsigned short com) { /* Bit: | 7 | 6 | 5 4 3 | 2 | 1 0 | * Content: | d | b | prty | s | dl | * Value: | 0 | 0 | 0 0 0 | 0 | 1 1 | = 0x03 */ outb(SERIAL_LINE_COMMAND_PORT(com), 0x03); } void serial_configure_baud_rate(unsigned short com, unsigned short divisor) { outb(SERIAL_LINE_COMMAND_PORT(com), SERIAL_LINE_ENABLE_DLAB); outb(SERIAL_DATA_PORT(com), (divisor >> 8) & 0x00FF); outb(SERIAL_DATA_PORT(com), divisor & 0x00FF); } int serial_is_transmit_fifo_empty(unsigned int com) { /* 0x20 = 0010 0000 */ return inb(SERIAL_LINE_STATUS_PORT(com)) & 0x20; }