Changeset 9a1b20c in mainline
- Timestamp:
- 2008-09-17T12:16:27Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb9b0b0
- Parents:
- 06a195bc
- Files:
-
- 22 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/amd64/Makefile.inc
r06a195bc r9a1b20c 52 52 $(USPACEDIR)/app/tetris/tetris \ 53 53 $(USPACEDIR)/app/tester/tester \ 54 $(USPACEDIR)/app/trace/trace \ 54 55 $(USPACEDIR)/app/klog/klog \ 55 56 $(USPACEDIR)/app/bdsh/bdsh -
boot/arch/arm32/loader/Makefile
r06a195bc r9a1b20c 107 107 $(USPACEDIR)/app/tetris/tetris \ 108 108 $(USPACEDIR)/app/tester/tester \ 109 $(USPACEDIR)/app/trace/trace \ 109 110 $(USPACEDIR)/app/klog/klog \ 110 111 $(USPACEDIR)/app/bdsh/bdsh -
boot/arch/ia32/Makefile.inc
r06a195bc r9a1b20c 51 51 $(USPACEDIR)/app/tetris/tetris \ 52 52 $(USPACEDIR)/app/tester/tester \ 53 $(USPACEDIR)/app/trace/trace \ 53 54 $(USPACEDIR)/app/klog/klog \ 54 55 $(USPACEDIR)/app/bdsh/bdsh -
boot/arch/ia64/loader/Makefile
r06a195bc r9a1b20c 102 102 $(USPACEDIR)/app/tetris/tetris \ 103 103 $(USPACEDIR)/app/tester/tester \ 104 $(USPACEDIR)/app/trace/trace \ 104 105 $(USPACEDIR)/app/klog/klog 105 106 -
boot/arch/mips32/loader/Makefile
r06a195bc r9a1b20c 107 107 $(USPACEDIR)/app/tetris/tetris \ 108 108 $(USPACEDIR)/app/tester/tester \ 109 $(USPACEDIR)/app/trace/trace \ 109 110 $(USPACEDIR)/app/bdsh/bdsh \ 110 111 $(USPACEDIR)/app/klog/klog -
boot/arch/ppc32/loader/Makefile
r06a195bc r9a1b20c 102 102 $(USPACEDIR)/app/tetris/tetris \ 103 103 $(USPACEDIR)/app/tester/tester \ 104 $(USPACEDIR)/app/trace/trace \ 104 105 $(USPACEDIR)/app/klog/klog \ 105 106 $(USPACEDIR)/app/bdsh/bdsh -
boot/arch/ppc64/loader/Makefile
r06a195bc r9a1b20c 90 90 $(USPACEDIR)/app/tetris/tetris \ 91 91 $(USPACEDIR)/app/tester/tester \ 92 $(USPACEDIR)/app/trace/trace \ 92 93 $(USPACEDIR)/app/klog/klog 93 94 -
kernel/Makefile
r06a195bc r9a1b20c 149 149 DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP) 150 150 endif 151 endif 152 153 ifeq ($(CONFIG_UDEBUG),y) 154 DEFS += -DCONFIG_UDEBUG 151 155 endif 152 156 … … 284 288 generic/src/sysinfo/sysinfo.c 285 289 290 ## Udebug interface sources 291 # 292 293 ifeq ($(CONFIG_UDEBUG),y) 294 GENERIC_SOURCES += \ 295 generic/src/ipc/ipc_kbox.c \ 296 generic/src/udebug/udebug.c \ 297 generic/src/udebug/udebug_ops.c \ 298 generic/src/udebug/udebug_ipc.c 299 endif 300 286 301 ## Test sources 287 302 # -
kernel/generic/include/ipc/ipc.h
r06a195bc r9a1b20c 195 195 */ 196 196 #define IPC_M_DATA_READ 7 197 198 /** Debug the recipient. 199 * - ARG1 - specifies the debug method (from udebug_method_t) 200 * - other arguments are specific to the debug method 201 */ 202 #define IPC_M_DEBUG_ALL 8 197 203 198 204 /* Well-known methods */ … … 308 314 extern void ipc_backsend_err(phone_t *, call_t *, unative_t); 309 315 extern void ipc_print_task(task_id_t); 316 extern void ipc_answerbox_slam_phones(answerbox_t *, bool); 317 extern void ipc_cleanup_call_list(link_t *); 310 318 311 319 extern answerbox_t *ipc_phone_0; -
kernel/generic/include/ipc/sysipc.h
r06a195bc r9a1b20c 58 58 irq_code_t *ucode); 59 59 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno); 60 unative_t sys_ipc_connect_kbox(sysarg64_t *task_id); 60 61 61 62 #endif -
kernel/generic/include/proc/task.h
r06a195bc r9a1b20c 53 53 #include <mm/tlb.h> 54 54 #include <proc/scheduler.h> 55 #include <udebug/udebug.h> 55 56 56 57 struct thread; … … 94 95 */ 95 96 atomic_t active_calls; 97 98 #ifdef CONFIG_UDEBUG 99 /** Debugging stuff */ 100 udebug_task_t udebug; 101 102 /** Kernel answerbox */ 103 answerbox_t kernel_box; 104 /** Thread used to service kernel answerbox */ 105 struct thread *kb_thread; 106 /** Kbox thread creation vs. begin of cleanup mutual exclusion */ 107 mutex_t kb_cleanup_lock; 108 /** True if cleanup of kbox has already started */ 109 bool kb_finished; 110 #endif 96 111 97 112 /** Architecture specific task data. */ -
kernel/generic/include/proc/thread.h
r06a195bc r9a1b20c 47 47 #include <mm/tlb.h> 48 48 #include <proc/uarg.h> 49 #include <udebug/udebug.h> 49 50 50 51 #define THREAD_STACK_SIZE STACK_SIZE … … 204 205 /** Thread's kernel stack. */ 205 206 uint8_t *kstack; 207 208 #ifdef CONFIG_UDEBUG 209 /** Debugging stuff */ 210 udebug_thread_t udebug; 211 #endif 212 206 213 } thread_t; 207 214 -
kernel/generic/include/syscall/syscall.h
r06a195bc r9a1b20c 79 79 80 80 SYS_DEBUG_ENABLE_CONSOLE, 81 SYS_IPC_CONNECT_KBOX, 81 82 SYSCALL_END 82 83 } syscall_t; -
kernel/generic/src/ipc/ipc.c
r06a195bc r9a1b20c 44 44 #include <synch/synch.h> 45 45 #include <ipc/ipc.h> 46 #include <ipc/ipc_kbox.h> 46 47 #include <errno.h> 47 48 #include <mm/slab.h> … … 52 53 53 54 #include <print.h> 55 #include <console/console.h> 54 56 #include <proc/thread.h> 55 57 #include <arch/interrupt.h> … … 428 430 * @param lst Head of the list to be cleaned up. 429 431 */ 430 staticvoid ipc_cleanup_call_list(link_t *lst)432 void ipc_cleanup_call_list(link_t *lst) 431 433 { 432 434 call_t *call; … … 443 445 } 444 446 447 /** Disconnects all phones connected to an answerbox. 448 * 449 * @param box Answerbox to disconnect phones from. 450 * @param notify_box If true, the answerbox will get a hangup message for 451 * each disconnected phone. 452 */ 453 void ipc_answerbox_slam_phones(answerbox_t *box, bool notify_box) 454 { 455 phone_t *phone; 456 DEADLOCK_PROBE_INIT(p_phonelck); 457 ipl_t ipl; 458 call_t *call; 459 460 call = notify_box ? ipc_call_alloc(0) : NULL; 461 462 /* Disconnect all phones connected to our answerbox */ 463 restart_phones: 464 ipl = interrupts_disable(); 465 spinlock_lock(&box->lock); 466 while (!list_empty(&box->connected_phones)) { 467 phone = list_get_instance(box->connected_phones.next, 468 phone_t, link); 469 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) { 470 spinlock_unlock(&box->lock); 471 interrupts_restore(ipl); 472 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD); 473 goto restart_phones; 474 } 475 476 /* Disconnect phone */ 477 ASSERT(phone->state == IPC_PHONE_CONNECTED); 478 479 list_remove(&phone->link); 480 phone->state = IPC_PHONE_SLAMMED; 481 482 if (notify_box) { 483 mutex_unlock(&phone->lock); 484 spinlock_unlock(&box->lock); 485 interrupts_restore(ipl); 486 487 /* 488 * Send one message to the answerbox for each 489 * phone. Used to make sure the kbox thread 490 * wakes up after the last phone has been 491 * disconnected. 492 */ 493 IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP); 494 call->flags |= IPC_CALL_DISCARD_ANSWER; 495 _ipc_call(phone, box, call); 496 497 /* Allocate another call in advance */ 498 call = ipc_call_alloc(0); 499 500 /* Must start again */ 501 goto restart_phones; 502 } 503 504 mutex_unlock(&phone->lock); 505 } 506 507 spinlock_unlock(&box->lock); 508 interrupts_restore(ipl); 509 510 /* Free unused call */ 511 if (call) ipc_call_free(call); 512 } 513 445 514 /** Cleans up all IPC communication of the current task. 446 515 * … … 452 521 int i; 453 522 call_t *call; 454 phone_t *phone;455 DEADLOCK_PROBE_INIT(p_phonelck);456 523 457 524 /* Disconnect all our phones ('ipc_phone_hangup') */ … … 462 529 ipc_irq_cleanup(&TASK->answerbox); 463 530 464 /* Disconnect all phones connected to our answerbox */ 465 restart_phones: 531 /* Disconnect all phones connected to our regular answerbox */ 532 ipc_answerbox_slam_phones(&TASK->answerbox, false); 533 534 #ifdef CONFIG_UDEBUG 535 /* Clean up kbox thread and communications */ 536 ipc_kbox_cleanup(); 537 #endif 538 539 /* Answer all messages in 'calls' and 'dispatched_calls' queues */ 466 540 spinlock_lock(&TASK->answerbox.lock); 467 while (!list_empty(&TASK->answerbox.connected_phones)) {468 phone = list_get_instance(TASK->answerbox.connected_phones.next,469 phone_t, link);470 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {471 spinlock_unlock(&TASK->answerbox.lock);472 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);473 goto restart_phones;474 }475 476 /* Disconnect phone */477 ASSERT(phone->state == IPC_PHONE_CONNECTED);478 phone->state = IPC_PHONE_SLAMMED;479 list_remove(&phone->link);480 481 mutex_unlock(&phone->lock);482 }483 484 /* Answer all messages in 'calls' and 'dispatched_calls' queues */485 541 ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls); 486 542 ipc_cleanup_call_list(&TASK->answerbox.calls); -
kernel/generic/src/ipc/sysipc.c
r06a195bc r9a1b20c 43 43 #include <ipc/irq.h> 44 44 #include <ipc/ipcrsc.h> 45 #include <ipc/ipc_kbox.h> 46 #include <udebug/udebug_ipc.h> 45 47 #include <arch/interrupt.h> 46 48 #include <print.h> … … 296 298 * 297 299 * @param call Call structure with the request. 300 * @param phone Phone that the call will be sent through. 298 301 * 299 302 * @return Return 0 on success, ELIMIT or EPERM on error. 300 303 */ 301 static int request_preprocess(call_t *call )304 static int request_preprocess(call_t *call, phone_t *phone) 302 305 { 303 306 int newphid; … … 341 344 } 342 345 break; 346 #ifdef CONFIG_UDEBUG 347 case IPC_M_DEBUG_ALL: 348 return udebug_request_preprocess(call, phone); 349 #endif 343 350 default: 344 351 break; … … 370 377 if (call->buffer) { 371 378 /* This must be an affirmative answer to IPC_M_DATA_READ. */ 379 /* or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ... */ 372 380 uintptr_t dst = IPC_GET_ARG1(call->data); 373 381 size_t size = IPC_GET_ARG2(call->data); … … 400 408 } 401 409 IPC_SET_ARG5(call->data, phoneid); 402 } 410 } 411 switch (IPC_GET_METHOD(call->data)) { 412 case IPC_M_DEBUG_ALL: 413 return -1; 414 default: 415 break; 416 } 403 417 return 0; 404 418 } … … 442 456 IPC_SET_ARG5(call.data, 0); 443 457 444 if (!(res = request_preprocess(&call ))) {458 if (!(res = request_preprocess(&call, phone))) { 445 459 rc = ipc_call_sync(phone, &call); 446 460 if (rc != EOK) … … 482 496 GET_CHECK_PHONE(phone, phoneid, return ENOENT); 483 497 484 if (!(res = request_preprocess(&call ))) {498 if (!(res = request_preprocess(&call, phone))) { 485 499 rc = ipc_call_sync(phone, &call); 486 500 if (rc != EOK) … … 551 565 IPC_SET_ARG5(call->data, 0); 552 566 553 if (!(res = request_preprocess(call )))567 if (!(res = request_preprocess(call, phone))) 554 568 ipc_call(phone, call); 555 569 else … … 585 599 return (unative_t) rc; 586 600 } 587 if (!(res = request_preprocess(call )))601 if (!(res = request_preprocess(call, phone))) 588 602 ipc_call(phone, call); 589 603 else … … 869 883 } 870 884 885 #include <console/console.h> 886 887 /** 888 * Syscall connect to a task by id. 889 * 890 * @return Phone id on success, or negative error code. 891 */ 892 unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg) 893 { 894 #ifdef CONFIG_UDEBUG 895 sysarg64_t taskid_arg; 896 int rc; 897 898 rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 899 if (rc != 0) 900 return (unative_t) rc; 901 902 printf("sys_ipc_connect_kbox(%lld, %d)\n", taskid_arg.value); 903 904 return ipc_connect_kbox(taskid_arg.value); 905 #else 906 return (unative_t) ENOTSUP; 907 #endif 908 } 909 871 910 /** @} 872 911 */ -
kernel/generic/src/main/uinit.c
r06a195bc r9a1b20c 47 47 #include <mm/slab.h> 48 48 #include <arch.h> 49 #include <udebug/udebug.h> 50 49 51 50 52 /** Thread used to bring up userspace thread. … … 66 68 */ 67 69 thread_detach(THREAD); 70 71 #ifdef CONFIG_UDEBUG 72 udebug_stoppable_end(); 73 #endif 68 74 69 75 uarg.uspace_entry = ((uspace_arg_t *) arg)->uspace_entry; -
kernel/generic/src/proc/task.c
r06a195bc r9a1b20c 156 156 ta->capabilities = 0; 157 157 ta->cycles = 0; 158 158 159 #ifdef CONFIG_UDEBUG 160 /* Init debugging stuff */ 161 udebug_task_init(&ta->udebug); 162 163 /* Init kbox stuff */ 164 ipc_answerbox_init(&ta->kernel_box, ta); 165 ta->kb_thread = NULL; 166 mutex_initialize(&ta->kb_cleanup_lock, MUTEX_PASSIVE); 167 ta->kb_finished = false; 168 #endif 169 159 170 ipc_answerbox_init(&ta->answerbox, ta); 160 171 for (i = 0; i < IPC_MAX_PHONES; i++) -
kernel/generic/src/proc/thread.c
r06a195bc r9a1b20c 181 181 } 182 182 183 #ifdef CONFIG_UDEBUG 184 mutex_initialize(&t->udebug.lock, MUTEX_PASSIVE); 185 #endif 186 183 187 return 0; 184 188 } … … 348 352 t->threads_tree_node.key = (uintptr_t) t; 349 353 354 #ifdef CONFIG_UDEBUG 355 /* Init debugging stuff */ 356 udebug_thread_initialize(&t->udebug); 357 #endif 358 350 359 /* might depend on previous initialization */ 351 360 thread_create_arch(t); … … 410 419 411 420 /* 412 * Attach to the currenttask.421 * Attach to the specified task. 413 422 */ 414 423 ipl = interrupts_disable(); 415 424 spinlock_lock(&task->lock); 425 416 426 atomic_inc(&task->refcount); 417 atomic_inc(&task->lifecount); 427 428 /* Must not count kbox thread into lifecount */ 429 if (t->flags & THREAD_FLAG_USPACE) 430 atomic_inc(&task->lifecount); 431 418 432 list_append(&t->th_link, &task->th_head); 419 433 spinlock_unlock(&task->lock); … … 438 452 ipl_t ipl; 439 453 440 if (atomic_predec(&TASK->lifecount) == 0) { 441 /* 442 * We are the last thread in the task that still has not exited. 443 * With the exception of the moment the task was created, new 444 * threads can only be created by threads of the same task. 445 * We are safe to perform cleanup. 446 */ 447 if (THREAD->flags & THREAD_FLAG_USPACE) { 454 if (THREAD->flags & THREAD_FLAG_USPACE) { 455 #ifdef CONFIG_UDEBUG 456 /* Generate udebug THREAD_E event */ 457 udebug_thread_e_event(); 458 #endif 459 if (atomic_predec(&TASK->lifecount) == 0) { 460 /* 461 * We are the last userspace thread in the task that 462 * still has not exited. With the exception of the 463 * moment the task was created, new userspace threads 464 * can only be created by threads of the same task. 465 * We are safe to perform cleanup. 466 */ 448 467 ipc_cleanup(); 449 468 futex_cleanup(); … … 742 761 thread_ready(t); 743 762 763 #ifdef CONFIG_UDEBUG 764 /* Generate udebug THREAD_B event */ 765 udebug_thread_b_event(t); 766 #endif 767 744 768 return 0; 745 769 } else -
kernel/generic/src/syscall/syscall.c
r06a195bc r9a1b20c 54 54 #include <sysinfo/sysinfo.h> 55 55 #include <console/console.h> 56 #include <udebug/udebug.h> 56 57 57 58 /** Print using kernel facility … … 102 103 unative_t rc; 103 104 104 if (id < SYSCALL_END) 105 #ifdef CONFIG_UDEBUG 106 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false); 107 #endif 108 109 if (id < SYSCALL_END) { 110 #ifdef CONFIG_UDEBUG 111 udebug_stoppable_begin(); 112 #endif 105 113 rc = syscall_table[id](a1, a2, a3, a4, a5, a6); 106 else {114 } else { 107 115 printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); 108 116 task_kill(TASK->taskid); … … 112 120 if (THREAD->interrupted) 113 121 thread_exit(); 122 123 #ifdef CONFIG_UDEBUG 124 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true); 125 udebug_stoppable_end(); 126 #endif 114 127 115 128 return rc; … … 166 179 167 180 /* Debug calls */ 168 (syshandler_t) sys_debug_enable_console 181 (syshandler_t) sys_debug_enable_console, 182 183 (syshandler_t) sys_ipc_connect_kbox 169 184 }; 170 185 -
kernel/kernel.config
r06a195bc r9a1b20c 145 145 ! [ARCH=sparc64] CONFIG_VIRT_IDX_DCACHE (y/n) 146 146 147 # Support for userspace debuggers 148 ! CONFIG_UDEBUG (n/y) 147 149 148 150 ## Debugging configuration directives -
uspace/Makefile
r06a195bc r9a1b20c 49 49 app/tetris \ 50 50 app/tester \ 51 app/trace \ 51 52 app/klog \ 52 53 app/init \ -
uspace/lib/libc/Makefile
r06a195bc r9a1b20c 79 79 generic/stdlib.c \ 80 80 generic/mman.c \ 81 generic/udebug.c \ 81 82 generic/vfs/vfs.c \ 82 83 generic/vfs/canonify.c -
uspace/lib/libc/generic/ipc.c
r06a195bc r9a1b20c 910 910 return ipc_answer_2(callid, EOK, (ipcarg_t) dst, (ipcarg_t) size); 911 911 } 912 913 #include <kernel/syscall/sysarg64.h> 914 /** Connect to a task specified by id. 915 */ 916 int ipc_connect_kbox(task_id_t id) 917 { 918 sysarg64_t arg; 919 920 arg.value = (unsigned long long) id; 921 922 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg); 923 } 912 924 913 925 /** @} -
uspace/lib/libc/include/ipc/ipc.h
r06a195bc r9a1b20c 289 289 extern int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size); 290 290 291 #include <task.h> 292 293 extern int ipc_connect_kbox(task_id_t id); 294 291 295 #endif 292 296
Note:
See TracChangeset
for help on using the changeset viewer.