Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_DIF_ALERT_HANDLER_H_ |
| 6 | #define OPENTITAN_SW_DEVICE_LIB_DIF_DIF_ALERT_HANDLER_H_ |
| 7 | |
| 8 | /** |
| 9 | * @file |
| 10 | * @brief <a href="/hw/ip/alert_handler/doc/">Alert handler</a> Device Interface |
| 11 | * Functions |
| 12 | */ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 16 | #include "sw/device/lib/base/macros.h" |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 17 | #include "sw/device/lib/base/mmio.h" |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 18 | #include "sw/device/lib/dif/dif_base.h" |
| 19 | |
| 20 | #include "sw/device/lib/dif/autogen/dif_alert_handler_autogen.h" |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 21 | |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif // __cplusplus |
| 25 | |
| 26 | /** |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 27 | * Helper X macro for defining enums and case statements related to alert |
| 28 | * classes. If an additional class is ever added to the hardware, this list can |
| 29 | * be updated. |
| 30 | */ |
| 31 | #define LIST_OF_CLASSES(X) \ |
| 32 | X(A, 0) \ |
| 33 | X(B, 1) \ |
| 34 | X(C, 2) \ |
| 35 | X(D, 3) |
| 36 | |
| 37 | /** |
| 38 | * Helper macro for defining a `dif_alert_handler_class_t` enumeration constant. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 39 | * @class_ Alert class of the enumeration constant. |
| 40 | * @value_ Value of the enumeration constant. |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 41 | */ |
| 42 | #define ALERT_CLASS_ENUM_INIT_(class_, value_) \ |
| 43 | kDifAlertHandlerClass##class_ = value_, |
| 44 | |
| 45 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 46 | * An alert class. |
| 47 | * |
| 48 | * An alert class roughly specifies how to deal with an alert. The class |
| 49 | * determines which interrupt handler is fired for an alert, as well as the |
| 50 | * fine-grained details of the escalation policy, for when the processor |
| 51 | * fails to respond to an alert quickly enough. |
| 52 | * |
| 53 | * Alert classes serve as the alert handler's IRQ types. There is one IRQ for |
| 54 | * each class. Whenever an alert fires, the corresponding class's IRQ is |
| 55 | * serviced by the processor (if enabled). |
| 56 | */ |
| 57 | typedef enum dif_alert_handler_class { |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 58 | LIST_OF_CLASSES(ALERT_CLASS_ENUM_INIT_) |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 59 | } dif_alert_handler_class_t; |
| 60 | |
| 61 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 62 | * An alert, identified by a numeric id. |
| 63 | * |
| 64 | * Alerts are hardware-level events indicating that something catastrophic |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 65 | * has happened. The alert handler consumes alerts, classifies them into a |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 66 | * particular `dif_alert_handler_class_t`, and uses policy information attached |
| 67 | * to that class to handle it. |
| 68 | * |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 69 | * The number of alerts is configurable at hardware-synthesis time. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 70 | */ |
| 71 | typedef uint32_t dif_alert_handler_alert_t; |
| 72 | |
| 73 | /** |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 74 | * Helper X macro for defining enums and case statements related to local |
| 75 | * alerts. If an additional class is ever added to the hardware, this list can |
| 76 | * be updated. |
| 77 | */ |
| 78 | #define LIST_OF_LOC_ALERTS(X) \ |
| 79 | X(kDifAlertHandlerLocalAlertAlertPingFail, 0) \ |
| 80 | X(kDifAlertHandlerLocalAlertEscalationPingFail, 1) \ |
| 81 | X(kDifAlertHandlerLocalAlertAlertIntegrityFail, 2) \ |
| 82 | X(kDifAlertHandlerLocalAlertEscalationIntegrityFail, 3) \ |
| 83 | X(kDifAlertHandlerLocalAlertBusIntegrityFail, 4) \ |
| 84 | X(kDifAlertHandlerLocalAlertShadowedUpdateError, 5) \ |
| 85 | X(kDifAlertHandlerLocalAlertShadowedStorageError, 6) |
| 86 | |
| 87 | /** |
| 88 | * Helper macro for defining a `dif_alert_handler_local_alert_t` enumeration |
| 89 | * constant. |
| 90 | * @name_ Name of the enumeration constant. |
| 91 | */ |
| 92 | #define LOC_ALERT_ENUM_INIT_(name_, value_) name_ = value_, |
| 93 | |
| 94 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 95 | * A local alert originating from within the alert handler itself. |
| 96 | * |
| 97 | * A local alert is exactly the same as a normal `dif_alert_handler_alert_t`, |
| 98 | * except that they use different functions for setting up classification and |
| 99 | * for getting causes. |
| 100 | */ |
| 101 | typedef enum dif_alert_handler_local_alert { |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 102 | LIST_OF_LOC_ALERTS(LOC_ALERT_ENUM_INIT_) |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 103 | } dif_alert_handler_local_alert_t; |
| 104 | |
| 105 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 106 | * An alert class state. |
| 107 | * |
| 108 | * This enum describes the sequence of states in the *escalation protocol*, |
| 109 | * which triggers under two different conditions: |
Timothy Trippel | 3d578e5 | 2021-08-05 00:37:34 +0000 | [diff] [blame] | 110 | * - If too many alerts of a particular class accumulate. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 111 | * - If the software IRQ handler for that class times out. |
| 112 | * |
| 113 | * When either of these conditions is reached, phase 0 begins. This may trigger |
| 114 | * an escalation signal, and after a configured duration, proceed to phase 1. |
| 115 | * This process repeats until phase 3 ends, at which point the class enters a |
| 116 | * "bricked" terminal state, which cannot be exited except by reset. |
| 117 | * |
| 118 | * At any point, software may end the escalation protocol by calling |
| 119 | * `dif_alert_handler_escalation_clear()` (unless clearing is disabled). |
| 120 | * Successfully calling this function, or clearing the IRQ on time, will reset |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 121 | * the state back to idle. Note that this function cannot clear the terminal |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 122 | * state; that state can only be cleared by resetting the chip. |
| 123 | */ |
| 124 | typedef enum dif_alert_handler_class_state { |
| 125 | /** |
| 126 | * The initial, idle state. |
| 127 | */ |
| 128 | kDifAlertHandlerClassStateIdle, |
| 129 | /** |
| 130 | * The "timeout" state, that is, the IRQ has been fired and the clock is |
| 131 | * ticking for the processor to handle the alert. |
| 132 | */ |
| 133 | kDifAlertHandlerClassStateTimeout, |
| 134 | |
| 135 | /** |
| 136 | * The zeroth escalation phase. |
| 137 | */ |
| 138 | kDifAlertHandlerClassStatePhase0, |
| 139 | /** |
| 140 | * The first escalation phase. |
| 141 | */ |
| 142 | kDifAlertHandlerClassStatePhase1, |
| 143 | /** |
| 144 | * The second escalation phase. |
| 145 | */ |
| 146 | kDifAlertHandlerClassStatePhase2, |
| 147 | /** |
| 148 | * The third escalation phase. |
| 149 | */ |
| 150 | kDifAlertHandlerClassStatePhase3, |
| 151 | |
| 152 | /** |
| 153 | * The terminal state. Most configurations will never reach this state, since |
| 154 | * one of the previous phases will use an escalation signal to reset the |
| 155 | * device. |
| 156 | */ |
| 157 | kDifAlertHandlerClassStateTerminal, |
| 158 | } dif_alert_handler_class_state_t; |
| 159 | |
| 160 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 161 | * An escalation signal, identified by a numeric ID. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 162 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 163 | * An escalation signal is a generic "response" to failing to handle alert(s). |
| 164 | * The meaning of each escalation signal is determined by the chip. |
| 165 | * |
| 166 | * An alert class can be configured to raise various escalation signal(s) during |
| 167 | * various escalation phases as part of its escalation policy. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 168 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 169 | typedef uint32_t dif_alert_handler_escalation_signal_t; |
| 170 | |
| 171 | /** |
| 172 | * Runtime configuration for an escalation phase. |
| 173 | */ |
| 174 | typedef struct dif_alert_handler_escalation_phase { |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 175 | /** |
| 176 | * The phase this configuration describes. |
| 177 | * |
| 178 | * It is an error for this to not be one of the `Phase` constants in |
| 179 | * `dif_alert_handler_class_state_t`. |
| 180 | */ |
| 181 | dif_alert_handler_class_state_t phase; |
| 182 | /** |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 183 | * The escalation signal that should be triggered when this phase begins. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 184 | */ |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 185 | dif_alert_handler_escalation_signal_t signal; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 186 | /** |
| 187 | * The duration of this phase, in cycles. |
| 188 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 189 | uint32_t duration_cycles; |
| 190 | } dif_alert_handler_escalation_phase_t; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * Runtime configuration for a particular alert class. |
| 194 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 195 | * This struct describes the escalation protocol for an alert class. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 196 | */ |
| 197 | typedef struct dif_alert_handler_class_config { |
| 198 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 199 | * Whether to automatically lock the accumulation counter. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 200 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 201 | * There are two ways to lock the accumulation counter (prevent it from being |
| 202 | * cleared once the class's escalation protocol has been triggered): |
| 203 | * 1. clear the write enable for the accumulation counter clear register, or |
| 204 | * 2. to set this configuration flag which will automatically clear the |
| 205 | * write enable for the accumulation counter clear register once the |
| 206 | * class's escalation protocol has been triggered. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 207 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 208 | dif_toggle_t auto_lock_accumulation_counter; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 209 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 210 | * The threshold for the class accmulator which indicates the number of alerts |
| 211 | * that must fire because the class's escalation protocol will trigger. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 212 | */ |
| 213 | uint16_t accumulator_threshold; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 214 | /** |
| 215 | * The number of cycles this class's associated IRQ handler has to acknowledge |
| 216 | * the IRQ before escalation is triggered. |
| 217 | * |
| 218 | * A value of zero disables the timeout. |
| 219 | */ |
| 220 | uint32_t irq_deadline_cycles; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 221 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 222 | * Escalation phases to be configured for this class. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 223 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 224 | * Each escalation phase in this list will additionally be set as enabled for |
| 225 | * this class; phases not listed will have their escalation signals disabled. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 226 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 227 | const dif_alert_handler_escalation_phase_t *escalation_phases; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 228 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 229 | * The length of the array `escalation_phases`. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 230 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 231 | size_t escalation_phases_len; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 232 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 233 | * The escalation phase to capture the crashdump information in. |
| 234 | * |
| 235 | * It is an error for this to not be one of the `Phase` constants in |
| 236 | * `dif_alert_handler_class_state_t`. |
| 237 | * |
| 238 | * Note, it is recommended to capture the crashdump upon entering the first |
| 239 | * escalation phase that activates a countermeasure with many side-effects |
| 240 | * (e.g. life cycle state scrapping) in order to prevent spurious alert events |
| 241 | * from masking the original alert causes. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 242 | */ |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 243 | dif_alert_handler_class_state_t crashdump_escalation_phase; |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 244 | } dif_alert_handler_class_config_t; |
| 245 | |
| 246 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 247 | * Runtime configuration for the alert handler. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 248 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 249 | * This struct describes runtime information for a single-shot configuration of |
| 250 | * the alert handler hardware. |
| 251 | * |
| 252 | * Note, any of the array pointers may be NULL, in which case the associated |
| 253 | * length should be 0. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 254 | */ |
| 255 | typedef struct dif_alert_handler_config { |
| 256 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 257 | * A list of alerts to configure. |
| 258 | */ |
| 259 | dif_alert_handler_alert_t *alerts; |
| 260 | /** |
| 261 | * A list of classes to assign each alert to. |
| 262 | */ |
| 263 | dif_alert_handler_class_t *alert_classes; |
| 264 | /** |
| 265 | * The lengths of the arrays `alerts` and `alert_classes`. |
| 266 | */ |
| 267 | size_t alerts_len; |
| 268 | |
| 269 | /** |
| 270 | * A list of local alerts to configure. |
| 271 | */ |
| 272 | dif_alert_handler_local_alert_t *local_alerts; |
| 273 | /** |
| 274 | * A list of classes to assign each local alert to. |
| 275 | */ |
| 276 | dif_alert_handler_class_t *local_alert_classes; |
| 277 | /** |
| 278 | * The lengths of the arrays `local_alerts` and `local_alert_classes`. |
| 279 | */ |
| 280 | size_t local_alerts_len; |
| 281 | |
| 282 | /** |
| 283 | * A list of alert classes to configure. |
| 284 | */ |
| 285 | const dif_alert_handler_class_t *classes; |
| 286 | /** |
| 287 | * A list of alert class (escalation protocol) configurations. |
| 288 | */ |
| 289 | const dif_alert_handler_class_config_t *class_configs; |
| 290 | /** |
| 291 | * The length of the arrays `classes` and `class_configs`. |
| 292 | */ |
| 293 | size_t classes_len; |
| 294 | |
| 295 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 296 | * The alert ping timeout, in cycles. |
| 297 | * |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 298 | * The alert handler will regularly, at random intervals, ping alert |
| 299 | * sources. If a source fails to respond, a local alert will be raised. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 300 | * |
| 301 | * The appropriate value will be dependent on all of the clocks involved on |
| 302 | * a chip. |
| 303 | * |
| 304 | * Note that the ping timer won't start until `dif_alert_handler_lock()` is |
| 305 | * successfully called. |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 306 | * |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 307 | * Note while this value must fit into the timeout register which is smaller |
| 308 | * than the native word length. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 309 | */ |
| 310 | uint32_t ping_timeout; |
| 311 | |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 312 | } dif_alert_handler_config_t; |
| 313 | |
| 314 | /** |
Timothy Trippel | 33e0d1e | 2022-01-07 13:56:41 -0800 | [diff] [blame] | 315 | * Configures an alert in the alert handler. |
| 316 | * |
Timothy Trippel | fc96427 | 2022-01-10 19:03:20 -0800 | [diff] [blame] | 317 | * This operation is lock-protected, meaning once the configuration is locked, |
| 318 | * it cannot be reconfigured until after a system reset. |
Timothy Trippel | 33e0d1e | 2022-01-07 13:56:41 -0800 | [diff] [blame] | 319 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 320 | * @param alert_handler An alert handler handle. |
Timothy Trippel | 33e0d1e | 2022-01-07 13:56:41 -0800 | [diff] [blame] | 321 | * @param alert The alert to be configured. |
| 322 | * @param alert_class The class to assign the alert to. |
| 323 | * @param enabled The enablement state to configure the alert in. |
| 324 | * @param locked The locked state to configure the alert in. |
| 325 | * @return The result of the operation. |
| 326 | */ |
| 327 | OT_WARN_UNUSED_RESULT |
| 328 | dif_result_t dif_alert_handler_configure_alert( |
| 329 | const dif_alert_handler_t *alert_handler, dif_alert_handler_alert_t alert, |
| 330 | dif_alert_handler_class_t alert_class, dif_toggle_t enabled, |
| 331 | dif_toggle_t locked); |
| 332 | |
| 333 | /** |
Timothy Trippel | fc96427 | 2022-01-10 19:03:20 -0800 | [diff] [blame] | 334 | * Configures a local alert in the alert handler. |
| 335 | * |
| 336 | * This operation is lock-protected, meaning once the configuration is locked, |
| 337 | * it cannot be reconfigured until after a system reset. |
| 338 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 339 | * @param alert_handler An alert handler handle. |
Timothy Trippel | fc96427 | 2022-01-10 19:03:20 -0800 | [diff] [blame] | 340 | * @param local_alert The local alert to be configured. |
| 341 | * @param alert_class The class to assign the alert to. |
| 342 | * @param enabled The enablement state to configure the alert in. |
| 343 | * @param locked The locked state to configure the alert in. |
| 344 | * @return The result of the operation. |
| 345 | */ |
| 346 | OT_WARN_UNUSED_RESULT |
| 347 | dif_result_t dif_alert_handler_configure_local_alert( |
| 348 | const dif_alert_handler_t *alert_handler, |
| 349 | dif_alert_handler_local_alert_t local_alert, |
| 350 | dif_alert_handler_class_t alert_class, dif_toggle_t enabled, |
| 351 | dif_toggle_t locked); |
| 352 | |
| 353 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 354 | * Configures the escalation protocol of an alert class in the alert handler. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 355 | * |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 356 | * This operation is lock-protected, meaning once the configuration is locked, |
| 357 | * it cannot be reconfigured until after a system reset. |
| 358 | * |
| 359 | * Note, regardless if the class is enabled or, IRQs will still fire based on |
| 360 | * the accumulation counter threshold configuration for the class, however, the |
| 361 | * escalation protocol will not trigger. |
| 362 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 363 | * @param alert_handler An alert handler handle. |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 364 | * @param alert_class The class to be configured. |
| 365 | * @param config The escalation protocol configuration. |
| 366 | * @param enabled The enablement state of the class escalation protocol. |
| 367 | * @param locked The locked state to configure the class in. |
Timothy Trippel | 95be8e6 | 2022-01-14 18:11:43 -0800 | [diff] [blame] | 368 | * @return The result of the operation. |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 369 | */ |
Timothy Trippel | 87a1451 | 2022-02-10 17:03:18 -0800 | [diff] [blame] | 370 | OT_WARN_UNUSED_RESULT |
| 371 | dif_result_t dif_alert_handler_configure_class( |
| 372 | const dif_alert_handler_t *alert_handler, |
| 373 | dif_alert_handler_class_t alert_class, |
| 374 | dif_alert_handler_class_config_t config, dif_toggle_t enabled, |
| 375 | dif_toggle_t locked); |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 376 | |
| 377 | /** |
Timothy Trippel | fe8409a | 2022-01-13 17:22:07 -0800 | [diff] [blame] | 378 | * Configures the ping timer in the alert handler. |
| 379 | * |
| 380 | * This operation is lock-protected, meaning once the configuration is locked, |
| 381 | * it cannot be reconfigured until after a system reset. |
| 382 | * |
| 383 | * Note, the ping timer will only ping alerts that have been enabled AND locked. |
| 384 | * Therefore, this DIF should be invoked after configuring and enabling each |
| 385 | * (local) alert. |
| 386 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 387 | * @param alert_handler An alert handler handle. |
Timothy Trippel | fe8409a | 2022-01-13 17:22:07 -0800 | [diff] [blame] | 388 | * @param ping_timeout The alert ping timeout, in cycles. |
| 389 | * @param enabled The enablement state to configure the ping timer in. |
| 390 | * @param locked The locked state to configure ping timer in. |
Timothy Trippel | cc147fa | 2022-01-13 17:41:23 -0800 | [diff] [blame] | 391 | * @return The result of the operation. |
Timothy Trippel | fe8409a | 2022-01-13 17:22:07 -0800 | [diff] [blame] | 392 | */ |
Miguel Young de la Sota | 82ff7f6 | 2022-03-03 10:54:56 -0500 | [diff] [blame^] | 393 | OT_WARN_UNUSED_RESULT |
| 394 | dif_result_t dif_alert_handler_configure_ping_timer( |
Timothy Trippel | fe8409a | 2022-01-13 17:22:07 -0800 | [diff] [blame] | 395 | const dif_alert_handler_t *alert_handler, uint32_t ping_timeout, |
| 396 | dif_toggle_t enabled, dif_toggle_t locked); |
| 397 | |
| 398 | /** |
Timothy Trippel | cc147fa | 2022-01-13 17:41:23 -0800 | [diff] [blame] | 399 | * Enables the ping timer in the alert handler. |
| 400 | * |
| 401 | * This operation is lock-protected, meaning once the configuration is locked, |
| 402 | * it cannot be reconfigured until after a system reset. |
| 403 | * |
| 404 | * Note, the ping timer will only ping alerts that have been enabled AND locked. |
| 405 | * Therefore, this DIF should be invoked after configuring and enabling each |
| 406 | * (local) alert. |
| 407 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 408 | * @param alert_handler An alert handler handle. |
Timothy Trippel | cc147fa | 2022-01-13 17:41:23 -0800 | [diff] [blame] | 409 | * @param locked The locked state to configure ping timer in after enabling it. |
| 410 | * @return The result of the operation. |
| 411 | */ |
Miguel Young de la Sota | 82ff7f6 | 2022-03-03 10:54:56 -0500 | [diff] [blame^] | 412 | OT_WARN_UNUSED_RESULT |
| 413 | dif_result_t dif_alert_handler_ping_timer_set_enabled( |
Timothy Trippel | cc147fa | 2022-01-13 17:41:23 -0800 | [diff] [blame] | 414 | const dif_alert_handler_t *alert_handler, dif_toggle_t locked); |
| 415 | |
| 416 | /** |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 417 | * Locks out an alert handler alert configuration. |
Timothy Trippel | 3dacc6f | 2022-01-19 13:39:10 -0800 | [diff] [blame] | 418 | * |
| 419 | * This operation cannot be undone, and should be performed at the end of |
| 420 | * configuring the alert handler in early boot. |
| 421 | * |
| 422 | * This function is reentrant: calling it while functionality is locked will |
| 423 | * have no effect and return `kDifOk`. |
| 424 | * |
| 425 | * @param alert_handler An alert handler handle. |
| 426 | * @param alert The alert to lock. |
| 427 | * @return The result of the operation. |
| 428 | */ |
| 429 | OT_WARN_UNUSED_RESULT |
| 430 | dif_result_t dif_alert_handler_lock_alert( |
| 431 | const dif_alert_handler_t *alert_handler, dif_alert_handler_alert_t alert); |
| 432 | |
| 433 | /** |
| 434 | * Checks whether an alert handler's alert is locked. |
| 435 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 436 | * @param alert_handler An alert handler handle. |
Timothy Trippel | 3dacc6f | 2022-01-19 13:39:10 -0800 | [diff] [blame] | 437 | * @param alert The alert to check is locked. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 438 | * @param[out] is_locked Out-param for the locked state. |
Timothy Trippel | 3dacc6f | 2022-01-19 13:39:10 -0800 | [diff] [blame] | 439 | * @return The result of the operation. |
| 440 | */ |
| 441 | OT_WARN_UNUSED_RESULT |
| 442 | dif_result_t dif_alert_handler_is_alert_locked( |
| 443 | const dif_alert_handler_t *alert_handler, dif_alert_handler_alert_t alert, |
| 444 | bool *is_locked); |
| 445 | |
| 446 | /** |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 447 | * Locks out an alert handler local alert configuration. |
| 448 | * |
| 449 | * This operation cannot be undone, and should be performed at the end of |
| 450 | * configuring the alert handler in early boot. |
| 451 | * |
| 452 | * This function is reentrant: calling it while functionality is locked will |
| 453 | * have no effect and return `kDifOk`. |
| 454 | * |
| 455 | * @param alert_handler An alert handler handle. |
| 456 | * @param local_alert The local alert to lock. |
| 457 | * @return The result of the operation. |
| 458 | */ |
| 459 | OT_WARN_UNUSED_RESULT |
| 460 | dif_result_t dif_alert_handler_lock_local_alert( |
| 461 | const dif_alert_handler_t *alert_handler, |
| 462 | dif_alert_handler_local_alert_t local_alert); |
| 463 | |
| 464 | /** |
| 465 | * Checks whether an alert handler's local alert is locked. |
| 466 | * |
| 467 | * @param alert_handler An alert handler handle. |
| 468 | * @param local_alert The local alert to check is locked. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 469 | * @param[out] is_locked Out-param for the locked state. |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 470 | * @return The result of the operation. |
| 471 | */ |
| 472 | OT_WARN_UNUSED_RESULT |
| 473 | dif_result_t dif_alert_handler_is_local_alert_locked( |
| 474 | const dif_alert_handler_t *alert_handler, |
| 475 | dif_alert_handler_local_alert_t local_alert, bool *is_locked); |
| 476 | |
| 477 | /** |
Timothy Trippel | c137676 | 2022-01-19 15:51:08 -0800 | [diff] [blame] | 478 | * Locks out an alert handler class configuration. |
| 479 | * |
| 480 | * This operation cannot be undone, and should be performed at the end of |
| 481 | * configuring the alert handler in early boot. |
| 482 | * |
| 483 | * This function is reentrant: calling it while functionality is locked will |
| 484 | * have no effect and return `kDifOk`. |
| 485 | * |
| 486 | * @param alert_handler An alert handler handle. |
| 487 | * @param alert_class The alert class to lock. |
| 488 | * @return The result of the operation. |
| 489 | */ |
| 490 | OT_WARN_UNUSED_RESULT |
| 491 | dif_result_t dif_alert_handler_lock_class( |
| 492 | const dif_alert_handler_t *alert_handler, |
| 493 | dif_alert_handler_class_t alert_class); |
| 494 | |
| 495 | /** |
| 496 | * Checks whether an alert handler's class is locked. |
| 497 | * |
| 498 | * @param alert_handler An alert handler handle. |
| 499 | * @param alert_class The alert class to check is locked. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 500 | * @param[out] is_locked Out-param for the locked state. |
Timothy Trippel | c137676 | 2022-01-19 15:51:08 -0800 | [diff] [blame] | 501 | * @return The result of the operation. |
| 502 | */ |
| 503 | OT_WARN_UNUSED_RESULT |
| 504 | dif_result_t dif_alert_handler_is_class_locked( |
| 505 | const dif_alert_handler_t *alert_handler, |
| 506 | dif_alert_handler_class_t alert_class, bool *is_locked); |
| 507 | |
| 508 | /** |
Timothy Trippel | eb0ca16 | 2022-01-12 16:06:10 -0800 | [diff] [blame] | 509 | * Locks out alert handler ping timer configuration. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 510 | * |
| 511 | * This operation cannot be undone, and should be performed at the end of |
| 512 | * configuring the alert handler in early boot. |
| 513 | * |
| 514 | * This function is reentrant: calling it while functionality is locked will |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 515 | * have no effect and return `kDifOk`. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 516 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 517 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 518 | * @return The result of the operation. |
| 519 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 520 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 521 | dif_result_t dif_alert_handler_lock_ping_timer( |
| 522 | const dif_alert_handler_t *alert_handler); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 523 | |
| 524 | /** |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 525 | * Checks whether alert handler's ping timer is locked. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 526 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 527 | * @param alert_handler An alert handler handle. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 528 | * @param[out] is_locked Out-param for the locked state. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 529 | * @return The result of the operation. |
| 530 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 531 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 26f7088 | 2022-01-06 15:10:41 -0800 | [diff] [blame] | 532 | dif_result_t dif_alert_handler_is_ping_timer_locked( |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 533 | const dif_alert_handler_t *alert_handler, bool *is_locked); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 534 | |
| 535 | /** |
| 536 | * Checks whether an alert is one of the causes for an alert IRQ. |
| 537 | * |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 538 | * Note that multiple alerts may be causes at the same time. |
| 539 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 540 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 541 | * @param alert The alert to check. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 542 | * @param[out] is_cause Out-param for whether this alert is a cause. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 543 | * @return The result of the operation. |
| 544 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 545 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 546 | dif_result_t dif_alert_handler_alert_is_cause( |
Timothy Trippel | 936db9a | 2021-10-13 19:55:11 +0000 | [diff] [blame] | 547 | const dif_alert_handler_t *alert_handler, dif_alert_handler_alert_t alert, |
| 548 | bool *is_cause); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 549 | |
| 550 | /** |
| 551 | * Clears an alert from the cause vector, similar to an IRQ acknowledgement. |
| 552 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 553 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 554 | * @param alert The alert to acknowledge. |
| 555 | * @return The result of the operation. |
| 556 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 557 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 558 | dif_result_t dif_alert_handler_alert_acknowledge( |
Timothy Trippel | 936db9a | 2021-10-13 19:55:11 +0000 | [diff] [blame] | 559 | const dif_alert_handler_t *alert_handler, dif_alert_handler_alert_t alert); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 560 | |
| 561 | /** |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 562 | * Checks whether a local alert is one of the causes for an alert IRQ. |
| 563 | * |
| 564 | * Note that multiple alerts may be causes at the same time. |
| 565 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 566 | * @param alert_handler An alert handler handle. |
Timothy Trippel | acd00c7 | 2022-01-24 16:59:49 -0800 | [diff] [blame] | 567 | * @param local_alert The local alert to check. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 568 | * @param[out] is_cause Out-param for whether this alert is a cause. |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 569 | * @return The result of the operation. |
| 570 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 571 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 572 | dif_result_t dif_alert_handler_local_alert_is_cause( |
| 573 | const dif_alert_handler_t *alert_handler, |
Timothy Trippel | acd00c7 | 2022-01-24 16:59:49 -0800 | [diff] [blame] | 574 | dif_alert_handler_local_alert_t local_alert, bool *is_cause); |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 575 | |
| 576 | /** |
| 577 | * Clears a local alert from the cause vector, similar to an IRQ |
| 578 | * acknowledgement. |
| 579 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 580 | * @param alert_handler An alert handler handle. |
Timothy Trippel | acd00c7 | 2022-01-24 16:59:49 -0800 | [diff] [blame] | 581 | * @param local_alert The local alert to acknowledge. |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 582 | * @return The result of the operation. |
| 583 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 584 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 585 | dif_result_t dif_alert_handler_local_alert_acknowledge( |
| 586 | const dif_alert_handler_t *alert_handler, |
Timothy Trippel | acd00c7 | 2022-01-24 16:59:49 -0800 | [diff] [blame] | 587 | dif_alert_handler_local_alert_t local_alert); |
Miguel Young de la Sota | dd71d98 | 2020-09-17 15:40:16 -0400 | [diff] [blame] | 588 | |
| 589 | /** |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 590 | * Checks whether software can clear escalations for this class. |
| 591 | * |
| 592 | * If `automatic_locking` has been set in a class's configuration, this |
| 593 | * function may suddenly begin returning `false` instead of `true` without |
| 594 | * software invervention, if escalation has been triggered. |
| 595 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 596 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 597 | * @param alert_class The class to check. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 598 | * @param[out] can_clear Out-param for the clear enablement state. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 599 | * @return The result of the operation. |
| 600 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 601 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 602 | dif_result_t dif_alert_handler_escalation_can_clear( |
| 603 | const dif_alert_handler_t *alert_handler, |
| 604 | dif_alert_handler_class_t alert_class, bool *can_clear); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 605 | |
| 606 | /** |
| 607 | * Disables escalation clearing for this class. |
| 608 | * |
| 609 | * This operation is similar to locking in that it cannot be undone. |
| 610 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 611 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 612 | * @param alert_class The class to disable clearing for. |
| 613 | * @return The result of the operation. |
| 614 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 615 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 616 | dif_result_t dif_alert_handler_escalation_disable_clearing( |
| 617 | const dif_alert_handler_t *alert_handler, |
| 618 | dif_alert_handler_class_t alert_class); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 619 | |
| 620 | /** |
| 621 | * Clears an on-going escalation, as well as the class accumulator. |
| 622 | * |
| 623 | * This operation can be disabled with |
| 624 | * `dif_alert_handler_escalation_disable_clearing()`. |
| 625 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 626 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 627 | * @param alert_class The class to clear an escalation for. |
| 628 | * @return The result of the operation. |
| 629 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 630 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 631 | dif_result_t dif_alert_handler_escalation_clear( |
| 632 | const dif_alert_handler_t *alert_handler, |
| 633 | dif_alert_handler_class_t alert_class); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 634 | |
| 635 | /** |
| 636 | * Gets the accumulator value for this class. |
| 637 | * |
| 638 | * This value is the number of alerts of this class that have been logged so |
| 639 | * far (more or less, since multiple alerts on the same cycle will be merged |
| 640 | * into one). Once this value equals the configured threshold, any followup |
| 641 | * alerts will immediately trigger the escalation protocol. |
| 642 | * |
| 643 | * This value is cleared as a side-effect of |
| 644 | * `dif_alert_handler_escalation_clear()`. |
| 645 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 646 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 647 | * @param alert_class The class to get the accumulator for. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 648 | * @param[out] num_alerts Out-param for the number of alerts that have |
| 649 | * accumulated. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 650 | * @return The result of the operation. |
| 651 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 652 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 653 | dif_result_t dif_alert_handler_get_accumulator( |
| 654 | const dif_alert_handler_t *alert_handler, |
Timothy Trippel | 47faff9 | 2022-01-24 23:09:56 -0800 | [diff] [blame] | 655 | dif_alert_handler_class_t alert_class, uint16_t *num_alerts); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 656 | |
| 657 | /** |
| 658 | * Gets the current value of the "escalation counter". |
| 659 | * |
| 660 | * The interpretation of this value depends on the value returned by |
| 661 | * `dif_alert_handler_class_state_get()`. If it is in the timeout state, |
| 662 | * it returns the number of cycles counted towards that cycle so far. |
| 663 | * If in an escalation phase, it returns the number of cycles that phase |
| 664 | * has been active for. |
| 665 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 666 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 667 | * @param alert_class The class to set the counter for. |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 668 | * @param[out] cycles Out-param for the counter. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 669 | * @return The result of the operation. |
| 670 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 671 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 672 | dif_result_t dif_alert_handler_get_escalation_counter( |
| 673 | const dif_alert_handler_t *alert_handler, |
| 674 | dif_alert_handler_class_t alert_class, uint32_t *cycles); |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 675 | |
| 676 | /** |
| 677 | * Gets the current state of this class. |
| 678 | * |
| 679 | * See `dif_alert_handler_class_state_t` for potential states. |
| 680 | * |
Timothy Trippel | 2e85ff1 | 2022-01-19 14:15:02 -0800 | [diff] [blame] | 681 | * @param alert_handler An alert handler handle. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 682 | * @param alert_class The class to get the state of |
Timothy Trippel | 059578e | 2022-02-25 20:04:55 -0800 | [diff] [blame] | 683 | * @param[out] state Out-param for the class state. |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 684 | * @return The result of the operation. |
| 685 | */ |
Timothy Trippel | e3f8a82 | 2021-09-17 06:09:28 +0000 | [diff] [blame] | 686 | OT_WARN_UNUSED_RESULT |
Timothy Trippel | 915ba13 | 2021-09-24 01:23:38 +0000 | [diff] [blame] | 687 | dif_result_t dif_alert_handler_get_class_state( |
| 688 | const dif_alert_handler_t *alert_handler, |
| 689 | dif_alert_handler_class_t alert_class, |
Miguel Young de la Sota | 475887f | 2020-08-10 16:40:09 -0400 | [diff] [blame] | 690 | dif_alert_handler_class_state_t *state); |
| 691 | |
| 692 | #ifdef __cplusplus |
| 693 | } // extern "C" |
| 694 | #endif // __cplusplus |
| 695 | |
| 696 | #endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_ALERT_HANDLER_H_ |