Software APIs
dif_alert_handler_autogen.h
Go to the documentation of this file.
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ALERT_HANDLER_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ALERT_HANDLER_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i
12// hw/top_earlgrey/ip_autogen/alert_handler/data/alert_handler.hjson -o
13// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
14
15
16/**
17 * @file
18 * @brief <a href="/book/hw/ip/alert_handler/">ALERT_HANDLER</a> Device Interface Functions
19 */
20
21#include <stdbool.h>
22#include <stdint.h>
23
27#include "hw/top/dt/alert_handler.h" // Generated.
28
29#ifdef __cplusplus
30extern "C" {
31#endif // __cplusplus
32
33/**
34 * A handle to alert_handler.
35 *
36 * This type should be treated as opaque by users.
37 */
38typedef struct dif_alert_handler {
39 /**
40 * The base address for the alert_handler hardware registers.
41 */
43 /**
44 * The instance, set to `kDtAlertHandlerCount` if not initialized
45 * through `dif_alert_handler_init_from_dt`.
46 */
49
50/**
51 * Creates a new handle for a(n) alert_handler peripheral.
52 *
53 * This function does not actuate the hardware.
54 *
55 * @param base_addr The MMIO base address of the alert_handler peripheral.
56 * @param[out] alert_handler Out param for the initialized handle.
57 * @return The result of the operation.
58 *
59 * DEPRECATED This function exists solely for the transition to
60 * dt-based DIFs and will be removed in the future.
61 */
64 mmio_region_t base_addr,
65 dif_alert_handler_t *alert_handler);
66
67/**
68 * Creates a new handle for a(n) alert_handler peripheral.
69 *
70 * This function does not actuate the hardware.
71 *
72 * @param dt The devicetable description of the device.
73 * @param[out] alert_handler Out param for the initialized handle.
74 * @return The result of the operation.
75 */
79 dif_alert_handler_t *alert_handler);
80
81/**
82 * Get the DT handle from this DIF.
83 *
84 * If this DIF was initialized by `dif_alert_handler_init_from_dt(dt, ..)`
85 * then this function will return `dt`. Otherwise it will return an error.
86 *
87 * @param alert_handler A alert_handler handle.
88 * @param[out] dt DT handle.
89 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
90 */
93 const dif_alert_handler_t *alert_handler,
95
96
97 // DEPRECATED This typedef exists solely for the transition to
98 // dt-based interrupt numbers and will be removed in the future.
99 typedef dt_alert_handler_irq_t dif_alert_handler_irq_t;
100
101 /**
102 * A alert_handler interrupt request type.
103 *
104 * DEPRECATED Use `dt_alert_handler_irq_t` instead.
105 * This enumeration exists solely for the transition to
106 * dt-based interrupt numbers and will be removed in the future.
107 *
108 * The following are defines to keep the types consistent with DT.
109 */
110 /**
111 * Interrupt state bit of Class A. Set by HW in case an alert within this class triggered. Defaults true, write one to clear.
112 */
113#define kDifAlertHandlerIrqClassa kDtAlertHandlerIrqClassa
114 /**
115 * Interrupt state bit of Class B. Set by HW in case an alert within this class triggered. Defaults true, write one to clear.
116 */
117#define kDifAlertHandlerIrqClassb kDtAlertHandlerIrqClassb
118 /**
119 * Interrupt state bit of Class C. Set by HW in case an alert within this class triggered. Defaults true, write one to clear.
120 */
121#define kDifAlertHandlerIrqClassc kDtAlertHandlerIrqClassc
122 /**
123 * Interrupt state bit of Class D. Set by HW in case an alert within this class triggered. Defaults true, write one to clear.
124 */
125#define kDifAlertHandlerIrqClassd kDtAlertHandlerIrqClassd
126
127 /**
128 * A snapshot of the state of the interrupts for this IP.
129 *
130 * This is an opaque type, to be used with the `dif_alert_handler_irq_get_state()`
131 * and `dif_alert_handler_irq_acknowledge_state()` functions.
132 */
134
135 /**
136 * Returns the type of a given interrupt (i.e., event or status) for this IP.
137 *
138 * @param alert_handler A alert_handler handle.
139 * @param irq An interrupt request.
140 * @param[out] type Out-param for the interrupt type.
141 * @return The result of the operation.
142 */
145 const dif_alert_handler_t *alert_handler,
146 dif_alert_handler_irq_t,
147 dif_irq_type_t *type);
148
149 /**
150 * Returns the state of all interrupts (i.e., pending or not) for this IP.
151 *
152 * @param alert_handler A alert_handler handle.
153 * @param[out] snapshot Out-param for interrupt state snapshot.
154 * @return The result of the operation.
155 */
158 const dif_alert_handler_t *alert_handler,
160
161 /**
162 * Returns whether a particular interrupt is currently pending.
163 *
164 * @param alert_handler A alert_handler handle.
165 * @param irq An interrupt request.
166 * @param[out] is_pending Out-param for whether the interrupt is pending.
167 * @return The result of the operation.
168 */
171 const dif_alert_handler_t *alert_handler,
172 dif_alert_handler_irq_t,
173 bool *is_pending);
174
175 /**
176 * Acknowledges all interrupts that were pending at the time of the state
177 * snapshot.
178 *
179 * @param alert_handler A alert_handler handle.
180 * @param snapshot Interrupt state snapshot.
181 * @return The result of the operation.
182 */
185 const dif_alert_handler_t *alert_handler,
187
188 /**
189 * Acknowledges all interrupts, indicating to the hardware that all
190 * interrupts have been successfully serviced.
191 *
192 * @param alert_handler A alert_handler handle.
193 * @return The result of the operation.
194 */
197 const dif_alert_handler_t *alert_handler
198 );
199
200 /**
201 * Acknowledges a particular interrupt, indicating to the hardware that it has
202 * been successfully serviced.
203 *
204 * @param alert_handler A alert_handler handle.
205 * @param irq An interrupt request.
206 * @return The result of the operation.
207 */
210 const dif_alert_handler_t *alert_handler,
211 dif_alert_handler_irq_t);
212
213 /**
214 * Forces a particular interrupt, causing it to be serviced as if hardware had
215 * asserted it.
216 *
217 * @param alert_handler A alert_handler handle.
218 * @param irq An interrupt request.
219 * @param val Value to be set.
220 * @return The result of the operation.
221 */
224 const dif_alert_handler_t *alert_handler,
225 dif_alert_handler_irq_t,
226 const bool val);
227
228 /**
229 * A snapshot of the enablement state of the interrupts for this IP.
230 *
231 * This is an opaque type, to be used with the
232 * `dif_alert_handler_irq_disable_all()` and `dif_alert_handler_irq_restore_all()`
233 * functions.
234 */
236
237 /**
238 * Checks whether a particular interrupt is currently enabled or disabled.
239 *
240 * @param alert_handler A alert_handler handle.
241 * @param irq An interrupt request.
242 * @param[out] state Out-param toggle state of the interrupt.
243 * @return The result of the operation.
244 */
247 const dif_alert_handler_t *alert_handler,
248 dif_alert_handler_irq_t,
249 dif_toggle_t *state);
250
251 /**
252 * Sets whether a particular interrupt is currently enabled or disabled.
253 *
254 * @param alert_handler A alert_handler handle.
255 * @param irq An interrupt request.
256 * @param state The new toggle state for the interrupt.
257 * @return The result of the operation.
258 */
261 const dif_alert_handler_t *alert_handler,
262 dif_alert_handler_irq_t,
263 dif_toggle_t state);
264
265 /**
266 * Disables all interrupts, optionally snapshotting all enable states for later
267 * restoration.
268 *
269 * @param alert_handler A alert_handler handle.
270 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
271 * @return The result of the operation.
272 */
275 const dif_alert_handler_t *alert_handler,
277
278 /**
279 * Restores interrupts from the given (enable) snapshot.
280 *
281 * @param alert_handler A alert_handler handle.
282 * @param snapshot A snapshot to restore from.
283 * @return The result of the operation.
284 */
287 const dif_alert_handler_t *alert_handler,
289
290
291#ifdef __cplusplus
292} // extern "C"
293#endif // __cplusplus
294
295#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ALERT_HANDLER_AUTOGEN_H_