本文整理汇总了C++中EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor方法的具体用法?C++ EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor怎么用?C++ EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_USB_IO_PROTOCOL
的用法示例。
在下文中一共展示了EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
Verify the controller type
@param [in] pThis Protocol instance pointer.
@param [in] Controller Handle of device to test.
@param [in] pRemainingDevicePath Not used.
@retval EFI_SUCCESS This driver supports this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
DriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath
)
{
EFI_USB_DEVICE_DESCRIPTOR Device;
EFI_USB_IO_PROTOCOL * pUsbIo;
EFI_STATUS Status;
//
// Connect to the USB stack
//
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
(VOID **) &pUsbIo,
pThis->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (!EFI_ERROR ( Status )) {
//
// Get the interface descriptor to check the USB class and find a transport
// protocol handler.
//
Status = pUsbIo->UsbGetDeviceDescriptor ( pUsbIo, &Device );
if (!EFI_ERROR ( Status )) {
//
// Validate the adapter
//
if (( VENDOR_ID != Device.IdVendor )
|| ( PRODUCT_ID != Device.IdProduct )) {
Status = EFI_UNSUPPORTED;
}
}
//
// Done with the USB stack
//
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
pThis->DriverBindingHandle,
Controller
);
}
//
// Return the device supported status
//
return Status;
}
示例2: DEBUG
/**
Tests to see if this driver supports a given controller.
@param This[in] A pointer to the EFI_DRIVER_BINDING_PROTOCOL
instance.
@param ControllerHandle[in] The handle of the controller to test.
@param RemainingDevicePath[in] The remaining device path.
(Ignored - this is not a bus driver.)
@retval EFI_SUCCESS The driver supports this controller.
@retval EFI_ALREADY_STARTED The device specified by ControllerHandle is
already being managed by the driver specified
by This.
@retval EFI_UNSUPPORTED The device specified by ControllerHandle is
not supported by the driver specified by This.
**/
EFI_STATUS
EFIAPI
UsbHwrngDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_USB_DEVICE_DESCRIPTOR Device;
EFI_USB_IO_PROTOCOL *UsbIo;
EFI_STATUS Status;
//
// Connect to the USB stack
//
Status = gBS->OpenProtocol (ControllerHandle,
&gEfiUsbIoProtocolGuid,
(VOID **) &UsbIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get the interface descriptor to check the USB class and find a transport
// protocol handler.
//
Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &Device);
if (!EFI_ERROR (Status)) {
//
// Validate the adapter
//
if ((Device.IdVendor != CHAOSKEY_VENDOR_ID) ||
(Device.IdProduct != CHAOSKEY_PRODUCT_ID)) {
Status = EFI_UNSUPPORTED;
} else {
DEBUG ((DEBUG_INIT | DEBUG_INFO,
"Detected ChaosKey RNG device (USB VendorID:0x%04x ProductID:0x%04x)\n",
Device.IdVendor, Device.IdProduct));
Status = EFI_SUCCESS;
}
}
//
// Clean up.
//
gBS->CloseProtocol (ControllerHandle,
&gEfiUsbIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
return Status;
}
示例3: StrSize
/**
Try to get the controller's USB description.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetUsbDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_USB_IO_PROTOCOL *UsbIo;
CHAR16 NullChar;
CHAR16 *Manufacturer;
CHAR16 *Product;
CHAR16 *SerialNumber;
CHAR16 *Description;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
UINTN DescMaxSize;
Status = gBS->HandleProtocol (
Handle,
&gEfiUsbIoProtocolGuid,
(VOID **) &UsbIo
);
if (EFI_ERROR (Status)) {
return NULL;
}
NullChar = L'\0';
Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
if (EFI_ERROR (Status)) {
return NULL;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrManufacturer,
&Manufacturer
);
if (EFI_ERROR (Status)) {
Manufacturer = &NullChar;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrProduct,
&Product
);
if (EFI_ERROR (Status)) {
Product = &NullChar;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrSerialNumber,
&SerialNumber
);
if (EFI_ERROR (Status)) {
SerialNumber = &NullChar;
}
if ((Manufacturer == &NullChar) &&
(Product == &NullChar) &&
(SerialNumber == &NullChar)
) {
return NULL;
}
DescMaxSize = StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber);
Description = AllocateZeroPool (DescMaxSize);
ASSERT (Description != NULL);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), Manufacturer);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
StrCatS (Description, DescMaxSize/sizeof(CHAR16), SerialNumber);
if (Manufacturer != &NullChar) {
FreePool (Manufacturer);
}
if (Product != &NullChar) {
FreePool (Product);
}
if (SerialNumber != &NullChar) {
FreePool (SerialNumber);
}
BmEliminateExtraSpaces (Description);
return Description;
}