generic device driver support.

HelenOS generic device driver support. More...


Files

file  char_dev.h
file  dev_iface.c
file  dev_iface.h
file  driver.c
file  driver.h
file  driver.h
file  hw_res.h
file  interrupt.h
file  remote_char_dev.c
file  remote_char_dev.h
file  remote_hw_res.c
file  remote_hw_res.h
file  remote_pci.c
file  remote_pci.h
file  remote_usb.c
file  remote_usb.h
file  remote_usbhc.c
file  remote_usbhc.h
file  remote_usbhid.c
file  remote_usbhid.h
file  usbhid_iface.h
 USB HID interface definition.

Data Structures

struct  async_transaction_t
struct  char_dev_ops_t
struct  ddf_dev
 Device structure. More...
struct  ddf_dev_ops
 Devices operations. More...
struct  ddf_fun
 Function structure. More...
struct  driver
 Driver structure. More...
struct  driver_ops
 Generic device driver operations. More...
struct  hw_res_ops_t
struct  iface_dipatch_table_t
struct  interrupt_context
struct  interrupt_context_list
struct  remote_iface_t
struct  usbhid_iface_t
 USB HID device communication interface. More...

Defines

#define HACK_MAX_PACKET_SIZE   8
#define HACK_MAX_PACKET_SIZE_INTERRUPT_IN   4
#define MAX_CHAR_RW_COUNT   256
#define USB_MAX_PAYLOAD_SIZE   1020
#define USBHID_IFACE_FLAG_NON_BLOCKING   (1 << 0)
 USB HID interface flag - return immediately if no data are available.

Typedefs

typedef ddf_dev_ops ddf_dev_ops_t
 Devices operations.
typedef ddf_dev ddf_dev_t
typedef ddf_fun ddf_fun_t
typedef driver_ops driver_ops_t
 Generic device driver operations.
typedef driver driver_t
 Driver structure.
typedef void interrupt_handler_t (ddf_dev_t *, ipc_callid_t, ipc_call_t *)
typedef void remote_handler_t (struct ddf_fun *, ipc_callid_t, ipc_call_t *)
typedef remote_iface_func_tremote_iface_func_ptr_t
typedef void remote_iface_func_t (struct ddf_fun *, void *, ipc_callid_t, ipc_call_t *)

Enumerations

enum  driver_interface_t
enum  usbhid_iface_funcs_t { IPC_M_USBHID_GET_EVENT_LENGTH, IPC_M_USBHID_GET_EVENT, IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, IPC_M_USBHID_GET_REPORT_DESCRIPTOR }
 IPC methods for USB HID device interface. More...

Functions

void add_interrupt_context (interrupt_context_list_t *list, interrupt_context_t *ctx)
static void add_to_functions_list (ddf_fun_t *fun)
static async_transaction_tasync_transaction_create (ipc_callid_t caller)
static void async_transaction_destroy (async_transaction_t *trans)
static void callback_in (ddf_fun_t *fun, int outcome, size_t actual_size, void *arg)
static void callback_out (ddf_fun_t *fun, int outcome, void *arg)
static ddf_dev_tcreate_device (void)
 Create new device structure.
static ddf_fun_tcreate_function (void)
 Create new function structure.
interrupt_context_tcreate_interrupt_context (void)
int ddf_driver_main (driver_t *drv)
int ddf_fun_add_match_id (ddf_fun_t *fun, const char *match_id_str, int match_score)
 Add single match ID to inner function.
int ddf_fun_add_to_class (ddf_fun_t *fun, const char *class_name)
 Add exposed function to class.
int ddf_fun_bind (ddf_fun_t *fun)
 Bind a function node.
ddf_fun_tddf_fun_create (ddf_dev_t *dev, fun_type_t ftype, const char *name)
 Create a DDF function node.
void ddf_fun_destroy (ddf_fun_t *fun)
 Destroy DDF function node.
int ddf_log_init (const char *drv_name, log_level_t level)
 Initialize the logging system.
void ddf_msg (log_level_t level, const char *fmt,...)
 Log a driver message.
static void delete_device (ddf_dev_t *dev)
 Delete device structure.
static void delete_function (ddf_fun_t *fun)
 Delete device structure.
void delete_interrupt_context (interrupt_context_t *ctx)
static void driver_add_device (ipc_callid_t iid, ipc_call_t *icall)
static void driver_connection (ipc_callid_t iid, ipc_call_t *icall)
 Function for handling connections to device driver.
static void driver_connection_client (ipc_callid_t iid, ipc_call_t *icall)
static void driver_connection_devman (ipc_callid_t iid, ipc_call_t *icall)
static void driver_connection_driver (ipc_callid_t iid, ipc_call_t *icall)
static void driver_connection_gen (ipc_callid_t iid, ipc_call_t *icall, bool drv)
 Generic client connection handler both for applications and drivers.
static ddf_fun_tdriver_get_function (link_t *functions, devman_handle_t handle)
static void driver_irq_handler (ipc_callid_t iid, ipc_call_t *icall)
interrupt_context_tfind_interrupt_context (interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
interrupt_context_tfind_interrupt_context_by_id (interrupt_context_list_t *list, int id)
static remote_handler_tfunction_get_default_handler (ddf_fun_t *fun)
 Get default handler for client requests.
static void * function_get_ops (ddf_fun_t *, dev_inferface_idx_t)
remote_iface_tget_remote_iface (int idx)
remote_iface_func_ptr_t get_remote_method (remote_iface_t *rem_iface, sysarg_t iface_method_idx)
void init_interrupt_context_list (interrupt_context_list_t *list)
bool is_valid_iface_idx (int idx)
 LIST_INITIALIZE (functions)
 Devices.
int register_interrupt_handler (ddf_dev_t *dev, int irq, interrupt_handler_t *handler, irq_code_t *pseudocode)
static void remote_char_read (ddf_fun_t *fun, void *ops, ipc_callid_t callid, ipc_call_t *call)
 Process the read request from the remote client.
static void remote_char_write (ddf_fun_t *fun, void *ops, ipc_callid_t callid, ipc_call_t *call)
 Process the write request from the remote client.
static void remote_config_space_read_16 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_config_space_read_32 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_config_space_read_8 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_config_space_write_16 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_config_space_write_32 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_config_space_write_8 (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_hw_res_enable_interrupt (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_hw_res_get_resource_list (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usb_get_address (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usb_get_hc_handle (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usb_get_interface (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_bind_address (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_bulk_in (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_bulk_out (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_control_read (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_control_write (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_find_by_address (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_in_transfer (ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call, usbhc_iface_transfer_in_t transfer_func)
 Process an incoming transfer.
static void remote_usbhc_interrupt_in (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_interrupt_out (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_out_transfer (ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call, usbhc_iface_transfer_out_t transfer_func)
 Process an outgoing transfer (both OUT and SETUP).
static void remote_usbhc_register_endpoint (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_release_address (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_request_address (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhc_unregister_endpoint (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhid_get_event (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhid_get_event_length (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhid_get_report_descriptor (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remote_usbhid_get_report_descriptor_length (ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *)
static void remove_from_functions_list (ddf_fun_t *fun)
void remove_interrupt_context (interrupt_context_list_t *list, interrupt_context_t *ctx)
int unregister_interrupt_handler (ddf_dev_t *dev, int irq)

Variables

static irq_cmd_t default_cmds []
static irq_code_t default_pseudocode
static driver_tdriver
 Driver structure.
static interrupt_context_list_t interrupt_contexts
 Interrupts.
remote_iface_t remote_char_dev_iface
 Remote character interface structure.
remote_iface_t remote_char_dev_iface
 Remote character interface structure.
static remote_iface_func_ptr_t remote_char_dev_iface_ops []
 Remote character interface operations.
remote_iface_t remote_hw_res_iface
remote_iface_t remote_hw_res_iface
static remote_iface_func_ptr_t remote_hw_res_iface_ops []
static iface_dipatch_table_t remote_ifaces
remote_iface_t remote_pci_iface
 Remote USB interface structure.
remote_iface_t remote_pci_iface
 Remote USB interface structure.
static remote_iface_func_ptr_t remote_pci_iface_ops []
 Remote USB interface operations.
remote_iface_t remote_usb_iface
 Remote USB interface structure.
remote_iface_t remote_usb_iface
 Remote USB interface structure.
static remote_iface_func_ptr_t remote_usb_iface_ops []
 Remote USB interface operations.
remote_iface_t remote_usbhc_iface
 Remote USB host controller interface structure.
remote_iface_t remote_usbhc_iface
 Remote USB host controller interface structure.
static remote_iface_func_ptr_t remote_usbhc_iface_ops []
 Remote USB host controller interface operations.
remote_iface_t remote_usbhid_iface
 Remote USB HID interface structure.
remote_iface_t remote_usbhid_iface
 Remote USB HID interface structure.
static remote_iface_func_ptr_t remote_usbhid_iface_ops []
 Remote USB HID interface operations.

Detailed Description

HelenOS generic device driver support.


Enumeration Type Documentation

enum usbhid_iface_funcs_t

IPC methods for USB HID device interface.

Enumerator:
IPC_M_USBHID_GET_EVENT_LENGTH  Get number of events reported in single burst.

Parameters: none Answer:

  • Size of one report in bytes.
IPC_M_USBHID_GET_EVENT  Get single event from the HID device.

The word single refers to set of individual events that were available at particular point in time. Parameters:

  • flags The call is followed by data read expecting two concatenated arrays. Answer:
  • EOK - events returned
  • EAGAIN - no event ready (only in non-blocking mode)

It is okay if the client requests less data. Extra data must be truncated by the driver.

IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH  Get the size of the report descriptor from the HID device.

Parameters:

  • none Answer:
  • EOK - method is implemented (expected always) Parameters of the answer:
  • Size of the report in bytes.
IPC_M_USBHID_GET_REPORT_DESCRIPTOR  Get the report descriptor from the HID device.

Parameters:

  • none The call is followed by data read expecting the descriptor itself. Answer:
  • EOK - report descriptor returned.

Definition at line 43 of file usbhid_iface.h.


Function Documentation

static ddf_dev_t * create_device ( void   )  [static]

Create new device structure.

Returns:
The device structure.

Definition at line 463 of file driver.c.

static ddf_fun_t* create_function ( void   )  [static]

Create new function structure.

Returns:
The device structure.

Definition at line 479 of file driver.c.

int ddf_fun_add_match_id ( ddf_fun_t fun,
const char *  match_id_str,
int  match_score 
)

Add single match ID to inner function.

Construct and add a single match ID to the specified function. Cannot be called when the function node is bound.

Parameters:
fun Function
match_id_str Match string
match_score Match score
Returns:
EOK on success, ENOMEM if out of memory.

Definition at line 619 of file driver.c.

int ddf_fun_add_to_class ( ddf_fun_t fun,
const char *  class_name 
)

Add exposed function to class.

Must only be called when the function is bound.

Definition at line 650 of file driver.c.

int ddf_fun_bind ( ddf_fun_t fun  ) 

Bind a function node.

Bind the specified function to the system. This effectively makes the function visible to the system (uploads it to the server).

This function can fail for several reasons. Specifically, it will fail if the device already has a bound function of the same name.

Parameters:
fun Function to bind
Returns:
EOK on success or negative error code

Definition at line 591 of file driver.c.

ddf_fun_t * ddf_fun_create ( ddf_dev_t dev,
fun_type_t  ftype,
const char *  name 
)

Create a DDF function node.

Create a DDF function (in memory). Both child devices and external clients communicate with a device via its functions.

The created function node is fully formed, but only exists in the memory of the client task. In order to be visible to the system, the function must be bound using ddf_fun_bind().

This function should only fail if there is not enough free memory. Specifically, this function succeeds even if dev already has a (bound) function with the same name.

Type: A function of type fun_inner indicates that DDF should attempt to attach child devices to the function. fun_exposed means that the function should be exported to external clients (applications).

Parameters:
dev Device to which we are adding function
ftype Type of function (fun_inner or fun_exposed)
name Name of function
Returns:
New function or NULL if memory is not available

Definition at line 537 of file driver.c.

void ddf_fun_destroy ( ddf_fun_t fun  ) 

Destroy DDF function node.

Destroy a function previously created with ddf_fun_create(). The function must not be bound.

Parameters:
fun Function to destroy

Definition at line 565 of file driver.c.

int ddf_log_init ( const char *  drv_name,
log_level_t  level 
)

Initialize the logging system.

Parameters:
drv_name Driver name, will be printed as part of message
level Minimum message level to print

Definition at line 43 of file log.c.

void ddf_msg ( log_level_t  level,
const char *  fmt,
  ... 
)

Log a driver message.

Parameters:
level Message verbosity level. Message is only printed if verbosity is less than or equal to current reporting level.
fmt Format string (no trailing newline)

Definition at line 55 of file log.c.

static void delete_device ( ddf_dev_t dev  )  [static]

Delete device structure.

Parameters:
dev The device structure.

Definition at line 497 of file driver.c.

static void delete_function ( ddf_fun_t fun  )  [static]

Delete device structure.

Parameters:
dev The device structure.

Definition at line 506 of file driver.c.

static void driver_connection_gen ( ipc_callid_t  iid,
ipc_call_t icall,
bool  drv 
) [static]

Generic client connection handler both for applications and drivers.

Parameters:
drv True for driver client, false for other clients (applications, services etc.).

Definition at line 311 of file driver.c.

static void remote_char_read ( ddf_fun_t fun,
void *  ops,
ipc_callid_t  callid,
ipc_call_t call 
) [static]

Process the read request from the remote client.

Receive the read request's parameters from the remote client and pass them to the local interface. Return the result of the operation processed by the local interface to the remote client.

Parameters:
fun The function from which the data are read.
ops The local ops structure.

Definition at line 73 of file remote_char_dev.c.

static void remote_char_write ( ddf_fun_t fun,
void *  ops,
ipc_callid_t  callid,
ipc_call_t call 
) [static]

Process the write request from the remote client.

Receive the write request's parameters from the remote client and pass them to the local interface. Return the result of the operation processed by the local interface to the remote client.

Parameters:
fun The function to which the data are written.
ops The local ops structure.

Definition at line 120 of file remote_char_dev.c.

static void remote_usbhc_in_transfer ( ddf_fun_t fun,
ipc_callid_t  callid,
ipc_call_t call,
usbhc_iface_transfer_in_t  transfer_func 
) [static]

Process an incoming transfer.

Parameters:
device Target device.
callid Initiating caller.
call Initiating call.
transfer_func Transfer function (might be NULL).

Definition at line 304 of file remote_usbhc.c.

static void remote_usbhc_out_transfer ( ddf_fun_t fun,
ipc_callid_t  callid,
ipc_call_t call,
usbhc_iface_transfer_out_t  transfer_func 
) [static]

Process an outgoing transfer (both OUT and SETUP).

Parameters:
device Target device.
callid Initiating caller.
call Initiating call.
transfer_func Transfer function (might be NULL).

Definition at line 249 of file remote_usbhc.c.


Variable Documentation

remote_iface_t remote_char_dev_iface

Remote character interface structure.

Interface for processing request from remote clients addressed to the character interface.

Definition at line 57 of file remote_char_dev.c.

remote_iface_t remote_char_dev_iface

Initial value:

 {
        .method_count = sizeof(remote_char_dev_iface_ops) /
            sizeof(remote_iface_func_ptr_t),
        .methods = remote_char_dev_iface_ops
}
Remote character interface structure.

Interface for processing request from remote clients addressed to the character interface.

Definition at line 57 of file remote_char_dev.c.


Generated on Thu Jun 2 07:45:56 2011 for HelenOS/USB by  doxygen 1.4.7