+\r
+STATIC\r
+EFI_STATUS\r
+UsbSetTransactionTranslator (\r
+ IN USB_IO_CONTROLLER_DEVICE *ParentHubController,\r
+ IN UINT8 ParentPort,\r
+ IN OUT USB_IO_DEVICE *Device\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Set Transaction Translator parameter\r
+ \r
+ Arguments:\r
+ \r
+ ParentHubController - Controller structure of the parent Hub device\r
+ ParentPort - Number of parent port\r
+ Device - Structure of the device\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS Success\r
+ EFI_OUT_OF_RESOURCES Cannot allocate resources\r
+ \r
+--*/\r
+{\r
+ USB_IO_CONTROLLER_DEVICE *AncestorHubController;\r
+\r
+ AncestorHubController = ParentHubController;\r
+ Device->Translator = NULL;\r
+\r
+ if (EFI_USB_SPEED_HIGH == Device->DeviceSpeed) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ do {\r
+ if (EFI_USB_SPEED_HIGH == AncestorHubController->UsbDevice->DeviceSpeed) {\r
+ break;\r
+ }\r
+\r
+ if (NULL == AncestorHubController->Parent) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ AncestorHubController = AncestorHubController->Parent;\r
+ } while (1);\r
+\r
+ Device->Translator = AllocatePool (sizeof (EFI_USB2_HC_TRANSACTION_TRANSLATOR));\r
+ if (NULL == Device->Translator) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ Device->Translator->TranslatorHubAddress = AncestorHubController->UsbDevice->DeviceAddress;\r
+ Device->Translator->TranslatorPortNumber = ParentPort;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UsbUnsetTransactionTranslator (\r
+ USB_IO_DEVICE *Device\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Unset Transaction Translator parameter\r
+ \r
+ Arguments:\r
+ \r
+ Device - Structure of the device\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS Success\r
+ \r
+--*/\r
+{\r
+ if (Device->Translator) {\r
+ gBS->FreePool (Device->Translator);\r
+ Device->Translator = NULL;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+IdentifyDeviceSpeed (\r
+ USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ USB_IO_DEVICE *NewDevice,\r
+ UINT8 Index\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Identify speed of USB device\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - UsbBus controller structure of the device\r
+ NewDevice - Devcie controller structure\r
+ Index - Number of the port\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS Success\r
+ EFI_NOT_FOUND Device release to CHC or can't be found\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_USB_PORT_STATUS HubPortStatus;\r
+\r
+ UsbVirtualHcGetRootHubPortStatus (\r
+ UsbBusDev,\r
+ Index,\r
+ (EFI_USB_PORT_STATUS *) &HubPortStatus\r
+ );\r
+ \r
+ //\r
+ // Check device device\r
+ //\r
+ if (!(HubPortStatus.PortStatus & USB_PORT_STAT_OWNER)) {\r
+ //\r
+ // EHC Port Owner\r
+ //\r
+ if (HubPortStatus.PortStatus & USB_PORT_STAT_HIGH_SPEED) {\r
+ DEBUG ((gUSBDebugLevel, "High Speed Device attached to EHC\n"));\r
+ NewDevice->DeviceSpeed = EFI_USB_SPEED_HIGH; \r
+ } else {\r
+ Status = ReleasePortToCHC (UsbBusDev, Index);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((gUSBErrorLevel, "Fail to release port to CHC\n"));\r
+ } else {\r
+ DEBUG ((gUSBDebugLevel, "Success to release port to CHC\n"));\r
+ }\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ } else {\r
+ //\r
+ // CHC Port Owner\r
+ //\r
+ if (HubPortStatus.PortStatus & USB_PORT_STAT_LOW_SPEED) {\r
+ DEBUG ((gUSBDebugLevel, "Low Speed Device attached to CHC\n"));\r
+ NewDevice->DeviceSpeed = EFI_USB_SPEED_LOW; \r
+ } else {\r
+ DEBUG ((gUSBDebugLevel, "FULL Speed Device attached to CHC\n"));\r
+ NewDevice->DeviceSpeed = EFI_USB_SPEED_FULL; \r
+ }\r
+ }\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ReleasePortToCHC (\r
+ USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ UINT8 PortNum\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Set bit to release the port owner to CHC\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - UsbBus controller structure of the device\r
+ PortNum - Number of the port\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS Success\r
+ EFI_DEVICE_ERROR Fail\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = UsbVirtualHcSetRootHubPortFeature (\r
+ UsbBusDev,\r
+ PortNum,\r
+ EfiUsbPortOwner\r
+ );\r
+\r
+ gBS->Stall (100 * 1000);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcGetCapability (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ OUT UINT8 *MaxSpeed,\r
+ OUT UINT8 *PortNumber,\r
+ OUT UINT8 *Is64BitCapable\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to Retrieves the capablility of root hub ports \r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ MaxSpeed - A pointer to the number of the host controller.\r
+ PortNumber - A pointer to the number of the root hub ports.\r
+ Is64BitCapable - A pointer to the flag for whether controller supports \r
+ 64-bit memory addressing.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The host controller capability were retrieved successfully.\r
+ EFI_INVALID_PARAMETER \r
+ MaxSpeed or PortNumber or Is64BitCapable is NULL.\r
+ EFI_DEVICE_ERROR \r
+ An error was encountered while attempting to retrieve the capabilities. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->GetCapability (\r
+ UsbBusDev->Usb2HCInterface,\r
+ MaxSpeed,\r
+ PortNumber,\r
+ Is64BitCapable\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->GetRootHubPortNumber (\r
+ UsbBusDev->UsbHCInterface,\r
+ PortNumber\r
+ );\r
+ *MaxSpeed = EFI_USB_SPEED_FULL;\r
+ *Is64BitCapable = (UINT8) FALSE;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcReset (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT16 Attributes\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to provides software reset for the USB host controller\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ Attributes - A bit mask of the reset operation to perform. \r
+ See below for a list of the supported bit mask values.\r
+ \r
+ #define EFI_USB_HC_RESET_GLOBAL 0x0001 // Hc2 and Hc\r
+ #define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 // Hc2 and Hc\r
+ #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 // Hc2\r
+ #define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 // Hc2\r
+\r
+ EFI_USB_HC_RESET_GLOBAL \r
+ If this bit is set, a global reset signal will be sent to the USB bus.\r
+ This resets all of the USB bus logic, including the USB host \r
+ controller hardware and all the devices attached on the USB bus.\r
+ EFI_USB_HC_RESET_HOST_CONTROLLER \r
+ If this bit is set, the USB host controller hardware will be reset. \r
+ No reset signal will be sent to the USB bus.\r
+ EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG\r
+ If this bit is set, a global reset signal will be sent to the USB bus.\r
+ This resets all of the USB bus logic, including the USB host \r
+ controller hardware and all the devices attached on the USB bus. \r
+ If this is an EHCI controller and the debug port has configured, then \r
+ this is will still reset the host controller.\r
+ EFI_USB_HC_RESET_HOST_WITH_DEBUG\r
+ If this bit is set, the USB host controller hardware will be reset. \r
+ If this is an EHCI controller and the debug port has been configured,\r
+ then this will still reset the host controller.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The reset operation succeeded.\r
+ EFI_INVALID_PARAMETER \r
+ Attributes is not valid.\r
+ EFI_UNSUPPOURTED\r
+ The type of reset specified by Attributes is not currently supported by\r
+ the host controller hardware.\r
+ EFI_ACCESS_DENIED\r
+ Reset operation is rejected due to the debug port being configured and \r
+ active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or \r
+ EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to\r
+ perform reset operation for this host controller.\r
+ EFI_DEVICE_ERROR \r
+ An error was encountered while attempting to perform \r
+ the reset operation.\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->Reset (\r
+ UsbBusDev->Usb2HCInterface,\r
+ EFI_USB_HC_RESET_GLOBAL\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->Reset (\r
+ UsbBusDev->UsbHCInterface,\r
+ EFI_USB_HC_RESET_GLOBAL\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcGetState (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ OUT EFI_USB_HC_STATE *State\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to retrieves current state of the USB host controller\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ State - A pointer to the EFI_USB_HC_STATE data structure that \r
+ indicates current state of the USB host controller. \r
+ Type EFI_USB_HC_STATE is defined below.\r
+ \r
+ typedef enum {\r
+ EfiUsbHcStateHalt,\r
+ EfiUsbHcStateOperational,\r
+ EfiUsbHcStateSuspend,\r
+ EfiUsbHcStateMaximum\r
+ } EFI_USB_HC_STATE;\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The state information of the host controller was returned in State.\r
+ EFI_INVALID_PARAMETER \r
+ State is NULL.\r
+ EFI_DEVICE_ERROR \r
+ An error was encountered while attempting to retrieve the \r
+ host controller's current state. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->GetState (\r
+ UsbBusDev->Usb2HCInterface,\r
+ State\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->GetState (\r
+ UsbBusDev->UsbHCInterface,\r
+ State\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcSetState (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN EFI_USB_HC_STATE State\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to sets the USB host controller to a specific state\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ State - Indicates the state of the host controller that will be set.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The USB host controller was successfully placed in the state \r
+ specified by State.\r
+ EFI_INVALID_PARAMETER \r
+ State is invalid.\r
+ EFI_DEVICE_ERROR \r
+ Failed to set the state specified by State due to device error. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->SetState (\r
+ UsbBusDev->Usb2HCInterface,\r
+ State\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->SetState (\r
+ UsbBusDev->UsbHCInterface,\r
+ State\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcGetRootHubPortStatus (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 PortNumber,\r
+ OUT EFI_USB_PORT_STATUS *PortStatus\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to retrieves the current status of a USB root hub port\r
+ both for Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ PortNumber - Specifies the root hub port from which the status \r
+ is to be retrieved. This value is zero-based. For example, \r
+ if a root hub has two ports, then the first port is numbered 0,\r
+ and the second port is numbered 1.\r
+ PortStatus - A pointer to the current port status bits and \r
+ port status change bits. \r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS The status of the USB root hub port specified by PortNumber \r
+ was returned in PortStatus.\r
+ EFI_INVALID_PARAMETER PortNumber is invalid. \r
+ EFI_DEVICE_ERROR Can't read register \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->GetRootHubPortStatus (\r
+ UsbBusDev->Usb2HCInterface,\r
+ PortNumber,\r
+ PortStatus\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->GetRootHubPortStatus (\r
+ UsbBusDev->UsbHCInterface,\r
+ PortNumber,\r
+ PortStatus\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcSetRootHubPortFeature (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 PortNumber,\r
+ IN EFI_USB_PORT_FEATURE PortFeature\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ Virual interface to sets a feature for the specified root hub port\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ PortNumber - Specifies the root hub port whose feature \r
+ is requested to be set.\r
+ PortFeature - Indicates the feature selector associated \r
+ with the feature set request. \r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The feature specified by PortFeature was set for the \r
+ USB root hub port specified by PortNumber.\r
+ EFI_INVALID_PARAMETER \r
+ PortNumber is invalid or PortFeature is invalid.\r
+ EFI_DEVICE_ERROR\r
+ Can't read register\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->SetRootHubPortFeature (\r
+ UsbBusDev->Usb2HCInterface,\r
+ PortNumber,\r
+ PortFeature\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->SetRootHubPortFeature (\r
+ UsbBusDev->UsbHCInterface,\r
+ PortNumber,\r
+ PortFeature\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcClearRootHubPortFeature (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 PortNumber,\r
+ IN EFI_USB_PORT_FEATURE PortFeature\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to clears a feature for the specified root hub port\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ PortNumber - Specifies the root hub port whose feature \r
+ is requested to be cleared.\r
+ PortFeature - Indicates the feature selector associated with the \r
+ feature clear request.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The feature specified by PortFeature was cleared for the \r
+ USB root hub port specified by PortNumber.\r
+ EFI_INVALID_PARAMETER \r
+ PortNumber is invalid or PortFeature is invalid.\r
+ EFI_DEVICE_ERROR\r
+ Can't read register\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->ClearRootHubPortFeature (\r
+ UsbBusDev->Usb2HCInterface,\r
+ PortNumber,\r
+ PortFeature\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->ClearRootHubPortFeature (\r
+ UsbBusDev->UsbHCInterface,\r
+ PortNumber,\r
+ PortFeature\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcControlTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN EFI_USB_DEVICE_REQUEST *Request,\r
+ IN EFI_USB_DATA_DIRECTION TransferDirection,\r
+ IN OUT VOID *Data,\r
+ IN OUT UINTN *DataLength,\r
+ IN UINTN TimeOut,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+ OUT UINT32 *TransferResult\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to submits control transfer to a target USB device\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB,\r
+ which is assigned during USB enumeration.\r
+ DeviceSpeed - Indicates target device speed.\r
+ MaximumPacketLength - Indicates the maximum packet size that the \r
+ default control transfer endpoint is capable of \r
+ sending or receiving.\r
+ Request - A pointer to the USB device request that will be sent \r
+ to the USB device. \r
+ TransferDirection - Specifies the data direction for the transfer.\r
+ There are three values available, DataIn, DataOut \r
+ and NoData.\r
+ Data - A pointer to the buffer of data that will be transmitted \r
+ to USB device or received from USB device.\r
+ DataLength - Indicates the size, in bytes, of the data buffer \r
+ specified by Data.\r
+ TimeOut - Indicates the maximum time, in microseconds, \r
+ which the transfer is allowed to complete.\r
+ Translator - A pointr to the transaction translator data.\r
+ TransferResult - A pointer to the detailed result information generated \r
+ by this control transfer.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The control transfer was completed successfully.\r
+ EFI_OUT_OF_RESOURCES \r
+ The control transfer could not be completed due to a lack of resources.\r
+ EFI_INVALID_PARAMETER \r
+ Some parameters are invalid.\r
+ EFI_TIMEOUT \r
+ The control transfer failed due to timeout.\r
+ EFI_DEVICE_ERROR \r
+ The control transfer failed due to host controller or device error. \r
+ Caller should check TranferResult for detailed error information.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ BOOLEAN IsSlowDevice;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->ControlTransfer (\r
+ UsbBusDev->Usb2HCInterface,\r
+ DeviceAddress,\r
+ DeviceSpeed,\r
+ MaximumPacketLength,\r
+ Request,\r
+ TransferDirection,\r
+ Data,\r
+ DataLength,\r
+ TimeOut,\r
+ Translator,\r
+ TransferResult\r
+ );\r
+ } else {\r
+ IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;\r
+ Status = UsbBusDev->UsbHCInterface->ControlTransfer (\r
+ UsbBusDev->UsbHCInterface,\r
+ DeviceAddress,\r
+ IsSlowDevice,\r
+ (UINT8) MaximumPacketLength,\r
+ Request,\r
+ TransferDirection,\r
+ Data,\r
+ DataLength,\r
+ TimeOut,\r
+ TransferResult\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcBulkTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 EndPointAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN UINT8 DataBuffersNumber,\r
+ IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],\r
+ IN OUT UINTN *DataLength,\r
+ IN OUT UINT8 *DataToggle,\r
+ IN UINTN TimeOut,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+ OUT UINT32 *TransferResult\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to submits bulk transfer to a bulk endpoint of a USB device\r
+ both for Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB,\r
+ which is assigned during USB enumeration. \r
+ EndPointAddress - The combination of an endpoint number and an \r
+ endpoint direction of the target USB device. \r
+ Each endpoint address supports data transfer in \r
+ one direction except the control endpoint \r
+ (whose default endpoint address is 0). \r
+ It is the caller's responsibility to make sure that \r
+ the EndPointAddress represents a bulk endpoint. \r
+ DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL\r
+ and EFI_USB_SPEED_HIGH.\r
+ MaximumPacketLength - Indicates the maximum packet size the target endpoint\r
+ is capable of sending or receiving. \r
+ DataBuffersNumber - Number of data buffers prepared for the transfer.\r
+ Data - Array of pointers to the buffers of data that will be transmitted \r
+ to USB device or received from USB device. \r
+ DataLength - When input, indicates the size, in bytes, of the data buffer\r
+ specified by Data. When output, indicates the actually \r
+ transferred data size. \r
+ DataToggle - A pointer to the data toggle value. On input, it indicates \r
+ the initial data toggle value the bulk transfer should adopt;\r
+ on output, it is updated to indicate the data toggle value \r
+ of the subsequent bulk transfer. \r
+ Translator - A pointr to the transaction translator data. \r
+ TimeOut - Indicates the maximum time, in microseconds, which the \r
+ transfer is allowed to complete. \r
+ TransferResult - A pointer to the detailed result information of the \r
+ bulk transfer.\r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The bulk transfer was completed successfully.\r
+ EFI_OUT_OF_RESOURCES \r
+ The bulk transfer could not be submitted due to lack of resource.\r
+ EFI_INVALID_PARAMETER \r
+ Some parameters are invalid.\r
+ EFI_TIMEOUT \r
+ The bulk transfer failed due to timeout.\r
+ EFI_DEVICE_ERROR \r
+ The bulk transfer failed due to host controller or device error.\r
+ Caller should check TranferResult for detailed error information.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->BulkTransfer (\r
+ UsbBusDev->Usb2HCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ DeviceSpeed,\r
+ MaximumPacketLength,\r
+ DataBuffersNumber,\r
+ Data,\r
+ DataLength,\r
+ DataToggle,\r
+ TimeOut,\r
+ Translator,\r
+ TransferResult\r
+ );\r
+ } else {\r
+ Status = UsbBusDev->UsbHCInterface->BulkTransfer (\r
+ UsbBusDev->UsbHCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ (UINT8) MaximumPacketLength,\r
+ *Data,\r
+ DataLength,\r
+ DataToggle,\r
+ TimeOut,\r
+ TransferResult\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcAsyncInterruptTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE * UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 EndPointAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN BOOLEAN IsNewTransfer,\r
+ IN OUT UINT8 *DataToggle,\r
+ IN UINTN PollingInterval,\r
+ IN UINTN DataLength,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,\r
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,\r
+ IN VOID *Context OPTIONAL\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to submits an asynchronous interrupt transfer to an \r
+ interrupt endpoint of a USB device for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB,\r
+ which is assigned during USB enumeration. \r
+ EndPointAddress - The combination of an endpoint number and an endpoint \r
+ direction of the target USB device. Each endpoint address \r
+ supports data transfer in one direction except the \r
+ control endpoint (whose default endpoint address is 0). \r
+ It is the caller's responsibility to make sure that \r
+ the EndPointAddress represents an interrupt endpoint. \r
+ DeviceSpeed - Indicates device speed.\r
+ MaximumPacketLength - Indicates the maximum packet size the target endpoint\r
+ is capable of sending or receiving. \r
+ IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between\r
+ the host and the target interrupt endpoint. \r
+ If FALSE, the specified asynchronous interrupt pipe \r
+ is canceled. \r
+ DataToggle - A pointer to the data toggle value. On input, it is valid \r
+ when IsNewTransfer is TRUE, and it indicates the initial \r
+ data toggle value the asynchronous interrupt transfer \r
+ should adopt. \r
+ On output, it is valid when IsNewTransfer is FALSE, \r
+ and it is updated to indicate the data toggle value of \r
+ the subsequent asynchronous interrupt transfer. \r
+ PollingInterval - Indicates the interval, in milliseconds, that the \r
+ asynchronous interrupt transfer is polled. \r
+ This parameter is required when IsNewTransfer is TRUE. \r
+ DataLength - Indicates the length of data to be received at the \r
+ rate specified by PollingInterval from the target \r
+ asynchronous interrupt endpoint. This parameter \r
+ is only required when IsNewTransfer is TRUE. \r
+ Translator - A pointr to the transaction translator data.\r
+ CallBackFunction - The Callback function.This function is called at the \r
+ rate specified by PollingInterval.This parameter is \r
+ only required when IsNewTransfer is TRUE. \r
+ Context - The context that is passed to the CallBackFunction.\r
+ - This is an optional parameter and may be NULL.\r
+ \r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The asynchronous interrupt transfer request has been successfully \r
+ submitted or canceled.\r
+ EFI_INVALID_PARAMETER \r
+ Some parameters are invalid.\r
+ EFI_OUT_OF_RESOURCES \r
+ The request could not be completed due to a lack of resources. \r
+ EFI_DEVICE_ERROR\r
+ Can't read register\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ BOOLEAN IsSlowDevice;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->AsyncInterruptTransfer (\r
+ UsbBusDev->Usb2HCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ DeviceSpeed,\r
+ MaximumPacketLength,\r
+ IsNewTransfer,\r
+ DataToggle,\r
+ PollingInterval,\r
+ DataLength,\r
+ Translator,\r
+ CallBackFunction,\r
+ Context\r
+ );\r
+ } else {\r
+ IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;\r
+ Status = UsbBusDev->UsbHCInterface->AsyncInterruptTransfer (\r
+ UsbBusDev->UsbHCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ IsSlowDevice,\r
+ (UINT8) MaximumPacketLength,\r
+ IsNewTransfer,\r
+ DataToggle,\r
+ PollingInterval,\r
+ DataLength,\r
+ CallBackFunction,\r
+ Context\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcSyncInterruptTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 EndPointAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN OUT VOID *Data,\r
+ IN OUT UINTN *DataLength,\r
+ IN OUT UINT8 *DataToggle,\r
+ IN UINTN TimeOut,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+ OUT UINT32 *TransferResult\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Vitual interface to submits synchronous interrupt transfer to an interrupt endpoint \r
+ of a USB device for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB, \r
+ which is assigned during USB enumeration.\r
+ EndPointAddress - The combination of an endpoint number and an endpoint \r
+ direction of the target USB device. Each endpoint \r
+ address supports data transfer in one direction \r
+ except the control endpoint (whose default \r
+ endpoint address is 0). It is the caller's responsibility\r
+ to make sure that the EndPointAddress represents \r
+ an interrupt endpoint. \r
+ DeviceSpeed - Indicates device speed.\r
+ MaximumPacketLength - Indicates the maximum packet size the target endpoint \r
+ is capable of sending or receiving.\r
+ Data - A pointer to the buffer of data that will be transmitted \r
+ to USB device or received from USB device.\r
+ DataLength - On input, the size, in bytes, of the data buffer specified \r
+ by Data. On output, the number of bytes transferred.\r
+ DataToggle - A pointer to the data toggle value. On input, it indicates\r
+ the initial data toggle value the synchronous interrupt \r
+ transfer should adopt; \r
+ on output, it is updated to indicate the data toggle value \r
+ of the subsequent synchronous interrupt transfer. \r
+ TimeOut - Indicates the maximum time, in microseconds, which the \r
+ transfer is allowed to complete.\r
+ Translator - A pointr to the transaction translator data.\r
+ TransferResult - A pointer to the detailed result information from \r
+ the synchronous interrupt transfer. \r
+\r
+ Returns:\r
+ \r
+ EFI_SUCCESS \r
+ The synchronous interrupt transfer was completed successfully.\r
+ EFI_OUT_OF_RESOURCES \r
+ The synchronous interrupt transfer could not be submitted due \r
+ to lack of resource.\r
+ EFI_INVALID_PARAMETER \r
+ Some parameters are invalid.\r
+ EFI_TIMEOUT \r
+ The synchronous interrupt transfer failed due to timeout.\r
+ EFI_DEVICE_ERROR \r
+ The synchronous interrupt transfer failed due to host controller \r
+ or device error. Caller should check TranferResult for detailed \r
+ error information. \r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ BOOLEAN IsSlowDevice;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (UsbBusDev->Hc2ProtocolSupported) {\r
+ Status = UsbBusDev->Usb2HCInterface->SyncInterruptTransfer (\r
+ UsbBusDev->Usb2HCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ DeviceSpeed,\r
+ MaximumPacketLength,\r
+ Data,\r
+ DataLength,\r
+ DataToggle,\r
+ TimeOut,\r
+ Translator,\r
+ TransferResult\r
+ );\r
+ } else {\r
+ IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;\r
+ Status = UsbBusDev->UsbHCInterface->SyncInterruptTransfer (\r
+ UsbBusDev->UsbHCInterface,\r
+ DeviceAddress,\r
+ EndPointAddress,\r
+ IsSlowDevice,\r
+ (UINT8) MaximumPacketLength,\r
+ Data,\r
+ DataLength,\r
+ DataToggle,\r
+ TimeOut,\r
+ TransferResult\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcIsochronousTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 EndPointAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN UINT8 DataBuffersNumber,\r
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
+ IN UINTN DataLength,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+ OUT UINT32 *TransferResult\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Virtual interface to submits isochronous transfer to a target USB device\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB,\r
+ which is assigned during USB enumeration.\r
+ EndPointAddress - End point address\r
+ DeviceSpeed - Indicates device speed.\r
+ MaximumPacketLength - Indicates the maximum packet size that the \r
+ default control transfer endpoint is capable of \r
+ sending or receiving.\r
+ DataBuffersNumber - Number of data buffers prepared for the transfer.\r
+ Data - Array of pointers to the buffers of data that will be \r
+ transmitted to USB device or received from USB device.\r
+ DataLength - Indicates the size, in bytes, of the data buffer \r
+ specified by Data.\r
+ Translator - A pointr to the transaction translator data.\r
+ TransferResult - A pointer to the detailed result information generated \r
+ by this control transfer. \r
+ \r
+ Returns:\r
+ \r
+ EFI_UNSUPPORTED \r
+\r
+--*/\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbVirtualHcAsyncIsochronousTransfer (\r
+ IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,\r
+ IN UINT8 DeviceAddress,\r
+ IN UINT8 EndPointAddress,\r
+ IN UINT8 DeviceSpeed,\r
+ IN UINTN MaximumPacketLength,\r
+ IN UINT8 DataBuffersNumber,\r
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
+ IN UINTN DataLength,\r
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ \r
+ Vitual interface to submits Async isochronous transfer to a target USB device\r
+ for both Hc2 and Hc protocol.\r
+ \r
+ Arguments:\r
+ \r
+ UsbBusDev - A pointer to bus controller of the device.\r
+ DeviceAddress - Represents the address of the target device on the USB,\r
+ which is assigned during USB enumeration.\r
+ EndPointAddress - End point address\r
+ DeviceSpeed - Indicates device speed.\r
+ MaximumPacketLength - Indicates the maximum packet size that the \r
+ default control transfer endpoint is capable of \r
+ sending or receiving.\r
+ DataBuffersNumber - Number of data buffers prepared for the transfer.\r
+ Data - Array of pointers to the buffers of data that will be transmitted \r
+ to USB device or received from USB device.\r
+ DataLength - Indicates the size, in bytes, of the data buffer \r
+ specified by Data.\r
+ Translator - A pointr to the transaction translator data.\r
+ IsochronousCallBack - When the transfer complete, the call back function will be called\r
+ Context - Pass to the call back function as parameter\r
+ \r
+ Returns:\r
+ \r
+ EFI_UNSUPPORTED \r
+\r
+--*/\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r