[1] | 1 | /* |
---|
| 2 | * rpc.h - RPC (Remote Procedure Call) operations definition. |
---|
| 3 | * |
---|
[23] | 4 | * Author Alain Greiner (2016,2017) |
---|
[1] | 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 _RPC_H_ |
---|
| 25 | #define _RPC_H_ |
---|
| 26 | |
---|
[14] | 27 | #include <kernel_config.h> |
---|
[1] | 28 | #include <hal_types.h> |
---|
| 29 | #include <hal_atomic.h> |
---|
| 30 | #include <bits.h> |
---|
| 31 | #include <spinlock.h> |
---|
[407] | 32 | #include <vseg.h> |
---|
[1] | 33 | #include <remote_fifo.h> |
---|
[409] | 34 | #include <signal.h> |
---|
[1] | 35 | |
---|
| 36 | /**** Forward declarations ****/ |
---|
| 37 | |
---|
| 38 | struct process_s; |
---|
[313] | 39 | struct page_s; |
---|
[1] | 40 | struct vseg_s; |
---|
| 41 | struct exec_info_s; |
---|
| 42 | struct pthread_attr_s; |
---|
| 43 | struct remote_sem_s; |
---|
| 44 | struct fragment_s; |
---|
| 45 | struct vfs_inode_s; |
---|
| 46 | struct vfs_dentry_s; |
---|
[23] | 47 | struct vfs_file_s; |
---|
[1] | 48 | struct thread_s; |
---|
| 49 | struct mapper_s; |
---|
| 50 | |
---|
| 51 | /**********************************************************************************/ |
---|
| 52 | /************** structures for Remote Procedure Calls ****************************/ |
---|
| 53 | /**********************************************************************************/ |
---|
| 54 | |
---|
| 55 | /*********************************************************************************** |
---|
| 56 | * This enum defines all RPC indexes. |
---|
| 57 | * It must be consistent with the rpc_server[] array defined in in the rpc.c file. |
---|
| 58 | **********************************************************************************/ |
---|
| 59 | |
---|
| 60 | typedef enum |
---|
| 61 | { |
---|
| 62 | RPC_PMEM_GET_PAGES = 0, |
---|
[409] | 63 | RPC_PMEM_RELEASE_PAGES = 1, |
---|
| 64 | RPC_PROCESS_MAKE_EXEC = 2, |
---|
| 65 | RPC_PROCESS_MAKE_FORK = 3, |
---|
| 66 | RPC_PROCESS_MAKE_EXIT = 4, |
---|
| 67 | RPC_PROCESS_MAKE_KILL = 5, |
---|
| 68 | RPC_THREAD_USER_CREATE = 6, |
---|
| 69 | RPC_THREAD_KERNEL_CREATE = 7, |
---|
| 70 | RPC_THREAD_KILL = 8, |
---|
| 71 | RPC_PROCESS_SIGACTION = 9, |
---|
[1] | 72 | |
---|
| 73 | RPC_VFS_INODE_CREATE = 10, |
---|
| 74 | RPC_VFS_INODE_DESTROY = 11, |
---|
| 75 | RPC_VFS_DENTRY_CREATE = 12, |
---|
| 76 | RPC_VFS_DENTRY_DESTROY = 13, |
---|
[23] | 77 | RPC_VFS_FILE_CREATE = 14, |
---|
| 78 | RPC_VFS_FILE_DESTROY = 15, |
---|
[238] | 79 | RPC_VFS_INODE_LOAD = 16, |
---|
| 80 | RPC_VFS_MAPPER_LOAD_ALL = 17, |
---|
| 81 | RPC_FATFS_GET_CLUSTER = 18, |
---|
[1] | 82 | |
---|
[389] | 83 | RPC_VMM_GET_VSEG = 20, |
---|
[1] | 84 | RPC_VMM_GET_PTE = 21, |
---|
[23] | 85 | RPC_KCM_ALLOC = 22, |
---|
| 86 | RPC_KCM_FREE = 23, |
---|
[265] | 87 | RPC_MAPPER_MOVE_BUFFER = 24, |
---|
[313] | 88 | RPC_MAPPER_GET_PAGE = 25, |
---|
[407] | 89 | RPC_VMM_CREATE_VSEG = 26, |
---|
| 90 | RPC_SCHED_DISPLAY = 27, |
---|
[408] | 91 | RPC_VMM_SET_COW = 28, |
---|
[409] | 92 | |
---|
[23] | 93 | RPC_MAX_INDEX = 30, |
---|
[1] | 94 | } |
---|
| 95 | rpc_index_t; |
---|
| 96 | |
---|
| 97 | /*********************************************************************************** |
---|
| 98 | * This defines the prototype of the rpc_server functions, |
---|
| 99 | * defined by the rpc_server[] array in the rpc.c file. |
---|
| 100 | **********************************************************************************/ |
---|
| 101 | |
---|
| 102 | typedef void (rpc_server_t) ( xptr_t xp ); |
---|
| 103 | |
---|
| 104 | /*********************************************************************************** |
---|
| 105 | * This structure defines the RPC descriptor |
---|
| 106 | **********************************************************************************/ |
---|
| 107 | |
---|
| 108 | typedef struct rpc_desc_s |
---|
| 109 | { |
---|
[407] | 110 | rpc_index_t index; /*! index of requested RPC service */ |
---|
| 111 | volatile uint32_t response; /*! response valid when 0 */ |
---|
| 112 | struct thread_s * thread; /*! local pointer on client thread */ |
---|
| 113 | uint32_t lid; /*! index of core running the calling thread */ |
---|
| 114 | uint64_t args[10]; /*! input/output arguments buffer */ |
---|
[1] | 115 | } |
---|
| 116 | rpc_desc_t; |
---|
| 117 | |
---|
| 118 | /**********************************************************************************/ |
---|
| 119 | /******* Generic functions supporting RPCs : client side **************************/ |
---|
| 120 | /**********************************************************************************/ |
---|
| 121 | |
---|
| 122 | /*********************************************************************************** |
---|
[409] | 123 | * This function is executed by the client thread in the client cluster. |
---|
| 124 | * It puts one RPC descriptor defined by the <desc> argument in the remote fifo |
---|
| 125 | * defined by the <cxy> argument. It sends an IPI to the server if fifo is empty. |
---|
| 126 | * The RPC descriptor must be allocated in the caller's stack, and initialised by |
---|
| 127 | * the caller. It exit with a Panic message if remote fifo is still full after |
---|
| 128 | * (CONFIG_RPC_PUT_MAX_ITERATIONS) retries. |
---|
| 129 | * - When the <block> argument is true, this function blocks and deschedule. |
---|
| 130 | * It returns only when the server acknowledges the RPC by writing in the RPC |
---|
| 131 | * "response" field, and unblocks the client. |
---|
| 132 | * - When the <block> argument is false, this function returns as soon as the RPC |
---|
| 133 | * has been registered in the FIFO, and the server thread must directly signal |
---|
| 134 | * completion to the client thread. |
---|
[1] | 135 | *********************************************************************************** |
---|
| 136 | * @ cxy : server cluster identifier |
---|
| 137 | * @ desc : local pointer on RPC descriptor in client cluster |
---|
[409] | 138 | * @ block : boolean true when blocking behaviour is required. |
---|
[1] | 139 | **********************************************************************************/ |
---|
[409] | 140 | void rpc_send( cxy_t cxy, |
---|
| 141 | rpc_desc_t * desc, |
---|
| 142 | bool_t block ); |
---|
[1] | 143 | |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | /**********************************************************************************/ |
---|
| 147 | /******* Generic functions supporting RPCs : server side **************************/ |
---|
| 148 | /**********************************************************************************/ |
---|
| 149 | |
---|
| 150 | /*********************************************************************************** |
---|
| 151 | * This function is the entry point for RPC handling on the server side. |
---|
[407] | 152 | * It is executed by a core receiving an IPI, and each time the core enters, |
---|
| 153 | * or exit the kernel to handle . |
---|
| 154 | * It does nothing and return if the RPC_FIFO is empty. |
---|
| 155 | * The calling thread checks if it exist at least one non-blocked RPC thread, |
---|
| 156 | * creates a new RPC if required, and deschedule to allow the RPC thead to execute. |
---|
[1] | 157 | **********************************************************************************/ |
---|
[407] | 158 | void rpc_check(); |
---|
[1] | 159 | |
---|
| 160 | /*********************************************************************************** |
---|
| 161 | * This function contains the loop to execute all pending RPCs on the server side. |
---|
[407] | 162 | * It is called by the rpc_thread_func() function with irq disabled, and after |
---|
| 163 | * RPC_FIFO ownership acquisition. |
---|
[1] | 164 | *********************************************************************************** |
---|
| 165 | * @ rpc_fifo : pointer on the local RPC fifo |
---|
| 166 | **********************************************************************************/ |
---|
[407] | 167 | void rpc_execute_all( remote_fifo_t * rpc_fifo ); |
---|
[1] | 168 | |
---|
| 169 | /*********************************************************************************** |
---|
[407] | 170 | * This function contains the infinite loop executed by a RPC thread. |
---|
[1] | 171 | **********************************************************************************/ |
---|
| 172 | void rpc_thread_func(); |
---|
| 173 | |
---|
| 174 | /*********************************************************************************** |
---|
| 175 | * This function is executed in case of illegal RPC index. |
---|
| 176 | **********************************************************************************/ |
---|
| 177 | void __attribute__((noinline)) rpc_undefined(); |
---|
| 178 | |
---|
[23] | 179 | |
---|
| 180 | |
---|
| 181 | |
---|
[1] | 182 | /**********************************************************************************/ |
---|
| 183 | /******* Marshalling functions attached to the various RPCs ***********************/ |
---|
| 184 | /**********************************************************************************/ |
---|
| 185 | |
---|
| 186 | /*********************************************************************************** |
---|
[23] | 187 | * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster, |
---|
[313] | 188 | * and returns the local pointer on the page descriptor. |
---|
[1] | 189 | *********************************************************************************** |
---|
| 190 | * @ cxy : server cluster identifier |
---|
| 191 | * @ order : [in] ln2( number of requested pages ) |
---|
[313] | 192 | * @ page : [out] local pointer on page descriptor / NULL if failure |
---|
[1] | 193 | **********************************************************************************/ |
---|
[313] | 194 | void rpc_pmem_get_pages_client( cxy_t cxy, |
---|
| 195 | uint32_t order, |
---|
| 196 | struct page_s ** page ); |
---|
[1] | 197 | |
---|
| 198 | void rpc_pmem_get_pages_server( xptr_t xp ); |
---|
| 199 | |
---|
| 200 | /*********************************************************************************** |
---|
[409] | 201 | * [1] The RPC_PMEM_RELEASE_PAGES release one or several pages to a remote cluster. |
---|
| 202 | *********************************************************************************** |
---|
| 203 | * @ cxy : server cluster identifier |
---|
| 204 | * @ page : [in] local pointer on page descriptor to release. |
---|
| 205 | **********************************************************************************/ |
---|
| 206 | void rpc_pmem_release_pages_client( cxy_t cxy, |
---|
| 207 | struct page_s * page ); |
---|
| 208 | |
---|
| 209 | void rpc_pmem_release_pages_server( xptr_t xp ); |
---|
| 210 | |
---|
| 211 | /*********************************************************************************** |
---|
| 212 | * [2] The RPC_PROCESS_MAKE_EXEC creates a new process descriptor, from an existing |
---|
[408] | 213 | * process descriptor in a remote server cluster. This server cluster must be |
---|
| 214 | * the owner cluster for the existing process. The new process descriptor is |
---|
| 215 | * initialized from informations found in the <exec_info> structure. |
---|
| 216 | * A new main thread descriptor is created in the server cluster. |
---|
| 217 | * All copies of the old process descriptor and all old threads are destroyed. |
---|
[1] | 218 | *********************************************************************************** |
---|
| 219 | * @ cxy : server cluster identifier. |
---|
[408] | 220 | * @ process : [in] local pointer on the exec_info structure in client cluster. |
---|
[1] | 221 | * @ error : [out] error status (0 if success). |
---|
| 222 | **********************************************************************************/ |
---|
[408] | 223 | void rpc_process_make_exec_client( cxy_t cxy, |
---|
| 224 | struct exec_info_s * info, |
---|
| 225 | error_t * error ); |
---|
[1] | 226 | |
---|
[408] | 227 | void rpc_process_make_exec_server( xptr_t xp ); |
---|
[1] | 228 | |
---|
| 229 | /*********************************************************************************** |
---|
[409] | 230 | * [3] The RPC_PROCESS_MAKE_FORK creates a "child" process descriptor, and the |
---|
[408] | 231 | * associated "child" thread descriptor in a target remote cluster that can be |
---|
| 232 | * any cluster. The child process is initialized from informations found in the |
---|
| 233 | * "parent" process descriptor (that must be the parent reference cluster), |
---|
| 234 | * and from the "parent" thread descriptor that can be in any cluster. |
---|
[1] | 235 | *********************************************************************************** |
---|
[408] | 236 | * @ cxy : server cluster identifier. |
---|
| 237 | * @ ref_process_xp : [in] extended pointer on reference parent process. |
---|
| 238 | * @ parent_thread_xp : [in] extended pointer on parent thread. |
---|
| 239 | * @ child_pid : [out] child process identifier. |
---|
| 240 | * @ child_thread_ptr : [out] local pointer on child thread. |
---|
| 241 | * @ error : [out] error status (0 if success). |
---|
[1] | 242 | **********************************************************************************/ |
---|
[408] | 243 | void rpc_process_make_fork_client( cxy_t cxy, |
---|
| 244 | xptr_t ref_process_xp, |
---|
| 245 | xptr_t parent_thread_xp, |
---|
| 246 | pid_t * child_pid, |
---|
| 247 | struct thread_s ** child_thread_ptr, |
---|
| 248 | error_t * error ); |
---|
[1] | 249 | |
---|
[408] | 250 | void rpc_process_make_fork_server( xptr_t xp ); |
---|
[1] | 251 | |
---|
| 252 | /*********************************************************************************** |
---|
[409] | 253 | * [4] The RPC_PROCESS_MAKE_EXIT can be called by any thread to request the owner |
---|
| 254 | * cluster to execute the process_make_exit() function for a calling process. |
---|
[1] | 255 | *********************************************************************************** |
---|
[409] | 256 | * @ cxy : server cluster identifier. |
---|
| 257 | * @ process : local pointer on calling process in owner cluster. |
---|
| 258 | * @ status : calling process exit status. |
---|
[1] | 259 | **********************************************************************************/ |
---|
[409] | 260 | void rpc_process_make_exit_client( cxy_t cxy, |
---|
| 261 | struct process_s * process, |
---|
| 262 | uint32_t status ); |
---|
[1] | 263 | |
---|
[409] | 264 | void rpc_process_make_exit_server( xptr_t xp ); |
---|
[1] | 265 | |
---|
| 266 | /*********************************************************************************** |
---|
[409] | 267 | * [5] The RPC_PROCESS_MAKE_KILL can be called by any thread to request the owner |
---|
| 268 | * cluster to execute the process_make_kill() function for a target process. |
---|
| 269 | *********************************************************************************** |
---|
| 270 | * @ cxy : server cluster identifier. |
---|
| 271 | * @ process : local pointer on target process in owner cluster. |
---|
| 272 | * @ seg_id : signal type (only SIGKILL / SIGSTOP / SIGCONT are supported). |
---|
| 273 | **********************************************************************************/ |
---|
| 274 | void rpc_process_make_kill_client( cxy_t cxy, |
---|
| 275 | struct process_s * process, |
---|
| 276 | uint32_t seg_id ); |
---|
| 277 | |
---|
| 278 | void rpc_process_make_kill_server( xptr_t xp ); |
---|
| 279 | |
---|
| 280 | /*********************************************************************************** |
---|
| 281 | * [6] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster, |
---|
[23] | 282 | * as specified by the arguments. It returns an extended pointer on the new |
---|
| 283 | * thread descriptor in server cluster, and an error code. |
---|
| 284 | * It is called by the sys_thread_create() system call. |
---|
[1] | 285 | *********************************************************************************** |
---|
| 286 | * @ cxy : server cluster identifier. |
---|
[407] | 287 | * @ attr : [in] local pointer on pthread_attr_t in client cluster. |
---|
| 288 | * @ thread_xp : [out] buffer for thread extended pointer. |
---|
[1] | 289 | * @ error : [out] error status (0 if success). |
---|
| 290 | **********************************************************************************/ |
---|
| 291 | void rpc_thread_user_create_client( cxy_t cxy, |
---|
[23] | 292 | pid_t pid, |
---|
| 293 | void * start_func, |
---|
| 294 | void * start_arg, |
---|
[407] | 295 | pthread_attr_t * attr, |
---|
[1] | 296 | xptr_t * thread_xp, |
---|
| 297 | error_t * error ); |
---|
| 298 | |
---|
| 299 | void rpc_thread_user_create_server( xptr_t xp ); |
---|
| 300 | |
---|
| 301 | /*********************************************************************************** |
---|
[409] | 302 | * [7] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster, |
---|
[1] | 303 | * as specified by the type, func and args arguments. It returns the local pointer |
---|
| 304 | * on the thread descriptor in server cluster and an error code. |
---|
[23] | 305 | * It is used by the dev_init() function to create the device server thread. |
---|
[1] | 306 | *********************************************************************************** |
---|
| 307 | * @ cxy : server cluster identifier. |
---|
| 308 | * @ type : [in] type of kernel thread. |
---|
| 309 | * @ func : [in] local pointer on thread function. |
---|
| 310 | * @ args : [in] local pointer on function arguments. |
---|
| 311 | * @ thread_xp : [out] pointer on buffer for thread extended pointer. |
---|
| 312 | * @ error : [out] error status (0 if success). |
---|
| 313 | **********************************************************************************/ |
---|
| 314 | void rpc_thread_kernel_create_client( cxy_t cxy, |
---|
| 315 | uint32_t type, |
---|
| 316 | void * func, |
---|
| 317 | void * args, |
---|
| 318 | xptr_t * thread_xp, |
---|
| 319 | error_t * error ); |
---|
| 320 | |
---|
| 321 | void rpc_thread_kernel_create_server( xptr_t xp ); |
---|
| 322 | |
---|
[23] | 323 | /*********************************************************************************** |
---|
[409] | 324 | * [8] The RPC_THREAD_KILL ask a target cluster to kill a given thread descriptor. |
---|
| 325 | * It is called by the sys_thread_cancel() function for a remote thread. |
---|
[23] | 326 | *********************************************************************************** |
---|
| 327 | * @ cxy : server cluster identifier. |
---|
[409] | 328 | * @ thread : [in] local pointer on target process descriptor in server. |
---|
[23] | 329 | **********************************************************************************/ |
---|
[409] | 330 | void rpc_thread_kill_client( cxy_t cxy, |
---|
| 331 | struct thread_s * thread ); |
---|
[23] | 332 | |
---|
[409] | 333 | void rpc_thread_kill_server( xptr_t xp ); |
---|
[23] | 334 | |
---|
[409] | 335 | /*********************************************************************************** |
---|
| 336 | * [9] The RPC_PROCESS_SIGACTION allows the owner cluster to request any other |
---|
| 337 | * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all threads |
---|
| 338 | * of a given process. |
---|
| 339 | * |
---|
| 340 | * WARNING : It is implemented as a NON BLOCKING multicast RPC, that can be sent |
---|
| 341 | * in parallel to all process copies. The various server threads must decrement the |
---|
| 342 | * responses counter defined by the <rsp_xp> argument, and the last server thread |
---|
| 343 | * must unblock the <client_xp> thread. |
---|
| 344 | *********************************************************************************** |
---|
| 345 | * @ cxy : server cluster identifier. |
---|
| 346 | * @ process : [in] local pointer on target process in server cluster. |
---|
| 347 | * @ sigaction : [in] action type (BLOCK / UNBLOCK / DELETE). |
---|
| 348 | * @ rsp_xp : [in] extended pointer on response counter. |
---|
| 349 | * @ client_xp : [in] extended pointer on client thread. |
---|
| 350 | **********************************************************************************/ |
---|
| 351 | void rpc_process_sigaction_client( cxy_t cxy, |
---|
| 352 | struct process_s * process, |
---|
| 353 | uint32_t sigaction, |
---|
| 354 | xptr_t rsp_xp, |
---|
| 355 | xptr_t client_xp ); |
---|
| 356 | |
---|
| 357 | void rpc_process_sigaction_server( xptr_t xp ); |
---|
| 358 | |
---|
[1] | 359 | /*********************************************************************************** |
---|
[23] | 360 | * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a |
---|
[1] | 361 | * remote cluster. The parent dentry must have been previously created. |
---|
| 362 | * It returns an extended pointer on the created inode. |
---|
| 363 | *********************************************************************************** |
---|
[23] | 364 | * @ cxy : server cluster identifier. |
---|
| 365 | * @ dentry_xp : [in] extended pointer on parent dentry. |
---|
| 366 | * @ fs_type : [in] file system type. |
---|
| 367 | * @ inode_type : [in] file system type. |
---|
[188] | 368 | * @ extend : [in] fs_type_specific inode extension. |
---|
[23] | 369 | * @ attr : [in] inode attributes. |
---|
| 370 | * @ rights : [in] access rights |
---|
| 371 | * @ uid : [in] user ID |
---|
| 372 | * @ gid : [in] group ID |
---|
| 373 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
| 374 | * @ error : [out] error status (0 if success). |
---|
[1] | 375 | **********************************************************************************/ |
---|
| 376 | void rpc_vfs_inode_create_client( cxy_t cxy, |
---|
| 377 | xptr_t dentry_xp, |
---|
[23] | 378 | uint32_t fs_type, |
---|
| 379 | uint32_t inode_type, |
---|
[188] | 380 | void * extend, |
---|
[1] | 381 | uint32_t attr, |
---|
[23] | 382 | uint32_t rights, |
---|
[1] | 383 | uint32_t uid, |
---|
| 384 | uint32_t gid, |
---|
| 385 | xptr_t * inode_xp, |
---|
| 386 | error_t * error ); |
---|
| 387 | |
---|
| 388 | void rpc_vfs_inode_create_server( xptr_t xp ); |
---|
| 389 | |
---|
| 390 | /*********************************************************************************** |
---|
[23] | 391 | * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor |
---|
[1] | 392 | * and for the associated mapper in a remote cluster. |
---|
| 393 | *********************************************************************************** |
---|
| 394 | * @ cxy : server cluster identifier |
---|
| 395 | * @ inode : [in] local pointer on inode. |
---|
| 396 | **********************************************************************************/ |
---|
| 397 | void rpc_vfs_inode_destroy_client( cxy_t cxy, |
---|
| 398 | struct vfs_inode_s * inode ); |
---|
| 399 | |
---|
| 400 | void rpc_vfs_inode_destroy_server( xptr_t xp ); |
---|
| 401 | |
---|
| 402 | /*********************************************************************************** |
---|
[23] | 403 | * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster. |
---|
[1] | 404 | * It returns an extended pointer on the created dentry. |
---|
| 405 | *********************************************************************************** |
---|
| 406 | * @ cxy : server cluster identifier |
---|
| 407 | * @ type : [in] file system type. |
---|
| 408 | * @ name : [in] directory entry name. |
---|
| 409 | * @ parent : [in] local pointer on parent inode. |
---|
| 410 | * @ dentry_xp : [out] buffer for extended pointer on created dentry. |
---|
| 411 | * @ error : [out] error status (0 if success). |
---|
| 412 | **********************************************************************************/ |
---|
| 413 | void rpc_vfs_dentry_create_client( cxy_t cxy, |
---|
| 414 | uint32_t type, |
---|
| 415 | char * name, |
---|
| 416 | struct vfs_inode_s * parent, |
---|
| 417 | xptr_t * dentry_xp, |
---|
| 418 | error_t * error ); |
---|
| 419 | |
---|
| 420 | void rpc_vfs_dentry_create_server( xptr_t xp ); |
---|
| 421 | |
---|
| 422 | /*********************************************************************************** |
---|
[23] | 423 | * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor |
---|
[1] | 424 | * in a remote cluster. |
---|
| 425 | *********************************************************************************** |
---|
| 426 | * @ cxy : server cluster identifier |
---|
| 427 | * @ dentry : [in] local pointer on dentry. |
---|
| 428 | **********************************************************************************/ |
---|
| 429 | void rpc_vfs_dentry_destroy_client( cxy_t cxy, |
---|
| 430 | struct vfs_dentry_s * dentry ); |
---|
| 431 | |
---|
| 432 | void rpc_vfs_dentry_destroy_server( xptr_t xp ); |
---|
| 433 | |
---|
[23] | 434 | /*********************************************************************************** |
---|
| 435 | * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster. |
---|
| 436 | * It returns an extended pointer on the created file structure. |
---|
| 437 | *********************************************************************************** |
---|
| 438 | * @ cxy : server cluster identifier |
---|
| 439 | * @ inode : [in] local pointer on parent inode. |
---|
| 440 | * @ file_attr : [in] new file attributes. |
---|
| 441 | * @ file_xp : [out] buffer for extended pointer on created file. |
---|
| 442 | * @ error : [out] error status (0 if success). |
---|
| 443 | **********************************************************************************/ |
---|
| 444 | void rpc_vfs_file_create_client( cxy_t cxy, |
---|
| 445 | struct vfs_inode_s * inode, |
---|
| 446 | uint32_t file_attr, |
---|
| 447 | xptr_t * file_xp, |
---|
| 448 | error_t * error ); |
---|
[1] | 449 | |
---|
[23] | 450 | void rpc_vfs_file_create_server( xptr_t xp ); |
---|
[1] | 451 | |
---|
[23] | 452 | /*********************************************************************************** |
---|
| 453 | * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor |
---|
| 454 | * in a remote cluster. |
---|
| 455 | *********************************************************************************** |
---|
| 456 | * @ cxy : server cluster identifier |
---|
| 457 | * @ file : [in] local pointer on file. |
---|
| 458 | **********************************************************************************/ |
---|
| 459 | void rpc_vfs_file_destroy_client( cxy_t cxy, |
---|
| 460 | struct vfs_file_s * file ); |
---|
[1] | 461 | |
---|
[23] | 462 | void rpc_vfs_file_destroy_server( xptr_t xp ); |
---|
| 463 | |
---|
[238] | 464 | /*********************************************************************************** |
---|
| 465 | * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a |
---|
| 466 | * remote cluster containing a parent inode directory to scan the associated |
---|
| 467 | * mapper, find a directory entry, identified by its name, and update the remote |
---|
| 468 | * child inode. |
---|
| 469 | *********************************************************************************** |
---|
| 470 | * @ cxy : server cluster identifier |
---|
| 471 | * @ parent_inode : [in] local pointer on parent inode. |
---|
| 472 | * @ name : [in] local pointer on child name (in client cluster). |
---|
| 473 | * @ child_inode_xp : [in] extended pointer on child inode (in another cluster). |
---|
| 474 | * @ error : [out] error status (0 if success). |
---|
| 475 | **********************************************************************************/ |
---|
| 476 | void rpc_vfs_inode_load_client( cxy_t cxy, |
---|
| 477 | struct vfs_inode_s * parent_inode, |
---|
| 478 | char * name, |
---|
| 479 | xptr_t child_inode_xp, |
---|
| 480 | error_t * error ); |
---|
| 481 | |
---|
| 482 | void rpc_vfs_inode_load_server( xptr_t xp ); |
---|
| 483 | |
---|
| 484 | /*********************************************************************************** |
---|
| 485 | * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function |
---|
| 486 | * in a remote cluster containing an inode, to load all pages of the associated |
---|
| 487 | * mapper from the file system on device. |
---|
| 488 | *********************************************************************************** |
---|
| 489 | * @ cxy : server cluster identifier |
---|
| 490 | * @ inode : [in] local pointer on inode in server cluster. |
---|
| 491 | * @ error : [out] error status (0 if success). |
---|
| 492 | **********************************************************************************/ |
---|
| 493 | void rpc_vfs_mapper_load_all_client( cxy_t cxy, |
---|
| 494 | struct vfs_inode_s * inode, |
---|
| 495 | error_t * error ); |
---|
| 496 | |
---|
| 497 | void rpc_vfs_mapper_load_all_server( xptr_t xp ); |
---|
| 498 | |
---|
[1] | 499 | /*********************************************************************************** |
---|
[238] | 500 | * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" |
---|
[23] | 501 | * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get |
---|
| 502 | * from the mapper the local pointer on a given page. |
---|
| 503 | *********************************************************************************** |
---|
| 504 | * @ cxy : server cluster identifier. |
---|
| 505 | * @ mapper : [in] local pointer on FAT mapper. |
---|
| 506 | * @ first : [in] FATFS cluster index allocated to first page of file. |
---|
| 507 | * @ page : [in] page index in file. |
---|
| 508 | * @ cluster : [out] local pointer on buffer for found FATFS cluster index. |
---|
| 509 | * @ error : [out] local pointer on buffer for error code (in client cluster). |
---|
| 510 | **********************************************************************************/ |
---|
| 511 | void rpc_fatfs_get_cluster_client( cxy_t cxy, |
---|
| 512 | struct mapper_s * mapper, |
---|
| 513 | uint32_t first, |
---|
| 514 | uint32_t page, |
---|
| 515 | uint32_t * cluster, |
---|
| 516 | error_t * error ); |
---|
| 517 | |
---|
| 518 | void rpc_fatfs_get_cluster_server( xptr_t xp ); |
---|
| 519 | |
---|
| 520 | /*********************************************************************************** |
---|
[389] | 521 | * [20] The RPC_VMM_GET_VSEG returns an extended pointer |
---|
[1] | 522 | * on the vseg containing a given virtual address in a given process. |
---|
| 523 | * The server cluster is supposed to be the reference cluster. |
---|
[389] | 524 | * It returns a non zero error value if no vseg has been founded. |
---|
[1] | 525 | *********************************************************************************** |
---|
| 526 | * @ cxy : server cluster identifier. |
---|
| 527 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
| 528 | * @ vaddr : [in] virtual address to be searched. |
---|
[16] | 529 | * @ vseg_xp : [out] buffer for extended pointer on vseg in client cluster. |
---|
[389] | 530 | * @ error : [out] local pointer on buffer for error code (in client cluster). |
---|
[1] | 531 | **********************************************************************************/ |
---|
[389] | 532 | void rpc_vmm_get_vseg_client( cxy_t cxy, |
---|
| 533 | struct process_s * process, |
---|
| 534 | intptr_t vaddr, |
---|
| 535 | xptr_t * vseg_xp, |
---|
[401] | 536 | error_t * error ); |
---|
[1] | 537 | |
---|
[389] | 538 | void rpc_vmm_get_vseg_server( xptr_t xp ); |
---|
[1] | 539 | |
---|
| 540 | /*********************************************************************************** |
---|
[407] | 541 | * [21] The RPC_VMM_GET_PTE returns in the <ppn> and <attr> arguments the PTE value |
---|
| 542 | * for a given <vpn> in a given <process> (page_fault or copy_on_write event). |
---|
[1] | 543 | * The server cluster is supposed to be the reference cluster, and the vseg |
---|
| 544 | * containing the VPN must be registered in the reference VMM. |
---|
[407] | 545 | * It returns an error if physical memory cannot be allocated for the missing PTE2, |
---|
[1] | 546 | * or for the missing page itself. |
---|
| 547 | *********************************************************************************** |
---|
| 548 | * @ cxy : server cluster identifier. |
---|
| 549 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
| 550 | * @ vaddr : [in] virtual address to be searched. |
---|
[407] | 551 | * @ cow : [in] "copy_on_write" event if true / "page_fault" event if false. |
---|
[1] | 552 | * @ attr : [out] address of buffer for attributes. |
---|
| 553 | * @ ppn : [out] address of buffer for PPN. |
---|
| 554 | * @ error : [out] address of buffer for error code. |
---|
| 555 | **********************************************************************************/ |
---|
| 556 | void rpc_vmm_get_pte_client( cxy_t cxy, |
---|
| 557 | struct process_s * process, |
---|
| 558 | vpn_t vpn, |
---|
[407] | 559 | bool_t cow, |
---|
[1] | 560 | uint32_t * attr, |
---|
| 561 | ppn_t * ppn, |
---|
| 562 | error_t * error ); |
---|
| 563 | |
---|
| 564 | void rpc_vmm_get_pte_server( xptr_t xp ); |
---|
| 565 | |
---|
| 566 | /*********************************************************************************** |
---|
[23] | 567 | * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster, |
---|
| 568 | * and returns an extended pointer on the allocated object. |
---|
| 569 | It returns XPTR_NULL if physical memory cannot be allocated. |
---|
[1] | 570 | *********************************************************************************** |
---|
[23] | 571 | * @ cxy : server cluster identifier. |
---|
| 572 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
| 573 | * @ buf_xp : [out] buffer for extended pointer on allocated buffer. |
---|
[1] | 574 | **********************************************************************************/ |
---|
[23] | 575 | void rpc_kcm_alloc_client( cxy_t cxy, |
---|
| 576 | uint32_t kmem_type, |
---|
| 577 | xptr_t * buf_xp ); |
---|
[1] | 578 | |
---|
[23] | 579 | void rpc_kcm_alloc_server( xptr_t xp ); |
---|
[1] | 580 | |
---|
| 581 | /*********************************************************************************** |
---|
[23] | 582 | * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type, |
---|
[1] | 583 | * in a remote cluster. |
---|
| 584 | *********************************************************************************** |
---|
[23] | 585 | * @ cxy : server cluster identifier. |
---|
| 586 | * @ buf : [in] local pointer on allocated buffer. |
---|
| 587 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
[1] | 588 | **********************************************************************************/ |
---|
[23] | 589 | void rpc_kcm_free_client( cxy_t cxy, |
---|
| 590 | void * buf, |
---|
| 591 | uint32_t kmem_type ); |
---|
[1] | 592 | |
---|
[23] | 593 | void rpc_kcm_free_server( xptr_t xp ); |
---|
[1] | 594 | |
---|
| 595 | /*********************************************************************************** |
---|
[313] | 596 | * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote |
---|
| 597 | * mapper to move data to/from a kernel or user buffer. |
---|
| 598 | * - It calls the mapper_move_user() function for a - possibly distributed - |
---|
| 599 | * user buffer identified by a user-space pointer, and casted to uint64_t. |
---|
| 600 | * - It calls the mapper_move_kernel() function for a - possibly remote - |
---|
| 601 | * kernel buffer identified by an extended pointer, and casted to uint64_t. |
---|
| 602 | * It is used by the vfs_move_user() function to move data between a mapper |
---|
| 603 | * and an user buffer required by a sys_read() or a sys_write(). |
---|
| 604 | * It is used by the vmm_get_one_ppn() function to initialise a physical page |
---|
| 605 | * from a .elf file mapper, for a CODE or DATA vseg page fault. |
---|
[1] | 606 | *********************************************************************************** |
---|
[23] | 607 | * @ cxy : server cluster identifier. |
---|
| 608 | * @ mapper : [in] local pointer on mapper |
---|
[313] | 609 | * @ to_buffer : [in] move data from mapper to buffer if non zero. |
---|
| 610 | * @ is_user : [in] buffer in user space if true |
---|
[23] | 611 | * @ file_offset : [in] first byte to move in mapper |
---|
[313] | 612 | * @ buffer : [in] user space pointer / kernel extended pointer |
---|
[23] | 613 | * @ size : [in] number of bytes to move |
---|
| 614 | * @ error : [out] error status (0 if success). |
---|
[1] | 615 | **********************************************************************************/ |
---|
[265] | 616 | void rpc_mapper_move_buffer_client( cxy_t cxy, |
---|
| 617 | struct mapper_s * mapper, |
---|
| 618 | bool_t to_buffer, |
---|
| 619 | bool_t is_user, |
---|
| 620 | uint32_t file_offset, |
---|
[313] | 621 | uint64_t buffer, |
---|
[265] | 622 | uint32_t size, |
---|
| 623 | error_t * error ); |
---|
[1] | 624 | |
---|
[265] | 625 | void rpc_mapper_move_buffer_server( xptr_t xp ); |
---|
[1] | 626 | |
---|
[313] | 627 | /*********************************************************************************** |
---|
| 628 | * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer |
---|
| 629 | * on a remote page descriptor, for a page, identified by the page index in mapper. |
---|
| 630 | * It is used by the vmm_get_one_ppn() function to handle a page fault on |
---|
| 631 | * a FILE type vseg. |
---|
| 632 | *********************************************************************************** |
---|
| 633 | * @ cxy : server cluster identifier. |
---|
| 634 | * @ mapper : [in] local pointer on mapper. |
---|
| 635 | * @ index : [in] page index in mapper. |
---|
| 636 | * @ page : [out] local pointer on page descriptor / NULL if failure. |
---|
| 637 | **********************************************************************************/ |
---|
| 638 | void rpc_mapper_get_page_client( cxy_t cxy, |
---|
| 639 | struct mapper_s * mapper, |
---|
| 640 | uint32_t index, |
---|
| 641 | struct page_s ** page ); |
---|
[1] | 642 | |
---|
[313] | 643 | void rpc_mapper_get_page_server( xptr_t xp ); |
---|
[1] | 644 | |
---|
[407] | 645 | /*********************************************************************************** |
---|
| 646 | * [26] The RPC_VMM_CREATE_VSEG allows a client thread to request the remote |
---|
| 647 | * reference cluster of a given process to allocate and register in the reference |
---|
| 648 | * process VMM a new vseg descriptor. |
---|
| 649 | * On the server side, this RPC uses the vmm_create_vseg() function, and returns |
---|
| 650 | * to the client the local pointer on the created vseg descriptor. |
---|
| 651 | *********************************************************************************** |
---|
| 652 | * @ cxy : server cluster identifier. |
---|
| 653 | * @ process : [in] local pointer on process descriptor in server. |
---|
| 654 | * @ type : [in] vseg type. |
---|
| 655 | * @ base : [in] base address (unused for dynamically allocated vsegs). |
---|
| 656 | * @ size : [in] number of bytes. |
---|
| 657 | * @ file_offset : [in] offset in file (for CODE, DATA, FILE types). |
---|
| 658 | * @ file_size : [in] can be smaller than size for DATA type. |
---|
| 659 | * @ mapper_xp : [in] extended pointer on mapper (for CODE, DATA, FILE types). |
---|
| 660 | * @ vseg_cxy : [in] target cluster for mapping (if not data type). |
---|
| 661 | * @ vseg : [out] local pointer on vseg descriptor / NULL if failure. |
---|
| 662 | **********************************************************************************/ |
---|
| 663 | void rpc_vmm_create_vseg_client( cxy_t cxy, |
---|
| 664 | struct process_s * process, |
---|
| 665 | vseg_type_t type, |
---|
| 666 | intptr_t base, |
---|
| 667 | uint32_t size, |
---|
| 668 | uint32_t file_offset, |
---|
| 669 | uint32_t file_size, |
---|
| 670 | xptr_t mapper_xp, |
---|
| 671 | cxy_t vseg_cxy, |
---|
| 672 | struct vseg_s ** vseg ); |
---|
| 673 | |
---|
| 674 | void rpc_vmm_create_vseg_server( xptr_t xp ); |
---|
| 675 | |
---|
| 676 | /*********************************************************************************** |
---|
| 677 | * [27] The RPC_SCHED_DISPLAY allows a client thread to request the display |
---|
| 678 | * of a remote scheduler, identified by the <lid> argument. |
---|
| 679 | *********************************************************************************** |
---|
| 680 | * @ cxy : server cluster identifier. |
---|
| 681 | * @ lid : [in] local index of target core in client cluster. |
---|
| 682 | **********************************************************************************/ |
---|
| 683 | void rpc_sched_display_client( cxy_t cxy, |
---|
| 684 | lid_t lid ); |
---|
| 685 | |
---|
| 686 | void rpc_sched_display_server( xptr_t xp ); |
---|
| 687 | |
---|
[408] | 688 | /*********************************************************************************** |
---|
| 689 | * [28] The RPC_VMM_SET_COW allows a client thread to request the remote reference |
---|
| 690 | * cluster to set the COW flag and reset the WRITABLE flag of all GPT entries for |
---|
| 691 | * the DATA, MMAP and REMOTE vsegs of process identified by the <process> argument. |
---|
| 692 | |
---|
| 693 | * of a remote scheduler, identified by the <lid> argument. |
---|
| 694 | *********************************************************************************** |
---|
| 695 | * @ cxy : server cluster identifier. |
---|
| 696 | * @ process : [in] local pointer on reference process descriptor. |
---|
| 697 | **********************************************************************************/ |
---|
| 698 | void rpc_vmm_set_cow_client( cxy_t cxy, |
---|
| 699 | struct process_s * process ); |
---|
| 700 | |
---|
| 701 | void rpc_vmm_set_cow_server( xptr_t xp ); |
---|
| 702 | |
---|
[1] | 703 | #endif |
---|