Package mars.mips.hardware
Class MemoryLayout
java.lang.Object
mars.mips.hardware.MemoryLayout
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Representation of an address range defined by a minimum address and a maximum address. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal MemoryLayout.Range
The range covered by the user data segment.final String
The description displayed in the Preferences dialog for this layout.final String
The name displayed in the Preferences dialog for this layout.final MemoryLayout.Range
The range containing dynamic data (runtime heap/stack).final int
The location of the default exception handler.final MemoryLayout.Range
The range containing global data (generated via.extern
).final int
The initial value of the global pointer ($gp
).final int
The initial value of the stack pointer ($sp
).final MemoryLayout.Range
The range covered by the kernel data segment (.kdata
).final MemoryLayout.Range
The range covered by the kernel text segment (.ktext
).static final String[]
Array of string descriptions for all memory locations.final int[]
Array containing all memory locations.final MemoryLayout.Range
The range of mapped address space.final MemoryLayout.Range
The range dedicated for performing memory-mapped I/O.static final String[]
Array of string descriptions for all memory ranges.final MemoryLayout.Range[]
Array containing all memory ranges.final MemoryLayout.Range
The range containing static data (.data
).final MemoryLayout.Range
The range covered by the user text segment (.text
).final MemoryLayout.Range
The range of user space. -
Constructor Summary
ConstructorsConstructorDescriptionMemoryLayout
(String displayName, String description, MemoryLayout.Range mappedRange, MemoryLayout.Range userRange, MemoryLayout.Range textRange, MemoryLayout.Range dataRange, MemoryLayout.Range externRange, MemoryLayout.Range staticRange, MemoryLayout.Range dynamicRange, MemoryLayout.Range kernelTextRange, MemoryLayout.Range kernelDataRange, MemoryLayout.Range mmioRange, int exceptionHandlerAddress, int initialGlobalPointer, int initialStackPointer) Construct a newMemoryLayout
manually. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryLayout
fromProperties
(Properties properties) Construct a newMemoryLayout
using the providedProperties
.
-
Field Details
-
RANGE_DESCRIPTIONS
Array of string descriptions for all memory ranges. Ordering is consistent withranges
. -
LOCATION_DESCRIPTIONS
Array of string descriptions for all memory locations. Ordering is consistent withlocations
. -
displayName
The name displayed in the Preferences dialog for this layout. (Derived from theDisplayName
property.) -
description
The description displayed in the Preferences dialog for this layout. (Derived from theDescription
property.) -
mappedRange
The range of mapped address space. All other ranges should be fully contained by this one. (Derived from theMappedSpace
property.) -
userRange
The range of user space.textRange
anddataRange
should be fully contained by this range. Note that "kernel space" is considered to be the space inmappedRange
not covered by this range. (Derived from theUserSpace
property.) -
textRange
The range covered by the user text segment (.text
). Should be contained byuserRange
. (Derived from theTextSegment
property.) -
dataRange
The range covered by the user data segment. Should be contained byuserRange
.externRange
,staticRange
, anddynamicRange
should all be fully contained by this range. (Derived from theDataSegment
property.) -
externRange
The range containing global data (generated via.extern
). Should be contained bydataRange
. (Derived from theExternData
property.) -
staticRange
The range containing static data (.data
). Should be contained bydataRange
. (Derived from theStaticData
property.) -
dynamicRange
The range containing dynamic data (runtime heap/stack). Should be contained bydataRange
. Note that the heap grows upward from the minimum address and the stack grows downward from the maximum address — more specifically, frominitialStackPointer
. (Derived from theHeapStackData
property.) -
kernelTextRange
The range covered by the kernel text segment (.ktext
). Should not be contained byuserRange
. (Derived from theKernelTextSegment
property.) -
kernelDataRange
The range covered by the kernel data segment (.kdata
). Should not be contained byuserRange
. (Derived from theKernelDataSegment
property.) -
mmioRange
The range dedicated for performing memory-mapped I/O. (Derived from theMemoryMappedIO
property.) -
exceptionHandlerAddress
public final int exceptionHandlerAddressThe location of the default exception handler. Execution jumps to this address whenever an exception, interrupt, or trap occurs. (Derived from theExceptionHandler
property.) -
initialGlobalPointer
public final int initialGlobalPointerThe initial value of the global pointer ($gp
). (Derived from theGlobalPointer
property.) -
initialStackPointer
public final int initialStackPointerThe 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 indynamicRange
. (Derived from theStackPointer
property.) -
ranges
Array containing all memory ranges. Ordering is consistent withRANGE_DESCRIPTIONS
. -
locations
public final int[] locationsArray containing all memory locations. Ordering is consistent withLOCATION_DESCRIPTIONS
.
-
-
Constructor Details
-
MemoryLayout
public MemoryLayout(String displayName, String description, MemoryLayout.Range mappedRange, MemoryLayout.Range userRange, MemoryLayout.Range textRange, MemoryLayout.Range dataRange, MemoryLayout.Range externRange, MemoryLayout.Range staticRange, MemoryLayout.Range dynamicRange, MemoryLayout.Range kernelTextRange, MemoryLayout.Range kernelDataRange, MemoryLayout.Range mmioRange, int exceptionHandlerAddress, int initialGlobalPointer, int initialStackPointer) Construct a newMemoryLayout
manually. To construct fromProperties
instead, seefromProperties(Properties)
.
-
-
Method Details
-
fromProperties
Construct a newMemoryLayout
using the providedProperties
. 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.
-