Skip to content

Implement real memory management and multitasking foundations - #14

Merged
n96j merged 3 commits into
mainfrom
agent/real-memory-multitasking-elf
Jul 31, 2026
Merged

Implement real memory management and multitasking foundations#14
n96j merged 3 commits into
mainfrom
agent/real-memory-multitasking-elf

Conversation

@n96j

@n96j n96j commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve and parse Multiboot 1/2 memory maps and feed a real bitmap PMM
  • implement page allocation, contiguous/aligned frames, accounting, and reserved-region handling
  • add per-process VMM contexts backed by architecture page tables on i686, x86_64, ARM32, AArch64, RISC-V 32, and RISC-V 64
  • connect the architecture assembly context switches to the round-robin scheduler
  • give processes dedicated kernel stacks and address spaces with lifecycle cleanup
  • add a bounds-checked ELF32/ELF64 loader that maps PT_LOAD segments through VMM, zeroes BSS, applies permissions, and rolls back failures
  • replace the semaphore spin loop with a FIFO blocking queue and scheduler wakeups
  • expose live PMM accounting through /proc/meminfo
  • make RISC-V CI authoritative instead of silently accepting missing toolchains or failed builds

Why

The userspace foundation merged in #13 intentionally stopped at embedded processes because PMM, VMM, context switching, ELF loading, and blocking synchronization were still stubs. This change replaces those boundaries with executable implementations so processes can own address spaces, switch stacks, load executable images, and sleep without busy-waiting.

Architecture notes

  • x86 receives its real firmware memory map from the Multiboot handoff.
  • non-x86 boot paths currently use their platform RAM fallback until their FDT/firmware memory discovery is wired.
  • address spaces and ELF mappings are real, but ELF entry points still execute at kernel privilege; ring-3/EL0/U-mode transitions are explicitly not claimed by this PR.
  • scheduling is cooperative through yield/block paths; timer-driven preemption remains separate work.

Validation

  • make test — host userspace, PMM, ELF, scheduler, and semaphore tests passed with -Werror
  • local x86_64 and i686 builds passed with no undefined symbols
  • GitHub Actions run 30 built and uploaded artifacts for all six targets:
    • i686
    • x86_64
    • arm32
    • aarch64
    • riscv32
    • riscv64
  • x86 ISO generation passed for both x86 targets
  • git diff --check — passed

RISC-V now uses the available riscv64-linux-gnu multilib toolchain for both XLENs and -mcmodel=medany for kernels linked at 0x80000000.

@n96j
n96j marked this pull request as ready for review July 31, 2026 09:23
@n96j
n96j merged commit 41a8d78 into main Jul 31, 2026
7 checks passed
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