dma.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef DMA_H
  10. #define DMA_H
  11. #include <stdio.h>
  12. //#include "cpu.h"
  13. #include "hw/hw.h"
  14. #include "block.h"
  15. typedef struct {
  16. target_phys_addr_t base;
  17. target_phys_addr_t len;
  18. } ScatterGatherEntry;
  19. typedef struct {
  20. ScatterGatherEntry *sg;
  21. int nsg;
  22. int nalloc;
  23. target_phys_addr_t size;
  24. } QEMUSGList;
  25. void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint);
  26. void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
  27. target_phys_addr_t len);
  28. void qemu_sglist_destroy(QEMUSGList *qsg);
  29. typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
  30. QEMUIOVector *iov, int nb_sectors,
  31. BlockDriverCompletionFunc *cb, void *opaque);
  32. BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs,
  33. QEMUSGList *sg, uint64_t sector_num,
  34. DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
  35. void *opaque, int is_write);
  36. BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
  37. QEMUSGList *sg, uint64_t sector,
  38. BlockDriverCompletionFunc *cb, void *opaque);
  39. BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
  40. QEMUSGList *sg, uint64_t sector,
  41. BlockDriverCompletionFunc *cb, void *opaque);
  42. #endif