Class ByteMappingScheme

java.lang.Object
ghidra.program.database.mem.ByteMappingScheme

public class ByteMappingScheme extends Object
ByteMappingScheme facilitate byte mapping/decimation scheme for a mapped sub-block to an underlying source memory region.
  • Constructor Details

    • ByteMappingScheme

      public ByteMappingScheme(int mappedByteCount, int mappedSourceByteCount)
      Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes.
      Parameters:
      mappedByteCount - number of mapped bytes per mappedSourcebyteCount (1..127). This value must be less-than or equal to schemeSrcByteCount.
      mappedSourceByteCount - number of source bytes for mapping ratio (1..127)
      Throws:
      IllegalArgumentException - if invalid mapping scheme specified
    • ByteMappingScheme

      public ByteMappingScheme(String mappingScheme)
      Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes. The two integer values in the range 1..127 are seperated by a ':' character. The number of mapped bytes must be less-than or equal to the number of source bytes.
      Parameters:
      mappingScheme - mapping scheme in string form (e.g., "2:4").
      Throws:
      IllegalArgumentException - if invalid mapping scheme specified
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isOneToOneMapping

      public boolean isOneToOneMapping()
      Determine this scheme corresponds to a 1:1 byte mapping
      Returns:
      true if 1:1 mapping else false
    • getMappedByteCount

      public int getMappedByteCount()
      Get the mapped-byte-count (left-hand value in mapping ratio)
      Returns:
      mapped-byte-count
    • getMappedSourceByteCount

      public int getMappedSourceByteCount()
      Get the mapped-source-byte-count (right-hand value in mapping ratio)
      Returns:
      mapped-source-byte-count
    • getMappedSourceAddress

      public Address getMappedSourceAddress(Address mappedSourceBaseAddress, long offsetInSubBlock) throws AddressOverflowException
      Calculate the mapped source address for a specified offset with the mapped sub-block.
      Parameters:
      mappedSourceBaseAddress - mapped source base address for sub-block
      offsetInSubBlock - byte offset within sub-block to be mapped into source
      Returns:
      mapped source address
      Throws:
      AddressOverflowException - if offset in sub-block produces a wrap condition in the mapped source address space.