flinkLinux
flink Linux Kernel Modules
 All Data Structures Files Functions Variables Macros Pages
flink.h File Reference

Function prototypes and data structures for core module. More...

#include <linux/types.h>
#include <linux/spinlock_types.h>
#include <linux/list.h>
#include <linux/fs.h>
Include dependency graph for flink.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  flink_private_data
 Private data structure which is associated with a file. The user library communicates with the kernel modules through read and write system calls As a parameter a pointer to a file descriptor is passed. Within this structure the field will hold the information about which device and subdevice will be targeted. More...
 
struct  flink_bus_ops
 Functions to communicate with various bus communication modules. More...
 
struct  flink_subdevice
 Describes a subdevice. More...
 
struct  flink_device
 Describes a device. More...
 
struct  ioctl_bit_container_t
 Structure containing information for ioctl system calls accessing single bits. More...
 
struct  ioctl_container_t
 Structure containing information for ioctl system calls. More...
 

Macros

#define UNKOWN_ERROR   -1
 
#define MAX_NOF_SUBDEVICES   256
 
#define MAX_ADDRESS_SPACE   0x10000
 
#define MAIN_HEADER_SIZE   16
 
#define SUB_HEADER_SIZE   16
 
#define SUBDEV_FUNCTION_OFFSET   0x0000
 
#define SUBDEV_SIZE_OFFSET   0x0004
 
#define SUBDEV_NOFCHANNELS_OFFSET   0x0008
 
#define SUBDEV_UNIQUE_ID_OFFSET   0x000C
 
#define SUBDEV_STATUS_OFFSET   0x0010
 
#define SUBDEV_CONFIG_OFFSET   0x0014
 
#define INFO_FUNCTION_ID   0x00
 
#define SELECT_SUBDEVICE   0x10
 
#define SELECT_SUBDEVICE_EXCL   0x11
 
#define SELECT_SUBDEVICE   0x10
 
#define SELECT_SUBDEVICE_EXCL   0x11
 
#define READ_NOF_SUBDEVICES   0x20
 
#define READ_SUBDEVICE_INFO   0x21
 
#define READ_SINGLE_BIT   0x30
 
#define WRITE_SINGLE_BIT   0x31
 
#define SELECT_AND_READ_BIT   0x40
 
#define SELECT_AND_WRITE_BIT   0x41
 
#define SELECT_AND_READ   0x42
 
#define SELECT_AND_WRITE   0x43
 
#define FLINKLIB_SUBDEVICE_SIZE   (sizeof(struct flink_subdevice)-offsetof(struct flink_subdevice,id))
 

Functions

struct flink_deviceflink_device_alloc (void)
 Allocate a flink_device structure. More...
 
void flink_device_init (struct flink_device *fdev, struct flink_bus_ops *bus_ops, struct module *mod)
 Initialize a flink_device structure. More...
 
int flink_device_add (struct flink_device *fdev)
 Add a flink device to the system, making it live immediately. More...
 
int flink_device_remove (struct flink_device *fdev)
 Remove a flink device from the system. More...
 
int flink_device_delete (struct flink_device *fdev)
 Deletes a flink device and frees the allocated memory. All subdevices will be deleted, using flink_subdevice_remove() and flink_subdevice_delete(). More...
 
struct flink_deviceflink_get_device_by_id (u8 flink_device_id)
 Get a flink device by its id. More...
 
struct flink_deviceflink_get_device_by_cdev (struct cdev *char_device)
 Get a flink device by cdev. More...
 
struct list_head * flink_get_device_list (void)
 Get a list with all devices. More...
 
struct flink_subdeviceflink_subdevice_alloc (void)
 Allocate a flink_subdevice structure. More...
 
void flink_subdevice_init (struct flink_subdevice *fsubdev)
 Initialize a flink_subdevice structure, making it ready to add to a flink_device with flink_subdevice_add() More...
 
int flink_subdevice_add (struct flink_device *fdev, struct flink_subdevice *fsubdev)
 Add a flink subdevice to flink device. More...
 
int flink_subdevice_remove (struct flink_subdevice *fsubdev)
 Remove a flink subdevice from the parent device. More...
 
int flink_subdevice_delete (struct flink_subdevice *fsubdev)
 Deletes a flink subdevice and frees the allocated memory. More...
 
struct flink_subdeviceflink_get_subdevice_by_id (struct flink_device *fdev, u8 flink_device_id)
 Get a flink subdevice by its id. More...
 
struct class * flink_get_sysfs_class (void)
 Get a flink sysfs class. More...
 
int flink_select_subdevice (struct file *f, u8 subdevice, bool exclusive)
 Select a subdevice for exclusive access. More...
 

Variables

const char * fmit_lkm_lut []
 

Detailed Description

Function prototypes and data structures for core module.

Author
Martin Züger
Urs Graf

Macro Definition Documentation

#define FLINKLIB_SUBDEVICE_SIZE   (sizeof(struct flink_subdevice)-offsetof(struct flink_subdevice,id))
#define INFO_FUNCTION_ID   0x00
#define MAIN_HEADER_SIZE   16
#define MAX_ADDRESS_SPACE   0x10000
#define MAX_NOF_SUBDEVICES   256
#define READ_NOF_SUBDEVICES   0x20
#define READ_SINGLE_BIT   0x30
#define READ_SUBDEVICE_INFO   0x21
#define SELECT_AND_READ   0x42
#define SELECT_AND_READ_BIT   0x40
#define SELECT_AND_WRITE   0x43
#define SELECT_AND_WRITE_BIT   0x41
#define SELECT_SUBDEVICE   0x10
#define SELECT_SUBDEVICE   0x10
#define SELECT_SUBDEVICE_EXCL   0x11
#define SELECT_SUBDEVICE_EXCL   0x11
#define SUB_HEADER_SIZE   16
#define SUBDEV_CONFIG_OFFSET   0x0014
#define SUBDEV_FUNCTION_OFFSET   0x0000
#define SUBDEV_NOFCHANNELS_OFFSET   0x0008
#define SUBDEV_SIZE_OFFSET   0x0004
#define SUBDEV_STATUS_OFFSET   0x0010
#define SUBDEV_UNIQUE_ID_OFFSET   0x000C
#define UNKOWN_ERROR   -1
#define WRITE_SINGLE_BIT   0x31

Function Documentation

int flink_device_add ( struct flink_device fdev)

Add a flink device to the system, making it live immediately.

Parameters
fdevThe flink device to add.
Returns
int: A negative error code is returned on failure.
struct flink_device* flink_device_alloc ( void  )

Allocate a flink_device structure.

Returns
flink_device*: Pointer to the new flink_device structure, or NULL on failure.
int flink_device_delete ( struct flink_device fdev)

Deletes a flink device and frees the allocated memory. All subdevices will be deleted, using flink_subdevice_remove() and flink_subdevice_delete().

Parameters
fdevThe flink_device structure to delete.
Returns
int: A negative error code is returned on failure.

Here is the call graph for this function:

void flink_device_init ( struct flink_device fdev,
struct flink_bus_ops bus_ops,
struct module *  mod 
)

Initialize a flink_device structure.

Parameters
fdevThe structure to initialize
bus_opsThe flink_bus_ops for this device, remember them when adding them to system with flink_device_add().
modThe kernel module this flink uses for hardware access.
int flink_device_remove ( struct flink_device fdev)

Remove a flink device from the system.

Parameters
fdevThe flink device to remove.
Returns
int: A negative error code is returned on failure.
struct flink_device* flink_get_device_by_cdev ( struct cdev *  char_device)

Get a flink device by cdev.

Parameters
char_devicePointer to the cdev struct of a flink device.
Returns
flink_device*: Returns the flink device structure associated with the given cdev. NULL is returned if no suitable device is found.

Here is the caller graph for this function:

struct flink_device* flink_get_device_by_id ( u8  id)

Get a flink device by its id.

Parameters
idThe id of the flink device.
Returns
flink_device*: Returns the flink device structure with the given id. NULL is returned if no device is found with the given id.
struct list_head* flink_get_device_list ( void  )

Get a list with all devices.

Returns
list_head*: Returns a pointer to a list containing all flink devices. The list could be empty.
struct flink_subdevice* flink_get_subdevice_by_id ( struct flink_device fdev,
u8  id 
)

Get a flink subdevice by its id.

Parameters
fdevThe flink device containing the desired flink_subdevice.
idThe id of the flink device.
Returns
flink_subdevice*: Returns the flink_subdevice structure with the given id. NULL is returned if no subdevice is found with the given id.

Here is the caller graph for this function:

struct class* flink_get_sysfs_class ( void  )

Get a flink sysfs class.

Returns
class*: Pointer to the flink sysfs class structure.
int flink_select_subdevice ( struct file *  f,
u8  subdevice,
bool  excl 
)

Select a subdevice for exclusive access.

Parameters
f
subdevice
excl
Returns
int: A negative error code is returned on failure.

Here is the call graph for this function:

Here is the caller graph for this function:

int flink_subdevice_add ( struct flink_device fdev,
struct flink_subdevice fsubdev 
)

Add a flink subdevice to flink device.

Parameters
fdevThe flink device to which the subdevice is added.
@fsubdevThe flink subdevice to add.
Returns
int: A negative error code is returned on failure.
struct flink_subdevice* flink_subdevice_alloc ( void  )

Allocate a flink_subdevice structure.

Returns
flink_subdevice*: Pointer to the new flink_subdevice structure, or NULL on failure.
int flink_subdevice_delete ( struct flink_subdevice fsubdev)

Deletes a flink subdevice and frees the allocated memory.

Parameters
fsubdevThe flink_subdevice structure to delete.
Returns
int: A negative error code is returned on failure.

Here is the caller graph for this function:

void flink_subdevice_init ( struct flink_subdevice fsubdev)

Initialize a flink_subdevice structure, making it ready to add to a flink_device with flink_subdevice_add()

Parameters
fsubdevThe structure to initialize
int flink_subdevice_remove ( struct flink_subdevice fsubdev)

Remove a flink subdevice from the parent device.

Parameters
fsubdevThe flink subdevice to remove.
Returns
int: A negative error code is returned on failure.

Here is the caller graph for this function:

Variable Documentation

const char* fmit_lkm_lut[]