|
ginnOS
The reference: libc, the libraries and the kernel
|
start the other cores (application processors) of an x86 machine. More...
#include "arch/arch.h"#include "arch/arch_cpu.h"#include "arch/x86/cpu/apic.h"#include "arch/x86/cpu/double_fault.h"#include "arch/x86/cpu/gdt.h"#include "arch/x86/cpu/idt.h"#include "arch/x86/cpu/paging.h"#include "arch/x86/cpu/pat.h"#include "common/memory.h"#include "drivers/pit/pit.h"#include "kernel/assert.h"#include "kernel/cpu/cpu.h"#include "kernel/memory/pmm.h"#include "kernel/process/process.h"#include "kernel/syscall/syscall.h"Macros | |
| #define | LOW_PAGE_LIMIT 0x100u |
| #define | CR4_PCIDE (1u << 17) |
| #define | MSR_EFER 0xC0000080u |
| #define | EFER_LMA (1u << 10) |
| #define | INIT_WAIT_US 10000u |
| #define | STARTUP_WAIT_US 200u |
| #define | ANSWER_WAIT_US 100000u |
| #define | POLL_US 100u |
Functions | |
| void | smp_ap_entry (cpu_t *cpu) |
| the first C code of a core other than the boot core. | |
| void | arch_smp_reserve (void) |
| keep a page of low memory for the start code of the other cores. | |
| bool | arch_smp_prepare (cpu_t *boot) |
| get ready to start the other cores: copy the start code to its page and make the page tables it uses. | |
| bool | arch_cpu_start (cpu_t *cpu) |
| start one core and wait up to 100 ms for it to say it is online. | |
| void | arch_smp_finish (bool all_started) |
| release what only the start of the cores used. | |
| void | arch_cpu_send_ipi (const cpu_t *cpu, arch_ipi_t ipi) |
Variables | |
| const uint8_t | ap_trampoline_start [] |
| const uint8_t | ap_trampoline_end [] |
| const uint8_t | ap_trampoline_data [] |
start the other cores (application processors) of an x86 machine.
a core that gets INIT and then a startup IPI (SIPI) starts in real mode at a page below 1 MiB that the SIPI gives. the trampoline (asm/ap_trampoline.asm, asm64/ap_trampoline.asm) is copied to that page. it changes to protected mode (and to long mode on x86_64) with a temporary page table, and jumps to smp_ap_entry() on the stack of the core. the temporary page table is a copy of the kernel half of the kernel's tables, with the trampoline page also at its own address. the sequence is from the Intel SDM, volume 3, 8.4, as in Linux's smpboot.c.
the boot core starts one core at a time and waits for it, so one data block in the trampoline page is enough.
| #define LOW_PAGE_LIMIT 0x100u |
| #define CR4_PCIDE (1u << 17) |
| #define MSR_EFER 0xC0000080u |
| #define EFER_LMA (1u << 10) |
| #define INIT_WAIT_US 10000u |
| #define STARTUP_WAIT_US 200u |
| #define ANSWER_WAIT_US 100000u |
| #define POLL_US 100u |
| void smp_ap_entry | ( | cpu_t * | cpu | ) |
the first C code of a core other than the boot core.
the trampoline jumps here with the temporary page table, interrupts off, and the stack of the core. never returns.
| cpu | the cpu_t of the core. |
| void arch_smp_reserve | ( | void | ) |
keep a page of low memory for the start code of the other cores.
call it right after pmm_init, before other allocations can take that memory.
start one core and wait up to 100 ms for it to say it is online.
| cpu | its cpu_t, with index, apic_id and idle_stack set. |
| void arch_smp_finish | ( | bool | all_started | ) |
release what only the start of the cores used.
| all_started | false if a core did not answer: then the start code and its page tables stay, because that core can still start late. |
| void arch_cpu_send_ipi | ( | const cpu_t * | cpu, |
| arch_ipi_t | ipi ) |
|
extern |
|
extern |
|
extern |