libmetal  latest
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 #include <stdint.h>
16 #include <metal/sys.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
26 #define METAL_DMA_DEV_R 1
27 #define METAL_DMA_DEV_W 2
28 #define METAL_DMA_DEV_WR 3
33 struct metal_sg {
34  void *virt;
35  struct metal_io_region *io;
36  int len;
37 };
38 
39 struct metal_device;
40 
53 int metal_dma_map(struct metal_device *dev,
54  uint32_t dir,
55  struct metal_sg *sg_in,
56  int nents_in,
57  struct metal_sg *sg_out);
58 
69 void metal_dma_unmap(struct metal_device *dev,
70  uint32_t dir,
71  struct metal_sg *sg,
72  int nents);
73 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* __METAL_DMA__H__ */
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:39
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.
Definition: dma.c:14
Libmetal device structure.
Definition: device.h:72
Libmetal I/O region structure.
Definition: io.h:73
scatter/gather list element structure
Definition: dma.h:33
struct metal_io_region * io
IO region.
Definition: dma.h:35
int len
length
Definition: dma.h:36
void * virt
CPU virtual address.
Definition: dma.h:34