root / dma.h @ 43cf8ae6
History | View | Annotate | Download (2 kB)
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> |
14 |
//#include "cpu.h"
|
15 |
#include "hw/hw.h" |
16 |
#include "block.h" |
17 |
|
18 |
typedef struct ScatterGatherEntry ScatterGatherEntry; |
19 |
|
20 |
typedef enum { |
21 |
DMA_DIRECTION_TO_DEVICE = 0,
|
22 |
DMA_DIRECTION_FROM_DEVICE = 1,
|
23 |
} DMADirection; |
24 |
|
25 |
struct QEMUSGList {
|
26 |
ScatterGatherEntry *sg; |
27 |
int nsg;
|
28 |
int nalloc;
|
29 |
size_t size; |
30 |
}; |
31 |
|
32 |
#if defined(TARGET_PHYS_ADDR_BITS)
|
33 |
typedef target_phys_addr_t dma_addr_t;
|
34 |
|
35 |
#define DMA_ADDR_FMT TARGET_FMT_plx
|
36 |
|
37 |
struct ScatterGatherEntry {
|
38 |
dma_addr_t base; |
39 |
dma_addr_t len; |
40 |
}; |
41 |
|
42 |
void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint); |
43 |
void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len);
|
44 |
void qemu_sglist_destroy(QEMUSGList *qsg);
|
45 |
#endif
|
46 |
|
47 |
typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
|
48 |
QEMUIOVector *iov, int nb_sectors,
|
49 |
BlockDriverCompletionFunc *cb, void *opaque);
|
50 |
|
51 |
BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs, |
52 |
QEMUSGList *sg, uint64_t sector_num, |
53 |
DMAIOFunc *io_func, BlockDriverCompletionFunc *cb, |
54 |
void *opaque, DMADirection dir);
|
55 |
BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, |
56 |
QEMUSGList *sg, uint64_t sector, |
57 |
BlockDriverCompletionFunc *cb, void *opaque);
|
58 |
BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, |
59 |
QEMUSGList *sg, uint64_t sector, |
60 |
BlockDriverCompletionFunc *cb, void *opaque);
|
61 |
uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); |
62 |
uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); |
63 |
|
64 |
void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie,
|
65 |
QEMUSGList *sg, enum BlockAcctType type);
|
66 |
|
67 |
#endif
|