|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | +// --------------------------------------------------------------------- |
| 16 | +// File: caliptra_isr.h |
| 17 | +// Description: |
| 18 | +// Provides function declarations for use by external test files, so |
| 19 | +// that the ISR functionality may behave like a library. |
| 20 | +// TODO: |
| 21 | +// This header file includes inline function definitions for event and |
| 22 | +// test specific interrupt service behavior, so it should be copied and |
| 23 | +// modified for each test. |
| 24 | +// --------------------------------------------------------------------- |
| 25 | + |
| 26 | +#ifndef CALIPTRA_ISR_H |
| 27 | + #define CALIPTRA_ISR_H |
| 28 | + |
| 29 | +#define EN_ISR_PRINTS 1 |
| 30 | + |
| 31 | +#include "caliptra_defines.h" |
| 32 | +#include <stdint.h> |
| 33 | +#include "printf.h" |
| 34 | + |
| 35 | +/* --------------- symbols/typedefs --------------- */ |
| 36 | +typedef struct { |
| 37 | + uint32_t doe_error; |
| 38 | + uint32_t doe_notif; |
| 39 | + uint32_t ecc_error; |
| 40 | + uint32_t ecc_notif; |
| 41 | + uint32_t hmac_error; |
| 42 | + uint32_t hmac_notif; |
| 43 | + uint32_t kv_error; |
| 44 | + uint32_t kv_notif; |
| 45 | + uint32_t sha512_error; |
| 46 | + uint32_t sha512_notif; |
| 47 | + uint32_t sha256_error; |
| 48 | + uint32_t sha256_notif; |
| 49 | + uint32_t soc_ifc_error; |
| 50 | + uint32_t soc_ifc_notif; |
| 51 | + uint32_t sha512_acc_error; |
| 52 | + uint32_t sha512_acc_notif; |
| 53 | + uint32_t abr_error; |
| 54 | + uint32_t abr_notif; |
| 55 | + uint32_t axi_dma_error; |
| 56 | + uint32_t axi_dma_notif; |
| 57 | +} caliptra_intr_received_s; |
| 58 | +extern volatile caliptra_intr_received_s cptra_intr_rcv; |
| 59 | + |
| 60 | +////////////////////////////////////////////////////////////////////////////// |
| 61 | +// Function Declarations |
| 62 | +// |
| 63 | + |
| 64 | +// Performs all the CSR setup to configure and enable vectored external interrupts |
| 65 | +void init_interrupts(void); |
| 66 | + |
| 67 | +// These inline functions are used to insert event-specific functionality into the |
| 68 | +// otherwise generic ISR that gets laid down by the parameterized macro "nonstd_veer_isr" |
| 69 | +inline void service_doe_error_intr() {return;} |
| 70 | +inline void service_doe_notif_intr() { |
| 71 | + uint32_t * reg = (uint32_t *) (CLP_DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 72 | + uint32_t sts = *reg; |
| 73 | + /* Write 1 to Clear the pending interrupt */ |
| 74 | + if (sts & DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 75 | + *reg = DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 76 | + cptra_intr_rcv.doe_notif |= DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 77 | + } |
| 78 | + if (sts == 0) { |
| 79 | + VPRINTF(ERROR,"bad doe_notif_intr sts:%x\n", sts); |
| 80 | + SEND_STDOUT_CTRL(0x1); |
| 81 | + while(1); |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +inline void service_ecc_error_intr() {return;} |
| 86 | +inline void service_ecc_notif_intr() { |
| 87 | + uint32_t * reg = (uint32_t *) (CLP_ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 88 | + uint32_t sts = *reg; |
| 89 | + /* Write 1 to Clear the pending interrupt */ |
| 90 | + if (sts & ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 91 | + *reg = ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 92 | + cptra_intr_rcv.ecc_notif |= ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 93 | + } |
| 94 | + if (sts == 0) { |
| 95 | + VPRINTF(ERROR,"bad ecc_notif_intr sts:%x\n", sts); |
| 96 | + SEND_STDOUT_CTRL(0x1); |
| 97 | + while(1); |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +inline void service_hmac_error_intr() {return;} |
| 102 | +inline void service_hmac_notif_intr() { |
| 103 | + uint32_t * reg = (uint32_t *) (CLP_HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 104 | + uint32_t sts = *reg; |
| 105 | + /* Write 1 to Clear the pending interrupt */ |
| 106 | + if (sts & HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 107 | + *reg = HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 108 | + cptra_intr_rcv.hmac_notif |= HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 109 | + } |
| 110 | + if (sts == 0) { |
| 111 | + VPRINTF(ERROR,"bad hmac_notif_intr sts:%x\n", sts); |
| 112 | + SEND_STDOUT_CTRL(0x1); |
| 113 | + while(1); |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +inline void service_kv_error_intr() {return;} |
| 118 | +inline void service_kv_notif_intr() {return;} |
| 119 | +inline void service_sha512_error_intr() {return;} |
| 120 | +inline void service_sha512_notif_intr() { |
| 121 | + uint32_t * reg = (uint32_t *) (CLP_SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 122 | + uint32_t sts = *reg; |
| 123 | + /* Write 1 to Clear the pending interrupt */ |
| 124 | + if (sts & SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 125 | + *reg = SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 126 | + cptra_intr_rcv.sha512_notif |= SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 127 | + } |
| 128 | + if (sts == 0) { |
| 129 | + VPRINTF(ERROR,"bad sha512_notif_intr sts:%x\n", sts); |
| 130 | + SEND_STDOUT_CTRL(0x1); |
| 131 | + while(1); |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +inline void service_sha256_error_intr() {return;} |
| 136 | +inline void service_sha256_notif_intr() { |
| 137 | + uint32_t * reg = (uint32_t *) (CLP_SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 138 | + uint32_t sts = *reg; |
| 139 | + /* Write 1 to Clear the pending interrupt */ |
| 140 | + if (sts & SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 141 | + *reg = SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 142 | + cptra_intr_rcv.sha256_notif |= SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 143 | + } |
| 144 | + if (sts == 0) { |
| 145 | + VPRINTF(ERROR,"bad sha256_notif_intr sts:%x\n", sts); |
| 146 | + SEND_STDOUT_CTRL(0x1); |
| 147 | + while(1); |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | + |
| 152 | +inline void service_soc_ifc_error_intr() { |
| 153 | + uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R); |
| 154 | + uint32_t sts = *reg; |
| 155 | + /* Write 1 to Clear the pending interrupt */ |
| 156 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK) { |
| 157 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK; |
| 158 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK; |
| 159 | + } |
| 160 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK) { |
| 161 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK; |
| 162 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK; |
| 163 | + } |
| 164 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK) { |
| 165 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK; |
| 166 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK; |
| 167 | + } |
| 168 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK) { |
| 169 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK; |
| 170 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK; |
| 171 | + } |
| 172 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK) { |
| 173 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK; |
| 174 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK; |
| 175 | + } |
| 176 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK) { |
| 177 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK; |
| 178 | + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK; |
| 179 | + } |
| 180 | + if (sts == 0) { |
| 181 | + VPRINTF(ERROR,"bad soc_ifc_error_intr sts:%x\n", sts); |
| 182 | + SEND_STDOUT_CTRL(0x1); |
| 183 | + while(1); |
| 184 | + } |
| 185 | +} |
| 186 | + |
| 187 | +inline void service_soc_ifc_notif_intr () { |
| 188 | + uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 189 | + uint32_t sts = *reg; |
| 190 | + /* Write 1 to Clear the pending interrupt */ |
| 191 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK) { |
| 192 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK; |
| 193 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK; |
| 194 | + } |
| 195 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK) { |
| 196 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK; |
| 197 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK; |
| 198 | + } |
| 199 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK) { |
| 200 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK; |
| 201 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK; |
| 202 | + } |
| 203 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK) { |
| 204 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK; |
| 205 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK; |
| 206 | + } |
| 207 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK) { |
| 208 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK; |
| 209 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK; |
| 210 | + } |
| 211 | + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK) { |
| 212 | + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK; |
| 213 | + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK; |
| 214 | + } |
| 215 | + if (sts == 0) { |
| 216 | + VPRINTF(ERROR,"bad soc_ifc_notif_intr sts:%x\n", sts); |
| 217 | + SEND_STDOUT_CTRL(0x1); |
| 218 | + while(1); |
| 219 | + } |
| 220 | +} |
| 221 | + |
| 222 | +inline void service_sha512_acc_error_intr() {return;} |
| 223 | +inline void service_sha512_acc_notif_intr() { |
| 224 | + uint32_t * reg = (uint32_t *) (CLP_SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); |
| 225 | + uint32_t sts = *reg; |
| 226 | + /* Write 1 to Clear the pending interrupt */ |
| 227 | + if (sts & SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { |
| 228 | + *reg = SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 229 | + cptra_intr_rcv.sha512_acc_notif |= SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; |
| 230 | + } |
| 231 | + if (sts == 0) { |
| 232 | + VPRINTF(ERROR,"bad sha512_acc_notif_intr sts:%x\n", sts); |
| 233 | + SEND_STDOUT_CTRL(0x1); |
| 234 | + while(1); |
| 235 | + } |
| 236 | +} |
| 237 | + |
| 238 | +inline void service_abr_error_intr() {return;} |
| 239 | +inline void service_abr_notif_intr() {return;} |
| 240 | +inline void service_axi_dma_error_intr() {return;} |
| 241 | +inline void service_axi_dma_notif_intr() {return;} |
| 242 | + |
| 243 | + |
| 244 | +#endif //CALIPTRA_ISR_H |
0 commit comments