Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
serial_core.h File Reference
#include <linux/compiler.h>
#include <linux/interrupt.h>
#include <linux/circ_buf.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/mutex.h>
#include <linux/sysrq.h>
#include <linux/pps_kernel.h>
#include <uapi/linux/serial_core.h>

Go to the source code of this file.

Data Structures

struct  uart_ops
struct  uart_icount
struct  uart_port
struct  uart_state
struct  uart_driver


#define NO_POLL_CHAR   0x00ff0000
#define UART_CONFIG_TYPE   (1 << 0)
#define UART_CONFIG_IRQ   (1 << 1)
#define UPIO_PORT   (0)
#define UPIO_HUB6   (1)
#define UPIO_MEM   (2)
#define UPIO_MEM32   (3)
#define UPIO_AU   (4) /* Au1x00 type IO */
#define UPIO_TSI   (5) /* Tsi108/109 type IO */
#define UPIO_RM9000   (6) /* RM9000 type IO */
#define UPF_FOURPORT   ((__force upf_t) (1 << 1))
#define UPF_SAK   ((__force upf_t) (1 << 2))
#define UPF_SPD_MASK   ((__force upf_t) (0x1030))
#define UPF_SPD_HI   ((__force upf_t) (0x0010))
#define UPF_SPD_VHI   ((__force upf_t) (0x0020))
#define UPF_SPD_CUST   ((__force upf_t) (0x0030))
#define UPF_SPD_SHI   ((__force upf_t) (0x1000))
#define UPF_SPD_WARP   ((__force upf_t) (0x1010))
#define UPF_SKIP_TEST   ((__force upf_t) (1 << 6))
#define UPF_AUTO_IRQ   ((__force upf_t) (1 << 7))
#define UPF_HARDPPS_CD   ((__force upf_t) (1 << 11))
#define UPF_LOW_LATENCY   ((__force upf_t) (1 << 13))
#define UPF_BUGGY_UART   ((__force upf_t) (1 << 14))
#define UPF_NO_TXEN_TEST   ((__force upf_t) (1 << 15))
#define UPF_MAGIC_MULTIPLIER   ((__force upf_t) (1 << 16))
#define UPF_CONS_FLOW   ((__force upf_t) (1 << 23))
#define UPF_SHARE_IRQ   ((__force upf_t) (1 << 24))
#define UPF_EXAR_EFR   ((__force upf_t) (1 << 25))
#define UPF_BUG_THRE   ((__force upf_t) (1 << 26))
#define UPF_FIXED_TYPE   ((__force upf_t) (1 << 27))
#define UPF_BOOT_AUTOCONF   ((__force upf_t) (1 << 28))
#define UPF_FIXED_PORT   ((__force upf_t) (1 << 29))
#define UPF_DEAD   ((__force upf_t) (1 << 30))
#define UPF_IOREMAP   ((__force upf_t) (1 << 31))
#define UPF_CHANGE_MASK   ((__force upf_t) (0x17fff))
#define UPF_USR_MASK   ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
#define WAKEUP_CHARS   256
#define uart_circ_empty(circ)   ((circ)->head == (circ)->tail)
#define uart_circ_clear(circ)   ((circ)->head = (circ)->tail = 0)
#define uart_circ_chars_pending(circ)   (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE))
#define uart_circ_chars_free(circ)   (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))
#define uart_handle_sysrq_char(port, ch)   ({ (void)port; 0; })
#define UART_ENABLE_MS(port, cflag)


typedef unsigned int __bitwise__ upf_t


void uart_write_wakeup (struct uart_port *port)
void uart_update_timeout (struct uart_port *port, unsigned int cflag, unsigned int baud)
unsigned int uart_get_baud_rate (struct uart_port *port, struct ktermios *termios, struct ktermios *old, unsigned int min, unsigned int max)
unsigned int uart_get_divisor (struct uart_port *port, unsigned int baud)
struct uart_portuart_get_console (struct uart_port *ports, int nr, struct console *c)
void uart_parse_options (char *options, int *baud, int *parity, int *bits, int *flow)
int uart_set_options (struct uart_port *port, struct console *co, int baud, int parity, int bits, int flow)
struct tty_driveruart_console_device (struct console *co, int *index)
void uart_console_write (struct uart_port *port, const char *s, unsigned int count, void(*putchar)(struct uart_port *, int))
int uart_register_driver (struct uart_driver *uart)
void uart_unregister_driver (struct uart_driver *uart)
int uart_add_one_port (struct uart_driver *reg, struct uart_port *port)
int uart_remove_one_port (struct uart_driver *reg, struct uart_port *port)
int uart_match_port (struct uart_port *port1, struct uart_port *port2)
int uart_suspend_port (struct uart_driver *reg, struct uart_port *port)
int uart_resume_port (struct uart_driver *reg, struct uart_port *port)
void uart_handle_dcd_change (struct uart_port *uport, unsigned int status)
void uart_handle_cts_change (struct uart_port *uport, unsigned int status)
void uart_insert_char (struct uart_port *port, unsigned int status, unsigned int overrun, unsigned int ch, unsigned int flag)

Macro Definition Documentation

#define NO_POLL_CHAR   0x00ff0000

Definition at line 89 of file serial_core.h.

#define uart_circ_chars_free (   circ)    (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))

Definition at line 298 of file serial_core.h.

#define uart_circ_chars_pending (   circ)    (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE))

Definition at line 295 of file serial_core.h.

#define uart_circ_clear (   circ)    ((circ)->head = (circ)->tail = 0)

Definition at line 293 of file serial_core.h.

#define uart_circ_empty (   circ)    ((circ)->head == (circ)->tail)

Definition at line 292 of file serial_core.h.

#define UART_CONFIG_IRQ   (1 << 1)

Definition at line 91 of file serial_core.h.

#define UART_CONFIG_TYPE   (1 << 0)

Definition at line 90 of file serial_core.h.

#define UART_ENABLE_MS (   port,
(cflag) & CRTSCTS || \
!((cflag) & CLOCAL))

Definition at line 366 of file serial_core.h.

#define uart_handle_sysrq_char (   port,
)    ({ (void)port; 0; })

Definition at line 336 of file serial_core.h.


Definition at line 217 of file serial_core.h.

#define UPF_AUTO_IRQ   ((__force upf_t) (1 << 7))

Definition at line 160 of file serial_core.h.

#define UPF_BOOT_AUTOCONF   ((__force upf_t) (1 << 28))

Definition at line 172 of file serial_core.h.

#define UPF_BUG_THRE   ((__force upf_t) (1 << 26))

Definition at line 169 of file serial_core.h.

#define UPF_BUGGY_UART   ((__force upf_t) (1 << 14))

Definition at line 163 of file serial_core.h.

#define UPF_CHANGE_MASK   ((__force upf_t) (0x17fff))

Definition at line 177 of file serial_core.h.

#define UPF_CONS_FLOW   ((__force upf_t) (1 << 23))

Definition at line 166 of file serial_core.h.

#define UPF_DEAD   ((__force upf_t) (1 << 30))

Definition at line 174 of file serial_core.h.

#define UPF_EXAR_EFR   ((__force upf_t) (1 << 25))

Definition at line 168 of file serial_core.h.

#define UPF_FIXED_PORT   ((__force upf_t) (1 << 29))

Definition at line 173 of file serial_core.h.

#define UPF_FIXED_TYPE   ((__force upf_t) (1 << 27))

Definition at line 171 of file serial_core.h.

#define UPF_FOURPORT   ((__force upf_t) (1 << 1))

Definition at line 151 of file serial_core.h.

#define UPF_HARDPPS_CD   ((__force upf_t) (1 << 11))

Definition at line 161 of file serial_core.h.

#define UPF_IOREMAP   ((__force upf_t) (1 << 31))

Definition at line 175 of file serial_core.h.

#define UPF_LOW_LATENCY   ((__force upf_t) (1 << 13))

Definition at line 162 of file serial_core.h.

#define UPF_MAGIC_MULTIPLIER   ((__force upf_t) (1 << 16))

Definition at line 165 of file serial_core.h.

#define UPF_NO_TXEN_TEST   ((__force upf_t) (1 << 15))

Definition at line 164 of file serial_core.h.

#define UPF_SAK   ((__force upf_t) (1 << 2))

Definition at line 152 of file serial_core.h.

#define UPF_SHARE_IRQ   ((__force upf_t) (1 << 24))

Definition at line 167 of file serial_core.h.

#define UPF_SKIP_TEST   ((__force upf_t) (1 << 6))

Definition at line 159 of file serial_core.h.

#define UPF_SPD_CUST   ((__force upf_t) (0x0030))

Definition at line 156 of file serial_core.h.

#define UPF_SPD_HI   ((__force upf_t) (0x0010))

Definition at line 154 of file serial_core.h.

#define UPF_SPD_MASK   ((__force upf_t) (0x1030))

Definition at line 153 of file serial_core.h.

#define UPF_SPD_SHI   ((__force upf_t) (0x1000))

Definition at line 157 of file serial_core.h.

#define UPF_SPD_VHI   ((__force upf_t) (0x0020))

Definition at line 155 of file serial_core.h.

#define UPF_SPD_WARP   ((__force upf_t) (0x1010))

Definition at line 158 of file serial_core.h.

#define UPF_USR_MASK   ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))

Definition at line 178 of file serial_core.h.

#define UPIO_AU   (4) /* Au1x00 type IO */

Definition at line 135 of file serial_core.h.

#define UPIO_HUB6   (1)

Definition at line 132 of file serial_core.h.

#define UPIO_MEM   (2)

Definition at line 133 of file serial_core.h.

#define UPIO_MEM32   (3)

Definition at line 134 of file serial_core.h.

#define UPIO_PORT   (0)

Definition at line 131 of file serial_core.h.

#define UPIO_RM9000   (6) /* RM9000 type IO */

Definition at line 137 of file serial_core.h.

#define UPIO_TSI   (5) /* Tsi108/109 type IO */

Definition at line 136 of file serial_core.h.

#define WAKEUP_CHARS   256

Definition at line 221 of file serial_core.h.

Typedef Documentation

typedef unsigned int __bitwise__ upf_t

Definition at line 107 of file serial_core.h.

Function Documentation

int uart_add_one_port ( struct uart_driver drv,
struct uart_port uport 

uart_add_one_port - attach a driver-defined port structure : pointer to the uart low level driver structure for this port : uart port structure to use for this port.

This allows the driver to register its own uart_port structure with the core driver. The main purpose is to allow the low level uart drivers to expand uart_port, rather than having yet more levels of structures.

Definition at line 2369 of file serial_core.c.

struct tty_driver* uart_console_device ( struct console co,
int index 

Definition at line 2322 of file serial_core.c.

void uart_console_write ( struct uart_port port,
const char s,
unsigned int  count,
void(*)(struct uart_port *, int putchar 
unsigned int uart_get_baud_rate ( struct uart_port port,
struct ktermios termios,
struct ktermios old,
unsigned int  min,
unsigned int  max 

uart_get_baud_rate - return baud rate for a particular port : uart_port structure describing the port in question. : desired termios settings. : old termios (or NULL) : minimum acceptable baud rate : maximum acceptable baud rate

Decode the termios structure into a numeric baud rate, taking account of the magic 38400 baud rate (with spd_* flags), and mapping the B0 rate to 9600 baud.

If the new baud rate is invalid, try the old termios setting. If it's still invalid, we try 9600 baud.

Update the structure to reflect the baud rate we're actually going to be using. Don't do this for the case where B0 is requested ("hang up").

Definition at line 335 of file serial_core.c.

struct uart_port* uart_get_console ( struct uart_port ports,
int  nr,
struct console c 
unsigned int uart_get_divisor ( struct uart_port port,
unsigned int  baud 

uart_get_divisor - return uart clock divisor : uart_port structure describing the port. : desired baud rate

Calculate the uart clock divisor for the port.

Definition at line 414 of file serial_core.c.

void uart_handle_cts_change ( struct uart_port uport,
unsigned int  status 

uart_handle_cts_change - handle a change of clear-to-send state : uart_port structure for the open port : new clear to send status, nonzero if active

Definition at line 2555 of file serial_core.c.

void uart_handle_dcd_change ( struct uart_port uport,
unsigned int  status 

uart_handle_dcd_change - handle a change of carrier detect state : uart_port structure for the open port : new carrier detect status, nonzero if active

Definition at line 2517 of file serial_core.c.

void uart_insert_char ( struct uart_port port,
unsigned int  status,
unsigned int  overrun,
unsigned int  ch,
unsigned int  flag 

uart_insert_char - push a char to the uart layer

User is responsible to call tty_flip_buffer_push when they are done with insertion.

: corresponding port : state of the serial port RX buffer (LSR for 8250) : mask of overrun bits in : character to push : flag for the character (see TTY_NORMAL and friends)

Definition at line 2591 of file serial_core.c.

int uart_match_port ( struct uart_port port1,
struct uart_port port2 

Definition at line 2491 of file serial_core.c.

void uart_parse_options ( char options,
int baud,
int parity,
int bits,
int flow 
int uart_register_driver ( struct uart_driver drv)

uart_register_driver - register a driver with the uart core layer : low level driver structure

Register a uart driver with the core driver. We in turn register with the tty layer, and initialise the core driver per-port state.

We have a proc file in /proc/tty/driver which is named after the normal driver.

drv->port should be NULL, and the per-port structures should be registered using uart_add_one_port after this call has succeeded.

Definition at line 2245 of file serial_core.c.

int uart_remove_one_port ( struct uart_driver drv,
struct uart_port uport 

uart_remove_one_port - detach a driver defined port structure : pointer to the uart low level driver structure for this port : uart port structure for this port

This unhooks (and hangs up) the specified port structure from the core driver. No further calls will be made to the low-level code for this port.

Definition at line 2442 of file serial_core.c.

int uart_resume_port ( struct uart_driver reg,
struct uart_port port 

Definition at line 1945 of file serial_core.c.

int uart_set_options ( struct uart_port port,
struct console co,
int  baud,
int  parity,
int  bits,
int  flow 
int uart_suspend_port ( struct uart_driver reg,
struct uart_port port 

Definition at line 1879 of file serial_core.c.

void uart_unregister_driver ( struct uart_driver drv)

uart_unregister_driver - remove a driver from the uart core layer : low level driver structure

Remove all references to a driver from the core driver. The low level driver must have removed all its ports via the uart_remove_one_port() if it registered them with uart_add_one_port(). (ie, drv->port == NULL)

Definition at line 2312 of file serial_core.c.

void uart_update_timeout ( struct uart_port port,
unsigned int  cflag,
unsigned int  baud 

uart_update_timeout - update per-port FIFO timeout. : uart_port structure describing the port : termios cflag value : speed of the port

Set the port FIFO timeout value. The value should reflect the actual hardware settings.

Definition at line 275 of file serial_core.c.

void uart_write_wakeup ( struct uart_port port)

Definition at line 70 of file serial_core.c.