srecord: srecord::memory Class Reference

srecord 1.65.0

Loading...
Searching...
No Matches
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.
| memory (const memory &)
| The copy constructor.
memory & | operator= (const memory &)
| The assignment operator.
| ~memory ()
| The destructor.
void | set (unsigned long address, int value)
| The set method is used to set the byte at the given ‘address’ to the given ‘value’.
int | get (unsigned long address) const
| The get method is used to fetch the value of the byte at the given 'address'.
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.
void | walk (memory_walker::pointer) const
| The walk method is used to apply a memory_walker derived class to every byte of memory.
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.
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.
record * | 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.
void | set_header (const std::string &value)
| The set_header method may be used to set the header command.
record * | 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.
void | set_execution_start_address (unsigned long value)
| The set_execution_start_address method may be used to set the execution start address record.
bool | has_holes (void) const
| The has_holes method may be used to determine whether or not the memory data has "holes" in it.
unsigned long | get_lower_bound () const
| The get_lower_bound method is used to obtain the lower bound (lowest address) of the memory image.
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.
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.
bool | empty (void) const
| The empty method is used to determine whether or not this memory image has no data in it.

## 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.
static bool | compare (const memory &, const memory &)
| The compare method may be used to determine if two memory instances are equal.

## 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.

Referenced by compare(), equal(), memory(), and operator=().

## ◆ memory() [2/2]

srecord::memory::memory | ( | const memory & |  | ) |

The copy constructor.

References memory().

## ◆ ~memory()

srecord::memory::~memory | ( |  | ) |

The destructor.

## Member Function Documentation

## ◆ operator=()

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

The assignment operator.

References memory().

## ◆ 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

  input | The source of the byte stream
  redundant_bytes | ignore: do nothing warning: issue a warning and continue (default) error: issuse a atal error message, and exit failure.
  contradictory_bytes | If 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()

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

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

References memory().

## ◆ compare()

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.

References memory().

## ◆ 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

  value | The ‘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

  multiple | The 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:

- memory.h