1 /*
2  * Copyright (c) 2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /**
9  * \file dma350_checker_layer.h
10  *
11  * \brief Checker layer for the DMA accesses.
12  *
13  */
14 
15 #ifndef __DMA350_CHECKER_LAYER_H__
16 #define __DMA350_CHECKER_LAYER_H__
17 
18 #include "dma350_ch_drv.h"
19 #include "dma350_lib.h"
20 
21 #include <stdint.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Enumeration for the supported DMA library commands */
28 enum dma350_config_type_t {
29     DMA_CALL_MEMMOVE = 0,
30     DMA_CALL_MEMCPY,
31     DMA_CALL_DRAW_FROM_CANVAS,
32     DMA_CLEAR_DONE_IRQ,
33     DMA_GET_STATUS,
34     DMA_NUMBER_OF_COMMANDS
35 };
36 
37 /* Structure for the memcpy setup */
38 struct dma350_memcpy_config {
39     enum dma350_lib_exec_type_t   exec_type;      /*!< The execution type of the command */
40     const void*                   src;            /*!< Source start address */
41     void*                         dst;            /*!< Destination start address */
42     uint32_t                      size;           /*!< Number of bytes to copy */
43 };
44 
45 /* Structure for the memmove setup */
46 struct dma350_memmove_config {
47     enum dma350_lib_exec_type_t   exec_type;      /*!< The execution type of the command */
48     const void*                   src;            /*!< Source start address */
49     void*                         dst;            /*!< Destination start address */
50     uint32_t                      size;           /*!< Number of bytes to move */
51 };
52 
53 /* Structure for the draw setup */
54 struct dma350_draw_config {
55     enum dma350_lib_exec_type_t   exec_type;      /*!< The execution type of the command */
56     const void*                   src;            /*!< Source start address */
57     void*                         des;            /*!< Destination start address */
58     uint32_t                      src_width;      /*!< Source width */
59     uint16_t                      src_height;     /*!< Source height */
60     uint16_t                      src_line_width; /*!< Source line width */
61     uint32_t                      des_width;      /*!< Destination width */
62     uint16_t                      des_height;     /*!< Destination height */
63     uint16_t                      des_line_width; /*!< Destination line width */
64     enum dma350_ch_transize_t     pixelsize;      /*!< Size of a pixel as in \ref dma350_ch_transize_t */
65     enum dma350_lib_transform_t   transform;      /*!< Transform type as in \ref dma350_lib_transform_t */
66 };
67 
68 /* These definitions are used to verify the incoming channel number and map it
69  * to an actual channel device. */
70 struct dma350_checker_channels_t {
71     struct dma350_ch_dev_t* const * channels;
72     const uint8_t number_of_channels;
73 };
74 extern struct dma350_checker_channels_t const DMA350_CHECKER_CHANNELS;
75 
76 /**
77  * \brief Setup the DMA350 and start the requested command.
78  *
79  * \param[in] config_type   The DMA350 command's type
80  * \param[in] channel       The DMA channel, the operation should use
81  * \param[in] config        The config for the DMA350 command. Its type has to
82  *                          be in sync with the command.
83  *
84  * \return Result of the operation \ref dma350_lib_error_t
85  *
86  * \note This function has to be called from privileged level.
87  */
88 enum dma350_lib_error_t config_dma350_for_unprivileged_actor(enum dma350_config_type_t config_type, uint8_t channel, void* config);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 #endif /* __DMA350_CHECKER_LAYER_H__ */
94