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