PatchworkOS
Loading...
Searching...
No Matches
trampoline.h File Reference
#include <kernel/cpu/smp.h>
#include <kernel/drivers/apic.h>
#include <stdint.h>
#include <sys/proc.h>

Go to the source code of this file.

Macros

#define TRAMPOLINE_BASE_ADDR   0x8000
 The physical address where the trampoline code will be copied to and executed from.
 
#define TRAMPOLINE_DATA_OFFSET   0x0F00
 The offset within the trampoline page where we can store data.
 
#define TRAMPOLINE_PML4_OFFSET   (TRAMPOLINE_DATA_OFFSET + 0x00)
 Offset within the trampoline page where the PML4 address is stored.
 
#define TRAMPOLINE_ENTRY_OFFSET   (TRAMPOLINE_DATA_OFFSET + 0x08)
 Offset within the trampoline page where the entry point to jump to is stored.
 
#define TRAMPOLINE_CPU_ID_OFFSET   (TRAMPOLINE_DATA_OFFSET + 0x10)
 Offset within the trampoline page where the CPU id is stored.
 
#define TRAMPOLINE_CPU_OFFSET   (TRAMPOLINE_DATA_OFFSET + 0x18)
 Offset within the trampoline page where the CPU structure pointer is stored.
 
#define TRAMPOLINE_STACK_OFFSET   (TRAMPOLINE_DATA_OFFSET + 0x20)
 Offset within the trampoline page where the stack pointer for the trampoline is stored.
 
#define TRAMPOLINE_ADDR(offset)   ((void*)(TRAMPOLINE_BASE_ADDR + (offset)))
 Macro to get a pointer to an address within the trampoline page.
 
#define TRAMPOLINE_SIZE   ((uintptr_t)trampoline_end - (uintptr_t)trampoline_start)
 The size of the trampoline code.
 

Functions

void trampoline_start (void)
 The start of the trampoline code, defined in trampoline.s.
 
void trampoline_end (void)
 The end of the trampoline code, defined in trampoline.s.
 
void trampoline_init (void)
 Initializes the trampoline by copying the trampoline code to its designated memory location.
 
void trampoline_deinit (void)
 Deinitializes the trampoline by restoring the original contents of the trampoline memory location.
 
void trampoline_send_startup_ipi (cpu_t *cpu, cpuid_t cpuId, lapic_id_t lapicId)
 Sends the startup IPI to a CPU to start it up.
 
uint64_t trampoline_wait_ready (clock_t timeout)
 Waits for the currently starting CPU to signal that it is ready.
 
_NORETURN void trampoline_c_entry (cpu_t *self, cpuid_t cpuId)
 After the trampoline is done with basic initialization, it calls this C entry point to continue CPU initialization.