|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--mars.mips.hardware.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 |
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(java.util.Observer obs)
Method to accept registration from observer for any memory address. |
void |
addObserver(java.util.Observer obs,
int addr)
Method to accept registration from observer for specific address. |
void |
addObserver(java.util.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(java.util.Observer obs)
Remove specified memory observers |
void |
deleteObservers()
Remove all memory observers |
int |
get(int address,
int length)
Starting at the given word address, read the given number of bytes (max 4). |
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. |
ProgramStatement |
getStatement(int address)
Gets ProgramStatement from Text Segment. |
int |
getWord(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 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 |
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(java.lang.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. |
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). |
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 final int textBaseAddress
public static final int dataSegmentBaseAddress
public static final int kernelTextBaseAddress
public static final int exceptionHandlerAddress
public static final int kernelDataBaseAddress
public static final int dataBaseAddress
public static final int heapBaseAddress
public static final int stackBaseAddress
public static final int userHighAddress
public static final int kernelBaseAddress
public static final int kernelHighAddress
public static final int globalPointer
public static final int stackPointer
public static final int memoryMapBaseAddress
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 final int dataSegmentLimitAddress
public static final int textLimitAddress
public static final int kernelDataSegmentLimitAddress
public static final int kernelTextLimitAddress
public static final int stackLimitAddress
public static final int memoryMapLimitAddress
Method Detail |
public static Memory getInstance()
public void clear()
public int allocateBytesFromHeap(int numBytes) throws java.lang.IllegalArgumentException
numBytes
- Number of bytes requested. Should be multiple of 4, otherwise next higher multiple of 4 allocated.
java.lang.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 int getWord(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 static boolean wordAligned(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 void addObserver(java.util.Observer obs)
addObserver
in class java.util.Observable
obs
- the observerpublic void addObserver(java.util.Observer obs, int addr) throws AddressErrorException
obs
- the observeraddr
- the memory address which must be on word boundary
AddressErrorException
public void addObserver(java.util.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 java.util.Observable
public void deleteObserver(java.util.Observer obs)
deleteObserver
in class java.util.Observable
obs
- Observer to be removedpublic void deleteObservers()
deleteObservers
in class java.util.Observable
public void notifyObservers()
notifyObservers
in class java.util.Observable
java.lang.UnsupportedOperationException
public void notifyObservers(java.lang.Object obj)
notifyObservers
in class java.util.Observable
java.lang.UnsupportedOperationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |