diff --git a/src/platform/x86_64/apic/smp.c b/src/platform/x86_64/apic/smp.c index b37a350..e3d6965 100644 --- a/src/platform/x86_64/apic/smp.c +++ b/src/platform/x86_64/apic/smp.c @@ -66,6 +66,38 @@ void *platformGetCPU(int n) { return cpu; } +/* findCPUACPI(): returns a CPU structure associated with an ACPI ID + * params: id - ACPI ID + * returns: pointer to CPU structure, NULL if not present + */ + +PlatformCPU *findCPUACPI(uint8_t id) { + PlatformCPU *list = cpus; + + while(list) { + if(list->procID == id) return list; + list = list->next; + } + + return NULL; +} + +/* findCPUAPIC(): returns a CPU structure associated with an APIC ID + * params: id - ACPI ID + * returns: pointer to CPU structure, NULL if not present + */ + +PlatformCPU *findCPUAPIC(uint8_t id) { + PlatformCPU *list = cpus; + + while(list) { + if(list->apicID == id) return list; + list = list->next; + } + + return NULL; +} + /* smpCPUInfoSetup(): constructs per-CPU kernel info structure and stores it in * the kernel's GS base, also sets up a per-CPU GDT and TSS and stack */ diff --git a/src/platform/x86_64/include/platform/smp.h b/src/platform/x86_64/include/platform/smp.h index f18da0b..4257b95 100644 --- a/src/platform/x86_64/include/platform/smp.h +++ b/src/platform/x86_64/include/platform/smp.h @@ -48,6 +48,9 @@ void smpCPUInfoSetup(); int smpBoot(); KernelCPUInfo *getKernelCPUInfo(); +PlatformCPU *findCPUACPI(uint8_t); +PlatformCPU *findCPUAPIC(uint8_t); + /* entry point for non-boot CPUs */ extern uint8_t apEntry[];