Software APIs
dif_kmac_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_KMAC_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KMAC_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/kmac/">KMAC</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 kmac.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_kmac {
33  /**
34  * The base address for the kmac hardware registers.
35  */
37 } dif_kmac_t;
38 
39 /**
40  * Creates a new handle for a(n) kmac peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the kmac peripheral.
45  * @param[out] kmac Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A kmac alert type.
53  */
54 typedef enum dif_kmac_alert {
55  /**
56  * Alert for KMAC operation error. It occurs when the shadow registers have
57  * update errors.
58  */
60  /**
61  * This fatal alert is triggered when a fatal error is detected inside the
62  * KMAC unit. Examples for such faults include: i) TL-UL bus integrity fault.
63  * ii) Storage errors in the shadow registers. iii) Errors in the message,
64  * round, or key counter. iv) Any internal FSM entering an invalid state. v)
65  * An error in the redundant lfsr. The KMAC unit cannot recover from such an
66  * error and needs to be reset.
67  */
70 
71 /**
72  * Forces a particular alert, causing it to be escalated as if the hardware
73  * had raised it.
74  *
75  * @param kmac A kmac handle.
76  * @param alert The alert to force.
77  * @return The result of the operation.
78  */
81  dif_kmac_alert_t alert);
82 
83 /**
84  * A kmac interrupt request type.
85  */
86 typedef enum dif_kmac_irq {
87  /**
88  * KMAC/SHA3 absorbing has been completed
89  */
91  /**
92  * The message FIFO is empty. This interrupt is raised only if the message
93  * FIFO is actually writable by software, i.e., if all of the following
94  * conditions are met: i) The KMAC block is not exercised by a hardware
95  * application interface. ii) The SHA3 block is in the Absorb state. iii)
96  * Software has not yet written the Process command to finish the absorption
97  * process. For the interrupt to be raised, the message FIFO must also have
98  * been full previously. Otherwise, the hardware empties the FIFO faster than
99  * software can fill it and there is no point in interrupting the software to
100  * inform it about the message FIFO being empty.
101  */
103  /**
104  * KMAC/SHA3 error occurred. ERR_CODE register shows the details
105  */
108 
109 /**
110  * A snapshot of the state of the interrupts for this IP.
111  *
112  * This is an opaque type, to be used with the `dif_kmac_irq_get_state()`
113  * and `dif_kmac_irq_acknowledge_state()` functions.
114  */
116 
117 /**
118  * Returns the type of a given interrupt (i.e., event or status) for this IP.
119  *
120  * @param kmac A kmac handle.
121  * @param irq An interrupt request.
122  * @param[out] type Out-param for the interrupt type.
123  * @return The result of the operation.
124  */
127  dif_irq_type_t *type);
128 
129 /**
130  * Returns the state of all interrupts (i.e., pending or not) for this IP.
131  *
132  * @param kmac A kmac handle.
133  * @param[out] snapshot Out-param for interrupt state snapshot.
134  * @return The result of the operation.
135  */
139 
140 /**
141  * Returns whether a particular interrupt is currently pending.
142  *
143  * @param kmac A kmac handle.
144  * @param irq An interrupt request.
145  * @param[out] is_pending Out-param for whether the interrupt is pending.
146  * @return The result of the operation.
147  */
150  bool *is_pending);
151 
152 /**
153  * Acknowledges all interrupts that were pending at the time of the state
154  * snapshot.
155  *
156  * @param kmac A kmac handle.
157  * @param snapshot Interrupt state snapshot.
158  * @return The result of the operation.
159  */
162  const dif_kmac_t *kmac, dif_kmac_irq_state_snapshot_t snapshot);
163 
164 /**
165  * Acknowledges all interrupts, indicating to the hardware that all
166  * interrupts have been successfully serviced.
167  *
168  * @param kmac A kmac handle.
169  * @return The result of the operation.
170  */
173 
174 /**
175  * Acknowledges a particular interrupt, indicating to the hardware that it has
176  * been successfully serviced.
177  *
178  * @param kmac A kmac handle.
179  * @param irq An interrupt request.
180  * @return The result of the operation.
181  */
184  dif_kmac_irq_t irq);
185 
186 /**
187  * Forces a particular interrupt, causing it to be serviced as if hardware had
188  * asserted it.
189  *
190  * @param kmac A kmac handle.
191  * @param irq An interrupt request.
192  * @param val Value to be set.
193  * @return The result of the operation.
194  */
197  const bool val);
198 
199 /**
200  * A snapshot of the enablement state of the interrupts for this IP.
201  *
202  * This is an opaque type, to be used with the
203  * `dif_kmac_irq_disable_all()` and `dif_kmac_irq_restore_all()`
204  * functions.
205  */
207 
208 /**
209  * Checks whether a particular interrupt is currently enabled or disabled.
210  *
211  * @param kmac A kmac handle.
212  * @param irq An interrupt request.
213  * @param[out] state Out-param toggle state of the interrupt.
214  * @return The result of the operation.
215  */
218  dif_kmac_irq_t irq, dif_toggle_t *state);
219 
220 /**
221  * Sets whether a particular interrupt is currently enabled or disabled.
222  *
223  * @param kmac A kmac handle.
224  * @param irq An interrupt request.
225  * @param state The new toggle state for the interrupt.
226  * @return The result of the operation.
227  */
230  dif_kmac_irq_t irq, dif_toggle_t state);
231 
232 /**
233  * Disables all interrupts, optionally snapshotting all enable states for later
234  * restoration.
235  *
236  * @param kmac A kmac handle.
237  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
238  * @return The result of the operation.
239  */
243 
244 /**
245  * Restores interrupts from the given (enable) snapshot.
246  *
247  * @param kmac A kmac handle.
248  * @param snapshot A snapshot to restore from.
249  * @return The result of the operation.
250  */
253  const dif_kmac_t *kmac, const dif_kmac_irq_enable_snapshot_t *snapshot);
254 
255 #ifdef __cplusplus
256 } // extern "C"
257 #endif // __cplusplus
258 
259 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_KMAC_AUTOGEN_H_