diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/ComponentName.c b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/ComponentName.c index 2c8b0b23..88232f4f 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/ComponentName.c +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/ComponentName.c @@ -1,6 +1,7 @@ /** @file UEFI Component Name and Name2 protocol for OHCI driver. +Copyright (c) 2025, Mario Bălănică Copyright (c) 2013-2015 Intel Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -166,9 +167,9 @@ OhciComponentNameGetControllerName ( OUT CHAR16 **ControllerName ) { - EFI_STATUS Status; - USB_OHCI_HC_DEV *OhciDev; - EFI_USB_HC_PROTOCOL *UsbHc; + EFI_STATUS Status; + USB_OHCI_HC_DEV *OhciDev; + EFI_USB2_HC_PROTOCOL *Usb2Hc; // // This is a device driver, so ChildHandle must be NULL. @@ -194,8 +195,8 @@ OhciComponentNameGetControllerName ( // Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiUsbHcProtocolGuid, - (VOID **)&UsbHc, + &gEfiUsb2HcProtocolGuid, + (VOID **)&Usb2Hc, gOhciDriverBinding.DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -204,7 +205,7 @@ OhciComponentNameGetControllerName ( return Status; } - OhciDev = USB_OHCI_HC_DEV_FROM_THIS (UsbHc); + OhciDev = USB_OHCI_HC_DEV_FROM_THIS (Usb2Hc); return LookupUnicodeString2 ( Language, diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.c b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.c index db6ff4cb..b350f813 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.c +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.c @@ -1,6 +1,7 @@ /** @file This file contains the implementation of Usb Hc Protocol. +Copyright (c) 2025, Mario Bălănică Copyright (c) 2013-2016 Intel Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -9,24 +10,76 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Ohci.h" +/** + Retrieves the Host Controller capabilities. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param MaxSpeed Host controller data transfer speed. + @param PortNumber Number of the root hub ports. + @param Is64BitCapable TRUE if controller supports 64-bit memory addressing, + FALSE otherwise. + + @retval EFI_SUCCESS The host controller capabilities were retrieved successfully. + @retval EFI_INVALID_PARAMETER One of the input args was NULL. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to + retrieve the capabilities. + +**/ +EFI_STATUS +EFIAPI +OhciGetCapability ( + IN EFI_USB2_HC_PROTOCOL *This, + OUT UINT8 *MaxSpeed, + OUT UINT8 *PortNumber, + OUT UINT8 *Is64BitCapable + ) +{ + USB_OHCI_HC_DEV *Ohc; + + Ohc = USB_OHCI_HC_DEV_FROM_THIS (This); + + if ((MaxSpeed == NULL) && (PortNumber == NULL) && (Is64BitCapable == NULL)) { + return EFI_INVALID_PARAMETER; + } + + if (MaxSpeed != NULL) { + *MaxSpeed = EFI_USB_SPEED_FULL; + } + + if (PortNumber != NULL) { + *PortNumber = (UINT8)OhciGetRootHubDescriptor (Ohc, RH_NUM_DS_PORTS); + } + + if (Is64BitCapable != NULL) { + *Is64BitCapable = FALSE; + } + + return EFI_SUCCESS; +} + /** Provides software reset for the USB host controller. - @param This This EFI_USB_HC_PROTOCOL instance. - @param Attributes A bit mask of the reset operation to perform. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param Attributes A bit mask of the reset operation to perform. @retval EFI_SUCCESS The reset operation succeeded. @retval EFI_INVALID_PARAMETER Attributes is not valid. - @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is - not currently supported by the host controller. - @retval EFI_DEVICE_ERROR Host controller isn't halted to reset. + @retval EFI_UNSUPPORTED The type of reset specified by Attributes is not currently + supported by the host controller hardware. + @retval EFI_ACCESS_DENIED Reset operation is rejected due to the debug port being configured + and active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or + EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Attributes can be used to + perform reset operation for this host controller. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to + retrieve the capabilities. **/ EFI_STATUS EFIAPI OhciReset ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT16 Attributes + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT16 Attributes ) { EFI_STATUS Status; @@ -103,7 +156,7 @@ OhciReset ( OhciSetRootHubDescriptor (Ohc, RH_PORT_PWR_CTRL_MASK, 0xffff); OhciSetRootHubStatus (Ohc, RH_LOCAL_PSTAT_CHANGE); OhciSetRootHubPortStatus (Ohc, 0, RH_SET_PORT_POWER); - OhciGetRootHubNumOfPorts (This, &NumOfPorts); + OhciGetCapability (This, NULL, &NumOfPorts, NULL); for (Index = 0; Index < NumOfPorts; Index++) { if (!EFI_ERROR (OhciSetRootHubPortFeature (This, Index, EfiUsbPortReset))) { gBS->Stall (200 * 1000); @@ -133,23 +186,23 @@ OhciReset ( } /** - Retrieve the current state of the USB host controller. + Retrieves current state of the USB host controller. - @param This This EFI_USB_HC_PROTOCOL instance. - @param State Variable to return the current host controller - state. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param State A pointer to the EFI_USB_HC_STATE data structure that + indicates current state of the USB host controller. - @retval EFI_SUCCESS Host controller state was returned in State. + @retval EFI_SUCCESS The state information of the host controller was returned in State. @retval EFI_INVALID_PARAMETER State is NULL. - @retval EFI_DEVICE_ERROR An error was encountered while attempting to - retrieve the host controller's current state. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the + host controller's current state. **/ EFI_STATUS EFIAPI OhciGetState ( - IN EFI_USB_HC_PROTOCOL *This, - OUT EFI_USB_HC_STATE *State + IN EFI_USB2_HC_PROTOCOL *This, + OUT EFI_USB_HC_STATE *State ) { USB_OHCI_HC_DEV *Ohc; @@ -187,20 +240,20 @@ OhciGetState ( /** Sets the USB host controller to a specific state. - @param This This EFI_USB_HC_PROTOCOL instance. - @param State The state of the host controller that will be set. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param State Indicates the state of the host controller that will be set. - @retval EFI_SUCCESS The USB host controller was successfully placed - in the state specified by State. - @retval EFI_INVALID_PARAMETER State is invalid. - @retval EFI_DEVICE_ERROR Failed to set the state due to device error. + @retval EFI_SUCCESS The USB host controller was successfully placed in the state + specified by State. + @retval EFI_INVALID_PARAMETER State is not valid. + @retval EFI_DEVICE_ERROR Failed to set the state specified by State due to device error. **/ EFI_STATUS EFIAPI OhciSetState ( - IN EFI_USB_HC_PROTOCOL *This, - IN EFI_USB_HC_STATE State + IN EFI_USB2_HC_PROTOCOL *This, + IN EFI_USB_HC_STATE State ) { EFI_STATUS Status; @@ -231,52 +284,48 @@ OhciSetState ( } /** - Submits control transfer to a target USB device. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxPaketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of - sending or receiving. - @param Request A pointer to the USB device request that will be sent - to the USB device. - @param TransferDirection Specifies the data direction for the transfer. - There are three values available, DataIn, DataOut - and NoData. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength Indicates the size, in bytes, of the data buffer - specified by Data. - @param TimeOut Indicates the maximum time, in microseconds, - which the transfer is allowed to complete. - @param TransferResult A pointer to the detailed result information generated - by this control transfer. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size that the default control transfer + endpoint is capable of sending or receiving. + @param Request A pointer to the USB device request that will be sent to the USB device. + @param TransferDirection Specifies the data direction for the transfer. There are three values + available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData. + @param Data A pointer to the buffer of data that will be transmitted to USB device or + received from USB device. + @param DataLength On input, indicates the size, in bytes, of the data buffer specified by Data. + On output, indicates the amount of data actually transferred. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information generated by this control + transfer. @retval EFI_SUCCESS The control transfer was completed successfully. - @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. @retval EFI_TIMEOUT The control transfer failed due to timeout. @retval EFI_DEVICE_ERROR The control transfer failed due to host controller or device error. - Caller should check TranferResult for detailed error information. + Caller should check TransferResult for detailed error information. ---*/ +**/ EFI_STATUS EFIAPI OhciControlTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN EFI_USB_DEVICE_REQUEST *Request, - IN EFI_USB_DATA_DIRECTION TransferDirection, - IN OUT VOID *Data OPTIONAL, - IN OUT UINTN *DataLength OPTIONAL, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN EFI_USB_DEVICE_REQUEST *Request, + IN EFI_USB_DATA_DIRECTION TransferDirection, + IN OUT VOID *Data OPTIONAL, + IN OUT UINTN *DataLength OPTIONAL, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ) { USB_OHCI_HC_DEV *Ohc; @@ -292,6 +341,7 @@ OhciControlTransfer ( UINT32 StatusPidDir; UINTN TimeCount; OHCI_ED_RESULT EdResult; + BOOLEAN IsSlowDevice; DMA_MAP_OPERATION MapOp; @@ -310,14 +360,16 @@ OhciControlTransfer ( HeadTd = NULL; DataTd = NULL; + IsSlowDevice = (DeviceSpeed == EFI_USB_SPEED_LOW); + if (((TransferDirection != EfiUsbDataOut) && (TransferDirection != EfiUsbDataIn) && (TransferDirection != EfiUsbNoData)) || (Request == NULL) || (DataLength == NULL) || (TransferResult == NULL) || ((TransferDirection == EfiUsbNoData) && ((*DataLength != 0) || (Data != NULL))) || ((TransferDirection != EfiUsbNoData) && ((*DataLength == 0) || (Data == NULL))) || - (IsSlowDevice && (MaxPacketLength != 8)) || - ((MaxPacketLength != 8) && (MaxPacketLength != 16) && - (MaxPacketLength != 32) && (MaxPacketLength != 64))) + (IsSlowDevice && (MaximumPacketLength != 8)) || + ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) && + (MaximumPacketLength != 32) && (MaximumPacketLength != 64))) { return EFI_INVALID_PARAMETER; } @@ -367,7 +419,7 @@ OhciControlTransfer ( OhciSetEDField (Ed, ED_DIR, ED_FROM_TD_DIR); OhciSetEDField (Ed, ED_SPEED, IsSlowDevice); OhciSetEDField (Ed, ED_FORMAT | ED_HALTED | ED_DTTOGGLE, 0); - OhciSetEDField (Ed, ED_MAX_PACKET, MaxPacketLength); + OhciSetEDField (Ed, ED_MAX_PACKET, MaximumPacketLength); OhciSetEDField (Ed, ED_PDATA, 0); OhciSetEDField (Ed, ED_ZERO, 0); OhciSetEDField (Ed, ED_TDHEAD_PTR, 0); @@ -432,8 +484,8 @@ OhciControlTransfer ( DataToggle = 1; while (LeftLength > 0) { ActualSendLength = LeftLength; - if (LeftLength > MaxPacketLength) { - ActualSendLength = MaxPacketLength; + if (LeftLength > MaximumPacketLength) { + ActualSendLength = MaximumPacketLength; } DataTd = OhciCreateTD (Ohc); @@ -597,55 +649,49 @@ CTRL_EXIT: } /** - Submits bulk transfer to a bulk endpoint of a USB device. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an - endpoint direction of the target USB device. - Each endpoint address supports data transfer in - one direction except the control endpoint - (whose default endpoint address is 0). - It is the caller's responsibility to make sure that - the EndPointAddress represents a bulk endpoint. - @param MaximumPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength When input, indicates the size, in bytes, of the data buffer - specified by Data. When output, indicates the actually - transferred data size. - @param DataToggle A pointer to the data toggle value. On input, it indicates - the initial data toggle value the bulk transfer should adopt; - on output, it is updated to indicate the data toggle value - of the subsequent bulk transfer. - @param TimeOut Indicates the maximum time, in microseconds, which the - transfer is allowed to complete. - TransferResult A pointer to the detailed result information of the - bulk transfer. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength When input, indicates the size, in bytes, of the data buffers specified by + Data. When output, indicates the actually transferred data size. + @param DataToggle A pointer to the data toggle value. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information of the bulk transfer. @retval EFI_SUCCESS The bulk transfer was completed successfully. - @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to lack of resource. @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to a lack of resources. @retval EFI_TIMEOUT The bulk transfer failed due to timeout. @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error. - Caller should check TranferResult for detailed error information. + Caller should check TransferResult for detailed error information. **/ EFI_STATUS EFIAPI OhciBulkTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaxPacketLength, - IN OUT VOID *Data, - IN OUT UINTN *DataLength, - IN OUT UINT8 *DataToggle, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ) { USB_OHCI_HC_DEV *Ohc; @@ -659,6 +705,7 @@ OhciBulkTransfer ( UINT8 EndPointNum; UINTN TimeCount; OHCI_ED_RESULT EdResult; + VOID *TransferData; DMA_MAP_OPERATION MapOp; VOID *Mapping; @@ -676,12 +723,19 @@ OhciBulkTransfer ( if ((Data == NULL) || (DataLength == NULL) || (DataToggle == NULL) || (TransferResult == NULL) || (*DataLength == 0) || ((*DataToggle != 0) && (*DataToggle != 1)) || - ((MaxPacketLength != 8) && (MaxPacketLength != 16) && - (MaxPacketLength != 32) && (MaxPacketLength != 64))) + ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) && + (MaximumPacketLength != 32) && (MaximumPacketLength != 64))) { return EFI_INVALID_PARAMETER; } + // Full-speed transfers only use the first data buffer. + TransferData = Data[0]; + + if (TransferData == NULL) { + return EFI_INVALID_PARAMETER; + } + Ohc = USB_OHCI_HC_DEV_FROM_THIS (This); if ((EndPointAddress & 0x80) != 0) { @@ -724,7 +778,7 @@ OhciBulkTransfer ( OhciSetEDField (Ed, ED_DIR, ED_FROM_TD_DIR); OhciSetEDField (Ed, ED_SPEED, HI_SPEED); OhciSetEDField (Ed, ED_FORMAT | ED_HALTED | ED_DTTOGGLE, 0); - OhciSetEDField (Ed, ED_MAX_PACKET, MaxPacketLength); + OhciSetEDField (Ed, ED_MAX_PACKET, MaximumPacketLength); OhciSetEDField (Ed, ED_PDATA, 0); OhciSetEDField (Ed, ED_ZERO, 0); OhciSetEDField (Ed, ED_TDHEAD_PTR, 0); @@ -734,7 +788,7 @@ OhciBulkTransfer ( if (Data != NULL) { MapLength = *DataLength; - Status = DmaMap (MapOp, (UINT8 *)Data, &MapLength, &MapPyhAddr, &Mapping); + Status = DmaMap (MapOp, TransferData, &MapLength, &MapPyhAddr, &Mapping); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "OhciBulkTransfer: Fail to Map Data Buffer for Bulk\r\n")); goto FREE_ED_BUFF; @@ -750,8 +804,8 @@ OhciBulkTransfer ( FirstTD = TRUE; while (LeftLength > 0) { ActualSendLength = LeftLength; - if (LeftLength > MaxPacketLength) { - ActualSendLength = MaxPacketLength; + if (LeftLength > MaximumPacketLength) { + ActualSendLength = MaximumPacketLength; } DataTd = OhciCreateTD (Ohc); @@ -897,7 +951,7 @@ FREE_ED_BUFF: the EndPointAddress represents an interrupt endpoint. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. - @param MaxPacketLength Indicates the maximum packet size the target endpoint + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the target interrupt endpoint. @@ -940,7 +994,7 @@ OhciInterruptTransfer ( IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, + IN UINT8 MaximumPacketLength, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle OPTIONAL, IN UINTN PollingInterval OPTIONAL, @@ -1038,7 +1092,7 @@ OhciInterruptTransfer ( OhciSetEDField (Ed, ED_DIR, ED_FROM_TD_DIR); OhciSetEDField (Ed, ED_SPEED, IsSlowDevice); OhciSetEDField (Ed, ED_FORMAT, 0); - OhciSetEDField (Ed, ED_MAX_PACKET, MaxPacketLength); + OhciSetEDField (Ed, ED_MAX_PACKET, MaximumPacketLength); OhciSetEDField (Ed, ED_PDATA | ED_ZERO | ED_HALTED | ED_DTTOGGLE, 0); OhciSetEDField (Ed, ED_TDHEAD_PTR, 0); OhciSetEDField (Ed, ED_TDTAIL_PTR, 0); @@ -1055,8 +1109,8 @@ OhciInterruptTransfer ( FirstTD = TRUE; while (LeftLength > 0) { ActualSendLength = LeftLength; - if (LeftLength > MaxPacketLength) { - ActualSendLength = MaxPacketLength; + if (LeftLength > MaximumPacketLength) { + ActualSendLength = MaximumPacketLength; } DataTd = OhciCreateTD (Ohc); @@ -1130,21 +1184,21 @@ OhciInterruptTransfer ( goto FREE_OHCI_TDBUFF; } - Entry->DeviceAddress = DeviceAddress; - Entry->EndPointAddress = EndPointAddress; - Entry->Ed = Ed; - Entry->DataTd = HeadTd; - Entry->IsSlowDevice = IsSlowDevice; - Entry->MaxPacketLength = MaxPacketLength; - Entry->PollingInterval = PollingInterval; - Entry->CallBackFunction = CallBackFunction; - Entry->Context = Context; - Entry->IsPeriodic = IsPeriodic; - Entry->UCBuffer = UCBuffer; - Entry->UCBufferMapping = Mapping; - Entry->DataLength = DataLength; - Entry->Toggle = DataToggle; - Entry->NextEntry = NULL; + Entry->DeviceAddress = DeviceAddress; + Entry->EndPointAddress = EndPointAddress; + Entry->Ed = Ed; + Entry->DataTd = HeadTd; + Entry->IsSlowDevice = IsSlowDevice; + Entry->MaximumPacketLength = MaximumPacketLength; + Entry->PollingInterval = PollingInterval; + Entry->CallBackFunction = CallBackFunction; + Entry->Context = Context; + Entry->IsPeriodic = IsPeriodic; + Entry->UCBuffer = UCBuffer; + Entry->UCBufferMapping = Mapping; + Entry->DataLength = DataLength; + Entry->Toggle = DataToggle; + Entry->NextEntry = NULL; OhciAddInterruptContextEntry (Ohc, Entry); } @@ -1182,45 +1236,30 @@ EXIT: } /** - Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device. + Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an endpoint - direction of the target USB device. Each endpoint address - supports data transfer in one direction except the - control endpoint (whose default endpoint address is 0). - It is the caller's responsibility to make sure that - the EndPointAddress represents an interrupt endpoint. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxiumPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between - the host and the target interrupt endpoint. - If FALSE, the specified asynchronous interrupt pipe - is canceled. - @param DataToggle A pointer to the data toggle value. On input, it is valid - when IsNewTransfer is TRUE, and it indicates the initial - data toggle value the asynchronous interrupt transfer - should adopt. - On output, it is valid when IsNewTransfer is FALSE, - and it is updated to indicate the data toggle value of - the subsequent asynchronous interrupt transfer. - @param PollingInterval Indicates the interval, in milliseconds, that the - asynchronous interrupt transfer is polled. - This parameter is required when IsNewTransfer is TRUE. - @param DataLength Indicates the length of data to be received at the - rate specified by PollingInterval from the target - asynchronous interrupt endpoint. This parameter - is only required when IsNewTransfer is TRUE. - @param CallBackFunction The Callback function.This function is called at the - rate specified by PollingInterval.This parameter is - only required when IsNewTransfer is TRUE. - @param Context The context that is passed to the CallBackFunction. - This is an optional parameter and may be NULL. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the + target interrupt endpoint. If FALSE, the specified asynchronous interrupt + pipe is canceled. If TRUE, and an interrupt transfer exists for the target + end point, then EFI_INVALID_PARAMETER is returned. + @param DataToggle A pointer to the data toggle value. + @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous interrupt + transfer is polled. + @param DataLength Indicates the length of data to be received at the rate specified by + PollingInterval from the target asynchronous interrupt endpoint. + @param Translator A pointr to the transaction translator data. + @param CallBackFunction The Callback function. This function is called at the rate specified by + PollingInterval. + @param Context The context that is passed to the CallBackFunction. This is an + optional parameter and may be NULL. @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully submitted or canceled. @@ -1231,23 +1270,25 @@ EXIT: EFI_STATUS EFIAPI OhciAsyncInterruptTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN BOOLEAN IsNewTransfer, - IN OUT UINT8 *DataToggle OPTIONAL, - IN UINTN PollingInterval OPTIONAL, - IN UINTN DataLength OPTIONAL, - IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, - IN VOID *Context OPTIONAL + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN BOOLEAN IsNewTransfer, + IN OUT UINT8 *DataToggle, + IN UINTN PollingInterval OPTIONAL, + IN UINTN DataLength OPTIONAL, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator OPTIONAL, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, + IN VOID *Context OPTIONAL ) { EFI_STATUS Status; USB_OHCI_HC_DEV *Ohc; VOID *UCBuffer; UINTN Pages; + BOOLEAN IsSlowDevice; if ((DataToggle == NULL) || ((EndPointAddress & 0x80) == 0) || (IsNewTransfer && ((DataLength == 0) || @@ -1258,6 +1299,8 @@ OhciAsyncInterruptTransfer ( Ohc = USB_OHCI_HC_DEV_FROM_THIS (This); + IsSlowDevice = (DeviceSpeed == EFI_USB_SPEED_LOW); + if ( IsNewTransfer ) { Pages = EFI_SIZE_TO_PAGES (DataLength); Status = DmaAllocateBuffer ( @@ -1277,7 +1320,7 @@ OhciAsyncInterruptTransfer ( DeviceAddress, EndPointAddress, IsSlowDevice, - MaxPacketLength, + MaximumPacketLength, IsNewTransfer, DataToggle, PollingInterval, @@ -1300,55 +1343,49 @@ OhciAsyncInterruptTransfer ( } /** + Submits synchronous interrupt transfer to an interrupt endpoint of a USB device. + Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version. - Submits synchronous interrupt transfer to an interrupt endpoint - of a USB device. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param Data A pointer to the buffer of data that will be transmitted to USB device or + received from USB device. + @param DataLength On input, the size, in bytes, of the data buffer specified by Data. On + output, the number of bytes transferred. + @param DataToggle A pointer to the data toggle value. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointr to the transaction translator data. + @param TransferResult A pointer to the detailed result information from the synchronous + interrupt transfer. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an endpoint - direction of the target USB device. Each endpoint - address supports data transfer in one direction - except the control endpoint (whose default - endpoint address is 0). It is the caller's responsibility - to make sure that the EndPointAddress represents - an interrupt endpoint. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength On input, the size, in bytes, of the data buffer specified - by Data. On output, the number of bytes transferred. - @param DataToggle A pointer to the data toggle value. On input, it indicates - the initial data toggle value the synchronous interrupt - transfer should adopt; - on output, it is updated to indicate the data toggle value - of the subsequent synchronous interrupt transfer. - @param TimeOut Indicates the maximum time, in microseconds, which the - transfer is allowed to complete. - @param TransferResult A pointer to the detailed result information from - the synchronous interrupt transfer. - - @retval EFI_UNSUPPORTED This interface not available. - @retval EFI_INVALID_PARAMETER Parameters not follow spec + @retval EFI_SUCCESS The synchronous interrupt transfer was completed successfully. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The synchronous interrupt transfer could not be submitted due to a lack of resources. + @retval EFI_TIMEOUT The synchronous interrupt transfer failed due to timeout. + @retval EFI_DEVICE_ERROR The synchronous interrupt transfer failed due to host controller or device error. + Caller should check TransferResult for detailed error information. **/ EFI_STATUS EFIAPI OhciSyncInterruptTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN OUT VOID *Data, - IN OUT UINTN *DataLength, - IN OUT UINT8 *DataToggle, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ) { USB_OHCI_HC_DEV *Ohc; @@ -1357,9 +1394,12 @@ OhciSyncInterruptTransfer ( TD_DESCRIPTOR *HeadTd; OHCI_ED_RESULT EdResult; VOID *UCBuffer; + BOOLEAN IsSlowDevice; + + IsSlowDevice = (DeviceSpeed == EFI_USB_SPEED_LOW); if (((EndPointAddress & 0x80) == 0) || (Data == NULL) || (DataLength == NULL) || (*DataLength == 0) || - (IsSlowDevice && (MaxPacketLength > 8)) || (!IsSlowDevice && (MaxPacketLength > 64)) || + (IsSlowDevice && (MaximumPacketLength > 8)) || (!IsSlowDevice && (MaximumPacketLength > 64)) || (DataToggle == NULL) || ((*DataToggle != 0) && (*DataToggle != 1)) || (TransferResult == NULL)) { return EFI_INVALID_PARAMETER; @@ -1376,7 +1416,7 @@ OhciSyncInterruptTransfer ( DeviceAddress, EndPointAddress, IsSlowDevice, - MaxPacketLength, + MaximumPacketLength, TRUE, DataToggle, 1, @@ -1406,7 +1446,7 @@ OhciSyncInterruptTransfer ( DeviceAddress, EndPointAddress, IsSlowDevice, - MaxPacketLength, + MaximumPacketLength, FALSE, DataToggle, 0, @@ -1423,37 +1463,75 @@ OhciSyncInterruptTransfer ( } /** + Submits isochronous transfer to an isochronous endpoint of a USB device. - Submits isochronous transfer to a target USB device. + This function is used to submit isochronous transfer to a target endpoint of a USB device. + The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers are + used when working with isochronous date. It provides periodic, continuous communication between + the host and a device. Isochronous transfers can beused only by full-speed, high-speed, and + super-speed devices. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress End point address - @param MaximumPacketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of + High-speed isochronous transfers can be performed using multiple data buffers. The number of + buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For + full-speed isochronous transfers this value is ignored. + + Data represents a list of pointers to the data buffers. For full-speed isochronous transfers + only the data pointed by Data[0]shall be used. For high-speed isochronous transfers and for + the split transactions depending on DataLengththere several data buffers canbe used. For the + high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM. + + For split transactions performed on full-speed device by high-speed host controller the total + number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1. + If the isochronous transfer is successful, then EFI_SUCCESSis returned. The isochronous transfer + is designed to be completed within one USB frame time, if it cannot be completed, EFI_TIMEOUT + is returned. If an error other than timeout occurs during the USB transfer, then EFI_DEVICE_ERROR + is returned and the detailed status code will be returned in TransferResult. + + EFI_INVALID_PARAMETERis returned if one of the following conditionsis satisfied: + - Data is NULL. + - DataLength is 0. + - DeviceSpeed is not one of the supported values listed above. + - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed devices, + and 1024 or less for high-speed and super-speed devices. + - TransferResult is NULL. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. The supported values are EFI_USB_SPEED_FULL, + EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength Indicates the size, in bytes, of the data buffer - specified by Data. - @param TransferResult A pointer to the detailed result information generated - by this control transfer. + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength Specifies the length, in bytes, of the data to be sent to or received from + the USB device. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information of the isochronous transfer. - @retval EFI_UNSUPPORTED This interface not available - @retval EFI_INVALID_PARAMETER Data is NULL or DataLength is 0 or TransferResult is NULL + @retval EFI_SUCCESS The isochronous transfer was completed successfully. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The isochronous transfer could not be submitted due to a lack of resources. + @retval EFI_TIMEOUT The isochronous transfer cannot be completed within the one USB frame time. + @retval EFI_DEVICE_ERROR The isochronous transfer failed due to host controller or device error. + Caller should check TransferResult for detailed error information. **/ EFI_STATUS EFIAPI OhciIsochronousTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaximumPacketLength, - IN OUT VOID *Data, - IN OUT UINTN DataLength, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ) { if ((Data == NULL) || (DataLength == 0) || (TransferResult == NULL)) { @@ -1464,36 +1542,79 @@ OhciIsochronousTransfer ( } /** + Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device. - Submits Async isochronous transfer to a target USB device. + This is an asynchronous type of USB isochronous transfer. If the caller submits a USB + isochronous transfer request through this function, this function will return immediately. - @param his A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress End point address - @param MaximumPacketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of + When the isochronous transfer completes, the IsochronousCallbackfunction will be triggered, + the caller can know the transfer results. If the transfer is successful, the caller can get + the data received or sent in this callback function. + + The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers + are used when working with isochronous date. It provides periodic, continuous communication + between the host and a device. Isochronous transfers can be used only by full-speed, high-speed, + and super-speed devices. + + High-speed isochronous transfers can be performed using multiple data buffers. The number of + buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For + full-speed isochronous transfers this value is ignored. + + Data represents a list of pointers to the data buffers. For full-speed isochronous transfers + only the data pointed by Data[0] shall be used. For high-speed isochronous transfers and for + the split transactions depending on DataLength there several data buffers can be used. For + the high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM. + + For split transactions performed on full-speed device by high-speed host controller the total + number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1. + + EFI_INVALID_PARAMETER is returned if one of the following conditionsis satisfied: + - Data is NULL. + - DataLength is 0. + - DeviceSpeed is not one of the supported values listed above. + - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed + devices and 1024 or less for high-speed and super-speed devices. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. The supported values are EFI_USB_SPEED_FULL, + EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param IsochronousCallBack When the transfer complete, the call back function will be called - @param Context Pass to the call back function as parameter + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength Specifies the length, in bytes, of the data to be sent to or received from + the USB device. + @param Translator A pointer to the transaction translator data. + @param IsochronousCallback The Callback function. This function is called if the requested + isochronous transfer is completed. + @param Context Data passed to the IsochronousCallback function. This is an + optional parameter and may be NULL. - @retval EFI_UNSUPPORTED This interface not available - @retval EFI_INVALID_PARAMETER Data is NULL or Datalength is 0 + @retval EFI_SUCCESS The asynchronous isochronous transfer request has been successfully + submitted or canceled. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The asynchronous isochronous transfer could not be submitted due to + a lack of resources. **/ EFI_STATUS EFIAPI OhciAsyncIsochronousTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaximumPacketLength, - IN OUT VOID *Data, - IN OUT UINTN DataLength, - IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, - IN VOID *Context OPTIONAL + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, + IN VOID *Context OPTIONAL ) { if ((Data == NULL) || (DataLength == 0)) { @@ -1504,56 +1625,24 @@ OhciAsyncIsochronousTransfer ( } /** - - Retrieves the number of root hub ports. - - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param NumOfPorts A pointer to the number of the root hub ports. - - @retval EFI_SUCCESS The port number was retrieved successfully. -**/ -EFI_STATUS -EFIAPI -OhciGetRootHubNumOfPorts ( - IN EFI_USB_HC_PROTOCOL *This, - OUT UINT8 *NumOfPorts - ) -{ - USB_OHCI_HC_DEV *Ohc; - - Ohc = USB_OHCI_HC_DEV_FROM_THIS (This); - - if (NumOfPorts == NULL) { - return EFI_INVALID_PARAMETER; - } - - *NumOfPorts = (UINT8)OhciGetRootHubDescriptor (Ohc, RH_NUM_DS_PORTS); - - return EFI_SUCCESS; -} - -/** - Retrieves the current status of a USB root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL. - @param PortNumber Specifies the root hub port from which the status - is to be retrieved. This value is zero-based. For example, - if a root hub has two ports, then the first port is numbered 0, - and the second port is numbered 1. - @param PortStatus A pointer to the current port status bits and - port status change bits. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port from which the status is to be retrieved. + This value is zero based. + @param PortStatus A pointer to the current port status bits and port status change bits. @retval EFI_SUCCESS The status of the USB root hub port specified by PortNumber was returned in PortStatus. - @retval EFI_INVALID_PARAMETER Port number not valid + @retval EFI_INVALID_PARAMETER PortNumber is invalid. + **/ EFI_STATUS EFIAPI OhciGetRootHubPortStatus ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 PortNumber, - OUT EFI_USB_PORT_STATUS *PortStatus + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 PortNumber, + OUT EFI_USB_PORT_STATUS *PortStatus ) { USB_OHCI_HC_DEV *Ohc; @@ -1561,7 +1650,7 @@ OhciGetRootHubPortStatus ( Ohc = USB_OHCI_HC_DEV_FROM_THIS (This); - OhciGetRootHubNumOfPorts (This, &NumOfPorts); + OhciGetCapability (This, NULL, &NumOfPorts, NULL); if (PortNumber >= NumOfPorts) { return EFI_INVALID_PARAMETER; } @@ -1621,24 +1710,22 @@ OhciGetRootHubPortStatus ( } /** - Sets a feature for the specified root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL. - @param PortNumber Specifies the root hub port whose feature - is requested to be set. - @param PortFeature Indicates the feature selector associated - with the feature set request. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port whose feature is requested to be set. This + value is zero based. + @param PortFeature Indicates the feature selector associated with the feature set request. + + @retval EFI_SUCCESS The feature specified by PortFeature was set for the USB + root hub port specified by PortNumber. + @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. - @retval EFI_SUCCESS The feature specified by PortFeature was set for the - USB root hub port specified by PortNumber. - @retval EFI_DEVICE_ERROR Set feature failed because of hardware issue - @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. **/ EFI_STATUS EFIAPI OhciSetRootHubPortFeature ( - IN EFI_USB_HC_PROTOCOL *This, + IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ) @@ -1648,7 +1735,7 @@ OhciSetRootHubPortFeature ( UINT8 NumOfPorts; UINTN RetryTimes; - OhciGetRootHubNumOfPorts (This, &NumOfPorts); + OhciGetCapability (This, NULL, &NumOfPorts, NULL); if (PortNumber >= NumOfPorts) { return EFI_INVALID_PARAMETER; } @@ -1744,24 +1831,22 @@ OhciSetRootHubPortFeature ( } /** - Clears a feature for the specified root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param PortNumber Specifies the root hub port whose feature - is requested to be cleared. - @param PortFeature Indicates the feature selector associated with the - feature clear request. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port whose feature is requested to be cleared. This + value is zero based. + @param PortFeature Indicates the feature selector associated with the feature clear request. + + @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the USB + root hub port specified by PortNumber. + @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. - @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the - USB root hub port specified by PortNumber. - @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. - @retval EFI_DEVICE_ERROR Some error happened when clearing feature **/ EFI_STATUS EFIAPI OhciClearRootHubPortFeature ( - IN EFI_USB_HC_PROTOCOL *This, + IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ) @@ -1771,7 +1856,7 @@ OhciClearRootHubPortFeature ( UINT8 NumOfPorts; UINTN RetryTimes; - OhciGetRootHubNumOfPorts (This, &NumOfPorts); + OhciGetCapability (This, NULL, &NumOfPorts, NULL); if (PortNumber >= NumOfPorts) { return EFI_INVALID_PARAMETER; } @@ -2002,14 +2087,14 @@ OhcInitHC ( OhciSetRootHubDescriptor (Ohc, RH_PORT_PWR_CTRL_MASK, 0xffff); OhciSetRootHubStatus (Ohc, RH_LOCAL_PSTAT_CHANGE); OhciSetRootHubPortStatus (Ohc, 0, RH_SET_PORT_POWER); - NumOfPorts = OhciGetRootHubDescriptor (Ohc, RH_NUM_DS_PORTS); + OhciGetCapability (&Ohc->Usb2Hc, NULL, &NumOfPorts, NULL); for (Index = 0; Index < NumOfPorts; Index++) { - if (!EFI_ERROR (OhciSetRootHubPortFeature (&Ohc->UsbHc, Index, EfiUsbPortReset))) { + if (!EFI_ERROR (OhciSetRootHubPortFeature (&Ohc->Usb2Hc, Index, EfiUsbPortReset))) { gBS->Stall (200 * 1000); - OhciClearRootHubPortFeature (&Ohc->UsbHc, Index, EfiUsbPortReset); + OhciClearRootHubPortFeature (&Ohc->Usb2Hc, Index, EfiUsbPortReset); gBS->Stall (1000); - OhciSetRootHubPortFeature (&Ohc->UsbHc, Index, EfiUsbPortEnable); + OhciSetRootHubPortFeature (&Ohc->Usb2Hc, Index, EfiUsbPortEnable); gBS->Stall (1000); } } @@ -2079,8 +2164,8 @@ OhciFreeDev ( **/ VOID OhciCleanDevUp ( - IN EFI_HANDLE Controller, - IN EFI_USB_HC_PROTOCOL *This + IN EFI_HANDLE Controller, + IN EFI_USB2_HC_PROTOCOL *This ) { USB_OHCI_HC_DEV *Ohc; @@ -2095,8 +2180,8 @@ OhciCleanDevUp ( // gBS->UninstallProtocolInterface ( Controller, - &gEfiUsbHcProtocolGuid, - &Ohc->UsbHc + &gEfiUsb2HcProtocolGuid, + &Ohc->Usb2Hc ); // @@ -2136,19 +2221,19 @@ OhcExitBootService ( VOID *Context ) { - USB_OHCI_HC_DEV *Ohc; - EFI_USB_HC_PROTOCOL *UsbHc; + USB_OHCI_HC_DEV *Ohc; + EFI_USB2_HC_PROTOCOL *Usb2Hc; Ohc = (USB_OHCI_HC_DEV *)Context; - UsbHc = &Ohc->UsbHc; + Usb2Hc = &Ohc->Usb2Hc; // // Stop the Host Controller // // OhciStopHc (Ohc, OHC_GENERIC_TIMEOUT); OhciSetHcControl (Ohc, PERIODIC_ENABLE | CONTROL_ENABLE | ISOCHRONOUS_ENABLE | BULK_ENABLE, 0); - UsbHc->Reset (UsbHc, EFI_USB_HC_RESET_GLOBAL); - UsbHc->SetState (UsbHc, EfiUsbHcStateHalt); + Usb2Hc->Reset (Usb2Hc, EFI_USB_HC_RESET_GLOBAL); + Usb2Hc->SetState (Usb2Hc, EfiUsbHcStateHalt); return; } @@ -2254,29 +2339,30 @@ OHCIDriverBindingStart ( Ohc->Signature = USB_OHCI_HC_DEV_SIGNATURE; - Ohc->UsbHc.Reset = OhciReset; - Ohc->UsbHc.GetState = OhciGetState; - Ohc->UsbHc.SetState = OhciSetState; - Ohc->UsbHc.ControlTransfer = OhciControlTransfer; - Ohc->UsbHc.BulkTransfer = OhciBulkTransfer; - Ohc->UsbHc.AsyncInterruptTransfer = OhciAsyncInterruptTransfer; - Ohc->UsbHc.SyncInterruptTransfer = OhciSyncInterruptTransfer; - Ohc->UsbHc.IsochronousTransfer = OhciIsochronousTransfer; - Ohc->UsbHc.AsyncIsochronousTransfer = OhciAsyncIsochronousTransfer; - Ohc->UsbHc.GetRootHubPortNumber = OhciGetRootHubNumOfPorts; - Ohc->UsbHc.GetRootHubPortStatus = OhciGetRootHubPortStatus; - Ohc->UsbHc.SetRootHubPortFeature = OhciSetRootHubPortFeature; - Ohc->UsbHc.ClearRootHubPortFeature = OhciClearRootHubPortFeature; - Ohc->UsbHc.MajorRevision = 0x1; - Ohc->UsbHc.MinorRevision = 0x1; - Ohc->UsbHcBaseAddress = Ohc->Protocol->BaseAddress; - Ohc->HccaMemoryBlock = NULL; - Ohc->HccaMemoryMapping = NULL; - Ohc->HccaMemoryBuf = NULL; - Ohc->HccaMemoryPages = 0; - Ohc->InterruptContextList = NULL; - Ohc->ControllerNameTable = NULL; - Ohc->HouseKeeperTimer = NULL; + Ohc->Usb2Hc.GetCapability = OhciGetCapability; + Ohc->Usb2Hc.Reset = OhciReset; + Ohc->Usb2Hc.GetState = OhciGetState; + Ohc->Usb2Hc.SetState = OhciSetState; + Ohc->Usb2Hc.ControlTransfer = OhciControlTransfer; + Ohc->Usb2Hc.BulkTransfer = OhciBulkTransfer; + Ohc->Usb2Hc.AsyncInterruptTransfer = OhciAsyncInterruptTransfer; + Ohc->Usb2Hc.SyncInterruptTransfer = OhciSyncInterruptTransfer; + Ohc->Usb2Hc.IsochronousTransfer = OhciIsochronousTransfer; + Ohc->Usb2Hc.AsyncIsochronousTransfer = OhciAsyncIsochronousTransfer; + Ohc->Usb2Hc.GetRootHubPortStatus = OhciGetRootHubPortStatus; + Ohc->Usb2Hc.SetRootHubPortFeature = OhciSetRootHubPortFeature; + Ohc->Usb2Hc.ClearRootHubPortFeature = OhciClearRootHubPortFeature; + Ohc->Usb2Hc.MajorRevision = 0x1; + Ohc->Usb2Hc.MinorRevision = 0x1; + + Ohc->UsbHcBaseAddress = Ohc->Protocol->BaseAddress; + Ohc->HccaMemoryBlock = NULL; + Ohc->HccaMemoryMapping = NULL; + Ohc->HccaMemoryBuf = NULL; + Ohc->HccaMemoryPages = 0; + Ohc->InterruptContextList = NULL; + Ohc->ControllerNameTable = NULL; + Ohc->HouseKeeperTimer = NULL; Ohc->MemPool = UsbHcInitMemPool (TRUE, 0); if (Ohc->MemPool == NULL) { @@ -2318,9 +2404,9 @@ OHCIDriverBindingStart ( // Status = gBS->InstallProtocolInterface ( &ControllerHandle, - &gEfiUsbHcProtocolGuid, + &gEfiUsb2HcProtocolGuid, EFI_NATIVE_INTERFACE, - &Ohc->UsbHc + &Ohc->Usb2Hc ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "Install protocol error")); @@ -2382,8 +2468,8 @@ FREE_OHC: UNINSTALL_USBHC: gBS->UninstallMultipleProtocolInterfaces ( ControllerHandle, - &gEfiUsbHcProtocolGuid, - &Ohc->UsbHc, + &gEfiUsb2HcProtocolGuid, + &Ohc->Usb2Hc, NULL ); gBS->CloseProtocol ( @@ -2424,13 +2510,13 @@ OHCIDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer ) { - EFI_STATUS Status; - EFI_USB_HC_PROTOCOL *UsbHc; + EFI_STATUS Status; + EFI_USB2_HC_PROTOCOL *Usb2Hc; Status = gBS->OpenProtocol ( Controller, - &gEfiUsbHcProtocolGuid, - (VOID **)&UsbHc, + &gEfiUsb2HcProtocolGuid, + (VOID **)&Usb2Hc, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -2439,7 +2525,7 @@ OHCIDriverBindingStop ( return Status; } - OhciCleanDevUp (Controller, UsbHc); + OhciCleanDevUp (Controller, Usb2Hc); gBS->CloseProtocol ( Controller, diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.h b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.h index c6740cea..c1d7f5c9 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.h +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/Ohci.h @@ -2,6 +2,7 @@ Provides the definition of Usb Hc Protocol and OHCI controller private data structure. +Copyright (c) 2025, Mario Bălănică Copyright (c) 2013-2016 Intel Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -13,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include -#include +#include #include #include @@ -62,7 +63,6 @@ typedef struct { struct _USB_OHCI_HC_DEV { UINTN Signature; - EFI_USB_HC_PROTOCOL UsbHc; EFI_USB2_HC_PROTOCOL Usb2Hc; UINT32 UsbHcBaseAddress; HCCA_MEMORY_BLOCK *HccaMemoryBlock; @@ -87,174 +87,189 @@ struct _USB_OHCI_HC_DEV { OHCI_DEVICE_PROTOCOL *Protocol; }; -#define USB_OHCI_HC_DEV_FROM_THIS(a) CR(a, USB_OHCI_HC_DEV, UsbHc, USB_OHCI_HC_DEV_SIGNATURE) +#define USB_OHCI_HC_DEV_FROM_THIS(a) CR(a, USB_OHCI_HC_DEV, Usb2Hc, USB_OHCI_HC_DEV_SIGNATURE) // // Func List // +/** + Retrieves the Host Controller capabilities. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param MaxSpeed Host controller data transfer speed. + @param PortNumber Number of the root hub ports. + @param Is64BitCapable TRUE if controller supports 64-bit memory addressing, + FALSE otherwise. + + @retval EFI_SUCCESS The host controller capabilities were retrieved successfully. + @retval EFI_INVALID_PARAMETER One of the input args was NULL. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to + retrieve the capabilities. + +**/ +EFI_STATUS +EFIAPI +OhciGetCapability ( + IN EFI_USB2_HC_PROTOCOL *This, + OUT UINT8 *MaxSpeed, + OUT UINT8 *PortNumber, + OUT UINT8 *Is64BitCapable + ); + /** Provides software reset for the USB host controller. - @param This This EFI_USB_HC_PROTOCOL instance. - @param Attributes A bit mask of the reset operation to perform. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param Attributes A bit mask of the reset operation to perform. @retval EFI_SUCCESS The reset operation succeeded. @retval EFI_INVALID_PARAMETER Attributes is not valid. - @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is - not currently supported by the host controller. - @retval EFI_DEVICE_ERROR Host controller isn't halted to reset. + @retval EFI_UNSUPPORTED The type of reset specified by Attributes is not currently + supported by the host controller hardware. + @retval EFI_ACCESS_DENIED Reset operation is rejected due to the debug port being configured + and active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or + EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Attributes can be used to + perform reset operation for this host controller. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to + retrieve the capabilities. **/ EFI_STATUS EFIAPI OhciReset ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT16 Attributes + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT16 Attributes ); /** - Retrieve the current state of the USB host controller. + Retrieves current state of the USB host controller. - @param This This EFI_USB_HC_PROTOCOL instance. - @param State Variable to return the current host controller - state. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param State A pointer to the EFI_USB_HC_STATE data structure that + indicates current state of the USB host controller. - @retval EFI_SUCCESS Host controller state was returned in State. + @retval EFI_SUCCESS The state information of the host controller was returned in State. @retval EFI_INVALID_PARAMETER State is NULL. - @retval EFI_DEVICE_ERROR An error was encountered while attempting to - retrieve the host controller's current state. + @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the + host controller's current state. **/ - EFI_STATUS EFIAPI OhciGetState ( - IN EFI_USB_HC_PROTOCOL *This, - OUT EFI_USB_HC_STATE *State + IN EFI_USB2_HC_PROTOCOL *This, + OUT EFI_USB_HC_STATE *State ); /** Sets the USB host controller to a specific state. - @param This This EFI_USB_HC_PROTOCOL instance. - @param State The state of the host controller that will be set. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param State Indicates the state of the host controller that will be set. - @retval EFI_SUCCESS The USB host controller was successfully placed - in the state specified by State. - @retval EFI_INVALID_PARAMETER State is invalid. - @retval EFI_DEVICE_ERROR Failed to set the state due to device error. + @retval EFI_SUCCESS The USB host controller was successfully placed in the state + specified by State. + @retval EFI_INVALID_PARAMETER State is not valid. + @retval EFI_DEVICE_ERROR Failed to set the state specified by State due to device error. **/ - EFI_STATUS EFIAPI OhciSetState ( - IN EFI_USB_HC_PROTOCOL *This, - IN EFI_USB_HC_STATE State + IN EFI_USB2_HC_PROTOCOL *This, + IN EFI_USB_HC_STATE State ); /** - Submits control transfer to a target USB device. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxPaketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of - sending or receiving. - @param Request A pointer to the USB device request that will be sent - to the USB device. - @param TransferDirection Specifies the data direction for the transfer. - There are three values available, DataIn, DataOut - and NoData. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength Indicates the size, in bytes, of the data buffer - specified by Data. - @param TimeOut Indicates the maximum time, in microseconds, - which the transfer is allowed to complete. - @param TransferResult A pointer to the detailed result information generated - by this control transfer. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size that the default control transfer + endpoint is capable of sending or receiving. + @param Request A pointer to the USB device request that will be sent to the USB device. + @param TransferDirection Specifies the data direction for the transfer. There are three values + available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData. + @param Data A pointer to the buffer of data that will be transmitted to USB device or + received from USB device. + @param DataLength On input, indicates the size, in bytes, of the data buffer specified by Data. + On output, indicates the amount of data actually transferred. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information generated by this control + transfer. @retval EFI_SUCCESS The control transfer was completed successfully. - @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. @retval EFI_TIMEOUT The control transfer failed due to timeout. @retval EFI_DEVICE_ERROR The control transfer failed due to host controller or device error. - Caller should check TranferResult for detailed error information. - ---*/ + Caller should check TransferResult for detailed error information. +**/ EFI_STATUS EFIAPI OhciControlTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN EFI_USB_DEVICE_REQUEST *Request, - IN EFI_USB_DATA_DIRECTION TransferDirection, - IN OUT VOID *Data OPTIONAL, - IN OUT UINTN *DataLength OPTIONAL, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN EFI_USB_DEVICE_REQUEST *Request, + IN EFI_USB_DATA_DIRECTION TransferDirection, + IN OUT VOID *Data OPTIONAL, + IN OUT UINTN *DataLength OPTIONAL, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ); /** - Submits bulk transfer to a bulk endpoint of a USB device. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an - endpoint direction of the target USB device. - Each endpoint address supports data transfer in - one direction except the control endpoint - (whose default endpoint address is 0). - It is the caller's responsibility to make sure that - the EndPointAddress represents a bulk endpoint. - @param MaximumPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength When input, indicates the size, in bytes, of the data buffer - specified by Data. When output, indicates the actually - transferred data size. - @param DataToggle A pointer to the data toggle value. On input, it indicates - the initial data toggle value the bulk transfer should adopt; - on output, it is updated to indicate the data toggle value - of the subsequent bulk transfer. - @param TimeOut Indicates the maximum time, in microseconds, which the - transfer is allowed to complete. - TransferResult A pointer to the detailed result information of the - bulk transfer. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength When input, indicates the size, in bytes, of the data buffers specified by + Data. When output, indicates the actually transferred data size. + @param DataToggle A pointer to the data toggle value. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information of the bulk transfer. @retval EFI_SUCCESS The bulk transfer was completed successfully. - @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to lack of resource. @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to a lack of resources. @retval EFI_TIMEOUT The bulk transfer failed due to timeout. @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error. - Caller should check TranferResult for detailed error information. + Caller should check TransferResult for detailed error information. **/ - EFI_STATUS EFIAPI OhciBulkTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaxPacketLength, - IN OUT VOID *Data, - IN OUT UINTN *DataLength, - IN OUT UINT8 *DataToggle, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ); /** @@ -272,7 +287,7 @@ OhciBulkTransfer ( the EndPointAddress represents an interrupt endpoint. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. - @param MaxPacketLength Indicates the maximum packet size the target endpoint + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the target interrupt endpoint. @@ -309,14 +324,13 @@ OhciBulkTransfer ( @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ - EFI_STATUS OhciInterruptTransfer ( IN USB_OHCI_HC_DEV *Ohc, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, + IN UINT8 MaximumPacketLength, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle OPTIONAL, IN UINTN PollingInterval OPTIONAL, @@ -330,45 +344,30 @@ OhciInterruptTransfer ( ); /** - Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device. + Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an endpoint - direction of the target USB device. Each endpoint address - supports data transfer in one direction except the - control endpoint (whose default endpoint address is 0). - It is the caller's responsibility to make sure that - the EndPointAddress represents an interrupt endpoint. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxiumPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between - the host and the target interrupt endpoint. - If FALSE, the specified asynchronous interrupt pipe - is canceled. - @param DataToggle A pointer to the data toggle value. On input, it is valid - when IsNewTransfer is TRUE, and it indicates the initial - data toggle value the asynchronous interrupt transfer - should adopt. - On output, it is valid when IsNewTransfer is FALSE, - and it is updated to indicate the data toggle value of - the subsequent asynchronous interrupt transfer. - @param PollingInterval Indicates the interval, in milliseconds, that the - asynchronous interrupt transfer is polled. - This parameter is required when IsNewTransfer is TRUE. - @param DataLength Indicates the length of data to be received at the - rate specified by PollingInterval from the target - asynchronous interrupt endpoint. This parameter - is only required when IsNewTransfer is TRUE. - @param CallBackFunction The Callback function.This function is called at the - rate specified by PollingInterval.This parameter is - only required when IsNewTransfer is TRUE. - @param Context The context that is passed to the CallBackFunction. - This is an optional parameter and may be NULL. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the + target interrupt endpoint. If FALSE, the specified asynchronous interrupt + pipe is canceled. If TRUE, and an interrupt transfer exists for the target + end point, then EFI_INVALID_PARAMETER is returned. + @param DataToggle A pointer to the data toggle value. + @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous interrupt + transfer is polled. + @param DataLength Indicates the length of data to be received at the rate specified by + PollingInterval from the target asynchronous interrupt endpoint. + @param Translator A pointr to the transaction translator data. + @param CallBackFunction The Callback function. This function is called at the rate specified by + PollingInterval. + @param Context The context that is passed to the CallBackFunction. This is an + optional parameter and may be NULL. @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully submitted or canceled. @@ -376,228 +375,276 @@ OhciInterruptTransfer ( @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ - EFI_STATUS EFIAPI OhciAsyncInterruptTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN BOOLEAN IsNewTransfer, - IN OUT UINT8 *DataToggle OPTIONAL, - IN UINTN PollingInterval OPTIONAL, - IN UINTN DataLength OPTIONAL, - IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, - IN VOID *Context OPTIONAL + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaxiumPacketLength, + IN BOOLEAN IsNewTransfer, + IN OUT UINT8 *DataToggle, + IN UINTN PollingInterval OPTIONAL, + IN UINTN DataLength OPTIONAL, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator OPTIONAL, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, + IN VOID *Context OPTIONAL ); /** + Submits synchronous interrupt transfer to an interrupt endpoint of a USB device. + Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version. - Submits synchronous interrupt transfer to an interrupt endpoint - of a USB device. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of + sending or receiving. + @param Data A pointer to the buffer of data that will be transmitted to USB device or + received from USB device. + @param DataLength On input, the size, in bytes, of the data buffer specified by Data. On + output, the number of bytes transferred. + @param DataToggle A pointer to the data toggle value. + @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is + allowed to complete. + @param Translator A pointr to the transaction translator data. + @param TransferResult A pointer to the detailed result information from the synchronous + interrupt transfer. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress The combination of an endpoint number and an endpoint - direction of the target USB device. Each endpoint - address supports data transfer in one direction - except the control endpoint (whose default - endpoint address is 0). It is the caller's responsibility - to make sure that the EndPointAddress represents - an interrupt endpoint. - @param IsSlowDevice Indicates whether the target device is slow device - or full-speed device. - @param MaxPacketLength Indicates the maximum packet size the target endpoint - is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength On input, the size, in bytes, of the data buffer specified - by Data. On output, the number of bytes transferred. - @param DataToggle A pointer to the data toggle value. On input, it indicates - the initial data toggle value the synchronous interrupt - transfer should adopt; - on output, it is updated to indicate the data toggle value - of the subsequent synchronous interrupt transfer. - @param TimeOut Indicates the maximum time, in microseconds, which the - transfer is allowed to complete. - @param TransferResult A pointer to the detailed result information from - the synchronous interrupt transfer. - - @retval EFI_UNSUPPORTED This interface not available. - @retval EFI_INVALID_PARAMETER Parameters not follow spec + @retval EFI_SUCCESS The synchronous interrupt transfer was completed successfully. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The synchronous interrupt transfer could not be submitted due to a lack of resources. + @retval EFI_TIMEOUT The synchronous interrupt transfer failed due to timeout. + @retval EFI_DEVICE_ERROR The synchronous interrupt transfer failed due to host controller or device error. + Caller should check TransferResult for detailed error information. **/ - EFI_STATUS EFIAPI OhciSyncInterruptTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN BOOLEAN IsSlowDevice, - IN UINT8 MaxPacketLength, - IN OUT VOID *Data, - IN OUT UINTN *DataLength, - IN OUT UINT8 *DataToggle, - IN UINTN TimeOut, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ); /** + Submits isochronous transfer to an isochronous endpoint of a USB device. - Submits isochronous transfer to a target USB device. + This function is used to submit isochronous transfer to a target endpoint of a USB device. + The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers are + used when working with isochronous date. It provides periodic, continuous communication between + the host and a device. Isochronous transfers can beused only by full-speed, high-speed, and + super-speed devices. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress End point address - @param MaximumPacketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of + High-speed isochronous transfers can be performed using multiple data buffers. The number of + buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For + full-speed isochronous transfers this value is ignored. + + Data represents a list of pointers to the data buffers. For full-speed isochronous transfers + only the data pointed by Data[0]shall be used. For high-speed isochronous transfers and for + the split transactions depending on DataLengththere several data buffers canbe used. For the + high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM. + + For split transactions performed on full-speed device by high-speed host controller the total + number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1. + If the isochronous transfer is successful, then EFI_SUCCESSis returned. The isochronous transfer + is designed to be completed within one USB frame time, if it cannot be completed, EFI_TIMEOUT + is returned. If an error other than timeout occurs during the USB transfer, then EFI_DEVICE_ERROR + is returned and the detailed status code will be returned in TransferResult. + + EFI_INVALID_PARAMETERis returned if one of the following conditionsis satisfied: + - Data is NULL. + - DataLength is 0. + - DeviceSpeed is not one of the supported values listed above. + - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed devices, + and 1024 or less for high-speed and super-speed devices. + - TransferResult is NULL. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. The supported values are EFI_USB_SPEED_FULL, + EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param DataLength Indicates the size, in bytes, of the data buffer - specified by Data. - @param TransferResult A pointer to the detailed result information generated - by this control transfer. + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength Specifies the length, in bytes, of the data to be sent to or received from + the USB device. + @param Translator A pointer to the transaction translator data. + @param TransferResult A pointer to the detailed result information of the isochronous transfer. - @retval EFI_UNSUPPORTED This interface not available - @retval EFI_INVALID_PARAMETER Data is NULL or DataLength is 0 or TransferResult is NULL + @retval EFI_SUCCESS The isochronous transfer was completed successfully. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The isochronous transfer could not be submitted due to a lack of resources. + @retval EFI_TIMEOUT The isochronous transfer cannot be completed within the one USB frame time. + @retval EFI_DEVICE_ERROR The isochronous transfer failed due to host controller or device error. + Caller should check TransferResult for detailed error information. **/ - EFI_STATUS EFIAPI OhciIsochronousTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaximumPacketLength, - IN OUT VOID *Data, - IN OUT UINTN DataLength, - OUT UINT32 *TransferResult + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult ); /** + Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device. - Submits Async isochronous transfer to a target USB device. + This is an asynchronous type of USB isochronous transfer. If the caller submits a USB + isochronous transfer request through this function, this function will return immediately. - @param his A pointer to the EFI_USB_HC_PROTOCOL instance. - @param DeviceAddress Represents the address of the target device on the USB, - which is assigned during USB enumeration. - @param EndPointAddress End point address - @param MaximumPacketLength Indicates the maximum packet size that the - default control transfer endpoint is capable of + When the isochronous transfer completes, the IsochronousCallbackfunction will be triggered, + the caller can know the transfer results. If the transfer is successful, the caller can get + the data received or sent in this callback function. + + The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers + are used when working with isochronous date. It provides periodic, continuous communication + between the host and a device. Isochronous transfers can be used only by full-speed, high-speed, + and super-speed devices. + + High-speed isochronous transfers can be performed using multiple data buffers. The number of + buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For + full-speed isochronous transfers this value is ignored. + + Data represents a list of pointers to the data buffers. For full-speed isochronous transfers + only the data pointed by Data[0] shall be used. For high-speed isochronous transfers and for + the split transactions depending on DataLength there several data buffers can be used. For + the high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM. + + For split transactions performed on full-speed device by high-speed host controller the total + number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1. + + EFI_INVALID_PARAMETER is returned if one of the following conditionsis satisfied: + - Data is NULL. + - DataLength is 0. + - DeviceSpeed is not one of the supported values listed above. + - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed + devices and 1024 or less for high-speed and super-speed devices. + + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param DeviceAddress Represents the address of the target device on the USB. + @param EndPointAddress The combination of an endpoint number and an endpoint direction of the + target USB device. + @param DeviceSpeed Indicates device speed. The supported values are EFI_USB_SPEED_FULL, + EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER. + @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. - @param Data A pointer to the buffer of data that will be transmitted - to USB device or received from USB device. - @param IsochronousCallBack When the transfer complete, the call back function will be called - @param Context Pass to the call back function as parameter + @param DataBuffersNumber Number of data buffers prepared for the transfer. + @param Data Array of pointers to the buffers of data that will be transmitted to USB + device or received from USB device. + @param DataLength Specifies the length, in bytes, of the data to be sent to or received from + the USB device. + @param Translator A pointer to the transaction translator data. + @param IsochronousCallback The Callback function. This function is called if the requested + isochronous transfer is completed. + @param Context Data passed to the IsochronousCallback function. This is an + optional parameter and may be NULL. - @retval EFI_UNSUPPORTED This interface not available - @retval EFI_INVALID_PARAMETER Data is NULL or Datalength is 0 + @retval EFI_SUCCESS The asynchronous isochronous transfer request has been successfully + submitted or canceled. + @retval EFI_INVALID_PARAMETER Some parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The asynchronous isochronous transfer could not be submitted due to + a lack of resources. **/ - EFI_STATUS EFIAPI OhciAsyncIsochronousTransfer ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 DeviceAddress, - IN UINT8 EndPointAddress, - IN UINT8 MaximumPacketLength, - IN OUT VOID *Data, - IN OUT UINTN DataLength, - IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, - IN VOID *Context OPTIONAL + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, + IN VOID *Context OPTIONAL ); /** - - Retrieves the number of root hub ports. - - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param NumOfPorts A pointer to the number of the root hub ports. - - @retval EFI_SUCCESS The port number was retrieved successfully. -**/ -EFI_STATUS -EFIAPI -OhciGetRootHubNumOfPorts ( - IN EFI_USB_HC_PROTOCOL *This, - OUT UINT8 *NumOfPorts - ); - -/** - Retrieves the current status of a USB root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL. - @param PortNumber Specifies the root hub port from which the status - is to be retrieved. This value is zero-based. For example, - if a root hub has two ports, then the first port is numbered 0, - and the second port is numbered 1. - @param PortStatus A pointer to the current port status bits and - port status change bits. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port from which the status is to be retrieved. + This value is zero based. + @param PortStatus A pointer to the current port status bits and port status change bits. @retval EFI_SUCCESS The status of the USB root hub port specified by PortNumber was returned in PortStatus. - @retval EFI_INVALID_PARAMETER Port number not valid -**/ + @retval EFI_INVALID_PARAMETER PortNumber is invalid. +**/ EFI_STATUS EFIAPI OhciGetRootHubPortStatus ( - IN EFI_USB_HC_PROTOCOL *This, - IN UINT8 PortNumber, - OUT EFI_USB_PORT_STATUS *PortStatus + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 PortNumber, + OUT EFI_USB_PORT_STATUS *PortStatus ); /** - Sets a feature for the specified root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL. - @param PortNumber Specifies the root hub port whose feature - is requested to be set. - @param PortFeature Indicates the feature selector associated - with the feature set request. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port whose feature is requested to be set. This + value is zero based. + @param PortFeature Indicates the feature selector associated with the feature set request. + + @retval EFI_SUCCESS The feature specified by PortFeature was set for the USB + root hub port specified by PortNumber. + @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. - @retval EFI_SUCCESS The feature specified by PortFeature was set for the - USB root hub port specified by PortNumber. - @retval EFI_DEVICE_ERROR Set feature failed because of hardware issue - @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. **/ EFI_STATUS EFIAPI OhciSetRootHubPortFeature ( - IN EFI_USB_HC_PROTOCOL *This, + IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ); /** - Clears a feature for the specified root hub port. - @param This A pointer to the EFI_USB_HC_PROTOCOL instance. - @param PortNumber Specifies the root hub port whose feature - is requested to be cleared. - @param PortFeature Indicates the feature selector associated with the - feature clear request. + @param This A pointer to the EFI_USB2_HC_PROTOCOL instance. + @param PortNumber Specifies the root hub port whose feature is requested to be cleared. This + value is zero based. + @param PortFeature Indicates the feature selector associated with the feature clear request. + + @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the USB + root hub port specified by PortNumber. + @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. - @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the - USB root hub port specified by PortNumber. - @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. - @retval EFI_DEVICE_ERROR Some error happened when clearing feature **/ EFI_STATUS EFIAPI OhciClearRootHubPortFeature ( - IN EFI_USB_HC_PROTOCOL *This, + IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ); @@ -616,7 +663,6 @@ OhciClearRootHubPortFeature ( **/ EFI_STATUS EFIAPI - OHCIDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciDxe.inf b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciDxe.inf index a586a885..de3bbbb4 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciDxe.inf +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciDxe.inf @@ -1,6 +1,7 @@ ## @file # OHCI USB Host Controller UEFI Driver # +# Copyright (c) 2025, Mario Bălănică # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -62,8 +63,8 @@ gEfiEndOfDxeEventGroupGuid [Protocols] - gOhciDeviceProtocolGuid ## TO_START - gEfiUsbHcProtocolGuid ## BY_START + gOhciDeviceProtocolGuid ## TO_START + gEfiUsb2HcProtocolGuid ## BY_START [Depex] TRUE diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciSched.h b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciSched.h index 903a9b11..7a904371 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciSched.h +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/OhciDxe/OhciSched.h @@ -24,7 +24,7 @@ struct _INTERRUPT_CONTEXT_ENTRY { ED_DESCRIPTOR *Ed; TD_DESCRIPTOR *DataTd; BOOLEAN IsSlowDevice; - UINT8 MaxPacketLength; + UINT8 MaximumPacketLength; UINTN PollingInterval; EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction; VOID *Context;