Cleaned up transport API
authorJustin Sobota <jsobota@ti.com>
Wed, 30 Jan 2013 20:59:02 +0000 (15:59 -0500)
committerJustin Sobota <jsobota@ti.com>
Wed, 30 Jan 2013 20:59:02 +0000 (15:59 -0500)
16 files changed:
include/rm_loc.h
include/rm_transportloc.h
include/rm_treeloc.h
rm.h
rm_transport.h
setupenv.bat
src/rm.c
src/rm_dtb_util.c
src/rm_nameserver.c
src/rm_policy.c
src/rm_services.c
src/rm_transport.c
src/rm_tree.c
test/rm_test.c
util/libfdt/fdt.h
util/libfdt/libfdt_env.h

index 9e7832b537731c8aaab77157be33aec5c4b25c74..c4e3641eedcf05d517b56803a874b19fb352cca2 100644 (file)
@@ -157,7 +157,7 @@ typedef struct {
     void                   *transports;
     uint32_t                transactionSeqNum;
     Rm_Transaction         *transactionQueue;
-    Rm_TransportCallouts    transport;
+    Rm_TransportCallouts    transportCallouts;
 } Rm_Inst;
 
 Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
index a9456a6b4db742526f218520e61b40ae24b8a748..8c7f19f5e5151dc1189c83e3c9d0a111972b43c7 100644 (file)
@@ -46,10 +46,30 @@ extern "C" {
 
 /* RM external includes */
 #include <ti/drv/rm/rm.h>
+#include <ti/drv/rm/rm_transport.h>
 
 /* RM internal includes */
 #include <ti/drv/rm/include/rm_loc.h>
 
+/* This macro generates compilier error if postulate is false, so 
+ * allows 0 overhead compile time size check.  This "works" when
+ * the expression contains sizeof() which otherwise doesn't work
+ * with preprocessor */
+#define RM_COMPILE_TIME_SIZE_CHECK(postulate)                           \
+   do {                                                                 \
+       typedef struct {                                                 \
+         uint8_t NegativeSizeIfPostulateFalse[((int)(postulate))*2 - 1];\
+       } PostulateCheck_t;                                              \
+   }                                                                    \
+   while (0)
+
+/* Check assumptions RM request/response packets fit in RM_TRANSPORT_PACKET_MAX_SIZE_BYTES */
+#define RM_PACKET_SIZE_CHECK \
+    RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceRequestPkt)); \
+    RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceResponsePkt)); \
+    RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsRequestPkt)); \
+    RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsResponsePkt)); \
+
 /**
  * @brief RM transport routing map linked list node.  The created 
  *        transport nodes are provided to the application casted
@@ -57,11 +77,13 @@ extern "C" {
  */
 typedef struct Rm_Transport_s {
     /** The RM instance that this node belongs to */
-    Rm_Handle rmHandle;
+    Rm_Handle              rmHandle;
+    /** The application transport handle */
+    Rm_AppTransportHandle  appTransportHandle;
     /** The remote RM instance type */
-    Rm_InstType remoteInstType;
+    Rm_InstType            remoteInstType;
     /** The remote RM instance name */
-    char remoteInstName[RM_NAME_MAX_CHARS];
+    char                   remoteInstName[RM_NAME_MAX_CHARS];
     /** Link to the next route node in the route map list */
     struct Rm_Transport_s *nextTransport;
 } Rm_Transport;
@@ -129,7 +151,7 @@ typedef enum {
     /** Request to map the specified name to the specified resources */
     Rm_nsReqPktType_MAP_RESOURCE = 0,
     /** Request to unmap the specified name from the specifed resources */
-    Rm_nsReqPktType_UNMAP_RESOURCE = 1
+    Rm_nsReqPktType_UNMAP_RESOURCE
 } Rm_NsReqPktType;
 
 /** 
@@ -167,14 +189,14 @@ typedef struct {
 
 Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName);
 Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType);
-Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode,
-                                           Rm_Transaction *transaction);
-Rm_Packet *rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode,
+Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
                                                 Rm_Transaction *transaction);
-Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode,
-                                         Rm_Transaction *transaction);
-Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode,
-                                          Rm_Transaction *transaction);
+Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
+                                                     Rm_Transaction *transaction);
+Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
+                                              Rm_Transaction *transaction);
+Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
+                                               Rm_Transaction *transaction);
 
 #ifdef __cplusplus
 }
index 080408f20b300db9db04aca75a9d874098c3b21f..a8e4c619afba9a65978f8fc0bb6eedc88ed642d8 100644 (file)
@@ -103,25 +103,25 @@ typedef RB_HEAD(_Rm_AllocatorResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
  ****************** Tree Node Function Definitions ********************
  **********************************************************************/
 
-Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg);
-void nameServerNodeFree(Rm_NameServerNode *node);
-int nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); 
+Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg);
+void rmNameServerNodeFree(Rm_NameServerNode *node);
+int rmNameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); 
 
-Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName);
-void policyValidInstNodeFree(Rm_PolicyValidInstNode *node);
-int policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); 
+Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName);
+void rmPolicyValidInstNodeFree(Rm_PolicyValidInstNode *node);
+int rmPolicyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); 
 
-Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength);
-void resourceNodeFree(Rm_ResourceNode *node);
-int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2); 
+Rm_ResourceNode *rmResourceNodeNew(uint32_t resourceBase, uint32_t resourceLength);
+void rmResourceNodeFree(Rm_ResourceNode *node);
+int rmResourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2); 
 
 /**********************************************************************
  ******************** Tree Prototype Generation ***********************
  **********************************************************************/
  
-RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, nameServerNodeCompare)
-RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, policyValidInstNodeCompare)
-RB_PROTOTYPE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, resourceNodeCompare)
+RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, rmNameServerNodeCompare)
+RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, rmPolicyValidInstNodeCompare)
+RB_PROTOTYPE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, rmResourceNodeCompare)
 
 #ifdef __cplusplus
 }
diff --git a/rm.h b/rm.h
index a414acb3dcac7d10bb964082e3b4f277c2522597..e5e0ebed3ae1cf803c5d8a927b0ef28de783c7ff 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -192,9 +192,6 @@ extern "C" {
 #define RM_SERVICE_ERROR_TRANSPORT_PKT_ALLOC_API_NULL (RM_SERVICE_ERROR_BASE-4)
 /** A failure occurred within a registered transport's packet alloc API */
 #define RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR (RM_SERVICE_ERROR_BASE-5)
-/** RM service request needs to be forwarded but the buffer allocated by transport
- *  is not large enough to fit the RM transport packet */
-#define RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL (RM_SERVICE_ERROR_BASE-6)
 /** RM service request needs to be forwarded but the transport returned an error
  *  when trying to send the RM packet to the higher level agent */
 #define RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR (RM_SERVICE_ERROR_BASE-7)
@@ -234,6 +231,12 @@ extern "C" {
 #define RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-5)
 /** RM NameServer request transaction could not be found matching the response received */
 #define RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-6)
+/** RM server cannot connect to other servers and CDs cannot connect to other CDs */
+#define RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE (RM_TRANSPORT_ERROR_BASE-7)
+/** RM clients can't register with more than one Server or CD.  CDs can't register with more than one Server */
+#define RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD (RM_TRANSPORT_ERROR_BASE-8)
+/** Transport callouts provided to RM were specified as valid but NULL was provided */
+#define RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED (RM_TRANSPORT_ERROR_BASE-10)
 
 /** 
  * @brief Maximum number of characters allowed for RM instance, resource, and
index 4fa569dfe982afee666296df83ebc2a25547c751..fc42ca7cf752be7999f8ab00148148fdd166191d 100644 (file)
@@ -66,6 +66,13 @@ extern "C" {
  */
 typedef void *Rm_TransportHandle;
 
+/**
+ * @brief Application transport handle
+ */
+typedef void *Rm_AppTransportHandle; 
+
+typedef void *Rm_PacketHandle;
+
 /**
  * @brief RM packet types that can be sent between RM instances
  */
@@ -114,31 +121,11 @@ typedef struct {
      *  @retval
      *      Failure - NULL
      */
-    Rm_Packet *(*rmAllocPkt)(Rm_TransportHandle transportHandle, uint32_t pktSize);
-    
-    /**
-     *  @b Description
-     *  @n  
-     *      This function pointer describes the RM transport layer packet 
-     *      free function.  The application which integrates with RM must 
-     *      supply a function to RM at initialization time that matches this  
-     *      prototype.  The provided function implements the free of packet
-     *      buffers used by the RM transport for sending/receiving messages 
-     *      between RM instances in the SOC.
-     *
-     *  @param[in]  transportHandle
-     *      Which application transport to free the packet to.
-     *
-     *  @param[in]  pkt
-     *      Pointer to resource packet to be freed.
-     *
-     *  @retval
-     *      0 - Packet free okay.
-     *  @retval
-     *      Non-zero - Send failed.
-     */
-    int32_t (*rmFreePkt)(Rm_TransportHandle transportHandle, Rm_Packet *pkt);
-    
+
+    /* Rm_Packet * and pktHandle cannot be NULL.  They will either be different or the same
+     * value based on the transport */
+    Rm_Packet *(*rmAllocPkt)(Rm_AppTransportHandle appTransport, uint32_t pktSize, 
+                             Rm_PacketHandle *pktHandle);    
     /**
      *  @b Description
      *  @n  
@@ -159,46 +146,7 @@ typedef struct {
      *  @retval
      *      Non-zero - Send failed.
      */
-    int32_t (*rmSend)(Rm_TransportHandle transportHandle, Rm_Packet *pkt);
-    
-    /**
-     *  @b Description
-     *  @n  
-     *      This function pointer describes the RM transport layer receive 
-     *      function. The application which integrates with RM must supply a 
-     *      function to RM at initialization time that matches this prototype.
-     *      The provided function implements the receive side of the transport 
-     *      between RM instances on different cores in the SOC.
-     *
-     *  @param[in]  transportHandle
-     *      Which application transport to retrieve a packet from
-     *
-     *  @retval
-     *      Non-NULL - Pointer to received RM packet.
-     *  @retval
-     *      NULL - Packet receive failed.
-     */
-    void * (*rmReceive)(Rm_TransportHandle transportHandle);
-    
-    /**
-     *  @b Description
-     *  @n  
-     *      This function pointer describes the RM transport layer number of
-     *      packets received function. The application which integrates with RM 
-     *      must supply a function to RM at initialization time that matches this 
-     *      prototype.  The provided function implements a query of the number of
-     *      RM packets received on a specified transport.
-     *
-     *  @param[in]  transportHandle
-     *      Which application transport to check for received packets.
-     *
-     *  @retval
-     *      Success -   Number of packets received over transport interfaces for
-     *                  a RM instance.
-     *  @retval
-     *      Failure -   -1
-     */
-    int32_t (*rmNumPktsReceived)(Rm_TransportHandle transportHandle);
+    int32_t (*rmSendPkt)(Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle);
 } Rm_TransportCallouts;
 
 /** 
@@ -206,24 +154,27 @@ typedef struct {
  */
 typedef struct {
     /** The RM Handle for which the transport is being registered */
-    Rm_Handle rmHandle;
+    Rm_Handle              rmHandle;
+    /** The Application transport handle associated with the registered
+     *  transport */
+    Rm_AppTransportHandle  appTransportHandle;
     /** The transport's remote RM instance type */
-    Rm_InstType remoteInstType;
+    Rm_InstType            remoteInstType;
     /** Pointer to the transport's remote RM instance name */
-    char *remoteInstName;
+    char                  *remoteInstName;
     /** Used to specify whether the transport callouts are valid.
      *  TRUE - Transport callouts are valid and will be stored by the RM
      *         instance.
      *  FALSE - Transport callouts are not valid and will not be stored by
      *          the RM instance. */
-    bool transportCalloutsValid;
+    bool                   transportCalloutsValid;
     /** Pointers to application implemented transport APIs.  The APIs for the
      *  provided functions must match the prototypes defined in the
      *  Rm_TransportCallouts structure.  Callouts will typically only be defined
      *  for the first transport registered with an RM instance.  The 
      *  transportCalloutsValid field can be used to disable RM instance's from
      *  reading in new callout values are they're specified once. */
-    Rm_TransportCallouts transportCallouts;   
+    Rm_TransportCallouts   transportCallouts;   
 } Rm_TransportCfg;
 
 /**
@@ -250,11 +201,10 @@ typedef struct {
  *  @retval
  *      Failure - NULL
  */
-Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result);
-int32_t Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandle transportHandle);
-int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt);
-int32_t Rm_receivePktPolling(Rm_TransportHandle transportHandle);
-
+Rm_TransportHandle Rm_transportRegister(Rm_TransportCfg *transportCfg, int32_t *result);
+int32_t Rm_transportUnregister (Rm_TransportHandle transportHandle);
+/* Application will always free the packet */
+int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, Rm_Packet *pkt);
 
 /** 
 @} 
index 2612c0fdefc561044c293275230434c8eba28613..f5a6564224a147cf3d6d07fd6c764b093c1e7501 100644 (file)
@@ -57,7 +57,7 @@ set PATH=%XDC_INSTALL_PATH%;%XDC_INSTALL_PATH%\bin;T:\Doxygen\doxygen\1.5.1-p1\b
 @REM Third Party Tools: Install-Jammer (Not required by customers)\r
 set PATH=%PATH%;T:\gen\InstallJammer\v1_2_05\r
 \r
-set PATH=%PATH%;%XDCCGROOT%\bin;T:\gen\gnu\99-11-01\cygwin-b20\H-i586-cygwin32\bin\r
+set PATH=%PATH%;%XDCCGROOT%\bin\r
 set PATH=%PATH%;T:\SDOApps\cg_xml\cg_xml_v2_20_00\bin\r
 set PATH=%PATH%;T:\ti_pdsp_cgen\20091120\r
 \r
index b03ccddad431f9e93ef57388e5cc2f17cc1ad807..1baa97ff2d0d1e17b0858751ed4f80e9dfbc0421 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -91,7 +91,7 @@ Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst)
         newTransaction->localId = rmTransactionGetSequenceNum(rmInst);\r
         newTransaction->nextTransaction = NULL;  \r
         if (transactionQueue) {\r
-            while (transactionQueue->nextTransaction != NULL) {\r
+            while (transactionQueue->nextTransaction) {\r
                 transactionQueue = transactionQueue->nextTransaction;\r
             }\r
             transactionQueue->nextTransaction = newTransaction;\r
@@ -107,14 +107,13 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
 {\r
     Rm_Transaction *transaction = rmInst->transactionQueue;\r
 \r
-    if (transaction != NULL) {\r
-        while (transaction != NULL) {\r
-            if (transaction->localId == transactionId) {\r
-                break;             \r
-            }\r
-            transaction = transaction->nextTransaction;\r
+    while (transaction) {\r
+        if (transaction->localId == transactionId) {\r
+            break;             \r
         }\r
+        transaction = transaction->nextTransaction;\r
     }\r
+\r
     return (transaction);\r
 }\r
 \r
@@ -188,7 +187,7 @@ Rm_Allocator *rmAllocatorAdd(Rm_Inst *rmInst, const char *resourceName)
 \r
         /* Add allocator to end of list */\r
         if (allocators) {\r
-            while (allocators->nextAllocator != NULL) {\r
+            while (allocators->nextAllocator) {\r
                 allocators = allocators->nextAllocator;\r
             }\r
             allocators->nextAllocator = newAllocator;\r
@@ -391,7 +390,7 @@ int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Reso
     RB_INIT(treeRootEntry);\r
 \r
     while (range != NULL) {\r
-        treeNode = resourceNodeNew(range->base, range->length);\r
+        treeNode = rmResourceNodeNew(range->base, range->length);\r
         collidingNode = RB_INSERT(_Rm_AllocatorResourceTree, treeRootEntry, treeNode);\r
 \r
         if (collidingNode) {\r
@@ -401,7 +400,7 @@ int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Reso
             for (treeNode = RB_MIN(_Rm_AllocatorResourceTree, treeRootEntry); treeNode != NULL; treeNode = nextNode) {\r
                        nextNode = RB_NEXT(_Rm_AllocatorResourceTree, treeRootEntry, treeNode);\r
                        RB_REMOVE(_Rm_AllocatorResourceTree, treeRootEntry, nextNode);\r
-                resourceNodeFree(treeNode);\r
+                rmResourceNodeFree(treeNode);\r
                }\r
             Rm_osalFree((void *)treeRootEntry, sizeof(Rm_ResourceTree));\r
             rmAllocatorDelete(rmInst, allocator->resourceName);\r
@@ -623,9 +622,9 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                         matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;\r
 \r
                         rmClearOwners(leftNode);\r
-                        resourceNodeFree(leftNode);\r
+                        rmResourceNodeFree(leftNode);\r
                         rmClearOwners(rightNode);\r
-                        resourceNodeFree(rightNode);                        \r
+                        rmResourceNodeFree(rightNode);                        \r
                     }\r
                     else if (combineLeft) {\r
                         /* Combine left and matching nodes.  Reinsert right. */\r
@@ -633,7 +632,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                         matchingNode->length += leftNode->length;\r
 \r
                         rmClearOwners(leftNode);\r
-                        resourceNodeFree(leftNode);\r
+                        rmResourceNodeFree(leftNode);\r
                         RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
                     }\r
                     else if (combineRight) {\r
@@ -641,7 +640,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                         matchingNode->length += rightNode->length;\r
 \r
                         rmClearOwners(rightNode);\r
-                        resourceNodeFree(rightNode);\r
+                        rmResourceNodeFree(rightNode);\r
                         RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                     }\r
                     else {\r
@@ -661,9 +660,9 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                      *        |<---alloc request--->|\r
                      */ \r
                     RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    leftNode = resourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);\r
+                    leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);\r
                     rmCopyOwners(leftNode, matchingNode);\r
-                    rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
+                    rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
                     rmCopyOwners(rightNode, matchingNode);\r
 \r
                     matchingNode->base = findNode.base;                                    \r
@@ -694,7 +693,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                             leftNode->length += findNode.length;\r
                         }\r
                         else {\r
-                            leftNode = resourceNodeNew(findNode.base, findNode.length);\r
+                            leftNode = rmResourceNodeNew(findNode.base, findNode.length);\r
                             rmCopyOwners(leftNode, matchingNode);\r
                         }\r
 \r
@@ -723,7 +722,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
                             rightNode->length += findNode.length;\r
                         }\r
                         else {\r
-                            rightNode = resourceNodeNew(findNode.base, findNode.length);\r
+                            rightNode = rmResourceNodeNew(findNode.base, findNode.length);\r
                             rmCopyOwners(rightNode, matchingNode);\r
                         }\r
 \r
@@ -802,9 +801,9 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;\r
 \r
                             rmClearOwners(leftNode);\r
-                            resourceNodeFree(leftNode);\r
+                            rmResourceNodeFree(leftNode);\r
                             rmClearOwners(rightNode);\r
-                            resourceNodeFree(rightNode);                        \r
+                            rmResourceNodeFree(rightNode);                        \r
                         }\r
                         else if (combineLeft) {\r
                             /* Combine left and matching nodes.  Reinsert right. */\r
@@ -812,7 +811,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             matchingNode->length += leftNode->length;\r
 \r
                             rmClearOwners(leftNode);\r
-                            resourceNodeFree(leftNode);\r
+                            rmResourceNodeFree(leftNode);\r
                             RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
                         }\r
                         else if (combineRight) {\r
@@ -820,7 +819,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                             matchingNode->length += rightNode->length;\r
 \r
                             rmClearOwners(rightNode);\r
-                            resourceNodeFree(rightNode);\r
+                            rmResourceNodeFree(rightNode);\r
                             RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         }\r
                         else {\r
@@ -845,12 +844,12 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                         RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
                         rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                         \r
-                        leftNode = resourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);\r
+                        leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);\r
                         rmCopyOwners(leftNode, matchingNode);\r
                         rmAddOwner(leftNode, opInfo->serviceSrcInstNode);\r
                         RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         \r
-                        rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
+                        rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
                         rmCopyOwners(rightNode, matchingNode);\r
                         rmAddOwner(rightNode, opInfo->serviceSrcInstNode);\r
                         RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
@@ -879,7 +878,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                                 leftNode->length += findNode.length;\r
                             }\r
                             else {\r
-                                leftNode = resourceNodeNew(findNode.base, findNode.length);\r
+                                leftNode = rmResourceNodeNew(findNode.base, findNode.length);\r
                                 rmCopyOwners(leftNode, matchingNode);\r
                             }\r
 \r
@@ -908,7 +907,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
                                 rightNode->length += findNode.length;\r
                             }\r
                             else {\r
-                                rightNode = resourceNodeNew(findNode.base, findNode.length);\r
+                                rightNode = rmResourceNodeNew(findNode.base, findNode.length);\r
                                 rmCopyOwners(rightNode, matchingNode);\r
                             }\r
 \r
@@ -1114,8 +1113,8 @@ void rmServiceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 /* Function used to send RM response transactions to lower level agents */\r
 void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
-    Rm_Transport *dstTransport = NULL;\r
-    Rm_Packet    *rmPkt = NULL;\r
+    Rm_Transport    *dstTransport = NULL;\r
+    Rm_PacketHandle  pktHandle = NULL;\r
 \r
     dstTransport = rmTransportFindRemoteName((Rm_Transport *) rmInst->transports, transaction->pktSrcInstName);\r
 \r
@@ -1124,22 +1123,20 @@ void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
         case Rm_service_RESOURCE_ALLOCATE_USE:\r
         case Rm_service_RESOURCE_FREE:\r
         case Rm_service_RESOURCE_GET_BY_NAME:\r
-            rmPkt = rmTransportCreateResourceResponsePkt(rmInst, dstTransport\r
-                                                          transaction);\r
+            pktHandle = rmTransportCreateResourceResponsePkt(rmInst, dstTransport->appTransportHandle\r
+                                                             transaction);\r
             break;\r
         case Rm_service_RESOURCE_MAP_TO_NAME:\r
         case Rm_service_RESOURCE_UNMAP_NAME:\r
-            rmPkt = rmTransportCreateNsResponsePkt(rmInst, dstTransport,\r
-                                                    transaction);\r
+            pktHandle = rmTransportCreateNsResponsePkt(rmInst, dstTransport->appTransportHandle,\r
+                                                       transaction);\r
             break;\r
     }\r
 \r
-    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
-        transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
-        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) {\r
-            transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
+    if (pktHandle) {\r
+        if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) {\r
+            transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
         }\r
-        return;\r
     }\r
     rmTransactionQueueDelete(rmInst, transaction->localId);\r
 }\r
@@ -1147,8 +1144,8 @@ void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 /* Function used to forward RM transactions to higher level agents */\r
 void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
-    Rm_Transport *dstTransport = NULL;\r
-    Rm_Packet    *rmPkt = NULL;\r
+    Rm_Transport    *dstTransport = NULL;\r
+    Rm_PacketHandle  pktHandle = NULL;\r
 \r
     if (rmInst->registeredWithDelegateOrServer == false) {\r
         transaction->state = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER;\r
@@ -1171,20 +1168,18 @@ void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
         case Rm_service_RESOURCE_ALLOCATE_USE:\r
         case Rm_service_RESOURCE_FREE:\r
         case Rm_service_RESOURCE_GET_BY_NAME:\r
-            rmPkt = rmTransportCreateResourceReqPkt(rmInst, dstTransport, transaction);\r
+            pktHandle = rmTransportCreateResourceReqPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
             break;\r
         case Rm_service_RESOURCE_MAP_TO_NAME:\r
         case Rm_service_RESOURCE_UNMAP_NAME:\r
-            rmPkt = rmTransportCreateNsRequestPkt(rmInst, dstTransport, transaction);\r
+            pktHandle = rmTransportCreateNsRequestPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
             break;\r
     }\r
 \r
-    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
-        transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
-        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) {\r
-            transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
+    if (pktHandle) {\r
+        if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) {\r
+            transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
         }\r
-        return;\r
     }\r
     /* Transaction not deleted.  Waiting for response from RM CD or Server */\r
 }\r
@@ -1826,6 +1821,3 @@ const char* Rm_getVersionStr (void)
     return rmVersionStr;\r
 }\r
 \r
-/**\r
-@}\r
-*/\r
index e08f306600964c5a3d02a08ce75047aa894ec0dd..aaf2c896cd236e06e991ccaf7f2808b8e87c7c46 100644 (file)
@@ -40,6 +40,9 @@
  *  \par
 */
 
+/* Standard includes */
+#include <string.h>
+
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
 
 #include <ti/drv/rm/util/libfdt/libfdt_env.h>
 
 /**********************************************************************
- ********************Common DTB Parsing Functions**********************
+ ******************** Common DTB Parsing Globals **********************
  **********************************************************************/
 
 const char rmDtbStartingNode[] = "\0";
 
+/**********************************************************************
+ *************** Global Resource List Parsing Globals *****************
+ **********************************************************************/
+
+/* Resource List Properties - These are the property values used
+ * by an application integrator to define the properties of resources
+ * listed in the Device Global Resource List */
+const char dtbUtilResRangeProp[]        = "resource-range";
+const char dtbUtilResLinuxAliasProp[]   = "linux-dtb-alias";
+const char dtbUtilResNsAssignmentProp[] = "ns-assignment";
+
+/**********************************************************************
+ *********************** Policy Parsing Globals ***********************
+ **********************************************************************/
+
+/* Policy Properties - These are the property values used
+ * by an application integrator to define the properties of resources
+ * listed in a Resource Manager Policy */
+const char dtbUtilPolicyValidInstances[]      = "valid-instances";
+const char dtbUtilPolicyAssignments[]         = "assignments";
+const char dtbUtilPolicyAllocationSize[]      = "allocation-size";
+const char dtbUtilPolicyAllocationAlignment[] = "allocation-alignment";
+
+/**********************************************************************
+ ******************* Common DTB Parsing Functions *********************
+ **********************************************************************/
+
 /* Construct and return a list of ranges as specified in either the Resource
  * DTB or a Policy DTB */
-Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
+static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
 {
     uint32_t         *dtbRangeData = (uint32_t *)dtbDataPtr;
     Rm_ResourceRange *startRange = NULL;
@@ -96,7 +126,7 @@ Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbD
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted ranges */
-void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList)
+static void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList)
 {
     Rm_ResourceRange *nextRange;
     
@@ -108,7 +138,7 @@ void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList)
 }
 
 /* Construct and return a list of values as specified in the Policy DTB */
-Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t dtbDataLen)
+static Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t dtbDataLen)
 {
     uint32_t         *dtbRangeData = (uint32_t *)dtbDataPtr;
     Rm_ResourceValue *startValue = NULL;
@@ -140,7 +170,7 @@ Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted values */
-void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
+static void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
 {
     Rm_ResourceValue *nextValue;
     
@@ -152,16 +182,9 @@ void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
 }
 
 /**********************************************************************
- *******Global Resource List DTB Parsing Defines and Functions*********
+ ************** Global Resource List Parsing Functions ****************
  **********************************************************************/
 
-/* Resource List Properties - These are the property values used
- * by an application integrator to define the properties of resources
- * listed in the Device Global Resource List */
-char dtbUtilResRangeProp[]        = "resource-range";
-char dtbUtilResLinuxAliasProp[]   = "linux-dtb-alias";
-char dtbUtilResNsAssignmentProp[] = "ns-assignment";
-
 Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName)
 {
     Rm_ResourcePropType propertyType = Rm_resourcePropType_UNKNOWN;
@@ -360,17 +383,9 @@ void rmDtbUtilResFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
 }
 
 /**********************************************************************
- ***************Policy DTB Parsing Defines and Functions***************
+ ********************** Policy Parsing Functions **********************
  **********************************************************************/
 
-/* Policy Properties - These are the property values used
- * by an application integrator to define the properties of resources
- * listed in a Resource Manager Policy */
-char dtbUtilPolicyValidInstances[]      = "valid-instances";
-char dtbUtilPolicyAssignments[]         = "assignments";
-char dtbUtilPolicyAllocationSize[]      = "allocation-size";
-char dtbUtilPolicyAllocationAlignment[] = "allocation-alignment";
-
 Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char * propertyName)
 {
     Rm_PolicyPropType propertyType = Rm_policyPropType_UNKNOWN;
@@ -574,7 +589,3 @@ void rmDtbUtilLinuxFreeValues(Rm_LinuxValueRange *valueList)
     }
 }
 
-/**
-@}
-*/
-
index 589ab6a4a6f4f66c796de8adea8f11a88a1cac20..2a3ee6d5f85639b96a6f63133a50ac256b2d2a46 100644 (file)
@@ -64,10 +64,10 @@ int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg)
     Rm_NameServerNode    *newNode = NULL;
     int32_t               retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
     
-    if (newNode = nameServerNodeNew(&objCfg->nodeCfg)) {
+    if (newNode = rmNameServerNodeNew(&objCfg->nodeCfg)) {
         if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) {
             /* Collision */
-            nameServerNodeFree(newNode);
+            rmNameServerNodeFree(newNode);
             retVal = RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS;
         }
     }
@@ -110,7 +110,7 @@ int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
     if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
         /* Remove from NameServer */
         RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode);
-        nameServerNodeFree(matchingNode);
+        rmNameServerNodeFree(matchingNode);
         
         retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
     }    
index b6a5c5e92c6293e9d74880e92010d92ee707b3a2..9432c3dea0c90f053064b0b9661b7ad2c06df2b0 100644 (file)
@@ -69,8 +69,8 @@ const char Rm_policyAllInstances[] = "*";
  ******************** Local Policy Functions **************************
  **********************************************************************/
 
-int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, 
-                             Rm_PolicyPermission *permissionsList)
+static int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, 
+                                    Rm_PolicyPermission *permissionsList)
 {
     while (permissionsList) {
         if (strcmp(permissionsList->instName, Rm_policyAllInstances) &&
@@ -82,8 +82,8 @@ int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree,
     return(RM_INIT_OK);
 }
 
-Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd, 
-                                              int32_t *result)
+static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd, 
+                                                     int32_t *result)
 {
     Rm_PolicyPermission *startPerm = NULL;
     Rm_PolicyPermission *newPerm = NULL;
@@ -381,7 +381,7 @@ Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrE
     return (startPerm);
 }
 
-void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
+static void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
 {
     Rm_PolicyPermission *nextPerm;
     
@@ -392,8 +392,8 @@ void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
     }
 }
 
-Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, 
-                                                    int32_t *result)
+static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, 
+                                                           int32_t *result)
 {
     Rm_PolicyPermission *startPerm = NULL;
     Rm_PolicyPermission *newPerm = NULL;
@@ -443,8 +443,8 @@ Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignm
     return(startPerm);
 }
 
-int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
-                                            Rm_PolicyAssignment *assignmentList)
+static int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
+                                                   Rm_PolicyAssignment *assignmentList)
 {
     Rm_PolicyAssignment *assignment = assignmentList;
     Rm_PolicyPermission *permissionList;
@@ -801,14 +801,14 @@ Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *re
     RB_INIT(rootEntry);
 
     while (validInstList) {
-        newNode = policyValidInstNodeNew(validInstList->instName);
+        newNode = rmPolicyValidInstNodeNew(validInstList->instName);
         RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);
         
         validInstList = validInstList->nextValidInst;
     }
 
     /* Add the Linux kernel node */
-    newNode = policyValidInstNodeNew(linuxName);
+    newNode = rmPolicyValidInstNodeNew(linuxName);
     RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);    
 
     *result = RM_INIT_OK;
@@ -821,7 +821,7 @@ void rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree)
     
     RB_FOREACH(node, _Rm_PolicyValidInstTree, validInstTree) {               
         RB_REMOVE(_Rm_PolicyValidInstTree, validInstTree, node);
-        policyValidInstNodeFree(node);
+        rmPolicyValidInstNodeFree(node);
     }        
     Rm_osalFree((void *)validInstTree, sizeof(Rm_PolicyValidInstTree));
 }
index 441f94720c6d04e6d180ff333702e2750c34b7b8..5120cd6754cc0423d6d99698b44fe6c996ca5731 100644 (file)
@@ -218,6 +218,3 @@ int32_t Rm_serviceCloseHandle(Rm_ServiceHandle *rmServiceHandle)
     return(retVal);
 }
 
-/**
-@}
-*/
index 8f0fa5529a00f1c4021ec1a7dd1f89c6abe9d7dc..50d4ec2304f196837d334df572ecc1eff3b8dd54 100644 (file)
  ********************** Internal Functions ****************************\r
  **********************************************************************/\r
 \r
-Rm_Transport *transportAdd(Rm_TransportCfg *transportCfg)\r
+static Rm_Transport *transportAdd(Rm_TransportCfg *transportCfg)\r
 {\r
     Rm_Inst      *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
     Rm_Transport *transports = rmInst->transports;\r
     Rm_Transport *newTransport = NULL;\r
 \r
     newTransport = Rm_osalMalloc (sizeof(Rm_Transport));\r
+    memset((void *)newTransport, 0, sizeof(Rm_Transport));\r
 \r
     if (newTransport) {\r
         newTransport->rmHandle = transportCfg->rmHandle;\r
+        newTransport->appTransportHandle = transportCfg->appTransportHandle;\r
         newTransport->remoteInstType = transportCfg->remoteInstType;\r
-        strncpy(&(newTransport->remoteInstName)[0], transportCfg->remoteInstName, RM_NAME_MAX_CHARS);\r
+        strncpy(newTransport->remoteInstName, transportCfg->remoteInstName, RM_NAME_MAX_CHARS);\r
         newTransport->nextTransport = NULL;\r
 \r
         if (transports) {\r
-            while (transports->nextTransport != NULL) {\r
+            while (transports->nextTransport) {\r
                 transports = transports->nextTransport;\r
             }\r
             transports->nextTransport = newTransport;\r
         }\r
         else {\r
-            rmInst->transports = (void *) newTransport;\r
+            rmInst->transports = (void *)newTransport;\r
         }\r
     }\r
     return (newTransport);\r
 }\r
 \r
-Rm_Transport *transportFindTransportHandle(Rm_Transport *transports, \r
-                                           Rm_TransportHandle transportHandle)\r
+static bool transportIsTransportRegistered(Rm_Handle rmHandle, Rm_Transport *transport)\r
 {\r
-    while (transports) {\r
-        if (transports == ((Rm_Transport *)transportHandle)) {\r
-            break;             \r
+    Rm_Inst      *rmInst = (Rm_Inst *)rmHandle;\r
+    Rm_Transport *transportList = (Rm_Transport *)rmInst->transports;\r
+    \r
+    while (transportList) {\r
+        if (transportList == transport) {\r
+            return(TRUE);             \r
         }\r
-        transports = transports->nextTransport;\r
+        transportList = transportList->nextTransport;\r
     }\r
-    return (transports);\r
+    return (FALSE);\r
 }\r
 \r
-int32_t transportDelete(Rm_Handle rmHandle, Rm_TransportHandle transportHandle)\r
+static void transportDelete(Rm_Transport *transport)\r
 {\r
-    Rm_Inst      *rmInst = (Rm_Inst *)rmHandle;\r
-    Rm_Transport *transport = (Rm_Transport *) rmInst->transports;\r
+    Rm_Inst      *rmInst = (Rm_Inst *)transport->rmHandle;\r
+    Rm_Transport *transportList = (Rm_Transport *)rmInst->transports;\r
     Rm_Transport *prevTransport = NULL;\r
 \r
-    while (transport) {\r
-        if (transport == (Rm_Transport *)transportHandle) {\r
+    /* Get previous transport in list */\r
+    while (transportList) {\r
+        if (transportList == transport) {\r
             break;             \r
         }\r
-        prevTransport = transport;\r
-        transport = transport->nextTransport;\r
+        prevTransport = transportList;\r
+        transportList = transportList->nextTransport;\r
     }\r
 \r
-    if (transport) {\r
-        if (prevTransport == NULL) {\r
-             rmInst->transports = (void *) transport->nextTransport;\r
-        }\r
-        else {\r
-             prevTransport->nextTransport = transport->nextTransport;\r
-        }\r
-        Rm_osalFree((void *) transport, sizeof(Rm_Transport));\r
+    if (prevTransport == NULL) {\r
+         rmInst->transports = (void *)transport->nextTransport;\r
     }\r
     else {\r
-        return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
+         prevTransport->nextTransport = transport->nextTransport;\r
     }\r
-    return (RM_TRANSPORT_SUCCESSFUL);\r
+    Rm_osalFree((void *)transport, sizeof(Rm_Transport));\r
 }\r
 \r
 Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName)\r
 {\r
     while (transports) {\r
-        if (strcmp(transports->remoteInstName, remoteName) == 0) {\r
+        if (strncmp(transports->remoteInstName, remoteName, RM_NAME_MAX_CHARS) == 0) {\r
             break;             \r
         }\r
         transports = transports->nextTransport;\r
@@ -147,22 +146,19 @@ Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstTyp
     return (transports);\r
 }\r
 \r
-Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
-                                            Rm_Transaction *transaction)\r
+Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
+                                                Rm_Transaction *transaction)\r
 {\r
     Rm_Packet             *rmPkt = NULL;\r
+    Rm_PacketHandle        pktHandle = NULL;\r
     Rm_ResourceRequestPkt *resourceReqPkt = NULL;\r
 \r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
-        NULL) {\r
+    if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
+                                                      sizeof(Rm_Packet),\r
+                                                      &pktHandle)) == NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
-\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) {   \r
-        transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
-        return (NULL);\r
-    }\r
    \r
     rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;\r
     resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;\r
@@ -183,54 +179,49 @@ Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTra
     strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
     memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
-    return (rmPkt);\r
+    \r
+    return (pktHandle);\r
 }\r
 \r
-Rm_Packet *rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
-                                                 Rm_Transaction *transaction)\r
+Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
+                                                     Rm_Transaction *transaction)\r
 {\r
     Rm_Packet              *rmPkt = NULL;\r
+    Rm_PacketHandle         pktHandle = NULL;\r
     Rm_ResourceResponsePkt *resourceRespPkt = NULL;\r
 \r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
-        NULL) {\r
+    if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
+                                                      sizeof(Rm_Packet),\r
+                                                      &pktHandle)) == NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
-\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) {   \r
-        transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
-        return (NULL);\r
-    } \r
-    rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;\r
-                          \r
\r
+    rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;                 \r
     resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;\r
     resourceRespPkt->responseId = transaction->remoteOriginatingId;\r
     resourceRespPkt->requestState = transaction->state;\r
     memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
 \r
-    return (rmPkt);\r
+    return (pktHandle);\r
 }\r
 \r
-Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
-                                          Rm_Transaction *transaction)\r
+Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
+                                              Rm_Transaction *transaction)\r
 {\r
     Rm_Packet       *rmPkt = NULL;\r
+    Rm_PacketHandle  pktHandle = NULL;    \r
     Rm_NsRequestPkt *nsReqPkt = NULL;\r
 \r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
-        NULL) {\r
+    if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
+                                                      sizeof(Rm_Packet),\r
+                                                      &pktHandle)) == NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
 \r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_NsRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) {   \r
-        transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
-        return (NULL);\r
-    }\r
-    rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;\r
-                          \r
+    rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;                   \r
     nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;\r
     nsReqPkt->requestId = transaction->localId;\r
     if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {\r
@@ -243,33 +234,30 @@ Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTrans
     strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
     memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
-\r
-    return (rmPkt);\r
+    \r
+    return (pktHandle);\r
 }\r
 \r
-Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
-                                           Rm_Transaction *transaction)\r
+Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
+                                               Rm_Transaction *transaction)\r
 {\r
     Rm_Packet        *rmPkt = NULL;\r
+    Rm_PacketHandle   pktHandle = NULL;\r
     Rm_NsResponsePkt *nsRespPkt = NULL;\r
 \r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
-        NULL) {\r
+    if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
+                                                      sizeof(Rm_Packet),\r
+                                                      &pktHandle)) == NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
-\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_NsResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) {   \r
-        transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
-        return (NULL);\r
-    }  \r
-    rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;\r
-                          \r
\r
+    rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;                \r
     nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;\r
     nsRespPkt->responseId = transaction->remoteOriginatingId;\r
     nsRespPkt->requestState = transaction->state;\r
 \r
-    return (rmPkt);\r
+    return (pktHandle);\r
 }\r
 \r
 /**********************************************************************\r
@@ -278,7 +266,7 @@ Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTran
 \r
 Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result)\r
 {\r
-    Rm_Inst          *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
+    Rm_Inst      *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
     Rm_Transport *transport = NULL;\r
 \r
     /* RM Servers cannot connect to other Servers.  RM Client Delegates cannot\r
@@ -287,7 +275,7 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t
          (transportCfg->remoteInstType == Rm_instType_SERVER)) ||\r
         ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
          (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE))) {\r
-        *result = -500;\r
+        *result = RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE;\r
         return(NULL);\r
     }\r
 \r
@@ -298,26 +286,21 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t
           (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
          ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
           (transportCfg->remoteInstType == Rm_instType_SERVER)))) {\r
-        *result = -501;\r
+        *result = RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD;\r
         return(NULL);\r
     }         \r
-\r
+    \r
     if (transportCfg->transportCalloutsValid &&\r
         ((transportCfg->transportCallouts.rmAllocPkt == NULL) ||\r
-         (transportCfg->transportCallouts.rmFreePkt == NULL) ||\r
-         (transportCfg->transportCallouts.rmSend == NULL) ||\r
-         (transportCfg->transportCallouts.rmReceive == NULL) ||\r
-         (transportCfg->transportCallouts.rmNumPktsReceived == NULL))) {\r
-        *result = -502;\r
+         (transportCfg->transportCallouts.rmSendPkt == NULL))) {\r
+        *result = RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED;\r
         return(NULL);\r
     }\r
     else {\r
-        rmInst->transport.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt;\r
-        rmInst->transport.rmFreePkt = transportCfg->transportCallouts.rmFreePkt;\r
-        rmInst->transport.rmSend = transportCfg->transportCallouts.rmSend;\r
-        rmInst->transport.rmReceive = transportCfg->transportCallouts.rmReceive;\r
-        rmInst->transport.rmNumPktsReceived = transportCfg->transportCallouts.rmNumPktsReceived;\r
+        rmInst->transportCallouts.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt;\r
+        rmInst->transportCallouts.rmSendPkt = transportCfg->transportCallouts.rmSendPkt;\r
     }\r
+\r
     transport = transportAdd(transportCfg);\r
 \r
     if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
@@ -325,40 +308,38 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t
         rmInst->registeredWithDelegateOrServer = true;\r
     }\r
 \r
-    *result = 0; /* TEMP */\r
+    *result = RM_INIT_OK;\r
     return ((Rm_TransportHandle) transport);\r
 }\r
 \r
-int32_t Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandle transportHandle)\r
+int32_t Rm_transportUnregister(Rm_TransportHandle transportHandle)\r
 {\r
-    Rm_Inst      *rmInst = (Rm_Inst *) rmHandle;\r
-    Rm_Transport *transport = transportFindTransportHandle((Rm_Transport *)rmInst->transports, \r
-                                                                 transportHandle);\r
-   int32_t        retVal = RM_TRANSPORT_SUCCESSFUL;  \r
+    Rm_Transport *transport = (Rm_Transport *)transportHandle;\r
+    Rm_Inst      *rmInst = (Rm_Inst *)transport->rmHandle;\r
+    int32_t       retVal = RM_TRANSPORT_SUCCESSFUL;  \r
 \r
-    if (transport == NULL) {\r
-        retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
-    }\r
-    else {\r
+    if (transportIsTransportRegistered(transport->rmHandle, transport)) {\r
         if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
             (transport->remoteInstType == Rm_instType_SERVER)) {\r
             rmInst->registeredWithDelegateOrServer = false;\r
         }\r
-        retVal = transportDelete(rmHandle, transportHandle);\r
+        transportDelete(transport);\r
+    }\r
+    else {\r
+        retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
     }\r
-\r
     return (retVal);\r
 }\r
 \r
 /* Used by the application to pass RM packets received from a transport to RM.\r
- * CODE THE FUNCTION SUCH THAT IT CAN BE CALLED DIRECTLY BY APP OR BE PLUGGED\r
- * AS PART OF AN ISR HANDLER FOR THE TRANSACTION RECEIVE */\r
-int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)\r
+ * Function can be called from polling or ISR context. */\r
+int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, Rm_Packet *pkt)\r
 {\r\r\r
-    Rm_Inst        *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle;\r
+    Rm_Transport   *transport = (Rm_Transport *)transportHandle;\r
+    Rm_Inst        *rmInst = (Rm_Inst *)transport->rmHandle;\r
     Rm_Transaction *transaction;\r
 \r
-    if (transportFindTransportHandle((Rm_Transport *)rmInst->transports, transportHandle) == NULL) {\r
+    if (!transportIsTransportRegistered(transport->rmHandle, transport)) {\r
         return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
     }\r
 \r
@@ -406,7 +387,6 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
                 rmTransactionProcessor(rmInst, transaction);\r
             }\r
             else {\r
-                rmInst->transport.rmFreePkt(transportHandle, pkt);\r
                 return (RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND);\r
             }\r
             break;\r
@@ -442,50 +422,14 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
                 rmTransactionProcessor(rmInst, transaction);\r
             }\r
             else {\r
-                rmInst->transport.rmFreePkt(transportHandle, pkt);\r
                 return (RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND);\r
             }\r
             break;\r
         }\r
         default:\r
-            rmInst->transport.rmFreePkt(transportHandle, pkt);\r
             return (RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE);\r
       }\r
 \r
-    rmInst->transport.rmFreePkt(transportHandle, pkt);\r
     return (RM_TRANSPORT_SUCCESSFUL);\r
 }\r
 \r
-/* Application can call this API so that RM handles reception of packets based on\r
- * the RM handle and transport handle provided */\r
-int32_t Rm_receivePktPolling(Rm_TransportHandle transportHandle)\r
-{\r
-    Rm_Inst   *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle;\r
-    Rm_Packet *pkt = NULL;\r
-    int32_t    retVal = RM_TRANSPORT_OK_BASE;\r
-\r
-    if (transportFindTransportHandle((Rm_Transport *)rmInst->transports, transportHandle) != NULL) {\r
-        while (rmInst->transport.rmNumPktsReceived(transportHandle) > 0) {\r
-            pkt = rmInst->transport.rmReceive(transportHandle);\r
-\r
-            if (pkt == NULL) {\r
-                retVal = RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR;\r
-                break;\r
-            }\r
-\r
-            /* Pass packet to RM.  Packet will be freed within PktIsr API */\r
-            if (retVal = Rm_receivePktIsr(transportHandle, pkt) <= RM_SERVICE_ERROR_BASE) {\r
-                break;\r
-            }\r
-        }\r
-    }\r
-    else {\r
-        retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
-    }\r
-\r
-    return (retVal); \r
-}\r
-\r
-/**\r
-@}\r
-*/\r
index cb9519c640cac67e98be7fffa943bda57d1e5c69..f1496e48df52fd9f85f840830ef40735f655ad58 100644 (file)
@@ -55,7 +55,7 @@
  ********************* NameServer Tree Functions **********************
  **********************************************************************/
 
-Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg)
+Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg)
 {
     Rm_NameServerNode *newNode = NULL;
 
@@ -70,7 +70,7 @@ Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg)
     return(newNode);
 }
 
-void nameServerNodeFree(Rm_NameServerNode *node)
+void rmNameServerNodeFree(Rm_NameServerNode *node)
 {
     if (node) {
         Rm_osalFree((void *)node, sizeof(Rm_NameServerNode));
@@ -81,18 +81,18 @@ void nameServerNodeFree(Rm_NameServerNode *node)
  * node1 < node2 --> return < 0
  * node1 = node2 --> return 0
  * node1 > node2 --> return > 0 */
-int nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2)
+int rmNameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2)
 {
     return(strcmp(node1->objName, node2->objName));
 }
 
 /* Generate the NameServer tree manipulation functions */
-RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, nameServerNodeCompare);
+RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, rmNameServerNodeCompare);
 
 /**********************************************************************
  *************** Policy Valid Instance Tree Functions *****************
  **********************************************************************/
-Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName)
+Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName)
 {
     Rm_PolicyValidInstNode *newNode = NULL;
 
@@ -105,26 +105,26 @@ Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName)
     return(newNode);
 }
 
-void policyValidInstNodeFree(Rm_PolicyValidInstNode *node)
+void rmPolicyValidInstNodeFree(Rm_PolicyValidInstNode *node)
 {
     if (node->allocRefCount == 0) {
         Rm_osalFree((void *)node, sizeof(Rm_PolicyValidInstNode));
     }
 }
 
-int policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2)
+int rmPolicyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2)
 {
     return(strcmp(node1->name, node2->name));
 }
 
 /* Generate the valid instance tree manipulation functions */
-RB_GENERATE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, policyValidInstNodeCompare);
+RB_GENERATE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, rmPolicyValidInstNodeCompare);
 
 /**********************************************************************
  ***************** Allocator Resource Tree Functions ******************
  **********************************************************************/
 
-Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength)
+Rm_ResourceNode *rmResourceNodeNew(uint32_t resourceBase, uint32_t resourceLength)
 {
     Rm_ResourceNode *newNode = NULL;
 
@@ -139,14 +139,14 @@ Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength)
     return(newNode);
 }
 
-void resourceNodeFree(Rm_ResourceNode *node)
+void rmResourceNodeFree(Rm_ResourceNode *node)
 {
     if (node->allocationCount == 0) {
         Rm_osalFree((void *)node, sizeof(Rm_ResourceNode));
     }
 }
 
-int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
+int rmResourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
 {
     uint32_t node1End = node1->base + node1->length - 1;
     uint32_t node2End = node2->base + node2->length - 1;
@@ -168,5 +168,5 @@ int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
 }
 
 /* Generate the red-black tree manipulation functions */
-RB_GENERATE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, resourceNodeCompare)
+RB_GENERATE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, rmResourceNodeCompare)
 
index a72f39722f22f5b4fb7f42975f6ce30170fe7cbc..5889b4fa81b31967e3ee77f6cb9474cfe874ddad 100644 (file)
@@ -86,10 +86,10 @@ Char rmClientDelegateName[RM_NAME_MAX_CHARS] = "RM_Client_Delegate";
 Char rmClientName[RM_NAME_MAX_CHARS] = "RM_Client";
 
 /* ======== RM IPC MessageQ Names ======== */
-Char serverCdQueueName[30] = "RM_Server_CD_Queue";
-Char cdServerQueueName[30] = "RM_CD_Server_Queue";
-Char cdClientQueueName[30] = "RM_CD_Client_Queue";
-Char clientCdQueueName[30] = "RM_Client_CD_Queue";
+Char serverFromCdQueueName[30] = "RM_Server_From_CD_Queue";
+Char cdFromServerQueueName[30] = "RM_CD_From_Server_Queue";
+Char cdFromClientQueueName[30] = "RM_CD_From_Client_Queue";
+Char clientFromCdQueueName[30] = "RM_Client_From_CD_Queue";
 
 /* ======== RM Instance Handles ======== */
 Rm_Handle rmServerHandle = NULL;
@@ -122,7 +122,6 @@ typedef struct {
 typedef struct {
     Rm_TransportHandle transportHandle;
     MessageQ_Handle receiveMsgQ;
-    MessageQ_QueueId remoteMsgQId;
 } Transport_MapEntry;
 
 /* Core 1 will have three mapping entries
@@ -160,8 +159,7 @@ void takeSyncObj(void)
 
 void waitOnSyncObj(void)
 {
-    do
-    {
+    do {
         /* Yield for other tasks */
         Task_yield();
         Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj));    
@@ -177,175 +175,97 @@ void releaseSyncObj(void)
 
 /* ======== RM Application Transport APIs ======== */
 
-Rm_Packet *TransportAlloc (Rm_TransportHandle transportHandle, uint32_t pktSize)
+Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
 {
-    Rm_Packet *pkt = NULL;
-
-    /* All transports will allocate from the same heap */
-    
-    pkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
+    Rm_Packet     *rmPkt = NULL;
+    MsgQ_RmPacket *rmMsg = NULL;
 
-    if (pkt != NULL)
-    {
-       pkt->pktLenBytes = pktSize;
+    /* Allocate a messageQ message for containing the RM packet */
+    rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
+    if (rmMsg == NULL) {
+        System_printf("Core %d: MessageQ_alloc failed in TransportSend\n", MultiProc_self());
+        *pktHandle = NULL;
+        return(NULL);
     }
-
-    return (pkt);
+    else {
+        /* Create and attach RM packet to MessageQ message.  All transports will allocate from the same heap */
+        rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
+        rmPkt->pktLenBytes = pktSize;
+        Rm_osalEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
+        rmMsg->rmPkt = rmPkt;
+        *pktHandle = (Rm_PacketHandle)rmMsg;
+    }
+    return (rmPkt);
 }
 
-int32_t TransportFree (Rm_TransportHandle transportHandle, Rm_Packet *pkt)
+void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
 {
     uint32_t pktSize = pkt->pktLenBytes;
+    int32_t  status;
 
-    /* All transports will free to the same heap */
-    
+    /* All transports will free rmPkts to the same heap */
     HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
 
-    return (0);    
+    status = MessageQ_free(rmMsgQMsg);
+    if (status < 0) { 
+        System_printf("Core %d: MessageQ_free had a failure/error in transportFree\n", MultiProc_self());
+    }     
 }
 
-int32_t TransportSend (Rm_TransportHandle transportHandle, Rm_Packet *pkt)
+int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
 {
-    MsgQ_RmPacket *rmMsg = NULL;
-    MessageQ_QueueId remoteQueueId;
-    bool handleValid = false;
-    int32_t status, i;    
-
-    /* Get the remoteQueueId based on the transportHandle */
-    for (i = 0; i < MAX_MAPPING_ENTRIES; i++)
-    {
-        /* transportHandle found in mapping table.  Get the remoteQueueId associated
-         * with it */
-        if (rmTransportMap[i].transportHandle == transportHandle)
-        {
-            remoteQueueId = rmTransportMap[i].remoteMsgQId;
-            /* Break out of the search loop */
-            handleValid = true;
-            break;
-        }
-    }
+    MessageQ_QueueId  remoteQueueId = (MessageQ_QueueId)appTransport;
+    MsgQ_RmPacket    *rmMsg = pktHandle;
+    int32_t           status;    
 
-    if (handleValid)
-    {
-        /* Allocate a messageQ message for containing the RM packet */
-        rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
-        if (rmMsg == NULL) 
-        {
-            System_printf("Core %d: MessageQ_alloc failed in TransportSend\n", MultiProc_self());
-        }
+    /* Write back data that was written by RM after alloc */
+    Rm_osalEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
 
-        /* Attach the RM packet to the MessageQ message */
-        Rm_osalEndMemAccess((void *) pkt, pkt->pktLenBytes);
-        rmMsg->rmPkt = pkt;
-        /* Send the message to the remote side */
-        status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
-        if (status < 0) 
-        { 
-            System_printf("Core %d: MessageQ_put had a failure/error in TransportSend\n", MultiProc_self());
-        }
-    }
-    else
-    {   
-        /* Could not find a registered transport handle that matched the handle provided by RM.
-         * Return an error to RM. */
-        System_printf("Core %d: TransportSend couldn't find transportHandle in transport map\n", MultiProc_self());
-        status = -1;
+    /* Send the message to the remote side */
+    status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
+    if (status < 0) {
+        transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
+        System_printf("Core %d: MessageQ_put had a failure/error in TransportSend: error: %d\n", MultiProc_self(),
+                                                                                                 status);
     }
-    
     return (status);
 }
 
-void *TransportReceive (Rm_TransportHandle transportHandle)
+void transportReceive (uint32_t transportMapEntry)
 {
-    MessageQ_Handle receiveQ;
-    MessageQ_Msg rmMsg = NULL;
-    Rm_Packet *rmPkt = NULL;
-    bool queueValid = false;
-    int32_t status, i;    
-
-    /* Get the receiveQ based on the transportHandle */
-    for (i = 0; i < MAX_MAPPING_ENTRIES; i++)
-    {
-        /* transportHandle found in mapping table.  Get the receiveQ associated
-         * with it */
-        if (rmTransportMap[i].transportHandle == transportHandle)
-        {
-            receiveQ = rmTransportMap[i].receiveMsgQ;
-            /* Break out of the search loop */
-            queueValid = true;
-            break;
-        }
-    }
-
-    if (queueValid)
-    {
-        /* Get the next message from the receiveQ */
+    MessageQ_Handle  receiveQ;
+    int32_t          numPkts;
+    MessageQ_Msg     rmMsg = NULL;
+    Rm_Packet       *rmPkt = NULL;
+    int32_t          status;
+    uint32_t         i;  
+
+    /* Check if any packets available */
+    receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
+    numPkts = (int32_t) MessageQ_count(receiveQ);
+
+    /* Process all available packets */
+    for (i = 0; i < numPkts; i++) {
         status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
-        if (status < 0) 
-        {
+        if (status < 0) {
             System_abort("This should not happen since timeout is forever\n");
         }
-        if (rmMsg == NULL) 
-        {
+        if (rmMsg == NULL) {
             System_printf("Core %d: MessageQ_get failed returning a null packet in TransportReceive\n", MultiProc_self());
         }
 
         /* Extract the Rm_Packet from the RM msg */
         rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
-        Rm_osalBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes); 
+        Rm_osalBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
 
-        /* Free the messageQ message now that RM packet pointer has been extracted */
-        status = MessageQ_free(rmMsg);
-        if (status < 0) 
-        { 
-            System_printf("Core %d: MessageQ_free had a failure/error in TransportReceive\n", MultiProc_self());
-        }
-    }
-    else
-    {   
-        /* Could not find a registered transport handle that matched the handle provided by RM.
-         * Return an error to RM. */
-        System_printf("Core %d: TransportReceive couldn't find transportHandle in transport map\n", MultiProc_self());
-    }
-
-    /* Pass the RM packet back to RM */
-    return ((void *)rmPkt);
-}
-
-int32_t TransportNumPktsReceived (Rm_TransportHandle transportHandle)
-{
-    MessageQ_Handle receiveQ;
-    bool queueValid = false;
-    int32_t numPkts, i;    
-
-    /* Get the receiveQ based on the transportHandle */
-    for (i = 0; i < MAX_MAPPING_ENTRIES; i++)
-    {
-        /* transportHandle found in mapping table.  Get the receiveQ associated
-         * with it */
-        if (rmTransportMap[i].transportHandle == transportHandle)
-        {
-            receiveQ = rmTransportMap[i].receiveMsgQ;
-            /* Break out of the search loop */
-            queueValid = true;
-            break;
+        /* Provide packet to RM for processing */
+        if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
+            System_printf("Core %d: RM encountered error processing received packet: %d\n", MultiProc_self(), status);
         }
-    }
 
-    if (queueValid)
-    {
-        /* Get the number of messages in the receiveQ */
-        numPkts = (int32_t) MessageQ_count(receiveQ);
-    }
-    else
-    {   
-        /* Could not find a registered transport handle that matched the handle provided by RM.
-         * Return an error to RM. */
-        System_printf("Core %d: TransportNumPktsReceived couldn't find transportHandle in transport map\n", MultiProc_self());
-        numPkts = -1;
+        /* Free RM packet buffer and messageQ message */
+        transportFree(rmMsg, rmPkt);
     }
-    
-    return (numPkts);
 }
 
 /*
@@ -354,8 +274,7 @@ int32_t TransportNumPktsReceived (Rm_TransportHandle transportHandle)
  */
 void testServiceCallback(Rm_ServiceRespInfo *serviceResponse)
 {
-    if (serviceResponse->serviceId == waitForBlockingOperation)
-    {
+    if (serviceResponse->serviceId == waitForBlockingOperation) {
         waitForBlockingOperation = 0;
         strcpy(responseInfo.resourceName, serviceResponse->resourceName);
         responseInfo.resourceBase = serviceResponse->resourceBase;
@@ -369,20 +288,17 @@ bool blockForResponse(Rm_ServiceRespInfo *respInfo)
     waitForBlockingOperation = respInfo->serviceId;
     /* Block and wait for the response if the RM needed to perform a blocking operation
      * to complete the request */
-    while(waitForBlockingOperation)
-    {
+    while(waitForBlockingOperation) {
         /* Yield to receive task to see if there are any packets for RM instance */
         Task_yield();
     }       
 
     if ((respInfo->serviceState != RM_SERVICE_PROCESSING) &&
-        (respInfo->serviceState != RM_SERVICE_APPROVED_AND_COMPLETED))
-    {
+        (respInfo->serviceState != RM_SERVICE_APPROVED_AND_COMPLETED)) {
         System_printf("Core %d: Service request encountered error or denial: %d\n", MultiProc_self(),
                                                                                     respInfo->serviceState);
         return(FALSE);
     }
-
     return(TRUE);
 }
 
@@ -394,23 +310,19 @@ void cleanupRmTsk(UArg arg0, UArg arg1)
 {
     /* Delete the RM test task */
     System_printf("Core %d: Deleting RM test task...\n", MultiProc_self());
-    if (testRmTskHandle)
-    {
+    if (testRmTskHandle) {
         Task_delete(&testRmTskHandle);
         /* Set the task handle to be NULL so that the delete only occurs once */
         testRmTskHandle = NULL;
     }
     /* Delete the RM receive task */
     System_printf("Core %d: Deleting RM receive task...\n", MultiProc_self());
-    if (testReceiveTskHandle)
-    {
+    if (testReceiveTskHandle) {
         Task_delete(&testReceiveTskHandle);
         /* Set the task handle to be NULL so that the delete only occurs once */
         testReceiveTskHandle = NULL;
     }
 
-    
-
     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
 
     BIOS_exit(0);
@@ -422,53 +334,15 @@ void cleanupRmTsk(UArg arg0, UArg arg1)
  */
 void testReceiveTsk(UArg arg0, UArg arg1)
 {
-    int32_t retVal;
-
-    while(1)
-    {
-
-        /* Run the RM polling functions for each RM instance. */
-        if (MultiProc_self() == 0)
-        {
-            retVal = Rm_receivePktPolling(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle);
-            if (retVal != RM_TRANSPORT_SUCCESSFUL)
-            {
-                System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), 
-                                                                                rmServerName,
-                                                                                rmClientDelegateName,
-                                                                                retVal);
-            }
+    while(1) {
+        if (MultiProc_self() == 0) {
+            transportReceive(SERVER_TO_CD_MAP_ENTRY);
         }
-        else if (MultiProc_self() == 1)
-        {
-            retVal = Rm_receivePktPolling(rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle);
-            if (retVal != RM_TRANSPORT_SUCCESSFUL)
-            {
-                System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), 
-                                                                                rmClientDelegateName,
-                                                                                rmServerName,
-                                                                                retVal);
-            }
-
-            retVal = Rm_receivePktPolling(rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle);
-            if (retVal != RM_TRANSPORT_SUCCESSFUL)
-            {
-                System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(),
-                                                                                rmClientDelegateName,
-                                                                                rmClientName,
-                                                                                retVal);
-            }
-
-            retVal = Rm_receivePktPolling(rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle);
-            if (retVal != RM_TRANSPORT_SUCCESSFUL)
-            {
-                System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), 
-                                                                                rmClientName,
-                                                                                rmClientDelegateName,
-                                                                                retVal);
-            }
+        else if (MultiProc_self() == 1) {
+            transportReceive(CD_TO_SERVER_MAP_ENTRY);
+            transportReceive(CD_TO_CLIENT_MAP_ENTRY);
+            transportReceive(CLIENT_TO_CD_MAP_ENTRY);
         }
-
         /* Yield for main test task */
         Task_yield();
     }
@@ -977,30 +851,27 @@ void testRmTsk(UArg arg0, UArg arg1)
  */
 Void startupRmTsk(UArg arg0, UArg arg1)
 {
-    MessageQ_Handle  serverCdMsgQ, cdServerMsgQ, cdClientMsgQ, clientCdMsgQ;
-    MessageQ_QueueId serverCdQId, cdServerQId, cdClientQId, clientCdQId;    
-    Int              status, i;
-    HeapBufMP_Handle msgQHeapHandle;
-    HeapBufMP_Params heapBufParams;
-    Rm_TransportCfg rmTransportCfg;
-    int32_t result = 0;
+    MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
+    MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
+    Int                status, i;
+    HeapBufMP_Handle   msgQHeapHandle;
+    HeapBufMP_Params   heapBufParams;
+    Rm_TransportCfg    rmTransportCfg;
+    int32_t            result = 0;
     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
-    Task_Params taskParams;
+    Task_Params        taskParams;
 
-    if (MultiProc_self() == 1)
-    {
+    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++)
-    {
+    for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
         rmTransportMap[i].transportHandle = NULL;
     }
 
-    if (MultiProc_self() == 0)
-    {
+    if (MultiProc_self() == 0) {
         /* Create the heap that will be used to allocate RM messages. This
          * heap is a multi-processor heap.  It will be shared amongst
          * all RM instances. */     
@@ -1010,8 +881,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         heapBufParams.numBlocks      = 64;
         heapBufParams.blockSize      = sizeof(Rm_Packet);
         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
-        if (rmPktHeapHandle == NULL) 
-        {
+        if (rmPktHeapHandle == NULL) {
             System_abort("HeapBufMP_create failed for RM packet heap\n" );
         }
         System_printf("Core %d: RM packet heap created\n", MultiProc_self());
@@ -1023,38 +893,32 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         heapBufParams.numBlocks      = 64;
         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
-        if (msgQHeapHandle == NULL) 
-        {
+        if (msgQHeapHandle == NULL) {
             System_abort("HeapBufMP_create failed MessageQ message heap\n" );
         } 
         System_printf("Core %d: IPC MessageQ message heap created\n", MultiProc_self());
     }
-    else 
-    {
+    else {
         /* Open the heaps created by the other processor. Loop until opened. */
-        do 
-        {
+        do {
             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0)
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
         System_printf("Core %d: RM packet heap opened\n", MultiProc_self());
         
-        do 
-        {
+        do {
             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0)
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
@@ -1067,38 +931,31 @@ Void startupRmTsk(UArg arg0, UArg arg1)
     /* Create the messageQ's for each RM instance connection
      * Need four queues.  Topology will be:
      * RM Server <---> RM Client Delegate <---> RM Client 
-     * 1 queue on RM Server
+     * 1 queues on RM Server
      * 2 queues on RM Client Delegate
-     * 1 queue on RM Client */
-    if (MultiProc_self() == 0)
-    {
-        /* Create the RM Server messageQ used by the RM Client Delegate */
-        serverCdMsgQ = MessageQ_create(serverCdQueueName, NULL);
-        if (serverCdMsgQ == NULL) 
-        {
+     * 1 queues on RM Client */
+    if (MultiProc_self() == 0) {
+        serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
+        if (serverFromCdMsgQ == NULL) {
             System_abort("MessageQ_create failed for RM Server - Client Delegate queue\n" );
         }
         System_printf("Core %d: RM Server MessageQ created for receiving packets from RM CD\n", MultiProc_self());
     }
-    else if (MultiProc_self() == 1)
-    {
-        /* Create the RM Client Delegate messageQ used by the RM Server */
-        cdServerMsgQ = MessageQ_create(cdServerQueueName, NULL);
-        if (cdServerMsgQ == NULL) 
-        {
+    else if (MultiProc_self() == 1) {
+        cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
+        if (cdFromServerMsgQ == NULL) {
             System_abort("MessageQ_create failed for RM Client Delegate - Server queue\n" );
         }
         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Server\n", MultiProc_self());
-        /* Create the RM Client Delegate messageQ used by the RM Client */
-        cdClientMsgQ = MessageQ_create(cdClientQueueName, NULL);
-        if (cdClientMsgQ == NULL) 
-        {
+        
+        cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
+        if (cdFromClientMsgQ == NULL) {
             System_abort("MessageQ_create failed for RM Client Delegate - Client queue\n" );
         } 
         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Client\n", MultiProc_self());
-        /* Create the RM Client messageQ used by the RM Client Delegate */
-        clientCdMsgQ = MessageQ_create(clientCdQueueName, NULL);
-        if (clientCdMsgQ == NULL) 
+        
+        clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
+        if (clientFromCdMsgQ == NULL) 
         {
             System_abort("MessageQ_create failed for RM Client - Client Delegate queue\n" );
         }
@@ -1106,143 +963,120 @@ Void startupRmTsk(UArg arg0, UArg arg1)
     }
     
     /* Open the remote message queues. Also register the RM transports with each RM instance */
-    if (MultiProc_self() == 0)
-    {
+    if (MultiProc_self() == 0) {
         /* Open the Client Delegate messageQ from the Server */
-        do 
-        {
-            status = MessageQ_open(cdServerQueueName, &serverCdQId); 
+        do {
+            status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0)
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
         System_printf("Core %d: RM CD MessageQ opened from RM Server\n", MultiProc_self());
 
         /* Register the Client Delegate with the RM Server Instance */
+        rmTransportCfg.rmHandle = rmServerHandle;
+        rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
         /* Set the callouts as valid for the first transport configuration on Server instance */
-        rmTransportCfg.rmHandle = rmServerHandle;
         rmTransportCfg.transportCalloutsValid = true;
-        rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc;
-        rmTransportCfg.transportCallouts.rmFreePkt = TransportFree;
-        rmTransportCfg.transportCallouts.rmSend = TransportSend;
-        rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
-        rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
-
+        rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
+        rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
-        rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverCdMsgQ;
-        rmTransportMap[SERVER_TO_CD_MAP_ENTRY].remoteMsgQId = serverCdQId;
+        rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
         System_printf("Core %d: Registered RM Server <=> RM CD transport with RM Server instance\n", MultiProc_self());
-        
     }
-    else if (MultiProc_self() == 1)
-    {
+    else if (MultiProc_self() == 1) {
         /* Open the Server messageQ from the Client Delegate */
-        do 
-        {
-            status = MessageQ_open(serverCdQueueName, &cdServerQId); 
+        do {
+            status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0) 
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
         System_printf("Core %d: RM Server MessageQ opened from RM CD\n", MultiProc_self());
 
         /* Register the Server with the RM Client Delegate Instance */
+        rmTransportCfg.rmHandle = rmClientDelegateHandle;
+        rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
         rmTransportCfg.remoteInstName = &rmServerName[0];
         /* Set the callouts as valid for the first transport configuration on Client Delegate instance */
-        rmTransportCfg.rmHandle = rmClientDelegateHandle;
-        rmTransportCfg.transportCalloutsValid = true;
-        rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc;
-        rmTransportCfg.transportCallouts.rmFreePkt = TransportFree;
-        rmTransportCfg.transportCallouts.rmSend = TransportSend;
-        rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
-        rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
 
+        rmTransportCfg.transportCalloutsValid = true;
+        rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
+        rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
-        rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdServerMsgQ;
-        rmTransportMap[CD_TO_SERVER_MAP_ENTRY].remoteMsgQId = cdServerQId;
+        rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
         System_printf("Core %d: Registered RM CD <=> RM Server transport with RM CD instance\n", MultiProc_self());
         
         /* Open the Client messageQ from the Client Delegate */
-        do 
-        {
-            status = MessageQ_open(clientCdQueueName, &cdClientQId); 
+        do {
+            status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0) 
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
         System_printf("Core %d: RM Client MessageQ opened from RM CD\n", MultiProc_self());
 
         /* Register the Client with the RM Client Delegate Instance */
+        rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
         rmTransportCfg.remoteInstName = &rmClientName[0];
         /* Callouts already set on the Client Delegate so set them as invalid */
         rmTransportCfg.transportCalloutsValid = false;
-
         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
-        rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdClientMsgQ;
-        rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].remoteMsgQId = cdClientQId;
+        rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
         System_printf("Core %d: Registered RM CD <=> RM Client transport with RM CD instance\n", MultiProc_self());
 
         /* Open the Client Delegate messageQ from the Client */        
-        do 
-        {
-            status = MessageQ_open(cdClientQueueName, &clientCdQId); 
+        do {
+            status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
             /* 
              *  Sleep for 1 clock tick to avoid inundating remote processor
              *  with interrupts if open failed
              */
-            if (status < 0) 
-            { 
+            if (status < 0) { 
                 Task_sleep(1);
             }
         } while (status < 0);
         System_printf("Core %d: RM CD MessageQ opened from RM Client\n", MultiProc_self());
 
         /* Register the Client Delegate with the RM Client Instance */
+        rmTransportCfg.rmHandle = rmClientHandle;
+        rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
         /* Set the callouts as valid for the first transport configuration on Client instance */
-        rmTransportCfg.rmHandle = rmClientHandle;
         rmTransportCfg.transportCalloutsValid = true;
-        rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc;
-        rmTransportCfg.transportCallouts.rmFreePkt = TransportFree;
-        rmTransportCfg.transportCallouts.rmSend = TransportSend;
-        rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
-        rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
-
+        rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
+        rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
-        rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientCdMsgQ;
-        rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].remoteMsgQId = clientCdQId; 
+        rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
         System_printf("Core %d: Registered RM Client <=> RM CD transport with RM Client instance\n", MultiProc_self());
     }
 
index 48ccfd9100002deb3aff35ee4f17bc7d232b25b2..4015e829f7c5b6bde578bda6fb39f4aa1d1ea8d2 100644 (file)
@@ -1,5 +1,55 @@
 #ifndef _FDT_H
 #define _FDT_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public
+ *     License along with this library; if not, write to the Free
+ *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ *     MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ *  b) Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *     1. Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *     2. Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #ifndef __ASSEMBLY__
 
index 449bf602daf1ff59a1cfef48bc4b50c15940112b..b71cef572255ab1b94f42930639df5abc266b88f 100644 (file)
@@ -1,5 +1,55 @@
 #ifndef _LIBFDT_ENV_H
 #define _LIBFDT_ENV_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public
+ *     License along with this library; if not, write to the Free
+ *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ *     MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ *  b) Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *     1. Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *     2. Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include <stddef.h>
 #include <stdint.h>