Software APIs
dif_keymgr_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_KEYMGR_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KEYMGR_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/keymgr/data/keymgr.hjson -o
12// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/keymgr/">KEYMGR</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "dt/dt_keymgr.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to keymgr.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_keymgr {
38 /**
39 * The base address for the keymgr hardware registers.
40 */
42 /**
43 * The instance, set to `kDtKeymgrCount` if not initialized
44 * through `dif_keymgr_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) keymgr peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the keymgr peripheral.
55 * @param[out] keymgr 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_keymgr_t *keymgr);
65
66/**
67 * Creates a new handle for a(n) keymgr peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] keymgr Out param for the initialized handle.
73 * @return The result of the operation.
74 */
77 dt_keymgr_t dt,
78 dif_keymgr_t *keymgr);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_keymgr_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param keymgr A keymgr handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_keymgr_t *keymgr,
93 dt_keymgr_t *dt);
94
95 /**
96 * A keymgr alert type.
97 */
98 typedef enum dif_keymgr_alert {
99 /**
100 * Alert for key manager operation errors. These errors could have been caused by software
101 */
103 /**
104 * Alert for key manager faults. These errors cannot be caused by software
105 */
108
109 /**
110 * Forces a particular alert, causing it to be escalated as if the hardware
111 * had raised it.
112 *
113 * @param keymgr A keymgr handle.
114 * @param alert The alert to force.
115 * @return The result of the operation.
116 */
119 const dif_keymgr_t *keymgr,
120 dif_keymgr_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_keymgr_irq_t dif_keymgr_irq_t;
125
126 /**
127 * A keymgr interrupt request type.
128 *
129 * DEPRECATED Use `dt_keymgr_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 * Operation complete
137 */
138#define kDifKeymgrIrqOpDone kDtKeymgrIrqOpDone
139
140 /**
141 * A snapshot of the state of the interrupts for this IP.
142 *
143 * This is an opaque type, to be used with the `dif_keymgr_irq_get_state()`
144 * and `dif_keymgr_irq_acknowledge_state()` functions.
145 */
147
148 /**
149 * Returns the type of a given interrupt (i.e., event or status) for this IP.
150 *
151 * @param keymgr A keymgr handle.
152 * @param irq An interrupt request.
153 * @param[out] type Out-param for the interrupt type.
154 * @return The result of the operation.
155 */
158 const dif_keymgr_t *keymgr,
159 dif_keymgr_irq_t,
160 dif_irq_type_t *type);
161
162 /**
163 * Returns the state of all interrupts (i.e., pending or not) for this IP.
164 *
165 * @param keymgr A keymgr handle.
166 * @param[out] snapshot Out-param for interrupt state snapshot.
167 * @return The result of the operation.
168 */
171 const dif_keymgr_t *keymgr,
173
174 /**
175 * Returns whether a particular interrupt is currently pending.
176 *
177 * @param keymgr A keymgr handle.
178 * @param irq An interrupt request.
179 * @param[out] is_pending Out-param for whether the interrupt is pending.
180 * @return The result of the operation.
181 */
184 const dif_keymgr_t *keymgr,
185 dif_keymgr_irq_t,
186 bool *is_pending);
187
188 /**
189 * Acknowledges all interrupts that were pending at the time of the state
190 * snapshot.
191 *
192 * @param keymgr A keymgr handle.
193 * @param snapshot Interrupt state snapshot.
194 * @return The result of the operation.
195 */
198 const dif_keymgr_t *keymgr,
200
201 /**
202 * Acknowledges all interrupts, indicating to the hardware that all
203 * interrupts have been successfully serviced.
204 *
205 * @param keymgr A keymgr handle.
206 * @return The result of the operation.
207 */
210 const dif_keymgr_t *keymgr
211 );
212
213 /**
214 * Acknowledges a particular interrupt, indicating to the hardware that it has
215 * been successfully serviced.
216 *
217 * @param keymgr A keymgr handle.
218 * @param irq An interrupt request.
219 * @return The result of the operation.
220 */
223 const dif_keymgr_t *keymgr,
224 dif_keymgr_irq_t);
225
226 /**
227 * Forces a particular interrupt, causing it to be serviced as if hardware had
228 * asserted it.
229 *
230 * @param keymgr A keymgr handle.
231 * @param irq An interrupt request.
232 * @param val Value to be set.
233 * @return The result of the operation.
234 */
237 const dif_keymgr_t *keymgr,
238 dif_keymgr_irq_t,
239 const bool val);
240
241 /**
242 * A snapshot of the enablement state of the interrupts for this IP.
243 *
244 * This is an opaque type, to be used with the
245 * `dif_keymgr_irq_disable_all()` and `dif_keymgr_irq_restore_all()`
246 * functions.
247 */
249
250 /**
251 * Checks whether a particular interrupt is currently enabled or disabled.
252 *
253 * @param keymgr A keymgr handle.
254 * @param irq An interrupt request.
255 * @param[out] state Out-param toggle state of the interrupt.
256 * @return The result of the operation.
257 */
260 const dif_keymgr_t *keymgr,
261 dif_keymgr_irq_t,
262 dif_toggle_t *state);
263
264 /**
265 * Sets whether a particular interrupt is currently enabled or disabled.
266 *
267 * @param keymgr A keymgr handle.
268 * @param irq An interrupt request.
269 * @param state The new toggle state for the interrupt.
270 * @return The result of the operation.
271 */
274 const dif_keymgr_t *keymgr,
275 dif_keymgr_irq_t,
276 dif_toggle_t state);
277
278 /**
279 * Disables all interrupts, optionally snapshotting all enable states for later
280 * restoration.
281 *
282 * @param keymgr A keymgr handle.
283 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
284 * @return The result of the operation.
285 */
288 const dif_keymgr_t *keymgr,
290
291 /**
292 * Restores interrupts from the given (enable) snapshot.
293 *
294 * @param keymgr A keymgr handle.
295 * @param snapshot A snapshot to restore from.
296 * @return The result of the operation.
297 */
300 const dif_keymgr_t *keymgr,
301 const dif_keymgr_irq_enable_snapshot_t *snapshot);
302
303
304#ifdef __cplusplus
305} // extern "C"
306#endif // __cplusplus
307
308#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KEYMGR_AUTOGEN_H_