Add support for loading to IPU internal memory on QNX OMAP5
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / omap5430 / Platform.c
1 /*
2  *  @file   Platform.c
3  *
4  *  @brief      Implementation of Platform initialization logic.
5  *
6  *  ============================================================================
7  *
8  *  Copyright (c) 2010-2013, Texas Instruments Incorporated
9  *
10  *  Redistribution and use in source and binary forms, with or without
11  *  modification, are permitted provided that the following conditions
12  *  are met:
13  *
14  *  *  Redistributions of source code must retain the above copyright
15  *     notice, this list of conditions and the following disclaimer.
16  *
17  *  *  Redistributions in binary form must reproduce the above copyright
18  *     notice, this list of conditions and the following disclaimer in the
19  *     documentation and/or other materials provided with the distribution.
20  *
21  *  *  Neither the name of Texas Instruments Incorporated nor the names of
22  *     its contributors may be used to endorse or promote products derived
23  *     from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *  Contact information for paper mail:
37  *  Texas Instruments
38  *  Post Office Box 655303
39  *  Dallas, Texas 75265
40  *  Contact information:
41  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
42  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
43  *  ============================================================================
44  *
45  */
48 /* Standard header files */
49 #include <ti/syslink/Std.h>
51 /* Utilities & Osal headers */
52 #include <ti/syslink/utils/Gate.h>
53 #include <ti/syslink/utils/GateMutex.h>
54 #include <ti/syslink/utils/Memory.h>
55 #include <ti/syslink/utils/Trace.h>
56 #include <ti/ipc/MultiProc.h>
57 #include <_MultiProc.h>
58 #include <ti/syslink/utils/OsalPrint.h>
59 #include <ti/syslink/utils/String.h>
61 /* SysLink device specific headers */
62 #include <ProcDefs.h>
63 #include <Processor.h>
64 #include <OMAP5430BenelliHal.h>
65 #include <OMAP5430BenelliHalReset.h>
66 #include <OMAP5430BenelliHalMmu.h>
67 #include <OMAP5430BenelliProc.h>
68 #include <Omap5430IpcInt.h>
70 /* Module level headers */
71 #include <_MessageQCopy.h>
72 #include <ti/ipc/MessageQCopy.h>
73 #include <_MessageQCopyDefs.h>
75 #include <ti/syslink/ProcMgr.h>
76 #include <_ProcMgr.h>
77 #include <ti/syslink/inc/knl/Platform.h>
78 #include <ElfLoader.h>
80 #include <ti/ipc/Ipc.h>
81 #include <_Ipc.h>
82 #include <_MultiProc.h>
83 #include <IpcKnl.h>
84 #include <ipu_pm.h>
85 #include <GateHWSpinlock.h>
87 #if defined (__cplusplus)
88 extern "C" {
89 #endif
92 /** ============================================================================
93  *  Macros.
94  *  ============================================================================
95  */
96 #define RESETVECTOR_SYMBOL          "_Ipc_ResetVector"
98 #define IPC_MEM_VRING0          0xA0000000
99 #define IPC_MEM_VRING1          0xA0004000
100 #define IPC_MEM_VRING2          0xA0008000
101 #define IPC_MEM_VRING3          0xA000c000
103 #define HWSPINLOCK_BASE             0x4A0F6000
104 #define HWSPINLOCK_SIZE             0x1000
105 #define HWSPINLOCK_OFFSET           0x800
107 #ifndef SYSLINK_SYSBIOS_SMP
108 #define CORE0 "CORE0"
109 #else
110 #define CORE0 "IPU"
111 #endif
113 /** ============================================================================
114  *  Application specific configuration, please change these value according to
115  *  your application's need.
116  *  ============================================================================
117  */
118 /*!
119  *  @brief  Structure defining config parameters for overall System.
120  */
121 typedef struct Platform_Config {
122     MultiProc_Config                multiProcConfig;
123     /*!< Multiproc config parameter */
125     MessageQCopy_Config             MQCopyConfig;
126     /*!< Notify config parameter */
128     ProcMgr_Config                  procMgrConfig;
129     /*!< Processor manager config parameter */
131     ipu_pm_config                   ipu_pm_config;
132     /* ipu_pm config parameter */
134     ElfLoader_Config                elfLoaderConfig;
135     /*!< Elf loader config parameter */
137     GateHWSpinlock_Config           gateHWSpinlockConfig;
138     /*!< GateHWSpinlock config parameter */
139 } Platform_Config;
142 /* Struct embedded into slave binary */
143 typedef struct Platform_SlaveConfig {
144     UInt32  cacheLineSize;
145     UInt32  brOffset;
146 } Platform_SlaveConfig;
148 typedef struct Platform_SlaveSRConfig {
149     UInt32 entryBase;
150     UInt32 entryLen;
151     UInt32 ownerProcId;
152     UInt32 id;
153     UInt32 createHeap;
154     UInt32 cacheLineSize;
155 } Platform_SlaveSRConfig;
157 /* Shared region configuration information for host side. */
158 typedef struct Platform_HostSRConfig {
159     UInt16 refCount;
160 } Platform_HostSRConfig;
162 /*! @brief structure for platform instance */
163 typedef struct Platform_Object {
164     /*!< Flag to indicate platform initialization status */
165     ProcMgr_Handle                pmHandle;
166     /*!< Handle to the ProcMgr instance used */
167     union{
168         struct {
169             OMAP5430BENELLIPROC_Handle    pHandle;
170             /*!< Handle to the Processor instance used */
171             /*!< Handle to the PwrMgr instance used */
172             ElfLoader_Handle             ldrHandle;
173             /*!< Handle to the Loader instance used */
174             UInt32                       fileId;
175             /*!< File ID of loaded image, needed for un-loading */
176         } ipu0;
177 #ifndef SYSLINK_SYSBIOS_SMP
178         struct {
179             OMAP5430BENELLIPROC_Handle    pHandle;
180             /*!< Handle to the Processor instance used */
181             /*!< Handle to the PwrMgr instance used */
182             /* NOTE: no loader used for ipu1, both cores loaded at once */
183             /*!< Handle to the Loader instance used */
184         } ipu1;
185 #endif
186         struct {
187             OMAP5430BENELLIPROC_Handle    pHandle;
188             /*!< Handle to the Processor instance used */
189             /*!< Handle to the PwrMgr instance used */
190             ElfLoader_Handle              ldrHandle;
191             /*!< Handle to the Loader instance used */
192         } dsp;
193     } sHandles;
194     /*!< Slave specific handles */
195     Platform_SlaveConfig          slaveCfg;
196     /*!< Slave embedded config */
197     Platform_SlaveSRConfig *      slaveSRCfg;
198     /*!< Shared region details from slave */
199 } Platform_Object, *Platform_Handle;
202 /*! @brief structure for platform instance */
203 typedef struct Platform_Module_State {
204     Bool              multiProcInitFlag;
205     /*!< MultiProc Initialize flag */
206     Bool              ipu_pm_init_flag;
207     /*!< ipu_pm Initialize flag */
208     Bool              procMgrInitFlag;
209     /*!< Processor manager Initialize flag */
210     Bool              elfLoaderInitFlag;
211     /*!< Elf loader Initialize flag */
212     Bool              ipcIntInitFlag;
213     /*!< IpcInt Initialize flag */
214     Bool              platformInitFlag;
215     /*!< Flag to indicate platform initialization status */
216     Bool              mqcopyInitFlag;
217     /*!< MQCopy Initialize flag */
218     Bool              platform_mem_init_flag;
219     /*!< Flag to indicate platform initialization status */
220     Bool              gateHWSpinlockInitFlag;
221     /*!< GateHWSpinlock Initialize flag */
222     Ptr               gateHWSpinlockVAddr;
223     /*!< GateHWSpinlock Virtual Address */
224 } Platform_Module_State;
227 /* =============================================================================
228  * GLOBALS
229  * =============================================================================
230  */
231 static Platform_Object Platform_objects [MultiProc_MAXPROCESSORS];
232 static Platform_Module_State Platform_Module_state;
233 static Platform_Module_State * Platform_module = &Platform_Module_state;
235 Int32 _Platform_setup  (Ipc_Config * cfg);
236 Int32 _Platform_destroy (void);
238 extern unsigned int syslink_ipu_mem_size;
239 extern unsigned int syslink_dsp_mem_size;
241 #define MAX_SIZE_OVERRIDE_PARAMS 500
243 /*Char Syslink_Override_Params[MAX_SIZE_OVERRIDE_PARAMS];*/
245 #ifndef SYSLINK_SYSBIOS_SMP
246 String Syslink_Override_Params = "ProcMgr.proc[CORE0].mmuEnable=TRUE;"
247                                  "ProcMgr.proc[CORE0].carveoutAddr0=0xBA300000;"
248                                  "ProcMgr.proc[CORE0].carveoutSize0=0x5A00000;"
249 #else
250 String Syslink_Override_Params = "ProcMgr.proc[IPU].mmuEnable=TRUE;"
251                                  "ProcMgr.proc[IPU].carveoutAddr0=0xBA300000;"
252                                  "ProcMgr.proc[IPU].carveoutSize0=0x5A00000;"
253 #endif
254                                  "ProcMgr.proc[DSP].mmuEnable=TRUE;"
255                                  "ProcMgr.proc[DSP].carveoutAddr0=0xBA300000;"
256                                  "ProcMgr.proc[DSP].carveoutSize0=0x5A00000;";
259 /** ============================================================================
260  *  APIs.
261  *  ============================================================================
262  */
263 /* Function to read slave memory */
264 Int32
265 _Platform_readSlaveMemory (UInt16   procId,
266                            UInt32   addr,
267                            Ptr      value,
268                            UInt32 * numBytes);
270 /* Function to write slave memory */
271 Int32
272 _Platform_writeSlaveMemory (UInt16   procId,
273                             UInt32   addr,
274                             Ptr      value,
275                             UInt32 * numBytes);
276 /*!
277  *  @brief      Function to get the default values for configurations.
278  *
279  *  @param      config   Configuration values.
280  */
281 Void
282 Platform_getConfig (Platform_Config * config)
284     GT_1trace (curTrace, GT_ENTER, "Platform_getConfig", config);
286     GT_assert (curTrace, (config != NULL));
288 #if !defined(SYSLINK_BUILD_OPTIMIZE)
289     if (config == NULL) {
290         GT_setFailureReason (curTrace,
291                              GT_4CLASS,
292                              "Platform_getConfig",
293                              Platform_E_INVALIDARG,
294                              "Argument of type (Platform_getConfig *) passed "
295                              "is null!");
296     }
297     else {
298 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
300         /* Get the gatepeterson default config */
301         MultiProc_getConfig (&config->multiProcConfig);
303         /* Get the PROCMGR default config */
304         ProcMgr_getConfig (&config->procMgrConfig);
306         /* Get the ElfLoader default config */
307         ElfLoader_getConfig(&config->elfLoaderConfig);
309         /* Get the HWSpinlock default config */
310         GateHWSpinlock_getConfig (&config->gateHWSpinlockConfig);
311 #if !defined(SYSLINK_BUILD_OPTIMIZE)
312     }
313 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
315     GT_0trace (curTrace, GT_LEAVE, "Platform_getConfig");
318 /*!
319  *  @brief      Function to override the default confiuration values.
320  *
321  *  @param      config   Configuration values.
322  */
323 Int32
324 Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
326     Int32  status = Platform_S_SUCCESS;
327     /*Char   hexString[16];*/
329     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", config);
331     GT_assert (curTrace, (config != NULL));
333 #if !defined(SYSLINK_BUILD_OPTIMIZE)
334     if (config == NULL) {
335         /*! @retval Platform_E_INVALIDARG Argument of type
336          *  (Platform_Config *) passed is null*/
337         status = Platform_E_INVALIDARG;
338         GT_setFailureReason (curTrace,
339                              GT_4CLASS,
340                              "Platform_overrideConfig",
341                              status,
342                              "Argument of type (Platform_getConfig *) passed "
343                              "is null!");
344     }
345     else {
346 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
347 /*
348         String_cpy(Syslink_Override_Params,
349                    "ProcMgr.proc[CORE0].mmuEnable=TRUE;");
350         String_hexToStr(hexString, cfg->pAddr);
351         String_cat(Syslink_Override_Params,
352                    "ProcMgr.proc[CORE0].carveoutAddr0=");
353         String_cat(Syslink_Override_Params, hexString);
354         String_cat(Syslink_Override_Params, ";");
355         String_hexToStr(hexString, syslink_ipu_mem_size);
356         String_cat(Syslink_Override_Params,
357                    "ProcMgr.proc[CORE0].carveoutSize0=");
358         String_cat(Syslink_Override_Params, hexString);
359         String_cat(Syslink_Override_Params, ";");
360         String_cat(Syslink_Override_Params,
361                    "ProcMgr.proc[DSP].mmuEnable=TRUE;");
362         String_hexToStr(hexString, cfg->pAddr_dsp);
363         String_cat(Syslink_Override_Params,
364                    "ProcMgr.proc[DSP].carveoutAddr0=");
365         String_cat(Syslink_Override_Params, hexString);
366         String_cat(Syslink_Override_Params, ";");
367         String_hexToStr(hexString, syslink_dsp_mem_size);
368         String_cat(Syslink_Override_Params,
369                    "ProcMgr.proc[DSP].carveoutSize0=");
370         String_cat(Syslink_Override_Params, hexString);
371         String_cat(Syslink_Override_Params, ";");
372 */
373         cfg->params = Memory_alloc(NULL,
374                                    String_len(Syslink_Override_Params) + 1, 0,
375                                    NULL);
376         if (cfg->params) {
377             String_cpy(cfg->params, Syslink_Override_Params);
378         }
380         _ProcMgr_saveParams(cfg->params, String_len(cfg->params));
382         /* Set the MultiProc config as defined in SystemCfg.c */
383         config->multiProcConfig = _MultiProc_cfg;
385         /* Override the PROCMGR default config */
387         /* Override the MessageQCopy default config */
388         config->MQCopyConfig.intId[1] = 58;
389         config->MQCopyConfig.intId[2] = 58;
390         config->MQCopyConfig.intId[3] = 58;
392         config->ipu_pm_config.int_id = 58;
393 #ifdef SYSLINK_SYSBIOS_SMP
394         config->ipu_pm_config.num_procs = 2;
395         config->ipu_pm_config.proc_ids[0] = 1; // IPU is set as 1 above
396         config->ipu_pm_config.proc_ids[1] = 2; // DSP is set as 2 above
397 #else
398         config->ipu_pm_config.num_procs = 3;
399         config->ipu_pm_config.proc_ids[0] = 1; // CORE0 is set as 1 above
400         config->ipu_pm_config.proc_ids[1] = 2; // CORE1 is set as 2 above
401         config->ipu_pm_config.proc_ids[2] = 3; // DSP is set as 3 above
402 #endif
404 #if !defined(SYSLINK_BUILD_OPTIMIZE)
405     }
406 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
408     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", status);
410     /*! @retval Platform_S_SUCCESS operation was successful */
411     return status;
414 /*!
415  *  @brief      Function to setup platform.
416  *              TBD: logic would change completely in the final system.
417  */
418 Int32
419 Platform_setup (Ipc_Config * cfg)
421     Int32                   status      = Platform_S_SUCCESS;
422     Platform_Config         _config;
423     Platform_Config *       config;
424     Omap5430IpcInt_Config   omap5430cfg;
425     Memory_MapInfo    minfo;
427     Platform_getConfig (&_config);
428     config = &_config;
430 /* Initialize PlatformMem */
431     status = MemoryOS_setup();
432 #if !defined(SYSLINK_BUILD_OPTIMIZE)
433     if (status < 0) {
434         GT_setFailureReason (curTrace,
435                              GT_4CLASS,
436                              "Platform_setup",
437                              status,
438                              "platform_mem_setup!");
439     } else {
440 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
441         Platform_module->platform_mem_init_flag = TRUE;
442 #if !defined(SYSLINK_BUILD_OPTIMIZE)
443     }
444 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
446     Platform_overrideConfig (config, cfg);
448     status = MultiProc_setup (&(config->multiProcConfig));
449 #if !defined(SYSLINK_BUILD_OPTIMIZE)
450     if (status < 0) {
451         GT_setFailureReason (curTrace,
452                              GT_4CLASS,
453                              "Platform_setup",
454                              status,
455                              "MultiProc_setup failed!");
456     }
457     else {
458 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
459             Platform_module->multiProcInitFlag = TRUE;
460 #if !defined(SYSLINK_BUILD_OPTIMIZE)
461     }
462 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
464 /* Initialize PROCMGR */
465     if (status >= 0) {
466         status = ProcMgr_setup (&(config->procMgrConfig));
467 #if !defined(SYSLINK_BUILD_OPTIMIZE)
468         if (status < 0) {
469             GT_setFailureReason (curTrace,
470                                  GT_4CLASS,
471                                  "Platform_setup",
472                                  status,
473                                  "ProcMgr_setup failed!");
474         }
475         else {
476 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
477             Platform_module->procMgrInitFlag = TRUE;
478 #if !defined(SYSLINK_BUILD_OPTIMIZE)
479         }
480 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
481     }
483     /* Initialize IpcInt required for VirtQueue/MessageQCopy. */
484     if (status >= 0) {
485         /* Do the IPC interrupt setup for the full platform (cfg is not used) */
486         Omap5430IpcInt_setup(&omap5430cfg);
487         Platform_module->ipcIntInitFlag = TRUE;
488     }
490 /* Initialize Elf loader */
491     if (status >= 0) {
492         status = ElfLoader_setup (&config->elfLoaderConfig);
493 #if !defined(SYSLINK_BUILD_OPTIMIZE)
494         if (status < 0) {
495             GT_setFailureReason (curTrace,
496                                  GT_4CLASS,
497                                  "Platform_setup",
498                                  status,
499                                  "ElfLoader_setup failed!");
500         }
501         else {
502 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
503             Platform_module->elfLoaderInitFlag = TRUE;
504 #if !defined(SYSLINK_BUILD_OPTIMIZE)
505         }
506 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
507     }
509 /* Initialize ipu_pm */
510     if (status >= 0) {
511         status = ipu_pm_setup (&config->ipu_pm_config);
512 #if !defined(SYSLINK_BUILD_OPTIMIZE)
513         if (status < 0) {
514             GT_setFailureReason (curTrace,
515                                  GT_4CLASS,
516                                  "Platform_setup",
517                                  status,
518                                  "ipu_pm_setup failed!");
519         }
520         else {
521 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
522             Platform_module->ipu_pm_init_flag = TRUE;
523 #if !defined(SYSLINK_BUILD_OPTIMIZE)
524         }
525 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
526     }
528 /* Initialize MessageQCopy */
529     if (status >= 0) {
530         status = MessageQCopy_setup (&config->MQCopyConfig);
531 #if !defined(SYSLINK_BUILD_OPTIMIZE)
532         if (status < 0) {
533             GT_setFailureReason (curTrace,
534                                  GT_4CLASS,
535                                  "Platform_setup",
536                                  status,
537                                  "MessageQCopy_setup failed!");
538         }
539         else {
540 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
541             Platform_module->mqcopyInitFlag = TRUE;
542 #if !defined(SYSLINK_BUILD_OPTIMIZE)
543         }
544 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
545     }
547     if (status >= 0) {
548         Memory_set (Platform_objects,
549                     0,
550                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
551     }
553     if (status >= 0) {
554         /* Doing per remote-proc init stuff */
555         status = _Platform_setup (cfg);
556 #if !defined(SYSLINK_BUILD_OPTIMIZE)
557         if (status < 0) {
558             GT_setFailureReason (curTrace,
559                                  GT_4CLASS,
560                                  "Platform_setup",
561                                  status,
562                                  "_Platform_setup failed!");
563         }
564         else {
565 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
566             Platform_module->platformInitFlag = TRUE;
567 #if !defined(SYSLINK_BUILD_OPTIMIZE)
568         }
569 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
570     }
571     if (status >= 0) {
572         minfo.src  = HWSPINLOCK_BASE;
573         minfo.size = HWSPINLOCK_SIZE;
574         minfo.isCached = FALSE;
575         status = Memory_map (&minfo);
576         if (status < 0) {
577            GT_setFailureReason (curTrace,
578                                 GT_4CLASS,
579                                 "Platform_setup",
580                                 status,
581                                 "Memory_map failed!");
582         }
583         else {
584             Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
585             config->gateHWSpinlockConfig.numLocks = 32;
586             config->gateHWSpinlockConfig.baseAddr = minfo.dst  + HWSPINLOCK_OFFSET;
587             status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
588 #if !defined(SYSLINK_BUILD_OPTIMIZE)
589             if (status < 0) {
590                 GT_setFailureReason (curTrace,
591                                      GT_4CLASS,
592                                      "Platform_setup",
593                                      status,
594                                      "GateHWSpinlock_setup failed!");
595             }
596             else {
597 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
598                 Platform_module->gateHWSpinlockInitFlag = TRUE;
599 #if !defined(SYSLINK_BUILD_OPTIMIZE)
600             }
601 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
602         }
603     }
605     if (status < 0) {
606         Platform_destroy();
607     }
609     return status;
613 /*!
614  *  @brief      Function to destroy the System.
615  *
616  *  @sa         Platform_setup
617  */
618 Int32
619 Platform_destroy (void)
621     Int32  status = Platform_S_SUCCESS;
622     Memory_UnmapInfo minfo;
624     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
626     /* Finalize Platform-specific destroy */
627     if (Platform_module->platformInitFlag == TRUE) {
628         status = _Platform_destroy ();
629 #if !defined(SYSLINK_BUILD_OPTIMIZE)
630         if (status < 0) {
631             GT_setFailureReason (curTrace,
632                                  GT_4CLASS,
633                                  "Platform_destroy",
634                                  status,
635                                  "Platform_destroy failed!");
636         }
637         else {
638 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
639             Platform_module->platformInitFlag = FALSE;
640 #if !defined(SYSLINK_BUILD_OPTIMIZE)
641         }
642 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
643     }
645     /* Finalize MessageQCopy */
646     if (Platform_module->mqcopyInitFlag == TRUE) {
647         status = MessageQCopy_destroy ();
648 #if !defined(SYSLINK_BUILD_OPTIMIZE)
649         if (status < 0) {
650             GT_setFailureReason (curTrace,
651                                  GT_4CLASS,
652                                  "Platform_destroy",
653                                  status,
654                                  "MessageQCopy_destroy failed!");
655         }
656         else {
657 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
658             Platform_module->mqcopyInitFlag = FALSE;
659 #if !defined(SYSLINK_BUILD_OPTIMIZE)
660         }
661 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
662     }
664     /* Finalize ipu_pm */
665     if (Platform_module->ipu_pm_init_flag == TRUE) {
666         status = ipu_pm_destroy ();
667 #if !defined(SYSLINK_BUILD_OPTIMIZE)
668         if (status < 0) {
669             GT_setFailureReason (curTrace,
670                                  GT_4CLASS,
671                                  "Platform_destroy",
672                                  status,
673                                  "ipu_pm_destroy failed!");
674         }
675         else {
676 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
677             Platform_module->ipu_pm_init_flag = FALSE;
678 #if !defined(SYSLINK_BUILD_OPTIMIZE)
679         }
680 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
681     }
683     /* Finalize Elf loader */
684     if (Platform_module->elfLoaderInitFlag == TRUE) {
685         status = ElfLoader_destroy ();
686 #if !defined(SYSLINK_BUILD_OPTIMIZE)
687         if (status < 0) {
688             GT_setFailureReason (curTrace,
689                                  GT_4CLASS,
690                                  "Platform_destroy",
691                                  status,
692                                  "ElfLoader_destroy failed!");
693         }
694         else {
695 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
696             Platform_module->elfLoaderInitFlag = FALSE;
697 #if !defined(SYSLINK_BUILD_OPTIMIZE)
698         }
699 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
700     }
702     if (Platform_module->ipcIntInitFlag == TRUE) {
703         Omap5430IpcInt_destroy ();
704         Platform_module->ipcIntInitFlag = FALSE;
705     }
707     /* Finalize PROCMGR */
708     if (Platform_module->procMgrInitFlag == TRUE) {
709         status = ProcMgr_destroy ();
710 #if !defined(SYSLINK_BUILD_OPTIMIZE)
711         if (status < 0) {
712             GT_setFailureReason (curTrace,
713                                  GT_4CLASS,
714                                  "Platform_destroy",
715                                  status,
716                                  "ProcMgr_destroy failed!");
717         }
718         else {
719 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
720             Platform_module->procMgrInitFlag = FALSE;
721 #if !defined(SYSLINK_BUILD_OPTIMIZE)
722         }
723 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
724     }
726     /* Finalize MultiProc */
727     if (Platform_module->multiProcInitFlag == TRUE) {
728         status = MultiProc_destroy ();
729 #if !defined(SYSLINK_BUILD_OPTIMIZE)
730         if (status < 0) {
731             GT_setFailureReason (curTrace,
732                                  GT_4CLASS,
733                                  "Platform_destroy",
734                                  status,
735                                  "MultiProc_destroy failed!");
736         }
737         else {
738 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
739             Platform_module->multiProcInitFlag = FALSE;
740 #if !defined(SYSLINK_BUILD_OPTIMIZE)
741         }
742 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
743     }
745     if (status >= 0) {
746         Memory_set (Platform_objects,
747                     0,
748                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
749     }
751     if (Platform_module->gateHWSpinlockInitFlag == TRUE) {
752         status = GateHWSpinlock_destroy();
753 #if !defined(SYSLINK_BUILD_OPTIMIZE)
754         if (status < 0) {
755             GT_setFailureReason (curTrace,
756                                  GT_4CLASS,
757                                  "Platform_destroy",
758                                  status,
759                                  "GateHWSpinlock_destroy failed!");
760         }
761         else {
762 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
763             Platform_module->gateHWSpinlockInitFlag = FALSE;
764 #if !defined(SYSLINK_BUILD_OPTIMIZE)
765         }
766 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
767     }
769     if (Platform_module->gateHWSpinlockVAddr) {
770         minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
771         minfo.size = HWSPINLOCK_SIZE;
772         minfo.isCached = FALSE;
773         status = Memory_unmap(&minfo);
774 #if !defined(SYSLINK_BUILD_OPTIMIZE)
775         if (status < 0) {
776             GT_setFailureReason (curTrace,
777                                  GT_4CLASS,
778                                  "Platform_destroy",
779                                  status,
780                                  "Memory_unmap failed!");
781         }
782 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
783         Platform_module->gateHWSpinlockVAddr = NULL;
784     }
786     if (Platform_module->platform_mem_init_flag == TRUE) {
787         status = MemoryOS_destroy();
788 #if !defined(SYSLINK_BUILD_OPTIMIZE)
789         if (status < 0) {
790             GT_setFailureReason (curTrace,
791                                  GT_4CLASS,
792                                  "Platform_destroy",
793                                  status,
794                                  "MemoryOS_destroy failed!");
795         }
796         else {
797 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
798             Platform_module->platform_mem_init_flag = FALSE;
799 #if !defined(SYSLINK_BUILD_OPTIMIZE)
800         }
801 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
802     }
804     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
806     /*! @retval Platform_S_SUCCESS Operation successful */
807     return status;
810 /*!
811  *  @brief      Function to setup platform.
812  *              TBD: logic would change completely in the final system.
813  */
814 Int32
815 _Platform_setup (Ipc_Config * cfg)
817     Int32                       status              = Platform_S_SUCCESS;
818     ProcMgr_Params              params;
819     OMAP5430BENELLIPROC_Config  ipu0ProcConfig;
820 #ifndef SYSLINK_SYSBIOS_SMP
821     OMAP5430BENELLIPROC_Config  ipu1ProcConfig;
822 #endif
823     OMAP5430BENELLIPROC_Config  dspProcConfig;
824     OMAP5430BENELLIPROC_Params  ipu0ProcParams;
825 #ifndef SYSLINK_SYSBIOS_SMP
826     OMAP5430BENELLIPROC_Params  ipu1ProcParams;
827 #endif
828     OMAP5430BENELLIPROC_Params  dspProcParams;
829     ProcMgr_AddrInfo *          memEntries;
830     ElfLoader_Params            elfLoaderParams;
831     ElfLoader_Handle            ldrHandle;
832     UInt16                      procId;
833     Platform_Handle             handle;
834     UInt32                      pa, va;
835     UInt32                      i                   = 0;
836     Bool                        core0Setup          = FALSE;
837 #ifndef SYSLINK_SYSBIOS_SMP
838     Bool                        core1Setup          = FALSE;
839 #endif
840     Bool                        dspSetup            = FALSE;
842     GT_0trace (curTrace, GT_ENTER, "_Platform_setup");
844     /* Get MultiProc ID by name. */
845     procId = MultiProc_getId (CORE0);
847     handle = &Platform_objects [procId];
849     OMAP5430BENELLIPROC_get_config(&ipu0ProcConfig, procId );
850     status = OMAP5430BENELLIPROC_setup (&ipu0ProcConfig, procId);
851     if (status < 0) {
852         GT_setFailureReason (curTrace,
853                              GT_4CLASS,
854                              "_Platform_setup",
855                              status,
856                              "OMAP5430PROC_setup failed!");
857     }
858     else {
859         core0Setup = TRUE;
860         /* Create an instance of the Processor object for
861          * OMAP5430 */
862         OMAP5430BENELLIPROC_Params_init (NULL, &ipu0ProcParams, procId);
864         handle->sHandles.ipu0.pHandle = OMAP5430BENELLIPROC_create (
865                                                       procId,
866                                                       &ipu0ProcParams);
868         /* Create an instance of the Elf Loader object */
869         ElfLoader_Params_init (NULL, &elfLoaderParams);
870         handle->sHandles.ipu0.ldrHandle = ElfLoader_create (procId,
871                                                           &elfLoaderParams);
873         if (handle->sHandles.ipu0.pHandle == NULL) {
874             status = Platform_E_FAIL;
875             GT_setFailureReason (curTrace,
876                                  GT_4CLASS,
877                                  "_Platform_setup",
878                                  status,
879                                  "OMAP5430PROC_create failed!");
880         }
881         else if (handle->sHandles.ipu0.ldrHandle ==  NULL) {
882             status = Platform_E_FAIL;
883             GT_setFailureReason (curTrace,
884                                  GT_4CLASS,
885                                  "_Platform_setup",
886                                  status,
887                                  "Failed to create loader instance!");
888         }
889         else {
890             /* Initialize parameters */
891             ProcMgr_Params_init (NULL, &params);
892             params.procHandle = handle->sHandles.ipu0.pHandle;
893             params.loaderHandle = handle->sHandles.ipu0.ldrHandle;
894             ldrHandle = params.loaderHandle;
895             String_cpy (params.rstVectorSectionName,
896                         RESETVECTOR_SYMBOL);
897             handle->pmHandle = ProcMgr_create (procId, &params);
898             if (handle->pmHandle == NULL) {
899                 status = Platform_E_FAIL;
900                 GT_setFailureReason (curTrace,
901                                      GT_4CLASS,
902                                      "_Platform_setup",
903                                      status,
904                                      "ProcMgr_create failed!");
905             }
906         }
907     }
909 #ifndef SYSLINK_SYSBIOS_SMP
910     if (status >= 0) {
911         /* Get MultiProc ID by name. */
912         procId = MultiProc_getId ("CORE1");
914         handle = &Platform_objects [procId];
915         OMAP5430BENELLIPROC_get_config (&ipu1ProcConfig, procId );
916         status = OMAP5430BENELLIPROC_setup (&ipu1ProcConfig, procId);
917         if (status < 0) {
918             GT_setFailureReason (curTrace,
919                                  GT_4CLASS,
920                                  "_Platform_setup",
921                                  status,
922                                  "OMAP5430PROC_setup failed!");
923         }
924         else {
925             core1Setup = TRUE;
926             /* Create an instance of the Processor object for
927              * OMAP5430 */
928             OMAP5430BENELLIPROC_Params_init(NULL, &ipu1ProcParams,procId);
930             handle->sHandles.ipu1.pHandle = OMAP5430BENELLIPROC_create(procId,
931                                                           &ipu1ProcParams);
933             /* Don't create an instance of the Elf Loader - not needed */
935             if (handle->sHandles.ipu1.pHandle == NULL) {
936                 status = Platform_E_FAIL;
937                 GT_setFailureReason (curTrace,
938                                      GT_4CLASS,
939                                      "_Platform_setup",
940                                      status,
941                                      "OMAP5430PROC_create failed!");
942             }
943             else {
944                 /* Initialize parameters */
945                 ProcMgr_Params_init (NULL, &params);
946                 params.procHandle = handle->sHandles.ipu1.pHandle;
947                 /* Use the same loader handle as ipu0 to avoid ProcMgr errors */
948                 params.loaderHandle = ldrHandle;
949                 String_cpy (params.rstVectorSectionName,
950                             RESETVECTOR_SYMBOL);
951                 handle->pmHandle = ProcMgr_create (procId, &params);
952                 if (handle->pmHandle == NULL) {
953                     status = Platform_E_FAIL;
954                     GT_setFailureReason (curTrace,
955                                          GT_4CLASS,
956                                          "_Platform_setup",
957                                          status,
958                                          "ProcMgr_create failed!");
959                 }
960             }
961         }
962     }
963 #endif
965     if (status >= 0) {
966         /* Get MultiProc ID by name. */
967         procId = MultiProc_getId ("DSP");
969         handle = &Platform_objects [procId];
970         OMAP5430BENELLIPROC_get_config(&dspProcConfig, procId);
971         status = OMAP5430BENELLIPROC_setup (&dspProcConfig, procId);
972         if (status < 0) {
973             GT_setFailureReason (curTrace,
974                                  GT_4CLASS,
975                                  "_Platform_setup",
976                                  status,
977                                  "OMAP5430PROC_setup failed!");
978         }
979         else {
980             dspSetup = TRUE;
981             /* Create an instance of the Processor object for
982                        * OMAP5430 */
983             OMAP5430BENELLIPROC_Params_init (NULL, &dspProcParams, procId);
985             handle->sHandles.dsp.pHandle = OMAP5430BENELLIPROC_create (
986                                                           procId,
987                                                           &dspProcParams);
989             /* Create an instance of the Elf Loader object */
990             ElfLoader_Params_init (NULL, &elfLoaderParams);
991             handle->sHandles.dsp.ldrHandle = ElfLoader_create (procId,
992                                                           &elfLoaderParams);
994             if (handle->sHandles.dsp.pHandle == NULL) {
995                 status = Platform_E_FAIL;
996                 GT_setFailureReason (curTrace,
997                                      GT_4CLASS,
998                                      "_Platform_setup",
999                                      status,
1000                                      "OMAP5430PROC_create failed!");
1001             }
1002             else if (handle->sHandles.dsp.ldrHandle ==  NULL) {
1003                 status = Platform_E_FAIL;
1004                 GT_setFailureReason (curTrace,
1005                                      GT_4CLASS,
1006                                      "_Platform_setup",
1007                                      status,
1008                                      "Failed to create loader instance!");
1009             }
1010             else {
1011                 /* Initialize parameters */
1012                 ProcMgr_Params_init (NULL, &params);
1013                 params.procHandle = handle->sHandles.dsp.pHandle;
1014                 params.loaderHandle = handle->sHandles.dsp.ldrHandle;
1015                 String_cpy (params.rstVectorSectionName,
1016                             RESETVECTOR_SYMBOL);
1017                 handle->pmHandle = ProcMgr_create (procId, &params);
1018                 if (handle->pmHandle == NULL) {
1019                     status = Platform_E_FAIL;
1020                     GT_setFailureReason (curTrace,
1021                                          GT_4CLASS,
1022                                          "_Platform_setup",
1023                                          status,
1024                                          "ProcMgr_create failed!");
1025                 }
1026             }
1027         }
1028     }
1030     if (status < 0) {
1031         /* Cleanup in case of error */
1032 #ifndef SYSLINK_SYSBIOS_SMP
1033         procId = MultiProc_getId ("CORE1");
1034         handle = &Platform_objects [procId];
1035         if (handle->pmHandle) {
1036             ProcMgr_delete(&handle->pmHandle);
1037             handle->pmHandle = NULL;
1038         }
1039         if (handle->sHandles.ipu1.pHandle) {
1040             OMAP5430BENELLIPROC_delete(&handle->sHandles.ipu1.pHandle);
1041             handle->sHandles.ipu1.pHandle = NULL;
1042         }
1043         if (core1Setup)
1044             OMAP5430BENELLIPROC_destroy(procId);
1045 #endif
1047         procId = MultiProc_getId (CORE0);
1049         handle = &Platform_objects [procId];
1050         if (handle->pmHandle) {
1051             ProcMgr_delete(&handle->pmHandle);
1052             handle->pmHandle = NULL;
1053         }
1054         if (handle->sHandles.ipu0.ldrHandle) {
1055             ElfLoader_delete(&handle->sHandles.ipu0.ldrHandle);
1056             handle->sHandles.ipu0.ldrHandle = NULL;
1057         }
1058         if (handle->sHandles.ipu0.pHandle) {
1059             OMAP5430BENELLIPROC_delete(&handle->sHandles.ipu0.pHandle);
1060             handle->sHandles.ipu0.pHandle = NULL;
1061         }
1062         if (core0Setup)
1063             OMAP5430BENELLIPROC_destroy(procId);
1065         procId = MultiProc_getId ("DSP");
1066         handle = &Platform_objects [procId];
1067         if (handle->pmHandle) {
1068             ProcMgr_delete(&handle->pmHandle);
1069             handle->pmHandle = NULL;
1070         }
1071         if (handle->sHandles.dsp.ldrHandle) {
1072             ElfLoader_delete(&handle->sHandles.dsp.ldrHandle);
1073             handle->sHandles.dsp.ldrHandle = NULL;
1074         }
1075         if (handle->sHandles.dsp.pHandle) {
1076             OMAP5430BENELLIPROC_delete(&handle->sHandles.dsp.pHandle);
1077             handle->sHandles.dsp.pHandle = NULL;
1078         }
1079         if (dspSetup)
1080             OMAP5430BENELLIPROC_destroy(procId);
1081     }
1082     GT_1trace (curTrace, GT_LEAVE, "_Platform_setup", status);
1084     /*! @retval Platform_S_SUCCESS operation was successful */
1085     return status;
1089 /*!
1090  *  @brief      Function to setup platform.
1091  *              TBD: logic would change completely in the final system.
1092  */
1093 Int32
1094 _Platform_destroy (void)
1096     Int32           status    = Platform_S_SUCCESS;
1097     Int32           tmpStatus = Platform_S_SUCCESS;
1098     Platform_Handle handle;
1099     /*UInt16          procId;*/
1101     /* Get MultiProc ID by name. */
1103     GT_0trace (curTrace, GT_ENTER, "_Platform_destroy");
1105 #ifndef SYSLINK_SYSBIOS_SMP
1106     /* ------------------------- ipu1 cleanup ------------------------------- */
1107     handle = &Platform_objects [MultiProc_getId ("CORE1")];
1108     if (handle->pmHandle != NULL) {
1109         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1110         GT_assert (curTrace, (tmpStatus >= 0));
1111         if ((status >= 0) && (tmpStatus < 0)) {
1112             status = tmpStatus;
1113 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1114             GT_setFailureReason (curTrace,
1115                                  GT_4CLASS,
1116                                  "_Platform_destroy",
1117                                  status,
1118                                  "ProcMgr_delete failed!");
1119 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1120         }
1121     }
1123     /* Delete the Processor, Loader and PwrMgr instances */
1125     if (handle->sHandles.ipu1.pHandle != NULL) {
1126         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.ipu1.pHandle);
1127         GT_assert (curTrace, (tmpStatus >= 0));
1128         if ((status >= 0) && (tmpStatus < 0)) {
1129             status = tmpStatus;
1130 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1131             GT_setFailureReason (curTrace,
1132                                  GT_4CLASS,
1133                                  "_Platform_destroy",
1134                                  status,
1135                                  "OMAP5430PROC_delete failed!");
1136 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1137         }
1138     }
1140     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId ("CORE1"));
1141     GT_assert (curTrace, (tmpStatus >= 0));
1142     if ((status >= 0) && (tmpStatus < 0)) {
1143         status = tmpStatus;
1144 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1145         GT_setFailureReason (curTrace,
1146                              GT_4CLASS,
1147                              "_Platform_destroy",
1148                              status,
1149                              "OMAP5430PROC_destroy failed!");
1150 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1151     }
1152 #endif
1154     /* ------------------------- ipu0 cleanup ------------------------------- */
1155     handle = &Platform_objects [MultiProc_getId (CORE0)];
1156     if (handle->pmHandle != NULL) {
1157         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1158         GT_assert (curTrace, (tmpStatus >= 0));
1159         if ((status >= 0) && (tmpStatus < 0)) {
1160             status = tmpStatus;
1161 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1162             GT_setFailureReason (curTrace,
1163                                  GT_4CLASS,
1164                                  "_Platform_destroy",
1165                                  status,
1166                                  "ProcMgr_delete failed!");
1167 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1168         }
1169     }
1171     /* Delete the Processor, Loader and PwrMgr instances */
1173     if (handle->sHandles.ipu0.ldrHandle != NULL) {
1174         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu0.ldrHandle);
1175         GT_assert (curTrace, (tmpStatus >= 0));
1176         if ((status >= 0) && (tmpStatus < 0)) {
1177             status = tmpStatus;
1178 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1179             GT_setFailureReason (curTrace,
1180                                  GT_4CLASS,
1181                                  "_Platform_destroy",
1182                                  status,
1183                                  "Failed to delete loader instance!");
1184 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1185         }
1186     }
1188     if (handle->sHandles.ipu0.pHandle != NULL) {
1189         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.ipu0.pHandle);
1190         GT_assert (curTrace, (tmpStatus >= 0));
1191         if ((status >= 0) && (tmpStatus < 0)) {
1192             status = tmpStatus;
1193 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1194             GT_setFailureReason (curTrace,
1195                                  GT_4CLASS,
1196                                  "_Platform_destroy",
1197                                  status,
1198                                  "OMAP5430PROC_delete failed!");
1199 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1200         }
1201     }
1203     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId (CORE0));
1204     GT_assert (curTrace, (tmpStatus >= 0));
1205     if ((status >= 0) && (tmpStatus < 0)) {
1206         status = tmpStatus;
1207 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1208         GT_setFailureReason (curTrace,
1209                              GT_4CLASS,
1210                              "_Platform_destroy",
1211                              status,
1212                              "OMAP5430PROC_destroy failed!");
1213 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1214     }
1216     /* ------------------------- dsp cleanup ------------------------------- */
1217     handle = &Platform_objects [MultiProc_getId ("DSP")];
1218     if (handle->pmHandle != NULL) {
1219         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1220         GT_assert (curTrace, (tmpStatus >= 0));
1221         if ((status >= 0) && (tmpStatus < 0)) {
1222             status = tmpStatus;
1223 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1224             GT_setFailureReason (curTrace,
1225                                  GT_4CLASS,
1226                                  "_Platform_destroy",
1227                                  status,
1228                                  "ProcMgr_delete failed!");
1229 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1230         }
1231     }
1233     /* Delete the Processor, Loader and PwrMgr instances */
1235     if (handle->sHandles.dsp.ldrHandle != NULL) {
1236         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1237         GT_assert (curTrace, (tmpStatus >= 0));
1238         if ((status >= 0) && (tmpStatus < 0)) {
1239             status = tmpStatus;
1240 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1241             GT_setFailureReason (curTrace,
1242                                  GT_4CLASS,
1243                                  "_Platform_destroy",
1244                                  status,
1245                                  "Failed to delete loader instance!");
1246 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1247         }
1248     }
1250     if (handle->sHandles.dsp.pHandle != NULL) {
1251         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.dsp.pHandle);
1252         GT_assert (curTrace, (tmpStatus >= 0));
1253         if ((status >= 0) && (tmpStatus < 0)) {
1254             status = tmpStatus;
1255 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1256             GT_setFailureReason (curTrace,
1257                                  GT_4CLASS,
1258                                  "_Platform_destroy",
1259                                  status,
1260                                  "OMAP5430PROC_delete failed!");
1261 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1262         }
1263     }
1265     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId ("DSP"));
1266     GT_assert (curTrace, (tmpStatus >= 0));
1267     if ((status >= 0) && (tmpStatus < 0)) {
1268         status = tmpStatus;
1269 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1270         GT_setFailureReason (curTrace,
1271                              GT_4CLASS,
1272                              "_Platform_destroy",
1273                              status,
1274                              "OMAP5430PROC_destroy failed!");
1275 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1276     }
1278     GT_1trace (curTrace, GT_LEAVE, "_Platform_destroy", status);
1280     /*! @retval Platform_S_SUCCESS operation was successful */
1281     return status;
1285 #if defined (__cplusplus)
1287 #endif /* defined (__cplusplus) */