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 #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ENTROPY_SRC_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ENTROPY_SRC_AUTOGEN_H_
7 
8 // THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
9 // util/make_new_dif.py --mode=regen --only=autogen
10 
11 /**
12  * @file
13  * @brief <a href="/book/hw/ip/entropy_src/">ENTROPY_SRC</a> Device Interface
14  * Functions
15  */
16 
17 #include <stdbool.h>
18 #include <stdint.h>
19 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif // __cplusplus
27 
28 /**
29  * A handle to entropy_src.
30  *
31  * This type should be treated as opaque by users.
32  */
33 typedef struct dif_entropy_src {
34  /**
35  * The base address for the entropy_src hardware registers.
36  */
39 
40 /**
41  * Creates a new handle for a(n) entropy_src peripheral.
42  *
43  * This function does not actuate the hardware.
44  *
45  * @param base_addr The MMIO base address of the entropy_src peripheral.
46  * @param[out] entropy_src Out param for the initialized handle.
47  * @return The result of the operation.
48  */
51  dif_entropy_src_t *entropy_src);
52 
53 /**
54  * A entropy_src alert type.
55  */
56 typedef enum dif_entropy_src_alert {
57  /**
58  * This alert is triggered upon the alert health test threshold criteria not
59  * met.
60  */
62  /**
63  * This alert triggers for any condition detected in the !!ERR_CODE register,
64  * which includes FIFO errors, COUNTER errors, FSM state errors, and also when
65  * integrity failures are detected on the TL-UL bus.
66  */
69 
70 /**
71  * Forces a particular alert, causing it to be escalated as if the hardware
72  * had raised it.
73  *
74  * @param entropy_src A entropy_src handle.
75  * @param alert The alert to force.
76  * @return The result of the operation.
77  */
81 
82 /**
83  * A entropy_src interrupt request type.
84  */
85 typedef enum dif_entropy_src_irq {
86  /**
87  * Asserted when entropy source bits are available for firmware for
88  * consumption via !!ENTROPY_DATA register.
89  */
91  /**
92  * Asserted whenever the main state machine is in the alert state, e.g., due
93  * to health tests failing and reaching the threshold value configured in
94  * !!ALERT_THRESHOLD.
95  */
97  /**
98  * Asserted when the observe FIFO has filled to the configured threshold level
99  * (see !!OBSERVE_FIFO_THRESH).
100  */
102  /**
103  * Asserted when an fatal error condition is met, e.g., upon FIFO errors, or
104  * if an illegal state machine state is reached.
105  */
108 
109 /**
110  * A snapshot of the state of the interrupts for this IP.
111  *
112  * This is an opaque type, to be used with the `dif_entropy_src_irq_get_state()`
113  * and `dif_entropy_src_irq_acknowledge_state()` functions.
114  */
116 
117 /**
118  * Returns the type of a given interrupt (i.e., event or status) for this IP.
119  *
120  * @param entropy_src A entropy_src handle.
121  * @param irq An interrupt request.
122  * @param[out] type Out-param for the interrupt type.
123  * @return The result of the operation.
124  */
128  dif_irq_type_t *type);
129 
130 /**
131  * Returns the state of all interrupts (i.e., pending or not) for this IP.
132  *
133  * @param entropy_src A entropy_src handle.
134  * @param[out] snapshot Out-param for interrupt state snapshot.
135  * @return The result of the operation.
136  */
139  const dif_entropy_src_t *entropy_src,
141 
142 /**
143  * Returns whether a particular interrupt is currently pending.
144  *
145  * @param entropy_src A entropy_src handle.
146  * @param irq An interrupt request.
147  * @param[out] is_pending Out-param for whether the interrupt is pending.
148  * @return The result of the operation.
149  */
152  const dif_entropy_src_t *entropy_src, dif_entropy_src_irq_t irq,
153  bool *is_pending);
154 
155 /**
156  * Acknowledges all interrupts that were pending at the time of the state
157  * snapshot.
158  *
159  * @param entropy_src A entropy_src handle.
160  * @param snapshot Interrupt state snapshot.
161  * @return The result of the operation.
162  */
165  const dif_entropy_src_t *entropy_src,
167 
168 /**
169  * Acknowledges all interrupts, indicating to the hardware that all
170  * interrupts have been successfully serviced.
171  *
172  * @param entropy_src A entropy_src handle.
173  * @return The result of the operation.
174  */
177  const dif_entropy_src_t *entropy_src);
178 
179 /**
180  * Acknowledges a particular interrupt, indicating to the hardware that it has
181  * been successfully serviced.
182  *
183  * @param entropy_src A entropy_src handle.
184  * @param irq An interrupt request.
185  * @return The result of the operation.
186  */
189  const dif_entropy_src_t *entropy_src, dif_entropy_src_irq_t irq);
190 
191 /**
192  * Forces a particular interrupt, causing it to be serviced as if hardware had
193  * asserted it.
194  *
195  * @param entropy_src A entropy_src handle.
196  * @param irq An interrupt request.
197  * @param val Value to be set.
198  * @return The result of the operation.
199  */
203  const bool val);
204 
205 /**
206  * A snapshot of the enablement state of the interrupts for this IP.
207  *
208  * This is an opaque type, to be used with the
209  * `dif_entropy_src_irq_disable_all()` and `dif_entropy_src_irq_restore_all()`
210  * functions.
211  */
213 
214 /**
215  * Checks whether a particular interrupt is currently enabled or disabled.
216  *
217  * @param entropy_src A entropy_src handle.
218  * @param irq An interrupt request.
219  * @param[out] state Out-param toggle state of the interrupt.
220  * @return The result of the operation.
221  */
224  const dif_entropy_src_t *entropy_src, dif_entropy_src_irq_t irq,
225  dif_toggle_t *state);
226 
227 /**
228  * Sets whether a particular interrupt is currently enabled or disabled.
229  *
230  * @param entropy_src A entropy_src handle.
231  * @param irq An interrupt request.
232  * @param state The new toggle state for the interrupt.
233  * @return The result of the operation.
234  */
237  const dif_entropy_src_t *entropy_src, dif_entropy_src_irq_t irq,
238  dif_toggle_t state);
239 
240 /**
241  * Disables all interrupts, optionally snapshotting all enable states for later
242  * restoration.
243  *
244  * @param entropy_src A entropy_src handle.
245  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
246  * @return The result of the operation.
247  */
250  const dif_entropy_src_t *entropy_src,
252 
253 /**
254  * Restores interrupts from the given (enable) snapshot.
255  *
256  * @param entropy_src A entropy_src handle.
257  * @param snapshot A snapshot to restore from.
258  * @return The result of the operation.
259  */
262  const dif_entropy_src_t *entropy_src,
263  const dif_entropy_src_irq_enable_snapshot_t *snapshot);
264 
265 #ifdef __cplusplus
266 } // extern "C"
267 #endif // __cplusplus
268 
269 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ENTROPY_SRC_AUTOGEN_H_