Software APIs
dif_entropy_src_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_ENTROPY_SRC_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ENTROPY_SRC_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/entropy_src/data/entropy_src.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/entropy_src/">ENTROPY_SRC</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "dt/dt_entropy_src.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to entropy_src.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_entropy_src {
38 /**
39 * The base address for the entropy_src hardware registers.
40 */
42 /**
43 * The instance, set to `kDtEntropySrcCount` if not initialized
44 * through `dif_entropy_src_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) entropy_src peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the entropy_src peripheral.
55 * @param[out] entropy_src 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_entropy_src_t *entropy_src);
65
66/**
67 * Creates a new handle for a(n) entropy_src peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] entropy_src Out param for the initialized handle.
73 * @return The result of the operation.
74 */
78 dif_entropy_src_t *entropy_src);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_entropy_src_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param entropy_src A entropy_src handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_entropy_src_t *entropy_src,
94
95 /**
96 * A entropy_src alert type.
97 */
98 typedef enum dif_entropy_src_alert {
99 /**
100 * This alert is triggered upon the alert health test threshold criteria not met.
101 */
103 /**
104 * This alert triggers for any condition detected in the !!ERR_CODE register, which includes FIFO errors, COUNTER errors, FSM state errors, and also when integrity failures are 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 entropy_src A entropy_src handle.
114 * @param alert The alert to force.
115 * @return The result of the operation.
116 */
119 const dif_entropy_src_t *entropy_src,
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_entropy_src_irq_t dif_entropy_src_irq_t;
125
126 /**
127 * A entropy_src interrupt request type.
128 *
129 * DEPRECATED Use `dt_entropy_src_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 entropy source bits are available for firmware for consumption via !!ENTROPY_DATA register.
137 */
138#define kDifEntropySrcIrqEsEntropyValid kDtEntropySrcIrqEsEntropyValid
139 /**
140 * Asserted whenever the main state machine is in the alert state, e.g., due to health tests failing and reaching the threshold value configured in !!ALERT_THRESHOLD.
141 */
142#define kDifEntropySrcIrqEsHealthTestFailed kDtEntropySrcIrqEsHealthTestFailed
143 /**
144 * Asserted when the observe FIFO has filled to the configured threshold level (see !!OBSERVE_FIFO_THRESH).
145 */
146#define kDifEntropySrcIrqEsObserveFifoReady kDtEntropySrcIrqEsObserveFifoReady
147 /**
148 * Asserted when an fatal error condition is met, e.g., upon FIFO errors, or if an illegal state machine state is reached.
149 */
150#define kDifEntropySrcIrqEsFatalErr kDtEntropySrcIrqEsFatalErr
151
152 /**
153 * A snapshot of the state of the interrupts for this IP.
154 *
155 * This is an opaque type, to be used with the `dif_entropy_src_irq_get_state()`
156 * and `dif_entropy_src_irq_acknowledge_state()` functions.
157 */
159
160 /**
161 * Returns the type of a given interrupt (i.e., event or status) for this IP.
162 *
163 * @param entropy_src A entropy_src handle.
164 * @param irq An interrupt request.
165 * @param[out] type Out-param for the interrupt type.
166 * @return The result of the operation.
167 */
170 const dif_entropy_src_t *entropy_src,
171 dif_entropy_src_irq_t,
172 dif_irq_type_t *type);
173
174 /**
175 * Returns the state of all interrupts (i.e., pending or not) for this IP.
176 *
177 * @param entropy_src A entropy_src handle.
178 * @param[out] snapshot Out-param for interrupt state snapshot.
179 * @return The result of the operation.
180 */
183 const dif_entropy_src_t *entropy_src,
185
186 /**
187 * Returns whether a particular interrupt is currently pending.
188 *
189 * @param entropy_src A entropy_src handle.
190 * @param irq An interrupt request.
191 * @param[out] is_pending Out-param for whether the interrupt is pending.
192 * @return The result of the operation.
193 */
196 const dif_entropy_src_t *entropy_src,
197 dif_entropy_src_irq_t,
198 bool *is_pending);
199
200 /**
201 * Acknowledges all interrupts that were pending at the time of the state
202 * snapshot.
203 *
204 * @param entropy_src A entropy_src handle.
205 * @param snapshot Interrupt state snapshot.
206 * @return The result of the operation.
207 */
210 const dif_entropy_src_t *entropy_src,
212
213 /**
214 * Acknowledges all interrupts, indicating to the hardware that all
215 * interrupts have been successfully serviced.
216 *
217 * @param entropy_src A entropy_src handle.
218 * @return The result of the operation.
219 */
222 const dif_entropy_src_t *entropy_src
223 );
224
225 /**
226 * Acknowledges a particular interrupt, indicating to the hardware that it has
227 * been successfully serviced.
228 *
229 * @param entropy_src A entropy_src handle.
230 * @param irq An interrupt request.
231 * @return The result of the operation.
232 */
235 const dif_entropy_src_t *entropy_src,
236 dif_entropy_src_irq_t);
237
238 /**
239 * Forces a particular interrupt, causing it to be serviced as if hardware had
240 * asserted it.
241 *
242 * @param entropy_src A entropy_src handle.
243 * @param irq An interrupt request.
244 * @param val Value to be set.
245 * @return The result of the operation.
246 */
249 const dif_entropy_src_t *entropy_src,
250 dif_entropy_src_irq_t,
251 const bool val);
252
253 /**
254 * A snapshot of the enablement state of the interrupts for this IP.
255 *
256 * This is an opaque type, to be used with the
257 * `dif_entropy_src_irq_disable_all()` and `dif_entropy_src_irq_restore_all()`
258 * functions.
259 */
261
262 /**
263 * Checks whether a particular interrupt is currently enabled or disabled.
264 *
265 * @param entropy_src A entropy_src handle.
266 * @param irq An interrupt request.
267 * @param[out] state Out-param toggle state of the interrupt.
268 * @return The result of the operation.
269 */
272 const dif_entropy_src_t *entropy_src,
273 dif_entropy_src_irq_t,
274 dif_toggle_t *state);
275
276 /**
277 * Sets whether a particular interrupt is currently enabled or disabled.
278 *
279 * @param entropy_src A entropy_src handle.
280 * @param irq An interrupt request.
281 * @param state The new toggle state for the interrupt.
282 * @return The result of the operation.
283 */
286 const dif_entropy_src_t *entropy_src,
287 dif_entropy_src_irq_t,
288 dif_toggle_t state);
289
290 /**
291 * Disables all interrupts, optionally snapshotting all enable states for later
292 * restoration.
293 *
294 * @param entropy_src A entropy_src handle.
295 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
296 * @return The result of the operation.
297 */
300 const dif_entropy_src_t *entropy_src,
302
303 /**
304 * Restores interrupts from the given (enable) snapshot.
305 *
306 * @param entropy_src A entropy_src handle.
307 * @param snapshot A snapshot to restore from.
308 * @return The result of the operation.
309 */
312 const dif_entropy_src_t *entropy_src,
314
315
316#ifdef __cplusplus
317} // extern "C"
318#endif // __cplusplus
319
320#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ENTROPY_SRC_AUTOGEN_H_