Software APIs
dt_rv_plic.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_RV_PLIC_H_
8
#define OPENTITAN_DT_RV_PLIC_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP rv_plic and top darjeeling.
17
*
18
* This file contains the type definitions and global functions of the rv_plic.
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_rv_plic
{
30
kDtRvPlic
= 0,
/**< rv_plic */
31
kDtRvPlicFirst = 0,
/**< \internal First instance */
32
kDtRvPlicCount = 1,
/**< \internal Number of instances */
33
}
dt_rv_plic_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_rv_plic_reg_block
{
41
kDtRvPlicRegBlockCore = 0,
/**< */
42
kDtRvPlicRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_rv_plic_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_rv_plic_reg_block_t
kDtRvPlicRegBlockPrimary = kDtRvPlicRegBlockCore;
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_rv_plic_memory
{
54
kDtRvPlicMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_rv_plic_memory_t
;
56
57
/**
58
* List of Alerts.
59
*
60
* Alerts are guaranteed to be numbered consecutively from 0.
61
*/
62
typedef
enum
dt_rv_plic_alert
{
63
kDtRvPlicAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
64
kDtRvPlicAlertCount = 1,
/**< \internal Number of Alerts */
65
}
dt_rv_plic_alert_t
;
66
67
/**
68
* List of clock ports.
69
*
70
* Clock ports are guaranteed to be numbered consecutively from 0.
71
*/
72
typedef
enum
dt_rv_plic_clock
{
73
kDtRvPlicClockClk
= 0,
/**< Clock port clk_i */
74
kDtRvPlicClockCount = 1,
/**< \internal Number of clock ports */
75
}
dt_rv_plic_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_rv_plic_reset
{
83
kDtRvPlicResetRst
= 0,
/**< Reset port rst_ni */
84
kDtRvPlicResetCount = 1,
/**< \internal Number of reset ports */
85
}
dt_rv_plic_reset_t
;
86
87
/**
88
* List of supported hardware features.
89
*/
90
#define OPENTITAN_RV_PLIC_HAS_PRIORITY 1
91
#define OPENTITAN_RV_PLIC_HAS_ENABLE 1
92
93
94
95
/**
96
* Get the rv_plic instance from an instance ID
97
*
98
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
99
*
100
* @param inst_id Instance ID.
101
* @return A rv_plic instance.
102
*
103
* **Note:** This function only makes sense if the instance ID has device type rv_plic,
104
* otherwise the returned value is unspecified.
105
*/
106
dt_rv_plic_t
dt_rv_plic_from_instance_id
(
dt_instance_id_t
inst_id);
107
108
/**
109
* Get the instance ID of an instance.
110
*
111
* @param dt Instance of rv_plic.
112
* @return The instance ID of that instance.
113
*/
114
dt_instance_id_t
dt_rv_plic_instance_id
(
dt_rv_plic_t
dt);
115
116
/**
117
* Get the register base address of an instance.
118
*
119
* @param dt Instance of rv_plic.
120
* @param reg_block The register block requested.
121
* @return The register base address of the requested block.
122
*/
123
uint32_t
dt_rv_plic_reg_block
(
124
dt_rv_plic_t
dt,
125
dt_rv_plic_reg_block_t
reg_block);
126
127
/**
128
* Get the primary register base address of an instance.
129
*
130
* This is just a convenience function, equivalent to
131
* `dt_rv_plic_reg_block(dt, kDtRvPlicRegBlockCore)`
132
*
133
* @param dt Instance of rv_plic.
134
* @return The register base address of the primary register block.
135
*/
136
static
inline
uint32_t dt_rv_plic_primary_reg_block(
137
dt_rv_plic_t
dt) {
138
return
dt_rv_plic_reg_block
(dt, kDtRvPlicRegBlockCore);
139
}
140
141
/**
142
* Get the base address of a memory.
143
*
144
* @param dt Instance of rv_plic.
145
* @param mem The memory requested.
146
* @return The base address of the requested memory.
147
*/
148
uint32_t
dt_rv_plic_memory_base
(
149
dt_rv_plic_t
dt,
150
dt_rv_plic_memory_t
mem);
151
152
/**
153
* Get the size of a memory.
154
*
155
* @param dt Instance of rv_plic.
156
* @param mem The memory requested.
157
* @return The size of the requested memory.
158
*/
159
uint32_t
dt_rv_plic_memory_size
(
160
dt_rv_plic_t
dt,
161
dt_rv_plic_memory_t
mem);
162
163
164
/**
165
* Get the alert ID of a rv_plic alert for a given instance.
166
*
167
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
168
* instances where the instance is not connected, the return value is unspecified.
169
*
170
* @param dt Instance of rv_plic.
171
* @param alert A rv_plic alert.
172
* @return The Alert Handler alert ID of the alert of this instance.
173
*/
174
dt_alert_id_t
dt_rv_plic_alert_to_alert_id
(
175
dt_rv_plic_t
dt,
176
dt_rv_plic_alert_t
alert);
177
178
/**
179
* Convert a global alert ID to a local rv_plic alert type.
180
*
181
* @param dt Instance of rv_plic.
182
* @param alert A global alert ID that belongs to this instance.
183
* @return The rv_plic alert, or `kDtRvPlicAlertCount`.
184
*
185
* **Note:** This function assumes that the global alert ID belongs to the
186
* instance of rv_plic passed in parameter. In other words, it must be the case
187
* that `dt_rv_plic_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
188
* this function will return `kDtRvPlicAlertCount`.
189
*/
190
dt_rv_plic_alert_t
dt_rv_plic_alert_from_alert_id
(
191
dt_rv_plic_t
dt,
192
dt_alert_id_t
alert);
193
194
195
196
/**
197
* Get the clock signal connected to a clock port of an instance.
198
*
199
* @param dt Instance of rv_plic.
200
* @param clk Clock port.
201
* @return Clock signal.
202
*/
203
dt_clock_t
dt_rv_plic_clock
(
204
dt_rv_plic_t
dt,
205
dt_rv_plic_clock_t
clk);
206
207
/**
208
* Get the reset signal connected to a reset port of an instance.
209
*
210
* @param dt Instance of rv_plic.
211
* @param rst Reset port.
212
* @return Reset signal.
213
*/
214
dt_reset_t
dt_rv_plic_reset
(
215
dt_rv_plic_t
dt,
216
dt_rv_plic_reset_t
rst);
217
218
219
220
#ifdef __cplusplus
221
}
// extern "C"
222
#endif
// __cplusplus
223
224
#endif
// OPENTITAN_DT_RV_PLIC_H_
(darjeeling)
hw
top
dt
dt_rv_plic.h
Return to
OpenTitan Documentation