|
PatchworkOS
|
Symmetric multi processing. More...
Functions | |
| void | smp_bootstrap_init_early (void) |
| Early initialization of the bootstrap CPU. | |
| void | smp_bootstrap_init (void) |
| Initializes the bootstrap CPU structure. | |
| void | smp_others_init (void) |
| Initializes the other CPUs. | |
| void | smp_halt_others (void) |
| Halts all CPUs except the current one. | |
| static uint16_t | smp_cpu_amount (void) |
| Returns the number of CPUs currently identified. | |
| static cpu_t * | smp_cpu (cpuid_t id) |
| Returns a pointer to the cpu_t structure of the CPU with the given id. | |
| static cpu_t * | smp_self_unsafe (void) |
| Returns a pointer to the cpu_t structure of the current CPU. | |
| static cpuid_t | smp_self_id_unsafe (void) |
| Returns the id of the current CPU. | |
| static cpu_t * | smp_self (void) |
| Returns a pointer to the cpu_t structure of the current CPU. | |
| static void | smp_put (void) |
Re-enables interrupts after a call to smp_self(). | |
Variables | |
| cpu_t * | _cpus [CPU_MAX] |
| Array of pointers to cpu_t structures for each CPU. | |
| uint16_t | _cpuAmount |
| The number of CPUs currently identified. | |
Symmetric multi processing.
This module handles symmetric multi processing (SMP) support, storing the cpu_t structures for each CPU and being responsible for identifiying and starting them.
| void smp_bootstrap_init | ( | void | ) |
Initializes the bootstrap CPU structure.
It must be called only once, by the bootstrap CPU.
Definition at line 31 of file smp.c.
References _cpus, CPU_ID_BOOTSTRAP, cpu_init(), ERR, NULL, and panic().
Referenced by init_early().
| void smp_bootstrap_init_early | ( | void | ) |
Early initialization of the bootstrap CPU.
This function will set the CPU ID MSR to 0 for the bootstrap CPU.
This is really just to fix circular dependencies during memory initialization.
Definition at line 26 of file smp.c.
References CPU_ID_BOOTSTRAP, MSR_CPU_ID, and msr_write().
Referenced by init_early().
Returns a pointer to the cpu_t structure of the CPU with the given id.
| id | The id of the CPU. |
Definition at line 77 of file smp.h.
Referenced by sched_find_least_loaded_cpu(), sched_get_neighbor(), and statistics_cpu_read().
|
inlinestatic |
Returns the number of CPUs currently identified.
Definition at line 66 of file smp.h.
References _cpuAmount.
Referenced by sched_find_least_loaded_cpu(), sched_get_neighbor(), sched_load_balance(), space_tlb_shootdown(), and statistics_cpu_read().
| void smp_halt_others | ( | void | ) |
Halts all CPUs except the current one.
Definition at line 102 of file smp.c.
References _cpuAmount, _cpus, cpu_t::id, INTERRUPT_HALT, lapic_send_ipi(), and smp_self_unsafe().
Referenced by panic().
| void smp_others_init | ( | void | ) |
Initializes the other CPUs.
It must be called only once, by the bootstrap CPU, after smp_bootstrap_init().
Definition at line 40 of file smp.c.
References _cpuAmount, _cpus, acpi_tables_lookup(), processor_local_apic_t::apicId, CLOCKS_PER_SEC, ERR, processor_local_apic_t::flags, processor_local_apic_t::header, INTERRUPT_CONTROLLER_PROCESSOR_LOCAL_APIC, lapic_self_id(), LOG_INFO, madt, MADT_FOR_EACH, MADT_SIGNATURE, memset(), newId, NULL, panic(), PML_GLOBAL, PML_PRESENT, PML_WRITE, PROCESSOR_LOCAL_APIC_ENABLED, trampoline_deinit(), trampoline_init(), trampoline_send_startup_ipi(), trampoline_wait_ready(), interrupt_controller_header_t::type, vmm_alloc(), and VMM_ALLOC_FAIL_IF_MAPPED.
Referenced by init_finalize().
|
inlinestatic |
Re-enables interrupts after a call to smp_self().
Definition at line 125 of file smp.h.
References interrupt_enable().
Referenced by rand_gen(), sched_push(), sched_push_new_thread(), sched_thread(), sched_yield(), wait_block_cancel(), wait_block_commit(), and wait_block_setup().
|
inlinestatic |
Returns a pointer to the cpu_t structure of the current CPU.
This function is safe because it disables interrupts. It is important to always call smp_put() after using this function to re-enable interrupts.
Definition at line 115 of file smp.h.
References _cpus, interrupt_disable(), MSR_CPU_ID, and msr_read().
Referenced by rand_gen(), sched_push(), sched_push_new_thread(), sched_thread(), sched_yield(), and wait_block_setup().
|
inlinestatic |
Returns the id of the current CPU.
This function is unsafe because it does not disable interrupts, so it must be called with interrupts disabled.
Definition at line 102 of file smp.h.
References MSR_CPU_ID, and msr_read().
|
inlinestatic |
Returns a pointer to the cpu_t structure of the current CPU.
This function is unsafe because it does not disable interrupts, so it must be called with interrupts disabled. It is useful in low-level code where disabling interrupts is necessary anyway, for example in interrupt handlers.
Definition at line 90 of file smp.h.
References _cpus, MSR_CPU_ID, and msr_read().
Referenced by exception_handler(), init_early(), interrupt_disable(), interrupt_enable(), interrupt_handler(), irq_install(), lapic_cpu_init(), log_print_header(), panic(), process_procfs_init(), rand_cpu_init(), sched_done_with_boot_thread(), sched_thread_unsafe(), simd_cpu_init(), smp_halt_others(), space_load(), space_tlb_shootdown(), timer_ctx_init(), vmm_cpu_ctx_init(), vmm_init(), wait_block_cancel(), and wait_block_commit().
|
extern |
The number of CPUs currently identified.
Definition at line 22 of file smp.c.
Referenced by smp_cpu_amount(), smp_halt_others(), and smp_others_init().
Array of pointers to cpu_t structures for each CPU.
Definition at line 21 of file smp.c.
Referenced by smp_bootstrap_init(), smp_cpu(), smp_halt_others(), smp_others_init(), smp_self(), and smp_self_unsafe().