Skip to content

Commit

Permalink
[nix] add -c_specialize arg for sail-riscv
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Oct 9, 2024
1 parent da681c2 commit 455aa2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions nix/pkgs/sail-riscv-c-model.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ stdenv.mkDerivation (finalAttr: {
'';

sailArgs = [
"-c_specialize"
"--strict-var"
"-dno_cast"
"-c_preserve"
Expand Down
21 changes: 19 additions & 2 deletions sail-riscv/sail-riscv-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ extern "C" {
fn ztick_platform(_: unit) -> unit;

pub(crate) static mut zxlen_val: mach_bits;
pub(crate) static mut zhtif_done: bool;
pub(crate) static mut zhtif_exit_code: mach_bits;
pub(crate) static mut have_exception: bool;

/* machine state */
Expand Down Expand Up @@ -95,3 +93,22 @@ extern "C" {

pub(crate) static mut zmisa: zMisa;
}

/// Initialize and setup internal register
pub unsafe fn preinit_sail_model() {
// setup rts: initialize sail runtime
// setup regs
model_init();
}

pub unsafe fn finalize_sail_model() {
model_fini();
}

pub unsafe fn init_sail_riscv_model() {
zinit_model(UNIT.try_into().expect("Invalid UNIT value"));
}

pub unsafe fn sail_step() {
zstep()
}

0 comments on commit 455aa2a

Please sign in to comment.