Added and tested static policy feature. Continued cleanup of API
[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);
467     }
469     memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
470     memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
472     System_printf("Core %d: Testing NameServer features...\n", MultiProc_self());
474     /* Use the service ports to test the service requests */
475     if (MultiProc_self() == 0) {
476         /* Issue the service request create a new NameServer object via the service port */                
477         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
478         requestInfo.resourceName = resourceNameGpQ;
479         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
480         requestInfo.resourceLength = 1;
481         requestInfo.resourceAlignment = 0;
482         requestInfo.callback.serviceCallback = testServiceCallback;
483         
484         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
485         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
486         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
487             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {
488             if (blockForResponse(&responseInfo)) {
489                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
490                                                                                           rmServerName,
491                                                                                           responseInfo.resourceName, 
492                                                                                           responseInfo.resourceBase,
493                                                                                           responseInfo.resourceLength);            
494             }  
495         }
496         else {
497             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
498                                                                                 responseInfo.serviceState);
499         }            
501         /* Issue the service request create a new NameServer object via the service port */                
502         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
503         requestInfo.resourceName = resourceNameGpQ;
504         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
505         requestInfo.resourceLength = 1;
506         requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
507         requestInfo.callback.serviceCallback = testServiceCallback;
508         
509         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
510         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
511         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
512             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
513             if (blockForResponse(&responseInfo)) {
514                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
515                                                                                           rmServerName,
516                                                                                           responseInfo.resourceName, 
517                                                                                           responseInfo.resourceBase,
518                                                                                           responseInfo.resourceLength);            
519             } 
520         }
521         else {
522             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
523                                                                                 responseInfo.serviceState);
524         }            
526         /* Issue the service request create a new NameServer object via the service port */                
527         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
528         requestInfo.resourceName = resourceNameGpQ;
529         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
530         requestInfo.resourceLength = 1;
531         requestInfo.resourceAlignment = 200;
532         requestInfo.callback.serviceCallback = testServiceCallback;
533         
534         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
535         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
536         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
537             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
538             if (blockForResponse(&responseInfo)) {
539                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
540                                                                                           rmServerName,
541                                                                                           responseInfo.resourceName, 
542                                                                                           responseInfo.resourceBase,
543                                                                                           responseInfo.resourceLength);            
544             }  
545         }
546         else {
547             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
548                                                                                 responseInfo.serviceState);
549         }            
551         Rm_printResourceStatus(rmServerHandle);
554         /* Issue the service request create a new NameServer object via the service port */                
555         requestInfo.type = Rm_service_RESOURCE_MAP_TO_NAME;
556         requestInfo.resourceName = resourceNameGpQ;
557         requestInfo.resourceBase = 1002;
558         requestInfo.resourceLength = 1;
559         requestInfo.resourceNsName = nameServerNameFavQ;
560         requestInfo.callback.serviceCallback = testServiceCallback;
561         
562         System_printf("Core %d: %s creating NameServer object...\n", MultiProc_self(), rmServerName);
563         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
564         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
565             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
566             if (blockForResponse(&responseInfo)) {
567                 System_printf("Core %d: %s created NameServer object: %s base: %d length: %d\n", MultiProc_self(),
568                                                                                                  rmServerName,
569                                                                                                  nameServerNameFavQ, 
570                                                                                                  requestInfo.resourceBase,
571                                                                                                  requestInfo.resourceLength);            
572             }
573         }
574         else {
575             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
576                                                                                 responseInfo.serviceState);
577         }            
579         /* Wait for Client Delegate and Client to retrieve resource via the name and allocate it */
580         waitOnSyncObj();
582         Rm_printResourceStatus(rmServerHandle);
584         /* Wait for Client to free resource via the NameServer and delete the NameServer object. */
585         waitOnSyncObj();
587         Rm_printResourceStatus(rmServerHandle);
589         /* Try to allocate the memory region taken by the Linux Kernel */
590         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
591         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
592         requestInfo.resourceName = resourceNameMemRegion;
593         requestInfo.resourceBase = 12;
594         requestInfo.resourceLength = 1;
595         requestInfo.callback.serviceCallback = testServiceCallback;
596         
597         System_printf("Core %d: %s Trying to reserve memory region taken by Linux...\n", MultiProc_self(), rmServerName);
598         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
599         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
600             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
601             if (blockForResponse(&responseInfo)) {
602                 System_printf("Core %d: %s allocated resource (SHOULD NOT HAPPEN): %s base: %d length: %d\n", MultiProc_self(),
603                                                                                                               rmServerName,
604                                                                                                               requestInfo.resourceName, 
605                                                                                                               requestInfo.resourceBase,
606                                                                                                               requestInfo.resourceLength);            
607             }  
608         }
609         else {
610             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
611                                                                                 responseInfo.serviceState);
612         }            
614         /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
615         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
616         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
617         requestInfo.resourceName = resourceNameAifRxCh;
618         requestInfo.resourceBase = 14;
619         requestInfo.resourceLength = 5;
620         requestInfo.callback.serviceCallback = testServiceCallback;
621         
622         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
623         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
624         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
625             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
626             if (blockForResponse(&responseInfo)) {
627                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
628                                                                                           rmServerName,
629                                                                                           requestInfo.resourceName, 
630                                                                                           requestInfo.resourceBase,
631                                                                                           requestInfo.resourceLength);            
632             }   
633         }
634         else {
635             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
636                                                                                 responseInfo.serviceState);
637         }            
638         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
639         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
640         requestInfo.resourceName = resourceNameAifRxCh;
641         requestInfo.resourceBase = 19;
642         requestInfo.resourceLength = 31;
643         requestInfo.callback.serviceCallback = testServiceCallback;
644         
645         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmServerName);
646         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
647         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
648             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
649             if (blockForResponse(&responseInfo)) {
650                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
651                                                                                           rmServerName,
652                                                                                           requestInfo.resourceName, 
653                                                                                           requestInfo.resourceBase,
654                                                                                           requestInfo.resourceLength);            
655             }   
656         }
657         else {
658             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
659                                                                                 responseInfo.serviceState);
660         }            
661         
662         /* Wait for Client and Client Delegate to do their allocates */
663         waitOnSyncObj();
665         Rm_printResourceStatus(rmServerHandle);        
667         /* Free resources to show tree handling of different frees */
668         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
669         requestInfo.type = Rm_service_RESOURCE_FREE;
670         requestInfo.resourceName = resourceNameAifRxCh;
671         requestInfo.resourceBase = 25;
672         requestInfo.resourceLength = 3;
673         requestInfo.callback.serviceCallback = testServiceCallback;
674         
675         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
676         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
677         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
678             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
679             if (blockForResponse(&responseInfo)) {
680                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
681                                                                                           rmServerName,
682                                                                                           requestInfo.resourceName, 
683                                                                                           requestInfo.resourceBase,
684                                                                                           requestInfo.resourceLength);            
685             }  
686         }
687         else {
688             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
689                                                                                 responseInfo.serviceState);
690         }            
691         
692         Rm_printResourceStatus(rmServerHandle);   
693         
694         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
695         requestInfo.type = Rm_service_RESOURCE_FREE;
696         requestInfo.resourceName = resourceNameAifRxCh;
697         requestInfo.resourceBase = 34;
698         requestInfo.resourceLength = 3;
699         requestInfo.callback.serviceCallback = testServiceCallback;
700         
701         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
702         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
703         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
704             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
705             if (blockForResponse(&responseInfo)) {
706                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
707                                                                                           rmServerName,
708                                                                                           requestInfo.resourceName, 
709                                                                                           requestInfo.resourceBase,
710                                                                                           requestInfo.resourceLength);            
711             }   
712         }
713         else {
714             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
715                                                                                 responseInfo.serviceState);
716         }            
717         
718         Rm_printResourceStatus(rmServerHandle);           
719      
720         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
721         requestInfo.type = Rm_service_RESOURCE_FREE;
722         requestInfo.resourceName = resourceNameAifRxCh;
723         requestInfo.resourceBase = 28;
724         requestInfo.resourceLength = 6;
725         requestInfo.callback.serviceCallback = testServiceCallback;
726         
727         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
728         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
729         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
730             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
731             if (blockForResponse(&responseInfo)) {
732                 System_printf("Core %d: %s freed resource: %s base: %d length: %d\n", MultiProc_self(),
733                                                                                           rmServerName,
734                                                                                           requestInfo.resourceName, 
735                                                                                           requestInfo.resourceBase,
736                                                                                           requestInfo.resourceLength);            
737             } 
738         }
739         else {
740             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
741                                                                                 responseInfo.serviceState);
742         }            
743         
744         Rm_printResourceStatus(rmServerHandle);     
746         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
747         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
748         requestInfo.resourceName = resourceNameAifRxCh;
749         requestInfo.resourceBase = 53;
750         requestInfo.resourceLength = 2;
751         requestInfo.callback.serviceCallback = testServiceCallback;
752         
753         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
754         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
755         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
756             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
757             if (blockForResponse(&responseInfo)) {
758                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
759                                                                                           rmServerName,
760                                                                                           requestInfo.resourceName, 
761                                                                                           requestInfo.resourceBase,
762                                                                                           requestInfo.resourceLength);            
763             } 
764         }
765         else {
766             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
767                                                                                 responseInfo.serviceState);
768         }            
769         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
770         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
771         requestInfo.resourceName = resourceNameAifRxCh;
772         requestInfo.resourceBase = 2;
773         requestInfo.resourceLength = 2;
774         requestInfo.callback.serviceCallback = testServiceCallback;
775         
776         System_printf("Core %d: %s freeing resource...\n", MultiProc_self(), rmServerName);
777         rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
778         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
779             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
780             if (blockForResponse(&responseInfo)) {
781                 System_printf("Core %d: %s allocate resource: %s base: %d length: %d\n", MultiProc_self(),
782                                                                                           rmServerName,
783                                                                                           requestInfo.resourceName, 
784                                                                                           requestInfo.resourceBase,
785                                                                                           requestInfo.resourceLength);            
786             }   
787         }
788         else {
789             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
790                                                                                 responseInfo.serviceState);
791         }            
792         
793         Rm_printResourceStatus(rmServerHandle); 
795         /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates */
796         waitOnSyncObj();
798         Rm_printResourceStatus(rmServerHandle);      
799         
800     }
801     else if (MultiProc_self() == 1) {    
802         /* Issue the service request for the resources tied to the name via the service port */                
803         requestInfo.type = Rm_service_RESOURCE_GET_BY_NAME;
804         requestInfo.resourceNsName = nameServerNameFavQ;
805         requestInfo.callback.serviceCallback = testServiceCallback;
806         
807         System_printf("Core %d: %s getting resources tied to NameServer object...\n", MultiProc_self(), 
808                                                                                       rmClientDelegateName);
809         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
810         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
811             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
812             if (blockForResponse(&responseInfo)) {
813                 System_printf("Core %d: %s got Name: %s base: %d length: %d\n", MultiProc_self(),
814                                                                                 rmClientDelegateName, 
815                                                                                 nameServerNameFavQ, 
816                                                                                 responseInfo.resourceBase,
817                                                                                 responseInfo.resourceLength);
818             }
819         }
820         else {
821             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
822                                                                                 responseInfo.serviceState);
823         }            
825         /* Allocate the resources via the service port from the Client */
826         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
827         requestInfo.resourceName = responseInfo.resourceName;
828         requestInfo.resourceBase = responseInfo.resourceBase;
829         requestInfo.resourceLength = responseInfo.resourceLength;
830         requestInfo.resourceNsName = NULL;
831         requestInfo.callback.serviceCallback = testServiceCallback;
832         
833         System_printf("Core %d: %s allocating resources...\n", MultiProc_self(), rmClientName);
834         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
835         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
836             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
837             if (blockForResponse(&responseInfo)) {
838                 System_printf("Core %d: %s allocated resources: %s base: %d length: %d\n", MultiProc_self(),
839                                                                                            rmClientName, 
840                                                                                            nameServerNameFavQ, 
841                                                                                            responseInfo.resourceBase,
842                                                                                            responseInfo.resourceLength);
843             }
844         }
845         else {
846             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
847                                                                                 responseInfo.serviceState);
848         }            
850         /* Release the syncObj so Server can print results of NameServer object add and resource allocate */
851         releaseSyncObj();
853         /* Take the syncObj to free the name resource via the name, rather than the base+length */
854         takeSyncObj();
856         /* Free the named resource using the name via the service port from the Client */
857         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
858         requestInfo.type = Rm_service_RESOURCE_FREE;
859         requestInfo.resourceNsName = nameServerNameFavQ;
860         requestInfo.callback.serviceCallback = testServiceCallback;
861         
862         System_printf("Core %d: %s freeing resource via name...\n", MultiProc_self(), rmClientName);
863         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
864         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
865             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
866             if (blockForResponse(&responseInfo)) {
867                 System_printf("Core %d: %s freed resource with name: %s\n", MultiProc_self(),
868                                                                             rmClientName, 
869                                                                             nameServerNameFavQ);
870             }
871         }
872         else {
873             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
874                                                                                 responseInfo.serviceState);
875         }            
877         /* Delete the name object from the NameServer */
878         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));
879         requestInfo.type = Rm_service_RESOURCE_UNMAP_NAME;
880         requestInfo.resourceNsName = nameServerNameFavQ;
881         requestInfo.callback.serviceCallback = testServiceCallback;
882         
883         System_printf("Core %d: %s Deleting NameServer object: %s...\n", MultiProc_self(), 
884                                                                          rmClientName,
885                                                                          nameServerNameFavQ);
886         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
887         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
888             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
889             if (blockForResponse(&responseInfo)) {
890                 System_printf("Core %d: %s deleted NameServer object: %s\n", MultiProc_self(),
891                                                                              rmClientName, 
892                                                                              nameServerNameFavQ);
893             }
894         }
895         else {
896             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
897                                                                                 responseInfo.serviceState);
898         }            
900         /* Release the syncObj so Server can print results of resource free and NameServer object delete. */
901         releaseSyncObj();   
903         /* Take the syncObj to allocate resources for testing resource tree interactions. */
904         takeSyncObj();
906         /* Allocate some resources for testing tree interaction with multiple allocations from different instances */
907         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
908         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
909         requestInfo.resourceName = resourceNameAifRxCh;
910         requestInfo.resourceBase = 0;
911         requestInfo.resourceLength = 6;
912         requestInfo.callback.serviceCallback = testServiceCallback;
913         
914         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
915         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
916         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
917             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
918             if (blockForResponse(&responseInfo)) {
919                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
920                                                                                           rmClientName,
921                                                                                           requestInfo.resourceName, 
922                                                                                           requestInfo.resourceBase,
923                                                                                           requestInfo.resourceLength);            
924             }  
925         }
926         else {
927             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
928                                                                                 responseInfo.serviceState);
929         }            
930         
931         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
932         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
933         requestInfo.resourceName = resourceNameAifRxCh;
934         requestInfo.resourceBase = 50;
935         requestInfo.resourceLength = 7;
936         requestInfo.callback.serviceCallback = testServiceCallback;
937         
938         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
939         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->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 allocated resource: %s base: %d length: %d\n", MultiProc_self(),
944                                                                                           rmClientDelegateName,
945                                                                                           requestInfo.resourceName, 
946                                                                                           requestInfo.resourceBase,
947                                                                                           requestInfo.resourceLength);            
948             }  
949         }
950         else {
951             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
952                                                                                 responseInfo.serviceState);
953         }            
955         /* Release the syncObj so Server can print results of resource allocations */
956         releaseSyncObj();    
958         /* Take the syncObj to allocate resources using the UNSPECIFIED parameters. */
959         takeSyncObj();
961         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
962         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
963         requestInfo.resourceName = resourceNameAccumCh;
964         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
965         requestInfo.resourceLength = 5;
966         requestInfo.resourceAlignment = 4;
967         requestInfo.callback.serviceCallback = testServiceCallback;
968         
969         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientDelegateName);
970         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
971         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
972             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
973             if (blockForResponse(&responseInfo)) {
974                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
975                                                                                           rmClientDelegateName,
976                                                                                           responseInfo.resourceName, 
977                                                                                           responseInfo.resourceBase,
978                                                                                           responseInfo.resourceLength);            
979             }    
980         }
981         else {
982             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
983                                                                                 responseInfo.serviceState);
984         }            
986         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
987         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
988         requestInfo.resourceName = resourceNameAccumCh;
989         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
990         requestInfo.resourceLength = 2;
991         requestInfo.resourceAlignment = 1;
992         requestInfo.callback.serviceCallback = testServiceCallback;
993         
994         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
995         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
996         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
997             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
998             if (blockForResponse(&responseInfo)) {
999                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
1000                                                                                           rmClientName,
1001                                                                                           responseInfo.resourceName, 
1002                                                                                           responseInfo.resourceBase,
1003                                                                                           responseInfo.resourceLength);            
1004             } 
1005         }
1006         else {
1007             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1008                                                                                 responseInfo.serviceState);
1009         }            
1011         memset((void *) &requestInfo, 0, sizeof(Rm_ServiceReqInfo));        
1012         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_USE;
1013         requestInfo.resourceName = resourceNameAccumCh;
1014         requestInfo.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED;
1015         requestInfo.resourceLength = 2;
1016         requestInfo.resourceAlignment = RM_RESOURCE_ALIGNMENT_UNSPECIFIED;
1017         requestInfo.callback.serviceCallback = testServiceCallback;
1018         
1019         System_printf("Core %d: %s Allocating resource...\n", MultiProc_self(), rmClientName);
1020         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1021         if ((responseInfo.serviceState == RM_SERVICE_APPROVED) ||
1022             (responseInfo.serviceState == RM_SERVICE_PROCESSING)) {        
1023             if (blockForResponse(&responseInfo)) {
1024                 System_printf("Core %d: %s allocated resource: %s base: %d length: %d\n", MultiProc_self(),
1025                                                                                           rmClientName,
1026                                                                                           responseInfo.resourceName, 
1027                                                                                           responseInfo.resourceBase,
1028                                                                                           responseInfo.resourceLength);            
1029             }  
1030         }
1031         else {
1032             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1033                                                                                 responseInfo.serviceState);
1034         }            
1036         /* Release the syncObj so Server can print results of resource allocations */
1037         releaseSyncObj();           
1038     }
1040     System_printf("Core %d: Testing is complete\n", MultiProc_self());
1041     
1042     /* Create the RM cleanup task. */
1043     System_printf("Core %d: Creating RM cleanup task...\n", MultiProc_self());
1044     Task_Params_init (&taskParams);
1045     Task_create (cleanupRmTsk, &taskParams, NULL);
1048 /*
1049  *  ======== startupRmTsk ========
1050  *  Configures application transports and registers them with RM
1051  */
1052 Void startupRmTsk(UArg arg0, UArg arg1)
1054     MessageQ_Handle    serverFromCdMsgQ, cdFromServerMsgQ, cdFromClientMsgQ, clientFromCdMsgQ;
1055     MessageQ_QueueId   serverToCdQId, cdToServerQId, cdToClientQId, clientToCdQId;    
1056     Int                status, i;
1057     HeapBufMP_Handle   msgQHeapHandle;
1058     HeapBufMP_Params   heapBufParams;
1059     Rm_TransportCfg    rmTransportCfg;
1060     int32_t            result = 0;
1061     Rm_TransportHandle serverCdHandle, cdServerHandle, cdClientHandle, clientCdHandle;
1062     Task_Params        taskParams;
1064     if (MultiProc_self() == 1) {
1065         /* Take the syncObj on core 1, preparing for RM testing */
1066         takeSyncObj();  
1067     }
1069     /* Initialize the transport map */
1070     for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
1071         rmTransportMap[i].transportHandle = NULL;
1072     }
1074     if (MultiProc_self() == 0) {
1075         /* Create the heap that will be used to allocate RM messages. This
1076          * heap is a multi-processor heap.  It will be shared amongst
1077          * all RM instances. */     
1078         HeapBufMP_Params_init(&heapBufParams);
1079         heapBufParams.regionId       = 0;
1080         heapBufParams.name           = RM_PKT_HEAP_NAME;
1081         heapBufParams.numBlocks      = 64;
1082         heapBufParams.blockSize      = sizeof(Rm_Packet);
1083         rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
1084         if (rmPktHeapHandle == NULL) {
1085             System_abort("HeapBufMP_create failed for RM packet heap\n" );
1086         }
1087         System_printf("Core %d: RM packet heap created\n", MultiProc_self());
1089         /* Create the heap that will be used to allocate messageQ messages. */     
1090         HeapBufMP_Params_init(&heapBufParams);
1091         heapBufParams.regionId       = 0;
1092         heapBufParams.name           = MSGQ_HEAP_NAME;
1093         heapBufParams.numBlocks      = 64;
1094         heapBufParams.blockSize      = sizeof(MsgQ_RmPacket);
1095         msgQHeapHandle = HeapBufMP_create(&heapBufParams);
1096         if (msgQHeapHandle == NULL) {
1097             System_abort("HeapBufMP_create failed MessageQ message heap\n" );
1098         } 
1099         System_printf("Core %d: IPC MessageQ message heap created\n", MultiProc_self());
1100     }
1101     else {
1102         /* Open the heaps created by the other processor. Loop until opened. */
1103         do {
1104             status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
1105             /* 
1106              *  Sleep for 1 clock tick to avoid inundating remote processor
1107              *  with interrupts if open failed
1108              */
1109             if (status < 0) { 
1110                 Task_sleep(1);
1111             }
1112         } while (status < 0);
1113         System_printf("Core %d: RM packet heap opened\n", MultiProc_self());
1114         
1115         do {
1116             status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
1117             /* 
1118              *  Sleep for 1 clock tick to avoid inundating remote processor
1119              *  with interrupts if open failed
1120              */
1121             if (status < 0) { 
1122                 Task_sleep(1);
1123             }
1124         } while (status < 0);
1125         System_printf("Core %d: IPC MessageQ message heap opened\n", MultiProc_self());
1126     }
1127     
1128     /* Register the MessageQ heap with MessageQ */
1129     MessageQ_registerHeap((IHeap_Handle)msgQHeapHandle, MSGQ_HEAP_ID);
1131     /* Create the messageQ's for each RM instance connection
1132      * Need four queues.  Topology will be:
1133      * RM Server <---> RM Client Delegate <---> RM Client 
1134      * 1 queues on RM Server
1135      * 2 queues on RM Client Delegate
1136      * 1 queues on RM Client */
1137     if (MultiProc_self() == 0) {
1138         serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
1139         if (serverFromCdMsgQ == NULL) {
1140             System_abort("MessageQ_create failed for RM Server - Client Delegate queue\n" );
1141         }
1142         System_printf("Core %d: RM Server MessageQ created for receiving packets from RM CD\n", MultiProc_self());
1143     }
1144     else if (MultiProc_self() == 1) {
1145         cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
1146         if (cdFromServerMsgQ == NULL) {
1147             System_abort("MessageQ_create failed for RM Client Delegate - Server queue\n" );
1148         }
1149         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Server\n", MultiProc_self());
1150         
1151         cdFromClientMsgQ = MessageQ_create(cdFromClientQueueName, NULL);
1152         if (cdFromClientMsgQ == NULL) {
1153             System_abort("MessageQ_create failed for RM Client Delegate - Client queue\n" );
1154         } 
1155         System_printf("Core %d: RM CD MessageQ created for receiving packets from RM Client\n", MultiProc_self());
1156         
1157         clientFromCdMsgQ = MessageQ_create(clientFromCdQueueName, NULL);
1158         if (clientFromCdMsgQ == NULL) 
1159         {
1160             System_abort("MessageQ_create failed for RM Client - Client Delegate queue\n" );
1161         }
1162         System_printf("Core %d: RM Client MessageQ created for receiving packets from RM CD\n", MultiProc_self());
1163     }
1164     
1165     /* Open the remote message queues. Also register the RM transports with each RM instance */
1166     if (MultiProc_self() == 0) {
1167         /* Open the Client Delegate messageQ from the Server */
1168         do {
1169             status = MessageQ_open(cdFromServerQueueName, &serverToCdQId); 
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: RM CD MessageQ opened from RM Server\n", MultiProc_self());
1180         /* Register the Client Delegate with the RM Server Instance */
1181         rmTransportCfg.rmHandle = rmServerHandle;
1182         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
1183         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1184         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
1185         /* Set the callouts as valid for the first transport configuration on Server instance */
1186         rmTransportCfg.transportCalloutsValid = true;
1187         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1188         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1189         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1191         /* Store the mapping information in the transport map */
1192         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle = serverCdHandle;
1193         rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
1194         System_printf("Core %d: Registered RM Server <=> RM CD transport with RM Server instance\n", MultiProc_self());
1195     }
1196     else if (MultiProc_self() == 1) {
1197         /* Open the Server messageQ from the Client Delegate */
1198         do {
1199             status = MessageQ_open(serverFromCdQueueName, &cdToServerQId); 
1200             /* 
1201              *  Sleep for 1 clock tick to avoid inundating remote processor
1202              *  with interrupts if open failed
1203              */
1204             if (status < 0) { 
1205                 Task_sleep(1);
1206             }
1207         } while (status < 0);
1208         System_printf("Core %d: RM Server MessageQ opened from RM CD\n", MultiProc_self());
1210         /* Register the Server with the RM Client Delegate Instance */
1211         rmTransportCfg.rmHandle = rmClientDelegateHandle;
1212         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
1213         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
1214         rmTransportCfg.remoteInstName = &rmServerName[0];
1215         /* Set the callouts as valid for the first transport configuration on Client Delegate instance */
1217         rmTransportCfg.transportCalloutsValid = true;
1218         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1219         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1220         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
1222         /* Store the mapping information in the transport map */
1223         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].transportHandle = cdServerHandle;
1224         rmTransportMap[CD_TO_SERVER_MAP_ENTRY].receiveMsgQ = cdFromServerMsgQ;
1225         System_printf("Core %d: Registered RM CD <=> RM Server transport with RM CD instance\n", MultiProc_self());
1226         
1227         /* Open the Client messageQ from the Client Delegate */
1228         do {
1229             status = MessageQ_open(clientFromCdQueueName, &cdToClientQId); 
1230             /* 
1231              *  Sleep for 1 clock tick to avoid inundating remote processor
1232              *  with interrupts if open failed
1233              */
1234             if (status < 0) { 
1235                 Task_sleep(1);
1236             }
1237         } while (status < 0);
1238         System_printf("Core %d: RM Client MessageQ opened from RM CD\n", MultiProc_self());
1240         /* Register the Client with the RM Client Delegate Instance */
1241         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
1242         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
1243         rmTransportCfg.remoteInstName = &rmClientName[0];
1244         /* Callouts already set on the Client Delegate so set them as invalid */
1245         rmTransportCfg.transportCalloutsValid = false;
1246         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
1248         /* Store the mapping information in the transport map */
1249         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].transportHandle = cdClientHandle;
1250         rmTransportMap[CD_TO_CLIENT_MAP_ENTRY].receiveMsgQ = cdFromClientMsgQ;
1251         System_printf("Core %d: Registered RM CD <=> RM Client transport with RM CD instance\n", MultiProc_self());
1253         /* Open the Client Delegate messageQ from the Client */        
1254         do {
1255             status = MessageQ_open(cdFromClientQueueName, &clientToCdQId); 
1256             /* 
1257              *  Sleep for 1 clock tick to avoid inundating remote processor
1258              *  with interrupts if open failed
1259              */
1260             if (status < 0) { 
1261                 Task_sleep(1);
1262             }
1263         } while (status < 0);
1264         System_printf("Core %d: RM CD MessageQ opened from RM Client\n", MultiProc_self());
1266         /* Register the Client Delegate with the RM Client Instance */
1267         rmTransportCfg.rmHandle = rmClientHandle;
1268         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
1269         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
1270         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
1271         /* Set the callouts as valid for the first transport configuration on Client instance */
1272         rmTransportCfg.transportCalloutsValid = true;
1273         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
1274         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
1275         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
1277         /* Store the mapping information in the transport map */
1278         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].transportHandle = clientCdHandle;
1279         rmTransportMap[CLIENT_TO_CD_MAP_ENTRY].receiveMsgQ = clientFromCdMsgQ;
1280         System_printf("Core %d: Registered RM Client <=> RM CD transport with RM Client instance\n", MultiProc_self());
1281     }
1283     /* Create the RM receive task. */
1284     System_printf("Core %d: Creating RM receive task...\n", MultiProc_self());
1285     Task_Params_init (&taskParams);
1286     testReceiveTskHandle = Task_create (testReceiveTsk, &taskParams, NULL);
1287     
1288     
1289     /* Create the RM test task. */
1290     System_printf("Core %d: Creating RM test task...\n", MultiProc_self());
1291     Task_Params_init (&taskParams);
1292     testRmTskHandle = Task_create (testRmTsk, &taskParams, NULL);
1295 /*
1296  *  ======== main ========
1297  *  Synchronizes all processors (in Ipc_start) and calls BIOS_start
1298  */
1299 Int main(Int argc, Char* argv[])
1301     Rm_InitCfg         rmInitCfg;
1302     Task_Params        taskParams;
1303     FILE              *globalResourceFp;
1304     FILE              *linuxDtbFp;
1305     FILE              *globalPolicyFp;
1306     FILE              *staticPolicyFp;
1307     Int                globalResourceFileSize;
1308     Int                linuxDtbFileSize;
1309     Int                globalPolicyFileSize;
1310     Int                staticPolicyFileSize;
1311     void              *globalResourceList = NULL;
1312     void              *linuxDtb = NULL;
1313     void              *globalPolicy = NULL;
1314     void              *staticPolicy = NULL;
1315     Int                status;
1316     Int                readSize;
1317     Rm_ServiceReqInfo  requestInfo;    
1318     int32_t            result;
1320     System_printf ("*********************************************************\n");
1321     System_printf ("********************** RM Testing ***********************\n");
1322     System_printf ("*********************************************************\n");
1324     System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
1326     /* Initialize the RM instances - RM must be initialized before anything else in the system
1327      * Core 0: 1 RM Instance - RM Server
1328      * Core 1: 2 RM Instances - RM Client Delegate
1329      *                          RM Client
1330      */
1331     if (MultiProc_self()== 0) {
1332         initSyncObj();
1333         
1334         globalResourceFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\device\\tci6614-global-resources.dtb", "rb");
1335         linuxDtbFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\device\\tci6614-linux-evm.dtb", "rb");
1336         globalPolicyFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\device\\tci6614-server-policy.dtb", "rb");
1338         fseek(globalResourceFp, 0, SEEK_END);
1339         globalResourceFileSize = ftell(globalResourceFp);
1340         rewind(globalResourceFp);
1342         fseek(linuxDtbFp, 0, SEEK_END);
1343         linuxDtbFileSize = ftell(linuxDtbFp);
1344         rewind(linuxDtbFp);
1346         fseek(globalPolicyFp, 0, SEEK_END);
1347         globalPolicyFileSize = ftell(globalPolicyFp);
1348         rewind(globalPolicyFp);      
1350         globalResourceList = Osal_rmMalloc(globalResourceFileSize);
1351         linuxDtb = Osal_rmMalloc(linuxDtbFileSize);
1352         globalPolicy = Osal_rmMalloc(globalPolicyFileSize);
1354         readSize = fread(globalResourceList, 1, globalResourceFileSize, globalResourceFp);
1355         System_printf("Read Size compared to file size: %d : %d\n", readSize, globalResourceFileSize);
1356         readSize = fread(linuxDtb, 1, linuxDtbFileSize, linuxDtbFp);
1357         System_printf("Read Size compared to file size: %d : %d\n", readSize, linuxDtbFileSize);        
1358         readSize = fread(globalPolicy, 1, globalPolicyFileSize, globalPolicyFp);
1359         System_printf("Read Size compared to file size: %d : %d\n", readSize, globalPolicyFileSize);
1361         /* Create the Server instance */
1362         rmInitCfg.instName = &rmServerName[0];
1363         rmInitCfg.instType = Rm_instType_SERVER;
1364         rmInitCfg.instCfg.serverCfg.globalResourceList = globalResourceList;
1365         rmInitCfg.instCfg.serverCfg.linuxDtb = linuxDtb;
1366         rmInitCfg.instCfg.serverCfg.globalPolicy = globalPolicy;
1367         rmServerHandle = Rm_init(&rmInitCfg, &result);
1368         System_printf("Core %d: RM Server instance created. Result = %d\n", MultiProc_self(), result);
1370         Rm_printResourceStatus(rmServerHandle);
1371     }
1372     else if (MultiProc_self()== 1) {
1373         staticPolicyFp = fopen("C:\\ti\\pdk_tci6614_1_0_0_11\\packages\\ti\\drv\\rm\\device\\tci6614-static-policy.dtb", "rb");
1375         fseek(staticPolicyFp, 0, SEEK_END);
1376         staticPolicyFileSize = ftell(staticPolicyFp);
1377         rewind(staticPolicyFp); 
1378         staticPolicy = Osal_rmMalloc(staticPolicyFileSize);  
1379         readSize = fread(staticPolicy, 1, staticPolicyFileSize, staticPolicyFp);
1380         System_printf("Read Size compared to file size: %d : %d\n", readSize, staticPolicyFileSize);
1382         /* Create the RM Client Delegate instance */
1383         rmInitCfg.instName = &rmClientDelegateName[0];
1384         rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
1385         rmInitCfg.instCfg.cdCfg.staticPolicy = staticPolicy;
1386         rmClientDelegateHandle = Rm_init(&rmInitCfg, &result);
1387         System_printf("Core %d: RM Client Delegate instance created. Result = %d\n", MultiProc_self(), result);
1389         /* Create the RM Client instance */
1390         rmInitCfg.instName = &rmClientName[0];
1391         rmInitCfg.instType = Rm_instType_CLIENT;      
1392         rmInitCfg.instCfg.clientCfg.staticPolicy = staticPolicy;
1393         rmClientHandle = Rm_init(&rmInitCfg, &result);
1394         System_printf("Core %d: RM Client instance created. Result = %d\n", MultiProc_self(), result);
1396         /* Open service handles on the CD and Client to test static allocations */
1397         rmClientDelegateServiceHandle = Rm_serviceOpenHandle(rmClientDelegateHandle, &result);
1398         rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);   
1400         /* Static allocations */
1401         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1402         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1403         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1404         requestInfo.resourceName = resourceNameQosCluster;
1405         requestInfo.resourceBase = 0;
1406         requestInfo.resourceLength = 1;
1407         requestInfo.callback.serviceCallback = testServiceCallback;
1408         
1409         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
1410         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
1411         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1412             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1413                                                                        rmClientDelegateName, 
1414                                                                        resourceNameQosCluster, 
1415                                                                        responseInfo.resourceBase,
1416                                                                        responseInfo.resourceLength);
1417         }
1418         else {
1419             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1420                                                                                 responseInfo.serviceState);
1421         }            
1422         
1423         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1424         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1425         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1426         requestInfo.resourceName = resourceNameQosCluster;
1427         requestInfo.resourceBase = 2;
1428         requestInfo.resourceLength = 1;
1429         requestInfo.callback.serviceCallback = testServiceCallback;
1430         
1431         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1432         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1433         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1434             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1435                                                                        rmClientName, 
1436                                                                        resourceNameQosCluster, 
1437                                                                        responseInfo.resourceBase,
1438                                                                        responseInfo.resourceLength);
1439         }
1440         else {
1441             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1442                                                                                 responseInfo.serviceState);
1443         }            
1445         /* Next request should return error */
1446         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1447         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1448         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1449         requestInfo.resourceName = resourceNameQosCluster;
1450         requestInfo.resourceBase = 1;
1451         requestInfo.resourceLength = 1;
1452         requestInfo.callback.serviceCallback = testServiceCallback;
1453         
1454         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1455         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1456         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
1457             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1458                                                                        rmClientName, 
1459                                                                        resourceNameQosCluster, 
1460                                                                        responseInfo.resourceBase,
1461                                                                        responseInfo.resourceLength); 
1462         }
1463         else {
1464             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1465                                                                                 responseInfo.serviceState);
1466         }
1468         /* Allocated shared resource to both CD and Client using static policy */
1469         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1470         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1471         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1472         requestInfo.resourceName = resourceNameAifQ;
1473         requestInfo.resourceBase = 525;
1474         requestInfo.resourceLength = 1;
1475         requestInfo.callback.serviceCallback = testServiceCallback;
1476         
1477         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientDelegateName);
1478         rmClientDelegateServiceHandle->Rm_serviceHandler(rmClientDelegateServiceHandle->rmHandle, &requestInfo, &responseInfo);
1479         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {
1480             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1481                                                                        rmClientDelegateName, 
1482                                                                        resourceNameAifQ, 
1483                                                                        responseInfo.resourceBase,
1484                                                                        responseInfo.resourceLength);
1485         }
1486         else {
1487             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1488                                                                                 responseInfo.serviceState);
1489         }
1490         
1491         memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
1492         memset((void *)&responseInfo, 0, sizeof(Rm_ServiceRespInfo));
1493         requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
1494         requestInfo.resourceName = resourceNameAifQ;
1495         requestInfo.resourceBase = 525;
1496         requestInfo.resourceLength = 1;
1497         requestInfo.callback.serviceCallback = testServiceCallback;
1498         
1499         System_printf("Core %d: %s allocating static resource...\n", MultiProc_self(), rmClientName);
1500         rmClientServiceHandle->Rm_serviceHandler(rmClientServiceHandle->rmHandle, &requestInfo, &responseInfo);
1501         if (responseInfo.serviceState == RM_SERVICE_APPROVED_STATIC) {        
1502             System_printf("Core %d: %s got %s: base: %d length: %d\n", MultiProc_self(),
1503                                                                        rmClientName, 
1504                                                                        resourceNameAifQ, 
1505                                                                        responseInfo.resourceBase,
1506                                                                        responseInfo.resourceLength);  
1507         }
1508         else {
1509             System_printf("Core %d: Static allocation failed with error: %d\n", MultiProc_self(), 
1510                                                                                 responseInfo.serviceState);
1511         }      
1512     }
1514     System_printf("Core %d: Starting IPC...\n", MultiProc_self());
1515     status = Ipc_start();
1516     if (status < 0) {
1517         System_abort("Ipc_start failed\n");
1518     }
1520     /* Create the RM startup task */
1521     System_printf("Core %d: Creating RM startup task...\n", MultiProc_self());
1522     Task_Params_init (&taskParams);
1523     startupRmTskHandle = Task_create (startupRmTsk, &taskParams, NULL);
1525     System_printf("Core %d: Starting BIOS...\n", MultiProc_self());
1526     BIOS_start();
1528     return (0);