Added pre-main capabilities, cleaned up services and NameServer modules
authorJustin Sobota <jsobota@ti.com>
Tue, 22 Jan 2013 23:32:01 +0000 (18:32 -0500)
committerJustin Sobota <jsobota@ti.com>
Tue, 22 Jan 2013 23:32:01 +0000 (18:32 -0500)
15 files changed:
device/tci6614-cd-startup-policy.dtb [new file with mode: 0644]
device/tci6614-cd-startup-policy.dts [new file with mode: 0644]
device/tci6614-server-policy.dtb
device/tci6614-server-policy.dts
include/rm_loc.h
include/rm_nameserverloc.h
include/rm_policyloc.h
include/rm_servicesloc.h
rm.h
rm_services.h
src/rm.c
src/rm_nameserver.c
src/rm_policy.c
src/rm_services.c
src/rm_transport.c

diff --git a/device/tci6614-cd-startup-policy.dtb b/device/tci6614-cd-startup-policy.dtb
new file mode 100644 (file)
index 0000000..51a363f
Binary files /dev/null and b/device/tci6614-cd-startup-policy.dtb differ
diff --git a/device/tci6614-cd-startup-policy.dts b/device/tci6614-cd-startup-policy.dts
new file mode 100644 (file)
index 0000000..77f82f3
--- /dev/null
@@ -0,0 +1,19 @@
+/dts-v1/;
+
+/* RM CD pre-main startup policy for BIOS/IPC startup resources */
+
+/ {
+       /* All RM instances expected to request resources prior to main in the startup functions */
+       valid-instances = "RM_Client_Delegate",
+                         "RM_Client";
+
+    /* Assign pre-main resources */
+    timers {
+               assignments = <0 1>, "iux = (RM_Client_Delegate)",
+                             <1 1>, "iux = (RM_Client)";
+    };
+    semaphores {
+               assignments = <0 1>, "iu  = (RM_Client_Delegate RM_Client)";
+    };
+};
+
index b2ca53856b6682193bd699af69d7a526777184f5..feff2fd992723f1ffe4105fcacf69fd5b131aad6 100644 (file)
Binary files a/device/tci6614-server-policy.dtb and b/device/tci6614-server-policy.dtb differ
index 6ad3b8989e1e717d5892522eeffab47ace67c136..6b57763c57c506ddc97c7ff8508da9d5b17a1bf7 100644 (file)
@@ -26,7 +26,8 @@
             assignments = <0x00000000 0xFFFFFFFF>, "iux = (*)";
         };
         accumulator-ch {
-            assignments = <0 48>, "iux = (*)";           
+            assignments = <0 48>, "iux = (*)";
+            alloc-alignments = <20>;
         };
         qos-cluster {
                        assignments = <0 8>, "iux = (*)";
index 5806800691c46278ab838e97c519974c3e896f6e..a5d65739b8a862953a49e37d60736137f221f52a 100644 (file)
@@ -48,6 +48,11 @@ extern "C" {
 #include <ti/drv/rm/rm_services.h>
 #include <ti/drv/rm/rm_transport.h>
 
+/* RM internal includes */
+#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>
 
@@ -61,19 +66,6 @@ typedef void *Rm_TransportRouteMap;
 /** Pointer to RM instance's transaction queue */
 typedef void *Rm_TransactionQueue;
 
-/** Pointer to the RM instance's allocators */
-typedef void *Rm_Allocators;
-
-/** Pointer to the RM instance's NameServer (Valid only on Server) */
-typedef void *Rm_NameServer;
-
-/** Pointer to the RM instance's policy information */
-typedef void *Rm_Policy;
-
-/** Pointer to the RM instance's valid policy instances */
-typedef void *Rm_PolicyValidInstances;
-
-
 /**
  * @brief RM protocol packet resource information
  */
@@ -89,7 +81,7 @@ typedef struct {
     int32_t  alignment;
     /** If applicable, the NameServer name assigned to the specified
      *  resource.  Used for commands centering on RM NameServer actions */
-    char     nsName[RM_RESOURCE_NAME_MAX_CHARS];
+    char     nameServerName[RM_RESOURCE_NAME_MAX_CHARS];
 } Rm_ResourceInfo;
 
 /**
@@ -142,7 +134,7 @@ typedef enum {
 } Rm_AllocatorOp;
 
 typedef struct {
-    void            *serviceSrcInstNode;
+    Rm_PolicyValidInstNode *serviceSrcInstNode;
     Rm_AllocatorOp   operation;
     uint32_t         allocType;
     Rm_ResourceInfo *resourceInfo;
@@ -156,23 +148,32 @@ typedef struct Rm_Allocator_s {
     struct Rm_Allocator_s *nextAllocator;
 } Rm_Allocator;
 
+
+typedef struct {
+    char                    instName[RM_INSTANCE_NAME_MAX_CHARS];
+    void                   *startupDtb;
+    Rm_PolicyValidInstTree *validInstTree;
+    uint32_t                requestCount;
+    Rm_ServicePreMainReq   *preMainReqList;
+} Rm_PreMainInst;
+
 typedef struct {
-    char name[RM_INSTANCE_NAME_MAX_CHARS];
-    Rm_InstType instType;
-    bool registeredWithDelegateOrServer;
-    Rm_Policy policy;
-    Rm_PolicyValidInstances validInstances;    
-    Rm_Allocatorallocators;
-    Rm_NameServer nameServer;
+    char                    instName[RM_INSTANCE_NAME_MAX_CHARS];
+    Rm_InstType             instType;
+    bool                    registeredWithDelegateOrServer;
+    void                   *policy;
+    Rm_PolicyValidInstTree *validInstances;    
+    Rm_Allocator           *allocators;
+    Rm_NameServerTree      *nameServer;
     /* RM instance transport parameters */
-    Rm_TransportRouteMap routeMap;
+    Rm_TransportRouteMap    routeMap;
     /* RM Transaction sequence number counter */
-    uint32_t transactionSeqNum;
+    uint32_t                transactionSeqNum;
     /* RM transaction queue */
-    Rm_TransactionQueue transactionQueue;
+    Rm_TransactionQueue     transactionQueue;
     /* Transport API function pointers - not global in case application wants to
       * hook up different transports to RM */
-    Rm_TransportCallouts transport;
+    Rm_TransportCallouts    transport;
 } Rm_Inst;
 
 Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst);
@@ -180,7 +181,7 @@ 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_Inst *rmInst, char *resourceName);
+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);
@@ -192,7 +193,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
 
 /* Declare the tree structure nodes */
 typedef struct Rm_AllocatedTo_s {
-    void                    *instNameNode;
+    Rm_PolicyValidInstNode  *instNameNode;
     struct Rm_AllocatedTo_s *nextAllocatedTo;
 } Rm_AllocatedTo;
 
index 9dda45653e10d504ce083aae7c56be50cb9eba76..a45d0501bbaa6021a43cfbf45bf99ebb799049ae 100644 (file)
@@ -48,45 +48,57 @@ extern "C" {
 #include <ti/drv/rm/rm.h>
 #include <ti/drv/rm/rm_services.h>
 
-/* RM internal includes */
-#include <ti/drv/rm/include/rm_loc.h>
-
 /* AVL BBST includes */
 #include <ti/drv/rm/include/tree.h>
 
-void Rm_nsInit(Rm_Inst *rmInst);
-int32_t Rm_nsAddObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
-void Rm_nsPrintObjects(Rm_Inst *rmInst);
-int32_t Rm_nsFindObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
-int32_t Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
+typedef struct {
+    char     *objName;
+    char     *resourceName;
+    uint32_t  resourceBase;
+    uint32_t  resourceLength;
+} Rm_NameServerNodeCfg;
 
 /**********************************************************************
- ******************* Red-Black Tree BBST Defines **********************
+ ******************** NameServer Tree Definitions *********************
  **********************************************************************/
 
 /* Declare the tree structure nodes */
 typedef struct _Rm_NameServerNode {
     RB_ENTRY(_Rm_NameServerNode) linkage;
-    char name[RM_RESOURCE_NAME_MAX_CHARS];
+    char objName[RM_RESOURCE_NAME_MAX_CHARS];
     char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
-    uint32_t base;
-    uint32_t length;
+    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_newNameServerNode(char *name, char *resourceName,
-                                        uint32_t resourceBase, uint32_t resourceLength);
-void Rm_freeNameServerNode(Rm_NameServerNode *node);
+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 *element1, Rm_NameServerNode *element2); 
+int Rm_nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); 
 
 /* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_NameServerNodeCompare);
+RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_nameServerNodeCompare);
+
+/**********************************************************************
+ ********************* Internal NameServer APIs ***********************
+ **********************************************************************/
+
+typedef struct {
+    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);
 
 #ifdef __cplusplus
 }
index a81e97675ccd6e9c3f5ee4e9f2ef82bfcad430b5..1d439057fafedc2f4ab3a8dd01f2eb02fded0109 100644 (file)
@@ -47,9 +47,6 @@ extern "C" {
 /* RM external API includes */
 #include <ti/drv/rm/rm_policy.h>
 
-/* RM internal API includes */
-#include <ti/drv/rm/include/rm_loc.h>
-
 /* AVL BBST includes */
 #include <ti/drv/rm/include/tree.h>
 
@@ -70,7 +67,7 @@ extern "C" {
  *                           allocated by the specified RM instances
  *  4 - 15 : UNUSED
  */
-typedef uint16_t Rm_PermissionBits;
+typedef uint16_t Rm_PolicyPermBits;
 
 #define RM_POLICY_PERM_INIT_LOWER         'i'
 #define RM_POLICY_PERM_INIT_UPPER         'I'
@@ -90,82 +87,76 @@ typedef uint16_t Rm_PermissionBits;
 #define RM_POLICY_PERM_TERMINATOR         '&'
 #define RM_POLICY_PERM_ASSIGNMENT         '='
 
-#define RM_POLICY_SET_PERM(permBits, permTypeShift, val) \
-    permBits = ((permBits & (~(((Rm_PermissionBits) 0x1) << permTypeShift))) | \
-               ((((Rm_PermissionBits) val) & 0x1) << permTypeShift))
-#define RM_POLICY_GET_PERM(permBits, permTypeShift) \
+#define RM_policy_SET_PERM(permBits, permTypeShift, val) \
+    permBits = ((permBits & (~(((Rm_PolicyPermBits) 0x1) << permTypeShift))) | \
+               ((((Rm_PolicyPermBits) val) & 0x1) << permTypeShift))
+#define RM_policy_GET_PERM(permBits, permTypeShift) \
     ((permBits >> permTypeShift) & 0x1)
 
 typedef struct Rm_Permission_s {
     char                    instName[RM_INSTANCE_NAME_MAX_CHARS];
-    Rm_PermissionBits       permissionBits;
+    Rm_PolicyPermBits       permissionBits;
     struct Rm_Permission_s *nextPermission;
 } Rm_PolicyPermission;
 
-typedef struct {
-    const void *assignmentData;
-    int32_t     assignmentLen;
-    const void *allocationSizeData;
-    int32_t     allocationSizeLen;
-    const void *alignmentData;
-    int32_t     alignmentLen;
-} Rm_PolicyNodeProperties;
-
-typedef enum {
-    Rm_policyCheck_EXCLUSIVE = 0,
-    Rm_policyCheck_INIT,
-    Rm_policyCheck_USE
-} Rm_PolicyCheckType;
-
-typedef struct {
-    Rm_PolicyCheckType  type;
-    void               *policyDtb;
-    void               *validInstNode;
-    int32_t             resourcePolicy;
-    uint32_t            resourceBase;
-    uint32_t            resourceLength;
-} Rm_PolicyCheckCfg;
-
-void     Rm_policyIncrementValidInstAllocationCount(void *validInstNameNode);
-void     Rm_policyDecrementValidInstAllocationCount(void *validInstNameNode);
-void    *Rm_policyGetValidInstNode(void *validInstTree, char *instName);
-char    *Rm_policyGetValidInstNodeName(void *validInstNode);
-bool     Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result);
-uint32_t Rm_policyGetResourceBase(void *policyDtb, void *validInstNode, 
-                                  int32_t resourcePolicy, uint32_t allocType, 
-                                  int32_t *result);
-uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourcePolicy);
-int32_t  Rm_policyGetResourcePolicy(void *policyDtb, char *resourceName);
-void    *Rm_policyGetLinuxInstNode(void *validInstTree);
-int32_t  Rm_policyValidatePolicyResourceNames(Rm_Inst *rmInst, void *policyDtb);
-int32_t  Rm_policyValidatePolicy(Rm_Inst *rmInst, void *policyDtb);
-void    *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result);
-
 /**********************************************************************
- ******************* Red-Black Tree BBST Defines **********************
+ ************** Policy Valid Instance Tree Definitions ****************
  **********************************************************************/
 
 /* Declare the tree structure nodes */
-typedef struct _Rm_ValidInstNode {
-    RB_ENTRY(_Rm_ValidInstNode) linkage;
+typedef struct _Rm_PolicyValidInstNode {
+    RB_ENTRY(_Rm_PolicyValidInstNode) linkage;
     char                        name[RM_INSTANCE_NAME_MAX_CHARS];
     uint32_t                    allocRefCount;
     bool                        deletePending;
-} Rm_ValidInstNode;
+} Rm_PolicyValidInstNode;
 
 /* Declare the tree head structure. */
-typedef RB_HEAD(_Rm_ValidInstTree, _Rm_ValidInstNode) Rm_ValidInstTree;
+typedef RB_HEAD(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode) Rm_PolicyValidInstTree;
 
-Rm_ValidInstNode *Rm_newValidInstNode(char *instName);
-void Rm_freeValidInstNode(Rm_ValidInstNode *node);
+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_ValidInstNodeCompare(Rm_ValidInstNode *element1, Rm_ValidInstNode *element2); 
+int Rm_policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); 
 
 /* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_ValidInstTree, _Rm_ValidInstNode, linkage, Rm_ValidInstNodeCompare);
+RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode,
+             linkage, Rm_policyValidInstNodeCompare);
+
+/**********************************************************************
+ *********************** Internal Policy APIs *************************
+ **********************************************************************/
+
+typedef enum {
+    Rm_policyCheck_EXCLUSIVE = 0,
+    Rm_policyCheck_INIT,
+    Rm_policyCheck_USE
+} Rm_PolicyCheckType;
+
+typedef struct {
+    Rm_PolicyCheckType      type;
+    void                   *policyDtb;
+    Rm_PolicyValidInstNode *validInstNode;
+    int32_t                 resourceOffset;
+    uint32_t                resourceBase;
+    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, 
+                                  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);
 
 #ifdef __cplusplus
 }
index f1317ae75367e400a62a35a9eb0ba96690227cd5..8195ebd6be16194c2caad99203c10aafe253b706 100644 (file)
  *  \par
 */
 
-#ifndef RMSERVICESLOC_H_
-#define RMSERVICESLOC_H_
+#ifndef RM_SERVICESLOC_H_
+#define RM_SERVICESLOC_H_
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* RM external includes */
-#include <ti/drv/rm/rm.h>
-
-/* RM internal includes */
-#include <ti/drv/rm/include/rm_loc.h>
-
-
-/* This function is executed when a RM instance receives a response to one of its requests
- * and the information in the request must be provided to the original requesting component */
-void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
+#include <ti/drv/rm/rm_services.h>
 
+typedef struct Rm_ServicePreMainReq_s {
+    Rm_ServiceReqInfo *preMainReq;
+    struct Rm_ServicePreMainReq_s *nextPreMainReq;
+} Rm_ServicePreMainReq;
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* RMSERVICESLOC_H_ */
+#endif /* RM_SERVICESLOC_H_ */
 
diff --git a/rm.h b/rm.h
index c8967039fda9053cdb0f8883ee83bc3bf168fc4f..8ccbeadf00a328a8701372fc5851f8c7fa6e7aa4 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -149,6 +149,9 @@ extern "C" {
 #define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INVALID_PERM_CHAR -263
 #define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_PERM_CHAR_WITHOUT_ASSIGN_CHAR -264
 #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
+
+
 
 /** 
  * @brief Maximum number of characters in a RM instance name
@@ -162,6 +165,8 @@ extern "C" {
  */
 typedef void *Rm_Handle;
 
+typedef void *Rm_PreMainHandle;
+
 /** 
  * @brief RM Instance types
  */
@@ -174,6 +179,12 @@ typedef enum {
     Rm_instType_CLIENT = 2
 } Rm_InstType;
 
+typedef struct {
+    char        *instName;
+    Rm_InstType  instType;
+    void        *startupPolicyDtb;
+} Rm_PreMainInitCfg;
+
 /** 
  * @brief RM instance initialization structure
  */
@@ -223,6 +234,14 @@ typedef struct {
 /* TESTING PURPOSES: SERVER ONLY */
 void Rm_printResourceStatus(Rm_Handle *rmHandle);
 
+Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *result);
+/** [Server/Client Delegate Parameter] Pre-main allocation handle used to
+ *  by application to request resources prior to main via the startup policy
+ *  The preMainHandle will be used to validate the resources allocated prior
+ *  to main
+ */
+int32_t Rm_preMainHandleValidateAndDelete(Rm_Handle rmHandle, Rm_PreMainHandle rmPreMainHandle);
+
 /**
  *  @b Description
  *  @n  
index 2013a662e0898fec77a65a354702334d99214214..a4c4ce91077ab0cc9c6b9c3c4b3636dd10955bf3 100644 (file)
@@ -122,8 +122,12 @@ extern "C" {
 /** The resource couldn't be allocated because it was already allocated to an instance with exclusive
  *  privileges for the resource */
 #define RM_SERVICE_DENIED_RESOURCE_ALLOCATED_TO_INSTANCE_WITH_EXCLUSIVE_PRIV (RM_SERVICE_DENIED_BEGIN+21)
+/** Pre main request was not an allocate use or allocate init request */
+#define RM_SERVICE_DENIED_INVALID_PREMAIN_REQUEST (RM_SERVICE_DENIED_BEGIN+22)
+/** Startup policy denied pre-main allocation request */
+#define RM_SERVICE_DENIED_POLICY_DENIED_PREMAIN_ALLOCATION (RM_SERVICE_DENIED_BEGIN+23)
 /** End of resource denied reasons */
-#define RM_SERVICE_DENIED_END (RM_SERVICE_DENIED_BEGIN+21)
+#define RM_SERVICE_DENIED_END (RM_SERVICE_DENIED_BEGIN+23)
 
 /** RM Service Request Error Code Base */
 #define RM_SERVICE_ERROR_BASE (-64)
@@ -192,21 +196,6 @@ typedef enum {
     Rm_service_RESOURCE_UNMAP_NAME
 } Rm_ServiceType;
 
-/** 
- * @brief RM pre-main allocation request information provided by the pre-main 
- *        startup function requesting the resource */
-typedef struct {
-    /** Pointer to the requested pre-main allocation resource name.  The 
-     *  name provided by the component must match the resource names
-     *  provided in the global resource table and allocation policies */
-    char *resourceName;
-    /** The pre-main allocation request resource base value.  For example, 
-     *  queue number or semaphore number */
-    uint32_t resourceBase;
-    /** Range of resource starting at resourceBase */
-    uint32_t resourceRange;
-} Rm_PreMainAllocInfo;
-
 /** 
  * @brief RM service response information provided by RM back to the 
  *        requesting component
@@ -305,6 +294,14 @@ typedef struct {
                       Rm_ServiceRespInfo *serviceResponse);
 } Rm_ServicePort;
 
+/** 
+ * @brief RM pre-main allocation request information provided by the pre-main 
+ *        startup function requesting the resource */
+typedef struct {
+    Rm_PreMainHandle   rmPreMainHandle;
+    Rm_ServiceReqInfo *request;
+} Rm_PreMainReqCfg;
+
 /**
  *  @b Description
  *  @n  
@@ -318,11 +315,11 @@ typedef struct {
  *            running a RM Server or Client Delegate that has a startup policy
  *            allowing the allocation of pre-main resources
  *
- *  @param[in]  preMainAllocInfo
+ *  @param[in]  preMainRequest
  *      Resource pre-main allocation structure that provides details of the 
  *      resource requested from RM for preallocation
  *
- *  @param[out] serviceResponse
+ *  @param[out] preMainResponse
  *      Contains the result information regarding the pre-main allocation request
  *
  *  @retval
@@ -330,8 +327,7 @@ typedef struct {
  *  @retval
  *      Failure - non-zero - Resource pre-main allocation request error.
  */
-void Rm_preMainAllocService (Rm_PreMainAllocInfo *preMainAllocInfo,
-                             Rm_ServiceRespInfo *serviceResponse);
+void Rm_servicePreMainRequest(Rm_PreMainReqCfg *reqCfg, Rm_ServiceRespInfo *preMainResp);
 
 /**
  *  @b Description
@@ -350,7 +346,7 @@ void Rm_preMainAllocService (Rm_PreMainAllocInfo *preMainAllocInfo,
  *  @retval
  *      Failure - NULL
  */
-Rm_ServicePort *Rm_getServicePort(Rm_Handle rmHandle);
+Rm_ServicePort *Rm_serviceGetPort(Rm_Handle rmHandle);
 
 /** 
 @} 
index c108bf6c58d4a978b52367f0802715634bd2fe63..273c1759364e535d3fc4f21255661f245c03af74 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -290,18 +290,16 @@ Rm_Allocator *Rm_allocatorAdd(Rm_Inst *rmInst, const char *resourceName)
     return (newAllocator);\r
 }\r
 \r
-Rm_Allocator *Rm_allocatorFind(Rm_Inst *rmInst, char *resourceName)\r
+Rm_Allocator *Rm_allocatorFind(Rm_Allocator *allocatorList, char *resourceName)\r
 {\r
-    Rm_Allocator *allocator = (Rm_Allocator *)rmInst->allocators;\r
-\r
-    while (allocator) {\r
-        if (strcmp(allocator->resourceName, resourceName) == 0) {\r
+    while (allocatorList) {\r
+        if (strcmp(allocatorList->resourceName, resourceName) == 0) {\r
             break;             \r
         }\r
-        allocator = allocator->nextAllocator;\r
+        allocatorList = allocatorList->nextAllocator;\r
     }\r
 \r
-    return (allocator);\r
+    return (allocatorList);\r
 }\r
 \r
 int32_t Rm_allocatorDelete(Rm_Inst *rmInst, char *resourceName)\r
@@ -365,7 +363,7 @@ void Rm_addAllocatedTo(Rm_ResourceNode *node, void *serviceInstNode)
         }\r
 \r
         node->allocationCount++;\r
-        Rm_policyIncrementValidInstAllocationCount(newAllocatedTo->instNameNode);\r
+        newAllocatedTo->instNameNode->allocRefCount++;\r
     }\r
 }\r
 \r
@@ -439,7 +437,7 @@ void Rm_deleteAllocatedTo(Rm_ResourceNode *node, void *serviceInstNode)
     }\r
     \r
     node->allocationCount--;\r
-    Rm_policyDecrementValidInstAllocationCount(allocatedTo->instNameNode);\r
+    allocatedTo->instNameNode->allocRefCount--;\r
     Rm_osalFree((void *)allocatedTo, sizeof(Rm_AllocatedTo));\r
 }\r
 \r
@@ -555,14 +553,14 @@ int32_t Rm_treePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t res
 \r
     /* Configure policy checking structure */\r
     memset((void *)&policyCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));\r
-    if (RM_POLICY_GET_PERM(opInfo->allocType, RM_POLICY_PERM_INIT_SHIFT)) {\r
+    if (RM_policy_GET_PERM(opInfo->allocType, RM_POLICY_PERM_INIT_SHIFT)) {\r
         policyCheckType = Rm_policyCheck_INIT;\r
     }\r
-    else if (RM_POLICY_GET_PERM(opInfo->allocType, RM_POLICY_PERM_USE_SHIFT)) {\r
+    else if (RM_policy_GET_PERM(opInfo->allocType, RM_POLICY_PERM_USE_SHIFT)) {\r
         policyCheckType = Rm_policyCheck_USE;\r
     }\r
     policyCheckCfg.policyDtb = rmInst->policy;\r
-    policyCheckCfg.resourcePolicy = resourcePolicy;\r
+    policyCheckCfg.resourceOffset = resourcePolicy;\r
     \r
     do {\r
         matchingNode = RB_FIND(_Rm_ResourceTree, allocator->allocatorRootEntry, &findNode);\r
@@ -648,10 +646,10 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
 \r
     /* Prepare privilege checks */\r
     memset((void *)&policyCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));\r
-    if (RM_POLICY_GET_PERM(opInfo->allocType, RM_POLICY_PERM_INIT_SHIFT)) {\r
+    if (RM_policy_GET_PERM(opInfo->allocType, RM_POLICY_PERM_INIT_SHIFT)) {\r
         policyCheckType = Rm_policyCheck_INIT;\r
     }\r
-    else if (RM_POLICY_GET_PERM(opInfo->allocType, RM_POLICY_PERM_USE_SHIFT)) {\r
+    else if (RM_policy_GET_PERM(opInfo->allocType, RM_POLICY_PERM_USE_SHIFT)) {\r
         policyCheckType = Rm_policyCheck_USE;\r
     }\r
 \r
@@ -667,7 +665,7 @@ int32_t Rm_treeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resour
             else {\r
                 allocPassesPolicy = FALSE;\r
                 policyCheckCfg.policyDtb = rmInst->policy;\r
-                policyCheckCfg.resourcePolicy = resourcePolicy;    \r
+                policyCheckCfg.resourceOffset = resourcePolicy;    \r
                 policyCheckCfg.type = policyCheckType;\r
                 policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
                 policyCheckCfg.resourceBase = findNode.base;\r
@@ -1047,25 +1045,25 @@ int32_t Rm_treeFree(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourcePo
 int32_t Rm_allocatorOperation(Rm_Inst *rmInst, Rm_AllocatorOpInfo *opInfo)\r
 {\r
     Rm_Allocator *allocator = NULL;\r
-    int32_t       resourcePolicy = 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
-    resourcePolicy = Rm_policyGetResourcePolicy(rmInst->policy, opInfo->resourceInfo->name);\r
-    allocator = Rm_allocatorFind(rmInst, opInfo->resourceInfo->name);\r
+    resourceOffsetInPolicy = Rm_policyGetResourceOffset(rmInst->policy, opInfo->resourceInfo->name);\r
+    allocator = Rm_allocatorFind(rmInst->allocators, opInfo->resourceInfo->name);\r
     \r
-    if ((resourcePolicy > 0) && allocator) {\r
+    if ((resourceOffsetInPolicy > 0) && allocator) {\r
         if (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE) {\r
-            retVal = Rm_treePreAllocate(rmInst, allocator, resourcePolicy, opInfo);\r
+            retVal = Rm_treePreAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }               \r
         else if (opInfo->operation == Rm_allocatorOp_ALLOCATE) {\r
-            retVal = Rm_treeAllocate(rmInst, allocator, resourcePolicy, opInfo);\r
+            retVal = Rm_treeAllocate(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }\r
         else if (opInfo->operation == Rm_allocatorOp_FREE) {\r
-            retVal = Rm_treeFree(rmInst, allocator, resourcePolicy, opInfo);\r
+            retVal = Rm_treeFree(rmInst, allocator, resourceOffsetInPolicy, opInfo);\r
         }         \r
     }\r
     else {\r
@@ -1080,8 +1078,9 @@ int32_t Rm_allocatorOperation(Rm_Inst *rmInst, Rm_AllocatorOpInfo *opInfo)
 void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode,\r
                            uint32_t allocType)\r
 {\r
-    Rm_AllocatorOpInfo opInfo;\r
-    int32_t            retVal = transaction->state;\r
+    Rm_AllocatorOpInfo  opInfo;\r
+    Rm_NameServerObjCfg nameServerObjCfg;\r
+    int32_t             retVal = transaction->state;\r
 \r
     memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
     \r
@@ -1095,13 +1094,20 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
         opInfo.serviceSrcInstNode = validInstNode;\r
         opInfo.allocType = allocType;\r
 \r
-        if (strlen(transaction->resourceInfo.nsName) > 0) {\r
+        if (strlen(transaction->resourceInfo.nameServerName) > 0) {\r
             if (transaction->resourceInfo.base != 0) {\r
                 /* Both NameServer name and static value cannot be specified for the request */\r
                 retVal = RM_SERVICE_ERROR_NAMESERVER_NAME_AND_RESOURCE_RANGE_BOTH_DEFINED;\r
             }\r
             else {\r
-                retVal = Rm_nsFindObject(rmInst, opInfo.resourceInfo);\r
+                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
+                    transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
+                    transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
+                }                \r
             }\r
         }\r
 \r
@@ -1119,7 +1125,7 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
         \r
         transaction->state = retVal;\r
 \r
-        if (strcmp(transaction->serviceSrcInstName, rmInst->name)) {\r
+        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
@@ -1130,8 +1136,9 @@ void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *v
 \r
 void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode)\r
 {\r
-    Rm_AllocatorOpInfo opInfo; \r
-    int32_t            retVal = transaction->state;\r
+    Rm_AllocatorOpInfo  opInfo; \r
+    Rm_NameServerObjCfg nameServerObjCfg;    \r
+    int32_t             retVal = transaction->state;\r
 \r
     memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
     \r
@@ -1143,14 +1150,22 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
         opInfo.resourceInfo = &transaction->resourceInfo;\r
         opInfo.serviceSrcInstNode = validInstNode;\r
 \r
-        if (strlen(transaction->resourceInfo.nsName) > 0) {\r
+        if (strlen(transaction->resourceInfo.nameServerName) > 0) {\r
             if (transaction->resourceInfo.base != 0) {\r
                 /* Both a name and a value cannot be specified for the request */\r
                 retVal = RM_SERVICE_ERROR_NAMESERVER_NAME_AND_RESOURCE_RANGE_BOTH_DEFINED;\r
             }\r
             else {\r
-                retVal = Rm_nsFindObject(rmInst, opInfo.resourceInfo);\r
+                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
+                    transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
+                    transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
+                }                \r
             }\r
+\r
         }\r
         \r
         if(retVal == RM_SERVICE_PROCESSING) {        \r
@@ -1160,7 +1175,7 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
 \r
         transaction->state = retVal;\r
 \r
-        if (strcmp(transaction->serviceSrcInstName, rmInst->name)) {\r
+        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
@@ -1169,6 +1184,39 @@ void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIn
     }   \r
 }\r
 \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
+{\r
+    Rm_ServiceRespInfo serviceResponse;\r
+\r
+    /* The responseTransaction will contain the resultant state details of\r
+     * the requestTransaction's service request */\r
+    serviceResponse.serviceState = transaction->state;\r
+    /* Pass back the ID that was provided to the component when it requested\r
+     * the service */\r
+    serviceResponse.serviceId = transaction->localId;\r
+\r
+    /* Service was approved and service was an allocate request.  The resource\r
+     * data is passed back to the component */\r
+    if ((serviceResponse.serviceState == 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
+        strcpy(serviceResponse.resourceName, transaction->resourceInfo.name);\r
+        serviceResponse.resourceBase = transaction->resourceInfo.base;\r
+        serviceResponse.resourceLength = transaction->resourceInfo.length;\r
+    }\r
+\r
+    /* Issue the callback to the requesting component with the response information */\r
+    transaction->callback.serviceCallback(&serviceResponse);\r
+\r
+    /* Delete the transaction from the transaction queue */\r
+    Rm_transactionQueueDelete(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
 {\r
@@ -1299,8 +1347,9 @@ void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 \r
 void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
 {\r
-    void     *validInstNode;\r
-    uint32_t  allocType = 0;\r
+    void                *validInstNode;\r
+    Rm_NameServerObjCfg  nameServerObjCfg;      \r
+    uint32_t             allocType = 0;\r
     \r
     /* Handle auto-forwarded transactions.  These transactions include:\r
      * - All request transactions received on Clients are forwarded to the Client Delegate\r
@@ -1312,7 +1361,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
           (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))) {\r
           \r
         if (transaction->state != RM_SERVICE_PROCESSING) {\r
-            if (strcmp(transaction->serviceSrcInstName, rmInst->name)) {\r
+            if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                 /* Transaction did not originate on this instance */\r
                 Rm_transactionResponder(rmInst, transaction);\r
             }\r
@@ -1334,7 +1383,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                 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->name)) {\r
+                if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                     Rm_transactionResponder(rmInst, transaction);\r
                 }\r
             }\r
@@ -1346,7 +1395,7 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
             case Rm_service_RESOURCE_FREE:               \r
                 if (transaction->state != RM_SERVICE_PROCESSING) {\r
                     /* Transaction complete */\r
-                    if (strcmp(transaction->serviceSrcInstName, rmInst->name)) {\r
+                    if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                         /* Transaction result not destined for this instance */\r
                         Rm_transactionResponder(rmInst, transaction);\r
                     }\r
@@ -1363,10 +1412,10 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
                     else {\r
                         switch (transaction->type) {\r
                             case Rm_service_RESOURCE_ALLOCATE_INIT:\r
-                                RM_POLICY_SET_PERM(allocType, RM_POLICY_PERM_INIT_SHIFT, 1);\r
+                                RM_policy_SET_PERM(allocType, RM_POLICY_PERM_INIT_SHIFT, 1);\r
                                 break;\r
                             case Rm_service_RESOURCE_ALLOCATE_USE:\r
-                                RM_POLICY_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1);    \r
+                                RM_policy_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1);    \r
                                 break;\r
                         }\r
                         Rm_allocationHandler(rmInst, transaction, validInstNode, allocType);\r
@@ -1377,21 +1426,31 @@ void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
             case Rm_service_RESOURCE_GET_BY_NAME:\r
             case Rm_service_RESOURCE_UNMAP_NAME:                \r
                 /* NameServer resides on server */\r
+                memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
+                nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
+                nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
                 if (rmInst->instType == Rm_instType_SERVER) {\r
                     if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {\r
-                        transaction->state = Rm_nsAddObject(rmInst, &transaction->resourceInfo);\r
+                        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
                     }\r
                     else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
-                        if (Rm_nsFindObject(rmInst, &transaction->resourceInfo) == RM_SERVICE_PROCESSING) {\r
+                        if ((transaction->state = Rm_nameServerFindObject(&nameServerObjCfg)) ==\r
+                            RM_SERVICE_PROCESSING) {\r
+                            strcpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName);\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
                     }\r
                     else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
-                        transaction->state = Rm_nsDeleteObject(rmInst, &transaction->resourceInfo);\r
+                        transaction->state = Rm_nameServerDeleteObject(&nameServerObjCfg);\r
                     }\r
 \r
                     /* Send result via responder if transaction did not originate from this instance */\r
-                    if (strcmp(transaction->serviceSrcInstName, rmInst->name)) {\r
+                    if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
                         Rm_transactionResponder(rmInst, transaction);\r
                     }\r
                 }\r
@@ -1541,7 +1600,7 @@ int32_t Rm_createAndInitAllocator(Rm_Inst *rmInst, const char *resourceName,
     Rm_NsAssignment *nsAssignments = NULL;\r
     Rm_NsAssignment *nsAssignmentBasePtr = NULL;\r
     Rm_LinuxAlias *linuxAlias = NULL;\r
-    Rm_ResourceInfo resourceInfo;\r
+    Rm_NameServerObjCfg  nameServerObjCfg;      \r
     int32_t retVal = RM_DTB_UTIL_RESULT_OKAY;\r
 \r
     if (resourceProperties->rangeData && (resourceProperties->rangeLen > 0))\r
@@ -1578,15 +1637,15 @@ int32_t Rm_createAndInitAllocator(Rm_Inst *rmInst, const char *resourceName,
             nsAssignmentBasePtr = nsAssignments;\r
             while (nsAssignments)\r
             {\r
-                memset((void *)&resourceInfo, 0, sizeof(Rm_ResourceInfo));\r
-\r
-                strcpy(resourceInfo.name, resourceName);\r
-                resourceInfo.base = nsAssignments->resourceBase;\r
-                resourceInfo.length = nsAssignments->resourceLength;\r
-                strcpy(resourceInfo.nsName, nsAssignments->nsName);\r
+                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_nsAddObject(rmInst, &resourceInfo);\r
+                Rm_nameServerAddObject(&nameServerObjCfg);\r
                 nsAssignments = nsAssignments->nextNsAssignment;\r
             }\r
             /* Free the memory allocated for the NameServer assignments */\r
@@ -1787,7 +1846,7 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
                 allocatedTo = treeNode->allocatedTo;\r
                 Rm_osalLog("allocated to ");\r
                 while (allocatedTo) {\r
-                    Rm_osalLog(" %s", Rm_policyGetValidInstNodeName(allocatedTo->instNameNode));\r
+                    Rm_osalLog(" %s", allocatedTo->instNameNode->name);\r
                     allocatedTo = allocatedTo->nextAllocatedTo;\r
                 }\r
                 Rm_osalLog("\n");\r
@@ -1796,7 +1855,70 @@ void Rm_printResourceStatus(Rm_Handle *rmHandle)
         allocator = allocator->nextAllocator;\r
     }\r
 \r
-    Rm_nsPrintObjects(rmInst);\r
+    Rm_nameServerPrintObjects(rmInst->nameServer);\r
+}\r
+\r
+Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *result)\r
+{\r
+    Rm_PreMainInst *preMainInst;\r
+\r
+    if ((strlen(preMainInitCfg->instName) + 1) > RM_INSTANCE_NAME_MAX_CHARS) {\r
+        *result = RM_INIT_ERROR_INSTANCE_NAME_TOO_BIG;\r
+        return (NULL);\r
+    }\r
+\r
+    preMainInst = (Rm_PreMainInst *) Rm_osalMalloc (sizeof(Rm_PreMainInst));\r
+    fdt_open_into(preMainInitCfg->startupPolicyDtb, preMainInitCfg->startupPolicyDtb,\r
+                  fdt_totalsize(preMainInitCfg->startupPolicyDtb));\r
+    preMainInst->startupDtb = preMainInitCfg->startupPolicyDtb;\r
+\r
+    preMainInst->validInstTree = Rm_policyCreateValidInstTree(preMainInst->startupDtb, result);\r
+    if (*result == RM_INIT_OK) {\r
+        /* Validate policy assignment strings */\r
+        *result = Rm_policyValidatePolicy(preMainInitCfg->startupPolicyDtb, preMainInst->validInstTree);\r
+    }\r
+\r
+    if (*result != RM_INIT_OK) {\r
+        if (preMainInst->validInstTree) {\r
+            Rm_policyFreeValidInstTree(preMainInst->validInstTree);\r
+        }\r
+        Rm_osalFree((void *)preMainInst, sizeof(Rm_PreMainInst));\r
+        preMainInst = NULL;\r
+    }\r
+    else {\r
+        strcpy(preMainInst->instName, preMainInitCfg->instName);\r
+        preMainInst->requestCount = 0;\r
+        preMainInst->preMainReqList = NULL;\r
+    }\r
+\r
+    return((Rm_PreMainHandle)preMainInst);\r
+}\r
+\r
+int32_t Rm_preMainHandleValidateAndDelete(Rm_Handle rmHandle, Rm_PreMainHandle rmPreMainHandle)\r
+{\r
+    Rm_Inst              *rmInst = (Rm_Inst *)rmHandle;\r
+    Rm_PreMainInst       *preMainInst = (Rm_PreMainInst *)rmPreMainHandle;\r
+    Rm_ServicePreMainReq *serviceReq = preMainInst->preMainReqList;\r
+    Rm_ServicePreMainReq *nextServiceReq;\r
+    int32_t retVal = RM_INIT_OK;\r
+\r
+    if (strcmp(rmInst->instName, preMainInst->instName) == 0) {\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
+        while(serviceReq) {\r
+            nextServiceReq = serviceReq->nextPreMainReq;\r
+            Rm_osalFree((void *)serviceReq->preMainReq, sizeof(Rm_ServiceReqInfo));\r
+            Rm_osalFree((void *)serviceReq, sizeof(Rm_ServicePreMainReq));\r
+            serviceReq = nextServiceReq;\r
+        }\r
+        Rm_osalFree((void *)preMainInst, sizeof(Rm_PreMainInst));\r
+    }\r
+    else {\r
+        retVal = RM_INIT_ERROR_PREMAIN_INST_AND_POSTMAIN_INST_NAMES_DONT_MATCH;\r
+    }\r
+    return(retVal);\r
 }\r
 \r
 Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)\r
@@ -1816,7 +1938,7 @@ 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->name[0], initCfg->instName);\r
+    strcpy (rmInst->instName, initCfg->instName);\r
     rmInst->instType = initCfg->instType;\r
     rmInst->registeredWithDelegateOrServer = false;\r
     rmInst->routeMap = NULL;\r
@@ -1841,7 +1963,7 @@ Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)
 \r
     /* RM Server specific actions */\r
     if (rmInst->instType == Rm_instType_SERVER) {\r
-        Rm_nsInit(rmInst);\r
+        Rm_nameServerInit();\r
 \r
         if (initCfg->globalResourceList) {\r
             globalResourceDtb = initCfg->globalResourceList;\r
index 10b5abeb52b6e119423132b7df85d2bc9ad0aa32..14f4469c47de906f71838b01ddef8130f780b6cf 100644 (file)
@@ -2,7 +2,7 @@
  *   @file  rm_nameserver.c
  *
  *   @brief   
- *      This is the Resource Manager NameServer source.
+ *      Resource Manager NameServer source.
  *
  *  \par
  *  ============================================================================
@@ -46,7 +46,6 @@
 #include <ti/drv/rm/rm_services.h>
 
 /* RM internal API includes */
-#include <ti/drv/rm/include/rm_loc.h>
 #include <ti/drv/rm/include/rm_nameserverloc.h>
 
 /* AVL BBST includes */
 #include <rm_osal.h>
 
 /**********************************************************************
- ************** Red-Black BBST Tree NameServer Functions **************
+ ********************* NameServer Tree Functions **********************
  **********************************************************************/
 
-Rm_NameServerNode *Rm_newNameServerNode(char *name, char *resourceName,
-                                        uint32_t resourceBase, uint32_t resourceLength)
+Rm_NameServerNode *Rm_nameServerNewNode(Rm_NameServerNodeCfg *nodeCfg)
 {
     Rm_NameServerNode *newNode = NULL;
 
     newNode = Rm_osalMalloc(sizeof(Rm_NameServerNode));
-
-    /* Populate the node */
-    strcpy(newNode->name, name);
-    strcpy(newNode->resourceName, resourceName); 
-    newNode->base = resourceBase;
-    newNode->length = resourceLength;
+    if (newNode) {
+        strcpy(newNode->objName, nodeCfg->objName);
+        strcpy(newNode->resourceName, nodeCfg->resourceName); 
+        newNode->resourceBase = nodeCfg->resourceBase;
+        newNode->resourceLength = nodeCfg->resourceLength;
+    }
     
     return(newNode);
 }
 
-void Rm_freeNameServerNode(Rm_NameServerNode *node)
+void Rm_nameServerFreeNode(Rm_NameServerNode *node)
 {
-    /* Free the memory associated with the tree node. */
-    Rm_osalFree((void *)node, sizeof(Rm_NameServerNode));
+    if (node) {
+        Rm_osalFree((void *)node, sizeof(Rm_NameServerNode));
+    }
 }
 
-/* Prototype for tree node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_NameServerNodeCompare(Rm_NameServerNode *element1, Rm_NameServerNode *element2)
+int Rm_nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2)
 {
-    return(strcmp(element1->name, element2->name));
+    return(strcmp(node1->objName, node2->objName));
 }
 
-/* Generate the red-black tree manipulation functions */
-RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_NameServerNodeCompare);
+/* Generate the NameServer tree manipulation functions */
+RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_nameServerNodeCompare);
 
 /**********************************************************************
- ********************** Internal Functions ****************************
+ ******************* Internal NameServer APIs *************************
  **********************************************************************/
 
-int32_t Rm_nsAddObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo)
+int32_t Rm_nameServerAddObject(Rm_NameServerObjCfg *objCfg)
 {
-    Rm_NameServerNode *newNode = NULL;
-    Rm_NameServerNode *collidingNode = NULL;
-    int32_t retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
-
-    newNode = Rm_newNameServerNode(resourceInfo->nsName, resourceInfo->name,
-                                   resourceInfo->base, resourceInfo->length);
-
-    if (newNode)
-    {
-        /* Try to insert the new name */
-        collidingNode = RB_INSERT(_Rm_NameServerTree, rmInst->nameServer, newNode);
-
-        if (collidingNode)
-        {
-            Rm_freeNameServerNode(newNode);
+    Rm_NameServerNode    *newNode = NULL;
+    int32_t               retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
+    
+    if (newNode = Rm_nameServerNewNode(&objCfg->nodeCfg)) {
+        if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) {
+            /* Collision */
+            Rm_nameServerFreeNode(newNode);
             retVal = RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS;
         }
     }
-    else
-    {
+    else {
         retVal = RM_SERVICE_ERROR_NAMESERVER_OBJECT_ADD_FAILED;
     }
     
     return(retVal);
 }
 
-int32_t Rm_nsFindObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo)
+int32_t Rm_nameServerFindObject(Rm_NameServerObjCfg *objCfg)
 {
     Rm_NameServerNode  findNode;
-    Rm_NameServerNode *matchingNode = NULL;
-    int32_t            retVal = RM_SERVICE_PROCESSING;
+    Rm_NameServerNode *matchingNode;
+    int32_t            retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
 
     memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
-    strcpy(findNode.name, resourceInfo->nsName);
-    
-    matchingNode = RB_FIND(_Rm_NameServerTree, rmInst->nameServer, &findNode);
-
-    if (matchingNode) {
-        /* Copy the name's resource information */
-        strcpy(resourceInfo->name, matchingNode->resourceName);
-        resourceInfo->base = matchingNode->base;
-        resourceInfo->length = matchingNode->length;
-    }
-    else {
-        retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
-    }
+    strcpy(findNode.objName, objCfg->nodeCfg.objName);
     
+    if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
+        /* Found in NameServer */
+        strcpy(objCfg->nodeCfg.resourceName, matchingNode->resourceName);
+        objCfg->nodeCfg.resourceBase = matchingNode->resourceBase;
+        objCfg->nodeCfg.resourceLength = matchingNode->resourceLength;
+
+        retVal = RM_SERVICE_PROCESSING;
+    }    
     return(retVal);
 }
 
-int32_t Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo)
+int32_t Rm_nameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
 {   
-    Rm_NameServerNode findNode;
-    Rm_NameServerNode *matchingNode = NULL;
-    int32_t retVal = RM_SERVICE_APPROVED_AND_COMPLETED;    
-
-    /* Copy the name to find into the find node structure */
-    strcpy(findNode.name, resourceInfo->nsName);
-    
-    matchingNode = RB_FIND(_Rm_NameServerTree, rmInst->nameServer, &findNode);
+    Rm_NameServerNode  findNode;
+    Rm_NameServerNode *matchingNode;
+    int32_t            retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;    
 
-    if (matchingNode)
-    {
-        /* Remove the name from the NameServer */
-        RB_REMOVE(_Rm_NameServerTree, rmInst->nameServer, matchingNode);
-        Rm_freeNameServerNode(matchingNode);
-    }
-    else
-    {
-        retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
-    }
+    memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
+    strcpy(findNode.objName, objCfg->nodeCfg.objName);
     
+    if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
+        /* Remove from NameServer */
+        RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode);
+        Rm_nameServerFreeNode(matchingNode);
+        
+        retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
+    }    
     return(retVal);
 }
 
-void Rm_nsPrintObjects(Rm_Inst *rmInst)
+void Rm_nameServerPrintObjects(Rm_NameServerTree *nameServerTree)
 {
     Rm_NameServerNode *node;
 
-    RB_FOREACH(node, _Rm_NameServerTree, rmInst->nameServer)
-    {               
-        Rm_osalLog("Name: %s resourceName: %s base: %d length: %d\n", node->name, node->resourceName,
-                                                                      node->base, node->length);
+    RB_FOREACH(node, _Rm_NameServerTree, nameServerTree) {               
+        Rm_osalLog("Name: %s resourceName: %s base: %d length: %d\n", node->objName, node->resourceName,
+                                                                      node->resourceBase, node->resourceLength);
     }
 }
 
-void Rm_nsInit(Rm_Inst *rmInst)
+Rm_NameServerTree *Rm_nameServerInit(void)
 {
     Rm_NameServerTree *rootEntry = NULL;
 
-    /* Create the NameServer root entry and initialize it */
     rootEntry = Rm_osalMalloc(sizeof(Rm_NameServerTree));
     RB_INIT(rootEntry);
 
-    rmInst->nameServer = (void *)rootEntry;
+    return(rootEntry);
 }
 
index 8e5c156f8332b01d41425a8f0f04a07b187ecd8b..9b3022b0949181730c379423650f24b2e970d562 100644 (file)
@@ -2,7 +2,7 @@
  *   @file  rmpolicy.c
  *
  *   @brief   
- *      This is the Resource Manager Policy source.
+ *      Resource Manager Policy source.
  *
  *  \par
  *  ============================================================================
 #include <rm_osal.h>
 
 /**********************************************************************
- ************************** Globals ***********************************
+ *********************** Policy Globals *******************************
  **********************************************************************/
 
 char Rm_policyAllInstances[] = "*";
 
 /**********************************************************************
- ************ Red-Black BBST Tree Valid Instance Functions ************
+ *************** Policy Valid Instance Tree Functions *****************
  **********************************************************************/
-Rm_ValidInstNode *Rm_newValidInstNode(char *instName)
+Rm_PolicyValidInstNode *Rm_policyNewValidInstNode(char *instName)
 {
-    Rm_ValidInstNode *newNode = NULL;
+    Rm_PolicyValidInstNode *newNode = NULL;
 
-    newNode = Rm_osalMalloc(sizeof(Rm_ValidInstNode));
+    newNode = Rm_osalMalloc(sizeof(Rm_PolicyValidInstNode));
     
     strcpy(newNode->name, instName);
     newNode->allocRefCount = 0;
@@ -83,51 +83,35 @@ Rm_ValidInstNode *Rm_newValidInstNode(char *instName)
     return(newNode);
 }
 
-void Rm_freeValidInstNode(Rm_ValidInstNode *node)
+void Rm_policyFreeValidInstNode(Rm_PolicyValidInstNode *node)
 {
     if (node->allocRefCount == 0) {
-        Rm_osalFree((void *)node, sizeof(Rm_ValidInstNode));
+        Rm_osalFree((void *)node, sizeof(Rm_PolicyValidInstNode));
     }
 }
 
-/* Prototype for tree node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_ValidInstNodeCompare(Rm_ValidInstNode *element1, Rm_ValidInstNode *element2)
+int Rm_policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2)
 {
-    return(strcmp(element1->name, element2->name));
+    return(strcmp(node1->name, node2->name));
 }
 
-/* Generate the red-black tree manipulation functions */
-RB_GENERATE(_Rm_ValidInstTree, _Rm_ValidInstNode, linkage, Rm_ValidInstNodeCompare);
+/* Generate the valid instance tree manipulation functions */
+RB_GENERATE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, Rm_policyValidInstNodeCompare);
 
 /**********************************************************************
- ********************** Internal Functions ****************************
+ ******************** Local Policy Functions **************************
  **********************************************************************/
 
-int32_t Rm_policyCheckInstances(Rm_ValidInstTree *root
+int32_t Rm_policyCheckInstances(Rm_PolicyValidInstTree *validInstTree
                                 Rm_PolicyPermission *permissionsList)
 {
-    Rm_PolicyPermission *permission = permissionsList;
-    bool                 instNameMatch = FALSE;
-    
-    while (permission) {
-        if (strcmp(permission->instName, Rm_policyAllInstances) == 0) {
-            instNameMatch = TRUE;
-        }
-        else if (Rm_policyGetValidInstNode(root, permission->instName)) {
-                    instNameMatch = TRUE; 
-        }
-
-        if (!instNameMatch) {
+    while (permissionsList) {
+        if (strcmp(permissionsList->instName, Rm_policyAllInstances) &&
+            (!Rm_policyGetValidInstNode(validInstTree, permissionsList->instName))) {
             return(RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE);
         }
-
-        permission = permission->nextPermission;
-        instNameMatch = FALSE;
+        permissionsList = permissionsList->nextPermission;
     }
-    
     return(RM_INIT_OK);
 }
 
@@ -258,7 +242,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                     (*permStrPtr == RM_POLICY_PERM_INIT_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -266,7 +250,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_USE_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                                           
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -274,7 +258,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                       
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -282,7 +266,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                       
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }                
@@ -357,7 +341,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                     (*permStrPtr == RM_POLICY_PERM_INIT_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -365,7 +349,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_USE_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                                           
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -373,7 +357,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                       
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }
@@ -381,7 +365,7 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
                          (*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER)) {
                     newPerm = startPerm;
                     while (newPerm) {                       
-                        RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
+                        RM_policy_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
                         newPerm = newPerm->nextPermission;
                     }
                 }                  
@@ -482,7 +466,7 @@ Rm_PolicyPermission *Rm_policyGetAssignmentPermissions(Rm_PolicyAssignment *assi
     return(startPerm);
 }
 
-int32_t Rm_policyValidateAssignmentPermissions(Rm_ValidInstTree *root,
+int32_t Rm_policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
                                                Rm_PolicyAssignment *assignmentList)
 {
     Rm_PolicyAssignment *assignment = assignmentList;
@@ -508,41 +492,29 @@ int32_t Rm_policyValidateAssignmentPermissions(Rm_ValidInstTree *root,
     return (RM_INIT_OK);
 }
 
-void Rm_policyIncrementValidInstAllocationCount(void *validInstNameNode)
-{
-    Rm_ValidInstNode *node = (Rm_ValidInstNode *)validInstNameNode;
-
-    node->allocRefCount++;
-}
-
-void Rm_policyDecrementValidInstAllocationCount(void *validInstNameNode)
-{
-    Rm_ValidInstNode *node = (Rm_ValidInstNode *)validInstNameNode;
-
-    node->allocRefCount--;
-}
+/**********************************************************************
+ ************************ Internal Policy APIs ************************
+ **********************************************************************/
 
-void *Rm_policyGetValidInstNode(void *validInstTree, char *instName)
+Rm_PolicyValidInstNode *Rm_policyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName)
 {
-    Rm_ValidInstTree *root = (Rm_ValidInstTree *)validInstTree;
-    Rm_ValidInstNode  findNode;
+    Rm_PolicyValidInstNode  findNode;
 
-    memset((void *)&findNode, 0, sizeof(Rm_ValidInstNode));
+    memset((void *)&findNode, 0, sizeof(Rm_PolicyValidInstNode));
     strcpy(findNode.name, instName);
     
-    return (RB_FIND(_Rm_ValidInstTree, root, &findNode));
+    return (RB_FIND(_Rm_PolicyValidInstTree, validInstTree, &findNode));
 }
 
-char *Rm_policyGetValidInstNodeName(void *validInstNode)
+Rm_PolicyValidInstNode *Rm_policyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree)
 {
-    Rm_ValidInstNode *node = validInstNode;
+    char linuxName[] = RM_ALLOCATED_TO_LINUX;
 
-    return (node->name);
+    return (Rm_policyGetValidInstNode(validInstTree, linuxName));
 }
 
 bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
 {
-    Rm_ValidInstNode    *instNode = (Rm_ValidInstNode *)privilegeCfg->validInstNode;
     int32_t              propertyOffset;
     const char          *propertyName;
        int32_t              propertyLen;
@@ -556,7 +528,7 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
     bool                 foundInstance;
 
     /* Get the resource's assignments */
-    propertyOffset = fdt_first_property_offset(privilegeCfg->policyDtb, privilegeCfg->resourcePolicy);
+    propertyOffset = fdt_first_property_offset(privilegeCfg->policyDtb, privilegeCfg->resourceOffset);
     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);
@@ -581,27 +553,27 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
                  
                 permission = permissionStart = Rm_policyGetAssignmentPermissions(assignment, result);
                 while (permission) {
-                    if ((strcmp(permission->instName, instNode->name) == 0) ||
+                    if ((strcmp(permission->instName, privilegeCfg->validInstNode->name) == 0) ||
                         (strcmp(permission->instName, Rm_policyAllInstances) == 0)) {
                         foundInstance = TRUE;
                         
                         /* Check instance's permissions */
                         if (privilegeCfg->type == Rm_policyCheck_INIT) {
-                            if (!RM_POLICY_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
+                            if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
                                 Rm_policyFreeAssignmentPermissions(permissionStart);
                                 Rm_policyFreeAssignments(assignmentStart);
                                 return(FALSE);
                             }
                         }
                         else if (privilegeCfg->type == Rm_policyCheck_USE) {
-                            if (!RM_POLICY_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
+                            if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
                                 Rm_policyFreeAssignmentPermissions(permissionStart);
                                 Rm_policyFreeAssignments(assignmentStart);
                                 return(FALSE);
                             }   
                         }
                         else if (privilegeCfg->type == Rm_policyCheck_EXCLUSIVE) {
-                            if (!RM_POLICY_GET_PERM(permission->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT)) {
+                            if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT)) {
                                 Rm_policyFreeAssignmentPermissions(permissionStart);
                                 Rm_policyFreeAssignments(assignmentStart);
                                 return(FALSE);
@@ -629,12 +601,11 @@ bool Rm_policyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result)
     return(TRUE);
 }
 
-uint32_t Rm_policyGetResourceBase(void *policyDtb, void *validInstNode, 
-                                  int32_t resourcePolicy, uint32_t allocType, 
+uint32_t Rm_policyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
+                                  int32_t resourceOffset, uint32_t allocType, 
                                   int32_t *result)
 
 {
-    Rm_ValidInstNode    *instNode = (Rm_ValidInstNode *)validInstNode;
     int32_t              propertyOffset;
     const char          *propertyName;
        int32_t              propertyLen;
@@ -645,7 +616,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, void *validInstNode,
     Rm_PolicyPermission *permissionStart = NULL;
     uint32_t             resourceBase = 0;
 
-    propertyOffset = fdt_first_property_offset(policyDtb, resourcePolicy);
+    propertyOffset = fdt_first_property_offset(policyDtb, 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);
@@ -662,20 +633,18 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, void *validInstNode,
         while (assignment) {
             permission = permissionStart = Rm_policyGetAssignmentPermissions(assignment, result);
             while (permission) {
-                if ((strcmp(permission->instName, instNode->name) == 0) ||
+                if ((strcmp(permission->instName, validInstNode->name) == 0) ||
                     (strcmp(permission->instName, Rm_policyAllInstances) == 0)) {
                     /* Check instance's permissions */
-                    if (RM_POLICY_GET_PERM(allocType, RM_POLICY_PERM_INIT_SHIFT)) {
-                        if (RM_POLICY_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
-                            resourceBase = assignment->resourceBase;
-                            break;
-                        }
+                    if (RM_policy_GET_PERM(allocType, RM_POLICY_PERM_INIT_SHIFT) &&
+                        RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
+                        resourceBase = assignment->resourceBase;
+                        break;
                     }
-                    else if (RM_POLICY_GET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT)) {
-                        if (RM_POLICY_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
-                            resourceBase = assignment->resourceBase;
-                            break;
-                        }   
+                    else if (RM_policy_GET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT) &&
+                             RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
+                        resourceBase = assignment->resourceBase;
+                        break;
                     }
                 }
                 permission = permission->nextPermission;
@@ -698,7 +667,7 @@ uint32_t Rm_policyGetResourceBase(void *policyDtb, void *validInstNode,
     return(resourceBase);
 }
 
-uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourcePolicy)
+uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
 {
     int32_t            propertyOffset;
     const char        *propertyName;
@@ -707,7 +676,7 @@ uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourcePolicy)
     Rm_ResourceValue  *alignmentList;
     uint32_t           resourceAlignment = 0;
 
-    propertyOffset = fdt_first_property_offset(policyDtb, resourcePolicy);
+    propertyOffset = fdt_first_property_offset(policyDtb, 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);
@@ -722,7 +691,7 @@ uint32_t Rm_policyGetResourceAlignment(void *policyDtb, int32_t resourcePolicy)
     return(resourceAlignment);
 }
 
-int32_t Rm_policyGetResourcePolicy(void *policyDtb, char *resourceName)
+int32_t Rm_policyGetResourceOffset(void *policyDtb, char *resourceName)
 {
     int32_t     nodeOffset;
     int32_t     depth;
@@ -745,15 +714,9 @@ int32_t Rm_policyGetResourcePolicy(void *policyDtb, char *resourceName)
     return(nodeOffset);
 }
 
-void *Rm_policyGetLinuxInstNode(void * validInstTree)
-{
-    char linuxName[] = RM_ALLOCATED_TO_LINUX;
-
-    return (Rm_policyGetValidInstNode(validInstTree, linuxName));
-}
-
-int32_t Rm_policyValidatePolicyResourceNames(Rm_Inst *rmInst, void *policyDtb)
+int32_t Rm_policyValidatePolicyResourceNames(void *allocatorList, void *policyDtb)
 {
+    Rm_Allocator *allocator = (Rm_Allocator *)allocatorList;
     int32_t              nodeOffset;
     int32_t              depth;
     const char          *nodeName;
@@ -769,7 +732,7 @@ int32_t Rm_policyValidatePolicyResourceNames(Rm_Inst *rmInst, void *policyDtb)
         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(rmInst, (char *)nodeName) == NULL) {
+            if (Rm_allocatorFind(allocator, (char *)nodeName) == NULL) {
                 /* No allocator tied to resource name */
                 return(RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE);
             }        
@@ -779,7 +742,7 @@ int32_t Rm_policyValidatePolicyResourceNames(Rm_Inst *rmInst, void *policyDtb)
 }
 
 /* TODO: ADD ABILITY TO RETURN THE SYNTAX ERROR LOCATION */
-int32_t Rm_policyValidatePolicy(Rm_Inst *rmInst, void *policyDtb)
+int32_t Rm_policyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree)
 {
     int32_t              nodeOffset;
     int32_t              propertyOffset;
@@ -805,8 +768,7 @@ int32_t Rm_policyValidatePolicy(Rm_Inst *rmInst, void *policyDtb)
             if (Rm_policyGetPropertyType(propertyName) == Rm_policyPropType_ASSIGNMENTS) {
                 assignmentList = Rm_policyExtractAssignments(propertyData, propertyLen);
                 
-                if ((result = Rm_policyValidateAssignmentPermissions((Rm_ValidInstTree *) rmInst->validInstances, 
-                                                                     assignmentList)) != RM_INIT_OK) {
+                if ((result = Rm_policyValidateAssignmentPermissions(validInstTree, assignmentList)) != RM_INIT_OK) {
                     Rm_policyFreeAssignments(assignmentList);
                     return(result);
                 }
@@ -818,7 +780,7 @@ int32_t Rm_policyValidatePolicy(Rm_Inst *rmInst, void *policyDtb)
     return(RM_INIT_OK);
 }
 
-void *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result)
+Rm_PolicyValidInstTree *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result)
 {
     int32_t             validInstOffset;
     const char         *validInstName;
@@ -826,8 +788,8 @@ void *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result)
        const void         *validInstData;
     Rm_PolicyPropType   propertyType;
     Rm_PolicyValidInst *validInstList;
-    Rm_ValidInstTree   *rootEntry = NULL;
-    Rm_ValidInstNode   *newNode;  
+    Rm_PolicyValidInstTree   *rootEntry = NULL;
+    Rm_PolicyValidInstNode   *newNode;  
     char                linuxName[] = RM_ALLOCATED_TO_LINUX;
 
     /* Valid instance list must be first and only property in the root node of
@@ -850,21 +812,32 @@ void *Rm_policyCreateValidInstTree(void *policyDtb, int32_t *result)
     validInstList = Rm_policyExtractValidInstances(validInstData, validInstLen);
 
     /* Create the tree */
-    rootEntry = Rm_osalMalloc(sizeof(Rm_ValidInstTree));
+    rootEntry = Rm_osalMalloc(sizeof(Rm_PolicyValidInstTree));
     RB_INIT(rootEntry);
 
     while (validInstList) {
-        newNode = Rm_newValidInstNode(validInstList->instName);
-        RB_INSERT(_Rm_ValidInstTree, rootEntry, newNode);
+        newNode = Rm_policyNewValidInstNode(validInstList->instName);
+        RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);
         
         validInstList = validInstList->nextValidInst;
     }
 
     /* Add the Linux kernel node */
-    newNode = Rm_newValidInstNode(linuxName);
-    RB_INSERT(_Rm_ValidInstTree, rootEntry, newNode);    
+    newNode = Rm_policyNewValidInstNode(linuxName);
+    RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);    
 
     *result = RM_INIT_OK;
-    return ((void *)rootEntry);
+    return (rootEntry);
+}
+
+void Rm_policyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree)
+{
+    Rm_PolicyValidInstNode *node;
+    
+    RB_FOREACH(node, _Rm_PolicyValidInstTree, validInstTree) {               
+        RB_REMOVE(_Rm_PolicyValidInstTree, validInstTree, node);
+        Rm_policyFreeValidInstNode(node);
+    }        
+    Rm_osalFree((void *)validInstTree, sizeof(Rm_PolicyValidInstTree));
 }
 
index 81027c13ad5c5543fa30ffd1295d23c763dd2bee..b1ff067cf5d08203e8b13aafc857c81c545ba4ec 100644 (file)
@@ -46,7 +46,9 @@
 #include <ti/drv/rm/rm_services.h>
 
 /* RM internal API includes */
+#include <ti/drv/rm/include/rm_servicesloc.h>
 #include <ti/drv/rm/include/rm_loc.h>
+#include <ti/drv/rm/include/rm_policyloc.h>
 
 /* RM OSAL layer */
 #include <rm_osal.h>
@@ -85,14 +87,14 @@ void Rm_serviceHandler (void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
     {
         /* Transfer request information into the transaction */
         transaction->type = serviceRequest->type;
-        strcpy(transaction->serviceSrcInstName, rmInst->name);
+        strcpy(transaction->serviceSrcInstName, rmInst->instName);
         transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
         transaction->state = RM_SERVICE_PROCESSING;
         strcpy(&(transaction->resourceInfo.name)[0], serviceRequest->resourceName);
         transaction->resourceInfo.base = serviceRequest->resourceBase;
         transaction->resourceInfo.length = serviceRequest->resourceLength;
         transaction->resourceInfo.alignment = serviceRequest->resourceAlignment;
-        strcpy(&(transaction->resourceInfo.nsName)[0], serviceRequest->resourceNsName);
+        strcpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName);
 
         /* Pass the new transaction to the transaction processor */
         Rm_transactionProcessor (rmInst, transaction);
@@ -134,50 +136,73 @@ void Rm_serviceHandler (void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
     return;
 }
 
-/* This function is executed when a RM instance receives a response to one of its requests
- * and the information in the request must be provided to the original requesting component */
-void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
-{
-    Rm_ServiceRespInfo serviceResponse;
-
-    /* The responseTransaction will contain the resultant state details of
-     * the requestTransaction's service request */
-    serviceResponse.serviceState = transaction->state;
-    /* Pass back the ID that was provided to the component when it requested
-     * the service */
-    serviceResponse.serviceId = transaction->localId;
-
-    /* Service was approved and service was an allocate request.  The resource
-     * data is passed back to the component */
-    if ((serviceResponse.serviceState == RM_SERVICE_APPROVED_AND_COMPLETED) &&
-        ((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);
-        serviceResponse.resourceBase = transaction->resourceInfo.base;
-        serviceResponse.resourceLength = transaction->resourceInfo.length;
-    }
-
-    /* Issue the callback to the requesting component with the response information */
-    transaction->callback.serviceCallback(&serviceResponse);
-
-    /* Delete the transaction from the transaction queue */
-    Rm_transactionQueueDelete(rmInst, transaction->localId);
-    return;
-}
-
 /**********************************************************************
  ********************** Application visible APIs **********************
  **********************************************************************/
 
-void Rm_preMainAllocService(Rm_PreMainAllocInfo *preMainAllocInfo,
-                            Rm_ServiceRespInfo *serviceResponse)
+void Rm_servicePreMainRequest(Rm_PreMainReqCfg *reqCfg, Rm_ServiceRespInfo *preMainResp)
 {
+    Rm_PreMainInst       *preMainInst = (Rm_PreMainInst *)reqCfg->rmPreMainHandle;
+    Rm_PolicyCheckCfg     privCheckCfg;
+    Rm_ServicePreMainReq *lastServiceReq;
+
+    preMainResp->serviceState = RM_SERVICE_PROCESSING;
+    preMainResp->serviceId = 0;
+
+    if ((reqCfg->request->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+        (reqCfg->request->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
+        (reqCfg->request->resourceBase == RM_RESOURCE_BASE_UNSPECIFIED)) {
+        /* Check request against startup policy */
+        memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
 
+        if (reqCfg->request->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+            privCheckCfg.type = Rm_policyCheck_INIT;
+        }
+        else {
+            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.resourceBase = reqCfg->request->resourceBase;
+        privCheckCfg.resourceLength = reqCfg->request->resourceLength;
+
+        if (Rm_policyCheckPrivilege(&privCheckCfg, &preMainResp->serviceState)) {
+            preMainResp->serviceState = RM_SERVICE_APPROVED_AND_COMPLETED;
+        }
+        else if (preMainResp->serviceState == RM_SERVICE_PROCESSING) {
+            /* Privilege check returned FALSE without error */
+            preMainResp->serviceState = RM_SERVICE_DENIED_POLICY_DENIED_PREMAIN_ALLOCATION;
+        }
+    }
+    else {
+        preMainResp->serviceState = RM_SERVICE_DENIED_INVALID_PREMAIN_REQUEST;
+    }
+
+    /* Store the request for validation after post-main instance
+     * transports have been established */
+    if (preMainResp->serviceState == RM_SERVICE_APPROVED_AND_COMPLETED) {
+        /* Store the request for validation after all instances have been setup post-main */
+        lastServiceReq = preMainInst->preMainReqList;
+        while(lastServiceReq) {
+            lastServiceReq = lastServiceReq->nextPreMainReq;
+        }
+        lastServiceReq = (Rm_ServicePreMainReq *) Rm_osalMalloc (sizeof(Rm_ServicePreMainReq));
+        lastServiceReq->nextPreMainReq = NULL;
+        lastServiceReq->preMainReq = (Rm_ServiceReqInfo *) Rm_osalMalloc(sizeof(Rm_ServiceReqInfo));
+        memcpy((void *)lastServiceReq->preMainReq, (void *)reqCfg->request, sizeof(Rm_ServiceReqInfo));
+
+        /* Fill out response */
+        preMainResp->resourceBase = reqCfg->request->resourceBase;
+        preMainResp->resourceLength = reqCfg->request->resourceLength;
+        strcpy(preMainResp->resourceName, reqCfg->request->resourceName);
+        preMainResp->serviceId = ++preMainInst->requestCount;
+    }
 }
 
-Rm_ServicePort *Rm_getServicePort(Rm_Handle rmHandle)
+Rm_ServicePort *Rm_serviceGetPort(Rm_Handle rmHandle)
 {
     Rm_ServicePort *newServicePort = NULL;
     
index 8d203bd0d2add30bc94b34987199578c19681a84..de5a60b74aac245877a3235d882741f5c8acdbce 100644 (file)
@@ -274,7 +274,7 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
         resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;\r
     }\r
     /* Pass along the packet source and service source information */\r
-    strcpy(resourceReqPkt->pktSrcInstName, rmInst->name);\r
+    strcpy(resourceReqPkt->pktSrcInstName, rmInst->instName);\r
     strcpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
     /* Copy the resource data */\r
     memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
@@ -360,7 +360,7 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
         nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;\r
     }\r
     /* Pass along the packet source and service source information */\r
-    strcpy(nsReqPkt->pktSrcInstName, rmInst->name);\r
+    strcpy(nsReqPkt->pktSrcInstName, rmInst->instName);\r
     strcpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName);\r
     /* Copy the NameServer request data */\r
     memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r