srecord  1.65.0
srecord::memory Class Reference

The srecord::memory class is used to simulate memory contents. More...

#include <memory.h>

Public Member Functions

 memory ()
 The default constructor. More...
 
 memory (const memory &)
 The copy constructor. More...
 
memoryoperator= (const memory &)
 The assignment operator. More...
 
 ~memory ()
 The destructor. More...
 
void set (unsigned long address, int value)
 The set method is used to set the byte at the given ‘address’ to the given ‘value’. More...
 
int get (unsigned long address) const
 The get method is used to fetch the value of the byte at the given 'address'. More...
 
bool set_p (unsigned long address) const
 The set_p method is used to determine whether the byte at the given address has been set() yet. More...
 
void walk (memory_walker::pointer) const
 The walk method is used to apply a memory_walker derived class to every byte of memory. More...
 
void reader (const input::pointer &input, defcon_t redundant_bytes, defcon_t contradictory_bytes)
 The reader method is used to read the given ‘input’ source into memory. More...
 
bool find_next_data (unsigned long &address, void *data, size_t &nbytes) const
 The find_next_data method may be used to locate data at or following the ‘address’ given. More...
 
recordget_header (void) const
 The get_header method is used to determine the value of the header record set by either the reader() or set_header() methods. More...
 
void set_header (const std::string &value)
 The set_header method may be used to set the header command. More...
 
recordget_execution_start_address (void) const
 The get_execution_start_address method is used to determine the value of the execution start address record set by either the reader() or set_execution_start_address() methods. More...
 
void set_execution_start_address (unsigned long value)
 The set_execution_start_address method may be used to set the execution start address record. More...
 
bool has_holes (void) const
 The has_holes method may be used to determine whether or not the memory data has "holes" in it. More...
 
unsigned long get_lower_bound () const
 The get_lower_bound method is used to obtain the lower bound (lowest address) of the memory image. More...
 
unsigned long get_upper_bound () const
 The get_upper_bound method is used to obtain the upper bound (maximum address plus one) of the memory image. More...
 
bool is_well_aligned (unsigned multiple) const
 The is_well_aligned method is used to test whether or not all of the data in the memory buffer is well aligned, on the given byte boundary. More...
 
bool empty (void) const
 The empty method is used to determine whether or not this memory image has no data in it. More...
 

Static Public Member Functions

static bool equal (const memory &, const memory &)
 The equal method may be used to determine if two memory instances are equal. More...
 
static bool compare (const memory &, const memory &)
 The compare method may be used to determine if two memory instances are equal. More...
 

Detailed Description

The srecord::memory class is used to simulate memory contents.

This allows staging of reord adta, and also validation of contents.

Definition at line 39 of file memory.h.

Constructor & Destructor Documentation

◆ memory() [1/2]

srecord::memory::memory ( )

The default constructor.

◆ memory() [2/2]

srecord::memory::memory ( const memory )

The copy constructor.

◆ ~memory()

srecord::memory::~memory ( )

The destructor.

Member Function Documentation

◆ operator=()

memory& srecord::memory::operator= ( const memory )

The assignment operator.

◆ set()

void srecord::memory::set ( unsigned long  address,
int  value 
)

The set method is used to set the byte at the given ‘address’ to the given ‘value’.

Uses the find() method to locate the chunk, and then calls the memory_chunk::set method, to set the byte within the chunk.

◆ get()

int srecord::memory::get ( unsigned long  address) const

The get method is used to fetch the value of the byte at the given 'address'.

If you fo a get on an address which has not been set() yet, the results are undefined.

Uses the find() method to locate the chunk, and then calls the memory_chunk::get method, to get the byte within the chunk.

◆ set_p()

bool srecord::memory::set_p ( unsigned long  address) const

The set_p method is used to determine whether the byte at the given address has been set() yet.

Returns true if already set, false if never been set.

Uses the find() method to locate the chunk, and then calls the memory_chunk::set_p method, to get the status of the byte within the chunk.

◆ walk()

void srecord::memory::walk ( memory_walker::pointer  ) const

The walk method is used to apply a memory_walker derived class to every byte of memory.

◆ reader()

void srecord::memory::reader ( const input::pointer input,
defcon_t  redundant_bytes,
defcon_t  contradictory_bytes 
)

The reader method is used to read the given ‘input’ source into memory.

This method may be called multiple times, for multiple input files.

If the input format supports headers, and the file has a header, the first header will be remembered, if set_header() was not called previously.

Parameters
inputThe source of the byte stream
redundant_bytesignore: do nothing warning: issue a warning and continue (default) error: issuse a atal error message, and exit failure.
contradictory_bytesIf the value at any address is set more than once, Thid argument controls what happeens. ignore: do nothing warning: issue a warning and continue (default) error: issuse a atal error message, and exit failure (default).

◆ equal()

static bool srecord::memory::equal ( const memory ,
const memory  
)
static

The equal method may be used to determine if two memory instances are equal.

◆ compare()

static bool srecord::memory::compare ( const memory ,
const memory  
)
static

The compare method may be used to determine if two memory instances are equal.

Verbose messages concerning the exact differences are printed if they are not equal.

◆ find_next_data()

bool srecord::memory::find_next_data ( unsigned long &  address,
void *  data,
size_t &  nbytes 
) const

The find_next_data method may be used to locate data at or following the ‘address’ given.

Returns false if there is no data meeting this criteria.

If there is data, the ‘address’ will be set to the start address of the data block. At most ‘nbytes’ of data will be transfetrred into the ‘data’ array. Then ‘nbytes’ wil be set to the number of bytes transferred. Returns true.

Calls the find_next_chunk() method.

◆ get_header()

record* srecord::memory::get_header ( void  ) const

The get_header method is used to determine the value of the header record set by either the reader() or set_header() methods.

If neither has set a header, a NULL is returned.

◆ set_header()

void srecord::memory::set_header ( const std::string &  value)

The set_header method may be used to set the header command.

Parameters
valueThe ‘value’ string, to set the header. The user may use URL encoding for of the more interesting non-printable byte values (eg. "%3F").

◆ get_execution_start_address()

record* srecord::memory::get_execution_start_address ( void  ) const

The get_execution_start_address method is used to determine the value of the execution start address record set by either the reader() or set_execution_start_address() methods.

If neither has set an execution start address, NULL is returned.

◆ set_execution_start_address()

void srecord::memory::set_execution_start_address ( unsigned long  value)

The set_execution_start_address method may be used to set the execution start address record.

◆ has_holes()

bool srecord::memory::has_holes ( void  ) const

The has_holes method may be used to determine whether or not the memory data has "holes" in it.

Returns
true if the memory data is not continuous (has at least one hole), false if the memory data is continuous (has no holes).

◆ get_lower_bound()

unsigned long srecord::memory::get_lower_bound ( ) const

The get_lower_bound method is used to obtain the lower bound (lowest address) of the memory image.

◆ get_upper_bound()

unsigned long srecord::memory::get_upper_bound ( ) const

The get_upper_bound method is used to obtain the upper bound (maximum address plus one) of the memory image.

◆ is_well_aligned()

bool srecord::memory::is_well_aligned ( unsigned  multiple) const

The is_well_aligned method is used to test whether or not all of the data in the memory buffer is well aligned, on the given byte boundary.

Parameters
multipleThe desired byte alignment.
Note
This isn't about holes, it's about the beginnings and endings of each consecitice run of bytes.

◆ empty()

bool srecord::memory::empty ( void  ) const
inline

The empty method is used to determine whether or not this memory image has no data in it.

Definition at line 228 of file memory.h.


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