mirror of
https://github.com/memtest86plus/memtest86plus
synced 2025-03-13 01:13:11 +03:00
Add support for boot command line options.
This commit is contained in:
parent
ad6c7d0455
commit
733919966d
136
app/config.c
136
app/config.c
@ -15,6 +15,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "boot.h"
|
||||
#include "bootparams.h"
|
||||
|
||||
#include "cpuinfo.h"
|
||||
#include "hwctrl.h"
|
||||
#include "keyboard.h"
|
||||
@ -22,9 +25,11 @@
|
||||
#include "pmem.h"
|
||||
#include "screen.h"
|
||||
#include "smp.h"
|
||||
#include "usbkbd.h"
|
||||
|
||||
#include "read.h"
|
||||
#include "print.h"
|
||||
#include "string.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#include "display.h"
|
||||
@ -56,6 +61,8 @@ static const char *cpu_mode_str[] = { "PAR", "SEQ", "RR " };
|
||||
|
||||
static uint16_t popup_save_buffer[POP_W * POP_H];
|
||||
|
||||
static bool smp_enabled = false;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
//------------------------------------------------------------------------------
|
||||
@ -74,10 +81,66 @@ bool enable_pcpu[MAX_PCPUS];
|
||||
bool enable_temperature = false;
|
||||
bool enable_trace = false;
|
||||
|
||||
bool pause_at_start = true;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static void parse_option(const char *option, const char *params)
|
||||
{
|
||||
if (option[0] == '\0') return;
|
||||
|
||||
if (strncmp(option, "keyboard", 9) == 0 && params != NULL) {
|
||||
if (strncmp(params, "legacy", 7) == 0) {
|
||||
keyboard_types = KT_LEGACY;
|
||||
} else if (strncmp(params, "usb", 4) == 0) {
|
||||
keyboard_types = KT_USB;
|
||||
} else if (strncmp(params, "buggy-usb", 10) == 0) {
|
||||
keyboard_types = KT_USB;
|
||||
usb_init_options = USB_EXTRA_RESET;
|
||||
}
|
||||
} else if (strncmp(option, "nopause", 8) == 0) {
|
||||
pause_at_start = false;
|
||||
} else if (strncmp(option, "smp", 4) == 0) {
|
||||
smp_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_command_line(char *cmd_line, int cmd_line_size)
|
||||
{
|
||||
const char *option = cmd_line;
|
||||
const char *params = NULL;
|
||||
for (int i = 0; i < cmd_line_size; i++) {
|
||||
switch (cmd_line[i]) {
|
||||
case '\0':
|
||||
parse_option(option, params);
|
||||
return;
|
||||
case ' ':
|
||||
cmd_line[i] = '\0';
|
||||
parse_option(option, params);
|
||||
option = &cmd_line[i+1];
|
||||
params = NULL;
|
||||
break;
|
||||
case '=':
|
||||
cmd_line[i] = '\0';
|
||||
params = &cmd_line[i+1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void display_initial_notice(void)
|
||||
{
|
||||
if (smp_enabled) {
|
||||
display_notice("Press <F1> to configure, <F2> to disable SMP, <Enter> to start testing");
|
||||
} else {
|
||||
display_notice("Press <F1> to configure, <F2> to enable SMP, <Enter> to start testing ");
|
||||
}
|
||||
}
|
||||
|
||||
static void update_num_pages_to_test(void)
|
||||
{
|
||||
num_pages_to_test = 0;
|
||||
@ -496,7 +559,15 @@ void config_init(void)
|
||||
}
|
||||
|
||||
enable_temperature = !no_temperature;
|
||||
enable_trace = false;
|
||||
|
||||
const boot_params_t *boot_params = (boot_params_t *)boot_params_addr;
|
||||
|
||||
uintptr_t cmd_line_addr = boot_params->cmd_line_ptr;
|
||||
if (cmd_line_addr != 0) {
|
||||
int cmd_line_size = boot_params->cmd_line_size;
|
||||
if (cmd_line_size == 0) cmd_line_size = 255;
|
||||
parse_command_line((char *)cmd_line_addr, cmd_line_size);
|
||||
}
|
||||
}
|
||||
|
||||
void config_menu(bool initial)
|
||||
@ -586,42 +657,39 @@ void config_menu(bool initial)
|
||||
|
||||
void initial_config(void)
|
||||
{
|
||||
display_notice("Press <F1> to configure, <F2> to enable SMP, <Enter> to start testing ");
|
||||
display_initial_notice();
|
||||
|
||||
bool got_key = false;
|
||||
bool smp_enabled = false;
|
||||
bool smp_init_done = false;
|
||||
for (int i = 0; i < 5000 && !got_key; i++) {
|
||||
usleep(1000);
|
||||
switch (get_key()) {
|
||||
case ESC:
|
||||
clear_message_area();
|
||||
display_notice("Rebooting...");
|
||||
reboot();
|
||||
break;
|
||||
case '1':
|
||||
smp_init(smp_enabled);
|
||||
smp_init_done = true;
|
||||
config_menu(true);
|
||||
got_key = true;
|
||||
break;
|
||||
case '2':
|
||||
smp_enabled = !smp_enabled;
|
||||
if (smp_enabled) {
|
||||
display_notice("Press <F1> to configure, <F2> to disable SMP, <Enter> to start testing");
|
||||
} else {
|
||||
display_notice("Press <F1> to configure, <F2> to enable SMP, <Enter> to start testing ");
|
||||
if (pause_at_start) {
|
||||
bool got_key = false;
|
||||
for (int i = 0; i < 5000 && !got_key; i++) {
|
||||
usleep(1000);
|
||||
switch (get_key()) {
|
||||
case ESC:
|
||||
clear_message_area();
|
||||
display_notice("Rebooting...");
|
||||
reboot();
|
||||
break;
|
||||
case '1':
|
||||
smp_init(smp_enabled);
|
||||
smp_init_done = true;
|
||||
config_menu(true);
|
||||
got_key = true;
|
||||
break;
|
||||
case '2':
|
||||
smp_enabled = !smp_enabled;
|
||||
display_initial_notice();
|
||||
i = 0;
|
||||
break;
|
||||
case ' ':
|
||||
toggle_scroll_lock();
|
||||
break;
|
||||
case '\n':
|
||||
got_key = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
i = 0;
|
||||
break;
|
||||
case ' ':
|
||||
toggle_scroll_lock();
|
||||
break;
|
||||
case '\n':
|
||||
got_key = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!smp_init_done) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
/*
|
||||
* Provides the configuration settings and pop-up menu.
|
||||
*
|
||||
* Copyright (C) 2020 Martin Whitaker.
|
||||
* Copyright (C) 2020-2021 Martin Whitaker.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
@ -39,6 +39,8 @@ extern bool enable_pcpu[MAX_PCPUS];
|
||||
extern bool enable_temperature;
|
||||
extern bool enable_trace;
|
||||
|
||||
extern bool pause_at_start;
|
||||
|
||||
void config_init(void);
|
||||
|
||||
void config_menu(bool initial);
|
||||
|
@ -151,7 +151,7 @@ static void global_init(void)
|
||||
|
||||
config_init();
|
||||
|
||||
keyboard_init(true);
|
||||
keyboard_init(pause_at_start);
|
||||
|
||||
display_init();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* the Linux boot_params struct, although we only define the fields we are
|
||||
* interested in.
|
||||
*
|
||||
* Copyright (C) 2020 Martin Whitaker.
|
||||
* Copyright (C) 2020-2021 Martin Whitaker.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
@ -94,9 +94,13 @@ typedef struct {
|
||||
uint8_t e820_entries;
|
||||
uint8_t unused4[0x214 - 0x1e9];
|
||||
uint32_t code32_start;
|
||||
uint8_t unused5[0x2d0 - 0x218];
|
||||
uint8_t unused5[0x228 - 0x218];
|
||||
uint32_t cmd_line_ptr;
|
||||
uint8_t unused6[0x238 - 0x22c];
|
||||
uint32_t cmd_line_size;
|
||||
uint8_t unused7[0x2d0 - 0x23c];
|
||||
e820_entry_t e820_map[E820_MAP_SIZE];
|
||||
uint8_t unused6[0xeec - 0xd00];
|
||||
uint8_t unused8[0xeec - 0xd00];
|
||||
} __attribute__((packed)) boot_params_t;
|
||||
|
||||
#endif /* BOOTPARAMS_H */
|
||||
|
@ -9,7 +9,7 @@
|
||||
// boot_params struct. A pointer to this block is passed to the main program,
|
||||
// for compatiblity with the Linux 32-bit boot protocol.
|
||||
//
|
||||
// Copyright (C) 2020 Martin Whitaker.
|
||||
// Copyright (C) 2020-2021 Martin Whitaker.
|
||||
//
|
||||
// Derived from memtest86+ setup.S and head.S:
|
||||
//
|
||||
@ -162,6 +162,13 @@ do_setup:
|
||||
|
||||
movl %eax, (BOOT_PARAMS_START + 0x214)
|
||||
|
||||
# Copy cmd_line_ptr and cmd_line_size to the boot_params struct.
|
||||
|
||||
movl (cmd_line_ptr - setup), %eax
|
||||
movl %eax, (BOOT_PARAMS_START + 0x228)
|
||||
movl (cmd_line_size - setup), %eax
|
||||
movl %eax, (BOOT_PARAMS_START + 0x238)
|
||||
|
||||
# Switch to protected mode.
|
||||
|
||||
movl %cr0, %eax
|
||||
|
Loading…
x
Reference in New Issue
Block a user