Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

drivers/char/serial.c File Reference

#include <linux/config.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/serial.h>
#include <linux/serial_reg.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/ptrace.h>
#include <linux/ioport.h>
#include <linux/mm.h>
#include <linux/malloc.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <asm/bitops.h>
#include <asm/serial.h>

Include dependency graph for drivers/char/serial.c:

Go to the source code of this file.

Defines

#define CONFIG_SERIAL_NOPAUSE_IO
#define SERIAL_DO_RESTART
#define RS_STROBE_TIME   (10*HZ)
#define RS_ISR_PASS_LIMIT   256
#define IRQ_T(state)   ((state->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
#define SERIAL_INLINE
#define DBG_CNT(s)
#define SERIAL_DEV_OFFSET   0
#define _INLINE_   inline
#define WAKEUP_CHARS   256
#define NR_PORTS   (sizeof(rs_table)/sizeof(struct serial_state))
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
#define RELEVANT_IFLAG(iflag)   (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))

Functions

static DECLARE_TASK_QUEUE (tq_serial)
static unsigned detect_uart_irq (struct serial_state *state)
static void autoconfig (struct serial_state *info)
static void change_speed (struct async_struct *info, struct termios *old)
static void rs_wait_until_sent (struct tty_struct *tty, int timeout)
static int serial_paranoia_check (struct async_struct *info, kdev_t device, const char *routine)
static unsigned int serial_in (struct async_struct *info, int offset)
static unsigned int serial_inp (struct async_struct *info, int offset)
static void serial_out (struct async_struct *info, int offset, int value)
static void serial_outp (struct async_struct *info, int offset, int value)
static void rs_stop (struct tty_struct *tty)
static void rs_start (struct tty_struct *tty)
static _INLINE_ void rs_sched_event (struct async_struct *info, int event)
static _INLINE_ void receive_chars (struct async_struct *info, int *status)
static _INLINE_ void transmit_chars (struct async_struct *info, int *intr_done)
static _INLINE_ void check_modem_status (struct async_struct *info)
static void rs_interrupt_single (int irq, void *dev_id, struct pt_regs *regs)
static void do_serial_bh (void)
static void do_softint (void *private_)
static void rs_timer (void)
static void figure_IRQ_timeout (int irq)
static int startup (struct async_struct *info)
static void shutdown (struct async_struct *info)
static void rs_put_char (struct tty_struct *tty, unsigned char ch)
static void rs_flush_chars (struct tty_struct *tty)
static int rs_write (struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
static int rs_write_room (struct tty_struct *tty)
static int rs_chars_in_buffer (struct tty_struct *tty)
static void rs_flush_buffer (struct tty_struct *tty)
static void rs_send_xchar (struct tty_struct *tty, char ch)
static void rs_throttle (struct tty_struct *tty)
static void rs_unthrottle (struct tty_struct *tty)
static int get_serial_info (struct async_struct *info, struct serial_struct *retinfo)
static int set_serial_info (struct async_struct *info, struct serial_struct *new_info)
static int get_lsr_info (struct async_struct *info, unsigned int *value)
static int get_modem_info (struct async_struct *info, unsigned int *value)
static int set_modem_info (struct async_struct *info, unsigned int cmd, unsigned int *value)
static int do_autoconfig (struct async_struct *info)
static void rs_break (struct tty_struct *tty, int break_state)
static int rs_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
static void rs_set_termios (struct tty_struct *tty, struct termios *old_termios)
static void rs_close (struct tty_struct *tty, struct file *filp)
static void rs_hangup (struct tty_struct *tty)
static int block_til_ready (struct tty_struct *tty, struct file *filp, struct async_struct *info)
static int get_async_struct (int line, struct async_struct **ret_info)
static int rs_open (struct tty_struct *tty, struct file *filp)
static int line_info (char *buf, struct serial_state *state)
int rs_read_proc (char *page, char **start, off_t idx, ssize_t count, int *eof, void *data)
static _INLINE_ void show_serial_version (void)
int register_serial (struct serial_struct *req)
void unregister_serial (int line)
 EXPORT_SYMBOL (register_serial)
 EXPORT_SYMBOL (unregister_serial)
 __initfunc (int rs_init(void))

Variables

static char * serial_name = "Serial driver"
static char * serial_version = "4.27"
static struct tty_driver serial_driver callout_driver
static int serial_refcount
static struct async_structIRQ_ports [NR_IRQS]
static int IRQ_timeout [NR_IRQS]
static struct serial_uart_config uart_config []
static struct serial_state rs_table []
static struct tty_struct * serial_table [NR_PORTS]
static struct termiosserial_termios [NR_PORTS]
static struct termiosserial_termios_locked [NR_PORTS]
static unsigned char * tmp_buf
static struct semaphore tmp_buf_sem = MUTEX


Define Documentation

#define _INLINE_   inline
 

Definition at line 160 of file drivers/char/serial.c.

#define CONFIG_SERIAL_NOPAUSE_IO
 

Definition at line 67 of file drivers/char/serial.c.

#define DBG_CNT s   ) 
 

Definition at line 116 of file drivers/char/serial.c.

#define IRQ_T state   )     ((state->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
 

Definition at line 107 of file drivers/char/serial.c.

#define MIN a,
 )     ((a) < (b) ? (a) : (b))
 

Definition at line 222 of file drivers/char/serial.c.

#define NR_PORTS   (sizeof(rs_table)/sizeof(struct serial_state))
 

Definition at line 215 of file drivers/char/serial.c.

#define RELEVANT_IFLAG iflag   )     (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
 

#define RS_ISR_PASS_LIMIT   256
 

Definition at line 105 of file drivers/char/serial.c.

#define RS_STROBE_TIME   (10*HZ)
 

Definition at line 104 of file drivers/char/serial.c.

#define SERIAL_DEV_OFFSET   0
 

Definition at line 156 of file drivers/char/serial.c.

Referenced by __initfunc().

#define SERIAL_DO_RESTART
 

Definition at line 68 of file drivers/char/serial.c.

#define SERIAL_INLINE
 

Definition at line 110 of file drivers/char/serial.c.

#define WAKEUP_CHARS   256
 

Definition at line 172 of file drivers/char/serial.c.


Function Documentation

__initfunc int   rs_init(void)  ) 
 

Definition at line 3092 of file drivers/char/serial.c.

References _MACH_Pmac, _machine, ASYNC_AUTO_IRQ, ASYNC_BOOT_AUTOCONF, ASYNC_FOURPORT, autoconfig(), B9600, tty_driver::break_ctl, async_icount::brk, termios::c_cflag, serial_state::callout_termios, tty_driver::chars_in_buffer, check_region, CLOCAL, tty_driver::close, serial_state::close_delay, serial_state::closing_wait, CON_CONSDEV, CREAD, CS8, async_icount::cts, serial_state::custom_divisor, async_icount::dcd, detect_uart_irq(), do_serial_bh(), tty_driver::driver_name, async_icount::dsr, timer_struct::expires, serial_state::flags, tty_driver::flags, console::flags, tty_driver::flush_buffer, tty_driver::flush_chars, timer_struct::fn, async_icount::frame, tty_driver::hangup, HUPCL, HZ, i, serial_state::icount, console::index, init_bh(), tty_driver::init_termios, tty_driver::ioctl, serial_state::irq, irq_cannonicalize, IRQ_timeout, KERN_INFO, serial_state::line, serial_state::magic, tty_driver::magic, tty_driver::major, memset, tty_driver::minor_start, tty_driver::name, serial_state::normal_termios, NR_PORTS, tty_driver::num, tty_driver::open, async_icount::overrun, panic(), async_icount::parity, serial_state::port, PORT_UNKNOWN, printk, tty_driver::proc_entry, tty_driver::put_char, tty_driver::read_proc, tty_driver::refcount, async_icount::rng, rs_break(), rs_chars_in_buffer(), rs_close(), rs_flush_buffer(), rs_flush_chars(), rs_hangup(), rs_ioctl(), rs_open(), rs_put_char(), rs_read_proc(), rs_send_xchar(), rs_set_termios(), rs_start(), rs_stop(), rs_throttle(), rs_timer(), RS_TIMER, rs_unthrottle(), rs_wait_until_sent(), rs_write(), rs_write_room(), async_icount::rx, tty_driver::send_xchar, SERIAL_BH, SERIAL_DEV_OFFSET, serial_refcount, serial_table, SERIAL_TYPE_CALLOUT, SERIAL_TYPE_NORMAL, tty_driver::set_termios, show_serial_version(), SSTATE_MAGIC, tty_driver::start, tty_driver::stop, tty_driver::subtype, tty_driver::table, tty_driver::termios, tty_driver::termios_locked, tty_driver::throttle, timer_table, TTY_DRIVER_MAGIC, TTY_DRIVER_REAL_RAW, TTY_DRIVER_TYPE_SERIAL, TTY_MAJOR, tty_register_driver(), tty_std_termios, TTYAUX_MAJOR, async_icount::tx, serial_state::type, tty_driver::type, tty_driver::unthrottle, tty_driver::wait_until_sent, tty_driver::write, and tty_driver::write_room.

Here is the call graph for this function:

static void autoconfig struct serial_state info  )  [static]
 

Definition at line 2935 of file drivers/char/serial.c.

References ASYNC_SKIP_TEST, cli, serial_uart_config::dfl_xmit_fifo_size, serial_state::flags, async_struct::flags, serial_state::hub6, async_struct::hub6, async_struct::magic, outb, async_struct::port, serial_state::port, PORT_16450, PORT_16550, PORT_16550A, PORT_16650, PORT_16650V2, PORT_16750, PORT_8250, PORT_UNKNOWN, request_region, restore_flags, save_flags, serial_in, serial_inp, SERIAL_MAGIC, serial_outp, serial_state::type, UART_EFR, UART_FCR, UART_FCR7_64BYTE, UART_FCR_CLEAR_RCVR, UART_FCR_CLEAR_XMIT, UART_FCR_ENABLE_FIFO, UART_IER, UART_IIR, UART_LCR, UART_LCR_DLAB, UART_MCR, UART_MCR_LOOP, UART_MSR, UART_RX, UART_SCR, x00, x0c(), xBF, xff, and serial_state::xmit_fifo_size.

Here is the call graph for this function:

static int block_til_ready struct tty_struct *  tty,
struct file filp,
struct async_struct info
[static]
 

Definition at line 2436 of file drivers/char/serial.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CLOSING, ASYNC_HUP_NOTIFY, ASYNC_INITIALIZED, ASYNC_NORMAL_ACTIVE, ASYNC_PGRP_LOCKOUT, ASYNC_SESSION_LOCKOUT, async_struct::blocked_open, termios::c_cflag, CBAUD, cli, CLOCAL, async_struct::close_wait, serial_state::count, current, EAGAIN, EBUSY, ERESTARTSYS, async_struct::flags, interruptible_sleep_on(), async_struct::line, serial_state::line, serial_state::normal_termios, NULL, O_NONBLOCK, async_struct::open_wait, async_struct::pgrp, printk, restore_flags, save_flags, schedule(), serial_in, serial_inp, serial_out, SERIAL_TYPE_CALLOUT, async_struct::session, signal_pending, async_struct::state, TASK_INTERRUPTIBLE, TASK_RUNNING, tty_hung_up_p(), UART_MCR, UART_MCR_DTR, UART_MCR_RTS, UART_MSR, and UART_MSR_DCD.

Here is the call graph for this function:

static void change_speed struct async_struct info,
struct termios old
[static]
 

Definition at line 1244 of file drivers/char/serial.c.

References ASYNC_CHECK_CD, ASYNC_CTS_FLOW, ASYNC_HARDPPS_CD, ASYNC_SPD_CUST, ASYNC_SPD_MASK, baud, serial_state::baud_base, termios::c_cflag, CBAUD, cli, CLOCAL, CMSPAR, CREAD, CRTSCTS, CS5, CS6, CS7, CS8, CSIZE, CSTOPB, serial_state::custom_divisor, serial_uart_config::flags, async_struct::flags, HZ, async_struct::IER, PARENB, PARODD, async_struct::port, port, PORT_16750, async_struct::quot, restore_flags, save_flags, serial_out, serial_outp, async_struct::state, async_struct::timeout, async_struct::tty, tty_get_baud_rate(), serial_state::type, UART_DLL, UART_DLM, UART_EFR, UART_EFR_CTS, UART_FCR, UART_FCR7_64BYTE, UART_FCR_ENABLE_FIFO, UART_FCR_TRIGGER_1, UART_FCR_TRIGGER_8, UART_IER, UART_IER_MSI, UART_LCR, UART_LCR_DLAB, UART_LCR_EPAR, UART_LCR_PARITY, UART_LCR_SPAR, UART_LSR_BI, UART_LSR_FE, UART_LSR_OE, UART_LSR_PE, UART_STARTECH, UART_USE_FIFO, xBF, xff, and async_struct::xmit_fifo_size.

Here is the call graph for this function:

static _INLINE_ void check_modem_status struct async_struct info  )  [static]
 

Definition at line 508 of file drivers/char/serial.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CALLOUT_NOHUP, ASYNC_CHECK_CD, ASYNC_CTS_FLOW, ASYNC_HARDPPS_CD, async_icount::cts, async_icount::dcd, async_struct::delta_msr_wait, async_icount::dsr, async_struct::flags, serial_state::icount, async_struct::IER, async_struct::line, async_struct::open_wait, printk, async_icount::rng, RS_EVENT_WRITE_WAKEUP, rs_sched_event(), serial_in, serial_out, async_struct::state, status, async_struct::tty, tty_hangup(), UART_IER, UART_IER_THRI, UART_MSR, UART_MSR_ANY_DELTA, UART_MSR_CTS, UART_MSR_DCD, UART_MSR_DCTS, UART_MSR_DDCD, UART_MSR_DDSR, and UART_MSR_TERI.

Here is the call graph for this function:

static DECLARE_TASK_QUEUE tq_serial   )  [static]
 

static unsigned detect_uart_irq struct serial_state state  )  [static]
 

Definition at line 2869 of file drivers/char/serial.c.

References ASYNC_FOURPORT, async_struct::flags, serial_state::flags, serial_state::hub6, async_struct::hub6, inb_p, irqs, async_struct::magic, outb_p, async_struct::port, serial_state::port, probe_irq_off(), probe_irq_on(), serial_inp, SERIAL_MAGIC, serial_outp, UART_IER, UART_IIR, UART_LSR, UART_MCR, UART_MCR_DTR, UART_MCR_OUT1, UART_MCR_OUT2, UART_MCR_RTS, UART_MSR, UART_RX, UART_TX, udelay, x0f, x80, and xFF.

Referenced by __initfunc(), and do_autoconfig().

Here is the call graph for this function:

static int do_autoconfig struct async_struct info  )  [static]
 

Definition at line 1884 of file drivers/char/serial.c.

References ASYNC_AUTO_IRQ, autoconfig(), CAP_SYS_ADMIN, capable, serial_state::count, detect_uart_irq(), EBUSY, EPERM, serial_state::flags, serial_state::irq, serial_state::port, PORT_UNKNOWN, shutdown(), startup(), async_struct::state, and serial_state::type.

Here is the call graph for this function:

static void do_serial_bh void   )  [static]
 

Definition at line 806 of file drivers/char/serial.c.

References run_task_queue().

Here is the call graph for this function:

static void do_softint void *  private_  )  [static]
 

Definition at line 811 of file drivers/char/serial.c.

References async_struct::event, RS_EVENT_WRITE_WAKEUP, test_and_clear_bit, async_struct::tty, and tty.

EXPORT_SYMBOL unregister_serial   ) 
 

EXPORT_SYMBOL register_serial   ) 
 

static void figure_IRQ_timeout int  irq  )  [static]
 

Definition at line 900 of file drivers/char/serial.c.

References HZ, IRQ_timeout, and timeout.

static int get_async_struct int  line,
struct async_struct **  ret_info
[static]
 

Definition at line 2571 of file drivers/char/serial.c.

References serial_state::count, do_softint(), ENOMEM, serial_state::flags, serial_state::info, kfree_s(), kmalloc(), memset, serial_state::port, SERIAL_MAGIC, and serial_state::xmit_fifo_size.

Here is the call graph for this function:

static int get_lsr_info struct async_struct info,
unsigned int *  value
[static]
 

Definition at line 1789 of file drivers/char/serial.c.

References cli, put_user, restore_flags, result, save_flags, serial_in, TIOCSER_TEMT, UART_LSR, and UART_LSR_TEMT.

static int get_modem_info struct async_struct info,
unsigned int *  value
[static]
 

Definition at line 1803 of file drivers/char/serial.c.

References cli, async_struct::MCR, put_user, restore_flags, result, save_flags, serial_in, TIOCM_CAR, TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_OUT1, TIOCM_OUT2, TIOCM_RNG, TIOCM_RTS, UART_MCR_DTR, UART_MCR_OUT1, UART_MCR_OUT2, UART_MCR_RTS, UART_MSR, UART_MSR_CTS, UART_MSR_DCD, UART_MSR_DSR, and UART_MSR_RI.

static int get_serial_info struct async_struct info,
struct serial_struct retinfo
[static]
 

Definition at line 1638 of file drivers/char/serial.c.

References serial_state::baud_base, serial_state::close_delay, serial_state::closing_wait, copy_to_user, serial_state::custom_divisor, EFAULT, serial_state::flags, serial_state::hub6, serial_state::irq, serial_state::line, memset, serial_state::port, async_struct::state, state, serial_state::type, and serial_state::xmit_fifo_size.

static int line_info char *  buf,
struct serial_state state
[inline, static]
 

Definition at line 2716 of file drivers/char/serial.c.

References serial_state::baud_base, async_icount::brk, cli, serial_state::flags, async_struct::flags, async_icount::frame, serial_state::icount, serial_state::info, serial_state::irq, serial_state::line, async_struct::magic, async_struct::MCR, async_icount::overrun, async_icount::parity, async_struct::port, serial_state::port, PORT_UNKNOWN, async_struct::quot, restore_flags, async_icount::rx, save_flags, serial_in, SERIAL_MAGIC, sprintf(), strcat, async_struct::tty, async_icount::tx, serial_state::type, UART_MCR, UART_MCR_DTR, UART_MCR_RTS, UART_MSR, UART_MSR_CTS, UART_MSR_DCD, UART_MSR_DSR, and UART_MSR_RI.

Here is the call graph for this function:

static _INLINE_ void receive_chars struct async_struct info,
int *  status
[static]
 

Definition at line 384 of file drivers/char/serial.c.

References ASYNC_SAK, async_icount::brk, do_SAK(), async_struct::flags, async_icount::frame, serial_state::icount, async_struct::ignore_status_mask, ignored, async_icount::overrun, async_icount::parity, printk, async_struct::read_status_mask, async_icount::rx, serial_inp, async_struct::state, async_struct::tty, tty, tty_flip_buffer_push, UART_LSR, UART_LSR_BI, UART_LSR_DR, UART_LSR_FE, UART_LSR_OE, UART_LSR_PE, and UART_RX.

Here is the call graph for this function:

int register_serial struct serial_struct req  ) 
 

Definition at line 89 of file sunserial.c.

static void rs_break struct tty_struct *  tty,
int  break_state
[static]
 

Definition at line 1911 of file drivers/char/serial.c.

References cli, async_struct::port, restore_flags, save_flags, serial_inp, serial_out, serial_paranoia_check(), UART_LCR, and UART_LCR_SBC.

Here is the call graph for this function:

static int rs_chars_in_buffer struct tty_struct *  tty  )  [static]
 

Definition at line 1527 of file drivers/char/serial.c.

References serial_paranoia_check(), and async_struct::xmit_cnt.

Here is the call graph for this function:

static void rs_close struct tty_struct *  tty,
struct file filp
[static]
 

Definition at line 2242 of file drivers/char/serial.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CLOSING, ASYNC_CLOSING_WAIT_NONE, ASYNC_INITIALIZED, ASYNC_NORMAL_ACTIVE, async_struct::blocked_open, serial_state::callout_termios, cli, async_struct::close_delay, async_struct::close_wait, async_struct::closing_wait, serial_state::count, current, DBG_CNT, async_struct::event, async_struct::flags, async_struct::IER, async_struct::line, MOD_DEC_USE_COUNT, serial_state::normal_termios, async_struct::open_wait, printk, async_struct::read_status_mask, restore_flags, rs_wait_until_sent(), save_flags, schedule_timeout, serial_out, serial_paranoia_check(), shutdown(), async_struct::state, TASK_INTERRUPTIBLE, async_struct::tty, tty_hung_up_p(), tty_wait_until_sent(), UART_IER, and UART_IER_RLSI.

Here is the call graph for this function:

static void rs_flush_buffer struct tty_struct *  tty  )  [static]
 

Definition at line 1536 of file drivers/char/serial.c.

References cli, restore_flags, save_flags, serial_paranoia_check(), async_struct::xmit_cnt, async_struct::xmit_head, and async_struct::xmit_tail.

Here is the call graph for this function:

static void rs_flush_chars struct tty_struct *  tty  )  [static]
 

Definition at line 1426 of file drivers/char/serial.c.

References cli, async_struct::IER, restore_flags, save_flags, serial_out, serial_paranoia_check(), UART_IER, UART_IER_THRI, async_struct::xmit_buf, and async_struct::xmit_cnt.

Here is the call graph for this function:

static void rs_hangup struct tty_struct *  tty  )  [static]
 

Definition at line 2412 of file drivers/char/serial.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_NORMAL_ACTIVE, serial_state::count, async_struct::event, async_struct::flags, async_struct::open_wait, rs_flush_buffer(), serial_paranoia_check(), shutdown(), async_struct::state, and async_struct::tty.

Here is the call graph for this function: