/home/hillier_g/checkout/most4linux/most-kernel/most-sync-rt-m.c File Reference

Implementation of the MOST Synchronous RTDM driver. More...

Go to the source code of this file.

Defines

#define DRIVER_NAME   "most-sync-rt"
#define DRIVER_MAJOR_VERSION   0
#define DRIVER_MINOR_VERSION   1
#define DRIVER_PATHLEVEL   0
#define PR   DRIVER_NAME ": "

Functions

static int most_sync_nrt_open (struct rtdm_dev_context *, rtdm_user_info_t *, int)
static int most_sync_nrt_close (struct rtdm_dev_context *, rtdm_user_info_t *)
static int most_sync_nrt_ioctl (struct rtdm_dev_context *, rtdm_user_info_t *, int, void *)
static ssize_t most_sync_rt_read (struct rtdm_dev_context *, rtdm_user_info_t *, void *, size_t)
static ssize_t most_sync_rt_write (struct rtdm_dev_context *, rtdm_user_info_t *, const void *, size_t)
static void most_sync_nrt_stop_rx (struct most_sync_rt_file *file)
static void most_sync_nrt_stop_tx (struct most_sync_rt_file *file)
static int most_sync_nrt_reconfigure_begin (struct most_conf_sync *sync)
static void most_sync_nrt_reconfigure_end (struct most_conf_sync *sync)
static int most_sync_rt_read_write_begin (struct most_conf_sync *sync)
static void most_sync_rt_read_write_end (struct most_conf_sync *sync)
static int most_sync_nrt_setup_rx (struct most_sync_rt_file *file, rtdm_user_info_t *user_info, void *ioctl_arg)
static int most_sync_nrt_setup_tx (struct most_sync_rt_file *file, rtdm_user_info_t *user_info, void *ioctl_arg)
static int most_sync_rt_probe (struct most_dev *most_dev)
static int most_sync_rt_remove (struct most_dev *dev)
static void most_sync_rt_interrupt_handler (struct most_dev *dev, unsigned int intstatus)
static int __init most_sync_rt_init (void)
static void __exit most_sync_rt_exit (void)

Variables

static char * version = "$Rev: 170 $"
most_sync_rt_devmost_sync_rt_devices [MOST_DEVICE_NUMBER]
long sw_rx_buffer_size = STD_MOST_FRAMES_PER_SEC
long sw_tx_buffer_size = STD_MOST_FRAMES_PER_SEC
long hw_rx_buffer_size = 44
long hw_tx_buffer_size = 44
static struct rtdm_device device_templ
static struct most_high_driver most_sync_rt_high_driver


Detailed Description

Implementation of the MOST Synchronous RTDM driver.

Definition in file most-sync-rt-m.c.


Define Documentation

#define DRIVER_NAME   "most-sync-rt"

The name of the driver.

Definition at line 54 of file most-sync-rt-m.c.

#define DRIVER_MAJOR_VERSION   0

The major version. Used as RTDM device version.

Definition at line 59 of file most-sync-rt-m.c.

#define DRIVER_MINOR_VERSION   1

The minor version. Used as RTDM device version.

Definition at line 64 of file most-sync-rt-m.c.

#define DRIVER_PATHLEVEL   0

The patchlevel. Used as RTDM device version.

Definition at line 69 of file most-sync-rt-m.c.

#define PR   DRIVER_NAME ": "

The prefix for printk outputs.

Definition at line 74 of file most-sync-rt-m.c.


Function Documentation

static int most_sync_nrt_open ( struct rtdm_dev_context *  context,
rtdm_user_info_t *  user_info,
int  oflag 
) [static]

Gets called if the MOST Synchronous RT device gets opened. Callable only from NRT context

Does following tasks:

Parameters:
context Context structure associated with opened device instance
user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
oflag Open flags as passed by the user

Definition at line 345 of file most-sync-rt-m.c.

References most_sync_rt_dev::file_list, most_sync_rt_file::list, most_sync_rt_dev::lock, most_sync_rt_dev::most_dev, MOST_DEV_CARDNUMBER, most_manage_usage, MOST_SYNC_OPENS, most_sync_rt_dev::open_count, PR, pr_sync_debug, rtnrt_err, and most_sync_rt_file::sync_dev.

static int most_sync_nrt_close ( struct rtdm_dev_context *  context,
rtdm_user_info_t *  user_info 
) [static]

Gets called if the MOST Synchronous RT device should be closed. Callable only from NRT context.

Parameters:
context Context structure associated with opened device instance
user_info Opaque pointer to information about user mode caller, NULL if kernel mode call

Definition at line 393 of file most-sync-rt-m.c.

References most_sync_rt_file::list, most_sync_rt_dev::lock, MAX_RETRIES, most_sync_rt_dev::most_dev, MOST_DEV_CARDNUMBER, most_manage_usage, most_sync_last_closed_rx, most_sync_last_closed_tx, most_sync_nrt_reconfigure_begin(), most_sync_nrt_reconfigure_end(), most_sync_nrt_stop_rx(), most_sync_nrt_stop_tx(), most_sync_rt_dev::open_count, PR, pr_sync_debug, most_sync_rt_dev::receiver_count, rtnrt_warn, most_sync_rt_file::rx_running, most_sync_rt_dev::rx_sync, most_sync_rt_file::sync_dev, most_sync_rt_dev::transmitter_count, most_sync_rt_file::tx_running, and most_sync_rt_dev::tx_sync.

static int most_sync_nrt_ioctl ( struct rtdm_dev_context *  context,
rtdm_user_info_t *  user_info,
int  request,
void *  arg 
) [static]

Gets called if the MOST Synchronous RT device should be configured Callable only from NRT context.

Parameters:
context Context structure associated with opened device instance
user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
request Request number as passed by the user
arg Request argument as passed by the user

Definition at line 536 of file most-sync-rt-m.c.

References most_sync_nrt_setup_rx(), most_sync_nrt_setup_tx(), MOST_SYNC_RT_IOCTL_MAGIC, MOST_SYNC_RT_SETUP_RX, and MOST_SYNC_RT_SETUP_TX.

static ssize_t most_sync_rt_read ( struct rtdm_dev_context *  context,
rtdm_user_info_t *  user_info,
void *  buff,
size_t  count 
) [static]

Gets called if data should be written from the MOST Synchronous RT device. Callable in RT and NRT context.

Parameters:
[in] context Context structure associated with opened device instance
[in] user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
[out] buff Input buffer as passed by the user
[in] count Number of bytes the user requests to read

Definition at line 590 of file most-sync-rt-m.c.

References rtnrt_copy_to_user_rt(), and most_sync_rt_file::sync_dev.

static ssize_t most_sync_rt_write ( struct rtdm_dev_context *  context,
rtdm_user_info_t *  user_info,
const void *  buff,
size_t  count 
) [static]

Gets called if data should be written to the MOST Synchronous RT device. Callable in RT and NRT context.

Parameters:
[in] context Context structure associated with opened device instance
[in] user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
[in] buff Output buffer as passed by the user
[in] count Number of bytes the user requests to write

Definition at line 662 of file most-sync-rt-m.c.

References rtnrt_copy_from_user_rt(), and most_sync_rt_file::sync_dev.

static void most_sync_nrt_stop_rx ( struct most_sync_rt_file file  )  [inline, static]

Stops reception (of the whole device) See p. 33 of OS8604 specification

Parameters:
[in,out] file the MOST synchonous file (rt)

Definition at line 196 of file most-sync-rt-m.c.

References most_sync_stop_rx_common, and most_sync_rt_file::sync_dev.

Referenced by most_sync_nrt_close(), most_sync_nrt_setup_rx(), and most_sync_nrt_setup_tx().

static void most_sync_nrt_stop_tx ( struct most_sync_rt_file file  )  [inline, static]

Stops transmission (of the whole device) See p. 33 of OS8604 specification

Parameters:
[in,out] file the MOST synchonous file (rt)

Definition at line 207 of file most-sync-rt-m.c.

References most_sync_stop_tx_common, and most_sync_rt_file::sync_dev.

Referenced by most_sync_nrt_close().

static int most_sync_nrt_reconfigure_begin ( struct most_conf_sync sync  )  [inline, static]

Must be executed at the beginning of most_sync_nrt_setup_rx() and most_sync_nrt_setup_tx().

Aquires the lock, i.e. synchronisation between NRT and RT. This means that the RT part must not be in most_sync_rt_read() or most_sync_rt_write(). If it's in one of these functions, it waits.

Parameters:
sync the synchronisation structure (rx or tx)
Returns:
0 on sucess, a negative error code on failure (interrupted, -EINTR)

Definition at line 223 of file most-sync-rt-m.c.

References most_conf_sync::counter, most_conf_sync::reconfigure_flag, and most_conf_sync::wait_reconfigure.

Referenced by most_sync_nrt_close(), most_sync_nrt_setup_rx(), and most_sync_nrt_setup_tx().

static void most_sync_nrt_reconfigure_end ( struct most_conf_sync sync  )  [inline, static]

Must be executed at the end of most_sync_nrt_setup_rx() and most_sync_nrt_setup_tx().

Releases the lock and wakes up waiting NRT and RT tasks.

Parameters:
sync the synchronisation structure (rx or tx)

Definition at line 258 of file most-sync-rt-m.c.

References most_conf_sync::reconfigure_flag, most_conf_sync::wait_read_write, and most_conf_sync::wait_reconfigure.

Referenced by most_sync_nrt_close(), most_sync_nrt_setup_rx(), and most_sync_nrt_setup_tx().

static int most_sync_rt_read_write_begin ( struct most_conf_sync sync  )  [inline, static]

Must be executed at the beginning of most_sync_rt_read() and most_sync_rt_write().

Checks if any NRT task is in configuratation period and waits until this is finished.

WARNING: This breaks real-time predictability since RT is waiting until NRT performs some tasks. You have to ensure in your application that no IOCTL call happens inside RT-critical code paths.

Parameters:
sync the synchronisation structure (rx or tx)
Returns:
0 on success, a negative error value on failure

Definition at line 285 of file most-sync-rt-m.c.

References assert, most_conf_sync::counter, most_conf_sync::reconfigure_flag, return_value_if_fails_dbg, and most_conf_sync::wait_read_write.

static void most_sync_rt_read_write_end ( struct most_conf_sync sync  )  [inline, static]

Must be executed at the end of most_sync_rt_read() and most_sync_rt_write().

Decreases the write counter and wakes up waiting Linux tasks if necessary.

Parameters:
sync the synchronisation structure (rx or tx)

Definition at line 316 of file most-sync-rt-m.c.

References assert, most_conf_sync::counter, and most_conf_sync::wait_reconfigure.

static int most_sync_nrt_setup_rx ( struct most_sync_rt_file file,
rtdm_user_info_t *  user_info,
void *  ioctl_arg 
) [inline, static]

See documentation of MOST_SYNC_RT_SETUP_RX.

Parameters:
file the most_syncrt__file structure
user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
ioctl_arg the already checked ioctl argument

Definition at line 448 of file most-sync-rt-m.c.

References copy_from_user_or_kernel, frame_part::count, hw_rx_buffer_size, most_sync_nrt_reconfigure_begin(), most_sync_nrt_reconfigure_end(), most_sync_nrt_stop_rx(), most_sync_setup_rx_common, frame_part::offset, PR, pr_sync_debug, most_sync_rt_file::rx_running, most_sync_rt_dev::rx_sync, sw_rx_buffer_size, and most_sync_rt_file::sync_dev.

Referenced by most_sync_nrt_ioctl().

static int most_sync_nrt_setup_tx ( struct most_sync_rt_file file,
rtdm_user_info_t *  user_info,
void *  ioctl_arg 
) [inline, static]

See documentation of MOST_SYNC_RT_SETUP_TX.

Parameters:
file the most_sync_rt_file structure
user_info Opaque pointer to information about user mode caller, NULL if kernel mode call
ioctl_arg the already checked ioctl argument

Definition at line 493 of file most-sync-rt-m.c.

References copy_from_user_or_kernel, hw_tx_buffer_size, most_sync_nrt_reconfigure_begin(), most_sync_nrt_reconfigure_end(), most_sync_nrt_stop_rx(), most_sync_setup_tx_common, sw_tx_buffer_size, most_sync_rt_file::sync_dev, most_sync_rt_file::tx_running, and most_sync_rt_dev::tx_sync.

Referenced by most_sync_nrt_ioctl().

static int most_sync_rt_probe ( struct most_dev most_dev  )  [static]

Gets called by the MOST driver when a new MOST device was discovered.

Parameters:
most_dev the most_dev that was discovered
Returns:
0 on success, an error code on failure

Definition at line 727 of file most-sync-rt-m.c.

References most_sync_rt_dev::file_list, most_sync_rt_dev::lock, most_conf_sync_init(), most_sync_rt_dev::most_dev, MOST_DEV_CARDNUMBER, MOST_DEVICE_NUMBER, most_sync_rt_devices, PR, pr_sync_debug, most_sync_rt_dev::receiver_count, return_value_if_fails_dbg, most_sync_rt_dev::rtdm_dev, rtnrt_warn, most_sync_rt_dev::rx_sync, most_sync_rt_dev::rx_wait, most_sync_rt_dev::transmitter_count, most_sync_rt_dev::tx_sync, and most_sync_rt_dev::tx_wait.

static int most_sync_rt_remove ( struct most_dev dev  )  [static]

Gets called by the MOST Base driver when a MOST device was removed.

Parameters:
dev the most_dev that was discovered
Returns:
0 on success, an error code on failure

Definition at line 787 of file most-sync-rt-m.c.

References most_conf_sync_destroy(), MOST_DEV_CARDNUMBER, most_sync_rt_devices, PR, pr_sync_debug, most_sync_rt_dev::rtdm_dev, most_sync_rt_dev::rx_sync, most_sync_rt_dev::rx_wait, most_sync_rt_dev::tx_sync, and most_sync_rt_dev::tx_wait.

static void most_sync_rt_interrupt_handler ( struct most_dev dev,
unsigned int  intstatus 
) [static]

Interrupt handler of a synchronous driver.

Parameters:
[in] dev the MOST device
[in] intstatus the interrupt status register content

Definition at line 815 of file most-sync-rt-m.c.

References dma_buffer::addr_virt, most_sync_rt_dev::hw_receive_buf, most_sync_rt_dev::hw_transmit_buf, ISSRX, ISSTX, measuring_receive_isr_start(), measuring_receive_isr_wakeup(), most_sync_rt_dev::most_dev, MOST_DEV_CARDNUMBER, MOST_PCI_SRXCTRL_REG, MOST_PCI_STXCTRL_REG, most_readreg_rt, most_sync_rt_devices, PR, pr_rt_irq_debug, return_if_fails_dbg, rtnrt_warn, most_sync_rt_dev::rx_current_page, most_sync_rt_dev::rx_wait, rxbuf_put(), dma_buffer::size, SRXPP, STXPP, most_sync_rt_dev::sw_receive_buf, most_sync_rt_dev::sw_transmit_buf, most_sync_rt_dev::tx_current_page, most_sync_rt_dev::tx_wait, and txbuf_get().

static int __init most_sync_rt_init ( void   )  [static]

This function gets called if the kernel loads this module.

Returns:
0 on success, an error code on failure

Definition at line 910 of file most-sync-rt-m.c.

References DRIVER_NAME, most_register_high_driver(), most_sync_rt_high_driver, print_measuring_warning(), rtnrt_info, serial_rt_debug_init(), and version.

static void __exit most_sync_rt_exit ( void   )  [static]

This function gets called if the Kernel removes this module.

Definition at line 931 of file most-sync-rt-m.c.

References DRIVER_NAME, most_deregister_high_driver(), most_sync_rt_high_driver, rtnrt_info, serial_rt_debug_finish(), and version.


Variable Documentation

char* version = "$Rev: 170 $" [static]

Variable that holds the version.

Definition at line 82 of file most-sync-rt-m.c.

struct most_sync_rt_dev* most_sync_rt_devices[MOST_DEVICE_NUMBER]

Array for each device.

Definition at line 87 of file most-sync-rt-m.c.

Referenced by most_sync_rt_interrupt_handler(), most_sync_rt_probe(), and most_sync_rt_remove().

long sw_rx_buffer_size = STD_MOST_FRAMES_PER_SEC

Module parameter that holds the size of the software receive buffer in number of stored frame parts.

Definition at line 104 of file most-sync-rt-m.c.

Referenced by most_sync_nrt_setup_rx(), and most_sync_setup_rx().

long sw_tx_buffer_size = STD_MOST_FRAMES_PER_SEC

Module parameter that holds the size of the software transmit buffer in number of stored frame parts.

Definition at line 109 of file most-sync-rt-m.c.

Referenced by most_sync_nrt_setup_tx(), most_sync_setup_tx(), snd_most_capture_open(), and snd_most_playback_open().

long hw_rx_buffer_size = 44

Module parameter that holds the size of the hardware receive buffer in number of stored frame parts.

Definition at line 114 of file most-sync-rt-m.c.

Referenced by most_sync_nrt_setup_rx(), most_sync_setup_rx(), and snd_most_new_pcm().

long hw_tx_buffer_size = 44

Module parameter that holds the size of the hardware transmit buffer in number of stored frame parts.

Definition at line 119 of file most-sync-rt-m.c.

Referenced by most_sync_nrt_setup_tx(), most_sync_setup_tx(), snd_most_capture_open(), snd_most_new_pcm(), and snd_most_playback_open().

struct rtdm_device device_templ [static]

The template for the struct rtdm_device which is used on device registration. This template is copied and modified then.

Definition at line 156 of file most-sync-rt-m.c.

struct most_high_driver most_sync_rt_high_driver [static]

Initial value:

 {
    .name                   = "most-sync-rt",
    .sema_list              = LIST_HEAD_INIT(most_sync_rt_high_driver.sema_list),
    .spin_list              = LIST_HEAD_INIT(most_sync_rt_high_driver.spin_list),
    .probe                  = most_sync_rt_probe,
    .remove                 = most_sync_rt_remove,
    .interrupt_mask         = (IESTX | IESRX),
    .int_handler            = most_sync_rt_interrupt_handler
}
The structure for the MOST High driver that is registered by the MOST PCI driver

Definition at line 895 of file most-sync-rt-m.c.

Referenced by most_sync_rt_exit(), and most_sync_rt_init().


Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0