Changeset 435 for trunk/kernel/syscalls/sys_mmap.c
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_mmap.c
r407 r435 25 25 #include <hal_types.h> 26 26 #include <hal_uspace.h> 27 #include <hal_irqmask.h> 27 28 #include <shared_syscalls.h> 28 29 #include <errno.h> … … 44 45 error_t error; 45 46 paddr_t paddr; // unused, but required for user space checking 46 47 uint64_t tm_start; 48 uint64_t tm_end; 49 50 tm_start = hal_get_cycles(); 47 reg_t save_sr; // required to enable IRQs 51 48 52 49 thread_t * this = CURRENT_THREAD; 53 50 process_t * process = this->process; 54 51 52 #if CONFIG_DEBUG_SYS_MMAP 53 uint64_t tm_start; 54 uint64_t tm_end; 55 tm_start = hal_get_cycles(); 56 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 57 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 58 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 59 #endif 60 55 61 // check arguments in user space 56 62 error = vmm_v2p_translate( false , attr , &paddr ); … … 58 64 if ( error ) 59 65 { 60 printk("\n[ERROR] in %s : arguments not in used space = %x\n", 61 __FUNCTION__ , (intptr_t)attr ); 66 67 #if CONFIG_DEBUG_SYSCALLS_ERROR 68 printk("\n[ERROR] in %s : arguments not in used space = %x\n", __FUNCTION__ , (intptr_t)attr ); 69 #endif 62 70 this->errno = EINVAL; 63 71 return -1; … … 82 90 if( map_fixed ) 83 91 { 84 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 92 93 #if CONFIG_DEBUG_SYSCALLS_ERROR 94 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 95 #endif 85 96 this->errno = EINVAL; 86 97 return -1; … … 89 100 if( map_shared == map_private ) 90 101 { 91 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 102 103 #if CONFIG_DEBUG_SYSCALLS_ERROR 104 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 105 #endif 92 106 this->errno = EINVAL; 93 107 return -1; … … 108 122 if( fdid >= CONFIG_PROCESS_FILE_MAX_NR ) 109 123 { 110 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 124 125 #if CONFIG_DEBUG_SYSCALLS_ERROR 126 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 127 #endif 111 128 this->errno = EBADFD; 112 129 return -1; … … 118 135 if( file_xp == XPTR_NULL ) 119 136 { 120 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 137 138 #if CONFIG_DEBUG_SYSCALLS_ERROR 139 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 140 #endif 121 141 this->errno = EBADFD; 122 142 return -1; … … 138 158 if( (offset + length) > size) 139 159 { 140 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 141 __FUNCTION__, k_attr.offset, k_attr.length, size ); 160 161 #if CONFIG_DEBUG_SYSCALLS_ERROR 162 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 163 __FUNCTION__, k_attr.offset, k_attr.length, size ); 164 #endif 142 165 this->errno = ERANGE; 143 166 return -1; … … 148 171 (prot_write && !(file_attr & FD_ATTR_WRITE_ENABLE)) ) 149 172 { 150 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 151 __FUNCTION__ , k_attr.prot , file_attr ); 173 174 #if CONFIG_DEBUG_SYSCALLS_ERROR 175 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 176 __FUNCTION__ , k_attr.prot , file_attr ); 177 #endif 152 178 this->errno = EACCES; 153 179 return -1; … … 178 204 if( cluster_is_undefined( vseg_cxy ) ) 179 205 { 180 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 206 207 #if CONFIG_DEBUG_SYSCALLS_ERROR 208 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 209 #endif 181 210 this->errno = EINVAL; 182 211 return -1; … … 184 213 } 185 214 } 215 216 // enable IRQs 217 hal_enable_irq( &save_sr ); 186 218 187 219 // get reference process cluster and local pointer … … 216 248 } 217 249 250 // restore IRQs 251 hal_restore_irq( save_sr ); 252 218 253 if( vseg == NULL ) 219 254 { 220 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 255 256 #if CONFIG_DEBUG_SYSCALLS_ERROR 257 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 258 #endif 221 259 this->errno = ENOMEM; 222 260 return -1; … … 226 264 hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) ); 227 265 228 tm_end = hal_get_cycles(); 229 230 syscall_dmsg("\n[DBG] %s : core[%x,%d] created vseg %s in cluster %x / cycle %d\n" 231 " base = %x / length = %x / cost = %d\n", 232 __FUNCTION__, local_cxy , this->core->lid , vseg_type_str(vseg->type) , 233 vseg->cxy , (uint32_t)tm_start , vseg->min , length , (uint32_t)(tm_end - tm_start) ); 266 hal_fence(); 267 268 #if CONFIG_DEBUG_SYS_MMAP 269 tm_end = hal_get_cycles(); 270 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 271 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n" 272 "vseg %s / cluster %x / base %x / size %x / cost %d\n", 273 __FUNCTION__, this, process->pid, (uint32_t)tm_end, 274 vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)(tm_end - tm_start) ); 275 #endif 234 276 235 277 return 0;
Note: See TracChangeset
for help on using the changeset viewer.