]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
API naming convention cleanup, switch to strncpy, renamed resourceNode allocatedTo...
authorJustin Sobota <jsobota@ti.com>
Mon, 28 Jan 2013 23:42:22 +0000 (18:42 -0500)
committerJustin Sobota <jsobota@ti.com>
Mon, 28 Jan 2013 23:42:22 +0000 (18:42 -0500)
22 files changed:
device/tci6614-global-resources.dtb
device/tci6614-global-resources.dts
include/rm_dtb_utilloc.h
include/rm_loc.h
include/rm_nameserverloc.h
include/rm_policyloc.h
include/rm_transportloc.h
include/rm_treeloc.h [new file with mode: 0644]
package.bld
rm.h
rm_policy.h [deleted file]
rm_services.h
rm_transport.h
src/Module.xs
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 [new file with mode: 0644]
test/rm_test.c

index 7eb11af12ddfa21d4f36fa3b7b606ae47e9ecb08..5f2582231f9a0a738f820651dd66e626b8834362 100644 (file)
Binary files a/device/tci6614-global-resources.dtb and b/device/tci6614-global-resources.dtb differ
index c574f4ccfa33c78e9a1dc85c52a413a550d186ce..8bc0addd3c6490d65c33c86f7403178706f2e8b8 100644 (file)
@@ -1,8 +1,6 @@
 /dts-v1/;
 
 / {
-    device-name = "TCI6614";
-    
     /* Device Resource Definitions */
 
        /* TODO: where do following get defined in the linux DTB
index 5b1d4637e4967819d1a33e063ec04e6a2af65604..78fcaa5fbe3ec9015f6740289bbcedc4f0306662 100644 (file)
@@ -62,15 +62,15 @@ extern "C" {
 */
 #define RM_DTB_UTIL_STARTING_DEPTH 0
 
-typedef struct {
-    uint32_t base;
-    uint32_t length;
-    void *nextRange;
+typedef struct Rm_ResourceRange_s {
+    uint32_t                   base;
+    uint32_t                   length;
+    struct Rm_ResourceRange_s *nextRange;
 } Rm_ResourceRange;
 
-typedef struct {
-    uint32_t value;
-    void *nextValue;
+typedef struct Rm_ResourceValue_s {
+    uint32_t                   value;
+    struct Rm_ResourceValue_s *nextValue;
 } Rm_ResourceValue;
 
 /**********************************************************************
@@ -84,40 +84,38 @@ typedef struct {
 
 typedef enum {
     /** Resource DTB unknown property type */
-    Rm_resourcePropType_UNKNOWN = 0,
-    /** Resource DTB device name property type */
-    Rm_resourcePropType_DEVICE_NAME = 1,    
+    Rm_resourcePropType_UNKNOWN = 0,  
     /** Resource DTB resource range property type */
-    Rm_resourcePropType_RESOURCE_RANGE = 2,
+    Rm_resourcePropType_RESOURCE_RANGE,
     /** Resource DTB resource alias path in Linux DTB */
-    Rm_resourcePropType_RESOURCE_LINUX_ALIAS = 3,    
+    Rm_resourcePropType_RESOURCE_LINUX_ALIAS,    
     /** Resource DTB NameServer assignment property type */
-    Rm_resourcePropType_NSASSIGNMENT = 4,    
+    Rm_resourcePropType_NSASSIGNMENT,    
 } Rm_ResourcePropType;
 
-typedef struct {
-    char *path;
-    uint32_t baseOffset;
-    uint32_t lengthOffset;
-    void *nextLinuxAlias;
+typedef struct Rm_LinuxAlias_s {
+    char                   *path;
+    uint32_t                baseOffset;
+    uint32_t                lengthOffset;
+    struct Rm_LinuxAlias_s *nextLinuxAlias;
 } Rm_LinuxAlias;
 
-typedef struct {
-    char *nsName;
-    uint32_t resourceBase;
-    uint32_t resourceLength;
-    void *nextNsAssignment;
+typedef struct Rm_NsAssignment_s {
+    char                      nsName[RM_RESOURCE_NAME_MAX_CHARS];
+    uint32_t                  resourceBase;
+    uint32_t                  resourceLength;
+    struct Rm_NsAssignment_s *nextNsAssignment;
 } Rm_NsAssignment;
 
-Rm_ResourcePropType Rm_resourceGetPropertyType(const char *propertyName);
-char *Rm_resourceExtractDeviceName(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_resourceFreeDeviceName(char *deviceName);
-Rm_ResourceRange *Rm_resourceExtractRange(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_resourceFreeRange(Rm_ResourceRange *rangeList);
-Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_resourceFreeLinuxAlias(Rm_LinuxAlias *aliasList);
-Rm_NsAssignment *Rm_resourceExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_resourceFreeNsAssignmentList(Rm_NsAssignment *nsAssignmentList);
+Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char *propertyName);
+Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr, int32_t dtbDataLen);
+void rmDtbUtilResFreeRange(Rm_ResourceRange *rangeList);
+Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen,
+                                             int32_t *result);
+void rmDtbUtilResFreeLinuxAlias(Rm_LinuxAlias *aliasList);
+Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen, 
+                                                 int32_t *result);
+void rmDtbUtilResFreeNsAssignmentList(Rm_NsAssignment *nsAssignmentList);
 
 /**********************************************************************
  ***************Policy DTB Parsing Defines and Functions***************
@@ -132,13 +130,13 @@ typedef enum {
     /** Policy DTB unknown property type */
     Rm_policyPropType_UNKNOWN = 0,     
     /** Policy DTB resource assignments property type */
-    Rm_policyPropType_ASSIGNMENTS = 1,
-    /** Policy DTB resource allocation sizes property type */
-    Rm_policyPropType_ALLOCATION_SIZES = 2,
-    /** Policy DTB allocation alignments property type */
-    Rm_policyPropType_ALLOCATION_ALIGNMENTS = 3,
+    Rm_policyPropType_ASSIGNMENTS,
+    /** Policy DTB resource allocation size property type */
+    Rm_policyPropType_ALLOCATION_SIZE,
+    /** Policy DTB allocation alignment property type */
+    Rm_policyPropType_ALLOCATION_ALIGNMENT,
     /** Policy DTB valid RM instances property type */
-    Rm_policyPropType_VALID_INSTANCES = 4,
+    Rm_policyPropType_VALID_INSTANCES,
 } Rm_PolicyPropType;
 
 typedef struct Rm_PolicyAssignment_s {
@@ -149,31 +147,32 @@ typedef struct Rm_PolicyAssignment_s {
 } Rm_PolicyAssignment;
 
 typedef struct Rm_PolicyValidInst_s {
-    char *instName;
+    char                         instName[RM_INSTANCE_NAME_MAX_CHARS];
     struct Rm_PolicyValidInst_s *nextValidInst;
 } Rm_PolicyValidInst;
 
-Rm_PolicyPropType Rm_policyGetPropertyType(const char *propertyName);
-Rm_PolicyAssignment *Rm_policyExtractAssignments(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_policyFreeAssignments(Rm_PolicyAssignment *assignmentList);
-Rm_ResourceValue *Rm_policyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_policyFreeAllocationSizes(Rm_ResourceValue *allocationSizeList);
-Rm_ResourceValue *Rm_policyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_policyFreeResourceAlignments (Rm_ResourceValue *alignmentList);
-Rm_PolicyValidInst *Rm_policyExtractValidInstances(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_policyFreeValidInstances (Rm_PolicyValidInst *validInstList);
+Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char *propertyName);
+Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr, int32_t dtbDataLen);
+void rmDtbUtilPolicyFreeAssignments(Rm_PolicyAssignment *assignmentList);
+Rm_ResourceValue *rmDtbUtilPolicyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen);
+void rmDtbUtilPolicyFreeAllocationSizes(Rm_ResourceValue *allocationSizeList);
+Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen);
+void rmDtbUtilPolicyFreeResourceAlignments (Rm_ResourceValue *alignmentList);
+Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr, int32_t dtbDataLen, 
+                                                         int32_t *result);
+void rmDtbUtilPolicyFreeValidInstances (Rm_PolicyValidInst *validInstList);
 
 /**********************************************************************
  ****************Linux DTB Parsing Defines and Functions***************
  **********************************************************************/
 
-typedef struct {
-    uint32_t value;
-    void *nextValue;
+typedef struct Rm_LinuxValueRange_s {
+    uint32_t                     value;
+    struct Rm_LinuxValueRange_s *nextValue;
 } Rm_LinuxValueRange;
 
-Rm_LinuxValueRange *Rm_linuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen);
-void Rm_linuxFreeValues(Rm_LinuxValueRange *valueList);
+Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen);
+void rmDtbUtilLinuxFreeValues(Rm_LinuxValueRange *valueList);
 
 #ifdef __cplusplus
 }
index a5d65739b8a862953a49e37d60736137f221f52a..e62bf7d9b9ee48bed60fa8e394187a0496f806f2 100644 (file)
@@ -52,17 +52,12 @@ extern "C" {
 #include <ti/drv/rm/include/rm_servicesloc.h>
 #include <ti/drv/rm/include/rm_policyloc.h>
 #include <ti/drv/rm/include/rm_nameserverloc.h>
-
-/* AVL BBST includes */
-#include <ti/drv/rm/include/tree.h>
+#include <ti/drv/rm/include/rm_treeloc.h>
 
 /** Maximum size of a transmittable RM policy in bytes */
 #define RM_MAX_POLICY_SIZE_BYTES (64)  // Placeholder: This will change 
                                        // during development
 
-/** Pointer to RM instance's transport routing map */
-typedef void *Rm_TransportRouteMap;
-
 /** Pointer to RM instance's transaction queue */
 typedef void *Rm_TransactionQueue;
 
@@ -162,11 +157,12 @@ typedef struct {
     Rm_InstType             instType;
     bool                    registeredWithDelegateOrServer;
     void                   *policy;
+    void                   *staticPolicy;
     Rm_PolicyValidInstTree *validInstances;    
     Rm_Allocator           *allocators;
     Rm_NameServerTree      *nameServer;
     /* RM instance transport parameters */
-    Rm_TransportRouteMap    routeMap;
+    void                   *transports;
     /* RM Transaction sequence number counter */
     uint32_t                transactionSeqNum;
     /* RM transaction queue */
@@ -176,49 +172,16 @@ typedef struct {
     Rm_TransportCallouts    transport;
 } Rm_Inst;
 
-Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst);
-Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
-int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
-uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst);
-
-Rm_Allocator *Rm_allocatorFind(Rm_Allocator *allocatorList, char *resourceName);
-
-void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
-void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction);
-void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
-
-/**********************************************************************
- ******************* Red-Black Tree BBST Defines **********************
- **********************************************************************/
-
-/* Declare the tree structure nodes */
-typedef struct Rm_AllocatedTo_s {
-    Rm_PolicyValidInstNode  *instNameNode;
-    struct Rm_AllocatedTo_s *nextAllocatedTo;
-} Rm_AllocatedTo;
-
-typedef struct _Rm_ResourceNode {
-    RB_ENTRY(_Rm_ResourceNode)  linkage;
-    uint32_t                    base;
-    uint32_t                    length;
-    uint16_t                    allocationCount;
-    Rm_AllocatedTo             *allocatedTo;
-} Rm_ResourceNode;
-
-/* Declare the tree head structure.  A structure of type Rm_ResourceTree will need to be
- * malloc'd for each tree that is to be created. */
-typedef RB_HEAD(_Rm_ResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
-
-Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength);
-void Rm_freeResourceNode(Rm_ResourceNode *node);
-/* Prototype for tree node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2); 
-
-/* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);
+Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
+Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
+int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
+uint32_t rmTransactionGetSequenceNum(Rm_Inst *rmInst);
+
+Rm_Allocator *rmAllocatorFind(Rm_Allocator *allocatorList, char *resourceName);
+
+void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
+void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction);
+void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
 
 #ifdef __cplusplus
 }
index a45d0501bbaa6021a43cfbf45bf99ebb799049ae..583ec99c8c7c3ff0731bc49e9ed30e0aa17f70ea 100644 (file)
@@ -45,60 +45,25 @@ extern "C" {
 #endif
 
 /* RM external includes */
-#include <ti/drv/rm/rm.h>
 #include <ti/drv/rm/rm_services.h>
 
-/* AVL BBST includes */
-#include <ti/drv/rm/include/tree.h>
-
-typedef struct {
-    char     *objName;
-    char     *resourceName;
-    uint32_t  resourceBase;
-    uint32_t  resourceLength;
-} Rm_NameServerNodeCfg;
-
-/**********************************************************************
- ******************** NameServer Tree Definitions *********************
- **********************************************************************/
-
-/* Declare the tree structure nodes */
-typedef struct _Rm_NameServerNode {
-    RB_ENTRY(_Rm_NameServerNode) linkage;
-    char objName[RM_RESOURCE_NAME_MAX_CHARS];
-    char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
-    uint32_t resourceBase;
-    uint32_t resourceLength;
-} Rm_NameServerNode;
-
-/* Declare the tree head structure. */
-typedef RB_HEAD(_Rm_NameServerTree, _Rm_NameServerNode) Rm_NameServerTree;
-
-Rm_NameServerNode *Rm_nameServerNewNode(Rm_NameServerNodeCfg *nodeCfg);
-void Rm_nameServerFreeNode(Rm_NameServerNode *node);
-/* Prototype for NameServer node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); 
-
-/* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_nameServerNodeCompare);
+/* RM internal includes */
+#include <ti/drv/rm/include/rm_treeloc.h>
 
 /**********************************************************************
  ********************* Internal NameServer APIs ***********************
  **********************************************************************/
 
 typedef struct {
-    Rm_NameServerTree *nameServerTree;
-    Rm_NameServerNodeCfg nodeCfg;
+    Rm_NameServerTree    *nameServerTree;
+    Rm_NameServerNodeCfg  nodeCfg;
 } Rm_NameServerObjCfg;
 
-int32_t Rm_nameServerAddObject(Rm_NameServerObjCfg *objCfg);
-int32_t Rm_nameServerFindObject(Rm_NameServerObjCfg *objCfg);
-int32_t Rm_nameServerDeleteObject(Rm_NameServerObjCfg *objCfg);
-void Rm_nameServerPrintObjects(Rm_NameServerTree *nameServerTree);
-Rm_NameServerTree *Rm_nameServerInit(void);
+int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg);
+int32_t rmNameServerFindObject(Rm_NameServerObjCfg *objCfg);
+int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg);
+void rmNameServerPrintObjects(Rm_NameServerTree *nameServerTree);
+Rm_NameServerTree *rmNameServerInit(void);
 
 #ifdef __cplusplus
 }
index 1d439057fafedc2f4ab3a8dd01f2eb02fded0109..fca977689d0cee3d85cccf79325925b7eafbf1ce 100644 (file)
 extern "C" {
 #endif
 
-/* RM external API includes */
-#include <ti/drv/rm/rm_policy.h>
-
-/* AVL BBST includes */
-#include <ti/drv/rm/include/tree.h>
+/* RM internal includes */
+#include <ti/drv/rm/include/rm_treeloc.h>
 
 /** String stored for resource elements that are reserved by the Linux kernel.  These
  *  resources will be in use for the lifetime of the system 
@@ -99,33 +96,6 @@ typedef struct Rm_Permission_s {
     struct Rm_Permission_s *nextPermission;
 } Rm_PolicyPermission;
 
-/**********************************************************************
- ************** Policy Valid Instance Tree Definitions ****************
- **********************************************************************/
-
-/* Declare the tree structure nodes */
-typedef struct _Rm_PolicyValidInstNode {
-    RB_ENTRY(_Rm_PolicyValidInstNode) linkage;
-    char                        name[RM_INSTANCE_NAME_MAX_CHARS];
-    uint32_t                    allocRefCount;
-    bool                        deletePending;
-} Rm_PolicyValidInstNode;
-
-/* Declare the tree head structure. */
-typedef RB_HEAD(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode) Rm_PolicyValidInstTree;
-
-Rm_PolicyValidInstNode *Rm_policyNewValidInstNode(char *instName);
-void Rm_policyFreeValidInstNode(Rm_PolicyValidInstNode *node);
-/* Prototype for Valid Instance node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); 
-
-/* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode,
-             linkage, Rm_policyValidInstNodeCompare);
-
 /**********************************************************************
  *********************** Internal Policy APIs *************************
  **********************************************************************/
@@ -145,18 +115,18 @@ typedef struct {
     uint32_t                resourceLength;
 } Rm_PolicyCheckCfg;
 
-Rm_PolicyValidInstNode *Rm_policyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName);
-Rm_PolicyValidInstNode *Rm_policyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree);
-bool     Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result);
-uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
+Rm_PolicyValidInstNode *rmPolicyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName);
+Rm_PolicyValidInstNode *rmPolicyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree);
+bool     rmPolicyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result);
+uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
                                   int32_t resourceOffset, uint32_t allocType, 
                                   int32_t *result);
-uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourceOffset);
-int32_t  Rm_policyGetResourceOffset(void *policyDtb, char *resourceName);
-int32_t  Rm_policyValidatePolicyResourceNames(void *allocatorList, void *policyDtb);
-int32_t  Rm_policyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree);
-Rm_PolicyValidInstTree *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result);
-void     Rm_policyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree);
+uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset);
+int32_t  rmPolicyGetResourceOffset(void *policyDtb, char *resourceName);
+int32_t  rmPolicyValidatePolicyResourceNames(void *allocatorList, void *policyDtb);
+int32_t  rmPolicyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree);
+Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *result);
+void     rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree);
 
 #ifdef __cplusplus
 }
index db97dec161e08396d5bda3508e083a8c30e64ef6..bf5c3e16a51305ae309a778283eba338cba93371 100644 (file)
@@ -55,7 +55,7 @@ extern "C" {
  *        transport nodes are provided to the application casted
  *        as a Rm_TransportHandle
  */
-typedef struct {
+typedef struct Rm_Transport_s {
     /** The RM instance that this node belongs to */
     Rm_Handle rmHandle;
     /** The remote RM instance type */
@@ -63,8 +63,8 @@ typedef struct {
     /** The remote RM instance name */
     char remoteInstName[RM_INSTANCE_NAME_MAX_CHARS];
     /** Link to the next route node in the route map list */
-    void *nextNode;
-} Rm_TransportNode;
+    struct Rm_Transport_s *nextTransport;
+} Rm_Transport;
 
 /**********************************************************************
  ************************* RM Packet Defs *****************************
@@ -238,22 +238,16 @@ typedef struct {
     Rm_ResourceInfo resourceInfo;
 } Rm_ResourcePoolModResponsePkt;
 
-Rm_TransportNode *Rm_transportNodeAdd(Rm_Inst *rmInst, Rm_TransportCfg *transportCfg);
-Rm_TransportNode *Rm_transportNodeFindTransportHandle(Rm_Inst *rmInst, 
-                                                      Rm_TransportHandle transportHandle);
-Rm_TransportNode *Rm_transportNodeFindRemoteName(Rm_Inst *rmInst, char *remoteName);
-Rm_TransportNode *Rm_transportNodeFindRemoteInstType(Rm_Inst *rmInst,
-                                                     Rm_InstType remoteInstType);
-Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, 
-                                          Rm_TransportHandle transportHandle);
-Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
-                                            Rm_Transaction *transaction);
-Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
-                                                 Rm_Transaction *transaction);
-Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
-                                          Rm_Transaction *transaction);
-Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
+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_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);
 
 #ifdef __cplusplus
 }
diff --git a/include/rm_treeloc.h b/include/rm_treeloc.h
new file mode 100644 (file)
index 0000000..a32ed16
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ *  file  rm_treeloc.h
+ *
+ *  Prototypes and data structures for the various RM Trees.
+ *
+ *  ============================================================================
+ *      (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    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.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  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.
+ *
+ *  \par
+*/
+
+#ifndef RM_TREELOC_H_
+#define RM_TREELOC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* RM external includes */
+#include <ti/drv/rm/rm.h>
+#include <ti/drv/rm/rm_services.h>
+
+/* AVL BBST includes */
+#include <ti/drv/rm/include/tree.h>
+
+/**********************************************************************
+ *************** Tree Node Data Structure Definitions *****************
+ **********************************************************************/
+
+typedef struct {
+    char     *objName;
+    char     *resourceName;
+    uint32_t  resourceBase;
+    uint32_t  resourceLength;
+} Rm_NameServerNodeCfg;
+
+typedef struct _Rm_NameServerNode {
+    RB_ENTRY(_Rm_NameServerNode) linkage;
+    char                         objName[RM_RESOURCE_NAME_MAX_CHARS];
+    char                         resourceName[RM_RESOURCE_NAME_MAX_CHARS];
+    uint32_t                     resourceBase;
+    uint32_t                     resourceLength;
+} Rm_NameServerNode;
+
+typedef RB_HEAD(_Rm_NameServerTree, _Rm_NameServerNode) Rm_NameServerTree;
+
+typedef struct _Rm_PolicyValidInstNode {
+    RB_ENTRY(_Rm_PolicyValidInstNode) linkage;
+    char                              name[RM_INSTANCE_NAME_MAX_CHARS];
+    uint32_t                          allocRefCount;
+    bool                              deletePending;
+} Rm_PolicyValidInstNode;
+
+typedef RB_HEAD(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode) Rm_PolicyValidInstTree;
+
+typedef struct Rm_Owner_s {
+    Rm_PolicyValidInstNode  *instNameNode;
+    struct Rm_Owner_s *nextOwner;
+} Rm_Owner;
+
+typedef struct _Rm_ResourceNode {
+    RB_ENTRY(_Rm_ResourceNode)  linkage;
+    uint32_t                    base;
+    uint32_t                    length;
+    uint16_t                    allocationCount;
+    Rm_Owner                    *ownerList;
+} Rm_ResourceNode;
+
+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_PolicyValidInstNode *policyValidInstNodeNew(char *instName);
+void policyValidInstNodeFree(Rm_PolicyValidInstNode *node);
+int policyValidInstNodeCompare(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); 
+
+/**********************************************************************
+ ******************** 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RM_NAMESERVERLOC_H_ */
+
index 790f810a51b427cb85f065b548d37845fbae5331..9fd9ff73e32c51fc07bd2df550066f6a229cf19e 100644 (file)
@@ -88,7 +88,6 @@ Pkg.otherFiles[Pkg.otherFiles.length++] = "package.xdc";
 Pkg.otherFiles[Pkg.otherFiles.length++] = "Settings.xdc";\r
 Pkg.otherFiles[Pkg.otherFiles.length++] = "Settings.xdc.xdt";\r
 Pkg.otherFiles[Pkg.otherFiles.length++] = "rm.h";\r
-Pkg.otherFiles[Pkg.otherFiles.length++] = "rm_policy.h";\r
 Pkg.otherFiles[Pkg.otherFiles.length++] = "rm_services.h";\r
 Pkg.otherFiles[Pkg.otherFiles.length++] = "rm_transport.h";\r
 Pkg.otherFiles[Pkg.otherFiles.length++] = "rm_types.h";\r
diff --git a/rm.h b/rm.h
index 6e209076440f1ac2e9db8342c6f02fdf71fdd535..d10d6ead552adcbfa2f938eff8903421945d5cab 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -151,6 +151,10 @@ extern "C" {
 #define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INVALID_CHAR_ON_RIGHT_WITH_ASSINMENT_ON_LEFT -265
 #define RM_INIT_ERROR_PREMAIN_INST_AND_POSTMAIN_INST_NAMES_DONT_MATCH -266
 #define RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE_PROPERTY -267
+#define RM_INIT_ERROR_POLICY_VALID_INSTANCE_NAME_TOO_LONG -268
+#define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INSTANCE_NAME_IN_ASSIGNMENT_TOO_LONG -269
+#define RM_INIT_ERROR_NS_ASSIGNMENT_NAME_TOO_LONG -270
+#define RM_INIT_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT -271
 
 /** 
  * @brief Maximum number of characters in a RM instance name
diff --git a/rm_policy.h b/rm_policy.h
deleted file mode 100644 (file)
index 54fc33e..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- *   @file  rm_policy.h
- *
- *   @brief   
- *      This is the RM include file for the policy APIs
- *
- *  \par
- *  ============================================================================
- *  @n   (C) Copyright 2012, Texas Instruments, Inc.
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    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.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  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.
- *
- *  \par
-*/
-
-#ifndef RM_POLICY_H_
-#define RM_POLICY_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* RM includes */
-#include <ti/drv/rm/rm.h>
-
-/**
-@addtogroup RM_POLICY_API
-@{
-*/
-/**
- * @brief Maximum number of characters in the policy name
- */
-#define RM_MAX_POLICY_NAME_LENGTH 8
-
-/**
- * @brief Policy handle (Flattened Device Tree (fdt) blob format)
- */
-typedef void *Rm_PolicyHandle;
-
-/** 
- * @brief Result of RM policy operations
- */
-typedef int32_t   Rm_PolicyResult;
-
-/**
- * @brief Structure populated by policy API with basic RM policy information
- */
-typedef struct {
-    /** Policy name */
-    char policyName[RM_MAX_POLICY_NAME_LENGTH] ;
-    /** Policy handle */
-    Rm_PolicyHandle policyHandle;
-} Rm_PolicyInfo;
-
-/**
- *  @b Description
- *  @n  
- *      This function returns the number of policies located within a RM
- *      instance tree
- *
- *  @param[in]  serverHandle
- *      RM tree's server handle.  Used to report the number of policies for
- *      the given server handle's instance tree
- *
- *  @retval
- *      Number of policies located within the instance tree
- */
-uint32_t Rm_numPoliciesInTree(Rm_Handle serverHandle);
-
-/**
- *  @b Description
- *  @n  
- *      This function returns a list of all policies within the system.  The
- *      list will contain a policy name and handle for each policy.
- *
- *  @param[in]  serverHandle
- *      RM tree's server handle.  Used to query the policy information for
- *      the given server handle's instance tree
- *
- *  @param[in]  *policyInfoArray
- *      An array of Rm_PolicyInfo structures that will contain information for
- *      all policies within the instance tree upon function return.
- *
- *      Note: The size of the array passed must be equal to or greater than 
- *            the number of policies returned by the Rm_numPoliciesInTree API
- *
- *  @retval
- *      SUCCESS - 0
- *  @retval
- *      FAILURE - non-zero value
- */
-Rm_PolicyResult Rm_listPolicies(Rm_Handle serverHandle, Rm_PolicyInfo *policyInfoArray);
-
-#if 0
-The following API input parameters are not finalized yet as they are a wrapper around the DTB modification APIs provided in the dtc library.  The input parameters will be finalized as the operation of the dtc API is better understood.
-
-/* Policy create/delete APIs */
-
-/* May not allow additional input parameters.  Created policies can be
- * modified using the policy modification APIs */
-Rm_PolicyHandle Rm_createPolicy(Rm_Handle serverHandle, ...);
-Rm_PolicyResult Rm_deletePolicy(Rm_PolicyHandle);
-
-/* Policy modification APIs */
-Rm_PolicyResult Rm_addInstToPolicy(Rm_PolicyHandle, ...);
-Rm_PolicyResult Rm_deleteInstFromPolicy(Rm_PolicyHandle, ...);
-Rm_PolicyResult Rm_addResourceToPolicy(Rm_PolicyHandle, instName, ...);
-Rm_PolicyResult Rm_deleteResourceFromPolicy(Rm_PolicyHandle, instName, ...);
-Rm_PolicyResult Rm_modifyResourceProp(Rm_PolicyHandle, instName, resName ...);
-
-/* Read Policy APIs */
-Rm_PolicyResult Rm_listPolicyInstances(Rm_PolicyHandle, ...);
-Rm_PolicyResult Rm_listInstResources(Rm_PolicyHandle, instName, ...);
-Rm_PolicyResult Rm_listPolicyResourceProperties(Rm_PolicyHandle, instName, 
-                                                resourceName, ...);
-#endif
-
-/** 
-@} 
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RM_POLICY_H_ */
index a4c4ce91077ab0cc9c6b9c3c4b3636dd10955bf3..bc23dcb5d4b74327ba5c88ed1bb5c8b4d236b890 100644 (file)
@@ -193,7 +193,9 @@ typedef enum {
     /** RM resource get by name service */
     Rm_service_RESOURCE_GET_BY_NAME,
     /** RM resource name unmapping service */
-    Rm_service_RESOURCE_UNMAP_NAME
+    Rm_service_RESOURCE_UNMAP_NAME,
+    /** DO NOT USE: Last type */
+    Rm_service_LAST
 } Rm_ServiceType;
 
 /** 
@@ -290,8 +292,8 @@ typedef struct {
      *      Service response structure that provides details of RM's response to the
      *      service request
      */
-    void (*rmService)(void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
-                      Rm_ServiceRespInfo *serviceResponse);
+    void (*Rm_serviceHandler)(void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
+                              Rm_ServiceRespInfo *serviceResponse);
 } Rm_ServicePort;
 
 /** 
index d986ba3e97840d32bacc1a8b27fcea84bb798354..6a961838b82e4b4ebf470a0dd06930c0a2aaf907 100644 (file)
@@ -65,8 +65,6 @@ extern "C" {
 #define RM_TRANSPORT_ERROR_BASE (-64)
 /** RM transport handle has not been registered with the RM instance */
 #define RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED (RM_TRANSPORT_ERROR_BASE-1)
-/** No transports have been registered with the RM instance */
-#define RM_TRANSPORT_ERROR_NO_TRANSPORTS_REGISTERED  (RM_TRANSPORT_ERROR_BASE-2)
 /** RM packets are available but an error was encountered during reception */
 #define RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR (RM_TRANSPORT_ERROR_BASE-3)
 /** RM received a packet with an unknown RM packet type */
@@ -237,6 +235,8 @@ typedef struct {
  * @brief RM transport registration configuration structure
  */
 typedef struct {
+    /** The RM Handle for which the transport is being registered */
+    Rm_Handle rmHandle;
     /** The transport's remote RM instance type */
     Rm_InstType remoteInstType;
     /** Pointer to the transport's remote RM instance name */
@@ -280,14 +280,9 @@ typedef struct {
  *  @retval
  *      Failure - NULL
  */
-Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, 
-                                         Rm_TransportCfg *transportCfg);
-
-Rm_TransportResult Rm_transportUnregister (Rm_Handle rmHandle, 
-                                           Rm_TransportHandle transportHandle);
-
+Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result);
+Rm_TransportResult 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);
 
 
index 16de9a4f50f63e861c547c645de5ae642eb5143f..f81b0c169990a8c081f5478634bdef5d22770f54 100644 (file)
@@ -18,6 +18,7 @@ var rmFile = [
     "src/rm_policy.c",
     "src/rm_services.c",
     "src/rm_transport.c",
+    "src/rm_tree.c",
     "src/rm_dtb_util.c",
     "src/libfdt/fdt.c",
     "src/libfdt/fdt_ro.c",
index b7ba1871b7bac342e4dd8cb9e887524482357b0d..eedda3c0def0fd592df0ad3fb61d7c22fd41a67f 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -46,7 +46,6 @@
 #include <ti/drv/rm/rm.h>\r
 #include <ti/drv/rm/rm_services.h>\r
 #include <ti/drv/rm/rm_transport.h>\r
-#include <ti/drv/rm/rm_policy.h>\r
 \r
 /* RM internal includes */\r
 #include <ti/drv/rm/include/rm_loc.h>\r
@@ -55,6 +54,7 @@
 #include <ti/drv/rm/include/rm_nameserverloc.h>\r
 #include <ti/drv/rm/include/rm_dtb_utilloc.h>\r
 #include <ti/drv/rm/include/rm_policyloc.h>\r
+#include <ti/drv/rm/include/rm_treeloc.h>\r
 \r
 /* RM LIBFDT includes */\r
 #include <ti/drv/rm/src/libfdt/libfdt.h>\r
 extern char rmDtbStartingNode[];\r
 \r
 /** @brief Global Variable which describes the RM Version Information */\r
-const char   rmVersionStr[] = RM_VERSION_STR ":" __DATE__  ":" __TIME__;\r
-\r
-/**********************************************************************\r
- ************** Red-Black BBST Tree Allocator Functions ***************\r
- **********************************************************************/\r
-\r
-\r
-Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength)\r
-{\r
-    Rm_ResourceNode *newNode = NULL;\r
-\r
-    newNode = Rm_osalMalloc(sizeof(Rm_ResourceNode));\r
-    memset((void *)newNode, 0, sizeof(Rm_ResourceNode));\r
-\r
-    newNode->base = resourceBase;\r
-    newNode->length = resourceLength;\r
-    newNode->allocationCount = 0;\r
-    newNode->allocatedTo = NULL;\r
-\r
-    return(newNode);\r
-}\r
-\r
-void Rm_freeResourceNode(Rm_ResourceNode *node)\r
-{\r
-    if (node->allocationCount == 0) {\r
-        Rm_osalFree((void *)node, sizeof(Rm_ResourceNode));\r
-    }\r
-}\r
-\r
-/* Prototype for tree node comparison function\r
- * element1 < element2 --> return < 0\r
- * element1 = element2 --> return 0\r
- * element1 > element2 --> return > 0 */\r
-int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2)\r
-{\r
-    uint32_t element1End = element1->base + element1->length - 1;\r
-    uint32_t element2End = element2->base + element2->length - 1;\r
-\r
-    if (element1End < element2->base) {\r
-        /* End of element1 range is less than the start of element2's range.  Return a negative\r
-         * value */\r
-        return (-1);\r
-    }\r
-    else if (element1->base > element2End) {\r
-        /* Start of element1 range is after end of element2's range.  Return a positive value */\r
-        return (1);\r
-    }\r
-    else {\r
-        /* If neither of the latter conditions were satisfied there is some overlap between\r
-         * element1 and element2.  Return 0 since the application must handle this overlap. */\r
-        return (0);\r
-    }\r
-}\r
-\r
-/* Generate the red-black tree manipulation functions */\r
-RB_GENERATE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);\r
+const char  rmVersionStr[] = RM_VERSION_STR ":" __DATE__  ":" __TIME__;\r
 \r
 /**********************************************************************\r
  ********************** Internal Functions ****************************\r
  **********************************************************************/\r
 \r
-Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst)\r
+Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst)\r
 {\r
     Rm_Transaction *transactionQueue = (Rm_Transaction *)rmInst->transactionQueue;\r
     Rm_Transaction *newTransaction   = NULL;\r
-    void           *key;\r
 \r
-    /* Lock access to the RM instance's transaction queue */\r
-    key = Rm_osalMtCsEnter();\r
-\r
-    /* Get memory for a new transaction from local memory */\r
     newTransaction = Rm_osalMalloc(sizeof(Rm_Transaction));\r
-\r
-    /* Return if the memory allocated for the transaction entry is NULL */\r
-    if (newTransaction != NULL) {\r
-        /* Clear the transaction */\r
+    if (newTransaction) {\r
         memset((void *)newTransaction, 0, sizeof(Rm_Transaction));\r
 \r
-        /* Create an ID for the new transaction.  The ID will be used for two purposes:\r
-         * 1) Matching responses from higher level RM agents to requests\r
-         * 2) Provided to the component that requested the service so that it can match its\r
-         *    request with the response it receives via its callback function it provided */\r
-        newTransaction->localId = Rm_transactionGetSequenceNum(rmInst);\r
-        /* New transaction's nextTransaction pointer will always be NULL */\r
+        newTransaction->localId = rmTransactionGetSequenceNum(rmInst);\r
         newTransaction->nextTransaction = NULL;  \r
-\r
-        /* Check if there are any transactions in the transaction queue */\r
         if (transactionQueue) {\r
-            /* At least one transaction in the transaction queue.  Add the new entry to the \r
-             * end of the transaction queue */\r
             while (transactionQueue->nextTransaction != NULL) {\r
-                /* Traverse the list until arriving at the last transaction */\r
                 transactionQueue = transactionQueue->nextTransaction;\r
             }\r
-\r
-            /* Add the new transaction to the end of the queue */\r
             transactionQueue->nextTransaction = newTransaction;\r
         }\r
         else {\r
-            /* The transaction queue does not currently exist.  The new transaction is the \r
-             * first transaction */\r
             rmInst->transactionQueue = newTransaction;\r
         }\r
     }\r
-\r
-    Rm_osalMtCsExit(key);\r
     return (newTransaction);\r
 }\r
 \r
-Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)\r
+Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)\r
 {\r
     Rm_Transaction *transaction = (Rm_Transaction *)rmInst->transactionQueue;\r
 \r
@@ -195,17 +116,12 @@ Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
     return (transaction);\r
 }\r
 \r
-int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)\r
+int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)\r
 {\r
     Rm_Transaction *transaction     = (Rm_Transaction *) rmInst->transactionQueue;\r
     Rm_Transaction *prevTransaction = NULL;\r
     int32_t         retVal          = RM_SERVICE_STATE_OKAY;\r
-    void           *key;\r
-\r
-    /* Lock access to the instance */\r
-    key = Rm_osalMtCsEnter();\r
 \r
-    /* Find transaction ID within transaction queue. */\r
     while (transaction) {\r
         if (transaction->localId == transactionId) {\r
             break;             \r
@@ -230,26 +146,24 @@ int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
     else {\r
         retVal = RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST;\r
     }    \r
-\r
-    Rm_osalMtCsExit(key);\r
     return (retVal);\r
 }\r
 \r
-uint32_t Rm_transactionInitSequenceNum(void)\r
+uint32_t rmTransactionInitSequenceNum(void)\r
 {\r
     /* Sequence number can never have value of 0.  Avoids conflicts\r
      * with non-response transactions that have remoteOriginatingId of 0 */\r
     return (1);\r
 }\r
 \r
-uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst)\r
+uint32_t rmTransactionGetSequenceNum(Rm_Inst *rmInst)\r
 {\r
     uint32_t sequenceNum = 0;\r
 \r
     if (rmInst->transactionSeqNum + 1 < rmInst->transactionSeqNum) {\r
         /* Overflow */\r
         sequenceNum = rmInst->transactionSeqNum;\r
-        rmInst->transactionSeqNum = Rm_transactionInitSequenceNum();\r
+        rmInst->transactionSeqNum = rmTransactionInitSequenceNum();\r
     }\r
     else {\r
         sequenceNum = rmInst->transactionSeqNum++;\r
@@ -257,20 +171,16 @@ uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst)
     return (sequenceNum);\r
 }\r
 \r
-Rm_Allocator *Rm_allocatorAdd(Rm_Inst *rmInst, const char *resourceName)\r
+Rm_Allocator *rmAllocatorAdd(Rm_Inst *rmInst, const char *resourceName)\r
 {\r
     Rm_Allocator *allocators   = (Rm_Allocator *)rmInst->allocators;\r
     Rm_Allocator *newAllocator = NULL;\r
-    void         *key;\r
-\r
-    /* Lock access to the instance */\r
-    key = Rm_osalMtCsEnter();\r
 \r
     newAllocator = Rm_osalMalloc(sizeof(Rm_Allocator));\r
 \r
     if (newAllocator) {\r
         memset((void *)newAllocator, 0, sizeof(Rm_Allocator));\r
-        strcpy(newAllocator->resourceName, resourceName);\r
+        strncpy(newAllocator->resourceName, resourceName, RM_RESOURCE_NAME_MAX_CHARS);\r
         newAllocator->allocatorRootEntry = NULL;\r
         newAllocator->nextAllocator = NULL;  \r
 \r
@@ -285,12 +195,10 @@ Rm_Allocator *Rm_allocatorAdd(Rm_Inst *rmInst, const char *resourceName)
             rmInst->allocators = newAllocator;\r
         }\r
     }\r
-\r
-    Rm_osalMtCsExit(key);\r
     return (newAllocator);\r
 }\r
 \r
-Rm_Allocator *Rm_allocatorFind(Rm_Allocator *allocatorList, char *resourceName)\r
+Rm_Allocator *rmAllocatorFind(Rm_Allocator *allocatorList, char *resourceName)\r
 {\r
     while (allocatorList) {\r
         if (strcmp(allocatorList->resourceName, resourceName) == 0) {\r
@@ -302,15 +210,11 @@ Rm_Allocator *Rm_allocatorFind(Rm_Allocator *allocatorList, char *resourceName)
     return (allocatorList);\r
 }\r
 \r
-int32_t Rm_allocatorDelete(Rm_Inst *rmInst, char *resourceName)\r
+int32_t rmAllocatorDelete(Rm_Inst *rmInst, char *resourceName)\r
 {\r
     Rm_Allocator *allocator = (Rm_Allocator *) rmInst->allocators;\r
     Rm_Allocator *prevAllocator = NULL;\r
     int32_t       retVal = RM_SERVICE_STATE_OKAY;\r
-    void         *key;\r
-\r
-    /* Lock access to instance */\r
-    key = Rm_osalMtCsEnter();\r
 \r
     while (allocator) {\r
         if (strcmp(allocator->resourceName, resourceName) == 0) {\r
@@ -335,71 +239,69 @@ int32_t Rm_allocatorDelete(Rm_Inst *rmInst, char *resourceName)
     else {\r
         retVal = -22; /* TEMP ERROR: Can't conflict with LIBFDT errors */\r
     }\r
-\r
-    Rm_osalMtCsExit(key);\r
     return (retVal);\r
 }\r
 \r
-void Rm_addAllocatedTo(Rm_ResourceNode *node, void *serviceInstNode)\r
+void rmAddOwner(Rm_ResourceNode *node, void *serviceInstNode)\r
 {\r
-    Rm_AllocatedTo *allocatedToList = node->allocatedTo;\r
-    Rm_AllocatedTo *newAllocatedTo = NULL;\r
+    Rm_Owner *ownerList = node->ownerList;\r
+    Rm_Owner *newOwner = NULL;\r
 \r
-    newAllocatedTo = Rm_osalMalloc(sizeof(Rm_AllocatedTo));\r
+    newOwner = Rm_osalMalloc(sizeof(Rm_Owner));\r
 \r
-    if (newAllocatedTo) {\r
-        newAllocatedTo->instNameNode = serviceInstNode;\r
-        newAllocatedTo->nextAllocatedTo = NULL;  \r
+    if (newOwner) {\r
+        newOwner->instNameNode = serviceInstNode;\r
+        newOwner->nextOwner = NULL;  \r
 \r
-        /* Add allocatedTo entry to end of list */\r
-        if (allocatedToList) {\r
-            while (allocatedToList->nextAllocatedTo) {\r
-                allocatedToList = allocatedToList->nextAllocatedTo;\r
+        /* Add owner entry to end of list */\r
+        if (ownerList) {\r
+            while (ownerList->nextOwner) {\r
+                ownerList = ownerList->nextOwner;\r
             }\r
-            allocatedToList->nextAllocatedTo = newAllocatedTo;\r
+            ownerList->nextOwner = newOwner;\r
         }\r
         else {\r
-            node->allocatedTo = newAllocatedTo;\r
+            node->ownerList = newOwner;\r
         }\r
 \r
         node->allocationCount++;\r
-        newAllocatedTo->instNameNode->allocRefCount++;\r
+        newOwner->instNameNode->allocRefCount++;\r
     }\r
 }\r
 \r
-bool Rm_isAllocatedTo(Rm_ResourceNode *node, void *serviceInstNode)\r
+bool rmIsOwnedBy(Rm_ResourceNode *node, void *serviceInstNode)\r
 {\r
-    Rm_AllocatedTo *allocatedTo = node->allocatedTo;\r
+    Rm_Owner *owner = node->ownerList;\r
 \r
-    while (allocatedTo) {\r
-        if (allocatedTo->instNameNode == serviceInstNode) {\r
+    while (owner) {\r
+        if (owner->instNameNode == serviceInstNode) {\r
             return(TRUE);           \r
         }\r
-        allocatedTo = allocatedTo->nextAllocatedTo;\r
+        owner = owner->nextOwner;\r
     }\r
     return(FALSE);\r
 }\r
 \r
-bool Rm_compareResourceNodeAllocations(Rm_ResourceNode *nodeOne, Rm_ResourceNode *nodeTwo)\r
+bool rmCompareResourceNodeOwners(Rm_ResourceNode *node1, Rm_ResourceNode *node2)\r
 {\r
-    Rm_AllocatedTo *nodeOneAllocs = nodeOne->allocatedTo;\r
-    Rm_AllocatedTo *nodeTwoAllocs = nodeTwo->allocatedTo;\r
-    bool            matchedInst;\r
+    Rm_Owner *node1Owners = node1->ownerList;\r
+    Rm_Owner *node2Owners = node2->ownerList;\r
+    bool      matchedInst;\r
 \r
-    if (nodeOne->allocationCount == nodeTwo->allocationCount) {\r
-        while (nodeOneAllocs) {\r
+    if (node1->allocationCount == node2->allocationCount) {\r
+        while (node1Owners) {\r
             matchedInst = FALSE;\r
-            while (nodeTwoAllocs) {\r
-                if (nodeOneAllocs->instNameNode == nodeTwoAllocs->instNameNode) {\r
+            while (node2Owners) {\r
+                if (node1Owners->instNameNode == node2Owners->instNameNode) {\r
                     matchedInst = TRUE;\r
                     break;\r
                 }\r
-                nodeTwoAllocs = nodeTwoAllocs->nextAllocatedTo;\r
+                node2Owners = node2Owners->nextOwner;\r
             }\r
 \r
             if (matchedInst) {\r
-                nodeTwoAllocs = nodeTwo->allocatedTo;\r
-                nodeOneAllocs = nodeOneAllocs->nextAllocatedTo;\r
+                node2Owners = node2->ownerList;\r
+                node1Owners = node1Owners->nextOwner;\r
             }\r
             else {\r
                 return(FALSE);\r
@@ -413,97 +315,94 @@ bool Rm_compareResourceNodeAllocations(Rm_ResourceNode *nodeOne, Rm_ResourceNode
     return(TRUE);\r
 }\r
 \r
-void Rm_deleteAllocatedTo(Rm_ResourceNode *node, void *serviceInstNode)\r
+void rmDeleteOwner(Rm_ResourceNode *node, void *serviceInstNode)\r
 {\r
-    Rm_AllocatedTo *allocatedTo = node->allocatedTo;\r
-    Rm_AllocatedTo *prevAllocatedTo = NULL;\r
+    Rm_Owner *owner = node->ownerList;\r
+    Rm_Owner *prevOwner = NULL;\r
 \r
-    while (allocatedTo) {\r
-        if (allocatedTo->instNameNode == serviceInstNode) {\r
+    while (owner) {\r
+        if (owner->instNameNode == serviceInstNode) {\r
             break;             \r
         }\r
-        prevAllocatedTo = allocatedTo;\r
-        allocatedTo = allocatedTo->nextAllocatedTo;\r
+        prevOwner = owner;\r
+        owner = owner->nextOwner;\r
     }\r
 \r
-    if (prevAllocatedTo == NULL) {\r
-        /* AllocatedTo entry at start of list. Map second allocatedTo entry to start of list \r
-         * as long as more than one allocatedTo entries. */\r
-        node->allocatedTo = allocatedTo->nextAllocatedTo;\r
+    if (prevOwner == NULL) {\r
+        node->ownerList = owner->nextOwner;\r
     }\r
     else {\r
-        /* AllocatedTo entry in middle or end of list. */\r
-        prevAllocatedTo->nextAllocatedTo = allocatedTo->nextAllocatedTo;\r
+        prevOwner->nextOwner = owner->nextOwner;\r
     }\r
     \r
     node->allocationCount--;\r
-    allocatedTo->instNameNode->allocRefCount--;\r
-    Rm_osalFree((void *)allocatedTo, sizeof(Rm_AllocatedTo));\r
+    owner->instNameNode->allocRefCount--;\r
+    Rm_osalFree((void *)owner, sizeof(Rm_Owner));\r
 }\r
 \r
-void Rm_copyAllocatedTo(Rm_ResourceNode *dstNode, Rm_ResourceNode *srcNode)\r
+void rmCopyOwners(Rm_ResourceNode *dstNode, Rm_ResourceNode *srcNode)\r
 {\r
-    Rm_AllocatedTo *srcAllocs = srcNode->allocatedTo;\r
-    Rm_AllocatedTo *newDstAlloc;\r
-    Rm_AllocatedTo *prevDstAlloc;\r
+    Rm_Owner *srcOwnerList = srcNode->ownerList;\r
+    Rm_Owner *dstNewOwner;\r
+    Rm_Owner *dstPrevOwner;\r
 \r
     dstNode->allocationCount = srcNode->allocationCount;\r
 \r
-    while (srcAllocs) {\r
-        newDstAlloc = Rm_osalMalloc(sizeof(Rm_AllocatedTo));\r
-        newDstAlloc->instNameNode = srcAllocs->instNameNode;\r
-        newDstAlloc->nextAllocatedTo = NULL;\r
+    while (srcOwnerList) {\r
+        dstNewOwner = Rm_osalMalloc(sizeof(Rm_Owner));\r
+        dstNewOwner->instNameNode = srcOwnerList->instNameNode;\r
+        dstNewOwner->nextOwner = NULL;\r
 \r
-        if (dstNode->allocatedTo == NULL) {\r
-            dstNode->allocatedTo = newDstAlloc;\r
+        if (dstNode->ownerList == NULL) {\r
+            dstNode->ownerList = dstNewOwner;\r
         }\r
         else {\r
-            prevDstAlloc->nextAllocatedTo = newDstAlloc;\r
+            dstPrevOwner->nextOwner = dstNewOwner;\r
         }\r
-        prevDstAlloc = newDstAlloc;\r
-        srcAllocs = srcAllocs->nextAllocatedTo;\r
+        dstPrevOwner = dstNewOwner;\r
+        srcOwnerList = srcOwnerList->nextOwner;\r
     }\r
 }\r
 \r
-void Rm_clearAllocatedTo(Rm_ResourceNode *node)\r
+void rmClearOwners(Rm_ResourceNode *node)\r
 {\r
-    Rm_AllocatedTo *allocatedTo = node->allocatedTo;\r
-    Rm_AllocatedTo *nextAllocatedTo;\r
+    Rm_Owner *owner = node->ownerList;\r
+    Rm_Owner *nextOwner;\r
 \r
-    while (allocatedTo) {\r
-        nextAllocatedTo = allocatedTo->nextAllocatedTo;\r
+    while (owner) {\r
+        nextOwner = owner->nextOwner;\r
         node->allocationCount--;\r
-        Rm_osalFree((void *)allocatedTo, sizeof(Rm_AllocatedTo));\r
-        allocatedTo = nextAllocatedTo;\r
+        Rm_osalFree((void *)owner, sizeof(Rm_Owner));\r
+        owner = nextOwner;\r
     }\r
 }\r
 \r
-int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_ResourceRange *range)\r
+int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_ResourceRange *range)\r
 {\r
     Rm_Allocator    *allocator = NULL;\r
     Rm_ResourceTree *treeRootEntry = NULL;\r
     Rm_ResourceNode *treeNode = NULL;\r
     Rm_ResourceNode *collidingNode = NULL;\r
 \r
-    allocator = Rm_allocatorAdd(rmInst, resourceName);\r
+    allocator = rmAllocatorAdd(rmInst, resourceName);\r
     treeRootEntry = Rm_osalMalloc(sizeof(Rm_ResourceTree));\r
     RB_INIT(treeRootEntry);\r
 \r
     while (range != NULL) {\r
-        treeNode = Rm_newResourceNode(range->base, range->length);\r
-        collidingNode = RB_INSERT(_Rm_ResourceTree, treeRootEntry, treeNode);\r
+        treeNode = resourceNodeNew(range->base, range->length);\r
+        collidingNode = RB_INSERT(_Rm_AllocatorResourceTree, treeRootEntry, treeNode);\r
 \r
         if (collidingNode) {\r
             Rm_ResourceNode *nextNode = NULL;\r
             \r
             /* Node that was inserted collides with existing node.  Destroy tree and return error */\r
-            for (treeNode = RB_MIN(_Rm_ResourceTree, treeRootEntry); treeNode != NULL; treeNode = nextNode) {\r
-                       nextNode = RB_NEXT(_Rm_ResourceTree, treeRootEntry, treeNode);\r
-                       RB_REMOVE(_Rm_ResourceTree, treeRootEntry, nextNode);\r
-                Rm_freeResourceNode(treeNode);\r
+            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
                }\r
             Rm_osalFree((void *)treeRootEntry, sizeof(Rm_ResourceTree));\r
-            Rm_allocatorDelete(rmInst, allocator->resourceName);\r
+            rmAllocatorDelete(rmInst, allocator->resourceName);\r
             return (-24); /* TODO FIX RETURN */\r
         }\r
         range = range->nextRange;\r
@@ -518,8 +417,8 @@ int32_t Rm_createTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Res
  * policy does not agree another resource(s) must be preallocated and tested against the \r
  * policy.  Policy will provide initialize the preallocate with the base that it allows\r
  * for the rm instance for the specified resource. */\r
-int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy,\r
-                           Rm_AllocatorOpInfo *opInfo)\r
+int32_t rmTreePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy,\r
+                          Rm_AllocatorOpInfo *opInfo)\r
 {\r
     Rm_ResourceNode    findNode;\r
     Rm_ResourceNode   *matchingNode = NULL;\r
@@ -531,7 +430,7 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
     bool               nodePassesPolicy;\r
     int32_t            retVal = RM_SERVICE_PROCESSING;    \r
 \r
-    opInfo->resourceInfo->base = Rm_policyGetResourceBase(rmInst->policy, opInfo->serviceSrcInstNode, \r
+    opInfo->resourceInfo->base = rmPolicyGetResourceBase(rmInst->policy, opInfo->serviceSrcInstNode, \r
                                                           resourcePolicy, opInfo->allocType, \r
                                                           &retVal);\r
     if (retVal != RM_SERVICE_PROCESSING) {\r
@@ -540,7 +439,7 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
 \r
     if (opInfo->resourceInfo->alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {  \r
         /* Get alignment from policy */\r
-        opInfo->resourceInfo->alignment = Rm_policyGetResourceAlignment(rmInst->policy, resourcePolicy);\r
+        opInfo->resourceInfo->alignment = rmPolicyGetResourceAlignment(rmInst->policy, resourcePolicy);\r
     }\r
     \r
     if (opInfo->resourceInfo->alignment == 0) {\r
@@ -563,7 +462,7 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
     policyCheckCfg.resourceOffset = resourcePolicy;\r
     \r
     do {\r
-        matchingNode = RB_FIND(_Rm_ResourceTree, allocator->allocatorRootEntry, &findNode);\r
+        matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);\r
         \r
         if (matchingNode) {\r
             nodePassesPolicy = FALSE;\r
@@ -571,21 +470,21 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
             policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
             policyCheckCfg.resourceBase = findNode.base;\r
             policyCheckCfg.resourceLength = findNode.length;\r
-            nodePassesPolicy = Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);    \r
+            nodePassesPolicy = rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);    \r
             \r
             if (nodePassesPolicy && (matchingNode->allocationCount > 0)) {\r
                 /* Check exclusive privileges of instance requesting resource.  Requesting\r
                  * instance with exclusive privileges can't reserve resource if already owned*/\r
                 policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;\r
                 policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
-                nodePassesPolicy = !Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);\r
+                nodePassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
             }\r
             \r
             if (nodePassesPolicy && (matchingNode->allocationCount == 1)) {\r
                 /* Check exclusive privileges of instance that currently owns resource */\r
                 policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;\r
-                policyCheckCfg.validInstNode = matchingNode->allocatedTo->instNameNode;\r
-                nodePassesPolicy = !Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);\r
+                policyCheckCfg.validInstNode = matchingNode->ownerList->instNameNode;\r
+                nodePassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
             }\r
 \r
             if (retVal != RM_SERVICE_PROCESSING) {\r
@@ -623,8 +522,8 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
     return(retVal); \r
 }\r
 \r
-int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy,\r
-                        Rm_AllocatorOpInfo *opInfo)\r
+int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy,\r
+                       Rm_AllocatorOpInfo *opInfo)\r
 {\r
     Rm_ResourceNode     findNode;\r
     Rm_ResourceNode    *matchingNode = NULL;\r
@@ -642,7 +541,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
     memset((void *)&findNode, 0, sizeof(Rm_ResourceNode));\r
     findNode.base = opInfo->resourceInfo->base;\r
     findNode.length = opInfo->resourceInfo->length;\r
-    matchingNode = RB_FIND(_Rm_ResourceTree, allocator->allocatorRootEntry, &findNode);\r
+    matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);\r
 \r
     /* Prepare privilege checks */\r
     memset((void *)&policyCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));\r
@@ -658,7 +557,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
         matchingEnd = matchingNode->base + matchingNode->length - 1;\r
         \r
         if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {\r
-            if (opInfo->serviceSrcInstNode == Rm_policyGetLinuxInstNode(rmInst->validInstances)) {\r
+            if (opInfo->serviceSrcInstNode == rmPolicyGetLinuxInstNode(rmInst->validInstances)) {\r
                 /* Bypass policy checks since Linux Kernel has full privileges */\r
                 allocPassesPolicy = TRUE;\r
             }\r
@@ -670,7 +569,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                 policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
                 policyCheckCfg.resourceBase = findNode.base;\r
                 policyCheckCfg.resourceLength = findNode.length;\r
-                allocPassesPolicy = Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);\r
+                allocPassesPolicy = rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
                 if (!allocPassesPolicy) {\r
                     retVal = RM_SERVICE_DENIED_INIT_USE_PERMISSION_DENIED;\r
                 }\r
@@ -680,7 +579,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                      * instance with exclusive privileges can't reserve resource if already owned*/\r
                     policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;\r
                     policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
-                    allocPassesPolicy = !Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);\r
+                    allocPassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
                     if (!allocPassesPolicy) {\r
                         retVal = RM_SERVICE_DENIED_REQUESTER_HAS_EXCLUSIVE_PRIV_BUT_RESOURCE_ALLOCATED;\r
                     }\r
@@ -688,8 +587,8 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                 if (allocPassesPolicy && (matchingNode->allocationCount == 1)) {\r
                     /* Check exclusive privileges of instance that currently owns resource */\r
                     policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;\r
-                    policyCheckCfg.validInstNode = matchingNode->allocatedTo->instNameNode;\r
-                    allocPassesPolicy = !Rm_policyCheckPrivilege(&policyCheckCfg, &retVal);\r
+                    policyCheckCfg.validInstNode = matchingNode->ownerList->instNameNode;\r
+                    allocPassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
                     if (!allocPassesPolicy) {\r
                         retVal = RM_SERVICE_DENIED_RESOURCE_ALLOCATED_TO_INSTANCE_WITH_EXCLUSIVE_PRIV;\r
                     }                \r
@@ -703,17 +602,17 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                      *   |<--left node-->||<--matched  node-->||<--right node-->| => existing node\r
                      *                    |<--alloc request-->|  => requested resources\r
                      */                     \r
-                    leftNode = RB_PREV(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    rightNode = RB_NEXT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    Rm_addAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                    leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    rmAddOwner(matchingNode, opInfo->serviceSrcInstNode);\r
 \r
-                    if (leftNode && Rm_compareResourceNodeAllocations(leftNode, matchingNode)) {\r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                    if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         combineLeft = TRUE;\r
                     }\r
-                    if (rightNode && Rm_compareResourceNodeAllocations(rightNode, matchingNode)) {\r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                    if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                         combineRight = TRUE;\r
                     }\r
 \r
@@ -722,36 +621,36 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                         matchingNode->base = leftNode->base;\r
                         matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;\r
 \r
-                        Rm_clearAllocatedTo(leftNode);\r
-                        Rm_freeResourceNode(leftNode);\r
-                        Rm_clearAllocatedTo(rightNode);\r
-                        Rm_freeResourceNode(rightNode);                        \r
+                        rmClearOwners(leftNode);\r
+                        resourceNodeFree(leftNode);\r
+                        rmClearOwners(rightNode);\r
+                        resourceNodeFree(rightNode);                        \r
                     }\r
                     else if (combineLeft) {\r
                         /* Combine left and matching nodes.  Reinsert right. */\r
                         matchingNode->base = leftNode->base;\r
                         matchingNode->length += leftNode->length;\r
 \r
-                        Rm_clearAllocatedTo(leftNode);\r
-                        Rm_freeResourceNode(leftNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
+                        rmClearOwners(leftNode);\r
+                        resourceNodeFree(leftNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
                     }\r
                     else if (combineRight) {\r
                         /* Combine right and matching nodes.  Reinsert left. */\r
                         matchingNode->length += rightNode->length;\r
 \r
-                        Rm_clearAllocatedTo(rightNode);\r
-                        Rm_freeResourceNode(rightNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        rmClearOwners(rightNode);\r
+                        resourceNodeFree(rightNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                     }\r
                     else {\r
                         /* No combine. */\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                     }\r
 \r
                     /* Always reinsert matchingNode */                \r
-                    RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);   \r
+                    RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);   \r
                 }   \r
                 else if ((findNode.base > matchingNode->base) && (findEnd < matchingEnd)) {\r
                     /* findNode range is subset of matchingNode range and neither boundary is\r
@@ -760,20 +659,20 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                      * |<----------matched node---------->|\r
                      *        |<---alloc request--->|\r
                      */ \r
-                    RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    leftNode = Rm_newResourceNode(matchingNode->base, findNode.base - matchingNode->base);\r
-                    Rm_copyAllocatedTo(leftNode, matchingNode);\r
-                    rightNode = Rm_newResourceNode(findNode.base + findNode.length, matchingEnd - findEnd);\r
-                    Rm_copyAllocatedTo(rightNode, matchingNode);\r
+                    RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    leftNode = resourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);\r
+                    rmCopyOwners(leftNode, matchingNode);\r
+                    rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
+                    rmCopyOwners(rightNode, matchingNode);\r
 \r
                     matchingNode->base = findNode.base;                                    \r
                     matchingNode->length = findNode.length;\r
-                    Rm_addAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                    rmAddOwner(matchingNode, opInfo->serviceSrcInstNode);\r
 \r
                     /* Insert all the nodes */\r
-                    RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                    RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
-                    RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                    RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                    RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                 }  \r
                 else {    \r
                     if (findNode.base == matchingNode->base) {\r
@@ -783,26 +682,26 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                          * |<---left node (alloc'd)--->||<----------matched node---------->|\r
                          *                              |<---findNode (alloc req)--->|\r
                          */                         \r
-                        leftNode = RB_PREV(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        /* Add allocating instance to allocatedTo list for compare with leftNode */\r
-                        Rm_addAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                        leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        /* Add allocating instance to owner list for compare with leftNode */\r
+                        rmAddOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                         \r
-                        if (leftNode && Rm_compareResourceNodeAllocations(leftNode, matchingNode)) {\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                             /* Combine leftNode and findNode */\r
                             leftNode->length += findNode.length;\r
                         }\r
                         else {\r
-                            leftNode = Rm_newResourceNode(findNode.base, findNode.length);\r
-                            Rm_copyAllocatedTo(leftNode, matchingNode);\r
+                            leftNode = resourceNodeNew(findNode.base, findNode.length);\r
+                            rmCopyOwners(leftNode, matchingNode);\r
                         }\r
 \r
                         /* Account for leftNode in matchingNode */\r
                         matchingNode->base = findNode.base + findNode.length;\r
                         matchingNode->length = matchingEnd - findEnd;  \r
 \r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                     }\r
                     else if (findEnd == matchingEnd) {\r
                         /* findNode end and matchingNode end are equivalent.  May be combine\r
@@ -811,30 +710,30 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
                          * |<----------matched node---------->||<---right node (alloc'd)--->|\r
                          *       |<---findNode (alloc req)--->| \r
                          */                        \r
-                        rightNode = RB_NEXT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        /* Add allocating instance to allocatedTo list for compare with rightNode */\r
-                        Rm_addAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                        rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        /* Add allocating instance to owner list for compare with rightNode */\r
+                        rmAddOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                         \r
-                        if (rightNode && Rm_compareResourceNodeAllocations(rightNode, matchingNode)) {\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                        if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                             /* Combine rightNode and findNode */\r
                             rightNode->base = findNode.base;\r
                             rightNode->length += findNode.length;\r
                         }\r
                         else {\r
-                            rightNode = Rm_newResourceNode(findNode.base, findNode.length);\r
-                            Rm_copyAllocatedTo(rightNode, matchingNode);\r
+                            rightNode = resourceNodeNew(findNode.base, findNode.length);\r
+                            rmCopyOwners(rightNode, matchingNode);\r
                         }\r
 \r
                         /* Account for rightNode in matchingNode */\r
                         matchingNode->length -= findNode.length;  \r
 \r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                     }\r
                     /* Remove allocating instance from leftover matchingNode */\r
-                    Rm_deleteAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
-                    RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                    rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
+                    RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
                 }\r
                 retVal = RM_SERVICE_APPROVED_AND_COMPLETED;\r
             }\r
@@ -850,7 +749,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
     return(retVal);        \r
 }\r
 \r
-int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy, Rm_AllocatorOpInfo *opInfo)\r
+int32_t rmTreeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePolicy, Rm_AllocatorOpInfo *opInfo)\r
 {\r
     Rm_ResourceNode  findNode;\r
     Rm_ResourceNode *matchingNode = NULL;\r
@@ -865,7 +764,7 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
     memset((void *)&findNode, 0, sizeof(Rm_ResourceNode));\r
     findNode.base = opInfo->resourceInfo->base;\r
     findNode.length = opInfo->resourceInfo->length;\r
-    matchingNode = RB_FIND(_Rm_ResourceTree, allocator->allocatorRootEntry, &findNode);\r
+    matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);\r
 \r
     if (matchingNode) {\r
         findEnd = findNode.base + findNode.length - 1;\r
@@ -873,7 +772,7 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
         \r
         if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {  \r
             if (matchingNode->allocationCount) {\r
-                if (Rm_isAllocatedTo(matchingNode, opInfo->serviceSrcInstNode)) {\r
+                if (rmIsOwnedBy(matchingNode, opInfo->serviceSrcInstNode)) {\r
                     if ((findNode.base == matchingNode->base) && (findEnd == matchingEnd))\r
                     {\r
                         /* Case 1: Free range equals allocated matched node exactly. Attempt to combine \r
@@ -882,17 +781,17 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
                          * |<--left node-->||<---matched node--->||<--right node-->|\r
                          *                  |<---free request--->|\r
                          */ \r
-                        leftNode = RB_PREV(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        rightNode = RB_NEXT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        Rm_deleteAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                        leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
 \r
-                        if (leftNode && Rm_compareResourceNodeAllocations(leftNode, matchingNode)) {\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                             combineLeft = TRUE;\r
                         }\r
-                        if (rightNode && Rm_compareResourceNodeAllocations(rightNode, matchingNode)) {\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                        if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                             combineRight = TRUE;\r
                         }\r
 \r
@@ -901,36 +800,36 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
                             matchingNode->base = leftNode->base;\r
                             matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;\r
 \r
-                            Rm_clearAllocatedTo(leftNode);\r
-                            Rm_freeResourceNode(leftNode);\r
-                            Rm_clearAllocatedTo(rightNode);\r
-                            Rm_freeResourceNode(rightNode);                        \r
+                            rmClearOwners(leftNode);\r
+                            resourceNodeFree(leftNode);\r
+                            rmClearOwners(rightNode);\r
+                            resourceNodeFree(rightNode);                        \r
                         }\r
                         else if (combineLeft) {\r
                             /* Combine left and matching nodes.  Reinsert right. */\r
                             matchingNode->base = leftNode->base;\r
                             matchingNode->length += leftNode->length;\r
 \r
-                            Rm_clearAllocatedTo(leftNode);\r
-                            Rm_freeResourceNode(leftNode);\r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
+                            rmClearOwners(leftNode);\r
+                            resourceNodeFree(leftNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);                        \r
                         }\r
                         else if (combineRight) {\r
                             /* Combine right and matching nodes.  Reinsert left. */\r
                             matchingNode->length += rightNode->length;\r
 \r
-                            Rm_clearAllocatedTo(rightNode);\r
-                            Rm_freeResourceNode(rightNode);\r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                            rmClearOwners(rightNode);\r
+                            resourceNodeFree(rightNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         }\r
                         else {\r
                             /* No combine. */\r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                         }\r
 \r
                         /* Always reinsert matchingNode */\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);                    \r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);                    \r
                     }\r
                     else if ((findNode.base > matchingNode->base) && (findEnd < matchingEnd)) {\r
                         /* Case 2: Free range is less than range in matched node. Split\r
@@ -942,22 +841,22 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
                          * Remove instance from AllocatedTo list then add it back in for side nodes for\r
                          * proper accounting of allocations in validInstance list\r
                          */ \r
-                        RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                        Rm_deleteAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                        RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                         \r
-                        leftNode = Rm_newResourceNode(matchingNode->base, findNode.base - matchingNode->base);\r
-                        Rm_copyAllocatedTo(leftNode, matchingNode);\r
-                        Rm_addAllocatedTo(leftNode, opInfo->serviceSrcInstNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                        leftNode = resourceNodeNew(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 = Rm_newResourceNode(findNode.base + findNode.length, matchingEnd - findEnd);\r
-                        Rm_copyAllocatedTo(rightNode, matchingNode);\r
-                        Rm_addAllocatedTo(rightNode, opInfo->serviceSrcInstNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                        rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);\r
+                        rmCopyOwners(rightNode, matchingNode);\r
+                        rmAddOwner(rightNode, opInfo->serviceSrcInstNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
 \r
                         matchingNode->base = findNode.base;                                    \r
                         matchingNode->length = findNode.length;\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
                     }\r
                     else {                        \r
                         if (findNode.base == matchingNode->base) {\r
@@ -968,25 +867,25 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
                              *                           |<---findNode (free req)--->|\r
                              */ \r
 \r
-                            leftNode = RB_PREV(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                            /* Remove freeing instance from allocatedTo list for compare with leftNode */\r
-                            Rm_deleteAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                            leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                            /* Remove freeing instance from owner list for compare with leftNode */\r
+                            rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                             \r
-                            if (leftNode && Rm_compareResourceNodeAllocations(leftNode, matchingNode)) {\r
-                                RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                            if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
+                                RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                                 /* Combine leftNode and findNode */\r
                                 leftNode->length += findNode.length;\r
                             }\r
                             else {\r
-                                leftNode = Rm_newResourceNode(findNode.base, findNode.length);\r
-                                Rm_copyAllocatedTo(leftNode, matchingNode);\r
+                                leftNode = resourceNodeNew(findNode.base, findNode.length);\r
+                                rmCopyOwners(leftNode, matchingNode);\r
                             }\r
 \r
                             /* Remove leftNode range from matchingNode */\r
                             matchingNode->base = findNode.base + findNode.length;\r
                             matchingNode->length = matchingEnd - findEnd;  \r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, leftNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
                         }\r
                         else if (findEnd == matchingEnd) {\r
                             /* Case 4: Free range is on right boundary of matched node. Try to \r
@@ -996,30 +895,30 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
                              *        |<---findNode (free req)--->|\r
                              */ \r
                             \r
-                            rightNode = RB_NEXT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
-                            RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode); \r
-                            /* Remove freeing instance from allocatedTo list for compare with rightNode */\r
-                            Rm_deleteAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
+                            rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                            RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode); \r
+                            /* Remove freeing instance from owner list for compare with rightNode */\r
+                            rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
                             \r
-                            if (rightNode && Rm_compareResourceNodeAllocations(rightNode, matchingNode)) {\r
-                                RB_REMOVE(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                            if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
+                                RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                                 /* Combine rightNode and findNode */\r
                                 rightNode->base = findNode.base;\r
                                 rightNode->length += findNode.length;\r
                             }\r
                             else {\r
-                                rightNode = Rm_newResourceNode(findNode.base, findNode.length);\r
-                                Rm_copyAllocatedTo(rightNode, matchingNode);\r
+                                rightNode = resourceNodeNew(findNode.base, findNode.length);\r
+                                rmCopyOwners(rightNode, matchingNode);\r
                             }\r
 \r
                             /* Remove rightNode range from matchingNode */\r
                             matchingNode->length -= findNode.length;  \r
-                            RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, rightNode);\r
+                            RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
                         }\r
 \r
                         /* Add freeing instance back into matchingNode allocations */\r
-                        Rm_addAllocatedTo(matchingNode, opInfo->serviceSrcInstNode);\r
-                        RB_INSERT(_Rm_ResourceTree, allocator->allocatorRootEntry, matchingNode);\r
+                        rmAddOwner(matchingNode, opInfo->serviceSrcInstNode);\r
+                        RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
                     }\r
 \r
                     retVal = RM_SERVICE_APPROVED_AND_COMPLETED;\r
@@ -1042,40 +941,34 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
     return(retVal);  \r
 }\r
 \r
-int32_t Rm_allocatorOperation(Rm_Inst *rmInst, Rm_AllocatorOpInfo *opInfo)\r
+int32_t rmAllocatorOperation(Rm_Inst *rmInst, Rm_AllocatorOpInfo *opInfo)\r
 {\r
     Rm_Allocator *allocator = NULL;\r
     int32_t       resourceOffsetInPolicy;\r
     int32_t       retVal;\r
-    void         *key;\r
-\r
-    /* Lock access to the RM instance's transaction queue */\r
-    key = Rm_osalMtCsEnter();\r
     \r
-    resourceOffsetInPolicy = Rm_policyGetResourceOffset(rmInst->policy, opInfo->resourceInfo->name);\r
-    allocator = Rm_allocatorFind(rmInst->allocators, opInfo->resourceInfo->name);\r
+    resourceOffsetInPolicy = rmPolicyGetResourceOffset(rmInst->policy, opInfo->resourceInfo->name);\r
+    allocator = rmAllocatorFind(rmInst->allocators, opInfo->resourceInfo->name);\r
     \r
     if ((resourceOffsetInPolicy > 0) && allocator) {\r
         if (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE) {\r
-            retVal = Rm_treePreAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
+            retVal = rmTreePreAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }               \r
         else if (opInfo->operation == Rm_allocatorOp_ALLOCATE) {\r
-            retVal = Rm_treeAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
+            retVal = rmTreeAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }\r
         else if (opInfo->operation == Rm_allocatorOp_FREE) {\r
-            retVal = Rm_treeFree(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
+            retVal = rmTreeFree(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }         \r
     }\r
     else {\r
         /* Resource could not be found in policy and/or allocator */\r
         retVal = RM_SERVICE_DENIED_RESOURCE_DOES_NOT_EXIST;\r
     }\r
-\r
-    Rm_osalMtCsExit(key);\r
     return(retVal);\r
 }\r
 \r
-void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode,\r
+void rmAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode,\r
                            uint32_t allocType)\r
 {\r
     Rm_AllocatorOpInfo  opInfo;\r
@@ -1086,7 +979,7 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
     \r
     if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
         /* TEMP: For now forward all allocations to the RM Server */\r
-        Rm_transactionForwarder(rmInst, transaction);\r
+        rmTransactionForwarder(rmInst, transaction);\r
              \r
     }\r
     else if (rmInst->instType == Rm_instType_SERVER) {\r
@@ -1103,8 +996,8 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
                 memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
                 nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
                 nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
-                if ((retVal = Rm_nameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {\r
-                    strcpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName);\r
+                if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {\r
+                    strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_RESOURCE_NAME_MAX_CHARS);\r
                     transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
                     transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
                 }                \r
@@ -1114,12 +1007,12 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
         if (retVal == RM_SERVICE_PROCESSING) {      \r
             if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {\r
                 opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE;\r
-                retVal = Rm_allocatorOperation(rmInst, &opInfo);\r
+                retVal = rmAllocatorOperation(rmInst, &opInfo);\r
             }\r
         \r
             if (retVal == RM_SERVICE_PROCESSING) {\r
                 opInfo.operation = Rm_allocatorOp_ALLOCATE;\r
-                retVal = Rm_allocatorOperation(rmInst, &opInfo);\r
+                retVal = rmAllocatorOperation(rmInst, &opInfo);\r
             }      \r
         }\r
         \r
@@ -1128,13 +1021,13 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
         if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
             /* Source of allocation was not the server instance, provide the transaction\r
              * to the transaction responder */\r
-            Rm_transactionResponder(rmInst, transaction);\r
+            rmTransactionResponder(rmInst, transaction);\r
         }\r
         /* Otherwise let the return stack return the transaction to the serviceHandler */                   \r
     }   \r
 }\r
 \r
-void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode)\r
+void rmFreeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode)\r
 {\r
     Rm_AllocatorOpInfo  opInfo; \r
     Rm_NameServerObjCfg nameServerObjCfg;    \r
@@ -1144,7 +1037,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
     \r
     if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
         /* TEMP: Forward all free requests to the Server */\r
-        Rm_transactionForwarder(rmInst, transaction);        \r
+        rmTransactionForwarder(rmInst, transaction);        \r
     }\r
     else if (rmInst->instType == Rm_instType_SERVER) {\r
         opInfo.resourceInfo = &transaction->resourceInfo;\r
@@ -1159,8 +1052,8 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
                 memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
                 nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
                 nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
-                if ((retVal = Rm_nameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {\r
-                    strcpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName);\r
+                if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {\r
+                    strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_RESOURCE_NAME_MAX_CHARS);\r
                     transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
                     transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
                 }                \r
@@ -1170,7 +1063,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
         \r
         if(retVal == RM_SERVICE_PROCESSING) {        \r
             opInfo.operation = Rm_allocatorOp_FREE;\r
-            retVal = Rm_allocatorOperation(rmInst, &opInfo);\r
+            retVal = rmAllocatorOperation(rmInst, &opInfo);\r
         }       \r
 \r
         transaction->state = retVal;\r
@@ -1178,7 +1071,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
         if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
             /* Source of allocation was not the server instance, provide the transaction\r
              * to the transaction responder */\r
-            Rm_transactionResponder(rmInst, transaction);\r
+            rmTransactionResponder(rmInst, transaction);\r
         }\r
         /* Otherwise let the return stack return the transaction to the serviceHandler */        \r
     }   \r
@@ -1186,7 +1079,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
 \r
 /* This function is executed when a RM instance receives a response to one of its requests\r
  * and the information in the request must be provided to the original requesting component */\r
-void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
+void rmServiceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
     Rm_ServiceRespInfo serviceResponse;\r
 \r
@@ -1204,7 +1097,7 @@ void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
          (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
          (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))\r
     {\r
-        strcpy(serviceResponse.resourceName, transaction->resourceInfo.name);\r
+        strncpy(serviceResponse.resourceName, transaction->resourceInfo.name, RM_RESOURCE_NAME_MAX_CHARS);\r
         serviceResponse.resourceBase = transaction->resourceInfo.base;\r
         serviceResponse.resourceLength = transaction->resourceInfo.length;\r
     }\r
@@ -1213,139 +1106,89 @@ void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
     transaction->callback.serviceCallback(&serviceResponse);\r
 \r
     /* Delete the transaction from the transaction queue */\r
-    Rm_transactionQueueDelete(rmInst, transaction->localId);\r
+    rmTransactionQueueDelete(rmInst, transaction->localId);\r
     return;\r
 }\r
 \r
 /* Function used to send RM response transactions to lower level agents */\r
-void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
+void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
-    Rm_TransportNode *dstTransportNode = NULL;\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Transport *dstTransport = NULL;\r
+    Rm_Packet    *rmPkt = NULL;\r
 \r
-    /* Find the transport for the RM instance that sent the request. */\r
-    dstTransportNode = Rm_transportNodeFindRemoteName(rmInst, transaction->pktSrcInstName);\r
+    dstTransport = rmTransportFindRemoteName((Rm_Transport *) rmInst->transports, transaction->pktSrcInstName);\r
 \r
-    /* Create a RM packet using the service information */\r
     switch (transaction->type) {\r
         case Rm_service_RESOURCE_ALLOCATE_INIT:\r
         case Rm_service_RESOURCE_ALLOCATE_USE:\r
         case Rm_service_RESOURCE_FREE:\r
         case Rm_service_RESOURCE_GET_BY_NAME:\r
-            rmPkt = Rm_transportCreateResourceResponsePkt(rmInst, dstTransportNode\r
+            rmPkt = rmTransportCreateResourceResponsePkt(rmInst, dstTransport\r
                                                           transaction);\r
             break;\r
         case Rm_service_RESOURCE_MAP_TO_NAME:\r
         case Rm_service_RESOURCE_UNMAP_NAME:\r
-            rmPkt = Rm_transportCreateNsResponsePkt(rmInst, dstTransportNode,\r
+            rmPkt = rmTransportCreateNsResponsePkt(rmInst, dstTransport,\r
                                                     transaction);\r
             break;\r
-        default:\r
-            /* Invalid service type.  Flag the error and return */\r
-            transaction->state = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
-            break;\r
     }\r
 \r
-    if (transaction->state <= RM_SERVICE_ERROR_BASE) {\r
-        /* Delete the transaction and return immediately because an error occurred \r
-         * allocating the packet */\r
-        Rm_transactionQueueDelete(rmInst, transaction->localId);\r
-        return;\r
-    }\r
-\r
-    /* Send the RM packet to the application transport */\r
-    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransportNode, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
-        /* Negative value returned by transport send.  An error occurred\r
-         * in the transport while attempting to send the packet.*/\r
+    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
-        /* Clean up the packet */\r
-        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransportNode, rmPkt)) {\r
-            /* Non-NULL value returned by transport packet free. Flag the\r
-             * error */\r
+        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) {\r
             transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
         }\r
         return;\r
     }\r
-\r
-    /* NEED TO DO SOMETHING IF GET AN ERROR IN THE transaction->state FIELD.  CREATE\r
-     * NEW TRANSACTION WITH DATA FROM ORIGINAL?  THEN TRY TO SEND FAILED REQUEST BACK\r
-     * TO REQUESTER???  KEEP RETRYING SEND OF RESPONSE??? */\r
-\r
-    /* Delete the transaction */\r
-    Rm_transactionQueueDelete(rmInst, transaction->localId);\r
+    rmTransactionQueueDelete(rmInst, transaction->localId);\r
 }\r
 \r
 /* Function used to forward RM transactions to higher level agents */\r
-void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
+void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
-    Rm_TransportNode *dstTransportNode = NULL;\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Transport *dstTransport = NULL;\r
+    Rm_Packet    *rmPkt = NULL;\r
 \r
-    /* Make sure the RM instance has a transport registered with a higher level agent */\r
     if (rmInst->registeredWithDelegateOrServer == false) {\r
         transaction->state = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER;\r
         return;\r
     }\r
 \r
-    /* Find the transport for the higher level agent.  Check for a connection to a Client Delegate\r
-     * or a Server.  Clients will be connected to either a Client Delegate or a Server.  Client\r
-     * Delegates will be connected to a Server. */\r
     if (rmInst->instType == Rm_instType_CLIENT) {\r
-        dstTransportNode = Rm_transportNodeFindRemoteInstType(rmInst, Rm_instType_CLIENT_DELEGATE);\r
+        dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_CLIENT_DELEGATE);\r
 \r
-        if (!dstTransportNode) {\r
-            /* No Client Delegate connection found.  Check for a Server connection */\r
-            dstTransportNode = Rm_transportNodeFindRemoteInstType(rmInst, Rm_instType_SERVER);\r
+        if (!dstTransport) {\r
+            dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);\r
         }\r
     } \r
     else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
-        dstTransportNode = Rm_transportNodeFindRemoteInstType(rmInst, Rm_instType_SERVER);\r
+        dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);\r
     }\r
 \r
-    /* Create a RM packet using the service information */\r
     switch (transaction->type) {\r
         case Rm_service_RESOURCE_ALLOCATE_INIT:\r
         case Rm_service_RESOURCE_ALLOCATE_USE:\r
         case Rm_service_RESOURCE_FREE:\r
         case Rm_service_RESOURCE_GET_BY_NAME:\r
-            rmPkt = Rm_transportCreateResourceReqPkt(rmInst, dstTransportNode, \r
-                                                     transaction);\r
+            rmPkt = rmTransportCreateResourceReqPkt(rmInst, dstTransport, transaction);\r
             break;\r
         case Rm_service_RESOURCE_MAP_TO_NAME:\r
         case Rm_service_RESOURCE_UNMAP_NAME:\r
-            rmPkt = Rm_transportCreateNsRequestPkt(rmInst, dstTransportNode,\r
-                                                   transaction);\r
+            rmPkt = rmTransportCreateNsRequestPkt(rmInst, dstTransport, transaction);\r
             break;\r
-        default:\r
-            /* Invalid service type.  Flag the error and return */\r
-            transaction->state = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
-            break;\r
-    }\r
-\r
-    if (transaction->state <= RM_SERVICE_ERROR_BASE) {\r
-        /* Return immediately because an error occurred allocating the packet */\r
-        return;\r
     }\r
 \r
-    /* Send the RM packet to the application transport */\r
-    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransportNode, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
-        /* Negative value returned by transport send.  An error occurred\r
-         * in the transport while attempting to send the packet.*/\r
+    if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
-        /* Clean up the packet */\r
-        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransportNode, rmPkt)) {\r
-            /* Non-NULL value returned by transport packet free. Flag the\r
-             * error */\r
+        if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) {\r
             transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
         }\r
         return;\r
     }\r
-\r
-    /* Transaction is not deleted because it is awaiting a response from the higher level\r
-     * RM instance */\r
+    /* Transaction not deleted.  Waiting for response from RM CD or Server */\r
 }\r
 \r
-void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
+void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
     void                *validInstNode;\r
     Rm_NameServerObjCfg  nameServerObjCfg;      \r
@@ -1363,28 +1206,28 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
         if (transaction->state != RM_SERVICE_PROCESSING) {\r
             if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                 /* Transaction did not originate on this instance */\r
-                Rm_transactionResponder(rmInst, transaction);\r
+                rmTransactionResponder(rmInst, transaction);\r
             }\r
             else {\r
                 /* Transaction originated on this instance */\r
-                Rm_serviceResponder(rmInst, transaction);\r
+                rmServiceResponder(rmInst, transaction);\r
             }\r
         }\r
         else {\r
             /* Forward new transaction */\r
-            Rm_transactionForwarder(rmInst, transaction);\r
+            rmTransactionForwarder(rmInst, transaction);\r
         }\r
     }\r
     else {\r
         /* Validate service's originating instance name */\r
         if (rmInst->instType == Rm_instType_SERVER) {\r
-            validInstNode = Rm_policyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);\r
+            validInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);\r
             if (validInstNode == NULL) {\r
                 transaction->state = RM_SERVICE_DENIED_ORIGINATING_INSTANCE_NAME_NOT_VALID;\r
 \r
                 /* Send result via responder if transaction did not originate from this instance */\r
                 if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
-                    Rm_transactionResponder(rmInst, transaction);\r
+                    rmTransactionResponder(rmInst, transaction);\r
                 }\r
             }\r
         }\r
@@ -1397,17 +1240,17 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                     /* Transaction complete */\r
                     if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                         /* Transaction result not destined for this instance */\r
-                        Rm_transactionResponder(rmInst, transaction);\r
+                        rmTransactionResponder(rmInst, transaction);\r
                     }\r
                     else {\r
                         /* Transaction result destined for this instance */\r
-                        Rm_serviceResponder(rmInst, transaction);      \r
+                        rmServiceResponder(rmInst, transaction);      \r
                     }\r
                 }\r
                 else {\r
                     /* Complete allocation/free request */\r
                     if (transaction->type == Rm_service_RESOURCE_FREE) {\r
-                        Rm_freeHandler(rmInst, transaction, validInstNode);\r
+                        rmFreeHandler(rmInst, transaction, validInstNode);\r
                     }\r
                     else {\r
                         switch (transaction->type) {\r
@@ -1418,7 +1261,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                                 RM_policy_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1);    \r
                                 break;\r
                         }\r
-                        Rm_allocationHandler(rmInst, transaction, validInstNode, allocType);\r
+                        rmAllocationHandler(rmInst, transaction, validInstNode, allocType);\r
                     }\r
                 }\r
                 break;\r
@@ -1434,24 +1277,24 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                         nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;\r
                         nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;\r
                         nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;\r
-                        transaction->state = Rm_nameServerAddObject(&nameServerObjCfg);\r
+                        transaction->state = rmNameServerAddObject(&nameServerObjCfg);\r
                     }\r
                     else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
-                        if ((transaction->state = Rm_nameServerFindObject(&nameServerObjCfg)) ==\r
+                        if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==\r
                             RM_SERVICE_PROCESSING) {\r
-                            strcpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName);\r
+                            strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_RESOURCE_NAME_MAX_CHARS);\r
                             transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
                             transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
                             transaction->state = RM_SERVICE_APPROVED_AND_COMPLETED;\r
                         } \r
                     }\r
                     else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
-                        transaction->state = Rm_nameServerDeleteObject(&nameServerObjCfg);\r
+                        transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);\r
                     }\r
 \r
                     /* Send result via responder if transaction did not originate from this instance */\r
                     if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
-                        Rm_transactionResponder(rmInst, transaction);\r
+                        rmTransactionResponder(rmInst, transaction);\r
                     }\r
                 }\r
                 else {\r
@@ -1462,8 +1305,8 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
     }\r
 }\r
 \r
-int32_t Rm_reserveLinuxResource(Rm_Inst *rmInst, Rm_LinuxAlias *linuxAlias, \r
-                                Rm_LinuxValueRange *linuxValues, Rm_AllocatorOpInfo *opInfo)\r
+int32_t rmReserveLinuxResource(Rm_Inst *rmInst, Rm_LinuxAlias *linuxAlias, \r
+                               Rm_LinuxValueRange *linuxValues, Rm_AllocatorOpInfo *opInfo)\r
 {\r
     int32_t  retVal = RM_DTB_UTIL_RESULT_OKAY;\r
     bool     baseFound = FALSE;\r
@@ -1494,13 +1337,13 @@ int32_t Rm_reserveLinuxResource(Rm_Inst *rmInst, Rm_LinuxAlias *linuxAlias,
     }\r
     else {\r
         /* Allocate resource to Linux */\r
-        retVal = Rm_allocatorOperation(rmInst, opInfo);\r
+        retVal = rmAllocatorOperation(rmInst, opInfo);\r
     }\r
     return (retVal);\r
 }\r
 \r
-int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName, void *linuxDtb, \r
-                                       Rm_LinuxAlias *linuxAlias)\r
+int32_t rmFindAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName, void *linuxDtb, \r
+                                      Rm_LinuxAlias *linuxAlias)\r
 {\r
     Rm_AllocatorOpInfo  opInfo;\r
     Rm_ResourceInfo     resourceInfo;\r
@@ -1520,8 +1363,8 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
     memset((void *) &opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
     memset((void *) &resourceInfo, 0, sizeof(Rm_ResourceInfo));\r
 \r
-    strcpy(resourceInfo.name, resourceName);\r
-    opInfo.serviceSrcInstNode = Rm_policyGetLinuxInstNode(rmInst->validInstances);\r
+    strncpy(resourceInfo.name, resourceName, RM_RESOURCE_NAME_MAX_CHARS);\r
+    opInfo.serviceSrcInstNode = rmPolicyGetLinuxInstNode(rmInst->validInstances);\r
     opInfo.operation = Rm_allocatorOp_ALLOCATE;\r
     opInfo.resourceInfo = &resourceInfo;    \r
 \r
@@ -1569,10 +1412,10 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
                     if (strcmp(linuxAlias->path + pathOffset, propertyName) == 0) {\r
                         /* Found resource at end of alias path */\r
                         pathOffset += (strlen(linuxAlias->path + pathOffset) + 1);\r
-                        linuxValueRange = Rm_linuxExtractValues(propertyData, propertyLen);\r
-                        retVal = Rm_reserveLinuxResource(rmInst, linuxAlias, \r
+                        linuxValueRange = rmDtbUtilLinuxExtractValues(propertyData, propertyLen);\r
+                        retVal = rmReserveLinuxResource(rmInst, linuxAlias, \r
                                                          linuxValueRange, &opInfo);\r
-                        Rm_linuxFreeValues(linuxValueRange);\r
+                        rmDtbUtilLinuxFreeValues(linuxValueRange);\r
                     }\r
                     propOffset = fdt_next_property_offset(linuxDtb, propOffset);\r
                 } \r
@@ -1592,75 +1435,63 @@ int32_t Rm_findAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName
     return (retVal);\r
 }\r
 \r
-int32_t Rm_createAndInitAllocator(Rm_Inst *rmInst, const char *resourceName, \r
-                                  Rm_ResourceProperties *resourceProperties, void *linuxDtb)\r
+int32_t rmCreateAndInitAllocator(Rm_Inst *rmInst, const char *resourceName, \r
+                                 Rm_ResourceProperties *resourceProperties, void *linuxDtb)\r
 {\r
-    Rm_ResourceRange *range = NULL;\r
-    Rm_ResourceRange *rangeBasePtr = NULL;\r
-    Rm_NsAssignment *nsAssignments = NULL;\r
-    Rm_NsAssignment *nsAssignmentBasePtr = NULL;\r
-    Rm_LinuxAlias *linuxAlias = NULL;\r
+    Rm_ResourceRange    *range = NULL;\r
+    Rm_ResourceRange    *rangeBasePtr = NULL;\r
+    Rm_NsAssignment     *nsAssignments = NULL;\r
+    Rm_NsAssignment     *nsAssignmentBasePtr = NULL;\r
+    Rm_LinuxAlias       *linuxAlias = NULL;\r
     Rm_NameServerObjCfg  nameServerObjCfg;      \r
-    int32_t retVal = RM_DTB_UTIL_RESULT_OKAY;\r
-\r
-    if (resourceProperties->rangeData && (resourceProperties->rangeLen > 0))\r
-    {\r
-        /* Extract the resource properties from the DTB */\r
-        range = rangeBasePtr = Rm_resourceExtractRange(resourceProperties->rangeData, \r
-                                                       resourceProperties->rangeLen);\r
+    int32_t              retVal = RM_DTB_UTIL_RESULT_OKAY;\r
 \r
-        /* Create a tree allocator using the resource properties */\r
-        retVal = Rm_createTreeAllocator(rmInst, resourceName, range); \r
-\r
-        if (retVal >= RM_DTB_UTIL_RESULT_OKAY)\r
-        {\r
-            if (resourceProperties->linuxAliasData && resourceProperties->linuxAliasLen)\r
-            {\r
-                /* Reserve the resources taken by the Linux kernel specified in the Linux DTB */\r
-                linuxAlias = Rm_resourceExtractLinuxAlias(resourceProperties->linuxAliasData,\r
-                                                          resourceProperties->linuxAliasLen);\r
-\r
-                retVal = Rm_findAndReserveLinuxResource(rmInst, resourceName, linuxDtb, linuxAlias);            \r
+    if (resourceProperties->rangeData && (resourceProperties->rangeLen > 0)) {\r
+        range = rangeBasePtr = rmDtbUtilResExtractRange(resourceProperties->rangeData, \r
+                                                        resourceProperties->rangeLen);\r
+        \r
+        if ((retVal = rmCreateTreeAllocator(rmInst, resourceName, range)) >= RM_DTB_UTIL_RESULT_OKAY) {\r
+            if (resourceProperties->linuxAliasData && resourceProperties->linuxAliasLen) {\r
+                linuxAlias = rmDtbUtilResExtractLinuxAlias(resourceProperties->linuxAliasData,\r
+                                                           resourceProperties->linuxAliasLen, &retVal);\r
+                if (linuxAlias) {\r
+                    retVal = rmFindAndReserveLinuxResource(rmInst, resourceName, linuxDtb, linuxAlias);            \r
+                }\r
             }\r
         }\r
     }\r
     \r
-    if (retVal >= RM_DTB_UTIL_RESULT_OKAY)\r
-    {\r
-        /* Create entries in the NameServer if any NameServer assignments were specified */\r
-        if (resourceProperties->nsAssignData && resourceProperties->nsAssignLen)\r
-        {\r
-            nsAssignments = Rm_resourceExtractNsAssignment(resourceProperties->nsAssignData, \r
-                                                           resourceProperties->nsAssignLen);\r
-\r
-            /* Cycle through the list of assignments and add them to the NameServer */\r
-            nsAssignmentBasePtr = nsAssignments;\r
-            while (nsAssignments)\r
-            {\r
-                memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
-                nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
-                nameServerObjCfg.nodeCfg.objName = nsAssignments->nsName;\r
-                nameServerObjCfg.nodeCfg.resourceName = (char *)resourceName;\r
-                nameServerObjCfg.nodeCfg.resourceBase= nsAssignments->resourceBase;\r
-                nameServerObjCfg.nodeCfg.resourceLength = nsAssignments->resourceLength;                \r
-                \r
-                /* TODO: RETURN IF ANY OF THE ADDS FAIL??? */\r
-                Rm_nameServerAddObject(&nameServerObjCfg);\r
-                nsAssignments = nsAssignments->nextNsAssignment;\r
+    if (retVal >= RM_DTB_UTIL_RESULT_OKAY) {\r
+        if (resourceProperties->nsAssignData && resourceProperties->nsAssignLen) {\r
+            nsAssignments = rmDtbUtilResExtractNsAssignment(resourceProperties->nsAssignData, \r
+                                                            resourceProperties->nsAssignLen, &retVal);\r
+            if (nsAssignments) {\r
+                nsAssignmentBasePtr = nsAssignments;\r
+                while (nsAssignments) {\r
+                    memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
+                    nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
+                    nameServerObjCfg.nodeCfg.objName = nsAssignments->nsName;\r
+                    nameServerObjCfg.nodeCfg.resourceName = (char *)resourceName;\r
+                    nameServerObjCfg.nodeCfg.resourceBase= nsAssignments->resourceBase;\r
+                    nameServerObjCfg.nodeCfg.resourceLength = nsAssignments->resourceLength;                \r
+                    \r
+                    /* TODO: RETURN IF ANY OF THE ADDS FAIL??? */\r
+                    rmNameServerAddObject(&nameServerObjCfg);\r
+                    nsAssignments = nsAssignments->nextNsAssignment;\r
+                }\r
+                rmDtbUtilResFreeNsAssignmentList(nsAssignmentBasePtr);\r
             }\r
-            /* Free the memory allocated for the NameServer assignments */\r
-            Rm_resourceFreeNsAssignmentList(nsAssignmentBasePtr);\r
         }\r
     }\r
 \r
-    /* Free the memory allocated for the resource properties */\r
-    Rm_resourceFreeRange(rangeBasePtr);\r
-    Rm_resourceFreeLinuxAlias(linuxAlias);\r
-\r
+    rmDtbUtilResFreeRange(rangeBasePtr);\r
+    if (linuxAlias) {\r
+        rmDtbUtilResFreeLinuxAlias(linuxAlias);\r
+    }\r
     return(retVal);\r
 }\r
 \r
-int32_t Rm_parseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_ResourceProperties *propertyInfo)\r
+int32_t rmParseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_ResourceProperties *propertyInfo)\r
 {\r
        int32_t propertyLen;\r
        const char *propertyName;\r
@@ -1672,7 +1503,7 @@ int32_t Rm_parseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_Res
        propertyData = fdt_getprop_by_offset(globalResourceDtb, offset, &propertyName, &propertyLen);\r
     if (propertyData)\r
     {\r
-        propertyType = Rm_resourceGetPropertyType(propertyName);\r
+        propertyType = rmDtbUtilResGetPropertyType(propertyName);\r
         if (propertyType == Rm_resourcePropType_RESOURCE_RANGE)\r
         {\r
             if (propertyInfo->rangeData || propertyInfo->rangeLen)\r
@@ -1734,7 +1565,7 @@ int32_t Rm_parseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_Res
         offset = fdt_next_property_offset(globalResourceDtb, offset);\r
        if (offset >= 0)\r
        {\r
-           retVal = Rm_parseResourceProperty(globalResourceDtb, offset, propertyInfo);\r
+           retVal = rmParseResourceProperty(globalResourceDtb, offset, propertyInfo);\r
        }\r
         else if (offset != -FDT_ERR_NOTFOUND)\r
         {\r
@@ -1746,8 +1577,8 @@ int32_t Rm_parseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_Res
     return (retVal);\r
 }\r
 \r
-int32_t Rm_parseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t nodeOffset, int32_t depth,\r
-                             void *linuxDtb)\r
+int32_t rmParseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t nodeOffset, int32_t depth,\r
+                            void *linuxDtb)\r
 {\r
        const char *resourceName = fdt_get_name(globalResourceDtb, nodeOffset, NULL);\r
     Rm_ResourceProperties resourceProperties;\r
@@ -1766,14 +1597,14 @@ int32_t Rm_parseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t n
        {\r
             /* Since at least one property exists attempt to parse the property nodes and \r
              * use them to create and initialize a resource allocator */\r
-               error =  Rm_parseResourceProperty(globalResourceDtb, offset, &resourceProperties);\r
+               error =  rmParseResourceProperty(globalResourceDtb, offset, &resourceProperties);\r
             if (error < -FDT_ERR_NOTFOUND)\r
             {\r
                 return (error);\r
             }\r
             \r
             /* Initialize an allocator with the resource properties if no error was returned */\r
-            Rm_createAndInitAllocator(rmInst, resourceName, &resourceProperties, linuxDtb);\r
+            rmCreateAndInitAllocator(rmInst, resourceName, &resourceProperties, linuxDtb);\r
        }\r
         else if (offset != -FDT_ERR_NOTFOUND)\r
         {\r
@@ -1789,7 +1620,7 @@ int32_t Rm_parseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t n
      * at the start of the recursion will signal the end of the resource list */\r
     if ((offset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) && (depth >= RM_DTB_UTIL_STARTING_DEPTH))\r
     {\r
-        error = Rm_parseResourceNode(rmInst, globalResourceDtb, offset, depth, linuxDtb);\r
+        error = rmParseResourceNode(rmInst, globalResourceDtb, offset, depth, linuxDtb);\r
         if (error < -FDT_ERR_NOTFOUND)\r
         {\r
             return (error);\r
@@ -1804,7 +1635,7 @@ int32_t Rm_parseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t n
     return (RM_DTB_UTIL_RESULT_OKAY);\r
 }\r
 \r
-int32_t Rm_initializeAllocators(Rm_Inst *rmInst, void *globalResourceDtb, void *linuxDtb)\r
+int32_t rmInitializeAllocators(Rm_Inst *rmInst, void *globalResourceDtb, void *linuxDtb)\r
 {\r
     int32_t nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;\r
     int32_t startDepth = RM_DTB_UTIL_STARTING_DEPTH;\r
@@ -1812,7 +1643,7 @@ int32_t Rm_initializeAllocators(Rm_Inst *rmInst, void *globalResourceDtb, void *
 \r
     /* Recursively parse the Global Resource List, creating an allocator for\r
      * each resource as specified in the node */\r
-    result = Rm_parseResourceNode(rmInst, globalResourceDtb, nodeOffset, startDepth, linuxDtb);\r
+    result = rmParseResourceNode(rmInst, globalResourceDtb, nodeOffset, startDepth, linuxDtb);\r
 \r
     return(result);\r
 }\r
@@ -1826,7 +1657,7 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
 {\r
     Rm_Inst         *rmInst = (Rm_Inst *) rmHandle;\r
     Rm_Allocator    *allocator = rmInst->allocators;\r
-    Rm_AllocatedTo  *allocatedTo;\r
+    Rm_Owner        *owners;\r
     Rm_ResourceTree *treeRoot;\r
     Rm_ResourceNode *treeNode;\r
 \r
@@ -1835,7 +1666,7 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
 \r
         treeRoot = allocator->allocatorRootEntry;\r
 \r
-        RB_FOREACH(treeNode, _Rm_ResourceTree, treeRoot) {               \r
+        RB_FOREACH(treeNode, _Rm_AllocatorResourceTree, treeRoot) {               \r
             Rm_osalLog("          %10d - %10d ", treeNode->base, \r
                                                  treeNode->base + treeNode->length -1);\r
             \r
@@ -1843,11 +1674,11 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
                 Rm_osalLog("NOT ALLOCATED\n");\r
             }\r
             else {\r
-                allocatedTo = treeNode->allocatedTo;\r
+                owners = treeNode->ownerList;\r
                 Rm_osalLog("allocated to ");\r
-                while (allocatedTo) {\r
-                    Rm_osalLog(" %s", allocatedTo->instNameNode->name);\r
-                    allocatedTo = allocatedTo->nextAllocatedTo;\r
+                while (owners) {\r
+                    Rm_osalLog(" %s", owners->instNameNode->name);\r
+                    owners = owners->nextOwner;\r
                 }\r
                 Rm_osalLog("\n");\r
             }\r
@@ -1855,7 +1686,7 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
         allocator = allocator->nextAllocator;\r
     }\r
 \r
-    Rm_nameServerPrintObjects(rmInst->nameServer);\r
+    rmNameServerPrintObjects(rmInst->nameServer);\r
 }\r
 \r
 Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *result)\r
@@ -1872,21 +1703,21 @@ Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *resu
                   fdt_totalsize(preMainInitCfg->startupPolicyDtb));\r
     preMainInst->startupDtb = preMainInitCfg->startupPolicyDtb;\r
 \r
-    preMainInst->validInstTree = Rm_policyCreateValidInstTree(preMainInst->startupDtb, result);\r
+    preMainInst->validInstTree = rmPolicyCreateValidInstTree(preMainInst->startupDtb, result);\r
     if (*result == RM_INIT_OK) {\r
         /* Validate policy assignment strings */\r
-        *result = Rm_policyValidatePolicy(preMainInitCfg->startupPolicyDtb, preMainInst->validInstTree);\r
+        *result = rmPolicyValidatePolicy(preMainInitCfg->startupPolicyDtb, preMainInst->validInstTree);\r
     }\r
 \r
     if (*result != RM_INIT_OK) {\r
         if (preMainInst->validInstTree) {\r
-            Rm_policyFreeValidInstTree(preMainInst->validInstTree);\r
+            rmPolicyFreeValidInstTree(preMainInst->validInstTree);\r
         }\r
         Rm_osalFree((void *)preMainInst, sizeof(Rm_PreMainInst));\r
         preMainInst = NULL;\r
     }\r
     else {\r
-        strcpy(preMainInst->instName, preMainInitCfg->instName);\r
+        strncpy(preMainInst->instName, preMainInitCfg->instName, RM_INSTANCE_NAME_MAX_CHARS);\r
         preMainInst->requestCount = 0;\r
         preMainInst->preMainReqList = NULL;\r
     }\r
@@ -1906,7 +1737,7 @@ int32_t Rm_preMainHandleValidateAndDelete(Rm_Handle rmHandle, Rm_PreMainHandle r
         /* TODO: Validate the requests against the global policyDtb */\r
 \r
         /* Free all memory associated with the pre-main instance */\r
-        Rm_policyFreeValidInstTree(preMainInst->validInstTree);\r
+        rmPolicyFreeValidInstTree(preMainInst->validInstTree);\r
         while(serviceReq) {\r
             nextServiceReq = serviceReq->nextPreMainReq;\r
             Rm_osalFree((void *)serviceReq->preMainReq, sizeof(Rm_ServiceReqInfo));\r
@@ -1937,15 +1768,15 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)
     /* Create and initialize instance */\r
     rmInst = Rm_osalMalloc (sizeof(Rm_Inst));\r
     memset ((void *) rmInst, 0, sizeof(Rm_Inst));\r
-    strcpy (rmInst->instName, initCfg->instName);\r
+    strncpy (rmInst->instName, initCfg->instName, RM_INSTANCE_NAME_MAX_CHARS);\r
     rmInst->instType = initCfg->instType;\r
     rmInst->registeredWithDelegateOrServer = false;\r
-    rmInst->routeMap = NULL;\r
+    rmInst->transports = NULL;\r
     rmInst->allocators = NULL;\r
     rmInst->nameServer = NULL;\r
     rmInst->policy = NULL;\r
     rmInst->validInstances = NULL;\r
-    rmInst->transactionSeqNum = Rm_transactionInitSequenceNum();\r
+    rmInst->transactionSeqNum = rmTransactionInitSequenceNum();\r
     rmInst->transactionQueue= NULL;\r
 \r
     if ((rmInst->instType != Rm_instType_CLIENT) && initCfg->policy) {\r
@@ -1954,14 +1785,14 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)
 \r
         /* Create valid instance list from policy.  Must be done prior to parsing\r
          * GRL so that Linux resources can be reserved correctly */\r
-        rmInst->validInstances = Rm_policyCreateValidInstTree(rmInst->policy, result);\r
+        rmInst->validInstances = rmPolicyCreateValidInstTree(rmInst->policy, result);\r
         /* Validate policy assignment strings */\r
-        *result = Rm_policyValidatePolicy(rmInst->policy, rmInst->validInstances);\r
+        *result = rmPolicyValidatePolicy(rmInst->policy, rmInst->validInstances);\r
     }\r
 \r
     /* RM Server specific actions */\r
     if (rmInst->instType == Rm_instType_SERVER) {\r
-        rmInst->nameServer = Rm_nameServerInit();\r
+        rmInst->nameServer = rmNameServerInit();\r
 \r
         if (initCfg->globalResourceList) {\r
             globalResourceDtb = initCfg->globalResourceList;\r
@@ -1971,12 +1802,12 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)
                 linuxResourceDtb = initCfg->linuxDtb;\r
                 fdt_open_into(linuxResourceDtb, linuxResourceDtb, fdt_totalsize(linuxResourceDtb));   \r
             }\r
-            Rm_initializeAllocators(rmInst, globalResourceDtb, linuxResourceDtb);\r
+            rmInitializeAllocators(rmInst, globalResourceDtb, linuxResourceDtb);\r
         }\r
     }\r
 \r
     if ((rmInst->instType != Rm_instType_CLIENT) && initCfg->policy) {\r
-        *result = Rm_policyValidatePolicyResourceNames(rmInst->policy, (void *)rmInst->allocators);\r
+        *result = rmPolicyValidatePolicyResourceNames(rmInst->policy, (void *)rmInst->allocators);\r
     }    \r
 \r
     return ((Rm_Handle) rmInst);\r
index 73097ba792f7d66c07405cb4c1dab13aa7a6738f..37f658fa9de9f3a09d3ae7d7f8874596ef2c5144 100644 (file)
 /* RM Types */
 #include <ti/drv/rm/rm_types.h>
 
+/* RM external API includes */
+#include <ti/drv/rm/rm.h>
+#include <ti/drv/rm/rm_services.h>
+
 /* RM internal API includes */
 #include <ti/drv/rm/include/rm_dtb_utilloc.h>
 
  **********************************************************************/
 
 char rmDtbStartingNode[] = "\0";
-char *Rm_commonExtractName(const void *dtbDataPtr, int32_t dtbDataLen)
-{
-    char *resourceName = NULL;
-    
-    resourceName = (char *) Rm_osalMalloc(dtbDataLen);
-
-    /* The resource name is stored as a null terminated string in the DTB
-     * so it's just a straightforward string copy operation to a local
-     * buffer to extract it. */
-    strcpy(resourceName, (char *)dtbDataPtr);
-
-    return(resourceName);
-}
-
-/* Free memory that was allocated to extract a name property string */
-void Rm_commonFreeName(char *resourceName)
-{
-    int32_t nameSize;
-    
-    /* Free the character array memory */
-    nameSize = strlen(resourceName);
-    /* Add one for the NULL character */
-    Rm_osalFree((void *)resourceName, nameSize+1);
-}
 
 /* Construct and return a list of ranges as specified in either the Resource
  * DTB or a Policy DTB */
-Rm_ResourceRange *Rm_commonExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    uint32_t *dtbRangeData = (uint32_t *)dtbDataPtr;
+    uint32_t         *dtbRangeData = (uint32_t *)dtbDataPtr;
     Rm_ResourceRange *startRange = NULL;
     Rm_ResourceRange *newRange = NULL;
     Rm_ResourceRange *prevRange = NULL;
@@ -99,48 +78,33 @@ Rm_ResourceRange *Rm_commonExtractRange(const void *dtbDataPtr, int32_t dtbDataL
      * base, lenth format. The DTB gives properties lengths in bytes so the length
      * returned from the DTB should be a multiple of the number of bytes in two
      * uint32_ts. */
-    if (dtbDataLen % (2 * sizeof(uint32_t)))
-    {
-        /* Return NULL if there are an odd number of range values */
+    if (dtbDataLen % (2 * sizeof(uint32_t))) {
         return (NULL);
     }
 
-    /* Extract the range data from the DTB */
-    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i+=2)
-    {
-        /* Creat a new range entry */
+    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i+=2) {
         newRange = (Rm_ResourceRange *) Rm_osalMalloc(sizeof(Rm_ResourceRange));
-        /* Populate the new range entry.  The endianness of the value extracted must
-         * be flipped */
         newRange->base = fdt32_to_cpu(dtbRangeData[i]);
         newRange->length = fdt32_to_cpu(dtbRangeData[i+1]);
         newRange->nextRange = NULL;
         
-        /* Range linked list pointer accounting */
-        if (prevRange == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevRange == NULL) {
             startRange = newRange;
         }
-        else
-        {
-            prevRange->nextRange = (void *) newRange;
+        else {
+            prevRange->nextRange = newRange;
         }
-
         prevRange = newRange;
     }
-
-    /* Return a pointer to the start of the range list */
     return (startRange);
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted ranges */
-void Rm_commonFreeRangeList(Rm_ResourceRange *rangeList)
+void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList)
 {
     Rm_ResourceRange *nextRange;
     
-    while (rangeList != NULL)
-    {
+    while (rangeList) {
         nextRange = rangeList->nextRange;
         Rm_osalFree((void *)rangeList, sizeof(Rm_ResourceRange));
         rangeList = nextRange;
@@ -148,132 +112,98 @@ void Rm_commonFreeRangeList(Rm_ResourceRange *rangeList)
 }
 
 /* Construct and return a list of values as specified in the Policy DTB */
-Rm_ResourceValue *Rm_commonExtractValueList(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    uint32_t *dtbRangeData = (uint32_t *)dtbDataPtr;
+    uint32_t         *dtbRangeData = (uint32_t *)dtbDataPtr;
     Rm_ResourceValue *startValue = NULL;
     Rm_ResourceValue *newValue = NULL;
     Rm_ResourceValue *prevValue = NULL;
-    uint32_t i;
+    uint32_t          i;
     
     /* Values are stored in the DTB as a list of 32-bit words. The DTB 
      * gives properties lengths in bytes so the length returned from the DTB 
      * should be a multiple of the number of bytes a uint32_t. */
-    if (dtbDataLen % sizeof(uint32_t))
-    {
+    if (dtbDataLen % sizeof(uint32_t)) {
         return (NULL);
     }
-
-    /* Extract the value data from the DTB */
-    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i++)
-    {
-        /* Creat a new allocation size entry */
+    
+    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i++) {
         newValue = (Rm_ResourceValue *) Rm_osalMalloc(sizeof(Rm_ResourceValue));
-        /* Populate the new allocation size entry.  The endianness of the value extracted must
-         * be flipped */
         newValue->value = fdt32_to_cpu(dtbRangeData[i]);
         newValue->nextValue = NULL;
         
-        /* Resource value linked list pointer accounting */
-        if (prevValue == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevValue == NULL) {
             startValue = newValue;
         }
-        else
-        {
-            prevValue->nextValue = (void *) newValue;
+        else {
+            prevValue->nextValue = newValue;
         }
-
         prevValue = newValue;
     }
-
-    /* Return a pointer to the start of the resource value list */
     return (startValue);
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted values */
-void Rm_commonFreeValueList (Rm_ResourceValue *valueList)
+void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
 {
     Rm_ResourceValue *nextValue;
     
-    while (valueList != NULL)
-    {
+    while (valueList) {
         nextValue = valueList->nextValue;
         Rm_osalFree((void *)valueList, sizeof(Rm_ResourceValue));
         valueList = nextValue;
     }
 }
 
-
 /**********************************************************************
- ***********Resource List DTB Parsing Defines and Functions************
+ *******Global Resource List DTB Parsing Defines and Functions*********
  **********************************************************************/
 
 /* Resource List Properties - These are the property values used
  * by an application integrator to define the properties of resources
- * listed in the Device Resource List */
-char rmResourceDeviceNameProp[] = "device-name";
-char rmResourceRangeProp[] = "resource-range";
-char rmResourceLinuxAliasProp[] = "linux-dtb-alias";
-char rmResourceNsAssignmentProp[] = "ns-assignment";
+ * listed in the Device Global Resource List */
+char dtbUtilResRangeProp[]        = "resource-range";
+char dtbUtilResLinuxAliasProp[]   = "linux-dtb-alias";
+char dtbUtilResNsAssignmentProp[] = "ns-assignment";
 
-Rm_ResourcePropType Rm_resourceGetPropertyType(const char * propertyName)
+Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName)
 {
     Rm_ResourcePropType propertyType = Rm_resourcePropType_UNKNOWN;
 
-    if(strcmp(rmResourceDeviceNameProp, propertyName) == 0)
-    {
-        propertyType = Rm_resourcePropType_DEVICE_NAME;
-    }    
-    else if(strcmp(rmResourceRangeProp, propertyName) == 0)
-    {
+    if(strcmp(dtbUtilResRangeProp, propertyName) == 0) {
         propertyType = Rm_resourcePropType_RESOURCE_RANGE;
     }
-    else if(strcmp(rmResourceLinuxAliasProp, propertyName) == 0)
-    {
+    else if(strcmp(dtbUtilResLinuxAliasProp, propertyName) == 0) {
         propertyType = Rm_resourcePropType_RESOURCE_LINUX_ALIAS;
     }    
-    else if(strcmp(rmResourceNsAssignmentProp, propertyName) == 0)
-    {
+    else if(strcmp(dtbUtilResNsAssignmentProp, propertyName) == 0) {
         propertyType = Rm_resourcePropType_NSASSIGNMENT;
     }
-
     return (propertyType);
 }
 
-char *Rm_resourceExtractDeviceName(const void *dtbDataPtr, int32_t dtbDataLen)
-{
-    return(Rm_commonExtractName(dtbDataPtr, dtbDataLen));
-}
-
-void Rm_resourceFreeDeviceName(char *deviceName)
-{
-    Rm_commonFreeName(deviceName);
-}
-
-Rm_ResourceRange *Rm_resourceExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    return(Rm_commonExtractRange(dtbDataPtr, dtbDataLen));
+    return(dtbUtilCommonExtractRange(dtbDataPtr, dtbDataLen));
 }
 
-void Rm_resourceFreeRange(Rm_ResourceRange *rangeList)
+void rmDtbUtilResFreeRange(Rm_ResourceRange *rangeList)
 {
-    Rm_commonFreeRangeList(rangeList);
+    dtbUtilCommonFreeRangeList(rangeList);
 }
 
-Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen, int32_t *result)
 {
-    uint8_t *dtbAliasData = (uint8_t *)dtbDataPtr;
-    uint32_t pathLenBytes;
-    uint32_t extractedValue;
-    uint8_t *extractedValueBytePtr;        
+    uint8_t       *dtbAliasData = (uint8_t *)dtbDataPtr;
+    uint32_t       pathLenBytes;
+    uint32_t       extractedValue;
+    uint8_t       *extractedValueBytePtr;        
     Rm_LinuxAlias *startAlias = NULL;
     Rm_LinuxAlias *newAlias = NULL;
     Rm_LinuxAlias *prevAlias = NULL;
-    uint32_t numOffsets;
-    int32_t i = 0;
-    uint16_t j;
+    uint32_t       numOffsets;
+    int32_t        i = 0;
+    uint16_t       j;
     
     /* Linux aliases are stored in the DTB as a list space-separated path node names within
      * null terminated string.  Following the path string 
@@ -284,181 +214,150 @@ Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbD
      * Linux DTB contains a single value for reservation.  There is no padding between
      * the path string and the 32-bit offsets.  Therefore the 32-bit offsets may not be on
      * a 4-byte boundary and must be constructed upon extraction */
-
-    /* Extract the alias data from the DTB */
-    while(i < dtbDataLen)
-    {
-        /* Creat a new alias entry */
+    while(i < dtbDataLen) {
         newAlias = (Rm_LinuxAlias *) Rm_osalMalloc(sizeof(Rm_LinuxAlias));
         
-        /* Populate the new alias entry.  Allocate a buffer for the path
-         * string (adding one for the null character). */
         pathLenBytes = strlen((char *) &dtbAliasData[i]) + 1;
         newAlias->path = (char *) Rm_osalMalloc(pathLenBytes);
-        strcpy(newAlias->path, ((char *) &dtbAliasData[i]));
+        strncpy(newAlias->path, ((char *) &dtbAliasData[i]), pathLenBytes);
         
-        /* Extract the 32-bit value specifying the number of offsets that follow */
+        /* Extract 32-bit value specifying number of offsets that follow */
         i += pathLenBytes;
         extractedValueBytePtr = (uint8_t *)&extractedValue;
-        for (j = 0; j < sizeof(uint32_t); j++, i++)
-        {
+        for (j = 0; j < sizeof(uint32_t); j++, i++) {
             extractedValueBytePtr[j] = dtbAliasData[i];
         }
-        /* flip the endianness */
         numOffsets = fdt32_to_cpu(extractedValue);
 
-        /* numOffsets should always be either 1 or 2 */
-        if ((numOffsets == 1) || (numOffsets == 2))
-        {
+        if ((numOffsets == 1) || (numOffsets == 2)) {
             /* Always extract the base value */
             extractedValueBytePtr = (uint8_t *)&extractedValue;
-            for (j = 0; j < sizeof(uint32_t); j++, i++)
-            {
+            for (j = 0; j < sizeof(uint32_t); j++, i++) {
                 extractedValueBytePtr[j] = dtbAliasData[i];
             }            
             newAlias->baseOffset = fdt32_to_cpu(extractedValue);
 
-            if (numOffsets == 2)
-            {
-                /* Extract the 32-bit length value if two offsets were specified */
-                for (j = 0; j < sizeof(uint32_t); j++, i++)
-                {
+            if (numOffsets == 2) {
+                for (j = 0; j < sizeof(uint32_t); j++, i++) {
                     extractedValueBytePtr[j] = dtbAliasData[i];
                 }
-                /* flip the endianness */
                 newAlias->lengthOffset = fdt32_to_cpu(extractedValue);
             }
-            else
-            {
+            else {
                 newAlias->lengthOffset = RM_DTB_LINUX_ALIAS_OFFSET_NOT_SET;
             }            
             
             newAlias->nextLinuxAlias = NULL;
-            
-            if (prevAlias == NULL)
-            {
-                /* Save the first entry so it can be returned */
+            if (prevAlias == NULL) {
                 startAlias = newAlias;
             }
-            else
-            {
-                prevAlias->nextLinuxAlias = (void *) newAlias;
+            else {
+                prevAlias->nextLinuxAlias = newAlias;
             }
             prevAlias = newAlias;
         }
-        else
-        {
-            /* Return NULL */
-            startAlias = NULL;
-            break;
+        else {
+            Rm_osalFree((void *)newAlias->path, pathLenBytes);
+            Rm_osalFree((void *)newAlias, sizeof(Rm_LinuxAlias));
+            while (startAlias) {
+                newAlias = startAlias->nextLinuxAlias;
+                pathLenBytes = strlen(startAlias->path);        
+                Rm_osalFree((void *)startAlias->path, pathLenBytes + 1);
+                Rm_osalFree((void *)startAlias, sizeof(Rm_LinuxAlias));
+                startAlias = newAlias;
+            }   
+            *result = RM_INIT_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT;
+            return(NULL);
         }
     }
-
-    /* Return a pointer to the start of the NameServer assignment list */
     return (startAlias);
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted Linux
  * aliases. */
-void Rm_resourceFreeLinuxAlias(Rm_LinuxAlias *aliasList)
+void rmDtbUtilResFreeLinuxAlias(Rm_LinuxAlias *aliasList)
 {
     Rm_LinuxAlias *nextAlias;
-    int32_t pathSize;
+    int32_t        pathSize;
        
-    while (aliasList != NULL)
-    {
+    while (aliasList) {
         nextAlias = aliasList->nextLinuxAlias;
-        /* Free the path string memory first */
         pathSize = strlen(aliasList->path);        
         Rm_osalFree((void *)aliasList->path, pathSize + 1);
-        /* Free the list element */
         Rm_osalFree((void *)aliasList, sizeof(Rm_LinuxAlias));
         aliasList = nextAlias;
     }
 }
 
 /* Construct and return a list of NameServer assignments as specified in the Resource DTB */
-Rm_NsAssignment *Rm_resourceExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen, int32_t *result)
 {
-    uint8_t *dtbNsAssignmentData = (uint8_t *)dtbDataPtr;
-    uint32_t nameLenBytes;
-    uint32_t extractedValue;
-    uint8_t *extractedValueBytePtr;        
+    uint8_t         *dtbNsAssignmentData = (uint8_t *)dtbDataPtr;
+    uint32_t         nameLenBytes;
+    uint32_t         extractedValue;
+    uint8_t         *extractedValueBytePtr;        
     Rm_NsAssignment *startAssignment = NULL;
     Rm_NsAssignment *newAssignment = NULL;
     Rm_NsAssignment *prevAssignment = NULL;
-    int32_t i = 0;
-    uint16_t j;
+    int32_t          i = 0;
+    uint16_t         j;
     
     /* NameServer assignments are stored in the DTB as a null-terminated character
      * string followed by a 32-bit word containing the value to be assigned to the
      * name in the string.  There is no padding between the string and the 32-bit 
      * word.  Therefore the 32-bit word may not be on a 4-byte boundary and must
      * be constructed upon extraction */
-
-    /* Extract the NameServer assignment data from the DTB */
-    while(i < dtbDataLen)
-    {
-        /* Creat a new NameServer assignment entry */
+    while(i < dtbDataLen) {
         newAssignment = (Rm_NsAssignment *) Rm_osalMalloc(sizeof(Rm_NsAssignment));
         
-        /* Populate the new assignment entry.  Allocate a buffer for the assignment
-         * name string (adding one for the null character). */
         nameLenBytes = strlen((char *) &dtbNsAssignmentData[i]) + 1;
-        newAssignment->nsName = (char *) Rm_osalMalloc(nameLenBytes);
-        strcpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]));
+        if (nameLenBytes > RM_RESOURCE_NAME_MAX_CHARS) {
+            Rm_osalFree((void *)newAssignment, sizeof(Rm_NsAssignment));
+            while (startAssignment) {
+                newAssignment = startAssignment->nextNsAssignment;
+                Rm_osalFree((void *)startAssignment, sizeof(Rm_NsAssignment));
+                startAssignment = newAssignment;
+            }
+            *result = RM_INIT_ERROR_NS_ASSIGNMENT_NAME_TOO_LONG;
+            return(NULL);
+        }        
+        strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]), RM_RESOURCE_NAME_MAX_CHARS);
         
-        /* Extract the 32-bit base value */
+        /* Extract 32-bit base value and flip endian */
         i += nameLenBytes;
         extractedValueBytePtr = (uint8_t *)&extractedValue;
-        for (j = 0; j < sizeof(uint32_t); j++, i++)
-        {
+        for (j = 0; j < sizeof(uint32_t); j++, i++) {
             extractedValueBytePtr[j] = dtbNsAssignmentData[i];
         }
-        /* flip the endianness */
         newAssignment->resourceBase = fdt32_to_cpu(extractedValue);
 
-        /* Extract the 32-bit length value */
-        for (j = 0; j < sizeof(uint32_t); j++, i++)
-        {
+        /* Extract 32-bit length value and flip endian */
+        for (j = 0; j < sizeof(uint32_t); j++, i++) {
             extractedValueBytePtr[j] = dtbNsAssignmentData[i];
         }
-        /* flip the endianness */
         newAssignment->resourceLength = fdt32_to_cpu(extractedValue);
-
+        
         newAssignment->nextNsAssignment = NULL;
-
-        if (prevAssignment == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevAssignment == NULL) {
             startAssignment = newAssignment;
         }
-        else
-        {
-            prevAssignment->nextNsAssignment = (void *) newAssignment;
+        else {
+            prevAssignment->nextNsAssignment = newAssignment;
         }
         prevAssignment = newAssignment;
     }
-
-    /* Return a pointer to the start of the NameServer assignment list */
+    
     return (startAssignment);
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted NameServer
  * assignments. */
-void Rm_resourceFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
+void rmDtbUtilResFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
 {
     Rm_NsAssignment *nextAssignment;
-    int32_t nameSize;
     
-    while (nsAssignmentList != NULL)
-    {
+    while (nsAssignmentList) {
         nextAssignment = nsAssignmentList->nextNsAssignment;
-        /* Free the character array memory first */
-        nameSize = strlen(nsAssignmentList->nsName);
-        /* Add one for the NULL character */
-        Rm_osalFree((void *)nsAssignmentList->nsName, nameSize+1);
-        /* Free the list element */
         Rm_osalFree((void *)nsAssignmentList, sizeof(Rm_NsAssignment));
         nsAssignmentList = nextAssignment;
     }
@@ -471,200 +370,167 @@ void Rm_resourceFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
 /* 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 rmPolicyValidInstances[] = "valid-instances";
-char rmPolicyAssignments[] = "assignments";
-char rmPolicyAllocationSizes[] = "allocation-size";
-char rmPolicyAllocationAlignments[] = "allocation-alignment";
+char dtbUtilPolicyValidInstances[]      = "valid-instances";
+char dtbUtilPolicyAssignments[]         = "assignments";
+char dtbUtilPolicyAllocationSize[]      = "allocation-size";
+char dtbUtilPolicyAllocationAlignment[] = "allocation-alignment";
 
-Rm_PolicyPropType Rm_policyGetPropertyType(const char * propertyName)
+Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char * propertyName)
 {
     Rm_PolicyPropType propertyType = Rm_policyPropType_UNKNOWN;
 
-    if(strcmp(rmPolicyAssignments, propertyName) == 0)
-    {
+    if(strcmp(dtbUtilPolicyAssignments, propertyName) == 0) {
         propertyType = Rm_policyPropType_ASSIGNMENTS;
     }
-    else if(strcmp(rmPolicyAllocationSizes, propertyName) == 0)
-    {
-        propertyType = Rm_policyPropType_ALLOCATION_SIZES;
+    else if(strcmp(dtbUtilPolicyAllocationSize, propertyName) == 0) {
+        propertyType = Rm_policyPropType_ALLOCATION_SIZE;
     }
-    else if(strcmp(rmPolicyAllocationAlignments, propertyName) == 0)
-    {
-        propertyType = Rm_policyPropType_ALLOCATION_ALIGNMENTS;
+    else if(strcmp(dtbUtilPolicyAllocationAlignment, propertyName) == 0) {
+        propertyType = Rm_policyPropType_ALLOCATION_ALIGNMENT;
     }    
-    else if(strcmp(rmPolicyValidInstances, propertyName) == 0)
-    {
+    else if(strcmp(dtbUtilPolicyValidInstances, propertyName) == 0) {
         propertyType = Rm_policyPropType_VALID_INSTANCES;
     }       
-
     return (propertyType);
 }
 
-Rm_PolicyAssignment *Rm_policyExtractAssignments(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    uint8_t *dtbAssignmentData = (uint8_t *)dtbDataPtr;
-    uint32_t permissionsLenBytes;
-    uint32_t extractedValue;
-    uint8_t *extractedValueBytePtr;        
+    uint8_t             *dtbAssignmentData = (uint8_t *)dtbDataPtr;
+    uint32_t             permissionsLenBytes;
+    uint32_t             extractedValue;
+    uint8_t             *extractedValueBytePtr;        
     Rm_PolicyAssignment *startAssignment = NULL;
     Rm_PolicyAssignment *newAssignment = NULL;
     Rm_PolicyAssignment *prevAssignment = NULL;
-    int32_t i = 0;
-    uint16_t j;
+    int32_t              i = 0;
+    uint16_t             j;
     
     /* Policy assignments are stored in the DTB as two 32-bit words containing a 
      * resource base and length to be assigned the permissions in the defined in
      * the string that follows.  There is no padding between the 32-bit words and the 
      * string.  Therefore the 32-bit word may not be on a 4-byte boundary and must
      * be constructed upon extraction */
-
-    /* Extract the policy assignment data from the DTB */
-    while(i < dtbDataLen)
-    {
-        /* Creat a new NameServer assignment entry */
+    while(i < dtbDataLen) {
         newAssignment = (Rm_PolicyAssignment *) Rm_osalMalloc(sizeof(Rm_PolicyAssignment));
 
-        /* Extract the 32-bit resource base value */
+        /* Extract 32-bit resource base value and flip endianness */
         extractedValueBytePtr = (uint8_t *)&extractedValue;
-        for (j = 0; j < sizeof(uint32_t); j++, i++)
-        {
+        for (j = 0; j < sizeof(uint32_t); j++, i++) {
             extractedValueBytePtr[j] = dtbAssignmentData[i];
         }
-        /* flip the endianness */
         newAssignment->resourceBase = fdt32_to_cpu(extractedValue);
 
-        /* Extract the 32-bit resource length value */
-        for (j = 0; j < sizeof(uint32_t); j++, i++)
-        {
+        /* Extract 32-bit resource length value and flip endianness */
+        for (j = 0; j < sizeof(uint32_t); j++, i++) {
             extractedValueBytePtr[j] = dtbAssignmentData[i];
         }
-        /* flip the endianness */
         newAssignment->resourceLength = fdt32_to_cpu(extractedValue);
 
-        /* Allocate a buffer for the assignment permissions string (adding one for 
-         * the null character). */
         permissionsLenBytes = strlen((char *) &dtbAssignmentData[i]) + 1;
         newAssignment->permissionsList = (char *) Rm_osalMalloc(permissionsLenBytes);
-        strcpy(newAssignment->permissionsList, ((char *) &dtbAssignmentData[i]));
+        strncpy(newAssignment->permissionsList, ((char *) &dtbAssignmentData[i]), permissionsLenBytes);
         i += permissionsLenBytes;
 
         newAssignment->nextAssignment = NULL;
-
-        if (prevAssignment == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevAssignment == NULL) {
             startAssignment = newAssignment;
         }
-        else
-        {
+        else {
             prevAssignment->nextAssignment = newAssignment;
         }
         prevAssignment = newAssignment;
     }
-
-    /* Return a pointer to the start of the policy assignment list */
     return (startAssignment);
 }
 
-void Rm_policyFreeAssignments(Rm_PolicyAssignment *assignmentList)
+void rmDtbUtilPolicyFreeAssignments(Rm_PolicyAssignment *assignmentList)
 {
     Rm_PolicyAssignment *nextAssignment;
-    int32_t permissionsSize;
+    int32_t              permissionsSize;
     
-    while (assignmentList != NULL)
-    {
+    while (assignmentList) {
         nextAssignment = assignmentList->nextAssignment;
-        /* Free the character array memory first */
         permissionsSize = strlen(assignmentList->permissionsList);
-        /* Add one for the NULL character */
         Rm_osalFree((void *)assignmentList->permissionsList, permissionsSize+1);
-        /* Free the list element */
         Rm_osalFree((void *)assignmentList, sizeof(Rm_PolicyAssignment));
         assignmentList = nextAssignment;
     }
 }
 
 /* Construct and return a list of allocation sizes as specified in the Policy DTB */
-Rm_ResourceValue *Rm_policyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceValue *rmDtbUtilPolicyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    return(Rm_commonExtractValueList(dtbDataPtr, dtbDataLen));
+    return(dtbUtilCommonExtractValueList(dtbDataPtr, dtbDataLen));
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted allocation sizes */
-void Rm_policyFreeAllocationSizes (Rm_ResourceValue *allocationSizeList)
+void rmDtbUtilPolicyFreeAllocationSizes (Rm_ResourceValue *allocationSizeList)
 {
-    Rm_commonFreeValueList(allocationSizeList);
+    dtbUtilCommonFreeValueList(allocationSizeList);
 }
 
 /* Construct and return a list of allocation alignments as specified in the Policy DTB */
-Rm_ResourceValue *Rm_policyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    return(Rm_commonExtractValueList(dtbDataPtr, dtbDataLen));
+    return(dtbUtilCommonExtractValueList(dtbDataPtr, dtbDataLen));
 }
 
 /* Function to clean up the memory allocated for a linked list of extracted allocation alignments */
-void Rm_policyFreeResourceAlignments (Rm_ResourceValue *alignmentList)
+void rmDtbUtilPolicyFreeResourceAlignments (Rm_ResourceValue *alignmentList)
 {
-    Rm_commonFreeValueList(alignmentList);
+    dtbUtilCommonFreeValueList(alignmentList);
 }
 
-Rm_PolicyValidInst *Rm_policyExtractValidInstances(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr, int32_t dtbDataLen,
+                                                         int32_t *result)
 {
-    uint8_t *dtbValidInstData = (uint8_t *)dtbDataPtr;
-    uint32_t instLenBytes;       
+    uint8_t            *dtbValidInstData = (uint8_t *)dtbDataPtr;
+    uint32_t            instLenBytes;       
     Rm_PolicyValidInst *startInst = NULL;
     Rm_PolicyValidInst *newInst = NULL;
     Rm_PolicyValidInst *prevInst = NULL;
-    int32_t i = 0;
+    int32_t             i = 0;
     
     /* Valid RM instances are stored in the DTB as a list of null-terminated character
      * strings. */
-
-    /* Extract the valid instance data from the DTB */
-    while(i < dtbDataLen)
-    {
-        /* Creat a new valid instance entry */
+    while(i < dtbDataLen) {
         newInst = (Rm_PolicyValidInst *) Rm_osalMalloc(sizeof(Rm_PolicyValidInst));
-        
-        /* Populate the new instance entry.  Allocate a buffer for the instance
-         * name string (adding one for the null character). */
+
         instLenBytes = strlen((char *) &dtbValidInstData[i]) + 1;
-        newInst->instName = (char *) Rm_osalMalloc(instLenBytes);
-        strcpy(newInst->instName, ((char *) &dtbValidInstData[i]));
+        if (instLenBytes > RM_INSTANCE_NAME_MAX_CHARS) {
+            Rm_osalFree((void *)newInst, sizeof(Rm_PolicyValidInst));
+            while (startInst) {
+                newInst = startInst->nextValidInst;
+                Rm_osalFree((void *)startInst, sizeof(Rm_PolicyValidInst));
+                startInst = newInst;
+            }
+            *result = RM_INIT_ERROR_POLICY_VALID_INSTANCE_NAME_TOO_LONG;
+            return(NULL);
+        }
+        strncpy(newInst->instName, ((char *) &dtbValidInstData[i]), instLenBytes);
         
         i += instLenBytes;
 
         newInst->nextValidInst = NULL;
 
-        if (prevInst == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevInst == NULL) {
             startInst = newInst;
         }
-        else
-        {
+        else {
             prevInst->nextValidInst = newInst;
         }
         prevInst = newInst;
     }
-
-    /* Return a pointer to the start of the valid instance list */
     return (startInst);
 }
 
-void Rm_policyFreeValidInstances (Rm_PolicyValidInst *validInstList)
+void rmDtbUtilPolicyFreeValidInstances (Rm_PolicyValidInst *validInstList)
 {
     Rm_PolicyValidInst *nextInst;
-    int32_t instSize;
     
-    while (validInstList != NULL)
-    {
+    while (validInstList) {
         nextInst = validInstList->nextValidInst;
-        /* Free the character array memory first */
-        instSize = strlen(validInstList->instName);
-        /* Add one for the NULL character */
-        Rm_osalFree((void *)validInstList->instName, instSize+1);
-        /* Free the list element */
         Rm_osalFree((void *)validInstList, sizeof(Rm_PolicyValidInst));
         validInstList = nextInst;
     }
@@ -674,51 +540,38 @@ void Rm_policyFreeValidInstances (Rm_PolicyValidInst *validInstList)
  ****************Linux DTB Parsing Defines and Functions***************
  **********************************************************************/
 
-Rm_LinuxValueRange *Rm_linuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen)
 {
-    uint32_t *dtbValueData = (uint32_t *)dtbDataPtr;
+    uint32_t           *dtbValueData = (uint32_t *)dtbDataPtr;
     Rm_LinuxValueRange *startValue = NULL;
     Rm_LinuxValueRange *newValue = NULL;
     Rm_LinuxValueRange *prevValue = NULL;
-    uint32_t i;
+    uint32_t            i;
     
     /* Values are stored in the Linux DTB as a list of 32-bit words.  The number of 32-bit
      * words in the value field can differ.  depending on the number of values specified. */
-
-    /* Extract the value data from the Linux DTB */
-    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i++)
-    {
-        /* Creat a new value entry */
+    for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i++) {
         newValue = (Rm_LinuxValueRange *) Rm_osalMalloc(sizeof(Rm_LinuxValueRange));
-        /* Populate the new value entry.  The endianness of the value extracted must
-         * be flipped */
+        /* Endianness of extracted value must be flipped */
         newValue->value = fdt32_to_cpu(dtbValueData[i]);
         newValue->nextValue = NULL;
         
-        /* Value linked list pointer accounting */
-        if (prevValue == NULL)
-        {
-            /* Save the first entry so it can be returned */
+        if (prevValue == NULL) {
             startValue = newValue;
         }
-        else
-        {
-            prevValue->nextValue = (void *) newValue;
+        else {
+            prevValue->nextValue = newValue;
         }
-
         prevValue = newValue;
     }
-
-    /* Return a pointer to the start of the value list */
     return (startValue);
 }
 
-void Rm_linuxFreeValues(Rm_LinuxValueRange *valueList)
+void rmDtbUtilLinuxFreeValues(Rm_LinuxValueRange *valueList)
 {
     Rm_LinuxValueRange *nextValue;
     
-    while (valueList != NULL)
-    {
+    while (valueList) {
         nextValue = valueList->nextValue;
         Rm_osalFree((void *)valueList, sizeof(Rm_LinuxValueRange));
         valueList = nextValue;
index 6857af3fa241689b5f2c5cc27922c7d4a9893f4f..ce3ab592e41d8396680db15f045d22fc5357109f 100644 (file)
@@ -47,6 +47,7 @@
 
 /* RM internal API includes */
 #include <ti/drv/rm/include/rm_nameserverloc.h>
+#include <ti/drv/rm/include/rm_treeloc.h>
 
 /* AVL BBST includes */
 #include <ti/drv/rm/include/tree.h>
 /* RM OSAL layer */
 #include <rm_osal.h>
 
-/**********************************************************************
- ********************* NameServer Tree Functions **********************
- **********************************************************************/
-
-Rm_NameServerNode *Rm_nameServerNewNode(Rm_NameServerNodeCfg *nodeCfg)
-{
-    Rm_NameServerNode *newNode = NULL;
-
-    newNode = Rm_osalMalloc(sizeof(Rm_NameServerNode));
-    if (newNode) {
-        strcpy(newNode->objName, nodeCfg->objName);
-        strcpy(newNode->resourceName, nodeCfg->resourceName); 
-        newNode->resourceBase = nodeCfg->resourceBase;
-        newNode->resourceLength = nodeCfg->resourceLength;
-    }
-    
-    return(newNode);
-}
-
-void Rm_nameServerFreeNode(Rm_NameServerNode *node)
-{
-    if (node) {
-        Rm_osalFree((void *)node, sizeof(Rm_NameServerNode));
-    }
-}
-
-int Rm_nameServerNodeCompare(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, Rm_nameServerNodeCompare);
-
 /**********************************************************************
  ******************* Internal NameServer APIs *************************
  **********************************************************************/
 
-int32_t Rm_nameServerAddObject(Rm_NameServerObjCfg *objCfg)
+int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg)
 {
     Rm_NameServerNode    *newNode = NULL;
     int32_t               retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
     
-    if (newNode = Rm_nameServerNewNode(&objCfg->nodeCfg)) {
+    if (newNode = nameServerNodeNew(&objCfg->nodeCfg)) {
         if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) {
             /* Collision */
-            Rm_nameServerFreeNode(newNode);
+            nameServerNodeFree(newNode);
             retVal = RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS;
         }
     }
@@ -111,14 +78,14 @@ int32_t Rm_nameServerAddObject(Rm_NameServerObjCfg *objCfg)
     return(retVal);
 }
 
-int32_t Rm_nameServerFindObject(Rm_NameServerObjCfg *objCfg)
+int32_t rmNameServerFindObject(Rm_NameServerObjCfg *objCfg)
 {
     Rm_NameServerNode  findNode;
     Rm_NameServerNode *matchingNode;
     int32_t            retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
 
     memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
-    strcpy(findNode.objName, objCfg->nodeCfg.objName);
+    strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_RESOURCE_NAME_MAX_CHARS);
     
     if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
         /* Found in NameServer */
@@ -131,26 +98,26 @@ int32_t Rm_nameServerFindObject(Rm_NameServerObjCfg *objCfg)
     return(retVal);
 }
 
-int32_t Rm_nameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
+int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
 {   
     Rm_NameServerNode  findNode;
     Rm_NameServerNode *matchingNode;
     int32_t            retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;    
 
     memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
-    strcpy(findNode.objName, objCfg->nodeCfg.objName);
+    strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_RESOURCE_NAME_MAX_CHARS);
     
     if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
         /* Remove from NameServer */
         RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode);
-        Rm_nameServerFreeNode(matchingNode);
+        nameServerNodeFree(matchingNode);
         
         retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
     }    
     return(retVal);
 }
 
-void Rm_nameServerPrintObjects(Rm_NameServerTree *nameServerTree)
+void rmNameServerPrintObjects(Rm_NameServerTree *nameServerTree)
 {
     Rm_NameServerNode *node;
 
@@ -160,7 +127,7 @@ void Rm_nameServerPrintObjects(Rm_NameServerTree *nameServerTree)
     }
 }
 
-Rm_NameServerTree *Rm_nameServerInit(void)
+Rm_NameServerTree *rmNameServerInit(void)
 {
     Rm_NameServerTree *rootEntry = NULL;
 
index 26f2529de315bb409477ea87f8c96028ea1ead90..c9d97c8639d7c862db43668603e7c2544f7280c1 100644 (file)
@@ -44,7 +44,6 @@
 
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
-#include <ti/drv/rm/rm_policy.h>
 #include <ti/drv/rm/rm_services.h>
 
 /* RM internal API includes */
 
 char Rm_policyAllInstances[] = "*";
 
-/**********************************************************************
- *************** Policy Valid Instance Tree Functions *****************
- **********************************************************************/
-Rm_PolicyValidInstNode *Rm_policyNewValidInstNode(char *instName)
-{
-    Rm_PolicyValidInstNode *newNode = NULL;
-
-    newNode = Rm_osalMalloc(sizeof(Rm_PolicyValidInstNode));
-    
-    strcpy(newNode->name, instName);
-    newNode->allocRefCount = 0;
-    newNode->deletePending = FALSE;
-    
-    return(newNode);
-}
-
-void Rm_policyFreeValidInstNode(Rm_PolicyValidInstNode *node)
-{
-    if (node->allocRefCount == 0) {
-        Rm_osalFree((void *)node, sizeof(Rm_PolicyValidInstNode));
-    }
-}
-
-int Rm_policyValidInstNodeCompare(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, Rm_policyValidInstNodeCompare);
-
 /**********************************************************************
  ******************** Local Policy Functions **************************
  **********************************************************************/
 
-int32_t Rm_policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, 
-                                Rm_PolicyPermission *permissionsList)
+int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, 
+                             Rm_PolicyPermission *permissionsList)
 {
     while (permissionsList) {
         if (strcmp(permissionsList->instName, Rm_policyAllInstances) &&
-            (!Rm_policyGetValidInstNode(validInstTree, permissionsList->instName))) {
+            (!rmPolicyGetValidInstNode(validInstTree, permissionsList->instName))) {
             return(RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE);
         }
         permissionsList = permissionsList->nextPermission;
@@ -115,8 +83,8 @@ int32_t Rm_policyCheckInstances(Rm_PolicyValidInstTree *validInstTree,
     return(RM_INIT_OK);
 }
 
-Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permStrEnd, 
-                                                 int32_t *result)
+Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd, 
+                                              int32_t *result)
 {
     Rm_PolicyPermission *startPerm = NULL;
     Rm_PolicyPermission *newPerm = NULL;
@@ -191,7 +159,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
             newPerm = (Rm_PolicyPermission *) Rm_osalMalloc(sizeof(Rm_PolicyPermission));
             memset((void *)newPerm, 0, sizeof(Rm_PolicyPermission));
 
-            strcpy(newPerm->instName, instNameTemp);
+            strncpy(newPerm->instName, instNameTemp, RM_INSTANCE_NAME_MAX_CHARS);
             newPerm->nextPermission = NULL;
 
             if (prevPerm == NULL) {
@@ -207,6 +175,17 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
             instNameIndex = 0;
             foundInstName = FALSE;
         }
+        else if (instNameIndex == RM_INSTANCE_NAME_MAX_CHARS) {
+            /* Instance name is longer than max length */
+            while (startPerm) {
+                nextPerm = startPerm->nextPermission;
+                Rm_osalFree((void *)startPerm, sizeof(Rm_PolicyPermission));
+                startPerm = nextPerm;
+            } 
+            Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
+            *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INSTANCE_NAME_IN_ASSIGNMENT_TOO_LONG;
+            return(NULL);
+        }
 
         permStrPtr++;
     }
@@ -404,7 +383,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
     return (startPerm);
 }
 
-void Rm_policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
+void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
 {
     Rm_PolicyPermission *nextPerm;
     
@@ -415,8 +394,8 @@ void Rm_policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
     }
 }
 
-Rm_PolicyPermission *Rm_policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, 
-                                                       int32_t *result)
+Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, 
+                                                    int32_t *result)
 {
     Rm_PolicyPermission *startPerm = NULL;
     Rm_PolicyPermission *newPerm = NULL;
@@ -435,12 +414,12 @@ Rm_PolicyPermission *Rm_policyGetAssignmentPermissions(Rm_PolicyAssignment *assi
             permStrEnd = permStrStart + strlen(permStrStart);
         }
 
-        newPerm = Rm_policyParseSubPermission(permStrStart, permStrEnd, result);
+        newPerm = policyParseSubPermission(permStrStart, permStrEnd, result);
 
         if (*result != RM_SERVICE_PROCESSING) {
             /* Delete the permission list that's been created thus far, return
              * the error and NULL for the permission list */
-            Rm_policyFreeAssignmentPermissions(startPerm);
+            policyFreeAssignmentPermissions(startPerm);
             return(NULL);
         }
 
@@ -466,8 +445,8 @@ Rm_PolicyPermission *Rm_policyGetAssignmentPermissions(Rm_PolicyAssignment *assi
     return(startPerm);
 }
 
-int32_t Rm_policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
-                                               Rm_PolicyAssignment *assignmentList)
+int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
+                                            Rm_PolicyAssignment *assignmentList)
 {
     Rm_PolicyAssignment *assignment = assignmentList;
     Rm_PolicyPermission *permissionList;
@@ -475,17 +454,17 @@ int32_t Rm_policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
 
     while (assignment) {
         /* Make sure assignment's permissions parse okay */
-        permissionList = Rm_policyGetAssignmentPermissions(assignment, &result);
+        permissionList = policyGetAssignmentPermissions(assignment, &result);
         if (result != RM_INIT_OK) {
             return(result);
         }                        
         
-        if (result = Rm_policyCheckInstances(root, permissionList) != RM_INIT_OK) {
-            Rm_policyFreeAssignmentPermissions(permissionList);
+        if (result = policyCheckInstances(root, permissionList) != RM_INIT_OK) {
+            policyFreeAssignmentPermissions(permissionList);
             return(result);
         }
 
-        Rm_policyFreeAssignmentPermissions(permissionList);
+        policyFreeAssignmentPermissions(permissionList);
         assignment = assignment->nextAssignment;
     }
 
@@ -496,24 +475,24 @@ int32_t Rm_policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
  ************************ Internal Policy APIs ************************
  **********************************************************************/
 
-Rm_PolicyValidInstNode *Rm_policyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName)
+Rm_PolicyValidInstNode *rmPolicyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName)
 {
     Rm_PolicyValidInstNode  findNode;
 
     memset((void *)&findNode, 0, sizeof(Rm_PolicyValidInstNode));
-    strcpy(findNode.name, instName);
+    strncpy(findNode.name, instName, RM_RESOURCE_NAME_MAX_CHARS);
     
     return (RB_FIND(_Rm_PolicyValidInstTree, validInstTree, &findNode));
 }
 
-Rm_PolicyValidInstNode *Rm_policyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree)
+Rm_PolicyValidInstNode *rmPolicyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree)
 {
     char linuxName[] = RM_ALLOCATED_TO_LINUX;
 
-    return (Rm_policyGetValidInstNode(validInstTree, linuxName));
+    return (rmPolicyGetValidInstNode(validInstTree, linuxName));
 }
 
-bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
+bool rmPolicyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
 {
     int32_t              propertyOffset;
     const char          *propertyName;
@@ -532,8 +511,8 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
         while (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
             propertyData = fdt_getprop_by_offset(privilegeCfg->policyDtb, propertyOffset, &propertyName, &propertyLen);
-            if (Rm_policyGetPropertyType(propertyName) == Rm_policyPropType_ASSIGNMENTS) {
-                assignment = assignmentStart = Rm_policyExtractAssignments(propertyData, propertyLen);
+            if (rmDtbUtilPolicyGetPropertyType(propertyName) == Rm_policyPropType_ASSIGNMENTS) {
+                assignment = assignmentStart = rmDtbUtilPolicyExtractAssignments(propertyData, propertyLen);
                 break;
             }
             propertyOffset = fdt_next_property_offset(privilegeCfg->policyDtb, propertyOffset);
@@ -551,7 +530,7 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
                 ((resourceEnd >= assignment->resourceBase) &&
                  (resourceEnd <= assignmentEnd))) {
                  
-                permission = permissionStart = Rm_policyGetAssignmentPermissions(assignment, result);
+                permission = permissionStart = policyGetAssignmentPermissions(assignment, result);
                 while (permission) {
                     if ((strcmp(permission->instName, privilegeCfg->validInstNode->name) == 0) ||
                         (strcmp(permission->instName, Rm_policyAllInstances) == 0)) {
@@ -560,22 +539,22 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
                         /* Check instance's permissions */
                         if (privilegeCfg->type == Rm_policyCheck_INIT) {
                             if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
-                                Rm_policyFreeAssignmentPermissions(permissionStart);
-                                Rm_policyFreeAssignments(assignmentStart);
+                                policyFreeAssignmentPermissions(permissionStart);
+                                rmDtbUtilPolicyFreeAssignments(assignmentStart);
                                 return(FALSE);
                             }
                         }
                         else if (privilegeCfg->type == Rm_policyCheck_USE) {
                             if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
-                                Rm_policyFreeAssignmentPermissions(permissionStart);
-                                Rm_policyFreeAssignments(assignmentStart);
+                                policyFreeAssignmentPermissions(permissionStart);
+                                rmDtbUtilPolicyFreeAssignments(assignmentStart);
                                 return(FALSE);
                             }   
                         }
                         else if (privilegeCfg->type == Rm_policyCheck_EXCLUSIVE) {
                             if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT)) {
-                                Rm_policyFreeAssignmentPermissions(permissionStart);
-                                Rm_policyFreeAssignments(assignmentStart);
+                                policyFreeAssignmentPermissions(permissionStart);
+                                rmDtbUtilPolicyFreeAssignments(assignmentStart);
                                 return(FALSE);
                             }   
                         }
@@ -584,15 +563,15 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
                     permission = permission->nextPermission;
                 }
                 
-                Rm_policyFreeAssignmentPermissions(permissionStart);
+                policyFreeAssignmentPermissions(permissionStart);
                 if (!foundInstance) {
-                    Rm_policyFreeAssignments(assignmentStart);
+                    rmDtbUtilPolicyFreeAssignments(assignmentStart);
                     return(FALSE);
                 }
             }
             assignment = assignment->nextAssignment;
         }
-        Rm_policyFreeAssignments(assignmentStart);
+        rmDtbUtilPolicyFreeAssignments(assignmentStart);
     }
     else {
         return(FALSE);
@@ -601,9 +580,9 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
     return(TRUE);
 }
 
-uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
-                                  int32_t resourceOffset, uint32_t allocType, 
-                                  int32_t *result)
+uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
+                                 int32_t resourceOffset, uint32_t allocType, 
+                                 int32_t *result)
 
 {
     int32_t              propertyOffset;
@@ -620,8 +599,8 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *valid
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
         while (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
             propertyData = fdt_getprop_by_offset(policyDtb, propertyOffset, &propertyName, &propertyLen);
-            if (Rm_policyGetPropertyType(propertyName) == Rm_policyPropType_ASSIGNMENTS) {
-                assignment = assignmentStart = Rm_policyExtractAssignments(propertyData, propertyLen);
+            if (rmDtbUtilPolicyGetPropertyType(propertyName) == Rm_policyPropType_ASSIGNMENTS) {
+                assignment = assignmentStart = rmDtbUtilPolicyExtractAssignments(propertyData, propertyLen);
                 break;
             }
             propertyOffset = fdt_next_property_offset(policyDtb, propertyOffset);
@@ -631,7 +610,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *valid
     /* Search policy permissions for a valid resource base */
     if (assignment) {
         while (assignment) {
-            permission = permissionStart = Rm_policyGetAssignmentPermissions(assignment, result);
+            permission = permissionStart = policyGetAssignmentPermissions(assignment, result);
             while (permission) {
                 if ((strcmp(permission->instName, validInstNode->name) == 0) ||
                     (strcmp(permission->instName, Rm_policyAllInstances) == 0)) {
@@ -649,7 +628,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *valid
                 }
                 permission = permission->nextPermission;
             }
-            Rm_policyFreeAssignmentPermissions(permissionStart);
+            policyFreeAssignmentPermissions(permissionStart);
 
             if (resourceBase) {
                 break;
@@ -658,7 +637,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *valid
                 assignment = assignment->nextAssignment;
             }
         }
-        Rm_policyFreeAssignments(assignmentStart);
+        rmDtbUtilPolicyFreeAssignments(assignmentStart);
     }
     else {
         *result = RM_SERVICE_DENIED_NO_RANGE_ASSIGNMENTS_FOR_POLICY;
@@ -667,7 +646,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *valid
     return(resourceBase);
 }
 
-uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
+uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
 {
     int32_t            propertyOffset;
     const char        *propertyName;
@@ -680,10 +659,10 @@ uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
         while (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
             propertyData = fdt_getprop_by_offset(policyDtb, propertyOffset, &propertyName, &propertyLen);
-            if (Rm_policyGetPropertyType(propertyName) == Rm_policyPropType_ALLOCATION_ALIGNMENTS) {
-                alignmentList = Rm_policyExtractResourceAlignments(propertyData, propertyLen);
+            if (rmDtbUtilPolicyGetPropertyType(propertyName) == Rm_policyPropType_ALLOCATION_ALIGNMENT) {
+                alignmentList = rmDtbUtilPolicyExtractResourceAlignments(propertyData, propertyLen);
                 resourceAlignment = alignmentList->value;                
-                Rm_policyFreeResourceAlignments(alignmentList);
+                rmDtbUtilPolicyFreeResourceAlignments(alignmentList);
             }
             propertyOffset = fdt_next_property_offset(policyDtb, propertyOffset);
         }
@@ -691,7 +670,7 @@ uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
     return(resourceAlignment);
 }
 
-int32_t Rm_policyGetResourceOffset(void *policyDtb, char *resourceName)
+int32_t rmPolicyGetResourceOffset(void *policyDtb, char *resourceName)
 {
     int32_t     nodeOffset;
     int32_t     depth;
@@ -714,7 +693,7 @@ int32_t Rm_policyGetResourceOffset(void *policyDtb, char *resourceName)
     return(nodeOffset);
 }
 
-int32_t Rm_policyValidatePolicyResourceNames(void *policyDtb, void *allocatorList)
+int32_t rmPolicyValidatePolicyResourceNames(void *policyDtb, void *allocatorList)
 {
     Rm_Allocator *allocator = (Rm_Allocator *)allocatorList;
     int32_t              nodeOffset;
@@ -732,7 +711,7 @@ int32_t Rm_policyValidatePolicyResourceNames(void *policyDtb, void *allocatorLis
         nodeOffset = fdt_next_node(policyDtb, nodeOffset, &depth);
         nodeName = fdt_get_name(policyDtb, nodeOffset, NULL);
         if (fdt_first_property_offset(policyDtb, nodeOffset) > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
-            if (Rm_allocatorFind(allocator, (char *)nodeName) == NULL) {
+            if (rmAllocatorFind(allocator, (char *)nodeName) == NULL) {
                 /* No allocator tied to resource name */
                 return(RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE);
             }        
@@ -742,7 +721,7 @@ int32_t Rm_policyValidatePolicyResourceNames(void *policyDtb, void *allocatorLis
 }
 
 /* TODO: ADD ABILITY TO RETURN THE SYNTAX ERROR LOCATION */
-int32_t Rm_policyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree)
+int32_t rmPolicyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree)
 {
     int32_t              nodeOffset;
     int32_t              propertyOffset;
@@ -766,15 +745,15 @@ int32_t Rm_policyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validIn
         propertyOffset = fdt_first_property_offset(policyDtb, nodeOffset);                
         while (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
             propertyData = fdt_getprop_by_offset(policyDtb, propertyOffset, &propertyName, &propertyLen);
-            propertyType = Rm_policyGetPropertyType(propertyName);
+            propertyType = rmDtbUtilPolicyGetPropertyType(propertyName);
             if (propertyType == Rm_policyPropType_ASSIGNMENTS) {
-                assignmentList = Rm_policyExtractAssignments(propertyData, propertyLen);
+                assignmentList = rmDtbUtilPolicyExtractAssignments(propertyData, propertyLen);
                 
-                if ((result = Rm_policyValidateAssignmentPermissions(validInstTree, assignmentList)) != RM_INIT_OK) {
-                    Rm_policyFreeAssignments(assignmentList);
+                if ((result = policyValidateAssignmentPermissions(validInstTree, assignmentList)) != RM_INIT_OK) {
+                    rmDtbUtilPolicyFreeAssignments(assignmentList);
                     return(result);
                 }
-                Rm_policyFreeAssignments(assignmentList);
+                rmDtbUtilPolicyFreeAssignments(assignmentList);
             }
             else if (propertyType == Rm_policyPropType_UNKNOWN) {
                 return(RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE_PROPERTY);
@@ -785,17 +764,17 @@ int32_t Rm_policyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validIn
     return(RM_INIT_OK);
 }
 
-Rm_PolicyValidInstTree *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result)
+Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *result)
 {
-    int32_t             validInstOffset;
-    const char         *validInstName;
-       int32_t             validInstLen;
-       const void         *validInstData;
-    Rm_PolicyPropType   propertyType;
-    Rm_PolicyValidInst *validInstList;
-    Rm_PolicyValidInstTree   *rootEntry = NULL;
-    Rm_PolicyValidInstNode   *newNode;  
-    char                linuxName[] = RM_ALLOCATED_TO_LINUX;
+    int32_t                 validInstOffset;
+    const char             *validInstName = NULL;
+       int32_t                 validInstLen;
+       const void             *validInstData = NULL;
+    Rm_PolicyPropType       propertyType;
+    Rm_PolicyValidInst     *validInstList = NULL;
+    Rm_PolicyValidInstTree *rootEntry = NULL;
+    Rm_PolicyValidInstNode *newNode = NULL;  
+    char                    linuxName[] = RM_ALLOCATED_TO_LINUX;
 
     /* Valid instance list must be first and only property in the root node of
      * the policyDtb */
@@ -809,39 +788,42 @@ Rm_PolicyValidInstTree *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *r
         return (NULL);
     }
     validInstData = fdt_getprop_by_offset(policyDtb, validInstOffset, &validInstName, &validInstLen);
-    propertyType = Rm_policyGetPropertyType(validInstName);
+    propertyType = rmDtbUtilPolicyGetPropertyType(validInstName);
     if (propertyType != Rm_policyPropType_VALID_INSTANCES) {
         *result = RM_INIT_ERROR_POLICY_NO_VALID_INSTANCES_DEFINED;
         return (NULL);
     }
-    validInstList = Rm_policyExtractValidInstances(validInstData, validInstLen);
 
+    if (!(validInstList = rmDtbUtilPolicyExtractValidInstances(validInstData, validInstLen, result))) {
+        return (NULL);
+    }
+    
     /* Create the tree */
     rootEntry = Rm_osalMalloc(sizeof(Rm_PolicyValidInstTree));
     RB_INIT(rootEntry);
 
     while (validInstList) {
-        newNode = Rm_policyNewValidInstNode(validInstList->instName);
+        newNode = policyValidInstNodeNew(validInstList->instName);
         RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);
         
         validInstList = validInstList->nextValidInst;
     }
 
     /* Add the Linux kernel node */
-    newNode = Rm_policyNewValidInstNode(linuxName);
+    newNode = policyValidInstNodeNew(linuxName);
     RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);    
 
     *result = RM_INIT_OK;
     return (rootEntry);
 }
 
-void Rm_policyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree)
+void rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree)
 {
     Rm_PolicyValidInstNode *node;
     
     RB_FOREACH(node, _Rm_PolicyValidInstTree, validInstTree) {               
         RB_REMOVE(_Rm_PolicyValidInstTree, validInstTree, node);
-        Rm_policyFreeValidInstNode(node);
+        policyValidInstNodeFree(node);
     }        
     Rm_osalFree((void *)validInstTree, sizeof(Rm_PolicyValidInstTree));
 }
index b1ff067cf5d08203e8b13aafc857c81c545ba4ec..3033b9186b651bec02549a595404ea780fa894eb 100644 (file)
 #include <rm_osal.h>
 
 /**********************************************************************
- ********************** Internal Functions ****************************
+ ********************** Application visible APIs **********************
  **********************************************************************/
 
 void Rm_serviceHandler (void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
                         Rm_ServiceRespInfo *serviceResponse)
 {
-    Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
+    Rm_Inst        *rmInst = (Rm_Inst *)rmHandle;
     Rm_Transaction *transaction;
 
-    /* Make sure that a callback function has been provided */
-    if (serviceRequest->callback.serviceCallback == NULL)
-    {
-        /* The RM Client and Client Delegate use blocking transports to consult with a 
-         * high-level RM agent prior to providing a response to the component.  It is 
-         * assumed the component's cannot block.  Therefore, all responses must go
-         * through the callback function provided by the component.  Return an error 
-         * if the component does not provide a callback function. */
+    if (serviceRequest->callback.serviceCallback == NULL) {
         serviceResponse->serviceState = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
         return;
     }
-    
-    /* Create a new transaction */
-    transaction = Rm_transactionQueueAdd(rmInst);
 
-    if (transaction == NULL)
-    {
-        /* Failed to create a new transaction */
-        serviceResponse->serviceState = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;
+    if (serviceRequest->type >= Rm_service_LAST) {
+        serviceResponse->serviceState = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;
+        return;
     }
-    else
-    {
-        /* Transfer request information into the transaction */
+    
+    transaction = rmTransactionQueueAdd(rmInst);
+    if (transaction) {
         transaction->type = serviceRequest->type;
-        strcpy(transaction->serviceSrcInstName, rmInst->instName);
+        strncpy(transaction->serviceSrcInstName, rmInst->instName, RM_INSTANCE_NAME_MAX_CHARS);
         transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
         transaction->state = RM_SERVICE_PROCESSING;
-        strcpy(&(transaction->resourceInfo.name)[0], serviceRequest->resourceName);
+        if (serviceRequest->resourceName) {
+            strncpy(transaction->resourceInfo.name, serviceRequest->resourceName, RM_RESOURCE_NAME_MAX_CHARS);
+        }
         transaction->resourceInfo.base = serviceRequest->resourceBase;
         transaction->resourceInfo.length = serviceRequest->resourceLength;
         transaction->resourceInfo.alignment = serviceRequest->resourceAlignment;
-        strcpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName);
-
-        /* Pass the new transaction to the transaction processor */
-        Rm_transactionProcessor (rmInst, transaction);
+        if (serviceRequest->resourceNsName) {
+            strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_RESOURCE_NAME_MAX_CHARS);
+        }
 
-        /* Provide response to the component that requested the service */
+        rmTransactionProcessor (rmInst, transaction);
         serviceResponse->serviceState = transaction->state;
-        if (serviceResponse->serviceState == RM_SERVICE_PROCESSING)
-        {
-            /* The service is still being processed.  Provide the transaction ID
-             * back to the component so that it can sort service responses received
-             * via the provided callback function */
+        if (serviceResponse->serviceState == RM_SERVICE_PROCESSING) {
+            /* Service still being processed.  Provide transaction ID
+             * back to component so it can sort service responses received
+             * via callback function */
             serviceResponse->serviceId = transaction->localId;
         }
-        else if (serviceResponse->serviceState == RM_SERVICE_APPROVED_AND_COMPLETED)
-        {
-            /* Service was approved and service was an allocate request the resource
-             * data is passed back to the component */
+        else if (serviceResponse->serviceState == RM_SERVICE_APPROVED_AND_COMPLETED) {
             if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
                 (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
-                (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))
-            {
-                strcpy(serviceResponse->resourceName, transaction->resourceInfo.name);
+                (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)) {
+                strncpy(serviceResponse->resourceName, transaction->resourceInfo.name, RM_RESOURCE_NAME_MAX_CHARS);
                 serviceResponse->resourceBase = transaction->resourceInfo.base;
                 serviceResponse->resourceLength = transaction->resourceInfo.length;
             }
-
-            /* Delete the transaction since a response was received immediately */
-            Rm_transactionQueueDelete(rmInst, transaction->localId);
+            rmTransactionQueueDelete(rmInst, transaction->localId);
         }
-        else
-        {
-            /* The serviceState field will contain information regarding why the 
-             * service was denied or what error the service encountered.  Just delete
-             * the transaction since a response was received immediately */
-            Rm_transactionQueueDelete(rmInst, transaction->localId);
+        else {
+            rmTransactionQueueDelete(rmInst, transaction->localId);
         }
     }
-
+    else {
+        serviceResponse->serviceState = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;    
+    }
     return;
 }
 
-/**********************************************************************
- ********************** Application visible APIs **********************
- **********************************************************************/
-
 void Rm_servicePreMainRequest(Rm_PreMainReqCfg *reqCfg, Rm_ServiceRespInfo *preMainResp)
 {
     Rm_PreMainInst       *preMainInst = (Rm_PreMainInst *)reqCfg->rmPreMainHandle;
@@ -162,14 +139,14 @@ void Rm_servicePreMainRequest(Rm_PreMainReqCfg *reqCfg, Rm_ServiceRespInfo *preM
             privCheckCfg.type = Rm_policyCheck_USE;
         }
         privCheckCfg.policyDtb = preMainInst->startupDtb;
-        privCheckCfg.validInstNode = Rm_policyGetValidInstNode(preMainInst->validInstTree, 
-                                                                preMainInst->instName);
-        privCheckCfg.resourceOffset = Rm_policyGetResourceOffset(preMainInst->startupDtb,
-                                                                  reqCfg->request->resourceName);
+        privCheckCfg.validInstNode = rmPolicyGetValidInstNode(preMainInst->validInstTree, 
+                                                              preMainInst->instName);
+        privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(preMainInst->startupDtb,
+                                                                reqCfg->request->resourceName);
         privCheckCfg.resourceBase = reqCfg->request->resourceBase;
         privCheckCfg.resourceLength = reqCfg->request->resourceLength;
 
-        if (Rm_policyCheckPrivilege(&privCheckCfg, &preMainResp->serviceState)) {
+        if (rmPolicyCheckPrivilege(&privCheckCfg, &preMainResp->serviceState)) {
             preMainResp->serviceState = RM_SERVICE_APPROVED_AND_COMPLETED;
         }
         else if (preMainResp->serviceState == RM_SERVICE_PROCESSING) {
@@ -197,7 +174,7 @@ void Rm_servicePreMainRequest(Rm_PreMainReqCfg *reqCfg, Rm_ServiceRespInfo *preM
         /* Fill out response */
         preMainResp->resourceBase = reqCfg->request->resourceBase;
         preMainResp->resourceLength = reqCfg->request->resourceLength;
-        strcpy(preMainResp->resourceName, reqCfg->request->resourceName);
+        strncpy(preMainResp->resourceName, reqCfg->request->resourceName, RM_RESOURCE_NAME_MAX_CHARS);
         preMainResp->serviceId = ++preMainInst->requestCount;
     }
 }
@@ -218,7 +195,7 @@ Rm_ServicePort *Rm_serviceGetPort(Rm_Handle rmHandle)
     }
 
     newServicePort->rmHandle = rmHandle;
-    newServicePort->rmService = Rm_serviceHandler;
+    newServicePort->Rm_serviceHandler = Rm_serviceHandler;
 
     return (newServicePort);
 }
index de5a60b74aac245877a3235d882741f5c8acdbce..5e255ead4f286bc0b92b9a830e665394f92fbb61 100644 (file)
  ********************** Internal Functions ****************************\r
  **********************************************************************/\r
 \r
-Rm_TransportNode *Rm_transportNodeAdd(Rm_Inst *rmInst, Rm_TransportCfg *transportCfg)\r
+Rm_Transport *transportAdd(Rm_TransportCfg *transportCfg)\r
 {\r
-    Rm_TransportNode *routeMap = (Rm_TransportNode *)rmInst->routeMap;\r
-    Rm_TransportNode *newTransportNode = NULL;\r
-\r
-    /* Get memory for a new transport node from local memory */\r
-    newTransportNode = Rm_osalMalloc (sizeof(Rm_TransportNode));\r
-\r
-    /* Return if the memory allocated for the transport node is NULL */\r
-    if (newTransportNode != NULL)\r
-    {\r
-        /* Populate the new entry */\r
-        newTransportNode->rmHandle = (Rm_Handle) rmInst;\r
-        newTransportNode->remoteInstType = transportCfg->remoteInstType;\r
-        strcpy(&(newTransportNode->remoteInstName)[0], transportCfg->remoteInstName);\r
-        newTransportNode->nextNode = NULL;  /* New node will always be NULL */\r
-\r
-        /* Check if there are any nodes in the transport routing map */\r
-        if (routeMap)\r
-        {\r
-            /* At least one node in the routing map.  Add the new node to the end of the\r
-             * routing map */\r
-            while (routeMap->nextNode != NULL)\r
-            {\r
-                /* Traverse the list until arriving at the last node */\r
-                routeMap = (Rm_TransportNode *)routeMap->nextNode;\r
-            }\r
+    Rm_Inst      *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
+    Rm_Transport *transports = rmInst->transports;\r
+    Rm_Transport *newTransport = NULL;\r
 \r
-            /* Add the new node to the end of the list */\r
-            routeMap->nextNode = (void *)newTransportNode;\r
-        }\r
-        else\r
-        {\r
-            /* The transport routing map does not currently exist.  The new node is the first node */\r
-            rmInst->routeMap = (void *)newTransportNode;\r
-        }\r
-    }\r
+    newTransport = Rm_osalMalloc (sizeof(Rm_Transport));\r
 \r
-    return (newTransportNode);\r
-}\r
+    if (newTransport) {\r
+        newTransport->rmHandle = transportCfg->rmHandle;\r
+        newTransport->remoteInstType = transportCfg->remoteInstType;\r
+        strncpy(&(newTransport->remoteInstName)[0], transportCfg->remoteInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
+        newTransport->nextTransport = NULL;\r
 \r
-Rm_TransportNode *Rm_transportNodeFindTransportHandle(Rm_Inst *rmInst, \r
-                                                      Rm_TransportHandle transportHandle)\r
-{\r
-    Rm_TransportNode *transportNode = (Rm_TransportNode *)rmInst->routeMap;\r
-\r
-    /* Make sure there is at least one node in the route map */\r
-    if (transportNode != NULL)\r
-    {\r
-        /* Find the transport node with the transport handle within the RM instance's\r
-         * route map.  If the end of the route map is reached without finding the node the \r
-         * node pointer will be NULL */\r
-        while (transportNode != NULL)\r
-        {\r
-            /* The transport handle is the address of the transport node */\r
-            if (transportNode == ((Rm_TransportNode *)transportHandle))\r
-            {\r
-                /* Match: break out of loop and return the node */\r
-                break;             \r
+        if (transports) {\r
+            while (transports->nextTransport != NULL) {\r
+                transports = transports->nextTransport;\r
             }\r
-            transportNode = (Rm_TransportNode *)transportNode->nextNode;\r
+            transports->nextTransport = newTransport;\r
+        }\r
+        else {\r
+            rmInst->transports = (void *) newTransport;\r
         }\r
     }\r
-\r
-    return (transportNode);\r
+    return (newTransport);\r
 }\r
 \r
-Rm_TransportNode *Rm_transportNodeFindRemoteName(Rm_Inst *rmInst, char *remoteName)\r
+Rm_Transport *transportFindTransportHandle(Rm_Transport *transports, \r
+                                           Rm_TransportHandle transportHandle)\r
 {\r
-    Rm_TransportNode *transportNode = (Rm_TransportNode *)rmInst->routeMap;\r
-\r
-    /* Make sure there is at least one node in the route map */\r
-    if (transportNode != NULL)\r
-    {\r
-        /* Find the transport node with the provided remote instance name.\r
-         * If the end of the route map is reached without finding the node the \r
-         * node pointer will be NULL */\r
-        while (transportNode != NULL)\r
-        {\r
-            /* The transport handle is the address of the transport node */\r
-            if (strcmp(&(transportNode->remoteInstName)[0], remoteName) == 0)\r
-            {\r
-                /* Match: break out of loop and return the node */\r
-                break;             \r
-            }\r
-            transportNode = (Rm_TransportNode *)transportNode->nextNode;\r
+    while (transports) {\r
+        if (transports == ((Rm_Transport *)transportHandle)) {\r
+            break;             \r
         }\r
+        transports = transports->nextTransport;\r
     }\r
-\r
-    return (transportNode);\r
+    return (transports);\r
 }\r
 \r
-Rm_TransportNode *Rm_transportNodeFindRemoteInstType(Rm_Inst *rmInst,\r
-                                                     Rm_InstType remoteInstType)\r
+Rm_TransportResult transportDelete(Rm_Handle rmHandle, Rm_TransportHandle transportHandle)\r
 {\r
-    Rm_TransportNode *transportNode = (Rm_TransportNode *)rmInst->routeMap;\r
-\r
-    /* Make sure there is at least one node in the route map */\r
-    if (transportNode != NULL)\r
-    {\r
-        /* Find the transport node with the provided remote instance type.\r
-         * If the end of the route map is reached without finding the node the \r
-         * node pointer will be NULL */\r
-        while (transportNode != NULL)\r
-        {\r
-            if (transportNode->remoteInstType == remoteInstType)\r
-            {\r
-                /* Match: break out of loop and return the node */\r
-                break;             \r
-            }\r
-            transportNode = (Rm_TransportNode *)transportNode->nextNode;\r
+    Rm_Inst      *rmInst = (Rm_Inst *)rmHandle;\r
+    Rm_Transport *transport = (Rm_Transport *) rmInst->transports;\r
+    Rm_Transport *prevTransport = NULL;\r
+\r
+    while (transport) {\r
+        if (transport == (Rm_Transport *)transportHandle) {\r
+            break;             \r
         }\r
+        prevTransport = transport;\r
+        transport = transport->nextTransport;\r
     }\r
 \r
-    return (transportNode);\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
+    }\r
+    else {\r
+        return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
+    }\r
+    return (RM_TRANSPORT_SUCCESSFUL);\r
 }\r
 \r
-Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle transportHandle)\r
+Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName)\r
 {\r
-    Rm_TransportNode *transportNode = (Rm_TransportNode *)rmInst->routeMap;\r
-    Rm_TransportNode *prevNode = NULL;\r
-\r
-    /* Make sure there is at least one entry in the transaction queue */\r
-    if (transportNode == NULL)\r
-    {\r
-        return (RM_TRANSPORT_ERROR_NO_TRANSPORTS_REGISTERED);\r
-    }\r
-\r
-    /* Find the transport handle within the RM instance's route map. */\r
-    while (transportNode != NULL)\r
-    {\r
-        if (transportNode == (Rm_TransportNode *) transportHandle)\r
-        {\r
-            /* Match: break out of loop and delete the entry */\r
+    while (transports) {\r
+        if (strcmp(transports->remoteInstName, remoteName) == 0) {\r
             break;             \r
         }\r
-\r
-        prevNode = transportNode;\r
-        transportNode = (Rm_TransportNode *)transportNode->nextNode;\r
+        transports = transports->nextTransport;\r
     }\r
+    return (transports);\r
+}\r
 \r
-    /* Traversed entire queue but did not find transaction */\r
-    if (transportNode == NULL)\r
-    {\r
-        return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
-    }\r
-    else\r
-    {\r
-        /* Delete the transport node */\r
-        if (prevNode == NULL)\r
-        {\r
-            /* Node to be deleted exists at start of route map.  Map second\r
-             * node to be start of route map as long as there are more than\r
-             * one nodes */\r
-            rmInst->routeMap = transportNode->nextNode;\r
-        }\r
-        else\r
-        {\r
-            /* Node to be deleted is in the middle or at end of the route map.  Adjust adjacent\r
-             * node pointers.  This covers the case where the node to be removed is at the\r
-             * end of the route map. */\r
-            prevNode->nextNode = transportNode->nextNode;\r
+Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType)\r
+{\r
+    while (transports) {\r
+        if (transports->remoteInstType == remoteInstType) {\r
+            break;             \r
         }\r
-\r
-        /* Free the memory associated with the node. */\r
-        Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode));\r
+        transports = transports->nextTransport;\r
     }\r
-\r
-    return (RM_TRANSPORT_SUCCESSFUL);\r
+    return (transports);\r
 }\r
 \r
-Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
+Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
                                             Rm_Transaction *transaction)\r
 {\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Packet             *rmPkt = NULL;\r
     Rm_ResourceRequestPkt *resourceReqPkt = NULL;\r
 \r
-    /* Make sure a buffer for the packet was allocated  */\r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
-        NULL)\r
-    {\r
+    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
+        NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
 \r
-    /* Make sure allocated buffer is large enough to fit the request packet plus the \r
-     * rmPktLen and Rm_PktType fields */\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\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
-    /* Set the Rm Packet type */    \r
+   \r
     rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;\r
-                          \r
-    /* Assign the packet's data field to be the start of the resource request packet */\r
     resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;\r
-    /* Populate the resource request packet using the transaction information */\r
     resourceReqPkt->requestId = transaction->localId;\r
-    if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT)\r
-    {\r
+    if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {\r
         resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;\r
     }\r
-    else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)\r
-    {\r
+    else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {\r
         resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;\r
     }    \r
-    else if (transaction->type == Rm_service_RESOURCE_FREE)\r
-    {\r
+    else if (transaction->type == Rm_service_RESOURCE_FREE) {\r
         resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;\r
     }\r
-    else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)\r
-    {\r
+    else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
         resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;\r
     }\r
-    /* Pass along the packet source and service source information */\r
-    strcpy(resourceReqPkt->pktSrcInstName, rmInst->instName);\r
-    strcpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
-    /* Copy the resource data */\r
+    strncpy(resourceReqPkt->pktSrcInstName, rmInst->instName, RM_INSTANCE_NAME_MAX_CHARS);\r
+    strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
     memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
-\r
     return (rmPkt);\r
 }\r
 \r
-Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
+Rm_Packet *rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
                                                  Rm_Transaction *transaction)\r
 {\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Packet              *rmPkt = NULL;\r
     Rm_ResourceResponsePkt *resourceRespPkt = NULL;\r
 \r
-    /* Make sure a buffer for the packet was allocated  */\r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
-        NULL)\r
-    {\r
+    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
+        NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
 \r
-    /* Make sure allocated buffer is large enough to fit the request packet plus the \r
-     * rmPktLen and Rm_PktType fields */\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\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
-\r
-    /* Set the Rm Packet type */    \r
+    } \r
     rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;\r
                           \r
-    /* Assign the packet's data field to be the start of the resource response packet */\r
     resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;\r
-    /* Populate the resource response packet using the transaction information.  The\r
-     * responseId is the remoteOriginatingId.  The responseId must match the local ID \r
-     * of the transaction that originated the request */\r
     resourceRespPkt->responseId = transaction->remoteOriginatingId;\r
     resourceRespPkt->requestState = transaction->state;\r
-    /* Copy the resource data */\r
     memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
 \r
     return (rmPkt);\r
 }\r
 \r
-Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
+Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
                                           Rm_Transaction *transaction)\r
 {\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Packet       *rmPkt = NULL;\r
     Rm_NsRequestPkt *nsReqPkt = NULL;\r
 \r
-    /* Make sure a buffer for the packet was allocated  */\r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
-        NULL)\r
-    {\r
+    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
+        NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
 \r
-    /* Make sure allocated buffer is large enough to fit the request packet plus the \r
-     * rmPktLen and Rm_PktType fields */\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_NsRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\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
-\r
-    /* Set the Rm Packet type */    \r
     rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;\r
                           \r
-    /* Assign the packet's data field to be the start of the NameServer request packet */\r
     nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;\r
-    /* Populate the NameServer request packet using the transaction information */\r
     nsReqPkt->requestId = transaction->localId;\r
-    if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME)\r
-    {\r
+    if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {\r
         nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;\r
     }\r
-    else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)\r
-    {\r
+    else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
         nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;\r
     }\r
-    /* Pass along the packet source and service source information */\r
-    strcpy(nsReqPkt->pktSrcInstName, rmInst->instName);\r
-    strcpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
-    /* Copy the NameServer request data */\r
+    strncpy(nsReqPkt->pktSrcInstName, rmInst->instName, RM_INSTANCE_NAME_MAX_CHARS);\r
+    strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
     memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
             sizeof(Rm_ResourceInfo));\r
 \r
     return (rmPkt);\r
 }\r
 \r
-Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
+Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport,\r
                                            Rm_Transaction *transaction)\r
 {\r
-    Rm_Packet *rmPkt = NULL;\r
+    Rm_Packet        *rmPkt = NULL;\r
     Rm_NsResponsePkt *nsRespPkt = NULL;\r
 \r
-    /* Make sure a buffer for the packet was allocated  */\r
-    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
-        NULL)\r
-    {\r
+    if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) ==\r
+        NULL) {\r
         transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
         return (NULL);\r
     }\r
 \r
-    /* Make sure allocated buffer is large enough to fit the response packet plus the \r
-     * rmPktLen and Rm_PktType fields */\r
-    if (rmPkt->pktLenBytes < (sizeof(Rm_NsResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\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
-\r
-    /* Set the Rm Packet type */    \r
+    }  \r
     rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;\r
                           \r
-    /* Assign the packet's data field to be the start of the NameServer response packet */\r
     nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;\r
-    /* Populate the NameServer response packet using the transaction information. The\r
-     * responseId is the remoteOriginatingId.  The responseId must match the local ID \r
-     * of the transaction that originated the request */\r
     nsRespPkt->responseId = transaction->remoteOriginatingId;\r
     nsRespPkt->requestState = transaction->state;\r
 \r
@@ -409,109 +276,77 @@ Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *ds
  ********************* Application visible APIs ***********************\r
  **********************************************************************/\r
 \r
-Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, Rm_TransportCfg *transportCfg)\r
+Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result)\r
 {\r
-    Rm_Inst *rmInst = (Rm_Inst *) rmHandle;\r
-    Rm_TransportNode *transportNode = NULL;\r
-    void *key;\r
-\r
-    /* Lock access to the RM instance */\r
-    key = Rm_osalMtCsEnter();\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
      * connect to other Client Delegates. */\r
     if (((rmInst->instType == Rm_instType_SERVER) &&\r
          (transportCfg->remoteInstType == Rm_instType_SERVER)) ||\r
         ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
-         (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)))\r
-    {\r
-        goto exitCs; /* Error - return null */\r
+         (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE))) {\r
+        *result = -500;\r
+        return(NULL);\r
     }\r
 \r
     /* Verify Clients are not registering with more than one Client Delegate or Server. And\r
-     * that Client Delegate are not registering with more than one Server. */\r
+     * that Client Delegate is not registering with more than one Server. */\r
     if (rmInst->registeredWithDelegateOrServer &&\r
         (((rmInst->instType == Rm_instType_CLIENT) &&\r
           (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
          ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
-          (transportCfg->remoteInstType == Rm_instType_SERVER))))\r
-    {\r
-        goto exitCs; /* Error - return null */\r
+          (transportCfg->remoteInstType == Rm_instType_SERVER)))) {\r
+        *result = -501;\r
+        return(NULL);\r
     }         \r
 \r
-    /* Copy the transport callout function pointers into the RM instance as long as they're\r
-     * valid or not NULL */\r
-    if (transportCfg->transportCalloutsValid)\r
-    {\r
-        /* The transport APIs must not be NULL */\r
-        if ((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
-        {\r
-            goto exitCs; /* Error - return null */\r
-        }\r
-            \r
-        /* Populate the instance transport callouts */\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
+        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
     }\r
+    transport = transportAdd(transportCfg);\r
 \r
-    /* Error checks passed - Create a new transport handle for the specified RM instance and\r
-     * create a new node in the RM instance's routing map. */\r
-    transportNode = Rm_transportNodeAdd(rmInst, transportCfg);\r
-\r
-    /* Specify RM instance has registered with a higher level agent */\r
-    if ((transportNode->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
-        (transportNode->remoteInstType == Rm_instType_SERVER))\r
-    {\r
+    if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
+        (transport->remoteInstType == Rm_instType_SERVER)) {\r
         rmInst->registeredWithDelegateOrServer = true;\r
     }\r
 \r
-exitCs:\r
-    \r
-    Rm_osalMtCsExit(key);\r
-    return ((Rm_TransportHandle) transportNode);\r
+    *result = 0; /* TEMP */\r
+    return ((Rm_TransportHandle) transport);\r
 }\r
 \r
 Rm_TransportResult Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandle transportHandle)\r
 {\r
-    Rm_Inst *rmInst = (Rm_Inst *) rmHandle;\r
-    Rm_TransportNode *transportNode = NULL;\r
-    Rm_TransportResult retVal = RM_TRANSPORT_SUCCESSFUL;\r
-    void *key;\r
-\r
-    /* Lock access to the RM instance */\r
-    key = Rm_osalMtCsEnter();    \r
+    Rm_Inst            *rmInst = (Rm_Inst *) rmHandle;\r
+    Rm_Transport       *transport = transportFindTransportHandle((Rm_Transport *)rmInst->transports, \r
+                                                                 transportHandle);\r
+    Rm_TransportResult  retVal = RM_TRANSPORT_SUCCESSFUL;  \r
 \r
-    /* Check if the transportHandle exists in the RM instance's route map */\r
-    transportNode = Rm_transportNodeFindTransportHandle(rmInst, transportHandle);\r
-\r
-    if (transportNode == NULL)\r
-    {\r
-        /* Error - transport node does not exist in RM instance route map */\r
+    if (transport == NULL) {\r
         retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
     }\r
-    else\r
-    {\r
-\r
-        /* Remove specification that RM instance has been connected to an upper level agent\r
-         * if the node to be deleted has a remote instance type of Client Delegate or Server */\r
-        if ((transportNode->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
-            (transportNode->remoteInstType == Rm_instType_SERVER))\r
-        {\r
+    else {\r
+        if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
+            (transport->remoteInstType == Rm_instType_SERVER)) {\r
             rmInst->registeredWithDelegateOrServer = false;\r
         }\r
-\r
-        /* Delete the transport node */\r
-        retVal = Rm_transportNodeDelete(rmInst, transportHandle);\r
+        retVal = transportDelete(rmHandle, transportHandle);\r
     }\r
 \r
-    Rm_osalMtCsExit(key);\r
     return (retVal);\r
 }\r
 \r
@@ -520,85 +355,57 @@ Rm_TransportResult Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandl
  * AS PART OF AN ISR HANDLER FOR THE TRANSACTION RECEIVE */\r
 int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)\r
 {\r\r\r
-    Rm_Inst *rmInst = (Rm_Inst *)((Rm_TransportNode *)transportHandle)->rmHandle;\r
+    Rm_Inst        *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle;\r
     Rm_Transaction *transaction;\r
 \r
-    /* Make sure the transport handle is registered with the provided RM instance */\r
-    if (Rm_transportNodeFindTransportHandle(rmInst, transportHandle) == NULL)\r
-    {\r
-        /* Transport is not registered with the RM instance.  Return an error.\r
-         * The packet cannot be freed since the transport handle is not valid. */\r
+    if (transportFindTransportHandle((Rm_Transport *)rmInst->transports, transportHandle) == NULL) {\r
         return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
     }\r
 \r
-    /* Based on packet type transfer the data to a transaction or a policy structure */\r
-    switch (pkt->pktType)\r
-    {\r
+    switch (pkt->pktType) {\r
         case Rm_pktType_RESOURCE_REQUEST:\r
         {\r
             Rm_ResourceRequestPkt *resourceReqPkt = (Rm_ResourceRequestPkt *)pkt->data;\r
 \r
-            /* Create the request transaction filling in the remoteOriginatingId using\r
-             * the request packet's ID.  The request packet's ID will map to the \r
-             * the request transaction that issued the request packet. */\r
-            transaction = Rm_transactionQueueAdd(rmInst);\r
+            transaction = rmTransactionQueueAdd(rmInst);\r
             transaction->remoteOriginatingId = resourceReqPkt->requestId;\r
-\r
-            /* Transfer the rest of the data into the transaction */\r
-            if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_INIT)\r
-            {\r
+            if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_INIT) {\r
                 transaction->type = Rm_service_RESOURCE_ALLOCATE_INIT;\r
             }\r
-            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_USE)\r
-            {\r
+            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_USE) {\r
                 transaction->type = Rm_service_RESOURCE_ALLOCATE_USE;\r
             }            \r
-            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_FREE)\r
-            {\r
+            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_FREE) {\r
                 transaction->type = Rm_service_RESOURCE_FREE;\r
             }\r
-            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_NAMED)\r
-            {\r
+            else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_NAMED) {\r
                 transaction->type = Rm_service_RESOURCE_GET_BY_NAME;\r
             }            \r
-\r
-            strcpy(transaction->pktSrcInstName, resourceReqPkt->pktSrcInstName);\r
-            strcpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName);\r
+            strncpy(transaction->pktSrcInstName, resourceReqPkt->pktSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
+            strncpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
             transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));\r
-\r
-            /* Process the transaction */\r
-            Rm_transactionProcessor(rmInst, transaction);\r
+            rmTransactionProcessor(rmInst, transaction);\r
             break;\r
         }\r
         case Rm_pktType_RESOURCE_RESPONSE:\r
         {\r
             Rm_ResourceResponsePkt *resourceRespPkt = (Rm_ResourceResponsePkt *)pkt->data;\r
 \r
-            /* Find the transaction that is awaiting the response */\r
-            if (transaction = Rm_transactionQueueFind(rmInst,resourceRespPkt->responseId))\r
-            {\r
-                /* Transfer the result of the request to the transaction */\r
+            if (transaction = rmTransactionQueueFind(rmInst,resourceRespPkt->responseId)) {\r
                 transaction->state = resourceRespPkt->requestState;\r
 \r
                 if ((transaction->state == RM_SERVICE_APPROVED_AND_COMPLETED) &&\r
                     ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
                      (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
-                     (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))\r
-                {\r
-                    /* Copy resources from request for allocations since an allocation\r
-                     * can be specified as unknown.  If the request resources were unspecified\r
-                     * the RM instance will specify the resources obtained */\r
+                     (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {\r
                     memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
                             sizeof(Rm_ResourceInfo));\r
                 }\r
-                \r
-                /* Process the transaction */\r
-                Rm_transactionProcessor(rmInst, transaction);\r
+                rmTransactionProcessor(rmInst, transaction);\r
             }\r
-            else\r
-            {\r
+            else {\r
                 rmInst->transport.rmFreePkt(transportHandle, pkt);\r
                 return (RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND);\r
             }\r
@@ -608,43 +415,33 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
         {\r
             Rm_NsRequestPkt *nsRequestPkt = (Rm_NsRequestPkt *)pkt->data;\r
 \r
-            transaction = Rm_transactionQueueAdd(rmInst);\r
+            transaction = rmTransactionQueueAdd(rmInst);\r
             transaction->remoteOriginatingId = nsRequestPkt->requestId;\r
 \r
-            if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_MAP_RESOURCE)\r
-            {\r
+            if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_MAP_RESOURCE) {\r
                 transaction->type = Rm_service_RESOURCE_MAP_TO_NAME;\r
             }\r
-            else if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_UNMAP_RESOURCE)\r
-            {\r
+            else if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_UNMAP_RESOURCE) {\r
                 transaction->type = Rm_service_RESOURCE_UNMAP_NAME;\r
             }\r
 \r
-            strcpy(transaction->pktSrcInstName, nsRequestPkt->pktSrcInstName);\r
-            strcpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName);\r
+            strncpy(transaction->pktSrcInstName, nsRequestPkt->pktSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
+            strncpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName, RM_INSTANCE_NAME_MAX_CHARS);\r
             transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(nsRequestPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));\r
-\r
-            /* Process the transaction */\r
-            Rm_transactionProcessor(rmInst, transaction);            \r
+            rmTransactionProcessor(rmInst, transaction);            \r
             break;\r
         }\r
         case Rm_pktType_NAMESERVER_RESPONSE:\r
         {\r
             Rm_NsResponsePkt *nsResponsePkt = (Rm_NsResponsePkt *)pkt->data;\r
 \r
-            /* Find the transaction that is awaiting the response */\r
-            if (transaction = Rm_transactionQueueFind(rmInst, nsResponsePkt->responseId))\r
-            {\r
-                /* Transfer the state of the request to the transaction */\r
+            if (transaction = rmTransactionQueueFind(rmInst, nsResponsePkt->responseId)) {\r
                 transaction->state = nsResponsePkt->requestState;            \r
-\r
-                /* Process the transaction */\r
-                Rm_transactionProcessor(rmInst, transaction);\r
+                rmTransactionProcessor(rmInst, transaction);\r
             }\r
-            else\r
-            {\r
+            else {\r
                 rmInst->transport.rmFreePkt(transportHandle, pkt);\r
                 return (RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND);\r
             }\r
@@ -654,21 +451,21 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
         {\r
             Rm_PolicyRequestPkt *policyRequestPkt = (Rm_PolicyRequestPkt *)pkt->data;\r
 \r
-            /* FILL IN POLICY API INFORMATION */\r
+            /* TODO: FILL IN POLICY API INFORMATION */\r
             break;  \r
         }\r
         case Rm_pktType_POLICY_CHANGE:\r
         {\r
             Rm_PolicyChangePkt *policyChangePkt = (Rm_PolicyChangePkt *)pkt->data;\r
 \r
-            /* FILL IN POLICY API INFORMATION */\r
+            /* TODO: FILL IN POLICY API INFORMATION */\r
             break;\r
         }\r
         case Rm_pktType_RESOURCE_POOL_MODIFICATION_REQUEST:\r
         {\r
             Rm_ResourcePoolModRequestPkt *resPoolModReqPkt = (Rm_ResourcePoolModRequestPkt *)pkt->data;\r
 \r
-            /* FILL IN RESOURCE POOL MODIFICATION API */\r
+            /* TODO: FILL IN RESOURCE POOL MODIFICATION API */\r
             /* Rm_resourcePoolModRequestHandler(...); Server only - needs to allocate resources to\r
              * the Client Delegate based on the policy and return those resources to the Client Delegate */\r
             break;\r
@@ -677,19 +474,17 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
         {\r
             Rm_ResourcePoolModResponsePkt *resPoolModRespPkt = (Rm_ResourcePoolModResponsePkt *)pkt->data;\r
 \r
-            /* FILL IN RESOURCE POOL MODIFICAITON API */\r
+            /* TODO: FILL IN RESOURCE POOL MODIFICAITON API */\r
             /* Rm_resourcePoolModResponseHandler(...);  Handler needs to populate allocator with\r
              * new resources provided in the response and then handle any request transactions waiting on\r
              * the resource pool modification */\r
             break;\r
         }\r
         default:\r
-            /* Invalid packet type.  Free the packet and return */\r
             rmInst->transport.rmFreePkt(transportHandle, pkt);\r
             return (RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE);\r
       }\r
 \r
-    /* Free the packet after it has been processed */\r
     rmInst->transport.rmFreePkt(transportHandle, pkt);\r
     return (RM_TRANSPORT_SUCCESSFUL);\r
 }\r
@@ -698,36 +493,26 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt)
  * the RM handle and transport handle provided */\r
 int32_t Rm_receivePktPolling(Rm_TransportHandle transportHandle)\r
 {\r
-    Rm_Inst *rmInst = (Rm_Inst *)((Rm_TransportNode *)transportHandle)->rmHandle;\r
+    Rm_Inst   *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle;\r
     Rm_Packet *pkt = NULL;\r
-    int32_t retVal = RM_TRANSPORT_OK_BASE;\r
+    int32_t    retVal = RM_TRANSPORT_OK_BASE;\r
 \r
-    /* Make sure the transport handle is registered with the provided RM instance */\r
-    if (Rm_transportNodeFindTransportHandle(rmInst, transportHandle) != NULL)\r
-    {\r
-        /* Check to see if any RM packets are available.  Process any available packets. */\r
-        while (rmInst->transport.rmNumPktsReceived(transportHandle) > 0)\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
-            {\r
+            if (pkt == NULL) {\r
                 retVal = RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR;\r
                 break;\r
             }\r
 \r
-            /* Pass the packet to RM.  The packet will be freed within the PktIsr API */\r
-            if (retVal = Rm_receivePktIsr(transportHandle, pkt) <= RM_SERVICE_ERROR_BASE)\r
-            {\r
-                /* Return if an error is encountered */\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
-    {\r
-        /* Transport is not registered with the RM instance.  Return an error.\r
-         * The packet cannot be freed since the transport handle is not valid. */\r
+    else {\r
         retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
     }\r
 \r
diff --git a/src/rm_tree.c b/src/rm_tree.c
new file mode 100644 (file)
index 0000000..cab252e
--- /dev/null
@@ -0,0 +1,169 @@
+/**
+ *   @file  rm_tree.c
+ *
+ *   @brief   
+ *      Resource Manager Tree Manipulation Source.
+ *
+ *  \par
+ *  ============================================================================
+ *  @n   (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    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.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  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.
+ *
+ *  \par
+*/
+
+/* RM Types */
+#include <ti/drv/rm/rm_types.h>
+
+/* RM internal API includes */
+#include <ti/drv/rm/include/rm_treeloc.h>
+
+/* RM OSAL layer */
+#include <rm_osal.h>
+
+/**********************************************************************
+ ********************* NameServer Tree Functions **********************
+ **********************************************************************/
+
+Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg)
+{
+    Rm_NameServerNode *newNode = NULL;
+
+    newNode = Rm_osalMalloc(sizeof(Rm_NameServerNode));
+    if (newNode) {
+        strncpy(newNode->objName, nodeCfg->objName, RM_RESOURCE_NAME_MAX_CHARS);
+        strncpy(newNode->resourceName, nodeCfg->resourceName, RM_RESOURCE_NAME_MAX_CHARS); 
+        newNode->resourceBase = nodeCfg->resourceBase;
+        newNode->resourceLength = nodeCfg->resourceLength;
+    }
+    
+    return(newNode);
+}
+
+void nameServerNodeFree(Rm_NameServerNode *node)
+{
+    if (node) {
+        Rm_osalFree((void *)node, sizeof(Rm_NameServerNode));
+    }
+}
+
+/* Prototype for NameServer node comparison function
+ * node1 < node2 --> return < 0
+ * node1 = node2 --> return 0
+ * node1 > node2 --> return > 0 */
+int nameServerNodeCompare(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);
+
+/**********************************************************************
+ *************** Policy Valid Instance Tree Functions *****************
+ **********************************************************************/
+Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName)
+{
+    Rm_PolicyValidInstNode *newNode = NULL;
+
+    newNode = Rm_osalMalloc(sizeof(Rm_PolicyValidInstNode));
+    
+    strncpy(newNode->name, instName, RM_INSTANCE_NAME_MAX_CHARS);
+    newNode->allocRefCount = 0;
+    newNode->deletePending = FALSE;
+    
+    return(newNode);
+}
+
+void policyValidInstNodeFree(Rm_PolicyValidInstNode *node)
+{
+    if (node->allocRefCount == 0) {
+        Rm_osalFree((void *)node, sizeof(Rm_PolicyValidInstNode));
+    }
+}
+
+int policyValidInstNodeCompare(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);
+
+/**********************************************************************
+ ***************** Allocator Resource Tree Functions ******************
+ **********************************************************************/
+
+Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength)
+{
+    Rm_ResourceNode *newNode = NULL;
+
+    newNode = Rm_osalMalloc(sizeof(Rm_ResourceNode));
+    memset((void *)newNode, 0, sizeof(Rm_ResourceNode));
+
+    newNode->base = resourceBase;
+    newNode->length = resourceLength;
+    newNode->allocationCount = 0;
+    newNode->ownerList = NULL;
+
+    return(newNode);
+}
+
+void resourceNodeFree(Rm_ResourceNode *node)
+{
+    if (node->allocationCount == 0) {
+        Rm_osalFree((void *)node, sizeof(Rm_ResourceNode));
+    }
+}
+
+int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
+{
+    uint32_t node1End = node1->base + node1->length - 1;
+    uint32_t node2End = node2->base + node2->length - 1;
+
+    if (node1End < node2->base) {
+        /* End of node1 range is less than the start of node2's range.  Return a negative
+         * value */
+        return (-1);
+    }
+    else if (node1->base > node2End) {
+        /* Start of node1 range is after end of node2's range.  Return a positive value */
+        return (1);
+    }
+    else {
+        /* If neither of the latter conditions were satisfied there is some overlap between
+         * node1 and node2.  Return 0 since the application must handle this overlap. */
+        return (0);
+    }
+}
+
+/* Generate the red-black tree manipulation functions */
+RB_GENERATE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, resourceNodeCompare);
+
index cc89fcb4915d074e6df2724670d96c7776802672..746dd8d72e1ff3cb751b09980fbae09a82bbb4d4 100644 (file)
@@ -529,7 +529,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -548,7 +548,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -567,7 +567,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -589,7 +589,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s creating NameServer object...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
@@ -618,7 +618,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Trying to reserve memory region taken by Linux...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
@@ -637,7 +637,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -654,7 +654,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -678,7 +678,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -698,7 +698,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -718,7 +718,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -738,7 +738,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -755,7 +755,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
-        rmServerServicePort->rmService(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmServerServicePort->Rm_serviceHandler(rmServerServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -787,7 +787,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         
         System_printf("Core %d: %s getting resources tied to NameServer object...\n", MultiProc_self(), 
                                                                                       rmClientDelegateName);
-        rmClientDelegateServicePort->rmService(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientDelegateServicePort->Rm_serviceHandler(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s got Name: %s base: %d length: %d\n", MultiProc_self(),
@@ -806,7 +806,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s allocating resources...\n", MultiProc_self(), rmClientName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resources: %s base: %d length: %d\n", MultiProc_self(),
@@ -829,7 +829,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s freeing resource via name...\n", MultiProc_self(), rmClientName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
@@ -846,7 +846,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         System_printf("Core %d: %s Deleting NameServer object: %s...\n", MultiProc_self(), 
                                                                          rmClientName,
                                                                          resourceNsName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
@@ -869,7 +869,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -887,7 +887,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
-        rmClientDelegateServicePort->rmService(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientDelegateServicePort->Rm_serviceHandler(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -912,7 +912,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
-        rmClientDelegateServicePort->rmService(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientDelegateServicePort->Rm_serviceHandler(rmClientDelegateServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -931,7 +931,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -950,7 +950,7 @@ void testRmTsk(UArg arg0, UArg arg1)
         requestInfo.callback.serviceCallback = testServiceCallback;
         
         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
-        rmClientServicePort->rmService(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
+        rmClientServicePort->Rm_serviceHandler(rmClientServicePort->rmHandle, &requestInfo, &responseInfo);
         if (blockForResponse(&responseInfo))
         {
             System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
@@ -984,6 +984,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
     HeapBufMP_Handle msgQHeapHandle;
     HeapBufMP_Params heapBufParams;
     Rm_TransportCfg rmTransportCfg;
+    int32_t result = 0;
     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
     Task_Params taskParams;
 
@@ -1127,6 +1128,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         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;
@@ -1134,7 +1136,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
         rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
 
-        serverCdHandle = Rm_transportRegister(rmServerHandle, &rmTransportCfg);
+        serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
@@ -1164,6 +1166,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         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;
@@ -1171,7 +1174,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
         rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
 
-        cdServerHandle = Rm_transportRegister(rmClientDelegateHandle, &rmTransportCfg);
+        cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
@@ -1200,7 +1203,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         /* Callouts already set on the Client Delegate so set them as invalid */
         rmTransportCfg.transportCalloutsValid = false;
 
-        cdClientHandle = Rm_transportRegister(rmClientDelegateHandle, &rmTransportCfg);
+        cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
@@ -1227,6 +1230,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         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;
@@ -1234,7 +1238,7 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.transportCallouts.rmReceive = TransportReceive;        
         rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; 
 
-        clientCdHandle = Rm_transportRegister(rmClientHandle, &rmTransportCfg);
+        clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;