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