]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
Added RESOURCE_STATUS service for requesting the owner reference count for a given...
authorJustin Sobota <jsobota@ti.com>
Mon, 22 Apr 2013 14:21:19 +0000 (10:21 -0400)
committerJustin Sobota <jsobota@ti.com>
Mon, 22 Apr 2013 14:21:19 +0000 (10:21 -0400)
include/rm_allocatorloc.h
include/rm_transportloc.h
rm.h
rm_services.h
src/rm.c
src/rm_allocator.c
src/rm_transport.c
test/rm_mem_test.c
test/rm_shared_test.c
test/rm_test.c

index fad2f91c8cc8b9e7ef9e91a327ba7642e6336852..9298ff1d703e4930cdeb7a49ae6d6eb76e867c2e 100644 (file)
@@ -77,6 +77,8 @@ typedef enum {
     Rm_allocatorOp_ALLOCATE_INIT = 0,
     /* Allocate use operation */
     Rm_allocatorOp_ALLOCATE_USE,
+    /* Get resource status operation */
+    Rm_allocatorOp_GET_STATUS,
     /* Free operation */
     Rm_allocatorOp_FREE,
     /* Preallocate to use based on Policy DTB information operation */
index af9b77f603ab46f0a5a9929d7df4b679e8554c0d..2106b259f665a6ac52f813a3263e096aa21f1d57 100644 (file)
@@ -97,6 +97,8 @@ typedef enum {
     Rm_resReqPktType_ALLOCATE_INIT = 0,
     /* Resource allocate for use request */
     Rm_resReqPktType_ALLOCATE_USE,
+    /* Resource status request */
+    Rm_resReqPktType_GET_STATUS,
     /* Free resource */
     Rm_resReqPktType_FREE,
     /* Get name resource */
diff --git a/rm.h b/rm.h
index b55332fdd576ed6c2c004865583d2f69138fe3cc..79af0bcfe9990802e38544e0e5ad8c92f48c9b80 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -143,6 +143,7 @@ extern "C" {
  *   RM instances currently provides the following resource services:
  *    - Allocate (initialize) - Allocate a resource for initialization
  *    - Allocate (usage)      - Allocate a resource for use
+ *    - Status                - Return the reference count for a specified resource
  *    - Free                  - Free an allocated resource (The free must originate
  *                              from the RM instance that allocated the resource
  *    - Map resource to name  - Map a specified resource to a NameServer name
@@ -486,7 +487,7 @@ typedef struct {
  *  @param[in]  rmServerHandle
  *      Server instance handle.
  *
- *  @param]in]  printResources
+ *  @param[in]  printResources
  *      Non-zero - Resource ownership details will be printed for all
  *                 tracked resources
  *      0        - Resource ownership details will not be printed.  Only
index 6a09bc1d11450219074ecdd5a1c1d6b3d6351451..6c2ebd4557e3ef924d03febca75facad56cca590 100644 (file)
@@ -65,6 +65,9 @@ typedef enum {
     Rm_service_RESOURCE_ALLOCATE_USE,
     /** RM resource free service */
     Rm_service_RESOURCE_FREE,
+    /** RM resource status service - returns the reference count for specified
+     *  resource. */
+    Rm_service_RESOURCE_STATUS,
     /** RM NameServer map resource to name service */
     Rm_service_RESOURCE_MAP_TO_NAME,
     /** RM NameServer get resource by name service */
@@ -84,9 +87,9 @@ typedef struct {
      *  result originated.  Used by application to sort responses, received
      *  via callback function, from RM instances located on the same core. */
     Rm_Handle rmHandle;
-    /** Service request state.  The state can be an approval, denial, or error.
-     *  The latter codes start at #RM_OK, #RM_SERVICE_DENIED_BASE, and 
-     *  #RM_ERROR_BASE, respectively. */
+    /** Service request state.  State values can be found in rm.h starting
+     *  with #RM_SERVICE_PROCESSING, #RM_SERVICE_DENIED_BASE, and 
+     *  #RM_ERROR_LIBFDT_START */
     int32_t   serviceState;
     /** The service ID is returned to the application in order to match service
      *  responses received at a later time via the provided callback function
@@ -216,8 +219,6 @@ typedef struct {
  *      Success - Rm_ServiceHandle and result = #RM_OK
  *  @retval
  *      Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED
- *  @retval
- *      Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_ALREADY_OPENED
  */
 Rm_ServiceHandle *Rm_serviceOpenHandle(Rm_Handle rmHandle, int32_t *result);
 
index 3afc89ed2908db1c4a0706c88d809501e9433843..4ee5361e33706bf7f817ee22334e95594a6402fa 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -122,7 +122,10 @@ void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction
     }
     else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
         resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
-    }    
+    }   
+    else if (transaction->type == Rm_service_RESOURCE_STATUS) {
+        resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_STATUS;
+    }
     else if (transaction->type == Rm_service_RESOURCE_FREE) {
         resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
     }
@@ -217,12 +220,16 @@ static void serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
     /* Pass back the ID that was provided to the component when it requested
      * the service */
     serviceResponse.serviceId = transaction->localId;
+    /* Owner count will only be set within RM under certain circumstances.  Most of time
+     * it will be RM_RESOURCE_NUM_OWNERS_INVALID */
+    serviceResponse.resourceNumOwners = transaction->resourceInfo.ownerCount;
 
     /* Service was approved and service was an allocate request.  The resource
      * data is passed back to the component */
     if ((serviceResponse.serviceState == RM_SERVICE_APPROVED) &&
         ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
          (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
+         (transaction->type == Rm_service_RESOURCE_STATUS) ||
          (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))
     {
         strncpy(serviceResponse.resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
@@ -267,6 +274,7 @@ static void transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
         switch (transaction->type) {
             case Rm_service_RESOURCE_ALLOCATE_INIT:
             case Rm_service_RESOURCE_ALLOCATE_USE:
+            case Rm_service_RESOURCE_STATUS:
             case Rm_service_RESOURCE_FREE:
             case Rm_service_RESOURCE_GET_BY_NAME:
                 createResourceResponsePkt(rmPkt, transaction);
@@ -329,6 +337,7 @@ static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
         switch (transaction->type) {
             case Rm_service_RESOURCE_ALLOCATE_INIT:
             case Rm_service_RESOURCE_ALLOCATE_USE:
+            case Rm_service_RESOURCE_STATUS:
             case Rm_service_RESOURCE_FREE:
             case Rm_service_RESOURCE_GET_BY_NAME:
                 createResourceReqPkt(rmPkt, rmInst->instName, transaction);
@@ -406,6 +415,72 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
     } 
 }
 
+/* FUNCTION PURPOSE: Handles resource status service requests
+ ***********************************************************************
+ * DESCRIPTION: Issues a set of allocator operations to retrieve the
+ *              current status (currently just owner reference count)
+ *              for the resource specified in the transaction
+ */
+static void statusHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+    Rm_AllocatorOpInfo  opInfo;
+    Rm_NameServerObjCfg nameServerObjCfg;
+    int32_t             retVal = transaction->state;
+
+    if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        /* Fill in status logic for CDs */  
+    }
+    else if ((rmInst->instType == Rm_instType_SERVER)||
+             (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+        memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+
+        opInfo.policy = rmInst->u.server.globalPolicy;
+        opInfo.resourceInfo = &transaction->resourceInfo;
+        opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst, transaction->serviceSrcInstName);
+        if (opInfo.serviceSrcInstNode) {
+            /* Populated NameServer name has precedence over base and length values */
+            if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+                if ((transaction->resourceInfo.base == 0) &&
+                    (transaction->resourceInfo.length == 0) &&
+                    (transaction->resourceInfo.alignment == 0)) {
+                    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+                        rmNameServerTreeInv(rmInst->u.server.nameServer);
+                    }
+                    memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+                    nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
+                    nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+                    if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
+                        strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                        transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+                        transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+                    }
+                    else {
+                        goto errorExit;
+                    }
+                }
+                else {
+                    retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+                    goto errorExit;
+                }
+            }
+
+            if ((transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) ||
+                (transaction->resourceInfo.length == 0)) {
+                retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
+                goto errorExit;
+            }
+        
+            opInfo.operation = Rm_allocatorOp_GET_STATUS;
+            retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);    
+        }
+        else {
+            retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+        }
+errorExit:        
+        transaction->state = retVal;                 
+    }
+}
+
 /* FUNCTION PURPOSE: Arbitrates allocation service requests
  ***********************************************************************
  * DESCRIPTION: Issues a set of allocator operations in order to
@@ -419,7 +494,6 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
 static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     Rm_AllocatorOpInfo  opInfo;
-    
     Rm_NameServerObjCfg nameServerObjCfg;
     int32_t             retVal = transaction->state;
 
@@ -449,7 +523,10 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
                         strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                         transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                         transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
-                    }                
+                    }
+                    else {
+                        goto errorExit;
+                    }
                 }
                 else {
                     retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
@@ -535,22 +612,25 @@ static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
                         strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                         transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                         transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
-                    } 
+                    }
+                    else {
+                        goto errorExit;
+                    }
                 }
                 else {
                     retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+                    goto errorExit;
                 }                
             }
-            
-            if(retVal == RM_SERVICE_PROCESSING) {        
-                opInfo.operation = Rm_allocatorOp_FREE;
-                retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
-            }    
+                 
+            opInfo.operation = Rm_allocatorOp_FREE;
+            retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo); 
         }
         else {
             retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
         }
 
+errorExit:
         transaction->state = retVal;       
     }   
 }
@@ -620,75 +700,40 @@ static void cdProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
          * Server is registered */
     }
     else {
-        if ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||
-            (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||
-            (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)) {
-            if (transaction->state == RM_SERVICE_PROCESSING) {
-                /* Forward all NameServer requests. */
-                transactionForwarder(rmInst, transaction);
-            }
-            else {
-                /* NameServer transaction validated.  Return result. */
-                if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                    /* Transaction did not originate on this instance */
-                    transactionResponder(rmInst, transaction);
-                }
-                else {
-                    /* Transaction originated on this instance */
-                    serviceResponder(rmInst, transaction);
-                }
-            }
-        }        
-        else if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
-                 (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
+        if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+            (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
             if ((transaction->state == RM_SERVICE_PROCESSING) ||
                 (transaction->state == RM_SERVICE_APPROVED_STATIC)) {   
-                transactionForwarder(rmInst, transaction);
-            }
-            else {
-                /* Transaction validated.  Return result. */
-                if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                    /* Transaction did not originate on this instance */
-                    transactionResponder(rmInst, transaction);
-                }
-                else {
-                    /* Transaction originated on this instance */
-                    serviceResponder(rmInst, transaction);
-                }
+                allocationHandler(rmInst, transaction);
             }
         }
+        else if (transaction->type == Rm_service_RESOURCE_STATUS) {
+            if (transaction->state == RM_SERVICE_PROCESSING) {   
+                statusHandler(rmInst, transaction);
+            }               
+        }        
         else if (transaction->type == Rm_service_RESOURCE_FREE) {     
             if (transaction->state == RM_SERVICE_PROCESSING) {
                 freeHandler(rmInst, transaction);
+            }     
+        }
+        /* Forward all NameServer-based transactions */
 
-                if (transaction->state == RM_SERVICE_PROCESSING) {
-                    /* CD could not handle free.  Forward to Server */
-                    transactionForwarder(rmInst, transaction);
-                }
-                else {
-                    /* Free validated by CD.  Return result */
-                    if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                        /* Transaction did not originate on this instance */
-                        transactionResponder(rmInst, transaction);
-                    }
-                    else {
-                        /* Transaction originated on this instance */
-                        serviceResponder(rmInst, transaction);
-                    }                    
-                }
+        if (transaction->state == RM_SERVICE_PROCESSING) {
+            /* CD could not complete transaction.  Forward to Server */
+            transactionForwarder(rmInst, transaction);
+        }
+        else {
+            /* Transaction completed by CD or completed response received from Server.  Return result */
+            if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
+                /* Transaction did not originate on this instance */
+                transactionResponder(rmInst, transaction);
             }
             else {
-                /* Transaction validated.  Return result. */
-                if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                    /* Transaction did not originate on this instance */
-                    transactionResponder(rmInst, transaction);
-                }
-                else {
-                    /* Transaction originated on this instance */
-                    serviceResponder(rmInst, transaction);
-                }
-            }
-        }
+                /* Transaction originated on this instance */
+                serviceResponder(rmInst, transaction);
+            }                    
+        }           
 
         /* Attempt allocation of any queued static requests:
          * RM_SERVICE_APPROVED_STATIC - Originated locally
@@ -718,6 +763,9 @@ static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
     Rm_NameServerObjCfg  nameServerObjCfg;        
 
     switch (transaction->type) {
+        case Rm_service_RESOURCE_STATUS:
+            statusHandler(rmInst, transaction);
+            break;
         case Rm_service_RESOURCE_ALLOCATE_INIT:
         case Rm_service_RESOURCE_ALLOCATE_USE:
             allocationHandler(rmInst, transaction);
index 23ce8afec41bc8b6c96dd755b6f1b40abfce77fb..0795db7fbfd76573d4ecf8b4a324832c2ec284f2 100644 (file)
@@ -401,6 +401,36 @@ static int allocatorResNodeIsOwnedBy(Rm_Handle rmHandle, Rm_ResourceNode *node,
     return(RM_FALSE);
 }
 
+/* FUNCTION PURPOSE: Get the status for an allocator resource
+ ***********************************************************************
+ * DESCRIPTION: Called when a resource status request is made.  The
+ *              resource's allocator is searched for the resource base
+ *              and length specified in the transaction.  The 
+ *              resource's owner reference count is returned if the 
+ *              resource range is found.
+ */
+static int32_t allocatorStatus(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
+{
+    Rm_ResourceNode  findNode;
+    Rm_ResourceNode *matchingNode = NULL;  
+    int32_t          retVal;
+
+    memset((void *)&findNode, 0, sizeof(findNode));
+    findNode.base = opInfo->resourceInfo->base;
+    findNode.length = opInfo->resourceInfo->length;
+    matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);
+
+    if (matchingNode) {
+        opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
+        retVal = RM_SERVICE_APPROVED;
+    }
+    else {
+        retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;
+    }
+
+    return(retVal);  
+}
+
 /* FUNCTION PURPOSE: Preallocates an allocator resource
  ***********************************************************************
  * DESCRIPTION: Called when an allocate request is made but the base 
@@ -1312,9 +1342,12 @@ int32_t rmAllocatorOperation(Rm_Handle rmHandle, Rm_AllocatorOpInfo *opInfo)
         if (rmInst->instType == Rm_instType_SHARED_SERVER) {
             rmResourceTreeInv(allocator->allocatorRootEntry);
         }
-        
-        if ((opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_INIT) ||
-            (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_USE)) {
+
+        if (opInfo->operation == Rm_allocatorOp_GET_STATUS) {
+            retVal = allocatorStatus(allocator, opInfo);
+        }
+        else if ((opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_INIT) ||
+                 (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_USE)) {
             retVal = allocatorPreAllocate(rmHandle, allocator, resourceOffsetInPolicy, opInfo);
         }               
         else if ((opInfo->operation == Rm_allocatorOp_ALLOCATE_INIT) ||
@@ -1326,6 +1359,7 @@ int32_t rmAllocatorOperation(Rm_Handle rmHandle, Rm_AllocatorOpInfo *opInfo)
         } 
 
         if ((rmInst->instType == Rm_instType_SHARED_SERVER) &&
+            (opInfo->operation != Rm_allocatorOp_GET_STATUS) &&
             (retVal == RM_SERVICE_APPROVED)) {
             rmResourceTreeWb(allocator->allocatorRootEntry);
         }        
index aba3c93d2e66f5273fd9d37646b681abccd18df2..18502da772d8850b6cbad3f4b4db4541588dfe54 100644 (file)
@@ -325,7 +325,10 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
             }\r
             else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_USE) {\r
                 transaction->type = Rm_service_RESOURCE_ALLOCATE_USE;\r
-            }            \r
+            }\r
+            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_STATUS) {\r
+                transaction->type = Rm_service_RESOURCE_STATUS;\r
+            }\r
             else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_FREE) {\r
                 transaction->type = Rm_service_RESOURCE_FREE;\r
             }\r
@@ -355,6 +358,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
                 if ((transaction->state == RM_SERVICE_APPROVED) &&\r
                     ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
                      (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
+                     (transaction->type == Rm_service_RESOURCE_STATUS) ||\r
                      (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {\r
                     memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
                             sizeof(Rm_ResourceInfo));\r
index 782490094cbd2a7ca716c31a163d19f26de0a4bb..ee1d3da5525eaecde0b90321c0312012005f15d4 100644 (file)
@@ -1007,6 +1007,37 @@ void testServerCdClient(void)
                        "Pre NS Map           ", "Name Mapped to NS    ", "Name Unmapped from NS");
 
 
+    /* Check status of resource directly and through NameServer name */
+    MEM_TEST_START_STORE(); 
+    setRmRequest(&request, Rm_service_RESOURCE_ALLOCATE_INIT, resNameGpQ, 
+                 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Allocate failed");
+    setRmRequest(&request, Rm_service_RESOURCE_MAP_TO_NAME, resNameGpQ, 
+                 900, 1, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "NameServer map failed");
+    setRmRequest(&request, Rm_service_RESOURCE_STATUS, resNameGpQ, 
+                 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Status check failed");
+    setRmRequest(&request, Rm_service_RESOURCE_STATUS, resNameGpQ, 
+                 0, 0, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Status check (via NS name) failed");
+    MEM_TEST_MID_STORE();         
+    setRmRequest(&request, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
+                 0, 0, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "NameServer unmap failed");  
+    setRmRequest(&request, Rm_service_RESOURCE_FREE, resNameGpQ, 
+                 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+    serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+    ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Free failed");  
+    MEM_TEST_END_PRINT("--------- Client Check Resource Status (via CD) ---------",
+                       "Pre Alloc            ", "Post Status Requests ", "Post Free            ");
+
+
     /* Cleanup */
     rmResult = Rm_serviceCloseHandle(serviceHandle);
     ERROR_CHECK(RM_OK, rmResult, clientName, "Service handle close failed");       
index 2645a7690954b9714d13c88934169c85a2704134..5f46c4e443c1c872512f435d00dbd6e1ead52d5b 100644 (file)
@@ -68,6 +68,8 @@
  ********************** RM Shared Test Symbols ************************
  **********************************************************************/
 
+#define PRINT_USED_RESOURCES         0  /* Make 1 and rebuild project to print resources allocated in example */
+
 #define SYSINIT                      0
 #define NUM_CORES                    2
 
         System_printf ("\n");                                                                       \
     } while(0);    
 
+#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
+    do {                                                                                                        \
+        int32_t start = resStart;                                                                               \
+        char    titleMsg[] = title;                                                                             \
+        System_printf ("Core %d : ---------------------------------------------------------\n",                 \
+                       core);                                                                                   \
+        System_printf ("Core %d : %s\n", core, titleMsg);                                                       \
+        System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);                           \
+        System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                            \
+        System_printf ("Core %d : - Start:         %-16d                       -\n",                            \
+                           core, resStart);                                                                     \
+        System_printf ("Core %d : - End:           %-16d                       -\n", core,                      \
+                           (start + resLen - 1));                                                               \
+        System_printf ("Core %d : - Expected Owner Count: %-16d                -\n",                            \
+                       core, expectRefCnt);                                                                     \
+        System_printf ("Core %d : - Returned Owner Count: %-16d                -\n",                            \
+                       core, refCnt);                                                                           \
+        System_printf ("Core %d : -                                                       -\n", core);          \
+        if ((state == check) && (refCnt == expectRefCnt)) {                                                     \
+            System_printf ("Core %d : - PASSED                                                -\n", core);      \
+        }                                                                                                       \
+        else {                                                                                                  \
+            if (refCnt != expectRefCnt) {                                                                       \
+                System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
+                               core);                                                                           \
+            }                                                                                                   \
+            else {                                                                                              \
+                System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
+                               core, state);                                                                    \
+            }                                                                                                   \
+            testErrors++;                                                                                       \
+        }                                                                                                       \
+        System_printf ("Core %d : ---------------------------------------------------------\n",                 \
+                       core);                                                                                   \
+        System_printf ("\n");                                                                                   \
+    } while(0);
+
 /**********************************************************************
  ****************** RM Shared Test Data Structures ********************
  **********************************************************************/
@@ -540,6 +579,28 @@ void rmServerTsk(UArg arg0, UArg arg1)
                         coreNum, rmServerName, resourceNameInfraQ,
                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
 
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
+                 53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
+
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
+                 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
+
+#if PRINT_USED_RESOURCES
+    Rm_resourceStatus(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
+#endif
+
     /* Signal to ClientTsk that Server is ready for cleanup */
     GateMP_leave(serverGate, serverKey);
     
@@ -661,7 +722,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
      * is returned by the server. */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
-                 7000, 1, 0, NULL, FALSE, &responseInfo);     
+                 7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmSharedClient2Name, resourceNameGpQ,
@@ -669,7 +730,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
-                 7005, 25, 0, NULL, FALSE, &responseInfo);     
+                 7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmSharedClient1Name, resourceNameGpQ,
@@ -677,7 +738,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
     
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
-                 7010, 5, 0, NULL, FALSE, &responseInfo);     
+                 7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmSharedClient2Name, resourceNameGpQ,
@@ -687,14 +748,32 @@ void rmClientTsk(UArg arg0, UArg arg1)
     /* Init allocation of resource already owned by Client should return approved and there should only
      * be one instance of Client in resource's owner list. */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
-                 7011, 1, 0, NULL, FALSE, &responseInfo);     
+                 7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
                         coreNum, rmSharedClient2Name, resourceNameGpQ,
                         requestInfo.resourceBase, requestInfo.resourceLength, 
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
-    /* END Allocating some resources without providing a callback function.  RM should block and not return until the result
-     * is returned by the server. */    
+    /* END Allocating some resources without providing a callback function.  RM should block and not return
+     * until the result is returned by the server. */   
+
+    /* BEGIN Getting the status of resources from the Shared Clients */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
+                      coreNum, rmSharedClient2Name, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
+    
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
+    rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
+                      coreNum, rmSharedClient1Name, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);        
+    /* END Getting the status of resources from Client and CD */    
 
     GateMP_leave(clientGate, clientKey);
     GateMP_leave(serverGate, serverKey);
index e66c5c45a3545ee75ed94c7af48f926a0b19f7c9..b28417dc402db0aa060f3526819eb0a39484ca37 100644 (file)
@@ -71,6 +71,8 @@
  ************************** RM Test Symbols ***************************
  **********************************************************************/
 
+#define PRINT_USED_RESOURCES         0  /* Make 1 and rebuild project to print resources allocated in example */
+
 #define SYSINIT                      0
 #define NUM_CORES                    2
 
         System_printf ("\n");                                                                       \
     } while(0);    
 
+#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
+    do {                                                                                                        \
+        int32_t start = resStart;                                                                               \
+        char    titleMsg[] = title;                                                                             \
+        System_printf ("Core %d : ---------------------------------------------------------\n",                 \
+                       core);                                                                                   \
+        System_printf ("Core %d : %s\n", core, titleMsg);                                                       \
+        System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);                           \
+        System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                            \
+        System_printf ("Core %d : - Start:         %-16d                       -\n",                            \
+                           core, resStart);                                                                     \
+        System_printf ("Core %d : - End:           %-16d                       -\n", core,                      \
+                           (start + resLen - 1));                                                               \
+        System_printf ("Core %d : - Expected Owner Count: %-16d                -\n",                            \
+                       core, expectRefCnt);                                                                     \
+        System_printf ("Core %d : - Returned Owner Count: %-16d                -\n",                            \
+                       core, refCnt);                                                                           \
+        System_printf ("Core %d : -                                                       -\n", core);          \
+        if ((state == check) && (refCnt == expectRefCnt)) {                                                     \
+            System_printf ("Core %d : - PASSED                                                -\n", core);      \
+        }                                                                                                       \
+        else {                                                                                                  \
+            if (refCnt != expectRefCnt) {                                                                       \
+                System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
+                               core);                                                                           \
+            }                                                                                                   \
+            else {                                                                                              \
+                System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
+                               core, state);                                                                    \
+            }                                                                                                   \
+            testErrors++;                                                                                       \
+        }                                                                                                       \
+        System_printf ("Core %d : ---------------------------------------------------------\n",                 \
+                       core);                                                                                   \
+        System_printf ("\n");                                                                                   \
+    } while(0);
+
 /**********************************************************************
  ********************** RM Test Data Structures ***********************
  **********************************************************************/
@@ -746,6 +785,28 @@ void rmServerTsk(UArg arg0, UArg arg1)
                         coreNum, rmServerName, resourceNameInfraQ,
                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
 
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
+                 53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
+
+    /* Get the status of a resource from Server */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
+                 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
+                      coreNum, rmServerName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
+
+#if PRINT_USED_RESOURCES
+    Rm_resourceStatus(rmServerHandle, RM_TEST_TRUE);
+#endif
+
     /* Signal to ClientTsk that Server is ready for cleanup */
     GateMP_leave(serverGate, serverKey);
     
@@ -793,6 +854,18 @@ void rmClientTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceBase, requestInfo.resourceLength, 
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
 
+    /* Retrieve the resource status via the NameServer name */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL, 
+                 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
+    rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+        waitForResponse(&responseInfo);
+    }
+    STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----", 
+                      coreNum, rmClientName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);  
+
     /* Free resource via a NameServer name */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
@@ -900,7 +973,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
      * is returned by the server. */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
-                 7000, 1, 0, NULL, FALSE, &responseInfo);     
+                 7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmClientName, resourceNameGpQ,
@@ -908,7 +981,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
 
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
-                 7005, 25, 0, NULL, FALSE, &responseInfo);     
+                 7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmCdName, resourceNameGpQ,
@@ -916,7 +989,7 @@ void rmClientTsk(UArg arg0, UArg arg1)
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
     
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
-                 7010, 5, 0, NULL, FALSE, &responseInfo);     
+                 7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
                         coreNum, rmClientName, resourceNameGpQ,
@@ -926,14 +999,54 @@ void rmClientTsk(UArg arg0, UArg arg1)
     /* Init allocation of resource already owned by Client should return approved and there should only
      * be one instance of Client in resource's owner list. */
     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
-                 7011, 1, 0, NULL, FALSE, &responseInfo);     
+                 7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
                         coreNum, rmClientName, resourceNameGpQ,
                         requestInfo.resourceBase, requestInfo.resourceLength, 
                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
     /* END Allocating some resources without providing a callback function.  RM should block and not return
-     * until the result is returned by the server. */            
+     * until the result is returned by the server. */   
+
+    /* BEGIN Getting the status of resources from Client and CD */
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+        waitForResponse(&responseInfo);
+    }    
+    STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -", 
+                      coreNum, rmClientName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
+    
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
+                 4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
+    rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---", 
+                      coreNum, rmClientName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);      
+
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
+                 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
+    rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+        waitForResponse(&responseInfo);
+    }     
+    STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---", 
+                      coreNum, rmCdName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
+
+    setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
+                 805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);     
+    rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
+    STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----", 
+                      coreNum, rmCdName, responseInfo.resourceName,
+                      responseInfo.resourceBase, responseInfo.resourceLength, 
+                      responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);   
+    /* END Getting the status of resources from Client and CD */    
 
     /* Verify static allocations were validated.  Validation responses should have been received after the
      * first service requests were made on the Client and CD post transport path registration. */
@@ -1307,7 +1420,7 @@ int main(Int argc, Char* argv[])
         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle open failed");
 
         /* Create the RM Client instance */
-        rmInitCfg.instName = &rmClientName[0];
+        rmInitCfg.instName = rmClientName;
         rmInitCfg.instType = Rm_instType_CLIENT;      
         rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)rmStaticPolicy;
         rmClientHandle = Rm_init(&rmInitCfg, &result);