Skip to content

Commit 8067c6f

Browse files
committed
Use okref for mailbox packet struct
Sometimes when results are unwrapped, the compiler will memcopy the Ok struct. okref will instead borrow the inner type. Using this on the packet struct saves about 4KiB of stack space.
1 parent 85b732a commit 8067c6f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

runtime/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use tagging::{GetTaggedTciCmd, TagTciCmd};
7373

7474
use caliptra_common::cprintln;
7575

76-
use caliptra_drivers::{CaliptraError, CaliptraResult, ResetReason};
76+
use caliptra_drivers::{okmutref, CaliptraError, CaliptraResult, ResetReason};
7777
use caliptra_registers::el2_pic_ctrl::El2PicCtrl;
7878
use caliptra_registers::{mbox::enums::MboxStatusE, soc_ifc};
7979
use dpe::{
@@ -230,10 +230,11 @@ fn handle_command(drivers: &mut Drivers) -> CaliptraResult<MboxStatusE> {
230230
CommandId::AUTHORIZE_AND_STASH => AuthorizeAndStashCmd::execute(drivers, cmd_bytes),
231231
CommandId::GET_IDEV_CSR => GetIdevCsrCmd::execute(drivers, cmd_bytes),
232232
_ => Err(CaliptraError::RUNTIME_UNIMPLEMENTED_COMMAND),
233-
}?;
233+
};
234+
let resp = okmutref(&mut resp)?;
234235

235236
// Send the response
236-
Packet::copy_to_mbox(drivers, &mut resp)?;
237+
Packet::copy_to_mbox(drivers, resp)?;
237238

238239
Ok(MboxStatusE::DataReady)
239240
}

0 commit comments

Comments
 (0)