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
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_HMAC_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_HMAC_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/hmac/data/hmac.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/hmac/">HMAC</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "hw/top/dt/hmac.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to hmac.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_hmac {
38 /**
39 * The base address for the hmac hardware registers.
40 */
42 /**
43 * The instance, set to `kDtHmacCount` if not initialized
44 * through `dif_hmac_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) hmac peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the hmac peripheral.
55 * @param[out] hmac 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_hmac_t *hmac);
65
66/**
67 * Creates a new handle for a(n) hmac peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] hmac Out param for the initialized handle.
73 * @return The result of the operation.
74 */
77 dt_hmac_t dt,
78 dif_hmac_t *hmac);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_hmac_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param hmac A hmac handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_hmac_t *hmac,
93 dt_hmac_t *dt);
94
95 /**
96 * A hmac alert type.
97 */
98 typedef enum dif_hmac_alert {
99 /**
100 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
101 */
104
105 /**
106 * Forces a particular alert, causing it to be escalated as if the hardware
107 * had raised it.
108 *
109 * @param hmac A hmac handle.
110 * @param alert The alert to force.
111 * @return The result of the operation.
112 */
115 const dif_hmac_t *hmac,
116 dif_hmac_alert_t alert);
117
118 // DEPRECATED This typedef exists solely for the transition to
119 // dt-based interrupt numbers and will be removed in the future.
120 typedef dt_hmac_irq_t dif_hmac_irq_t;
121
122 /**
123 * A hmac interrupt request type.
124 *
125 * DEPRECATED Use `dt_hmac_irq_t` instead.
126 * This enumeration exists solely for the transition to
127 * dt-based interrupt numbers and will be removed in the future.
128 *
129 * The following are defines to keep the types consistent with DT.
130 */
131 /**
132 * HMAC/SHA-2 has completed.
133 */
134#define kDifHmacIrqHmacDone kDtHmacIrqHmacDone
135 /**
136 * The message FIFO is empty. This interrupt is raised only if the message FIFO is actually writable by software, i.e., if all of the following conditions are met: i) The HMAC block is not running in HMAC mode and performing the second round of computing the final hash of the outer key as well as the result of the first round using the inner key. ii) Software has not yet written the Process or Stop command to finish the hashing operation. For the interrupt to be raised, the message FIFO must also have been full previously. Otherwise, the hardware empties the FIFO faster than software can fill it and there is no point in interrupting the software to inform it about the message FIFO being empty.
137 */
138#define kDifHmacIrqFifoEmpty kDtHmacIrqFifoEmpty
139 /**
140 * HMAC error has occurred. ERR_CODE register shows which error occurred.
141 */
142#define kDifHmacIrqHmacErr kDtHmacIrqHmacErr
143
144 /**
145 * A snapshot of the state of the interrupts for this IP.
146 *
147 * This is an opaque type, to be used with the `dif_hmac_irq_get_state()`
148 * and `dif_hmac_irq_acknowledge_state()` functions.
149 */
151
152 /**
153 * Returns the type of a given interrupt (i.e., event or status) for this IP.
154 *
155 * @param hmac A hmac handle.
156 * @param irq An interrupt request.
157 * @param[out] type Out-param for the interrupt type.
158 * @return The result of the operation.
159 */
162 const dif_hmac_t *hmac,
163 dif_hmac_irq_t,
164 dif_irq_type_t *type);
165
166 /**
167 * Returns the state of all interrupts (i.e., pending or not) for this IP.
168 *
169 * @param hmac A hmac handle.
170 * @param[out] snapshot Out-param for interrupt state snapshot.
171 * @return The result of the operation.
172 */
175 const dif_hmac_t *hmac,
177
178 /**
179 * Returns whether a particular interrupt is currently pending.
180 *
181 * @param hmac A hmac handle.
182 * @param irq An interrupt request.
183 * @param[out] is_pending Out-param for whether the interrupt is pending.
184 * @return The result of the operation.
185 */
188 const dif_hmac_t *hmac,
189 dif_hmac_irq_t,
190 bool *is_pending);
191
192 /**
193 * Acknowledges all interrupts that were pending at the time of the state
194 * snapshot.
195 *
196 * @param hmac A hmac handle.
197 * @param snapshot Interrupt state snapshot.
198 * @return The result of the operation.
199 */
202 const dif_hmac_t *hmac,
204
205 /**
206 * Acknowledges all interrupts, indicating to the hardware that all
207 * interrupts have been successfully serviced.
208 *
209 * @param hmac A hmac handle.
210 * @return The result of the operation.
211 */
214 const dif_hmac_t *hmac
215 );
216
217 /**
218 * Acknowledges a particular interrupt, indicating to the hardware that it has
219 * been successfully serviced.
220 *
221 * @param hmac A hmac handle.
222 * @param irq An interrupt request.
223 * @return The result of the operation.
224 */
227 const dif_hmac_t *hmac,
228 dif_hmac_irq_t);
229
230 /**
231 * Forces a particular interrupt, causing it to be serviced as if hardware had
232 * asserted it.
233 *
234 * @param hmac A hmac handle.
235 * @param irq An interrupt request.
236 * @param val Value to be set.
237 * @return The result of the operation.
238 */
241 const dif_hmac_t *hmac,
242 dif_hmac_irq_t,
243 const bool val);
244
245 /**
246 * A snapshot of the enablement state of the interrupts for this IP.
247 *
248 * This is an opaque type, to be used with the
249 * `dif_hmac_irq_disable_all()` and `dif_hmac_irq_restore_all()`
250 * functions.
251 */
253
254 /**
255 * Checks whether a particular interrupt is currently enabled or disabled.
256 *
257 * @param hmac A hmac handle.
258 * @param irq An interrupt request.
259 * @param[out] state Out-param toggle state of the interrupt.
260 * @return The result of the operation.
261 */
264 const dif_hmac_t *hmac,
265 dif_hmac_irq_t,
266 dif_toggle_t *state);
267
268 /**
269 * Sets whether a particular interrupt is currently enabled or disabled.
270 *
271 * @param hmac A hmac handle.
272 * @param irq An interrupt request.
273 * @param state The new toggle state for the interrupt.
274 * @return The result of the operation.
275 */
278 const dif_hmac_t *hmac,
279 dif_hmac_irq_t,
280 dif_toggle_t state);
281
282 /**
283 * Disables all interrupts, optionally snapshotting all enable states for later
284 * restoration.
285 *
286 * @param hmac A hmac handle.
287 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
288 * @return The result of the operation.
289 */
292 const dif_hmac_t *hmac,
294
295 /**
296 * Restores interrupts from the given (enable) snapshot.
297 *
298 * @param hmac A hmac handle.
299 * @param snapshot A snapshot to restore from.
300 * @return The result of the operation.
301 */
304 const dif_hmac_t *hmac,
305 const dif_hmac_irq_enable_snapshot_t *snapshot);
306
307
308#ifdef __cplusplus
309} // extern "C"
310#endif // __cplusplus
311
312#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_HMAC_AUTOGEN_H_