blob: 2bdc236c4c190366e7df35fad29c879ed7c42c4f [file] [log] [blame]
aliguori244ab902009-02-05 21:23:50 +00001/*
2 * DMA helper functions
3 *
4 * Copyright (c) 2009 Red Hat
5 *
6 * This work is licensed under the terms of the GNU General Public License
7 * (GNU GPL), version 2 or later.
8 */
9
10#ifndef DMA_H
11#define DMA_H
12
13#include <stdio.h>
Paul Brook1ad21342009-05-19 16:17:58 +010014//#include "cpu.h"
15#include "hw/hw.h"
aliguori59a703e2009-02-05 21:23:58 +000016#include "block.h"
aliguori244ab902009-02-05 21:23:50 +000017
Paolo Bonzini10dc8ae2011-09-16 16:40:01 +020018typedef struct ScatterGatherEntry ScatterGatherEntry;
19
20#if defined(TARGET_PHYS_ADDR_BITS)
21struct ScatterGatherEntry {
Anthony Liguoric227f092009-10-01 16:12:16 -050022 target_phys_addr_t base;
23 target_phys_addr_t len;
Paolo Bonzini10dc8ae2011-09-16 16:40:01 +020024};
aliguori244ab902009-02-05 21:23:50 +000025
Gerd Hoffmannd35bf9a2011-07-12 13:36:23 +020026struct QEMUSGList {
aliguori244ab902009-02-05 21:23:50 +000027 ScatterGatherEntry *sg;
28 int nsg;
29 int nalloc;
Anthony Liguoric227f092009-10-01 16:12:16 -050030 target_phys_addr_t size;
Gerd Hoffmannd35bf9a2011-07-12 13:36:23 +020031};
aliguori244ab902009-02-05 21:23:50 +000032
33void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint);
Anthony Liguoric227f092009-10-01 16:12:16 -050034void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
35 target_phys_addr_t len);
aliguori244ab902009-02-05 21:23:50 +000036void qemu_sglist_destroy(QEMUSGList *qsg);
Paolo Bonzini10dc8ae2011-09-16 16:40:01 +020037#endif
aliguori244ab902009-02-05 21:23:50 +000038
Christoph Hellwigcb144cc2011-05-19 10:57:59 +020039typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
40 QEMUIOVector *iov, int nb_sectors,
41 BlockDriverCompletionFunc *cb, void *opaque);
42
43BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs,
44 QEMUSGList *sg, uint64_t sector_num,
45 DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
Paolo Bonzinibbca72c2011-09-16 16:40:00 +020046 void *opaque, bool to_dev);
aliguori59a703e2009-02-05 21:23:58 +000047BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
48 QEMUSGList *sg, uint64_t sector,
49 BlockDriverCompletionFunc *cb, void *opaque);
50BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
51 QEMUSGList *sg, uint64_t sector,
52 BlockDriverCompletionFunc *cb, void *opaque);
aliguori244ab902009-02-05 21:23:50 +000053#endif