source: trunk/hal/generic/hal_remote.h @ 237

Last change on this file since 237 was 121, checked in by alain, 7 years ago

Fix bugs in hal_remote, hal uspace, hal_special

File size: 9.7 KB
RevLine 
[1]1/*
2 * hal_remote.h - Generic Remote Access API definition.
[17]3 *
[1]4 * Authors   Mohamed Karaoui  (2015)
5 *           Alain Greiner    (2016)
6 *
7 * Copyright (c)  UPMC Sorbonne Universites
[17]8 *
[1]9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef  _HAL_REMOTE_H_
26#define  _HAL_REMOTE_H_
27
28#include <hal_types.h>
29
30//////////////////////////////////////////////////////////////////////////////////////////
[17]31//          Generic Remote Access API (implementation in hal_remote.c)
[1]32//
33// Kernel accesses to local memory bank and peripherals can use normal C pointers.
34// kernel accesses to remote memory banks or peripherals must use the following
35// dedicated functions, because implementation depends on architectures.
36/////////////////////////////////////////////////////////////////////////////////////////
37
38/*****************************************************************************************
39 * This function writes a single byte in a remote cluster.
40 *****************************************************************************************
41 * @ xp      : extended pointer to remote cluster
42 * @ data    : value to be written
43 ****************************************************************************************/
44void hal_remote_sb( xptr_t xp,
[69]45                    uint8_t  data );
[1]46
47/*****************************************************************************************
48 * This function writes an aligned 32 bits word in a remote cluster.
49 *****************************************************************************************
50 * @ xp      : extended pointer to remote cluster
51 * @ data    : value to be written
52 ****************************************************************************************/
53void hal_remote_sw( xptr_t   xp,
54                    uint32_t data );
55
56/*****************************************************************************************
57 * This function writes an aligned 64 bits word in a remote cluster.
58 *****************************************************************************************
59 * @ xp      : extended pointer to remote cluster
60 * @ data    : value to be written
61 ****************************************************************************************/
62void hal_remote_swd( xptr_t   xp,
63                     uint64_t data );
64
65/*****************************************************************************************
66 * This function writes a pointer (32 or 64 bits) in a remote cluster.
67 *****************************************************************************************
68 * @ xp      : extended pointer to remote cluster
69 * @ pt      : value to be written
70 ****************************************************************************************/
71void hal_remote_spt( xptr_t   xp,
72                     void   * pt );
73
74/*****************************************************************************************
75 * This function reads a single byte in a remote cluster.
76 *****************************************************************************************
77 * @ xp      : extended pointer to remote data
[17]78 * @ return read value
[1]79 ****************************************************************************************/
[72]80uint8_t hal_remote_lb( xptr_t  xp );
[1]81
82/*****************************************************************************************
83 * This function reads an aligned 32 bits word in a remote cluster.
84 *****************************************************************************************
85 * @ xp      : extended pointer to remote data
86 * @ return read value
87 ****************************************************************************************/
88uint32_t hal_remote_lw( xptr_t  xp );
89
90/*****************************************************************************************
91 * This function reads an aligned 64 bits word in a remote cluster.
92 *****************************************************************************************
93 * @ xp      : extended pointer to remote data
94 * @ return read value
95 ****************************************************************************************/
96uint64_t hal_remote_lwd( xptr_t  xp );
97
98/*****************************************************************************************
99 * This function reads a pointer (can be 32 or 64 bits) in a remote cluster.
100 *****************************************************************************************
101 * @ xp      : extended pointer to remote data
102 * @ return read value
103 ****************************************************************************************/
104void * hal_remote_lpt( xptr_t  xp );
105
106/*****************************************************************************************
[8]107 * This non blocking function makes an atomic Compare-And-Swap in a remote cluster.
[1]108 *****************************************************************************************
109 * @ xp      : extended pointer to remote data
110 * @ old     : expected value
111 * @ new     : new value to be written
[17]112 * @ return true if success / return false if failure
[1]113 ****************************************************************************************/
114bool_t hal_remote_atomic_cas( xptr_t   xp,
115                              uint32_t old,
116                              uint32_t new );
117
118/*****************************************************************************************
119 * This blocking function adds atomically an increment to the current value of
120 * a 32 bits integer in a remote cluster. Returns only after success.
121 *****************************************************************************************
122 * @ xp      : extended pointer to remote data
123 * @ incr    : increment value.
124 * @ return old value (before increment) of the remote integer
125 ****************************************************************************************/
[17]126uint32_t hal_remote_atomic_add( xptr_t    xp,
[1]127                                uint32_t  incr );
128
129/*****************************************************************************************
[95]130 * This blocking function makes an atomic "and" between a local mask value and
[1]131 * a 32 bits integer in a remote cluster. Returns only after success.
132 *****************************************************************************************
133 * @ xp      : extended pointer to remote data
134 * @ mask    : local mask value.
135 * @ return old value (before increment) of the remote integer
136 ****************************************************************************************/
[17]137uint32_t hal_remote_atomic_and( xptr_t    xp,
[1]138                                uint32_t  mask );
139
140/*****************************************************************************************
[95]141 * This blocking function makes an atomic "or" between a local mask value and
[1]142 * a 32 bits integer in a remote cluster. Returns only after success.
143 *****************************************************************************************
144 * @ xp      : extended pointer to remote data
145 * @ mask    : local mask value.
146 * @ return old value (before increment) of the remote integer
147 ****************************************************************************************/
[17]148uint32_t hal_remote_atomic_or( xptr_t    xp,
[1]149                               uint32_t  mask );
150
151/*****************************************************************************************
152 * This non blocking function tries to make an atomic increment to the current
153 * value of a 32 bits integer in a remote cluster.
154 *****************************************************************************************
155 * @ xp      : extended pointer to remote data
156 * @ incr    : increment value.
157 * @ old     : local buffer address for the read value (before increment)
[17]158 * @ return 0 if atomic / return non-zero if failure
[1]159 ****************************************************************************************/
160error_t hal_remote_atomic_try_add( xptr_t     xp,
161                                   uint32_t   incr,
162                                   uint32_t * old );
163
164/*****************************************************************************************
165 * This function makes a memcpy from a source remote buffer in kernel space to another
166 * destination remote buffer in kernel space.
167 *****************************************************************************************
168 * @ dst     : extended pointer to destination buffer
169 * @ src     : extended pointer to source buffer
170 * @ size    : number of bytes to move
171 ****************************************************************************************/
172void hal_remote_memcpy( xptr_t   dst,
[17]173                        xptr_t   src,
[1]174                        uint32_t size );
175
[121]176/*****************************************************************************************
177 * This function makes a copy from a source character string to another destination
178 * character string, including the NUL terminating character.
179 *****************************************************************************************
180 * @ dst     : extended pointer to destination char array.
181 * @ src     : extended pointer to source char array.
182 ****************************************************************************************/
183void hal_remote_strcpy( xptr_t dst,
184                        xptr_t src );
185
[1]186#endif  /* _HAL_REMOTE_H_ */
Note: See TracBrowser for help on using the repository browser.