Software APIs
edn_testutils.h
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 #ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_EDN_TESTUTILS_H_
6 #define OPENTITAN_SW_DEVICE_LIB_TESTING_EDN_TESTUTILS_H_
7 
9 #include "sw/device/lib/testing/test_framework/check.h"
10 
11 /**
12  * Returns the value of the EDN status flag.
13  *
14  * @param edn An edn DIF handle.
15  * @param status Status value to query.
16  */
17 inline bool edn_testutils_get_status(dif_edn_t *edn, uint32_t state_val) {
18  uint32_t state;
20  return (res == kDifOk) && (state == state_val);
21 }
22 
23 /**
24  * Waits for the given EDN status flag to be set the given value.
25  *
26  * @param edn An edn DIF handle.
27  * @param flag Status flag value.
28  * @param status The status value.
29  * @param timeout_usec Timeout in microseconds.
30  */
31 #define EDN_TESTUTILS_WAIT_FOR_STATUS(edn_, state_, flag_, timeout_usec_) \
32  IBEX_TRY_SPIN_FOR(edn_testutils_get_status((edn_), (state_)) == (flag_), \
33  (timeout_usec_))
34 
35 /**
36  * Returns randomized seed material.
37  *
38  * @param disable_rand If set, a struct containing default values is returned.
39  * @return A seed material struct containing the length and the seed material.
40  */
42 dif_edn_seed_material_t edn_testutils_seed_material_build(bool disable_rand);
43 
44 /**
45  * Returns a randomized EDN auto mode configuration.
46  *
47  * @param disable_rand If set, a struct containing default values is returned.
48  * @param res_itval If > 0, the reseed interval is set to res_itval.
49  * @param glen_val If > 0, the generate length is set to glen_val.
50  * @return A parameter struct containing the settings required for auto mode.
51  */
53 dif_edn_auto_params_t edn_testutils_auto_params_build(bool disable_rand,
54  unsigned int res_itval,
55  unsigned int glen_val);
56 
57 #endif // OPENTITAN_SW_DEVICE_LIB_TESTING_EDN_TESTUTILS_H_