Serial port driver.

HelenOS serial port driver. More...

Files

file  cyclic_buffer.h
file  ns8250.c

Data Structures

struct  cyclic_buffer
struct  ns8250
 The driver data for the serial port devices. More...

Defines

#define BUF_LEN   256
#define DLAB_MASK   (1 << 7)
#define MAX_BAUD_RATE   115200
#define NAME   "ns8250"
#define NS8250(fnode)   ((ns8250_t *) ((fnode)->dev->driver_data))
 Obtain soft-state structure from function node.
#define NS8250_FROM_DEV(dnode)   ((ns8250_t *) ((dnode)->driver_data))
 Obtain soft-state structure from device node.
#define REG_COUNT   7

Typedefs

typedef ns8250 ns8250_t
 The driver data for the serial port devices.

Enumerations

enum  stop_bit_t { ONE_STOP_BIT, TWO_STOP_BITS }
 The number of stop bits used by the serial port. More...
enum  word_length_t
 The number of bits of one data unit send by the serial port.

Functions

static void buf_clear (cyclic_buffer_t *buf)
static bool buf_is_empty (cyclic_buffer_t *buf)
static uint8_t buf_pop_front (cyclic_buffer_t *buf)
static bool buf_push_back (cyclic_buffer_t *buf, uint8_t item)
static void clear_dlab (ioport8_t *port)
 Clear Divisor Latch Access Bit.
static void enable_dlab (ioport8_t *port)
 Set Divisor Latch Access Bit.
static bool is_transmit_empty (ioport8_t *port)
 Find out wheter it is possible to send data.
int main (int argc, char *argv[])
 Main entry point.
static int ns8250_add_device (ddf_dev_t *dev)
 The add_device callback method of the serial port driver.
static void ns8250_close (ddf_fun_t *fun)
 Close the device.
static void ns8250_default_handler (ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call)
 Default handler for client requests which are not handled by the standard interfaces.
static void ns8250_delete (ns8250_t *ns)
 Delete soft-state structure.
static void ns8250_dev_cleanup (ns8250_t *ns)
 Clean up the serial port soft-state.
static int ns8250_dev_initialize (ns8250_t *ns)
 Initialize serial port device.
static bool ns8250_dev_probe (ns8250_t *ns)
 Probe the serial port device for its presence.
static void ns8250_get_props (ddf_dev_t *dev, unsigned int *baud_rate, unsigned int *parity, unsigned int *word_length, unsigned int *stop_bits)
 Get parameters of the serial communication which are set to the specified device.
static void ns8250_init (void)
 Initialize the serial port driver.
static void ns8250_initialize_port (ns8250_t *ns)
 Initialize the serial port device.
static int ns8250_interrupt_enable (ns8250_t *ns)
 Enable interrupts for the serial port device.
static void ns8250_interrupt_handler (ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *icall)
 The interrupt handler.
static ns8250_tns8250_new (void)
 Create per-device soft-state structure.
static int ns8250_open (ddf_fun_t *fun)
 Open the device.
static bool ns8250_pio_enable (ns8250_t *ns)
 Enable the i/o ports of the device.
static unsigned int ns8250_port_get_baud_rate (ioport8_t *port)
 Get baud rate used by the serial port device.
static void ns8250_port_get_com_props (ioport8_t *port, unsigned int *parity, unsigned int *word_length, unsigned int *stop_bits)
 Get the parameters of the serial communication set on the serial port device.
static void ns8250_port_interrupts_disable (ioport8_t *port)
 Disable interrupts on the serial port device.
static void ns8250_port_interrupts_enable (ioport8_t *port)
 Enable interrupts on the serial port device.
static int ns8250_port_set_baud_rate (ioport8_t *port, unsigned int baud_rate)
 Set baud rate of the serial communication on the serial device.
static int ns8250_port_set_com_props (ioport8_t *port, unsigned int parity, unsigned int word_length, unsigned int stop_bits)
 Set the parameters of the serial communication on the serial port device.
static void ns8250_putchar (ns8250_t *ns, uint8_t c)
 Write a character to the serial port.
static int ns8250_read (ddf_fun_t *fun, char *buf, size_t count)
 Read data from the serial port device.
static uint8_t ns8250_read_8 (ioport8_t *port)
 Read one byte from the serial port.
static void ns8250_read_from_device (ns8250_t *ns)
 Read the data from the serial port device and store them to the input buffer.
static bool ns8250_received (ioport8_t *port)
 Find out if there is some incomming data available on the serial port.
static int ns8250_register_interrupt_handler (ns8250_t *ns)
 Register the interrupt handler for the device.
static int ns8250_set_props (ddf_dev_t *dev, unsigned int baud_rate, unsigned int parity, unsigned int word_length, unsigned int stop_bits)
 Set parameters of the serial communication to the specified serial port device.
static int ns8250_unregister_interrupt_handler (ns8250_t *ns)
 Unregister the interrupt handler for the device.
static int ns8250_write (ddf_fun_t *fun, char *buf, size_t count)
 Write data to the serial port.
static void ns8250_write_8 (ioport8_t *port, uint8_t c)
 Write one character on the serial port.

Variables

static char_dev_ops_t ns8250_char_dev_ops
 The character interface's callbacks.
static ddf_dev_ops_t ns8250_dev_ops
static driver_t ns8250_driver
 The serial port device driver structure.
static driver_ops_t ns8250_ops
 The serial port device driver's standard operations.

Detailed Description

HelenOS serial port driver.


Enumeration Type Documentation

enum stop_bit_t

The number of stop bits used by the serial port.

Enumerator:
ONE_STOP_BIT  Use one stop bit.
TWO_STOP_BITS  1.5 stop bits for word length 5, 2 stop bits otherwise.

Definition at line 88 of file ns8250.c.


Function Documentation

static void clear_dlab ( ioport8_t port  )  [inline, static]

Clear Divisor Latch Access Bit.

Parameters:
port The base address of the serial port device's ports.

Definition at line 456 of file ns8250.c.

static void enable_dlab ( ioport8_t port  )  [inline, static]

Set Divisor Latch Access Bit.

When the Divisor Latch Access Bit is set, it is possible to set baud rate of the serial port device.

Parameters:
port The base address of the serial port device's ports.

Definition at line 446 of file ns8250.c.

static bool is_transmit_empty ( ioport8_t port  )  [static]

Find out wheter it is possible to send data.

Parameters:
port The base address of the serial port device's ports.

Definition at line 166 of file ns8250.c.

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 954 of file ns8250.c.

static int ns8250_add_device ( ddf_dev_t dev  )  [static]

The add_device callback method of the serial port driver.

Probe and initialize the newly added device.

Parameters:
dev The serial port device.

Definition at line 712 of file ns8250.c.

static void ns8250_close ( ddf_fun_t fun  )  [static]

Close the device.

This is a callback function called when a client tries to disconnect from the device.

Parameters:
dev The device.

Definition at line 830 of file ns8250.c.

static void ns8250_default_handler ( ddf_fun_t fun,
ipc_callid_t  callid,
ipc_call_t call 
) [static]

Default handler for client requests which are not handled by the standard interfaces.

Configure the parameters of the serial communication.

Definition at line 908 of file ns8250.c.

static void ns8250_delete ( ns8250_t ns  )  [static]

Delete soft-state structure.

Parameters:
ns The driver data structure.

Definition at line 135 of file ns8250.c.

static void ns8250_dev_cleanup ( ns8250_t ns  )  [static]

Clean up the serial port soft-state.

Parameters:
ns Serial port device

Definition at line 263 of file ns8250.c.

static int ns8250_dev_initialize ( ns8250_t ns  )  [static]

Initialize serial port device.

Parameters:
ns Serial port device
Returns:
Zero on success, negative error number otherwise

Definition at line 329 of file ns8250.c.

static bool ns8250_dev_probe ( ns8250_t ns  )  [static]

Probe the serial port device for its presence.

Parameters:
ns Serial port device
Returns:
True if the device is present, false otherwise

Definition at line 296 of file ns8250.c.

static void ns8250_get_props ( ddf_dev_t dev,
unsigned int *  baud_rate,
unsigned int *  parity,
unsigned int *  word_length,
unsigned int *  stop_bits 
) [static]

Get parameters of the serial communication which are set to the specified device.

Parameters:
dev The serial port device.
baud_rate The baud rate used by the device.
parity The type of parity used by the device.
word_length The size of one data unit in bits.
stop_bits The number of stop bits used.

Definition at line 854 of file ns8250.c.

static void ns8250_init ( void   )  [static]

Initialize the serial port driver.

Initialize device operations structures with callback methods for handling client requests to the serial port devices.

Definition at line 943 of file ns8250.c.

static void ns8250_initialize_port ( ns8250_t ns  )  [static]

Initialize the serial port device.

Set the default parameters of the serial communication.

Parameters:
ns Serial port device

Definition at line 621 of file ns8250.c.

static int ns8250_interrupt_enable ( ns8250_t ns  )  [static]

Enable interrupts for the serial port device.

Parameters:
ns Serial port device
Returns:
Zero on success, negative error number otherwise

Definition at line 431 of file ns8250.c.

static void ns8250_interrupt_handler ( ddf_dev_t dev,
ipc_callid_t  iid,
ipc_call_t icall 
) [inline, static]

The interrupt handler.

The serial port is initialized to interrupt when some data come, so the interrupt is handled by reading the incomming data.

Parameters:
dev The serial port device.

Definition at line 681 of file ns8250.c.

static ns8250_t* ns8250_new ( void   )  [static]

Create per-device soft-state structure.

Returns:
Pointer to soft-state structure.

Definition at line 119 of file ns8250.c.

static int ns8250_open ( ddf_fun_t fun  )  [static]

Open the device.

This is a callback function called when a client tries to connect to the device.

Parameters:
dev The device.

Definition at line 806 of file ns8250.c.

static bool ns8250_pio_enable ( ns8250_t ns  )  [static]

Enable the i/o ports of the device.

Parameters:
ns Serial port device
Returns:
True on success, false otherwise

Definition at line 276 of file ns8250.c.

static unsigned int ns8250_port_get_baud_rate ( ioport8_t port  )  [static]

Get baud rate used by the serial port device.

Parameters:
port The base address of the serial port device's ports.
baud_rate The ouput parameter to which the baud rate is stored.

Definition at line 502 of file ns8250.c.

static void ns8250_port_get_com_props ( ioport8_t port,
unsigned int *  parity,
unsigned int *  word_length,
unsigned int *  stop_bits 
) [static]

Get the parameters of the serial communication set on the serial port device.

Parameters:
parity The parity used.
word_length The length of one data unit in bits.
stop_bits The number of stop bits used (one or two).

Definition at line 528 of file ns8250.c.

static void ns8250_port_interrupts_disable ( ioport8_t port  )  [inline, static]

Disable interrupts on the serial port device.

Parameters:
port The base address of the serial port device's ports

Definition at line 421 of file ns8250.c.

static void ns8250_port_interrupts_enable ( ioport8_t port  )  [inline, static]

Enable interrupts on the serial port device.

Interrupt when data is received

Parameters:
port The base address of the serial port device's ports.

Definition at line 411 of file ns8250.c.

static int ns8250_port_set_baud_rate ( ioport8_t port,
unsigned int  baud_rate 
) [static]

Set baud rate of the serial communication on the serial device.

Parameters:
port The base address of the serial port device's ports.
baud_rate The baud rate to be used by the device.
Returns:
Zero on success, negative error number otherwise (EINVAL if the specified baud_rate is not valid).

Definition at line 469 of file ns8250.c.

static int ns8250_port_set_com_props ( ioport8_t port,
unsigned int  parity,
unsigned int  word_length,
unsigned int  stop_bits 
) [static]

Set the parameters of the serial communication on the serial port device.

Parameters:
parity The parity to be used.
word_length The length of one data unit in bits.
stop_bits The number of stop bits used (one or two).
Returns:
Zero on success, EINVAL if some of the specified values is invalid.

Definition at line 565 of file ns8250.c.

static void ns8250_putchar ( ns8250_t ns,
uint8_t  c 
) [inline, static]

Write a character to the serial port.

Parameters:
ns Serial port device
c The character to be written

Definition at line 213 of file ns8250.c.

static int ns8250_read ( ddf_fun_t fun,
char *  buf,
size_t  count 
) [static]

Read data from the serial port device.

Parameters:
fun The serial port function
buf The ouput buffer for read data.
count The number of bytes to be read.
Returns:
The number of bytes actually read on success, negative error number otherwise.

Definition at line 193 of file ns8250.c.

static uint8_t ns8250_read_8 ( ioport8_t port  )  [static]

Read one byte from the serial port.

Parameters:
port The base address of the serial port device's ports.
Returns:
The data read.

Definition at line 157 of file ns8250.c.

static void ns8250_read_from_device ( ns8250_t ns  )  [static]

Read the data from the serial port device and store them to the input buffer.

Parameters:
ns Serial port device

Definition at line 645 of file ns8250.c.

static bool ns8250_received ( ioport8_t port  )  [static]

Find out if there is some incomming data available on the serial port.

Parameters:
port The base address of the serial port device's ports.
Returns:
True if there are data waiting to be read, false otherwise.

Definition at line 147 of file ns8250.c.

static int ns8250_register_interrupt_handler ( ns8250_t ns  )  [inline, static]

Register the interrupt handler for the device.

Parameters:
ns Serial port device

Definition at line 691 of file ns8250.c.

static int ns8250_set_props ( ddf_dev_t dev,
unsigned int  baud_rate,
unsigned int  parity,
unsigned int  word_length,
unsigned int  stop_bits 
) [static]

Set parameters of the serial communication to the specified serial port device.

Parameters:
dev The serial port device.
baud_rate The baud rate to be used by the device.
parity The type of parity to be used by the device.
word_length The size of one data unit in bits.
stop_bits The number of stop bits to be used.

Definition at line 881 of file ns8250.c.

static int ns8250_unregister_interrupt_handler ( ns8250_t ns  )  [inline, static]

Unregister the interrupt handler for the device.

Parameters:
ns Serial port device

Definition at line 701 of file ns8250.c.

static int ns8250_write ( ddf_fun_t fun,
char *  buf,
size_t  count 
) [static]

Write data to the serial port.

Parameters:
fun The serial port function
buf The data to be written
count The number of bytes to be written
Returns:
Zero on success

Definition at line 227 of file ns8250.c.

static void ns8250_write_8 ( ioport8_t port,
uint8_t  c 
) [static]

Write one character on the serial port.

Parameters:
port The base address of the serial port device's ports.
c The character to be written to the serial port device.

Definition at line 176 of file ns8250.c.


Generated on Thu Jun 2 07:45:56 2011 for HelenOS/USB by  doxygen 1.4.7