diff options
author | AlmuHS <liberamenso10000@gmail.com> | 2019-03-29 17:36:29 +0100 |
---|---|---|
committer | AlmuHS <liberamenso10000@gmail.com> | 2019-03-29 17:36:29 +0100 |
commit | 9f5c0d044a6fbb2b5185079ca04a5a4df75966d4 (patch) | |
tree | 97bf5ae26c902af7af62f8bc368e2f4244c4a7d1 /kern | |
parent | 3dee26b037c7b88ad9652be28e2ece7dd11aa089 (diff) |
split cpu_number in a new file
Diffstat (limited to 'kern')
-rw-r--r-- | kern/cpu_number.c | 19 | ||||
-rw-r--r-- | kern/cpu_number.h | 21 |
2 files changed, 21 insertions, 19 deletions
diff --git a/kern/cpu_number.c b/kern/cpu_number.c new file mode 100644 index 00000000..e7942d6b --- /dev/null +++ b/kern/cpu_number.c @@ -0,0 +1,19 @@ +#include <kern/cpu_number.h> +#include <i386at/acpi_rsdp.h> + +int +cpu_number() +{ + if(ncpu == 1) return 0; + else if(lapic != 0){ + + unsigned apic_id = lapic->apic_id.r >>24; + int i = 0; + + while(i< ncpu && machine_slot[i].apic_id != apic_id) i++; + + if(i == ncpu) return -1; + else return i; + } + else return 0; +} diff --git a/kern/cpu_number.h b/kern/cpu_number.h index 675f225b..d15e20a2 100644 --- a/kern/cpu_number.h +++ b/kern/cpu_number.h @@ -29,7 +29,7 @@ #include <imps/apic.h> #include <mach/machine.h> -#include <i386at/acpi_rsdp.h> + /* * Definitions for cpu identification in multi-processors. @@ -44,24 +44,7 @@ unsigned int master_cpu; /* 'master' processor - keeps time */ #else /* NCPUS == 1 */ /*TODO: Get kernelID from cpus vector*/ - static inline int - cpu_number() - { - if(ncpu == 1) return 0; - else{ - if(lapic != 0){ - - unsigned apic_id = lapic->apic_id.r >>24; - int i = 0; - - while(i< ncpu && machine_slot[i].apic_id != apic_id) i++; - - if(i == ncpu) return -1; - else return i; - } - else return 0; - } - } + int cpu_number(); #endif /* NCPUS != 1 */ |