]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
Fixed bug preventing UNSPECIFIED allocations from taking place
authorJustin Sobota <jsobota@ti.com>
Fri, 5 Apr 2013 23:03:27 +0000 (19:03 -0400)
committerJustin Sobota <jsobota@ti.com>
Fri, 5 Apr 2013 23:03:27 +0000 (19:03 -0400)
src/rm.c
src/rm_allocator.c
src/rm_policy.c

index 30633652d938fc42e16a4f4c29f4f203a6c9a7ec..1cbc4b47653ae4ced6e787455519fb001a0cd430 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -365,6 +365,7 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
     Rm_Inst                *rmInst = (Rm_Inst *)rmHandle;
     void                   *staticPolicy = rmPolicyGetPolicy(rmHandle);
     Rm_PolicyCheckCfg       privCheckCfg;
+    int32_t                 result;
     
     if (staticPolicy) {
         if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
@@ -385,13 +386,17 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
             privCheckCfg.resourceBase = transaction->resourceInfo.base;
             privCheckCfg.resourceLength = transaction->resourceInfo.length;
     
-            if (rmPolicyCheckPrivilege(&privCheckCfg, &transaction->state)) {
+            if (rmPolicyCheckPrivilege(&privCheckCfg, &result)) {
                 transaction->state = RM_SERVICE_APPROVED_STATIC;
             }
-            else if (transaction->state == RM_SERVICE_PROCESSING) {
+            else if (result == RM_OK) {
                 /* Privilege check returned false without error */
                 transaction->state = RM_SERVICE_DENIED_BY_STATIC_POLICY;
             }
+            else {
+                /* Privilege check returned false with error */
+                transaction->state = result;
+            }
         }
         else {
             transaction->state = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;
index 8e034f0b84ced13ed418d69c1c4021384e01920a..8892717d35f43fdaab68ff3144b1094a118f31d8 100644 (file)
@@ -394,12 +394,12 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
     Rm_PolicyCheckType policyCheckType;
     Rm_PolicyCheckCfg  policyCheckCfg;
     int                nodePassesPolicy;
-    int32_t            retVal = RM_SERVICE_PROCESSING;    
+    int32_t            retVal;
 
     opInfo->resourceInfo->base = rmPolicyGetResourceBase(opInfo->policy, opInfo->serviceSrcInstNode, 
                                                          resourcePolicy, opInfo->allocType, 
                                                          &retVal);
-    if (retVal != RM_SERVICE_PROCESSING) {
+    if (retVal != RM_OK) {
         return (retVal);
     }
 
@@ -465,7 +465,7 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
                     nodePassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);
                 }
 
-                if (retVal != RM_SERVICE_PROCESSING) {
+                if (retVal != RM_OK) {
                     break;
                 }
 
@@ -483,6 +483,7 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
                          * allocate requirements */
                         opInfo->resourceInfo->base = rangeIndex;
                         resourceFound = RM_TRUE;
+                        retVal = RM_SERVICE_PROCESSING;
                     }     
                 }
             }
@@ -526,7 +527,7 @@ static int32_t allocatorAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator, in
     int                 combineRight = RM_FALSE;    
     uint32_t            findEnd;
     uint32_t            matchingEnd;  
-    int32_t             retVal = RM_SERVICE_PROCESSING;
+    int32_t             retVal;
 
     memset((void *)&findNode, 0, sizeof(findNode));
     findNode.base = opInfo->resourceInfo->base;
index 8c1ffe89da4e6012237e77dbe3b312edfc87678a..396a08d7367776a1be0c509a8fe7863c831d5d21 100644 (file)
@@ -417,6 +417,8 @@ static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *
     char                *permStrEnd;
     uint32_t             permStrLen = strlen(assignment->permissionsList) + 1;
     uint32_t             i = 0;
+
+    *result = RM_OK;
     
     while(i < permStrLen) {
         /* Find the first sub-permission specification and parse it.  A sub-permission
@@ -470,7 +472,7 @@ static int32_t policyValidateAssignmentPermissions(Rm_Handle rmHandle,
 {
     Rm_PolicyAssignment *assignment = assignmentList;
     Rm_PolicyPermission *permissionList;
-    int32_t              result = RM_OK;
+    int32_t              result;
 
     while (assignment) {
         /* Make sure assignment's permissions parse okay */
@@ -572,6 +574,8 @@ int rmPolicyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
     uint32_t             resourceEnd = privilegeCfg->resourceBase + privilegeCfg->resourceLength - 1;
     int                  foundInstance;
 
+    *result = RM_OK;
+
     /* Get the resource's assignments */
     propertyOffset = fdt_first_property_offset(privilegeCfg->policyDtb, privilegeCfg->resourceOffset);
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
@@ -674,6 +678,8 @@ uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validI
     Rm_PolicyPermission *permissionStart = NULL;
     uint32_t             resourceBase = 0;
 
+    *result = RM_OK;
+
     propertyOffset = fdt_first_property_offset(policyDtb, resourceOffset);
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
         while (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {