git.cappig.dev / apheleiaOS.git master

9b57ea8de458836c14cc8b6b0c7d576df81f6bec master
cappig <[email protected]> ยท 3 months ago
Bring up x86 SMP and per-core runtime telemetry

* Add x86 SMP bring-up end-to-end: reserve a low trampoline page in BIOS/UEFI, boot APs via LAPIC INIT/SIPI trampolines, initialize per-core APIC timer/IDT/GDT/FPU state, and enable TLB shootdown IPIs.

* Rework scheduler/core plumbing for multicore startup with BSP/AP handoff, per-core usage counters, runnable affinity handling, poll wait wakeups, and stronger guards against contextless or non-ready runqueue entries.

* Expand kernel process and CPU observability by exporting online core count plus per-core tick counters in /dev/cpu, adding core_id and vm_kib to /proc/<pid>/stat, tracking user VM KiB through mmap/munmap/exec, and locking procfs directory walks safely.

* Refresh userland diagnostics/runtime defaults: teach top/fetch the new CPU/memory/core fields (including optional per-core and bar views), pass QEMU SMP count via QEMU_SMP, and adjust Doom build optimization flag handling.
39 files changed, 2248 insertions, 205 deletions
kernel/arch/arch.h +1 -0
kernel/arch/x86/apic.c +152 -18
kernel/arch/x86/apic.h +4 -0
kernel/arch/x86/arch.c +45 -5
kernel/arch/x86/boot.h +1 -0
kernel/arch/x86/boot/bios/main.c +10 -0
kernel/arch/x86/boot/bios/memory.c +8 -0
kernel/arch/x86/boot/bios/memory.h +1 -0
kernel/arch/x86/boot/uefi/main.c +16 -0
kernel/arch/x86/gdt.c +12 -0
kernel/arch/x86/idt.c +4 -0
kernel/arch/x86/idt.h +1 -0
kernel/arch/x86/irq.c +13 -1
kernel/arch/x86/irq.h +1 -0
kernel/arch/x86/mm/phys_window.c +10 -0
kernel/arch/x86/smp.c created
kernel/arch/x86/smp.h created
kernel/arch/x86/smp_trampoline32.asm created
kernel/arch/x86/smp_trampoline64.asm created
kernel/arch/x86/switch32.asm +11 -2
kernel/arch/x86/vm.c +14 -0
kernel/main.c +1 -0
kernel/sched/scheduler.c +377 -41
kernel/sched/scheduler.h +17 -0
kernel/sys/console.c +31 -13
kernel/sys/cpu.c +50 -0
kernel/sys/cpu.h +4 -0
kernel/sys/devfs.c +47 -5
kernel/sys/exec.c +4 -0
kernel/sys/procfs.c +61 -30
kernel/sys/procfs.h +2 -0
kernel/sys/syscall.c +20 -3
libs/libc/sys/proc.h +2 -0
libs/libc_usr/proc.c +11 -0
makefile +1 -1
userland/games/doom/Makefile +4 -6
userland/tools/fetch/main.c +7 -2
userland/tools/top/main.c +468 -78
utils/qemu.mk +2 -0