Ghidra Decompiler Analysis Engine
Public Member Functions | Protected Member Functions | List of all members
MemoryPageOverlay Class Reference

Memory bank that overlays some other memory bank, using a "copy on write" behavior. More...

#include <memstate.hh>

Inheritance diagram for MemoryPageOverlay:
Inheritance graph
[legend]
Collaboration diagram for MemoryPageOverlay:
Collaboration graph
[legend]

Public Member Functions

 MemoryPageOverlay (AddrSpace *spc, int4 ws, int4 ps, MemoryBank *ul)
 Constructor for page overlay. More...
 
- Public Member Functions inherited from MemoryBank
 MemoryBank (AddrSpace *spc, int4 ws, int4 ps)
 Generic constructor for a memory bank. More...
 
int4 getWordSize (void) const
 Get the number of bytes in a word for this memory bank. More...
 
int4 getPageSize (void) const
 Get the number of bytes in a page for this memory bank. More...
 
AddrSpacegetSpace (void) const
 Get the address space associated with this memory bank. More...
 
void setValue (uintb offset, int4 size, uintb val)
 Set the value of a (small) range of bytes. More...
 
uintb getValue (uintb offset, int4 size) const
 Retrieve the value encoded in a (small) range of bytes. More...
 
void setChunk (uintb offset, int4 size, const uint1 *val)
 Set values of an arbitrary sequence of bytes. More...
 
void getChunk (uintb offset, int4 size, uint1 *res) const
 Retrieve an arbitrary sequence of bytes. More...
 

Protected Member Functions

virtual void insert (uintb addr, uintb val)
 Overridden aligned word insert. More...
 
virtual uintb find (uintb addr) const
 Overridden aligned word find. More...
 
virtual void getPage (uintb addr, uint1 *res, int4 skip, int4 size) const
 Overridden getPage. More...
 
virtual void setPage (uintb addr, const uint1 *val, int4 skip, int4 size)
 Overridden setPage. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MemoryBank
static uintb constructValue (const uint1 *ptr, int4 size, bool bigendian)
 Decode bytes to value. More...
 
static void deconstructValue (uint1 *ptr, uintb val, int4 size, bool bigendian)
 Encode value to bytes. More...
 

Detailed Description

Memory bank that overlays some other memory bank, using a "copy on write" behavior.

Pages are copied from the underlying object only when there is a write. The underlying access routines are overridden to make optimal use of this page implementation. The underlying memory bank can be a null pointer in which case, this memory bank behaves as if it were initially filled with zeros.

Constructor & Destructor Documentation

◆ MemoryPageOverlay()

MemoryPageOverlay::MemoryPageOverlay ( AddrSpace spc,
int4  ws,
int4  ps,
MemoryBank ul 
)

Constructor for page overlay.

A page overlay memory bank needs all the parameters for a generic memory bank and it needs to know the underlying memory bank being overlayed.

Parameters
spcis the address space associated with the memory bank
wsis the number of bytes in the preferred wordsize (must be power of 2)
psis the number of bytes in a page (must be power of 2)
ulis the underlying MemoryBank

Member Function Documentation

◆ find()

uintb MemoryPageOverlay::find ( uintb  addr) const
protectedvirtual

Overridden aligned word find.

This derived method first looks for the aligned word in the mapped pages. If the address is not mapped, the search is forwarded to the underlying memory bank. If there is no underlying bank, zero is returned.

Parameters
addris the aligned offset of the word
Returns
the retrieved value

Implements MemoryBank.

◆ getPage()

void MemoryPageOverlay::getPage ( uintb  addr,
uint1 *  res,
int4  skip,
int4  size 
) const
protectedvirtual

Overridden getPage.

The desired page is looked for in the page cache. If it doesn't exist, the request is forwarded to underlying bank. If there is no underlying bank, the result buffer is filled with zeros.

Parameters
addris the aligned offset of the page
resis the pointer to where retrieved bytes should be stored
skipis the offset into the page from where bytes should be retrieved
sizeis the number of bytes to retrieve

Reimplemented from MemoryBank.

◆ insert()

void MemoryPageOverlay::insert ( uintb  addr,
uintb  val 
)
protectedvirtual

Overridden aligned word insert.

This derived method looks for a previously cached page of the underlying memory bank. If the cached page does not exist, it creates it and fills in its initial value by retrieving the page from the underlying bank. The new value is then written into cached page.

Parameters
addris the aligned address of the word to be written
valis the value to be written at that word

Implements MemoryBank.

◆ setPage()

void MemoryPageOverlay::setPage ( uintb  addr,
const uint1 *  val,
int4  skip,
int4  size 
)
protectedvirtual

Overridden setPage.

First, a cached version of the desired page is searched for via its address. If it doesn't exist, it is created, and its initial value is filled via the underlying bank. The bytes to be written are then copied into the cached page.

Parameters
addris the aligned offset of the page to write
valis a pointer to bytes to be written into the page
skipis the offset into the page where bytes should be written
sizeis the number of bytes to write

Reimplemented from MemoryBank.


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