The GatOS Kernel has been updated from v2.0.0 to v2.1.0, following the merge of branch QOL.
This version is a stability, performance, and polish release that touches nearly every subsystem: 99 files changed, ~9,100 insertions and ~5,000 deletions. It fixes several long-standing memory corruption bugs, restores full FPU/SSE code generation across the kernel, and roughly doubles the written documentation.
- Restored full floating point and SSE code generation across the kernel. Instead of building the entire kernel with
-mno-sse -mno-sse2 -mno-mmx -mno-80387, the build system now maintains an explicitKERNEL_INTERRUPT_PATHset (interrupt dispatcher, scheduler, timers, keyboard/xHCI IRQ handlers, and the demand-paging path throughvmm.c,pmm.candavl.c) and restricts SSE emission only for those files. Every other translation unit, including drivers, klibc and kernel threads, compiles with full vector support, with the lazy FPU mechanism handling state save and restore. - Fixed a catastrophic firmware memory corruption bug in
kernel_main. Non-MULTIBOOT_MEMORY_AVAILABLEregions were registered as MMIO but then fell through intopmm_populate, handing reserved firmware, ACPI, and MMIO ranges to the physical allocator as free memory. A missingcontinuewas silently arming the kernel to overwrite firmware structures at runtime. - Rebuilt the PMM around a cleaner buddy allocator with a first-class exclusion table.
pmm_exclude_range()registers up to eight physical ranges that must never be handed out,pmm_initderives its order count from the managed range, and population is now firmware-robust across machines with unusual E820/multiboot maps. - Implemented USB hotplug. The xHCI driver now runs a dedicated hotplug process and thread that polls hub status-change endpoints, handles
C_PORT_CONNECTIONandC_PORT_RESETevents, clears port features over the control pipe, enumerates newly attached devices, and tears down downstream slots withDisable Sloton disconnect. Devices can now be plugged and unplugged at runtime instead of only at boot enumeration. - Added a full power management subsystem (
power.c/power.h).power_off()walks the FADT to the DSDT, parses the_S5_package for the SLP_TYPa/b values, enables ACPI mode viaSMI_CMD, and writesPM1a/PM1b_CNT.reboot()cascades through the 0xCF9 reset register, the ACPI FADT reset register, the PS/2 controller, and finally a triple fault. Intel RAPL energy sampling was added on top, exposing live average package wattage throughpower_avg_watts(). - Massively improved klibc and ulibc performance.
kmemset,kmemcpy,kmemmove, and their userspace twins now align to an 8-byte boundary, run a 64-bit word loop over the bulk of the buffer, and fall back to bytewise copies only for the head and tail, replacing the original one-byte-at-a-time loops used by every subsystem in the kernel. - Added long and long long parsing support to
scanf/vscanfin both klibc and ulibc. Thelandlllength modifiers are now honored for%d,%i,%o,%u, and%x, routing throughkstrtol/kstrtoulwith correct destination widths instead of truncating everything toint. - Implemented dirty-cell tracking and batched rendering in the console. Each console carries a bitmap of dirty character cells;
flush_displaynow redraws only the cells that actually changed since the last flush, and a deferred-render toggle lets callers batch many writes into a single screen update. Glyph and fill blitting gained a fully unrolled 32bpp fast path that writes eight pixels per glyph row directly into the framebuffer. - Reworked the syscall ABI and dispatcher.
syscall_dispatchernow receives a singlecpu_context_t*built on the per-thread kernel stack rather than a raw register array indexed by magic offsets, making argument and return-value handling explicit.MSR_STARnow programs the user base as0x13soSYSRETQproducesCS=0x23/SS=0x1Bwithout relying on the CPU forcingSS.RPL=3, a behavior some Intel microarchitectures get wrong. User buffer validation now runs with interrupts disabled so the buffer cannot be swapped between thevmm_check_bufferand the copy, andSYS_MMAPmasks user-supplied flags down toVM_FLAG_WRITE | VM_FLAG_EXEC | VM_FLAG_LAZY. - Rewrote the Kernel Dashboard renderer as a layout engine. Sections, key/value column grids, standalone and paired progress bars, and unified column alignment are now computed from a
layout_tderived from console dimensions, instead of hardcoded positioning. The CPU section gained live package power draw from RAPL, and the whole dashboard renders through the deferred-render path so a refresh is a single batched flush. - Added a MONITOR/MWAIT idle thread to the scheduler, with an automatic
hltfallback when the CPU does not advertise MONITOR/MWAIT. Idle and total tick accounting is exposed throughsched_cpu_usage(), giving the dashboard real CPU utilization instead of an estimate. - Added LAPIC TSC-Deadline timer support.
lapic_tsc_arm()programs the LVT timer in TSC-Deadline mode and writesIA32_TSC_DEADLINEdirectly, replacing periodic-count rearming on hardware that supports it, withlapic_timer_stop()disarming both modes. - Fixed a TTY teardown leak where threads parked in a TTY's wait queue were left dangling on destroy.
tty_destroynow flushes the entire wait queue into the dead queue, andactive_ttywas madevolatileto stop the compiler from caching a stale focus pointer across interrupt-driven focus changes. - Fixed process creation to allocate fresh physical pages for the userspace BSS and explicitly zero them, rather than reusing whatever the allocator handed back, eliminating a class of nondeterministic userspace startup failures.
- Corrected
reserve_required_tablespaceparameter passing and added an assertion that required page-table space never exceeds available memory, catching a bad-argument bug that could under-reserve table space on large-memory machines. - Enabled link-time optimization and stripping in the build pipeline. Kernel objects compile with
-fltoand link throughgcc(so the LTO plugin is actually loaded) with--gc-sections, followed byx86_64-elf-strip; userspace objects build with-ffast-math. Thetestprofile now inherits thefastoptimization flags instead of building unoptimized. - Restored 16-byte stack alignment in
generic_interrupt_handlerbefore calling intointerrupt_dispatcher, and reworked interrupt-context zeroing to avoid emitting SSE instructions that would clobber the interrupted thread's XMM state. - Extended CPU feature detection to cover SSE3/SSSE3/SSE4.1/SSE4.2, AVX, VMX, SVM, PAE, and the full CPUID brand string, with
cpu_enable_featurewiring up SSE, AVX, SMEP and SMAP at boot and the dashboard reporting each one. - Added two new documentation chapters, namely C6 (Interrupts, Panics, and Spinlocks) and C7 (PMM and Slab Allocators), ~2,450 lines combined. I also substantially rewrote C0 through C5.
- Sweeping readability and consistency work across the tree:
heap.cshed roughly 400 lines through shortened type names (heap_block_header_t->blk_hdr_t) and de-duplicated statistics helpers,vmm.c,slab.c,process.c,scheduler.c,gdt.c,apic.candacpi.cwere restructured, every test file was tidied, and comments and authorship headers were made consistent throughout.