PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
cpu.h File Reference
#include <kernel/config.h>
#include <kernel/cpu/interrupt.h>
#include <kernel/cpu/ipi.h>
#include <kernel/cpu/tss.h>
#include <kernel/defs.h>
#include <kernel/drivers/perf.h>
#include <kernel/drivers/rand.h>
#include <kernel/mem/vmm.h>
#include <kernel/sched/sched.h>
#include <kernel/sched/timer.h>
#include <kernel/sched/wait.h>
#include <kernel/utils/map.h>
#include <stdatomic.h>
#include <stdint.h>
#include <sys/bitmap.h>
#include <sys/list.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_event_t
 CPU event structure. More...
 
struct  cpu_handler_t
 
struct  cpu_t
 CPU structure. More...
 

Macros

#define CPU_MAX   (UINT8_MAX + 1)
 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_MAX_EVENT_HANDLERS   32
 Maximum number of CPU event handlers that can be registered.
 
#define CPU_FOR_EACH(cpu)
 Macro to iterate over all CPUs.
 

Typedefs

typedef uint16_t cpuid_t
 Type used to identify a CPU.
 
typedef void(* cpu_func_t) (cpu_t *cpu, const cpu_event_t *event)
 CPU event function type.
 

Enumerations

enum  cpu_event_type_t { CPU_ONLINE , CPU_OFFLINE }
 CPU event types. More...
 

Functions

void cpu_init_early (cpu_t *cpu)
 Only initialize the parts of the CPU structure needed for early boot.
 
void cpu_init (cpu_t *cpu)
 Initializes the CPU represented by the cpu_t structure.
 
uint64_t cpu_handler_register (cpu_func_t func)
 Registers a CPU event handler for all CPUs.
 
void cpu_handler_unregister (cpu_func_t func)
 Unregisters a previously registered CPU event handler.
 
void cpu_handlers_check (cpu_t *cpu)
 Checks if any handlers have been registered since the last check, and invokes them if so.
 
void cpu_stacks_overflow_check (cpu_t *cpu)
 Checks for CPU stack overflows.
 
uint64_t cpu_halt_others (void)
 Halts all other CPUs.
 
static uint16_t cpu_amount (void)
 Gets the number of identified CPUs.
 
static cpu_tcpu_get_by_id (cpuid_t id)
 Gets a CPU structure by its ID.
 
static cpu_tcpu_get (void)
 Gets the current CPU structure.
 
static void cpu_put (void)
 Releases the current CPU structure.
 
static cpu_tcpu_get_unsafe (void)
 Gets the current CPU structure without disabling interrupts.
 
static cpuid_t cpu_get_id_unsafe (void)
 Gets the current CPU 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.