CS318 - Pintos
Pintos source browser for JHU CS318 course
|
Go to the documentation of this file.
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);
static void set_serial(int bps)
Configures the serial port for BPS bits per second.
#define LSR_DR
Line Status Register.
#define IIR_REG
DLAB-insensitive registers.
#define LCR_N81
Line Control Register bits.
#define LCR_REG
Line Control Register.
#define IER_XMIT
Interrupt when transmit finishes.
static enum @0 mode
Transmission mode.
intr_level
Interrupts on or off?
#define LCR_DLAB
Divisor Latch Access Bit (DLAB).
bool intq_empty(const struct intq *q)
Returns true if Q is empty, false otherwise.
static intr_handler_func serial_interrupt
#define IER_REG
Interrupt Enable Reg.
enum intr_level intr_set_level(enum intr_level level)
Enables or disables interrupts as specified by LEVEL and returns the previous interrupt status.
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
#define THR_REG
Transmitter Holding Reg.
unsigned short int uint16_t
static void init_poll(void)
Initializes the serial port device for polling mode.
#define MCR_REG
MODEM Control Register.
void intq_init(struct intq *q)
Initializes interrupt queue Q.
uint8_t intq_getc(struct intq *q)
Removes a byte from Q and returns it.
#define LSR_THRE
THR Empty.
enum intr_level intr_get_level(void)
Returns the current interrupt status.
#define MS_REG
Divisor Latch (MSB).
#define LS_REG
DLAB=1 registers.
#define RBR_REG
DLAB=0 registers.
void intq_putc(struct intq *q, uint8_t byte)
Adds BYTE to the end of Q.
void serial_notify(void)
The fullness of the input buffer may have changed.
bool intq_full(const struct intq *q)
Returns true if Q is full, false otherwise.
#define LSR_REG
Line Status Register (read-only).
void intr_handler_func(struct intr_frame *)
static void putc_poll(uint8_t)
Polls the serial port until it's ready, and then transmits BYTE.
enum intr_level intr_disable(void)
Disables interrupts and returns the previous interrupt status.
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
static void write_ier(void)
Update interrupt enable register.
static void outb(uint16_t port, uint8_t data)
Writes byte DATA to PORT.
A circular queue of bytes.
static uint8_t inb(uint16_t port)
Reads and returns a byte from PORT.
#define IER_RECV
Interrupt Enable Register bits.
#define FCR_REG
FIFO Control Reg.
void serial_putc(uint8_t byte)
Sends BYTE to the serial port.
#define MCR_OUT2
MODEM Control Register.
void serial_init_queue(void)
Initializes the serial port device for queued interrupt-driven I/O.
void serial_flush(void)
Flushes anything in the serial buffer out the port in polling mode.
static struct intq txq
Data to be transmitted.
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.