e1b87868ce842f88fe250e2565a876cd942aa06a
[keystone-rtos/rm-lld.git] / test / src / rm_test.c
1 /*
2  *   rm_test.c
3  *
4  *   Multicore Resource Manager test that uses IPC to an application
5  *   requesting RM services from a RM Server, Client Delegate, and Client.
6  *
7  *  ============================================================================
8  *
9  * Copyright (c) 2012-2013, Texas Instruments Incorporated
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  *
16  * *  Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  *
19  * *  Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  *
23  * *  Neither the name of Texas Instruments Incorporated nor the names of
24  *    its contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
29  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  */
40  
41 /* Standard Includes */
42 #include <string.h>
44 /* XDC Includes */
45 #include <xdc/std.h>
46 #include <xdc/runtime/System.h>
48 /* IPC Includes */
49 #include <ti/ipc/Ipc.h>
50 #include <ti/ipc/MessageQ.h>
51 #include <ti/ipc/HeapBufMP.h>
52 #include <ti/ipc/GateMP.h>
54 /* BIOS Includes */
55 #include <ti/sysbios/BIOS.h>
56 #include <ti/sysbios/knl/Task.h>
57 #include <ti/sysbios/family/c64p/Hwi.h>
59 /* CSL Includes */
60 #include <ti/csl/csl_chip.h>
61 #include <ti/csl/csl_cacheAux.h>
62 #include <ti/csl/csl_xmcAux.h>
64 /* RM Includes */
65 #include <ti/drv/rm/rm.h>
66 #include <ti/drv/rm/rm_transport.h>
67 #include <ti/drv/rm/rm_services.h>
68 #include <ti/drv/rm/rm_osal.h>
70 /**********************************************************************
71  ************************** RM Test Symbols ***************************
72  **********************************************************************/
74 #define PRINT_USED_RESOURCES         0  /* Make 1 and rebuild project to print resources allocated in example */
76 #define SYSINIT                      0
77 #define NUM_CORES                    2
79 /* Test FALSE */
80 #define RM_TEST_FALSE                0
81 /* Test TRUE */
82 #define RM_TEST_TRUE                 1
84 /* IPC MessageQ heap name */
85 #define MSGQ_HEAP_NAME               "msgQHeapBuf"
86 /* IPC MessageQ heap ID */
87 #define MSGQ_HEAP_ID                 0
89 /* RM packet heap name */
90 #define RM_PKT_HEAP_NAME             "rmHeapBuf"
91 /* GateMP names used to synchronize the RM test tasks */
92 #define RM_SERVER_GATE_NAME          "rmServerGate"
93 #define RM_CLIENT_GATE_NAME          "rmClientGate"
95 /* Application's core 0 registered RM transport indices */
96 #define SERVER_TO_CD_MAP_ENTRY       0
97 /* Application's core 1 registered RM transport indices */
98 #define CD_TO_SERVER_MAP_ENTRY       0
99 #define CD_TO_CLIENT_MAP_ENTRY       1
100 #define CLIENT_TO_CD_MAP_ENTRY       2
101 /* Maximum number of registered RM transports */
102 #define MAX_MAPPING_ENTRIES          3
104 /* Size of RM static allocation response queue.  Must be greater than number of APPROVED
105  * static allocations */
106 #define MAX_STATIC_ALLOCATION_RESPS  5 
108 /* Size of RM service response queue */
109 #define MAX_QUEUED_SERVICE_RESPONSES 10
111 /* Error checking macro */
112 #define ERROR_CHECK(checkVal, resultVal, rmInstName, printMsg)                   \
113     if (resultVal != checkVal) {                                                 \
114         char errorMsgToPrint[] = printMsg;                                       \
115         System_printf("Error Core %d : %s : ", coreNum, rmInstName);             \
116         System_printf("%s with error code : %d\n", errorMsgToPrint, resultVal);  \
117         testErrors++;                                                            \
118         System_abort("Test Failure\n");                                          \
119     }
121 #define POSITIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check)  \
122     do {                                                                                            \
123         int32_t start = resStart;                                                                   \
124         int32_t alignment = align;                                                                  \
125         char    titleMsg[] = title;                                                                 \
126         System_printf ("Core %d : ---------------------------------------------------------\n",     \
127                        core);                                                                       \
128         System_printf ("Core %d : %s\n", core, titleMsg);                                           \
129         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);               \
130         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                \
131         if (start == RM_RESOURCE_BASE_UNSPECIFIED) {                                                \
132             System_printf ("Core %d : - Start:         UNSPECIFIED                            -\n", \
133                            core);                                                                   \
134             System_printf ("Core %d : - Length:        %-16d                       -\n",            \
135                            core, resLen);                                                           \
136         }                                                                                           \
137         else {                                                                                      \
138             System_printf ("Core %d : - Start:         %-16d                       -\n",            \
139                            core, resStart);                                                         \
140             System_printf ("Core %d : - End:           %-16d                       -\n", core,      \
141                            (start + resLen - 1));                                                   \
142         }                                                                                           \
143         if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {                                       \
144             System_printf ("Core %d : - Alignment:     UNSPECIFIED                            -\n", \
145                            core);                                                                   \
146         }                                                                                           \
147         else {                                                                                      \
148             System_printf ("Core %d : - Alignment:     %-16d                       -\n",            \
149                            core, alignment);                                                        \
150         }                                                                                           \
151         System_printf ("Core %d : -                                                       -\n",     \
152                        core);                                                                       \
153         if (state == check) {                                                                       \
154             System_printf ("Core %d : - PASSED                                                -\n", \
155                            core);                                                                   \
156         }                                                                                           \
157         else {                                                                                      \
158             System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",   \
159                            core, state);                                                            \
160             testErrors++;                                                                           \
161         }                                                                                           \
162         System_printf ("Core %d : ---------------------------------------------------------\n",     \
163                        core);                                                                       \
164         System_printf ("\n");                                                                       \
165     } while(0);
167 #define NEGATIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check)  \
168     do {                                                                                            \
169         int32_t start = resStart;                                                                   \
170         int32_t alignment = align;                                                                  \
171         char    titleMsg[] = title;                                                                 \
172         System_printf ("Core %d : ---------------------------------------------------------\n",     \
173                        core);                                                                       \
174         System_printf ("Core %d : %s\n", core, titleMsg);                                           \
175         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);               \
176         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                \
177         if (start == RM_RESOURCE_BASE_UNSPECIFIED) {                                                \
178             System_printf ("Core %d : - Start:         UNSPECIFIED                            -\n", \
179                            core);                                                                   \
180             System_printf ("Core %d : - Length:        %-16d                       -\n",            \
181                            core, resLen);                                                           \
182         }                                                                                           \
183         else {                                                                                      \
184             System_printf ("Core %d : - Start:         %-16d                       -\n",            \
185                            core, resStart);                                                         \
186             System_printf ("Core %d : - End:           %-16d                       -\n", core,      \
187                            (start + resLen - 1));                                                   \
188         }                                                                                           \
189         if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {                                       \
190             System_printf ("Core %d : - Alignment:     UNSPECIFIED                            -\n", \
191                            core);                                                                   \
192         }                                                                                           \
193         else {                                                                                      \
194             System_printf ("Core %d : - Alignment:     %-16d                       -\n",            \
195                            core, alignment);                                                        \
196         }                                                                                           \
197         System_printf ("Core %d : -                                                       -\n",     \
198                        core);                                                                       \
199         if (state != check) {                                                                       \
200             System_printf ("Core %d : - PASSED - Denial: %-6d                               -\n",   \
201                            core, state);                                                            \
202         }                                                                                           \
203         else {                                                                                      \
204             System_printf ("Core %d : - FAILED - Expected Denial                              -\n", \
205                            core);                                                                   \
206             testErrors++;                                                                           \
207         }                                                                                           \
208         System_printf ("Core %d : ---------------------------------------------------------\n",     \
209                        core);                                                                       \
210         System_printf ("\n");                                                                       \
211     } while(0);    
213 #define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
214     do {                                                                                                        \
215         int32_t start = resStart;                                                                               \
216         char    titleMsg[] = title;                                                                             \
217         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
218                        core);                                                                                   \
219         System_printf ("Core %d : %s\n", core, titleMsg);                                                       \
220         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);                           \
221         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                            \
222         System_printf ("Core %d : - Start:         %-16d                       -\n",                            \
223                            core, resStart);                                                                     \
224         System_printf ("Core %d : - End:           %-16d                       -\n", core,                      \
225                            (start + resLen - 1));                                                               \
226         System_printf ("Core %d : - Expected Owner Count: %-16d                -\n",                            \
227                        core, expectRefCnt);                                                                     \
228         System_printf ("Core %d : - Returned Owner Count: %-16d                -\n",                            \
229                        core, refCnt);                                                                           \
230         System_printf ("Core %d : -                                                       -\n", core);          \
231         if ((state == check) && (refCnt == expectRefCnt)) {                                                     \
232             System_printf ("Core %d : - PASSED                                                -\n", core);      \
233         }                                                                                                       \
234         else {                                                                                                  \
235             if (refCnt != expectRefCnt) {                                                                       \
236                 System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
237                                core);                                                                           \
238             }                                                                                                   \
239             else {                                                                                              \
240                 System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
241                                core, state);                                                                    \
242             }                                                                                                   \
243             testErrors++;                                                                                       \
244         }                                                                                                       \
245         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
246                        core);                                                                                   \
247         System_printf ("\n");                                                                                   \
248     } while(0);
250 /**********************************************************************
251  ********************** RM Test Data Structures ***********************
252  **********************************************************************/
254 /* IPC MessageQ RM packet encapsulation structure */
255 typedef struct {
256     /* IPC MessageQ header (must be first element in structure) */
257     MessageQ_MsgHeader  msgQHeader;
258     /* Pointer to RM packet */
259     Rm_Packet          *rmPkt;
260 } MsgQ_RmPacket;
262 /* RM registered transport mapping structure */
263 typedef struct {
264     /* Registered RM transport handle */
265     Rm_TransportHandle transportHandle;
266     /* MessageQ receive queue tied to the transport handle */
267     MessageQ_Handle    receiveMsgQ;
268 } Transport_MapEntry;
270 /**********************************************************************
271  ********************** Extern Variables ******************************
272  **********************************************************************/
274 /* Alloc and free OSAL variables */
275 extern uint32_t rmMallocCounter;
276 extern uint32_t rmFreeCounter;
278 /* RM test Global Resource List (GRL) */
279 extern const char rmGRL[];
280 /* Example Linux DTB file provided to RM Server for automatic Linux Kernel resource extraction */
281 extern const char rmLinuxDtb[];
282 /* RM test Global Policy provided to RM Server */
283 extern const char rmGlobalPolicy[];
284 /* RM test Static Policy provided to RM Client Delegate and Client */
285 extern const char rmStaticPolicy[];
287 /**********************************************************************
288  ********************** Global Variables ******************************
289  **********************************************************************/
291 /* DSP core number according to DNUM */
292 uint16_t            coreNum;
293 /* Number of errors that occurred during the test */
294 uint16_t            testErrors;
296 /* Task to configure application transport code for RM */
297 Task_Handle         rmStartupTskHandle;
298 /* High priority task for receiving RM packets */
299 Task_Handle         rmReceiveTskHandle;
300 /* RM server test task */
301 Task_Handle         rmServerTskHandle;
302 /* RM client delegate and client test task */
303 Task_Handle         rmClientTskHandle;
305 /* GateMPs used to synchronize tests between the two RM test tasks */
306 GateMP_Handle       serverGate = NULL;
307 GateMP_Handle       clientGate = NULL;
308 /* GateMP keys */
309 IArg                serverKey;
310 IArg                clientKey;
312 /* Handle for heap that RM packets will be allocated from */
313 HeapBufMP_Handle    rmPktHeapHandle = NULL;
315 /* MessageQ used by RM CD to send packets to RM Server */
316 char                serverFromCdQueueName[30] = "RM_Server_From_CD_Queue";
317 /* MessageQ used by RM Server to send packets to RM CD */
318 char                cdFromServerQueueName[30] = "RM_CD_From_Server_Queue";
319 /* MessageQ used by RM Client to send packets to RM CD */
320 char                cdFromClientQueueName[30] = "RM_CD_From_Client_Queue";
321 /* MessageQ used by RM CD to send packets to RM Client */
322 char                clientFromCdQueueName[30] = "RM_Client_From_CD_Queue";
324 /* RM Server instance name (must match with RM Global Resource List (GRL) and policies */
325 char                rmServerName[RM_NAME_MAX_CHARS] = "RM_Server";
326 /* RM CD instance name (must match with RM Global Resource List (GRL) and policies */
327 char                rmCdName[RM_NAME_MAX_CHARS]     = "RM_Client_Delegate";
328 /* RM Client instance name (must match with RM Global Resource List (GRL) and policies */
329 char                rmClientName[RM_NAME_MAX_CHARS] = "RM_Client";
331 /* RM instance handles */
332 Rm_Handle           rmServerHandle = NULL;
333 Rm_Handle           rmCdHandle     = NULL;
334 Rm_Handle           rmClientHandle = NULL;
336 /* RM instance service handles */
337 Rm_ServiceHandle   *rmServerServiceHandle = NULL;
338 Rm_ServiceHandle   *rmCdServiceHandle     = NULL;
339 Rm_ServiceHandle   *rmClientServiceHandle = NULL;
341 /* Transport map stores the RM transport handle to IPC MessageQ queue mapping */
342 Transport_MapEntry  rmTransportMap[MAX_MAPPING_ENTRIES];
344 /* Static allocation response queue */
345 Rm_ServiceRespInfo  staticResponseQueue[MAX_STATIC_ALLOCATION_RESPS];
346 /* Static allocation response queue index */
347 uint32_t            numStaticResponses;
349 /* RM response info queue used to store service responses received via the callback function */
350 Rm_ServiceRespInfo  responseInfoQueue[MAX_QUEUED_SERVICE_RESPONSES];
352 /* RM resource names (must match resource node names in GRL and policies */
353 char                resourceNameMemRegion[RM_NAME_MAX_CHARS]  = "memory-regions";
354 char                resourceNameAccumCh[RM_NAME_MAX_CHARS]    = "accumulator-ch";
355 char                resourceNameGpQ[RM_NAME_MAX_CHARS]        = "gp-queue";
356 char                resourceNameAifQ[RM_NAME_MAX_CHARS]       = "aif-queue";
357 char                resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
358 char                resourceNameAifRxCh[RM_NAME_MAX_CHARS]    = "aif-rx-ch";
359 char                resourceNameInfraQ[RM_NAME_MAX_CHARS]     = "infra-queue";
360 char                resourceNameLowPrioQ[RM_NAME_MAX_CHARS]   = "low-prio-queue";
362 /* Test RM NameServer name */
363 char                nameServerNameFavQ[RM_NAME_MAX_CHARS]     = "My_Favorite_Queue";
365 /**********************************************************************
366  *************************** Test Functions ***************************
367  **********************************************************************/
369 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
371     Rm_Packet     *rmPkt = NULL;
372     MsgQ_RmPacket *rmMsg = NULL;
374     /* Allocate a messageQ message for containing the RM packet */
375     rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
376     if (rmMsg == NULL) {
377         System_printf("Error Core %d : MessageQ_alloc failed to allocate message: %d\n", coreNum);
378         testErrors++;
379         *pktHandle = NULL;
380         return(NULL);
381     }
382     else {
383         /* Create and attach RM packet to MessageQ message.  All transports will allocate from the same heap */
384         rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
385         rmPkt->pktLenBytes = pktSize;
386         Osal_rmEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
387         rmMsg->rmPkt = rmPkt;
388         *pktHandle = (Rm_PacketHandle)rmMsg;
389     }
390     return (rmPkt);
393 void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
395     uint32_t pktSize = pkt->pktLenBytes;
396     int32_t  status;
398     /* All transports will free rmPkts to the same heap */
399     HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
401     status = MessageQ_free(rmMsgQMsg);
402     if (status < 0) { 
403         System_printf("Error Core %d : MessageQ_free failed to free message: %d\n", coreNum, status);
404         testErrors++;
405     }     
408 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
410     MessageQ_QueueId  remoteQueueId = (MessageQ_QueueId)appTransport;
411     MsgQ_RmPacket    *rmMsg = pktHandle;
412     int32_t           status;    
414     /* Write back data that was written by RM after alloc */
415     Osal_rmEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
417     /* Send the message to the remote side */
418     status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
419     if (status < 0) {
420         transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
421         System_printf("Error Core %d : MessageQ_put failed to send message: %d\n", coreNum, status);
422         testErrors++;
423     }
424     return (status);
427 void transportReceive (uint32_t transportMapEntry)
429     MessageQ_Handle  receiveQ;
430     int32_t          numPkts;
431     MessageQ_Msg     rmMsg = NULL;
432     Rm_Packet       *rmPkt = NULL;
433     int32_t          status;
434     uint32_t         i;  
436     /* Check if any packets available */
437     receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
438     numPkts = (int32_t) MessageQ_count(receiveQ);
440     /* Process all available packets */
441     for (i = 0; i < numPkts; i++) {
442         status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
443         if (rmMsg == NULL) {
444             System_printf("Error Core %d : MessageQ_get failed, returning a NULL packet\n", coreNum);
445             testErrors++;
446         }
448         /* Extract the Rm_Packet from the RM msg */
449         rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
450         Osal_rmBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
452         /* Provide packet to RM for processing */
453         if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
454             System_printf("Error Core %d : RM failed to process received packet: %d\n", coreNum, status);
455             testErrors++;
456         }
458         /* Free RM packet buffer and messageQ message */
459         transportFree(rmMsg, rmPkt);
460     }
463 void serviceCallback(Rm_ServiceRespInfo *serviceResponse)
465     uint32_t qIndex = 0;
466     
467     /* Populate next free entry in the responseInfoQueue */
468     while (responseInfoQueue[qIndex].serviceId != 0) {
469         qIndex++;
470         if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
471             qIndex = 0;
472         }
473     }
475     /* Save the response in the response queue for the test task to pick up */
476     memcpy((void *)&responseInfoQueue[qIndex], (void *)serviceResponse, sizeof(Rm_ServiceRespInfo));
479 void waitForResponse(Rm_ServiceRespInfo *respInfo)
481     uint32_t qIndex = 0;
483     if ((respInfo->serviceState == RM_SERVICE_PROCESSING) ||
484         (respInfo->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
485         /* Scan responseInfoQueue for the response received via the callback function */
486         while((responseInfoQueue[qIndex].serviceId != respInfo->serviceId) ||
487               (responseInfoQueue[qIndex].rmHandle != respInfo->rmHandle)) {
488             qIndex++;
489             if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
490                 qIndex = 0;
491             }
492             
493             /* Higher priority receive task will retrieve response */
494         }  
496         memcpy((void *)respInfo, (void *)&responseInfoQueue[qIndex], sizeof(Rm_ServiceRespInfo));
497         memset((void *)&responseInfoQueue[qIndex], 0, sizeof(Rm_ServiceRespInfo));
498     }
501 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
502                   uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
503 {                                                                                
504     memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));                                        
505     reqInfo->type = type;                                                                           
506     reqInfo->resourceName = resName;                                                                
507     reqInfo->resourceBase = resBase;                                                                
508     reqInfo->resourceLength = resLen;                                                               
509     reqInfo->resourceAlignment = resAlign;                                                          
510     reqInfo->resourceNsName = nsName;
511     if (setCallback) {
512         reqInfo->callback.serviceCallback = serviceCallback;  
513     }
514     memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));                                     
517 void rmCleanupTsk(UArg arg0, UArg arg1)
519     int32_t result;
520     int32_t finalMallocFree;    
521     
522     /* Delete the RM test tasks */
523     System_printf("Core %d : Deleting RM startup task...\n", coreNum);
524     if (rmStartupTskHandle) {
525        Task_delete(&rmStartupTskHandle);
526        /* Set the task handle to be NULL so that the delete only occurs once */
527        rmStartupTskHandle = NULL;
528     }  
529     
530     if (coreNum == SYSINIT) {
531         if (rmServerTskHandle) {
532             System_printf("Core %d : Deleting RM server task...\n", coreNum);
533             Task_delete(&rmServerTskHandle);
534             /* Set the task handle to be NULL so that the delete only occurs once */
535             rmServerTskHandle = NULL;
536         }
537     }
538     else {
539         if (rmClientTskHandle) {
540             System_printf("Core %d : Deleting RM client task...\n", coreNum);        
541             Task_delete(&rmClientTskHandle);
542             /* Set the task handle to be NULL so that the delete only occurs once */
543             rmClientTskHandle = NULL;
544         }
545     }
546     
547     /* Delete the RM receive task */
548     System_printf("Core %d : Deleting RM receive task...\n", coreNum);
549     if (rmReceiveTskHandle) {
550         Task_delete(&rmReceiveTskHandle);
551         /* Set the task handle to be NULL so that the delete only occurs once */
552         rmReceiveTskHandle = NULL;
553     }
555     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
556     if (coreNum == SYSINIT) {
557         result = Rm_serviceCloseHandle(rmServerServiceHandle);
558         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle close failed");
560         result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle);
561         ERROR_CHECK(RM_OK, result, rmServerName, "Unregister of CD transport failed");
563         result = Rm_delete(rmServerHandle, RM_TEST_TRUE);  
564         ERROR_CHECK(RM_OK, result, rmServerName, "Instance delete failed");
565     }
566     else {
567         result = Rm_serviceCloseHandle(rmCdServiceHandle);
568         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle close failed");
569         result = Rm_serviceCloseHandle(rmClientServiceHandle);
570         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
572         result = Rm_transportUnregister(rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle);
573         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Server transport failed");
574         result = Rm_transportUnregister(rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle);
575         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Client transport failed");
576         result = Rm_transportUnregister(rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle);
577         ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of CD transport failed");
579         result = Rm_delete(rmCdHandle, RM_TEST_TRUE);
580         ERROR_CHECK(RM_OK, result, rmCdName, "Instance delete failed");  
581         result = Rm_delete(rmClientHandle, RM_TEST_TRUE);
582         ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");         
583     }
585     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
586     System_printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
587     System_printf ("Core %d : -                       : malloc count   |   free count -\n", coreNum);
588     System_printf ("Core %d : - Example Completion    :  %6d        |  %6d      -\n", coreNum,
589                    rmMallocCounter, rmFreeCounter);
590     finalMallocFree = rmMallocCounter - rmFreeCounter; 
591     if (finalMallocFree > 0) {
592         System_printf ("Core %d : - FAILED - %6d unfreed mallocs                       -\n",
593                        coreNum, finalMallocFree);
594         testErrors++;
595     }
596     else if (finalMallocFree < 0) {
597         System_printf ("Core %d : - FAILED - %6d more frees than mallocs               -\n",
598                        coreNum, -finalMallocFree);
599         testErrors++;
600     }
601     else {
602         System_printf ("Core %d : - PASSED                                                -\n",
603                        coreNum);
604     }
605     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
606     System_printf ("\n");  
608     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
609     System_printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
610     if (testErrors) {
611         System_printf ("Core %d : - Test Errors: %-32d         -\n", coreNum, testErrors);
612     }
613     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
614     System_printf ("\n"); 
616     BIOS_exit(0);
619 /* Receive task has priority of 2 so that it pre-empts the RM instance test tasks */
620 void rmReceiveTsk(UArg arg0, UArg arg1)
622     while(1) {
623         if (coreNum == SYSINIT) {
624             transportReceive(SERVER_TO_CD_MAP_ENTRY);
625         }
626         else {
627             transportReceive(CD_TO_SERVER_MAP_ENTRY);
628             transportReceive(CD_TO_CLIENT_MAP_ENTRY);
629             transportReceive(CLIENT_TO_CD_MAP_ENTRY);
630         }
631         /* Sleep for 1ms so that the main test tasks can run */
632         Task_sleep(1);
633     }
636 void rmServerTsk(UArg arg0, UArg arg1)
638     Rm_ServiceReqInfo  requestInfo;
639     Rm_ServiceRespInfo responseInfo;
640     Task_Params        taskParams;
642     /* BEGIN testing UNSPECIFIED base and alignment requests on Server */               
643     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
644                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);       
645     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);                 
646     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
647                         coreNum, rmServerName, resourceNameGpQ,
648                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
649                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
650                
651     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
652                  RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
653     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
654     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
655                         coreNum, rmServerName, resourceNameGpQ,
656                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
657                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);      
659     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
660                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);     
661     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
662     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
663                         coreNum, rmServerName, resourceNameGpQ,
664                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
665                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);        
666     /* END testing UNSPECIFIED base and alignment requests on Server */      
668     /* Create new NameServer object */                
669     setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ, 
670                  1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
671     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
672     POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------", 
673                         coreNum, rmServerName, resourceNameGpQ,
674                         requestInfo.resourceBase, responseInfo.resourceLength, 
675                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
677     /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and 
678      * delete the NameServer object. */
679     GateMP_leave(serverGate, serverKey);
680     clientKey = GateMP_enter(clientGate);
681     GateMP_leave(clientGate, clientKey);
682     serverKey = GateMP_enter(serverGate);
684     /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
685     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion, 
686                  12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
687     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
688     NEGATIVE_PASS_CHECK("------- Use Allocation of Resource Owned by Linux -------", 
689                         coreNum, rmServerName, resourceNameMemRegion,
690                         requestInfo.resourceBase, requestInfo.resourceLength, 
691                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
693     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
694     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
695                  14, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);       
696     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
697     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
698                         coreNum, rmServerName, resourceNameAifRxCh,
699                         requestInfo.resourceBase, requestInfo.resourceLength, 
700                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
701     
702     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
703                  19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);      
704     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
705     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
706                         coreNum, rmServerName, resourceNameAifRxCh,
707                         requestInfo.resourceBase, requestInfo.resourceLength, 
708                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
709     
710     /* Wait for Client and Client Delegate to do their allocations */
711     GateMP_leave(serverGate, serverKey);
712     clientKey = GateMP_enter(clientGate);
713     GateMP_leave(clientGate, clientKey);
714     serverKey = GateMP_enter(serverGate);      
716     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
717                  25, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
718     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
719     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
720                         coreNum, rmServerName, resourceNameAifRxCh,
721                         requestInfo.resourceBase, requestInfo.resourceLength, 
722                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
723     
724     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
725                  34, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
726     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
727     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
728                         coreNum, rmServerName, resourceNameAifRxCh,
729                         requestInfo.resourceBase, requestInfo.resourceLength, 
730                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
731  
732     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
733                  28, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);      
734     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);   
735     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
736                         coreNum, rmServerName, resourceNameAifRxCh,
737                         requestInfo.resourceBase, requestInfo.resourceLength, 
738                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
740     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
741                  53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
742     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
743     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
744                         coreNum, rmServerName, resourceNameAifRxCh,
745                         requestInfo.resourceBase, requestInfo.resourceLength, 
746                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
747     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */  
748     
749     /* Test exclusive rights to an allocated resource */
750     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
751                  2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
752     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
753     NEGATIVE_PASS_CHECK("------ Use Allocation of Exclusively Owned Resource -----", 
754                         coreNum, rmServerName, resourceNameAifRxCh,
755                         requestInfo.resourceBase, requestInfo.resourceLength, 
756                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
758     /* Allocate small regions of general purpuse queues to prepare for CD local allocation testing */
759     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
760                  2100, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
761     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
762     POSITIVE_PASS_CHECK("-- Use Allocation Preparing for CD Local Alloc Testing --", 
763                         coreNum, rmServerName, resourceNameGpQ,
764                         responseInfo.resourceBase, responseInfo.resourceLength, 
765                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
767     /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates and CD testing */
768     GateMP_leave(serverGate, serverKey);
769     clientKey = GateMP_enter(clientGate);
770     GateMP_leave(clientGate, clientKey);
771     serverKey = GateMP_enter(serverGate);
773     /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
774      * should be approved but the instance should have only one owner instance in resource's owner list */
775     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
776                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
777     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
778     POSITIVE_PASS_CHECK("-- Init/Use Allocate of Resource from Same Inst (Init) --", 
779                         coreNum, rmServerName, resourceNameGpQ,
780                         requestInfo.resourceBase, requestInfo.resourceLength, 
781                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
783     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
784                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
785     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
786     POSITIVE_PASS_CHECK("--- Init/Use Allocate of Resource from Same Inst (Use) --", 
787                         coreNum, rmServerName, resourceNameGpQ,
788                         requestInfo.resourceBase, requestInfo.resourceLength, 
789                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
790     
791     /* Should take two frees to free both references */
792     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
793                  6543, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);      
794     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
795     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (1st Ref) -------", 
796                         coreNum, rmServerName, resourceNameGpQ,
797                         requestInfo.resourceBase, requestInfo.resourceLength, 
798                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
800     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
801                  6543, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
802     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
803     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (2nd Ref) -------", 
804                         coreNum, rmServerName, resourceNameGpQ,
805                         requestInfo.resourceBase, requestInfo.resourceLength, 
806                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
808     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
809     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
810                  805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
811     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
812     NEGATIVE_PASS_CHECK("- Init Allocation of Shared Linux and Client Resource  --", 
813                         coreNum, rmServerName, resourceNameInfraQ,
814                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
816     /* Get the status of a resource from Server */
817     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
818                  53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
819     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
820     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
821                       coreNum, rmServerName, responseInfo.resourceName,
822                       responseInfo.resourceBase, responseInfo.resourceLength, 
823                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
825     /* Get the status of a resource from Server */
826     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
827                  1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
828     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
829     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
830                       coreNum, rmServerName, responseInfo.resourceName,
831                       responseInfo.resourceBase, responseInfo.resourceLength, 
832                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
834     /* BEGIN Testing CD local allocation feature from Server */
835     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
836                  2051, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
837     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
838     POSITIVE_PASS_CHECK("--------- CD Testing: Allocate Use From Server ----------", 
839                         coreNum, rmServerName, resourceNameGpQ,
840                         responseInfo.resourceBase, responseInfo.resourceLength, 
841                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
842     /* END Testing CD local allocation feature from Server */
845 #if PRINT_USED_RESOURCES
846     Rm_resourceStatus(rmServerHandle, RM_TEST_TRUE);
847 #endif
849     /* Signal to ClientTsk that Server is ready for cleanup */
850     GateMP_leave(serverGate, serverKey);
851     
852     /* Create the RM cleanup task. */
853     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
854     Task_Params_init (&taskParams);
855     Task_create (rmCleanupTsk, &taskParams, NULL);
858 void rmClientTsk(UArg arg0, UArg arg1)
860     Rm_ServiceReqInfo  requestInfo;
861     Rm_ServiceRespInfo responseInfo;    
862     Task_Params        taskParams;
863     uint32_t           i, j;
865     serverKey = GateMP_enter(serverGate);  
867     /* Retrieve a resource via a NameServer name */
868     setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL, 
869                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
870     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
871     waitForResponse(&responseInfo); 
872     POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------", 
873                         coreNum, rmCdName, responseInfo.resourceName,
874                         responseInfo.resourceBase, responseInfo.resourceLength, 
875                         0, responseInfo.serviceState, RM_SERVICE_APPROVED);     
877     /* Allocate the resource returned from the NameServer request */
878     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo)); 
879     requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
880     requestInfo.resourceName = responseInfo.resourceName;
881     requestInfo.resourceBase = responseInfo.resourceBase;
882     requestInfo.resourceLength = responseInfo.resourceLength;
883     requestInfo.resourceNsName = NULL;
884     requestInfo.callback.serviceCallback = serviceCallback;     
885     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
886     waitForResponse(&responseInfo); 
887     POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------", 
888                         coreNum, rmClientName, responseInfo.resourceName,
889                         requestInfo.resourceBase, requestInfo.resourceLength, 
890                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
892     /* Retrieve the resource status via the NameServer name */
893     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL, 
894                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
895     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
896     waitForResponse(&responseInfo); 
897     STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----", 
898                       coreNum, rmClientName, responseInfo.resourceName,
899                       responseInfo.resourceBase, responseInfo.resourceLength, 
900                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);  
902     /* Free resource via a NameServer name */
903     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
904                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
905     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
906     waitForResponse(&responseInfo); 
907     POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----", 
908                         coreNum, rmClientName, nameServerNameFavQ,
909                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
911     /* Delete the NameServer name */
912     setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
913                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
914     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
915     waitForResponse(&responseInfo); 
916     POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------", 
917                         coreNum, rmClientName, nameServerNameFavQ,
918                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
920     GateMP_leave(clientGate, clientKey);
921     GateMP_leave(serverGate, serverKey);
922     clientKey = GateMP_enter(clientGate);
923     serverKey = GateMP_enter(serverGate);    
925     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
926     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
927                  0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);     
928     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
929     waitForResponse(&responseInfo);    
930     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
931                         coreNum, rmClientName, resourceNameAifRxCh,
932                         requestInfo.resourceBase, requestInfo.resourceLength, 
933                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
934     
935     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh, 
936                  50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);        
937     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
938     waitForResponse(&responseInfo);    
939     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -", 
940                         coreNum, rmCdName, resourceNameAifRxCh,
941                         requestInfo.resourceBase, requestInfo.resourceLength, 
942                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
943     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
945     GateMP_leave(clientGate, clientKey);
946     GateMP_leave(serverGate, serverKey);
947     clientKey = GateMP_enter(clientGate);
948     serverKey = GateMP_enter(serverGate);  
951     /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
952     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
953                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);        
954     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
955     waitForResponse(&responseInfo); 
956     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
957                         coreNum, rmCdName, resourceNameAccumCh,
958                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
959                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
961     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
962                  RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);      
963     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
964     waitForResponse(&responseInfo); 
965     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
966                         coreNum, rmClientName, resourceNameAccumCh,
967                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
968                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
970     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
971                  RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
972     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
973     waitForResponse(&responseInfo); 
974     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
975                         coreNum, rmClientName, resourceNameAccumCh,
976                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
977                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);     
978     /* END testing allocations with UNSPECIFIED base and alignment values */    
980     /* Allocate infrastructure queue shared between Linux kernel and Client */
981     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
982                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
983     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
984     waitForResponse(&responseInfo); 
985     POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --", 
986                         coreNum, rmClientName, resourceNameInfraQ,
987                         requestInfo.resourceBase, requestInfo.resourceLength, 
988                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
990     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
991      * is returned by the server. */
992     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
993                  7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
994     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
995     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
996                         coreNum, rmClientName, resourceNameGpQ,
997                         requestInfo.resourceBase, requestInfo.resourceLength, 
998                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1000     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1001                  7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1002     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1003     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1004                         coreNum, rmCdName, resourceNameGpQ,
1005                         requestInfo.resourceBase, requestInfo.resourceLength, 
1006                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1007     
1008     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1009                  7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1010     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1011     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1012                         coreNum, rmClientName, resourceNameGpQ,
1013                         requestInfo.resourceBase, requestInfo.resourceLength, 
1014                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1016     /* Init allocation of resource already owned by Client should return approved and there should only
1017      * be one instance of Client in resource's owner list. */
1018     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1019                  7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1020     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1021     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
1022                         coreNum, rmClientName, resourceNameGpQ,
1023                         requestInfo.resourceBase, requestInfo.resourceLength, 
1024                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1025     /* END Allocating some resources without providing a callback function.  RM should block and not return
1026      * until the result is returned by the Server. */   
1028     /* BEGIN Getting the status of resources from Client and CD */
1029     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1030                  7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1031     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1032     waitForResponse(&responseInfo);  
1033     STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -", 
1034                       coreNum, rmClientName, responseInfo.resourceName,
1035                       responseInfo.resourceBase, responseInfo.resourceLength, 
1036                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
1037     
1038     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1039                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1040     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1041     STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---", 
1042                       coreNum, rmClientName, responseInfo.resourceName,
1043                       responseInfo.resourceBase, responseInfo.resourceLength, 
1044                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);      
1046     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1047                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1048     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1049     waitForResponse(&responseInfo);     
1050     STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---", 
1051                       coreNum, rmCdName, responseInfo.resourceName,
1052                       responseInfo.resourceBase, responseInfo.resourceLength, 
1053                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
1055     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1056                  805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1057     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1058     STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----", 
1059                       coreNum, rmCdName, responseInfo.resourceName,
1060                       responseInfo.resourceBase, responseInfo.resourceLength, 
1061                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);   
1062     /* END Getting the status of resources from Client and CD */    
1064     /* BEGIN Testing CD local allocation feature */
1065     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1066                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1067     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1068     waitForResponse(&responseInfo);   
1069     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From CD (Non-Blocking) ----", 
1070                         coreNum, rmCdName, responseInfo.resourceName,
1071                         responseInfo.resourceBase, responseInfo.resourceLength, 
1072                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1073     
1074     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1075                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1076     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1077     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From CD (Blocking) ------", 
1078                         coreNum, rmCdName, responseInfo.resourceName,
1079                         responseInfo.resourceBase, responseInfo.resourceLength, 
1080                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1081     
1082     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1083                  RM_RESOURCE_BASE_UNSPECIFIED, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1084     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1085     waitForResponse(&responseInfo);    
1086     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From Client (Non-Blocking) ----", 
1087                         coreNum, rmClientName, responseInfo.resourceName,
1088                         responseInfo.resourceBase, responseInfo.resourceLength, 
1089                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1091     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1092                  RM_RESOURCE_BASE_UNSPECIFIED, 50, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1093     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1094     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From Client (Blocking) ------", 
1095                         coreNum, rmClientName, responseInfo.resourceName,
1096                         responseInfo.resourceBase, responseInfo.resourceLength, 
1097                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1099     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1100                  910, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1101     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1102     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Explicitly From Client ---", 
1103                         coreNum, rmClientName, responseInfo.resourceName,
1104                         responseInfo.resourceBase, responseInfo.resourceLength, 
1105                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1107     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1108                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1109     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1110     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Explicitly From CD -----", 
1111                         coreNum, rmCdName, responseInfo.resourceName,
1112                         responseInfo.resourceBase, responseInfo.resourceLength, 
1113                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1115     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1116                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1117     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1118     waitForResponse(&responseInfo); 
1119     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Unspecified From Client --", 
1120                         coreNum, rmClientName, responseInfo.resourceName,
1121                         responseInfo.resourceBase, responseInfo.resourceLength, 
1122                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1124     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1125                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1126     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1127     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Unspecified From CD ----", 
1128                         coreNum, rmCdName, responseInfo.resourceName,
1129                         responseInfo.resourceBase, responseInfo.resourceLength, 
1130                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1132     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1133                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 7, NULL, RM_TEST_FALSE, &responseInfo);     
1134     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1135     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res From Client For Sharing --", 
1136                         coreNum, rmClientName, responseInfo.resourceName,
1137                         RM_RESOURCE_BASE_UNSPECIFIED, responseInfo.resourceLength, 
1138                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1140     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1141                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1142     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1143     waitForResponse(&responseInfo); 
1144     STATUS_PASS_CHECK("----- Status Check of Resource Alloc'd Locally to CD ----", 
1145                       coreNum, rmCdName, responseInfo.resourceName,
1146                       responseInfo.resourceBase, responseInfo.resourceLength, 
1147                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1); 
1149     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1150                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1151     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1152     waitForResponse(&responseInfo); 
1153     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Shared Local Resource From CD ----", 
1154                         coreNum, rmCdName, responseInfo.resourceName,
1155                         responseInfo.resourceBase, responseInfo.resourceLength, 
1156                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1158     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1159                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1160     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1161     STATUS_PASS_CHECK("- Status Check of Res Alloc'd Locally to CD After Share -", 
1162                       coreNum, rmClientName, responseInfo.resourceName,
1163                       responseInfo.resourceBase, responseInfo.resourceLength, 
1164                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
1166     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1167                  900, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1168     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1169     waitForResponse(&responseInfo); 
1170     NEGATIVE_PASS_CHECK("-- Attempt Shared Alloc of Unshared Local CD Resourcee --", 
1171                         coreNum, rmClientName, responseInfo.resourceName,
1172                         responseInfo.resourceBase, responseInfo.resourceLength, 
1173                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1175     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameLowPrioQ, 
1176                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1177     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1178     waitForResponse(&responseInfo); 
1179     POSITIVE_PASS_CHECK("---- CD Testing: Free Shared Local Resource From CD -----", 
1180                         coreNum, rmCdName, responseInfo.resourceName,
1181                         responseInfo.resourceBase, responseInfo.resourceLength, 
1182                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1184     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameLowPrioQ, 
1185                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1186     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1187     waitForResponse(&responseInfo); 
1188     POSITIVE_PASS_CHECK("-- CD Testing: Free Shared Local Resource From Client ---", 
1189                         coreNum, rmClientName, responseInfo.resourceName,
1190                         responseInfo.resourceBase, responseInfo.resourceLength, 
1191                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1193     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1194                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1195     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1196     STATUS_PASS_CHECK("-- Status Check After Free of Locally Shared Resource ---", 
1197                       coreNum, rmClientName, responseInfo.resourceName,
1198                       responseInfo.resourceBase, responseInfo.resourceLength, 
1199                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);   
1201     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1202                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1203     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1204     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1205                         coreNum, rmCdName, responseInfo.resourceName,
1206                         responseInfo.resourceBase, responseInfo.resourceLength, 
1207                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED); 
1209     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1210                  898, 10, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1211     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1212     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1213                         coreNum, rmCdName, responseInfo.resourceName,
1214                         responseInfo.resourceBase, responseInfo.resourceLength, 
1215                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1217     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1218                  972, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1219     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1220     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1221                         coreNum, rmCdName, responseInfo.resourceName,
1222                         responseInfo.resourceBase, responseInfo.resourceLength, 
1223                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1225     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1226                  910, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1227     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1228     waitForResponse(&responseInfo); 
1229     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1230                         coreNum, rmClientName, responseInfo.resourceName,
1231                         responseInfo.resourceBase, responseInfo.resourceLength, 
1232                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1234     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1235                  914, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1236     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1237     waitForResponse(&responseInfo); 
1238     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1239                         coreNum, rmClientName, responseInfo.resourceName,
1240                         responseInfo.resourceBase, responseInfo.resourceLength, 
1241                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1243     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1244                  967, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1245     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1246     waitForResponse(&responseInfo); 
1247     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1248                         coreNum, rmClientName, responseInfo.resourceName,
1249                         responseInfo.resourceBase, responseInfo.resourceLength, 
1250                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1251     /* END Testing CD local allocation feature */ 
1254     /* Verify static allocations were validated.  Validation responses should have been received after the
1255      * first service requests were made on the Client and CD post transport path registration. */
1256     while (numStaticResponses > 0) {
1257         /* Loop until all static request validations have been received */
1258         for (i = 0; i < MAX_STATIC_ALLOCATION_RESPS; i++) {
1259             if (staticResponseQueue[i].serviceId != 0) {            
1260                 for (j = 0; j < MAX_QUEUED_SERVICE_RESPONSES; j++) {
1261                     if ((staticResponseQueue[i].serviceId == responseInfoQueue[j].serviceId) &&
1262                         (staticResponseQueue[i].rmHandle == responseInfoQueue[j].rmHandle)) {                   
1263                         POSITIVE_PASS_CHECK("------------- Static Allocation Validation --------------", 
1264                                             coreNum, rmClientName, responseInfoQueue[j].resourceName,
1265                                             responseInfoQueue[j].resourceBase, responseInfoQueue[j].resourceLength, 
1266                                             0, responseInfoQueue[j].serviceState, 
1267                                             RM_SERVICE_APPROVED); 
1268                         memset((void *)&staticResponseQueue[i], 0, sizeof(Rm_ServiceRespInfo));
1269                         memset((void *)&responseInfoQueue[j], 0, sizeof(Rm_ServiceRespInfo));
1270                         numStaticResponses--;                        
1271                         break;
1272                     }
1273                 }
1274             }
1275         }    
1276     }  
1278 #if PRINT_USED_RESOURCES
1279     Rm_resourceStatus(rmCdHandle, RM_TEST_TRUE);
1280 #endif
1282     GateMP_leave(clientGate, clientKey);
1283     GateMP_leave(serverGate, serverKey);
1284     clientKey = GateMP_enter(clientGate);
1285     /* Enter Server gate one last time to wait for Server to complete testing prior to entering cleanup */
1286     serverKey = GateMP_enter(serverGate);  
1287     
1288     /* Create the RM cleanup task. */
1289     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
1290     Task_Params_init (&taskParams);
1291     Task_create (rmCleanupTsk, &taskParams, NULL);
1294 void rmStartupTsk(UArg arg0, UArg arg1)
1296     MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
1297     MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
1298     Int                status, i;
1299     GateMP_Params      gateParams;    
1300     HeapBufMP_Handle   msgQHeapHandle;
1301     HeapBufMP_Params   heapBufParams;
1302     Rm_TransportCfg    rmTransportCfg;
1303     int32_t            result = 0;
1304     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
1305     Task_Params        taskParams;
1307     /* Initialize the transport map */
1308     for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
1309         rmTransportMap[i].transportHandle = NULL;
1310     } 
1312     if (coreNum == SYSINIT) {
1313         GateMP_Params_init(&gateParams);
1314         gateParams.name = RM_SERVER_GATE_NAME;
1315         /* Disable local protection since only concerned with sync'ing cores */
1316         gateParams.localProtect = GateMP_LocalProtect_NONE;
1317         serverGate = GateMP_create(&gateParams);
1319         serverKey = GateMP_enter(serverGate);  
1321         do {
1322             status = GateMP_open(RM_CLIENT_GATE_NAME, &clientGate);
1323             /* 
1324              *  Sleep for 1 clock tick to avoid inundating remote processor
1325              *  with interrupts if open failed
1326              */
1327             if (status < 0) { 
1328                 Task_sleep(1);
1329             }
1330         } while (status < 0);        
1331         
1332         /* Create the heap that will be used to allocate RM messages. This
1333          * heap is a multi-processor heap.  It will be shared amongst
1334          * all RM instances. */     
1335         HeapBufMP_Params_init(&heapBufParams);
1336         heapBufParams.regionId       = 0;
1337         heapBufParams.name           = RM_PKT_HEAP_NAME;
1338         heapBufParams.numBlocks      = 64;
1339         heapBufParams.blockSize      = sizeof(Rm_Packet);
1340         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
1341         if (rmPktHeapHandle == NULL) {
1342             System_printf("Error Core %d : Failed to create RM packet heap\n", coreNum);
1343             testErrors++;
1344         }
1345         System_printf("Core %d : RM packet heap created\n", coreNum);
1347         /* Create the heap that will be used to allocate messageQ messages. */     
1348         HeapBufMP_Params_init(&heapBufParams);
1349         heapBufParams.regionId       = 0;
1350         heapBufParams.name           = MSGQ_HEAP_NAME;
1351         heapBufParams.numBlocks      = 64;
1352         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
1353         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
1354         if (msgQHeapHandle == NULL) {
1355             System_printf("Error Core %d : Failed to create HeapBufMP MessageQ heap\n", coreNum);
1356             testErrors++;
1357         } 
1358         System_printf("Core %d : IPC MessageQ message heap created\n", coreNum);
1359     }
1360     else {
1361         GateMP_Params_init(&gateParams);
1362         gateParams.name = RM_CLIENT_GATE_NAME;
1363         /* Disable local protection since only concerned with sync'ing cores */
1364         gateParams.localProtect = GateMP_LocalProtect_NONE;
1365         clientGate = GateMP_create(&gateParams);
1367         clientKey = GateMP_enter(clientGate); 
1368         
1369         do {
1370             status = GateMP_open(RM_SERVER_GATE_NAME, &serverGate);
1371             /* 
1372              *  Sleep for 1 clock tick to avoid inundating remote processor
1373              *  with interrupts if open failed
1374              */
1375             if (status < 0) { 
1376                 Task_sleep(1);
1377             }
1378         } while (status < 0);
1379         
1380         /* Open the heaps created by the other processor. Loop until opened. */
1381         do {
1382             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
1383             /* 
1384              *  Sleep for 1 clock tick to avoid inundating remote processor
1385              *  with interrupts if open failed
1386              */
1387             if (status < 0) { 
1388                 Task_sleep(1);
1389             }
1390         } while (status < 0);
1391         System_printf("Core %d : RM packet heap opened\n", coreNum);
1392         
1393         do {
1394             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
1395             /* 
1396              *  Sleep for 1 clock tick to avoid inundating remote processor
1397              *  with interrupts if open failed
1398              */
1399             if (status < 0) { 
1400                 Task_sleep(1);
1401             }
1402         } while (status < 0);
1403         System_printf("Core %d : IPC MessageQ message heap opened\n", coreNum);
1404     }
1405     
1406     /* Register the MessageQ heap with MessageQ */
1407     MessageQ_registerHeap(msgQHeapHandle, MSGQ_HEAP_ID);
1409     /* Create the messageQ's for each RM instance connection
1410      * Need four queues.  Topology will be:
1411      * RM Server <---> RM Client Delegate <---> RM Client 
1412      * 1 queues on RM Server
1413      * 2 queues on RM Client Delegate
1414      * 1 queues on RM Client */
1415     if (coreNum == SYSINIT) {
1416         serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
1417         if (serverFromCdMsgQ == NULL) {
1418             System_printf("Error Core %d : Failed to create Server's receive Q for CD\n", coreNum);
1419             testErrors++;
1420         }
1421         System_printf("Core %d : Created Server receive Q for CD\n", coreNum);
1422     }
1423     else {
1424         cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
1425         if (cdFromServerMsgQ == NULL) {
1426             System_printf("Error Core %d : Failed to create CD's receive Q for Server\n", coreNum);
1427             testErrors++;
1428         }
1429         System_printf("Core %d : Created CD receive Q for Server\n", coreNum);
1430         
1431         cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
1432         if (cdFromClientMsgQ == NULL) {
1433             System_printf("Error Core %d : Failed to create CD's receive Q for Client\n", coreNum);
1434             testErrors++;
1435         } 
1436         System_printf("Core %d : Created CD receive Q for Client\n", coreNum);        
1437         
1438         clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
1439         if (clientFromCdMsgQ == NULL) {
1440             System_printf("Error Core %d : Failed to create Client's receive Q for CD\n", coreNum);
1441             testErrors++;
1442         }
1443         System_printf("Core %d : Created Client receive Q for CD\n", coreNum);
1444     }
1445     
1446     /* Open the remote message queues. Also register the RM transports with each RM instance */
1447     if (coreNum == SYSINIT) {
1448         /* Open the Client Delegate messageQ from the Server */
1449         do {
1450             status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
1451             /* 
1452              *  Sleep for 1 clock tick to avoid inundating remote processor
1453              *  with interrupts if open failed
1454              */
1455             if (status < 0) { 
1456                 Task_sleep(1);
1457             }
1458         } while (status < 0);
1459         System_printf("Core %d : RM CD MessageQ opened from RM Server\n", coreNum);
1461         /* Register the Client Delegate with the RM Server Instance */
1462         rmTransportCfg.rmHandle = rmServerHandle;
1463         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
1464         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1465         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1466         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1467         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1469         /* Store the mapping information in the transport map */
1470         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
1471         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
1472         System_printf("Core %d : Registered RM Server <=> RM CD transport with RM Server instance\n", coreNum);
1473     }
1474     else {
1475         /* Open the Server messageQ from the Client Delegate */
1476         do {
1477             status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
1478             /* 
1479              *  Sleep for 1 clock tick to avoid inundating remote processor
1480              *  with interrupts if open failed
1481              */
1482             if (status < 0) { 
1483                 Task_sleep(1);
1484             }
1485         } while (status < 0);
1486         System_printf("Core %d : RM Server MessageQ opened from RM CD\n", coreNum);
1488         /* Register the Server with the RM Client Delegate Instance */
1489         rmTransportCfg.rmHandle = rmCdHandle;
1490         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
1491         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
1492         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1493         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1494         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
1496         /* Store the mapping information in the transport map */
1497         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
1498         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
1499         System_printf("Core %d : Registered RM CD <=> RM Server transport with RM CD instance\n", coreNum);
1500         
1501         /* Open the Client messageQ from the Client Delegate */
1502         do {
1503             status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
1504             /* 
1505              *  Sleep for 1 clock tick to avoid inundating remote processor
1506              *  with interrupts if open failed
1507              */
1508             if (status < 0) { 
1509                 Task_sleep(1);
1510             }
1511         } while (status < 0);
1512         System_printf("Core %d : RM Client MessageQ opened from RM CD\n", coreNum);
1514         /* Register the Client with the RM Client Delegate Instance */
1515         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
1516         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
1517         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1518         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1519         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
1521         /* Store the mapping information in the transport map */
1522         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
1523         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
1524         System_printf("Core %d : Registered RM CD <=> RM Client transport with RM CD instance\n", coreNum);
1526         /* Open the Client Delegate messageQ from the Client */        
1527         do {
1528             status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
1529             /* 
1530              *  Sleep for 1 clock tick to avoid inundating remote processor
1531              *  with interrupts if open failed
1532              */
1533             if (status < 0) { 
1534                 Task_sleep(1);
1535             }
1536         } while (status < 0);
1537         System_printf("Core %d : RM CD MessageQ opened from RM Client\n", coreNum);
1539         /* Register the Client Delegate with the RM Client Instance */
1540         rmTransportCfg.rmHandle = rmClientHandle;
1541         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
1542         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1543         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1544         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1545         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1547         /* Store the mapping information in the transport map */
1548         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
1549         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
1550         System_printf("Core %d : Registered RM Client <=> RM CD transport with RM Client instance\n", coreNum);
1551     }
1553     /* Create the RM receive task.  Assign higher priority than the test tasks so that
1554      * when they spin waiting for messages from other RM instances the receive task is
1555      * executed. */
1556     System_printf("Core %d : Creating RM receive task...\n", coreNum);
1557     Task_Params_init (&taskParams);
1558     taskParams.priority = 2;
1559     rmReceiveTskHandle = Task_create (rmReceiveTsk, &taskParams, NULL);
1560     
1561     /* Create the RM test tasks. */
1562     if (coreNum == SYSINIT) {
1563         System_printf("Core %d : Creating RM server task...\n", coreNum);
1564         Task_Params_init (&taskParams);
1565         taskParams.priority = 1;
1566         rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
1567     }
1568     else if (coreNum) {
1569         System_printf("Core %d : Creating RM client task...\n", coreNum);
1570         Task_Params_init (&taskParams);
1571         taskParams.priority = 1;
1572         rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
1573     }
1576 int main(Int argc, Char* argv[])
1578     Rm_InitCfg         rmInitCfg;
1579     Task_Params        taskParams; 
1580     int                status;
1581     Rm_ServiceReqInfo  requestInfo;
1582     Rm_ServiceRespInfo responseInfo;
1583     int32_t            result;
1585     System_printf ("*********************************************************\n");
1586     System_printf ("********************** RM Testing ***********************\n");
1587     System_printf ("*********************************************************\n");
1589     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
1591     coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
1592     testErrors = 0;
1594     /* Initialize the RM instances - RM must be initialized before anything else in the system
1595      * Core 0: 1 RM Instance  - RM Server
1596      * Core 1: 2 RM Instances - RM Client Delegate
1597      *                          RM Client
1598      */
1599     if (coreNum == SYSINIT) {
1600         /* Create the Server instance */
1601         rmInitCfg.instName = rmServerName;
1602         rmInitCfg.instType = Rm_instType_SERVER;
1603         rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
1604         rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
1605         rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
1606         rmServerHandle = Rm_init(&rmInitCfg, &result);
1607         ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
1609         /* Open Server service handle */
1610         rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
1611         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
1612     }
1613     else {
1614         /* Create the RM Client Delegate instance */
1615         rmInitCfg.instName = rmCdName;
1616         rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
1617         rmInitCfg.instCfg.cdCfg.cdPolicy = (void *)rmGlobalPolicy;
1618         rmCdHandle = Rm_init(&rmInitCfg, &result);
1619         ERROR_CHECK(RM_WARNING_CD_INSTANCE_NOT_STABLE, result, rmCdName, "Initialization failed");
1621         /* Open CD service handle */
1622         rmCdServiceHandle = Rm_serviceOpenHandle(rmCdHandle, &result);
1623         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle open failed");
1625         /* Create the RM Client instance */
1626         rmInitCfg.instName = rmClientName;
1627         rmInitCfg.instType = Rm_instType_CLIENT;      
1628         rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)rmStaticPolicy;
1629         rmClientHandle = Rm_init(&rmInitCfg, &result);
1630         ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
1632         /* Open Client service handle */
1633         rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
1634         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
1636         /* Initialize the static allocation response queue */
1637         for (numStaticResponses = 0; numStaticResponses < MAX_STATIC_ALLOCATION_RESPS; numStaticResponses++) {
1638             memset((void *)&staticResponseQueue[numStaticResponses], 0, sizeof(Rm_ServiceRespInfo));
1639         }
1640         numStaticResponses = 0;
1642         /* Static allocation tests */
1643         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1644                      0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
1645         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);               
1646         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1647                             coreNum, rmCdName, resourceNameQosCluster,
1648                             requestInfo.resourceBase, requestInfo.resourceLength, 
1649                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1650         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1651             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1652         }        
1653         
1654         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1655                      2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1656         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1657         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1658                             coreNum, rmClientName, resourceNameQosCluster,
1659                             requestInfo.resourceBase, requestInfo.resourceLength, 
1660                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1661         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1662             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1663         }           
1665         /* Request resource from Client that can only be allocated to CD according to static policy */
1666         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1667                      1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1668         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1669         NEGATIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1670                             coreNum, rmClientName, resourceNameQosCluster,
1671                             requestInfo.resourceBase, requestInfo.resourceLength, 
1672                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);          
1674         /* Request resource from both Client and CD that is shared according to static policy */
1675         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1676                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1677         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1678         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1679                             coreNum, rmCdName, resourceNameAifQ,
1680                             requestInfo.resourceBase, requestInfo.resourceLength, 
1681                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1682         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1683             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1684         }           
1686         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1687                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1688         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1689         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1690                             coreNum, rmClientName, resourceNameAifQ,
1691                             requestInfo.resourceBase, requestInfo.resourceLength, 
1692                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1693         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1694             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1695         }           
1696     }
1698     System_printf("Core %d : Starting IPC...\n", coreNum);
1699     status = Ipc_start();
1700     if (status < 0) {
1701         System_abort("Ipc_start failed\n");
1702     }
1704     /* Create the RM startup task */
1705     System_printf("Core %d : Creating RM startup task...\n", coreNum);
1706     Task_Params_init (&taskParams);
1707     rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
1709     System_printf("Core %d : Starting BIOS...\n", coreNum);
1710     BIOS_start();
1712     return (0);