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

parallel_io.c File Reference


Detailed Description

Parallel interface support.

Author:
Andrew Roca
Provides interfaces to allow user programs to read and write the parallel inputs and outputs implemented by the Axis hardware. The file supports two styles of operation firstly by file io using a character driver or by accessing entries in the /proc/axis_nn/ file system. The /dev/axis_nn/inputs uses a binary interface while the /proc interface understands primitive text based commands. Allowing access to the IO state from shell scripts and from the command line.

#include "parallel_io.h"
#include "axis_pci.h"

Include dependency graph for parallel_io.c:

Include dependency graph

Functions

void FlushOutputsToDevice (struct axis_pci_device_entry *device)
 Flush output mirrors out to hardware.

void init_parallel_io (struct axis_pci_device_entry *device)
 Initalises AXIS parallel.

void enable_axis_inputs (struct axis_pci_device_entry *device)
 Enables Axis inputs.

void enable_axis_outputs (struct axis_pci_device_entry *device)
 Enables Axis outputs.

void update_inputs_bitmap (struct axis_pci_device_entry *device)
 synchs the inputs mirror with physical hardware

loff_t axis_input_llseek (struct file *file_ptr, loff_t offset,int whence)
 handles user lseek calls for input device.

ssize_t axis_input_read (struct file *file_ptr, char *buf, size_t count, loff_t *ppos)
 Gets data from the inputs and returns it to userland.

void axis_dipswitch_update (struct axis_pci_device_entry *device)
 Updates dipswitch mirror.

ssize_t axis_dipswitch_read (struct file *file_ptr, char *buf, size_t count, loff_t *ppos)
 Gets data from the dipswitchs and returns it to userland.

ssize_t axis_input_write (struct file *file_ptr, const char *buf, size_t count, loff_t *ppos)
int axis_input_ioctl (struct inode *inode_ptr, struct file *file_ptr, unsigned int type, unsigned long data)
 Provides an interface to allow user land to control input processing.

int axis_input_open (struct inode *inode_ptr, struct file *file_ptr)
 open function input device

int axis_input_release (struct inode *inode_ptr, struct file *file_ptr)
 Called by kernel in response to a process closing input device.

int axis_dipswitch_open (struct inode *inode_ptr, struct file *file_ptr)
 open function for dipswitches

int axis_dipswitch_release (struct inode *inode_ptr, struct file *file_ptr)
 Called by kernel in response to a process closing a device.

int axis_input_fsync (struct file *file_ptr, struct dentry *directory, int datasync)
 updates input mirror after user request

loff_t axis_output_llseek (struct file *file_ptr, loff_t offset,int whence)
 handles user lseek calls for output device.

ssize_t axis_output_read (struct file *file_ptr, char *buf, size_t count, loff_t *ppos)
 Returns current output state.

ssize_t axis_output_write (struct file *file_ptr, const char *buf, size_t count, loff_t *ppos)
 Copies data from USER space and sends it to outputs.

int axis_output_ioctl (struct inode *inode_ptr, struct file *file_ptr, unsigned int type, unsigned long data)
 Provides an interface to allow user land to output handling.

int axis_output_open (struct inode *inode_ptr, struct file *file_ptr)
 open function for parallel output

int axis_output_release (struct inode *inode_ptr, struct file *file_ptr)
 Called by kernel in response to a process closing a device.

int axis_output_fsync (struct file *file_ptr, struct dentry *directory, int datasync)
 Forces outputs to be updated.

void bin_to_text (unsigned char *bin_start, char *text_start, off_t offset, int count, size_t buffer_size)
 Given a pointer to a binary block creates a text string out off 1 and 0 to represent it.

int proc_read_inputs (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read inputs callback function

int proc_read_dipswitches (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read dipswitchs callback function

int proc_read_outputs (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read output callback function

int proc_write_outputs (struct file *file, const char *buffer, unsigned long count, void *data)
 Passed a text string converts it to a binary form and writes it to the outputs.

int proc_write_single_output (struct file *file, const char *buffer, unsigned long count, void *data)
 Passed a text string converts it to a binary form and writes it to a specific single output.

int proc_read_single_input (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read input callback function

int proc_read_single_dipswitch (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read dipswitch callback function

int proc_read_single_output (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 /Proc read outputs callback function

void create_proc_input_entries (struct axis_pci_device_entry *device)
 create /proc entries for inputs

void create_proc_output_entries (struct axis_pci_device_entry *device)
 create /proc entries for outputs

void delete_proc_output_entries (struct axis_pci_device_entry *device)
 Remove the /proc output entries.

void delete_proc_input_entries (struct axis_pci_device_entry *device)
 Remove the /proc input entries.

void create_proc_dipswitch_entries (struct axis_pci_device_entry *device)
 create /proc entries for dipswitches

void delete_proc_dipswitch_entries (struct axis_pci_device_entry *device)
 Remove the /proc dipswitch entries.


Variables

input_def input_definitions []
 Associates a text string wil.

output_def output_definitions []
file_operations input_file_operations
file_operations dipswitch_file_operations
file_operations output_file_operations

Function Documentation

int axis_dipswitch_open struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

open function for dipswitches

Parameters:
inode_ptr - pointer to inode structure the kernel will associate with this instance
file_ptr - pointer to the file structure the kernel uses to track this open instance
Returns:
0 on sucess error code otherwise

This open is called from the general open after its worked out what type of subdevice user space has requested Nothing to be done the default axis open sets everything up OK

ssize_t axis_dipswitch_read struct file *  file_ptr,
char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

Gets data from the dipswitchs and returns it to userland.

Parameters:
file_ptr - pointer to kernel file structure for open device
buf- pointer to user applications buffer
count- number of bytes to read
ppos- not used
Returns:
number read-

Called by kernel in response to a user application making a read call. Note the user buffer pointer is not a valid address from inside the kernel. Reads the dipswitchs values from the fpga and stores then in the bitswitch map associated with the PCI device structure Read inputs expands bit packed IO to byte aligned IO so to read the first 8 inputs read the first 8 bytes not the first one this should make locking and sharing simpler

Here is the call graph for this function:

int axis_dipswitch_release struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

Called by kernel in response to a process closing a device.

Parameters:
inode_ptr - not currently used
file_ptr - not currently used
Returns:
0 on success

Called by kernel if user application closes device, nothing to do

void axis_dipswitch_update struct axis_pci_device_entry device  )  [static]
 

Updates dipswitch mirror.

Parameters:
device - hardware master structure
Returns:
NONE

Reads dipswitch hardware and updates mirror data

int axis_input_fsync struct file *  file_ptr,
struct dentry *  directory,
int  datasync
[static]
 

updates input mirror after user request

Parameters:
file_ptr - not currently used
directory - not currently used
datasync - not currently used
Returns:
zero

Allows user applications to force a clean input read

Here is the call graph for this function:

int axis_input_ioctl struct inode *  inode_ptr,
struct file *  file_ptr,
unsigned int  type,
unsigned long  data
[static]
 

Provides an interface to allow user land to control input processing.

Parameters:
inode_ptr - devices inode
file_ptr - pointer to kernel file structure for open device
type- identifies the IOCTL operation requested
data- unspecified parameter supplied by user program meaning depends on type
Returns:
0 on success error number otherwise

To allow user applications options other then read / write the driver supports IOCTL calls the type constants are defined in axis.h No ioctls defined so far

loff_t axis_input_llseek struct file *  file_ptr,
loff_t  offset,
int  whence
[static]
 

handles user lseek calls for input device.

Parameters:
file_ptr - pointer to kernel file structure for open device
offset - file offset requested
whence - New offset is from head or tail of file
Returns:
new offset

Called by kernel in response to a user application making a llseek call. Resets the file_ptrs f_pos element to new position

int axis_input_open struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

open function input device

Parameters:
inode_ptr - pointer to inode structure the kernel will associate with this instance
file_ptr - pointer to the file structure the kernel uses to track this open instance
Returns:
0 on sucess error code otherwise

This open is called from the general open after its worked out what type of subdevice user space has requested Nothing to be done the default axis open sets everything up OK

ssize_t axis_input_read struct file *  file_ptr,
char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

Gets data from the inputs and returns it to userland.

Parameters:
file_ptr - pointer to kernel file structure for open device
buf - pointer to user applications buffer
count - number of bytes to read
ppos - start offset
Returns:
number read

Called by kernel in response to a user application making a read call. Note the user buffer pointer is not a valid address from inside the kernel. Read inputs expands bit packed IO to byte aligned IO so to read the first 8 inputs read the first 8 bytes not the first one this should make locking and sharing simpler

Here is the call graph for this function:

int axis_input_release struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

Called by kernel in response to a process closing input device.

Parameters:
inode_ptr 
file_ptr 
Returns:
0 on success

Called by kernel if user application closes device, nothing to do

ssize_t axis_input_write struct file *  file_ptr,
const char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

int axis_output_fsync struct file *  file_ptr,
struct dentry *  directory,
int  datasync
[static]
 

Forces outputs to be updated.

Returns:
zero

Flushs parallel output buffers to device, callable from user space

Here is the call graph for this function:

int axis_output_ioctl struct inode *  inode_ptr,
struct file *  file_ptr,
unsigned int  type,
unsigned long  data
[static]
 

Provides an interface to allow user land to output handling.

Parameters:
inode_ptr - devices inode
file_ptr - pointer to kernel file structure for open device
type- identifies the IOCTL operation requested
data- unspecified parameter supplied by user program meaning depends on type
Returns:
0 on success error number otherwise

To allow user applications options other then read / write the driver support IOCTL calls the type constants are defined in axis.h Currently no IOCTLS defined for outputs

loff_t axis_output_llseek struct file *  file_ptr,
loff_t  offset,
int  whence
[static]
 

handles user lseek calls for output device.

Parameters:
file_ptr - pointer to kernel file structure for open device
offset - file offset requested
whence - New offset is from head or tail of file
Returns:
new offset

Called by kernel in response to a user application making a llseek call. Resets the file_ptrs f_pos element to new position

int axis_output_open struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

open function for parallel output

Parameters:
inode_ptr - pointer to inode structure the kernel will associate with this instance
file_ptr - pointer to the file structure the kernel uses to track this open instance
Returns:
0 on sucess error code otherwise

This open is called from the general open after its worked out what type of subdevice user space has requested Nothing to be done the default axis open sets everything up OK

ssize_t axis_output_read struct file *  file_ptr,
char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

Returns current output state.

Parameters:
file_ptr - pointer to kernel file structure for open device
buf - pointer to user applications buffer
count - number of bytes to read
ppos - start offset
Returns:
number read

Reads the axis outputs, allows an application to see the current output state as a small complication we convert a hardware representation of one bit per output to a software one of one byte per output. This should give application programs effective random access to the outputs and reduce the chances of any nasty race conditions.

int axis_output_release struct inode *  inode_ptr,
struct file *  file_ptr
[static]
 

Called by kernel in response to a process closing a device.

Parameters:
inode_ptr 
file_ptr 
Returns:
0 on success

Called by kernel if user application closes device, nothing to do

ssize_t axis_output_write struct file *  file_ptr,
const char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

Copies data from USER space and sends it to outputs.

Parameters:
file_ptr - pointer to kernel file structure for open device
buf - user processes buffer
count - number of bytes to write
ppos- allow lseek offset
Returns:
number written

Writes parallel outputs to hardware. The hardware allocates one bit per output. However to reduce possible race conditions caused by multiple programs modifing seperate but physically close outputs the user interface sees one byte per output. All non zero values are assumed to represent a logic on. Called by the kernel in response to a write call by a user application. Note the buffer address supplied will not be a valid kernel address

Here is the call graph for this function:

void bin_to_text unsigned char *  bin_start,
char *  text_start,
off_t  offset,
int  count,
size_t  buffer_size
[static]
 

Given a pointer to a binary block creates a text string out off 1 and 0 to represent it.

Parameters:
bin_start - binary data
text_start - text buffer to write result
offset - Allow starting at an offset rather than the start
count - number of bits to do
buffer_size - size of destination
Returns:
NONE

Given a pointer to a binary block creates a text string out off 1 and 0 to represent it

void create_proc_dipswitch_entries struct axis_pci_device_entry device  ) 
 

create /proc entries for dipswitches

Parameters:
device - master hardware structure
Returns:
NONE

Called by the PCI probe function creates a directory full of inputs

Here is the call graph for this function:

void create_proc_input_entries struct axis_pci_device_entry device  ) 
 

create /proc entries for inputs

Parameters:
device - master hardware structure
Returns:
NONE

Called by the PCI probe function creates a directory full of inputs

Here is the call graph for this function:

void create_proc_output_entries struct axis_pci_device_entry device  ) 
 

create /proc entries for outputs

Parameters:
device - master hardware structure
Returns:
NONE

Called by the PCI probe function creates a directory full of outputs

Here is the call graph for this function:

void delete_proc_dipswitch_entries struct axis_pci_device_entry device  ) 
 

Remove the /proc dipswitch entries.

Parameters:
device - master hardware structure
Returns:
NONE

Removes the /proc dipswitch entries

void delete_proc_input_entries struct axis_pci_device_entry device  ) 
 

Remove the /proc input entries.

Parameters:
device - master hardware structure
Returns:
NONE

Delete all the input /proc entries called if PCI device removed (unlikely) or on module unload

void delete_proc_output_entries struct axis_pci_device_entry device  ) 
 

Remove the /proc output entries.

Parameters:
device - master hardware structure
Returns:
NONE

Remove all the entries in the /proc file system related to outputs

void enable_axis_inputs struct axis_pci_device_entry device  ) 
 

Enables Axis inputs.

Parameters:
device - hardware master structure
Returns:
NONE

Enables Axis inputs

void enable_axis_outputs struct axis_pci_device_entry device  )  [inline, static]
 

Enables Axis outputs.

Parameters:
device - hardware master structure
Returns:
NONE

Enables Axis outputs

void FlushOutputsToDevice struct axis_pci_device_entry device  )  [inline, static]
 

Flush output mirrors out to hardware.

Parameters:
device - hardware master structure
Returns:
NONE

Flush output mirrors out to hardware and writes the outputs to the physical devices

void init_parallel_io struct axis_pci_device_entry device  ) 
 

Initalises AXIS parallel.

Parameters:
device - hardware master structure
Returns:
NONE

Initalises AXIS parallel, called as PCI device is detected

Here is the call graph for this function:

int proc_read_dipswitches char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read dipswitchs callback function

Parameters:
buf- address to write results to
start - not used
offset- offet to write to
count- number of bytes to read
eof- used to signal end of data
data- user supplied parameter
Returns:
number of bytes written negative value for error

Read all the dipswitchs and output them as text. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_read_inputs char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read inputs callback function

Parameters:
buf- address to write results to
start - not used
offset- offet to write to
count- number of bytes to read
eof- used to signal end of data
data- user supplied parameter
Returns:
number of bytes written negative value for error

Read all the inputs and output them as text. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_read_outputs char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read output callback function

Parameters:
buf- address to write results to
start - not used
offset - offet to write to
count - number of bytes to read
eof - used to signal end of data
data - user supplied parameter
Returns:
number of bytes written negative value for error

Read all the outputs and output them as text. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_read_single_dipswitch char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read dipswitch callback function

Parameters:
buf- address to write results to
start - not used
offset- offet to write to
count- number of bytes to read
eof- used to signal end of data
data- user supplied parameter
Returns:
number of bytes written negative value for error

Read an dipswitch input and output it as text. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_read_single_input char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read input callback function

Parameters:
buf- address to write results to
start - not used
offset- offet to write to
count- number of bytes to read
eof- used to signal end of data
data- user supplied parameter
Returns:
number of bytes written negative value for error

Read a single input and output it as text. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_read_single_output char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data
[static]
 

/Proc read outputs callback function

Parameters:
buf- address to write results to
start - not used
offset- offet to write to
count- number of bytes to read
eof- used to signal end of data
data- user supplied parameter
Returns:
number of bytes written negative value for error

Read an output and output its current state as text. A callback function passed to the /proc file syste,

int proc_write_outputs struct file *  file,
const char *  buffer,
unsigned long  count,
void *  data
[static]
 

Passed a text string converts it to a binary form and writes it to the outputs.

Parameters:
file - not used
buffer - data to write
count - number to write
data - user supplied parameter
Returns:
NONE

Passed a text string converts it to a binary form and writes it to the outputs. A callback function passed to the /proc file system

Here is the call graph for this function:

int proc_write_single_output struct file *  file,
const char *  buffer,
unsigned long  count,
void *  data
[static]
 

Passed a text string converts it to a binary form and writes it to a specific single output.

Parameters:
file - not used
buffer - data to write
count - number to write
data - user supplied parameter
Returns:
NONE

Passed a text string converts it to a binary form and writes it to a specific single output. A callback function passed to the /proc file system

Here is the call graph for this function:

void update_inputs_bitmap struct axis_pci_device_entry device  ) 
 

synchs the inputs mirror with physical hardware

Parameters:
device - hardware master structure
Returns:
NONE

Reads the inputs temp version pending stage two inputs


Variable Documentation

struct file_operations dipswitch_file_operations
 

Initial value:

{
                                          
    llseek:          axis_input_llseek,         
    read:            axis_dipswitch_read,           
                                              
                                          
                                          
                                          
                                               
    open:            axis_dipswitch_open,            
                                           
    release:         axis_dipswitch_release,          
                                            
                                           
                                           
                                           
                                           
}

struct input_def input_definitions[] [static]
 

Associates a text string wil.

struct file_operations input_file_operations
 

Initial value:

{
                                          
    llseek:          axis_input_llseek,         
    read:            axis_input_read,           
    write:           axis_input_write,          
                                          
                                          
    ioctl:           axis_input_ioctl,          
   
    open:            axis_input_open,            
                                           
    release:         axis_input_release,          
    fsync:           axis_input_fsync,       
                                           
                                           
                                           
                                           
}

struct output_def output_definitions[] [static]
 

struct file_operations output_file_operations
 

Initial value:

{
                                          
    llseek:          axis_output_llseek,         
    read:            axis_output_read,           
    write:           axis_output_write,          
                                          
                                          
    ioctl:           axis_output_ioctl,          
    
    open:            axis_output_open,            
                                           
    release:         axis_output_release,          
    fsync:           axis_output_fsync,       
                                           
                                           
                                           
                                           
}


Generated on Fri Jan 28 12:36:42 2005 for Axis Kernel Driver by doxygen 1.3.6