Software APIs
sw
device
lib
dif
autogen
dif_rv_timer_autogen.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
#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_
7
8
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
9
// util/make_new_dif.py --mode=regen --only=autogen
10
11
/**
12
* @file
13
* @brief <a href="/book/hw/ip/rv_timer/">RV_TIMER</a> Device Interface
14
* Functions
15
*/
16
17
#include <
stdbool.h
>
18
#include <
stdint.h
>
19
20
#include "
sw/device/lib/base/macros.h
"
21
#include "
sw/device/lib/base/mmio.h
"
22
#include "
sw/device/lib/dif/dif_base.h
"
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif // __cplusplus
27
28
/**
29
* A handle to rv_timer.
30
*
31
* This type should be treated as opaque by users.
32
*/
33
typedef
struct
dif_rv_timer
{
34
/**
35
* The base address for the rv_timer hardware registers.
36
*/
37
mmio_region_t
base_addr
;
38
}
dif_rv_timer_t
;
39
40
/**
41
* Creates a new handle for a(n) rv_timer peripheral.
42
*
43
* This function does not actuate the hardware.
44
*
45
* @param base_addr The MMIO base address of the rv_timer peripheral.
46
* @param[out] rv_timer Out param for the initialized handle.
47
* @return The result of the operation.
48
*/
49
OT_WARN_UNUSED_RESULT
50
dif_result_t
dif_rv_timer_init
(
mmio_region_t
base_addr,
51
dif_rv_timer_t
*rv_timer);
52
53
/**
54
* A rv_timer alert type.
55
*/
56
typedef
enum
dif_rv_timer_alert
{
57
/**
58
* This fatal alert is triggered when a fatal TL-UL bus integrity fault is
59
* detected inside the RV_TIMER unit.
60
*/
61
kDifRvTimerAlertFatalFault
= 0,
62
}
dif_rv_timer_alert_t
;
63
64
/**
65
* Forces a particular alert, causing it to be escalated as if the hardware
66
* had raised it.
67
*
68
* @param rv_timer A rv_timer handle.
69
* @param alert The alert to force.
70
* @return The result of the operation.
71
*/
72
OT_WARN_UNUSED_RESULT
73
dif_result_t
dif_rv_timer_alert_force
(
const
dif_rv_timer_t
*rv_timer,
74
dif_rv_timer_alert_t
alert);
75
76
/**
77
* A rv_timer interrupt request type.
78
*/
79
typedef
enum
dif_rv_timer_irq
{
80
/**
81
* Raised if hart0's timer0 expired (mtimecmp >= mtime)
82
*/
83
kDifRvTimerIrqTimerExpiredHart0Timer0
= 0,
84
}
dif_rv_timer_irq_t
;
85
86
/**
87
* A snapshot of the state of the interrupts for this IP.
88
*
89
* This is an opaque type, to be used with the `dif_rv_timer_irq_get_state()`
90
* and `dif_rv_timer_irq_acknowledge_state()` functions.
91
*/
92
typedef
uint32_t
dif_rv_timer_irq_state_snapshot_t
;
93
94
/**
95
* Returns the type of a given interrupt (i.e., event or status) for this IP.
96
*
97
* @param rv_timer A rv_timer handle.
98
* @param irq An interrupt request.
99
* @param[out] type Out-param for the interrupt type.
100
* @return The result of the operation.
101
*/
102
OT_WARN_UNUSED_RESULT
103
dif_result_t
dif_rv_timer_irq_get_type
(
const
dif_rv_timer_t
*rv_timer,
104
dif_rv_timer_irq_t
irq,
105
dif_irq_type_t
*type);
106
107
/**
108
* Returns the state of all interrupts (i.e., pending or not) for this IP.
109
*
110
* @param rv_timer A rv_timer handle.
111
* @param hart_id The hart to manipulate.
112
* @param[out] snapshot Out-param for interrupt state snapshot.
113
* @return The result of the operation.
114
*/
115
OT_WARN_UNUSED_RESULT
116
dif_result_t
dif_rv_timer_irq_get_state
(
117
const
dif_rv_timer_t
*rv_timer, uint32_t hart_id,
118
dif_rv_timer_irq_state_snapshot_t
*snapshot);
119
120
/**
121
* Returns whether a particular interrupt is currently pending.
122
*
123
* @param rv_timer A rv_timer handle.
124
* @param irq An interrupt request.
125
* @param[out] is_pending Out-param for whether the interrupt is pending.
126
* @return The result of the operation.
127
*/
128
OT_WARN_UNUSED_RESULT
129
dif_result_t
dif_rv_timer_irq_is_pending
(
const
dif_rv_timer_t
*rv_timer,
130
dif_rv_timer_irq_t
irq,
131
bool
*is_pending);
132
133
/**
134
* Acknowledges all interrupts that were pending at the time of the state
135
* snapshot.
136
*
137
* @param rv_timer A rv_timer handle.
138
* @param hart_id The hart to manipulate.
139
* @param snapshot Interrupt state snapshot.
140
* @return The result of the operation.
141
*/
142
OT_WARN_UNUSED_RESULT
143
dif_result_t
dif_rv_timer_irq_acknowledge_state
(
144
const
dif_rv_timer_t
*rv_timer, uint32_t hart_id,
145
dif_rv_timer_irq_state_snapshot_t
snapshot);
146
147
/**
148
* Acknowledges all interrupts, indicating to the hardware that all
149
* interrupts have been successfully serviced.
150
*
151
* @param rv_timer A rv_timer handle.
152
* @return The result of the operation.
153
*/
154
OT_WARN_UNUSED_RESULT
155
dif_result_t
dif_rv_timer_irq_acknowledge_all
(
const
dif_rv_timer_t
*rv_timer,
156
uint32_t hart_id);
157
158
/**
159
* Acknowledges a particular interrupt, indicating to the hardware that it has
160
* been successfully serviced.
161
*
162
* @param rv_timer A rv_timer handle.
163
* @param irq An interrupt request.
164
* @return The result of the operation.
165
*/
166
OT_WARN_UNUSED_RESULT
167
dif_result_t
dif_rv_timer_irq_acknowledge
(
const
dif_rv_timer_t
*rv_timer,
168
dif_rv_timer_irq_t
irq);
169
170
/**
171
* Forces a particular interrupt, causing it to be serviced as if hardware had
172
* asserted it.
173
*
174
* @param rv_timer A rv_timer handle.
175
* @param irq An interrupt request.
176
* @param val Value to be set.
177
* @return The result of the operation.
178
*/
179
OT_WARN_UNUSED_RESULT
180
dif_result_t
dif_rv_timer_irq_force
(
const
dif_rv_timer_t
*rv_timer,
181
dif_rv_timer_irq_t
irq,
const
bool
val);
182
183
/**
184
* A snapshot of the enablement state of the interrupts for this IP.
185
*
186
* This is an opaque type, to be used with the
187
* `dif_rv_timer_irq_disable_all()` and `dif_rv_timer_irq_restore_all()`
188
* functions.
189
*/
190
typedef
uint32_t
dif_rv_timer_irq_enable_snapshot_t
;
191
192
/**
193
* Checks whether a particular interrupt is currently enabled or disabled.
194
*
195
* @param rv_timer A rv_timer handle.
196
* @param irq An interrupt request.
197
* @param[out] state Out-param toggle state of the interrupt.
198
* @return The result of the operation.
199
*/
200
OT_WARN_UNUSED_RESULT
201
dif_result_t
dif_rv_timer_irq_get_enabled
(
const
dif_rv_timer_t
*rv_timer,
202
dif_rv_timer_irq_t
irq,
203
dif_toggle_t
*state);
204
205
/**
206
* Sets whether a particular interrupt is currently enabled or disabled.
207
*
208
* @param rv_timer A rv_timer handle.
209
* @param irq An interrupt request.
210
* @param state The new toggle state for the interrupt.
211
* @return The result of the operation.
212
*/
213
OT_WARN_UNUSED_RESULT
214
dif_result_t
dif_rv_timer_irq_set_enabled
(
const
dif_rv_timer_t
*rv_timer,
215
dif_rv_timer_irq_t
irq,
216
dif_toggle_t
state);
217
218
/**
219
* Disables all interrupts, optionally snapshotting all enable states for later
220
* restoration.
221
*
222
* @param rv_timer A rv_timer handle.
223
* @param hart_id The hart to manipulate.
224
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
225
* @return The result of the operation.
226
*/
227
OT_WARN_UNUSED_RESULT
228
dif_result_t
dif_rv_timer_irq_disable_all
(
229
const
dif_rv_timer_t
*rv_timer, uint32_t hart_id,
230
dif_rv_timer_irq_enable_snapshot_t
*snapshot);
231
232
/**
233
* Restores interrupts from the given (enable) snapshot.
234
*
235
* @param rv_timer A rv_timer handle.
236
* @param hart_id The hart to manipulate.
237
* @param snapshot A snapshot to restore from.
238
* @return The result of the operation.
239
*/
240
OT_WARN_UNUSED_RESULT
241
dif_result_t
dif_rv_timer_irq_restore_all
(
242
const
dif_rv_timer_t
*rv_timer, uint32_t hart_id,
243
const
dif_rv_timer_irq_enable_snapshot_t
*snapshot);
244
245
#ifdef __cplusplus
246
}
// extern "C"
247
#endif // __cplusplus
248
249
#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_
Return to
OpenTitan Documentation