summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/UefiUsbLib/UsbDxeLib.c')
-rw-r--r--MdePkg/Library/UefiUsbLib/UsbDxeLib.c253
1 files changed, 120 insertions, 133 deletions
diff --git a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
index e75df8d044..53b90984f7 100644
--- a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
+++ b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c
@@ -10,7 +10,6 @@
#include "UefiUsbLibInternal.h"
-
/**
Get the descriptor of the specified USB device.
@@ -40,12 +39,12 @@
EFI_STATUS
EFIAPI
UsbGetDescriptor (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 Value,
- IN UINT16 Index,
- IN UINT16 DescriptorLength,
- OUT VOID *Descriptor,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ OUT VOID *Descriptor,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -56,11 +55,11 @@ UsbGetDescriptor (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
- DevReq.Request = USB_REQ_GET_DESCRIPTOR;
- DevReq.Value = Value;
- DevReq.Index = Index;
- DevReq.Length = DescriptorLength;
+ DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
+ DevReq.Request = USB_REQ_GET_DESCRIPTOR;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = DescriptorLength;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -73,7 +72,6 @@ UsbGetDescriptor (
);
}
-
/**
Set the descriptor of the specified USB device.
@@ -100,12 +98,12 @@ UsbGetDescriptor (
EFI_STATUS
EFIAPI
UsbSetDescriptor (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 Value,
- IN UINT16 Index,
- IN UINT16 DescriptorLength,
- IN VOID *Descriptor,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ IN VOID *Descriptor,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -116,11 +114,11 @@ UsbSetDescriptor (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;
- DevReq.Request = USB_REQ_SET_DESCRIPTOR;
- DevReq.Value = Value;
- DevReq.Index = Index;
- DevReq.Length = DescriptorLength;
+ DevReq.RequestType = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;
+ DevReq.Request = USB_REQ_SET_DESCRIPTOR;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = DescriptorLength;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -133,7 +131,6 @@ UsbSetDescriptor (
);
}
-
/**
Get the interface setting of the specified USB device.
@@ -158,10 +155,10 @@ UsbSetDescriptor (
EFI_STATUS
EFIAPI
UsbGetInterface (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 Interface,
- OUT UINT16 *AlternateSetting,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Interface,
+ OUT UINT16 *AlternateSetting,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -174,10 +171,10 @@ UsbGetInterface (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_GET_INTERFACE_REQ_TYPE;
- DevReq.Request = USB_REQ_GET_INTERFACE;
- DevReq.Index = Interface;
- DevReq.Length = 1;
+ DevReq.RequestType = USB_DEV_GET_INTERFACE_REQ_TYPE;
+ DevReq.Request = USB_REQ_GET_INTERFACE;
+ DevReq.Index = Interface;
+ DevReq.Length = 1;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -190,7 +187,6 @@ UsbGetInterface (
);
}
-
/**
Set the interface setting of the specified USB device.
@@ -214,10 +210,10 @@ UsbGetInterface (
EFI_STATUS
EFIAPI
UsbSetInterface (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 Interface,
- IN UINT16 AlternateSetting,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Interface,
+ IN UINT16 AlternateSetting,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -227,10 +223,10 @@ UsbSetInterface (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;
- DevReq.Request = USB_REQ_SET_INTERFACE;
- DevReq.Value = AlternateSetting;
- DevReq.Index = Interface;
+ DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;
+ DevReq.Request = USB_REQ_SET_INTERFACE;
+ DevReq.Value = AlternateSetting;
+ DevReq.Index = Interface;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -243,7 +239,6 @@ UsbSetInterface (
);
}
-
/**
Get the device configuration.
@@ -267,9 +262,9 @@ UsbSetInterface (
EFI_STATUS
EFIAPI
UsbGetConfiguration (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT UINT16 *ConfigurationValue,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT UINT16 *ConfigurationValue,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -282,9 +277,9 @@ UsbGetConfiguration (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_GET_CONFIGURATION_REQ_TYPE;
- DevReq.Request = USB_REQ_GET_CONFIG;
- DevReq.Length = 1;
+ DevReq.RequestType = USB_DEV_GET_CONFIGURATION_REQ_TYPE;
+ DevReq.Request = USB_REQ_GET_CONFIG;
+ DevReq.Length = 1;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -297,7 +292,6 @@ UsbGetConfiguration (
);
}
-
/**
Set the device configuration.
@@ -320,9 +314,9 @@ UsbGetConfiguration (
EFI_STATUS
EFIAPI
UsbSetConfiguration (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 ConfigurationValue,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 ConfigurationValue,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -332,9 +326,9 @@ UsbSetConfiguration (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
- DevReq.Request = USB_REQ_SET_CONFIG;
- DevReq.Value = ConfigurationValue;
+ DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
+ DevReq.Request = USB_REQ_SET_CONFIG;
+ DevReq.Value = ConfigurationValue;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -347,7 +341,6 @@ UsbSetConfiguration (
);
}
-
/**
Set the specified feature of the specified device.
@@ -374,11 +367,11 @@ UsbSetConfiguration (
EFI_STATUS
EFIAPI
UsbSetFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN USB_TYPES_DEFINITION Recipient,
- IN UINT16 Value,
- IN UINT16 Target,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN USB_TYPES_DEFINITION Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -389,29 +382,28 @@ UsbSetFeature (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
switch (Recipient) {
+ case USB_TARGET_DEVICE:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_D;
+ break;
- case USB_TARGET_DEVICE:
- DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_D;
- break;
-
- case USB_TARGET_INTERFACE:
- DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_I;
- break;
+ case USB_TARGET_INTERFACE:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_I;
+ break;
- case USB_TARGET_ENDPOINT:
- DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_E;
- break;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_E;
+ break;
- default:
- break;
+ default:
+ break;
}
+
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_REQ_SET_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = Target;
-
+ DevReq.Request = USB_REQ_SET_FEATURE;
+ DevReq.Value = Value;
+ DevReq.Index = Target;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -424,7 +416,6 @@ UsbSetFeature (
);
}
-
/**
Clear the specified feature of the specified device.
@@ -451,11 +442,11 @@ UsbSetFeature (
EFI_STATUS
EFIAPI
UsbClearFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN USB_TYPES_DEFINITION Recipient,
- IN UINT16 Value,
- IN UINT16 Target,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN USB_TYPES_DEFINITION Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -463,33 +454,31 @@ UsbClearFeature (
ASSERT (UsbIo != NULL);
ASSERT (Status != NULL);
-
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_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_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;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
+ break;
- default:
- break;
+ default:
+ break;
}
+
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_REQ_CLEAR_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = Target;
-
+ DevReq.Request = USB_REQ_CLEAR_FEATURE;
+ DevReq.Value = Value;
+ DevReq.Index = Target;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -502,7 +491,6 @@ UsbClearFeature (
);
}
-
/**
Get the status of the specified device.
@@ -530,11 +518,11 @@ UsbClearFeature (
EFI_STATUS
EFIAPI
UsbGetStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN USB_TYPES_DEFINITION Recipient,
- IN UINT16 Target,
- OUT UINT16 *DeviceStatus,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN USB_TYPES_DEFINITION Recipient,
+ IN UINT16 Target,
+ OUT UINT16 *DeviceStatus,
+ OUT UINT32 *Status
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -546,29 +534,29 @@ UsbGetStatus (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
switch (Recipient) {
+ case USB_TARGET_DEVICE:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_D;
+ break;
- case USB_TARGET_DEVICE:
- DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_D;
- break;
-
- case USB_TARGET_INTERFACE:
- DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_I;
- break;
+ case USB_TARGET_INTERFACE:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_I;
+ break;
- case USB_TARGET_ENDPOINT:
- DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_E;
- break;
+ case USB_TARGET_ENDPOINT:
+ DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_E;
+ break;
- default:
- break;
+ default:
+ break;
}
+
//
// Fill device request, see USB1.1 spec
//
- DevReq.Request = USB_REQ_GET_STATUS;
- DevReq.Value = 0;
- DevReq.Index = Target;
- DevReq.Length = 2;
+ DevReq.Request = USB_REQ_GET_STATUS;
+ DevReq.Value = 0;
+ DevReq.Index = Target;
+ DevReq.Length = 2;
return UsbIo->UsbControlTransfer (
UsbIo,
@@ -581,7 +569,6 @@ UsbGetStatus (
);
}
-
/**
Clear halt feature of the specified usb endpoint.
@@ -606,9 +593,9 @@ UsbGetStatus (
EFI_STATUS
EFIAPI
UsbClearEndpointHalt (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Endpoint,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Endpoint,
+ OUT UINT32 *Status
)
{
EFI_STATUS Result;
@@ -654,12 +641,12 @@ UsbClearEndpointHalt (
}
Result = UsbClearFeature (
- UsbIo,
- USB_TARGET_ENDPOINT,
- USB_FEATURE_ENDPOINT_HALT,
- EndpointDescriptor.EndpointAddress,
- Status
- );
+ UsbIo,
+ USB_TARGET_ENDPOINT,
+ USB_FEATURE_ENDPOINT_HALT,
+ EndpointDescriptor.EndpointAddress,
+ Status
+ );
return Result;
}