blfwk::MemoryStore Class Reference

Represents target device memory as a disk file. More...

`#include <SimulatorMemory.h>`

Inheritance diagram for blfwk::MemoryStore:
[legend]

## Public Types

enum | { kMapIndexFlash = 0, kMapIndexSRAM = 1 }
| Map indicies. More...

## Public Member Functions

| MemoryStore (int mapIndex, uint32_t fillByte=0)
| Constructor that takes a map index. More...
bool | open (const std::string &pathToDir, bool forceCreate)
| Open the store. More...
void | close ()
| Close the store.
size_t | read (long int offset, size_t size, unsigned char *buffer)
| Read from memory. More...
size_t | write (long int offset, size_t size, const unsigned char *buffer)
| Write to memory. More...
void | erase (long int offset, size_t size)
| Erase memory. More...
void | erase ()
| Erase all memory.

## Protected Attributes

int | m_mapIndex
| Index of memory map entry.
uint8_t | m_fillByte
| Erase value.
size_t | m_size
| Size of memory file.
uint32_t | m_startAddress
| Address address from map.
FILE * | m_memoryFile
| Handle to memory file.

## Detailed Description

Represents target device memory as a disk file.

## Member Enumeration Documentation

anonymous enum

Map indicies.

Enumerator
kMapIndexFlash | Flash memory.
kMapIndexSRAM | SRAM.

## Constructor & Destructor Documentation

blfwk::MemoryStore::MemoryStore | ( | int | mapIndex,
|  | uint32_t | fillByte = `0`
| ) |  |

inline

Constructor that takes a map index.

Parameters

  mapIndex | Index into memory map array
  fillByte | Optional byte erase value, default 0

## Member Function Documentation

void MemoryStore::erase | ( | long int | offset,
|  | size_t | size
| ) |  |

Erase memory.

The requested offset is adjusted by the store's start address to create a zero-based file offset.

Parameters

  offset | Offset into memory region
  size | Number of bytes to erase

bool MemoryStore::open | ( | const std::string & | pathToDir,
|  | bool | forceCreate
| ) |  |

Open the store.

Parameters

  pathToDir | Directory for memory backing file.
  forceCreate | True to re-create backing file even if it exists.

size_t MemoryStore::read | ( | long int | offset,
|  | size_t | size,
|  | unsigned char * | buffer
| ) |  |

Read from memory.

The requested offset is adjusted by the store's start address to create a zero-based file offset.

Parameters

  offset | Offset into memory region
  size | Number of bytes to read
  buffer | Destination buffer

Returns
  Number of bytes read

size_t MemoryStore::write | ( | long int | offset,
|  | size_t | size,
|  | const unsigned char * | buffer
| ) |  |

Write to memory.

The requested offset is adjusted by the store's start address to create a zero-based file offset.

Parameters

  offset | Offset into memory region
  size | Number of bytes to write
  buffer | Source buffer

Returns
  Number of bytes written

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

- SimulatorMemory.h
- SimulatorMemory.cpp