int iommu_dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c,

                         dma_addr_t len)

{

    target_phys_addr_t paddr, plen;

    int err;



#ifdef DEBUG_IOMMU

    fprintf(stderr, "dma_memory_set context=%p addr=0x" DMA_ADDR_FMT

            " len=0x" DMA_ADDR_FMT "\n", dma, addr, len);

#endif



    while (len) {

        err = dma->translate(dma, addr, &paddr, &plen,

                             DMA_DIRECTION_FROM_DEVICE);

        if (err) {

            return err;

        }



        /* The translation might be valid for larger regions. */

        if (plen > len) {

            plen = len;

        }



        do_dma_memory_set(dma->as, paddr, c, plen);



        len -= plen;

        addr += plen;

    }



    return 0;

}

int iommu_dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c,

                         dma_addr_t len)

{

    target_phys_addr_t paddr, plen;

    int err;



#ifdef DEBUG_IOMMU

    fprintf(stderr, "dma_memory_set context=%p addr=0x" DMA_ADDR_FMT

            " len=0x" DMA_ADDR_FMT "\n", dma, addr, len);

#endif



    while (len) {

        err = dma->translate(dma, addr, &paddr, &plen,

                             DMA_DIRECTION_FROM_DEVICE);

        if (err) {

            return err;

        }



        

        if (plen > len) {

            plen = len;

        }



        do_dma_memory_set(dma->as, paddr, c, plen);



        len -= plen;

        addr += plen;

    }



    return 0;

}

int FUNC_0(DMAContext *VAR_0, dma_addr_t VAR_1, uint8_t VAR_2,

                         dma_addr_t VAR_3)

{

    target_phys_addr_t paddr, plen;

    int VAR_4;



#ifdef DEBUG_IOMMU

    fprintf(stderr, "dma_memory_set context=%p VAR_1=0x" DMA_ADDR_FMT

            " VAR_3=0x" DMA_ADDR_FMT "\n", VAR_0, VAR_1, VAR_3);

#endif



    while (VAR_3) {

        VAR_4 = VAR_0->translate(VAR_0, VAR_1, &paddr, &plen,

                             DMA_DIRECTION_FROM_DEVICE);

        if (VAR_4) {

            return VAR_4;

        }



        

        if (plen > VAR_3) {

            plen = VAR_3;

        }



        do_dma_memory_set(VAR_0->as, paddr, VAR_2, plen);



        VAR_3 -= plen;

        VAR_1 += plen;

    }



    return 0;

}

int FUNC_0(DMAContext *VAR_0, dma_addr_t VAR_1, uint8_t VAR_2,
dma_addr_t VAR_3)
{ target_phys_addr_t paddr, plen; int VAR_4; #ifdef DEBUG_IOMMU
fprintf(stderr, "dma_memory_set context=%p VAR_1=0x" DMA_ADDR_FMT
" VAR_3=0x" DMA_ADDR_FMT "\n", VAR_0, VAR_1, VAR_3); #endif
while (VAR_3) { VAR_4 = VAR_0->translate(VAR_0, VAR_1, &paddr, &plen,
DMA_DIRECTION_FROM_DEVICE); if (VAR_4) { return VAR_4; } if (plen > VAR_3) { plen = VAR_3; } do_dma_memory_set(VAR_0->as, paddr, VAR_2, plen); VAR_3 -= plen; VAR_1 += plen; } return 0; }