2 Private Header file for Usb Host Controller PEIM
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _RECOVERY_UHC_H_
18 #define _RECOVERY_UHC_H_
23 #include <Ppi/UsbController.h>
24 #include <Ppi/UsbHostController.h>
26 #include <Library/DebugLib.h>
27 #include <Library/PeimEntryPoint.h>
28 #include <Library/PeiServicesLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/TimerLib.h>
31 #include <Library/IoLib.h>
32 #include <Library/PeiServicesLib.h>
34 #define USB_SLOW_SPEED_DEVICE 0x01
35 #define USB_FULL_SPEED_DEVICE 0x02
38 // One memory block uses 16 page
40 #define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 16
42 #define USBCMD 0 /* Command Register Offset 00-01h */
43 #define USBCMD_RS BIT0 /* Run/Stop */
44 #define USBCMD_HCRESET BIT1 /* Host reset */
45 #define USBCMD_GRESET BIT2 /* Global reset */
46 #define USBCMD_EGSM BIT3 /* Global Suspend Mode */
47 #define USBCMD_FGR BIT4 /* Force Global Resume */
48 #define USBCMD_SWDBG BIT5 /* SW Debug mode */
49 #define USBCMD_CF BIT6 /* Config Flag (sw only) */
50 #define USBCMD_MAXP BIT7 /* Max Packet (0 = 32, 1 = 64) */
53 #define USBSTS 2 /* Status Register Offset 02-03h */
54 #define USBSTS_USBINT BIT0 /* Interrupt due to IOC */
55 #define USBSTS_ERROR BIT1 /* Interrupt due to error */
56 #define USBSTS_RD BIT2 /* Resume Detect */
57 #define USBSTS_HSE BIT3 /* Host System Error - basically PCI problems */
58 #define USBSTS_HCPE BIT4 /* Host Controller Process Error - the scripts were buggy */
59 #define USBSTS_HCH BIT5 /* HC Halted */
61 /* Interrupt enable register */
62 #define USBINTR 4 /* Interrupt Enable Register 04-05h */
63 #define USBINTR_TIMEOUT BIT0 /* Timeout/CRC error enable */
64 #define USBINTR_RESUME BIT1 /* Resume interrupt enable */
65 #define USBINTR_IOC BIT2 /* Interrupt On Complete enable */
66 #define USBINTR_SP BIT3 /* Short packet interrupt enable */
68 /* Frame Number Register Offset 06-08h */
71 /* Frame List Base Address Register Offset 08-0Bh */
72 #define USBFLBASEADD 8
74 /* Start of Frame Modify Register Offset 0Ch */
77 /* USB port status and control registers */
78 #define USBPORTSC1 0x10 /*Port 1 offset 10-11h */
79 #define USBPORTSC2 0x12 /*Port 2 offset 12-13h */
81 #define USBPORTSC_CCS BIT0 /* Current Connect Status ("device present") */
82 #define USBPORTSC_CSC BIT1 /* Connect Status Change */
83 #define USBPORTSC_PED BIT2 /* Port Enable / Disable */
84 #define USBPORTSC_PEDC BIT3 /* Port Enable / Disable Change */
85 #define USBPORTSC_LSL BIT4 /* Line Status Low bit*/
86 #define USBPORTSC_LSH BIT5 /* Line Status High bit*/
87 #define USBPORTSC_RD BIT6 /* Resume Detect */
88 #define USBPORTSC_LSDA BIT8 /* Low Speed Device Attached */
89 #define USBPORTSC_PR BIT9 /* Port Reset */
90 #define USBPORTSC_SUSP BIT12 /* Suspend */
92 #define SETUP_PACKET_ID 0x2D
93 #define INPUT_PACKET_ID 0x69
94 #define OUTPUT_PACKET_ID 0xE1
95 #define ERROR_PACKET_ID 0x55
97 #define STALL_1_MICRO_SECOND 1
98 #define STALL_1_MILLI_SECOND 1000
104 UINT32 FrameListPtrTerminate
: 1;
105 UINT32 FrameListPtrQSelect
: 1;
106 UINT32 FrameListRsvd
: 2;
107 UINT32 FrameListPtr
: 28;
111 UINT32 QHHorizontalTerminate
: 1;
112 UINT32 QHHorizontalQSelect
: 1;
113 UINT32 QHHorizontalRsvd
: 2;
114 UINT32 QHHorizontalPtr
: 28;
115 UINT32 QHVerticalTerminate
: 1;
116 UINT32 QHVerticalQSelect
: 1;
117 UINT32 QHVerticalRsvd
: 2;
118 UINT32 QHVerticalPtr
: 28;
122 QUEUE_HEAD QueueHead
;
132 UINT32 TDLinkPtrTerminate
: 1;
133 UINT32 TDLinkPtrQSelect
: 1;
134 UINT32 TDLinkPtrDepthSelect
: 1;
135 UINT32 TDLinkPtrRsvd
: 1;
136 UINT32 TDLinkPtr
: 28;
137 UINT32 TDStatusActualLength
: 11;
138 UINT32 TDStatusRsvd
: 5;
140 UINT32 TDStatusIOC
: 1;
141 UINT32 TDStatusIOS
: 1;
142 UINT32 TDStatusLS
: 1;
143 UINT32 TDStatusErr
: 2;
144 UINT32 TDStatusSPD
: 1;
145 UINT32 TDStatusRsvd2
: 2;
146 UINT32 TDTokenPID
: 8;
147 UINT32 TDTokenDevAddr
: 7;
148 UINT32 TDTokenEndPt
: 4;
149 UINT32 TDTokenDataToggle
: 1;
150 UINT32 TDTokenRsvd
: 1;
151 UINT32 TDTokenMaxLen
: 11;
160 UINT16 TDBufferLength
;
166 typedef struct _MEMORY_MANAGE_HEADER MEMORY_MANAGE_HEADER
;
168 struct _MEMORY_MANAGE_HEADER
{
170 UINTN BitArraySizeInBytes
;
171 UINT8
*MemoryBlockPtr
;
172 UINTN MemoryBlockSizeInBytes
;
173 MEMORY_MANAGE_HEADER
*Next
;
176 #define USB_UHC_DEV_SIGNATURE SIGNATURE_32 ('p', 'u', 'h', 'c')
179 PEI_USB_HOST_CONTROLLER_PPI UsbHostControllerPpi
;
180 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
182 UINT32 UsbHostControllerBaseAddress
;
183 FRAMELIST_ENTRY
*FrameListEntry
;
187 // Header1 used for QH,TD memory blocks management
189 MEMORY_MANAGE_HEADER
*Header1
;
193 #define PEI_RECOVERY_USB_UHC_DEV_FROM_UHCI_THIS(a) CR (a, USB_UHC_DEV, UsbHostControllerPpi, USB_UHC_DEV_SIGNATURE)
196 Submits control transfer to a target USB device.
198 @param PeiServices The pointer of EFI_PEI_SERVICES.
199 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
200 @param DeviceAddress The target device address.
201 @param DeviceSpeed Target device speed.
202 @param MaximumPacketLength Maximum packet size the default control transfer
203 endpoint is capable of sending or receiving.
204 @param Request USB device request to send.
205 @param TransferDirection Specifies the data direction for the data stage.
206 @param Data Data buffer to be transmitted or received from USB device.
207 @param DataLength The size (in bytes) of the data buffer.
208 @param TimeOut Indicates the maximum timeout, in millisecond.
209 @param TransferResult Return the result of this control transfer.
211 @retval EFI_SUCCESS Transfer was completed successfully.
212 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.
213 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
214 @retval EFI_TIMEOUT Transfer failed due to timeout.
215 @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.
221 IN EFI_PEI_SERVICES
**PeiServices
,
222 IN PEI_USB_HOST_CONTROLLER_PPI
* This
,
223 IN UINT8 DeviceAddress
,
224 IN UINT8 DeviceSpeed
,
225 IN UINT8 MaximumPacketLength
,
226 IN EFI_USB_DEVICE_REQUEST
* Request
,
227 IN EFI_USB_DATA_DIRECTION TransferDirection
,
228 IN OUT VOID
*Data OPTIONAL
,
229 IN OUT UINTN
*DataLength OPTIONAL
,
231 OUT UINT32
*TransferResult
235 Submits bulk transfer to a bulk endpoint of a USB device.
237 @param PeiServices The pointer of EFI_PEI_SERVICES.
238 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
239 @param DeviceAddress Target device address.
240 @param EndPointAddress Endpoint number and its direction in bit 7.
241 @param MaximumPacketLength Maximum packet size the endpoint is capable of
242 sending or receiving.
243 @param Data Array of pointers to the buffers of data to transmit
244 from or receive into.
245 @param DataLength The lenght of the data buffer.
246 @param DataToggle On input, the initial data toggle for the transfer;
247 On output, it is updated to to next data toggle to use of
248 the subsequent bulk transfer.
249 @param TimeOut Indicates the maximum time, in millisecond, which the
250 transfer is allowed to complete.
251 @param TransferResult A pointer to the detailed result information of the
254 @retval EFI_SUCCESS The transfer was completed successfully.
255 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.
256 @retval EFI_INVALID_PARAMETER Parameters are invalid.
257 @retval EFI_TIMEOUT The transfer failed due to timeout.
258 @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.
264 IN EFI_PEI_SERVICES
**PeiServices
,
265 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
266 IN UINT8 DeviceAddress
,
267 IN UINT8 EndPointAddress
,
268 IN UINT8 MaximumPacketLength
,
270 IN OUT UINTN
*DataLength
,
271 IN OUT UINT8
*DataToggle
,
273 OUT UINT32
*TransferResult
277 Retrieves the number of root hub ports.
279 @param[in] PeiServices The pointer to the PEI Services Table.
280 @param[in] This The pointer to this instance of the
281 PEI_USB_HOST_CONTROLLER_PPI.
282 @param[out] PortNumber The pointer to the number of the root hub ports.
284 @retval EFI_SUCCESS The port number was retrieved successfully.
285 @retval EFI_INVALID_PARAMETER PortNumber is NULL.
290 UhcGetRootHubPortNumber (
291 IN EFI_PEI_SERVICES
**PeiServices
,
292 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
293 OUT UINT8
*PortNumber
297 Retrieves the current status of a USB root hub port.
299 @param PeiServices The pointer of EFI_PEI_SERVICES.
300 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
301 @param PortNumber The root hub port to retrieve the state from.
302 @param PortStatus Variable to receive the port state.
304 @retval EFI_SUCCESS The status of the USB root hub port specified.
305 by PortNumber was returned in PortStatus.
306 @retval EFI_INVALID_PARAMETER PortNumber is invalid.
311 UhcGetRootHubPortStatus (
312 IN EFI_PEI_SERVICES
**PeiServices
,
313 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
315 OUT EFI_USB_PORT_STATUS
*PortStatus
319 Sets a feature for the specified root hub port.
321 @param PeiServices The pointer of EFI_PEI_SERVICES
322 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI
323 @param PortNumber Root hub port to set.
324 @param PortFeature Feature to set.
326 @retval EFI_SUCCESS The feature specified by PortFeature was set.
327 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
328 @retval EFI_TIMEOUT The time out occurred.
333 UhcSetRootHubPortFeature (
334 IN EFI_PEI_SERVICES
**PeiServices
,
335 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
337 IN EFI_USB_PORT_FEATURE PortFeature
341 Clears a feature for the specified root hub port.
343 @param PeiServices The pointer of EFI_PEI_SERVICES.
344 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
345 @param PortNumber Specifies the root hub port whose feature
346 is requested to be cleared.
347 @param PortFeature Indicates the feature selector associated with the
348 feature clear request.
350 @retval EFI_SUCCESS The feature specified by PortFeature was cleared
351 for the USB root hub port specified by PortNumber.
352 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
357 UhcClearRootHubPortFeature (
358 IN EFI_PEI_SERVICES
**PeiServices
,
359 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
361 IN EFI_USB_PORT_FEATURE PortFeature
367 @param UhcDev UHCI Device.
369 @retval EFI_SUCCESS UHCI successfully initialized.
370 @retval EFI_OUT_OF_RESOURCES Resource can not be allocated.
375 IN USB_UHC_DEV
*UhcDev
379 Create Frame List Structure.
381 @param UhcDev UHCI device.
383 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
384 @retval EFI_SUCCESS Success.
393 Read a 16bit width data from Uhc HC IO space register.
395 @param UhcDev The UHCI device.
396 @param Port The IO space address of the register.
398 @retval the register content read.
403 IN USB_UHC_DEV
*UhcDev
,
408 Write a 16bit width data into Uhc HC IO space register.
410 @param UhcDev The UHCI device.
411 @param Port The IO space address of the register.
412 @param Data The data written into the register.
417 IN USB_UHC_DEV
*UhcDev
,
423 Write a 32bit width data into Uhc HC IO space register.
425 @param UhcDev The UHCI device.
426 @param Port The IO space address of the register.
427 @param Data The data written into the register.
432 IN USB_UHC_DEV
*UhcDev
,
438 Clear the content of UHCI's Status Register.
440 @param UhcDev The UHCI device.
441 @param StatusAddr The IO space address of the register.
446 IN USB_UHC_DEV
*UhcDev
,
451 Check whether the host controller operates well.
453 @param UhcDev The UHCI device.
454 @param StatusRegAddr The io address of status register.
456 @retval TRUE Host controller is working.
457 @retval FALSE Host controller is halted or system error.
462 IN USB_UHC_DEV
*UhcDev
,
463 IN UINT32 StatusRegAddr
467 Get Current Frame Number.
469 @param UhcDev The UHCI device.
470 @param FrameNumberAddr The address of frame list register.
472 @retval The content of the frame list register.
476 GetCurrentFrameNumber (
477 IN USB_UHC_DEV
*UhcDev
,
478 IN UINT32 FrameNumberAddr
482 Set Frame List Base Address.
484 @param UhcDev The UHCI device.
485 @param FrameListRegAddr The address of frame list register.
486 @param Addr The address of frame list table.
490 SetFrameListBaseAddress (
491 IN USB_UHC_DEV
*UhcDev
,
492 IN UINT32 FrameListRegAddr
,
497 Create QH and initialize.
499 @param UhcDev The UHCI device.
500 @param PtrQH Place to store QH_STRUCT pointer.
502 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
503 @retval EFI_SUCCESS Success.
508 IN USB_UHC_DEV
*UhcDev
,
509 OUT QH_STRUCT
**PtrQH
513 Set the horizontal link pointer in QH.
515 @param PtrQH Place to store QH_STRUCT pointer.
516 @param PtrNext Place to the next QH_STRUCT.
520 SetQHHorizontalLinkPtr (
526 Get the horizontal link pointer in QH.
528 @param PtrQH Place to store QH_STRUCT pointer.
530 @retval The horizontal link pointer in QH.
534 GetQHHorizontalLinkPtr (
539 Set a QH or TD horizontally to be connected with a specific QH.
541 @param PtrQH Place to store QH_STRUCT pointer.
542 @param IsQH Specify QH or TD is connected.
546 SetQHHorizontalQHorTDSelect (
552 Set the horizontal validor bit in QH.
554 @param PtrQH Place to store QH_STRUCT pointer.
555 @param IsValid Specify the horizontal linker is valid or not.
559 SetQHHorizontalValidorInvalid (
565 Set the vertical link pointer in QH.
567 @param PtrQH Place to store QH_STRUCT pointer.
568 @param PtrNext Place to the next QH_STRUCT.
572 SetQHVerticalLinkPtr (
578 Set a QH or TD vertically to be connected with a specific QH.
580 @param PtrQH Place to store QH_STRUCT pointer.
581 @param IsQH Specify QH or TD is connected.
585 SetQHVerticalQHorTDSelect (
591 Set the vertical validor bit in QH.
593 @param PtrQH Place to store QH_STRUCT pointer.
594 @param IsValid Specify the vertical linker is valid or not.
598 SetQHVerticalValidorInvalid (
604 Get the vertical validor bit in QH.
606 @param PtrQH Place to store QH_STRUCT pointer.
608 @retval The vertical linker is valid or not.
612 GetQHHorizontalValidorInvalid (
617 Allocate TD or QH Struct.
619 @param UhcDev The UHCI device.
620 @param Size The size of allocation.
621 @param PtrStruct Place to store TD_STRUCT pointer.
623 @return EFI_SUCCESS Allocate successfully.
624 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
628 AllocateTDorQHStruct (
629 IN USB_UHC_DEV
*UhcDev
,
637 @param UhcDev The UHCI device.
638 @param PtrTD Place to store TD_STRUCT pointer.
640 @return EFI_SUCCESS Allocate successfully.
641 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
646 IN USB_UHC_DEV
*UhcDev
,
647 OUT TD_STRUCT
**PtrTD
651 Generate Setup Stage TD.
653 @param UhcDev The UHCI device.
654 @param DevAddr Device address.
655 @param Endpoint Endpoint number.
656 @param DeviceSpeed Device Speed.
657 @param DevRequest Device reuquest.
658 @param RequestLen Request length.
659 @param PtrTD TD_STRUCT generated.
661 @return EFI_SUCCESS Generate setup stage TD successfully.
662 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
667 IN USB_UHC_DEV
*UhcDev
,
670 IN UINT8 DeviceSpeed
,
671 IN UINT8
*DevRequest
,
673 OUT TD_STRUCT
**PtrTD
677 Generate Data Stage TD.
679 @param UhcDev The UHCI device.
680 @param DevAddr Device address.
681 @param Endpoint Endpoint number.
682 @param PtrData Data buffer.
683 @param Len Data length.
684 @param PktID PacketID.
685 @param Toggle Data toggle value.
686 @param DeviceSpeed Device Speed.
687 @param PtrTD TD_STRUCT generated.
689 @return EFI_SUCCESS Generate data stage TD successfully.
690 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
695 IN USB_UHC_DEV
*UhcDev
,
702 IN UINT8 DeviceSpeed
,
703 OUT TD_STRUCT
**PtrTD
707 Generate Status Stage TD.
709 @param UhcDev The UHCI device.
710 @param DevAddr Device address.
711 @param Endpoint Endpoint number.
712 @param PktID PacketID.
713 @param DeviceSpeed Device Speed.
714 @param PtrTD TD_STRUCT generated.
716 @return EFI_SUCCESS Generate status stage TD successfully.
717 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
722 IN USB_UHC_DEV
*UhcDev
,
726 IN UINT8 DeviceSpeed
,
727 OUT TD_STRUCT
**PtrTD
731 Set the link pointer validor bit in TD.
733 @param PtrTDStruct Place to store TD_STRUCT pointer.
734 @param IsValid Specify the linker pointer is valid or not.
738 SetTDLinkPtrValidorInvalid (
739 IN TD_STRUCT
*PtrTDStruct
,
744 Set the Link Pointer pointing to a QH or TD.
746 @param PtrTDStruct Place to store TD_STRUCT pointer.
747 @param IsQH Specify QH or TD is connected.
751 SetTDLinkPtrQHorTDSelect (
752 IN TD_STRUCT
*PtrTDStruct
,
757 Set the traverse is depth-first or breadth-first.
759 @param PtrTDStruct Place to store TD_STRUCT pointer.
760 @param IsDepth Specify the traverse is depth-first or breadth-first.
764 SetTDLinkPtrDepthorBreadth (
765 IN TD_STRUCT
*PtrTDStruct
,
770 Set TD Link Pointer in TD.
772 @param PtrTDStruct Place to store TD_STRUCT pointer.
773 @param PtrNext Place to the next TD_STRUCT.
778 IN TD_STRUCT
*PtrTDStruct
,
785 @param PtrTDStruct Place to store TD_STRUCT pointer.
787 @retval Get TD Link Pointer in TD.
792 IN TD_STRUCT
*PtrTDStruct
796 Get the information about whether the Link Pointer field pointing to
799 @param PtrTDStruct Place to store TD_STRUCT pointer.
801 @retval whether the Link Pointer field pointing to a QH or a TD.
806 IN TD_STRUCT
*PtrTDStruct
810 Enable/Disable short packet detection mechanism.
812 @param PtrTDStruct Place to store TD_STRUCT pointer.
813 @param IsEnable Enable or disable short packet detection mechanism.
817 EnableorDisableTDShortPacket (
818 IN TD_STRUCT
*PtrTDStruct
,
823 Set the max error counter in TD.
825 @param PtrTDStruct Place to store TD_STRUCT pointer.
826 @param MaxErrors The number of allowable error.
830 SetTDControlErrorCounter (
831 IN TD_STRUCT
*PtrTDStruct
,
836 Set the TD is targeting a low-speed device or not.
838 @param PtrTDStruct Place to store TD_STRUCT pointer.
839 @param IsLowSpeedDevice Whether The device is low-speed.
843 SetTDLoworFullSpeedDevice (
844 IN TD_STRUCT
*PtrTDStruct
,
845 IN BOOLEAN IsLowSpeedDevice
849 Set the TD is isochronous transfer type or not.
851 @param PtrTDStruct Place to store TD_STRUCT pointer.
852 @param IsIsochronous Whether the transaction isochronous transfer type.
856 SetTDControlIsochronousorNot (
857 IN TD_STRUCT
*PtrTDStruct
,
858 IN BOOLEAN IsIsochronous
862 Set if UCHI should issue an interrupt on completion of the frame
863 in which this TD is executed
865 @param PtrTDStruct Place to store TD_STRUCT pointer.
866 @param IsSet Whether HC should issue an interrupt on completion.
870 SetorClearTDControlIOC (
871 IN TD_STRUCT
*PtrTDStruct
,
876 Set if the TD is active and can be executed.
878 @param PtrTDStruct Place to store TD_STRUCT pointer.
879 @param IsActive Whether the TD is active and can be executed.
883 SetTDStatusActiveorInactive (
884 IN TD_STRUCT
*PtrTDStruct
,
889 Specifies the maximum number of data bytes allowed for the transfer.
891 @param PtrTDStruct Place to store TD_STRUCT pointer.
892 @param MaxLen The maximum number of data bytes allowed.
894 @retval The allowed maximum number of data.
897 SetTDTokenMaxLength (
898 IN TD_STRUCT
*PtrTDStruct
,
903 Set the data toggle bit to DATA1.
905 @param PtrTDStruct Place to store TD_STRUCT pointer.
909 SetTDTokenDataToggle1 (
910 IN TD_STRUCT
*PtrTDStruct
914 Set the data toggle bit to DATA0.
916 @param PtrTDStruct Place to store TD_STRUCT pointer.
920 SetTDTokenDataToggle0 (
921 IN TD_STRUCT
*PtrTDStruct
925 Set EndPoint Number the TD is targeting at.
927 @param PtrTDStruct Place to store TD_STRUCT pointer.
928 @param EndPoint The Endport number of the target.
933 IN TD_STRUCT
*PtrTDStruct
,
938 Set Device Address the TD is targeting at.
940 @param PtrTDStruct Place to store TD_STRUCT pointer.
941 @param DevAddr The Device Address of the target.
945 SetTDTokenDeviceAddress (
946 IN TD_STRUCT
*PtrTDStruct
,
951 Set Packet Identification the TD is targeting at.
953 @param PtrTDStruct Place to store TD_STRUCT pointer.
954 @param PacketID The Packet Identification of the target.
959 IN TD_STRUCT
*PtrTDStruct
,
964 Set the beginning address of the data buffer that will be used
965 during the transaction.
967 @param PtrTDStruct Place to store TD_STRUCT pointer.
972 IN TD_STRUCT
*PtrTDStruct
976 Detect whether the TD is active.
978 @param PtrTDStruct Place to store TD_STRUCT pointer.
980 @retval The TD is active or not.
985 IN TD_STRUCT
*PtrTDStruct
989 Detect whether the TD is stalled.
991 @param PtrTDStruct Place to store TD_STRUCT pointer.
993 @retval The TD is stalled or not.
998 IN TD_STRUCT
*PtrTDStruct
1002 Detect whether Data Buffer Error is happened.
1004 @param PtrTDStruct Place to store TD_STRUCT pointer.
1006 @retval The Data Buffer Error is happened or not.
1010 IsTDStatusBufferError (
1011 IN TD_STRUCT
*PtrTDStruct
1015 Detect whether Babble Error is happened.
1017 @param PtrTDStruct Place to store TD_STRUCT pointer.
1019 @retval The Babble Error is happened or not.
1023 IsTDStatusBabbleError (
1024 IN TD_STRUCT
*PtrTDStruct
1028 Detect whether NAK is received.
1030 @param PtrTDStruct Place to store TD_STRUCT pointer.
1032 @retval The NAK is received or not.
1036 IsTDStatusNAKReceived (
1037 IN TD_STRUCT
*PtrTDStruct
1041 Detect whether CRC/Time Out Error is encountered.
1043 @param PtrTDStruct Place to store TD_STRUCT pointer.
1045 @retval The CRC/Time Out Error is encountered or not.
1049 IsTDStatusCRCTimeOutError (
1050 IN TD_STRUCT
*PtrTDStruct
1054 Detect whether Bitstuff Error is received.
1056 @param PtrTDStruct Place to store TD_STRUCT pointer.
1058 @retval The Bitstuff Error is received or not.
1062 IsTDStatusBitStuffError (
1063 IN TD_STRUCT
*PtrTDStruct
1067 Retrieve the actual number of bytes that were tansferred.
1069 @param PtrTDStruct Place to store TD_STRUCT pointer.
1071 @retval The actual number of bytes that were tansferred.
1075 GetTDStatusActualLength (
1076 IN TD_STRUCT
*PtrTDStruct
1080 Retrieve the information of whether the Link Pointer field is valid or not.
1082 @param PtrTDStruct Place to store TD_STRUCT pointer.
1084 @retval The linker pointer field is valid or not.
1088 GetTDLinkPtrValidorInvalid (
1089 IN TD_STRUCT
*PtrTDStruct
1093 Count TD Number from PtrFirstTD.
1095 @param PtrFirstTD Place to store TD_STRUCT pointer.
1097 @retval The queued TDs number.
1102 IN TD_STRUCT
*PtrFirstTD
1108 @param PtrQH Place to store QH_STRUCT pointer.
1109 @param PtrTD Place to store TD_STRUCT pointer.
1114 IN QH_STRUCT
*PtrQH
,
1121 @param PtrPreTD Place to store TD_STRUCT pointer.
1122 @param PtrTD Place to store TD_STRUCT pointer.
1127 IN TD_STRUCT
*PtrPreTD
,
1132 Execute Control Transfer.
1134 @param UhcDev The UCHI device.
1135 @param PtrTD A pointer to TD_STRUCT data.
1136 @param ActualLen Actual transfer Length.
1137 @param TimeOut TimeOut value.
1138 @param TransferResult Transfer Result.
1140 @return EFI_DEVICE_ERROR The transfer failed due to transfer error.
1141 @return EFI_TIMEOUT The transfer failed due to time out.
1142 @return EFI_SUCCESS The transfer finished OK.
1146 ExecuteControlTransfer (
1147 IN USB_UHC_DEV
*UhcDev
,
1148 IN TD_STRUCT
*PtrTD
,
1149 OUT UINTN
*ActualLen
,
1151 OUT UINT32
*TransferResult
1155 Execute Bulk Transfer.
1157 @param UhcDev The UCHI device.
1158 @param PtrTD A pointer to TD_STRUCT data.
1159 @param ActualLen Actual transfer Length.
1160 @param DataToggle DataToggle value.
1161 @param TimeOut TimeOut value.
1162 @param TransferResult Transfer Result.
1164 @return EFI_DEVICE_ERROR The transfer failed due to transfer error.
1165 @return EFI_TIMEOUT The transfer failed due to time out.
1166 @return EFI_SUCCESS The transfer finished OK.
1171 IN USB_UHC_DEV
*UhcDev
,
1172 IN TD_STRUCT
*PtrTD
,
1173 IN OUT UINTN
*ActualLen
,
1174 IN UINT8
*DataToggle
,
1176 OUT UINT32
*TransferResult
1182 @param UhcDev The UCHI device.
1183 @param PtrFirstTD Place to store TD_STRUCT pointer.
1188 IN USB_UHC_DEV
*UhcDev
,
1189 IN TD_STRUCT
*PtrFirstTD
1195 @param PtrTD A pointer to TD_STRUCT data.
1196 @param Result The result to return.
1197 @param ErrTDPos The Error TD position.
1198 @param ActualTransferSize Actual transfer size.
1200 @retval The TD is executed successfully or not.
1205 IN TD_STRUCT
*PtrTD
,
1207 OUT UINTN
*ErrTDPos
,
1208 OUT UINTN
*ActualTransferSize
1212 Create Memory Block.
1214 @param UhcDev The UCHI device.
1215 @param MemoryHeader The Pointer to allocated memory block.
1216 @param MemoryBlockSizeInPages The page size of memory block to be allocated.
1218 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
1219 @retval EFI_SUCCESS Success.
1224 IN USB_UHC_DEV
*UhcDev
,
1225 OUT MEMORY_MANAGE_HEADER
**MemoryHeader
,
1226 IN UINTN MemoryBlockSizeInPages
1230 Initialize UHCI memory management.
1232 @param UhcDev The UCHI device.
1234 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
1235 @retval EFI_SUCCESS Success.
1239 InitializeMemoryManagement (
1240 IN USB_UHC_DEV
*UhcDev
1244 Initialize UHCI memory management.
1246 @param UhcDev The UCHI device.
1247 @param Pool Buffer pointer to store the buffer pointer.
1248 @param AllocSize The size of the pool to be allocated.
1250 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
1251 @retval EFI_SUCCESS Success.
1256 IN USB_UHC_DEV
*UhcDev
,
1262 Alloc Memory In MemoryBlock.
1264 @param MemoryHeader The pointer to memory manage header.
1265 @param Pool Buffer pointer to store the buffer pointer.
1266 @param NumberOfMemoryUnit The size of the pool to be allocated.
1268 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
1269 @retval EFI_SUCCESS Success.
1273 AllocMemInMemoryBlock (
1274 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
1276 IN UINTN NumberOfMemoryUnit
1282 @param UhcDev The UHCI device.
1283 @param Pool A pointer to store the buffer address.
1284 @param AllocSize The size of the pool to be freed.
1289 IN USB_UHC_DEV
*UhcDev
,
1295 Insert a new memory header into list.
1297 @param MemoryHeader A pointer to the memory header list.
1298 @param NewMemoryHeader A new memory header to be inserted into the list.
1302 InsertMemoryHeaderToList (
1303 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
1304 IN MEMORY_MANAGE_HEADER
*NewMemoryHeader
1308 Judge the memory block in the memory header is empty or not.
1310 @param MemoryHeaderPtr A pointer to the memory header list.
1312 @retval Whether the memory block in the memory header is empty or not.
1316 IsMemoryBlockEmptied (
1317 IN MEMORY_MANAGE_HEADER
*MemoryHeaderPtr
1321 remove a memory header from list.
1323 @param FirstMemoryHeader A pointer to the memory header list.
1324 @param FreeMemoryHeader A memory header to be removed into the list.
1329 IN MEMORY_MANAGE_HEADER
*FirstMemoryHeader
,
1330 IN MEMORY_MANAGE_HEADER
*FreeMemoryHeader