|
ginnOS
The reference: libc, the libraries and the kernel
|
the data of each core (per-CPU data). More...
Go to the source code of this file.
Data Structures | |
| struct | cpu_times_t |
| the timer ticks of a core since boot, as the "cpu" lines of Linux's /proc/stat. More... | |
| struct | cpu |
| the data of one core More... | |
Macros | |
| #define | CPU_MAX 64 |
| the most cores that ginnOS uses | |
| #define | CPU_SELF 0 |
| the offsets that the assembly uses (asm64/syscall.asm); cpu.c checks them | |
| #define | CPU_KERNEL_SP (1 * (int)sizeof(uintptr_t)) |
| #define | CPU_USER_SP (2 * (int)sizeof(uintptr_t)) |
Typedefs | |
| typedef struct cpu | cpu_t |
| the data of one core | |
Functions | |
| void | cpu_init_boot (void) |
| set up the cpu_t of the boot core and point the per-CPU segment at it. | |
| void | smp_init (void) |
| start the other cores that the ACPI MADT gives, one at a time. | |
| void | cpu_ap_main (cpu_t *cpu, bool has_timer) __attribute__((noreturn)) |
| the rest of the start of a core other than the boot core, after the arch code has set up its registers, tables and local APIC. | |
Variables | |
| cpu_t | cpus [CPU_MAX] |
| the data of all cores; index 0 is the boot core | |
| bool | cpu_ready |
| true once cpu_init_boot() has run, so cpu_current() is valid | |
| uint32_t | cpu_count |
| the number of cores that run: cpus[0] to cpus[cpu_count - 1] | |
the data of each core (per-CPU data).
each core has a cpu_t, and a segment base points at it (arch/arch_cpu.h), so cpu_current() is one load. the state that belongs to "the core that runs this code", not to a process, is here.
the boot core starts the other cores (smp.c). each core runs processes from its own run queue (scheduler.c).
| #define CPU_MAX 64 |
the most cores that ginnOS uses
| #define CPU_SELF 0 |
the offsets that the assembly uses (asm64/syscall.asm); cpu.c checks them
| #define CPU_KERNEL_SP (1 * (int)sizeof(uintptr_t)) |
| #define CPU_USER_SP (2 * (int)sizeof(uintptr_t)) |
| void cpu_init_boot | ( | void | ) |
set up the cpu_t of the boot core and point the per-CPU segment at it.
call it once, right after the GDT is loaded, before anything uses cpu_current().
| void smp_init | ( | void | ) |
start the other cores that the ACPI MADT gives, one at a time.
the kernel command line can limit them: "nosmp" keeps only the boot core, "maxcpus=N" starts at most N cores, the boot core included. call it on the boot core with interrupts on, after apic_init.
the rest of the start of a core other than the boot core, after the arch code has set up its registers, tables and local APIC.
it marks the core online and becomes the idle task of the core, which runs processes from the run queue of the core.
| cpu | the cpu_t of the core that runs the call. |
| has_timer | true if the core has a timer. without one the scheduler cannot end a time slice on the core, so the core only halts and runs no processes. |
|
extern |
true once cpu_init_boot() has run, so cpu_current() is valid
|
extern |
the number of cores that run: cpus[0] to cpus[cpu_count - 1]