[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / common / ti81xx / ti81xxdsp / Dm8168DspHal.c
1 /*
2 * @file Dm8168DspHal.c
3 *
4 * @brief Top-level Hardware Abstraction Module implementation
5 *
6 * This module implements the top-level Hardware Abstraction Layer
7 * for DM8168DSP.
8 * The implementation is specific to DM8168DSP.
9 *
10 *
11 * ============================================================================
12 *
13 * Copyright (c) 2008-2012, Texas Instruments Incorporated
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 * Contact information for paper mail:
42 * Texas Instruments
43 * Post Office Box 655303
44 * Dallas, Texas 75265
45 * Contact information:
46 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
47 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
48 * ============================================================================
49 *
50 */
54 #if defined(SYSLINK_BUILD_RTOS)
55 #include <xdc/std.h>
56 #include <xdc/runtime/Memory.h>
57 #include <xdc/runtime/Error.h>
58 #endif /* #if defined(SYSLINK_BUILD_RTOS) */
60 #if defined(SYSLINK_BUILD_HLOS)
61 #include <ti/syslink/Std.h>
62 /* OSAL & Utils headers */
63 #include <ti/syslink/utils/Memory.h>
64 #endif /* #if defined(SYSLINK_BUILD_HLOS) */
66 #include <ti/syslink/utils/Trace.h>
67 /* Hardware Abstraction Layer headers */
68 #include <_ProcDefs.h>
69 #include <Processor.h>
70 #include <Dm8168DspHal.h>
71 #include <Dm8168DspHalBoot.h>
72 #include <Dm8168DspPhyShmem.h>
75 #if defined (__cplusplus)
76 extern "C" {
77 #endif
80 /* =============================================================================
81 * Macros and types
82 * =============================================================================
83 */
85 /* =============================================================================
86 * APIs called by DM8168DSPPROC module
87 * =============================================================================
88 */
89 /*!
90 * @brief Function to initialize the HAL object
91 *
92 * @param halObj Return parameter: Pointer to the HAL object
93 * @param initParams Optional initialization parameters
94 *
95 * @sa DM8168DSP_halExit
96 * DM8168DSP_phyShmemInit
97 */
98 Int
99 DM8168DSP_halInit (Ptr * halObj, Ptr params)
100 {
101 Int status = PROCESSOR_SUCCESS;
102 DM8168DSP_HalObject * halObject = NULL;
104 GT_2trace(curTrace, GT_ENTER,
105 "--> DM8168DSP_halInit: halObj=0x%x, params=0x%x", halObj, params);
107 GT_assert (curTrace, (halObj != NULL));
109 halObject = (DM8168DSP_HalObject *) halObj ;
111 (Void) params ; /* Not used. */
113 *halObj = Memory_calloc (NULL, sizeof (DM8168DSP_HalObject), 0, NULL);
114 if (halObject == NULL) {
115 /*! @retval PROCESSOR_E_MEMORY Memory allocation failed */
116 status = PROCESSOR_E_MEMORY;
117 GT_setFailureReason (curTrace,
118 GT_4CLASS,
119 "DM8168DSP_halInit",
120 status,
121 "Memory allocation failed for HAL object!");
122 }
123 else {
124 status = DM8168DSP_phyShmemInit (*halObj);
125 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
126 if (status < 0) {
127 GT_setFailureReason (curTrace,
128 GT_4CLASS,
129 "DM8168DSP_halInit",
130 status,
131 "DM8168DSP_phyShmemInit failed!");
132 Memory_free (NULL, *halObj, sizeof (DM8168DSP_HalObject));
133 *halObj = NULL;
134 }
135 #endif
136 }
139 GT_1trace(curTrace, GT_LEAVE, "<-- DM8168DSP_halInit: 0x%x", status);
141 /*! @retval PROCESSOR_SUCCESS Operation successful */
142 return status;
143 }
146 /*!
147 * @brief Function to finalize the HAL object
148 *
149 * @param halObj Pointer to the HAL object
150 *
151 * @sa DM8168DSP_halInit
152 * DM8168DSP_phyShmemExit
153 */
154 Int
155 DM8168DSP_halExit (Ptr halObj)
156 {
157 Int status = PROCESSOR_SUCCESS;
159 GT_1trace (curTrace, GT_ENTER, "DM8168DSP_halExit", halObj);
161 GT_assert (curTrace, (halObj != NULL));
163 status = DM8168DSP_phyShmemExit (halObj);
164 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
165 if (status < 0) {
166 GT_setFailureReason (curTrace,
167 GT_4CLASS,
168 "DM8168DSP_halExit",
169 status,
170 "DM8168DSP_phyShmemExit failed!");
171 }
172 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
174 if (halObj != NULL) {
175 /* Free the memory for the HAL object. */
176 Memory_free (NULL, halObj, sizeof (DM8168DSP_HalObject));
177 }
179 GT_1trace (curTrace, GT_LEAVE, "DM8168DSP_halExit", status);
181 /*! @retval PROCESSOR_SUCCESS Operation successful */
182 return status;
183 }
186 #if defined (__cplusplus)
187 }
188 #endif