Changeset 1787e527 in mainline for kernel/generic
- Timestamp:
- 2009-11-16T21:22:54Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ebdf94
- Parents:
- fcbd1be (diff), 9c70ed6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/generic
- Files:
-
- 26 edited
-
include/console/chardev.h (modified) (3 diffs)
-
include/console/console.h (modified) (2 diffs)
-
include/context.h (modified) (2 diffs)
-
include/ddi/irq.h (modified) (1 diff)
-
include/ipc/sysipc.h (modified) (1 diff)
-
include/main/main.h (modified) (1 diff)
-
include/print.h (modified) (1 diff)
-
include/printf/printf_core.h (modified) (1 diff)
-
include/stdarg.h (modified) (3 diffs)
-
include/synch/spinlock.h (modified) (6 diffs)
-
include/synch/waitq.h (modified) (1 diff)
-
include/syscall/syscall.h (modified) (1 diff)
-
include/sysinfo/sysinfo.h (modified) (1 diff)
-
src/console/chardev.c (modified) (2 diffs)
-
src/console/cmd.c (modified) (9 diffs)
-
src/console/console.c (modified) (6 diffs)
-
src/ddi/ddi.c (modified) (1 diff)
-
src/ipc/kbox.c (modified) (1 diff)
-
src/ipc/sysipc.c (modified) (2 diffs)
-
src/main/main.c (modified) (1 diff)
-
src/printf/printf_core.c (modified) (1 diff)
-
src/printf/vprintf.c (modified) (1 diff)
-
src/synch/spinlock.c (modified) (5 diffs)
-
src/synch/waitq.c (modified) (1 diff)
-
src/syscall/syscall.c (modified) (1 diff)
-
src/sysinfo/sysinfo.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/console/chardev.h
rfcbd1be r1787e527 36 36 #define KERN_CHARDEV_H_ 37 37 38 #include <adt/list.h> 38 39 #include <arch/types.h> 39 40 #include <synch/waitq.h> … … 73 74 /** Write character to output. */ 74 75 void (* write)(struct outdev *, wchar_t, bool); 76 77 /** Redraw any previously cached characters. */ 78 void (* redraw)(struct outdev *); 75 79 } outdev_operations_t; 76 80 77 /** Character input device. */81 /** Character output device. */ 78 82 typedef struct outdev { 79 83 char *name; … … 81 85 /** Protects everything below. */ 82 86 SPINLOCK_DECLARE(lock); 87 88 /** Fields suitable for multiplexing. */ 89 link_t link; 90 link_t list; 83 91 84 92 /** Implementation of outdev operations. */ -
kernel/generic/include/console/console.h
rfcbd1be r1787e527 44 44 45 45 extern indev_t *stdin_wire(void); 46 extern void stdout_wire(outdev_t *outdev); 46 47 extern void console_init(void); 47 48 … … 59 60 extern unative_t sys_debug_disable_console(void); 60 61 61 extern void arch_grab_console(void);62 extern void arch_release_console(void);63 64 62 #endif /* KERN_CONSOLE_H_ */ 65 63 -
kernel/generic/include/context.h
rfcbd1be r1787e527 51 51 /** Save register context. 52 52 * 53 * Save current register context (including stack pointers) 54 * to context structure. 55 * 56 * Note that call to context_restore() will return at the same 53 * Save the current register context (including stack pointer) to a context 54 * structure. A subsequent call to context_restore() will return to the same 57 55 * address as the corresponding call to context_save(). 58 56 * 59 * This MUST be a macro, gcc -O0 does not inline functions even 60 * if they are marked inline and context_save_arch must be called 61 * from level <= that when context_restore is called. 57 * Note that context_save_arch() must reuse the stack frame of the function 58 * which called context_save(). We guarantee this by: 62 59 * 63 * @param c Context structure. 60 * a) implementing context_save_arch() in assembly so that it does not create 61 * its own stack frame, and by 62 * b) defining context_save() as a macro because the inline keyword is just a 63 * hint for the compiler, not a real constraint; the application of a macro 64 * will definitely not create a stack frame either. 64 65 * 65 * @return context_save() returns 1, context_restore() returns 0. 66 * To imagine what could happen if there were some extra stack frames created 67 * either by context_save() or context_save_arch(), we need to realize that the 68 * sp saved in the contex_t structure points to the current stack frame as it 69 * existed when context_save_arch() was executing. After the return from 70 * context_save_arch() and context_save(), any extra stack frames created by 71 * these functions will be destroyed and their contents sooner or later 72 * overwritten by functions called next. Any attempt to restore to a context 73 * saved like that would therefore lead to a disaster. 74 * 75 * @param c Context structure. 76 * 77 * @return context_save() returns 1, context_restore() returns 0. 66 78 */ 67 79 #define context_save(c) context_save_arch(c) … … 69 81 /** Restore register context. 70 82 * 71 * Restore previously saved register context (including stack pointers)72 * fromcontext structure.83 * Restore a previously saved register context (including stack pointer) from 84 * a context structure. 73 85 * 74 * Note that this function does not normally return. 75 * Instead, it returns at the same address as the 76 * corresponding call to context_save(), the only 77 * difference being return value. 86 * Note that this function does not normally return. Instead, it returns to the 87 * same address as the corresponding call to context_save(), the only difference 88 * being return value. 78 89 * 79 * @param c Context structure.90 * @param c Context structure. 80 91 */ 81 92 static inline void context_restore(context_t *c) -
kernel/generic/include/ddi/irq.h
rfcbd1be r1787e527 37 37 38 38 typedef enum { 39 /** Read 1 byte from the I/O space. */ 39 40 CMD_PIO_READ_8 = 1, 41 /** Read 2 bytes from the I/O space. */ 40 42 CMD_PIO_READ_16, 43 /** Read 4 bytes from the I/O space. */ 41 44 CMD_PIO_READ_32, 45 /** Write 1 byte to the I/O space. */ 42 46 CMD_PIO_WRITE_8, 47 /** Write 2 bytes to the I/O space. */ 43 48 CMD_PIO_WRITE_16, 49 /** Write 4 bytes to the I/O space. */ 44 50 CMD_PIO_WRITE_32, 51 /** 52 * Perform a bit test on the source argument and store the result into 53 * the destination argument. 54 */ 45 55 CMD_BTEST, 56 /** 57 * Predicate the execution of the following N commands by the boolean 58 * value of the source argument. 59 */ 46 60 CMD_PREDICATE, 61 /** Accept the interrupt. */ 47 62 CMD_ACCEPT, 63 /** Decline the interrupt. */ 48 64 CMD_DECLINE, 49 65 CMD_LAST -
kernel/generic/include/ipc/sysipc.h
rfcbd1be r1787e527 52 52 unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 53 53 int nonblocking); 54 unative_t sys_ipc_poke(void); 54 55 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, 55 56 unative_t method, unative_t arg1, unative_t arg2, int mode); -
kernel/generic/include/main/main.h
rfcbd1be r1787e527 38 38 #include <arch/types.h> 39 39 40 extern size_t hardcoded_kdata_size; 41 extern size_t hardcoded_ktext_size; 42 extern uintptr_t hardcoded_load_address; 40 43 extern uintptr_t stack_safe; 41 44 -
kernel/generic/include/print.h
rfcbd1be r1787e527 37 37 38 38 #include <arch/types.h> 39 #include <synch/spinlock.h> 40 #include <arch/arg.h> 41 42 /* We need this address in spinlock to avoid deadlock in deadlock detection */ 43 SPINLOCK_EXTERN(printf_lock); 39 #include <stdarg.h> 44 40 45 41 #define EOF (-1) -
kernel/generic/include/printf/printf_core.h
rfcbd1be r1787e527 37 37 38 38 #include <typedefs.h> 39 #include < arch/arg.h>39 #include <stdarg.h> 40 40 41 41 /** Structure for specifying output methods for different printf clones. */ -
kernel/generic/include/stdarg.h
rfcbd1be r1787e527 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 37 37 * for all architectures with compiler support for __builtin_va_*. 38 38 */ 39 39 40 40 #ifndef KERN_STDARG_H_ 41 41 #define KERN_STDARG_H_ … … 43 43 typedef __builtin_va_list va_list; 44 44 45 #define va_start(ap, last) __builtin_va_start(ap, last)46 #define va_arg(ap, type) __builtin_va_arg(ap, type)47 #define va_end(ap) __builtin_va_end(ap)48 #define va_copy(dst, src) __builtin_va_copy(dst, src)45 #define va_start(ap, last) __builtin_va_start(ap, last) 46 #define va_arg(ap, type) __builtin_va_arg(ap, type) 47 #define va_end(ap) __builtin_va_end(ap) 48 #define va_copy(dst, src) __builtin_va_copy(dst, src) 49 49 50 50 #endif -
kernel/generic/include/synch/spinlock.h
rfcbd1be r1787e527 43 43 44 44 #ifdef CONFIG_SMP 45 45 46 typedef struct { 47 atomic_t val; 48 46 49 #ifdef CONFIG_DEBUG_SPINLOCK 47 50 char *name; 48 51 #endif 49 atomic_t val;50 52 } spinlock_t; 51 53 … … 54 56 * where the lock gets initialized in run time. 55 57 */ 56 #define SPINLOCK_DECLARE( slname) spinlock_t slname57 #define SPINLOCK_EXTERN( slname) extern spinlock_t slname58 #define SPINLOCK_DECLARE(lock_name) spinlock_t lock_name 59 #define SPINLOCK_EXTERN(lock_name) extern spinlock_t lock_name 58 60 59 61 /* … … 62 64 */ 63 65 #ifdef CONFIG_DEBUG_SPINLOCK 64 #define SPINLOCK_INITIALIZE(slname) \ 65 spinlock_t slname = { \ 66 .name = #slname, \ 67 .val = { 0 } \ 66 67 #define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \ 68 spinlock_t lock_name = { \ 69 .name = desc_name, \ 70 .val = { 0 } \ 68 71 } 72 73 #define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \ 74 static spinlock_t lock_name = { \ 75 .name = desc_name, \ 76 .val = { 0 } \ 77 } 78 79 #define spinlock_lock(lock) spinlock_lock_debug(lock) 80 69 81 #else 70 #define SPINLOCK_INITIALIZE(slname) \ 71 spinlock_t slname = { \ 72 .val = { 0 } \ 82 83 #define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \ 84 spinlock_t lock_name = { \ 85 .val = { 0 } \ 73 86 } 87 88 #define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \ 89 static spinlock_t lock_name = { \ 90 .val = { 0 } \ 91 } 92 93 #define spinlock_lock(lock) atomic_lock_arch(&(lock)->val) 94 74 95 #endif 75 96 76 extern void spinlock_initialize(spinlock_t *sl, char *name); 77 extern int spinlock_trylock(spinlock_t *sl); 78 extern void spinlock_lock_debug(spinlock_t *sl); 97 #define SPINLOCK_INITIALIZE(lock_name) \ 98 SPINLOCK_INITIALIZE_NAME(lock_name, #lock_name) 79 99 80 #ifdef CONFIG_DEBUG_SPINLOCK 81 # define spinlock_lock(x) spinlock_lock_debug(x) 82 #else 83 # define spinlock_lock(x) atomic_lock_arch(&(x)->val) 84 #endif 100 #define SPINLOCK_STATIC_INITIALIZE(lock_name) \ 101 SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name) 102 103 extern void spinlock_initialize(spinlock_t *lock, char *name); 104 extern int spinlock_trylock(spinlock_t *lock); 105 extern void spinlock_lock_debug(spinlock_t *lock); 85 106 86 107 /** Unlock spinlock … … 90 111 * @param sl Pointer to spinlock_t structure. 91 112 */ 92 static inline void spinlock_unlock(spinlock_t * sl)113 static inline void spinlock_unlock(spinlock_t *lock) 93 114 { 94 ASSERT(atomic_get(& sl->val) != 0);95 115 ASSERT(atomic_get(&lock->val) != 0); 116 96 117 /* 97 118 * Prevent critical section code from bleeding out this way down. … … 99 120 CS_LEAVE_BARRIER(); 100 121 101 atomic_set(& sl->val, 0);122 atomic_set(&lock->val, 0); 102 123 preemption_enable(); 103 124 } … … 105 126 #ifdef CONFIG_DEBUG_SPINLOCK 106 127 107 extern int printf(const char *, ...); 128 #include <print.h> 108 129 109 #define DEADLOCK_THRESHOLD 100000000 110 #define DEADLOCK_PROBE_INIT(pname) size_t pname = 0 111 #define DEADLOCK_PROBE(pname, value) \ 112 if ((pname)++ > (value)) { \ 113 (pname) = 0; \ 114 printf("Deadlock probe %s: exceeded threshold %u\n", \ 115 "cpu%u: function=%s, line=%u\n", \ 116 #pname, (value), CPU->id, __func__, __LINE__); \ 130 #define DEADLOCK_THRESHOLD 100000000 131 132 #define DEADLOCK_PROBE_INIT(pname) size_t pname = 0 133 134 #define DEADLOCK_PROBE(pname, value) \ 135 if ((pname)++ > (value)) { \ 136 (pname) = 0; \ 137 printf("Deadlock probe %s: exceeded threshold %u\n", \ 138 "cpu%u: function=%s, line=%u\n", \ 139 #pname, (value), CPU->id, __func__, __LINE__); \ 117 140 } 118 #else119 #define DEADLOCK_PROBE_INIT(pname)120 #define DEADLOCK_PROBE(pname, value)121 #endif122 141 123 142 #else 124 143 144 #define DEADLOCK_PROBE_INIT(pname) 145 #define DEADLOCK_PROBE(pname, value) 146 147 #endif 148 149 #else /* CONFIG_SMP */ 150 125 151 /* On UP systems, spinlocks are effectively left out. */ 152 126 153 #define SPINLOCK_DECLARE(name) 127 154 #define SPINLOCK_EXTERN(name) 155 128 156 #define SPINLOCK_INITIALIZE(name) 157 #define SPINLOCK_STATIC_INITIALIZE(name) 129 158 130 #define spinlock_initialize(x, name) 131 #define spinlock_lock(x) preemption_disable() 132 #define spinlock_trylock(x) (preemption_disable(), 1) 133 #define spinlock_unlock(x) preemption_enable() 159 #define SPINLOCK_INITIALIZE_NAME(name, desc_name) 160 #define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name) 161 162 #define spinlock_initialize(lock, name) 163 164 #define spinlock_lock(lock) preemption_disable() 165 #define spinlock_trylock(lock) (preemption_disable(), 1) 166 #define spinlock_unlock(lock) preemption_enable() 134 167 135 168 #define DEADLOCK_PROBE_INIT(pname) -
kernel/generic/include/synch/waitq.h
rfcbd1be r1787e527 68 68 struct thread; 69 69 70 extern void waitq_initialize(waitq_t *wq); 71 extern int waitq_sleep_timeout(waitq_t *wq, uint32_t usec, int flags); 72 extern ipl_t waitq_sleep_prepare(waitq_t *wq); 73 extern int waitq_sleep_timeout_unsafe(waitq_t *wq, uint32_t usec, int flags); 74 extern void waitq_sleep_finish(waitq_t *wq, int rc, ipl_t ipl); 75 extern void waitq_wakeup(waitq_t *wq, wakeup_mode_t mode); 76 extern void _waitq_wakeup_unsafe(waitq_t *wq, wakeup_mode_t mode); 77 extern void waitq_interrupt_sleep(struct thread *t); 70 extern void waitq_initialize(waitq_t *); 71 extern int waitq_sleep_timeout(waitq_t *, uint32_t, int); 72 extern ipl_t waitq_sleep_prepare(waitq_t *); 73 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int); 74 extern void waitq_sleep_finish(waitq_t *, int, ipl_t); 75 extern void waitq_wakeup(waitq_t *, wakeup_mode_t); 76 extern void _waitq_wakeup_unsafe(waitq_t *, wakeup_mode_t); 77 extern void waitq_interrupt_sleep(struct thread *); 78 extern void waitq_unsleep(waitq_t *); 78 79 79 80 #endif -
kernel/generic/include/syscall/syscall.h
rfcbd1be r1787e527 66 66 SYS_IPC_FORWARD_SLOW, 67 67 SYS_IPC_WAIT, 68 SYS_IPC_POKE, 68 69 SYS_IPC_HANGUP, 69 70 SYS_IPC_REGISTER_IRQ, -
kernel/generic/include/sysinfo/sysinfo.h
rfcbd1be r1787e527 38 38 #include <arch/types.h> 39 39 #include <string.h> 40 41 extern bool fb_exported; 40 42 41 43 typedef union sysinfo_item_val { -
kernel/generic/src/console/chardev.c
rfcbd1be r1787e527 33 33 */ 34 34 35 #include <adt/list.h> 35 36 #include <console/chardev.h> 36 37 #include <synch/waitq.h> … … 134 135 outdev->name = name; 135 136 spinlock_initialize(&outdev->lock, "outdev"); 137 link_initialize(&outdev->link); 138 list_initialize(&outdev->list); 136 139 outdev->op = op; 137 140 } -
kernel/generic/src/console/cmd.c
rfcbd1be r1787e527 409 409 }; 410 410 411 /* Data and methods for 'kill' command */ 412 static int cmd_kill(cmd_arg_t *argv); 413 static cmd_arg_t kill_argv = { 414 .type = ARG_TYPE_INT, 415 }; 416 static cmd_info_t kill_info = { 417 .name = "kill", 418 .description = "kill <taskid> Kill a task.", 419 .func = cmd_kill, 420 .argc = 1, 421 .argv = &kill_argv 422 }; 423 411 424 /* Data and methods for 'zone' command */ 412 425 static int cmd_zone(cmd_arg_t *argv); … … 459 472 &help_info, 460 473 &ipc_info, 474 &kill_info, 461 475 &set4_info, 462 476 &slabs_info, … … 848 862 * @return Always 1 849 863 */ 850 int cmd_slabs(cmd_arg_t * argv) { 864 int cmd_slabs(cmd_arg_t * argv) 865 { 851 866 slab_print_list(); 852 867 return 1; … … 860 875 * @return Always 1 861 876 */ 862 int cmd_threads(cmd_arg_t * argv) { 877 int cmd_threads(cmd_arg_t * argv) 878 { 863 879 thread_print_list(); 864 880 return 1; … … 871 887 * @return Always 1 872 888 */ 873 int cmd_tasks(cmd_arg_t * argv) { 889 int cmd_tasks(cmd_arg_t * argv) 890 { 874 891 task_print_list(); 875 892 return 1; … … 882 899 * @return Always 1 883 900 */ 884 int cmd_sched(cmd_arg_t * argv) { 901 int cmd_sched(cmd_arg_t * argv) 902 { 885 903 sched_print_list(); 886 904 return 1; … … 893 911 * return Always 1 894 912 */ 895 int cmd_zones(cmd_arg_t * argv) { 913 int cmd_zones(cmd_arg_t * argv) 914 { 896 915 zone_print_list(); 897 916 return 1; … … 904 923 * return Always 1 905 924 */ 906 int cmd_zone(cmd_arg_t * argv) { 925 int cmd_zone(cmd_arg_t * argv) 926 { 907 927 zone_print_one(argv[0].intval); 908 928 return 1; … … 915 935 * return Always 1 916 936 */ 917 int cmd_ipc(cmd_arg_t * argv) { 937 int cmd_ipc(cmd_arg_t * argv) 938 { 918 939 ipc_print_task(argv[0].intval); 919 940 return 1; 920 941 } 921 942 943 /** Command for killing a task 944 * 945 * @param argv Integer argument from cmdline expected 946 * 947 * return 0 on failure, 1 on success. 948 */ 949 int cmd_kill(cmd_arg_t * argv) 950 { 951 if (task_kill(argv[0].intval) != EOK) 952 return 0; 953 954 return 1; 955 } 922 956 923 957 /** Command for listing processors. -
kernel/generic/src/console/console.c
rfcbd1be r1787e527 71 71 72 72 /** Kernel log spinlock */ 73 SPINLOCK_ INITIALIZE(klog_lock);73 SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "*klog_lock"); 74 74 75 75 /** Physical memory area used for klog buffer */ 76 76 static parea_t klog_parea; 77 78 static indev_t stdin_sink; 79 static outdev_t stdout_source; 77 80 78 81 static indev_operations_t stdin_ops = { … … 80 83 }; 81 84 85 static void stdout_write(outdev_t *dev, wchar_t ch, bool silent); 86 static void stdout_redraw(outdev_t *dev); 87 88 static outdev_operations_t stdout_ops = { 89 .write = stdout_write, 90 .redraw = stdout_redraw 91 }; 92 82 93 /** Silence output */ 83 94 bool silent = false; … … 90 101 { 91 102 if (stdin == NULL) { 92 stdin = malloc(sizeof(indev_t), FRAME_ATOMIC); 93 if (stdin != NULL) 94 indev_initialize("stdin", stdin, &stdin_ops); 103 indev_initialize("stdin", &stdin_sink, &stdin_ops); 104 stdin = &stdin_sink; 95 105 } 96 106 97 107 return stdin; 108 } 109 110 void stdout_wire(outdev_t *outdev) 111 { 112 if (stdout == NULL) { 113 outdev_initialize("stdout", &stdout_source, &stdout_ops); 114 stdout = &stdout_source; 115 } 116 117 list_append(&outdev->link, &stdout->list); 118 } 119 120 static void stdout_write(outdev_t *dev, wchar_t ch, bool silent) 121 { 122 link_t *cur; 123 124 for (cur = dev->list.next; cur != &dev->list; cur = cur->next) { 125 outdev_t *sink = list_get_instance(cur, outdev_t, link); 126 if ((sink) && (sink->op->write)) 127 sink->op->write(sink, ch, silent); 128 } 129 } 130 131 static void stdout_redraw(outdev_t *dev) 132 { 133 link_t *cur; 134 135 for (cur = dev->list.next; cur != &dev->list; cur = cur->next) { 136 outdev_t *sink = list_get_instance(cur, outdev_t, link); 137 if ((sink) && (sink->op->redraw)) 138 sink->op->redraw(sink); 139 } 98 140 } 99 141 … … 128 170 129 171 silent = false; 130 arch_grab_console(); 172 if ((stdout) && (stdout->op->redraw)) 173 stdout->op->redraw(stdout); 131 174 132 175 /* Force the console to print the prompt */ … … 137 180 void release_console(void) 138 181 { 182 // FIXME arch_release_console 139 183 silent = true; 140 arch_release_console();141 184 } 142 185 … … 276 319 277 320 if (size > PAGE_SIZE) 278 return ELIMIT;321 return (unative_t) ELIMIT; 279 322 280 323 if (size > 0) { 281 324 data = (char *) malloc(size + 1, 0); 282 325 if (!data) 283 return ENOMEM;326 return (unative_t) ENOMEM; 284 327 285 328 rc = copy_from_uspace(data, buf, size); 286 329 if (rc) { 287 330 free(data); 288 return rc;331 return (unative_t) rc; 289 332 } 290 333 data[size] = 0; -
kernel/generic/src/ddi/ddi.c
rfcbd1be r1787e527 276 276 unative_t sys_preempt_control(int enable) 277 277 { 278 if (! cap_get(TASK) & CAP_PREEMPT_CONTROL)278 if (!(cap_get(TASK) & CAP_PREEMPT_CONTROL)) 279 279 return EPERM; 280 280 -
kernel/generic/src/ipc/kbox.c
rfcbd1be r1787e527 137 137 /* Only detach kbox thread unless already terminating. */ 138 138 mutex_lock(&TASK->kb.cleanup_lock); 139 if ( &TASK->kb.finished == false) {139 if (TASK->kb.finished == false) { 140 140 /* Detach kbox thread so it gets freed from memory. */ 141 141 thread_detach(TASK->kb.thread); -
kernel/generic/src/ipc/sysipc.c
rfcbd1be r1787e527 44 44 #include <ipc/ipcrsc.h> 45 45 #include <ipc/kbox.h> 46 #include <synch/waitq.h> 46 47 #include <udebug/udebug_ipc.h> 47 48 #include <arch/interrupt.h> … … 1051 1052 } 1052 1053 1054 /** Interrupt one thread from sys_ipc_wait_for_call(). */ 1055 unative_t sys_ipc_poke(void) 1056 { 1057 waitq_unsleep(&TASK->answerbox.wq); 1058 return EOK; 1059 } 1060 1053 1061 /** Connect an IRQ handler to a task. 1054 1062 * -
kernel/generic/src/main/main.c
rfcbd1be r1787e527 101 101 context_t ctx; 102 102 103 /*104 * These 'hardcoded' variables will be intialized by105 * the linker or the low level assembler code with106 * appropriate sizes and addresses.107 */108 109 /** Virtual address of where the kernel is loaded. */110 uintptr_t hardcoded_load_address = 0;111 /** Size of the kernel code in bytes. */112 size_t hardcoded_ktext_size = 0;113 /** Size of the kernel data in bytes. */114 size_t hardcoded_kdata_size = 0;115 103 /** Lowest safe stack virtual address. */ 116 104 uintptr_t stack_safe = 0; -
kernel/generic/src/printf/printf_core.c
rfcbd1be r1787e527 39 39 #include <printf/printf_core.h> 40 40 #include <print.h> 41 #include < arch/arg.h>41 #include <stdarg.h> 42 42 #include <macros.h> 43 43 #include <string.h> -
kernel/generic/src/printf/vprintf.c
rfcbd1be r1787e527 42 42 #include <string.h> 43 43 44 SPINLOCK_ INITIALIZE(printf_lock); /**< vprintf spinlock */44 SPINLOCK_STATIC_INITIALIZE_NAME(printf_lock, "*printf_lock"); 45 45 46 46 static int vprintf_str_write(const char *str, size_t size, void *data) -
kernel/generic/src/synch/spinlock.c
rfcbd1be r1787e527 45 45 #include <symtab.h> 46 46 47 #ifdef CONFIG_FB48 #include <genarch/fb/fb.h>49 #endif50 51 47 #ifdef CONFIG_SMP 52 48 53 49 /** Initialize spinlock 54 50 * 55 * Initialize spinlock.51 * @param sl Pointer to spinlock_t structure. 56 52 * 57 * @param sl Pointer to spinlock_t structure.58 53 */ 59 void spinlock_initialize(spinlock_t * sl, char *name)54 void spinlock_initialize(spinlock_t *lock, char *name) 60 55 { 61 atomic_set(& sl->val, 0);56 atomic_set(&lock->val, 0); 62 57 #ifdef CONFIG_DEBUG_SPINLOCK 63 sl->name = name;64 #endif 58 lock->name = name; 59 #endif 65 60 } 61 62 #ifdef CONFIG_DEBUG_SPINLOCK 66 63 67 64 /** Lock spinlock … … 71 68 * possible occurence of deadlock. 72 69 * 73 * @param sl Pointer to spinlock_t structure. 70 * @param lock Pointer to spinlock_t structure. 71 * 74 72 */ 75 #ifdef CONFIG_DEBUG_SPINLOCK 76 void spinlock_lock_debug(spinlock_t *sl) 73 void spinlock_lock_debug(spinlock_t *lock) 77 74 { 78 75 size_t i = 0; 79 76 bool deadlock_reported = false; 80 77 81 78 preemption_disable(); 82 while (test_and_set(&sl->val)) { 83 79 while (test_and_set(&lock->val)) { 84 80 /* 85 * We need to be careful about printf_lock and fb_lock. 86 * Both of them are used to report deadlocks via 87 * printf() and fb_putchar(). 81 * We need to be careful about particular locks 82 * which are directly used to report deadlocks 83 * via printf() (and recursively other functions). 84 * This conserns especially printf_lock and the 85 * framebuffer lock. 88 86 * 87 * Any lock whose name is prefixed by "*" will be 88 * ignored by this deadlock detection routine 89 * as this might cause an infinite recursion. 89 90 * We trust our code that there is no possible deadlock 90 * caused by these two locks (except when an exception 91 * is triggered for instance by printf() or fb_putchar()). 92 * However, we encountered false positives caused by very 93 * slow VESA framebuffer interaction (especially when 91 * caused by these locks (except when an exception 92 * is triggered for instance by printf()). 93 * 94 * We encountered false positives caused by very 95 * slow framebuffer interaction (especially when 94 96 * run in a simulator) that caused problems with both 95 * printf_lock and fb_lock.97 * printf_lock and the framebuffer lock. 96 98 * 97 * Possible deadlocks on both printf_lock and fb_lock98 * are therefore not reported as they would cause an99 * infinite recursion.100 99 */ 101 if ( sl == &printf_lock)100 if (lock->name[0] == '*') 102 101 continue; 103 #ifdef CONFIG_FB 104 if (sl == &fb_lock) 105 continue; 106 #endif 102 107 103 if (i++ > DEADLOCK_THRESHOLD) { 108 104 printf("cpu%u: looping on spinlock %" PRIp ":%s, " 109 "caller=%" PRIp "(%s)\n", CPU->id, sl, sl->name,105 "caller=%" PRIp "(%s)\n", CPU->id, lock, lock->name, 110 106 CALLER, symtab_fmt_name_lookup(CALLER)); 111 107 … … 114 110 } 115 111 } 116 112 117 113 if (deadlock_reported) 118 114 printf("cpu%u: not deadlocked\n", CPU->id); 119 115 120 116 /* 121 117 * Prevent critical section code from bleeding out this way up. … … 123 119 CS_ENTER_BARRIER(); 124 120 } 121 125 122 #endif 126 123 … … 131 128 * signal failure. 132 129 * 133 * @param slPointer to spinlock_t structure.130 * @param lock Pointer to spinlock_t structure. 134 131 * 135 132 * @return Zero on failure, non-zero otherwise. 133 * 136 134 */ 137 int spinlock_trylock(spinlock_t * sl)135 int spinlock_trylock(spinlock_t *lock) 138 136 { 139 int rc; 137 preemption_disable(); 138 int rc = !test_and_set(&lock->val); 140 139 141 preemption_disable();142 rc = !test_and_set(&sl->val);143 144 140 /* 145 141 * Prevent critical section code from bleeding out this way up. 146 142 */ 147 143 CS_ENTER_BARRIER(); 148 144 149 145 if (!rc) 150 146 preemption_enable(); -
kernel/generic/src/synch/waitq.c
rfcbd1be r1787e527 171 171 out: 172 172 spinlock_unlock(&threads_lock); 173 interrupts_restore(ipl); 174 } 175 176 /** Interrupt the first thread sleeping in the wait queue. 177 * 178 * Note that the caller somehow needs to know that the thread to be interrupted 179 * is sleeping interruptibly. 180 * 181 * @param wq Pointer to wait queue. 182 */ 183 void waitq_unsleep(waitq_t *wq) 184 { 185 ipl_t ipl; 186 187 ipl = interrupts_disable(); 188 spinlock_lock(&wq->lock); 189 190 if (!list_empty(&wq->head)) { 191 thread_t *t; 192 193 t = list_get_instance(wq->head.next, thread_t, wq_link); 194 spinlock_lock(&t->lock); 195 ASSERT(t->sleep_interruptible); 196 if (t->timeout_pending && timeout_unregister(&t->sleep_timeout)) 197 t->timeout_pending = false; 198 list_remove(&t->wq_link); 199 t->saved_context = t->sleep_interruption_context; 200 t->sleep_queue = NULL; 201 spinlock_unlock(&t->lock); 202 thread_ready(t); 203 } 204 205 spinlock_unlock(&wq->lock); 173 206 interrupts_restore(ipl); 174 207 } -
kernel/generic/src/syscall/syscall.c
rfcbd1be r1787e527 137 137 (syshandler_t) sys_ipc_forward_slow, 138 138 (syshandler_t) sys_ipc_wait_for_call, 139 (syshandler_t) sys_ipc_poke, 139 140 (syshandler_t) sys_ipc_hangup, 140 141 (syshandler_t) sys_ipc_register_irq, -
kernel/generic/src/sysinfo/sysinfo.c
rfcbd1be r1787e527 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 38 38 #include <syscall/copy.h> 39 39 40 bool fb_exported = false; 40 41 sysinfo_item_t *_root = NULL; 41 42 42 43 43 static sysinfo_item_t *sysinfo_find_item(const char *name, sysinfo_item_t *subtree)
Note:
See TracChangeset
for help on using the changeset viewer.
