decompiler
1.0.0
|
Memory bank that overlays some other memory bank, using a "copy on write" behavior. More...
#include <memstate.hh>
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... | |
AddrSpace * | getSpace (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... | |
Private Attributes | |
MemoryBank * | underlie |
Underlying memory object. | |
map< uintb, uint1 * > | page |
Overlayed pages. | |
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... | |
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.
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.
spc | is the address space associated with the memory bank |
ws | is the number of bytes in the preferred wordsize (must be power of 2) |
ps | is the number of bytes in a page (must be power of 2) |
ul | is the underlying MemoryBank |
References underlie.
|
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.
addr | is the aligned offset of the word |
Implements MemoryBank.
References MemoryBank::constructValue(), MemoryBank::find(), MemoryBank::getPageSize(), MemoryBank::getSpace(), MemoryBank::getWordSize(), page, and underlie.
|
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.
addr | is the aligned offset of the page |
res | is the pointer to where retrieved bytes should be stored |
skip | is the offset into the page from where bytes should be retrieved |
size | is the number of bytes to retrieve |
Reimplemented from MemoryBank.
References MemoryBank::getPage(), page, and underlie.
|
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.
addr | is the aligned address of the word to be written |
val | is the value to be written at that word |
Implements MemoryBank.
References MemoryBank::getPage(), MemoryBank::getPageSize(), page, and underlie.
|
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.
addr | is the aligned offset of the page to write |
val | is a pointer to bytes to be written into the page |
skip | is the offset into the page where bytes should be written |
size | is the number of bytes to write |
Reimplemented from MemoryBank.
References MemoryBank::getPage(), MemoryBank::getPageSize(), page, and underlie.