SplitState, //
};
+use pin_init::pin_init_scope;
+
use crate::{
driver::Bar0,
gsp::{
/// Inner mutex-protected state.
#[pin]
inner: Mutex<CmdqInner>,
+ /// DMA handle of the command queue's shared memory region.
+ pub(super) dma_handle: DmaAddress,
}
impl Cmdq {
/// Creates a new command queue for `dev`.
pub(crate) fn new(dev: &device::Device<device::Bound>) -> impl PinInit<Self, Error> + '_ {
- try_pin_init!(Self {
- inner <- new_mutex!(CmdqInner {
- dev: dev.into(),
- gsp_mem: DmaGspMem::new(dev)?,
- seq: 0,
- }),
+ pin_init_scope(move || {
+ let gsp_mem = DmaGspMem::new(dev)?;
+
+ Ok(try_pin_init!(Self {
+ dma_handle: gsp_mem.0.dma_handle(),
+ inner <- new_mutex!(CmdqInner {
+ dev: dev.into(),
+ gsp_mem,
+ seq: 0,
+ }),
+ }))
})
}
{
self.inner.lock().receive_msg(timeout)
}
-
- /// Returns the DMA handle of the command queue's shared memory region.
- pub(crate) fn dma_handle(&self) -> DmaAddress {
- self.inner.lock().gsp_mem.0.dma_handle()
- }
}
/// Inner mutex protected state of [`Cmdq`].
#[allow(non_snake_case)]
fn new(cmdq: &Cmdq) -> impl Init<Self> + '_ {
init!(MessageQueueInitArguments {
- sharedMemPhysAddr: cmdq.dma_handle(),
+ sharedMemPhysAddr: cmdq.dma_handle,
pageTableEntryCount: num::usize_into_u32::<{ Cmdq::NUM_PTES }>(),
cmdQueueOffset: num::usize_as_u64(Cmdq::CMDQ_OFFSET),
statQueueOffset: num::usize_as_u64(Cmdq::STATQ_OFFSET),