Changeset 664 for trunk/kernel/syscalls/sys_get_config.c
- Timestamp:
- Oct 10, 2020, 5:11:27 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_get_config.c
r637 r664 2 2 * sys_get_config.c - get hardware platform parameters. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 34 34 35 35 #include <syscalls.h> 36 #include <shared_syscalls.h> 36 37 37 ////////////////////////////////////// 38 int sys_get_config( uint32_t * x_size, 39 uint32_t * y_size, 40 uint32_t * ncores ) 38 ////////////////////////////////////////////// 39 int sys_get_config( hard_config_t * u_config ) 41 40 { 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 47 43 48 44 thread_t * this = CURRENT_THREAD; … … 60 56 #endif 61 57 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 ) ) 66 60 { 67 61 68 62 #if DEBUG_SYSCALLS_ERROR 69 printk("\n[ERROR] in %s : x_size bufferunmapped / thread %x / process %x\n",70 __FUNCTION__ , (intptr_t) x_size, this->trdid , process->pid );63 printk("\n[ERROR] in %s : config pointer %x unmapped / thread %x / process %x\n", 64 __FUNCTION__ , (intptr_t)u_config , this->trdid , process->pid ); 71 65 #endif 72 66 this->errno = EINVAL; … … 74 68 } 75 69 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; 78 78 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) ); 113 81 114 82 hal_fence();
Note: See TracChangeset
for help on using the changeset viewer.