]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
Linux-dtb-alias property cleanup
authorJustin Sobota <jsobota@ti.com>
Thu, 20 Dec 2012 22:51:21 +0000 (17:51 -0500)
committerJustin Sobota <jsobota@ti.com>
Thu, 20 Dec 2012 22:51:21 +0000 (17:51 -0500)
device/tci6614-global-resources.dtb
device/tci6614-global-resources.dts
include/rm_dtb_utilloc.h
include/rm_loc.h
src/rm.c
src/rm_dtb_util.c
test/rm_test.c

index 5746f10204ab4073034e8d758cbbf29dbd3b8c07..7eb11af12ddfa21d4f36fa3b7b606ae47e9ecb08 100644 (file)
Binary files a/device/tci6614-global-resources.dtb and b/device/tci6614-global-resources.dtb differ
index 1b9a8aee224352abc1452b124a38cc005eebb09a..c574f4ccfa33c78e9a1dc85c52a413a550d186ce 100644 (file)
@@ -19,7 +19,7 @@
         };
         memory-regions {
                        resource-range = <0 20>;
-                       linux-dtb-alias = "hwqueue@2a00000", "regions", "region-12", "id", "end", <0>, "end";
+                       linux-dtb-alias = "hwqueue@2a00000 regions region-12 id", <1 0>;
         };
         link-ram {
             resource-range = <0x00000000 0xFFFFFFFF>;
             resource-range = <0 48>;
                /* Each new line specifies a different path.  The last string in the line
                 * must result in a property tied to a value */
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "accumulator-low-0", "accumulator", "end", <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-1", "accumulator", "end", <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-2", "accumulator", "end", <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-3", "accumulator", "end", <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-high", "accumulator", "end", <1>, "end";            
+               linux-dtb-alias = "hwqueue@2a00000 queues accumulator-low-0 accumulator", <1 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-1 accumulator", <1 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-2 accumulator", <1 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-3 accumulator", <1 1>,
+                                                 "hwqueue@2a00000 queues accumulator-high accumulator", <1 1>;            
         };
         qos-cluster {
                        resource-range = <0 8>;
         low-prio-queue {
                resource-range = <0 512>;
                /* Each new line specifies a different path. */
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "accumulator-low-0", "values", "end", <0>, <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-1", "values", "end", <0>, <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-2", "values", "end", <0>, <1>, "end",
-                                                 "hwqueue@2a00000", "queues", "accumulator-low-3", "values", "end", <0>, <1>, "end";
+               linux-dtb-alias = "hwqueue@2a00000 queues accumulator-low-0 values", <2 0 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-1 values", <2 0 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-2 values", <2 0 1>,
+                                                 "hwqueue@2a00000 queues accumulator-low-3 values", <2 0 1>;
         };
         aif-queue {
                resource-range = <512 128>;
@@ -62,7 +62,7 @@
         };
         srio-queue {
                resource-range = <672 16>;
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "riotx", "values", "end", <0>, <1>, "end";
+               linux-dtb-alias = "hwqueue@2a00000 queues riotx values", <2 0 1>;
         }; 
         fftc-a-queue {
                resource-range = <688 4>;
         };
         high-prio-queue {
                resource-range = <704 32>;
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "accumulator-high", "values", "end", <0>, <1>, "end";
+               linux-dtb-alias = "hwqueue@2a00000 queues accumulator-high values", <2 0 1>;
         };
         starvation-queue {
                resource-range = <736 64>;
         };
         infra-queue {
                resource-range = <800 32>;
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "infradma", "values", "end", <0>, <1>, "end";
+               linux-dtb-alias = "hwqueue@2a00000 queues infradma values", <2 0 1>;
         };
         traffic-shaping-queue {
                resource-range = <832 32>;
         };
         gp-queue {
                resource-range = <896 7296>;
-               linux-dtb-alias = "hwqueue@2a00000", "queues", "general", "values", "end", <0>, <1>, "end";
+               linux-dtb-alias = "hwqueue@2a00000 queues general values", <2 0 1>;
                ns-assignment = "QOS_Ingress_Queue_Base", <8000 1>;
         };          
     }; /* qmss */
index b9ced927d5637b4863202303ca046d66b3d76eb4..103df61656820e64c6035b3e419dd7b3c5931e0f 100644 (file)
@@ -91,8 +91,7 @@ typedef enum {
 } Rm_ResourcePropType;
 
 typedef struct {
-    const char *pathList;
-    uint32_t pathListLenBytes;
+    char *path;
     uint32_t baseOffset;
     uint32_t lengthOffset;
     void *nextLinuxAlias;
index 115ac4f98bef70e0126a04d289667521715c8c57..057942e8ac0b45e6e5482b66b01260b4f73a61f5 100644 (file)
@@ -190,29 +190,28 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
  **********************************************************************/
 
 /* Declare the tree structure nodes */
-typedef struct _Rm_ResourceTreeNode {
-    RB_ENTRY(_Rm_ResourceTreeNode) linkage;
+typedef struct _Rm_ResourceNode {
+    RB_ENTRY(_Rm_ResourceNode) linkage;
     uint32_t base;
     uint32_t length;
     char allocatedTo[RM_INSTANCE_NAME_MAX_CHARS];
-} Rm_ResourceTreeNode;
+} Rm_ResourceNode;
 
 /* Declare the tree head structure.  A structure of type Rm_ResourceTree will need to be
  * malloc'd for each tree that is to be created. */
-typedef RB_HEAD(_Rm_ResourceTree, _Rm_ResourceTreeNode) Rm_ResourceTree;
+typedef RB_HEAD(_Rm_ResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
 
-
-Rm_ResourceTreeNode *Rm_newResourceTreeNode(uint32_t resourceBase, uint32_t resourceLength, 
-                                            char *allocatedTo);
-void Rm_freeResourceTreeNode(Rm_ResourceTreeNode *treeNode);
+Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength, 
+                                    char *allocatedTo);
+void Rm_freeResourceNode(Rm_ResourceNode *node);
 /* Prototype for tree node comparison function
  * element1 < element2 --> return < 0
  * element1 = element2 --> return 0
  * element1 > element2 --> return > 0 */
-int Rm_ResourceTreeNodeCompare(Rm_ResourceTreeNode *element1, Rm_ResourceTreeNode *element2); 
+int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2); 
 
 /* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_ResourceTree, _Rm_ResourceTreeNode, linkage, Rm_ResourceTreeNodeCompare);
+RB_PROTOTYPE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);
 
 #ifdef __cplusplus
 }
index 27a6f728e9a78eb4ba77edbc7c959b3c124b481c..2f99160d23698914c46af4a60bbb1dec93d4cea9 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -67,9 +67,6 @@
 /**********************************************************************\r
  ************************** Globals ***********************************\r
  **********************************************************************/\r
-char rmIntegerAllocator[] = "integer";\r
-char rmTreeAllocator[] = "tree";\r
-\r
 extern char rmDtbStartingNode[];\r
 \r
 /** @brief Global Variable which describes the RM Version Information */\r
@@ -80,12 +77,12 @@ const char   rmVersionStr[] = RM_VERSION_STR ":" __DATE__  ":" __TIME__;
  **********************************************************************/\r
 \r
 /* Prototype for function that allocates new tree nodes */\r
-Rm_ResourceTreeNode *Rm_newResourceTreeNode(uint32_t resourceBase, uint32_t resourceLength, \r
-                                            char *allocatedTo)\r
+Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength, \r
+                                    char *allocatedTo)\r
 {\r
-    Rm_ResourceTreeNode *newNode = NULL;\r
+    Rm_ResourceNode *newNode = NULL;\r
 \r
-    newNode = Rm_osalMalloc(sizeof(Rm_ResourceTreeNode));\r
+    newNode = Rm_osalMalloc(sizeof(Rm_ResourceNode));\r
 \r
     /* Populate the RM relevant fields */\r
     newNode->base = resourceBase;\r
@@ -96,17 +93,17 @@ Rm_ResourceTreeNode *Rm_newResourceTreeNode(uint32_t resourceBase, uint32_t reso
 }\r
 \r
 /* Prototype for function that frees new tree nodes */\r
-void Rm_freeResourceTreeNode(Rm_ResourceTreeNode *treeNode)\r
+void Rm_freeResourceNode(Rm_ResourceNode *node)\r
 {\r
     /* Free the memory associated with the tree node. */\r
-    Rm_osalFree((void *)treeNode, sizeof(Rm_ResourceTreeNode));\r
+    Rm_osalFree((void *)node, sizeof(Rm_ResourceNode));\r
 }\r
 \r
 /* Prototype for tree node comparison function\r
  * element1 < element2 --> return < 0\r
  * element1 = element2 --> return 0\r
  * element1 > element2 --> return > 0 */\r
-int Rm_ResourceTreeNodeCompare(Rm_ResourceTreeNode *element1, Rm_ResourceTreeNode *element2)\r
+int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2)\r
 {\r
     uint32_t element1End = element1->base + element1->length - 1;\r
     uint32_t element2End = element2->base + element2->length - 1;\r
@@ -131,7 +128,7 @@ int Rm_ResourceTreeNodeCompare(Rm_ResourceTreeNode *element1, Rm_ResourceTreeNod
 }\r
 \r
 /* Generate the red-black tree manipulation functions */\r
-RB_GENERATE(_Rm_ResourceTree, _Rm_ResourceTreeNode, linkage, Rm_ResourceTreeNodeCompare);\r
+RB_GENERATE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);\r
 \r
 /**********************************************************************\r
  ********************** Internal Functions ****************************\r
@@ -427,8 +424,8 @@ int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Res
 {\r
     Rm_Allocator *allocator = NULL;\r
     Rm_ResourceTree *treeRootEntry = NULL;\r
-    Rm_ResourceTreeNode *treeNode = NULL;\r
-    Rm_ResourceTreeNode *collidingNode = NULL;\r
+    Rm_ResourceNode *treeNode = NULL;\r
+    Rm_ResourceNode *collidingNode = NULL;\r
 \r
     /* Create the new base integer allocator */\r
     allocator = Rm_allocatorAdd(rmInst, resourceName);\r
@@ -440,14 +437,14 @@ int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Res
     /* Create a node in the tree for resource range and insert them into the tree. */\r
     while (range != NULL)\r
     {\r
-        treeNode = Rm_newResourceTreeNode(range->base, range->length, RM_NOT_ALLOCATED_STRING);\r
+        treeNode = Rm_newResourceNode(range->base, range->length, RM_NOT_ALLOCATED_STRING);\r
 \r
         /* Insert the node into the tree */\r
         collidingNode = RB_INSERT(_Rm_ResourceTree, treeRootEntry, treeNode);\r
 \r
         if (collidingNode)\r
         {\r
-            Rm_ResourceTreeNode *nextNode = NULL;\r
+            Rm_ResourceNode *nextNode = NULL;\r
             \r
             /* Node that was inserted colliding with an existing node.  Clean up the tree\r
              * that's been allocated thus far and return an error since there should be no\r
@@ -456,7 +453,7 @@ int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Res
             {\r
                        nextNode = RB_NEXT(_Rm_ResourceTree, treeRootEntry, treeNode);\r
                        RB_REMOVE(_Rm_ResourceTree, treeRootEntry, nextNode);\r
-                Rm_freeResourceTreeNode(treeNode);\r
+                Rm_freeResourceNode(treeNode);\r
                }\r
             /* Delete the tree root entry and the allocator */\r
             Rm_osalFree((void *)treeRootEntry, sizeof(Rm_ResourceTree));\r
@@ -480,8 +477,8 @@ int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Res
  * for the rm instance for the specified resource. */\r
 int32_t Rm_treePreAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)\r
 {\r
-    Rm_ResourceTreeNode findNode;\r
-    Rm_ResourceTreeNode *matchingNode = NULL;\r
+    Rm_ResourceNode findNode;\r
+    Rm_ResourceNode *matchingNode = NULL;\r
     uint32_t matchingEnd;\r
     uint32_t rangeIndex;\r
     bool resourceFound = FALSE;\r
@@ -550,10 +547,10 @@ int32_t Rm_treePreAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
 /* Assume the policy has already approved of the allocation */\r
 int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)\r
 {\r
-    Rm_ResourceTreeNode findNode;\r
-    Rm_ResourceTreeNode *matchingNode = NULL;\r
-    Rm_ResourceTreeNode *leftNode = NULL;\r
-    Rm_ResourceTreeNode *rightNode = NULL;  \r
+    Rm_ResourceNode findNode;\r
+    Rm_ResourceNode *matchingNode = NULL;\r
+    Rm_ResourceNode *leftNode = NULL;\r
+    Rm_ResourceNode *rightNode = NULL;  \r
     uint32_t findEnd, matchingEnd;\r
     int32_t retVal;\r
 \r
@@ -608,12 +605,12 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                     /* New left node attributes:\r
                      * base: base of the matching node\r
                      * length: base of requested resources - base of matching node */\r
-                    leftNode = Rm_newResourceTreeNode(matchingNode->base, findNode.base - matchingNode->base,\r
+                    leftNode = Rm_newResourceNode(matchingNode->base, findNode.base - matchingNode->base,\r
                                                       RM_NOT_ALLOCATED_STRING);\r
                     /* New right node attributes:\r
                      * base: base of the requested resources + length of requested resources\r
                      * length: right bound of matching node - right bound of request resources */\r
-                    rightNode = Rm_newResourceTreeNode(findNode.base + findNode.length,\r
+                    rightNode = Rm_newResourceNode(findNode.base + findNode.length,\r
                                                        matchingEnd - findEnd, RM_NOT_ALLOCATED_STRING);\r
 \r
                     /* Base and length of matching node become the base and length of the\r
@@ -667,7 +664,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         {\r
                             /* Allocate a new leftNode that will take the place of the findNode\r
                              * range in tree. */\r
-                            leftNode = Rm_newResourceTreeNode(findNode.base, findNode.length,\r
+                            leftNode = Rm_newResourceNode(findNode.base, findNode.length,\r
                                                               opInfo->serviceSrcInstName);\r
                         }\r
 \r
@@ -701,7 +698,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         {\r
                             /* Allocate a new rightNode that will take the place of the findNode\r
                              * range in tree. */\r
-                            rightNode = Rm_newResourceTreeNode(findNode.base, findNode.length,\r
+                            rightNode = Rm_newResourceNode(findNode.base, findNode.length,\r
                                                                opInfo->serviceSrcInstName);\r
                         }\r
 \r
@@ -745,10 +742,10 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
 /* Assume policy has already approved of the free */\r
 int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)\r
 {\r
-    Rm_ResourceTreeNode findNode;\r
-    Rm_ResourceTreeNode *matchingNode = NULL;\r
-    Rm_ResourceTreeNode *leftNode = NULL;\r
-    Rm_ResourceTreeNode *rightNode = NULL;\r
+    Rm_ResourceNode findNode;\r
+    Rm_ResourceNode *matchingNode = NULL;\r
+    Rm_ResourceNode *leftNode = NULL;\r
+    Rm_ResourceNode *rightNode = NULL;\r
     bool combineLeft = FALSE;\r
     bool combineRight = FALSE;\r
     uint32_t findEnd, matchingEnd;\r
@@ -819,8 +816,8 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             matchingNode->base = leftNode->base;\r
                             matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;\r
 \r
-                            Rm_freeResourceTreeNode(leftNode);\r
-                            Rm_freeResourceTreeNode(rightNode);                        \r
+                            Rm_freeResourceNode(leftNode);\r
+                            Rm_freeResourceNode(rightNode);                        \r
                         }\r
                         else if (combineLeft)\r
                         {\r
@@ -828,7 +825,7 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             matchingNode->base = leftNode->base;\r
                             matchingNode->length += leftNode->length;\r
                             \r
-                            Rm_freeResourceTreeNode(leftNode);\r
+                            Rm_freeResourceNode(leftNode);\r
                             RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
                         }\r
                         else if (combineRight)\r
@@ -836,7 +833,7 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             /* Combine the right and matching nodes.  Reinsert the left. */\r
                             matchingNode->length += rightNode->length;\r
                             \r
-                            Rm_freeResourceTreeNode(rightNode);\r
+                            Rm_freeResourceNode(rightNode);\r
                             RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         }\r
                         else\r
@@ -867,12 +864,12 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         /* New left node attributes:\r
                          * base: base of the matching node\r
                          * length: base of requested resources - base of matching node */\r
-                        leftNode = Rm_newResourceTreeNode(matchingNode->base, findNode.base - matchingNode->base,\r
+                        leftNode = Rm_newResourceNode(matchingNode->base, findNode.base - matchingNode->base,\r
                                                           matchingNode->allocatedTo); \r
                         /* New right node attributes:\r
                          * base: base of the requested resources + length of requested resources\r
                          * length: right bound of matching node - right bound of request resources */\r
-                        rightNode = Rm_newResourceTreeNode(findNode.base + findNode.length,\r
+                        rightNode = Rm_newResourceNode(findNode.base + findNode.length,\r
                                                            matchingEnd - findEnd, matchingNode->allocatedTo);\r
 \r
                         /* Insert the left and right nodes into the tree. */\r
@@ -917,7 +914,7 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             {\r
                                 /* Allocate a new leftNode that will take the place of the findNode\r
                                  * range in tree. */\r
-                                leftNode = Rm_newResourceTreeNode(findNode.base, findNode.length,\r
+                                leftNode = Rm_newResourceNode(findNode.base, findNode.length,\r
                                                                   RM_NOT_ALLOCATED_STRING);\r
                             }\r
 \r
@@ -958,7 +955,7 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             {\r
                                 /* Allocate a new rightNode that will take the place of the findNode\r
                                  * range in tree. */\r
-                                rightNode = Rm_newResourceTreeNode(findNode.base, findNode.length,\r
+                                rightNode = Rm_newResourceNode(findNode.base, findNode.length,\r
                                                                    RM_NOT_ALLOCATED_STRING);\r
                             }\r
 \r
@@ -1672,6 +1669,8 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
     Rm_AllocatorOpInfo opInfo;\r
     Rm_ResourceInfo resourceInfo;\r
     uint32_t pathOffset;\r
+    uint32_t pathSize;\r
+    char *spacePtr;\r
     int32_t propOffset;\r
     int32_t nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;\r
     int32_t prevDepth = RM_DTB_UTIL_STARTING_DEPTH;\r
@@ -1700,19 +1699,26 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
     {\r
         /* Reset the parsing variables */\r
         pathOffset = 0;\r
+        pathSize = strlen(linuxAlias->path) + 1;\r
         nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;\r
         prevDepth = RM_DTB_UTIL_STARTING_DEPTH;   \r
         resourceInfo.base = 0;\r
         resourceInfo.length = 0;\r
+\r
+        spacePtr = strpbrk(linuxAlias->path, " ");\r
+        if (spacePtr)\r
+        {\r
+            *spacePtr = '\0';\r
+        }       \r
         \r
-        while(pathOffset < linuxAlias->pathListLenBytes)\r
+        while(pathOffset < pathSize)\r
         {\r
             /* Move through the DTB nodes until the next alias path node is found */\r
-            if (strcmp(linuxAlias->pathList + pathOffset, fdt_get_name(linuxDtb, nodeOffset, NULL)))\r
+            if (strcmp(linuxAlias->path + pathOffset, fdt_get_name(linuxDtb, nodeOffset, NULL)))\r
             {\r
                 nodeOffset = fdt_next_node(linuxDtb, nodeOffset, &depth);\r
 \r
-                if (depth < prevDepth)\r
+                if ((depth < prevDepth) || (nodeOffset == -FDT_ERR_NOTFOUND))\r
                 {\r
                     /* Returning from subnode that matched part of alias path without finding\r
                      * the resource values */\r
@@ -1722,8 +1728,15 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
             }\r
             else\r
             {\r
-                /* Found the next alias path node */\r
-                pathOffset += (strlen(linuxAlias->pathList + pathOffset) + 1);\r
+                /* Found the next alias path node.  Move to the next node name in the path\r
+                 * string. */\r
+                pathOffset += (strlen(linuxAlias->path + pathOffset) + 1);\r
+                spacePtr = strpbrk(linuxAlias->path + pathOffset, " ");\r
+                if (spacePtr)\r
+                {\r
+                    *spacePtr = '\0';\r
+                }       \r
+                \r
                 prevDepth = fdt_node_depth(linuxDtb, nodeOffset);\r
 \r
                 /* Check the properties of the node to see if they match the next alias\r
@@ -1732,14 +1745,14 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
            \r
                 /* Search the properties for the next alias path string */\r
                 while ((propOffset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) &&\r
-                       (pathOffset < linuxAlias->pathListLenBytes))\r
+                       (pathOffset < pathSize))\r
                 {\r
                     propertyData = fdt_getprop_by_offset(linuxDtb, propOffset, \r
                                                          &propertyName, &propertyLen);\r
 \r
-                    if (strcmp(linuxAlias->pathList + pathOffset, propertyName) == 0)\r
+                    if (strcmp(linuxAlias->path + pathOffset, propertyName) == 0)\r
                     {\r
-                        pathOffset += (strlen(linuxAlias->pathList + pathOffset) + 1);\r
+                        pathOffset += (strlen(linuxAlias->path + pathOffset) + 1);\r
                         /* Found the alias property.  Extract the values that will\r
                          * contain the resource information that must be reserved. */\r
                         linuxValueRange = Rm_linuxExtractValues(propertyData, propertyLen);\r
@@ -2009,7 +2022,7 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
     Rm_Inst *rmInst = (Rm_Inst *) rmHandle;\r
     Rm_Allocator *allocator = rmInst->allocators;\r
     Rm_ResourceTree *treeRoot;\r
-    Rm_ResourceTreeNode *treeNode;\r
+    Rm_ResourceNode *treeNode;\r
     uint32_t numLinuxResources;\r
 \r
     while (allocator != NULL)\r
index fc10988437d90895ae548f8b253d26e9dee12c52..2275dd0ebd359629dbe49913394341969028b876 100644 (file)
@@ -157,7 +157,6 @@ void Rm_commonFreeRangeList(Rm_ResourceRange *rangeList)
 char rmResourceDeviceNameProp[] = "device-name";
 char rmResourceRangeProp[] = "resource-range";
 char rmResourceLinuxAliasProp[] = "linux-dtb-alias";
-char rmResourceLinuxAliasCompletionString[] = "end";
 char rmResourceNsAssignmentProp[] = "ns-assignment";
 
 Rm_ResourcePropType Rm_resourceGetPropertyType(const char * propertyName)
@@ -206,95 +205,97 @@ void Rm_resourceFreeRange(Rm_ResourceRange *rangeList)
 
 Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    uint8_t *aliasData = (uint8_t *)dtbDataPtr;
-    uint8_t *pathStart = NULL;
+    uint8_t *dtbAliasData = (uint8_t *)dtbDataPtr;
     uint32_t pathLenBytes;
-    uint32_t stringLenBytes;
     uint32_t extractedValue;
     uint8_t *extractedValueBytePtr;        
     Rm_LinuxAlias *startAlias = NULL;
     Rm_LinuxAlias *newAlias = NULL;
     Rm_LinuxAlias *prevAlias = NULL;
-    uint32_t i = 0;
+    uint32_t numOffsets;
+    int32_t i = 0;
     uint16_t j;
     
-    /* Linux aliases are stored in the DTB as a list of null-terminated character
-     * strings ending with a string defined as "end".  Following the string list 
-     * will be one or two values specifying the fields in the linux DTB property
-     * that contain the relevant data.  If two field offsets are specified the 
-     * Linux DTB contains a base + length. If one field offset is specified the 
-     * Linux DTB contains a single value for reservation.  An "end" string follows
-     * the offset fields.  There is no padding between the "end" string and the 32-bit 
-     * offsets.  Therefore the 32-bit offsets may not be on a 4-byte boundary and must
-     * be constructed upon extraction */
+    /* Linux aliases are stored in the DTB as a list space-separated path node names within
+     * null terminated string.  Following the path string 
+     * will be two or three values specifying the fields in the linux DTB property
+     * that contain the relevant data.  The first value specifies the number of offsets
+     * that follow.  If two field offsets are specified the 
+     * Linux DTB contains a base + length. If   one field offset is specified the 
+     * Linux DTB contains a single value for reservation.  There is no padding between
+     * the path string and the 32-bit offsets.  Therefore the 32-bit offsets may not be on
+     * a 4-byte boundary and must be constructed upon extraction */
 
     /* Extract the alias data from the DTB */
     while(i < dtbDataLen)
     {
-        /* Creat a new Linux alias entry */
+        /* Creat a new alias entry */
         newAlias = (Rm_LinuxAlias *) Rm_osalMalloc(sizeof(Rm_LinuxAlias));
         
-        /* Populate the new alias entry.  Allocate a buffer for the alias
-         * path string (adding one for each null character). */
-        pathStart = aliasData + i;
-        pathLenBytes = 0;
-        while (strcmp((char *)(aliasData + i), rmResourceLinuxAliasCompletionString) != 0)
-        {
-            stringLenBytes = strlen((char *) (aliasData + i)) + 1;
-            pathLenBytes += stringLenBytes;
-            i += stringLenBytes;
-        }
-        newAlias->pathList = (char *) Rm_osalMalloc(pathLenBytes);
-        newAlias->pathListLenBytes = pathLenBytes;
-        memcpy((void *) newAlias->pathList, (void *)pathStart, pathLenBytes);
-
-        /* Skip past the first "end" string */
-        i += (strlen((char *) (aliasData + i)) + 1);       
+        /* Populate the new alias entry.  Allocate a buffer for the path
+         * string (adding one for the null character). */
+        pathLenBytes = strlen((char *) &dtbAliasData[i]) + 1;
+        newAlias->path = (char *) Rm_osalMalloc(pathLenBytes);
+        strcpy(newAlias->path, ((char *) &dtbAliasData[i]));
         
-        /* Extract the first 32-bit offset */
+        /* Extract the 32-bit value specifying the number of offsets that follow */
+        i += pathLenBytes;
         extractedValueBytePtr = (uint8_t *)&extractedValue;
         for (j = 0; j < sizeof(uint32_t); j++, i++)
         {
-            extractedValueBytePtr[j] = aliasData[i];
+            extractedValueBytePtr[j] = dtbAliasData[i];
         }
         /* flip the endianness */
-        newAlias->baseOffset = fdt32_to_cpu(extractedValue);
+        numOffsets = fdt32_to_cpu(extractedValue);
 
-        /* Check for the "end" string. Extract the second offset if it isn't there */
-        if (strcmp((char *) (aliasData + i), rmResourceLinuxAliasCompletionString) != 0)
+        /* numOffsets should always be either 1 or 2 */
+        if ((numOffsets == 1) || (numOffsets == 2))
         {
-            /* Extract the second 32-bit offset */
+            /* Always extract the base value */
             extractedValueBytePtr = (uint8_t *)&extractedValue;
             for (j = 0; j < sizeof(uint32_t); j++, i++)
             {
-                extractedValueBytePtr[j] = aliasData[i];
-            }
-            /* flip the endianness */
-            newAlias->lengthOffset = fdt32_to_cpu(extractedValue);
-        }
-        else
-        {
-            newAlias->lengthOffset = RM_DTB_LINUX_ALIAS_OFFSET_NOT_SET;
-        }
-
-        /* Skip past the second "end" string */
-        i += (strlen((char *) (aliasData + i)) + 1);   
-
-        newAlias->nextLinuxAlias = NULL;
+                extractedValueBytePtr[j] = dtbAliasData[i];
+            }            
+            newAlias->baseOffset = fdt32_to_cpu(extractedValue);
 
-        if (prevAlias == NULL)
-        {
-            /* Save the first entry so it can be returned */
-            startAlias = newAlias;
+            if (numOffsets == 2)
+            {
+                /* Extract the 32-bit length value if two offsets were specified */
+                for (j = 0; j < sizeof(uint32_t); j++, i++)
+                {
+                    extractedValueBytePtr[j] = dtbAliasData[i];
+                }
+                /* flip the endianness */
+                newAlias->lengthOffset = fdt32_to_cpu(extractedValue);
+            }
+            else
+            {
+                newAlias->lengthOffset = RM_DTB_LINUX_ALIAS_OFFSET_NOT_SET;
+            }            
+            
+            newAlias->nextLinuxAlias = NULL;
+            
+            if (prevAlias == NULL)
+            {
+                /* Save the first entry so it can be returned */
+                startAlias = newAlias;
+            }
+            else
+            {
+                prevAlias->nextLinuxAlias = (void *) newAlias;
+            }
+            prevAlias = newAlias;
         }
         else
         {
-            prevAlias->nextLinuxAlias = (void *) newAlias;
+            /* Return NULL */
+            startAlias = NULL;
+            break;
         }
-        prevAlias = newAlias;
     }
 
-    /* Return a pointer to the start of the Linux alias list */
+    /* Return a pointer to the start of the NameServer assignment list */
     return (startAlias);
 }
 
@@ -303,12 +304,14 @@ Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbD
 void Rm_resourceFreeLinuxAlias(Rm_LinuxAlias *aliasList)
 {
     Rm_LinuxAlias *nextAlias;
-    
+    int32_t pathSize;
+       
     while (aliasList != NULL)
     {
         nextAlias = aliasList->nextLinuxAlias;
-        /* Free the path string list memory first */
-        Rm_osalFree((void *)aliasList->pathList, aliasList->pathListLenBytes);
+        /* Free the path string memory first */
+        pathSize = strlen(aliasList->path);        
+        Rm_osalFree((void *)aliasList->path, pathSize + 1);
         /* Free the list element */
         Rm_osalFree((void *)aliasList, sizeof(Rm_LinuxAlias));
         aliasList = nextAlias;
index 38f10886053a29f05a66a8e83bc7c7653b9e88b0..60420ae5674defc72a7d329ec7c5b9fa03604416 100644 (file)
@@ -1260,8 +1260,6 @@ Int main(Int argc, Char* argv[])
         readSize = fread(globalPolicy, 1, globalPolicyFileSize, globalPolicyFp);
         System_printf("Read Size compared to file size: %d : %d\n", readSize, globalPolicyFileSize);
         
-        System_printf("Core %d: RM Server instance created\n", MultiProc_self());
-        
         /* Create the RM Server instance */
         rmInitCfg.instName = &rmServerName[0];
         rmInitCfg.instType = Rm_instType_SERVER;