]> git.proxmox.com Git - qemu.git/blame - dma.h
msi: Guard msi/msix_write_config with msi_present
[qemu.git] / dma.h
CommitLineData
244ab90e
AL
1/*
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>
1ad2134f 14#include "hw/hw.h"
59a703eb 15#include "block.h"
244ab90e 16
10dc8aef
PB
17typedef struct ScatterGatherEntry ScatterGatherEntry;
18
43cf8ae6
DG
19typedef enum {
20 DMA_DIRECTION_TO_DEVICE = 0,
21 DMA_DIRECTION_FROM_DEVICE = 1,
22} DMADirection;
23
fead0c24
PB
24struct QEMUSGList {
25 ScatterGatherEntry *sg;
26 int nsg;
27 int nalloc;
28 size_t size;
29};
30
10dc8aef 31#if defined(TARGET_PHYS_ADDR_BITS)
d9d1055e
DG
32typedef target_phys_addr_t dma_addr_t;
33
34#define DMA_ADDR_FMT TARGET_FMT_plx
35
10dc8aef 36struct ScatterGatherEntry {
d3231181
DG
37 dma_addr_t base;
38 dma_addr_t len;
10dc8aef 39};
244ab90e 40
244ab90e 41void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint);
d3231181 42void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len);
244ab90e 43void qemu_sglist_destroy(QEMUSGList *qsg);
10dc8aef 44#endif
244ab90e 45
cb144ccb
CH
46typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
47 QEMUIOVector *iov, int nb_sectors,
48 BlockDriverCompletionFunc *cb, void *opaque);
49
50BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs,
51 QEMUSGList *sg, uint64_t sector_num,
52 DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
43cf8ae6 53 void *opaque, DMADirection dir);
59a703eb
AL
54BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
55 QEMUSGList *sg, uint64_t sector,
56 BlockDriverCompletionFunc *cb, void *opaque);
57BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
58 QEMUSGList *sg, uint64_t sector,
59 BlockDriverCompletionFunc *cb, void *opaque);
8171ee35
PB
60uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg);
61uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg);
62
84a69356
PB
63void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie,
64 QEMUSGList *sg, enum BlockAcctType type);
65
244ab90e 66#endif