feat/kernel: Broadcast PIT to all CPUs
This commit is contained in:
parent
2b29a1afa1
commit
9c62518033
4 changed files with 23 additions and 13 deletions
|
@ -10,12 +10,21 @@
|
||||||
#include <mm/heap.h>
|
#include <mm/heap.h>
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <sys/apic/lapic.h>
|
#include <sys/apic/lapic.h>
|
||||||
|
#include <sys/apic/ioapic.h>
|
||||||
#include <sys/acpi/madt.h>
|
#include <sys/acpi/madt.h>
|
||||||
#include <arch/paging.h>
|
#include <arch/paging.h>
|
||||||
#include <util/align.h>
|
#include <util/align.h>
|
||||||
#include <mm/pmm.h>
|
#include <mm/pmm.h>
|
||||||
#include <arch/gdt.h>
|
#include <arch/gdt.h>
|
||||||
#include <arch/idt.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
|
#define MSR_GS_BASE 0xC0000101
|
||||||
|
|
||||||
|
@ -91,6 +100,13 @@ void smp_init(void)
|
||||||
log_early("%u CPUs detected", cpu_count);
|
log_early("%u CPUs detected", cpu_count);
|
||||||
|
|
||||||
lapic_enable();
|
lapic_enable();
|
||||||
|
|
||||||
|
/* Setup IOAPIC */
|
||||||
|
ioapic_init();
|
||||||
|
|
||||||
|
/* Setup timer */
|
||||||
|
pit_init(tick);
|
||||||
|
|
||||||
tss_init(kstack_top);
|
tss_init(kstack_top);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cpu_count; i++)
|
for (uint32_t i = 0; i < cpu_count; i++)
|
||||||
|
|
|
@ -29,6 +29,5 @@ void pit_init(idt_intr_handler handler)
|
||||||
outb(0x40, (divisor >> 8) & 0xFF);
|
outb(0x40, (divisor >> 8) & 0xFF);
|
||||||
|
|
||||||
idt_register_handler(PIT_VECTOR, pit_handler);
|
idt_register_handler(PIT_VECTOR, pit_handler);
|
||||||
ioapic_map(0, PIT_VECTOR, 0, get_cpu_local()->lapic_id);
|
ioapic_map(0, PIT_VECTOR, 0, 0xFF); /* Broadcast to ALL CPUs */
|
||||||
ioapic_unmask(0);
|
|
||||||
}
|
}
|
|
@ -68,11 +68,6 @@ struct limine_mp_response *mp_response = NULL;
|
||||||
struct flanterm_context *ft_ctx = NULL;
|
struct flanterm_context *ft_ctx = NULL;
|
||||||
#endif // FLANTERM_SUPPORT
|
#endif // FLANTERM_SUPPORT
|
||||||
|
|
||||||
void tick(struct register_ctx *)
|
|
||||||
{
|
|
||||||
log_early("tick on CPU %d", get_cpu_local()->cpu_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void emk_entry(void)
|
void emk_entry(void)
|
||||||
{
|
{
|
||||||
__asm__ volatile("movq %%rsp, %0" : "=r"(kstack_top));
|
__asm__ volatile("movq %%rsp, %0" : "=r"(kstack_top));
|
||||||
|
@ -207,16 +202,11 @@ void emk_entry(void)
|
||||||
lapic_init();
|
lapic_init();
|
||||||
smp_init();
|
smp_init();
|
||||||
|
|
||||||
/* Setup IOAPIC */
|
|
||||||
ioapic_init();
|
|
||||||
|
|
||||||
/* Setup timer */
|
|
||||||
pit_init(tick);
|
|
||||||
|
|
||||||
/* Finished */
|
/* Finished */
|
||||||
log_early("%s", LOG_SEPARATOR);
|
log_early("%s", LOG_SEPARATOR);
|
||||||
log_early("Finished initializing EMK v1.0, took ? seconds"); /* Still not running in usermode, so keep using log_early */
|
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");
|
__asm__ volatile("sti");
|
||||||
hlt();
|
hlt();
|
||||||
}
|
}
|
5
kernel/src/user/sched.h
Normal file
5
kernel/src/user/sched.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/* EMK 1.0 Copyright (c) 2025 Piraterna */
|
||||||
|
#ifndef SCHED_H
|
||||||
|
#define SCHED_H
|
||||||
|
|
||||||
|
#endif // SCHED_H
|
Loading…
Add table
Add a link
Reference in a new issue