TianoCore EDK2 master
|
#include <Uefi.h>
#include <Protocol/Usb2HostController.h>
#include <Protocol/UsbHostController.h>
#include <Protocol/UsbIo.h>
#include <Protocol/DevicePath.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <IndustryStandard/Usb.h>
#include "UsbUtility.h"
#include "UsbDesc.h"
#include "UsbHub.h"
#include "UsbEnumer.h"
Go to the source code of this file.
Data Structures | |
struct | _EFI_USB_BUS_PROTOCOL |
struct | _USB_DEVICE |
struct | _USB_INTERFACE |
struct | _USB_BUS |
struct | _USB_HUB_API |
struct | _DEVICE_PATH_LIST_ITEM |
struct | USB_CLASS_FORMAT_DEVICE_PATH |
Macros | |
#define | USB_MAX_LANG_ID 16 |
#define | USB_MAX_INTERFACE 16 |
#define | USB_MAX_DEVICES 128 |
#define | USB_BUS_1_MILLISECOND 1000 |
#define | USB_ROOTHUB_POLL_INTERVAL (100 * 10000U) |
#define | USB_HUB_POLL_INTERVAL 64 |
#define | USB_WAIT_PORT_STABLE_STALL (100 * USB_BUS_1_MILLISECOND) |
#define | USB_WAIT_PORT_STS_CHANGE_STALL (100) |
#define | USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND) |
#define | USB_RETRY_MAX_PACK_SIZE_STALL (100 * USB_BUS_1_MILLISECOND) |
#define | USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND) |
#define | USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND) |
#define | USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND) |
#define | USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND) |
#define | USB_CLR_ROOT_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND) |
#define | USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND) |
#define | USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500 |
#define | USB_CLEAR_FEATURE_REQUEST_TIMEOUT 10 |
#define | USB_BUS_TPL TPL_NOTIFY |
#define | USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I') |
#define | USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B') |
#define | USB_BIT(a) ((UINTN)(1 << (a))) |
#define | USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define | USB_INTERFACE_FROM_USBIO(a) CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE) |
#define | USB_BUS_FROM_THIS(a) CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE) |
#define | USB_US_LAND_ID 0x0409 |
#define | DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i') |
Typedefs | |
typedef struct _USB_DEVICE | USB_DEVICE |
typedef struct _USB_INTERFACE | USB_INTERFACE |
typedef struct _USB_BUS | USB_BUS |
typedef struct _USB_HUB_API | USB_HUB_API |
typedef struct _EFI_USB_BUS_PROTOCOL | EFI_USB_BUS_PROTOCOL |
typedef struct _DEVICE_PATH_LIST_ITEM | DEVICE_PATH_LIST_ITEM |
Variables | |
EFI_USB_IO_PROTOCOL | mUsbIoProtocol |
EFI_DRIVER_BINDING_PROTOCOL | mUsbBusDriverBinding |
EFI_COMPONENT_NAME_PROTOCOL | mUsbBusComponentName |
EFI_COMPONENT_NAME2_PROTOCOL | mUsbBusComponentName2 |
Usb Bus Driver Binding and Bus IO Protocol.
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file UsbBus.h.
#define DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i') |
#define USB_BIT_IS_SET | ( | Data, | |
Bit | |||
) | ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B') |
#define USB_CLR_ROOT_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND) |
#define USB_INTERFACE_FROM_USBIO | ( | a | ) | CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE) |
#define USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I') |
#define USB_RETRY_MAX_PACK_SIZE_STALL (100 * USB_BUS_1_MILLISECOND) |
#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND) |
#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND) |
#define USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND) |
#define USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND) |
#define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND) |
#define USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND) |
#define USB_WAIT_PORT_STABLE_STALL (100 * USB_BUS_1_MILLISECOND) |
typedef struct _USB_DEVICE USB_DEVICE |
typedef struct _USB_HUB_API USB_HUB_API |
typedef struct _USB_INTERFACE USB_INTERFACE |
EFI_STATUS EFIAPI UsbBusAddWantedUsbIoDP | ( | IN EFI_USB_BUS_PROTOCOL * | UsbBusId, |
IN EFI_DEVICE_PATH_PROTOCOL * | RemainingDevicePath | ||
) |
Store a wanted usb child device info (its Usb part of device path) which is indicated by RemainingDevicePath in a Usb bus which is indicated by UsbBusId.
UsbBusId | Point to EFI_USB_BUS_PROTOCOL interface. |
RemainingDevicePath | The remaining device patch. |
EFI_SUCCESS | Add operation is successful. |
EFI_INVALID_PARAMETER | The parameters are invalid. |
Definition at line 951 of file UsbUtility.c.
EFI_STATUS EFIAPI UsbBusBuildProtocol | ( | IN EFI_DRIVER_BINDING_PROTOCOL * | This, |
IN EFI_HANDLE | Controller, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | RemainingDevicePath | ||
) |
Install Usb Bus Protocol on host controller, and start the Usb bus.
This | The USB bus driver binding instance. |
Controller | The controller to check. |
RemainingDevicePath | The remaining device patch. |
EFI_SUCCESS | The controller is controlled by the usb bus. |
EFI_ALREADY_STARTED | The controller is already controlled by the usb bus. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
EFI_STATUS EFIAPI UsbBusControllerDriverStart | ( | IN EFI_DRIVER_BINDING_PROTOCOL * | This, |
IN EFI_HANDLE | Controller, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | RemainingDevicePath | ||
) |
Start to process the controller.
This | The USB bus driver binding instance. |
Controller | The controller to check. |
RemainingDevicePath | The remaining device patch. |
EFI_SUCCESS | The controller is controlled by the usb bus. |
EFI_ALREADY_STARTED | The controller is already controlled by the usb bus. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
EFI_STATUS EFIAPI UsbBusControllerDriverStop | ( | IN EFI_DRIVER_BINDING_PROTOCOL * | This, |
IN EFI_HANDLE | Controller, | ||
IN UINTN | NumberOfChildren, | ||
IN EFI_HANDLE * | ChildHandleBuffer | ||
) |
Stop handle the controller by this USB bus driver.
This | The USB bus driver binding protocol. |
Controller | The controller to release. |
NumberOfChildren | The child of USB bus that opened controller BY_CHILD. |
ChildHandleBuffer | The array of child handle. |
EFI_SUCCESS | The controller or children are stopped. |
EFI_DEVICE_ERROR | Failed to stop the driver. |
EFI_STATUS EFIAPI UsbBusControllerDriverSupported | ( | IN EFI_DRIVER_BINDING_PROTOCOL * | This, |
IN EFI_HANDLE | Controller, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | RemainingDevicePath | ||
) |
Check whether USB bus driver support this device.
This | The USB bus driver binding protocol. |
Controller | The controller handle to check. |
RemainingDevicePath | The remaining device path. |
EFI_SUCCESS | The bus supports this controller. |
EFI_UNSUPPORTED | This device isn't supported. |
EFI_STATUS EFIAPI UsbBusDriverEntryPoint | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
EFI_STATUS EFIAPI UsbBusFreeUsbDPList | ( | IN LIST_ENTRY * | UsbIoDPList | ) |
Free a DEVICE_PATH_LIST_ITEM list.
UsbIoDPList | a DEVICE_PATH_LIST_ITEM list pointer. |
EFI_INVALID_PARAMETER | If parameters are invalid, return this value. |
EFI_SUCCESS | If free operation is successful, return this value. |
Definition at line 902 of file UsbUtility.c.
BOOLEAN EFIAPI UsbBusIsWantedUsbIO | ( | IN USB_BUS * | Bus, |
IN USB_INTERFACE * | UsbIf | ||
) |
Check whether a usb child device is the wanted device in a bus.
Bus | The Usb bus's private data pointer. |
UsbIf | The usb child device interface. |
True | If a usb child device is the wanted device in a bus. |
False | If a usb child device is NOT the wanted device in a bus. |
Definition at line 1022 of file UsbUtility.c.
EFI_STATUS EFIAPI UsbBusRecursivelyConnectWantedUsbIo | ( | IN EFI_USB_BUS_PROTOCOL * | UsbBusId | ) |
Recursively connect every wanted usb child device to ensure they all fully connected. Check all the child Usb IO handles in this bus, recursively connecte if it is wanted usb child device.
UsbBusId | Point to EFI_USB_BUS_PROTOCOL interface. |
EFI_SUCCESS | Connect is done successfully. |
EFI_INVALID_PARAMETER | The parameter is invalid. |
Definition at line 1134 of file UsbUtility.c.
EFI_STATUS EFIAPI UsbIoAsyncInterruptTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | Endpoint, | ||
IN BOOLEAN | IsNewTransfer, | ||
IN UINTN PollInterval | OPTIONAL, | ||
IN UINTN DataLength | OPTIONAL, | ||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback | OPTIONAL, | ||
IN VOID *Context | OPTIONAL | ||
) |
Queue a new asynchronous interrupt transfer, or remove the old request if (IsNewTransfer == FALSE).
This | The USB_IO instance. |
Endpoint | The device endpoint. |
IsNewTransfer | Whether this is a new request, if it's old, remove the request. |
PollInterval | The interval to poll the transfer result, (in ms). |
DataLength | The length of perodic data transfer. |
Callback | The function to call periodically when transfer is ready. |
Context | The context to the callback. |
EFI_SUCCESS | New transfer is queued or old request is removed. |
EFI_INVALID_PARAMETER | Some parameters are invalid. |
Others | Failed to queue the new request or remove the old request. |
EFI_STATUS EFIAPI UsbIoAsyncIsochronousTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | DeviceEndpoint, | ||
IN OUT VOID * | Data, | ||
IN UINTN | DataLength, | ||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK | IsochronousCallBack, | ||
IN VOID *Context | OPTIONAL | ||
) |
Queue an asynchronous isochronous transfer.
This | The USB_IO instance. |
DeviceEndpoint | The device endpoint. |
Data | The data to transfer. |
DataLength | The length of perodic data transfer. |
IsochronousCallBack | The function to call periodically when transfer is ready. |
Context | The context to the callback. |
EFI_UNSUPPORTED | Currently isochronous transfer isn't supported. |
EFI_STATUS EFIAPI UsbIoBulkTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | Endpoint, | ||
IN OUT VOID * | Data, | ||
IN OUT UINTN * | DataLength, | ||
IN UINTN | Timeout, | ||
OUT UINT32 * | UsbStatus | ||
) |
Execute a bulk transfer to the device endpoint.
This | The USB IO instance. |
Endpoint | The device endpoint. |
Data | The data to transfer. |
DataLength | The length of the data to transfer. |
Timeout | Time to wait before timeout. |
UsbStatus | The result of USB transfer. |
EFI_SUCCESS | The bulk transfer is OK. |
EFI_INVALID_PARAMETER | Some parameters are invalid. |
Others | Failed to execute transfer, reason returned in UsbStatus. |
EFI_STATUS EFIAPI UsbIoControlTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN EFI_USB_DEVICE_REQUEST * | Request, | ||
IN EFI_USB_DATA_DIRECTION | Direction, | ||
IN UINT32 | Timeout, | ||
IN OUT VOID *Data | OPTIONAL, | ||
IN UINTN DataLength | OPTIONAL, | ||
OUT UINT32 * | UsbStatus | ||
) |
USB_IO function to execute a control transfer. This function will execute the USB transfer. If transfer successes, it will sync the internal state of USB bus with device state.
This | The USB_IO instance |
Request | The control transfer request |
Direction | Direction for data stage |
Timeout | The time to wait before timeout |
Data | The buffer holding the data |
DataLength | Then length of the data |
UsbStatus | USB result |
EFI_INVALID_PARAMETER | The parameters are invalid |
EFI_SUCCESS | The control transfer succeded. |
Others | Failed to execute the transfer |
USB_IO function to execute a control transfer. This function will execute the USB transfer. If transfer successes, it will sync the internal state of USB bus with device state.
This | The USB_IO instance |
Request | The control transfer request |
Direction | Direction for data stage |
Timeout | The time to wait before timeout |
Data | The buffer holding the data |
DataLength | Then length of the data |
UsbStatus | USB result |
EFI_INVALID_PARAMETER | The parameters are invalid |
EFI_SUCCESS | The control transfer succeeded. |
Others | Failed to execute the transfer |
EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor | ( | IN EFI_USB_IO_PROTOCOL * | This, |
OUT EFI_USB_CONFIG_DESCRIPTOR * | Descriptor | ||
) |
Return the configuration descriptor of the current active configuration.
This | The USB IO instance. |
Descriptor | The USB configuration descriptor. |
EFI_SUCCESS | The active configuration descriptor is returned. |
EFI_INVALID_PARAMETER | Some parameter is invalid. |
EFI_NOT_FOUND | Currently no active configuration is selected. |
EFI_STATUS EFIAPI UsbIoGetDeviceDescriptor | ( | IN EFI_USB_IO_PROTOCOL * | This, |
OUT EFI_USB_DEVICE_DESCRIPTOR * | Descriptor | ||
) |
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | Index, | ||
OUT EFI_USB_ENDPOINT_DESCRIPTOR * | Descriptor | ||
) |
Retrieve the endpoint descriptor from this interface setting.
This | The USB IO instance. |
Index | The index (start from zero) of the endpoint to retrieve. |
Descriptor | The variable to receive the descriptor. |
EFI_SUCCESS | The endpoint descriptor is returned. |
EFI_INVALID_PARAMETER | Some parameter is invalid. |
EFI_STATUS EFIAPI UsbIoGetInterfaceDescriptor | ( | IN EFI_USB_IO_PROTOCOL * | This, |
OUT EFI_USB_INTERFACE_DESCRIPTOR * | Descriptor | ||
) |
Retrieve the active interface setting descriptor for this USB IO instance.
This | The USB IO instance. |
Descriptor | The variable to receive active interface setting. |
EFI_SUCCESS | The active interface setting is returned. |
EFI_INVALID_PARAMETER | Some parameter is invalid. |
EFI_STATUS EFIAPI UsbIoGetStringDescriptor | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT16 | LangID, | ||
IN UINT8 | StringIndex, | ||
OUT CHAR16 ** | String | ||
) |
Retrieve an indexed string in the language of LangID.
This | The USB IO instance. |
LangID | The language ID of the string to retrieve. |
StringIndex | The index of the string. |
String | The variable to receive the string. |
EFI_SUCCESS | The string is returned. |
EFI_NOT_FOUND | No such string existed. |
EFI_STATUS EFIAPI UsbIoGetSupportedLanguages | ( | IN EFI_USB_IO_PROTOCOL * | This, |
OUT UINT16 ** | LangIDTable, | ||
OUT UINT16 * | TableSize | ||
) |
EFI_STATUS EFIAPI UsbIoIsochronousTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | DeviceEndpoint, | ||
IN OUT VOID * | Data, | ||
IN UINTN | DataLength, | ||
OUT UINT32 * | Status | ||
) |
Execute a synchronous isochronous transfer.
This | The USB IO instance. |
DeviceEndpoint | The device endpoint. |
Data | The data to transfer. |
DataLength | The length of the data to transfer. |
UsbStatus | The result of USB transfer. |
EFI_UNSUPPORTED | Currently isochronous transfer isn't supported. |
EFI_STATUS EFIAPI UsbIoPortReset | ( | IN EFI_USB_IO_PROTOCOL * | This | ) |
EFI_STATUS EFIAPI UsbIoSyncInterruptTransfer | ( | IN EFI_USB_IO_PROTOCOL * | This, |
IN UINT8 | Endpoint, | ||
IN OUT VOID * | Data, | ||
IN OUT UINTN * | DataLength, | ||
IN UINTN | Timeout, | ||
OUT UINT32 * | UsbStatus | ||
) |
Execute a synchronous interrupt transfer.
This | The USB IO instance. |
Endpoint | The device endpoint. |
Data | The data to transfer. |
DataLength | The length of the data to transfer. |
Timeout | Time to wait before timeout. |
UsbStatus | The result of USB transfer. |
EFI_SUCCESS | The synchronous interrupt transfer is OK. |
EFI_INVALID_PARAMETER | Some parameters are invalid. |
Others | Failed to execute transfer, reason returned in UsbStatus. |
|
extern |
Definition at line 142 of file ComponentName.c.
|
extern |
Definition at line 151 of file ComponentName.c.
|
extern |
|
extern |