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

Last change on this file since 176 was 14, checked in by alain, 8 years ago

Bugs fix.

File size: 4.5 KB
Line 
1/*
2 * dev_dma.h - DMA (Direct Memory Access) generic device API definition.
3 *
4 * Authors   Alain Greiner  (2017)
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_types.h>
29#include <spinlock.h>
30
31/*****************************************************************************************
32 *     Generic Multi-channels DMA controller definition
33 *
34 * The DMA device describes a generic, multi-channels DMA controller, that can be used
35 * by the kernel to speedup memory copies. It is an "internal" device, replicated in all
36 * clusters. It can only be configured by a local kernel thread, but it can move data
37 * to/from remote clusters. The burst size is defined by the cache line size.
38 * Each DMA channel is described by a specific chdev descriptor, handling its private
39 * waiting threads queue.
40 * It implement one single command : move data from a (remote) source buffer
41 * to a (remote) destination buffer.
42 ****************************************************************************************/
43 
44/****  Forward declarations  ****/
45
46struct chdev_s;
47
48/*****************************************************************************************
49 * This defines the (implementation independant) command passed to the driver.
50 ****************************************************************************************/
51
52typedef struct dma_command_s
53{
54    xptr_t      dev_xp;    /*! extended pointer on the DMA chdev descriptor             */
55    xptr_t      src_xp;    /*! extended pointer on source buffer.                        */
56    xptr_t      dst_xp;    /*! extended pointer on destination buffer.                   */
57    uint32_t    size;      /*! number of bytes to move.                                  */
58    uint32_t    error;     /*! operation status (0 if success)                           */
59}
60dma_command_t;
61
62/*****************************************************************************************
63 * This enum defines the various implementations of the DMA internal interrupt controller.
64 * This array must be kept consistent with the define in arch_info.h file
65 ****************************************************************************************/
66
67enum dma_impl_e
68{
69    IMPL_DMA_SCL =   0,         /* vci_xdma component used in TSAR                      */
70    IMPL_DMA_I86 =   1          /* TBD                                                  */
71}
72dma_impl_t;
73
74/*****************************************************************************************
75 * This function makes two initialisations:
76 * - It initialises the DMA specific fields of the chdev descriptor.
77 * - it initialises the implementation specific DMA hardware device and associated
78 *   data structures if required.
79 * It must be called by a local thread.
80 *****************************************************************************************
81 * @ chdev   : pointer on DMA chdev descriptor.
82 ****************************************************************************************/
83void dev_dma_init( struct chdev_s * chdev );
84
85/*****************************************************************************************
86 * This blocking function register a DMA request in the device queue.
87 * It uses a descheduling policy to wait completion, and return an error status
88 * when the transfer is completed.
89 *****************************************************************************************
90 * @ dst        : extended pointer on destination buffer.
91 * @ src        : extended pointer on Rsource buffer.
92 * @ size       : number of bytes to move.
93 ****************************************************************************************/
94error_t dev_dma_remote_memcpy( xptr_t     dst_xp,
95                               xptr_t     src_xp,
96                               uint32_t   size );   
97
98
99#endif  /* _DEV_DMA_H_ */
Note: See TracBrowser for help on using the repository browser.