Skip to content

Commit

Permalink
feat: forward application exit status
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Sep 22, 2023
1 parent cb6f039 commit 02be7e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cartesi-machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,12 @@ local function check_rollup_htif_config(htif)
assert(htif.yield_automatic, "yield automatic must be enabled for rollup")
end

local function get_halt(machine)
local cmd = machine:read_htif_tohost_cmd()
local data = machine:read_htif_tohost_data() >> 1 -- lsb is always 1
return cmd, data
end

local function get_yield(machine)
local cmd = machine:read_htif_tohost_cmd()
local data = machine:read_htif_tohost_data()
Expand Down Expand Up @@ -1698,7 +1704,8 @@ else
cycles = machine:read_mcycle()
-- deal with halt
if machine:read_iflags_H() then
exit_code = machine:read_htif_tohost_data() >> 1
local _, data = get_halt(machine)
exit_code = data
if exit_code ~= 0 then
stderr("\nHalted with payload: %u\n", exit_code)
else
Expand Down

0 comments on commit 02be7e9

Please sign in to comment.