1/* 2 * xlnx_dpdma.h 3 * 4 * Copyright (C) 2015 : GreenSocs Ltd 5 * http://www.greensocs.com/ , email: info@greensocs.com 6 * 7 * Developed by : 8 * Frederic Konrad <fred.konrad@greensocs.com> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation, either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with this program; if not, see <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25#ifndef XLNX_DPDMA_H 26#define XLNX_DPDMA_H 27 28#include "hw/sysbus.h" 29#include "ui/console.h" 30#include "sysemu/dma.h" 31 32#define XLNX_DPDMA_REG_ARRAY_SIZE (0x1000 >> 2) 33 34struct XlnxDPDMAState { 35 /*< private >*/ 36 SysBusDevice parent_obj; 37 /*< public >*/ 38 MemoryRegion *dma_mr; 39 AddressSpace *dma_as; 40 MemoryRegion iomem; 41 uint32_t registers[XLNX_DPDMA_REG_ARRAY_SIZE]; 42 uint8_t *data[6]; 43 bool operation_finished[6]; 44 qemu_irq irq; 45}; 46 47typedef struct XlnxDPDMAState XlnxDPDMAState; 48 49#define TYPE_XLNX_DPDMA "xlnx.dpdma" 50#define XLNX_DPDMA(obj) OBJECT_CHECK(XlnxDPDMAState, (obj), TYPE_XLNX_DPDMA) 51 52/* 53 * xlnx_dpdma_start_operation: Start the operation on the specified channel. The 54 * DPDMA gets the current descriptor and retrieves 55 * data to the buffer specified by 56 * dpdma_set_host_data_location(). 57 * 58 * Returns The number of bytes transfered by the DPDMA or 0 if an error occured. 59 * 60 * @s The DPDMA state. 61 * @channel The channel to start. 62 */ 63size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, uint8_t channel, 64 bool one_desc); 65 66/* 67 * xlnx_dpdma_set_host_data_location: Set the location in the host memory where 68 * to store the data out from the dma 69 * channel. 70 * 71 * @s The DPDMA state. 72 * @channel The channel associated to the pointer. 73 * @p The buffer where to store the data. 74 */ 75/* XXX: add a maximum size arg and send an interrupt in case of overflow. */ 76void xlnx_dpdma_set_host_data_location(XlnxDPDMAState *s, uint8_t channel, 77 void *p); 78 79/* 80 * xlnx_dpdma_trigger_vsync_irq: Trigger a VSYNC IRQ when the display is 81 * updated. 82 * 83 * @s The DPDMA state. 84 */ 85void xlnx_dpdma_trigger_vsync_irq(XlnxDPDMAState *s); 86 87#endif /* !XLNX_DPDMA_H */ 88