MemorySectionManager Class Reference

yasimavr: MemorySectionManager Class Reference
yasimavr
Loading...
Searching...
No Matches
MemorySectionManager Class Reference

Memory section management. More...

#include <sim_memory.h>

Public Types

enum  AccessFlag { Access_Read = 0x01 , Access_Write = 0x02 }
 Generic Read/Write access flags. More...
 
enum  SignalId { Signal_Leave , Signal_Enter }
 SignalID raised by the section manager. More...
 

Public Member Functions

 MemorySectionManager (flash_addr_t page_count, flash_addr_t page_size, unsigned int section_count)
 
flash_addr_t page_count () const
 Getter for the page count. (as given to the constructor)
 
flash_addr_t page_size () const
 Getter for the page size in bytes. (as given to the constructor)
 
unsigned int section_count () const
 Getter for the number of sections.
 
unsigned int current_section () const
 Return the section containing the current address.
 
void set_section_limits (const std::vector< flash_addr_t > &limits)
 
flash_addr_t section_start (unsigned int section) const
 Return the section start address.
 
flash_addr_t section_end (unsigned int section) const
 Return the section end address.
 
flash_addr_t section_size (unsigned int section) const
 Return the size in bytes of a section.
 
unsigned int page_to_section (flash_addr_t page) const
 
unsigned int address_to_section (flash_addr_t addr) const
 Return the section index containing the given memory address.
 
void set_access_flags (unsigned int src, unsigned int dst, uint8_t flags)
 
void set_access_flags (unsigned int section, uint8_t flags)
 
uint8_t access_flags (unsigned int section_src, unsigned int section_dst) const
 
uint8_t access_flags (unsigned int section) const
 Return the access flags currently set from one section to itself.
 
bool can_read (flash_addr_t addr) const
 Return the read access flag for a given address.
 
bool can_write (flash_addr_t addr) const
 Return the write access flag for a given address.
 
uint8_t address_access_flags (flash_addr_t addr) const
 Return the access flags for a given address.
 
void set_fetch_allowed (unsigned int section, bool allowed)
 
bool fetch_address (flash_addr_t addr)
 
Signalsignal ()
 Getter for the signal of the section manager.
 

Detailed Description

Memory section management.

Manages a memory page range by dividing it in sections, allowing to set access control flags from one section to another. Sections are identified by an index and always cover the whole page range. Section limits are set by set_section_limits() and take an array of N-1 values, where N is the number of sections. For example, with N=3, and 100 pages, limits = { 16; 32 } will configure the sections limits as : Section 0 = [0; 15], Section 1 = [16; 31], Section 2 = [32; 99]

Member Enumeration Documentation

◆ AccessFlag

Generic Read/Write access flags.

Enumerator
Access_Read 
Access_Write 

◆ SignalId

SignalID raised by the section manager.

Enumerator
Signal_Leave 

Raised when the current address leaves a section. data is set to the section index (integer)

Signal_Enter 

Raised when the current address enters a section. data is set to the section index (integer)

Constructor & Destructor Documentation

◆ MemorySectionManager()

MemorySectionManager::MemorySectionManager ( flash_addr_t  page_count,
flash_addr_t  page_size,
unsigned int  section_count 
)

Construct a section manager.

Parameters
page_countnumber of pages covering the whole memory area
page_sizepage size in bytes
section_countnumber of sections

Member Function Documentation

◆ access_flags() [1/2]

uint8_t MemorySectionManager::access_flags ( unsigned int  section) const
inline

Return the access flags currently set from one section to itself.

◆ access_flags() [2/2]

uint8_t MemorySectionManager::access_flags ( unsigned int  section_src,
unsigned int  section_dst 
) const
inline

Return the access flags currently set containing the given memory address.

Parameters
section_src: Section source
sectiondst: Section destination

◆ address_access_flags()

uint8_t MemorySectionManager::address_access_flags ( flash_addr_t  addr) const
inline

Return the access flags for a given address.

◆ address_to_section()

unsigned int MemorySectionManager::address_to_section ( flash_addr_t  addr) const
inline

Return the section index containing the given memory address.

◆ can_read()

bool MemorySectionManager::can_read ( flash_addr_t  addr) const
inline

Return the read access flag for a given address.

◆ can_write()

bool MemorySectionManager::can_write ( flash_addr_t  addr) const
inline

Return the write access flag for a given address.

◆ current_section()

unsigned int MemorySectionManager::current_section ( ) const
inline

Return the section containing the current address.

◆ fetch_address()

bool MemorySectionManager::fetch_address ( flash_addr_t  addr)

Change the current address and return the fetch access flag for the containing section.

◆ page_count()

flash_addr_t MemorySectionManager::page_count ( ) const
inline

Getter for the page count. (as given to the constructor)

◆ page_size()

flash_addr_t MemorySectionManager::page_size ( ) const
inline

Getter for the page size in bytes. (as given to the constructor)

◆ page_to_section()

unsigned int MemorySectionManager::page_to_section ( flash_addr_t  page) const

Return the section index containing the given page number.

◆ section_count()

unsigned int MemorySectionManager::section_count ( ) const
inline

Getter for the number of sections.

◆ section_end()

flash_addr_t MemorySectionManager::section_end ( unsigned int  section) const
inline

Return the section end address.

◆ section_size()

flash_addr_t MemorySectionManager::section_size ( unsigned int  section) const
inline

Return the size in bytes of a section.

◆ section_start()

flash_addr_t MemorySectionManager::section_start ( unsigned int  section) const
inline

Return the section start address.

◆ set_access_flags() [1/2]

void MemorySectionManager::set_access_flags ( unsigned int  section,
uint8_t  flags 
)

Set the access flags from one section to itself.

◆ set_access_flags() [2/2]

void MemorySectionManager::set_access_flags ( unsigned int  src,
unsigned int  dst,
uint8_t  flags 
)

Set the access flags from one section to another.

Example: set_access_flags(0, 1, Read) means that code in section 0 can read but cannot write data located in section 1.

Parameters
src: Section source
dst: Section destination
flags: OR'ed combination of access flags

◆ set_fetch_allowed()

void MemorySectionManager::set_fetch_allowed ( unsigned int  section,
bool  allowed 
)

Set the fetch flag for a section.

◆ set_section_limits()

void MemorySectionManager::set_section_limits ( const std::vector< flash_addr_t > &  limits)

Set the section limits in page number. Limits must be given as an array and must be organised as : [ L0, L1, ..., Ln-2] where Li is the 1st page of section i+1 and n the number of sections. For example, with 3 sections, limits = { 16, 32 } will set Section 0 as range [0;15], Section 1 as [16;31] and Section 2 as [32;end].

◆ signal()

Signal & MemorySectionManager::signal ( )
inline

Getter for the signal of the section manager.


The documentation for this class was generated from the following files: