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;
}