105d64b89df54f6539dcb5708c025fb1f5027cd9
1 /**
2 * @file fm_exclusion.c
3 *
4 * @brief
5 * Fault Management exclusion list source
6 *
7 * \par
8 * ============================================================================
9 * @n (C) Copyright 2014, Texas Instruments, Inc.
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
21 * distribution.
22 *
23 * Neither the name of Texas Instruments Incorporated nor the names of
24 * its contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * \par
40 */
42 /* CSL Includes */
43 #include <ti/csl/csl_sem.h>
44 #include <ti/csl/cslr.h>
46 /* FM API Include */
47 #include <ti/instrumentation/fault_mgmt/fault_mgmt.h>
49 /* FM Internal Includes */
50 #include <ti/instrumentation/fault_mgmt/include/fm_loc.h>
51 #include <ti/instrumentation/fault_mgmt/include/fm_exclusionloc.h>
53 /**********************************************************************
54 ********************* Exclusion Globals ******************************
55 **********************************************************************/
58 /**********************************************************************
59 ******************** External Variables ******************************
60 **********************************************************************/
63 /**********************************************************************
64 ******************* Local Exclusion Functions ***********************
65 **********************************************************************/
67 /* FUNCTION PURPOSE: Generic check if a resource is in exclusion list
68 ***********************************************************************
69 * DESCRIPTION: Compares input resource with the list of resources
70 * in the supplied exclusion list
71 */
72 static uint32_t isExcludedGenericResource(Fm_ExclusionParams *exParams)
73 {
74 int i;
76 if (exParams->exclusionList) {
77 for (i = 0; i < exParams->numListEntries; i++) {
78 if (exParams->exclusionList[i].resType == exParams->resType) {
79 if ((exParams->resourceNum >= exParams->exclusionList[i].exRange.exStart) &&
80 (exParams->resourceNum <= exParams->exclusionList[i].exRange.exEnd)) {
81 return (FM_TRUE);
82 }
83 }
84 }
85 }
87 return (FM_FALSE);
88 }
90 /* FUNCTION PURPOSE: Checks if CPDMA channel is in exclusion list
91 ***********************************************************************
92 * DESCRIPTION: Compares input channel/flow of a given CPDMA with the
93 * list of CPDMA channels in the supplied exclusion list
94 */
95 static uint32_t isExcludedCpdmaResource(Fm_ExclusionParams *exParams)
96 {
97 Fm_ExclusionCpdmaParams *cpdmaParams = &(exParams->u.cpdmaParams);
98 int i;
100 if (exParams->exclusionList) {
101 for (i = 0; i < exParams->numListEntries; i++) {
102 if (exParams->exclusionList[i].resType == exParams->resType) {
103 if ((cpdmaParams->dma == exParams->exclusionList[i].exResInfo) &&
104 (exParams->resourceNum >= exParams->exclusionList[i].exRange.exStart) &&
105 (exParams->resourceNum <= exParams->exclusionList[i].exRange.exEnd)) {
106 return (FM_TRUE);
107 }
108 }
109 }
110 }
112 return (FM_FALSE);
113 }
115 /* FUNCTION PURPOSE: Checks if EDMA3 channel is in exclusion list
116 ***********************************************************************
117 * DESCRIPTION: Compares input channel with the list of EDMA3 channels
118 * in the supplied exclusion list
119 */
120 static uint32_t isExcludedEdma3Resource(Fm_ExclusionParams *exParams)
121 {
122 Fm_ExclusionEdma3Params *edma3Params = &(exParams->u.edma3Params);
123 int i;
125 if (exParams->exclusionList) {
126 for (i = 0; i < exParams->numListEntries; i++) {
127 if (exParams->exclusionList[i].resType == exParams->resType) {
128 if ((edma3Params->edma3Num == exParams->exclusionList[i].exResInfo) &&
129 (exParams->resourceNum >= exParams->exclusionList[i].exRange.exStart) &&
130 (exParams->resourceNum <= exParams->exclusionList[i].exRange.exEnd)) {
131 return (FM_TRUE);
132 }
133 }
134 }
135 }
137 return (FM_FALSE);
138 }
140 /* FUNCTION PURPOSE: Checks if LUT entry is in exclusion list
141 ***********************************************************************
142 * DESCRIPTION: Compares input LUT entry with the list of LUT entries
143 * in the supplied exclusion list
144 */
145 static uint32_t isExcludedLutEntry(Fm_ExclusionParams *exParams)
146 {
147 Fm_ExclusionLutEntryParams *lutParams = &(exParams->u.lutParams);
148 int i;
150 if (exParams->exclusionList) {
151 for (i = 0; i < exParams->numListEntries; i++) {
152 if (exParams->exclusionList[i].resType == exParams->resType) {
153 if ((lutParams->lutInst == exParams->exclusionList[i].exResInfo) &&
154 (exParams->resourceNum >= exParams->exclusionList[i].exRange.exStart) &&
155 (exParams->resourceNum <= exParams->exclusionList[i].exRange.exEnd)) {
156 return (FM_TRUE);
157 }
158 }
159 }
160 }
162 return (FM_FALSE);
163 }
165 /* FUNCTION PURPOSE: Checks if CIC host interrupt is in exclusion list
166 ***********************************************************************
167 * DESCRIPTION: Compares input CIC host interrupt with the list of
168 * CIC host interrupts in the supplied exclusion list
169 */
170 static uint32_t isExcludedCicResource(Fm_ExclusionParams *exParams)
171 {
172 Fm_ExclusionCicParams *cicParams = &(exParams->u.cicParams);
173 int i;
175 if (exParams->exclusionList) {
176 for (i = 0; i < exParams->numListEntries; i++) {
177 if (exParams->exclusionList[i].resType == exParams->resType) {
178 if ((cicParams->cic == exParams->exclusionList[i].exResInfo) &&
179 (exParams->resourceNum >= exParams->exclusionList[i].exRange.exStart) &&
180 (exParams->resourceNum <= exParams->exclusionList[i].exRange.exEnd)) {
181 return (FM_TRUE);
182 }
183 }
184 }
185 }
187 return (FM_FALSE);
188 }
190 /**********************************************************************
191 ************************** Exclusion APIs ****************************
192 **********************************************************************/
194 /* FUNCTION PURPOSE: Validates the excluded resource list passed by the app
195 ***********************************************************************
196 * DESCRIPTION: Validates the exResInfo field for the different possible
197 * exclusion types that can be passed in. Will return a -1
198 * and the exclusion list entry that failed if the exResInfo
199 * does not match what is expected. Otherwise, returns 0 in the
200 * status field and the number of exclusion entries
201 * as the return value.
202 */
203 uint32_t fmExclusionValidateList(Fm_GlobalConfigParams *fmGblCfgParams, Fm_ExcludedResource *exResList,
204 int32_t *status)
205 {
206 int32_t exEntries = 0;
208 *status = FM_OK;
210 if (exResList) {
211 while(exResList[exEntries].resType != Fm_res_END) {
212 switch(exResList[exEntries].resType) {
213 case Fm_res_CpdmaRxCh:
214 case Fm_res_CpdmaTxCh:
215 case Fm_res_CpdmaRxFlow:
216 if (exResList[exEntries].exResInfo > CPPI_MAX_CPDMA) {
217 *status = FM_ERROR_INVALID_CPDMA_IN_EXCLUSION_LIST;
218 return(exEntries);
219 }
220 break;
221 case Fm_res_Edma3DmaCh:
222 case Fm_res_Edma3QdmaCh:
223 case Fm_res_Edma3IntCh:
224 if (exResList[exEntries].exResInfo > fmGblCfgParams->maxEdma3Cc) {
225 *status = FM_ERROR_INVALID_EDMA3_CC_IN_EXCLUSION_LIST;
226 return(exEntries);
227 }
228 break;
229 case Fm_res_PaLutEntry:
230 if (exResList[exEntries].exResInfo > 2) {
231 *status = FM_ERROR_INVALID_LUT_IN_EXCLUSION_LIST;
232 return(exEntries);
233 }
234 break;
235 case Fm_res_CicHostInt:
236 if (exResList[exEntries].exResInfo >= fmGblCfgParams->maxCic) {
237 *status = FM_ERROR_INVALID_CIC_IN_EXCLUSION_LIST;
238 return(exEntries);
239 }
240 break;
241 case Fm_res_Timer:
242 if ((exResList[exEntries].exRange.exStart < 0) ||
243 (exResList[exEntries].exRange.exStart >= fmGblCfgParams->maxTimers) ||
244 (exResList[exEntries].exRange.exEnd < 0) ||
245 (exResList[exEntries].exRange.exEnd >= fmGblCfgParams->maxTimers)) {
246 *status = FM_ERROR_INVALID_TIMER_IN_EXCLUSION_LIST;
247 return(exEntries);
248 }
249 break;
250 case Fm_res_AifPeCh:
251 case Fm_res_AifPdCh:
252 case Fm_res_QmssAccumCh:
253 case Fm_res_QmssQueue:
254 case Fm_res_QmssMemRegion:
255 default:
256 break;
257 }
258 exEntries++;
259 }
260 }
262 return(exEntries);
263 }
265 /* FUNCTION PURPOSE: Gets the exclusion result for a resource
266 ***********************************************************************
267 * DESCRIPTION: Returns the exclusion result for the provided resource
268 */
269 uint32_t fmExclusionIsExcluded(Fm_ExclusionParams *exParams)
270 {
271 uint32_t isExcluded = FM_TRUE;
273 switch(exParams->resType) {
274 case Fm_res_CpdmaRxCh:
275 case Fm_res_CpdmaTxCh:
276 case Fm_res_CpdmaRxFlow:
277 isExcluded = isExcludedCpdmaResource(exParams);
278 break;
279 case Fm_res_Edma3DmaCh:
280 case Fm_res_Edma3QdmaCh:
281 case Fm_res_Edma3IntCh:
282 isExcluded = isExcludedEdma3Resource(exParams);
283 break;
284 case Fm_res_PaLutEntry:
285 isExcluded = isExcludedLutEntry(exParams);
286 break;
287 case Fm_res_CicHostInt:
288 isExcluded = isExcludedCicResource(exParams);
289 break;
290 case Fm_res_QmssAccumCh:
291 case Fm_res_QmssQueue:
292 case Fm_res_QmssMemRegion:
293 case Fm_res_AifPeCh:
294 case Fm_res_AifPdCh:
295 case Fm_res_PaPdsp:
296 case Fm_res_Timer:
297 isExcluded = isExcludedGenericResource(exParams);
298 break;
299 case Fm_res_END:
300 default:
301 /* Exclude an invalid peripheral */
302 break;
303 }
305 return (isExcluded);
306 }