mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 01:43:39 +00:00
39 lines
848 B
C
39 lines
848 B
C
![]() |
/*
|
||
|
* DMA helper functions
|
||
|
*
|
||
|
* Copyright (c) 2009 Red Hat
|
||
|
*
|
||
|
* This work is licensed under the terms of the GNU General Public License
|
||
|
* (GNU GPL), version 2 or later.
|
||
|
*/
|
||
|
|
||
|
#include "dma.h"
|
||
|
|
||
|
|
||
|
void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint)
|
||
|
{
|
||
|
qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry));
|
||
|
qsg->nsg = 0;
|
||
|
qsg->nalloc = alloc_hint;
|
||
|
qsg->size = 0;
|
||
|
}
|
||
|
|
||
|
void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
|
||
|
target_phys_addr_t len)
|
||
|
{
|
||
|
if (qsg->nsg == qsg->nalloc) {
|
||
|
qsg->nalloc = 2 * qsg->nalloc + 1;
|
||
|
qsg->sg = qemu_realloc(qsg->sg, qsg->nalloc * sizeof(ScatterGatherEntry));
|
||
|
}
|
||
|
qsg->sg[qsg->nsg].base = base;
|
||
|
qsg->sg[qsg->nsg].len = len;
|
||
|
qsg->size += len;
|
||
|
++qsg->nsg;
|
||
|
}
|
||
|
|
||
|
void qemu_sglist_destroy(QEMUSGList *qsg)
|
||
|
{
|
||
|
qemu_free(qsg->sg);
|
||
|
}
|
||
|
|