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