TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiUsbLib.c
Go to the documentation of this file.
1
10#include "UsbPeim.h"
11#include "PeiUsbLib.h"
12
29 IN EFI_PEI_SERVICES **PeiServices,
30 IN PEI_USB_IO_PPI *UsbIoPpi,
31 IN EFI_USB_RECIPIENT Recipient,
32 IN UINT16 Value,
33 IN UINT16 Target
34 )
35{
37
38 ASSERT (UsbIoPpi != NULL);
39
40 switch (Recipient) {
41 case EfiUsbDevice:
42 DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
43 break;
44
45 case EfiUsbInterface:
46 DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
47 break;
48
49 case EfiUsbEndpoint:
50 DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
51 break;
52 }
53
54 DevReq.Request = USB_DEV_CLEAR_FEATURE;
55 DevReq.Value = Value;
56 DevReq.Index = Target;
57 DevReq.Length = 0;
58
59 return UsbIoPpi->UsbControlTransfer (
60 PeiServices,
61 UsbIoPpi,
62 &DevReq,
63 EfiUsbNoData,
64 PcdGet32 (PcdUsbTransferTimeoutValue),
65 NULL,
66 0
67 );
68}
69
84 IN EFI_PEI_SERVICES **PeiServices,
85 IN PEI_USB_IO_PPI *UsbIoPpi,
86 IN UINT8 EndpointAddress
87 )
88{
89 EFI_STATUS Status;
90 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
91 EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
92 UINT8 EndpointIndex;
93
94 //
95 // Check its interface
96 //
97 Status = UsbIoPpi->UsbGetInterfaceDescriptor (
98 PeiServices,
99 UsbIoPpi,
100 &InterfaceDesc
101 );
102 if (EFI_ERROR (Status)) {
103 return Status;
104 }
105
106 for (EndpointIndex = 0; EndpointIndex < InterfaceDesc->NumEndpoints; EndpointIndex++) {
107 Status = UsbIoPpi->UsbGetEndpointDescriptor (PeiServices, UsbIoPpi, EndpointIndex, &EndpointDescriptor);
108 if (EFI_ERROR (Status)) {
109 return EFI_INVALID_PARAMETER;
110 }
111
112 if (EndpointDescriptor->EndpointAddress == EndpointAddress) {
113 break;
114 }
115 }
116
117 if (EndpointIndex == InterfaceDesc->NumEndpoints) {
118 return EFI_INVALID_PARAMETER;
119 }
120
121 Status = PeiUsbClearDeviceFeature (
122 PeiServices,
123 UsbIoPpi,
124 EfiUsbEndpoint,
125 EfiUsbEndpointHalt,
126 EndpointAddress
127 );
128
129 return Status;
130}
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS PeiUsbClearDeviceFeature(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *UsbIoPpi, IN EFI_USB_RECIPIENT Recipient, IN UINT16 Value, IN UINT16 Target)
Definition: PeiUsbLib.c:28
EFI_STATUS PeiUsbClearEndpointHalt(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *UsbIoPpi, IN UINT8 EndpointAddress)
Definition: PeiUsbLib.c:83