26#define CPU_OFFSET_SELF 0x0
31#define CPU_OFFSET_SYSCALL_RSP 0x10
36#define CPU_OFFSET_USER_RSP 0x18
45#define CPU_OFFSET_ID 0x8
50#define CPU_MAX UINT8_MAX
55#define CPU_ID_BOOTSTRAP 0
60#define CPU_ID_INVALID UINT16_MAX
73#define CPU_STACK_CANARY 0x1234567890ABCDEFULL
105 "CPU_OFFSET_SELF does not match the offset of the self field in cpu_t");
110 "CPU_OFFSET_SYSCALL_RSP does not match the offset of the syscallRsp field in cpu_t");
113 "CPU_OFFSET_USER_RSP does not match the offset of the userRsp field in cpu_t");
203 return _cpus[nextId];
214#define CPU_FOR_EACH(cpu) \
215 for (cpu_id_t _cpuId = 0; _cpuId < _cpuAmount; _cpuId++) \
216 for (cpu = _cpus[_cpuId]; cpu != NULL; cpu = NULL)
#define CONFIG_PERCPU_SIZE
Per-CPU data size configuration.
#define CONFIG_INTERRUPT_STACK_PAGES
Interrupt stack configuration.
static cpu_t * cpu_get_next(cpu_t *current)
Gets the next CPU in the CPU array.
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.
#define CPU_OFFSET_SYSCALL_RSP
The offset of the syscall_ctx_t pointer in the cpu_t structure.
uint16_t cpu_id_t
Type used to identify a CPU.
void cpu_init(cpu_t *cpu)
Initializes a CPU structure.
#define CPU_OFFSET_SELF
The offset of the self member in the cpu_t structure.
#define CPU_MAX
Maximum number of CPUs supported.
#define CPU_OFFSET_USER_RSP
The offset of the userRsp member in the cpu_t structure.
cpu_t * _cpus[CPU_MAX]
Array of pointers to cpu_t structures for each CPU, indexed by CPU ID.
#define CPU_OFFSET_ID
The offset of the id member in the cpu_t structure.
static uint16_t cpu_amount(void)
Gets the number of identified CPUs.
uint16_t _cpuAmount
The number of CPUs currently identified.
static cpu_t * cpu_get_by_id(cpu_id_t id)
Gets a CPU structure by its ID.
#define NULL
Pointer error value.
#define PAGE_SIZE
The size of a memory page in bytes.
#define offsetof(type, member)
__UINTPTR_TYPE__ uintptr_t
uint16_t cli
The CLI depth counter used in cli_push() and cli_pop().
uint8_t interruptStackBuffer[CONFIG_INTERRUPT_STACK_PAGES *PAGE_SIZE] ALIGNED(PAGE_SIZE)
uint64_t oldRflags
The rflags value before disabling interrupts.
stack_pointer_t exceptionStack
uint8_t nmiStackBuffer[CONFIG_INTERRUPT_STACK_PAGES *PAGE_SIZE] ALIGNED(PAGE_SIZE)
uint8_t doubleFaultStackBuffer[CONFIG_INTERRUPT_STACK_PAGES *PAGE_SIZE] ALIGNED(PAGE_SIZE)
uint8_t exceptionStackBuffer[CONFIG_INTERRUPT_STACK_PAGES *PAGE_SIZE] ALIGNED(PAGE_SIZE)
uint8_t percpu[CONFIG_PERCPU_SIZE] ALIGNED(PAGE_SIZE)
Buffer used for per-CPU data.
stack_pointer_t interruptStack
stack_pointer_t doubleFaultStack
volatile bool inInterrupt
Structure to define a stack in memory.
Task State Segment structure.