Commit Graph
33 Commits
Author SHA1 Message Date
danielandClaude Fable 5 5db2bd4c7c feat: TLS runtime - PT_TLS loading and per-thread FS base
MontaukOS binaries could not use thread-local storage: the ELF loader
ignored PT_TLS and no FS base was ever programmed, so any %fs access
(initial-exec/local-exec TLS, e.g. libbfd's _Thread_local error state)
page faulted at address 0. This is the kernel prerequisite for
cc1plus/libstdc++ in the GCC port.

ELF loader: parse PT_TLS and build the main thread's TLS block above
the loaded image (x86-64 variant II ABI: block below the thread
pointer, TP = base + align_up(memsz, align), .tdata copied from the
template, .tbss zeroed, ABI self-pointer stored at [TP]). The
template description is kept on the process for thread spawns.

Scheduler: fsBase per thread, loaded into IA32_FS_BASE at every
dispatch site through a per-CPU cache - TLS-free processes cost one
MSR write per CPU ever, and userspace cannot desync the cache since
CR4.FSGSBASE stays off. SYS_THREAD_SPAWN gives each new thread its
own TLS block copied from the template (allocated from the process
heap; reclaimed at process teardown).

Ships tls-test.elf in the SDK (built by the devkit target): checks
.tdata values, .tbss zeroing, and the %fs:0 self-pointer, exiting
nonzero on failure. Boot-smoke verified; existing TLS-free programs
are unaffected.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-16 18:48:25 +02:00
danielandClaude Fable 5 75184e0651 feat: process exit codes, posix_spawn, 4 KiB command lines
Groundwork for the GCC driver: a compiler driver must spawn cc1/as/ld
and know whether each stage succeeded.

Kernel: the scheduler keeps an exit-code ledger (pid -> code; pids are
monotonic so entries never alias), published during teardown right
before waiters wake. SYS_EXIT records main()'s return value, SYS_KILL
records 256+SIGKILL, and the exception handler records 256+signal
mapped from the fault vector (#PF/#GP -> SIGSEGV, #DE/FP -> SIGFPE,
#UD -> SIGILL). SYS_WAITPID now returns the code: 0..255 for a normal
exit, 256+signal for a violent death. Process args grow from 256
bytes to 4 KiB (cc1 invocations do not fit in 256), with crt1 now
parsing up to 255 argv entries from a static buffer.

libc: new spawn.h with posix_spawn/posix_spawnp over SYS_SPAWN -
libiberty's pex layer has a posix_spawn backend, so GCC's driver works
without fork. argv is joined into the kernel args string (spaces in
arguments rejected; no kernel quoting), envp is not transferred, and
non-empty file actions fail loudly with ENOTSUP until the kernel can
redirect stdio on spawn. waitpid() now decodes real POSIX status and
the sys/wait.h macros distinguish exited from signaled children.

Shell: prints [exit code N] after nonzero exits and [terminated by
signal N] for killed or crashed children.

Verified on the OS: cat on a missing file reports exit code 1; a
window-close (clean exit 0) stays silent as it should.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-16 16:59:17 +02:00
danielandClaude Fable 5 182520a585 feat: vblank IRQ and double-buffered page flip for Intel GPU
Add tear-free scanout to the Intel GPU driver: a second kernel-allocated
scanout buffer, DSPASURF flips latched at vblank, and a vblank interrupt
delivered over MSI (Gen 11+ master/display/pipe IRQ chain) with a
monotonic vblank counter and WaitVblank().

Expose it as SYS_FBFLIP (150): index selects the front buffer, -1
queries support, flags bit0 waits for the flip to latch. fb_map() now
maps buffer 1 right after buffer 0 when flipping is available, and
gui::Framebuffer draws to the off-screen buffer and flips with vsync,
falling back to the direct copy when unsupported.

Scanout is restored to buffer 0 when the flip-owning process exits and
on panic, so the terminal and panic box never land on the invisible
buffer.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-13 21:53:06 +02:00
danielandClaude Fable 5 928fe0bbed fix: make BT A2DP output exclusive to one process
The A2DP output is a single unmixed PCM stream. A second process
opening audio while a stream was active would reconfigure the SBC
encoder and media clock under the owner and interleave both apps' PCM
into one ring, garbling playback (e.g. launching DOOM destabilized
Music). Add ClaimOutput/ReleaseOutput pid ownership: the first opener
gets the BT sink, later openers fall back to the HDA mixer, and only
the owner can tear the stream down. The scheduler releases ownership
on process exit so a killed app cannot leak the claim.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-10 12:41:17 +02:00
danielandClaude Fable 5 8bf3ceb457 wip: async BT firmware download attempt — DO NOT MERGE, breaks AX211 bring-up
Deferring the Intel BT firmware download off the boot path made the AX211
bootloader stop answering after the first FC05; even the final synchronous
revert freezes boot, so one of the 'neutral' fixes kept in this diff breaks
the bring-up on its own (candidates: BT-TRACE logging inside TransferCallback,
unconditional interrupt-IN re-queue after error completions on a halted EP,
xHCI interrupt-IN ZLP len fix interacting with HID, InPollContext owner
check).  Full history + next experiments in memory notes, 2026-07-05/06.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-06 15:46:06 +02:00
daniel 70702a21b0 feat: HWP scaling, C1E, closed-loop thermal governor for Intel CPUs 2026-07-05 10:51:11 +02:00
daniel c86650d662 fix: lock crash report ring buffer (SMP race) and guard crashpad crash loop 2026-06-19 19:36:21 +02:00
daniel bbb6fcf0ee feat: add support for console sessions to crashpad and crash handling in kernel 2026-06-18 12:56:29 +02:00
daniel 43d43ac9ea cleanup: namespace Montauk (capital M) => montauk::abi 2026-06-16 09:09:16 +02:00
daniel 159fea1667 feat: add threading to Scheduler, fix desktop background selection freeze issue 2026-05-23 16:08:25 +02:00
daniel 8b8c8cee95 feat: audio mixer, Audio app, fix Installer crash 2026-05-19 07:48:09 +02:00
daniel 4fde39397a fix: kernel and desktop bug fixes 2026-05-14 11:31:14 +02:00
daniel d04d7194b9 fix: add start pending mode to mitigate Terminal output redirection issue 2026-05-07 07:32:44 +02:00
daniel ff264aa0f5 fix: properly record PIDs 2026-05-04 08:01:55 +02:00
daniel 017a8a28ac feat: graphing in MTK toolkit, kernel exposes CPU time, Processes app Performance tab 2026-05-02 15:26:59 +02:00
daniel 38b1f8a7ef feat: further kernel power and power optimizations 2026-04-21 20:51:12 +02:00
daniel 7d6f001659 feat: various power and thermal optimizations, fix Printers app regression 2026-04-20 16:00:52 +02:00
daniel 856b431fde fix: various kernel bug fixes 2026-04-10 23:16:02 +02:00
daniel 9e04e51daa feat: add process crash popups 2026-04-07 20:15:56 +02:00
daniel fb9885819b feat: implement new IPC layer 2026-04-01 13:11:03 +02:00
daniel ada6cdff47 fix: SYS_READDIR memory leak 2026-03-27 20:15:37 +01:00
daniel 1c0db774f6 feat: add cwd tracking to kernel, remove shell hack, update system utilities to use getcwd, fix tcc libc stub, fix nonexistent directory issue 2026-03-25 15:45:22 +01:00
daniel 58a144fc1a feat: ACPI parsing improvements, username in process struct + syscalls 2026-03-24 17:17:47 +01:00
daniel 9b4dfe3e0e fix: improve scheduling, memory, timer implementations 2026-03-24 07:40:37 +01:00
daniel 41ad1f6404 feat: Symmetric Multiprocessing, text editor improvements, merge doom libc, implement math functions 2026-03-23 20:09:11 +01:00
daniel 39b0424085 feat: multi-user system, bug fixes, security & performance fixes, and more 2026-03-14 13:28:46 +01:00
daniel bcd959b80f feat: ext2 filesystem, installer updates, add update feature, and more 2026-03-08 14:41:36 +01:00
daniel 48bf14ee0e fix: continue fix page fault heap regression 2026-02-28 00:14:28 +01:00
daniel 9e191f64a9 feat: TrueType (TTF) font rendering, many new desktop applications and DOOM support, among other improvements 2026-02-20 22:46:41 +01:00
daniel 987a85da27 feat: rudimentary userspace desktop environment 2026-02-20 00:48:51 +01:00
daniel 010783429c feat: e100e Ethernet driver, ramdisk reorganization, shell rewrite, web server/client, and more 2026-02-19 01:18:11 +01:00
daniel fb8d16ee7b feat: expand user mode, add DOOM game, add manpages 2026-02-18 15:13:53 +01:00
daniel f384d4cf75 feat: scheduling, usermode, shell 2026-02-17 19:17:01 +01:00