Skip to content

Fix Multitasking and Integrate Alix Features#6

Open
rtech-technologies wants to merge 28 commits into
sovereign-core-expansion-2313558312167675719from
fix-multitasking-and-integrate-alix-features-15811689905368575737
Open

Fix Multitasking and Integrate Alix Features#6
rtech-technologies wants to merge 28 commits into
sovereign-core-expansion-2313558312167675719from
fix-multitasking-and-integrate-alix-features-15811689905368575737

Conversation

@rtech-technologies

Copy link
Copy Markdown
Owner

This submission fixes the broken multitasking system by correcting the assembly context switcher and Task Control Block (TCB) alignment. It also restores stable hardware drivers (AHCI/XHCI) and integrates several features from the 'alix' OS, including kernel-level SSE support, configurable keyboard repeat controls, and path-based binary invocation in the shell.


PR created automatically by Jules for task 15811689905368575737 started by @rtech-technologies

- Fixed critical bug in `unice64_context_switch` assembly where RSP was incorrectly set to the TCB address instead of the task's stack pointer.
- Aligned `task_t` structure to ensure `fxsave_region` is at offset 192 and 16-byte aligned, matching the updated context switcher.
- Restored full AHCI and XHCI hardware support from the last known working state.
- Integrated SIMD/SSE support by enabling CR0/CR4 bits and implementing state preservation in the scheduler.
- Added configurable keyboard repeat (initial delay/repeat rate) with a new `kbd-config` shell command.
- Enabled path invocation support in the shell (e.g., `./path/to/bin`).
- Cleaned up build system by enabling SSE for kernel and userland programs.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 27 commits April 21, 2026 22:40
- Fixed critical bug in `unice64_context_switch` assembly where RSP was incorrectly set to the TCB address instead of the task's stack pointer.
- Aligned `task_t` structure to ensure `fxsave_region` is at offset 192 and 16-byte aligned, matching the updated context switcher.
- Restored full AHCI and XHCI hardware support from the last known working state.
- Integrated SIMD/SSE support by enabling CR0/CR4 bits and implementing state preservation in the scheduler.
- Added configurable keyboard repeat (initial delay/repeat rate) with a new `kbd-config` shell command.
- Enabled path invocation support in the shell (e.g., `./path/to/bin`).
- Cleaned up build system by enabling SSE for kernel and userland programs.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Overhaulled AHCI driver with bounded polling and spec-compliant COMRESET to prevent "LINK ESTABLISHED" stall.
- Fixed critical corruption in `unice64_context_switch` by using RCX for RSP validation instead of RAX.
- Aligned `task_t` structure to ensure `fxsave_region` is at offset 192 (16-byte aligned).
- Added safety timeouts to PIT delay logic.
- Integrated Alix features: path invocation (`./path`) and configurable keyboard repeat.
- Verified build and memory map consistency.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Corrected AHCI initialization sequence to follow the "Sovereign Order": ensuring `PxCLB` and `PxFB` are set only when `ST` and `FRE` are 0.
- Overhaulled `ahci_port_stop` and `ahci_port_start` for AHCI 1.3 spec compliance.
- Increased AHCI Command List and FIS area alignment to 4KB for improved hardware compatibility.
- Fixed critical `RAX` corruption in `unice64_context_switch` by utilizing `RCX` as a scratch register during RSP validation.
- Synchronized `task_t` structure padding to guarantee 16-byte alignment of the SSE `fxsave_region` at offset 192.
- Integrated Alix features: path-based binary invocation (`./path`) and configurable keyboard repeat controls via the RSL shell.
- Added bounded loop counters and safety timeouts to hardware polling and PIT delay logic.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Fixed AHCI boot stall by reordering the kernel ritual: APIC timer now starts before hardware discovery, ensuring `pit_wait_ms` works.
- Implemented AHCI "Sovereign Order": `PxCLB` and `PxFB` are now set strictly while `ST` and `FRE` are disabled.
- Corrected critical `RAX` corruption in `unice64_context_switch` by using `RCX` as a scratch register for RSP validation.
- Fixed task state restoration by ensuring `fxrstor` uses the correct TCB pointer in `RAX`.
- Aligned `task_t` padding to keep `fxsave_region` at offset 192 (16-byte aligned) for architectural consistency.
- Integrated Alix features: modern shell with `./path` invocation and configurable keyboard repeat.
- Optimized AHCI and USB polling with bounded loop counters and safety timeouts.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
… logic

- Fixed AHCI boot stall by reordering kernel initialization: APIC timer now starts before hardware discovery.
- Implemented AHCI "Sovereign Order": PxCLB/PxFB are set strictly while port engine is stopped.
- Corrected multitasking corruption: `unice64_context_switch` now uses RCX for validation to preserve the RAX TCB pointer.
- Refined boot logic: System now scans for Sovereign volumes and provides a recovery menu (Safe Mode/Format) if none are found.
- Updated `boot/linker.ld` with 4KB alignment and preserved the `*(.programs)` section.
- Integrated Alix features: configurable keyboard repeat and `./path` execution.
- Ensured bit-perfect `task_t` alignment for SSE state preservation.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
Restored core hardware drivers (AHCI, xHCI, ATAPI) from last working
branch. Fixed a fatal bug in the assembly context switcher that
corrupted task state and stack pointers.

- Implemented spec-compliant AHCI 'Sovereign Order' initialization to
  fix boot stalls.
- Aligned task_t structure to ensure 16-byte SSE (fxsave) alignment.
- Integrated configurable keyboard repeat and path-based shell
  invocation from Alix OS.
- Added a recovery boot menu for Safe Mode or disk formatting.
- Updated documentation and set bootloader to quiet mode.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
…dalone RSL binaries

Restored core hardware drivers (AHCI, xHCI, ATAPI) and fixed critical
multitasking stability issues. Implemented explicit SSE support across
the kernel and standalone programs.

- Enabled -msse -msse2 flags in Makefile.
- Hardened interrupt handler to preserve SSE state.
- Refactored shell and text_editor into standalone RSL binaries.
- Fixed x86_64 context switch stack restoration and TCB validation.
- Implemented 'Sovereign Order' AHCI initialization ritual.
- Added recovery boot menu and quiet mode for Limine.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
Restored core hardware drivers (AHCI, xHCI, ATAPI) and fixed critical
multitasking stability issues. Reintegrated the RSL shell into the
kernel binary while maintaining SSE support.

- Reverted shell to kernel integration for improved boot stability.
- Implemented professional boot flow (logo, spinner, silent VGA logs).
- Fixed x86_64 context switch stack restoration and SSE preservation.
- Hardened AHCI 'Sovereign Order' initialization ritual.
- Enabled explicit SSE support (-msse -msse2) in Makefile.
- Added recovery boot menu and configured Limine to quiet mode.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
Finalized the restoration of the OS to match the requested features
while fixing critical multitasking and hardware stability issues.

- Reintegrated the RSL shell into the kernel binary for stability.
- Enabled VGA printing during the boot sequence by default.
- Removed all USB (xHCI) support as requested.
- Eliminated artificial boot delays from the initialization sequence.
- Preserved 'Sovereign Order' AHCI initialization and SSE support.
- Hardened the multitasking context switcher and interrupt handlers.
- Updated recovery menu to support installation and safe mode.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
Implemented the CMD-LETS library providing bash-like scripting
capabilities (if/fi, variables, expansion) for RSL commands.
Added a standalone JIT program to execute these scripts.

- Created include/cmdlets.h and kernel/libs/core/cmdlets.c.
- Created programs/jit.c (Just In Time compiler/interpreter).
- Added RSL system call gate (0x03) and handler in rsl_syscalls.c.
- Refactored forensic_panic to use a single atomic report loop.
- Reintegrated RSL shell into kernel binary for startup stability.
- Enabled VGA printing by default during boot.
- Removed USB (xHCI) support as requested.
- Maintained SSE support and multitasking stability fixes.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Created CMD-LETS library for bash-like scripting (if/fi, variables).
- Added JIT standalone program for script execution.
- Refactored forensic_panic to use a single atomic print loop and halt.
- Restored VGA boot printing and kernel-integrated shell.
- Removed USB support and optimized boot performance.
- Maintained SSE support and AHCI stability fixes.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit performs a comprehensive overhaul of the OS, merging core
stability from the last working bootstrap with advanced features
from the Alix project.

Key Changes:
- Hardware: Fixed AHCI 'Init-Stall' by enforcing Sovereign Order (engine
  stopped during address registration) and pre-initializing the APIC
  timer for driver delays.
- Tasking: Overhauled unice64 context switcher to fix RSP restoration
  logic and added SSE state preservation (fxsave/fxrstor) with
  guaranteed 16-byte alignment in task_t.
- Shell: Re-integrated the shell into the kernel for immediate boot
  availability. Added the CMD-LETS scripting library (if/fi, variables,
  expansion) and the JIT standalone compiler.
- System: Hardened forensic_panic for atomic VGA/Serial reporting and
  implemented 'quiet' boot parsing for the Limine command line.
- Cleanup: Completely removed xHCI/USB stack to streamline the kernel
  per project requirements.
- Build: Updated Makefile and limine.cfg for the new ISO root layout
  and Sovereign branding.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit addresses the reported hang during AHCI initialization by
hardening the timer subsystem and strictly enforcing the AHCI engine
state machine.

Changes:
- Timer: Re-implemented pit_wait_ms using PIT Mode 1 (Hardware One-Shot)
  to provide reliable timing before interrupts are enabled.
- AHCI: Ensured DMA engines (ST/FRE) are fully stopped before
  registering memory addresses. Added detailed serial logging for port
  link status and engine transitions.
- Boot: Updated main.c to parse Limine command line for 'quiet' flag.
  Added forced serial telemetry for the critical init sequence.
- Loader: Fixed 32-byte header offset bug in tasking_spawn_app to ensure
  compatibility with standalone RSL binaries.
- Stability: Aligned kernel stack to 16-byte boundary for SSE/ABI
  compliance.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit fixes the kernel hang during AHCI initialization and ensures
that all system output is reliably transmitted via Serial for
debugging and hardware discovery visibility.

Changes:
- AHCI: Implemented strict HBA port stop sequence (ST/FRE clear) before
  registering memory addresses to prevent controller state-machine
  stalls. Added verbose serial diagnostics for link training.
- Timer: Hardened pit_wait_ms with a robust PIT Mode 0 polling loop and
  safety timeouts for use during early boot.
- Console: Simplified the printing architecture to remove unstable
  worker tasks. print() and vga_print() now mirror all output to Serial
  synchronously, ensuring visibility during critical init phases.
- Boot: Added early serial_init to the kernel entry point and resolved
  linker errors in limine_reqs.c.
- Tasking: Integrated soft-yielding via interrupt 0x81 to improve
  multitasking stability during hardware polling.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit resolves the AHCI initialization stall and implements a
robust printing architecture that mirrors all console output to Serial
COM1 for full system visibility during boot.

Hardware/Boot:
- AHCI: Implemented a strict 'Sovereign Order' sequence (stop engine ->
  register addresses -> start engine) to prevent controller deadlocks.
- Timer: Hardened pit_wait_ms with a reliable PIT Mode 0 delay loop.
- Boot: Updated main.c to parse Limine cmdline for 'quiet' and
  initialize Serial immediately.

Printing:
- Mirrored VGA to Serial: vga_write_char now always transmits to Serial
  before checking g_vga_silent for drawing.
- Simplified console.c to remove unstable worker tasks and unify output
  routing through vga_write_char.

Shell/Tasking:
- Shell: Added 'run' and 'exec' commands. Fixed binary loader to skip
  the 32-byte RSL header.
- Tasking: Added soft-yielding via interrupt 0x81 and ensured 16-byte
  alignment for task_t structures.
- ISO: Refined Makefile and ISO root layout for Limine compatibility.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit stabilizes the OSx2 Limemade kernel by fixing the AHCI
initialization hang and implementing a two-phase boot logging strategy
with robust VGA-to-Serial mirroring.

Key Changes:
- Hardware: Implemented 'Sovereign Order' AHCI initialization in ahci.c,
  ensuring engines are stopped during address registration. Hardened
  pit_wait_ms for reliable early-boot delays.
- Printing: Implemented true VGA-to-Serial mirroring in vga_write_char.
  All system output (kernel/shell) is mirrored to Serial COM1.
- Boot Flow: Updated main.c to display all hardware discovery logs on
  VGA and then switch to silent mode (g_vga_silent=true) immediately
  before starting the shell task.
- Tasking: Added soft-yield via interrupt 0x81 and enforced 16-byte
  alignment for task_t to support SSE state preservation (fxsave).
- Shell: Added 'run' and 'exec' commands and fixed the 32-byte RSL
  header offset bug in the binary loader.
- Stability: Resolved 'get_kernel_file' linker error and unified all
  print calls to route through the mirroring console.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
… logging

This commit stabilizes the Sovereign kernel and implements the
requested feature set from the Alix project.

Key Features & Fixes:
- Hardware: Resolved AHCI 'Init-Stall' by reordering timer init and
  enforcing HBA engine stop before address registration.
- Logging: Implemented a two-phase logging strategy. Full VGA
  visibility during boot/discovery, then VGA silence for the shell
  while maintaining robust Serial mirroring via vga_write_char.
- Tasking: Fixed context-switch stack corruption and added SSE state
  preservation with strict 16-byte alignment in task_t.
- Shell: Integrated the shell into the kernel for boot stability. Added
  support for program execution (./, exec, run) and fixed the binary
  loader to correctly skip the 32-byte RSL header.
- Scripting: Added the CMD-LETS engine and JIT standalone compiler.
- Cleanup: Removed redundant USB (xHCI) code and unified printing
  to ensure reliable system diagnostics.
- Build: Updated Makefile and ISO layout for high-half kernel and
  standalone binary support.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
This commit resolves the AHCI boot stall and integrates a full suite
of features including multitasking, scripting, and standalone binary
support.

Key Improvements:
- Hardware: Resolved AHCI 'Init-Stall' by reordering timer init and
  enforcing HBA engine stop before address registration.
- Mirroring: Implemented true VGA-to-Serial mirroring. Every console
  character is transmitted to Serial COM1.
- Boot Flow: Modified main.c to display all boot logs on VGA, then
  silence the VGA console immediately before shell start (Phase 2).
- Tasking: Fixed context-switch corruption and implemented SSE state
  preservation with strict 16-byte alignment.
- Shell: Integrated shell for stability; added './', 'exec', and 'run'
  command support for programs and scripts.
- Scripting: Integrated CMD-LETS engine and JIT standalone compiler.
- Loader: Fixed binary compatibility by skipping the 32-byte RSL header.
- Cleanup: Removed redundant USB (xHCI) code and unified printing
  architecture for maximum reliability.
- Build: Updated Makefile and Limine config for high-half kernel and
  correct ISO root structure.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Resolved AHCI 'Init-Stall' by enforcing Sovereign Order (Stop->Register->Start).
- Overhauled unice64 multitasking with SSE support (fxsave/fxrstor) and 16-byte alignment.
- Implemented VGA-to-Serial mirroring and two-phase boot logging.
- Integrated CMD-LETS scripting engine and fixed RSL binary loader (32-byte header skip).
- Optimized AHCI hardware audit to prevent redundant engine resets.
- Hardened SSE stack safety in interrupt handlers.
- Fixed ISO layout and Limine configuration for root-level kernel loading.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Implemented recursive directory injection in `fat_tool.py` to support nested ramdisk structures.
- Reorganized `iso_root` layout: kernel and ramdisk moved to `/boot`, binaries to `/bin`, and system scripts to `/sys`.
- Updated `limine.cfg` and `Makefile` to reflect the new standardized folder locations.
- Modified kernel initialization to support `INITRD:/` registration and fallback `BOOT:/` aliasing.
- Updated shell paths for automated boot scripts.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Fixed shell entry point mismatch by restoring `task_shell` safety wrapper.
- Implemented `translate_user_ptr` in the syscall handler to support relative addressing for standalone RSL binaries.
- Hardened FatFS `f_write` with a read-modify-write loop and fixed `resolve_path_to_cluster` component transitions.
- Improved `slab_alloc_persistent` with a multi-depth 'Sovereign Shield' to support nested filesystem operations.
- Fixed Window Manager dragging logic and implemented Z-order reordering for focused windows.
- Ensured 16-byte stack alignment across all assembly-to-C transitions (IRQs and Syscalls).
- Updated the build system to generate default system scripts and maintain a standardized ISO structure.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Implement Sovereign AHCI Handshake: force ICC to Active and set SUD bit to resolve QEMU-specific stalls (0x130 TFD).
- Multi-Stage AHCI Boot: scan ports 0-4 synchronously during init; defer ports 5-31 to a background kernel thread (ahci_bg).
- Integrate Nuklear GUI: provide a fixed-memory backend and a minimal userland C library (rsl_libc.h) for standalone RSL binaries.
- Unified Console Output: route all output through vga_write_char for consistent Serial/VGA mirroring and remove redundant prints.
- Stability Fixes: preserve SSE state in multitasking, fix stack alignment in interrupt stubs, and resolve build breakers in vdisk/FatFS.
- Cleanup: remove dead XHCI driver code.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Resolved AHCI 0x130 TFD stall by forcing ICC Active and SUD bits in `ahci_port_start`.
- Implemented background AHCI scanning for ports 5-31 via dedicated kernel thread.
- Integrated Nuklear immediate-mode GUI with a custom direct-framebuffer backend.
- Added RSL service gate syscalls for Mouse (ID 204), Framebuffer (ID 202), and Pixel Drawing (ID 213).
- Unified kernel/shell output through a VGA-Serial mirroring gate in `vga_write_char`.
- Implemented `programs/nuklear/rsl_libc.h` to provide standalone RSL binaries with memory and math symbols.
- Hardened tasking and interrupt stubs for 16-byte SSE stack alignment safety.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
…mentation

- Integrated CherryUSB Host Stack core into the kernel.
- Implemented 'Primary Receive/Process Task' architecture for USB event handling.
- Refactored Nuklear backend to use a new standard C library (libc) in `programs/libc/`.
- Implemented `malloc`, `free`, `memcpy`, `memset`, and basic math in `programs/libc/`.
- Updated kernel with `rsl_get_new_transient_slab` (ID 201) to support userland heap allocation.
- Refactored `Makefile` to build all binaries from source, ensuring a clean, source-only repository.
- Updated `.gitignore` to strictly exclude all binaries, ISOs, and build artifacts.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
…mentation

- Integrated CherryUSB Host Stack core into the kernel.
- Implemented 'Primary Receive/Process Task' architecture for USB event handling.
- Refactored Nuklear backend to use a new standard C library (libc) in `programs/libc/`.
- Implemented `malloc`, `free`, `memcpy`, `memset`, and essential math/string functions in `programs/libc/`.
- Standardized memory management headers (`stdlib.h`, `string.h`, `math.h`) across the kernel and programs.
- Updated kernel with `rsl_get_new_transient_slab` (ID 201) to support userland heap allocation.
- Refactored `Makefile` to build all binaries from source, ensuring a clean, source-only repository.
- Updated `.gitignore` to strictly exclude all binaries, ISOs, and build artifacts.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Implemented `STDE` command in shell to launch the Window Manager (`wm.bin`).
- Standardized memory management by including `<include/stdlib.h>`, `<include/string.h>`, and `<include/math.h>` across kernel and programs.
- Removed redundant manual declarations of `malloc`, `free`, `memcpy`, and `memset`.
- Enhanced userland `malloc` and `realloc` in `programs/libc/libc.c` with an `alloc_header_t` to track allocation sizes, ensuring safe `realloc` operations.
- Updated `usbh_primary_task` signature and enrollment to ensure ABI compliance.
- Verified that all programs and kernel components correctly reference the new centralized libc headers.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
- Implemented `STDE` shell command to launch the window manager (`wm.bin`).
- Refined userland `malloc`/`realloc` in `programs/libc/libc.c` to use an `alloc_header_t` for safe size tracking.
- Standardized `usbh_primary_task` signature and enrollment.
- Performed system-wide header cleanup, replacing manual declarations with `<include/stdlib.h>` and `<include/string.h>`.
- Ensured a clean, source-only repository by removing all build artifacts.

Co-authored-by: rtech-technologies <254326487+rtech-technologies@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant