1
0
Fork 0

feat/kernel: Broadcast PIT to all CPUs

This commit is contained in:
Kevin Alavik 2025-06-02 16:46:35 +02:00
parent 2b29a1afa1
commit 9c62518033
Signed by: cmpsb
GPG key ID: 10D1CC0526FDC6D7
4 changed files with 23 additions and 13 deletions

View file

@ -10,12 +10,21 @@
#include <mm/heap.h>
#include <arch/io.h>
#include <sys/apic/lapic.h>
#include <sys/apic/ioapic.h>
#include <sys/acpi/madt.h>
#include <arch/paging.h>
#include <util/align.h>
#include <mm/pmm.h>
#include <arch/gdt.h>
#include <arch/idt.h>
#include <dev/pit.h>
#include <sys/acpi.h>
void tick(struct register_ctx *)
{
log_early("tick on CPU %d", get_cpu_local()->cpu_index);
lapic_eoi();
}
#define MSR_GS_BASE 0xC0000101
@ -91,6 +100,13 @@ void smp_init(void)
log_early("%u CPUs detected", cpu_count);
lapic_enable();
/* Setup IOAPIC */
ioapic_init();
/* Setup timer */
pit_init(tick);
tss_init(kstack_top);
for (uint32_t i = 0; i < cpu_count; i++)

View file

@ -29,6 +29,5 @@ void pit_init(idt_intr_handler handler)
outb(0x40, (divisor >> 8) & 0xFF);
idt_register_handler(PIT_VECTOR, pit_handler);
ioapic_map(0, PIT_VECTOR, 0, get_cpu_local()->lapic_id);
ioapic_unmask(0);
ioapic_map(0, PIT_VECTOR, 0, 0xFF); /* Broadcast to ALL CPUs */
}

View file

@ -68,11 +68,6 @@ struct limine_mp_response *mp_response = NULL;
struct flanterm_context *ft_ctx = NULL;
#endif // FLANTERM_SUPPORT
void tick(struct register_ctx *)
{
log_early("tick on CPU %d", get_cpu_local()->cpu_index);
}
void emk_entry(void)
{
__asm__ volatile("movq %%rsp, %0" : "=r"(kstack_top));
@ -207,16 +202,11 @@ void emk_entry(void)
lapic_init();
smp_init();
/* Setup IOAPIC */
ioapic_init();
/* Setup timer */
pit_init(tick);
/* Finished */
log_early("%s", LOG_SEPARATOR);
log_early("Finished initializing EMK v1.0, took ? seconds"); /* Still not running in usermode, so keep using log_early */
ioapic_unmask(0); // start the timer
__asm__ volatile("sti");
hlt();
}

5
kernel/src/user/sched.h Normal file
View file

@ -0,0 +1,5 @@
/* EMK 1.0 Copyright (c) 2025 Piraterna */
#ifndef SCHED_H
#define SCHED_H
#endif // SCHED_H