-/*++\r
+/** @file\r
\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
- Module Name:\r
-\r
- UsbDxeLib.c\r
-\r
- Abstract:\r
-\r
- Common Dxe Libarary for USB\r
-\r
- Revision History\r
+ The library provides the USB Standard Device Requests defined \r
+ in Usb specification 9.4 section.\r
+ \r
+ Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are\r
+ licensed and made available under the terms and conditions of\r
+ the BSD License which accompanies this distribution. The full\r
+ text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
---*/\r
+**/\r
\r
#include "UefiUsbLibInternal.h"\r
\r
-//\r
-// Get Device Descriptor\r
-//\r
+\r
+/**\r
+ Get the descriptor of the specified USB device.\r
+\r
+ Submit a USB get descriptor request for the USB device specified by UsbIo, Value,\r
+ and Index, and return the descriptor in the buffer specified by Descriptor.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Descriptor is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
+\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Value The device request value.\r
+ @param Index The device request index.\r
+ @param DescriptorLength The size, in bytes, of Descriptor.\r
+ @param Descriptor A pointer to the descriptor buffer to get.\r
+ @param Status A pointer to the status of the transfer.\r
+\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed because the\r
+ buffer specified by DescriptorLength and Descriptor\r
+ is not large enough to hold the result of the request.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error. The transfer\r
+ status is returned in Status.\r
+\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
UsbGetDescriptor (\r
IN EFI_USB_IO_PROTOCOL *UsbIo,\r
IN UINT16 Value,\r
OUT VOID *Descriptor,\r
OUT UINT32 *Status\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Usb Get Descriptor\r
-\r
-Arguments:\r
-\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Value - Device Request Value\r
- Index - Device Request Index \r
- DescriptorLength - Descriptor Length\r
- Descriptor - Descriptor buffer to contain result\r
- Status - Transfer Status\r
-Returns:\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
---*/\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Descriptor != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;\r
- DevReq.Request = USB_DEV_GET_DESCRIPTOR;\r
+ DevReq.Request = USB_REQ_GET_DESCRIPTOR;\r
DevReq.Value = Value;\r
DevReq.Index = Index;\r
DevReq.Length = DescriptorLength;\r
UsbIo,\r
&DevReq,\r
EfiUsbDataIn,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
Descriptor,\r
DescriptorLength,\r
Status\r
);\r
}\r
-//\r
-// Set Device Descriptor\r
-//\r
+\r
+\r
+/**\r
+ Set the descriptor of the specified USB device.\r
+\r
+ Submit a USB set descriptor request for the USB device specified by UsbIo,\r
+ Value, and Index, and set the descriptor using the buffer specified by DesriptorLength\r
+ and Descriptor. The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Descriptor is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
+\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Value The device request value.\r
+ @param Index The device request index.\r
+ @param DescriptorLength The size, in bytes, of Descriptor.\r
+ @param Descriptor A pointer to the descriptor buffer to set.\r
+ @param Status A pointer to the status of the transfer.\r
+\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
+\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
UsbSetDescriptor (\r
IN EFI_USB_IO_PROTOCOL *UsbIo,\r
IN UINT16 Value,\r
IN VOID *Descriptor,\r
OUT UINT32 *Status\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Usb Set Descriptor\r
-\r
-Arguments:\r
-\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Value - Device Request Value\r
- Index - Device Request Index \r
- DescriptorLength - Descriptor Length\r
- Descriptor - Descriptor buffer to set\r
- Status - Transfer Status\r
-Returns:\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
---*/\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Descriptor != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;\r
- DevReq.Request = USB_DEV_SET_DESCRIPTOR;\r
+ DevReq.Request = USB_REQ_SET_DESCRIPTOR;\r
DevReq.Value = Value;\r
DevReq.Index = Index;\r
DevReq.Length = DescriptorLength;\r
UsbIo,\r
&DevReq,\r
EfiUsbDataOut,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
Descriptor,\r
DescriptorLength,\r
Status\r
);\r
}\r
\r
-//\r
-// Get device Interface\r
-//\r
-EFI_STATUS\r
-UsbGetDeviceInterface (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN UINT16 Index,\r
- OUT UINT8 *AltSetting,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
- Usb Get Device Interface\r
+/**\r
+ Get the interface setting of the specified USB device.\r
\r
-Arguments:\r
+ Submit a USB get interface request for the USB device specified by UsbIo,\r
+ and Interface, and place the result in the buffer specified by AlternateSetting.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If AlternateSetting is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Index - Interface index value\r
- AltSetting - Alternate setting\r
- Status - Trasnsfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Interface The interface index value.\r
+ @param AlternateSetting A pointer to the alternate setting to be retrieved.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbGetInterface (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN UINT16 Interface,\r
+ OUT UINT16 *AlternateSetting,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (AlternateSetting != NULL);\r
+ ASSERT (Status != NULL);\r
+\r
+ *AlternateSetting = 0;\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_GET_INTERFACE_REQ_TYPE;\r
- DevReq.Request = USB_DEV_GET_INTERFACE;\r
- DevReq.Index = Index;\r
+ DevReq.Request = USB_REQ_GET_INTERFACE;\r
+ DevReq.Index = Interface;\r
DevReq.Length = 1;\r
\r
return UsbIo->UsbControlTransfer (\r
UsbIo,\r
&DevReq,\r
EfiUsbDataIn,\r
- TIMEOUT_VALUE,\r
- AltSetting,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
+ AlternateSetting,\r
1,\r
Status\r
);\r
}\r
-//\r
-// Set device interface\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceInterface (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN UINT16 InterfaceNo,\r
- IN UINT16 AltSetting,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
\r
-Routine Description:\r
\r
- Usb Set Device Interface\r
+/**\r
+ Set the interface setting of the specified USB device.\r
\r
-Arguments:\r
+ Submit a USB set interface request for the USB device specified by UsbIo, and\r
+ Interface, and set the alternate setting to the value specified by AlternateSetting.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- InterfaceNo - Interface Number\r
- AltSetting - Alternate setting\r
- Status - Trasnsfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Interface The interface index value.\r
+ @param AlternateSetting The alternate setting to be set.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_SUCCESS The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbSetInterface (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN UINT16 Interface,\r
+ IN UINT16 AlternateSetting,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;\r
- DevReq.Request = USB_DEV_SET_INTERFACE;\r
- DevReq.Value = AltSetting;\r
- DevReq.Index = InterfaceNo;\r
- \r
+ DevReq.Request = USB_REQ_SET_INTERFACE;\r
+ DevReq.Value = AlternateSetting;\r
+ DevReq.Index = Interface;\r
\r
return UsbIo->UsbControlTransfer (\r
UsbIo,\r
&DevReq,\r
EfiUsbNoData,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
NULL,\r
0,\r
Status\r
);\r
}\r
-//\r
-// Get device configuration\r
-//\r
-EFI_STATUS\r
-UsbGetDeviceConfiguration (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- OUT UINT8 *ConfigValue,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
- Usb Get Device Configuration\r
\r
-Arguments:\r
+/**\r
+ Get the device configuration.\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- ConfigValue - Config Value\r
- Status - Transfer Status\r
+ Submit a USB get configuration request for the USB device specified by UsbIo\r
+ and place the result in the buffer specified by ConfigurationValue. The status\r
+ of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If ConfigurationValue is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
-Returns:\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param ConfigurationValue A pointer to the device configuration to be retrieved.\r
+ @param Status A pointer to the status of the transfer.\r
\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbGetConfiguration (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ OUT UINT16 *ConfigurationValue,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (ConfigurationValue != NULL);\r
+ ASSERT (Status != NULL);\r
+\r
+ *ConfigurationValue = 0;\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_GET_CONFIGURATION_REQ_TYPE;\r
- DevReq.Request = USB_DEV_GET_CONFIGURATION;\r
+ DevReq.Request = USB_REQ_GET_CONFIG;\r
DevReq.Length = 1;\r
\r
return UsbIo->UsbControlTransfer (\r
UsbIo,\r
&DevReq,\r
EfiUsbDataIn,\r
- TIMEOUT_VALUE,\r
- ConfigValue,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
+ ConfigurationValue,\r
1,\r
Status\r
);\r
}\r
-//\r
-// Set device configuration\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceConfiguration (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN UINT16 Value,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
\r
-Routine Description:\r
\r
- Usb Set Device Configuration\r
+/**\r
+ Set the device configuration.\r
\r
-Arguments:\r
+ Submit a USB set configuration request for the USB device specified by UsbIo\r
+ and set the device configuration to the value specified by ConfigurationValue.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Value - Configuration Value to set\r
- Status - Transfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param ConfigurationValue The device configuration value to be set.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbSetConfiguration (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN UINT16 ConfigurationValue,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;\r
- DevReq.Request = USB_DEV_SET_CONFIGURATION;\r
- DevReq.Value = Value;\r
- \r
+ DevReq.Request = USB_REQ_SET_CONFIG;\r
+ DevReq.Value = ConfigurationValue;\r
+\r
return UsbIo->UsbControlTransfer (\r
UsbIo,\r
&DevReq,\r
EfiUsbNoData,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
NULL,\r
0,\r
Status\r
);\r
}\r
-//\r
-// Set Device Feature\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceFeature (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN EFI_USB_RECIPIENT Recipient,\r
- IN UINT16 Value,\r
- IN UINT16 Target,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
\r
-Routine Description:\r
\r
- Usb Set Device Feature\r
+/**\r
+ Set the specified feature of the specified device.\r
\r
-Arguments:\r
+ Submit a USB set device feature request for the USB device specified by UsbIo,\r
+ Recipient, and Target to the value specified by Value. The status of the\r
+ transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Recipient - Interface/Device/Endpoint\r
- Value - Request value\r
- Target - Request Index\r
- Status - Transfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).\r
+ Type USB_TYPES_DEFINITION is defined in the MDE Package Industry\r
+ Standard include file Usb.h.\r
+ @param Value The value of the feature to be set.\r
+ @param Target The index of the device to be set.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
- \r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbSetFeature (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN USB_TYPES_DEFINITION Recipient,\r
+ IN UINT16 Value,\r
+ IN UINT16 Target,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
switch (Recipient) {\r
\r
- case EfiUsbDevice:\r
- DevReq.RequestType = 0x00;\r
+ case USB_TARGET_DEVICE:\r
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_D;\r
break;\r
\r
- case EfiUsbInterface:\r
- DevReq.RequestType = 0x01;\r
+ case USB_TARGET_INTERFACE:\r
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_I;\r
break;\r
\r
- case EfiUsbEndpoint:\r
- DevReq.RequestType = 0x02;\r
+ case USB_TARGET_ENDPOINT:\r
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_E;\r
+ break;\r
+\r
+ default:\r
break;\r
}\r
//\r
// Fill device request, see USB1.1 spec\r
//\r
- DevReq.Request = USB_DEV_SET_FEATURE;\r
+ DevReq.Request = USB_REQ_SET_FEATURE;\r
DevReq.Value = Value;\r
DevReq.Index = Target;\r
\r
UsbIo,\r
&DevReq,\r
EfiUsbNoData,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
NULL,\r
0,\r
Status\r
);\r
}\r
-//\r
-// Clear Device Feature\r
-//\r
-EFI_STATUS\r
-UsbClearDeviceFeature (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN EFI_USB_RECIPIENT Recipient,\r
- IN UINT16 Value,\r
- IN UINT16 Target,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
\r
-Routine Description:\r
\r
- Usb Clear Device Feature\r
+/**\r
+ Clear the specified feature of the specified device.\r
\r
-Arguments:\r
+ Submit a USB clear device feature request for the USB device specified by UsbIo,\r
+ Recipient, and Target to the value specified by Value. The status of the transfer\r
+ is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Recipient - Interface/Device/Endpoint\r
- Value - Request value\r
- Target - Request Index\r
- Status - Transfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).\r
+ Type USB_TYPES_DEFINITION is defined in the MDE Package Industry Standard\r
+ include file Usb.h.\r
+ @param Value The value of the feature to be cleared.\r
+ @param Target The index of the device to be cleared.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
- \r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbClearFeature (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN USB_TYPES_DEFINITION Recipient,\r
+ IN UINT16 Value,\r
+ IN UINT16 Target,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Status != NULL);\r
+\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
switch (Recipient) {\r
\r
- case EfiUsbDevice:\r
- DevReq.RequestType = 0x00;\r
+ case USB_TARGET_DEVICE:\r
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;\r
break;\r
\r
- case EfiUsbInterface:\r
- DevReq.RequestType = 0x01;\r
+ case USB_TARGET_INTERFACE:\r
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;\r
break;\r
\r
- case EfiUsbEndpoint:\r
- DevReq.RequestType = 0x02;\r
+ case USB_TARGET_ENDPOINT:\r
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;\r
+ break;\r
+\r
+ default:\r
break;\r
}\r
//\r
// Fill device request, see USB1.1 spec\r
//\r
- DevReq.Request = USB_DEV_CLEAR_FEATURE;\r
+ DevReq.Request = USB_REQ_CLEAR_FEATURE;\r
DevReq.Value = Value;\r
DevReq.Index = Target;\r
\r
UsbIo,\r
&DevReq,\r
EfiUsbNoData,\r
- TIMEOUT_VALUE,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
NULL,\r
0,\r
Status\r
);\r
}\r
-//\r
-// Get Device Status\r
-//\r
-EFI_STATUS\r
-UsbGetDeviceStatus (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN EFI_USB_RECIPIENT Recipient,\r
- IN UINT16 Target,\r
- OUT UINT16 *DevStatus,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
\r
-Routine Description:\r
\r
- Usb Get Device Status\r
+/**\r
+ Get the status of the specified device.\r
\r
-Arguments:\r
+ Submit a USB device get status request for the USB device specified by UsbIo,\r
+ Recipient, and Target and place the result in the buffer specified by DeviceStatus.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If DeviceStatus is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- Recipient - Interface/Device/Endpoint\r
- Target - Request index\r
- DevStatus - Device status\r
- Status - Transfer status\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).\r
+ Type USB_TYPES_DEFINITION is defined in the MDE Package Industry Standard\r
+ include file Usb.h.\r
+ @param Target The index of the device to be get the status of.\r
+ @param DeviceStatus A pointer to the device status to be retrieved.\r
+ @param Status A pointer to the status of the transfer.\r
\r
-Returns:\r
- \r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbGetStatus (\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ IN USB_TYPES_DEFINITION Recipient,\r
+ IN UINT16 Target,\r
+ OUT UINT16 *DeviceStatus,\r
+ OUT UINT32 *Status\r
+ )\r
{\r
EFI_USB_DEVICE_REQUEST DevReq;\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (DeviceStatus != NULL);\r
+ ASSERT (Status != NULL);\r
\r
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
\r
switch (Recipient) {\r
\r
- case EfiUsbDevice:\r
- DevReq.RequestType = 0x80;\r
+ case USB_TARGET_DEVICE:\r
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_D;\r
break;\r
\r
- case EfiUsbInterface:\r
- DevReq.RequestType = 0x81;\r
+ case USB_TARGET_INTERFACE:\r
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_I;\r
break;\r
\r
- case EfiUsbEndpoint:\r
- DevReq.RequestType = 0x82;\r
+ case USB_TARGET_ENDPOINT:\r
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_E;\r
+ break;\r
+\r
+ default:\r
break;\r
}\r
//\r
// Fill device request, see USB1.1 spec\r
//\r
- DevReq.Request = USB_DEV_GET_STATUS;\r
+ DevReq.Request = USB_REQ_GET_STATUS;\r
DevReq.Value = 0;\r
DevReq.Index = Target;\r
DevReq.Length = 2;\r
UsbIo,\r
&DevReq,\r
EfiUsbDataIn,\r
- TIMEOUT_VALUE,\r
- DevStatus,\r
+ PcdGet32 (PcdUsbTransferTimeoutValue),\r
+ DeviceStatus,\r
2,\r
Status\r
);\r
}\r
-//\r
-// Usb Get String\r
-//\r
-EFI_STATUS\r
-UsbGetString (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN UINT16 LangID,\r
- IN UINT8 Index,\r
- IN VOID *Buf,\r
- IN UINTN BufSize,\r
- OUT UINT32 *Status\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
- Usb Get String\r
\r
-Arguments:\r
+/**\r
+ Clear halt feature of the specified usb endpoint.\r
\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- LangID - Language ID\r
- Index - Request index\r
- Buf - Buffer to store string\r
- BufSize - Buffer size\r
- Status - Transfer status\r
+ Retrieve the USB endpoint descriptor specified by UsbIo and EndPoint.\r
+ If the USB endpoint descriptor can not be retrieved, then return EFI_NOT_FOUND.\r
+ If the endpoint descriptor is found, then clear the halt feature of this USB endpoint.\r
+ The status of the transfer is returned in Status.\r
+ If UsbIo is NULL, then ASSERT().\r
+ If Status is NULL, then ASSERT().\r
\r
-Returns:\r
- \r
- EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success\r
- EFI_TIMEOUT - Device has no response \r
-\r
---*/\r
-{\r
- UINT16 Value;\r
+ @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.\r
+ @param Endpoint The endpoint address.\r
+ @param Status A pointer to the status of the transfer.\r
\r
- if (UsbIo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- //\r
- // Fill value, see USB1.1 spec\r
- //\r
- Value = (UINT16) ((USB_DT_STRING << 8) | Index);\r
-\r
- return UsbGetDescriptor (\r
- UsbIo,\r
- Value,\r
- LangID,\r
- (UINT16) BufSize,\r
- Buf,\r
- Status\r
- );\r
-}\r
+ @retval EFI_SUCCESS The request executed successfully.\r
+ @retval EFI_TIMEOUT A timeout occurred executing the request.\r
+ @retval EFI_DEVICE_ERROR The request failed due to a device error.\r
+ The transfer status is returned in Status.\r
+ @retval EFI_NOT_FOUND The specified USB endpoint descriptor can not be found\r
\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
UsbClearEndpointHalt (\r
IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- IN UINT8 EndpointNo,\r
+ IN UINT8 Endpoint,\r
OUT UINT32 *Status\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Clear endpoint stall\r
-\r
-Arguments:\r
-\r
- UsbIo - EFI_USB_IO_PROTOCOL\r
- EndpointNo - Endpoint Number\r
- Status - Transfer Status\r
-\r
-Returns:\r
-\r
- EFI_NOT_FOUND - Can't find the Endpoint\r
- EFI_DEVICE_ERROR - Hardware error\r
- EFI_SUCCESS - Success\r
-\r
---*/\r
{\r
EFI_STATUS Result;\r
EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;\r
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
UINT8 Index;\r
\r
+ ASSERT (UsbIo != NULL);\r
+ ASSERT (Status != NULL);\r
+\r
ZeroMem (&EndpointDescriptor, sizeof (EFI_USB_ENDPOINT_DESCRIPTOR));\r
//\r
// First seach the endpoint descriptor for that endpoint addr\r
continue;\r
}\r
\r
- if (EndpointDescriptor.EndpointAddress == EndpointNo) {\r
+ if (EndpointDescriptor.EndpointAddress == Endpoint) {\r
break;\r
}\r
}\r
return EFI_NOT_FOUND;\r
}\r
\r
- Result = UsbClearDeviceFeature (\r
+ Result = UsbClearFeature (\r
UsbIo,\r
- EfiUsbEndpoint,\r
- EfiUsbEndpointHalt,\r
+ USB_TARGET_ENDPOINT,\r
+ USB_FEATURE_ENDPOINT_HALT,\r
EndpointDescriptor.EndpointAddress,\r
Status\r
);\r