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  * Indicates the transfer of a single chunk has been completed.
83  */
85  /**
86  * DMA error has occurred. DMA_STATUS.error_code register shows the details.
87  */
90 
91 /**
92  * A snapshot of the state of the interrupts for this IP.
93  *
94  * This is an opaque type, to be used with the `dif_dma_irq_get_state()`
95  * and `dif_dma_irq_acknowledge_state()` functions.
96  */
98 
99 /**
100  * Returns the type of a given interrupt (i.e., event or status) for this IP.
101  *
102  * @param dma A dma handle.
103  * @param irq An interrupt request.
104  * @param[out] type Out-param for the interrupt type.
105  * @return The result of the operation.
106  */
109  dif_irq_type_t *type);
110 
111 /**
112  * Returns the state of all interrupts (i.e., pending or not) for this IP.
113  *
114  * @param dma A dma handle.
115  * @param[out] snapshot Out-param for interrupt state snapshot.
116  * @return The result of the operation.
117  */
120  dif_dma_irq_state_snapshot_t *snapshot);
121 
122 /**
123  * Returns whether a particular interrupt is currently pending.
124  *
125  * @param dma A dma handle.
126  * @param irq An interrupt request.
127  * @param[out] is_pending Out-param for whether the interrupt is pending.
128  * @return The result of the operation.
129  */
132  bool *is_pending);
133 
134 /**
135  * Acknowledges all interrupts that were pending at the time of the state
136  * snapshot.
137  *
138  * @param dma A dma handle.
139  * @param snapshot Interrupt state snapshot.
140  * @return The result of the operation.
141  */
144  const dif_dma_t *dma, dif_dma_irq_state_snapshot_t snapshot);
145 
146 /**
147  * Acknowledges all interrupts, indicating to the hardware that all
148  * interrupts have been successfully serviced.
149  *
150  * @param dma A dma handle.
151  * @return The result of the operation.
152  */
155 
156 /**
157  * Acknowledges a particular interrupt, indicating to the hardware that it has
158  * been successfully serviced.
159  *
160  * @param dma A dma handle.
161  * @param irq An interrupt request.
162  * @return The result of the operation.
163  */
166 
167 /**
168  * Forces a particular interrupt, causing it to be serviced as if hardware had
169  * asserted it.
170  *
171  * @param dma A dma handle.
172  * @param irq An interrupt request.
173  * @param val Value to be set.
174  * @return The result of the operation.
175  */
178  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_dma_irq_disable_all()` and `dif_dma_irq_restore_all()`
185  * functions.
186  */
188 
189 /**
190  * Checks whether a particular interrupt is currently enabled or disabled.
191  *
192  * @param dma A dma 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_toggle_t *state);
200 
201 /**
202  * Sets whether a particular interrupt is currently enabled or disabled.
203  *
204  * @param dma A dma handle.
205  * @param irq An interrupt request.
206  * @param state The new toggle state for the interrupt.
207  * @return The result of the operation.
208  */
211  dif_toggle_t state);
212 
213 /**
214  * Disables all interrupts, optionally snapshotting all enable states for later
215  * restoration.
216  *
217  * @param dma A dma handle.
218  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
219  * @return The result of the operation.
220  */
224 
225 /**
226  * Restores interrupts from the given (enable) snapshot.
227  *
228  * @param dma A dma handle.
229  * @param snapshot A snapshot to restore from.
230  * @return The result of the operation.
231  */
234  const dif_dma_t *dma, const dif_dma_irq_enable_snapshot_t *snapshot);
235 
236 #ifdef __cplusplus
237 } // extern "C"
238 #endif // __cplusplus
239 
240 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_AUTOGEN_H_