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 #ifndef __CPU_C_H__ 24 #define __CPU_C_H__ 25 26 enum OS_HOOK_TYPE_ENUM 27 { 28 OS_HOOK_TYPE_ENTER_INTR=0, 29 OS_HOOK_TYPE_EXIT_INTR, 30 OS_HOOK_TYPE_TASK_SWITCH, 31 OS_HOOK_TYPE_MSG_GET, 32 OS_HOOK_TYPE_NMI, 33 OS_HOOK_TYPE_EXCEPTION, 34 OS_HOOK_TYPE_APPINIT, 35 OS_HOOK_TYPE_IDLE, 36 OS_HOOK_TYPE_BUTT 37 }; 38 39 enum OS_INTR_CONNECT_TYPE_ENUM 40 { 41 OS_INTR_CONNECT_00=0, /*Int 0 type / priority level NMI / 6 */ 42 OS_INTR_CONNECT_01, /*Int 1 type / priority level Software / 3 */ 43 OS_INTR_CONNECT_02, /*Int 2 type / priority level ExtLevel / 2 */ 44 OS_INTR_CONNECT_03, /*Int 3 type / priority level ExtLevel / 2 */ 45 OS_INTR_CONNECT_04, /*Int 4 type / priority level ExtLevel / 2 */ 46 OS_INTR_CONNECT_05, /*Int 5 type / priority level Timer / 3 */ 47 OS_INTR_CONNECT_06, /*Int 6 type / priority level Timer / 4 */ 48 OS_INTR_CONNECT_07, /*Int 7 type / priority level ExtLevel / 3 */ 49 OS_INTR_CONNECT_08, /*Int 8 type / priority level ExtLevel / 3 */ 50 OS_INTR_CONNECT_09, /*Int 9 type / priority level ExtLevel / 3 */ 51 OS_INTR_CONNECT_10, /*Int 10 type / priority level ExtLevel / 2 */ 52 OS_INTR_CONNECT_11, /*Int 11 type / priority level ExtLevel / 2 */ 53 OS_INTR_CONNECT_12, /*Int 12 type / priority level ExtLevel / 2 */ 54 OS_INTR_CONNECT_13, /*Int 13 type / priority level ExtLevel / 2 */ 55 OS_INTR_CONNECT_14, /*Int 14 type / priority level ExtLevel / 2 */ 56 OS_INTR_CONNECT_15, /*Int 15 type / priority level ExtLevel / 1 */ 57 OS_INTR_CONNECT_16, /*Int 16 type / priority level ExtLevel / 1 */ 58 OS_INTR_CONNECT_17, /*Int 17 type / priority level ExtLevel / 1 */ 59 OS_INTR_CONNECT_18, /*Int 18 type / priority level ExtLevel / 1 */ 60 OS_INTR_CONNECT_19, /*Int 19 type / priority level Timer / 2 */ 61 OS_INTR_CONNECT_20, /*Int 20 type / priority level ExtLevel / 1 */ 62 OS_INTR_CONNECT_21, /*Int 21 type / priority level ExtLevel / 1 */ 63 OS_INTR_CONNECT_22, /*Int 22 type / priority level ExtLevel / 1 */ 64 OS_INTR_CONNECT_23, /*Int 23 type / priority level ExtLevel / 1 */ 65 OS_INTR_CONNECT_24, /*Int 24 type / priority level ExtLevel / 1 */ 66 OS_INTR_CONNECT_25, /*Int 25 type / priority level ExtLevel / 1 */ 67 OS_INTR_CONNECT_26, /*Int 26 type / priority level ExtLevel / 1 */ 68 OS_INTR_CONNECT_27, /*Int 27 type / priority level ExtLevel / 1 */ 69 OS_INTR_CONNECT_28, /*Int 28 type / priority level ExtLevel / 1 */ 70 OS_INTR_CONNECT_29, /*Int 29 type / priority level ExtLevel / 1 */ 71 OS_INTR_CONNECT_30, /*Int 30 type / priority level ExtLevel / 1 */ 72 OS_INTR_CONNECT_31, /*Int 31 type / priority level ExtEdge / 1 */ 73 OS_INTR_CONNECT_BUTT 74 }; 75 76 #define UCOM_SET_WFI_NMI(var1) asm ("waiti 5": :) 77 78 #define UCOM_FlushCache(pAddr, uwSize) \ 79 xthal_dcache_region_writeback(pAddr, uwSize) 80 81 #define UCOM_FlushCacheAll() \ 82 xthal_dcache_all_writeback() 83 84 #define UCOM_InvalidateCache(pAddr, uwSize) \ 85 xthal_dcache_region_invalidate(pAddr, uwSize) 86 87 #define UCOM_InvalidateCacheAll() \ 88 xthal_dcache_all_invalidate() 89 90 #define ADD_TAG asm("movi a1, 0xdeadbaaf \n movi a2, 0xe8075e80 \n s32i a1, a2, 0": :) 91 92 //typedef void (*HOOK_FUN_TYPE)(void); 93 typedef void (*HOOK_FUN_TYPE)(unsigned int); 94 95 typedef void (*INTR_HOOK_FUN_TYPE )(unsigned int uwIntNo); 96 97 typedef void (*VOS_EXCEPTION_HOOK_FUNC)( unsigned int uwExceptionNo); 98 99 extern void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT]; 100 101 extern void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook); 102 103 extern void VOS_EnableInterrupt(unsigned int uwIntNo); 104 extern void VOS_DisableInterrupt(unsigned int uwIntNo); 105 106 extern void OS_UserExit(void); 107 108 109 #endif /* end of cpu_c.h */ 110