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

Last change on this file since 657 was 657, checked in by alain, 4 years ago

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File size: 5.6 KB
Line 
1/*
2 * dev_dma.h - DMA (Direct Memory Access) generic device API definition.
3 *
4 * Authors   Alain Greiner  (2016,2017,2018,2019,2020)
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. It implements two blocking commands :
39 * - move synchronously data from a remote source buffer to a remote destination buffer,
40 *   using a polling policy to wait completion (No DMA_IRQ use).
41 * - move synchronously data from a remote source buffer to a remote destination buffer,
42 *   using a descheduling policy to wait completion (reactivated bythe IDMA_IRQ).
43 ****************************************************************************************/
44 
45/****  Forward declarations  ****/
46
47struct chdev_s;
48
49/*****************************************************************************************
50 * This defines the (implementation independant) command passed to the driver.
51 ****************************************************************************************/
52
53typedef struct dma_command_s
54{
55    bool_t      sync;      /*! polling policy if true / descheduling policy if false     */
56    xptr_t      dev_xp;    /*! extended pointer on the DMA chdev descriptor              */
57    xptr_t      src_xp;    /*! extended pointer on source buffer.                        */
58    xptr_t      dst_xp;    /*! extended pointer on destination buffer.                   */
59    uint32_t    size;      /*! number of bytes to move.                                  */
60    uint32_t    error;     /*! operation status (0 if success)                           */
61}
62dma_command_t;
63
64/*****************************************************************************************
65 * This enum defines the various implementations of the DMA internal interrupt controller.
66 * This array must be kept consistent with the define in arch_info.h file
67 ****************************************************************************************/
68
69enum dma_impl_e
70{
71    IMPL_DMA_SCL =   0,         /* vci_xdma component used in TSAR                      */
72    IMPL_DMA_I86 =   1          /* TBD                                                  */
73}
74dma_impl_t;
75
76/*****************************************************************************************
77 * This function makes two initialisations:
78 * - It initialises the DMA specific fields of the chdev descriptor.
79 * - it initialises the implementation specific DMA hardware device and associated
80 *   data structures if required.
81 * It must be called by a local thread.
82 *****************************************************************************************
83 * @ chdev   : pointer on DMA chdev descriptor.
84 ****************************************************************************************/
85void dev_dma_init( struct chdev_s * chdev );
86
87/*****************************************************************************************
88 * This blocking function register a DMA request in the device queue.
89 * It uses a descheduling policy to wait completion,
90 * It return an error status when the transfer is completed.
91 *****************************************************************************************
92 * @ dst_xp     : extended pointer on destination buffer.
93 * @ src_xp     : extended pointer on source buffer.
94 * @ size       : number of bytes to move.
95 ****************************************************************************************/
96error_t dev_dma_async_memcpy( xptr_t     dst_xp,
97                              xptr_t     src_xp,
98                              uint32_t   size );   
99
100/*****************************************************************************************
101 * This blocking function register a DMA request in the device queue.
102 * It uses a polling policy to wait completion.
103 * It return an error status when the transfer is completed.
104 *****************************************************************************************
105 * @ dst_xp     : extended pointer on destination buffer.
106 * @ src_xp     : extended pointer on source buffer.
107 * @ size       : number of bytes to move.
108 ****************************************************************************************/
109error_t dev_dma_sync_memcpy( xptr_t     dst_xp,
110                             xptr_t     src_xp,
111                             uint32_t   size );   
112
113
114#endif  /* _DEV_DMA_H_ */
Note: See TracBrowser for help on using the repository browser.