This commit is contained in:
Alvin-Zilverstand committed 2026-10-09 03:19:53 +02:00
1 parent 6dc841f956
commit 3d06f94e48
46 files changed
+5830 -543

No files matched your search

+210 -53
View File
@@ -47,8 +47,8 @@ the existing emulator/build outputs stay separate.
walks low and upper canonical virtual addresses and physical/table addresses
above 4 GiB, and verifies writable pages can become read-only/NX, be unmapped,
and be mapped again. The handoff activates the root after enabling `EFER.NXE`
when supported; host tests cover mapping logic, while the privileged switch
still needs UEFI runtime verification.
when supported; QEMU runtime smoke tests verify active mappings through the
kernel memory and user-page-protection checks.
- `bob64/bootstrap.c` composes that mapper into a bootstrap identity address
space for the loaded EFI image, a replacement stack, and a pre-reserved
contiguous page-table pool. It marks stack/pool pages NX when supported and
@@ -105,8 +105,10 @@ the existing emulator/build outputs stay separate.
pages into a 64 MiB high-half range at `0xffff900000000000`. New pages are
zeroed before use. Kernel entry smoke-tests multi-page allocations, alignment,
zeroing, writes, frees, and double-free rejection. Host tests cover splitting,
coalescing, overflow, and invalid frees. This early heap is single-core and
does not reclaim empty pages yet.
coalescing, overflow, invalid frees, and four-thread allocation/free stress.
Heap metadata is protected by an atomic lock; kernel builds disable local
interrupts while holding it to avoid same-CPU interrupt deadlocks. SMP is not
enabled in the kernel, so hardware multicore runtime contention is untested.
- `bob64/keyboard.c` decodes PS/2 set-1 input, including shift, caps lock,
editing keys, and Pause/extended sequences. IRQ1 now feeds a bounded 64-event
queue used by the shell and app event service after the kernel remaps the PIC;
@@ -125,13 +127,19 @@ the existing emulator/build outputs stay separate.
- `bob64/snapshot.c` defines B64S version 1 as a pointer-free little-endian
format with 64-bit total/data lengths and a CRC-32. Restore validates version,
size, checksum, record bounds, names, and duplicate files before replacing
the live filesystem. The shell's `save` and `restore` commands keep one
checkpoint in the kernel heap for the current boot session; it is lost on
reboot. Host tests cover round-trip, empty files, replace-on-restore,
the live filesystem. The shell's `save` and `restore` commands keep a RAM
checkpoint and store a compressed B64S copy in a non-volatile UEFI variable
when firmware capacity permits. Startup restores that snapshot after
installing the default apps. Host tests cover round-trip, empty files,
replace-on-restore,
truncation, unsupported versions, checksum errors, and unchanged state after
rejected input. Disk persistence and directories remain future stages; the
app filesystem ABI supports bounded whole-file operations and ABI v10 streaming
handles with 64-bit seek positions and bounded reads/writes; hardware-backed
rejected input. A mock runtime-services suite verifies compressed variable
save/restore, corruption rejection, and missing-variable behavior. QEMU/OVMF
reboot testing saved a shell-created file to writable NVRAM, reset the VM, and
verified the file after automatic restore. Disk-backed
filesystem persistence and directories remain future stages; the
app filesystem ABI supports bounded whole-file operations and ABI v12 streaming
handles with 64-bit seek positions and bounded reads/writes; disk-backed
persistence remains outstanding.
- `bob64/exec.c` defines B64E version 1, a flat position-independent 64-bit
executable image with a versioned ABI, exact payload length, 64-bit memory
@@ -140,7 +148,10 @@ the existing emulator/build outputs stay separate.
images before returning a view; a contiguous copy helper preflights capacity
and address overflow, copies the image, clears the memory-only tail, and
preserves entry addresses above 4 GiB. Mapped application loading is provided
separately by `process.c`. A synthetic B64E app now runs at CPL3, writes
separately by `process.c`. The `bob64cc` packager keeps PE zero-fill data out
of the B64E file while retaining its full 64-bit `MemorySize`; the desktop
image is about 37 KiB on disk and still maps over 4 MiB at runtime. A
synthetic B64E app now runs at CPL3, writes
`bob!` through syscall v2, performs a bounded RAM-file round trip, and exits
back to the saved kernel stack.
- `bob64/abi.h` starts application ABI v1 on the same Microsoft x64 calling
@@ -150,7 +161,7 @@ the existing emulator/build outputs stay separate.
32-byte startup record containing a 64-bit argument count and argv pointer.
The record and its strings are app-space data, so the contract does not pass
kernel pointers. Tests check the record layout, entry call, nested calls, and
stack-passed arguments. Syscall ABI v10 defines an ABI query, character and
stack-passed arguments. Syscall ABI v12 defines an ABI query, character and
bounded buffer output, file reads and writes, pixel-display query/present,
blocking keyboard and PS/2 mouse events, and process exit through interrupt
vector `0x80`; user pointers are validated
@@ -171,8 +182,8 @@ the existing emulator/build outputs stay separate.
lists RAM files in a separate window, supports selection/open/refresh and
confirmed deletion, plus insertion, line breaks, cursor movement, click
placement, scrolling, Ctrl+S save and an unsaved-exit prompt. It validates flat
filenames and protects an existing file over the current 4 KiB syscall limit
from accidental overwrite. The shell launches it with
filenames, streams files in 4 KiB chunks, and supports up to 16 KiB of text,
matching the resident compiler's source limit. The shell launches it with
`run desktop.b64e [filename]`; host tests cover the editor buffer, packaged
UI strings, file ABI and window manager. The full existing bob GUI, a file
picker and real UEFI interaction remain to be ported/verified.
@@ -187,24 +198,32 @@ the existing emulator/build outputs stay separate.
as B64E; `run app.b64e` launches it. The current syntax accepts `int` or
`long`, `long long`, or `int main(void)`, initialized `int`/`long`/`long long`
locals and assignments,
bounded `bob64_app_write` calls with string literals, and 64-bit integer
return expressions with parentheses, unary minus, addition, subtraction, and
multiplication. Its frame and entry wrapper follow the Microsoft x64 stack
contract; syscall ABI v10 provides exit, graphics output, whole-file and
`bob64_app_write` calls with typed `char *` expressions and scalar length
expressions, and 64-bit integer
return expressions with parentheses, unary minus, addition, subtraction,
multiplication, signed division/remainder, and unsigned pointer-sized
division/remainder. Signed division truncates toward zero. Its frame and entry
wrapper follow the Microsoft x64 stack
contract; syscall ABI v12 provides exit, graphics output, whole-file and
streaming file I/O/list/delete,
and input.
and input. Host compiler-model tests execute both 32-bit `long` truncation
and 64-bit pointer-sized values, while the test harness asserts the host and
UEFI targets use the documented LLP64 scalar widths.
The compiler recognizes `usize`/`uintptr_t` as unsigned 64-bit scalar types
and `isize`/`intptr_t` as signed 64-bit scalar types in declarations and
function signatures. These are built-in type names; typedefs and header
inclusion remain unsupported. `usize *`, `uintptr_t *`, `isize *`,
function signatures. These are built-in type names. Bounded file-scope
typedefs alias supported scalar types, scalar pointers, and previously
declared named structs; alias chains work, while typedef arrays, function
pointers, anonymous structs and header inclusion remain unsupported.
`usize *`, `uintptr_t *`, `isize *`,
`intptr_t *`, and `long long *` map to signed/unsigned wide-pointer types with
eight-byte loads, stores, indexing and scaled pointer arithmetic. They work as local,
parameter, return, global, and struct-field types; global pointers may target
matching scalar objects. Fixed-size signed and unsigned 64-bit arrays now
support local and global storage, initialization, indexing, mutation, array
parameter decay, and eight-byte element addressing. Local arrays are limited
to 16 elements by the fixed function frame; global arrays share the 4 KiB data
page.
parameter decay, and eight-byte element addressing. Local automatic storage
is bounded by the function frame; global arrays share the 16 KiB compiler data
region.
Function declarations and definitions can return `char *`, `short *`, `int *`,
and pointers to declared structs. Returned pointers keep all 64 bits; return
expressions must match the declared pointee type. Returning a pointer through
@@ -245,27 +264,58 @@ the existing emulator/build outputs stay separate.
GDT/IDT and new CR3. A deliberate invalid opcode was diagnosed with the full
register frame and returned to the kernel; the corrected smoke app now exits
normally. The IDT now also contains PIT, PS/2 keyboard, and PS/2 mouse IRQ
handlers; runtime IRQ-path verification remains pending below.
handlers; PIT tick advancement is now checked at runtime, keyboard IRQ
delivery is exercised by the shell/desktop sessions, and live mouse-event
assertions remain open below.
- [x] Verify actual ring-3 text protection and data NX behavior. QEMU runtime
probes attempt to write the read-only executable page and execute the NX data
page; both receive the expected user page-fault error bits and return to the
kernel. The kernel also checks that the stack guard is unmapped.
- [ ] Add dynamic page-table-pool growth, heap locking, and reclamation of empty
heap pages. The bootstrap identity map favors bring-up simplicity.
- [x] Grow the page-table pool dynamically in 64-page chunks, triggered while
eight reserve pages remain. New chunks are identity-mapped using the reserve
before becoming allocatable. Host bootstrap tests cover growth beyond the
initial 128 pages, and the kernel now runs a 140-table smoke test.
- [x] Verify the expanded page-table smoke test under QEMU; the runtime script
waits for its `dynamic page-table pool passed` marker.
- [x] Protect heap metadata with an atomic lock and disable local interrupts
while kernel callers hold it. Four-thread host stress covers concurrent
allocation, free, coalescing, and page shrinking. Kernel SMP is not enabled.
- [x] Reclaim full trailing heap pages when the final free block reaches the
heap end. The heap keeps its first page mapped, returns released physical
frames to the allocator, invalidates each removed virtual mapping, and
regrows contiguously when later allocations need the pages again. Host and
kernel smoke tests cover reclaim and regrowth.
- [x] Verify GOP, COM1, PS/2 keyboard, and mouse input under UEFI emulation.
QEMU showed mouse movement and a click selecting a file-list row; keyboard
input launched/closed the desktop and created a third window.
- [ ] Verify the new IRQ1 keyboard and IRQ12 mouse paths under UEFI emulation.
Host tests cover the IDT gates and bounded event queues; QEMU verification is
pending.
- [x] Add a 100 Hz PIT timer IRQ, tick counter, and user tick query. The timer
tick path is covered by host syscall tests; runtime QEMU verification remains
pending alongside keyboard/mouse IRQ checks.
- [ ] Add USB keyboard support and command history/completion. COM1 remains
polled.
- [ ] Add persistent storage for B64S snapshots. ABI v10 now supplies bounded
handle-based streaming reads/writes, 64-bit absolute seeks, create/truncate/
append modes, and per-app handle cleanup; physical persistence remains open.
- [x] Verify live IRQ1 keyboard and IRQ12 mouse input under UEFI emulation.
Host tests cover the IDT gates and bounded queues. Existing desktop runs
exercise keyboard input; the QEMU runner now injects a PS/2 mouse move,
launches a ring-3 event-wait app, and requires its nonzero movement event to
arrive through the syscall ABI.
- [x] Add a 100 Hz PIT timer IRQ, tick counter, and user tick query. Host tests
cover the syscall path, and the UEFI kernel now waits for a real tick before
continuing; QEMU checks the `timer tick passed` marker.
- [x] Add synchronous B64E child launch through syscall ABI v12, with validated
argv copying so native apps can open selected files or pass commands onward.
The user-entry
return bridge keeps eight nested return frames; per-app kernel stacks,
syscall-service contexts, file handles, and window-server sessions are
restored on return. Host syscall tests cover nested context restoration, and
the boot image includes a `bob!` nested-launch smoke app; QEMU runtime testing
confirms the child returns and the parent continues.
- [ ] Add USB keyboard support; COM1 remains polled.
- [x] Add an eight-command shell history on Up/Down and Tab completion for
built-in commands plus file arguments to `cat`, `rm`, `run`, and `cc`. Host
tests cover draft restoration, keyboard arrow translation, and unique command
and filename completion.
- [x] Verify compressed B64S persistence across reboot with writable OVMF
NVRAM. The kernel stores compressed snapshots in two alternating EFI slots,
split across bounded variables, and commits the active-slot record last. Host
tests cover multi-variable round-trip, corruption fallback, missing storage,
and firmware without `QueryVariableInfo`. QEMU/OVMF runtime testing saved a
file in the shell, reset the VM, restored the snapshot, and verified that
file. Disk-backed filesystem persistence remains open.
- [ ] Port remaining device services and add USB keyboard support.
- [x] Add typed pointer returns to the resident x86-64 compiler for
`char *`, `short *`, `int *`, and declared struct pointers. Tests cover
@@ -281,16 +331,16 @@ the existing emulator/build outputs stay separate.
pointer values above 4 GiB.
- [x] Add fixed signed and unsigned 64-bit arrays with local/global storage,
initialization, indexed reads/writes, and array-parameter decay. Local arrays
are bounded to 16 elements and global data to the existing 4 KiB page.
are bounded to 16 elements and global data to the compiler's 16 KiB limit.
File-scope `short`, `int`, `long`, `char`, and `long long` scalars plus bounded
fixed `short`/`int`/`char` arrays now use initialized writable B64E data and
RIP-relative x64 access across functions. Global `short *`/`int *`/`char *`
initializers may target
previously declared arrays or string literals. Named structs define aligned
scalar/pointer layouts and support local/global instances plus `.`/`->` field
loads/stores. Struct arrays, nested structs, typedefs, and multiple translation
loads/stores. Struct arrays, nested structs, and multiple translation
units remain unsupported. Limits are 8 struct types, 16 fields per type, 16
global objects, and the single 4 KiB data page.
global objects, within the compiler's 16 KiB global data limit.
Local fixed `short`/`int` arrays, `short *`/`int *` locals,
dereference/indexing, scaled pointer arithmetic and pointer differences, and
local brace initializers are
@@ -316,34 +366,141 @@ the existing emulator/build outputs stay separate.
nearest loop; `for` continue enters its update clause. Early `return`
statements work inside branches and loops; the subset still requires a final
return at the end of each function.
- [x] Expand the resident compiler's bounded source, machine-code, and global
data capacities from 4 KiB each to 16 KiB each. Host execution tests compile
and run a source file larger than 4 KiB with generated code beyond the old
page limit, and access an 8 KiB global array. B64E still separates read-only
code from writable/NX data pages.
- [x] Expand resident C function frames from 128 bytes and 16 variables to a
1 KiB frame and 64 variables. Code generation now uses disp8 or disp32 RBP
operands as needed. Host execution tests cover forty local scalars, a 64-item
local integer array and a 256-byte initialized character array.
- [x] Add bounded resident C typedefs for scalar, pointer, and named-struct
aliases. Host execution tests cover aliases in declarations, arrays, struct
fields, pointer parameters/returns, and member access through an aliased
struct pointer.
- [x] Add signed division/remainder and unsigned `usize` division/remainder to
resident C integer expressions. Host tests execute negative 64-bit operands
and an unsigned value above 4 GiB; the QEMU resident-compiler smoke program
covers signed truncation/remainder and wide unsigned arithmetic.
- [x] Add C-precedence bitwise complement, AND/XOR/OR, and left/right shifts.
Host execution tests cover operator precedence, signed arithmetic shift, and
unsigned right shift above 4 GiB; the QEMU resident-compiler smoke program
exercises the same operators in the running kernel.
- [x] Add a kernel-owned per-app window manager and port the desktop's file and
editor windows to its surfaces. Syscall ABI v10 creates, focuses, destroys,
editor windows to its surfaces. Syscall ABI v12 creates, focuses, destroys,
validates and copies app surfaces, composites z-order, routes input with
64-bit handles and local/screen coordinates, and releases the session on app
exit. Concurrent apps are still not displayed together.
- [x] Run the native desktop under QEMU/OVMF at 1280x800. Both managed windows
rendered; keyboard input created a third window, Escape returned to the
shell, and Ctrl+S saved editor text through the file syscall. The full screen
and B64S shell commands were also exercised in the same UEFI session.
- [ ] Port the remaining applications to the kernel window API. Syscall ABI v10
and B64S shell commands were also exercised in the same UEFI session. The
automated QEMU pass now opens the Applications window while both desktop
windows remain active, launches a child app, and repeats the GUI/child-app
round trip after B64S restore. The restored run opens the launcher, uses a
PS/2 mouse click on Run App and X CLOSE, then verifies Escape returns to the
shell.
- [x] Add a desktop launcher control for selected `.b64e` files. It runs the
child synchronously and displays its exit status after returning to the
editor; host packaging tests cover the control strings. QEMU/OVMF now opens
the Applications launcher, starts its selected `bob!` child, and verifies
that the desktop returns to the shell with a zero exit status.
- [x] Port reusable button behavior to the native framebuffer GUI. The
`bob64/widgets.h` button handles hover/pressed states and activates only on
an inside left-button release; the desktop uses it for Run App, APPS and
X CLOSE. Host tests cover hit bounds and cancel-on-release-outside; QEMU
verifies mouse launch and close interactions.
- [x] Port bounded single-line text entry to the native GUI and add Save As
through the desktop's filename field. Host tests cover caret placement,
insertion, deletion, horizontal reveal, and capacity bounds. QEMU clicks the
field, edits a filename, saves through the GUI, verifies the file from the
shell, and removes the smoke fixture.
- [x] Replace Bob64's two-press file deletion shortcut with a visible
Yes/Cancel confirmation window. `D` and the file-window Delete button open
the dialog; `Y`/Enter confirms and `N`/Escape cancels. The open editor file
remains protected. The handoff build and full QEMU/OVMF regression pass;
direct QEMU interaction coverage for this dialog remains to be added.
- [x] Port the Bob32 desktop's on-screen help overlay as a managed Bob64 help
window. It is reachable from the Files panel or `H`/`?`, and documents the
native desktop's current navigation, app-launch, delete, save, and focus
shortcuts. Host packaging tests assert the help window's contents.
- [x] Add a bounded file-browser preview to the Bob64 desktop. Selection changes
load up to 384 bytes into a separate scratch buffer, show text, mark truncated
files, and identify executable/binary files without putting them in the editor.
Host package checks assert the preview UI and its app/error states.
- [x] Port the argument-printing `echo` utility to the B64E startup ABI and
install it in the default RAM filesystem. The UEFI smoke path passes a
`bob!` argument and checks the native app output; the QEMU runtime script
verifies the app marker and argument output.
- [x] Port a native `ls.b64e` app over the 64-bit file-list syscall. The kernel
launches it during smoke testing and checks its output begins with the
installed `ls.b64e` filename; QEMU runtime testing confirms the marker.
- [x] Port a native `cat.b64e` app over streaming file handles. The kernel
smoke path reads a `bob!` RAM-file fixture, verifies the output, and removes
the fixture afterward; QEMU runtime testing confirms the marker.
- [x] Port Bob32's notes utility as native `notes.b64e`, with a desktop-editable
notes window and shell `show`, `put` / `edit`, `add`, and `delete` commands
over the 64-bit file ABI. It rejects binary files and is packaged for the
desktop app launcher. The kernel smoke path creates, shows, verifies, and
deletes a `bob!` note; QEMU runtime testing confirms its marker and output.
- [x] Port Bob32's keyboard/mouse application launcher into the Bob64 desktop.
It lists installed `.b64e` files, launches the selected app through the
nested-app ABI, and supports keyboard/mouse selection plus run/close controls.
Host packaging checks verify its visible title and shortcuts.
- [x] Match the text editor's Home/End line navigation from Bob32 and cover it
with native editor unit checks.
- [x] Protect Bob64 editor contents from executable/binary files. The GUI now
uses a scratch buffer, rejects `.b64e` and control-byte content, and leaves
the current document untouched when a binary file is selected.
- [x] Expand the desktop editor and Notes app to 16 KiB using high-level
streaming file helpers over the existing 4 KiB syscall transfers. Editor
unit checks fill the complete buffer and reject the first excess character.
- [x] Keep zero-fill PE sections out of B64E file payloads while preserving
their virtual memory sizes. Host packaging tests assert the desktop's
multi-megabyte zero-fill tail is loaded from B64E `MemorySize`, and QEMU
verifies the desktop runs and B64S save/restore still succeeds.
- [ ] Port the remaining applications to the kernel window API. Syscall ABI v11
also provides bounded file reads/writes/list/delete, console I/O,
full-screen presentation, blocking PS/2 keyboard/mouse events, ABI query, and
process exit. The host `bob64cc`
bridge continues to package the broader C subset supported by GCC.
- [ ] Port the remaining existing applications and full GUI/widget behavior;
the current native text editor is an initial, limited desktop milestone.
- [x] Port Bob32's graphics demo as a 640x400 kernel-composited Bob64 window.
The native `display.b64e` app draws colored panels and diagonal lines, prints
`bob!`, and returns to the shell on X or Escape. The QEMU runtime test checks
presentation, clean app exit, and compatibility with snapshot save/restore.
- [x] Port the system-information utility as native `info.b64e`. It reports the
syscall ABI, available display resolution, uptime, and RAM filesystem usage;
the kernel embeds and launches it in the application smoke path. The kernel
smoke test checks its captured ABI, uptime, filesystem fields, and final
`bob!` output; the QEMU runtime script confirms the marker and output.
- [x] Port the standalone application launcher to a native Bob64 window. It
lists installed `.b64e` apps, launches the selected app through the nested
app-run syscall, and closes on Escape/X/Close. Host packaging checks validate
the B64E image; QEMU opens it, checks `bob!`, and verifies a clean return to
the shell. The shell can also run the launcher with `APP [ARG ...]`; ABI v12
validates and forwards the full argv vector to the selected child.
- [x] Run the kernel-generated ring-3 `bob!` app under x64 UEFI emulation. The
resident compiler also compiled and launched `bob.c`; B64S `save`/`restore`
recovered a deleted file, and the native GUI opened and saved an editor file.
QEMU runtime test also compiles `bob.c` through the resident shell compiler,
launches the resulting B64E app, and checks `bob!` and a zero exit status.
The source exercises local character/integer arrays, helper functions, array
parameters, loops, pointer-based syscall output, computed string length,
forty local variables, a 64-element stack array and a nested call with sixteen
integer arguments (four register-passed and twelve stack-passed).
The test saves the compiled app in B64S, resets, and launches it again after
restore, then relaunches the GUI and a child app from the restored system.
- [ ] Complete the full acceptance flow and add runtime tests for broader
calling-convention/stack cases, hardware interrupts, mouse input, and
persistent B64S storage. The ring-3 app image runs at a virtual address above
calling-convention/stack cases and the remaining widget interactions.
The ring-3 app image runs at a virtual address above
4 GiB; host tests also cover synthetic high addresses and broad ABI/memory
cases.
- [x] Verify bob64 boots in x64 UEFI emulation and performs its own kernel
initialization without executing 32-bit kernel or app code. The broader
migration remains active: the resident C subset, devices, persistence, and
existing application ports still need work.
migration remains active: the resident C subset, USB and other device
support, disk-backed persistence, and remaining application ports still need
work.
## Build and test
@@ -352,7 +509,7 @@ build-tool --bob64
build-tool --bob64-test
build-tool --bob64-handoff
build-tool --bob64-handoff-test
tools/test_bob64_qemu.ps1 -QemuPath <qemu-system-x86_64.exe> -OvmfCodePath <edk2-x86_64-code.fd>
tools/test_bob64_qemu.ps1 -QemuPath <qemu-system-x86_64.exe> -OvmfCodePath <edk2-x86_64-code.fd> -OvmfVarsPath <edk2-x86_64-vars.fd>
```
The safe output goes to `build/bob64/EFI/BOOT/BOOTX64.EFI`; the opt-in handoff
@@ -388,8 +545,8 @@ The fallback kernel privilege stack and each app's dedicated 16 KiB interrupt
stack are allocated from the supervisor-only heap. App runs also push a bounded
syscall context that preserves the parent's callbacks, user page table, scratch
buffers, and file handles; each app owns a separately allocated window-server
session. The user-entry return bridge still uses singleton state, so nested app
execution is not enabled yet.
session. The user-entry return bridge keeps a bounded stack of nested return
frames, allowing synchronous child-app execution while preserving the parent.
The volatile
filesystem and B64S checkpoint live in the kernel heap; there is no full
physical direct map or filesystem mapping.