source: trunk/kernel/devices/dev_dma.h @ 565

Last change on this file since 565 was 565, checked in by alain, 3 years ago

Complete restructuration of kernel locks.

File size: 4.5 KB
Line 
1/*
2 * dev_dma.h - DMA (Direct Memory Access) generic device API definition.
3 *
4 * Authors   Alain Greiner  (2016,2017,2018)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTDMALAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _DEV_DMA_H_
25#define _DEV_DMA_H_
26
27#include <kernel_config.h>
28#include <hal_kernel_types.h>
29
30/*****************************************************************************************
31 *     Generic Multi-channels DMA controller definition
32 *
33 * The DMA device describes a generic, multi-channels DMA controller, that can be used
34 * by the kernel to speedup memory copies. It is an "internal" device, replicated in all
35 * clusters. It can only be configured by a local kernel thread, but it can move data
36 * to/from remote clusters. The burst size is defined by the cache line size.
37 * Each DMA channel is described by a specific chdev descriptor, handling its private
38 * waiting threads queue.
39 * It implement one single command : move data from a (remote) source buffer
40 * to a (remote) destination buffer.
41 ****************************************************************************************/
42 
43/****  Forward declarations  ****/
44
45struct chdev_s;
46
47/*****************************************************************************************
48 * This defines the (implementation independant) command passed to the driver.
49 ****************************************************************************************/
50
51typedef struct dma_command_s
52{
53    xptr_t      dev_xp;    /*! extended pointer on the DMA chdev descriptor             */
54    xptr_t      src_xp;    /*! extended pointer on source buffer.                        */
55    xptr_t      dst_xp;    /*! extended pointer on destination buffer.                   */
56    uint32_t    size;      /*! number of bytes to move.                                  */
57    uint32_t    error;     /*! operation status (0 if success)                           */
58}
59dma_command_t;
60
61/*****************************************************************************************
62 * This enum defines the various implementations of the DMA internal interrupt controller.
63 * This array must be kept consistent with the define in arch_info.h file
64 ****************************************************************************************/
65
66enum dma_impl_e
67{
68    IMPL_DMA_SCL =   0,         /* vci_xdma component used in TSAR                      */
69    IMPL_DMA_I86 =   1          /* TBD                                                  */
70}
71dma_impl_t;
72
73/*****************************************************************************************
74 * This function makes two initialisations:
75 * - It initialises the DMA specific fields of the chdev descriptor.
76 * - it initialises the implementation specific DMA hardware device and associated
77 *   data structures if required.
78 * It must be called by a local thread.
79 *****************************************************************************************
80 * @ chdev   : pointer on DMA chdev descriptor.
81 ****************************************************************************************/
82void dev_dma_init( struct chdev_s * chdev );
83
84/*****************************************************************************************
85 * This blocking function register a DMA request in the device queue.
86 * It uses a descheduling policy to wait completion, and return an error status
87 * when the transfer is completed.
88 *****************************************************************************************
89 * @ dst        : extended pointer on destination buffer.
90 * @ src        : extended pointer on Rsource buffer.
91 * @ size       : number of bytes to move.
92 ****************************************************************************************/
93error_t dev_dma_remote_memcpy( xptr_t     dst_xp,
94                               xptr_t     src_xp,
95                               uint32_t   size );   
96
97
98#endif  /* _DEV_DMA_H_ */
Note: See TracBrowser for help on using the repository browser.