Ignore:
Timestamp:
Oct 1, 2019, 1:19:00 PM (5 years ago)
Author:
alain
Message:

Remove all RPCs in page-fault handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_munmap.c

    r635 r640  
    7272    }
    7373
     74    // compute unmapped region min an max
     75    intptr_t addr_min = (intptr_t)vaddr;
     76    intptr_t addr_max = addr_min + size;
     77
     78
     79    // get vseg min & max addresses
     80    intptr_t vseg_min = vseg->min;
     81    intptr_t vseg_max = vseg->max;
     82
    7483    // enable IRQs
    7584    hal_enable_irq( &save_sr );
    7685
    77     // call relevant kernel function
    78     error = vmm_resize_vseg( process , (intptr_t)vaddr , (intptr_t)size );
    79 
    80     if ( error )
     86    // action depend on both vseg and region bases & sizes
     87    if( (vseg_min > addr_min) || (vseg_max < addr_max) )   // region not included in vseg
    8188    {
    8289
    8390#if DEBUG_SYSCALLS_ERROR
    84 printk("\n[ERROR] in %s : cannot remove mapping\n", __FUNCTION__ );
     91printk("\n[ERROR] in %s : region[%x->%x] / vseg[%x->%x] => non included in vseg\n",
     92__FUNCTION__, process->pid, this->trdid, addr_min, addr_max, vseg_min, vseg_max );
    8593#endif
    8694                this->errno = EINVAL;
    8795                return -1;
     96    }
     97    else if( (vseg_min == addr_min) && (vseg_min == vseg_max) ) 
     98    {
     99
     100#if( DEBUG_SYS_MUNMAP & 1 )
     101if( DEBUG_SYS_MUNMAP < cycle )
     102printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg deleted\n",
     103__FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     104#endif
     105        // delete existing vseg
     106        vmm_global_delete_vseg( process,
     107                                vseg_min );
     108    }
     109    else if( (vseg_min == addr_min) || (vseg_min == vseg_max) ) 
     110    {
     111
     112#if( DEBUG_SYS_MUNMAP & 1 )
     113if( DEBUG_SYS_MUNMAP < cycle )
     114printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg resized\n",
     115__FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     116#endif
     117        // resize existing vseg
     118        vmm_global_resize_vseg( process,
     119                                vseg_min,
     120                                addr_min,
     121                                addr_max - addr_min );
     122    }
     123    else     //  vseg_min < addr_min) && (addr_max < vseg_max)         
     124    {
     125
     126#if( DEBUG_SYS_MUNMAP & 1 )
     127if( DEBUG_SYS_MUNMAP < cycle )
     128printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg resized & new vseg created\n",
     129__FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     130#endif
     131        // resize existing vseg
     132        vmm_global_resize_vseg( process,
     133                                vseg_min,
     134                                vseg_min,
     135                                addr_min - vseg_min );
     136
     137        // create new vseg
     138        vmm_create_vseg( process,
     139                         vseg->type,
     140                         addr_max,
     141                         vseg_max - addr_max,
     142                         vseg->file_offset,
     143                         vseg->file_size,
     144                         vseg->mapper_xp,
     145                         vseg->cxy );
    88146    }
    89147
Note: See TracChangeset for help on using the changeset viewer.