[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> |
---|
| 34 | |
---|
| 35 | /**** Forward declarations ****/ |
---|
| 36 | |
---|
| 37 | struct process_s; |
---|
[313] | 38 | struct page_s; |
---|
[1] | 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; |
---|
[23] | 46 | struct vfs_file_s; |
---|
[1] | 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_PID_ALLOC = 1, |
---|
| 63 | RPC_PROCESS_EXEC = 2, |
---|
| 64 | RPC_PROCESS_KILL = 3, |
---|
| 65 | RPC_THREAD_USER_CREATE = 4, |
---|
| 66 | RPC_THREAD_KERNEL_CREATE = 5, |
---|
[23] | 67 | RPC_SIGNAL_RISE = 6, |
---|
[1] | 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, |
---|
[23] | 73 | RPC_VFS_FILE_CREATE = 14, |
---|
| 74 | RPC_VFS_FILE_DESTROY = 15, |
---|
[238] | 75 | RPC_VFS_INODE_LOAD = 16, |
---|
| 76 | RPC_VFS_MAPPER_LOAD_ALL = 17, |
---|
| 77 | RPC_FATFS_GET_CLUSTER = 18, |
---|
[1] | 78 | |
---|
[389] | 79 | RPC_VMM_GET_VSEG = 20, |
---|
[1] | 80 | RPC_VMM_GET_PTE = 21, |
---|
[23] | 81 | RPC_KCM_ALLOC = 22, |
---|
| 82 | RPC_KCM_FREE = 23, |
---|
[265] | 83 | RPC_MAPPER_MOVE_BUFFER = 24, |
---|
[313] | 84 | RPC_MAPPER_GET_PAGE = 25, |
---|
[407] | 85 | RPC_VMM_CREATE_VSEG = 26, |
---|
| 86 | RPC_SCHED_DISPLAY = 27, |
---|
[1] | 87 | |
---|
[23] | 88 | RPC_MAX_INDEX = 30, |
---|
[1] | 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 | { |
---|
[407] | 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 */ |
---|
[1] | 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. |
---|
[407] | 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. |
---|
[1] | 144 | **********************************************************************************/ |
---|
[407] | 145 | void rpc_check(); |
---|
[1] | 146 | |
---|
| 147 | /*********************************************************************************** |
---|
| 148 | * This function contains the loop to execute all pending RPCs on the server side. |
---|
[407] | 149 | * It is called by the rpc_thread_func() function with irq disabled, and after |
---|
| 150 | * RPC_FIFO ownership acquisition. |
---|
[1] | 151 | *********************************************************************************** |
---|
| 152 | * @ rpc_fifo : pointer on the local RPC fifo |
---|
| 153 | **********************************************************************************/ |
---|
[407] | 154 | void rpc_execute_all( remote_fifo_t * rpc_fifo ); |
---|
[1] | 155 | |
---|
| 156 | /*********************************************************************************** |
---|
[407] | 157 | * This function contains the infinite loop executed by a RPC thread. |
---|
[1] | 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 | |
---|
[23] | 166 | |
---|
| 167 | |
---|
| 168 | |
---|
[1] | 169 | /**********************************************************************************/ |
---|
| 170 | /******* Marshalling functions attached to the various RPCs ***********************/ |
---|
| 171 | /**********************************************************************************/ |
---|
| 172 | |
---|
| 173 | /*********************************************************************************** |
---|
[23] | 174 | * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster, |
---|
[313] | 175 | * and returns the local pointer on the page descriptor. |
---|
[1] | 176 | *********************************************************************************** |
---|
| 177 | * @ cxy : server cluster identifier |
---|
| 178 | * @ order : [in] ln2( number of requested pages ) |
---|
[313] | 179 | * @ page : [out] local pointer on page descriptor / NULL if failure |
---|
[1] | 180 | **********************************************************************************/ |
---|
[313] | 181 | void rpc_pmem_get_pages_client( cxy_t cxy, |
---|
| 182 | uint32_t order, |
---|
| 183 | struct page_s ** page ); |
---|
[1] | 184 | |
---|
| 185 | void rpc_pmem_get_pages_server( xptr_t xp ); |
---|
| 186 | |
---|
| 187 | /*********************************************************************************** |
---|
[23] | 188 | * [1] The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers |
---|
[1] | 189 | * the new process in the remote cluster, and returns the PID, and an error code. |
---|
| 190 | *********************************************************************************** |
---|
| 191 | * @ cxy : server cluster identifier. |
---|
| 192 | * @ process : [in] local pointer on process descriptor in client cluster. |
---|
| 193 | * @ error : [out] error status (0 if success). |
---|
| 194 | * @ pid : [out] new process identifier. |
---|
| 195 | **********************************************************************************/ |
---|
| 196 | void rpc_process_pid_alloc_client( cxy_t cxy, |
---|
| 197 | struct process_s * process, |
---|
| 198 | error_t * error, |
---|
| 199 | pid_t * pid ); |
---|
| 200 | |
---|
| 201 | void rpc_process_pid_alloc_server( xptr_t xp ); |
---|
| 202 | |
---|
| 203 | /*********************************************************************************** |
---|
[23] | 204 | * [2] The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster |
---|
[1] | 205 | * and initializes if from information found in the reference process descriptor. |
---|
| 206 | * This remote cluster becomes the new reference cluster. |
---|
| 207 | *********************************************************************************** |
---|
| 208 | * @ cxy : server cluster identifier. |
---|
| 209 | * @ info : [in] pointer on local exec_info structure. |
---|
| 210 | * @ error : [out] error status (0 if success). |
---|
| 211 | **********************************************************************************/ |
---|
| 212 | void rpc_process_exec_client( cxy_t cxy, |
---|
| 213 | struct exec_info_s * info, |
---|
| 214 | error_t * error ); |
---|
| 215 | |
---|
| 216 | void rpc_process_exec_server( xptr_t xp ); |
---|
| 217 | |
---|
| 218 | /*********************************************************************************** |
---|
[23] | 219 | * [3] The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster |
---|
[1] | 220 | * to other clusters containing a process descriptor copy, to destroy these copies. |
---|
| 221 | *********************************************************************************** |
---|
| 222 | * @ process : local pointer on target process. |
---|
| 223 | **********************************************************************************/ |
---|
| 224 | void rpc_process_kill_client( struct process_s * process ); |
---|
| 225 | |
---|
| 226 | void rpc_process_kill_server( xptr_t xp ); |
---|
| 227 | |
---|
| 228 | /*********************************************************************************** |
---|
[23] | 229 | * [4] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster, |
---|
| 230 | * as specified by the arguments. It returns an extended pointer on the new |
---|
| 231 | * thread descriptor in server cluster, and an error code. |
---|
| 232 | * It is called by the sys_thread_create() system call. |
---|
[1] | 233 | *********************************************************************************** |
---|
| 234 | * @ cxy : server cluster identifier. |
---|
[407] | 235 | * @ attr : [in] local pointer on pthread_attr_t in client cluster. |
---|
| 236 | * @ thread_xp : [out] buffer for thread extended pointer. |
---|
[1] | 237 | * @ error : [out] error status (0 if success). |
---|
| 238 | **********************************************************************************/ |
---|
| 239 | void rpc_thread_user_create_client( cxy_t cxy, |
---|
[23] | 240 | pid_t pid, |
---|
| 241 | void * start_func, |
---|
| 242 | void * start_arg, |
---|
[407] | 243 | pthread_attr_t * attr, |
---|
[1] | 244 | xptr_t * thread_xp, |
---|
| 245 | error_t * error ); |
---|
| 246 | |
---|
| 247 | void rpc_thread_user_create_server( xptr_t xp ); |
---|
| 248 | |
---|
| 249 | /*********************************************************************************** |
---|
[23] | 250 | * [5] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster, |
---|
[1] | 251 | * as specified by the type, func and args arguments. It returns the local pointer |
---|
| 252 | * on the thread descriptor in server cluster and an error code. |
---|
[23] | 253 | * It is used by the dev_init() function to create the device server thread. |
---|
[1] | 254 | *********************************************************************************** |
---|
| 255 | * @ cxy : server cluster identifier. |
---|
| 256 | * @ type : [in] type of kernel thread. |
---|
| 257 | * @ func : [in] local pointer on thread function. |
---|
| 258 | * @ args : [in] local pointer on function arguments. |
---|
| 259 | * @ thread_xp : [out] pointer on buffer for thread extended pointer. |
---|
| 260 | * @ error : [out] error status (0 if success). |
---|
| 261 | **********************************************************************************/ |
---|
| 262 | void rpc_thread_kernel_create_client( cxy_t cxy, |
---|
| 263 | uint32_t type, |
---|
| 264 | void * func, |
---|
| 265 | void * args, |
---|
| 266 | xptr_t * thread_xp, |
---|
| 267 | error_t * error ); |
---|
| 268 | |
---|
| 269 | void rpc_thread_kernel_create_server( xptr_t xp ); |
---|
| 270 | |
---|
[23] | 271 | /*********************************************************************************** |
---|
| 272 | * [6] The RPC_SIGNAL_RISE ask a target cluster to register a given signal in |
---|
| 273 | * all threads descriptors of a given process. |
---|
| 274 | * It is used by the sys_kill() function. |
---|
| 275 | *********************************************************************************** |
---|
| 276 | * @ cxy : server cluster identifier. |
---|
| 277 | * @ process : [in] local pointer on target process descriptor in server. |
---|
| 278 | * @ sig_id : [in] signal index. |
---|
| 279 | **********************************************************************************/ |
---|
| 280 | void rpc_signal_rise_client( cxy_t cxy, |
---|
| 281 | struct process_s * process, |
---|
| 282 | uint32_t sig_id ); |
---|
| 283 | |
---|
| 284 | void rpc_signal_rise_server( xptr_t xp ); |
---|
| 285 | |
---|
[1] | 286 | /*********************************************************************************** |
---|
[23] | 287 | * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a |
---|
[1] | 288 | * remote cluster. The parent dentry must have been previously created. |
---|
| 289 | * It returns an extended pointer on the created inode. |
---|
| 290 | *********************************************************************************** |
---|
[23] | 291 | * @ cxy : server cluster identifier. |
---|
| 292 | * @ dentry_xp : [in] extended pointer on parent dentry. |
---|
| 293 | * @ fs_type : [in] file system type. |
---|
| 294 | * @ inode_type : [in] file system type. |
---|
[188] | 295 | * @ extend : [in] fs_type_specific inode extension. |
---|
[23] | 296 | * @ attr : [in] inode attributes. |
---|
| 297 | * @ rights : [in] access rights |
---|
| 298 | * @ uid : [in] user ID |
---|
| 299 | * @ gid : [in] group ID |
---|
| 300 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
| 301 | * @ error : [out] error status (0 if success). |
---|
[1] | 302 | **********************************************************************************/ |
---|
| 303 | void rpc_vfs_inode_create_client( cxy_t cxy, |
---|
| 304 | xptr_t dentry_xp, |
---|
[23] | 305 | uint32_t fs_type, |
---|
| 306 | uint32_t inode_type, |
---|
[188] | 307 | void * extend, |
---|
[1] | 308 | uint32_t attr, |
---|
[23] | 309 | uint32_t rights, |
---|
[1] | 310 | uint32_t uid, |
---|
| 311 | uint32_t gid, |
---|
| 312 | xptr_t * inode_xp, |
---|
| 313 | error_t * error ); |
---|
| 314 | |
---|
| 315 | void rpc_vfs_inode_create_server( xptr_t xp ); |
---|
| 316 | |
---|
| 317 | /*********************************************************************************** |
---|
[23] | 318 | * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor |
---|
[1] | 319 | * and for the associated mapper in a remote cluster. |
---|
| 320 | *********************************************************************************** |
---|
| 321 | * @ cxy : server cluster identifier |
---|
| 322 | * @ inode : [in] local pointer on inode. |
---|
| 323 | **********************************************************************************/ |
---|
| 324 | void rpc_vfs_inode_destroy_client( cxy_t cxy, |
---|
| 325 | struct vfs_inode_s * inode ); |
---|
| 326 | |
---|
| 327 | void rpc_vfs_inode_destroy_server( xptr_t xp ); |
---|
| 328 | |
---|
| 329 | /*********************************************************************************** |
---|
[23] | 330 | * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster. |
---|
[1] | 331 | * It returns an extended pointer on the created dentry. |
---|
| 332 | *********************************************************************************** |
---|
| 333 | * @ cxy : server cluster identifier |
---|
| 334 | * @ type : [in] file system type. |
---|
| 335 | * @ name : [in] directory entry name. |
---|
| 336 | * @ parent : [in] local pointer on parent inode. |
---|
| 337 | * @ dentry_xp : [out] buffer for extended pointer on created dentry. |
---|
| 338 | * @ error : [out] error status (0 if success). |
---|
| 339 | **********************************************************************************/ |
---|
| 340 | void rpc_vfs_dentry_create_client( cxy_t cxy, |
---|
| 341 | uint32_t type, |
---|
| 342 | char * name, |
---|
| 343 | struct vfs_inode_s * parent, |
---|
| 344 | xptr_t * dentry_xp, |
---|
| 345 | error_t * error ); |
---|
| 346 | |
---|
| 347 | void rpc_vfs_dentry_create_server( xptr_t xp ); |
---|
| 348 | |
---|
| 349 | /*********************************************************************************** |
---|
[23] | 350 | * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor |
---|
[1] | 351 | * in a remote cluster. |
---|
| 352 | *********************************************************************************** |
---|
| 353 | * @ cxy : server cluster identifier |
---|
| 354 | * @ dentry : [in] local pointer on dentry. |
---|
| 355 | **********************************************************************************/ |
---|
| 356 | void rpc_vfs_dentry_destroy_client( cxy_t cxy, |
---|
| 357 | struct vfs_dentry_s * dentry ); |
---|
| 358 | |
---|
| 359 | void rpc_vfs_dentry_destroy_server( xptr_t xp ); |
---|
| 360 | |
---|
[23] | 361 | /*********************************************************************************** |
---|
| 362 | * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster. |
---|
| 363 | * It returns an extended pointer on the created file structure. |
---|
| 364 | *********************************************************************************** |
---|
| 365 | * @ cxy : server cluster identifier |
---|
| 366 | * @ inode : [in] local pointer on parent inode. |
---|
| 367 | * @ file_attr : [in] new file attributes. |
---|
| 368 | * @ file_xp : [out] buffer for extended pointer on created file. |
---|
| 369 | * @ error : [out] error status (0 if success). |
---|
| 370 | **********************************************************************************/ |
---|
| 371 | void rpc_vfs_file_create_client( cxy_t cxy, |
---|
| 372 | struct vfs_inode_s * inode, |
---|
| 373 | uint32_t file_attr, |
---|
| 374 | xptr_t * file_xp, |
---|
| 375 | error_t * error ); |
---|
[1] | 376 | |
---|
[23] | 377 | void rpc_vfs_file_create_server( xptr_t xp ); |
---|
[1] | 378 | |
---|
[23] | 379 | /*********************************************************************************** |
---|
| 380 | * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor |
---|
| 381 | * in a remote cluster. |
---|
| 382 | *********************************************************************************** |
---|
| 383 | * @ cxy : server cluster identifier |
---|
| 384 | * @ file : [in] local pointer on file. |
---|
| 385 | **********************************************************************************/ |
---|
| 386 | void rpc_vfs_file_destroy_client( cxy_t cxy, |
---|
| 387 | struct vfs_file_s * file ); |
---|
[1] | 388 | |
---|
[23] | 389 | void rpc_vfs_file_destroy_server( xptr_t xp ); |
---|
| 390 | |
---|
[238] | 391 | /*********************************************************************************** |
---|
| 392 | * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a |
---|
| 393 | * remote cluster containing a parent inode directory to scan the associated |
---|
| 394 | * mapper, find a directory entry, identified by its name, and update the remote |
---|
| 395 | * child inode. |
---|
| 396 | *********************************************************************************** |
---|
| 397 | * @ cxy : server cluster identifier |
---|
| 398 | * @ parent_inode : [in] local pointer on parent inode. |
---|
| 399 | * @ name : [in] local pointer on child name (in client cluster). |
---|
| 400 | * @ child_inode_xp : [in] extended pointer on child inode (in another cluster). |
---|
| 401 | * @ error : [out] error status (0 if success). |
---|
| 402 | **********************************************************************************/ |
---|
| 403 | void rpc_vfs_inode_load_client( cxy_t cxy, |
---|
| 404 | struct vfs_inode_s * parent_inode, |
---|
| 405 | char * name, |
---|
| 406 | xptr_t child_inode_xp, |
---|
| 407 | error_t * error ); |
---|
| 408 | |
---|
| 409 | void rpc_vfs_inode_load_server( xptr_t xp ); |
---|
| 410 | |
---|
| 411 | /*********************************************************************************** |
---|
| 412 | * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function |
---|
| 413 | * in a remote cluster containing an inode, to load all pages of the associated |
---|
| 414 | * mapper from the file system on device. |
---|
| 415 | *********************************************************************************** |
---|
| 416 | * @ cxy : server cluster identifier |
---|
| 417 | * @ inode : [in] local pointer on inode in server cluster. |
---|
| 418 | * @ error : [out] error status (0 if success). |
---|
| 419 | **********************************************************************************/ |
---|
| 420 | void rpc_vfs_mapper_load_all_client( cxy_t cxy, |
---|
| 421 | struct vfs_inode_s * inode, |
---|
| 422 | error_t * error ); |
---|
| 423 | |
---|
| 424 | void rpc_vfs_mapper_load_all_server( xptr_t xp ); |
---|
| 425 | |
---|
[1] | 426 | /*********************************************************************************** |
---|
[238] | 427 | * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" |
---|
[23] | 428 | * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get |
---|
| 429 | * from the mapper the local pointer on a given page. |
---|
| 430 | *********************************************************************************** |
---|
| 431 | * @ cxy : server cluster identifier. |
---|
| 432 | * @ mapper : [in] local pointer on FAT mapper. |
---|
| 433 | * @ first : [in] FATFS cluster index allocated to first page of file. |
---|
| 434 | * @ page : [in] page index in file. |
---|
| 435 | * @ cluster : [out] local pointer on buffer for found FATFS cluster index. |
---|
| 436 | * @ error : [out] local pointer on buffer for error code (in client cluster). |
---|
| 437 | **********************************************************************************/ |
---|
| 438 | void rpc_fatfs_get_cluster_client( cxy_t cxy, |
---|
| 439 | struct mapper_s * mapper, |
---|
| 440 | uint32_t first, |
---|
| 441 | uint32_t page, |
---|
| 442 | uint32_t * cluster, |
---|
| 443 | error_t * error ); |
---|
| 444 | |
---|
| 445 | void rpc_fatfs_get_cluster_server( xptr_t xp ); |
---|
| 446 | |
---|
| 447 | /*********************************************************************************** |
---|
[389] | 448 | * [20] The RPC_VMM_GET_VSEG returns an extended pointer |
---|
[1] | 449 | * on the vseg containing a given virtual address in a given process. |
---|
| 450 | * The server cluster is supposed to be the reference cluster. |
---|
[389] | 451 | * It returns a non zero error value if no vseg has been founded. |
---|
[1] | 452 | *********************************************************************************** |
---|
| 453 | * @ cxy : server cluster identifier. |
---|
| 454 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
| 455 | * @ vaddr : [in] virtual address to be searched. |
---|
[16] | 456 | * @ vseg_xp : [out] buffer for extended pointer on vseg in client cluster. |
---|
[389] | 457 | * @ error : [out] local pointer on buffer for error code (in client cluster). |
---|
[1] | 458 | **********************************************************************************/ |
---|
[389] | 459 | void rpc_vmm_get_vseg_client( cxy_t cxy, |
---|
| 460 | struct process_s * process, |
---|
| 461 | intptr_t vaddr, |
---|
| 462 | xptr_t * vseg_xp, |
---|
[401] | 463 | error_t * error ); |
---|
[1] | 464 | |
---|
[389] | 465 | void rpc_vmm_get_vseg_server( xptr_t xp ); |
---|
[1] | 466 | |
---|
| 467 | /*********************************************************************************** |
---|
[407] | 468 | * [21] The RPC_VMM_GET_PTE returns in the <ppn> and <attr> arguments the PTE value |
---|
| 469 | * for a given <vpn> in a given <process> (page_fault or copy_on_write event). |
---|
[1] | 470 | * The server cluster is supposed to be the reference cluster, and the vseg |
---|
| 471 | * containing the VPN must be registered in the reference VMM. |
---|
[407] | 472 | * It returns an error if physical memory cannot be allocated for the missing PTE2, |
---|
[1] | 473 | * or for the missing page itself. |
---|
| 474 | *********************************************************************************** |
---|
| 475 | * @ cxy : server cluster identifier. |
---|
| 476 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
| 477 | * @ vaddr : [in] virtual address to be searched. |
---|
[407] | 478 | * @ cow : [in] "copy_on_write" event if true / "page_fault" event if false. |
---|
[1] | 479 | * @ attr : [out] address of buffer for attributes. |
---|
| 480 | * @ ppn : [out] address of buffer for PPN. |
---|
| 481 | * @ error : [out] address of buffer for error code. |
---|
| 482 | **********************************************************************************/ |
---|
| 483 | void rpc_vmm_get_pte_client( cxy_t cxy, |
---|
| 484 | struct process_s * process, |
---|
| 485 | vpn_t vpn, |
---|
[407] | 486 | bool_t cow, |
---|
[1] | 487 | uint32_t * attr, |
---|
| 488 | ppn_t * ppn, |
---|
| 489 | error_t * error ); |
---|
| 490 | |
---|
| 491 | void rpc_vmm_get_pte_server( xptr_t xp ); |
---|
| 492 | |
---|
| 493 | /*********************************************************************************** |
---|
[23] | 494 | * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster, |
---|
| 495 | * and returns an extended pointer on the allocated object. |
---|
| 496 | It returns XPTR_NULL if physical memory cannot be allocated. |
---|
[1] | 497 | *********************************************************************************** |
---|
[23] | 498 | * @ cxy : server cluster identifier. |
---|
| 499 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
| 500 | * @ buf_xp : [out] buffer for extended pointer on allocated buffer. |
---|
[1] | 501 | **********************************************************************************/ |
---|
[23] | 502 | void rpc_kcm_alloc_client( cxy_t cxy, |
---|
| 503 | uint32_t kmem_type, |
---|
| 504 | xptr_t * buf_xp ); |
---|
[1] | 505 | |
---|
[23] | 506 | void rpc_kcm_alloc_server( xptr_t xp ); |
---|
[1] | 507 | |
---|
| 508 | /*********************************************************************************** |
---|
[23] | 509 | * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type, |
---|
[1] | 510 | * in a remote cluster. |
---|
| 511 | *********************************************************************************** |
---|
[23] | 512 | * @ cxy : server cluster identifier. |
---|
| 513 | * @ buf : [in] local pointer on allocated buffer. |
---|
| 514 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
[1] | 515 | **********************************************************************************/ |
---|
[23] | 516 | void rpc_kcm_free_client( cxy_t cxy, |
---|
| 517 | void * buf, |
---|
| 518 | uint32_t kmem_type ); |
---|
[1] | 519 | |
---|
[23] | 520 | void rpc_kcm_free_server( xptr_t xp ); |
---|
[1] | 521 | |
---|
| 522 | /*********************************************************************************** |
---|
[313] | 523 | * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote |
---|
| 524 | * mapper to move data to/from a kernel or user buffer. |
---|
| 525 | * - It calls the mapper_move_user() function for a - possibly distributed - |
---|
| 526 | * user buffer identified by a user-space pointer, and casted to uint64_t. |
---|
| 527 | * - It calls the mapper_move_kernel() function for a - possibly remote - |
---|
| 528 | * kernel buffer identified by an extended pointer, and casted to uint64_t. |
---|
| 529 | * It is used by the vfs_move_user() function to move data between a mapper |
---|
| 530 | * and an user buffer required by a sys_read() or a sys_write(). |
---|
| 531 | * It is used by the vmm_get_one_ppn() function to initialise a physical page |
---|
| 532 | * from a .elf file mapper, for a CODE or DATA vseg page fault. |
---|
[1] | 533 | *********************************************************************************** |
---|
[23] | 534 | * @ cxy : server cluster identifier. |
---|
| 535 | * @ mapper : [in] local pointer on mapper |
---|
[313] | 536 | * @ to_buffer : [in] move data from mapper to buffer if non zero. |
---|
| 537 | * @ is_user : [in] buffer in user space if true |
---|
[23] | 538 | * @ file_offset : [in] first byte to move in mapper |
---|
[313] | 539 | * @ buffer : [in] user space pointer / kernel extended pointer |
---|
[23] | 540 | * @ size : [in] number of bytes to move |
---|
| 541 | * @ error : [out] error status (0 if success). |
---|
[1] | 542 | **********************************************************************************/ |
---|
[265] | 543 | void rpc_mapper_move_buffer_client( cxy_t cxy, |
---|
| 544 | struct mapper_s * mapper, |
---|
| 545 | bool_t to_buffer, |
---|
| 546 | bool_t is_user, |
---|
| 547 | uint32_t file_offset, |
---|
[313] | 548 | uint64_t buffer, |
---|
[265] | 549 | uint32_t size, |
---|
| 550 | error_t * error ); |
---|
[1] | 551 | |
---|
[265] | 552 | void rpc_mapper_move_buffer_server( xptr_t xp ); |
---|
[1] | 553 | |
---|
[313] | 554 | /*********************************************************************************** |
---|
| 555 | * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer |
---|
| 556 | * on a remote page descriptor, for a page, identified by the page index in mapper. |
---|
| 557 | * It is used by the vmm_get_one_ppn() function to handle a page fault on |
---|
| 558 | * a FILE type vseg. |
---|
| 559 | *********************************************************************************** |
---|
| 560 | * @ cxy : server cluster identifier. |
---|
| 561 | * @ mapper : [in] local pointer on mapper. |
---|
| 562 | * @ index : [in] page index in mapper. |
---|
| 563 | * @ page : [out] local pointer on page descriptor / NULL if failure. |
---|
| 564 | **********************************************************************************/ |
---|
| 565 | void rpc_mapper_get_page_client( cxy_t cxy, |
---|
| 566 | struct mapper_s * mapper, |
---|
| 567 | uint32_t index, |
---|
| 568 | struct page_s ** page ); |
---|
[1] | 569 | |
---|
[313] | 570 | void rpc_mapper_get_page_server( xptr_t xp ); |
---|
[1] | 571 | |
---|
[407] | 572 | /*********************************************************************************** |
---|
| 573 | * [26] The RPC_VMM_CREATE_VSEG allows a client thread to request the remote |
---|
| 574 | * reference cluster of a given process to allocate and register in the reference |
---|
| 575 | * process VMM a new vseg descriptor. |
---|
| 576 | * On the server side, this RPC uses the vmm_create_vseg() function, and returns |
---|
| 577 | * to the client the local pointer on the created vseg descriptor. |
---|
| 578 | *********************************************************************************** |
---|
| 579 | * @ cxy : server cluster identifier. |
---|
| 580 | * @ process : [in] local pointer on process descriptor in server. |
---|
| 581 | * @ type : [in] vseg type. |
---|
| 582 | * @ base : [in] base address (unused for dynamically allocated vsegs). |
---|
| 583 | * @ size : [in] number of bytes. |
---|
| 584 | * @ file_offset : [in] offset in file (for CODE, DATA, FILE types). |
---|
| 585 | * @ file_size : [in] can be smaller than size for DATA type. |
---|
| 586 | * @ mapper_xp : [in] extended pointer on mapper (for CODE, DATA, FILE types). |
---|
| 587 | * @ vseg_cxy : [in] target cluster for mapping (if not data type). |
---|
| 588 | * @ vseg : [out] local pointer on vseg descriptor / NULL if failure. |
---|
| 589 | **********************************************************************************/ |
---|
| 590 | void rpc_vmm_create_vseg_client( cxy_t cxy, |
---|
| 591 | struct process_s * process, |
---|
| 592 | vseg_type_t type, |
---|
| 593 | intptr_t base, |
---|
| 594 | uint32_t size, |
---|
| 595 | uint32_t file_offset, |
---|
| 596 | uint32_t file_size, |
---|
| 597 | xptr_t mapper_xp, |
---|
| 598 | cxy_t vseg_cxy, |
---|
| 599 | struct vseg_s ** vseg ); |
---|
| 600 | |
---|
| 601 | void rpc_vmm_create_vseg_server( xptr_t xp ); |
---|
| 602 | |
---|
| 603 | /*********************************************************************************** |
---|
| 604 | * [27] The RPC_SCHED_DISPLAY allows a client thread to request the display |
---|
| 605 | * of a remote scheduler, identified by the <lid> argument. |
---|
| 606 | *********************************************************************************** |
---|
| 607 | * @ cxy : server cluster identifier. |
---|
| 608 | * @ lid : [in] local index of target core in client cluster. |
---|
| 609 | **********************************************************************************/ |
---|
| 610 | void rpc_sched_display_client( cxy_t cxy, |
---|
| 611 | lid_t lid ); |
---|
| 612 | |
---|
| 613 | void rpc_sched_display_server( xptr_t xp ); |
---|
| 614 | |
---|
[1] | 615 | #endif |
---|