Software APIs
dif_flash_ctrl_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_FLASH_CTRL_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_FLASH_CTRL_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/flash_ctrl/">FLASH_CTRL</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 flash_ctrl.
30  *
31  * This type should be treated as opaque by users.
32  */
33 typedef struct dif_flash_ctrl {
34  /**
35  * The base address for the flash_ctrl hardware registers.
36  */
39 
40 /**
41  * Creates a new handle for a(n) flash_ctrl peripheral.
42  *
43  * This function does not actuate the hardware.
44  *
45  * @param base_addr The MMIO base address of the flash_ctrl peripheral.
46  * @param[out] flash_ctrl Out param for the initialized handle.
47  * @return The result of the operation.
48  */
51  dif_flash_ctrl_t *flash_ctrl);
52 
53 /**
54  * A flash_ctrl alert type.
55  */
56 typedef enum dif_flash_ctrl_alert {
57  /**
58  * Flash recoverable errors
59  */
61  /**
62  * Flash standard fatal errors
63  */
65  /**
66  * Flash fatal errors including uncorrectable ECC errors. Note that this
67  * alert is not always fatal. The underlying error bits in the !!FAULT_STATUS
68  * register remain set until reset, meaning the alert keeps firing. This
69  * doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and
70  * !!FAULT_STATUS.PHY_STORAGE_ERR. To enable firmware dealing with multi-bit
71  * ECC and ICV errors during firmware selection and verification, these error
72  * bits can be cleared. After passing this stage, it is recommended that
73  * firmware classifies the corresponding alert as fatal on the receiver end,
74  * i.e, inside the alert handler.
75  */
77  /**
78  * Fatal alert triggered inside the flash primitive, including fatal TL-UL bus
79  * integrity faults of the test interface.
80  */
82  /**
83  * Recoverable alert triggered inside the flash primitive.
84  */
87 
88 /**
89  * Forces a particular alert, causing it to be escalated as if the hardware
90  * had raised it.
91  *
92  * @param flash_ctrl A flash_ctrl handle.
93  * @param alert The alert to force.
94  * @return The result of the operation.
95  */
99 
100 /**
101  * A flash_ctrl interrupt request type.
102  */
103 typedef enum dif_flash_ctrl_irq {
104  /**
105  * Program FIFO empty
106  */
108  /**
109  * Program FIFO drained to level
110  */
112  /**
113  * Read FIFO full
114  */
116  /**
117  * Read FIFO filled to level
118  */
120  /**
121  * Operation complete
122  */
124  /**
125  * Correctable error encountered
126  */
129 
130 /**
131  * A snapshot of the state of the interrupts for this IP.
132  *
133  * This is an opaque type, to be used with the `dif_flash_ctrl_irq_get_state()`
134  * and `dif_flash_ctrl_irq_acknowledge_state()` functions.
135  */
137 
138 /**
139  * Returns the type of a given interrupt (i.e., event or status) for this IP.
140  *
141  * @param flash_ctrl A flash_ctrl handle.
142  * @param irq An interrupt request.
143  * @param[out] type Out-param for the interrupt type.
144  * @return The result of the operation.
145  */
149  dif_irq_type_t *type);
150 
151 /**
152  * Returns the state of all interrupts (i.e., pending or not) for this IP.
153  *
154  * @param flash_ctrl A flash_ctrl handle.
155  * @param[out] snapshot Out-param for interrupt state snapshot.
156  * @return The result of the operation.
157  */
160  const dif_flash_ctrl_t *flash_ctrl,
162 
163 /**
164  * Returns whether a particular interrupt is currently pending.
165  *
166  * @param flash_ctrl A flash_ctrl handle.
167  * @param irq An interrupt request.
168  * @param[out] is_pending Out-param for whether the interrupt is pending.
169  * @return The result of the operation.
170  */
174  bool *is_pending);
175 
176 /**
177  * Acknowledges all interrupts that were pending at the time of the state
178  * snapshot.
179  *
180  * @param flash_ctrl A flash_ctrl handle.
181  * @param snapshot Interrupt state snapshot.
182  * @return The result of the operation.
183  */
186  const dif_flash_ctrl_t *flash_ctrl,
188 
189 /**
190  * Acknowledges all interrupts, indicating to the hardware that all
191  * interrupts have been successfully serviced.
192  *
193  * @param flash_ctrl A flash_ctrl handle.
194  * @return The result of the operation.
195  */
198  const dif_flash_ctrl_t *flash_ctrl);
199 
200 /**
201  * Acknowledges a particular interrupt, indicating to the hardware that it has
202  * been successfully serviced.
203  *
204  * @param flash_ctrl A flash_ctrl handle.
205  * @param irq An interrupt request.
206  * @return The result of the operation.
207  */
211 
212 /**
213  * Forces a particular interrupt, causing it to be serviced as if hardware had
214  * asserted it.
215  *
216  * @param flash_ctrl A flash_ctrl handle.
217  * @param irq An interrupt request.
218  * @param val Value to be set.
219  * @return The result of the operation.
220  */
223  dif_flash_ctrl_irq_t irq, const bool val);
224 
225 /**
226  * A snapshot of the enablement state of the interrupts for this IP.
227  *
228  * This is an opaque type, to be used with the
229  * `dif_flash_ctrl_irq_disable_all()` and `dif_flash_ctrl_irq_restore_all()`
230  * functions.
231  */
233 
234 /**
235  * Checks whether a particular interrupt is currently enabled or disabled.
236  *
237  * @param flash_ctrl A flash_ctrl handle.
238  * @param irq An interrupt request.
239  * @param[out] state Out-param toggle state of the interrupt.
240  * @return The result of the operation.
241  */
245  dif_toggle_t *state);
246 
247 /**
248  * Sets whether a particular interrupt is currently enabled or disabled.
249  *
250  * @param flash_ctrl A flash_ctrl handle.
251  * @param irq An interrupt request.
252  * @param state The new toggle state for the interrupt.
253  * @return The result of the operation.
254  */
258  dif_toggle_t state);
259 
260 /**
261  * Disables all interrupts, optionally snapshotting all enable states for later
262  * restoration.
263  *
264  * @param flash_ctrl A flash_ctrl handle.
265  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
266  * @return The result of the operation.
267  */
270  const dif_flash_ctrl_t *flash_ctrl,
272 
273 /**
274  * Restores interrupts from the given (enable) snapshot.
275  *
276  * @param flash_ctrl A flash_ctrl handle.
277  * @param snapshot A snapshot to restore from.
278  * @return The result of the operation.
279  */
282  const dif_flash_ctrl_t *flash_ctrl,
283  const dif_flash_ctrl_irq_enable_snapshot_t *snapshot);
284 
285 #ifdef __cplusplus
286 } // extern "C"
287 #endif // __cplusplus
288 
289 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_FLASH_CTRL_AUTOGEN_H_