source: trunk/kernel/devices/dev_mmc.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: 8.4 KB
Line 
1/*
2 * dev_mmc.h - MMC (Generic L2 cache controller) 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 PARTICULAR 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_MMC_H_
25#define _DEV_MMC_H_
26
27#include <kernel_config.h>
28#include <hal_kernel_types.h>
29
30/*****************************************************************************************
31 *     Generic L2 cache controller definition
32 *
33 * The MMC (Memory Cache Controller) device describes an internal peripheral,
34 * acting in all clusters containing a level 2 cache controller.
35 *
36 * It supports  five command types:
37 * - MMC_CC_INVAL   : invalidate all cache lines covering a given buffer in L2 cache.
38 * - MMC_CC_SYNC    : synchronize all cache lines covering a given buffer to L3 cache.
39 * - MMC_GET_ERROR  : return content of a given error signaling register.
40 * - MMC_SET_ERROR  : set a given error signaling register.
41 * - MMC_GET_INSTRU : return content of a given instrumentation register.
42 *
43 * As all L2 caches can be accessed by any thread running in any cluster, a calling
44 * thread must get exclusive access to the MMC configuration interface.
45 * As these operations consume few cycles, and access conflicts are expected to be
46 * rare events, the calling threads use a busy waiting strategy to get the device
47 * busylock, but do not register in the device waiting queue, and no server thread
48 * is used for this device.
49 ****************************************************************************************/
50 
51/****  Forward declarations  ****/
52
53struct chdev_s;
54
55/******************************************************************************************
56 * This enum defines the various implementations of the generic MMC peripheral.
57 * It must be kept consistent with the define in arch_info.h file.
58 *****************************************************************************************/
59
60enum mmc_impl_e
61{
62    IMPL_MMC_TSR =   0,     
63}
64mmc_impl_t;
65
66/*****************************************************************************************
67 * This structure defines the (implementation independant) command pased to the driver.
68 * To have a fixed format, the arguments interpretation depends on the command type.
69 ****************************************************************************************/
70
71enum
72{
73    MMC_CC_INVAL   = 0,
74    MMC_CC_SYNC    = 1,
75    MMC_GET_ERROR  = 2,
76    MMC_SET_ERROR  = 3,
77    MMC_GET_INSTRU = 4,
78};
79
80typedef struct mmc_command_s
81{
82    xptr_t      dev_xp;     /*! extended pointer on target MMC device descriptor        */
83    uint32_t    type;       /*! CC_INVAL / CC_SYNC / GET_ERROR / SET_ERROR / GET_INSTRU */
84    void      * buf_ptr;    /*! local pointer on memory buffer    (used by INVAL/SYNC)  */
85    uint32_t    buf_size;   /*! memory buffer size (bytes)        (used by INVAL/SYNC)  */
86    uint32_t    reg_index;  /*! register index in MMC peripheral  (used by SET/GET)     */
87    uint32_t  * reg_ptr;    /*! local pointer on src/dst buffer   (used by SET/GET)     */
88    error_t     error;      /*! operation status (0 if success)                         */
89}
90mmc_command_t;
91
92/*****************************************************************************************
93 * This function initializes the driver specific fields in the generic MMC device
94 * descriptor, and the implementation specific driver.
95 * It must be executed once in any cluster containing an L2 cache.
96 *****************************************************************************************
97 * @ chdev      : pointer on MMC device descriptor.
98 ****************************************************************************************/
99void dev_mmc_init( struct chdev_s * chdev );
100
101/*****************************************************************************************
102 * This function invalidates all cache lines covering a memory buffer
103 * in the physical address space.
104 * It can be executed by any thread in any cluster, because it uses remote accesses
105 * to access both the MMC device descriptor, and the L2 cache configuration interface.
106 *****************************************************************************************
107 * @ buf_xp     : extended pointer on memory buffer.
108 * @ buf_size   : buffer size (bytes).
109 * @ return 0 if success / return EINVAL if failure
110 ****************************************************************************************/
111error_t dev_mmc_inval( xptr_t     buf_xp,
112                       uint32_t   buf_size );
113
114/*****************************************************************************************
115 * This function forces the L2 cache to synchronize the L3 cache for all cache lines
116 * covering a memory buffer in the physical address space.
117 * It can be executed by any thread in any cluster, because it uses remote accesses
118 * to access both the MMC device descriptor, and the L2 cache configuration interface.
119 *****************************************************************************************
120 * @ buf_xp     : extended pointer on memory buffer.
121 * @ buf_size   : buffer size (bytes).
122 * @ return 0 if success / return EINVAL if failure
123 ****************************************************************************************/
124error_t dev_mmc_sync( xptr_t     buf_xp,
125                      uint32_t   buf_size );
126                       
127/*****************************************************************************************
128 * This function set a value in one error signaling MMC register.
129 * It can be executed by any thread in any cluster, because it uses remote accesses
130 * to access the L2 cache instrumentation interface in any cluster.
131 *****************************************************************************************
132 * @ cxy     : MMC cluster identifier.
133 * @ index   : register index in MMC peripheral.
134 * @ wdata   : value to be written.
135 * @ return 0 if success / return EINVAL if failure
136 ****************************************************************************************/
137error_t dev_mmc_set_error( cxy_t    cxy,
138                           uint32_t index,
139                           uint32_t wdata );
140             
141/*****************************************************************************************
142 * This function returns the value contained in one error signaling MMC register.
143 * It can be executed by any thread in any cluster, because it uses remote accesses
144 * to access the L2 cache instrumentation interface in any cluster.
145 *****************************************************************************************
146 * @ cxy     : MMC cluster identifier.
147 * @ index   : error register index in MMC peripheral.
148 * @ rdata   : local pointer on buffer for returned value.
149 * @ return 0 if success / return EINVAL if failure
150 ****************************************************************************************/
151error_t dev_mmc_get_error( cxy_t      cxy,
152                           uint32_t   index, 
153                           uint32_t * rdata );
154             
155
156/*****************************************************************************************
157 * This function returns the value contained in one instrumentation MMC register.
158 * It can be executed by any thread in any cluster, because it uses remote accesses
159 * to access the L2 cache configuration interface in any cluster.
160 *****************************************************************************************
161 * @ cxy     : MMC cluster identifier.
162 * @ index   : instrumentation register index in MMC peripheral.
163 * @ rdata   : local pointer on buffer for returned value.
164 * @ return 0 if success / return EINVAL if failure
165 ****************************************************************************************/
166error_t dev_mmc_get_instrumentation( cxy_t      cxy,
167                                     uint32_t   index,
168                                     uint32_t * rdata );
169
170#endif  /* _DEV_MMC_H_ */
Note: See TracBrowser for help on using the repository browser.