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