Software APIs
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
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/rv_timer/data/rv_timer.hjson -o
12// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/rv_timer/">RV_TIMER</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "hw/top/dt/rv_timer.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to rv_timer.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_rv_timer {
38 /**
39 * The base address for the rv_timer hardware registers.
40 */
42 /**
43 * The instance, set to `kDtRvTimerCount` if not initialized
44 * through `dif_rv_timer_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) rv_timer peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the rv_timer peripheral.
55 * @param[out] rv_timer Out param for the initialized handle.
56 * @return The result of the operation.
57 *
58 * DEPRECATED This function exists solely for the transition to
59 * dt-based DIFs and will be removed in the future.
60 */
63 mmio_region_t base_addr,
64 dif_rv_timer_t *rv_timer);
65
66/**
67 * Creates a new handle for a(n) rv_timer peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] rv_timer Out param for the initialized handle.
73 * @return The result of the operation.
74 */
78 dif_rv_timer_t *rv_timer);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_rv_timer_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param rv_timer A rv_timer handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_rv_timer_t *rv_timer,
93 dt_rv_timer_t *dt);
94
95 /**
96 * A rv_timer alert type.
97 */
98 typedef enum dif_rv_timer_alert {
99 /**
100 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected inside the RV_TIMER unit.
101 */
104
105 /**
106 * Forces a particular alert, causing it to be escalated as if the hardware
107 * had raised it.
108 *
109 * @param rv_timer A rv_timer handle.
110 * @param alert The alert to force.
111 * @return The result of the operation.
112 */
115 const dif_rv_timer_t *rv_timer,
117
118 // DEPRECATED This typedef exists solely for the transition to
119 // dt-based interrupt numbers and will be removed in the future.
120 typedef dt_rv_timer_irq_t dif_rv_timer_irq_t;
121
122 /**
123 * A rv_timer interrupt request type.
124 *
125 * DEPRECATED Use `dt_rv_timer_irq_t` instead.
126 * This enumeration exists solely for the transition to
127 * dt-based interrupt numbers and will be removed in the future.
128 *
129 * The following are defines to keep the types consistent with DT.
130 */
131 /**
132 * Raised if hart0's timer0 expired (mtimecmp >= mtime)
133 */
134#define kDifRvTimerIrqTimerExpiredHart0Timer0 kDtRvTimerIrqTimerExpiredHart0Timer0
135
136 /**
137 * A snapshot of the state of the interrupts for this IP.
138 *
139 * This is an opaque type, to be used with the `dif_rv_timer_irq_get_state()`
140 * and `dif_rv_timer_irq_acknowledge_state()` functions.
141 */
143
144 /**
145 * Returns the type of a given interrupt (i.e., event or status) for this IP.
146 *
147 * @param rv_timer A rv_timer handle.
148 * @param irq An interrupt request.
149 * @param[out] type Out-param for the interrupt type.
150 * @return The result of the operation.
151 */
154 const dif_rv_timer_t *rv_timer,
155 dif_rv_timer_irq_t,
156 dif_irq_type_t *type);
157
158 /**
159 * Returns the state of all interrupts (i.e., pending or not) for this IP.
160 *
161 * @param rv_timer A rv_timer handle.
162 * @param hart_id The hart to manipulate.
163 * @param[out] snapshot Out-param for interrupt state snapshot.
164 * @return The result of the operation.
165 */
168 const dif_rv_timer_t *rv_timer,
169 uint32_t hart_id,
171
172 /**
173 * Returns whether a particular interrupt is currently pending.
174 *
175 * @param rv_timer A rv_timer handle.
176 * @param irq An interrupt request.
177 * @param[out] is_pending Out-param for whether the interrupt is pending.
178 * @return The result of the operation.
179 */
182 const dif_rv_timer_t *rv_timer,
183 dif_rv_timer_irq_t,
184 bool *is_pending);
185
186 /**
187 * Acknowledges all interrupts that were pending at the time of the state
188 * snapshot.
189 *
190 * @param rv_timer A rv_timer handle.
191 * @param hart_id The hart to manipulate.
192 * @param snapshot Interrupt state snapshot.
193 * @return The result of the operation.
194 */
197 const dif_rv_timer_t *rv_timer,
198 uint32_t hart_id,
200
201 /**
202 * Acknowledges all interrupts, indicating to the hardware that all
203 * interrupts have been successfully serviced.
204 *
205 * @param rv_timer A rv_timer handle.
206 * @return The result of the operation.
207 */
210 const dif_rv_timer_t *rv_timer
211 , uint32_t hart_id
212 );
213
214 /**
215 * Acknowledges a particular interrupt, indicating to the hardware that it has
216 * been successfully serviced.
217 *
218 * @param rv_timer A rv_timer handle.
219 * @param irq An interrupt request.
220 * @return The result of the operation.
221 */
224 const dif_rv_timer_t *rv_timer,
225 dif_rv_timer_irq_t);
226
227 /**
228 * Forces a particular interrupt, causing it to be serviced as if hardware had
229 * asserted it.
230 *
231 * @param rv_timer A rv_timer handle.
232 * @param irq An interrupt request.
233 * @param val Value to be set.
234 * @return The result of the operation.
235 */
238 const dif_rv_timer_t *rv_timer,
239 dif_rv_timer_irq_t,
240 const bool val);
241
242 /**
243 * A snapshot of the enablement state of the interrupts for this IP.
244 *
245 * This is an opaque type, to be used with the
246 * `dif_rv_timer_irq_disable_all()` and `dif_rv_timer_irq_restore_all()`
247 * functions.
248 */
250
251 /**
252 * Checks whether a particular interrupt is currently enabled or disabled.
253 *
254 * @param rv_timer A rv_timer handle.
255 * @param irq An interrupt request.
256 * @param[out] state Out-param toggle state of the interrupt.
257 * @return The result of the operation.
258 */
261 const dif_rv_timer_t *rv_timer,
262 dif_rv_timer_irq_t,
263 dif_toggle_t *state);
264
265 /**
266 * Sets whether a particular interrupt is currently enabled or disabled.
267 *
268 * @param rv_timer A rv_timer handle.
269 * @param irq An interrupt request.
270 * @param state The new toggle state for the interrupt.
271 * @return The result of the operation.
272 */
275 const dif_rv_timer_t *rv_timer,
276 dif_rv_timer_irq_t,
277 dif_toggle_t state);
278
279 /**
280 * Disables all interrupts, optionally snapshotting all enable states for later
281 * restoration.
282 *
283 * @param rv_timer A rv_timer handle.
284 * @param hart_id The hart to manipulate.
285 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
286 * @return The result of the operation.
287 */
290 const dif_rv_timer_t *rv_timer,
291 uint32_t hart_id,
293
294 /**
295 * Restores interrupts from the given (enable) snapshot.
296 *
297 * @param rv_timer A rv_timer handle.
298 * @param hart_id The hart to manipulate.
299 * @param snapshot A snapshot to restore from.
300 * @return The result of the operation.
301 */
304 const dif_rv_timer_t *rv_timer,
305 uint32_t hart_id,
306 const dif_rv_timer_irq_enable_snapshot_t *snapshot);
307
308
309#ifdef __cplusplus
310} // extern "C"
311#endif // __cplusplus
312
313#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RV_TIMER_AUTOGEN_H_