本文整理汇总了C++中EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor方法的具体用法?C++ EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor怎么用?C++ EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_USB_IO_PROTOCOL
的用法示例。
在下文中一共展示了EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AllocateZeroPool
/**
Initialize the USB mouse device.
This function retrieves and parses HID report descriptor, and
initializes state of USB_MOUSE_DEV. Then it sets indefinite idle
rate for the device. Finally it creates event for delayed recovery,
which deals with device error.
@param UsbMouseDev Device instance to be initialized.
@retval EFI_SUCCESS USB mouse device successfully initialized..
@retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
@retval Other USB mouse device was not initialized successfully.
**/
EFI_STATUS
InitializeUsbMouseDevice (
IN OUT USB_MOUSE_DEV *UsbMouseDev
)
{
EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 Protocol;
EFI_STATUS Status;
EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
UINT8 *ReportDesc;
EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
VOID *Buf;
UINT32 TransferResult;
UINT16 Total;
USB_DESC_HEAD *Head;
BOOLEAN Start;
UsbIo = UsbMouseDev->UsbIo;
//
// Get the current configuration descriptor. Note that it doesn't include other descriptors.
//
Status = UsbIo->UsbGetConfigDescriptor (
UsbIo,
&ConfigDesc
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,
// all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.
//
Buf = AllocateZeroPool (ConfigDesc.TotalLength);
if (Buf == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = UsbGetDescriptor (
UsbIo,
(UINT16)((USB_DESC_TYPE_CONFIG << 8) | (ConfigDesc.ConfigurationValue - 1)),
0,
ConfigDesc.TotalLength,
Buf,
&TransferResult
);
if (EFI_ERROR (Status)) {
FreePool (Buf);
return Status;
}
Total = 0;
Start = FALSE;
Head = (USB_DESC_HEAD *)Buf;
MouseHidDesc = NULL;
//
// Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.
// This algorithm is based on the fact that the HID descriptor shall be interleaved
// between the interface and endpoint descriptors for HID interfaces.
//
while (Total < ConfigDesc.TotalLength) {
if (Head->Type == USB_DESC_TYPE_INTERFACE) {
if ((((USB_INTERFACE_DESCRIPTOR *)Head)->InterfaceNumber == UsbMouseDev->InterfaceDescriptor.InterfaceNumber) &&
(((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseDev->InterfaceDescriptor.AlternateSetting)) {
Start = TRUE;
}
}
if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {
break;
}
if (Start && (Head->Type == USB_DESC_TYPE_HID)) {
MouseHidDesc = (EFI_USB_HID_DESCRIPTOR *)Head;
break;
}
Total = Total + (UINT16)Head->Len;
Head = (USB_DESC_HEAD*)((UINT8 *)Buf + Total);
}
if (MouseHidDesc == NULL) {
FreePool (Buf);
return EFI_UNSUPPORTED;
}
//.........这里部分代码省略.........