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
This commit is contained in:
vanjeff
2007-07-12 17:31:28 +00:00
parent 1e5e792546
commit ed838d0c5e
21 changed files with 5097 additions and 575 deletions

View File

@@ -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
//
/**
Usb Set Device Interface
@param UsbIo EFI_USB_IO_PROTOCOL
@param InterfaceNo Interface Number
@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
UsbSetDeviceInterface (
UsbSetInterface (
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
Returns:
EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success
EFI_TIMEOUT - Device has no response
--*/
{
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
//
/**
Usb Get Device Configuration
@param UsbIo EFI_USB_IO_PROTOCOL
@param ConfigValue Config Value
@param Status Transfer Status
@retval EFI_INVALID_PARAMETER Parameter is error
@retval EFI_SUCCESS Success
@retval EFI_TIMEOUT Device has no response
**/
EFI_STATUS
UsbGetDeviceConfiguration (
UsbGetConfiguration (
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:
EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success
EFI_TIMEOUT - Device has no response
--*/
{
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
//
/**
Usb Set Device Configuration
@param UsbIo EFI_USB_IO_PROTOCOL
@param Value Configuration Value 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
UsbSetDeviceConfiguration (
UsbSetConfiguration (
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
Returns:
EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success
EFI_TIMEOUT - Device has no response
--*/
{
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,111 +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_USB_DEVICE_REQUEST DevReq;
if (UsbIo == NULL) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
switch (Recipient) {
case EfiUsbDevice:
DevReq.RequestType = 0x00;
break;
case EfiUsbInterface:
DevReq.RequestType = 0x01;
break;
case EfiUsbEndpoint:
DevReq.RequestType = 0x02;
break;
}
//
// Fill device request, see USB1.1 spec
//
DevReq.Request = USB_DEV_SET_FEATURE;
DevReq.Value = Value;
DevReq.Index = Target;
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbNoData,
TIMEOUT_VALUE,
NULL,
0,
Status
);
}
//
// Clear Device Feature
//
**/
EFI_STATUS
UsbClearDeviceFeature (
UsbSetFeature (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN EFI_USB_RECIPIENT Recipient,
IN UINTN Recipient,
IN UINT16 Value,
IN UINT16 Target,
OUT UINT32 *Status
)
/*++
Routine Description:
Usb Clear Device Feature
Arguments:
UsbIo - EFI_USB_IO_PROTOCOL
Recipient - Interface/Device/Endpoint
Value - Request value
Target - Request Index
Status - Transfer status
Returns:
EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success
EFI_TIMEOUT - Device has no response
--*/
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -466,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_CLEAR_FEATURE;
DevReq.Request = USB_REQ_SET_FEATURE;
DevReq.Value = Value;
DevReq.Index = Target;
@@ -496,38 +376,95 @@ Returns:
Status
);
}
//
// Get Device Status
//
/**
Usb Clear Device Feature
@param UsbIo EFI_USB_IO_PROTOCOL
@param Recipient Interface/Device/Endpoint
@param Value Request value
@param Target Request Index
@param Status Transfer status
@retval EFI_INVALID_PARAMETER Parameter is error
@retval EFI_SUCCESS Success
@retval EFI_TIMEOUT Device has no response
**/
EFI_STATUS
UsbGetDeviceStatus (
UsbClearFeature (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN EFI_USB_RECIPIENT Recipient,
IN UINTN Recipient,
IN UINT16 Value,
IN UINT16 Target,
OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
if (UsbIo == NULL) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
switch (Recipient) {
case USB_TARGET_DEVICE:
DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
break;
case USB_TARGET_INTERFACE:
DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
break;
case USB_TARGET_ENDPOINT:
DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
break;
}
//
// Fill device request, see USB1.1 spec
//
DevReq.Request = USB_REQ_CLEAR_FEATURE;
DevReq.Value = Value;
DevReq.Index = Target;
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbNoData,
TIMEOUT_VALUE,
NULL,
0,
Status
);
}
/**
Usb Get Device Status
@param UsbIo EFI_USB_IO_PROTOCOL
@param Recipient Interface/Device/Endpoint
@param Target Request index
@param DevStatus Device status
@param Status Transfer status
@retval EFI_INVALID_PARAMETER Parameter is error
@retval EFI_SUCCESS Success
@retval 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
)
/*++
Routine Description:
Usb Get Device Status
Arguments:
UsbIo - EFI_USB_IO_PROTOCOL
Recipient - Interface/Device/Endpoint
Target - Request index
DevStatus - Device status
Status - Transfer status
Returns:
EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success
EFI_TIMEOUT - Device has no response
--*/
{
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