OHCI driver
[USB]

Driver for OHCI host controller. More...


Files

file  batch.c
 OHCI driver USB transaction structure.
file  batch.h
 OHCI driver USB transaction structure.
file  completion_codes.h
 OHCI driver.
file  endpoint_descriptor.c
 OHCI driver.
file  endpoint_descriptor.h
 OHCI driver.
file  endpoint_list.c
 OHCI driver transfer list implementation.
file  endpoint_list.h
 OHCI driver transfer list structure.
file  hc.h
 OHCI host controller driver structure.
file  hcca.h
 OHCI driver.
file  hcd_endpoint.c
 OHCI driver.
file  hcd_endpoint.h
 OHCI driver.
file  iface.c
 OHCI driver hc interface implementation.
file  iface.h
 Common OHCI definitions.
file  iso_transfer_descriptor.h
 OHCI driver.
file  main.c
 Main routines of OHCI driver.
file  malloc32.h
 OHCI driver.
file  ohci.c
 OHCI driver.
file  ohci.h
 OHCI driver main structure for both host controller and root-hub.
file  pci.c
 PCI related functions needed by the OHCI driver.
file  pci.h
 PCI related functions needed by OHCI driver.
file  root_hub.c
 OHCI driver.
file  root_hub.h
 OHCI driver.
file  transfer_descriptor.c
 OHCI driver.
file  transfer_descriptor.h
 OHCI driver.

Data Structures

struct  ed
struct  endpoint_list
 Structure maintains both OHCI queue and software list of active endpoints. More...
struct  hc
 Main OHCI drier structure. More...
struct  hcca
 Host controller communication area. More...
struct  hcd_endpoint
 Connector structure linking ED to to prepared TD. More...
struct  itd
struct  ohci
struct  ohci_transfer_batch
 OHCI specific data required for USB transfer. More...
struct  rh
 ohci root hub representation More...
struct  td

Defines

#define CC_BITSTUFF   (0x2)
#define CC_BUFFEROVERRRUN   (0xc)
#define CC_BUFFERUNDERRUN   (0xd)
#define CC_CRC   (0x1)
#define CC_DATAOVERRRUN   (0x8)
#define CC_DATAUNDERRRUN   (0x9)
#define CC_NOACCESS1   (0xe)
#define CC_NOACCESS2   (0xf)
#define CC_NOERROR   (0x0)
#define CC_NORESPONSE   (0x5)
#define CC_PIDFAIL   (0x6)
#define CC_PIDUNEXPECTED   (0x7)
#define CC_STALL   (0x4)
#define CC_TOGGLE   (0x3)
#define NAME   "ohci"
#define OHCI_NEEDED_IRQ_COMMANDS   5
#define OHCI_TD_MAX_TRANSFER   (4 * 1024)

Typedefs

typedef endpoint_list endpoint_list_t
 Structure maintains both OHCI queue and software list of active endpoints.
typedef hc hc_t
 Main OHCI drier structure.
typedef hcca hcca_t
 Host controller communication area.
typedef hcd_endpoint hcd_endpoint_t
 Connector structure linking ED to to prepared TD.
typedef ohci_transfer_batch ohci_transfer_batch_t
 OHCI specific data required for USB transfer.
typedef rh rh_t
 ohci root hub representation

Functions

static uintptr_t addr_to_phys (void *addr)
 Get physical address translation.
void batch_bulk_in (usb_transfer_batch_t *instance)
 Prepare bulk in transfer.
void batch_bulk_out (usb_transfer_batch_t *instance)
 Prepare bulk out transfer.
void batch_commit (usb_transfer_batch_t *instance)
 Starts execution of the TD list.
static void batch_control (usb_transfer_batch_t *instance, usb_direction_t data_dir, usb_direction_t status_dir)
 Prepare generic control transfer.
void batch_control_read (usb_transfer_batch_t *instance)
 Prepares control read transfer.
void batch_control_write (usb_transfer_batch_t *instance)
 Prepares control write transfer.
static void batch_data (usb_transfer_batch_t *instance)
 Prepare generic data transfer.
usb_transfer_batch_tbatch_get (ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t buffer_size, const char *setup_buffer, size_t setup_size, usbhc_iface_transfer_in_callback_t func_in, usbhc_iface_transfer_out_callback_t func_out, void *arg)
 Allocate memory initialize internal structures.
void batch_interrupt_in (usb_transfer_batch_t *instance)
 Prepare interrupt in transfer.
void batch_interrupt_out (usb_transfer_batch_t *instance)
 Prepare interrupt out transfer.
bool batch_is_complete (usb_transfer_batch_t *instance)
 Check batch TDs' status.
static int bind_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
 Bind address interface function.
static int bulk_in (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule bulk in transfer.
static int bulk_out (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule bulk out transfer.
static int cc_to_rc (int cc)
static int control_read (ddf_fun_t *fun, usb_target_t target, void *setup_data, size_t setup_size, void *data, size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule control read transfer.
static int control_write (ddf_fun_t *fun, usb_target_t target, void *setup_data, size_t setup_size, void *data, size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule control write transfer.
static void create_interrupt_mask_in_instance (rh_t *instance)
 create answer to status interrupt consisting of change bitmap
static int create_serialized_hub_descriptor (rh_t *instance)
 Create hub descriptor used in hub-driver <-> hub communication.
static ohci_tdev_to_ohci (ddf_dev_t *dev)
int device_setup_ohci (ddf_dev_t *device)
 Initialize hc and rh ddf structures and their respective drivers.
static void ed_append_ed (ed_t *instance, ed_t *next)
void ed_init (ed_t *instance, endpoint_t *ep)
static void ed_set_end_td (ed_t *instance, td_t *td)
static void ed_set_td (ed_t *instance, td_t *td)
static int ed_toggle_get (ed_t *instance)
static void ed_toggle_set (ed_t *instance, int toggle)
void endpoint_list_add_ep (endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)
 Add endpoint to the list and queue.
static void endpoint_list_fini (endpoint_list_t *instance)
 Dispose transfer list structures.
int endpoint_list_init (endpoint_list_t *instance, const char *name)
 Initialize transfer list structures.
void endpoint_list_remove_ep (endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)
 Remove endpoint from the list and queue.
void endpoint_list_set_next (endpoint_list_t *instance, endpoint_list_t *next)
 Set the next list in transfer list chain.
static int find_by_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t *handle)
 Find device handle by address interface function.
static void free32 (void *addr)
 Physical mallocator simulator.
static hc_tfun_to_hc (ddf_fun_t *fun)
 Get and cast pointer to the driver data.
int hc_add_endpoint (hc_t *instance, usb_address_t address, usb_endpoint_t ep, usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction, size_t max_packet_size, size_t size, unsigned interval)
 Create end register endpoint structures.
static void hc_fini (hc_t *instance)
 Safely dispose host controller internal structures.
endpoint_thc_get_endpoint (hc_t *instance, usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw)
 Get access to endpoint structures.
int hc_init (hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts)
 Initialize OHCI hc driver structure.
void hc_interrupt (hc_t *instance, uint32_t status)
 Interrupt handling routine.
int hc_register_hub (hc_t *instance, ddf_fun_t *hub_fun)
 Announce OHCI root hub to the DDF.
int hc_remove_endpoint (hc_t *instance, usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction)
 Dequeue and delete endpoint structures.
int hc_schedule (hc_t *instance, usb_transfer_batch_t *batch)
 Add USB transfer to the schedule.
void hc_start_hw (hc_t *instance)
 OHCI hw initialization routine.
hcd_endpoint_thcd_endpoint_assign (endpoint_t *ep)
 Creates new hcd endpoint representation.
void hcd_endpoint_clear (endpoint_t *ep)
 Disposes assigned hcd endpoint structure.
static hcd_endpoint_thcd_endpoint_get (endpoint_t *ep)
 Get and convert assigned hcd_endpoint_t structure.
static int hcd_ep_toggle_get (void *hcd_ep)
 Callback to get value of toggle bit.
static void hcd_ep_toggle_set (void *hcd_ep, int toggle)
 Callback to set toggle on ED.
static int interrupt_in (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule interrupt in transfer.
static int interrupt_out (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule interrupt out transfer.
static void irq_handler (ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
 IRQ handling callback, identifies device.
static bool is_zeros (void *buffer, size_t size)
 return whether the buffer is full of zeros
int main (int argc, char *argv[])
 Main entry point.
static void * malloc32 (size_t size)
 Physical mallocator simulator.
static int ohci_add_device (ddf_dev_t *device)
 Initializes a new ddf driver instance of OHCI hcd.
static void ohci_transfer_batch_dispose (void *ohci_batch)
 Safely destructs ohci_transfer_batch_t structure.
int pci_enable_interrupts (ddf_dev_t *device)
 Calls the PCI driver with a request to enable interrupts.
int pci_get_my_registers (ddf_dev_t *dev, uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
 Get address of registers and IRQ for given device.
static int process_address_set_request (rh_t *instance, uint16_t address)
 register address to this device
static int process_ctrl_request (rh_t *instance, usb_transfer_batch_t *request)
 process hub control request
static int process_get_configuration_request (rh_t *instance, usb_transfer_batch_t *request)
 answer to get configuration request
static int process_get_descriptor_request (rh_t *instance, usb_transfer_batch_t *request)
 create answer to a descriptor request
static int process_get_hub_status_request (rh_t *instance, usb_transfer_batch_t *request)
 create answer to port status_request
static int process_get_port_status_request (rh_t *instance, uint16_t port, usb_transfer_batch_t *request)
 create answer to port status_request
static int process_get_status_request (rh_t *instance, usb_transfer_batch_t *request)
 create answer to status request
static int process_hub_feature_clear_request (rh_t *instance, uint16_t feature)
 process feature-disabling request on hub
static int process_hub_feature_set_request (rh_t *instance, uint16_t feature)
 process feature-enabling request on hub
static int process_interrupt_mask_in_instance (rh_t *instance, usb_transfer_batch_t *request)
 process hanging interrupt request
static int process_port_feature_clear_request (rh_t *instance, uint16_t feature, uint16_t port)
 process feature-disabling request on hub
static int process_port_feature_set_request (rh_t *instance, uint16_t feature, uint16_t port)
 process feature-enabling request on hub
static int process_request_with_input (rh_t *instance, usb_transfer_batch_t *request)
 process one of requests that carry input data
static int process_request_with_output (rh_t *instance, usb_transfer_batch_t *request)
 process one of requests that requere output data
static int process_request_without_data (rh_t *instance, usb_transfer_batch_t *request)
 process one of requests that do not request nor carry additional data
static int register_endpoint (ddf_fun_t *fun, usb_address_t address, usb_speed_t ep_speed, usb_endpoint_t endpoint, usb_transfer_type_t transfer_type, usb_direction_t direction, size_t max_packet_size, unsigned int interval)
 Register endpoint for bandwidth reservation.
static int release_address (ddf_fun_t *fun, usb_address_t address)
 Release address interface function.
static int request_address (ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address)
 Request address interface function.
int rh_init (rh_t *instance, ohci_regs_t *regs)
 Root hub initialization.
static int rh_init_descriptors (rh_t *instance)
 initialize hub descriptors
void rh_interrupt (rh_t *instance)
 process interrupt on a hub
int rh_request (rh_t *instance, usb_transfer_batch_t *request)
 process root hub request
static int setup_batch (ddf_fun_t *fun, usb_target_t target, usb_direction_t direction, void *data, size_t size, void *setup_data, size_t setup_size, usbhc_iface_transfer_in_callback_t in, usbhc_iface_transfer_out_callback_t out, void *arg, const char *name, hc_t **hc, usb_transfer_batch_t **batch)
static int td_error (td_t *instance)
void td_init (td_t *instance, usb_direction_t dir, void *buffer, size_t size, int toggle)
static bool td_is_finished (td_t *instance)
static size_t td_remain_size (td_t *instance)
static void td_set_next (td_t *instance, td_t *next)
static int unregister_endpoint (ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction)
static int usb_iface_get_address (ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address)
 Get address of the device identified by handle.
static int usb_iface_get_hc_handle (ddf_fun_t *fun, devman_handle_t *handle)
 Gets handle of the respective hc (this device, hc function).

Variables

static unsigned direc [3]
static unsigned dp [3]
usbhc_iface_t hc_iface
usbhc_iface_t hc_iface
static ddf_dev_ops_t hc_ops
 Standard USB HC options (HC interface).
static const uint32_t hub_clear_feature_by_writing_one_mask
 bitmask of hub features that are cleared by writing 1 (and not 0)
static const uint32_t hub_clear_feature_valid_mask
 bitmask of hub features that are valid to be cleared
static const uint32_t hub_set_feature_direct_mask
 bitmask of hub features that are set by writing 1 and cleared by writing 0
static const uint32_t hub_set_feature_valid_mask
 bitmask of hub features that are valid to be set
static driver_t ohci_driver
static driver_ops_t ohci_driver_ops
static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor
 standart configuration descriptor with filled common values for ohci root hubs
static const usb_standard_device_descriptor_t ohci_rh_device_descriptor
 standart device descriptor for ohci root hub
static const usb_standard_endpoint_descriptor_t ohci_rh_ep_descriptor
 standart ohci root hub endpoint descriptor
static const usb_standard_interface_descriptor_t ohci_rh_iface_descriptor
 standart ohci root hub interface descriptor
static const uint32_t port_clear_feature_valid_mask
 bitmask of port features that can be cleared
static const uint32_t port_set_feature_valid_mask
 bitmask of port features that are valid to be set
static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK
 bitmask with port status changes
static ddf_dev_ops_t rh_ops
 Standard USB RH options (RH interface).
static unsigned togg [2] = { TD_STATUS_T_0, TD_STATUS_T_1 }
static usb_iface_t usb_iface
 Root hub USB interface.

Detailed Description

Driver for OHCI host controller.


Typedef Documentation

typedef struct hcca hcca_t

Host controller communication area.

Shared memory used for communication between the controller and the driver.


Function Documentation

static uintptr_t addr_to_phys ( void *  addr  )  [inline, static]

Get physical address translation.

Parameters:
[in] addr Virtual address to translate
Returns:
Physical address if exists, NULL otherwise.

Definition at line 48 of file malloc32.h.

void batch_bulk_in ( usb_transfer_batch_t instance  ) 

Prepare bulk in transfer.

Parameters:
[in] instance Batch structure to use.
Data transfer.

Definition at line 309 of file batch.c.

void batch_bulk_out ( usb_transfer_batch_t instance  ) 

Prepare bulk out transfer.

Parameters:
[in] instance Batch structure to use.
Data transfer.

Definition at line 323 of file batch.c.

void batch_commit ( usb_transfer_batch_t instance  ) 

Starts execution of the TD list.

Parameters:
[in] instance Batch structure to use

Definition at line 233 of file batch.c.

void batch_control ( usb_transfer_batch_t instance,
usb_direction_t  data_dir,
usb_direction_t  status_dir 
) [static]

Prepare generic control transfer.

Parameters:
[in] instance Batch structure to use.
[in] data_dir Direction to use for data stage.
[in] status_dir Direction to use for status stage.
Setup stage with toggle 0 and direction BOTH(SETUP_PID) Data stage with alternating toggle and direction supplied by parameter. Status stage with toggle 1 and direction supplied by parameter.

Definition at line 343 of file batch.c.

void batch_control_read ( usb_transfer_batch_t instance  ) 

Prepares control read transfer.

Parameters:
[in] instance Batch structure to use.
Uses generic control transfer using direction IN(data stage) and OUT(status stage).

Definition at line 265 of file batch.c.

void batch_control_write ( usb_transfer_batch_t instance  ) 

Prepares control write transfer.

Parameters:
[in] instance Batch structure to use.
Uses generic control transfer using direction OUT(data stage) and IN(status stage).

Definition at line 248 of file batch.c.

void batch_data ( usb_transfer_batch_t instance  )  [static]

Prepare generic data transfer.

Parameters:
[in] instance Batch structure to use.
Direction is supplied by the associated ep and toggle is maintained by the OHCI hw in ED.

Definition at line 398 of file batch.c.

usb_transfer_batch_t * batch_get ( ddf_fun_t fun,
endpoint_t ep,
char *  buffer,
size_t  buffer_size,
const char *  setup_buffer,
size_t  setup_size,
usbhc_iface_transfer_in_callback_t  func_in,
usbhc_iface_transfer_out_callback_t  func_out,
void *  arg 
)

Allocate memory initialize internal structures.

Parameters:
[in] fun DDF function to pass to callback.
[in] ep Communication target
[in] buffer Data source/destination.
[in] buffer_size Size of the buffer.
[in] setup_buffer Setup data source (if not NULL)
[in] setup_size Size of setup_buffer (should be always 8)
[in] func_in function to call on inbound transfer completion
[in] func_out function to call on outbound transfer completion
[in] arg additional parameter to func_in or func_out
Returns:
Valid pointer if all structures were successfully created, NULL otherwise.
Allocates and initializes structures needed by the OHCI hw for the transfer.

Definition at line 101 of file batch.c.

void batch_interrupt_in ( usb_transfer_batch_t instance  ) 

Prepare interrupt in transfer.

Parameters:
[in] instance Batch structure to use.
Data transfer.

Definition at line 279 of file batch.c.

void batch_interrupt_out ( usb_transfer_batch_t instance  ) 

Prepare interrupt out transfer.

Parameters:
[in] instance Batch structure to use.
Data transfer.

Definition at line 293 of file batch.c.

bool batch_is_complete ( usb_transfer_batch_t instance  ) 

Check batch TDs' status.

Parameters:
[in] instance Batch structure to use.
Returns:
False, if there is an active TD, true otherwise.
Walk all TDs (usually there is just one). Stop with false if there is an active TD. Stop with true if an error is found. Return true if the walk completes with the last TD.

Definition at line 179 of file batch.c.

static int bind_address ( ddf_fun_t fun,
usb_address_t  address,
devman_handle_t  handle 
) [static]

Bind address interface function.

Parameters:
[in] fun DDF function that was called.
[in] address Address of the device
[in] handle Devman handle of the device driver.
Returns:
Error code.

Definition at line 114 of file iface.c.

static int bulk_in ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule bulk in transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 324 of file iface.c.

static int bulk_out ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule bulk out transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Data to be sent (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 290 of file iface.c.

static int control_read ( ddf_fun_t fun,
usb_target_t  target,
void *  setup_data,
size_t  setup_size,
void *  data,
size_t  size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule control read transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] setup_packet Setup packet buffer (in USB endianess, allocated and deallocated by the caller).
[in] setup_size Size of setup_packet buffer in bytes.
[in] data_buffer Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] size Size of data_buffer buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 401 of file iface.c.

static int control_write ( ddf_fun_t fun,
usb_target_t  target,
void *  setup_data,
size_t  setup_size,
void *  data,
size_t  size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule control write transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] setup_packet Setup packet buffer (in USB endianess, allocated and deallocated by the caller).
[in] setup_size Size of setup_packet buffer in bytes.
[in] data_buffer Data buffer (in USB endianess, allocated and deallocated by the caller).
[in] size Size of data_buffer buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 361 of file iface.c.

static void create_interrupt_mask_in_instance ( rh_t instance  )  [static]

create answer to status interrupt consisting of change bitmap

Result contains bitmap where bit 0 indicates change on hub and bit i indicates change on i`th port (i>0). For more info see Hub and Port status bitmap specification in USB specification (chapter 11.13.4). Uses instance`s interrupt buffer to store the interrupt information.

Parameters:
instance root hub instance

Definition at line 484 of file root_hub.c.

static int create_serialized_hub_descriptor ( rh_t instance  )  [static]

Create hub descriptor used in hub-driver <-> hub communication.

This means creating byt array from data in root hub registers. For more info see usb hub specification.

Parameters:
instance root hub instance
Returns:
error code

Definition at line 305 of file root_hub.c.

int device_setup_ohci ( ddf_dev_t device  ) 

Initialize hc and rh ddf structures and their respective drivers.

Parameters:
[in] device DDF instance of the device to use.
[in] instance OHCI structure to use.
This function does all the preparatory work for hc and rh drivers:

Definition at line 147 of file ohci.c.

void endpoint_list_add_ep ( endpoint_list_t instance,
hcd_endpoint_t hcd_ep 
)

Add endpoint to the list and queue.

Parameters:
[in] instance List to use.
[in] endpoint Endpoint to add.
The endpoint is added to the end of the list and queue.

Definition at line 88 of file endpoint_list.c.

static void endpoint_list_fini ( endpoint_list_t instance  )  [inline, static]

Dispose transfer list structures.

Parameters:
[in] instance Memory place to use.
Frees memory of the internal ed_t structure.

Definition at line 63 of file endpoint_list.h.

int endpoint_list_init ( endpoint_list_t instance,
const char *  name 
)

Initialize transfer list structures.

Parameters:
[in] instance Memory place to use.
[in] name Name of the new list.
Returns:
Error code
Allocates memory for internal ed_t structure.

Definition at line 48 of file endpoint_list.c.

void endpoint_list_remove_ep ( endpoint_list_t instance,
hcd_endpoint_t hcd_ep 
)

Remove endpoint from the list and queue.

Parameters:
[in] instance List to use.
[in] endpoint Endpoint to remove.

Definition at line 140 of file endpoint_list.c.

void endpoint_list_set_next ( endpoint_list_t instance,
endpoint_list_t next 
)

Set the next list in transfer list chain.

Parameters:
[in] instance List to lead.
[in] next List to append.
Does not check whether this replaces an existing list.

Definition at line 74 of file endpoint_list.c.

static int find_by_address ( ddf_fun_t fun,
usb_address_t  address,
devman_handle_t handle 
) [static]

Find device handle by address interface function.

Parameters:
[in] fun DDF function that was called.
[in] address Address in question.
[out] handle Where to store device handle if found.
Returns:
Error code.

Definition at line 133 of file iface.c.

static void free32 ( void *  addr  )  [inline, static]

Physical mallocator simulator.

Parameters:
[in] addr Address of the place allocated by malloc32

Definition at line 70 of file malloc32.h.

static hc_t* fun_to_hc ( ddf_fun_t fun  )  [inline, static]

Get and cast pointer to the driver data.

Parameters:
[in] fun DDF function pointer
Returns:
cast pointer to driver_data

Definition at line 115 of file hc.h.

int hc_add_endpoint ( hc_t instance,
usb_address_t  address,
usb_endpoint_t  endpoint,
usb_speed_t  speed,
usb_transfer_type_t  type,
usb_direction_t  direction,
size_t  mps,
size_t  size,
unsigned  interval 
)

Create end register endpoint structures.

Parameters:
[in] instance OHCI driver structure.
[in] address USB address of the device.
[in] endpoint USB endpoint number.
[in] speed Communication speeed of the device.
[in] type Endpoint's transfer type.
[in] direction Endpoint's direction.
[in] mps Maximum packet size the endpoint accepts.
[in] size Maximum allowed buffer size.
[in] interval Time between transfers(interrupt transfers only).
Returns:
Error code

Definition at line 165 of file hc.c.

static void hc_fini ( hc_t instance  )  [inline, static]

Safely dispose host controller internal structures.

Parameters:
[in] instance Host controller structure to use.

Definition at line 96 of file hc.h.

endpoint_t* hc_get_endpoint ( hc_t instance,
usb_address_t  address,
usb_endpoint_t  endpoint,
usb_direction_t  direction,
size_t bw 
)

Get access to endpoint structures.

Parameters:
[in] instance OHCI hc driver structure.
[in] address USB address of the device.
[in] endpoint USB endpoint number.
[in] direction Direction of the endpoint.
[out] bw Reserved bandwidth.
Returns:
Error code

Definition at line 289 of file hc.c.

int hc_init ( hc_t instance,
uintptr_t  regs,
size_t  reg_size,
bool  interrupts 
)

Initialize OHCI hc driver structure.

Parameters:
[in] instance Memory place for the structure.
[in] regs Address of the memory mapped I/O registers.
[in] reg_size Size of the memory mapped area.
[in] interrupts True if w interrupts should be used
Returns:
Error code

Definition at line 111 of file hc.c.

void hc_interrupt ( hc_t instance,
uint32_t  status 
)

Interrupt handling routine.

Parameters:
[in] instance OHCI hc driver structure.
[in] status Value of the status register at the time of interrupt.

Definition at line 342 of file hc.c.

int hc_register_hub ( hc_t instance,
ddf_fun_t hub_fun 
)

Announce OHCI root hub to the DDF.

Parameters:
[in] instance OHCI driver intance
[in] hub_fun DDF fuction representing OHCI root hub
Returns:
Error code

Definition at line 59 of file hc.c.

int hc_remove_endpoint ( hc_t instance,
usb_address_t  address,
usb_endpoint_t  endpoint,
usb_direction_t  direction 
)

Dequeue and delete endpoint structures.

Parameters:
[in] instance OHCI hc driver structure.
[in] address USB address of the device.
[in] endpoint USB endpoint number.
[in] direction Direction of the endpoint.
Returns:
Error code

Definition at line 230 of file hc.c.

int hc_schedule ( hc_t instance,
usb_transfer_batch_t batch 
)

Add USB transfer to the schedule.

Parameters:
[in] instance UHCI structure to use.
[in] batch Transfer batch to schedule.
Returns:
Error code
Checks for bandwidth availability and appends the batch to the proper queue.

Definition at line 306 of file hc.c.

void hc_start_hw ( hc_t instance  ) 

OHCI hw initialization routine.

Parameters:
[in] instance OHCI hc driver structure.

Definition at line 455 of file hc.c.

hcd_endpoint_t * hcd_endpoint_assign ( endpoint_t ep  ) 

Creates new hcd endpoint representation.

Parameters:
[in] ep USBD endpoint structure
Returns:
pointer to a new hcd endpoint structure, NULL on failure.

Definition at line 68 of file hcd_endpoint.c.

void hcd_endpoint_clear ( endpoint_t ep  ) 

Disposes assigned hcd endpoint structure.

Parameters:
[in] ep USBD endpoint structure

Definition at line 99 of file hcd_endpoint.c.

static hcd_endpoint_t* hcd_endpoint_get ( endpoint_t ep  )  [inline, static]

Get and convert assigned hcd_endpoint_t structure.

Parameters:
[in] ep USBD endpoint structure.
Returns:
Pointer to assigned hcd endpoint structure

Definition at line 61 of file hcd_endpoint.h.

static int hcd_ep_toggle_get ( void *  hcd_ep  )  [static]

Callback to get value of toggle bit.

Parameters:
[in] hcd_ep hcd endpoint structure
Returns:
Current value of toggle bit.

Definition at line 55 of file hcd_endpoint.c.

static void hcd_ep_toggle_set ( void *  hcd_ep,
int  toggle 
) [static]

Callback to set toggle on ED.

Parameters:
[in] hcd_ep hcd endpoint structure
[in] toggle new value of toggle bit

Definition at line 42 of file hcd_endpoint.c.

static int interrupt_in ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule interrupt in transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 256 of file iface.c.

static int interrupt_out ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule interrupt out transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Data to be sent (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 222 of file iface.c.

static void irq_handler ( ddf_dev_t dev,
ipc_callid_t  iid,
ipc_call_t call 
) [static]

IRQ handling callback, identifies device.

Parameters:
[in] dev DDF instance of the device to use.
[in] iid (Unused).
[in] call Pointer to the call that represents interrupt.

Definition at line 70 of file ohci.c.

static bool is_zeros ( void *  buffer,
size_t  size 
) [static]

return whether the buffer is full of zeros

Convenience function.

Parameters:
buffer 
size 
Returns:

Definition at line 931 of file root_hub.c.

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 83 of file main.c.

static void* malloc32 ( size_t  size  )  [inline, static]

Physical mallocator simulator.

Parameters:
[in] size Size of the required memory space
Returns:
Address of the aligned and big enough memory place, NULL on failure.

Definition at line 63 of file malloc32.h.

static int ohci_add_device ( ddf_dev_t device  )  [static]

Initializes a new ddf driver instance of OHCI hcd.

Parameters:
[in] device DDF instance of the device to initialize.
Returns:
Error code.

Definition at line 50 of file main.c.

static void ohci_transfer_batch_dispose ( void *  ohci_batch  )  [static]

Safely destructs ohci_transfer_batch_t structure.

Parameters:
[in] ohci_batch Instance to destroy.

Definition at line 68 of file batch.c.

int pci_enable_interrupts ( ddf_dev_t device  ) 

Calls the PCI driver with a request to enable interrupts.

Parameters:
[in] device Device asking for interrupts
Returns:
Error code.

Definition at line 130 of file pci.c.

int pci_get_my_registers ( ddf_dev_t dev,
uintptr_t mem_reg_address,
size_t mem_reg_size,
int *  irq_no 
)

Get address of registers and IRQ for given device.

Parameters:
[in] dev Device asking for the addresses.
[out] mem_reg_address Base address of the memory range.
[out] mem_reg_size Size of the memory range.
[out] irq_no IRQ assigned to the device.
Returns:
Error code.

Definition at line 57 of file pci.c.

static int process_address_set_request ( rh_t instance,
uint16_t  address 
) [static]

register address to this device

Parameters:
instance root hub instance
address new address
Returns:
error code

Definition at line 707 of file root_hub.c.

static int process_ctrl_request ( rh_t instance,
usb_transfer_batch_t request 
) [static]

process hub control request

If needed, writes answer into the request structure. Request can be one of USB_DEVREQ_GET_STATUS, USB_DEVREQ_GET_DESCRIPTOR, USB_DEVREQ_GET_CONFIGURATION, USB_DEVREQ_CLEAR_FEATURE, USB_DEVREQ_SET_FEATURE, USB_DEVREQ_SET_ADDRESS, USB_DEVREQ_SET_DESCRIPTOR or USB_DEVREQ_SET_CONFIGURATION.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 846 of file root_hub.c.

static int process_get_configuration_request ( rh_t instance,
usb_transfer_batch_t request 
) [static]

answer to get configuration request

Root hub works independently on the configuration.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 589 of file root_hub.c.

static int process_get_descriptor_request ( rh_t instance,
usb_transfer_batch_t request 
) [static]

create answer to a descriptor request

This might be a request for standard (configuration, device, endpoint or interface) or device specific (hub) descriptor.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 512 of file root_hub.c.

static int process_get_hub_status_request ( rh_t instance,
usb_transfer_batch_t request 
) [static]

create answer to port status_request

This copies flags in hub status register into the buffer. The format of the status register and status message is the same, according to USB hub specification and OHCI root hub specification.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 429 of file root_hub.c.

static int process_get_port_status_request ( rh_t instance,
uint16_t  port,
usb_transfer_batch_t request 
) [static]

create answer to port status_request

Copy content of corresponding port status register to answer buffer. The format of the port status register and port status data is the same ( see OHCI root hub and USB hub documentation).

Parameters:
instance root hub instance
port port number, counted from 1
request structure containing both request and response information
Returns:
error code

Definition at line 407 of file root_hub.c.

static int process_get_status_request ( rh_t instance,
usb_transfer_batch_t request 
) [static]

create answer to status request

This might be either hub status or port status request. If neither, ENOTSUP is returned.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 450 of file root_hub.c.

static int process_hub_feature_clear_request ( rh_t instance,
uint16_t  feature 
) [static]

process feature-disabling request on hub

Parameters:
instance root hub instance
feature feature selector
Returns:
error code

Definition at line 630 of file root_hub.c.

static int process_hub_feature_set_request ( rh_t instance,
uint16_t  feature 
) [static]

process feature-enabling request on hub

Parameters:
instance root hub instance
feature feature selector
Returns:
error code

Definition at line 609 of file root_hub.c.

static int process_interrupt_mask_in_instance ( rh_t instance,
usb_transfer_batch_t request 
) [static]

process hanging interrupt request

If an interrupt transfer has been received and there was no change, the driver stores the transfer information and waits for change to occcur. This routine is called when that happens and it finalizes the interrupt transfer.

Parameters:
instance hub instance
request batch request to be processed
Returns:

Definition at line 910 of file root_hub.c.

static int process_port_feature_clear_request ( rh_t instance,
uint16_t  feature,
uint16_t  port 
) [static]

process feature-disabling request on hub

Parameters:
instance root hub instance
feature feature selector
port port number, counted from 1
enable enable or disable the specified feature
Returns:
error code

Definition at line 681 of file root_hub.c.

static int process_port_feature_set_request ( rh_t instance,
uint16_t  feature,
uint16_t  port 
) [static]

process feature-enabling request on hub

Parameters:
instance root hub instance
feature feature selector
port port number, counted from 1
enable enable or disable the specified feature
Returns:
error code

Definition at line 659 of file root_hub.c.

static int process_request_with_input ( rh_t instance,
usb_transfer_batch_t request 
) [static]

process one of requests that carry input data

Request can be one of USB_DEVREQ_SET_DESCRIPTOR or USB_DEVREQ_SET_CONFIGURATION.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 752 of file root_hub.c.

static int process_request_with_output ( rh_t instance,
usb_transfer_batch_t request 
) [static]

process one of requests that requere output data

Request can be one of USB_DEVREQ_GET_STATUS, USB_DEVREQ_GET_DESCRIPTOR or USB_DEVREQ_GET_CONFIGURATION.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 722 of file root_hub.c.

static int process_request_without_data ( rh_t instance,
usb_transfer_batch_t request 
) [static]

process one of requests that do not request nor carry additional data

Request can be one of USB_DEVREQ_CLEAR_FEATURE, USB_DEVREQ_SET_FEATURE or USB_DEVREQ_SET_ADDRESS.

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 779 of file root_hub.c.

static int register_endpoint ( ddf_fun_t fun,
usb_address_t  address,
usb_speed_t  ep_speed,
usb_endpoint_t  endpoint,
usb_transfer_type_t  transfer_type,
usb_direction_t  direction,
size_t  max_packet_size,
unsigned int  interval 
) [static]

Register endpoint for bandwidth reservation.

Parameters:
[in] fun Device function the action was invoked on.
[in] address USB address of the device.
[in] ep_speed Endpoint speed (invalid means to use device one).
[in] endpoint Endpoint number.
[in] transfer_type USB transfer type.
[in] direction Endpoint data direction.
[in] max_packet_size Max packet size of the endpoint.
[in] interval Polling interval.
Returns:
Error code.

Definition at line 173 of file iface.c.

static int release_address ( ddf_fun_t fun,
usb_address_t  address 
) [static]

Release address interface function.

Parameters:
[in] fun DDF function that was called.
[in] address USB address to be released.
Returns:
Error code.

Definition at line 151 of file iface.c.

static int request_address ( ddf_fun_t fun,
usb_speed_t  speed,
usb_address_t address 
) [static]

Request address interface function.

Parameters:
[in] fun DDF function that was called.
[in] speed Speed to associate with the new default address.
[out] address Place to write a new address.
Returns:
Error code.

Definition at line 91 of file iface.c.

int rh_init ( rh_t instance,
ohci_regs_t regs 
)

Root hub initialization.

Returns:
Error code.

Definition at line 217 of file root_hub.c.

static int rh_init_descriptors ( rh_t instance  )  [static]

initialize hub descriptors

Initialized are device and full configuration descriptor. These need to be initialized only once per hub. root hub instance

Returns:
error code

Definition at line 354 of file root_hub.c.

void rh_interrupt ( rh_t instance  ) 

process interrupt on a hub

If there is no pending interrupt transfer, nothing happens.

Parameters:
instance 

Definition at line 285 of file root_hub.c.

int rh_request ( rh_t instance,
usb_transfer_batch_t request 
)

process root hub request

Parameters:
instance root hub instance
request structure containing both request and response information
Returns:
error code

Definition at line 248 of file root_hub.c.

static int usb_iface_get_address ( ddf_fun_t fun,
devman_handle_t  handle,
usb_address_t address 
) [static]

Get address of the device identified by handle.

Parameters:
[in] dev DDF instance of the device to use.
[in] iid (Unused).
[in] call Pointer to the call that represents interrupt.

Definition at line 84 of file ohci.c.

static int usb_iface_get_hc_handle ( ddf_fun_t fun,
devman_handle_t handle 
) [static]

Gets handle of the respective hc (this device, hc function).

Parameters:
[in] root_hub_fun Root hub function seeking hc handle.
[out] handle Place to write the handle.
Returns:
Error code.

Definition at line 108 of file ohci.c.


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