Lines Matching full:ch

71 static void sifive_pdma_run(SiFivePDMAState *s, int ch)  in sifive_pdma_run()  argument
73 uint64_t bytes = s->chan[ch].next_bytes; in sifive_pdma_run()
74 uint64_t dst = s->chan[ch].next_dst; in sifive_pdma_run()
75 uint64_t src = s->chan[ch].next_src; in sifive_pdma_run()
76 uint32_t config = s->chan[ch].next_config; in sifive_pdma_run()
112 s->chan[ch].state = DMA_CHAN_STATE_STARTED; in sifive_pdma_run()
113 s->chan[ch].control &= ~CONTROL_DONE; in sifive_pdma_run()
114 s->chan[ch].control &= ~CONTROL_ERR; in sifive_pdma_run()
117 s->chan[ch].exec_config = config; in sifive_pdma_run()
118 s->chan[ch].exec_bytes = bytes; in sifive_pdma_run()
119 s->chan[ch].exec_dst = dst; in sifive_pdma_run()
120 s->chan[ch].exec_src = src; in sifive_pdma_run()
123 cpu_physical_memory_read(s->chan[ch].exec_src, buf, size); in sifive_pdma_run()
124 cpu_physical_memory_write(s->chan[ch].exec_dst, buf, size); in sifive_pdma_run()
125 s->chan[ch].exec_src += size; in sifive_pdma_run()
126 s->chan[ch].exec_dst += size; in sifive_pdma_run()
127 s->chan[ch].exec_bytes -= size; in sifive_pdma_run()
131 cpu_physical_memory_read(s->chan[ch].exec_src, buf, remainder); in sifive_pdma_run()
132 cpu_physical_memory_write(s->chan[ch].exec_dst, buf, remainder); in sifive_pdma_run()
133 s->chan[ch].exec_src += remainder; in sifive_pdma_run()
134 s->chan[ch].exec_dst += remainder; in sifive_pdma_run()
135 s->chan[ch].exec_bytes -= remainder; in sifive_pdma_run()
139 if (s->chan[ch].next_config & CONFIG_REPEAT) { in sifive_pdma_run()
140 s->chan[ch].exec_bytes = bytes; in sifive_pdma_run()
141 s->chan[ch].exec_dst = dst; in sifive_pdma_run()
142 s->chan[ch].exec_src = src; in sifive_pdma_run()
147 s->chan[ch].state = DMA_CHAN_STATE_DONE; in sifive_pdma_run()
148 s->chan[ch].control &= ~CONTROL_RUN; in sifive_pdma_run()
149 s->chan[ch].control |= CONTROL_DONE; in sifive_pdma_run()
153 s->chan[ch].state = DMA_CHAN_STATE_ERROR; in sifive_pdma_run()
154 s->chan[ch].control |= CONTROL_ERR; in sifive_pdma_run()
158 static inline void sifive_pdma_update_irq(SiFivePDMAState *s, int ch) in sifive_pdma_update_irq() argument
162 done_ie = !!(s->chan[ch].control & CONTROL_DONE_IE); in sifive_pdma_update_irq()
163 err_ie = !!(s->chan[ch].control & CONTROL_ERR_IE); in sifive_pdma_update_irq()
165 if (done_ie && (s->chan[ch].control & CONTROL_DONE)) { in sifive_pdma_update_irq()
166 qemu_irq_raise(s->irq[ch * 2]); in sifive_pdma_update_irq()
168 qemu_irq_lower(s->irq[ch * 2]); in sifive_pdma_update_irq()
171 if (err_ie && (s->chan[ch].control & CONTROL_ERR)) { in sifive_pdma_update_irq()
172 qemu_irq_raise(s->irq[ch * 2 + 1]); in sifive_pdma_update_irq()
174 qemu_irq_lower(s->irq[ch * 2 + 1]); in sifive_pdma_update_irq()
177 s->chan[ch].state = DMA_CHAN_STATE_IDLE; in sifive_pdma_update_irq()
180 static uint64_t sifive_pdma_readq(SiFivePDMAState *s, int ch, hwaddr offset) in sifive_pdma_readq() argument
187 val = s->chan[ch].next_bytes; in sifive_pdma_readq()
190 val = s->chan[ch].next_dst; in sifive_pdma_readq()
193 val = s->chan[ch].next_src; in sifive_pdma_readq()
196 val = s->chan[ch].exec_bytes; in sifive_pdma_readq()
199 val = s->chan[ch].exec_dst; in sifive_pdma_readq()
202 val = s->chan[ch].exec_src; in sifive_pdma_readq()
214 static uint32_t sifive_pdma_readl(SiFivePDMAState *s, int ch, hwaddr offset) in sifive_pdma_readl() argument
221 val = s->chan[ch].control; in sifive_pdma_readl()
224 val = s->chan[ch].next_config; in sifive_pdma_readl()
227 val = extract64(s->chan[ch].next_bytes, 0, 32); in sifive_pdma_readl()
230 val = extract64(s->chan[ch].next_bytes, 32, 32); in sifive_pdma_readl()
233 val = extract64(s->chan[ch].next_dst, 0, 32); in sifive_pdma_readl()
236 val = extract64(s->chan[ch].next_dst, 32, 32); in sifive_pdma_readl()
239 val = extract64(s->chan[ch].next_src, 0, 32); in sifive_pdma_readl()
242 val = extract64(s->chan[ch].next_src, 32, 32); in sifive_pdma_readl()
245 val = s->chan[ch].exec_config; in sifive_pdma_readl()
248 val = extract64(s->chan[ch].exec_bytes, 0, 32); in sifive_pdma_readl()
251 val = extract64(s->chan[ch].exec_bytes, 32, 32); in sifive_pdma_readl()
254 val = extract64(s->chan[ch].exec_dst, 0, 32); in sifive_pdma_readl()
257 val = extract64(s->chan[ch].exec_dst, 32, 32); in sifive_pdma_readl()
260 val = extract64(s->chan[ch].exec_src, 0, 32); in sifive_pdma_readl()
263 val = extract64(s->chan[ch].exec_src, 32, 32); in sifive_pdma_readl()
278 int ch = SIFIVE_PDMA_CHAN_NO(offset); in sifive_pdma_read() local
281 if (ch >= SIFIVE_PDMA_CHANS) { in sifive_pdma_read()
283 __func__, ch); in sifive_pdma_read()
289 val = sifive_pdma_readq(s, ch, offset); in sifive_pdma_read()
292 val = sifive_pdma_readl(s, ch, offset); in sifive_pdma_read()
303 static void sifive_pdma_writeq(SiFivePDMAState *s, int ch, in sifive_pdma_writeq() argument
309 s->chan[ch].next_bytes = value; in sifive_pdma_writeq()
312 s->chan[ch].next_dst = value; in sifive_pdma_writeq()
315 s->chan[ch].next_src = value; in sifive_pdma_writeq()
330 static void sifive_pdma_writel(SiFivePDMAState *s, int ch, in sifive_pdma_writel() argument
338 claimed = !!(s->chan[ch].control & CONTROL_CLAIM); in sifive_pdma_writel()
339 run = !!(s->chan[ch].control & CONTROL_RUN); in sifive_pdma_writel()
343 s->chan[ch].next_config = (CONFIG_RDSZ_DEFAULT << CONFIG_RDSZ_SHIFT) | in sifive_pdma_writel()
345 s->chan[ch].next_bytes = 0; in sifive_pdma_writel()
346 s->chan[ch].next_dst = 0; in sifive_pdma_writel()
347 s->chan[ch].next_src = 0; in sifive_pdma_writel()
355 s->chan[ch].control = value; in sifive_pdma_writel()
363 s->chan[ch].control &= ~CONTROL_RUN; in sifive_pdma_writel()
368 sifive_pdma_run(s, ch); in sifive_pdma_writel()
371 sifive_pdma_update_irq(s, ch); in sifive_pdma_writel()
374 s->chan[ch].next_config = value; in sifive_pdma_writel()
377 s->chan[ch].next_bytes = in sifive_pdma_writel()
378 deposit64(s->chan[ch].next_bytes, 0, 32, value); in sifive_pdma_writel()
381 s->chan[ch].next_bytes = in sifive_pdma_writel()
382 deposit64(s->chan[ch].next_bytes, 32, 32, value); in sifive_pdma_writel()
385 s->chan[ch].next_dst = deposit64(s->chan[ch].next_dst, 0, 32, value); in sifive_pdma_writel()
388 s->chan[ch].next_dst = deposit64(s->chan[ch].next_dst, 32, 32, value); in sifive_pdma_writel()
391 s->chan[ch].next_src = deposit64(s->chan[ch].next_src, 0, 32, value); in sifive_pdma_writel()
394 s->chan[ch].next_src = deposit64(s->chan[ch].next_src, 32, 32, value); in sifive_pdma_writel()
417 int ch = SIFIVE_PDMA_CHAN_NO(offset); in sifive_pdma_write() local
419 if (ch >= SIFIVE_PDMA_CHANS) { in sifive_pdma_write()
421 __func__, ch); in sifive_pdma_write()
427 sifive_pdma_writeq(s, ch, offset, value); in sifive_pdma_write()
430 sifive_pdma_writel(s, ch, offset, (uint32_t) value); in sifive_pdma_write()