TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Memory.h File Reference
#include "temu-c/Support/Objsys.h"
#include "temu-c/Support/Memory.h"
#include <stdint.h>
Include dependency graph for Memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  temu_MemTransaction
 
struct  temu_MemAccessIface
 
struct  temu_MemoryIface
 
struct  temu_MemoryMapIface
 

Macros

#define TEMU_MT_CACHEABLE   1
 
#define TEMU_MT_BYPASS_CACHE   (1 << 1)
 
#define TEMU_MT_FORCE_CACHE_MISS   (1 << 2)
 
#define TEMU_MT_FAILED   (1 << 3)
 
#define TEMU_MT_CACHE_HIT   (1 << 4)
 
#define TEMU_MT_PRIV_MASK   (7 << 5)
 
#define TEMU_MT_PRIV_USER   (1 << 5)
 
#define TEMU_MT_PRIV_SUPER   (2 << 5)
 
#define TEMU_MT_PRIV_HYPER   (3 << 5)
 
#define TEMU_MT_PROBE   (1 << 8)
 
#define TEMU_MEM_ACCESS_IFACE_TYPE   "MemAccessIface"
 
#define TEMU_MEMORY_IFACE_TYPE   "MemoryIface"
 
#define TEMU_MEMORY_MAP_IFACE_TYPE   "MemoryMapIface"
 

Typedefs

typedef enum temu_MemoryKind temu_MemoryKind
 
typedef struct temu_MemTransaction temu_MemTransaction
 
typedef struct temu_MemAccessIface temu_MemAccessIface
 
typedef struct temu_MemoryIface temu_MemoryIface
 
typedef struct temu_MemoryMapIface temu_MemoryMapIface
 

Enumerations

enum  temu_MemoryKind { teMK_RAM, teMK_ROM, teMK_MMIO }
 
enum  temu_InitiatorType { teIT_Cpu, teIT_Device, teIT_Unknown }
 

Functions

 TEMU_IFACE_REFERENCE_TYPE (temu_MemAccess)
 
 TEMU_IFACE_REFERENCE_TYPE (temu_Memory)
 
 TEMU_IFACE_REFERENCE_TYPE (temu_MemoryMap)
 
int temu_mapMemorySpace (void *Obj, uint64_t Addr, uint64_t Len, void *MemObj)
 
int temu_mapMemorySpaceFlags (void *Obj, uint64_t Addr, uint64_t Len, void *MemObj, uint32_t Flags)
 
void temu_setMemAttr (void *Obj, uint64_t Addr, uint64_t Len, temu_MemoryAttr Attr)
 
void temu_clearMemAttr (void *Obj, uint64_t Addr, uint64_t Len, temu_MemoryAttr Attr)
 

Macro Definition Documentation

#define TEMU_MEM_ACCESS_IFACE_TYPE   "MemAccessIface"

Definition at line 129 of file Memory.h.

#define TEMU_MEMORY_IFACE_TYPE   "MemoryIface"

Definition at line 155 of file Memory.h.

#define TEMU_MEMORY_MAP_IFACE_TYPE   "MemoryMapIface"

Definition at line 176 of file Memory.h.

#define TEMU_MT_BYPASS_CACHE   (1 << 1)

Definition at line 35 of file Memory.h.

#define TEMU_MT_CACHE_HIT   (1 << 4)

Definition at line 38 of file Memory.h.

#define TEMU_MT_CACHEABLE   1

Definition at line 34 of file Memory.h.

#define TEMU_MT_FAILED   (1 << 3)

Definition at line 37 of file Memory.h.

#define TEMU_MT_FORCE_CACHE_MISS   (1 << 2)

Definition at line 36 of file Memory.h.

#define TEMU_MT_PRIV_HYPER   (3 << 5)

Definition at line 43 of file Memory.h.

#define TEMU_MT_PRIV_MASK   (7 << 5)

Definition at line 40 of file Memory.h.

#define TEMU_MT_PRIV_SUPER   (2 << 5)

Definition at line 42 of file Memory.h.

#define TEMU_MT_PRIV_USER   (1 << 5)

Definition at line 41 of file Memory.h.

#define TEMU_MT_PROBE   (1 << 8)

Definition at line 45 of file Memory.h.

Typedef Documentation

Memory access interface implemented by all memory mapped devices Exposed to the emulator core by a memory object.

For objects which have actual memory (not just registers) This is for the simulator (not the emu core). The procedures should write the data given in bytes to the given physical offset. The offset is a 64 bit uint to support 64 bit targets. The interface is used for example by DMA transactions.

The size argument is in bytes.

The swap argument is used to swap bytes to the host endianess. Specify the log size of the read data types.

  • 0: We are reading bytes (bytes will be in target memory order)
  • 1: We are reading half words (will be swapped to host order)
  • 2: We are reading words (will be swapped)
  • 3: We are reading double words (will be swapped) With 0 for swap, we are basically reading a byte array

readBytes and writeBytes should return the number of bytes read / written or negative on error.

Standard interface for memory space objects

Users should not implement their own memory spaces. No stability guarantees are made about this interface at the moment.

Generic memory transaction.

This type is kept in sync with the emulator core. The layout is guaranteed. and will remain as is, although more fields may be added (at the bottom).

When the emulator core issues a memory transaction (assuming no ATC hit), the core allocates this structure on the stack and fills in some of the fields with default values. The memory transaction is passed by pointer or reference. By filling in the different fields you can adapt the result of the memory transaction.

Enumeration Type Documentation

Enumerator
teIT_Cpu 
teIT_Device 
teIT_Unknown 

Definition at line 27 of file Memory.h.

Enumerator
teMK_RAM 
teMK_ROM 
teMK_MMIO 

Definition at line 21 of file Memory.h.

Function Documentation

void temu_clearMemAttr ( void *  Obj,
uint64_t  Addr,
uint64_t  Len,
temu_MemoryAttr  Attr 
)

Clear attribute on memory space location

Parameters
ObjThe memory space object
AddrPhysical address where to map the device
LenLength in bytes of area where the attribute should be set.
AttrThe attribute to clear.
TEMU_IFACE_REFERENCE_TYPE ( temu_MemAccess  )
TEMU_IFACE_REFERENCE_TYPE ( temu_Memory  )
TEMU_IFACE_REFERENCE_TYPE ( temu_MemoryMap  )
int temu_mapMemorySpace ( void *  Obj,
uint64_t  Addr,
uint64_t  Len,
void *  MemObj 
)

Map memory object into address space

Parameters
ObjThe memory space object
AddrPhysical address where to map the device
LenLength in bytes of area where the object is mapped.
MemObjThe memory object. This object must correspond to the MemAccessIface
Returns
Zero on success, other values indicates that the mapping failed
int temu_mapMemorySpaceFlags ( void *  Obj,
uint64_t  Addr,
uint64_t  Len,
void *  MemObj,
uint32_t  Flags 
)

Map memory object into address space with flags

Parameters
ObjThe memory space object
AddrPhysical address where to map the device
LenLength in bytes of area where the object is mapped.
MemObjThe memory object. This object must correspond to the MemAccessIface
FlagsSticky flags for memory accesses to that object (e.g. cachable)
Returns
Zero on success, other values indicates that the mapping failed
void temu_setMemAttr ( void *  Obj,
uint64_t  Addr,
uint64_t  Len,
temu_MemoryAttr  Attr 
)

Set attribute on memory space location

Parameters
ObjThe memory space object
AddrPhysical address where to map the device
LenLength in bytes of area where the attribute should be set.
AttrThe attribute to set.