Ignore:
Timestamp:
Oct 10, 2020, 5:11:27 PM (4 years ago)
Author:
alain
Message:
  • Introduce the sys_socket.c file implementing all socket related syscalls.
  • Improve the non-standard sys_get_config() function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_get_config.c

    r637 r664  
    22 * sys_get_config.c - get hardware platform parameters.
    33 *
    4  * Author    Alain Greiner (2016,2017,2018,2019)
     4 * Author    Alain Greiner (2016,2017,2018,2019,2020)
    55 * 
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3434
    3535#include <syscalls.h>
     36#include <shared_syscalls.h>
    3637
    37 //////////////////////////////////////
    38 int sys_get_config( uint32_t * x_size,
    39                     uint32_t * y_size,
    40                     uint32_t * ncores )
     38//////////////////////////////////////////////
     39int sys_get_config( hard_config_t * u_config )
    4140{
    42         error_t    error;
    43     vseg_t   * vseg;
    44     uint32_t   k_x_size;
    45     uint32_t   k_y_size;
    46     uint32_t   k_ncores;
     41    vseg_t        * vseg;       
     42    hard_config_t   k_config;    // hard_config structure in kernel space
    4743
    4844    thread_t  * this    = CURRENT_THREAD;
     
    6056#endif
    6157
    62     // check x_size buffer in user space
    63     error = vmm_get_vseg( process , (intptr_t)x_size  , &vseg );
    64 
    65         if( error )
     58    // check u_config mapped in user space
     59    if( vmm_get_vseg( process , (intptr_t)u_config  , &vseg ) )
    6660        {
    6761
    6862#if DEBUG_SYSCALLS_ERROR
    69 printk("\n[ERROR] in %s : x_size buffer unmapped / thread %x / process %x\n",
    70 __FUNCTION__ , (intptr_t)x_size , this->trdid , process->pid );
     63printk("\n[ERROR] in %s : config pointer %x unmapped / thread %x / process %x\n",
     64__FUNCTION__ , (intptr_t)u_config , this->trdid , process->pid );
    7165#endif
    7266        this->errno = EINVAL;
     
    7468        }
    7569
    76     // check y_size buffer in user space
    77     error = vmm_get_vseg( process , (intptr_t)y_size  , &vseg );
     70    // copy config parameters from cluster descriptor to kernel structure
     71        k_config.x_size       = LOCAL_CLUSTER->x_size;
     72        k_config.y_size       = LOCAL_CLUSTER->y_size;
     73        k_config.ncores       = LOCAL_CLUSTER->cores_nr;
     74    k_config.txt_channels = LOCAL_CLUSTER->nb_txt_channels;
     75    k_config.nic_channels = LOCAL_CLUSTER->nb_nic_channels;
     76    k_config.ioc_channels = LOCAL_CLUSTER->nb_ioc_channels;
     77    k_config.fbf_channels = LOCAL_CLUSTER->nb_fbf_channels;
    7878
    79         if( error )
    80         {
    81 
    82 #if DEBUG_SYSCALLS_ERROR
    83 printk("\n[ERROR] in %s : y_size buffer unmapped / thread %x / process %x\n",
    84 __FUNCTION__ , (intptr_t)y_size , this->trdid , process->pid );
    85 #endif
    86         this->errno = EINVAL;
    87                 return -1;
    88         }
    89 
    90     // check ncores buffer in user space
    91     error = vmm_get_vseg( process , (intptr_t)ncores  , &vseg );
    92 
    93         if( error )
    94         {
    95 
    96 #if DEBUG_SYSCALLS_ERROR
    97 printk("\n[ERROR] in %s : ncores buffer unmapped / thread %x / process %x\n",
    98 __FUNCTION__ , (intptr_t)ncores , this->trdid , process->pid );
    99 #endif
    100         this->errno = EINVAL;
    101                 return -1;
    102         }
    103 
    104     // get parameters
    105         k_x_size  = LOCAL_CLUSTER->x_size;
    106         k_y_size  = LOCAL_CLUSTER->y_size;
    107         k_ncores  = LOCAL_CLUSTER->cores_nr;
    108 
    109     // copy to user space
    110         hal_copy_to_uspace( x_size, XPTR( local_cxy , &k_x_size ), sizeof(uint32_t) );
    111         hal_copy_to_uspace( y_size, XPTR( local_cxy , &k_y_size ), sizeof(uint32_t) );
    112         hal_copy_to_uspace( ncores, XPTR( local_cxy , &k_ncores ), sizeof(uint32_t) );
     79    // copy k_config structure to user space
     80        hal_copy_to_uspace( u_config , XPTR(local_cxy, &k_config ), sizeof(hard_config_t) );
    11381
    11482    hal_fence();
Note: See TracChangeset for help on using the changeset viewer.