summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a81f202)
raw | patch | inline | side by side (parent: a81f202)
author | Justin Sobota <jsobota@ti.com> | |
Mon, 19 Nov 2012 23:27:54 +0000 (18:27 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Mon, 19 Nov 2012 23:27:54 +0000 (18:27 -0500) |
diff --git a/include/rm_loc.h b/include/rm_loc.h
index ea6828f0ef9517da3ffbcbb07022b773b366b584..1ad8ce1fc5152e1beac5f7355e1a47fcdd5c2ce7 100644 (file)
--- a/include/rm_loc.h
+++ b/include/rm_loc.h
char sourceInstName[RM_INSTANCE_NAME_MAX_CHARS];
/** Transaction's associated callback function */
Rm_ServiceCallback callback;
- /** Transaction state */
- Rm_TransactionState state;
- /** Transaction result. The codes are externally visible and tracked
+ /** Transaction state. The codes are externally visible and tracked
* in rmservices.h */
- int32_t result;
+ int32_t state;
/** Resource information */
Rm_ResourceInfo resourceInfo;
/** Link to the next transaction in the queue */
Rm_TransportCallouts transport;
} Rm_Inst;
-Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst, uint32_t transactionId);
+Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst);
Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst);
-void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction,
- Rm_TransactionReceipt *receipt);
-
+void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
#ifdef __cplusplus
}
index 819e9e54cad7d4cf806c460b8d98dc42ff046678..2fe9382ed0759c784d93b4d8d10ac6510aff605c 100644 (file)
/* RM internal includes */
#include <ti/drv/rm/include/rm_loc.h>
-void Rm_nsAddObject(Rm_Inst *rmInst, Rm_Transaction *transaction,
- Rm_TransactionReceipt *receipt);
-void Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_Transaction *transaction,
- Rm_TransactionReceipt *receipt);
+void Rm_nsAddObject(Rm_Inst *rmInst, Rm_Transaction *transaction);
+void Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_Transaction *transaction);
#ifdef __cplusplus
}
index 1241420f062a0d11d6b2a8ac682256ca578dbb00..f1317ae75367e400a62a35a9eb0ba96690227cd5 100644 (file)
--- a/include/rm_servicesloc.h
+++ b/include/rm_servicesloc.h
/* This function is executed when a RM instance receives a response to one of its requests
* and the information in the request must be provided to the original requesting component */
-void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *responseTransaction,
- Rm_Transaction *requestTransaction);
+void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
#ifdef __cplusplus
index b3a7209fbb231c6180378636e9d12f770f559f58..6c3899b4aa8f334668b4716a287c25521b30d0dc 100644 (file)
* packet. This ID should be associated with a transaction stored in
* the RM instance that sent the resource request packet */
uint32_t responseId;
- /** Result of the request. Resource request, denied, or error. The
+ /** State of the request. Resource request, denied, or error. The
* return values are externally visible so they're tracked in rmservice.h */
- int32_t requestResult;
+ int32_t requestState;
/* Resource response information */
Rm_ResourceInfo resourceInfo;
} Rm_ResourceResponsePkt;
* packet. This ID should be associated with a transaction stored in
* the RM instance that sent the resource request packet */
uint32_t responseId;
- /** Result of the request. Resource request, denied, or error. The
+ /** State of the request. Resource request, denied, or error. The
* return values are externally visible so they're tracked in rmservice.h */
- int32_t requestResult;
+ int32_t requestState;
} Rm_NsResponsePkt;
/**
Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst,
Rm_TransportHandle transportHandle);
Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt);
+ Rm_Transaction *transaction);
Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt);
+ Rm_Transaction *transaction);
Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt);
+ Rm_Transaction *transaction);
Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt);
+ Rm_Transaction *transaction);
#ifdef __cplusplus
}
diff --git a/src/rm.c b/src/rm.c
index a6dd50165de91d782c5a222f4898bb2ff08f961c..9484c8cb0e7ed73eca826f81dbb068160e25c91d 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
**********************************************************************/\r
\r
/* At the very least the transaction ID needs to be provided to create a transaction */\r
-Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst, uint32_t transactionId)\r
+Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst)\r
{\r
Rm_Transaction *transactionQueue = (Rm_Transaction *)rmInst->transactionQueue;\r
Rm_Transaction *newTransaction = NULL;\r
/* Clear the transaction */\r
memset((void *)newTransaction, 0, sizeof(Rm_Transaction));\r
\r
- /* Set the transaction's local ID */\r
- newTransaction->localId = transactionId;\r
+ /* Create an ID for the new transaction. The ID will be used for two purposes:\r
+ * 1) Matching responses from higher level RM agents to requests\r
+ * 2) Provided to the component that requested the service so that it can match its\r
+ * request with the response it receives via its callback function it provided */\r
+ newTransaction->localId = Rm_transactionGetSequenceNum(rmInst);\r
/* New transaction's nextTransaction pointer will always be NULL */\r
newTransaction->nextTransaction = NULL; \r
\r
receipt->serviceId = transaction->id;\r
}\r
\r
-void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction, \r
- Rm_TransactionReceipt *receipt)\r
+void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
Rm_Transaction *queuedTransaction = NULL;\r
\r
diff --git a/src/rm_services.c b/src/rm_services.c
index d42769cc9eb9c7e686a7ee9d811cdbdbfd8e53f8..edfdd5a8e7b686bf479c44184fa0980dbfbe63f2 100644 (file)
--- a/src/rm_services.c
+++ b/src/rm_services.c
Rm_ServiceRespInfo *serviceResponse)
{
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
- uint32_t transactionId = 0;
Rm_Transaction *transaction;
void *key;
if ((serviceRequest->type < Rm_service_FIRST) ||
(serviceRequest->type > Rm_service_LAST))
{
- serviceResponse->serviceResult = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;
+ serviceResponse->serviceState = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;
Rm_osalCsExit(key);
return;
}
* assumed the component's cannot block. Therefore, all responses must go
* through the callback function provided by the component. Return an error
* if the component does not provide a callback function. */
- serviceResponse->serviceResult = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
+ serviceResponse->serviceState = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
Rm_osalCsExit(key);
return;
}
-
- /* Create an ID for this transaction. The ID will be used for two purposes:
- * 1) Matching responses from higher level RM agents to requests
- * 2) Provided to the component that requested the service so that it can match its
- * request with the response it receives via its callback function it provided */
- transactionId = Rm_transactionGetSequenceNum(rmInst);
+
/* Create a new transaction */
- transaction = Rm_transactionQueueAdd(rmInst, transactionId);
+ transaction = Rm_transactionQueueAdd(rmInst);
if (transaction == NULL)
{
/* Failed to create a new transaction */
- serviceResponse->serviceResult = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;
+ serviceResponse->serviceState = RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE;
}
else
{
transaction->type = serviceRequest->type;
strcpy(transaction->sourceInstName, rmInst->name);
transaction->callback.serviceCallback = serviceRequest->callback.serviceCallback;
- transaction->state = Rm_transactionState_PROCESSING;
+ transaction->state = RM_SERVICE_PROCESSING;
strcpy(&(transaction->resourceInfo.name)[0], serviceRequest->resourceName);
transaction->resourceInfo.base = serviceRequest->resourceBase;
transaction->resourceInfo.range = serviceRequest->resourceRange;
Rm_transactionProcessor (rmInst, transaction);
/* Provide response to the component that requested the service */
- if (transaction->state == Rm_transactionState_PROCESSING)
+ serviceResponse->serviceState = transaction->state;
+ if (serviceResponse->serviceState == RM_SERVICE_PROCESSING)
{
/* The service is still being processed. Provide the transaction ID
* back to the component so that it can sort service responses received
* via the provided callback function */
- serviceResponse->serviceResult == RM_SERVICE_PROCESSING;
- serviceResponse->requestId = transaction->localId;
+ serviceResponse->serviceId = transaction->localId;
}
- else if (transaction->state == Rm_transactionState_TRANSACTION_APPROVED)
+ else if (serviceResponse->serviceState == RM_SERVICE_APPROVED)
{
- serviceResponse->serviceResult = RM_SERVICE_APPROVED;
/* Service was approved and service was an allocate request the resource
* data is passed back to the component */
if ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||
/* Delete the transaction since a response was received immediately */
Rm_transactionQueueDelete(rmInst, transaction->id);
}
- else if (transaction->state == Rm_transactionState_TRANSACTION_DENIED)
+ else if ((serviceResponse->serviceState >= RM_SERVICE_DENIED_BEGIN) &&
+ (serviceResponse->serviceState <= RM_SERVICE_DENIED_END))
{
- /* Transaction result field will contain a vlaue specifying why resource was
- * denied */
- serviceResponse->serviceResult = transaction->result;
- /* Delete the transaction since a response was received immediately */
+ /* The serviceState field will contain information regarding why the
+ * service was denied. Just delete the transaction since a response was
+ * received immediately */
Rm_transactionQueueDelete(rmInst, transaction->id);
}
}
/* This function is executed when a RM instance receives a response to one of its requests
* and the information in the request must be provided to the original requesting component */
-void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *responseTransaction,
- Rm_Transaction *requestTransaction)
+void Rm_serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_ServiceRespInfo serviceResponse;
-
- /* CODING HERE */
-
- /* Populate the service response with the transaction response details
- * for the component */
- serviceResponse.serviceResult = responseTransaction->result;
+ /* The responseTransaction will contain the resultant state details of
+ * the requestTransaction's service request */
+ serviceResponse.serviceState = transaction->state;
/* Pass back the ID that was provided to the component when it requested
* the service */
- serviceResponse.requestId = responseTransaction->id;
+ serviceResponse.serviceId = transaction->localId;
/* Service was approved and service was an allocate request. The resource
* data is passed back to the component */
- if ((serviceResponse.serviceResult == RM_SERVICE_APPROVED) &&
- ((responseTransaction->type == Rm_service_RESOURCE_ALLOCATE) ||
- (responseTransaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||
- (responseTransaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME)))
+ if ((serviceResponse.serviceState == RM_SERVICE_APPROVED) &&
+ ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||
+ (transaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME)))
{
- serviceResponse.resourceBase = responseTransaction->resourceInfo.base;
- serviceResponse.resourceRange = responseTransaction->resourceInfo.range;
+ serviceResponse.resourceBase = transaction->resourceInfo.base;
+ serviceResponse.resourceRange = transaction->resourceInfo.range;
}
/* Issue the callback to the requesting component with the response information */
- if (requestTransaction != NULL)
- {
- /* The requestTransaction will be NULL if the request transaction is handled
- * by the same RM instance it was created on. Typically this applies to RM
- * Client Delegate and RM Server instances. In these cases the response
- * transaction will be a copy of the request transaction, meaning it will contain
- * the proper callback information */
- requestTransaction->callback.serviceCallback(&serviceResponse);
- }
- else
- {
- responseTransaction->callback.serviceCallback(&serviceResponse);
- }
-
- /* Delete both transactions from the transaction queue */
- Rm_transactionQueueDelete(rmInst,responseTransaction->id);
- if (requestTransaction != NULL)
- {
- Rm_transactionQueueDelete(rmInst,requestTransaction->id);
- }
+ transaction->callback.serviceCallback(&serviceResponse);
- /* Response to component completed */
- receipt->serviceResult = RM_SERVICE_ACTION_OKAY;
+ /* Delete the transaction from the transaction queue */
+ Rm_transactionQueueDelete(rmInst, transaction->localId);
return;
}
diff --git a/src/rm_transport.c b/src/rm_transport.c
index 0d3908a59af32dfdf0019feb0b363031a097b39e..4a2b5cb243e6d0b8d51977301b59b5576d6d6c7c 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
{\r\r\r
Rm_Inst *rmInst = (Rm_Inst *)((Rm_TransportNode *)transportHandle)->rmHandle;\r
Rm_Transaction *transaction;\r
- Rm_TransactionReceipt receipt;\r
\r
/* Make sure the transport handle is registered with the provided RM instance */\r
if (Rm_transportNodeFindTransportHandle(rmInst, transportHandle) == NULL)\r
return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
}\r
\r
- /* Clear the transaction receipt */\r
- memset((void *)&receipt, 0, sizeof(Rm_TransactionReceipt));\r
-\r
/* Based on packet type transfer the data to a transaction or a policy structure */\r
switch (pkt->pktType)\r
{\r
{\r
Rm_ResourceRequestPkt *resourceReqPkt = (Rm_ResourceRequestPkt *)pkt->data;\r
\r
- /* The transaction ID will be the request ID. The request ID\r
- * will become the response packet's ID so the requesting RM instance\r
- * can filter received resource responses */\r
- transaction = Rm_transactionQueueAdd(rmInst, resourceReqPkt->requestId);\r
+ /* Create the request transaction filling in the remoteOriginatingId using\r
+ * the request packet's ID. The request packet's ID will map to the \r
+ * the request transaction that issued the request packet. */\r
+ transaction = Rm_transactionQueueAdd(rmInst);\r
+ transaction->remoteOriginatingId = resourceReqPkt->requestId;\r
\r
/* Transfer the rest of the data into the transaction */\r
if (resourceReqPkt->resourceReqType == Rm_resReqPktType_ALLOCATE)\r
}\r
\r
strcpy(transaction->sourceInstName, resourceReqPkt->instName);\r
- transaction->state = Rm_transactionState_PROCESSING;\r
+ transaction->state = RM_SERVICE_PROCESSING;\r
memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
sizeof(Rm_ResourceInfo));\r
\r
/* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction, &receipt);\r
+ Rm_transactionProcessor(rmInst, transaction);\r
break;\r
}\r
case Rm_pktType_RESOURCE_RESPONSE:\r
{\r
Rm_ResourceResponsePkt *resourceRespPkt = (Rm_ResourceResponsePkt *)pkt->data;\r
\r
- /* If the packet is a response packet the transaction ID should match a queued \r
- * request transaction's ID */\r
- transaction = Rm_transactionQueueAdd(rmInst, resourceRespPkt->responseId);\r
+ /* Find the transaction that is awaiting the response */\r
+ transaction = Rm_transactionQueueFind(rmInst,resourceRespPkt->responseId);\r
+ /* Transfer the result of the request to the transaction */\r
+ transaction->state = resourceRespPkt->requestState;\r
\r
- if (resourceRespPkt->requestResult == RM_SERVICE_APPROVED)\r
+ if ((transaction->state == RM_SERVICE_APPROVED) &&\r
+ ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME)))\r
{\r
- transaction->state = Rm_transactionState_RESOURCE_APPROVED;\r
+ /* Copy resources from request for allocations since an allocation\r
+ * can be specified as unknown. Meaning the RM instance will specify the\r
+ * resource value obtained */\r
+ memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
+ sizeof(Rm_ResourceInfo));\r
}\r
- else if ((resourceRespPkt->requestResult >= RM_SERVICE_DENIED_BEGIN) &&\r
- (resourceRespPkt->requestResult <= RM_SERVICE_DENIED_END))\r
- {\r
- transaction->state = Rm_transactionState_RESOURCE_DENIED;\r
- } \r
- /* The result of the request should be placed in the details field of the \r
- * response transaction */\r
- transaction->details = resourceRespPkt->requestResult;\r
- memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo));\r
\r
/* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction, &receipt);\r
+ Rm_transactionProcessor(rmInst, transaction);\r
break;\r
}\r
case Rm_pktType_NAMESERVER_REQUEST:\r
{\r
Rm_NsRequestPkt *nsRequestPkt = (Rm_NsRequestPkt *)pkt->data;\r
\r
- transaction = Rm_transactionQueueAdd(rmInst, nsRequestPkt->requestId);\r
+ transaction = Rm_transactionQueueAdd(rmInst);\r
+ transaction->remoteOriginatingId = nsRequestPkt->requestId;\r
\r
if (nsRequestPkt->nsRequestType == Rm_nsReqPktType_MAP_RESOURCE)\r
{\r
sizeof(Rm_ResourceInfo));\r
\r
/* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction, &receipt); \r
+ Rm_transactionProcessor(rmInst, transaction); \r
break;\r
}\r
case Rm_pktType_NAMESERVER_RESPONSE:\r
{\r
Rm_NsResponsePkt *nsResponsePkt = (Rm_NsResponsePkt *)pkt->data;\r
\r
- transaction = Rm_transactionQueueAdd(rmInst, nsResponsePkt->responseId);\r
- transaction->details = nsResponsePkt->requestResult;\r
-\r
- if (nsResponsePkt->requestResult == RM_SERVICE_APPROVED)\r
- {\r
- transaction->state = Rm_transactionState_RESOURCE_APPROVED;\r
- }\r
- else if ((nsResponsePkt->requestResult >= RM_SERVICE_DENIED_BEGIN) &&\r
- (nsResponsePkt->requestResult <= RM_SERVICE_DENIED_END))\r
- {\r
- transaction->state = Rm_transactionState_RESOURCE_DENIED;\r
- }\r
+ /* Find the transaction that is awaiting the response */\r
+ transaction = Rm_transactionQueueFind(rmInst, nsResponsePkt->responseId);\r
+ /* Transfer the state of the request to the transaction */\r
+ transaction->state = nsResponsePkt->requestState; \r
\r
/* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction, &receipt);\r
+ Rm_transactionProcessor(rmInst, transaction);\r
break;\r
}\r
case Rm_pktType_POLICY_REQUEST:\r
\r
/* Free the packet after it has been processed */\r
rmInst->transport.rmFreePkt(transportHandle, pkt);\r
-\r
- /* Return the receipt's service result which contains the result return code\r
- * for the receive packet */\r
- return (receipt.serviceResult);\r
+ return (RM_TRANSPORT_SUCCESSFUL);\r
}\r
\r
/* Application can call this API so that RM handles reception of packets based on\r
{\r
Rm_Inst *rmInst = (Rm_Inst *)((Rm_TransportNode *)transportHandle)->rmHandle;\r
Rm_Packet *pkt = NULL;\r
- int32_t retVal = RM_SERVICE_ACTION_BASE;\r
+ int32_t retVal = RM_TRANSPORT_OK_BASE;\r
\r
/* Make sure the transport handle is registered with the provided RM instance */\r
if (Rm_transportNodeFindTransportHandle(rmInst, transportHandle) == NULL)\r