21#define RBR_REG (IO_BASE + 0)
22#define THR_REG (IO_BASE + 0)
23#define IER_REG (IO_BASE + 1)
26#define LS_REG (IO_BASE + 0)
27#define MS_REG (IO_BASE + 1)
30#define IIR_REG (IO_BASE + 2)
31#define FCR_REG (IO_BASE + 2)
32#define LCR_REG (IO_BASE + 3)
33#define MCR_REG (IO_BASE + 4)
34#define LSR_REG (IO_BASE + 5)
159 int base_rate = 1843200 / 16;
162 ASSERT (bps >= 300 && bps <= 115200);
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
void intr_register_ext(uint8_t vec_no, intr_handler_func *handler, const char *name)
Registers external interrupt VEC_NO to invoke HANDLER, which is named NAME for debugging purposes.
enum intr_level intr_disable(void)
Disables interrupts and returns the previous interrupt status.
enum intr_level intr_get_level(void)
Returns the current interrupt status.
enum intr_level intr_set_level(enum intr_level level)
Enables or disables interrupts as specified by LEVEL and returns the previous interrupt status.
void intr_handler_func(struct intr_frame *)
intr_level
Interrupts on or off?
@ INTR_OFF
Interrupts disabled.
bool intq_empty(const struct intq *q)
Returns true if Q is empty, false otherwise.
uint8_t intq_getc(struct intq *q)
Removes a byte from Q and returns it.
void intq_putc(struct intq *q, uint8_t byte)
Adds BYTE to the end of Q.
void intq_init(struct intq *q)
Initializes interrupt queue Q.
bool intq_full(const struct intq *q)
Returns true if Q is full, false otherwise.
static uint8_t inb(uint16_t port)
Reads and returns a byte from PORT.
static void outb(uint16_t port, uint8_t data)
Writes byte DATA to PORT.
void serial_flush(void)
Flushes anything in the serial buffer out the port in polling mode.
void serial_putc(uint8_t byte)
Sends BYTE to the serial port.
static void putc_poll(uint8_t)
Polls the serial port until it's ready, and then transmits BYTE.
#define LCR_DLAB
Divisor Latch Access Bit (DLAB).
static intr_handler_func serial_interrupt
#define MCR_OUT2
MODEM Control Register.
#define RBR_REG
DLAB=0 registers.
#define MS_REG
Divisor Latch (MSB).
static struct intq txq
Data to be transmitted.
#define LSR_REG
Line Status Register (read-only).
void serial_init_queue(void)
Initializes the serial port device for queued interrupt-driven I/O.
#define THR_REG
Transmitter Holding Reg.
#define IER_XMIT
Interrupt when transmit finishes.
static enum @0 mode
Transmission mode.
#define LCR_REG
Line Control Register.
#define IIR_REG
DLAB-insensitive registers.
#define LSR_THRE
THR Empty.
static void init_poll(void)
Initializes the serial port device for polling mode.
#define FCR_REG
FIFO Control Reg.
#define LCR_N81
Line Control Register bits.
#define LS_REG
DLAB=1 registers.
static void write_ier(void)
Update interrupt enable register.
#define IER_REG
Interrupt Enable Reg.
#define MCR_REG
MODEM Control Register.
void serial_notify(void)
The fullness of the input buffer may have changed.
#define LSR_DR
Line Status Register.
static void set_serial(int bps)
Configures the serial port for BPS bits per second.
#define IER_RECV
Interrupt Enable Register bits.
unsigned short int uint16_t
A circular queue of bytes.