Document amd64 platform-specific code
This commit is contained in:
@@ -11,10 +11,14 @@
|
||||
#include <sys/debug.h>
|
||||
#include <sys/smp.h>
|
||||
|
||||
/// Cpu ID counter
|
||||
static uint32_t cpu_counter = 0;
|
||||
/// Lock for \ref cpu_counter
|
||||
static spin_lock_t cpu_counter_lock = SPIN_LOCK_INIT;
|
||||
/// The CPUs
|
||||
static struct cpu cpus[CPUS_MAX];
|
||||
|
||||
/// Allocate a CPU structure
|
||||
struct cpu* cpu_make (void) {
|
||||
spin_lock (&cpu_counter_lock);
|
||||
int id = cpu_counter++;
|
||||
@@ -36,10 +40,13 @@ struct cpu* cpu_get (uint32_t id) {
|
||||
return &cpus[id];
|
||||
}
|
||||
|
||||
/// Get ID of current running CPU
|
||||
uint32_t cpu_id (void) { return (uint32_t)amd64_rdmsr (MSR_GS_BASE); }
|
||||
|
||||
/// Assign an ID to the current running CPU
|
||||
void cpu_assign (uint32_t id) { amd64_wrmsr (MSR_GS_BASE, (uint64_t)id); }
|
||||
|
||||
/// Bootstrap code for non-BSP CPUs
|
||||
static void amd64_smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
amd64_load_kernel_cr3 ();
|
||||
|
||||
@@ -59,6 +66,7 @@ static void amd64_smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
;
|
||||
}
|
||||
|
||||
/// Initialize SMP subsystem for AMD64. Start AP CPUs
|
||||
void smp_init (void) {
|
||||
thiscpu->lapic_ticks = amd64_lapic_init (2500);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user