zisk-asm-runner 1.1.0-alpha

Runtime for managing the ZisK assembly emulator process and its shared-memory I/O
use crate::asm_services::CMD_RH_RESPONSE_ID;

use super::{FromResponsePayload, RequestData, ResponseData, ToRequestPayload, CMD_RH_REQUEST_ID};

pub(crate) struct RomHistogramRequest {
    pub max_steps: u64,
}

impl ToRequestPayload for RomHistogramRequest {
    fn to_request_payload(&self) -> RequestData {
        [CMD_RH_REQUEST_ID, self.max_steps, 0, 0, 0]
    }
}

// Fields mirror the on-wire ROM histogram response; these document the protocol layout.
#[allow(dead_code)]
pub(crate) struct RomHistogramResponse {
    pub result: u8,
    pub allocated_len: u64,
    pub trace_len: u64,
    pub last_step: u64,
}

impl FromResponsePayload for RomHistogramResponse {
    fn from_response_payload(payload: ResponseData) -> Self {
        assert!(payload[0] == CMD_RH_RESPONSE_ID,);
        RomHistogramResponse {
            result: payload[1] as u8,
            allocated_len: payload[2],
            trace_len: payload[3],
            last_step: payload[4],
        }
    }
}