Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse controller reg #1984

Open
wants to merge 4 commits into
base: main-2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
[submodule "hw/latest/i3c-core-rtl"]
path = hw/latest/i3c-core-rtl
url = https://github.com/chipsalliance/i3c-core.git
[submodule "hw/latest/caliptra-ss"]
path = hw/latest/caliptra-ss
url = https://github.com/chipsalliance/caliptra-ss.git
53 changes: 53 additions & 0 deletions drivers/src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use caliptra_registers::axi_dma::{
enums::{RdRouteE, WrRouteE},
AxiDmaReg, RegisterBlock,
};
use caliptra_registers::caliptra_otp_ctrl::RegisterBlock as FuseCtrlRegisterBlock;
use caliptra_registers::i3ccsr::RegisterBlock as I3CRegisterBlock;
use core::{cell::Cell, mem::size_of, ops::Add};
use ureg::{Mmio, MmioMut, RealMmioMut};
Expand Down Expand Up @@ -612,3 +613,55 @@ impl<'a> DmaRecovery<'a> {
});
}
}

pub struct DmaOtpCtrl<'a> {
base: AxiAddr,
dma: &'a Dma,
}

impl<'a> DmaOtpCtrl<'a> {
#[inline(always)]
pub fn new(base: AxiAddr, dma: &'a Dma) -> Self {
Self { base, dma }
}

/// Returns a register block that can be used to read
/// registers from this peripheral, but cannot write.
#[inline(always)]
pub fn with_regs<T, F>(&self, f: F) -> CaliptraResult<T>
where
F: FnOnce(FuseCtrlRegisterBlock<&DmaMmio>) -> T,
{
let mmio = DmaMmio::new(self.base, self.dma);
// SAFETY: we aren't referencing memory directly
let regs = unsafe {
FuseCtrlRegisterBlock::new_with_mmio(
// substract the recovery offset since all recovery registers are relative to it
core::ptr::null_mut::<u32>(),
&mmio,
)
};
let t = f(regs);
mmio.check_error(t)
}

/// Return a register block that can be used to read and
/// write this peripheral's registers.
#[inline(always)]
pub fn with_regs_mut<T, F>(&self, f: F) -> CaliptraResult<T>
where
F: FnOnce(FuseCtrlRegisterBlock<&DmaMmio>) -> T,
{
let mmio = DmaMmio::new(self.base, self.dma);
// SAFETY: we aren't referencing memory directly
let regs = unsafe {
FuseCtrlRegisterBlock::new_with_mmio(
// substract the recovery offset since all recovery registers are relative to it
core::ptr::null_mut::<u32>(),
&mmio,
)
};
let t = f(regs);
mmio.check_error(t)
}
}
2 changes: 1 addition & 1 deletion drivers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub use caliptra_error::{CaliptraError, CaliptraResult};
pub use csrng::{Csrng, HealthFailCounts as CsrngHealthFailCounts, Seed as CsrngSeed};
pub use data_vault::{ColdResetEntries, DataVault, WarmResetEntries};
pub use dma::{
AxiAddr, Dma, DmaReadTarget, DmaReadTransaction, DmaRecovery, DmaWriteOrigin,
AxiAddr, Dma, DmaOtpCtrl, DmaReadTarget, DmaReadTransaction, DmaRecovery, DmaWriteOrigin,
DmaWriteTransaction,
};
pub use doe::DeobfuscationEngine;
Expand Down
1 change: 1 addition & 0 deletions hw/latest/caliptra-ss
Submodule caliptra-ss added at 976164
Loading
Loading