pci: simplify memory region registration
[qemu.git] / dma.h
blob2bdc236c4c190366e7df35fad29c879ed7c42c4f
1 /*
2 * DMA helper functions
4 * Copyright (c) 2009 Red Hat
6 * This work is licensed under the terms of the GNU General Public License
7 * (GNU GPL), version 2 or later.
8 */
10 #ifndef DMA_H
11 #define DMA_H
13 #include <stdio.h>
14 //#include "cpu.h"
15 #include "hw/hw.h"
16 #include "block.h"
18 typedef struct ScatterGatherEntry ScatterGatherEntry;
20 #if defined(TARGET_PHYS_ADDR_BITS)
21 struct ScatterGatherEntry {
22 target_phys_addr_t base;
23 target_phys_addr_t len;
26 struct QEMUSGList {
27 ScatterGatherEntry *sg;
28 int nsg;
29 int nalloc;
30 target_phys_addr_t size;
33 void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint);
34 void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
35 target_phys_addr_t len);
36 void qemu_sglist_destroy(QEMUSGList *qsg);
37 #endif
39 typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
40 QEMUIOVector *iov, int nb_sectors,
41 BlockDriverCompletionFunc *cb, void *opaque);
43 BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs,
44 QEMUSGList *sg, uint64_t sector_num,
45 DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
46 void *opaque, bool to_dev);
47 BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
48 QEMUSGList *sg, uint64_t sector,
49 BlockDriverCompletionFunc *cb, void *opaque);
50 BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
51 QEMUSGList *sg, uint64_t sector,
52 BlockDriverCompletionFunc *cb, void *opaque);
53 #endif