Software APIs
dif_dma_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_DMA_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_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/dma/">DMA</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 dma.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_dma {
33  /**
34  * The base address for the dma hardware registers.
35  */
37 } dif_dma_t;
38 
39 /**
40  * Creates a new handle for a(n) dma peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the dma peripheral.
45  * @param[out] dma Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A dma alert type.
53  */
54 typedef enum dif_dma_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 dma A dma handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72 
73 /**
74  * A dma interrupt request type.
75  */
76 typedef enum dif_dma_irq {
77  /**
78  * DMA operation has been completed.
79  */
81  /**
82  * DMA error has occurred. DMA_STATUS.error_code register shows the details.
83  */
86 
87 /**
88  * A snapshot of the state of the interrupts for this IP.
89  *
90  * This is an opaque type, to be used with the `dif_dma_irq_get_state()`
91  * and `dif_dma_irq_acknowledge_state()` functions.
92  */
94 
95 /**
96  * Returns the type of a given interrupt (i.e., event or status) for this IP.
97  *
98  * @param dma A dma handle.
99  * @param irq An interrupt request.
100  * @param[out] type Out-param for the interrupt type.
101  * @return The result of the operation.
102  */
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 dma A dma handle.
111  * @param[out] snapshot Out-param for interrupt state snapshot.
112  * @return The result of the operation.
113  */
116  dif_dma_irq_state_snapshot_t *snapshot);
117 
118 /**
119  * Returns whether a particular interrupt is currently pending.
120  *
121  * @param dma A dma handle.
122  * @param irq An interrupt request.
123  * @param[out] is_pending Out-param for whether the interrupt is pending.
124  * @return The result of the operation.
125  */
128  bool *is_pending);
129 
130 /**
131  * Acknowledges all interrupts that were pending at the time of the state
132  * snapshot.
133  *
134  * @param dma A dma handle.
135  * @param snapshot Interrupt state snapshot.
136  * @return The result of the operation.
137  */
140  const dif_dma_t *dma, dif_dma_irq_state_snapshot_t snapshot);
141 
142 /**
143  * Acknowledges all interrupts, indicating to the hardware that all
144  * interrupts have been successfully serviced.
145  *
146  * @param dma A dma handle.
147  * @return The result of the operation.
148  */
151 
152 /**
153  * Acknowledges a particular interrupt, indicating to the hardware that it has
154  * been successfully serviced.
155  *
156  * @param dma A dma handle.
157  * @param irq An interrupt request.
158  * @return The result of the operation.
159  */
162 
163 /**
164  * Forces a particular interrupt, causing it to be serviced as if hardware had
165  * asserted it.
166  *
167  * @param dma A dma handle.
168  * @param irq An interrupt request.
169  * @param val Value to be set.
170  * @return The result of the operation.
171  */
174  const bool val);
175 
176 /**
177  * A snapshot of the enablement state of the interrupts for this IP.
178  *
179  * This is an opaque type, to be used with the
180  * `dif_dma_irq_disable_all()` and `dif_dma_irq_restore_all()`
181  * functions.
182  */
184 
185 /**
186  * Checks whether a particular interrupt is currently enabled or disabled.
187  *
188  * @param dma A dma handle.
189  * @param irq An interrupt request.
190  * @param[out] state Out-param toggle state of the interrupt.
191  * @return The result of the operation.
192  */
195  dif_toggle_t *state);
196 
197 /**
198  * Sets whether a particular interrupt is currently enabled or disabled.
199  *
200  * @param dma A dma handle.
201  * @param irq An interrupt request.
202  * @param state The new toggle state for the interrupt.
203  * @return The result of the operation.
204  */
207  dif_toggle_t state);
208 
209 /**
210  * Disables all interrupts, optionally snapshotting all enable states for later
211  * restoration.
212  *
213  * @param dma A dma handle.
214  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
215  * @return The result of the operation.
216  */
220 
221 /**
222  * Restores interrupts from the given (enable) snapshot.
223  *
224  * @param dma A dma handle.
225  * @param snapshot A snapshot to restore from.
226  * @return The result of the operation.
227  */
230  const dif_dma_t *dma, const dif_dma_irq_enable_snapshot_t *snapshot);
231 
232 #ifdef __cplusplus
233 } // extern "C"
234 #endif // __cplusplus
235 
236 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_AUTOGEN_H_