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