Initial testing, basic demo complete
authorJustin Sobota <jsobota@ti.com>
Mon, 17 Dec 2012 23:48:58 +0000 (18:48 -0500)
committerJustin Sobota <jsobota@ti.com>
Mon, 17 Dec 2012 23:48:58 +0000 (18:48 -0500)
include/rm_loc.h
include/rm_nameserverloc.h
include/rm_transportloc.h
rm_services.h
rm_transport.h
src/rm.c
src/rm_nameserver.c
src/rm_services.c
src/rm_transport.c
test/rm_test.c

index aa42d44087e3a970da6ebd55ca6c1a4d0d544c68..ec1677da69c3d14933a6ce0db10d7c04c966838b 100644 (file)
@@ -76,19 +76,6 @@ typedef void *Rm_Allocators;
 /** Pointer to the RM instance's NameServer (Valid only on Server) */
 typedef void *Rm_NameServer;
 
-/**
- * @brief RM transaction details values.  Details values provide more fine-grained
- *        information regarding a transaction request or response
- */
-typedef enum {
-    /** Transaction is being processed */
-    Rm_transactionState_PROCESSING = 0,
-    /** Transaction has been approved */
-    Rm_transactionState_TRANSACTION_APPROVED = 1,
-    /** Transaction has been denied */
-    Rm_transactionState_TRANSACTION_DENIED = 2  
-} Rm_TransactionState;
-
 /**
  * @brief RM protocol packet resource information
  */
@@ -125,13 +112,16 @@ typedef struct {
      *  to the lower level RM instance.  The lower level RM instance will 
      *  match the response packet with the originating request using the ID */
     uint32_t remoteOriginatingId;
-    /** Name of the RM instance the transaction originated from */
-    char sourceInstName[RM_INSTANCE_NAME_MAX_CHARS];
+    /** Name of the RM instance the RM packet, that spawned the transaction,
+     *  originated from */
+    char pktSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];
     /** Transaction's associated callback function */
     Rm_ServiceCallback callback;
     /** Transaction state.  The codes are externally visible and tracked
      *  in rmservices.h */
     int32_t state;
+    /** Name of the RM instance the service originated from */
+    char serviceSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];    
     /** Resource information */
     Rm_ResourceInfo resourceInfo;
     /** Link to the next transaction in the queue */
@@ -154,7 +144,7 @@ typedef enum {
 } Rm_AllocatorOp;
 
 typedef struct {
-    char *srcInstName;
+    char *serviceSrcInstName;
     Rm_AllocatorOp operation;
     /* When pre-allocating, the policy's ranges and alignment for the resource
      * for the RM instance will be copied to the following three variables.  These
index b8fe7ddc7afbab6c21e70fe95aca93e98a1c07f8..2870bb40635957121ed1833c4b1c8d6db9a5deaf 100644 (file)
@@ -46,6 +46,7 @@ extern "C" {
 
 /* RM external includes */
 #include <ti/drv/rm/rm.h>
+#include <ti/drv/rm/rm_services.h>
 
 /* RM internal includes */
 #include <ti/drv/rm/include/rm_loc.h>
@@ -75,6 +76,7 @@ int32_t Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
 typedef struct _Rm_NameServerNode {
     RB_ENTRY(_Rm_NameServerNode) linkage;
     char name[RM_RESOURCE_NAME_MAX_CHARS];
+    char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
     uint32_t base;
     uint32_t length;
 } Rm_NameServerNode;
@@ -82,8 +84,8 @@ typedef struct _Rm_NameServerNode {
 /* Declare the tree head structure. */
 typedef RB_HEAD(_Rm_NameServerTree, _Rm_NameServerNode) Rm_NameServerTree;
 
-Rm_NameServerNode *Rm_newNameServerNode(char *name, uint32_t resourceBase, 
-                                        uint32_t resourceLength);
+Rm_NameServerNode *Rm_newNameServerNode(char *name, char *resourceName,
+                                        uint32_t resourceBase, uint32_t resourceLength);
 void Rm_freeNameServerNode(Rm_NameServerNode *node);
 /* Prototype for NameServer node comparison function
  * element1 < element2 --> return < 0
index 163f52495f74cbc0498d9a505a5726e975a6aaaf..fa6154cc7f488501e25763bb1685d7b02d8e0f34 100644 (file)
@@ -92,10 +92,13 @@ typedef struct {
     uint32_t requestId;  
     /** The resource request type */
     Rm_ResourceReqPktType resourceReqType;
-    /** Name of RM instance that is issuing the resource request. The instance 
+    /** RM instance name from which the request packet originated.  Used by 
+     *  receiving instance to route the response */
+    char pktSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];    
+    /** Name of RM instance that is issuing the service request. The instance 
      *  name will be used to validate the request against the RM policy defined
      *  for the instance. */
-    char instName[RM_INSTANCE_NAME_MAX_CHARS];      
+    char serviceSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];      
     /** Resource request information */
     Rm_ResourceInfo resourceInfo;
 } Rm_ResourceRequestPkt;
@@ -136,9 +139,12 @@ typedef struct {
     uint32_t requestId;  
     /** The resource request type */
     Rm_NsReqPktType nsRequestType;
-    /** RM instance name making the request.  Policies may restrict who
+    /** RM instance name from which the request packet originated.  Used by 
+     *  receiving instance to route the response */
+    char pktSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];
+    /** RM instance name making the service request.  Policies may restrict who
      *  can and cannot map and unmap resources via the RM NameServer */
-    char instName[RM_INSTANCE_NAME_MAX_CHARS];
+    char serviceSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];
     /** Resource request information */
     Rm_ResourceInfo resourceInfo;
 } Rm_NsRequestPkt;
index 0f824598d316d679a937088fa667af32550dff56..88680b705aa7fa320cec7521d70e0fb6a0c3a8d6 100644 (file)
@@ -175,6 +175,8 @@ typedef struct {
      *  service responses received via the component callback function.  A service ID will not
      *  be returned if the service request is satisfied immediately */
     uint32_t serviceId;
+    /** The name of the resource affected by the service request */
+    char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
     /** The base value of the returned resource.  In the case of a block resource allocation 
      *  response this field will contain the base value of the block. */
     int32_t resourceBase;
index 039fb12ebbb4aac8f50b453a0bb4f16b779f6b18..d986ba3e97840d32bacc1a8b27fcea84bb798354 100644 (file)
@@ -82,7 +82,7 @@ extern "C" {
 typedef int32_t   Rm_TransportResult;
 
 /** Maximum size of the RM transport packet */
-#define RM_TRANSPORT_PACKET_MAX_SIZE_BYTES (128)  // Placeholder: This will 
+#define RM_TRANSPORT_PACKET_MAX_SIZE_BYTES (256)  // Placeholder: This will 
                                                  // change during development
 
 /** 
index d3ab4932ba66e2c1677bf1b3d2d905dae3133c12..57e42c0a379831fb8739e85aad45a8af4aeddd23 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -610,7 +610,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                 if ((findNode.base == matchingNode->base) && (findEnd == matchingEnd))\r
                 {\r
                     /* Can reserve matchingNode's resources in-place */\r
-                    strcpy(matchingNode->allocatedTo, opInfo->srcInstName);\r
+                    strcpy(matchingNode->allocatedTo, opInfo->serviceSrcInstName);\r
                 }\r
                 /* Handle case where the findNode range is a subset of the matchingNode\r
                  * range and neither of the boundaries of the two ranges are equivalent.\r
@@ -646,7 +646,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                     matchingNode->base = findNode.base;                                    \r
                     matchingNode->length = findNode.length;\r
                     /* Reserve the resources */\r
-                    strcpy(matchingNode->allocatedTo, opInfo->srcInstName);\r
+                    strcpy(matchingNode->allocatedTo, opInfo->serviceSrcInstName);\r
 \r
                     /* Insert all the nodes */\r
                     RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
@@ -680,7 +680,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         \r
                         /* Can the node to the left of the matchingNode be combined with the \r
                          * findNode's range? */\r
-                        if (leftNode && (strcmp(leftNode->allocatedTo, opInfo->srcInstName) == 0))\r
+                        if (leftNode && (strcmp(leftNode->allocatedTo, opInfo->serviceSrcInstName) == 0))\r
                         {\r
                             /* Remove the leftNode from the tree for editing */\r
                             RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
@@ -693,7 +693,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             /* 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
-                                                              opInfo->srcInstName);\r
+                                                              opInfo->serviceSrcInstName);\r
                         }\r
 \r
                         /* Account for the leftNode in the matchingNode */\r
@@ -710,7 +710,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         \r
                         /* Can the node to the right of the matchingNode be combined with the \r
                          * findNode's range? */\r
-                        if (rightNode && (strcmp(rightNode->allocatedTo, opInfo->srcInstName) == 0))\r
+                        if (rightNode && (strcmp(rightNode->allocatedTo, opInfo->serviceSrcInstName) == 0))\r
                         {\r
                             /* Remove the rightNode from the tree for editing */\r
                             RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
@@ -724,7 +724,7 @@ int32_t Rm_treeAllocate(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             /* 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
-                                                               opInfo->srcInstName);\r
+                                                               opInfo->serviceSrcInstName);\r
                         }\r
 \r
                         /* Account for the rightNode in the matchingNode */\r
@@ -792,7 +792,7 @@ int32_t Rm_treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
          * then attempts to free a contiguous subset of the allocated block. */\r
         if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd))\r
         {            \r
-            if (strcmp(matchingNode->allocatedTo, opInfo->srcInstName) == 0)\r
+            if (strcmp(matchingNode->allocatedTo, opInfo->serviceSrcInstName) == 0)\r
             {\r
                 /* Resources can be freed */\r
 \r
@@ -1119,7 +1119,7 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
         /* Fill out the allocator operation general information */\r
         opInfo.resourceInfo = &transaction->resourceInfo;\r
-        opInfo.srcInstName = transaction->sourceInstName;\r
+        opInfo.serviceSrcInstName = transaction->serviceSrcInstName;\r
 \r
         if (strlen(transaction->resourceInfo.nsName) > 0)\r
         {\r
@@ -1163,7 +1163,7 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
         }\r
 \r
         /* Call allocator as long as an error or denial hasn't occurred */\r
-        if (retVal == RM_SERVICE_PROCESSING)\r
+        if ((retVal == RM_SERVICE_PROCESSING) || (retVal == RM_NS_ACTION_APPROVED))\r
         {\r
             opInfo.operation = Rm_allocatorOp_ALLOCATE;\r
 \r
@@ -1172,7 +1172,7 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
         transaction->state = retVal;\r
 \r
-        if (strcmp(transaction->sourceInstName, rmInst->name))\r
+        if (strcmp(transaction->serviceSrcInstName, rmInst->name))\r
         {\r
             /* Source of allocation was not the server instance, provide the transaction\r
              * to the transaction responder */\r
@@ -1228,6 +1228,9 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {\r
     Rm_AllocatorOpInfo opInfo;\r
     int32_t retVal = transaction->state;\r
+\r
+    /* Initialize the opInfo structure */\r
+    memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
     \r
     if (rmInst->instType == Rm_instType_CLIENT_DELEGATE)\r
     {\r
@@ -1276,7 +1279,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
         /* Fill out the allocator operation general information */\r
         opInfo.resourceInfo = &transaction->resourceInfo;\r
-        opInfo.srcInstName = transaction->sourceInstName;\r
+        opInfo.serviceSrcInstName = transaction->serviceSrcInstName;\r
 \r
         if (strlen(transaction->resourceInfo.nsName) > 0)\r
         {\r
@@ -1295,7 +1298,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
         }\r
         \r
         /* Call allocator as long as an error or denial hasn't occurred */\r
-        if (retVal == RM_SERVICE_PROCESSING)\r
+        if ((retVal == RM_SERVICE_PROCESSING) || (retVal == RM_NS_ACTION_APPROVED))\r
         {\r
             opInfo.operation = Rm_allocatorOp_FREE;\r
 \r
@@ -1304,7 +1307,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
         transaction->state = retVal;\r
 \r
-        if (strcmp(transaction->sourceInstName, rmInst->name))\r
+        if (strcmp(transaction->serviceSrcInstName, rmInst->name))\r
         {\r
             /* Source of allocation was not the server instance, provide the transaction\r
              * to the transaction responder */\r
@@ -1350,7 +1353,7 @@ void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
     Rm_Packet *rmPkt = NULL;\r
 \r
     /* Find the transport for the RM instance that sent the request. */\r
-    dstTransportNode = Rm_transportNodeFindRemoteName(rmInst, transaction->sourceInstName);\r
+    dstTransportNode = Rm_transportNodeFindRemoteName(rmInst, transaction->pktSrcInstName);\r
 \r
     /* Create a RM packet using the service information */\r
     switch (transaction->type)\r
@@ -1499,7 +1502,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
             /* A transaction has received a response. Send the response to either the \r
              * transaction or service responder based on the source instance */\r
-            if (strcmp(transaction->sourceInstName, rmInst->name))\r
+            if (strcmp(transaction->serviceSrcInstName, rmInst->name))\r
             {\r
                 /* Transaction originated from another instance.  Use the \r
                  * transaction responder to send the result to the source instance.  This\r
@@ -1532,7 +1535,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                     /* If source instance name does not match the current instance\r
                      * name the allocation request came from a client.  The result\r
                      * must be sent back to the Client */\r
-                    if (strcmp(transaction->sourceInstName, rmInst->name))\r
+                    if (strcmp(transaction->serviceSrcInstName, rmInst->name))\r
                     {\r
                         Rm_transactionResponder(rmInst, transaction);\r
                     }\r
@@ -1614,7 +1617,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                      * result must be sent back to the Client or Client Delegate.  Just return if it does\r
                      * match since the NameServer transaction result can be returned immediately by the\r
                      * Rm_serviceHandler. */\r
-                    if (strcmp(transaction->sourceInstName, rmInst->name))\r
+                    if (strcmp(transaction->serviceSrcInstName, rmInst->name))\r
                     {\r
                         Rm_transactionResponder(rmInst, transaction);\r
                     }\r
@@ -1699,7 +1702,7 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
     strcpy(resourceInfo.name, resourceName);\r
 \r
     /* Set the source instance name for allocation to be the Linux Kernel */\r
-    opInfo.srcInstName = RM_ALLOCATED_TO_LINUX;\r
+    opInfo.serviceSrcInstName = RM_ALLOCATED_TO_LINUX;\r
     opInfo.operation = Rm_allocatorOp_ALLOCATE;\r
     opInfo.resourceInfo = &resourceInfo;    \r
 \r
@@ -1830,6 +1833,7 @@ int32_t Rm_createAndInitAllocator(Rm_Inst *rmInst, const char *resourceName,
             {\r
                 memset((void *)&resourceInfo, 0, sizeof(Rm_ResourceInfo));\r
 \r
+                strcpy(resourceInfo.name, resourceName);\r
                 resourceInfo.base = nsAssignments->resourceBase;\r
                 resourceInfo.length = nsAssignments->resourceLength;\r
                 strcpy(resourceInfo.nsName, nsAssignments->nsName);\r
index 84bb331a477d676c3db883d4cb28bce692560949..20740c996e5a5da2238476955cf52fe3d0f444b0 100644 (file)
@@ -59,8 +59,8 @@
  ************** Red-Black BBST Tree NameServer Functions **************
  **********************************************************************/
 
-Rm_NameServerNode *Rm_newNameServerNode(char *name, uint32_t resourceBase, 
-                                        uint32_t resourceLength)
+Rm_NameServerNode *Rm_newNameServerNode(char *name, char *resourceName,
+                                        uint32_t resourceBase, uint32_t resourceLength)
 {
     Rm_NameServerNode *newNode = NULL;
 
@@ -68,6 +68,7 @@ Rm_NameServerNode *Rm_newNameServerNode(char *name, uint32_t resourceBase,
 
     /* Populate the node */
     strcpy(newNode->name, name);
+    strcpy(newNode->resourceName, resourceName); 
     newNode->base = resourceBase;
     newNode->length = resourceLength;
     
@@ -114,8 +115,8 @@ int32_t Rm_nsAddObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo)
     Rm_NameServerNode *newNode = NULL;
     Rm_NameServerNode *collidingNode = NULL;
 
-    newNode = Rm_newNameServerNode(resourceInfo->nsName, resourceInfo->base,
-                                   resourceInfo->length);
+    newNode = Rm_newNameServerNode(resourceInfo->nsName, resourceInfo->name,
+                                   resourceInfo->base, resourceInfo->length);
 
     /* Try to insert the new name */
     collidingNode = RB_INSERT(_Rm_NameServerTree, rmInst->nameServer, newNode);
@@ -135,7 +136,8 @@ void Rm_nsPrintObjects(Rm_Inst *rmInst)
 
     RB_FOREACH(node, _Rm_NameServerTree, rmInst->nameServer)
     {               
-        Rm_osalLog("Name: %s base: %d length: %d\n", node->name, node->base, node->length);
+        Rm_osalLog("Name: %s resourceName: %s base: %d length: %d\n", node->name, node->resourceName,
+                                                                      node->base, node->length);
     }
 }
 
@@ -152,6 +154,7 @@ int32_t Rm_nsFindObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo)
     if (matchingNode)
     {
         /* Copy the name's resource information */
+        strcpy(resourceInfo->name, matchingNode->resourceName);
         resourceInfo->base = matchingNode->base;
         resourceInfo->length = matchingNode->length;
     }
index a85ab9b8a23a001466195ee9093078553f95b116..dd85f95a0fa8f781bb05de2e0c13b21b979c9754 100644 (file)
@@ -85,7 +85,7 @@ void Rm_serviceHandler (void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
     {
         /* Transfer request information into the transaction */
         transaction->type = serviceRequest->type;
-        strcpy(transaction->sourceInstName, rmInst->name);
+        strcpy(transaction->serviceSrcInstName, rmInst->name);
         transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
         transaction->state = RM_SERVICE_PROCESSING;
         strcpy(&(transaction->resourceInfo.name)[0], serviceRequest->resourceName);
@@ -113,6 +113,7 @@ void Rm_serviceHandler (void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
             if ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||
                 (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))
             {
+                strcpy(serviceResponse->resourceName, transaction->resourceInfo.name);
                 serviceResponse->resourceBase = transaction->resourceInfo.base;
                 serviceResponse->resourceLength = transaction->resourceInfo.length;
             }
@@ -151,6 +152,7 @@ void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
         ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||
          (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))
     {
+        strcpy(serviceResponse.resourceName, transaction->resourceInfo.name);
         serviceResponse.resourceBase = transaction->resourceInfo.base;
         serviceResponse.resourceLength = transaction->resourceInfo.length;
     }
index 3ebd5a5511814871127e848cd164924de34dac4f..091870522ade5d9e4dd986ff638a3d65f31a1254 100644 (file)
@@ -269,7 +269,9 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
     {\r
         resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;\r
     }\r
-    strcpy(&(resourceReqPkt->instName)[0], rmInst->name);\r
+    /* Pass along the packet source and service source information */\r
+    strcpy(resourceReqPkt->pktSrcInstName, rmInst->name);\r
+    strcpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
     /* Copy the resource data */\r
     memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
@@ -353,7 +355,9 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
     {\r
         nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;\r
     }\r
-    strcpy(&(nsReqPkt->instName)[0], rmInst->name);\r
+    /* Pass along the packet source and service source information */\r
+    strcpy(nsReqPkt->pktSrcInstName, rmInst->name);\r
+    strcpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
     /* Copy the NameServer request data */\r
     memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
@@ -550,7 +554,8 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
                 transaction->type = Rm_service_RESOURCE_GET_BY_NAME;\r
             }            \r
 \r
-            strcpy(transaction->sourceInstName, resourceReqPkt->instName);\r
+            strcpy(transaction->pktSrcInstName, resourceReqPkt->pktSrcInstName);\r
+            strcpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName);\r
             transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));\r
@@ -606,8 +611,9 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
                 transaction->type = Rm_service_RESOURCE_UNMAP_NAME;\r
             }\r
 \r
-            strcpy(transaction->sourceInstName, nsRequestPkt->instName);\r
-            transaction->state = Rm_transactionState_PROCESSING;\r
+            strcpy(transaction->pktSrcInstName, nsRequestPkt->pktSrcInstName);\r
+            strcpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName);\r
+            transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(nsRequestPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));\r
 \r
index 916408433543ee848c07e36edb8f14ec5e8398a2..1a9623b44d7ee66a1f5ee9ef69b243aa5daef59c 100644 (file)
@@ -357,6 +357,7 @@ void testServiceCallback(Rm_ServiceRespInfo *serviceResponse)
     if (serviceResponse->serviceId == waitForBlockingOperation)
     {
         waitForBlockingOperation = 0;
+        strcpy(responseInfo.resourceName, serviceResponse->resourceName);
         responseInfo.resourceBase = serviceResponse->resourceBase;
         responseInfo.resourceLength = serviceResponse->resourceLength;
         responseInfo.serviceState = serviceResponse->serviceState;
@@ -514,6 +515,9 @@ void testRmTsk(UArg arg0, UArg arg1)
         char resourceName[RM_RESOURCE_NAME_MAX_CHARS] = "gp-queue";
         char resourceNsName[RM_RESOURCE_NAME_MAX_CHARS] = "My_Favorite_Queue";
 
+        char aifName[RM_RESOURCE_NAME_MAX_CHARS] = "aif-rx-ch";
+        char memRegionName[RM_RESOURCE_NAME_MAX_CHARS] = "memory-regions";
+
         /* Issue the service request create a new NameServer object via the service port */                
         requestInfo.type = Rm_service_RESOURCE_MAP_TO_NAME;
         requestInfo.resourceName = resourceName;
@@ -526,17 +530,143 @@ void testRmTsk(UArg arg0, UArg arg1)
         rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
-            System_printf("Core %d: %s created Name: %s base: %d length: %d\n", MultiProc_self(),
-                                                                                rmServerName,
-                                                                                resourceNsName, 
-                                                                                requestInfo.resourceBase,
-                                                                                requestInfo.resourceLength);            
+            System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                             rmServerName,
+                                                                                             resourceNsName, 
+                                                                                             requestInfo.resourceBase,
+                                                                                             requestInfo.resourceLength);            
         }
 
         /* Wait for Client Delegate and Client to retrieve resource via the name and allocate it */
         waitOnSyncObj();
 
         Rm_printResourceStatus(rmServerHandle);
+
+        /* Wait for Client to free resource via the NameServer and delete the NameServer object. */
+        waitOnSyncObj();
+
+        Rm_printResourceStatus(rmServerHandle);
+
+        /* Try to allocate the memory region taken by the Linux Kernel */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
+        requestInfo.resourceName = memRegionName;
+        requestInfo.resourceBase = 12;
+        requestInfo.resourceLength = 1;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Trying to reserve memory region taken by Linux...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
+                                                                                                          rmServerName,
+                                                                                                          requestInfo.resourceName, 
+                                                                                                          requestInfo.resourceBase,
+                                                                                                          requestInfo.resourceLength);            
+        }  
+
+        /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 14;
+        requestInfo.resourceLength = 5;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmServerName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }    
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 19;
+        requestInfo.resourceLength = 31;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmServerName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }            
+        
+        /* Wait for Client and Client Delegate to do their allocates */
+        waitOnSyncObj();
+
+        Rm_printResourceStatus(rmServerHandle);        
+
+        /* Free resources to show tree handling of different frees */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_FREE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 25;
+        requestInfo.resourceLength = 3;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmServerName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }            
+        
+        Rm_printResourceStatus(rmServerHandle);   
+        
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_FREE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 34;
+        requestInfo.resourceLength = 3;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmServerName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }            
+        
+        Rm_printResourceStatus(rmServerHandle);           
+     
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_FREE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 28;
+        requestInfo.resourceLength = 6;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
+        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmServerName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }            
+        
+        Rm_printResourceStatus(rmServerHandle);           
         
     }
     else if (MultiProc_self() == 1)
@@ -544,15 +674,15 @@ void testRmTsk(UArg arg0, UArg arg1)
         char resourceName[RM_RESOURCE_NAME_MAX_CHARS] = "gp-queue";
         char resourceNsName[RM_RESOURCE_NAME_MAX_CHARS] = "My_Favorite_Queue";
 
-        /* Take the sync obj preparing for NameServer testing */
-        takeSyncObj();    
+        char aifName[RM_RESOURCE_NAME_MAX_CHARS] = "aif-rx-ch";        
 
         /* Issue the service request for the resources tied to the name via the service port */                
         requestInfo.type = Rm_service_RESOURCE_GET_BY_NAME;
-        requestInfo.resourceNsName = &resourceNsName[0];
+        requestInfo.resourceNsName = resourceNsName;
         requestInfo.callback.serviceCallback = testServiceCallback;
         
-        System_printf("Core %d: %s getting NameServer object...\n", MultiProc_self(), rmClientDelegateName);
+        System_printf("Core %d: %s getting resources tied to NameServer object...\n", MultiProc_self(), 
+                                                                                      rmClientDelegateName);
         rmClientDelegateServicePort->rmService(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
@@ -565,7 +695,7 @@ void testRmTsk(UArg arg0, UArg arg1)
 
         /* Allocate the resources via the service port from the Client */
         requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
-        requestInfo.resourceName = resourceName;
+        requestInfo.resourceName = responseInfo.resourceName;
         requestInfo.resourceBase = responseInfo.resourceBase;
         requestInfo.resourceLength = responseInfo.resourceLength;
         requestInfo.resourceNsName = NULL;
@@ -582,8 +712,88 @@ void testRmTsk(UArg arg0, UArg arg1)
                                                                                        responseInfo.resourceLength);
         }
 
-        /* Release the syncObj so Server can move forward with NameServer object testing */
-        releaseSyncObj();        
+        /* Release the syncObj so Server can print results of NameServer object add and resource allocate */
+        releaseSyncObj();
+
+        /* Take the syncObj to free the name resource via the name, rather than the base+length */
+        takeSyncObj();
+
+        /* Free the named resource using the name via the service port from the Client */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+        requestInfo.type = Rm_service_RESOURCE_FREE;
+        requestInfo.resourceNsName = resourceNsName;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s freeing resource via name...\n", MultiProc_self(), rmClientName);
+        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
+                                                                        rmClientName, 
+                                                                        resourceNsName);
+        }
+
+        /* Delete the name object from the NameServer */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+        requestInfo.type = Rm_service_RESOURCE_UNMAP_NAME;
+        requestInfo.resourceNsName = resourceNsName;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Deleting NameServer object: %s...\n", MultiProc_self(), 
+                                                                         rmClientName,
+                                                                         resourceNsName);
+        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
+                                                                         rmClientName, 
+                                                                         resourceNsName);
+        }
+
+        /* Release the syncObj so Server can print results of resource free and NameServer object delete. */
+        releaseSyncObj();   
+
+        /* Take the syncObj to allocate resources for testing resource tree interactions. */
+        takeSyncObj();
+
+        /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 0;
+        requestInfo.resourceLength = 6;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
+        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmClientName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }     
+        memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
+        requestInfo.type = Rm_service_RESOURCE_ALLOCATE;
+        requestInfo.resourceName = aifName;
+        requestInfo.resourceBase = 50;
+        requestInfo.resourceLength = 7;
+        requestInfo.callback.serviceCallback = testServiceCallback;
+        
+        System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
+        rmClientDelegateServicePort->rmService(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
+        if (blockForResponse(&responseInfo))
+        {
+            System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+                                                                                      rmClientDelegateName,
+                                                                                      requestInfo.resourceName, 
+                                                                                      requestInfo.resourceBase,
+                                                                                      requestInfo.resourceLength);            
+        }  
+
+        /* Release the syncObj so Server can print results of resource allocations */
+        releaseSyncObj();          
     }
 
     System_printf("Core %d: Testing is complete\n", MultiProc_self());
@@ -609,6 +819,12 @@ Void startupRmTsk(UArg arg0, UArg arg1)
     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
     Task_Params taskParams;
 
+    if (MultiProc_self() == 1)
+    {
+        /* Take the syncObj on core 1, preparing for RM testing */
+        takeSyncObj();  
+    }
+
     /* Initialize the transport map */
     for (i = 0; i < MAX_MAPPING_ENTRIES; i++)
     {
@@ -951,7 +1167,7 @@ Int main(Int argc, Char* argv[])
         rmServerHandle = Rm_init(&rmInitCfg);
         System_printf("Core %d: RM Server instance created\n", MultiProc_self());
 
-     //   Rm_printResourceStatus(rmServerHandle);
+        Rm_printResourceStatus(rmServerHandle);
     }
     else if (MultiProc_self()== 1)
     {