root / dma.h @ 95d65800
History | View | Annotate | Download (2 kB)
1 | 244ab90e | aliguori | /*
|
---|---|---|---|
2 | 244ab90e | aliguori | * DMA helper functions
|
3 | 244ab90e | aliguori | *
|
4 | 244ab90e | aliguori | * Copyright (c) 2009 Red Hat
|
5 | 244ab90e | aliguori | *
|
6 | 244ab90e | aliguori | * This work is licensed under the terms of the GNU General Public License
|
7 | 244ab90e | aliguori | * (GNU GPL), version 2 or later.
|
8 | 244ab90e | aliguori | */
|
9 | 244ab90e | aliguori | |
10 | 244ab90e | aliguori | #ifndef DMA_H
|
11 | 244ab90e | aliguori | #define DMA_H
|
12 | 244ab90e | aliguori | |
13 | 244ab90e | aliguori | #include <stdio.h> |
14 | 1ad2134f | Paul Brook | #include "hw/hw.h" |
15 | 59a703eb | aliguori | #include "block.h" |
16 | 244ab90e | aliguori | |
17 | 10dc8aef | Paolo Bonzini | typedef struct ScatterGatherEntry ScatterGatherEntry; |
18 | 10dc8aef | Paolo Bonzini | |
19 | 43cf8ae6 | David Gibson | typedef enum { |
20 | 43cf8ae6 | David Gibson | DMA_DIRECTION_TO_DEVICE = 0,
|
21 | 43cf8ae6 | David Gibson | DMA_DIRECTION_FROM_DEVICE = 1,
|
22 | 43cf8ae6 | David Gibson | } DMADirection; |
23 | 43cf8ae6 | David Gibson | |
24 | fead0c24 | Paolo Bonzini | struct QEMUSGList {
|
25 | fead0c24 | Paolo Bonzini | ScatterGatherEntry *sg; |
26 | fead0c24 | Paolo Bonzini | int nsg;
|
27 | fead0c24 | Paolo Bonzini | int nalloc;
|
28 | fead0c24 | Paolo Bonzini | size_t size; |
29 | fead0c24 | Paolo Bonzini | }; |
30 | fead0c24 | Paolo Bonzini | |
31 | 10dc8aef | Paolo Bonzini | #if defined(TARGET_PHYS_ADDR_BITS)
|
32 | d9d1055e | David Gibson | typedef target_phys_addr_t dma_addr_t;
|
33 | d9d1055e | David Gibson | |
34 | d9d1055e | David Gibson | #define DMA_ADDR_FMT TARGET_FMT_plx
|
35 | d9d1055e | David Gibson | |
36 | 10dc8aef | Paolo Bonzini | struct ScatterGatherEntry {
|
37 | d3231181 | David Gibson | dma_addr_t base; |
38 | d3231181 | David Gibson | dma_addr_t len; |
39 | 10dc8aef | Paolo Bonzini | }; |
40 | 244ab90e | aliguori | |
41 | 244ab90e | aliguori | void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint); |
42 | d3231181 | David Gibson | void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len);
|
43 | 244ab90e | aliguori | void qemu_sglist_destroy(QEMUSGList *qsg);
|
44 | 10dc8aef | Paolo Bonzini | #endif
|
45 | 244ab90e | aliguori | |
46 | cb144ccb | Christoph Hellwig | typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
|
47 | cb144ccb | Christoph Hellwig | QEMUIOVector *iov, int nb_sectors,
|
48 | cb144ccb | Christoph Hellwig | BlockDriverCompletionFunc *cb, void *opaque);
|
49 | cb144ccb | Christoph Hellwig | |
50 | cb144ccb | Christoph Hellwig | BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs, |
51 | cb144ccb | Christoph Hellwig | QEMUSGList *sg, uint64_t sector_num, |
52 | cb144ccb | Christoph Hellwig | DMAIOFunc *io_func, BlockDriverCompletionFunc *cb, |
53 | 43cf8ae6 | David Gibson | void *opaque, DMADirection dir);
|
54 | 59a703eb | aliguori | BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, |
55 | 59a703eb | aliguori | QEMUSGList *sg, uint64_t sector, |
56 | 59a703eb | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
57 | 59a703eb | aliguori | BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, |
58 | 59a703eb | aliguori | QEMUSGList *sg, uint64_t sector, |
59 | 59a703eb | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
60 | 8171ee35 | Paolo Bonzini | uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); |
61 | 8171ee35 | Paolo Bonzini | uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); |
62 | 8171ee35 | Paolo Bonzini | |
63 | 84a69356 | Paolo Bonzini | void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie,
|
64 | 84a69356 | Paolo Bonzini | QEMUSGList *sg, enum BlockAcctType type);
|
65 | 84a69356 | Paolo Bonzini | |
66 | 244ab90e | aliguori | #endif |