From 27c5fe363ff9fd7278cce94c7fa739c38e5ba29c Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 10 Dec 2020 12:52:58 +0000 Subject: [PATCH] Add startup option to enable/disable SMP. --- README.md | 4 +++- app/config.c | 18 +++++++++++++++++- app/main.c | 2 -- system/smp.c | 6 ++++-- system/smp.h | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c541136..8e40e92 100644 --- a/README.md +++ b/README.md @@ -99,13 +99,15 @@ the system was booted in UEFI mode, graphics mode must be used. Once booted, PCMemTest will initialise its display, then pause for a few seconds to allow the user to configure its operation. If no key is pressed, -it will automatically start running all tests using all available CPU cores, +it will automatically start running all tests using a single CPU core, continuing indefinitely until the user reboots or halts the machine. At startup, and when running tests, PCMemTest responds to the following keys: * F1 * enters the configuration menu + * F2 + * toggles detection and use of multiple CPU cores (SMP) * Space * toggles scroll lock (stops/starts error message scrolling) * Enter diff --git a/app/config.c b/app/config.c index 58b30a7..96426f3 100644 --- a/app/config.c +++ b/app/config.c @@ -586,9 +586,11 @@ void config_menu(bool initial) void initial_config(void) { - display_notice("Press to configure, to start testing"); + display_notice("Press to configure, to enable SMP, to start testing "); 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()) { @@ -598,9 +600,20 @@ void initial_config(void) 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 to configure, to disable SMP, to start testing"); + } else { + display_notice("Press to configure, to enable SMP, to start testing "); + } + i = 0; + break; case ' ': toggle_scroll_lock(); break; @@ -611,4 +624,7 @@ void initial_config(void) break; } } + if (!smp_init_done) { + smp_init(smp_enabled); + } } diff --git a/app/main.c b/app/main.c index f57b743..0d5d0f5 100644 --- a/app/main.c +++ b/app/main.c @@ -155,8 +155,6 @@ static void global_init(void) error_init(); - smp_init(); - initial_config(); clear_message_area(); diff --git a/system/smp.c b/system/smp.c index a55ac92..bcdde84 100644 --- a/system/smp.c +++ b/system/smp.c @@ -631,7 +631,7 @@ static smp_error_t start_cpu(int pcpu_num) // Public Functions //------------------------------------------------------------------------------ -void smp_init(void) +void smp_init(bool smp_enable) { for (int i = 0; i < MAX_APIC_IDS; i++) { apic_id_to_pcpu_num[i] = 0; @@ -644,7 +644,9 @@ void smp_init(void) num_pcpus = 1; - (void)(find_cpus_in_rsdp() || find_cpus_in_floating_mp_struct()); + if (smp_enable) { + (void)(find_cpus_in_rsdp() || find_cpus_in_floating_mp_struct()); + } for (int i = 0; i < num_pcpus; i++) { apic_id_to_pcpu_num[pcpu_num_to_apic_id[i]] = i; diff --git a/system/smp.h b/system/smp.h index 092113e..eb3de6a 100644 --- a/system/smp.h +++ b/system/smp.h @@ -39,7 +39,7 @@ extern int num_pcpus; /* * Initialises the SMP state and detects the number of physical CPUs. */ -void smp_init(void); +void smp_init(bool smp_enable); /* * Starts the selected APs.