Software APIs
dt_aes.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// Device table API auto-generated by `dtgen`
6
7#ifndef OPENTITAN_DT_AES_H_
8#define OPENTITAN_DT_AES_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP aes and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the aes.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_aes {
30 kDtAes = 0, /**< aes */
31 kDtAesFirst = 0, /**< \internal First instance */
32 kDtAesCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
40typedef enum dt_aes_reg_block {
41 kDtAesRegBlockCore = 0, /**< */
42 kDtAesRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_aes_reg_block_t kDtAesRegBlockPrimary = kDtAesRegBlockCore;
47
48/**
49 * List of memories.
50 *
51 * Memories are guaranteed to start at 0 and to be consecutively numbered.
52 */
53typedef enum dt_aes_memory {
54 kDtAesMemoryCount = 0, /**< \internal Number of memories */
56
57/**
58 * List of Alerts.
59 *
60 * Alerts are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_aes_alert {
63 kDtAesAlertRecovCtrlUpdateErr = 0, /**< This recoverable alert is triggered upon detecting an update error in the shadowed Control Register.
64The content of the Control Register is not modified (See Control Register).
65The AES unit can be recovered from such a condition by restarting the AES operation, i.e., by re-writing the Control Register.
66This should be monitored by the system. */
67 kDtAesAlertFatalFault = 1, /**< This fatal alert is triggered upon detecting a fatal fault inside the AES unit.
68Examples for such faults include
69i) storage errors in the shadowed Control Register,
70ii) any internal FSM entering an invalid state,
71iii) any sparsely encoded signal taking on an invalid value,
72iv) errors in the internal round counter,
73v) escalations triggered by the life cycle controller, and
74vi) fatal integrity failures on the TL-UL bus.
75The AES unit cannot recover from such an error and needs to be reset. */
76 kDtAesAlertCount = 2, /**< \internal Number of Alerts */
78
79/**
80 * List of clock ports.
81 *
82 * Clock ports are guaranteed to be numbered consecutively from 0.
83 */
84typedef enum dt_aes_clock {
85 kDtAesClockClk = 0, /**< Clock port clk_i */
86 kDtAesClockEdn = 1, /**< Clock port clk_edn_i */
87 kDtAesClockCount = 2, /**< \internal Number of clock ports */
89
90/**
91 * List of reset ports.
92 *
93 * Reset ports are guaranteed to be numbered consecutively from 0.
94 */
95typedef enum dt_aes_reset {
96 kDtAesResetRst = 0, /**< Reset port rst_ni */
97 kDtAesResetEdn = 1, /**< Reset port rst_edn_ni */
98 kDtAesResetCount = 2, /**< \internal Number of reset ports */
100
101/**
102 * List of supported hardware features.
103 */
104#define OPENTITAN_AES_HAS_KEY_LEN_128 1
105#define OPENTITAN_AES_HAS_KEY_LEN_192 1
106#define OPENTITAN_AES_HAS_KEY_LEN_256 1
107#define OPENTITAN_AES_HAS_MODE_ECB 1
108#define OPENTITAN_AES_HAS_MODE_CBC 1
109#define OPENTITAN_AES_HAS_MODE_CFB_128 1
110#define OPENTITAN_AES_HAS_MODE_OFB 1
111#define OPENTITAN_AES_HAS_MODE_CTR 1
112#define OPENTITAN_AES_HAS_KEY_SIDELOAD 1
113#define OPENTITAN_AES_HAS_CLEAR_DATA_OUT 1
114#define OPENTITAN_AES_HAS_CLEAR_KEY_IV_DATA_IN 1
115#define OPENTITAN_AES_HAS_PRNG_RESEED_RATE 1
116#define OPENTITAN_AES_HAS_PRNG_KEY_TOUCH_FORCES_RESEED 1
117#define OPENTITAN_AES_HAS_PRNG_FORCE_MASKS 1
118#define OPENTITAN_AES_HAS_MANUAL_OPERATION 1
119
120
121
122/**
123 * Get the aes instance from an instance ID
124 *
125 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
126 *
127 * @param inst_id Instance ID.
128 * @return A aes instance.
129 *
130 * **Note:** This function only makes sense if the instance ID has device type aes,
131 * otherwise the returned value is unspecified.
132 */
134
135/**
136 * Get the instance ID of an instance.
137 *
138 * @param dt Instance of aes.
139 * @return The instance ID of that instance.
140 */
142
143/**
144 * Get the register base address of an instance.
145 *
146 * @param dt Instance of aes.
147 * @param reg_block The register block requested.
148 * @return The register base address of the requested block.
149 */
150uint32_t dt_aes_reg_block(
151 dt_aes_t dt,
152 dt_aes_reg_block_t reg_block);
153
154/**
155 * Get the primary register base address of an instance.
156 *
157 * This is just a convenience function, equivalent to
158 * `dt_aes_reg_block(dt, kDtAesRegBlockCore)`
159 *
160 * @param dt Instance of aes.
161 * @return The register base address of the primary register block.
162 */
163static inline uint32_t dt_aes_primary_reg_block(
164 dt_aes_t dt) {
165 return dt_aes_reg_block(dt, kDtAesRegBlockCore);
166}
167
168/**
169 * Get the base address of a memory.
170 *
171 * @param dt Instance of aes.
172 * @param mem The memory requested.
173 * @return The base address of the requested memory.
174 */
175uint32_t dt_aes_memory_base(
176 dt_aes_t dt,
177 dt_aes_memory_t mem);
178
179/**
180 * Get the size of a memory.
181 *
182 * @param dt Instance of aes.
183 * @param mem The memory requested.
184 * @return The size of the requested memory.
185 */
186uint32_t dt_aes_memory_size(
187 dt_aes_t dt,
188 dt_aes_memory_t mem);
189
190
191/**
192 * Get the alert ID of a aes alert for a given instance.
193 *
194 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
195 * instances where the instance is not connected, the return value is unspecified.
196 *
197 * @param dt Instance of aes.
198 * @param alert A aes alert.
199 * @return The Alert Handler alert ID of the alert of this instance.
200 */
202 dt_aes_t dt,
203 dt_aes_alert_t alert);
204
205/**
206 * Convert a global alert ID to a local aes alert type.
207 *
208 * @param dt Instance of aes.
209 * @param alert A global alert ID that belongs to this instance.
210 * @return The aes alert, or `kDtAesAlertCount`.
211 *
212 * **Note:** This function assumes that the global alert ID belongs to the
213 * instance of aes passed in parameter. In other words, it must be the case
214 * that `dt_aes_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
215 * this function will return `kDtAesAlertCount`.
216 */
218 dt_aes_t dt,
219 dt_alert_id_t alert);
220
221
222
223/**
224 * Get the clock signal connected to a clock port of an instance.
225 *
226 * @param dt Instance of aes.
227 * @param clk Clock port.
228 * @return Clock signal.
229 */
231 dt_aes_t dt,
232 dt_aes_clock_t clk);
233
234/**
235 * Get the reset signal connected to a reset port of an instance.
236 *
237 * @param dt Instance of aes.
238 * @param rst Reset port.
239 * @return Reset signal.
240 */
242 dt_aes_t dt,
243 dt_aes_reset_t rst);
244
245
246
247#ifdef __cplusplus
248} // extern "C"
249#endif // __cplusplus
250
251#endif // OPENTITAN_DT_AES_H_