Changeset 1787e527 in mainline for kernel/generic


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
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/chardev.h

    rfcbd1be r1787e527  
    3636#define KERN_CHARDEV_H_
    3737
     38#include <adt/list.h>
    3839#include <arch/types.h>
    3940#include <synch/waitq.h>
     
    7374        /** Write character to output. */
    7475        void (* write)(struct outdev *, wchar_t, bool);
     76       
     77        /** Redraw any previously cached characters. */
     78        void (* redraw)(struct outdev *);
    7579} outdev_operations_t;
    7680
    77 /** Character input device. */
     81/** Character output device. */
    7882typedef struct outdev {
    7983        char *name;
     
    8185        /** Protects everything below. */
    8286        SPINLOCK_DECLARE(lock);
     87       
     88        /** Fields suitable for multiplexing. */
     89        link_t link;
     90        link_t list;
    8391       
    8492        /** Implementation of outdev operations. */
  • kernel/generic/include/console/console.h

    rfcbd1be r1787e527  
    4444
    4545extern indev_t *stdin_wire(void);
     46extern void stdout_wire(outdev_t *outdev);
    4647extern void console_init(void);
    4748
     
    5960extern unative_t sys_debug_disable_console(void);
    6061
    61 extern void arch_grab_console(void);
    62 extern void arch_release_console(void);
    63 
    6462#endif /* KERN_CONSOLE_H_ */
    6563
  • kernel/generic/include/context.h

    rfcbd1be r1787e527  
    5151/** Save register context.
    5252 *
    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
    5755 * address as the corresponding call to context_save().
    5856 *
    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:
    6259 *
    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.
    6465 *
    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.
    6678 */
    6779#define context_save(c)   context_save_arch(c)
     
    6981/** Restore register context.
    7082 *
    71  * Restore previously saved register context (including stack pointers)
    72  * from context structure.
     83 * Restore a previously saved register context (including stack pointer) from
     84 * a context structure.
    7385 *
    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.
    7889 *
    79  * @param c Context structure.
     90 * @param c             Context structure.
    8091 */
    8192static inline void context_restore(context_t *c)
  • kernel/generic/include/ddi/irq.h

    rfcbd1be r1787e527  
    3737
    3838typedef enum {
     39        /** Read 1 byte from the I/O space. */
    3940        CMD_PIO_READ_8 = 1,
     41        /** Read 2 bytes from the I/O space. */
    4042        CMD_PIO_READ_16,
     43        /** Read 4 bytes from the I/O space. */
    4144        CMD_PIO_READ_32,
     45        /** Write 1 byte to the I/O space. */
    4246        CMD_PIO_WRITE_8,
     47        /** Write 2 bytes to the I/O space. */
    4348        CMD_PIO_WRITE_16,
     49        /** Write 4 bytes to the I/O space. */
    4450        CMD_PIO_WRITE_32,
     51        /**
     52         * Perform a bit test on the source argument and store the result into
     53         * the destination argument.
     54         */
    4555        CMD_BTEST,
     56        /**
     57         * Predicate the execution of the following N commands by the boolean
     58         * value of the source argument.
     59         */
    4660        CMD_PREDICATE,
     61        /** Accept the interrupt. */
    4762        CMD_ACCEPT,
     63        /** Decline the interrupt. */
    4864        CMD_DECLINE,
    4965        CMD_LAST
  • kernel/generic/include/ipc/sysipc.h

    rfcbd1be r1787e527  
    5252unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
    5353    int nonblocking);
     54unative_t sys_ipc_poke(void);
    5455unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
    5556    unative_t method, unative_t arg1, unative_t arg2, int mode);
  • kernel/generic/include/main/main.h

    rfcbd1be r1787e527  
    3838#include <arch/types.h>
    3939
     40extern size_t hardcoded_kdata_size;
     41extern size_t hardcoded_ktext_size;
     42extern uintptr_t hardcoded_load_address;
    4043extern uintptr_t stack_safe;
    4144
  • kernel/generic/include/print.h

    rfcbd1be r1787e527  
    3737
    3838#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>
    4440
    4541#define EOF (-1)
  • kernel/generic/include/printf/printf_core.h

    rfcbd1be r1787e527  
    3737
    3838#include <typedefs.h>
    39 #include <arch/arg.h>
     39#include <stdarg.h>
    4040
    4141/** Structure for specifying output methods for different printf clones. */
  • kernel/generic/include/stdarg.h

    rfcbd1be r1787e527  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3737 * for all architectures with compiler support for __builtin_va_*.
    3838 */
    39  
     39
    4040#ifndef KERN_STDARG_H_
    4141#define KERN_STDARG_H_
     
    4343typedef __builtin_va_list va_list;
    4444
    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)
    4949
    5050#endif
  • kernel/generic/include/synch/spinlock.h

    rfcbd1be r1787e527  
    4343
    4444#ifdef CONFIG_SMP
     45
    4546typedef struct {
     47        atomic_t val;
     48       
    4649#ifdef CONFIG_DEBUG_SPINLOCK
    4750        char *name;
    4851#endif
    49         atomic_t val;
    5052} spinlock_t;
    5153
     
    5456 * where the lock gets initialized in run time.
    5557 */
    56 #define SPINLOCK_DECLARE(slname)        spinlock_t slname
    57 #define SPINLOCK_EXTERN(slname)         extern spinlock_t slname
     58#define SPINLOCK_DECLARE(lock_name)  spinlock_t lock_name
     59#define SPINLOCK_EXTERN(lock_name)   extern spinlock_t lock_name
    5860
    5961/*
     
    6264 */
    6365#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 } \
    6871        }
     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
    6981#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 } \
    7386        }
     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
    7495#endif
    7596
    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)
    7999
    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
     103extern void spinlock_initialize(spinlock_t *lock, char *name);
     104extern int spinlock_trylock(spinlock_t *lock);
     105extern void spinlock_lock_debug(spinlock_t *lock);
    85106
    86107/** Unlock spinlock
     
    90111 * @param sl Pointer to spinlock_t structure.
    91112 */
    92 static inline void spinlock_unlock(spinlock_t *sl)
     113static inline void spinlock_unlock(spinlock_t *lock)
    93114{
    94         ASSERT(atomic_get(&sl->val) != 0);
    95 
     115        ASSERT(atomic_get(&lock->val) != 0);
     116       
    96117        /*
    97118         * Prevent critical section code from bleeding out this way down.
     
    99120        CS_LEAVE_BARRIER();
    100121       
    101         atomic_set(&sl->val, 0);
     122        atomic_set(&lock->val, 0);
    102123        preemption_enable();
    103124}
     
    105126#ifdef CONFIG_DEBUG_SPINLOCK
    106127
    107 extern int printf(const char *, ...);
     128#include <print.h>
    108129
    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__); \
    117140        }
    118 #else
    119 #define DEADLOCK_PROBE_INIT(pname)
    120 #define DEADLOCK_PROBE(pname, value)
    121 #endif
    122141
    123142#else
    124143
     144#define DEADLOCK_PROBE_INIT(pname)
     145#define DEADLOCK_PROBE(pname, value)
     146
     147#endif
     148
     149#else /* CONFIG_SMP */
     150
    125151/* On UP systems, spinlocks are effectively left out. */
     152
    126153#define SPINLOCK_DECLARE(name)
    127154#define SPINLOCK_EXTERN(name)
     155
    128156#define SPINLOCK_INITIALIZE(name)
     157#define SPINLOCK_STATIC_INITIALIZE(name)
    129158
    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()
    134167
    135168#define DEADLOCK_PROBE_INIT(pname)
  • kernel/generic/include/synch/waitq.h

    rfcbd1be r1787e527  
    6868struct thread;
    6969
    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);
     70extern void waitq_initialize(waitq_t *);
     71extern int waitq_sleep_timeout(waitq_t *, uint32_t, int);
     72extern ipl_t waitq_sleep_prepare(waitq_t *);
     73extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int);
     74extern void waitq_sleep_finish(waitq_t *, int, ipl_t);
     75extern void waitq_wakeup(waitq_t *, wakeup_mode_t);
     76extern void _waitq_wakeup_unsafe(waitq_t *, wakeup_mode_t);
     77extern void waitq_interrupt_sleep(struct thread *);
     78extern void waitq_unsleep(waitq_t *);
    7879
    7980#endif
  • kernel/generic/include/syscall/syscall.h

    rfcbd1be r1787e527  
    6666        SYS_IPC_FORWARD_SLOW,
    6767        SYS_IPC_WAIT,
     68        SYS_IPC_POKE,
    6869        SYS_IPC_HANGUP,
    6970        SYS_IPC_REGISTER_IRQ,
  • kernel/generic/include/sysinfo/sysinfo.h

    rfcbd1be r1787e527  
    3838#include <arch/types.h>
    3939#include <string.h>
     40
     41extern bool fb_exported;
    4042
    4143typedef union sysinfo_item_val {
  • 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.