Software APIs
dif_csrng_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_CSRNG_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_CSRNG_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/csrng/">CSRNG</a> Device Interface Functions
14  */
15 
16 #include <stdbool.h>
17 #include <stdint.h>
18 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif // __cplusplus
26 
27 /**
28  * A handle to csrng.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_csrng {
33  /**
34  * The base address for the csrng hardware registers.
35  */
38 
39 /**
40  * Creates a new handle for a(n) csrng peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the csrng peripheral.
45  * @param[out] csrng Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A csrng alert type.
53  */
54 typedef enum dif_csrng_alert {
55  /**
56  * This alert is triggered when a recoverable alert occurs. Check the
57  * !!RECOV_ALERT_STS register to get more information.
58  */
60  /**
61  * This alert triggers (i) if an illegal state machine state is reached, or
62  * (ii) if an AES fatal alert condition occurs, or (iii) if a fatal integrity
63  * failure is detected on the TL-UL bus.
64  */
67 
68 /**
69  * Forces a particular alert, causing it to be escalated as if the hardware
70  * had raised it.
71  *
72  * @param csrng A csrng handle.
73  * @param alert The alert to force.
74  * @return The result of the operation.
75  */
78  dif_csrng_alert_t alert);
79 
80 /**
81  * A csrng interrupt request type.
82  */
83 typedef enum dif_csrng_irq {
84  /**
85  * Asserted when a command request is completed.
86  */
88  /**
89  * Asserted when a request for entropy has been made.
90  */
92  /**
93  * Asserted when a hardware-attached CSRNG instance encounters a command
94  * exception
95  */
97  /**
98  * Asserted when a FIFO error or a fatal alert occurs. Check the !!ERR_CODE
99  * register to get more information.
100  */
103 
104 /**
105  * A snapshot of the state of the interrupts for this IP.
106  *
107  * This is an opaque type, to be used with the `dif_csrng_irq_get_state()`
108  * and `dif_csrng_irq_acknowledge_state()` functions.
109  */
111 
112 /**
113  * Returns the type of a given interrupt (i.e., event or status) for this IP.
114  *
115  * @param csrng A csrng handle.
116  * @param irq An interrupt request.
117  * @param[out] type Out-param for the interrupt type.
118  * @return The result of the operation.
119  */
122  dif_csrng_irq_t irq, dif_irq_type_t *type);
123 
124 /**
125  * Returns the state of all interrupts (i.e., pending or not) for this IP.
126  *
127  * @param csrng A csrng handle.
128  * @param[out] snapshot Out-param for interrupt state snapshot.
129  * @return The result of the operation.
130  */
134 
135 /**
136  * Returns whether a particular interrupt is currently pending.
137  *
138  * @param csrng A csrng handle.
139  * @param irq An interrupt request.
140  * @param[out] is_pending Out-param for whether the interrupt is pending.
141  * @return The result of the operation.
142  */
145  dif_csrng_irq_t irq, bool *is_pending);
146 
147 /**
148  * Acknowledges all interrupts that were pending at the time of the state
149  * snapshot.
150  *
151  * @param csrng A csrng handle.
152  * @param snapshot Interrupt state snapshot.
153  * @return The result of the operation.
154  */
157  const dif_csrng_t *csrng, dif_csrng_irq_state_snapshot_t snapshot);
158 
159 /**
160  * Acknowledges all interrupts, indicating to the hardware that all
161  * interrupts have been successfully serviced.
162  *
163  * @param csrng A csrng handle.
164  * @return The result of the operation.
165  */
168 
169 /**
170  * Acknowledges a particular interrupt, indicating to the hardware that it has
171  * been successfully serviced.
172  *
173  * @param csrng A csrng handle.
174  * @param irq An interrupt request.
175  * @return The result of the operation.
176  */
179  dif_csrng_irq_t irq);
180 
181 /**
182  * Forces a particular interrupt, causing it to be serviced as if hardware had
183  * asserted it.
184  *
185  * @param csrng A csrng handle.
186  * @param irq An interrupt request.
187  * @param val Value to be set.
188  * @return The result of the operation.
189  */
192  const bool val);
193 
194 /**
195  * A snapshot of the enablement state of the interrupts for this IP.
196  *
197  * This is an opaque type, to be used with the
198  * `dif_csrng_irq_disable_all()` and `dif_csrng_irq_restore_all()`
199  * functions.
200  */
202 
203 /**
204  * Checks whether a particular interrupt is currently enabled or disabled.
205  *
206  * @param csrng A csrng handle.
207  * @param irq An interrupt request.
208  * @param[out] state Out-param toggle state of the interrupt.
209  * @return The result of the operation.
210  */
213  dif_csrng_irq_t irq,
214  dif_toggle_t *state);
215 
216 /**
217  * Sets whether a particular interrupt is currently enabled or disabled.
218  *
219  * @param csrng A csrng handle.
220  * @param irq An interrupt request.
221  * @param state The new toggle state for the interrupt.
222  * @return The result of the operation.
223  */
226  dif_csrng_irq_t irq, dif_toggle_t state);
227 
228 /**
229  * Disables all interrupts, optionally snapshotting all enable states for later
230  * restoration.
231  *
232  * @param csrng A csrng handle.
233  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
234  * @return The result of the operation.
235  */
238  const dif_csrng_t *csrng, dif_csrng_irq_enable_snapshot_t *snapshot);
239 
240 /**
241  * Restores interrupts from the given (enable) snapshot.
242  *
243  * @param csrng A csrng handle.
244  * @param snapshot A snapshot to restore from.
245  * @return The result of the operation.
246  */
249  const dif_csrng_t *csrng, const dif_csrng_irq_enable_snapshot_t *snapshot);
250 
251 #ifdef __cplusplus
252 } // extern "C"
253 #endif // __cplusplus
254 
255 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_CSRNG_AUTOGEN_H_