Package ghidra.app.emulator.memory
Class MemoryImage
java.lang.Object
ghidra.pcode.memstate.MemoryBank
ghidra.app.emulator.memory.MemoryImage
A kind of MemoryBank which retrieves its data from an underlying LoadImage
Any bytes requested on the bank which lie in the LoadImage are retrieved from the LoadImage. Other addresses in the space are filled in with zero. This bank cannot be written to.
-
Field Summary
Fields inherited from class ghidra.pcode.memstate.MemoryBank
faultHandler
-
Constructor Summary
ConstructorsConstructorDescriptionMemoryImage
(AddressSpace spc, boolean isBigEndian, int ps, MemoryLoadImage ld, MemoryFaultHandler faultHandler) A MemoryImage needs everything a basic memory bank needs and is needs to know the underlying LoadImage object to forward read requests to. -
Method Summary
Modifier and TypeMethodDescriptiongetPage
(long addr) Retrieve an aligned page from the bank.protected void
setPage
(long addr, byte[] val, int skip, int size, int bufOffset) This routine writes data only to a single page of the memory bank.protected void
setPageInitialized
(long addr, boolean initialized, int skip, int size, int bufOffset) This routine marks a range within a single page of the memory bank as initialized or uninitialized.Methods inherited from class ghidra.pcode.memstate.MemoryBank
constructValue, deconstructValue, getChunk, getInitializedMaskSize, getMemoryFaultHandler, getPageSize, getSpace, isBigEndian, setChunk, setInitialized
-
Constructor Details
-
MemoryImage
public MemoryImage(AddressSpace spc, boolean isBigEndian, int ps, MemoryLoadImage ld, MemoryFaultHandler faultHandler) A MemoryImage needs everything a basic memory bank needs and is needs to know the underlying LoadImage object to forward read requests to.- Parameters:
spc
- is the address space associated with the memory bankisBigEndian
-ps
- is the number of bytes in a page (must be power of 2)ld
- is the underlying LoadImagefaultHandler
-
-
-
Method Details
-
getPage
Retrieve an aligned page from the bank. First an attempt is made to retrieve the page from the LoadImage, which may do its own zero filling. If the attempt fails, the page is entirely filled in with zeros.- Specified by:
getPage
in classMemoryBank
-
setPage
protected void setPage(long addr, byte[] val, int skip, int size, int bufOffset) Description copied from class:MemoryBank
This routine writes data only to a single page of the memory bank. Bytes need not be written to the exact start of the page, but all bytes must be written to only one page when using this routine. A page is a fixed number of bytes, and the address of a page is always aligned based on this size. This routine may be overridden for a page based implementation of the MemoryBank. The default implementation writes the page as a sequence of aligned words, using the insert method.- Specified by:
setPage
in classMemoryBank
- Parameters:
addr
- is the aligned offset of the desired pageval
- is a pointer to the bytes to be written into the pageskip
- is the offset into the page where bytes will be writtensize
- is the number of bytes to be writtenbufOffset
- the offset in val from which to get the bytes
-
setPageInitialized
protected void setPageInitialized(long addr, boolean initialized, int skip, int size, int bufOffset) Description copied from class:MemoryBank
This routine marks a range within a single page of the memory bank as initialized or uninitialized. A page is a fixed number of bytes, and the address of a page is always aligned based on this size. This routine may be overridden for a page based implementation of the MemoryBank. The default implementation writes the page as a sequence of aligned words, using the insert method.- Specified by:
setPageInitialized
in classMemoryBank
- Parameters:
addr
- is the aligned offset of the desired pageinitialized
- true if range should be marked as initialized, false if uninitializedskip
- is the offset into the page where bytes will be writtensize
- is the number of bytes to be writtenbufOffset
- the offset in val from which to get the bytes
-