Skip to content

Commit

Permalink
(lib/setup) replace some hardcoded 4 with (MAX|NO)_CPUS
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner committed May 28, 2024
1 parent 7a9af93 commit 504f6e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion inc/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct
struct arm_implementation impl;
} thread_info_t;

extern thread_info_t thread_infos[4];
extern thread_info_t thread_infos[MAX_CPUS];

u64 get_cpu(void);
u64 get_vcpu(void);
Expand Down
2 changes: 1 addition & 1 deletion lib/arch/cpu_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ thread_info_t* current_thread_info() {
}

void cpu_data_init(void) {
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_CPUS; i++) {
cpu_data[i].started = 0;
cpu_data[i].to_execute = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/litmus_test/litmus_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void run_test(const litmus_test_t* cfg) {
/* run it */
if (TRACE) {
printf("#");
for (int i = 0; i < 4; i++) {
for (int i = 0; i < NO_CPUS; i++) {
printf("P%d\t\t\t", i);
}
printf("\n");
Expand Down
11 changes: 6 additions & 5 deletions lib/setup.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <lib.h>

#include "device.h"
#include "vmm.h"

extern u64 __argc;
extern char* __argv[100];

/* per-thread boot data */
cpu_data_t cpu_data[4];
cpu_data_t cpu_data[MAX_CPUS];

/** setup is called very early
* before the UART is enabled
Expand Down Expand Up @@ -209,12 +210,12 @@ void ensure_cpus_on(void) {
per_cpu_setup(0);

debug("booting all CPUs ...\n");
cpu_boot(1);
cpu_boot(2);
cpu_boot(3);
for (int i = 1; i < NO_CPUS; i++) {
cpu_boot(i);
}
debug("started boot.\n");

for (int i = 0; i < 4; i++) {
for (int i = 0; i < NO_CPUS; i++) {
while (!cpu_data[i].started)
wfe();
}
Expand Down

0 comments on commit 504f6e1

Please sign in to comment.