Added multi-threaded client test for Linux
[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, allocCnt, state, check, expectRefCnt, expectAllocCnt) \
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 : - Expected Inst Allocation Count: %-16d      -\n",                            \
210                        core, expectAllocCnt);                                                                   \
211         System_printf ("Core %d : - Returned Inst Allocation Count: %-16d      -\n",                            \
212                        core, allocCnt);                                                                         \
213         System_printf ("Core %d : -                                                       -\n", core);          \
214         if ((state == check) && (refCnt == expectRefCnt) && (allocCnt == expectAllocCnt)) {                     \
215             System_printf ("Core %d : - PASSED                                                -\n", core);      \
216         }                                                                                                       \
217         else {                                                                                                  \
218             if (refCnt != expectRefCnt) {                                                                       \
219                 System_printf ("Core %d : - FAILED - Owner Count Mismatch                         -\n",         \
220                                core);                                                                           \
221             }                                                                                                   \
222             else if (allocCnt != expectAllocCnt) {                                                              \
223                 System_printf ("Core %d : - FAILED - Instance Allocation Count Mismatch           -\n",         \
224                                core);                                                                           \
225             }                                                                                                   \
226             else {                                                                                              \
227                 System_printf ("Core %d : - FAILED - Denial: %-6d                               -\n",           \
228                                core, state);                                                                    \
229             }                                                                                                   \
230             testErrors++;                                                                                       \
231         }                                                                                                       \
232         System_printf ("Core %d : ---------------------------------------------------------\n",                 \
233                        core);                                                                                   \
234         System_printf ("\n");                                                                                   \
235     } while(0);
237 /**********************************************************************
238  ****************** RM Shared Test Data Structures ********************
239  **********************************************************************/
241 typedef struct {
242     /* RM shared server handle */
243     Rm_Handle sharedServerHandle;
244     /** Padding required to make sure linker doesn't put something else
245      * on the same cache line. */
246     uint8_t pad[RM_TEST_MAX_CACHE_ALIGN - sizeof(Rm_Handle)];
247 } Test_SharedRmHandle;
249 /**********************************************************************
250  ********************** Extern Variables ******************************
251  **********************************************************************/
253 /* Alloc and free OSAL variables */
254 extern uint32_t rmMallocCounter[];
255 extern uint32_t rmFreeCounter[];
257 /* RM test Global Resource List (GRL) */
258 extern const char rmGRL[];
259 /* Example Linux DTB file provided to RM Server for automatic Linux Kernel resource extraction */
260 extern const char rmLinuxDtb[];
261 /* RM test Global Policy provided to RM Server */
262 extern const char rmGlobalPolicy[];
264 /**********************************************************************
265  ********************** Global Variables ******************************
266  **********************************************************************/
268 /* DSP core number according to DNUM */
269 uint16_t            coreNum;
270 /* Number of errors that occurred during the test */
271 uint16_t            testErrors;
273 /* Task to configure application transport code for RM */
274 Task_Handle         rmStartupTskHandle;
275 /* RM server test task */
276 Task_Handle         rmServerTskHandle;
277 /* RM client delegate and client test task */
278 Task_Handle         rmClientTskHandle;
280 /* GateMPs used to synchronize tests between the two RM test tasks */
281 GateMP_Handle       serverGate = NULL;
282 GateMP_Handle       clientGate = NULL;
283 /* GateMP keys */
284 IArg                serverKey;
285 IArg                clientKey;
287 /* RM Shared Server instance name (must match with RM Global Resource List (GRL) and policies */
288 char                rmServerName[RM_NAME_MAX_CHARS]        = "RM_Server";
289 /* First Shared Client instance name (must match with RM Global Resource List (GRL) and policies */
290 char                rmSharedClient1Name[RM_NAME_MAX_CHARS] = "RM_Client_Delegate";
291 /* Second Shared Client instance name (must match with RM Global Resource List (GRL) and policies */
292 char                rmSharedClient2Name[RM_NAME_MAX_CHARS] = "RM_Client";
294 /* RM shared server instance handle */
295 #pragma DATA_SECTION (rmSharedHandle, ".rmSharedHandleTest");
296 #pragma DATA_ALIGN (rmSharedHandle, RM_TEST_MAX_CACHE_ALIGN)
297 Test_SharedRmHandle rmSharedHandle = {NULL};
299 /* First Shared Client instance (local memory) */
300 Rm_Handle rmSharedClient1Handle = NULL;
301 /* Second Shared Client instance (local memory) */
302 Rm_Handle rmSharedClient2Handle = NULL;
304 /* RM shared server instance service handle */
305 Rm_ServiceHandle   *rmSharedServerServiceHandle        = NULL;
306 Rm_ServiceHandle   *rmSharedClient1ServiceHandle = NULL;
307 Rm_ServiceHandle   *rmSharedClient2ServiceHandle = NULL;
309 /* RM resource names (must match resource node names in GRL and policies */
310 char                resourceNameMemRegion[RM_NAME_MAX_CHARS]  = "memory-regions";
311 char                resourceNameAccumCh[RM_NAME_MAX_CHARS]    = "accumulator-ch";
312 char                resourceNameGpQ[RM_NAME_MAX_CHARS]        = "gp-queue";
313 char                resourceNameAifQ[RM_NAME_MAX_CHARS]       = "aif-queue";
314 char                resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
315 char                resourceNameAifRxCh[RM_NAME_MAX_CHARS]    = "aif-rx-ch";
316 char                resourceNameInfraQ[RM_NAME_MAX_CHARS]     = "infra-queue";
318 /* Test RM NameServer name */
319 char                nameServerNameFavQ[RM_NAME_MAX_CHARS]     = "My_Favorite_Queue";
321 /**********************************************************************
322  *************************** Test Functions ***************************
323  **********************************************************************/
325 void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
326                   uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
327 {                                                                                
328     memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));                                        
329     reqInfo->type = type;                                                                           
330     reqInfo->resourceName = resName;                                                                
331     reqInfo->resourceBase = resBase;                                                                
332     reqInfo->resourceLength = resLen;                                                               
333     reqInfo->resourceAlignment = resAlign;                                                          
334     reqInfo->resourceNsName = nsName;
335     if (setCallback) {
336         reqInfo->callback.serviceCallback = NULL;  
337     }
338     memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));                                     
341 void rmCleanupTsk(UArg arg0, UArg arg1)
343     int32_t result;
344     int32_t finalMallocFree;    
345     
346     /* Delete the RM test tasks */
347     System_printf("Core %d : Deleting RM startup task...\n", coreNum);
348     if (rmStartupTskHandle) {
349        Task_delete(&rmStartupTskHandle);
350        /* Set the task handle to be NULL so that the delete only occurs once */
351        rmStartupTskHandle = NULL;
352     }  
353     
354     if (coreNum == SYSINIT) {
355         if (rmServerTskHandle) {
356             System_printf("Core %d : Deleting RM server task...\n", coreNum);
357             Task_delete(&rmServerTskHandle);
358             /* Set the task handle to be NULL so that the delete only occurs once */
359             rmServerTskHandle = NULL;
360         }
361     }
362     else {
363         if (rmClientTskHandle) {
364             System_printf("Core %d : Deleting RM client task...\n", coreNum);        
365             Task_delete(&rmClientTskHandle);
366             /* Set the task handle to be NULL so that the delete only occurs once */
367             rmClientTskHandle = NULL;
368         }
369     }
371     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
372     if (coreNum == SYSINIT) {
373         result = Rm_serviceCloseHandle(rmSharedServerServiceHandle);
374         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle close failed");
376         result = Rm_delete(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
377         ERROR_CHECK(RM_OK, result, rmServerName, "Instance delete failed");
379         /* Wait for remote core to verify it has deleted its Shared Clients */
380         clientKey = GateMP_enter(clientGate);
382         /* Only need to check for memory leaks from one Shared Server core since instance
383          * was shared amongst all test cores */
384         Osal_rmBeginMemAccess(rmMallocCounter, 128);
385         Osal_rmBeginMemAccess(rmFreeCounter, 128);
387         System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
388         System_printf ("Core %d : ------------------ Memory Leak Check --------------------\n", coreNum);
389         System_printf ("Core %d : -                       : malloc count   |   free count -\n", coreNum);
390         System_printf ("Core %d : - Example Completion    :  %6d        |  %6d      -\n", coreNum,
391                        rmMallocCounter[0], rmFreeCounter[0]);
392         finalMallocFree = rmMallocCounter[0] - rmFreeCounter[0]; 
393         if (finalMallocFree > 0) {
394             System_printf ("Core %d : - FAILED - %6d unfreed mallocs                       -\n",
395                            coreNum, finalMallocFree);
396             testErrors++;
397         }
398         else if (finalMallocFree < 0) {
399             System_printf ("Core %d : - FAILED - %6d more frees than mallocs               -\n",
400                            coreNum, -finalMallocFree);
401             testErrors++;
402         }
403         else {
404             System_printf ("Core %d : - PASSED                                                -\n",
405                            coreNum);
406         }
407         System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
408         System_printf ("\n");           
409     }
410     else {
411         result = Rm_serviceCloseHandle(rmSharedClient1ServiceHandle);
412         ERROR_CHECK(RM_OK, result, rmSharedClient1Handle, "Service handle close failed");
413         result = Rm_serviceCloseHandle(rmSharedClient2ServiceHandle);
414         ERROR_CHECK(RM_OK, result, rmSharedClient2Handle, "Service handle close failed");
415         
416         result = Rm_delete(rmSharedClient1Handle, RM_TEST_TRUE);
417         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Instance delete failed");
418         result = Rm_delete(rmSharedClient2Handle, RM_TEST_TRUE);
419         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Instance delete failed");
421         /* Signal to Shared Server core that the Shared Clients have been deleted */
422         GateMP_leave(clientGate, clientKey);
423     }
425     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
426     System_printf ("Core %d : ------------------ Example Completion -------------------\n", coreNum);
427     if (testErrors) {
428         System_printf ("Core %d : - Test Errors: %-32d         -\n", coreNum, testErrors);
429     }
430     System_printf ("Core %d : ---------------------------------------------------------\n", coreNum);
431     System_printf ("\n"); 
433     BIOS_exit(0);
436 void rmServerTsk(UArg arg0, UArg arg1)
438     Rm_ServiceReqInfo  requestInfo;
439     Rm_ServiceRespInfo responseInfo;
440     Task_Params        taskParams;
442     /* BEGIN testing UNSPECIFIED base and alignment requests on Server */               
443     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
444                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);       
445     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
446     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
447                         coreNum, rmServerName, resourceNameGpQ,
448                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
449                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
450                
451     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
452                  RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
453     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
454     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
455                         coreNum, rmServerName, resourceNameGpQ,
456                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
457                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);      
459     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
460                  RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);     
461     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
462     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
463                         coreNum, rmServerName, resourceNameGpQ,
464                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
465                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);        
466     /* END testing UNSPECIFIED base and alignment requests on Server */      
468     /* Create new NameServer object */                
469     setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ, 
470                  1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
471     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
472     POSITIVE_PASS_CHECK("--------------- Create NameServer Object ----------------", 
473                         coreNum, rmServerName, resourceNameGpQ,
474                         requestInfo.resourceBase, responseInfo.resourceLength, 
475                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
477     /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and 
478      * delete the NameServer object. */
479     GateMP_leave(serverGate, serverKey);
480     clientKey = GateMP_enter(clientGate);
481     GateMP_leave(clientGate, clientKey);
482     serverKey = GateMP_enter(serverGate);
484     /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
485     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion, 
486                  12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
487     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo); 
488     NEGATIVE_PASS_CHECK("------- Use Allocation of Resource Owned by Linux -------", 
489                         coreNum, rmServerName, resourceNameMemRegion,
490                         requestInfo.resourceBase, requestInfo.resourceLength, 
491                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
493     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
494     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
495                  14, 5, 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     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
503                  19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);      
504     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
505     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
506                         coreNum, rmServerName, resourceNameAifRxCh,
507                         requestInfo.resourceBase, requestInfo.resourceLength, 
508                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
509     
510     /* Wait for Client and Client Delegate to do their allocations */
511     GateMP_leave(serverGate, serverKey);
512     clientKey = GateMP_enter(clientGate);
513     GateMP_leave(clientGate, clientKey);
514     serverKey = GateMP_enter(serverGate);      
516     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
517                  25, 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                  34, 3, 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);      
531  
532     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh, 
533                  28, 6, 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);     
540     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
541                  53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
542     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);  
543     POSITIVE_PASS_CHECK("----- Resource Node Expand/Contract Testing (Free) ------", 
544                         coreNum, rmServerName, resourceNameAifRxCh,
545                         requestInfo.resourceBase, requestInfo.resourceLength, 
546                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);  
547     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */  
548     
549     /* Test exclusive rights to an allocated resource */
550     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
551                  2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);      
552     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
553     NEGATIVE_PASS_CHECK("------ Use Allocation of Exclusively Owned Resource -----", 
554                         coreNum, rmServerName, resourceNameAifRxCh,
555                         requestInfo.resourceBase, requestInfo.resourceLength, 
556                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);       
558     /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates */
559     GateMP_leave(serverGate, serverKey);
560     clientKey = GateMP_enter(clientGate);
561     GateMP_leave(clientGate, clientKey);
562     serverKey = GateMP_enter(serverGate);
564     /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
565      * should be approved but the instance should have only one owner instance in resource's owner list */
566     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, 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 (Init) --", 
570                         coreNum, rmServerName, resourceNameGpQ,
571                         requestInfo.resourceBase, requestInfo.resourceLength, 
572                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
574     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
575                  6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);      
576     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
577     POSITIVE_PASS_CHECK("--- Init/Use Allocate of Resource from Same Inst (Use) --", 
578                         coreNum, rmServerName, resourceNameGpQ,
579                         requestInfo.resourceBase, requestInfo.resourceLength, 
580                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
582     /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client.  Expect error or denial. */
583     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
584                  805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
585     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
586     NEGATIVE_PASS_CHECK("- Init Allocation of Shared Linux and Client Resource  --", 
587                         coreNum, rmServerName, resourceNameInfraQ,
588                         805, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);    
590     /* Get the status of a resource from Server */
591     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameAifRxCh, 
592                  53, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
593     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
594     STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
595                       coreNum, rmServerName, responseInfo.resourceName,
596                       responseInfo.resourceBase, responseInfo.resourceLength, 
597                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
598                       responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1); 
600     /* Get the status of a resource from Server */
601     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameQosCluster, 
602                  1, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
603     rmSharedServerServiceHandle->Rm_serviceHandler(rmSharedServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
604     STATUS_PASS_CHECK("----- Status Check of Resources from Shared Server ------", 
605                       coreNum, rmServerName, responseInfo.resourceName,
606                       responseInfo.resourceBase, responseInfo.resourceLength, 
607                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
608                       responseInfo.serviceState, RM_SERVICE_APPROVED, 0, 0);
610 #if PRINT_USED_RESOURCES
611     Rm_resourceStatus(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
612 #endif
614     /* Signal to ClientTsk that Server is ready for cleanup */
615     GateMP_leave(serverGate, serverKey);
616     
617     /* Create the RM cleanup task. */
618     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
619     Task_Params_init (&taskParams);
620     Task_create (rmCleanupTsk, &taskParams, NULL);
623 void rmClientTsk(UArg arg0, UArg arg1)
625     Rm_ServiceReqInfo  requestInfo;
626     Rm_ServiceRespInfo responseInfo;    
627     Task_Params        taskParams;
629     serverKey = GateMP_enter(serverGate);  
631     /* Retrieve a resource via a NameServer name */
632     setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL, 
633                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
634     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
635     POSITIVE_PASS_CHECK("------- Retrieve Resource Via NameServer Object ---------", 
636                         coreNum, rmSharedClient1Name, responseInfo.resourceName,
637                         responseInfo.resourceBase, responseInfo.resourceLength, 
638                         0, responseInfo.serviceState, RM_SERVICE_APPROVED);     
640     /* Allocate the resource returned from the NameServer request */
641     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo)); 
642     requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
643     requestInfo.resourceName = responseInfo.resourceName;
644     requestInfo.resourceBase = responseInfo.resourceBase;
645     requestInfo.resourceLength = responseInfo.resourceLength;
646     requestInfo.resourceNsName = NULL;
647     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
648     POSITIVE_PASS_CHECK("-------- Init Allocate Using Retrieved Resource ---------", 
649                         coreNum, rmSharedClient2Name, responseInfo.resourceName,
650                         requestInfo.resourceBase, requestInfo.resourceLength, 
651                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
653     /* Free resource via a NameServer name */
654     setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL, 
655                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
656     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
657     POSITIVE_PASS_CHECK("--- Free of Retrieved Resource Using NameServer Name ----", 
658                         coreNum, rmSharedClient2Name, nameServerNameFavQ,
659                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
661     /* Delete the NameServer name */
662     setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL, 
663                  0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);     
664     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);     
665     POSITIVE_PASS_CHECK("--------------- Delete NameServer Object ----------------", 
666                         coreNum, rmSharedClient2Name, nameServerNameFavQ,
667                         0, 1, 0, responseInfo.serviceState, RM_SERVICE_APPROVED);      
669     GateMP_leave(clientGate, clientKey);
670     GateMP_leave(serverGate, serverKey);
671     clientKey = GateMP_enter(clientGate);
672     serverKey = GateMP_enter(serverGate);    
674     /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
675     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh, 
676                  0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);     
677     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
678     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Use Allocate) --", 
679                         coreNum, rmSharedClient2Name, resourceNameAifRxCh,
680                         requestInfo.resourceBase, requestInfo.resourceLength, 
681                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
682     
683     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh, 
684                  50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);        
685     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
686     POSITIVE_PASS_CHECK("- Resource Node Expand/Contract Testing (Init Allocate) -", 
687                         coreNum, rmSharedClient1Name, resourceNameAifRxCh,
688                         requestInfo.resourceBase, requestInfo.resourceLength, 
689                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
690     /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
692     GateMP_leave(clientGate, clientKey);
693     GateMP_leave(serverGate, serverKey);
694     clientKey = GateMP_enter(clientGate);
695     serverKey = GateMP_enter(serverGate);  
697     /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
698     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
699                  RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);        
700     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);
701     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
702                         coreNum, rmSharedClient1Name, resourceNameAccumCh,
703                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
704                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);    
706     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
707                  RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);      
708     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo); 
709     POSITIVE_PASS_CHECK("---------- Use Allocation w/ UNSPECIFIED Base -----------", 
710                         coreNum, rmSharedClient2Name, resourceNameAccumCh,
711                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
712                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
714     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh, 
715                  RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);     
716     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
717     POSITIVE_PASS_CHECK("---- Use Allocation w/ UNSPECIFIED Base & Alignment -----", 
718                         coreNum, rmSharedClient2Name, resourceNameAccumCh,
719                         RM_RESOURCE_BASE_UNSPECIFIED, requestInfo.resourceLength, 
720                         RM_RESOURCE_ALIGNMENT_UNSPECIFIED, responseInfo.serviceState, RM_SERVICE_APPROVED);     
721     /* END testing allocations with UNSPECIFIED base and alignment values */    
723     /* Allocate infrastructure queue shared between Linux kernel and Client */
724     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ, 
725                  800, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);     
726     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
727     POSITIVE_PASS_CHECK("-- Init Allocation of Shared Linux and Client Resource --", 
728                         coreNum, rmSharedClient2Name, resourceNameInfraQ,
729                         requestInfo.resourceBase, requestInfo.resourceLength, 
730                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
732     /* BEGIN Allocating some resources without providing a callback function.  RM should block and not return until the result
733      * is returned by the server. */
734     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
735                  7000, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
736     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
737     POSITIVE_PASS_CHECK("- Init Allocation (RM Blocked Until Resource Returned) --", 
738                         coreNum, rmSharedClient2Name, resourceNameGpQ,
739                         requestInfo.resourceBase, requestInfo.resourceLength, 
740                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);      
742     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
743                  7005, 25, 0, NULL, RM_TEST_FALSE, &responseInfo);     
744     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient1ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
745     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
746                         coreNum, rmSharedClient1Name, resourceNameGpQ,
747                         requestInfo.resourceBase, requestInfo.resourceLength, 
748                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
749     
750     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ, 
751                  7010, 5, 0, NULL, RM_TEST_FALSE, &responseInfo);     
752     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
753     POSITIVE_PASS_CHECK("-- Use Allocation (RM Blocked Until Resource Returned) --", 
754                         coreNum, rmSharedClient2Name, resourceNameGpQ,
755                         requestInfo.resourceBase, requestInfo.resourceLength, 
756                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
758     /* Init allocation of resource already owned by Client should return approved and there should only
759      * be one instance of Client in resource's owner list. */
760     setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ, 
761                  7011, 1, 0, NULL, RM_TEST_FALSE, &responseInfo);     
762     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);   
763     POSITIVE_PASS_CHECK("----- Use Allocation of Owned Resource (RM Blocked) -----", 
764                         coreNum, rmSharedClient2Name, resourceNameGpQ,
765                         requestInfo.resourceBase, requestInfo.resourceLength, 
766                         requestInfo.resourceAlignment, responseInfo.serviceState, RM_SERVICE_APPROVED);     
767     /* END Allocating some resources without providing a callback function.  RM should block and not return
768      * until the result is returned by the server. */   
770     /* BEGIN Getting the status of resources from the Shared Clients */
771     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
772                  7012, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);     
773     rmSharedClient2ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
774     STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
775                       coreNum, rmSharedClient2Name, responseInfo.resourceName,
776                       responseInfo.resourceBase, responseInfo.resourceLength, 
777                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
778                       responseInfo.serviceState, RM_SERVICE_APPROVED, 2, 1);   
779     
780     setRmRequest(&requestInfo, Rm_service_RESOURCE_STATUS, resourceNameGpQ, 
781                  4025, 20, 0, NULL, RM_TEST_FALSE, &responseInfo);     
782     rmSharedClient1ServiceHandle->Rm_serviceHandler(rmSharedClient2ServiceHandle->rmHandle, &requestInfo, &responseInfo);
783     STATUS_PASS_CHECK("------- Resource Status Check from Shared Client --------", 
784                       coreNum, rmSharedClient1Name, responseInfo.resourceName,
785                       responseInfo.resourceBase, responseInfo.resourceLength, 
786                       responseInfo.resourceNumOwners, responseInfo.instAllocCount,
787                       responseInfo.serviceState, RM_SERVICE_APPROVED, 1, 0);        
788     /* END Getting the status of resources from Client and CD */    
790     GateMP_leave(clientGate, clientKey);
791     GateMP_leave(serverGate, serverKey);
792     clientKey = GateMP_enter(clientGate);
793     /* Enter Server gate one last time to wait for Server to complete testing prior to entering cleanup */
794     serverKey = GateMP_enter(serverGate);  
795     
796     /* Create the RM cleanup task. */
797     System_printf("Core %d : Creating RM cleanup task...\n", coreNum);
798     Task_Params_init (&taskParams);
799     Task_create (rmCleanupTsk, &taskParams, NULL);
802 void rmStartupTsk(UArg arg0, UArg arg1)
803 {  
804     Int           status;
805     GateMP_Params gateParams;
806     Task_Params   taskParams;
808     if (coreNum == SYSINIT) {
809         GateMP_Params_init(&gateParams);
810         gateParams.name = RM_SERVER_GATE_NAME;
811         /* Disable local protection since only concerned with sync'ing cores */
812         gateParams.localProtect = GateMP_LocalProtect_NONE;
813         serverGate = GateMP_create(&gateParams);
815         serverKey = GateMP_enter(serverGate);  
817         do {
818             status = GateMP_open(RM_CLIENT_GATE_NAME, &clientGate);
819             /* 
820              *  Sleep for 1 clock tick to avoid inundating remote processor
821              *  with interrupts if open failed
822              */
823             if (status < 0) { 
824                 Task_sleep(1);
825             }
826         } while (status < 0);        
827     }
828     else {
829         GateMP_Params_init(&gateParams);
830         gateParams.name = RM_CLIENT_GATE_NAME;
831         /* Disable local protection since only concerned with sync'ing cores */
832         gateParams.localProtect = GateMP_LocalProtect_NONE;
833         clientGate = GateMP_create(&gateParams);
835         clientKey = GateMP_enter(clientGate); 
836         
837         do {
838             status = GateMP_open(RM_SERVER_GATE_NAME, &serverGate);
839             /* 
840              *  Sleep for 1 clock tick to avoid inundating remote processor
841              *  with interrupts if open failed
842              */
843             if (status < 0) { 
844                 Task_sleep(1);
845             }
846         } while (status < 0);
847     }
848  
849     /* Create the RM test tasks. */
850     if (coreNum == SYSINIT) {
851         System_printf("Core %d : Creating RM server task...\n", coreNum);
852         Task_Params_init (&taskParams);
853         taskParams.priority = 1;
854         rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
855     }
856     else if (coreNum) {
857         System_printf("Core %d : Creating RM client task...\n", coreNum);
858         Task_Params_init (&taskParams);
859         taskParams.priority = 1;
860         rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
861     }
864 int main(Int argc, Char* argv[])
866     Rm_InitCfg         rmInitCfg;
867     Task_Params        taskParams; 
868     int                status;
869     int32_t            result;
871     System_printf ("*********************************************************\n");
872     System_printf ("***************** RM Shared Server Test *****************\n");
873     System_printf ("*********************************************************\n");
875     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
877     coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
878     testErrors = 0;
879     
880     /* Initialize the heap in shared memory. Using IPC module to do that */ 
881     System_printf("Core %d: Starting IPC...\n", coreNum);
882     status = Ipc_start();
883     if (status < 0) {
884         System_abort("Ipc_start failed\n");
885     }
887     /* Initialize the RM instances - RM must be initialized before anything else in the system
888      * Core 0: 1 RM Instance  - RM Server
889      * Core 1: 2 RM Instances - RM Client Delegate
890      *                          RM Client
891      */
892     if (coreNum == SYSINIT) {
893         /* Create the Server instance */
894         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
895         rmInitCfg.instName = rmServerName;
896         rmInitCfg.instType = Rm_instType_SHARED_SERVER;
897         rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
898         rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
899         rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
900         rmSharedHandle.sharedServerHandle = Rm_init(&rmInitCfg, &result);
901         ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
903         /* Open Server service handle */
904         rmSharedServerServiceHandle = Rm_serviceOpenHandle(rmSharedHandle.sharedServerHandle, &result);
905         ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
907         Osal_rmEndMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
908     }
909     else {
910         do {
911             Osal_rmBeginMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
912         } while (!rmSharedHandle.sharedServerHandle);
914         /* Create the first Shared Client instance */
915         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
916         rmInitCfg.instName = rmSharedClient1Name;
917         rmInitCfg.instType = Rm_instType_SHARED_CLIENT;
918         rmInitCfg.instCfg.sharedClientCfg.sharedServerHandle = rmSharedHandle.sharedServerHandle;
919         rmSharedClient1Handle = Rm_init(&rmInitCfg, &result);
920         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Initialization failed");
922         /* Open shared client service handle */
923         rmSharedClient1ServiceHandle = Rm_serviceOpenHandle(rmSharedClient1Handle, &result);
924         ERROR_CHECK(RM_OK, result, rmSharedClient1Name, "Service handle open failed");
926         /* Create the second Shared Client instance */
927         memset(&rmInitCfg, 0, sizeof(rmInitCfg));
928         rmInitCfg.instName = rmSharedClient2Name;
929         rmInitCfg.instType = Rm_instType_SHARED_CLIENT;
930         rmInitCfg.instCfg.sharedClientCfg.sharedServerHandle = rmSharedHandle.sharedServerHandle;
931         rmSharedClient2Handle = Rm_init(&rmInitCfg, &result);
932         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Initialization failed");
934         /* Open shared client service handle */
935         rmSharedClient2ServiceHandle = Rm_serviceOpenHandle(rmSharedClient2Handle, &result);
936         ERROR_CHECK(RM_OK, result, rmSharedClient2Name, "Service handle open failed");
937     }
939     /* Create the RM startup task */
940     System_printf("Core %d : Creating RM startup task...\n", coreNum);
941     Task_Params_init (&taskParams);
942     rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
944     System_printf("Core %d : Starting BIOS...\n", coreNum);
945     BIOS_start();
947     return (0);