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