source: trunk/kernel/syscalls/sys_get_config.c @ 429

Last change on this file since 429 was 421, checked in by alain, 7 years ago

Introduce sys_fg() , sys_display() , sys_wait() syscalls.

File size: 2.4 KB
RevLine 
[410]1/*
2 * sys_get_config.c - get hardware platform parameters.
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_uspace.h>
26#include <hal_special.h>
27#include <errno.h>
28#include <core.h>
29#include <thread.h>
30#include <process.h>
31#include <vmm.h>
32#include <printk.h>
33
34//////////////////////////////////////
35int sys_get_config( uint32_t * x_size,
36                    uint32_t * y_size,
[421]37                    uint32_t * y_width,
[410]38                    uint32_t * ncores )
39{
40    paddr_t   paddr;
41    uint32_t  k_x_size;
42    uint32_t  k_y_size;
[421]43    uint32_t  k_y_width;
[410]44    uint32_t  k_ncores;
45
46        error_t   error = 0;
47
48    thread_t  * this    = CURRENT_THREAD;
49    process_t * process = this->process;
50
51    // check buffer in user space
[421]52    error |= vmm_v2p_translate( false , x_size  , &paddr );
53    error |= vmm_v2p_translate( false , y_size  , &paddr );
54    error |= vmm_v2p_translate( false , y_width , &paddr );
55    error |= vmm_v2p_translate( false , ncores  , &paddr );
[410]56
57        if( error )
58        {
59        printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n",
60               __FUNCTION__ , this->trdid , process->pid );
61        this->errno = EFAULT;
62                return -1;
63        }
64
65    // get parameters
[421]66        k_x_size  = LOCAL_CLUSTER->x_size;
67        k_y_size  = LOCAL_CLUSTER->y_size;
68        k_y_width = LOCAL_CLUSTER->y_width;
69        k_ncores  = LOCAL_CLUSTER->cores_nr;
[410]70
71    // copy to user space
[421]72        hal_copy_to_uspace( x_size  , &k_x_size  , sizeof(uint32_t) );
73        hal_copy_to_uspace( y_size  , &k_y_size  , sizeof(uint32_t) );
74        hal_copy_to_uspace( y_width , &k_y_width , sizeof(uint32_t) );
75        hal_copy_to_uspace( ncores  , &k_ncores  , sizeof(uint32_t) );
[410]76
77        return 0; 
78
79}  // end sys_get_config()
Note: See TracBrowser for help on using the repository browser.