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