[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / omap5430 / ipu / omap5430BenelliProc.c
1 /*
2 * @file omap5430BenelliProc.c
3 *
4 * @brief Processor implementation for OMAP5430BENELLI.
5 *
6 * This module is responsible for taking care of device-specific
7 * operations for the processor. This module can be used
8 * stand-alone or as part of ProcMgr.
9 * The implementation is specific to OMAP5430BENELLI.
10 *
11 *
12 * @ver 02.00.00.44_pre-alpha3
13 *
14 * ============================================================================
15 *
16 * Copyright (c) 2010-2015, Texas Instruments Incorporated
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * * Neither the name of Texas Instruments Incorporated nor the names of
30 * its contributors may be used to endorse or promote products derived
31 * from this software without specific prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
34 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
35 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
36 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
37 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
38 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
39 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
40 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
41 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
42 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 * Contact information for paper mail:
45 * Texas Instruments
46 * Post Office Box 655303
47 * Dallas, Texas 75265
48 * Contact information:
49 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
50 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
51 * ============================================================================
52 *
53 */
56 /* Standard headers */
57 #include <ti/syslink/Std.h>
59 /* OSAL & Utils headers */
60 #include <ti/syslink/utils/IGateProvider.h>
61 #include <ti/syslink/utils/GateMutex.h>
62 #include <ti/syslink/utils/Trace.h>
63 #include <ti/syslink/utils/Cfg.h>
65 /* Module level headers */
66 #include <ProcDefs.h>
67 #include <Processor.h>
68 #include <OMAP5430BenelliHal.h>
69 #include <OMAP5430BenelliHalReset.h>
70 #include <OMAP5430BenelliHalMmu.h>
71 #include <OMAP5430BenelliProc.h>
72 #include <OMAP5430BenelliEnabler.h>
73 #include <_MultiProc.h>
74 #include <hw/inout.h>
75 #include <RscTable.h>
77 #if defined (__cplusplus)
78 extern "C" {
79 #endif
81 #define INREG32(x) in32(x)
82 #define OUTREG32(x, y) out32(x, y)
85 /* =============================================================================
86 * Macros and types
87 * =============================================================================
88 */
90 /*!
91 * @brief Checks if a value lies in given range.
92 */
93 #define IS_RANGE_VALID(x,min,max) (((x) < (max)) && ((x) >= (min)))
96 /*!
97 * @brief max entries in translation table.
98 */
99 #define AddrTable_SIZE 32
101 /* number of carveouts */
102 #define NumCarveouts 1
105 /*!
106 * @brief OMAP5430BENELLIPROC Module state object
107 */
110 /*OMAP5430 Module state object */
111 typedef struct OMAP5430BENELLIPROC_module_object_tag {
112 UINT32 config_size;
113 /* Size of configuration structure */
114 struct OMAP5430BENELLIPROC_Config cfg;
115 /* OMAP5430 configuration structure */
116 struct OMAP5430BENELLIPROC_Config defCfg;
117 /* Default module configuration */
118 OMAP5430BENELLIPROC_Params defInstParams;
119 /*!< Default parameters for the OMAP5430BENELLIPROC instances */
120 Bool isSetup;
121 /* Flag to indicate if module is setup */
122 OMAP5430BENELLIPROC_Handle procHandle;
123 /* Processor handle array. */
124 IGateProvider_Handle gateHandle;
125 /* void * of gate to be used for local thread safety */
126 }OMAP5430BENELLIPROC_ModuleObject;
128 typedef struct OMAP5430TESLAPROC_module_object_tag {
129 UINT32 config_size;
130 /* Size of configuration structure */
131 struct OMAP5430TESLAPROC_Config cfg;
132 /* OMAP5430 configuration structure */
133 struct OMAP5430TESLAPROC_Config defCfg;
134 /* Default module configuration */
135 OMAP5430BENELLIPROC_Params defInstParams;
136 /*!< Default parameters for the OMAP5430TESLAPROC instances */
137 Bool isSetup;
138 /* Default parameters for the OMAP5430 instances */
139 OMAP5430BENELLIPROC_Handle procHandle;
140 /* Processor handle array. */
141 IGateProvider_Handle gateHandle;
142 /* void * of gate to be used for local thread safety */
143 }OMAP5430TESLAPROC_ModuleObject;
146 /* Number of memory regions */
147 static UInt32 AddrTable_IPU_count = 0;
148 static UInt32 AddrTable_DSP_count = 0;
150 /* Address translation table for IPU */
151 static ProcMgr_AddrInfo OMAP5430BENELLIPROC_addrTable[AddrTable_SIZE];
153 /* Address translation table for DSP */
154 static ProcMgr_AddrInfo OMAP5430TESLAPROC_addrTable[AddrTable_SIZE];
156 /* =============================================================================
157 * Globals
158 * =============================================================================
159 */
160 /*!
161 * @var OMAP5430BENELLIPROC_state
162 *
163 * @brief OMAP5430BENELLIPROC state object variable
164 */
165 #if !defined(IPC_BUILD_DEBUG)
166 static
167 #endif /* if !defined(IPC_BUILD_DEBUG) */
168 OMAP5430BENELLIPROC_ModuleObject OMAP5430IPU0PROC_state =
169 {
170 .config_size = sizeof (OMAP5430BENELLIPROC_Config),
171 .defInstParams.numMemEntries = 0,
172 .isSetup = FALSE,
173 .procHandle = NULL,
174 .gateHandle = NULL
175 };
177 #ifndef IPC_SYSBIOS_SMP
178 #if !defined(IPC_BUILD_DEBUG)
179 static
180 #endif /* if !defined(IPC_BUILD_DEBUG) */
181 OMAP5430BENELLIPROC_ModuleObject OMAP5430IPU1PROC_state =
182 {
183 .config_size = sizeof (OMAP5430BENELLIPROC_Config),
184 .defInstParams.numMemEntries = 0,
185 .isSetup = FALSE,
186 .procHandle = NULL,
187 .gateHandle = NULL
188 };
189 #endif
191 #if !defined(IPC_BUILD_DEBUG)
192 static
193 #endif /* if !defined(IPC_BUILD_DEBUG) */
194 OMAP5430TESLAPROC_ModuleObject OMAP5430DSPPROC_state =
195 {
196 .config_size = sizeof (OMAP5430TESLAPROC_Config),
197 .defInstParams.numMemEntries = 0,
198 .isSetup = FALSE,
199 .procHandle = NULL,
200 .gateHandle = NULL
201 };
204 /* =============================================================================
205 * APIs directly called by applications
206 * =============================================================================
207 */
208 /*!
209 * @brief Function to get the default configuration for the
210 * OMAP5430BENELLIPROC module.
211 *
212 * This function can be called by the application to get their
213 * configuration parameter to OMAP5430BENELLIPROC_setup filled in by
214 * the OMAP5430BENELLIPROC module with the default parameters. If
215 * the user does not wish to make any change in the default
216 * parameters, this API is not required to be called.
217 *
218 * @param cfg Pointer to the OMAP5430BENELLIPROC module
219 * configuration structure in which the default config
220 * is to be returned.
221 *
222 * @sa OMAP5430BENELLIPROC_setup
223 */
224 Void
225 OMAP5430BENELLIPROC_get_config (OMAP5430BENELLIPROC_Config * cfg, Int ProcType)
226 {
227 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_get_config", cfg);
229 GT_assert (curTrace, (cfg != NULL));
231 #if !defined(IPC_BUILD_OPTIMIZE)
232 if (cfg == NULL) {
233 GT_setFailureReason (curTrace,
234 GT_4CLASS,
235 "OMAP5430BENELLIPROC_get_config",
236 PROCESSOR_E_INVALIDARG,
237 "Argument of type (OMAP5430BENELLIPROC_Config *) "
238 "passed is null!");
239 }
240 else {
241 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
242 switch (ProcType)
243 {
244 case PROCTYPE_IPU0:
245 Memory_copy (cfg,
246 &(OMAP5430IPU0PROC_state.defCfg),
247 sizeof (OMAP5430BENELLIPROC_Config));
248 break;
249 #ifndef IPC_SYSBIOS_SMP
250 case PROCTYPE_IPU1:
251 Memory_copy (cfg,
252 &(OMAP5430IPU1PROC_state.defCfg),
253 sizeof (OMAP5430BENELLIPROC_Config));
254 break;
255 #endif
256 case PROCTYPE_DSP:
257 Memory_copy (cfg,
258 &(OMAP5430DSPPROC_state.defCfg),
259 sizeof (OMAP5430TESLAPROC_Config));
260 break;
261 }
262 #if !defined(IPC_BUILD_OPTIMIZE)
263 }
264 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
266 GT_0trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_get_config");
267 }
270 /*!
271 * @brief Function to setup the OMAP5430BENELLIPROC module.
272 *
273 * This function sets up the OMAP5430BENELLIPROC module. This
274 * function must be called before any other instance-level APIs
275 * can be invoked.
276 * Module-level configuration needs to be provided to this
277 * function. If the user wishes to change some specific config
278 * parameters, then OMAP5430BENELLIPROC_getConfig can be called to
279 * get the configuration filled with the default values. After
280 * this, only the required configuration values can be changed. If
281 * the user does not wish to make any change in the default
282 * parameters, the application can simply call
283 * OMAP5430BENELLIPROC_setup with NULL parameters. The default
284 * parameters would get automatically used.
285 *
286 * @param cfg Optional OMAP5430BENELLIPROC module configuration. If
287 * provided as NULL, default configuration is used.
288 *
289 * @sa OMAP5430BENELLIPROC_destroy
290 * GateMutex_create
291 */
292 Int
293 OMAP5430BENELLIPROC_setup (OMAP5430BENELLIPROC_Config * cfg, Int ProcType)
294 {
295 Int status = PROCESSOR_SUCCESS;
296 OMAP5430BENELLIPROC_Config tmpCfg;
297 OMAP5430BENELLIPROC_ModuleObject * pState = NULL;
298 Error_Block eb;
300 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_setup", cfg);
302 Error_init(&eb);
304 if (cfg == NULL) {
305 OMAP5430BENELLIPROC_get_config (&tmpCfg,ProcType );
306 cfg = &tmpCfg;
307 }
309 switch (ProcType)
310 {
311 case PROCTYPE_IPU0:
312 pState = &OMAP5430IPU0PROC_state;
313 break;
314 #ifndef IPC_SYSBIOS_SMP
315 case PROCTYPE_IPU1:
316 pState = &OMAP5430IPU1PROC_state;
317 break;
318 #endif
319 case PROCTYPE_DSP:
320 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
321 break;
322 }
324 if (pState == NULL) {
325 GT_setFailureReason (curTrace,
326 GT_4CLASS,
327 "OMAP5430BENELLIPROC_setup",
328 PROCESSOR_E_INVALIDARG,
329 "Unsupported procType");
330 return PROCESSOR_E_INVALIDARG;
331 }
333 /* Create a default gate handle for local module protection. */
334 pState->gateHandle = (IGateProvider_Handle)
335 GateMutex_create ((GateMutex_Params *)NULL, &eb);
336 #if !defined(IPC_BUILD_OPTIMIZE)
337 if (pState->gateHandle == NULL) {
338 /*! @retval PROCESSOR_E_FAIL Failed to create GateMutex! */
339 status = PROCESSOR_E_FAIL;
340 GT_setFailureReason (curTrace,
341 GT_4CLASS,
342 "OMAP5430BENELLIPROC_setup",
343 status,
344 "Failed to create GateMutex!");
345 }
346 else {
347 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
348 /* Copy the user provided values into the state object. */
349 Memory_copy (&pState->cfg,
350 cfg,
351 sizeof (OMAP5430BENELLIPROC_Config));
353 /* Initialize the name to handles mapping array. */
354 pState->procHandle = NULL;
356 pState->isSetup = TRUE;
357 #if !defined(IPC_BUILD_OPTIMIZE)
358 }
359 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
361 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_setup", status);
363 /*! @retval PROCESSOR_SUCCESS Operation successful */
364 return (status);
365 }
368 /*!
369 * @brief Function to destroy the OMAP5430BENELLIPROC module.
370 *
371 * Once this function is called, other OMAP5430BENELLIPROC module
372 * APIs, except for the OMAP5430BENELLIPROC_getConfig API cannot be
373 * called anymore.
374 *
375 * @sa OMAP5430BENELLIPROC_setup
376 * GateMutex_delete
377 */
378 Int
379 OMAP5430BENELLIPROC_destroy (Int ProcType)
380 {
381 Int status = PROCESSOR_SUCCESS;
382 OMAP5430BENELLIPROC_ModuleObject * pState = NULL;
384 GT_0trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_destroy");
386 switch(ProcType)
387 {
388 case PROCTYPE_IPU0:
389 pState = &OMAP5430IPU0PROC_state;
390 break;
391 #ifndef IPC_SYSBIOS_SMP
392 case PROCTYPE_IPU1:
393 pState = &OMAP5430IPU1PROC_state;
394 break;
395 #endif
396 case PROCTYPE_DSP:
397 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
398 break;
399 }
401 if (pState == NULL) {
402 GT_setFailureReason (curTrace,
403 GT_4CLASS,
404 "OMAP5430BENELLIPROC_setup",
405 PROCESSOR_E_INVALIDARG,
406 "Unsupported procType");
407 return PROCESSOR_E_INVALIDARG;
408 }
410 /* Check if any OMAP5430BENELLIPROC instances have not been deleted so far.
411 * If not, delete them.
412 */
413 if (pState->procHandle != NULL) {
414 OMAP5430BENELLIPROC_delete(&pState->procHandle);
415 }
417 if (pState->gateHandle != NULL) {
418 GateMutex_delete ((GateMutex_Handle *)
419 &(pState->gateHandle));
420 }
422 pState->isSetup = FALSE;
424 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_destroy", status);
426 /*! @retval PROCESSOR_SUCCESS Operation successful */
427 return (status);
428 }
431 /*!
432 * @brief Function to initialize the parameters for this Processor
433 * instance.
434 *
435 * @param params Configuration parameters to be returned
436 *
437 * @sa OMAP5430BENELLIPROC_create
438 */
439 Void
440 OMAP5430BENELLIPROC_Params_init (OMAP5430BENELLIPROC_Handle handle,
441 OMAP5430BENELLIPROC_Params * params,
442 Int ProcType)
443 {
444 OMAP5430BENELLIPROC_Object * procObject =
445 (OMAP5430BENELLIPROC_Object *) handle;
446 UInt32 numMemEntries = 0;
447 ProcMgr_AddrInfo * pMemRegn = NULL;
449 GT_2trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_Params_init",
450 handle, params);
452 GT_assert (curTrace, (params != NULL));
453 switch(ProcType)
454 {
455 case PROCTYPE_IPU0:
456 pMemRegn = OMAP5430BENELLIPROC_addrTable;
457 numMemEntries = AddrTable_IPU_count;
458 break;
459 #ifndef IPC_SYSBIOS_SMP
460 case PROCTYPE_IPU1:
461 pMemRegn = OMAP5430BENELLIPROC_addrTable;
462 numMemEntries = AddrTable_IPU_count;
463 break;
464 #endif
465 case PROCTYPE_DSP:
466 pMemRegn = OMAP5430TESLAPROC_addrTable;
467 numMemEntries = AddrTable_DSP_count;
468 break;
469 }
471 #if !defined(IPC_BUILD_OPTIMIZE)
472 if (params == NULL) {
473 GT_setFailureReason (curTrace,
474 GT_4CLASS,
475 "OMAP5430BENELLIPROC_Params_init",
476 PROCESSOR_E_INVALIDARG,
477 "Argument of type (OMAP5430BENELLIPROC_Params *) "
478 "passed is null!");
479 }
480 else {
481 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
482 if (handle == NULL) {
483 params->numMemEntries = numMemEntries;
484 Memory_copy ((Ptr) params->memEntries,
485 pMemRegn,
486 (sizeof(ProcMgr_AddrInfo) * params->numMemEntries));
487 }
488 else {
489 /* Return updated OMAP5430BENELLIPROC instance specific parameters. */
490 Memory_copy (params,
491 &(procObject->params),
492 sizeof (OMAP5430BENELLIPROC_Params));
493 }
494 #if !defined(IPC_BUILD_OPTIMIZE)
495 }
496 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
498 GT_0trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_Params_init");
499 }
501 /*!
502 * @brief Function to create an instance of this Processor.
503 *
504 * @param name Name of the Processor instance.
505 * @param params Configuration parameters.
506 *
507 * @sa OMAP5430BENELLIPROC_delete
508 */
510 OMAP5430BENELLIPROC_Handle
511 OMAP5430BENELLIPROC_create (UInt16 procId,
512 const OMAP5430BENELLIPROC_Params * params)
513 {
514 #if !defined(IPC_BUILD_OPTIMIZE)
515 Int status = PROCESSOR_SUCCESS;
516 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
517 Processor_Object * handle = NULL;
518 OMAP5430BENELLIPROC_Object * object = NULL;
519 IArg key;
520 OMAP5430BENELLIPROC_ModuleObject * pState = NULL;
521 List_Params listParams;
523 switch(procId)
524 {
525 case PROCTYPE_IPU0:
526 pState = &OMAP5430IPU0PROC_state;
527 break;
528 #ifndef IPC_SYSBIOS_SMP
529 case PROCTYPE_IPU1:
530 pState = &OMAP5430IPU1PROC_state;
531 break;
532 #endif
533 case PROCTYPE_DSP:
534 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
535 break;
536 }
538 GT_2trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_create", procId, params);
540 GT_assert (curTrace, IS_VALID_PROCID (procId));
541 GT_assert (curTrace, (params != NULL));
543 #if !defined(IPC_BUILD_OPTIMIZE)
544 if (pState == NULL) {
545 /* Not setting status here since this function does not return status.*/
546 GT_setFailureReason (curTrace,
547 GT_4CLASS,
548 "OMAP5430BENELLIPROC_create",
549 PROCESSOR_E_INVALIDARG,
550 "Invalid procId specified");
551 }
552 else if (params == NULL) {
553 GT_setFailureReason (curTrace,
554 GT_4CLASS,
555 "OMAP5430BENELLIPROC_create",
556 PROCESSOR_E_INVALIDARG,
557 "params passed is NULL!");
558 }
559 else {
560 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
561 /* Enter critical section protection. */
562 key = IGateProvider_enter (pState->gateHandle);
563 #if !defined(IPC_BUILD_OPTIMIZE)
564 /* Check if the Processor already exists for specified procId. */
565 if (pState->procHandle!= NULL) {
566 status = PROCESSOR_E_ALREADYEXIST;
567 GT_setFailureReason (curTrace,
568 GT_4CLASS,
569 "OMAP5430BENELLIPROC_create",
570 status,
571 "Processor already exists for specified procId!");
572 }
573 else {
574 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
575 /* Allocate memory for the handle */
576 handle = (Processor_Object *) Memory_calloc (NULL,
577 sizeof (Processor_Object),
578 0,
579 NULL);
580 #if !defined(IPC_BUILD_OPTIMIZE)
581 if (handle == NULL) {
582 GT_setFailureReason (curTrace,
583 GT_4CLASS,
584 "OMAP5430BENELLIPROC_create",
585 PROCESSOR_E_MEMORY,
586 "Memory allocation failed for handle!");
587 }
588 else {
589 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
590 /* Populate the handle fields */
591 handle->procFxnTable.attach = &OMAP5430BENELLIPROC_attach;
592 handle->procFxnTable.detach = &OMAP5430BENELLIPROC_detach;
593 handle->procFxnTable.start = &OMAP5430BENELLIPROC_start;
594 handle->procFxnTable.stop = &OMAP5430BENELLIPROC_stop;
595 handle->procFxnTable.read = &OMAP5430BENELLIPROC_read;
596 handle->procFxnTable.write = &OMAP5430BENELLIPROC_write;
597 handle->procFxnTable.control = &OMAP5430BENELLIPROC_control;
598 handle->procFxnTable.map = &OMAP5430BENELLIPROC_map;
599 handle->procFxnTable.unmap = &OMAP5430BENELLIPROC_unmap;
600 handle->procFxnTable.translateAddr = &OMAP5430BENELLIPROC_translate;
601 handle->procFxnTable.virtToPhys = &OMAP5430BENELLI_virtToPhys;
602 handle->procFxnTable.getProcInfo = &OMAP5430BENELLIPROC_procInfo;
603 handle->state = ProcMgr_State_Unknown;
605 /* Allocate memory for the OMAP5430BENELLIPROC handle */
606 handle->object = Memory_calloc (NULL,
607 sizeof (OMAP5430BENELLIPROC_Object),
608 0,
609 NULL);
610 #if !defined(IPC_BUILD_OPTIMIZE)
611 if (handle->object == NULL) {
612 status = PROCESSOR_E_MEMORY;
613 GT_setFailureReason (curTrace,
614 GT_4CLASS,
615 "OMAP5430BENELLIPROC_create",
616 status,
617 "Memory allocation failed for handle->object!");
618 }
619 else {
620 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
621 handle->procId = procId;
622 object = (OMAP5430BENELLIPROC_Object *) handle->object;
623 object->halObject = NULL;
624 object->procHandle = (Processor_Handle)handle;
625 /* Copy params into instance object. */
626 Memory_copy (&(object->params),
627 (Ptr) params,
628 sizeof (OMAP5430BENELLIPROC_Params));
629 object->params.procHandle = object->procHandle;
631 /* Set the handle in the state object. */
632 pState->procHandle = handle->object;
634 /* Initialize the list of listeners */
635 List_Params_init(&listParams);
636 handle->registeredNotifiers = List_create(&listParams);
638 #if !defined(IPC_BUILD_OPTIMIZE)
639 if (handle->registeredNotifiers == NULL) {
640 /*! @retval PROCESSOR_E_FAIL OsalIsr_create failed */
641 status = PROCESSOR_E_FAIL;
642 GT_setFailureReason (curTrace,
643 GT_4CLASS,
644 "OMAP5430BENELLIPROC_create",
645 status,
646 "List_create failed");
647 }
648 else {
649 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
651 handle->notifiersLock =
652 OsalMutex_create(OsalMutex_Type_Interruptible);
654 #if !defined(IPC_BUILD_OPTIMIZE)
655 if (handle->notifiersLock == NULL) {
656 /*! @retval PROCESSOR_E_FAIL OsalIsr_create failed*/
657 status = PROCESSOR_E_FAIL;
658 GT_setFailureReason (curTrace,
659 GT_4CLASS,
660 "OMAP5430BENELLIPROC_create",
661 status,
662 "OsalMutex_create failed");
663 }
664 }
665 }
666 }
667 }
668 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
670 /* Leave critical section protection. */
671 IGateProvider_leave (pState->gateHandle, key);
672 #if !defined(IPC_BUILD_OPTIMIZE)
673 }
674 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
676 #if !defined(IPC_BUILD_OPTIMIZE)
677 if (status < 0) {
678 if (handle != NULL) {
679 if (handle->registeredNotifiers != NULL) {
680 List_delete (&handle->registeredNotifiers);
681 }
682 if (handle->object != NULL) {
683 Memory_free (NULL,
684 handle->object,
685 sizeof (OMAP5430BENELLIPROC_Object));
686 }
687 Memory_free (NULL, handle, sizeof (Processor_Object));
688 }
689 /*! @retval NULL Function failed */
690 handle = NULL;
691 }
692 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
694 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_create", handle);
696 /*! @retval Valid-Handle Operation successful */
697 return (void*) handle;
698 }
701 /*!
702 * @brief Function to delete an instance of this Processor.
703 *
704 * The user provided pointer to the handle is reset after
705 * successful completion of this function.
706 *
707 * @param handlePtr Pointer to Handle to the Processor instance
708 *
709 * @sa OMAP5430BENELLIPROC_create
710 */
711 Int
712 OMAP5430BENELLIPROC_delete (OMAP5430BENELLIPROC_Handle * handlePtr)
713 {
714 Int status = PROCESSOR_SUCCESS;
715 OMAP5430BENELLIPROC_Object * object = NULL;
716 Processor_Object * handle = NULL;
717 IArg key = NULL;
718 OMAP5430BENELLIPROC_ModuleObject * pState = NULL;
719 List_Elem * elem = NULL;
720 Processor_RegisterElem * regElem = NULL;
723 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_delete", handlePtr);
725 GT_assert (curTrace, (handlePtr != NULL));
726 GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL)));
728 #if !defined(IPC_BUILD_OPTIMIZE)
729 if (handlePtr == NULL) {
730 /*! @retval PROCESSOR_E_INVALIDARG Invalid NULL handlePtr pointer
731 specified*/
732 status = PROCESSOR_E_INVALIDARG;
733 GT_setFailureReason (curTrace,
734 GT_4CLASS,
735 "OMAP5430BENELLIPROC_delete",
736 status,
737 "Invalid NULL handlePtr pointer specified");
738 }
739 else if (*handlePtr == NULL) {
740 /*! @retval PROCESSOR_E_HANDLE Invalid NULL *handlePtr specified */
741 status = PROCESSOR_E_HANDLE;
742 GT_setFailureReason (curTrace,
743 GT_4CLASS,
744 "OMAP5430BENELLIPROC_delete",
745 status,
746 "Invalid NULL *handlePtr specified");
747 }
748 else {
749 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
750 handle = (Processor_Object *) (*handlePtr);
751 /* Enter critical section protection. */
752 if (handle->object != NULL) {
753 object = (OMAP5430BENELLIPROC_Object *) handle->object;
754 switch (handle->procId)
755 {
756 case PROCTYPE_IPU0:
757 pState = &OMAP5430IPU0PROC_state;
758 break;
759 #ifndef IPC_SYSBIOS_SMP
760 case PROCTYPE_IPU1:
761 pState = &OMAP5430IPU1PROC_state;
762 break;
763 #endif
764 case PROCTYPE_DSP:
765 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
766 break;
767 }
768 }
769 #if !defined(IPC_BUILD_OPTIMIZE)
770 if (pState == NULL) {
771 GT_setFailureReason (curTrace,
772 GT_4CLASS,
773 "OMAP5430BENELLIPROC_delete",
774 PROCESSOR_E_INVALIDARG,
775 "Unsupported procType");
776 return PROCESSOR_E_INVALIDARG;
777 }
778 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
780 key = IGateProvider_enter (pState->gateHandle);
782 /* Reset handle in PwrMgr handle array. */
783 GT_assert (curTrace, IS_VALID_PROCID (handle->procId));
784 pState->procHandle = NULL;
786 /* Free memory used for the PROC object. */
787 Memory_free (NULL,
788 handle->object,
789 sizeof (Ptr));
790 handle->object = NULL;
792 /*
793 * Check the list of listeners to see if any are remaining
794 * and reply to them
795 */
796 OsalMutex_delete(&handle->notifiersLock);
798 while ((elem = List_dequeue(handle->registeredNotifiers)) != NULL) {
799 regElem = (Processor_RegisterElem *)elem;
801 /* Check if there is an associated timer and cancel it */
802 if (regElem->timer != -1) {
803 struct itimerspec value ;
804 value.it_value.tv_sec = 0;
805 value.it_value.tv_nsec = 0;
806 value.it_interval.tv_sec = 0;
807 value.it_interval.tv_nsec = 0;
808 timer_settime(regElem->timer, 0, &value, NULL);
810 timer_delete(regElem->timer);
811 regElem->timer = -1;
812 }
814 /* Call the callback function so it can clean up. */
815 regElem->info->cbFxn(handle->procId,
816 NULL,
817 handle->state,
818 handle->state,
819 ProcMgr_EventStatus_Canceled,
820 regElem->info->arg);
821 /* Free the memory */
822 Memory_free(NULL, regElem, sizeof(Processor_RegisterElem));
823 }
825 /* Delete the list of listeners */
826 List_delete(&handle->registeredNotifiers);
828 /* Free memory used for the Processor object. */
829 Memory_free (NULL, handle, sizeof (Processor_Object));
830 *handlePtr = NULL;
832 /* Leave critical section protection. */
833 IGateProvider_leave (pState->gateHandle, key);
834 #if !defined(IPC_BUILD_OPTIMIZE)
835 }
836 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
838 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_delete", status);
840 /*! @retval PROCESSOR_SUCCESS Operation successful */
841 return (status);
842 }
845 /*!
846 * @brief Function to open a handle to an instance of this Processor. This
847 * function is called when access to the Processor is required from
848 * a different process.
849 *
850 * @param handlePtr Handle to the Processor instance
851 * @param procId Processor ID addressed by this Processor instance.
852 *
853 * @sa OMAP5430BENELLIPROC_close
854 */
855 Int
856 OMAP5430BENELLIPROC_open (OMAP5430BENELLIPROC_Handle * handlePtr, UInt16 procId)
857 {
858 Int status = PROCESSOR_SUCCESS;
859 OMAP5430BENELLIPROC_ModuleObject * pState = NULL;
861 GT_2trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_open",
862 handlePtr, procId);
864 GT_assert (curTrace, (handlePtr != NULL));
865 GT_assert (curTrace, IS_VALID_PROCID (procId));
867 switch(procId)
868 {
869 case PROCTYPE_IPU0:
870 pState = &OMAP5430IPU0PROC_state;
871 break;
872 #ifndef IPC_SYSBIOS_SMP
873 case PROCTYPE_IPU1:
874 pState = &OMAP5430IPU1PROC_state;
875 break;
876 #endif
877 case PROCTYPE_DSP:
878 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
879 break;
880 }
882 #if !defined(IPC_BUILD_OPTIMIZE)
883 if (handlePtr == NULL) {
884 /*! @retval PROCESSOR_E_HANDLE Invalid NULL handlePtr specified */
885 status = PROCESSOR_E_HANDLE;
886 GT_setFailureReason (curTrace,
887 GT_4CLASS,
888 "OMAP5430BENELLIPROC_open",
889 status,
890 "Invalid NULL handlePtr specified");
891 }
892 else if (pState == NULL) {
893 /*! @retval PROCESSOR_E_INVALIDARG Invalid procId specified */
894 status = PROCESSOR_E_INVALIDARG;
895 GT_setFailureReason (curTrace,
896 GT_4CLASS,
897 "OMAP5430BENELLIPROC_open",
898 status,
899 "Invalid procId specified");
900 }
901 else {
902 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
903 /* Initialize return parameter handle. */
904 *handlePtr = NULL;
906 /* Check if the PwrMgr exists and return the handle if found. */
907 if (pState->procHandle == NULL) {
908 /*! @retval PROCESSOR_E_NOTFOUND Specified instance not found */
909 status = PROCESSOR_E_NOTFOUND;
910 GT_setFailureReason (curTrace,
911 GT_4CLASS,
912 "OMAP5430BENELLIPROC_open",
913 status,
914 "Specified instance does not exist!");
915 }
916 else {
917 *handlePtr = pState->procHandle;
918 }
919 #if !defined(IPC_BUILD_OPTIMIZE)
920 }
921 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
923 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_open", status);
925 /*! @retval PROCESSOR_SUCCESS Operation successful */
926 return status;
927 }
930 /*!
931 * @brief Function to close a handle to an instance of this Processor.
932 *
933 * @param handlePtr Pointer to Handle to the Processor instance
934 *
935 * @sa OMAP5430BENELLIPROC_open
936 */
937 Int
938 OMAP5430BENELLIPROC_close (OMAP5430BENELLIPROC_Handle * handlePtr)
939 {
940 Int status = PROCESSOR_SUCCESS;
942 GT_1trace (curTrace, GT_ENTER, "OMAP5430M3VIDEOPROC_close", handlePtr);
944 GT_assert (curTrace, (handlePtr != NULL));
945 GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL)));
947 #if !defined(IPC_BUILD_OPTIMIZE)
948 if (handlePtr == NULL) {
949 /*! @retval PROCESSOR_E_INVALIDARG Invalid NULL handlePtr pointer
950 specified*/
951 status = PROCESSOR_E_INVALIDARG;
952 GT_setFailureReason (curTrace,
953 GT_4CLASS,
954 "OMAP5430BENELLIPROC_close",
955 status,
956 "Invalid NULL handlePtr pointer specified");
957 }
958 else if (*handlePtr == NULL) {
959 /*! @retval PROCESSOR_E_HANDLE Invalid NULL *handlePtr specified */
960 status = PROCESSOR_E_HANDLE;
961 GT_setFailureReason (curTrace,
962 GT_4CLASS,
963 "OMAP5430BENELLIPROC_close",
964 status,
965 "Invalid NULL *handlePtr specified");
966 }
967 else {
968 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
969 /* Nothing to be done for close. */
970 #if !defined(IPC_BUILD_OPTIMIZE)
971 }
972 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
974 GT_1trace (curTrace, GT_LEAVE, "OMAP5430M3VIDEOPROC_close", status);
976 /*! @retval PROCESSOR_SUCCESS Operation successful */
977 return status;
978 }
981 /* =============================================================================
982 * APIs called by Processor module (part of function table interface)
983 * =============================================================================
984 */
985 /*!
986 * @brief Function to initialize the slave processor
987 *
988 * @param handle Handle to the Processor instance
989 * @param params Attach parameters
990 *
991 * @sa OMAP5430BENELLIPROC_detach
992 */
993 Int
994 OMAP5430BENELLIPROC_attach (Processor_Handle handle,
995 Processor_AttachParams * params)
996 {
998 Int status = PROCESSOR_SUCCESS ;
999 Processor_Object * procHandle = (Processor_Object *) handle;
1000 OMAP5430BENELLIPROC_Object * object = NULL;
1001 ProcMgr_AddrInfo * me;
1002 OMAP5430BENELLIPROC_ModuleObject * pState;
1003 OMAP5430BENELLI_HalMmuCtrlArgs_Enable enableArgs;
1004 UInt32 i = 0;
1005 UInt32 index = 0;
1006 Ipc_MemEntry * entry;
1007 Ipc_MemEntry_Block memBlock;
1008 ProcMgr_AddrInfo * pMemRegn = NULL;
1009 UInt32 * AddrTable_count = NULL;
1011 GT_2trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_attach", handle, params);
1013 GT_assert (curTrace, (handle != NULL));
1014 GT_assert (curTrace, (params != NULL));
1016 switch(procHandle->procId)
1017 {
1018 case PROCTYPE_IPU0:
1019 pState = &OMAP5430IPU0PROC_state;
1020 pMemRegn = OMAP5430BENELLIPROC_addrTable;
1021 AddrTable_count = &AddrTable_IPU_count;
1022 break;
1023 #ifndef IPC_SYSBIOS_SMP
1024 case PROCTYPE_IPU1:
1025 pState = &OMAP5430IPU1PROC_state;
1026 pMemRegn = OMAP5430BENELLIPROC_addrTable;
1027 AddrTable_count = &AddrTable_IPU_count;
1028 break;
1029 #endif
1030 case PROCTYPE_DSP:
1031 pState = (OMAP5430BENELLIPROC_ModuleObject *)&OMAP5430DSPPROC_state;
1032 pMemRegn = OMAP5430TESLAPROC_addrTable;
1033 AddrTable_count = &AddrTable_DSP_count;
1034 break;
1035 }
1037 #if !defined(IPC_BUILD_OPTIMIZE)
1038 if (handle == NULL) {
1039 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1040 status = PROCESSOR_E_HANDLE;
1041 GT_setFailureReason (curTrace,
1042 GT_4CLASS,
1043 "OMAP5430BENELLIPROC_attach",
1044 status,
1045 "Invalid handle specified");
1046 }
1047 else if (params == NULL) {
1048 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1049 status = PROCESSOR_E_INVALIDARG;
1050 GT_setFailureReason (curTrace,
1051 GT_4CLASS,
1052 "OMAP5430BENELLIPROC_attach",
1053 status,
1054 "Invalid params specified");
1055 }
1056 else {
1057 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1058 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
1059 GT_assert (curTrace, (object != NULL));
1061 /* Added for Netra Benelli core0 is cortex M3 */
1062 params->procArch = Processor_ProcArch_M3;
1063 GT_0trace (curTrace,
1064 GT_2CLASS,
1065 " OMAP5430BENELLIPROC_attach: Mapping memory regions");
1067 object->pmHandle = params->pmHandle;
1068 GT_0trace(curTrace, GT_1CLASS,
1069 "OMAP5430BENELLIPROC_attach: Mapping memory regions");
1071 /* search for dsp memory map */
1072 status = RscTable_process(procHandle->procId,
1073 TRUE, &memBlock.numEntries);
1074 if (status < 0 || memBlock.numEntries > IPC_MAX_MEMENTRIES) {
1075 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1076 status = PROCESSOR_E_INVALIDARG;
1077 GT_setFailureReason (curTrace,
1078 GT_4CLASS,
1079 "OMAP5430BENELLIPROC_attach",
1080 status,
1081 "Failed to process resource table");
1082 }
1083 else {
1084 status = RscTable_getMemEntries(procHandle->procId,
1085 memBlock.memEntries,
1086 &memBlock.numEntries);
1087 if (status < 0) {
1088 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1089 status = PROCESSOR_E_INVALIDARG;
1090 GT_setFailureReason (curTrace,
1091 GT_4CLASS,
1092 "OMAP5430BENELLIPROC_attach",
1093 status,
1094 "Failed to get resource table memEntries");
1095 }
1096 }
1098 /* update translation tables with memory map */
1099 for (i = 0; (i < memBlock.numEntries)
1100 && (memBlock.memEntries[i].isValid) && (status >= 0); i++) {
1102 entry = &memBlock.memEntries[i];
1104 if (entry->map == FALSE) {
1105 /* update table with entries which don't require mapping */
1106 if (*AddrTable_count != AddrTable_SIZE) {
1107 me = &pMemRegn[*AddrTable_count];
1109 me->addr[ProcMgr_AddrType_MasterKnlVirt] = -1u;
1110 me->addr[ProcMgr_AddrType_MasterUsrVirt] = -1u;
1111 me->addr[ProcMgr_AddrType_MasterPhys] =
1112 entry->masterPhysAddr;
1113 me->addr[ProcMgr_AddrType_SlaveVirt] = entry->slaveVirtAddr;
1114 me->addr[ProcMgr_AddrType_SlavePhys] = -1u;
1115 me->size = entry->size;
1116 me->isCached = entry->isCached;
1117 me->mapMask = entry->mapMask;
1119 (*AddrTable_count)++;
1120 }
1121 else {
1122 status = PROCESSOR_E_FAIL;
1123 GT_setFailureReason(curTrace, GT_4CLASS,
1124 "OMAP5430BENELLIPROC_attach", status,
1125 "AddrTable_SIZE reached!");
1126 }
1127 }
1128 else if (entry->map == TRUE) {
1129 /* send these entries back to ProcMgr for mapping */
1130 index = object->params.numMemEntries;
1132 if (index != ProcMgr_MAX_MEMORY_REGIONS) {
1133 me = &object->params.memEntries[index];
1135 me->addr[ProcMgr_AddrType_MasterKnlVirt] = -1u;
1136 me->addr[ProcMgr_AddrType_MasterUsrVirt] = -1u;
1137 me->addr[ProcMgr_AddrType_MasterPhys] =
1138 entry->masterPhysAddr;
1139 me->addr[ProcMgr_AddrType_SlaveVirt] = entry->slaveVirtAddr;
1140 me->addr[ProcMgr_AddrType_SlavePhys] = -1u;
1141 me->size = entry->size;
1142 me->isCached = entry->isCached;
1143 me->mapMask = entry->mapMask;
1145 object->params.numMemEntries++;
1146 }
1147 else {
1148 status = PROCESSOR_E_FAIL;
1149 GT_setFailureReason(curTrace, GT_4CLASS,
1150 "OMAP5430BENELLIPROC_attach", status,
1151 "ProcMgr_MAX_MEMORY_REGIONS reached!");
1152 }
1153 }
1154 else {
1155 status = PROCESSOR_E_INVALIDARG;
1156 GT_setFailureReason(curTrace, GT_4CLASS,
1157 "OMAP5430BENELLIPROC_attach", status,
1158 "Memory map has entry with invalid 'map' value");
1159 }
1160 } /* for (...) */
1162 if (status >= 0) {
1163 /* populate the return params */
1164 params->numMemEntries = object->params.numMemEntries;
1165 memcpy((Ptr)params->memEntries, (Ptr)object->params.memEntries,
1166 sizeof(ProcMgr_AddrInfo) * params->numMemEntries);
1168 status = OMAP5430BENELLI_halInit (&(object->halObject),
1169 &object->params,
1170 procHandle->procId);
1171 #if !defined(IPC_BUILD_OPTIMIZE)
1172 if (status < 0) {
1173 GT_setFailureReason (curTrace,
1174 GT_4CLASS,
1175 "OMAP5430BENELLIPROC_attach",
1176 status,
1177 "OMAP5430BENELLI_halInit failed");
1178 }
1179 else {
1180 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1182 if ( (procHandle->bootMode == ProcMgr_BootMode_Boot)
1183 || (procHandle->bootMode == ProcMgr_BootMode_NoLoad_Pwr)) {
1185 #if !defined(IPC_BUILD_OPTIMIZE)
1186 if (status < 0) {
1187 GT_setFailureReason (curTrace,
1188 GT_4CLASS,
1189 "OMAP5430BENELLIPROC_attach",
1190 status,
1191 "Failed to reset the slave processor");
1192 }
1193 else {
1194 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1195 GT_0trace (curTrace,
1196 GT_1CLASS,
1197 " OMAP5430BENELLIPROC_attach: Slave is now "
1198 "in reset!");
1200 if (procHandle->procId == PROCTYPE_IPU0 ||
1201 procHandle->procId == PROCTYPE_DSP) {
1202 /* Enable MMU */
1203 GT_0trace (curTrace,
1204 GT_2CLASS,
1205 "OMAP5430BENELLIPROC_attach: "
1206 "Enabling Slave MMU ...");
1207 enableArgs.memEntries = NULL;
1208 enableArgs.numMemEntries = 0;
1209 status = OMAP5430BENELLI_halMmuCtrl (
1210 object->halObject,
1211 Processor_MmuCtrlCmd_Enable,
1212 &enableArgs);
1213 #if !defined(IPC_BUILD_OPTIMIZE)
1214 if (status < 0) {
1215 GT_setFailureReason (curTrace,
1216 GT_4CLASS,
1217 "OMAP5430BENELLIPROC_attach",
1218 status,
1219 "Failed to enable the slave MMU");
1220 }
1221 else if (procHandle->procId == PROCTYPE_IPU0) {
1222 #endif
1223 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1224 Processor_ResetCtrlCmd_MMU_Release);
1225 if (status < 0) {
1226 /*! @retval status */
1227 GT_setFailureReason (curTrace,
1228 GT_4CLASS,
1229 "OMAP5430BENELLI_halResetCtrl",
1230 status,
1231 "Reset MMU_Release failed");
1232 }
1233 #if !defined(IPC_BUILD_OPTIMIZE)
1234 }
1235 }
1236 }
1237 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1238 }
1239 }
1240 #if !defined(IPC_BUILD_OPTIMIZE)
1241 }
1242 }
1243 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1245 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_attach",status);
1247 /*! @retval PROCESSOR_SUCCESS Operation successful */
1248 return status;
1250 }
1253 /*!
1254 * @brief Function to detach from the Processor.
1255 *
1256 * @param handle Handle to the Processor instance
1257 *
1258 * @sa OMAP5430BENELLIPROC_attach
1259 */
1260 Int
1261 OMAP5430BENELLIPROC_detach (Processor_Handle handle)
1262 {
1263 Int status = PROCESSOR_SUCCESS;
1264 Int tmpStatus = PROCESSOR_SUCCESS;
1265 Processor_Object * procHandle = (Processor_Object *) handle;
1266 OMAP5430BENELLIPROC_Object * object = NULL;
1267 Int i = 0;
1268 ProcMgr_AddrInfo * ai;
1269 ProcMgr_AddrInfo * pMemRegn = NULL;
1270 UInt32 * AddrTable_count = NULL;
1272 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_detach", handle);
1274 GT_assert (curTrace, (handle != NULL));
1276 switch(procHandle->procId)
1277 {
1278 case PROCTYPE_IPU0:
1279 pMemRegn = OMAP5430BENELLIPROC_addrTable;
1280 AddrTable_count = &AddrTable_IPU_count;
1281 break;
1282 #ifndef IPC_SYSBIOS_SMP
1283 case PROCTYPE_IPU1:
1284 pMemRegn = OMAP5430BENELLIPROC_addrTable;
1285 AddrTable_count = &AddrTable_IPU_count;
1286 break;
1287 #endif
1288 case PROCTYPE_DSP:
1289 pMemRegn = OMAP5430TESLAPROC_addrTable;
1290 AddrTable_count = &AddrTable_DSP_count;
1291 break;
1292 }
1294 #if !defined(IPC_BUILD_OPTIMIZE)
1295 if (handle == NULL) {
1296 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1297 status = PROCESSOR_E_HANDLE;
1298 GT_setFailureReason (curTrace,
1299 GT_4CLASS,
1300 "OMAP5430BENELLIPROC_detach",
1301 PROCESSOR_E_HANDLE,
1302 "Invalid handle specified");
1303 }
1304 else {
1305 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1306 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
1307 GT_assert (curTrace, (object != NULL));
1309 if ( (procHandle->bootMode == ProcMgr_BootMode_Boot)
1310 || (procHandle->bootMode == ProcMgr_BootMode_NoLoad_Pwr)) {
1311 if (procHandle->procId == PROCTYPE_IPU0) {
1312 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1313 Processor_ResetCtrlCmd_MMU_Reset);
1314 if (status < 0) {
1315 /*! @retval status */
1316 GT_setFailureReason (curTrace,
1317 GT_4CLASS,
1318 "OMAP5430BENELLI_halResetCtrl",
1319 status,
1320 "Reset MMU failed");
1321 }
1322 else {
1323 /* Disable MMU */
1324 GT_0trace (curTrace,
1325 GT_2CLASS,
1326 " OMAP5430BENELLIPROC_detach: "
1327 "Disabling Slave MMU ...");
1328 status = OMAP5430BENELLI_halMmuCtrl (object->halObject,
1329 Processor_MmuCtrlCmd_Disable,
1330 NULL);
1331 #if !defined(IPC_BUILD_OPTIMIZE)
1332 if (status < 0) {
1333 GT_setFailureReason (curTrace,
1334 GT_4CLASS,
1335 "OMAP5430BENELLIPROC_detach",
1336 status,
1337 "Failed to disable the slave MMU");
1338 }
1339 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1340 }
1341 }
1342 else if (procHandle->procId == PROCTYPE_DSP) {
1343 /* Disable MMU */
1344 GT_0trace (curTrace,
1345 GT_2CLASS,
1346 " OMAP5430BENELLIPROC_detach: "
1347 "Disabling Slave MMU ...");
1348 status = OMAP5430BENELLI_halMmuCtrl (object->halObject,
1349 Processor_MmuCtrlCmd_Disable,
1350 NULL);
1351 #if !defined(IPC_BUILD_OPTIMIZE)
1352 if (status < 0) {
1353 GT_setFailureReason (curTrace,
1354 GT_4CLASS,
1355 "OMAP5430BENELLIPROC_detach",
1356 status,
1357 "Failed to disable the slave MMU");
1358 }
1359 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1360 }
1362 /* delete all dynamically added entries */
1363 for (i = 0; i < *AddrTable_count; i++) {
1364 ai = &pMemRegn[i];
1365 ai->addr[ProcMgr_AddrType_MasterKnlVirt] = -1u;
1366 ai->addr[ProcMgr_AddrType_MasterUsrVirt] = -1u;
1367 ai->addr[ProcMgr_AddrType_MasterPhys] = -1u;
1368 ai->addr[ProcMgr_AddrType_SlaveVirt] = -1u;
1369 ai->addr[ProcMgr_AddrType_SlavePhys] = -1u;
1370 ai->size = 0u;
1371 ai->isCached = FALSE;
1372 ai->mapMask = 0u;
1373 ai->isMapped = FALSE;
1374 ai->refCount = 0u;
1375 }
1376 object->params.numMemEntries = 0;
1377 *AddrTable_count = 0;
1379 //No need to reset.. that will be done in STOP
1380 /* tmpStatus = OMAP5430BENELLI_halResetCtrl (object->halObject,
1381 Processor_ResetCtrlCmd_Reset,
1382 NULL);
1383 GT_0trace (curTrace,
1384 GT_2CLASS,
1385 " OMAP5430BENELLIPROC_detach: Slave processor is "
1386 "now in reset");*/
1387 #if !defined(IPC_BUILD_OPTIMIZE)
1388 if ((tmpStatus < 0) && (status >= 0)) {
1389 status = tmpStatus;
1390 GT_setFailureReason (curTrace,
1391 GT_4CLASS,
1392 "OMAP5430BENELLIPROC_detach",
1393 status,
1394 "Failed to reset the slave processor");
1395 }
1396 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1397 }
1399 GT_0trace (curTrace,
1400 GT_2CLASS,
1401 " OMAP5430BENELLIPROC_detach: Unmapping memory regions");
1403 tmpStatus = OMAP5430BENELLI_halExit(object->halObject, &object->params);
1404 #if !defined(IPC_BUILD_OPTIMIZE)
1405 if ((tmpStatus < 0) && (status >= 0)) {
1406 status = tmpStatus;
1407 GT_setFailureReason (curTrace,
1408 GT_4CLASS,
1409 "OMAP5430BENELLIPROC_detach",
1410 status,
1411 "Failed to finalize HAL object");
1412 }
1413 }
1414 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1416 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_detach", status);
1418 /*! @retval PROCESSOR_SUCCESS Operation successful */
1419 return status;
1420 }
1423 /*!
1424 * @brief Function to start the slave processor
1425 *
1426 * Start the slave processor running from its entry point.
1427 * Depending on the boot mode, this involves configuring the boot
1428 * address and releasing the slave from reset.
1429 *
1430 * @param handle Handle to the Processor instance
1431 *
1432 * @sa OMAP5430BENELLIPROC_stop, OMAP5430BENELLIPROC_halBootCtrl,
1433 * OMAP5430BENELLIPROC_halResetCtrl
1434 */
1435 Int
1436 OMAP5430BENELLIPROC_start (Processor_Handle handle,
1437 UInt32 entryPt,
1438 Processor_StartParams * params)
1439 {
1440 Int status = PROCESSOR_SUCCESS ;
1441 Processor_Object * procHandle = (Processor_Object *) handle;
1442 OMAP5430BENELLIPROC_Object * object = procHandle->object;
1443 Memory_MapInfo sysCtrlMapInfo;
1444 Memory_UnmapInfo sysCtrlUnmapInfo;
1446 GT_3trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_start",
1447 handle, entryPt, params);
1449 GT_assert (curTrace, (handle != NULL));
1450 GT_assert (curTrace, (params != NULL));
1452 #if !defined(IPC_BUILD_OPTIMIZE)
1453 if (handle == NULL) {
1454 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1455 status = PROCESSOR_E_HANDLE;
1456 GT_setFailureReason (curTrace,
1457 GT_4CLASS,
1458 "OMAP5430BENELLIPROC_start",
1459 status,
1460 "Invalid handle specified");
1461 }
1462 else if (params == NULL) {
1463 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1464 status = PROCESSOR_E_INVALIDARG;
1465 GT_setFailureReason (curTrace,
1466 GT_4CLASS,
1467 "OMAP5430BENELLIPROC_start",
1468 status,
1469 "Invalid params specified");
1470 }
1471 else {
1472 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1473 if (handle->procId == MultiProc_getId("DSP")) {
1474 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1475 Processor_ResetCtrlCmd_MMU_Release);
1476 if (status < 0) {
1477 /*! @retval status */
1478 GT_setFailureReason (curTrace,
1479 GT_4CLASS,
1480 "OMAP5430BENELLI_halResetCtrl",
1481 status,
1482 "Reset MMU_Release failed");
1483 }
1484 }
1486 if (status >= 0) {
1487 if(handle->procId != MultiProc_getId("DSP")) {
1488 status = ipu_setup(object->halObject, object->params.memEntries,
1489 object->params.numMemEntries);
1490 }
1491 else {
1492 status = tesla_setup(object->halObject,
1493 object->params.memEntries,
1494 object->params.numMemEntries);
1495 }
1497 if (status < 0) {
1498 /*! @retval status */
1499 GT_setFailureReason (curTrace,
1500 GT_4CLASS,
1501 "OMAP5430BENELLI_halResetCtrl",
1502 status,
1503 "ipu_setup failed");
1504 }
1505 else {
1506 if (handle->procId == MultiProc_getId("DSP")) {
1507 /* Get the user virtual address of the PRM base */
1508 sysCtrlMapInfo.src = 0x4A002000;
1509 sysCtrlMapInfo.size = 0x1000;
1510 sysCtrlMapInfo.isCached = FALSE;
1512 status = Memory_map (&sysCtrlMapInfo);
1513 if (status < 0) {
1514 status = PROCESSOR_E_FAIL;
1515 GT_setFailureReason (curTrace,
1516 GT_4CLASS,
1517 "ProcMgr_load",
1518 status,
1519 "Memory_map failed");
1520 }
1521 else {
1522 *(UInt32 *)(sysCtrlMapInfo.dst + 0x304) = entryPt;
1524 sysCtrlUnmapInfo.addr = sysCtrlMapInfo.dst;
1525 sysCtrlUnmapInfo.size = sysCtrlMapInfo.size;
1526 sysCtrlUnmapInfo.isCached = FALSE;
1527 Memory_unmap (&sysCtrlUnmapInfo);
1528 }
1529 }
1530 if (status >= 0) {
1531 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1532 Processor_ResetCtrlCmd_Release);
1533 }
1534 if (status < 0) {
1535 /*! @retval status */
1536 GT_setFailureReason (curTrace,
1537 GT_4CLASS,
1538 "OMAP5430BENELLI_halResetCtrl",
1539 status,
1540 "Reset Release failed");
1541 }
1542 }
1543 }
1544 #if !defined(IPC_BUILD_OPTIMIZE)
1545 }
1546 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1547 return status;
1548 }
1551 /*!
1552 * @brief Function to stop the slave processor
1553 *
1554 * Stop the execution of the slave processor. Depending on the boot
1555 * mode, this may result in placing the slave processor in reset.
1556 *
1557 * @param handle Handle to the Processor instance
1558 *
1559 * @sa OMAP5430BENELLIPROC_start, OMAP5430BENELLIPROC_halResetCtrl
1560 */
1561 Int
1562 OMAP5430BENELLIPROC_stop (Processor_Handle handle)
1563 {
1564 Int status = PROCESSOR_SUCCESS ;
1565 Processor_Object * procHandle = (Processor_Object *) handle;
1566 OMAP5430BENELLIPROC_Object * object = procHandle->object;
1568 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_stop", handle);
1570 GT_assert (curTrace, (handle != NULL));
1572 #if !defined(IPC_BUILD_OPTIMIZE)
1573 if (handle == NULL) {
1574 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1575 status = PROCESSOR_E_HANDLE;
1576 GT_setFailureReason (curTrace,
1577 GT_4CLASS,
1578 "OMAP5430BENELLIPROC_stop",
1579 status,
1580 "Invalid handle specified");
1581 }
1582 else {
1583 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1584 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1585 Processor_ResetCtrlCmd_Reset);
1586 if (status < 0) {
1587 /*! @retval status */
1588 GT_setFailureReason (curTrace,
1589 GT_4CLASS,
1590 "OMAP5430BENELLI_halResetCtrl",
1591 status,
1592 "Reset failed");
1593 }
1595 ipu_destroy(object->halObject);
1596 if (procHandle->procId == MultiProc_getId("DSP")) {
1597 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1598 Processor_ResetCtrlCmd_MMU_Reset);
1599 if (status < 0) {
1600 /*! @retval status */
1601 GT_setFailureReason (curTrace,
1602 GT_4CLASS,
1603 "OMAP5430BENELLI_halResetCtrl",
1604 status,
1605 "Reset MMU failed");
1606 }
1607 }
1609 #if !defined(IPC_BUILD_OPTIMIZE)
1610 }
1611 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1613 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_stop", status);
1615 /*! @retval PROCESSOR_SUCCESS Operation successful */
1616 return status;
1617 }
1620 /*!
1621 * @brief Function to read from the slave processor's memory.
1622 *
1623 * Read from the slave processor's memory and copy into the
1624 * provided buffer.
1625 *
1626 * @param handle Handle to the Processor instance
1627 * @param procAddr Address in host processor's address space of the
1628 * memory region to read from.
1629 * @param numBytes IN/OUT parameter. As an IN-parameter, it takes in the
1630 * number of bytes to be read. When the function
1631 * returns, this parameter contains the number of bytes
1632 * actually read.
1633 * @param buffer User-provided buffer in which the slave processor's
1634 * memory contents are to be copied.
1635 *
1636 * @sa OMAP5430BENELLIPROC_write
1637 */
1638 Int
1639 OMAP5430BENELLIPROC_read (Processor_Handle handle,
1640 UInt32 procAddr,
1641 UInt32 * numBytes,
1642 Ptr buffer)
1643 {
1644 Int status = PROCESSOR_SUCCESS ;
1645 UInt8 * procPtr8 = NULL;
1647 GT_4trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_read",
1648 handle, procAddr, numBytes, buffer);
1650 GT_assert (curTrace, (handle != NULL));
1651 GT_assert (curTrace, (numBytes != NULL));
1652 GT_assert (curTrace, (buffer != NULL));
1654 #if !defined(IPC_BUILD_OPTIMIZE)
1655 if (handle == NULL) {
1656 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1657 status = PROCESSOR_E_HANDLE;
1658 GT_setFailureReason (curTrace,
1659 GT_4CLASS,
1660 "OMAP5430BENELLIPROC_read",
1661 status,
1662 "Invalid handle specified");
1663 }
1664 else if (numBytes == 0) {
1665 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1666 status = PROCESSOR_E_INVALIDARG;
1667 GT_setFailureReason (curTrace,
1668 GT_4CLASS,
1669 "OMAP5430BENELLIPROC_read",
1670 status,
1671 "Invalid numBytes specified");
1672 }
1673 else if (buffer == NULL) {
1674 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1675 status = PROCESSOR_E_INVALIDARG;
1676 GT_setFailureReason (curTrace,
1677 GT_4CLASS,
1678 "OMAP5430BENELLIPROC_read",
1679 status,
1680 "Invalid buffer specified");
1681 }
1682 else {
1683 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1684 procPtr8 = (UInt8 *) procAddr ;
1685 buffer = Memory_copy (buffer, procPtr8, *numBytes);
1686 GT_assert (curTrace, (buffer != (UInt32) NULL));
1687 #if !defined(IPC_BUILD_OPTIMIZE)
1688 if (buffer == (UInt32) NULL) {
1689 /*! @retval PROCESSOR_E_FAIL Failed in Memory_copy */
1690 status = PROCESSOR_E_FAIL;
1691 GT_setFailureReason (curTrace,
1692 GT_4CLASS,
1693 "OMAP5430BENELLIPROC_read",
1694 status,
1695 "Failed in Memory_copy");
1696 *numBytes = 0;
1697 }
1698 }
1699 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1701 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_read",status);
1703 /*! @retval PROCESSOR_SUCCESS Operation successful */
1704 return status;
1705 }
1708 /*!
1709 * @brief Function to write into the slave processor's memory.
1710 *
1711 * Read from the provided buffer and copy into the slave
1712 * processor's memory.
1713 *
1714 * @param handle Handle to the Processor object
1715 * @param procAddr Address in host processor's address space of the
1716 * memory region to write into.
1717 * @param numBytes IN/OUT parameter. As an IN-parameter, it takes in the
1718 * number of bytes to be written. When the function
1719 * returns, this parameter contains the number of bytes
1720 * actually written.
1721 * @param buffer User-provided buffer from which the data is to be
1722 * written into the slave processor's memory.
1723 *
1724 * @sa OMAP5430BENELLIPROC_read
1725 */
1726 Int
1727 OMAP5430BENELLIPROC_write (Processor_Handle handle,
1728 UInt32 procAddr,
1729 UInt32 * numBytes,
1730 Ptr buffer)
1731 {
1732 Int status = PROCESSOR_SUCCESS ;
1733 Processor_Object * procHandle = (Processor_Object *) handle;
1734 OMAP5430BENELLIPROC_Object * object = NULL;
1735 UInt8 * procPtr8 = NULL;
1736 UInt8 temp8_1;
1737 UInt8 temp8_2;
1738 UInt8 temp8_3;
1739 UInt8 temp8_4;
1740 UInt32 temp;
1742 GT_4trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_write",
1743 handle, procAddr, numBytes, buffer);
1745 GT_assert (curTrace, (handle != NULL));
1746 GT_assert (curTrace, (numBytes != NULL));
1747 GT_assert (curTrace, (buffer != NULL));
1749 #if !defined(IPC_BUILD_OPTIMIZE)
1750 if (handle == NULL) {
1751 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1752 status = PROCESSOR_E_HANDLE;
1753 GT_setFailureReason (curTrace,
1754 GT_4CLASS,
1755 "OMAP5430BENELLIPROC_write",
1756 status,
1757 "Invalid handle specified");
1758 }
1759 else if (numBytes == 0) {
1760 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1761 status = PROCESSOR_E_INVALIDARG;
1762 GT_setFailureReason (curTrace,
1763 GT_4CLASS,
1764 "OMAP5430BENELLIPROC_write",
1765 status,
1766 "Invalid numBytes specified");
1767 }
1768 else if (buffer == NULL) {
1769 /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
1770 status = PROCESSOR_E_INVALIDARG;
1771 GT_setFailureReason (curTrace,
1772 GT_4CLASS,
1773 "OMAP5430BENELLIPROC_write",
1774 status,
1775 "Invalid buffer specified");
1776 }
1777 else {
1778 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1779 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
1780 GT_assert (curTrace, (object != NULL));
1781 if (*numBytes != sizeof (UInt32)) {
1782 procPtr8 = (UInt8 *) procAddr ;
1783 procAddr = (UInt32) Memory_copy (procPtr8,
1784 buffer,
1785 *numBytes);
1786 GT_assert (curTrace, (procAddr != (UInt32) NULL));
1787 #if !defined(IPC_BUILD_OPTIMIZE)
1788 if (procAddr == (UInt32) NULL) {
1789 /*! @retval PROCESSOR_E_FAIL Failed in Memory_copy */
1790 status = PROCESSOR_E_FAIL;
1791 GT_setFailureReason (curTrace,
1792 GT_4CLASS,
1793 "OMAP5430BENELLIPROC_write",
1794 status,
1795 "Failed in Memory_copy");
1796 *numBytes = 0;
1797 }
1798 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1799 }
1800 else {
1801 /* For 4 bytes, directly write as a UInt32 */
1802 temp8_1 = ((UInt8 *) buffer) [0];
1803 temp8_2 = ((UInt8 *) buffer) [1];
1804 temp8_3 = ((UInt8 *) buffer) [2];
1805 temp8_4 = ((UInt8 *) buffer) [3];
1806 temp = (UInt32) ( ((UInt32) temp8_4 << 24)
1807 | ((UInt32) temp8_3 << 16)
1808 | ((UInt32) temp8_2 << 8)
1809 | ((UInt32) temp8_1));
1810 *((UInt32*) procAddr) = temp;
1811 }
1812 #if !defined(IPC_BUILD_OPTIMIZE)
1813 }
1814 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1816 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_write", status);
1818 /*! @retval PROCESSOR_SUCCESS Operation successful */
1819 return status;
1820 }
1823 /*!
1824 * @brief Function to perform device-dependent operations.
1825 *
1826 * Performs device-dependent control operations as exposed by this
1827 * implementation of the Processor module.
1828 *
1829 * @param handle Handle to the Processor object
1830 * @param cmd Device specific processor command
1831 * @param arg Arguments specific to the type of command.
1832 *
1833 * @sa
1834 */
1835 Int
1836 OMAP5430BENELLIPROC_control (Processor_Handle handle, Int32 cmd, Ptr arg)
1837 {
1838 Int status = PROCESSOR_SUCCESS ;
1839 Processor_Object * procHandle = (Processor_Object *) handle;
1840 OMAP5430BENELLIPROC_Object * object = NULL;
1842 GT_3trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_control",
1843 handle, cmd, arg);
1845 GT_assert (curTrace, (handle != NULL));
1846 /* cmd and arg can be 0/NULL, so cannot check for validity. */
1848 #if !defined(IPC_BUILD_OPTIMIZE)
1849 if (handle == NULL) {
1850 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
1851 status = PROCESSOR_E_HANDLE;
1852 GT_setFailureReason (curTrace,
1853 GT_4CLASS,
1854 "OMAP5430BENELLIPROC_control",
1855 status,
1856 "Invalid handle specified");
1857 }
1858 else {
1859 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1860 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
1861 GT_assert (curTrace, (object != NULL));
1862 /* No control operations currently implemented. */
1863 /*! @retval PROCESSOR_E_NOTSUPPORTED No control operations are supported
1864 for this device. */
1866 switch (cmd) {
1867 case Omap5430BenelliProc_CtrlCmd_Suspend:
1868 if (procHandle->state == ProcMgr_State_Running) {
1869 if (procHandle->procId == PROCTYPE_IPU0) {
1870 status = save_mmu_ctxt(object->halObject,
1871 procHandle->procId);
1872 }
1873 if (status < 0) {
1874 GT_setFailureReason(curTrace, GT_4CLASS,
1875 "OMAP5430BENELLIPROC_control",
1876 status,
1877 "Error while saving the MMU context");
1878 }
1879 else {
1880 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1881 Processor_ResetCtrlCmd_Reset);
1882 if (status < 0) {
1883 GT_setFailureReason(curTrace, GT_4CLASS,
1884 "OMAP5430BENELLIPROC_control",
1885 status,
1886 "Error while Resetting proc");
1887 }
1888 else {
1889 status = OMAP5430BENELLI_halResetCtrl(
1890 object->halObject,
1891 Processor_ResetCtrlCmd_MMU_Reset);
1892 if (status < 0) {
1893 GT_setFailureReason(curTrace, GT_4CLASS,
1894 "OMAP5430BENELLIPROC_control",
1895 status,
1896 "Error while Resetting MMU");
1897 }
1898 else {
1899 Processor_setState(handle, ProcMgr_State_Suspended);
1900 }
1901 }
1902 }
1903 }
1904 else {
1905 status = PROCESSOR_E_INVALIDSTATE;
1906 GT_setFailureReason(curTrace, GT_4CLASS,
1907 "OMAP5430BENELLIPROC_control",
1908 status,
1909 "Processor not is correct state to Suspend");
1910 }
1911 break;
1912 case Omap5430BenelliProc_CtrlCmd_Resume:
1913 if (procHandle->state == ProcMgr_State_Suspended) {
1914 status = OMAP5430BENELLI_halResetCtrl(object->halObject,
1915 Processor_ResetCtrlCmd_MMU_Release);
1916 if (status < 0) {
1917 GT_setFailureReason(curTrace, GT_4CLASS,
1918 "OMAP5430BENELLIPROC_control",
1919 status,
1920 "Error while releasing proc MMU reset");
1921 }
1922 else {
1923 if (procHandle->procId == PROCTYPE_IPU0) {
1924 status = restore_mmu_ctxt(object->halObject,
1925 procHandle->procId);
1926 }
1927 if (status < 0) {
1928 GT_setFailureReason(curTrace, GT_4CLASS,
1929 "OMAP5430BENELLIPROC_control",
1930 status,
1931 "Error while restoring MMU context");
1932 }
1933 else {
1934 status = OMAP5430BENELLI_halResetCtrl(
1935 object->halObject,
1936 Processor_ResetCtrlCmd_Release);
1937 if (status < 0) {
1938 GT_setFailureReason(curTrace, GT_4CLASS,
1939 "OMAP5430BENELLIPROC_control",
1940 status,
1941 "Error while releasing reset");
1942 }
1943 else {
1944 Processor_setState(handle, ProcMgr_State_Running);
1945 }
1946 }
1947 }
1948 }
1949 else {
1950 status = PROCESSOR_E_INVALIDSTATE;
1951 GT_setFailureReason(curTrace, GT_4CLASS,
1952 "OMAP5430BENELLIPROC_control",
1953 status,
1954 "Processor not is correct state to Resume");
1955 }
1956 break;
1957 default:
1958 status = PROCESSOR_E_NOTSUPPORTED;
1959 }
1961 #if !defined(IPC_BUILD_OPTIMIZE)
1962 }
1963 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
1964 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_control",status);
1966 /*! @retval PROCESSOR_SUCCESS Operation successful */
1967 return status;
1968 }
1971 /*!
1972 * @brief Function to translate slave physical address to master physical
1973 * address.
1974 *
1975 * @param handle Handle to the Processor object
1976 * @param dstAddr Returned: master physical address.
1977 * @param srcAddr Slave physical address.
1978 *
1979 * @sa
1980 */
1981 Int
1982 OMAP5430BENELLIPROC_translate (Processor_Handle handle,
1983 UInt32 * dstAddr,
1984 UInt32 srcAddr)
1985 {
1986 Int status = PROCESSOR_SUCCESS ;
1987 Processor_Object * procHandle = (Processor_Object *) handle;
1988 OMAP5430BENELLIPROC_Object * object = NULL;
1989 UInt32 i;
1990 ProcMgr_AddrInfo * ai;
1991 ProcMgr_AddrInfo * pMemRegn = NULL;
1992 UInt32 nRegions = 0;
1994 GT_3trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_translate",
1995 handle, dstAddr, srcAddr);
1997 GT_assert (curTrace, (handle != NULL));
1998 GT_assert (curTrace, (dstAddr != NULL));
2000 GT_1trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_Params_init", handle);
2002 #if !defined(IPC_BUILD_OPTIMIZE)
2003 if (handle == NULL) {
2004 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
2005 status = PROCESSOR_E_HANDLE;
2006 GT_setFailureReason (curTrace,
2007 GT_4CLASS,
2008 "OMAP5430BENELLIPROC_translate",
2009 status,
2010 "Invalid handle specified");
2011 }
2012 else if (dstAddr == NULL) {
2013 /*! @retval PROCESSOR_E_INVALIDARG sglist provided as NULL */
2014 status = PROCESSOR_E_INVALIDARG;
2015 GT_setFailureReason (curTrace,
2016 GT_4CLASS,
2017 "OMAP5430BENELLIPROC_translate",
2018 status,
2019 "dstAddr provided as NULL");
2020 }
2021 else {
2022 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2023 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
2024 GT_assert (curTrace, (object != NULL));
2026 switch(procHandle->procId)
2027 {
2028 case PROCTYPE_IPU0:
2029 pMemRegn = OMAP5430BENELLIPROC_addrTable;
2030 nRegions = AddrTable_IPU_count;
2031 break;
2032 #ifndef IPC_SYSBIOS_SMP
2033 case PROCTYPE_IPU1:
2034 pMemRegn = OMAP5430BENELLIPROC_addrTable;
2035 nRegions = AddrTable_IPU_count;
2036 break;
2037 #endif
2038 case PROCTYPE_DSP:
2039 pMemRegn = OMAP5430TESLAPROC_addrTable;
2040 nRegions = AddrTable_DSP_count;
2041 break;
2042 }
2045 *dstAddr = -1u;
2046 for (i = 0;i < nRegions;i++)
2047 {
2048 ai = &pMemRegn [i];
2049 if ( (srcAddr >= ai->addr [ProcMgr_AddrType_SlaveVirt])
2050 && (srcAddr < ( ai->addr [ProcMgr_AddrType_SlaveVirt]
2051 + ai->size))) {
2052 *dstAddr = ai->addr [ProcMgr_AddrType_MasterPhys]
2053 + (srcAddr - ai->addr [ProcMgr_AddrType_SlaveVirt]);
2054 break;
2055 }
2056 }
2058 if (*dstAddr == -1u) {
2059 /*! @retval PROCESSOR_E_FAIL srcAddr not found in slave address
2060 * space */
2061 status = PROCESSOR_E_INVALIDARG;
2062 GT_setFailureReason (curTrace,
2063 GT_4CLASS,
2064 "OMAP5430BENELLIPROC_translate",
2065 status,
2066 "srcAddr not found in slave address space");
2067 }
2069 #if !defined(IPC_BUILD_OPTIMIZE)
2070 }
2071 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2072 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_translate",status);
2074 /*! @retval PROCESSOR_SUCCESS Operation successful */
2075 return status;
2076 }
2079 /*!
2080 * @brief Function to map slave address to host address space
2081 *
2082 * Map the provided slave address to master address space. This
2083 * function also maps the specified address to slave MMU space.
2084 *
2085 * @param handle Handle to the Processor object
2086 * @param mapType Type of mapping to be performed.
2087 * @param addrInfo Structure containing map info.
2088 * @param srcAddrType Source address type.
2089 *
2090 * @sa
2091 */
2092 Int
2093 OMAP5430BENELLIPROC_map (Processor_Handle handle,
2094 UInt32 * dstAddr,
2095 UInt32 nSegs,
2096 Memory_SGList * sglist)
2097 {
2098 Int status = PROCESSOR_SUCCESS ;
2099 Processor_Object * procHandle = (Processor_Object *) handle;
2100 OMAP5430BENELLIPROC_Object * object = NULL;
2101 UInt32 i, j;
2102 UInt32 startAddr;
2103 UInt32 endAddr;
2104 Bool found = FALSE;
2105 ProcMgr_AddrInfo * pMemRegn = NULL;
2106 UInt32 * pNumRegions = NULL;
2107 ProcMgr_AddrInfo * ai = NULL;
2109 GT_4trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_map",
2110 handle, dstAddr, nSegs, sglist);
2112 GT_assert (curTrace, (handle != NULL));
2113 GT_assert (curTrace, (sglist != NULL));
2114 GT_assert (curTrace, (nSegs > 0));
2116 #if !defined(IPC_BUILD_OPTIMIZE)
2117 if (handle == NULL) {
2118 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
2119 status = PROCESSOR_E_HANDLE;
2120 GT_setFailureReason (curTrace,
2121 GT_4CLASS,
2122 "OMAP5430BENELLIPROC_map",
2123 status,
2124 "Invalid handle specified");
2125 }
2126 else if (sglist == NULL) {
2127 /*! @retval PROCESSOR_E_INVALIDARG sglist provided as NULL */
2128 status = PROCESSOR_E_INVALIDARG;
2129 GT_setFailureReason (curTrace,
2130 GT_4CLASS,
2131 "OMAP5430BENELLIPROC_map",
2132 status,
2133 "sglist provided as NULL");
2134 }
2135 else if (nSegs == 0) {
2136 /*! @retval PROCESSOR_E_INVALIDARG Number of segments provided is 0 */
2137 status = PROCESSOR_E_INVALIDARG;
2138 GT_setFailureReason (curTrace,
2139 GT_4CLASS,
2140 "OMAP5430BENELLIPROC_map",
2141 status,
2142 "Number of segments provided is 0");
2143 }
2144 else {
2145 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2146 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
2147 GT_assert (curTrace, (object != NULL));
2149 switch(procHandle->procId)
2150 {
2151 case PROCTYPE_IPU0:
2152 pMemRegn = OMAP5430BENELLIPROC_addrTable;
2153 pNumRegions = &AddrTable_IPU_count;
2154 break;
2155 #ifndef IPC_SYSBIOS_SMP
2156 case PROCTYPE_IPU1:
2157 pMemRegn = OMAP5430BENELLIPROC_addrTable;
2158 pNumRegions = &ddrTable_IPU_count;
2159 break;
2160 #endif
2161 case PROCTYPE_DSP:
2162 pMemRegn = OMAP5430TESLAPROC_addrTable;
2163 pNumRegions = &AddrTable_DSP_count;
2164 break;
2165 }
2167 /* Program the mmu with the sglist */
2168 /* Program the DSP MMU also */
2169 for (i = 0; (i < nSegs) && (status >= 0); i++)
2170 {
2171 /* Update the translation table with entries for which mapping
2172 * is required. Add the entry only if the range does not exist
2173 * in the translation table.
2174 */
2175 for (j = 0;
2176 j < *pNumRegions; j++) {
2177 ai = &pMemRegn[j];
2179 if (ai->isMapped == TRUE) {
2180 startAddr = ai->addr[ProcMgr_AddrType_SlaveVirt];
2181 endAddr = startAddr + ai->size;
2183 if ((startAddr <= *dstAddr) && (*dstAddr < endAddr)
2184 && ((*dstAddr + sglist[i].size) <= endAddr)) {
2185 found = TRUE;
2186 ai->refCount++;
2187 break;
2188 }
2189 }
2190 }
2192 /* If not found, add new entry to table. If mmu is disabled,
2193 * the assumption is that the ammu will be used.
2194 */
2195 if (!found) {
2196 if (*pNumRegions != AddrTable_SIZE) {
2197 ai = &pMemRegn[*pNumRegions];
2198 ai->addr[ProcMgr_AddrType_MasterKnlVirt] = -1u;
2199 ai->addr[ProcMgr_AddrType_MasterUsrVirt] = -1u;
2200 ai->addr[ProcMgr_AddrType_MasterPhys] = sglist[i].paddr;
2201 ai->addr[ProcMgr_AddrType_SlaveVirt] = *dstAddr;
2202 ai->addr[ProcMgr_AddrType_SlavePhys] = -1u;
2203 ai->size = sglist[i].size;
2204 ai->isCached = sglist[i].isCached;
2205 ai->refCount++;
2206 ai->isMapped = TRUE;
2208 (*pNumRegions)++;
2209 }
2210 else {
2211 status = PROCESSOR_E_FAIL;
2212 GT_setFailureReason(curTrace, GT_4CLASS,
2213 "OMAP5430BENELLIPROC_map", status,
2214 "AddrTable_SIZE reached!");
2215 }
2216 }
2218 *(dstAddr) = get_BenelliVirtAdd(object->halObject,
2219 sglist[i].paddr);
2220 }
2221 #if !defined(IPC_BUILD_OPTIMIZE)
2222 }
2223 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2224 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_map",status);
2226 /*! @retval PROCESSOR_SUCCESS Operation successful */
2227 return status;
2228 }
2231 /*!
2232 * @brief Function to unmap slave address from host address space
2233 *
2234 * @param handle Handle to the Processor object
2235 * @param dstAddr Return parameter: Pointer to receive the mapped
2236 * address.
2237 * @param size Size of the region to be mapped.
2238 s *
2239 * @sa
2240 */
2241 Int
2242 OMAP5430BENELLIPROC_unmap (Processor_Handle handle,
2243 UInt32 addr,
2244 UInt32 size)
2245 {
2246 Int status = PROCESSOR_SUCCESS ;
2247 Processor_Object * procHandle = (Processor_Object *) handle;
2248 OMAP5430BENELLIPROC_Object * object = NULL;
2249 OMAP5430BENELLI_HalMmuCtrlArgs_DeleteEntry deleteEntryArgs;
2251 GT_3trace (curTrace, GT_ENTER, "OMAP5430BENELLIPROC_unmap",
2252 handle, addr, size);
2254 GT_assert (curTrace, (handle != NULL));
2255 GT_assert (curTrace, (size != 0));
2257 #if !defined(IPC_BUILD_OPTIMIZE)
2258 if (handle == NULL) {
2259 /*! @retval PROCESSOR_E_HANDLE Invalid argument */
2260 status = PROCESSOR_E_HANDLE;
2261 GT_setFailureReason (curTrace,
2262 GT_4CLASS,
2263 "OMAP5430BENELLIPROC_unmap",
2264 status,
2265 "Invalid handle specified");
2266 }
2267 else if (size == 0) {
2268 /*! @retval PROCESSOR_E_INVALIDARG Size provided is zero */
2269 status = PROCESSOR_E_INVALIDARG;
2270 GT_setFailureReason (curTrace,
2271 GT_4CLASS,
2272 "OMAP5430BENELLIPROC_unmap",
2273 status,
2274 "Size provided is zero");
2275 }
2276 else {
2277 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2278 object = (OMAP5430BENELLIPROC_Object *) procHandle->object;
2279 GT_assert (curTrace, (object != NULL));
2280 /* Remove the entry from the DSP MMU also */
2282 deleteEntryArgs.size = size;
2283 deleteEntryArgs.slaveVirtAddr = addr;
2284 /*TBD : elementSize, endianism, mixedSized are hard coded now,
2285 * must be configurable later*/
2286 deleteEntryArgs.elementSize = ELEM_SIZE_16BIT;
2287 deleteEntryArgs.endianism = LITTLE_ENDIAN;
2288 deleteEntryArgs.mixedSize = MMU_TLBES;
2290 status = OMAP5430BENELLI_halMmuCtrl(object->halObject,
2291 Processor_MmuCtrlCmd_DeleteEntry,
2292 &deleteEntryArgs);
2293 #if !defined(IPC_BUILD_OPTIMIZE)
2294 if (status < 0) {
2295 GT_setFailureReason (curTrace,
2296 GT_4CLASS,
2297 "OMAP5430BENELLIPROC_unmap",
2298 status,
2299 "DSP MMU configuration failed");
2300 }
2301 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2303 #if !defined(IPC_BUILD_OPTIMIZE)
2304 }
2305 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
2306 GT_1trace (curTrace, GT_LEAVE, "OMAP5430BENELLIPROC_unmap",status);
2308 /*! @retval PROCESSOR_SUCCESS Operation successful */
2309 return status;
2310 }
2312 Int
2313 OMAP5430BENELLIPROC_procInfo (Processor_Handle handle,
2314 ProcMgr_ProcInfo * procInfo)
2315 {
2316 Processor_Object * procHandle = NULL;
2317 OMAP5430BENELLIPROC_Object * object = NULL;
2318 ProcMgr_AddrInfo * entry = NULL;
2319 Int i = 0;
2321 procHandle = (Processor_Object *)handle;
2322 object = procHandle->object;
2323 for (i = 0; i < object->params.numMemEntries; i++) {
2324 entry = &object->params.memEntries[i];
2326 procInfo->memEntries[i].info.addr[ProcMgr_AddrType_MasterKnlVirt] =
2327 entry->addr[ProcMgr_AddrType_MasterKnlVirt];
2329 procInfo->memEntries[i].info.addr[ProcMgr_AddrType_SlaveVirt] =
2330 entry->addr[ProcMgr_AddrType_SlaveVirt];
2333 }
2334 procInfo->numMemEntries = object->params.numMemEntries;
2335 return 0;
2336 }
2338 Int
2339 OMAP5430BENELLI_virtToPhys (Processor_Handle handle,
2340 UInt32 da,
2341 UInt32 * mappedEntries,
2342 UInt32 numEntries)
2343 {
2344 if(!handle || !mappedEntries || !numEntries) {
2345 return -1;
2346 }
2347 return 0;
2348 }
2351 #if defined (__cplusplus)
2352 }
2353 #endif /* defined (__cplusplus) */