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 #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_EDN_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_EDN_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/edn/">EDN</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 edn.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_edn {
33  /**
34  * The base address for the edn hardware registers.
35  */
37 } dif_edn_t;
38 
39 /**
40  * Creates a new handle for a(n) edn peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the edn peripheral.
45  * @param[out] edn Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A edn alert type.
53  */
54 typedef enum dif_edn_alert {
55  /**
56  * This alert is triggered when entropy bus data matches on consecutive clock
57  * cycles.
58  */
60  /**
61  * This alert triggers (i) if an illegal state machine state is reached, or
62  * (ii) if a fatal integrity failure is detected on the TL-UL bus.
63  */
66 
67 /**
68  * Forces a particular alert, causing it to be escalated as if the hardware
69  * had raised it.
70  *
71  * @param edn A edn handle.
72  * @param alert The alert to force.
73  * @return The result of the operation.
74  */
77 
78 /**
79  * A edn interrupt request type.
80  */
81 typedef enum dif_edn_irq {
82  /**
83  * Asserted when a software CSRNG request has completed.
84  */
86  /**
87  * Asserted when a FIFO error occurs.
88  */
91 
92 /**
93  * A snapshot of the state of the interrupts for this IP.
94  *
95  * This is an opaque type, to be used with the `dif_edn_irq_get_state()`
96  * and `dif_edn_irq_acknowledge_state()` functions.
97  */
99 
100 /**
101  * Returns the type of a given interrupt (i.e., event or status) for this IP.
102  *
103  * @param edn A edn handle.
104  * @param irq An interrupt request.
105  * @param[out] type Out-param for the interrupt type.
106  * @return The result of the operation.
107  */
110  dif_irq_type_t *type);
111 
112 /**
113  * Returns the state of all interrupts (i.e., pending or not) for this IP.
114  *
115  * @param edn A edn handle.
116  * @param[out] snapshot Out-param for interrupt state snapshot.
117  * @return The result of the operation.
118  */
121  dif_edn_irq_state_snapshot_t *snapshot);
122 
123 /**
124  * Returns whether a particular interrupt is currently pending.
125  *
126  * @param edn A edn handle.
127  * @param irq An interrupt request.
128  * @param[out] is_pending Out-param for whether the interrupt is pending.
129  * @return The result of the operation.
130  */
133  bool *is_pending);
134 
135 /**
136  * Acknowledges all interrupts that were pending at the time of the state
137  * snapshot.
138  *
139  * @param edn A edn handle.
140  * @param snapshot Interrupt state snapshot.
141  * @return The result of the operation.
142  */
145  const dif_edn_t *edn, dif_edn_irq_state_snapshot_t snapshot);
146 
147 /**
148  * Acknowledges all interrupts, indicating to the hardware that all
149  * interrupts have been successfully serviced.
150  *
151  * @param edn A edn handle.
152  * @return The result of the operation.
153  */
156 
157 /**
158  * Acknowledges a particular interrupt, indicating to the hardware that it has
159  * been successfully serviced.
160  *
161  * @param edn A edn handle.
162  * @param irq An interrupt request.
163  * @return The result of the operation.
164  */
167 
168 /**
169  * Forces a particular interrupt, causing it to be serviced as if hardware had
170  * asserted it.
171  *
172  * @param edn A edn handle.
173  * @param irq An interrupt request.
174  * @param val Value to be set.
175  * @return The result of the operation.
176  */
179  const bool val);
180 
181 /**
182  * A snapshot of the enablement state of the interrupts for this IP.
183  *
184  * This is an opaque type, to be used with the
185  * `dif_edn_irq_disable_all()` and `dif_edn_irq_restore_all()`
186  * functions.
187  */
189 
190 /**
191  * Checks whether a particular interrupt is currently enabled or disabled.
192  *
193  * @param edn A edn handle.
194  * @param irq An interrupt request.
195  * @param[out] state Out-param toggle state of the interrupt.
196  * @return The result of the operation.
197  */
200  dif_toggle_t *state);
201 
202 /**
203  * Sets whether a particular interrupt is currently enabled or disabled.
204  *
205  * @param edn A edn handle.
206  * @param irq An interrupt request.
207  * @param state The new toggle state for the interrupt.
208  * @return The result of the operation.
209  */
212  dif_toggle_t state);
213 
214 /**
215  * Disables all interrupts, optionally snapshotting all enable states for later
216  * restoration.
217  *
218  * @param edn A edn handle.
219  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
220  * @return The result of the operation.
221  */
225 
226 /**
227  * Restores interrupts from the given (enable) snapshot.
228  *
229  * @param edn A edn handle.
230  * @param snapshot A snapshot to restore from.
231  * @return The result of the operation.
232  */
235  const dif_edn_t *edn, const dif_edn_irq_enable_snapshot_t *snapshot);
236 
237 #ifdef __cplusplus
238 } // extern "C"
239 #endif // __cplusplus
240 
241 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_EDN_AUTOGEN_H_