9#define BLOCK_0_NAME "gorp"
10#define BLOCK_1_NAME "baba"
11#define BLOCK_2_NAME "yaga"
20#define MAX_DATA_SIZE 32
73 foundIndex = (int)index;
91 bool isValidHandle =
false;
93 if (memoryIndex != NULL)
95 int index = dataHandle;
103 return isValidHandle;
125 if (blockName != NULL && dataHandle != NULL)
130 if (foundBlockIndex != -1)
137 *dataHandle = foundBlockIndex;
154 int memoryIndex = -1;
174 if (memorySizeInChunks != NULL)
177 int memoryIndex = -1;
197 int memoryIndex = -1;
222 int memoryIndex = -1;
const char * BLOCK_NAME_0
Name of the first block.
static size_t memory_block_count
DDR_ErrorCode DDR_SetDataChunk(int dataHandle, int chunkOffset, uint32_t value)
Writes a single 32-bit value to the given offset in the memory block indicated by the specified handl...
static MemoryBlock memory_blocks[]
Predefined set of memory blocks that can be accessed by name. Data for each memory block is stored as...
static bool _ConvertHandleToBlockIndex(int dataHandle, int *memoryIndex)
Convert the given data handle to an index into the memory blocks.
const char * BLOCK_NAME_2
Name of the third block.
DDR_ErrorCode DDR_GetDataChunk(int dataHandle, int chunkOffset, uint32_t *value)
Read a single 32-bit value at the given offset in the memory block indicated by the specified handle.
static bool _IsValidOffset(int chunkOffset)
Determine if the given offset is valid.
#define MAX_DATA_SIZE
Maximum number of 32-bit chunks in a single memory block.
static int _FindBlock(const char *blockName)
Retrieve the index of the requested memory block.
DDR_ErrorCode DDR_OpenMemoryBlock(const char *blockName, int *dataHandle)
Open access to a memory block for exclusive use, given the name of the memory block.
DDR_ErrorCode DDR_CloseMemoryBlock(int dataHandle)
Close access to a previously opened memory block, thus releasing it for others to open.
const char * BLOCK_NAME_1
Name of the second block.
DDR_ErrorCode DDR_GetMemorySize(int dataHandle, int *memorySizeInChunks)
Retrieve the number of chunks in the memory block indicated by the handle to the successfully opened ...
Declaration of the "low-level" memory block read/write functions that are provided in a separate DLL ...
DDR_ErrorCode
Represents the possible errors that can be returned from the memory block access functions.
@ DDR_ErrorCode_Block_Not_Opened
Memory block is closed and cannot be accessed.
@ DDR_ErrorCode_Block_Already_Opened
Memory block is already open and cannot be opened again.
@ DDR_ErrorCode_Null_Argument
The block name pointer or return handle pointer argument is NULL.
@ DDR_ErrorCode_Invalid_Block_Name
The given name is not a recognized memory block name.
@ DDR_ErrorCode_Invalid_Handle
The handle argument does not correspond to a valid open memory block.
@ DDR_ErrorCode_Success
Operation succeeded.
@ DDR_ErrorCode_Invalid_Offset
The given offset is out of bounds.
@ DDR_MAX_OFFSET
All offsets must from 0 to 1 less than this value.
@ DDR_INVALID_HANDLE
Value indicating the handle is invalid.
Header for precompiled headers. Used only on Windows.
Represents a single memory block.
bool locked
True if a caller has acquired this memory block for exclusive access; otherwise, false,...
uint32_t data[MAX_DATA_SIZE]
Data held in this memory block, stored as 32-bit values. Least significant byte is first byte of each...
const char * name
Name of a memory block so it can be addressed individually.