1 /* 2 * Copyright (c) 2019 Nuclei Limited. All rights reserved. 3 * Copyright (c) 2021 TOKITA Hiroshi 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 /** 9 * @file 10 * @brief Define Nuclei specific CSR and related definitions. 11 * 12 * This header contains Nuclei specific definitions. 13 * Use arch/riscv/csr.h for RISC-V standard CSR and definitions. 14 */ 15 16 #ifndef ZEPHYR_SOC_RISCV_RISCV_PRIVILEGED_COMMON_NUCLEI_NUCLEI_CSR_H_ 17 #define ZEPHYR_SOC_RISCV_RISCV_PRIVILEGED_COMMON_NUCLEI_NUCLEI_CSR_H_ 18 19 #include <zephyr/sys/util_macro.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define UCODE_OV (0x1U) 26 27 #define WFE_WFE (0x1U) 28 #define TXEVT_TXEVT (0x1U) 29 #define SLEEPVALUE_SLEEPVALUE (0x1U) 30 31 #define MCOUNTINHIBIT_IR BIT(2U) 32 #define MCOUNTINHIBIT_CY BIT(0U) 33 34 #define MILM_CTL_ILM_BPA (((1ULL << ((__riscv_xlen) - 10U)) - 1U) << 10U) 35 #define MILM_CTL_ILM_RWECC BIT(3U) 36 #define MILM_CTL_ILM_ECC_EXCP_EN BIT(2U) 37 #define MILM_CTL_ILM_ECC_EN BIT(1U) 38 #define MILM_CTL_ILM_EN BIT(0U) 39 40 #define MDLM_CTL_DLM_BPA (((1ULL << ((__riscv_xlen) - 10U)) - 1U) << 10U) 41 #define MDLM_CTL_DLM_RWECC BIT(3U) 42 #define MDLM_CTL_DLM_ECC_EXCP_EN BIT(2U) 43 #define MDLM_CTL_DLM_ECC_EN BIT(1U) 44 #define MDLM_CTL_DLM_EN BIT(0U) 45 46 #define MSUBM_PTYP (0x3U << 8U) 47 #define MSUBM_TYP (0x3U << 6U) 48 49 #define MDCAUSE_MDCAUSE (0x3U) 50 51 #define MMISC_CTL_NMI_CAUSE_FFF BIT(9U) 52 #define MMISC_CTL_MISALIGN BIT(6U) 53 #define MMISC_CTL_BPu BIT(3U) 54 55 #define MCACHE_CTL_IC_EN BIT(0U) 56 #define MCACHE_CTL_IC_SCPD_MOD BIT(1U) 57 #define MCACHE_CTL_IC_ECC_EN BIT(2U) 58 #define MCACHE_CTL_IC_ECC_EXCP_EN BIT(3U) 59 #define MCACHE_CTL_IC_RWTECC BIT(4U) 60 #define MCACHE_CTL_IC_RWDECC BIT(5U) 61 #define MCACHE_CTL_DC_EN BIT(16U) 62 #define MCACHE_CTL_DC_ECC_EN BIT(17U) 63 #define MCACHE_CTL_DC_ECC_EXCP_EN BIT(18U) 64 #define MCACHE_CTL_DC_RWTECC BIT(19U) 65 #define MCACHE_CTL_DC_RWDECC BIT(20U) 66 67 #define MTVT2_MTVT2EN BIT(0U) 68 #define MTVT2_COMMON_CODE_ENTRY (((1ULL << ((__riscv_xlen) - 2U)) - 1U) << 2U) 69 70 #define MCFG_INFO_TEE BIT(0U) 71 #define MCFG_INFO_ECC BIT(1U) 72 #define MCFG_INFO_CLIC BIT(2U) 73 #define MCFG_INFO_PLIC BIT(3U) 74 #define MCFG_INFO_FIO BIT(4U) 75 #define MCFG_INFO_PPI BIT(5U) 76 #define MCFG_INFO_NICE BIT(6U) 77 #define MCFG_INFO_ILM BIT(7U) 78 #define MCFG_INFO_DLM BIT(8U) 79 #define MCFG_INFO_ICACHE BIT(9U) 80 #define MCFG_INFO_DCACHE BIT(10U) 81 82 #define MICFG_IC_SET (0xFU << 0U) 83 #define MICFG_IC_WAY (0x7U << 4U) 84 #define MICFG_IC_LSIZE (0x7U << 7U) 85 #define MICFG_IC_ECC (0x1U << 10U) 86 #define MICFG_ILM_SIZE (0x1FU << 16U) 87 #define MICFG_ILM_XONLY (0x1U << 21U) 88 #define MICFG_ILM_ECC (0x1U << 22U) 89 90 #define MDCFG_DC_SET (0xFU << 0U) 91 #define MDCFG_DC_WAY (0x7U << 4U) 92 #define MDCFG_DC_LSIZE (0x7U << 7U) 93 #define MDCFG_DC_ECC (0x1U << 10U) 94 #define MDCFG_DLM_SIZE (0x1FU << 16U) 95 #define MDCFG_DLM_ECC (0x1U << 21U) 96 97 #define MPPICFG_INFO_PPI_SIZE (0x1FU << 1U) 98 #define MPPICFG_INFO_PPI_BPA (((1ULL << ((__riscv_xlen) - 10U)) - 1U) << 10U) 99 100 #define MFIOCFG_INFO_FIO_SIZE (0x1FU << 1) 101 #define MFIOCFG_INFO_FIO_BPA (((1ULL << ((__riscv_xlen) - 10U)) - 1U) << 10U) 102 103 #define MECC_LOCK_ECC_LOCK (0x1U) 104 105 #define MECC_CODE_CODE (0x1FFU) 106 #define MECC_CODE_RAMID (0x1FU << 16U) 107 #define MECC_CODE_SRAMID (0x1FU << 24U) 108 109 #define CCM_SUEN_SUEN (0x1U << 0U) 110 #define CCM_DATA_DATA (0x7U << 0U) 111 #define CCM_COMMAND_COMMAND (0x1FU << 0U) 112 113 #define FRM_RNDMODE_RNE 0x0U 114 #define FRM_RNDMODE_RTZ 0x1U 115 #define FRM_RNDMODE_RDN 0x2U 116 #define FRM_RNDMODE_RUP 0x3U 117 #define FRM_RNDMODE_RMM 0x4U 118 #define FRM_RNDMODE_DYN 0x7U 119 120 #define FFLAGS_AE_NX BIT(0U) 121 #define FFLAGS_AE_UF BIT(1U) 122 #define FFLAGS_AE_OF BIT(2U) 123 #define FFLAGS_AE_DZ BIT(3U) 124 #define FFLAGS_AE_NV BIT(4U) 125 126 #define MSTATUS_SD MSTATUS32_SD 127 #define SSTATUS_SD SSTATUS32_SD 128 #define RISCV_PGLEVEL_BITS 10 129 130 #define RISCV_PGSHIFT 12U 131 #define RISCV_PGSIZE (1U << RISCV_PGSHIFT) 132 133 #define CSR_SPMPCFG0 0x1A0U 134 #define CSR_SPMPCFG1 0x1A1U 135 #define CSR_SPMPCFG2 0x1A2U 136 #define CSR_SPMPCFG3 0x1A3U 137 #define CSR_SPMPADDR0 0x1B0U 138 #define CSR_SPMPADDR1 0x1B1U 139 #define CSR_SPMPADDR2 0x1B2U 140 #define CSR_SPMPADDR3 0x1B3U 141 #define CSR_SPMPADDR4 0x1B4U 142 #define CSR_SPMPADDR5 0x1B5U 143 #define CSR_SPMPADDR6 0x1B6U 144 #define CSR_SPMPADDR7 0x1B7U 145 #define CSR_SPMPADDR8 0x1B8U 146 #define CSR_SPMPADDR9 0x1B9U 147 #define CSR_SPMPADDR10 0x1BAU 148 #define CSR_SPMPADDR11 0x1BBU 149 #define CSR_SPMPADDR12 0x1BCU 150 #define CSR_SPMPADDR13 0x1BDU 151 #define CSR_SPMPADDR14 0x1BEU 152 #define CSR_SPMPADDR15 0x1BFU 153 154 #define CSR_JALSNXTI 0x947U 155 #define CSR_STVT2 0x948U 156 #define CSR_PUSHSCAUSE 0x949U 157 #define CSR_PUSHSEPC 0x94AU 158 159 #define CSR_MTVT 0x307U 160 #define CSR_MNXTI 0x345U 161 #define CSR_MINTSTATUS 0x346U 162 #define CSR_MSCRATCHCSW 0x348U 163 #define CSR_MSCRATCHCSWL 0x349U 164 #define CSR_MCLICBASE 0x350U 165 166 #define CSR_UCODE 0x801U 167 168 #define CSR_MILM_CTL 0x7C0U 169 #define CSR_MDLM_CTL 0x7C1U 170 #define CSR_MECC_CODE 0x7C2U 171 #define CSR_MNVEC 0x7C3U 172 #define CSR_MSUBM 0x7C4U 173 #define CSR_MDCAUSE 0x7C9U 174 #define CSR_MCACHE_CTL 0x7CAU 175 #define CSR_MMISC_CTL 0x7D0U 176 #define CSR_MSAVESTATUS 0x7D6U 177 #define CSR_MSAVEEPC1 0x7D7U 178 #define CSR_MSAVECAUSE1 0x7D8U 179 #define CSR_MSAVEEPC2 0x7D9U 180 #define CSR_MSAVECAUSE2 0x7DAU 181 #define CSR_MSAVEDCAUSE1 0x7DBU 182 #define CSR_MSAVEDCAUSE2 0x7DCU 183 #define CSR_MTLB_CTL 0x7DDU 184 #define CSR_MECC_LOCK 0x7DEU 185 #define CSR_MFP16MODE 0x7E2U 186 #define CSR_LSTEPFORC 0x7E9U 187 #define CSR_PUSHMSUBM 0x7EBU 188 #define CSR_MTVT2 0x7ECU 189 #define CSR_JALMNXTI 0x7EDU 190 #define CSR_PUSHMCAUSE 0x7EEU 191 #define CSR_PUSHMEPC 0x7EFU 192 #define CSR_MPPICFG_INFO 0x7F0U 193 #define CSR_MFIOCFG_INFO 0x7F1U 194 #define CSR_MSMPCFG_INFO 0x7F7U 195 #define CSR_SLEEPVALUE 0x811U 196 #define CSR_TXEVT 0x812U 197 #define CSR_WFE 0x810U 198 #define CSR_MICFG_INFO 0xFC0U 199 #define CSR_MDCFG_INFO 0xFC1U 200 #define CSR_MCFG_INFO 0xFC2U 201 #define CSR_MTLBCFG_INFO 0xFC3U 202 203 #define CSR_CCM_MBEGINADDR 0x7CBU 204 #define CSR_CCM_MCOMMAND 0x7CCU 205 #define CSR_CCM_MDATA 0x7CDU 206 #define CSR_CCM_SUEN 0x7CEU 207 #define CSR_CCM_SBEGINADDR 0x5CBU 208 #define CSR_CCM_SCOMMAND 0x5CCU 209 #define CSR_CCM_SDATA 0x5CDU 210 #define CSR_CCM_UBEGINADDR 0x4CBU 211 #define CSR_CCM_UCOMMAND 0x4CCU 212 #define CSR_CCM_UDATA 0x4CDU 213 #define CSR_CCM_FPIPE 0x4CFU 214 215 #define CAUSE_MISALIGNED_FETCH 0x0U 216 #define CAUSE_FAULT_FETCH 0x1U 217 #define CAUSE_ILLEGAL_INSTRUCTION 0x2U 218 #define CAUSE_BREAKPOINT 0x3U 219 #define CAUSE_MISALIGNED_LOAD 0x4U 220 #define CAUSE_FAULT_LOAD 0x5U 221 #define CAUSE_MISALIGNED_STORE 0x6U 222 #define CAUSE_FAULT_STORE 0x7U 223 #define CAUSE_USER_ECALL 0x8U 224 #define CAUSE_SUPERVISOR_ECALL 0x9U 225 #define CAUSE_HYPERVISOR_ECALL 0xaU 226 #define CAUSE_MACHINE_ECALL 0xbU 227 228 #define DCAUSE_FAULT_FETCH_PMP 0x1U 229 #define DCAUSE_FAULT_FETCH_INST 0x2U 230 231 #define DCAUSE_FAULT_LOAD_PMP 0x1U 232 #define DCAUSE_FAULT_LOAD_INST 0x2U 233 #define DCAUSE_FAULT_LOAD_NICE 0x3U 234 235 #define DCAUSE_FAULT_STORE_PMP 0x1U 236 #define DCAUSE_FAULT_STORE_INST 0x2U 237 238 #ifdef __cplusplus 239 } 240 #endif 241 242 #endif /* ZEPHYR_SOC_RISCV_RISCV_PRIVILEGED_COMMON_NUCLEI_NUCLEI_CSR_H_ */ 243