MyOS Kernel
serial.c File Reference
#include <cpu/ports.h>

Macros

#define DATA_PORT(com)   (data_ports[com])
 Returns the data port of a serial port.
 
#define INT_PORT(com)   (DATA_PORT(com)+1)
 Returns the interrupt config port of a serial port.
 
#define FIFO_PORT(com)   (DATA_PORT(com)+2)
 Returns the fifo config port of a serial port.
 
#define LINE_CMD_PORT(com)   (DATA_PORT(com)+3)
 Returns the line cmd port of a serial port.
 
#define MODEM_CMD_PORT(com)   (DATA_PORT(com)+4)
 Returns the modem cmd port of a serial port.
 
#define LINE_STAT_PORT(com)   (DATA_PORT(com)+5)
 Returns the line status port of a serial port.
 
#define SCRATCH_PORT(com)   (DATA_PORT(com)+7)
 Returns the scratch port of a serial port.
 
#define IS_TRANSMIT_FIFO_EMPTY(com)   (port_byte_in(LINE_STAT_PORT(com))&0x20)
 Returns whether the trasmit FIFO is empty.
 

Functions

static void configure (int com, int rate)
 
void serial_init ()
 
void serial_putc (char c)
 

Variables

static char configured [] ={0,0,0,0}
 What serial ports have been detected and configured.
 
static int data_ports [4] ={0x3f8,0x2f8,0x3e8,0x2e8}
 List of the data ports for all the potential serial ports.
 

Function Documentation

◆ configure()

static void configure ( int  com,
int  rate 
)
static

Configure a serial port with a specified baud rate.

Parameters
comThe number of the serial port to configure
rateThe baud rate to set the serial port to.

◆ serial_init()

void serial_init ( )

Initialize the serial driver

◆ serial_putc()

void serial_putc ( char  c)

Write a character to the serial port

Parameters
cThe character to write