75b7aedffc664efff9ef8f3c0a931c593e10e766
[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, allocCnt, state, check, expectRefCnt, expectAllocCnt) \
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 : - Expected Inst Allocation Count: %-16d      -\n",                            \
231                        core, expectAllocCnt);                                                                   \
232         System_printf ("Core %d : - Returned Inst Allocation Count: %-16d      -\n",                            \
233                        core, allocCnt);                                                                         \
234         System_printf ("Core %d : -                                                       -\n", core);          \
235         if ((state == check) && (refCnt == expectRefCnt) && (allocCnt == expectAllocCnt)) {                     \
236             System_printf ("Core %d : - PASSED                                                -\n", core);      \
237         }                                                                                                       \
238         else {                                                                                                  \
239             if (refCnt != expectRefCnt) {                                                                       \
240                 System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
241                                core);                                                                           \
242             }                                                                                                   \
243             else if (allocCnt != expectAllocCnt) {                                                              \
244                 System_printf ("Core %d : - FAILED - Instance Allocation Count Mismatch           -\n",         \
245                                core);                                                                           \
246             }                                                                                                   \
247             else {                                                                                              \
248                 System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
249                                core, state);                                                                    \
250             }                                                                                                   \
251             testErrors++;                                                                                       \
252         }                                                                                                       \
253         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
254                        core);                                                                                   \
255         System_printf ("\n");                                                                                   \
256     } while(0);
258 /**********************************************************************
259  ********************** RM Test Data Structures ***********************
260  **********************************************************************/
262 /* IPC MessageQ RM packet encapsulation structure */
263 typedef struct {
264     /* IPC MessageQ header (must be first element in structure) */
265     MessageQ_MsgHeader  msgQHeader;
266     /* Pointer to RM packet */
267     Rm_Packet          *rmPkt;
268 } MsgQ_RmPacket;
270 /* RM registered transport mapping structure */
271 typedef struct {
272     /* Registered RM transport handle */
273     Rm_TransportHandle transportHandle;
274     /* MessageQ receive queue tied to the transport handle */
275     MessageQ_Handle    receiveMsgQ;
276 } Transport_MapEntry;
278 /**********************************************************************
279  ********************** Extern Variables ******************************
280  **********************************************************************/
282 /* Alloc and free OSAL variables */
283 extern uint32_t rmMallocCounter;
284 extern uint32_t rmFreeCounter;
286 /* RM test Global Resource List (GRL) */
287 extern const char rmGRL[];
288 /* Example Linux DTB file provided to RM Server for automatic Linux Kernel resource extraction */
289 extern const char rmLinuxDtb[];
290 /* RM test Global Policy provided to RM Server */
291 extern const char rmGlobalPolicy[];
292 /* RM test Static Policy provided to RM Client Delegate and Client */
293 extern const char rmStaticPolicy[];
295 /**********************************************************************
296  ********************** Global Variables ******************************
297  **********************************************************************/
299 /* DSP core number according to DNUM */
300 uint16_t            coreNum;
301 /* Number of errors that occurred during the test */
302 uint16_t            testErrors;
304 /* Task to configure application transport code for RM */
305 Task_Handle         rmStartupTskHandle;
306 /* High priority task for receiving RM packets */
307 Task_Handle         rmReceiveTskHandle;
308 /* RM server test task */
309 Task_Handle         rmServerTskHandle;
310 /* RM client delegate and client test task */
311 Task_Handle         rmClientTskHandle;
313 /* GateMPs used to synchronize tests between the two RM test tasks */
314 GateMP_Handle       serverGate = NULL;
315 GateMP_Handle       clientGate = NULL;
316 /* GateMP keys */
317 IArg                serverKey;
318 IArg                clientKey;
320 /* Handle for heap that RM packets will be allocated from */
321 HeapBufMP_Handle    rmPktHeapHandle = NULL;
323 /* MessageQ used by RM CD to send packets to RM Server */
324 char                serverFromCdQueueName[30] = "RM_Server_From_CD_Queue";
325 /* MessageQ used by RM Server to send packets to RM CD */
326 char                cdFromServerQueueName[30] = "RM_CD_From_Server_Queue";
327 /* MessageQ used by RM Client to send packets to RM CD */
328 char                cdFromClientQueueName[30] = "RM_CD_From_Client_Queue";
329 /* MessageQ used by RM CD to send packets to RM Client */
330 char                clientFromCdQueueName[30] = "RM_Client_From_CD_Queue";
332 /* RM Server instance name (must match with RM Global Resource List (GRL) and policies */
333 char                rmServerName[RM_NAME_MAX_CHARS] = "RM_Server";
334 /* RM CD instance name (must match with RM Global Resource List (GRL) and policies */
335 char                rmCdName[RM_NAME_MAX_CHARS]     = "RM_Client_Delegate";
336 /* RM Client instance name (must match with RM Global Resource List (GRL) and policies */
337 char                rmClientName[RM_NAME_MAX_CHARS] = "RM_Client";
339 /* RM instance handles */
340 Rm_Handle           rmServerHandle = NULL;
341 Rm_Handle           rmCdHandle     = NULL;
342 Rm_Handle           rmClientHandle = NULL;
344 /* RM instance service handles */
345 Rm_ServiceHandle   *rmServerServiceHandle = NULL;
346 Rm_ServiceHandle   *rmCdServiceHandle     = NULL;
347 Rm_ServiceHandle   *rmClientServiceHandle = NULL;
349 /* Transport map stores the RM transport handle to IPC MessageQ queue mapping */
350 Transport_MapEntry  rmTransportMap[MAX_MAPPING_ENTRIES];
352 /* Static allocation response queue */
353 Rm_ServiceRespInfo  staticResponseQueue[MAX_STATIC_ALLOCATION_RESPS];
354 /* Static allocation response queue index */
355 uint32_t            numStaticResponses;
357 /* RM response info queue used to store service responses received via the callback function */
358 Rm_ServiceRespInfo  responseInfoQueue[MAX_QUEUED_SERVICE_RESPONSES];
360 /* RM resource names (must match resource node names in GRL and policies */
361 char                resourceNameMemRegion[RM_NAME_MAX_CHARS]  = "memory-regions";
362 char                resourceNameAccumCh[RM_NAME_MAX_CHARS]    = "accumulator-ch";
363 char                resourceNameGpQ[RM_NAME_MAX_CHARS]        = "gp-queue";
364 char                resourceNameAifQ[RM_NAME_MAX_CHARS]       = "aif-queue";
365 char                resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
366 char                resourceNameAifRxCh[RM_NAME_MAX_CHARS]    = "aif-rx-ch";
367 char                resourceNameInfraQ[RM_NAME_MAX_CHARS]     = "infra-queue";
368 char                resourceNameLowPrioQ[RM_NAME_MAX_CHARS]   = "low-prio-queue";
369 char                resourceNamePassQ[RM_NAME_MAX_CHARS]      = "pass-queue";
371 /* Test RM NameServer name */
372 char                nameServerNameFavQ[RM_NAME_MAX_CHARS]     = "My_Favorite_Queue";
374 /**********************************************************************
375  *************************** Test Functions ***************************
376  **********************************************************************/
378 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
380     Rm_Packet     *rmPkt = NULL;
381     MsgQ_RmPacket *rmMsg = NULL;
383     /* Allocate a messageQ message for containing the RM packet */
384     rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
385     if (rmMsg == NULL) {
386         System_printf("Error Core %d : MessageQ_alloc failed to allocate message: %d\n", coreNum);
387         testErrors++;
388         *pktHandle = NULL;
389         return(NULL);
390     }
391     else {
392         /* Create and attach RM packet to MessageQ message.  All transports will allocate from the same heap */
393         rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
394         rmPkt->pktLenBytes = pktSize;
395         Osal_rmEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
396         rmMsg->rmPkt = rmPkt;
397         *pktHandle = (Rm_PacketHandle)rmMsg;
398     }
399     return (rmPkt);
402 void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
404     uint32_t pktSize = pkt->pktLenBytes;
405     int32_t  status;
407     /* All transports will free rmPkts to the same heap */
408     HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
410     status = MessageQ_free(rmMsgQMsg);
411     if (status < 0) { 
412         System_printf("Error Core %d : MessageQ_free failed to free message: %d\n", coreNum, status);
413         testErrors++;
414     }     
417 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
419     MessageQ_QueueId  remoteQueueId = (MessageQ_QueueId)appTransport;
420     MsgQ_RmPacket    *rmMsg = pktHandle;
421     int32_t           status;    
423     /* Write back data that was written by RM after alloc */
424     Osal_rmEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
426     /* Send the message to the remote side */
427     status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
428     if (status < 0) {
429         transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
430         System_printf("Error Core %d : MessageQ_put failed to send message: %d\n", coreNum, status);
431         testErrors++;
432     }
433     return (status);
436 void transportReceive (uint32_t transportMapEntry)
438     MessageQ_Handle  receiveQ;
439     int32_t          numPkts;
440     MessageQ_Msg     rmMsg = NULL;
441     Rm_Packet       *rmPkt = NULL;
442     int32_t          status;
443     uint32_t         i;  
445     /* Check if any packets available */
446     receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
447     numPkts = (int32_t) MessageQ_count(receiveQ);
449     /* Process all available packets */
450     for (i = 0; i < numPkts; i++) {
451         status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
452         if (rmMsg == NULL) {
453             System_printf("Error Core %d : MessageQ_get failed, returning a NULL packet\n", coreNum);
454             testErrors++;
455         }
457         /* Extract the Rm_Packet from the RM msg */
458         rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
459         Osal_rmBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
461         /* Provide packet to RM for processing */
462         if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
463             System_printf("Error Core %d : RM failed to process received packet: %d\n", coreNum, status);
464             testErrors++;
465         }
467         /* Free RM packet buffer and messageQ message */
468         transportFree(rmMsg, rmPkt);
469     }
472 void serviceCallback(Rm_ServiceRespInfo *serviceResponse)
474     uint32_t qIndex = 0;
475     
476     /* Populate next free entry in the responseInfoQueue */
477     while (responseInfoQueue[qIndex].serviceId != 0) {
478         qIndex++;
479         if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
480             qIndex = 0;
481         }
482     }
484     /* Save the response in the response queue for the test task to pick up */
485     memcpy((void *)&responseInfoQueue[qIndex], (void *)serviceResponse, sizeof(Rm_ServiceRespInfo));
488 void waitForResponse(Rm_ServiceRespInfo *respInfo)
490     uint32_t qIndex = 0;
492     if ((respInfo->serviceState == RM_SERVICE_PROCESSING) ||
493         (respInfo->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
494         /* Scan responseInfoQueue for the response received via the callback function */
495         while((responseInfoQueue[qIndex].serviceId != respInfo->serviceId) ||
496               (responseInfoQueue[qIndex].rmHandle != respInfo->rmHandle)) {
497             qIndex++;
498             if (qIndex == MAX_QUEUED_SERVICE_RESPONSES) {
499                 qIndex = 0;
500             }
501             
502             /* Higher priority receive task will retrieve response */
503         }  
505         memcpy((void *)respInfo, (void *)&responseInfoQueue[qIndex], sizeof(Rm_ServiceRespInfo));
506         memset((void *)&responseInfoQueue[qIndex], 0, sizeof(Rm_ServiceRespInfo));
507     }
510 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
511                   uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
512 {                                                                                
513     memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));                                        
514     reqInfo->type = type;                                                                           
515     reqInfo->resourceName = resName;                                                                
516     reqInfo->resourceBase = resBase;                                                                
517     reqInfo->resourceLength = resLen;                                                               
518     reqInfo->resourceAlignment = resAlign;                                                          
519     reqInfo->resourceNsName = nsName;
520     if (setCallback) {
521         reqInfo->callback.serviceCallback = serviceCallback;  
522     }
523     memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));                                     
526 void rmCleanupTsk(UArg arg0, UArg arg1)
528     int32_t result;
529     int32_t finalMallocFree;    
530     
531     /* Delete the RM test tasks */
532     System_printf("Core %d : Deleting RM startup task...\n", coreNum);
533     if (rmStartupTskHandle) {
534        Task_delete(&rmStartupTskHandle);
535        /* Set the task handle to be NULL so that the delete only occurs once */
536        rmStartupTskHandle = NULL;
537     }  
538     
539     if (coreNum == SYSINIT) {
540         if (rmServerTskHandle) {
541             System_printf("Core %d : Deleting RM server task...\n", coreNum);
542             Task_delete(&rmServerTskHandle);
543             /* Set the task handle to be NULL so that the delete only occurs once */
544             rmServerTskHandle = NULL;
545         }
546     }
547     else {
548         if (rmClientTskHandle) {
549             System_printf("Core %d : Deleting RM client task...\n", coreNum);        
550             Task_delete(&rmClientTskHandle);
551             /* Set the task handle to be NULL so that the delete only occurs once */
552             rmClientTskHandle = NULL;
553         }
554     }
555     
556     /* Delete the RM receive task */
557     System_printf("Core %d : Deleting RM receive task...\n", coreNum);
558     if (rmReceiveTskHandle) {
559         Task_delete(&rmReceiveTskHandle);
560         /* Set the task handle to be NULL so that the delete only occurs once */
561         rmReceiveTskHandle = NULL;
562     }
564     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
565     if (coreNum == SYSINIT) {
566         result = Rm_serviceCloseHandle(rmServerServiceHandle);
567         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle close failed");
569         result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle);
570         ERROR_CHECK(RM_OK, result, rmServerName, "Unregister of CD transport failed");
572         result = Rm_delete(rmServerHandle, RM_TEST_TRUE);  
573         ERROR_CHECK(RM_OK, result, rmServerName, "Instance delete failed");
574     }
575     else {
576         result = Rm_serviceCloseHandle(rmCdServiceHandle);
577         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle close failed");
578         result = Rm_serviceCloseHandle(rmClientServiceHandle);
579         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
581         result = Rm_transportUnregister(rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle);
582         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Server transport failed");
583         result = Rm_transportUnregister(rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle);
584         ERROR_CHECK(RM_OK, result, rmCdName, "Unregister of Client transport failed");
585         result = Rm_transportUnregister(rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle);
586         ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of CD transport failed");
588         result = Rm_delete(rmCdHandle, RM_TEST_TRUE);
589         ERROR_CHECK(RM_OK, result, rmCdName, "Instance delete failed");  
590         result = Rm_delete(rmClientHandle, RM_TEST_TRUE);
591         ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");         
592     }
594     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
595     System_printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
596     System_printf ("Core %d : -                       : malloc count   |   free count -\n", coreNum);
597     System_printf ("Core %d : - Example Completion    :  %6d        |  %6d      -\n", coreNum,
598                    rmMallocCounter, rmFreeCounter);
599     finalMallocFree = rmMallocCounter - rmFreeCounter; 
600     if (finalMallocFree > 0) {
601         System_printf ("Core %d : - FAILED - %6d unfreed mallocs                       -\n",
602                        coreNum, finalMallocFree);
603         testErrors++;
604     }
605     else if (finalMallocFree < 0) {
606         System_printf ("Core %d : - FAILED - %6d more frees than mallocs               -\n",
607                        coreNum, -finalMallocFree);
608         testErrors++;
609     }
610     else {
611         System_printf ("Core %d : - PASSED                                                -\n",
612                        coreNum);
613     }
614     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
615     System_printf ("\n");  
617     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
618     System_printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
619     if (testErrors) {
620         System_printf ("Core %d : - Test Errors: %-32d         -\n", coreNum, testErrors);
621     }
622     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
623     System_printf ("\n"); 
625     BIOS_exit(0);
628 /* Receive task has priority of 2 so that it pre-empts the RM instance test tasks */
629 void rmReceiveTsk(UArg arg0, UArg arg1)
631     while(1) {
632         if (coreNum == SYSINIT) {
633             transportReceive(SERVER_TO_CD_MAP_ENTRY);
634         }
635         else {
636             transportReceive(CD_TO_SERVER_MAP_ENTRY);
637             transportReceive(CD_TO_CLIENT_MAP_ENTRY);
638             transportReceive(CLIENT_TO_CD_MAP_ENTRY);
639         }
640         /* Sleep for 1ms so that the main test tasks can run */
641         Task_sleep(1);
642     }
645 void rmServerTsk(UArg arg0, UArg arg1)
647     Rm_ServiceReqInfo  requestInfo;
648     Rm_ServiceRespInfo responseInfo;
649     Task_Params        taskParams;
651     /* BEGIN testing UNSPECIFIED base and alignment requests on Server */               
652     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
653                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);       
654     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);                 
655     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
656                         coreNum, rmServerName, resourceNameGpQ,
657                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
658                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
659                
660     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
661                  RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
662     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
663     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
664                         coreNum, rmServerName, resourceNameGpQ,
665                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
666                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);      
668     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
669                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);     
670     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
671     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
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 1)-", 
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 2)-", 
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 3)-", 
696                         coreNum, rmServerName, resourceNameGpQ,
697                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
698                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
700     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNamePassQ, 
701                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
702     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
703     POSITIVE_PASS_CHECK("- UNSPECIFIED Allocation Avoiding Policy Denial (Part 4)-", 
704                         coreNum, rmServerName, resourceNameGpQ,
705                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
706                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
707     /* END testing UNSPECIFIED base and alignment requests on Server */      
709     /* Create new NameServer object */                
710     setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ, 
711                  1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
712     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
713     POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------", 
714                         coreNum, rmServerName, resourceNameGpQ,
715                         requestInfo.resourceBase, responseInfo.resourceLength, 
716                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
718     /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and 
719      * delete the NameServer object. */
720     GateMP_leave(serverGate, serverKey);
721     clientKey = GateMP_enter(clientGate);
722     GateMP_leave(clientGate, clientKey);
723     serverKey = GateMP_enter(serverGate);
725     /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
726     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion, 
727                  12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
728     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
729     NEGATIVE_PASS_CHECK("------- Use Allocation of Resource Owned by Linux -------", 
730                         coreNum, rmServerName, resourceNameMemRegion,
731                         requestInfo.resourceBase, requestInfo.resourceLength, 
732                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
734     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
735     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
736                  14, 5, 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     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
744                  19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);      
745     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
746     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
747                         coreNum, rmServerName, resourceNameAifRxCh,
748                         requestInfo.resourceBase, requestInfo.resourceLength, 
749                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
750     
751     /* Wait for Client and Client Delegate to do their allocations */
752     GateMP_leave(serverGate, serverKey);
753     clientKey = GateMP_enter(clientGate);
754     GateMP_leave(clientGate, clientKey);
755     serverKey = GateMP_enter(serverGate);      
757     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
758                  25, 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                  34, 3, 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);      
772  
773     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
774                  28, 6, 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);     
781     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
782                  53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
783     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
784     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
785                         coreNum, rmServerName, resourceNameAifRxCh,
786                         requestInfo.resourceBase, requestInfo.resourceLength, 
787                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
788     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */  
789     
790     /* Test exclusive rights to an allocated resource */
791     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
792                  2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
793     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
794     NEGATIVE_PASS_CHECK("------ Use Allocation of Exclusively Owned Resource -----", 
795                         coreNum, rmServerName, resourceNameAifRxCh,
796                         requestInfo.resourceBase, requestInfo.resourceLength, 
797                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
799     /* Allocate small regions of general purpuse queues to prepare for CD local allocation testing */
800     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
801                  2100, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
802     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
803     POSITIVE_PASS_CHECK("-- Use Allocation Preparing for CD Local Alloc Testing --", 
804                         coreNum, rmServerName, resourceNameGpQ,
805                         responseInfo.resourceBase, responseInfo.resourceLength, 
806                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
808     /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates and CD testing */
809     GateMP_leave(serverGate, serverKey);
810     clientKey = GateMP_enter(clientGate);
811     GateMP_leave(clientGate, clientKey);
812     serverKey = GateMP_enter(serverGate);
814     /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
815      * should be approved but the instance should have only one owner instance in resource's owner list */
816     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, 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 (Init) --", 
820                         coreNum, rmServerName, resourceNameGpQ,
821                         requestInfo.resourceBase, requestInfo.resourceLength, 
822                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
824     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
825                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
826     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
827     POSITIVE_PASS_CHECK("--- Init/Use Allocate of Resource from Same Inst (Use) --", 
828                         coreNum, rmServerName, resourceNameGpQ,
829                         requestInfo.resourceBase, requestInfo.resourceLength, 
830                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
831     
832     /* Get the status of a resource from Server */
833     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
834                  6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
835     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
836     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
837                       coreNum, rmServerName, responseInfo.resourceName,
838                       responseInfo.resourceBase, responseInfo.resourceLength, 
839                       responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
840                       RM_SERVICE_APPROVED, 1, 2); 
841     
842     /* Should take two frees to free both references */
843     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
844                  6543, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);      
845     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
846     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (1st Ref) -------", 
847                         coreNum, rmServerName, resourceNameGpQ,
848                         requestInfo.resourceBase, requestInfo.resourceLength, 
849                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
851     /* Get the status of a resource from Server */
852     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
853                  6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
854     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
855     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
856                       coreNum, rmServerName, responseInfo.resourceName,
857                       responseInfo.resourceBase, responseInfo.resourceLength, 
858                       responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
859                       RM_SERVICE_APPROVED, 1, 1); 
861     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
862                  6543, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
863     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
864     POSITIVE_PASS_CHECK("------- Free of Resource from Same Inst (2nd Ref) -------", 
865                         coreNum, rmServerName, resourceNameGpQ,
866                         requestInfo.resourceBase, requestInfo.resourceLength, 
867                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
869     /* Get the status of a resource from Server */
870     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
871                  6543, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
872     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
873     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
874                       coreNum, rmServerName, responseInfo.resourceName,
875                       responseInfo.resourceBase, responseInfo.resourceLength, 
876                       responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
877                       RM_SERVICE_APPROVED, 0, 0);     
879     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
880     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
881                  805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
882     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
883     NEGATIVE_PASS_CHECK("- Init Allocation of Shared Linux and Client Resource  --", 
884                         coreNum, rmServerName, resourceNameInfraQ,
885                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
887     /* Get the status of a resource from Server */
888     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
889                  53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
890     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
891     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
892                       coreNum, rmServerName, responseInfo.resourceName,
893                       responseInfo.resourceBase, responseInfo.resourceLength, 
894                       responseInfo.resourceNumOwners, responseInfo.instAllocCount, responseInfo.serviceState,
895                       RM_SERVICE_APPROVED, 2, 1); 
897     /* Get the status of a resource from Server */
898     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
899                  1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
900     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
901     STATUS_PASS_CHECK("--------- Status Check of Resources from Server ---------", 
902                       coreNum, rmServerName, responseInfo.resourceName,
903                       responseInfo.resourceBase, responseInfo.resourceLength, 
904                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
905                       responseInfo.serviceState, RM_SERVICE_APPROVED, 0, 0);
907     /* BEGIN Testing CD local allocation feature from Server */
908     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
909                  2051, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
910     rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
911     POSITIVE_PASS_CHECK("--------- CD Testing: Allocate Use From Server ----------", 
912                         coreNum, rmServerName, resourceNameGpQ,
913                         responseInfo.resourceBase, responseInfo.resourceLength, 
914                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
915     /* END Testing CD local allocation feature from Server */
918 #if PRINT_USED_RESOURCES
919     Rm_resourceStatus(rmServerHandle, RM_TEST_TRUE);
920 #endif
922     /* Signal to ClientTsk that Server is ready for cleanup */
923     GateMP_leave(serverGate, serverKey);
924     
925     /* Create the RM cleanup task. */
926     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
927     Task_Params_init (&taskParams);
928     Task_create (rmCleanupTsk, &taskParams, NULL);
931 void rmClientTsk(UArg arg0, UArg arg1)
933     Rm_ServiceReqInfo  requestInfo;
934     Rm_ServiceRespInfo responseInfo;    
935     Task_Params        taskParams;
936     uint32_t           i, j;
938     serverKey = GateMP_enter(serverGate);  
940     /* Retrieve a resource via a NameServer name */
941     setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL, 
942                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
943     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
944     waitForResponse(&responseInfo); 
945     POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------", 
946                         coreNum, rmCdName, responseInfo.resourceName,
947                         responseInfo.resourceBase, responseInfo.resourceLength, 
948                         0, responseInfo.serviceState, RM_SERVICE_APPROVED);     
950     /* Allocate the resource returned from the NameServer request */
951     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo)); 
952     requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
953     requestInfo.resourceName = responseInfo.resourceName;
954     requestInfo.resourceBase = responseInfo.resourceBase;
955     requestInfo.resourceLength = responseInfo.resourceLength;
956     requestInfo.resourceNsName = NULL;
957     requestInfo.callback.serviceCallback = serviceCallback;     
958     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
959     waitForResponse(&responseInfo); 
960     POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------", 
961                         coreNum, rmClientName, responseInfo.resourceName,
962                         requestInfo.resourceBase, requestInfo.resourceLength, 
963                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
965     /* Retrieve the resource status via the NameServer name */
966     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, NULL, 
967                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
968     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
969     waitForResponse(&responseInfo); 
970     STATUS_PASS_CHECK("---- Retrieve Resource Status Via NameServer Object -----", 
971                       coreNum, rmClientName, responseInfo.resourceName,
972                       responseInfo.resourceBase, responseInfo.resourceLength, 
973                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
974                       responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 1);  
976     /* Free resource via a NameServer name */
977     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
978                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
979     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
980     waitForResponse(&responseInfo); 
981     POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----", 
982                         coreNum, rmClientName, nameServerNameFavQ,
983                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
985     /* Delete the NameServer name */
986     setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
987                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
988     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
989     waitForResponse(&responseInfo); 
990     POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------", 
991                         coreNum, rmClientName, nameServerNameFavQ,
992                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
994     GateMP_leave(clientGate, clientKey);
995     GateMP_leave(serverGate, serverKey);
996     clientKey = GateMP_enter(clientGate);
997     serverKey = GateMP_enter(serverGate);    
999     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
1000     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
1001                  0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1002     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1003     waitForResponse(&responseInfo);    
1004     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
1005                         coreNum, rmClientName, resourceNameAifRxCh,
1006                         requestInfo.resourceBase, requestInfo.resourceLength, 
1007                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1008     
1009     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh, 
1010                  50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1011     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1012     waitForResponse(&responseInfo);    
1013     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -", 
1014                         coreNum, rmCdName, resourceNameAifRxCh,
1015                         requestInfo.resourceBase, requestInfo.resourceLength, 
1016                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1017     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
1019     GateMP_leave(clientGate, clientKey);
1020     GateMP_leave(serverGate, serverKey);
1021     clientKey = GateMP_enter(clientGate);
1022     serverKey = GateMP_enter(serverGate);  
1025     /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
1026     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
1027                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);        
1028     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1029     waitForResponse(&responseInfo); 
1030     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
1031                         coreNum, rmCdName, resourceNameAccumCh,
1032                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
1033                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
1035     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
1036                  RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);      
1037     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1038     waitForResponse(&responseInfo); 
1039     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
1040                         coreNum, rmClientName, resourceNameAccumCh,
1041                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
1042                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1044     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
1045                  RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
1046     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1047     waitForResponse(&responseInfo); 
1048     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
1049                         coreNum, rmClientName, resourceNameAccumCh,
1050                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
1051                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1052     /* END testing allocations with UNSPECIFIED base and alignment values */    
1054     /* Allocate infrastructure queue shared between Linux kernel and Client */
1055     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
1056                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1057     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1058     waitForResponse(&responseInfo); 
1059     POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --", 
1060                         coreNum, rmClientName, resourceNameInfraQ,
1061                         requestInfo.resourceBase, requestInfo.resourceLength, 
1062                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1064     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
1065      * is returned by the server. */
1066     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1067                  7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1068     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1069     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
1070                         coreNum, rmClientName, resourceNameGpQ,
1071                         requestInfo.resourceBase, requestInfo.resourceLength, 
1072                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1074     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1075                  7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1076     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1077     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1078                         coreNum, rmCdName, resourceNameGpQ,
1079                         requestInfo.resourceBase, requestInfo.resourceLength, 
1080                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1081     
1082     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
1083                  7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1084     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1085     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
1086                         coreNum, rmClientName, resourceNameGpQ,
1087                         requestInfo.resourceBase, requestInfo.resourceLength, 
1088                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1090     /* Init allocation of resource already owned by Client should return approved and there should only
1091      * be one instance of Client in resource's owner list. */
1092     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1093                  7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1094     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);   
1095     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
1096                         coreNum, rmClientName, resourceNameGpQ,
1097                         requestInfo.resourceBase, requestInfo.resourceLength, 
1098                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
1099     /* END Allocating some resources without providing a callback function.  RM should block and not return
1100      * until the result is returned by the Server. */   
1102     /* BEGIN Getting the status of resources from Client and CD */
1103     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1104                  7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1105     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1106     waitForResponse(&responseInfo);  
1107     STATUS_PASS_CHECK("-- Status Check of Resources from Client (Non-Blocking) -", 
1108                       coreNum, rmClientName, responseInfo.resourceName,
1109                       responseInfo.resourceBase, responseInfo.resourceLength, 
1110                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1111                       responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1);   
1112     
1113     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
1114                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1115     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1116     STATUS_PASS_CHECK("---- Status Check of Resources from Client (Blocking) ---", 
1117                       coreNum, rmClientName, responseInfo.resourceName,
1118                       responseInfo.resourceBase, responseInfo.resourceLength, 
1119                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1120                       responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0);      
1122     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1123                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1124     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1125     waitForResponse(&responseInfo);     
1126     STATUS_PASS_CHECK("---- Status Check of Resources from CD (Non-Blocking) ---", 
1127                       coreNum, rmCdName, responseInfo.resourceName,
1128                       responseInfo.resourceBase, responseInfo.resourceLength, 
1129                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1130                       responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 0); 
1132     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameInfraQ, 
1133                  805, 6, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1134     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1135     STATUS_PASS_CHECK("------ Status Check of Resources from CD (Blocking) -----", 
1136                       coreNum, rmCdName, responseInfo.resourceName,
1137                       responseInfo.resourceBase, responseInfo.resourceLength, 
1138                       responseInfo.resourceNumOwners, responseInfo.instAllocCount, 
1139                       responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0);   
1140     /* END Getting the status of resources from Client and CD */    
1142     /* BEGIN Testing CD local allocation feature */
1143     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1144                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1145     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1146     waitForResponse(&responseInfo);   
1147     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From CD (Non-Blocking) ----", 
1148                         coreNum, rmCdName, responseInfo.resourceName,
1149                         responseInfo.resourceBase, responseInfo.resourceLength, 
1150                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1151     
1152     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1153                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1154     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1155     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From CD (Blocking) ------", 
1156                         coreNum, rmCdName, responseInfo.resourceName,
1157                         responseInfo.resourceBase, responseInfo.resourceLength, 
1158                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1159     
1160     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1161                  RM_RESOURCE_BASE_UNSPECIFIED, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1162     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1163     waitForResponse(&responseInfo);    
1164     POSITIVE_PASS_CHECK("---- CD Testing: Allocate From Client (Non-Blocking) ----", 
1165                         coreNum, rmClientName, responseInfo.resourceName,
1166                         responseInfo.resourceBase, responseInfo.resourceLength, 
1167                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1169     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1170                  RM_RESOURCE_BASE_UNSPECIFIED, 50, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1171     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1172     POSITIVE_PASS_CHECK("------ CD Testing: Allocate From Client (Blocking) ------", 
1173                         coreNum, rmClientName, responseInfo.resourceName,
1174                         responseInfo.resourceBase, responseInfo.resourceLength, 
1175                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1177     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1178                  910, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1179     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1180     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Explicitly From Client ---", 
1181                         coreNum, rmClientName, responseInfo.resourceName,
1182                         responseInfo.resourceBase, responseInfo.resourceLength, 
1183                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1185     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1186                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1187     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1188     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Explicitly From CD -----", 
1189                         coreNum, rmCdName, responseInfo.resourceName,
1190                         responseInfo.resourceBase, responseInfo.resourceLength, 
1191                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1193     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1194                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1195     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1196     waitForResponse(&responseInfo); 
1197     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res Unspecified From Client --", 
1198                         coreNum, rmClientName, responseInfo.resourceName,
1199                         responseInfo.resourceBase, responseInfo.resourceLength, 
1200                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1202     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1203                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1204     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1205     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Local Res Unspecified From CD ----", 
1206                         coreNum, rmCdName, responseInfo.resourceName,
1207                         responseInfo.resourceBase, responseInfo.resourceLength, 
1208                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1210     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1211                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 7, NULL, RM_TEST_FALSE, &responseInfo);     
1212     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1213     POSITIVE_PASS_CHECK("-- CD Testing: Alloc Local Res From Client For Sharing --", 
1214                         coreNum, rmClientName, responseInfo.resourceName,
1215                         RM_RESOURCE_BASE_UNSPECIFIED, responseInfo.resourceLength, 
1216                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);
1218     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1219                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1220     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1221     waitForResponse(&responseInfo); 
1222     STATUS_PASS_CHECK("----- Status Check of Resource Alloc'd Locally to CD ----", 
1223                       coreNum, rmCdName, responseInfo.resourceName,
1224                       responseInfo.resourceBase, responseInfo.resourceLength, 
1225                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1226                       responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0); 
1228     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameLowPrioQ, 
1229                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1230     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1231     waitForResponse(&responseInfo); 
1232     POSITIVE_PASS_CHECK("---- CD Testing: Alloc Shared Local Resource From CD ----", 
1233                         coreNum, rmCdName, responseInfo.resourceName,
1234                         responseInfo.resourceBase, responseInfo.resourceLength, 
1235                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1237     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1238                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1239     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1240     STATUS_PASS_CHECK("- Status Check of Res Alloc'd Locally to CD After Share -", 
1241                       coreNum, rmClientName, responseInfo.resourceName,
1242                       responseInfo.resourceBase, responseInfo.resourceLength, 
1243                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1244                       responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1);
1246     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
1247                  900, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1248     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1249     waitForResponse(&responseInfo); 
1250     NEGATIVE_PASS_CHECK("-- Attempt Shared Alloc of Unshared Local CD Resourcee --", 
1251                         coreNum, rmClientName, responseInfo.resourceName,
1252                         responseInfo.resourceBase, responseInfo.resourceLength, 
1253                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1255     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameLowPrioQ, 
1256                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1257     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1258     waitForResponse(&responseInfo); 
1259     POSITIVE_PASS_CHECK("---- CD Testing: Free Shared Local Resource From CD -----", 
1260                         coreNum, rmCdName, responseInfo.resourceName,
1261                         responseInfo.resourceBase, responseInfo.resourceLength, 
1262                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);   
1264     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameLowPrioQ, 
1265                  133, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1266     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1267     waitForResponse(&responseInfo); 
1268     POSITIVE_PASS_CHECK("-- CD Testing: Free Shared Local Resource From Client ---", 
1269                         coreNum, rmClientName, responseInfo.resourceName,
1270                         responseInfo.resourceBase, responseInfo.resourceLength, 
1271                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1273     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameLowPrioQ, 
1274                  responseInfo.resourceBase, responseInfo.resourceLength, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1275     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1276     STATUS_PASS_CHECK("-- Status Check After Free of Locally Shared Resource ---", 
1277                       coreNum, rmClientName, responseInfo.resourceName,
1278                       responseInfo.resourceBase, responseInfo.resourceLength, 
1279                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
1280                       responseInfo.serviceState, RM_SERVICE_APPROVED, 0, 0);   
1282     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1283                  965, 2, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1284     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1285     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1286                         coreNum, rmCdName, responseInfo.resourceName,
1287                         responseInfo.resourceBase, responseInfo.resourceLength, 
1288                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED); 
1290     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1291                  898, 10, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1292     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1293     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1294                         coreNum, rmCdName, responseInfo.resourceName,
1295                         responseInfo.resourceBase, responseInfo.resourceLength, 
1296                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1298     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1299                  972, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
1300     rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1301     POSITIVE_PASS_CHECK("-------- CD Testing: Free Local Resource From CD --------", 
1302                         coreNum, rmCdName, responseInfo.resourceName,
1303                         responseInfo.resourceBase, responseInfo.resourceLength, 
1304                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1306     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1307                  910, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1308     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1309     waitForResponse(&responseInfo); 
1310     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1311                         coreNum, rmClientName, responseInfo.resourceName,
1312                         responseInfo.resourceBase, responseInfo.resourceLength, 
1313                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1315     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1316                  914, 50, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1317     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1318     waitForResponse(&responseInfo); 
1319     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1320                         coreNum, rmClientName, responseInfo.resourceName,
1321                         responseInfo.resourceBase, responseInfo.resourceLength, 
1322                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
1324     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameGpQ, 
1325                  967, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);     
1326     rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);  
1327     waitForResponse(&responseInfo); 
1328     POSITIVE_PASS_CHECK("---- CD Testing: Free Local Resource From CD Client -----", 
1329                         coreNum, rmClientName, responseInfo.resourceName,
1330                         responseInfo.resourceBase, responseInfo.resourceLength, 
1331                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
1332     /* END Testing CD local allocation feature */ 
1335     /* Verify static allocations were validated.  Validation responses should have been received after the
1336      * first service requests were made on the Client and CD post transport path registration. */
1337     while (numStaticResponses > 0) {
1338         /* Loop until all static request validations have been received */
1339         for (i = 0; i < MAX_STATIC_ALLOCATION_RESPS; i++) {
1340             if (staticResponseQueue[i].serviceId != 0) {            
1341                 for (j = 0; j < MAX_QUEUED_SERVICE_RESPONSES; j++) {
1342                     if ((staticResponseQueue[i].serviceId == responseInfoQueue[j].serviceId) &&
1343                         (staticResponseQueue[i].rmHandle == responseInfoQueue[j].rmHandle)) {                   
1344                         POSITIVE_PASS_CHECK("------------- Static Allocation Validation --------------", 
1345                                             coreNum, rmClientName, responseInfoQueue[j].resourceName,
1346                                             responseInfoQueue[j].resourceBase, responseInfoQueue[j].resourceLength, 
1347                                             0, responseInfoQueue[j].serviceState, 
1348                                             RM_SERVICE_APPROVED); 
1349                         memset((void *)&staticResponseQueue[i], 0, sizeof(Rm_ServiceRespInfo));
1350                         memset((void *)&responseInfoQueue[j], 0, sizeof(Rm_ServiceRespInfo));
1351                         numStaticResponses--;                        
1352                         break;
1353                     }
1354                 }
1355             }
1356         }    
1357     }  
1359 #if PRINT_USED_RESOURCES
1360     Rm_resourceStatus(rmCdHandle, RM_TEST_TRUE);
1361 #endif
1363     GateMP_leave(clientGate, clientKey);
1364     GateMP_leave(serverGate, serverKey);
1365     clientKey = GateMP_enter(clientGate);
1366     /* Enter Server gate one last time to wait for Server to complete testing prior to entering cleanup */
1367     serverKey = GateMP_enter(serverGate);  
1368     
1369     /* Create the RM cleanup task. */
1370     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
1371     Task_Params_init (&taskParams);
1372     Task_create (rmCleanupTsk, &taskParams, NULL);
1375 void rmStartupTsk(UArg arg0, UArg arg1)
1377     MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
1378     MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
1379     Int                status, i;
1380     GateMP_Params      gateParams;    
1381     HeapBufMP_Handle   msgQHeapHandle;
1382     HeapBufMP_Params   heapBufParams;
1383     Rm_TransportCfg    rmTransportCfg;
1384     int32_t            result = 0;
1385     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
1386     Task_Params        taskParams;
1388     /* Initialize the transport map */
1389     for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
1390         rmTransportMap[i].transportHandle = NULL;
1391     } 
1393     if (coreNum == SYSINIT) {
1394         GateMP_Params_init(&gateParams);
1395         gateParams.name = RM_SERVER_GATE_NAME;
1396         /* Disable local protection since only concerned with sync'ing cores */
1397         gateParams.localProtect = GateMP_LocalProtect_NONE;
1398         serverGate = GateMP_create(&gateParams);
1400         serverKey = GateMP_enter(serverGate);  
1402         do {
1403             status = GateMP_open(RM_CLIENT_GATE_NAME, &clientGate);
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         /* Create the heap that will be used to allocate RM messages. This
1414          * heap is a multi-processor heap.  It will be shared amongst
1415          * all RM instances. */     
1416         HeapBufMP_Params_init(&heapBufParams);
1417         heapBufParams.regionId       = 0;
1418         heapBufParams.name           = RM_PKT_HEAP_NAME;
1419         heapBufParams.numBlocks      = 64;
1420         heapBufParams.blockSize      = sizeof(Rm_Packet);
1421         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
1422         if (rmPktHeapHandle == NULL) {
1423             System_printf("Error Core %d : Failed to create RM packet heap\n", coreNum);
1424             testErrors++;
1425         }
1426         System_printf("Core %d : RM packet heap created\n", coreNum);
1428         /* Create the heap that will be used to allocate messageQ messages. */     
1429         HeapBufMP_Params_init(&heapBufParams);
1430         heapBufParams.regionId       = 0;
1431         heapBufParams.name           = MSGQ_HEAP_NAME;
1432         heapBufParams.numBlocks      = 64;
1433         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
1434         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
1435         if (msgQHeapHandle == NULL) {
1436             System_printf("Error Core %d : Failed to create HeapBufMP MessageQ heap\n", coreNum);
1437             testErrors++;
1438         } 
1439         System_printf("Core %d : IPC MessageQ message heap created\n", coreNum);
1440     }
1441     else {
1442         GateMP_Params_init(&gateParams);
1443         gateParams.name = RM_CLIENT_GATE_NAME;
1444         /* Disable local protection since only concerned with sync'ing cores */
1445         gateParams.localProtect = GateMP_LocalProtect_NONE;
1446         clientGate = GateMP_create(&gateParams);
1448         clientKey = GateMP_enter(clientGate); 
1449         
1450         do {
1451             status = GateMP_open(RM_SERVER_GATE_NAME, &serverGate);
1452             /* 
1453              *  Sleep for 1 clock tick to avoid inundating remote processor
1454              *  with interrupts if open failed
1455              */
1456             if (status < 0) { 
1457                 Task_sleep(1);
1458             }
1459         } while (status < 0);
1460         
1461         /* Open the heaps created by the other processor. Loop until opened. */
1462         do {
1463             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
1464             /* 
1465              *  Sleep for 1 clock tick to avoid inundating remote processor
1466              *  with interrupts if open failed
1467              */
1468             if (status < 0) { 
1469                 Task_sleep(1);
1470             }
1471         } while (status < 0);
1472         System_printf("Core %d : RM packet heap opened\n", coreNum);
1473         
1474         do {
1475             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
1476             /* 
1477              *  Sleep for 1 clock tick to avoid inundating remote processor
1478              *  with interrupts if open failed
1479              */
1480             if (status < 0) { 
1481                 Task_sleep(1);
1482             }
1483         } while (status < 0);
1484         System_printf("Core %d : IPC MessageQ message heap opened\n", coreNum);
1485     }
1486     
1487     /* Register the MessageQ heap with MessageQ */
1488     MessageQ_registerHeap(msgQHeapHandle, MSGQ_HEAP_ID);
1490     /* Create the messageQ's for each RM instance connection
1491      * Need four queues.  Topology will be:
1492      * RM Server <---> RM Client Delegate <---> RM Client 
1493      * 1 queues on RM Server
1494      * 2 queues on RM Client Delegate
1495      * 1 queues on RM Client */
1496     if (coreNum == SYSINIT) {
1497         serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
1498         if (serverFromCdMsgQ == NULL) {
1499             System_printf("Error Core %d : Failed to create Server's receive Q for CD\n", coreNum);
1500             testErrors++;
1501         }
1502         System_printf("Core %d : Created Server receive Q for CD\n", coreNum);
1503     }
1504     else {
1505         cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
1506         if (cdFromServerMsgQ == NULL) {
1507             System_printf("Error Core %d : Failed to create CD's receive Q for Server\n", coreNum);
1508             testErrors++;
1509         }
1510         System_printf("Core %d : Created CD receive Q for Server\n", coreNum);
1511         
1512         cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
1513         if (cdFromClientMsgQ == NULL) {
1514             System_printf("Error Core %d : Failed to create CD's receive Q for Client\n", coreNum);
1515             testErrors++;
1516         } 
1517         System_printf("Core %d : Created CD receive Q for Client\n", coreNum);        
1518         
1519         clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
1520         if (clientFromCdMsgQ == NULL) {
1521             System_printf("Error Core %d : Failed to create Client's receive Q for CD\n", coreNum);
1522             testErrors++;
1523         }
1524         System_printf("Core %d : Created Client receive Q for CD\n", coreNum);
1525     }
1526     
1527     /* Open the remote message queues. Also register the RM transports with each RM instance */
1528     if (coreNum == SYSINIT) {
1529         /* Open the Client Delegate messageQ from the Server */
1530         do {
1531             status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
1532             /* 
1533              *  Sleep for 1 clock tick to avoid inundating remote processor
1534              *  with interrupts if open failed
1535              */
1536             if (status < 0) { 
1537                 Task_sleep(1);
1538             }
1539         } while (status < 0);
1540         System_printf("Core %d : RM CD MessageQ opened from RM Server\n", coreNum);
1542         /* Register the Client Delegate with the RM Server Instance */
1543         rmTransportCfg.rmHandle = rmServerHandle;
1544         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
1545         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1546         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1547         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1548         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1550         /* Store the mapping information in the transport map */
1551         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
1552         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
1553         System_printf("Core %d : Registered RM Server <=> RM CD transport with RM Server instance\n", coreNum);
1554     }
1555     else {
1556         /* Open the Server messageQ from the Client Delegate */
1557         do {
1558             status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
1559             /* 
1560              *  Sleep for 1 clock tick to avoid inundating remote processor
1561              *  with interrupts if open failed
1562              */
1563             if (status < 0) { 
1564                 Task_sleep(1);
1565             }
1566         } while (status < 0);
1567         System_printf("Core %d : RM Server MessageQ opened from RM CD\n", coreNum);
1569         /* Register the Server with the RM Client Delegate Instance */
1570         rmTransportCfg.rmHandle = rmCdHandle;
1571         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
1572         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
1573         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1574         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1575         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
1577         /* Store the mapping information in the transport map */
1578         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
1579         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
1580         System_printf("Core %d : Registered RM CD <=> RM Server transport with RM CD instance\n", coreNum);
1581         
1582         /* Open the Client messageQ from the Client Delegate */
1583         do {
1584             status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
1585             /* 
1586              *  Sleep for 1 clock tick to avoid inundating remote processor
1587              *  with interrupts if open failed
1588              */
1589             if (status < 0) { 
1590                 Task_sleep(1);
1591             }
1592         } while (status < 0);
1593         System_printf("Core %d : RM Client MessageQ opened from RM CD\n", coreNum);
1595         /* Register the Client with the RM Client Delegate Instance */
1596         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
1597         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
1598         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1599         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1600         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
1602         /* Store the mapping information in the transport map */
1603         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
1604         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
1605         System_printf("Core %d : Registered RM CD <=> RM Client transport with RM CD instance\n", coreNum);
1607         /* Open the Client Delegate messageQ from the Client */        
1608         do {
1609             status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
1610             /* 
1611              *  Sleep for 1 clock tick to avoid inundating remote processor
1612              *  with interrupts if open failed
1613              */
1614             if (status < 0) { 
1615                 Task_sleep(1);
1616             }
1617         } while (status < 0);
1618         System_printf("Core %d : RM CD MessageQ opened from RM Client\n", coreNum);
1620         /* Register the Client Delegate with the RM Client Instance */
1621         rmTransportCfg.rmHandle = rmClientHandle;
1622         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
1623         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1624         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1625         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1626         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1628         /* Store the mapping information in the transport map */
1629         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
1630         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
1631         System_printf("Core %d : Registered RM Client <=> RM CD transport with RM Client instance\n", coreNum);
1632     }
1634     /* Create the RM receive task.  Assign higher priority than the test tasks so that
1635      * when they spin waiting for messages from other RM instances the receive task is
1636      * executed. */
1637     System_printf("Core %d : Creating RM receive task...\n", coreNum);
1638     Task_Params_init (&taskParams);
1639     taskParams.priority = 2;
1640     rmReceiveTskHandle = Task_create (rmReceiveTsk, &taskParams, NULL);
1641     
1642     /* Create the RM test tasks. */
1643     if (coreNum == SYSINIT) {
1644         System_printf("Core %d : Creating RM server task...\n", coreNum);
1645         Task_Params_init (&taskParams);
1646         taskParams.priority = 1;
1647         rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
1648     }
1649     else if (coreNum) {
1650         System_printf("Core %d : Creating RM client task...\n", coreNum);
1651         Task_Params_init (&taskParams);
1652         taskParams.priority = 1;
1653         rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
1654     }
1657 int main(Int argc, Char* argv[])
1659     Rm_InitCfg         rmInitCfg;
1660     Task_Params        taskParams; 
1661     int                status;
1662     Rm_ServiceReqInfo  requestInfo;
1663     Rm_ServiceRespInfo responseInfo;
1664     int32_t            result;
1666     System_printf ("*********************************************************\n");
1667     System_printf ("********************** RM Testing ***********************\n");
1668     System_printf ("*********************************************************\n");
1670     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
1672     coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
1673     testErrors = 0;
1675     /* Initialize the RM instances - RM must be initialized before anything else in the system
1676      * Core 0: 1 RM Instance  - RM Server
1677      * Core 1: 2 RM Instances - RM Client Delegate
1678      *                          RM Client
1679      */
1680     if (coreNum == SYSINIT) {
1681         /* Create the Server instance */
1682         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
1683         rmInitCfg.instName = rmServerName;
1684         rmInitCfg.instType = Rm_instType_SERVER;
1685         rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
1686         rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
1687         rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
1688         rmServerHandle = Rm_init(&rmInitCfg, &result);
1689         ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
1691         /* Open Server service handle */
1692         rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
1693         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
1694     }
1695     else {
1696         /* Create the RM Client Delegate instance */
1697         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
1698         rmInitCfg.instName = rmCdName;
1699         rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
1700         rmInitCfg.instCfg.cdCfg.cdPolicy = (void *)rmGlobalPolicy;
1701         rmCdHandle = Rm_init(&rmInitCfg, &result);
1702         ERROR_CHECK(RM_WARNING_CD_INSTANCE_NOT_STABLE, result, rmCdName, "Initialization failed");
1704         /* Open CD service handle */
1705         rmCdServiceHandle = Rm_serviceOpenHandle(rmCdHandle, &result);
1706         ERROR_CHECK(RM_OK, result, rmCdName, "Service handle open failed");
1708         /* Create the RM Client instance */
1709         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
1710         rmInitCfg.instName = rmClientName;
1711         rmInitCfg.instType = Rm_instType_CLIENT;
1712         rmInitCfg.instCfg.clientCfg.staticPolicy = (void *)rmStaticPolicy;
1713         rmClientHandle = Rm_init(&rmInitCfg, &result);
1714         ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
1716         /* Open Client service handle */
1717         rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
1718         ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
1720         /* Initialize the static allocation response queue */
1721         for (numStaticResponses = 0; numStaticResponses < MAX_STATIC_ALLOCATION_RESPS; numStaticResponses++) {
1722             memset((void *)&staticResponseQueue[numStaticResponses], 0, sizeof(Rm_ServiceRespInfo));
1723         }
1724         numStaticResponses = 0;
1726         /* Static allocation tests */
1727         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1728                      0, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
1729         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);               
1730         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1731                             coreNum, rmCdName, resourceNameQosCluster,
1732                             requestInfo.resourceBase, requestInfo.resourceLength, 
1733                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1734         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1735             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1736         }        
1737         
1738         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1739                      2, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1740         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1741         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1742                             coreNum, rmClientName, resourceNameQosCluster,
1743                             requestInfo.resourceBase, requestInfo.resourceLength, 
1744                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1745         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1746             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1747         }           
1749         /* Request resource from Client that can only be allocated to CD according to static policy */
1750         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameQosCluster, 
1751                      1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1752         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1753         NEGATIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1754                             coreNum, rmClientName, resourceNameQosCluster,
1755                             requestInfo.resourceBase, requestInfo.resourceLength, 
1756                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);          
1758         /* Request resource from both Client and CD that is shared according to static policy */
1759         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1760                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1761         rmCdServiceHandle->Rm_serviceHandler(rmCdServiceHandle->rmHandle, &requestInfo, &responseInfo);
1762         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1763                             coreNum, rmCdName, resourceNameAifQ,
1764                             requestInfo.resourceBase, requestInfo.resourceLength, 
1765                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1766         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1767             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1768         }           
1770         setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifQ, 
1771                      525, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);        
1772         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo); 
1773         POSITIVE_PASS_CHECK("---------------- Static Init Allocation -----------------", 
1774                             coreNum, rmClientName, resourceNameAifQ,
1775                             requestInfo.resourceBase, requestInfo.resourceLength, 
1776                             requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED_STATIC);     
1777         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1778             memcpy((void *)&staticResponseQueue[numStaticResponses++], (void *)&responseInfo, sizeof(responseInfo));
1779         }           
1780     }
1782     System_printf("Core %d : Starting IPC...\n", coreNum);
1783     status = Ipc_start();
1784     if (status < 0) {
1785         System_abort("Ipc_start failed\n");
1786     }
1788     /* Create the RM startup task */
1789     System_printf("Core %d : Creating RM startup task...\n", coreNum);
1790     Task_Params_init (&taskParams);
1791     rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
1793     System_printf("Core %d : Starting BIOS...\n", coreNum);
1794     BIOS_start();
1796     return (0);