Removed debug compiler flag
[keystone-rtos/rm-lld.git] / test / rm_test.c
1 /* 
2  * Copyright (c) 2012, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * */
32 /*
33  *  ======== rm_test.c ========
34  *  RM multicore test example
35  *
36  *  This is an example program that uses MessageQ to pass a message
37  *  from one processor to another.
38  *
39  *  Each processor creates its own MessageQ first and then will try to open
40  *  a remote processor's MessageQ.  
41  *
42  *  See message_multicore.k file for expected output.
43  */
45 #include <c6x.h>
46 #include <xdc/std.h>
47 #include <stdio.h>
48 #include <string.h>
49 #include <stdbool.h>
51 /*  -----------------------------------XDC.RUNTIME module Headers    */
52 #include <xdc/runtime/System.h>
53 #include <xdc/runtime/IHeap.h>
55 /*  ----------------------------------- IPC module Headers           */
56 #include <ti/ipc/Ipc.h>
57 #include <ti/ipc/MessageQ.h>
58 #include <ti/ipc/HeapBufMP.h>
59 #include <ti/ipc/MultiProc.h>
61 /*  ----------------------------------- BIOS6 module Headers         */
62 #include <ti/sysbios/BIOS.h>
63 #include <ti/sysbios/knl/Task.h>
64 #include <ti/sysbios/family/c64p/Hwi.h>
66 /*  ----------------------------------- Resource Manager Headers         */
67 #include <ti/drv/rm/rm.h>
68 #include <ti/drv/rm/rm_osal.h>
69 #include <ti/drv/rm/rm_transport.h>
70 #include <ti/drv/rm/rm_services.h>
72 /*  ----------------------------------- CSL Module Headers         */
73 #include <ti/csl/csl_semAux.h>
74 #include <ti/csl/csl_cacheAux.h>
75 #include <ti/csl/csl_xmcAux.h>
77 /* ======== Task Handles ======== */
78 Task_Handle startupRmTskHandle;
79 Task_Handle testReceiveTskHandle;
80 Task_Handle testRmTskHandle;
82 /* ======== Application Heaps ======== */
83 #define RM_PKT_HEAP_NAME   "rmHeapBuf"
84 HeapBufMP_Handle rmPktHeapHandle = NULL;
86 #define MSGQ_HEAP_NAME   "msgQHeapBuf"
87 #define MSGQ_HEAP_ID      0
89 /* ======== RM Instance Names ======== */
90 Char rmServerName[RM_NAME_MAX_CHARS] = "RM_Server";
91 Char rmClientDelegateName[RM_NAME_MAX_CHARS] = "RM_Client_Delegate";
92 Char rmClientName[RM_NAME_MAX_CHARS] = "RM_Client";
94 /* ======== RM IPC MessageQ Names ======== */
95 Char serverFromCdQueueName[30] = "RM_Server_From_CD_Queue";
96 Char cdFromServerQueueName[30] = "RM_CD_From_Server_Queue";
97 Char cdFromClientQueueName[30] = "RM_CD_From_Client_Queue";
98 Char clientFromCdQueueName[30] = "RM_Client_From_CD_Queue";
100 /* ======== Test Resource & NameServer Names ======== */
101 Char resourceNameMemRegion[RM_NAME_MAX_CHARS] = "memory-regions";
102 char resourceNameAccumCh[RM_NAME_MAX_CHARS] = "accumulator-ch";
103 Char resourceNameGpQ[RM_NAME_MAX_CHARS] = "gp-queue";
104 Char resourceNameAifQ[RM_NAME_MAX_CHARS] = "aif-queue";
105 Char resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
106 Char resourceNameAifRxCh[RM_NAME_MAX_CHARS] = "aif-rx-ch";
108 Char nameServerNameFavQ[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
109   
110 /* ======== RM Instance Handles ======== */
111 Rm_Handle rmServerHandle = NULL;
112 Rm_Handle rmClientDelegateHandle = NULL;
113 Rm_Handle rmClientHandle = NULL;
115 /* ======== RM Instance Service Ports ======== */
116 Rm_ServiceHandle *rmServerServiceHandle = NULL;
117 Rm_ServiceHandle *rmClientDelegateServiceHandle = NULL;
118 Rm_ServiceHandle *rmClientServiceHandle = NULL;
120 /* ======== RM Transport Packet Definition ======== */
121 typedef struct {
122   MessageQ_MsgHeader msgQHeader;
123   /* Pointer to packet provided by RM */
124   Rm_Packet *rmPkt;
125 } MsgQ_RmPacket;
127 /* ======== RM Transport Mapping Tables for Application ======== */
128 /* Core 0 Map Entry Indices */
129 #define SERVER_TO_CD_MAP_ENTRY 0
130 /* Core 1 Map Entry Indicies */
131 #define CD_TO_SERVER_MAP_ENTRY 0
132 #define CD_TO_CLIENT_MAP_ENTRY 1
133 #define CLIENT_TO_CD_MAP_ENTRY 2
135 /* Max map entries across all cores */
136 #define MAX_MAPPING_ENTRIES 3
138 typedef struct {
139     Rm_TransportHandle transportHandle;
140     MessageQ_Handle receiveMsgQ;
141 } Transport_MapEntry;
143 /* Core 1 will have three mapping entries
144  * Two map entries for the Client Delegate
145  * One map entry for the Client */
146 Transport_MapEntry rmTransportMap[MAX_MAPPING_ENTRIES];
148 uint32_t waitForBlockingOperation = 0;
149 Rm_ServiceRespInfo responseInfo;
151 /* ======== RM Application Sync APIs ======== */
153 typedef struct {
154     uint32_t sem;
155     uint32_t pad[31];
156 } syncObj;
158 #pragma DATA_SECTION (testSyncObj, ".syncObj");
159 #pragma DATA_ALIGN (testSyncObj, 16)
160 syncObj testSyncObj;
162 /**
163  *  @b Description
164  *  @n
165  *      The function is used to indicate that a block of memory is
166  *      about to be accessed. If the memory block is cached then this
167  *      indicates that the application would need to ensure that the
168  *      cache is updated with the data from the actual memory.
169  *
170  *  @param[in]  ptr
171  *       Address of memory block
172  *
173  *  @param[in]  size
174  *       Size of memory block
175  *
176  *  @retval
177  *      Not Applicable
178  */
179 void beginMemAccess (void *ptr, uint32_t size)
181     uint32_t key;
183     key = Hwi_disable();
185     /* Cleanup the prefetch buffer also. */
186     CSL_XMC_invalidatePrefetchBuffer();
187     /* Invalidate L1D cache and wait until operation is complete.
188      * Use this approach if L2 cache is not enabled */
189     CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
190     asm   (" nop      4");
191     asm   (" nop      4");
192     asm   (" nop      4");
193     asm   (" nop      4");
194     Hwi_restore(key);
197 /**
198  *  @b Description
199  *  @n
200  *      The function is used to indicate that the block of memory has
201  *      finished being accessed. If the memory block is cached then the
202  *      application would need to ensure that the contents of the cache
203  *      are updated immediately to the actual memory.
204  *
205  *  @param[in]  ptr
206  *       Address of memory block
207  *
208  *  @param[in]  size
209  *       Size of memory block
210  *
211  *  @retval
212  *      Not Applicable
213  */
214 void endMemAccess (void *ptr, uint32_t size)
216     uint32_t key;
218     key = Hwi_disable();
220     /* Writeback L1D cache and wait until operation is complete.
221      * Use this approach if L2 cache is not enabled */
222     CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
223     asm   (" nop      4");
224     asm   (" nop      4");
225     asm   (" nop      4");
226     asm   (" nop      4");
227     Hwi_restore(key);
231 void initSyncObj(void)
233     beginMemAccess((void *) &testSyncObj, sizeof(syncObj));    
234     testSyncObj.sem = 0;
235     endMemAccess((void *) &testSyncObj, sizeof(syncObj));
238 void takeSyncObj(void)
240     beginMemAccess((void *) &testSyncObj, sizeof(syncObj));    
241     testSyncObj.sem = 1;
242     endMemAccess((void *) &testSyncObj, sizeof(syncObj));
245 void waitOnSyncObj(void)
247     do {
248         /* Yield for other tasks */
249         Task_yield();
250         beginMemAccess((void *) &testSyncObj, sizeof(syncObj));    
251     } while (testSyncObj.sem == 1);
254 void releaseSyncObj(void)
256     beginMemAccess((void *) &testSyncObj, sizeof(syncObj));    
257     testSyncObj.sem = 0;
258     endMemAccess((void *) &testSyncObj, sizeof(syncObj));
261 /* ======== RM Application Transport APIs ======== */
263 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
265     Rm_Packet     *rmPkt = NULL;
266     MsgQ_RmPacket *rmMsg = NULL;
268     /* Allocate a messageQ message for containing the RM packet */
269     rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
270     if (rmMsg == NULL) {
271         System_printf("Core %d: MessageQ_alloc failed in TransportSend\n", MultiProc_self());
272         *pktHandle = NULL;
273         return(NULL);
274     }
275     else {
276         /* Create and attach RM packet to MessageQ message.  All transports will allocate from the same heap */
277         rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
278         rmPkt->pktLenBytes = pktSize;
279         endMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
280         rmMsg->rmPkt = rmPkt;
281         *pktHandle = (Rm_PacketHandle)rmMsg;
282     }
283     return (rmPkt);
286 void transportFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
288     uint32_t pktSize = pkt->pktLenBytes;
289     int32_t  status;
291     /* All transports will free rmPkts to the same heap */
292     HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
294     status = MessageQ_free(rmMsgQMsg);
295     if (status < 0) { 
296         System_printf("Core %d: MessageQ_free had a failure/error in transportFree\n", MultiProc_self());
297     }     
300 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
302     MessageQ_QueueId  remoteQueueId = (MessageQ_QueueId)appTransport;
303     MsgQ_RmPacket    *rmMsg = pktHandle;
304     int32_t           status;    
306     /* Write back data that was written by RM after alloc */
307     endMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
309     /* Send the message to the remote side */
310     status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
311     if (status < 0) {
312         transportFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
313         System_printf("Core %d: MessageQ_put had a failure/error in TransportSend: error: %d\n", MultiProc_self(),
314                                                                                                  status);
315     }
316     return (status);
319 void transportReceive (uint32_t transportMapEntry)
321     MessageQ_Handle  receiveQ;
322     int32_t          numPkts;
323     MessageQ_Msg     rmMsg = NULL;
324     Rm_Packet       *rmPkt = NULL;
325     int32_t          status;
326     uint32_t         i;  
328     /* Check if any packets available */
329     receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
330     numPkts = (int32_t) MessageQ_count(receiveQ);
332     /* Process all available packets */
333     for (i = 0; i < numPkts; i++) {
334         status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
335         if (status < 0) {
336             System_abort("This should not happen since timeout is forever\n");
337         }
338         if (rmMsg == NULL) {
339             System_printf("Core %d: MessageQ_get failed returning a null packet in TransportReceive\n", MultiProc_self());
340         }
342         /* Extract the Rm_Packet from the RM msg */
343         rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
344         beginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
346         /* Provide packet to RM for processing */
347         if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
348             System_printf("Core %d: RM encountered error processing received packet: %d\n", MultiProc_self(), status);
349         }
351         /* Free RM packet buffer and messageQ message */
352         transportFree(rmMsg, rmPkt);
353     }
356 /*
357  *  ======== testServiceCallback ========
358  *  Application's callback function given to RM on service requests
359  */
360 void testServiceCallback(Rm_ServiceRespInfo *serviceResponse)
362     if (serviceResponse->serviceId == waitForBlockingOperation) {
363         waitForBlockingOperation = 0;
364         strcpy(responseInfo.resourceName, serviceResponse->resourceName);
365         responseInfo.resourceBase = serviceResponse->resourceBase;
366         responseInfo.resourceLength = serviceResponse->resourceLength;
367         responseInfo.serviceState = serviceResponse->serviceState;
368     }
369     else {
370         System_printf("Core %d: validation of static request with ID %d\n", MultiProc_self(),
371                                                                             serviceResponse->serviceId);
372         System_printf("         resource: %s, state: %d, base: %d, length: %d\n", serviceResponse->resourceName,
373                                                                                   serviceResponse->serviceState,
374                                                                                   serviceResponse->resourceBase,
375                                                                                   serviceResponse->resourceLength);                                                                                          
376     }
379 bool blockForResponse(Rm_ServiceRespInfo *respInfo)
381     waitForBlockingOperation = respInfo->serviceId;
382     /* Block and wait for the response if the RM needed to perform a blocking operation
383      * to complete the request */
384     while(waitForBlockingOperation) {
385         /* Yield to receive task to see if there are any packets for RM instance */
386         Task_yield();
387     }       
389     if ((respInfo->serviceState != RM_SERVICE_PROCESSING) &&
390         (respInfo->serviceState != RM_SERVICE_APPROVED) &&
391         (respInfo->serviceState != RM_SERVICE_APPROVED_STATIC)) {
392         System_printf("Core %d: Service request encountered error or denial: %d\n", MultiProc_self(),
393                                                                                     respInfo->serviceState);
394         return(FALSE);
395     }
396     return(TRUE);
399 /*
400  *  ======== testRmTsk ========
401  *  RM cleanup task
402  */
403 void cleanupRmTsk(UArg arg0, UArg arg1)
405     /* Delete the RM test task */
406     System_printf("Core %d: Deleting RM test task...\n", MultiProc_self());
407     if (testRmTskHandle) {
408         Task_delete(&testRmTskHandle);
409         /* Set the task handle to be NULL so that the delete only occurs once */
410         testRmTskHandle = NULL;
411     }
412     /* Delete the RM receive task */
413     System_printf("Core %d: Deleting RM receive task...\n", MultiProc_self());
414     if (testReceiveTskHandle) {
415         Task_delete(&testReceiveTskHandle);
416         /* Set the task handle to be NULL so that the delete only occurs once */
417         testReceiveTskHandle = NULL;
418     }
420     /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
422     BIOS_exit(0);
425 /*
426  *  ======== testRmTsk ========
427  *  RM test task
428  */
429 void testReceiveTsk(UArg arg0, UArg arg1)
431     while(1) {
432         if (MultiProc_self() == 0) {
433             transportReceive(SERVER_TO_CD_MAP_ENTRY);
434         }
435         else if (MultiProc_self() == 1) {
436             transportReceive(CD_TO_SERVER_MAP_ENTRY);
437             transportReceive(CD_TO_CLIENT_MAP_ENTRY);
438             transportReceive(CLIENT_TO_CD_MAP_ENTRY);
439         }
440         /* Yield for main test task */
441         Task_yield();
442     }
445 /*
446  *  ======== testRmTsk ========
447  *  RM test task
448  */
449 void testRmTsk(UArg arg0, UArg arg1)
451     Rm_ServiceReqInfo requestInfo;
452     Task_Params taskParams;
453     int32_t result;
454        
455     /* Delete the RM startup task */
456     System_printf("Core %d: Deleting RM startup task...\n", MultiProc_self());
457     if (startupRmTskHandle) {
458         Task_delete(&startupRmTskHandle);
459         /* Set the task handle to be NULL so that the delete only occurs once */
460         startupRmTskHandle = NULL;
461     }
463     /* Open service ports on all the RM instances to test service requests from the different
464      * RM instances */
465     if (MultiProc_self() == 0) {
466         rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
468         Rm_printInstanceStatus(rmServerHandle);
469     }
470     else if (MultiProc_self() == 1) {
471         /* CD and Client serviceHandles were allocated in main() for static allocations.
472          * just reuse */
473          
474         Rm_printInstanceStatus(rmClientDelegateHandle);
475         Rm_printInstanceStatus(rmClientHandle);
476     }
478     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
479     memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
481     System_printf("Core %d: Testing NameServer features...\n", MultiProc_self());
483     /* Use the service ports to test the service requests */
484     if (MultiProc_self() == 0) {
485         /* Issue the service request create a new NameServer object via the service port */                
486         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
487         requestInfo.resourceName = resourceNameGpQ;
488         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
489         requestInfo.resourceLength = 1;
490         requestInfo.resourceAlignment = 0;
491         requestInfo.callback.serviceCallback = testServiceCallback;
492         
493         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
494         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
495         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
496             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
497             if (blockForResponse(&responseInfo)) {
498                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
499                                                                                           rmServerName,
500                                                                                           responseInfo.resourceName, 
501                                                                                           responseInfo.resourceBase,
502                                                                                           responseInfo.resourceLength);            
503             }  
504         }
505         else {
506             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
507                                                                                 responseInfo.serviceState);
508         }            
510         /* Issue the service request create a new NameServer object via the service port */                
511         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
512         requestInfo.resourceName = resourceNameGpQ;
513         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
514         requestInfo.resourceLength = 1;
515         requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
516         requestInfo.callback.serviceCallback = testServiceCallback;
517         
518         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
519         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
520         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
521             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
522             if (blockForResponse(&responseInfo)) {
523                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
524                                                                                           rmServerName,
525                                                                                           responseInfo.resourceName, 
526                                                                                           responseInfo.resourceBase,
527                                                                                           responseInfo.resourceLength);            
528             } 
529         }
530         else {
531             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
532                                                                                 responseInfo.serviceState);
533         }            
535         /* Issue the service request create a new NameServer object via the service port */                
536         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
537         requestInfo.resourceName = resourceNameGpQ;
538         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
539         requestInfo.resourceLength = 1;
540         requestInfo.resourceAlignment = 200;
541         requestInfo.callback.serviceCallback = testServiceCallback;
542         
543         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
544         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
545         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
546             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
547             if (blockForResponse(&responseInfo)) {
548                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
549                                                                                           rmServerName,
550                                                                                           responseInfo.resourceName, 
551                                                                                           responseInfo.resourceBase,
552                                                                                           responseInfo.resourceLength);            
553             }  
554         }
555         else {
556             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
557                                                                                 responseInfo.serviceState);
558         }            
560         Rm_printResourceStatus(rmServerHandle);
563         /* Issue the service request create a new NameServer object via the service port */                
564         requestInfo.type = Rm_service_RESOURCE_MAP_TO_NAME;
565         requestInfo.resourceName = resourceNameGpQ;
566         requestInfo.resourceBase = 1002;
567         requestInfo.resourceLength = 1;
568         requestInfo.resourceNsName = nameServerNameFavQ;
569         requestInfo.callback.serviceCallback = testServiceCallback;
570         
571         System_printf("Core %d: %s creating NameServer object...\n", MultiProc_self(), rmServerName);
572         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
573         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
574             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
575             if (blockForResponse(&responseInfo)) {
576                 System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
577                                                                                                  rmServerName,
578                                                                                                  nameServerNameFavQ, 
579                                                                                                  requestInfo.resourceBase,
580                                                                                                  requestInfo.resourceLength);            
581             }
582         }
583         else {
584             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
585                                                                                 responseInfo.serviceState);
586         }            
588         /* Wait for Client Delegate and Client to retrieve resource via the name and allocate it */
589         waitOnSyncObj();
591         Rm_printResourceStatus(rmServerHandle);
593         /* Wait for Client to free resource via the NameServer and delete the NameServer object. */
594         waitOnSyncObj();
596         Rm_printResourceStatus(rmServerHandle);
598         /* Try to allocate the memory region taken by the Linux Kernel */
599         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
600         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
601         requestInfo.resourceName = resourceNameMemRegion;
602         requestInfo.resourceBase = 12;
603         requestInfo.resourceLength = 1;
604         requestInfo.callback.serviceCallback = testServiceCallback;
605         
606         System_printf("Core %d: %s Trying to reserve memory region taken by Linux...\n", MultiProc_self(), rmServerName);
607         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
608         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
609             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
610             if (blockForResponse(&responseInfo)) {
611                 System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
612                                                                                                               rmServerName,
613                                                                                                               requestInfo.resourceName, 
614                                                                                                               requestInfo.resourceBase,
615                                                                                                               requestInfo.resourceLength);            
616             }  
617         }
618         else {
619             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
620                                                                                 responseInfo.serviceState);
621         }            
623         /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
624         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
625         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
626         requestInfo.resourceName = resourceNameAifRxCh;
627         requestInfo.resourceBase = 14;
628         requestInfo.resourceLength = 5;
629         requestInfo.callback.serviceCallback = testServiceCallback;
630         
631         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
632         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
633         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
634             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
635             if (blockForResponse(&responseInfo)) {
636                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
637                                                                                           rmServerName,
638                                                                                           requestInfo.resourceName, 
639                                                                                           requestInfo.resourceBase,
640                                                                                           requestInfo.resourceLength);            
641             }   
642         }
643         else {
644             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
645                                                                                 responseInfo.serviceState);
646         }            
647         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
648         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
649         requestInfo.resourceName = resourceNameAifRxCh;
650         requestInfo.resourceBase = 19;
651         requestInfo.resourceLength = 31;
652         requestInfo.callback.serviceCallback = testServiceCallback;
653         
654         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
655         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
656         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
657             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
658             if (blockForResponse(&responseInfo)) {
659                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
660                                                                                           rmServerName,
661                                                                                           requestInfo.resourceName, 
662                                                                                           requestInfo.resourceBase,
663                                                                                           requestInfo.resourceLength);            
664             }   
665         }
666         else {
667             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
668                                                                                 responseInfo.serviceState);
669         }            
670         
671         /* Wait for Client and Client Delegate to do their allocates */
672         waitOnSyncObj();
674         Rm_printResourceStatus(rmServerHandle);        
676         /* Free resources to show tree handling of different frees */
677         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
678         requestInfo.type = Rm_service_RESOURCE_FREE;
679         requestInfo.resourceName = resourceNameAifRxCh;
680         requestInfo.resourceBase = 25;
681         requestInfo.resourceLength = 3;
682         requestInfo.callback.serviceCallback = testServiceCallback;
683         
684         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
685         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
686         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
687             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
688             if (blockForResponse(&responseInfo)) {
689                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
690                                                                                           rmServerName,
691                                                                                           requestInfo.resourceName, 
692                                                                                           requestInfo.resourceBase,
693                                                                                           requestInfo.resourceLength);            
694             }  
695         }
696         else {
697             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
698                                                                                 responseInfo.serviceState);
699         }            
700         
701         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
702         requestInfo.type = Rm_service_RESOURCE_FREE;
703         requestInfo.resourceName = resourceNameAifRxCh;
704         requestInfo.resourceBase = 34;
705         requestInfo.resourceLength = 3;
706         requestInfo.callback.serviceCallback = testServiceCallback;
707         
708         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
709         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
710         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
711             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
712             if (blockForResponse(&responseInfo)) {
713                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
714                                                                                           rmServerName,
715                                                                                           requestInfo.resourceName, 
716                                                                                           requestInfo.resourceBase,
717                                                                                           requestInfo.resourceLength);            
718             }   
719         }
720         else {
721             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
722                                                                                 responseInfo.serviceState);
723         }                    
724      
725         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
726         requestInfo.type = Rm_service_RESOURCE_FREE;
727         requestInfo.resourceName = resourceNameAifRxCh;
728         requestInfo.resourceBase = 28;
729         requestInfo.resourceLength = 6;
730         requestInfo.callback.serviceCallback = testServiceCallback;
731         
732         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
733         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
734         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
735             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
736             if (blockForResponse(&responseInfo)) {
737                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
738                                                                                           rmServerName,
739                                                                                           requestInfo.resourceName, 
740                                                                                           requestInfo.resourceBase,
741                                                                                           requestInfo.resourceLength);            
742             } 
743         }
744         else {
745             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
746                                                                                 responseInfo.serviceState);
747         }                
749         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
750         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
751         requestInfo.resourceName = resourceNameAifRxCh;
752         requestInfo.resourceBase = 53;
753         requestInfo.resourceLength = 2;
754         requestInfo.callback.serviceCallback = testServiceCallback;
755         
756         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
757         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
758         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
759             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
760             if (blockForResponse(&responseInfo)) {
761                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
762                                                                                           rmServerName,
763                                                                                           requestInfo.resourceName, 
764                                                                                           requestInfo.resourceBase,
765                                                                                           requestInfo.resourceLength);            
766             } 
767         }
768         else {
769             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
770                                                                                 responseInfo.serviceState);
771         }            
772         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
773         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
774         requestInfo.resourceName = resourceNameAifRxCh;
775         requestInfo.resourceBase = 2;
776         requestInfo.resourceLength = 2;
777         requestInfo.callback.serviceCallback = testServiceCallback;
778         
779         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
780         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
781         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
782             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
783             if (blockForResponse(&responseInfo)) {
784                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
785                                                                                           rmServerName,
786                                                                                           requestInfo.resourceName, 
787                                                                                           requestInfo.resourceBase,
788                                                                                           requestInfo.resourceLength);            
789             }   
790         }
791         else {
792             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
793                                                                                 responseInfo.serviceState);
794         }            
795         
796         Rm_printResourceStatus(rmServerHandle); 
798         /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates */
799         waitOnSyncObj();
801         Rm_printResourceStatus(rmServerHandle);
803         /* Test allocation of a resource twice from the same instance with init and use privileges.  Both
804          * should be approved but the instance should only be mentioned once in the resource's owner list */
805         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
806         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
807         requestInfo.resourceName = resourceNameGpQ;
808         requestInfo.resourceBase = 6543;
809         requestInfo.resourceLength = 10;
810         requestInfo.callback.serviceCallback = testServiceCallback;
811         
812         System_printf("Core %d: %s Allocating resource for init...\n", MultiProc_self(), rmServerName);
813         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
814         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
815             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
816             if (blockForResponse(&responseInfo)) {
817                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
818                                                                                           rmServerName,
819                                                                                           requestInfo.resourceName, 
820                                                                                           requestInfo.resourceBase,
821                                                                                           requestInfo.resourceLength);            
822             }   
823         }
824         else {
825             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
826                                                                                 responseInfo.serviceState);
827         }     
828         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
829         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
830         requestInfo.resourceName = resourceNameGpQ;
831         requestInfo.resourceBase = 6543;
832         requestInfo.resourceLength = 10;
833         requestInfo.callback.serviceCallback = testServiceCallback;
834         
835         System_printf("Core %d: %s Allocating same resource for use...\n", MultiProc_self(), rmServerName);
836         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
837         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
838             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
839             if (blockForResponse(&responseInfo)) {
840                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
841                                                                                           rmServerName,
842                                                                                           requestInfo.resourceName, 
843                                                                                           requestInfo.resourceBase,
844                                                                                           requestInfo.resourceLength);            
845             }   
846         }
847         else {
848             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
849                                                                                 responseInfo.serviceState);
850         }         
852         Rm_printResourceStatus(rmServerHandle);        
853     }
854     else if (MultiProc_self() == 1) {    
855         /* Issue the service request for the resources tied to the name via the service port */                
856         requestInfo.type = Rm_service_RESOURCE_GET_BY_NAME;
857         requestInfo.resourceNsName = nameServerNameFavQ;
858         requestInfo.callback.serviceCallback = testServiceCallback;
859         
860         System_printf("Core %d: %s getting resources tied to NameServer object...\n", MultiProc_self(), 
861                                                                                       rmClientDelegateName);
862         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
863         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
864             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
865             if (blockForResponse(&responseInfo)) {
866                 System_printf("Core %d: %s got Name: %s base: %d length: %d\n", MultiProc_self(),
867                                                                                 rmClientDelegateName, 
868                                                                                 nameServerNameFavQ, 
869                                                                                 responseInfo.resourceBase,
870                                                                                 responseInfo.resourceLength);
871             }
872         }
873         else {
874             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
875                                                                                 responseInfo.serviceState);
876         }            
878         /* Allocate the resources via the service port from the Client */
879         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
880         requestInfo.resourceName = responseInfo.resourceName;
881         requestInfo.resourceBase = responseInfo.resourceBase;
882         requestInfo.resourceLength = responseInfo.resourceLength;
883         requestInfo.resourceNsName = NULL;
884         requestInfo.callback.serviceCallback = testServiceCallback;
885         
886         System_printf("Core %d: %s allocating resources...\n", MultiProc_self(), rmClientName);
887         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
888         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
889             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
890             if (blockForResponse(&responseInfo)) {
891                 System_printf("Core %d: %s allocated resources: %s base: %d length: %d\n", MultiProc_self(),
892                                                                                            rmClientName, 
893                                                                                            nameServerNameFavQ, 
894                                                                                            responseInfo.resourceBase,
895                                                                                            responseInfo.resourceLength);
896             }
897         }
898         else {
899             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
900                                                                                 responseInfo.serviceState);
901         }            
903         /* Release the syncObj so Server can print results of NameServer object add and resource allocate */
904         releaseSyncObj();
906         /* Take the syncObj to free the name resource via the name, rather than the base+length */
907         takeSyncObj();
909         /* Free the named resource using the name via the service port from the Client */
910         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
911         requestInfo.type = Rm_service_RESOURCE_FREE;
912         requestInfo.resourceNsName = nameServerNameFavQ;
913         requestInfo.callback.serviceCallback = testServiceCallback;
914         
915         System_printf("Core %d: %s freeing resource via name...\n", MultiProc_self(), rmClientName);
916         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
917         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
918             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
919             if (blockForResponse(&responseInfo)) {
920                 System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
921                                                                             rmClientName, 
922                                                                             nameServerNameFavQ);
923             }
924         }
925         else {
926             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
927                                                                                 responseInfo.serviceState);
928         }            
930         /* Delete the name object from the NameServer */
931         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
932         requestInfo.type = Rm_service_RESOURCE_UNMAP_NAME;
933         requestInfo.resourceNsName = nameServerNameFavQ;
934         requestInfo.callback.serviceCallback = testServiceCallback;
935         
936         System_printf("Core %d: %s Deleting NameServer object: %s...\n", MultiProc_self(), 
937                                                                          rmClientName,
938                                                                          nameServerNameFavQ);
939         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
940         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
941             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
942             if (blockForResponse(&responseInfo)) {
943                 System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
944                                                                              rmClientName, 
945                                                                              nameServerNameFavQ);
946             }
947         }
948         else {
949             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
950                                                                                 responseInfo.serviceState);
951         }            
953         /* Release the syncObj so Server can print results of resource free and NameServer object delete. */
954         releaseSyncObj();   
956         /* Take the syncObj to allocate resources for testing resource tree interactions. */
957         takeSyncObj();
959         /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
960         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
961         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
962         requestInfo.resourceName = resourceNameAifRxCh;
963         requestInfo.resourceBase = 0;
964         requestInfo.resourceLength = 6;
965         requestInfo.callback.serviceCallback = testServiceCallback;
966         
967         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
968         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
969         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
970             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
971             if (blockForResponse(&responseInfo)) {
972                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
973                                                                                           rmClientName,
974                                                                                           requestInfo.resourceName, 
975                                                                                           requestInfo.resourceBase,
976                                                                                           requestInfo.resourceLength);            
977             }  
978         }
979         else {
980             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
981                                                                                 responseInfo.serviceState);
982         }            
983         
984         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
985         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
986         requestInfo.resourceName = resourceNameAifRxCh;
987         requestInfo.resourceBase = 50;
988         requestInfo.resourceLength = 7;
989         requestInfo.callback.serviceCallback = testServiceCallback;
990         
991         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
992         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
993         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
994             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
995             if (blockForResponse(&responseInfo)) {
996                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
997                                                                                           rmClientDelegateName,
998                                                                                           requestInfo.resourceName, 
999                                                                                           requestInfo.resourceBase,
1000                                                                                           requestInfo.resourceLength);            
1001             }  
1002         }
1003         else {
1004             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1005                                                                                 responseInfo.serviceState);
1006         }            
1008         /* Release the syncObj so Server can print results of resource allocations */
1009         releaseSyncObj();    
1011         /* Take the syncObj to allocate resources using the UNSPECIFIED parameters. */
1012         takeSyncObj();
1014         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
1015         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
1016         requestInfo.resourceName = resourceNameAccumCh;
1017         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
1018         requestInfo.resourceLength = 5;
1019         requestInfo.resourceAlignment = 4;
1020         requestInfo.callback.serviceCallback = testServiceCallback;
1021         
1022         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
1023         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
1024         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
1025             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
1026             if (blockForResponse(&responseInfo)) {
1027                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
1028                                                                                           rmClientDelegateName,
1029                                                                                           responseInfo.resourceName, 
1030                                                                                           responseInfo.resourceBase,
1031                                                                                           responseInfo.resourceLength);            
1032             }    
1033         }
1034         else {
1035             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1036                                                                                 responseInfo.serviceState);
1037         }            
1039         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
1040         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
1041         requestInfo.resourceName = resourceNameAccumCh;
1042         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
1043         requestInfo.resourceLength = 2;
1044         requestInfo.resourceAlignment = 1;
1045         requestInfo.callback.serviceCallback = testServiceCallback;
1046         
1047         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
1048         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1049         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
1050             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
1051             if (blockForResponse(&responseInfo)) {
1052                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
1053                                                                                           rmClientName,
1054                                                                                           responseInfo.resourceName, 
1055                                                                                           responseInfo.resourceBase,
1056                                                                                           responseInfo.resourceLength);            
1057             } 
1058         }
1059         else {
1060             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1061                                                                                 responseInfo.serviceState);
1062         }            
1064         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
1065         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
1066         requestInfo.resourceName = resourceNameAccumCh;
1067         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
1068         requestInfo.resourceLength = 2;
1069         requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
1070         requestInfo.callback.serviceCallback = testServiceCallback;
1071         
1072         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
1073         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1074         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
1075             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
1076             if (blockForResponse(&responseInfo)) {
1077                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
1078                                                                                           rmClientName,
1079                                                                                           responseInfo.resourceName, 
1080                                                                                           responseInfo.resourceBase,
1081                                                                                           responseInfo.resourceLength);            
1082             }  
1083         }
1084         else {
1085             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1086                                                                                 responseInfo.serviceState);
1087         }            
1089         /* Release the syncObj so Server can print results of resource allocations */
1090         releaseSyncObj();           
1091     }
1093     System_printf("Core %d: Testing is complete\n", MultiProc_self());
1094     
1095     /* Create the RM cleanup task. */
1096     System_printf("Core %d: Creating RM cleanup task...\n", MultiProc_self());
1097     Task_Params_init (&taskParams);
1098     Task_create (cleanupRmTsk, &taskParams, NULL);
1101 /*
1102  *  ======== startupRmTsk ========
1103  *  Configures application transports and registers them with RM
1104  */
1105 Void startupRmTsk(UArg arg0, UArg arg1)
1107     MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
1108     MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
1109     Int                status, i;
1110     HeapBufMP_Handle   msgQHeapHandle;
1111     HeapBufMP_Params   heapBufParams;
1112     Rm_TransportCfg    rmTransportCfg;
1113     int32_t            result = 0;
1114     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
1115     Task_Params        taskParams;
1117     if (MultiProc_self() == 1) {
1118         /* Take the syncObj on core 1, preparing for RM testing */
1119         takeSyncObj();  
1120     }
1122     /* Initialize the transport map */
1123     for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
1124         rmTransportMap[i].transportHandle = NULL;
1125     }
1127     if (MultiProc_self() == 0) {
1128         /* Create the heap that will be used to allocate RM messages. This
1129          * heap is a multi-processor heap.  It will be shared amongst
1130          * all RM instances. */     
1131         HeapBufMP_Params_init(&heapBufParams);
1132         heapBufParams.regionId       = 0;
1133         heapBufParams.name           = RM_PKT_HEAP_NAME;
1134         heapBufParams.numBlocks      = 64;
1135         heapBufParams.blockSize      = sizeof(Rm_Packet);
1136         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
1137         if (rmPktHeapHandle == NULL) {
1138             System_abort("HeapBufMP_create failed for RM packet heap\n" );
1139         }
1140         System_printf("Core %d: RM packet heap created\n", MultiProc_self());
1142         /* Create the heap that will be used to allocate messageQ messages. */     
1143         HeapBufMP_Params_init(&heapBufParams);
1144         heapBufParams.regionId       = 0;
1145         heapBufParams.name           = MSGQ_HEAP_NAME;
1146         heapBufParams.numBlocks      = 64;
1147         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
1148         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
1149         if (msgQHeapHandle == NULL) {
1150             System_abort("HeapBufMP_create failed MessageQ message heap\n" );
1151         } 
1152         System_printf("Core %d: IPC MessageQ message heap created\n", MultiProc_self());
1153     }
1154     else {
1155         /* Open the heaps created by the other processor. Loop until opened. */
1156         do {
1157             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
1158             /* 
1159              *  Sleep for 1 clock tick to avoid inundating remote processor
1160              *  with interrupts if open failed
1161              */
1162             if (status < 0) { 
1163                 Task_sleep(1);
1164             }
1165         } while (status < 0);
1166         System_printf("Core %d: RM packet heap opened\n", MultiProc_self());
1167         
1168         do {
1169             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
1170             /* 
1171              *  Sleep for 1 clock tick to avoid inundating remote processor
1172              *  with interrupts if open failed
1173              */
1174             if (status < 0) { 
1175                 Task_sleep(1);
1176             }
1177         } while (status < 0);
1178         System_printf("Core %d: IPC MessageQ message heap opened\n", MultiProc_self());
1179     }
1180     
1181     /* Register the MessageQ heap with MessageQ */
1182     MessageQ_registerHeap((IHeap_Handle)msgQHeapHandle, MSGQ_HEAP_ID);
1184     /* Create the messageQ's for each RM instance connection
1185      * Need four queues.  Topology will be:
1186      * RM Server <---> RM Client Delegate <---> RM Client 
1187      * 1 queues on RM Server
1188      * 2 queues on RM Client Delegate
1189      * 1 queues on RM Client */
1190     if (MultiProc_self() == 0) {
1191         serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
1192         if (serverFromCdMsgQ == NULL) {
1193             System_abort("MessageQ_create failed for RM Server - Client Delegate queue\n" );
1194         }
1195         System_printf("Core %d: RM Server MessageQ created for receiving packets from RM CD\n", MultiProc_self());
1196     }
1197     else if (MultiProc_self() == 1) {
1198         cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
1199         if (cdFromServerMsgQ == NULL) {
1200             System_abort("MessageQ_create failed for RM Client Delegate - Server queue\n" );
1201         }
1202         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Server\n", MultiProc_self());
1203         
1204         cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
1205         if (cdFromClientMsgQ == NULL) {
1206             System_abort("MessageQ_create failed for RM Client Delegate - Client queue\n" );
1207         } 
1208         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Client\n", MultiProc_self());
1209         
1210         clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
1211         if (clientFromCdMsgQ == NULL) 
1212         {
1213             System_abort("MessageQ_create failed for RM Client - Client Delegate queue\n" );
1214         }
1215         System_printf("Core %d: RM Client MessageQ created for receiving packets from RM CD\n", MultiProc_self());
1216     }
1217     
1218     /* Open the remote message queues. Also register the RM transports with each RM instance */
1219     if (MultiProc_self() == 0) {
1220         /* Open the Client Delegate messageQ from the Server */
1221         do {
1222             status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
1223             /* 
1224              *  Sleep for 1 clock tick to avoid inundating remote processor
1225              *  with interrupts if open failed
1226              */
1227             if (status < 0) { 
1228                 Task_sleep(1);
1229             }
1230         } while (status < 0);
1231         System_printf("Core %d: RM CD MessageQ opened from RM Server\n", MultiProc_self());
1233         /* Register the Client Delegate with the RM Server Instance */
1234         rmTransportCfg.rmHandle = rmServerHandle;
1235         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
1236         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1237         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
1238         /* Set the callouts as valid for the first transport configuration on Server instance */
1239         rmTransportCfg.transportCalloutsValid = true;
1240         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1241         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1242         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1244         /* Store the mapping information in the transport map */
1245         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
1246         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
1247         System_printf("Core %d: Registered RM Server <=> RM CD transport with RM Server instance\n", MultiProc_self());
1248     }
1249     else if (MultiProc_self() == 1) {
1250         /* Open the Server messageQ from the Client Delegate */
1251         do {
1252             status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
1253             /* 
1254              *  Sleep for 1 clock tick to avoid inundating remote processor
1255              *  with interrupts if open failed
1256              */
1257             if (status < 0) { 
1258                 Task_sleep(1);
1259             }
1260         } while (status < 0);
1261         System_printf("Core %d: RM Server MessageQ opened from RM CD\n", MultiProc_self());
1263         /* Register the Server with the RM Client Delegate Instance */
1264         rmTransportCfg.rmHandle = rmClientDelegateHandle;
1265         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
1266         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
1267         rmTransportCfg.remoteInstName = &rmServerName[0];
1268         /* Set the callouts as valid for the first transport configuration on Client Delegate instance */
1270         rmTransportCfg.transportCalloutsValid = true;
1271         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1272         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1273         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
1275         /* Store the mapping information in the transport map */
1276         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
1277         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
1278         System_printf("Core %d: Registered RM CD <=> RM Server transport with RM CD instance\n", MultiProc_self());
1279         
1280         /* Open the Client messageQ from the Client Delegate */
1281         do {
1282             status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
1283             /* 
1284              *  Sleep for 1 clock tick to avoid inundating remote processor
1285              *  with interrupts if open failed
1286              */
1287             if (status < 0) { 
1288                 Task_sleep(1);
1289             }
1290         } while (status < 0);
1291         System_printf("Core %d: RM Client MessageQ opened from RM CD\n", MultiProc_self());
1293         /* Register the Client with the RM Client Delegate Instance */
1294         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
1295         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
1296         rmTransportCfg.remoteInstName = &rmClientName[0];
1297         /* Callouts already set on the Client Delegate so set them as invalid */
1298         rmTransportCfg.transportCalloutsValid = false;
1299         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
1301         /* Store the mapping information in the transport map */
1302         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
1303         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
1304         System_printf("Core %d: Registered RM CD <=> RM Client transport with RM CD instance\n", MultiProc_self());
1306         /* Open the Client Delegate messageQ from the Client */        
1307         do {
1308             status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
1309             /* 
1310              *  Sleep for 1 clock tick to avoid inundating remote processor
1311              *  with interrupts if open failed
1312              */
1313             if (status < 0) { 
1314                 Task_sleep(1);
1315             }
1316         } while (status < 0);
1317         System_printf("Core %d: RM CD MessageQ opened from RM Client\n", MultiProc_self());
1319         /* Register the Client Delegate with the RM Client Instance */
1320         rmTransportCfg.rmHandle = rmClientHandle;
1321         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
1322         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1323         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
1324         /* Set the callouts as valid for the first transport configuration on Client instance */
1325         rmTransportCfg.transportCalloutsValid = true;
1326         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1327         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1328         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1330         /* Store the mapping information in the transport map */
1331         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
1332         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
1333         System_printf("Core %d: Registered RM Client <=> RM CD transport with RM Client instance\n", MultiProc_self());
1334     }
1336     /* Create the RM receive task. */
1337     System_printf("Core %d: Creating RM receive task...\n", MultiProc_self());
1338     Task_Params_init (&taskParams);
1339     testReceiveTskHandle = Task_create (testReceiveTsk, &taskParams, NULL);
1340     
1341     
1342     /* Create the RM test task. */
1343     System_printf("Core %d: Creating RM test task...\n", MultiProc_self());
1344     Task_Params_init (&taskParams);
1345     testRmTskHandle = Task_create (testRmTsk, &taskParams, NULL);
1348 /*
1349  *  ======== main ========
1350  *  Synchronizes all processors (in Ipc_start) and calls BIOS_start
1351  */
1352 Int main(Int argc, Char* argv[])
1354     Rm_InitCfg         rmInitCfg;
1355     Task_Params        taskParams;
1356     FILE              *globalResourceFp;
1357     FILE              *linuxDtbFp;
1358     FILE              *globalPolicyFp;
1359     FILE              *staticPolicyFp;
1360     Int                globalResourceFileSize;
1361     Int                linuxDtbFileSize;
1362     Int                globalPolicyFileSize;
1363     Int                staticPolicyFileSize;
1364     void              *globalResourceList = NULL;
1365     void              *linuxDtb = NULL;
1366     void              *globalPolicy = NULL;
1367     void              *staticPolicy = NULL;
1368     Int                status;
1369     Int                readSize;
1370     Rm_ServiceReqInfo  requestInfo;    
1371     int32_t            result;
1373     System_printf ("*********************************************************\n");
1374     System_printf ("********************** RM Testing ***********************\n");
1375     System_printf ("*********************************************************\n");
1377     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
1379     /* Initialize the RM instances - RM must be initialized before anything else in the system
1380      * Core 0: 1 RM Instance - RM Server
1381      * Core 1: 2 RM Instances - RM Client Delegate
1382      *                          RM Client
1383      */
1384     if (MultiProc_self()== 0) {
1385         initSyncObj();
1386         
1387         globalResourceFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\test\\dts_files\\global-resources.dtb", "rb");
1388         linuxDtbFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\test\\dts_files\\linux-evm.dtb", "rb");
1389         globalPolicyFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\test\\dts_files\\server-policy.dtb", "rb");
1391         fseek(globalResourceFp, 0, SEEK_END);
1392         globalResourceFileSize = ftell(globalResourceFp);
1393         rewind(globalResourceFp);
1395         fseek(linuxDtbFp, 0, SEEK_END);
1396         linuxDtbFileSize = ftell(linuxDtbFp);
1397         rewind(linuxDtbFp);
1399         fseek(globalPolicyFp, 0, SEEK_END);
1400         globalPolicyFileSize = ftell(globalPolicyFp);
1401         rewind(globalPolicyFp);      
1403         globalResourceList = Osal_rmMalloc(globalResourceFileSize);
1404         linuxDtb = Osal_rmMalloc(linuxDtbFileSize);
1405         globalPolicy = Osal_rmMalloc(globalPolicyFileSize);
1407         readSize = fread(globalResourceList, 1, globalResourceFileSize, globalResourceFp);
1408         System_printf("Read Size compared to file size: %d : %d\n", readSize, globalResourceFileSize);
1409         readSize = fread(linuxDtb, 1, linuxDtbFileSize, linuxDtbFp);
1410         System_printf("Read Size compared to file size: %d : %d\n", readSize, linuxDtbFileSize);        
1411         readSize = fread(globalPolicy, 1, globalPolicyFileSize, globalPolicyFp);
1412         System_printf("Read Size compared to file size: %d : %d\n", readSize, globalPolicyFileSize);
1414         /* Create the Server instance */
1415         rmInitCfg.instName = &rmServerName[0];
1416         rmInitCfg.instType = Rm_instType_SERVER;
1417         rmInitCfg.instCfg.serverCfg.globalResourceList = globalResourceList;
1418         rmInitCfg.instCfg.serverCfg.linuxDtb = linuxDtb;
1419         rmInitCfg.instCfg.serverCfg.globalPolicy = globalPolicy;
1420         rmServerHandle = Rm_init(&rmInitCfg, &result);
1421         System_printf("Core %d: RM Server instance created. Result = %d\n", MultiProc_self(), result);
1423         Rm_printResourceStatus(rmServerHandle);
1424     }
1425     else if (MultiProc_self()== 1) {
1426         staticPolicyFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\test\\dts_files\\static-policy.dtb", "rb");
1428         fseek(staticPolicyFp, 0, SEEK_END);
1429         staticPolicyFileSize = ftell(staticPolicyFp);
1430         rewind(staticPolicyFp); 
1431         staticPolicy = Osal_rmMalloc(staticPolicyFileSize);  
1432         readSize = fread(staticPolicy, 1, staticPolicyFileSize, staticPolicyFp);
1433         System_printf("Read Size compared to file size: %d : %d\n", readSize, staticPolicyFileSize);
1435         /* Create the RM Client Delegate instance */
1436         rmInitCfg.instName = &rmClientDelegateName[0];
1437         rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
1438         rmInitCfg.instCfg.cdCfg.staticPolicy = staticPolicy;
1439         rmClientDelegateHandle = Rm_init(&rmInitCfg, &result);
1440         System_printf("Core %d: RM Client Delegate instance created. Result = %d\n", MultiProc_self(), result);
1442         /* Create the RM Client instance */
1443         rmInitCfg.instName = &rmClientName[0];
1444         rmInitCfg.instType = Rm_instType_CLIENT;      
1445         rmInitCfg.instCfg.clientCfg.staticPolicy = staticPolicy;
1446         rmClientHandle = Rm_init(&rmInitCfg, &result);
1447         System_printf("Core %d: RM Client instance created. Result = %d\n", MultiProc_self(), result);
1449         /* Open service handles on the CD and Client to test static allocations */
1450         rmClientDelegateServiceHandle = Rm_serviceOpenHandle(rmClientDelegateHandle, &result);
1451         rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);   
1453         /* Static allocations */
1454         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1455         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1456         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1457         requestInfo.resourceName = resourceNameQosCluster;
1458         requestInfo.resourceBase = 0;
1459         requestInfo.resourceLength = 1;
1460         requestInfo.callback.serviceCallback = testServiceCallback;
1461         
1462         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
1463         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
1464         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1465             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1466                                                                        rmClientDelegateName, 
1467                                                                        resourceNameQosCluster, 
1468                                                                        responseInfo.resourceBase,
1469                                                                        responseInfo.resourceLength);
1470         }
1471         else {
1472             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1473                                                                                 responseInfo.serviceState);
1474         }            
1475         
1476         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1477         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1478         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1479         requestInfo.resourceName = resourceNameQosCluster;
1480         requestInfo.resourceBase = 2;
1481         requestInfo.resourceLength = 1;
1482         requestInfo.callback.serviceCallback = testServiceCallback;
1483         
1484         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1485         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1486         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1487             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1488                                                                        rmClientName, 
1489                                                                        resourceNameQosCluster, 
1490                                                                        responseInfo.resourceBase,
1491                                                                        responseInfo.resourceLength);
1492         }
1493         else {
1494             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1495                                                                                 responseInfo.serviceState);
1496         }            
1498         /* Next request should return error */
1499         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1500         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1501         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1502         requestInfo.resourceName = resourceNameQosCluster;
1503         requestInfo.resourceBase = 1;
1504         requestInfo.resourceLength = 1;
1505         requestInfo.callback.serviceCallback = testServiceCallback;
1506         
1507         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1508         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1509         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
1510             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1511                                                                        rmClientName, 
1512                                                                        resourceNameQosCluster, 
1513                                                                        responseInfo.resourceBase,
1514                                                                        responseInfo.resourceLength); 
1515         }
1516         else {
1517             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1518                                                                                 responseInfo.serviceState);
1519         }
1521         /* Allocated shared resource to both CD and Client using static policy */
1522         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1523         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1524         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1525         requestInfo.resourceName = resourceNameAifQ;
1526         requestInfo.resourceBase = 525;
1527         requestInfo.resourceLength = 1;
1528         requestInfo.callback.serviceCallback = testServiceCallback;
1529         
1530         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
1531         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
1532         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
1533             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1534                                                                        rmClientDelegateName, 
1535                                                                        resourceNameAifQ, 
1536                                                                        responseInfo.resourceBase,
1537                                                                        responseInfo.resourceLength);
1538         }
1539         else {
1540             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1541                                                                                 responseInfo.serviceState);
1542         }
1543         
1544         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1545         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1546         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1547         requestInfo.resourceName = resourceNameAifQ;
1548         requestInfo.resourceBase = 525;
1549         requestInfo.resourceLength = 1;
1550         requestInfo.callback.serviceCallback = testServiceCallback;
1551         
1552         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1553         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1554         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1555             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1556                                                                        rmClientName, 
1557                                                                        resourceNameAifQ, 
1558                                                                        responseInfo.resourceBase,
1559                                                                        responseInfo.resourceLength);  
1560         }
1561         else {
1562             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1563                                                                                 responseInfo.serviceState);
1564         }      
1565     }
1567     System_printf("Core %d: Starting IPC...\n", MultiProc_self());
1568     status = Ipc_start();
1569     if (status < 0) {
1570         System_abort("Ipc_start failed\n");
1571     }
1573     /* Create the RM startup task */
1574     System_printf("Core %d: Creating RM startup task...\n", MultiProc_self());
1575     Task_Params_init (&taskParams);
1576     startupRmTskHandle = Task_create (startupRmTsk, &taskParams, NULL);
1578     System_printf("Core %d: Starting BIOS...\n", MultiProc_self());
1579     BIOS_start();
1581     return (0);