summaryrefslogtreecommitdiff
path: root/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-07-12 17:31:28 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-07-12 17:31:28 +0000
commited838d0c5ec4d4f2f1c1898fff1c6c619ff46352 (patch)
tree037448daf15593f1297124adb9deec57a343d3f0 /MdePkg/Library/UefiUsbLib/UsbDxeLib.c
parent1e5e7925461761398efdd6a2853b03543a3a9f6d (diff)
downloadedk2-platforms-ed838d0c5ec4d4f2f1c1898fff1c6c619ff46352.tar.xz
1. Import UsbKbDxe and UsbMouseDxe into MdeModulePkg
2. Updated UefiUsbLib git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3216 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/UefiUsbLib/UsbDxeLib.c')
-rw-r--r--MdePkg/Library/UefiUsbLib/UsbDxeLib.c528
1 files changed, 203 insertions, 325 deletions
diff --git a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
index 626fa22290..cb8885396d 100644
--- a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
+++ b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
@@ -1,13 +1,13 @@
-/*++
+/** @file
-Copyright (c) 2006, 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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2004 - 2007, 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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -19,13 +19,34 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Revision History
---*/
-#include "UefiUsbLibInternal.h"
+**/
//
-// Get Device Descriptor
+// The package level header files this module uses
+//
+#include <PiDxe.h>
+//
+// The Library classes this module consumes
//
+#include <Library/BaseMemoryLib.h>
+#include <Library/UsbLib.h>
+
+/**
+ Usb Get Descriptor
+
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Value Device Request Value
+ @param Index Device Request Index
+ @param DescriptorLength Descriptor Length
+ @param Descriptor Descriptor buffer to contain result
+ @param Status Transfer Status
+
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
+
+**/
EFI_STATUS
UsbGetDescriptor (
IN EFI_USB_IO_PROTOCOL *UsbIo,
@@ -35,26 +56,6 @@ UsbGetDescriptor (
OUT VOID *Descriptor,
OUT UINT32 *Status
)
-/*++
-
-Routine Description:
-
- Usb Get Descriptor
-
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- Value - Device Request Value
- Index - Device Request Index
- DescriptorLength - Descriptor Length
- Descriptor - Descriptor buffer to contain result
- Status - Transfer Status
-Returns:
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -65,7 +66,7 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
- DevReq.Request = USB_DEV_GET_DESCRIPTOR;
+ DevReq.Request = USB_REQ_GET_DESCRIPTOR;
DevReq.Value = Value;
DevReq.Index = Index;
DevReq.Length = DescriptorLength;
@@ -80,9 +81,23 @@ Returns:
Status
);
}
-//
-// Set Device Descriptor
-//
+
+
+/**
+ Usb Set Descriptor
+
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Value Device Request Value
+ @param Index Device Request Index
+ @param DescriptorLength Descriptor Length
+ @param Descriptor Descriptor buffer to set
+ @param Status Transfer Status
+
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
+
+**/
EFI_STATUS
UsbSetDescriptor (
IN EFI_USB_IO_PROTOCOL *UsbIo,
@@ -92,26 +107,6 @@ UsbSetDescriptor (
IN VOID *Descriptor,
OUT UINT32 *Status
)
-/*++
-
-Routine Description:
-
- Usb Set Descriptor
-
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- Value - Device Request Value
- Index - Device Request Index
- DescriptorLength - Descriptor Length
- Descriptor - Descriptor buffer to set
- Status - Transfer Status
-Returns:
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -122,7 +117,7 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_DESCRIPTOR;
+ DevReq.Request = USB_REQ_SET_DESCRIPTOR;
DevReq.Value = Value;
DevReq.Index = Index;
DevReq.Length = DescriptorLength;
@@ -138,37 +133,27 @@ Returns:
);
}
-//
-// Get device Interface
-//
+
+/**
+ Usb Get Device Interface
+
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Index Interface index value
+ @param AltSetting Alternate setting
+ @param Status Trasnsfer status
+
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
+
+**/
EFI_STATUS
-UsbGetDeviceInterface (
+UsbGetInterface (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN UINT16 Index,
OUT UINT8 *AltSetting,
OUT UINT32 *Status
)
-/*++
-
-Routine Description:
-
- Usb Get Device Interface
-
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- Index - Interface index value
- AltSetting - Alternate setting
- Status - Trasnsfer status
-
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
-
---*/
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -179,7 +164,7 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_GET_INTERFACE_REQ_TYPE;
- DevReq.Request = USB_DEV_GET_INTERFACE;
+ DevReq.Request = USB_REQ_GET_INTERFACE;
DevReq.Index = Index;
DevReq.Length = 1;
@@ -193,36 +178,28 @@ Returns:
Status
);
}
-//
-// Set device interface
-//
-EFI_STATUS
-UsbSetDeviceInterface (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 InterfaceNo,
- IN UINT16 AltSetting,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Set Device Interface
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- InterfaceNo - Interface Number
- AltSetting - Alternate setting
- Status - Trasnsfer status
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param InterfaceNo Interface Number
+ @param AltSetting Alternate setting
+ @param Status Trasnsfer status
-Returns:
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
+**/
+EFI_STATUS
+UsbSetInterface (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 InterfaceNo,
+ IN UINT16 AltSetting,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -233,10 +210,10 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_INTERFACE;
+ DevReq.Request = USB_REQ_SET_INTERFACE;
DevReq.Value = AltSetting;
DevReq.Index = InterfaceNo;
-
+
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -248,34 +225,26 @@ Returns:
Status
);
}
-//
-// Get device configuration
-//
-EFI_STATUS
-UsbGetDeviceConfiguration (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT UINT8 *ConfigValue,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Get Device Configuration
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- ConfigValue - Config Value
- Status - Transfer Status
-
-Returns:
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param ConfigValue Config Value
+ @param Status Transfer Status
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
---*/
+**/
+EFI_STATUS
+UsbGetConfiguration (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT UINT8 *ConfigValue,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -286,7 +255,7 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_GET_CONFIGURATION_REQ_TYPE;
- DevReq.Request = USB_DEV_GET_CONFIGURATION;
+ DevReq.Request = USB_REQ_GET_CONFIG;
DevReq.Length = 1;
return UsbIo->UsbControlTransfer (
@@ -299,34 +268,26 @@ Returns:
Status
);
}
-//
-// Set device configuration
-//
-EFI_STATUS
-UsbSetDeviceConfiguration (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 Value,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Set Device Configuration
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- Value - Configuration Value to set
- Status - Transfer status
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Value Configuration Value to set
+ @param Status Transfer status
-Returns:
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
+**/
+EFI_STATUS
+UsbSetConfiguration (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -337,9 +298,9 @@ Returns:
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_CONFIGURATION;
+ DevReq.Request = USB_REQ_SET_CONFIG;
DevReq.Value = Value;
-
+
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
@@ -350,38 +311,30 @@ Returns:
Status
);
}
-//
-// Set Device Feature
-//
-EFI_STATUS
-UsbSetDeviceFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN EFI_USB_RECIPIENT Recipient,
- IN UINT16 Value,
- IN UINT16 Target,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Set Device Feature
-Arguments:
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Recipient Interface/Device/Endpoint
+ @param Value Request value
+ @param Target Request Index
+ @param Status Transfer status
- UsbIo - EFI_USB_IO_PROTOCOL
- Recipient - Interface/Device/Endpoint
- Value - Request value
- Target - Request Index
- Status - Transfer status
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
+**/
+EFI_STATUS
+UsbSetFeature (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINTN Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -393,22 +346,22 @@ Returns:
switch (Recipient) {
- case EfiUsbDevice:
- DevReq.RequestType = 0x00;
+ case USB_TARGET_DEVICE:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_D;
break;
- case EfiUsbInterface:
- DevReq.RequestType = 0x01;
+ case USB_TARGET_INTERFACE:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_I;
break;
- case EfiUsbEndpoint:
- DevReq.RequestType = 0x02;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_E;
break;
}
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_DEV_SET_FEATURE;
+ DevReq.Request = USB_REQ_SET_FEATURE;
DevReq.Value = Value;
DevReq.Index = Target;
@@ -423,38 +376,30 @@ Returns:
Status
);
}
-//
-// Clear Device Feature
-//
-EFI_STATUS
-UsbClearDeviceFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN EFI_USB_RECIPIENT Recipient,
- IN UINT16 Value,
- IN UINT16 Target,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Clear Device Feature
-Arguments:
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Recipient Interface/Device/Endpoint
+ @param Value Request value
+ @param Target Request Index
+ @param Status Transfer status
- UsbIo - EFI_USB_IO_PROTOCOL
- Recipient - Interface/Device/Endpoint
- Value - Request value
- Target - Request Index
- Status - Transfer status
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
+**/
+EFI_STATUS
+UsbClearFeature (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINTN Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -466,22 +411,22 @@ Returns:
switch (Recipient) {
- case EfiUsbDevice:
- DevReq.RequestType = 0x00;
+ case USB_TARGET_DEVICE:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
break;
- case EfiUsbInterface:
- DevReq.RequestType = 0x01;
+ case USB_TARGET_INTERFACE:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
break;
- case EfiUsbEndpoint:
- DevReq.RequestType = 0x02;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
break;
}
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_DEV_CLEAR_FEATURE;
+ DevReq.Request = USB_REQ_CLEAR_FEATURE;
DevReq.Value = Value;
DevReq.Index = Target;
@@ -496,38 +441,30 @@ Returns:
Status
);
}
-//
-// Get Device Status
-//
-EFI_STATUS
-UsbGetDeviceStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN EFI_USB_RECIPIENT Recipient,
- IN UINT16 Target,
- OUT UINT16 *DevStatus,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
+/**
Usb Get Device Status
-Arguments:
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param Recipient Interface/Device/Endpoint
+ @param Target Request index
+ @param DevStatus Device status
+ @param Status Transfer status
- UsbIo - EFI_USB_IO_PROTOCOL
- Recipient - Interface/Device/Endpoint
- Target - Request index
- DevStatus - Device status
- Status - Transfer status
+ @retval EFI_INVALID_PARAMETER Parameter is error
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Device has no response
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
+**/
+EFI_STATUS
+UsbGetStatus (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINTN Recipient,
+ IN UINT16 Target,
+ OUT UINT16 *DevStatus,
+ OUT UINT32 *Status
+ )
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -539,22 +476,22 @@ Returns:
switch (Recipient) {
- case EfiUsbDevice:
- DevReq.RequestType = 0x80;
+ case USB_TARGET_DEVICE:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_D;
break;
- case EfiUsbInterface:
- DevReq.RequestType = 0x81;
+ case USB_TARGET_INTERFACE:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_I;
break;
- case EfiUsbEndpoint:
- DevReq.RequestType = 0x82;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_E;
break;
}
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_DEV_GET_STATUS;
+ DevReq.Request = USB_REQ_GET_STATUS;
DevReq.Value = 0;
DevReq.Index = Target;
DevReq.Length = 2;
@@ -569,86 +506,27 @@ Returns:
Status
);
}
-//
-// Usb Get String
-//
-EFI_STATUS
-UsbGetString (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 LangID,
- IN UINT8 Index,
- IN VOID *Buf,
- IN UINTN BufSize,
- OUT UINT32 *Status
- )
-/*++
-Routine Description:
- Usb Get String
-Arguments:
+/**
+ Clear endpoint stall
- UsbIo - EFI_USB_IO_PROTOCOL
- LangID - Language ID
- Index - Request index
- Buf - Buffer to store string
- BufSize - Buffer size
- Status - Transfer status
+ @param UsbIo EFI_USB_IO_PROTOCOL
+ @param EndpointNo Endpoint Number
+ @param Status Transfer Status
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
---*/
-{
- UINT16 Value;
-
- if (UsbIo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Fill value, see USB1.1 spec
- //
- Value = (UINT16) ((USB_DT_STRING << 8) | Index);
-
- return UsbGetDescriptor (
- UsbIo,
- Value,
- LangID,
- (UINT16) BufSize,
- Buf,
- Status
- );
-}
+ @retval EFI_NOT_FOUND Can't find the Endpoint
+ @retval EFI_DEVICE_ERROR Hardware error
+ @retval EFI_SUCCESS Success
+**/
EFI_STATUS
UsbClearEndpointHalt (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN UINT8 EndpointNo,
OUT UINT32 *Status
)
-/*++
-
-Routine Description:
-
- Clear endpoint stall
-
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- EndpointNo - Endpoint Number
- Status - Transfer Status
-
-Returns:
-
- EFI_NOT_FOUND - Can't find the Endpoint
- EFI_DEVICE_ERROR - Hardware error
- EFI_SUCCESS - Success
-
---*/
{
EFI_STATUS Result;
EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
@@ -689,9 +567,9 @@ Returns:
return EFI_NOT_FOUND;
}
- Result = UsbClearDeviceFeature (
+ Result = UsbClearFeature (
UsbIo,
- EfiUsbEndpoint,
+ USB_TARGET_ENDPOINT,
EfiUsbEndpointHalt,
EndpointDescriptor.EndpointAddress,
Status