static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,

                                  DMADirection dir)

{

    dma_addr_t addr;

    DMADirection expected_dir;



    if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) {

        expected_dir = DMA_DIRECTION_FROM_DEVICE;

    } else {

        expected_dir = DMA_DIRECTION_TO_DEVICE;

    }



    if (dir != expected_dir) {

        trace_esp_pci_error_invalid_dma_direction();

        return;

    }



    if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) {

        qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n");

    }



    addr = pci->dma_regs[DMA_SPA];

    if (pci->dma_regs[DMA_WBC] < len) {

        len = pci->dma_regs[DMA_WBC];

    }



    pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir);



    /* update status registers */

    pci->dma_regs[DMA_WBC] -= len;

    pci->dma_regs[DMA_WAC] += len;



}
static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,

                                  DMADirection dir)

{

    dma_addr_t addr;

    DMADirection expected_dir;



    if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) {

        expected_dir = DMA_DIRECTION_FROM_DEVICE;

    } else {

        expected_dir = DMA_DIRECTION_TO_DEVICE;

    }



    if (dir != expected_dir) {

        trace_esp_pci_error_invalid_dma_direction();

        return;

    }



    if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) {

        qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n");

    }



    addr = pci->dma_regs[DMA_SPA];

    if (pci->dma_regs[DMA_WBC] < len) {

        len = pci->dma_regs[DMA_WBC];

    }



    pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir);



    

    pci->dma_regs[DMA_WBC] -= len;

    pci->dma_regs[DMA_WAC] += len;



}
static void FUNC_0(PCIESPState *VAR_0, uint8_t *VAR_1, int VAR_2,

                                  DMADirection VAR_3)

{

    dma_addr_t addr;

    DMADirection expected_dir;



    if (VAR_0->dma_regs[DMA_CMD] & DMA_CMD_DIR) {

        expected_dir = DMA_DIRECTION_FROM_DEVICE;

    } else {

        expected_dir = DMA_DIRECTION_TO_DEVICE;

    }



    if (VAR_3 != expected_dir) {

        trace_esp_pci_error_invalid_dma_direction();

        return;

    }



    if (VAR_0->dma_regs[DMA_STAT] & DMA_CMD_MDL) {

        qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n");

    }



    addr = VAR_0->dma_regs[DMA_SPA];

    if (VAR_0->dma_regs[DMA_WBC] < VAR_2) {

        VAR_2 = VAR_0->dma_regs[DMA_WBC];

    }



    pci_dma_rw(PCI_DEVICE(VAR_0), addr, VAR_1, VAR_2, VAR_3);



    

    VAR_0->dma_regs[DMA_WBC] -= VAR_2;

    VAR_0->dma_regs[DMA_WAC] += VAR_2;



}
static void FUNC_0(PCIESPState *VAR_0, uint8_t *VAR_1, int VAR_2,
DMADirection VAR_3)
{ dma_addr_t addr; DMADirection expected_dir; if (VAR_0->dma_regs[DMA_CMD] & DMA_CMD_DIR) { expected_dir = DMA_DIRECTION_FROM_DEVICE; } else { expected_dir = DMA_DIRECTION_TO_DEVICE; } if (VAR_3 != expected_dir) { trace_esp_pci_error_invalid_dma_direction(); return; } if (VAR_0->dma_regs[DMA_STAT] & DMA_CMD_MDL) { qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } addr = VAR_0->dma_regs[DMA_SPA]; if (VAR_0->dma_regs[DMA_WBC] < VAR_2) { VAR_2 = VAR_0->dma_regs[DMA_WBC]; } pci_dma_rw(PCI_DEVICE(VAR_0), addr, VAR_1, VAR_2, VAR_3); VAR_0->dma_regs[DMA_WBC] -= VAR_2; VAR_0->dma_regs[DMA_WAC] += VAR_2; }