Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 637)
+++ trunk/kernel/kern/rpc.c	(revision 640)
@@ -73,11 +73,11 @@
     &rpc_vfs_inode_load_all_pages_server,  // 19 
 
-    &rpc_vmm_get_vseg_server,              // 20
-    &rpc_vmm_global_update_pte_server,     // 21
+    &rpc_undefined,                        // 20
+    &rpc_undefined,                        // 21
     &rpc_undefined,                        // 22
     &rpc_undefined,                        // 23
     &rpc_mapper_sync_server,               // 24
-    &rpc_undefined,                        // 25
-    &rpc_vmm_delete_vseg_server,           // 26 
+    &rpc_vmm_resize_vseg_server,           // 25
+    &rpc_vmm_remove_vseg_server,           // 26 
     &rpc_vmm_create_vseg_server,           // 27
     &rpc_vmm_set_cow_server,               // 28
@@ -109,11 +109,11 @@
     "VFS_INODE_LOAD_ALL_PAGES",  // 19
 
-    "GET_VSEG",                  // 20
-    "GLOBAL_UPDATE_PTE",         // 21
+    "VMM_GLOBAL_RESIZE_VSEG",    // 20
+    "VMM_GLOBAL_UPDATE_PTE",     // 21
     "undefined_22",              // 22
     "undefined_23",              // 23
     "MAPPER_SYNC",               // 24
     "undefined_25",              // 25
-    "VMM_DELETE_VSEG",           // 26
+    "VMM_REMOVE_VSEG",           // 26
     "VMM_CREATE_VSEG",           // 27
     "VMM_SET_COW",               // 28
@@ -1072,5 +1072,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [8]   Marshaling functions attached to RPC_VRS_FS_UPDATE_DENTRY
+// [8]   Marshaling functions attached to RPC_VFS_FS_UPDATE_DENTRY
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -2059,7 +2059,8 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [20]          Marshaling functions attached to RPC_VMM_GET_VSEG 
-/////////////////////////////////////////////////////////////////////////////////////////
-
+// [20]          RPC_VMM_GET_VSEG deprecated [AG] sept 2019
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/*
 //////////////////////////////////////////////////
 void rpc_vmm_get_vseg_client( cxy_t       cxy,      
@@ -2144,89 +2145,12 @@
 #endif
 }
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// [21]    Marshaling functions attached to RPC_VMM_GLOBAL_UPDATE_PTE 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////
-void rpc_vmm_global_update_pte_client( cxy_t       cxy,   
-                                       process_t * process,  // in 
-                                       vpn_t       vpn,      // in 
-                                       uint32_t    attr,     // in
-                                       ppn_t       ppn )     // in
-{
-#if DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE
-thread_t * this = CURRENT_THREAD;
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-
-    uint32_t responses = 1;
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_VMM_GLOBAL_UPDATE_PTE;
-    rpc.blocking = true;
-    rpc.rsp      = &responses;
-
-    // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)process;
-    rpc.args[1] = (uint64_t)vpn;
-    rpc.args[2] = (uint64_t)attr;
-    rpc.args[3] = (uint64_t)ppn;
-
-    // register RPC request in remote RPC fifo
-    rpc_send( cxy , &rpc );
-
-#if DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
-
-//////////////////////////////////////////////////
-void rpc_vmm_global_update_pte_server( xptr_t xp )
-{
-#if DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE
-thread_t * this = CURRENT_THREAD;
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-
-    process_t   * process;
-    vpn_t         vpn;
-    uint32_t      attr;
-    ppn_t         ppn;
-
-    // get client cluster identifier and pointer on RPC descriptor
-    cxy_t        client_cxy  = GET_CXY( xp );
-    rpc_desc_t * desc        = GET_PTR( xp );
-
-    // get input argument "process" & "vpn" from client RPC descriptor
-    process = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    vpn     = (vpn_t)                hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-    attr    = (uint32_t)             hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
-    ppn     = (ppn_t)                hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
-    
-    // call local kernel function
-    vmm_global_update_pte( process , vpn , attr , ppn ); 
-
-#if DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_GLOBAL_UPDATE_PTE )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// [22]          Marshaling functions attached to RPC_KCM_ALLOC 
+*/
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [21]    undefined
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [22]          RPC_KCM_ALLOC deprecated [AG] sept 2019
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -2308,5 +2232,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [23]          Marshaling functions attached to RPC_KCM_FREE 
+// [23]          RPC_KCM_FREE deprecated [AG] sept 2019
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -2460,19 +2384,18 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [25]          Marshaling functions attached to RPC_MAPPER_HANDLE_MISS 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-/*
+// [25]          Marshaling functions attached to RPC_VMM_RESIZE_VSEG 
+/////////////////////////////////////////////////////////////////////////////////////////
+
 //////////////////////////////////////////////////////////
-void rpc_mapper_handle_miss_client( cxy_t             cxy,
-                                    struct mapper_s * mapper,
-                                    uint32_t          page_id,
-                                    xptr_t          * page_xp,
-                                    error_t         * error )
-{
-#if DEBUG_RPC_MAPPER_HANDLE_MISS
-thread_t * this = CURRENT_THREAD;
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_HANDLE_MISS )
+void rpc_vmm_resize_vseg_client( cxy_t             cxy,
+                                 struct process_s * process,
+                                 struct vseg_s    * vseg,
+                                 intptr_t           new_base,
+                                 intptr_t           new_size )
+{
+#if DEBUG_RPC_VMM_RESIZE_VSEG
+thread_t * this = CURRENT_THREAD;
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
@@ -2483,42 +2406,40 @@
     // initialise RPC descriptor header 
     rpc_desc_t  rpc;
-    rpc.index    = RPC_MAPPER_HANDLE_MISS;
+    rpc.index    = RPC_VMM_RESIZE_VSEG;
     rpc.blocking = true;
     rpc.rsp      = &responses;
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)mapper;
-    rpc.args[1] = (uint64_t)page_id;
+    rpc.args[0] = (uint64_t)(intptr_t)process;
+    rpc.args[1] = (uint64_t)(intptr_t)vseg;
+    rpc.args[2] = (uint64_t)new_base;
+    rpc.args[3] = (uint64_t)new_size;
 
     // register RPC request in remote RPC fifo
     rpc_send( cxy , &rpc );
 
-    // get output values from RPC descriptor
-    *page_xp = (xptr_t)rpc.args[2];
-    *error   = (error_t)rpc.args[3];
-
-#if DEBUG_RPC_MAPPER_HANDLE_MISS
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_HANDLE_MISS )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
-
-///////////////////////////////////////////////
-void rpc_mapper_handle_miss_server( xptr_t xp )
-{
-#if DEBUG_RPC_MAPPER_HANDLE_MISS
-thread_t * this = CURRENT_THREAD;
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_HANDLE_MISS )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-
-    mapper_t * mapper;
-    uint32_t   page_id;
-    xptr_t     page_xp;
-    error_t    error;
+#if DEBUG_RPC_VMM_RESIZE_VSEG
+cycle = (uint32_t)hal_get_cycles();
+if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
+printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
+#endif
+}
+
+////////////////////////////////////////////
+void rpc_vmm_resize_vseg_server( xptr_t xp )
+{
+#if DEBUG_RPC_VMM_RESIZE_VSEG
+thread_t * this = CURRENT_THREAD;
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
+printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
+#endif
+
+    process_t * process;
+    vseg_t    * vseg;
+    intptr_t    new_base;
+    intptr_t    new_size;
 
     // get client cluster identifier and pointer on RPC descriptor
@@ -2527,38 +2448,37 @@
 
     // get arguments from client RPC descriptor
-    mapper  = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    page_id =                       hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-
-    // call local kernel function
-    error = mapper_handle_miss( mapper,
-                                page_id,
-                                &page_xp );
-
-    // set output argument to client RPC descriptor
-    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)page_xp );
-    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
-
-#if DEBUG_RPC_MAPPER_HANDLE_MISS
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_HANDLE_MISS )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
-*/
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// [26]  Marshaling functions attached to RPC_VMM_DELETE_VSEG 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////
-void rpc_vmm_delete_vseg_client( cxy_t        cxy,
-                                 pid_t        pid,
-                                 intptr_t     vaddr )
-{
-#if DEBUG_RPC_VMM_DELETE_VSEG
+    process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
+    new_base =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
+    new_size =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
+
+    // call relevant kernel function
+    vmm_resize_vseg( process,
+                     vseg,
+                     new_base,
+                     new_size );
+
+#if DEBUG_RPC_VMM_RESIZE_VSEG
+cycle = (uint32_t)hal_get_cycles();
+if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
+printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
+#endif
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [26]  Marshaling functions attached to RPC_VMM_REMOVE_VSEG 
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////
+void rpc_vmm_remove_vseg_client( cxy_t       cxy,
+                                 process_t * process,
+                                 vseg_t    * vseg )
+{
+#if DEBUG_RPC_VMM_REMOVE_VSEG
 thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_DELETE_VSEG )
+if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG )
 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
@@ -2569,18 +2489,18 @@
 
     // initialise RPC descriptor header 
-    rpc.index    = RPC_VMM_DELETE_VSEG;
+    rpc.index    = RPC_VMM_REMOVE_VSEG;
     rpc.blocking = true;
     rpc.rsp      = &responses;
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)pid;
-    rpc.args[1] = (uint64_t)vaddr;
+    rpc.args[0] = (uint64_t)(intptr_t)process;
+    rpc.args[1] = (uint64_t)(intptr_t)vseg;
 
     // register RPC request in remote RPC fifo
     rpc_send( cxy , &rpc );
 
-#if DEBUG_RPC_VMM_DELETE_VSEG
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_VMM_DELETE_VSEG )
+#if DEBUG_RPC_VMM_REMOVE_VSEG
+cycle = (uint32_t)hal_get_cycles();
+if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG )
 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
@@ -2589,13 +2509,16 @@
 
 ////////////////////////////////////////////
-void rpc_vmm_delete_vseg_server( xptr_t xp )
-{
-#if DEBUG_RPC_VMM_DELETE_VSEG
-uint32_t cycle = (uint32_t)hal_get_cycles();
-thread_t * this = CURRENT_THREAD;
-if( DEBUG_RPC_VMM_DELETE_VSEG < cycle )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
-#endif
+void rpc_vmm_remove_vseg_server( xptr_t xp )
+{
+#if DEBUG_RPC_VMM_REMOVE_VSEG
+uint32_t cycle = (uint32_t)hal_get_cycles();
+thread_t * this = CURRENT_THREAD;
+if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle )
+printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
+#endif
+
+    process_t * process;
+    vseg_t    * vseg;
 
     // get client cluster identifier and pointer on RPC descriptor
@@ -2604,13 +2527,14 @@
 
     // get arguments from RPC descriptor
-    pid_t    pid   = (pid_t)   hal_remote_l64( XPTR(client_cxy , &desc->args[0]) );
-    intptr_t vaddr = (intptr_t)hal_remote_l64( XPTR(client_cxy , &desc->args[1]) );
+    process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
 
     // call relevant kernel function
-    vmm_delete_vseg( pid , vaddr );
-
-#if DEBUG_RPC_VMM_DELETE_VSEG
-cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_RPC_VMM_DELETE_VSEG < cycle )
+    vmm_remove_vseg( process,
+                     vseg );
+
+#if DEBUG_RPC_VMM_REMOVE_VSEG
+cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle )
 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
