Skip to content

Commit

Permalink
get driver details from bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli-Pinchover committed Jan 28, 2024
1 parent 9d9ec3c commit 220dd94
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
24 changes: 24 additions & 0 deletions src/driver_client/dclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ pub trait DriverPrimitive<T, P, I, O> {
/// The `result` method returns the output data from the driver primitive,
/// optionally with a specific parameter. If there is no output data available, it returns `None`.
fn result(&self, param: Option<usize>) -> Result<Option<O>>;

fn get_bin_type(&self) -> BinType {
let params = &self.loaded_binary_parameters();
let bin_id = params[0];
match bin_id {
0 => BinType::MSM,
1 => BinType::NTT,
3 => BinType::POSEIDON,
_ => BinType::NONE,
}
}

fn get_driver_details(&self) -> (BinType, u32) {
let params = &self.loaded_binary_parameters();
let bin_id = params[0];
let image_paramters = params[1];
let bin_id = match bin_id {
0 => BinType::MSM,
1 => BinType::NTT,
3 => BinType::POSEIDON,
_ => BinType::NONE,
};
(bin_id, image_paramters)
}
}

/// The [`DriverClient`] is described bunch of addreses on FPGA which called [`DriverConfig`] also
Expand Down
7 changes: 7 additions & 0 deletions src/driver_client/dclient_cfg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
pub enum CardType {
C1100,
}
#[derive(Debug, PartialEq, Eq)]
pub enum BinType {
MSM = 0,
NTT = 1,
POSEIDON = 3,
NONE,
}

/// The [`DriverConfig`] is a struct that defines a set of 64-bit unsigned integer (`u64`)
/// representing addreses memory space for different components of a FPGA.
Expand Down
24 changes: 11 additions & 13 deletions tests/integration_msm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use ingo_blaze::{driver_client::*, ingo_msm::*, utils::*, error::DriverClientError};
use ingo_blaze::{
driver_client::{dclient_cfg::BinType, *},
error::DriverClientError,
ingo_msm::*,
utils::*,
};
use num_traits::Pow;
use std::{
env,
fmt::Display,
io::Error,
thread::sleep,
time::{Duration, Instant}, io::Error,
time::{Duration, Instant},
};

pub mod msm;
Expand Down Expand Up @@ -425,21 +431,13 @@ fn msm_bls12_377_precompute_max_test() -> Result<(), Box<dyn std::error::Error>>

driver.driver_client.firewalls_status();

let params = driver.loaded_binary_parameters();
let bin_id = params[0];
if bin_id == 0 {
//Box::new<dyn Err("aaaa")>;
//return Err(Box::new("Oops"));
return Err(Box::new(DriverClientError::NotMsmBin));
//eprintln!("Error: Could not complete task")
//println!("NOT MSM binary loaded");
//std::process::exit(1);
if driver.get_bin_type() != BinType::MSM {
return Err(Box::new(DriverClientError::NotMsmBin));
}

let params = driver.loaded_binary_parameters();
let params_parce = MSMImageParametrs::parse_image_params(params[1]);

//let xxx= driver.get_api();

params_parce.debug_information();
log::info!("Checking MSM core is ready: ");
driver.is_msm_engine_ready()?;
Expand Down

0 comments on commit 220dd94

Please sign in to comment.