PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
cpu.h File Reference
#include <kernel/config.h>
#include <kernel/cpu/stack_pointer.h>
#include <kernel/cpu/tss.h>
#include <assert.h>
#include <stdint.h>
#include <sys/proc.h>
Include dependency graph for cpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cpu_t
 CPU structure. More...
 

Macros

#define CPU_OFFSET_SELF   0x0
 The offset of the self member in the cpu_t structure.
 
#define CPU_OFFSET_SYSCALL_RSP   0x10
 The offset of the syscall_ctx_t pointer in the cpu_t structure.
 
#define CPU_OFFSET_USER_RSP   0x18
 The offset of the userRsp member in the cpu_t structure.
 
#define CPU_OFFSET_ID   0x8
 The offset of the id member in the cpu_t structure.
 
#define CPU_MAX   UINT8_MAX
 Maximum number of CPUs supported.
 
#define CPU_ID_BOOTSTRAP   0
 ID of the bootstrap CPU.
 
#define CPU_ID_INVALID   UINT16_MAX
 Invalid CPU ID.
 
#define CPU_STACK_CANARY   0x1234567890ABCDEFULL
 CPU stack canary value.
 
#define CPU_FOR_EACH(cpu)
 Macro to iterate over all CPUs.
 

Typedefs

typedef struct cpu cpu_t
 
typedef uint16_t cpu_id_t
 Type used to identify a CPU.
 

Functions

void cpu_init (cpu_t *cpu)
 Initializes a CPU structure.
 
void cpu_stacks_overflow_check (void)
 Checks the current CPU for stack overflows.
 
uint64_t cpu_halt_others (void)
 Halts all other CPUs.
 
uintptr_t cpu_interrupt_stack_top (void)
 Gets the top of the interrupt stack for the current CPU.
 
static uint16_t cpu_amount (void)
 Gets the number of identified CPUs.
 
static cpu_tcpu_get_by_id (cpu_id_t id)
 Gets a CPU structure by its ID.
 
static cpu_tcpu_get_next (cpu_t *current)
 Gets the next CPU in the CPU array.
 

Variables

cpu_t_cpus [CPU_MAX]
 Array of pointers to cpu_t structures for each CPU, indexed by CPU ID.
 
uint16_t _cpuAmount
 The number of CPUs currently identified.
 

Typedef Documentation

◆ cpu_t

typedef struct cpu cpu_t

Definition at line 12 of file cpu.h.