• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2 * Copyright (C) 2018 Cadence Design Systems, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to use this Software with Cadence processor cores only and
7 * not with any other processors and platforms, subject to
8 * the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 ******************************************************************************/
22 
23 
24 #include "cpu_c.h"
25 #include <xtensa/config/specreg.h>
26 #include <xtensa/config/core.h>
27 #include <xtensa/simcall.h>
28 #include "arch_hifi330.h"
29 
30 #ifdef __cplusplus
31 #if __cplusplus
32 extern "C" {
33 #endif
34 #endif
35 
36 /*lint -e838 -e835 -e750 -e529 -e533 -e40*/
37 
38 //#define DSP_TRACES_TO_MEM_SIZE (0x800)
39 
40 void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT];
41 
42 void *g_pfVosIntrFuncTable[OS_INTR_CONNECT_BUTT];
43 
44 //unsigned int g_uwSoftIntInfo = 0;
45 
46 /* Interrupt nesting level */
47 unsigned char g_ucVosIntNesting;
48 
49 /* Priority of current task */
50 unsigned char g_ucVosPrioCur;
51 
52 /* Priority of highest priority task */
53 unsigned char g_ucVosPrioHighRdy;
54 
55 /* Flag indicating that kernel is running */
56 unsigned short g_bVosRunning;
57 
58 /* Pointer to highest priority TCB R-to-R */
59 unsigned int *g_pstVosTCBHighRdy;
60 
61 /* Pointer to currently running TCB*/
62 unsigned int *g_pstVosTCBCur;
63 
64 #define _XTSTR(x) #x
65 #define XTSTR(x) _XTSTR(x)
66 
OS_EnterIntHook(unsigned int uhwIntrNo)67 void OS_EnterIntHook(unsigned int uhwIntrNo)
68 {
69     INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_ENTER_INTR];/*lint !e611*/
70 
71     if (0 != pfIntrHook)
72     {
73         pfIntrHook(uhwIntrNo);
74     }
75 }
76 
OS_ExitIntHook(unsigned int uhwIntrNo)77 void OS_ExitIntHook(unsigned int uhwIntrNo)
78 {
79     INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXIT_INTR];/*lint !e611*/
80 
81     if (0 != pfIntrHook)
82     {
83         pfIntrHook(uhwIntrNo);
84     }
85 }
86 
OS_UserexecHandler(unsigned int uwExecCauseNo,unsigned int psAddr)87 void OS_UserexecHandler(unsigned int uwExecCauseNo, unsigned int psAddr)
88 {
89     VOS_EXCEPTION_HOOK_FUNC pfIntrHook = (VOS_EXCEPTION_HOOK_FUNC)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXCEPTION];/*lint !e611*/
90 
91     if (0 != pfIntrHook)
92     {
93         pfIntrHook(uwExecCauseNo);
94     }
95     else
96     {
97         extern void OS_Panic(void);
98         OS_Panic();
99     }
100 }
101 
OS_InterruptHandler(unsigned int uhwIntrNo)102 void OS_InterruptHandler(unsigned int uhwIntrNo)
103 {
104     HOOK_FUN_TYPE pfIntrHook = (HOOK_FUN_TYPE)g_pfVosIntrFuncTable[uhwIntrNo];
105 
106     if (0 != pfIntrHook)
107         //pfIntrHook();
108         pfIntrHook(0);
109 }
110 
OS_NmiHook(unsigned int uwExecCauseNo,unsigned int psAddr)111 void OS_NmiHook(unsigned int uwExecCauseNo, unsigned int psAddr)
112 {
113     HOOK_FUN_TYPE pfNmiHook = (HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_NMI];/*lint !e611*/
114 
115     if (0 != pfNmiHook)
116     {
117         //pfNmiHook();
118         pfNmiHook(0);
119     }
120 
121     //wait for hifi reset
122     UCOM_SET_WFI_NMI(5);
123 }
124 
VOS_ConnectInterrupt(unsigned int uwIntrNo,HOOK_FUN_TYPE pfnInterruptHook)125 void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook)
126 {
127     g_pfVosIntrFuncTable[uwIntrNo] = (void *)pfnInterruptHook;/*lint !e611*/
128 }
129 
VOS_EnableInterrupt(unsigned int uwIntNo)130 void VOS_EnableInterrupt(unsigned int uwIntNo)
131 {
132     unsigned int uwBitEnable;
133 
134     uwBitEnable = xthal_get_intenable();
135     xthal_set_intenable(uwBitEnable | (((unsigned int)1) << uwIntNo ));
136 
137 }
VOS_DisableInterrupt(unsigned int uwIntNo)138 void VOS_DisableInterrupt(unsigned int uwIntNo)
139 {
140     unsigned int uwBitEnable;
141 
142     uwBitEnable = xthal_get_intenable();
143     xthal_set_intenable(uwBitEnable | (((unsigned int)0) << uwIntNo ));
144 
145 }
146 
147 #ifdef __cplusplus
148     #if __cplusplus
149         }
150     #endif
151 #endif
152 
153