libmetal
dma.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Xilinx Inc. and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*
8  * @file dma.h
9  * @brief DMA primitives for libmetal.
10  */
11 
12 #ifndef __METAL_DMA__H__
13 #define __METAL_DMA__H__
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
22 #include <stdint.h>
23 #include <metal/sys.h>
24 
25 #define METAL_DMA_DEV_R 1
26 #define METAL_DMA_DEV_W 2
27 #define METAL_DMA_DEV_WR 3
32 struct metal_sg {
33  void *virt;
34  struct metal_io_region *io;
35  int len;
36 };
37 
38 struct metal_device;
39 
52 int metal_dma_map(struct metal_device *dev,
53  uint32_t dir,
54  struct metal_sg *sg_in,
55  int nents_in,
56  struct metal_sg *sg_out);
57 
68 void metal_dma_unmap(struct metal_device *dev,
69  uint32_t dir,
70  struct metal_sg *sg,
71  int nents);
72 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* __METAL_DMA__H__ */
int metal_dma_map(struct metal_device *dev, uint32_t dir, struct metal_sg *sg_in, int nents_in, struct metal_sg *sg_out)
Map memory for DMA transaction. After the memory is DMA mapped, the memory should be accessed by the ...
Definition: dma.c:14
Definition: device.h:71
struct metal_io_region * io
Definition: dma.h:34
void metal_dma_unmap(struct metal_device *dev, uint32_t dir, struct metal_sg *sg, int nents)
Unmap DMA memory After the memory is DMA unmapped, the memory should be accessed by the CPU but not t...
Definition: dma.c:40
int len
Definition: dma.h:35
void * virt
Definition: dma.h:33
Definition: io.h:68
scatter/gather list element structure
Definition: dma.h:32