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

char/esp.c File Reference

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/serial.h>
#include <linux/serialP.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/init.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/segment.h>
#include <asm/bitops.h>
#include <asm/dma.h>
#include <linux/malloc.h>
#include <asm/uaccess.h>
#include <linux/hayesesp.h>

Include dependency graph for char/esp.c:

Go to the source code of this file.

Defines

#define NR_PORTS   64
#define NR_PRIMARY   8
#define DMA_BUFFER_SZ   1024
#define WAKEUP_CHARS   1024
#define SERIAL_TYPE_NORMAL   1
#define SERIAL_TYPE_CALLOUT   2
#define SERIAL_DO_RESTART
#define _INLINE_   inline
#define DBG_CNT(s)
#define BASE_BAUD   ((1843200 / 16) * (1 << ESPC_SCALE))
#define STD_COM_FLAGS   (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
#define RELEVANT_IFLAG(iflag)   (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))

Functions

 MODULE_PARM (irq,"1-8i")
 MODULE_PARM (divisor,"1-8i")
 MODULE_PARM (dma,"i")
 MODULE_PARM (rx_trigger,"i")
 MODULE_PARM (tx_trigger,"i")
 MODULE_PARM (flow_off,"i")
 MODULE_PARM (flow_on,"i")
 MODULE_PARM (rx_timeout,"i")
 MODULE_PARM (pio_threshold,"i")
static DECLARE_TASK_QUEUE (tq_esp)
static void change_speed (struct esp_struct *info)
static void rs_wait_until_sent (struct tty_struct *, int)
static int serial_paranoia_check (struct esp_struct *info, kdev_t device, const char *routine)
static unsigned int serial_in (struct esp_struct *info, int offset)
static void serial_out (struct esp_struct *info, int offset, unsigned char value)
static int __get_order (unsigned long size)
static void rs_stop (struct tty_struct *tty)
static void rs_start (struct tty_struct *tty)
static _INLINE_ void rs_sched_event (struct esp_struct *info, int event)
static _INLINE_ struct esp_pio_buffer * get_pio_buffer (void)
static _INLINE_ void release_pio_buffer (struct esp_pio_buffer *buf)
static _INLINE_ void receive_chars_pio (struct esp_struct *info, int num_bytes)
static _INLINE_ void receive_chars_dma (struct esp_struct *info, int num_bytes)
static _INLINE_ void receive_chars_dma_done (struct esp_struct *info, int status)
static _INLINE_ void transmit_chars_pio (struct esp_struct *info, int space_avail)
static _INLINE_ void transmit_chars_dma (struct esp_struct *info, int num_bytes)
static _INLINE_ void transmit_chars_dma_done (struct esp_struct *info)
static _INLINE_ void check_modem_status (struct esp_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 do_serial_hangup (void *private_)
static _INLINE_ void esp_basic_init (struct esp_struct *info)
static int startup (struct esp_struct *info)
static void shutdown (struct esp_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_throttle (struct tty_struct *tty)
static void rs_unthrottle (struct tty_struct *tty)
static int get_serial_info (struct esp_struct *info, struct serial_struct *retinfo)
static int get_esp_config (struct esp_struct *info, struct hayes_esp_config *retinfo)
static int set_serial_info (struct esp_struct *info, struct serial_struct *new_info)
static int set_esp_config (struct esp_struct *info, struct hayes_esp_config *new_info)
static int get_lsr_info (struct esp_struct *info, unsigned int *value)
static int get_modem_info (struct esp_struct *info, unsigned int *value)
static int set_modem_info (struct esp_struct *info, unsigned int cmd, unsigned int *value)
static void esp_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 esp_hangup (struct tty_struct *tty)
static int block_til_ready (struct tty_struct *tty, struct file *filp, struct esp_struct *info)
static int esp_open (struct tty_struct *tty, struct file *filp)
static _INLINE_ void show_serial_version (void)
static _INLINE_ int autoconfig (struct esp_struct *info, int *region_start)
 __initfunc (int espserial_init(void))

Variables

static int irq [NR_PRIMARY] = {0,0,0,0,0,0,0,0}
static unsigned int divisor [NR_PRIMARY] = {0,0,0,0,0,0,0,0}
static unsigned int dma = ESP_DMA_CHANNEL
static unsigned int rx_trigger = ESP_RX_TRIGGER
static unsigned int tx_trigger = ESP_TX_TRIGGER
static unsigned int flow_off = ESP_FLOW_OFF
static unsigned int flow_on = ESP_FLOW_ON
static unsigned int rx_timeout = ESP_RX_TMOUT
static unsigned int pio_threshold = ESP_PIO_THRESHOLD
static char * dma_buffer
static int dma_bytes
static struct esp_pio_buffer * free_pio_buf
static char * serial_name = "ESP serial driver"
static char * serial_version = "2.2"
static struct tty_driver esp_driver esp_callout_driver
static int serial_refcount
static struct esp_struct * ports
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 = 0
static struct semaphore tmp_buf_sem = MUTEX


Define Documentation

#define _INLINE_   inline
 

Definition at line 131 of file char/esp.c.

#define BASE_BAUD   ((1843200 / 16) * (1 << ESPC_SCALE))
 

Definition at line 149 of file char/esp.c.

Referenced by change_speed(), get_serial_info(), mstartup(), and set_serial_info().

#define DBG_CNT s   ) 
 

Definition at line 137 of file char/esp.c.

#define DMA_BUFFER_SZ   1024
 

Definition at line 100 of file char/esp.c.

Referenced by shutdown(), and startup().

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

Definition at line 159 of file char/esp.c.

#define NR_PORTS   64
 

Definition at line 69 of file char/esp.c.

#define NR_PRIMARY   8
 

Definition at line 70 of file char/esp.c.

Referenced by __initfunc().

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

#define SERIAL_DO_RESTART
 

Definition at line 125 of file char/esp.c.

#define SERIAL_TYPE_CALLOUT   2
 

Definition at line 114 of file char/esp.c.

Referenced by __initfunc(), block_til_ready(), block_till_ready(), epcaparam(), ip2_open(), ircomm_tty_block_til_ready(), m68k_rs_init(), macserial_init(), mgsl_init(), moxa_init(), mxser_block_til_ready(), mxser_init(), pc_init(), pcxe_open(), register_drivers(), rs_init(), serial167_init(), and tty_open().

#define SERIAL_TYPE_NORMAL   1
 

Definition at line 113 of file char/esp.c.

Referenced by __initfunc(), cy_open(), dz_open(), esp_open(), ip2_open(), ircomm_tty_init(), isicom_open(), m68k_rs_init(), macserial_init(), mgsl_init(), mgsl_open(), moxa_init(), moxa_open(), mxser_init(), mxser_open(), pc_init(), pc_open(), pcxe_open(), register_drivers(), rp_open(), rs_8xx_open(), rs_init(), rs_open(), sab82532_open(), serial167_init(), su_open(), sx_open(), and zs_open().

#define STD_COM_FLAGS   (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
 

Definition at line 152 of file char/esp.c.

#define WAKEUP_CHARS   1024
 

Definition at line 102 of file char/esp.c.


Function Documentation

static int __get_order unsigned long  size  )  [inline, static]
 

Definition at line 206 of file char/esp.c.

References PAGE_SHIFT, and PAGE_SIZE.

__initfunc int   espserial_init(void)  ) 
 

Definition at line 2531 of file char/esp.c.

References ASYNC_SPD_CUST, autoconfig(), B9600, tty_driver::break_ctl, termios::c_cflag, tty_driver::chars_in_buffer, CLOCAL, tty_driver::close, CREAD, CS8, divisor, dma, do_serial_bh(), do_serial_hangup(), do_softint(), esp, ESP_BH, esp_break(), esp_hangup(), esp_open(), tty_driver::flags, flow_off, flow_on, tty_driver::flush_buffer, tty_driver::flush_chars, tty_driver::hangup, HUPCL, HZ, i, init_bh(), tty_driver::init_termios, tty_driver::ioctl, irq, KERN_ERR, KERN_INFO, kfree(), kmalloc(), tty_driver::magic, tty_driver::major, memset, tty_driver::minor_start, tty_driver::name, NR_PORTS, NR_PRIMARY, tty_driver::num, offset, tty_driver::open, pio_threshold, ports, printk, tty_driver::put_char, tty_driver::refcount, rs_chars_in_buffer(), rs_close(), rs_flush_buffer(), rs_flush_chars(), rs_ioctl(), rs_put_char(), rs_set_termios(), rs_start(), rs_stop(), rs_throttle(), rs_unthrottle(), rs_wait_until_sent(), rs_write(), rs_write_room(), rx_timeout, rx_trigger, serial_refcount, serial_table, SERIAL_TYPE_CALLOUT, SERIAL_TYPE_NORMAL, tty_driver::set_termios, show_serial_version(), tty_driver::start, STD_COM_FLAGS, tty_driver::stop, tty_driver::subtype, tty_driver::table, tty_driver::termios, tty_driver::termios_locked, tty_driver::throttle, TTY_DRIVER_MAGIC, TTY_DRIVER_REAL_RAW, TTY_DRIVER_TYPE_SERIAL, tty_register_driver(), tty_std_termios, tty_unregister_driver(), tx_trigger, 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 _INLINE_ int autoconfig struct esp_struct *  info,
int *  region_start
[static]
 

Definition at line 2474 of file char/esp.c.

References check_region, cli, esp_basic_init(), ports, release_region, request_region, restore_flags, save_flags, serial_in, serial_out, UART_MCR, x00, x01, x02, x20, and x70.

Here is the call graph for this function:

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

Definition at line 2226 of file char/esp.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CLOSING, ASYNC_HUP_NOTIFY, ASYNC_INITIALIZED, ASYNC_NORMAL_ACTIVE, ASYNC_PGRP_LOCKOUT, ASYNC_SESSION_LOCKOUT, CBAUD, cli, CLOCAL, current, EAGAIN, EBUSY, ERESTARTSYS, interruptible_sleep_on(), NULL, O_NONBLOCK, printk, schedule(), serial_in, serial_out, SERIAL_TYPE_CALLOUT, signal_pending, sti, TASK_INTERRUPTIBLE, TASK_RUNNING, tty_hung_up_p(), UART_MCR, UART_MCR_DTR, UART_MCR_RTS, and UART_MSR_DCD.

Here is the call graph for this function:

static void change_speed struct esp_struct *  info  )  [static]
 

Definition at line 1113 of file char/esp.c.

References ASYNC_CHECK_CD, ASYNC_CTS_FLOW, ASYNC_SPD_CUST, ASYNC_SPD_MASK, BASE_BAUD, baud, cli, CLOCAL, CMSPAR, CRTSCTS, CS5, CS6, CS7, CS8, CSIZE, CSTOPB, HZ, PARENB, PARODD, port, restore_flags, save_flags, serial_out, tty_get_baud_rate(), UART_LCR, UART_LCR_EPAR, UART_LCR_PARITY, UART_LCR_SPAR, UART_LSR_BI, UART_LSR_DR, UART_LSR_FE, UART_LSR_OE, UART_LSR_PE, UART_LSR_THRE, x10, x1f, x3f, x7f, and xff.

Here is the call graph for this function:

static _INLINE_ void check_modem_status struct esp_struct *  info  )  [static]
 

Definition at line 626 of file char/esp.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CALLOUT_NOHUP, ASYNC_CHECK_CD, printk, queue_task, serial_in, serial_out, status, tq_scheduler, UART_MSR_ANY_DELTA, UART_MSR_DCD, UART_MSR_DCTS, UART_MSR_DDCD, UART_MSR_DDSR, and UART_MSR_TERI.

static DECLARE_TASK_QUEUE tq_esp   )  [static]
 

static void do_serial_bh void   )  [static]
 

Definition at line 783 of file char/esp.c.

References run_task_queue().

Here is the call graph for this function:

static void do_serial_hangup void *  private_  )  [static]
 

Definition at line 815 of file char/esp.c.

References tty, and tty_hangup().

Here is the call graph for this function:

static void do_softint void *  private_  )  [static]
 

Definition at line 788 of file char/esp.c.

References test_and_clear_bit, and tty.

static _INLINE_ void esp_basic_init struct esp_struct *  info  )  [static]
 

Definition at line 836 of file char/esp.c.

References dma, serial_out, x00, x01, x02, x04, and xff.

Referenced by autoconfig(), and set_esp_config().

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

Definition at line 1861 of file char/esp.c.

References cli, interruptible_sleep_on(), restore_flags, save_flags, serial_out, serial_paranoia_check(), x00, and x01.

Referenced by __initfunc().

Here is the call graph for this function:

static void esp_hangup struct tty_struct *  tty  )  [static]
 

Definition at line 2205 of file char/esp.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_NORMAL_ACTIVE, rs_flush_buffer(), serial_paranoia_check(), and shutdown().

Referenced by __initfunc().

Here is the call graph for this function:

static int esp_open struct tty_struct *  tty,
struct file filp
[static]
 

Definition at line 2376 of file char/esp.c.

References ASYNC_SPLIT_TERMIOS, block_til_ready(), change_speed(), current, ENODEV, ENOMEM, free_page, line, MINOR, MOD_INC_USE_COUNT, NR_PORTS, page, ports, printk, serial_paranoia_check(), SERIAL_TYPE_NORMAL, startup(), and tmp_buf.

Referenced by __initfunc().

Here is the call graph for this function:

static int get_esp_config struct esp_struct *  info,
struct hayes_esp_config retinfo
[static]
 

Definition at line 1502 of file char/esp.c.

References copy_to_user, dma, EFAULT, and memset.

Referenced by rs_ioctl().

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

Definition at line 1786 of file char/esp.c.

References cli, put_user, result, serial_in, serial_out, status, sti, TIOCSER_TEMT, and UART_LSR_TEMT.

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

Definition at line 1800 of file char/esp.c.

References cli, put_user, result, serial_in, serial_out, status, sti, TIOCM_CAR, TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_RNG, TIOCM_RTS, UART_MCR_DTR, UART_MCR_RTS, UART_MSR_CTS, UART_MSR_DCD, UART_MSR_DSR, and UART_MSR_RI.

static _INLINE_ struct esp_pio_buffer* get_pio_buffer void   )  [static]
 

Definition at line 295 of file char/esp.c.

References buf, free_pio_buf, and kmalloc().

Referenced by receive_chars_pio(), and transmit_chars_pio().

Here is the call graph for this function:

static int get_serial_info struct esp_struct *  info,
struct serial_struct retinfo
[static]
 

Definition at line 1478 of file char/esp.c.

References BASE_BAUD, copy_to_user, EFAULT, memset, and PORT_16550A.

MODULE_PARM pio_threshold  ,
"i" 
 

MODULE_PARM rx_timeout  ,
"i" 
 

MODULE_PARM flow_on  ,
"i" 
 

MODULE_PARM flow_off  ,
"i" 
 

MODULE_PARM tx_trigger  ,
"i" 
 

MODULE_PARM rx_trigger  ,
"i" 
 

MODULE_PARM dma  ,
"i" 
 

MODULE_PARM divisor  ,
"1-8i" 
 

MODULE_PARM irq  ,
"1-8i" 
 

static _INLINE_ void receive_chars_dma struct esp_struct *  info,
int  num_bytes
[static]
 

Definition at line 396 of file char/esp.c.

References claim_dma_lock, clear_dma_ff, disable_dma(), dma, dma_buffer, dma_bytes, DMA_MODE_READ, enable_dma(), release_dma_lock, serial_out, set_dma_addr(), set_dma_count(), set_dma_mode(), and virt_to_bus.

Referenced by receive_chars_dma_done(), and rs_interrupt_single().

Here is the call graph for this function:

static _INLINE_ void receive_chars_dma_done struct esp_struct *  info,
int  status
[static]
 

Definition at line 415 of file char/esp.c.

References ASYNC_SAK, claim_dma_lock, clear_dma_ff, disable_dma(), dma, dma_buffer, dma_bytes, do_SAK(), get_dma_residue, memcpy, memset, queue_task, receive_chars_dma(), release_dma_lock, tq_timer, tty, x04, x08, and x10.

Referenced by rs_interrupt_single().

Here is the call graph for this function:

static _INLINE_ void receive_chars_pio struct esp_struct *  info,
int  num_bytes
[static]
 

Definition at line 316 of file char/esp.c.

References ASYNC_SAK, cli, do_SAK(), get_pio_buffer(), i, inw, queue_task, release_pio_buffer(), serial_in, status_mask, sti, tq_timer, tty, x01, x02, and x04.

Referenced by rs_interrupt_single().

Here is the call graph for this function:

static _INLINE_ void release_pio_buffer struct esp_pio_buffer *  buf  )  [static]
 

Definition at line 310 of file char/esp.c.

References free_pio_buf.

Referenced by receive_chars_pio(), and transmit_chars_pio().

static int rs_chars_in_buffer struct tty_struct *  tty  )  [static]
 

Definition at line 1395 of file char/esp.c.

References serial_paranoia_check().

Here is the call graph for this function:

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

Definition at line 2057 of file char/esp.c.

References ASYNC_CALLOUT_ACTIVE, ASYNC_CLOSING, ASYNC_CLOSING_WAIT_NONE, ASYNC_INITIALIZED, ASYNC_NORMAL_ACTIVE, cli, current, DBG_CNT, MOD_DEC_USE_COUNT, printk, restore_flags, rs_wait_until_sent(), save_flags, schedule_timeout, serial_out, serial_paranoia_check(), shutdown(), TASK_INTERRUPTIBLE, tty_hung_up_p(), tty_wait_until_sent(), UART_IER_RDI, UART_LSR_DR, and x00.

Here is the call graph for this function:

static void rs_flush_buffer struct tty_struct *  tty  )  [static]
 

Definition at line 1404 of file char/esp.c.

References cli, serial_paranoia_check(), and sti.

Here is the call graph for this function:

static void rs_flush_chars struct tty_struct *  tty  )  [static]
 

Definition at line 1293 of file char/esp.c.

References cli, restore_flags, save_flags, serial_out, serial_paranoia_check(), and UART_IER_THRI.

Here is the call graph for this function:

static void rs_interrupt_single int  irq,
void *  dev_id,
struct pt_regs regs
[static]
 

Definition at line 666 of file char/esp.c.

References check_modem_status(), cli, dma_bytes, jiffies, printk, receive_chars_dma(), receive_chars_dma_done(), receive_chars_pio(), serial_in, serial_out, sti, transmit_chars_dma(), transmit_chars_dma_done(), transmit_chars_pio(),