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