summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1a0f987)
raw | patch | inline | side by side (parent: 1a0f987)
author | Justin Sobota <jsobota@ti.com> | |
Tue, 2 Jun 2015 22:07:33 +0000 (18:07 -0400) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Tue, 2 Jun 2015 22:07:33 +0000 (18:07 -0400) |
17 files changed:
index a4029c035c711ce6d5540bb30b9a8c2f2804178d..f9bfbabf46475f1373ab16ba1cfda20debe6855b 100644 (file)
--- a/include/rm_dtb_utilloc.h
+++ b/include/rm_dtb_utilloc.h
* Private Resource List and Policy DTB Parsing Utilities
*
* ============================================================================
- * (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * (C) Copyright 2012-2015, Texas Instruments, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
**********************************************************************/
Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char *propertyName);
-Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr, int32_t dtbDataLen);
+Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr,
+ int32_t dtbDataLen);
void rmDtbUtilResFreeRange(Rm_ResourceRange *rangeList);
-Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen,
+Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr,
+ int32_t dtbDataLen,
int32_t *result);
void rmDtbUtilResFreeLinuxAlias(Rm_LinuxAlias *aliasList);
-Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen,
+Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr,
+ int32_t dtbDataLen,
int32_t *result);
void rmDtbUtilResFreeNsAssignmentList(Rm_NsAssignment *nsAssignmentList);
Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr,
int32_t dtbDataLen);
void rmDtbUtilPolicyFreeAssignments(Rm_PolicyAssignment *assignmentList);
-Rm_ResourceValue *rmDtbUtilPolicyExtractCdAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen);
+Rm_ResourceValue *rmDtbUtilPolicyExtractCdAllocationSizes(const void *dtbDataPtr,
+ int32_t dtbDataLen);
void rmDtbUtilPolicyFreeCdAllocationSizes(Rm_ResourceValue *allocationSizeList);
-Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen);
+Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr,
+ int32_t dtbDataLen);
void rmDtbUtilPolicyFreeResourceAlignments (Rm_ResourceValue *alignmentList);
Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
int32_t dtbDataLen,
********************* Linux DTB Parsing Functions ********************
**********************************************************************/
-Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen);
+Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr,
+ int32_t dtbDataLen);
void rmDtbUtilLinuxFreeValues(Rm_LinuxValueRange *valueList);
#ifdef __cplusplus
diff --git a/include/rm_internal.h b/include/rm_internal.h
index 898ca3b817339f9833c6e076c09146645cd15955..952ab201ab5b042bc27169c1010e41bcb2f5322f 100644 (file)
--- a/include/rm_internal.h
+++ b/include/rm_internal.h
* Data structures used by more than one internal RM module.
*
* ============================================================================
- * (C) Copyright 2012-2014, Texas Instruments, Inc.
+ * (C) Copyright 2012-2015, Texas Instruments, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
if (rmInst->instType == Rm_instType_SHARED_SERVER) { \
Rm_osalEndMemAccess((void *)rmInst, sizeof(Rm_Inst)); \
Rm_osalCsExit(csKey); \
- }
+ }
/* Shared server invalidate macro */
#define RM_SS_OBJ_INV(rmInst, obj, objType) \
#define RM_SS_OBJ_WB(rmInst, obj, objType) \
if (rmInst->instType == Rm_instType_SHARED_SERVER) { \
Rm_osalEndMemAccess((void *)obj, sizeof(objType)); \
- }
+ }
/* RM resource information */
typedef struct {
diff --git a/include/rm_policyloc.h b/include/rm_policyloc.h
index 94893782ed8c25130ed7f4af8276abf94cf22175..9608515a4d042a652cff123249586cced52d6b48 100644 (file)
--- a/include/rm_policyloc.h
+++ b/include/rm_policyloc.h
/* Index of global permission bits in policy tree node permission array */
#define RM_POLICY_GLOBAL_PERM_INDEX 0
-/* String stored for resource elements that are reserved by the Linux kernel. These
- * resources will be in use for the lifetime of the system
+/* String stored for resource elements that are reserved by the Linux kernel.
+ * These resources will be in use for the lifetime of the system
*
- * TODO: MOVE TO policy.h LATER SO INTEGRATORS KNOW NOT TO NAME RM INSTANCES THIS NAME */
+ * TODO: MOVE TO policy.h LATER SO INTEGRATORS KNOW NOT TO NAME RM INSTANCES
+ * THIS NAME */
#define RM_ALLOCATED_TO_LINUX "Linux-Kernel"
-/* Policy permission bit storage type
+/* Policy permission bit storage definition for Rm_PolicyPermBits
* Bit : Description
*-----------------------------
- * 0 : Init (i) - RM instance has initialization permission for resource
+ * 0 : Init (i) - RM instance has initialization permission for
+ * resource
* 1 : Use (u) - RM instance has usage permission for resource
- * 2 : Exclusive (x) - RM instance has exclusive allocation privilege for resource
- * i.e. No other RM instance can reserve the resource if a RM
- * instance with exclusive privilege reserves the resource
- * 3 : Shared Linux (s) - Resource has been reserved by the Linux kernel but can be
- * allocated by the specified RM instances
+ * 2 : Exclusive (x) - RM instance has exclusive allocation privilege for
+ * resource i.e. No other RM instance can reserve the
+ * resource if a RM instance with exclusive privilege
+ * reserves the resource
+ * 3 : Shared Linux (s) - Resource has been reserved by the Linux kernel but
+ * can be allocated by the specified RM instances
* 4 - 31 : UNUSED
*/
/* Permissions assignment character */
#define RM_POLICY_PERM_ASSIGNMENT '='
-/* Policy bit mask */
+/* Full permissions bit mask */
#define RM_policy_PERM_FULL_MASK ((1 << RM_POLICY_PERM_MAX_BITS) - 1)
+/* Calculates number of instance permission sets per permission word */
#define RM_policy_PERM_INST_PER_WORD \
((sizeof(Rm_PolicyPermBits) * 8) / RM_POLICY_PERM_MAX_BITS)
+/* Calculates the instance's word index into the permission word array */
#define RM_policy_PERM_INDEX(instIdx) \
(instIdx / RM_policy_PERM_INST_PER_WORD)
+/* Calculates the instance's bit offset into the permission word */
#define RM_policy_PERM_OFFSET(instIdx) \
((instIdx % RM_policy_PERM_INST_PER_WORD) * \
RM_POLICY_PERM_MAX_BITS)
+/* Sets a permission for an instance */
#define RM_policy_PERM_SET(permArray, wordIdx, wordOffset, permOffset, val) \
permArray[wordIdx] &= ~(0x1 << (wordOffset + permOffset)); \
permArray[wordIdx] |= (val & 0x1) << (wordOffset + permOffset);
+/* Gets a permission for an instance */
#define RM_policy_PERM_GET(permArray, wordIdx, wordOffset, permOffset) \
((permArray[wordIdx] >> (wordOffset + permOffset)) & 0x1)
index 74e064daa0e63b69dc1b858d98ef17c1a4d4c582..828dae19a7101557cbdad266d3231d93595c9325 100644 (file)
* Private data structures of Resource Manager transport layer.
*
* ============================================================================
- * (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * (C) Copyright 2012-2015, Texas Instruments, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
/* RM internal includes */
#include <ti/drv/rm/include/rm_internal.h>
-/* This macro generates compilier error if postulate is false, so
+/* This macro generates compilier error if postulate is false, so
* allows 0 overhead compile time size check. This "works" when
* the expression contains sizeof() which otherwise doesn't work
* with preprocessor */
} \
while (0)
-/* Check assumptions RM request/response packets fit in RM_TRANSPORT_PACKET_MAX_SIZE_BYTES */
+/* Check assumptions RM request/response packets fit in
+ * RM_TRANSPORT_PACKET_MAX_SIZE_BYTES */
#define RM_PACKET_SIZE_CHECK \
- RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceRequestPkt)); \
- RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceResponsePkt)); \
- RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsRequestPkt)); \
- RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsResponsePkt)); \
+ RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
+ sizeof(Rm_ResourceRequestPkt)); \
+ RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
+ sizeof(Rm_ResourceResponsePkt)); \
+ RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
+ sizeof(Rm_NsRequestPkt)); \
+ RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
+ sizeof(Rm_NsResponsePkt)); \
/* RM transport list node */
typedef struct Rm_Transport_s {
} Rm_ResourceReqPktType;
/* Resource Request Packet - Packet sent to CDs and Servers to request
- * a resource service that cannot be handled on the local RM instance due to
+ * a resource service that cannot be handled on the local RM instance due to
* permission restrictions. */
typedef struct {
/* Transaction ID associated with the request packet */
uint32_t requestId;
/* Resource request type */
Rm_ResourceReqPktType resourceReqType;
- /* RM instance name from which the request packet originated. Used by
+ /* RM instance name from which the request packet originated. Used by
* receiving instance to route the response */
- char pktSrcInstName[RM_NAME_MAX_CHARS];
- /* Name of RM instance that is issuing the service request. The instance
+ char pktSrcInstName[RM_NAME_MAX_CHARS];
+ /* Name of RM instance that is issuing the service request. The instance
* name will be used to validate the request against the RM policy defined
* for the instance. */
- char serviceSrcInstName[RM_NAME_MAX_CHARS];
+ char serviceSrcInstName[RM_NAME_MAX_CHARS];
/* Resource request information */
Rm_ResourceInfo resourceInfo;
} Rm_ResourceRequestPkt;
/* Resource Response Packet - Packet sent to RM instances that requested
- * a resource service. The packet will contain resource response
+ * a resource service. The packet will contain resource response
* information based on the request */
typedef struct {
/* responseID will equal the requestId received in the resource request
- * packet. This ID should be associated with a transaction stored in
+ * 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
* NameServer mapping or unmapping data */
typedef struct {
/* Transaction ID associated with the NameServer request packet */
- uint32_t requestId;
+ uint32_t requestId;
/* NameServer request type */
Rm_NsReqPktType nsRequestType;
- /* RM instance name from which the request packet originated. Used by
+ /* RM instance name from which the request packet originated. Used by
* receiving instance to route the response */
char pktSrcInstName[RM_NAME_MAX_CHARS];
/* RM instance name making the service request. Policies may restrict who
int32_t requestState;
} Rm_NsResponsePkt;
-Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType);
+Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports,
+ Rm_InstType remoteInstType);
#ifdef __cplusplus
}
diff --git a/include/rm_treeloc.h b/include/rm_treeloc.h
index dc2f8c8930319ec31e87b3e2d9569dd9fdfccb46..e31250a123cf5151a890cab1e83ff89b18746b9d 100644 (file)
--- a/include/rm_treeloc.h
+++ b/include/rm_treeloc.h
typedef RB_HEAD(_Rm_AllocatorResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
/* Policy permission bit storage type
- * Bit : Description
- *-----------------------------
- * 0 : Init (i) - RM instance has initialization permission for resource
- * 1 : Use (u) - RM instance has usage permission for resource
- * 2 : Exclusive (x) - RM instance has exclusive allocation privilege for resource
- * i.e. No other RM instance can reserve the resource if a RM
- * instance with exclusive privilege reserves the resource
- * 3 : Shared Linux (s) - Resource has been reserved by the Linux kernel but can be
- * allocated by the specified RM instances
- * 4 - 31 : UNUSED
- */
+ * See rm_policyloc.h for bit by bit usage of this type */
typedef uint32_t Rm_PolicyPermBits;
/* Policy node */
index 8282e18690ddc8610e791d134c088b38c6fc99ba..55d3ef0b9112ef81ec3f7e646a2b2ccb31868a04 100644 (file)
--- a/rm.h
+++ b/rm.h
*
* @section intro Introduction
*
- * The Resource Manager (RM) is designed to provide an easy to use, extensible
- * uinified resource management solution on TI devices. RM can be integrated by
- * a system application to provide resource management services to the system
- * temporally (pre-main/post-main) and spatially (system subcomponents, task,
- * cores).
+ * The Resource Manager (RM) is designed to provide an easy to use,
+ * extensible uinified resource management solution on TI devices. RM can be
+ * integrated by a system application to provide resource management services
+ * to the system temporally (pre-main/post-main) and spatially (system
+ * subcomponents, task, cores).
*
- * The RM architecture is instance based. All RM resource management services
- * must originate from a RM instance. Resource permissions are assigned by a
- * system integrator using RM instance names provided during the initialization
- * of each RM instance in use. There are three types of RM instances, all of
- * which can be used by the system to request resource management services:
+ * The RM architecture is instance based. All RM resource management
+ * services must originate from a RM instance. Resource permissions are
+ * assigned by a system integrator using RM instance names provided during the
+ * initialization of each RM instance in use. There are three types of RM
+ * instances, all of which can be used by the system to request resource
+ * management services:
* - Server - Manages all resource data structures including the resource
* allocators, the permissions policies, and a simple NameServer.
* There can only be one Server per RM ecosystem. If two Servers
* are initialized within a system they must manage mutually
- * exclusive sets of device resources. There is no limit to the
+ * exclusive sets of device resources. There is no limit to the
* number of Client and Client Delegate instances that can connect
* to the Server
- * - Client - Used by system components to request resource services. There is
- * no limit to the number of Clients a system can have. Client
- * names must be unique since resource permissions are assigned based
- * on RM instance names. Clients can connect to at most one Server
- * or Client Delegate, but not both at the same time.
+ * - Client - Used by system components to request resource services. There
+ * is no limit to the number of Clients a system can have. Client
+ * names must be unique since resource permissions are assigned
+ * based on RM instance names. Clients can connect to at most
+ * one Server or Client Delegate, but not both at the same time.
* - Client Delegate (CD) - At the moment the CD is not different from the
- * Client. However, in the future the CD will be able
- * to act as a proxy for the Server. The CD will be
- * able to satisfy some service requests from Clients,
- * offloading some processing from the Server. This
- * feature will be helpful in situations where a
- * slower data path exists between the Server and
- * CD/Client instances. There is no limit to the number
- * of Clients that can connect to a CD. The CD can
- * connect to at most one Server.
+ * Client. However, in the future the CD will be
+ * able to act as a proxy for the Server. The CD
+ * will be able to satisfy some service requests
+ * from Clients, offloading some processing from
+ * the Server. This feature will be helpful in
+ * situations where a slower data path exists
+ * between the Server and CD/Client instances.
+ * There is no limit to the number of Clients that
+ * can connect to a CD. The CD can connect to at
+ * most one Server.
*
- * RM instances communicate via a generic transport interface. The RM transport
- * interface expects the application to configure and manage the transport data paths
- * between RM instances. This allows RM to easily extend to different device
- * configurations and different devices entirely.
+ * RM instances communicate via a generic transport interface. The RM
+ * transport interface expects the application to configure and manage the
+ * transport data paths between RM instances. This allows RM to easily
+ * extend to different device configurations and different devices entirely.
*
- * Shared memory versions of the Server and Client are available for configuration
- * in cases where the DSP applications cannot tolerate blocking operations or long wait
- * times for resources. The Shared Server - Shared Client model assumes all memory
- * allocated via the OSAL layer is within shared memory. RM service requests
- * received from Shared Servers and Shared Clients will be handled via accesses
- * to the resource management data structures existing in shared memory.
- * - Shared Server - Essentially a Server instance that expects to be allocated
- * from shared memory via the application-supplied OSAL functions.
- * Shared Client instances will piggyback on the Shared Server
- * instance to allocate/free resources without the need to setup
- * transports between the instances. Access to the resource
- * management data structures is managed through OSAL implemented
- * cache writeback and invalidate operations.
- * - Shared Client - Must be provided a Shared Server handle at initialization time.
- * The Shared Client will essentially use the resource management
- * data structures, created in shared memory when the Shared Server
- * was initialized, to handle any server requests.
-
- * RM utilizes the BDS-licensed, open source, Flattened Device Tree format to
- * specify what resources are managed by RM as well as the RM instance permissions
- * for managed resources. The Global Resource List or GRL defines all device
- * resources and their ranges that will be tracked by the RM Server. Addition or
- * subtraction of resources from RM requires one modify only the GRL. RM source code
- * changes are not required to add or subtract resources from RM's umbrella of
- * management. RM Policies specify resource permissions for the RM instances. There
- * are two types of Policies:
- * - Global Policy - Provided to the Server at initialization and defines the
- * resource permissions for all RM instances in the system.
- * All service requests will be validated against the Global
- * Policy on the Server. If the RM instance is found to not
- * hold the privileges for the request a denial of the service
- * will be issued back to the requesting instance.
+ * Shared memory versions of the Server and Client are available for
+ * configuration in cases where the DSP applications cannot tolerate blocking
+ * operations or long wait times for resources. The Shared Server - Shared
+ * Client model assumes all memory allocated via the OSAL layer is within
+ * shared memory. RM service requests received from Shared Servers and
+ * Shared Clients will be handled via accesses to the resource management
+ * data structures existing in shared memory.
+ * - Shared Server - Essentially a Server instance that expects to be
+ * allocated from shared memory via the application-supplied
+ * OSAL functions. Shared Client instances will piggyback
+ * on the Shared Server instance to allocate/free resources
+ * without the need to setup transports between the
+ * instances. Access to the resource management data
+ * structures is managed through OSAL implemented cache
+ * writeback and invalidate operations.
+ * - Shared Client - Must be provided a Shared Server handle at initialization
+ * time. The Shared Client will essentially use the
+ * resource management data structures, created in shared
+ * memory when the Shared Server was initialized, to handle
+ * any server requests.
+ *
+ * RM utilizes the BDS-licensed, open source, Flattened Device Tree format to
+ * specify what resources are managed by RM as well as the RM instance
+ * permissions for managed resources. The Global Resource List or GRL defines
+ * all device resources and their ranges that will be tracked by the
+ * RM Server. Addition or subtraction of resources from RM requires one
+ * modify only the GRL. RM source code changes are not required to add or
+ * subtract resources from RM's umbrella of management. RM Policies specify
+ * resource permissions for the RM instances. There are two types of
+ * Policies:
+ * - Global Policy - Provided to the Server at initialization and defines
+ * the resource permissions for all RM instances in the
+ * system. All service requests will be validated against
+ * the Global Policy on the Server. If the RM instance is
+ * found to not hold the privileges for the request a
+ * denial of the service will be issued back to the
+ * requesting instance.
* - Static Policy - Optionally provided to Client and CD instances at
- * initialization. Allows these instances to statically
+ * initialization. Allows these instances to statically
* allocate resources. This feature is typically used
* for RM instances that must allocate resources prior
- * to the transport connection to the Server being established.
- * Resources allocated via any Static Policies will
- * be validated against the Global Policy once the transport
+ * to the transport connection to the Server being
+ * established. Resources allocated via any Static
+ * Policies will be validated against the Global Policy
+ * once the transport
* to the Server has been fully established. If a Static
- * Policy request fails validation with the Global Policy the
- * RM instance that issued the static request will be placed
- * into a locked state. The locked state prevents any further
- * service requests from the instance.
+ * Policy request fails validation with the Global Policy
+ * the RM instance that issued the static request will be
+ * placed into a locked state. The locked state prevents
+ * any further service requests from the instance.
*
- * Combined, the GRL and Policy Device Tree implementations allow RM to easily extend
- * to new resources without the need to recompile the RM source code.
+ * Combined, the GRL and Policy Device Tree implementations allow RM to easily
+ * extend to new resources without the need to recompile the RM source code.
*
* RM instances currently provides the following resource services:
* - Allocate (initialize) - Allocate a resource for initialization
* - Allocate (usage) - Allocate a resource for use
- * - Status - Return the reference count for a specified resource
- * - Free - Free an allocated resource (The free must originate
- * from the RM instance that allocated the resource
+ * - Status - Return the reference count for a specified
+ * resource
+ * - Free - Free an allocated resource (The free must
+ * originate from the RM instance that allocated
+ * the resource
* - Map resource to name - Map a specified resource to a NameServer name
* - Unmap named resource - Unmap a resource from an existing NameServer name
- * - Get resource by name - Returns a resource based on a provided NameServer name
+ * - Get resource by name - Returns a resource based on a provided NameServer
+ * name
*/
-
+
/* Define RM_API as a master group in Doxygen format and add all RM API
definitions to this group. */
/** @defgroup RM_API Resource Manager API
#define RM_SERVICE_PENDING_SERVER_RESPONSE 2
/** RM has approved requested service */
#define RM_SERVICE_APPROVED 3
-/** RM has approved requested service based on static policy. Request will be validated
- * against global policy once all transports have been registered */
+/** 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 4
/** RM service request denial reasons base */
#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) */
+/** 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) */
+/** 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 */
+/** 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
#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 */
+/** 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 */
+/** 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 */
+/** 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
-/** Allocate request denied because the resource is already reserved by Linux and "Shared Linux"
- * privileges are not assigned to the requesting instance */
+/** Allocate request denied because the resource is already reserved by Linux
+ * and "Shared Linux" privileges are not assigned to the requesting instance */
#define RM_SERVICE_DENIED_RES_NOT_SHARED_LINUX RM_SERVICE_DENIED_BASE+17
-/** Status request resource range partially found (Handling of partial status requests not yet implemented) */
+/** Status request resource range partially found (Handling of partial status
+ * requests not yet implemented) */
#define RM_SERVICE_DENIED_PARTIAL_STATUS RM_SERVICE_DENIED_BASE+18
-/** RM Client Delegate instance is not stable. RM system operation cannot be guarateed
- * if a CD instance is used. At the time please manage resources using Server and Client
- * instances - tracked by SDOCM00100797 */
+/** RM Client Delegate instance is not stable. RM system operation cannot be
+ * guarateed if a CD instance is used. At the time please manage resources
+ * using Server and Client instances - tracked by SDOCM00100797 */
#define RM_WARNING_CD_INSTANCE_NOT_STABLE (-1024)
/** Start of libfdt.h error codes */
#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 */
+/** 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
#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)"; */
+/** 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
+/** 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 */
+/** 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 and/or service request
- * is greater than RM_NAME_MAX_CHARS */
+/** NameServer name in global resource list nameServer assignment and/or
+ * service request is greater than RM_NAME_MAX_CHARS */
#define RM_ERROR_NAMESERVER_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
#define RM_ERROR_RES_SPECIFIED_MORE_THAN_ONCE RM_ERROR_BASE-19
/** 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-20
-/** RM server was not provided a Global Resource List (GRL) and global policy at initialization */
+/** RM server was not provided a Global Resource List (GRL) and global policy
+ * at initialization */
#define RM_ERROR_INVALID_SERVER_CONFIGURATION RM_ERROR_BASE-21
/** Service request type not recognized */
#define RM_ERROR_INVALID_SERVICE_TYPE RM_ERROR_BASE-22
/** rmAllocPkt transport callout returned NULL for rmPkt */
#define RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR RM_ERROR_BASE-23
-/** rmSendPkt transport callout returned error when attempting to send the rmPkt */
+/** rmSendPkt transport callout returned error when attempting to send the
+ * rmPkt */
#define RM_ERROR_TRANSPORT_SEND_ERROR RM_ERROR_BASE-24
/** A RM service transaction could not be created for the service request */
#define RM_ERROR_SERVICE_TRANS_NOT_CREATED RM_ERROR_BASE-25
/** RM service transaction could not be found in instance's transaction queue */
#define RM_ERROR_SERVICE_TRANS_DOES_NOT_EXIST RM_ERROR_BASE-26
-/** NameServer does not exist in instance, cannot satisfy NameServer service request */
+/** NameServer does not exist in instance, cannot satisfy NameServer service
+ * request */
#define RM_ERROR_NAMESERVER_DOES_NOT_EXIST RM_ERROR_BASE-27
/** Service request to add a name to the NameServer failed */
#define RM_ERROR_NAMESERVER_NAME_ADD_FAILED RM_ERROR_BASE-28
/** Could not find name specified in service request in NameServer */
#define RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST RM_ERROR_BASE-29
-/** Service request made on Client or CD when no transport established and no static policy registered */
+/** 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-30
/** RM transport handle has not been registered with the RM instance */
#define RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST RM_ERROR_BASE-31
#define RM_ERROR_RECEIVED_INVALID_PACKET_TYPE RM_ERROR_BASE-32
/** RM response packet does not match any requests sent from instance */
#define RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ RM_ERROR_BASE-33
-/** Server attempted to connect to another server or a CD attempted to connect to another CD or
- * Client attempted to connect to another client */
+/** 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-34
-/** RM client attempted to register with more than one Server or CD or a CD attempted to register
- * with more than one Server */
+/** 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-35
/** Instance type not recognized */
#define RM_ERROR_INVALID_INST_TYPE RM_ERROR_BASE-36
-/** RM attempted to allocate a transport packet but the rmAllocPkt callout was not registered */
+/** RM attempted to allocate a transport packet but the rmAllocPkt callout was
+ * not registered */
#define RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD RM_ERROR_BASE-37
-/** RM attempted to send a packet but the rmSendPkt callout was not registered */
+/** RM attempted to send a packet but the rmSendPkt callout was not
+ * registered */
#define RM_ERROR_TRANSPORT_SEND_NOT_REGD RM_ERROR_BASE-38
/** RM instance cannot be deleted with transports still registered */
#define RM_ERROR_CANT_DELETE_WITH_REGD_TRANSPORT RM_ERROR_BASE-39
/** RM instance cannot be deleted with open service handle */
#define RM_ERROR_CANT_DELETE_WITH_OPEN_SERV_HNDL RM_ERROR_BASE-40
-/** RM instance cannot be deleted when there are transactions pending and the
+/** RM instance cannot be deleted when there are transactions pending and the
* ignorePendingServices parameter is set to false */
#define RM_ERROR_CANT_DELETE_PENDING_TRANSACTIONS RM_ERROR_BASE-41
/** Only the Server instance can be used to return resource status via the
* Rm_resourceStatus API */
#define RM_ERROR_INVALID_RES_STATUS_INSTANCE RM_ERROR_BASE-42
-/** RM Shared Server and Client instances should always return a finished request since
- * the instance has access to the resource structures no matter what core the service
- * is requested from */
+/** RM Shared Server and Client instances should always return a finished
+ * request since the instance has access to the resource structures no matter
+ * what core the service is requested from */
#define RM_ERROR_SHARED_INSTANCE_UNFINISHED_REQ RM_ERROR_BASE-43
/** RM Shared Server and Client instances cannot register transports */
#define RM_ERROR_SHARED_INSTANCE_CANNOT_REG_TRANS RM_ERROR_BASE-44
-/** RM Shared Client handle was provided an invalid Shared Server handle. The shared
- * server handle was either NULL or was not an instance of type Rm_instType_SHARED_SERVER */
+/** RM Shared Client handle was provided an invalid Shared Server handle.
+ * The shared server handle was either NULL or was not an instance of type
+ * Rm_instType_SHARED_SERVER */
#define RM_ERROR_INVALID_SHARED_SERVER_HANDLE RM_ERROR_BASE-45
-/** A RM Client failed to create a new transaction to request data from the Server in order
- * to potentially process a transaction on a Client Delegate */
+/** A RM Client failed to create a new transaction to request data from the
+ * Server in order to potentially process a transaction on a Client Delegate */
#define RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED RM_ERROR_BASE-46
-/** Service request required a policy check but instance was not initialized with a policy */
+/** Service request required a policy check but instance was not initialized
+ * with a policy */
#define RM_ERROR_INSTANCE_HAS_NO_POLICY RM_ERROR_BASE-47
/** RM Client Delegate was not provided a policy at initialization */
#define RM_ERROR_INVALID_CD_CONFIGURATION RM_ERROR_BASE-48
-/** RM CD freed local resources which allowed a free request of local request to be sent to
- * the Server. The Server free failed so the CD tried to realloc the local resources
- * that were originally freed. The re-allocate operation failed causing a resource loss
- * on the CD */
+/** RM CD freed local resources which allowed a free request of local request
+ * to be sent to the Server. The Server free failed so the CD tried to
+ * realloc the local resources that were originally freed. The re-allocate
+ * operation failed causing a resource loss on the CD */
#define RM_ERROR_LOST_RESOURCES_ON_CD RM_ERROR_BASE-49
-/** The service source inst name and RM packet source instance names are not available
- * for the given type of RM packet */
+/** The service source inst name and RM packet source instance names are not
+ * available for the given type of RM packet */
#define RM_ERROR_PKT_AND_SERVICE_SRC_NOT_AVAIL RM_ERROR_BASE-50
-/** The provided character buffer that will contain the service source inst name or pkt
- * source inst name is not of size RM_NAME_MAX_CHARS */
+/** The provided character buffer that will contain the service source inst
+ * name or pkt source inst name is not of size RM_NAME_MAX_CHARS */
#define RM_ERROR_SRC_NAME_BUF_INVALID_SIZE RM_ERROR_BASE-51
-/** A resource name specified in the GRL, policy, and/or service request is greater than
- * RM_NAME_MAX_CHARS */
+/** A resource name specified in the GRL, policy, and/or service request is
+ * greater than RM_NAME_MAX_CHARS */
#define RM_ERROR_RESOURCE_NAME_TOO_LONG RM_ERROR_BASE-52
-/** RM failed to create a new allocator - Occurred because an instance that does not use
- * allocators tried to create one (RM Client) */
+/** RM failed to create a new allocator - Occurred because an instance that
+ * does not use allocators tried to create one (RM Client) */
#define RM_ERROR_COULD_NOT_CREATE_NEW_ALLOCATOR RM_ERROR_BASE-53
/** Could not allocate the memory needed to store the root entry of the
* allocator tree */
*/
#define RM_NAME_MAX_CHARS (32)
-/**
+/**
* @brief RM instance handle. The RM handle is used to register transports
* between RM instances and request resource services from the RM
* instance.
*/
typedef void *Rm_Handle;
-/**
+/**
* @brief RM instance types
*/
typedef enum {
* @brief RM client delegate (CD) initialization configurations
*/
typedef struct {
- /** Pointer to a client delegate policy used by the CD to allocate resources
+ /** Pointer to a client delegate policy used by the CD to allocate resources
* without contacting the server. The cdPolicy will be used by the CD to
* determine whether clients connected to the CD can be allocated resources
* provided to the CD by the server.
*
* The cdPolicy will also act as a static policy until the transport to the
- * server has been established. Static allocations can occur before the
- * instance has been attached to a server instance within the RM system.
- * This is useful for allocating resources prior to main(). Resources allocated
- * via the static policy will be verified against the global policy once the
- * CD connects with the server. The static policy must be in DTB format.
+ * server has been established. Static allocations can occur before the
+ * instance has been attached to a server instance within the RM system.
+ * This is useful for allocating resources prior to main(). Resources
+ * allocated via the static policy will be verified against the global
+ * policy once the CD connects with the server. The static policy must be
+ * in DTB format.
*
* To guarantee proper resource permission synchronization between the CD
* and server the cdPolicy must either be an exact copy of the globalPolicy
- * or a exact replica of a subset of the globalPolicy provided to the server
- * at initialization. */
+ * or a exact replica of a subset of the globalPolicy provided to the
+ * server at initialization. */
void *cdPolicy;
} Rm_ClientDelegateCfg;
* @brief RM client initialization configurations
*/
typedef struct {
- /** Pointer to a static policy used by the client to allocate resources statically.
- * Static allocations can occur before the instance has been attached to a server
- * or CD instance within the RM system. This is useful for allocating resources
- * prior to main(). Resources allocated via the static policy will be verified
- * against the global policy once the client connects with the server (directly or
- * indirectly through a CD). The static policy must be in DTB format. */
+ /** Pointer to a static policy used by the client to allocate resources
+ * statically. Static allocations can occur before the instance has been
+ * attached to a server or CD instance within the RM system. This is
+ * useful for allocating resources prior to main(). Resources allocated
+ * via the static policy will be verified against the global policy once
+ * the client connects with the server (directly or indirectly through a
+ * CD). The static policy must be in DTB format. */
void *staticPolicy;
} Rm_ClientCfg;
* @brief RM shared client initialization configurations
*/
typedef struct {
- /** RM Shared Server handle. Typically, the Shared Server handle is created on
- * DSP core designated for system initialization. The application then
- * the Shared Server handle, located in shared memory, to the other DSP cores.
- * These DSP cores can then piggyback onto the shared memory data structures in
- * the Shared Server via the Shared Client */
+ /** RM Shared Server handle. Typically, the Shared Server handle is
+ * created on DSP core designated for system initialization. The
+ * application then the Shared Server handle, located in shared memory, to
+ * the other DSP cores. These DSP cores can then piggyback onto the
+ * shared memory data structures in the Shared Server via the Shared
+ * Client */
Rm_Handle sharedServerHandle;
} Rm_SharedClientCfg;
-/**
+/**
* @brief RM instance initialization structure
*/
typedef struct {
- /** Pointer to a character array containing the instance name. The name of the
- * RM instance can be no greater than #RM_NAME_MAX_CHARS. The instance name
- * must match an instance name defined in the "valid-instances" lists contained
- * in the global and static policy DTS files. Resources and privileges to the
- * resources will be based on the name assigned to the RM instance*/
+ /** Pointer to a character array containing the instance name. The name of
+ * the RM instance can be no greater than #RM_NAME_MAX_CHARS. The instance
+ * name must match an instance name defined in the "valid-instances" lists
+ * contained in the global and static policy DTS files. Resources and
+ * privileges to the resources will be based on the name assigned to the
+ * RM instance*/
const char *instName;
/** The type of RM instance that will be created. */
Rm_InstType instType;
- /** Instance's multi-threaded semaphore object. Two or more RM instances can have
- * their service transactions to the Server serialized by providing a valid
- * multi-threaded semaphore object. The semaphore object will be used by the
- * Osal_rmMtCsEnter and Osal_rmMtCsExit functions. The multi-threaded
- * semaphore associated with the provided object will be taken when a
- * service transaction is requested. The semaphore will be released when
- * the service response is returned. This will serialize the transactions
- * of any RM instance initialized with the same multi-threaded sem object.
- * Multi-threaded semaphores will not be used if NULL is provided as the object */
+ /** Instance's multi-threaded semaphore object. Two or more RM instances
+ * can have their service transactions to the Server serialized by
+ * providing a valid multi-threaded semaphore object. The semaphore
+ * object will be used by the Osal_rmMtCsEnter and Osal_rmMtCsExit
+ * functions. The multi-threaded semaphore associated with the provided
+ * object will be taken when a service transaction is requested. The
+ * semaphore will be released when the service response is returned. This
+ * will serialize the transactions of any RM instance initialized with the
+ * same multi-threaded sem object. Multi-threaded semaphores will not be
+ * used if NULL is provided as the object */
uint32_t *mtSemObj;
/** Instance-type specific configurations */
union {
/**
* @b Description
- * @n
+ * @n
* This function prints and returns the status for all resources managed by
* the RM instance network. The allocate/free status as well as ownership
* status will be printed for every resource. Also, the NameServer name
*
* @retval
* Success - Total number of allocated resource nodes owners. Effectively
- * returns the number of resource ranges still allocated.
+ * returns the number of resource ranges still allocated.
* @retval
- * Failure - #RM_ERROR_INVALID_RES_STATUS_INSTANCE
+ * Failure - #RM_ERROR_INVALID_RES_STATUS_INSTANCE
*/
int32_t Rm_resourceStatus(Rm_Handle rmHandle, int printResources);
/**
* @b Description
- * @n
+ * @n
* This function prints the current status of a RM instance. The
* following instance properties will be printed:
* a) instance name & type
/**
* @b Description
- * @n
+ * @n
* This function initializes a RM instance. There are no restrictions
* on the amount of times this function can be called. Each call will
* result in a new RM instance. However, a network of RM instances
/**
* @b Description
- * @n
+ * @n
* This function deletes the specified RM instance. All memory
* associated with the instance will be freed.
*
* Instance handle.
*
* @param[in] ignorePendingServices
- * Non-zero - The instance will be deleted despite any services pending <br>
+ * Non-zero - The instance will be deleted despite any services pending<br>
* 0 - The instance will not be deleted due to at least one service
* pending.
*
/**
* @b Description
- * @n
+ * @n
* The function is used to get the version information of RM.
*
* @retval
/**
* @b Description
- * @n
+ * @n
* The function is used to get the version string for RM.
*
* @retval
*/
const char* Rm_getVersionStr(void);
-/**
-@}
+/**
+@}
*/
#ifdef __cplusplus
diff --git a/rm_osal.h b/rm_osal.h
index fbee72006466e9838f67bc0803195bfd94d8746a..9038850a390b89920b63def853e53c8afb4eac93 100644 (file)
--- a/rm_osal.h
+++ b/rm_osal.h
*
* @brief
* This is the sample OS Adaptation layer which is used by the Resource
- * Manager. The OSAL layer can be ported in either of the following
+ * Manager. The OSAL layer can be ported in either of the following
* manners to a native OS:
*
* <b> Approach 1: </b>
* @n Use Prebuilt Libraries
- * - Ensure that the provide an implementation of all
+ * - Ensure that the provide an implementation of all
* Osal_XXX API for their native OS.
* - Link the prebuilt libraries with their application.
* - Refer to the "example" directory for an example of this
* - Customers can reuse prebuilt TI provided libraries
* @n <b> Cons: </b>
* - Level of indirection in the API to get to the actual OS call
- *
+ *
* <b> Approach 2: </b>
* @n Rebuilt Library
* - Create a copy of this file and modify it to directly
* inline the native OS calls
- * - Rebuild the RM low level drivver library; ensure that the Include
- * path points to the directory where the copy of this file
+ * - Rebuild the RM low level drivver library; ensure that the Include
+ * path points to the directory where the copy of this file
* has been provided.
- * - Please refer to the "test" directory for an example of this
+ * - Please refer to the "test" directory for an example of this
* @n <b> Pros: </b>
* - Optimizations can be done to remove the level of indirection
* @n <b> Cons: </b>
*
* \par
* NOTE:
- * (C) Copyright 2012-2013 Texas Instruments, Inc.
+ * (C) Copyright 2012-2015 Texas Instruments, Inc.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
#define RM_OSAL_H_
/** @addtogroup RM_OSAL_API
- @{
+ @{
*/
/**********************************************************************
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void* Osal_rmMalloc (uint32_t numBytes)
- @endverbatim
- *
+ * void* Osal_rmMalloc (uint32_t numBytes)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Number of bytes to be allocated
*
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmFree (void *ptr, uint32_t size)
- @endverbatim
- *
+ * void Osal_rmFree (void *ptr, uint32_t size)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Pointer to the block of memory to be cleaned up.
* @n Size of the allocated memory which is being freed.
/**
* @brief The function is used to enter a critical section.
* Function protects against
- *
+ *
* access from multiple cores
* and
* access from multiple threads on single core
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void *Osal_rmCsEnter (void)
- @endverbatim
- *
+ * void *Osal_rmCsEnter (void)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Not applicable.
*
#define Rm_osalCsEnter Osal_rmCsEnter
/**
- * @brief The function is used to exit a critical section
+ * @brief The function is used 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
- *
+ * void Osal_rmCsExit (void *CsHandle)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Handle for unlocking critical section.
*
/**
* @brief The function is used to enter a multi-threaded critical
- * section. Function protects against
- *
+ * section. Function protects against
+ *
* 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 *mtSemObj)
- @endverbatim
- *
+ * void *Osal_rmMtCsEnter (void *mtSemObj)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Multi-threaded critical section object handle.
*
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmMtCsExit (void *mtSemObj, void *CsHandle)
- @endverbatim
+ * void Osal_rmMtCsExit (void *mtSemObj, void *CsHandle)
+ * @endverbatim
*
* <b> Parameter </b>
* @n Multi-threaded critical section object handle.
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmBeginMemAccess (void *ptr, uint32_t size)
- @endverbatim
- *
+ * void Osal_rmBeginMemAccess (void *ptr, uint32_t size)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Address of memory block
* @n Size of memory block
#define Rm_osalBeginMemAccess Osal_rmBeginMemAccess
/**
- * @brief 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.
+ * @brief 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.
*
* <b> Prototype: </b>
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmEndMemAccess (void *ptr, uint32_t size)
- @endverbatim
- *
+ * void Osal_rmEndMemAccess (void *ptr, uint32_t size)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Address of memory block
* @n Size of memory block
* @brief The macro is used by RM to create a task blocking
* mechanism allowing a RM instance to block when it
* has not been provided a service callback function
- * and it must send a packet to remote RM instance
+ * and it must send a packet to remote RM instance
* to complete a service.
*
* <b> Prototype: </b>
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void *Osal_rmTaskBlockCreate (void)
- @endverbatim
- *
+ * void *Osal_rmTaskBlockCreate (void)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Not applicable.
*
/**
* @brief The macro is used by a RM instance to block when it
* has not been provided a service callback function
- * and it must send a packet to remote RM instance
+ * and it must send a packet to remote RM instance
* to complete a service. The blocking operation
* should block the current RM instance's task/thread
* from executing until a task/thread from which the
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmTaskBlock (void *handle)
- @endverbatim
- *
+ * void Osal_rmTaskBlock (void *handle)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Task blocking mechanism handle cast as a void pointer
*
#define Rm_osalTaskBlock Osal_rmTaskBlock
/**
- * @brief The macro is used by a RM instance to unblock from
+ * @brief The macro is used by a RM instance to unblock from
* a previous block operation.
*
* <b> Prototype: </b>
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmTaskUnblock (void *handle)
- @endverbatim
- *
+ * void Osal_rmTaskUnblock (void *handle)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Task blocking mechanism handle cast as a void pointer
*
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmTaskBlockDelete (void *handle)
- @endverbatim
- *
+ * void Osal_rmTaskBlockDelete (void *handle)
+ * @endverbatim
+ *
* <b> Parameter </b>
* @n Task blocking mechanism handle cast as a void pointer
*
/**
* @brief The macro is used by RM to log various
- * messages.
+ * messages.
*
* <b> Prototype: </b>
* The following is the C prototype for the expected OSAL API.
*
* @verbatim
- void Osal_rmLog( char *fmt, ... )
- @endverbatim
+ * void Osal_rmLog( char *fmt, ... )
+ * @endverbatim
*
* <b> Parameter </b>
* @n printf-style format string
diff --git a/rm_services.h b/rm_services.h
index ec9c21e79c30b13f8858540658623bd4b1086035..a2f3bba0cf7f0f123b1f27260b1585e051bcfe9a 100644 (file)
--- a/rm_services.h
+++ b/rm_services.h
/**
* @file rm_services.h
*
- * @brief
- * This is the RM include file for services provided to components that
+ * @brief
+ * This is the RM include file for services provided to components that
* register a RM instance
*
* \par
* ============================================================================
- * @n (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * @n (C) Copyright 2012-2015, Texas Instruments, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Rm_service_LAST
} Rm_ServiceType;
-/**
+/**
* @brief RM service response information used by RM to provide service
* request results back to the application components
*/
typedef struct {
- /** RM instance handle from which the service request that spawned this
+ /** RM instance handle from which the service request that spawned this
* result originated. Used by application to sort responses, received
* via callback function, from RM instances located on the same core. */
Rm_Handle rmHandle;
/** Service request state. State values can be found in rm.h starting
- * with #RM_SERVICE_PROCESSING, #RM_SERVICE_DENIED_BASE, and
+ * with #RM_SERVICE_PROCESSING, #RM_SERVICE_DENIED_BASE, and
* #RM_ERROR_LIBFDT_START */
int32_t serviceState;
/** The service ID is returned to the application in order to match service
uint32_t serviceId;
/** Affected resource name */
char resourceName[RM_NAME_MAX_CHARS];
- /** The resource base value allocated, freed, or mapped to NameServer name. */
+ /** The resource base value allocated, freed, or mapped to NameServer
+ * name. */
int32_t resourceBase;
/** The resource length starting at base allocated, freed, or mapped to
* NameServer name. */
uint32_t resourceLength;
/** resourceNumOwners is not valid unless >= 0 */
-#define RM_RESOURCE_NUM_OWNERS_INVALID (-1)
+#define RM_RESOURCE_NUM_OWNERS_INVALID (-1)
/** Current number of owners for the returned resource. A value greater
* than one means the resource is being shared. This value is only valid
- * if the serviceState is RM_SERVICE_APPROVED or RM_SERVICE_APPROVED_STATIC. */
+ * if the serviceState is RM_SERVICE_APPROVED or
+ * RM_SERVICE_APPROVED_STATIC. */
int32_t resourceNumOwners;
/** instAllocCount is not valid unless >= 0 */
-#define RM_INST_ALLOC_COUNT_INVALID (-1)
- /** Number of times the requesting instance has allocated the returned resource.
- * This value is only valid if the serviceState is RM_SERVICE_APPROVED or
- * RM_SERVICE_APPROVED_STATIC */
+#define RM_INST_ALLOC_COUNT_INVALID (-1)
+ /** Number of times the requesting instance has allocated the returned
+ * resource. This value is only valid if the serviceState is
+ * RM_SERVICE_APPROVED or RM_SERVICE_APPROVED_STATIC */
int32_t instAllocCount;
} Rm_ServiceRespInfo;
-/**
+/**
* @brief RM service callback function
*/
typedef struct {
- /** Component callback function. RM calls this function when a blocking
+ /** Component callback function. RM calls this function when a blocking
* resource service request is complete. The callback function supplied
* for this parameter must match the function pointer prototype. */
void (*serviceCallback) (Rm_ServiceRespInfo *serviceResponse);
} Rm_ServiceCallback;
-/**
+/**
* @brief RM service request information
*/
typedef struct {
* property defined.
* b) The default alignment of 1 if no alignment is specified in the policy
* for the resource.
- * This value is only valid if resourceBase is set to #RM_RESOURCE_BASE_UNSPECIFIED */
-#define RM_RESOURCE_ALIGNMENT_UNSPECIFIED (-1)
+ * This value is only valid if resourceBase is set to
+ * #RM_RESOURCE_BASE_UNSPECIFIED */
+#define RM_RESOURCE_ALIGNMENT_UNSPECIFIED (-1)
/** Alignment of the resource affected by the service request. Only valid
* if resourceBase is set to #RM_RESOURCE_BASE_UNSPECIFIED.
* #RM_RESOURCE_ALIGNMENT_UNSPECIFIED can be substituted. */
int32_t resourceAlignment;
- /** The NameServer name associated, or to be associated, with a resource.
- * The NameServer name has precedence over #resourceBase and #resourceLength
- * for all resource modification service types as well as
+ /** The NameServer name associated, or to be associated, with a resource.
+ * The NameServer name has precedence over #resourceBase and
+ * #resourceLength for all resource modification service types as well as
* #Rm_service_RESOURCE_GET_BY_NAME. If the NameServer name and the base
* and length are not NULL the resource information retrieved from the
* NameServer entry for the name will replace the values present in
Rm_ServiceCallback callback;
} Rm_ServiceReqInfo;
-/**
+/**
* @brief RM service handle provided to application components for requesting
* services
*/
void *rmHandle;
/**
* @b Description
- * @n
+ * @n
* Processes service requests from application components. Responses
- * are returned immediately if the service request could be satisfied
- * without blocking. If the service request requires a blocking operation,
- * such as forwarding the service request to another instance for
- * validation, the response will be received via the Rm_ServerCallback
+ * are returned immediately if the service request could be satisfied
+ * without blocking. If the service request requires a blocking
+ * operation, such as forwarding the service request to another
+ * instance for validation, the response will be received via the
+ * Rm_ServerCallback
*
* @param[in] rmHandle
* RM instance handle specifies the instance that handles the service
- * request. The request's result, if policy checks are involved, will be
- * based on the permissions assigned to the rmHandle's instance name within
- * global/static policy.
- *
+ * request. The request's result, if policy checks are involved, will
+ * be based on the permissions assigned to the rmHandle's instance
+ * name within global/static policy.
+ *
* @param[in] serviceRequest
* Pointer to the service request structure
*
* @param[out] serviceResponse
* Pointer to a service response structure.
*/
- void (*Rm_serviceHandler)(void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
+ void (*Rm_serviceHandler)(void *rmHandle,
+ const Rm_ServiceReqInfo *serviceRequest,
Rm_ServiceRespInfo *serviceResponse);
} Rm_ServiceHandle;
/**
* @b Description
- * @n
- * This function returns a RM service handle to the application to
- * provide services to software components (LLDs, BIOS, etc) that want to use RM
- * for resource management. Only one service handle can be opened from
- * each RM instance.
+ * @n
+ * This function returns a RM service handle to the application to
+ * provide services to software components (LLDs, BIOS, etc) that want to
+ * use RM for resource management. Only one service handle can be opened
+ * from each RM instance.
*
* @param[in] rmHandle
* RM instance handle from which the service handle will be opened
* @retval
* Success - Rm_ServiceHandle and result = #RM_OK
* @retval
- * Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED
+ * Failure - NULL Rm_ServiceHandle and
+ * result = #RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED
*/
Rm_ServiceHandle *Rm_serviceOpenHandle(Rm_Handle rmHandle, int32_t *result);
/**
* @b Description
- * @n
+ * @n
* This function closes a RM instance's service handle
*
* @param[in] rmServiceHandle
*/
int32_t Rm_serviceCloseHandle(Rm_ServiceHandle *rmServiceHandle);
-/**
-@}
+/**
+@}
*/
#ifdef __cplusplus
diff --git a/rm_transport.h b/rm_transport.h
index 426a3cbe7117638bce5985353fd492a14d5f79c8..05c8793733c1bfb1efe57a8b6985c01f2b4857c6 100644 (file)
--- a/rm_transport.h
+++ b/rm_transport.h
*
* \par
* ============================================================================
- * @n (C) Copyright 2012-2014, Texas Instruments, Inc.
+ * @n (C) Copyright 2012-2015, Texas Instruments, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
*/
#define RM_TRANSPORT_PACKET_MAX_SIZE_BYTES (256)
-/**
+/**
* @brief RM transport handle
*/
typedef void *Rm_TransportHandle;
* a Rm_AppTransportHandle to the application any time RM
* wants to alloc or send a packet via the transport callouts
*/
-typedef void *Rm_AppTransportHandle;
+typedef void *Rm_AppTransportHandle;
/**
* @brief A void pointer to the start of a registered application transport
typedef enum {
/** Allocate/Free request packet */
Rm_pktType_RESOURCE_REQUEST = 0,
- /** Allocate/Free response packet */
+ /** Allocate/Free response packet */
Rm_pktType_RESOURCE_RESPONSE,
/** RM NameServer mapping request */
Rm_pktType_NAMESERVER_REQUEST,
Rm_pktType_NAMESERVER_RESPONSE
} Rm_pktType;
-/**
+/**
* @brief RM transport layer packet
*/
typedef struct {
/**
* @b Description
* @n
- * This function pointer describes the RM transport layer packet
+ * This function pointer describes the RM transport layer packet
* allocation function. The application must supply an alloc function
- * to RM instances at transport registration if the RM instance is
+ * to RM instances at transport registration if the RM instance is
* intended to communicate with other RM instances. The function
* provided by the application must match this prototype. The provided
* function implements the allocation of packet buffers from the
- * application data path that the RM transport will use to send messages
- * between RM instances. The Rm_Packet pointer will point to start of
- * the data buffer containing the RM packet data. The pktHandle will
- * point to the start of the application data path "packet" data
- * structure. The Rm_Packet pointer and pktHandle cannot be NULL. They
- * will either be different or the same value based on the application
- * transport.
+ * application data path that the RM transport will use to send
+ * messages between RM instances. The Rm_Packet pointer will point to
+ * start of the data buffer containing the RM packet data. The
+ * pktHandle will point to the start of the application data path
+ * "packet" data structure. The Rm_Packet pointer and pktHandle cannot
+ * be NULL. They will either be different or the same value based on
+ * the application transport.
*
* @param[in] appTransport
* Application transport handle to allocate packet from. This value
* @retval
* Failure - NULL
*/
- Rm_Packet *(*rmAllocPkt)(Rm_AppTransportHandle appTransport, uint32_t pktSize,
- Rm_PacketHandle *pktHandle);
+ Rm_Packet *(*rmAllocPkt)(Rm_AppTransportHandle appTransport,
+ uint32_t pktSize,
+ Rm_PacketHandle *pktHandle);
/**
* @b Description
- * @n
- * This function pointer describes the RM transport layer packet
+ * @n
+ * This function pointer describes the RM transport layer packet
* send function. The application must supply a send function
- * to RM instances at transport registration if the RM instance is
+ * to RM instances at transport registration if the RM instance is
* intended to communicate with other RM instances. The function
* provided by the application must match this prototype. The provided
* function implements the sending of application data path packets,
* @retval
* < 0 - Packet send failed.
*/
- int32_t (*rmSendPkt)(Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle);
+ int32_t (*rmSendPkt)(Rm_AppTransportHandle appTransport,
+ Rm_PacketHandle pktHandle);
} Rm_TransportCallouts;
-/**
+/**
* @brief RM transport registration configuration structure
*/
typedef struct {
* should be sent on. For example, a QMSS queue number, network
* port data structure, etc. */
Rm_AppTransportHandle appTransportHandle;
- /** Remote RM instance type at other end of the application transport
+ /** Remote RM instance type at other end of the application transport
* "pipe". */
Rm_InstType remoteInstType;
/** Pointers to application implemented transport APIs. The APIs for the
* for each registered transport. However, based on the application's
* implementation of transport code the same function can be provided
* for each transport registration. In these cases, the transport
- * must mux/demux the packets it receives from RM based on the
+ * must mux/demux the packets it receives from RM based on the
* #Rm_TransportHandle. */
- Rm_TransportCallouts transportCallouts;
+ Rm_TransportCallouts transportCallouts;
} Rm_TransportCfg;
-/**
+/**
* @brief RM transport reconfiguration structure
*/
typedef struct {
* for each registered transport. However, based on the application's
* implementation of transport code the same function can be provided
* for each transport registration. In these cases, the transport
- * must mux/demux the packets it receives from RM based on the
+ * must mux/demux the packets it receives from RM based on the
* #Rm_TransportHandle. */
- Rm_TransportCallouts transportCallouts;
+ Rm_TransportCallouts transportCallouts;
} Rm_TransportReCfg;
/**
* @b Description
- * @n
+ * @n
* This function is used to register transports with RM for sending and
* receiving packets between RM instances over application transport
* data paths.
* @retval
* Success - RM_TransportHandle and result = #RM_OK
* @retval
- * Failure - NULL RM_TransportHandle and result = #RM_ERROR_INVALID_REMOTE_INST_TYPE
+ * Failure - NULL RM_TransportHandle and
+ * result = #RM_ERROR_INVALID_REMOTE_INST_TYPE
* @retval
- * Failure - NULL RM_TransportHandle and result = #RM_ERROR_ALREADY_REGD_SERVER_OR_CD
+ * Failure - NULL RM_TransportHandle and
+ * result = #RM_ERROR_ALREADY_REGD_SERVER_OR_CD
* @retval
- * Failure - NULL RM_TransportHandle and result = #RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD
+ * Failure - NULL RM_TransportHandle and
+ * result = #RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD
* @retval
- * Failure - NULL RM_TransportHandle and result = #RM_ERROR_TRANSPORT_SEND_NOT_REGD
+ * Failure - NULL RM_TransportHandle and
+ * result = #RM_ERROR_TRANSPORT_SEND_NOT_REGD
*/
-Rm_TransportHandle Rm_transportRegister(const Rm_TransportCfg *transportCfg, int32_t *result);
+Rm_TransportHandle Rm_transportRegister(const Rm_TransportCfg *transportCfg,
+ int32_t *result);
/**
* @b Description
- * @n
+ * @n
* This function reconfigures an existing transport handle using the
* provided transport configurations
*
@@ -292,11 +299,12 @@ Rm_TransportHandle Rm_transportRegister(const Rm_TransportCfg *transportCfg, int
* @retval
* Failure - #RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST
*/
-int32_t Rm_transportReconfig (Rm_TransportHandle transportHandle, const Rm_TransportReCfg *transportReCfg);
+int32_t Rm_transportReconfig(Rm_TransportHandle transportHandle,
+ const Rm_TransportReCfg *transportReCfg);
/**
* @b Description
- * @n
+ * @n
* This function unregisters the provided transportHandle from the
* RM instance
*
@@ -309,11 +317,11 @@ int32_t Rm_transportReconfig (Rm_TransportHandle transportHandle, const Rm_Trans
* @retval
* Failure - #RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST
*/
-int32_t Rm_transportUnregister (Rm_TransportHandle transportHandle);
+int32_t Rm_transportUnregister(Rm_TransportHandle transportHandle);
/**
* @b Description
- * @n
+ * @n
* This function returns the RM instance name from which the service
* encapsulated within the RM packet originated
*
* Success - #RM_OK
* @retval
* Failure - #RM_ERROR_PKT_AND_SERVICE_SRC_NOT_AVAIL
- * Failure - #RM_ERROR_SRC_NAME_BUF_INVALID_SIZE
+ * Failure - #RM_ERROR_SRC_NAME_BUF_INVALID_SIZE
*/
-int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt, char *serviceInstName,
+int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt,
+ char *serviceInstName,
int32_t charBufLen);
/**
* @b Description
- * @n
+ * @n
* This function returns the RM instance name from which the RM packet
* originated
*
@@ -366,12 +375,13 @@ int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt, char *serviceInstNa
* Failure - #RM_ERROR_PKT_AND_SERVICE_SRC_NOT_AVAIL
* Failure - #RM_ERROR_SRC_NAME_BUF_INVALID_SIZE
*/
-int32_t Rm_receiveGetPktSrcName(const Rm_Packet *pkt, char *pktInstName,
+int32_t Rm_receiveGetPktSrcName(const Rm_Packet *pkt,
+ char *pktInstName,
int32_t charBufLen);
/**
* @b Description
- * @n
+ * @n
* This function is called by the application when it has received a RM
* packet for processing. The application provides the transportHandle
* associated with the RM instance that should receive the packet and
* @retval
* Success - #RM_OK
* @retval
- * Failure - < #RM_OK
+ * Failure - < #RM_OK
*/
-int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pkt);
+int32_t Rm_receivePacket(Rm_TransportHandle transportHandle,
+ const Rm_Packet *pkt);
-/**
-@}
+/**
+@}
*/
#ifdef __cplusplus
diff --git a/rmver.h.xdt b/rmver.h.xdt
index 8730a57d3734672a21e8ce88ac2b7df58cf70c5b..007ade8ab6d039cbce9dda11ccbe3c0f787d4db5 100644 (file)
--- a/rmver.h.xdt
+++ b/rmver.h.xdt
* @brief Resource Manager Version Definitions\r
*\r
* ============================================================\r
- * Copyright (c) Texas Instruments Incorporated 2012-2014\r
+ * Copyright (c) Texas Instruments Incorporated 2012-2015\r
* \r
* Redistribution and use in source and binary forms, with or without \r
* modification, are permitted provided that the following conditions \r
*/\r
\r
/**\r
- * @brief This is the RM Version. Versions numbers are encoded in the following \r
+ * @brief This is the RM Version. Versions numbers are encoded in the\r
+ * following\r
* format:\r
* 0xAABBCCDD -> Arch (AA); API Changes (BB); Major (CC); Minor (DD)\r
*/\r
#ifdef __cplusplus\r
}\r
#endif\r
- \r
+\r
\r
#endif /* _RMVER_H */\r
diff --git a/src/rm.c b/src/rm.c
index 81d3d27327cc395d740557db4a31fd7430b519a6..792b945ef1551b0b05b4b9ed299467f74274c91d 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
rmInst->transactionSeqNum++;
if (!rmInst->transactionSeqNum) {
rmInst->transactionSeqNum++;
- }
- return (rmInst->transactionSeqNum);
+ }
+ return(rmInst->transactionSeqNum);
}
/* FUNCTION PURPOSE: Creates a resource request packet
* is allocated via the rmAllocPkt API using the
* appTransport handle provided by the application
*/
-void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
+static void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName,
+ Rm_Transaction *transaction)
{
Rm_ResourceRequestPkt *resourceReqPkt = NULL;
-
+
rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;
resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;
resourceReqPkt->requestId = transaction->localId;
if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
- }
- else if (transaction->type == Rm_service_RESOURCE_STATUS) {
+ } else if (transaction->type == Rm_service_RESOURCE_STATUS) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_STATUS;
- }
- else if (transaction->type == Rm_service_RESOURCE_FREE) {
+ } else if (transaction->type == Rm_service_RESOURCE_FREE) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
- }
- else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+ } else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;
}
- rm_strncpy(resourceReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
- rm_strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
- memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
- sizeof(Rm_ResourceInfo));
+ rm_strncpy(resourceReqPkt->pktSrcInstName, localInstName,
+ RM_NAME_MAX_CHARS);
+ rm_strncpy(resourceReqPkt->serviceSrcInstName,
+ transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+ memcpy((void *)&(resourceReqPkt->resourceInfo),
+ (void *)&(transaction->resourceInfo),
+ sizeof(Rm_ResourceInfo));
}
/* FUNCTION PURPOSE: Creates a resource response packet
@@ -145,16 +145,18 @@ void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction
* is allocated via the rmAllocPkt API using the
* appTransport handle provided by the application
*/
-void createResourceResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+static void createResourceResponsePkt(Rm_Packet *rmPkt,
+ Rm_Transaction *transaction)
{
Rm_ResourceResponsePkt *resourceRespPkt = NULL;
-
- rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;
+
+ rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;
resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;
resourceRespPkt->responseId = transaction->remoteOriginatingId;
resourceRespPkt->requestState = transaction->state;
- memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),
- sizeof(Rm_ResourceInfo));
+ memcpy((void *)&(resourceRespPkt->resourceInfo),
+ (void *)&(transaction->resourceInfo),
+ sizeof(Rm_ResourceInfo));
}
/* FUNCTION PURPOSE: Creates a NameServer request packet
* is allocated via the rmAllocPkt API using the
* appTransport handle provided by the application
*/
-void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
+static void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName,
+ Rm_Transaction *transaction)
{
Rm_NsRequestPkt *nsReqPkt = NULL;
- rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;
+ rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;
nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;
nsReqPkt->requestId = transaction->localId;
if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;
- }
- else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
+ } else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;
}
rm_strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
- rm_strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
- memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
- sizeof(Rm_ResourceInfo));
+ rm_strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName,
+ RM_NAME_MAX_CHARS);
+ memcpy((void *)&(nsReqPkt->resourceInfo),
+ (void *)&(transaction->resourceInfo),
+ sizeof(Rm_ResourceInfo));
}
/* FUNCTION PURPOSE: Creates a NameServer response packet
@@ -192,11 +196,11 @@ void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *t
* is allocated via the rmAllocPkt API using the
* appTransport handle provided by the application
*/
-void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+static void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
{
Rm_NsResponsePkt *nsRespPkt = NULL;
- rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;
+ rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;
nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;
nsRespPkt->responseId = transaction->remoteOriginatingId;
nsRespPkt->requestState = transaction->state;
/* Pass back the ID that was provided to the component when it requested
* the service */
serviceResponse.serviceId = transaction->localId;
- /* Owner and instance allocation count will only be set within RM under certain circumstances. */
+ /* Owner and instance allocation count will only be set within RM under
+ * certain circumstances. */
serviceResponse.resourceNumOwners = transaction->resourceInfo.ownerCount;
serviceResponse.instAllocCount = transaction->resourceInfo.instAllocCount;
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
(transaction->type == Rm_service_RESOURCE_FREE) ||
(transaction->type == Rm_service_RESOURCE_STATUS) ||
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))
- {
- rm_strncpy(serviceResponse.resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+ (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {
+ rm_strncpy(serviceResponse.resourceName, transaction->resourceInfo.name,
+ RM_NAME_MAX_CHARS);
serviceResponse.resourceBase = transaction->resourceInfo.base;
serviceResponse.resourceLength = transaction->resourceInfo.length;
}
if (transaction->u.callback.serviceCallback) {
- /* Issue the callback to the requesting component with the response information */
+ /* Issue the callback to the requesting component with the response
+ * information */
transaction->u.callback.serviceCallback(&serviceResponse);
/* Delete the transaction from the transaction queue */
rmTransactionQueueDelete(rmInst, transaction->localId);
- }
- else {
+ } else {
rmServiceInternalCallback((Rm_Handle)rmInst);
}
-
+
return;
}
Rm_Packet *rmPkt = NULL;
Rm_PacketHandle pktHandle = NULL;
- rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
+ rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
sizeof(Rm_Packet), &pktHandle);
if (!rmPkt || !pktHandle) {
transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
@@ -286,17 +291,18 @@ static void transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
- if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
+ if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle,
+ pktHandle) < RM_OK) {
transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
goto errorExit;
}
-
+
/* Response packet sent: Delete transaction from queue */
rmTransactionQueueDelete(rmInst, transaction->localId);
errorExit:
- /* Do not delete transaction on transport error. Transport error transactions should be visible
- * from Rm_printInstanceStatus() */
+ /* Do not delete transaction on transport error. Transport error
+ * transactions should be visible from Rm_printInstanceStatus() */
return;
}
@@ -314,20 +320,23 @@ static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
Rm_PacketHandle pktHandle = NULL;
if (rmInst->instType == Rm_instType_CLIENT) {
- dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_CLIENT_DELEGATE);
+ dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
+ Rm_instType_CLIENT_DELEGATE);
if (!dstTransport) {
- dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+ dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
+ Rm_instType_SERVER);
}
- }
- else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
- dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+ } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
+ Rm_instType_SERVER);
}
- /* Just queue transaction if transport hasn't been registered. Do not return error */
- if (dstTransport) {
- rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
- sizeof(Rm_Packet), &pktHandle);
+ /* Just queue transaction if transport hasn't been registered. Do not
+ * return error */
+ if (dstTransport) {
+ rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
+ sizeof(Rm_Packet), &pktHandle);
if (!rmPkt || !pktHandle) {
transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
goto errorExit;
@@ -349,17 +358,18 @@ static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
-
- if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
+
+ if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle,
+ pktHandle) < RM_OK) {
transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
goto errorExit;
- }
+ }
transaction->hasBeenForwarded = RM_TRUE;
/* Transaction not deleted. Waiting for response from RM CD or Server */
}
-errorExit:
- /* Do not delete transaction on transport error. Transport error transactions should be visible
- * from Rm_printInstanceStatus() */
+errorExit:
+ /* Do not delete transaction on transport error. Transport error
+ * transactions should be visible from Rm_printInstanceStatus() */
return;
}
/* Resource could not be found in policy */
retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
}
- return (retVal);
+ return(retVal);
}
/* FUNCTION PURPOSE: Frees local resources to Server from CD
* managed resources that are now localized back to
* the Server.
*/
-static int32_t cdFreeResourcesToServer(Rm_Inst *rmInst, Rm_Transaction *transaction)
+static int32_t cdFreeResourcesToServer(Rm_Inst *rmInst,
+ Rm_Transaction *transaction)
{
int32_t baseToFree = transaction->resourceInfo.base;
uint32_t lenToFree = transaction->resourceInfo.length;
Rm_Transaction *newTrans = NULL;
/* This function should only be called after a free was approved */
int32_t retVal = RM_SERVICE_APPROVED;
-
- /* Did free result in a localized free node that can be given back to Server? If
- * so create transaction to Server to free localized resource node */
- if (rmAllocatorGetNodeLocalization((Rm_Handle)rmInst, transaction->resourceInfo.name,
+
+ /* Did free result in a localized free node that can be given back to
+ * Server? If so create transaction to Server to free localized
+ * resource node */
+ if (rmAllocatorGetNodeLocalization((Rm_Handle)rmInst,
+ transaction->resourceInfo.name,
&baseToFree, &lenToFree)) {
if ((newTrans = rmTransactionQueueAdd(rmInst))) {
newTrans->type = transaction->type;
- rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
+ rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
+ RM_NAME_MAX_CHARS);
newTrans->state = RM_SERVICE_PROCESSING;
- rm_strncpy(newTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+ rm_strncpy(newTrans->resourceInfo.name,
+ transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
newTrans->resourceInfo.base = baseToFree;
newTrans->resourceInfo.length = lenToFree;
newTrans->pendingTransactionId = transaction->localId;
transactionForwarder(rmInst, newTrans);
retVal = RM_SERVICE_PENDING_SERVER_RESPONSE;
- }
- else {
+ } else {
/* Error: Need to re-allocate what was freed */
- retVal = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
+ retVal = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
}
- }
- return (retVal);
+ }
+ return(retVal);
}
/* FUNCTION PURPOSE: Arbitrates allocation service requests
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
if (transaction->resourceInfo.base != RM_RESOURCE_BASE_UNSPECIFIED) {
- if (rmAllocatorFind((Rm_Handle)rmInst, transaction->resourceInfo.name)) {
- /* Attempt to allocate from local resources that were provided by Server */
+ if (rmAllocatorFind((Rm_Handle)rmInst,
+ transaction->resourceInfo.name)) {
+ /* Attempt to allocate from local resources that were provided
+ * by Server */
if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_USE) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
- }
- else {
+ } else {
retVal = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
- /* Request resource range was not found within local resources
- * provided by Server. Set back to PROCESSING so request is forwarded to
- * Server */
+ /* Request resource range was not found within local
+ * resources provided by Server. Set back to PROCESSING so
+ * request is forwarded to Server */
retVal = RM_SERVICE_PROCESSING;
}
}
- }
- else {
- if (rmAllocatorFind((Rm_Handle)rmInst, transaction->resourceInfo.name)) {
+ } else {
+ if (rmAllocatorFind((Rm_Handle)rmInst,
+ transaction->resourceInfo.name)) {
int32_t oldAlign = transaction->resourceInfo.alignment;
-
- /* Attempt to allocate from local resources that were provided by Server */
+
+ /* Attempt to allocate from local resources that were provided
+ * by Server */
if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_USE) {
opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_USE;
- }
- else {
+ } else {
retVal = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
-
+
if (retVal == RM_SERVICE_PROCESSING) {
- if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+ if (transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_INIT) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_USE) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
- }
- else {
+ } else {
retVal = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
- /* Request resource range was not found within local resources
- * provided by Server. Set back to PROCESSING so request is forwarded to
- * Server */
+ /* Request resource range was not found within local
+ * resources provided by Server. Set back to
+ * PROCESSING so request is forwarded to Server */
retVal = RM_SERVICE_PROCESSING;
- }
- }
- else if (retVal == RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET) {
+ }
+ } else if (retVal == RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET) {
if (transaction->pendingTransactionId) {
- /* Request to Server for resources to complete transaction locally
- * performed once already. Forward transaction to Server for completion */
+ /* Request to Server for resources to complete
+ * transaction locally performed once already. Forward
+ * transaction to Server for completion */
retVal = RM_SERVICE_PROCESSING;
- }
- else {
- /* Restore base and alignment since they were replaced in pre-allocate routine */
+ } else {
+ /* Restore base and alignment since they were replaced
+ * in pre-allocate routine */
transaction->resourceInfo.base = RM_RESOURCE_BASE_UNSPECIFIED;
transaction->resourceInfo.alignment = oldAlign;
-
+
retVal = cdRequestServerResources(rmInst, transaction);
}
}
- }
- else {
+ } else {
retVal = cdRequestServerResources(rmInst, transaction);
- }
+ }
}
- }
- else if ((rmInst->instType == Rm_instType_SERVER)||
- (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+ } else if ((rmInst->instType == Rm_instType_SERVER)||
+ (rmInst->instType == Rm_instType_SHARED_SERVER)) {
/* Populated NameServer name has precedence over base */
if (strlen(transaction->resourceInfo.nameServerName) > 0) {
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
- rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+ RM_SERVICE_PROCESSING) {
+ rm_strncpy(transaction->resourceInfo.name,
+ nameServerObjCfg.nodeCfg.resourceName,
+ RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
- else {
+ } else {
goto errorExit;
}
}
if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {
if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_USE;
- }
- else {
+ } else {
retVal = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
}
-
+
if (retVal == RM_SERVICE_PROCESSING) {
if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
- }
- else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+ } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
- }
- else {
+ } else {
retVal = RM_ERROR_INVALID_SERVICE_TYPE;
goto errorExit;
}
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
- }
+ }
}
-errorExit:
- transaction->state = retVal;
+errorExit:
+ transaction->state = retVal;
}
/* FUNCTION PURPOSE: Handles resource status service requests
if (opInfo.serviceInstNode == NULL) {
retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
goto errorExit;
- }
+ }
if ((strlen(transaction->resourceInfo.nameServerName) == 0) &&
((transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) ||
}
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
- if (rmAllocatorFind((Rm_Handle)rmInst, transaction->resourceInfo.name)) {
- /* Attempt to get status from local resources that were provided by Server */
+ if (rmAllocatorFind((Rm_Handle)rmInst,
+ transaction->resourceInfo.name)) {
+ /* Attempt to get status from local resources that were provided by
+ * Server */
retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
- /* Request resource range was not found within local allocator resources
- * provided by Server. Set back to PROCESSING so request is forwarded to
- * Server */
+ /* Request resource range was not found within local allocator
+ * resources provided by Server. Set back to PROCESSING so
+ * request is forwarded to Server */
retVal = RM_SERVICE_PROCESSING;
- }
+ }
}
- }
- else if ((rmInst->instType == Rm_instType_SERVER)||
- (rmInst->instType == Rm_instType_SHARED_SERVER)) {
- /* Populated NameServer name has precedence over base and length values */
+ } else if ((rmInst->instType == Rm_instType_SERVER)||
+ (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+ /* Populated NameServer name has precedence over base and length
+ * values */
if (strlen(transaction->resourceInfo.nameServerName) > 0) {
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
rmNameServerTreeInv(rmInst->u.server.nameServer);
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
- rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+ RM_SERVICE_PROCESSING) {
+ rm_strncpy(transaction->resourceInfo.name,
+ nameServerObjCfg.nodeCfg.resourceName,
+ RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
- else {
+ } else {
goto errorExit;
}
}
/* Check if free allows local resources to be freed back to
* Server */
retVal = cdFreeResourcesToServer(rmInst, transaction);
- }
- else if ((retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) ||
+ } else if ((retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) ||
(retVal == RM_SERVICE_DENIED_RES_DOES_NOT_EXIST)) {
/* Requested resource or its range were not found within local
* allocator resources provided by Server. Set back to PROCESSING
* so request is forwarded to Server */
retVal = RM_SERVICE_PROCESSING;
}
- }
- else if ((rmInst->instType == Rm_instType_SERVER) ||
+ } else if ((rmInst->instType == Rm_instType_SERVER) ||
(rmInst->instType == Rm_instType_SHARED_SERVER)) {
/* Populated NameServer name has precedence over base */
if (strlen(transaction->resourceInfo.nameServerName) > 0) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
- rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+ RM_SERVICE_PROCESSING) {
+ rm_strncpy(transaction->resourceInfo.name,
+ nameServerObjCfg.nodeCfg.resourceName,
+ RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
- else {
+ } else {
goto errorExit;
- }
+ }
}
-
- retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
- }
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ }
errorExit:
- transaction->state = retVal;
+ transaction->state = retVal;
}
/* FUNCTION PURPOSE: Client transaction handling process
* - Forwards all service requests to CD or Server
* once transport has been registered
*/
-static void clientProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void clientProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_Transaction *transQ;
-
+
if (!rmInst->registeredWithDelegateOrServer) {
staticAllocationHandler((Rm_Handle)rmInst, transaction);
- }
- else {
+ } else {
if (transaction->state == RM_SERVICE_PROCESSING) {
/* Forward all new transactions to CD or Server */
- transactionForwarder(rmInst, transaction);
- }
- else {
+ transactionForwarder(rmInst, transaction);
+ } else {
/* Transaction validated. Return result. */
serviceResponder(rmInst, transaction);
}
transactionForwarder(rmInst, transQ);
}
transQ = transQ->nextTransaction;
- }
+ }
}
/* Let call stack return transaction result app via Rm_serviceHandler */
}
* - Attempts to complete resource service requests
* received from registered Clients
*/
-static void cdProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void cdProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_Transaction *newTrans = NULL;
Rm_AllocatorNode *allocator = NULL;
if (!rmInst->registeredWithDelegateOrServer) {
if ((transaction->state == RM_SERVICE_PROCESSING) &&
- (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
+ (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+ RM_NAME_MAX_CHARS) == 0)) {
/* Attempt static allocation of requests originating from CD inst */
staticAllocationHandler((Rm_Handle)rmInst, transaction);
}
- /* Everything else left in transaction queue for forwarding once transport to
- * Server is registered */
- }
- else {
+ /* Everything else left in transaction queue for forwarding once
+ * transport to Server is registered */
+ } else {
if (transaction->pendingTransactionId) {
- Rm_Transaction *pendingTrans = rmTransactionQueueFind(rmInst, transaction->pendingTransactionId);
+ Rm_Transaction *pendingTrans = rmTransactionQueueFind(rmInst,
+ transaction->pendingTransactionId);
/* Transaction is response from Server for transaction sent to get
* information in order to complete pending transaction */
if (transaction->state == RM_SERVICE_APPROVED) {
if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
/* Transfer resource data tied to name to pending transaction */
- rm_strncpy(pendingTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+ rm_strncpy(pendingTrans->resourceInfo.name,
+ transaction->resourceInfo.name,
+ RM_NAME_MAX_CHARS);
pendingTrans->resourceInfo.base = transaction->resourceInfo.base;
pendingTrans->resourceInfo.length = transaction->resourceInfo.length;
- /* Delete NS name from pending transaction so Server isn't queried again */
- memset(pendingTrans->resourceInfo.nameServerName, 0, RM_NAME_MAX_CHARS);
- /* Now that resource values have been retrieved clear pending transaction ID so
- * CD doesn't think a resource request was sent to Server already for more local resources */
+ /* Delete NS name from pending transaction so Server isn't
+ * queried again */
+ memset(pendingTrans->resourceInfo.nameServerName, 0,
+ RM_NAME_MAX_CHARS);
+ /* Now that resource values have been retrieved clear
+ * pending transaction ID so CD doesn't think a resource
+ * request was sent to Server already for more local
+ * resources */
pendingTrans->pendingTransactionId = 0;
- /* Return original transaction to processing state to attempt completion. */
+ /* Return original transaction to processing state to
+ * attempt completion. */
pendingTrans->state = RM_SERVICE_PROCESSING;
- }
- else if ((transaction->type ==
- Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (transaction->type ==
- Rm_service_RESOURCE_ALLOCATE_USE)) {
- /* Add resources provided by Server to those managed by CD */
+ } else if ((transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_INIT) ||
+ (transaction->type ==
+ Rm_service_RESOURCE_ALLOCATE_USE)) {
+ /* Add resources provided by Server to those managed by
+ * CD */
if ((allocator = rmAllocatorFind((Rm_Handle)rmInst,
transaction->resourceInfo.name))) {
rmAllocatorAddResNode((Rm_Handle)rmInst,
transaction->resourceInfo.length);
}
- /* Return original transaction to processing state to attempt completion */
+ /* Return original transaction to processing state to
+ * attempt completion */
pendingTrans->state = RM_SERVICE_PROCESSING;
- }
- else if (transaction->type == Rm_service_RESOURCE_FREE) {
+ } else if (transaction->type == Rm_service_RESOURCE_FREE) {
allocator = rmAllocatorFind((Rm_Handle)rmInst,
transaction->resourceInfo.name);
/* Allow original free to complete */
pendingTrans->state = RM_SERVICE_APPROVED;
}
- }
- else {
+ } else {
if (transaction->type == Rm_service_RESOURCE_FREE) {
- /* Error occurred when trying to free local resource on Server. Reinsert local
- * resources freed by original request */
+ /* Error occurred when trying to free local resource on
+ * Server. Reinsert local resources freed by original
+ * request */
Rm_AllocatorOpInfo opInfo;
memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
opInfo.resourceInfo = &pendingTrans->resourceInfo;
opInfo.serviceInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
- pendingTrans->serviceSrcInstName);
- /* Can't regain the original type of allocate. Default to init */
+ pendingTrans->serviceSrcInstName);
+ /* Can't regain the original type of allocate. Default to
+ * init */
opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
- if (rmAllocatorOperation((Rm_Handle)rmInst, &opInfo) != RM_SERVICE_APPROVED) {
+ if (rmAllocatorOperation((Rm_Handle)rmInst, &opInfo) !=
+ RM_SERVICE_APPROVED) {
transaction->state = RM_ERROR_LOST_RESOURCES_ON_CD;
}
}
/* Switch to pending transaction */
transaction = pendingTrans;
}
-
+
if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
(transaction->type == Rm_service_RESOURCE_STATUS) ||
(transaction->type == Rm_service_RESOURCE_FREE)) {
if ((transaction->state == RM_SERVICE_PROCESSING) &&
- (strlen(transaction->resourceInfo.nameServerName) > 0)) {
+ (strlen(transaction->resourceInfo.nameServerName) > 0)) {
/* Create and forward new transaction to Server to
* retrieve resource data mapped to name */
if ((newTrans = rmTransactionQueueAdd(rmInst))) {
newTrans->type = Rm_service_RESOURCE_GET_BY_NAME;
- rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
- newTrans->state = RM_SERVICE_PROCESSING;
- rm_strncpy(newTrans->resourceInfo.nameServerName, transaction->resourceInfo.nameServerName,
- RM_NAME_MAX_CHARS);
+ rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
+ RM_NAME_MAX_CHARS);
+ newTrans->state = RM_SERVICE_PROCESSING;
+ rm_strncpy(newTrans->resourceInfo.nameServerName,
+ transaction->resourceInfo.nameServerName,
+ RM_NAME_MAX_CHARS);
newTrans->pendingTransactionId = transaction->localId;
transactionForwarder(rmInst, newTrans);
transaction->state = RM_SERVICE_PENDING_SERVER_RESPONSE;
+ } else {
+ transaction->state = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
}
- else {
- transaction->state = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
- }
- }
+ }
}
if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
- if (transaction->state == RM_SERVICE_PROCESSING) {
+ if (transaction->state == RM_SERVICE_PROCESSING) {
allocationHandler(rmInst, transaction);
}
- }
- else if (transaction->type == Rm_service_RESOURCE_STATUS) {
- if (transaction->state == RM_SERVICE_PROCESSING) {
+ } else if (transaction->type == Rm_service_RESOURCE_STATUS) {
+ if (transaction->state == RM_SERVICE_PROCESSING) {
statusHandler(rmInst, transaction);
- }
- }
- else if (transaction->type == Rm_service_RESOURCE_FREE) {
+ }
+ } else if (transaction->type == Rm_service_RESOURCE_FREE) {
if (transaction->state == RM_SERVICE_PROCESSING) {
freeHandler(rmInst, transaction);
- }
+ }
}
/* Forward all NameServer-based transactions */
if (transaction->state == RM_SERVICE_PROCESSING) {
/* CD could not complete transaction. Forward to Server */
transactionForwarder(rmInst, transaction);
- }
- else if (transaction->state != RM_SERVICE_PENDING_SERVER_RESPONSE) {
- /* Transaction completed by CD or completed response received from Server. Return result */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
+ } else if (transaction->state != RM_SERVICE_PENDING_SERVER_RESPONSE) {
+ /* Transaction completed by CD or completed response received from
+ * Server. Return result */
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+ RM_NAME_MAX_CHARS)) {
/* Transaction did not originate on this instance */
transactionResponder(rmInst, transaction);
- }
- else {
+ } else {
/* Transaction originated on this instance */
serviceResponder(rmInst, transaction);
- }
- }
+ }
+ }
/* Attempt allocation of any queued static requests:
* RM_SERVICE_APPROVED_STATIC - Originated locally
transactionForwarder(rmInst, transQ);
}
transQ = transQ->nextTransaction;
- }
+ }
}
}
* the service handle and registered CDs and
* Clients
*/
-static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void serverProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_NameServerObjCfg nameServerObjCfg;
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
rmNameServerTreeInv(rmInst->u.server.nameServer);
}
- memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+ memset((void *)&nameServerObjCfg, 0,
+ sizeof(Rm_NameServerObjCfg));
nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;
nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;
transaction->state = rmNameServerAddObject(&nameServerObjCfg);
- }
- else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+ } else if (transaction->type ==
+ Rm_service_RESOURCE_GET_BY_NAME) {
if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==
RM_SERVICE_PROCESSING) {
- rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ rm_strncpy(transaction->resourceInfo.name,
+ nameServerObjCfg.nodeCfg.resourceName,
+ RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
transaction->state = RM_SERVICE_APPROVED;
- }
- }
- else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
+ }
+ } else if (transaction->type ==
+ Rm_service_RESOURCE_UNMAP_NAME) {
transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);
}
-
+
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
rmNameServerTreeWb(rmInst->u.server.nameServer);
}
- }
- else {
+ } else {
transaction->state = RM_ERROR_NAMESERVER_DOES_NOT_EXIST;
}
break;
/* Source of shared server transaction will always be local. */
if (rmInst->instType != Rm_instType_SHARED_SERVER) {
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Source of transaction was not Server, return transaction via responder */
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+ RM_NAME_MAX_CHARS)) {
+ /* Source of transaction was not Server, return transaction via
+ * responder */
transactionResponder(rmInst, transaction);
}
}
- /* Otherwise let call stack return transaction result app via Rm_serviceHandler */
+ /* Otherwise let call stack return transaction result app via
+ * Rm_serviceHandler */
}
/**********************************************************************
transactionQueue = transactionQueue->nextTransaction;
}
transactionQueue->nextTransaction = newTransaction;
- }
- else {
+ } else {
rmInst->transactionQueue = newTransaction;
}
}
- return (newTransaction);
+ return(newTransaction);
}
/* FUNCTION PURPOSE: Finds a transaction
@@ -1145,12 +1170,12 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
while (transaction) {
if (transaction->localId == transactionId) {
- break;
+ break;
}
transaction = transaction->nextTransaction;
}
- return (transaction);
+ return(transaction);
}
/* FUNCTION PURPOSE: Deletes a transaction
@@ -1160,13 +1185,13 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
*/
int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
{
- Rm_Transaction *transaction = rmInst->transactionQueue;
+ Rm_Transaction *transaction = rmInst->transactionQueue;
Rm_Transaction *prevTransaction = NULL;
- int32_t retVal = RM_OK;
+ int32_t retVal = RM_OK;
while (transaction) {
if (transaction->localId == transactionId) {
- break;
+ break;
}
prevTransaction = transaction;
if (transaction) {
if (prevTransaction == NULL) {
- /* Transaction at start of queue. Map second transaction to start of queue
- * as long as more than one transactions. */
+ /* Transaction at start of queue. Map second transaction to start
+ * of queue as long as more than one transactions. */
rmInst->transactionQueue = transaction->nextTransaction;
- }
- else {
+ } else {
/* Transaction in middle or end of queue. */
prevTransaction->nextTransaction = transaction->nextTransaction;
}
Rm_osalFree((void *)transaction, sizeof(Rm_Transaction));
- }
- else {
+ } else {
retVal = RM_ERROR_SERVICE_TRANS_DOES_NOT_EXIST;
- }
- return (retVal);
+ }
+ return(retVal);
}
/* FUNCTION PURPOSE: Routes a transaction for processing
{
if (rmInst->instType == Rm_instType_CLIENT) {
clientProcess(rmInst, transaction);
- }
- else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
cdProcess(rmInst, transaction);
- }
- else if ((rmInst->instType == Rm_instType_SERVER) ||
- (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+ } else if ((rmInst->instType == Rm_instType_SERVER) ||
+ (rmInst->instType == Rm_instType_SHARED_SERVER)) {
serverProcess(rmInst, transaction);
- }
+ }
}
-
+
/**********************************************************************
********************** Application visible APIs **********************
**********************************************************************/
if (rmInst->instType != Rm_instType_CLIENT) {
Rm_osalLog("Instance name: %s\n", rmInst->instName);
- Rm_osalLog("Handle: 0x%08x\n", rmHandle);
+ Rm_osalLog("Handle: 0x%08x\n", rmHandle);
if (rmInst->instType == Rm_instType_SERVER) {
Rm_osalLog("Type: Server\n");
} else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
Rm_osalLog("Handle: 0x%08x\n", rmHandle);
if (rmInst->instType == Rm_instType_SERVER) {
Rm_osalLog("Type: Server\n");
- }
- else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
Rm_osalLog("Type: Client Delegate\n");
- }
- else if (rmInst->instType == Rm_instType_CLIENT) {
+ } else if (rmInst->instType == Rm_instType_CLIENT) {
Rm_osalLog("Type: Client\n");
- }
- else if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+ } else if (rmInst->instType == Rm_instType_SHARED_SERVER) {
Rm_osalLog("Type: Shared Server\n");
- }
- else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
+ } else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
Rm_osalLog("Type: Shared Client\n");
Rm_osalLog("\nShared Server Properties:\n");
Rm_osalLog("Instance name: %s\n", rmInst->instName);
Rm_osalLog("Handle: 0x%08x\n", rmHandle);
}
-
+
transportList = rmInst->transports;
if (transportList) {
Rm_osalLog("\nRegistered Transports:\n");
RM_SS_OBJ_INV(rmInst, transportList, Rm_Transport);
if (transportList->remoteInstType == Rm_instType_SERVER) {
Rm_osalLog(" Remote instType: Server\n");
- }
- else if (transportList->remoteInstType == Rm_instType_CLIENT_DELEGATE) {
+ } else if (transportList->remoteInstType ==
+ Rm_instType_CLIENT_DELEGATE) {
Rm_osalLog(" Remote instType: Client Delegate\n");
- }
- else {
+ } else {
Rm_osalLog(" Remote instType: Client\n");
}
- Rm_osalLog(" appTransportHandle: 0x%08x\n", transportList->appTransportHandle);
+ Rm_osalLog(" appTransportHandle: 0x%08x\n",
+ transportList->appTransportHandle);
Rm_osalLog("\n");
transportList = transportList->nextTransport;
}
Rm_osalLog("\nQueued Service Transactions:\n");
while (transactionQ) {
RM_SS_OBJ_INV(rmInst, transactionQ, Rm_Transaction);
- Rm_osalLog(" Service type: %d\n", transactionQ->type);
+ Rm_osalLog(" Service type: %d\n",
+ transactionQ->type);
Rm_osalLog(" Service ID: %d\n", transactionQ->localId);
- Rm_osalLog(" Service srcInstName %s\n", transactionQ->serviceSrcInstName);
+ Rm_osalLog(" Service srcInstName %s\n",
+ transactionQ->serviceSrcInstName);
Rm_osalLog(" Service state: %d\n", transactionQ->state);
- Rm_osalLog(" Resource name: %s\n", transactionQ->resourceInfo.name);
- Rm_osalLog(" Resource base: %d\n", transactionQ->resourceInfo.base);
- Rm_osalLog(" Resource length: %d\n", transactionQ->resourceInfo.length);
- Rm_osalLog(" Resource alignment: %d\n", transactionQ->resourceInfo.alignment);
- Rm_osalLog(" Resource NS name: %s\n", transactionQ->resourceInfo.nameServerName);
+ Rm_osalLog(" Resource name: %s\n",
+ transactionQ->resourceInfo.name);
+ Rm_osalLog(" Resource base: %d\n",
+ transactionQ->resourceInfo.base);
+ Rm_osalLog(" Resource length: %d\n",
+ transactionQ->resourceInfo.length);
+ Rm_osalLog(" Resource alignment: %d\n",
+ transactionQ->resourceInfo.alignment);
+ Rm_osalLog(" Resource NS name: %s\n",
+ transactionQ->resourceInfo.nameServerName);
Rm_osalLog("\n");
transactionQ = transactionQ->nextTransaction;
- }
+ }
}
-
- /* Free sem object using originating instance in case the Shared Client to Shared
- * Server instance switch took place */
+
+ /* Free sem object using originating instance in case the Shared Client
+ * to Shared Server instance switch took place */
if (((Rm_Inst *)rmHandle)->mtSemObj) {
Rm_osalMtCsExit(((Rm_Inst *)rmHandle)->mtSemObj, mtKey);
- }
- RM_SS_INST_WB_EXIT_CS(rmInst, key);
+ }
+ RM_SS_INST_WB_EXIT_CS(rmInst, key);
}
/* FUNCTION PURPOSE: RM instance creation and initialization
diff --git a/src/rm_allocator.c b/src/rm_allocator.c
index 420fffd5330a10e3df23f79d4b4cbf3841c0540a..8864f5ed8cfdce19e6bbc616aa728b8de1da95c3 100644 (file)
--- a/src/rm_allocator.c
+++ b/src/rm_allocator.c
@@ -166,14 +166,13 @@ static void allocatorResNodeOwnerAdd(Rm_Handle rmHandle, Rm_ResourceNode *node,
if (allocatorResNodeIsOwnedBy(rmHandle, node, serviceInstNode)) {
allocatorResNodeOwnerRefCntInc(rmHandle, node, serviceInstNode);
- }
- else {
+ } else {
newOwner = Rm_osalMalloc(sizeof(*newOwner));
if (newOwner) {
newOwner->instNameNode = serviceInstNode;
newOwner->refCnt = 0;
- newOwner->nextOwner = NULL;
+ newOwner->nextOwner = NULL;
/* Add owner entry to end of list */
if (ownerList) {
}
ownerList->nextOwner = newOwner;
RM_SS_OBJ_WB(rmInst, ownerList, Rm_Owner);
- }
- else {
+ } else {
node->ownerList = newOwner;
}
newOwner->refCnt++;
newOwner->instNameNode->allocRefCount++;
RM_SS_OBJ_WB(rmInst, newOwner, Rm_Owner);
- RM_SS_OBJ_WB(rmInst, newOwner->instNameNode, Rm_PolicyValidInstNode);
+ RM_SS_OBJ_WB(rmInst, newOwner->instNameNode,
+ Rm_PolicyValidInstNode);
}
}
}
if (node1End == (node2->base - 1)) {
return(RM_TRUE);
}
- }
- else if (node2->base < node1->base) {
+ } else if (node2->base < node1->base) {
if (node2End == (node1->base - 1)) {
return(RM_TRUE);
- }
+ }
}
}
return(RM_FALSE);
if (matchedInst) {
node2Owners = node2->ownerList;
node1Owners = node1Owners->nextOwner;
- }
- else {
+ } else {
return(RM_FALSE);
- }
+ }
}
- }
- else {
+ } else {
return(RM_FALSE);
- }
-
+ }
+
return(RM_TRUE);
}
if (allocatorResNodeIsOwnedBy(rmHandle, node, serviceInstNode) > 1) {
allocatorResNodeOwnerRefCntDec(rmHandle, node, serviceInstNode);
- }
- else {
+ } else {
while (owner) {
RM_SS_OBJ_INV(rmInst, owner, Rm_Owner);
if (owner->instNameNode == serviceInstNode) {
- break;
+ break;
}
prevOwner = owner;
owner = owner->nextOwner;
if (owner) {
if (prevOwner == NULL) {
node->ownerList = owner->nextOwner;
- }
- else {
+ } else {
prevOwner->nextOwner = owner->nextOwner;
RM_SS_OBJ_WB(rmInst, prevOwner, Rm_Owner);
}
-
+
node->allocationCount--;
owner->instNameNode->allocRefCount--;
RM_SS_OBJ_WB(rmInst, owner->instNameNode, Rm_PolicyValidInstNode);
if (dstNode->ownerList == NULL) {
dstNode->ownerList = dstNewOwner;
- }
- else {
+ } else {
dstPrevOwner->nextOwner = dstNewOwner;
RM_SS_OBJ_WB(rmInst, dstPrevOwner, Rm_Owner);
}
@@ -417,15 +410,13 @@ static int32_t allocatorStatus(Rm_Handle rmHandle, Rm_AllocatorNode *allocator,
if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
- matchingNode,
- opInfo->serviceInstNode);
+ matchingNode,
+ opInfo->serviceInstNode);
retVal = RM_SERVICE_APPROVED;
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_PARTIAL_STATUS;
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;
}
opInfo->serviceInstNode,
policyCheckType);
}
-
+
if (retVal != RM_OK) {
return (retVal);
}
if (opInfo->resourceInfo->alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {
/* Get alignment from policy */
opInfo->resourceInfo->alignment = rmPolicyGetAllocAlign(allocator->policyRoot);
- }
+ }
if (opInfo->resourceInfo->alignment == 0) {
opInfo->resourceInfo->alignment = 1;
- }
+ }
memset((void *)&findNode, 0, sizeof(findNode));
findNode.base = opInfo->resourceInfo->base;
policyCheckCfg.polTree = allocator->policyRoot;
do {
- matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->resourceRoot, &findNode);
-
+ matchingNode = RB_FIND(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, &findNode);
+
if (matchingNode) {
matchingEnd = matchingNode->base + matchingNode->length - 1;
findEnd = findNode.base + findNode.length - 1;
nodePassesPolicy = RM_BOOL_UNDEF;
if ((matchingNode->allocationCount == 0) &&
- (findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {
- /* Attempt to preallocate from node only if not owned by anyone and sits
- * within a matching node. */
+ (findNode.base >= matchingNode->base) &&
+ (findEnd <= matchingEnd)) {
+ /* Attempt to preallocate from node only if not owned by anyone
+ * and sits within a matching node. */
policyCheckCfg.type = policyCheckType;
policyCheckCfg.validInstNode = opInfo->serviceInstNode;
policyCheckCfg.resourceBase = findNode.base;
nodePassesPolicy = rmPolicyCheckPrivilege(&policyCheckCfg);
if (nodePassesPolicy && (matchingNode->allocationCount > 0)) {
- if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode, rmPolicyGetLinuxInstNode(rmHandle))) {
- /* Check if instance requesting resource has privileges to share
- * a resource already reserved by Linux */
+ if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode,
+ rmPolicyGetLinuxInstNode(rmHandle))) {
+ /* Check if instance requesting resource has privileges
+ * to share a resource already reserved by Linux */
policyCheckCfg.type = Rm_policyCheck_SHARED_LINUX;
nodePassesPolicy = rmPolicyCheckPrivilege(&policyCheckCfg);
}
if (nodePassesPolicy) {
- /* Check exclusive privileges of instance requesting resource. Requesting
- * instance with exclusive privileges can't reserve resource if already owned*/
+ /* Check exclusive privileges of instance requesting
+ * resource. Requesting instance with exclusive
+ * privileges can't reserve resource if already owned*/
policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;
nodePassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg);
}
}
-
+
if (nodePassesPolicy && (matchingNode->allocationCount == 1)) {
- /* Check exclusive privileges of instance that currently owns resource */
+ /* Check exclusive privileges of instance that currently
+ * owns resource */
policyCheckCfg.type = Rm_policyCheck_EXCLUSIVE;
policyCheckCfg.validInstNode = matchingNode->ownerList->instNameNode;
nodePassesPolicy = !rmPolicyCheckPrivilege(&policyCheckCfg);
/* Check next resource node for available resources */
if (findNode.base < matchingNode->base) {
findNode.base = matchingNode->base;
- }
- else {
+ } else {
if (!nodePassesPolicy) {
findNode.base += findNode.length;
- }
- else {
+ } else {
/* Matching node allocated, move to next node */
if ((nextNode = RB_NEXT(_Rm_AllocatorResourceTree,
allocator->resourceRoot,
matchingNode))) {
findNode.base = nextNode->base;
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET;
}
}
}
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET;
}
} while ((!resourceFound) &&
(retVal != RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET));
- return(retVal);
+ return(retVal);
}
/* FUNCTION PURPOSE: Allocates an allocator resource
}
}
- if (!allocatorResNodeIsOwnedBy(rmHandle, matchingNode, opInfo->serviceInstNode)) {
- if (allocPassesPolicy && (matchingNode->allocationCount > 0)) {
- if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode, rmPolicyGetLinuxInstNode(rmHandle))) {
- /* Check if instance requesting resource has privileges to share
- * a resource already reserved by Linux */
+ if (!allocatorResNodeIsOwnedBy(rmHandle, matchingNode,
+ opInfo->serviceInstNode)) {
+ if (allocPassesPolicy &&
+ (matchingNode->allocationCount > 0)) {
+ if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode,
+ rmPolicyGetLinuxInstNode(rmHandle))) {
+ /* Check if instance requesting resource has
+ * privileges to share a resource already reserved
+ * by Linux */
checkCfg.type = Rm_policyCheck_SHARED_LINUX;
checkCfg.validInstNode = opInfo->serviceInstNode;
allocPassesPolicy = rmPolicyCheckPrivilege(&checkCfg);
}
}
if (allocPassesPolicy) {
- /* Check exclusive privileges of instance requesting resource. Requesting
- * instance with exclusive privileges can't reserve resource if already owned*/
+ /* Check exclusive privileges of instance
+ * requesting resource. Requesting instance with
+ * exclusive privileges can't reserve resource if
+ * already owned*/
checkCfg.type = Rm_policyCheck_EXCLUSIVE;
checkCfg.validInstNode = opInfo->serviceInstNode;
allocPassesPolicy = !rmPolicyCheckPrivilege(&checkCfg);
}
}
}
- if (allocPassesPolicy && (matchingNode->allocationCount == 1)) {
- /* Check exclusive privileges of instance that currently owns resource */
+ if (allocPassesPolicy &&
+ (matchingNode->allocationCount == 1)) {
+ /* Check exclusive privileges of instance that
+ * currently owns resource */
checkCfg.type = Rm_policyCheck_EXCLUSIVE;
checkCfg.validInstNode = matchingNode->ownerList->instNameNode;
allocPassesPolicy = !rmPolicyCheckPrivilege(&checkCfg);
if (!allocPassesPolicy) {
retVal = RM_SERVICE_DENIED_ALLOCD_TO_EXCLUSIVE_INST;
- }
- }
+ }
+ }
}
}
-
+
if (allocPassesPolicy) {
- /* Handle any possible node combinations if requesting instance is
- * not already in resource's owner list. Automatic approval if requesting
- * instance is already in owner list. */
- if ((findNode.base == matchingNode->base) && (findEnd == matchingEnd)) {
+ /* Handle any possible node combinations if requesting instance
+ * is not already in resource's owner list. Automatic approval
+ * if requesting instance is already in owner list. */
+ if ((findNode.base == matchingNode->base) &&
+ (findEnd == matchingEnd)) {
/* findNode range matches matchingNode range
*
- * |<--left node-->||<--matched node-->||<--right node-->| => existing node
- * |<--alloc request-->| => requested resources
- */
- leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- allocatorResNodeOwnerAdd(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- if (leftNode && allocatorResNodeOwnerCompare(rmHandle, leftNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(leftNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ * |<--left node-->||<--matched node-->||<--right node-->|
+ * |<--alloc request-->|
+ */
+ leftNode = RB_PREV(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ rightNode = RB_NEXT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ allocatorResNodeOwnerAdd(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ if (leftNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ leftNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(leftNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
combineLeft = RM_TRUE;
}
- if (rightNode && allocatorResNodeOwnerCompare(rmHandle, rightNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(rightNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ if (rightNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ rightNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(rightNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
combineRight = RM_TRUE;
}
if (combineLeft && combineRight) {
/* Combine all three nodes into matchingNode */
matchingNode->base = leftNode->base;
- matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;
+ matchingNode->length = leftNode->length +
+ matchingNode->length +
+ rightNode->length;
allocatorResNodeOwnerClear(rmHandle, leftNode);
rmResourceNodeFree(leftNode);
allocatorResNodeOwnerClear(rmHandle, rightNode);
- rmResourceNodeFree(rightNode);
- }
- else if (combineLeft) {
+ rmResourceNodeFree(rightNode);
+ } else if (combineLeft) {
/* Combine left and matching nodes. Reinsert right. */
matchingNode->base = leftNode->base;
matchingNode->length += leftNode->length;
allocatorResNodeOwnerClear(rmHandle, leftNode);
rmResourceNodeFree(leftNode);
if (rightNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
}
- }
- else if (combineRight) {
+ } else if (combineRight) {
/* Combine right and matching nodes. Reinsert left. */
matchingNode->length += rightNode->length;
allocatorResNodeOwnerClear(rmHandle, rightNode);
rmResourceNodeFree(rightNode);
if (leftNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
}
- }
- else {
+ } else {
/* No combine. */
if (leftNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
}
if (rightNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
}
}
- /* Always reinsert matchingNode */
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
-
- /* Matching node contains new reference count after alloc. Return new owner count
- * and originating instance allocation reference count. */
+ /* Always reinsert matchingNode */
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+
+ /* Matching node contains new reference count after alloc.
+ * Return new owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
- }
- else if ((findNode.base > matchingNode->base) && (findEnd < matchingEnd)) {
- /* findNode range is subset of matchingNode range and neither boundary is
- * equivalent.
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
+ } else if ((findNode.base > matchingNode->base) &&
+ (findEnd < matchingEnd)) {
+ /* findNode range is subset of matchingNode range and
+ * neither boundary is equivalent.
*
* |<----------matched node---------->|
* |<---alloc request--->|
- */
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);
+ */
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ leftNode = rmResourceNodeNew(matchingNode->base,
+ findNode.base -
+ matchingNode->base);
allocatorResNodeOwnerCopy(rmHandle, leftNode, matchingNode);
- rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);
- allocatorResNodeOwnerCopy(rmHandle, rightNode, matchingNode);
+ rightNode = rmResourceNodeNew(findNode.base +
+ findNode.length,
+ matchingEnd - findEnd);
+ allocatorResNodeOwnerCopy(rmHandle, rightNode,
+ matchingNode);
- matchingNode->base = findNode.base;
+ matchingNode->base = findNode.base;
matchingNode->length = findNode.length;
- allocatorResNodeOwnerAdd(rmHandle, matchingNode, opInfo->serviceInstNode);
+ allocatorResNodeOwnerAdd(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
/* Insert all the nodes */
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
-
- /* Matching node contains new reference count after alloc. Return new owner count
- * and originating instance allocation reference count. */
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
+
+ /* Matching node contains new reference count after alloc.
+ * Return new owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
- }
- else {
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
+ } else {
if (findNode.base == matchingNode->base) {
- /* findNode base and matchingNode base are equivalent. May be combine
- * possibilities to the left
+ /* findNode base and matchingNode base are equivalent.
+ * May be combine possibilities to the left
*
- * |<---left node (alloc'd)--->||<----------matched node---------->|
- * |<---findNode (alloc req)--->|
- */
- leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- /* Add allocating instance to owner list for compare with leftNode */
- allocatorResNodeOwnerAdd(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- if (leftNode && allocatorResNodeOwnerCompare(rmHandle, leftNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(leftNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ * |<-left node (alloc'd)->||<-----matched node------->|
+ * |<-findNode (alloc req)->|
+ */
+ leftNode = RB_PREV(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ /* Add allocating instance to owner list for compare
+ * with leftNode */
+ allocatorResNodeOwnerAdd(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ if (leftNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ leftNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(leftNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
/* Combine leftNode and findNode */
leftNode->length += findNode.length;
- }
- else {
- leftNode = rmResourceNodeNew(findNode.base, findNode.length);
- allocatorResNodeOwnerCopy(rmHandle, leftNode, matchingNode);
+ } else {
+ leftNode = rmResourceNodeNew(findNode.base,
+ findNode.length);
+ allocatorResNodeOwnerCopy(rmHandle, leftNode,
+ matchingNode);
}
/* Account for leftNode in matchingNode */
matchingNode->base = findNode.base + findNode.length;
- matchingNode->length = matchingEnd - findEnd;
+ matchingNode->length = matchingEnd - findEnd;
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
- /* Left node contains new reference count after alloc. Return new owner count
- * and originating instance allocation reference count. */
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
+ /* Left node contains new reference count after alloc.
+ * Return new owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = leftNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, leftNode,
- opInfo->serviceInstNode);
- }
- else if (findEnd == matchingEnd) {
- /* findNode end and matchingNode end are equivalent. May be combine
- * possibilities to the right
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ leftNode,
+ opInfo->serviceInstNode);
+ } else if (findEnd == matchingEnd) {
+ /* findNode end and matchingNode end are equivalent.
+ * May be combine possibilities to the right
*
- * |<----------matched node---------->||<---right node (alloc'd)--->|
- * |<---findNode (alloc req)--->|
- */
- rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- /* Add allocating instance to owner list for compare with rightNode */
- allocatorResNodeOwnerAdd(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- if (rightNode && allocatorResNodeOwnerCompare(rmHandle, rightNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(rightNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ * |<------matched node----->||<-right node (alloc'd)->|
+ * |<-findNode (alloc req)->|
+ */
+ rightNode = RB_NEXT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ /* Add allocating instance to owner list for compare
+ * with rightNode */
+ allocatorResNodeOwnerAdd(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ if (rightNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ rightNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(rightNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
/* Combine rightNode and findNode */
rightNode->base = findNode.base;
rightNode->length += findNode.length;
- }
- else {
- rightNode = rmResourceNodeNew(findNode.base, findNode.length);
- allocatorResNodeOwnerCopy(rmHandle, rightNode, matchingNode);
+ } else {
+ rightNode = rmResourceNodeNew(findNode.base,
+ findNode.length);
+ allocatorResNodeOwnerCopy(rmHandle, rightNode,
+ matchingNode);
}
/* Account for rightNode in matchingNode */
- matchingNode->length -= findNode.length;
+ matchingNode->length -= findNode.length;
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
- /* Right node contains new reference count after alloc. Return new owner count
- * and originating instance allocation reference count. */
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
+ /* Right node contains new reference count after alloc.
+ * Return new owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = rightNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, rightNode,
- opInfo->serviceInstNode);
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ rightNode,
+ opInfo->serviceInstNode);
}
/* Remove allocating instance from leftover matchingNode */
- allocatorResNodeOwnerDelete(rmHandle, matchingNode, opInfo->serviceInstNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
+ allocatorResNodeOwnerDelete(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
}
retVal = RM_SERVICE_APPROVED;
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_PARTIAL_ALLOCATION;
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;
}
memset((void *)&findNode, 0, sizeof(findNode));
findNode.base = opInfo->resourceInfo->base;
findNode.length = opInfo->resourceInfo->length;
- matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->resourceRoot, &findNode);
+ matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->resourceRoot,
+ &findNode);
if (matchingNode) {
findEnd = findNode.base + findNode.length - 1;
@@ -928,217 +988,290 @@ static int32_t allocatorFree(Rm_Handle rmHandle, Rm_AllocatorNode *allocator,
if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {
if (matchingNode->allocationCount) {
- if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode, opInfo->serviceInstNode)) {
- if ((findNode.base == matchingNode->base) && (findEnd == matchingEnd)) {
- /* Case 1: Free range equals allocated matched node exactly. Attempt to combine
- * freed node with nodes to left and right.
+ if (allocatorResNodeIsOwnedBy(rmHandle, matchingNode,
+ opInfo->serviceInstNode)) {
+ if ((findNode.base == matchingNode->base) &&
+ (findEnd == matchingEnd)) {
+ /* Case 1: Free range equals allocated matched node
+ * exactly. Attempt to combine freed node with
+ * nodes to left and right.
*
- * |<--left node-->||<---matched node--->||<--right node-->|
- * |<---free request--->|
- */
- leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- allocatorResNodeOwnerDelete(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- if (leftNode && allocatorResNodeOwnerCompare(rmHandle, leftNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(leftNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ * |<-left node->||<---matched node--->||<-right node->|
+ * |<---free request--->|
+ */
+ leftNode = RB_PREV(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ rightNode = RB_NEXT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ allocatorResNodeOwnerDelete(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ if (leftNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ leftNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(leftNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
combineLeft = RM_TRUE;
}
- if (rightNode && allocatorResNodeOwnerCompare(rmHandle, rightNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(rightNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ if (rightNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ rightNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(rightNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
combineRight = RM_TRUE;
}
if (combineLeft && combineRight) {
/* Combine all three nodes into matchingNode */
matchingNode->base = leftNode->base;
- matchingNode->length = leftNode->length + matchingNode->length + rightNode->length;
+ matchingNode->length = leftNode->length +
+ matchingNode->length +
+ rightNode->length;
allocatorResNodeOwnerClear(rmHandle, leftNode);
rmResourceNodeFree(leftNode);
allocatorResNodeOwnerClear(rmHandle, rightNode);
- rmResourceNodeFree(rightNode);
- }
- else if (combineLeft) {
- /* Combine left and matching nodes. Reinsert right. */
+ rmResourceNodeFree(rightNode);
+ } else if (combineLeft) {
+ /* Combine left and matching nodes.
+ * Reinsert right. */
matchingNode->base = leftNode->base;
matchingNode->length += leftNode->length;
allocatorResNodeOwnerClear(rmHandle, leftNode);
rmResourceNodeFree(leftNode);
if (rightNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
}
- }
- else if (combineRight) {
- /* Combine right and matching nodes. Reinsert left. */
+ } else if (combineRight) {
+ /* Combine right and matching nodes.
+ * Reinsert left. */
matchingNode->length += rightNode->length;
allocatorResNodeOwnerClear(rmHandle, rightNode);
rmResourceNodeFree(rightNode);
if (leftNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
}
- }
- else {
+ } else {
/* No combine. */
if (leftNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
}
if (rightNode) {
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
}
}
/* Always reinsert matchingNode */
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
- /* Matching node is what remains after free. Return remaining owner count
- * and originating instance allocation reference count. */
+ /* Matching node is what remains after free. Return
+ * remaining owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
- }
- else if ((findNode.base > matchingNode->base) && (findEnd < matchingEnd)) {
- /* Case 2: Free range is less than range in matched node. Split
- * matched node into three nodes.
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
+ } else if ((findNode.base > matchingNode->base) &&
+ (findEnd < matchingEnd)) {
+ /* Case 2: Free range is less than range in matched
+ * node. Split matched node into three nodes.
*
* |<----------matched node---------->|
* |<---free request--->|
*
- * Remove instance from owner list then add it back in for side nodes for
- * proper accounting of allocations in validInstance list
- */
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- allocatorResNodeOwnerDelete(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base);
- allocatorResNodeOwnerCopy(rmHandle, leftNode, matchingNode);
- allocatorResNodeOwnerAdd(rmHandle, leftNode, opInfo->serviceInstNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
-
- rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd);
- allocatorResNodeOwnerCopy(rmHandle, rightNode, matchingNode);
- allocatorResNodeOwnerAdd(rmHandle, rightNode, opInfo->serviceInstNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
-
- matchingNode->base = findNode.base;
+ * Remove instance from owner list then add it back in
+ * for side nodes for proper accounting of allocations
+ * in validInstance list
+ */
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ allocatorResNodeOwnerDelete(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ leftNode = rmResourceNodeNew(matchingNode->base,
+ findNode.base -
+ matchingNode->base);
+ allocatorResNodeOwnerCopy(rmHandle, leftNode,
+ matchingNode);
+ allocatorResNodeOwnerAdd(rmHandle, leftNode,
+ opInfo->serviceInstNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
+
+ rightNode = rmResourceNodeNew(findNode.base +
+ findNode.length,
+ matchingEnd - findEnd);
+ allocatorResNodeOwnerCopy(rmHandle, rightNode,
+ matchingNode);
+ allocatorResNodeOwnerAdd(rmHandle, rightNode,
+ opInfo->serviceInstNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
+
+ matchingNode->base = findNode.base;
matchingNode->length = findNode.length;
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
-
- /* Matching node is what remains after free. Return remaining owner count
- * and originating instance allocation reference count. */
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+
+ /* Matching node is what remains after free. Return
+ * remaining owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
- }
- else {
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
+ } else {
if (findNode.base == matchingNode->base) {
- /* Case 3: Free range is on left boundary of matched node. Try to
- * combine free range with left node.
+ /* Case 3: Free range is on left boundary of
+ * matched node. Try to combine free range
+ * with left node.
*
- * |<---left node (free)--->||<----------matched node---------->|
- * |<---findNode (free req)--->|
- */
-
- leftNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- /* Remove freeing instance from owner list for compare with leftNode */
- allocatorResNodeOwnerDelete(rmHandle, matchingNode, opInfo->serviceInstNode);
-
- if (leftNode && allocatorResNodeOwnerCompare(rmHandle, leftNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(leftNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
+ * |<-left node (free)->||<-----matched node------>|
+ * |<-findNode (free req)->|
+ */
+
+ leftNode = RB_PREV(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ /* Remove freeing instance from owner list for
+ * compare with leftNode */
+ allocatorResNodeOwnerDelete(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+
+ if (leftNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ leftNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(leftNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
/* Combine leftNode and findNode */
leftNode->length += findNode.length;
- }
- else {
- leftNode = rmResourceNodeNew(findNode.base, findNode.length);
- allocatorResNodeOwnerCopy(rmHandle, leftNode, matchingNode);
+ } else {
+ leftNode = rmResourceNodeNew(findNode.base,
+ findNode.length);
+ allocatorResNodeOwnerCopy(rmHandle, leftNode,
+ matchingNode);
}
/* Remove leftNode range from matchingNode */
- matchingNode->base = findNode.base + findNode.length;
- matchingNode->length = matchingEnd - findEnd;
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, leftNode);
-
- /* Left node is what remains after free. Return remaining owner count
- * and originating instance allocation reference count. */
+ matchingNode->base = findNode.base +
+ findNode.length;
+ matchingNode->length = matchingEnd - findEnd;
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, leftNode);
+
+ /* Left node is what remains after free. Return
+ * remaining owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = leftNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, leftNode,
- opInfo->serviceInstNode);
- }
- else if (findEnd == matchingEnd) {
- /* Case 4: Free range is on right boundary of matched node. Try to
- * combine free range with right node.
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ leftNode,
+ opInfo->serviceInstNode);
+ } else if (findEnd == matchingEnd) {
+ /* Case 4: Free range is on right boundary of
+ * matched node. Try to combine free range
+ * with right node.
*
- * |<----------matched node---------->||<---right node (free)--->|
- * |<---findNode (free req)--->|
- */
-
- rightNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- /* Remove freeing instance from owner list for compare with rightNode */
- allocatorResNodeOwnerDelete(rmHandle, matchingNode, opInfo->serviceInstNode);
+ * |<-----matched node----->||<-right node (free)->|
+ * |<-findNode (free req)->|
+ */
+
+ rightNode = RB_NEXT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot,
+ matchingNode);
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ /* Remove freeing instance from owner list for
+ * compare with rightNode */
+ allocatorResNodeOwnerDelete(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
- if (rightNode && allocatorResNodeOwnerCompare(rmHandle, rightNode, matchingNode) &&
- allocatorResNodeBoundaryCompare(rightNode, matchingNode)) {
- RB_REMOVE(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
+ if (rightNode &&
+ allocatorResNodeOwnerCompare(rmHandle,
+ rightNode,
+ matchingNode) &&
+ allocatorResNodeBoundaryCompare(rightNode,
+ matchingNode)) {
+ RB_REMOVE(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
/* Combine rightNode and findNode */
rightNode->base = findNode.base;
rightNode->length += findNode.length;
- }
- else {
- rightNode = rmResourceNodeNew(findNode.base, findNode.length);
- allocatorResNodeOwnerCopy(rmHandle, rightNode, matchingNode);
+ } else {
+ rightNode = rmResourceNodeNew(findNode.base,
+ findNode.length);
+ allocatorResNodeOwnerCopy(rmHandle, rightNode,
+ matchingNode);
}
/* Remove rightNode range from matchingNode */
- matchingNode->length -= findNode.length;
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, rightNode);
-
- /* Right node is what remains after free. Return remaining owner count
- * and originating instance allocation reference count. */
+ matchingNode->length -= findNode.length;
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, rightNode);
+
+ /* Right node is what remains after free. Return
+ * remaining owner count and originating instance
+ * allocation reference count. */
opInfo->resourceInfo->ownerCount = rightNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, rightNode,
- opInfo->serviceInstNode);
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ rightNode,
+ opInfo->serviceInstNode);
}
- /* Add freeing instance back into matchingNode allocations */
- allocatorResNodeOwnerAdd(rmHandle, matchingNode, opInfo->serviceInstNode);
- RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
+ /* Add freeing instance back into matchingNode
+ * allocations */
+ allocatorResNodeOwnerAdd(rmHandle, matchingNode,
+ opInfo->serviceInstNode);
+ RB_INSERT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
}
retVal = RM_SERVICE_APPROVED;
- }
- else {
- /* Return owner count and instance alloc count. In case it's a reference count
- * check in application */
+ } else {
+ /* Return owner count and instance alloc count. In case
+ * it's a reference count check in application */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
retVal = RM_SERVICE_DENIED_RES_NOT_ALLOCD_TO_INST;
}
- }
- else {
- /* Return owner count and instance alloc count. In case it's a reference count
- * check in application */
+ } else {
+ /* Return owner count and instance alloc count. In case it's
+ * a reference count check in application */
opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
- opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle, matchingNode,
- opInfo->serviceInstNode);
+ opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
+ matchingNode,
+ opInfo->serviceInstNode);
retVal = RM_SERVICE_DENIED_RES_ALREADY_FREE;
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_PARTIAL_FREE;
}
- }
- else {
+ } else {
retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;
}
- return(retVal);
+ return(retVal);
}
/* FUNCTION PURPOSE: Reserves a Linux resource
memset((void *)&findNode, 0, sizeof(findNode));
findNode.base = *resBase;
findNode.length = *resLen;
- matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->resourceRoot, &findNode);
+ matchingNode = RB_FIND(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, &findNode);
if (matchingNode) {
/* Node can be freed back to Server from CD if:
* - allocationCount == 0
* - node's resource range is multiple of policy allocation size
- * - node's resource range boundaries are not contiguous with surrounding nodes */
+ * - node's resource range boundaries are not contiguous with
+ * surrounding nodes */
if (matchingNode->allocationCount) {
goto exitLocalization;
}
}
/* Check left neighbor */
- neighborNode = RB_PREV(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- if (neighborNode && allocatorResNodeBoundaryCompare(neighborNode, matchingNode)) {
+ neighborNode = RB_PREV(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ if (neighborNode &&
+ allocatorResNodeBoundaryCompare(neighborNode, matchingNode)) {
goto exitLocalization;
}
/* Check right neighbor */
- neighborNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->resourceRoot, matchingNode);
- if (neighborNode && allocatorResNodeBoundaryCompare(neighborNode, matchingNode)) {
+ neighborNode = RB_NEXT(_Rm_AllocatorResourceTree,
+ allocator->resourceRoot, matchingNode);
+ if (neighborNode &&
+ allocatorResNodeBoundaryCompare(neighborNode, matchingNode)) {
goto exitLocalization;
}
- /* All localization checks passed. Return the base and length of localized node. */
+ /* All localization checks passed. Return the base and length of
+ * localized node. */
nodeIsLocalized = RM_TRUE;
*resBase = matchingNode->base;
*resLen = matchingNode->length;
- }
- else {
+ } else {
nodeIsLocalized = RM_FALSE;
}
}
exitLocalization:
- return (nodeIsLocalized);
+ return(nodeIsLocalized);
}
/* FUNCTION PURPOSE: Issues an allocator operation
diff --git a/src/rm_dtb_util.c b/src/rm_dtb_util.c
index 8af1160573d5067089a8d658ba471c0750c0c497..249aeea79a1e6797d6a38e87c15957d7c1fa7049 100644 (file)
--- a/src/rm_dtb_util.c
+++ b/src/rm_dtb_util.c
* <200 100>;
* Results in a list of three ranges.
*/
-static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
+static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
uint32_t *dtbRangeData = (uint32_t *)dtbDataPtr;
Rm_ResourceRange *startRange = NULL;
@@ -101,11 +102,11 @@ static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32
Rm_ResourceRange *prevRange = NULL;
uint32_t i;
- /* Ranges are stored in the DTB as a list of 32-bit words. The number of 32-bit
- * words in the DTB ranges field should be even since ranges are specified in a
- * base, lenth format. The DTB gives properties lengths in bytes so the length
- * returned from the DTB should be a multiple of the number of bytes in two
- * uint32_ts. */
+ /* Ranges are stored in the DTB as a list of 32-bit words. The number of
+ * 32-bit words in the DTB ranges field should be even since ranges are
+ * specified in a base, lenth format. The DTB gives properties lengths in
+ * bytes so the length returned from the DTB should be a multiple of the
+ * number of bytes in two uint32_ts. */
if (dtbDataLen % (2 * sizeof(uint32_t))) {
return (NULL);
}
@@ -118,13 +119,12 @@ static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32
if (prevRange == NULL) {
startRange = newRange;
- }
- else {
+ } else {
prevRange->nextRange = newRange;
}
prevRange = newRange;
}
- return (startRange);
+ return(startRange);
}
/* FUNCTION PURPOSE: Deletes a range list
@@ -135,7 +135,7 @@ static Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32
static void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList)
{
Rm_ResourceRange *nextRange;
-
+
while (rangeList) {
nextRange = rangeList->nextRange;
Rm_osalFree((void *)rangeList, sizeof(Rm_ResourceRange));
* <30>;
* Results in a list of three values.
*/
-static Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t dtbDataLen)
+static Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
uint32_t *dtbRangeData = (uint32_t *)dtbDataPtr;
Rm_ResourceValue *startValue = NULL;
@@ -174,27 +175,26 @@ static Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, i
newValue = (Rm_ResourceValue *) Rm_osalMalloc(sizeof(Rm_ResourceValue));
newValue->value = fdt32_to_cpu(dtbRangeData[i]);
newValue->nextValue = NULL;
-
+
if (prevValue == NULL) {
startValue = newValue;
- }
- else {
+ } else {
prevValue->nextValue = newValue;
}
prevValue = newValue;
}
- return (startValue);
+ return(startValue);
}
/* FUNCTION PURPOSE: Deletes a value list
***********************************************************************
- * DESCRIPTION: Frees the memory associated with a list of values
+ * DESCRIPTION: Frees the memory associated with a list of values
* that were extracted from a DTB.
*/
static void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
{
Rm_ResourceValue *nextValue;
-
+
while (valueList) {
nextValue = valueList->nextValue;
Rm_osalFree((void *)valueList, sizeof(Rm_ResourceValue));
/* FUNCTION PURPOSE: Returns the GRL property type
***********************************************************************
- * DESCRIPTION: Returns the GRL property type associated with the
+ * DESCRIPTION: Returns the GRL property type associated with the
* property name specified.
*/
Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName)
if(strcmp(dtbUtilResRangeProp, propertyName) == 0) {
propertyType = Rm_resourcePropType_RESOURCE_RANGE;
- }
- else if(strcmp(dtbUtilResLinuxAliasProp, propertyName) == 0) {
+ } else if(strcmp(dtbUtilResLinuxAliasProp, propertyName) == 0) {
propertyType = Rm_resourcePropType_RESOURCE_LINUX_ALIAS;
- }
- else if(strcmp(dtbUtilResNsAssignmentProp, propertyName) == 0) {
+ } else if(strcmp(dtbUtilResNsAssignmentProp, propertyName) == 0) {
propertyType = Rm_resourcePropType_NSASSIGNMENT;
}
return (propertyType);
* <20 10>;
* Results in a list of three resource ranges.
*/
-Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceRange *rmDtbUtilResExtractRange(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
return(dtbUtilCommonExtractRange(dtbDataPtr, dtbDataLen));
}
* "LinuxDtbNode1 LinuxDtbNode2 anotherRes", <2 2 3>,
* Results in a list of two Linux alias paths.
*/
-Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen, int32_t *result)
+Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr,
+ int32_t dtbDataLen,
+ int32_t *result)
{
uint8_t *dtbAliasData = (uint8_t *)dtbDataPtr;
uint32_t pathLenBytes;
uint32_t extractedValue;
- uint8_t *extractedValueBytePtr;
+ uint8_t *extractedValueBytePtr;
Rm_LinuxAlias *startAlias = NULL;
Rm_LinuxAlias *newAlias = NULL;
Rm_LinuxAlias *prevAlias = NULL;
uint32_t numOffsets;
int32_t i = 0;
uint16_t j;
-
- /* Linux aliases are stored in the DTB as a list space-separated path node names within
- * null terminated string. Following the path string
- * will be two or three values specifying the fields in the linux DTB property
- * that contain the relevant data. The first value specifies the number of offsets
- * that follow. If two field offsets are specified the
- * Linux DTB contains a base + length. If one field offset is specified the
- * Linux DTB contains a single value for reservation. There is no padding between
- * the path string and the 32-bit offsets. Therefore the 32-bit offsets may not be on
- * a 4-byte boundary and must be constructed upon extraction */
+
+ /* Linux aliases are stored in the DTB as a list space-separated path node
+ * names within null terminated string. Following the path string will be
+ * two or three values specifying the fields in the linux DTB property that
+ * contain the relevant data. The first value specifies the number of
+ * offsets that follow. If two field offsets are specified the Linux DTB
+ * contains a base + length. If one field offset is specified the Linux
+ * DTB contains a single value for reservation. There is no padding
+ * between the path string and the 32-bit offsets. Therefore the 32-bit
+ * offsets may not be on a 4-byte boundary and must be constructed upon
+ * extraction */
while(i < dtbDataLen) {
newAlias = (Rm_LinuxAlias *) Rm_osalMalloc(sizeof(Rm_LinuxAlias));
-
+
pathLenBytes = strlen((char *) &dtbAliasData[i]) + 1;
newAlias->path = (char *) Rm_osalMalloc(pathLenBytes);
rm_strncpy(newAlias->path, ((char *) &dtbAliasData[i]), pathLenBytes);
-
+
/* Extract 32-bit value specifying number of offsets that follow */
i += pathLenBytes;
extractedValueBytePtr = (uint8_t *)&extractedValue;
@@ -313,7 +315,7 @@ Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtb
extractedValueBytePtr = (uint8_t *)&extractedValue;
for (j = 0; j < sizeof(uint32_t); j++, i++) {
extractedValueBytePtr[j] = dtbAliasData[i];
- }
+ }
newAlias->baseOffset = fdt32_to_cpu(extractedValue);
if (numOffsets == 2) {
@@ -321,50 +323,47 @@ Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtb
extractedValueBytePtr[j] = dtbAliasData[i];
}
newAlias->lengthOffset = fdt32_to_cpu(extractedValue);
- }
- else {
+ } else {
newAlias->lengthOffset = RM_DTB_UTIL_LINUX_ALIAS_OFFSET_NOT_SET;
- }
-
+ }
+
newAlias->nextLinuxAlias = NULL;
if (prevAlias == NULL) {
startAlias = newAlias;
- }
- else {
+ } else {
prevAlias->nextLinuxAlias = newAlias;
}
prevAlias = newAlias;
- }
- else {
+ } else {
Rm_osalFree((void *)newAlias->path, pathLenBytes);
Rm_osalFree((void *)newAlias, sizeof(Rm_LinuxAlias));
while (startAlias) {
newAlias = startAlias->nextLinuxAlias;
- pathLenBytes = strlen(startAlias->path);
+ pathLenBytes = strlen(startAlias->path);
Rm_osalFree((void *)startAlias->path, pathLenBytes + 1);
Rm_osalFree((void *)startAlias, sizeof(Rm_LinuxAlias));
startAlias = newAlias;
- }
+ }
*result = RM_ERROR_GRL_INVALID_LINUX_ALIAS_FORMAT;
return(NULL);
}
}
- return (startAlias);
+ return(startAlias);
}
/* FUNCTION PURPOSE: Deletes a Linux Alias list
***********************************************************************
- * DESCRIPTION: Frees the memory associated with a list of Linux
+ * DESCRIPTION: Frees the memory associated with a list of Linux
* aliases that were extracted from a GRL DTB.
*/
void rmDtbUtilResFreeLinuxAlias(Rm_LinuxAlias *aliasList)
{
Rm_LinuxAlias *nextAlias;
int32_t pathSize;
-
+
while (aliasList) {
nextAlias = aliasList->nextLinuxAlias;
- pathSize = strlen(aliasList->path);
+ pathSize = strlen(aliasList->path);
Rm_osalFree((void *)aliasList->path, pathSize + 1);
Rm_osalFree((void *)aliasList, sizeof(Rm_LinuxAlias));
aliasList = nextAlias;
* "Another Name", <20 10>;
* Results in a list of three NameServer assignments.
*/
-Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen, int32_t *result)
+Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr,
+ int32_t dtbDataLen,
+ int32_t *result)
{
uint8_t *dtbNsAssignmentData = (uint8_t *)dtbDataPtr;
uint32_t nameLenBytes;
uint32_t extractedValue;
- uint8_t *extractedValueBytePtr;
+ uint8_t *extractedValueBytePtr;
Rm_NsAssignment *startAssignment = NULL;
Rm_NsAssignment *newAssignment = NULL;
Rm_NsAssignment *prevAssignment = NULL;
int32_t i = 0;
uint16_t j;
-
- /* NameServer assignments are stored in the DTB as a null-terminated character
- * string followed by a 32-bit word containing the value to be assigned to the
- * name in the string. There is no padding between the string and the 32-bit
- * word. Therefore the 32-bit word may not be on a 4-byte boundary and must
- * be constructed upon extraction */
+
+ /* NameServer assignments are stored in the DTB as a null-terminated
+ * character string followed by a 32-bit word containing the value to be
+ * assigned to the name in the string. There is no padding between the
+ * string and the 32-bit word. Therefore the 32-bit word may not be on a
+ * 4-byte boundary and must be constructed upon extraction */
while(i < dtbDataLen) {
- newAssignment = (Rm_NsAssignment *) Rm_osalMalloc(sizeof(Rm_NsAssignment));
-
+ newAssignment = (Rm_NsAssignment *)Rm_osalMalloc(sizeof(Rm_NsAssignment));
+
nameLenBytes = strlen((char *) &dtbNsAssignmentData[i]) + 1;
if (nameLenBytes > RM_NAME_MAX_CHARS) {
Rm_osalFree((void *)newAssignment, sizeof(Rm_NsAssignment));
@@ -414,9 +415,10 @@ Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t
}
*result = RM_ERROR_NAMESERVER_NAME_TOO_LONG;
return(NULL);
- }
- rm_strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]), RM_NAME_MAX_CHARS);
-
+ }
+ rm_strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]),
+ RM_NAME_MAX_CHARS);
+
/* Extract 32-bit base value and flip endian */
i += nameLenBytes;
extractedValueBytePtr = (uint8_t *)&extractedValue;
@@ -430,18 +432,17 @@ Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t
extractedValueBytePtr[j] = dtbNsAssignmentData[i];
}
newAssignment->resourceLength = fdt32_to_cpu(extractedValue);
-
+
newAssignment->nextNsAssignment = NULL;
if (prevAssignment == NULL) {
startAssignment = newAssignment;
- }
- else {
+ } else {
prevAssignment->nextNsAssignment = newAssignment;
}
prevAssignment = newAssignment;
}
-
- return (startAssignment);
+
+ return(startAssignment);
}
/* FUNCTION PURPOSE: Deletes a NameServer assignment list
@@ -452,7 +453,7 @@ Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t
void rmDtbUtilResFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
{
Rm_NsAssignment *nextAssignment;
-
+
while (nsAssignmentList) {
nextAssignment = nsAssignmentList->nextNsAssignment;
Rm_osalFree((void *)nsAssignmentList, sizeof(Rm_NsAssignment));
if(strcmp(dtbUtilPolicyAssignments, propertyName) == 0) {
propertyType = Rm_policyPropType_ASSIGNMENTS;
- }
- else if(strcmp(dtbUtilPolicyCdAllocationSize, propertyName) == 0) {
+ } else if(strcmp(dtbUtilPolicyCdAllocationSize, propertyName) == 0) {
propertyType = Rm_policyPropType_CD_ALLOCATION_SIZE;
- }
- else if(strcmp(dtbUtilPolicyAllocationAlignment, propertyName) == 0) {
+ } else if(strcmp(dtbUtilPolicyAllocationAlignment, propertyName) == 0) {
propertyType = Rm_policyPropType_ALLOCATION_ALIGNMENT;
- }
- else if(strcmp(dtbUtilPolicyValidInstances, propertyName) == 0) {
+ } else if(strcmp(dtbUtilPolicyValidInstances, propertyName) == 0) {
propertyType = Rm_policyPropType_VALID_INSTANCES;
- }
- return (propertyType);
+ }
+ return(propertyType);
}
/* FUNCTION PURPOSE: Extracts a policy assignment list from a Policy DTB
* <10 10>, "iu = (*);
* Results in a list of two policy assignments.
*/
-Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
uint8_t *dtbAssignmentData = (uint8_t *)dtbDataPtr;
uint32_t permissionsLenBytes;
uint32_t extractedValue;
- uint8_t *extractedValueBytePtr;
+ uint8_t *extractedValueBytePtr;
Rm_PolicyAssignment *startAssignment = NULL;
Rm_PolicyAssignment *newAssignment = NULL;
Rm_PolicyAssignment *prevAssignment = NULL;
int32_t i = 0;
uint16_t j;
-
- /* Policy assignments are stored in the DTB as two 32-bit words containing a
- * resource base and length to be assigned the permissions in the defined in
- * the string that follows. There is no padding between the 32-bit words and the
- * string. Therefore the 32-bit word may not be on a 4-byte boundary and must
- * be constructed upon extraction */
+
+ /* Policy assignments are stored in the DTB as two 32-bit words containing
+ * a resource base and length to be assigned the permissions in the defined
+ * in the string that follows. There is no padding between the 32-bit
+ * words and the string. Therefore the 32-bit word may not be on a 4-byte
+ * boundary and must be constructed upon extraction */
while(i < dtbDataLen) {
- newAssignment = (Rm_PolicyAssignment *) Rm_osalMalloc(sizeof(Rm_PolicyAssignment));
+ newAssignment = (Rm_PolicyAssignment *)Rm_osalMalloc(sizeof(Rm_PolicyAssignment));
/* Extract 32-bit resource base value and flip endianness */
extractedValueBytePtr = (uint8_t *)&extractedValue;
@@ -537,20 +536,20 @@ Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr, i
newAssignment->resourceLength = fdt32_to_cpu(extractedValue);
permissionsLenBytes = strlen((char *) &dtbAssignmentData[i]) + 1;
- newAssignment->permissionsList = (char *) Rm_osalMalloc(permissionsLenBytes);
- rm_strncpy(newAssignment->permissionsList, ((char *) &dtbAssignmentData[i]), permissionsLenBytes);
+ newAssignment->permissionsList = (char *)Rm_osalMalloc(permissionsLenBytes);
+ rm_strncpy(newAssignment->permissionsList,
+ ((char *)&dtbAssignmentData[i]), permissionsLenBytes);
i += permissionsLenBytes;
newAssignment->nextAssignment = NULL;
if (prevAssignment == NULL) {
startAssignment = newAssignment;
- }
- else {
+ } else {
prevAssignment->nextAssignment = newAssignment;
}
prevAssignment = newAssignment;
}
- return (startAssignment);
+ return(startAssignment);
}
/* FUNCTION PURPOSE: Deletes a policy assignment list
{
Rm_PolicyAssignment *nextAssignment;
int32_t permissionsSize;
-
+
while (assignmentList) {
nextAssignment = assignmentList->nextAssignment;
permissionsSize = strlen(assignmentList->permissionsList);
* <100>;
* Results in a list of two allocation sizes.
*/
-Rm_ResourceValue *rmDtbUtilPolicyExtractCdAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceValue *rmDtbUtilPolicyExtractCdAllocationSizes(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
return(dtbUtilCommonExtractValueList(dtbDataPtr, dtbDataLen));
}
@@ -611,7 +611,8 @@ void rmDtbUtilPolicyFreeCdAllocationSizes (Rm_ResourceValue *allocationSizeList)
* <100>;
* Results in a list of two resource alignments.
*/
-Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
return(dtbUtilCommonExtractValueList(dtbDataPtr, dtbDataLen));
}
@@ -621,7 +622,7 @@ Rm_ResourceValue *rmDtbUtilPolicyExtractResourceAlignments(const void *dtbDataPt
* DESCRIPTION: Frees the memory associated with a list of resource
* alignments that were extracted from a Policy DTB.
*/
-void rmDtbUtilPolicyFreeResourceAlignments (Rm_ResourceValue *alignmentList)
+void rmDtbUtilPolicyFreeResourceAlignments(Rm_ResourceValue *alignmentList)
{
dtbUtilCommonFreeValueList(alignmentList);
}
@@ -648,11 +649,11 @@ Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
Rm_PolicyValidInst *newInst = NULL;
Rm_PolicyValidInst *prevInst = NULL;
int32_t i = 0;
-
- /* Valid RM instances are stored in the DTB as a list of null-terminated character
- * strings. */
+
+ /* Valid RM instances are stored in the DTB as a list of null-terminated
+ * character strings. */
while(i < dtbDataLen) {
- newInst = (Rm_PolicyValidInst *) Rm_osalMalloc(sizeof(Rm_PolicyValidInst));
+ newInst = (Rm_PolicyValidInst *)Rm_osalMalloc(sizeof(Rm_PolicyValidInst));
instLenBytes = strlen((char *) &dtbValidInstData[i]) + 1;
if (instLenBytes > RM_NAME_MAX_CHARS) {
@@ -665,21 +666,21 @@ Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
*result = RM_ERROR_VALID_INST_NAME_TOO_LONG;
return(NULL);
}
- rm_strncpy(newInst->instName, ((char *) &dtbValidInstData[i]), instLenBytes);
-
+ rm_strncpy(newInst->instName, ((char *) &dtbValidInstData[i]),
+ instLenBytes);
+
i += instLenBytes;
newInst->nextValidInst = NULL;
if (prevInst == NULL) {
startInst = newInst;
- }
- else {
+ } else {
prevInst->nextValidInst = newInst;
}
prevInst = newInst;
}
- return (startInst);
+ return(startInst);
}
/* FUNCTION PURPOSE: Deletes a valid instnace list
@@ -690,7 +691,7 @@ Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
void rmDtbUtilPolicyFreeValidInstances (Rm_PolicyValidInst *validInstList)
{
Rm_PolicyValidInst *nextInst;
-
+
while (validInstList) {
nextInst = validInstList->nextValidInst;
Rm_osalFree((void *)validInstList, sizeof(Rm_PolicyValidInst));
* <1 5 10 15 20 25>;
* Results in a list of six Linux values.
*/
-Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen)
+Rm_LinuxValueRange *rmDtbUtilLinuxExtractValues(const void *dtbDataPtr,
+ int32_t dtbDataLen)
{
uint32_t *dtbValueData = (uint32_t *)dtbDataPtr;
Rm_LinuxValueRange *startValue = NULL;
Rm_LinuxValueRange *newValue = NULL;
Rm_LinuxValueRange *prevValue = NULL;
uint32_t i;
-
- /* Values are stored in the Linux DTB as a list of 32-bit words. The number of 32-bit
- * words in the value field can differ. depending on the number of values specified. */
+
+ /* Values are stored in the Linux DTB as a list of 32-bit words. The
+ * number of 32-bit words in the value field can differ. depending on the
+ * number of values specified. */
for (i = 0; i < (dtbDataLen / sizeof(uint32_t)); i++) {
- newValue = (Rm_LinuxValueRange *) Rm_osalMalloc(sizeof(Rm_LinuxValueRange));
+ newValue = (Rm_LinuxValueRange *)Rm_osalMalloc(sizeof(Rm_LinuxValueRange));
/* Endianness of extracted value must be flipped */
newValue->value = fdt32_to_cpu(dtbValueData[i]);
newValue->nextValue = NULL;
-
+
if (prevValue == NULL) {
startValue = newValue;
- }
- else {
+ } else {
prevValue->nextValue = newValue;
}
prevValue = newValue;
}
- return (startValue);
+ return(startValue);
}
/* FUNCTION PURPOSE: Deletes a Linux values list
diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c
index ee920403359ef857f438e8a94cee71db3e3e7c23..1464d8d978adaacce4d739d5264d758e5a604ee5 100644 (file)
--- a/src/rm_nameserver.c
+++ b/src/rm_nameserver.c
rmNameServerNodeFree(newNode);
retVal = RM_SERVICE_DENIED_NAME_EXISTS_IN_NS;
}
- }
- else {
+ } else {
retVal = RM_ERROR_NAMESERVER_NAME_ADD_FAILED;
}
objCfg->nodeCfg.resourceLength = matchingNode->resourceLength;
retVal = RM_SERVICE_PROCESSING;
- }
+ }
return(retVal);
}
* memory associated with the NameServer node
*/
int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
-{
+{
Rm_NameServerNode findNode;
Rm_NameServerNode *matchingNode;
- int32_t retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;
+ int32_t retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;
memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
rm_strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
-
+
if ((matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree,
&findNode))) {
/* Remove from NameServer */
RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode);
rmNameServerNodeFree(matchingNode);
-
+
retVal = RM_SERVICE_APPROVED;
- }
+ }
return(retVal);
}
rmNameServerTreeInv(root);
}
RB_FOREACH(node, _Rm_NameServerTree, root) {
- Rm_osalLog("Name: %s resourceName: %s base: %d length: %d\n", node->objName, node->resourceName,
- node->resourceBase, node->resourceLength);
+ Rm_osalLog("Name: %s resourceName: %s base: %d length: %d\n",
+ node->objName, node->resourceName, node->resourceBase,
+ node->resourceLength);
}
}
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
rmNameServerTreeInv(treeRoot);
}
-
- for (node = RB_MIN(_Rm_NameServerTree, treeRoot); node != NULL; node = nextNode) {
+
+ for (node = RB_MIN(_Rm_NameServerTree, treeRoot);
+ node != NULL;
+ node = nextNode) {
nextNode = RB_NEXT(_Rm_NameServerTree, treeRoot, node);
objCfg.nameServerTree = treeRoot;
objCfg.nodeCfg.objName = node->objName;
rmNameServerDeleteObject(&objCfg);
}
- /* Don't need to writeback tree node changes since NameServer will be made
- * NULL in instance */
-
+ /* Don't need to writeback tree node changes since NameServer will be
+ * made NULL in instance */
+
if (RB_MIN(_Rm_NameServerTree, treeRoot) == NULL) {
Rm_osalFree((void *)treeRoot, sizeof(Rm_NameServerTree));
}
diff --git a/src/rm_policy.c b/src/rm_policy.c
index 82753da8f9a25c091ff0903957baf3da16000549..01421dcb8fe6718239bb9aece9ec63167f75c6b5 100644 (file)
--- a/src/rm_policy.c
+++ b/src/rm_policy.c
* errors are encountered during the parsing. The error
* is returned via the result pointer parameter.
*/
-static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd,
+static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart,
+ char *permStrEnd,
int32_t *result)
{
Rm_PolicyPermission *startPerm = NULL;
@@ -111,14 +112,17 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
subgroupEnd = strchr(permStrStart, RM_POLICY_PERM_SUBGROUP_END);
if ((!subgroupStart) || (!subgroupEnd) || (subgroupStart > subgroupEnd) ||
- ((subgroupStart != strrchr(permStrStart, RM_POLICY_PERM_SUBGROUP_START)) &&
- (subgroupEnd != strrchr(permStrStart, RM_POLICY_PERM_SUBGROUP_END)))) {
- /* Free the memory associated with the temp string and return an error if:
+ ((subgroupStart != strrchr(permStrStart,
+ RM_POLICY_PERM_SUBGROUP_START)) &&
+ (subgroupEnd != strrchr(permStrStart,
+ RM_POLICY_PERM_SUBGROUP_END)))) {
+ /* Free the memory associated with the temp string and return an
+ * error if:
* a) Could not find the instance group start
* b) Could not find the instance group end
* c) Subgroup start and end are out of order
- * d) There is more than one instance subgroup specified in the string. There
- * should only be one subgroup per sub-permission string */
+ * d) There is more than one instance subgroup specified in the string.
+ * There should only be one subgroup per sub-permission string */
*result = RM_ERROR_PERM_STR_TOO_MANY_INST_GROUPS;
goto parseError;
}
@@ -130,15 +134,15 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
foundInstName = RM_FALSE;
instNameComplete = RM_FALSE;
while (permStrPtr <= subgroupEnd) {
- if ((isspace(*permStrPtr) || (*permStrPtr == RM_POLICY_PERM_SUBGROUP_END))
+ if ((isspace(*permStrPtr) ||
+ (*permStrPtr == RM_POLICY_PERM_SUBGROUP_END))
&& foundInstName) {
/* First space encountered after copying an instance name. This
* terminates the instance name. All other space characters are
* ignored. */
instNameTemp[instNameIndex] = '\0';
instNameComplete = RM_TRUE;
- }
- else {
+ } else {
if (!foundInstName) {
/* First non-whitespace character encountered is the start of an
* instance name */
@@ -150,8 +154,8 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
}
if (instNameComplete) {
- newPerm = (Rm_PolicyPermission *) Rm_osalMalloc(sizeof(Rm_PolicyPermission));
- memset((void *)newPerm, 0, sizeof(Rm_PolicyPermission));
+ newPerm = Rm_osalMalloc(sizeof(*newPerm));
+ memset((void *)newPerm, 0, sizeof(*newPerm));
rm_strncpy(newPerm->instName, instNameTemp, RM_NAME_MAX_CHARS);
newPerm->nextPermission = NULL;
@@ -159,8 +163,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
if (prevPerm == NULL) {
/* Save the first instance so it can be returned */
startPerm = newPerm;
- }
- else {
+ } else {
prevPerm->nextPermission = newPerm;
}
prevPerm = newPerm;
@@ -168,8 +171,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
instNameComplete = RM_FALSE;
instNameIndex = 0;
foundInstName = RM_FALSE;
- }
- else if (instNameIndex == RM_NAME_MAX_CHARS) {
+ } else if (instNameIndex == RM_NAME_MAX_CHARS) {
/* Instance name is longer than max length */
*result = RM_ERROR_INST_NAME_IN_ASSIGNMENT_TOO_LONG;
goto parseError;
@@ -187,19 +189,17 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
{
if (*permStrPtr == RM_POLICY_PERM_ASSIGNMENT) {
if (assignmentLeft) {
- /* Assignment character has been found more than once. This is a
- * syntax error. Free the permission list and the temporary string
- * and return. */
+ /* Assignment character has been found more than once. This
+ * is a syntax error. Free the permission list and the
+ * temporary string and return. */
*result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
goto parseError;
- }
- else {
+ } else {
assignmentLeft = RM_TRUE;
}
- }
- else if (!isspace(*permStrPtr)) {
+ } else if (!isspace(*permStrPtr)) {
if (assignmentLeft) {
- if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
+ if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_INIT_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -208,8 +208,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_INIT_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_USE_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -218,8 +217,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_USE_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -228,8 +226,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -239,19 +236,17 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
1);
newPerm = newPerm->nextPermission;
}
- }
- else {
- /* Invalid permission character. This is a
- * syntax error. Free the permission list and the temporary string
+ } else {
+ /* Invalid permission character. This is a syntax error.
+ * Free the permission list and the temporary string
* and return. */
*result = RM_ERROR_PERM_STR_INVALID_CHAR;
goto parseError;
}
- }
- else {
- /* Character found without the assignment character being found. This is a
- * syntax error. Free the permission list and the temporary string
- * and return. */
+ } else {
+ /* Character found without the assignment character being found.
+ * This is a syntax error. Free the permission list and the
+ * temporary string and return. */
*result = RM_ERROR_PERM_CHAR_WITHOUT_ASSIGN_CHAR;
goto parseError;
}
@@ -264,26 +259,25 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
assignmentRight = RM_FALSE;
while (permStrPtr < permStrEnd) {
if (assignmentLeft && (!isspace(*permStrPtr))) {
- /* There should be nothing but spaces on right if assignment was already found on left */
+ /* There should be nothing but spaces on right if assignment was
+ * already found on left */
*result = RM_ERROR_INVALID_PERMS_CHAR_ON_RIGHT;
- goto parseError;
+ goto parseError;
}
-
+
if (*permStrPtr == RM_POLICY_PERM_ASSIGNMENT) {
if (assignmentRight) {
- /* Assignment character has been found more than once. This is a
- * syntax error. Free the permission list and the temporary string
- * and return. */
+ /* Assignment character has been found more than once. This is
+ * a syntax error. Free the permission list and the temporary
+ * string and return. */
*result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
- goto parseError;
- }
- else {
+ goto parseError;
+ } else {
assignmentRight = RM_TRUE;
}
- }
- else if (!isspace(*permStrPtr)) {
+ } else if (!isspace(*permStrPtr)) {
if (assignmentRight) {
- if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
+ if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_INIT_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -292,8 +286,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_INIT_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_USE_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -302,8 +295,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_USE_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -312,8 +304,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
newPerm = newPerm->nextPermission;
}
- }
- else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
+ } else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER)) {
newPerm = startPerm;
while (newPerm) {
@@ -323,19 +314,17 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
1);
newPerm = newPerm->nextPermission;
}
- }
- else {
- /* Invalid permission character. This is a
- * syntax error. Free the permission list and the temporary string
+ } else {
+ /* Invalid permission character. This is a syntax error.
+ * Free the permission list and the temporary string
* and return. */
*result = RM_ERROR_PERM_STR_INVALID_CHAR;
- goto parseError;
+ goto parseError;
}
- }
- else {
- /* Character found without the assignment character being found. This is a
- * syntax error. Free the permission list and the temporary string
- * and return. */
+ } else {
+ /* Character found without the assignment character being found.
+ * This is a syntax error. Free the permission list and the
+ * temporary string and return. */
*result = RM_ERROR_PERM_STR_TOO_MANY_ASSIGN_CHARS;
goto parseError;
}
nextPerm = startPerm->nextPermission;
Rm_osalFree((void *)startPerm, sizeof(Rm_PolicyPermission));
startPerm = nextPerm;
- }
+ }
Rm_osalFree((void *)permStrStart, permStrLen);
- return(NULL);
+ return(NULL);
}
/* FUNCTION PURPOSE: Frees a linked list of assignment permissions
static void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
{
Rm_PolicyPermission *nextPerm;
-
+
while (permissionList) {
nextPerm = permissionList->nextPermission;
Rm_osalFree((void *)permissionList, sizeof(Rm_PolicyPermission));
@@ -381,7 +370,7 @@ static void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList)
* Each node in the linked list will contain a valid instance
* name along with the permissions assigned to the instance
*/
-static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment,
+static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment,
int32_t *result)
{
Rm_PolicyPermission *startPerm = NULL;
@@ -393,13 +382,14 @@ static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *
uint32_t i = 0;
*result = RM_OK;
-
+
while(i < permStrLen) {
- /* Find the first sub-permission specification and parse it. A sub-permission
- * can be terminated by the termination character or the end of the string. */
- if (!(permStrEnd = strchr(permStrStart, RM_POLICY_PERM_TERMINATOR))) {
- /* Sub-permission termination character not found. The permission string
- * end is the end of the entire permission string */
+ /* Find the first sub-permission specification and parse it. A
+ * sub-permission can be terminated by the termination character or the
+ * end of the string. */
+ if (!(permStrEnd = strchr(permStrStart, RM_POLICY_PERM_TERMINATOR))) {
+ /* Sub-permission termination character not found. The permission
+ * string end is the end of the entire permission string */
permStrEnd = permStrStart + strlen(permStrStart);
}
@@ -414,19 +404,19 @@ static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *
if (prevPerm == NULL) {
startPerm = newPerm;
- }
- else {
+ } else {
prevPerm->nextPermission = newPerm;
}
- /* Set prevPerm to the last sub-permission returned by the sub-permission parser */
+ /* Set prevPerm to the last sub-permission returned by the
+ * sub-permission parser */
prevPerm = newPerm;
while(prevPerm->nextPermission != NULL) {
prevPerm = prevPerm->nextPermission;
}
-
- /* Update the number of characters parsed from the permission list and point to
- * the start of the next sub-permission */
+
+ /* Update the number of characters parsed from the permission list and
+ * point to the start of the next sub-permission */
i += ((uint32_t)(permStrEnd - permStrStart + 1));
permStrStart = permStrEnd + 1;
}
{
const char linuxName[] = RM_ALLOCATED_TO_LINUX;
- return (rmPolicyGetValidInstNode(rmHandle, linuxName));
+ return(rmPolicyGetValidInstNode(rmHandle, linuxName));
}
/* FUNCTION PURPOSE: Validates resource permissions against a Policy DTB
matchEnd = matchNode->base + matchNode->len - 1;
findEnd = findNode.base + findNode.len - 1;
-
+
/* Check node to right if request range spans matching node to right */
if (findEnd > matchEnd) {
matchNode = RB_NEXT(_Rm_AllocatorPolicyTree, privilegeCfg->polTree,
diff --git a/src/rm_services.c b/src/rm_services.c
index 6bedf7b861c3da8f331526604d81ad896f2760c5..ed3d758adedc46f57dd7aa6adc3539ba1b8b56a6 100644 (file)
--- a/src/rm_services.c
+++ b/src/rm_services.c
@@ -161,11 +161,12 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
if ((rmInst->instType == Rm_instType_SHARED_SERVER) &&
(transaction->state == RM_SERVICE_PROCESSING)) {
- /* Shared Server should always return a fully processed transaction */
+ /* Shared Server should always return a fully processed
+ * transaction */
serviceResponse->serviceState = RM_ERROR_SHARED_INSTANCE_UNFINISHED_REQ;
rmTransactionQueueDelete(rmInst, transaction->localId);
} else {
- if ((transaction->state == RM_SERVICE_PROCESSING) &&
+ if ((transaction->state == RM_SERVICE_PROCESSING) &&
(transaction->u.callback.serviceCallback == NULL)) {
/* Block until response is received. Response will be
* received in transaction. */
serviceHandle->Rm_serviceHandler = Rm_serviceHandler;
RM_SS_OBJ_WB(rmInst, serviceHandle, Rm_ServiceHandle);
rmInst->serviceHandle = serviceHandle;
- }
- else {
+ } else {
*result = RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED;
}
}
-
+
if (rmInst->mtSemObj) {
Rm_osalMtCsExit(rmInst->mtSemObj, mtKey);
- }
+ }
RM_SS_INST_WB_EXIT_CS(rmInst, key);
return (serviceHandle);
}
if (rmInst->serviceHandle) {
Rm_osalFree((void *)rmServiceHandle, sizeof(*rmServiceHandle));
rmInst->serviceHandle = NULL;
- }
- else {
+ } else {
retVal = RM_ERROR_SERVICE_HANDLE_ALREADY_CLOSED;
}
-
+
if (rmInst->mtSemObj) {
Rm_osalMtCsExit(rmInst->mtSemObj, mtKey);
- }
+ }
RM_SS_INST_WB_EXIT_CS(rmInst, key);
return(retVal);
}
diff --git a/src/rm_transport.c b/src/rm_transport.c
index c105a143a989ab87a19c39e05c8fdfc1cb641785..db14c8853bd65a04cbf2b1be6a23aebb9c3f6a54 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
transports = transports->nextTransport;\r
}\r
transports->nextTransport = newTransport;\r
- }\r
- else {\r
+ } else {\r
rmInst->transports = newTransport;\r
}\r
}\r
- return (newTransport);\r
+ return(newTransport);\r
}\r
\r
/* FUNCTION PURPOSE: Tests if a transport is registered to an instance\r
{\r
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;\r
Rm_Transport *transportList = (Rm_Transport *)rmInst->transports;\r
- \r
+\r
while (transportList) {\r
if (transportList == transport) {\r
- return(RM_TRUE); \r
+ return(RM_TRUE);\r
}\r
transportList = transportList->nextTransport;\r
}\r
- return (RM_FALSE);\r
+ return(RM_FALSE);\r
}\r
\r
/* FUNCTION PURPOSE: Deletes a transport\r
/* Get previous transport in list */\r
while (transportList) {\r
if (transportList == transport) {\r
- break; \r
+ break;\r
}\r
prevTransport = transportList;\r
transportList = transportList->nextTransport;\r
\r
if (prevTransport == NULL) {\r
rmInst->transports = transport->nextTransport;\r
- }\r
- else {\r
+ } else {\r
prevTransport->nextTransport = transport->nextTransport;\r
}\r
Rm_osalFree((void *)transport, sizeof(Rm_Transport));\r
}\r
\r
-/**********************************************************************\r
- ********************** Internal Functions ****************************\r
- **********************************************************************/\r
-\r
-/* FUNCTION PURPOSE: Finds a transport based on remote inst type\r
- ***********************************************************************\r
- * DESCRIPTION: Returns a pointer to the transport within an instance's\r
- * transport list that matches the provided remote\r
- * instance type. NULL is returned if no transports in \r
- * the list match the remote instance type.\r
- */\r
-Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType)\r
-{\r
- while (transports) {\r
- if (transports->remoteInstType == remoteInstType) {\r
- break; \r
- }\r
- transports = transports->nextTransport;\r
- }\r
- return (transports);\r
-}\r
-\r
/* FUNCTION PURPOSE: Returns RM packet source instance\r
***********************************************************************\r
* DESCRIPTION: Can return the RM instance name for one of two things:\r
@@ -168,27 +144,28 @@ Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstTyp
* - RM instance from which the service request contained\r
* in the provided RM packet originated\r
*/\r
-int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc, char *serviceSrc, int32_t bufLen)\r
+static int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc,\r
+ char *serviceSrc, int32_t bufLen)\r
{\r
int32_t retVal = RM_OK;\r
\r
if (bufLen != RM_NAME_MAX_CHARS) {\r
retVal = RM_ERROR_SRC_NAME_BUF_INVALID_SIZE;\r
- }\r
- else {\r
+ } else {\r
switch (pkt->pktType) {\r
case Rm_pktType_RESOURCE_REQUEST:\r
{\r
Rm_ResourceRequestPkt *resourceReqPkt = (Rm_ResourceRequestPkt *)pkt->data;\r
\r
if (pktSrc){\r
- rm_strncpy(pktSrc, resourceReqPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
+ rm_strncpy(pktSrc, resourceReqPkt->pktSrcInstName,\r
+ RM_NAME_MAX_CHARS);\r
}\r
\r
if (serviceSrc) {\r
- rm_strncpy(serviceSrc, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+ rm_strncpy(serviceSrc, resourceReqPkt->serviceSrcInstName,\r
+ RM_NAME_MAX_CHARS);\r
}\r
-\r
break;\r
}\r
case Rm_pktType_NAMESERVER_REQUEST:\r
@@ -196,26 +173,48 @@ int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc, char *serviceSrc, int
Rm_NsRequestPkt *nsRequestPkt = (Rm_NsRequestPkt *)pkt->data;\r
\r
if (pktSrc){\r
- rm_strncpy(pktSrc, nsRequestPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
+ rm_strncpy(pktSrc, nsRequestPkt->pktSrcInstName,\r
+ RM_NAME_MAX_CHARS);\r
}\r
\r
if (serviceSrc) {\r
- rm_strncpy(serviceSrc, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+ rm_strncpy(serviceSrc, nsRequestPkt->serviceSrcInstName,\r
+ RM_NAME_MAX_CHARS);\r
}\r
-\r
break;\r
}\r
case Rm_pktType_RESOURCE_RESPONSE:\r
case Rm_pktType_NAMESERVER_RESPONSE:\r
default:\r
- {\r
retVal = RM_ERROR_PKT_AND_SERVICE_SRC_NOT_AVAIL;\r
break;\r
- }\r
}\r
}\r
\r
- return (retVal);\r
+ return(retVal);\r
+}\r
+\r
+/**********************************************************************\r
+ ********************** Internal Functions ****************************\r
+ **********************************************************************/\r
+\r
+/* FUNCTION PURPOSE: Finds a transport based on remote inst type\r
+ ***********************************************************************\r
+ * DESCRIPTION: Returns a pointer to the transport within an instance's\r
+ * transport list that matches the provided remote\r
+ * instance type. NULL is returned if no transports in \r
+ * the list match the remote instance type.\r
+ */\r
+Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports,\r
+ Rm_InstType remoteInstType)\r
+{\r
+ while (transports) {\r
+ if (transports->remoteInstType == remoteInstType) {\r
+ break;\r
+ }\r
+ transports = transports->nextTransport;\r
+ }\r
+ return(transports);\r
}\r
\r
/**********************************************************************\r
@@ -234,7 +233,8 @@ int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc, char *serviceSrc, int
* is returned for the transport handle if any errors\r
* are encountered.\r
*/\r
-Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, int32_t *result)\r
+Rm_TransportHandle Rm_transportRegister(const Rm_TransportCfg *transportCfg,\r
+ int32_t *result)\r
{\r
Rm_Inst *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
Rm_Transport *transport = NULL;\r
@@ -270,22 +270,22 @@ Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, in
goto errorExit;\r
}\r
\r
- /* Verify Clients are not registering with more than one Client Delegate or Server. And\r
- * that Client Delegate is not registering with more than one Server. */\r
+ /* Verify Clients are not registering with more than one Client Delegate or\r
+ * Server. And that Client Delegate is not registering with more than one\r
+ * Server. */\r
if (rmInst->registeredWithDelegateOrServer &&\r
(((rmInst->instType == Rm_instType_CLIENT) &&\r
- (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
+ (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) ||\r
((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
(transportCfg->remoteInstType == Rm_instType_SERVER)))) {\r
*result = RM_ERROR_ALREADY_REGD_SERVER_OR_CD;\r
goto errorExit;\r
- } \r
- \r
+ }\r
+\r
if (!transportCfg->transportCallouts.rmAllocPkt) {\r
*result = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
goto errorExit;\r
- }\r
- else if (!transportCfg->transportCallouts.rmSendPkt) {\r
+ } else if (!transportCfg->transportCallouts.rmSendPkt) {\r
*result = RM_ERROR_TRANSPORT_SEND_NOT_REGD;\r
goto errorExit;\r
}\r
@@ -299,8 +299,8 @@ Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, in
errorExit:\r
if (rmInst->mtSemObj) {\r
Rm_osalMtCsExit(rmInst->mtSemObj, mtKey);\r
- } \r
- RM_SS_INST_WB_EXIT_CS(rmInst, key); \r
+ }\r
+ RM_SS_INST_WB_EXIT_CS(rmInst, key);\r
return ((Rm_TransportHandle) transport);\r
}\r
\r
* configuration parameters if it exists within the \r
* instance.\r
*/\r
-int32_t Rm_transportReconfig (Rm_TransportHandle transportHandle, const Rm_TransportReCfg *reCfg)\r
+int32_t Rm_transportReconfig(Rm_TransportHandle transportHandle,\r
+ const Rm_TransportReCfg *reCfg)\r
{\r
Rm_Transport *transport = (Rm_Transport *)transportHandle;\r
Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle;\r
@@ -324,8 +325,8 @@ int32_t Rm_transportReconfig (Rm_TransportHandle transportHandle, const Rm_Trans
}\r
\r
if (transportIsRegistered(transport->rmHandle, transport)) {\r
- /* Reconfigure existing transport's appTransportHandle. Used in cases where instances\r
- * running on same core connected by function call. */\r
+ /* Reconfigure existing transport's appTransportHandle. Used in cases\r
+ * where instances running on same core connected by function call. */\r
transport->appTransportHandle = reCfg->appTransportHandle;\r
\r
if (reCfg->transportCallouts.rmAllocPkt) {\r
@@ -334,16 +335,15 @@ int32_t Rm_transportReconfig (Rm_TransportHandle transportHandle, const Rm_Trans
if (reCfg->transportCallouts.rmSendPkt) {\r
transport->callouts.rmSendPkt = reCfg->transportCallouts.rmSendPkt;\r
}\r
- }\r
- else {\r
+ } else {\r
retVal = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;\r
- } \r
+ }\r
\r
if (rmInst->mtSemObj) {\r
Rm_osalMtCsExit(rmInst->mtSemObj, mtKey);\r
}\r
- RM_SS_INST_WB_EXIT_CS(rmInst, key); \r
- return (retVal);\r
+ RM_SS_INST_WB_EXIT_CS(rmInst, key);\r
+ return(retVal);\r
}\r
\r
/* FUNCTION PURPOSE: Unregisters an app transport from a RM instance\r
rmInst->registeredWithDelegateOrServer = RM_FALSE;\r
}\r
transportDelete(transport);\r
- }\r
- else {\r
+ } else {\r
retVal = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;\r
}\r
- return (retVal);\r
+ return(retVal);\r
}\r
\r
/* FUNCTION PURPOSE: Returns a RM packet's service source instance name\r
* DESCRIPTION: Returns the RM instance name from which the service\r
* encapsulated in the RM packet originated.\r
*/\r
-int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt, char *serviceInstName, \r
- int32_t charBufLen)\r
+int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt,\r
+ char *serviceInstName,\r
+ int32_t charBufLen)\r
{\r
return(getPktSrcNames(pkt, NULL, serviceInstName, charBufLen));\r
}\r
@@ -387,8 +387,8 @@ int32_t Rm_receiveGetPktServiceSrcName(const Rm_Packet *pkt, char *serviceInstNa
* DESCRIPTION: Returns the RM instance name from which the RM packet\r
* originated.\r
*/\r
-int32_t Rm_receiveGetPktSrcName(const Rm_Packet *pkt, char *pktInstName, \r
- int32_t charBufLen)\r
+int32_t Rm_receiveGetPktSrcName(const Rm_Packet *pkt, char *pktInstName,\r
+ int32_t charBufLen)\r
{\r
return(getPktSrcNames(pkt, pktInstName, NULL, charBufLen));\r
}\r
* invoking application will free packet after this\r
* function returns.\r
*/\r
-int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pkt)\r
+int32_t Rm_receivePacket(Rm_TransportHandle transportHandle,\r
+ const Rm_Packet *pkt)\r
{\r\r\r
Rm_Transport *transport = (Rm_Transport *)transportHandle;\r
Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle;\r
@@ -421,36 +422,40 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
transaction = rmTransactionQueueAdd(rmInst);\r
transaction->remoteOriginatingId = resourceReqPkt->requestId;\r
transaction->u.respTrans = transport;\r
- if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_INIT) {\r
+ if (resourceReqPkt->resourceReqType ==\r
+ Rm_resReqPktType_ALLOCATE_INIT) {\r
transaction->type = Rm_service_RESOURCE_ALLOCATE_INIT;\r
- }\r
- else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_USE) {\r
+ } else if (resourceReqPkt->resourceReqType ==\r
+ Rm_resReqPktType_ALLOCATE_USE) {\r
transaction->type = Rm_service_RESOURCE_ALLOCATE_USE;\r
- }\r
- else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_STATUS) {\r
+ } else if (resourceReqPkt->resourceReqType ==\r
+ Rm_resReqPktType_GET_STATUS) {\r
transaction->type = Rm_service_RESOURCE_STATUS;\r
- }\r
- else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_FREE) {\r
+ } else if (resourceReqPkt->resourceReqType ==\r
+ Rm_resReqPktType_FREE) {\r
transaction->type = Rm_service_RESOURCE_FREE;\r
- }\r
- else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_NAMED) {\r
+ } else if (resourceReqPkt->resourceReqType ==\r
+ Rm_resReqPktType_GET_NAMED) {\r
transaction->type = Rm_service_RESOURCE_GET_BY_NAME;\r
- } \r
- rm_strncpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+ }\r
+ rm_strncpy(transaction->serviceSrcInstName,\r
+ resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
transaction->state = RM_SERVICE_PROCESSING;\r
- memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo));\r
+ memcpy((void *)&(transaction->resourceInfo),\r
+ (void *)&(resourceReqPkt->resourceInfo),\r
+ sizeof(Rm_ResourceInfo));\r
break;\r
}\r
case Rm_pktType_RESOURCE_RESPONSE:\r
{\r
Rm_ResourceResponsePkt *resourceRespPkt = (Rm_ResourceResponsePkt *)pkt->data;\r
\r
- if ((transaction = rmTransactionQueueFind(rmInst,resourceRespPkt->responseId))) {\r
+ if ((transaction = rmTransactionQueueFind(rmInst,\r
+ 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
+ /* Lock the RM instance since service validated against\r
+ * static policy failed against Server's global policy */\r
rmInst->isLocked = RM_TRUE;\r
}\r
transaction->state = resourceRespPkt->requestState;\r
@@ -460,16 +465,15 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
(transaction->type == Rm_service_RESOURCE_STATUS) ||\r
(transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {\r
- memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo));\r
- }\r
- else {\r
+ memcpy((void *)&(transaction->resourceInfo),\r
+ (void *)&(resourceRespPkt->resourceInfo),\r
+ sizeof(Rm_ResourceInfo));\r
+ } else {\r
/* Always copy owner count and instance allocation count */\r
transaction->resourceInfo.ownerCount = resourceRespPkt->resourceInfo.ownerCount;\r
transaction->resourceInfo.instAllocCount = resourceRespPkt->resourceInfo.instAllocCount;\r
}\r
- }\r
- else {\r
+ } else {\r
retVal = RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ;\r
goto errorExit;\r
}\r
@@ -485,31 +489,33 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
\r
if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_MAP_RESOURCE) {\r
transaction->type = Rm_service_RESOURCE_MAP_TO_NAME;\r
- }\r
- else if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_UNMAP_RESOURCE) {\r
+ } else if (nsRequestPkt->nsRequestType ==\r
+ Rm_nsReqPktType_UNMAP_RESOURCE) {\r
transaction->type = Rm_service_RESOURCE_UNMAP_NAME;\r
}\r
\r
- rm_strncpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+ rm_strncpy(transaction->serviceSrcInstName,\r
+ nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
transaction->state = RM_SERVICE_PROCESSING;\r
- memcpy ((void *)&(transaction->resourceInfo), (void *)&(nsRequestPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo)); \r
+ memcpy((void *)&(transaction->resourceInfo),\r
+ (void *)&(nsRequestPkt->resourceInfo),\r
+ sizeof(Rm_ResourceInfo));\r
break;\r
}\r
case Rm_pktType_NAMESERVER_RESPONSE:\r
{\r
Rm_NsResponsePkt *nsResponsePkt = (Rm_NsResponsePkt *)pkt->data;\r
\r
- if ((transaction = rmTransactionQueueFind(rmInst, nsResponsePkt->responseId))) {\r
+ if ((transaction = rmTransactionQueueFind(rmInst,\r
+ 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
+ /* Lock the RM instance since service validated against\r
+ * static policy failed against Server's global policy */\r
rmInst->isLocked = RM_TRUE;\r
}\r
transaction->state = nsResponsePkt->requestState;\r
- }\r
- else {\r
+ } else {\r
retVal = RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ;\r
goto errorExit;\r
}\r
@@ -521,7 +527,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
}\r
\r
/* Process received transaction */\r
- rmProcessRouter(rmInst, transaction); \r
+ rmProcessRouter(rmInst, transaction);\r
errorExit:\r
return(retVal);\r
}\r