Revision 97bf4851 hw/sparc32_dma.c
b/hw/sparc32_dma.c | ||
---|---|---|
29 | 29 |
#include "sparc32_dma.h" |
30 | 30 |
#include "sun4m.h" |
31 | 31 |
#include "sysbus.h" |
32 |
|
|
33 |
/* debug DMA */ |
|
34 |
//#define DEBUG_DMA |
|
32 |
#include "trace.h" |
|
35 | 33 |
|
36 | 34 |
/* |
37 | 35 |
* This is the DMA controller part of chip STP2000 (Master I/O), also |
... | ... | |
41 | 39 |
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/DMA2.txt |
42 | 40 |
*/ |
43 | 41 |
|
44 |
#ifdef DEBUG_DMA |
|
45 |
#define DPRINTF(fmt, ...) \ |
|
46 |
do { printf("DMA: " fmt , ## __VA_ARGS__); } while (0) |
|
47 |
#else |
|
48 |
#define DPRINTF(fmt, ...) |
|
49 |
#endif |
|
50 |
|
|
51 | 42 |
#define DMA_REGS 4 |
52 | 43 |
#define DMA_SIZE (4 * sizeof(uint32_t)) |
53 | 44 |
/* We need the mask, because one instance of the device is not page |
... | ... | |
88 | 79 |
DMAState *s = opaque; |
89 | 80 |
int i; |
90 | 81 |
|
91 |
DPRINTF("DMA write, direction: %c, addr 0x%8.8x\n", |
|
92 |
s->dmaregs[0] & DMA_WRITE_MEM ? 'w': 'r', s->dmaregs[1]); |
|
93 | 82 |
addr |= s->dmaregs[3]; |
83 |
trace_ledma_memory_read(addr); |
|
94 | 84 |
if (do_bswap) { |
95 | 85 |
sparc_iommu_memory_read(s->iommu, addr, buf, len); |
96 | 86 |
} else { |
... | ... | |
110 | 100 |
int l, i; |
111 | 101 |
uint16_t tmp_buf[32]; |
112 | 102 |
|
113 |
DPRINTF("DMA read, direction: %c, addr 0x%8.8x\n", |
|
114 |
s->dmaregs[0] & DMA_WRITE_MEM ? 'w': 'r', s->dmaregs[1]); |
|
115 | 103 |
addr |= s->dmaregs[3]; |
104 |
trace_ledma_memory_write(addr); |
|
116 | 105 |
if (do_bswap) { |
117 | 106 |
sparc_iommu_memory_write(s->iommu, addr, buf, len); |
118 | 107 |
} else { |
... | ... | |
139 | 128 |
if (level) { |
140 | 129 |
s->dmaregs[0] |= DMA_INTR; |
141 | 130 |
if (s->dmaregs[0] & DMA_INTREN) { |
142 |
DPRINTF("Raise IRQ\n");
|
|
131 |
trace_sparc32_dma_set_irq_raise();
|
|
143 | 132 |
qemu_irq_raise(s->irq); |
144 | 133 |
} |
145 | 134 |
} else { |
146 | 135 |
if (s->dmaregs[0] & DMA_INTR) { |
147 | 136 |
s->dmaregs[0] &= ~DMA_INTR; |
148 | 137 |
if (s->dmaregs[0] & DMA_INTREN) { |
149 |
DPRINTF("Lower IRQ\n");
|
|
138 |
trace_sparc32_dma_set_irq_lower();
|
|
150 | 139 |
qemu_irq_lower(s->irq); |
151 | 140 |
} |
152 | 141 |
} |
... | ... | |
157 | 146 |
{ |
158 | 147 |
DMAState *s = opaque; |
159 | 148 |
|
160 |
DPRINTF("DMA read, direction: %c, addr 0x%8.8x\n", |
|
161 |
s->dmaregs[0] & DMA_WRITE_MEM ? 'w': 'r', s->dmaregs[1]); |
|
149 |
trace_espdma_memory_read(s->dmaregs[1]); |
|
162 | 150 |
sparc_iommu_memory_read(s->iommu, s->dmaregs[1], buf, len); |
163 | 151 |
s->dmaregs[1] += len; |
164 | 152 |
} |
... | ... | |
167 | 155 |
{ |
168 | 156 |
DMAState *s = opaque; |
169 | 157 |
|
170 |
DPRINTF("DMA write, direction: %c, addr 0x%8.8x\n", |
|
171 |
s->dmaregs[0] & DMA_WRITE_MEM ? 'w': 'r', s->dmaregs[1]); |
|
158 |
trace_espdma_memory_write(s->dmaregs[1]); |
|
172 | 159 |
sparc_iommu_memory_write(s->iommu, s->dmaregs[1], buf, len); |
173 | 160 |
s->dmaregs[1] += len; |
174 | 161 |
} |
... | ... | |
179 | 166 |
uint32_t saddr; |
180 | 167 |
|
181 | 168 |
saddr = (addr & DMA_MASK) >> 2; |
182 |
DPRINTF("read dmareg " TARGET_FMT_plx ": 0x%8.8x\n", addr, |
|
183 |
s->dmaregs[saddr]); |
|
184 |
|
|
169 |
trace_sparc32_dma_mem_readl(addr, s->dmaregs[saddr]); |
|
185 | 170 |
return s->dmaregs[saddr]; |
186 | 171 |
} |
187 | 172 |
|
... | ... | |
191 | 176 |
uint32_t saddr; |
192 | 177 |
|
193 | 178 |
saddr = (addr & DMA_MASK) >> 2; |
194 |
DPRINTF("write dmareg " TARGET_FMT_plx ": 0x%8.8x -> 0x%8.8x\n", addr, |
|
195 |
s->dmaregs[saddr], val); |
|
179 |
trace_sparc32_dma_mem_writel(addr, s->dmaregs[saddr], val); |
|
196 | 180 |
switch (saddr) { |
197 | 181 |
case 0: |
198 | 182 |
if (val & DMA_INTREN) { |
199 | 183 |
if (s->dmaregs[0] & DMA_INTR) { |
200 |
DPRINTF("Raise IRQ\n");
|
|
184 |
trace_sparc32_dma_set_irq_raise();
|
|
201 | 185 |
qemu_irq_raise(s->irq); |
202 | 186 |
} |
203 | 187 |
} else { |
204 | 188 |
if (s->dmaregs[0] & (DMA_INTR | DMA_INTREN)) { |
205 |
DPRINTF("Lower IRQ\n");
|
|
189 |
trace_sparc32_dma_set_irq_lower();
|
|
206 | 190 |
qemu_irq_lower(s->irq); |
207 | 191 |
} |
208 | 192 |
} |
... | ... | |
215 | 199 |
val = DMA_DRAIN_FIFO; |
216 | 200 |
|
217 | 201 |
if (val & DMA_EN && !(s->dmaregs[0] & DMA_EN)) { |
218 |
DPRINTF("Raise DMA enable\n");
|
|
202 |
trace_sparc32_dma_enable_raise();
|
|
219 | 203 |
qemu_irq_raise(s->gpio[GPIO_DMA]); |
220 | 204 |
} else if (!(val & DMA_EN) && !!(s->dmaregs[0] & DMA_EN)) { |
221 |
DPRINTF("Lower DMA enable\n");
|
|
205 |
trace_sparc32_dma_enable_lower();
|
|
222 | 206 |
qemu_irq_lower(s->gpio[GPIO_DMA]); |
223 | 207 |
} |
224 | 208 |
|
Also available in: Unified diff