summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f3bc81)
raw | patch | inline | side by side (parent: 2f3bc81)
author | Justin Sobota <jsobota@ti.com> | |
Mon, 22 Apr 2013 14:21:19 +0000 (10:21 -0400) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Mon, 22 Apr 2013 14:21:19 +0000 (10:21 -0400) |
index fad2f91c8cc8b9e7ef9e91a327ba7642e6336852..9298ff1d703e4930cdeb7a49ae6d6eb76e867c2e 100644 (file)
Rm_allocatorOp_ALLOCATE_INIT = 0,
/* Allocate use operation */
Rm_allocatorOp_ALLOCATE_USE,
+ /* Get resource status operation */
+ Rm_allocatorOp_GET_STATUS,
/* Free operation */
Rm_allocatorOp_FREE,
/* Preallocate to use based on Policy DTB information operation */
index af9b77f603ab46f0a5a9929d7df4b679e8554c0d..2106b259f665a6ac52f813a3263e096aa21f1d57 100644 (file)
Rm_resReqPktType_ALLOCATE_INIT = 0,
/* Resource allocate for use request */
Rm_resReqPktType_ALLOCATE_USE,
+ /* Resource status request */
+ Rm_resReqPktType_GET_STATUS,
/* Free resource */
Rm_resReqPktType_FREE,
/* Get name resource */
index b55332fdd576ed6c2c004865583d2f69138fe3cc..79af0bcfe9990802e38544e0e5ad8c92f48c9b80 100644 (file)
--- a/rm.h
+++ b/rm.h
* 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
* - Map resource to name - Map a specified resource to a NameServer name
* @param[in] rmServerHandle
* Server instance handle.
*
- * @param]in] printResources
+ * @param[in] printResources
* Non-zero - Resource ownership details will be printed for all
* tracked resources
* 0 - Resource ownership details will not be printed. Only
diff --git a/rm_services.h b/rm_services.h
index 6a09bc1d11450219074ecdd5a1c1d6b3d6351451..6c2ebd4557e3ef924d03febca75facad56cca590 100644 (file)
--- a/rm_services.h
+++ b/rm_services.h
Rm_service_RESOURCE_ALLOCATE_USE,
/** RM resource free service */
Rm_service_RESOURCE_FREE,
+ /** RM resource status service - returns the reference count for specified
+ * resource. */
+ Rm_service_RESOURCE_STATUS,
/** RM NameServer map resource to name service */
Rm_service_RESOURCE_MAP_TO_NAME,
/** RM NameServer get resource by name service */
* 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. The state can be an approval, denial, or error.
- * The latter codes start at #RM_OK, #RM_SERVICE_DENIED_BASE, and
- * #RM_ERROR_BASE, respectively. */
+ /** Service request state. State values can be found in rm.h starting
+ * 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
* responses received at a later time via the provided callback function
* Success - Rm_ServiceHandle and result = #RM_OK
* @retval
* Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED
- * @retval
- * Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_ALREADY_OPENED
*/
Rm_ServiceHandle *Rm_serviceOpenHandle(Rm_Handle rmHandle, int32_t *result);
diff --git a/src/rm.c b/src/rm.c
index 3afc89ed2908db1c4a0706c88d809501e9433843..4ee5361e33706bf7f817ee22334e95594a6402fa 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -122,7 +122,10 @@ void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction
}
else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
- }
+ }
+ else if (transaction->type == Rm_service_RESOURCE_STATUS) {
+ resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_STATUS;
+ }
else if (transaction->type == Rm_service_RESOURCE_FREE) {
resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
}
/* Pass back the ID that was provided to the component when it requested
* the service */
serviceResponse.serviceId = transaction->localId;
+ /* Owner count will only be set within RM under certain circumstances. Most of time
+ * it will be RM_RESOURCE_NUM_OWNERS_INVALID */
+ serviceResponse.resourceNumOwners = transaction->resourceInfo.ownerCount;
/* Service was approved and service was an allocate request. The resource
* data is passed back to the component */
if ((serviceResponse.serviceState == RM_SERVICE_APPROVED) &&
((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_GET_BY_NAME)))
{
strncpy(serviceResponse.resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
switch (transaction->type) {
case Rm_service_RESOURCE_ALLOCATE_INIT:
case Rm_service_RESOURCE_ALLOCATE_USE:
+ case Rm_service_RESOURCE_STATUS:
case Rm_service_RESOURCE_FREE:
case Rm_service_RESOURCE_GET_BY_NAME:
createResourceResponsePkt(rmPkt, transaction);
switch (transaction->type) {
case Rm_service_RESOURCE_ALLOCATE_INIT:
case Rm_service_RESOURCE_ALLOCATE_USE:
+ case Rm_service_RESOURCE_STATUS:
case Rm_service_RESOURCE_FREE:
case Rm_service_RESOURCE_GET_BY_NAME:
createResourceReqPkt(rmPkt, rmInst->instName, transaction);
@@ -406,6 +415,72 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
}
}
+/* FUNCTION PURPOSE: Handles resource status service requests
+ ***********************************************************************
+ * DESCRIPTION: Issues a set of allocator operations to retrieve the
+ * current status (currently just owner reference count)
+ * for the resource specified in the transaction
+ */
+static void statusHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+ Rm_AllocatorOpInfo opInfo;
+ Rm_NameServerObjCfg nameServerObjCfg;
+ int32_t retVal = transaction->state;
+
+ if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ /* Fill in status logic for CDs */
+ }
+ else if ((rmInst->instType == Rm_instType_SERVER)||
+ (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+ memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+
+ opInfo.policy = rmInst->u.server.globalPolicy;
+ opInfo.resourceInfo = &transaction->resourceInfo;
+ opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst, transaction->serviceSrcInstName);
+ if (opInfo.serviceSrcInstNode) {
+ /* Populated NameServer name has precedence over base and length values */
+ if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+ if ((transaction->resourceInfo.base == 0) &&
+ (transaction->resourceInfo.length == 0) &&
+ (transaction->resourceInfo.alignment == 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) {
+ strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+ transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+ }
+ else {
+ goto errorExit;
+ }
+ }
+ else {
+ retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+ goto errorExit;
+ }
+ }
+
+ if ((transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) ||
+ (transaction->resourceInfo.length == 0)) {
+ retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
+ goto errorExit;
+ }
+
+ opInfo.operation = Rm_allocatorOp_GET_STATUS;
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ }
+ else {
+ retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+ }
+errorExit:
+ transaction->state = retVal;
+ }
+}
+
/* FUNCTION PURPOSE: Arbitrates allocation service requests
***********************************************************************
* DESCRIPTION: Issues a set of allocator operations in order to
@@ -419,7 +494,6 @@ static void staticAllocationHandler (Rm_Handle rmHandle, Rm_Transaction *transac
static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_AllocatorOpInfo opInfo;
-
Rm_NameServerObjCfg nameServerObjCfg;
int32_t retVal = transaction->state;
strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
+ }
+ else {
+ goto errorExit;
+ }
}
else {
retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
+ }
+ else {
+ goto errorExit;
+ }
}
else {
retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+ goto errorExit;
}
}
-
- if(retVal == RM_SERVICE_PROCESSING) {
- opInfo.operation = Rm_allocatorOp_FREE;
- retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
- }
+
+ opInfo.operation = Rm_allocatorOp_FREE;
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
}
else {
retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
}
+errorExit:
transaction->state = retVal;
}
}
* Server is registered */
}
else {
- if ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||
- (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)) {
- if (transaction->state == RM_SERVICE_PROCESSING) {
- /* Forward all NameServer requests. */
- transactionForwarder(rmInst, transaction);
- }
- else {
- /* NameServer transaction validated. Return result. */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction did not originate on this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction originated on this instance */
- serviceResponder(rmInst, transaction);
- }
- }
- }
- else if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
+ if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
if ((transaction->state == RM_SERVICE_PROCESSING) ||
(transaction->state == RM_SERVICE_APPROVED_STATIC)) {
- transactionForwarder(rmInst, transaction);
- }
- else {
- /* Transaction validated. Return result. */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction did not originate on this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction originated on this instance */
- serviceResponder(rmInst, transaction);
- }
+ allocationHandler(rmInst, transaction);
}
}
+ 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) {
if (transaction->state == RM_SERVICE_PROCESSING) {
freeHandler(rmInst, transaction);
+ }
+ }
+ /* Forward all NameServer-based transactions */
- if (transaction->state == RM_SERVICE_PROCESSING) {
- /* CD could not handle free. Forward to Server */
- transactionForwarder(rmInst, transaction);
- }
- else {
- /* Free validated by CD. Return result */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction did not originate on this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction originated on this instance */
- serviceResponder(rmInst, transaction);
- }
- }
+ if (transaction->state == RM_SERVICE_PROCESSING) {
+ /* CD could not complete transaction. Forward to Server */
+ transactionForwarder(rmInst, transaction);
+ }
+ else {
+ /* 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 {
- /* Transaction validated. Return result. */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction did not originate on this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction originated on this instance */
- serviceResponder(rmInst, transaction);
- }
- }
- }
+ /* Transaction originated on this instance */
+ serviceResponder(rmInst, transaction);
+ }
+ }
/* Attempt allocation of any queued static requests:
* RM_SERVICE_APPROVED_STATIC - Originated locally
Rm_NameServerObjCfg nameServerObjCfg;
switch (transaction->type) {
+ case Rm_service_RESOURCE_STATUS:
+ statusHandler(rmInst, transaction);
+ break;
case Rm_service_RESOURCE_ALLOCATE_INIT:
case Rm_service_RESOURCE_ALLOCATE_USE:
allocationHandler(rmInst, transaction);
diff --git a/src/rm_allocator.c b/src/rm_allocator.c
index 23ce8afec41bc8b6c96dd755b6f1b40abfce77fb..0795db7fbfd76573d4ecf8b4a324832c2ec284f2 100644 (file)
--- a/src/rm_allocator.c
+++ b/src/rm_allocator.c
@@ -401,6 +401,36 @@ static int allocatorResNodeIsOwnedBy(Rm_Handle rmHandle, Rm_ResourceNode *node,
return(RM_FALSE);
}
+/* FUNCTION PURPOSE: Get the status for an allocator resource
+ ***********************************************************************
+ * DESCRIPTION: Called when a resource status request is made. The
+ * resource's allocator is searched for the resource base
+ * and length specified in the transaction. The
+ * resource's owner reference count is returned if the
+ * resource range is found.
+ */
+static int32_t allocatorStatus(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
+{
+ Rm_ResourceNode findNode;
+ Rm_ResourceNode *matchingNode = NULL;
+ int32_t retVal;
+
+ memset((void *)&findNode, 0, sizeof(findNode));
+ findNode.base = opInfo->resourceInfo->base;
+ findNode.length = opInfo->resourceInfo->length;
+ matchingNode = RB_FIND(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, &findNode);
+
+ if (matchingNode) {
+ opInfo->resourceInfo->ownerCount = matchingNode->allocationCount;
+ retVal = RM_SERVICE_APPROVED;
+ }
+ else {
+ retVal = RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST;
+ }
+
+ return(retVal);
+}
+
/* FUNCTION PURPOSE: Preallocates an allocator resource
***********************************************************************
* DESCRIPTION: Called when an allocate request is made but the base
if (rmInst->instType == Rm_instType_SHARED_SERVER) {
rmResourceTreeInv(allocator->allocatorRootEntry);
}
-
- if ((opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_INIT) ||
- (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_USE)) {
+
+ if (opInfo->operation == Rm_allocatorOp_GET_STATUS) {
+ retVal = allocatorStatus(allocator, opInfo);
+ }
+ else if ((opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_INIT) ||
+ (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE_USE)) {
retVal = allocatorPreAllocate(rmHandle, allocator, resourceOffsetInPolicy, opInfo);
}
else if ((opInfo->operation == Rm_allocatorOp_ALLOCATE_INIT) ||
}
if ((rmInst->instType == Rm_instType_SHARED_SERVER) &&
+ (opInfo->operation != Rm_allocatorOp_GET_STATUS) &&
(retVal == RM_SERVICE_APPROVED)) {
rmResourceTreeWb(allocator->allocatorRootEntry);
}
diff --git a/src/rm_transport.c b/src/rm_transport.c
index aba3c93d2e66f5273fd9d37646b681abccd18df2..18502da772d8850b6cbad3f4b4db4541588dfe54 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
@@ -325,7 +325,10 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
}\r
else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE_USE) {\r
transaction->type = Rm_service_RESOURCE_ALLOCATE_USE;\r
- } \r
+ }\r
+ else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_STATUS) {\r
+ transaction->type = Rm_service_RESOURCE_STATUS;\r
+ }\r
else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_FREE) {\r
transaction->type = Rm_service_RESOURCE_FREE;\r
}\r
@@ -355,6 +358,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
if ((transaction->state == RM_SERVICE_APPROVED) &&\r
((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||\r
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||\r
+ (transaction->type == Rm_service_RESOURCE_STATUS) ||\r
(transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {\r
memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
sizeof(Rm_ResourceInfo));\r
diff --git a/test/rm_mem_test.c b/test/rm_mem_test.c
index 782490094cbd2a7ca716c31a163d19f26de0a4bb..ee1d3da5525eaecde0b90321c0312012005f15d4 100644 (file)
--- a/test/rm_mem_test.c
+++ b/test/rm_mem_test.c
"Pre NS Map ", "Name Mapped to NS ", "Name Unmapped from NS");
+ /* Check status of resource directly and through NameServer name */
+ MEM_TEST_START_STORE();
+ setRmRequest(&request, Rm_service_RESOURCE_ALLOCATE_INIT, resNameGpQ,
+ 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Allocate failed");
+ setRmRequest(&request, Rm_service_RESOURCE_MAP_TO_NAME, resNameGpQ,
+ 900, 1, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "NameServer map failed");
+ setRmRequest(&request, Rm_service_RESOURCE_STATUS, resNameGpQ,
+ 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Status check failed");
+ setRmRequest(&request, Rm_service_RESOURCE_STATUS, resNameGpQ,
+ 0, 0, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Status check (via NS name) failed");
+ MEM_TEST_MID_STORE();
+ setRmRequest(&request, Rm_service_RESOURCE_UNMAP_NAME, NULL,
+ 0, 0, 0, nsNameFavQ, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "NameServer unmap failed");
+ setRmRequest(&request, Rm_service_RESOURCE_FREE, resNameGpQ,
+ 900, 50, 0, NULL, RM_TEST_FALSE, &response);
+ serviceHandle->Rm_serviceHandler(serviceHandle->rmHandle, &request, &response);
+ ERROR_CHECK(RM_SERVICE_APPROVED, response.serviceState, clientName, "Free failed");
+ MEM_TEST_END_PRINT("--------- Client Check Resource Status (via CD) ---------",
+ "Pre Alloc ", "Post Status Requests ", "Post Free ");
+
+
/* Cleanup */
rmResult = Rm_serviceCloseHandle(serviceHandle);
ERROR_CHECK(RM_OK, rmResult, clientName, "Service handle close failed");
diff --git a/test/rm_shared_test.c b/test/rm_shared_test.c
index 2645a7690954b9714d13c88934169c85a2704134..5f46c4e443c1c872512f435d00dbd6e1ead52d5b 100644 (file)
--- a/test/rm_shared_test.c
+++ b/test/rm_shared_test.c
********************** RM Shared Test Symbols ************************
**********************************************************************/
+#define PRINT_USED_RESOURCES 0 /* Make 1 and rebuild project to print resources allocated in example */
+
#define SYSINIT 0
#define NUM_CORES 2
System_printf ("\n"); \
} while(0);
+#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
+ do { \
+ int32_t start = resStart; \
+ char titleMsg[] = title; \
+ System_printf ("Core %d : ---------------------------------------------------------\n", \
+ core); \
+ System_printf ("Core %d : %s\n", core, titleMsg); \
+ System_printf ("Core %d : - Instance Name: %-32s -\n", core, instName); \
+ System_printf ("Core %d : - Resource Name: %-32s -\n", core, resName); \
+ System_printf ("Core %d : - Start: %-16d -\n", \
+ core, resStart); \
+ System_printf ("Core %d : - End: %-16d -\n", core, \
+ (start + resLen - 1)); \
+ System_printf ("Core %d : - Expected Owner Count: %-16d -\n", \
+ core, expectRefCnt); \
+ System_printf ("Core %d : - Returned Owner Count: %-16d -\n", \
+ core, refCnt); \
+ System_printf ("Core %d : - -\n", core); \
+ if ((state == check) && (refCnt == expectRefCnt)) { \
+ System_printf ("Core %d : - PASSED -\n", core); \
+ } \
+ else { \
+ if (refCnt != expectRefCnt) { \
+ System_printf ("Core %d : - FAILED - Owner Count Mismatch -\n", \
+ core); \
+ } \
+ else { \
+ System_printf ("Core %d : - FAILED - Denial: %-6d -\n", \
+ core, state); \
+ } \
+ testErrors++; \
+ } \
+ System_printf ("Core %d : ---------------------------------------------------------\n", \
+ core); \
+ System_printf ("\n"); \
+ } while(0);
+
/**********************************************************************
****************** RM Shared Test Data Structures ********************
**********************************************************************/
coreNum, rmServerName, resourceNameInfraQ,
805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
+ /* Get the status of a resource from Server */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh,
+ 53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------",
+ coreNum, rmServerName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+
+ /* Get the status of a resource from Server */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster,
+ 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------",
+ coreNum, rmServerName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
+
+#if PRINT_USED_RESOURCES
+ Rm_resourceStatus(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
+#endif
+
/* Signal to ClientTsk that Server is ready for cleanup */
GateMP_leave(serverGate, serverKey);
/* BEGIN Allocating some resources without providing a callback function. RM should block and not return until the result
* is returned by the server. */
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
- 7000, 1, 0, NULL, FALSE, &responseInfo);
+ 7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmSharedClient2Name, resourceNameGpQ,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
- 7005, 25, 0, NULL, FALSE, &responseInfo);
+ 7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmSharedClient1Name, resourceNameGpQ,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
- 7010, 5, 0, NULL, FALSE, &responseInfo);
+ 7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmSharedClient2Name, resourceNameGpQ,
/* Init allocation of resource already owned by Client should return approved and there should only
* be one instance of Client in resource's owner list. */
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
- 7011, 1, 0, NULL, FALSE, &responseInfo);
+ 7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----",
coreNum, rmSharedClient2Name, resourceNameGpQ,
requestInfo.resourceBase, requestInfo.resourceLength,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
- /* END Allocating some resources without providing a callback function. RM should block and not return until the result
- * is returned by the server. */
+ /* END Allocating some resources without providing a callback function. RM should block and not return
+ * until the result is returned by the server. */
+
+ /* BEGIN Getting the status of resources from the Shared Clients */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
+ 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------",
+ coreNum, rmSharedClient2Name, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
+ 4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);
+ rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------",
+ coreNum, rmSharedClient1Name, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
+ /* END Getting the status of resources from Client and CD */
GateMP_leave(clientGate, clientKey);
GateMP_leave(serverGate, serverKey);
diff --git a/test/rm_test.c b/test/rm_test.c
index e66c5c45a3545ee75ed94c7af48f926a0b19f7c9..b28417dc402db0aa060f3526819eb0a39484ca37 100644 (file)
--- a/test/rm_test.c
+++ b/test/rm_test.c
************************** RM Test Symbols ***************************
**********************************************************************/
+#define PRINT_USED_RESOURCES 0 /* Make 1 and rebuild project to print resources allocated in example */
+
#define SYSINIT 0
#define NUM_CORES 2
System_printf ("\n"); \
} while(0);
+#define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
+ do { \
+ int32_t start = resStart; \
+ char titleMsg[] = title; \
+ System_printf ("Core %d : ---------------------------------------------------------\n", \
+ core); \
+ System_printf ("Core %d : %s\n", core, titleMsg); \
+ System_printf ("Core %d : - Instance Name: %-32s -\n", core, instName); \
+ System_printf ("Core %d : - Resource Name: %-32s -\n", core, resName); \
+ System_printf ("Core %d : - Start: %-16d -\n", \
+ core, resStart); \
+ System_printf ("Core %d : - End: %-16d -\n", core, \
+ (start + resLen - 1)); \
+ System_printf ("Core %d : - Expected Owner Count: %-16d -\n", \
+ core, expectRefCnt); \
+ System_printf ("Core %d : - Returned Owner Count: %-16d -\n", \
+ core, refCnt); \
+ System_printf ("Core %d : - -\n", core); \
+ if ((state == check) && (refCnt == expectRefCnt)) { \
+ System_printf ("Core %d : - PASSED -\n", core); \
+ } \
+ else { \
+ if (refCnt != expectRefCnt) { \
+ System_printf ("Core %d : - FAILED - Owner Count Mismatch -\n", \
+ core); \
+ } \
+ else { \
+ System_printf ("Core %d : - FAILED - Denial: %-6d -\n", \
+ core, state); \
+ } \
+ testErrors++; \
+ } \
+ System_printf ("Core %d : ---------------------------------------------------------\n", \
+ core); \
+ System_printf ("\n"); \
+ } while(0);
+
/**********************************************************************
********************** RM Test Data Structures ***********************
**********************************************************************/
coreNum, rmServerName, resourceNameInfraQ,
805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);
+ /* Get the status of a resource from Server */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh,
+ 53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------",
+ coreNum, rmServerName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+
+ /* Get the status of a resource from Server */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster,
+ 1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------",
+ coreNum, rmServerName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
+
+#if PRINT_USED_RESOURCES
+ Rm_resourceStatus(rmServerHandle, RM_TEST_TRUE);
+#endif
+
/* Signal to ClientTsk that Server is ready for cleanup */
GateMP_leave(serverGate, serverKey);
requestInfo.resourceBase, requestInfo.resourceLength,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
+ /* Retrieve the resource status via the NameServer name */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL,
+ 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+ waitForResponse(&responseInfo);
+ }
+ STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----",
+ coreNum, rmClientName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
+
/* Free resource via a NameServer name */
setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL,
0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
/* BEGIN Allocating some resources without providing a callback function. RM should block and not return until the result
* is returned by the server. */
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
- 7000, 1, 0, NULL, FALSE, &responseInfo);
+ 7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmClientName, resourceNameGpQ,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
- 7005, 25, 0, NULL, FALSE, &responseInfo);
+ 7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmCdName, resourceNameGpQ,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
- 7010, 5, 0, NULL, FALSE, &responseInfo);
+ 7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --",
coreNum, rmClientName, resourceNameGpQ,
/* Init allocation of resource already owned by Client should return approved and there should only
* be one instance of Client in resource's owner list. */
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
- 7011, 1, 0, NULL, FALSE, &responseInfo);
+ 7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);
rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----",
coreNum, rmClientName, resourceNameGpQ,
requestInfo.resourceBase, requestInfo.resourceLength,
requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
/* END Allocating some resources without providing a callback function. RM should block and not return
- * until the result is returned by the server. */
+ * until the result is returned by the server. */
+
+ /* BEGIN Getting the status of resources from Client and CD */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
+ 7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+ waitForResponse(&responseInfo);
+ }
+ STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -",
+ coreNum, rmClientName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ,
+ 4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);
+ rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---",
+ coreNum, rmClientName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ,
+ 800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ if (responseInfo.serviceState == RM_SERVICE_PROCESSING) {
+ waitForResponse(&responseInfo);
+ }
+ STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---",
+ coreNum, rmCdName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ,
+ 805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);
+ rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----",
+ coreNum, rmCdName, responseInfo.resourceName,
+ responseInfo.resourceBase, responseInfo.resourceLength,
+ responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);
+ /* END Getting the status of resources from Client and CD */
/* Verify static allocations were validated. Validation responses should have been received after the
* first service requests were made on the Client and CD post transport path registration. */
ERROR_CHECK(RM_OK, result, rmCdName, "Service handle open failed");
/* Create the RM Client instance */
- rmInitCfg.instName = &rmClientName[0];
+ rmInitCfg.instName = rmClientName;
rmInitCfg.instType = Rm_instType_CLIENT;
rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)rmStaticPolicy;
rmClientHandle = Rm_init(&rmInitCfg, &result);