Software APIs
rv_dm_ndm_reset_req_when_cpu_halted.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 
8 #include "sw/device/lib/testing/rstmgr_testutils.h"
9 #include "sw/device/lib/testing/test_framework/check.h"
11 
13 
14 static dif_rstmgr_t rstmgr;
15 
16 OTTF_DEFINE_TEST_CONFIG(.enable_concurrency = false);
17 
18 bool test_main(void) {
19  CHECK_DIF_OK(dif_rstmgr_init(
21 
22  if (UNWRAP(rstmgr_testutils_is_reset_info(&rstmgr, kDifRstmgrResetInfoPor))) {
23  rstmgr_testutils_reason_clear();
24 
25  // Sync log used by the SV sequence. Do not modify.
26  LOG_INFO("Ready for CPU halt request");
27 
28  // Wait for 1ms. The host test sequence will issue a halt request, followed
29  // by an NDM reset request.
30  busy_spin_micros(10000);
31 
32  LOG_ERROR("Timed out waiting for an NDM reset request.");
33  return false;
34 
35  } else if (UNWRAP(rstmgr_testutils_is_reset_info(&rstmgr,
37  LOG_INFO("Rebooted after NDM reset request.");
38  rstmgr_testutils_reason_clear();
39  return true;
40 
41  } else {
43  reset_info = rstmgr_testutils_reason_get();
44  LOG_ERROR("Unexpected reset_info: %d", reset_info);
45  return false;
46  }
47 
48  return false;
49 }