16 DDR_ErrorCode_Success = 0
18 DDR_ErrorCode_Block_Already_Opened = 1
20 DDR_ErrorCode_Block_Not_Opened = 2
22 DDR_ErrorCode_Invalid_Block_Name = 3
24 DDR_ErrorCode_Invalid_Handle = 4
26 DDR_ErrorCode_Invalid_Offset = 5
28 DDR_ErrorCode_Null_Argument = 6
72if sys.platform ==
"win32":
73 dll_path = os.path.join(os.path.dirname(__file__),
"Adapter_BackEnd")
75 dll_path = os.path.join(os.path.dirname(__file__),
"libAdapter_BackEnd.so")
78adapter_backend = cdll.LoadLibrary(dll_path)
97 name = blockName.encode(
"UTF8")
98 error_code =
DDR_ErrorCode(adapter_backend.DDR_OpenMemoryBlock(name, byref(handle)))
99 if error_code == DDR_ErrorCode.DDR_ErrorCode_Success:
100 dataHandle.value = handle.value
114 return DDR_ErrorCode(adapter_backend.DDR_CloseMemoryBlock(dataHandle.value))
130 error_code =
DDR_ErrorCode(adapter_backend.DDR_GetMemorySize(dataHandle.value, byref(chunks)))
131 if error_code == DDR_ErrorCode.DDR_ErrorCode_Success:
132 memorySizeInChunks.value = chunks.value
150def ddr_getdatachunk(dataHandle: Handle, chunkOffset: int, value: ValueHandle) -> DDR_ErrorCode:
151 chunk_value = c_uint32()
152 error_code =
DDR_ErrorCode(adapter_backend.DDR_GetDataChunk(dataHandle.value, chunkOffset, byref(chunk_value)))
153 if error_code == DDR_ErrorCode.DDR_ErrorCode_Success:
154 value.value = chunk_value.value
173 chunk_value = c_uint32(value)
174 error_code =
DDR_ErrorCode(adapter_backend.DDR_SetDataChunk(dataHandle.value, chunkOffset, chunk_value))
Represents the possible errors that can be returned from the memory block access functions.
Represents an opaque token or handle to data.
def __init__(self)
Constructor.
value
The attribute to read to get the value passed back through the Handle class instance.
Represents a value that can be passed into or out of a function.
def __init__(self)
Constructor.
value
The attribute to read to get the value passed back through the ValueHandle class instance.
DDR_ErrorCode ddr_getdatachunk(Handle dataHandle, int chunkOffset, ValueHandle value)
Read a single 32-bit value at the given offset in the memory block indicated by the specified handle.
DDR_ErrorCode ddr_closememoryblock(Handle dataHandle)
Close access to a memory block previously opened by ddr_openmemoryblock(), thus releasing it for othe...
DDR_ErrorCode ddr_getmemorysize(Handle dataHandle, ValueHandle memorySizeInChunks)
Retrieve the number of chunks in the memory block indicated by the handle to the successfully opened ...
DDR_ErrorCode ddr_setdatachunk(Handle dataHandle, int chunkOffset, int value)
Writes a single 32-bit value to the given offset in the memory block indicated by the specified handl...
DDR_ErrorCode ddr_openmemoryblock(blockName, Handle dataHandle)
Open access to a memory block for exclusive use, given the name of the memory block.