36 panic(
NULL,
"Failed to initialize bootstrap cpu");
static atomic_uint64_t newId
#define PROCESSOR_LOCAL_APIC_ENABLED
sdt_header_t * acpi_tables_lookup(const char *signature, uint64_t n)
Lookup the n'th table matching the signature.
#define INTERRUPT_CONTROLLER_PROCESSOR_LOCAL_APIC
#define MADT_FOR_EACH(madt, ic)
Iterate over all MADT interrupt controllers.
#define MADT_SIGNATURE
MADT table signature.
@ INTERRUPT_HALT
Halt the CPU.
void smp_bootstrap_init(void)
Initializes the bootstrap CPU structure.
static cpu_t * smp_self_unsafe(void)
Returns a pointer to the cpu_t structure of the current CPU.
void smp_bootstrap_init_early(void)
Early initialization of the bootstrap CPU.
cpu_t * _cpus[CPU_MAX]
Array of pointers to cpu_t structures for each CPU.
void smp_others_init(void)
Initializes the other CPUs.
uint16_t _cpuAmount
The number of CPUs currently identified.
void smp_halt_others(void)
Halts all CPUs except the current one.
void trampoline_send_startup_ipi(cpu_t *cpu, cpuid_t cpuId, lapic_id_t lapicId)
Sends the startup IPI to a CPU to start it up.
void trampoline_deinit(void)
Deinitializes the trampoline by restoring the original contents of the trampoline memory location.
uint64_t trampoline_wait_ready(clock_t timeout)
Waits for the currently starting CPU to signal that it is ready.
void trampoline_init(void)
Initializes the trampoline by copying the trampoline code to its designated memory location.
#define CPU_MAX
Maximum number of CPUs supported.
uint64_t cpu_init(cpu_t *cpu, cpuid_t id)
Initializes a CPU structure as part of the boot process.
#define CPU_ID_BOOTSTRAP
ID of the bootstrap CPU.
uint16_t cpuid_t
Type used to identify a CPU.
#define ALIGNED(alignment)
GCC aligned attribute.
lapic_id_t lapic_self_id(void)
Get the lapic id of the current cpu.
void lapic_send_ipi(lapic_id_t id, interrupt_t vector)
Send an Inter-Processor Interrupt (IPI) to a local apic.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_INFO(format,...)
void * vmm_alloc(space_t *space, void *virtAddr, uint64_t length, pml_flags_t pmlFlags, vmm_alloc_flags_t allocFlags)
Allocates and maps virtual memory in a given address space.
@ VMM_ALLOC_FAIL_IF_MAPPED
If set and any page is already mapped, fail and set errno to EEXIST.
#define PAGE_SIZE
Memory page size.
#define NULL
Pointer error value.
#define ERR
Integer error value.
static void msr_write(uint32_t msr, uint64_t value)
static void smp_halt_ipi(interrupt_frame_t *frame)
static atomic_uint16_t haltedAmount
#define ATOMIC_VAR_INIT(value)
#define atomic_fetch_add(object, operand)
_PUBLIC void * memset(void *s, int c, size_t n)
Multiple APIC Description Table.
interrupt_controller_header_t header