Software APIs
dif_edn_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_EDN_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_EDN_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/edn/data/edn.hjson -o
12// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/edn/">EDN</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "hw/top/dt/edn.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to edn.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_edn {
38 /**
39 * The base address for the edn hardware registers.
40 */
42 /**
43 * The instance, set to `kDtEdnCount` if not initialized
44 * through `dif_edn_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) edn peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the edn peripheral.
55 * @param[out] edn Out param for the initialized handle.
56 * @return The result of the operation.
57 *
58 * DEPRECATED This function exists solely for the transition to
59 * dt-based DIFs and will be removed in the future.
60 */
63 mmio_region_t base_addr,
64 dif_edn_t *edn);
65
66/**
67 * Creates a new handle for a(n) edn peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] edn Out param for the initialized handle.
73 * @return The result of the operation.
74 */
77 dt_edn_t dt,
78 dif_edn_t *edn);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_edn_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param edn A edn handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_edn_t *edn,
93 dt_edn_t *dt);
94
95 /**
96 * A edn alert type.
97 */
98 typedef enum dif_edn_alert {
99 /**
100 * This alert is triggered when entropy bus data matches on consecutive clock cycles.
101 */
103 /**
104 * This alert triggers (i) if an illegal state machine state is reached, or (ii) if a fatal integrity failure is detected on the TL-UL bus.
105 */
108
109 /**
110 * Forces a particular alert, causing it to be escalated as if the hardware
111 * had raised it.
112 *
113 * @param edn A edn handle.
114 * @param alert The alert to force.
115 * @return The result of the operation.
116 */
119 const dif_edn_t *edn,
120 dif_edn_alert_t alert);
121
122 // DEPRECATED This typedef exists solely for the transition to
123 // dt-based interrupt numbers and will be removed in the future.
124 typedef dt_edn_irq_t dif_edn_irq_t;
125
126 /**
127 * A edn interrupt request type.
128 *
129 * DEPRECATED Use `dt_edn_irq_t` instead.
130 * This enumeration exists solely for the transition to
131 * dt-based interrupt numbers and will be removed in the future.
132 *
133 * The following are defines to keep the types consistent with DT.
134 */
135 /**
136 * Asserted when a software CSRNG request has completed.
137 */
138#define kDifEdnIrqEdnCmdReqDone kDtEdnIrqEdnCmdReqDone
139 /**
140 * Asserted when a FIFO error occurs.
141 */
142#define kDifEdnIrqEdnFatalErr kDtEdnIrqEdnFatalErr
143
144 /**
145 * A snapshot of the state of the interrupts for this IP.
146 *
147 * This is an opaque type, to be used with the `dif_edn_irq_get_state()`
148 * and `dif_edn_irq_acknowledge_state()` functions.
149 */
151
152 /**
153 * Returns the type of a given interrupt (i.e., event or status) for this IP.
154 *
155 * @param edn A edn handle.
156 * @param irq An interrupt request.
157 * @param[out] type Out-param for the interrupt type.
158 * @return The result of the operation.
159 */
162 const dif_edn_t *edn,
163 dif_edn_irq_t,
164 dif_irq_type_t *type);
165
166 /**
167 * Returns the state of all interrupts (i.e., pending or not) for this IP.
168 *
169 * @param edn A edn handle.
170 * @param[out] snapshot Out-param for interrupt state snapshot.
171 * @return The result of the operation.
172 */
175 const dif_edn_t *edn,
177
178 /**
179 * Returns whether a particular interrupt is currently pending.
180 *
181 * @param edn A edn handle.
182 * @param irq An interrupt request.
183 * @param[out] is_pending Out-param for whether the interrupt is pending.
184 * @return The result of the operation.
185 */
188 const dif_edn_t *edn,
189 dif_edn_irq_t,
190 bool *is_pending);
191
192 /**
193 * Acknowledges all interrupts that were pending at the time of the state
194 * snapshot.
195 *
196 * @param edn A edn handle.
197 * @param snapshot Interrupt state snapshot.
198 * @return The result of the operation.
199 */
202 const dif_edn_t *edn,
204
205 /**
206 * Acknowledges all interrupts, indicating to the hardware that all
207 * interrupts have been successfully serviced.
208 *
209 * @param edn A edn handle.
210 * @return The result of the operation.
211 */
214 const dif_edn_t *edn
215 );
216
217 /**
218 * Acknowledges a particular interrupt, indicating to the hardware that it has
219 * been successfully serviced.
220 *
221 * @param edn A edn handle.
222 * @param irq An interrupt request.
223 * @return The result of the operation.
224 */
227 const dif_edn_t *edn,
228 dif_edn_irq_t);
229
230 /**
231 * Forces a particular interrupt, causing it to be serviced as if hardware had
232 * asserted it.
233 *
234 * @param edn A edn handle.
235 * @param irq An interrupt request.
236 * @param val Value to be set.
237 * @return The result of the operation.
238 */
241 const dif_edn_t *edn,
242 dif_edn_irq_t,
243 const bool val);
244
245 /**
246 * A snapshot of the enablement state of the interrupts for this IP.
247 *
248 * This is an opaque type, to be used with the
249 * `dif_edn_irq_disable_all()` and `dif_edn_irq_restore_all()`
250 * functions.
251 */
253
254 /**
255 * Checks whether a particular interrupt is currently enabled or disabled.
256 *
257 * @param edn A edn handle.
258 * @param irq An interrupt request.
259 * @param[out] state Out-param toggle state of the interrupt.
260 * @return The result of the operation.
261 */
264 const dif_edn_t *edn,
265 dif_edn_irq_t,
266 dif_toggle_t *state);
267
268 /**
269 * Sets whether a particular interrupt is currently enabled or disabled.
270 *
271 * @param edn A edn handle.
272 * @param irq An interrupt request.
273 * @param state The new toggle state for the interrupt.
274 * @return The result of the operation.
275 */
278 const dif_edn_t *edn,
279 dif_edn_irq_t,
280 dif_toggle_t state);
281
282 /**
283 * Disables all interrupts, optionally snapshotting all enable states for later
284 * restoration.
285 *
286 * @param edn A edn handle.
287 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
288 * @return The result of the operation.
289 */
292 const dif_edn_t *edn,
294
295 /**
296 * Restores interrupts from the given (enable) snapshot.
297 *
298 * @param edn A edn handle.
299 * @param snapshot A snapshot to restore from.
300 * @return The result of the operation.
301 */
304 const dif_edn_t *edn,
305 const dif_edn_irq_enable_snapshot_t *snapshot);
306
307
308#ifdef __cplusplus
309} // extern "C"
310#endif // __cplusplus
311
312#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_EDN_AUTOGEN_H_