From 8825b399c4ea89184fbce73a011fb7f5c43060ae Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Mon, 16 Feb 2015 13:59:24 -0800 Subject: [PATCH] Improve MP debugging --- sys/amd64/mp.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/sys/amd64/mp.c b/sys/amd64/mp.c index 959cca7..134777c 100644 --- a/sys/amd64/mp.c +++ b/sys/amd64/mp.c @@ -14,14 +14,23 @@ #include #include -#define MP_WAITTIME 250000000ULL - extern uint8_t mpstart_begin[]; extern uint8_t mpstart_end[]; extern AS systemAS; -volatile bool booted; +#define MP_WAITTIME 250000000ULL + +#define CPUSTATE_NOT_PRESENT 0 +#define CPUSTATE_BOOTED 1 + +typedef struct CPUState { + int state; + UnixEpochNS heartbeat; +} CPUState; + +volatile static bool booted; +volatile static CPUState cpus[MAX_CPUS]; static int MPBootAP(int procNo) @@ -75,18 +84,28 @@ MP_Init() if (MPBootAP(i) < 0) break; } + + cpus[CPU()].state = CPUSTATE_BOOTED; } void MP_InitAP() { kprintf("AP %d booted!\n", CPU()); + cpus[CPU()].state = CPUSTATE_BOOTED; booted = 1; } static void Debug_CPUS(int argc, const char *argv[]) { + int c; + + for (c = 0; c < MAX_CPUS; c++) { + if (cpus[c].state != CPUSTATE_NOT_PRESENT) { + kprintf("CPU %d: BOOTED\n", c); + } + } } REGISTER_DBGCMD(cpus, "Show MP information", Debug_CPUS);