mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2024-11-23 08:26:23 -06:00
Add usbdebug command line option and conditionally pause at end of USB scan.
If the usbdebug option is present, pause at the end of the USB scan until a key is pressed. Otherwise, if the keyboard=usb option is present and no USB keyboards were discovered, pause for 10 seconds. Otherwise don't pause.
This commit is contained in:
parent
d1cafa9f64
commit
644a13c730
@ -191,6 +191,8 @@ static void parse_option(const char *option, const char *params)
|
||||
smp_enabled = true;
|
||||
} else if (strncmp(option, "trace", 6) == 0) {
|
||||
enable_trace = true;
|
||||
} else if (strncmp(option, "usbdebug", 9) == 0) {
|
||||
usb_init_options |= USB_DEBUG;
|
||||
} else if (strncmp(option, "nosm", 5) == 0) {
|
||||
enable_sm = false;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ static void global_init(void)
|
||||
|
||||
config_init();
|
||||
|
||||
keyboard_init(pause_at_start);
|
||||
keyboard_init();
|
||||
|
||||
display_init();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (C) 2020-2021 Martin Whitaker.
|
||||
// Copyright (C) 2020-2022 Martin Whitaker.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -218,10 +218,10 @@ keyboard_types_t keyboard_types = KT_LEGACY | KT_USB;
|
||||
// Public Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void keyboard_init(bool pause_at_end)
|
||||
void keyboard_init(void)
|
||||
{
|
||||
if (keyboard_types & KT_USB) {
|
||||
find_usb_keyboards(pause_at_end);
|
||||
find_usb_keyboards(keyboard_types == KT_USB);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ extern keyboard_types_t keyboard_types;
|
||||
/**
|
||||
* Initialises the keyboard interface.
|
||||
*/
|
||||
void keyboard_init(bool pause_at_end);
|
||||
void keyboard_init(void);
|
||||
|
||||
/**
|
||||
* Checks if a key has been pressed and returns the primary ASCII character
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#define MAX_USB_CONTROLLERS 8 // an arbitrary limit - must match the initialisation of usb_controllers
|
||||
|
||||
#define PAUSE_IF_NONE_TIME 10 // seconds
|
||||
|
||||
#define MILLISEC 1000 // in microseconds
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -681,7 +683,7 @@ static void probe_usb_controller(int bus, int dev, int func, hci_type_t controll
|
||||
// Public Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void find_usb_keyboards(bool pause_at_end)
|
||||
void find_usb_keyboards(bool pause_if_none)
|
||||
{
|
||||
clear_screen();
|
||||
print_usb_info("Scanning for USB keyboards...");
|
||||
@ -738,9 +740,15 @@ void find_usb_keyboards(bool pause_at_end)
|
||||
}
|
||||
}
|
||||
|
||||
if (pause_at_end) {
|
||||
if (usb_init_options & USB_DEBUG) {
|
||||
print_usb_info("Press any key to continue...");
|
||||
while (get_key() == 0) {}
|
||||
} else if (pause_if_none && num_usb_controllers == 0) {
|
||||
for (int i = PAUSE_IF_NONE_TIME; i > 0; i--) {
|
||||
print_usb_info("No USB keyboards found. Continuing in %i second%c ", i, i == 1 ? ' ' : 's');
|
||||
sleep(1);
|
||||
print_row--; // overwrite message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,8 @@ typedef struct usb_hcd_s {
|
||||
typedef enum {
|
||||
USB_DEFAULT_INIT = 0,
|
||||
USB_EXTRA_RESET = 1 << 0,
|
||||
USB_IGNORE_EHCI = 1 << 1
|
||||
USB_IGNORE_EHCI = 1 << 1,
|
||||
USB_DEBUG = 1 << 2
|
||||
} usb_init_options_t;
|
||||
|
||||
/**
|
||||
@ -266,7 +267,7 @@ bool find_attached_usb_keyboards(const usb_hcd_t *hcd, const usb_hub_t *hub, int
|
||||
*
|
||||
* Used internally by keyboard.c.
|
||||
*/
|
||||
void find_usb_keyboards(bool pause_at_end);
|
||||
void find_usb_keyboards(bool pause_if_none);
|
||||
|
||||
/**
|
||||
* Polls the keyboards discovered by find_usb_keyboards. Consumes and returns
|
||||
|
Loading…
Reference in New Issue
Block a user