Class MemoryBlockUtil


  • public class MemoryBlockUtil
    extends java.lang.Object
    A utility class that encapsulates the creation of different types of memory blocks in a program.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MemoryBlock createInitializedBlock​(java.lang.String name, Address start, byte[] data, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
      Creates an initialized memory block using a byte array.
      MemoryBlock createInitializedBlock​(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
      Creates an initialized memory block using the specified input stream.
      MemoryBlock createMappedBlock​(boolean isBitMapped, java.lang.String name, Address start, Address base, int length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
      Creates a bit or byte mapped memory block.
      MemoryBlock createOverlayBlock​(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
      Creates an initialized overlay memory block using the specified input stream.
      MemoryBlock createUninitializedBlock​(boolean isOverlay, java.lang.String name, Address start, long length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
      Creates an uninitialized memory block.
      void dispose()
      This method performs cleanup with this object is no longer needed.
      java.lang.String getMessages()
      Return error messages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MemoryBlockUtil

        public MemoryBlockUtil​(Program program,
                               MemoryConflictHandler handler)
        Constructs a new memory block utility.
        Parameters:
        program - the program having memory blocks created
        handler - the memory conflict handler
    • Method Detail

      • getMessages

        public java.lang.String getMessages()
        Return error messages.
      • dispose

        public void dispose()
        This method performs cleanup with this object is no longer needed. This method should be invoked to prevent potential memory leaks.
      • createMappedBlock

        public MemoryBlock createMappedBlock​(boolean isBitMapped,
                                             java.lang.String name,
                                             Address start,
                                             Address base,
                                             int length,
                                             java.lang.String comment,
                                             java.lang.String source,
                                             boolean r,
                                             boolean w,
                                             boolean x)
        Creates a bit or byte mapped memory block.
        Parameters:
        isBitMapped - if true, creates a bit mapped block, otherwise a byte mapped block
        name - name of the block
        start - start address of the block
        base - base address for the bit block
        length - length of the block
        comment - comment for the block
        source - source of the block, where it originated
        r - is block read-only?
        w - is block writeable?
        x - is block executable?
        Returns:
        the newly created memory block or null (see messages)
      • createUninitializedBlock

        public MemoryBlock createUninitializedBlock​(boolean isOverlay,
                                                    java.lang.String name,
                                                    Address start,
                                                    long length,
                                                    java.lang.String comment,
                                                    java.lang.String source,
                                                    boolean r,
                                                    boolean w,
                                                    boolean x)
        Creates an uninitialized memory block.
        Parameters:
        isOverlay - true if overlay space and block should be createds
        name - name of the block
        start - start address of the block
        length - length of the block
        comment - comment for the block
        source - source of the block, where it originated
        r - is block read-only?
        w - is block writeable?
        x - is block executable?
        Returns:
        the newly created memory block or null (see messages)
      • createInitializedBlock

        public MemoryBlock createInitializedBlock​(java.lang.String name,
                                                  Address start,
                                                  byte[] data,
                                                  java.lang.String comment,
                                                  java.lang.String source,
                                                  boolean r,
                                                  boolean w,
                                                  boolean x,
                                                  TaskMonitor monitor)
                                           throws AddressOverflowException
        Creates an initialized memory block using a byte array.
        Parameters:
        name - name of the block
        start - start address of the block
        data - the bytes for the memory block
        comment - comment for the block
        source - source of the block, where it originated
        r - is block read-only?
        w - is block writeable?
        x - is block executable?
        monitor - the task monitor
        Returns:
        the newly created memory block or null (see messages)
        Throws:
        AddressOverflowException
      • createInitializedBlock

        public MemoryBlock createInitializedBlock​(java.lang.String name,
                                                  Address start,
                                                  java.io.InputStream dataInput,
                                                  long dataLength,
                                                  java.lang.String comment,
                                                  java.lang.String source,
                                                  boolean r,
                                                  boolean w,
                                                  boolean x,
                                                  TaskMonitor monitor)
                                           throws AddressOverflowException
        Creates an initialized memory block using the specified input stream. If the length of the block is greater than the maximum size of a memory block (0x40000000), then the block is broken in to multiple blocks. The first block created will have the given name and each subsequent block will have ".1", ".2", etc., appended to the base name. The first block created will be the one returned by this call.

        The MemoryConflictHandler is responsible for determining how to deal with memory conflict exceptions that occur with initialized memory blocks.

        Any uninitialized memory blocks involved in the conflict will be removed and replaced with initialized memory blocks.

        If only a portion of the uninitialized memory block has caused a conflict, then only that portion will be removed and replaced. Subsequently, the uninitialized memory blocks boundaries may change.

        When other types of memory blocks are involved in a conflict, only the bytes will be replaced. The boundaries will not change. Initialized memory blocks will be created around the existing ones. Also, when bytes change from under an existing memory block, then all code units in the range of the conflict will be cleared.

        Parameters:
        name - name of the block
        start - start address of the block
        dataInput - an input stream containing the bytes for the block
        dataLength - length of the block
        comment - comment for the block
        source - source of the block, where it originated
        r - is block read-only?
        w - is block writeable?
        x - is block executable?
        monitor - the task monitor
        Returns:
        new block or null on failure (see messages)
        Throws:
        AddressOverflowException
      • createOverlayBlock

        public MemoryBlock createOverlayBlock​(java.lang.String name,
                                              Address start,
                                              java.io.InputStream dataInput,
                                              long dataLength,
                                              java.lang.String comment,
                                              java.lang.String source,
                                              boolean r,
                                              boolean w,
                                              boolean x,
                                              TaskMonitor monitor)
                                       throws AddressOverflowException,
                                              DuplicateNameException
        Creates an initialized overlay memory block using the specified input stream.
        Parameters:
        name - name of the block
        start - start address of the block
        dataInput - an input stream containing the bytes for the block
        dataLength - length of the block
        comment - comment for the block
        source - source of the block, where it originated
        r - is block read-only?
        w - is block writeable?
        x - is block executable?
        monitor - the task monitor
        Returns:
        the newly created memory block
        Throws:
        AddressOverflowException
        DuplicateNameException