#include "devices/serial.h"
#include <debug.h>
#include "devices/input.h"
#include "devices/intq.h"
#include "devices/timer.h"
#include "threads/io.h"
#include "threads/interrupt.h"
#include "threads/synch.h"
#include "threads/thread.h"
Go to the source code of this file.
Defines | |
#define | IO_BASE 0x3f8 |
#define | RBR_REG (IO_BASE + 0) |
#define | THR_REG (IO_BASE + 0) |
#define | IER_REG (IO_BASE + 1) |
#define | LS_REG (IO_BASE + 0) |
#define | MS_REG (IO_BASE + 1) |
#define | IIR_REG (IO_BASE + 2) |
#define | FCR_REG (IO_BASE + 2) |
#define | LCR_REG (IO_BASE + 3) |
#define | MCR_REG (IO_BASE + 4) |
#define | LSR_REG (IO_BASE + 5) |
#define | IER_RECV 0x01 |
#define | IER_XMIT 0x02 |
#define | LCR_N81 0x03 |
#define | LCR_DLAB 0x80 |
#define | MCR_OUT2 0x08 |
#define | LSR_DR 0x01 |
#define | LSR_THRE 0x20 |
Enumerations | |
enum | { UNINIT, POLL, QUEUE } |
Functions | |
static void | set_serial (int bps) |
static void | putc_poll (uint8_t) |
static void | write_ier (void) |
static void | init_poll (void) |
void | serial_init_queue (void) |
void | serial_putc (uint8_t byte) |
void | serial_flush (void) |
void | serial_notify (void) |
static void | serial_interrupt (struct intr_frame *f UNUSED) |
Variables | |
static enum { ... } | mode |
static struct intq | txq |
static intr_handler_func | serial_interrupt |
#define FCR_REG (IO_BASE + 2) |
#define IER_RECV 0x01 |
#define IER_REG (IO_BASE + 1) |
#define IER_XMIT 0x02 |
#define IIR_REG (IO_BASE + 2) |
#define LCR_DLAB 0x80 |
#define LCR_N81 0x03 |
#define LCR_REG (IO_BASE + 3) |
#define LS_REG (IO_BASE + 0) |
#define LSR_DR 0x01 |
#define LSR_REG (IO_BASE + 5) |
#define LSR_THRE 0x20 |
#define MCR_OUT2 0x08 |
#define MCR_REG (IO_BASE + 4) |
#define MS_REG (IO_BASE + 1) |
#define RBR_REG (IO_BASE + 0) |
#define THR_REG (IO_BASE + 0) |
static void init_poll | ( | void | ) | [static] |
Definition at line 68 of file serial.c.
References ASSERT, FCR_REG, IER_REG, intq_init(), MCR_OUT2, MCR_REG, mode, outb(), POLL, set_serial(), txq, and UNINIT.
Referenced by serial_init_queue(), and serial_putc().
static void putc_poll | ( | uint8_t | byte | ) | [static] |
Definition at line 200 of file serial.c.
References ASSERT, inb(), intr_get_level(), INTR_OFF, LSR_REG, LSR_THRE, outb(), and THR_REG.
Referenced by serial_flush(), and serial_putc().
void serial_flush | ( | void | ) |
Definition at line 136 of file serial.c.
References intq_empty(), intq_getc(), intr_disable(), intr_set_level(), putc_poll(), and txq.
Referenced by debug_panic(), and power_off().
void serial_init_queue | ( | void | ) |
Definition at line 83 of file serial.c.
References ASSERT, init_poll(), intr_disable(), intr_register_ext(), intr_set_level(), mode, POLL, QUEUE, serial_interrupt, UNINIT, and write_ier().
Referenced by main().
static void serial_interrupt | ( | struct intr_frame *f | UNUSED | ) | [static] |
Definition at line 211 of file serial.c.
References IIR_REG, inb(), input_full(), input_putc(), intq_empty(), intq_getc(), LSR_DR, LSR_REG, LSR_THRE, outb(), RBR_REG, THR_REG, txq, and write_ier().
void serial_notify | ( | void | ) |
Definition at line 149 of file serial.c.
References ASSERT, intr_get_level(), INTR_OFF, mode, QUEUE, and write_ier().
Referenced by input_getc(), and input_putc().
void serial_putc | ( | uint8_t | byte | ) |
Definition at line 100 of file serial.c.
References init_poll(), intq_full(), intq_getc(), intq_putc(), intr_disable(), INTR_OFF, intr_set_level(), mode, putc_poll(), QUEUE, txq, UNINIT, and write_ier().
Referenced by putchar_have_lock().
static void set_serial | ( | int | bps | ) | [static] |
static void write_ier | ( | void | ) | [static] |
Definition at line 178 of file serial.c.
References ASSERT, IER_RECV, IER_REG, IER_XMIT, input_full(), intq_empty(), intr_get_level(), INTR_OFF, outb(), and txq.
Referenced by serial_init_queue(), serial_interrupt(), serial_notify(), and serial_putc().
enum { ... } mode [static] |
Referenced by init_poll(), serial_init_queue(), serial_notify(), and serial_putc().
intr_handler_func serial_interrupt [static] |
Definition at line 56 of file serial.c.
Referenced by init_poll(), serial_flush(), serial_interrupt(), serial_putc(), and write_ier().