115021Sjoerg/* 215021Sjoerg * Copyright (c) 2014 ETH Zurich. 315021Sjoerg * All rights reserved. 415021Sjoerg * 515021Sjoerg * This file is distributed under the terms in the attached LICENSE file. 615021Sjoerg * If you do not find this file, copies can be found by writing to: 715021Sjoerg * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 815021Sjoerg */ 915021Sjoerg 1015021Sjoerg#ifndef DMA_DESCRIPTOR_INTERNAL_H 1115021Sjoerg#define DMA_DESCRIPTOR_INTERNAL_H 1215021Sjoerg 1315021Sjoerg#include <dma/dma_descriptor.h> 1415021Sjoerg 1515021Sjoergstruct iommu_client; 1615021Sjoerg 1715021Sjoerg/* 1815021Sjoerg * ---------------------------------------------------------------------------- 1915021Sjoerg * Allocation / Deallocation 2015021Sjoerg * ---------------------------------------------------------------------------- 2115021Sjoerg */ 2215021Sjoerg 2315021Sjoerg/** 2415021Sjoerg * \brief allocates a number of hardware DMA descriptors and fills them into the 2515021Sjoerg * array of descriptor pointers 2650476Speter * 27111447Sru * \param size size of a signle descriptor in bytes 28337034Shselasky * \param align alignment constraints of the descriptors 29206622Suqs * \param count number of descriptors to allocate in bits 3015021Sjoerg * \param desc pointer to the array of descriptor pointers 3115021Sjoerg * 3265709Sjake * \returns SYS_ERR_OK on success 33247812Sdavide * errval on error 34153992Sjhb */ 35247812Sdavideerrval_t dma_desc_alloc(uint32_t size, 36166908Sjhb uint16_t align, 37337034Shselasky uint8_t count, 38247812Sdavide struct dma_device *dev, 3915059Smpp struct dma_descriptor **desc); 40247812Sdavide 4115059Smpp/** 4215021Sjoerg * \brief brief frees up the array of previously allocated descriptors 4315021Sjoerg * and releases the resources 4484306Sru * 4584306Sru * \param desc the descriptors to be freed 4684306Sru * 4715021Sjoerg * \returns SYS_ERR_OK on success 48153992Sjhb * errval on failure 49153992Sjhb */ 50247812Sdavideerrval_t dma_desc_free(struct dma_descriptor *desc); 51247812Sdavide 52247812Sdavide/* 53153992Sjhb * ---------------------------------------------------------------------------- 54247812Sdavide * Descriptor getters / setters 55247812Sdavide * ---------------------------------------------------------------------------- 56247812Sdavide */ 57337034Shselasky 58166908Sjhb/** 59337034Shselasky * \brief returns a virtual address pointer to the location where the descriptor 60337034Shselasky * is mapped 61337034Shselasky * 62247812Sdavide * \param desc IOAT DMA descriptor 63247812Sdavide */ 64166908Sjhbuint8_t *dma_desc_get_desc_handle(struct dma_descriptor *desc); 65166908Sjhb 66247812Sdavide/** 67247812Sdavide * \brief sets the corresponding request 68247812Sdavide * 69166908Sjhb * \param desc IOAT DMA descriptor 70153992Sjhb */ 7124737Smppvoid dma_desc_set_request(struct dma_descriptor *desc, 72153992Sjhb struct dma_request *req); 7315021Sjoerg 7415021Sjoerg/** 75157817Sjhb * \brief returns the physical address of the descriptor 76157817Sjhb * 77157817Sjhb * \param desc IOAT DMA descriptor 78166908Sjhb * 79337034Shselasky * \returns physical address of the descriptor 80337034Shselasky */ 81157817Sjhblpaddr_t dma_desc_get_paddr(struct dma_descriptor *desc); 8215021Sjoerg 83157817Sjhb#endif /* DMA_DESCRIPTORS_INTERNAL_H */ 84157817Sjhb