source: trunk/hal/tsar_mips32/core/hal_syscall.c @ 657

Last change on this file since 657 was 625, checked in by alain, 6 years ago

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File size: 2.2 KB
Line 
1/*
2 * hal_syscall.c - Implementation of syscall handler for TSAR-MIPS32.
3 *
4 * Author    Alain Greiner (2016,2017)
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#include <hal_kernel_types.h>
25#include <hal_syscall.h>
26#include <do_syscall.h>
27#include <thread.h>
28#include <printk.h>
29#include <hal_kentry.h>
30
31///////////////////////////
32void hal_do_syscall( void )
33{
34    thread_t    * this;
35
36    uint32_t    * enter_uzone;
37    uint32_t    * exit_uzone;
38
39        uint32_t      arg0;
40        uint32_t      arg1;
41        uint32_t      arg2;
42        uint32_t      arg3;
43        uint32_t      service_num;
44        uint32_t      retval;
45 
46    // get pointer on enter_thread uzone
47    this        = CURRENT_THREAD;
48    enter_uzone = (uint32_t *)this->uzone_current;
49
50    // get syscall arguments from uzone
51        service_num = enter_uzone[UZ_V0];
52        arg0        = enter_uzone[UZ_A0];
53        arg1        = enter_uzone[UZ_A1];
54        arg2        = enter_uzone[UZ_A2];
55        arg3        = enter_uzone[UZ_A3];
56 
57    // call architecture independant syscall handler
58        retval = do_syscall( this,
59                         arg0,
60                         arg1,
61                         arg2,
62                         arg3,
63                         service_num );
64
65    // get pointer on exit_thread uzone, because exit thread
66    // can be different from enter_thread for a fork syscall
67    this       = CURRENT_THREAD;
68    exit_uzone = (uint32_t *)this->uzone_current;
69
70    // set return value to uzone
71        exit_uzone[UZ_V0] = retval;
72
73    // update EPC in uzone
74        exit_uzone[UZ_EPC] += 4;
75
76    hal_fence();
77}
Note: See TracBrowser for help on using the repository browser.