Ignore:
Timestamp:
Mar 6, 2019, 4:37:15 PM (5 years ago)
Author:
alain
Message:

Introduce three new types of vsegs (KCODE,KDATA,KDEV)
to map the kernel vsegs in the process VSL and GPT.
This now used by both the TSAR and the I86 architectures.

File:
1 edited

Legend:

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

    r506 r623  
    2525#include <hal_kernel_types.h>
    2626#include <hal_uspace.h>
     27#include <hal_irqmask.h>
    2728#include <shared_syscalls.h>
    2829#include <errno.h>
     
    4142{
    4243    error_t       error;
     44    vseg_t      * vseg;
     45    reg_t         save_sr;      // required to enable IRQs
    4346
    4447        thread_t    * this    = CURRENT_THREAD;
    4548        process_t   * process = this->process;
    4649
     50#if (DEBUG_SYS_MUNMAP || CONFIG_INSTRUMENTATION_SYSCALLS)
     51uint64_t     tm_start = hal_get_cycles();
     52#endif
     53
    4754#if DEBUG_SYS_MUNMAP
    48 uint64_t tm_start;
    49 uint64_t tm_end;
    50 tm_start = hal_get_cycles();
    5155if( DEBUG_SYS_MUNMAP < tm_start )
    52 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n"
     56printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
    5357__FUNCTION__ , this, process->pid, (uint32_t)tm_start );
    5458#endif
     59
     60    // check user buffer is mapped
     61    error = vmm_get_vseg( process , (intptr_t)vaddr, &vseg );
     62
     63    if( error )
     64    {
     65
     66#if DEBUG_SYSCALLS_ERROR
     67printk("\n[ERROR] in %s : thread[%x,%x] / user buffer unmapped %x\n",
     68__FUNCTION__ , process->pid, this->trdid, (intptr_t)vaddr );
     69vmm_display( process , false );
     70#endif
     71                this->errno = EINVAL;
     72                return -1;
     73    }
     74
     75    // enable IRQs
     76    hal_enable_irq( &save_sr );
    5577
    5678    // call relevant kernel function
     
    6789    }
    6890
     91    // restore IRQs
     92    hal_restore_irq( save_sr );
     93
     94#if (DEBUG_SYS_MUNMAP || CONFIG_INSTRUMENTATION_SYSCALLS)
     95uint64_t     tm_end = hal_get_cycles();
     96#endif
     97
     98#if CONFIG_INSTRUMENTATION_SYSCALLS
     99hal_atomic_add( &syscalls_cumul_cost[SYS_MUNMAP] , tm_end - tm_start );
     100hal_atomic_add( &syscalls_occurences[SYS_MUNMAP] , 1 );
     101#endif
     102
    69103#if DEBUG_SYS_MUNMAP
    70 tm_end = hal_get_cycles();
    71104if( DEBUG_SYS_MUNMAP < tm_start )
    72 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
     105printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n",
    73106__FUNCTION__ , this, process->pid, (uint32_t)tm_end );
    74107#endif
Note: See TracChangeset for help on using the changeset viewer.