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

axis_smart_card.c File Reference


Detailed Description

User space interface to the Axis smart card.

Author:
Andrew Roca
The Axis hardware includes a simple UART configured to work with a ISO 7816 smart card using the T1 protocol (3V operation required). The code in this file presents a simple character interface that supports read / write operations. An open will powerup and reset the smart card a close will power it down. IOCTLS exist for user control over the smart card reset and enable line. As well as a /proc interface to both lines

#include "axis_smart_card.h"
#include "serial_io.h"
#include "axis.h"
#include <asm/termbits.h>
#include <asm/ioctls.h>

Include dependency graph for axis_smart_card.c:

Include dependency graph

Defines

#define SMART_CARD_TIMEOUT   1000

Functions

void output_serial_routing (struct axis_pci_device_entry *device)
 write the serial routing out to the fpga

void input_serial_routing (struct axis_pci_device_entry *device)
 reads the serial routing from hardware to mirror

int proc_smart_card_write (const char *buffer, unsigned long n, void *data, unsigned long mask)
 takes inputs from /proc and sets a smart card control bit

int proc_smart_card_enable_write (struct file *file, const char *buffer, unsigned long count, void *data)
 function to allow /proc to control smart card

int proc_smart_card_reset_write (struct file *file, const char *buffer, unsigned long count, void *data)
 function to allow /proc to control smart card

int proc_smart_card_read (char *buf, char **start, off_t offset, int count, int *eof, void *data, unsigned long mask)
 reads the current start of the smart card outputs

int proc_smart_card_enable_read (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 read the current start of the smart card enable control outputs

int proc_smart_card_reset_read (char *buf, char **start, off_t offset, int count, int *eof, void *data)
 read the current start of the smart card reset control outputs

void delete_proc_smart_card_entries (struct axis_pci_device_entry *device)
 removes smart card related entries from axis /proc filesystem

void create_proc_smart_card_entries (struct axis_pci_device_entry *device)
 Creates a smart card releated /proc file system.

void start_smart_card (struct axis_pci_device_entry *device)
 Turns on the smart card.

void stop_smart_card (struct axis_pci_device_entry *device)
 Turns off the smart card.

ssize_t axis_smart_read (struct file *file_ptr, char *buffer, size_t size, loff_t *offset)
 Gets data from the smart card and returns it to userland.

ssize_t axis_smart_write (struct file *file_ptr, const char *buffer,size_t size,loff_t *offset)
 Copies data from USER space and sends it to the smart card.

int axis_smart_ioctl (struct inode *inode_ptr, struct file *file_ptr, unsigned int type,unsigned long args)
 Provides an interface to allow user land to control smart card clock / reset.

int axis_smart_open (struct inode *inode_ptr, struct file *file_ptr)
 open function for smart card sub device

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

void init_smart_card (struct axis_pci_device_entry *device)
 Initialise smart card structures.


Variables

file_operations smart_card_file_operations
 Define a file operations structure for output devices.


Define Documentation

#define SMART_CARD_TIMEOUT   1000
 


Function Documentation

int axis_smart_ioctl struct inode *  inode_ptr,
struct file *  file_ptr,
unsigned int  type,
unsigned long  args
[static]
 

Provides an interface to allow user land to control smart card clock / reset.

Parameters:
inode_ptr - inode
file_ptr - pointer to kernel file structure for open device
type- identifies the IOCTL operation requested
args- 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

Here is the call graph for this function:

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

open function for smart card sub 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 Open an individual SPI device for sanities sake only allow a single open for each device

Here is the call graph for this function:

ssize_t axis_smart_read struct file *  file_ptr,
char *  buffer,
size_t  size,
loff_t *  offset
[static]
 

Gets data from the smart card and returns it to userland.

Parameters:
file_ptr- pointer to kernel file structure for open device
buffer- pointer to user applications buffer
size- number of bytes to read
offset- 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.

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

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

Parameters:
inode_ptr - pointer to device inode not used
file_ptr - pointer to file structure not used
Returns:
0 on success

Release must decrement the open count to signal that the device has been finished with and that other processes can open it

Here is the call graph for this function:

ssize_t axis_smart_write struct file *  file_ptr,
const char *  buffer,
size_t  size,
loff_t *  offset
[static]
 

Copies data from USER space and sends it to the smart card.

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

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 create_proc_smart_card_entries struct axis_pci_device_entry device  ) 
 

Creates a smart card releated /proc file system.

Parameters:
device - hardware master structure
Returns:
none

Creates a smart card releated /proc file system

Here is the call graph for this function:

void delete_proc_smart_card_entries struct axis_pci_device_entry device  ) 
 

removes smart card related entries from axis /proc filesystem

Parameters:
device - hardware master structure
Returns:
none

removes smart card related entries from axis /proc filesystem

void init_smart_card struct axis_pci_device_entry device  ) 
 

Initialise smart card structures.

Parameters:
device - hardware master structure
Returns:
none

Initialise smart card structures, call at the point the PCI system detects the Axis hardware

void input_serial_routing struct axis_pci_device_entry device  )  [inline, static]
 

reads the serial routing from hardware to mirror

Parameters:
device - hardware master structure
Returns:
none

Smart card control bits are embedded in the serial routing register.

void output_serial_routing struct axis_pci_device_entry device  )  [inline, static]
 

write the serial routing out to the fpga

Parameters:
device - hardware master structure
Returns:
none

Currently the control bits for the smart card rest inside the serial routing register so smart card ops need to write the serial routing register. The serial lock should be aquired before calling this program

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

read the current start of the smart card enable control outputs

Parameters:
buf- destination passed in from /proc
start- destination passed in from /proc
offset- current file position ignored
count- number to read
eof- pointer to allow signalling of eof condition
data- user data supplied when /proc entry created cast back to hardware master structure
Returns:
length of string returned

Passed to /proc as a read call back returns current start of smart card enable output

Here is the call graph for this function:

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

function to allow /proc to control smart card

Parameters:
file- file object associated with /proc entry
buffer- data to write
count- number to write
data- user data supplied when /proc entry created cast back to hardware master structure
Returns:
pretends to write the number of bytes

A callback called by /proc

Here is the call graph for this function:

int proc_smart_card_read char *  buf,
char **  start,
off_t  offset,
int  count,
int *  eof,
void *  data,
unsigned long  mask
[static]
 

reads the current start of the smart card outputs

Parameters:
buf- destination passed in from /proc
start- destination passed in from /proc
offset- current file position ignored
count- number to read
eof- pointer to allow signalling of eof condition
data- user data supplied when /proc entry created cast back to hardware master structure
mask - which bit to set
Returns:
length of string returned

Common code to allow /proc smart card entries to return (read) current status

Here is the call graph for this function:

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

read the current start of the smart card reset control outputs

Parameters:
buf- destination passed in from /proc
start- destination passed in from /proc
offset- current file position ignored
count- number to read
eof- pointer to allow signalling of eof condition
data- user data supplied when /proc entry created cast back to hardware master structure
Returns:
length of string returned

Passed to /proc as a read call back returns current start of smart card reset output

Here is the call graph for this function:

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

function to allow /proc to control smart card

Parameters:
file- file object associated with /proc entry
buffer- data to write
count- number to write
data- user data supplied when /proc entry created cast back to hardware master structure
Returns:
pretends to write the number of bytes

A callback called by /proc

Here is the call graph for this function:

int proc_smart_card_write const char *  buffer,
unsigned long  n,
void *  data,
unsigned long  mask
[inline, static]
 

takes inputs from /proc and sets a smart card control bit

Parameters:
buffer - pointer to text command values of "0" and "1" recognised
n - not used
data - ends up cast hardware master structure
mask - which bit to clear/set
Returns:
number of bytes /proc system wanted to write

Common code for the two smart card /proc write callbacks factored into this function

Here is the call graph for this function:

void start_smart_card struct axis_pci_device_entry device  )  [inline, static]
 

Turns on the smart card.

Parameters:
device - hardware master structure
Returns:
none

Turns on and resets the smart card

Here is the call graph for this function:

void stop_smart_card struct axis_pci_device_entry device  )  [inline, static]
 

Turns off the smart card.

Parameters:
device - hardware master structure
Returns:
none

Here is the call graph for this function:


Variable Documentation

struct file_operations smart_card_file_operations
 

Initial value:

{
    read:      axis_smart_read,           
    write:     axis_smart_write,          
    ioctl:     axis_smart_ioctl,    
    open:      axis_smart_open,  
    release:   axis_smart_release,          
}
Define a file operations structure for output devices.


Generated on Fri Jan 28 12:34:52 2005 for Axis Kernel Driver by doxygen 1.3.6