blob: c388e0d23c7e39ce6bf418b16de951050f8054d2 [file] [log] [blame]
Miguel Young de la Sota475887f2020-08-10 16:40:09 -04001// 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
16#include "sw/device/lib/base/mmio.h"
17#include "sw/device/lib/dif/dif_warn_unused_result.h"
18
Miguel Young de la Sota475887f2020-08-10 16:40:09 -040019#ifdef __cplusplus
20extern "C" {
21#endif // __cplusplus
22
23/**
24 * A toggle state: enabled, or disabled.
25 *
26 * This enum may be used instead of a `bool` when describing an enabled/disabled
27 * state.
28 */
29typedef enum dif_alert_handler_toggle {
30 /**
31 * The "enabled" state.
32 */
33 kDifAlertHandlerToggleEnabled,
34 /**
35 * The "disabled" state.
36 */
37 kDifAlertHandlerToggleDisabled,
38} dif_alert_handler_toggle_t;
39
40/**
41 * Hardware instantiation parameters for the alert handler.
42 *
43 * This struct describes information about the underlying hardware that is
44 * not determined until the hardware design is used as part of a top-level
45 * design.
46 */
47typedef struct dif_alert_handler_params {
48 /**
49 * The base address for the alert handler hardware registers.
50 */
51 mmio_region_t base_addr;
52 /**
53 * The configured number of alerts.
54 *
55 * This value is fixed by the hardware, but not known to this library.
56 */
57 uint32_t alert_count;
58 /**
59 * The configured number of escalation signals.
60 *
61 * This value is fixed by the hardware, but not known to this library.
62 */
63 // It's actually fixed at 4 right now but this is likely to become
64 // configurable too.
65 uint32_t escalation_signal_count;
66} dif_alert_handler_params_t;
67
68/**
69 * A handle to alert handler.
70 *
71 * This type should be treated as opaque by users.
72 */
73typedef struct dif_alert_handler {
74 dif_alert_handler_params_t params;
75} dif_alert_handler_t;
76
77/**
78 * The result of an alert handler operation.
79 */
80typedef enum dif_alert_handler_result {
81 /**
82 * Indicates that the operation succeeded.
83 */
84 kDifAlertHandlerOk = 0,
85 /**
86 * Indicates some unspecified failure.
87 */
88 kDifAlertHandlerError = 1,
89 /**
90 * Indicates that some parameter passed into a function failed a
91 * precondition.
92 *
Michael Mundayd55bc6c2021-02-26 12:24:44 +000093 * When this value is returned, no hardware operations occurred.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -040094 */
95 kDifAlertHandlerBadArg = 2,
96} dif_alert_handler_result_t;
97
98/**
99 * The result of an alert handler configuration operation.
100 */
101typedef enum dif_alert_handler_config_result {
102 /**
103 * Indicates that the operation succeeded.
104 */
105 kDifAlertHandlerConfigOk = kDifAlertHandlerOk,
106 /**
107 * Indicates some unspecified failure.
108 */
109 kDifAlertHandlerConfigError = kDifAlertHandlerError,
110 /**
111 * Indicates that some parameter passed into a function failed a
112 * precondition.
113 *
Michael Mundayd55bc6c2021-02-26 12:24:44 +0000114 * When this value is returned, no hardware operations occurred.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400115 */
116 kDifAlertHandlerConfigBadArg = kDifAlertHandlerBadArg,
117 /**
118 * Indicates that this operation has been locked out, and can never
119 * succeed until hardware reset.
120 */
121 kDifAlertHandlerConfigLocked = 3,
122} dif_alert_handler_config_result_t;
123
124/**
125 * An alert class.
126 *
127 * An alert class roughly specifies how to deal with an alert. The class
128 * determines which interrupt handler is fired for an alert, as well as the
129 * fine-grained details of the escalation policy, for when the processor
130 * fails to respond to an alert quickly enough.
131 *
132 * Alert classes serve as the alert handler's IRQ types. There is one IRQ for
133 * each class. Whenever an alert fires, the corresponding class's IRQ is
134 * serviced by the processor (if enabled).
135 */
136typedef enum dif_alert_handler_class {
137 /**
138 * Alert class "A".
139 */
140 kDifAlertHandlerClassA = 0,
141 /**
142 * Alert class "B".
143 */
144 kDifAlertHandlerClassB = 1,
145 /**
146 * Alert class "C".
147 */
148 kDifAlertHandlerClassC = 2,
149 /**
150 * Alert class "D".
151 */
152 kDifAlertHandlerClassD = 3,
153} dif_alert_handler_class_t;
154
155/**
156 * A snapshot of the enablement state of the interrupts for alert handler.
157 *
158 * This is an opaque type, to be used with the
159 * `dif_alert_handler_irq_disable_all()` and
160 * `dif_alert_handler_irq_restore_all()` functions.
161 */
162typedef uint32_t dif_alert_handler_irq_snapshot_t;
163
164/**
165 * An alert, identified by a numeric id.
166 *
167 * Alerts are hardware-level events indicating that something catastrophic
168 * has happened. An alert handler handle.consumes alerts, classifies them to a
169 * particular `dif_alert_handler_class_t`, and uses policy information attached
170 * to that class to handle it.
171 *
172 * The number of alerts is configurable at hardware-synthesis time, and is
173 * specified by the software when initializing a `dif_alert_handler_t`.
174 */
175typedef uint32_t dif_alert_handler_alert_t;
176
177/**
178 * A local alert originating from within the alert handler itself.
179 *
180 * A local alert is exactly the same as a normal `dif_alert_handler_alert_t`,
181 * except that they use different functions for setting up classification and
182 * for getting causes.
183 */
184typedef enum dif_alert_handler_local_alert {
185 kDifAlertHandlerLocalAlertAlertPingFail,
186 kDifAlertHandlerLocalAlertEscalationPingFail,
187 kDifAlertHandlerLocalAlertAlertIntegrityFail,
188 kDifAlertHandlerLocalAlertEscalationIntegrityFail,
Timothy Trippelbcca3302021-08-04 20:18:16 +0000189 kDifAlertHandlerLocalAlertBusIntegrityFail,
Michael Schaffner1a5d53a2021-06-03 17:44:17 -0700190 kDifAlertHandlerLocalAlertShadowedUpdateError,
191 kDifAlertHandlerLocalAlertShadowedStorageError,
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400192} dif_alert_handler_local_alert_t;
193
194/**
195 * An escalation signal, identified by a numeric id.
196 *
197 * An escalation signal is a generic "response" to failing to handle a
198 * catastrophic event. What each signal means is determined by the chip.
199 *
200 * A `dif_alert_handler_class_t` can be configured to raise escalation signals
201 * as part of its policy.
202 */
203typedef uint32_t dif_alert_handler_signal_t;
204
205/**
206 * An alert class state.
207 *
208 * This enum describes the sequence of states in the *escalation protocol*,
209 * which triggers under two different conditions:
210 * - If too many alerts of a particular class accumualte.
211 * - If the software IRQ handler for that class times out.
212 *
213 * When either of these conditions is reached, phase 0 begins. This may trigger
214 * an escalation signal, and after a configured duration, proceed to phase 1.
215 * This process repeats until phase 3 ends, at which point the class enters a
216 * "bricked" terminal state, which cannot be exited except by reset.
217 *
218 * At any point, software may end the escalation protocol by calling
219 * `dif_alert_handler_escalation_clear()` (unless clearing is disabled).
220 * Successfully calling this function, or clearing the IRQ on time, will reset
221 * back to the idle state. Note that this function cannot clear the terminal
222 * state; that state can only be cleared by resetting the chip.
223 */
224typedef enum dif_alert_handler_class_state {
225 /**
226 * The initial, idle state.
227 */
228 kDifAlertHandlerClassStateIdle,
229 /**
230 * The "timeout" state, that is, the IRQ has been fired and the clock is
231 * ticking for the processor to handle the alert.
232 */
233 kDifAlertHandlerClassStateTimeout,
234
235 /**
236 * The zeroth escalation phase.
237 */
238 kDifAlertHandlerClassStatePhase0,
239 /**
240 * The first escalation phase.
241 */
242 kDifAlertHandlerClassStatePhase1,
243 /**
244 * The second escalation phase.
245 */
246 kDifAlertHandlerClassStatePhase2,
247 /**
248 * The third escalation phase.
249 */
250 kDifAlertHandlerClassStatePhase3,
251
252 /**
253 * The terminal state. Most configurations will never reach this state, since
254 * one of the previous phases will use an escalation signal to reset the
255 * device.
256 */
257 kDifAlertHandlerClassStateTerminal,
258} dif_alert_handler_class_state_t;
259
260/**
261 * Runtime configuration for responding to a given escalation phase.
262 *
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400263 * See `dif_alert_handler_class_config_t`.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400264 */
265typedef struct dif_alert_handler_class_phase_signal {
266 /**
267 * The phase this configuration describes.
268 *
269 * It is an error for this to not be one of the `Phase` constants in
270 * `dif_alert_handler_class_state_t`.
271 */
272 dif_alert_handler_class_state_t phase;
273 /**
274 * The signal that should be triggered when this phase begins.
275 */
276 dif_alert_handler_signal_t signal;
277} dif_alert_handler_class_phase_signal_t;
278
279/**
280 * Runtime configuration for the duration of an escalation phase.
281 *
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400282 * See `dif_alert_handler_class_config_t`.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400283 */
284typedef struct dif_alert_handler_class_phase_duration {
285 /**
286 * The phase this configuration describes.
287 *
288 * It is an error for this to not be one of the `Phase` constants in
289 * `dif_alert_handler_class_state_t`.
290 */
291 dif_alert_handler_class_state_t phase;
292 /**
293 * The duration of this phase, in cycles.
294 */
295 uint32_t cycles;
296} dif_alert_handler_class_phase_duration_t;
297
298/**
299 * Runtime configuration for a particular alert class.
300 *
301 * This struct describes how a particular alert class should be configured,
302 * such as which signals are associated with it, and what options are turned
303 * on for the escalation protocol.
304 *
305 * For each of the pointer/length field pairs below, if the length is zero, the
306 * pointer may be `NULL`.
307 */
308typedef struct dif_alert_handler_class_config {
309 /**
310 * The class this configuration describes.
311 */
312 dif_alert_handler_class_t alert_class;
313
314 /**
315 * A list of alerts that should be classified as having this class.
316 *
317 * Each alert in this list will additionally be set as enabled.
318 */
319 const dif_alert_handler_alert_t *alerts;
320 /**
321 * The length of the array `alerts`.
322 */
323 size_t alerts_len;
324
325 /**
326 * A list of local that should be classified as having this class.
327 *
328 * Each local alert in this list will additionally be set as enabled.
329 */
330 const dif_alert_handler_local_alert_t *local_alerts;
331 /**
332 * The length of the array `local_alerts`.
333 */
334 size_t local_alerts_len;
335
336 /**
337 * Whether the escalation protocol should be used for this class
338 * (i.e., accumulator and timeout based escalation).
339 *
340 * Class IRQs will still fire regardless of this setting.
341 */
342 dif_alert_handler_toggle_t use_escalation_protocol;
343
344 /**
345 * Whether automatic escalation locking should be used for this class.
346 *
347 * When enabled, upon beginning the escalation protocol, the hardware will
348 * lock
349 * the escalation clear bit, so that software cannot stop escalation once it
350 * has begun.
351 */
352 dif_alert_handler_toggle_t automatic_locking;
353
354 /**
355 * The threshold for the class accmulator which, when reached, will
Miguel Young de la Sotadf5994c2020-10-22 13:29:46 -0400356 * automatically trigger escalation.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400357 */
358 uint16_t accumulator_threshold;
359
360 /**
361 * The number of cycles this class's associated IRQ handler has to acknowledge
362 * the IRQ before escalation is triggered.
363 *
364 * A value of zero disables the timeout.
365 */
366 uint32_t irq_deadline_cycles;
367
368 /**
369 * Signals to associate to each escalation phase.
370 *
371 * Each escalation phase signal in this list will additionally be set as
372 * enabled; phases not listed will have their escalation signals disabled.
373 */
374 const dif_alert_handler_class_phase_signal_t *phase_signals;
375 /**
376 * The length of the array `phase_signals`.
377 */
378 size_t phase_signals_len;
379
380 /**
381 * Durations, in cycles, of each escalation phase.
382 */
383 const dif_alert_handler_class_phase_duration_t *phase_durations;
384 /**
385 * The length of the array `phase_durations`.
386 */
387 size_t phase_durations_len;
388} dif_alert_handler_class_config_t;
389
390/**
391 * Runtime configuration for alert handler.
392 *
393 * This struct describes runtime information for one-time configuration of the
394 * hardware.
395 */
396typedef struct dif_alert_handler_config {
397 /**
398 * The alert ping timeout, in cycles.
399 *
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400400 * The alert handler will regularly, at random intervals, ping alert
401 * sources. If a source fails to respond, a local alert will be raised.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400402 *
403 * The appropriate value will be dependent on all of the clocks involved on
404 * a chip.
405 *
406 * Note that the ping timer won't start until `dif_alert_handler_lock()` is
407 * successfully called.
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400408 *
409 * This value must fit in 24 bits.
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400410 */
411 uint32_t ping_timeout;
412
413 /**
414 * A list of alert classes to configure.
415 */
416 const dif_alert_handler_class_config_t *classes;
417 /**
418 * The length of the array `classes`.
419 */
420 size_t classes_len;
421} dif_alert_handler_config_t;
422
423/**
424 * Creates a new handle for alert handler.
425 *
426 * This function does not actuate the hardware.
427 *
428 * @param params Hardware instantiation parameters.
429 * @param handler Out param for the initialized handle.
430 * @return The result of the operation.
431 */
432DIF_WARN_UNUSED_RESULT
433dif_alert_handler_result_t dif_alert_handler_init(
434 dif_alert_handler_params_t params, dif_alert_handler_t *handler);
435
436/**
437 * Configures alert handler with runtime information.
438 *
439 * This function should need to be called once for the lifetime of `handle`.
440 *
441 * This operation is lock-protected.
442 *
443 * @param handler An alert handler handle.
444 * @param config Runtime configuration parameters.
445 * @return The result of the operation.
446 */
447DIF_WARN_UNUSED_RESULT
448dif_alert_handler_config_result_t dif_alert_handler_configure(
449 const dif_alert_handler_t *handler, dif_alert_handler_config_t config);
450/**
451 * Locks out alert handler configuration functionality.
452 *
453 * Once locked, `dif_alert_handler_configure()` will return
454 * `kDifAlertHandlerConfigLocked`.
455 *
456 * This operation cannot be undone, and should be performed at the end of
457 * configuring the alert handler in early boot.
458 *
459 * This function is reentrant: calling it while functionality is locked will
460 * have no effect and return `kDifAlertHandlerOk`.
461 *
462 * @param handler An alert handler handle.
463 * @return The result of the operation.
464 */
465DIF_WARN_UNUSED_RESULT
466dif_alert_handler_result_t dif_alert_handler_lock(
467 const dif_alert_handler_t *handler);
468
469/**
470 * Checks whether this alert handler is locked.
471 *
472 * See `dif_alert_handler_lock()`.
473 *
474 * @param handler An alert handler handle.
475 * @param is_locked Out-param for the locked state.
476 * @return The result of the operation.
477 */
478DIF_WARN_UNUSED_RESULT
479dif_alert_handler_result_t dif_alert_handler_is_locked(
480 const dif_alert_handler_t *handler, bool *is_locked);
481
482/**
483 * Returns whether a particular interrupt is currently pending.
484 *
485 * @param handler An alert handler handle.
486 * @param alert_class An alert class.
487 * @param is_pending Out-param for whether the interrupt is pending.
488 * @return The result of the operation.
489 */
490DIF_WARN_UNUSED_RESULT
491dif_alert_handler_result_t dif_alert_handler_irq_is_pending(
492 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
493 bool *is_pending);
494
495/**
496 * Acknowledges a particular interrupt, indicating to the hardware that it has
497 * been successfully serviced.
498 *
499 * @param handler An alert handler handle.
500 * @param alert_class An alert class.
501 * @return The result of the operation.
502 */
503DIF_WARN_UNUSED_RESULT
504dif_alert_handler_result_t dif_alert_handler_irq_acknowledge(
505 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
506
507/**
508 * Checks whether a particular interrupt is currently enabled or disabled.
509 *
510 * @param handler An alert handler handle.
511 * @param alert_class An alert class.
512 * @param state Out-param toggle state of the interrupt.
513 * @return The result of the operation.
514 */
515DIF_WARN_UNUSED_RESULT
516dif_alert_handler_result_t dif_alert_handler_irq_get_enabled(
517 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
518 dif_alert_handler_toggle_t *state);
519
520/**
521 * Sets whether a particular interrupt is currently enabled or disabled.
522 *
523 * @param handler An alert handler handle.
524 * @param alert_class An alert class.
525 * @param state The new toggle state for the interrupt.
526 * @return The result of the operation.
527 */
528DIF_WARN_UNUSED_RESULT
529dif_alert_handler_result_t dif_alert_handler_irq_set_enabled(
530 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
531 dif_alert_handler_toggle_t state);
532
533/**
534 * Forces a particular interrupt, causing it to be serviced as if hardware had
535 * asserted it.
536 *
537 * @param handler An alert handler handle.
538 * @param alert_class An alert class.
539 * @return The result of the operation.
540 */
541DIF_WARN_UNUSED_RESULT
542dif_alert_handler_result_t dif_alert_handler_irq_force(
543 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
544
545/**
546 * Disables all interrupts, optionally snapshotting all toggle state for later
547 * restoration.
548 *
549 * @param handler An alert handler handle.
550 * @param snapshot Out-param for the snapshot; may be `NULL`.
551 * @return The result of the operation.
552 */
553DIF_WARN_UNUSED_RESULT
554dif_alert_handler_result_t dif_alert_handler_irq_disable_all(
555 const dif_alert_handler_t *handler,
556 dif_alert_handler_irq_snapshot_t *snapshot);
557
558/**
559 * Restores interrupts from the given snapshot.
560 *
561 * This function can be used with `dif_alert_handler_irq_disable_all()` to
562 * temporary
563 * interrupt save-and-restore.
564 *
565 * @param handler An alert handler handle.
566 * @param snapshot A snapshot to restore from.
567 * @return The result of the operation.
568 */
569DIF_WARN_UNUSED_RESULT
570dif_alert_handler_result_t dif_alert_handler_irq_restore_all(
571 const dif_alert_handler_t *handler,
572 const dif_alert_handler_irq_snapshot_t *snapshot);
573
574/**
575 * Checks whether an alert is one of the causes for an alert IRQ.
576 *
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400577 * Note that multiple alerts may be causes at the same time.
578 *
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400579 * @param handler An alert handler handle.
580 * @param alert The alert to check.
581 * @param is_cause Out-param for whether this alert is a cause.
582 * @return The result of the operation.
583 */
584DIF_WARN_UNUSED_RESULT
585dif_alert_handler_result_t dif_alert_handler_alert_is_cause(
586 const dif_alert_handler_t *handler, dif_alert_handler_alert_t alert,
587 bool *is_cause);
588
589/**
590 * Clears an alert from the cause vector, similar to an IRQ acknowledgement.
591 *
592 * @param handler An alert handler handle.
593 * @param alert The alert to acknowledge.
594 * @return The result of the operation.
595 */
596DIF_WARN_UNUSED_RESULT
597dif_alert_handler_result_t dif_alert_handler_alert_acknowledge(
598 const dif_alert_handler_t *handler, dif_alert_handler_alert_t alert);
599
600/**
Miguel Young de la Sotadd71d982020-09-17 15:40:16 -0400601 * Checks whether a local alert is one of the causes for an alert IRQ.
602 *
603 * Note that multiple alerts may be causes at the same time.
604 *
605 * @param handler An alert handler handle.
606 * @param alert The alert to check.
607 * @param is_cause Out-param for whether this alert is a cause.
608 * @return The result of the operation.
609 */
610DIF_WARN_UNUSED_RESULT
611dif_alert_handler_result_t dif_alert_handler_local_alert_is_cause(
612 const dif_alert_handler_t *handler, dif_alert_handler_local_alert_t alert,
613 bool *is_cause);
614
615/**
616 * Clears a local alert from the cause vector, similar to an IRQ
617 * acknowledgement.
618 *
619 * @param handler An alert handler handle.
620 * @param alert The alert to acknowledge.
621 * @return The result of the operation.
622 */
623DIF_WARN_UNUSED_RESULT
624dif_alert_handler_result_t dif_alert_handler_local_alert_acknowledge(
625 const dif_alert_handler_t *handler, dif_alert_handler_local_alert_t alert);
626
627/**
Miguel Young de la Sota475887f2020-08-10 16:40:09 -0400628 * Checks whether software can clear escalations for this class.
629 *
630 * If `automatic_locking` has been set in a class's configuration, this
631 * function may suddenly begin returning `false` instead of `true` without
632 * software invervention, if escalation has been triggered.
633 *
634 * @param handler An alert handler handle.
635 * @param alert_class The class to check.
636 * @param can_clear Out-param for the clear enablement state.
637 * @return The result of the operation.
638 */
639DIF_WARN_UNUSED_RESULT
640dif_alert_handler_result_t dif_alert_handler_escalation_can_clear(
641 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
642 bool *can_clear);
643
644/**
645 * Disables escalation clearing for this class.
646 *
647 * This operation is similar to locking in that it cannot be undone.
648 *
649 * @param handler An alert handler handle.
650 * @param alert_class The class to disable clearing for.
651 * @return The result of the operation.
652 */
653DIF_WARN_UNUSED_RESULT
654dif_alert_handler_result_t dif_alert_handler_escalation_disable_clearing(
655 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
656
657/**
658 * Clears an on-going escalation, as well as the class accumulator.
659 *
660 * This operation can be disabled with
661 * `dif_alert_handler_escalation_disable_clearing()`.
662 *
663 * @param handler An alert handler handle.
664 * @param alert_class The class to clear an escalation for.
665 * @return The result of the operation.
666 */
667DIF_WARN_UNUSED_RESULT
668dif_alert_handler_result_t dif_alert_handler_escalation_clear(
669 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class);
670
671/**
672 * Gets the accumulator value for this class.
673 *
674 * This value is the number of alerts of this class that have been logged so
675 * far (more or less, since multiple alerts on the same cycle will be merged
676 * into one). Once this value equals the configured threshold, any followup
677 * alerts will immediately trigger the escalation protocol.
678 *
679 * This value is cleared as a side-effect of
680 * `dif_alert_handler_escalation_clear()`.
681 *
682 * @param handler An alert handler handle.
683 * @param alert_class The class to get the accumulator for.
684 * @param alerts Out-param for the accumulator.
685 * @return The result of the operation.
686 */
687DIF_WARN_UNUSED_RESULT
688dif_alert_handler_result_t dif_alert_handler_get_accumulator(
689 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
690 uint16_t *alerts);
691
692/**
693 * Gets the current value of the "escalation counter".
694 *
695 * The interpretation of this value depends on the value returned by
696 * `dif_alert_handler_class_state_get()`. If it is in the timeout state,
697 * it returns the number of cycles counted towards that cycle so far.
698 * If in an escalation phase, it returns the number of cycles that phase
699 * has been active for.
700 *
701 * @param handler An alert handler handle.
702 * @param alert_class The class to set the counter for.
703 * @param cycles Out-param for the counter.
704 * @return The result of the operation.
705 */
706DIF_WARN_UNUSED_RESULT
707dif_alert_handler_result_t dif_alert_handler_get_escalation_counter(
708 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
709 uint32_t *cycles);
710
711/**
712 * Gets the current state of this class.
713 *
714 * See `dif_alert_handler_class_state_t` for potential states.
715 *
716 * @param handler An alert handler handle.
717 * @param alert_class The class to get the state of
718 * @param state Out-param for the class state.
719 * @return The result of the operation.
720 */
721DIF_WARN_UNUSED_RESULT
722dif_alert_handler_result_t dif_alert_handler_get_class_state(
723 const dif_alert_handler_t *handler, dif_alert_handler_class_t alert_class,
724 dif_alert_handler_class_state_t *state);
725
726#ifdef __cplusplus
727} // extern "C"
728#endif // __cplusplus
729
730#endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_ALERT_HANDLER_H_