Skip to content

Commit

Permalink
cleanup field arithmetic routines to refer to local job primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnie committed Mar 11, 2024
1 parent e53c5e5 commit ebcc370
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions curve25519-dalek/src/backend/serial/u32e/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,22 @@ pub(crate) enum EngineOp {
#[allow(unused_qualifications)]
pub(crate) fn engine(a: &[u8; 32], b: &[u8; 32], op: EngineOp) -> Engine25519 {
use utralib::generated::*;
let mut engine = utralib::CSR::new(utra::engine::HW_ENGINE_BASE as *mut u32);
let mcode: &'static mut [u32] = unsafe{ core::slice::from_raw_parts_mut(utralib::HW_ENGINE_MEM as *mut u32, 1024) };
// allocate the first three registers
let rf: [&'static mut [u32]; 3] =
unsafe { [
core::slice::from_raw_parts_mut((utralib::HW_ENGINE_MEM + 0x1_0000 + 0 * 32) as *mut u32, 8),
core::slice::from_raw_parts_mut((utralib::HW_ENGINE_MEM + 0x1_0000 + 1 * 32) as *mut u32, 8),
core::slice::from_raw_parts_mut((utralib::HW_ENGINE_MEM + 0x1_0000 + 2 * 32) as *mut u32, 8),
] };
use crate::backend::serial::u32e::*;

crate::backend::serial::u32e::ensure_engine();
let mut engine = utralib::CSR::new(unsafe{ENGINE_BASE.unwrap()}.as_mut_ptr() as *mut u32);
let mcode: &'static mut [u32] = unsafe{
core::slice::from_raw_parts_mut(ENGINE_MEM.unwrap().as_mut_ptr() as *mut u32, 1024)
};
let rf: [&'static mut [u32]; 3] = [
unsafe{core::slice::from_raw_parts_mut(
(ENGINE_MEM.unwrap().as_mut_ptr() as usize + 0x1_0000 + 0 * 32) as *mut u32, 8)},
unsafe{core::slice::from_raw_parts_mut(
(ENGINE_MEM.unwrap().as_mut_ptr() as usize + 0x1_0000 + 1 * 32) as *mut u32, 8)},
unsafe{core::slice::from_raw_parts_mut(
(ENGINE_MEM.unwrap().as_mut_ptr() as usize + 0x1_0000 + 2 * 32) as *mut u32, 8)},
];

match op {
EngineOp::Mul => {
let prog = assemble_engine25519!(
Expand Down

0 comments on commit ebcc370

Please sign in to comment.