Revision bc24a225 hw/pxa2xx_dma.c
b/hw/pxa2xx_dma.c | ||
---|---|---|
11 | 11 |
#include "hw.h" |
12 | 12 |
#include "pxa.h" |
13 | 13 |
|
14 |
struct pxa2xx_dma_channel_s {
|
|
14 |
typedef struct {
|
|
15 | 15 |
target_phys_addr_t descr; |
16 | 16 |
target_phys_addr_t src; |
17 | 17 |
target_phys_addr_t dest; |
18 | 18 |
uint32_t cmd; |
19 | 19 |
uint32_t state; |
20 | 20 |
int request; |
21 |
}; |
|
21 |
} PXA2xxDMAChannel;
|
|
22 | 22 |
|
23 | 23 |
/* Allow the DMA to be used as a PIC. */ |
24 | 24 |
typedef void (*pxa2xx_dma_handler_t)(void *opaque, int irq, int level); |
25 | 25 |
|
26 |
struct pxa2xx_dma_state_s {
|
|
26 |
struct PXA2xxDMAState {
|
|
27 | 27 |
pxa2xx_dma_handler_t handler; |
28 | 28 |
qemu_irq irq; |
29 | 29 |
|
... | ... | |
37 | 37 |
uint32_t pio; |
38 | 38 |
|
39 | 39 |
int channels; |
40 |
struct pxa2xx_dma_channel_s *chan;
|
|
40 |
PXA2xxDMAChannel *chan;
|
|
41 | 41 |
|
42 | 42 |
uint8_t *req; |
43 | 43 |
|
... | ... | |
106 | 106 |
#define DCSR_NODESCFETCH (1 << 30) |
107 | 107 |
#define DCSR_RUN (1 << 31) |
108 | 108 |
|
109 |
static inline void pxa2xx_dma_update(struct pxa2xx_dma_state_s *s, int ch)
|
|
109 |
static inline void pxa2xx_dma_update(PXA2xxDMAState *s, int ch)
|
|
110 | 110 |
{ |
111 | 111 |
if (ch >= 0) { |
112 | 112 |
if ((s->chan[ch].state & DCSR_STOPIRQEN) && |
... | ... | |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
static inline void pxa2xx_dma_descriptor_fetch( |
148 |
struct pxa2xx_dma_state_s *s, int ch)
|
|
148 |
PXA2xxDMAState *s, int ch)
|
|
149 | 149 |
{ |
150 | 150 |
uint32_t desc[4]; |
151 | 151 |
target_phys_addr_t daddr = s->chan[ch].descr & ~0xf; |
... | ... | |
170 | 170 |
s->chan[ch].state |= DCSR_STARTINTR; |
171 | 171 |
} |
172 | 172 |
|
173 |
static void pxa2xx_dma_run(struct pxa2xx_dma_state_s *s)
|
|
173 |
static void pxa2xx_dma_run(PXA2xxDMAState *s)
|
|
174 | 174 |
{ |
175 | 175 |
int c, srcinc, destinc; |
176 | 176 |
uint32_t n, size; |
177 | 177 |
uint32_t width; |
178 | 178 |
uint32_t length; |
179 | 179 |
uint8_t buffer[32]; |
180 |
struct pxa2xx_dma_channel_s *ch;
|
|
180 |
PXA2xxDMAChannel *ch;
|
|
181 | 181 |
|
182 | 182 |
if (s->running ++) |
183 | 183 |
return; |
... | ... | |
254 | 254 |
|
255 | 255 |
static uint32_t pxa2xx_dma_read(void *opaque, target_phys_addr_t offset) |
256 | 256 |
{ |
257 |
struct pxa2xx_dma_state_s *s = (struct pxa2xx_dma_state_s *) opaque;
|
|
257 |
PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
|
|
258 | 258 |
unsigned int channel; |
259 | 259 |
|
260 | 260 |
switch (offset) { |
... | ... | |
308 | 308 |
static void pxa2xx_dma_write(void *opaque, |
309 | 309 |
target_phys_addr_t offset, uint32_t value) |
310 | 310 |
{ |
311 |
struct pxa2xx_dma_state_s *s = (struct pxa2xx_dma_state_s *) opaque;
|
|
311 |
PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
|
|
312 | 312 |
unsigned int channel; |
313 | 313 |
|
314 | 314 |
switch (offset) { |
... | ... | |
430 | 430 |
|
431 | 431 |
static void pxa2xx_dma_save(QEMUFile *f, void *opaque) |
432 | 432 |
{ |
433 |
struct pxa2xx_dma_state_s *s = (struct pxa2xx_dma_state_s *) opaque;
|
|
433 |
PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
|
|
434 | 434 |
int i; |
435 | 435 |
|
436 | 436 |
qemu_put_be32(f, s->channels); |
... | ... | |
456 | 456 |
|
457 | 457 |
static int pxa2xx_dma_load(QEMUFile *f, void *opaque, int version_id) |
458 | 458 |
{ |
459 |
struct pxa2xx_dma_state_s *s = (struct pxa2xx_dma_state_s *) opaque;
|
|
459 |
PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
|
|
460 | 460 |
int i; |
461 | 461 |
|
462 | 462 |
if (qemu_get_be32(f) != s->channels) |
... | ... | |
483 | 483 |
return 0; |
484 | 484 |
} |
485 | 485 |
|
486 |
static struct pxa2xx_dma_state_s *pxa2xx_dma_init(target_phys_addr_t base,
|
|
486 |
static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base,
|
|
487 | 487 |
qemu_irq irq, int channels) |
488 | 488 |
{ |
489 | 489 |
int i, iomemtype; |
490 |
struct pxa2xx_dma_state_s *s;
|
|
491 |
s = (struct pxa2xx_dma_state_s *)
|
|
492 |
qemu_mallocz(sizeof(struct pxa2xx_dma_state_s));
|
|
490 |
PXA2xxDMAState *s;
|
|
491 |
s = (PXA2xxDMAState *)
|
|
492 |
qemu_mallocz(sizeof(PXA2xxDMAState));
|
|
493 | 493 |
|
494 | 494 |
s->channels = channels; |
495 |
s->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * s->channels);
|
|
495 |
s->chan = qemu_mallocz(sizeof(PXA2xxDMAChannel) * s->channels);
|
|
496 | 496 |
s->irq = irq; |
497 | 497 |
s->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request; |
498 | 498 |
s->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS); |
499 | 499 |
|
500 |
memset(s->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * s->channels);
|
|
500 |
memset(s->chan, 0, sizeof(PXA2xxDMAChannel) * s->channels);
|
|
501 | 501 |
for (i = 0; i < s->channels; i ++) |
502 | 502 |
s->chan[i].state = DCSR_STOPINTR; |
503 | 503 |
|
... | ... | |
512 | 512 |
return s; |
513 | 513 |
} |
514 | 514 |
|
515 |
struct pxa2xx_dma_state_s *pxa27x_dma_init(target_phys_addr_t base,
|
|
515 |
PXA2xxDMAState *pxa27x_dma_init(target_phys_addr_t base,
|
|
516 | 516 |
qemu_irq irq) |
517 | 517 |
{ |
518 | 518 |
return pxa2xx_dma_init(base, irq, PXA27X_DMA_NUM_CHANNELS); |
519 | 519 |
} |
520 | 520 |
|
521 |
struct pxa2xx_dma_state_s *pxa255_dma_init(target_phys_addr_t base,
|
|
521 |
PXA2xxDMAState *pxa255_dma_init(target_phys_addr_t base,
|
|
522 | 522 |
qemu_irq irq) |
523 | 523 |
{ |
524 | 524 |
return pxa2xx_dma_init(base, irq, PXA255_DMA_NUM_CHANNELS); |
525 | 525 |
} |
526 | 526 |
|
527 |
void pxa2xx_dma_request(struct pxa2xx_dma_state_s *s, int req_num, int on)
|
|
527 |
void pxa2xx_dma_request(PXA2xxDMAState *s, int req_num, int on)
|
|
528 | 528 |
{ |
529 | 529 |
int ch; |
530 | 530 |
if (req_num < 0 || req_num >= PXA2XX_DMA_NUM_REQUESTS) |
Also available in: Unified diff