Skip to content

add support for a zisk guest program#32

Merged
gballet merged 5 commits intomainfrom
add-zisk
Jul 15, 2025
Merged

add support for a zisk guest program#32
gballet merged 5 commits intomainfrom
add-zisk

Conversation

@gballet
Copy link
Copy Markdown
Contributor

@gballet gballet commented Jun 27, 2025

No description provided.

@gballet gballet requested a review from Copilot June 27, 2025 17:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for a Zisk guest program by providing a RISC-V64 linker script, startup assembly, Zig runtime modules (lib, io, layout), and registering a new zisk target in the build system.

  • Defined memory regions and sections in zisk.ld for ROM/RAM layout
  • Implemented _start assembly stub to set up gp and sp, then call main
  • Added Zig modules for I/O (get_input, print_str), layout constants, and a halt runtime
  • Registered the zisk target in build.zig

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkgs/state-transition-runtime/src/zisk/zisk.ld Linker script for ROM/RAM memory regions and section layout
pkgs/state-transition-runtime/src/zisk/start.s Assembly entrypoint initializing registers and tail-calling main
pkgs/state-transition-runtime/src/zisk/lib.zig Runtime functions: halt and free_input
pkgs/state-transition-runtime/src/zisk/layout.zig Memory-mapped I/O address constants
pkgs/state-transition-runtime/src/zisk/io.zig get_input and print_str implementations for Zisk
build.zig Adds the zisk target configuration to the build script
Comments suppressed due to low confidence (1)

pkgs/state-transition-runtime/src/zisk/io.zig:6

  • These new I/O functions (get_input, print_str) don’t have tests yet; consider adding unit or integration tests to verify input-size parsing and UART write behavior.
pub fn get_input(_: std.mem.Allocator) []const u8 {

Comment on lines +5 to +21
pub fn halt(_: u32) noreturn {
const arch_id_zisk = asm volatile ("csrr %[ret], marchid"
: [ret] "=r" (-> usize),
);
if (arch_id_zisk == 0xFFFEEE) {
// Zisk exit
asm volatile (
\\ li a7, 93
\\ ecall
);
} else {
// QEMU exit
//"li t0, {_QEMU_EXIT_ADDR}",
//"li t1, {_QEMU_EXIT_CODE}",
asm volatile (
\\ li t0, 0x100000
\\ li t1, 0x5555
Copy link

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The halt function ignores its code parameter and uses a hardcoded exit code. Consider passing the code argument into the ecall (in a0) or the QEMU exit store instead of always using 0x5555.

Suggested change
pub fn halt(_: u32) noreturn {
const arch_id_zisk = asm volatile ("csrr %[ret], marchid"
: [ret] "=r" (-> usize),
);
if (arch_id_zisk == 0xFFFEEE) {
// Zisk exit
asm volatile (
\\ li a7, 93
\\ ecall
);
} else {
// QEMU exit
//"li t0, {_QEMU_EXIT_ADDR}",
//"li t1, {_QEMU_EXIT_CODE}",
asm volatile (
\\ li t0, 0x100000
\\ li t1, 0x5555
pub fn halt(code: u32) noreturn {
const arch_id_zisk = asm volatile ("csrr %[ret], marchid"
: [ret] "=r" (-> usize),
);
if (arch_id_zisk == 0xFFFEEE) {
// Zisk exit
asm volatile (
\\ mv a0, {code}
\\ li a7, 93
\\ ecall
);
} else {
// QEMU exit
asm volatile (
\\ li t0, 0x100000
\\ mv t1, {code}

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +21
\\ li t0, 0x100000
\\ li t1, 0x5555
Copy link

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extract the hardcoded exit-store address 0x100000 and exit code 0x5555 into named constants to clarify their intention in the QEMU path.

Suggested change
\\ li t0, 0x100000
\\ li t1, 0x5555
\\ li t0, QEMU_EXIT_ADDR
\\ li t1, QEMU_EXIT_CODE

Copilot uses AI. Check for mistakes.
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
gballet added 3 commits June 28, 2025 23:36
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
@gballet gballet marked this pull request as ready for review July 15, 2025 15:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gballet gballet merged commit d1bce1b into main Jul 15, 2025
4 checks passed
@g11tech g11tech deleted the add-zisk branch July 21, 2025 16:57
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.

2 participants