/**
The user Entry Point for Application. The user code starts with this function
as the real entry point for the application.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_USB_IO_PROTOCOL *UsbIo;
UINTN HandleIndex, NumHandles;
EFI_HANDLE *ControllerHandle = NULL;
//
EFI_USB_DEVICE_DESCRIPTOR Device;
gST->ConOut->OutputString (gST->ConOut, L"---------------------------------\r\n");
gST->ConOut->ClearScreen(gST->ConOut);
gST->ConOut->EnableCursor(gST->ConOut,TRUE);
Status = gBS->LocateHandleBuffer(
ByProtocol,
&gEfiUsbIoProtocolGuid,
NULL,
&NumHandles,
&ControllerHandle);
if (EFI_ERROR (Status)) {
Print (L"gEfiUsbIoProtocolGuid err 0\r\n");
//gST->ConOut->ClearScreen(gST->ConOut);
//gST->ConOut->EnableCursor(gST->ConOut,TRUE);
return Status;
}
Print (L"USB NumHandles : %d\r\n",NumHandles);
for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++)
{
Status = gBS->OpenProtocol(
ControllerHandle[HandleIndex],
&gEfiUsbIoProtocolGuid,
(VOID**)&UsbIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(Status)) {
continue;
}
//
if (!IsUSBKeyboard (UsbIo))
{
Status = EFI_UNSUPPORTED;
}
//
Status = UsbIo->UsbGetDeviceDescriptor ( UsbIo, &Device );
if (EFI_ERROR ( Status )) {
Status = EFI_UNSUPPORTED;
}
else
{
//Device.IdVendor Device.IdProduct
Print(L"USB HandleIndex:%d VID:%04X PID:%04X\r\n",HandleIndex,Device.IdVendor,Device.IdProduct);
if((0x17EF == Device.IdVendor) && (0x60C1 == Device.IdProduct))
{
//
gBS->Stall(1000*800); //800ms Delay
}
}
gBS->CloseProtocol (
ControllerHandle[HandleIndex],
&gEfiUsbIoProtocolGuid,
gImageHandle,
NULL
);
}
return EFI_SUCCESS;
}
附带自己调试build 出的 .efi 执行文件
https://download.csdn.net/download/mini92/10334027