Files | |
file | ehci.h |
Common EHCI definitions. | |
file | hc_iface.c |
USB-HC interface implementation. | |
file | main.c |
Main routines of EHCI driver. | |
file | pci.c |
PCI related functions needed by the EHCI driver. | |
file | pci.h |
PCI related functions needed by EHCI driver. | |
Defines | |
#define | CFG_OFFSET 0x40 |
#define | CMD_OFFSET 0x0 |
#define | DEFAULT_WAIT 1000 |
#define | HCC_PARAMS_EECP_MASK 0xff |
#define | HCC_PARAMS_EECP_OFFSET 8 |
#define | HCC_PARAMS_OFFSET 0x8 |
#define | INT_OFFSET 0x8 |
#define | NAME "ehci-hcd" |
#define | PAGE_SIZE_MASK 0xfffff000 |
#define | PCI_READ(size) |
#define | PCI_WRITE(size) |
#define | STS_OFFSET 0x4 |
#define | UNSUPPORTED(methodname) |
#define | USBCMD_RUN 1 |
#define | USBLEGCTLSTS_OFFSET 4 |
#define | USBLEGSUP_BIOS_CONTROL (1 << 16) |
#define | USBLEGSUP_OFFSET 0 |
#define | USBLEGSUP_OS_CONTROL (1 << 24) |
#define | USBSTS_HALTED (1 << 12) |
#define | WAIT_STEP 10 |
Functions | |
static int | bind_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t handle) |
Bind USB address with device devman handle. | |
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 | control_read (ddf_fun_t *fun, usb_target_t target, void *setup_packet, size_t setup_packet_size, void *data_buffer, size_t data_buffer_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_packet, size_t setup_packet_size, void *data_buffer, size_t data_buffer_size, usbhc_iface_transfer_out_callback_t callback, void *arg) |
Schedule control write transfer. | |
static int | ehci_add_device (ddf_dev_t *device) |
Initializes a new ddf driver instance of EHCI hcd. | |
static int | find_by_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t *handle) |
Find device handle by USB address. | |
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. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
int | pci_disable_legacy (const ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, int irq) |
Implements BIOS handoff routine as decribed in EHCI spec. | |
int | pci_enable_interrupts (const ddf_dev_t *device) |
Calls the PCI driver with a request to enable interrupts. | |
int | pci_get_my_registers (const 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 | pci_read16 (const ddf_dev_t *dev, int address, uint16_t *value) |
static int | pci_read32 (const ddf_dev_t *dev, int address, uint32_t *value) |
static int | pci_read8 (const ddf_dev_t *dev, int address, uint8_t *value) |
static int | pci_write16 (const ddf_dev_t *dev, int address, uint16_t value) |
static int | pci_write32 (const ddf_dev_t *dev, int address, uint32_t value) |
static int | pci_write8 (const ddf_dev_t *dev, int address, uint8_t value) |
static int | register_endpoint (ddf_fun_t *fun, usb_address_t address, usb_speed_t 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 previously requested address. | |
static int | request_address (ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address) |
Found free USB address. | |
static int | unregister_endpoint (ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction) |
Unregister endpoint (free some bandwidth reservation). | |
Variables | |
static driver_t | ehci_driver |
static driver_ops_t | ehci_driver_ops |
usbhc_iface_t | ehci_hc_iface |
Host controller interface implementation for EHCI. | |
usbhc_iface_t | ehci_hc_iface |
Host controller interface implementation for EHCI. | |
static ddf_dev_ops_t | hc_ops |
static int bind_address | ( | ddf_fun_t * | fun, | |
usb_address_t | address, | |||
devman_handle_t | handle | |||
) | [static] |
Bind USB address with device devman handle.
[in] | fun | Device function the action was invoked on. |
[in] | address | USB address of the device. |
[in] | handle | Devman handle of the device. |
Definition at line 72 of file hc_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).
[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. |
Definition at line 237 of file hc_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).
[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. |
Definition at line 212 of file hc_iface.c.
static int control_read | ( | ddf_fun_t * | fun, | |
usb_target_t | target, | |||
void * | setup_packet, | |||
size_t | setup_packet_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_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).
[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_packet_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] | data_buffer_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. |
Definition at line 294 of file hc_iface.c.
static int control_write | ( | ddf_fun_t * | fun, | |
usb_target_t | target, | |||
void * | setup_packet, | |||
size_t | setup_packet_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_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).
[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_packet_size | Size of setup_packet buffer in bytes. |
[in] | data_buffer | Data buffer (in USB endianess, allocated and deallocated by the caller). |
[in] | data_buffer_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. |
Definition at line 265 of file hc_iface.c.
static int ehci_add_device | ( | ddf_dev_t * | device | ) | [static] |
static int find_by_address | ( | ddf_fun_t * | fun, | |
usb_address_t | address, | |||
devman_handle_t * | handle | |||
) | [static] |
Find device handle by USB address.
[in] | fun | DDF function that was called. |
[in] | address | Address in question. |
[out] | handle | Where to store device handle if found. |
Definition at line 87 of file hc_iface.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).
[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. |
Definition at line 187 of file hc_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).
[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. |
Definition at line 162 of file hc_iface.c.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
int pci_enable_interrupts | ( | const ddf_dev_t * | device | ) |
int pci_get_my_registers | ( | const 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.
[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. |
static int register_endpoint | ( | ddf_fun_t * | fun, | |
usb_address_t | address, | |||
usb_speed_t | 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.
[in] | fun | Device function the action was invoked on. |
[in] | address | USB address of the device. |
[in] | 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. |
Definition at line 120 of file hc_iface.c.
static int release_address | ( | ddf_fun_t * | fun, | |
usb_address_t | address | |||
) | [static] |
Release previously requested address.
[in] | fun | Device function the action was invoked on. |
[in] | address | USB address to be released. |
Definition at line 101 of file hc_iface.c.
static int request_address | ( | ddf_fun_t * | fun, | |
usb_speed_t | speed, | |||
usb_address_t * | address | |||
) | [static] |
Found free USB address.
[in] | fun | Device function the action was invoked on. |
[in] | speed | Speed of the device that will get this address. |
[out] | address | Non-null pointer where to store the free address. |
Definition at line 57 of file hc_iface.c.
static int unregister_endpoint | ( | ddf_fun_t * | fun, | |
usb_address_t | address, | |||
usb_endpoint_t | endpoint, | |||
usb_direction_t | direction | |||
) | [static] |
Unregister endpoint (free some bandwidth reservation).
[in] | fun | Device function the action was invoked on. |
[in] | address | USB address of the device. |
[in] | endpoint | Endpoint number. |
[in] | direction | Endpoint data direction. |
Definition at line 138 of file hc_iface.c.