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

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

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

File size: 5.6 KB
RevLine 
[3]1/*
2 * dev_dma.h - DMA (Direct Memory Access) generic device API definition.
3 *
[657]4 * Authors   Alain Greiner  (2016,2017,2018,2019,2020)
[3]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
[14]27#include <kernel_config.h>
[457]28#include <hal_kernel_types.h>
[3]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
[657]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).
[3]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{
[657]55    bool_t      sync;      /*! polling policy if true / descheduling policy if false     */
56    xptr_t      dev_xp;    /*! extended pointer on the DMA chdev descriptor              */
[3]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.
[657]89 * It uses a descheduling policy to wait completion,
90 * It return an error status when the transfer is completed.
[3]91 *****************************************************************************************
[657]92 * @ dst_xp     : extended pointer on destination buffer.
93 * @ src_xp     : extended pointer on source buffer.
[3]94 * @ size       : number of bytes to move.
95 ****************************************************************************************/
[657]96error_t dev_dma_async_memcpy( xptr_t     dst_xp,
97                              xptr_t     src_xp,
98                              uint32_t   size );   
[3]99
[657]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 );   
[3]112
[657]113
[3]114#endif  /* _DEV_DMA_H_ */
Note: See TracBrowser for help on using the repository browser.