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