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

axis_driver.c File Reference


Detailed Description

Top level driver initalisation and removal code + inital open.

Author:
Andrew Roca
This contains the axis driver inital entry code plus the top level initalisation code detailed initalistion occur after a call back from the PCI subsystem. Also contains the first open call (C++ types might think of it as a device instance factory) Modifing a open kernel file structure to dynamically subclass the driver based on the device minor number

#include "axis_driver.h"
#include "axis.h"
#include "axis_pci.h"
#include "axis_sram.h"
#include "des_io.h"
#include "parallel_io.h"
#include "serial_io.h"
#include "spi_io.h"
#include "axis_smart_card.h"

Include dependency graph for axis_driver.c:

Include dependency graph

Defines

#define TITLE   "Axis2 PCI Bridge"
#define ISSUE   "0.0"
#define DRIVER_DESC   "Axis PCI Kernel Driver"
#define DRIVER_AUTHOR   "Heber Limited <http://www.heber.co.uk>"
#define DRIVER_SUPPORTED_DEVICES   "Axis"
#define AXIS_PCI_VENDOR_ID   0x10b5
#define AXIS_PCI_DEVICE_ID   0x3001
#define STATIC_RAM_REGION   2
#define CONTROL_REGION   4
#define CONTROL_OFFSET   0x800
#define MAX_REGION   6
#define MAX_AXIS_ROUTED_SERIAL_PORTS   4
#define AXIS_MAX_UARTS   8
#define DIPSWITCH_OFFSET   0x64
#define IO_REGION   3

Functions

 MODULE_LICENSE ("GPL")
 MODULE_DESCRIPTION ("Axis PCI Kernel Driver")
 MODULE_AUTHOR ("Heber Limited< http://www.heber.co.uk >")
 MODULE_SUPPORTED_DEVICE ("Axis")
int axis_general_open (struct inode *inode_ptr,struct file *file_ptr)
 The main entry point for open operations against the major character device associated with this driver.

proc_dir_entry * create_axis_root (struct proc_dir_entry *parent, struct axis_pci_device_entry *device)
 Create axis /proc root directory.

void delete_axis_root (struct axis_pci_device_entry *device)
 Deletes an axis entry in the /proc file system.

int add_proc_exports (struct axis_pci_device_entry *device)
 Function to create a set of axis specific entries in the /proc file system.

void remove_proc_exports (struct axis_pci_device_entry *device)
 Function to delete Axis entries from /proc.

int axis_activity_thread (void *data)
 Function for a thread scans for missing interrupts and time out the driver.

void pci_remove (struct pci_dev *dev)
 Callback passed to PCI subsystem so it can signal either a removal or an unload.

int init_module (void)
 This value is currently unassigned according to Documentation/devices/txt Called by the kernel when the module is first loaded allows module it initialise.

void cleanup_module (void)
 Called by the kernel when module is about to be unloaded.


Variables

file_operations driver_file_operations
pci_device_id pci_id_table []
pci_driver axis_pci_driver
 Defines a pci driver struct that can be passed to the kernel PCI subsystem.

char * driver_name = "Axis_2_PCI_Bridge"
 Defines a name for this driver.

int driver_major_number = 231
 Allocate a major number.


Define Documentation

#define AXIS_MAX_UARTS   8
 

#define AXIS_PCI_DEVICE_ID   0x3001
 

#define AXIS_PCI_VENDOR_ID   0x10b5
 

#define CONTROL_OFFSET   0x800
 

#define CONTROL_REGION   4
 

#define DIPSWITCH_OFFSET   0x64
 

#define DRIVER_AUTHOR   "Heber Limited <http://www.heber.co.uk>"
 

#define DRIVER_DESC   "Axis PCI Kernel Driver"
 

#define DRIVER_SUPPORTED_DEVICES   "Axis"
 

#define IO_REGION   3
 

#define ISSUE   "0.0"
 

#define MAX_AXIS_ROUTED_SERIAL_PORTS   4
 

#define MAX_REGION   6
 

#define STATIC_RAM_REGION   2
 

#define TITLE   "Axis2 PCI Bridge"
 


Function Documentation

int add_proc_exports struct axis_pci_device_entry device  ) 
 

Function to create a set of axis specific entries in the /proc file system.

Parameters:
device - the master configuration/control structure for each Axis PCI device
Returns:
always 0

Adds a set of entries to the /proc file system these allow easy configuration and control to be implemented from the command line or via shell scripts as well as from conventional programming

Here is the call graph for this function:

int axis_activity_thread void *  data  ) 
 

Function for a thread scans for missing interrupts and time out the driver.

Parameters:
data - typed as void as this function is a callback but casted back to pointer to Master control structure
Returns:
0 but not relevent

This function becomes the main loop in a kernel thread tracking the Axis hardware in the background. Main use is to timeout IO which stall pending a non occuring interrupt

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

The main entry point for open operations against the major character device associated with this driver.

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 splits the minor number and chooses the correct physical device it then uses the type field to replace the file operations pointer in the file * with one corresponding to the selected hardware element requested. It then calls the hardware specific open

Here is the call graph for this function:

void cleanup_module void   ) 
 

Called by the kernel when module is about to be unloaded.

Returns:
none

Called by the kernel prior to the axis module being unloaded (rmmod axis). Unregisters the Axis hardware from PCI system this calls the callback pci_remove. This then cleans up the axis data structures. The cleanup then removes the character driver

struct proc_dir_entry * create_axis_root struct proc_dir_entry *  parent,
struct axis_pci_device_entry device
[static]
 

Create axis /proc root directory.

Parameters:
parent - were in the existing /proc tree to attach axis root
device - pointer to master control structure for each PCI instance
Returns:
pointer to root of axis /proc tree

Creates a root directory within the /proc directory entry for each axis device

void delete_axis_root struct axis_pci_device_entry device  )  [static]
 

Deletes an axis entry in the /proc file system.

Parameters:
device - pointer to master structure for each set of axis hardware
Returns:
none

Code is built in theory to support multiple devices so multiple entries might exit one for each device. So code checks in the PCI structure to work out which one to clobber

int init_module void   ) 
 

This value is currently unassigned according to Documentation/devices/txt Called by the kernel when the module is first loaded allows module it initialise.

Returns:
0 on success error no otherwise

All modules have at least two entry points the first init_module is called by the kernel and the driver must initalise itself starting from this entry point. Function is quite simple first it creates a character device so it can be accessed through /dev type special files created with mknod. Then it registers a structure with the PCI subsystem. The structure identifies the Axis hardware and includes call backs that the PCI system calls if it recognises Axis hardware, the callbacks then build the structures needed.

MODULE_AUTHOR "Heber Limited< http://www.heber.co.uk >"   ) 
 

MODULE_DESCRIPTION "Axis PCI Kernel Driver"   ) 
 

MODULE_LICENSE "GPL"   ) 
 

MODULE_SUPPORTED_DEVICE "Axis"   ) 
 

void pci_remove struct pci_dev *  dev  )  [static]
 

Callback passed to PCI subsystem so it can signal either a removal or an unload.

Parameters:
dev - pointer to pci_dev structure
Returns:
none

This function is a callback its included in a stucture passed to the PCI subsystem when the Axis driver signals interest in PCI devices with the Axis idenity. If the Axis device is unplugged or rather more likely the driver calls pci_unregister as part of its unload procedure the PCI system calls this call back. In practice the tear down of Axis resources is started from this callback.

Here is the call graph for this function:

void remove_proc_exports struct axis_pci_device_entry device  ) 
 

Function to delete Axis entries from /proc.

Parameters:
device - master structure pointer for each Axis
Returns:
none

Here is the call graph for this function:


Variable Documentation

struct pci_driver axis_pci_driver [static]
 

Initial value:

{
    name:   "Axis2_PCI_Bridge",
    id_table:   pci_id_table,
    probe:      pci_probe,
    remove:     pci_remove
}
Defines a pci driver struct that can be passed to the kernel PCI subsystem.

struct file_operations driver_file_operations [static]
 

Initial value:

{
    open:            axis_general_open,       
}
Defines a table of file operations callbacks for an Axis device (mostly NULL) All opens to the axis major number go through this table. The open function then replaces the file op table in the open file * structure with a new one based upon the minor number

int driver_major_number = 231 [static]
 

Allocate a major number.

char* driver_name = "Axis_2_PCI_Bridge" [static]
 

Defines a name for this driver.

struct pci_device_id pci_id_table[] [static]
 

Initial value:

{
    { 0x10b5 ,  0x3001 , PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
    {0,}
}
Table of PCI Identifiers the driver should respond to This is passed to the kernel PCI subsystem so it knows Which devices the Axis driver is interested in


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