Package ghidra.pcode.memstate
Class DefaultMemoryState
java.lang.Object
ghidra.pcode.memstate.AbstractMemoryState
ghidra.pcode.memstate.DefaultMemoryState
- All Implemented Interfaces:
MemoryState
All storage/state for a pcode emulator machine
Every piece of information in a pcode emulator machine is representable as a triple
(AddressSpace,offset,size). This class allows getting and setting of all state information of
this form.
-
Constructor Summary
ConstructorDescriptionDefaultMemoryState
(Language language) MemoryState constructor for a specified processor language -
Method Summary
Modifier and TypeMethodDescriptionint
getChunk
(byte[] res, AddressSpace spc, long off, int size, boolean stopOnUnintialized) This is the main interface for reading a range of bytes from the MemorySate.final MemoryBank
Any MemoryBank that has been registered with this MemoryState can be retrieved via this method if the MemoryBank's associated address space is known.void
setChunk
(byte[] val, AddressSpace spc, long off, int size) This is the main interface for setting values for a range of bytes in the MemoryState.void
setInitialized
(boolean initialized, AddressSpace spc, long off, int size) This is the main interface for setting the initialization status for a range of bytes in the MemoryState.final void
setMemoryBank
(MemoryBank bank) MemoryBanks associated with specific address spaces must be registers with this MemoryState via this method.Methods inherited from class ghidra.pcode.memstate.AbstractMemoryState
getBigInteger, getBigInteger, getBigInteger, getBigInteger, getValue, getValue, getValue, getValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue
-
Constructor Details
-
DefaultMemoryState
MemoryState constructor for a specified processor language- Parameters:
language
-
-
-
Method Details
-
setMemoryBank
MemoryBanks associated with specific address spaces must be registers with this MemoryState via this method. Each address space that will be used during emulation must be registered separately. The MemoryState object does not assume responsibility for freeing the MemoryBank.- Parameters:
bank
- is a pointer to the MemoryBank to be registered
-
getMemoryBank
Any MemoryBank that has been registered with this MemoryState can be retrieved via this method if the MemoryBank's associated address space is known.- Parameters:
spc
- is the address space of the desired MemoryBank- Returns:
- the MemoryBank or null if no bank is associated with spc.
-
getChunk
This is the main interface for reading a range of bytes from the MemorySate. The MemoryBank associated with the address space of the query is looked up and the request is forwarded to the getChunk method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is thrown. All getLongValue methods utilize this method to read the bytes from the appropriate memory bank.- Parameters:
res
- the result buffer for storing retrieved bytesspc
- the desired address spaceoff
- the starting offset of the byte range being readsize
- the number of bytes being readstopOnUnintialized
- if true a partial read is permitted and returned size may be smaller than size requested- Returns:
- number of bytes actually read
- Throws:
LowlevelError
- if spc has not been mapped within this MemoryState or memory fault handler generated error
-
setChunk
This is the main interface for setting values for a range of bytes in the MemoryState. The MemoryBank associated with the desired address space is looked up and the write is forwarded to the setChunk method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is throw. All setValue methods utilize this method to read the bytes from the appropriate memory bank.- Parameters:
val
- the byte values to be written into the MemoryStatespc
- the address space being writtenoff
- the starting offset of the range being writtensize
- the number of bytes to write- Throws:
LowlevelError
- if spc has not been mapped within this MemoryState
-
setInitialized
This is the main interface for setting the initialization status for a range of bytes in the MemoryState. The MemoryBank associated with the desired address space is looked up and the write is forwarded to the setInitialized method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is throw. All setValue methods utilize this method to read the bytes from the appropriate memory bank.- Parameters:
initialized
- indicates if range should be marked as initialized or notspc
- the address space being writtenoff
- the starting offset of the range being writtensize
- the number of bytes to write
-