X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FXhciDxe%2FXhciSched.h;h=f40f94c1e4b711acf47b37adb4f4964cb0c129ac;hp=2090644e04540eef94bde3222e3fa28ed1468d89;hb=49be9c3c20cea7477b9c9e390c9f97735760e216;hpb=a9292c1363437b081ea72fd8f3b2ed075e2a7ef3 diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h index 2090644e04..f40f94c1e4 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h @@ -2,7 +2,7 @@ This file contains the definition for XHCI host controller schedule routines. -Copyright (c) 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -80,6 +80,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define TRB_COMPLETION_TRB_ERROR 5 #define TRB_COMPLETION_STALL_ERROR 6 #define TRB_COMPLETION_SHORT_PACKET 13 +#define TRB_COMPLETION_STOPPED 26 +#define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27 // // The topology string used to present usb device location @@ -111,6 +113,12 @@ typedef union _USB_DEV_ROUTE { // Endpoint address and its capabilities // typedef struct _USB_ENDPOINT { + // + // Store logical device address assigned by UsbBus + // It's because some XHCI host controllers may assign the same physcial device + // address for those devices inserted at different root port. + // + UINT8 BusAddr; UINT8 DevAddr; UINT8 EpAddr; EFI_USB_DATA_DIRECTION Direction; @@ -144,7 +152,6 @@ typedef struct _TRANSFER_RING { } TRANSFER_RING; typedef struct _EVENT_RING { - UINT32 EventInterrupter; VOID *ERSTBase; VOID *EventRingSeg0; UINTN TrbNumber; @@ -167,6 +174,8 @@ typedef struct _URB { EFI_USB_DEVICE_REQUEST *Request; VOID *Data; UINTN DataLen; + VOID *DataPhy; + VOID *DataMap; EFI_ASYNC_USB_TRANSFER_CALLBACK Callback; VOID *Context; // @@ -184,8 +193,11 @@ typedef struct _URB { TRB_TEMPLATE *TrbStart; TRB_TEMPLATE *TrbEnd; UINTN TrbNum; - EVENT_RING *EvtRing; - TRB_TEMPLATE *EvtTrbStart; + BOOLEAN StartDone; + BOOLEAN EndDone; + BOOLEAN Finished; + + TRB_TEMPLATE *EvtTrb; } URB; // @@ -214,7 +226,7 @@ typedef struct _TRANSFER_TRB_NORMAL { UINT32 TRBPtrHi; - UINT32 Lenth:17; + UINT32 Length:17; UINT32 TDSize:5; UINT32 IntTarget:10; @@ -243,7 +255,7 @@ typedef struct _TRANSFER_TRB_CONTROL_SETUP { UINT32 wIndex:16; UINT32 wLength:16; - UINT32 Lenth:17; + UINT32 Length:17; UINT32 RsvdZ1:5; UINT32 IntTarget:10; @@ -266,7 +278,7 @@ typedef struct _TRANSFER_TRB_CONTROL_DATA { UINT32 TRBPtrHi; - UINT32 Lenth:17; + UINT32 Length:17; UINT32 TDSize:5; UINT32 IntTarget:10; @@ -315,7 +327,7 @@ typedef struct _EVT_TRB_TRANSFER { UINT32 TRBPtrHi; - UINT32 Lenth:24; + UINT32 Length:24; UINT32 Completecode:8; UINT32 CycleBit:1; @@ -577,6 +589,46 @@ typedef struct _SLOT_CONTEXT { UINT32 RsvdZ7; } SLOT_CONTEXT; +typedef struct _SLOT_CONTEXT_64 { + UINT32 RouteString:20; + UINT32 Speed:4; + UINT32 RsvdZ1:1; + UINT32 MTT:1; + UINT32 Hub:1; + UINT32 ContextEntries:5; + + UINT32 MaxExitLatency:16; + UINT32 RootHubPortNum:8; + UINT32 PortNum:8; + + UINT32 TTHubSlotId:8; + UINT32 TTPortNum:8; + UINT32 TTT:2; + UINT32 RsvdZ2:4; + UINT32 InterTarget:10; + + UINT32 DeviceAddress:8; + UINT32 RsvdZ3:19; + UINT32 SlotState:5; + + UINT32 RsvdZ4; + UINT32 RsvdZ5; + UINT32 RsvdZ6; + UINT32 RsvdZ7; + + UINT32 RsvdZ8; + UINT32 RsvdZ9; + UINT32 RsvdZ10; + UINT32 RsvdZ11; + + UINT32 RsvdZ12; + UINT32 RsvdZ13; + UINT32 RsvdZ14; + UINT32 RsvdZ15; + +} SLOT_CONTEXT_64; + + // // 6.2.3 Endpoint Context // @@ -609,6 +661,47 @@ typedef struct _ENDPOINT_CONTEXT { UINT32 RsvdZ7; } ENDPOINT_CONTEXT; +typedef struct _ENDPOINT_CONTEXT_64 { + UINT32 EPState:3; + UINT32 RsvdZ1:5; + UINT32 Mult:2; + UINT32 MaxPStreams:5; + UINT32 LSA:1; + UINT32 Interval:8; + UINT32 RsvdZ2:8; + + UINT32 RsvdZ3:1; + UINT32 CErr:2; + UINT32 EPType:3; + UINT32 RsvdZ4:1; + UINT32 HID:1; + UINT32 MaxBurstSize:8; + UINT32 MaxPacketSize:16; + + UINT32 PtrLo; + + UINT32 PtrHi; + + UINT32 AverageTRBLength:16; + UINT32 MaxESITPayload:16; + + UINT32 RsvdZ5; + UINT32 RsvdZ6; + UINT32 RsvdZ7; + + UINT32 RsvdZ8; + UINT32 RsvdZ9; + UINT32 RsvdZ10; + UINT32 RsvdZ11; + + UINT32 RsvdZ12; + UINT32 RsvdZ13; + UINT32 RsvdZ14; + UINT32 RsvdZ15; + +} ENDPOINT_CONTEXT_64; + + // // 6.2.5.1 Input Control Context // @@ -623,6 +716,25 @@ typedef struct _INPUT_CONTRL_CONTEXT { UINT32 RsvdZ6; } INPUT_CONTRL_CONTEXT; +typedef struct _INPUT_CONTRL_CONTEXT_64 { + UINT32 Dword1; + UINT32 Dword2; + UINT32 RsvdZ1; + UINT32 RsvdZ2; + UINT32 RsvdZ3; + UINT32 RsvdZ4; + UINT32 RsvdZ5; + UINT32 RsvdZ6; + UINT32 RsvdZ7; + UINT32 RsvdZ8; + UINT32 RsvdZ9; + UINT32 RsvdZ10; + UINT32 RsvdZ11; + UINT32 RsvdZ12; + UINT32 RsvdZ13; + UINT32 RsvdZ14; +} INPUT_CONTRL_CONTEXT_64; + // // 6.2.1 Device Context // @@ -631,6 +743,11 @@ typedef struct _DEVICE_CONTEXT { ENDPOINT_CONTEXT EP[31]; } DEVICE_CONTEXT; +typedef struct _DEVICE_CONTEXT_64 { + SLOT_CONTEXT_64 Slot; + ENDPOINT_CONTEXT_64 EP[31]; +} DEVICE_CONTEXT_64; + // // 6.2.5 Input Context // @@ -640,6 +757,13 @@ typedef struct _INPUT_CONTEXT { ENDPOINT_CONTEXT EP[31]; } INPUT_CONTEXT; +typedef struct _INPUT_CONTEXT_64 { + INPUT_CONTRL_CONTEXT_64 InputControlContext; + SLOT_CONTEXT_64 Slot; + ENDPOINT_CONTEXT_64 EP[31]; +} INPUT_CONTEXT_64; + + /** Initialize the XHCI host controller for schedule. @@ -703,7 +827,7 @@ XhcExecTransfer ( the device and endpoint. @param Xhc The XHCI Instance. - @param DevAddr The address of the target device. + @param BusAddr The logical device address assigned by UsbBus driver. @param EpNum The endpoint of the target. @retval EFI_SUCCESS An asynchronous transfer is removed. @@ -713,7 +837,7 @@ XhcExecTransfer ( EFI_STATUS XhciDelAsyncIntTransfer ( IN USB_XHCI_INSTANCE *Xhc, - IN UINT8 DevAddr, + IN UINT8 BusAddr, IN UINT8 EpNum ); @@ -750,21 +874,6 @@ XhcClearBiosOwnership ( IN USB_XHCI_INSTANCE *Xhc ); -/** - Find out the slot id according to device address assigned by XHCI's Address_Device cmd. - - @param Xhc The XHCI Instance. - @param DevAddr The device address of the target device. - - @return The slot id used by the device. - -**/ -UINT8 -XhcDevAddrToSlotId ( - IN USB_XHCI_INSTANCE *Xhc, - IN UINT8 DevAddr - ); - /** Find out the slot id according to the device's route string. @@ -870,6 +979,29 @@ XhcConfigHubContext ( IN UINT8 MTT ); + +/** + Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param PortNum The total number of downstream port supported by the hub. + @param TTT The TT think time of the hub device. + @param MTT The multi-TT of the hub device. + + @retval EFI_SUCCESS Successfully configure the hub device's slot context. + +**/ +EFI_STATUS +XhcConfigHubContext64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 PortNum, + IN UINT8 TTT, + IN UINT8 MTT + ); + + /** Configure all the device endpoints through XHCI's Configure_Endpoint cmd. @@ -890,6 +1022,71 @@ XhcSetConfigCmd ( IN USB_CONFIG_DESCRIPTOR *ConfigDesc ); + +/** + Configure all the device endpoints through XHCI's Configure_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param DeviceSpeed The device's speed. + @param ConfigDesc The pointer to the usb device configuration descriptor. + + @retval EFI_SUCCESS Successfully configure all the device endpoints. + +**/ +EFI_STATUS +EFIAPI +XhcSetConfigCmd64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 DeviceSpeed, + IN USB_CONFIG_DESCRIPTOR *ConfigDesc + ); + +/** + Set interface through XHCI's Configure_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param DeviceSpeed The device's speed. + @param ConfigDesc The pointer to the usb device configuration descriptor. + @param Request USB device request to send. + + @retval EFI_SUCCESS Successfully set interface. + +**/ +EFI_STATUS +EFIAPI +XhcSetInterface ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 DeviceSpeed, + IN USB_CONFIG_DESCRIPTOR *ConfigDesc, + IN EFI_USB_DEVICE_REQUEST *Request + ); + +/** + Set interface through XHCI's Configure_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param DeviceSpeed The device's speed. + @param ConfigDesc The pointer to the usb device configuration descriptor. + @param Request USB device request to send. + + @retval EFI_SUCCESS Successfully set interface. + +**/ +EFI_STATUS +EFIAPI +XhcSetInterface64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 DeviceSpeed, + IN USB_CONFIG_DESCRIPTOR *ConfigDesc, + IN EFI_USB_DEVICE_REQUEST *Request + ); + /** Find out the actual device address according to the requested device address from UsbBus. @@ -928,6 +1125,28 @@ XhcInitializeDeviceSlot ( IN UINT8 DeviceSpeed ); +/** + Assign and initialize the device slot for a new device. + + @param Xhc The XHCI Instance. + @param ParentRouteChart The route string pointed to the parent device. + @param ParentPort The port at which the device is located. + @param RouteChart The route string pointed to the device. + @param DeviceSpeed The device speed. + + @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it. + +**/ +EFI_STATUS +EFIAPI +XhcInitializeDeviceSlot64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN USB_DEV_ROUTE ParentRouteChart, + IN UINT16 ParentPort, + IN USB_DEV_ROUTE RouteChart, + IN UINT8 DeviceSpeed + ); + /** Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd. @@ -946,6 +1165,26 @@ XhcEvaluateContext ( IN UINT32 MaxPacketSize ); + +/** + Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be evaluated. + @param MaxPacketSize The max packet size supported by the device control transfer. + + @retval EFI_SUCCESS Successfully evaluate the device endpoint 0. + +**/ +EFI_STATUS +EFIAPI +XhcEvaluateContext64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT32 MaxPacketSize + ); + + /** Disable the specified device slot. @@ -962,6 +1201,24 @@ XhcDisableSlotCmd ( IN UINT8 SlotId ); + +/** + Disable the specified device slot. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be disabled. + + @retval EFI_SUCCESS Successfully disable the device slot. + +**/ +EFI_STATUS +EFIAPI +XhcDisableSlotCmd64 ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId + ); + + /** Synchronize the specified transfer ring to update the enqueue and dequeue pointer. @@ -1032,14 +1289,12 @@ CreateTransferRing ( Create XHCI event ring. @param Xhc The XHCI Instance. - @param EventInterrupter The interrupter of event. @param EventRing The created event ring. **/ VOID CreateEventRing ( IN USB_XHCI_INSTANCE *Xhc, - IN UINT8 EventInterrupter, OUT EVENT_RING *EventRing ); @@ -1064,6 +1319,88 @@ XhcRecoverHaltedEndpoint ( 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. + + @param Xhc The XHCI Instance. + @param Urb The urb which doesn't get completed in a specified timeout range. + + @retval EFI_SUCCESS The dequeuing of the TDs is successful. + @retval Others Failed to stop the endpoint and dequeue the TDs. + +**/ +EFI_STATUS +EFIAPI +XhcDequeueTrbFromEndpoint ( + IN USB_XHCI_INSTANCE *Xhc, + IN URB *Urb + ); + +/** + Stop endpoint through XHCI's Stop_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param Dci The device context index of endpoint. + @param PendingUrb The pending URB to check completion status when stopping the end point. + + @retval EFI_SUCCESS Stop endpoint successfully. + @retval Others Failed to stop endpoint. + +**/ +EFI_STATUS +EFIAPI +XhcStopEndpoint ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 Dci, + IN URB *PendingUrb OPTIONAL + ); + +/** + Reset endpoint through XHCI's Reset_Endpoint cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param Dci The device context index of endpoint. + + @retval EFI_SUCCESS Reset endpoint successfully. + @retval Others Failed to reset endpoint. + +**/ +EFI_STATUS +EFIAPI +XhcResetEndpoint ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 Dci + ); + +/** + Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd. + + @param Xhc The XHCI Instance. + @param SlotId The slot id to be configured. + @param Dci The device context index of endpoint. + @param Urb The dequeue pointer of the transfer ring specified + by the urb to be updated. + + @retval EFI_SUCCESS Set transfer ring dequeue pointer succeeds. + @retval Others Failed to set transfer ring dequeue pointer. + +**/ +EFI_STATUS +EFIAPI +XhcSetTrDequeuePointer ( + IN USB_XHCI_INSTANCE *Xhc, + IN UINT8 SlotId, + IN UINT8 Dci, + IN URB *Urb + ); + /** Create a new URB for a new transaction. @@ -1097,6 +1434,19 @@ XhcCreateUrb ( IN VOID *Context ); +/** + Free an allocated URB. + + @param Xhc The XHCI device. + @param Urb The URB to free. + +**/ +VOID +XhcFreeUrb ( + IN USB_XHCI_INSTANCE *Xhc, + IN URB *Urb + ); + /** Create a transfer TRB.