2 Common Libarary for PEI USB.
4 Copyright (c) 2006 - 2018, 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.
18 #include "PeiUsbLib.h"
22 Clear a given usb feature.
24 @param PeiServices General-purpose services that are available to every PEIM.
25 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
26 @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
27 @param Value Request Value.
28 @param Target Request Index.
30 @retval EFI_SUCCESS Usb feature is cleared successfully.
31 @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.
32 @retval Others Other failure occurs.
36 PeiUsbClearDeviceFeature (
37 IN EFI_PEI_SERVICES
**PeiServices
,
38 IN PEI_USB_IO_PPI
*UsbIoPpi
,
39 IN EFI_USB_RECIPIENT Recipient
,
44 EFI_USB_DEVICE_REQUEST DevReq
;
46 ASSERT (UsbIoPpi
!= NULL
);
50 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_D
;
54 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_I
;
58 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_E
;
62 DevReq
.Request
= USB_DEV_CLEAR_FEATURE
;
64 DevReq
.Index
= Target
;
67 return UsbIoPpi
->UsbControlTransfer (
72 PcdGet32 (PcdUsbTransferTimeoutValue
),
82 @param PeiServices General-purpose services that are available to every PEIM.
83 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
84 @param EndpointAddress The endpoint address.
86 @retval EFI_SUCCESS Endpoint halt is cleared successfully.
87 @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.
88 @retval Others Other failure occurs.
92 PeiUsbClearEndpointHalt (
93 IN EFI_PEI_SERVICES
**PeiServices
,
94 IN PEI_USB_IO_PPI
*UsbIoPpi
,
95 IN UINT8 EndpointAddress
99 EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDesc
;
100 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
;
105 // Check its interface
107 Status
= UsbIoPpi
->UsbGetInterfaceDescriptor (
112 if (EFI_ERROR (Status
)) {
115 for (EndpointIndex
= 0; EndpointIndex
< InterfaceDesc
->NumEndpoints
; EndpointIndex
++) {
116 Status
= UsbIoPpi
->UsbGetEndpointDescriptor (PeiServices
, UsbIoPpi
, EndpointIndex
, &EndpointDescriptor
);
117 if (EFI_ERROR (Status
)) {
118 return EFI_INVALID_PARAMETER
;
121 if (EndpointDescriptor
->EndpointAddress
== EndpointAddress
) {
126 if (EndpointIndex
== InterfaceDesc
->NumEndpoints
) {
127 return EFI_INVALID_PARAMETER
;
130 Status
= PeiUsbClearDeviceFeature (