1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef HW_SOC_DMA_H
22#define HW_SOC_DMA_H
23
24#include "exec/hwaddr.h"
25
26struct soc_dma_s;
27struct soc_dma_ch_s;
28typedef void (*soc_dma_io_t)(void *opaque, uint8_t *buf, int len);
29typedef void (*soc_dma_transfer_t)(struct soc_dma_ch_s *ch);
30
31enum soc_dma_port_type {
32 soc_dma_port_mem,
33 soc_dma_port_fifo,
34 soc_dma_port_other,
35};
36
37enum soc_dma_access_type {
38 soc_dma_access_const,
39 soc_dma_access_linear,
40 soc_dma_access_other,
41};
42
43struct soc_dma_ch_s {
44
45 struct soc_dma_s *dma;
46 int num;
47 QEMUTimer *timer;
48
49
50 int enable;
51 int update;
52
53
54 int bytes;
55
56 enum soc_dma_access_type type[2];
57 hwaddr vaddr[2];
58
59 void *paddr[2];
60 soc_dma_io_t io_fn[2];
61 void *io_opaque[2];
62
63 int running;
64 soc_dma_transfer_t transfer_fn;
65
66
67 void *opaque;
68};
69
70struct soc_dma_s {
71
72
73 uint64_t drqbmp;
74 qemu_irq *drq;
75 void *opaque;
76 int64_t freq;
77 soc_dma_transfer_t transfer_fn;
78 soc_dma_transfer_t setup_fn;
79
80 struct soc_dma_ch_s *ch;
81};
82
83
84void soc_dma_set_request(struct soc_dma_ch_s *ch, int level);
85
86
87
88
89
90
91void soc_dma_ch_update(struct soc_dma_ch_s *ch);
92
93
94void soc_dma_reset(struct soc_dma_s *s);
95struct soc_dma_s *soc_dma_init(int n);
96
97void soc_dma_port_add_fifo(struct soc_dma_s *dma, hwaddr virt_base,
98 soc_dma_io_t fn, void *opaque, int out);
99void soc_dma_port_add_mem(struct soc_dma_s *dma, uint8_t *phys_base,
100 hwaddr virt_base, size_t size);
101
102static inline void soc_dma_port_add_fifo_in(struct soc_dma_s *dma,
103 hwaddr virt_base, soc_dma_io_t fn, void *opaque)
104{
105 return soc_dma_port_add_fifo(dma, virt_base, fn, opaque, 0);
106}
107
108static inline void soc_dma_port_add_fifo_out(struct soc_dma_s *dma,
109 hwaddr virt_base, soc_dma_io_t fn, void *opaque)
110{
111 return soc_dma_port_add_fifo(dma, virt_base, fn, opaque, 1);
112}
113
114#endif
115