PatchworkOS
Loading...
Searching...
No Matches

CPU. More...

Modules

 GDT
 Global Descriptor Table.
 
 IDT
 Interrupt Descriptor Table.
 
 Interrupts
 Interrupt Handling.
 
 IRQ
 Interrupt Request handling.
 
 Port I/O
 Port I/O operations.
 
 SIMD
 SIMD context management.
 
 SMP
 Symmetric multi processing.
 
 Stack Pointer
 Helpers for managing stacks.
 
 Syscalls
 System Calls.
 
 Trampoline
 Trampoline for CPU initialization.
 
 TSS
 Task State Segment.
 

Data Structures

struct  cpu_t
 CPU structure. More...
 

Macros

#define CPU_STACK_CANARY   0x1234567890ABCDEFULL
 CPU stack canary value.
 
#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.
 

Typedefs

typedef uint16_t cpuid_t
 Type used to identify a CPU.
 

Functions

uint64_t cpu_init (cpu_t *cpu, cpuid_t id)
 Initializes a CPU structure as part of the boot process.
 
void cpu_stacks_overflow_check (cpu_t *cpu)
 Checks for CPU stack overflows.
 

Detailed Description

CPU.

Macro Definition Documentation

◆ CPU_ID_BOOTSTRAP

#define CPU_ID_BOOTSTRAP   0

ID of the bootstrap CPU.

Definition at line 19 of file cpu_id.h.

◆ CPU_ID_INVALID

#define CPU_ID_INVALID   UINT16_MAX

Invalid CPU ID.

Definition at line 24 of file cpu_id.h.

◆ CPU_MAX

#define CPU_MAX   UINT8_MAX

Maximum number of CPUs supported.

Definition at line 14 of file cpu_id.h.

◆ CPU_STACK_CANARY

#define CPU_STACK_CANARY   0x1234567890ABCDEFULL

CPU stack canary value.

Placed at the bottom of CPU stacks, we then check in the interrupt handler if any of the stacks have overflowed by checking if its canary has been modified.

Definition at line 31 of file cpu.h.

Typedef Documentation

◆ cpuid_t

typedef uint16_t cpuid_t

Type used to identify a CPU.

Definition at line 29 of file cpu_id.h.

Function Documentation

◆ cpu_init()

◆ cpu_stacks_overflow_check()

void cpu_stacks_overflow_check ( cpu_t cpu)

Checks for CPU stack overflows.

Checks the canary values at the bottom of each CPU stack and if its been modified panics.

Parameters
cpuThe CPU to check.

Definition at line 69 of file cpu.c.

References stack_pointer_t::bottom, CPU_STACK_CANARY, cpu_t::doubleFaultStack, cpu_t::exceptionStack, cpu_t::id, cpu_t::interruptStack, NULL, and panic().

Referenced by interrupt_handler().