#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <bool.h>
#include <fibril_synch.h>
#include <stdlib.h>
#include <str.h>
#include <ctype.h>
#include <macros.h>
#include <malloc.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <ddi.h>
#include <libarch/ddi.h>
#include <ddf/driver.h>
#include <ddf/interrupt.h>
#include <ddf/log.h>
#include <ops/char_dev.h>
#include <devman.h>
#include <ipc/devman.h>
#include <device/hw_res.h>
#include <ipc/serial_ctl.h>
#include "cyclic_buffer.h"
Go to the source code of this file.
Data Structures | |
struct | ns8250 |
The driver data for the serial port devices. More... | |
Defines | |
#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 | 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_t * | ns8250_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. |
Definition in file ns8250.c.