+ vmm: higher half should not be identify-mapped + panic: now displays current process + kernel: fix physical addresses (ḑ̷̩̜̦̥̰͔̻͔̖͎̳̗̫̓̓͊́̒͜ơ̸͙͎̠͎̩̤̭̬̙͚̬̣͇̤̼̑̐̿̿͆͠͝ ̷̗̟̘͎̥̤̭̂͛͆́͂͝͠ͅN̴̨̛̥̩̺͚̺̠͙̼̙̯̱͚̫̊̐̅̀̌̏͆̋̕͜͝͠ͅö̵̪͚̞̞̜͎͉̦́́̍̀̃̋̇̄̓͊̎͝t̶̡͍̩̤̹̤̂̑̓͌͂̾̑̈́͒̾̾́͐͆͊͂ ̴̨̫̺̦̊̍̒͛͌̌͂͘̚̚͘͘͝I̶̥͚̯̖̙̩͂́͜d̸̢̡̗͉̠̹̒͠e̸̡̪̺͎͖͚̗̟̟̥͍͑̈̋̉̋̓̐̊̚͘͜n̸̡̍͐͗̈͌̀̓̃́́͠t̶̢͈͈̦̻̰͎̪̰̒̄͒̃̐͜ĩ̴͕̼̻͓͚͕̲̬̤͈̜̣̐̍́̾̀̏̏̑͒̚ͅf̷̡̨̼̻̠̠͔̪͍͛y̴͉͓̓͒̆̎̚ ̶̟͙͖̙̟͍̟͕̞̥̹͇̌̉́̑͗͋̀̕ͅͅM̷͙̬̲̓a̶̫̰̞̺̖̍̀p̶̡̨̡̗̖̹̩̫̯̞̬͋͂̏̍̾̽͜ͅ ̶̧̨̧̫͉̝̮̳͎͍̱̟̪̝̀̽͑̂̿̄̈̇̓͘Ḫ̶̨̨̗̣̪͓̺͙͈͙̀ḭ̶̧̡͇̹͙̩͍͎̮̤̦̜̻͎̞̔̐̇̉̓͒͛̅̿͊̍͆͘̕g̷͖͙͍͓̯̪̩̑̑͋̈́͌͐̊̀͝͠͝ĥ̴̢̡̫̪̟̞̭̟͕̖͎͊͑͛̆͝e̴̡̨̗̱̱͙͔̻̤͎͆̒̾̾̓̈͊̓ͅr̵̛͈̩͍̔̌̃̇͊̽̀̉̽̊͌̿́ ̷̨̡̛̩̹̹̇̇̈́̑̍̊͒̄́͛H̷̨̪̜̤͍̻͎̲̜͋́̆͋̂̚͘͘͜͠ą̷̠͓̫̲́́̽̉̒͌́̓ͅl̴̢̛͈̤̺̱̙̬̆̎̄̊̈́̐̾̏̿̕f̸̢̰͓̦̺̰̯͚̣̙͔̺̂͜͜)
52 lines
No EOL
1.4 KiB
C
52 lines
No EOL
1.4 KiB
C
#include "arch/x86_64/smp.h"
|
|
#include "lib/spinlock.h"
|
|
#include "limine.h"
|
|
#include "sys/log.h"
|
|
#include <stdint.h>
|
|
|
|
__attribute__((
|
|
used, section(".limine_requests"))) static volatile struct limine_mp_request
|
|
smp_request = {.id = LIMINE_MP_REQUEST, .revision = 0};
|
|
|
|
uint32_t bootstrap_lapic_id = 0;
|
|
uint32_t smp_cpu_count = 0; // Number of processors
|
|
spinlock_t smp_lock = {0};
|
|
|
|
uint32_t ctr = 0;
|
|
|
|
void smp_entry(struct limine_mp_info *smp_info) {
|
|
// spinlock_acquire(&smp_lock);
|
|
|
|
log("smp - CPU %d started (LAPIC ID: %d)\n", smp_info->processor_id,
|
|
smp_info->lapic_id);
|
|
__atomic_fetch_add(&ctr, 1, __ATOMIC_SEQ_CST);
|
|
|
|
while (1)
|
|
;
|
|
;
|
|
// spinlock_release(&smp_lock);
|
|
}
|
|
|
|
void smp_init() {
|
|
bootstrap_lapic_id = smp_request.response->bsp_lapic_id;
|
|
smp_cpu_count = smp_request.response->cpu_count;
|
|
|
|
log("smp - detected %d CPUs\n", smp_cpu_count);
|
|
|
|
for (uint64_t i = 0; i < smp_cpu_count; i++) {
|
|
if (smp_request.response->cpus[i]->lapic_id != bootstrap_lapic_id) {
|
|
uint32_t old_ctr = __atomic_load_n(&ctr, __ATOMIC_SEQ_CST);
|
|
|
|
__atomic_store_n(&smp_request.response->cpus[i]->goto_address, smp_entry,
|
|
__ATOMIC_SEQ_CST);
|
|
|
|
while (__atomic_load_n(&ctr, __ATOMIC_SEQ_CST) == old_ctr)
|
|
;
|
|
} else {
|
|
log("smp - CPU %d is the bootstrap processor (LAPIC ID: %d)\n", i,
|
|
smp_request.response->cpus[i]->lapic_id);
|
|
}
|
|
}
|
|
|
|
log("smp - initialized\n");
|
|
} |