From: Justin Sobota Date: Wed, 30 Jan 2013 20:59:02 +0000 (-0500) Subject: Cleaned up transport API X-Git-Tag: DEV.RM_LLD.02.00.00.01~10^2~9 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Frm-lld.git;a=commitdiff_plain;h=7fd8dbaea7adc93d57810033855d576082f146a2 Cleaned up transport API --- diff --git a/include/rm_loc.h b/include/rm_loc.h index 9e7832b..c4e3641 100644 --- a/include/rm_loc.h +++ b/include/rm_loc.h @@ -157,7 +157,7 @@ typedef struct { void *transports; uint32_t transactionSeqNum; Rm_Transaction *transactionQueue; - Rm_TransportCallouts transport; + Rm_TransportCallouts transportCallouts; } Rm_Inst; Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst); diff --git a/include/rm_transportloc.h b/include/rm_transportloc.h index a9456a6..8c7f19f 100644 --- a/include/rm_transportloc.h +++ b/include/rm_transportloc.h @@ -46,10 +46,30 @@ extern "C" { /* RM external includes */ #include +#include /* RM internal includes */ #include +/* 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 */ +#define RM_COMPILE_TIME_SIZE_CHECK(postulate) \ + do { \ + typedef struct { \ + uint8_t NegativeSizeIfPostulateFalse[((int)(postulate))*2 - 1];\ + } PostulateCheck_t; \ + } \ + while (0) + +/* 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)); \ + /** * @brief RM transport routing map linked list node. The created * transport nodes are provided to the application casted @@ -57,11 +77,13 @@ extern "C" { */ typedef struct Rm_Transport_s { /** The RM instance that this node belongs to */ - Rm_Handle rmHandle; + Rm_Handle rmHandle; + /** The application transport handle */ + Rm_AppTransportHandle appTransportHandle; /** The remote RM instance type */ - Rm_InstType remoteInstType; + Rm_InstType remoteInstType; /** The remote RM instance name */ - char remoteInstName[RM_NAME_MAX_CHARS]; + char remoteInstName[RM_NAME_MAX_CHARS]; /** Link to the next route node in the route map list */ struct Rm_Transport_s *nextTransport; } Rm_Transport; @@ -129,7 +151,7 @@ typedef enum { /** Request to map the specified name to the specified resources */ Rm_nsReqPktType_MAP_RESOURCE = 0, /** Request to unmap the specified name from the specifed resources */ - Rm_nsReqPktType_UNMAP_RESOURCE = 1 + Rm_nsReqPktType_UNMAP_RESOURCE } Rm_NsReqPktType; /** @@ -167,14 +189,14 @@ typedef struct { Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName); Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType); -Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode, - Rm_Transaction *transaction); -Rm_Packet *rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode, +Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, Rm_Transaction *transaction); -Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode, - Rm_Transaction *transaction); -Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransportNode, - Rm_Transaction *transaction); +Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction); +Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction); +Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction); #ifdef __cplusplus } diff --git a/include/rm_treeloc.h b/include/rm_treeloc.h index 080408f..a8e4c61 100644 --- a/include/rm_treeloc.h +++ b/include/rm_treeloc.h @@ -103,25 +103,25 @@ typedef RB_HEAD(_Rm_AllocatorResourceTree, _Rm_ResourceNode) Rm_ResourceTree; ****************** Tree Node Function Definitions ******************** **********************************************************************/ -Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg); -void nameServerNodeFree(Rm_NameServerNode *node); -int nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); +Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg); +void rmNameServerNodeFree(Rm_NameServerNode *node); +int rmNameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); -Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName); -void policyValidInstNodeFree(Rm_PolicyValidInstNode *node); -int policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); +Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName); +void rmPolicyValidInstNodeFree(Rm_PolicyValidInstNode *node); +int rmPolicyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2); -Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength); -void resourceNodeFree(Rm_ResourceNode *node); -int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2); +Rm_ResourceNode *rmResourceNodeNew(uint32_t resourceBase, uint32_t resourceLength); +void rmResourceNodeFree(Rm_ResourceNode *node); +int rmResourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2); /********************************************************************** ******************** Tree Prototype Generation *********************** **********************************************************************/ -RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, nameServerNodeCompare) -RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, policyValidInstNodeCompare) -RB_PROTOTYPE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, resourceNodeCompare) +RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, rmNameServerNodeCompare) +RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, rmPolicyValidInstNodeCompare) +RB_PROTOTYPE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, rmResourceNodeCompare) #ifdef __cplusplus } diff --git a/rm.h b/rm.h index a414acb..e5e0ebe 100644 --- a/rm.h +++ b/rm.h @@ -192,9 +192,6 @@ extern "C" { #define RM_SERVICE_ERROR_TRANSPORT_PKT_ALLOC_API_NULL (RM_SERVICE_ERROR_BASE-4) /** A failure occurred within a registered transport's packet alloc API */ #define RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR (RM_SERVICE_ERROR_BASE-5) -/** RM service request needs to be forwarded but the buffer allocated by transport - * is not large enough to fit the RM transport packet */ -#define RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL (RM_SERVICE_ERROR_BASE-6) /** RM service request needs to be forwarded but the transport returned an error * when trying to send the RM packet to the higher level agent */ #define RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR (RM_SERVICE_ERROR_BASE-7) @@ -234,6 +231,12 @@ extern "C" { #define RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-5) /** RM NameServer request transaction could not be found matching the response received */ #define RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-6) +/** RM server cannot connect to other servers and CDs cannot connect to other CDs */ +#define RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE (RM_TRANSPORT_ERROR_BASE-7) +/** RM clients can't register with more than one Server or CD. CDs can't register with more than one Server */ +#define RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD (RM_TRANSPORT_ERROR_BASE-8) +/** Transport callouts provided to RM were specified as valid but NULL was provided */ +#define RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED (RM_TRANSPORT_ERROR_BASE-10) /** * @brief Maximum number of characters allowed for RM instance, resource, and diff --git a/rm_transport.h b/rm_transport.h index 4fa569d..fc42ca7 100644 --- a/rm_transport.h +++ b/rm_transport.h @@ -66,6 +66,13 @@ extern "C" { */ typedef void *Rm_TransportHandle; +/** + * @brief Application transport handle + */ +typedef void *Rm_AppTransportHandle; + +typedef void *Rm_PacketHandle; + /** * @brief RM packet types that can be sent between RM instances */ @@ -114,31 +121,11 @@ typedef struct { * @retval * Failure - NULL */ - Rm_Packet *(*rmAllocPkt)(Rm_TransportHandle transportHandle, uint32_t pktSize); - - /** - * @b Description - * @n - * This function pointer describes the RM transport layer packet - * free function. The application which integrates with RM must - * supply a function to RM at initialization time that matches this - * prototype. The provided function implements the free of packet - * buffers used by the RM transport for sending/receiving messages - * between RM instances in the SOC. - * - * @param[in] transportHandle - * Which application transport to free the packet to. - * - * @param[in] pkt - * Pointer to resource packet to be freed. - * - * @retval - * 0 - Packet free okay. - * @retval - * Non-zero - Send failed. - */ - int32_t (*rmFreePkt)(Rm_TransportHandle transportHandle, Rm_Packet *pkt); - + + /* Rm_Packet * and pktHandle cannot be NULL. They will either be different or the same + * value based on the transport */ + Rm_Packet *(*rmAllocPkt)(Rm_AppTransportHandle appTransport, uint32_t pktSize, + Rm_PacketHandle *pktHandle); /** * @b Description * @n @@ -159,46 +146,7 @@ typedef struct { * @retval * Non-zero - Send failed. */ - int32_t (*rmSend)(Rm_TransportHandle transportHandle, Rm_Packet *pkt); - - /** - * @b Description - * @n - * This function pointer describes the RM transport layer receive - * function. The application which integrates with RM must supply a - * function to RM at initialization time that matches this prototype. - * The provided function implements the receive side of the transport - * between RM instances on different cores in the SOC. - * - * @param[in] transportHandle - * Which application transport to retrieve a packet from - * - * @retval - * Non-NULL - Pointer to received RM packet. - * @retval - * NULL - Packet receive failed. - */ - void * (*rmReceive)(Rm_TransportHandle transportHandle); - - /** - * @b Description - * @n - * This function pointer describes the RM transport layer number of - * packets received function. The application which integrates with RM - * must supply a function to RM at initialization time that matches this - * prototype. The provided function implements a query of the number of - * RM packets received on a specified transport. - * - * @param[in] transportHandle - * Which application transport to check for received packets. - * - * @retval - * Success - Number of packets received over transport interfaces for - * a RM instance. - * @retval - * Failure - -1 - */ - int32_t (*rmNumPktsReceived)(Rm_TransportHandle transportHandle); + int32_t (*rmSendPkt)(Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle); } Rm_TransportCallouts; /** @@ -206,24 +154,27 @@ typedef struct { */ typedef struct { /** The RM Handle for which the transport is being registered */ - Rm_Handle rmHandle; + Rm_Handle rmHandle; + /** The Application transport handle associated with the registered + * transport */ + Rm_AppTransportHandle appTransportHandle; /** The transport's remote RM instance type */ - Rm_InstType remoteInstType; + Rm_InstType remoteInstType; /** Pointer to the transport's remote RM instance name */ - char *remoteInstName; + char *remoteInstName; /** Used to specify whether the transport callouts are valid. * TRUE - Transport callouts are valid and will be stored by the RM * instance. * FALSE - Transport callouts are not valid and will not be stored by * the RM instance. */ - bool transportCalloutsValid; + bool transportCalloutsValid; /** Pointers to application implemented transport APIs. The APIs for the * provided functions must match the prototypes defined in the * Rm_TransportCallouts structure. Callouts will typically only be defined * for the first transport registered with an RM instance. The * transportCalloutsValid field can be used to disable RM instance's from * reading in new callout values are they're specified once. */ - Rm_TransportCallouts transportCallouts; + Rm_TransportCallouts transportCallouts; } Rm_TransportCfg; /** @@ -250,11 +201,10 @@ typedef struct { * @retval * Failure - NULL */ -Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result); -int32_t Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandle transportHandle); -int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt); -int32_t Rm_receivePktPolling(Rm_TransportHandle transportHandle); - +Rm_TransportHandle Rm_transportRegister(Rm_TransportCfg *transportCfg, int32_t *result); +int32_t Rm_transportUnregister (Rm_TransportHandle transportHandle); +/* Application will always free the packet */ +int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, Rm_Packet *pkt); /** @} diff --git a/setupenv.bat b/setupenv.bat index 2612c0f..f5a6564 100644 --- a/setupenv.bat +++ b/setupenv.bat @@ -57,7 +57,7 @@ set PATH=%XDC_INSTALL_PATH%;%XDC_INSTALL_PATH%\bin;T:\Doxygen\doxygen\1.5.1-p1\b @REM Third Party Tools: Install-Jammer (Not required by customers) set PATH=%PATH%;T:\gen\InstallJammer\v1_2_05 -set PATH=%PATH%;%XDCCGROOT%\bin;T:\gen\gnu\99-11-01\cygwin-b20\H-i586-cygwin32\bin +set PATH=%PATH%;%XDCCGROOT%\bin set PATH=%PATH%;T:\SDOApps\cg_xml\cg_xml_v2_20_00\bin set PATH=%PATH%;T:\ti_pdsp_cgen\20091120 diff --git a/src/rm.c b/src/rm.c index b03ccdd..1baa97f 100644 --- a/src/rm.c +++ b/src/rm.c @@ -91,7 +91,7 @@ Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst) newTransaction->localId = rmTransactionGetSequenceNum(rmInst); newTransaction->nextTransaction = NULL; if (transactionQueue) { - while (transactionQueue->nextTransaction != NULL) { + while (transactionQueue->nextTransaction) { transactionQueue = transactionQueue->nextTransaction; } transactionQueue->nextTransaction = newTransaction; @@ -107,14 +107,13 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId) { Rm_Transaction *transaction = rmInst->transactionQueue; - if (transaction != NULL) { - while (transaction != NULL) { - if (transaction->localId == transactionId) { - break; - } - transaction = transaction->nextTransaction; + while (transaction) { + if (transaction->localId == transactionId) { + break; } + transaction = transaction->nextTransaction; } + return (transaction); } @@ -188,7 +187,7 @@ Rm_Allocator *rmAllocatorAdd(Rm_Inst *rmInst, const char *resourceName) /* Add allocator to end of list */ if (allocators) { - while (allocators->nextAllocator != NULL) { + while (allocators->nextAllocator) { allocators = allocators->nextAllocator; } allocators->nextAllocator = newAllocator; @@ -391,7 +390,7 @@ int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Reso RB_INIT(treeRootEntry); while (range != NULL) { - treeNode = resourceNodeNew(range->base, range->length); + treeNode = rmResourceNodeNew(range->base, range->length); collidingNode = RB_INSERT(_Rm_AllocatorResourceTree, treeRootEntry, treeNode); if (collidingNode) { @@ -401,7 +400,7 @@ int32_t rmCreateTreeAllocator(Rm_Inst *rmInst, const char *resourceName, Rm_Reso for (treeNode = RB_MIN(_Rm_AllocatorResourceTree, treeRootEntry); treeNode != NULL; treeNode = nextNode) { nextNode = RB_NEXT(_Rm_AllocatorResourceTree, treeRootEntry, treeNode); RB_REMOVE(_Rm_AllocatorResourceTree, treeRootEntry, nextNode); - resourceNodeFree(treeNode); + rmResourceNodeFree(treeNode); } Rm_osalFree((void *)treeRootEntry, sizeof(Rm_ResourceTree)); rmAllocatorDelete(rmInst, allocator->resourceName); @@ -623,9 +622,9 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc matchingNode->length = leftNode->length + matchingNode->length + rightNode->length; rmClearOwners(leftNode); - resourceNodeFree(leftNode); + rmResourceNodeFree(leftNode); rmClearOwners(rightNode); - resourceNodeFree(rightNode); + rmResourceNodeFree(rightNode); } else if (combineLeft) { /* Combine left and matching nodes. Reinsert right. */ @@ -633,7 +632,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc matchingNode->length += leftNode->length; rmClearOwners(leftNode); - resourceNodeFree(leftNode); + rmResourceNodeFree(leftNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode); } else if (combineRight) { @@ -641,7 +640,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc matchingNode->length += rightNode->length; rmClearOwners(rightNode); - resourceNodeFree(rightNode); + rmResourceNodeFree(rightNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode); } else { @@ -661,9 +660,9 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc * |<---alloc request--->| */ RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode); - leftNode = resourceNodeNew(matchingNode->base, findNode.base - matchingNode->base); + leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base); rmCopyOwners(leftNode, matchingNode); - rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd); + rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd); rmCopyOwners(rightNode, matchingNode); matchingNode->base = findNode.base; @@ -694,7 +693,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc leftNode->length += findNode.length; } else { - leftNode = resourceNodeNew(findNode.base, findNode.length); + leftNode = rmResourceNodeNew(findNode.base, findNode.length); rmCopyOwners(leftNode, matchingNode); } @@ -723,7 +722,7 @@ int32_t rmTreeAllocate(Rm_Inst *rmInst, Rm_Allocator *allocator, int32_t resourc rightNode->length += findNode.length; } else { - rightNode = resourceNodeNew(findNode.base, findNode.length); + rightNode = rmResourceNodeNew(findNode.base, findNode.length); rmCopyOwners(rightNode, matchingNode); } @@ -802,9 +801,9 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) matchingNode->length = leftNode->length + matchingNode->length + rightNode->length; rmClearOwners(leftNode); - resourceNodeFree(leftNode); + rmResourceNodeFree(leftNode); rmClearOwners(rightNode); - resourceNodeFree(rightNode); + rmResourceNodeFree(rightNode); } else if (combineLeft) { /* Combine left and matching nodes. Reinsert right. */ @@ -812,7 +811,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) matchingNode->length += leftNode->length; rmClearOwners(leftNode); - resourceNodeFree(leftNode); + rmResourceNodeFree(leftNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode); } else if (combineRight) { @@ -820,7 +819,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) matchingNode->length += rightNode->length; rmClearOwners(rightNode); - resourceNodeFree(rightNode); + rmResourceNodeFree(rightNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode); } else { @@ -845,12 +844,12 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) RB_REMOVE(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode); rmDeleteOwner(matchingNode, opInfo->serviceSrcInstNode); - leftNode = resourceNodeNew(matchingNode->base, findNode.base - matchingNode->base); + leftNode = rmResourceNodeNew(matchingNode->base, findNode.base - matchingNode->base); rmCopyOwners(leftNode, matchingNode); rmAddOwner(leftNode, opInfo->serviceSrcInstNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, leftNode); - rightNode = resourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd); + rightNode = rmResourceNodeNew(findNode.base + findNode.length, matchingEnd - findEnd); rmCopyOwners(rightNode, matchingNode); rmAddOwner(rightNode, opInfo->serviceSrcInstNode); RB_INSERT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, rightNode); @@ -879,7 +878,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) leftNode->length += findNode.length; } else { - leftNode = resourceNodeNew(findNode.base, findNode.length); + leftNode = rmResourceNodeNew(findNode.base, findNode.length); rmCopyOwners(leftNode, matchingNode); } @@ -908,7 +907,7 @@ int32_t rmTreeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo) rightNode->length += findNode.length; } else { - rightNode = resourceNodeNew(findNode.base, findNode.length); + rightNode = rmResourceNodeNew(findNode.base, findNode.length); rmCopyOwners(rightNode, matchingNode); } @@ -1114,8 +1113,8 @@ void rmServiceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction) /* Function used to send RM response transactions to lower level agents */ void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction) { - Rm_Transport *dstTransport = NULL; - Rm_Packet *rmPkt = NULL; + Rm_Transport *dstTransport = NULL; + Rm_PacketHandle pktHandle = NULL; dstTransport = rmTransportFindRemoteName((Rm_Transport *) rmInst->transports, transaction->pktSrcInstName); @@ -1124,22 +1123,20 @@ void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction) case Rm_service_RESOURCE_ALLOCATE_USE: case Rm_service_RESOURCE_FREE: case Rm_service_RESOURCE_GET_BY_NAME: - rmPkt = rmTransportCreateResourceResponsePkt(rmInst, dstTransport, - transaction); + pktHandle = rmTransportCreateResourceResponsePkt(rmInst, dstTransport->appTransportHandle, + transaction); break; case Rm_service_RESOURCE_MAP_TO_NAME: case Rm_service_RESOURCE_UNMAP_NAME: - rmPkt = rmTransportCreateNsResponsePkt(rmInst, dstTransport, - transaction); + pktHandle = rmTransportCreateNsResponsePkt(rmInst, dstTransport->appTransportHandle, + transaction); break; } - if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) { - transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR; - if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR; + if (pktHandle) { + if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) { + transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR; } - return; } rmTransactionQueueDelete(rmInst, transaction->localId); } @@ -1147,8 +1144,8 @@ void rmTransactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction) /* Function used to forward RM transactions to higher level agents */ void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction) { - Rm_Transport *dstTransport = NULL; - Rm_Packet *rmPkt = NULL; + Rm_Transport *dstTransport = NULL; + Rm_PacketHandle pktHandle = NULL; if (rmInst->registeredWithDelegateOrServer == false) { transaction->state = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER; @@ -1171,20 +1168,18 @@ void rmTransactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction) case Rm_service_RESOURCE_ALLOCATE_USE: case Rm_service_RESOURCE_FREE: case Rm_service_RESOURCE_GET_BY_NAME: - rmPkt = rmTransportCreateResourceReqPkt(rmInst, dstTransport, transaction); + pktHandle = rmTransportCreateResourceReqPkt(rmInst, dstTransport->appTransportHandle, transaction); break; case Rm_service_RESOURCE_MAP_TO_NAME: case Rm_service_RESOURCE_UNMAP_NAME: - rmPkt = rmTransportCreateNsRequestPkt(rmInst, dstTransport, transaction); + pktHandle = rmTransportCreateNsRequestPkt(rmInst, dstTransport->appTransportHandle, transaction); break; } - if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransport, rmPkt) < RM_TRANSPORT_SUCCESSFUL) { - transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR; - if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransport, rmPkt)) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR; + if (pktHandle) { + if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_TRANSPORT_SUCCESSFUL) { + transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR; } - return; } /* Transaction not deleted. Waiting for response from RM CD or Server */ } @@ -1826,6 +1821,3 @@ const char* Rm_getVersionStr (void) return rmVersionStr; } -/** -@} -*/ diff --git a/src/rm_dtb_util.c b/src/rm_dtb_util.c index e08f306..aaf2c89 100644 --- a/src/rm_dtb_util.c +++ b/src/rm_dtb_util.c @@ -40,6 +40,9 @@ * \par */ +/* Standard includes */ +#include + /* RM external API includes */ #include @@ -54,14 +57,41 @@ #include /********************************************************************** - ********************Common DTB Parsing Functions********************** + ******************** Common DTB Parsing Globals ********************** **********************************************************************/ const char rmDtbStartingNode[] = "\0"; +/********************************************************************** + *************** Global Resource List Parsing Globals ***************** + **********************************************************************/ + +/* Resource List Properties - These are the property values used + * by an application integrator to define the properties of resources + * listed in the Device Global Resource List */ +const char dtbUtilResRangeProp[] = "resource-range"; +const char dtbUtilResLinuxAliasProp[] = "linux-dtb-alias"; +const char dtbUtilResNsAssignmentProp[] = "ns-assignment"; + +/********************************************************************** + *********************** Policy Parsing Globals *********************** + **********************************************************************/ + +/* Policy Properties - These are the property values used + * by an application integrator to define the properties of resources + * listed in a Resource Manager Policy */ +const char dtbUtilPolicyValidInstances[] = "valid-instances"; +const char dtbUtilPolicyAssignments[] = "assignments"; +const char dtbUtilPolicyAllocationSize[] = "allocation-size"; +const char dtbUtilPolicyAllocationAlignment[] = "allocation-alignment"; + +/********************************************************************** + ******************* Common DTB Parsing Functions ********************* + **********************************************************************/ + /* Construct and return a list of ranges as specified in either the Resource * DTB or a Policy DTB */ -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; @@ -96,7 +126,7 @@ Rm_ResourceRange *dtbUtilCommonExtractRange(const void *dtbDataPtr, int32_t dtbD } /* Function to clean up the memory allocated for a linked list of extracted ranges */ -void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList) +static void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList) { Rm_ResourceRange *nextRange; @@ -108,7 +138,7 @@ void dtbUtilCommonFreeRangeList(Rm_ResourceRange *rangeList) } /* Construct and return a list of values as specified in the Policy DTB */ -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; @@ -140,7 +170,7 @@ Rm_ResourceValue *dtbUtilCommonExtractValueList(const void *dtbDataPtr, int32_t } /* Function to clean up the memory allocated for a linked list of extracted values */ -void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList) +static void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList) { Rm_ResourceValue *nextValue; @@ -152,16 +182,9 @@ void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList) } /********************************************************************** - *******Global Resource List DTB Parsing Defines and Functions********* + ************** Global Resource List Parsing Functions **************** **********************************************************************/ -/* Resource List Properties - These are the property values used - * by an application integrator to define the properties of resources - * listed in the Device Global Resource List */ -char dtbUtilResRangeProp[] = "resource-range"; -char dtbUtilResLinuxAliasProp[] = "linux-dtb-alias"; -char dtbUtilResNsAssignmentProp[] = "ns-assignment"; - Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName) { Rm_ResourcePropType propertyType = Rm_resourcePropType_UNKNOWN; @@ -360,17 +383,9 @@ void rmDtbUtilResFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList) } /********************************************************************** - ***************Policy DTB Parsing Defines and Functions*************** + ********************** Policy Parsing Functions ********************** **********************************************************************/ -/* Policy Properties - These are the property values used - * by an application integrator to define the properties of resources - * listed in a Resource Manager Policy */ -char dtbUtilPolicyValidInstances[] = "valid-instances"; -char dtbUtilPolicyAssignments[] = "assignments"; -char dtbUtilPolicyAllocationSize[] = "allocation-size"; -char dtbUtilPolicyAllocationAlignment[] = "allocation-alignment"; - Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char * propertyName) { Rm_PolicyPropType propertyType = Rm_policyPropType_UNKNOWN; @@ -574,7 +589,3 @@ void rmDtbUtilLinuxFreeValues(Rm_LinuxValueRange *valueList) } } -/** -@} -*/ - diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c index 589ab6a..2a3ee6d 100644 --- a/src/rm_nameserver.c +++ b/src/rm_nameserver.c @@ -64,10 +64,10 @@ int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg) Rm_NameServerNode *newNode = NULL; int32_t retVal = RM_SERVICE_APPROVED_AND_COMPLETED; - if (newNode = nameServerNodeNew(&objCfg->nodeCfg)) { + if (newNode = rmNameServerNodeNew(&objCfg->nodeCfg)) { if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) { /* Collision */ - nameServerNodeFree(newNode); + rmNameServerNodeFree(newNode); retVal = RM_SERVICE_DENIED_NAMESERVER_ERROR_NAME_ALREADY_EXISTS; } } @@ -110,7 +110,7 @@ int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg) if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) { /* Remove from NameServer */ RB_REMOVE(_Rm_NameServerTree, objCfg->nameServerTree, matchingNode); - nameServerNodeFree(matchingNode); + rmNameServerNodeFree(matchingNode); retVal = RM_SERVICE_APPROVED_AND_COMPLETED; } diff --git a/src/rm_policy.c b/src/rm_policy.c index b6a5c5e..9432c3d 100644 --- a/src/rm_policy.c +++ b/src/rm_policy.c @@ -69,8 +69,8 @@ const char Rm_policyAllInstances[] = "*"; ******************** Local Policy Functions ************************** **********************************************************************/ -int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, - Rm_PolicyPermission *permissionsList) +static int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, + Rm_PolicyPermission *permissionsList) { while (permissionsList) { if (strcmp(permissionsList->instName, Rm_policyAllInstances) && @@ -82,8 +82,8 @@ int32_t policyCheckInstances(Rm_PolicyValidInstTree *validInstTree, return(RM_INIT_OK); } -Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd, - int32_t *result) +static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrEnd, + int32_t *result) { Rm_PolicyPermission *startPerm = NULL; Rm_PolicyPermission *newPerm = NULL; @@ -381,7 +381,7 @@ Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *permStrE return (startPerm); } -void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList) +static void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList) { Rm_PolicyPermission *nextPerm; @@ -392,8 +392,8 @@ void policyFreeAssignmentPermissions(Rm_PolicyPermission *permissionList) } } -Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, - int32_t *result) +static Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignment, + int32_t *result) { Rm_PolicyPermission *startPerm = NULL; Rm_PolicyPermission *newPerm = NULL; @@ -443,8 +443,8 @@ Rm_PolicyPermission *policyGetAssignmentPermissions(Rm_PolicyAssignment *assignm return(startPerm); } -int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root, - Rm_PolicyAssignment *assignmentList) +static int32_t policyValidateAssignmentPermissions(Rm_PolicyValidInstTree *root, + Rm_PolicyAssignment *assignmentList) { Rm_PolicyAssignment *assignment = assignmentList; Rm_PolicyPermission *permissionList; @@ -801,14 +801,14 @@ Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, int32_t *re RB_INIT(rootEntry); while (validInstList) { - newNode = policyValidInstNodeNew(validInstList->instName); + newNode = rmPolicyValidInstNodeNew(validInstList->instName); RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode); validInstList = validInstList->nextValidInst; } /* Add the Linux kernel node */ - newNode = policyValidInstNodeNew(linuxName); + newNode = rmPolicyValidInstNodeNew(linuxName); RB_INSERT(_Rm_PolicyValidInstTree, rootEntry, newNode); *result = RM_INIT_OK; @@ -821,7 +821,7 @@ void rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree) RB_FOREACH(node, _Rm_PolicyValidInstTree, validInstTree) { RB_REMOVE(_Rm_PolicyValidInstTree, validInstTree, node); - policyValidInstNodeFree(node); + rmPolicyValidInstNodeFree(node); } Rm_osalFree((void *)validInstTree, sizeof(Rm_PolicyValidInstTree)); } diff --git a/src/rm_services.c b/src/rm_services.c index 441f947..5120cd6 100644 --- a/src/rm_services.c +++ b/src/rm_services.c @@ -218,6 +218,3 @@ int32_t Rm_serviceCloseHandle(Rm_ServiceHandle *rmServiceHandle) return(retVal); } -/** -@} -*/ diff --git a/src/rm_transport.c b/src/rm_transport.c index 8f0fa55..50d4ec2 100644 --- a/src/rm_transport.c +++ b/src/rm_transport.c @@ -57,78 +57,77 @@ ********************** Internal Functions **************************** **********************************************************************/ -Rm_Transport *transportAdd(Rm_TransportCfg *transportCfg) +static Rm_Transport *transportAdd(Rm_TransportCfg *transportCfg) { Rm_Inst *rmInst = (Rm_Inst *) transportCfg->rmHandle; Rm_Transport *transports = rmInst->transports; Rm_Transport *newTransport = NULL; newTransport = Rm_osalMalloc (sizeof(Rm_Transport)); + memset((void *)newTransport, 0, sizeof(Rm_Transport)); if (newTransport) { newTransport->rmHandle = transportCfg->rmHandle; + newTransport->appTransportHandle = transportCfg->appTransportHandle; newTransport->remoteInstType = transportCfg->remoteInstType; - strncpy(&(newTransport->remoteInstName)[0], transportCfg->remoteInstName, RM_NAME_MAX_CHARS); + strncpy(newTransport->remoteInstName, transportCfg->remoteInstName, RM_NAME_MAX_CHARS); newTransport->nextTransport = NULL; if (transports) { - while (transports->nextTransport != NULL) { + while (transports->nextTransport) { transports = transports->nextTransport; } transports->nextTransport = newTransport; } else { - rmInst->transports = (void *) newTransport; + rmInst->transports = (void *)newTransport; } } return (newTransport); } -Rm_Transport *transportFindTransportHandle(Rm_Transport *transports, - Rm_TransportHandle transportHandle) +static bool transportIsTransportRegistered(Rm_Handle rmHandle, Rm_Transport *transport) { - while (transports) { - if (transports == ((Rm_Transport *)transportHandle)) { - break; + Rm_Inst *rmInst = (Rm_Inst *)rmHandle; + Rm_Transport *transportList = (Rm_Transport *)rmInst->transports; + + while (transportList) { + if (transportList == transport) { + return(TRUE); } - transports = transports->nextTransport; + transportList = transportList->nextTransport; } - return (transports); + return (FALSE); } -int32_t transportDelete(Rm_Handle rmHandle, Rm_TransportHandle transportHandle) +static void transportDelete(Rm_Transport *transport) { - Rm_Inst *rmInst = (Rm_Inst *)rmHandle; - Rm_Transport *transport = (Rm_Transport *) rmInst->transports; + Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle; + Rm_Transport *transportList = (Rm_Transport *)rmInst->transports; Rm_Transport *prevTransport = NULL; - while (transport) { - if (transport == (Rm_Transport *)transportHandle) { + /* Get previous transport in list */ + while (transportList) { + if (transportList == transport) { break; } - prevTransport = transport; - transport = transport->nextTransport; + prevTransport = transportList; + transportList = transportList->nextTransport; } - if (transport) { - if (prevTransport == NULL) { - rmInst->transports = (void *) transport->nextTransport; - } - else { - prevTransport->nextTransport = transport->nextTransport; - } - Rm_osalFree((void *) transport, sizeof(Rm_Transport)); + if (prevTransport == NULL) { + rmInst->transports = (void *)transport->nextTransport; } else { - return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED); + prevTransport->nextTransport = transport->nextTransport; } - return (RM_TRANSPORT_SUCCESSFUL); + Rm_osalFree((void *)transport, sizeof(Rm_Transport)); } Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName) { while (transports) { - if (strcmp(transports->remoteInstName, remoteName) == 0) { + if (strncmp(transports->remoteInstName, remoteName, RM_NAME_MAX_CHARS) == 0) { break; } transports = transports->nextTransport; @@ -147,22 +146,19 @@ Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstTyp return (transports); } -Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport, - Rm_Transaction *transaction) +Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction) { Rm_Packet *rmPkt = NULL; + Rm_PacketHandle pktHandle = NULL; Rm_ResourceRequestPkt *resourceReqPkt = NULL; - if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) == - NULL) { + if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, + sizeof(Rm_Packet), + &pktHandle)) == NULL) { transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR; return (NULL); } - - if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL; - return (NULL); - } rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST; resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data; @@ -183,54 +179,49 @@ Rm_Packet *rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_Transport *dstTra strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS); memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo), sizeof(Rm_ResourceInfo)); - return (rmPkt); + + return (pktHandle); } -Rm_Packet *rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport, - Rm_Transaction *transaction) +Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction) { Rm_Packet *rmPkt = NULL; + Rm_PacketHandle pktHandle = NULL; Rm_ResourceResponsePkt *resourceRespPkt = NULL; - if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) == - NULL) { + if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, + sizeof(Rm_Packet), + &pktHandle)) == NULL) { transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR; return (NULL); } - - if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL; - return (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)); - return (rmPkt); + return (pktHandle); } -Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTransport, - Rm_Transaction *transaction) +Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction) { Rm_Packet *rmPkt = NULL; + Rm_PacketHandle pktHandle = NULL; Rm_NsRequestPkt *nsReqPkt = NULL; - if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) == - NULL) { + if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, + sizeof(Rm_Packet), + &pktHandle)) == NULL) { transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR; return (NULL); } - if (rmPkt->pktLenBytes < (sizeof(Rm_NsRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL; - return (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) { @@ -243,33 +234,30 @@ Rm_Packet *rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_Transport *dstTrans strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS); memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo), sizeof(Rm_ResourceInfo)); - - return (rmPkt); + + return (pktHandle); } -Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTransport, - Rm_Transaction *transaction) +Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport, + Rm_Transaction *transaction) { Rm_Packet *rmPkt = NULL; + Rm_PacketHandle pktHandle = NULL; Rm_NsResponsePkt *nsRespPkt = NULL; - if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransport, sizeof(Rm_Packet))) == - NULL) { + if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, + sizeof(Rm_Packet), + &pktHandle)) == NULL) { transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR; return (NULL); } - - if (rmPkt->pktLenBytes < (sizeof(Rm_NsResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType))) { - transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL; - return (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; - return (rmPkt); + return (pktHandle); } /********************************************************************** @@ -278,7 +266,7 @@ Rm_Packet *rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_Transport *dstTran Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t *result) { - Rm_Inst *rmInst = (Rm_Inst *) transportCfg->rmHandle; + Rm_Inst *rmInst = (Rm_Inst *) transportCfg->rmHandle; Rm_Transport *transport = NULL; /* RM Servers cannot connect to other Servers. RM Client Delegates cannot @@ -287,7 +275,7 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t (transportCfg->remoteInstType == Rm_instType_SERVER)) || ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) && (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE))) { - *result = -500; + *result = RM_TRANSPORT_ERROR_INVALID_REMOTE_INST_TYPE; return(NULL); } @@ -298,26 +286,21 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) && (transportCfg->remoteInstType == Rm_instType_SERVER)))) { - *result = -501; + *result = RM_TRANSPORT_ERROR_REGISTERING_WITH_MORE_THAN_ONE_SERVER_OR_CD; return(NULL); } - + if (transportCfg->transportCalloutsValid && ((transportCfg->transportCallouts.rmAllocPkt == NULL) || - (transportCfg->transportCallouts.rmFreePkt == NULL) || - (transportCfg->transportCallouts.rmSend == NULL) || - (transportCfg->transportCallouts.rmReceive == NULL) || - (transportCfg->transportCallouts.rmNumPktsReceived == NULL))) { - *result = -502; + (transportCfg->transportCallouts.rmSendPkt == NULL))) { + *result = RM_TRANSPORT_ERROR_CALLOUTS_VALID_BUT_NULL_PROVIDED; return(NULL); } else { - rmInst->transport.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt; - rmInst->transport.rmFreePkt = transportCfg->transportCallouts.rmFreePkt; - rmInst->transport.rmSend = transportCfg->transportCallouts.rmSend; - rmInst->transport.rmReceive = transportCfg->transportCallouts.rmReceive; - rmInst->transport.rmNumPktsReceived = transportCfg->transportCallouts.rmNumPktsReceived; + rmInst->transportCallouts.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt; + rmInst->transportCallouts.rmSendPkt = transportCfg->transportCallouts.rmSendPkt; } + transport = transportAdd(transportCfg); if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) || @@ -325,40 +308,38 @@ Rm_TransportHandle Rm_transportRegister (Rm_TransportCfg *transportCfg, int32_t rmInst->registeredWithDelegateOrServer = true; } - *result = 0; /* TEMP */ + *result = RM_INIT_OK; return ((Rm_TransportHandle) transport); } -int32_t Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandle transportHandle) +int32_t Rm_transportUnregister(Rm_TransportHandle transportHandle) { - Rm_Inst *rmInst = (Rm_Inst *) rmHandle; - Rm_Transport *transport = transportFindTransportHandle((Rm_Transport *)rmInst->transports, - transportHandle); - int32_t retVal = RM_TRANSPORT_SUCCESSFUL; + Rm_Transport *transport = (Rm_Transport *)transportHandle; + Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle; + int32_t retVal = RM_TRANSPORT_SUCCESSFUL; - if (transport == NULL) { - retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED; - } - else { + if (transportIsTransportRegistered(transport->rmHandle, transport)) { if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) || (transport->remoteInstType == Rm_instType_SERVER)) { rmInst->registeredWithDelegateOrServer = false; } - retVal = transportDelete(rmHandle, transportHandle); + transportDelete(transport); + } + else { + retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED; } - return (retVal); } /* Used by the application to pass RM packets received from a transport to RM. - * CODE THE FUNCTION SUCH THAT IT CAN BE CALLED DIRECTLY BY APP OR BE PLUGGED - * AS PART OF AN ISR HANDLER FOR THE TRANSACTION RECEIVE */ -int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt) + * Function can be called from polling or ISR context. */ +int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, Rm_Packet *pkt) { - Rm_Inst *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle; + Rm_Transport *transport = (Rm_Transport *)transportHandle; + Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle; Rm_Transaction *transaction; - if (transportFindTransportHandle((Rm_Transport *)rmInst->transports, transportHandle) == NULL) { + if (!transportIsTransportRegistered(transport->rmHandle, transport)) { return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED); } @@ -406,7 +387,6 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt) rmTransactionProcessor(rmInst, transaction); } else { - rmInst->transport.rmFreePkt(transportHandle, pkt); return (RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND); } break; @@ -442,50 +422,14 @@ int32_t Rm_receivePktIsr(Rm_TransportHandle transportHandle, Rm_Packet *pkt) rmTransactionProcessor(rmInst, transaction); } else { - rmInst->transport.rmFreePkt(transportHandle, pkt); return (RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND); } break; } default: - rmInst->transport.rmFreePkt(transportHandle, pkt); return (RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE); } - rmInst->transport.rmFreePkt(transportHandle, pkt); return (RM_TRANSPORT_SUCCESSFUL); } -/* Application can call this API so that RM handles reception of packets based on - * the RM handle and transport handle provided */ -int32_t Rm_receivePktPolling(Rm_TransportHandle transportHandle) -{ - Rm_Inst *rmInst = (Rm_Inst *)((Rm_Transport *)transportHandle)->rmHandle; - Rm_Packet *pkt = NULL; - int32_t retVal = RM_TRANSPORT_OK_BASE; - - if (transportFindTransportHandle((Rm_Transport *)rmInst->transports, transportHandle) != NULL) { - while (rmInst->transport.rmNumPktsReceived(transportHandle) > 0) { - pkt = rmInst->transport.rmReceive(transportHandle); - - if (pkt == NULL) { - retVal = RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR; - break; - } - - /* Pass packet to RM. Packet will be freed within PktIsr API */ - if (retVal = Rm_receivePktIsr(transportHandle, pkt) <= RM_SERVICE_ERROR_BASE) { - break; - } - } - } - else { - retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED; - } - - return (retVal); -} - -/** -@} -*/ diff --git a/src/rm_tree.c b/src/rm_tree.c index cb9519c..f1496e4 100644 --- a/src/rm_tree.c +++ b/src/rm_tree.c @@ -55,7 +55,7 @@ ********************* NameServer Tree Functions ********************** **********************************************************************/ -Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg) +Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg) { Rm_NameServerNode *newNode = NULL; @@ -70,7 +70,7 @@ Rm_NameServerNode *nameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg) return(newNode); } -void nameServerNodeFree(Rm_NameServerNode *node) +void rmNameServerNodeFree(Rm_NameServerNode *node) { if (node) { Rm_osalFree((void *)node, sizeof(Rm_NameServerNode)); @@ -81,18 +81,18 @@ void nameServerNodeFree(Rm_NameServerNode *node) * node1 < node2 --> return < 0 * node1 = node2 --> return 0 * node1 > node2 --> return > 0 */ -int nameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2) +int rmNameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2) { return(strcmp(node1->objName, node2->objName)); } /* Generate the NameServer tree manipulation functions */ -RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, nameServerNodeCompare); +RB_GENERATE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, rmNameServerNodeCompare); /********************************************************************** *************** Policy Valid Instance Tree Functions ***************** **********************************************************************/ -Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName) +Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName) { Rm_PolicyValidInstNode *newNode = NULL; @@ -105,26 +105,26 @@ Rm_PolicyValidInstNode *policyValidInstNodeNew(char *instName) return(newNode); } -void policyValidInstNodeFree(Rm_PolicyValidInstNode *node) +void rmPolicyValidInstNodeFree(Rm_PolicyValidInstNode *node) { if (node->allocRefCount == 0) { Rm_osalFree((void *)node, sizeof(Rm_PolicyValidInstNode)); } } -int policyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2) +int rmPolicyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2) { return(strcmp(node1->name, node2->name)); } /* Generate the valid instance tree manipulation functions */ -RB_GENERATE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, policyValidInstNodeCompare); +RB_GENERATE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, rmPolicyValidInstNodeCompare); /********************************************************************** ***************** Allocator Resource Tree Functions ****************** **********************************************************************/ -Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength) +Rm_ResourceNode *rmResourceNodeNew(uint32_t resourceBase, uint32_t resourceLength) { Rm_ResourceNode *newNode = NULL; @@ -139,14 +139,14 @@ Rm_ResourceNode *resourceNodeNew(uint32_t resourceBase, uint32_t resourceLength) return(newNode); } -void resourceNodeFree(Rm_ResourceNode *node) +void rmResourceNodeFree(Rm_ResourceNode *node) { if (node->allocationCount == 0) { Rm_osalFree((void *)node, sizeof(Rm_ResourceNode)); } } -int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2) +int rmResourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2) { uint32_t node1End = node1->base + node1->length - 1; uint32_t node2End = node2->base + node2->length - 1; @@ -168,5 +168,5 @@ int resourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2) } /* Generate the red-black tree manipulation functions */ -RB_GENERATE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, resourceNodeCompare) +RB_GENERATE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, rmResourceNodeCompare) diff --git a/test/rm_test.c b/test/rm_test.c index a72f397..5889b4f 100644 --- a/test/rm_test.c +++ b/test/rm_test.c @@ -86,10 +86,10 @@ Char rmClientDelegateName[RM_NAME_MAX_CHARS] = "RM_Client_Delegate"; Char rmClientName[RM_NAME_MAX_CHARS] = "RM_Client"; /* ======== RM IPC MessageQ Names ======== */ -Char serverCdQueueName[30] = "RM_Server_CD_Queue"; -Char cdServerQueueName[30] = "RM_CD_Server_Queue"; -Char cdClientQueueName[30] = "RM_CD_Client_Queue"; -Char clientCdQueueName[30] = "RM_Client_CD_Queue"; +Char serverFromCdQueueName[30] = "RM_Server_From_CD_Queue"; +Char cdFromServerQueueName[30] = "RM_CD_From_Server_Queue"; +Char cdFromClientQueueName[30] = "RM_CD_From_Client_Queue"; +Char clientFromCdQueueName[30] = "RM_Client_From_CD_Queue"; /* ======== RM Instance Handles ======== */ Rm_Handle rmServerHandle = NULL; @@ -122,7 +122,6 @@ typedef struct { typedef struct { Rm_TransportHandle transportHandle; MessageQ_Handle receiveMsgQ; - MessageQ_QueueId remoteMsgQId; } Transport_MapEntry; /* Core 1 will have three mapping entries @@ -160,8 +159,7 @@ void takeSyncObj(void) void waitOnSyncObj(void) { - do - { + do { /* Yield for other tasks */ Task_yield(); Rm_osalBeginMemAccess((void *) &testSyncObj, sizeof(syncObj)); @@ -177,175 +175,97 @@ void releaseSyncObj(void) /* ======== RM Application Transport APIs ======== */ -Rm_Packet *TransportAlloc (Rm_TransportHandle transportHandle, uint32_t pktSize) +Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle) { - Rm_Packet *pkt = NULL; - - /* All transports will allocate from the same heap */ - - pkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0); + Rm_Packet *rmPkt = NULL; + MsgQ_RmPacket *rmMsg = NULL; - if (pkt != NULL) - { - pkt->pktLenBytes = pktSize; + /* Allocate a messageQ message for containing the RM packet */ + rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket)); + if (rmMsg == NULL) { + System_printf("Core %d: MessageQ_alloc failed in TransportSend\n", MultiProc_self()); + *pktHandle = NULL; + return(NULL); } - - return (pkt); + else { + /* Create and attach RM packet to MessageQ message. All transports will allocate from the same heap */ + rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0); + rmPkt->pktLenBytes = pktSize; + Rm_osalEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes); + rmMsg->rmPkt = rmPkt; + *pktHandle = (Rm_PacketHandle)rmMsg; + } + return (rmPkt); } -int32_t TransportFree (Rm_TransportHandle transportHandle, Rm_Packet *pkt) +void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt) { uint32_t pktSize = pkt->pktLenBytes; + int32_t status; - /* All transports will free to the same heap */ - + /* All transports will free rmPkts to the same heap */ HeapBufMP_free(rmPktHeapHandle, pkt, pktSize); - return (0); + status = MessageQ_free(rmMsgQMsg); + if (status < 0) { + System_printf("Core %d: MessageQ_free had a failure/error in transportFree\n", MultiProc_self()); + } } -int32_t TransportSend (Rm_TransportHandle transportHandle, Rm_Packet *pkt) +int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle) { - MsgQ_RmPacket *rmMsg = NULL; - MessageQ_QueueId remoteQueueId; - bool handleValid = false; - int32_t status, i; - - /* Get the remoteQueueId based on the transportHandle */ - for (i = 0; i < MAX_MAPPING_ENTRIES; i++) - { - /* transportHandle found in mapping table. Get the remoteQueueId associated - * with it */ - if (rmTransportMap[i].transportHandle == transportHandle) - { - remoteQueueId = rmTransportMap[i].remoteMsgQId; - /* Break out of the search loop */ - handleValid = true; - break; - } - } + MessageQ_QueueId remoteQueueId = (MessageQ_QueueId)appTransport; + MsgQ_RmPacket *rmMsg = pktHandle; + int32_t status; - if (handleValid) - { - /* Allocate a messageQ message for containing the RM packet */ - rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket)); - if (rmMsg == NULL) - { - System_printf("Core %d: MessageQ_alloc failed in TransportSend\n", MultiProc_self()); - } + /* Write back data that was written by RM after alloc */ + Rm_osalEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes); - /* Attach the RM packet to the MessageQ message */ - Rm_osalEndMemAccess((void *) pkt, pkt->pktLenBytes); - rmMsg->rmPkt = pkt; - /* Send the message to the remote side */ - status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg); - if (status < 0) - { - System_printf("Core %d: MessageQ_put had a failure/error in TransportSend\n", MultiProc_self()); - } - } - else - { - /* Could not find a registered transport handle that matched the handle provided by RM. - * Return an error to RM. */ - System_printf("Core %d: TransportSend couldn't find transportHandle in transport map\n", MultiProc_self()); - status = -1; + /* Send the message to the remote side */ + status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg); + if (status < 0) { + transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt); + System_printf("Core %d: MessageQ_put had a failure/error in TransportSend: error: %d\n", MultiProc_self(), + status); } - return (status); } -void *TransportReceive (Rm_TransportHandle transportHandle) +void transportReceive (uint32_t transportMapEntry) { - MessageQ_Handle receiveQ; - MessageQ_Msg rmMsg = NULL; - Rm_Packet *rmPkt = NULL; - bool queueValid = false; - int32_t status, i; - - /* Get the receiveQ based on the transportHandle */ - for (i = 0; i < MAX_MAPPING_ENTRIES; i++) - { - /* transportHandle found in mapping table. Get the receiveQ associated - * with it */ - if (rmTransportMap[i].transportHandle == transportHandle) - { - receiveQ = rmTransportMap[i].receiveMsgQ; - /* Break out of the search loop */ - queueValid = true; - break; - } - } - - if (queueValid) - { - /* Get the next message from the receiveQ */ + MessageQ_Handle receiveQ; + int32_t numPkts; + MessageQ_Msg rmMsg = NULL; + Rm_Packet *rmPkt = NULL; + int32_t status; + uint32_t i; + + /* Check if any packets available */ + receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ; + numPkts = (int32_t) MessageQ_count(receiveQ); + + /* Process all available packets */ + for (i = 0; i < numPkts; i++) { status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER); - if (status < 0) - { + if (status < 0) { System_abort("This should not happen since timeout is forever\n"); } - if (rmMsg == NULL) - { + if (rmMsg == NULL) { System_printf("Core %d: MessageQ_get failed returning a null packet in TransportReceive\n", MultiProc_self()); } /* Extract the Rm_Packet from the RM msg */ rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt; - Rm_osalBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes); + Rm_osalBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes); - /* Free the messageQ message now that RM packet pointer has been extracted */ - status = MessageQ_free(rmMsg); - if (status < 0) - { - System_printf("Core %d: MessageQ_free had a failure/error in TransportReceive\n", MultiProc_self()); - } - } - else - { - /* Could not find a registered transport handle that matched the handle provided by RM. - * Return an error to RM. */ - System_printf("Core %d: TransportReceive couldn't find transportHandle in transport map\n", MultiProc_self()); - } - - /* Pass the RM packet back to RM */ - return ((void *)rmPkt); -} - -int32_t TransportNumPktsReceived (Rm_TransportHandle transportHandle) -{ - MessageQ_Handle receiveQ; - bool queueValid = false; - int32_t numPkts, i; - - /* Get the receiveQ based on the transportHandle */ - for (i = 0; i < MAX_MAPPING_ENTRIES; i++) - { - /* transportHandle found in mapping table. Get the receiveQ associated - * with it */ - if (rmTransportMap[i].transportHandle == transportHandle) - { - receiveQ = rmTransportMap[i].receiveMsgQ; - /* Break out of the search loop */ - queueValid = true; - break; + /* Provide packet to RM for processing */ + if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) { + System_printf("Core %d: RM encountered error processing received packet: %d\n", MultiProc_self(), status); } - } - if (queueValid) - { - /* Get the number of messages in the receiveQ */ - numPkts = (int32_t) MessageQ_count(receiveQ); - } - else - { - /* Could not find a registered transport handle that matched the handle provided by RM. - * Return an error to RM. */ - System_printf("Core %d: TransportNumPktsReceived couldn't find transportHandle in transport map\n", MultiProc_self()); - numPkts = -1; + /* Free RM packet buffer and messageQ message */ + transportFree(rmMsg, rmPkt); } - - return (numPkts); } /* @@ -354,8 +274,7 @@ int32_t TransportNumPktsReceived (Rm_TransportHandle transportHandle) */ void testServiceCallback(Rm_ServiceRespInfo *serviceResponse) { - if (serviceResponse->serviceId == waitForBlockingOperation) - { + if (serviceResponse->serviceId == waitForBlockingOperation) { waitForBlockingOperation = 0; strcpy(responseInfo.resourceName, serviceResponse->resourceName); responseInfo.resourceBase = serviceResponse->resourceBase; @@ -369,20 +288,17 @@ bool blockForResponse(Rm_ServiceRespInfo *respInfo) waitForBlockingOperation = respInfo->serviceId; /* Block and wait for the response if the RM needed to perform a blocking operation * to complete the request */ - while(waitForBlockingOperation) - { + while(waitForBlockingOperation) { /* Yield to receive task to see if there are any packets for RM instance */ Task_yield(); } if ((respInfo->serviceState != RM_SERVICE_PROCESSING) && - (respInfo->serviceState != RM_SERVICE_APPROVED_AND_COMPLETED)) - { + (respInfo->serviceState != RM_SERVICE_APPROVED_AND_COMPLETED)) { System_printf("Core %d: Service request encountered error or denial: %d\n", MultiProc_self(), respInfo->serviceState); return(FALSE); } - return(TRUE); } @@ -394,23 +310,19 @@ void cleanupRmTsk(UArg arg0, UArg arg1) { /* Delete the RM test task */ System_printf("Core %d: Deleting RM test task...\n", MultiProc_self()); - if (testRmTskHandle) - { + if (testRmTskHandle) { Task_delete(&testRmTskHandle); /* Set the task handle to be NULL so that the delete only occurs once */ testRmTskHandle = NULL; } /* Delete the RM receive task */ System_printf("Core %d: Deleting RM receive task...\n", MultiProc_self()); - if (testReceiveTskHandle) - { + if (testReceiveTskHandle) { Task_delete(&testReceiveTskHandle); /* Set the task handle to be NULL so that the delete only occurs once */ testReceiveTskHandle = NULL; } - - /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */ BIOS_exit(0); @@ -422,53 +334,15 @@ void cleanupRmTsk(UArg arg0, UArg arg1) */ void testReceiveTsk(UArg arg0, UArg arg1) { - int32_t retVal; - - while(1) - { - - /* Run the RM polling functions for each RM instance. */ - if (MultiProc_self() == 0) - { - retVal = Rm_receivePktPolling(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle); - if (retVal != RM_TRANSPORT_SUCCESSFUL) - { - System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), - rmServerName, - rmClientDelegateName, - retVal); - } + while(1) { + if (MultiProc_self() == 0) { + transportReceive(SERVER_TO_CD_MAP_ENTRY); } - else if (MultiProc_self() == 1) - { - retVal = Rm_receivePktPolling(rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle); - if (retVal != RM_TRANSPORT_SUCCESSFUL) - { - System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), - rmClientDelegateName, - rmServerName, - retVal); - } - - retVal = Rm_receivePktPolling(rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle); - if (retVal != RM_TRANSPORT_SUCCESSFUL) - { - System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), - rmClientDelegateName, - rmClientName, - retVal); - } - - retVal = Rm_receivePktPolling(rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle); - if (retVal != RM_TRANSPORT_SUCCESSFUL) - { - System_printf("Core %d: %s to %s transport receive error %d\n", MultiProc_self(), - rmClientName, - rmClientDelegateName, - retVal); - } + else if (MultiProc_self() == 1) { + transportReceive(CD_TO_SERVER_MAP_ENTRY); + transportReceive(CD_TO_CLIENT_MAP_ENTRY); + transportReceive(CLIENT_TO_CD_MAP_ENTRY); } - /* Yield for main test task */ Task_yield(); } @@ -977,30 +851,27 @@ void testRmTsk(UArg arg0, UArg arg1) */ Void startupRmTsk(UArg arg0, UArg arg1) { - MessageQ_Handle serverCdMsgQ, cdServerMsgQ, cdClientMsgQ, clientCdMsgQ; - MessageQ_QueueId serverCdQId, cdServerQId, cdClientQId, clientCdQId; - Int status, i; - HeapBufMP_Handle msgQHeapHandle; - HeapBufMP_Params heapBufParams; - Rm_TransportCfg rmTransportCfg; - int32_t result = 0; + MessageQ_Handle serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ; + MessageQ_QueueId serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId; + Int status, i; + HeapBufMP_Handle msgQHeapHandle; + HeapBufMP_Params heapBufParams; + Rm_TransportCfg rmTransportCfg; + int32_t result = 0; Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle; - Task_Params taskParams; + Task_Params taskParams; - if (MultiProc_self() == 1) - { + if (MultiProc_self() == 1) { /* Take the syncObj on core 1, preparing for RM testing */ takeSyncObj(); } /* Initialize the transport map */ - for (i = 0; i < MAX_MAPPING_ENTRIES; i++) - { + for (i = 0; i < MAX_MAPPING_ENTRIES; i++) { rmTransportMap[i].transportHandle = NULL; } - if (MultiProc_self() == 0) - { + if (MultiProc_self() == 0) { /* Create the heap that will be used to allocate RM messages. This * heap is a multi-processor heap. It will be shared amongst * all RM instances. */ @@ -1010,8 +881,7 @@ Void startupRmTsk(UArg arg0, UArg arg1) heapBufParams.numBlocks = 64; heapBufParams.blockSize = sizeof(Rm_Packet); rmPktHeapHandle = HeapBufMP_create(&heapBufParams); - if (rmPktHeapHandle == NULL) - { + if (rmPktHeapHandle == NULL) { System_abort("HeapBufMP_create failed for RM packet heap\n" ); } System_printf("Core %d: RM packet heap created\n", MultiProc_self()); @@ -1023,38 +893,32 @@ Void startupRmTsk(UArg arg0, UArg arg1) heapBufParams.numBlocks = 64; heapBufParams.blockSize = sizeof(MsgQ_RmPacket); msgQHeapHandle = HeapBufMP_create(&heapBufParams); - if (msgQHeapHandle == NULL) - { + if (msgQHeapHandle == NULL) { System_abort("HeapBufMP_create failed MessageQ message heap\n" ); } System_printf("Core %d: IPC MessageQ message heap created\n", MultiProc_self()); } - else - { + else { /* Open the heaps created by the other processor. Loop until opened. */ - do - { + do { status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); System_printf("Core %d: RM packet heap opened\n", MultiProc_self()); - do - { + do { status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); @@ -1067,38 +931,31 @@ Void startupRmTsk(UArg arg0, UArg arg1) /* Create the messageQ's for each RM instance connection * Need four queues. Topology will be: * RM Server <---> RM Client Delegate <---> RM Client - * 1 queue on RM Server + * 1 queues on RM Server * 2 queues on RM Client Delegate - * 1 queue on RM Client */ - if (MultiProc_self() == 0) - { - /* Create the RM Server messageQ used by the RM Client Delegate */ - serverCdMsgQ = MessageQ_create(serverCdQueueName, NULL); - if (serverCdMsgQ == NULL) - { + * 1 queues on RM Client */ + if (MultiProc_self() == 0) { + serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL); + if (serverFromCdMsgQ == NULL) { System_abort("MessageQ_create failed for RM Server - Client Delegate queue\n" ); } System_printf("Core %d: RM Server MessageQ created for receiving packets from RM CD\n", MultiProc_self()); } - else if (MultiProc_self() == 1) - { - /* Create the RM Client Delegate messageQ used by the RM Server */ - cdServerMsgQ = MessageQ_create(cdServerQueueName, NULL); - if (cdServerMsgQ == NULL) - { + else if (MultiProc_self() == 1) { + cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL); + if (cdFromServerMsgQ == NULL) { System_abort("MessageQ_create failed for RM Client Delegate - Server queue\n" ); } System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Server\n", MultiProc_self()); - /* Create the RM Client Delegate messageQ used by the RM Client */ - cdClientMsgQ = MessageQ_create(cdClientQueueName, NULL); - if (cdClientMsgQ == NULL) - { + + cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL); + if (cdFromClientMsgQ == NULL) { System_abort("MessageQ_create failed for RM Client Delegate - Client queue\n" ); } System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Client\n", MultiProc_self()); - /* Create the RM Client messageQ used by the RM Client Delegate */ - clientCdMsgQ = MessageQ_create(clientCdQueueName, NULL); - if (clientCdMsgQ == NULL) + + clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL); + if (clientFromCdMsgQ == NULL) { System_abort("MessageQ_create failed for RM Client - Client Delegate queue\n" ); } @@ -1106,143 +963,120 @@ Void startupRmTsk(UArg arg0, UArg arg1) } /* Open the remote message queues. Also register the RM transports with each RM instance */ - if (MultiProc_self() == 0) - { + if (MultiProc_self() == 0) { /* Open the Client Delegate messageQ from the Server */ - do - { - status = MessageQ_open(cdServerQueueName, &serverCdQId); + do { + status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); System_printf("Core %d: RM CD MessageQ opened from RM Server\n", MultiProc_self()); /* Register the Client Delegate with the RM Server Instance */ + rmTransportCfg.rmHandle = rmServerHandle; + rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId; rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE; rmTransportCfg.remoteInstName = &rmClientDelegateName[0]; /* Set the callouts as valid for the first transport configuration on Server instance */ - rmTransportCfg.rmHandle = rmServerHandle; rmTransportCfg.transportCalloutsValid = true; - rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc; - rmTransportCfg.transportCallouts.rmFreePkt = TransportFree; - rmTransportCfg.transportCallouts.rmSend = TransportSend; - rmTransportCfg.transportCallouts.rmReceive = TransportReceive; - rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; - + rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc; + rmTransportCfg.transportCallouts.rmSendPkt = transportSend; serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result); /* Store the mapping information in the transport map */ rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle; - rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverCdMsgQ; - rmTransportMap[SERVER_TO_CD_MAP_ENTRY].remoteMsgQId = serverCdQId; + rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ; System_printf("Core %d: Registered RM Server <=> RM CD transport with RM Server instance\n", MultiProc_self()); - } - else if (MultiProc_self() == 1) - { + else if (MultiProc_self() == 1) { /* Open the Server messageQ from the Client Delegate */ - do - { - status = MessageQ_open(serverCdQueueName, &cdServerQId); + do { + status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); System_printf("Core %d: RM Server MessageQ opened from RM CD\n", MultiProc_self()); /* Register the Server with the RM Client Delegate Instance */ + rmTransportCfg.rmHandle = rmClientDelegateHandle; + rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId; rmTransportCfg.remoteInstType = Rm_instType_SERVER; rmTransportCfg.remoteInstName = &rmServerName[0]; /* Set the callouts as valid for the first transport configuration on Client Delegate instance */ - rmTransportCfg.rmHandle = rmClientDelegateHandle; - rmTransportCfg.transportCalloutsValid = true; - rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc; - rmTransportCfg.transportCallouts.rmFreePkt = TransportFree; - rmTransportCfg.transportCallouts.rmSend = TransportSend; - rmTransportCfg.transportCallouts.rmReceive = TransportReceive; - rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; + rmTransportCfg.transportCalloutsValid = true; + rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc; + rmTransportCfg.transportCallouts.rmSendPkt = transportSend; cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result); /* Store the mapping information in the transport map */ rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle; - rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdServerMsgQ; - rmTransportMap[CD_TO_SERVER_MAP_ENTRY].remoteMsgQId = cdServerQId; + rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ; System_printf("Core %d: Registered RM CD <=> RM Server transport with RM CD instance\n", MultiProc_self()); /* Open the Client messageQ from the Client Delegate */ - do - { - status = MessageQ_open(clientCdQueueName, &cdClientQId); + do { + status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); System_printf("Core %d: RM Client MessageQ opened from RM CD\n", MultiProc_self()); /* Register the Client with the RM Client Delegate Instance */ + rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId; rmTransportCfg.remoteInstType = Rm_instType_CLIENT; rmTransportCfg.remoteInstName = &rmClientName[0]; /* Callouts already set on the Client Delegate so set them as invalid */ rmTransportCfg.transportCalloutsValid = false; - cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result); /* Store the mapping information in the transport map */ rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle; - rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdClientMsgQ; - rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].remoteMsgQId = cdClientQId; + rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ; System_printf("Core %d: Registered RM CD <=> RM Client transport with RM CD instance\n", MultiProc_self()); /* Open the Client Delegate messageQ from the Client */ - do - { - status = MessageQ_open(cdClientQueueName, &clientCdQId); + do { + status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); /* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */ - if (status < 0) - { + if (status < 0) { Task_sleep(1); } } while (status < 0); System_printf("Core %d: RM CD MessageQ opened from RM Client\n", MultiProc_self()); /* Register the Client Delegate with the RM Client Instance */ + rmTransportCfg.rmHandle = rmClientHandle; + rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId; rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE; rmTransportCfg.remoteInstName = &rmClientDelegateName[0]; /* Set the callouts as valid for the first transport configuration on Client instance */ - rmTransportCfg.rmHandle = rmClientHandle; rmTransportCfg.transportCalloutsValid = true; - rmTransportCfg.transportCallouts.rmAllocPkt = TransportAlloc; - rmTransportCfg.transportCallouts.rmFreePkt = TransportFree; - rmTransportCfg.transportCallouts.rmSend = TransportSend; - rmTransportCfg.transportCallouts.rmReceive = TransportReceive; - rmTransportCfg.transportCallouts.rmNumPktsReceived = TransportNumPktsReceived; - + rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc; + rmTransportCfg.transportCallouts.rmSendPkt = transportSend; clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result); /* Store the mapping information in the transport map */ rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle; - rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientCdMsgQ; - rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].remoteMsgQId = clientCdQId; + rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ; System_printf("Core %d: Registered RM Client <=> RM CD transport with RM Client instance\n", MultiProc_self()); } diff --git a/util/libfdt/fdt.h b/util/libfdt/fdt.h index 48ccfd9..4015e82 100644 --- a/util/libfdt/fdt.h +++ b/util/libfdt/fdt.h @@ -1,5 +1,55 @@ #ifndef _FDT_H #define _FDT_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef __ASSEMBLY__ diff --git a/util/libfdt/libfdt_env.h b/util/libfdt/libfdt_env.h index 449bf60..b71cef5 100644 --- a/util/libfdt/libfdt_env.h +++ b/util/libfdt/libfdt_env.h @@ -1,5 +1,55 @@ #ifndef _LIBFDT_ENV_H #define _LIBFDT_ENV_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include #include