Changeset 1787e527 in mainline for kernel/generic/src
- 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/src
- Files:
-
- 13 edited
-
console/chardev.c (modified) (2 diffs)
-
console/cmd.c (modified) (9 diffs)
-
console/console.c (modified) (6 diffs)
-
ddi/ddi.c (modified) (1 diff)
-
ipc/kbox.c (modified) (1 diff)
-
ipc/sysipc.c (modified) (2 diffs)
-
main/main.c (modified) (1 diff)
-
printf/printf_core.c (modified) (1 diff)
-
printf/vprintf.c (modified) (1 diff)
-
synch/spinlock.c (modified) (5 diffs)
-
synch/waitq.c (modified) (1 diff)
-
syscall/syscall.c (modified) (1 diff)
-
sysinfo/sysinfo.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
