Changeset e3c762cd in mainline for generic/src
- Timestamp:
- 2006-05-05T11:59:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- de07bcf
- Parents:
- 22cf454d
- Location:
- generic/src
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/ddi/ddi.c
r22cf454d re3c762cd 41 41 #include <security/cap.h> 42 42 #include <mm/frame.h> 43 #include <mm/page.h>44 43 #include <mm/as.h> 45 44 #include <synch/spinlock.h> 45 #include <syscall/copy.h> 46 46 #include <arch.h> 47 47 #include <align.h> … … 184 184 { 185 185 ddi_memarg_t arg; 186 187 copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); 186 int rc; 187 188 rc = copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); 189 if (rc != 0) 190 return (__native) rc; 191 188 192 return (__native) ddi_physmem_map((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE), 189 193 ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages, … … 200 204 { 201 205 ddi_ioarg_t arg; 202 203 copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 206 int rc; 207 208 rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 209 if (rc != 0) 210 return (__native) rc; 211 204 212 return (__native) ddi_iospace_enable((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size); 205 213 } -
generic/src/ipc/irq.c
r22cf454d re3c762cd 48 48 #include <ipc/irq.h> 49 49 #include <atomic.h> 50 #include <syscall/copy.h> 50 51 51 52 typedef struct { … … 121 122 irq_code_t *code; 122 123 irq_cmd_t *ucmds; 124 int rc; 123 125 124 126 code = malloc(sizeof(*code), 0); 125 copy_from_uspace(code, ucode, sizeof(*code)); 127 rc = copy_from_uspace(code, ucode, sizeof(*code)); 128 if (rc != 0) { 129 free(code); 130 return NULL; 131 } 126 132 127 133 if (code->cmdcount > IRQ_MAX_PROG_SIZE) { … … 131 137 ucmds = code->cmds; 132 138 code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0); 133 copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount)); 139 rc = copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount)); 140 if (rc != 0) { 141 free(code->cmds); 142 free(code); 143 return NULL; 144 } 134 145 135 146 return code; -
generic/src/ipc/sysipc.c
r22cf454d re3c762cd 29 29 #include <arch.h> 30 30 #include <proc/task.h> 31 31 #include <proc/thread.h> 32 32 #include <errno.h> 33 #include <mm/page.h>34 33 #include <memstr.h> 35 34 #include <debug.h> … … 39 38 #include <ipc/ipcrsc.h> 40 39 #include <arch/interrupt.h> 41 42 40 #include <print.h> 43 #include <arch.h> 44 #include <proc/thread.h> 41 #include <syscall/copy.h> 45 42 46 43 #define GET_CHECK_PHONE(phone,phoneid,err) { \ … … 229 226 phone_t *phone; 230 227 int res; 228 int rc; 231 229 232 230 ipc_call_static_init(&call); 233 copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args)); 231 rc = copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args)); 232 if (rc != 0) 233 return (__native) rc; 234 234 235 235 GET_CHECK_PHONE(phone, phoneid, return ENOENT); … … 241 241 IPC_SET_RETVAL(call.data, res); 242 242 243 STRUCT_TO_USPACE(&reply->args, &call.data.args); 243 rc = STRUCT_TO_USPACE(&reply->args, &call.data.args); 244 if (rc != 0) 245 return rc; 244 246 245 247 return 0; … … 298 300 phone_t *phone; 299 301 int res; 302 int rc; 300 303 301 304 if (check_call_limit()) … … 305 308 306 309 call = ipc_call_alloc(0); 307 copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args)); 310 rc = copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args)); 311 if (rc != 0) 312 return (__native) rc; 308 313 if (!(res=request_preprocess(call))) 309 314 ipc_call(phone, call); … … 394 399 ipc_data_t saved_data; 395 400 int saveddata = 0; 401 int rc; 396 402 397 403 call = get_call(callid); … … 403 409 saveddata = 1; 404 410 } 405 copy_from_uspace(&call->data.args, &data->args,411 rc = copy_from_uspace(&call->data.args, &data->args, 406 412 sizeof(call->data.args)); 413 if (rc != 0) 414 return rc; 407 415 408 416 answer_preprocess(call, saveddata ? &saved_data : NULL); -
generic/src/mm/as.c
r22cf454d re3c762cd 58 58 #include <adt/btree.h> 59 59 #include <proc/task.h> 60 #include <proc/thread.h> 60 61 #include <arch/asm.h> 61 62 #include <panic.h> … … 69 70 #include <arch/types.h> 70 71 #include <typedefs.h> 72 #include <syscall/copy.h> 73 #include <arch/interrupt.h> 71 74 72 75 as_operations_t *as_operations = NULL; … … 478 481 * 479 482 * @param page Faulting page. 480 * 481 * @return 0 on page fault, 1 on success. 482 */ 483 int as_page_fault(__address page) 483 * @param istate Pointer to interrupted state. 484 * 485 * @return 0 on page fault, 1 on success or 2 if the fault was caused by copy_to_uspace() or copy_from_uspace(). 486 */ 487 int as_page_fault(__address page, istate_t *istate) 484 488 { 485 489 pte_t *pte; … … 497 501 */ 498 502 spinlock_unlock(&AS->lock); 499 return 0;503 goto page_fault; 500 504 } 501 505 … … 507 511 spinlock_unlock(&area->lock); 508 512 spinlock_unlock(&AS->lock); 509 return 0;513 goto page_fault; 510 514 } 511 515 … … 555 559 spinlock_unlock(&area->lock); 556 560 spinlock_unlock(&AS->lock); 557 return 1; 561 return AS_PF_OK; 562 563 page_fault: 564 if (!THREAD) 565 return AS_PF_FAULT; 566 567 if (THREAD->in_copy_from_uspace) { 568 THREAD->in_copy_from_uspace = false; 569 istate_set_retaddr(istate, (__address) &memcpy_from_uspace_failover_address); 570 } else if (THREAD->in_copy_to_uspace) { 571 THREAD->in_copy_to_uspace = false; 572 istate_set_retaddr(istate, (__address) &memcpy_to_uspace_failover_address); 573 } else { 574 return AS_PF_FAULT; 575 } 576 577 return AS_PF_DEFER; 558 578 } 559 579 … … 885 905 { 886 906 as_area_acptsnd_arg_t arg; 887 888 copy_from_uspace(&arg, uspace_accept_arg, sizeof(as_area_acptsnd_arg_t)); 907 int rc; 908 909 rc = copy_from_uspace(&arg, uspace_accept_arg, sizeof(as_area_acptsnd_arg_t)); 910 if (rc != 0) 911 return rc; 889 912 890 913 if (!arg.size) … … 907 930 { 908 931 as_area_acptsnd_arg_t arg; 909 910 copy_from_uspace(&arg, uspace_send_arg, sizeof(as_area_acptsnd_arg_t)); 932 int rc; 933 934 rc = copy_from_uspace(&arg, uspace_send_arg, sizeof(as_area_acptsnd_arg_t)); 935 if (rc != 0) 936 return rc; 911 937 912 938 if (!arg.size) -
generic/src/mm/slab.c
r22cf454d re3c762cd 176 176 slab = data + fsize - sizeof(*slab); 177 177 } 178 178 179 179 /* Fill in slab structures */ 180 180 for (i=0; i < (1 << cache->order); i++) … … 278 278 /* Allow recursion and reclaiming 279 279 * - this should work, as the slab control structures 280 * are small and do not need to alloc te with anything281 * other t en frame_alloc when they are allocating,280 * are small and do not need to allocate with anything 281 * other than frame_alloc when they are allocating, 282 282 * that's why we should get recursion at most 1-level deep 283 283 */ … … 880 880 881 881 ASSERT(_slab_initialized); 882 ASSERT( 882 ASSERT(size && size <= (1 << SLAB_MAX_MALLOC_W)); 883 883 884 884 if (size < (1 << SLAB_MIN_MALLOC_W)) … … 890 890 } 891 891 892 893 892 void free(void *obj) 894 893 { -
generic/src/printf/vsnprintf.c
r22cf454d re3c762cd 40 40 41 41 /** Write string to given buffer. 42 * Write at most data->size characters including trailing zero. According to C99 has snprintfto return number42 * Write at most data->size characters including trailing zero. According to C99, snprintf() has to return number 43 43 * of characters that would have been written if enough space had been available. Hence the return value is not 44 * number of really printed characters but size of input string. Number of really used characters44 * number of really printed characters but size of the input string. Number of really used characters 45 45 * is stored in data->len. 46 46 * @param str source string to print … … 91 91 return printf_core(fmt, &ps, ap); 92 92 } 93 94 -
generic/src/proc/task.c
r22cf454d re3c762cd 49 49 #include <print.h> 50 50 #include <elf.h> 51 51 #include <syscall/copy.h> 52 52 53 53 #ifndef LOADED_PROG_STACK_PAGES_NO … … 171 171 * @param uspace_task_id Userspace address of 8-byte buffer where to store current task ID. 172 172 * 173 * @return Always returns 0.173 * @return 0 on success or an error code from @ref errno.h. 174 174 */ 175 175 __native sys_task_get_id(task_id_t *uspace_task_id) … … 179 179 * remains constant for the lifespan of the task. 180 180 */ 181 copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid)); 182 183 return 0; 181 return (__native) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid)); 184 182 } 185 183 -
generic/src/proc/thread.c
r22cf454d re3c762cd 61 61 #include <debug.h> 62 62 #include <main/uinit.h> 63 #include <syscall/copy.h> 64 #include <errno.h> 63 65 64 66 char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */ … … 304 306 t->sleep_queue = NULL; 305 307 t->timeout_pending = 0; 308 309 t->in_copy_from_uspace = false; 310 t->in_copy_to_uspace = false; 306 311 307 312 t->rwlock_holder_type = RWLOCK_NONE; … … 463 468 uspace_arg_t *kernel_uarg; 464 469 __u32 tid; 465 466 copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN); 470 int rc; 471 472 rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN); 473 if (rc != 0) 474 return (__native) rc; 467 475 468 476 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 469 copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 477 rc = copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 478 if (rc != 0) { 479 free(kernel_uarg); 480 return (__native) rc; 481 } 470 482 471 483 if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) { … … 477 489 } 478 490 479 return (__native) -1;491 return (__native) ENOMEM; 480 492 } 481 493 -
generic/src/smp/ipi.c
r22cf454d re3c762cd 44 44 * @param ipi Message to broadcast. 45 45 * 46 * @bug sThe decision whether to actually send the IPI must be based47 * 48 * 49 * 46 * @bug The decision whether to actually send the IPI must be based 47 * on a different criterion. The current version has 48 * problems when some of the detected CPUs are marked 49 * disabled in machine configuration. 50 50 */ 51 51 void ipi_broadcast(int ipi) -
generic/src/synch/waitq.c
r22cf454d re3c762cd 31 31 * @brief Wait queue. 32 32 * 33 * Wait queue is the basic synchronization primitive upon all33 * Wait queue is the basic synchronization primitive upon which all 34 34 * other synchronization primitives build. 35 35 *
Note:
See TracChangeset
for help on using the changeset viewer.