Files
mop3/kernel/amd64/bootmain.c
kamkow1 c191ac0a50
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 1m30s
Build documentation / build-and-deploy (push) Successful in 48s
Use intr_enable() and intr_disable() to perform cli/sti
2026-04-26 23:06:12 +02:00

98 lines
2.2 KiB
C

#include <amd64/apic.h>
#include <amd64/debug.h>
#include <amd64/gdt.h>
#include <amd64/hpet.h>
#include <amd64/intr.h>
#include <amd64/intr_defs.h>
#include <amd64/msr-index.h>
#include <amd64/msr.h>
#include <amd64/rtc.h>
#include <amd64/sse.h>
#include <amd64/systick.h>
#include <aux/compiler.h>
#include <device/device.h>
#include <device/storage/partitions.h>
#include <devices.h>
#include <fs/vfs.h>
#include <fs_types.h>
#include <irq/irq.h>
#include <libk/std.h>
#include <libk/string.h>
#include <limine/limine.h>
#include <limine/requests.h>
#include <mm/pmm.h>
#include <proc/proc.h>
#include <proc/reschedule.h>
#include <sys/debug.h>
#include <sys/intr.h>
#include <sys/mm.h>
#include <sys/smp.h>
#include <sys/spin.h>
#include <sys/spin_lock.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <uacpi/uacpi.h>
#define UACPI_MEMORY_BUFFER_MAX 4096
ALIGNED(16) static uint8_t uacpi_memory_buffer[UACPI_MEMORY_BUFFER_MAX];
/*
* The kernel starts booting here. This is the entry point after Limine hands control. We set up all
* the necessary platform-dependent subsystems/drivers and jump into the init app.
*/
void bootmain(void) {
struct limine_mp_response* mp = limine_mp_request.response;
if (LIMINE_BASE_REVISION_SUPPORTED(limine_base_revision) == false)
spin();
struct cpu* bsp_cpu = cpu_make(mp->bsp_lapic_id, 0);
gdt_init(bsp_cpu);
intr_init();
syscall_init();
debug_init();
pmm_init();
mm_init();
sse_enable();
uacpi_setup_early_table_access((void*)uacpi_memory_buffer, sizeof(uacpi_memory_buffer));
ioapic_init();
hpet_init();
rtc_init();
proc_pid_alloc_init();
procgroup_pgid_alloc_init();
bsp_cpu->kproc = kproc_create();
lapic_init(1000);
intr_enable();
devices_init();
vfs_init();
struct reschedule_ctx rctx;
memset(&rctx, 0, sizeof(rctx));
struct device* sys0 = device_find("sys0");
vfs_create_volume(thiscpu->kproc, &rctx, "sys", FS_TARFS, sys0, false);
struct device* temp0 = device_find("temp0");
vfs_create_volume(thiscpu->kproc, &rctx, "temp", FS_FAT16, temp0, true);
irq_attach(&systick_irq, NULL, INTR_SYSTICK);
irq_attach(&proc_irq_sched, NULL, INTR_CPU_REQUEST_SCHED);
smp_init();
proc_init();
for (;;)
;
}