Class MemoryLayout

java.lang.Object
mars.mips.hardware.MemoryLayout

public class MemoryLayout extends Object
A specification for how MIPS memory should be laid out in the address space. The layout consists of a number of address ranges as well as a number of special locations.

This class is typically constructed using fromProperties(Properties). Many of the public fields in this class indicate which property in the Properties object they are derived from.

  • Field Details

    • RANGE_DESCRIPTIONS

      public static final String[] RANGE_DESCRIPTIONS
      Array of string descriptions for all memory ranges. Ordering is consistent with ranges.
    • LOCATION_DESCRIPTIONS

      public static final String[] LOCATION_DESCRIPTIONS
      Array of string descriptions for all memory locations. Ordering is consistent with locations.
    • displayName

      public final String displayName
      The name displayed in the Preferences dialog for this layout. (Derived from the DisplayName property.)
    • description

      public final String description
      The description displayed in the Preferences dialog for this layout. (Derived from the Description property.)
    • mappedRange

      public final MemoryLayout.Range mappedRange
      The range of mapped address space. All other ranges should be fully contained by this one. (Derived from the MappedSpace property.)
    • userRange

      public final MemoryLayout.Range userRange
      The range of user space. textRange and dataRange should be fully contained by this range. Note that "kernel space" is considered to be the space in mappedRange not covered by this range. (Derived from the UserSpace property.)
    • textRange

      public final MemoryLayout.Range textRange
      The range covered by the user text segment (.text). Should be contained by userRange. (Derived from the TextSegment property.)
    • dataRange

      public final MemoryLayout.Range dataRange
      The range covered by the user data segment. Should be contained by userRange. externRange, staticRange, and dynamicRange should all be fully contained by this range. (Derived from the DataSegment property.)
    • externRange

      public final MemoryLayout.Range externRange
      The range containing global data (generated via .extern). Should be contained by dataRange. (Derived from the ExternData property.)
    • staticRange

      public final MemoryLayout.Range staticRange
      The range containing static data (.data). Should be contained by dataRange. (Derived from the StaticData property.)
    • dynamicRange

      public final MemoryLayout.Range dynamicRange
      The range containing dynamic data (runtime heap/stack). Should be contained by dataRange. Note that the heap grows upward from the minimum address and the stack grows downward from the maximum address — more specifically, from initialStackPointer. (Derived from the HeapStackData property.)
    • kernelTextRange

      public final MemoryLayout.Range kernelTextRange
      The range covered by the kernel text segment (.ktext). Should not be contained by userRange. (Derived from the KernelTextSegment property.)
    • kernelDataRange

      public final MemoryLayout.Range kernelDataRange
      The range covered by the kernel data segment (.kdata). Should not be contained by userRange. (Derived from the KernelDataSegment property.)
    • mmioRange

      public final MemoryLayout.Range mmioRange
      The range dedicated for performing memory-mapped I/O. (Derived from the MemoryMappedIO property.)
    • exceptionHandlerAddress

      public final int exceptionHandlerAddress
      The location of the default exception handler. Execution jumps to this address whenever an exception, interrupt, or trap occurs. (Derived from the ExceptionHandler property.)
    • initialGlobalPointer

      public final int initialGlobalPointer
      The initial value of the global pointer ($gp). (Derived from the GlobalPointer property.)
    • initialStackPointer

      public final int initialStackPointer
      The initial value of the stack pointer ($sp). This serves as the starting point for the runtime stack, which grows downward. Typically, this is the last word-aligned address in dynamicRange. (Derived from the StackPointer property.)
    • ranges

      public final MemoryLayout.Range[] ranges
      Array containing all memory ranges. Ordering is consistent with RANGE_DESCRIPTIONS.
    • locations

      public final int[] locations
      Array containing all memory locations. Ordering is consistent with LOCATION_DESCRIPTIONS.
  • Constructor Details

  • Method Details

    • fromProperties

      public static MemoryLayout fromProperties(Properties properties) throws IllegalArgumentException
      Construct a new MemoryLayout using the provided Properties. A property value is required for every range and location in the layout. See the documentation for the fields in this class for the specific property keys.
      Parameters:
      properties - The properties to initialize fields with.
      Returns:
      The constructed MemoryLayout.
      Throws:
      IllegalArgumentException - Thrown if one or more required properties is not present.