source: trunk/kernel/syscalls/sys_munmap.c @ 410

Last change on this file since 410 was 410, checked in by alain, 4 years ago

Introduce new syscalls.

File size: 1.9 KB
RevLine 
[410]1/*
2 * sys_munmap.c - unmap a mapping from process virtual address space
3 *
4 * Authors       Ghassan Almaless (2008,2009,2010,2011,2012)
5 *               Alain Greiner (2016,2017)
6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#include <hal_types.h>
26#include <hal_uspace.h>
27#include <shared_syscalls.h>
28#include <errno.h>
29#include <thread.h>
30#include <printk.h>
31#include <mapper.h>
32#include <vfs.h>
33#include <process.h>
34#include <vmm.h>
35
36////////////////////////////////
37int sys_munmap( void     * vaddr,
38                uint32_t   size )
39{
40    error_t       error;
41
42        uint32_t      tm_start;
43        uint32_t      tm_end;
44
45        tm_start = hal_get_cycles();
46
47        thread_t    * this    = CURRENT_THREAD;
48        process_t   * process = this->process;
49
50    // call relevant kernel function
51    error = vmm_resize_vseg( process , (intptr_t)vaddr , (intptr_t)size );
52
53    if ( error )
54    {
55        printk("\n[ERROR] in %s : cannot remove mapping\n", __FUNCTION__ );
56                this->errno = EINVAL;
57                return -1;
58    }
59
60    tm_end = hal_get_cycles();
61
62syscall_dmsg("\n[DBG] %s : core[%x,%d] removed vseg in process %x / cycle %d\n"
63"      base = %x / size = %x / cost = %d\n",
64__FUNCTION__, local_cxy , this->core->lid , process->pid , tm_start ,
65vaddr , size , tm_end - tm_start );
66
67        return 0;
68
69}  // end sys_mmap()
70
Note: See TracBrowser for help on using the repository browser.