Major refactoring, moving to a kernel architecture - #23
Merged
Conversation
Map a dedicated 16 KiB stack region at the top of bootloader memory and start the heap after the loaded image to avoid overwriting kernel text/rodata. Expose map_range on the MMU trait and make range mapping robust to unaligned spans. Allow examples’ test runner to find kernel.elf by default, propagate verbose logging to the VM, and add bootloader bin to .gitignore. Note: crates/bootloader/bin/kernel.elf is a generated binary and currently marked modified.
…, and update bootloader
Move trap logic into a new trap module directory and split save/restore assembly into dedicated files for readability. Keep the trap entry flow intact while wiring module-level helpers. This change removes the old trap.rs file and introduces trap/mod.rs plus save/restore trap frame sources.
- save full kernel register state into TASKS[0] before handoff - keep run_task focused on user-mode entry only - export new wrapper and update program_call to use it - add inline asm comments for register snapshot and trampoline jump
- decode bundle into globals and process one tx at a time - add resume_bundle hook for program calls - wire main to decode then process - log erc20 transfer amount
- add TransactionReceipt to types and re-export in the types lib - track bundle receipts and current tx in kernel globals - initialize receipts when decoding bundles and keep them through bundle execution - implement sys_fire_event in its own module and append events to current receipt - reuse existing user-memory helpers for event payload reads
- capture program results in tasks and attach them to receipts - serialize receipts to kernel memory with a fixed handoff header - read receipts back in the bootloader and print/verify in tests - add receipt encode/decode helpers and kernel result type - refactor receipt handoff helpers into result modules
Create a shared program image loader to centralize account/code validation and entry offset detection. Implement syscall call-program flow with task setup, caller trapframe save, and result handoff back to user callers. Add result copying via caller heap allocation and adjust trap return behavior. Rework trampoline setup to share a single kernel trampoline page mapped into user roots and avoid reliance on current root. Add logging/cleanup tweaks and document kernel_run_task_inner.
- drop avm from the workspace and delete the crate sources - remove the VM host interface abstraction and its plumbing - update syscall wiring/tests and bootloader initialization - restore API trait import for bootloader memory helpers
- add a VM console writer entry point and use ecall id 1000 for console output - drop VM syscall handling and host syscall module; simplify VM/CPU construction - remove bootloader syscall module and related tests - move syscall IDs into program, add kernel/guest log prefixes, and update deps
Rename the smart contract runtime crate to clibc (Chain Libc) and move it into crates/clibc. Update workspace members, crate dependencies, and Rust imports/macros across kernel, bootloader, examples, and compiler ABI generation. Refresh docs to reflect the new name and add a clibc README covering modules, macros, and usage.
- add shared State transfer helpers and bundle transfer processing - implement transfer/balance syscalls and move to balance module - add kernel result state pointer/len with safe encoding - update bootloader/test runner for state capture - keep state crate no_std and clean unused helpers
Move trap/entry trampoline assembly and mapping into a dedicated module and replace the inline setup in prep. Document the trap trampoline instruction sequence for readability. Rename MMU helpers for shorter call sites (map_range_for_root, copy, translate) and update all kernel usages accordingly.
Move kernel config and ABI address constants into global.rs and update all call sites to use the new globals. Remove the Config module/export and delete config.rs now that constants live in global. Reorganize global.rs with prominent section headers and add/adjust comments for clarity. Also update clibc entrypoint comment to point at the new RESULT_ADDR location.
- place stack at end of program window to avoid heap overlap - add dedicated call-args page above user window and remap TO/FROM/INPUT - centralize program window sizing in global and reuse in task module - rename current_root_ppn to current_task_root_ppn for clarity - expand kernel VA window and test VM memory defaults
- add kernel README with responsibilities, task lifecycle, and memory layout - include ASCII diagrams for task, trap, and memory flow - refresh top-level project structure and architecture overview
Add aTester crate with AVM runner, suite runner, and kernel test harness that builds kernel bins and prints VM logs. Wire kernel test ABI (input bytes + TestResults) with results struct and test utils init. Expose init_boot_info for test init path and add kernel_first_test bin. Add root Makefile kernel target and route run_examples through it. Include target spec fix and dependency updates in workspace and lockfile.
Extract program window mapping into a helper with clearer intent. Keep the first page RWX for result writes at 0x100, map remaining code pages RX, and map data/stack/heap RW. Add inline documentation explaining the mapping split and rationale.
Add new kernel test bins for map/heap/page allocator edge cases Cover multi-L2 mapping, mirror gaps, map_to_physical aliasing, and atomic copy_user Make copy_user preflight all pages and remap existing PTEs with new perms
Add machine/supervisor trap routing in CPU and use mode-aware vectors. Split sret from mret decoding and execution paths. Update ebreak handling to trap only in user mode and halt otherwise. Adjust spec runner to use Sv32 memory, map sections, and report tohost/ecall exits.
add aTester examples test harness with fixtures, bundles, and expected results pass kernel output bytes through RunResult for test-side decoding refactor kernel test evaluation to decode TestResults from output bytes move example integration tests out of crates/examples and clean its dev deps update run_examples make target and examples README to use aTester align kernel test results address with KERNEL_RESULT_ADDR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing