| #include "hw/top_matcha/sw/autogen/top_matcha.h" |
| #include "sw/device/lib/arch/device.h" |
| #include "sw/device/lib/dif/dif_uart.h" |
| #include "sw/device/lib/runtime/print.h" |
| #include "sw/device/lib/testing/test_framework/check.h" |
| #include "sw/device/lib/testing/test_framework/ottf_test_config.h" |
| #include "sw/device/lib/testing/test_framework/test_util.h" |
| |
| OTTF_DEFINE_TEST_CONFIG(); |
| |
| static dif_uart_t smc_uart; |
| |
| void _ottf_main(void) { |
| // Initialize the SMC UART to enable logging for non-DV simulation platforms. |
| if (kDeviceType != kDeviceSimDV) { |
| init_uart(TOP_MATCHA_SMC_UART_BASE_ADDR, &smc_uart); |
| } |
| LOG_INFO("[SMC] Memory test starts from SMC!"); |
| |
| test_status_set(kTestStatusInTest); |
| |
| mmio_region_t ml_dmem_test_base = |
| mmio_region_from_addr(TOP_MATCHA_RAM_ML_DMEM_BASE_ADDR + 0x300000); |
| |
| const unsigned char golden_data[20] = { |
| 0xff, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xff, 0xff, 0xe1, 0xe1, |
| 0xe1, 0xe5, 0xc1, 0xde, 0xe1, 0xe1, 0xb3, 0xb3, 0xb1, 0xa9}; |
| uint32_t golden_data_size = 20; |
| |
| unsigned char mem_val; |
| unsigned char golden_val; |
| |
| LOG_INFO("[SMC] Write the test data array."); |
| for (uint32_t offset = 0; offset < golden_data_size; offset++) { |
| mmio_region_write8(ml_dmem_test_base, offset, golden_data[offset]); |
| } |
| |
| LOG_INFO("[SMC] Read the test data array."); |
| for (uint32_t offset = 0; offset < golden_data_size; offset++) { |
| mem_val = mmio_region_read8(ml_dmem_test_base, offset); |
| golden_val = golden_data[offset]; |
| CHECK(mem_val == golden_val, |
| "Mismatch data at offset 0x%h - Expected: 0x%h | Actual: 0x%h", |
| offset, golden_val, mem_val); |
| } |
| |
| test_status_set(kTestStatusPassed); |
| } |