Go to the source code of this file.
|
| TEMU_IFACE_REFERENCE_TYPE (temu_MemorySpace) |
|
| TEMU_IFACE_REFERENCE_TYPE (temu_PDC) |
|
TEMU_API int | temu_memoryRead (void *mem, uint8_t *buff, uint64_t addr, uint32_t size, int swap) |
|
TEMU_API int | temu_memoryWrite (void *mem, uint64_t addr, uint8_t *buff, uint32_t size, int swap) |
|
TEMU_API int | temu_memoryMap (void *Obj, uint64_t Addr, uint64_t Len, void *MemObj, uint32_t Flags) |
|
TEMU_API int | temu_memoryMapNamedIface (void *Obj, uint64_t Addr, uint64_t Len, void *MemObj, const char *IfaceName, uint32_t Flags) |
|
TEMU_API void | temu_memorySetAttr (void *Obj, uint64_t Addr, uint64_t Len, temu_MemoryAttr Attr) |
|
TEMU_API void | temu_memoryClearAttr (void *Obj, uint64_t Addr, uint64_t Len, temu_MemoryAttr Attr) |
|
TEMU_API temu_MemoryAttrs | temu_memoryGetAttrs (void *Obj, uint64_t Addr) |
| Get memory attributes for address. More...
|
|
TEMU_API int | temu_memoryReadPhys32 (void *Obj, uint64_t Addr, uint32_t *Word) |
|
TEMU_API int | temu_memoryWritePhys32 (void *Obj, uint64_t Addr, uint32_t Word) |
|
TEMU_API uint32_t | temu_normaliseWrite32 (uint32_t OldVal, uint32_t NewVal, int Sz, int Off) |
|
TEMU_API uint32_t | temu_normaliseRead32 (uint32_t Value, int Sz, int Off) |
|
TEMU_API uint16_t | temu_normaliseRead16 (uint16_t Value, int Sz, int Off) |
|
TEMU_API uint16_t | temu_normaliseWrite16 (uint16_t OldVal, uint16_t NewVal, int Sz, int Off) |
|
#define TEMU_MEMORY_SPACE_IFACE_TYPE "MemorySpaceIface" |
#define TEMU_PDC_IFACE_TYPE "PDCIface" |
Memory attribute enumeration.
The emulator provides 5 standard attributes, and 3 user defined ones. The attributes are set in the memory space (not the memory models), so it is possible to set a watch point on memory mapped devices. When an attribute is set on a page, that page will get a shadow attribute page (same size as the page), enabling attributes to be set on a per byte level.
Attributes are only checked on the address being accessed, the transaction size is not taken into account.
Enumerator |
---|
teMA_Break |
Breakpoint set.
|
teMA_WatchRead |
Read watchpoint set.
|
teMA_WatchWrite |
Write watchpoint set.
|
teMA_Upset |
Single event upset.
|
teMA_Faulty |
Multiple event upset / uncorrectable.
|
teMA_User1 |
User definable.
|
teMA_User2 |
User definable.
|
teMA_User3 |
User definable.
|
Definition at line 33 of file Memory.h.
TEMU_IFACE_REFERENCE_TYPE |
( |
temu_MemorySpace |
| ) |
|
TEMU_IFACE_REFERENCE_TYPE |
( |
temu_PDC |
| ) |
|
Clears an attribute on the given memory range
- Parameters
-
Obj | Memory space object |
Addr | Physical address of start |
Len | Length of memory range |
Attr | Attribute to clear |
Get memory attributes for address.
- Parameters
-
Obj | Memory space |
Addr | Physical addres |
- Returns
- Memory attributes for the address
TEMU_API int temu_memoryMap |
( |
void * |
Obj, |
|
|
uint64_t |
Addr, |
|
|
uint64_t |
Len, |
|
|
void * |
MemObj, |
|
|
uint32_t |
Flags |
|
) |
| |
temu_memoryMap Maps an object into a memory space. The object must have an interface named MemAccessIface, of the type defined as TEMU_MEM_ACCESS_IFACE_TYPE
- Parameters
-
Obj | is the memory space object |
Addr | the physical address |
Len | the length in bytes |
MemObj | is the object that is mapped into the memory space it needs to be of a class that follows the rules above |
Flags | are flags that are copied into the memory transaction object's flag field when a transaction reaches an object |
- Returns
- Zero on success
TEMU_API int temu_memoryMapNamedIface |
( |
void * |
Obj, |
|
|
uint64_t |
Addr, |
|
|
uint64_t |
Len, |
|
|
void * |
MemObj, |
|
|
const char * |
IfaceName, |
|
|
uint32_t |
Flags |
|
) |
| |
temu_memoryMapNamedIface Maps an object into a memory space using the named memory access interface. The interface named by IfaceName must be of the type TEMU_MEM_ACCESS_IFACE_TYPE
- Parameters
-
Obj | is the memory space object |
Addr | the physical address |
Len | the length in bytes |
MemObj | is the object that is mapped into the memory space it needs to be of a class that follows the rules above |
IfaceName | Name of the memory access interface |
Flags | are flags that are copied into the memory transaction object's flag field when a transaction reaches an object |
- Returns
- Zero on success
TEMU_API int temu_memoryRead |
( |
void * |
mem, |
|
|
uint8_t * |
buff, |
|
|
uint64_t |
addr, |
|
|
uint32_t |
size, |
|
|
int |
swap |
|
) |
| |
temu_memoryRead TODO
- Parameters
-
mem | Pointer to memory space object |
buff | The buffer to which the memory should be stored |
addr | The address of the memory block to be read |
size | The size to be read |
swap | setting this to 0 indicates reading a byte array, 1 a uint16 array, 2 a uint32 array and 3 a uint64 array |
- Returns
- Negative on failures. Other values indicate success. The convention is to return the number of bytes read which should be == size.
TEMU_API int temu_memoryReadPhys32 |
( |
void * |
Obj, |
|
|
uint64_t |
Addr, |
|
|
uint32_t * |
Word |
|
) |
| |
Issue a memory read transaction (without initiator)
- Parameters
-
Obj | Memory space |
Addr | Physical address |
Word | 32 bit word that is read |
- Returns
- 0 on success, other values imply failure and will not update the word.
Sets an attribute on the given memory range
- Parameters
-
Obj | Memory space object |
Addr | Physical address of start |
Len | Length of memory range |
Attr | Attribute to set |
TEMU_API int temu_memoryWrite |
( |
void * |
mem, |
|
|
uint64_t |
addr, |
|
|
uint8_t * |
buff, |
|
|
uint32_t |
size, |
|
|
int |
swap |
|
) |
| |
temu_memoryWrite TODO
- Parameters
-
mem | Pointer to memory space object |
buff | The buffer to which the memory should be stored |
addr | The address, at which the write should be done |
size | The size to be read |
swap | Negative on failures. Other values indicate success. |
- Returns
- Negative on failure. Other values indicate success. The convention is to return the number of bytes written, which should be == size.
TEMU_API int temu_memoryWritePhys32 |
( |
void * |
Obj, |
|
|
uint64_t |
Addr, |
|
|
uint32_t |
Word |
|
) |
| |
Issue a memory write transaction (without initiator)
- Parameters
-
Obj | Memory space |
Addr | Physical address |
Word | 32 bit word to write |
- Returns
- 0 on success
TEMU_API uint16_t temu_normaliseRead16 |
( |
uint16_t |
Value, |
|
|
int |
Sz, |
|
|
int |
Off |
|
) |
| |
Normalise a value for reads where only 16 bit transactions are supported by the device model, but the target is allowed to read non-16 bit quantities.
Given a 32 bit register value, the function extracts the bits from it that was actually requested.
- Parameters
-
Value | Register value |
Sz | Size in log number of bytes (0 or 1) |
Off | Offset in bytes within the 32 bit word of the transaction (0 or 2) |
TEMU_API uint32_t temu_normaliseRead32 |
( |
uint32_t |
Value, |
|
|
int |
Sz, |
|
|
int |
Off |
|
) |
| |
Normalise a value for reads where only 32 bit transactions are supported by the device model, but the target is allowed to read non-32 bit quantities.
Given a 32 bit register value, the function extracts the bits from it that was actually requested.
- Parameters
-
Value | Register value |
Sz | Size in log number of bytes (0, 1, or 2) |
Off | Offset in bytes within the 32 bit word of the transaction (0-3) |
TEMU_API uint16_t temu_normaliseWrite16 |
( |
uint16_t |
OldVal, |
|
|
uint16_t |
NewVal, |
|
|
int |
Sz, |
|
|
int |
Off |
|
) |
| |
Normalise a value for writes where only 16 bit transactions are supported by the device model, but the target is allowed to write non-16 bit quantity. The function mixes the old register value with the new one based on the size and offset parameter. The problem exists because the memory access interface has a value entry, which always ends up in the lower bits, so if we write to the higher bits in in a 16 bit register, then by just forwarding the the value as is to the write handler, will result in a write of the lower bits and a clear of the upper bits (for a store unsigned).
Thus a normalisation is neded where we mix the written word with the old bits. So for transaction size of 8, and an offset of8, the resulting word is (old & 0x00ff) | (new << 8)
- Parameters
-
OldVal | Old regiseter value. |
NewVal | Content in memory transaction (new value). |
Sz | Size in log number of bytes |
Off | Offset in bytes within the 16 bit word of the transaction. |
TEMU_API uint32_t temu_normaliseWrite32 |
( |
uint32_t |
OldVal, |
|
|
uint32_t |
NewVal, |
|
|
int |
Sz, |
|
|
int |
Off |
|
) |
| |
Normalise a value for writes where only 32 bit transactions are supported by the device model, but the target is allowed to write non-32 bit quantity. The function mixes the old register value with the new one based on the size and offset parameter. The problem exists because the memory access interface has a value entry, which always ends up in the lower bits, so if we write to the higher bits in in a 32 bit register, then by just forwarding the the value as is to the write handler, will result in a write of the lower bits and a clear of the upper bits (for a store unsigned).
Thus a normalisation is neded where we mix the written word with the old bits. So for transaction size of 16, and an offset of 16, the resulting word is (old & 0x0000ffff) | (new << 16)
- Parameters
-
OldVal | Old regiseter value. |
NewVal | Content in memory transaction (new value). |
Sz | Size in log number of bytes |
Off | Offset in bytes within the 32 bit word of the transaction. |