Resolved SDOCM00101586. Added test cases to cover resolved issued
[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";
361 char                resourceNamePassQ[RM_NAME_MAX_CHARS]      = "pass-queue";
363 /* Test RM NameServer name */
364 char                nameServerNameFavQ[RM_NAME_MAX_CHARS]     = "My_Favorite_Queue";
366 /**********************************************************************
367  *************************** Test Functions ***************************
368  **********************************************************************/
370 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
372     Rm_Packet     *rmPkt = NULL;
373     MsgQ_RmPacket *rmMsg = NULL;
375     /* Allocate a messageQ message for containing the RM packet */
376     rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
377     if (rmMsg == NULL) {
378         System_printf("Error Core %d : MessageQ_alloc failed to allocate message: %d\n", coreNum);
379         testErrors++;
380         *pktHandle = NULL;
381         return(NULL);
382     }
383     else {
384         /* Create and attach RM packet to MessageQ message.  All transports will allocate from the same heap */
385         rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
386         rmPkt->pktLenBytes = pktSize;
387         Osal_rmEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
388         rmMsg->rmPkt = rmPkt;
389         *pktHandle = (Rm_PacketHandle)rmMsg;
390     }
391     return (rmPkt);
394 void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
396     uint32_t pktSize = pkt->pktLenBytes;
397     int32_t  status;
399     /* All transports will free rmPkts to the same heap */
400     HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
402     status = MessageQ_free(rmMsgQMsg);
403     if (status < 0) { 
404         System_printf("Error Core %d : MessageQ_free failed to free message: %d\n", coreNum, status);
405         testErrors++;
406     }     
409 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
411     MessageQ_QueueId  remoteQueueId = (MessageQ_QueueId)appTransport;
412     MsgQ_RmPacket    *rmMsg = pktHandle;
413     int32_t           status;    
415     /* Write back data that was written by RM after alloc */
416     Osal_rmEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
418     /* Send the message to the remote side */
419     status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
420     if (status < 0) {
421         transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
422         System_printf("Error Core %d : MessageQ_put failed to send message: %d\n", coreNum, status);
423         testErrors++;
424     }
425     return (status);
428 void transportReceive (uint32_t transportMapEntry)
430     MessageQ_Handle  receiveQ;
431     int32_t          numPkts;
432     MessageQ_Msg     rmMsg = NULL;
433     Rm_Packet       *rmPkt = NULL;
434     int32_t          status;
435     uint32_t         i;  
437     /* Check if any packets available */
438     receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
439     numPkts = (int32_t) MessageQ_count(receiveQ);
441     /* Process all available packets */
442     for (i = 0; i < numPkts; i++) {
443         status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
444         if (rmMsg == NULL) {
445             System_printf("Error Core %d : MessageQ_get failed, returning a NULL packet\n", coreNum);
446             testErrors++;
447         }
449         /* Extract the Rm_Packet from the RM msg */
450         rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
451         Osal_rmBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
453         /* Provide packet to RM for processing */
454         if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
455             System_printf("Error Core %d : RM failed to process received packet: %d\n", coreNum, status);
456             testErrors++;
457         }
459         /* Free RM packet buffer and messageQ message */
460         transportFree(rmMsg, rmPkt);
461     }
464 void serviceCallback(Rm_ServiceRespInfo *serviceResponse)
466     uint32_t qIndex = 0;
467     
468     /* Populate next free entry in the responseInfoQueue */
469     while (responseInfoQueue[qIndex].serviceId != 0) {
470         qIndex++;
471         if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
472             qIndex = 0;
473         }
474     }
476     /* Save the response in the response queue for the test task to pick up */
477     memcpy((void *)&responseInfoQueue[qIndex], (void *)serviceResponse, sizeof(Rm_ServiceRespInfo));
480 void waitForResponse(Rm_ServiceRespInfo *respInfo)
482     uint32_t qIndex = 0;
484     if ((respInfo->serviceState == RM_SERVICE_PROCESSING) ||
485         (respInfo->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
486         /* Scan responseInfoQueue for the response received via the callback function */
487         while((responseInfoQueue[qIndex].serviceId != respInfo->serviceId) ||
488               (responseInfoQueue[qIndex].rmHandle != respInfo->rmHandle)) {
489             qIndex++;
490             if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
491                 qIndex = 0;
492             }
493             
494             /* Higher priority receive task will retrieve response */
495         }  
497         memcpy((void *)respInfo, (void *)&responseInfoQueue[qIndex], sizeof(Rm_ServiceRespInfo));
498         memset((void *)&responseInfoQueue[qIndex], 0, sizeof(Rm_ServiceRespInfo));
499     }
502 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
503                   uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
504 {                                                                                
505     memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));                                        
506     reqInfo->type = type;                                                                           
507     reqInfo->resourceName = resName;                                                                
508     reqInfo->resourceBase = resBase;                                                                
509     reqInfo->resourceLength = resLen;                                                               
510     reqInfo->resourceAlignment = resAlign;                                                          
511     reqInfo->resourceNsName = nsName;
512     if (setCallback) {
513         reqInfo->callback.serviceCallback = serviceCallback;  
514     }
515     memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));                                     
518 void rmCleanupTsk(UArg arg0, UArg arg1)
520     int32_t result;
521     int32_t finalMallocFree;    
522     
523     /* Delete the RM test tasks */
524     System_printf("Core %d : Deleting RM startup task...\n", coreNum);
525     if (rmStartupTskHandle) {
526        Task_delete(&rmStartupTskHandle);
527        /* Set the task handle to be NULL so that the delete only occurs once */
528        rmStartupTskHandle = NULL;
529     }  
530     
531     if (coreNum == SYSINIT) {
532         if (rmServerTskHandle) {
533             System_printf("Core %d : Deleting RM server task...\n", coreNum);
534             Task_delete(&rmServerTskHandle);
535             /* Set the task handle to be NULL so that the delete only occurs once */
536             rmServerTskHandle = NULL;
537         }
538     }
539     else {
540         if (rmClientTskHandle) {
541             System_printf("Core %d : Deleting RM client task...\n", coreNum);        
542             Task_delete(&rmClientTskHandle);
543             /* Set the task handle to be NULL so that the delete only occurs once */
544             rmClientTskHandle = NULL;
545         }
546     }
547     
548     /* Delete the RM receive task */
549     System_printf("Core %d : Deleting RM receive task...\n", coreNum);
550     if (rmReceiveTskHandle) {
551         Task_delete(&rmReceiveTskHandle);
552         /* Set the task handle to be NULL so that the delete only occurs once */
553         rmReceiveTskHandle = NULL;
554     }
556     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
557     if (coreNum == SYSINIT) {
558         result = Rm_serviceCloseHandle(rmServerServiceHandle);
559         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle close failed");
561         result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle);
562         ERROR_CHECK(RM_OK, result, rmServerName, "Unregister of CD transport failed");
564         result = Rm_delete(rmServerHandle, RM_TEST_TRUE);  
565         ERROR_CHECK(RM_OK, result, rmServerName, "Instance delete failed");
566     }
567     else {
568         result = Rm_serviceCloseHandle(rmCdServiceHandle);
569         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle close failed");
570         result = Rm_serviceCloseHandle(rmClientServiceHandle);
571         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
573         result = Rm_transportUnregister(rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle);
574         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Server transport failed");
575         result = Rm_transportUnregister(rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle);
576         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Client transport failed");
577         result = Rm_transportUnregister(rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle);
578         ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of CD transport failed");
580         result = Rm_delete(rmCdHandle, RM_TEST_TRUE);
581         ERROR_CHECK(RM_OK, result, rmCdName, "Instance delete failed");  
582         result = Rm_delete(rmClientHandle, RM_TEST_TRUE);
583         ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");         
584     }
586     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
587     System_printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
588     System_printf ("Core %d : -                       : malloc count   |   free count -\n", coreNum);
589     System_printf ("Core %d : - Example Completion    :  %6d        |  %6d      -\n", coreNum,
590                    rmMallocCounter, rmFreeCounter);
591     finalMallocFree = rmMallocCounter - rmFreeCounter; 
592     if (finalMallocFree > 0) {
593         System_printf ("Core %d : - FAILED - %6d unfreed mallocs                       -\n",
594                        coreNum, finalMallocFree);
595         testErrors++;
596     }
597     else if (finalMallocFree < 0) {
598         System_printf ("Core %d : - FAILED - %6d more frees than mallocs               -\n",
599                        coreNum, -finalMallocFree);
600         testErrors++;
601     }
602     else {
603         System_printf ("Core %d : - PASSED                                                -\n",
604                        coreNum);
605     }
606     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
607     System_printf ("\n");  
609     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
610     System_printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
611     if (testErrors) {
612         System_printf ("Core %d : - Test Errors: %-32d         -\n", coreNum, testErrors);
613     }
614     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
615     System_printf ("\n"); 
617     BIOS_exit(0);
620 /* Receive task has priority of 2 so that it pre-empts the RM instance test tasks */
621 void rmReceiveTsk(UArg arg0, UArg arg1)
623     while(1) {
624         if (coreNum == SYSINIT) {
625             transportReceive(SERVER_TO_CD_MAP_ENTRY);
626         }
627         else {
628             transportReceive(CD_TO_SERVER_MAP_ENTRY);
629             transportReceive(CD_TO_CLIENT_MAP_ENTRY);
630             transportReceive(CLIENT_TO_CD_MAP_ENTRY);
631         }
632         /* Sleep for 1ms so that the main test tasks can run */
633         Task_sleep(1);
634     }
637 void rmServerTsk(UArg arg0, UArg arg1)
639     Rm_ServiceReqInfo  requestInfo;
640     Rm_ServiceRespInfo responseInfo;
641     Task_Params        taskParams;
643     /* BEGIN testing UNSPECIFIED base and alignment requests on Server */               
644     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
645                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);       
646     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);                 
647     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
648                         coreNum, rmServerName, resourceNameGpQ,
649                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
650                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
651                
652     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
653                  RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
654     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
655     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
656                         coreNum, rmServerName, resourceNameGpQ,
657                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
658                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);      
660     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
661                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);     
662     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
663     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
664                         coreNum, rmServerName, resourceNameGpQ,
665                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
666                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
668     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNamePassQ, 
669                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
670     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
671     POSITIVE_PASS_CHECK("- UNSPECIFIED Allocation Avoiding Policy Denial (Part 1)-", 
672                         coreNum, rmServerName, resourceNameGpQ,
673                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
674                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
676     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNamePassQ, 
677                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
678     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
679     POSITIVE_PASS_CHECK("- UNSPECIFIED Allocation Avoiding Policy Denial (Part 2)-", 
680                         coreNum, rmServerName, resourceNameGpQ,
681                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
682                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
684     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNamePassQ, 
685                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
686     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
687     POSITIVE_PASS_CHECK("- UNSPECIFIED Allocation Avoiding Policy Denial (Part 3)-", 
688                         coreNum, rmServerName, resourceNameGpQ,
689                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
690                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
692     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNamePassQ, 
693                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
694     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
695     POSITIVE_PASS_CHECK("- UNSPECIFIED Allocation Avoiding Policy Denial (Part 4)-", 
696                         coreNum, rmServerName, resourceNameGpQ,
697                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
698                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
699     /* END testing UNSPECIFIED base and alignment requests on Server */      
701     /* Create new NameServer object */                
702     setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ, 
703                  1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
704     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
705     POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------", 
706                         coreNum, rmServerName, resourceNameGpQ,
707                         requestInfo.resourceBase, responseInfo.resourceLength, 
708                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
710     /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and 
711      * delete the NameServer object. */
712     GateMP_leave(serverGate, serverKey);
713     clientKey = GateMP_enter(clientGate);
714     GateMP_leave(clientGate, clientKey);
715     serverKey = GateMP_enter(serverGate);
717     /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
718     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion, 
719                  12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
720     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
721     NEGATIVE_PASS_CHECK("------- Use Allocation of Resource Owned by Linux -------", 
722                         coreNum, rmServerName, resourceNameMemRegion,
723                         requestInfo.resourceBase, requestInfo.resourceLength, 
724                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
726     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
727     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
728                  14, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);       
729     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
730     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
731                         coreNum, rmServerName, resourceNameAifRxCh,
732                         requestInfo.resourceBase, requestInfo.resourceLength, 
733                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
734     
735     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
736                  19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);      
737     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
738     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
739                         coreNum, rmServerName, resourceNameAifRxCh,
740                         requestInfo.resourceBase, requestInfo.resourceLength, 
741                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
742     
743     /* Wait for Client and Client Delegate to do their allocations */
744     GateMP_leave(serverGate, serverKey);
745     clientKey = GateMP_enter(clientGate);
746     GateMP_leave(clientGate, clientKey);
747     serverKey = GateMP_enter(serverGate);      
749     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
750                  25, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
751     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
752     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
753                         coreNum, rmServerName, resourceNameAifRxCh,
754                         requestInfo.resourceBase, requestInfo.resourceLength, 
755                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
756     
757     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
758                  34, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
759     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
760     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
761                         coreNum, rmServerName, resourceNameAifRxCh,
762                         requestInfo.resourceBase, requestInfo.resourceLength, 
763                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
764  
765     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
766                  28, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);      
767     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);   
768     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
769                         coreNum, rmServerName, resourceNameAifRxCh,
770                         requestInfo.resourceBase, requestInfo.resourceLength, 
771                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
773     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
774                  53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
775     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
776     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
777                         coreNum, rmServerName, resourceNameAifRxCh,
778                         requestInfo.resourceBase, requestInfo.resourceLength, 
779                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
780     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */  
781     
782     /* Test exclusive rights to an allocated resource */
783     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
784                  2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
785     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
786     NEGATIVE_PASS_CHECK("------ Use Allocation of Exclusively Owned Resource -----", 
787                         coreNum, rmServerName, resourceNameAifRxCh,
788                         requestInfo.resourceBase, requestInfo.resourceLength, 
789                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
791     /* Allocate small regions of general purpuse queues to prepare for CD local allocation testing */
792     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
793                  2100, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
794     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
795     POSITIVE_PASS_CHECK("-- Use Allocation Preparing for CD Local Alloc Testing --", 
796                         coreNum, rmServerName, resourceNameGpQ,
797                         responseInfo.resourceBase, responseInfo.resourceLength, 
798                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
800     /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates and CD testing */
801     GateMP_leave(serverGate, serverKey);
802     clientKey = GateMP_enter(clientGate);
803     GateMP_leave(clientGate, clientKey);
804     serverKey = GateMP_enter(serverGate);
806     /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
807      * should be approved but the instance should have only one owner instance in resource's owner list */
808     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
809                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
810     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
811     POSITIVE_PASS_CHECK("-- Init/Use Allocate of Resource from Same Inst (Init) --", 
812                         coreNum, rmServerName, resourceNameGpQ,
813                         requestInfo.resourceBase, requestInfo.resourceLength, 
814                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
816     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
817                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
818     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
819     POSITIVE_PASS_CHECK("--- Init/Use Allocate of Resource from Same Inst (Use) --", 
820                         coreNum, rmServerName, resourceNameGpQ,
821                         requestInfo.resourceBase, requestInfo.resourceLength, 
822                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
823     
824     /* Should take two frees to free both references */
825     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
826                  6543, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);      
827     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
828     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (1st Ref) -------", 
829                         coreNum, rmServerName, resourceNameGpQ,
830                         requestInfo.resourceBase, requestInfo.resourceLength, 
831                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
833     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
834                  6543, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
835     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
836     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (2nd Ref) -------", 
837                         coreNum, rmServerName, resourceNameGpQ,
838                         requestInfo.resourceBase, requestInfo.resourceLength, 
839                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
841     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
842     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
843                  805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
844     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
845     NEGATIVE_PASS_CHECK("- Init Allocation of Shared Linux and Client Resource  --", 
846                         coreNum, rmServerName, resourceNameInfraQ,
847                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
849     /* Get the status of a resource from Server */
850     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
851                  53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
852     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
853     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
854                       coreNum, rmServerName, responseInfo.resourceName,
855                       responseInfo.resourceBase, responseInfo.resourceLength, 
856                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
858     /* Get the status of a resource from Server */
859     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
860                  1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
861     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
862     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
863                       coreNum, rmServerName, responseInfo.resourceName,
864                       responseInfo.resourceBase, responseInfo.resourceLength, 
865                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
867     /* BEGIN Testing CD local allocation feature from Server */
868     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
869                  2051, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
870     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
871     POSITIVE_PASS_CHECK("--------- CD Testing: Allocate Use From Server ----------", 
872                         coreNum, rmServerName, resourceNameGpQ,
873                         responseInfo.resourceBase, responseInfo.resourceLength, 
874                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
875     /* END Testing CD local allocation feature from Server */
878 #if PRINT_USED_RESOURCES
879     Rm_resourceStatus(rmServerHandle, RM_TEST_TRUE);
880 #endif
882     /* Signal to ClientTsk that Server is ready for cleanup */
883     GateMP_leave(serverGate, serverKey);
884     
885     /* Create the RM cleanup task. */
886     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
887     Task_Params_init (&taskParams);
888     Task_create (rmCleanupTsk, &taskParams, NULL);
891 void rmClientTsk(UArg arg0, UArg arg1)
893     Rm_ServiceReqInfo  requestInfo;
894     Rm_ServiceRespInfo responseInfo;    
895     Task_Params        taskParams;
896     uint32_t           i, j;
898     serverKey = GateMP_enter(serverGate);  
900     /* Retrieve a resource via a NameServer name */
901     setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL, 
902                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
903     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
904     waitForResponse(&responseInfo); 
905     POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------", 
906                         coreNum, rmCdName, responseInfo.resourceName,
907                         responseInfo.resourceBase, responseInfo.resourceLength, 
908                         0, responseInfo.serviceState, RM_SERVICE_APPROVED);     
910     /* Allocate the resource returned from the NameServer request */
911     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo)); 
912     requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
913     requestInfo.resourceName = responseInfo.resourceName;
914     requestInfo.resourceBase = responseInfo.resourceBase;
915     requestInfo.resourceLength = responseInfo.resourceLength;
916     requestInfo.resourceNsName = NULL;
917     requestInfo.callback.serviceCallback = serviceCallback;     
918     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
919     waitForResponse(&responseInfo); 
920     POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------", 
921                         coreNum, rmClientName, responseInfo.resourceName,
922                         requestInfo.resourceBase, requestInfo.resourceLength, 
923                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
925     /* Retrieve the resource status via the NameServer name */
926     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL, 
927                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
928     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
929     waitForResponse(&responseInfo); 
930     STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----", 
931                       coreNum, rmClientName, responseInfo.resourceName,
932                       responseInfo.resourceBase, responseInfo.resourceLength, 
933                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);  
935     /* Free resource via a NameServer name */
936     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
937                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
938     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
939     waitForResponse(&responseInfo); 
940     POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----", 
941                         coreNum, rmClientName, nameServerNameFavQ,
942                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
944     /* Delete the NameServer name */
945     setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
946                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
947     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
948     waitForResponse(&responseInfo); 
949     POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------", 
950                         coreNum, rmClientName, nameServerNameFavQ,
951                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
953     GateMP_leave(clientGate, clientKey);
954     GateMP_leave(serverGate, serverKey);
955     clientKey = GateMP_enter(clientGate);
956     serverKey = GateMP_enter(serverGate);    
958     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
959     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
960                  0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);     
961     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
962     waitForResponse(&responseInfo);    
963     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
964                         coreNum, rmClientName, resourceNameAifRxCh,
965                         requestInfo.resourceBase, requestInfo.resourceLength, 
966                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
967     
968     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh, 
969                  50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);        
970     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
971     waitForResponse(&responseInfo);    
972     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -", 
973                         coreNum, rmCdName, resourceNameAifRxCh,
974                         requestInfo.resourceBase, requestInfo.resourceLength, 
975                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
976     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
978     GateMP_leave(clientGate, clientKey);
979     GateMP_leave(serverGate, serverKey);
980     clientKey = GateMP_enter(clientGate);
981     serverKey = GateMP_enter(serverGate);  
984     /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
985     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
986                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);        
987     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
988     waitForResponse(&responseInfo); 
989     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
990                         coreNum, rmCdName, resourceNameAccumCh,
991                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
992                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
994     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
995                  RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);      
996     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
997     waitForResponse(&responseInfo); 
998     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
999                         coreNum, rmClientName, resourceNameAccumCh,
1000                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
1001                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1003     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
1004                  RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
1005     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1006     waitForResponse(&responseInfo); 
1007     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
1008                         coreNum, rmClientName, resourceNameAccumCh,
1009                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
1010                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1011     /* END testing allocations with UNSPECIFIED base and alignment values */    
1013     /* Allocate infrastructure queue shared between Linux kernel and Client */
1014     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
1015                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1016     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1017     waitForResponse(&responseInfo); 
1018     POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --", 
1019                         coreNum, rmClientName, resourceNameInfraQ,
1020                         requestInfo.resourceBase, requestInfo.resourceLength, 
1021                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1023     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
1024      * is returned by the server. */
1025     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1026                  7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1027     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1028     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
1029                         coreNum, rmClientName, resourceNameGpQ,
1030                         requestInfo.resourceBase, requestInfo.resourceLength, 
1031                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1033     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1034                  7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1035     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1036     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1037                         coreNum, rmCdName, resourceNameGpQ,
1038                         requestInfo.resourceBase, requestInfo.resourceLength, 
1039                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1040     
1041     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1042                  7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1043     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1044     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1045                         coreNum, rmClientName, resourceNameGpQ,
1046                         requestInfo.resourceBase, requestInfo.resourceLength, 
1047                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1049     /* Init allocation of resource already owned by Client should return approved and there should only
1050      * be one instance of Client in resource's owner list. */
1051     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1052                  7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1053     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1054     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
1055                         coreNum, rmClientName, resourceNameGpQ,
1056                         requestInfo.resourceBase, requestInfo.resourceLength, 
1057                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1058     /* END Allocating some resources without providing a callback function.  RM should block and not return
1059      * until the result is returned by the Server. */   
1061     /* BEGIN Getting the status of resources from Client and CD */
1062     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1063                  7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1064     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1065     waitForResponse(&responseInfo);  
1066     STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -", 
1067                       coreNum, rmClientName, responseInfo.resourceName,
1068                       responseInfo.resourceBase, responseInfo.resourceLength, 
1069                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
1070     
1071     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1072                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1073     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1074     STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---", 
1075                       coreNum, rmClientName, responseInfo.resourceName,
1076                       responseInfo.resourceBase, responseInfo.resourceLength, 
1077                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);      
1079     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1080                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1081     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1082     waitForResponse(&responseInfo);     
1083     STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---", 
1084                       coreNum, rmCdName, responseInfo.resourceName,
1085                       responseInfo.resourceBase, responseInfo.resourceLength, 
1086                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
1088     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1089                  805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1090     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1091     STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----", 
1092                       coreNum, rmCdName, responseInfo.resourceName,
1093                       responseInfo.resourceBase, responseInfo.resourceLength, 
1094                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);   
1095     /* END Getting the status of resources from Client and CD */    
1097     /* BEGIN Testing CD local allocation feature */
1098     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1099                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1100     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1101     waitForResponse(&responseInfo);   
1102     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From CD (Non-Blocking) ----", 
1103                         coreNum, rmCdName, responseInfo.resourceName,
1104                         responseInfo.resourceBase, responseInfo.resourceLength, 
1105                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1106     
1107     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1108                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1109     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1110     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From CD (Blocking) ------", 
1111                         coreNum, rmCdName, responseInfo.resourceName,
1112                         responseInfo.resourceBase, responseInfo.resourceLength, 
1113                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1114     
1115     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1116                  RM_RESOURCE_BASE_UNSPECIFIED, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1117     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1118     waitForResponse(&responseInfo);    
1119     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From Client (Non-Blocking) ----", 
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, 50, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1126     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1127     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From Client (Blocking) ------", 
1128                         coreNum, rmClientName, responseInfo.resourceName,
1129                         responseInfo.resourceBase, responseInfo.resourceLength, 
1130                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1132     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1133                  910, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1134     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1135     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Explicitly From Client ---", 
1136                         coreNum, rmClientName, responseInfo.resourceName,
1137                         responseInfo.resourceBase, responseInfo.resourceLength, 
1138                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1140     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1141                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1142     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1143     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Explicitly From CD -----", 
1144                         coreNum, rmCdName, responseInfo.resourceName,
1145                         responseInfo.resourceBase, responseInfo.resourceLength, 
1146                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1148     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1149                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1150     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1151     waitForResponse(&responseInfo); 
1152     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Unspecified From Client --", 
1153                         coreNum, rmClientName, responseInfo.resourceName,
1154                         responseInfo.resourceBase, responseInfo.resourceLength, 
1155                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1157     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1158                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1159     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1160     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Unspecified From CD ----", 
1161                         coreNum, rmCdName, responseInfo.resourceName,
1162                         responseInfo.resourceBase, responseInfo.resourceLength, 
1163                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1165     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1166                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 7, NULL, RM_TEST_FALSE, &responseInfo);     
1167     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1168     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res From Client For Sharing --", 
1169                         coreNum, rmClientName, responseInfo.resourceName,
1170                         RM_RESOURCE_BASE_UNSPECIFIED, responseInfo.resourceLength, 
1171                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1173     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1174                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1175     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1176     waitForResponse(&responseInfo); 
1177     STATUS_PASS_CHECK("----- Status Check of Resource Alloc'd Locally to CD ----", 
1178                       coreNum, rmCdName, responseInfo.resourceName,
1179                       responseInfo.resourceBase, responseInfo.resourceLength, 
1180                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1); 
1182     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1183                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1184     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1185     waitForResponse(&responseInfo); 
1186     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Shared Local Resource From CD ----", 
1187                         coreNum, rmCdName, responseInfo.resourceName,
1188                         responseInfo.resourceBase, responseInfo.resourceLength, 
1189                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1191     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1192                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1193     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1194     STATUS_PASS_CHECK("- Status Check of Res Alloc'd Locally to CD After Share -", 
1195                       coreNum, rmClientName, responseInfo.resourceName,
1196                       responseInfo.resourceBase, responseInfo.resourceLength, 
1197                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);
1199     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1200                  900, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1201     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1202     waitForResponse(&responseInfo); 
1203     NEGATIVE_PASS_CHECK("-- Attempt Shared Alloc of Unshared Local CD Resourcee --", 
1204                         coreNum, rmClientName, responseInfo.resourceName,
1205                         responseInfo.resourceBase, responseInfo.resourceLength, 
1206                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1208     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameLowPrioQ, 
1209                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1210     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1211     waitForResponse(&responseInfo); 
1212     POSITIVE_PASS_CHECK("---- CD Testing: Free Shared 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, resourceNameLowPrioQ, 
1218                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1219     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1220     waitForResponse(&responseInfo); 
1221     POSITIVE_PASS_CHECK("-- CD Testing: Free Shared Local Resource From Client ---", 
1222                         coreNum, rmClientName, responseInfo.resourceName,
1223                         responseInfo.resourceBase, responseInfo.resourceLength, 
1224                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1226     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1227                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1228     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1229     STATUS_PASS_CHECK("-- Status Check After Free of Locally Shared Resource ---", 
1230                       coreNum, rmClientName, responseInfo.resourceName,
1231                       responseInfo.resourceBase, responseInfo.resourceLength, 
1232                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);   
1234     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1235                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1236     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1237     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1238                         coreNum, rmCdName, responseInfo.resourceName,
1239                         responseInfo.resourceBase, responseInfo.resourceLength, 
1240                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED); 
1242     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1243                  898, 10, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1244     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1245     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1246                         coreNum, rmCdName, responseInfo.resourceName,
1247                         responseInfo.resourceBase, responseInfo.resourceLength, 
1248                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1250     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1251                  972, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1252     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1253     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1254                         coreNum, rmCdName, responseInfo.resourceName,
1255                         responseInfo.resourceBase, responseInfo.resourceLength, 
1256                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1258     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1259                  910, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1260     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1261     waitForResponse(&responseInfo); 
1262     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1263                         coreNum, rmClientName, responseInfo.resourceName,
1264                         responseInfo.resourceBase, responseInfo.resourceLength, 
1265                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1267     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1268                  914, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1269     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1270     waitForResponse(&responseInfo); 
1271     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1272                         coreNum, rmClientName, responseInfo.resourceName,
1273                         responseInfo.resourceBase, responseInfo.resourceLength, 
1274                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1276     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1277                  967, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1278     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1279     waitForResponse(&responseInfo); 
1280     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1281                         coreNum, rmClientName, responseInfo.resourceName,
1282                         responseInfo.resourceBase, responseInfo.resourceLength, 
1283                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1284     /* END Testing CD local allocation feature */ 
1287     /* Verify static allocations were validated.  Validation responses should have been received after the
1288      * first service requests were made on the Client and CD post transport path registration. */
1289     while (numStaticResponses > 0) {
1290         /* Loop until all static request validations have been received */
1291         for (i = 0; i < MAX_STATIC_ALLOCATION_RESPS; i++) {
1292             if (staticResponseQueue[i].serviceId != 0) {            
1293                 for (j = 0; j < MAX_QUEUED_SERVICE_RESPONSES; j++) {
1294                     if ((staticResponseQueue[i].serviceId == responseInfoQueue[j].serviceId) &&
1295                         (staticResponseQueue[i].rmHandle == responseInfoQueue[j].rmHandle)) {                   
1296                         POSITIVE_PASS_CHECK("------------- Static Allocation Validation --------------", 
1297                                             coreNum, rmClientName, responseInfoQueue[j].resourceName,
1298                                             responseInfoQueue[j].resourceBase, responseInfoQueue[j].resourceLength, 
1299                                             0, responseInfoQueue[j].serviceState, 
1300                                             RM_SERVICE_APPROVED); 
1301                         memset((void *)&staticResponseQueue[i], 0, sizeof(Rm_ServiceRespInfo));
1302                         memset((void *)&responseInfoQueue[j], 0, sizeof(Rm_ServiceRespInfo));
1303                         numStaticResponses--;                        
1304                         break;
1305                     }
1306                 }
1307             }
1308         }    
1309     }  
1311 #if PRINT_USED_RESOURCES
1312     Rm_resourceStatus(rmCdHandle, RM_TEST_TRUE);
1313 #endif
1315     GateMP_leave(clientGate, clientKey);
1316     GateMP_leave(serverGate, serverKey);
1317     clientKey = GateMP_enter(clientGate);
1318     /* Enter Server gate one last time to wait for Server to complete testing prior to entering cleanup */
1319     serverKey = GateMP_enter(serverGate);  
1320     
1321     /* Create the RM cleanup task. */
1322     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
1323     Task_Params_init (&taskParams);
1324     Task_create (rmCleanupTsk, &taskParams, NULL);
1327 void rmStartupTsk(UArg arg0, UArg arg1)
1329     MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
1330     MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
1331     Int                status, i;
1332     GateMP_Params      gateParams;    
1333     HeapBufMP_Handle   msgQHeapHandle;
1334     HeapBufMP_Params   heapBufParams;
1335     Rm_TransportCfg    rmTransportCfg;
1336     int32_t            result = 0;
1337     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
1338     Task_Params        taskParams;
1340     /* Initialize the transport map */
1341     for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
1342         rmTransportMap[i].transportHandle = NULL;
1343     } 
1345     if (coreNum == SYSINIT) {
1346         GateMP_Params_init(&gateParams);
1347         gateParams.name = RM_SERVER_GATE_NAME;
1348         /* Disable local protection since only concerned with sync'ing cores */
1349         gateParams.localProtect = GateMP_LocalProtect_NONE;
1350         serverGate = GateMP_create(&gateParams);
1352         serverKey = GateMP_enter(serverGate);  
1354         do {
1355             status = GateMP_open(RM_CLIENT_GATE_NAME, &clientGate);
1356             /* 
1357              *  Sleep for 1 clock tick to avoid inundating remote processor
1358              *  with interrupts if open failed
1359              */
1360             if (status < 0) { 
1361                 Task_sleep(1);
1362             }
1363         } while (status < 0);        
1364         
1365         /* Create the heap that will be used to allocate RM messages. This
1366          * heap is a multi-processor heap.  It will be shared amongst
1367          * all RM instances. */     
1368         HeapBufMP_Params_init(&heapBufParams);
1369         heapBufParams.regionId       = 0;
1370         heapBufParams.name           = RM_PKT_HEAP_NAME;
1371         heapBufParams.numBlocks      = 64;
1372         heapBufParams.blockSize      = sizeof(Rm_Packet);
1373         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
1374         if (rmPktHeapHandle == NULL) {
1375             System_printf("Error Core %d : Failed to create RM packet heap\n", coreNum);
1376             testErrors++;
1377         }
1378         System_printf("Core %d : RM packet heap created\n", coreNum);
1380         /* Create the heap that will be used to allocate messageQ messages. */     
1381         HeapBufMP_Params_init(&heapBufParams);
1382         heapBufParams.regionId       = 0;
1383         heapBufParams.name           = MSGQ_HEAP_NAME;
1384         heapBufParams.numBlocks      = 64;
1385         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
1386         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
1387         if (msgQHeapHandle == NULL) {
1388             System_printf("Error Core %d : Failed to create HeapBufMP MessageQ heap\n", coreNum);
1389             testErrors++;
1390         } 
1391         System_printf("Core %d : IPC MessageQ message heap created\n", coreNum);
1392     }
1393     else {
1394         GateMP_Params_init(&gateParams);
1395         gateParams.name = RM_CLIENT_GATE_NAME;
1396         /* Disable local protection since only concerned with sync'ing cores */
1397         gateParams.localProtect = GateMP_LocalProtect_NONE;
1398         clientGate = GateMP_create(&gateParams);
1400         clientKey = GateMP_enter(clientGate); 
1401         
1402         do {
1403             status = GateMP_open(RM_SERVER_GATE_NAME, &serverGate);
1404             /* 
1405              *  Sleep for 1 clock tick to avoid inundating remote processor
1406              *  with interrupts if open failed
1407              */
1408             if (status < 0) { 
1409                 Task_sleep(1);
1410             }
1411         } while (status < 0);
1412         
1413         /* Open the heaps created by the other processor. Loop until opened. */
1414         do {
1415             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
1416             /* 
1417              *  Sleep for 1 clock tick to avoid inundating remote processor
1418              *  with interrupts if open failed
1419              */
1420             if (status < 0) { 
1421                 Task_sleep(1);
1422             }
1423         } while (status < 0);
1424         System_printf("Core %d : RM packet heap opened\n", coreNum);
1425         
1426         do {
1427             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
1428             /* 
1429              *  Sleep for 1 clock tick to avoid inundating remote processor
1430              *  with interrupts if open failed
1431              */
1432             if (status < 0) { 
1433                 Task_sleep(1);
1434             }
1435         } while (status < 0);
1436         System_printf("Core %d : IPC MessageQ message heap opened\n", coreNum);
1437     }
1438     
1439     /* Register the MessageQ heap with MessageQ */
1440     MessageQ_registerHeap(msgQHeapHandle, MSGQ_HEAP_ID);
1442     /* Create the messageQ's for each RM instance connection
1443      * Need four queues.  Topology will be:
1444      * RM Server <---> RM Client Delegate <---> RM Client 
1445      * 1 queues on RM Server
1446      * 2 queues on RM Client Delegate
1447      * 1 queues on RM Client */
1448     if (coreNum == SYSINIT) {
1449         serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
1450         if (serverFromCdMsgQ == NULL) {
1451             System_printf("Error Core %d : Failed to create Server's receive Q for CD\n", coreNum);
1452             testErrors++;
1453         }
1454         System_printf("Core %d : Created Server receive Q for CD\n", coreNum);
1455     }
1456     else {
1457         cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
1458         if (cdFromServerMsgQ == NULL) {
1459             System_printf("Error Core %d : Failed to create CD's receive Q for Server\n", coreNum);
1460             testErrors++;
1461         }
1462         System_printf("Core %d : Created CD receive Q for Server\n", coreNum);
1463         
1464         cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
1465         if (cdFromClientMsgQ == NULL) {
1466             System_printf("Error Core %d : Failed to create CD's receive Q for Client\n", coreNum);
1467             testErrors++;
1468         } 
1469         System_printf("Core %d : Created CD receive Q for Client\n", coreNum);        
1470         
1471         clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
1472         if (clientFromCdMsgQ == NULL) {
1473             System_printf("Error Core %d : Failed to create Client's receive Q for CD\n", coreNum);
1474             testErrors++;
1475         }
1476         System_printf("Core %d : Created Client receive Q for CD\n", coreNum);
1477     }
1478     
1479     /* Open the remote message queues. Also register the RM transports with each RM instance */
1480     if (coreNum == SYSINIT) {
1481         /* Open the Client Delegate messageQ from the Server */
1482         do {
1483             status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
1484             /* 
1485              *  Sleep for 1 clock tick to avoid inundating remote processor
1486              *  with interrupts if open failed
1487              */
1488             if (status < 0) { 
1489                 Task_sleep(1);
1490             }
1491         } while (status < 0);
1492         System_printf("Core %d : RM CD MessageQ opened from RM Server\n", coreNum);
1494         /* Register the Client Delegate with the RM Server Instance */
1495         rmTransportCfg.rmHandle = rmServerHandle;
1496         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
1497         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1498         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1499         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1500         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1502         /* Store the mapping information in the transport map */
1503         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
1504         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
1505         System_printf("Core %d : Registered RM Server <=> RM CD transport with RM Server instance\n", coreNum);
1506     }
1507     else {
1508         /* Open the Server messageQ from the Client Delegate */
1509         do {
1510             status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
1511             /* 
1512              *  Sleep for 1 clock tick to avoid inundating remote processor
1513              *  with interrupts if open failed
1514              */
1515             if (status < 0) { 
1516                 Task_sleep(1);
1517             }
1518         } while (status < 0);
1519         System_printf("Core %d : RM Server MessageQ opened from RM CD\n", coreNum);
1521         /* Register the Server with the RM Client Delegate Instance */
1522         rmTransportCfg.rmHandle = rmCdHandle;
1523         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
1524         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
1525         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1526         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1527         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
1529         /* Store the mapping information in the transport map */
1530         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
1531         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
1532         System_printf("Core %d : Registered RM CD <=> RM Server transport with RM CD instance\n", coreNum);
1533         
1534         /* Open the Client messageQ from the Client Delegate */
1535         do {
1536             status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
1537             /* 
1538              *  Sleep for 1 clock tick to avoid inundating remote processor
1539              *  with interrupts if open failed
1540              */
1541             if (status < 0) { 
1542                 Task_sleep(1);
1543             }
1544         } while (status < 0);
1545         System_printf("Core %d : RM Client MessageQ opened from RM CD\n", coreNum);
1547         /* Register the Client with the RM Client Delegate Instance */
1548         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
1549         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
1550         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1551         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1552         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
1554         /* Store the mapping information in the transport map */
1555         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
1556         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
1557         System_printf("Core %d : Registered RM CD <=> RM Client transport with RM CD instance\n", coreNum);
1559         /* Open the Client Delegate messageQ from the Client */        
1560         do {
1561             status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
1562             /* 
1563              *  Sleep for 1 clock tick to avoid inundating remote processor
1564              *  with interrupts if open failed
1565              */
1566             if (status < 0) { 
1567                 Task_sleep(1);
1568             }
1569         } while (status < 0);
1570         System_printf("Core %d : RM CD MessageQ opened from RM Client\n", coreNum);
1572         /* Register the Client Delegate with the RM Client Instance */
1573         rmTransportCfg.rmHandle = rmClientHandle;
1574         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
1575         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1576         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1577         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1578         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1580         /* Store the mapping information in the transport map */
1581         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
1582         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
1583         System_printf("Core %d : Registered RM Client <=> RM CD transport with RM Client instance\n", coreNum);
1584     }
1586     /* Create the RM receive task.  Assign higher priority than the test tasks so that
1587      * when they spin waiting for messages from other RM instances the receive task is
1588      * executed. */
1589     System_printf("Core %d : Creating RM receive task...\n", coreNum);
1590     Task_Params_init (&taskParams);
1591     taskParams.priority = 2;
1592     rmReceiveTskHandle = Task_create (rmReceiveTsk, &taskParams, NULL);
1593     
1594     /* Create the RM test tasks. */
1595     if (coreNum == SYSINIT) {
1596         System_printf("Core %d : Creating RM server task...\n", coreNum);
1597         Task_Params_init (&taskParams);
1598         taskParams.priority = 1;
1599         rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
1600     }
1601     else if (coreNum) {
1602         System_printf("Core %d : Creating RM client task...\n", coreNum);
1603         Task_Params_init (&taskParams);
1604         taskParams.priority = 1;
1605         rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
1606     }
1609 int main(Int argc, Char* argv[])
1611     Rm_InitCfg         rmInitCfg;
1612     Task_Params        taskParams; 
1613     int                status;
1614     Rm_ServiceReqInfo  requestInfo;
1615     Rm_ServiceRespInfo responseInfo;
1616     int32_t            result;
1618     System_printf ("*********************************************************\n");
1619     System_printf ("********************** RM Testing ***********************\n");
1620     System_printf ("*********************************************************\n");
1622     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
1624     coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
1625     testErrors = 0;
1627     /* Initialize the RM instances - RM must be initialized before anything else in the system
1628      * Core 0: 1 RM Instance  - RM Server
1629      * Core 1: 2 RM Instances - RM Client Delegate
1630      *                          RM Client
1631      */
1632     if (coreNum == SYSINIT) {
1633         /* Create the Server instance */
1634         rmInitCfg.instName = rmServerName;
1635         rmInitCfg.instType = Rm_instType_SERVER;
1636         rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
1637         rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
1638         rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
1639         rmServerHandle = Rm_init(&rmInitCfg, &result);
1640         ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
1642         /* Open Server service handle */
1643         rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
1644         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
1645     }
1646     else {
1647         /* Create the RM Client Delegate instance */
1648         rmInitCfg.instName = rmCdName;
1649         rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
1650         rmInitCfg.instCfg.cdCfg.cdPolicy = (void *)rmGlobalPolicy;
1651         rmCdHandle = Rm_init(&rmInitCfg, &result);
1652         ERROR_CHECK(RM_WARNING_CD_INSTANCE_NOT_STABLE, result, rmCdName, "Initialization failed");
1654         /* Open CD service handle */
1655         rmCdServiceHandle = Rm_serviceOpenHandle(rmCdHandle, &result);
1656         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle open failed");
1658         /* Create the RM Client instance */
1659         rmInitCfg.instName = rmClientName;
1660         rmInitCfg.instType = Rm_instType_CLIENT;      
1661         rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)rmStaticPolicy;
1662         rmClientHandle = Rm_init(&rmInitCfg, &result);
1663         ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
1665         /* Open Client service handle */
1666         rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
1667         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
1669         /* Initialize the static allocation response queue */
1670         for (numStaticResponses = 0; numStaticResponses < MAX_STATIC_ALLOCATION_RESPS; numStaticResponses++) {
1671             memset((void *)&staticResponseQueue[numStaticResponses], 0, sizeof(Rm_ServiceRespInfo));
1672         }
1673         numStaticResponses = 0;
1675         /* Static allocation tests */
1676         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1677                      0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
1678         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);               
1679         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1680                             coreNum, rmCdName, resourceNameQosCluster,
1681                             requestInfo.resourceBase, requestInfo.resourceLength, 
1682                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1683         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1684             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1685         }        
1686         
1687         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1688                      2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1689         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1690         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1691                             coreNum, rmClientName, resourceNameQosCluster,
1692                             requestInfo.resourceBase, requestInfo.resourceLength, 
1693                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1694         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1695             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1696         }           
1698         /* Request resource from Client that can only be allocated to CD according to static policy */
1699         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1700                      1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1701         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1702         NEGATIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1703                             coreNum, rmClientName, resourceNameQosCluster,
1704                             requestInfo.resourceBase, requestInfo.resourceLength, 
1705                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);          
1707         /* Request resource from both Client and CD that is shared according to static policy */
1708         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1709                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1710         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1711         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1712                             coreNum, rmCdName, resourceNameAifQ,
1713                             requestInfo.resourceBase, requestInfo.resourceLength, 
1714                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1715         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1716             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1717         }           
1719         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1720                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1721         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1722         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1723                             coreNum, rmClientName, resourceNameAifQ,
1724                             requestInfo.resourceBase, requestInfo.resourceLength, 
1725                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1726         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1727             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1728         }           
1729     }
1731     System_printf("Core %d : Starting IPC...\n", coreNum);
1732     status = Ipc_start();
1733     if (status < 0) {
1734         System_abort("Ipc_start failed\n");
1735     }
1737     /* Create the RM startup task */
1738     System_printf("Core %d : Creating RM startup task...\n", coreNum);
1739     Task_Params_init (&taskParams);
1740     rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
1742     System_printf("Core %d : Starting BIOS...\n", coreNum);
1743     BIOS_start();
1745     return (0);