Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fesqvw committed Feb 21, 2024
1 parent 90cf4af commit 778d7ce
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions payloads/csr_id/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,21 @@ _start:
);

extern "C" fn entry() -> ! {
let csrs = [
"mvendorid",
"marchid",
"mimpid",
"mhartid"
];
let csrs = ["mvendorid", "marchid", "mimpid", "mhartid"];

for csr in csrs{
let(out_csr,expected) = test_csr_id(csr);
for csr in csrs {
let (out_csr, expected) = test_csr_id(csr);
read_test(out_csr, expected);
}


success();
panic!();
}

fn test_csr_id(csr_name : &str) -> (usize,usize){
fn test_csr_id(csr_name: &str) -> (usize, usize) {
let expected: usize = 0x0;
let res: usize;
let res: usize;

match csr_name {
"mvendorid" => unsafe {
asm!(
Expand All @@ -63,15 +57,15 @@ fn test_csr_id(csr_name : &str) -> (usize,usize){
out(reg) res
);
},
_ => res = 0x42,//TO FAIL BY DEFAULT IF NO VALID CSR REGISTER IS FOUND
_ => res = 0x42, //TO FAIL BY DEFAULT IF NO VALID CSR REGISTER IS FOUND
};

(res, expected)
}

fn read_test(out_csr: usize, expected: usize){
fn read_test(out_csr: usize, expected: usize) {
assert_eq!(out_csr, expected);
}
}

#[inline(always)]
fn success() {
Expand Down

0 comments on commit 778d7ce

Please sign in to comment.