From b906d25b51f65366d68bbf3a498ae5c54c196184 Mon Sep 17 00:00:00 2001 From: Caleb <11879229+calebofearth@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:55:19 -0700 Subject: [PATCH] [UVM,DOC] Define AHB address alignment requirements and enforce in UVM test env (#576) * Update makefile for 48KiB size of ROM * Update uvm predictor to allow exception for unaligned dir-mode SRAM reads * Update RDL reg file for Caliptra top to include Mailbox SRAM (dir mode) * Update RDL doc generator to include memory nodes (for mbox_sram) * Send unaligned address to scoreboard (when valid) to avoid txn mismatch error * Update HW spec to describe direct-mode mailbox SRAM access and AHB alignment requirements * MICROSOFT AUTOMATED PIPELINE: Stamp 'cwhitehead-msft-UVM-algn-update' with updated timestamp and hash after successful run * Single-byte-sized reads are allowed; address must be DW aligned unless a byte-read from SRAM dir mode * Use dw size when printing stdout to generic_output_wires; byte-writes are not permitted * MICROSOFT AUTOMATED PIPELINE: Stamp 'cwhitehead-msft-UVM-algn-update' with updated timestamp and hash after successful run * Clarify size requirement * Add a smoke test to validate byte-access to Mailbox SRAM * Reduce logic for test speedup * Two-step type cast to resolve compiler warning * MICROSOFT AUTOMATED PIPELINE: Stamp 'cwhitehead-msft-UVM-algn-update' with updated timestamp and hash after successful run --- .github/workflow_metadata/pr_hash | 2 +- .github/workflow_metadata/pr_timestamp | 2 +- docs/CaliptraHardwareSpecification.md | 4 + src/integration/rtl/caliptra_reg.h | 2 + src/integration/rtl/caliptra_reg.rdl | 9 + src/integration/rtl/caliptra_reg_defines.svh | 2 + src/integration/stimulus/L0_regression.yml | 1 + ...liptra_top_nightly_directed_regression.yml | 1 + .../c_intr_handler/c_intr_handler.c | 4 +- .../test_suites/caliptra_demo/caliptra_demo.c | 4 +- .../test_suites/caliptra_fmc/caliptra_fmc.c | 2 +- .../test_suites/caliptra_rt/caliptra_rt.c | 2 +- .../test_suites/caliptra_top/caliptra_top.c | 2 +- .../fw_test_rom/fw_test_rom.makefile | 2 +- .../test_suites/iccm_lock/iccm_lock.c | 4 +- .../test_suites/libs/printf/printf.c | 4 +- .../test_suites/libs/riscv_hw_if/crt0.s | 6 +- .../pv_hash_and_sign/pv_hash_and_sign.c | 4 +- .../test_suites/pv_hash_reset/pv_hash_reset.c | 6 +- .../randomized_pcr_signing.c | 4 +- .../smoke_test_cg_wdt/smoke_test_cg_wdt.c | 10 +- .../smoke_test_clk_gating.c | 6 +- .../smoke_test_datavault_basic.c | 8 +- .../smoke_test_datavault_lock.c | 8 +- .../smoke_test_datavault_mini.c | 4 +- .../smoke_test_datavault_reset.c | 8 +- .../smoke_test_doe_cg/smoke_test_doe_cg.c | 6 +- .../smoke_test_doe_rand/smoke_test_doe_rand.c | 6 +- .../smoke_test_doe_scan/smoke_test_doe_scan.c | 6 +- .../smoke_test_ecc/smoke_test_ecc.c | 4 +- .../smoke_test_ecc_errortrigger.c | 6 +- .../smoke_test_fw_kv_backtoback_hmac.c | 4 +- .../smoke_test_hmac/smoke_test_hmac.c | 4 +- .../smoke_test_hw_config.c | 4 +- .../smoke_test_iccm_reset.c | 8 +- .../smoke_test_kv_cg/smoke_test_kv_cg.c | 6 +- .../smoke_test_kv_crypto_flow.c | 8 +- .../smoke_test_kv_ecc_flow.c | 4 +- .../smoke_test_kv_hmac_flow.c | 4 +- .../smoke_test_kv_hmac_multiblock_flow.c | 4 +- .../smoke_test_kv_securitystate.c | 6 +- .../smoke_test_kv_sha512_flow.c | 6 +- .../smoke_test_kv_uds_reset.c | 6 +- .../smoke_test_mbox/smoke_test_mbox.c | 4 +- .../smoke_test_mbox_byte_read/caliptra_isr.h | 247 ++++++++++++++++++ .../smoke_test_mbox_byte_read.c | 128 +++++++++ .../smoke_test_mbox_byte_read.yml | 17 ++ .../smoke_test_mbox_cg/smoke_test_mbox_cg.c | 4 +- .../smoke_test_pcr_signing.c | 4 +- .../smoke_test_pcr_zeroize.c | 4 +- .../smoke_test_qspi/smoke_test_qspi.c | 6 +- .../smoke_test_ras/smoke_test_ras.c | 2 +- .../smoke_test_sha256/smoke_test_sha256.c | 4 +- .../smoke_test_sha256_wntz.c | 4 +- .../smoke_test_sha256_wntz_rand.c | 4 +- .../smoke_test_sha512/smoke_test_sha512.c | 4 +- .../smoke_test_sram_ecc/smoke_test_sram_ecc.c | 4 +- .../smoke_test_trng/smoke_test_trng.c | 6 +- .../smoke_test_uart/smoke_test_uart.c | 6 +- .../smoke_test_wdt/smoke_test_wdt.c | 6 +- .../smoke_test_wdt_rst/smoke_test_wdt_rst.c | 6 +- .../smoke_test_zeroize_crypto.c | 4 +- .../soc_ifc_env_pkg/src/soc_ifc_predictor.svh | 23 +- tools/scripts/reg_doc_gen.py | 14 +- 64 files changed, 572 insertions(+), 132 deletions(-) create mode 100644 src/integration/test_suites/smoke_test_mbox_byte_read/caliptra_isr.h create mode 100644 src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.c create mode 100755 src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml diff --git a/.github/workflow_metadata/pr_hash b/.github/workflow_metadata/pr_hash index 6cf6c73bc..21aeee2c9 100644 --- a/.github/workflow_metadata/pr_hash +++ b/.github/workflow_metadata/pr_hash @@ -1 +1 @@ -7fda014d9c945100c76479d6339a609816bee2b05c7749596d7ad3955555f36606325f7d0e8e9c7df09cb9f954e6094a \ No newline at end of file +87d12e3f1a9f2c2fca2dc4b1da0c727bed238bfaf9919890da2d84936cb226568e05b7a33ff6f6a4ce2e88fd9da0ea00 \ No newline at end of file diff --git a/.github/workflow_metadata/pr_timestamp b/.github/workflow_metadata/pr_timestamp index 8990211f3..647863f45 100644 --- a/.github/workflow_metadata/pr_timestamp +++ b/.github/workflow_metadata/pr_timestamp @@ -1 +1 @@ -1723748145 \ No newline at end of file +1724699665 \ No newline at end of file diff --git a/docs/CaliptraHardwareSpecification.md b/docs/CaliptraHardwareSpecification.md index 89a1021f5..88c05209e 100644 --- a/docs/CaliptraHardwareSpecification.md +++ b/docs/CaliptraHardwareSpecification.md @@ -218,6 +218,8 @@ Each IP component in the Caliptra system uses a native AHB data width of 32-bits As a result of this implementation, 64-bit data transfers are not supported on the Caliptra AHB fabric. Firmware running on the internal microprocessor may only access memory and registers using a 32-bit or smaller request size, as 64-bit transfer requests will be corrupted. +All AHB requests internal to Caliptra must be to an address that is aligned to the native data width of 4-bytes. Any AHB read or write by the Caliptra RISC-V processor that is not aligned to this boundary will fail to decode to the targeted register, will fail to write the submitted data, and will return read data of all zeroes. All AHB requests must also use the native size of 4 bytes (encoded in the hsize signal with a value of 2). The only exception to this is when the RISC-V processor performs byte-aligned, single-byte reads to the Mailbox SRAM using the direct-access mechanism described in [SoC Mailbox](#SoC-mailbox). In this case, a byte-aligned address must be accompanied by the correct size indicator for a single-byte access. Read addresses for byte accesses are aligned to the 4-byte boundary in hardware, and will successfully complete with the correct data at the specified byte offset. Direct mode SRAM writes must be 4-bytes in size and must be aligned to the 4-byte boundary. Hardware writes the entire dword of data to the aligned address, so attempts to write a partial word of data may result in data corruption. + ## Cryptographic subsystem For details, see the [Cryptographic subsystem architecture](#cryptographic-subsystem-architecture) section. @@ -390,6 +392,8 @@ The UART block architecture inputs and outputs are described in the following ta For more information on the mailbox protocol, see [Mailbox](https://github.com/chipsalliance/caliptra-rtl/blob/main/docs/CaliptraIntegrationSpecification.md#mailbox) in the Caliptra Integration Specification. Mailbox registers accessible to the Caliptra microcontroller are defined in [internal-regs/mbox_csr](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.mbox_csr). +The RISC-V processor is able to access the SoC mailbox SRAM using a direct access mode (which bypasses the defined mailbox protocol). The addresses for performing this access are described in [SoC interface subsystem](#SoC-interface-subsystem) and in [mbox_sram](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.mbox_sram). In this mode, firmware must first acquire the mailbox lock. Then, reads and writes to the direct access address region will go directly to the SRAM block. Firmware must release the mailbox lock by writing to the [mbox_unlock](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.mbox_csr.mbox_unlock) register after direct access operations are completed. + ## Security state diff --git a/src/integration/rtl/caliptra_reg.h b/src/integration/rtl/caliptra_reg.h index 1354a0b6e..2c549e70c 100644 --- a/src/integration/rtl/caliptra_reg.h +++ b/src/integration/rtl/caliptra_reg.h @@ -5174,6 +5174,8 @@ #define ENTROPY_SRC_REG_MAIN_SM_STATE (0xe0) #define ENTROPY_SRC_REG_MAIN_SM_STATE_MAIN_SM_STATE_LOW (0) #define ENTROPY_SRC_REG_MAIN_SM_STATE_MAIN_SM_STATE_MASK (0x1ff) +#define CLP_MBOX_SRAM_BASE_ADDR (0x30000000) +#define CLP_MBOX_SRAM_END_ADDR (0x3001ffff) #define CLP_MBOX_CSR_BASE_ADDR (0x30020000) #define CLP_MBOX_CSR_MBOX_LOCK (0x30020000) #define MBOX_CSR_MBOX_LOCK (0x0) diff --git a/src/integration/rtl/caliptra_reg.rdl b/src/integration/rtl/caliptra_reg.rdl index 6f98b9bca..e96c5ccf6 100644 --- a/src/integration/rtl/caliptra_reg.rdl +++ b/src/integration/rtl/caliptra_reg.rdl @@ -40,6 +40,15 @@ addrmap clp { entropy_src entropy_src_reg @ 0x2000_3000; + mem {name="Mailbox SRAM"; + desc="Mailbox SRAM for Caliptra direct-mode accesses. Accessible to Caliptra only after acquiring mbox_lock. + [br]Caliptra Access: RW + [br]SOC Access: -"; + memwidth=32; + mementries=32768; + sw=rw; + } external mbox_sram @ 0x3000_0000; + mbox_csr mbox_csr @ 0x3002_0000; sha512_acc_csr sha512_acc_csr @ 0x3002_1000; diff --git a/src/integration/rtl/caliptra_reg_defines.svh b/src/integration/rtl/caliptra_reg_defines.svh index 56fe762f9..a096ab286 100644 --- a/src/integration/rtl/caliptra_reg_defines.svh +++ b/src/integration/rtl/caliptra_reg_defines.svh @@ -5174,6 +5174,8 @@ `define ENTROPY_SRC_REG_MAIN_SM_STATE (32'he0) `define ENTROPY_SRC_REG_MAIN_SM_STATE_MAIN_SM_STATE_LOW (0) `define ENTROPY_SRC_REG_MAIN_SM_STATE_MAIN_SM_STATE_MASK (32'h1ff) +`define CLP_MBOX_SRAM_BASE_ADDR (32'h30000000) +`define CLP_MBOX_SRAM_END_ADDR (32'h3001ffff) `define CLP_MBOX_CSR_BASE_ADDR (32'h30020000) `define CLP_MBOX_CSR_MBOX_LOCK (32'h30020000) `define MBOX_CSR_MBOX_LOCK (32'h0) diff --git a/src/integration/stimulus/L0_regression.yml b/src/integration/stimulus/L0_regression.yml index a5846f50e..8f933fc83 100644 --- a/src/integration/stimulus/L0_regression.yml +++ b/src/integration/stimulus/L0_regression.yml @@ -9,6 +9,7 @@ contents: #add back for aes #- ../test_suites/smoke_test_aes/smoke_test_aes.yml - ../test_suites/smoke_test_mbox/smoke_test_mbox.yml + - ../test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml - ../test_suites/smoke_test_mbox_cg/smoke_test_mbox_cg.yml - ../test_suites/smoke_test_sha512/smoke_test_sha512.yml - ../test_suites/smoke_test_sha256/smoke_test_sha256.yml diff --git a/src/integration/stimulus/testsuites/caliptra_top_nightly_directed_regression.yml b/src/integration/stimulus/testsuites/caliptra_top_nightly_directed_regression.yml index 8fc300b35..808fbc6cc 100644 --- a/src/integration/stimulus/testsuites/caliptra_top_nightly_directed_regression.yml +++ b/src/integration/stimulus/testsuites/caliptra_top_nightly_directed_regression.yml @@ -13,6 +13,7 @@ contents: - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_datavault_mini/smoke_test_datavault_mini.yml - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_veer/smoke_test_veer.yml - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_mbox/smoke_test_mbox.yml + - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_sha512/smoke_test_sha512.yml - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_sha256/smoke_test_sha256.yml - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_sha256_wntz/smoke_test_sha256_wntz.yml diff --git a/src/integration/test_suites/c_intr_handler/c_intr_handler.c b/src/integration/test_suites/c_intr_handler/c_intr_handler.c index 01e11447c..98b624eb3 100644 --- a/src/integration/test_suites/c_intr_handler/c_intr_handler.c +++ b/src/integration/test_suites/c_intr_handler/c_intr_handler.c @@ -25,8 +25,8 @@ //#define ee_printf whisperPrintf -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/caliptra_demo/caliptra_demo.c b/src/integration/test_suites/caliptra_demo/caliptra_demo.c index 0cce6583f..67b215aeb 100644 --- a/src/integration/test_suites/caliptra_demo/caliptra_demo.c +++ b/src/integration/test_suites/caliptra_demo/caliptra_demo.c @@ -30,8 +30,8 @@ enum doe_cmd_e { }; /* --------------- Global vars --------------- */ -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY    enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/caliptra_fmc/caliptra_fmc.c b/src/integration/test_suites/caliptra_fmc/caliptra_fmc.c index cf8bcfbf7..aee17aa59 100644 --- a/src/integration/test_suites/caliptra_fmc/caliptra_fmc.c +++ b/src/integration/test_suites/caliptra_fmc/caliptra_fmc.c @@ -38,7 +38,7 @@ extern uintptr_t STACK; /* --------------- Global vars --------------- */ -volatile char* stdout = (char *)STDOUT; +volatile uint32_t* stdout = (uint32_t *)STDOUT; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/caliptra_rt/caliptra_rt.c b/src/integration/test_suites/caliptra_rt/caliptra_rt.c index 88121c44a..136a62028 100644 --- a/src/integration/test_suites/caliptra_rt/caliptra_rt.c +++ b/src/integration/test_suites/caliptra_rt/caliptra_rt.c @@ -42,7 +42,7 @@ extern uintptr_t STACK; /* --------------- Global vars --------------- */ -volatile char* stdout = (char *)STDOUT; +volatile uint32_t* stdout = (uint32_t *)STDOUT; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/caliptra_top/caliptra_top.c b/src/integration/test_suites/caliptra_top/caliptra_top.c index 4ff260755..05991172c 100644 --- a/src/integration/test_suites/caliptra_top/caliptra_top.c +++ b/src/integration/test_suites/caliptra_top/caliptra_top.c @@ -32,7 +32,7 @@ /* --------------- Global symbols/typedefs --------------- */ /* --------------- Global vars --------------- */ -volatile char* stdout = (char *)STDOUT; +volatile uint32_t* stdout = (uint32_t *)STDOUT; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/fw_test_rom/fw_test_rom.makefile b/src/integration/test_suites/fw_test_rom/fw_test_rom.makefile index 214e47a97..812509767 100644 --- a/src/integration/test_suites/fw_test_rom/fw_test_rom.makefile +++ b/src/integration/test_suites/fw_test_rom/fw_test_rom.makefile @@ -58,7 +58,7 @@ clean: # Build program.hex from RUST executable program.hex: key_manifest_pk_hash_val.hex owner_pk_hash_val.hex fw_update.hex $(TEST_DIR)/$(TESTNAME).extracted $(TEST_DIR)/$(TESTNAME) @-echo "Building program.hex from $(TESTNAME) using Crypto Test rules for pre-compiled RUST executables" - $(GCC_PREFIX)-objcopy -I binary -O verilog --pad-to 0x8000 --gap-fill 0xFF --no-change-warnings $(TEST_DIR)/$(TESTNAME) program.hex + $(GCC_PREFIX)-objcopy -I binary -O verilog --pad-to 0xC000 --gap-fill 0xFF --no-change-warnings $(TEST_DIR)/$(TESTNAME) program.hex du -b $(TEST_DIR)/$(TESTNAME) | cut -f1 > $(TESTNAME).size fw_update.hex: $(TEST_DIR)/$(TESTNAME).extracted $(TEST_DIR)/$(TESTNAME_fw) diff --git a/src/integration/test_suites/iccm_lock/iccm_lock.c b/src/integration/test_suites/iccm_lock/iccm_lock.c index 416c449fc..f56c9b953 100644 --- a/src/integration/test_suites/iccm_lock/iccm_lock.c +++ b/src/integration/test_suites/iccm_lock/iccm_lock.c @@ -26,8 +26,8 @@ //#define ee_printf whisperPrintf -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/libs/printf/printf.c b/src/integration/test_suites/libs/printf/printf.c index 367fe3a1d..e4d2d1179 100644 --- a/src/integration/test_suites/libs/printf/printf.c +++ b/src/integration/test_suites/libs/printf/printf.c @@ -17,12 +17,12 @@ #include #include -extern volatile char *stdout; +extern volatile uint32_t *stdout; static int whisperPutc(char c) { - *stdout = c; + *stdout = (uint32_t) c; return (int) c; } diff --git a/src/integration/test_suites/libs/riscv_hw_if/crt0.s b/src/integration/test_suites/libs/riscv_hw_if/crt0.s index aaf6ccd46..fd8b10cff 100644 --- a/src/integration/test_suites/libs/riscv_hw_if/crt0.s +++ b/src/integration/test_suites/libs/riscv_hw_if/crt0.s @@ -90,7 +90,7 @@ bss_cp_loop: _finish: li t0, STDOUT addi t5, zero, 0xff - sb t5, 0(t0) + sw t5, 0(t0) beq zero, zero, _finish .rept 100 nop @@ -121,10 +121,10 @@ li t3, STDOUT la t4, trap_msg trap_print_loop: lb t0, 0(t4) - sb t0, 0(t3) + sw t0, 0(t3) addi t4, t4, 1 bnez t0, trap_print_loop addi t5, zero, 0x1 -sb t5, 0(t3) +sw t5, 0(t3) j early_trap_vector .cfi_endproc diff --git a/src/integration/test_suites/pv_hash_and_sign/pv_hash_and_sign.c b/src/integration/test_suites/pv_hash_and_sign/pv_hash_and_sign.c index f23b86f12..022c3291d 100644 --- a/src/integration/test_suites/pv_hash_and_sign/pv_hash_and_sign.c +++ b/src/integration/test_suites/pv_hash_and_sign/pv_hash_and_sign.c @@ -23,8 +23,8 @@ #include "keyvault.h" #include "sha512.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/pv_hash_reset/pv_hash_reset.c b/src/integration/test_suites/pv_hash_reset/pv_hash_reset.c index d29684875..1a1c6eac1 100644 --- a/src/integration/test_suites/pv_hash_reset/pv_hash_reset.c +++ b/src/integration/test_suites/pv_hash_reset/pv_hash_reset.c @@ -23,9 +23,9 @@ #include "keyvault.h" #include "sha512.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/randomized_pcr_signing/randomized_pcr_signing.c b/src/integration/test_suites/randomized_pcr_signing/randomized_pcr_signing.c index 1b6ff2e68..aaff1b104 100644 --- a/src/integration/test_suites/randomized_pcr_signing/randomized_pcr_signing.c +++ b/src/integration/test_suites/randomized_pcr_signing/randomized_pcr_signing.c @@ -20,8 +20,8 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_cg_wdt/smoke_test_cg_wdt.c b/src/integration/test_suites/smoke_test_cg_wdt/smoke_test_cg_wdt.c index ecbc2b28d..9319a159f 100644 --- a/src/integration/test_suites/smoke_test_cg_wdt/smoke_test_cg_wdt.c +++ b/src/integration/test_suites/smoke_test_cg_wdt/smoke_test_cg_wdt.c @@ -20,10 +20,10 @@ #include "printf.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t hmac_intr_status; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t hmac_intr_status; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; @@ -240,4 +240,4 @@ void main() { VPRINTF(LOW, "WDT independent mode and core is halted\n====================\n"); set_mit0_and_halt_core(mitb0, mie_timer0_ext_int_en); } -} \ No newline at end of file +} diff --git a/src/integration/test_suites/smoke_test_clk_gating/smoke_test_clk_gating.c b/src/integration/test_suites/smoke_test_clk_gating/smoke_test_clk_gating.c index 114abc7d3..438371b04 100644 --- a/src/integration/test_suites/smoke_test_clk_gating/smoke_test_clk_gating.c +++ b/src/integration/test_suites/smoke_test_clk_gating/smoke_test_clk_gating.c @@ -20,9 +20,9 @@ #include "printf.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t hmac_intr_status = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t hmac_intr_status = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_datavault_basic/smoke_test_datavault_basic.c b/src/integration/test_suites/smoke_test_datavault_basic/smoke_test_datavault_basic.c index 78f5a809f..a73abde4f 100644 --- a/src/integration/test_suites/smoke_test_datavault_basic/smoke_test_datavault_basic.c +++ b/src/integration/test_suites/smoke_test_datavault_basic/smoke_test_datavault_basic.c @@ -24,10 +24,10 @@ #include "printf.h" #include "datavault.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; -volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_datavault_lock/smoke_test_datavault_lock.c b/src/integration/test_suites/smoke_test_datavault_lock/smoke_test_datavault_lock.c index 1a995fc73..2f0068646 100644 --- a/src/integration/test_suites/smoke_test_datavault_lock/smoke_test_datavault_lock.c +++ b/src/integration/test_suites/smoke_test_datavault_lock/smoke_test_datavault_lock.c @@ -24,10 +24,10 @@ #include "printf.h" #include "datavault.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; -volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_datavault_mini/smoke_test_datavault_mini.c b/src/integration/test_suites/smoke_test_datavault_mini/smoke_test_datavault_mini.c index b402e7a68..20f193868 100644 --- a/src/integration/test_suites/smoke_test_datavault_mini/smoke_test_datavault_mini.c +++ b/src/integration/test_suites/smoke_test_datavault_mini/smoke_test_datavault_mini.c @@ -31,8 +31,8 @@ #include "printf.h" #include "datavault.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; diff --git a/src/integration/test_suites/smoke_test_datavault_reset/smoke_test_datavault_reset.c b/src/integration/test_suites/smoke_test_datavault_reset/smoke_test_datavault_reset.c index c0a40a93d..68e727903 100644 --- a/src/integration/test_suites/smoke_test_datavault_reset/smoke_test_datavault_reset.c +++ b/src/integration/test_suites/smoke_test_datavault_reset/smoke_test_datavault_reset.c @@ -23,10 +23,10 @@ #include "printf.h" #include "datavault.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; -volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t err_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_doe_cg/smoke_test_doe_cg.c b/src/integration/test_suites/smoke_test_doe_cg/smoke_test_doe_cg.c index 04ab79691..e6b7da9d0 100644 --- a/src/integration/test_suites/smoke_test_doe_cg/smoke_test_doe_cg.c +++ b/src/integration/test_suites/smoke_test_doe_cg/smoke_test_doe_cg.c @@ -21,9 +21,9 @@ #include "printf.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_doe_rand/smoke_test_doe_rand.c b/src/integration/test_suites/smoke_test_doe_rand/smoke_test_doe_rand.c index 4609650e4..394ceada7 100644 --- a/src/integration/test_suites/smoke_test_doe_rand/smoke_test_doe_rand.c +++ b/src/integration/test_suites/smoke_test_doe_rand/smoke_test_doe_rand.c @@ -20,9 +20,9 @@ #include #include "printf.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_doe_scan/smoke_test_doe_scan.c b/src/integration/test_suites/smoke_test_doe_scan/smoke_test_doe_scan.c index d2966ca31..c98b2e51f 100644 --- a/src/integration/test_suites/smoke_test_doe_scan/smoke_test_doe_scan.c +++ b/src/integration/test_suites/smoke_test_doe_scan/smoke_test_doe_scan.c @@ -21,9 +21,9 @@ #include "printf.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_ecc/smoke_test_ecc.c b/src/integration/test_suites/smoke_test_ecc/smoke_test_ecc.c index 164d9ed50..22eed3367 100644 --- a/src/integration/test_suites/smoke_test_ecc/smoke_test_ecc.c +++ b/src/integration/test_suites/smoke_test_ecc/smoke_test_ecc.c @@ -20,8 +20,8 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_ecc_errortrigger/smoke_test_ecc_errortrigger.c b/src/integration/test_suites/smoke_test_ecc_errortrigger/smoke_test_ecc_errortrigger.c index 5233f778c..40bd9099e 100644 --- a/src/integration/test_suites/smoke_test_ecc_errortrigger/smoke_test_ecc_errortrigger.c +++ b/src/integration/test_suites/smoke_test_ecc_errortrigger/smoke_test_ecc_errortrigger.c @@ -20,9 +20,9 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_fw_kv_backtoback_hmac/smoke_test_fw_kv_backtoback_hmac.c b/src/integration/test_suites/smoke_test_fw_kv_backtoback_hmac/smoke_test_fw_kv_backtoback_hmac.c index ec0ff622a..a2d66b5ed 100644 --- a/src/integration/test_suites/smoke_test_fw_kv_backtoback_hmac/smoke_test_fw_kv_backtoback_hmac.c +++ b/src/integration/test_suites/smoke_test_fw_kv_backtoback_hmac/smoke_test_fw_kv_backtoback_hmac.c @@ -23,8 +23,8 @@ #include "printf.h" #include "hmac.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_hmac/smoke_test_hmac.c b/src/integration/test_suites/smoke_test_hmac/smoke_test_hmac.c index f8a30856c..03d2983d1 100644 --- a/src/integration/test_suites/smoke_test_hmac/smoke_test_hmac.c +++ b/src/integration/test_suites/smoke_test_hmac/smoke_test_hmac.c @@ -24,8 +24,8 @@ #else enum printf_verbosity verbosity_g = LOW; #endif -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile caliptra_intr_received_s cptra_intr_rcv = { .doe_error = 0, diff --git a/src/integration/test_suites/smoke_test_hw_config/smoke_test_hw_config.c b/src/integration/test_suites/smoke_test_hw_config/smoke_test_hw_config.c index 78647dcc9..4cc713379 100644 --- a/src/integration/test_suites/smoke_test_hw_config/smoke_test_hw_config.c +++ b/src/integration/test_suites/smoke_test_hw_config/smoke_test_hw_config.c @@ -26,8 +26,8 @@ //#define ee_printf whisperPrintf -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_iccm_reset/smoke_test_iccm_reset.c b/src/integration/test_suites/smoke_test_iccm_reset/smoke_test_iccm_reset.c index c1c3ef473..e3cbd8ab4 100644 --- a/src/integration/test_suites/smoke_test_iccm_reset/smoke_test_iccm_reset.c +++ b/src/integration/test_suites/smoke_test_iccm_reset/smoke_test_iccm_reset.c @@ -20,10 +20,10 @@ #include #include "printf.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; -volatile uint32_t iter __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t iter __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_kv_cg/smoke_test_kv_cg.c b/src/integration/test_suites/smoke_test_kv_cg/smoke_test_kv_cg.c index 6929ed929..a14e5ee9f 100644 --- a/src/integration/test_suites/smoke_test_kv_cg/smoke_test_kv_cg.c +++ b/src/integration/test_suites/smoke_test_kv_cg/smoke_test_kv_cg.c @@ -21,9 +21,9 @@ #include "printf.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_kv_crypto_flow/smoke_test_kv_crypto_flow.c b/src/integration/test_suites/smoke_test_kv_crypto_flow/smoke_test_kv_crypto_flow.c index 552140de5..ba429e276 100644 --- a/src/integration/test_suites/smoke_test_kv_crypto_flow/smoke_test_kv_crypto_flow.c +++ b/src/integration/test_suites/smoke_test_kv_crypto_flow/smoke_test_kv_crypto_flow.c @@ -25,9 +25,9 @@ #include "doe.h" #include -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; @@ -322,4 +322,4 @@ void main(){ printf("%c",0xff); //End the test } -} \ No newline at end of file +} diff --git a/src/integration/test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.c b/src/integration/test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.c index 36d869c0d..e480fed6c 100644 --- a/src/integration/test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.c +++ b/src/integration/test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.c @@ -20,8 +20,8 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_kv_hmac_flow/smoke_test_kv_hmac_flow.c b/src/integration/test_suites/smoke_test_kv_hmac_flow/smoke_test_kv_hmac_flow.c index b69a3f962..f217e0781 100644 --- a/src/integration/test_suites/smoke_test_kv_hmac_flow/smoke_test_kv_hmac_flow.c +++ b/src/integration/test_suites/smoke_test_kv_hmac_flow/smoke_test_kv_hmac_flow.c @@ -23,8 +23,8 @@ #include "printf.h" #include "hmac.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_kv_hmac_multiblock_flow/smoke_test_kv_hmac_multiblock_flow.c b/src/integration/test_suites/smoke_test_kv_hmac_multiblock_flow/smoke_test_kv_hmac_multiblock_flow.c index f7fcd2d75..45c600e83 100644 --- a/src/integration/test_suites/smoke_test_kv_hmac_multiblock_flow/smoke_test_kv_hmac_multiblock_flow.c +++ b/src/integration/test_suites/smoke_test_kv_hmac_multiblock_flow/smoke_test_kv_hmac_multiblock_flow.c @@ -24,8 +24,8 @@ #include "hmac.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.c b/src/integration/test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.c index e6221f101..d3113cf70 100644 --- a/src/integration/test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.c +++ b/src/integration/test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.c @@ -20,9 +20,9 @@ #include #include "printf.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.c b/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.c index 54b2b6060..67c80f7bd 100644 --- a/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.c +++ b/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.c @@ -23,9 +23,9 @@ #include "printf.h" #include "sha512.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.c b/src/integration/test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.c index 829b5a4d0..3ef51ff77 100644 --- a/src/integration/test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.c +++ b/src/integration/test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.c @@ -20,9 +20,9 @@ #include #include "printf.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_mbox/smoke_test_mbox.c b/src/integration/test_suites/smoke_test_mbox/smoke_test_mbox.c index 1ad31280c..2a8a3f3ff 100644 --- a/src/integration/test_suites/smoke_test_mbox/smoke_test_mbox.c +++ b/src/integration/test_suites/smoke_test_mbox/smoke_test_mbox.c @@ -19,8 +19,8 @@ #include "printf.h" #include "caliptra_isr.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_mbox_byte_read/caliptra_isr.h b/src/integration/test_suites/smoke_test_mbox_byte_read/caliptra_isr.h new file mode 100644 index 000000000..8f5779e04 --- /dev/null +++ b/src/integration/test_suites/smoke_test_mbox_byte_read/caliptra_isr.h @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// --------------------------------------------------------------------- +// File: caliptra_isr.h +// Description: +// Provides function declarations for use by external test files, so +// that the ISR functionality may behave like a library. +// TODO: +// This header file includes inline function definitions for event and +// test specific interrupt service behavior, so it should be copied and +// modified for each test. +// --------------------------------------------------------------------- + +#ifndef CALIPTRA_ISR_H + #define CALIPTRA_ISR_H + +#define EN_ISR_PRINTS 1 + +#include "caliptra_defines.h" +#include +#include "printf.h" + +/* --------------- symbols/typedefs --------------- */ +typedef struct { + uint32_t doe_error; + uint32_t doe_notif; + uint32_t ecc_error; + uint32_t ecc_notif; + uint32_t hmac_error; + uint32_t hmac_notif; + uint32_t kv_error; + uint32_t kv_notif; + uint32_t sha512_error; + uint32_t sha512_notif; + uint32_t sha256_error; + uint32_t sha256_notif; + uint32_t qspi_error; + uint32_t qspi_notif; + uint32_t uart_error; + uint32_t uart_notif; + uint32_t i3c_error; + uint32_t i3c_notif; + uint32_t soc_ifc_error; + uint32_t soc_ifc_notif; + uint32_t sha512_acc_error; + uint32_t sha512_acc_notif; +} caliptra_intr_received_s; +extern volatile caliptra_intr_received_s cptra_intr_rcv; + +////////////////////////////////////////////////////////////////////////////// +// Function Declarations +// + +// Performs all the CSR setup to configure and enable vectored external interrupts +void init_interrupts(void); + +// These inline functions are used to insert event-specific functionality into the +// otherwise generic ISR that gets laid down by the parameterized macro "nonstd_veer_isr" +inline void service_doe_error_intr() {return;} +inline void service_doe_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.doe_notif |= DOE_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad doe_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_ecc_error_intr() {return;} +inline void service_ecc_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.ecc_notif |= ECC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad ecc_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_hmac_error_intr() {return;} +inline void service_hmac_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.hmac_notif |= HMAC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad hmac_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_kv_error_intr() {return;} +inline void service_kv_notif_intr() {return;} +inline void service_sha512_error_intr() {return;} +inline void service_sha512_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.sha512_notif |= SHA512_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad sha512_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_sha256_error_intr() {return;} +inline void service_sha256_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.sha256_notif |= SHA256_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad sha256_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_qspi_error_intr() {return;} +inline void service_qspi_notif_intr() {return;} +inline void service_uart_error_intr() {return;} +inline void service_uart_notif_intr() {return;} +inline void service_i3c_error_intr() {return;} +inline void service_i3c_notif_intr() {return;} + +inline void service_soc_ifc_error_intr() { + uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK; + cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad soc_ifc_error_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_soc_ifc_notif_intr () { + uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK; + } + if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK) { + *reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK; + cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad soc_ifc_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + +inline void service_sha512_acc_error_intr() {return;} +inline void service_sha512_acc_notif_intr() { + uint32_t * reg = (uint32_t *) (CLP_SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R); + uint32_t sts = *reg; + /* Write 1 to Clear the pending interrupt */ + if (sts & SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) { + *reg = SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + cptra_intr_rcv.sha512_acc_notif |= SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK; + } + if (sts == 0) { + VPRINTF(ERROR,"bad sha512_acc_notif_intr sts:%x\n", sts); + SEND_STDOUT_CTRL(0x1); + while(1); + } +} + + +#endif //CALIPTRA_ISR_H diff --git a/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.c b/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.c new file mode 100644 index 000000000..7ae9b94bd --- /dev/null +++ b/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.c @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "caliptra_defines.h" +#include "riscv_hw_if.h" +#include "soc_ifc.h" +#include +//#include +#include "printf.h" +#include "caliptra_isr.h" + +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +#ifdef CPT_VERBOSITY + enum printf_verbosity verbosity_g = CPT_VERBOSITY; +#else + enum printf_verbosity verbosity_g = MEDIUM; +#endif + +volatile caliptra_intr_received_s cptra_intr_rcv = { + .doe_error = 0, + .doe_notif = 0, + .ecc_error = 0, + .ecc_notif = 0, + .hmac_error = 0, + .hmac_notif = 0, + .kv_error = 0, + .kv_notif = 0, + .sha512_error = 0, + .sha512_notif = 0, + .sha256_error = 0, + .sha256_notif = 0, + .qspi_error = 0, + .qspi_notif = 0, + .uart_error = 0, + .uart_notif = 0, + .i3c_error = 0, + .i3c_notif = 0, + .soc_ifc_error = 0, + .soc_ifc_notif = 0, + .sha512_acc_error = 0, + .sha512_acc_notif = 0, +}; + +//#ifndef MY_RANDOM_SEED +//#define MY_RANDOM_SEED 17 +//#endif // MY_RANDOM_SEED +// +//const long seed = MY_RANDOM_SEED; + +void main () { + + uint32_t data; + uint8_t* read_addr; + + // Message + VPRINTF(LOW, "----------------------------------\n"); + VPRINTF(LOW, " Caliptra Mbox SRAM DIR Smoke Test!!\n" ); + VPRINTF(LOW, "----------------------------------\n"); + +// VPRINTF(LOW,"\nINFO. Using random seed = %d\n", seed); +// srand(seed); +// VPRINTF(MEDIUM, "srand done\n") + + // Acquire Lock + if (soc_ifc_mbox_acquire_lock(1)) { + VPRINTF(ERROR, "ERROR: Failed to acquire mbox lock\n"); + SEND_STDOUT_CTRL( 0x1); + while(1); + } + + // Write data to fill mailbox + for (data = CLP_MBOX_SRAM_BASE_ADDR; data < CLP_MBOX_SRAM_END_ADDR; data+=4) { + // Data written is the address being written to + lsu_write_32((uintptr_t) data, data); + if ((data & 0xfff) == 0) { + VPRINTF(MEDIUM, "Writing [0x%x] to addr [0x%x]\n", data, data) + } + } + + // Read back one byte at a time and check values + read_addr = (uint8_t*) CLP_MBOX_SRAM_BASE_ADDR; + while(read_addr <= (uint8_t*) CLP_MBOX_SRAM_END_ADDR) { + if (((uintptr_t)read_addr & 0xfff) == 0) { + VPRINTF(MEDIUM, "Reading from addr [0x%x]\n", read_addr) + } + // Data should match the address being read from + if (*read_addr != (uint8_t)(((uintptr_t) read_addr) )) { + VPRINTF(ERROR, "ERROR: Data mismatch at addr [0x%x]. Exp [0x%x] got [0x%x]\n", (uintptr_t) read_addr, (uint8_t)(((uintptr_t) read_addr) >> 0 ), *read_addr); + SEND_STDOUT_CTRL( 0x1); + while(1); + } + read_addr++; + if (*read_addr != (uint8_t)(((uintptr_t) read_addr) >> 8)) { + VPRINTF(ERROR, "ERROR: Data mismatch at addr [0x%x]. Exp [0x%x] got [0x%x]\n", (uintptr_t) read_addr, (uint8_t)(((uintptr_t) read_addr) >> 8 ), *read_addr); + SEND_STDOUT_CTRL( 0x1); + while(1); + } + read_addr++; + if (*read_addr != (uint8_t)(((uintptr_t) read_addr) >> 16)) { + VPRINTF(ERROR, "ERROR: Data mismatch at addr [0x%x]. Exp [0x%x] got [0x%x]\n", (uintptr_t) read_addr, (uint8_t)(((uintptr_t) read_addr) >> 16), *read_addr); + SEND_STDOUT_CTRL( 0x1); + while(1); + } + read_addr++; + if (*read_addr != (uint8_t)(((uintptr_t) read_addr) >> 24)) { + VPRINTF(ERROR, "ERROR: Data mismatch at addr [0x%x]. Exp [0x%x] got [0x%x]\n", (uintptr_t) read_addr, (uint8_t)(((uintptr_t) read_addr) >> 24), *read_addr); + SEND_STDOUT_CTRL( 0x1); + while(1); + } + read_addr++; + } + + // Force unlock + lsu_write_32(CLP_MBOX_CSR_MBOX_UNLOCK, MBOX_CSR_MBOX_UNLOCK_UNLOCK_MASK); + +} diff --git a/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml b/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml new file mode 100755 index 000000000..dce82ad9f --- /dev/null +++ b/src/integration/test_suites/smoke_test_mbox_byte_read/smoke_test_mbox_byte_read.yml @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +seed: 1 +testname: smoke_test_mbox_byte_read diff --git a/src/integration/test_suites/smoke_test_mbox_cg/smoke_test_mbox_cg.c b/src/integration/test_suites/smoke_test_mbox_cg/smoke_test_mbox_cg.c index 9697d6e71..0bf3924d9 100644 --- a/src/integration/test_suites/smoke_test_mbox_cg/smoke_test_mbox_cg.c +++ b/src/integration/test_suites/smoke_test_mbox_cg/smoke_test_mbox_cg.c @@ -20,8 +20,8 @@ #include "caliptra_isr.h" #include "clk_gate.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_pcr_signing/smoke_test_pcr_signing.c b/src/integration/test_suites/smoke_test_pcr_signing/smoke_test_pcr_signing.c index 0afb0b306..9c64c9e9e 100644 --- a/src/integration/test_suites/smoke_test_pcr_signing/smoke_test_pcr_signing.c +++ b/src/integration/test_suites/smoke_test_pcr_signing/smoke_test_pcr_signing.c @@ -20,8 +20,8 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_pcr_zeroize/smoke_test_pcr_zeroize.c b/src/integration/test_suites/smoke_test_pcr_zeroize/smoke_test_pcr_zeroize.c index 2ff485ee4..55f666073 100644 --- a/src/integration/test_suites/smoke_test_pcr_zeroize/smoke_test_pcr_zeroize.c +++ b/src/integration/test_suites/smoke_test_pcr_zeroize/smoke_test_pcr_zeroize.c @@ -20,8 +20,8 @@ #include "printf.h" #include "ecc.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_qspi/smoke_test_qspi.c b/src/integration/test_suites/smoke_test_qspi/smoke_test_qspi.c index babe4f400..33f53a914 100644 --- a/src/integration/test_suites/smoke_test_qspi/smoke_test_qspi.c +++ b/src/integration/test_suites/smoke_test_qspi/smoke_test_qspi.c @@ -22,9 +22,9 @@ #include "riscv-csr.h" #include "riscv_hw_if.h" -volatile char *stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_ras/smoke_test_ras.c b/src/integration/test_suites/smoke_test_ras/smoke_test_ras.c index 629e87e90..411c07232 100644 --- a/src/integration/test_suites/smoke_test_ras/smoke_test_ras.c +++ b/src/integration/test_suites/smoke_test_ras/smoke_test_ras.c @@ -178,7 +178,7 @@ enum boot_count_list { // Globals // extern uintptr_t iccm_code0_start, iccm_code0_end; -volatile char* stdout = (char *)STDOUT; +volatile uint32_t* stdout = (uint32_t *)STDOUT; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_sha256/smoke_test_sha256.c b/src/integration/test_suites/smoke_test_sha256/smoke_test_sha256.c index 2b3cdf92b..c7e635ab6 100644 --- a/src/integration/test_suites/smoke_test_sha256/smoke_test_sha256.c +++ b/src/integration/test_suites/smoke_test_sha256/smoke_test_sha256.c @@ -24,8 +24,8 @@ #else enum printf_verbosity verbosity_g = LOW; #endif -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile caliptra_intr_received_s cptra_intr_rcv = { .doe_error = 0, diff --git a/src/integration/test_suites/smoke_test_sha256_wntz/smoke_test_sha256_wntz.c b/src/integration/test_suites/smoke_test_sha256_wntz/smoke_test_sha256_wntz.c index 7037b386a..a80ad085c 100644 --- a/src/integration/test_suites/smoke_test_sha256_wntz/smoke_test_sha256_wntz.c +++ b/src/integration/test_suites/smoke_test_sha256_wntz/smoke_test_sha256_wntz.c @@ -24,8 +24,8 @@ #else enum printf_verbosity verbosity_g = LOW; #endif -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile caliptra_intr_received_s cptra_intr_rcv = { .doe_error = 0, diff --git a/src/integration/test_suites/smoke_test_sha256_wntz_rand/smoke_test_sha256_wntz_rand.c b/src/integration/test_suites/smoke_test_sha256_wntz_rand/smoke_test_sha256_wntz_rand.c index b30b80c77..93e55a73b 100644 --- a/src/integration/test_suites/smoke_test_sha256_wntz_rand/smoke_test_sha256_wntz_rand.c +++ b/src/integration/test_suites/smoke_test_sha256_wntz_rand/smoke_test_sha256_wntz_rand.c @@ -24,8 +24,8 @@ #else enum printf_verbosity verbosity_g = LOW; #endif -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile caliptra_intr_received_s cptra_intr_rcv = { .doe_error = 0, diff --git a/src/integration/test_suites/smoke_test_sha512/smoke_test_sha512.c b/src/integration/test_suites/smoke_test_sha512/smoke_test_sha512.c index 4f31d91fd..041882cba 100644 --- a/src/integration/test_suites/smoke_test_sha512/smoke_test_sha512.c +++ b/src/integration/test_suites/smoke_test_sha512/smoke_test_sha512.c @@ -24,8 +24,8 @@ #else enum printf_verbosity verbosity_g = LOW; #endif -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; volatile caliptra_intr_received_s cptra_intr_rcv = { .doe_error = 0, diff --git a/src/integration/test_suites/smoke_test_sram_ecc/smoke_test_sram_ecc.c b/src/integration/test_suites/smoke_test_sram_ecc/smoke_test_sram_ecc.c index f9c3ceb44..9a072897e 100644 --- a/src/integration/test_suites/smoke_test_sram_ecc/smoke_test_sram_ecc.c +++ b/src/integration/test_suites/smoke_test_sram_ecc/smoke_test_sram_ecc.c @@ -22,8 +22,8 @@ -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_trng/smoke_test_trng.c b/src/integration/test_suites/smoke_test_trng/smoke_test_trng.c index e0e34369f..3d7fbdec4 100644 --- a/src/integration/test_suites/smoke_test_trng/smoke_test_trng.c +++ b/src/integration/test_suites/smoke_test_trng/smoke_test_trng.c @@ -22,9 +22,9 @@ #include "riscv-csr.h" #include "riscv_hw_if.h" -volatile char *stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_uart/smoke_test_uart.c b/src/integration/test_suites/smoke_test_uart/smoke_test_uart.c index c0918a194..6543c6095 100644 --- a/src/integration/test_suites/smoke_test_uart/smoke_test_uart.c +++ b/src/integration/test_suites/smoke_test_uart/smoke_test_uart.c @@ -22,9 +22,9 @@ #include "riscv-csr.h" #include "riscv_hw_if.h" -volatile char *stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; #else diff --git a/src/integration/test_suites/smoke_test_wdt/smoke_test_wdt.c b/src/integration/test_suites/smoke_test_wdt/smoke_test_wdt.c index b59ecdd7c..efb0c0ec7 100644 --- a/src/integration/test_suites/smoke_test_wdt/smoke_test_wdt.c +++ b/src/integration/test_suites/smoke_test_wdt/smoke_test_wdt.c @@ -22,9 +22,9 @@ #include "riscv_hw_if.h" #include "wdt.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_wdt_rst/smoke_test_wdt_rst.c b/src/integration/test_suites/smoke_test_wdt_rst/smoke_test_wdt_rst.c index f472b3c2f..68c8d715c 100644 --- a/src/integration/test_suites/smoke_test_wdt_rst/smoke_test_wdt_rst.c +++ b/src/integration/test_suites/smoke_test_wdt_rst/smoke_test_wdt_rst.c @@ -22,9 +22,9 @@ #include "riscv_hw_if.h" #include "wdt.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; -volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; +volatile uint32_t rst_count __attribute__((section(".dccm.persistent"))) = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/integration/test_suites/smoke_test_zeroize_crypto/smoke_test_zeroize_crypto.c b/src/integration/test_suites/smoke_test_zeroize_crypto/smoke_test_zeroize_crypto.c index 0fb74a00b..19f04192c 100644 --- a/src/integration/test_suites/smoke_test_zeroize_crypto/smoke_test_zeroize_crypto.c +++ b/src/integration/test_suites/smoke_test_zeroize_crypto/smoke_test_zeroize_crypto.c @@ -23,8 +23,8 @@ #include "printf.h" #include "hmac.h" -volatile char* stdout = (char *)STDOUT; -volatile uint32_t intr_count = 0; +volatile uint32_t* stdout = (uint32_t *)STDOUT; +volatile uint32_t intr_count = 0; #ifdef CPT_VERBOSITY enum printf_verbosity verbosity_g = CPT_VERBOSITY; diff --git a/src/soc_ifc/uvmf_soc_ifc/uvmf_template_output/verification_ip/environment_packages/soc_ifc_env_pkg/src/soc_ifc_predictor.svh b/src/soc_ifc/uvmf_soc_ifc/uvmf_template_output/verification_ip/environment_packages/soc_ifc_env_pkg/src/soc_ifc_predictor.svh index 9527795c9..68f963afa 100644 --- a/src/soc_ifc/uvmf_soc_ifc/uvmf_template_output/verification_ip/environment_packages/soc_ifc_env_pkg/src/soc_ifc_predictor.svh +++ b/src/soc_ifc/uvmf_soc_ifc/uvmf_template_output/verification_ip/environment_packages/soc_ifc_env_pkg/src/soc_ifc_predictor.svh @@ -667,6 +667,7 @@ class soc_ifc_predictor #( bit do_reg_prediction = 1; bit [SOC_IFC_DATA_W-1:0] data_active; bit [ahb_lite_slave_0_params::AHB_WDATA_WIDTH-1:0] address_aligned; + ahb_transfer_size_e native_size; // Flags control whether each transaction is sent to scoreboard bit send_soc_ifc_sts_txn = 0; bit send_cptra_sts_txn = 0; @@ -691,12 +692,28 @@ class soc_ifc_predictor #( $cast(ahb_txn, t); soc_ifc_sb_ahb_ap_output_transaction.copy(ahb_txn); // Address must be aligned to the native data width in the SOC IFC! I.e. 4-byte aligned - address_aligned = ahb_txn.address & ~(SOC_IFC_DATA_W/8 - 1); - if (ahb_txn.address & ((SOC_IFC_DATA_W/8 - 1))) begin - `uvm_error("PRED_AHB", "Detected AHB transfer with bad address alignment! Address: 0x%x, expected alignment: 0x%x") + native_size = (SOC_IFC_DATA_W == 8) ? AHB_BITS_8 : + ahb_transfer_size_e'($clog2(SOC_IFC_DATA_W/8)); + address_aligned = ahb_txn.address & ~((1 << ahb_txn.size) - 1); + if (ahb_txn.size == native_size) begin + if (ahb_txn.address & ((SOC_IFC_DATA_W/8 - 1))) + `uvm_error("PRED_AHB", $sformatf("Detected AHB transfer with bad address alignment! Address: 0x%x, Size: %p, expected alignment: 0x%x", ahb_txn.address, ahb_txn.size, SOC_IFC_DATA_W/8)) + end + else if (ahb_txn.size == AHB_BITS_8) begin + if (p_soc_ifc_AHB_map.get_mem_by_offset(ahb_txn.address) == null) + `uvm_error("PRED_AHB", $sformatf("Detected AHB transfer with non-DW size that does not target the Mailbox SRAM! Size: %p, expected size: %p", ahb_txn.size, native_size)) + else if (ahb_txn.RnW == AHB_WRITE) + `uvm_error("PRED_AHB", $sformatf("Detected AHB write with bad size! Size: %p, expected %p", ahb_txn.size, native_size)) + // Byte alignment exception is for READS to the Mailbox via direct mode + else + `uvm_info("PRED_AHB", $sformatf("Detected AHB byte transfer that targets the Mailbox SRAM. Address: 0x%x, size %p, native alignment boundary: 0x%x", ahb_txn.address, ahb_txn.size, SOC_IFC_DATA_W/8), UVM_FULL) + end + else begin + `uvm_error("PRED_AHB", $sformatf("Detected AHB transfer with bad size! Size: %p, expected %p or %p", ahb_txn.size, AHB_BITS_8, native_size)) end // Grab the data from the address offset, similar to how it's done in HW data_active = SOC_IFC_DATA_W'(ahb_txn.data[0] >> (8*(address_aligned % (ahb_lite_slave_0_params::AHB_WDATA_WIDTH/8)))); + // Determine which sub-block in soc_ifc is being targeted if (p_soc_ifc_AHB_map.get_mem_by_offset(ahb_txn.address) != null) begin: MEM_HANDLE `uvm_info("PRED_AHB", $sformatf("Detected access to mailbox at address: 0x%x", ahb_txn.address), UVM_MEDIUM) axs_mem = p_soc_ifc_AHB_map.get_mem_by_offset(ahb_txn.address); diff --git a/tools/scripts/reg_doc_gen.py b/tools/scripts/reg_doc_gen.py index d8bbb0e26..8e2fe58c3 100644 --- a/tools/scripts/reg_doc_gen.py +++ b/tools/scripts/reg_doc_gen.py @@ -75,7 +75,7 @@ def enter_Regfile(self, node): def exit_Regfile(self, node): self.regfile_offset = 0 def enter_Reg(self, node): - #getting and printing the absolute address and path for reach register + #getting and printing the absolute address and path for each register register_name = node.get_path("_",'_{index:d}') address = hex(node.absolute_address) if self.tick == "`": @@ -101,6 +101,18 @@ def enter_Field(self, node): field_mask = field_mask.replace("0x", "32'h", 1) self.file.write((self.tick + "define " + field_name.upper() + "_LOW" + "\t(" + str(node.low) + ")\n").expandtabs(100)) self.file.write((self.tick + "define " + field_name.upper() + "_MASK" + "\t(" + field_mask + ")\n").expandtabs(100)) + def enter_Mem(self, node): + #getting and printing the absolute address and path for each register + mem_name = node.get_path("_",'_{index:d}') + address = hex(node.absolute_address) + if self.tick == "`": + address = address.replace("0x", "32'h", 1) + self.file.write((self.tick + "define " + mem_name.upper() + "_BASE_ADDR" + "\t(" + address + ")\n").expandtabs(100)) + #getting and printing the end address for the memory + address = hex(node.absolute_address + node.size - 1) + if self.tick == "`": + address = address.replace("0x", "32'h", 1) + self.file.write((self.tick + "define " + mem_name.upper() + "_END_ADDR" + "\t(" + address + ")\n").expandtabs(100)) #list of address map files to compile