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

Last change on this file since 446 was 425, checked in by alain, 7 years ago

bloup

File size: 2.4 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_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()
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//printk("\n@@@ enter %s : thread = %x / enter_uzone = %x / EPC = %x\n",
51//__FUNCTION__ , this , enter_uzone , enter_uzone[UZ_EPC] );
52
53    // get syscall arguments from uzone
54        service_num = enter_uzone[UZ_V0];
55        arg0        = enter_uzone[UZ_A0];
56        arg1        = enter_uzone[UZ_A1];
57        arg2        = enter_uzone[UZ_A2];
58        arg3        = enter_uzone[UZ_A3];
59 
60    // call architecture independant syscall handler
61        retval = do_syscall( this,
62                         arg0,
63                         arg1,
64                         arg2,
65                         arg3,
66                         service_num );
67
68    // get pointer on exit_thread uzone, because
69    // exit_thread can be different from enter_thread
70    this       = CURRENT_THREAD;
71    exit_uzone = (uint32_t *)this->uzone_current;
72
73//printk("\n@@@ exit %s : thread = %x / exit_uzone = %x / EPC = %x\n",
74//__FUNCTION__ , this , exit_uzone , exit_uzone[UZ_EPC] );
75
76    // set return value to uzone
77        exit_uzone[UZ_V0] = retval;
78
79    // update EPC in uzone
80        exit_uzone[UZ_EPC] += 4;
81
82    hal_fence();
83}
Note: See TracBrowser for help on using the repository browser.