Firmware Class Reference

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

#include <sim_firmware.h>

Classes

struct  block_view_t
 
struct  Symbol
 

Public Types

enum  Area {
  Area_Flash , Area_Data , Area_EEPROM , Area_Fuses ,
  Area_Lock , Area_Signature , Area_UserSignatures
}
 

Public Member Functions

 Firmware ()
 
 Firmware (const Firmware &other)=default
 
void add_block (Area area, const block_view_t &block)
 
bool has_memory (Area area) const
 
std::vector< Areamemories () const
 
size_t memory_size (Area area) const
 
std::vector< block_view_tblocks (Area area) const
 
bool load_memory (Area area, NonVolatileMemory &memory) const
 
mem_addr_t datasize () const
 
mem_addr_t bsssize () const
 
void add_symbol (const Symbol &s)
 
const std::vector< Symbol > & symbols () const
 
Firmwareoperator= (const Firmware &other)=default
 

Static Public Member Functions

static Firmwareread_elf (const std::string &filename)
 

Public Attributes

unsigned long frequency
 Main clock frequency in hertz, mandatory to run the simulation.
 
double vcc
 Power supply voltage in volts. If not set, analog peripherals such as ADC are not usable.
 
double aref
 Analog reference voltage in volts.
 
reg_addr_t console_register
 I/O register address used for console output.
 

Detailed Description

Firmware contains the information of a firmware loaded from a ELF file. A firmware consists of blocks of binary data that can be loaded into the various non-volatile memory areas of a MCU. Each memory area can have several blocks of data (e.g. flash has .text, .rodata, ...) placed at different addresses, not necessarily contiguous. The currently supported memory areas :

area name ELF section(s) LMA origin
Flash .text, .data, .rodata 0x000000
EEPROM .eeprom 0x810000
Fuses .fuse 0x820000
Lock .lock 0x830000
Signature .signature 0x840000
UserSignatures .user_signatures 0x850000
Note
The area in which a section is loaded depends on the LMA, not the section name.

Member Enumeration Documentation

◆ Area

Enumerator
Area_Flash 
Area_Data 
Area_EEPROM 
Area_Fuses 
Area_Lock 
Area_Signature 
Area_UserSignatures 

Constructor & Destructor Documentation

◆ Firmware() [1/2]

YASIMAVR_USING_NAMESPACE Firmware::Firmware ( )

Build an empty firmware

◆ Firmware() [2/2]

Firmware::Firmware ( const Firmware other)
default

Member Function Documentation

◆ add_block()

void Firmware::add_block ( Area  area,
const block_view_t block 
)

Add a binary block to the firmware

Parameters
areaNVM area to which the block should be added
blockbinary data block to be added
Note
A deep copy of the binary data is made

◆ add_symbol()

void Firmware::add_symbol ( const Symbol s)

◆ blocks()

std::vector< Firmware::block_view_t > Firmware::blocks ( Area  area) const

Get the binary blocks loaded for a given NVM area.

Parameters
areaNVM area to check
Returns
the binary data blocks loaded for this area, may be empty.

◆ bsssize()

mem_addr_t Firmware::bsssize ( ) const
inline

◆ datasize()

mem_addr_t Firmware::datasize ( ) const
inline

◆ has_memory()

bool Firmware::has_memory ( Area  area) const

Get whether the firmware has binary data for a given NVM area.

Parameters
areaNVM area to check
Returns
true if the NVM area has data, false otherwise

◆ load_memory()

bool Firmware::load_memory ( Area  area,
NonVolatileMemory memory 
) const

Copy the binary blocks loaded for a given NVM area into a NVM model.

Parameters
areaNVM area to retrieve
memoryNVM model where the data should be copied
Returns
true if the binary data could be copied, false if it failed

◆ memories()

std::vector< Firmware::Area > Firmware::memories ( ) const

Return the list of NVM areas for which the firmware has binary data.

◆ memory_size()

size_t Firmware::memory_size ( Area  area) const

Get the total size of binary data loaded for a given NVM area.

Parameters
areaNVM area to check
Returns
the total size of data in bytes

◆ operator=()

Firmware & Firmware::operator= ( const Firmware other)
default

◆ read_elf()

Firmware * Firmware::read_elf ( const std::string &  filename)
static

Read a ELF file and build a firmware, using the section binary blocks from the file. The ELF format decoding relies on the library libelf.

Parameters
filenamefile path of the ELF file to read

◆ symbols()

const std::vector< Firmware::Symbol > & Firmware::symbols ( ) const
inline

Member Data Documentation

◆ aref

double Firmware::aref

Analog reference voltage in volts.

◆ console_register

reg_addr_t Firmware::console_register

I/O register address used for console output.

◆ frequency

unsigned long Firmware::frequency

Main clock frequency in hertz, mandatory to run the simulation.

◆ vcc

double Firmware::vcc

Power supply voltage in volts. If not set, analog peripherals such as ADC are not usable.


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