Software APIs
dt_keymgr.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_KEYMGR_H_
8
#define OPENTITAN_DT_KEYMGR_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP keymgr and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the keymgr.
19
*/
20
21
#include "hw/top/dt/dt_api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_keymgr
{
30
kDtKeymgr
= 0,
/**< keymgr */
31
kDtKeymgrFirst = 0,
/**< \internal First instance */
32
kDtKeymgrCount = 1,
/**< \internal Number of instances */
33
}
dt_keymgr_t
;
34
35
/**
36
* List of register blocks.
37
*
38
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39
*/
40
typedef
enum
dt_keymgr_reg_block
{
41
kDtKeymgrRegBlockCore = 0,
/**< */
42
kDtKeymgrRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_keymgr_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_keymgr_reg_block_t
kDtKeymgrRegBlockPrimary = kDtKeymgrRegBlockCore;
47
48
/**
49
* List of memories.
50
*
51
* Memories are guaranteed to start at 0 and to be consecutively numbered.
52
*/
53
typedef
enum
dt_keymgr_memory
{
54
kDtKeymgrMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_keymgr_memory_t
;
56
57
/**
58
* List of IRQs.
59
*
60
* IRQs are guaranteed to be numbered consecutively from 0.
61
*/
62
typedef
enum
dt_keymgr_irq
{
63
kDtKeymgrIrqOpDone
= 0,
/**< Operation complete */
64
kDtKeymgrIrqCount = 1,
/**< \internal Number of IRQs */
65
}
dt_keymgr_irq_t
;
66
67
/**
68
* List of Alerts.
69
*
70
* Alerts are guaranteed to be numbered consecutively from 0.
71
*/
72
typedef
enum
dt_keymgr_alert
{
73
kDtKeymgrAlertRecovOperationErr
= 0,
/**< Alert for key manager operation errors. These errors could have been caused by
74
software */
75
kDtKeymgrAlertFatalFaultErr
= 1,
/**< Alert for key manager faults. These errors cannot be caused by software */
76
kDtKeymgrAlertCount = 2,
/**< \internal Number of Alerts */
77
}
dt_keymgr_alert_t
;
78
79
/**
80
* List of clock ports.
81
*
82
* Clock ports are guaranteed to be numbered consecutively from 0.
83
*/
84
typedef
enum
dt_keymgr_clock
{
85
kDtKeymgrClockClk
= 0,
/**< Clock port clk_i */
86
kDtKeymgrClockEdn
= 1,
/**< Clock port clk_edn_i */
87
kDtKeymgrClockCount = 2,
/**< \internal Number of clock ports */
88
}
dt_keymgr_clock_t
;
89
90
/**
91
* List of reset ports.
92
*
93
* Reset ports are guaranteed to be numbered consecutively from 0.
94
*/
95
typedef
enum
dt_keymgr_reset
{
96
kDtKeymgrResetRst
= 0,
/**< Reset port rst_ni */
97
kDtKeymgrResetEdn
= 1,
/**< Reset port rst_edn_ni */
98
kDtKeymgrResetCount = 2,
/**< \internal Number of reset ports */
99
}
dt_keymgr_reset_t
;
100
101
/**
102
* List of supported hardware features.
103
*/
104
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_KMAC 1
105
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_AES 1
106
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_OTBN 1
107
#define OPENTITAN_KEYMGR_HAS_DERIVE_ATTESTATION 1
108
#define OPENTITAN_KEYMGR_HAS_DERIVE_SEALING 1
109
#define OPENTITAN_KEYMGR_HAS_GENERATE_OUTPUT 1
110
#define OPENTITAN_KEYMGR_HAS_GENERATE_IDENTITY 1
111
#define OPENTITAN_KEYMGR_HAS_KEY_VERSIONING 1
112
113
114
115
/**
116
* Get the keymgr instance from an instance ID
117
*
118
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
119
*
120
* @param inst_id Instance ID.
121
* @return A keymgr instance.
122
*
123
* **Note:** This function only makes sense if the instance ID has device type keymgr,
124
* otherwise the returned value is unspecified.
125
*/
126
dt_keymgr_t
dt_keymgr_from_instance_id
(
dt_instance_id_t
inst_id);
127
128
/**
129
* Get the instance ID of an instance.
130
*
131
* @param dt Instance of keymgr.
132
* @return The instance ID of that instance.
133
*/
134
dt_instance_id_t
dt_keymgr_instance_id
(
dt_keymgr_t
dt);
135
136
/**
137
* Get the register base address of an instance.
138
*
139
* @param dt Instance of keymgr.
140
* @param reg_block The register block requested.
141
* @return The register base address of the requested block.
142
*/
143
uint32_t
dt_keymgr_reg_block
(
144
dt_keymgr_t
dt,
145
dt_keymgr_reg_block_t
reg_block);
146
147
/**
148
* Get the primary register base address of an instance.
149
*
150
* This is just a convenience function, equivalent to
151
* `dt_keymgr_reg_block(dt, kDtKeymgrRegBlockCore)`
152
*
153
* @param dt Instance of keymgr.
154
* @return The register base address of the primary register block.
155
*/
156
static
inline
uint32_t dt_keymgr_primary_reg_block(
157
dt_keymgr_t
dt) {
158
return
dt_keymgr_reg_block
(dt, kDtKeymgrRegBlockCore);
159
}
160
161
/**
162
* Get the base address of a memory.
163
*
164
* @param dt Instance of keymgr.
165
* @param mem The memory requested.
166
* @return The base address of the requested memory.
167
*/
168
uint32_t
dt_keymgr_memory_base
(
169
dt_keymgr_t
dt,
170
dt_keymgr_memory_t
mem);
171
172
/**
173
* Get the size of a memory.
174
*
175
* @param dt Instance of keymgr.
176
* @param mem The memory requested.
177
* @return The size of the requested memory.
178
*/
179
uint32_t
dt_keymgr_memory_size
(
180
dt_keymgr_t
dt,
181
dt_keymgr_memory_t
mem);
182
183
/**
184
* Get the PLIC ID of a keymgr IRQ for a given instance.
185
*
186
* If the instance is not connected to the PLIC, this function
187
* will return `kDtPlicIrqIdNone`.
188
*
189
* @param dt Instance of keymgr.
190
* @param irq A keymgr IRQ.
191
* @return The PLIC ID of the IRQ of this instance.
192
*/
193
dt_plic_irq_id_t
dt_keymgr_irq_to_plic_id
(
194
dt_keymgr_t
dt,
195
dt_keymgr_irq_t
irq);
196
197
/**
198
* Convert a global IRQ ID to a local keymgr IRQ type.
199
*
200
* @param dt Instance of keymgr.
201
* @param irq A PLIC ID that belongs to this instance.
202
* @return The keymgr IRQ, or `kDtKeymgrIrqCount`.
203
*
204
* **Note:** This function assumes that the PLIC ID belongs to the instance
205
* of keymgr passed in parameter. In other words, it must be the case that
206
* `dt_keymgr_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
207
* will return `kDtKeymgrIrqCount`.
208
*/
209
dt_keymgr_irq_t
dt_keymgr_irq_from_plic_id
(
210
dt_keymgr_t
dt,
211
dt_plic_irq_id_t
irq);
212
213
214
/**
215
* Get the alert ID of a keymgr alert for a given instance.
216
*
217
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
218
* instances where the instance is not connected, the return value is unspecified.
219
*
220
* @param dt Instance of keymgr.
221
* @param alert A keymgr alert.
222
* @return The Alert Handler alert ID of the alert of this instance.
223
*/
224
dt_alert_id_t
dt_keymgr_alert_to_alert_id
(
225
dt_keymgr_t
dt,
226
dt_keymgr_alert_t
alert);
227
228
/**
229
* Convert a global alert ID to a local keymgr alert type.
230
*
231
* @param dt Instance of keymgr.
232
* @param alert A global alert ID that belongs to this instance.
233
* @return The keymgr alert, or `kDtKeymgrAlertCount`.
234
*
235
* **Note:** This function assumes that the global alert ID belongs to the
236
* instance of keymgr passed in parameter. In other words, it must be the case
237
* that `dt_keymgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
238
* this function will return `kDtKeymgrAlertCount`.
239
*/
240
dt_keymgr_alert_t
dt_keymgr_alert_from_alert_id
(
241
dt_keymgr_t
dt,
242
dt_alert_id_t
alert);
243
244
245
246
/**
247
* Get the clock signal connected to a clock port of an instance.
248
*
249
* @param dt Instance of keymgr.
250
* @param clk Clock port.
251
* @return Clock signal.
252
*/
253
dt_clock_t
dt_keymgr_clock
(
254
dt_keymgr_t
dt,
255
dt_keymgr_clock_t
clk);
256
257
/**
258
* Get the reset signal connected to a reset port of an instance.
259
*
260
* @param dt Instance of keymgr.
261
* @param rst Reset port.
262
* @return Reset signal.
263
*/
264
dt_reset_t
dt_keymgr_reset
(
265
dt_keymgr_t
dt,
266
dt_keymgr_reset_t
rst);
267
268
269
270
#ifdef __cplusplus
271
}
// extern "C"
272
#endif
// __cplusplus
273
274
#endif
// OPENTITAN_DT_KEYMGR_H_
(earlgrey)
hw
top
dt
dt_keymgr.h
Return to
OpenTitan Documentation