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

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

Fix a bug in hal_kentry.S : the "uzone" pointer in the thread descriptor
must not be modified in case of interrupt.

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// @@@
32// __attribute__((section(".kdata"))) uint32_t * enter_uzone;
33// __attribute__((section(".kdata"))) uint32_t * exit_uzone;
34// @@@
35
36/////////////////////
37void hal_do_syscall()
38{
39    thread_t    * this;
40
41    uint32_t    * enter_uzone;
42    uint32_t    * exit_uzone;
43
44        uint32_t      arg0;
45        uint32_t      arg1;
46        uint32_t      arg2;
47        uint32_t      arg3;
48        uint32_t      service_num;
49        uint32_t      retval;
50 
51    // get pointer on enter_thread uzone
52    this        = CURRENT_THREAD;
53    enter_uzone = (uint32_t *)this->uzone;
54
55    // get syscall arguments from uzone
56        service_num = enter_uzone[UZ_V0];
57        arg0        = enter_uzone[UZ_A0];
58        arg1        = enter_uzone[UZ_A1];
59        arg2        = enter_uzone[UZ_A2];
60        arg3        = enter_uzone[UZ_A3];
61 
62    // call architecture independant syscall handler
63        retval = do_syscall( this,
64                         arg0,
65                         arg1,
66                         arg2,
67                         arg3,
68                         service_num );
69
70    // get pointer on exit_thread uzone,
71    // exit_thread can be different from enter_thread
72    this       = CURRENT_THREAD;
73    exit_uzone = (uint32_t *)this->uzone;
74
75// printk("\n@@@ %s exit : enter_uzone = %x / exit_uzone = %x\n",
76// __FUNCTION__ , enter_uzone , exit_uzone );
77
78    // set syscall return value to uzone
79        exit_uzone[UZ_V0] = retval;
80
81    // update EPC in uzone
82        exit_uzone[UZ_EPC] += 4;
83
84    hal_fence();
85}
Note: See TracBrowser for help on using the repository browser.