b62422314219d8c771db27c5dd4de1e37fa19149
[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];
941         VAYUDSPPROC_getConfig (&lv->dspProcConfig);
942         status = VAYUDSPPROC_setup (&lv->dspProcConfig);
943         if (status < 0) {
944             GT_setFailureReason (curTrace,
945                                  GT_4CLASS,
946                                  "_Platform_setup",
947                                  status,
948                                  "VAYUDSPPROC_setup failed!");
949         }
950         else {
951             VAYUDSPPWR_getConfig (&lv->dspPwrConfig);
952             status = VAYUDSPPWR_setup (&lv->dspPwrConfig);
953             if (status < 0) {
954                 GT_setFailureReason (curTrace,
955                                      GT_4CLASS,
956                                      "_Platform_setup",
957                                      status,
958                                      "VAYUDSPPWR_setup failed!");
959             }
960         }
962         if (status >= 0) {
963             /* Create an instance of the Processor object for
964              * VAYUDSP */
965             VAYUDSPPROC_Params_init (NULL, &lv->dspProcParams);
966             handle->sHandles.dsp.pHandle = VAYUDSPPROC_create (procId,
967                                                               &lv->dspProcParams);
969             /* Create an instance of the ELF Loader object */
970             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
971             handle->sHandles.dsp.ldrHandle =
972                                            ElfLoader_create (procId,
973                                                              &lv->elfLoaderParams);
974             /* Create an instance of the PwrMgr object for VAYUDSP */
975             VAYUDSPPWR_Params_init (&lv->dspPwrParams);
976             handle->sHandles.dsp.pwrHandle = VAYUDSPPWR_create (procId,
977                                                     &lv->dspPwrParams);
979             if (handle->sHandles.dsp.pHandle == NULL) {
980                 status = Platform_E_FAIL;
981                 GT_setFailureReason (curTrace,
982                                      GT_4CLASS,
983                                      "_Platform_setup",
984                                      status,
985                                      "VAYUDSPPROC_create failed!");
986             }
987             else if (handle->sHandles.dsp.ldrHandle ==  NULL) {
988                 status = Platform_E_FAIL;
989                 GT_setFailureReason (curTrace,
990                                      GT_4CLASS,
991                                      "_Platform_setup",
992                                      status,
993                                      "Failed to create loader instance!");
994             }
995             else if (handle->sHandles.dsp.pwrHandle ==  NULL) {
996                 status = Platform_E_FAIL;
997                 GT_setFailureReason (curTrace,
998                                      GT_4CLASS,
999                                      "_Platform_setup",
1000                                      status,
1001                                      "VAYUDSPPWR_create failed!");
1002             }
1003             else {
1004                 /* Initialize parameters */
1005                 ProcMgr_Params_init (NULL, &lv->params);
1006                 lv->params.procHandle = handle->sHandles.dsp.pHandle;
1007                 lv->params.loaderHandle = handle->sHandles.dsp.ldrHandle;
1008                 lv->params.pwrHandle = handle->sHandles.dsp.pwrHandle;
1009                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
1010                 if (handle->pmHandle == NULL) {
1011                     status = Platform_E_FAIL;
1012                     GT_setFailureReason (curTrace,
1013                                          GT_4CLASS,
1014                                          "_Platform_setup",
1015                                          status,
1016                                          "ProcMgr_create failed!");
1017                 }
1018             }
1019         }
1020     }
1022     Memory_free(NULL, lv, sizeof(_Platform_setup_Local));
1024 ret:
1025     GT_1trace (curTrace, GT_LEAVE, "_Platform_setup", status);
1027     /*! @retval Platform_S_SUCCESS operation was successful */
1028     return status;
1032 /*!
1033  *  @brief      Function to setup platform.
1034  *              TBD: logic would change completely in the final system.
1035  */
1036 Int32
1037 _Platform_destroy (void)
1039     Int32           status    = Platform_S_SUCCESS;
1040     Int32           tmpStatus = Platform_S_SUCCESS;
1041     Platform_Handle handle;
1043     GT_0trace (curTrace, GT_ENTER, "_Platform_destroy");
1045     /* ------------------------- DSP1 cleanup -------------------------------- */
1046     handle = &Platform_objects [MultiProc_getId ("DSP1")];
1047     if (handle->pmHandle != NULL) {
1048         status = ProcMgr_delete (&handle->pmHandle);
1049         GT_assert (curTrace, (status >= 0));
1050 #if !defined(IPC_BUILD_OPTIMIZE)
1051         if (status < 0) {
1052             GT_setFailureReason (curTrace,
1053                                  GT_4CLASS,
1054                                  "_Platform_destroy",
1055                                  status,
1056                                  "ProcMgr_delete failed!");
1057         }
1058 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1059     }
1061     /* Delete the Processor, Loader and PwrMgr instances */
1062     if (handle->sHandles.dsp.pwrHandle != NULL) {
1063         tmpStatus = VAYUDSPPWR_delete (&handle->sHandles.dsp.pwrHandle);
1064         GT_assert (curTrace, (tmpStatus >= 0));
1065         if ((status >= 0) && (tmpStatus < 0)) {
1066             status = tmpStatus;
1067 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1068             GT_setFailureReason (curTrace,
1069                                  GT_4CLASS,
1070                                  "_Platform_destroy",
1071                                  status,
1072                                  "VAYUDSPPWR_delete failed!");
1073 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1074         }
1075     }
1077     if (handle->sHandles.dsp.ldrHandle != NULL) {
1078         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1079         GT_assert (curTrace, (tmpStatus >= 0));
1080         if ((status >= 0) && (tmpStatus < 0)) {
1081             status = tmpStatus;
1082 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1083             GT_setFailureReason (curTrace,
1084                                  GT_4CLASS,
1085                                  "_Platform_destroy",
1086                                  status,
1087                                  "Failed to delete loader instance!");
1088 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1089         }
1090     }
1092     if (handle->sHandles.dsp.pHandle != NULL) {
1093         tmpStatus = VAYUDSPPROC_delete (&handle->sHandles.dsp.pHandle);
1094         GT_assert (curTrace, (tmpStatus >= 0));
1095         if ((status >= 0) && (tmpStatus < 0)) {
1096             status = tmpStatus;
1097 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1098             GT_setFailureReason (curTrace,
1099                                  GT_4CLASS,
1100                                  "_Platform_destroy",
1101                                  status,
1102                                  "VAYUDSPPROC_delete failed!");
1103 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1104         }
1105     }
1107     /* ------------------------- DSP2 cleanup -------------------------------- */
1108     handle = &Platform_objects [MultiProc_getId ("DSP2")];
1109     if (handle->pmHandle != NULL) {
1110         status = ProcMgr_delete (&handle->pmHandle);
1111         GT_assert (curTrace, (status >= 0));
1112 #if !defined(SYSLINK_BUILD_OPTIMIZE)
1113         if (status < 0) {
1114             GT_setFailureReason (curTrace,
1115                                  GT_4CLASS,
1116                                  "_Platform_destroy",
1117                                  status,
1118                                  "ProcMgr_delete failed!");
1119         }
1120 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
1121     }
1123     /* Delete the Processor, Loader and PwrMgr instances */
1124     if (handle->sHandles.dsp.pwrHandle != NULL) {
1125         tmpStatus = VAYUDSPPWR_delete (&handle->sHandles.dsp.pwrHandle);
1126         GT_assert (curTrace, (tmpStatus >= 0));
1127         if ((status >= 0) && (tmpStatus < 0)) {
1128             status = tmpStatus;
1129 #if !defined(IPC_BUILD_OPTIMIZE)
1130             GT_setFailureReason (curTrace,
1131                                  GT_4CLASS,
1132                                  "_Platform_destroy",
1133                                  status,
1134                                  "VAYUDSPPWR_delete failed!");
1135 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1136         }
1137     }
1139     if (handle->sHandles.dsp.ldrHandle != NULL) {
1140         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp.ldrHandle);
1141         GT_assert (curTrace, (tmpStatus >= 0));
1142         if ((status >= 0) && (tmpStatus < 0)) {
1143             status = tmpStatus;
1144 #if !defined(IPC_BUILD_OPTIMIZE)
1145             GT_setFailureReason (curTrace,
1146                                  GT_4CLASS,
1147                                  "_Platform_destroy",
1148                                  status,
1149                                  "Failed to delete loader instance!");
1150 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1151         }
1152     }
1154     if (handle->sHandles.dsp.pHandle != NULL) {
1155         tmpStatus = VAYUDSPPROC_delete (&handle->sHandles.dsp.pHandle);
1156         GT_assert (curTrace, (tmpStatus >= 0));
1157         if ((status >= 0) && (tmpStatus < 0)) {
1158             status = tmpStatus;
1159 #if !defined(IPC_BUILD_OPTIMIZE)
1160             GT_setFailureReason (curTrace,
1161                                  GT_4CLASS,
1162                                  "_Platform_destroy",
1163                                  status,
1164                                  "VAYUDSPPROC_delete failed!");
1165 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1166         }
1167     }
1169     tmpStatus = VAYUDSPPWR_destroy ();
1170     GT_assert (curTrace, (tmpStatus >= 0));
1171     if ((status >= 0) && (tmpStatus < 0)) {
1172         status = tmpStatus;
1173 #if !defined(IPC_BUILD_OPTIMIZE)
1174         GT_setFailureReason (curTrace,
1175                              GT_4CLASS,
1176                              "_Platform_destroy",
1177                              status,
1178                              "VAYUDSPPWR_destroy failed!");
1179 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1180     }
1182     tmpStatus = VAYUDSPPROC_destroy ();
1183     GT_assert (curTrace, (tmpStatus >= 0));
1184     if ((status >= 0) && (tmpStatus < 0)) {
1185         status = tmpStatus;
1186 #if !defined(IPC_BUILD_OPTIMIZE)
1187         GT_setFailureReason (curTrace,
1188                              GT_4CLASS,
1189                              "_Platform_destroy",
1190                              status,
1191                              "VAYUDSPPROC_destroy failed!");
1192 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1193     }
1195     /* ------------------------- IPU1 cleanup ------------------------------- */
1196     handle = &Platform_objects [MultiProc_getId ("IPU1")];
1197     if (handle->pmHandle != NULL) {
1198         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1199         GT_assert (curTrace, (tmpStatus >= 0));
1200         if ((status >= 0) && (tmpStatus < 0)) {
1201             status = tmpStatus;
1202 #if !defined(IPC_BUILD_OPTIMIZE)
1203             GT_setFailureReason (curTrace,
1204                                  GT_4CLASS,
1205                                  "_Platform_destroy",
1206                                  status,
1207                                  "ProcMgr_delete failed!");
1208 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1209         }
1210     }
1212     /* Delete the Processor, Loader and PwrMgr instances */
1213     if (handle->sHandles.ipu.pwrHandle != NULL) {
1214         tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
1215         GT_assert (curTrace, (tmpStatus >= 0));
1216         if ((status >= 0) && (tmpStatus < 0)) {
1217             status = tmpStatus;
1218 #if !defined(IPC_BUILD_OPTIMIZE)
1219             GT_setFailureReason (curTrace,
1220                                  GT_4CLASS,
1221                                  "_Platform_destroy",
1222                                  status,
1223                                  "VAYUIPUPWR_delete failed!");
1224 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1225         }
1226     }
1228     if (handle->sHandles.ipu.ldrHandle != NULL) {
1229         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
1230         GT_assert (curTrace, (tmpStatus >= 0));
1231         if ((status >= 0) && (tmpStatus < 0)) {
1232             status = tmpStatus;
1233 #if !defined(IPC_BUILD_OPTIMIZE)
1234             GT_setFailureReason (curTrace,
1235                                  GT_4CLASS,
1236                                  "_Platform_destroy",
1237                                  status,
1238                                  "Failed to delete loader instance!");
1239 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1240         }
1241     }
1243     if (handle->sHandles.ipu.pHandle != NULL) {
1244         tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
1245         GT_assert (curTrace, (tmpStatus >= 0));
1246         if ((status >= 0) && (tmpStatus < 0)) {
1247             status = tmpStatus;
1248 #if !defined(IPC_BUILD_OPTIMIZE)
1249             GT_setFailureReason (curTrace,
1250                                  GT_4CLASS,
1251                                  "_Platform_destroy",
1252                                  status,
1253                                  "VAYUIPUCORE0PROC_delete failed!");
1254 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1255         }
1256     }
1258     /* ------------------------- IPU2 cleanup ------------------------------- */
1259     handle = &Platform_objects [MultiProc_getId ("IPU2")];
1260     if (handle->pmHandle != NULL) {
1261         tmpStatus = ProcMgr_delete (&handle->pmHandle);
1262         GT_assert (curTrace, (tmpStatus >= 0));
1263         if ((status >= 0) && (tmpStatus < 0)) {
1264             status = tmpStatus;
1265 #if !defined(IPC_BUILD_OPTIMIZE)
1266             GT_setFailureReason (curTrace,
1267                                  GT_4CLASS,
1268                                  "_Platform_destroy",
1269                                  status,
1270                                  "ProcMgr_delete failed!");
1271 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1272         }
1273     }
1275     /* Delete the Processor, Loader and PwrMgr instances */
1276     if (handle->sHandles.ipu.pwrHandle != NULL) {
1277         tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
1278         GT_assert (curTrace, (tmpStatus >= 0));
1279         if ((status >= 0) && (tmpStatus < 0)) {
1280             status = tmpStatus;
1281 #if !defined(IPC_BUILD_OPTIMIZE)
1282             GT_setFailureReason (curTrace,
1283                                  GT_4CLASS,
1284                                  "_Platform_destroy",
1285                                  status,
1286                                  "VAYUIPUPWR_delete failed!");
1287 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1288         }
1289     }
1291     if (handle->sHandles.ipu.ldrHandle != NULL) {
1292         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
1293         GT_assert (curTrace, (tmpStatus >= 0));
1294         if ((status >= 0) && (tmpStatus < 0)) {
1295             status = tmpStatus;
1296 #if !defined(IPC_BUILD_OPTIMIZE)
1297             GT_setFailureReason (curTrace,
1298                                  GT_4CLASS,
1299                                  "_Platform_destroy",
1300                                  status,
1301                                  "Failed to delete loader instance!");
1302 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1303         }
1304     }
1306     if (handle->sHandles.ipu.pHandle != NULL) {
1307         tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
1308         GT_assert (curTrace, (tmpStatus >= 0));
1309         if ((status >= 0) && (tmpStatus < 0)) {
1310             status = tmpStatus;
1311 #if !defined(IPC_BUILD_OPTIMIZE)
1312             GT_setFailureReason (curTrace,
1313                                  GT_4CLASS,
1314                                  "_Platform_destroy",
1315                                  status,
1316                                  "VAYUIPUCORE0PROC_delete failed!");
1317 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1318         }
1319     }
1321     tmpStatus = VAYUIPUPWR_destroy ();
1322     GT_assert (curTrace, (tmpStatus >= 0));
1323     if ((status >= 0) && (tmpStatus < 0)) {
1324         status = tmpStatus;
1325 #if !defined(IPC_BUILD_OPTIMIZE)
1326         GT_setFailureReason (curTrace,
1327                              GT_4CLASS,
1328                              "_Platform_destroy",
1329                              status,
1330                              "VAYUIPUPWR_destroy failed!");
1331 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1332     }
1334     tmpStatus = VAYUIPUCORE0PROC_destroy ();
1335     GT_assert (curTrace, (tmpStatus >= 0));
1336     if ((status >= 0) && (tmpStatus < 0)) {
1337         status = tmpStatus;
1338 #if !defined(IPC_BUILD_OPTIMIZE)
1339         GT_setFailureReason (curTrace,
1340                              GT_4CLASS,
1341                              "_Platform_destroy",
1342                              status,
1343                              "VAYUIPUCORE0PROC_destroy failed!");
1344 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1345     }
1347     GT_1trace (curTrace, GT_LEAVE, "_Platform_destroy", status);
1349     /*! @retval Platform_S_SUCCESS operation was successful */
1350     return status;
1354 #if defined (__cplusplus)
1356 #endif