Class DefaultMemoryState

java.lang.Object
ghidra.pcode.memstate.AbstractMemoryState
ghidra.pcode.memstate.DefaultMemoryState
All Implemented Interfaces:
MemoryState

public class DefaultMemoryState extends AbstractMemoryState
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 Details

    • DefaultMemoryState

      public DefaultMemoryState(Language language)
      MemoryState constructor for a specified processor language
      Parameters:
      language -
  • Method Details

    • setMemoryBank

      public final void setMemoryBank(MemoryBank bank)
      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

      public final MemoryBank getMemoryBank(AddressSpace spc)
      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

      public int 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. 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 bytes
      spc - the desired address space
      off - the starting offset of the byte range being read
      size - the number of bytes being read
      stopOnUnintialized - 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

      public 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. 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 MemoryState
      spc - the address space being written
      off - the starting offset of the range being written
      size - the number of bytes to write
      Throws:
      LowlevelError - if spc has not been mapped within this MemoryState
    • setInitialized

      public 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. 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 not
      spc - the address space being written
      off - the starting offset of the range being written
      size - the number of bytes to write