| [1] | 1 | /* | 
|---|
 | 2 |  * rpc.h - RPC (Remote Procedure Call) operations definition. | 
|---|
 | 3 |  * | 
|---|
 | 4 |  * Authors Mohamed Karaoui (2015) | 
|---|
 | 5 |  *         Alain Greiner (2016) | 
|---|
 | 6 |  * | 
|---|
 | 7 |  * Copyright (c) UPMC Sorbonne Universites | 
|---|
 | 8 |  *  | 
|---|
 | 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 _RPC_H_ | 
|---|
 | 26 | #define _RPC_H_ | 
|---|
 | 27 |  | 
|---|
 | 28 | #include <almos_config.h> | 
|---|
 | 29 | #include <hal_types.h> | 
|---|
 | 30 | #include <hal_atomic.h> | 
|---|
 | 31 | #include <bits.h> | 
|---|
 | 32 | #include <spinlock.h> | 
|---|
 | 33 | #include <remote_fifo.h> | 
|---|
 | 34 |  | 
|---|
 | 35 | /**** Forward declarations ****/ | 
|---|
 | 36 |  | 
|---|
 | 37 | struct process_s; | 
|---|
 | 38 | struct vseg_s; | 
|---|
 | 39 | struct exec_info_s; | 
|---|
 | 40 | struct pthread_attr_s; | 
|---|
 | 41 | struct remote_sem_s; | 
|---|
 | 42 | struct fragment_s; | 
|---|
 | 43 | struct vfs_inode_s; | 
|---|
 | 44 | struct vfs_dentry_s; | 
|---|
 | 45 | struct thread_s; | 
|---|
 | 46 | struct mapper_s; | 
|---|
 | 47 |  | 
|---|
 | 48 | /**********************************************************************************/ | 
|---|
 | 49 | /**************  structures for Remote Procedure Calls ****************************/ | 
|---|
 | 50 | /**********************************************************************************/ | 
|---|
 | 51 |  | 
|---|
 | 52 | /*********************************************************************************** | 
|---|
 | 53 |  * This enum defines all RPC indexes. | 
|---|
 | 54 |  * It must be consistent with the rpc_server[] array defined in in the rpc.c file. | 
|---|
 | 55 |  **********************************************************************************/ | 
|---|
 | 56 |  | 
|---|
 | 57 | typedef enum | 
|---|
 | 58 | { | 
|---|
 | 59 |     RPC_PMEM_GET_PAGES         = 0, | 
|---|
 | 60 |     RPC_PROCESS_PID_ALLOC      = 1, | 
|---|
 | 61 |     RPC_PROCESS_EXEC           = 2, | 
|---|
 | 62 |     RPC_PROCESS_KILL           = 3, | 
|---|
 | 63 |     RPC_THREAD_USER_CREATE     = 4, | 
|---|
 | 64 |     RPC_THREAD_KERNEL_CREATE   = 5, | 
|---|
 | 65 |         RPC_ICU_WTI_ALLOC          = 6, | 
|---|
 | 66 |     RPC_DEVICE_ALLOC           = 7, | 
|---|
 | 67 |  | 
|---|
 | 68 |     RPC_VFS_INODE_CREATE       = 10, | 
|---|
 | 69 |     RPC_VFS_INODE_DESTROY      = 11, | 
|---|
 | 70 |     RPC_VFS_DENTRY_CREATE      = 12, | 
|---|
 | 71 |     RPC_VFS_DENTRY_DESTROY     = 13, | 
|---|
 | 72 |  | 
|---|
 | 73 |     RPC_VMM_GET_REF_VSEG       = 20, | 
|---|
 | 74 |     RPC_VMM_GET_PTE            = 21, | 
|---|
 | 75 |     RPC_SEMAPHORE_ALLOC        = 22, | 
|---|
 | 76 |     RPC_SEMAPHORE_FREE         = 23, | 
|---|
 | 77 |     RPC_MAPPER_MOVE            = 24, | 
|---|
 | 78 |  | 
|---|
 | 79 |     RPC_FATFS_GET_CLUSTER      = 30, | 
|---|
 | 80 |  | 
|---|
 | 81 |     RPC_MAX_INDEX              = 31, | 
|---|
 | 82 | } | 
|---|
 | 83 | rpc_index_t; | 
|---|
 | 84 |  | 
|---|
 | 85 | /*********************************************************************************** | 
|---|
 | 86 |  * This defines the prototype of the rpc_server functions, | 
|---|
 | 87 |  * defined by the rpc_server[] array in the rpc.c file.  | 
|---|
 | 88 |  **********************************************************************************/ | 
|---|
 | 89 |  | 
|---|
 | 90 | typedef  void (rpc_server_t) ( xptr_t xp ); | 
|---|
 | 91 |  | 
|---|
 | 92 | /*********************************************************************************** | 
|---|
 | 93 |  *  This structure defines the RPC descriptor | 
|---|
 | 94 |  **********************************************************************************/ | 
|---|
 | 95 |  | 
|---|
 | 96 | typedef struct rpc_desc_s | 
|---|
 | 97 | { | 
|---|
 | 98 |         rpc_index_t       index;       // index of requested RPC service | 
|---|
 | 99 |         volatile uint32_t response;    // response valid when 0 | 
|---|
 | 100 |     uint64_t          args[8];     // input/output arguments buffer | 
|---|
 | 101 | }  | 
|---|
 | 102 | rpc_desc_t; | 
|---|
 | 103 |  | 
|---|
 | 104 | /*********************************************************************************** | 
|---|
 | 105 |  * This structure defines the RPC fifo, containing a remote_fifo, the owner RPC | 
|---|
 | 106 |  * thread TRDID (used as a light lock), and the intrumentation counter. | 
|---|
 | 107 |  * | 
|---|
 | 108 |  * Implementation note: the TRDID is a good owner identifier, because all | 
|---|
 | 109 |  * RPC threads in a given cluster belong to the same process_zero kernel process, | 
|---|
 | 110 |  * and RPC threads cannot have local index LTID = 0. | 
|---|
 | 111 |  **********************************************************************************/ | 
|---|
 | 112 |  | 
|---|
 | 113 | typedef struct rpc_fifo_s | 
|---|
 | 114 | { | 
|---|
 | 115 |         trdid_t           owner;       // owner thread / 0 if no owner | 
|---|
 | 116 |         uint64_t          count;       // total number of received RPCs (instrumentation)  | 
|---|
 | 117 |         remote_fifo_t     fifo;        // embedded remote fifo | 
|---|
 | 118 | }  | 
|---|
 | 119 | rpc_fifo_t; | 
|---|
 | 120 |  | 
|---|
 | 121 |  | 
|---|
 | 122 | /**********************************************************************************/ | 
|---|
 | 123 | /******* Generic functions supporting RPCs : client side **************************/ | 
|---|
 | 124 | /**********************************************************************************/ | 
|---|
 | 125 |  | 
|---|
 | 126 | /*********************************************************************************** | 
|---|
 | 127 |  * This blocking function executes on the client core.  | 
|---|
 | 128 |  * It puts one RPC extended pointer in the remote fifo.  | 
|---|
 | 129 |  * It sends an IPI if fifo is empty, and waits until RPC response available. | 
|---|
 | 130 |  * The RPC descriptor must be allocated in the caller's stack | 
|---|
 | 131 |  * and initialised by the caller.  Exit with a Panic message if remote fifo  | 
|---|
 | 132 |  * is still full after (CONFIG_RPC_PUT_MAX_ITERATIONS) retries. | 
|---|
 | 133 |  *********************************************************************************** | 
|---|
 | 134 |  * @ cxy   : server cluster identifier | 
|---|
 | 135 |  * @ desc  : local pointer on RPC descriptor in client cluster | 
|---|
 | 136 |  **********************************************************************************/ | 
|---|
 | 137 | void rpc_send_sync( cxy_t        cxy,     | 
|---|
 | 138 |                     rpc_desc_t * desc ); | 
|---|
 | 139 |  | 
|---|
 | 140 |  | 
|---|
 | 141 |  | 
|---|
 | 142 | /**********************************************************************************/ | 
|---|
 | 143 | /******* Generic functions supporting RPCs : server side **************************/ | 
|---|
 | 144 | /**********************************************************************************/ | 
|---|
 | 145 |  | 
|---|
 | 146 | /*********************************************************************************** | 
|---|
 | 147 |  * This function initialises the local RPC fifo and the lock protecting readers. | 
|---|
 | 148 |  * The number of slots is defined by the CONFIG_REMOTE_FIFO_SLOTS parameter. | 
|---|
 | 149 |  * Each slot contains an extended pointer on the RPC descriptor. | 
|---|
 | 150 |  *********************************************************************************** | 
|---|
 | 151 |  * @ rf     : pointer on the local RPC fifo. | 
|---|
 | 152 |  **********************************************************************************/  | 
|---|
 | 153 | void rpc_fifo_init( rpc_fifo_t * rf ); | 
|---|
 | 154 |  | 
|---|
 | 155 | /*********************************************************************************** | 
|---|
 | 156 |  * This function is the entry point for RPC handling on the server side. | 
|---|
 | 157 |  * It can be executed by any thread running (in kernel mode) on any core. | 
|---|
 | 158 |  * It first checks the core private RPC fifo, an then the cluster shared RPC fifo. | 
|---|
 | 159 |  * It calls the rpc_activate_thread() function to activate a dedicated RPC thread. | 
|---|
 | 160 |  *********************************************************************************** | 
|---|
 | 161 |  * @ returns true if at least one RPC found / false otherwise. | 
|---|
 | 162 |  **********************************************************************************/ | 
|---|
 | 163 | bool_t rpc_check(); | 
|---|
 | 164 |  | 
|---|
 | 165 | /*********************************************************************************** | 
|---|
 | 166 |  * This function contains the loop to execute all pending RPCs on the server side. | 
|---|
 | 167 |  * It should be called with irq disabled and after light lock acquisition. | 
|---|
 | 168 |  *********************************************************************************** | 
|---|
 | 169 |  * @ rpc_fifo  : pointer on the local RPC fifo | 
|---|
 | 170 |  * @ returns 0 if success | 
|---|
 | 171 |  **********************************************************************************/ | 
|---|
 | 172 | error_t rpc_execute_all( rpc_fifo_t * rpc_fifo ); | 
|---|
 | 173 |  | 
|---|
 | 174 | /********************************************************************************** | 
|---|
 | 175 |  * This function is called by any thread running on any core in any cluster, | 
|---|
 | 176 |  * that detected a non-empty RPC_FIFO and got the RPC_FIFO ownership. | 
|---|
 | 177 |  * It activates one RPC thread, and immediately switches to the RPC thread. | 
|---|
 | 178 |  * It gets the first free RPC thread from the core free-list, or creates a new one | 
|---|
 | 179 |  * when the core free-list is empty.  | 
|---|
 | 180 |  *********************************************************************************** | 
|---|
 | 181 |  * @ rpc_fifo : pointer on the non-empty RPC fifo. | 
|---|
 | 182 |  * @ return 0 if success / return ENOMEM if error. | 
|---|
 | 183 |  **********************************************************************************/ | 
|---|
 | 184 | error_t rpc_activate_thread( rpc_fifo_t * rpc_fifo ); | 
|---|
 | 185 |  | 
|---|
 | 186 | /*********************************************************************************** | 
|---|
 | 187 |  * This function contains the infinite loop executed by each RPC thread. | 
|---|
 | 188 |  **********************************************************************************/ | 
|---|
 | 189 | void rpc_thread_func(); | 
|---|
 | 190 |  | 
|---|
 | 191 | /*********************************************************************************** | 
|---|
 | 192 |  * This function is executed in case of illegal RPC index. | 
|---|
 | 193 |  **********************************************************************************/ | 
|---|
 | 194 | void __attribute__((noinline)) rpc_undefined(); | 
|---|
 | 195 |  | 
|---|
 | 196 | /**********************************************************************************/ | 
|---|
 | 197 | /******* Marshalling functions attached to the various RPCs ***********************/ | 
|---|
 | 198 | /**********************************************************************************/ | 
|---|
 | 199 |  | 
|---|
 | 200 | /*********************************************************************************** | 
|---|
 | 201 |  * The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster, | 
|---|
 | 202 |  * and returns the PPN of the first allocated page. | 
|---|
 | 203 |  *********************************************************************************** | 
|---|
 | 204 |  * @ cxy     : server cluster identifier | 
|---|
 | 205 |  * @ order   : [in]  ln2( number of requested pages ) | 
|---|
 | 206 |  * @ error   : [out] error status (0 if success) | 
|---|
 | 207 |  * @ ppn     : [out] first physical page number | 
|---|
 | 208 |  **********************************************************************************/ | 
|---|
 | 209 | void rpc_pmem_get_pages_client( cxy_t      cxy, | 
|---|
 | 210 |                                 uint32_t   order, | 
|---|
 | 211 |                                 error_t  * error, | 
|---|
 | 212 |                                 uint32_t * ppn ); | 
|---|
 | 213 |  | 
|---|
 | 214 | void rpc_pmem_get_pages_server( xptr_t xp ); | 
|---|
 | 215 |  | 
|---|
 | 216 | /*********************************************************************************** | 
|---|
 | 217 |  * The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers | 
|---|
 | 218 |  * the new process in the remote cluster, and returns the PID, and an error code. | 
|---|
 | 219 |  *********************************************************************************** | 
|---|
 | 220 |  * @ cxy     : server cluster identifier. | 
|---|
 | 221 |  * @ process : [in]  local pointer on process descriptor in client cluster. | 
|---|
 | 222 |  * @ error   : [out] error status (0 if success). | 
|---|
 | 223 |  * @ pid     : [out] new process identifier. | 
|---|
 | 224 |  **********************************************************************************/ | 
|---|
 | 225 | void rpc_process_pid_alloc_client( cxy_t              cxy, | 
|---|
 | 226 |                                    struct process_s * process, | 
|---|
 | 227 |                                    error_t          * error, | 
|---|
 | 228 |                                    pid_t            * pid ); | 
|---|
 | 229 |  | 
|---|
 | 230 | void rpc_process_pid_alloc_server( xptr_t xp ); | 
|---|
 | 231 |  | 
|---|
 | 232 | /*********************************************************************************** | 
|---|
 | 233 |  * The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster | 
|---|
 | 234 |  * and initializes if from information found in the reference process descriptor. | 
|---|
 | 235 |  * This remote cluster becomes the new reference cluster. | 
|---|
 | 236 |  *********************************************************************************** | 
|---|
 | 237 |  * @ cxy     : server cluster identifier. | 
|---|
 | 238 |  * @ info    : [in]   pointer on local exec_info structure. | 
|---|
 | 239 |  * @ error   : [out]  error status (0 if success). | 
|---|
 | 240 |  **********************************************************************************/ | 
|---|
 | 241 | void rpc_process_exec_client( cxy_t                cxy, | 
|---|
 | 242 |                               struct exec_info_s * info, | 
|---|
 | 243 |                               error_t            * error ); | 
|---|
 | 244 |  | 
|---|
 | 245 | void rpc_process_exec_server( xptr_t xp ); | 
|---|
 | 246 |  | 
|---|
 | 247 | /*********************************************************************************** | 
|---|
 | 248 |  * The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster | 
|---|
 | 249 |  * to other clusters containing a process descriptor copy, to destroy these copies. | 
|---|
 | 250 |  *********************************************************************************** | 
|---|
 | 251 |  * @ process  : local pointer on target process. | 
|---|
 | 252 |  **********************************************************************************/ | 
|---|
 | 253 | void rpc_process_kill_client( struct process_s * process ); | 
|---|
 | 254 |  | 
|---|
 | 255 | void rpc_process_kill_server( xptr_t xp ); | 
|---|
 | 256 |  | 
|---|
 | 257 | /*********************************************************************************** | 
|---|
 | 258 |  * The RPC_THREAD_USER_CREATE creates an user thread in the server cluster, | 
|---|
 | 259 |  * as specified by the pthread_attr_t argument. It returns the local pointer | 
|---|
 | 260 |  * on the thread descriptor in server cluster, and an error code. | 
|---|
 | 261 |  * It is called by the pthread_create system call. | 
|---|
 | 262 |  *********************************************************************************** | 
|---|
 | 263 |  * @ cxy       : server cluster identifier. | 
|---|
 | 264 |  * @ attr      : [in]  pointer on pthread_attr_t in client cluster. | 
|---|
 | 265 |  * @ thread_xp : [out] pointer on buffer for thread extended pointer.  | 
|---|
 | 266 |  * @ error     : [out] error status (0 if success). | 
|---|
 | 267 |  **********************************************************************************/ | 
|---|
 | 268 | void rpc_thread_user_create_client( cxy_t                   cxy, | 
|---|
 | 269 |                                     struct pthread_attr_s * attr, | 
|---|
 | 270 |                                     xptr_t                * thread_xp, | 
|---|
 | 271 |                                     error_t               * error ); | 
|---|
 | 272 |  | 
|---|
 | 273 | void rpc_thread_user_create_server( xptr_t xp ); | 
|---|
 | 274 |  | 
|---|
 | 275 | /*********************************************************************************** | 
|---|
 | 276 |  * The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster, | 
|---|
 | 277 |  * as specified by the type, func and args arguments. It returns the local pointer | 
|---|
 | 278 |  * on the thread descriptor in server cluster and an error code. | 
|---|
 | 279 |  * It is used by the dev_init() function to cretae the device server thread. | 
|---|
 | 280 |  *********************************************************************************** | 
|---|
 | 281 |  * @ cxy       : server cluster identifier. | 
|---|
 | 282 |  * @ type      : [in]  type of kernel thread. | 
|---|
 | 283 |  * @ func      : [in]  local pointer on thread function. | 
|---|
 | 284 |  * @ args      : [in]  local pointer on function arguments. | 
|---|
 | 285 |  * @ thread_xp : [out] pointer on buffer for thread extended pointer.  | 
|---|
 | 286 |  * @ error     : [out] error status (0 if success). | 
|---|
 | 287 |  **********************************************************************************/ | 
|---|
 | 288 | void rpc_thread_kernel_create_client( cxy_t     cxy, | 
|---|
 | 289 |                                       uint32_t  type, | 
|---|
 | 290 |                                       void    * func, | 
|---|
 | 291 |                                       void    * args, | 
|---|
 | 292 |                                       xptr_t  * thread_xp, | 
|---|
 | 293 |                                       error_t * error ); | 
|---|
 | 294 |  | 
|---|
 | 295 | void rpc_thread_kernel_create_server( xptr_t xp ); | 
|---|
 | 296 |  | 
|---|
 | 297 | /***********************************************************************************  | 
|---|
 | 298 |  * The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a | 
|---|
 | 299 |  * remote cluster. The parent dentry must have been previously created. | 
|---|
 | 300 |  * It returns an extended pointer on the created inode. | 
|---|
 | 301 |  *********************************************************************************** | 
|---|
 | 302 |  * @ cxy       :  server cluster identifier | 
|---|
 | 303 |  * @ dentry_xp : [in]  extended pointer on parent dentry. | 
|---|
 | 304 |  * @ type      : [in]  file system type. | 
|---|
 | 305 |  * @ attr      : [in]  TODO ??? | 
|---|
 | 306 |  * @ mode      : [in]  access mode. | 
|---|
 | 307 |  * @ uid       : [in]  user ID | 
|---|
 | 308 |  * @ gid       : [in]  group ID | 
|---|
 | 309 |  * @ inode_xp  : [out] buffer for extended pointer on created inode. | 
|---|
 | 310 |  * @ error     : [out] error status (0 if success). | 
|---|
 | 311 |  **********************************************************************************/ | 
|---|
 | 312 | void rpc_vfs_inode_create_client( cxy_t      cxy, | 
|---|
 | 313 |                                   xptr_t     dentry_xp, | 
|---|
 | 314 |                                   uint32_t   type, | 
|---|
 | 315 |                                   uint32_t   attr,     | 
|---|
 | 316 |                                   uint32_t   mode,   | 
|---|
 | 317 |                                   uint32_t   uid, | 
|---|
 | 318 |                                   uint32_t   gid, | 
|---|
 | 319 |                                   xptr_t   * inode_xp, | 
|---|
 | 320 |                                   error_t  * error ); | 
|---|
 | 321 |  | 
|---|
 | 322 | void rpc_vfs_inode_create_server( xptr_t xp ); | 
|---|
 | 323 |  | 
|---|
 | 324 | /***********************************************************************************  | 
|---|
 | 325 |  * The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor | 
|---|
 | 326 |  * and for the associated mapper in a remote cluster.  | 
|---|
 | 327 |  *********************************************************************************** | 
|---|
 | 328 |  * @ cxy       :  server cluster identifier | 
|---|
 | 329 |  * @ inode     : [in]  local pointer on inode. | 
|---|
 | 330 |  **********************************************************************************/ | 
|---|
 | 331 | void rpc_vfs_inode_destroy_client( cxy_t                 cxy, | 
|---|
 | 332 |                                    struct vfs_inode_s * inode ); | 
|---|
 | 333 |  | 
|---|
 | 334 | void rpc_vfs_inode_destroy_server( xptr_t xp ); | 
|---|
 | 335 |  | 
|---|
 | 336 | /***********************************************************************************  | 
|---|
 | 337 |  * The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster.  | 
|---|
 | 338 |  * It returns an extended pointer on the created dentry. | 
|---|
 | 339 |  *********************************************************************************** | 
|---|
 | 340 |  * @ cxy        :  server cluster identifier | 
|---|
 | 341 |  * @ type       : [in]  file system type. | 
|---|
 | 342 |  * @ name       : [in]  directory entry name. | 
|---|
 | 343 |  * @ parent     : [in]  local pointer on parent inode. | 
|---|
 | 344 |  * @ dentry_xp  : [out] buffer for extended pointer on created dentry. | 
|---|
 | 345 |  * @ error      : [out] error status (0 if success). | 
|---|
 | 346 |  **********************************************************************************/ | 
|---|
 | 347 | void rpc_vfs_dentry_create_client( cxy_t                  cxy, | 
|---|
 | 348 |                                    uint32_t               type, | 
|---|
 | 349 |                                    char                 * name,     | 
|---|
 | 350 |                                    struct vfs_inode_s   * parent, | 
|---|
 | 351 |                                    xptr_t               * dentry_xp, | 
|---|
 | 352 |                                    error_t              * error ); | 
|---|
 | 353 |  | 
|---|
 | 354 | void rpc_vfs_dentry_create_server( xptr_t xp ); | 
|---|
 | 355 |  | 
|---|
 | 356 | /***********************************************************************************  | 
|---|
 | 357 |  * The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor | 
|---|
 | 358 |  * in a remote cluster.  | 
|---|
 | 359 |  *********************************************************************************** | 
|---|
 | 360 |  * @ cxy       :  server cluster identifier | 
|---|
 | 361 |  * @ dentry     : [in]  local pointer on dentry. | 
|---|
 | 362 |  **********************************************************************************/ | 
|---|
 | 363 | void rpc_vfs_dentry_destroy_client( cxy_t                 cxy, | 
|---|
 | 364 |                                     struct vfs_dentry_s * dentry ); | 
|---|
 | 365 |  | 
|---|
 | 366 | void rpc_vfs_dentry_destroy_server( xptr_t xp ); | 
|---|
 | 367 |  | 
|---|
 | 368 |  | 
|---|
 | 369 |  | 
|---|
 | 370 |  | 
|---|
 | 371 | /*********************************************************************************** | 
|---|
 | 372 |  * The RPC_VMM_GET_REF_VSEG returns an extended pointer  | 
|---|
 | 373 |  * on the vseg containing a given virtual address in a given process. | 
|---|
 | 374 |  * The server cluster is supposed to be the reference cluster. | 
|---|
 | 375 |  * It returns NULL if no vseg has been founded. | 
|---|
 | 376 |  *********************************************************************************** | 
|---|
 | 377 |  * @ cxy     : server cluster identifier. | 
|---|
 | 378 |  * @ process : [in]   pointer on process descriptor in server cluster.  | 
|---|
 | 379 |  * @ vaddr   : [in]   virtual address to be searched. | 
|---|
 | 380 |  * @ vseg    : [out]  address of buffer for vseg pointer in client cluster. | 
|---|
 | 381 |  **********************************************************************************/ | 
|---|
 | 382 | void rpc_vmm_get_ref_vseg_client( cxy_t              cxy, | 
|---|
 | 383 |                                   struct process_s * process, | 
|---|
 | 384 |                                   intptr_t           vaddr, | 
|---|
 | 385 |                                   xptr_t           * vseg_xp ); | 
|---|
 | 386 |  | 
|---|
 | 387 | void rpc_vmm_get_ref_vseg_server( xptr_t xp ); | 
|---|
 | 388 |  | 
|---|
 | 389 | /*********************************************************************************** | 
|---|
 | 390 |  * The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value | 
|---|
 | 391 |  * for a given VPN in a given process. | 
|---|
 | 392 |  * The server cluster is supposed to be the reference cluster, and the vseg | 
|---|
 | 393 |  * containing the VPN must be registered in the reference VMM. | 
|---|
 | 394 |  * It returns an error if physical memory cannot be allocated for the PTE2,  | 
|---|
 | 395 |  * or for the missing page itself. | 
|---|
 | 396 |  *********************************************************************************** | 
|---|
 | 397 |  * @ cxy     : server cluster identifier. | 
|---|
 | 398 |  * @ process : [in]   pointer on process descriptor in server cluster.  | 
|---|
 | 399 |  * @ vaddr   : [in]   virtual address to be searched. | 
|---|
 | 400 |  * @ attr    : [out]  address of buffer for attributes. | 
|---|
 | 401 |  * @ ppn     : [out]  address of buffer for PPN. | 
|---|
 | 402 |  * @ error   : [out]  address of buffer for error code. | 
|---|
 | 403 |  **********************************************************************************/ | 
|---|
 | 404 | void rpc_vmm_get_pte_client( cxy_t              cxy, | 
|---|
 | 405 |                              struct process_s * process, | 
|---|
 | 406 |                              vpn_t              vpn, | 
|---|
 | 407 |                              uint32_t         * attr, | 
|---|
 | 408 |                              ppn_t            * ppn, | 
|---|
 | 409 |                              error_t          * error ); | 
|---|
 | 410 |  | 
|---|
 | 411 | void rpc_vmm_get_pte_server( xptr_t xp ); | 
|---|
 | 412 |  | 
|---|
 | 413 | /*********************************************************************************** | 
|---|
 | 414 |  * The RPC_SEMAPHORE_ALLOC allocates memory for a semaphore in a remote cluster, | 
|---|
 | 415 |  * and returns an extended pointer on the created semaphore. | 
|---|
 | 416 |   It returns NULL if physical memory cannot be allocated.  | 
|---|
 | 417 |  *********************************************************************************** | 
|---|
 | 418 |  * @ cxy     : server cluster identifier. | 
|---|
 | 419 |  * @ sem_xp  : [out] buffer for extended pointer on semaphore.  | 
|---|
 | 420 |  **********************************************************************************/ | 
|---|
 | 421 | void rpc_semaphore_alloc_client( cxy_t    cxy, | 
|---|
 | 422 |                                  xptr_t * sem_xp );   | 
|---|
 | 423 |  | 
|---|
 | 424 | void rpc_semaphore_alloc_server( xptr_t xp ); | 
|---|
 | 425 |  | 
|---|
 | 426 | /*********************************************************************************** | 
|---|
 | 427 |  * The RPC_SEMAPHORE_FREE releases memory allocated for a semaphore  | 
|---|
 | 428 |  * in a remote cluster. | 
|---|
 | 429 |  *********************************************************************************** | 
|---|
 | 430 |  * @ cxy     : server cluster identifier. | 
|---|
 | 431 |  * @ sem     : [in] local pointer on semaphore.  | 
|---|
 | 432 |  **********************************************************************************/ | 
|---|
 | 433 | void rpc_semaphore_free_client( cxy_t                 cxy, | 
|---|
 | 434 |                                 struct remote_sem_s * sem ); | 
|---|
 | 435 |  | 
|---|
 | 436 | void rpc_semaphore_free_server( xptr_t xp ); | 
|---|
 | 437 |  | 
|---|
 | 438 | /*********************************************************************************** | 
|---|
 | 439 |  * The RPC_MAPPER_MOVE can be send by any thread running in a "client" cluster  | 
|---|
 | 440 |  * to the "server" cluster containing the mapper of a given file. The service is  | 
|---|
 | 441 |  * to move data between the mapper and an user buffer. This user buffer is described | 
|---|
 | 442 |  * as a set of fragments. Each fragment is contained in one single physical page. | 
|---|
 | 443 |  * It is defined by four parameters : size / file_offset / ppn / page_offset, | 
|---|
 | 444 |  * defined in the mapper.h file. The client thread is in charge of building  | 
|---|
 | 445 |  * the fragments array covering the user buffer.  | 
|---|
 | 446 |  * As each fragments can be stored in a different cluster, and this fragment can  | 
|---|
 | 447 |  * be stored in two successive pages in the radix tree, each fragment is moved  | 
|---|
 | 448 |  * using one or two different hal_remote_memcpy(). | 
|---|
 | 449 |  *********************************************************************************** | 
|---|
 | 450 |  * @ cxy      : server cluster identifier. | 
|---|
 | 451 |  * @ inode    : [in]  local pointer on inode (in server cluster). | 
|---|
 | 452 |  * @ read     : [in]  mapper to buffer if true / buffer to mapper if false. | 
|---|
 | 453 |  * @ nb_frags : [in]  number of fragments in fragments array. | 
|---|
 | 454 |  * @ frags    : [in]  local pointer on fragments array (in client cluster). | 
|---|
 | 455 |  * @ error    : [out] local pointer on buffer for error code (in client cluster).  | 
|---|
 | 456 |  **********************************************************************************/ | 
|---|
 | 457 | void rpc_mapper_move_client( cxy_t                cxy, | 
|---|
 | 458 |                              struct mapper_s    * mapper, | 
|---|
 | 459 |                              bool_t               read, | 
|---|
 | 460 |                              uint32_t             nb_frags, | 
|---|
 | 461 |                              struct fragment_s  * frags, | 
|---|
 | 462 |                              error_t            * error ); | 
|---|
 | 463 |  | 
|---|
 | 464 | void rpc_mapper_move_server( xptr_t xp ); | 
|---|
 | 465 |  | 
|---|
 | 466 | /*********************************************************************************** | 
|---|
 | 467 |  * The RPC_ICU_WTI_ALLOC can be send by any thread running in a "client" cluster | 
|---|
 | 468 |  * to get a WTI mailbox from the ICU of a "server" cluster. | 
|---|
 | 469 |  * The WTI is allocated from the server ICU, but the WTI is not enabled, | 
|---|
 | 470 |  * and no target core is selected in remote cluster. | 
|---|
 | 471 |  * It returns wti_id == -1 if there is no free WTI in server cluster. | 
|---|
 | 472 |  *********************************************************************************** | 
|---|
 | 473 |  * @ cxy      : server cluster identifier. | 
|---|
 | 474 |  * @ wti_id   : [out] local pointer on WTI index in client cluster (-1 if error). | 
|---|
 | 475 |  **********************************************************************************/ | 
|---|
 | 476 | void rpc_icu_wti_alloc_client( cxy_t      cxy, | 
|---|
 | 477 |                                uint32_t * wti_id );     | 
|---|
 | 478 |  | 
|---|
 | 479 | void rpc_icu_wti_alloc_server( xptr_t xp ); | 
|---|
 | 480 |  | 
|---|
 | 481 | /*********************************************************************************** | 
|---|
 | 482 |  * The RPC_DEVICE_ALLOC can be send by any thread running in a "client" cluster | 
|---|
 | 483 |  * to create a device descriptor in a remote "server" cluster. | 
|---|
 | 484 |  * The WTI is allocated from the server ICU, but the WTI is not enabled, | 
|---|
 | 485 |  * and no target core is selected in remote cluster. | 
|---|
 | 486 |  * It returns wti_id == -1 if there is no free WTI in server cluster. | 
|---|
 | 487 |  *********************************************************************************** | 
|---|
 | 488 |  * @ cxy      : server cluster identifier. | 
|---|
 | 489 |  * @ dev_xp   : [out] buffer for extended pointer on device (in client cluster). | 
|---|
 | 490 |  * @ error    : [out] local pointer on buffer for error code (in client cluster).  | 
|---|
 | 491 |  **********************************************************************************/ | 
|---|
 | 492 | void rpc_device_alloc_client( cxy_t     cxy, | 
|---|
 | 493 |                               xptr_t  * dev_xp,            | 
|---|
 | 494 |                               error_t * error );     | 
|---|
 | 495 |  | 
|---|
 | 496 | void rpc_device_alloc_server( xptr_t xp ); | 
|---|
 | 497 |  | 
|---|
 | 498 | /*********************************************************************************** | 
|---|
 | 499 |  * The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" cluster | 
|---|
 | 500 |  * to scan the FAT mapper, stored in a remote "server" cluster, and get the FATFS  | 
|---|
 | 501 |  * cluster index of a given page of a given file. | 
|---|
 | 502 |  *********************************************************************************** | 
|---|
 | 503 |  * @ cxy      : server cluster identifier. | 
|---|
 | 504 |  * @ mapper   : [in]  local pointer on FAT mapper. | 
|---|
 | 505 |  * @ first    : [in]  FATFS cluster index allocated to first page of file. | 
|---|
 | 506 |  * @ page     : [in]  page index in file. | 
|---|
 | 507 |  * @ cluster  : [out] local pointer on buffer for found FATFS cluster index. | 
|---|
 | 508 |  * @ error    : [out] local pointer on buffer for error code (in client cluster).  | 
|---|
 | 509 |  **********************************************************************************/ | 
|---|
 | 510 | void rpc_fatfs_get_cluster_client( cxy_t             cxy, | 
|---|
 | 511 |                                    struct mapper_s * mapper, | 
|---|
 | 512 |                                    uint32_t          first, | 
|---|
 | 513 |                                    uint32_t          page, | 
|---|
 | 514 |                                    uint32_t        * cluster, | 
|---|
 | 515 |                                    error_t         * error );     | 
|---|
 | 516 |  | 
|---|
 | 517 | void rpc_fatfs_get_cluster_server( xptr_t xp ); | 
|---|
 | 518 |  | 
|---|
 | 519 | #endif | 
|---|