Skip to content

Cosmos gen3 port (NativeAOT) - #279

Closed
valentinbreiz wants to merge 17 commits into
masterfrom
gen3
Closed

valentinbreiz wants to merge 17 commits into
masterfrom
gen3

Conversation

@valentinbreiz

Copy link
Copy Markdown
Member

Port of Aura to the Cosmos gen3 kernel (nativeaot-patcher), currently built against Cosmos SDK 3.0.77.

In this branch

  • Kernel, memory, scheduler, graphics, input, network and filesystem wired to the gen3 packages (Cosmos.Kernel, Cosmos.Kernel.System), resolved from the nativeaot-patcher feed.
  • Multithreading: background services and app compute workers on kernel threads; the UI stays single-threaded.
  • ping restored via upstream ICMP (gen3 Receive reports elapsed milliseconds with 10ms granularity, where gen2 reported whole seconds).
  • SVGA hardware cursor via DefineAlphaCursor/SetCursor when the device offers one; software blit remains the GOP fallback.
  • QEMU/dev configs: virtio input/net, KVM acceleration.

Not done yet

Remaining gen2-parity gaps are tracked in GEN3-GAPS.md (ISO9660/boot-ISO file shipping, and the rest of section 2).

valentinbreiz and others added 17 commits July 14, 2026 01:20
…files

- Aura_OS.csproj -> Cosmos.Sdk / net10.0, local nativeaot-patcher package feed
- Kernel wrapper moved into Aura_OS (Boot/Kernel.cs) with OnBoot + NetworkStack.Initialize
- Kernel.cs: FAT mount at /mnt instead of CosmosVFS 0:\, canvas mode read-back, gen3 GC
- Files.cs: ISO9660 assets -> embedded resources via Cosmos ResourceManager
- Core/Memory.cs: CPU.GetAmountOfRAM/GetEndOfKernel -> PageAllocator accounting
- Retire gen2-only Aura_Boot and Aura_Plugs projects (IL2CPU/XSharp)
…d links

- Graphics/GUI: namespace sweep, DirectBitmap XSharp SSE plugs rewritten in C#,
  CUI console retargeted at KernelConsole, themes from embedded resources
- Network: Http rewritten on plugged System.Net.Sockets TcpClient, Dhcp/Dns/Udp
  renames, ping ICMP stubbed (no ICMP in gen3 yet), ftp stubbed
- Filesystem/Users: /mnt mount-point paths, StatFs free-space, fd-leak fixes,
  ZipStorer on vendored SharpZipLib inflater (STORE-only writes)
- Input: gen3 Mouse/Keyboard managers with edge detection, FR AZERTY layout
  ported as Aura-side ScanMapBase
- Apps/commands: PageAllocator/GC memory stats, PciManager lspci, PIT beep,
  StorageManager/PartitionManager vol, CPUID brand string via X86Base
- Build: Directory.Build.props pins CosmosArch before restore (Sdk conditional
  PackageReference ordering), Makefile QEMU workflow, sln trimmed

Requires nativeaot-patcher feat/aura-port-gaps (fmod/cosh/sinh/tanh, RhCpuIdEx,
MemSet tail fix, ResetScrollDelta, CosmosDefaultFont knob fix).
…egion id

- Files.GetUiResourceText strips the UTF-8 BOM (gen2 File.ReadAllText did);
  NanoXML rejected the U+FEFF prefix with 'Unexpected token'
- RegionListBuilder: guard optional region 'id' attribute — gen2/IL2CPU read
  the null attribute from identity-mapped low memory and got away with it,
  gen3's real paging page-faults
…buffer size, QEMU PS/2

- construct MouseManager before Explorer: the Explorer ctor reaches
  LoginScreen.Hide(), which writes Kernel.MouseManager.FocusedComponent;
  gen2/IL2CPU identity-mapped low memory silently absorbed that null
  write, gen3 page-faults (#PF CR2=0x28 in RhpAssignRef). Its
  Initialize() stays after Explorer's so the cursor draws on top.
- guard theme <text> nodes and missing region attributes in
  RegionListBuilder; show an empty desktop instead of faulting when no
  FAT volume is mounted
- drop '-device i8042' from the Makefile: q35 already has a built-in
  PS/2 controller and the second one broke mouse input under QEMU
  (worked on VMware and via the Cosmos extension, which never adds it)
- bump Cosmos packages to 3.0.63.20260714 (Canvas.Mode now reports the
  real Limine framebuffer size — the taskbar was laid out 247px below
  a 1280x800 screen; GC first-collection hang and mark-stack OOB fixed)
- document all of it in GEN3-GAPS.md §1.8–1.11
…xtract+copy-back

The old path allocated a temporary Bitmap the size of the source on
every alpha blit (~1.6MB per window per frame with a window open),
draining the heap to exhaustion within seconds and forcing constant
collections. AlphaBlendSSE already takes separate dest/src pitches, so
blend straight into the backing buffer — with real rectangle clipping,
which the old bounds check didn't actually provide.
crash-debug boots the ISO headless with a gdb stub, catches a panic on
serial (or, with --hang-after/--mem, halts and samples a silently hung
kernel twice), dumps the crashed stack, and symbolicates every return
address against the kernel ELF via nm/addr2line. run-aura builds and
boots the ISO in a visible QEMU window with the environment gotchas
(broken cosmos-tools qemu wrapper, disk.img write locks) handled.
…lace gen2 vol, auto-mount every FAT volume at boot

New Disk command type so block-device commands run before any volume is
mounted (the old Filesystem guard deadlocked first-time setup: lsblk/mkfs/
mount were rejected with "No volume detected!" on a blank disk).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…oot and every 4th frame

The gen3 kernel only collects when the heap is exhausted, so the desktop's
per-frame allocations just grew the heap forever (GC Collections stayed 0).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…, menu lists every gen3 scan map

KeyboardLayouts registry (US/GB/FR/DE/ES/TR/DV) shared by the taskbar menu
and setkeyboardmap; drop Aura's local AZERTY port now that gen3 ships FR
upstream (closes GEN3-GAP keyboard-layouts). Bump Cosmos.Kernel to 3.0.64,
the first package with the six new scan maps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…p/login after setup

gen2 required exact-size wallpapers and blanked to black otherwise; gen3 runs
at the real framebuffer size (1280x800), so the 1920x1080 wallpapers hit that
fallback once setup flipped Kernel.Installed. ImageUtils now scales them once
at load (nearest-neighbour, same math as Canvas.ScaleImage).

Also factor the taskbar keyboard switcher into KeyboardLayoutButton and add
one to the login screen (bottom right) — an AZERTY user could not type their
password on the US boot layout before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e 64-slot array

PciManager.Devices is a fixed 64-slot PciDevice[] where only the first Count slots are populated; PciDevice is a class, so the trailing slots are null. The foreach walked the whole array and dereferenced the first null slot (page fault, CR2=0x10). Loop by Count like every other PciManager consumer.
- global.json + csproj: Cosmos.Sdk/Kernel/Kernel.System 3.0.64 -> 3.0.66
- Makefile: use -enable-kvm -cpu host when /dev/kvm is writable, fall back to -cpu max (TCG) for CI/containers
- .vscode/launch.json: cosmos-debug launch config
- .cosmos/config.json: QEMU run config (ahci disk5.img, e1000e, ps2)
- .gitignore: ignore disk*.img (was disk.img)
- VersionInfo: bump revision
…I stays single-threaded

- WorkerThread/ThreadedProcess: repeating work loop on a real gen3 kernel
  thread; ProcessManager skips threaded processes in its cooperative tick
- SpinGuard (Interlocked spinlock) instead of lock/Monitor, whose contended
  LowLevelMonitor path faults under concurrency
- Application.RunsWorker: apps offload compute to a worker and publish
  results by atomic reference swap — Cube (projection), GameBoy (emulation,
  double-buffered frames), Terminal (command execution off the UI thread)
- WindowManager: guarded Add/Remove + snapshot iteration; Console scroll
  history guarded (worker writes vs UI scroll)
- SystemMonitor service samples CPU/heap/threads once a second off-thread;
  new SystemMonitorApp and lsprocess TID/THREAD columns surface it
Receive now reports elapsed milliseconds (10ms granularity) where gen2
reported whole seconds; the GEN3-GAP(icmp) stub is gone.
Host composes the cursor via DefineAlphaCursor/SetCursor (premultiplied
BGRA); software blit stays as the fallback for GOP.
@valentinbreiz valentinbreiz mentioned this pull request Oct 2, 2026
7 of 8 tasks
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