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 #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KEYMGR_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KEYMGR_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/keymgr/">KEYMGR</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 keymgr.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_keymgr {
33  /**
34  * The base address for the keymgr hardware registers.
35  */
37 } dif_keymgr_t;
38 
39 /**
40  * Creates a new handle for a(n) keymgr peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the keymgr peripheral.
45  * @param[out] keymgr Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A keymgr alert type.
53  */
54 typedef enum dif_keymgr_alert {
55  /**
56  * Alert for key manager operation errors. These errors could have been
57  * caused by software
58  */
60  /**
61  * Alert for key manager faults. These errors cannot be caused by software
62  */
65 
66 /**
67  * Forces a particular alert, causing it to be escalated as if the hardware
68  * had raised it.
69  *
70  * @param keymgr A keymgr handle.
71  * @param alert The alert to force.
72  * @return The result of the operation.
73  */
76  dif_keymgr_alert_t alert);
77 
78 /**
79  * A keymgr interrupt request type.
80  */
81 typedef enum dif_keymgr_irq {
82  /**
83  * Operation complete
84  */
87 
88 /**
89  * A snapshot of the state of the interrupts for this IP.
90  *
91  * This is an opaque type, to be used with the `dif_keymgr_irq_get_state()`
92  * and `dif_keymgr_irq_acknowledge_state()` functions.
93  */
95 
96 /**
97  * Returns the type of a given interrupt (i.e., event or status) for this IP.
98  *
99  * @param keymgr A keymgr handle.
100  * @param irq An interrupt request.
101  * @param[out] type Out-param for the interrupt type.
102  * @return The result of the operation.
103  */
106  dif_keymgr_irq_t irq,
107  dif_irq_type_t *type);
108 
109 /**
110  * Returns the state of all interrupts (i.e., pending or not) for this IP.
111  *
112  * @param keymgr A keymgr handle.
113  * @param[out] snapshot Out-param for interrupt state snapshot.
114  * @return The result of the operation.
115  */
118  const dif_keymgr_t *keymgr, dif_keymgr_irq_state_snapshot_t *snapshot);
119 
120 /**
121  * Returns whether a particular interrupt is currently pending.
122  *
123  * @param keymgr A keymgr handle.
124  * @param irq An interrupt request.
125  * @param[out] is_pending Out-param for whether the interrupt is pending.
126  * @return The result of the operation.
127  */
130  dif_keymgr_irq_t irq, bool *is_pending);
131 
132 /**
133  * Acknowledges all interrupts that were pending at the time of the state
134  * snapshot.
135  *
136  * @param keymgr A keymgr handle.
137  * @param snapshot Interrupt state snapshot.
138  * @return The result of the operation.
139  */
142  const dif_keymgr_t *keymgr, dif_keymgr_irq_state_snapshot_t snapshot);
143 
144 /**
145  * Acknowledges all interrupts, indicating to the hardware that all
146  * interrupts have been successfully serviced.
147  *
148  * @param keymgr A keymgr handle.
149  * @return The result of the operation.
150  */
153 
154 /**
155  * Acknowledges a particular interrupt, indicating to the hardware that it has
156  * been successfully serviced.
157  *
158  * @param keymgr A keymgr handle.
159  * @param irq An interrupt request.
160  * @return The result of the operation.
161  */
164  dif_keymgr_irq_t irq);
165 
166 /**
167  * Forces a particular interrupt, causing it to be serviced as if hardware had
168  * asserted it.
169  *
170  * @param keymgr A keymgr handle.
171  * @param irq An interrupt request.
172  * @param val Value to be set.
173  * @return The result of the operation.
174  */
177  dif_keymgr_irq_t irq, const bool val);
178 
179 /**
180  * A snapshot of the enablement state of the interrupts for this IP.
181  *
182  * This is an opaque type, to be used with the
183  * `dif_keymgr_irq_disable_all()` and `dif_keymgr_irq_restore_all()`
184  * functions.
185  */
187 
188 /**
189  * Checks whether a particular interrupt is currently enabled or disabled.
190  *
191  * @param keymgr A keymgr handle.
192  * @param irq An interrupt request.
193  * @param[out] state Out-param toggle state of the interrupt.
194  * @return The result of the operation.
195  */
198  dif_keymgr_irq_t irq,
199  dif_toggle_t *state);
200 
201 /**
202  * Sets whether a particular interrupt is currently enabled or disabled.
203  *
204  * @param keymgr A keymgr handle.
205  * @param irq An interrupt request.
206  * @param state The new toggle state for the interrupt.
207  * @return The result of the operation.
208  */
211  dif_keymgr_irq_t irq,
212  dif_toggle_t state);
213 
214 /**
215  * Disables all interrupts, optionally snapshotting all enable states for later
216  * restoration.
217  *
218  * @param keymgr A keymgr handle.
219  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
220  * @return The result of the operation.
221  */
224  const dif_keymgr_t *keymgr, dif_keymgr_irq_enable_snapshot_t *snapshot);
225 
226 /**
227  * Restores interrupts from the given (enable) snapshot.
228  *
229  * @param keymgr A keymgr handle.
230  * @param snapshot A snapshot to restore from.
231  * @return The result of the operation.
232  */
235  const dif_keymgr_t *keymgr,
236  const dif_keymgr_irq_enable_snapshot_t *snapshot);
237 
238 #ifdef __cplusplus
239 } // extern "C"
240 #endif // __cplusplus
241 
242 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KEYMGR_AUTOGEN_H_