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