mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 05:58:22 +00:00
smp: let other processors run threads
This commit is contained in:
@@ -11,7 +11,7 @@ static volatile struct limine_smp_request smprequest = {
|
||||
};
|
||||
|
||||
// set to 1 because of the bsp
|
||||
size_t cpusawake = 1;
|
||||
size_t arch_smp_cpusawake = 1;
|
||||
|
||||
static void cpuwakeup(struct limine_smp_info *info) {
|
||||
cpu_set((cpu_t *)info->extra_argument);
|
||||
@@ -20,13 +20,14 @@ static void cpuwakeup(struct limine_smp_info *info) {
|
||||
arch_idt_reload();
|
||||
dpc_init();
|
||||
arch_mmu_apswitch();
|
||||
vmm_apinit();
|
||||
|
||||
cpu_initstate();
|
||||
arch_apic_timerinit();
|
||||
|
||||
__atomic_add_fetch(&cpusawake, 1, __ATOMIC_SEQ_CST);
|
||||
// TODO let other processors run threads and applications
|
||||
for (;;) CPU_HALT();
|
||||
__atomic_add_fetch(&arch_smp_cpusawake, 1, __ATOMIC_SEQ_CST);
|
||||
|
||||
sched_apentry();
|
||||
}
|
||||
|
||||
// if the nosmp argument is given to the kernel, this is what the APs will jump to
|
||||
@@ -34,6 +35,10 @@ static void cpuwakeuphalt(struct limine_smp_info *info) {
|
||||
for (;;) CPU_HALT();
|
||||
}
|
||||
|
||||
void arch_smp_sendipi(cpu_t *targcpu, isr_t *isr, int target) {
|
||||
arch_apic_sendipi(targcpu ? targcpu->id : 0, INTERRUPT_IDTOVECTOR(isr->id), target, 0, 1);
|
||||
}
|
||||
|
||||
void arch_smp_wakeup() {
|
||||
struct limine_smp_response *response = smprequest.response;
|
||||
if (response == NULL) {
|
||||
@@ -64,7 +69,7 @@ void arch_smp_wakeup() {
|
||||
|
||||
// wait for other cpus to boot up
|
||||
if (wakeupfn == cpuwakeup)
|
||||
while (__atomic_load_n(&cpusawake, __ATOMIC_SEQ_CST) != response->cpu_count) asm("pause");
|
||||
while (__atomic_load_n(&arch_smp_cpusawake, __ATOMIC_SEQ_CST) != response->cpu_count) asm("pause");
|
||||
|
||||
printf("smp: awoke other processors\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user