]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - qnx/src/ipc3x_dev/ti/syslink/family/vayu/Platform.c
QNX IPC: Remove EVE from MultiProc as it is Not Used Currently
[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, 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 /* SysLink device specific headers */
64 #include <VAYUIpcInt.h>
65 #include <VAYUDspPwr.h>
66 #include <VAYUDspProc.h>
67 #include <VAYUIpuCore1Proc.h>
68 #include <VAYUIpuCore0Proc.h>
69 #include <VAYUIpuPwr.h>
71 /* Module level headers */
72 #include <_MessageQCopy.h>
73 #include <ti/ipc/MessageQCopy.h>
74 #include <_MessageQCopyDefs.h>
76 #include <ti/syslink/ProcMgr.h>
77 #include <_ProcMgr.h>
78 #include <ti/syslink/inc/knl/Platform.h>
79 #include <ElfLoader.h>
81 #include <ti/ipc/Ipc.h>
82 #include <_Ipc.h>
83 #include <IpcKnl.h>
84 #include <sys/mman.h>
86 #if defined (__cplusplus)
87 extern "C" {
88 #endif
91 /** ============================================================================
92  *  Macros.
93  *  ============================================================================
94  */
96 /** ============================================================================
97  *  Application specific configuration, please change these value according to
98  *  your application's need.
99  *  ============================================================================
100  */
101 /*!
102  *  @brief  Structure defining config parameters for overall System.
103  */
104 typedef struct Platform_Config {
105     MultiProc_Config                multiProcConfig;
106     /*!< Multiproc config parameter */
108     MessageQCopy_Config             MQCopyConfig;
109     /*!< MessageQCopy config parameter */
111     ProcMgr_Config                  procMgrConfig;
112     /*!< Processor manager config parameter */
114     ElfLoader_Config                elfLoaderConfig;
115     /*!< Elf loader config parameter */
116 } Platform_Config;
118 /*! @brief structure for platform instance */
119 typedef struct Platform_Object {
120     /*!< Flag to indicate platform initialization status */
121     ProcMgr_Handle                pmHandle;
122     /*!< Handle to the ProcMgr instance used */
123     union {
124         struct {
125             VAYUDSPPROC_Handle pHandle;
126             /*!< Handle to the Processor instance used */
127             VAYUDSPPWR_Handle  pwrHandle;
128             /*!< Handle to the PwrMgr instance used */
129             ElfLoader_Handle   ldrHandle;
130             /*!< Handle to the Loader instance used */
131         } dsp0;
132         struct {
133             VAYUIPUCORE0PROC_Handle pHandle;
134             /*!< Handle to the Processor instance used */
135             VAYUIPUPWR_Handle       pwrHandle;
136             /*!< Handle to the PwrMgr instance used */
137             ElfLoader_Handle        ldrHandle;
138             /*!< Handle to the Loader instance used */
139         } ipu1;
140     } sHandles;
141     /*!< Slave specific handles */
142 } Platform_Object, *Platform_Handle;
145 /*! @brief structure for platform instance */
146 typedef struct Platform_Module_State {
147     Bool              multiProcInitFlag;
148     /*!< MultiProc Initialize flag */
149     Bool              messageQCopyInitFlag;
150     /*!< MessageQCopy Initialize flag */
151     Bool              procMgrInitFlag;
152     /*!< Processor manager Initialize flag */
153     Bool              elfLoaderInitFlag;
154     /*!< Elf loader Initialize flag */
155     Bool              ipcIntInitFlag;
156     /*!< IpcInt Initialize flag */
157     Bool              platformInitFlag;
158     /*!< Flag to indicate platform initialization status */
159 } Platform_Module_State;
162 /* =============================================================================
163  * GLOBALS
164  * =============================================================================
165  */
166 static Platform_Object Platform_objects [MultiProc_MAXPROCESSORS];
167 static Platform_Module_State Platform_Module_state;
168 static Platform_Module_State * Platform_module = &Platform_Module_state;
170 Int32 _Platform_setup  (Ipc_Config * cfg);
171 Int32 _Platform_destroy (void);
173 extern String ProcMgr_sysLinkCfgParams;
175 String Syslink_Override_Params = "ProcMgr.proc[DSP1].mmuEnable=TRUE;"
176                                  "ProcMgr.proc[DSP1].carveoutAddr0=0xBA300000;"
177                                  "ProcMgr.proc[DSP1].carveoutSize0=0x5A00000;"
178                                  "ProcMgr.proc[IPU2].mmuEnable=TRUE;"
179                                  "ProcMgr.proc[IPU2].carveoutAddr0=0xBA300000;"
180                                  "ProcMgr.proc[IPU2].carveoutSize0=0x5A00000;";
182 /** ============================================================================
183  *  APIs.
184  *  ============================================================================
185  */
186 /* Function to read slave memory */
187 Int32
188 _Platform_readSlaveMemory (UInt16   procId,
189                            UInt32   addr,
190                            Ptr      value,
191                            UInt32 * numBytes);
193 /* Function to write slave memory */
194 Int32
195 _Platform_writeSlaveMemory (UInt16   procId,
196                             UInt32   addr,
197                             Ptr      value,
198                             UInt32 * numBytes);
199 /*!
200  *  @brief      Function to get the default values for configurations.
201  *
202  *  @param      config   Configuration values.
203  */
204 Void
205 Platform_getConfig (Platform_Config * config)
207     GT_1trace (curTrace, GT_ENTER, "Platform_getConfig", config);
209     GT_assert (curTrace, (config != NULL));
211 #if !defined(SYSLINK_BUILD_OPTIMIZE)
212     if (config == NULL) {
213         GT_setFailureReason (curTrace,
214                              GT_4CLASS,
215                              "Platform_getConfig",
216                              Platform_E_INVALIDARG,
217                              "Argument of type (Platform_getConfig *) passed "
218                              "is null!");
219     }
220     else {
221 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
223         /* Get the gatepeterson default config */
224         MultiProc_getConfig (&config->multiProcConfig);
226         /* Get the PROCMGR default config */
227         ProcMgr_getConfig (&config->procMgrConfig);
229         /* Get the ElfLoader default config */
230         ElfLoader_getConfig (&config->elfLoaderConfig);
231 #if !defined(SYSLINK_BUILD_OPTIMIZE)
232     }
233 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
235     GT_0trace (curTrace, GT_LEAVE, "Platform_getConfig");
238 /*!
239  *  @brief      Function to override the default configuration values.
240  *
241  *  @param      config   Configuration values.
242  */
243 Int32
244 Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
246     Int32  status = Platform_S_SUCCESS;
247     char * pSL_PARAMS;
249     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", config);
251     GT_assert (curTrace, (config != NULL));
253 #if !defined(SYSLINK_BUILD_OPTIMIZE)
254     if (config == NULL) {
255         /*! @retval Platform_E_INVALIDARG Argument of type
256          *  (Platform_Config *) passed is null*/
257         status = Platform_E_INVALIDARG;
258         GT_setFailureReason (curTrace,
259                              GT_4CLASS,
260                              "Platform_overrideConfig",
261                              status,
262                              "Argument of type (Platform_getConfig *) passed "
263                              "is null!");
264     }
265     else {
266 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
268         /* assign config->params - overriding with SL_PARAMS env var, if set */
269         pSL_PARAMS = getenv("SL_PARAMS");
270         if (pSL_PARAMS != NULL) {
271             GT_2trace(curTrace, GT_1CLASS, "Overriding SysLink_params \"%s\""
272                     " with SL_PARAMS \"%s\"\n", Syslink_Override_Params, pSL_PARAMS);
273             cfg->params = Memory_alloc(NULL, String_len(pSL_PARAMS), 0, NULL);
274             if (cfg->params) {
275                 String_cpy(cfg->params, pSL_PARAMS);
276             }
277         }
278         else {
279             cfg->params = Memory_alloc(NULL,
280                                        String_len(Syslink_Override_Params) + 1, 0,
281                                        NULL);
282             if (cfg->params) {
283                 String_cpy(cfg->params, Syslink_Override_Params);
284             }
285         }
287         _ProcMgr_saveParams(cfg->params, String_len(cfg->params));
289         /* Override the MultiProc default config */
290         config->multiProcConfig.numProcessors = 5;
291         config->multiProcConfig.id            = 0;
292         String_cpy (config->multiProcConfig.nameList [0],
293                     "HOST");
294         String_cpy (config->multiProcConfig.nameList [1],
295                     "IPU2");
296         String_cpy (config->multiProcConfig.nameList [2],
297                     "IPU1");
298         String_cpy (config->multiProcConfig.nameList [3],
299                     "DSP2");
300         String_cpy (config->multiProcConfig.nameList [4],
301                     "DSP1");
303         /* Override the MESSAGEQCOPY default config */
304         config->MQCopyConfig.intId[1] = 116; // 84 + 32
305         config->MQCopyConfig.intId[4] = 115; // 83 + 32
307 #if !defined(SYSLINK_BUILD_OPTIMIZE)
308     }
309 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
311     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", status);
313     /*! @retval Platform_S_SUCCESS operation was successful */
314     return status;
317 /*!
318  *  @brief      Function to setup platform.
319  *              TBD: logic would change completely in the final system.
320  */
321 Int32
322 Platform_setup (Ipc_Config * cfg)
324     Int32             status = Platform_S_SUCCESS;
325     Platform_Config   _config;
326     Platform_Config * config;
327     VAYUIpcInt_Config VAYUcfg;
329     Platform_getConfig (&_config);
330     config = &_config;
332     Platform_overrideConfig (config, cfg);
334     status = MultiProc_setup (&(config->multiProcConfig));
336 #if !defined(SYSLINK_BUILD_OPTIMIZE)
337     if (status < 0) {
338         GT_setFailureReason (curTrace,
339                              GT_4CLASS,
340                              "Platform_setup",
341                              status,
342                              "MultiProc_setup failed!");
343     }
344     else {
345 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
346             Platform_module->multiProcInitFlag = TRUE;
347 #if !defined(SYSLINK_BUILD_OPTIMIZE)
348     }
349 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
351 /* Initialize PROCMGR */
352     if (status >= 0) {
353         status = ProcMgr_setup (&(config->procMgrConfig));
354 #if !defined(SYSLINK_BUILD_OPTIMIZE)
355         if (status < 0) {
356             GT_setFailureReason (curTrace,
357                                  GT_4CLASS,
358                                  "Platform_setup",
359                                  status,
360                                  "ProcMgr_setup failed!");
361         }
362         else {
363 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
364             Platform_module->procMgrInitFlag = TRUE;
365 #if !defined(SYSLINK_BUILD_OPTIMIZE)
366         }
367 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
368     }
370     /* Initialize IpcInt required for VirtQueue/MessageQCopy. */
371     if (status >= 0) {
372         /* Do the IPC interrupts setup for the full platform (cfg is not used) */
373         VAYUIpcInt_setup (&VAYUcfg);
374         Platform_module->ipcIntInitFlag = TRUE;
375     }
378 /* Intialize MESSAGEQCOPY */
379     if (status >= 0) {
380         status = MessageQCopy_setup (&config->MQCopyConfig);
381 #if !defined(SYSLINK_BUILD_OPTIMIZE)
382         if (status < 0) {
383             GT_setFailureReason (curTrace,
384                                  GT_4CLASS,
385                                  "Platform_setup",
386                                  status,
387                                  "MessageQCopy_setup failed!");
388         }
389         else {
390 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
391             Platform_module->messageQCopyInitFlag = TRUE;
392 #if !defined(SYSLINK_BUILD_OPTIMIZE)
393         }
394 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
395     }
397 /* Intialize Elf loader */
398     if (status >= 0) {
399         status = ElfLoader_setup (&config->elfLoaderConfig);
400 #if !defined(SYSLINK_BUILD_OPTIMIZE)
401         if (status < 0) {
402             GT_setFailureReason (curTrace,
403                                  GT_4CLASS,
404                                  "Platform_setup",
405                                  status,
406                                  "ElfLoader_setup failed!");
407         }
408         else {
409 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
410             Platform_module->elfLoaderInitFlag = TRUE;
411 #if !defined(SYSLINK_BUILD_OPTIMIZE)
412         }
413 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
414     }
416     if (status >= 0) {
417         Memory_set (Platform_objects,
418                     0,
419                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
420     }
422     if (status >= 0) {
423         status = _Platform_setup (cfg);
424 #if !defined(SYSLINK_BUILD_OPTIMIZE)
425         if (status < 0) {
426             GT_setFailureReason (curTrace,
427                                  GT_4CLASS,
428                                  "Platform_setup",
429                                  status,
430                                  "_Platform_setup failed!");
431         }
432         else {
433 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
434             Platform_module->platformInitFlag = TRUE;
435 #if !defined(SYSLINK_BUILD_OPTIMIZE)
436         }
437 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
438     }
440     if (status < 0) {
441         Platform_destroy();
442     }
443     return status;
447 /*!
448  *  @brief      Function to destroy the System.
449  *
450  *  @sa         Platform_setup
451  */
452 Int32
453 Platform_destroy (void)
455     Int32  status = Platform_S_SUCCESS;
457     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
459     /* Finalize Platform-specific destroy */
460     if (Platform_module->platformInitFlag == TRUE) {
461         status = _Platform_destroy ();
462 #if !defined(SYSLINK_BUILD_OPTIMIZE)
463         if (status < 0) {
464             GT_setFailureReason (curTrace,
465                                  GT_4CLASS,
466                                  "Platform_destroy",
467                                  status,
468                                  "Platform_destroy failed!");
469         }
470         else {
471 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
472             Platform_module->platformInitFlag = FALSE;
473 #if !defined(SYSLINK_BUILD_OPTIMIZE)
474         }
475 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
476     }
478     /* Finalize elf loader */
479     if (Platform_module->elfLoaderInitFlag == TRUE) {
480         status = ElfLoader_destroy ();
481 #if !defined(SYSLINK_BUILD_OPTIMIZE)
482         if (status < 0) {
483             GT_setFailureReason (curTrace,
484                                  GT_4CLASS,
485                                  "Platform_destroy",
486                                  status,
487                                  "ElfLoader_destroy failed!");
488         }
489         else {
490 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
491             Platform_module->elfLoaderInitFlag = FALSE;
492 #if !defined(SYSLINK_BUILD_OPTIMIZE)
493         }
494 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
495     }
497     /* Finalize MESSAGEQCOPY */
498     if (Platform_module->messageQCopyInitFlag == TRUE) {
499         status = MessageQCopy_destroy ();
500 #if !defined(SYSLINK_BUILD_OPTIMIZE)
501         if (status < 0) {
502             GT_setFailureReason (curTrace,
503                                  GT_4CLASS,
504                                  "Platform_destroy",
505                                  status,
506                                  "MessageQCopy_destroy failed!");
507         }
508         else {
509 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
510             Platform_module->messageQCopyInitFlag = FALSE;
511 #if !defined(SYSLINK_BUILD_OPTIMIZE)
512         }
513 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
514     }
517     if (Platform_module->ipcIntInitFlag == TRUE) {
518         VAYUIpcInt_destroy ();
519         Platform_module->ipcIntInitFlag = FALSE;
520     }
522     /* Finalize PROCMGR */
523     if (Platform_module->procMgrInitFlag == TRUE) {
524         status = ProcMgr_destroy ();
525 #if !defined(SYSLINK_BUILD_OPTIMIZE)
526         if (status < 0) {
527             GT_setFailureReason (curTrace,
528                                  GT_4CLASS,
529                                  "Platform_destroy",
530                                  status,
531                                  "ProcMgr_destroy failed!");
532         }
533         else {
534 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
535             Platform_module->procMgrInitFlag = FALSE;
536 #if !defined(SYSLINK_BUILD_OPTIMIZE)
537         }
538 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
539     }
541     /* Finalize MultiProc */
542     if (Platform_module->multiProcInitFlag == TRUE) {
543         status = MultiProc_destroy ();
544 #if !defined(SYSLINK_BUILD_OPTIMIZE)
545     if (status < 0) {
546         GT_setFailureReason (curTrace,
547                              GT_4CLASS,
548                              "Platform_destroy",
549                              status,
550                              "MultiProc_destroy failed!");
551     }
552         else {
553 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
554             Platform_module->multiProcInitFlag = FALSE;
555 #if !defined(SYSLINK_BUILD_OPTIMIZE)
556         }
557 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
558     }
560     if (status >= 0) {
561         Memory_set (Platform_objects,
562                     0,
563                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
564     }
566     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
568     /*! @retval Platform_S_SUCCESS Operation successful */
569     return status;
572 /*
573  * union _Platform_setup_Local exists so that we don't waste stack or
574  * alloc'ed memory on storage for things that exist for just a few
575  * statements of the function _Platform_setup().  The *PROC_Params
576  * elements are large and variably sized, depending on the macro
577  * ProcMgr_MAX_MEMORY_REGIONS.
578  */
579 typedef union _Platform_setup_Local {
580     ProcMgr_Params          params;
581     VAYUDSPPROC_Config      dspProcConfig;
582     VAYUIPUCORE1PROC_Config videoProcConfig;
583     VAYUIPUCORE0PROC_Config vpssProcConfig;
584     VAYUDSPPWR_Config       dspPwrConfig;
585     VAYUIPUPWR_Config       videoPwrConfig;
586     VAYUIPUPWR_Config       vpssPwrConfig;
587     VAYUDSPPROC_Params      dspProcParams;
588     VAYUIPUCORE1PROC_Params videoProcParams;
589     VAYUIPUCORE0PROC_Params vpssProcParams;
590     VAYUDSPPWR_Params       dspPwrParams;
591     VAYUIPUPWR_Params       videoPwrParams;
592     VAYUIPUPWR_Params       vpssPwrParams;
593     ElfLoader_Params        elfLoaderParams;
594 } _Platform_setup_Local;
597 /*!
598  *  @brief      Function to setup platform.
599  *              TBD: logic would change completely in the final system.
600  */
601 Int32
602 _Platform_setup (Ipc_Config * cfg)
604     Int32                   status = Platform_S_SUCCESS;
605     _Platform_setup_Local   *lv;
606     UInt16                  procId;
607     Platform_Handle         handle;
609     GT_0trace (curTrace, GT_ENTER, "_Platform_setup");
611     lv = Memory_alloc(NULL, sizeof(_Platform_setup_Local), 0, NULL);
612     if (lv == NULL) {
613         status = Platform_E_FAIL;
614         GT_setFailureReason (curTrace,
615                                 GT_4CLASS,
616                                 "_Platform_setup",
617                                 status,
618                                 "Memory_alloc failed");
619         goto ret;
620     }
621     if (status >= 0) {
622         /* Get MultiProc ID by name. */
623         procId = MultiProc_getId ("IPU2");
625         handle = &Platform_objects [procId];
626         VAYUIPUCORE0PROC_getConfig (&lv->vpssProcConfig);
627         status = VAYUIPUCORE0PROC_setup (&lv->vpssProcConfig);
628         if (status < 0) {
629             GT_setFailureReason (curTrace,
630                                  GT_4CLASS,
631                                  "_Platform_setup",
632                                  status,
633                                  "VAYUIPUCORE0PROC_setup failed!");
634         }
635         else {
636             VAYUIPUPWR_getConfig (&lv->vpssPwrConfig);
637             status = VAYUIPUPWR_setup (&lv->vpssPwrConfig);
638             if (status < 0) {
639                 GT_setFailureReason (curTrace,
640                                      GT_4CLASS,
641                                      "_Platform_setup",
642                                      status,
643                                      "VAYUIPUPWR_setup failed!");
644             }
645         }
647         if (status >= 0) {
648             /* Create an instance of the Processor object for
649              * VAYUIPUCORE0 */
650             VAYUIPUCORE0PROC_Params_init (NULL, &lv->vpssProcParams);
651             handle->sHandles.ipu1.pHandle = VAYUIPUCORE0PROC_create (procId,
652                                                          &lv->vpssProcParams);
654             /* Create an instance of the ELF Loader object */
655             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
656             handle->sHandles.ipu1.ldrHandle = ElfLoader_create (procId,
657                                                         &lv->elfLoaderParams);
659             /* Create an instance of the PwrMgr object for VAYUIPUCORE0 */
660             VAYUIPUPWR_Params_init (&lv->vpssPwrParams);
661             handle->sHandles.ipu1.pwrHandle = VAYUIPUPWR_create (
662                                                            procId,
663                                                            &lv->vpssPwrParams);
665             if (handle->sHandles.ipu1.pHandle == NULL) {
666                 status = Platform_E_FAIL;
667                 GT_setFailureReason (curTrace,
668                                      GT_4CLASS,
669                                      "_Platform_setup",
670                                      status,
671                                      "VAYUIPUCORE0PROC_create failed!");
672             }
673             else if (handle->sHandles.ipu1.ldrHandle ==  NULL) {
674                 status = Platform_E_FAIL;
675                 GT_setFailureReason (curTrace,
676                                      GT_4CLASS,
677                                      "_Platform_setup",
678                                      status,
679                                      "Failed to create loader instance!");
680             }
681             else if (handle->sHandles.ipu1.pwrHandle ==  NULL) {
682                 status = Platform_E_FAIL;
683                 GT_setFailureReason (curTrace,
684                                      GT_4CLASS,
685                                      "_Platform_setup",
686                                      status,
687                                      "VAYUIPUPWR_create failed!");
688             }
689             else {
690                 /* Initialize parameters */
691                 ProcMgr_Params_init (NULL, &lv->params);
692                 lv->params.procHandle = handle->sHandles.ipu1.pHandle;
693                 lv->params.loaderHandle = handle->sHandles.ipu1.ldrHandle;
694                 lv->params.pwrHandle = handle->sHandles.ipu1.pwrHandle;
695                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
696                 if (handle->pmHandle == NULL) {
697                     status = Platform_E_FAIL;
698                     GT_setFailureReason (curTrace,
699                                          GT_4CLASS,
700                                          "_Platform_setup",
701                                          status,
702                                          "ProcMgr_create failed!");
703                 }
704             }
705         }
706     }
708     if (status >= 0) {
709         /* Get MultiProc ID by name. */
710         procId = MultiProc_getId ("DSP1");
712         handle = &Platform_objects [procId];
713         VAYUDSPPROC_getConfig (&lv->dspProcConfig);
714         status = VAYUDSPPROC_setup (&lv->dspProcConfig);
715         if (status < 0) {
716             GT_setFailureReason (curTrace,
717                                  GT_4CLASS,
718                                  "_Platform_setup",
719                                  status,
720                                  "VAYUDSPPROC_setup failed!");
721         }
722         else {
723             VAYUDSPPWR_getConfig (&lv->dspPwrConfig);
724             status = VAYUDSPPWR_setup (&lv->dspPwrConfig);
725             if (status < 0) {
726                 GT_setFailureReason (curTrace,
727                                      GT_4CLASS,
728                                      "_Platform_setup",
729                                      status,
730                                      "VAYUDSPPWR_setup failed!");
731             }
732         }
734         if (status >= 0) {
735             /* Create an instance of the Processor object for
736              * VAYUDSP */
737             VAYUDSPPROC_Params_init (NULL, &lv->dspProcParams);
738             handle->sHandles.dsp0.pHandle = VAYUDSPPROC_create (procId,
739                                                               &lv->dspProcParams);
741             /* Create an instance of the ELF Loader object */
742             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
743             handle->sHandles.dsp0.ldrHandle =
744                                            ElfLoader_create (procId,
745                                                              &lv->elfLoaderParams);
746             /* Create an instance of the PwrMgr object for VAYUDSP */
747             VAYUDSPPWR_Params_init (&lv->dspPwrParams);
748             handle->sHandles.dsp0.pwrHandle = VAYUDSPPWR_create (procId,
749                                                     &lv->dspPwrParams);
751             if (handle->sHandles.dsp0.pHandle == NULL) {
752                 status = Platform_E_FAIL;
753                 GT_setFailureReason (curTrace,
754                                      GT_4CLASS,
755                                      "_Platform_setup",
756                                      status,
757                                      "VAYUDSPPROC_create failed!");
758             }
759             else if (handle->sHandles.dsp0.ldrHandle ==  NULL) {
760                 status = Platform_E_FAIL;
761                 GT_setFailureReason (curTrace,
762                                      GT_4CLASS,
763                                      "_Platform_setup",
764                                      status,
765                                      "Failed to create loader instance!");
766             }
767             else if (handle->sHandles.dsp0.pwrHandle ==  NULL) {
768                 status = Platform_E_FAIL;
769                 GT_setFailureReason (curTrace,
770                                      GT_4CLASS,
771                                      "_Platform_setup",
772                                      status,
773                                      "VAYUDSPPWR_create failed!");
774             }
775             else {
776                 /* Initialize parameters */
777                 ProcMgr_Params_init (NULL, &lv->params);
778                 lv->params.procHandle = handle->sHandles.dsp0.pHandle;
779                 lv->params.loaderHandle = handle->sHandles.dsp0.ldrHandle;
780                 lv->params.pwrHandle = handle->sHandles.dsp0.pwrHandle;
781                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
782                 if (handle->pmHandle == NULL) {
783                     status = Platform_E_FAIL;
784                     GT_setFailureReason (curTrace,
785                                          GT_4CLASS,
786                                          "_Platform_setup",
787                                          status,
788                                          "ProcMgr_create failed!");
789                 }
790             }
791         }
792     }
794     Memory_free(NULL, lv, sizeof(_Platform_setup_Local));
796 ret:
797     GT_1trace (curTrace, GT_LEAVE, "_Platform_setup", status);
799     /*! @retval Platform_S_SUCCESS operation was successful */
800     return status;
804 /*!
805  *  @brief      Function to setup platform.
806  *              TBD: logic would change completely in the final system.
807  */
808 Int32
809 _Platform_destroy (void)
811     Int32           status    = Platform_S_SUCCESS;
812     Int32           tmpStatus = Platform_S_SUCCESS;
813     Platform_Handle handle;
815     GT_0trace (curTrace, GT_ENTER, "_Platform_destroy");
817     /* ------------------------- DSP cleanup -------------------------------- */
818     handle = &Platform_objects [MultiProc_getId ("DSP1")];
819     if (handle->pmHandle != NULL) {
820         status = ProcMgr_delete (&handle->pmHandle);
821         GT_assert (curTrace, (status >= 0));
822 #if !defined(SYSLINK_BUILD_OPTIMIZE)
823         if (status < 0) {
824             GT_setFailureReason (curTrace,
825                                  GT_4CLASS,
826                                  "_Platform_destroy",
827                                  status,
828                                  "ProcMgr_delete failed!");
829         }
830 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
831     }
833     /* Delete the Processor, Loader and PwrMgr instances */
834     if (handle->sHandles.dsp0.pwrHandle != NULL) {
835         tmpStatus = VAYUDSPPWR_delete (&handle->sHandles.dsp0.pwrHandle);
836         GT_assert (curTrace, (tmpStatus >= 0));
837         if ((status >= 0) && (tmpStatus < 0)) {
838             status = tmpStatus;
839 #if !defined(SYSLINK_BUILD_OPTIMIZE)
840             GT_setFailureReason (curTrace,
841                                  GT_4CLASS,
842                                  "_Platform_destroy",
843                                  status,
844                                  "VAYUDSPPWR_delete failed!");
845 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
846         }
847     }
849     if (handle->sHandles.dsp0.ldrHandle != NULL) {
850         tmpStatus = ElfLoader_delete (&handle->sHandles.dsp0.ldrHandle);
851         GT_assert (curTrace, (tmpStatus >= 0));
852         if ((status >= 0) && (tmpStatus < 0)) {
853             status = tmpStatus;
854 #if !defined(SYSLINK_BUILD_OPTIMIZE)
855             GT_setFailureReason (curTrace,
856                                  GT_4CLASS,
857                                  "_Platform_destroy",
858                                  status,
859                                  "Failed to delete loader instance!");
860 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
861         }
862     }
864     if (handle->sHandles.dsp0.pHandle != NULL) {
865         tmpStatus = VAYUDSPPROC_delete (&handle->sHandles.dsp0.pHandle);
866         GT_assert (curTrace, (tmpStatus >= 0));
867         if ((status >= 0) && (tmpStatus < 0)) {
868             status = tmpStatus;
869 #if !defined(SYSLINK_BUILD_OPTIMIZE)
870             GT_setFailureReason (curTrace,
871                                  GT_4CLASS,
872                                  "_Platform_destroy",
873                                  status,
874                                  "VAYUDSPPROC_delete failed!");
875 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
876         }
877     }
879     tmpStatus = VAYUDSPPWR_destroy ();
880     GT_assert (curTrace, (tmpStatus >= 0));
881     if ((status >= 0) && (tmpStatus < 0)) {
882         status = tmpStatus;
883 #if !defined(SYSLINK_BUILD_OPTIMIZE)
884         GT_setFailureReason (curTrace,
885                              GT_4CLASS,
886                              "_Platform_destroy",
887                              status,
888                              "VAYUDSPPWR_destroy failed!");
889 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
890     }
892     tmpStatus = VAYUDSPPROC_destroy ();
893     GT_assert (curTrace, (tmpStatus >= 0));
894     if ((status >= 0) && (tmpStatus < 0)) {
895         status = tmpStatus;
896 #if !defined(SYSLINK_BUILD_OPTIMIZE)
897         GT_setFailureReason (curTrace,
898                              GT_4CLASS,
899                              "_Platform_destroy",
900                              status,
901                              "VAYUDSPPROC_destroy failed!");
902 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
903     }
905     /* ------------------------- IPU1 cleanup ------------------------------- */
906     handle = &Platform_objects [MultiProc_getId ("IPU2")];
907     if (handle->pmHandle != NULL) {
908         tmpStatus = ProcMgr_delete (&handle->pmHandle);
909         GT_assert (curTrace, (tmpStatus >= 0));
910         if ((status >= 0) && (tmpStatus < 0)) {
911             status = tmpStatus;
912 #if !defined(SYSLINK_BUILD_OPTIMIZE)
913             GT_setFailureReason (curTrace,
914                                  GT_4CLASS,
915                                  "_Platform_destroy",
916                                  status,
917                                  "ProcMgr_delete failed!");
918 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
919         }
920     }
922     /* Delete the Processor, Loader and PwrMgr instances */
923     if (handle->sHandles.ipu1.pwrHandle != NULL) {
924         tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu1.pwrHandle);
925         GT_assert (curTrace, (tmpStatus >= 0));
926         if ((status >= 0) && (tmpStatus < 0)) {
927             status = tmpStatus;
928 #if !defined(SYSLINK_BUILD_OPTIMIZE)
929             GT_setFailureReason (curTrace,
930                                  GT_4CLASS,
931                                  "_Platform_destroy",
932                                  status,
933                                  "VAYUIPUPWR_delete failed!");
934 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
935         }
936     }
938     if (handle->sHandles.ipu1.ldrHandle != NULL) {
939         tmpStatus = ElfLoader_delete (&handle->sHandles.ipu1.ldrHandle);
940         GT_assert (curTrace, (tmpStatus >= 0));
941         if ((status >= 0) && (tmpStatus < 0)) {
942             status = tmpStatus;
943 #if !defined(SYSLINK_BUILD_OPTIMIZE)
944             GT_setFailureReason (curTrace,
945                                  GT_4CLASS,
946                                  "_Platform_destroy",
947                                  status,
948                                  "Failed to delete loader instance!");
949 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
950         }
951     }
953     if (handle->sHandles.ipu1.pHandle != NULL) {
954         tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu1.pHandle);
955         GT_assert (curTrace, (tmpStatus >= 0));
956         if ((status >= 0) && (tmpStatus < 0)) {
957             status = tmpStatus;
958 #if !defined(SYSLINK_BUILD_OPTIMIZE)
959             GT_setFailureReason (curTrace,
960                                  GT_4CLASS,
961                                  "_Platform_destroy",
962                                  status,
963                                  "VAYUIPUCORE0PROC_delete failed!");
964 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
965         }
966     }
968     tmpStatus = VAYUIPUPWR_destroy ();
969     GT_assert (curTrace, (tmpStatus >= 0));
970     if ((status >= 0) && (tmpStatus < 0)) {
971         status = tmpStatus;
972 #if !defined(SYSLINK_BUILD_OPTIMIZE)
973         GT_setFailureReason (curTrace,
974                              GT_4CLASS,
975                              "_Platform_destroy",
976                              status,
977                              "VAYUIPUPWR_destroy failed!");
978 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
979     }
981     tmpStatus = VAYUIPUCORE0PROC_destroy ();
982     GT_assert (curTrace, (tmpStatus >= 0));
983     if ((status >= 0) && (tmpStatus < 0)) {
984         status = tmpStatus;
985 #if !defined(SYSLINK_BUILD_OPTIMIZE)
986         GT_setFailureReason (curTrace,
987                              GT_4CLASS,
988                              "_Platform_destroy",
989                              status,
990                              "VAYUIPUCORE0PROC_destroy failed!");
991 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
992     }
994     GT_1trace (curTrace, GT_LEAVE, "_Platform_destroy", status);
996     /*! @retval Platform_S_SUCCESS operation was successful */
997     return status;
1001 #if defined (__cplusplus)
1003 #endif