Software APIs
dif_hmac_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_HMAC_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_HMAC_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/hmac/">HMAC</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 hmac.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_hmac {
33  /**
34  * The base address for the hmac hardware registers.
35  */
37 } dif_hmac_t;
38 
39 /**
40  * Creates a new handle for a(n) hmac peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the hmac peripheral.
45  * @param[out] hmac Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A hmac alert type.
53  */
54 typedef enum dif_hmac_alert {
55  /**
56  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57  * detected.
58  */
61 
62 /**
63  * Forces a particular alert, causing it to be escalated as if the hardware
64  * had raised it.
65  *
66  * @param hmac A hmac handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72  dif_hmac_alert_t alert);
73 
74 /**
75  * A hmac interrupt request type.
76  */
77 typedef enum dif_hmac_irq {
78  /**
79  * HMAC/SHA-2 has completed.
80  */
82  /**
83  * The message FIFO is empty. This interrupt is raised only if the message
84  * FIFO is actually writable by software, i.e., if all of the following
85  * conditions are met: i) The HMAC block is not running in HMAC mode and
86  * performing the second round of computing the final hash of the outer key as
87  * well as the result of the first round using the inner key. ii) Software has
88  * not yet written the Process or Stop command to finish the hashing
89  * operation. For the interrupt to be raised, the message FIFO must also have
90  * been full previously. Otherwise, the hardware empties the FIFO faster than
91  * software can fill it and there is no point in interrupting the software to
92  * inform it about the message FIFO being empty.
93  */
95  /**
96  * HMAC error has occurred. ERR_CODE register shows which error occurred.
97  */
100 
101 /**
102  * A snapshot of the state of the interrupts for this IP.
103  *
104  * This is an opaque type, to be used with the `dif_hmac_irq_get_state()`
105  * and `dif_hmac_irq_acknowledge_state()` functions.
106  */
108 
109 /**
110  * Returns the type of a given interrupt (i.e., event or status) for this IP.
111  *
112  * @param hmac A hmac handle.
113  * @param irq An interrupt request.
114  * @param[out] type Out-param for the interrupt type.
115  * @return The result of the operation.
116  */
119  dif_irq_type_t *type);
120 
121 /**
122  * Returns the state of all interrupts (i.e., pending or not) for this IP.
123  *
124  * @param hmac A hmac handle.
125  * @param[out] snapshot Out-param for interrupt state snapshot.
126  * @return The result of the operation.
127  */
131 
132 /**
133  * Returns whether a particular interrupt is currently pending.
134  *
135  * @param hmac A hmac handle.
136  * @param irq An interrupt request.
137  * @param[out] is_pending Out-param for whether the interrupt is pending.
138  * @return The result of the operation.
139  */
142  bool *is_pending);
143 
144 /**
145  * Acknowledges all interrupts that were pending at the time of the state
146  * snapshot.
147  *
148  * @param hmac A hmac handle.
149  * @param snapshot Interrupt state snapshot.
150  * @return The result of the operation.
151  */
154  const dif_hmac_t *hmac, dif_hmac_irq_state_snapshot_t snapshot);
155 
156 /**
157  * Acknowledges all interrupts, indicating to the hardware that all
158  * interrupts have been successfully serviced.
159  *
160  * @param hmac A hmac handle.
161  * @return The result of the operation.
162  */
165 
166 /**
167  * Acknowledges a particular interrupt, indicating to the hardware that it has
168  * been successfully serviced.
169  *
170  * @param hmac A hmac handle.
171  * @param irq An interrupt request.
172  * @return The result of the operation.
173  */
176  dif_hmac_irq_t irq);
177 
178 /**
179  * Forces a particular interrupt, causing it to be serviced as if hardware had
180  * asserted it.
181  *
182  * @param hmac A hmac handle.
183  * @param irq An interrupt request.
184  * @param val Value to be set.
185  * @return The result of the operation.
186  */
189  const bool val);
190 
191 /**
192  * A snapshot of the enablement state of the interrupts for this IP.
193  *
194  * This is an opaque type, to be used with the
195  * `dif_hmac_irq_disable_all()` and `dif_hmac_irq_restore_all()`
196  * functions.
197  */
199 
200 /**
201  * Checks whether a particular interrupt is currently enabled or disabled.
202  *
203  * @param hmac A hmac handle.
204  * @param irq An interrupt request.
205  * @param[out] state Out-param toggle state of the interrupt.
206  * @return The result of the operation.
207  */
210  dif_hmac_irq_t irq, dif_toggle_t *state);
211 
212 /**
213  * Sets whether a particular interrupt is currently enabled or disabled.
214  *
215  * @param hmac A hmac handle.
216  * @param irq An interrupt request.
217  * @param state The new toggle state for the interrupt.
218  * @return The result of the operation.
219  */
222  dif_hmac_irq_t irq, dif_toggle_t state);
223 
224 /**
225  * Disables all interrupts, optionally snapshotting all enable states for later
226  * restoration.
227  *
228  * @param hmac A hmac handle.
229  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
230  * @return The result of the operation.
231  */
235 
236 /**
237  * Restores interrupts from the given (enable) snapshot.
238  *
239  * @param hmac A hmac handle.
240  * @param snapshot A snapshot to restore from.
241  * @return The result of the operation.
242  */
245  const dif_hmac_t *hmac, const dif_hmac_irq_enable_snapshot_t *snapshot);
246 
247 #ifdef __cplusplus
248 } // extern "C"
249 #endif // __cplusplus
250 
251 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_HMAC_AUTOGEN_H_