TianoCore EDK2 master
|
#include "XhcPeim.h"
Go to the source code of this file.
PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid which is used to enable recovery function from USB Drivers.
Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file XhciSched.c.
UINT8 XhcPeiBusDevAddrToSlotId | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | BusDevAddr | ||
) |
Find out the actual device address according to the requested device address from UsbBus.
Xhc | The XHCI device. |
BusDevAddr | The requested device address by UsbBus upper driver. |
Definition at line 979 of file XhciSched.c.
EFI_STATUS XhcPeiCheckNewEvent | ( | IN PEI_XHC_DEV * | Xhc, |
IN EVENT_RING * | EvtRing, | ||
OUT TRB_TEMPLATE ** | NewEvtTrb | ||
) |
Check if there is a new generated event.
Xhc | The XHCI device. |
EvtRing | The event ring to check. |
NewEvtTrb | The new event TRB found. |
EFI_SUCCESS | Found a new event TRB at the event ring. |
EFI_NOT_READY | The event ring has no new event. |
Definition at line 2561 of file XhciSched.c.
BOOLEAN XhcPeiCheckUrbResult | ( | IN PEI_XHC_DEV * | Xhc, |
IN URB * | Urb | ||
) |
Check the URB's execution result and update the URB's result accordingly.
Xhc | The XHCI device. |
Urb | The URB to check result. |
Definition at line 623 of file XhciSched.c.
EFI_STATUS XhcPeiCmdTransfer | ( | IN PEI_XHC_DEV * | Xhc, |
IN TRB_TEMPLATE * | CmdTrb, | ||
IN UINTN | Timeout, | ||
OUT TRB_TEMPLATE ** | EvtTrb | ||
) |
Execute a XHCI cmd TRB pointed by CmdTrb.
Xhc | The XHCI device. |
CmdTrb | The cmd TRB to be executed. |
Timeout | Indicates the maximum time, in millisecond, which the transfer is allowed to complete. |
EvtTrb | The event TRB corresponding to the cmd TRB. |
EFI_SUCCESS | The transfer was completed successfully. |
EFI_INVALID_PARAMETER | Some parameters are invalid. |
EFI_TIMEOUT | The transfer failed due to timeout. |
EFI_DEVICE_ERROR | The transfer failed due to host controller error. |
Definition at line 65 of file XhciSched.c.
EFI_STATUS XhcPeiConfigHubContext | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | PortNum, | ||
IN UINT8 | TTT, | ||
IN UINT8 | MTT | ||
) |
Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be configured. |
PortNum | The total number of downstream port supported by the hub. |
TTT | The TT think time of the hub device. |
MTT | The multi-TT of the hub device. |
EFI_SUCCESS | Successfully configure the hub device's slot context. |
Definition at line 2279 of file XhciSched.c.
EFI_STATUS XhcPeiConfigHubContext64 | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | PortNum, | ||
IN UINT8 | TTT, | ||
IN UINT8 | MTT | ||
) |
Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be configured. |
PortNum | The total number of downstream port supported by the hub. |
TTT | The TT think time of the hub device. |
MTT | The multi-TT of the hub device. |
EFI_SUCCESS | Successfully configure the hub device's slot context. |
Definition at line 2348 of file XhciSched.c.
URB * XhcPeiCreateCmdTrb | ( | IN PEI_XHC_DEV * | Xhc, |
IN TRB_TEMPLATE * | CmdTrb | ||
) |
Create a command transfer TRB to support XHCI command interfaces.
Xhc | The XHCI device. |
CmdTrb | The cmd TRB to be executed. |
Definition at line 24 of file XhciSched.c.
VOID XhcPeiCreateEventRing | ( | IN PEI_XHC_DEV * | Xhc, |
OUT EVENT_RING * | EventRing | ||
) |
Create XHCI event ring.
Xhc | The XHCI device. |
EventRing | The created event ring. |
Definition at line 2670 of file XhciSched.c.
VOID XhcPeiCreateTransferRing | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINTN | TrbNum, | ||
OUT TRANSFER_RING * | TransferRing | ||
) |
Create XHCI transfer ring.
Xhc | The XHCI Device. |
TrbNum | The number of TRB in the ring. |
TransferRing | The created transfer ring. |
Definition at line 2835 of file XhciSched.c.
EFI_STATUS XhcPeiCreateTransferTrb | ( | IN PEI_XHC_DEV * | Xhc, |
IN URB * | Urb | ||
) |
Create a transfer TRB.
Xhc | The XHCI device |
Urb | The urb used to construct the transfer TRB. |
Definition at line 212 of file XhciSched.c.
URB * XhcPeiCreateUrb | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | BusAddr, | ||
IN UINT8 | EpAddr, | ||
IN UINT8 | DevSpeed, | ||
IN UINTN | MaxPacket, | ||
IN UINTN | Type, | ||
IN EFI_USB_DEVICE_REQUEST * | Request, | ||
IN VOID * | Data, | ||
IN UINTN | DataLen, | ||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK | Callback, | ||
IN VOID * | Context | ||
) |
Create a new URB for a new transaction.
Xhc | The XHCI device |
BusAddr | The logical device address assigned by UsbBus driver |
EpAddr | Endpoint addrress |
DevSpeed | The device speed |
MaxPacket | The max packet length of the endpoint |
Type | The transaction type |
Request | The standard USB request for control transfer |
Data | The user data to transfer |
DataLen | The length of data buffer |
Callback | The function to call when data is transferred |
Context | The context to the callback |
Definition at line 131 of file XhciSched.c.
EFI_STATUS XhcPeiDequeueTrbFromEndpoint | ( | IN PEI_XHC_DEV * | Xhc, |
IN URB * | Urb | ||
) |
System software shall use a Stop Endpoint Command (section 4.6.9) and the Set TR Dequeue Pointer Command (section 4.6.10) to remove the timed-out TDs from the xHC transfer ring. The next write to the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running state.
Xhc | The XHCI device. |
Urb | The urb which doesn't get completed in a specified timeout range. |
EFI_SUCCESS | The dequeuing of the TDs is successful. |
Others | Failed to stop the endpoint and dequeue the TDs. |
Definition at line 532 of file XhciSched.c.
EFI_STATUS XhcPeiDisableSlotCmd | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId | ||
) |
Disable the specified device slot.
Xhc | The XHCI device. |
SlotId | The slot id to be disabled. |
EFI_SUCCESS | Successfully disable the device slot. |
Definition at line 1497 of file XhciSched.c.
EFI_STATUS XhcPeiDisableSlotCmd64 | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId | ||
) |
Disable the specified device slot.
Xhc | The XHCI device. |
SlotId | The slot id to be disabled. |
EFI_SUCCESS | Successfully disable the device slot. |
Definition at line 1604 of file XhciSched.c.
UINT8 XhcPeiEndpointToDci | ( | IN UINT8 | EpAddr, |
IN EFI_USB_DATA_DIRECTION | Direction | ||
) |
Calculate the device context index by endpoint address and direction.
EpAddr | The target endpoint number. |
Direction | The direction of the target endpoint. |
Definition at line 948 of file XhciSched.c.
EFI_STATUS XhcPeiEvaluateContext | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT32 | MaxPacketSize | ||
) |
Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be evaluated. |
MaxPacketSize | The max packet size supported by the device control transfer. |
EFI_SUCCESS | Successfully evaluate the device endpoint 0. |
Definition at line 2167 of file XhciSched.c.
EFI_STATUS XhcPeiEvaluateContext64 | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT32 | MaxPacketSize | ||
) |
Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be evaluated. |
MaxPacketSize | The max packet size supported by the device control transfer. |
EFI_SUCCESS | Successfully evaluate the device endpoint 0. |
Definition at line 2222 of file XhciSched.c.
EFI_STATUS XhcPeiExecTransfer | ( | IN PEI_XHC_DEV * | Xhc, |
IN BOOLEAN | CmdTransfer, | ||
IN URB * | Urb, | ||
IN UINTN | Timeout | ||
) |
Execute the transfer by polling the URB. This is a synchronous operation.
Xhc | The XHCI device. |
CmdTransfer | The executed URB is for cmd transfer or not. |
Urb | The URB to execute. |
Timeout | The time to wait before abort, in millisecond. |
Definition at line 797 of file XhciSched.c.
VOID XhcPeiFreeEventRing | ( | IN PEI_XHC_DEV * | Xhc, |
IN EVENT_RING * | EventRing | ||
) |
Free XHCI event ring.
Xhc | The XHCI device. |
EventRing | The event ring to be freed. |
Definition at line 2642 of file XhciSched.c.
VOID XhcPeiFreeSched | ( | IN PEI_XHC_DEV * | Xhc | ) |
Free the resouce allocated at initializing schedule.
Xhc | The XHCI device. |
Definition at line 3049 of file XhciSched.c.
VOID XhcPeiFreeUrb | ( | IN PEI_XHC_DEV * | Xhc, |
IN URB * | Urb | ||
) |
Free an allocated URB.
Xhc | The XHCI device. |
Urb | The URB to free. |
Definition at line 188 of file XhciSched.c.
EFI_STATUS XhcPeiInitializeDeviceSlot | ( | IN PEI_XHC_DEV * | Xhc, |
IN USB_DEV_ROUTE | ParentRouteChart, | ||
IN UINT16 | ParentPort, | ||
IN USB_DEV_ROUTE | RouteChart, | ||
IN UINT8 | DeviceSpeed | ||
) |
Assign and initialize the device slot for a new device.
Xhc | The XHCI device. |
ParentRouteChart | The route string pointed to the parent device. |
ParentPort | The port at which the device is located. |
RouteChart | The route string pointed to the device. |
DeviceSpeed | The device speed. |
EFI_SUCCESS | Successfully assign a slot to the device and assign an address to it. |
Others | Fail to initialize device slot. |
Definition at line 1071 of file XhciSched.c.
EFI_STATUS XhcPeiInitializeDeviceSlot64 | ( | IN PEI_XHC_DEV * | Xhc, |
IN USB_DEV_ROUTE | ParentRouteChart, | ||
IN UINT16 | ParentPort, | ||
IN USB_DEV_ROUTE | RouteChart, | ||
IN UINT8 | DeviceSpeed | ||
) |
Assign and initialize the device slot for a new device.
Xhc | The XHCI device. |
ParentRouteChart | The route string pointed to the parent device. |
ParentPort | The port at which the device is located. |
RouteChart | The route string pointed to the device. |
DeviceSpeed | The device speed. |
EFI_SUCCESS | Successfully assign a slot to the device and assign an address to it. |
Others | Fail to initialize device slot. |
Definition at line 1286 of file XhciSched.c.
VOID XhcPeiInitSched | ( | IN PEI_XHC_DEV * | Xhc | ) |
Initialize the XHCI host controller for schedule.
Xhc | The XHCI device to be initialized. |
Definition at line 2882 of file XhciSched.c.
BOOLEAN XhcPeiIsTransferRingTrb | ( | IN TRB_TEMPLATE * | Trb, |
IN URB * | Urb | ||
) |
Check if the Trb is a transaction of the URB.
Trb | The TRB to be checked |
Urb | The transfer ring to be checked. |
TRUE | It is a transaction of the URB. |
FALSE | It is not any transaction of the URB. |
Definition at line 589 of file XhciSched.c.
EFI_STATUS XhcPeiPollPortStatusChange | ( | IN PEI_XHC_DEV * | Xhc, |
IN USB_DEV_ROUTE | ParentRouteChart, | ||
IN UINT8 | Port, | ||
IN EFI_USB_PORT_STATUS * | PortState | ||
) |
Monitor the port status change. Enable/Disable device slot if there is a device attached/detached.
Xhc | The XHCI device. |
ParentRouteChart | The route string pointed to the parent device if it exists. |
Port | The port to be polled. |
PortState | The port state. |
EFI_SUCCESS | Successfully enable/disable device slot according to port state. |
Others | Should not appear. |
Definition at line 863 of file XhciSched.c.
EFI_STATUS XhcPeiRecoverHaltedEndpoint | ( | IN PEI_XHC_DEV * | Xhc, |
IN URB * | Urb | ||
) |
System software shall use a Reset Endpoint Command (section 4.11.4.7) to remove the Halted condition in the xHC. After the successful completion of the Reset Endpoint Command, the Endpoint Context is transitioned from the Halted to the Stopped state and the Transfer Ring of the endpoint is reenabled. The next write to the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running state.
Xhc | The XHCI device. |
Urb | The urb which makes the endpoint halted. |
EFI_SUCCESS | The recovery is successful. |
Others | Failed to recovery halted endpoint. |
Definition at line 472 of file XhciSched.c.
EFI_STATUS EFIAPI XhcPeiResetEndpoint | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | Dci | ||
) |
Reset endpoint through XHCI's Reset_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id of the target device. |
Dci | The device context index of the target slot or endpoint. |
EFI_SUCCESS | Reset endpoint successfully. |
Others | Failed to reset endpoint. |
Definition at line 2463 of file XhciSched.c.
VOID XhcPeiRingDoorBell | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | Dci | ||
) |
Ring the door bell to notify XHCI there is a transaction to be executed.
Xhc | The XHCI device. |
SlotId | The slot id of the target device. |
Dci | The device context index of the target slot or endpoint. |
Definition at line 1044 of file XhciSched.c.
UINT8 XhcPeiRouteStringToSlotId | ( | IN PEI_XHC_DEV * | Xhc, |
IN USB_DEV_ROUTE | RouteString | ||
) |
Find out the slot id according to the device's route string.
Xhc | The XHCI device. |
RouteString | The route string described the device location. |
Definition at line 1012 of file XhciSched.c.
EFI_STATUS XhcPeiSetConfigCmd | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | DeviceSpeed, | ||
IN USB_CONFIG_DESCRIPTOR * | ConfigDesc | ||
) |
Configure all the device endpoints through XHCI's Configure_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be configured. |
DeviceSpeed | The device's speed. |
ConfigDesc | The pointer to the usb device configuration descriptor. |
EFI_SUCCESS | Successfully configure all the device endpoints. |
Definition at line 1713 of file XhciSched.c.
EFI_STATUS XhcPeiSetConfigCmd64 | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | DeviceSpeed, | ||
IN USB_CONFIG_DESCRIPTOR * | ConfigDesc | ||
) |
Configure all the device endpoints through XHCI's Configure_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id to be configured. |
DeviceSpeed | The device's speed. |
ConfigDesc | The pointer to the usb device configuration descriptor. |
EFI_SUCCESS | Successfully configure all the device endpoints. |
Definition at line 1939 of file XhciSched.c.
EFI_STATUS EFIAPI XhcPeiSetTrDequeuePointer | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | Dci, | ||
IN URB * | Urb | ||
) |
Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd.
Xhc | The XHCI device. |
SlotId | The slot id of the target device. |
Dci | The device context index of the target slot or endpoint. |
Urb | The dequeue pointer of the transfer ring specified by the urb to be updated. |
EFI_SUCCESS | Set transfer ring dequeue pointer succeeds. |
Others | Failed to set transfer ring dequeue pointer. |
Definition at line 2511 of file XhciSched.c.
EFI_STATUS EFIAPI XhcPeiStopEndpoint | ( | IN PEI_XHC_DEV * | Xhc, |
IN UINT8 | SlotId, | ||
IN UINT8 | Dci | ||
) |
Stop endpoint through XHCI's Stop_Endpoint cmd.
Xhc | The XHCI device. |
SlotId | The slot id of the target device. |
Dci | The device context index of the target slot or endpoint. |
EFI_SUCCESS | Stop endpoint successfully. |
Others | Failed to stop endpoint. |
Definition at line 2417 of file XhciSched.c.
EFI_STATUS XhcPeiSyncEventRing | ( | IN PEI_XHC_DEV * | Xhc, |
IN EVENT_RING * | EvtRing | ||
) |
Synchronize the specified event ring to update the enqueue and dequeue pointer.
Xhc | The XHCI device. |
EvtRing | The event ring to sync. |
EFI_SUCCESS | The event ring is synchronized successfully. |
Definition at line 2596 of file XhciSched.c.
EFI_STATUS XhcPeiSyncTrsRing | ( | IN PEI_XHC_DEV * | Xhc, |
IN TRANSFER_RING * | TrsRing | ||
) |
Synchronize the specified transfer ring to update the enqueue and dequeue pointer.
Xhc | The XHCI device. |
TrsRing | The transfer ring to sync. |
EFI_SUCCESS | The transfer ring is synchronized successfully. |
Definition at line 2772 of file XhciSched.c.