Re: Simple usb keyboard/mouse driver implementation after ExitBootServices

Laszlo Ersek

On 02/23/21 07:04, gomidas95@... wrote:
Hello, I am an amateur. I made a uefi app for reading some type of images (bmp os/2) and files in folders. That also provides mice and keyboard support. I did not use edk2 but gnu-efi later I will switch it to edk2. Gnu do not have any doc about drivers. When I exit boot services my keyboard (console output text) and mice (graphical cursor on screen) becomes unresponsive.

I exit like this:
SystemTable->BootServices->ExitBootServices(ImageHandle, 0);

For, qemu emulator I did a trick, I made a third event for 'gEfiSimpleTextInProtocolGuid' and keyboard became responsive again after I called exitbootservices:

SimpleKeyboard(EFI_EVENT kbEvent)

in main.c:
Events[0] = mouse->WaitForInput;

//Keyboard - will become useless after exitbootservices.
Events[1] = gST->ConIn->WaitForKey;

//keyboard - work in emulator as a trick.

When switched to real hardware keyboard became unresponsive again, qemu do not have mouse support and did not test it. I did the app for hobby and I do not have enough knowledge about drivers.

What I should I do to allow keyboard and mice again on a real hardware ?
Your "trick" is undefined behavior.

EFI_SIMPLE_TEXT_INPUT_PROTOCOL is not a runtime protocol; you cannot use
it after ExitBootServices().

TBH I don't understand your purpose. Why do you call ExitBootServices()
in the first place, if you want to handle user input afterwards with
your UEFI application?

You're expected to call ExitBootServices() *because* the work of the
bootloader application is done, and now it's time for the OS to take

In that sense, to answer your question "What I should I do to allow
keyboard and mice again on a real hardware", I'd say "launch an actual
operating system after ExitBootServices".

Please read up on the various firmware phases.


Join to automatically receive all group messages.