|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
mars.mips.hardware.Memory
public class Memory
Represents MIPS memory. Different segments are represented by different data structs.
Field Summary | |
---|---|
static boolean |
BIG_ENDIAN
Constant representing byte order of each memory word. |
static int |
dataBaseAddress
base address for storage of non-global static data in data segment: 0x10010000 (from SPIM) |
static int |
dataSegmentBaseAddress
base address for (user) data segment: 0x10000000 |
static int |
dataSegmentLimitAddress
|
static int |
exceptionHandlerAddress
starting address for exception handlers: 0x80000180 |
static int |
externBaseAddress
base address for .extern directive: 0x10000000 |
static int |
globalPointer
base address for storing globals |
static int |
heapAddress
|
static int |
heapBaseAddress
base address for heap: 0x10040000 (I think from SPIM not MIPS) |
static int |
kernelBaseAddress
kernel boundary. |
static int |
kernelDataBaseAddress
base address for kernel data segment: 0x90000000 |
static int |
kernelDataSegmentLimitAddress
|
static int |
kernelHighAddress
highest address acessible in kernel mode. |
static int |
kernelTextBaseAddress
base address for kernel text segment: 0x80000000 |
static int |
kernelTextLimitAddress
|
static boolean |
LITTLE_ENDIAN
Constant representing byte order of each memory word. |
static int |
memoryMapBaseAddress
starting address for memory mapped I/O: 0xffff0000 (-65536) |
static int |
memoryMapLimitAddress
|
static int |
stackBaseAddress
base address for stack: 0x7ffffffc (this is mine - start of highest word below kernel space) |
static int |
stackLimitAddress
|
static int |
stackPointer
starting address for stack: 0x7fffeffc (this is from SPIM not MIPS) |
static int |
textBaseAddress
base address for (user) text segment: 0x00400000 |
static int |
textLimitAddress
|
static int |
userHighAddress
highest address accessible in user (not kernel) mode. |
static int |
WORD_LENGTH_BYTES
MIPS word length in bytes. |
Method Summary | |
---|---|
void |
addObserver(Observer obs)
Method to accept registration from observer for any memory address. |
void |
addObserver(Observer obs,
int addr)
Method to accept registration from observer for specific address. |
void |
addObserver(Observer obs,
int startAddr,
int endAddr)
Method to accept registration from observer for specific address range. |
static int |
alignToWordBoundary(int address)
Utility method to align given address to next full word boundary, if not already aligned. |
int |
allocateBytesFromHeap(int numBytes)
Returns the next available word-aligned heap address. |
void |
clear()
Explicitly clear the contents of memory. |
int |
countObservers()
Return number of observers |
void |
deleteObserver(Observer obs)
Remove specified memory observers |
void |
deleteObservers()
Remove all memory observers |
static boolean |
doublewordAligned(int address)
Utility to determine if given address is doubleword-aligned. |
int |
get(int address,
int length)
Starting at the given word address, read the given number of bytes (max 4). |
int |
getAddressOfFirstNull(int baseAddress,
int limitAddress)
Look for first "null" memory value in an address range. |
int |
getByte(int address)
Reads specified Memory byte into low order 8 bits of int. |
boolean |
getByteOrder()
Retrieve memory byte order. |
int |
getHalf(int address)
Starting at the given word address, read a 2 byte word into lower 16 bits of int. |
static Memory |
getInstance()
Returns the unique Memory instance, which becomes in essence global. |
int |
getRawWord(int address)
Starting at the given word address, read a 4 byte word as an int. |
Integer |
getRawWordOrNull(int address)
Starting at the given word address, read a 4 byte word as an int and return Integer. |
ProgramStatement |
getStatement(int address)
Gets ProgramStatement from Text Segment. |
ProgramStatement |
getStatementNoNotify(int address)
Gets ProgramStatement from Text Segment without notifying observers. |
int |
getWord(int address)
Starting at the given word address, read a 4 byte word as an int. |
int |
getWordNoNotify(int address)
Starting at the given word address, read a 4 byte word as an int. |
static boolean |
inDataSegment(int address)
Handy little utility to find out if given address is in MARS data segment (starts at Memory.dataSegmentBaseAddress). |
static boolean |
inKernelDataSegment(int address)
Handy little utility to find out if given address is in MARS kernel data segment (starts at Memory.kernelDataSegmentBaseAddress). |
static boolean |
inKernelTextSegment(int address)
Handy little utility to find out if given address is in MARS kernel text segment (starts at Memory.kernelTextBaseAddress). |
static boolean |
inMemoryMapSegment(int address)
Handy little utility to find out if given address is in the Memory Map area starts at Memory.memoryMapBaseAddress, range 0xffff0000 to 0xffffffff. |
static boolean |
inTextSegment(int address)
Handy little utility to find out if given address is in MARS text segment (starts at Memory.textBaseAddress). |
void |
notifyObservers()
Overridden to be unavailable. |
void |
notifyObservers(Object obj)
Overridden to be unavailable. |
int |
set(int address,
int value,
int length)
Starting at the given address, write the given value over the given number of bytes. |
int |
setByte(int address,
int value)
Writes low order 8 bits of given value into specified Memory byte. |
void |
setByteOrder(boolean order)
Set byte order to either LITTLE_ENDIAN or BIG_ENDIAN. |
static void |
setConfiguration()
Sets current memory configuration for simulated MIPS. |
double |
setDouble(int address,
double value)
Writes 64 bit double value starting at specified Memory address. |
int |
setHalf(int address,
int value)
Starting at the given halfword address, write the lower 16 bits of given value into 2 bytes (a halfword). |
int |
setRawWord(int address,
int value)
Starting at the given word address, write the given value over 4 bytes (a word). |
void |
setStatement(int address,
ProgramStatement statement)
Stores ProgramStatement in Text Segment. |
int |
setWord(int address,
int value)
Starting at the given word address, write the given value over 4 bytes (a word). |
boolean |
usingCompactMemoryConfiguration()
Determine whether the current memory configuration has a maximum address that can be stored in 16 bits. |
static boolean |
wordAligned(int address)
Utility to determine if given address is word-aligned. |
Methods inherited from class java.util.Observable |
---|
clearChanged, hasChanged, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int textBaseAddress
public static int dataSegmentBaseAddress
public static int externBaseAddress
public static int globalPointer
public static int dataBaseAddress
public static int heapBaseAddress
public static int stackPointer
public static int stackBaseAddress
public static int userHighAddress
public static int kernelBaseAddress
public static int kernelTextBaseAddress
public static int exceptionHandlerAddress
public static int kernelDataBaseAddress
public static int memoryMapBaseAddress
public static int kernelHighAddress
public static final int WORD_LENGTH_BYTES
public static final boolean LITTLE_ENDIAN
public static final boolean BIG_ENDIAN
public static int heapAddress
public static int dataSegmentLimitAddress
public static int textLimitAddress
public static int kernelDataSegmentLimitAddress
public static int kernelTextLimitAddress
public static int stackLimitAddress
public static int memoryMapLimitAddress
Method Detail |
---|
public static Memory getInstance()
public void clear()
public static void setConfiguration()
public boolean usingCompactMemoryConfiguration()
public int allocateBytesFromHeap(int numBytes) throws IllegalArgumentException
numBytes
- Number of bytes requested. Should be multiple of 4, otherwise next higher multiple of 4 allocated.
IllegalArgumentException
- if number of requested bytes is negative or exceeds available heap storagepublic void setByteOrder(boolean order)
order
- either LITTLE_ENDIAN or BIG_ENDIANpublic boolean getByteOrder()
public int set(int address, int value, int length) throws AddressErrorException
address
- Starting address of Memory address to be set.value
- Value to be stored starting at that address.length
- Number of bytes to be written.
AddressErrorException
public int setRawWord(int address, int value) throws AddressErrorException
address
- Starting address of Memory address to be set.value
- Value to be stored starting at that address.
AddressErrorException
- If address is not on word boundary.public int setWord(int address, int value) throws AddressErrorException
address
- Starting address of Memory address to be set.value
- Value to be stored starting at that address.
AddressErrorException
- If address is not on word boundary.public int setHalf(int address, int value) throws AddressErrorException
address
- Starting address of Memory address to be set.value
- Value to be stored starting at that address. Only low order 16 bits used.
AddressErrorException
- If address is not on halfword boundary.public int setByte(int address, int value) throws AddressErrorException
address
- Address of Memory byte to be set.value
- Value to be stored at that address. Only low order 8 bits used.
AddressErrorException
public double setDouble(int address, double value) throws AddressErrorException
address
- Starting address of Memory address to be set.value
- Value to be stored at that address.
AddressErrorException
public void setStatement(int address, ProgramStatement statement) throws AddressErrorException
address
- Starting address of Memory address to be set. Must be word boundary.statement
- Machine code to be stored starting at that address -- for simulation
purposes, actually stores reference to ProgramStatement instead of 32-bit machine code.
AddressErrorException
- If address is not on word boundary or is outside Text Segment.ProgramStatement
public int get(int address, int length) throws AddressErrorException
address
- Starting address of Memory address to be read.length
- Number of bytes to be read.
AddressErrorException
public int getRawWord(int address) throws AddressErrorException
address
- Starting address of word to be read.
AddressErrorException
- If address is not on word boundary.public Integer getRawWordOrNull(int address) throws AddressErrorException
address
- Starting address of word to be read.
AddressErrorException
- If address is not on word boundary.public int getAddressOfFirstNull(int baseAddress, int limitAddress) throws AddressErrorException
baseAddress
- lowest MIPS address to be searched; the starting pointlimitAddress
- highest MIPS address to be searched
AddressErrorException
- if the base address is not on a word boundarypublic int getWord(int address) throws AddressErrorException
address
- Starting address of word to be read.
AddressErrorException
- If address is not on word boundary.public int getWordNoNotify(int address) throws AddressErrorException
address
- Starting address of word to be read.
AddressErrorException
- If address is not on word boundary.public int getHalf(int address) throws AddressErrorException
address
- Starting address of word to be read.
AddressErrorException
- If address is not on halfword boundary.public int getByte(int address) throws AddressErrorException
address
- Address of Memory byte to be read.
AddressErrorException
public ProgramStatement getStatement(int address) throws AddressErrorException
address
- Starting address of Memory address to be read. Must be word boundary.
AddressErrorException
- If address is not on word boundary or is outside Text Segment.ProgramStatement
public ProgramStatement getStatementNoNotify(int address) throws AddressErrorException
address
- Starting address of Memory address to be read. Must be word boundary.
AddressErrorException
- If address is not on word boundary or is outside Text Segment.ProgramStatement
public static boolean wordAligned(int address)
address
- the address to check
public static boolean doublewordAligned(int address)
address
- the address to check
public static int alignToWordBoundary(int address)
address
- a memory address (any int value is potentially valid)
public static boolean inTextSegment(int address)
address
- integer memory address
public static boolean inKernelTextSegment(int address)
address
- integer memory address
public static boolean inDataSegment(int address)
address
- integer memory address
public static boolean inKernelDataSegment(int address)
address
- integer memory address
public static boolean inMemoryMapSegment(int address)
address
- integer memory address
public void addObserver(Observer obs)
addObserver
in class Observable
obs
- the observerpublic void addObserver(Observer obs, int addr) throws AddressErrorException
obs
- the observeraddr
- the memory address which must be on word boundary
AddressErrorException
public void addObserver(Observer obs, int startAddr, int endAddr) throws AddressErrorException
obs
- the observerstartAddr
- the low end of memory address range, must be on word boundaryendAddr
- the high end of memory address range, must be on word boundary
AddressErrorException
public int countObservers()
countObservers
in class Observable
public void deleteObserver(Observer obs)
deleteObserver
in class Observable
obs
- Observer to be removedpublic void deleteObservers()
deleteObservers
in class Observable
public void notifyObservers()
notifyObservers
in class Observable
UnsupportedOperationException
public void notifyObservers(Object obj)
notifyObservers
in class Observable
UnsupportedOperationException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |