Skip to content

Commit

Permalink
Miscellaneous fixes to the Soc Manager API (chipsalliance#1804)
Browse files Browse the repository at this point in the history
- Add hw-1.0 feature switch for support of  hw-1.0 RTL.
- Validate length of slice passed as an argument.
  • Loading branch information
rusty1968 authored Nov 20, 2024
1 parent 9a1a9da commit 51bfb5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ caliptra-emu-types.workspace = true
caliptra-registers.workspace = true
caliptra-api-types.workspace = true
ureg.workspace = true

[features]
"hw-1.0" = ["caliptra-registers/hw-1.0"]
6 changes: 6 additions & 0 deletions api/src/soc_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use core::mem;
use ureg::MmioMut;
use zerocopy::{AsBytes, FromBytes};

pub const NUM_PAUSERS: usize = 5;

/// Implementation of the `SocManager` trait for a `RealSocManager`.
///
/// # Example
Expand Down Expand Up @@ -77,6 +79,10 @@ pub trait SocManager {

/// Set up valid PAUSERs for mailbox access.
fn setup_mailbox_users(&mut self, apb_pausers: &[u32]) -> Result<(), CaliptraApiError> {
if apb_pausers.len() > NUM_PAUSERS {
return Err(CaliptraApiError::UnableToSetPauser);
}

for (idx, apb_pauser) in apb_pausers.iter().enumerate() {
if self
.soc_ifc()
Expand Down

0 comments on commit 51bfb5c

Please sign in to comment.