]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blobdiff - src/rm.c
Bug fixes, cleanup, expanded test code
[keystone-rtos/rm-lld.git] / src / rm.c
index 15f3d6dc533f4732ca6ef2a365e0d25f24c19426..d3ab4932ba66e2c1677bf1b3d2d905dae3133c12 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -150,7 +150,7 @@ Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst)
     newTransaction = Rm_osalMalloc(sizeof(Rm_Transaction));\r
 \r
     /* Return if the memory allocated for the transaction entry is NULL */\r
-    if (newTransaction == NULL)\r
+    if (newTransaction != NULL)\r
     {\r
         /* Clear the transaction */\r
         memset((void *)newTransaction, 0, sizeof(Rm_Transaction));\r
@@ -244,7 +244,7 @@ int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
     else\r
     {\r
         /* Delete the transaction */\r
-        if ((prevTransaction == NULL) && transaction->nextTransaction)\r
+        if (prevTransaction == NULL)\r
         {\r
             /* Transaction to be deleted exists at start of transaction queue.  Map second\r
              * transaction to be start of transaction queue as long as there are more than\r
@@ -400,7 +400,7 @@ int32_t Rm_allocatorDelete(Rm_Inst *rmInst, char *resourceName)
     else\r
     {\r
         /* Delete the allocator */\r
-        if ((prevAllocator == NULL) && allocator->nextAllocator)\r
+        if (prevAllocator == NULL)\r
         {\r
             /* Allocator to be deleted exists at start of allocator list.  Map second\r
              * allocator to be start of allocator list as long as there are more than\r
@@ -1488,10 +1488,10 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
      * - NameServer requests received on the Client Delegate are forwarded to the Server */\r
     if ((rmInst->instType == Rm_instType_CLIENT) ||\r
         ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
-         (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||\r
-         (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||\r
-         (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))\r
-    {\r
+         ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||\r
+          (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||\r
+          (transaction->type == Rm_service_RESOURCE_UNMAP_NAME))))\r
+    {        \r
         /* Check if the transaction is a transaction that received a response to its\r
          * request. */\r
         if (transaction->state != RM_SERVICE_PROCESSING)\r
@@ -1794,24 +1794,25 @@ int32_t Rm_createAndInitAllocator(Rm_Inst *rmInst, const char *resourceName,
     Rm_ResourceInfo resourceInfo;\r
     int32_t retVal = RM_DTB_UTIL_RESULT_OKAY;\r
 \r
-    /* TODO: NEED CHECKS FOR VALIDITY OF ALL THE resourceProperties FIELDS */\r
-\r
-    /* Extract the resource properties from the DTB */\r
-    range = rangeBasePtr = Rm_resourceExtractRange(resourceProperties->rangeData, \r
-                                                   resourceProperties->rangeLen);\r
+    if (resourceProperties->rangeData && (resourceProperties->rangeLen > 0))\r
+    {\r
+        /* Extract the resource properties from the DTB */\r
+        range = rangeBasePtr = Rm_resourceExtractRange(resourceProperties->rangeData, \r
+                                                       resourceProperties->rangeLen);\r
 \r
-    /* Create a tree allocator using the resource properties */\r
-    retVal = Rm_createTreeAllocator(rmInst, resourceName, range); \r
+        /* Create a tree allocator using the resource properties */\r
+        retVal = Rm_createTreeAllocator(rmInst, resourceName, range); \r
 \r
-    if (retVal >= RM_DTB_UTIL_RESULT_OKAY)\r
-    {\r
-        if (resourceProperties->linuxAliasData && resourceProperties->linuxAliasLen)\r
+        if (retVal >= RM_DTB_UTIL_RESULT_OKAY)\r
         {\r
-            /* Reserve the resources taken by the Linux kernel specified in the Linux DTB */\r
-            linuxAlias = Rm_resourceExtractLinuxAlias(resourceProperties->linuxAliasData,\r
-                                                      resourceProperties->linuxAliasLen);\r
+            if (resourceProperties->linuxAliasData && resourceProperties->linuxAliasLen)\r
+            {\r
+                /* Reserve the resources taken by the Linux kernel specified in the Linux DTB */\r
+                linuxAlias = Rm_resourceExtractLinuxAlias(resourceProperties->linuxAliasData,\r
+                                                          resourceProperties->linuxAliasLen);\r
 \r
-            retVal = Rm_findAndReserveLinuxResource(rmInst, resourceName, linuxDtb, linuxAlias);            \r
+                retVal = Rm_findAndReserveLinuxResource(rmInst, resourceName, linuxDtb, linuxAlias);            \r
+            }\r
         }\r
     }\r
     \r
@@ -2005,9 +2006,15 @@ int32_t Rm_initializeAllocators(Rm_Inst *rmInst, void *globalResourceDtb, void *
 \r
     return(result);\r
 }\r
+     \r
+/**********************************************************************\r
+ ********************** Application visible APIs **********************\r
+ **********************************************************************/\r
 \r
-void Rm_printResourceStatus(Rm_Inst *rmInst)\r
+/* Server Only */\r
+void Rm_printResourceStatus(Rm_Handle *rmHandle)\r
 {\r
+    Rm_Inst *rmInst = (Rm_Inst *) rmHandle;\r
     Rm_Allocator *allocator = rmInst->allocators;\r
     Rm_ResourceTree *treeRoot;\r
     Rm_ResourceTreeNode *treeNode;\r
@@ -2045,11 +2052,9 @@ void Rm_printResourceStatus(Rm_Inst *rmInst)
         \r
         allocator = allocator->nextAllocator;\r
     }\r
+\r
+    Rm_nsPrintObjects(rmInst);\r
 }\r
-     \r
-/**********************************************************************\r
- ********************** Application visible APIs **********************\r
- **********************************************************************/\r
 \r
 Rm_Handle Rm_init(Rm_InitCfg *initCfg)\r
 {\r
@@ -2093,6 +2098,9 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg)
     /* RM Server specific actions */\r
     if (rmInst->instType == Rm_instType_SERVER)\r
     {\r
+        /* Initialize the NameServer */\r
+        Rm_nsInit(rmInst);\r
+        \r
         /* Open the ResourceList file and provide it to the resource initializer.  The Linux\r
          * DTB will be parsed simultaneously for resource's consumed by the kernel.  The resources\r
          * used by the kernel will be marked as used in the resource allocators. */\r
@@ -2108,12 +2116,7 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg)
             }\r
             \r
             Rm_initializeAllocators(rmInst, globalResourceDtb, linuxResourceDtb);\r
-\r
-            Rm_printResourceStatus(rmInst);\r
         }\r
-\r
-        /* Initialize the NameServer */\r
-        Rm_nsInit(rmInst);\r
     }\r
 \r
     /* Instance startup policies are only used for Servers and Client Delegates */\r