[dif] simplify autogen DIF templates by sharing typedefs
This partially addressed #8142 by sharing, rather than autogenerating,
duplicate common DIFs typedefs.
Signed-off-by: Timothy Trippel <ttrippel@google.com>
diff --git a/sw/device/lib/base/macros.h b/sw/device/lib/base/macros.h
index 87837d4..7f5ded0 100644
--- a/sw/device/lib/base/macros.h
+++ b/sw/device/lib/base/macros.h
@@ -77,4 +77,20 @@
#define OT_PLATFORM_RV32 1
#endif
+/**
+ * Attribute for functions which return errors that must be acknowledged.
+ *
+ * This attribute must be used to mark all DIFs which return an error value of
+ * some kind, to ensure that callers do not accidentally drop the error on the
+ * ground.
+ *
+ * Normally, the standard way to drop such a value on the ground explicitly is
+ * with the syntax `(void)expr;`, in analogy with the behavior of C++'s
+ * `[[nodiscard]]` attribute.
+ * However, GCC does not implement this, so the idiom `if (expr) {}` should be
+ * used instead, for the time being.
+ * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509.
+ */
+#define OT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+
#endif // OPENTITAN_SW_DEVICE_LIB_BASE_MACROS_H_
diff --git a/sw/device/lib/dif/dif_aes.c b/sw/device/lib/dif/dif_aes.c
index e37199d..2bf34ee 100644
--- a/sw/device/lib/dif/dif_aes.c
+++ b/sw/device/lib/dif/dif_aes.c
@@ -416,7 +416,7 @@
return kDifAesOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_alert_force(const dif_aes_t *aes,
dif_aes_alert_t alert) {
if (aes == NULL) {
diff --git a/sw/device/lib/dif/dif_aes.h b/sw/device/lib/dif/dif_aes.h
index bca4e5f..ea07922 100644
--- a/sw/device/lib/dif/dif_aes.h
+++ b/sw/device/lib/dif/dif_aes.h
@@ -8,8 +8,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -230,7 +230,7 @@
* @param[out] aes Out param for the initialised handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_init(dif_aes_params_t params, dif_aes_t *aes);
/**
@@ -241,7 +241,7 @@
* @param aes AES state data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_reset(const dif_aes_t *aes);
/**
@@ -263,7 +263,7 @@
* @param transaction Configuration data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_start_ecb(const dif_aes_t *aes,
const dif_aes_transaction_t *transaction,
dif_aes_key_share_t key);
@@ -290,7 +290,7 @@
* @param iv AES Initialisation Vector.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_start_cbc(const dif_aes_t *aes,
const dif_aes_transaction_t *transaction,
dif_aes_key_share_t key, dif_aes_iv_t iv);
@@ -315,7 +315,7 @@
* @param iv AES Initial Counter Value.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_start_ctr(const dif_aes_t *aes,
const dif_aes_transaction_t *transaction,
dif_aes_key_share_t key, dif_aes_iv_t iv);
@@ -332,7 +332,7 @@
* @param aes AES state data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_end(const dif_aes_t *aes);
/**
@@ -348,7 +348,7 @@
* @param data AES Input Data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_load_data(const dif_aes_t *aes,
const dif_aes_data_t data);
@@ -363,7 +363,7 @@
* @param data AES Output Data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_read_output(const dif_aes_t *aes,
dif_aes_data_t *data);
@@ -399,7 +399,7 @@
* @param trigger AES trigger.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_trigger(const dif_aes_t *aes,
dif_aes_trigger_t trigger);
@@ -452,7 +452,7 @@
* @param set Flag state (set/unset).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_get_status(const dif_aes_t *aes, dif_aes_status_t flag,
bool *set);
@@ -464,7 +464,7 @@
* @param alert An alert type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aes_result_t dif_aes_alert_force(const dif_aes_t *aes,
dif_aes_alert_t alert);
diff --git a/sw/device/lib/dif/dif_alert_handler.c b/sw/device/lib/dif/dif_alert_handler.c
index efcf3b6..c3c8b08 100644
--- a/sw/device/lib/dif/dif_alert_handler.c
+++ b/sw/device/lib/dif/dif_alert_handler.c
@@ -44,7 +44,7 @@
* Classifies alerts for a single alert class. Returns `false` if any of the
* provided configuration is invalid.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool classify_alerts(const dif_alert_handler_t *handler,
const dif_alert_handler_class_config_t *class) {
if (class->alerts == NULL && class->alerts_len != 0) {
@@ -122,7 +122,7 @@
* Classifies local alerts for a single alert class. Returns `false` if any of
* the provided configuration is invalid.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool classify_local_alerts(
const dif_alert_handler_t *handler,
const dif_alert_handler_class_config_t *class) {
@@ -224,7 +224,7 @@
*
* Returns false if `toggle` is out of range.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool toggle_to_bool(dif_alert_handler_toggle_t toggle, bool *flag) {
switch (toggle) {
case kDifAlertHandlerToggleEnabled:
@@ -242,7 +242,7 @@
/**
* Configures the control registers of a particular alert handler class.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool configure_class(const dif_alert_handler_t *handler,
const dif_alert_handler_class_config_t *class) {
ptrdiff_t reg_offset;
@@ -378,7 +378,7 @@
/**
* Configures phase durations of a particular class.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool configure_phase_durations(
const dif_alert_handler_t *handler,
const dif_alert_handler_class_config_t *class) {
@@ -528,7 +528,7 @@
return kDifAlertHandlerOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool irq_index(dif_alert_handler_class_t class,
bitfield_bit32_index_t *index) {
switch (class) {
@@ -721,7 +721,7 @@
return kDifAlertHandlerOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool loc_alert_cause_reg_offset(dif_alert_handler_local_alert_t alert,
ptrdiff_t *offset) {
switch (alert) {
@@ -752,7 +752,7 @@
return true;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool loc_alert_cause_bit_index(dif_alert_handler_local_alert_t alert,
bitfield_bit32_index_t *index) {
switch (alert) {
@@ -834,7 +834,7 @@
return kDifAlertHandlerOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool get_clear_enable_reg_offset(dif_alert_handler_class_t class,
ptrdiff_t *reg_offset) {
switch (class) {
diff --git a/sw/device/lib/dif/dif_alert_handler.h b/sw/device/lib/dif/dif_alert_handler.h
index ccf8f03..13d5aed 100644
--- a/sw/device/lib/dif/dif_alert_handler.h
+++ b/sw/device/lib/dif/dif_alert_handler.h
@@ -13,8 +13,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -429,7 +429,7 @@
* @param handler Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_init(
dif_alert_handler_params_t params, dif_alert_handler_t *handler);
@@ -444,7 +444,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_config_result_t dif_alert_handler_configure(
const dif_alert_handler_t *handler, dif_alert_handler_config_t config);
/**
@@ -462,7 +462,7 @@
* @param handler An alert handler handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_lock(
const dif_alert_handler_t *handler);
@@ -475,7 +475,7 @@
* @param is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_is_locked(
const dif_alert_handler_t *handler, bool *is_locked);
@@ -487,7 +487,7 @@
* @param is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_is_pending(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
bool *is_pending);
@@ -500,7 +500,7 @@
* @param alert_class An alert class.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_acknowledge(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
@@ -512,7 +512,7 @@
* @param state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_get_enabled(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
dif_alert_handler_toggle_t *state);
@@ -525,7 +525,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_set_enabled(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
dif_alert_handler_toggle_t state);
@@ -538,7 +538,7 @@
* @param alert_class An alert class.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_force(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
@@ -550,7 +550,7 @@
* @param snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_disable_all(
const dif_alert_handler_t *handler,
dif_alert_handler_irq_snapshot_t *snapshot);
@@ -566,7 +566,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_irq_restore_all(
const dif_alert_handler_t *handler,
const dif_alert_handler_irq_snapshot_t *snapshot);
@@ -581,7 +581,7 @@
* @param is_cause Out-param for whether this alert is a cause.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_alert_is_cause(
const dif_alert_handler_t *handler, dif_alert_handler_alert_t alert,
bool *is_cause);
@@ -593,7 +593,7 @@
* @param alert The alert to acknowledge.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_alert_acknowledge(
const dif_alert_handler_t *handler, dif_alert_handler_alert_t alert);
@@ -607,7 +607,7 @@
* @param is_cause Out-param for whether this alert is a cause.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_local_alert_is_cause(
const dif_alert_handler_t *handler, dif_alert_handler_local_alert_t alert,
bool *is_cause);
@@ -620,7 +620,7 @@
* @param alert The alert to acknowledge.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_local_alert_acknowledge(
const dif_alert_handler_t *handler, dif_alert_handler_local_alert_t alert);
@@ -636,7 +636,7 @@
* @param can_clear Out-param for the clear enablement state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_escalation_can_clear(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
bool *can_clear);
@@ -650,7 +650,7 @@
* @param alert_class The class to disable clearing for.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_escalation_disable_clearing(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
@@ -664,7 +664,7 @@
* @param alert_class The class to clear an escalation for.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_escalation_clear(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
@@ -684,7 +684,7 @@
* @param alerts Out-param for the accumulator.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_get_accumulator(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
uint16_t *alerts);
@@ -703,7 +703,7 @@
* @param cycles Out-param for the counter.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_get_escalation_counter(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
uint32_t *cycles);
@@ -718,7 +718,7 @@
* @param state Out-param for the class state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_alert_handler_result_t dif_alert_handler_get_class_state(
const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
dif_alert_handler_class_state_t *state);
diff --git a/sw/device/lib/dif/dif_aon_timer.h b/sw/device/lib/dif/dif_aon_timer.h
index 71f091f..09f0653 100644
--- a/sw/device/lib/dif/dif_aon_timer.h
+++ b/sw/device/lib/dif/dif_aon_timer.h
@@ -14,8 +14,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -114,7 +114,7 @@
* @param[out] aon Out param for the initialised handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_init(dif_aon_timer_params_t params,
dif_aon_timer_t *aon);
@@ -131,7 +131,7 @@
* every N + 1 clock cycles, where N is the pre-scaler value).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_wakeup_start(const dif_aon_timer_t *aon,
uint32_t threshold,
uint32_t prescaler);
@@ -144,7 +144,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_wakeup_stop(const dif_aon_timer_t *aon);
/** Restarts Always-On Timer (wake-up timer).
@@ -154,7 +154,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_wakeup_restart(const dif_aon_timer_t *aon);
/** Retrieves Always-On Timer (wake-up timer) tick count.
@@ -163,7 +163,7 @@
* @param[out] count Current timer tick count.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_wakeup_get_count(
const dif_aon_timer_t *aon, uint32_t *count);
@@ -181,7 +181,7 @@
* @param lock Lock access to watchdog configuration registers.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_watchdog_result_t dif_aon_timer_watchdog_start(
const dif_aon_timer_t *aon, uint32_t bark_threshold,
uint32_t bite_threshold, bool pause_in_sleep, bool lock);
@@ -194,7 +194,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_watchdog_result_t dif_aon_timer_watchdog_stop(
const dif_aon_timer_t *aon);
@@ -205,7 +205,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_watchdog_result_t dif_aon_timer_watchdog_restart(
const dif_aon_timer_t *aon);
@@ -215,7 +215,7 @@
* @param[out] count Current timer tick count.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_watchdog_get_count(
const dif_aon_timer_t *aon, uint32_t *count);
@@ -229,7 +229,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_watchdog_pet(const dif_aon_timer_t *aon);
/**
@@ -242,7 +242,7 @@
* @param aon An Always-On Timer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_watchdog_result_t dif_aon_timer_watchdog_lock(
const dif_aon_timer_t *aon);
@@ -253,7 +253,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_watchdog_is_locked(
const dif_aon_timer_t *aon, bool *is_locked);
@@ -265,7 +265,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_irq_is_pending(const dif_aon_timer_t *aon,
dif_aon_timer_irq_t irq,
bool *is_pending);
@@ -280,7 +280,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_irq_acknowledge(const dif_aon_timer_t *aon,
dif_aon_timer_irq_t irq);
@@ -292,7 +292,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_aon_timer_result_t dif_aon_timer_irq_force(const dif_aon_timer_t *aon,
dif_aon_timer_irq_t irq);
diff --git a/sw/device/lib/dif/dif_base.h b/sw/device/lib/dif/dif_base.h
new file mode 100644
index 0000000..4e11f6f
--- /dev/null
+++ b/sw/device/lib/dif/dif_base.h
@@ -0,0 +1,68 @@
+// Copyright lowRISC contributors.
+// Licensed under the Apache License, Version 2.0, see LICENSE for details.
+// SPDX-License-Identifier: Apache-2.0
+
+#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_DIF_BASE_H_
+#define OPENTITAN_SW_DEVICE_LIB_DIF_DIF_BASE_H_
+
+/**
+ * @file
+ * @brief Shared macros and headers for DIFs.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+/**
+ * The result of a DIF operation.
+ *
+ * NOTE: additional result values can be defined in the manually-implemented
+ * header by creating an additional *_result_t enum type. See the Lifecycle
+ * Controller DIF for how this may be implemented.
+ */
+typedef enum dif_result {
+ /**
+ * Indicates that the operation succeeded.
+ */
+ kDifOk = 0,
+ /**
+ * Indicates some unspecified failure.
+ */
+ kDifError = 1,
+ /**
+ * Indicates that some parameter passed into a function failed a
+ * precondition.
+ *
+ * When this value is returned, no hardware operations occurred.
+ */
+ kDifBadArg = 2,
+ /**
+ * The operation failed because writes to a required register are
+ * disabled.
+ */
+ kDifLocked = 3,
+} dif_result_t;
+
+/**
+ * A toggle state: enabled, or disabled.
+ *
+ * This enum may be used instead of a `bool` when describing an enabled/disabled
+ * state.
+ */
+typedef enum dif_toggle {
+ /**
+ * The "enabled" state.
+ */
+ kDifToggleEnabled,
+ /**
+ * The "disabled" state.
+ */
+ kDifToggleDisabled,
+} dif_toggle_t;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif // __cplusplus
+
+#endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_BASE_H_
diff --git a/sw/device/lib/dif/dif_clkmgr.c b/sw/device/lib/dif/dif_clkmgr.c
index 76b7a72..5dac36c 100644
--- a/sw/device/lib/dif/dif_clkmgr.c
+++ b/sw/device/lib/dif/dif_clkmgr.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
#include "sw/device/lib/dif/dif_clkmgr.h"
+
#include "sw/device/lib/base/bitfield.h"
#include "sw/device/lib/base/mmio.h"
diff --git a/sw/device/lib/dif/dif_clkmgr.h b/sw/device/lib/dif/dif_clkmgr.h
index 35dd4f6..cf759a0 100644
--- a/sw/device/lib/dif/dif_clkmgr.h
+++ b/sw/device/lib/dif/dif_clkmgr.h
@@ -13,8 +13,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -115,7 +115,7 @@
* @param[out] handle Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_init(dif_clkmgr_params_t params,
dif_clkmgr_t *handle);
@@ -127,7 +127,7 @@
* @param[out] is_enabled whether the clock is enabled or not.
* @returns The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_gateable_clock_get_enabled(
const dif_clkmgr_t *handle, dif_clkmgr_gateable_clock_t clock,
bool *is_enabled);
@@ -140,7 +140,7 @@
* @param new_state whether to enable or disable the clock.
* @returns The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_gateable_clock_set_enabled(
const dif_clkmgr_t *handle, dif_clkmgr_gateable_clock_t clock,
dif_clkmgr_toggle_t new_state);
@@ -160,7 +160,7 @@
* @param[out] is_enabled whether the clock is enabled or not.
* @returns The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_hintable_clock_get_enabled(
const dif_clkmgr_t *handle, dif_clkmgr_hintable_clock_t clock,
bool *is_enabled);
@@ -181,7 +181,7 @@
* @param new_state whether to enable or disable the clock.
* @returns The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_hintable_clock_set_hint(
const dif_clkmgr_t *handle, dif_clkmgr_hintable_clock_t clock,
dif_clkmgr_toggle_t new_state);
@@ -202,7 +202,7 @@
* clock.
* @returns The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_clkmgr_result_t dif_clkmgr_hintable_clock_get_hint(
const dif_clkmgr_t *handle, dif_clkmgr_hintable_clock_t clock,
bool *hinted_is_enabled);
diff --git a/sw/device/lib/dif/dif_csrng.c b/sw/device/lib/dif/dif_csrng.c
index 90281d2..2e91cca 100644
--- a/sw/device/lib/dif/dif_csrng.c
+++ b/sw/device/lib/dif/dif_csrng.c
@@ -255,7 +255,7 @@
return kDifCsrngOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_get_internal_state(
const dif_csrng_t *csrng, dif_csrng_internal_state_id_t instance_id,
dif_csrng_internal_state_t *state) {
diff --git a/sw/device/lib/dif/dif_csrng.h b/sw/device/lib/dif/dif_csrng.h
index b8c4c94..fa32261 100644
--- a/sw/device/lib/dif/dif_csrng.h
+++ b/sw/device/lib/dif/dif_csrng.h
@@ -12,8 +12,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -292,7 +292,7 @@
* @param[out] csrng Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_init(dif_csrng_params_t params,
dif_csrng_t *csrng);
@@ -304,7 +304,7 @@
* @param csrng A CSRNG handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_configure(const dif_csrng_t *csrng);
/**
@@ -322,7 +322,7 @@
* @param seed_material Seed initialization parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_instantiate(
const dif_csrng_t *csrng, dif_csrng_entropy_src_toggle_t entropy_src_enable,
const dif_csrng_seed_material_t *seed_material);
@@ -338,7 +338,7 @@
* @param seed_material Reseed parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_reseed(
const dif_csrng_t *csrng, const dif_csrng_seed_material_t *seed_material);
@@ -355,7 +355,7 @@
* @param seed_material Update parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_update(
const dif_csrng_t *csrng, const dif_csrng_seed_material_t *seed_material);
@@ -375,7 +375,7 @@
* @param len Number of uint32_t words to generate.
*
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_generate_start(const dif_csrng_t *csrng,
size_t len);
@@ -394,7 +394,7 @@
* @param len The number of words to read into `buf`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_generate_end(const dif_csrng_t *csrng,
uint32_t *buf, size_t len);
@@ -408,7 +408,7 @@
* @param csrng An CSRNG handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_uninstantiate(const dif_csrng_t *csrng);
/**
@@ -426,7 +426,7 @@
* @param[out] status Command interface status.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_get_cmd_interface_status(
const dif_csrng_t *csrng, dif_csrng_cmd_status_t *status);
@@ -440,7 +440,7 @@
* @param[out] status CSRNG output status.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_get_output_status(
const dif_csrng_t *csrng, dif_csrng_output_status_t *status);
@@ -453,7 +453,7 @@
* @return The result of the operation.
*
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_get_internal_state(
const dif_csrng_t *csrng, dif_csrng_internal_state_id_t instance_id,
dif_csrng_internal_state_t *state);
@@ -467,7 +467,7 @@
* @param csrng A CSRNG handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_lock(const dif_csrng_t *csrng);
/**
@@ -477,7 +477,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_is_locked(const dif_csrng_t *csrng,
bool *is_locked);
@@ -489,7 +489,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_is_pending(const dif_csrng_t *csrng,
dif_csrng_irq_t irq,
bool *is_pending);
@@ -502,7 +502,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_acknowledge(const dif_csrng_t *csrng,
dif_csrng_irq_t irq);
@@ -514,7 +514,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_get_enabled(const dif_csrng_t *csrng,
dif_csrng_irq_t irq,
dif_csrng_toggle_t *state);
@@ -527,7 +527,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_set_enabled(const dif_csrng_t *csrng,
dif_csrng_irq_t irq,
dif_csrng_toggle_t state);
@@ -540,7 +540,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_force(const dif_csrng_t *csrng,
dif_csrng_irq_t irq);
@@ -552,7 +552,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_disable_all(
const dif_csrng_t *csrng, dif_csrng_irq_snapshot_t *snapshot);
@@ -566,7 +566,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_csrng_result_t dif_csrng_irq_restore_all(
const dif_csrng_t *csrng, const dif_csrng_irq_snapshot_t *snapshot);
diff --git a/sw/device/lib/dif/dif_edn.h b/sw/device/lib/dif/dif_edn.h
index 327f2c4..0d312ad 100644
--- a/sw/device/lib/dif/dif_edn.h
+++ b/sw/device/lib/dif/dif_edn.h
@@ -43,8 +43,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -200,7 +200,7 @@
* @param[out] edn Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_init(dif_edn_params_t params, dif_edn_t *edn);
/**
@@ -211,7 +211,7 @@
* @param edn An Entropy Distribution Network handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_configure(const dif_edn_t *edn);
/**
@@ -223,7 +223,7 @@
* @param edn An Entropy Distribution Network handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_boot_mode_start(const dif_edn_t *edn);
/**
@@ -236,7 +236,7 @@
* @param config Auto request configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_auto_mode_start(const dif_edn_t *edn,
dif_edn_auto_params_t *config);
@@ -272,7 +272,7 @@
* @param edn An Entropy Distribution Network handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_stop(const dif_edn_t *edn);
/**
@@ -284,7 +284,7 @@
* @param edn An Entropy Distribution Network handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_lock(const dif_edn_t *edn);
/**
@@ -294,7 +294,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_is_locked(const dif_edn_t *edn, bool *is_locked);
/**
@@ -305,7 +305,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_is_pending(const dif_edn_t *edn, dif_edn_irq_t irq,
bool *is_pending);
@@ -317,7 +317,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_acknowledge(const dif_edn_t *edn,
dif_edn_irq_t irq);
@@ -329,7 +329,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_get_enabled(const dif_edn_t *edn,
dif_edn_irq_t irq,
dif_edn_toggle_t *state);
@@ -342,7 +342,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_set_enabled(const dif_edn_t *edn,
dif_edn_irq_t irq,
dif_edn_toggle_t state);
@@ -355,7 +355,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_force(const dif_edn_t *edn, dif_edn_irq_t irq);
/**
@@ -366,7 +366,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_disable_all(const dif_edn_t *edn,
dif_edn_irq_snapshot_t *snapshot);
@@ -380,7 +380,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_edn_result_t dif_edn_irq_restore_all(
const dif_edn_t *edn, const dif_edn_irq_snapshot_t *snapshot);
diff --git a/sw/device/lib/dif/dif_entropy_src.h b/sw/device/lib/dif/dif_entropy_src.h
index 9417082..4b921be 100644
--- a/sw/device/lib/dif/dif_entropy_src.h
+++ b/sw/device/lib/dif/dif_entropy_src.h
@@ -13,8 +13,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -428,7 +428,7 @@
* @param[out] entropy Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_init(dif_entropy_src_params_t params,
dif_entropy_src_t *entropy);
@@ -441,7 +441,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_configure(
const dif_entropy_src_t *entropy, dif_entropy_src_config_t config);
@@ -452,7 +452,7 @@
* @param[out] revision Out-param for revision data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_get_revision(
const dif_entropy_src_t *entropy, dif_entropy_src_revision_t *revision);
@@ -466,7 +466,7 @@
* @param[out] stats Out-param for stats data.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_get_stats(
const dif_entropy_src_t *entropy, bool fips_mode,
dif_entropy_src_test_stats_t *stats);
@@ -480,7 +480,7 @@
* @param entropy An entropy source handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_lock(const dif_entropy_src_t *entropy);
/**
@@ -490,7 +490,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_is_locked(
const dif_entropy_src_t *entropy, bool *is_locked);
@@ -500,7 +500,7 @@
* @param entropy An entropy source handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_avail(
const dif_entropy_src_t *entropy);
@@ -511,7 +511,7 @@
* @param[out] word Out-param for the entropy.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_read(const dif_entropy_src_t *entropy,
uint32_t *word);
@@ -523,7 +523,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_is_pending(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_t irq,
bool *is_pending);
@@ -536,7 +536,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_acknowledge(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_t irq);
@@ -548,7 +548,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_get_enabled(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_t irq,
dif_entropy_src_toggle_t *state);
@@ -561,7 +561,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_set_enabled(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_t irq,
dif_entropy_src_toggle_t state);
@@ -574,7 +574,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_force(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_t irq);
@@ -586,7 +586,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_disable_all(
const dif_entropy_src_t *entropy, dif_entropy_src_irq_snapshot_t *snapshot);
@@ -600,7 +600,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_irq_restore_all(
const dif_entropy_src_t *entropy,
const dif_entropy_src_irq_snapshot_t *snapshot);
@@ -613,7 +613,7 @@
* @param alert An alert type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_alert_force(
const dif_entropy_src_t *entropy, dif_entropy_src_alert_t alert);
@@ -631,7 +631,7 @@
* @param len The number of words to read into `buf`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_read(
const dif_entropy_src_t *entropy, uint32_t *buf, size_t len);
@@ -647,7 +647,7 @@
* @param len The number of words to read from `buf`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_write(
const dif_entropy_src_t *entropy, const uint32_t *buf, size_t len);
@@ -660,7 +660,7 @@
* @param[out] len The number of words in the FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_get_len(
const dif_entropy_src_t *entropy, uint8_t *len);
@@ -671,7 +671,7 @@
* @param[out] capacity The number of words of capacity in the FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_get_capacity(
const dif_entropy_src_t *entropy, uint8_t *capacity);
@@ -685,7 +685,7 @@
* @param capacity The new capacity for the FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_set_capacity(
const dif_entropy_src_t *entropy, uint8_t capacity);
@@ -699,7 +699,7 @@
* @param entropy An entropy source handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_fifo_reconnect(
const dif_entropy_src_t *entropy);
@@ -709,7 +709,7 @@
* @param entropy An entropy source handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_disable(
const dif_entropy_src_t *entropy);
@@ -719,7 +719,7 @@
* @param entropy An entropy source handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_entropy_src_result_t dif_entropy_src_get_idle(
const dif_entropy_src_t *entropy);
diff --git a/sw/device/lib/dif/dif_gpio.c b/sw/device/lib/dif/dif_gpio.c
index 188d8da..642ed7c 100644
--- a/sw/device/lib/dif/dif_gpio.c
+++ b/sw/device/lib/dif/dif_gpio.c
@@ -36,7 +36,7 @@
* @param mask Mask that identifies the bits to write to.
* @param val Value to write.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static dif_gpio_result_t gpio_masked_write(const dif_gpio_t *gpio,
ptrdiff_t reg_lower_offset,
ptrdiff_t reg_upper_offset,
@@ -78,7 +78,7 @@
* @param index Zero-based index of the bit to write to.
* @param val Value to write.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static dif_gpio_result_t gpio_masked_bit_write(const dif_gpio_t *gpio,
ptrdiff_t reg_lower_offset,
ptrdiff_t reg_upper_offset,
diff --git a/sw/device/lib/dif/dif_gpio.h b/sw/device/lib/dif/dif_gpio.h
index bc9991d..f8a10d8 100644
--- a/sw/device/lib/dif/dif_gpio.h
+++ b/sw/device/lib/dif/dif_gpio.h
@@ -13,8 +13,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -60,7 +60,9 @@
*
* This type should be treated as opaque by users.
*/
-typedef struct dif_gpio { dif_gpio_params_t params; } dif_gpio_t;
+typedef struct dif_gpio {
+ dif_gpio_params_t params;
+} dif_gpio_t;
/**
* The result of a GPIO operation.
@@ -160,7 +162,7 @@
* @param[out] gpio Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_init(dif_gpio_params_t params, dif_gpio_t *gpio);
/**
@@ -172,7 +174,7 @@
* @param gpio A GPIO handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_reset(const dif_gpio_t *gpio);
/**
@@ -183,7 +185,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_is_pending(const dif_gpio_t *gpio,
dif_gpio_pin_t pin, bool *is_pending);
@@ -194,7 +196,7 @@
* @param[out] is_pending Out-param for which interrupts are pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_is_pending_all(const dif_gpio_t *gpio,
dif_gpio_state_t *is_pending);
@@ -207,7 +209,7 @@
* @param pin A GPIO pin.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_acknowledge(const dif_gpio_t *gpio,
dif_gpio_pin_t pin);
@@ -219,7 +221,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_get_enabled(const dif_gpio_t *gpio,
dif_gpio_pin_t pin,
dif_gpio_toggle_t *state);
@@ -232,7 +234,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_set_enabled(const dif_gpio_t *gpio,
dif_gpio_pin_t pin,
dif_gpio_toggle_t state);
@@ -246,7 +248,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_set_enabled_masked(const dif_gpio_t *gpio,
dif_gpio_mask_t mask,
dif_gpio_toggle_t state);
@@ -259,7 +261,7 @@
* @param pin A GPIO pin.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_force(const dif_gpio_t *gpio,
dif_gpio_pin_t pin);
@@ -271,7 +273,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_disable_all(const dif_gpio_t *gpio,
dif_gpio_state_t *snapshot);
@@ -285,7 +287,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_restore_all(const dif_gpio_t *gpio,
const dif_gpio_state_t *snapshot);
@@ -302,7 +304,7 @@
* @param trigger New configuration of interrupt triggers.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_irq_set_trigger(const dif_gpio_t *gpio,
dif_gpio_mask_t mask,
dif_gpio_irq_trigger_t trigger);
@@ -319,7 +321,7 @@
* @param[out] state Pin value.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_read(const dif_gpio_t *gpio, dif_gpio_pin_t pin,
bool *state);
@@ -334,7 +336,7 @@
* @param[out] state Pin values.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_read_all(const dif_gpio_t *gpio,
dif_gpio_state_t *state);
@@ -348,7 +350,7 @@
* @param state Value to write.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_write(const dif_gpio_t *gpio, dif_gpio_pin_t pin,
bool state);
@@ -361,7 +363,7 @@
* @param state Value to write.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_write_all(const dif_gpio_t *gpio,
dif_gpio_state_t state);
@@ -375,7 +377,7 @@
* @param state Value to write.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_write_masked(const dif_gpio_t *gpio,
dif_gpio_mask_t mask,
dif_gpio_state_t state);
@@ -388,7 +390,7 @@
* @param state Output mode of the pin.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_output_set_enabled(const dif_gpio_t *gpio,
dif_gpio_pin_t pin,
dif_gpio_toggle_t state);
@@ -400,7 +402,7 @@
* @param state Output modes of the pins.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_output_set_enabled_all(const dif_gpio_t *gpio,
dif_gpio_state_t state);
@@ -412,7 +414,7 @@
* @param state Output modes of the pins.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_output_set_enabled_masked(const dif_gpio_t *gpio,
dif_gpio_mask_t mask,
dif_gpio_state_t state);
@@ -428,7 +430,7 @@
* @param state The new toggle state for the filter.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_gpio_result_t dif_gpio_input_noise_filter_set_enabled(
const dif_gpio_t *gpio, dif_gpio_mask_t mask, dif_gpio_toggle_t state);
diff --git a/sw/device/lib/dif/dif_hmac.h b/sw/device/lib/dif/dif_hmac.h
index 72bc22e..0814cd1 100644
--- a/sw/device/lib/dif/dif_hmac.h
+++ b/sw/device/lib/dif/dif_hmac.h
@@ -12,6 +12,7 @@
#include <stddef.h>
#include <stdint.h>
+
#include "sw/device/lib/base/mmio.h"
#ifdef __cplusplus
@@ -158,7 +159,9 @@
/**
* A typed representation of the HMAC digest.
*/
-typedef struct dif_hmac_digest { uint32_t digest[8]; } dif_hmac_digest_t;
+typedef struct dif_hmac_digest {
+ uint32_t digest[8];
+} dif_hmac_digest_t;
/**
* State for a particular HMAC device.
@@ -166,7 +169,9 @@
* Its member variables should be considered private, and are only provided so
* that callers can allocate it.
*/
-typedef struct dif_hmac { mmio_region_t base_addr; } dif_hmac_t;
+typedef struct dif_hmac {
+ mmio_region_t base_addr;
+} dif_hmac_t;
/**
* Initializes the HMAC device described by `config`, writing internal state to
diff --git a/sw/device/lib/dif/dif_i2c.c b/sw/device/lib/dif/dif_i2c.c
index 9300ca3..080fd49 100644
--- a/sw/device/lib/dif/dif_i2c.c
+++ b/sw/device/lib/dif/dif_i2c.c
@@ -5,6 +5,7 @@
#include "sw/device/lib/dif/dif_i2c.h"
#include "sw/device/lib/base/bitfield.h"
+
#include "i2c_regs.h" // Generated
/**
@@ -263,7 +264,7 @@
return kDifI2cOk;
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool irq_index(dif_i2c_irq_t irq, bitfield_bit32_index_t *bit_index) {
switch (irq) {
case kDifI2cIrqFmtWatermarkUnderflow:
diff --git a/sw/device/lib/dif/dif_i2c.h b/sw/device/lib/dif/dif_i2c.h
index f85371c..392938c 100644
--- a/sw/device/lib/dif/dif_i2c.h
+++ b/sw/device/lib/dif/dif_i2c.h
@@ -13,8 +13,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -152,7 +152,9 @@
*
* This type should be treated as opaque by users.
*/
-typedef struct dif_i2c { dif_i2c_params_t params; } dif_i2c_t;
+typedef struct dif_i2c {
+ dif_i2c_params_t params;
+} dif_i2c_t;
/**
* The result of a I2C operation.
@@ -361,7 +363,7 @@
* parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_compute_timing(dif_i2c_timing_config_t timing_config,
dif_i2c_config_t *config);
/**
@@ -373,7 +375,7 @@
* @param[out] i2c Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_init(dif_i2c_params_t params, dif_i2c_t *i2c);
/**
@@ -385,7 +387,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_configure(const dif_i2c_t *i2c,
dif_i2c_config_t config);
@@ -397,7 +399,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_is_pending(const dif_i2c_t *i2c, dif_i2c_irq_t irq,
bool *is_pending);
@@ -409,7 +411,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_acknowledge(const dif_i2c_t *i2c,
dif_i2c_irq_t irq);
@@ -421,7 +423,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_get_enabled(const dif_i2c_t *i2c,
dif_i2c_irq_t irq,
dif_i2c_toggle_t *state);
@@ -434,7 +436,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_set_enabled(const dif_i2c_t *i2c,
dif_i2c_irq_t irq,
dif_i2c_toggle_t state);
@@ -447,7 +449,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_force(const dif_i2c_t *i2c, dif_i2c_irq_t irq);
/**
@@ -458,7 +460,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_disable_all(const dif_i2c_t *i2c,
dif_i2c_irq_snapshot_t *snapshot);
@@ -472,7 +474,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_irq_restore_all(
const dif_i2c_t *i2c, const dif_i2c_irq_snapshot_t *snapshot);
@@ -482,7 +484,7 @@
* @param i2c An I2c handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_reset_rx_fifo(const dif_i2c_t *i2c);
/**
@@ -492,7 +494,7 @@
* @param i2c An I2c handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_reset_fmt_fifo(const dif_i2c_t *i2c);
/**
@@ -507,7 +509,7 @@
* @param fmt_level The desired watermark level for the FMT FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_set_watermarks(const dif_i2c_t *i2c,
dif_i2c_level_t rx_level,
dif_i2c_level_t fmt_level);
@@ -521,7 +523,7 @@
* @param state The new toggle state for the host functionality.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_host_set_enabled(const dif_i2c_t *i2c,
dif_i2c_toggle_t state);
@@ -534,7 +536,7 @@
* @param state The new toggle state for override mode.'
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_override_set_enabled(const dif_i2c_t *i2c,
dif_i2c_toggle_t state);
@@ -547,7 +549,7 @@
* @param sda The value to drive SDA to.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_override_drive_pins(const dif_i2c_t *i2c, bool scl,
bool sda);
@@ -560,7 +562,7 @@
* @param[out] sda_samples SDA sample bits; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_override_sample_pins(const dif_i2c_t *i2c,
uint16_t *scl_samples,
uint16_t *sda_samples);
@@ -575,7 +577,7 @@
* @param[out] rx_fifo_level The number of unread RX bytes; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_get_fifo_levels(const dif_i2c_t *i2c,
uint8_t *fmt_fifo_level,
uint8_t *rx_fifo_level);
@@ -588,7 +590,7 @@
* @param[out] byte The popped byte; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_read_byte(const dif_i2c_t *i2c, uint8_t *byte);
/**
@@ -605,7 +607,7 @@
* @param flags The flags to use for this write.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_write_byte_raw(const dif_i2c_t *i2c, uint8_t byte,
dif_i2c_fmt_flags_t flags);
@@ -621,7 +623,7 @@
* May not be used in combination with `Rx` codes.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_i2c_result_t dif_i2c_write_byte(const dif_i2c_t *i2c, uint8_t byte,
dif_i2c_fmt_t code, bool suppress_nak_irq);
diff --git a/sw/device/lib/dif/dif_i2c_unittest.cc b/sw/device/lib/dif/dif_i2c_unittest.cc
index 067f25a..a9b5642 100644
--- a/sw/device/lib/dif/dif_i2c_unittest.cc
+++ b/sw/device/lib/dif/dif_i2c_unittest.cc
@@ -631,34 +631,37 @@
{I2C_FDATA_READ_BIT, 0x1},
{I2C_FDATA_RCONT_BIT, 0x1},
});
- EXPECT_EQ(
- dif_i2c_write_byte_raw(
- &i2c_, 0x00,
- {
- .start = false, .stop = false, .read = true, .read_cont = true,
- }),
- kDifI2cOk);
+ EXPECT_EQ(dif_i2c_write_byte_raw(&i2c_, 0x00,
+ {
+ .start = false,
+ .stop = false,
+ .read = true,
+ .read_cont = true,
+ }),
+ kDifI2cOk);
EXPECT_WRITE32(I2C_FDATA_REG_OFFSET, {
{I2C_FDATA_FBYTE_OFFSET, 0x77},
{I2C_FDATA_READ_BIT, 0x1},
});
- EXPECT_EQ(
- dif_i2c_write_byte_raw(&i2c_, 0x77,
- {
- .start = false, .stop = false, .read = true,
- }),
- kDifI2cOk);
+ EXPECT_EQ(dif_i2c_write_byte_raw(&i2c_, 0x77,
+ {
+ .start = false,
+ .stop = false,
+ .read = true,
+ }),
+ kDifI2cOk);
}
TEST_F(FifoTest, WriteRawBadArgs) {
EXPECT_EQ(dif_i2c_write_byte_raw(nullptr, 0xff, {}), kDifI2cBadArg);
- EXPECT_EQ(
- dif_i2c_write_byte_raw(&i2c_, 0xff,
- {
- .start = false, .stop = true, .read = true,
- }),
- kDifI2cBadArg);
+ EXPECT_EQ(dif_i2c_write_byte_raw(&i2c_, 0xff,
+ {
+ .start = false,
+ .stop = true,
+ .read = true,
+ }),
+ kDifI2cBadArg);
EXPECT_EQ(dif_i2c_write_byte_raw(&i2c_, 0xff,
{
.start = false,
diff --git a/sw/device/lib/dif/dif_keymgr.c b/sw/device/lib/dif/dif_keymgr.c
index e956207..b04951c 100644
--- a/sw/device/lib/dif/dif_keymgr.c
+++ b/sw/device/lib/dif/dif_keymgr.c
@@ -116,7 +116,7 @@
* Checks if the key manager is ready for a new operation, i.e. it is idle and
* the CONFIG register is unlocked.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_ready(const dif_keymgr_t *keymgr) {
// Keymgr must be idle and the CONTROL register must be writable.
uint32_t reg_op_status =
@@ -155,7 +155,7 @@
/**
* Returns max key version register information for transitioning from a state.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool get_max_key_version_reg_info_for_next_state(
uint32_t cur_state, max_key_version_reg_info_t *reg_info) {
switch (cur_state) {
@@ -231,7 +231,7 @@
/**
* Returns the bit index for a given IRQ.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool get_irq_bit_index(dif_keymgr_irq_t irq,
bitfield_bit32_index_t *bit_index) {
switch (irq) {
@@ -246,7 +246,7 @@
/**
* Checks if a value is a valid `dif_keymgr_toggle_t` and converts it to `bool`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool toggle_to_bool(dif_keymgr_toggle_t val, bool *val_bool) {
switch (val) {
case kDifKeymgrToggleEnabled:
diff --git a/sw/device/lib/dif/dif_keymgr.h b/sw/device/lib/dif/dif_keymgr.h
index 76cfd0d..fbbf669 100644
--- a/sw/device/lib/dif/dif_keymgr.h
+++ b/sw/device/lib/dif/dif_keymgr.h
@@ -13,8 +13,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -295,7 +295,7 @@
* @param[out] keymgr Out-param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_init(dif_keymgr_params_t params,
dif_keymgr_t *keymgr);
@@ -308,7 +308,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_configure(const dif_keymgr_t *keymgr,
dif_keymgr_config_t config);
@@ -363,7 +363,7 @@
* @param params The binding and max key version value for the next state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_lockable_result_t dif_keymgr_advance_state(
const dif_keymgr_t *keymgr, const dif_keymgr_state_params_t *params);
@@ -377,7 +377,7 @@
* @param keymgr A key manager handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_lockable_result_t dif_keymgr_disable(const dif_keymgr_t *keymgr);
/**
@@ -435,7 +435,7 @@
* @param[out] status_codes Out-param for key manager status codes.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_get_status_codes(
const dif_keymgr_t *keymgr, dif_keymgr_status_codes_t *status_codes);
@@ -446,7 +446,7 @@
* @param[out] state Out-param for current key manager state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_get_state(const dif_keymgr_t *keymgr,
dif_keymgr_state_t *state);
@@ -464,7 +464,7 @@
* @param keymgr A key manager handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_lockable_result_t dif_keymgr_generate_identity_seed(
const dif_keymgr_t *keymgr);
@@ -534,7 +534,7 @@
* @param params Key generation parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_lockable_result_t dif_keymgr_generate_versioned_key(
const dif_keymgr_t *keymgr, dif_keymgr_versioned_key_params_t params);
@@ -551,7 +551,7 @@
* @param state The new toggle state for sideload clear.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_sideload_clear_set_enabled(
const dif_keymgr_t *keymgr, dif_keymgr_toggle_t state);
@@ -562,7 +562,7 @@
* @param[out] Out-param for the current toggle state of sideload clear.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_sideload_clear_get_enabled(
const dif_keymgr_t *keymgr, dif_keymgr_toggle_t *state);
@@ -592,7 +592,7 @@
* @param[out] output Out-param for key manager output.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_read_output(const dif_keymgr_t *keymgr,
dif_keymgr_output_t *output);
@@ -603,7 +603,7 @@
* @param alert An alert type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_alert_force(const dif_keymgr_t *keymgr,
dif_keymgr_alert_t alert);
/**
@@ -614,7 +614,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_is_pending(const dif_keymgr_t *keymgr,
dif_keymgr_irq_t irq,
bool *is_pending);
@@ -627,7 +627,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_acknowledge(const dif_keymgr_t *keymgr,
dif_keymgr_irq_t irq);
@@ -639,7 +639,7 @@
* @param[out] state Out-param for toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_get_enabled(const dif_keymgr_t *keymgr,
dif_keymgr_irq_t irq,
dif_keymgr_toggle_t *state);
@@ -652,7 +652,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_set_enabled(const dif_keymgr_t *keymgr,
dif_keymgr_irq_t irq,
dif_keymgr_toggle_t state);
@@ -665,7 +665,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_force(const dif_keymgr_t *keymgr,
dif_keymgr_irq_t irq);
@@ -677,7 +677,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_disable_all(
const dif_keymgr_t *keymgr, dif_keymgr_irq_snapshot_t *snapshot);
@@ -691,7 +691,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_keymgr_result_t dif_keymgr_irq_restore_all(
const dif_keymgr_t *keymgr, const dif_keymgr_irq_snapshot_t *snapshot);
diff --git a/sw/device/lib/dif/dif_kmac.h b/sw/device/lib/dif/dif_kmac.h
index 2b9a04d..c1f7044 100644
--- a/sw/device/lib/dif/dif_kmac.h
+++ b/sw/device/lib/dif/dif_kmac.h
@@ -12,8 +12,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -494,7 +494,7 @@
* @param[out] kmac Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_init(dif_kmac_params_t params, dif_kmac_t *kmac);
/**
@@ -504,7 +504,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT dif_kmac_result_t
+OT_WARN_UNUSED_RESULT dif_kmac_result_t
dif_kmac_configure(dif_kmac_t *kmac, dif_kmac_config_t config);
/**
@@ -523,7 +523,7 @@
* @param[out] out Encoded customization string.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_customization_string_init(
const char *data, size_t len, dif_kmac_customization_string_t *out);
@@ -543,7 +543,7 @@
* @param[out] out Encoded function name.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_function_name_init(const char *data, size_t len,
dif_kmac_function_name_t *out);
@@ -558,7 +558,7 @@
* @param mode The SHA-3 mode of operation.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_mode_sha3_start(dif_kmac_t *kmac,
dif_kmac_mode_sha3_t mode);
@@ -573,7 +573,7 @@
* @param mode The mode of operation.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_mode_shake_start(dif_kmac_t *kmac,
dif_kmac_mode_shake_t mode);
@@ -590,7 +590,7 @@
* @param s Customization string (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_mode_cshake_start(
dif_kmac_t *kmac, dif_kmac_mode_cshake_t mode,
const dif_kmac_function_name_t *n,
@@ -615,7 +615,7 @@
* @param s Customization string (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_mode_kmac_start(
dif_kmac_t *kmac, dif_kmac_mode_kmac_t mode, size_t l,
const dif_kmac_key_t *k, const dif_kmac_customization_string_t *s);
@@ -637,7 +637,7 @@
* @param[out] processed Number of bytes processed (optional).
* @preturn The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_absorb(dif_kmac_t *kmac, const void *msg, size_t len,
size_t *processed);
@@ -662,7 +662,7 @@
* (optional).
* @preturn The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_squeeze(dif_kmac_t *kmac, uint32_t *out, size_t len,
size_t *processed);
@@ -673,7 +673,7 @@
* @param kmac A KMAC handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_end(dif_kmac_t *kmac);
/**
@@ -683,7 +683,7 @@
* @param[out] error The current error code.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_get_error(const dif_kmac_t *kmac,
dif_kmac_error_t *error);
@@ -697,7 +697,7 @@
* @param kmac A KMAC handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_reset(dif_kmac_t *kmac);
/**
@@ -708,7 +708,7 @@
* @param[out] depth The current depth of the FIFO (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_get_fifo_state(const dif_kmac_t *kmac,
dif_kmac_fifo_state_t *state,
uint32_t *depth);
@@ -725,7 +725,7 @@
* @param[out] is_locked Out-param reporting the lock state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_config_is_locked(const dif_kmac_t *kmac,
bool *is_locked);
@@ -737,7 +737,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_is_pending(const dif_kmac_t *kmac,
dif_kmac_irq_t irq, bool *is_pending);
@@ -749,7 +749,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_acknowledge(const dif_kmac_t *kmac,
dif_kmac_irq_t irq);
@@ -761,7 +761,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_get_enabled(const dif_kmac_t *kmac,
dif_kmac_irq_t irq,
dif_kmac_toggle_t *state);
@@ -774,7 +774,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_set_enabled(const dif_kmac_t *kmac,
dif_kmac_irq_t irq,
dif_kmac_toggle_t state);
@@ -787,7 +787,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_force(const dif_kmac_t *kmac,
dif_kmac_irq_t irq);
@@ -799,7 +799,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_disable_all(const dif_kmac_t *kmac,
dif_kmac_irq_snapshot_t *snapshot);
@@ -813,7 +813,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_kmac_result_t dif_kmac_irq_restore_all(
const dif_kmac_t *kmac, const dif_kmac_irq_snapshot_t *snapshot);
diff --git a/sw/device/lib/dif/dif_lc_ctrl.h b/sw/device/lib/dif/dif_lc_ctrl.h
index 76274fb..42d8ed3 100644
--- a/sw/device/lib/dif/dif_lc_ctrl.h
+++ b/sw/device/lib/dif/dif_lc_ctrl.h
@@ -14,8 +14,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -420,7 +420,7 @@
* @param[out] lc Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_init(dif_lc_ctrl_params_t params,
dif_lc_ctrl_t *lc);
@@ -431,7 +431,7 @@
* @param[out] state Out-param for the controller's state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_get_state(const dif_lc_ctrl_t *lc,
dif_lc_ctrl_state_t *state);
@@ -443,7 +443,7 @@
* @param[out] count Out-param for the number of attempts.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_attempts_result_t dif_lc_ctrl_get_attempts(const dif_lc_ctrl_t *lc,
uint8_t *count);
@@ -454,7 +454,7 @@
* @param[out] status Out-param for the controller's status.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_get_status(const dif_lc_ctrl_t *lc,
dif_lc_ctrl_status_t *status);
@@ -465,7 +465,7 @@
* @param[out] state Out-param for the controller's personalization state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_get_id_state(const dif_lc_ctrl_t *lc,
dif_lc_ctrl_id_state_t *state);
@@ -477,7 +477,7 @@
* @param[out] device_id Out-param for the device id.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_get_device_id(
const dif_lc_ctrl_t *lc, dif_lc_ctrl_device_id_t *device_id);
@@ -489,7 +489,7 @@
* @param alert The alert to force.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_alert_force(const dif_lc_ctrl_t *lc,
dif_lc_ctrl_alert_t alert);
@@ -504,7 +504,7 @@
*/
// Open Q: do we want to be checking REGWEN for all operations dependent on the
// mutex?
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_mutex_result_t dif_lc_ctrl_mutex_try_acquire(
const dif_lc_ctrl_t *lc);
@@ -517,7 +517,7 @@
* @param lc A lifecycle handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_mutex_result_t dif_lc_ctrl_mutex_release(const dif_lc_ctrl_t *lc);
/**
@@ -531,7 +531,7 @@
* @param token A token for unlocking the transition; may be null.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_mutex_result_t dif_lc_ctrl_transition(
const dif_lc_ctrl_t *lc, dif_lc_ctrl_state_t state,
const dif_lc_ctrl_token_t *token, const dif_lc_ctrl_settings_t *settings);
@@ -543,7 +543,7 @@
* @param settings The settings to write to the register.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_mutex_result_t dif_lc_ctrl_set_otp_vendor_test_reg(
const dif_lc_ctrl_t *lc, uint32_t settings);
@@ -554,7 +554,7 @@
* @param settings Output parameter for the settings.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_lc_ctrl_result_t dif_lc_ctrl_get_otp_vendor_test_reg(
const dif_lc_ctrl_t *lc, uint32_t *settings);
diff --git a/sw/device/lib/dif/dif_otp_ctrl.h b/sw/device/lib/dif/dif_otp_ctrl.h
index 0c34019..fde3245 100644
--- a/sw/device/lib/dif/dif_otp_ctrl.h
+++ b/sw/device/lib/dif/dif_otp_ctrl.h
@@ -12,8 +12,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
// Header Extern Guard (so header can be used from C and C++)
#ifdef __cplusplus
@@ -473,7 +473,7 @@
* @param[out] otp Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_init(dif_otp_ctrl_params_t params,
dif_otp_ctrl_t *otp);
@@ -487,7 +487,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_lockable_result_t dif_otp_ctrl_configure(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_config_t config);
@@ -500,7 +500,7 @@
* @param otp An OTP handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_lockable_result_t dif_otp_ctrl_check_integrity(
const dif_otp_ctrl_t *otp);
@@ -513,7 +513,7 @@
* @param otp An OTP handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_lockable_result_t dif_otp_ctrl_check_consistency(
const dif_otp_ctrl_t *otp);
@@ -527,7 +527,7 @@
* @param otp An OTP handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_lock_config(const dif_otp_ctrl_t *otp);
/**
@@ -538,7 +538,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_config_is_locked(const dif_otp_ctrl_t *otp,
bool *is_locked);
@@ -559,7 +559,7 @@
* @param partition The SW partition to lock.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_lock_reading(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition);
@@ -574,7 +574,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_reading_is_locked(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
bool *is_locked);
@@ -587,7 +587,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_is_pending(const dif_otp_ctrl_t *otp,
dif_otp_ctrl_irq_t irq,
bool *is_pending);
@@ -600,7 +600,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_acknowledge(const dif_otp_ctrl_t *otp,
dif_otp_ctrl_irq_t irq);
@@ -612,7 +612,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_get_enabled(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_irq_t irq,
dif_otp_ctrl_toggle_t *state);
@@ -625,7 +625,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_set_enabled(const dif_otp_ctrl_t *otp,
dif_otp_ctrl_irq_t irq,
dif_otp_ctrl_toggle_t state);
@@ -638,7 +638,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_force(const dif_otp_ctrl_t *otp,
dif_otp_ctrl_irq_t irq);
@@ -650,7 +650,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_disable_all(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_irq_snapshot_t *snapshot);
@@ -664,7 +664,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_irq_restore_all(
const dif_otp_ctrl_t *otp, const dif_otp_ctrl_irq_snapshot_t *snapshot);
@@ -675,7 +675,7 @@
* @param[out] status Out-param for the controller's status.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_get_status(const dif_otp_ctrl_t *otp,
dif_otp_ctrl_status_t *status);
@@ -695,7 +695,7 @@
* @param address A partition-relative address to read from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_read_start(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint32_t address);
@@ -711,7 +711,7 @@
* @param[out] value Out-param for the read value.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_read32_end(const dif_otp_ctrl_t *otp,
uint32_t *value);
@@ -726,7 +726,7 @@
* @param[out] value Out-param for the read value.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_read64_end(const dif_otp_ctrl_t *otp,
uint64_t *value);
@@ -749,7 +749,7 @@
* @param value The value to program into the OTP.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_program32(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint32_t address, uint32_t value);
@@ -770,7 +770,7 @@
* @param value The value to program into the OTP.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_program64(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint32_t address, uint64_t value);
@@ -793,7 +793,7 @@
* @param digest The digest to program (for SW partitions).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_dai_digest(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint64_t digest);
@@ -813,7 +813,7 @@
* @param[out] digest Out-param for the digest.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_digest_result_t dif_otp_ctrl_get_digest(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint64_t *digest);
@@ -837,7 +837,7 @@
* @param len The number of words to read.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_dai_result_t dif_otp_ctrl_read_blocking(
const dif_otp_ctrl_t *otp, dif_otp_ctrl_partition_t partition,
uint32_t address, uint32_t *buf, size_t len);
@@ -856,7 +856,7 @@
* @param len The number of words to read.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_read_test(const dif_otp_ctrl_t *otp,
uint32_t address, uint32_t *buf,
size_t len);
@@ -875,7 +875,7 @@
* @param len The number of words to write.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_otp_ctrl_result_t dif_otp_ctrl_write_test(const dif_otp_ctrl_t *otp,
uint32_t address,
const uint32_t *buf, size_t len);
diff --git a/sw/device/lib/dif/dif_pinmux.h b/sw/device/lib/dif/dif_pinmux.h
index 7aad075..362fcc9 100644
--- a/sw/device/lib/dif/dif_pinmux.h
+++ b/sw/device/lib/dif/dif_pinmux.h
@@ -25,8 +25,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -335,7 +335,7 @@
* @param[out] pinmux Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_init(dif_pinmux_params_t params,
dif_pinmux_t *pinmux);
@@ -358,7 +358,7 @@
* @param target Target functionality to be locked.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_lock(const dif_pinmux_t *pinmux,
dif_pinmux_index_t index,
dif_pinmux_lock_target_t target);
@@ -374,7 +374,7 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_is_locked(const dif_pinmux_t *pinmux,
dif_pinmux_index_t index,
dif_pinmux_lock_target_t target,
@@ -417,7 +417,7 @@
* a peripheral input.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_select_result_t dif_pinmux_input_select(
const dif_pinmux_t *pinmux, dif_pinmux_index_t peripheral_input,
dif_pinmux_index_t insel);
@@ -433,7 +433,7 @@
* connected to a MIO pad output.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_select_result_t dif_pinmux_output_select(
const dif_pinmux_t *pinmux, dif_pinmux_index_t mio_pad_output,
dif_pinmux_index_t outsel);
@@ -546,7 +546,7 @@
* @param mode Pad deep sleep mode.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_toggle_result_t dif_pinmux_pad_sleep_enable(
const dif_pinmux_t *pinmux, dif_pinmux_index_t pad,
dif_pinmux_pad_kind_t type, dif_pinmux_sleep_mode_t mode);
@@ -565,7 +565,7 @@
* @param type Pad type (MIO or DIO).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_toggle_result_t dif_pinmux_pad_sleep_disable(
const dif_pinmux_t *pinmux, dif_pinmux_index_t pad,
dif_pinmux_pad_kind_t type);
@@ -582,7 +582,7 @@
* @param[out] in_sleep_mode Pad state, `true` when in deep sleep mode.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_pad_sleep_get_state(const dif_pinmux_t *pinmux,
dif_pinmux_index_t pad,
dif_pinmux_pad_kind_t type,
@@ -601,7 +601,7 @@
* @param type Padring pad type (MIO or DIO).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_pad_sleep_clear_state(
const dif_pinmux_t *pinmux, dif_pinmux_index_t pad,
dif_pinmux_pad_kind_t type);
@@ -614,7 +614,7 @@
* @param config A wake-up detector configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_toggle_result_t dif_pinmux_wakeup_detector_enable_edge(
const dif_pinmux_t *pinmux, dif_pinmux_index_t detector,
dif_pinmux_wakeup_edge_config_t config);
@@ -627,7 +627,7 @@
* @param config A wake-up detector configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_toggle_result_t dif_pinmux_wakeup_detector_enable_timed(
const dif_pinmux_t *pinmux, dif_pinmux_index_t detector,
dif_pinmux_wakeup_timed_config_t config);
@@ -639,7 +639,7 @@
* @param detector A detector index.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_toggle_result_t dif_pinmux_wakeup_detect_disable(
const dif_pinmux_t *pinmux, dif_pinmux_index_t detector);
@@ -649,7 +649,7 @@
* @param pinmux A Pin Multiplexer handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_wakeup_cause_clear(const dif_pinmux_t *pinmux);
/**
@@ -659,7 +659,7 @@
* @param detector[out] A detector index.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pinmux_result_t dif_pinmux_wakeup_cause_get(const dif_pinmux_t *pinmux,
dif_pinmux_index_t *detector);
diff --git a/sw/device/lib/dif/dif_pwrmgr.c b/sw/device/lib/dif/dif_pwrmgr.c
index cbbbcfd..c552564 100644
--- a/sw/device/lib/dif/dif_pwrmgr.c
+++ b/sw/device/lib/dif/dif_pwrmgr.c
@@ -150,7 +150,7 @@
/**
* Checks if a value is a valid `dif_pwrmgr_toggle_t` and converts it to `bool`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool toggle_to_bool(dif_pwrmgr_toggle_t val, bool *val_bool) {
switch (val) {
case kDifPwrmgrToggleEnabled:
@@ -175,7 +175,7 @@
/**
* Checks if a value is a valid `dif_pwrmgr_req_type_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_req_type(dif_pwrmgr_req_type_t val) {
return val == kDifPwrmgrReqTypeWakeup || val == kDifPwrmgrReqTypeReset;
}
@@ -183,7 +183,7 @@
/**
* Checks if a value is a valid `dif_pwrmgr_irq_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_irq(dif_pwrmgr_irq_t val) {
return val >= 0 && val <= kDifPwrmgrIrqLast;
}
@@ -192,7 +192,7 @@
* Checks if a value is valid for, i.e. fits in the mask of, a
* `bitfield_field32_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_for_bitfield(uint32_t val, bitfield_field32_t bitfield) {
return (val & bitfield.mask) == val;
}
@@ -203,7 +203,7 @@
* Control register is locked when low power is enabled and WFI occurs. It is
* unlocked when the chip transitions back to active power state.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool control_register_is_locked(const dif_pwrmgr_t *pwrmgr) {
// Control register is locked when `PWRMGR_CTRL_CFG_REGWEN_EN_BIT` bit is 0.
return !bitfield_bit32_read(
@@ -232,7 +232,7 @@
/**
* Checks if sources of a request type are locked.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool request_sources_is_locked(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_req_type_t req_type) {
request_reg_info_t reg_info = request_reg_infos[req_type];
diff --git a/sw/device/lib/dif/dif_pwrmgr.h b/sw/device/lib/dif/dif_pwrmgr.h
index 92cf8a8..81d7442 100644
--- a/sw/device/lib/dif/dif_pwrmgr.h
+++ b/sw/device/lib/dif/dif_pwrmgr.h
@@ -13,8 +13,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -296,7 +296,7 @@
* @param[out] pwrmgr Out-param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_init(dif_pwrmgr_params_t params,
dif_pwrmgr_t *pwrmgr);
@@ -315,7 +315,7 @@
* @param new_state Whether low power state is enabled.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_config_result_t dif_pwrmgr_low_power_set_enabled(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_toggle_t new_state);
@@ -326,7 +326,7 @@
* @param[out] cur_state Whether low power state is enabled.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_low_power_get_enabled(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_toggle_t *cur_state);
@@ -341,7 +341,7 @@
* @param config A domain configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_config_result_t dif_pwrmgr_set_domain_config(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_domain_config_t config);
@@ -352,7 +352,7 @@
* @param[out] config Current configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_get_domain_config(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_domain_config_t *config);
@@ -371,7 +371,7 @@
* @param sources Sources enabled for the given request type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_config_result_t dif_pwrmgr_set_request_sources(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_req_type_t req_type,
dif_pwrmgr_request_sources_t sources);
@@ -388,7 +388,7 @@
* @param[out] sources Sources enabled for the given request type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_get_request_sources(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_req_type_t req_type,
dif_pwrmgr_request_sources_t *sources);
@@ -402,7 +402,7 @@
* request type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_get_current_request_sources(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_req_type_t req_type,
dif_pwrmgr_request_sources_t *sources);
@@ -417,7 +417,7 @@
* @param req_type A request type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_request_sources_lock(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_req_type_t req_type);
@@ -429,7 +429,7 @@
* @param[out] is_locked Whether sources of the given request type is locked.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_request_sources_is_locked(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_req_type_t req_type,
bool *is_locked);
@@ -445,7 +445,7 @@
* @param new_state Whether wakeup requests should be recorded.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_wakeup_request_recording_set_enabled(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_toggle_t new_state);
@@ -456,7 +456,7 @@
* @param[out] cur_state Whether wakeup requests are being recorded.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_wakeup_request_recording_get_enabled(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_toggle_t *cur_state);
@@ -474,7 +474,7 @@
* @param[out] reason Wakeup reasons.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_wakeup_reason_get(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_wakeup_reason_t *reason);
@@ -484,7 +484,7 @@
* @param pwrmgr A power manager handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_wakeup_reason_clear(const dif_pwrmgr_t *pwrmgr);
/**
@@ -495,7 +495,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_is_pending(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_irq_t irq,
bool *is_pending);
@@ -508,7 +508,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_acknowledge(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_irq_t irq);
@@ -520,7 +520,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_get_enabled(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_irq_t irq,
dif_pwrmgr_toggle_t *state);
@@ -533,7 +533,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_set_enabled(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_irq_t irq,
dif_pwrmgr_toggle_t state);
@@ -546,7 +546,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_force(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_irq_t irq);
@@ -558,7 +558,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_disable_all(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_irq_snapshot_t *snapshot);
@@ -572,7 +572,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_irq_restore_all(
const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_irq_snapshot_t snapshot);
@@ -584,7 +584,7 @@
* @param alert A power manager alert type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_pwrmgr_result_t dif_pwrmgr_alert_force(const dif_pwrmgr_t *pwrmgr,
dif_pwrmgr_alert_t alert);
diff --git a/sw/device/lib/dif/dif_rstmgr.h b/sw/device/lib/dif/dif_rstmgr.h
index a8f15bb..716df86 100644
--- a/sw/device/lib/dif/dif_rstmgr.h
+++ b/sw/device/lib/dif/dif_rstmgr.h
@@ -14,8 +14,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -147,7 +147,7 @@
* @param handle Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_init(dif_rstmgr_params_t params,
dif_rstmgr_t *handle);
@@ -160,7 +160,7 @@
* @param handle A Reset Manager handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_reset(const dif_rstmgr_t *handle);
/**
@@ -173,7 +173,7 @@
* @param peripheral Peripheral to lock the reset functionality for.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_reset_lock(const dif_rstmgr_t *handle,
dif_rstmgr_peripheral_t peripheral);
@@ -185,7 +185,7 @@
* @param is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_reset_is_locked(
const dif_rstmgr_t *handle, dif_rstmgr_peripheral_t peripheral,
bool *is_locked);
@@ -200,7 +200,7 @@
* @param info Reset information.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_reset_info_get(
const dif_rstmgr_t *handle, dif_rstmgr_reset_info_bitfield_t *info);
@@ -211,7 +211,7 @@
* @return `dif_rstmgr_result_t`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_reset_info_clear(const dif_rstmgr_t *handle);
/**
@@ -226,7 +226,7 @@
* @param state The new toggle state for the crash dump capture.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_alert_info_set_enabled(
const dif_rstmgr_t *handle, dif_rstmgr_toggle_t state);
@@ -265,7 +265,7 @@
*
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_alert_info_dump_read(
const dif_rstmgr_t *handle, dif_rstmgr_alert_info_dump_segment_t *dump,
size_t dump_size, size_t *segments_read);
@@ -304,7 +304,7 @@
* @param reset Reset control.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_software_reset_result_t dif_rstmgr_software_reset(
const dif_rstmgr_t *handle, dif_rstmgr_peripheral_t peripheral,
dif_rstmgr_software_reset_t reset);
@@ -317,7 +317,7 @@
* @param asserted 'true' when held in reset, `false` otherwise.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rstmgr_result_t dif_rstmgr_software_reset_is_held(
const dif_rstmgr_t *handle, dif_rstmgr_peripheral_t peripheral,
bool *asserted);
diff --git a/sw/device/lib/dif/dif_rv_plic.h b/sw/device/lib/dif/dif_rv_plic.h
index f7c0e6f..d14bfd7 100644
--- a/sw/device/lib/dif/dif_rv_plic.h
+++ b/sw/device/lib/dif/dif_rv_plic.h
@@ -20,8 +20,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -132,7 +132,7 @@
* @param[out] plic Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_init(dif_rv_plic_params_t params,
dif_rv_plic_t *plic);
@@ -144,7 +144,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_is_pending(const dif_rv_plic_t *plic,
dif_rv_plic_irq_id_t irq,
bool *is_pending);
@@ -158,7 +158,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_get_enabled(const dif_rv_plic_t *plic,
dif_rv_plic_irq_id_t irq,
dif_rv_plic_target_t target,
@@ -176,7 +176,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_set_enabled(const dif_rv_plic_t *plic,
dif_rv_plic_irq_id_t irq,
dif_rv_plic_target_t target,
@@ -194,7 +194,7 @@
* @param priority Priority to set.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_set_priority(const dif_rv_plic_t *plic,
dif_rv_plic_irq_id_t irq,
uint32_t priority);
@@ -211,7 +211,7 @@
* @param threshold IRQ priority threshold to be set.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_target_set_threshold(
const dif_rv_plic_t *plic, dif_rv_plic_target_t target, uint32_t threshold);
@@ -239,7 +239,7 @@
* @param[out] claim_data Data that describes the origin of the IRQ.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_claim(const dif_rv_plic_t *plic,
dif_rv_plic_target_t target,
dif_rv_plic_irq_id_t *claim_data);
@@ -262,7 +262,7 @@
* PLIC of the IRQ servicing completion.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_irq_complete(
const dif_rv_plic_t *plic, dif_rv_plic_target_t target,
dif_rv_plic_irq_id_t complete_data);
@@ -284,7 +284,7 @@
* @param target Target HART.
* @return `dif_rv_plic_result_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_software_irq_force(
const dif_rv_plic_t *plic, dif_rv_plic_target_t target);
@@ -299,7 +299,7 @@
* @param target Target HART.
* @return `dif_rv_plic_result_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_software_irq_acknowledge(
const dif_rv_plic_t *plic, dif_rv_plic_target_t target);
@@ -311,7 +311,7 @@
* @param[out] is_pending Flag indicating whether the interrupt is pending.
* @return `dif_rv_plic_result_t`.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_rv_plic_result_t dif_rv_plic_software_irq_is_pending(
const dif_rv_plic_t *plic, dif_rv_plic_target_t target, bool *is_pending);
diff --git a/sw/device/lib/dif/dif_spi_device.c b/sw/device/lib/dif/dif_spi_device.c
index 3603f65..0299804 100644
--- a/sw/device/lib/dif/dif_spi_device.c
+++ b/sw/device/lib/dif/dif_spi_device.c
@@ -6,6 +6,7 @@
#include "sw/device/lib/base/bitfield.h"
#include "sw/device/lib/base/memory.h"
+
#include "spi_device_regs.h" // Generated.
const uint16_t kDifSpiDeviceBufferLen = SPI_DEVICE_BUFFER_SIZE_BYTES;
@@ -110,7 +111,7 @@
}
}
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool irq_index(dif_spi_device_irq_t irq, bitfield_bit32_index_t *index) {
switch (irq) {
case kDifSpiDeviceIrqRxFull:
@@ -424,18 +425,18 @@
}
uint32_t ptr = 0;
- ptr = bitfield_field32_write(
- ptr,
- (bitfield_field32_t){
- .mask = params.write_mask, .index = params.write_offset,
- },
- write_val);
- ptr = bitfield_field32_write(
- ptr,
- (bitfield_field32_t){
- .mask = params.read_mask, .index = params.read_offset,
- },
- read_val);
+ ptr = bitfield_field32_write(ptr,
+ (bitfield_field32_t){
+ .mask = params.write_mask,
+ .index = params.write_offset,
+ },
+ write_val);
+ ptr = bitfield_field32_write(ptr,
+ (bitfield_field32_t){
+ .mask = params.read_mask,
+ .index = params.read_offset,
+ },
+ read_val);
mmio_region_write32(spi->params.base_addr, params.reg_offset, ptr);
}
diff --git a/sw/device/lib/dif/dif_spi_device.h b/sw/device/lib/dif/dif_spi_device.h
index 4e894b7..ba432de 100644
--- a/sw/device/lib/dif/dif_spi_device.h
+++ b/sw/device/lib/dif/dif_spi_device.h
@@ -14,8 +14,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -194,7 +194,7 @@
* @param[out] spi Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_init(dif_spi_device_params_t params,
dif_spi_device_t *spi);
@@ -207,7 +207,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_configure(
dif_spi_device_t *spi, dif_spi_device_config_t config);
@@ -218,7 +218,7 @@
* @param spi A SPI handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_abort(const dif_spi_device_t *spi);
/**
@@ -229,7 +229,7 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_is_pending(
const dif_spi_device_t *spi, dif_spi_device_irq_t irq, bool *is_pending);
@@ -241,7 +241,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_acknowledge(
const dif_spi_device_t *spi, dif_spi_device_irq_t irq);
@@ -253,7 +253,7 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_get_enabled(
const dif_spi_device_t *spi, dif_spi_device_irq_t irq,
dif_spi_device_toggle_t *state);
@@ -266,7 +266,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_set_enabled(
const dif_spi_device_t *spi, dif_spi_device_irq_t irq,
dif_spi_device_toggle_t state);
@@ -279,7 +279,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_force(const dif_spi_device_t *spi,
dif_spi_device_irq_t irq);
@@ -291,7 +291,7 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_disable_all(
const dif_spi_device_t *spi, dif_spi_device_irq_snapshot_t *snapshot);
@@ -306,7 +306,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_irq_restore_all(
const dif_spi_device_t *spi, const dif_spi_device_irq_snapshot_t *snapshot);
@@ -329,7 +329,7 @@
* @param tx_level The new TX level, as described above.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_set_irq_levels(
const dif_spi_device_t *spi, uint16_t rx_level, uint16_t tx_level);
@@ -340,7 +340,7 @@
* @param[out] bytes_pending The number of bytes pending
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_rx_pending(const dif_spi_device_t *spi,
size_t *bytes_pending);
@@ -352,7 +352,7 @@
* @param[out] bytes_pending The number of bytes pending
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_tx_pending(const dif_spi_device_t *spi,
size_t *bytes_pending);
@@ -367,7 +367,7 @@
* null.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_recv(const dif_spi_device_t *spi,
void *buf, size_t buf_len,
size_t *bytes_received);
@@ -382,7 +382,7 @@
* @param[out] bytes_sent The number of bytes successfully written; may be null.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_spi_device_result_t dif_spi_device_send(const dif_spi_device_t *spi,
const void *buf, size_t buf_len,
size_t *bytes_sent);
diff --git a/sw/device/lib/dif/dif_sram_ctrl.h b/sw/device/lib/dif/dif_sram_ctrl.h
index c3fe6b8..011d674 100644
--- a/sw/device/lib/dif/dif_sram_ctrl.h
+++ b/sw/device/lib/dif/dif_sram_ctrl.h
@@ -28,8 +28,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -105,7 +105,7 @@
* @param[out] handle Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_init(dif_sram_ctrl_params_t params,
dif_sram_ctrl_t *handle);
@@ -115,7 +115,7 @@
* @param sram_ctrl A SRAM Controller handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_force_alert(
const dif_sram_ctrl_t *sram_ctrl);
@@ -129,7 +129,7 @@
* @param sram_ctrl A SRAM Controller handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_exec_lock(
const dif_sram_ctrl_t *sram_ctrl);
@@ -143,7 +143,7 @@
* @param state[out] Enabled if locked, disabled if unlocked.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_exec_is_locked(
const dif_sram_ctrl_t *sram_ctrl, dif_sram_ctrl_toggle_t *state);
@@ -157,7 +157,7 @@
* @param state[out] Enabled if locked, disabled if unlocked.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_control_is_locked(
const dif_sram_ctrl_t *sram_ctrl, dif_sram_ctrl_toggle_t *state);
@@ -194,7 +194,7 @@
* @param state Enable or disable SRAM execution.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_exec_result_t dif_sram_ctrl_exec_set_enabled(
const dif_sram_ctrl_t *sram_ctrl, dif_sram_ctrl_toggle_t state);
@@ -205,7 +205,7 @@
* @param[out] state State of SRAM execution (enabled or disabled).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_exec_get_enabled(
const dif_sram_ctrl_t *sram_ctrl, dif_sram_ctrl_toggle_t *state);
@@ -223,7 +223,7 @@
* @param[out] address The byte address of the last parity error (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_get_error(const dif_sram_ctrl_t *sram_ctrl,
bool *error, uintptr_t *address);
@@ -257,7 +257,7 @@
* @param[out] status Information about the scrambling key in use.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_sram_ctrl_result_t dif_sram_ctrl_get_scrambling_status(
const dif_sram_ctrl_t *sram_ctrl,
dif_sram_ctrl_scrambling_status_t *status);
diff --git a/sw/device/lib/dif/dif_uart.h b/sw/device/lib/dif/dif_uart.h
index 38fcfbf..417e093 100644
--- a/sw/device/lib/dif/dif_uart.h
+++ b/sw/device/lib/dif/dif_uart.h
@@ -12,8 +12,8 @@
#include <stdint.h>
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -94,7 +94,9 @@
*
* This type should be treated as opaque by users.
*/
-typedef struct dif_uart { dif_uart_params_t params; } dif_uart_t;
+typedef struct dif_uart {
+ dif_uart_params_t params;
+} dif_uart_t;
/**
* The result of a UART operation.
@@ -264,7 +266,7 @@
* @param uart Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_init(dif_uart_params_t params, dif_uart_t *uart);
/**
@@ -276,7 +278,7 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_config_result_t dif_uart_configure(const dif_uart_t *uart,
dif_uart_config_t config);
@@ -288,7 +290,7 @@
* @param is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_is_pending(const dif_uart_t *uart,
dif_uart_irq_t irq, bool *is_pending);
@@ -300,7 +302,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_acknowledge(const dif_uart_t *uart,
dif_uart_irq_t irq);
@@ -312,7 +314,7 @@
* @param state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_get_enabled(const dif_uart_t *uart,
dif_uart_irq_t irq,
dif_uart_toggle_t *state);
@@ -325,7 +327,7 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_set_enabled(const dif_uart_t *uart,
dif_uart_irq_t irq,
dif_uart_toggle_t state);
@@ -338,7 +340,7 @@
* @param irq An interrupt type.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_force(const dif_uart_t *uart,
dif_uart_irq_t irq);
@@ -350,7 +352,7 @@
* @param snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_disable_all(const dif_uart_t *uart,
dif_uart_irq_snapshot_t *snapshot);
@@ -364,7 +366,7 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_irq_restore_all(
const dif_uart_t *uart, const dif_uart_irq_snapshot_t *snapshot);
@@ -379,7 +381,7 @@
* @param watermark RX FIFO watermark.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_watermark_rx_set(const dif_uart_t *uart,
dif_uart_watermark_t watermark);
@@ -394,7 +396,7 @@
* @param watermark TX FIFO watermark.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_watermark_tx_set(const dif_uart_t *uart,
dif_uart_watermark_t watermark);
@@ -414,7 +416,7 @@
* @param[out] bytes_written Number of bytes written (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_bytes_send(const dif_uart_t *uart,
const uint8_t *data,
size_t bytes_requested,
@@ -436,7 +438,7 @@
* @param[out] bytes_read Number of bytes read (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_bytes_receive(const dif_uart_t *uart,
size_t bytes_requested, uint8_t *data,
size_t *bytes_read);
@@ -452,7 +454,7 @@
* @param byte Byte to be transmitted.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_byte_send_polled(const dif_uart_t *uart,
uint8_t byte);
@@ -467,7 +469,7 @@
* @param[out] byte Received byte.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_byte_receive_polled(const dif_uart_t *uart,
uint8_t *byte);
@@ -480,7 +482,7 @@
* @param[out] num_bytes Number of bytes available to be read.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_rx_bytes_available(const dif_uart_t *uart,
size_t *num_bytes);
@@ -493,7 +495,7 @@
* @param[out] num_bytes Number of bytes available to be written.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_tx_bytes_available(const dif_uart_t *uart,
size_t *num_bytes);
/**
@@ -541,7 +543,7 @@
* clock as reference) in the range [0,0xffffff].
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_enable_rx_timeout(const dif_uart_t *uart,
uint32_t duration_ticks);
@@ -554,7 +556,7 @@
* @param uart A UART handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_disable_rx_timeout(const dif_uart_t *uart);
/**
@@ -567,7 +569,7 @@
* rate clock as reference) in the range [0,0xffffff] (optional).
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_uart_result_t dif_uart_get_rx_timeout(const dif_uart_t *uart,
dif_uart_toggle_t *status,
uint32_t *duration_ticks);
diff --git a/sw/device/lib/dif/dif_usbdev.c b/sw/device/lib/dif/dif_usbdev.c
index 694c5e9..4b48081 100644
--- a/sw/device/lib/dif/dif_usbdev.c
+++ b/sw/device/lib/dif/dif_usbdev.c
@@ -91,7 +91,7 @@
* @param pool A buffer pool.
* @return `true` if the buffer pool if full, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_is_full(dif_usbdev_buffer_pool_t *pool) {
return pool->top == BUFFER_POOL_FULL;
}
@@ -102,7 +102,7 @@
* @param pool A buffer pool.
* @return `true` if the buffer pool is empty, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_is_empty(dif_usbdev_buffer_pool_t *pool) {
return pool->top == BUFFER_POOL_EMPTY;
}
@@ -115,7 +115,7 @@
* @param buffer_id A buffer id.
* @return `true` if `buffer_id` is valid, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_is_valid_buffer_id(uint8_t buffer_id) {
return buffer_id < USBDEV_NUM_BUFFERS;
}
@@ -127,7 +127,7 @@
* @param buffer_id A buffer id.
* @return `true` if the operation was successful, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_add(dif_usbdev_buffer_pool_t *pool, uint8_t buffer_id) {
if (buffer_pool_is_full(pool) || !buffer_pool_is_valid_buffer_id(buffer_id)) {
return false;
@@ -146,7 +146,7 @@
* @param buffer_id A buffer id.
* @return `true` if the operation was successful, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_remove(dif_usbdev_buffer_pool_t *pool,
uint8_t *buffer_id) {
if (buffer_pool_is_empty(pool) || buffer_id == NULL) {
@@ -168,7 +168,7 @@
* @param pool A buffer pool.
* @return `true` if the operation was successful, `false` otherwise.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool buffer_pool_init(dif_usbdev_buffer_pool_t *pool) {
// Start with an empty pool
pool->top = -1;
@@ -190,7 +190,7 @@
/**
* Checks if the given value is a valid `dif_usbdev_toggle_t` variant.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_toggle(dif_usbdev_toggle_t val) {
return val == kDifUsbdevToggleEnable || val == kDifUsbdevToggleDisable;
}
@@ -199,7 +199,7 @@
* Checks if the given value is a valid `dif_usbdev_power_sense_override_t`
* variant.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_power_sense_override(
dif_usbdev_power_sense_override_t val) {
return val == kDifUsbdevPowerSenseOverrideDisabled ||
@@ -210,7 +210,7 @@
/**
* Checks if the given value is a valid endpoint number.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_endpoint(uint8_t endpoint) {
return endpoint < USBDEV_NUM_ENDPOINTS;
}
@@ -218,7 +218,7 @@
/**
* Checks if the given value is a valid `dif_usbdev_irq_t` variant.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static bool is_valid_irq(dif_usbdev_irq_t irq) {
return irq >= kDifUsbdevIrqFirst && irq <= kDifUsbdevIrqLast;
}
@@ -227,7 +227,7 @@
* Enables/disables the functionality controlled by the register at `reg_offset`
* for an endpoint.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static dif_usbdev_result_t endpoint_functionality_enable(
dif_usbdev_t *usbdev, uint32_t reg_offset, uint8_t endpoint,
dif_usbdev_toggle_t new_state) {
@@ -251,7 +251,7 @@
* Returns the address that corresponds to the given buffer and offset
* into that buffer.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
static uint32_t get_buffer_addr(uint8_t buffer_id, size_t offset) {
return USBDEV_BUFFER_REG_OFFSET +
(buffer_id * USBDEV_BUFFER_ENTRY_SIZE_BYTES) + offset;
diff --git a/sw/device/lib/dif/dif_usbdev.h b/sw/device/lib/dif/dif_usbdev.h
index d4e454d..f7b2929 100644
--- a/sw/device/lib/dif/dif_usbdev.h
+++ b/sw/device/lib/dif/dif_usbdev.h
@@ -12,8 +12,9 @@
#include <stddef.h>
#include <stdint.h>
+
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
#ifdef __cplusplus
extern "C" {
@@ -191,7 +192,7 @@
* @param[out] usbdev Internal state of the initialized USB device.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_init(dif_usbdev_config_t *config,
dif_usbdev_t *usbdev);
@@ -210,7 +211,7 @@
* @param usbdev A USB device.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_fill_available_fifo(dif_usbdev_t *usbdev);
/**
@@ -221,7 +222,7 @@
* @param new_state New SETUP packet reception state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_endpoint_setup_enable(
dif_usbdev_t *usbdev, uint8_t endpoint, dif_usbdev_toggle_t new_state);
@@ -233,7 +234,7 @@
* @param new_state New OUT packet reception state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_endpoint_out_enable(
dif_usbdev_t *usbdev, uint8_t endpoint, dif_usbdev_toggle_t new_state);
@@ -245,7 +246,7 @@
* @param new_state New STALL state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_endpoint_stall_enable(
dif_usbdev_t *usbdev, uint8_t endpoint, dif_usbdev_toggle_t new_state);
@@ -257,7 +258,7 @@
* @param[out] state Current STALL state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_endpoint_stall_get(dif_usbdev_t *usbdev,
uint8_t endpoint,
bool *state);
@@ -274,7 +275,7 @@
* @param new_state New isochronous state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_endpoint_iso_enable(
dif_usbdev_t *usbdev, uint8_t endpoint, dif_usbdev_toggle_t new_state);
@@ -288,7 +289,7 @@
* @param new_state New interface state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_interface_enable(dif_usbdev_t *usbdev,
dif_usbdev_toggle_t new_state);
@@ -367,7 +368,7 @@
* @param[out] buffer Buffer that holds the packet payload.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_recv_result_t dif_usbdev_recv(
dif_usbdev_t *usbdev, dif_usbdev_rx_packet_info_t *packet_info,
dif_usbdev_buffer_t *buffer);
@@ -416,7 +417,7 @@
* @param[out] bytes_written Number of bytes written to destination buffer.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_buffer_read_result_t dif_usbdev_buffer_read(
dif_usbdev_t *usbdev, dif_usbdev_buffer_t *buffer, uint8_t *dst,
size_t dst_len, size_t *bytes_written);
@@ -438,7 +439,7 @@
* `dif_usbdev_buffer_request`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_buffer_return(dif_usbdev_t *usbdev,
dif_usbdev_buffer_t *buffer);
@@ -499,7 +500,7 @@
* @param[out] buffer A buffer for writing outgoing packet payload.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_buffer_request_result_t dif_usbdev_buffer_request(
dif_usbdev_t *usbdev, dif_usbdev_buffer_t *buffer);
@@ -544,7 +545,7 @@
* @param[out] bytes_written Number of bytes written to the USB device buffer.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_buffer_write_result_t dif_usbdev_buffer_write(
dif_usbdev_t *usbdev, dif_usbdev_buffer_t *buffer, uint8_t *src,
size_t src_len, size_t *bytes_written);
@@ -577,7 +578,7 @@
* @param buffer A buffer provided by `dif_usbdev_buffer_request`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_send(dif_usbdev_t *usbdev, uint8_t endpoint,
dif_usbdev_buffer_t *buffer);
@@ -621,7 +622,7 @@
* @param[out] status Status of the packet.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_get_tx_status(dif_usbdev_t *usbdev,
uint8_t endpoint,
dif_usbdev_tx_status_t *status);
@@ -633,7 +634,7 @@
* @param addr New address. Only the last 7 bits are significant.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_address_set(dif_usbdev_t *usbdev, uint8_t addr);
/**
@@ -643,7 +644,7 @@
* @param[out] addr Current address.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_address_get(dif_usbdev_t *usbdev, uint8_t *addr);
/**
@@ -653,7 +654,7 @@
* @param[out] frame_index USB frame index.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_frame(dif_usbdev_t *usbdev,
uint16_t *frame_index);
@@ -668,7 +669,7 @@
* otherwise.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_host_lost(dif_usbdev_t *usbdev,
bool *host_lost);
@@ -690,7 +691,7 @@
* @param[out] link_state USB link state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_link_state(
dif_usbdev_t *usbdev, dif_usbdev_link_state_t *link_state);
@@ -702,7 +703,7 @@
* VBUS, `false` otherwise.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_sense(dif_usbdev_t *usbdev,
bool *sense);
@@ -715,7 +716,7 @@
* @param[out] depth Depth of the AV FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_available_fifo_depth(
dif_usbdev_t *usbdev, uint8_t *depth);
/**
@@ -727,7 +728,7 @@
* @param[out] is_full State of the AV FIFO. `true` if full, false otherwise.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_available_fifo_full(
dif_usbdev_t *usbdev, bool *is_full);
/**
@@ -739,7 +740,7 @@
* @param[out] depth Depth of the RX FIFO.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_rx_fifo_depth(dif_usbdev_t *usbdev,
uint8_t *depth);
@@ -753,7 +754,7 @@
* otherwise.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_status_get_rx_fifo_empty(dif_usbdev_t *usbdev,
bool *is_empty);
@@ -845,7 +846,7 @@
* @param state New state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_enable(dif_usbdev_t *usbdev,
dif_usbdev_irq_t irq,
dif_usbdev_toggle_t state);
@@ -858,7 +859,7 @@
* @param[out] state State of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_get(dif_usbdev_t *usbdev,
dif_usbdev_irq_t irq, bool *state);
@@ -869,7 +870,7 @@
* @param irq An interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_clear(dif_usbdev_t *usbdev,
dif_usbdev_irq_t irq);
@@ -879,7 +880,7 @@
* @param usbdev A USB device.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_clear_all(dif_usbdev_t *usbdev);
/**
@@ -890,7 +891,7 @@
* @param[out] cur_config Current interrupt configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_disable_all(dif_usbdev_t *usbdev,
uint32_t *cur_config);
@@ -901,7 +902,7 @@
* @param new_config New interrupt configuration.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_restore(dif_usbdev_t *usbdev,
uint32_t new_config);
@@ -912,7 +913,7 @@
* @param irq An interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
dif_usbdev_result_t dif_usbdev_irq_test(dif_usbdev_t *usbdev,
dif_usbdev_irq_t irq);
diff --git a/sw/device/lib/dif/dif_warn_unused_result.h b/sw/device/lib/dif/dif_warn_unused_result.h
deleted file mode 100644
index bf9725b..0000000
--- a/sw/device/lib/dif/dif_warn_unused_result.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright lowRISC contributors.
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
-
-#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_DIF_WARN_UNUSED_RESULT_H_
-#define OPENTITAN_SW_DEVICE_LIB_DIF_DIF_WARN_UNUSED_RESULT_H_
-
-/**
- * @file
- * @brief Unused Result Warning Macro for DIFs.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-/**
- * Attribute for functions which return errors that must be acknowledged.
- *
- * This attribute must be used to mark all DIFs which return an error value of
- * some kind, to ensure that callers do not accidentally drop the error on the
- * ground.
- *
- * Normally, the standard way to drop such a value on the ground explicitly is
- * with the syntax `(void)expr;`, in analogy with the behavior of C++'s
- * `[[nodiscard]]` attribute.
- * However, GCC does not implement this, so the idiom `if (expr) {}` should be
- * used instead, for the time being.
- * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509.
- */
-#define DIF_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-#endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_WARN_UNUSED_RESULT_H_
diff --git a/util/check_dif_statuses.py b/util/check_dif_statuses.py
index 7f7e32b..9f78a55 100644
--- a/util/check_dif_statuses.py
+++ b/util/check_dif_statuses.py
@@ -456,7 +456,7 @@
print("WARNING: It is recommended to pass the --top-hjson switch to "
"get a more accurate representation of the DIF progress. The "
"list of IPs for which no DIF sources exist is unknown.")
- shared_headers = ["dif_warn_unused_result"]
+ shared_headers = ["dif_base"]
top_level = "top_earlgrey"
difs = get_list_of_difs(difs_root_path, shared_headers)
diff --git a/util/make_new_dif/dif_autogen.c.tpl b/util/make_new_dif/dif_autogen.c.tpl
index c426364..448e7e9 100644
--- a/util/make_new_dif/dif_autogen.c.tpl
+++ b/util/make_new_dif/dif_autogen.c.tpl
@@ -53,135 +53,135 @@
return true;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_get_state(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_get_state(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_state_snapshot_t *snapshot) {
if (${ip.name_snake} == NULL || snapshot == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
*snapshot = ${mmio_region_read32("STATE")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_is_pending(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_is_pending(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
bool *is_pending) {
if (${ip.name_snake} == NULL || is_pending == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
bitfield_bit32_index_t index;
if (!${ip.name_snake}_get_irq_bit_index(irq, &index)) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
uint32_t intr_state_reg = ${mmio_region_read32("STATE")}
*is_pending = bitfield_bit32_read(intr_state_reg, index);
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_acknowledge(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_acknowledge(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq) {
if (${ip.name_snake} == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
bitfield_bit32_index_t index;
if (!${ip.name_snake}_get_irq_bit_index(irq, &index)) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
// Writing to the register clears the corresponding bits (Write-one clear).
uint32_t intr_state_reg = bitfield_bit32_write(0, index, true);
${mmio_region_write32("STATE", "intr_state_reg")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_get_enabled(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_get_enabled(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
- dif_${ip.name_snake}_toggle_t *state) {
+ dif_toggle_t *state) {
if (${ip.name_snake} == NULL || state == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
bitfield_bit32_index_t index;
if (!${ip.name_snake}_get_irq_bit_index(irq, &index)) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
uint32_t intr_enable_reg = ${mmio_region_read32("ENABLE")}
bool is_enabled = bitfield_bit32_read(intr_enable_reg, index);
*state = is_enabled ?
- kDif${ip.name_camel}ToggleEnabled : kDif${ip.name_camel}ToggleDisabled;
+ kDifToggleEnabled : kDifToggleDisabled;
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_set_enabled(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_set_enabled(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
- dif_${ip.name_snake}_toggle_t state) {
+ dif_toggle_t state) {
if (${ip.name_snake} == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
bitfield_bit32_index_t index;
if (!${ip.name_snake}_get_irq_bit_index(irq, &index)) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
uint32_t intr_enable_reg = ${mmio_region_read32("ENABLE")}
- bool enable_bit = (state == kDifUartToggleEnabled) ? true : false;
+ bool enable_bit = (state == kDifToggleEnabled) ? true : false;
intr_enable_reg = bitfield_bit32_write(intr_enable_reg, index, enable_bit);
${mmio_region_write32("ENABLE", "intr_enable_reg")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_force(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_force(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq) {
if (${ip.name_snake} == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
bitfield_bit32_index_t index;
if (!${ip.name_snake}_get_irq_bit_index(irq, &index)) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
uint32_t intr_test_reg = bitfield_bit32_write(0, index, true);
${mmio_region_write32("TEST", "intr_test_reg")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_disable_all(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_disable_all(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_enable_snapshot_t *snapshot) {
if (${ip.name_snake} == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
// Pass the current interrupt state to the caller, if requested.
@@ -192,19 +192,19 @@
// Disable all interrupts.
${mmio_region_write32("ENABLE", "0u")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_restore_all(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_restore_all(
const dif_${ip.name_snake}_t *${ip.name_snake},
const dif_${ip.name_snake}_irq_enable_snapshot_t *snapshot) {
if (${ip.name_snake} == NULL || snapshot == NULL) {
- return kDif${ip.name_camel}BadArg;
+ return kDifBadArg;
}
${mmio_region_write32("ENABLE", "*snapshot")}
- return kDif${ip.name_camel}Ok;
+ return kDifOk;
}
diff --git a/util/make_new_dif/dif_autogen.inc.tpl b/util/make_new_dif/dif_autogen.inc.tpl
index 628b614..f2be59e 100644
--- a/util/make_new_dif/dif_autogen.inc.tpl
+++ b/util/make_new_dif/dif_autogen.inc.tpl
@@ -31,9 +31,9 @@
#include <stdbool.h>
#include <stdint.h>
-#include "sw/device/lib/base/bitfield.h"
+#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
+#include "sw/device/lib/dif/dif_base.h"
#ifdef __cplusplus
extern "C" {
@@ -52,47 +52,6 @@
} dif_${ip.name_snake}_t;
/**
- * The result of a ${ip.name_long_lower} operation.
- *
- * NOTE: additional result values can be defined in the manually-implemented
- * header.
- */
-typedef enum dif_${ip.name_snake}_result {
- /**
- * Indicates that the operation succeeded.
- */
- kDif${ip.name_camel}Ok = 0,
- /**
- * Indicates some unspecified failure.
- */
- kDif${ip.name_camel}Error = 1,
- /**
- * Indicates that some parameter passed into a function failed a
- * precondition.
- *
- * When this value is returned, no hardware operations occurred.
- */
- kDif${ip.name_camel}BadArg = 2,
-} dif_${ip.name_snake}_result_t;
-
-/**
- * A toggle state: enabled, or disabled.
- *
- * This enum may be used instead of a `bool` when describing an enabled/disabled
- * state.
- */
-typedef enum dif_${ip.name_snake}_toggle {
- /**
- * The "enabled" state.
- */
- kDif${ip.name_camel}ToggleEnabled,
- /**
- * The "disabled" state.
- */
- kDif${ip.name_camel}ToggleDisabled,
-} dif_${ip.name_snake}_toggle_t;
-
-/**
* A ${ip.name_long_lower} interrupt request type.
*/
typedef enum dif_${ip.name_snake}_irq {
@@ -129,8 +88,8 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_get_state(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_get_state(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_state_snapshot_t *snapshot);
@@ -142,8 +101,8 @@
* @param[out] is_pending Out-param for whether the interrupt is pending.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_is_pending(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_is_pending(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
bool *is_pending);
@@ -156,8 +115,8 @@
* @param irq An interrupt request.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_acknowledge(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_acknowledge(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq);
@@ -169,11 +128,11 @@
* @param[out] state Out-param toggle state of the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_get_enabled(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_get_enabled(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
- dif_${ip.name_snake}_toggle_t *state);
+ dif_toggle_t *state);
/**
* Sets whether a particular interrupt is currently enabled or disabled.
@@ -183,11 +142,11 @@
* @param state The new toggle state for the interrupt.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_set_enabled(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_set_enabled(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq,
- dif_${ip.name_snake}_toggle_t state);
+ dif_toggle_t state);
/**
* Forces a particular interrupt, causing it to be serviced as if hardware had
@@ -197,8 +156,8 @@
* @param irq An interrupt request.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_force(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_force(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_t irq);
@@ -210,8 +169,8 @@
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_disable_all(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_disable_all(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_irq_enable_snapshot_t *snapshot);
@@ -222,8 +181,8 @@
* @param snapshot A snapshot to restore from.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_irq_restore_all(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_irq_restore_all(
const dif_${ip.name_snake}_t *${ip.name_snake},
const dif_${ip.name_snake}_irq_enable_snapshot_t *snapshot);
diff --git a/util/make_new_dif/dif_autogen_unittest.cc.tpl b/util/make_new_dif/dif_autogen_unittest.cc.tpl
index b1a3ec0..930a688 100644
--- a/util/make_new_dif/dif_autogen_unittest.cc.tpl
+++ b/util/make_new_dif/dif_autogen_unittest.cc.tpl
@@ -32,17 +32,17 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_get_state(
nullptr,
&irq_snapshot),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_get_state(
&${ip.name_snake}_,
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_get_state(
nullptr,
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqGetStateTest, SuccessAllRaised) {
@@ -53,7 +53,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_get_state(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_EQ(irq_snapshot, std::numeric_limits<uint32_t>::max());
}
@@ -64,7 +64,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_get_state(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_EQ(irq_snapshot, 0);
}
@@ -77,19 +77,19 @@
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
&is_pending),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_is_pending(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_is_pending(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqIsPendingTest, BadIrq) {
@@ -99,7 +99,7 @@
&${ip.name_snake}_,
(dif_${ip.name_snake}_irq_t)32,
&is_pending),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqIsPendingTest, Success) {
@@ -113,7 +113,7 @@
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
&irq_state),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_TRUE(irq_state);
// Get the last IRQ state.
@@ -124,7 +124,7 @@
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[-1].name_camel},
&irq_state),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_FALSE(irq_state);
}
@@ -134,14 +134,14 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_acknowledge(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel}),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqAcknowledgeTest, BadIrq) {
EXPECT_EQ(dif_${ip.name_snake}_irq_acknowledge(
nullptr,
(dif_${ip.name_snake}_irq_t)32),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqAcknowledgeTest, Success) {
@@ -151,7 +151,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_acknowledge(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel}),
- kDif${ip.name_camel}Ok);
+ kDifOk);
// Clear the last IRQ state.
EXPECT_WRITE32(${ip.name_upper}_INTR_STATE_REG_OFFSET,
@@ -159,96 +159,96 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_acknowledge(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[-1].name_camel}),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
class IrqGetEnabledTest : public ${ip.name_camel}Test {};
TEST_F(IrqGetEnabledTest, NullArgs) {
- dif_${ip.name_snake}_toggle_t irq_state;
+ dif_toggle_t irq_state;
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
&irq_state),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqGetEnabledTest, BadIrq) {
- dif_${ip.name_snake}_toggle_t irq_state;
+ dif_toggle_t irq_state;
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
&${ip.name_snake}_,
(dif_${ip.name_snake}_irq_t)32,
&irq_state),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqGetEnabledTest, Success) {
- dif_${ip.name_snake}_toggle_t irq_state;
+ dif_toggle_t irq_state;
// First IRQ is enabled.
- irq_state = kDif${ip.name_camel}ToggleDisabled;
+ irq_state = kDifToggleDisabled;
EXPECT_READ32(${ip.name_upper}_INTR_ENABLE_REG_OFFSET,
{{${ip.name_upper}_INTR_ENABLE_${irqs[0].name_upper}_BIT, true}});
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
&irq_state),
- kDif${ip.name_camel}Ok);
- EXPECT_EQ(irq_state, kDif${ip.name_camel}ToggleEnabled);
+ kDifOk);
+ EXPECT_EQ(irq_state, kDifToggleEnabled);
// Last IRQ is disabled.
- irq_state = kDif${ip.name_camel}ToggleEnabled;
+ irq_state = kDifToggleEnabled;
EXPECT_READ32(${ip.name_upper}_INTR_ENABLE_REG_OFFSET,
{{${ip.name_upper}_INTR_ENABLE_${irqs[-1].name_upper}_BIT, true}});
EXPECT_EQ(dif_${ip.name_snake}_irq_get_enabled(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
&irq_state),
- kDif${ip.name_camel}Ok);
- EXPECT_EQ(irq_state, kDif${ip.name_camel}ToggleDisabled);
+ kDifOk);
+ EXPECT_EQ(irq_state, kDifToggleDisabled);
}
class IrqSetEnabledTest : public ${ip.name_camel}Test {};
TEST_F(IrqSetEnabledTest, NullArgs) {
- dif_${ip.name_snake}_toggle_t irq_state = kDif${ip.name_camel}ToggleEnabled;
+ dif_toggle_t irq_state = kDifToggleEnabled;
EXPECT_EQ(dif_${ip.name_snake}_irq_set_enabled(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
irq_state),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqSetEnabledTest, BadIrq) {
- dif_${ip.name_snake}_toggle_t irq_state = kDif${ip.name_camel}ToggleEnabled;
+ dif_toggle_t irq_state = kDifToggleEnabled;
EXPECT_EQ(dif_${ip.name_snake}_irq_set_enabled(
&${ip.name_snake}_,
(dif_${ip.name_snake}_irq_t)32,
irq_state),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqSetEnabledTest, Success) {
- dif_${ip.name_snake}_toggle_t irq_state;
+ dif_toggle_t irq_state;
// Enable first IRQ.
- irq_state = kDif${ip.name_camel}ToggleEnabled;
+ irq_state = kDifToggleEnabled;
EXPECT_MASK32(${ip.name_upper}_INTR_ENABLE_REG_OFFSET,
{{${ip.name_upper}_INTR_ENABLE_${irqs[0].name_upper}_BIT,
0x1,
@@ -257,10 +257,10 @@
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel},
irq_state),
- kDif${ip.name_camel}Ok);
+ kDifOk);
// Disable last IRQ.
- irq_state = kDif${ip.name_camel}ToggleDisabled;
+ irq_state = kDifToggleDisabled;
EXPECT_MASK32(${ip.name_upper}_INTR_ENABLE_REG_OFFSET,
{{${ip.name_upper}_INTR_ENABLE_${irqs[-1].name_upper}_BIT,
0x1,
@@ -269,7 +269,7 @@
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[-1].name_camel},
irq_state),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
class IrqForceTest : public ${ip.name_camel}Test {};
@@ -278,14 +278,14 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_force(
nullptr,
kDif${ip.name_camel}Irq${irqs[0].name_camel}),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqForceTest, BadIrq) {
EXPECT_EQ(dif_${ip.name_snake}_irq_force(
nullptr,
(dif_${ip.name_snake}_irq_t)32),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqForceTest, Success) {
@@ -295,7 +295,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_force(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[0].name_camel}),
- kDif${ip.name_camel}Ok);
+ kDifOk);
// Force last IRQ.
EXPECT_WRITE32(${ip.name_upper}_INTR_TEST_REG_OFFSET,
@@ -303,7 +303,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_force(
&${ip.name_snake}_,
kDif${ip.name_camel}Irq${irqs[-1].name_camel}),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
class IrqDisableAllTest : public ${ip.name_camel}Test {};
@@ -314,12 +314,12 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_disable_all(
nullptr,
&irq_snapshot),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_disable_all(
nullptr,
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqDisableAllTest, SuccessNoSnapshot) {
@@ -327,7 +327,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_disable_all(
&${ip.name_snake}_,
nullptr),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
TEST_F(IrqDisableAllTest, SuccessSnapshotAllDisabled) {
@@ -338,7 +338,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_disable_all(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_EQ(irq_snapshot, 0);
}
@@ -351,7 +351,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_disable_all(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
EXPECT_EQ(irq_snapshot, std::numeric_limits<uint32_t>::max());
}
@@ -363,17 +363,17 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_restore_all(
nullptr,
&irq_snapshot),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_restore_all(
&${ip.name_snake}_,
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
EXPECT_EQ(dif_${ip.name_snake}_irq_restore_all(
nullptr,
nullptr),
- kDif${ip.name_camel}BadArg);
+ kDifBadArg);
}
TEST_F(IrqRestoreAllTest, SuccessAllEnabled) {
@@ -385,7 +385,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_restore_all(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
TEST_F(IrqRestoreAllTest, SuccessAllDisabled) {
@@ -395,7 +395,7 @@
EXPECT_EQ(dif_${ip.name_snake}_irq_restore_all(
&${ip.name_snake}_,
&irq_snapshot),
- kDif${ip.name_camel}Ok);
+ kDifOk);
}
} // namespace
diff --git a/util/make_new_dif/dif_template.h.tpl b/util/make_new_dif/dif_template.h.tpl
index 871dee9..3a1df83 100644
--- a/util/make_new_dif/dif_template.h.tpl
+++ b/util/make_new_dif/dif_template.h.tpl
@@ -36,8 +36,6 @@
#include <stdint.h>
-#include "sw/device/lib/dif/dif_warn_unused_result.h"
-
#include "sw/device/lib/dif/autogen/dif_${ip.name_snake}_autogen.inc"
#ifdef __cplusplus
@@ -69,18 +67,6 @@
// Fields, if necessary.
} dif_${ip.name_snake}_config_t;
-/**
- * Additional results of a ${ip.name_long_lower} operation.
- *
- * Note: base result values are defined in the fully autogenerated header, see
- * the util/make_new_dif/dif_autogen.h.tpl template, there fore these values
- * must start at 3.
- */
-typedef enum dif_${ip.name_snake}_result_ext {
- // Remove this variant if you don't need it.
- kDif${ip.name_camel}Locked = 3,
- // Additional variants if required..
-} dif_${ip.name_snake}_result_ext_t;
/**
* Parameters for a ${ip.name_long_lower} transaction.
@@ -105,7 +91,7 @@
* @param params Hardware instantiation parameters.
* @return The information required.
*/
-DIF_WARN_UNUSED_RESULT
+OT_WARN_UNUSED_RESULT
uint32_t dif_${ip.name_snake}_get_size(dif_${ip.name_snake}_params_t params);
/**
@@ -118,8 +104,8 @@
* @param[out] ${ip.name_snake} Out param for the initialized handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_init(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_init(
mmio_region_t base_addr,
dif_${ip.name_snake}_params_t params,
dif_${ip.name_snake}_t *${ip.name_snake});
@@ -134,8 +120,8 @@
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_configure(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_configure(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_config_t config);
@@ -149,8 +135,8 @@
* @param transaction Transaction configuration parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_start(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_start(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_transaction_t transaction);
@@ -160,8 +146,8 @@
* @param output Transaction output parameters.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_end(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_end(
const dif_${ip.name_snake}_t *${ip.name_snake},
dif_${ip.name_snake}_output_t output);
@@ -174,8 +160,8 @@
* @param ${ip.name_snake} A ${ip.name_long_lower} handle.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_lock(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_lock(
const dif_${ip.name_snake}_t *${ip.name_snake});
/**
@@ -185,8 +171,8 @@
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
-DIF_WARN_UNUSED_RESULT
-dif_${ip.name_snake}_result_t dif_${ip.name_snake}_is_locked(
+OT_WARN_UNUSED_RESULT
+dif_result_t dif_${ip.name_snake}_is_locked(
const dif_${ip.name_snake}_t *${ip.name_snake},
bool *is_locked);