3.3.6. Querying the hardware resource for memory information

Similar to register information, memory information is also structured hierarchically. An example hierarchy is shown in Figure 3.3:

Figure 3.3. Memory organization

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


To retrieve the information on the memories, the caller again must start from the target features. This data structure holds the number of available memory spaces (nrMemSpaces). Based on this value, an appropriate array of CADIMemSpaceInfo_t can be created that receives the corresponding memory space information during the CADIMemGetSpaces() method call. This call complies with the common call scheme described in Overview of CADI accesses from a debugger.

A memory space is subdivided into memory blocks that define the characteristics of certain ranges of memory within a memory space such as, for example, ranges with different accessibility properties. Call CADIMemGetBlocks() to retrieve a list of these memory blocks. In addition to the parameters of the typical call scheme, it receives the memory space ID. It is not possible to acquire all available memory blocks of all memory spaces by a special memory space ID.

Memory blocks can be ordered hierarchically as shown in Figure 3.3. To enable identifying the structure, the dedicated parentID parameter CADIMemBlockInfo_t is used. It is required because the memory blocks are returned as a list that flattens the corresponding hierarchy. This value must be set to the ID of the actual parent. For blocks that are direct children of a memory space, this parameter is set to CADI_MEMBLOCK_ROOT.

Example 3.4 shows how to access the memory-related hardware information:

Example 3.4. Accessing memory-related hardware information

//"cadi" points to a CADI 2.0 interface

eslapi::CADITargetFeatures_t target_features;
eslapi::CADIReturn_t status;

status = cadi->CADIXfaceGetFeatures(&target_features);

//...check status and setup ...
eslapi::CADIMemSpaceInfo_t* mem_spaces =
         new eslapi::CADIMemSpaceInfo_t[target_features.nrMemSpaces]();
uint32_t startMemSpaceIndex = 0;
uint32_t actualNumOfMemSpaces = 0;

status = cadi->CADIMemGetSpaces(startMemSpaceIndex, target_features.nrMemSpaces,
                                &actualNumOfMemSpaces, mem_spaces);

//...check status...
for (uint32_t spaceCnt = 0; spaceCnt < actualNumOfMemSpaces; spaceCnt++)
{
   uint32_t memBlockIndex = 0;
   uint32_t desiredNumOfMemBlocks = mem_spaces[spaceCnt].nrMemBlocks;
   uint32_t actualNumOfMemBlocks = 0;

   eslapi::CADIMemBlockInfo_t* mem_blocks =
                new eslapi::CADIMemBlockInfo_t[desiredNumOfMemBlocks]();

   status = cadi->CADIMemGetBlocks(mem_spaces[spaceCnt].memSpaceId,
                                   memBlockIndex, desiredNumOfMemBlocks,
                                   &actualNumOfMemBlocks, mem_blocks);

//...check status and use obtained memory information...
   delete[] mem_blocks;
}
delete[] mem_spaces;
//...

Copyright © 2008-2014 ARM. All rights reserved.ARM DUI 0444M
Non-ConfidentialID051314