00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 struct soc_dma_s;
00023 struct soc_dma_ch_s;
00024 typedef void (*soc_dma_io_t)(void *opaque, uint8_t *buf, int len);
00025 typedef void (*soc_dma_transfer_t)(struct soc_dma_ch_s *ch);
00026
00027 enum soc_dma_port_type {
00028 soc_dma_port_mem,
00029 soc_dma_port_fifo,
00030 soc_dma_port_other,
00031 };
00032
00033 enum soc_dma_access_type {
00034 soc_dma_access_const,
00035 soc_dma_access_linear,
00036 soc_dma_access_other,
00037 };
00038
00039 struct soc_dma_ch_s {
00040
00041 struct soc_dma_s *dma;
00042 int num;
00043 QEMUTimer *timer;
00044
00045
00046 int enable;
00047 int update;
00048
00049
00050 int bytes;
00051
00052 enum soc_dma_access_type type[2];
00053 target_phys_addr_t vaddr[2];
00054
00055 void *paddr[2];
00056 soc_dma_io_t io_fn[2];
00057 void *io_opaque[2];
00058
00059 int running;
00060 soc_dma_transfer_t transfer_fn;
00061
00062
00063 void *opaque;
00064 };
00065
00066 struct soc_dma_s {
00067
00068
00069 uint64_t drqbmp;
00070 qemu_irq *drq;
00071 void *opaque;
00072 int64_t freq;
00073 soc_dma_transfer_t transfer_fn;
00074 soc_dma_transfer_t setup_fn;
00075
00076 struct soc_dma_ch_s *ch;
00077 };
00078
00079
00080 void soc_dma_set_request(struct soc_dma_ch_s *ch, int level);
00081
00082
00083
00084
00085
00086
00087 void soc_dma_ch_update(struct soc_dma_ch_s *ch);
00088
00089
00090 void soc_dma_reset(struct soc_dma_s *s);
00091 struct soc_dma_s *soc_dma_init(int n);
00092
00093 void soc_dma_port_add_fifo(struct soc_dma_s *dma, target_phys_addr_t virt_base,
00094 soc_dma_io_t fn, void *opaque, int out);
00095 void soc_dma_port_add_mem(struct soc_dma_s *dma, uint8_t *phys_base,
00096 target_phys_addr_t virt_base, size_t size);
00097
00098 static inline void soc_dma_port_add_fifo_in(struct soc_dma_s *dma,
00099 target_phys_addr_t virt_base, soc_dma_io_t fn, void *opaque)
00100 {
00101 return soc_dma_port_add_fifo(dma, virt_base, fn, opaque, 0);
00102 }
00103
00104 static inline void soc_dma_port_add_fifo_out(struct soc_dma_s *dma,
00105 target_phys_addr_t virt_base, soc_dma_io_t fn, void *opaque)
00106 {
00107 return soc_dma_port_add_fifo(dma, virt_base, fn, opaque, 1);
00108 }
00109
00110 static inline void soc_dma_port_add_mem_ram(struct soc_dma_s *dma,
00111 ram_addr_t offset, target_phys_addr_t virt_base, size_t size)
00112 {
00113 return soc_dma_port_add_mem(dma, phys_ram_base + offset, virt_base, size);
00114 }