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
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_MBX_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_MBX_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/mbx/data/mbx.hjson -o
12// bazel-out/k8-fastbuild-ST-24cc6a2908d2/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/mbx/">MBX</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "dt/dt_mbx.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to mbx.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_mbx {
38 /**
39 * The base address for the mbx hardware registers.
40 */
42 /**
43 * The instance, set to `kDtMbxCount` if not initialized
44 * through `dif_mbx_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) mbx peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the mbx peripheral.
55 * @param[out] mbx Out param for the initialized handle.
56 * @return The result of the operation.
57 *
58 * DEPRECATED This function exists solely for the transition to
59 * dt-based DIFs and will be removed in the future.
60 */
63 mmio_region_t base_addr,
64 dif_mbx_t *mbx);
65
66/**
67 * Creates a new handle for a(n) mbx peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] mbx Out param for the initialized handle.
73 * @return The result of the operation.
74 */
77 dt_mbx_t dt,
78 dif_mbx_t *mbx);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_mbx_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param mbx A mbx handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_mbx_t *mbx,
93 dt_mbx_t *dt);
94
95 /**
96 * A mbx alert type.
97 */
98 typedef enum dif_mbx_alert {
99 /**
100 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
101 */
103 /**
104 * This recoverable alert is triggered when memory with invalid ECC (e.g., uninitialized memory) or at an invalid address is accessed.
105 */
108
109 /**
110 * Forces a particular alert, causing it to be escalated as if the hardware
111 * had raised it.
112 *
113 * @param mbx A mbx handle.
114 * @param alert The alert to force.
115 * @return The result of the operation.
116 */
119 const dif_mbx_t *mbx,
120 dif_mbx_alert_t alert);
121
122 // DEPRECATED This typedef exists solely for the transition to
123 // dt-based interrupt numbers and will be removed in the future.
124 typedef dt_mbx_irq_t dif_mbx_irq_t;
125
126 /**
127 * A mbx interrupt request type.
128 *
129 * DEPRECATED Use `dt_mbx_irq_t` instead.
130 * This enumeration exists solely for the transition to
131 * dt-based interrupt numbers and will be removed in the future.
132 *
133 * The following are defines to keep the types consistent with DT.
134 */
135 /**
136 * A new object was received in the inbound mailbox.
137 */
138#define kDifMbxIrqMbxReady kDtMbxIrqMbxReady
139 /**
140 * An abort request was received from the requester.
141 */
142#define kDifMbxIrqMbxAbort kDtMbxIrqMbxAbort
143 /**
144 * The mailbox instance generated an error.
145 */
146#define kDifMbxIrqMbxError kDtMbxIrqMbxError
147
148 /**
149 * A snapshot of the state of the interrupts for this IP.
150 *
151 * This is an opaque type, to be used with the `dif_mbx_irq_get_state()`
152 * and `dif_mbx_irq_acknowledge_state()` functions.
153 */
155
156 /**
157 * Returns the type of a given interrupt (i.e., event or status) for this IP.
158 *
159 * @param mbx A mbx handle.
160 * @param irq An interrupt request.
161 * @param[out] type Out-param for the interrupt type.
162 * @return The result of the operation.
163 */
166 const dif_mbx_t *mbx,
167 dif_mbx_irq_t,
168 dif_irq_type_t *type);
169
170 /**
171 * Returns the state of all interrupts (i.e., pending or not) for this IP.
172 *
173 * @param mbx A mbx handle.
174 * @param[out] snapshot Out-param for interrupt state snapshot.
175 * @return The result of the operation.
176 */
179 const dif_mbx_t *mbx,
181
182 /**
183 * Returns whether a particular interrupt is currently pending.
184 *
185 * @param mbx A mbx handle.
186 * @param irq An interrupt request.
187 * @param[out] is_pending Out-param for whether the interrupt is pending.
188 * @return The result of the operation.
189 */
192 const dif_mbx_t *mbx,
193 dif_mbx_irq_t,
194 bool *is_pending);
195
196 /**
197 * Acknowledges all interrupts that were pending at the time of the state
198 * snapshot.
199 *
200 * @param mbx A mbx handle.
201 * @param snapshot Interrupt state snapshot.
202 * @return The result of the operation.
203 */
206 const dif_mbx_t *mbx,
208
209 /**
210 * Acknowledges all interrupts, indicating to the hardware that all
211 * interrupts have been successfully serviced.
212 *
213 * @param mbx A mbx handle.
214 * @return The result of the operation.
215 */
218 const dif_mbx_t *mbx
219 );
220
221 /**
222 * Acknowledges a particular interrupt, indicating to the hardware that it has
223 * been successfully serviced.
224 *
225 * @param mbx A mbx handle.
226 * @param irq An interrupt request.
227 * @return The result of the operation.
228 */
231 const dif_mbx_t *mbx,
232 dif_mbx_irq_t);
233
234 /**
235 * Forces a particular interrupt, causing it to be serviced as if hardware had
236 * asserted it.
237 *
238 * @param mbx A mbx handle.
239 * @param irq An interrupt request.
240 * @param val Value to be set.
241 * @return The result of the operation.
242 */
245 const dif_mbx_t *mbx,
246 dif_mbx_irq_t,
247 const bool val);
248
249 /**
250 * A snapshot of the enablement state of the interrupts for this IP.
251 *
252 * This is an opaque type, to be used with the
253 * `dif_mbx_irq_disable_all()` and `dif_mbx_irq_restore_all()`
254 * functions.
255 */
257
258 /**
259 * Checks whether a particular interrupt is currently enabled or disabled.
260 *
261 * @param mbx A mbx handle.
262 * @param irq An interrupt request.
263 * @param[out] state Out-param toggle state of the interrupt.
264 * @return The result of the operation.
265 */
268 const dif_mbx_t *mbx,
269 dif_mbx_irq_t,
270 dif_toggle_t *state);
271
272 /**
273 * Sets whether a particular interrupt is currently enabled or disabled.
274 *
275 * @param mbx A mbx handle.
276 * @param irq An interrupt request.
277 * @param state The new toggle state for the interrupt.
278 * @return The result of the operation.
279 */
282 const dif_mbx_t *mbx,
283 dif_mbx_irq_t,
284 dif_toggle_t state);
285
286 /**
287 * Disables all interrupts, optionally snapshotting all enable states for later
288 * restoration.
289 *
290 * @param mbx A mbx handle.
291 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
292 * @return The result of the operation.
293 */
296 const dif_mbx_t *mbx,
298
299 /**
300 * Restores interrupts from the given (enable) snapshot.
301 *
302 * @param mbx A mbx handle.
303 * @param snapshot A snapshot to restore from.
304 * @return The result of the operation.
305 */
308 const dif_mbx_t *mbx,
309 const dif_mbx_irq_enable_snapshot_t *snapshot);
310
311
312#ifdef __cplusplus
313} // extern "C"
314#endif // __cplusplus
315
316#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_MBX_AUTOGEN_H_