diff --git a/README.md b/README.md index 9d05dcf..c54c210 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/config.c b/app/config.c index be2a12e..7a7ed82 100644 --- a/app/config.c +++ b/app/config.c @@ -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) { diff --git a/boot/bootparams.h b/boot/bootparams.h index 49ec96c..45d95c4 100644 --- a/boot/bootparams.h +++ b/boot/bootparams.h @@ -15,6 +15,8 @@ #include +#include + typedef struct { uint8_t orig_x; uint8_t orig_y; diff --git a/system/keyboard.c b/system/keyboard.c index 513b42d..71a37af 100644 --- a/system/keyboard.c +++ b/system/keyboard.c @@ -3,6 +3,8 @@ #include +#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); }