By default, only enable USB keyboard detection when booted in UEFI mode.

Most legacy BIOSs will support USB legacy keyboard emulation. Using that
will avoid having to reserve memory for the USB drivers, and should
improve the chance of having a working keyboard without having to work
around various USB device quirks.
This commit is contained in:
Martin Whitaker
2022-07-24 13:56:41 +01:00
parent 740df34656
commit 13d9569041
4 changed files with 23 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
#include <stdint.h>
#include "bootparams.h"
#include "io.h"
#include "usbhcd.h"
@@ -212,7 +214,7 @@ static const char usb_hid_keymap[] = {
// Public Variables
//------------------------------------------------------------------------------
keyboard_types_t keyboard_types = KT_LEGACY | KT_USB;
keyboard_types_t keyboard_types = KT_NONE;
//------------------------------------------------------------------------------
// Public Functions
@@ -220,6 +222,16 @@ keyboard_types_t keyboard_types = KT_LEGACY | KT_USB;
void keyboard_init(void)
{
if (keyboard_types == KT_NONE) {
// No command line option was found, so set the default according to
// how we were booted.
const boot_params_t *boot_params = (boot_params_t *)boot_params_addr;
if (boot_params->efi_info.loader_signature != 0) {
keyboard_types = KT_USB|KT_LEGACY;
} else {
keyboard_types = KT_LEGACY;
}
}
if (keyboard_types & KT_USB) {
find_usb_keyboards(keyboard_types == KT_USB);
}