Struct FlashCtrl

Source
pub struct FlashCtrl<'a> { /* private fields */ }

Implementations§

Source§

impl FlashCtrl<'_>

Source

pub fn new(base: StaticRef<FlashCtrlRegisters>, region_num: FlashRegion) -> Self

Source

pub fn reset_fifos(&self)

Reset the internal FIFOs, used for when recovering from errors.

Source

pub fn handle_interrupt(&self)

Source

pub fn mp_set_region_perms( &self, start_addr: usize, end_addr: usize, region_num: usize, mp_perms: &FlashMPConfig, ) -> Result<(), ErrorCode>

Setup the specified flash memory protection configuration

Returns Ok(()) on successfully applying the requested configuration Returns [NOSUPPORT](ErrorCode::NOSUPPORT) if address space is not supported, or the region_num does not exist

§Arguments
  • start_addr - Starting address that bounds the start of this region. Note: This is the absolute address, i.e FLASH_ADDR_OFFSET and onwards
  • end_addr - End address that bounds the end of this region Note: This is the absolute address, i.e FLASH_ADDR_OFFSET and onwards
  • region_num - The configuration region number associated with this region. This associates the specified permissions to a configuration region, the number of simultaneous configs supported should be requested by mp_get_num_regions()
  • mp_perms - Specifies the permissions to set
§Examples

Usage:

peripherals
    .flash_ctrl
    .mp_set_region_perms(0x0, text_end_addr as usize, 5, &mp_cfg)

The snippet reads as: Allow access controls as specified by mp_cfg, for the address space bounded by start_addr=0x0 to end_addr=text_end_addr and associate this cfg to region_num=5.

If a user would want to modify this region (assuming it wasn’t locked), you can index into it with the associated region_num, in this case 5.

Source

pub fn mp_read_region_perms( &self, region_num: usize, ) -> Result<FlashMPConfig, ErrorCode>

Read the flash memory protection configuration bounded by the specified region

Returns [FlashMPConfig](lowrisc::flash_ctrl::FlashMPConfig) on success, with the permissions specified by this region Returns [NOSUPPORT](ErrorCode::NOSUPPORT) if the region_num does not exist

§Arguments
  • region_num - The configuration region number associated with this region. This associates the specified permissions to a configuration region.
Source

pub fn mp_get_num_regions(&self) -> Result<u32, ErrorCode>

Get the number of configuration regions supported by this hardware

Returns Ok(FLASH_MP_MAX_CFGS) where FLASH_MP_MAX_CFGS is the number of cfg regions supported

Note: Indexing starts with 0, this returns the total number of configuration registers.

Source

pub fn mp_is_region_locked(&self, region_num: usize) -> Result<bool, ErrorCode>

Check if the specified region_num is locked by hardware

Returns Ok(bool) on success, if true the region is locked till next reset, if false, it is unlocked. Returns [NOSUPPORT](ErrorCode::NOSUPPORT) if the region_num does not exist

§Arguments
  • region_num - The configuration region number associated with this region. This associates the specified permissions to a configuration region.
Source

pub fn mp_lock_region_cfg(&self, region_num: usize) -> Result<(), ErrorCode>

Lock the configuration Locks the config bounded by region_num such that no further modifications can be made until the next system reset.

Returns [NOSUPPORT](ErrorCode::NOSUPPORT) if the region_num does not exist Returns [ALREADY](ErrorCode::ALREADY) if the region_num region is already locked Returns Ok(()) on successfully locking the region

§Arguments
  • region_num - The configuration region number associated with this region. This associates the specified permissions to a configuration region.

Trait Implementations§

Source§

impl Flash for FlashCtrl<'_>

Source§

fn read_page( &self, page_number: usize, buf: &'static mut Self::Page, ) -> Result<(), (ErrorCode, &'static mut Self::Page)>

The flash controller will truncate to the closest, lower word aligned address. For example, if 0x13 is supplied, the controller will perform a read at address 0x10.

Source§

fn write_page( &self, page_number: usize, buf: &'static mut Self::Page, ) -> Result<(), (ErrorCode, &'static mut Self::Page)>

The flash controller will truncate to the closest, lower word aligned address. For example, if 0x13 is supplied, the controller will perform a write at address 0x10. the controller does not have read modified write support.

Source§

fn erase_page(&self, page_number: usize) -> Result<(), ErrorCode>

The controller will truncate to the closest lower page aligned address. Similarly for bank erases, the controller will truncate to the closest lower bank aligned address.

Source§

type Page = LowRiscPage

Type of a single flash page for the given implementation.
Source§

impl<C: Client<Self>> HasClient<'static, C> for FlashCtrl<'_>

Source§

fn set_client(&self, client: &'static C)

Set the client for this flash peripheral. The client will be called when operations complete.

Auto Trait Implementations§

§

impl<'a> !Freeze for FlashCtrl<'a>

§

impl<'a> !RefUnwindSafe for FlashCtrl<'a>

§

impl<'a> !Send for FlashCtrl<'a>

§

impl<'a> !Sync for FlashCtrl<'a>

§

impl<'a> Unpin for FlashCtrl<'a>

§

impl<'a> !UnwindSafe for FlashCtrl<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.