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

@ -132,6 +132,7 @@ recognised:
* where *type* is one of
* legacy
* usb
* both
* usbdebug
* pauses after probing for USB keyboards
* usbinit=*mode*
@ -157,8 +158,9 @@ recognised:
Memtest86+ supports both the legacy keyboard interface (using I/O ports 0x60
and 0x64) and USB keyboards (using its own USB device drivers). One or the
other can be selected via the boot command line, If neither is selected, the
default is to use both.
other or both can be selected via the boot command line, If not specified on
the command line, the default is to use both if the system was booted in UEFI
mode, otherwise to only use the legacy interface.
Older BIOSs usually support USB legacy keyboard emulation, which makes USB
keyboards act like legacy keyboards connected to ports 0x60 and 0x64. This
@ -168,7 +170,8 @@ keyboards directly. The downside of that is that the USB controllers and
device drivers require some memory to be reserved for their private use,
which means that memory can't then be covered by the memory tests. So to
maximise test coverage, if it is supported, enable USB legacy keyboard
emulation and add `keyboard=legacy` on the boot command line.
emulation and, if booting in UEFI mode, add `keyboard=legacy` on the boot
command line.
**NOTE**: Some UEFI BIOSs only support USB legacy keyboard emulation when
you enable the Compatibility System Module (CSM) in the BIOS setup. Others
@ -178,9 +181,6 @@ Many USB devices don't fully conform to the USB specification. If the USB
keyboard probe hangs or fails to detect your keyboard, try the various
workarounds provided by the "usbinit" boot option.
**NOTE**: Memtest86+'s USB device drivers are work in progress. Not all USB
devices are supported yet, and there may be problems on some hardware.
## Operation
Once booted, Memtest86+ will initialise its display, then pause for a few

View File

@ -177,6 +177,8 @@ static void parse_option(const char *option, const char *params)
keyboard_types = KT_LEGACY;
} else if (strncmp(params, "usb", 4) == 0) {
keyboard_types = KT_USB;
} else if (strncmp(params, "both", 5) == 0) {
keyboard_types = KT_USB|KT_LEGACY;
}
} else if (strncmp(option, "powersave", 10) == 0) {
if (strncmp(params, "off", 4) == 0) {

View File

@ -15,6 +15,8 @@
#include <stdint.h>
#include <boot.h>
typedef struct {
uint8_t orig_x;
uint8_t orig_y;

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);
}