Skip to content

Commit

Permalink
x86_64: find CPUs by APIC and ACPI IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Oct 8, 2024
1 parent ba05122 commit fadca39
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/platform/x86_64/apic/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
3 changes: 3 additions & 0 deletions src/platform/x86_64/include/platform/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit fadca39

Please sign in to comment.