[1] | 1 | /* |
---|
| 2 | * hal_remote.h - Generic Remote Access API definition. |
---|
[17] | 3 | * |
---|
[657] | 4 | * Authors Alain Greiner (2016,2017,2018,2019,2020) |
---|
[1] | 5 | * |
---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
---|
[17] | 7 | * |
---|
[1] | 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 _HAL_REMOTE_H_ |
---|
| 25 | #define _HAL_REMOTE_H_ |
---|
| 26 | |
---|
[457] | 27 | #include <hal_kernel_types.h> |
---|
[1] | 28 | |
---|
| 29 | ////////////////////////////////////////////////////////////////////////////////////////// |
---|
[17] | 30 | // Generic Remote Access API (implementation in hal_remote.c) |
---|
[1] | 31 | // |
---|
| 32 | // Kernel accesses to local memory bank and peripherals can use normal C pointers. |
---|
| 33 | // kernel accesses to remote memory banks or peripherals must use the following |
---|
| 34 | // dedicated functions, because implementation depends on architectures. |
---|
| 35 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
| 36 | |
---|
| 37 | /***************************************************************************************** |
---|
| 38 | * This function writes a single byte in a remote cluster. |
---|
| 39 | ***************************************************************************************** |
---|
| 40 | * @ xp : extended pointer to remote cluster |
---|
| 41 | * @ data : value to be written |
---|
| 42 | ****************************************************************************************/ |
---|
| 43 | void hal_remote_sb( xptr_t xp, |
---|
[69] | 44 | uint8_t data ); |
---|
[1] | 45 | |
---|
| 46 | /***************************************************************************************** |
---|
| 47 | * This function writes an aligned 32 bits word in a remote cluster. |
---|
| 48 | ***************************************************************************************** |
---|
| 49 | * @ xp : extended pointer to remote cluster |
---|
| 50 | * @ data : value to be written |
---|
| 51 | ****************************************************************************************/ |
---|
[570] | 52 | void hal_remote_s32( xptr_t xp, |
---|
[1] | 53 | uint32_t data ); |
---|
| 54 | |
---|
| 55 | /***************************************************************************************** |
---|
| 56 | * This function writes an aligned 64 bits word in a remote cluster. |
---|
| 57 | ***************************************************************************************** |
---|
| 58 | * @ xp : extended pointer to remote cluster |
---|
| 59 | * @ data : value to be written |
---|
| 60 | ****************************************************************************************/ |
---|
[570] | 61 | void hal_remote_s64( xptr_t xp, |
---|
[1] | 62 | uint64_t data ); |
---|
| 63 | |
---|
| 64 | /***************************************************************************************** |
---|
| 65 | * This function writes a pointer (32 or 64 bits) in a remote cluster. |
---|
| 66 | ***************************************************************************************** |
---|
| 67 | * @ xp : extended pointer to remote cluster |
---|
| 68 | * @ pt : value to be written |
---|
| 69 | ****************************************************************************************/ |
---|
| 70 | void hal_remote_spt( xptr_t xp, |
---|
| 71 | void * pt ); |
---|
| 72 | |
---|
| 73 | /***************************************************************************************** |
---|
| 74 | * This function reads a single byte in a remote cluster. |
---|
| 75 | ***************************************************************************************** |
---|
| 76 | * @ xp : extended pointer to remote data |
---|
[17] | 77 | * @ return read value |
---|
[1] | 78 | ****************************************************************************************/ |
---|
[72] | 79 | uint8_t hal_remote_lb( xptr_t xp ); |
---|
[1] | 80 | |
---|
| 81 | /***************************************************************************************** |
---|
| 82 | * This function reads an aligned 32 bits word in a remote cluster. |
---|
| 83 | ***************************************************************************************** |
---|
| 84 | * @ xp : extended pointer to remote data |
---|
| 85 | * @ return read value |
---|
| 86 | ****************************************************************************************/ |
---|
[570] | 87 | uint32_t hal_remote_l32( xptr_t xp ); |
---|
[1] | 88 | |
---|
| 89 | /***************************************************************************************** |
---|
| 90 | * This function reads an aligned 64 bits word in a remote cluster. |
---|
| 91 | ***************************************************************************************** |
---|
| 92 | * @ xp : extended pointer to remote data |
---|
| 93 | * @ return read value |
---|
| 94 | ****************************************************************************************/ |
---|
[570] | 95 | uint64_t hal_remote_l64( xptr_t xp ); |
---|
[1] | 96 | |
---|
| 97 | /***************************************************************************************** |
---|
| 98 | * This function reads a pointer (can be 32 or 64 bits) in a remote cluster. |
---|
| 99 | ***************************************************************************************** |
---|
| 100 | * @ xp : extended pointer to remote data |
---|
| 101 | * @ return read value |
---|
| 102 | ****************************************************************************************/ |
---|
| 103 | void * hal_remote_lpt( xptr_t xp ); |
---|
| 104 | |
---|
| 105 | /***************************************************************************************** |
---|
[8] | 106 | * This non blocking function makes an atomic Compare-And-Swap in a remote cluster. |
---|
[1] | 107 | ***************************************************************************************** |
---|
| 108 | * @ xp : extended pointer to remote data |
---|
| 109 | * @ old : expected value |
---|
| 110 | * @ new : new value to be written |
---|
[17] | 111 | * @ return true if success / return false if failure |
---|
[1] | 112 | ****************************************************************************************/ |
---|
| 113 | bool_t hal_remote_atomic_cas( xptr_t xp, |
---|
| 114 | uint32_t old, |
---|
| 115 | uint32_t new ); |
---|
| 116 | |
---|
| 117 | /***************************************************************************************** |
---|
| 118 | * This blocking function adds atomically an increment to the current value of |
---|
| 119 | * a 32 bits integer in a remote cluster. Returns only after success. |
---|
| 120 | ***************************************************************************************** |
---|
| 121 | * @ xp : extended pointer to remote data |
---|
| 122 | * @ incr : increment value. |
---|
| 123 | * @ return old value (before increment) of the remote integer |
---|
| 124 | ****************************************************************************************/ |
---|
[17] | 125 | uint32_t hal_remote_atomic_add( xptr_t xp, |
---|
[1] | 126 | uint32_t incr ); |
---|
| 127 | |
---|
| 128 | /***************************************************************************************** |
---|
[95] | 129 | * This blocking function makes an atomic "and" between a local mask value and |
---|
[1] | 130 | * a 32 bits integer in a remote cluster. Returns only after success. |
---|
| 131 | ***************************************************************************************** |
---|
| 132 | * @ xp : extended pointer to remote data |
---|
| 133 | * @ mask : local mask value. |
---|
[407] | 134 | * @ return old value (before mask) of the remote integer |
---|
[1] | 135 | ****************************************************************************************/ |
---|
[17] | 136 | uint32_t hal_remote_atomic_and( xptr_t xp, |
---|
[1] | 137 | uint32_t mask ); |
---|
| 138 | |
---|
| 139 | /***************************************************************************************** |
---|
[95] | 140 | * This blocking function makes an atomic "or" between a local mask value and |
---|
[1] | 141 | * a 32 bits integer in a remote cluster. Returns only after success. |
---|
| 142 | ***************************************************************************************** |
---|
| 143 | * @ xp : extended pointer to remote data |
---|
| 144 | * @ mask : local mask value. |
---|
[407] | 145 | * @ return old value (before mask) of the remote integer |
---|
[1] | 146 | ****************************************************************************************/ |
---|
[17] | 147 | uint32_t hal_remote_atomic_or( xptr_t xp, |
---|
[1] | 148 | uint32_t mask ); |
---|
| 149 | |
---|
| 150 | /***************************************************************************************** |
---|
| 151 | * This non blocking function tries to make an atomic increment to the current |
---|
| 152 | * value of a 32 bits integer in a remote cluster. |
---|
| 153 | ***************************************************************************************** |
---|
| 154 | * @ xp : extended pointer to remote data |
---|
| 155 | * @ incr : increment value. |
---|
| 156 | * @ old : local buffer address for the read value (before increment) |
---|
[17] | 157 | * @ return 0 if atomic / return non-zero if failure |
---|
[1] | 158 | ****************************************************************************************/ |
---|
| 159 | error_t hal_remote_atomic_try_add( xptr_t xp, |
---|
| 160 | uint32_t incr, |
---|
| 161 | uint32_t * old ); |
---|
| 162 | |
---|
| 163 | /***************************************************************************************** |
---|
| 164 | * This function makes a memcpy from a source remote buffer in kernel space to another |
---|
| 165 | * destination remote buffer in kernel space. |
---|
| 166 | ***************************************************************************************** |
---|
[619] | 167 | * @ dst_xp : extended pointer to destination buffer |
---|
| 168 | * @ src_xp : extended pointer to source buffer |
---|
[1] | 169 | * @ size : number of bytes to move |
---|
| 170 | ****************************************************************************************/ |
---|
[619] | 171 | void hal_remote_memcpy( xptr_t dst_xp, |
---|
| 172 | xptr_t src_xp, |
---|
[1] | 173 | uint32_t size ); |
---|
| 174 | |
---|
[121] | 175 | /***************************************************************************************** |
---|
| 176 | * This function makes a copy from a source character string to another destination |
---|
| 177 | * character string, including the NUL terminating character. |
---|
| 178 | ***************************************************************************************** |
---|
| 179 | * @ dst : extended pointer to destination char array. |
---|
| 180 | * @ src : extended pointer to source char array. |
---|
| 181 | ****************************************************************************************/ |
---|
| 182 | void hal_remote_strcpy( xptr_t dst, |
---|
| 183 | xptr_t src ); |
---|
| 184 | |
---|
[313] | 185 | /***************************************************************************************** |
---|
| 186 | * This function makes a memset to a remote buffer in kernel space. |
---|
| 187 | ***************************************************************************************** |
---|
| 188 | * @ buf_xp : extended pointer to destination buffer. |
---|
| 189 | * @ byte : Rvalue to be set in all buffer slots. |
---|
| 190 | * @ size : number of bytes to move. |
---|
| 191 | ****************************************************************************************/ |
---|
| 192 | void hal_remote_memset( xptr_t buf_xp, |
---|
| 193 | uint8_t byte, |
---|
| 194 | uint32_t size ); |
---|
| 195 | |
---|
[1] | 196 | #endif /* _HAL_REMOTE_H_ */ |
---|