Changeset 1787e527 in mainline for kernel/generic/src


Ignore:
Timestamp:
2009-11-16T21:22:54Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
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.
Message:

merged with head (unstable)

Location:
kernel/generic/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/chardev.c

    rfcbd1be r1787e527  
    3333 */
    3434
     35#include <adt/list.h>
    3536#include <console/chardev.h>
    3637#include <synch/waitq.h>
     
    134135        outdev->name = name;
    135136        spinlock_initialize(&outdev->lock, "outdev");
     137        link_initialize(&outdev->link);
     138        list_initialize(&outdev->list);
    136139        outdev->op = op;
    137140}
  • kernel/generic/src/console/cmd.c

    rfcbd1be r1787e527  
    409409};
    410410
     411/* Data and methods for 'kill' command */
     412static int cmd_kill(cmd_arg_t *argv);
     413static cmd_arg_t kill_argv = {
     414        .type = ARG_TYPE_INT,
     415};
     416static 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
    411424/* Data and methods for 'zone' command */
    412425static int cmd_zone(cmd_arg_t *argv);
     
    459472        &help_info,
    460473        &ipc_info,
     474        &kill_info,
    461475        &set4_info,
    462476        &slabs_info,
     
    848862 * @return Always 1
    849863 */
    850 int cmd_slabs(cmd_arg_t * argv) {
     864int cmd_slabs(cmd_arg_t * argv)
     865{
    851866        slab_print_list();
    852867        return 1;
     
    860875 * @return Always 1
    861876 */
    862 int cmd_threads(cmd_arg_t * argv) {
     877int cmd_threads(cmd_arg_t * argv)
     878{
    863879        thread_print_list();
    864880        return 1;
     
    871887 * @return Always 1
    872888 */
    873 int cmd_tasks(cmd_arg_t * argv) {
     889int cmd_tasks(cmd_arg_t * argv)
     890{
    874891        task_print_list();
    875892        return 1;
     
    882899 * @return Always 1
    883900 */
    884 int cmd_sched(cmd_arg_t * argv) {
     901int cmd_sched(cmd_arg_t * argv)
     902{
    885903        sched_print_list();
    886904        return 1;
     
    893911 * return Always 1
    894912 */
    895 int cmd_zones(cmd_arg_t * argv) {
     913int cmd_zones(cmd_arg_t * argv)
     914{
    896915        zone_print_list();
    897916        return 1;
     
    904923 * return Always 1
    905924 */
    906 int cmd_zone(cmd_arg_t * argv) {
     925int cmd_zone(cmd_arg_t * argv)
     926{
    907927        zone_print_one(argv[0].intval);
    908928        return 1;
     
    915935 * return Always 1
    916936 */
    917 int cmd_ipc(cmd_arg_t * argv) {
     937int cmd_ipc(cmd_arg_t * argv)
     938{
    918939        ipc_print_task(argv[0].intval);
    919940        return 1;
    920941}
    921942
     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 */
     949int cmd_kill(cmd_arg_t * argv)
     950{
     951        if (task_kill(argv[0].intval) != EOK)
     952                return 0;
     953
     954        return 1;
     955}
    922956
    923957/** Command for listing processors.
  • kernel/generic/src/console/console.c

    rfcbd1be r1787e527  
    7171
    7272/** Kernel log spinlock */
    73 SPINLOCK_INITIALIZE(klog_lock);
     73SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "*klog_lock");
    7474
    7575/** Physical memory area used for klog buffer */
    7676static parea_t klog_parea;
     77
     78static indev_t stdin_sink;
     79static outdev_t stdout_source;
    7780
    7881static indev_operations_t stdin_ops = {
     
    8083};
    8184
     85static void stdout_write(outdev_t *dev, wchar_t ch, bool silent);
     86static void stdout_redraw(outdev_t *dev);
     87
     88static outdev_operations_t stdout_ops = {
     89        .write = stdout_write,
     90        .redraw = stdout_redraw
     91};
     92
    8293/** Silence output */
    8394bool silent = false;
     
    90101{
    91102        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;
    95105        }
    96106       
    97107        return stdin;
     108}
     109
     110void 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
     120static 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
     131static 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        }
    98140}
    99141
     
    128170       
    129171        silent = false;
    130         arch_grab_console();
     172        if ((stdout) && (stdout->op->redraw))
     173                stdout->op->redraw(stdout);
    131174       
    132175        /* Force the console to print the prompt */
     
    137180void release_console(void)
    138181{
     182        // FIXME arch_release_console
    139183        silent = true;
    140         arch_release_console();
    141184}
    142185
     
    276319       
    277320        if (size > PAGE_SIZE)
    278                 return ELIMIT;
     321                return (unative_t) ELIMIT;
    279322       
    280323        if (size > 0) {
    281324                data = (char *) malloc(size + 1, 0);
    282325                if (!data)
    283                         return ENOMEM;
     326                        return (unative_t) ENOMEM;
    284327               
    285328                rc = copy_from_uspace(data, buf, size);
    286329                if (rc) {
    287330                        free(data);
    288                         return rc;
     331                        return (unative_t) rc;
    289332                }
    290333                data[size] = 0;
  • kernel/generic/src/ddi/ddi.c

    rfcbd1be r1787e527  
    276276unative_t sys_preempt_control(int enable)
    277277{
    278         if (!cap_get(TASK) & CAP_PREEMPT_CONTROL)
     278        if (!(cap_get(TASK) & CAP_PREEMPT_CONTROL))
    279279                return EPERM;
    280280       
  • kernel/generic/src/ipc/kbox.c

    rfcbd1be r1787e527  
    137137                /* Only detach kbox thread unless already terminating. */
    138138                mutex_lock(&TASK->kb.cleanup_lock);
    139                 if (&TASK->kb.finished == false) {
     139                if (TASK->kb.finished == false) {
    140140                        /* Detach kbox thread so it gets freed from memory. */
    141141                        thread_detach(TASK->kb.thread);
  • kernel/generic/src/ipc/sysipc.c

    rfcbd1be r1787e527  
    4444#include <ipc/ipcrsc.h>
    4545#include <ipc/kbox.h>
     46#include <synch/waitq.h>
    4647#include <udebug/udebug_ipc.h>
    4748#include <arch/interrupt.h>
     
    10511052}
    10521053
     1054/** Interrupt one thread from sys_ipc_wait_for_call(). */
     1055unative_t sys_ipc_poke(void)
     1056{
     1057        waitq_unsleep(&TASK->answerbox.wq);     
     1058        return EOK;
     1059}
     1060
    10531061/** Connect an IRQ handler to a task.
    10541062 *
  • kernel/generic/src/main/main.c

    rfcbd1be r1787e527  
    101101context_t ctx;
    102102
    103 /*
    104  * These 'hardcoded' variables will be intialized by
    105  * the linker or the low level assembler code with
    106  * 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;
    115103/** Lowest safe stack virtual address. */
    116104uintptr_t stack_safe = 0;               
  • kernel/generic/src/printf/printf_core.c

    rfcbd1be r1787e527  
    3939#include <printf/printf_core.h>
    4040#include <print.h>
    41 #include <arch/arg.h>
     41#include <stdarg.h>
    4242#include <macros.h>
    4343#include <string.h>
  • kernel/generic/src/printf/vprintf.c

    rfcbd1be r1787e527  
    4242#include <string.h>
    4343
    44 SPINLOCK_INITIALIZE(printf_lock);  /**< vprintf spinlock */
     44SPINLOCK_STATIC_INITIALIZE_NAME(printf_lock, "*printf_lock");
    4545
    4646static int vprintf_str_write(const char *str, size_t size, void *data)
  • kernel/generic/src/synch/spinlock.c

    rfcbd1be r1787e527  
    4545#include <symtab.h>
    4646
    47 #ifdef CONFIG_FB
    48 #include <genarch/fb/fb.h>
    49 #endif
    50 
    5147#ifdef CONFIG_SMP
    5248
    5349/** Initialize spinlock
    5450 *
    55  * Initialize spinlock.
     51 * @param sl Pointer to spinlock_t structure.
    5652 *
    57  * @param sl Pointer to spinlock_t structure.
    5853 */
    59 void spinlock_initialize(spinlock_t *sl, char *name)
     54void spinlock_initialize(spinlock_t *lock, char *name)
    6055{
    61         atomic_set(&sl->val, 0);
     56        atomic_set(&lock->val, 0);
    6257#ifdef CONFIG_DEBUG_SPINLOCK
    63         sl->name = name;
    64 #endif 
     58        lock->name = name;
     59#endif
    6560}
     61
     62#ifdef CONFIG_DEBUG_SPINLOCK
    6663
    6764/** Lock spinlock
     
    7168 * possible occurence of deadlock.
    7269 *
    73  * @param sl Pointer to spinlock_t structure.
     70 * @param lock Pointer to spinlock_t structure.
     71 *
    7472 */
    75 #ifdef CONFIG_DEBUG_SPINLOCK
    76 void spinlock_lock_debug(spinlock_t *sl)
     73void spinlock_lock_debug(spinlock_t *lock)
    7774{
    7875        size_t i = 0;
    7976        bool deadlock_reported = false;
    80 
     77       
    8178        preemption_disable();
    82         while (test_and_set(&sl->val)) {
    83 
     79        while (test_and_set(&lock->val)) {
    8480                /*
    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.
    8886                 *
     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.
    8990                 * 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
    9496                 * run in a simulator) that caused problems with both
    95                  * printf_lock and fb_lock.
     97                 * printf_lock and the framebuffer lock.
    9698                 *
    97                  * Possible deadlocks on both printf_lock and fb_lock
    98                  * are therefore not reported as they would cause an
    99                  * infinite recursion.
    10099                 */
    101                 if (sl == &printf_lock)
     100                if (lock->name[0] == '*')
    102101                        continue;
    103 #ifdef CONFIG_FB
    104                 if (sl == &fb_lock)
    105                         continue;
    106 #endif
     102               
    107103                if (i++ > DEADLOCK_THRESHOLD) {
    108104                        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,
    110106                            CALLER, symtab_fmt_name_lookup(CALLER));
    111107                       
     
    114110                }
    115111        }
    116 
     112       
    117113        if (deadlock_reported)
    118114                printf("cpu%u: not deadlocked\n", CPU->id);
    119 
     115       
    120116        /*
    121117         * Prevent critical section code from bleeding out this way up.
     
    123119        CS_ENTER_BARRIER();
    124120}
     121
    125122#endif
    126123
     
    131128 * signal failure.
    132129 *
    133  * @param sl Pointer to spinlock_t structure.
     130 * @param lock Pointer to spinlock_t structure.
    134131 *
    135132 * @return Zero on failure, non-zero otherwise.
     133 *
    136134 */
    137 int spinlock_trylock(spinlock_t *sl)
     135int spinlock_trylock(spinlock_t *lock)
    138136{
    139         int rc;
     137        preemption_disable();
     138        int rc = !test_and_set(&lock->val);
    140139       
    141         preemption_disable();
    142         rc = !test_and_set(&sl->val);
    143 
    144140        /*
    145141         * Prevent critical section code from bleeding out this way up.
    146142         */
    147143        CS_ENTER_BARRIER();
    148 
     144       
    149145        if (!rc)
    150146                preemption_enable();
  • kernel/generic/src/synch/waitq.c

    rfcbd1be r1787e527  
    171171out:
    172172        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 */
     183void 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);
    173206        interrupts_restore(ipl);
    174207}
  • kernel/generic/src/syscall/syscall.c

    rfcbd1be r1787e527  
    137137        (syshandler_t) sys_ipc_forward_slow,
    138138        (syshandler_t) sys_ipc_wait_for_call,
     139        (syshandler_t) sys_ipc_poke,
    139140        (syshandler_t) sys_ipc_hangup,
    140141        (syshandler_t) sys_ipc_register_irq,
  • kernel/generic/src/sysinfo/sysinfo.c

    rfcbd1be r1787e527  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3838#include <syscall/copy.h>
    3939
     40bool fb_exported = false;
    4041sysinfo_item_t *_root = NULL;
    41 
    4242
    4343static sysinfo_item_t *sysinfo_find_item(const char *name, sysinfo_item_t *subtree)
Note: See TracChangeset for help on using the changeset viewer.