blob: 47355a50bd5270cd15310c4c680ff247669e1b28 [file] [log] [blame]
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/dif/dif_rom_ctrl.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/testing/check.h"
#include "sw/device/lib/testing/test_framework/ottf.h"
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
static dif_rom_ctrl_t rom_ctrl;
const test_config_t kTestConfig;
bool test_main(void) {
dif_rom_ctrl_digest_t computed_digest;
dif_rom_ctrl_digest_t expected_digest;
// initialize rom_ctrl
mmio_region_t rom_ctrl_reg =
mmio_region_from_addr(TOP_EARLGREY_ROM_CTRL_REGS_BASE_ADDR);
CHECK_DIF_OK(dif_rom_ctrl_init(rom_ctrl_reg, &rom_ctrl));
// get computed and expected digests and check that they match
CHECK_DIF_OK(dif_rom_ctrl_get_digest(&rom_ctrl, &computed_digest));
CHECK_DIF_OK(dif_rom_ctrl_get_expected_digest(&rom_ctrl, &expected_digest));
CHECK_BUFFER(computed_digest.digest, expected_digest.digest,
ROM_CTRL_DIGEST_MULTIREG_COUNT,
"Mismatch between computed and expected digest.");
return true;
}