summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca8de60)
raw | patch | inline | side by side (parent: ca8de60)
author | Justin Sobota <jsobota@ti.com> | |
Tue, 5 Feb 2013 01:13:56 +0000 (20:13 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Tue, 5 Feb 2013 01:13:56 +0000 (20:13 -0500) |
21 files changed:
device/tci6614-server-policy.dtb | patch | blob | history | |
device/tci6614-server-policy.dts | patch | blob | history | |
device/tci6614-static-policy.dtb | patch | blob | history | |
device/tci6614-static-policy.dts | patch | blob | history | |
include/rm_loc.h | patch | blob | history | |
include/rm_policyloc.h | patch | blob | history | |
include/rm_servicesloc.h | [deleted file] | patch | blob | history |
include/rm_transportloc.h | patch | blob | history | |
rm.h | patch | blob | history | |
rm_osal.h | patch | blob | history | |
src/rm.c | patch | blob | history | |
src/rm_dtb_util.c | patch | blob | history | |
src/rm_nameserver.c | patch | blob | history | |
src/rm_policy.c | patch | blob | history | |
src/rm_services.c | patch | blob | history | |
src/rm_transport.c | patch | blob | history | |
src/rm_tree.c | patch | blob | history | |
test/rm_osal.c | patch | blob | history | |
test/rm_osal.h | [deleted file] | patch | blob | history |
test/rm_test.c | patch | blob | history | |
test/rm_testproject.txt | patch | blob | history |
index c80794aa50de5b37dba252e021e3f0c4fcd35996..1c76f6fabf6e10d91ac3d3dcee542f9e370941a4 100644 (file)
Binary files a/device/tci6614-server-policy.dtb and b/device/tci6614-server-policy.dtb differ
Binary files a/device/tci6614-server-policy.dtb and b/device/tci6614-server-policy.dtb differ
index c0000526c8ad8f35f6f69ed2744320792c97eaf3..6ec77367661ad1e9a74de827edda7d2a471fe6ca 100644 (file)
/* RM Server global policy */
/ {
- /* All RM instances expected to be resource assignees within the policy. RM will fail at init if
- * it finds a resource assignee that is not in the user-instances list */
- valid-instances = "RM_Server",
- "RM_Client_Delegate",
- "RM_Client";
+ /* All RM instances expected to be resource assignees within the policy. RM will fail at init if
+ * it finds a resource assignee that is not in the user-instances list */
+ valid-instances = "RM_Server",
+ "RM_Client_Delegate",
+ "RM_Client";
- /* RM will deny any resource requests for resources not defined in the policy. */
+ /* RM will deny any resource requests for resources not defined in the policy. */
/* Format for assigning resources to specific RM instances */
qmss {
assignments = <0 512>, "iux = (*)";
};
aif-queue {
- assignments = <512 128>, "iux = (*)";
+ /* Give 525 shared permissions to match static policy permissions given to Client and CD.
+ * Otherwise Client will get locked out */
+ assignments = <512 13>, "iux = (*)",
+ <525 1>, "iu = (*)",
+ <526 114>, "iux = (*)";
};
pass-queue {
assignments = <640 9>, "iux = (*)";
pa-lut {
assignments = <0 5>, "iux = (*)";
};
-
};
-
index 2d01b611c859b6b0460b3662b6a06b620a3e5ee4..574204b5848d813c91269a35f6e5b3e79b40521f 100644 (file)
Binary files a/device/tci6614-static-policy.dtb and b/device/tci6614-static-policy.dtb differ
Binary files a/device/tci6614-static-policy.dtb and b/device/tci6614-static-policy.dtb differ
index 515b3ac5ca3d794e95c6e9ec70fcb99375dc1573..9c5c342bdda918081ced16e61e64bb9c1d75a057 100644 (file)
/* Client static policy */
/ {
- /* All RM instances expected to request static resources prior to RM's complete configuration */
- valid-instances = "RM_Client_Delegate",
- "RM_Client";
+ /* All RM instances expected to request static resources prior to RM's complete configuration */
+ valid-instances = "RM_Client_Delegate",
+ "RM_Client";
/* Assign static resources */
qmss {
memory_regions {
- assignments = <12 1>, "iux = (RM_Client_Delegate)"; /* Test validating a resource not allowed in global policy */
+ /* Test validating a resource not allowed in global policy */
+ assignments = <12 1>, "iux = (RM_Client_Delegate)";
};
qos-cluster {
assignments = <0 1>, "iux = (RM_Client_Delegate RM_Client)",
- <1 1>, "iu = (RM_Client_Delegate)",
- <2 1>, "iu = (RM_Client)";
+ <1 1>, "iu = (RM_Client_Delegate)",
+ <2 1>, "iu = (RM_Client)";
};
aif-queue {
- assignments = <525 1>, "iu = (RM_Client_Delegate RM_Client)";
+ assignments = <525 1>, "iu = (RM_Client_Delegate RM_Client)";
};
};
};
diff --git a/include/rm_loc.h b/include/rm_loc.h
index df6fb1113e8ab516b208e9de075d1977a1e7b663..8ae409064e6eb7a22404c02d1c05601efc4c613e 100644 (file)
--- a/include/rm_loc.h
+++ b/include/rm_loc.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>
#include <ti/drv/rm/include/rm_treeloc.h>
/** Transaction state. The codes are externally visible and tracked
* in rmservices.h */
int32_t state;
+ /** Transaction has been forwarded to CD or Server instance. Waiting for response */
+ bool hasBeenForwarded;
/** Name of the RM instance the service originated from */
char serviceSrcInstName[RM_NAME_MAX_CHARS];
/** Resource information */
typedef struct {
void *staticPolicy;
Rm_PolicyValidInstTree *staticValidInstTree;
- Rm_ServiceStaticReq *staticReqList;
} Rm_StaticInfo;
typedef struct {
char instName[RM_NAME_MAX_CHARS];
Rm_InstType instType;
+ /* Instance locks if static request fails when checked against global policy */
+ bool isLocked;
Rm_ServiceHandle *serviceHandle;
bool registeredWithDelegateOrServer;
void *policy;
diff --git a/include/rm_policyloc.h b/include/rm_policyloc.h
index 8caf61bc1bfc9fb468da2c715f5f612948c7045c..dc7fbf9daf4dba4e30b32364b6b93bebbe3050a6 100644 (file)
--- a/include/rm_policyloc.h
+++ b/include/rm_policyloc.h
int32_t rmPolicyGetResourceOffset(void *policyDtb, char *resourceName);
int32_t rmPolicyValidatePolicyResourceNames(void *policyDtb, void *allocatorList);
int32_t rmPolicyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree);
-Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *result);
+Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, bool addLinux, int32_t *result);
void rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree);
#ifdef __cplusplus
diff --git a/include/rm_servicesloc.h b/include/rm_servicesloc.h
--- a/include/rm_servicesloc.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * file rm_servicesloc.h
- *
- * Private data structures of Resource Manager services layer.
- *
- * ============================================================================
- * (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_SERVICESLOC_H_
-#define RM_SERVICESLOC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* RM external includes */
-#include <ti/drv/rm/rm_services.h>
-
-typedef struct Rm_ServiceStaticReq_s {
- Rm_ServiceReqInfo *staticReq;
- struct Rm_ServiceStaticReq_s *nextStaticReq;
-} Rm_ServiceStaticReq;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RM_SERVICESLOC_H_ */
-
index 8c7f19f5e5151dc1189c83e3c9d0a111972b43c7..85c120ecb26d9b08f83de49f7fe2c21f4e97e86f 100644 (file)
* packet. This ID should be associated with a transaction stored in
* the RM instance that sent the resource request packet */
uint32_t responseId;
- /** State of the request. Resource request, denied, or error. The
+ /** State of the request. Resource request denied, or error. The
* return values are externally visible so they're tracked in rmservice.h */
int32_t requestState;
/* Resource response information */
* packet. This ID should be associated with a transaction stored in
* the RM instance that sent the resource request packet */
uint32_t responseId;
- /** State of the request. Resource request, denied, or error. The
+ /** State of the request. Resource request denied, or error. The
* return values are externally visible so they're tracked in rmservice.h */
int32_t requestState;
} Rm_NsResponsePkt;
index ca6f1d2811a586fd4702a4f21beb6cc86dcbb2cd..87d6920500b5210e501fc402993c282fe62a380e 100644 (file)
--- a/rm.h
+++ b/rm.h
@defgroup RM_SERVICES_API RM Registered Component Services API
@ingroup RM_API
*/
+/**
+@defgroup RM_OSAL_API RM OS Abstraction Layer API
+@ingroup RM_API
+*/
-/* TODO: CANT CONFLICT WITH OTHER ERROR CODES INCLUDING LIBFDT */
-#define RM_INIT_OK 0
-#define RM_INIT_ERROR_INSTANCE_NAME_TOO_BIG -256
-#define RM_INIT_ERROR_POLICY_NO_VALID_INSTANCES_DEFINED -257
-#define RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE -258
-#define RM_INIT_ERROR_POLICY_PERMISSION_SYNTAX_ERROR -259
-#define RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE -260
-#define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_INSTANCE_GROUP -261
-#define RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_ASSIGNMENT_CHAR -262
-#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_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
-#define RM_INIT_ERROR_SERVICE_HANDLE_MEMORY_ALLOC_FAILED -272
-#define RM_INIT_ERROR_SERVICE_HANDLE_ALREADY_ALLOCATED -273
-#define RM_INIT_ERROR_SERVICE_HANDLE_ALREADY_CLOSED_FOR_INSTANCE -274
-#define RM_INIT_ERROR_UNKNOWN_RESOURCE_LIST_PROPERTY_TYPE -275
-#define RM_INIT_ERROR_ALLOCATOR_DOES_NOT_EXIST -276
-#define RM_INIT_ERROR_RESOURCE_OVERLAP_WHEN_CREATING_ALLOCATOR -277
-#define RM_INIT_ERROR_COULD_NOT_LOCATE_RESOURCE_IN_LINUX_DTB -278
+/**
+@addtogroup RM_API
+@{
+*/
-/** RM Service Request State Codes and Errors */
-/** RM Service Request State Code Base */
-#define RM_SERVICE_STATE_BASE (0)
-/** RM internal state okay - This value is for internal use by RM. It should never be
- * seen as a return value during normal operation */
-#define RM_SERVICE_STATE_OKAY (RM_SERVICE_STATE_BASE)
-/** RM service is being processed. Typically this means the service is
- * being sent to a higher level RM agent for processing */
-#define RM_SERVICE_PROCESSING (RM_SERVICE_STATE_BASE+1)
-/** RM service was approved. The resource data in the response is valid if
- * the service has been approved. */
-#define RM_SERVICE_APPROVED_AND_COMPLETED (RM_SERVICE_STATE_BASE+2)
-/** Beginning of resource denied reasons */
-#define RM_SERVICE_DENIED_BEGIN (RM_SERVICE_STATE_BASE+3)
-/** RM could not find an allocator for the resource specified with the provided name */
-#define RM_SERVICE_DENIED_RESOURCE_DOES_NOT_EXIST (RM_SERVICE_DENIED_BEGIN)
-/** A resource value within the specifed base+range could not be found within the resource's
- * allocator. No action was taken on the resources. */
-#define RM_SERVICE_DENIED_RESOURCE_VALUE_RANGE_DOES_NOT_EXIST (RM_SERVICE_DENIED_BEGIN+1)
-/** A resource value within the specifed base+range was not allocated to the RM instance
- * that is the source of the request. No action was taken on the resources. */
-#define RM_SERVICE_DENIED_RESOURCE_NOT_ALLOCATED_TO_INSTANCE_REQUESTING_THE_SERVICE (RM_SERVICE_DENIED_BEGIN+2)
-/** A resource value within the specifed base+range is already free */
-#define RM_SERVICE_DENIED_RESOURCE_ALREADY_FREE (RM_SERVICE_DENIED_BEGIN+3)
-/** A resource value within the specifed base+range is already allocated to another
- * RM instance. */
-#define RM_SERVICE_DENIED_RESOURCE_ALREADY_ALLOCATED (RM_SERVICE_DENIED_BEGIN+4)
-/** The resource range specified for freeing included free and allocated resoruces. */
-#define RM_SERVICE_DENIED_INVALID_RESOURCE_RANGE (RM_SERVICE_DENIED_BEGIN+5)
-/** No free resource ranges could be found that satisfy the resource base, length, and
- * alignment requirements */
-#define RM_SERVICE_DENIED_RESOURCE_ALLOCATION_REQUIREMENTS_COULD_NOT_BE_SATISFIED (RM_SERVICE_DENIED_BEGIN+6)
-/** The RM instance requesting the service is not defined in the policy */
-#define RM_SERVICE_DENIED_RM_INST_NOT_DEFINED_IN_POLICY (RM_SERVICE_DENIED_BEGIN+7)
-/** The resource in the service request is not defined in the policy */
-#define RM_SERVICE_DENIED_RESOURCE_NOT_DEFINED_IN_POLICY (RM_SERVICE_DENIED_BEGIN+8)
-/** The resource has multiple assigned range definitions */
-#define RM_SERVICE_DENIED_ASSIGNED_RANGE_SPECIFICATION_ERROR (RM_SERVICE_DENIED_BEGIN+9)
-/** The resource has multiple allocation size definitions */
-#define RM_SERVICE_DENIED_ALLOCATION_SIZE_SPECIFICATION_ERROR (RM_SERVICE_DENIED_BEGIN+10)
-/** The resource has multiple assigned name definitions */
-#define RM_SERVICE_DENIED_ASSIGNED_NAME_SPECIFICATION_ERROR (RM_SERVICE_DENIED_BEGIN+11)
-/** The resource has multiple allocation alignment definitions */
-#define RM_SERVICE_DENIED_ALLOCATION_ALIGNMENT_SPECIFICATION_ERROR (RM_SERVICE_DENIED_BEGIN+12)
-/** The resource node in the policy has an unknown property type */
-#define RM_SERVICE_DENIED_UNKNOWN_POLICY_PROPERTY (RM_SERVICE_DENIED_BEGIN+13)
-/** The policy does not approve of the resources requested by the RM instance in the service
- * request */
-#define RM_SERVICE_DENIED_POLICY_DENIAL (RM_SERVICE_DENIED_BEGIN+14)
-/** Attempt to add object to NameServer denied: The object name already exists in the NameServer */
-#define RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS (RM_SERVICE_DENIED_BEGIN+15)
-/** No valid ranges were specified for the resource within the RM instance's node within the policy.
- * By default all resource requests for this resource are denied */
-#define RM_SERVICE_DENIED_POLICY_DENIAL_NO_RANGES_SPECIFIED (RM_SERVICE_DENIED_BEGIN+16)
-/** The instance name of the service requesting instance is not in the policy valid instance list */
-#define RM_SERVICE_DENIED_ORIGINATING_INSTANCE_NAME_NOT_VALID (RM_SERVICE_DENIED_BEGIN+17)
-/** The policy does not specify any assignment ranges for the resource in the service request */
-#define RM_SERVICE_DENIED_NO_RANGE_ASSIGNMENTS_FOR_POLICY (RM_SERVICE_DENIED_BEGIN+18)
-/** The resource couldn't be allocated because the requesting instance was not given the init/use
- * permissions in the policy */
-#define RM_SERVICE_DENIED_INIT_USE_PERMISSION_DENIED (RM_SERVICE_DENIED_BEGIN+19)
-/** The resource couldn't be allocated because the requesting instance has exclusive privileges in the
- * policy but the resource was already allocated */
-#define RM_SERVICE_DENIED_REQUESTER_HAS_EXCLUSIVE_PRIV_BUT_RESOURCE_ALLOCATED (RM_SERVICE_DENIED_BEGIN+20)
-/** 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)
-/** Static request was not an allocate use or allocate init request */
-#define RM_SERVICE_DENIED_INVALID_STATIC_REQUEST (RM_SERVICE_DENIED_BEGIN+22)
-/** Startup policy denied static allocation request */
-#define RM_SERVICE_DENIED_POLICY_DENIED_STATIC_ALLOCATION (RM_SERVICE_DENIED_BEGIN+23)
-/** End of resource denied reasons */
-#define RM_SERVICE_DENIED_END (RM_SERVICE_DENIED_BEGIN+23)
+/** RM return and Error Codes */
+/** RM successful return code */
+#define RM_OK 0
+/** RM processing requested service */
+#define RM_SERVICE_PROCESSING 1
+/** RM has approved requested service */
+#define RM_SERVICE_APPROVED 2
+/** RM has approved requested service based on static policy. Request will be validated
+ * against global policy once all transports have been registered */
+#define RM_SERVICE_APPROVED_STATIC 3
-/** RM Service Request Error Code Base */
-#define RM_SERVICE_ERROR_BASE (-64)
-/** RM service request type not recognized */
-#define RM_SERVICE_ERROR_INVALID_SERVICE_TYPE (RM_SERVICE_ERROR_BASE)
-/** RM Service request was not provided a component callback
- * function. Service requests may result in blocking operations. A callback
- * function must always be provided with a service request since
- * blocked or non-blocked operations cannot be promised. */
-#define RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED (RM_SERVICE_ERROR_BASE-1)
-/** RM service request needs to be forwarded to another RM agent but no transports
- * have been registered */
-#define RM_SERVICE_ERROR_NO_TRANSPORT_REGISTERED (RM_SERVICE_ERROR_BASE-2)
-/** RM service request needs to be forwarded but no client delegate or server has
- * been registered with the RM instance */
-#define RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER (RM_SERVICE_ERROR_BASE-3)
-/** RM service request needs to be forwarded but the transport packet alloc API
- * has not been provided */
-#define RM_SERVICE_ERROR_TRANSPORT_PKT_ALLOC_API_NULL (RM_SERVICE_ERROR_BASE-4)
-/** A failure occurred within a registered transport's packet alloc API */
-#define RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR (RM_SERVICE_ERROR_BASE-5)
-/** RM service request needs to be forwarded but the transport returned an error
- * when trying to send the RM packet to the higher level agent */
-#define RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR (RM_SERVICE_ERROR_BASE-7)
-/** RM service response from higher level agent did not match any requests made
- * by the provided RM instance */
-#define RM_SERVICE_ERROR_TRANSACTION_DOES_NOT_EXIST_FOR_THIS_RM_INSTANCE (RM_SERVICE_ERROR_BASE-8)
-/** RM failed to allocate memory for new service transaction */
-#define RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE (RM_SERVICE_ERROR_BASE-9)
-/** RM could not find the service transaction in the RM instance's transaction queue */
-#define RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST (RM_SERVICE_ERROR_BASE-10)
-/** A failure occurred within a registered transport's packet free API */
-#define RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR (RM_SERVICE_ERROR_BASE-11)
-/** Invalid NameServer object modification on non-Server instance */
-#define RM_SERVICE_ERROR_NAMESERVER_OBJECT_MOD_ON_INVALID_INSTANCE (RM_SERVICE_ERROR_BASE-12)
-/** Request failed because both a NameServer name and a resource range were specified */
-#define RM_SERVICE_ERROR_NAMESERVER_NAME_AND_RESOURCE_RANGE_BOTH_DEFINED (RM_SERVICE_ERROR_BASE-13)
-/** Error occurred when trying to add an object to the NameServer */
-#define RM_SERVICE_ERROR_NAMESERVER_OBJECT_ADD_FAILED (RM_SERVICE_ERROR_BASE-14)
-/** Could not find the object specified in the service request in the NameServer */
-#define RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST (RM_SERVICE_ERROR_BASE-15)
+/** RM service request denial reasons base */
+#define RM_SERVICE_DENIED_BASE 64
+/** Request resource not found in policy or allocators */
+#define RM_SERVICE_DENIED_RES_DOES_NOT_EXIST RM_SERVICE_DENIED_BASE+1
+/** Request resource range within not found within resource's allocator */
+#define RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST RM_SERVICE_DENIED_BASE+2
+/** Free request resource range not allocated to service's source inst */
+#define RM_SERVICE_DENIED_RES_NOT_ALLOCD_TO_INST RM_SERVICE_DENIED_BASE+3
+/** Free request resource range already free */
+#define RM_SERVICE_DENIED_RES_ALREADY_FREE RM_SERVICE_DENIED_BASE+4
+/** Allocate request resource range partially allocated (Handling of partial allocations
+ * not yet implemented) */
+#define RM_SERVICE_DENIED_PARTIAL_ALLOCATION RM_SERVICE_DENIED_BASE+5
+/** Free request resource range partially free (Handling of partial frees not yet implemented) */
+#define RM_SERVICE_DENIED_PARTIAL_FREE RM_SERVICE_DENIED_BASE+6
+/** Requirements of allocate request could not be satisfied (occurs for UNSPECIFIED base
+ * and/or alignment requests */
+#define RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET RM_SERVICE_DENIED_BASE+7
+/** NameServer add request name string already exists in NameServer */
+#define RM_SERVICE_DENIED_NAME_EXISTS_IN_NS RM_SERVICE_DENIED_BASE+8
+/** Service request instance not in policy "valid-instances" list */
+#define RM_SERVICE_DENIED_INST_NAME_NOT_VALID RM_SERVICE_DENIED_BASE+9
+/** Init allocate request resource range not given init privileges in policy */
+#define RM_SERVICE_DENIED_INIT_PERM_NOT_GIVEN RM_SERVICE_DENIED_BASE+10
+/** Use allocate request resource range not given use privileges in policy */
+#define RM_SERVICE_DENIED_USE_PERM_NOT_GIVEN RM_SERVICE_DENIED_BASE+11
+/** Allocate request resource range marked as exclusive in policy has already been allocated */
+#define RM_SERVICE_DENIED_EXCLUSIVE_RES_ALLOCD RM_SERVICE_DENIED_BASE+12
+/** Allocate request resource range allocated to an instance assigned exclusive privileges in policy */
+#define RM_SERVICE_DENIED_ALLOCD_TO_EXCLUSIVE_INST RM_SERVICE_DENIED_BASE+13
+/** Static allocate request was not an allocate-use or allocate-init request */
+#define RM_SERVICE_DENIED_INVALID_STATIC_REQUEST RM_SERVICE_DENIED_BASE+14
+/** Static allocate request denied by static policy */
+#define RM_SERVICE_DENIED_BY_STATIC_POLICY RM_SERVICE_DENIED_BASE+15
+/** RM instance locked from further services since a static allocation failed validation against
+ * global policy. RM instance cannot be unlocked. Please make sure static policy and global policy
+ * are in sync */
+#define RM_SERVICE_DENIED_RM_INSTANCE_LOCKED RM_SERVICE_DENIED_BASE+16
-/** RM Transport Result Return Codes */
-/** RM Transport Success Code Base */
-#define RM_TRANSPORT_OK_BASE (0)
-/** RM transport action was successful. */
-#define RM_TRANSPORT_SUCCESSFUL (RM_TRANSPORT_OK_BASE)
+/** See libfdt.h for error codes -1 through -13 */
+#define RM_ERROR_LIBFDT_START (-1)
+/** See libfdt.h for error codes -1 through -13 */
+#define RM_ERROR_LIBFDT_END (-13)
-/** RM Transport Error Code Base */
-#define RM_TRANSPORT_ERROR_BASE (-64)
+/** RM Error Base */
+#define RM_ERROR_BASE (-64)
+/** Instance name provided is NULL or greater than RM_NAME_MAX_CHARS */
+#define RM_ERROR_INVALID_INST_NAME RM_ERROR_BASE-1
+/** List of "valid-instances" not found in global or static policy */
+#define RM_ERROR_NO_VALID_INST_IN_POLICY RM_ERROR_BASE-2
+/** Instance specified in permissions string does not match any instances specified in the
+ * "valid-instances" list */
+#define RM_ERROR_PERM_STR_INST_NOT_VALID RM_ERROR_BASE-3
+/** Resource specified in global policy does not have an allocator */
+#define RM_ERROR_UNKNOWN_RESOURCE_IN_POLICY RM_ERROR_BASE-4
+/** Permissions string has more than instance group specified.
+ * Ex: assignments = <12 1>, "iux = (RM_Client_Delegate) iu = (RM_Client)"; */
+#define RM_ERROR_PERM_STR_TOO_MANY_INST_GROUPS RM_ERROR_BASE-5
+/** Permissions string has more than assignment.
+ * Ex: assignments = <12 1>, "iux = (RM_Client_Delegate) = i"; */
+#define RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS RM_ERROR_BASE-6
+/** Permissions string contains invalid character */
+#define RM_ERROR_PERM_STR_INVALID_CHAR RM_ERROR_BASE-7
+/** Permissions string contains a permission character without the assignment operator
+ * Ex: assignments = <12 1>, "iux (RM_Client_Delegate)"; */
+#define RM_ERROR_PERM_CHAR_WITHOUT_ASSIGN_CHAR RM_ERROR_BASE-8
+/** Permissions string contains a permission character on opposite side of already made assignment
+ * Ex: assignments = <12 1>, "iux = (RM_Client_Delegate) x"; */
+#define RM_ERROR_INVALID_PERMS_CHAR_ON_RIGHT RM_ERROR_BASE-9
+/** Policy resource node contains an unknown property */
+#define RM_ERROR_UNKNOWN_POLICY_RESOURCE_PROPERTY RM_ERROR_BASE-10
+/** Instance name provided in "valid-instances" list is greater than RM_NAME_MAX_CHARS */
+#define RM_ERROR_VALID_INST_NAME_TOO_LONG RM_ERROR_BASE-11
+/** Instance name in permissions assignment is greater than RM_NAME_MAX_CHARS */
+#define RM_ERROR_INST_NAME_IN_ASSIGNMENT_TOO_LONG RM_ERROR_BASE-12
+/** NameServer name in global resource list nameServer assignment is greater than RM_NAME_MAX_CHARS */
+#define RM_ERROR_GRL_NS_ASSIGNMENT_NAME_TOO_LONG RM_ERROR_BASE-13
+/** Linux alias assignment in global resource list is invalid */
+#define RM_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT RM_ERROR_BASE-14
+/** Error allocating memory for the service handle */
+#define RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED RM_ERROR_BASE-15
+/** The RM instance service handle has already been opened */
+#define RM_ERROR_SERVICE_HANDLE_ALREADY_OPENED RM_ERROR_BASE-16
+/** The RM instance service handle has already been closed */
+#define RM_ERROR_SERVICE_HANDLE_ALREADY_CLOSED RM_ERROR_BASE-17
+/** Global Resource List (GRL) resource node contains an unknown property */
+#define RM_ERROR_GRL_UNKNOWN_RESOURCE_PROPERTY RM_ERROR_BASE-18
+/** Could not find an allocator for the specified resource */
+#define RM_ERROR_RES_ALLOCATOR_DOES_NOT_EXIST RM_ERROR_BASE-19
+/** A resource node is specified more than once in the Global Resource List (GRL) */
+#define RM_ERROR_GRL_RES_SPECIFIED_MORE_THAN_ONCE RM_ERROR_BASE-20
+/** No data was found at the GRL resource node's specified Linux alias path */
+#define RM_ERROR_DATA_NOT_FOUND_AT_LINUX_ALIAS RM_ERROR_BASE-21
+/** RM server was not provided a Global Resource List (GRL) and global policy at initialization */
+#define RM_ERROR_INVALID_SERVER_CONFIGURATION RM_ERROR_BASE-22
+/** Service request type not recognized */
+#define RM_ERROR_INVALID_SERVICE_TYPE RM_ERROR_BASE-23
+/** Service request did not contain callback function. Callback function must always be provided
+ * with service request since blocking or non-blocking operations cannot be promised. */
+#define RM_ERROR_CALLBACK_NOT_PROVIDED RM_ERROR_BASE-24
+/** rmAllocPkt transport callout returned NULL for rmPkt */
+#define RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR RM_ERROR_BASE-25
+/** rmSendPkt transport callout returned error when attempting to send the rmPkt */
+#define RM_ERROR_TRANSPORT_SEND_ERROR RM_ERROR_BASE-26
+/** A RM service transaction could not be created for the service request */
+#define RM_ERROR_SERVICE_TRANS_NOT_CREATED RM_ERROR_BASE-27
+/** RM service transaction could not be found in instance's transaction queue */
+#define RM_ERROR_SERVICE_TRANS_DOES_NOT_EXIST RM_ERROR_BASE-28
+/** NameServer does not exist in instance, cannot satisfy NameServer service request */
+#define RM_ERROR_NAMESERVER_DOES_NOT_EXIST RM_ERROR_BASE-29
+/** Service request to add a name to the NameServer failed */
+#define RM_ERROR_NAMESERVER_NAME_ADD_FAILED RM_ERROR_BASE-30
+/** Could not find name specified in service request in NameServer */
+#define RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST RM_ERROR_BASE-31
+/** Service request made on Client or CD when no transport established and no static policy registered */
+#define RM_ERROR_REQ_FAILED_NO_STATIC_POLICY RM_ERROR_BASE-32
/** 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)
-/** RM packets are available but an error was encountered during reception */
-#define RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR (RM_TRANSPORT_ERROR_BASE-3)
+#define RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST RM_ERROR_BASE-33
/** RM received a packet with an unknown RM packet type */
-#define RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE (RM_TRANSPORT_ERROR_BASE-4)
-/** RM resource request transaction could not be found matching the response received */
-#define RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-5)
-/** RM NameServer request transaction could not be found matching the response received */
-#define RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-6)
-/** RM server cannot connect to other servers and CDs cannot connect to other CDs */
-#define RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE (RM_TRANSPORT_ERROR_BASE-7)
-/** RM clients can't register with more than one Server or CD. CDs can't register with more than one Server */
-#define RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD (RM_TRANSPORT_ERROR_BASE-8)
-/** Transport callouts provided to RM were specified as valid but NULL was provided */
-#define RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED (RM_TRANSPORT_ERROR_BASE-10)
+#define RM_ERROR_RECEIVED_INVALID_PACKET_TYPE RM_ERROR_BASE-34
+/** RM response packet does not match any requests sent from instance */
+#define RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ RM_ERROR_BASE-35
+/** Server attempted to connect to another server or a CD attempted to connect to another CD or
+ * Client attempted to connect to another client */
+#define RM_ERROR_INVALID_REMOTE_INST_TYPE RM_ERROR_BASE-36
+/** RM client attempted to register with more than one Server or CD or a CD attempted to register
+ * with more than one Server */
+#define RM_ERROR_ALREADY_REGD_SERVER_OR_CD RM_ERROR_BASE-37
+/** Transport registration callout function pointers specified as valid but were NULL */
+#define RM_ERROR_NULL_CALLOUTS_WHEN_VALID RM_ERROR_BASE-38
+/** Service both a NameServer name and a base, length, or alignment */
+#define RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT RM_ERROR_BASE-39
+/** Instance type not recognized */
+#define RM_ERROR_INVALID_INST_TYPE RM_ERROR_BASE-40
+/** Linux DTB alias properties specified in GRL but not Linux DTB provided during server instance init */
+#define RM_ERROR_GRL_LINUX_ALIAS_BUT_NO_DTB RM_ERROR_BASE-41
/**
* @brief Maximum number of characters allowed for RM instance, resource, and
*/
typedef void *Rm_Handle;
-typedef void *Rm_PreMainHandle;
-
/**
* @brief RM Instance types
*/
/** RM Server */
Rm_instType_SERVER = 0,
/** RM Client Delegate */
- Rm_instType_CLIENT_DELEGATE = 1,
+ Rm_instType_CLIENT_DELEGATE,
/** RM Client */
- Rm_instType_CLIENT = 2
+ Rm_instType_CLIENT,
+ /** DO NOT USE: Last type */
+ Rm_instType_LAST
} Rm_InstType;
-/**
- * @brief RM instance initialization structure
- */
typedef struct {
- /** Pointer to RM instance name character array. The name of the RM instance must
- * be reflected exactly in the initial RM policies provided to the RM
- * tree's Servers and Client Delegates. The RM instance name is
- * used by the policy to map which instances are allowed defined
- * privileges */
- char *instName;
- /** RM instance type. Defines whether the RM instance will be initialized
- * as a RM Server, Client Delegate, or Client */
- Rm_InstType instType;
/** [Server Parameter] Pointer to the device-wide resource list. The list
* contains all resources available on the device available for
* allocation. Servers running on ARM-Linux cores provide a subset
* Note: This parameter will be ignored when the instance type is either
* Client Delegate or Client */
void *linuxDtb;
- /** [Server/Client Delegate Paramter] Pointer to the allocation
+ /** [Server Paramter] Pointer to the allocation
* policy. RM Servers should be initialized with the global policy
* listing for all RM instances within the system. RM Client Delegates
* can be initialized with their local policy, must be a subset of the
* Note: This parameter will be ignored when the instance type is a
* Client
*/
- void *dynamicPolicy;
+ void *globalPolicy;
+} Rm_ServerCfg;
+
+typedef struct {
/** static policy used for pre-main allocation of resources. Resources given
* in the static will be verified against the global policy once the RM
* system is fully initialized */
void *staticPolicy;
-} Rm_InitCfg;
-
-/* TESTING PURPOSES: SERVER ONLY */
-void Rm_printResourceStatus(Rm_Handle *rmHandle);
+} Rm_ClientDelegateCfg;
-Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *result);
+typedef struct {
+ /** static policy used for pre-main allocation of resources. Resources given
+ * in the static will be verified against the global policy once the RM
+ * system is fully initialized */
+ void *staticPolicy;
+} Rm_ClientCfg;
+/**
+ * @brief RM instance initialization structure
+ */
+typedef struct {
+ /** Pointer to RM instance name character array. The name of the RM instance must
+ * be reflected exactly in the initial RM policies provided to the RM
+ * tree's Servers and Client Delegates. The RM instance name is
+ * used by the policy to map which instances are allowed defined
+ * privileges */
+ char *instName;
+ /** RM instance type. Defines whether the RM instance will be initialized
+ * as a RM Server, Client Delegate, or Client */
+ Rm_InstType instType;
+ union {
+ Rm_ServerCfg serverCfg;
+ Rm_ClientDelegateCfg cdCfg;
+ Rm_ClientCfg clientCfg;
+ } instCfg;
+} Rm_InitCfg;
-int32_t Rm_validateStaticRequests(Rm_Handle rmHandle);
+/**
+@}
+*/
-/**
- * @b Description
- * @n
- * This function initializes a RM instance.
- *
- * IMPORTANT: Rm_init must be called prior to any other component startup
- * APIs (BIOS_start, Ipc_start, etc).
- *
- * @param[in] *initCfg
- * Pointer to structure containing the initialization information for
- * this RM instance.
- *
- * @param[in] *result
- * Pointer to a uint32_t that will contain the result of the RM
- * intialization and handle creation. Any errors encountered will be
- * returned via this pointer.
- *
- * @retval
- * Success - non-zero Rm_Handle returned.
- * @retval
- * Failure - NULL Rm_handle returned.
- */
+void Rm_printResourceStatus(Rm_Handle *rmHandle);
Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result);
-
-/**
- * @b Description
- * @n
- * The function is used to get the version information of the RM.
- *
- * @retval
- * Version Information.
- */
uint32_t Rm_getVersion (void);
-
-/**
- * @b Description
- * @n
- * The function is used to get the version string for the RM.
- *
- * @retval
- * Version String.
- */
const char* Rm_getVersionStr (void);
#ifdef __cplusplus
diff --git a/rm_osal.h b/rm_osal.h
index 12ed993d769e693d2acfb5ee5454425c7957cdbf..6bf8bde7b863857313fecb1e24df7b776daf92df 100644 (file)
--- a/rm_osal.h
+++ b/rm_osal.h
*
* \par
* NOTE:
- * (C) Copyright 2012 Texas Instruments, Inc.
+ * (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
#ifndef __RM_OSAL_H__
#define __RM_OSAL_H__
-/** @addtogroup RM_LLD_OSAL
- @{ */
+/** @addtogroup RM_OSAL_API
+ @{
+ */
/**********************************************************************
************************* Extern Declarations ************************
**********************************************************************/
-/* #include <string.h> is here because there used to be
- * memcpy/memset prototypes here. This #include prevents warnings in
- * other code that unintentionally worked because of these prototypes
- */
-#include <xdc/runtime/System.h>
-
-
extern void* Osal_rmMalloc (uint32_t num_bytes);
extern void Osal_rmFree (void *ptr, uint32_t size);
-extern void* Osal_rmCsEnter (void);
-extern void Osal_rmCsExit (void *CsHandle);
-extern void* Osal_rmMtCsEnter (void);
-extern void Osal_rmMtCsExit (void *CsHandle);
-//extern void Osal_rmLog (char *fmt, ... );
-extern void Osal_rmBeginMemAccess (void *ptr, uint32_t size);
-extern void Osal_rmEndMemAccess (void *ptr, uint32_t size);
+extern void Osal_rmLog (char *fmt, ... );
/**
* @brief The macro is used by the RM LLD to allocate memory of specified
#define Rm_osalFree Osal_rmFree
-/**
- * @brief The macro is used by the RM LLD to provide critical sections to
- * protect global and shared variables from
- *
- * access from multiple cores
- * and
- * access from multiple threads on single core
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void* Osal_rmCsEnter (void)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n None.
- *
- * <b> Return Value </b>
- * @n Handle used to lock critical section.
- */
-#define Rm_osalCsEnter Osal_rmCsEnter
-
-/**
- * @brief The macro is used by the RM LLD to exit a critical section
- * protected using Osal_rmCsEnter() API.
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void Osal_rmCsExit (void *CsHandle)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n Handle for unlocking critical section.
- *
- * <b> Return Value </b>
- * @n Not applicable.
- */
-#define Rm_osalCsExit Osal_rmCsExit
-
-/**
- * @brief The macro is used by the RM LLD to provide critical sections to
- * protect global and shared variables from
- *
- * access from multiple threads on single core
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void* Osal_rmMtCsEnter (void)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n None.
- *
- * <b> Return Value </b>
- * @n Handle used to lock critical section.
- */
-#define Rm_osalMtCsEnter Osal_rmMtCsEnter
-
-/**
- * @brief The macro is used by the RM LLD to exit a critical section
- * protected using Osal_rmMtCsEnter() API.
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void Osal_rmMtCsExit (void *CsHandle)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n Handle for unlocking critical section.
- *
- * <b> Return Value </b>
- * @n Not applicable.
- */
-#define Rm_osalMtCsExit Osal_rmMtCsExit
-
/**
* @brief The macro is used by the RM LLD to log various
* messages.
* <b> Return Value </b>
* @n Not applicable.
*/
-#define Rm_osalLog System_printf
-
-/**
- * @brief The macro is used by the RM LLD to indicate that a block
- * of memory is about to be accessed. If the memory block is cached then
- * this indicates that the application would need to ensure that the cache
- * is updated with the data from the actual memory.
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void Osal_rmBeginMemAccess (void *ptr, uint32_t size)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n Address of memory block.
- * @n Size of memory block.
- *
- * <b> Return Value </b>
- * @n Not applicable.
- */
-#define Rm_osalBeginMemAccess Osal_rmBeginMemAccess
-
-/**
- * @brief The macro is used by the RM LLD to indicate that the block of
- * memory has finished being accessed. If the memory block is cached then the
- * application would need to ensure that the contents of the cache are updated
- * immediately to the actual memory.
- *
- * <b> Prototype: </b>
- * The following is the C prototype for the expected OSAL API.
- *
- * @verbatim
- void Osal_rmEndMemAccess (void *ptr, uint32_t size)
- @endverbatim
- *
- * <b> Parameter </b>
- * @n Address of memory block.
- * @n Size of memory block.
- *
- * <b> Return Value </b>
- * @n Not applicable.
- */
-#define Rm_osalEndMemAccess Osal_rmEndMemAccess
+#define Rm_osalLog Osal_rmLog
/**
@}
diff --git a/src/rm.c b/src/rm.c
index 3dfb2bb8b288439ef4019f47962ebb3c57110f0c..2ebbb3f39cf791580999e0f894654fbe15dd89a8 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
/* RM internal includes */\r
#include <ti/drv/rm/include/rm_loc.h>\r
#include <ti/drv/rm/include/rm_transportloc.h>\r
-#include <ti/drv/rm/include/rm_servicesloc.h>\r
#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
{\r
Rm_Transaction *transaction = rmInst->transactionQueue;\r
Rm_Transaction *prevTransaction = NULL;\r
- int32_t retVal = RM_SERVICE_STATE_OKAY;\r
+ int32_t retVal = RM_OK;\r
\r
while (transaction) {\r
if (transaction->localId == transactionId) {\r
Rm_osalFree((void *)transaction, sizeof(Rm_Transaction));\r
}\r
else {\r
- retVal = RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST;\r
+ retVal = RM_ERROR_SERVICE_TRANS_DOES_NOT_EXIST;\r
} \r
return (retVal);\r
}\r
Rm_Allocator *rmAllocatorFind(Rm_Allocator *allocatorList, char *resourceName)\r
{\r
while (allocatorList) {\r
- if (strcmp(allocatorList->resourceName, resourceName) == 0) {\r
+ if (strncmp(allocatorList->resourceName, resourceName, RM_NAME_MAX_CHARS) == 0) {\r
break; \r
}\r
allocatorList = allocatorList->nextAllocator;\r
{\r
Rm_Allocator *allocator = rmInst->allocators;\r
Rm_Allocator *prevAllocator = NULL;\r
- int32_t retVal = RM_SERVICE_STATE_OKAY;\r
+ int32_t retVal = RM_OK;\r
\r
while (allocator) {\r
- if (strcmp(allocator->resourceName, resourceName) == 0) {\r
+ if (strncmp(allocator->resourceName, resourceName, RM_NAME_MAX_CHARS) == 0) {\r
break; \r
}\r
prevAllocator = allocator;\r
Rm_osalFree((void *)allocator, sizeof(Rm_Allocator));\r
}\r
else {\r
- retVal = RM_INIT_ERROR_ALLOCATOR_DOES_NOT_EXIST;\r
+ retVal = RM_ERROR_RES_ALLOCATOR_DOES_NOT_EXIST;\r
}\r
return (retVal);\r
}\r
\r
while (owner) {\r
if (owner->instNameNode == serviceInstNode) {\r
- return(TRUE); \r
+ return(true); \r
}\r
owner = owner->nextOwner;\r
}\r
- return(FALSE);\r
+ return(false);\r
}\r
\r
bool rmCompareResourceNodeOwners(Rm_ResourceNode *node1, Rm_ResourceNode *node2)\r
@@ -287,10 +286,10 @@ bool rmCompareResourceNodeOwners(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
\r
if (node1->allocationCount == node2->allocationCount) {\r
while (node1Owners) {\r
- matchedInst = FALSE;\r
+ matchedInst = false;\r
while (node2Owners) {\r
if (node1Owners->instNameNode == node2Owners->instNameNode) {\r
- matchedInst = TRUE;\r
+ matchedInst = true;\r
break;\r
}\r
node2Owners = node2Owners->nextOwner;\r
@@ -301,15 +300,15 @@ bool rmCompareResourceNodeOwners(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
node1Owners = node1Owners->nextOwner;\r
}\r
else {\r
- return(FALSE);\r
+ return(false);\r
} \r
}\r
}\r
else {\r
- return(FALSE);\r
+ return(false);\r
} \r
\r
- return(TRUE);\r
+ return(true);\r
}\r
\r
void rmDeleteOwner(Rm_ResourceNode *node, void *serviceInstNode)\r
@@ -400,13 +399,13 @@ int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Reso
}\r
Rm_osalFree((void *)treeRootEntry, sizeof(Rm_ResourceTree));\r
rmAllocatorDelete(rmInst, allocator->resourceName);\r
- return (RM_INIT_ERROR_RESOURCE_OVERLAP_WHEN_CREATING_ALLOCATOR);\r
+ return (RM_ERROR_GRL_RES_SPECIFIED_MORE_THAN_ONCE);\r
}\r
range = range->nextRange;\r
}\r
\r
allocator->allocatorRootEntry = treeRootEntry;\r
- return(RM_INIT_OK);\r
+ return(RM_OK);\r
}\r
\r
/* Called when an allocate request is made but the base is unspecified. RM must preallocate\r
@@ -421,7 +420,7 @@ int32_t rmTreePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t reso
Rm_ResourceNode *matchingNode = NULL;\r
uint32_t matchingEnd;\r
uint32_t rangeIndex;\r
- bool resourceFound = FALSE;\r
+ bool resourceFound = false;\r
Rm_PolicyCheckType policyCheckType;\r
Rm_PolicyCheckCfg policyCheckCfg;\r
bool nodePassesPolicy;\r
@@ -462,7 +461,7 @@ int32_t rmTreePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t reso
matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);\r
\r
if (matchingNode) {\r
- nodePassesPolicy = FALSE;\r
+ nodePassesPolicy = false;\r
policyCheckCfg.type = policyCheckType;\r
policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
policyCheckCfg.resourceBase = findNode.base;\r
@@ -501,7 +500,7 @@ int32_t rmTreePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t reso
/* Block of unallocated resources within matchingNode that satisfies\r
* allocate requirements */\r
opInfo->resourceInfo->base = rangeIndex;\r
- resourceFound = TRUE;\r
+ resourceFound = true;\r
} \r
}\r
\r
@@ -511,10 +510,10 @@ int32_t rmTreePreAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t reso
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_ALLOCATION_REQUIREMENTS_COULD_NOT_BE_SATISFIED;\r
+ retVal = RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET;\r
}\r
} while ((!resourceFound) && \r
- (retVal != RM_SERVICE_DENIED_RESOURCE_ALLOCATION_REQUIREMENTS_COULD_NOT_BE_SATISFIED));\r
+ (retVal != RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET));\r
\r
return(retVal); \r
}\r
@@ -529,8 +528,8 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
Rm_PolicyCheckType policyCheckType; \r
Rm_PolicyCheckCfg policyCheckCfg;\r
bool allocPassesPolicy;\r
- bool combineLeft = FALSE;\r
- bool combineRight = FALSE; \r
+ bool combineLeft = false;\r
+ bool combineRight = false; \r
uint32_t findEnd;\r
uint32_t matchingEnd; \r
int32_t retVal = RM_SERVICE_PROCESSING;\r
@@ -556,7 +555,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {\r
if (opInfo->serviceSrcInstNode == rmPolicyGetLinuxInstNode(rmInst->validInstances)) {\r
/* Bypass policy checks since Linux Kernel has full privileges */\r
- allocPassesPolicy = TRUE;\r
+ allocPassesPolicy = true;\r
}\r
else {\r
policyCheckCfg.policyDtb = rmInst->policy;\r
@@ -567,7 +566,12 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
policyCheckCfg.resourceLength = findNode.length;\r
allocPassesPolicy = rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
if (!allocPassesPolicy) {\r
- retVal = RM_SERVICE_DENIED_INIT_USE_PERMISSION_DENIED;\r
+ if (policyCheckType == Rm_policyCheck_INIT) {\r
+ retVal = RM_SERVICE_DENIED_INIT_PERM_NOT_GIVEN;\r
+ }\r
+ else {\r
+ retVal = RM_SERVICE_DENIED_USE_PERM_NOT_GIVEN;\r
+ }\r
}\r
\r
if (allocPassesPolicy && (matchingNode->allocationCount > 0)) {\r
@@ -577,7 +581,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;\r
allocPassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg, &retVal);\r
if (!allocPassesPolicy) {\r
- retVal = RM_SERVICE_DENIED_REQUESTER_HAS_EXCLUSIVE_PRIV_BUT_RESOURCE_ALLOCATED;\r
+ retVal = RM_SERVICE_DENIED_EXCLUSIVE_RES_ALLOCD;\r
}\r
}\r
if (allocPassesPolicy && (matchingNode->allocationCount == 1)) {\r
@@ -586,7 +590,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
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
+ retVal = RM_SERVICE_DENIED_ALLOCD_TO_EXCLUSIVE_INST;\r
} \r
} \r
}\r
@@ -605,11 +609,11 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
\r
if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
- combineLeft = TRUE;\r
+ combineLeft = true;\r
}\r
if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
- combineRight = TRUE;\r
+ combineRight = true;\r
}\r
\r
if (combineLeft && combineRight) {\r
@@ -731,15 +735,15 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc
rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode);\r
RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
}\r
- retVal = RM_SERVICE_APPROVED_AND_COMPLETED;\r
+ retVal = RM_SERVICE_APPROVED;\r
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_ALREADY_ALLOCATED;\r
+ retVal = RM_SERVICE_DENIED_PARTIAL_ALLOCATION;\r
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_VALUE_RANGE_DOES_NOT_EXIST;\r
+ retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;\r
}\r
\r
return(retVal); \r
Rm_ResourceNode *matchingNode = NULL;\r
Rm_ResourceNode *leftNode = NULL;\r
Rm_ResourceNode *rightNode = NULL;\r
- bool combineLeft = FALSE;\r
- bool combineRight = FALSE;\r
+ bool combineLeft = false;\r
+ bool combineRight = false;\r
uint32_t findEnd;\r
uint32_t matchingEnd;\r
int32_t retVal;\r
\r
if (leftNode && rmCompareResourceNodeOwners(leftNode, matchingNode)) {\r
RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode);\r
- combineLeft = TRUE;\r
+ combineLeft = true;\r
}\r
if (rightNode && rmCompareResourceNodeOwners(rightNode, matchingNode)) {\r
RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode);\r
- combineRight = TRUE;\r
+ combineRight = true;\r
}\r
\r
if (combineLeft && combineRight) {\r
RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode);\r
}\r
\r
- retVal = RM_SERVICE_APPROVED_AND_COMPLETED;\r
+ retVal = RM_SERVICE_APPROVED;\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_NOT_ALLOCATED_TO_INSTANCE_REQUESTING_THE_SERVICE;\r
+ retVal = RM_SERVICE_DENIED_RES_NOT_ALLOCD_TO_INST;\r
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_ALREADY_FREE;\r
+ retVal = RM_SERVICE_DENIED_RES_ALREADY_FREE;\r
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_INVALID_RESOURCE_RANGE;\r
+ retVal = RM_SERVICE_DENIED_PARTIAL_FREE;\r
}\r
}\r
else {\r
- retVal = RM_SERVICE_DENIED_RESOURCE_VALUE_RANGE_DOES_NOT_EXIST;\r
+ retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;\r
}\r
return(retVal); \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
+ retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;\r
}\r
return(retVal);\r
}\r
\r
void rmAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode,\r
- uint32_t allocType)\r
+ uint32_t allocType)\r
{\r
Rm_AllocatorOpInfo opInfo;\r
Rm_NameServerObjCfg nameServerObjCfg;\r
@@ -974,21 +978,21 @@ void rmAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *va
memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
\r
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
- /* TEMP: For now forward all allocations to the RM Server */\r
- rmTransactionForwarder(rmInst, transaction);\r
- \r
+ /* Forward all allocation requests to Server if transport is up. Otherwise, just queue. */\r
+ if (rmInst->registeredWithDelegateOrServer) {\r
+ rmTransactionForwarder(rmInst, transaction); \r
+ } \r
}\r
else if (rmInst->instType == Rm_instType_SERVER) {\r
opInfo.resourceInfo = &transaction->resourceInfo;\r
opInfo.serviceSrcInstNode = validInstNode;\r
opInfo.allocType = allocType;\r
\r
+ /* Populated NameServer name has precedence over base */\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
+ if ((transaction->resourceInfo.base == 0) &&\r
+ (transaction->resourceInfo.length == 0) &&\r
+ (transaction->resourceInfo.alignment == 0)) {\r
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
@@ -998,6 +1002,9 @@ void rmAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *va
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
} \r
}\r
+ else {\r
+ retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;\r
+ }\r
}\r
\r
if (retVal == RM_SERVICE_PROCESSING) { \r
@@ -1014,7 +1021,7 @@ void rmAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *va
\r
transaction->state = retVal;\r
\r
- if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
/* Source of allocation was not the server instance, provide the transaction\r
* to the transaction responder */\r
rmTransactionResponder(rmInst, transaction);\r
@@ -1032,19 +1039,20 @@ void rmFreeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIns
memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
\r
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
- /* TEMP: Forward all free requests to the Server */\r
- rmTransactionForwarder(rmInst, transaction); \r
+ /* Forward all free requests to Server if transport is up. Otherwise, just queue. */\r
+ if (rmInst->registeredWithDelegateOrServer) {\r
+ rmTransactionForwarder(rmInst, transaction); \r
+ }\r
}\r
else if (rmInst->instType == Rm_instType_SERVER) {\r
opInfo.resourceInfo = &transaction->resourceInfo;\r
opInfo.serviceSrcInstNode = validInstNode;\r
\r
+ /* Populated NameServer name has precedence over base */\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
+ if ((transaction->resourceInfo.base == 0) &&\r
+ (transaction->resourceInfo.length == 0) &&\r
+ (transaction->resourceInfo.alignment == 0)) {\r
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));\r
nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
@@ -1052,9 +1060,11 @@ void rmFreeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIns
strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);\r
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
- } \r
+ } \r
}\r
-\r
+ else {\r
+ retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;\r
+ } \r
}\r
\r
if(retVal == RM_SERVICE_PROCESSING) { \r
@@ -1064,7 +1074,7 @@ void rmFreeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validIns
\r
transaction->state = retVal;\r
\r
- if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
/* Source of allocation was not the server instance, provide the transaction\r
* to the transaction responder */\r
rmTransactionResponder(rmInst, transaction);\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
+ if ((serviceResponse.serviceState == RM_SERVICE_APPROVED) &&\r
((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
(transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))\r
}\r
\r
if (pktHandle) {\r
- if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
+ if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {\r
+ transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;\r
}\r
}\r
rmTransactionQueueDelete(rmInst, transaction->localId);\r
@@ -1143,156 +1153,216 @@ void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
Rm_Transport *dstTransport = NULL;\r
Rm_PacketHandle pktHandle = NULL;\r
\r
- if (rmInst->registeredWithDelegateOrServer == false) {\r
- transaction->state = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER;\r
- return;\r
- }\r
-\r
- if (rmInst->instType == Rm_instType_CLIENT) {\r
- dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_CLIENT_DELEGATE);\r
+ if (rmInst->registeredWithDelegateOrServer) {\r
+ if (rmInst->instType == Rm_instType_CLIENT) {\r
+ dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_CLIENT_DELEGATE);\r
\r
- if (!dstTransport) {\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
dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);\r
}\r
- } \r
- else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {\r
- dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);\r
- }\r
\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
- pktHandle = rmTransportCreateResourceReqPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
- break;\r
- case Rm_service_RESOURCE_MAP_TO_NAME:\r
- case Rm_service_RESOURCE_UNMAP_NAME:\r
- pktHandle = rmTransportCreateNsRequestPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
- break;\r
- }\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
+ pktHandle = rmTransportCreateResourceReqPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
+ break;\r
+ case Rm_service_RESOURCE_MAP_TO_NAME:\r
+ case Rm_service_RESOURCE_UNMAP_NAME:\r
+ pktHandle = rmTransportCreateNsRequestPkt(rmInst, dstTransport->appTransportHandle, transaction);\r
+ break;\r
+ }\r
\r
- if (pktHandle) {\r
- if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
+ if (pktHandle) {\r
+ if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {\r
+ transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;\r
+ }\r
}\r
+\r
+ transaction->hasBeenForwarded = true;\r
+ /* Transaction not deleted. Waiting for response from RM CD or Server */\r
}\r
- /* Transaction not deleted. Waiting for response from RM CD or Server */\r
}\r
\r
void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
void *validInstNode;\r
+ Rm_PolicyCheckCfg privCheckCfg;\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
- * - NameServer requests received on the Client Delegate are forwarded to the Server */\r
- if ((rmInst->instType == Rm_instType_CLIENT) ||\r
- ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
- ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||\r
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||\r
- (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))) {\r
- \r
- if (transaction->state != RM_SERVICE_PROCESSING) {\r
- if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
- /* Transaction did not originate on this instance */\r
- rmTransactionResponder(rmInst, transaction);\r
+ uint32_t allocType = 0; \r
+\r
+ /* Handle static transactions originating on this instance. Any other static transactions will be\r
+ * stored in transaction queue until all transports are up. */\r
+ if (((rmInst->instType == Rm_instType_CLIENT) || (rmInst->instType == Rm_instType_CLIENT_DELEGATE)) &&\r
+ (!rmInst->registeredWithDelegateOrServer) && \r
+ (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {\r
+ if (rmInst->staticInfo.staticPolicy) {\r
+ if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {\r
+ /* Check request against startup policy */\r
+ memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));\r
+\r
+ if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {\r
+ privCheckCfg.type = Rm_policyCheck_INIT;\r
+ }\r
+ else {\r
+ privCheckCfg.type = Rm_policyCheck_USE;\r
+ }\r
+ privCheckCfg.policyDtb = rmInst->staticInfo.staticPolicy;\r
+ privCheckCfg.validInstNode = rmPolicyGetValidInstNode(rmInst->staticInfo.staticValidInstTree, \r
+ rmInst->instName);\r
+ privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(rmInst->staticInfo.staticPolicy,\r
+ transaction->resourceInfo.name);\r
+ privCheckCfg.resourceBase = transaction->resourceInfo.base;\r
+ privCheckCfg.resourceLength = transaction->resourceInfo.length;\r
+\r
+ if (rmPolicyCheckPrivilege(&privCheckCfg, &transaction->state)) {\r
+ transaction->state = RM_SERVICE_APPROVED_STATIC;\r
+ }\r
+ else if (transaction->state == RM_SERVICE_PROCESSING) {\r
+ /* Privilege check returned false without error */\r
+ transaction->state = RM_SERVICE_DENIED_BY_STATIC_POLICY;\r
+ }\r
}\r
else {\r
- /* Transaction originated on this instance */\r
- rmServiceResponder(rmInst, transaction);\r
+ transaction->state = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;\r
}\r
}\r
else {\r
- /* Forward new transaction */\r
- rmTransactionForwarder(rmInst, transaction);\r
- }\r
+ transaction->state = RM_ERROR_REQ_FAILED_NO_STATIC_POLICY;\r
+ } \r
}\r
else {\r
- /* Validate service's originating instance name */\r
- if (rmInst->instType == Rm_instType_SERVER) {\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
+ /* Handle auto-forwarded transactions. These transactions include:\r
+ * - All request transactions received on Clients are forwarded to the Client Delegate\r
+ * - NameServer requests received on the Client Delegate are forwarded to the Server */\r
+ if ((rmInst->instType == Rm_instType_CLIENT) ||\r
+ ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
+ ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||\r
+ (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||\r
+ (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))) {\r
+ \r
+ if ((transaction->state != RM_SERVICE_PROCESSING) &&\r
+ (transaction->state != RM_SERVICE_APPROVED_STATIC)) {\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
+ /* Transaction did not originate on this instance */\r
rmTransactionResponder(rmInst, transaction);\r
}\r
+ else {\r
+ /* Transaction originated on this instance */\r
+ rmServiceResponder(rmInst, transaction);\r
+ }\r
+ }\r
+ else {\r
+ /* Forward request if transport is up. Otherwise, just queue. */\r
+ if (rmInst->registeredWithDelegateOrServer) {\r
+ rmTransactionForwarder(rmInst, transaction); \r
+ } \r
}\r
}\r
+ else {\r
+ /* Validate service's originating instance name */\r
+ if (rmInst->instType == Rm_instType_SERVER) {\r
+ validInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);\r
+ if (validInstNode == NULL) {\r
+ transaction->state = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;\r
\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
- if (transaction->state != RM_SERVICE_PROCESSING) {\r
- /* Transaction complete */\r
- if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
- /* Transaction result not destined for this instance */\r
+ /* Send result via responder if transaction did not originate from this instance */\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
rmTransactionResponder(rmInst, transaction);\r
}\r
- else {\r
- /* Transaction result destined for this instance */\r
- rmServiceResponder(rmInst, transaction); \r
- }\r
}\r
- else {\r
- /* Complete allocation/free request */\r
- if (transaction->type == Rm_service_RESOURCE_FREE) {\r
- rmFreeHandler(rmInst, transaction, validInstNode);\r
+ }\r
+\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
+ if ((transaction->state != RM_SERVICE_PROCESSING) &&\r
+ (transaction->state != RM_SERVICE_APPROVED_STATIC)) {\r
+ /* Transaction complete */\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
+ /* Transaction result not destined for this instance */\r
+ rmTransactionResponder(rmInst, transaction);\r
+ }\r
+ else {\r
+ /* Transaction result destined for this instance */\r
+ rmServiceResponder(rmInst, transaction); \r
+ }\r
}\r
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
- break;\r
- case Rm_service_RESOURCE_ALLOCATE_USE:\r
- RM_policy_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1); \r
- break;\r
+ /* Complete allocation/free request */\r
+ if (transaction->type == Rm_service_RESOURCE_FREE) {\r
+ rmFreeHandler(rmInst, transaction, validInstNode);\r
+ }\r
+ 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
+ break;\r
+ case Rm_service_RESOURCE_ALLOCATE_USE:\r
+ RM_policy_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1); \r
+ break;\r
+ }\r
+ rmAllocationHandler(rmInst, transaction, validInstNode, allocType);\r
}\r
- rmAllocationHandler(rmInst, transaction, validInstNode, allocType);\r
- }\r
- }\r
- break;\r
- case Rm_service_RESOURCE_MAP_TO_NAME:\r
- 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
- nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;\r
- nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;\r
- nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;\r
- transaction->state = rmNameServerAddObject(&nameServerObjCfg);\r
}\r
- else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
- if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==\r
- RM_SERVICE_PROCESSING) {\r
- strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_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
+ break;\r
+ case Rm_service_RESOURCE_MAP_TO_NAME:\r
+ 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
+ if (rmInst->nameServer) {\r
+ nameServerObjCfg.nameServerTree = rmInst->nameServer;\r
+ nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;\r
+ if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {\r
+ nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;\r
+ nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;\r
+ nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;\r
+ transaction->state = rmNameServerAddObject(&nameServerObjCfg);\r
+ }\r
+ else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
+ if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==\r
+ RM_SERVICE_PROCESSING) {\r
+ strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);\r
+ transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;\r
+ transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;\r
+ transaction->state = RM_SERVICE_APPROVED;\r
+ } \r
+ }\r
+ else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
+ transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);\r
+ }\r
}\r
- else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
- transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);\r
+ else {\r
+ transaction->state = RM_ERROR_NAMESERVER_DOES_NOT_EXIST;\r
}\r
\r
/* Send result via responder if transaction did not originate from this instance */\r
- if (strcmp(transaction->serviceSrcInstName, rmInst->instName)) {\r
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {\r
rmTransactionResponder(rmInst, transaction);\r
}\r
- }\r
- else {\r
- transaction->state = RM_SERVICE_ERROR_NAMESERVER_OBJECT_MOD_ON_INVALID_INSTANCE;\r
- }\r
- break;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Forward any queued requests that weren't forwarded yet */\r
+ if (rmInst->registeredWithDelegateOrServer) {\r
+ transaction = rmInst->transactionQueue;\r
+ while(transaction) {\r
+ if (((transaction->state == RM_SERVICE_PROCESSING) ||\r
+ (transaction->state == RM_SERVICE_APPROVED_STATIC)) &&\r
+ !transaction->hasBeenForwarded) {\r
+ rmTransactionForwarder(rmInst, transaction);\r
+ }\r
+ transaction = transaction->nextTransaction;\r
}\r
}\r
}\r
int32_t rmReserveLinuxResource(Rm_Inst *rmInst, Rm_LinuxAlias *linuxAlias, \r
Rm_LinuxValueRange *linuxValues, Rm_AllocatorOpInfo *opInfo)\r
{\r
- int32_t retVal = RM_INIT_OK;\r
- bool baseFound = FALSE;\r
- bool lengthFound = FALSE;\r
+ int32_t retVal = RM_OK;\r
+ bool baseFound = false;\r
+ bool lengthFound = false;\r
uint32_t valueIndex = 0;\r
\r
while ((linuxValues) && (!baseFound || !lengthFound)) {\r
if (linuxAlias->baseOffset == valueIndex) {\r
opInfo->resourceInfo->base = linuxValues->value;\r
- baseFound = TRUE;\r
+ baseFound = true;\r
\r
if (linuxAlias->lengthOffset == RM_DTB_LINUX_ALIAS_OFFSET_NOT_SET) {\r
opInfo->resourceInfo->length = 1;\r
- lengthFound = TRUE;\r
+ lengthFound = true;\r
}\r
}\r
else if (linuxAlias->lengthOffset == valueIndex) {\r
opInfo->resourceInfo->length = linuxValues->value;\r
- lengthFound = TRUE;\r
+ lengthFound = true;\r
}\r
\r
linuxValues = (Rm_LinuxValueRange *)linuxValues->nextValue;\r
}\r
\r
if (!baseFound || !lengthFound) {\r
- retVal = RM_INIT_ERROR_COULD_NOT_LOCATE_RESOURCE_IN_LINUX_DTB;\r
+ retVal = RM_ERROR_DATA_NOT_FOUND_AT_LINUX_ALIAS;\r
}\r
else {\r
/* Allocate resource to Linux */\r
@@ -1350,7 +1420,7 @@ int32_t rmFindAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName,
const char *propertyName;\r
const void *propertyData; \r
Rm_LinuxValueRange *linuxValueRange;\r
- int32_t retVal = RM_INIT_OK; \r
+ int32_t retVal = RM_OK; \r
\r
memset((void *) &opInfo, 0, sizeof(Rm_AllocatorOpInfo));\r
memset((void *) &resourceInfo, 0, sizeof(Rm_ResourceInfo));\r
@@ -1382,7 +1452,7 @@ int32_t rmFindAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName,
if ((depth < prevDepth) || (nodeOffset == -FDT_ERR_NOTFOUND)) {\r
/* Returning from subnode that matched part of alias path without finding\r
* resource values */\r
- retVal = (RM_INIT_ERROR_COULD_NOT_LOCATE_RESOURCE_IN_LINUX_DTB);\r
+ retVal = RM_ERROR_DATA_NOT_FOUND_AT_LINUX_ALIAS;\r
break;\r
}\r
}\r
@@ -1419,7 +1489,7 @@ int32_t rmFindAndReserveLinuxResource(Rm_Inst *rmInst, const char *resourceName,
}\r
}\r
\r
- if (retVal < RM_INIT_OK) {\r
+ if (retVal < RM_OK) {\r
break;\r
}\r
linuxAlias = (Rm_LinuxAlias *) linuxAlias->nextLinuxAlias;\r
Rm_NsAssignment *nsAssignmentBasePtr = NULL;\r
Rm_LinuxAlias *linuxAlias = NULL;\r
Rm_NameServerObjCfg nameServerObjCfg; \r
- int32_t retVal = RM_INIT_OK;\r
+ int32_t retVal = RM_OK;\r
\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_INIT_OK) {\r
+ if ((retVal = rmCreateTreeAllocator(rmInst, resourceName, range)) >= RM_OK) {\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
+ if (linuxDtb) {\r
+ linuxAlias = rmDtbUtilResExtractLinuxAlias(resourceProperties->linuxAliasData,\r
+ resourceProperties->linuxAliasLen, &retVal);\r
+ if (linuxAlias) {\r
+ retVal = rmFindAndReserveLinuxResource(rmInst, resourceName, linuxDtb, linuxAlias); \r
+ }\r
+ }\r
+ else {\r
+ retVal = RM_ERROR_GRL_LINUX_ALIAS_BUT_NO_DTB;\r
}\r
}\r
}\r
}\r
\r
- if (retVal >= RM_INIT_OK) {\r
+ if (retVal >= RM_OK) {\r
if (resourceProperties->nsAssignData && resourceProperties->nsAssignLen) {\r
nsAssignments = rmDtbUtilResExtractNsAssignment(resourceProperties->nsAssignData, \r
resourceProperties->nsAssignLen, &retVal);\r
@@ -1487,7 +1562,7 @@ int32_t rmParseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_Reso
const char *propertyName;\r
const void *propertyData;\r
Rm_ResourcePropType propertyType;\r
- int32_t retVal = RM_INIT_OK;\r
+ int32_t retVal = RM_OK;\r
\r
propertyData = fdt_getprop_by_offset(globalResourceDtb, offset, &propertyName, &propertyLen);\r
propertyType = rmDtbUtilResGetPropertyType(propertyName);\r
@@ -1504,10 +1579,10 @@ int32_t rmParseResourceProperty(void *globalResourceDtb, int32_t offset, Rm_Reso
propertyInfo->linuxAliasLen = propertyLen;\r
} \r
else {\r
- retVal = RM_INIT_ERROR_UNKNOWN_RESOURCE_LIST_PROPERTY_TYPE;\r
+ retVal = RM_ERROR_GRL_UNKNOWN_RESOURCE_PROPERTY;\r
}\r
\r
- if (retVal == RM_INIT_OK) {\r
+ if (retVal == RM_OK) {\r
offset = fdt_next_property_offset(globalResourceDtb, offset);\r
if (offset >= 0) {\r
retVal = rmParseResourceProperty(globalResourceDtb, offset, propertyInfo);\r
@@ -1525,7 +1600,7 @@ int32_t rmParseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t no
{\r
const char *resourceName = fdt_get_name(globalResourceDtb, nodeOffset, NULL);\r
Rm_ResourceProperties resourceProperties;\r
- int32_t retVal = RM_INIT_OK;\r
+ int32_t retVal = RM_OK;\r
int32_t offset;\r
\r
memset((void *)&resourceProperties, 0, sizeof(Rm_ResourceProperties));\r
@@ -1536,7 +1611,9 @@ int32_t rmParseResourceNode(Rm_Inst *rmInst, void *globalResourceDtb, int32_t no
if (retVal < -FDT_ERR_NOTFOUND) {\r
return (retVal);\r
}\r
- rmCreateAndInitAllocator(rmInst, resourceName, &resourceProperties, linuxDtb);\r
+ if (retVal = rmCreateAndInitAllocator(rmInst, resourceName, &resourceProperties, linuxDtb) < RM_OK) {\r
+ return (retVal);\r
+ }\r
}\r
else if (offset != -FDT_ERR_NOTFOUND) {\r
/* Error returned by LIBFDT */\r
@@ -1561,7 +1638,7 @@ int32_t rmInitializeAllocators(Rm_Inst *rmInst, void *globalResourceDtb, void *l
{\r
int32_t nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;\r
int32_t startDepth = RM_DTB_UTIL_STARTING_DEPTH;\r
- int32_t result = RM_INIT_OK;\r
+ int32_t result = RM_OK;\r
\r
/* Recursively parse the Global Resource List, creating an allocator for\r
* each resource as specified in the node */\r
}\r
else {\r
owners = treeNode->ownerList;\r
- Rm_osalLog("allocated to ");\r
+ Rm_osalLog("allocated to");\r
while (owners) {\r
Rm_osalLog(" %s", owners->instNameNode->name);\r
owners = owners->nextOwner;\r
}\r
}\r
\r
-Rm_PreMainHandle Rm_preMainInit(Rm_PreMainInitCfg *preMainInitCfg, int32_t *result)\r
-{\r
- Rm_PreMainInst *preMainInst;\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 = rmPolicyCreateValidInstTree(preMainInst->startupDtb, result);\r
- if (*result == RM_INIT_OK) {\r
- /* Validate policy assignment strings */\r
- *result = rmPolicyValidatePolicy(preMainInitCfg->startupPolicyDtb, preMainInst->validInstTree);\r
- }\r
-\r
- if (*result != RM_INIT_OK) {\r
- if (preMainInst->validInstTree) {\r
- rmPolicyFreeValidInstTree(preMainInst->validInstTree);\r
- }\r
- Rm_osalFree((void *)preMainInst, sizeof(Rm_PreMainInst));\r
- preMainInst = NULL;\r
- }\r
- else {\r
- strncpy(preMainInst->instName, preMainInitCfg->instName, RM_NAME_MAX_CHARS);\r
- preMainInst->requestCount = 0;\r
- preMainInst->preMainReqList = NULL;\r
- }\r
-\r
- return((Rm_PreMainHandle)preMainInst);\r
-}\r
-\r
+/**\r
+ * @b Description\r
+ * @n \r
+ * This function initializes a RM instance.\r
+ * \r
+ * IMPORTANT: Rm_init must be called prior to any other component startup\r
+ * APIs (BIOS_start, Ipc_start, etc).\r
+ *\r
+ * @param[in] *initCfg\r
+ * Pointer to structure containing the initialization information for\r
+ * this RM instance.\r
+ *\r
+ * @param[in] *result\r
+ * Pointer to a uint32_t that will contain the result of the RM \r
+ * intialization and handle creation. Any errors encountered will be \r
+ * returned via this pointer.\r
+ *\r
+ * @retval\r
+ * Success - non-zero Rm_Handle returned.\r
+ * @retval\r
+ * Failure - NULL Rm_handle returned.\r
+ */\r
Rm_Handle Rm_init(Rm_InitCfg *initCfg, int32_t *result)\r
{\r
Rm_Inst *rmInst;\r
void *globalResourceDtb = NULL;\r
void *linuxResourceDtb = NULL;\r
+ bool addLinux = false;\r
\r
- *result = RM_INIT_OK;\r
+ *result = RM_OK;\r
\r
- if ((strlen(initCfg->instName) + 1) > RM_NAME_MAX_CHARS) {\r
- *result = RM_INIT_ERROR_INSTANCE_NAME_TOO_BIG;\r
+ if ((initCfg->instName == NULL) ||\r
+ ((strlen(initCfg->instName) + 1) > RM_NAME_MAX_CHARS)) {\r
+ *result = RM_ERROR_INVALID_INST_NAME;\r
return (NULL);\r
}\r
\r
+ if (initCfg->instType >= Rm_instType_LAST) {\r
+ *result = RM_ERROR_INVALID_INST_TYPE;\r
+ }\r
+\r
/* Create and initialize instance */\r
rmInst = Rm_osalMalloc (sizeof(Rm_Inst));\r
memset ((void *) rmInst, 0, sizeof(Rm_Inst));\r
- strncpy (rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);\r
- rmInst->instType = initCfg->instType;\r
- rmInst->serviceHandle = NULL;\r
+ rmInst->isLocked = false;\r
rmInst->registeredWithDelegateOrServer = false;\r
- rmInst->transports = NULL;\r
- rmInst->allocators = NULL;\r
- rmInst->nameServer = NULL;\r
- rmInst->policy = NULL;\r
- rmInst->validInstances = NULL;\r
rmInst->transactionSeqNum = rmTransactionInitSequenceNum();\r
- rmInst->transactionQueue= NULL;\r
\r
- if ((rmInst->instType != Rm_instType_CLIENT) && initCfg->dynamicPolicy) {\r
- rmInst->policy = initCfg->dynamicPolicy;\r
+ rmInst->instType = initCfg->instType; \r
+ strncpy (rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);\r
+\r
+ if (rmInst->instType == Rm_instType_SERVER) {\r
+ if (!initCfg->instCfg.serverCfg.globalResourceList ||\r
+ !initCfg->instCfg.serverCfg.globalPolicy) {\r
+ *result = RM_ERROR_INVALID_SERVER_CONFIGURATION;\r
+ return(NULL);\r
+ }\r
+\r
+ rmInst->policy = initCfg->instCfg.serverCfg.globalPolicy;\r
fdt_open_into(rmInst->policy, rmInst->policy, fdt_totalsize(rmInst->policy)); \r
\r
+ if (initCfg->instCfg.serverCfg.linuxDtb) {\r
+ linuxResourceDtb = initCfg->instCfg.serverCfg.linuxDtb;\r
+ fdt_open_into(linuxResourceDtb, linuxResourceDtb, fdt_totalsize(linuxResourceDtb));\r
+ addLinux = true;\r
+ }\r
+\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 = rmPolicyCreateValidInstTree(rmInst->policy, result);\r
+ rmInst->validInstances = rmPolicyCreateValidInstTree(rmInst->policy, addLinux, result);\r
/* Validate policy assignment strings */\r
- *result = rmPolicyValidatePolicy(rmInst->policy, rmInst->validInstances);\r
- }\r
+ *result = rmPolicyValidatePolicy(rmInst->policy, rmInst->validInstances); \r
\r
- /* RM Server specific actions */\r
- if (rmInst->instType == Rm_instType_SERVER) {\r
rmInst->nameServer = rmNameServerInit();\r
\r
- if (initCfg->globalResourceList) {\r
- globalResourceDtb = initCfg->globalResourceList;\r
- fdt_open_into(globalResourceDtb, globalResourceDtb, fdt_totalsize(globalResourceDtb));\r
+ globalResourceDtb = initCfg->instCfg.serverCfg.globalResourceList;\r
+ fdt_open_into(globalResourceDtb, globalResourceDtb, fdt_totalsize(globalResourceDtb));\r
\r
- if (initCfg->linuxDtb) {\r
- linuxResourceDtb = initCfg->linuxDtb;\r
- fdt_open_into(linuxResourceDtb, linuxResourceDtb, fdt_totalsize(linuxResourceDtb)); \r
- }\r
- rmInitializeAllocators(rmInst, globalResourceDtb, linuxResourceDtb);\r
+ rmInitializeAllocators(rmInst, globalResourceDtb, linuxResourceDtb); \r
+\r
+ if ((*result = rmPolicyValidatePolicyResourceNames(rmInst->policy, (void *)rmInst->allocators)) !=\r
+ RM_OK) {\r
+ return(NULL);\r
}\r
}\r
\r
- if ((rmInst->instType != Rm_instType_CLIENT) && initCfg->dynamicPolicy) {\r
- *result = rmPolicyValidatePolicyResourceNames(rmInst->policy, (void *)rmInst->allocators);\r
- } \r
-\r
+ if ((rmInst->instType == Rm_instType_CLIENT) && \r
+ (initCfg->instCfg.clientCfg.staticPolicy)) {\r
+ rmInst->staticInfo.staticPolicy = initCfg->instCfg.clientCfg.staticPolicy; \r
+ }\r
+ else if ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
+ (initCfg->instCfg.cdCfg.staticPolicy)) { \r
+ rmInst->staticInfo.staticPolicy = initCfg->instCfg.cdCfg.staticPolicy; \r
+ }\r
+ if (rmInst->staticInfo.staticPolicy) {\r
+ fdt_open_into(rmInst->staticInfo.staticPolicy, rmInst->staticInfo.staticPolicy, \r
+ fdt_totalsize(rmInst->staticInfo.staticPolicy)); \r
+ rmInst->staticInfo.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->staticInfo.staticPolicy, \r
+ addLinux, result); \r
+ if (*result == RM_OK) {\r
+ /* Validate policy assignment strings */\r
+ *result = rmPolicyValidatePolicy(rmInst->staticInfo.staticPolicy, rmInst->staticInfo.staticValidInstTree);\r
+ }\r
+ if (*result != RM_OK) {\r
+ if (rmInst->staticInfo.staticValidInstTree) {\r
+ rmPolicyFreeValidInstTree(rmInst->staticInfo.staticValidInstTree);\r
+ }\r
+ Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));\r
+ rmInst = NULL;\r
+ }\r
+ }\r
return ((Rm_Handle) rmInst);\r
}\r
\r
+/**\r
+ * @b Description\r
+ * @n \r
+ * The function is used to get the version information of the RM.\r
+ *\r
+ * @retval\r
+ * Version Information.\r
+ */\r
uint32_t Rm_getVersion (void)\r
{\r
return RM_VERSION_ID;\r
}\r
\r
-\r
+/**\r
+ * @b Description\r
+ * @n \r
+ * The function is used to get the version string for the RM.\r
+ *\r
+ * @retval\r
+ * Version String.\r
+ */\r
const char* Rm_getVersionStr (void)\r
{\r
return rmVersionStr;\r
diff --git a/src/rm_dtb_util.c b/src/rm_dtb_util.c
index eddbf769dbed93b5d18b1c57c6a569e47e148147..3754b6d0051b2fdad70c26ee463ce1a0c5625700 100644 (file)
--- a/src/rm_dtb_util.c
+++ b/src/rm_dtb_util.c
@@ -283,7 +283,7 @@ Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtb
Rm_osalFree((void *)startAlias, sizeof(Rm_LinuxAlias));
startAlias = newAlias;
}
- *result = RM_INIT_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT;
+ *result = RM_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT;
return(NULL);
}
}
@@ -335,7 +335,7 @@ Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t
Rm_osalFree((void *)startAssignment, sizeof(Rm_NsAssignment));
startAssignment = newAssignment;
}
- *result = RM_INIT_ERROR_NS_ASSIGNMENT_NAME_TOO_LONG;
+ *result = RM_ERROR_GRL_NS_ASSIGNMENT_NAME_TOO_LONG;
return(NULL);
}
strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]), RM_NAME_MAX_CHARS);
@@ -514,7 +514,7 @@ Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
Rm_osalFree((void *)startInst, sizeof(Rm_PolicyValidInst));
startInst = newInst;
}
- *result = RM_INIT_ERROR_POLICY_VALID_INSTANCE_NAME_TOO_LONG;
+ *result = RM_ERROR_VALID_INST_NAME_TOO_LONG;
return(NULL);
}
strncpy(newInst->instName, ((char *) &dtbValidInstData[i]), instLenBytes);
diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c
index 2a3ee6d5f85639b96a6f63133a50ac256b2d2a46..2129944614bc027d0e1ed4f1f732c7c4ab1d72b6 100644 (file)
--- a/src/rm_nameserver.c
+++ b/src/rm_nameserver.c
int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg)
{
Rm_NameServerNode *newNode = NULL;
- int32_t retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
+ int32_t retVal = RM_SERVICE_APPROVED;
if (newNode = rmNameServerNodeNew(&objCfg->nodeCfg)) {
if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) {
/* Collision */
rmNameServerNodeFree(newNode);
- retVal = RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS;
+ retVal = RM_SERVICE_DENIED_NAME_EXISTS_IN_NS;
}
}
else {
- retVal = RM_SERVICE_ERROR_NAMESERVER_OBJECT_ADD_FAILED;
+ retVal = RM_ERROR_NAMESERVER_NAME_ADD_FAILED;
}
return(retVal);
{
Rm_NameServerNode findNode;
Rm_NameServerNode *matchingNode;
- int32_t retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
+ int32_t retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;
memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
{
Rm_NameServerNode findNode;
Rm_NameServerNode *matchingNode;
- int32_t retVal = RM_SERVICE_ERROR_NAMESERVER_ERROR_NAME_DOES_NOT_EXIST;
+ int32_t retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;
memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode);
rmNameServerNodeFree(matchingNode);
- retVal = RM_SERVICE_APPROVED_AND_COMPLETED;
+ retVal = RM_SERVICE_APPROVED;
}
return(retVal);
}
diff --git a/src/rm_policy.c b/src/rm_policy.c
index 9432c3dea0c90f053064b0b9661b7ad2c06df2b0..b09a3cf94ee8ca3702bfc736c192046465eaa425 100644 (file)
--- a/src/rm_policy.c
+++ b/src/rm_policy.c
/* Standard includes */
#include <ctype.h>
+#include <stdbool.h>
/* RM external API includes */
#include <ti/drv/rm/rm.h>
while (permissionsList) {
if (strcmp(permissionsList->instName, Rm_policyAllInstances) &&
(!rmPolicyGetValidInstNode(validInstTree, permissionsList->instName))) {
- return(RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE);
+ return(RM_ERROR_PERM_STR_INST_NOT_VALID);
}
permissionsList = permissionsList->nextPermission;
}
- return(RM_INIT_OK);
+ return(RM_OK);
}
static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd,
@@ -123,7 +124,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
* d) There is more than one instance subgroup specified in the string. There
* should only be one subgroup per sub-permission string */
Rm_osalFree((void *)permStrStart, permStrLen);
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_INSTANCE_GROUP;
+ *result = RM_ERROR_PERM_STR_TOO_MANY_INST_GROUPS;
return(NULL);
}
@@ -131,8 +132,8 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
* Instances names are separated by one or more spaces. */
permStrPtr = subgroupStart + 1;
instNameIndex = 0;
- foundInstName = FALSE;
- instNameComplete = FALSE;
+ foundInstName = false;
+ instNameComplete = false;
while (permStrPtr <= subgroupEnd) {
if ((isspace(*permStrPtr) || (*permStrPtr == RM_POLICY_PERM_SUBGROUP_END))
&& foundInstName) {
@@ -140,13 +141,13 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
* terminates the instance name. All other space characters are
* ignored. */
instNameTemp[instNameIndex] = '\0';
- instNameComplete = TRUE;
+ instNameComplete = true;
}
else {
if (!foundInstName) {
/* First non-whitespace character encountered is the start of an
* instance name */
- foundInstName = TRUE;
+ foundInstName = true;
}
/* Copy the character into the temporary instance name string */
@@ -165,13 +166,13 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = newPerm;
}
else {
- prevPerm->nextPermission = (void *) newPerm;
+ prevPerm->nextPermission = newPerm;
}
prevPerm = newPerm;
- instNameComplete = FALSE;
+ instNameComplete = false;
instNameIndex = 0;
- foundInstName = FALSE;
+ foundInstName = false;
}
else if (instNameIndex == RM_NAME_MAX_CHARS) {
/* Instance name is longer than max length */
@@ -181,7 +182,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INSTANCE_NAME_IN_ASSIGNMENT_TOO_LONG;
+ *result = RM_ERROR_INST_NAME_IN_ASSIGNMENT_TOO_LONG;
return(NULL);
}
@@ -192,7 +193,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
/* Look on left of instance group for permission assignments. */
permStrPtr = subgroupStart - 1;
- assignmentLeft = FALSE;
+ assignmentLeft = false;
while (permStrPtr >= permStrStart)
{
if (*permStrPtr == RM_POLICY_PERM_ASSIGNMENT) {
@@ -206,11 +207,11 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_ASSIGNMENT_CHAR;
+ *result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
return(NULL);
}
else {
- assignmentLeft = TRUE;
+ assignmentLeft = true;
}
}
else if (!isspace(*permStrPtr)) {
@@ -257,7 +258,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INVALID_PERM_CHAR;
+ *result = RM_ERROR_PERM_STR_INVALID_CHAR;
return(NULL);
}
}
@@ -271,7 +272,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_PERM_CHAR_WITHOUT_ASSIGN_CHAR;
+ *result = RM_ERROR_PERM_CHAR_WITHOUT_ASSIGN_CHAR;
return(NULL);
}
}
@@ -280,7 +281,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
/* Look on right of instance group for permission assignments. */
permStrPtr = subgroupEnd + 1;
- assignmentRight = FALSE;
+ assignmentRight = false;
while (permStrPtr < permStrEnd) {
if (assignmentLeft && (!isspace(*permStrPtr))) {
/* There should be nothing but spaces on right if assignment was already found on left */
@@ -290,7 +291,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INVALID_CHAR_ON_RIGHT_WITH_ASSINMENT_ON_LEFT;
+ *result = RM_ERROR_INVALID_PERMS_CHAR_ON_RIGHT;
return(NULL);
}
@@ -305,11 +306,11 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_ASSIGNMENT_CHAR;
+ *result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
return(NULL);
}
else {
- assignmentRight = TRUE;
+ assignmentRight = true;
}
}
else if (!isspace(*permStrPtr)) {
@@ -356,7 +357,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_INVALID_PERM_CHAR;
+ *result = RM_ERROR_PERM_STR_INVALID_CHAR;
return(NULL);
}
}
@@ -370,7 +371,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
startPerm = nextPerm;
}
Rm_osalFree((void *)permStrStart, sizeof(permStrLen));
- *result = RM_INIT_ERROR_POLICY_SYNTAX_ERROR_MORE_THAN_ONE_ASSIGNMENT_CHAR;
+ *result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
return(NULL);
}
}
@@ -448,16 +449,16 @@ static int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
{
Rm_PolicyAssignment *assignment = assignmentList;
Rm_PolicyPermission *permissionList;
- int32_t result;
+ int32_t result = RM_OK;
while (assignment) {
/* Make sure assignment's permissions parse okay */
permissionList = policyGetAssignmentPermissions(assignment, &result);
- if (result != RM_INIT_OK) {
+ if (result != RM_OK) {
return(result);
}
- if (result = policyCheckInstances(root, permissionList) != RM_INIT_OK) {
+ if (result = policyCheckInstances(root, permissionList) != RM_OK) {
policyFreeAssignmentPermissions(permissionList);
return(result);
}
@@ -466,7 +467,7 @@ static int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root,
assignment = assignment->nextAssignment;
}
- return (RM_INIT_OK);
+ return (RM_OK);
}
/**********************************************************************
if (assignment) {
while (assignment) {
assignmentEnd = assignment->resourceBase + assignment->resourceLength - 1;
- foundInstance = FALSE;
+ foundInstance = false;
if (((privilegeCfg->resourceBase >= assignment->resourceBase) &&
(privilegeCfg->resourceBase <= assignmentEnd)) ||
((privilegeCfg->resourceBase < assignment->resourceBase) &&
while (permission) {
if ((strcmp(permission->instName, privilegeCfg->validInstNode->name) == 0) ||
(strcmp(permission->instName, Rm_policyAllInstances) == 0)) {
- foundInstance = TRUE;
+ foundInstance = true;
/* Check instance's permissions */
if (privilegeCfg->type == Rm_policyCheck_INIT) {
if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_INIT_SHIFT)) {
policyFreeAssignmentPermissions(permissionStart);
rmDtbUtilPolicyFreeAssignments(assignmentStart);
- return(FALSE);
+ return(false);
}
}
else if (privilegeCfg->type == Rm_policyCheck_USE) {
if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
policyFreeAssignmentPermissions(permissionStart);
rmDtbUtilPolicyFreeAssignments(assignmentStart);
- return(FALSE);
+ return(false);
}
}
else if (privilegeCfg->type == Rm_policyCheck_EXCLUSIVE) {
if (!RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT)) {
policyFreeAssignmentPermissions(permissionStart);
rmDtbUtilPolicyFreeAssignments(assignmentStart);
- return(FALSE);
+ return(false);
}
}
break;
policyFreeAssignmentPermissions(permissionStart);
if (!foundInstance) {
rmDtbUtilPolicyFreeAssignments(assignmentStart);
- return(FALSE);
+ return(false);
}
}
assignment = assignment->nextAssignment;
rmDtbUtilPolicyFreeAssignments(assignmentStart);
}
else {
- return(FALSE);
+ return(false);
}
- return(TRUE);
+ return(true);
}
uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode,
@@ -605,40 +606,38 @@ uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validI
}
}
- /* Search policy permissions for a valid resource base */
- if (assignment) {
- while (assignment) {
- permission = permissionStart = policyGetAssignmentPermissions(assignment, result);
- while (permission) {
- 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) &&
- 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) &&
- RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
- resourceBase = assignment->resourceBase;
- break;
- }
+ /* Search policy permissions for valid resource base */
+ while (assignment) {
+ permission = permissionStart = policyGetAssignmentPermissions(assignment, result);
+ while (permission) {
+ 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) &&
+ 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) &&
+ RM_policy_GET_PERM(permission->permissionBits, RM_POLICY_PERM_USE_SHIFT)) {
+ resourceBase = assignment->resourceBase;
+ break;
}
- permission = permission->nextPermission;
}
- policyFreeAssignmentPermissions(permissionStart);
+ permission = permission->nextPermission;
+ }
+ policyFreeAssignmentPermissions(permissionStart);
- if (resourceBase) {
- break;
- }
- else {
- assignment = assignment->nextAssignment;
- }
+ if (resourceBase) {
+ break;
+ }
+ else {
+ assignment = assignment->nextAssignment;
}
- rmDtbUtilPolicyFreeAssignments(assignmentStart);
}
- else {
- *result = RM_SERVICE_DENIED_NO_RANGE_ASSIGNMENTS_FOR_POLICY;
+
+ if (assignmentStart) {
+ rmDtbUtilPolicyFreeAssignments(assignmentStart);
}
return(resourceBase);
@@ -711,11 +710,11 @@ int32_t rmPolicyValidatePolicyResourceNames(void *policyDtb, void *allocatorList
if (fdt_first_property_offset(policyDtb, nodeOffset) > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
if (rmAllocatorFind(allocator, (char *)nodeName) == NULL) {
/* No allocator tied to resource name */
- return(RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE);
+ return(RM_ERROR_UNKNOWN_RESOURCE_IN_POLICY);
}
}
}
- return(RM_INIT_OK);
+ return(RM_OK);
}
/* TODO: ADD ABILITY TO RETURN THE SYNTAX ERROR LOCATION */
@@ -747,22 +746,22 @@ int32_t rmPolicyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validIns
if (propertyType == Rm_policyPropType_ASSIGNMENTS) {
assignmentList = rmDtbUtilPolicyExtractAssignments(propertyData, propertyLen);
- if ((result = policyValidateAssignmentPermissions(validInstTree, assignmentList)) != RM_INIT_OK) {
+ if ((result = policyValidateAssignmentPermissions(validInstTree, assignmentList)) != RM_OK) {
rmDtbUtilPolicyFreeAssignments(assignmentList);
return(result);
}
rmDtbUtilPolicyFreeAssignments(assignmentList);
}
else if (propertyType == Rm_policyPropType_UNKNOWN) {
- return(RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE_PROPERTY);
+ return(RM_ERROR_UNKNOWN_POLICY_RESOURCE_PROPERTY);
}
propertyOffset = fdt_next_property_offset(policyDtb, propertyOffset);
}
}
- return(RM_INIT_OK);
+ return(RM_OK);
}
-Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *result)
+Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, bool addLinux, int32_t *result)
{
int32_t validInstOffset;
const char *validInstName = NULL;
@@ -782,13 +781,13 @@ Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *re
return (NULL);
}
else if (validInstOffset == -FDT_ERR_NOTFOUND) {
- *result = RM_INIT_ERROR_POLICY_NO_VALID_INSTANCES_DEFINED;
+ *result = RM_ERROR_NO_VALID_INST_IN_POLICY;
return (NULL);
}
validInstData = fdt_getprop_by_offset(policyDtb, validInstOffset, &validInstName, &validInstLen);
propertyType = rmDtbUtilPolicyGetPropertyType(validInstName);
if (propertyType != Rm_policyPropType_VALID_INSTANCES) {
- *result = RM_INIT_ERROR_POLICY_NO_VALID_INSTANCES_DEFINED;
+ *result = RM_ERROR_NO_VALID_INST_IN_POLICY;
return (NULL);
}
@@ -808,10 +807,12 @@ Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *re
}
/* Add the Linux kernel node */
- newNode = rmPolicyValidInstNodeNew(linuxName);
- RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);
+ if (addLinux) {
+ newNode = rmPolicyValidInstNodeNew(linuxName);
+ RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode);
+ }
- *result = RM_INIT_OK;
+ *result = RM_OK;
return (rootEntry);
}
diff --git a/src/rm_services.c b/src/rm_services.c
index 885fd96380b8999b5d1a07159633cd4758afae73..460028f09bfb710c39c0dd22a723ee1b2f6e187a 100644 (file)
--- a/src/rm_services.c
+++ b/src/rm_services.c
#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>
{
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
Rm_Transaction *transaction;
- Rm_PolicyCheckCfg privCheckCfg;
- Rm_ServiceStaticReq *lastStaticReq;
- if (serviceRequest->reqType == Rm_reqType_STATIC) {
- serviceResponse->serviceState = RM_SERVICE_PROCESSING;
-
- if ((serviceRequest->serviceType == Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (serviceRequest->serviceType == Rm_service_RESOURCE_ALLOCATE_USE) ||
- (serviceRequest->resourceBase != RM_RESOURCE_BASE_UNSPECIFIED)) {
- /* Check request against startup policy */
- memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
+ if (rmInst->isLocked) {
+ serviceResponse->serviceState = RM_SERVICE_DENIED_RM_INSTANCE_LOCKED;
+ return;
+ }
- if (serviceRequest->serviceType == Rm_service_RESOURCE_ALLOCATE_INIT) {
- privCheckCfg.type = Rm_policyCheck_INIT;
- }
- else {
- privCheckCfg.type = Rm_policyCheck_USE;
- }
- privCheckCfg.policyDtb = rmInst->staticInfo.staticPolicy;
- privCheckCfg.validInstNode = rmPolicyGetValidInstNode(rmInst->staticInfo.staticValidInstTree,
- rmInst->instName);
- privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(rmInst->staticInfo.staticPolicy,
- serviceRequest->resourceName);
- privCheckCfg.resourceBase = serviceRequest->resourceBase;
- privCheckCfg.resourceLength = serviceRequest->resourceLength;
+ if (serviceRequest->callback.serviceCallback == NULL) {
+ serviceResponse->serviceState = RM_ERROR_CALLBACK_NOT_PROVIDED;
+ return;
+ }
- if (rmPolicyCheckPrivilege(&privCheckCfg, &serviceResponse->serviceState)) {
- serviceResponse->serviceState = RM_SERVICE_APPROVED_AND_COMPLETED;
- }
- else if (serviceResponse->serviceState == RM_SERVICE_PROCESSING) {
- /* Privilege check returned FALSE without error */
- serviceResponse->serviceState = RM_SERVICE_DENIED_POLICY_DENIED_STATIC_ALLOCATION;
- }
+ if (serviceRequest->type >= Rm_service_LAST) {
+ serviceResponse->serviceState = RM_ERROR_INVALID_SERVICE_TYPE;
+ return;
+ }
+
+ transaction = rmTransactionQueueAdd(rmInst);
+ if (transaction) {
+ transaction->type = serviceRequest->type;
+ strncpy(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
+ transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
+ transaction->state = RM_SERVICE_PROCESSING;
+ if (serviceRequest->resourceName) {
+ strncpy(transaction->resourceInfo.name, serviceRequest->resourceName, RM_NAME_MAX_CHARS);
}
- else {
- serviceResponse->serviceState = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;
+ transaction->resourceInfo.base = serviceRequest->resourceBase;
+ transaction->resourceInfo.length = serviceRequest->resourceLength;
+ transaction->resourceInfo.alignment = serviceRequest->resourceAlignment;
+ if (serviceRequest->resourceNsName) {
+ strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
}
- /* Store request for validation after instance transports have been established */
- if (serviceResponse->serviceState == RM_SERVICE_APPROVED_AND_COMPLETED) {
- lastStaticReq = rmInst->staticInfo.staticReqList;
- while(lastStaticReq) {
- lastStaticReq = lastStaticReq->nextStaticReq;
- }
- lastStaticReq = (Rm_ServiceStaticReq *) Rm_osalMalloc (sizeof(Rm_ServiceStaticReq));
- lastStaticReq->nextStaticReq = NULL;
- lastStaticReq->staticReq = (Rm_ServiceReqInfo *) Rm_osalMalloc(sizeof(Rm_ServiceReqInfo));
- memcpy((void *)lastStaticReq->staticReq, (void *)serviceRequest, sizeof(Rm_ServiceReqInfo));
-
- /* Fill out response */
- serviceResponse->resourceBase = serviceRequest->resourceBase;
- serviceResponse->resourceLength = serviceRequest->resourceLength;
- strncpy(serviceResponse->resourceName, serviceRequest->resourceName, RM_NAME_MAX_CHARS);
- serviceResponse->serviceId = rmTransactionGetSequenceNum(rmInst);
- }
- }
- else if (serviceRequest->reqType == Rm_reqType_DYNAMIC) {
- if (serviceRequest->callback.serviceCallback == NULL) {
- serviceResponse->serviceState = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
- return;
+ rmTransactionProcessor (rmInst, transaction);
+ memset((void *)serviceResponse, 0, sizeof(Rm_ServiceRespInfo));
+ serviceResponse->serviceState = transaction->state;
+ if ((serviceResponse->serviceState == RM_SERVICE_PROCESSING) ||
+ (serviceResponse->serviceState == RM_SERVICE_APPROVED_STATIC)) {
+ /* Service still being processed. Static requests will have their validation responses sent once
+ * all transports have been established. Provide transaction ID back to component so it can sort
+ * service responses received via callback function */
+ serviceResponse->serviceId = transaction->localId;
}
- if (serviceRequest->serviceType >= Rm_service_LAST) {
- serviceResponse->serviceState = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;
- return;
+ if ((serviceResponse->serviceState == RM_SERVICE_APPROVED) ||
+ (serviceResponse->serviceState == RM_SERVICE_APPROVED_STATIC)) {
+ strncpy(serviceResponse->resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+ serviceResponse->resourceBase = transaction->resourceInfo.base;
+ serviceResponse->resourceLength = transaction->resourceInfo.length;
}
-
- transaction = rmTransactionQueueAdd(rmInst);
- if (transaction) {
- transaction->type = serviceRequest->serviceType;
- strncpy(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
- transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
- transaction->state = RM_SERVICE_PROCESSING;
- if (serviceRequest->resourceName) {
- strncpy(transaction->resourceInfo.name, serviceRequest->resourceName, RM_NAME_MAX_CHARS);
- }
- transaction->resourceInfo.base = serviceRequest->resourceBase;
- transaction->resourceInfo.length = serviceRequest->resourceLength;
- transaction->resourceInfo.alignment = serviceRequest->resourceAlignment;
- if (serviceRequest->resourceNsName) {
- strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
- }
- rmTransactionProcessor (rmInst, transaction);
- serviceResponse->serviceState = transaction->state;
- 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) {
- if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)) {
- strncpy(serviceResponse->resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
- serviceResponse->resourceBase = transaction->resourceInfo.base;
- serviceResponse->resourceLength = transaction->resourceInfo.length;
- }
- rmTransactionQueueDelete(rmInst, transaction->localId);
- }
- else {
- rmTransactionQueueDelete(rmInst, transaction->localId);
- }
+ /* Transactions still processing not deleted from queue. Includes static transactions which will be
+ * verified once all transports are up */
+ if ((serviceResponse->serviceState != RM_SERVICE_PROCESSING) &&
+ (serviceResponse->serviceState != RM_SERVICE_APPROVED_STATIC)) {
+ rmTransactionQueueDelete(rmInst, transaction->localId);
}
- else {
- serviceResponse->serviceState = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;
- }
- }
- return;
-}
-
-void Rm_serviceValidateStaticRequests(Rm_Handle rmHandle, Rm_ServiceCallback validateCallback)
-{
- Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
- Rm_ServiceReqInfo *staticRequest;
- Rm_ServiceStaticReq *nextServiceReq;
- Rm_Transaction *transaction;
- Rm_ServiceRespInfo serviceResponse;
-
- if (validateCallback.serviceCallback == NULL) {
- serviceResponse->serviceState = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
- return;
}
-
- /* Validate static requests against the global policyDtb */
- while(rmInst->staticInfo.staticReqList) {
- transaction = rmTransactionQueueAdd(rmInst);
- if (transaction) {
- staticRequest = rmInst->staticInfo.staticReqList->staticReq;
- transaction->type = staticRequest->serviceType;
- strncpy(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
- transaction->callback.serviceCallback = validateCallback.serviceCallback;
- transaction->state = RM_SERVICE_PROCESSING;
- if (staticRequest->resourceName) {
- strncpy(transaction->resourceInfo.name, staticRequest->resourceName, RM_NAME_MAX_CHARS);
- }
- transaction->resourceInfo.base = staticRequest->resourceBase;
- transaction->resourceInfo.length = staticRequest->resourceLength;
- transaction->resourceInfo.alignment = staticRequest->resourceAlignment;
- if (staticRequest->resourceNsName) {
- strncpy(transaction->resourceInfo.nameServerName, staticRequest->resourceNsName, RM_NAME_MAX_CHARS);
- }
-
- rmTransactionProcessor (rmInst, transaction);
- memset((void *)&serviceResponse, 0, sizeof(Rm_ServiceRespInfo));
- serviceResponse->serviceState = transaction->state;
- 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) {
- if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)) {
- strncpy(serviceResponse->resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
- serviceResponse->resourceBase = transaction->resourceInfo.base;
- serviceResponse->resourceLength = transaction->resourceInfo.length;
- }
- rmTransactionQueueDelete(rmInst, transaction->localId);
- }
- else {
- rmTransactionQueueDelete(rmInst, transaction->localId);
- }
- /* Issue response via callback since function won't return until all static requests have
- * been handled */
- validateCallback->serviceCallback(&serviceResponse);
- }
- else {
- serviceResponse->serviceState = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;
- return;
- }
- /* Free memory associated with static requests sent for validation */
- nextServiceReq = rmInst->staticInfo.staticReqList->nextStaticReq;
- Rm_osalFree((void *)rmInst->staticInfo.staticReqList->staticReq, sizeof(Rm_ServiceReqInfo));
- Rm_osalFree((void *)rmInst->staticInfo.staticReqList, sizeof(Rm_ServiceStaticReq));
- rmInst->staticInfo.staticReqList = nextServiceReq;
+ else {
+ serviceResponse->serviceState = RM_ERROR_SERVICE_TRANS_NOT_CREATED;
}
+ return;
}
Rm_ServiceHandle *Rm_serviceOpenHandle(Rm_Handle rmHandle, int32_t *result)
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
Rm_ServiceHandle *newServiceHandle = NULL;
- *result = RM_INIT_OK;
+ *result = RM_OK;
if (rmInst->serviceHandle == NULL) {
newServiceHandle = Rm_osalMalloc (sizeof(Rm_ServiceHandle));
rmInst->serviceHandle = newServiceHandle;
}
else {
- *result = RM_INIT_ERROR_SERVICE_HANDLE_MEMORY_ALLOC_FAILED;
+ *result = RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED;
}
}
else {
- *result = RM_INIT_ERROR_SERVICE_HANDLE_ALREADY_ALLOCATED;
+ *result = RM_ERROR_SERVICE_HANDLE_ALREADY_OPENED;
}
return (newServiceHandle);
}
int32_t Rm_serviceCloseHandle(Rm_ServiceHandle *rmServiceHandle)
{
Rm_Inst *rmInst = (Rm_Inst *)rmServiceHandle->rmHandle;
- int32_t retVal = RM_INIT_OK;
+ int32_t retVal = RM_OK;
if (rmInst->serviceHandle) {
Rm_osalFree((void *)rmServiceHandle, sizeof(Rm_ServiceHandle));
rmInst->serviceHandle = NULL;
}
else {
- retVal = RM_INIT_ERROR_SERVICE_HANDLE_ALREADY_CLOSED_FOR_INSTANCE;
+ retVal = RM_ERROR_SERVICE_HANDLE_ALREADY_CLOSED;
}
return(retVal);
}
diff --git a/src/rm_transport.c b/src/rm_transport.c
index 50d4ec2304f196837d334df572ecc1eff3b8dd54..a68288ea962a1c5807ece042a7abae4300c2ee94 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
\r
/* Standard includes */\r
#include <string.h>\r
+#include <stdbool.h>\r
\r
/* RM external includes */\r
#include <ti/drv/rm/rm.h>\r
@@ -93,11 +94,11 @@ static bool transportIsTransportRegistered(Rm_Handle rmHandle, Rm_Transport *tra
\r
while (transportList) {\r
if (transportList == transport) {\r
- return(TRUE); \r
+ return(true); \r
}\r
transportList = transportList->nextTransport;\r
}\r
- return (FALSE);\r
+ return (false);\r
}\r
\r
static void transportDelete(Rm_Transport *transport)\r
@@ -156,7 +157,7 @@ Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransport
if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
sizeof(Rm_Packet),\r
&pktHandle)) == NULL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -193,7 +194,7 @@ Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTran
if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
sizeof(Rm_Packet),\r
&pktHandle)) == NULL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -217,7 +218,7 @@ Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHa
if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
sizeof(Rm_Packet),\r
&pktHandle)) == NULL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -248,7 +249,7 @@ Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportH
if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
sizeof(Rm_Packet),\r
&pktHandle)) == NULL) {\r
- transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -269,13 +270,16 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t
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
+ /* RM Servers cannot connect to other Servers. \r
+ * RM Client Delegates cannot connect to other Client Delegates.\r
+ * RM Clients cannot connect to other Clients */\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
- *result = RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE;\r
+ (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) ||\r
+ ((rmInst->instType == Rm_instType_CLIENT) &&\r
+ (transportCfg->remoteInstType == Rm_instType_CLIENT))) {\r
+ *result = RM_ERROR_INVALID_REMOTE_INST_TYPE;\r
return(NULL);\r
}\r
\r
@@ -286,14 +290,14 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t
(transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
(transportCfg->remoteInstType == Rm_instType_SERVER)))) {\r
- *result = RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD;\r
+ *result = RM_ERROR_ALREADY_REGD_SERVER_OR_CD;\r
return(NULL);\r
} \r
\r
if (transportCfg->transportCalloutsValid &&\r
((transportCfg->transportCallouts.rmAllocPkt == NULL) ||\r
(transportCfg->transportCallouts.rmSendPkt == NULL))) {\r
- *result = RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED;\r
+ *result = RM_ERROR_NULL_CALLOUTS_WHEN_VALID;\r
return(NULL);\r
}\r
else {\r
rmInst->registeredWithDelegateOrServer = true;\r
}\r
\r
- *result = RM_INIT_OK;\r
+ *result = RM_OK;\r
return ((Rm_TransportHandle) transport);\r
}\r
\r
{\r
Rm_Transport *transport = (Rm_Transport *)transportHandle;\r
Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle;\r
- int32_t retVal = RM_TRANSPORT_SUCCESSFUL; \r
+ int32_t retVal = RM_OK; \r
\r
if (transportIsTransportRegistered(transport->rmHandle, transport)) {\r
if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
transportDelete(transport);\r
}\r
else {\r
- retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
+ retVal = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;\r
}\r
return (retVal);\r
}\r
Rm_Transaction *transaction;\r
\r
if (!transportIsTransportRegistered(transport->rmHandle, transport)) {\r
- return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
+ return (RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST);\r
}\r
\r
switch (pkt->pktType) {\r
Rm_ResourceResponsePkt *resourceRespPkt = (Rm_ResourceResponsePkt *)pkt->data;\r
\r
if (transaction = rmTransactionQueueFind(rmInst,resourceRespPkt->responseId)) {\r
+ if ((transaction->state == RM_SERVICE_APPROVED_STATIC) &&\r
+ (resourceRespPkt->requestState != RM_SERVICE_APPROVED)) {\r
+ /* Lock the RM instance since service validated against static policy failed against \r
+ * Server's global policy */\r
+ rmInst->isLocked = true;\r
+ }\r
transaction->state = resourceRespPkt->requestState;\r
\r
- if ((transaction->state == RM_SERVICE_APPROVED_AND_COMPLETED) &&\r
+ if ((transaction->state == RM_SERVICE_APPROVED) &&\r
((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
(transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {\r
rmTransactionProcessor(rmInst, transaction);\r
}\r
else {\r
- return (RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND);\r
+ return (RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ);\r
}\r
break;\r
}\r
Rm_NsResponsePkt *nsResponsePkt = (Rm_NsResponsePkt *)pkt->data;\r
\r
if (transaction = rmTransactionQueueFind(rmInst, nsResponsePkt->responseId)) {\r
+ if ((transaction->state == RM_SERVICE_APPROVED_STATIC) &&\r
+ (nsResponsePkt->requestState != RM_SERVICE_APPROVED)) {\r
+ /* Lock the RM instance since service validated against static policy failed against \r
+ * Server's global policy */ \r
+ rmInst->isLocked = true;\r
+ } \r
transaction->state = nsResponsePkt->requestState; \r
rmTransactionProcessor(rmInst, transaction);\r
}\r
else {\r
- return (RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND);\r
+ return (RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ);\r
}\r
break;\r
}\r
default:\r
- return (RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE);\r
+ return (RM_ERROR_RECEIVED_INVALID_PACKET_TYPE);\r
}\r
\r
- return (RM_TRANSPORT_SUCCESSFUL);\r
+ return (RM_OK);\r
}\r
\r
diff --git a/src/rm_tree.c b/src/rm_tree.c
index f1496e48df52fd9f85f840830ef40735f655ad58..7f2d78d866ceb57be2ad0d9bb0e3fcdd6ac615bc 100644 (file)
--- a/src/rm_tree.c
+++ b/src/rm_tree.c
/* Standard includes */
#include <string.h>
+#include <stdbool.h>
/* RM external API includes */
#include <ti/drv/rm/rm.h>
strncpy(newNode->name, instName, RM_NAME_MAX_CHARS);
newNode->allocRefCount = 0;
- newNode->deletePending = FALSE;
+ newNode->deletePending = false;
return(newNode);
}
diff --git a/test/rm_osal.c b/test/rm_osal.c
index 258eb47c029408a2bc36570d6496cba518bf3bef..54b13604e5d117a56a94dd0bc8bc312dd8ab0b6a 100644 (file)
--- a/test/rm_osal.c
+++ b/test/rm_osal.c
*
* \par
*/
+#include <stdarg.h>
+
#include <xdc/std.h>
#include <xdc/runtime/Memory.h>
#include <xdc/runtime/Error.h>
-
-#include <ti/sysbios/family/c64p/Hwi.h>
-
- /* CSL modules */
-#include <ti/csl/csl_semAux.h>
-/* CSL Cache module includes */
-#include <ti/csl/csl_cacheAux.h>
-/* CSL XMC module includes */
-#include <ti/csl/csl_xmcAux.h>
+#include <xdc/runtime/System.h>
/**********************************************************************
****************************** Defines *******************************
**********************************************************************/
-#define RM_HW_SEM 2
-
/**********************************************************************
************************** Global Variables **************************
**********************************************************************/
uint32_t rmMallocCounter = 0;
uint32_t rmFreeCounter = 0;
-uint32_t rmMtSem = 0;
-
/**********************************************************************
*************************** OSAL Functions **************************
**********************************************************************/
Memory_free(NULL, ptr, size);
}
-/**
- * @b Description
- * @n
- * The function is used to enter a critical section.
- * Function protects against
- *
- * access from multiple cores
- * and
- * access from multiple threads on single core
- *
- * @retval
- * Handle used to lock critical section
- */
-void* Osal_rmCsEnter (void)
-{
- /* Get the hardware semaphore */
- while ((CSL_semAcquireDirect (RM_HW_SEM)) == 0);
-
- /* Create Semaphore for protection against access from multiple threads
- * Not created here becasue application is not multithreaded
- * */
- return NULL;
-}
-
-/**
- * @b Description
- * @n
- * The function is used to exit a critical section
- * protected using Osal_rmCsEnter() API.
- *
- * @param[in] CsHandle
- * Handle for unlocking critical section.
- *
- * @retval
- * Not Applicable
- */
-void Osal_rmCsExit (void *CsHandle)
-{
- /* Release Semaphore using handle */
-
- /* Release the hardware semaphore */
- CSL_semReleaseSemaphore (RM_HW_SEM);
-
- return;
-}
-/**
- * @b Description
- * @n
- * The function is used to enter a critical section.
- * Function protects against
- * access from multiple threads on single core
- *
- * @retval
- * Handle used to lock critical section
- */
-void* Osal_rmMtCsEnter (void)
-{
- /* Create Semaphore for protection against access from multiple threads
- * Not created here becasue application is not multithreaded
- * */
-
- /* Block while semaphore is taken */
- while (rmMtSem){};
-
- /* Take the semaphore if it's available */
- rmMtSem = 1;
-
- return ((void *)&rmMtSem);
-}
-
-/**
- * @b Description
- * @n
- * The function is used to exit a critical section
- * protected using Osal_rmCsEnter() API.
- *
- * @param[in] CsHandle
- * Handle for unlocking critical section.
- *
- * @retval
- * Not Applicable
- */
-void Osal_rmMtCsExit (void *CsHandle)
+void Osal_rmLog (char *fmt, ... )
{
- uint32_t *mtSem = (uint32_t *)CsHandle;
+ VaList ap;
- /* Release Semaphore using handle */
- *mtSem = 0;
-
- return;
-}
-
-/**
- * @b Description
- * @n
- * The function is used to indicate that a block of memory is
- * about to be accessed. If the memory block is cached then this
- * indicates that the application would need to ensure that the
- * cache is updated with the data from the actual memory.
- *
- * @param[in] ptr
- * Address of memory block
- *
- * @param[in] size
- * Size of memory block
- *
- * @retval
- * Not Applicable
- */
-void Osal_rmBeginMemAccess (void *ptr, uint32_t size)
-{
- uint32_t key;
-
- /* Disable Interrupts */
- key = Hwi_disable();
-
- /* Cleanup the prefetch buffer also. */
- CSL_XMC_invalidatePrefetchBuffer();
-
-#ifdef L2_CACHE
- /* Invalidate L2 cache. This should invalidate L1D as well.
- * Wait until operation is complete. */
- CACHE_invL2 (ptr, size, CACHE_FENCE_WAIT);
-#else
- /* Invalidate L1D cache and wait until operation is complete.
- * Use this approach if L2 cache is not enabled */
- CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
-#endif
-
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
-
- /* Reenable Interrupts. */
- Hwi_restore(key);
-
- return;
-}
-
-/**
- * @b Description
- * @n
- * The function is used to indicate that the block of memory has
- * finished being accessed. If the memory block is cached then the
- * application would need to ensure that the contents of the cache
- * are updated immediately to the actual memory.
- *
- * @param[in] ptr
- * Address of memory block
- *
- * @param[in] size
- * Size of memory block
- *
- * @retval
- * Not Applicable
- */
-void Osal_rmEndMemAccess (void *ptr, uint32_t size)
-{
- uint32_t key;
-
- /* Disable Interrupts */
- key = Hwi_disable();
-
-#ifdef L2_CACHE
- /* Writeback L2 cache. This should Writeback L1D as well.
- * Wait until operation is complete. */
- CACHE_wbL2 (ptr, size, CACHE_FENCE_WAIT);
-
-#else
- /* Writeback L1D cache and wait until operation is complete.
- * Use this approach if L2 cache is not enabled */
- CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
-#endif
-
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
-
- /* Reenable Interrupts. */
- Hwi_restore(key);
- return;
+ va_start(ap, fmt);
+ System_vprintf(fmt, ap);
+ va_end(ap);
}
diff --git a/test/rm_osal.h b/test/rm_osal.h
--- a/test/rm_osal.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * @file rm_osal.h
- *
- * @brief
- * This is the OS adaptation layer for the Resource Manager. This file should
- * be modified by the system integrator to their system/OS implementation
- * The file is provided as an 'example' template ported for XDC/BIOS.
- *
- * \par
- * NOTE:
- * (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_OSAL_H__
-#define __RM_OSAL_H__
-
-extern void* Osal_rmMalloc (uint32_t num_bytes);
-extern void Osal_rmFree (void *ptr, uint32_t size);
-extern void* Osal_rmCsEnter (void);
-extern void Osal_rmCsExit (void *CsHandle);
-extern void* Osal_rmMtCsEnter (void);
-extern void Osal_rmMtCsExit (void *CsHandle);
-extern void Osal_rmBeginMemAccess (void *ptr, uint32_t size);
-extern void Osal_rmEndMemAccess (void *ptr, uint32_t size);
-
-/* RM LLD OSAL Memory Allocation API are redefined to TEST application API */
-#define Rm_osalMalloc Osal_rmMalloc
-#define Rm_osalFree Osal_rmFree
-
-/* RM LLD OSAL Critical section and cache coherency APIs are used without redefinition in TEST application API */
-#define Rm_osalCsEnter Osal_rmCsEnter
-#define Rm_osalCsExit Osal_rmCsExit
-#define Rm_osalMtCsEnter Osal_rmMtCsEnter
-#define Rm_osalMtCsExit Osal_rmMtCsExit
-#define Rm_osalBeginMemAccess Osal_rmBeginMemAccess
-#define Rm_osalEndMemAccess Osal_rmEndMemAccess
-
-/* RM LLD OSAL Logging API is mapped directly to an XDC Runtime API */
-#define Rm_osalLog System_printf
-
-#endif /* __RM_OSAL_H__ */
-
diff --git a/test/rm_test.c b/test/rm_test.c
index 5889b4fa81b31967e3ee77f6cb9474cfe874ddad..74e9383432010631bda44fe003f5df43b42f6261 100644 (file)
--- a/test/rm_test.c
+++ b/test/rm_test.c
/* ----------------------------------- BIOS6 module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/family/c64p/Hwi.h>
/* ----------------------------------- Resource Manager Headers */
#include <ti/drv/rm/rm.h>
#include <ti/drv/rm/rm_transport.h>
#include <ti/drv/rm/rm_services.h>
+/* ----------------------------------- CSL Module Headers */
+#include <ti/csl/csl_semAux.h>
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+
/* ======== Task Handles ======== */
Task_Handle startupRmTskHandle;
Task_Handle testReceiveTskHandle;
Char cdFromClientQueueName[30] = "RM_CD_From_Client_Queue";
Char clientFromCdQueueName[30] = "RM_Client_From_CD_Queue";
+/* ======== Test Resource & NameServer Names ======== */
+Char resourceNameMemRegion[RM_NAME_MAX_CHARS] = "memory-regions";
+char resourceNameAccumCh[RM_NAME_MAX_CHARS] = "accumulator-ch";
+Char resourceNameGpQ[RM_NAME_MAX_CHARS] = "gp-queue";
+Char resourceNameAifQ[RM_NAME_MAX_CHARS] = "aif-queue";
+Char resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
+Char resourceNameAifRxCh[RM_NAME_MAX_CHARS] = "aif-rx-ch";
+
+Char nameServerNameFavQ[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
+
/* ======== RM Instance Handles ======== */
Rm_Handle rmServerHandle = NULL;
Rm_Handle rmClientDelegateHandle = NULL;
#pragma DATA_ALIGN (testSyncObj, 16)
syncObj testSyncObj;
+/**
+ * @b Description
+ * @n
+ * The function is used to indicate that a block of memory is
+ * about to be accessed. If the memory block is cached then this
+ * indicates that the application would need to ensure that the
+ * cache is updated with the data from the actual memory.
+ *
+ * @param[in] ptr
+ * Address of memory block
+ *
+ * @param[in] size
+ * Size of memory block
+ *
+ * @retval
+ * Not Applicable
+ */
+void beginMemAccess (void *ptr, uint32_t size)
+{
+ uint32_t key;
+
+ key = Hwi_disable();
+
+ /* Cleanup the prefetch buffer also. */
+ CSL_XMC_invalidatePrefetchBuffer();
+ /* Invalidate L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
+ asm (" nop 4");
+ asm (" nop 4");
+ asm (" nop 4");
+ asm (" nop 4");
+ Hwi_restore(key);
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to indicate that the block of memory has
+ * finished being accessed. If the memory block is cached then the
+ * application would need to ensure that the contents of the cache
+ * are updated immediately to the actual memory.
+ *
+ * @param[in] ptr
+ * Address of memory block
+ *
+ * @param[in] size
+ * Size of memory block
+ *
+ * @retval
+ * Not Applicable
+ */
+void endMemAccess (void *ptr, uint32_t size)
+{
+ uint32_t key;
+
+ key = Hwi_disable();
+
+ /* Writeback L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
+ asm (" nop 4");
+ asm (" nop 4");
+ asm (" nop 4");
+ asm (" nop 4");
+ Hwi_restore(key);
+}
+
+
void initSyncObj(void)
{
- Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ beginMemAccess((void *) &testSyncObj, sizeof(syncObj));
testSyncObj.sem = 0;
- Rm_osalEndMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ endMemAccess((void *) &testSyncObj, sizeof(syncObj));
}
void takeSyncObj(void)
{
- Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ beginMemAccess((void *) &testSyncObj, sizeof(syncObj));
testSyncObj.sem = 1;
- Rm_osalEndMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ endMemAccess((void *) &testSyncObj, sizeof(syncObj));
}
void waitOnSyncObj(void)
do {
/* Yield for other tasks */
Task_yield();
- Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ beginMemAccess((void *) &testSyncObj, sizeof(syncObj));
} while (testSyncObj.sem == 1);
}
void releaseSyncObj(void)
{
- Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ beginMemAccess((void *) &testSyncObj, sizeof(syncObj));
testSyncObj.sem = 0;
- Rm_osalEndMemAccess((void *) &testSyncObj, sizeof(syncObj));
+ endMemAccess((void *) &testSyncObj, sizeof(syncObj));
}
/* ======== RM Application Transport APIs ======== */
/* Create and attach RM packet to MessageQ message. All transports will allocate from the same heap */
rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
rmPkt->pktLenBytes = pktSize;
- Rm_osalEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
+ endMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
rmMsg->rmPkt = rmPkt;
*pktHandle = (Rm_PacketHandle)rmMsg;
}
@@ -219,7 +304,7 @@ int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHa
int32_t status;
/* Write back data that was written by RM after alloc */
- Rm_osalEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
+ endMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
/* Send the message to the remote side */
status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
/* Extract the Rm_Packet from the RM msg */
rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
- Rm_osalBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
+ beginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
/* Provide packet to RM for processing */
if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
responseInfo.resourceLength = serviceResponse->resourceLength;
responseInfo.serviceState = serviceResponse->serviceState;
}
+ else {
+ System_printf("Core %d: validation of static request with ID %d\n", MultiProc_self(),
+ serviceResponse->serviceId);
+ System_printf(" resource: %s, state: %d, base: %d, length: %d\n", serviceResponse->resourceName,
+ serviceResponse->serviceState,
+ serviceResponse->resourceBase,
+ serviceResponse->resourceLength);
+ }
}
bool blockForResponse(Rm_ServiceRespInfo *respInfo)
}
if ((respInfo->serviceState != RM_SERVICE_PROCESSING) &&
- (respInfo->serviceState != RM_SERVICE_APPROVED_AND_COMPLETED)) {
+ (respInfo->serviceState != RM_SERVICE_APPROVED) &&
+ (respInfo->serviceState != RM_SERVICE_APPROVED_STATIC)) {
System_printf("Core %d: Service request encountered error or denial: %d\n", MultiProc_self(),
respInfo->serviceState);
return(FALSE);
/* Delete the RM startup task */
System_printf("Core %d: Deleting RM startup task...\n", MultiProc_self());
- if (startupRmTskHandle)
- {
+ if (startupRmTskHandle) {
Task_delete(&startupRmTskHandle);
/* Set the task handle to be NULL so that the delete only occurs once */
startupRmTskHandle = NULL;
/* Open service ports on all the RM instances to test service requests from the different
* RM instances */
- if (MultiProc_self() == 0)
- {
+ if (MultiProc_self() == 0) {
rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
}
- else if (MultiProc_self() == 1)
- {
- rmClientDelegateServiceHandle = Rm_serviceOpenHandle(rmClientDelegateHandle, &result);
- rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
- }
memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
System_printf("Core %d: Testing NameServer features...\n", MultiProc_self());
/* Use the service ports to test the service requests */
- if (MultiProc_self() == 0)
- {
- char resourceName[RM_NAME_MAX_CHARS] = "gp-queue";
- char resourceNsName[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
-
- char aifName[RM_NAME_MAX_CHARS] = "aif-rx-ch";
- char memRegionName[RM_NAME_MAX_CHARS] = "memory-regions";
-
+ if (MultiProc_self() == 0) {
/* Issue the service request create a new NameServer object via the service port */
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = resourceName;
+ requestInfo.resourceName = resourceNameGpQ;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 1;
requestInfo.resourceAlignment = 0;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Issue the service request create a new NameServer object via the service port */
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = resourceName;
+ requestInfo.resourceName = resourceNameGpQ;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 1;
requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Issue the service request create a new NameServer object via the service port */
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = resourceName;
+ requestInfo.resourceName = resourceNameGpQ;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 1;
requestInfo.resourceAlignment = 200;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
Rm_printResourceStatus(rmServerHandle);
/* Issue the service request create a new NameServer object via the service port */
requestInfo.type = Rm_service_RESOURCE_MAP_TO_NAME;
- requestInfo.resourceName = resourceName;
+ requestInfo.resourceName = resourceNameGpQ;
requestInfo.resourceBase = 1002;
requestInfo.resourceLength = 1;
- requestInfo.resourceNsName = resourceNsName;
+ requestInfo.resourceNsName = nameServerNameFavQ;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s creating NameServer object...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- resourceNsName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ nameServerNameFavQ,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
}
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Wait for Client Delegate and Client to retrieve resource via the name and allocate it */
waitOnSyncObj();
/* Try to allocate the memory region taken by the Linux Kernel */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = memRegionName;
+ requestInfo.resourceName = resourceNameMemRegion;
requestInfo.resourceBase = 12;
requestInfo.resourceLength = 1;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Trying to reserve memory region taken by Linux...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Allocate some resources for testing tree interaction with multiple allocations from different instances */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 14;
requestInfo.resourceLength = 5;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 19;
requestInfo.resourceLength = 31;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
}
/* Wait for Client and Client Delegate to do their allocates */
/* Free resources to show tree handling of different frees */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_FREE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 25;
requestInfo.resourceLength = 3;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
}
Rm_printResourceStatus(rmServerHandle);
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_FREE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 34;
requestInfo.resourceLength = 3;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
}
Rm_printResourceStatus(rmServerHandle);
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_FREE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 28;
requestInfo.resourceLength = 6;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
}
Rm_printResourceStatus(rmServerHandle);
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 53;
requestInfo.resourceLength = 2;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 2;
requestInfo.resourceLength = 2;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
- rmServerName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmServerName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
Rm_printResourceStatus(rmServerHandle);
Rm_printResourceStatus(rmServerHandle);
}
- else if (MultiProc_self() == 1)
- {
- char resourceNsName[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
-
- char aifName[RM_NAME_MAX_CHARS] = "aif-rx-ch";
- char accumChName[RM_NAME_MAX_CHARS] = "accumulator-ch";
-
+ else if (MultiProc_self() == 1) {
/* Issue the service request for the resources tied to the name via the service port */
requestInfo.type = Rm_service_RESOURCE_GET_BY_NAME;
- requestInfo.resourceNsName = resourceNsName;
+ requestInfo.resourceNsName = nameServerNameFavQ;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s getting resources tied to NameServer object...\n", MultiProc_self(),
rmClientDelegateName);
rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s got Name: %s base: %d length: %d\n", MultiProc_self(),
- rmClientDelegateName,
- resourceNsName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s got Name: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientDelegateName,
+ nameServerNameFavQ,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
}
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Allocate the resources via the service port from the Client */
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
System_printf("Core %d: %s allocating resources...\n", MultiProc_self(), rmClientName);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resources: %s base: %d length: %d\n", MultiProc_self(),
- rmClientName,
- resourceNsName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resources: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ nameServerNameFavQ,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
}
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Release the syncObj so Server can print results of NameServer object add and resource allocate */
releaseSyncObj();
/* Free the named resource using the name via the service port from the Client */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_FREE;
- requestInfo.resourceNsName = resourceNsName;
+ requestInfo.resourceNsName = nameServerNameFavQ;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s freeing resource via name...\n", MultiProc_self(), rmClientName);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
- rmClientName,
- resourceNsName);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
+ rmClientName,
+ nameServerNameFavQ);
+ }
}
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Delete the name object from the NameServer */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_UNMAP_NAME;
- requestInfo.resourceNsName = resourceNsName;
+ requestInfo.resourceNsName = nameServerNameFavQ;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Deleting NameServer object: %s...\n", MultiProc_self(),
rmClientName,
- resourceNsName);
+ nameServerNameFavQ);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
- rmClientName,
- resourceNsName);
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
+ rmClientName,
+ nameServerNameFavQ);
+ }
}
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Release the syncObj so Server can print results of resource free and NameServer object delete. */
releaseSyncObj();
/* Allocate some resources for testing tree interaction with multiple allocations from different instances */
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 0;
requestInfo.resourceLength = 6;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmClientName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
- requestInfo.resourceName = aifName;
+ requestInfo.resourceName = resourceNameAifRxCh;
requestInfo.resourceBase = 50;
requestInfo.resourceLength = 7;
requestInfo.callback.serviceCallback = testServiceCallback;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmClientDelegateName,
- requestInfo.resourceName,
- requestInfo.resourceBase,
- requestInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientDelegateName,
+ requestInfo.resourceName,
+ requestInfo.resourceBase,
+ requestInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Release the syncObj so Server can print results of resource allocations */
releaseSyncObj();
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = accumChName;
+ requestInfo.resourceName = resourceNameAccumCh;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 5;
requestInfo.resourceAlignment = 4;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmClientDelegateName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientDelegateName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = accumChName;
+ requestInfo.resourceName = resourceNameAccumCh;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 2;
requestInfo.resourceAlignment = 1;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmClientName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
- requestInfo.resourceName = accumChName;
+ requestInfo.resourceName = resourceNameAccumCh;
requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
requestInfo.resourceLength = 2;
requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
- if (blockForResponse(&responseInfo))
- {
- System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
- rmClientName,
- responseInfo.resourceName,
- responseInfo.resourceBase,
- responseInfo.resourceLength);
- }
+ if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
+ (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
+ if (blockForResponse(&responseInfo)) {
+ System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ responseInfo.resourceName,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
/* Release the syncObj so Server can print results of resource allocations */
releaseSyncObj();
System_printf("Core %d: Registered RM Client <=> RM CD transport with RM Client instance\n", MultiProc_self());
}
- /* Creat the RM receive task. */
+ /* Create the RM receive task. */
System_printf("Core %d: Creating RM receive task...\n", MultiProc_self());
Task_Params_init (&taskParams);
testReceiveTskHandle = Task_create (testReceiveTsk, &taskParams, NULL);
*/
Int main(Int argc, Char* argv[])
{
- Rm_InitCfg rmInitCfg;
- Task_Params taskParams;
- FILE *globalResourceFp;
- FILE *linuxDtbFp;
- FILE *globalPolicyFp;
- Int globalResourceFileSize;
- Int linuxDtbFileSize;
- Int globalPolicyFileSize;
- void *globalResourceList = NULL;
- void *linuxDtb = NULL;
- void *globalPolicy = NULL;
- Int status;
- Int readSize;
- int32_t result;
+ Rm_InitCfg rmInitCfg;
+ Task_Params taskParams;
+ FILE *globalResourceFp;
+ FILE *linuxDtbFp;
+ FILE *globalPolicyFp;
+ FILE *staticPolicyFp;
+ Int globalResourceFileSize;
+ Int linuxDtbFileSize;
+ Int globalPolicyFileSize;
+ Int staticPolicyFileSize;
+ void *globalResourceList = NULL;
+ void *linuxDtb = NULL;
+ void *globalPolicy = NULL;
+ void *staticPolicy = NULL;
+ Int status;
+ Int readSize;
+ Rm_ServiceReqInfo requestInfo;
+ int32_t result;
System_printf ("*********************************************************\n");
System_printf ("********************** RM Testing ***********************\n");
/* Create the Server instance */
rmInitCfg.instName = &rmServerName[0];
rmInitCfg.instType = Rm_instType_SERVER;
- rmInitCfg.globalResourceList = globalResourceList;
- rmInitCfg.linuxDtb = linuxDtb;
- rmInitCfg.policy = globalPolicy;
+ rmInitCfg.instCfg.serverCfg.globalResourceList = globalResourceList;
+ rmInitCfg.instCfg.serverCfg.linuxDtb = linuxDtb;
+ rmInitCfg.instCfg.serverCfg.globalPolicy = globalPolicy;
rmServerHandle = Rm_init(&rmInitCfg, &result);
System_printf("Core %d: RM Server instance created. Result = %d\n", MultiProc_self(), result);
Rm_printResourceStatus(rmServerHandle);
}
else if (MultiProc_self()== 1) {
+ staticPolicyFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\device\\tci6614-static-policy.dtb", "rb");
+
+ fseek(staticPolicyFp, 0, SEEK_END);
+ staticPolicyFileSize = ftell(staticPolicyFp);
+ rewind(staticPolicyFp);
+ staticPolicy = Osal_rmMalloc(staticPolicyFileSize);
+ readSize = fread(staticPolicy, 1, staticPolicyFileSize, staticPolicyFp);
+ System_printf("Read Size compared to file size: %d : %d\n", readSize, staticPolicyFileSize);
+
/* Create the RM Client Delegate instance */
rmInitCfg.instName = &rmClientDelegateName[0];
rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
- rmInitCfg.globalResourceList = NULL;
- rmInitCfg.linuxDtb = NULL;
- rmInitCfg.policy = NULL;
+ rmInitCfg.instCfg.cdCfg.staticPolicy = staticPolicy;
rmClientDelegateHandle = Rm_init(&rmInitCfg, &result);
System_printf("Core %d: RM Client Delegate instance created. Result = %d\n", MultiProc_self(), result);
/* Create the RM Client instance */
rmInitCfg.instName = &rmClientName[0];
- rmInitCfg.instType = Rm_instType_CLIENT;
- rmInitCfg.globalResourceList = NULL;
- rmInitCfg.linuxDtb = NULL;
- rmInitCfg.policy = NULL;
+ rmInitCfg.instType = Rm_instType_CLIENT;
+ rmInitCfg.instCfg.clientCfg.staticPolicy = staticPolicy;
rmClientHandle = Rm_init(&rmInitCfg, &result);
System_printf("Core %d: RM Client instance created. Result = %d\n", MultiProc_self(), result);
+
+ /* Open service handles on the CD and Client to test static allocations */
+ rmClientDelegateServiceHandle = Rm_serviceOpenHandle(rmClientDelegateHandle, &result);
+ rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
+
+ /* Static allocations */
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = resourceNameQosCluster;
+ requestInfo.resourceBase = 0;
+ requestInfo.resourceLength = 1;
+ requestInfo.callback.serviceCallback = testServiceCallback;
+
+ System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
+ rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
+ System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
+ rmClientDelegateName,
+ resourceNameQosCluster,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
+
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = resourceNameQosCluster;
+ requestInfo.resourceBase = 2;
+ requestInfo.resourceLength = 1;
+ requestInfo.callback.serviceCallback = testServiceCallback;
+
+ System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
+ System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ resourceNameQosCluster,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
+
+ /* Next request should return error */
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = resourceNameQosCluster;
+ requestInfo.resourceBase = 1;
+ requestInfo.resourceLength = 1;
+ requestInfo.callback.serviceCallback = testServiceCallback;
+
+ System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
+ System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ resourceNameQosCluster,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
+
+ /* Allocated shared resource to both CD and Client using static policy */
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = resourceNameAifQ;
+ requestInfo.resourceBase = 525;
+ requestInfo.resourceLength = 1;
+ requestInfo.callback.serviceCallback = testServiceCallback;
+
+ System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
+ rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
+ System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
+ rmClientDelegateName,
+ resourceNameAifQ,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
+
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = resourceNameAifQ;
+ requestInfo.resourceBase = 525;
+ requestInfo.resourceLength = 1;
+ requestInfo.callback.serviceCallback = testServiceCallback;
+
+ System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
+ System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
+ rmClientName,
+ resourceNameAifQ,
+ responseInfo.resourceBase,
+ responseInfo.resourceLength);
+ }
+ else {
+ System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(),
+ responseInfo.serviceState);
+ }
}
System_printf("Core %d: Starting IPC...\n", MultiProc_self());
index 6a183c10617e55f0e46f99604c308c0423c4b51d..9cb21c950762fc45a160ec0ce3f1c97a8beb9cdb 100644 (file)
--- a/test/rm_testproject.txt
+++ b/test/rm_testproject.txt
-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_test.c"
-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_osal.c"
--ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_osal.h"
-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_test.cfg"
-ccs.setCompilerOptions "-mv6600 -g --diag_warning=225 -I${PDK_INSTALL_PATH}/ti/drv/rm"
-rtsc.enableRtsc