Merge remote-tracking branch 'angela/13_eng_dev-ramsey-3.00.a' into dev-3.00
[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];*/
241 String Syslink_Override_Params = "ProcMgr.proc[CORE0].mmuEnable=TRUE;"
242                                  "ProcMgr.proc[CORE0].carveoutAddr0=0xBA300000;"
243                                  "ProcMgr.proc[CORE0].carveoutSize0=0x5A00000;"
244                                  "ProcMgr.proc[DSP].mmuEnable=TRUE;"
245                                  "ProcMgr.proc[DSP].carveoutAddr0=0xBA300000;"
246                                  "ProcMgr.proc[DSP].carveoutSize0=0x5A00000;";
249 /** ============================================================================
250  *  APIs.
251  *  ============================================================================
252  */
253 /* Function to read slave memory */
254 Int32
255 _Platform_readSlaveMemory (UInt16   procId,
256                            UInt32   addr,
257                            Ptr      value,
258                            UInt32 * numBytes);
260 /* Function to write slave memory */
261 Int32
262 _Platform_writeSlaveMemory (UInt16   procId,
263                             UInt32   addr,
264                             Ptr      value,
265                             UInt32 * numBytes);
266 /*!
267  *  @brief      Function to get the default values for configurations.
268  *
269  *  @param      config   Configuration values.
270  */
271 Void
272 Platform_getConfig (Platform_Config * config)
274     GT_1trace (curTrace, GT_ENTER, "Platform_getConfig", config);
276     GT_assert (curTrace, (config != NULL));
278 #if !defined(SYSLINK_BUILD_OPTIMIZE)
279     if (config == NULL) {
280         GT_setFailureReason (curTrace,
281                              GT_4CLASS,
282                              "Platform_getConfig",
283                              Platform_E_INVALIDARG,
284                              "Argument of type (Platform_getConfig *) passed "
285                              "is null!");
286     }
287     else {
288 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
290         /* Get the gatepeterson default config */
291         MultiProc_getConfig (&config->multiProcConfig);
293         /* Get the PROCMGR default config */
294         ProcMgr_getConfig (&config->procMgrConfig);
296         /* Get the ElfLoader default config */
297         ElfLoader_getConfig(&config->elfLoaderConfig);
299         /* Get the HWSpinlock default config */
300         GateHWSpinlock_getConfig (&config->gateHWSpinlockConfig);
301 #if !defined(SYSLINK_BUILD_OPTIMIZE)
302     }
303 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
305     GT_0trace (curTrace, GT_LEAVE, "Platform_getConfig");
308 /*!
309  *  @brief      Function to override the default confiuration values.
310  *
311  *  @param      config   Configuration values.
312  */
313 Int32
314 Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
316     Int32  status = Platform_S_SUCCESS;
317     /*Char   hexString[16];*/
319     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", config);
321     GT_assert (curTrace, (config != NULL));
323 #if !defined(SYSLINK_BUILD_OPTIMIZE)
324     if (config == NULL) {
325         /*! @retval Platform_E_INVALIDARG Argument of type
326          *  (Platform_Config *) passed is null*/
327         status = Platform_E_INVALIDARG;
328         GT_setFailureReason (curTrace,
329                              GT_4CLASS,
330                              "Platform_overrideConfig",
331                              status,
332                              "Argument of type (Platform_getConfig *) passed "
333                              "is null!");
334     }
335     else {
336 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
337 /*
338         String_cpy(Syslink_Override_Params,
339                    "ProcMgr.proc[CORE0].mmuEnable=TRUE;");
340         String_hexToStr(hexString, cfg->pAddr);
341         String_cat(Syslink_Override_Params,
342                    "ProcMgr.proc[CORE0].carveoutAddr0=");
343         String_cat(Syslink_Override_Params, hexString);
344         String_cat(Syslink_Override_Params, ";");
345         String_hexToStr(hexString, syslink_ipu_mem_size);
346         String_cat(Syslink_Override_Params,
347                    "ProcMgr.proc[CORE0].carveoutSize0=");
348         String_cat(Syslink_Override_Params, hexString);
349         String_cat(Syslink_Override_Params, ";");
350         String_cat(Syslink_Override_Params,
351                    "ProcMgr.proc[DSP].mmuEnable=TRUE;");
352         String_hexToStr(hexString, cfg->pAddr_dsp);
353         String_cat(Syslink_Override_Params,
354                    "ProcMgr.proc[DSP].carveoutAddr0=");
355         String_cat(Syslink_Override_Params, hexString);
356         String_cat(Syslink_Override_Params, ";");
357         String_hexToStr(hexString, syslink_dsp_mem_size);
358         String_cat(Syslink_Override_Params,
359                    "ProcMgr.proc[DSP].carveoutSize0=");
360         String_cat(Syslink_Override_Params, hexString);
361         String_cat(Syslink_Override_Params, ";");
362 */
363         cfg->params = Memory_alloc(NULL,
364                                    String_len(Syslink_Override_Params) + 1, 0,
365                                    NULL);
366         if (cfg->params) {
367             String_cpy(cfg->params, Syslink_Override_Params);
368         }
370         _ProcMgr_saveParams(cfg->params, String_len(cfg->params));
372 #ifdef SYSLINK_SYSBIOS_SMP
373         /* Override the gatepeterson default config */
374         config->multiProcConfig.numProcessors = 3;
375         config->multiProcConfig.id            = 0;
377         String_cpy (config->multiProcConfig.nameList [0],
378                     "HOST");
379         String_cpy (config->multiProcConfig.nameList [1],
380                     "CORE0");
381         String_cpy (config->multiProcConfig.nameList [2],
382                     "DSP");
383 #else
384         /* Override the gatepeterson default config */
385         config->multiProcConfig.numProcessors = 4;
386         config->multiProcConfig.id            = 0;
388         String_cpy (config->multiProcConfig.nameList [0],
389                     "HOST");
390         String_cpy (config->multiProcConfig.nameList [1],
391                     "CORE0");
392         String_cpy (config->multiProcConfig.nameList [2],
393                     "CORE1");
394         String_cpy (config->multiProcConfig.nameList [3],
395                     "DSP");
396 #endif
398         /* Override the PROCMGR default config */
400         /* Override the MessageQCopy default config */
401         config->MQCopyConfig.intId = 58;
403         config->ipu_pm_config.int_id = 58;
404 #ifdef SYSLINK_SYSBIOS_SMP
405         config->ipu_pm_config.num_procs = 2;
406         config->ipu_pm_config.proc_ids[0] = 1; // CORE0 is set as 1 above
407         config->ipu_pm_config.proc_ids[1] = 2; // DSP is set as 2 above
408 #else
409         config->ipu_pm_config.num_procs = 3;
410         config->ipu_pm_config.proc_ids[0] = 1; // CORE0 is set as 1 above
411         config->ipu_pm_config.proc_ids[1] = 2; // CORE1 is set as 2 above
412         config->ipu_pm_config.proc_ids[2] = 3; // DSP is set as 3 above
413 #endif
415 #if !defined(SYSLINK_BUILD_OPTIMIZE)
416     }
417 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
419     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", status);
421     /*! @retval Platform_S_SUCCESS operation was successful */
422     return status;
425 /*!
426  *  @brief      Function to setup platform.
427  *              TBD: logic would change completely in the final system.
428  */
429 Int32
430 Platform_setup (Ipc_Config * cfg)
432     Int32                   status      = Platform_S_SUCCESS;
433     Platform_Config         _config;
434     Platform_Config *       config;
435     Omap5430IpcInt_Config   omap5430cfg;
436     Memory_MapInfo    minfo;
438     Platform_getConfig (&_config);
439     config = &_config;
441 /* Initialize PlatformMem */
442     status = MemoryOS_setup();
443 #if !defined(SYSLINK_BUILD_OPTIMIZE)
444     if (status < 0) {
445         GT_setFailureReason (curTrace,
446                              GT_4CLASS,
447                              "Platform_setup",
448                              status,
449                              "platform_mem_setup!");
450     } else {
451 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
452         Platform_module->platform_mem_init_flag = TRUE;
453 #if !defined(SYSLINK_BUILD_OPTIMIZE)
454     }
455 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
457     Platform_overrideConfig (config, cfg);
459     status = MultiProc_setup (&(config->multiProcConfig));
460 #if !defined(SYSLINK_BUILD_OPTIMIZE)
461     if (status < 0) {
462         GT_setFailureReason (curTrace,
463                              GT_4CLASS,
464                              "Platform_setup",
465                              status,
466                              "MultiProc_setup failed!");
467     }
468     else {
469 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
470             Platform_module->multiProcInitFlag = TRUE;
471 #if !defined(SYSLINK_BUILD_OPTIMIZE)
472     }
473 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
475 /* Initialize PROCMGR */
476     if (status >= 0) {
477         status = ProcMgr_setup (&(config->procMgrConfig));
478 #if !defined(SYSLINK_BUILD_OPTIMIZE)
479         if (status < 0) {
480             GT_setFailureReason (curTrace,
481                                  GT_4CLASS,
482                                  "Platform_setup",
483                                  status,
484                                  "ProcMgr_setup failed!");
485         }
486         else {
487 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
488             Platform_module->procMgrInitFlag = TRUE;
489 #if !defined(SYSLINK_BUILD_OPTIMIZE)
490         }
491 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
492     }
494     /* Initialize IpcInt required for VirtQueue/MessageQCopy. */
495     if (status >= 0) {
496         /* Do the IPC interrupt setup for the full platform (cfg is not used) */
497         Omap5430IpcInt_setup(&omap5430cfg);
498         Platform_module->ipcIntInitFlag = TRUE;
499     }
501 /* Initialize Elf loader */
502     if (status >= 0) {
503         status = ElfLoader_setup (&config->elfLoaderConfig);
504 #if !defined(SYSLINK_BUILD_OPTIMIZE)
505         if (status < 0) {
506             GT_setFailureReason (curTrace,
507                                  GT_4CLASS,
508                                  "Platform_setup",
509                                  status,
510                                  "ElfLoader_setup failed!");
511         }
512         else {
513 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
514             Platform_module->elfLoaderInitFlag = TRUE;
515 #if !defined(SYSLINK_BUILD_OPTIMIZE)
516         }
517 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
518     }
520 /* Initialize ipu_pm */
521     if (status >= 0) {
522         status = ipu_pm_setup (&config->ipu_pm_config);
523 #if !defined(SYSLINK_BUILD_OPTIMIZE)
524         if (status < 0) {
525             GT_setFailureReason (curTrace,
526                                  GT_4CLASS,
527                                  "Platform_setup",
528                                  status,
529                                  "ipu_pm_setup failed!");
530         }
531         else {
532 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
533             Platform_module->ipu_pm_init_flag = TRUE;
534 #if !defined(SYSLINK_BUILD_OPTIMIZE)
535         }
536 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
537     }
539 /* Initialize MessageQCopy */
540     if (status >= 0) {
541         status = MessageQCopy_setup (&config->MQCopyConfig);
542 #if !defined(SYSLINK_BUILD_OPTIMIZE)
543         if (status < 0) {
544             GT_setFailureReason (curTrace,
545                                  GT_4CLASS,
546                                  "Platform_setup",
547                                  status,
548                                  "MessageQCopy_setup failed!");
549         }
550         else {
551 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
552             Platform_module->mqcopyInitFlag = TRUE;
553 #if !defined(SYSLINK_BUILD_OPTIMIZE)
554         }
555 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
556     }
558     if (status >= 0) {
559         Memory_set (Platform_objects,
560                     0,
561                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
562     }
564     if (status >= 0) {
565         /* Doing per remote-proc init stuff */
566         status = _Platform_setup (cfg);
567 #if !defined(SYSLINK_BUILD_OPTIMIZE)
568         if (status < 0) {
569             GT_setFailureReason (curTrace,
570                                  GT_4CLASS,
571                                  "Platform_setup",
572                                  status,
573                                  "_Platform_setup failed!");
574         }
575         else {
576 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
577             Platform_module->platformInitFlag = TRUE;
578 #if !defined(SYSLINK_BUILD_OPTIMIZE)
579         }
580 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
581     }
582     if (status >= 0) {
583         minfo.src  = HWSPINLOCK_BASE;
584         minfo.size = HWSPINLOCK_SIZE;
585         minfo.isCached = FALSE;
586         status = Memory_map (&minfo);
587         if (status < 0) {
588            GT_setFailureReason (curTrace,
589                                 GT_4CLASS,
590                                 "Platform_setup",
591                                 status,
592                                 "Memory_map failed!");
593         }
594         else {
595             Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
596             config->gateHWSpinlockConfig.numLocks = 32;
597             config->gateHWSpinlockConfig.baseAddr = minfo.dst  + HWSPINLOCK_OFFSET;
598             status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
599 #if !defined(SYSLINK_BUILD_OPTIMIZE)
600             if (status < 0) {
601                 GT_setFailureReason (curTrace,
602                                      GT_4CLASS,
603                                      "Platform_setup",
604                                      status,
605                                      "GateHWSpinlock_setup failed!");
606             }
607             else {
608 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
609                 Platform_module->gateHWSpinlockInitFlag = TRUE;
610 #if !defined(SYSLINK_BUILD_OPTIMIZE)
611             }
612 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
613         }
614     }
616     if (status < 0) {
617         Platform_destroy();
618     }
620     return status;
624 /*!
625  *  @brief      Function to destroy the System.
626  *
627  *  @sa         Platform_setup
628  */
629 Int32
630 Platform_destroy (void)
632     Int32  status = Platform_S_SUCCESS;
633     Memory_UnmapInfo minfo;
635     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
637     /* Finalize Platform-specific destroy */
638     if (Platform_module->platformInitFlag == TRUE) {
639         status = _Platform_destroy ();
640 #if !defined(SYSLINK_BUILD_OPTIMIZE)
641         if (status < 0) {
642             GT_setFailureReason (curTrace,
643                                  GT_4CLASS,
644                                  "Platform_destroy",
645                                  status,
646                                  "Platform_destroy failed!");
647         }
648         else {
649 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
650             Platform_module->platformInitFlag = FALSE;
651 #if !defined(SYSLINK_BUILD_OPTIMIZE)
652         }
653 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
654     }
656     /* Finalize MessageQCopy */
657     if (Platform_module->mqcopyInitFlag == TRUE) {
658         status = MessageQCopy_destroy ();
659 #if !defined(SYSLINK_BUILD_OPTIMIZE)
660         if (status < 0) {
661             GT_setFailureReason (curTrace,
662                                  GT_4CLASS,
663                                  "Platform_destroy",
664                                  status,
665                                  "MessageQCopy_destroy failed!");
666         }
667         else {
668 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
669             Platform_module->mqcopyInitFlag = FALSE;
670 #if !defined(SYSLINK_BUILD_OPTIMIZE)
671         }
672 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
673     }
675     /* Finalize ipu_pm */
676     if (Platform_module->ipu_pm_init_flag == TRUE) {
677         status = ipu_pm_destroy ();
678 #if !defined(SYSLINK_BUILD_OPTIMIZE)
679         if (status < 0) {
680             GT_setFailureReason (curTrace,
681                                  GT_4CLASS,
682                                  "Platform_destroy",
683                                  status,
684                                  "ipu_pm_destroy failed!");
685         }
686         else {
687 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
688             Platform_module->ipu_pm_init_flag = FALSE;
689 #if !defined(SYSLINK_BUILD_OPTIMIZE)
690         }
691 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
692     }
694     /* Finalize Elf loader */
695     if (Platform_module->elfLoaderInitFlag == TRUE) {
696         status = ElfLoader_destroy ();
697 #if !defined(SYSLINK_BUILD_OPTIMIZE)
698         if (status < 0) {
699             GT_setFailureReason (curTrace,
700                                  GT_4CLASS,
701                                  "Platform_destroy",
702                                  status,
703                                  "ElfLoader_destroy failed!");
704         }
705         else {
706 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
707             Platform_module->elfLoaderInitFlag = FALSE;
708 #if !defined(SYSLINK_BUILD_OPTIMIZE)
709         }
710 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
711     }
713     if (Platform_module->ipcIntInitFlag == TRUE) {
714         Omap5430IpcInt_destroy ();
715         Platform_module->ipcIntInitFlag = FALSE;
716     }
718     /* Finalize PROCMGR */
719     if (Platform_module->procMgrInitFlag == TRUE) {
720         status = ProcMgr_destroy ();
721 #if !defined(SYSLINK_BUILD_OPTIMIZE)
722         if (status < 0) {
723             GT_setFailureReason (curTrace,
724                                  GT_4CLASS,
725                                  "Platform_destroy",
726                                  status,
727                                  "ProcMgr_destroy failed!");
728         }
729         else {
730 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
731             Platform_module->procMgrInitFlag = FALSE;
732 #if !defined(SYSLINK_BUILD_OPTIMIZE)
733         }
734 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
735     }
737     /* Finalize MultiProc */
738     if (Platform_module->multiProcInitFlag == TRUE) {
739         status = MultiProc_destroy ();
740 #if !defined(SYSLINK_BUILD_OPTIMIZE)
741         if (status < 0) {
742             GT_setFailureReason (curTrace,
743                                  GT_4CLASS,
744                                  "Platform_destroy",
745                                  status,
746                                  "MultiProc_destroy failed!");
747         }
748         else {
749 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
750             Platform_module->multiProcInitFlag = FALSE;
751 #if !defined(SYSLINK_BUILD_OPTIMIZE)
752         }
753 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
754     }
756     if (status >= 0) {
757         Memory_set (Platform_objects,
758                     0,
759                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
760     }
762     if (Platform_module->gateHWSpinlockInitFlag == TRUE) {
763         status = GateHWSpinlock_destroy();
764 #if !defined(SYSLINK_BUILD_OPTIMIZE)
765         if (status < 0) {
766             GT_setFailureReason (curTrace,
767                                  GT_4CLASS,
768                                  "Platform_destroy",
769                                  status,
770                                  "GateHWSpinlock_destroy failed!");
771         }
772         else {
773 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
774             Platform_module->gateHWSpinlockInitFlag = FALSE;
775 #if !defined(SYSLINK_BUILD_OPTIMIZE)
776         }
777 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
778     }
780     if (Platform_module->gateHWSpinlockVAddr) {
781         minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
782         minfo.size = HWSPINLOCK_SIZE;
783         minfo.isCached = FALSE;
784         status = Memory_unmap(&minfo);
785 #if !defined(SYSLINK_BUILD_OPTIMIZE)
786         if (status < 0) {
787             GT_setFailureReason (curTrace,
788                                  GT_4CLASS,
789                                  "Platform_destroy",
790                                  status,
791                                  "Memory_unmap failed!");
792         }
793 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
794         Platform_module->gateHWSpinlockVAddr = NULL;
795     }
797     if (Platform_module->platform_mem_init_flag == TRUE) {
798         status = MemoryOS_destroy();
799 #if !defined(SYSLINK_BUILD_OPTIMIZE)
800         if (status < 0) {
801             GT_setFailureReason (curTrace,
802                                  GT_4CLASS,
803                                  "Platform_destroy",
804                                  status,
805                                  "MemoryOS_destroy failed!");
806         }
807         else {
808 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
809             Platform_module->platform_mem_init_flag = FALSE;
810 #if !defined(SYSLINK_BUILD_OPTIMIZE)
811         }
812 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
813     }
815     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
817     /*! @retval Platform_S_SUCCESS Operation successful */
818     return status;
821 /*!
822  *  @brief      Function to setup platform.
823  *              TBD: logic would change completely in the final system.
824  */
825 Int32
826 _Platform_setup (Ipc_Config * cfg)
828     Int32                       status              = Platform_S_SUCCESS;
829     ProcMgr_Params              params;
830     OMAP5430BENELLIPROC_Config  ipu0ProcConfig;
831 #ifndef SYSLINK_SYSBIOS_SMP
832     OMAP5430BENELLIPROC_Config  ipu1ProcConfig;
833 #endif
834     OMAP5430BENELLIPROC_Config  dspProcConfig;
835     OMAP5430BENELLIPROC_Params  ipu0ProcParams;
836 #ifndef SYSLINK_SYSBIOS_SMP
837     OMAP5430BENELLIPROC_Params  ipu1ProcParams;
838 #endif
839     OMAP5430BENELLIPROC_Params  dspProcParams;
840     ProcMgr_AddrInfo *          memEntries;
841     ElfLoader_Params            elfLoaderParams;
842     ElfLoader_Handle            ldrHandle;
843     UInt16                      procId;
844     Platform_Handle             handle;
845     UInt32                      pa, va;
846     UInt32                      i                   = 0;
847     Bool                        core0Setup          = FALSE;
848 #ifndef SYSLINK_SYSBIOS_SMP
849     Bool                        core1Setup          = FALSE;
850 #endif
851     Bool                        dspSetup            = FALSE;
853     GT_0trace (curTrace, GT_ENTER, "_Platform_setup");
855     /* Get MultiProc ID by name. */
856     procId = MultiProc_getId ("CORE0");
858     handle = &Platform_objects [procId];
860     OMAP5430BENELLIPROC_get_config(&ipu0ProcConfig, procId );
861     status = OMAP5430BENELLIPROC_setup (&ipu0ProcConfig, procId);
862     if (status < 0) {
863         GT_setFailureReason (curTrace,
864                              GT_4CLASS,
865                              "_Platform_setup",
866                              status,
867                              "OMAP5430PROC_setup failed!");
868     }
869     else {
870         core0Setup = TRUE;
871         /* Create an instance of the Processor object for
872          * OMAP5430 */
873         OMAP5430BENELLIPROC_Params_init (NULL, &ipu0ProcParams, procId);
874         pa = cfg->pAddr;
875         va = cfg->vAddr;
876         memEntries = ipu0ProcParams.memEntries;
877         for (i = 0; i < ipu0ProcParams.numMemEntries; i++) {
878             memEntries[i].addr[ProcMgr_AddrType_MasterPhys] = pa;
879             memEntries[i].addr[ProcMgr_AddrType_MasterKnlVirt] = va;
880             pa += memEntries[i].size;
881             va += memEntries[i].size;
882         }
883         handle->sHandles.ipu0.pHandle = OMAP5430BENELLIPROC_create (
884                                                       procId,
885                                                       &ipu0ProcParams);
887         /* Create an instance of the Elf Loader object */
888         ElfLoader_Params_init (NULL, &elfLoaderParams);
889         handle->sHandles.ipu0.ldrHandle = ElfLoader_create (procId,
890                                                           &elfLoaderParams);
892         if (handle->sHandles.ipu0.pHandle == NULL) {
893             status = Platform_E_FAIL;
894             GT_setFailureReason (curTrace,
895                                  GT_4CLASS,
896                                  "_Platform_setup",
897                                  status,
898                                  "OMAP5430PROC_create failed!");
899         }
900         else if (handle->sHandles.ipu0.ldrHandle ==  NULL) {
901             status = Platform_E_FAIL;
902             GT_setFailureReason (curTrace,
903                                  GT_4CLASS,
904                                  "_Platform_setup",
905                                  status,
906                                  "Failed to create loader instance!");
907         }
908         else {
909             /* Initialize parameters */
910             ProcMgr_Params_init (NULL, &params);
911             params.procHandle = handle->sHandles.ipu0.pHandle;
912             params.loaderHandle = handle->sHandles.ipu0.ldrHandle;
913             ldrHandle = params.loaderHandle;
914             String_cpy (params.rstVectorSectionName,
915                         RESETVECTOR_SYMBOL);
916             handle->pmHandle = ProcMgr_create (procId, &params);
917             if (handle->pmHandle == NULL) {
918                 status = Platform_E_FAIL;
919                 GT_setFailureReason (curTrace,
920                                      GT_4CLASS,
921                                      "_Platform_setup",
922                                      status,
923                                      "ProcMgr_create failed!");
924             }
925         }
926     }
928 #ifndef SYSLINK_SYSBIOS_SMP
929     if (status >= 0) {
930         /* Get MultiProc ID by name. */
931         procId = MultiProc_getId ("CORE1");
933         handle = &Platform_objects [procId];
934         OMAP5430BENELLIPROC_get_config (&ipu1ProcConfig, procId );
935         status = OMAP5430BENELLIPROC_setup (&ipu1ProcConfig, procId);
936         if (status < 0) {
937             GT_setFailureReason (curTrace,
938                                  GT_4CLASS,
939                                  "_Platform_setup",
940                                  status,
941                                  "OMAP5430PROC_setup failed!");
942         }
943         else {
944             core1Setup = TRUE;
945             /* Create an instance of the Processor object for
946              * OMAP5430 */
947             OMAP5430BENELLIPROC_Params_init(NULL, &ipu1ProcParams,procId);
948             pa = cfg->pAddr;
949             va = cfg->vAddr;
950             memEntries = ipu1ProcParams.memEntries;
951             for (i = 0; i < ipu1ProcParams.numMemEntries; i++) {
952                 memEntries[i].addr[ProcMgr_AddrType_MasterPhys] = pa;
953                 memEntries[i].addr[ProcMgr_AddrType_MasterKnlVirt] = va;
954                 pa += memEntries[i].size;
955                 va += memEntries[i].size;
956             }
957             handle->sHandles.ipu1.pHandle = OMAP5430BENELLIPROC_create(procId,
958                                                           &ipu1ProcParams);
960             /* Don't create an instance of the Elf Loader - not needed */
962             if (handle->sHandles.ipu1.pHandle == NULL) {
963                 status = Platform_E_FAIL;
964                 GT_setFailureReason (curTrace,
965                                      GT_4CLASS,
966                                      "_Platform_setup",
967                                      status,
968                                      "OMAP5430PROC_create failed!");
969             }
970             else {
971                 /* Initialize parameters */
972                 ProcMgr_Params_init (NULL, &params);
973                 params.procHandle = handle->sHandles.ipu1.pHandle;
974                 /* Use the same loader handle as ipu0 to avoid ProcMgr errors */
975                 params.loaderHandle = ldrHandle;
976                 String_cpy (params.rstVectorSectionName,
977                             RESETVECTOR_SYMBOL);
978                 handle->pmHandle = ProcMgr_create (procId, &params);
979                 if (handle->pmHandle == NULL) {
980                     status = Platform_E_FAIL;
981                     GT_setFailureReason (curTrace,
982                                          GT_4CLASS,
983                                          "_Platform_setup",
984                                          status,
985                                          "ProcMgr_create failed!");
986                 }
987             }
988         }
989     }
990 #endif
992     if (status >= 0) {
993         /* Get MultiProc ID by name. */
994         procId = MultiProc_getId ("DSP");
996         handle = &Platform_objects [procId];
997         OMAP5430BENELLIPROC_get_config(&dspProcConfig, procId);
998         status = OMAP5430BENELLIPROC_setup (&dspProcConfig, procId);
999         if (status < 0) {
1000             GT_setFailureReason (curTrace,
1001                                  GT_4CLASS,
1002                                  "_Platform_setup",
1003                                  status,
1004                                  "OMAP5430PROC_setup failed!");
1005         }
1006         else {
1007             dspSetup = TRUE;
1008             /* Create an instance of the Processor object for
1009                        * OMAP5430 */
1010             OMAP5430BENELLIPROC_Params_init (NULL, &dspProcParams, procId);
1011             pa = cfg->pAddr_dsp;
1012             va = cfg->vAddr_dsp;
1013             memEntries = dspProcParams.memEntries;
1014             for (i = 0; i < dspProcParams.numMemEntries; i++) {
1015                 memEntries[i].addr[ProcMgr_AddrType_MasterPhys] = pa;
1016                 memEntries[i].addr[ProcMgr_AddrType_MasterKnlVirt] = va;
1017                 pa += memEntries[i].size;
1018                 va += memEntries[i].size;
1019             }
1020             handle->sHandles.dsp.pHandle = OMAP5430BENELLIPROC_create (
1021                                                           procId,
1022                                                           &dspProcParams);
1024             /* Create an instance of the Elf Loader object */
1025             ElfLoader_Params_init (NULL, &elfLoaderParams);
1026             handle->sHandles.dsp.ldrHandle = ElfLoader_create (procId,
1027                                                           &elfLoaderParams);
1029             if (handle->sHandles.dsp.pHandle == NULL) {
1030                 status = Platform_E_FAIL;
1031                 GT_setFailureReason (curTrace,
1032                                      GT_4CLASS,
1033                                      "_Platform_setup",
1034                                      status,
1035                                      "OMAP5430PROC_create failed!");
1036             }
1037             else if (handle->sHandles.dsp.ldrHandle ==  NULL) {
1038                 status = Platform_E_FAIL;
1039                 GT_setFailureReason (curTrace,
1040                                      GT_4CLASS,
1041                                      "_Platform_setup",
1042                                      status,
1043                                      "Failed to create loader instance!");
1044             }
1045             else {
1046                 /* Initialize parameters */
1047                 ProcMgr_Params_init (NULL, &params);
1048                 params.procHandle = handle->sHandles.dsp.pHandle;
1049                 params.loaderHandle = handle->sHandles.dsp.ldrHandle;
1050                 String_cpy (params.rstVectorSectionName,
1051                             RESETVECTOR_SYMBOL);
1052                 handle->pmHandle = ProcMgr_create (procId, &params);
1053                 if (handle->pmHandle == NULL) {
1054                     status = Platform_E_FAIL;
1055                     GT_setFailureReason (curTrace,
1056                                          GT_4CLASS,
1057                                          "_Platform_setup",
1058                                          status,
1059                                          "ProcMgr_create failed!");
1060                 }
1061             }
1062         }
1063     }
1065     if (status < 0) {
1066         /* Cleanup in case of error */
1067 #ifndef SYSLINK_SYSBIOS_SMP
1068         procId = MultiProc_getId ("CORE1");
1069         handle = &Platform_objects [procId];
1070         if (handle->pmHandle) {
1071             ProcMgr_delete(&handle->pmHandle);
1072             handle->pmHandle = NULL;
1073         }
1074         if (handle->sHandles.ipu1.pHandle) {
1075             OMAP5430BENELLIPROC_delete(&handle->sHandles.ipu1.pHandle);
1076             handle->sHandles.ipu1.pHandle = NULL;
1077         }
1078         if (core1Setup)
1079             OMAP5430BENELLIPROC_destroy(procId);
1080 #endif
1082         procId = MultiProc_getId ("CORE0");
1083         handle = &Platform_objects [procId];
1084         if (handle->pmHandle) {
1085             ProcMgr_delete(&handle->pmHandle);
1086             handle->pmHandle = NULL;
1087         }
1088         if (handle->sHandles.ipu0.ldrHandle) {
1089             ElfLoader_delete(&handle->sHandles.ipu0.ldrHandle);
1090             handle->sHandles.ipu0.ldrHandle = NULL;
1091         }
1092         if (handle->sHandles.ipu0.pHandle) {
1093             OMAP5430BENELLIPROC_delete(&handle->sHandles.ipu0.pHandle);
1094             handle->sHandles.ipu0.pHandle = NULL;
1095         }
1096         if (core0Setup)
1097             OMAP5430BENELLIPROC_destroy(procId);
1099         procId = MultiProc_getId ("DSP");
1100         handle = &Platform_objects [procId];
1101         if (handle->pmHandle) {
1102             ProcMgr_delete(&handle->pmHandle);
1103             handle->pmHandle = NULL;
1104         }
1105         if (handle->sHandles.dsp.ldrHandle) {
1106             ElfLoader_delete(&handle->sHandles.dsp.ldrHandle);
1107             handle->sHandles.dsp.ldrHandle = NULL;
1108         }
1109         if (handle->sHandles.dsp.pHandle) {
1110             OMAP5430BENELLIPROC_delete(&handle->sHandles.dsp.pHandle);
1111             handle->sHandles.dsp.pHandle = NULL;
1112         }
1113         if (dspSetup)
1114             OMAP5430BENELLIPROC_destroy(procId);
1115     }
1116     GT_1trace (curTrace, GT_LEAVE, "_Platform_setup", status);
1118     /*! @retval Platform_S_SUCCESS operation was successful */
1119     return status;
1123 /*!
1124  *  @brief      Function to setup platform.
1125  *              TBD: logic would change completely in the final system.
1126  */
1127 Int32
1128 _Platform_destroy (void)
1130     Int32           status    = Platform_S_SUCCESS;
1131     Int32           tmpStatus = Platform_S_SUCCESS;
1132     Platform_Handle handle;
1133     /*UInt16          procId;*/
1135     /* Get MultiProc ID by name. */
1137     GT_0trace (curTrace, GT_ENTER, "_Platform_destroy");
1139 #ifndef SYSLINK_SYSBIOS_SMP
1140     /* ------------------------- ipu1 cleanup ------------------------------- */
1141     handle = &Platform_objects [MultiProc_getId ("CORE1")];
1142     if (handle->pmHandle != NULL) {
1143         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1144         GT_assert (curTrace, (tmpStatus >= 0));
1145         if ((status >= 0) && (tmpStatus < 0)) {
1146             status = tmpStatus;
1147 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1148             GT_setFailureReason (curTrace,
1149                                  GT_4CLASS,
1150                                  "_Platform_destroy",
1151                                  status,
1152                                  "ProcMgr_delete failed!");
1153 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1154         }
1155     }
1157     /* Delete the Processor, Loader and PwrMgr instances */
1159     if (handle->sHandles.ipu1.pHandle != NULL) {
1160         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.ipu1.pHandle);
1161         GT_assert (curTrace, (tmpStatus >= 0));
1162         if ((status >= 0) && (tmpStatus < 0)) {
1163             status = tmpStatus;
1164 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1165             GT_setFailureReason (curTrace,
1166                                  GT_4CLASS,
1167                                  "_Platform_destroy",
1168                                  status,
1169                                  "OMAP5430PROC_delete failed!");
1170 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1171         }
1172     }
1174     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId ("CORE1"));
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                              "OMAP5430PROC_destroy failed!");
1184 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1185     }
1186 #endif
1188     /* ------------------------- ipu0 cleanup ------------------------------- */
1189     handle = &Platform_objects [MultiProc_getId ("CORE0")];
1190     if (handle->pmHandle != NULL) {
1191         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1192         GT_assert (curTrace, (tmpStatus >= 0));
1193         if ((status >= 0) && (tmpStatus < 0)) {
1194             status = tmpStatus;
1195 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1196             GT_setFailureReason (curTrace,
1197                                  GT_4CLASS,
1198                                  "_Platform_destroy",
1199                                  status,
1200                                  "ProcMgr_delete failed!");
1201 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1202         }
1203     }
1205     /* Delete the Processor, Loader and PwrMgr instances */
1207     if (handle->sHandles.ipu0.ldrHandle != NULL) {
1208         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu0.ldrHandle);
1209         GT_assert (curTrace, (tmpStatus >= 0));
1210         if ((status >= 0) && (tmpStatus < 0)) {
1211             status = tmpStatus;
1212 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1213             GT_setFailureReason (curTrace,
1214                                  GT_4CLASS,
1215                                  "_Platform_destroy",
1216                                  status,
1217                                  "Failed to delete loader instance!");
1218 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1219         }
1220     }
1222     if (handle->sHandles.ipu0.pHandle != NULL) {
1223         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.ipu0.pHandle);
1224         GT_assert (curTrace, (tmpStatus >= 0));
1225         if ((status >= 0) && (tmpStatus < 0)) {
1226             status = tmpStatus;
1227 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1228             GT_setFailureReason (curTrace,
1229                                  GT_4CLASS,
1230                                  "_Platform_destroy",
1231                                  status,
1232                                  "OMAP5430PROC_delete failed!");
1233 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1234         }
1235     }
1237     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId ("CORE0"));
1238     GT_assert (curTrace, (tmpStatus >= 0));
1239     if ((status >= 0) && (tmpStatus < 0)) {
1240         status = tmpStatus;
1241 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1242         GT_setFailureReason (curTrace,
1243                              GT_4CLASS,
1244                              "_Platform_destroy",
1245                              status,
1246                              "OMAP5430PROC_destroy failed!");
1247 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1248     }
1250     /* ------------------------- dsp cleanup ------------------------------- */
1251     handle = &Platform_objects [MultiProc_getId ("DSP")];
1252     if (handle->pmHandle != NULL) {
1253         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1254         GT_assert (curTrace, (tmpStatus >= 0));
1255         if ((status >= 0) && (tmpStatus < 0)) {
1256             status = tmpStatus;
1257 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1258             GT_setFailureReason (curTrace,
1259                                  GT_4CLASS,
1260                                  "_Platform_destroy",
1261                                  status,
1262                                  "ProcMgr_delete failed!");
1263 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1264         }
1265     }
1267     /* Delete the Processor, Loader and PwrMgr instances */
1269     if (handle->sHandles.dsp.ldrHandle != NULL) {
1270         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1271         GT_assert (curTrace, (tmpStatus >= 0));
1272         if ((status >= 0) && (tmpStatus < 0)) {
1273             status = tmpStatus;
1274 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1275             GT_setFailureReason (curTrace,
1276                                  GT_4CLASS,
1277                                  "_Platform_destroy",
1278                                  status,
1279                                  "Failed to delete loader instance!");
1280 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1281         }
1282     }
1284     if (handle->sHandles.dsp.pHandle != NULL) {
1285         tmpStatus = OMAP5430BENELLIPROC_delete (&handle->sHandles.dsp.pHandle);
1286         GT_assert (curTrace, (tmpStatus >= 0));
1287         if ((status >= 0) && (tmpStatus < 0)) {
1288             status = tmpStatus;
1289 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1290             GT_setFailureReason (curTrace,
1291                                  GT_4CLASS,
1292                                  "_Platform_destroy",
1293                                  status,
1294                                  "OMAP5430PROC_delete failed!");
1295 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1296         }
1297     }
1299     tmpStatus = OMAP5430BENELLIPROC_destroy (MultiProc_getId ("DSP"));
1300     GT_assert (curTrace, (tmpStatus >= 0));
1301     if ((status >= 0) && (tmpStatus < 0)) {
1302         status = tmpStatus;
1303 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1304         GT_setFailureReason (curTrace,
1305                              GT_4CLASS,
1306                              "_Platform_destroy",
1307                              status,
1308                              "OMAP5430PROC_destroy failed!");
1309 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1310     }
1312     GT_1trace (curTrace, GT_LEAVE, "_Platform_destroy", status);
1314     /*! @retval Platform_S_SUCCESS operation was successful */
1315     return status;
1319 #if defined (__cplusplus)
1321 #endif /* defined (__cplusplus) */