Support a seperate address translation table for DSP2
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / vayu / Platform.c
1 /*
2  *  @file   Platform.c
3  *
4  *  @brief      Implementation of Platform initialization logic.
5  *
6  *
7  *  ============================================================================
8  *
9  *  Copyright (c) 2013-2015, Texas Instruments Incorporated
10  *
11  *  Redistribution and use in source and binary forms, with or without
12  *  modification, are permitted provided that the following conditions
13  *  are met:
14  *
15  *  *  Redistributions of source code must retain the above copyright
16  *     notice, this list of conditions and the following disclaimer.
17  *
18  *  *  Redistributions in binary form must reproduce the above copyright
19  *     notice, this list of conditions and the following disclaimer in the
20  *     documentation and/or other materials provided with the distribution.
21  *
22  *  *  Neither the name of Texas Instruments Incorporated nor the names of
23  *     its contributors may be used to endorse or promote products derived
24  *     from this software without specific prior written permission.
25  *
26  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *  Contact information for paper mail:
38  *  Texas Instruments
39  *  Post Office Box 655303
40  *  Dallas, Texas 75265
41  *  Contact information:
42  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
43  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
44  *  ============================================================================
45  *
46  */
49 /* Standard header files */
50 #include <ti/syslink/Std.h>
52 /* Utilities & Osal headers */
53 #include <ti/syslink/utils/Gate.h>
54 #include <ti/syslink/utils/GateMutex.h>
55 #include <ti/syslink/utils/Memory.h>
56 #include <ti/syslink/utils/Trace.h>
57 #include <ti/ipc/MultiProc.h>
58 #include <ti/syslink/utils/OsalPrint.h>
59 #include <ti/syslink/inc/knl/OsalThread.h>
60 #include <ti/syslink/utils/String.h>
61 #include <ti/syslink/utils/Cfg.h>
63 /* Ipc device specific headers */
64 #include <VAYUIpcInt.h>
65 #include <VAYUDspPwr.h>
66 #include <VAYUDspProc.h>
67 #include <VAYUIpuCore0Proc.h>
68 #include <VAYUIpuPwr.h>
70 /* Module level headers */
71 #include <_MessageQCopy.h>
72 #include <ti/ipc/MessageQCopy.h>
73 #include <_MessageQCopyDefs.h>
75 #include <ti/syslink/ProcMgr.h>
76 #include <_ProcMgr.h>
77 #include <ti/syslink/inc/knl/Platform.h>
78 #include <ElfLoader.h>
80 #include <ti/ipc/Ipc.h>
81 #include <_Ipc.h>
82 #include <_MultiProc.h>
83 #include <IpcKnl.h>
84 #include <sys/mman.h>
85 #include <GateHWSpinlock.h>
86 #include <gptimers.h>
88 #if defined (__cplusplus)
89 extern "C" {
90 #endif
93 /** ============================================================================
94  *  Macros.
95  *  ============================================================================
96  */
97 /* Hardware spinlocks info */
98 #define HWSPINLOCK_BASE             0x4A0F6000
99 #define HWSPINLOCK_SIZE             0x1000
100 #define HWSPINLOCK_OFFSET           0x800
102 /** ============================================================================
103  *  Application specific configuration, please change these value according to
104  *  your application's need.
105  *  ============================================================================
106  */
107 /*!
108  *  @brief  Structure defining config parameters for overall System.
109  */
110 typedef struct Platform_Config {
111     MultiProc_Config                multiProcConfig;
112     /*!< Multiproc config parameter */
114     MessageQCopy_Config             MQCopyConfig;
115     /*!< MessageQCopy config parameter */
117     ProcMgr_Config                  procMgrConfig;
118     /*!< Processor manager config parameter */
120     ElfLoader_Config                elfLoaderConfig;
121     /*!< Elf loader config parameter */
123     GateHWSpinlock_Config           gateHWSpinlockConfig;
124     /*!< GateHWSpinlock config parameter */
125 } Platform_Config;
127 /*! @brief structure for platform instance */
128 typedef struct Platform_Object {
129     /*!< Flag to indicate platform initialization status */
130     ProcMgr_Handle                pmHandle;
131     /*!< Handle to the ProcMgr instance used */
132     union {
133         struct {
134             VAYUDSPPROC_Handle pHandle;
135             /*!< Handle to the Processor instance used */
136             VAYUDSPPWR_Handle  pwrHandle;
137             /*!< Handle to the PwrMgr instance used */
138             ElfLoader_Handle   ldrHandle;
139             /*!< Handle to the Loader instance used */
140         } dsp;
141         struct {
142             VAYUIPUCORE0PROC_Handle pHandle;
143             /*!< Handle to the Processor instance used */
144             VAYUIPUPWR_Handle       pwrHandle;
145             /*!< Handle to the PwrMgr instance used */
146             ElfLoader_Handle        ldrHandle;
147             /*!< Handle to the Loader instance used */
148         } ipu;
149     } sHandles;
150     /*!< Slave specific handles */
151 } Platform_Object, *Platform_Handle;
154 /*! @brief structure for platform instance */
155 typedef struct Platform_Module_State {
156     Bool              multiProcInitFlag;
157     /*!< MultiProc Initialize flag */
158     Bool              messageQCopyInitFlag;
159     /*!< MessageQCopy Initialize flag */
160     Bool              procMgrInitFlag;
161     /*!< Processor manager Initialize flag */
162     Bool              elfLoaderInitFlag;
163     /*!< Elf loader Initialize flag */
164     Bool              ipcIntInitFlag;
165     /*!< IpcInt Initialize flag */
166     Bool              platformInitFlag;
167     /*!< Flag to indicate platform initialization status */
168     Bool              gateHWSpinlockInitFlag;
169     /*!< GateHWSpinlock Initialize flag */
170     Ptr               gateHWSpinlockVAddr;
171     /*!< GateHWSpinlock Virtual Address */
172 } Platform_Module_State;
175 /* =============================================================================
176  * GLOBALS
177  * =============================================================================
178  */
179 static Platform_Object Platform_objects [MultiProc_MAXPROCESSORS];
180 static Platform_Module_State Platform_Module_state;
181 static Platform_Module_State * Platform_module = &Platform_Module_state;
183 Int32 _Platform_setup  (Ipc_Config * cfg);
184 Int32 _Platform_destroy (void);
187 /** ============================================================================
188  *  APIs.
189  *  ============================================================================
190  */
191 /* Function to read slave memory */
192 Int32
193 _Platform_readSlaveMemory (UInt16   procId,
194                            UInt32   addr,
195                            Ptr      value,
196                            UInt32 * numBytes);
198 /* Function to write slave memory */
199 Int32
200 _Platform_writeSlaveMemory (UInt16   procId,
201                             UInt32   addr,
202                             Ptr      value,
203                             UInt32 * numBytes);
204 /*!
205  *  @brief      Function to get the default values for configurations.
206  *
207  *  @param      config   Configuration values.
208  */
209 Void
210 Platform_getConfig (Platform_Config * config)
212     GT_1trace (curTrace, GT_ENTER, "Platform_getConfig", config);
214     GT_assert (curTrace, (config != NULL));
216 #if !defined(IPC_BUILD_OPTIMIZE)
217     if (config == NULL) {
218         GT_setFailureReason (curTrace,
219                              GT_4CLASS,
220                              "Platform_getConfig",
221                              Platform_E_INVALIDARG,
222                              "Argument of type (Platform_getConfig *) passed "
223                              "is null!");
224     }
225     else {
226 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
228         /* Get the gatepeterson default config */
229         MultiProc_getConfig (&config->multiProcConfig);
231         /* Get the PROCMGR default config */
232         ProcMgr_getConfig (&config->procMgrConfig);
234         /* Get the ElfLoader default config */
235         ElfLoader_getConfig (&config->elfLoaderConfig);
237         /* Get the HWSpinlock default config */
238         GateHWSpinlock_getConfig (&config->gateHWSpinlockConfig);
239 #if !defined(IPC_BUILD_OPTIMIZE)
240     }
241 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
243     GT_0trace (curTrace, GT_LEAVE, "Platform_getConfig");
246 /*!
247  *  @brief      Function to override the default configuration values.
248  *
249  *  @param      config   Configuration values.
250  */
251 Int32
252 Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
254     Int32  status = Platform_S_SUCCESS;
256     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", config);
258     GT_assert (curTrace, (config != NULL));
260 #if !defined(IPC_BUILD_OPTIMIZE)
261     if (config == NULL) {
262         /*! @retval Platform_E_INVALIDARG Argument of type
263          *  (Platform_Config *) passed is null*/
264         status = Platform_E_INVALIDARG;
265         GT_setFailureReason (curTrace,
266                              GT_4CLASS,
267                              "Platform_overrideConfig",
268                              status,
269                              "Argument of type (Platform_getConfig *) passed "
270                              "is null!");
271     }
272     else {
273 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
275         /* Set the MultiProc config as defined in SystemCfg.c */
276         config->multiProcConfig = _MultiProc_cfg;
278         /* Override the MESSAGEQCOPY default config */
279         config->MQCopyConfig.intId[1] = 173; // 141 + 32
280         config->MQCopyConfig.intId[2] = 168; // 136 + 32
281         config->MQCopyConfig.intId[3] = 173; // 141 + 32
282         config->MQCopyConfig.intId[4] = 168; // 136 + 32
284 #if !defined(IPC_BUILD_OPTIMIZE)
285     }
286 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
288     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", status);
290     /*! @retval Platform_S_SUCCESS operation was successful */
291     return status;
294 /*!
295  *  @brief      Function to setup platform.
296  *              TBD: logic would change completely in the final system.
297  */
298 Int32
299 Platform_setup (Ipc_Config * cfg)
301     Int32             status = Platform_S_SUCCESS;
302     Platform_Config   _config;
303     Platform_Config * config;
304     VAYUIpcInt_Config VAYUcfg;
305     Memory_MapInfo    minfo;
307     Platform_getConfig (&_config);
308     config = &_config;
310     Platform_overrideConfig (config, cfg);
312     status = MultiProc_setup (&(config->multiProcConfig));
314 #if !defined(IPC_BUILD_OPTIMIZE)
315     if (status < 0) {
316         GT_setFailureReason (curTrace,
317                              GT_4CLASS,
318                              "Platform_setup",
319                              status,
320                              "MultiProc_setup failed!");
321     }
322     else {
323 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
324             Platform_module->multiProcInitFlag = TRUE;
325 #if !defined(IPC_BUILD_OPTIMIZE)
326     }
327 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
329 /* Initialize PROCMGR */
330     if (status >= 0) {
331         status = ProcMgr_setup (&(config->procMgrConfig));
332 #if !defined(IPC_BUILD_OPTIMIZE)
333         if (status < 0) {
334             GT_setFailureReason (curTrace,
335                                  GT_4CLASS,
336                                  "Platform_setup",
337                                  status,
338                                  "ProcMgr_setup failed!");
339         }
340         else {
341 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
342             Platform_module->procMgrInitFlag = TRUE;
343 #if !defined(IPC_BUILD_OPTIMIZE)
344         }
345 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
346     }
348     /* Initialize IpcInt required for VirtQueue/MessageQCopy. */
349     if (status >= 0) {
350         /* Do the IPC interrupts setup for the full platform (cfg is not used) */
351         VAYUIpcInt_setup (&VAYUcfg);
352         Platform_module->ipcIntInitFlag = TRUE;
353     }
356 /* Intialize MESSAGEQCOPY */
357     if (status >= 0) {
358         status = MessageQCopy_setup (&config->MQCopyConfig);
359 #if !defined(IPC_BUILD_OPTIMIZE)
360         if (status < 0) {
361             GT_setFailureReason (curTrace,
362                                  GT_4CLASS,
363                                  "Platform_setup",
364                                  status,
365                                  "MessageQCopy_setup failed!");
366         }
367         else {
368 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
369             Platform_module->messageQCopyInitFlag = TRUE;
370 #if !defined(IPC_BUILD_OPTIMIZE)
371         }
372 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
373     }
375 /* Intialize Elf loader */
376     if (status >= 0) {
377         status = ElfLoader_setup (&config->elfLoaderConfig);
378 #if !defined(IPC_BUILD_OPTIMIZE)
379         if (status < 0) {
380             GT_setFailureReason (curTrace,
381                                  GT_4CLASS,
382                                  "Platform_setup",
383                                  status,
384                                  "ElfLoader_setup failed!");
385         }
386         else {
387 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
388             Platform_module->elfLoaderInitFlag = TRUE;
389 #if !defined(IPC_BUILD_OPTIMIZE)
390         }
391 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
392     }
394     if (status >= 0) {
395         Memory_set (Platform_objects,
396                     0,
397                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
398     }
400     if (status >= 0) {
401         status = _Platform_setup (cfg);
402 #if !defined(IPC_BUILD_OPTIMIZE)
403         if (status < 0) {
404             GT_setFailureReason (curTrace,
405                                  GT_4CLASS,
406                                  "Platform_setup",
407                                  status,
408                                  "_Platform_setup failed!");
409         }
410         else {
411 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
412             Platform_module->platformInitFlag = TRUE;
413 #if !defined(IPC_BUILD_OPTIMIZE)
414         }
415 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
416     }
417     if (status >= 0) {
418         minfo.src  = HWSPINLOCK_BASE;
419         minfo.size = HWSPINLOCK_SIZE;
420         minfo.isCached = FALSE;
421         status = Memory_map (&minfo);
422         if (status < 0) {
423            GT_setFailureReason (curTrace,
424                                 GT_4CLASS,
425                                 "Platform_setup",
426                                 status,
427                                 "Memory_map failed!");
428         }
429         else {
430             Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
431             config->gateHWSpinlockConfig.numLocks = 32;
432             config->gateHWSpinlockConfig.baseAddr = minfo.dst  + HWSPINLOCK_OFFSET;
433             status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
434 #if !defined(IPC_BUILD_OPTIMIZE)
435             if (status < 0) {
436                 GT_setFailureReason (curTrace,
437                                      GT_4CLASS,
438                                      "Platform_setup",
439                                      status,
440                                      "GateHWSpinlock_setup failed!");
441             }
442             else {
443 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
444                 status = GateHWSpinlock_start();
445                 if (status < 0) {
446                     GT_setFailureReason (curTrace,
447                                      GT_4CLASS,
448                                      "Platform_setup",
449                                      status,
450                                      "GateHWSpinlock_start failed!");
451                 }
452                 else {
453                     Platform_module->gateHWSpinlockInitFlag = TRUE;
454                 }
455 #if !defined(IPC_BUILD_OPTIMIZE)
456             }
457 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
458         }
459     }
461     /* Enable GP timers */
462     if (status >= 0) {
463         status = gpt_setup();
464         if (status < 0) {
465             GT_setFailureReason(curTrace, GT_4CLASS, "Platform_setup",
466                     status, "gpt_setup failed!");
467         }
468     }
470     if (status < 0) {
471         Platform_destroy();
472     }
473     return status;
477 /*!
478  *  @brief      Function to destroy the System.
479  *
480  *  @sa         Platform_setup
481  */
482 Int32
483 Platform_destroy (void)
485     Int32  status = Platform_S_SUCCESS;
486     Memory_UnmapInfo minfo;
488     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
490     /* Finalize Platform-specific destroy */
491     if (Platform_module->platformInitFlag == TRUE) {
492         status = _Platform_destroy ();
493 #if !defined(IPC_BUILD_OPTIMIZE)
494         if (status < 0) {
495             GT_setFailureReason (curTrace,
496                                  GT_4CLASS,
497                                  "Platform_destroy",
498                                  status,
499                                  "Platform_destroy failed!");
500         }
501         else {
502 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
503             Platform_module->platformInitFlag = FALSE;
504 #if !defined(IPC_BUILD_OPTIMIZE)
505         }
506 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
507     }
509     /* disable GP timers */
510     gpt_destroy();
512     /* Finalize elf loader */
513     if (Platform_module->elfLoaderInitFlag == TRUE) {
514         status = ElfLoader_destroy ();
515 #if !defined(IPC_BUILD_OPTIMIZE)
516         if (status < 0) {
517             GT_setFailureReason (curTrace,
518                                  GT_4CLASS,
519                                  "Platform_destroy",
520                                  status,
521                                  "ElfLoader_destroy failed!");
522         }
523         else {
524 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
525             Platform_module->elfLoaderInitFlag = FALSE;
526 #if !defined(IPC_BUILD_OPTIMIZE)
527         }
528 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
529     }
531     /* Finalize MESSAGEQCOPY */
532     if (Platform_module->messageQCopyInitFlag == TRUE) {
533         status = MessageQCopy_destroy ();
534 #if !defined(IPC_BUILD_OPTIMIZE)
535         if (status < 0) {
536             GT_setFailureReason (curTrace,
537                                  GT_4CLASS,
538                                  "Platform_destroy",
539                                  status,
540                                  "MessageQCopy_destroy failed!");
541         }
542         else {
543 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
544             Platform_module->messageQCopyInitFlag = FALSE;
545 #if !defined(IPC_BUILD_OPTIMIZE)
546         }
547 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
548     }
551     if (Platform_module->ipcIntInitFlag == TRUE) {
552         VAYUIpcInt_destroy ();
553         Platform_module->ipcIntInitFlag = FALSE;
554     }
556     /* Finalize PROCMGR */
557     if (Platform_module->procMgrInitFlag == TRUE) {
558         status = ProcMgr_destroy ();
559 #if !defined(IPC_BUILD_OPTIMIZE)
560         if (status < 0) {
561             GT_setFailureReason (curTrace,
562                                  GT_4CLASS,
563                                  "Platform_destroy",
564                                  status,
565                                  "ProcMgr_destroy failed!");
566         }
567         else {
568 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
569             Platform_module->procMgrInitFlag = FALSE;
570 #if !defined(IPC_BUILD_OPTIMIZE)
571         }
572 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
573     }
575     /* Finalize MultiProc */
576     if (Platform_module->multiProcInitFlag == TRUE) {
577         status = MultiProc_destroy ();
578 #if !defined(IPC_BUILD_OPTIMIZE)
579     if (status < 0) {
580         GT_setFailureReason (curTrace,
581                              GT_4CLASS,
582                              "Platform_destroy",
583                              status,
584                              "MultiProc_destroy failed!");
585     }
586         else {
587 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
588             Platform_module->multiProcInitFlag = FALSE;
589 #if !defined(IPC_BUILD_OPTIMIZE)
590         }
591 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
592     }
594     if (status >= 0) {
595         Memory_set (Platform_objects,
596                     0,
597                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
598     }
600     if (Platform_module->gateHWSpinlockInitFlag == TRUE) {
601         status = GateHWSpinlock_stop();
602         if (status < 0) {
603             GT_setFailureReason (curTrace,
604                                  GT_4CLASS,
605                                  "Platform_destroy",
606                                  status,
607                                  "GateHWSpinlock_stop failed!");
608         }
609         else {
610             status = GateHWSpinlock_destroy();
611 #if !defined(IPC_BUILD_OPTIMIZE)
612             if (status < 0) {
613                 GT_setFailureReason (curTrace,
614                                  GT_4CLASS,
615                                  "Platform_destroy",
616                                  status,
617                                  "GateHWSpinlock_destroy failed!");
618             }
619             else {
620 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
621                 Platform_module->gateHWSpinlockInitFlag = FALSE;
622             }
623 #if !defined(IPC_BUILD_OPTIMIZE)
624         }
625 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
626     }
628     if (Platform_module->gateHWSpinlockVAddr) {
629         minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
630         minfo.size = HWSPINLOCK_SIZE;
631         minfo.isCached = FALSE;
632         status = Memory_unmap(&minfo);
633 #if !defined(IPC_BUILD_OPTIMIZE)
634         if (status < 0) {
635             GT_setFailureReason (curTrace,
636                                  GT_4CLASS,
637                                  "Platform_destroy",
638                                  status,
639                                  "Memory_unmap failed!");
640         }
641 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
642         Platform_module->gateHWSpinlockVAddr = NULL;
643     }
645     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
647     /*! @retval Platform_S_SUCCESS Operation successful */
648     return status;
651 /*
652  * union _Platform_setup_Local exists so that we don't waste stack or
653  * alloc'ed memory on storage for things that exist for just a few
654  * statements of the function _Platform_setup().  The *PROC_Params
655  * elements are large and variably sized, depending on the macro
656  * ProcMgr_MAX_MEMORY_REGIONS.
657  */
658 typedef union _Platform_setup_Local {
659     ProcMgr_Params          params;
660     VAYUDSPPROC_Config      dspProcConfig;
661     VAYUIPUCORE0PROC_Config ipuProcConfig;
662     VAYUDSPPWR_Config       dspPwrConfig;
663     VAYUIPUPWR_Config       ipuPwrConfig;
664     VAYUDSPPROC_Params      dspProcParams;
665     VAYUIPUCORE0PROC_Params ipuProcParams;
666     VAYUDSPPWR_Params       dspPwrParams;
667     VAYUIPUPWR_Params       ipuPwrParams;
668     ElfLoader_Params        elfLoaderParams;
669 } _Platform_setup_Local;
672 /*!
673  *  @brief      Function to setup platform.
674  *              TBD: logic would change completely in the final system.
675  */
676 Int32
677 _Platform_setup (Ipc_Config * cfg)
679     Int32                   status = Platform_S_SUCCESS;
680     _Platform_setup_Local   *lv;
681     UInt16                  procId;
682     Platform_Handle         handle;
684     GT_0trace (curTrace, GT_ENTER, "_Platform_setup");
686     lv = Memory_alloc(NULL, sizeof(_Platform_setup_Local), 0, NULL);
687     if (lv == NULL) {
688         status = Platform_E_FAIL;
689         GT_setFailureReason (curTrace,
690                                 GT_4CLASS,
691                                 "_Platform_setup",
692                                 status,
693                                 "Memory_alloc failed");
694         goto ret;
695     }
696     if (status >= 0) {
697         /* Get MultiProc ID by name. */
698         procId = MultiProc_getId ("IPU1");
700         handle = &Platform_objects [procId];
701         VAYUIPUCORE0PROC_getConfig (&lv->ipuProcConfig);
702         status = VAYUIPUCORE0PROC_setup (&lv->ipuProcConfig);
703         if (status < 0) {
704             GT_setFailureReason (curTrace,
705                                  GT_4CLASS,
706                                  "_Platform_setup",
707                                  status,
708                                  "VAYUIPUCORE0PROC_setup failed!");
709         }
710         else {
711             VAYUIPUPWR_getConfig (&lv->ipuPwrConfig);
712             status = VAYUIPUPWR_setup (&lv->ipuPwrConfig);
713             if (status < 0) {
714                 GT_setFailureReason (curTrace,
715                                      GT_4CLASS,
716                                      "_Platform_setup",
717                                      status,
718                                      "VAYUIPUPWR_setup failed!");
719             }
720         }
722         if (status >= 0) {
723             /* Create an instance of the Processor object for
724              * VAYUIPUCORE0 */
725             VAYUIPUCORE0PROC_Params_init (NULL, &lv->ipuProcParams);
726             handle->sHandles.ipu.pHandle = VAYUIPUCORE0PROC_create (procId,
727                                                          &lv->ipuProcParams);
729             /* Create an instance of the ELF Loader object */
730             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
731             handle->sHandles.ipu.ldrHandle = ElfLoader_create (procId,
732                                                         &lv->elfLoaderParams);
734             /* Create an instance of the PwrMgr object for VAYUIPUCORE0 */
735             VAYUIPUPWR_Params_init (&lv->ipuPwrParams);
736             handle->sHandles.ipu.pwrHandle = VAYUIPUPWR_create (
737                                                            procId,
738                                                            &lv->ipuPwrParams);
740             if (handle->sHandles.ipu.pHandle == NULL) {
741                 status = Platform_E_FAIL;
742                 GT_setFailureReason (curTrace,
743                                      GT_4CLASS,
744                                      "_Platform_setup",
745                                      status,
746                                      "VAYUIPUCORE0PROC_create failed!");
747             }
748             else if (handle->sHandles.ipu.ldrHandle ==  NULL) {
749                 status = Platform_E_FAIL;
750                 GT_setFailureReason (curTrace,
751                                      GT_4CLASS,
752                                      "_Platform_setup",
753                                      status,
754                                      "Failed to create loader instance!");
755             }
756             else if (handle->sHandles.ipu.pwrHandle ==  NULL) {
757                 status = Platform_E_FAIL;
758                 GT_setFailureReason (curTrace,
759                                      GT_4CLASS,
760                                      "_Platform_setup",
761                                      status,
762                                      "VAYUIPUPWR_create failed!");
763             }
764             else {
765                 /* Initialize parameters */
766                 ProcMgr_Params_init (NULL, &lv->params);
767                 lv->params.procHandle = handle->sHandles.ipu.pHandle;
768                 lv->params.loaderHandle = handle->sHandles.ipu.ldrHandle;
769                 lv->params.pwrHandle = handle->sHandles.ipu.pwrHandle;
770                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
771                 if (handle->pmHandle == NULL) {
772                     status = Platform_E_FAIL;
773                     GT_setFailureReason (curTrace,
774                                          GT_4CLASS,
775                                          "_Platform_setup",
776                                          status,
777                                          "ProcMgr_create failed!");
778                 }
779             }
780         }
781     }
783     if (status >= 0) {
784         /* Get MultiProc ID by name. */
785         procId = MultiProc_getId ("IPU2");
787         handle = &Platform_objects [procId];
789         if (status >= 0) {
790             /* Create an instance of the Processor object for
791              * VAYUIPUCORE0 */
792             VAYUIPUCORE0PROC_Params_init (NULL, &lv->ipuProcParams);
793             handle->sHandles.ipu.pHandle = VAYUIPUCORE0PROC_create (procId,
794                                                          &lv->ipuProcParams);
796             /* Create an instance of the ELF Loader object */
797             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
798             handle->sHandles.ipu.ldrHandle = ElfLoader_create (procId,
799                                                         &lv->elfLoaderParams);
801             /* Create an instance of the PwrMgr object for VAYUIPUCORE0 */
802             VAYUIPUPWR_Params_init (&lv->ipuPwrParams);
803             handle->sHandles.ipu.pwrHandle = VAYUIPUPWR_create (
804                                                            procId,
805                                                            &lv->ipuPwrParams);
807             if (handle->sHandles.ipu.pHandle == NULL) {
808                 status = Platform_E_FAIL;
809                 GT_setFailureReason (curTrace,
810                                      GT_4CLASS,
811                                      "_Platform_setup",
812                                      status,
813                                      "VAYUIPUCORE0PROC_create failed!");
814             }
815             else if (handle->sHandles.ipu.ldrHandle ==  NULL) {
816                 status = Platform_E_FAIL;
817                 GT_setFailureReason (curTrace,
818                                      GT_4CLASS,
819                                      "_Platform_setup",
820                                      status,
821                                      "Failed to create loader instance!");
822             }
823             else if (handle->sHandles.ipu.pwrHandle ==  NULL) {
824                 status = Platform_E_FAIL;
825                 GT_setFailureReason (curTrace,
826                                      GT_4CLASS,
827                                      "_Platform_setup",
828                                      status,
829                                      "VAYUIPUPWR_create failed!");
830             }
831             else {
832                 /* Initialize parameters */
833                 ProcMgr_Params_init (NULL, &lv->params);
834                 lv->params.procHandle = handle->sHandles.ipu.pHandle;
835                 lv->params.loaderHandle = handle->sHandles.ipu.ldrHandle;
836                 lv->params.pwrHandle = handle->sHandles.ipu.pwrHandle;
837                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
838                 if (handle->pmHandle == NULL) {
839                     status = Platform_E_FAIL;
840                     GT_setFailureReason (curTrace,
841                                          GT_4CLASS,
842                                          "_Platform_setup",
843                                          status,
844                                          "ProcMgr_create failed!");
845                 }
846             }
847         }
848     }
850     if (status >= 0) {
851         /* Get MultiProc ID by name. */
852         procId = MultiProc_getId ("DSP1");
854         handle = &Platform_objects [procId];
855         VAYUDSPPROC_getConfig (&lv->dspProcConfig);
856         status = VAYUDSPPROC_setup (&lv->dspProcConfig);
857         if (status < 0) {
858             GT_setFailureReason (curTrace,
859                                  GT_4CLASS,
860                                  "_Platform_setup",
861                                  status,
862                                  "VAYUDSPPROC_setup failed!");
863         }
864         else {
865             VAYUDSPPWR_getConfig (&lv->dspPwrConfig);
866             status = VAYUDSPPWR_setup (&lv->dspPwrConfig);
867             if (status < 0) {
868                 GT_setFailureReason (curTrace,
869                                      GT_4CLASS,
870                                      "_Platform_setup",
871                                      status,
872                                      "VAYUDSPPWR_setup failed!");
873             }
874         }
876         if (status >= 0) {
877             /* Create an instance of the Processor object for
878              * VAYUDSP */
879             VAYUDSPPROC_Params_init (NULL, &lv->dspProcParams);
880             handle->sHandles.dsp.pHandle = VAYUDSPPROC_create (procId,
881                                                               &lv->dspProcParams);
883             /* Create an instance of the ELF Loader object */
884             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
885             handle->sHandles.dsp.ldrHandle =
886                                            ElfLoader_create (procId,
887                                                              &lv->elfLoaderParams);
888             /* Create an instance of the PwrMgr object for VAYUDSP */
889             VAYUDSPPWR_Params_init (&lv->dspPwrParams);
890             handle->sHandles.dsp.pwrHandle = VAYUDSPPWR_create (procId,
891                                                     &lv->dspPwrParams);
893             if (handle->sHandles.dsp.pHandle == NULL) {
894                 status = Platform_E_FAIL;
895                 GT_setFailureReason (curTrace,
896                                      GT_4CLASS,
897                                      "_Platform_setup",
898                                      status,
899                                      "VAYUDSPPROC_create failed!");
900             }
901             else if (handle->sHandles.dsp.ldrHandle ==  NULL) {
902                 status = Platform_E_FAIL;
903                 GT_setFailureReason (curTrace,
904                                      GT_4CLASS,
905                                      "_Platform_setup",
906                                      status,
907                                      "Failed to create loader instance!");
908             }
909             else if (handle->sHandles.dsp.pwrHandle ==  NULL) {
910                 status = Platform_E_FAIL;
911                 GT_setFailureReason (curTrace,
912                                      GT_4CLASS,
913                                      "_Platform_setup",
914                                      status,
915                                      "VAYUDSPPWR_create failed!");
916             }
917             else {
918                 /* Initialize parameters */
919                 ProcMgr_Params_init (NULL, &lv->params);
920                 lv->params.procHandle = handle->sHandles.dsp.pHandle;
921                 lv->params.loaderHandle = handle->sHandles.dsp.ldrHandle;
922                 lv->params.pwrHandle = handle->sHandles.dsp.pwrHandle;
923                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
924                 if (handle->pmHandle == NULL) {
925                     status = Platform_E_FAIL;
926                     GT_setFailureReason (curTrace,
927                                          GT_4CLASS,
928                                          "_Platform_setup",
929                                          status,
930                                          "ProcMgr_create failed!");
931                 }
932             }
933         }
934     }
936     if (status >= 0) {
937         /* Get MultiProc ID by name. */
938         procId = MultiProc_getId ("DSP2");
940         handle = &Platform_objects [procId];
942         if (status >= 0) {
943             /* Create an instance of the Processor object for
944              * VAYUDSP */
945             VAYUDSPPROC_Params_init (NULL, &lv->dspProcParams);
946             handle->sHandles.dsp.pHandle = VAYUDSPPROC_create (procId,
947                                                               &lv->dspProcParams);
949             /* Create an instance of the ELF Loader object */
950             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
951             handle->sHandles.dsp.ldrHandle =
952                                            ElfLoader_create (procId,
953                                                              &lv->elfLoaderParams);
954             /* Create an instance of the PwrMgr object for VAYUDSP */
955             VAYUDSPPWR_Params_init (&lv->dspPwrParams);
956             handle->sHandles.dsp.pwrHandle = VAYUDSPPWR_create (procId,
957                                                     &lv->dspPwrParams);
959             if (handle->sHandles.dsp.pHandle == NULL) {
960                 status = Platform_E_FAIL;
961                 GT_setFailureReason (curTrace,
962                                      GT_4CLASS,
963                                      "_Platform_setup",
964                                      status,
965                                      "VAYUDSPPROC_create failed!");
966             }
967             else if (handle->sHandles.dsp.ldrHandle ==  NULL) {
968                 status = Platform_E_FAIL;
969                 GT_setFailureReason (curTrace,
970                                      GT_4CLASS,
971                                      "_Platform_setup",
972                                      status,
973                                      "Failed to create loader instance!");
974             }
975             else if (handle->sHandles.dsp.pwrHandle ==  NULL) {
976                 status = Platform_E_FAIL;
977                 GT_setFailureReason (curTrace,
978                                      GT_4CLASS,
979                                      "_Platform_setup",
980                                      status,
981                                      "VAYUDSPPWR_create failed!");
982             }
983             else {
984                 /* Initialize parameters */
985                 ProcMgr_Params_init (NULL, &lv->params);
986                 lv->params.procHandle = handle->sHandles.dsp.pHandle;
987                 lv->params.loaderHandle = handle->sHandles.dsp.ldrHandle;
988                 lv->params.pwrHandle = handle->sHandles.dsp.pwrHandle;
989                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
990                 if (handle->pmHandle == NULL) {
991                     status = Platform_E_FAIL;
992                     GT_setFailureReason (curTrace,
993                                          GT_4CLASS,
994                                          "_Platform_setup",
995                                          status,
996                                          "ProcMgr_create failed!");
997                 }
998             }
999         }
1000     }
1002     Memory_free(NULL, lv, sizeof(_Platform_setup_Local));
1004 ret:
1005     GT_1trace (curTrace, GT_LEAVE, "_Platform_setup", status);
1007     /*! @retval Platform_S_SUCCESS operation was successful */
1008     return status;
1012 /*!
1013  *  @brief      Function to setup platform.
1014  *              TBD: logic would change completely in the final system.
1015  */
1016 Int32
1017 _Platform_destroy (void)
1019     Int32           status    = Platform_S_SUCCESS;
1020     Int32           tmpStatus = Platform_S_SUCCESS;
1021     Platform_Handle handle;
1023     GT_0trace (curTrace, GT_ENTER, "_Platform_destroy");
1025     /* ------------------------- DSP1 cleanup -------------------------------- */
1026     handle = &Platform_objects [MultiProc_getId ("DSP1")];
1027     if (handle->pmHandle != NULL) {
1028         status = ProcMgr_delete (&handle->pmHandle);
1029         GT_assert (curTrace, (status >= 0));
1030 #if !defined(IPC_BUILD_OPTIMIZE)
1031         if (status < 0) {
1032             GT_setFailureReason (curTrace,
1033                                  GT_4CLASS,
1034                                  "_Platform_destroy",
1035                                  status,
1036                                  "ProcMgr_delete failed!");
1037         }
1038 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1039     }
1041     /* Delete the Processor, Loader and PwrMgr instances */
1042     if (handle->sHandles.dsp.pwrHandle != NULL) {
1043         tmpStatus = VAYUDSPPWR_delete (&handle->sHandles.dsp.pwrHandle);
1044         GT_assert (curTrace, (tmpStatus >= 0));
1045         if ((status >= 0) && (tmpStatus < 0)) {
1046             status = tmpStatus;
1047 #if !defined(IPC_BUILD_OPTIMIZE)
1048             GT_setFailureReason (curTrace,
1049                                  GT_4CLASS,
1050                                  "_Platform_destroy",
1051                                  status,
1052                                  "VAYUDSPPWR_delete failed!");
1053 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1054         }
1055     }
1057     if (handle->sHandles.dsp.ldrHandle != NULL) {
1058         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1059         GT_assert (curTrace, (tmpStatus >= 0));
1060         if ((status >= 0) && (tmpStatus < 0)) {
1061             status = tmpStatus;
1062 #if !defined(IPC_BUILD_OPTIMIZE)
1063             GT_setFailureReason (curTrace,
1064                                  GT_4CLASS,
1065                                  "_Platform_destroy",
1066                                  status,
1067                                  "Failed to delete loader instance!");
1068 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1069         }
1070     }
1072     if (handle->sHandles.dsp.pHandle != NULL) {
1073         tmpStatus = VAYUDSPPROC_delete (&handle->sHandles.dsp.pHandle);
1074         GT_assert (curTrace, (tmpStatus >= 0));
1075         if ((status >= 0) && (tmpStatus < 0)) {
1076             status = tmpStatus;
1077 #if !defined(IPC_BUILD_OPTIMIZE)
1078             GT_setFailureReason (curTrace,
1079                                  GT_4CLASS,
1080                                  "_Platform_destroy",
1081                                  status,
1082                                  "VAYUDSPPROC_delete failed!");
1083 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1084         }
1085     }
1087     /* ------------------------- DSP2 cleanup -------------------------------- */
1088     handle = &Platform_objects [MultiProc_getId ("DSP2")];
1089     if (handle->pmHandle != NULL) {
1090         status = ProcMgr_delete (&handle->pmHandle);
1091         GT_assert (curTrace, (status >= 0));
1092 #if !defined(IPC_BUILD_OPTIMIZE)
1093         if (status < 0) {
1094             GT_setFailureReason (curTrace,
1095                                  GT_4CLASS,
1096                                  "_Platform_destroy",
1097                                  status,
1098                                  "ProcMgr_delete failed!");
1099         }
1100 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1101     }
1103     /* Delete the Processor, Loader and PwrMgr instances */
1104     if (handle->sHandles.dsp.pwrHandle != NULL) {
1105         tmpStatus = VAYUDSPPWR_delete (&handle->sHandles.dsp.pwrHandle);
1106         GT_assert (curTrace, (tmpStatus >= 0));
1107         if ((status >= 0) && (tmpStatus < 0)) {
1108             status = tmpStatus;
1109 #if !defined(IPC_BUILD_OPTIMIZE)
1110             GT_setFailureReason (curTrace,
1111                                  GT_4CLASS,
1112                                  "_Platform_destroy",
1113                                  status,
1114                                  "VAYUDSPPWR_delete failed!");
1115 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1116         }
1117     }
1119     if (handle->sHandles.dsp.ldrHandle != NULL) {
1120         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1121         GT_assert (curTrace, (tmpStatus >= 0));
1122         if ((status >= 0) && (tmpStatus < 0)) {
1123             status = tmpStatus;
1124 #if !defined(IPC_BUILD_OPTIMIZE)
1125             GT_setFailureReason (curTrace,
1126                                  GT_4CLASS,
1127                                  "_Platform_destroy",
1128                                  status,
1129                                  "Failed to delete loader instance!");
1130 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1131         }
1132     }
1134     if (handle->sHandles.dsp.pHandle != NULL) {
1135         tmpStatus = VAYUDSPPROC_delete (&handle->sHandles.dsp.pHandle);
1136         GT_assert (curTrace, (tmpStatus >= 0));
1137         if ((status >= 0) && (tmpStatus < 0)) {
1138             status = tmpStatus;
1139 #if !defined(IPC_BUILD_OPTIMIZE)
1140             GT_setFailureReason (curTrace,
1141                                  GT_4CLASS,
1142                                  "_Platform_destroy",
1143                                  status,
1144                                  "VAYUDSPPROC_delete failed!");
1145 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1146         }
1147     }
1149     tmpStatus = VAYUDSPPWR_destroy ();
1150     GT_assert (curTrace, (tmpStatus >= 0));
1151     if ((status >= 0) && (tmpStatus < 0)) {
1152         status = tmpStatus;
1153 #if !defined(IPC_BUILD_OPTIMIZE)
1154         GT_setFailureReason (curTrace,
1155                              GT_4CLASS,
1156                              "_Platform_destroy",
1157                              status,
1158                              "VAYUDSPPWR_destroy failed!");
1159 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1160     }
1162     tmpStatus = VAYUDSPPROC_destroy ();
1163     GT_assert (curTrace, (tmpStatus >= 0));
1164     if ((status >= 0) && (tmpStatus < 0)) {
1165         status = tmpStatus;
1166 #if !defined(IPC_BUILD_OPTIMIZE)
1167         GT_setFailureReason (curTrace,
1168                              GT_4CLASS,
1169                              "_Platform_destroy",
1170                              status,
1171                              "VAYUDSPPROC_destroy failed!");
1172 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1173     }
1175     /* ------------------------- IPU1 cleanup ------------------------------- */
1176     handle = &Platform_objects [MultiProc_getId ("IPU1")];
1177     if (handle->pmHandle != NULL) {
1178         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1179         GT_assert (curTrace, (tmpStatus >= 0));
1180         if ((status >= 0) && (tmpStatus < 0)) {
1181             status = tmpStatus;
1182 #if !defined(IPC_BUILD_OPTIMIZE)
1183             GT_setFailureReason (curTrace,
1184                                  GT_4CLASS,
1185                                  "_Platform_destroy",
1186                                  status,
1187                                  "ProcMgr_delete failed!");
1188 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1189         }
1190     }
1192     /* Delete the Processor, Loader and PwrMgr instances */
1193     if (handle->sHandles.ipu.pwrHandle != NULL) {
1194         tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
1195         GT_assert (curTrace, (tmpStatus >= 0));
1196         if ((status >= 0) && (tmpStatus < 0)) {
1197             status = tmpStatus;
1198 #if !defined(IPC_BUILD_OPTIMIZE)
1199             GT_setFailureReason (curTrace,
1200                                  GT_4CLASS,
1201                                  "_Platform_destroy",
1202                                  status,
1203                                  "VAYUIPUPWR_delete failed!");
1204 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1205         }
1206     }
1208     if (handle->sHandles.ipu.ldrHandle != NULL) {
1209         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
1210         GT_assert (curTrace, (tmpStatus >= 0));
1211         if ((status >= 0) && (tmpStatus < 0)) {
1212             status = tmpStatus;
1213 #if !defined(IPC_BUILD_OPTIMIZE)
1214             GT_setFailureReason (curTrace,
1215                                  GT_4CLASS,
1216                                  "_Platform_destroy",
1217                                  status,
1218                                  "Failed to delete loader instance!");
1219 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1220         }
1221     }
1223     if (handle->sHandles.ipu.pHandle != NULL) {
1224         tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
1225         GT_assert (curTrace, (tmpStatus >= 0));
1226         if ((status >= 0) && (tmpStatus < 0)) {
1227             status = tmpStatus;
1228 #if !defined(IPC_BUILD_OPTIMIZE)
1229             GT_setFailureReason (curTrace,
1230                                  GT_4CLASS,
1231                                  "_Platform_destroy",
1232                                  status,
1233                                  "VAYUIPUCORE0PROC_delete failed!");
1234 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1235         }
1236     }
1238     /* ------------------------- IPU2 cleanup ------------------------------- */
1239     handle = &Platform_objects [MultiProc_getId ("IPU2")];
1240     if (handle->pmHandle != NULL) {
1241         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1242         GT_assert (curTrace, (tmpStatus >= 0));
1243         if ((status >= 0) && (tmpStatus < 0)) {
1244             status = tmpStatus;
1245 #if !defined(IPC_BUILD_OPTIMIZE)
1246             GT_setFailureReason (curTrace,
1247                                  GT_4CLASS,
1248                                  "_Platform_destroy",
1249                                  status,
1250                                  "ProcMgr_delete failed!");
1251 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1252         }
1253     }
1255     /* Delete the Processor, Loader and PwrMgr instances */
1256     if (handle->sHandles.ipu.pwrHandle != NULL) {
1257         tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
1258         GT_assert (curTrace, (tmpStatus >= 0));
1259         if ((status >= 0) && (tmpStatus < 0)) {
1260             status = tmpStatus;
1261 #if !defined(IPC_BUILD_OPTIMIZE)
1262             GT_setFailureReason (curTrace,
1263                                  GT_4CLASS,
1264                                  "_Platform_destroy",
1265                                  status,
1266                                  "VAYUIPUPWR_delete failed!");
1267 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1268         }
1269     }
1271     if (handle->sHandles.ipu.ldrHandle != NULL) {
1272         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
1273         GT_assert (curTrace, (tmpStatus >= 0));
1274         if ((status >= 0) && (tmpStatus < 0)) {
1275             status = tmpStatus;
1276 #if !defined(IPC_BUILD_OPTIMIZE)
1277             GT_setFailureReason (curTrace,
1278                                  GT_4CLASS,
1279                                  "_Platform_destroy",
1280                                  status,
1281                                  "Failed to delete loader instance!");
1282 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1283         }
1284     }
1286     if (handle->sHandles.ipu.pHandle != NULL) {
1287         tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
1288         GT_assert (curTrace, (tmpStatus >= 0));
1289         if ((status >= 0) && (tmpStatus < 0)) {
1290             status = tmpStatus;
1291 #if !defined(IPC_BUILD_OPTIMIZE)
1292             GT_setFailureReason (curTrace,
1293                                  GT_4CLASS,
1294                                  "_Platform_destroy",
1295                                  status,
1296                                  "VAYUIPUCORE0PROC_delete failed!");
1297 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1298         }
1299     }
1301     tmpStatus = VAYUIPUPWR_destroy ();
1302     GT_assert (curTrace, (tmpStatus >= 0));
1303     if ((status >= 0) && (tmpStatus < 0)) {
1304         status = tmpStatus;
1305 #if !defined(IPC_BUILD_OPTIMIZE)
1306         GT_setFailureReason (curTrace,
1307                              GT_4CLASS,
1308                              "_Platform_destroy",
1309                              status,
1310                              "VAYUIPUPWR_destroy failed!");
1311 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1312     }
1314     tmpStatus = VAYUIPUCORE0PROC_destroy ();
1315     GT_assert (curTrace, (tmpStatus >= 0));
1316     if ((status >= 0) && (tmpStatus < 0)) {
1317         status = tmpStatus;
1318 #if !defined(IPC_BUILD_OPTIMIZE)
1319         GT_setFailureReason (curTrace,
1320                              GT_4CLASS,
1321                              "_Platform_destroy",
1322                              status,
1323                              "VAYUIPUCORE0PROC_destroy failed!");
1324 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1325     }
1327     GT_1trace (curTrace, GT_LEAVE, "_Platform_destroy", status);
1329     /*! @retval Platform_S_SUCCESS operation was successful */
1330     return status;
1334 #if defined (__cplusplus)
1336 #endif