Software APIs
dif_mbx_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_MBX_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_MBX_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/mbx/">MBX</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 mbx.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_mbx {
33  /**
34  * The base address for the mbx hardware registers.
35  */
38 
39 /**
40  * Creates a new handle for a(n) mbx peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the mbx peripheral.
45  * @param[out] mbx Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A mbx alert type.
53  */
54 typedef enum dif_mbx_alert {
55  /**
56  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57  * detected.
58  */
60  /**
61  * This recoverable alert is triggered when memory with invalid ECC (e.g.,
62  * uninitialized memory) or at an invalid address is accessed.
63  */
66 
67 /**
68  * Forces a particular alert, causing it to be escalated as if the hardware
69  * had raised it.
70  *
71  * @param mbx A mbx handle.
72  * @param alert The alert to force.
73  * @return The result of the operation.
74  */
77 
78 /**
79  * A mbx interrupt request type.
80  */
81 typedef enum dif_mbx_irq {
82  /**
83  * A new object was received in the inbound mailbox.
84  */
86  /**
87  * An abort request was received from the requester.
88  */
90  /**
91  * The mailbox instance generated an error.
92  */
95 
96 /**
97  * A snapshot of the state of the interrupts for this IP.
98  *
99  * This is an opaque type, to be used with the `dif_mbx_irq_get_state()`
100  * and `dif_mbx_irq_acknowledge_state()` functions.
101  */
103 
104 /**
105  * Returns the type of a given interrupt (i.e., event or status) for this IP.
106  *
107  * @param mbx A mbx handle.
108  * @param irq An interrupt request.
109  * @param[out] type Out-param for the interrupt type.
110  * @return The result of the operation.
111  */
114  dif_irq_type_t *type);
115 
116 /**
117  * Returns the state of all interrupts (i.e., pending or not) for this IP.
118  *
119  * @param mbx A mbx handle.
120  * @param[out] snapshot Out-param for interrupt state snapshot.
121  * @return The result of the operation.
122  */
125  dif_mbx_irq_state_snapshot_t *snapshot);
126 
127 /**
128  * Returns whether a particular interrupt is currently pending.
129  *
130  * @param mbx A mbx handle.
131  * @param irq An interrupt request.
132  * @param[out] is_pending Out-param for whether the interrupt is pending.
133  * @return The result of the operation.
134  */
137  bool *is_pending);
138 
139 /**
140  * Acknowledges all interrupts that were pending at the time of the state
141  * snapshot.
142  *
143  * @param mbx A mbx handle.
144  * @param snapshot Interrupt state snapshot.
145  * @return The result of the operation.
146  */
149  const dif_mbx_t *mbx, dif_mbx_irq_state_snapshot_t snapshot);
150 
151 /**
152  * Acknowledges all interrupts, indicating to the hardware that all
153  * interrupts have been successfully serviced.
154  *
155  * @param mbx A mbx handle.
156  * @return The result of the operation.
157  */
160 
161 /**
162  * Acknowledges a particular interrupt, indicating to the hardware that it has
163  * been successfully serviced.
164  *
165  * @param mbx A mbx handle.
166  * @param irq An interrupt request.
167  * @return The result of the operation.
168  */
171 
172 /**
173  * Forces a particular interrupt, causing it to be serviced as if hardware had
174  * asserted it.
175  *
176  * @param mbx A mbx handle.
177  * @param irq An interrupt request.
178  * @param val Value to be set.
179  * @return The result of the operation.
180  */
183  const bool val);
184 
185 /**
186  * A snapshot of the enablement state of the interrupts for this IP.
187  *
188  * This is an opaque type, to be used with the
189  * `dif_mbx_irq_disable_all()` and `dif_mbx_irq_restore_all()`
190  * functions.
191  */
193 
194 /**
195  * Checks whether a particular interrupt is currently enabled or disabled.
196  *
197  * @param mbx A mbx handle.
198  * @param irq An interrupt request.
199  * @param[out] state Out-param toggle state of the interrupt.
200  * @return The result of the operation.
201  */
204  dif_toggle_t *state);
205 
206 /**
207  * Sets whether a particular interrupt is currently enabled or disabled.
208  *
209  * @param mbx A mbx handle.
210  * @param irq An interrupt request.
211  * @param state The new toggle state for the interrupt.
212  * @return The result of the operation.
213  */
216  dif_toggle_t state);
217 
218 /**
219  * Disables all interrupts, optionally snapshotting all enable states for later
220  * restoration.
221  *
222  * @param mbx A mbx handle.
223  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
224  * @return The result of the operation.
225  */
229 
230 /**
231  * Restores interrupts from the given (enable) snapshot.
232  *
233  * @param mbx A mbx handle.
234  * @param snapshot A snapshot to restore from.
235  * @return The result of the operation.
236  */
239  const dif_mbx_t *mbx, const dif_mbx_irq_enable_snapshot_t *snapshot);
240 
241 #ifdef __cplusplus
242 } // extern "C"
243 #endif // __cplusplus
244 
245 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_MBX_AUTOGEN_H_