Changeset 23 for trunk/kernel/syscalls/sys_sem.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_sem.c
r1 r23 2 2 * sys_sem.c - Acces a POSIX unamed semaphore. 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Authors Alain Greiner (2016,2017) 6 5 * 7 * This file is part of ALMOS-kernel.6 * Copyright (c) UPMC Sorbonne Universites 8 7 * 9 * ALMOS-kernel is free software; you can redistribute it and/or modify it 8 * This file is part of ALMOS-MKH. 9 * 10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 22 23 23 24 #include <hal_types.h> 24 #include <hal_uspace. 25 #include <hal_uspace.h> 26 #include <errno.h> 27 #include <thread.h> 28 #include <printk.h> 29 #include <vmm.h> 25 30 #include <remote_sem.h> 31 #include <syscalls.h> 26 32 27 33 ////////////////////////////////// … … 31 37 { 32 38 uint32_t data; 33 error_t error; 39 paddr_t paddr; 40 error_t error; 34 41 35 thread_t * this = CURRENT_THREAD; 36 process_t * process = CURRENT_PROCESS; 42 thread_t * this = CURRENT_THREAD; 37 43 38 44 // check vaddr in user vspace 39 error = vmm_ check_address( process , vaddr , sizeof(unsigned long));40 if( error ) 45 error = vmm_v2p_translate( false , vaddr , &paddr ); 46 if( error ) 41 47 { 48 printk("\n[ERROR] in %s : illegal semaphore virtual address = %x\n", 49 __FUNCTION__ , (intptr_t)vaddr ); 42 50 this->errno = error; 43 51 return -1; … … 45 53 46 54 // check value in user vspace 47 error = vmm_check_address( process , value , sizeof(int*));48 if( error ) 55 error = vmm_v2p_translate( false , value , &paddr ); 56 if( error ) 49 57 { 58 printk("\n[ERROR] in %s : illegal argument virtual address = %x\n", 59 __FUNCTION__ , (intptr_t)value ); 50 60 this->errno = error; 51 61 return -1; … … 62 72 63 73 // call init function 64 error = remote_sem_ init( (intptr_t)vaddr , data );74 error = remote_sem_create( (intptr_t)vaddr , data ); 65 75 66 76 if ( error ) 67 77 { 78 printk("\n[ERROR] in %s : cannot create semaphore = %x\n", 79 __FUNCTION__ , (intptr_t)value ); 68 80 this->errno = error; 69 81 return -1; … … 79 91 if( sem_xp == XPTR_NULL ) // user error 80 92 { 93 printk("\n[ERROR] in %s : semaphore %x not registered\n", 94 __FUNCTION__ , (intptr_t)value ); 81 95 this->errno = EINVAL; 82 96 return -1; … … 100 114 if( sem_xp == XPTR_NULL ) // user error 101 115 { 116 printk("\n[ERROR] in %s : semaphore %x not registered\n", 117 __FUNCTION__ , (intptr_t)value ); 102 118 this->errno = EINVAL; 103 119 return -1; … … 118 134 if( sem_xp == XPTR_NULL ) // user error 119 135 { 136 printk("\n[ERROR] in %s : semaphore %x not registered\n", 137 __FUNCTION__ , (intptr_t)value ); 120 138 this->errno = EINVAL; 121 139 return -1; … … 136 154 if( sem_xp == XPTR_NULL ) // user error 137 155 { 156 printk("\n[ERROR] in %s : semaphore %x not registered\n", 157 __FUNCTION__ , (intptr_t)value ); 138 158 this->errno = EINVAL; 139 159 return -1; … … 149 169 default: // undefined operation 150 170 { 151 this->errno = EINVAL;152 return -1;171 printk("\n[PANIC] in %s : illegal operation type\n", __FUNCTION__ ); 172 hal_core_sleep(); 153 173 } 154 174 }
Note: See TracChangeset
for help on using the changeset viewer.