Interface MemoryContext<CellType>
- Type Parameters:
CellType- memory cell type
- All Superinterfaces:
Context
- All Known Implementing Classes:
AbstractMemoryContext
It provides the basic memory functionality, such as reading/writing memory cells. The memory cell can be of any Java type, thus a "byte", as the lowest addressable unit, is not enforced.
The memory context must be extended in a memory plugin in order to support additional functionality.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA listener for receiving memory related events. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a memory listenerbooleanDetermine if notifications of memory changes are globally enabled or disabled.voidclear()Clears the memory content.Get memory cell type class.intgetSize()Get memory sizedefault CellTypepeek(int location) Inspect a CPU-visible cell without guest timing, device effects, or access events.read(int location) Reads one memory cell at given location.CellType[]read(int location, int count) Reads one or more adjacent cells from a memory.voidRemoves a memory listenervoidsetMemoryNotificationsEnabled(boolean enabled) Enable/disable notifications of memory changes globally.voidWrite a value to a memory cell at given location.default voidWrite several cell values at once to a given location.voidWrite several cell values at once to a given location.
-
Method Details
-
read
Reads one memory cell at given location.- Parameters:
location- memory location of the memory cell- Returns:
- cell at given location
-
peek
Inspect a CPU-visible cell without guest timing, device effects, or access events. Pure memory uses its ordinary read; providers with execution side effects must override this operation. The provider resolves the same address mapping asread(int).- Parameters:
location- CPU-visible cell address- Returns:
- currently mapped cell
-
read
Reads one or more adjacent cells from a memory.Implementation of return value is up to plugin programmer (e.g. ordering of cells or atomicity). If cells in memory are pure bytes, concatenation can be realized as (in small endian):
result = (mem[from]&0xFF) | ((mem[from+1]<<8)&0xFF) | ...;and in big endian as:
result = ((mem[from]<<(count *8 ))&0xFF) | (mem[from+1]<<((count-1)*8)&0xFF) | ...;If memory size is smaller than (location + count), then only available cells are returned - returned array size can be less than
count.- Parameters:
location- location of the first cellcount- number of cells to read- Returns:
- array of cells at given location
- Throws:
RuntimeException- if memory size is smaller than (location + count)
-
write
Write a value to a memory cell at given location.- Parameters:
location- location of the cellvalue- data to be written
-
write
Write several cell values at once to a given location. The ordering of values, as well as atomicity is implementation-specific.- Parameters:
location- location of the first cellvalues- data to be writtencount- number of values taken from given array- Throws:
RuntimeException- if memory size is less than (location + count) or if (count > values.length) or if (count < 0)
-
write
Write several cell values at once to a given location. The ordering of values, as well as atomicity is implementation-specific.- Parameters:
location- location of the first cellvalues- data to be written- Throws:
RuntimeException- if memory size is less than (location + count)
-
getCellTypeClass
-
clear
void clear()Clears the memory content. -
getSize
int getSize()Get memory sizeA memory size is basically a number of cells.
Its interpretation is defined by the implementing memory.
- Returns:
- memory size (number of cells)
-
addMemoryListener
Adds a memory listener- Parameters:
listener- the memory listener (non-null)
-
removeMemoryListener
Removes a memory listener- Parameters:
listener- the memory listener to be removed (non-null)
-
setMemoryNotificationsEnabled
void setMemoryNotificationsEnabled(boolean enabled) Enable/disable notifications of memory changes globally.Enabled by default. Usually it is disabled by CPU when in a "running" state.
- Parameters:
enabled- - true if enabled, false if disabled.
-
areMemoryNotificationsEnabled
boolean areMemoryNotificationsEnabled()Determine if notifications of memory changes are globally enabled or disabled.- Returns:
- true if notifications are enabled, false if disabled.
-