48 panic(
NULL,
"Failed to init exception stack for cpu %u\n", cpu->
id);
57 panic(
NULL,
"Failed to init double fault stack for cpu %u\n", cpu->
id);
66 panic(
NULL,
"Failed to init NMI stack for cpu %u\n", cpu->
id);
75 panic(
NULL,
"Failed to init interrupt stack for cpu %u\n", cpu->
id);
87 panic(
NULL,
"CPU%u exception stack overflow detected",
SELF->id);
91 panic(
NULL,
"CPU%u double fault stack overflow detected",
SELF->id);
99 panic(
NULL,
"CPU%u interrupt stack overflow detected",
SELF->id);
112 __builtin_unreachable();
126 return SELF->interruptStack.top;
static void cpu_halt_ipi_handler(ipi_func_data_t *data)
#define CONFIG_PERCPU_SIZE
Per-CPU data size configuration.
#define CONFIG_INTERRUPT_STACK_PAGES
Interrupt stack configuration.
void gdt_cpu_tss_load(tss_t *tss)
Load a TSS into the GDT and load it using the ltr instruction on the current CPU.
void gdt_cpu_load(void)
Load the GDT on the current CPU.
void idt_cpu_load(void)
Load the IDT on the current CPU.
uint64_t ipi_send(cpu_t *cpu, ipi_flags_t flags, ipi_func_t func, void *data)
Send an IPI to one or more CPUs.
@ IPI_OTHERS
Send the IPI to all CPUs except the specified CPU.
void percpu_init(cpu_t *cpu)
Initialize the percpu system.
#define SELF
Macro to access data in the current cpu.
void stack_pointer_deinit_buffer(stack_pointer_t *stack)
Deinitializes a stack pointer structure that was initialized using stack_pointer_init_buffer().
uint64_t stack_pointer_init_buffer(stack_pointer_t *stack, void *buffer, uint64_t pages)
Initializes a stack pointer structure using a provided buffer, does not allocate or map any memory.
void tss_ist_load(tss_t *tss, tss_ist_t ist, stack_pointer_t *stack)
Load a stack into an IST entry.
#define TSS_IST_NMI
The IST index to use for non-maskable interrupts.
void tss_init(tss_t *tss)
Initialize a TSS structure.
#define TSS_IST_INTERRUPT
The IST index to use for other interrupts.
#define TSS_IST_EXCEPTION
The IST index to use for exceptions.
#define TSS_IST_DOUBLE_FAULT
The IST index to use for double faults.
uint64_t cpu_halt_others(void)
Halts all other CPUs.
void cpu_stacks_overflow_check(void)
Checks the current CPU for stack overflows.
uintptr_t cpu_interrupt_stack_top(void)
Gets the top of the interrupt stack for the current CPU.
uint16_t cpu_id_t
Type used to identify a CPU.
void cpu_init(cpu_t *cpu)
Initializes a CPU structure.
#define CPU_MAX
Maximum number of CPUs supported.
cpu_t * _cpus[CPU_MAX]
Array of pointers to cpu_t structures for each CPU, indexed by CPU ID.
#define CPU_STACK_CANARY
CPU stack canary value.
uint16_t _cpuAmount
The number of CPUs currently identified.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define ASM(...)
Inline assembly macro.
#define UNUSED(x)
Mark a variable as unused.
#define NULL
Pointer error value.
#define ERR
Integer error value.
static void msr_write(uint32_t msr, uint64_t value)
__UINTPTR_TYPE__ uintptr_t
_PUBLIC void * memset(void *s, int c, size_t n)
stack_pointer_t exceptionStack
stack_pointer_t interruptStack
stack_pointer_t doubleFaultStack
volatile bool inInterrupt
IPI function data structure.
uintptr_t bottom
The bottom of the stack, this address is inclusive.