Software APIs
dif_pattgen_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_PATTGEN_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PATTGEN_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/pattgen/">PATTGEN</a> Device Interface Functions
14  */
15 
16 #include <stdbool.h>
17 #include <stdint.h>
18 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif // __cplusplus
26 
27 /**
28  * A handle to pattgen.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_pattgen {
33  /**
34  * The base address for the pattgen hardware registers.
35  */
38 
39 /**
40  * Creates a new handle for a(n) pattgen peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the pattgen peripheral.
45  * @param[out] pattgen Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A pattgen alert type.
53  */
54 typedef enum dif_pattgen_alert {
55  /**
56  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57  * detected.
58  */
61 
62 /**
63  * Forces a particular alert, causing it to be escalated as if the hardware
64  * had raised it.
65  *
66  * @param pattgen A pattgen handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72  dif_pattgen_alert_t alert);
73 
74 /**
75  * A pattgen interrupt request type.
76  */
77 typedef enum dif_pattgen_irq {
78  /**
79  * Raise if pattern generation on Channel 0 is complete
80  */
82  /**
83  * Raise if pattern generation on Channel 1 is complete
84  */
87 
88 /**
89  * A snapshot of the state of the interrupts for this IP.
90  *
91  * This is an opaque type, to be used with the `dif_pattgen_irq_get_state()`
92  * and `dif_pattgen_irq_acknowledge_state()` functions.
93  */
95 
96 /**
97  * Returns the type of a given interrupt (i.e., event or status) for this IP.
98  *
99  * @param pattgen A pattgen handle.
100  * @param irq An interrupt request.
101  * @param[out] type Out-param for the interrupt type.
102  * @return The result of the operation.
103  */
106  dif_pattgen_irq_t irq,
107  dif_irq_type_t *type);
108 
109 /**
110  * Returns the state of all interrupts (i.e., pending or not) for this IP.
111  *
112  * @param pattgen A pattgen handle.
113  * @param[out] snapshot Out-param for interrupt state snapshot.
114  * @return The result of the operation.
115  */
118  const dif_pattgen_t *pattgen, dif_pattgen_irq_state_snapshot_t *snapshot);
119 
120 /**
121  * Returns whether a particular interrupt is currently pending.
122  *
123  * @param pattgen A pattgen 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  */
130  dif_pattgen_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 pattgen A pattgen handle.
138  * @param snapshot Interrupt state snapshot.
139  * @return The result of the operation.
140  */
143  const dif_pattgen_t *pattgen, dif_pattgen_irq_state_snapshot_t snapshot);
144 
145 /**
146  * Acknowledges all interrupts, indicating to the hardware that all
147  * interrupts have been successfully serviced.
148  *
149  * @param pattgen A pattgen handle.
150  * @return The result of the operation.
151  */
154 
155 /**
156  * Acknowledges a particular interrupt, indicating to the hardware that it has
157  * been successfully serviced.
158  *
159  * @param pattgen A pattgen handle.
160  * @param irq An interrupt request.
161  * @return The result of the operation.
162  */
165  dif_pattgen_irq_t irq);
166 
167 /**
168  * Forces a particular interrupt, causing it to be serviced as if hardware had
169  * asserted it.
170  *
171  * @param pattgen A pattgen handle.
172  * @param irq An interrupt request.
173  * @param val Value to be set.
174  * @return The result of the operation.
175  */
178  dif_pattgen_irq_t irq, const bool val);
179 
180 /**
181  * A snapshot of the enablement state of the interrupts for this IP.
182  *
183  * This is an opaque type, to be used with the
184  * `dif_pattgen_irq_disable_all()` and `dif_pattgen_irq_restore_all()`
185  * functions.
186  */
188 
189 /**
190  * Checks whether a particular interrupt is currently enabled or disabled.
191  *
192  * @param pattgen A pattgen handle.
193  * @param irq An interrupt request.
194  * @param[out] state Out-param toggle state of the interrupt.
195  * @return The result of the operation.
196  */
199  dif_pattgen_irq_t irq,
200  dif_toggle_t *state);
201 
202 /**
203  * Sets whether a particular interrupt is currently enabled or disabled.
204  *
205  * @param pattgen A pattgen handle.
206  * @param irq An interrupt request.
207  * @param state The new toggle state for the interrupt.
208  * @return The result of the operation.
209  */
212  dif_pattgen_irq_t irq,
213  dif_toggle_t state);
214 
215 /**
216  * Disables all interrupts, optionally snapshotting all enable states for later
217  * restoration.
218  *
219  * @param pattgen A pattgen handle.
220  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
221  * @return The result of the operation.
222  */
225  const dif_pattgen_t *pattgen, dif_pattgen_irq_enable_snapshot_t *snapshot);
226 
227 /**
228  * Restores interrupts from the given (enable) snapshot.
229  *
230  * @param pattgen A pattgen handle.
231  * @param snapshot A snapshot to restore from.
232  * @return The result of the operation.
233  */
236  const dif_pattgen_t *pattgen,
237  const dif_pattgen_irq_enable_snapshot_t *snapshot);
238 
239 #ifdef __cplusplus
240 } // extern "C"
241 #endif // __cplusplus
242 
243 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PATTGEN_AUTOGEN_H_