1/* 2 * Copyright (c) 2014, ETH Zurich. All rights reserved. 3 * 4 * This file is distributed under the terms in the attached LICENSE file. 5 * If you do not find this file, copies can be found by writing to: 6 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 7 */ 8 9#include <string.h> 10#include <barrelfish/barrelfish.h> 11 12#include <dev/ioat_dma_dev.h> 13 14#include <ioat/ioat_dma_internal.h> 15#include <ioat/ioat_dma_descriptors_internal.h> 16 17/* 18 * ============================================================================ 19 * Public Interface 20 * ============================================================================ 21 */ 22 23/** 24 * \brief initializes the hardware specific part of the descriptor 25 * 26 * \param desc IOAT DMA descriptor 27 * \param src Source address of the transfer 28 * \param dst destination address of the transfer 29 * \param size number of bytes to copy 30 * \param ctrl control flags 31 * 32 * XXX: this function assumes that the size of the descriptor has already been 33 * checked and must match the maximum transfer size of the channel 34 */ 35inline void ioat_dma_desc_fill_memcpy(struct dma_descriptor *desc, 36 lpaddr_t src, 37 lpaddr_t dst, 38 uint32_t size, 39 ioat_dma_desc_ctrl_t ctrl) 40{ 41 uint8_t *vbase = dma_desc_get_desc_handle(desc); 42 ioat_dma_desc_size_insert(vbase, size); 43 ioat_dma_desc_ctrl_insert(vbase, *((uint32_t *) ctrl)); 44 ioat_dma_desc_ctrl_op_insert(ctrl, ioat_dma_desc_op_copy); 45 ioat_dma_desc_src_insert(vbase, src); 46 ioat_dma_desc_dst_insert(vbase, dst); 47} 48 49/** 50 * \brief initializes the hardware specific part of the descriptor 51 * 52 * \param desc IOAT DMA descriptor 53 * \param src Source address of the transfer 54 * \param dst destination address of the transfer 55 * \param size number of bytes to copy 56 * \param ctrl control flags 57 * 58 * XXX: this function assumes that the size of the descriptor has already been 59 * checked and must match the maximum transfer size of the channel 60 */ 61inline void ioat_dma_desc_fill_memset(struct dma_descriptor *desc, 62 uint64_t data, 63 lpaddr_t dst, 64 uint32_t size, 65 ioat_dma_desc_ctrl_t ctrl) 66{ 67 uint8_t *vbase = dma_desc_get_desc_handle(desc); 68 ioat_dma_desc_size_insert(vbase, size); 69 ioat_dma_desc_ctrl_op_insert(ctrl, ioat_dma_desc_op_memset); 70 ioat_dma_desc_ctrl_insert(vbase, *((uint32_t *) ctrl)); 71 ioat_dma_desc_src_insert(vbase, data); 72 ioat_dma_desc_dst_insert(vbase, dst); 73} 74 75/** 76 * \brief initializes the hardware specific part of the descriptor to be used 77 * for nop descriptors (null descriptors) 78 * 79 * \param desc IOAT DMA descriptor 80 */ 81inline void ioat_dma_desc_fill_nop(struct dma_descriptor *desc) 82{ 83 uint8_t *vbase = dma_desc_get_desc_handle(desc); 84 uint32_t ctrl = 0; 85 ioat_dma_desc_ctrl_t dma_ctrl = (ioat_dma_desc_ctrl_t) (&ctrl); 86 ioat_dma_desc_ctrl_int_en_insert(dma_ctrl, 0x1); 87 ioat_dma_desc_ctrl_null_insert(dma_ctrl, 0x1); 88 ioat_dma_desc_ctrl_compl_write_insert(dma_ctrl, 0x1); 89 90 ioat_dma_desc_size_insert(vbase, 1); // size must be non zero 91 ioat_dma_desc_ctrl_insert(vbase, ctrl); 92 ioat_dma_desc_src_insert(vbase, 0); 93 ioat_dma_desc_dst_insert(vbase, 0); 94} 95