void *iommu_dma_memory_map(DMAContext *dma, dma_addr_t addr, dma_addr_t *len,

                           DMADirection dir)

{

    int err;

    target_phys_addr_t paddr, plen;

    void *buf;



    if (dma->map) {

        return dma->map(dma, addr, len, dir);

    }



    plen = *len;

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

    if (err) {

        return NULL;

    }



    /*

     * If this is true, the virtual region is contiguous,

     * but the translated physical region isn't. We just

     * clamp *len, much like address_space_map() does.

     */

    if (plen < *len) {

        *len = plen;

    }



    buf = address_space_map(dma->as, paddr, &plen, dir == DMA_DIRECTION_FROM_DEVICE);

    *len = plen;



    return buf;

}

void *iommu_dma_memory_map(DMAContext *dma, dma_addr_t addr, dma_addr_t *len,

                           DMADirection dir)

{

    int err;

    target_phys_addr_t paddr, plen;

    void *buf;



    if (dma->map) {

        return dma->map(dma, addr, len, dir);

    }



    plen = *len;

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

    if (err) {

        return NULL;

    }



    









    if (plen < *len) {

        *len = plen;

    }



    buf = address_space_map(dma->as, paddr, &plen, dir == DMA_DIRECTION_FROM_DEVICE);

    *len = plen;



    return buf;

}

void *FUNC_0(DMAContext *VAR_0, dma_addr_t VAR_1, dma_addr_t *VAR_2,

                           DMADirection VAR_3)

{

    int VAR_4;

    target_phys_addr_t paddr, plen;

    void *VAR_5;



    if (VAR_0->map) {

        return VAR_0->map(VAR_0, VAR_1, VAR_2, VAR_3);

    }



    plen = *VAR_2;

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

    if (VAR_4) {

        return NULL;

    }



    









    if (plen < *VAR_2) {

        *VAR_2 = plen;

    }



    VAR_5 = address_space_map(VAR_0->as, paddr, &plen, VAR_3 == DMA_DIRECTION_FROM_DEVICE);

    *VAR_2 = plen;



    return VAR_5;

}

void *FUNC_0(DMAContext *VAR_0, dma_addr_t VAR_1, dma_addr_t *VAR_2,
DMADirection VAR_3)
{ int VAR_4; target_phys_addr_t paddr, plen; void *VAR_5; if (VAR_0->map) { return VAR_0->map(VAR_0, VAR_1, VAR_2, VAR_3); } plen = *VAR_2; VAR_4 = VAR_0->translate(VAR_0, VAR_1, &paddr, &plen, VAR_3); if (VAR_4) { return NULL; } if (plen < *VAR_2) { *VAR_2 = plen; } VAR_5 = address_space_map(VAR_0->as, paddr, &plen, VAR_3 == DMA_DIRECTION_FROM_DEVICE); *VAR_2 = plen; return VAR_5; }