Cleaned up test directory and added makefile for ARM test project
[keystone-rtos/rm-lld.git] / test / src / rm_shared_test.c
1 /*
2  *   rm_shared_test.c
3  *
4  *   Multicore Resource Manager test that uses the RM shared server to
5  *   request resources from multiple cores.
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/GateMP.h>
52 /* BIOS Includes */
53 #include <ti/sysbios/BIOS.h>
54 #include <ti/sysbios/knl/Task.h>
55 #include <ti/sysbios/family/c64p/Hwi.h>
57 /* CSL Includes */
58 #include <ti/csl/csl_chip.h>
59 #include <ti/csl/csl_cacheAux.h>
60 #include <ti/csl/csl_xmcAux.h>
62 /* RM Includes */
63 #include <ti/drv/rm/rm.h>
64 #include <ti/drv/rm/rm_services.h>
65 #include <ti/drv/rm/rm_osal.h>
67 /**********************************************************************
68  ********************** RM Shared Test Symbols ************************
69  **********************************************************************/
71 #define PRINT_USED_RESOURCES         0  /* Make 1 and rebuild project to print resources allocated in example */
73 #define SYSINIT                      0
74 #define NUM_CORES                    2
76 /* Test FALSE */
77 #define RM_TEST_FALSE                0
78 /* Test TRUE */
79 #define RM_TEST_TRUE                 1
81 /* Test cache align */
82 #define RM_TEST_MAX_CACHE_ALIGN      128
84 /* RM packet heap name */
85 #define RM_PKT_HEAP_NAME             "rmHeapBuf"
86 /* GateMP names used to synchronize the RM test tasks */
87 #define RM_SERVER_GATE_NAME          "rmServerGate"
88 #define RM_CLIENT_GATE_NAME          "rmClientGate"
90 /* Error checking macro */
91 #define ERROR_CHECK(checkVal, resultVal, rmInstName, printMsg)                   \
92     if (resultVal != checkVal) {                                                 \
93         char errorMsgToPrint[] = printMsg;                                       \
94         System_printf("Error Core %d : %s : ", coreNum, rmInstName);             \
95         System_printf("%s with error code : %d\n", errorMsgToPrint, resultVal);  \
96         testErrors++;                                                            \
97         System_abort("Test Failure\n");                                          \
98     }
100 #define POSITIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check)  \
101     do {                                                                                            \
102         int32_t start = resStart;                                                                   \
103         int32_t alignment = align;                                                                  \
104         char    titleMsg[] = title;                                                                 \
105         System_printf ("Core %d : ---------------------------------------------------------\n",     \
106                        core);                                                                       \
107         System_printf ("Core %d : %s\n", core, titleMsg);                                           \
108         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);               \
109         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                \
110         if (start == RM_RESOURCE_BASE_UNSPECIFIED) {                                                \
111             System_printf ("Core %d : - Start:         UNSPECIFIED                            -\n", \
112                            core);                                                                   \
113             System_printf ("Core %d : - Length:        %-16d                       -\n",            \
114                            core, resLen);                                                           \
115         }                                                                                           \
116         else {                                                                                      \
117             System_printf ("Core %d : - Start:         %-16d                       -\n",            \
118                            core, resStart);                                                         \
119             System_printf ("Core %d : - End:           %-16d                       -\n", core,      \
120                            (start + resLen - 1));                                                   \
121         }                                                                                           \
122         if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {                                       \
123             System_printf ("Core %d : - Alignment:     UNSPECIFIED                            -\n", \
124                            core);                                                                   \
125         }                                                                                           \
126         else {                                                                                      \
127             System_printf ("Core %d : - Alignment:     %-16d                       -\n",            \
128                            core, alignment);                                                        \
129         }                                                                                           \
130         System_printf ("Core %d : -                                                       -\n",     \
131                        core);                                                                       \
132         if (state == check) {                                                                       \
133             System_printf ("Core %d : - PASSED                                                -\n", \
134                            core);                                                                   \
135         }                                                                                           \
136         else {                                                                                      \
137             System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",   \
138                            core, state);                                                            \
139             testErrors++;                                                                           \
140         }                                                                                           \
141         System_printf ("Core %d : ---------------------------------------------------------\n",     \
142                        core);                                                                       \
143         System_printf ("\n");                                                                       \
144     } while(0);
146 #define NEGATIVE_PASS_CHECK(title, core, instName, resName, resStart, resLen, align, state, check)  \
147     do {                                                                                            \
148         int32_t start = resStart;                                                                   \
149         int32_t alignment = align;                                                                  \
150         char    titleMsg[] = title;                                                                 \
151         System_printf ("Core %d : ---------------------------------------------------------\n",     \
152                        core);                                                                       \
153         System_printf ("Core %d : %s\n", core, titleMsg);                                           \
154         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);               \
155         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                \
156         if (start == RM_RESOURCE_BASE_UNSPECIFIED) {                                                \
157             System_printf ("Core %d : - Start:         UNSPECIFIED                            -\n", \
158                            core);                                                                   \
159             System_printf ("Core %d : - Length:        %-16d                       -\n",            \
160                            core, resLen);                                                           \
161         }                                                                                           \
162         else {                                                                                      \
163             System_printf ("Core %d : - Start:         %-16d                       -\n",            \
164                            core, resStart);                                                         \
165             System_printf ("Core %d : - End:           %-16d                       -\n", core,      \
166                            (start + resLen - 1));                                                   \
167         }                                                                                           \
168         if (alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {                                       \
169             System_printf ("Core %d : - Alignment:     UNSPECIFIED                            -\n", \
170                            core);                                                                   \
171         }                                                                                           \
172         else {                                                                                      \
173             System_printf ("Core %d : - Alignment:     %-16d                       -\n",            \
174                            core, alignment);                                                        \
175         }                                                                                           \
176         System_printf ("Core %d : -                                                       -\n",     \
177                        core);                                                                       \
178         if (state != check) {                                                                       \
179             System_printf ("Core %d : - PASSED - Denial: %-6d                               -\n",   \
180                            core, state);                                                            \
181         }                                                                                           \
182         else {                                                                                      \
183             System_printf ("Core %d : - FAILED - Expected Denial                              -\n", \
184                            core);                                                                   \
185             testErrors++;                                                                           \
186         }                                                                                           \
187         System_printf ("Core %d : ---------------------------------------------------------\n",     \
188                        core);                                                                       \
189         System_printf ("\n");                                                                       \
190     } while(0);    
192 #define STATUS_PASS_CHECK(title, core, instName, resName, resStart, resLen, refCnt, state, check, expectRefCnt) \
193     do {                                                                                                        \
194         int32_t start = resStart;                                                                               \
195         char    titleMsg[] = title;                                                                             \
196         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
197                        core);                                                                                   \
198         System_printf ("Core %d : %s\n", core, titleMsg);                                                       \
199         System_printf ("Core %d : - Instance Name: %-32s       -\n", core, instName);                           \
200         System_printf ("Core %d : - Resource Name: %-32s       -\n", core, resName);                            \
201         System_printf ("Core %d : - Start:         %-16d                       -\n",                            \
202                            core, resStart);                                                                     \
203         System_printf ("Core %d : - End:           %-16d                       -\n", core,                      \
204                            (start + resLen - 1));                                                               \
205         System_printf ("Core %d : - Expected Owner Count: %-16d                -\n",                            \
206                        core, expectRefCnt);                                                                     \
207         System_printf ("Core %d : - Returned Owner Count: %-16d                -\n",                            \
208                        core, refCnt);                                                                           \
209         System_printf ("Core %d : -                                                       -\n", core);          \
210         if ((state == check) && (refCnt == expectRefCnt)) {                                                     \
211             System_printf ("Core %d : - PASSED                                                -\n", core);      \
212         }                                                                                                       \
213         else {                                                                                                  \
214             if (refCnt != expectRefCnt) {                                                                       \
215                 System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
216                                core);                                                                           \
217             }                                                                                                   \
218             else {                                                                                              \
219                 System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
220                                core, state);                                                                    \
221             }                                                                                                   \
222             testErrors++;                                                                                       \
223         }                                                                                                       \
224         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
225                        core);                                                                                   \
226         System_printf ("\n");                                                                                   \
227     } while(0);
229 /**********************************************************************
230  ****************** RM Shared Test Data Structures ********************
231  **********************************************************************/
233 typedef struct {
234     /* RM shared server handle */
235     Rm_Handle sharedServerHandle;
236     /** Padding required to make sure linker doesn't put something else
237      * on the same cache line. */
238     uint8_t pad[RM_TEST_MAX_CACHE_ALIGN - sizeof(Rm_Handle)];
239 } Test_SharedRmHandle;
241 /**********************************************************************
242  ********************** Extern Variables ******************************
243  **********************************************************************/
245 /* Alloc and free OSAL variables */
246 extern uint32_t rmMallocCounter[];
247 extern uint32_t rmFreeCounter[];
249 /* RM test Global Resource List (GRL) */
250 extern const char rmGRL[];
251 /* Example Linux DTB file provided to RM Server for automatic Linux Kernel resource extraction */
252 extern const char rmLinuxDtb[];
253 /* RM test Global Policy provided to RM Server */
254 extern const char rmGlobalPolicy[];
256 /**********************************************************************
257  ********************** Global Variables ******************************
258  **********************************************************************/
260 /* DSP core number according to DNUM */
261 uint16_t            coreNum;
262 /* Number of errors that occurred during the test */
263 uint16_t            testErrors;
265 /* Task to configure application transport code for RM */
266 Task_Handle         rmStartupTskHandle;
267 /* RM server test task */
268 Task_Handle         rmServerTskHandle;
269 /* RM client delegate and client test task */
270 Task_Handle         rmClientTskHandle;
272 /* GateMPs used to synchronize tests between the two RM test tasks */
273 GateMP_Handle       serverGate = NULL;
274 GateMP_Handle       clientGate = NULL;
275 /* GateMP keys */
276 IArg                serverKey;
277 IArg                clientKey;
279 /* RM Shared Server instance name (must match with RM Global Resource List (GRL) and policies */
280 char                rmServerName[RM_NAME_MAX_CHARS]        = "RM_Server";
281 /* First Shared Client instance name (must match with RM Global Resource List (GRL) and policies */
282 char                rmSharedClient1Name[RM_NAME_MAX_CHARS] = "RM_Client_Delegate";
283 /* Second Shared Client instance name (must match with RM Global Resource List (GRL) and policies */
284 char                rmSharedClient2Name[RM_NAME_MAX_CHARS] = "RM_Client";
286 /* RM shared server instance handle */
287 #pragma DATA_SECTION (rmSharedHandle, ".rmSharedHandleTest");
288 #pragma DATA_ALIGN (rmSharedHandle, RM_TEST_MAX_CACHE_ALIGN)
289 Test_SharedRmHandle rmSharedHandle = {NULL};
291 /* First Shared Client instance (local memory) */
292 Rm_Handle rmSharedClient1Handle = NULL;
293 /* Second Shared Client instance (local memory) */
294 Rm_Handle rmSharedClient2Handle = NULL;
296 /* RM shared server instance service handle */
297 Rm_ServiceHandle   *rmSharedServerServiceHandle        = NULL;
298 Rm_ServiceHandle   *rmSharedClient1ServiceHandle = NULL;
299 Rm_ServiceHandle   *rmSharedClient2ServiceHandle = NULL;
301 /* RM resource names (must match resource node names in GRL and policies */
302 char                resourceNameMemRegion[RM_NAME_MAX_CHARS]  = "memory-regions";
303 char                resourceNameAccumCh[RM_NAME_MAX_CHARS]    = "accumulator-ch";
304 char                resourceNameGpQ[RM_NAME_MAX_CHARS]        = "gp-queue";
305 char                resourceNameAifQ[RM_NAME_MAX_CHARS]       = "aif-queue";
306 char                resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
307 char                resourceNameAifRxCh[RM_NAME_MAX_CHARS]    = "aif-rx-ch";
308 char                resourceNameInfraQ[RM_NAME_MAX_CHARS]     = "infra-queue";
310 /* Test RM NameServer name */
311 char                nameServerNameFavQ[RM_NAME_MAX_CHARS]     = "My_Favorite_Queue";
313 /**********************************************************************
314  *************************** Test Functions ***************************
315  **********************************************************************/
317 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
318                   uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
319 {                                                                                
320     memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));                                        
321     reqInfo->type = type;                                                                           
322     reqInfo->resourceName = resName;                                                                
323     reqInfo->resourceBase = resBase;                                                                
324     reqInfo->resourceLength = resLen;                                                               
325     reqInfo->resourceAlignment = resAlign;                                                          
326     reqInfo->resourceNsName = nsName;
327     if (setCallback) {
328         reqInfo->callback.serviceCallback = NULL;  
329     }
330     memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));                                     
333 void rmCleanupTsk(UArg arg0, UArg arg1)
335     int32_t result;
336     int32_t finalMallocFree;    
337     
338     /* Delete the RM test tasks */
339     System_printf("Core %d : Deleting RM startup task...\n", coreNum);
340     if (rmStartupTskHandle) {
341        Task_delete(&rmStartupTskHandle);
342        /* Set the task handle to be NULL so that the delete only occurs once */
343        rmStartupTskHandle = NULL;
344     }  
345     
346     if (coreNum == SYSINIT) {
347         if (rmServerTskHandle) {
348             System_printf("Core %d : Deleting RM server task...\n", coreNum);
349             Task_delete(&rmServerTskHandle);
350             /* Set the task handle to be NULL so that the delete only occurs once */
351             rmServerTskHandle = NULL;
352         }
353     }
354     else {
355         if (rmClientTskHandle) {
356             System_printf("Core %d : Deleting RM client task...\n", coreNum);        
357             Task_delete(&rmClientTskHandle);
358             /* Set the task handle to be NULL so that the delete only occurs once */
359             rmClientTskHandle = NULL;
360         }
361     }
363     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
364     if (coreNum == SYSINIT) {
365         result = Rm_serviceCloseHandle(rmSharedServerServiceHandle);
366         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle close failed");
368         result = Rm_delete(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
369         ERROR_CHECK(RM_OK, result, rmServerName, "Instance delete failed");
371         /* Wait for remote core to verify it has deleted its Shared Clients */
372         clientKey = GateMP_enter(clientGate);
374         /* Only need to check for memory leaks from one Shared Server core since instance
375          * was shared amongst all test cores */
376         Osal_rmBeginMemAccess(rmMallocCounter, 128);
377         Osal_rmBeginMemAccess(rmFreeCounter, 128);
379         System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
380         System_printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
381         System_printf ("Core %d : -                       : malloc count   |   free count -\n", coreNum);
382         System_printf ("Core %d : - Example Completion    :  %6d        |  %6d      -\n", coreNum,
383                        rmMallocCounter[0], rmFreeCounter[0]);
384         finalMallocFree = rmMallocCounter[0] - rmFreeCounter[0]; 
385         if (finalMallocFree > 0) {
386             System_printf ("Core %d : - FAILED - %6d unfreed mallocs                       -\n",
387                            coreNum, finalMallocFree);
388             testErrors++;
389         }
390         else if (finalMallocFree < 0) {
391             System_printf ("Core %d : - FAILED - %6d more frees than mallocs               -\n",
392                            coreNum, -finalMallocFree);
393             testErrors++;
394         }
395         else {
396             System_printf ("Core %d : - PASSED                                                -\n",
397                            coreNum);
398         }
399         System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
400         System_printf ("\n");           
401     }
402     else {
403         result = Rm_serviceCloseHandle(rmSharedClient1ServiceHandle);
404         ERROR_CHECK(RM_OK, result, rmSharedClient1Handle, "Service handle close failed");
405         result = Rm_serviceCloseHandle(rmSharedClient2ServiceHandle);
406         ERROR_CHECK(RM_OK, result, rmSharedClient2Handle, "Service handle close failed");
407         
408         result = Rm_delete(rmSharedClient1Handle, RM_TEST_TRUE);
409         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Instance delete failed");
410         result = Rm_delete(rmSharedClient2Handle, RM_TEST_TRUE);
411         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Instance delete failed");
413         /* Signal to Shared Server core that the Shared Clients have been deleted */
414         GateMP_leave(clientGate, clientKey);
415     }
417     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
418     System_printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
419     if (testErrors) {
420         System_printf ("Core %d : - Test Errors: %-32d         -\n", coreNum, testErrors);
421     }
422     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
423     System_printf ("\n"); 
425     BIOS_exit(0);
428 void rmServerTsk(UArg arg0, UArg arg1)
430     Rm_ServiceReqInfo  requestInfo;
431     Rm_ServiceRespInfo responseInfo;
432     Task_Params        taskParams;
434     /* BEGIN testing UNSPECIFIED base and alignment requests on Server */               
435     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
436                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);       
437     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
438     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
439                         coreNum, rmServerName, resourceNameGpQ,
440                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
441                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
442                
443     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
444                  RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
445     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
446     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
447                         coreNum, rmServerName, resourceNameGpQ,
448                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
449                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);      
451     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
452                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);     
453     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
454     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
455                         coreNum, rmServerName, resourceNameGpQ,
456                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
457                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);        
458     /* END testing UNSPECIFIED base and alignment requests on Server */      
460     /* Create new NameServer object */                
461     setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ, 
462                  1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
463     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
464     POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------", 
465                         coreNum, rmServerName, resourceNameGpQ,
466                         requestInfo.resourceBase, responseInfo.resourceLength, 
467                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
469     /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and 
470      * delete the NameServer object. */
471     GateMP_leave(serverGate, serverKey);
472     clientKey = GateMP_enter(clientGate);
473     GateMP_leave(clientGate, clientKey);
474     serverKey = GateMP_enter(serverGate);
476     /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
477     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion, 
478                  12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
479     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
480     NEGATIVE_PASS_CHECK("------- Use Allocation of Resource Owned by Linux -------", 
481                         coreNum, rmServerName, resourceNameMemRegion,
482                         requestInfo.resourceBase, requestInfo.resourceLength, 
483                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
485     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
486     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
487                  14, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);       
488     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
489     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
490                         coreNum, rmServerName, resourceNameAifRxCh,
491                         requestInfo.resourceBase, requestInfo.resourceLength, 
492                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
493     
494     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
495                  19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);      
496     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
497     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
498                         coreNum, rmServerName, resourceNameAifRxCh,
499                         requestInfo.resourceBase, requestInfo.resourceLength, 
500                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
501     
502     /* Wait for Client and Client Delegate to do their allocations */
503     GateMP_leave(serverGate, serverKey);
504     clientKey = GateMP_enter(clientGate);
505     GateMP_leave(clientGate, clientKey);
506     serverKey = GateMP_enter(serverGate);      
508     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
509                  25, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
510     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
511     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
512                         coreNum, rmServerName, resourceNameAifRxCh,
513                         requestInfo.resourceBase, requestInfo.resourceLength, 
514                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
515     
516     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
517                  34, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);      
518     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
519     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
520                         coreNum, rmServerName, resourceNameAifRxCh,
521                         requestInfo.resourceBase, requestInfo.resourceLength, 
522                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
523  
524     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
525                  28, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);      
526     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);   
527     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
528                         coreNum, rmServerName, resourceNameAifRxCh,
529                         requestInfo.resourceBase, requestInfo.resourceLength, 
530                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
532     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
533                  53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
534     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
535     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
536                         coreNum, rmServerName, resourceNameAifRxCh,
537                         requestInfo.resourceBase, requestInfo.resourceLength, 
538                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
539     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */  
540     
541     /* Test exclusive rights to an allocated resource */
542     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
543                  2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
544     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
545     NEGATIVE_PASS_CHECK("------ Use Allocation of Exclusively Owned Resource -----", 
546                         coreNum, rmServerName, resourceNameAifRxCh,
547                         requestInfo.resourceBase, requestInfo.resourceLength, 
548                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
550     /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates */
551     GateMP_leave(serverGate, serverKey);
552     clientKey = GateMP_enter(clientGate);
553     GateMP_leave(clientGate, clientKey);
554     serverKey = GateMP_enter(serverGate);
556     /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
557      * should be approved but the instance should have only one owner instance in resource's owner list */
558     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
559                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
560     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
561     POSITIVE_PASS_CHECK("-- Init/Use Allocate of Resource from Same Inst (Init) --", 
562                         coreNum, rmServerName, resourceNameGpQ,
563                         requestInfo.resourceBase, requestInfo.resourceLength, 
564                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
566     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
567                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
568     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
569     POSITIVE_PASS_CHECK("--- Init/Use Allocate of Resource from Same Inst (Use) --", 
570                         coreNum, rmServerName, resourceNameGpQ,
571                         requestInfo.resourceBase, requestInfo.resourceLength, 
572                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
574     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
575     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
576                  805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
577     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
578     NEGATIVE_PASS_CHECK("- Init Allocation of Shared Linux and Client Resource  --", 
579                         coreNum, rmServerName, resourceNameInfraQ,
580                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
582     /* Get the status of a resource from Server */
583     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
584                  53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
585     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
586     STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
587                       coreNum, rmServerName, responseInfo.resourceName,
588                       responseInfo.resourceBase, responseInfo.resourceLength, 
589                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2); 
591     /* Get the status of a resource from Server */
592     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
593                  1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
594     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
595     STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
596                       coreNum, rmServerName, responseInfo.resourceName,
597                       responseInfo.resourceBase, responseInfo.resourceLength, 
598                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 0);
600 #if PRINT_USED_RESOURCES
601     Rm_resourceStatus(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
602 #endif
604     /* Signal to ClientTsk that Server is ready for cleanup */
605     GateMP_leave(serverGate, serverKey);
606     
607     /* Create the RM cleanup task. */
608     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
609     Task_Params_init (&taskParams);
610     Task_create (rmCleanupTsk, &taskParams, NULL);
613 void rmClientTsk(UArg arg0, UArg arg1)
615     Rm_ServiceReqInfo  requestInfo;
616     Rm_ServiceRespInfo responseInfo;    
617     Task_Params        taskParams;
619     serverKey = GateMP_enter(serverGate);  
621     /* Retrieve a resource via a NameServer name */
622     setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL, 
623                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
624     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
625     POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------", 
626                         coreNum, rmSharedClient1Name, responseInfo.resourceName,
627                         responseInfo.resourceBase, responseInfo.resourceLength, 
628                         0, responseInfo.serviceState, RM_SERVICE_APPROVED);     
630     /* Allocate the resource returned from the NameServer request */
631     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo)); 
632     requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
633     requestInfo.resourceName = responseInfo.resourceName;
634     requestInfo.resourceBase = responseInfo.resourceBase;
635     requestInfo.resourceLength = responseInfo.resourceLength;
636     requestInfo.resourceNsName = NULL;
637     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
638     POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------", 
639                         coreNum, rmSharedClient2Name, responseInfo.resourceName,
640                         requestInfo.resourceBase, requestInfo.resourceLength, 
641                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
643     /* Free resource via a NameServer name */
644     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
645                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
646     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
647     POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----", 
648                         coreNum, rmSharedClient2Name, nameServerNameFavQ,
649                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
651     /* Delete the NameServer name */
652     setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
653                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
654     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);     
655     POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------", 
656                         coreNum, rmSharedClient2Name, nameServerNameFavQ,
657                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
659     GateMP_leave(clientGate, clientKey);
660     GateMP_leave(serverGate, serverKey);
661     clientKey = GateMP_enter(clientGate);
662     serverKey = GateMP_enter(serverGate);    
664     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
665     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
666                  0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);     
667     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
668     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
669                         coreNum, rmSharedClient2Name, resourceNameAifRxCh,
670                         requestInfo.resourceBase, requestInfo.resourceLength, 
671                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
672     
673     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh, 
674                  50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);        
675     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
676     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -", 
677                         coreNum, rmSharedClient1Name, resourceNameAifRxCh,
678                         requestInfo.resourceBase, requestInfo.resourceLength, 
679                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
680     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
682     GateMP_leave(clientGate, clientKey);
683     GateMP_leave(serverGate, serverKey);
684     clientKey = GateMP_enter(clientGate);
685     serverKey = GateMP_enter(serverGate);  
687     /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
688     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
689                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);        
690     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
691     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
692                         coreNum, rmSharedClient1Name, resourceNameAccumCh,
693                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
694                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
696     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
697                  RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);      
698     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo); 
699     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
700                         coreNum, rmSharedClient2Name, resourceNameAccumCh,
701                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
702                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
704     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
705                  RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
706     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
707     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
708                         coreNum, rmSharedClient2Name, resourceNameAccumCh,
709                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
710                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);     
711     /* END testing allocations with UNSPECIFIED base and alignment values */    
713     /* Allocate infrastructure queue shared between Linux kernel and Client */
714     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
715                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
716     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
717     POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --", 
718                         coreNum, rmSharedClient2Name, resourceNameInfraQ,
719                         requestInfo.resourceBase, requestInfo.resourceLength, 
720                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
722     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
723      * is returned by the server. */
724     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
725                  7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
726     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
727     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
728                         coreNum, rmSharedClient2Name, resourceNameGpQ,
729                         requestInfo.resourceBase, requestInfo.resourceLength, 
730                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
732     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
733                  7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
734     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
735     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
736                         coreNum, rmSharedClient1Name, resourceNameGpQ,
737                         requestInfo.resourceBase, requestInfo.resourceLength, 
738                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
739     
740     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
741                  7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
742     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
743     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
744                         coreNum, rmSharedClient2Name, resourceNameGpQ,
745                         requestInfo.resourceBase, requestInfo.resourceLength, 
746                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
748     /* Init allocation of resource already owned by Client should return approved and there should only
749      * be one instance of Client in resource's owner list. */
750     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
751                  7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
752     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
753     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
754                         coreNum, rmSharedClient2Name, resourceNameGpQ,
755                         requestInfo.resourceBase, requestInfo.resourceLength, 
756                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
757     /* END Allocating some resources without providing a callback function.  RM should block and not return
758      * until the result is returned by the server. */   
760     /* BEGIN Getting the status of resources from the Shared Clients */
761     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
762                  7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
763     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
764     STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
765                       coreNum, rmSharedClient2Name, responseInfo.resourceName,
766                       responseInfo.resourceBase, responseInfo.resourceLength, 
767                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 2);   
768     
769     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
770                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
771     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
772     STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
773                       coreNum, rmSharedClient1Name, responseInfo.resourceName,
774                       responseInfo.resourceBase, responseInfo.resourceLength, 
775                       responseInfo.resourceNumOwners, responseInfo.serviceState, RM_SERVICE_APPROVED, 1);        
776     /* END Getting the status of resources from Client and CD */    
778     GateMP_leave(clientGate, clientKey);
779     GateMP_leave(serverGate, serverKey);
780     clientKey = GateMP_enter(clientGate);
781     /* Enter Server gate one last time to wait for Server to complete testing prior to entering cleanup */
782     serverKey = GateMP_enter(serverGate);  
783     
784     /* Create the RM cleanup task. */
785     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
786     Task_Params_init (&taskParams);
787     Task_create (rmCleanupTsk, &taskParams, NULL);
790 void rmStartupTsk(UArg arg0, UArg arg1)
791 {  
792     Int           status;
793     GateMP_Params gateParams;
794     Task_Params   taskParams;
796     if (coreNum == SYSINIT) {
797         GateMP_Params_init(&gateParams);
798         gateParams.name = RM_SERVER_GATE_NAME;
799         /* Disable local protection since only concerned with sync'ing cores */
800         gateParams.localProtect = GateMP_LocalProtect_NONE;
801         serverGate = GateMP_create(&gateParams);
803         serverKey = GateMP_enter(serverGate);  
805         do {
806             status = GateMP_open(RM_CLIENT_GATE_NAME, &clientGate);
807             /* 
808              *  Sleep for 1 clock tick to avoid inundating remote processor
809              *  with interrupts if open failed
810              */
811             if (status < 0) { 
812                 Task_sleep(1);
813             }
814         } while (status < 0);        
815     }
816     else {
817         GateMP_Params_init(&gateParams);
818         gateParams.name = RM_CLIENT_GATE_NAME;
819         /* Disable local protection since only concerned with sync'ing cores */
820         gateParams.localProtect = GateMP_LocalProtect_NONE;
821         clientGate = GateMP_create(&gateParams);
823         clientKey = GateMP_enter(clientGate); 
824         
825         do {
826             status = GateMP_open(RM_SERVER_GATE_NAME, &serverGate);
827             /* 
828              *  Sleep for 1 clock tick to avoid inundating remote processor
829              *  with interrupts if open failed
830              */
831             if (status < 0) { 
832                 Task_sleep(1);
833             }
834         } while (status < 0);
835     }
836  
837     /* Create the RM test tasks. */
838     if (coreNum == SYSINIT) {
839         System_printf("Core %d : Creating RM server task...\n", coreNum);
840         Task_Params_init (&taskParams);
841         taskParams.priority = 1;
842         rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
843     }
844     else if (coreNum) {
845         System_printf("Core %d : Creating RM client task...\n", coreNum);
846         Task_Params_init (&taskParams);
847         taskParams.priority = 1;
848         rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
849     }
852 int main(Int argc, Char* argv[])
854     Rm_InitCfg         rmInitCfg;
855     Task_Params        taskParams; 
856     int                status;
857     int32_t            result;
859     System_printf ("*********************************************************\n");
860     System_printf ("***************** RM Shared Server Test *****************\n");
861     System_printf ("*********************************************************\n");
863     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
865     coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
866     testErrors = 0;
867     
868     /* Initialize the heap in shared memory. Using IPC module to do that */ 
869     System_printf("Core %d: Starting IPC...\n", coreNum);
870     status = Ipc_start();
871     if (status < 0) {
872         System_abort("Ipc_start failed\n");
873     }
875     /* Initialize the RM instances - RM must be initialized before anything else in the system
876      * Core 0: 1 RM Instance  - RM Server
877      * Core 1: 2 RM Instances - RM Client Delegate
878      *                          RM Client
879      */
880     if (coreNum == SYSINIT) {
881         /* Create the Server instance */
882         rmInitCfg.instName = rmServerName;
883         rmInitCfg.instType = Rm_instType_SHARED_SERVER;
884         rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
885         rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
886         rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
887         rmSharedHandle.sharedServerHandle = Rm_init(&rmInitCfg, &result);
888         ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
890         /* Open Server service handle */
891         rmSharedServerServiceHandle = Rm_serviceOpenHandle(rmSharedHandle.sharedServerHandle, &result);
892         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
894         Osal_rmEndMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
895     }
896     else {
897         do {
898             Osal_rmBeginMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
899         } while (!rmSharedHandle.sharedServerHandle);
901         /* Create the first Shared Client instance */
902         rmInitCfg.instName = rmSharedClient1Name;
903         rmInitCfg.instType = Rm_instType_SHARED_CLIENT;
904         rmInitCfg.instCfg.sharedClientCfg.sharedServerHandle = rmSharedHandle.sharedServerHandle;
905         rmSharedClient1Handle = Rm_init(&rmInitCfg, &result);
906         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Initialization failed");
908         /* Open shared client service handle */
909         rmSharedClient1ServiceHandle = Rm_serviceOpenHandle(rmSharedClient1Handle, &result);
910         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Service handle open failed");
912         /* Create the second Shared Client instance */
913         rmInitCfg.instName = rmSharedClient2Name;
914         rmInitCfg.instType = Rm_instType_SHARED_CLIENT;
915         rmInitCfg.instCfg.sharedClientCfg.sharedServerHandle = rmSharedHandle.sharedServerHandle;
916         rmSharedClient2Handle = Rm_init(&rmInitCfg, &result);
917         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Initialization failed");
919         /* Open shared client service handle */
920         rmSharedClient2ServiceHandle = Rm_serviceOpenHandle(rmSharedClient2Handle, &result);
921         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Service handle open failed");
922     }
924     /* Create the RM startup task */
925     System_printf("Core %d : Creating RM startup task...\n", coreNum);
926     Task_Params_init (&taskParams);
927     rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
929     System_printf("Core %d : Starting BIOS...\n", coreNum);
930     BIOS_start();
932     return (0);