Software APIs
rstmgr_smoketest.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "dt/dt_rstmgr.h"
8 #include "sw/device/lib/testing/rstmgr_testutils.h"
9 #include "sw/device/lib/testing/test_framework/check.h"
11 
12 static_assert(kDtRstmgrCount >= 1,
13  "This test requires at least one Rstmgr instance");
14 
15 static dt_rstmgr_t kTestRstmgr = (dt_rstmgr_t)0;
16 
17 OTTF_DEFINE_TEST_CONFIG();
18 
19 // The SV side will flip POR_N and cause some AON power glitches prior to the
20 // start of test_main. Both of these cause a new POR, so all this has to do is
21 // check that the `reset_info` CSR is POR.
22 bool test_main(void) {
23  dif_rstmgr_t rstmgr;
24  CHECK_DIF_OK(dif_rstmgr_init_from_dt(kTestRstmgr, &rstmgr));
25 
26  LOG_INFO("Checking reset status.");
27  CHECK(
28  UNWRAP(rstmgr_testutils_reset_info_any(&rstmgr, kDifRstmgrResetInfoPor)));
29  LOG_INFO("Reset status indicates a POR");
30 
31  return true;
32 }