Changeset 04803bf in mainline for kernel/generic/include


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (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:

Merge mainline changes (needs fixes).

Location:
kernel/generic/include
Files:
6 added
73 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/avl.h

    rb50b5af2 r04803bf  
    3434
    3535#ifndef KERN_AVLTREE_H_
    36 #define KERN_AVLTREE_H_ 
     36#define KERN_AVLTREE_H_
    3737
    38 #include <arch/types.h>
    3938#include <typedefs.h>
     39#include <trace.h>
    4040
    4141/**
     
    111111 * @param t AVL tree.
    112112 */
    113 static inline void avltree_create(avltree_t *t)
     113NO_TRACE static inline void avltree_create(avltree_t *t)
    114114{
    115115        t->root = NULL;
     
    121121 * @param node Node which is initialized.
    122122 */
    123 static inline void avltree_node_initialize(avltree_node_t *node)
     123NO_TRACE static inline void avltree_node_initialize(avltree_node_t *node)
    124124{
    125125        node->key = 0;
  • kernel/generic/include/adt/bitmap.h

    rb50b5af2 r04803bf  
    3636#define KERN_BITMAP_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040#define BITS2BYTES(bits)        (bits ? ((((bits)-1)>>3)+1) : 0)
  • kernel/generic/include/adt/btree.h

    rb50b5af2 r04803bf  
    3636#define KERN_BTREE_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <adt/list.h>
    4040
  • kernel/generic/include/adt/hash_table.h

    rb50b5af2 r04803bf  
    3737
    3838#include <adt/list.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141/** Set of operations for hash table. */
     
    4848         * @return Index into hash table.
    4949         */
    50         size_t (* hash)(unative_t key[]);
     50        size_t (* hash)(sysarg_t key[]);
    5151       
    5252        /** Hash table item comparison function.
     
    5757         * @return true if the keys match, false otherwise.
    5858         */
    59         bool (*compare)(unative_t key[], size_t keys, link_t *item);
     59        bool (*compare)(sysarg_t key[], size_t keys, link_t *item);
    6060
    6161        /** Hash table item removal callback.
     
    7979extern void hash_table_create(hash_table_t *h, size_t m, size_t max_keys,
    8080    hash_table_operations_t *op);
    81 extern void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item);
    82 extern link_t *hash_table_find(hash_table_t *h, unative_t key[]);
    83 extern void hash_table_remove(hash_table_t *h, unative_t key[], size_t keys);
     81extern void hash_table_insert(hash_table_t *h, sysarg_t key[], link_t *item);
     82extern link_t *hash_table_find(hash_table_t *h, sysarg_t key[]);
     83extern void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys);
    8484
    8585#endif
  • kernel/generic/include/adt/list.h

    rb50b5af2 r04803bf  
    3636#define KERN_LIST_H_
    3737
    38 #include <arch/types.h>
    3938#include <typedefs.h>
     39#include <trace.h>
    4040
    4141/** Doubly linked list head and link type. */
     
    5858 * @param link Pointer to link_t structure to be initialized.
    5959 */
    60 static inline void link_initialize(link_t *link)
     60NO_TRACE static inline void link_initialize(link_t *link)
    6161{
    6262        link->prev = NULL;
     
    7070 * @param head Pointer to link_t structure representing head of the list.
    7171 */
    72 static inline void list_initialize(link_t *head)
     72NO_TRACE static inline void list_initialize(link_t *head)
    7373{
    7474        head->prev = head;
     
    8383 * @param head Pointer to link_t structure representing head of the list.
    8484 */
    85 static inline void list_prepend(link_t *link, link_t *head)
     85NO_TRACE static inline void list_prepend(link_t *link, link_t *head)
    8686{
    8787        link->next = head->next;
     
    9898 * @param head Pointer to link_t structure representing head of the list.
    9999 */
    100 static inline void list_append(link_t *link, link_t *head)
     100NO_TRACE static inline void list_append(link_t *link, link_t *head)
    101101{
    102102        link->prev = head->prev;
     
    113113 *              contained in.
    114114 */
    115 static inline void list_remove(link_t *link)
     115NO_TRACE static inline void list_remove(link_t *link)
    116116{
    117117        link->next->prev = link->prev;
     
    126126 * @param head Pointer to link_t structure representing head of the list.
    127127 */
    128 static inline bool list_empty(link_t *head)
     128NO_TRACE static inline bool list_empty(link_t *head)
    129129{
    130130        return head->next == head ? true : false;
     
    144144 *              headless) list.
    145145 */
    146 static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
     146NO_TRACE static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
    147147{
    148148        link_t *hlp;
     
    165165 *              headless list.
    166166 */
    167 static inline void headless_list_split(link_t *part1, link_t *part2)
     167NO_TRACE static inline void headless_list_split(link_t *part1, link_t *part2)
    168168{
    169169        headless_list_split_or_concat(part1, part2);
     
    177177 * @param part2 Pointer to link_t structure leading the second headless list.
    178178 */
    179 static inline void headless_list_concat(link_t *part1, link_t *part2)
     179NO_TRACE static inline void headless_list_concat(link_t *part1, link_t *part2)
    180180{
    181181        headless_list_split_or_concat(part1, part2);
  • kernel/generic/include/arch.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3939#include <proc/thread.h>
    4040#include <proc/task.h>
     41#include <mm/as.h>
    4142
    42 #define DEFAULT_CONTEXT         0
     43#define DEFAULT_CONTEXT  0
    4344
    44 #define CPU                     THE->cpu
    45 #define THREAD                  THE->thread
    46 #define TASK                    THE->task
    47 #define AS                      THE->as
    48 #define CONTEXT         (THE->task ? THE->task->context : DEFAULT_CONTEXT)
    49 #define PREEMPTION_DISABLED     THE->preemption_disabled
     45#define CPU                  THE->cpu
     46#define THREAD               THE->thread
     47#define TASK                 THE->task
     48#define AS                   THE->as
     49#define CONTEXT              (THE->task ? THE->task->context : DEFAULT_CONTEXT)
     50#define PREEMPTION_DISABLED  THE->preemption_disabled
    5051
    51 #define context_check(ctx1, ctx2)       ((ctx1) == (ctx2))
     52#define context_check(ctx1, ctx2)  ((ctx1) == (ctx2))
    5253
    5354/**
     
    5758 */
    5859typedef struct {
    59         size_t preemption_disabled;     /**< Preemption disabled counter. */
    60         thread_t *thread;               /**< Current thread. */
    61         task_t *task;                   /**< Current task. */
    62         cpu_t *cpu;                     /**< Executing cpu. */
    63         as_t *as;                       /**< Current address space. */
     60        size_t preemption_disabled;  /**< Preemption disabled counter. */
     61        thread_t *thread;            /**< Current thread. */
     62        task_t *task;                /**< Current task. */
     63        cpu_t *cpu;                  /**< Executing cpu. */
     64        as_t *as;                    /**< Current address space. */
    6465} the_t;
    6566
     67/*
     68 * THE is not an abbreviation, but the English definite article written in
     69 * capital letters. It means the current pointer to something, e.g. thread,
     70 * processor or address space. Kind reader of this comment shall appreciate
     71 * the wit of constructs like THE->thread and similar.
     72 */
    6673#define THE  ((the_t * )(get_stack_base()))
    6774
    68 extern void the_initialize(the_t *the);
    69 extern void the_copy(the_t *src, the_t *dst);
     75extern void the_initialize(the_t *);
     76extern void the_copy(the_t *, the_t *);
    7077
    7178extern void arch_pre_mm_init(void);
     
    7986extern void reboot(void);
    8087extern void arch_reboot(void);
    81 extern void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller);
     88extern void *arch_construct_function(fncptr_t *, void *, void *);
    8289
    8390#endif
  • kernel/generic/include/atomic.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_ATOMIC_H_
    3737
    38 typedef struct atomic {
    39         volatile long count;
    40 } atomic_t;
     38#include <typedefs.h>
     39#include <arch/atomic.h>
     40#include <verify.h>
    4141
    42 #include <arch/atomic.h>
    43 
    44 static inline void atomic_set(atomic_t *val, long i)
     42NO_TRACE ATOMIC static inline void atomic_set(atomic_t *val, atomic_count_t i)
     43    WRITES(&val->count)
     44    REQUIRES_EXTENT_MUTABLE(val)
    4545{
    4646        val->count = i;
    4747}
    4848
    49 static inline long atomic_get(atomic_t *val)
     49NO_TRACE ATOMIC static inline atomic_count_t atomic_get(atomic_t *val)
     50    REQUIRES_EXTENT_MUTABLE(val)
    5051{
    5152        return val->count;
  • kernel/generic/include/bitops.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_BITOPS_H_
    3737
     38#include <trace.h>
    3839
    39 /** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
     40#ifdef __32_BITS__
     41        #define fnzb(arg)  fnzb32(arg)
     42#endif
     43
     44#ifdef __64_BITS__
     45        #define fnzb(arg)  fnzb64(arg)
     46#endif
     47
     48/** Return position of first non-zero bit from left (32b variant).
    4049 *
    41  * If number is zero, it returns 0
     50 * @return 0 (if the number is zero) or [log_2(arg)].
     51 *
    4252 */
    43 static inline int fnzb32(uint32_t arg)
     53NO_TRACE static inline uint8_t fnzb32(uint32_t arg)
    4454{
    45         int n = 0;
    46 
     55        uint8_t n = 0;
     56       
    4757        if (arg >> 16) {
    4858                arg >>= 16;
     
    6575        }
    6676       
    67         if (arg >> 1) {
    68                 arg >>= 1;
     77        if (arg >> 1)
    6978                n += 1;
    70         }
    7179       
    7280        return n;
    7381}
    7482
    75 static inline int fnzb64(uint64_t arg)
     83/** Return position of first non-zero bit from left (64b variant).
     84 *
     85 * @return 0 (if the number is zero) or [log_2(arg)].
     86 *
     87 */
     88NO_TRACE static inline uint8_t fnzb64(uint64_t arg)
    7689{
    77         int n = 0;
    78 
     90        uint8_t n = 0;
     91       
    7992        if (arg >> 32) {
    8093                arg >>= 32;
     
    8598}
    8699
    87 #define fnzb(x) fnzb32(x)
    88 
    89100#endif
    90101
  • kernel/generic/include/byteorder.h

    rb50b5af2 r04803bf  
    3636#define KERN_BYTEORDER_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040#if !(defined(__BE__) ^ defined(__LE__))
  • kernel/generic/include/config.h

    rb50b5af2 r04803bf  
    3636#define KERN_CONFIG_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <arch/mm/page.h>
    4040
     
    6666
    6767typedef struct {
    68         size_t cpu_count;            /**< Number of processors detected. */
     68        unsigned int cpu_count;      /**< Number of processors detected. */
    6969        volatile size_t cpu_active;  /**< Number of processors that are up and running. */
    7070       
    7171        uintptr_t base;
    72         size_t kernel_size;           /**< Size of memory in bytes taken by kernel and stack */
     72        size_t kernel_size;          /**< Size of memory in bytes taken by kernel and stack */
    7373       
    74         uintptr_t stack_base;         /**< Base adddress of initial stack */
    75         size_t stack_size;            /**< Size of initial stack */
     74        uintptr_t stack_base;        /**< Base adddress of initial stack */
     75        size_t stack_size;           /**< Size of initial stack */
    7676} config_t;
    7777
  • kernel/generic/include/console/chardev.h

    rb50b5af2 r04803bf  
    3737
    3838#include <adt/list.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <synch/waitq.h>
    4141#include <synch/spinlock.h>
     
    5353/** Character input device. */
    5454typedef struct indev {
    55         char *name;
     55        const char *name;
    5656        waitq_t wq;
    5757       
    5858        /** Protects everything below. */
    59         SPINLOCK_DECLARE(lock);
     59        IRQ_SPINLOCK_DECLARE(lock);
    6060        wchar_t buffer[INDEV_BUFLEN];
    6161        size_t counter;
     
    8181/** Character output device. */
    8282typedef struct outdev {
    83         char *name;
     83        const char *name;
    8484       
    8585        /** Protects everything below. */
     
    9595} outdev_t;
    9696
    97 extern void indev_initialize(char *name, indev_t *indev,
    98     indev_operations_t *op);
    99 extern void indev_push_character(indev_t *indev, wchar_t ch);
    100 extern wchar_t indev_pop_character(indev_t *indev);
     97extern void indev_initialize(const char *, indev_t *,
     98    indev_operations_t *);
     99extern void indev_push_character(indev_t *, wchar_t);
     100extern wchar_t indev_pop_character(indev_t *);
    101101
    102 extern void outdev_initialize(char *name, outdev_t *outdev,
    103     outdev_operations_t *op);
     102extern void outdev_initialize(const char *, outdev_t *,
     103    outdev_operations_t *);
    104104
    105 extern bool check_poll(indev_t *indev);
     105extern bool check_poll(indev_t *);
    106106
    107107#endif /* KERN_CHARDEV_H_ */
  • kernel/generic/include/console/console.h

    rb50b5af2 r04803bf  
    3636#define KERN_CONSOLE_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
     39#include <print.h>
    3940#include <console/chardev.h>
     41
     42#define PAGING(counter, increment, before, after) \
     43        do { \
     44                (counter) += (increment); \
     45                if ((counter) > 23) { \
     46                        before; \
     47                        printf(" -- Press any key to continue -- "); \
     48                        indev_pop_character(stdin); \
     49                        after; \
     50                        printf("\n"); \
     51                        (counter) = 0; \
     52                } \
     53        } while (0)
    4054
    4155extern indev_t *stdin;
    4256extern outdev_t *stdout;
    43 extern bool silent;
     57
     58extern void early_putchar(wchar_t);
    4459
    4560extern indev_t *stdin_wire(void);
     
    5267extern wchar_t getc(indev_t *indev);
    5368extern size_t gets(indev_t *indev, char *buf, size_t buflen);
    54 extern unative_t sys_klog(int fd, const void *buf, size_t size);
     69extern sysarg_t sys_klog(int fd, const void *buf, size_t size);
    5570
    5671extern void grab_console(void);
    5772extern void release_console(void);
    5873
    59 extern unative_t sys_debug_enable_console(void);
    60 extern unative_t sys_debug_disable_console(void);
     74extern sysarg_t sys_debug_enable_console(void);
     75extern sysarg_t sys_debug_disable_console(void);
    6176
    6277#endif /* KERN_CONSOLE_H_ */
  • kernel/generic/include/console/kconsole.h

    rb50b5af2 r04803bf  
    4747        ARG_TYPE_INT,
    4848        ARG_TYPE_STRING,
     49        /** Optional string */
     50        ARG_TYPE_STRING_OPTIONAL,
    4951        /** Variable type - either symbol or string. */
    5052        ARG_TYPE_VAR
     
    6062        size_t len;
    6163        /** Integer value. */
    62         unative_t intval;
     64        sysarg_t intval;
    6365        /** Resulting type of variable arg */
    6466        cmd_arg_type_t vartype;
     
    9496extern void kconsole_notify_init(void);
    9597extern bool kconsole_check_poll(void);
    96 extern void kconsole(char *prompt, char *msg, bool kcon);
     98extern void kconsole(const char *prompt, const char *msg, bool kcon);
    9799extern void kconsole_thread(void *data);
    98100
  • kernel/generic/include/context.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_CONTEXT_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
     39#include <trace.h>
    3940#include <arch/context.h>
    4041
     42#define context_set_generic(ctx, _pc, stack, size) \
     43        (ctx)->pc = (uintptr_t) (_pc); \
     44        (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA;
    4145
    42 #ifndef context_set
    43 #define context_set(c, _pc, stack, size)        \
    44         (c)->pc = (uintptr_t) (_pc);            \
    45         (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA;
    46 #endif /* context_set */
    47 
    48 extern int context_save_arch(context_t *c) __attribute__ ((returns_twice));
    49 extern void context_restore_arch(context_t *c) __attribute__ ((noreturn));
     46extern int context_save_arch(context_t *ctx) __attribute__((returns_twice));
     47extern void context_restore_arch(context_t *ctx) __attribute__((noreturn));
    5048
    5149/** Save register context.
    5250 *
    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
     51 * Save the current register context (including stack pointer) to a context
     52 * structure. A subsequent call to context_restore() will return to the same
    5753 * address as the corresponding call to context_save().
    5854 *
    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.
     55 * Note that context_save_arch() must reuse the stack frame of the function
     56 * which called context_save(). We guarantee this by:
    6257 *
    63  * @param c Context structure.
     58 *   a) implementing context_save_arch() in assembly so that it does not create
     59 *      its own stack frame, and by
     60 *   b) defining context_save() as a macro because the inline keyword is just a
     61 *      hint for the compiler, not a real constraint; the application of a macro
     62 *      will definitely not create a stack frame either.
     63 *
     64 * To imagine what could happen if there were some extra stack frames created
     65 * either by context_save() or context_save_arch(), we need to realize that the
     66 * sp saved in the contex_t structure points to the current stack frame as it
     67 * existed when context_save_arch() was executing. After the return from
     68 * context_save_arch() and context_save(), any extra stack frames created by
     69 * these functions will be destroyed and their contents sooner or later
     70 * overwritten by functions called next. Any attempt to restore to a context
     71 * saved like that would therefore lead to a disaster.
     72 *
     73 * @param ctx Context structure.
    6474 *
    6575 * @return context_save() returns 1, context_restore() returns 0.
     76 *
    6677 */
    67 #define context_save(c)   context_save_arch(c)
     78#define context_save(ctx)  context_save_arch(ctx)
    6879
    6980/** Restore register context.
    7081 *
    71  * Restore previously saved register context (including stack pointers)
    72  * from context structure.
     82 * Restore a previously saved register context (including stack pointer) from
     83 * a context structure.
    7384 *
    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.
     85 * Note that this function does not normally return.  Instead, it returns to the
     86 * same address as the corresponding call to context_save(), the only difference
     87 * being return value.
    7888 *
    79  * @param c Context structure.
     89 * @param ctx Context structure.
     90 *
    8091 */
    81 static inline void context_restore(context_t *c)
     92NO_TRACE static inline void context_restore(context_t *ctx)
    8293{
    83         context_restore_arch(c);
     94        context_restore_arch(ctx);
    8495}
    8596
  • kernel/generic/include/cpu.h

    rb50b5af2 r04803bf  
    4242#include <arch/context.h>
    4343
    44 #define CPU_STACK_SIZE  STACK_SIZE
     44#define CPU_STACK_SIZE  STACK_SIZE
    4545
    4646/** CPU structure.
     
    4848 * There is one structure like this for every processor.
    4949 */
    50 typedef struct {
    51         SPINLOCK_DECLARE(lock);
    52 
     50typedef struct cpu {
     51        IRQ_SPINLOCK_DECLARE(lock);
     52       
    5353        tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
    5454        size_t tlb_messages_count;
    5555       
    5656        context_t saved_context;
    57 
     57       
    5858        atomic_t nrdy;
    5959        runq_t rq[RQ_COUNT];
    6060        volatile size_t needs_relink;
    61 
    62         SPINLOCK_DECLARE(timeoutlock);
     61       
     62        IRQ_SPINLOCK_DECLARE(timeoutlock);
    6363        link_t timeout_active_head;
    64 
    65         size_t missed_clock_ticks;      /**< When system clock loses a tick, it is recorded here
    66                                              so that clock() can react. This variable is
    67                                              CPU-local and can be only accessed when interrupts
    68                                              are disabled. */
    69 
     64       
     65        /**
     66         * When system clock loses a tick, it is
     67         * recorded here so that clock() can react.
     68         * This variable is CPU-local and can be
     69         * only accessed when interrupts are
     70         * disabled.
     71         */
     72        size_t missed_clock_ticks;
     73       
     74        /**
     75         * Processor cycle accounting.
     76         */
     77        bool idle;
     78        uint64_t last_cycle;
     79        uint64_t idle_cycles;
     80        uint64_t busy_cycles;
     81       
    7082        /**
    7183         * Processor ID assigned by kernel.
     
    7385        unsigned int id;
    7486       
    75         int active;
    76         int tlb_active;
    77 
     87        bool active;
     88        bool tlb_active;
     89       
    7890        uint16_t frequency_mhz;
    7991        uint32_t delay_loop_const;
    80 
     92       
    8193        cpu_arch_t arch;
    82 
     94       
    8395        struct thread *fpu_owner;
    8496       
     
    96108extern void cpu_arch_init(void);
    97109extern void cpu_identify(void);
    98 extern void cpu_print_report(cpu_t *m);
     110extern void cpu_print_report(cpu_t *);
    99111
    100112#endif
  • kernel/generic/include/ddi/ddi.h

    rb50b5af2 r04803bf  
    3737
    3838#include <ddi/ddi_arg.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <proc/task.h>
    4141#include <adt/list.h>
     
    4343/** Structure representing contiguous physical memory area. */
    4444typedef struct {
    45         uintptr_t pbase;    /**< Physical base of the area. */
    46         pfn_t frames;       /**< Number of frames in the area. */
     45        link_t link;      /**< Linked list link */
    4746       
    48         link_t link;        /**< Linked list link */
     47        uintptr_t pbase;  /**< Physical base of the area. */
     48        pfn_t frames;     /**< Number of frames in the area. */
     49        bool unpriv;      /**< Allow mapping by unprivileged tasks. */
    4950} parea_t;
    5051
    5152extern void ddi_init(void);
    52 extern void ddi_parea_register(parea_t *parea);
     53extern void ddi_parea_register(parea_t *);
    5354
    54 extern unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base,
    55         unative_t pages, unative_t flags);
    56 extern unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg);
    57 extern unative_t sys_preempt_control(int enable);
     55extern sysarg_t sys_physmem_map(sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     56extern sysarg_t sys_iospace_enable(ddi_ioarg_t *);
    5857
    5958/*
    6059 * Interface to be implemented by all architectures.
    6160 */
    62 extern int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size);
     61extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
    6362
    6463#endif
  • kernel/generic/include/ddi/ddi_arg.h

    rb50b5af2 r04803bf  
    3636#define KERN_DDI_ARG_H_
    3737
     38#ifdef KERNEL
     39
     40#include <typedefs.h>
     41
     42#endif /* KERNEL */
     43
    3844/** Structure encapsulating arguments for SYS_PHYSMEM_MAP syscall. */
    3945typedef struct {
    4046        /** ID of the destination task. */
    41         unsigned long long task_id;
     47        uint64_t task_id;
    4248        /** Physical address of starting frame. */
    4349        void *phys_base;
     
    4551        void *virt_base;
    4652        /** Number of pages to map. */
    47         unsigned long pages;
     53        size_t pages;
    4854        /** Address space area flags for the mapping. */
    49         int flags;
     55        unsigned int flags;
    5056} ddi_memarg_t;
    5157
    5258/** Structure encapsulating arguments for SYS_ENABLE_IOSPACE syscall. */
    5359typedef struct {
    54         unsigned long long task_id;     /**< ID of the destination task. */
    55         void *ioaddr;                   /**< Starting I/O space address. */
    56         unsigned long size;             /**< Number of bytes. */
     60        uint64_t task_id;  /**< ID of the destination task. */
     61        void *ioaddr;      /**< Starting I/O space address. */
     62        size_t size;       /**< Number of bytes. */
    5763} ddi_ioarg_t;
    5864
  • kernel/generic/include/ddi/device.h

    rb50b5af2 r04803bf  
    3636#define KERN_DEVICE_H_
    3737
    38 #include <arch/types.h>
    3938#include <typedefs.h>
    4039
    4140extern devno_t device_assign_devno(void);
    42 extern unative_t sys_device_assign_devno(void);
     41extern sysarg_t sys_device_assign_devno(void);
    4342
    4443#endif
  • kernel/generic/include/ddi/irq.h

    rb50b5af2 r04803bf  
    3636#define KERN_IRQ_H_
    3737
    38 typedef enum {
    39         CMD_PIO_READ_8 = 1,
    40         CMD_PIO_READ_16,
    41         CMD_PIO_READ_32,
    42         CMD_PIO_WRITE_8,
    43         CMD_PIO_WRITE_16,
    44         CMD_PIO_WRITE_32,
    45         CMD_BTEST,
    46         CMD_PREDICATE,
    47         CMD_ACCEPT,
    48         CMD_DECLINE,
    49         CMD_LAST
    50 } irq_cmd_type;
    51 
    52 typedef struct {
    53         irq_cmd_type cmd;
    54         void *addr;
    55         unsigned long long value;
    56         unsigned int srcarg;
    57         unsigned int dstarg;
    58 } irq_cmd_t;
    59 
    60 typedef struct {
    61         unsigned int cmdcount;
    62         irq_cmd_t *cmds;
    63 } irq_code_t;
    64 
    6538#ifdef KERNEL
    6639
    67 #include <arch/types.h>
     40#include <typedefs.h>
    6841#include <adt/list.h>
    6942#include <adt/hash_table.h>
     
    7245#include <ipc/ipc.h>
    7346
     47#endif /* KERNEL */
     48
    7449typedef enum {
    75         IRQ_DECLINE,            /**< Decline to service. */
    76         IRQ_ACCEPT              /**< Accept to service. */
     50        /** Read 1 byte from the I/O space. */
     51        CMD_PIO_READ_8 = 1,
     52        /** Read 2 bytes from the I/O space. */
     53        CMD_PIO_READ_16,
     54        /** Read 4 bytes from the I/O space. */
     55        CMD_PIO_READ_32,
     56       
     57        /** Write 1 byte to the I/O space. */
     58        CMD_PIO_WRITE_8,
     59        /** Write 2 bytes to the I/O space. */
     60        CMD_PIO_WRITE_16,
     61        /** Write 4 bytes to the I/O space. */
     62        CMD_PIO_WRITE_32,
     63       
     64        /**
     65         * Write 1 byte from the source argument
     66         * to the I/O space.
     67         */
     68        CMD_PIO_WRITE_A_8,
     69        /**
     70         * Write 2 bytes from the source argument
     71         * to the I/O space.
     72         */
     73        CMD_PIO_WRITE_A_16,
     74        /**
     75         * Write 4 bytes from the source argument
     76         * to the I/O space.
     77         */
     78        CMD_PIO_WRITE_A_32,
     79       
     80        /**
     81         * Perform a bit masking on the source argument
     82         * and store the result into the destination argument.
     83         */
     84        CMD_BTEST,
     85       
     86        /**
     87         * Predicate the execution of the following
     88         * N commands by the boolean value of the source
     89         * argument.
     90         */
     91        CMD_PREDICATE,
     92       
     93        /** Accept the interrupt. */
     94        CMD_ACCEPT,
     95       
     96        /** Decline the interrupt. */
     97        CMD_DECLINE,
     98        CMD_LAST
     99} irq_cmd_type;
     100
     101typedef struct {
     102        irq_cmd_type cmd;
     103        void *addr;
     104        uint32_t value;
     105        uintptr_t srcarg;
     106        uintptr_t dstarg;
     107} irq_cmd_t;
     108
     109typedef struct {
     110        size_t cmdcount;
     111        irq_cmd_t *cmds;
     112} irq_code_t;
     113
     114#ifdef KERNEL
     115
     116typedef enum {
     117        IRQ_DECLINE,  /**< Decline to service. */
     118        IRQ_ACCEPT    /**< Accept to service. */
    77119} irq_ownership_t;
    78120
     
    92134 * Primarily, this structure is encapsulated in the irq_t structure.
    93135 * It is protected by irq_t::lock.
     136 *
    94137 */
    95138typedef struct {
     
    98141        /** Answerbox for notifications. */
    99142        answerbox_t *answerbox;
    100         /** Method to be used for the notification. */
    101         unative_t method;
     143        /** Interface and method to be used for the notification. */
     144        sysarg_t imethod;
    102145        /** Arguments that will be sent if the IRQ is claimed. */
    103         unative_t scratch[IPC_CALL_LEN];
     146        uint32_t scratch[IPC_CALL_LEN];
    104147        /** Top-half pseudocode. */
    105148        irq_code_t *code;
    106149        /** Counter. */
    107150        size_t counter;
     151       
    108152        /**
    109153         * Link between IRQs that are notifying the same answerbox. The list is
     
    117161 * If one device has multiple interrupts, there will be multiple irq_t
    118162 * instantions with the same devno.
     163 *
    119164 */
    120165typedef struct irq {
    121166        /** Hash table link. */
    122167        link_t link;
    123 
     168       
    124169        /** Lock protecting everything in this structure
    125170         *  except the link member. When both the IRQ
     
    127172         *  this lock must not be taken first.
    128173         */
    129         SPINLOCK_DECLARE(lock);
     174        IRQ_SPINLOCK_DECLARE(lock);
    130175       
    131176        /** Send EOI before processing the interrupt.
     
    136181         */
    137182        bool preack;
    138 
     183       
    139184        /** Unique device number. -1 if not yet assigned. */
    140185        devno_t devno;
    141 
     186       
    142187        /** Actual IRQ number. -1 if not yet assigned. */
    143188        inr_t inr;
     
    150195        /** Instance argument for the handler and the claim function. */
    151196        void *instance;
    152 
     197       
    153198        /** Clear interrupt routine. */
    154199        cir_t cir;
    155200        /** First argument to the clear interrupt routine. */
    156201        void *cir_arg;
    157 
     202       
    158203        /** Notification configuration structure. */
    159204        ipc_notif_cfg_t notif_cfg;
    160205} irq_t;
    161206
    162 SPINLOCK_EXTERN(irq_uspace_hash_table_lock);
     207IRQ_SPINLOCK_EXTERN(irq_uspace_hash_table_lock);
    163208extern hash_table_t irq_uspace_hash_table;
     209
     210extern inr_t last_inr;
    164211
    165212extern void irq_init(size_t, size_t);
     
    168215extern irq_t *irq_dispatch_and_lock(inr_t);
    169216
     217#endif /* KERNEL */
     218
    170219#endif
    171220
    172 #endif
    173 
    174221/** @}
    175222 */
  • kernel/generic/include/debug.h

    rb50b5af2 r04803bf  
    3737
    3838#include <panic.h>
    39 #include <arch/debug.h>
     39#include <symtab.h>
    4040
    41 #define CALLER ((uintptr_t) __builtin_return_address(0))
     41#define CALLER  ((uintptr_t) __builtin_return_address(0))
    4242
    43 #ifndef HERE
    44 /** Current Instruction Pointer address */
    45 #       define HERE ((uintptr_t *) 0)
    46 #endif
     43#ifdef CONFIG_DEBUG
    4744
    4845/** Debugging ASSERT macro
     
    5552 *
    5653 */
    57 #ifdef CONFIG_DEBUG
    58 #       define ASSERT(expr) \
    59                 if (!(expr)) { \
    60                         panic("Assertion failed (%s), caller=%p.", #expr, CALLER); \
    61                 }
    62 #else
    63 #       define ASSERT(expr)
    64 #endif
     54#define ASSERT(expr) \
     55        do { \
     56                if (!(expr)) \
     57                        panic_assert("%s() at %s:%u:\n%s", \
     58                            __func__, __FILE__, __LINE__, #expr); \
     59        } while (0)
     60
     61/** Debugging verbose ASSERT macro
     62 *
     63 * If CONFIG_DEBUG is set, the ASSERT() macro
     64 * evaluates expr and if it is false raises
     65 * kernel panic. The panic message contains also
     66 * the supplied message.
     67 *
     68 * @param expr Expression which is expected to be true.
     69 * @param msg  Additional message to show (string).
     70 *
     71 */
     72#define ASSERT_VERBOSE(expr, msg) \
     73        do { \
     74                if (!(expr)) \
     75                        panic_assert("%s() at %s:%u:\n%s, %s", \
     76                            __func__, __FILE__, __LINE__, #expr, msg); \
     77        } while (0)
     78
     79#else /* CONFIG_DEBUG */
     80
     81#define ASSERT(expr)
     82#define ASSERT_VERBOSE(expr, msg)
     83
     84#endif /* CONFIG_DEBUG */
     85
     86#ifdef CONFIG_LOG
    6587
    6688/** Extensive logging output macro
     
    7193 *
    7294 */
     95#define LOG(format, ...) \
     96        do { \
     97                printf("%s() from %s at %s:%u: " format "\n", __func__, \
     98                    symtab_fmt_name_lookup(CALLER), __FILE__, __LINE__, \
     99                    ##__VA_ARGS__); \
     100        } while (0)
    73101
    74 #ifdef CONFIG_LOG
    75 #       define LOG(format, ...) \
    76                 printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \
    77                         __LINE__, ##__VA_ARGS__);
    78 #else
    79 #       define LOG(format, ...)
    80 #endif
     102#else /* CONFIG_LOG */
    81103
    82 /** Extensive logging execute macro
    83  *
    84  * If CONFIG_LOG is set, the LOG_EXEC() macro
    85  * will print an information about calling a given
    86  * function and call it.
    87  *
    88  */
     104#define LOG(format, ...)
    89105
    90 #ifdef CONFIG_LOG
    91 #       define LOG_EXEC(fnc) \
    92                 { \
    93                         printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \
    94                         __LINE__); \
    95                         fnc; \
    96                 }
    97 #else
    98 #       define LOG_EXEC(fnc) fnc
    99 #endif
     106#endif /* CONFIG_LOG */
    100107
     108#ifdef CONFIG_TRACE
     109
     110extern void __cyg_profile_func_enter(void *, void *);
     111extern void __cyg_profile_func_exit(void *, void *);
     112
     113#endif /* CONFIG_TRACE */
    101114
    102115#endif
  • kernel/generic/include/func.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_FUNC_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <atomic.h>
    4040
    4141extern atomic_t haltstate;
    4242
    43 extern void halt(void);
    44 extern unative_t atoi(const char *text);
    45 extern void order(const uint64_t val, uint64_t *rv, char *suffix);
     43extern void halt(void) __attribute__((noreturn));
    4644
    4745#endif
  • kernel/generic/include/interrupt.h

    rb50b5af2 r04803bf  
    3737
    3838#include <arch/interrupt.h>
    39 #include <arch/types.h>
     39#include <print.h>
     40#include <typedefs.h>
    4041#include <proc/task.h>
    4142#include <proc/thread.h>
    4243#include <arch.h>
    4344#include <ddi/irq.h>
     45#include <stacktrace.h>
    4446
    45 typedef void (* iroutine)(int n, istate_t *istate);
     47typedef void (* iroutine_t)(unsigned int, istate_t *);
    4648
    47 #define fault_if_from_uspace(istate, fmt, ...) \
    48 { \
    49         if (istate_from_uspace(istate)) { \
    50                 task_t *task = TASK; \
    51                 printf("Task %s (%" PRIu64 ") killed due to an exception at %p: ", task->name, task->taskid, istate_get_pc(istate)); \
    52                 printf(fmt "\n", ##__VA_ARGS__); \
    53                 task_kill(task->taskid); \
    54                 thread_exit(); \
    55         } \
    56 }
     49typedef struct {
     50        const char *name;
     51        bool hot;
     52        iroutine_t handler;
     53        uint64_t cycles;
     54        uint64_t count;
     55} exc_table_t;
    5756
    58 extern iroutine exc_register(int n, const char *name, iroutine f);
    59 extern void exc_dispatch(int n, istate_t *t);
    60 void exc_init(void);
     57IRQ_SPINLOCK_EXTERN(exctbl_lock);
     58extern exc_table_t exc_table[];
     59
     60extern void fault_if_from_uspace(istate_t *, const char *, ...)
     61    PRINTF_ATTRIBUTE(2, 3);
     62extern istate_t *istate_get(thread_t *);
     63extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t);
     64extern void exc_dispatch(unsigned int, istate_t *);
     65extern void exc_init(void);
     66
     67extern void irq_initialize_arch(irq_t *);
     68
     69extern void istate_decode(istate_t *);
    6170
    6271#endif
  • kernel/generic/include/ipc/event.h

    rb50b5af2 r04803bf  
    3737
    3838#include <ipc/event_types.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <synch/spinlock.h>
    4141#include <ipc/ipc.h>
     
    4747        /** Answerbox for notifications. */
    4848        answerbox_t *answerbox;
    49         /** Method to be used for the notification. */
    50         unative_t method;
     49        /** Interface and method to be used for the notification. */
     50        sysarg_t imethod;
    5151        /** Counter. */
    5252        size_t counter;
     
    5454
    5555extern void event_init(void);
    56 extern unative_t sys_event_subscribe(unative_t, unative_t);
     56extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t);
    5757extern bool event_is_subscribed(event_type_t);
    5858extern void event_cleanup_answerbox(answerbox_t *);
     
    7171        event_notify((e), (a1), (a2), (a3), (a4), (a5))
    7272
    73 extern void event_notify(event_type_t, unative_t, unative_t, unative_t,
    74     unative_t, unative_t);
     73extern void event_notify(event_type_t, sysarg_t, sysarg_t, sysarg_t,
     74    sysarg_t, sysarg_t);
    7575
    7676#endif
  • kernel/generic/include/ipc/event_types.h

    rb50b5af2 r04803bf  
    3737
    3838typedef enum event_type {
     39        /** New data available in kernel log */
    3940        EVENT_KLOG = 0,
     41        /** Returning from kernel console to userspace */
    4042        EVENT_KCONSOLE,
     43        /** A task/thread has faulted and will be terminated */
     44        EVENT_FAULT,
    4145        EVENT_END
    4246} event_type_t;
  • kernel/generic/include/ipc/ipc.h

    rb50b5af2 r04803bf  
    3636#define KERN_IPC_H_
    3737
    38 /* Length of data being transfered with IPC call */
    39 /* - the uspace may not be able to utilize full length */
    40 #define IPC_CALL_LEN            6       
    41 
    42 /** Maximum active async calls per thread */
    43 #ifdef CONFIG_DEBUG
    44 #define IPC_MAX_ASYNC_CALLS     4
    45 #else
    46 #define IPC_MAX_ASYNC_CALLS     4000
    47 #endif
     38/** Length of data being transfered with IPC call
     39 *
     40 * The uspace may not be able to utilize full length
     41 *
     42 */
     43#define IPC_CALL_LEN  6
     44
     45/** Maximum active async calls per phone */
     46#define IPC_MAX_ASYNC_CALLS  4
    4847
    4948/* Flags for calls */
    5049
    5150/** This is answer to a call */
    52 #define IPC_CALL_ANSWERED       (1 << 0)
    53 /** This call will not be freed on error */
    54 #define IPC_CALL_STATIC_ALLOC   (1 << 1)
     51#define IPC_CALL_ANSWERED  (1 << 0)
     52
    5553/** Answer will not be passed to userspace, will be discarded */
    56 #define IPC_CALL_DISCARD_ANSWER (1 << 2)
     54#define IPC_CALL_DISCARD_ANSWER  (1 << 1)
     55
    5756/** Call was forwarded */
    58 #define IPC_CALL_FORWARDED      (1 << 3)
     57#define IPC_CALL_FORWARDED  (1 << 2)
     58
    5959/** Identify connect_me_to answer */
    60 #define IPC_CALL_CONN_ME_TO     (1 << 4)
     60#define IPC_CALL_CONN_ME_TO  (1 << 3)
     61
    6162/** Interrupt notification */
    62 #define IPC_CALL_NOTIF          (1 << 5)
    63 
    64 /*
    65  * Bits used in call hashes.
     63#define IPC_CALL_NOTIF  (1 << 4)
     64
     65
     66/** Bits used in call hashes.
     67 *
    6668 * The addresses are aligned at least to 4 that is why we can use the 2 least
    6769 * significant bits of the call address.
    68  */
     70 *
     71 */
     72
    6973/** Type of this call is 'answer' */
    70 #define IPC_CALLID_ANSWERED     1
     74#define IPC_CALLID_ANSWERED  1
     75
    7176/** Type of this call is 'notification' */
    72 #define IPC_CALLID_NOTIFICATION 2
     77#define IPC_CALLID_NOTIFICATION  2
    7378
    7479/* Return values from sys_ipc_call_async(). */
    75 #define IPC_CALLRET_FATAL       -1
    76 #define IPC_CALLRET_TEMPORARY   -2
     80#define IPC_CALLRET_FATAL      -1
     81#define IPC_CALLRET_TEMPORARY  -2
    7782
    7883
    7984/* Macros for manipulating calling data */
    80 #define IPC_SET_RETVAL(data, retval)    ((data).args[0] = (retval))
    81 #define IPC_SET_METHOD(data, val)       ((data).args[0] = (val))
    82 #define IPC_SET_ARG1(data, val)         ((data).args[1] = (val))
    83 #define IPC_SET_ARG2(data, val)         ((data).args[2] = (val))
    84 #define IPC_SET_ARG3(data, val)         ((data).args[3] = (val))
    85 #define IPC_SET_ARG4(data, val)         ((data).args[4] = (val))
    86 #define IPC_SET_ARG5(data, val)         ((data).args[5] = (val))
    87 
    88 #define IPC_GET_METHOD(data)            ((data).args[0])
    89 #define IPC_GET_RETVAL(data)            ((data).args[0])
    90 
    91 #define IPC_GET_ARG1(data)              ((data).args[1])
    92 #define IPC_GET_ARG2(data)              ((data).args[2])
    93 #define IPC_GET_ARG3(data)              ((data).args[3])
    94 #define IPC_GET_ARG4(data)              ((data).args[4])
    95 #define IPC_GET_ARG5(data)              ((data).args[5])
     85#define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
     86#define IPC_SET_IMETHOD(data, val)    ((data).args[0] = (val))
     87#define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
     88#define IPC_SET_ARG2(data, val)       ((data).args[2] = (val))
     89#define IPC_SET_ARG3(data, val)       ((data).args[3] = (val))
     90#define IPC_SET_ARG4(data, val)       ((data).args[4] = (val))
     91#define IPC_SET_ARG5(data, val)       ((data).args[5] = (val))
     92
     93#define IPC_GET_IMETHOD(data)  ((data).args[0])
     94#define IPC_GET_RETVAL(data)   ((data).args[0])
     95
     96#define IPC_GET_ARG1(data)  ((data).args[1])
     97#define IPC_GET_ARG2(data)  ((data).args[2])
     98#define IPC_GET_ARG3(data)  ((data).args[3])
     99#define IPC_GET_ARG4(data)  ((data).args[4])
     100#define IPC_GET_ARG5(data)  ((data).args[5])
    96101
    97102/* Well known phone descriptors */
    98 #define PHONE_NS        0
     103#define PHONE_NS  0
    99104
    100105/* Forwarding flags. */
    101 #define IPC_FF_NONE             0
     106#define IPC_FF_NONE  0
     107
    102108/**
    103109 * The call will be routed as though it was initially sent via the phone used to
     
    106112 * calls that were initially sent by the forwarder to the same destination. This
    107113 * flag has no imapct on routing replies.
    108  */
    109 #define IPC_FF_ROUTE_FROM_ME    (1 << 0)
    110 
    111 /* System-specific methods - only through special syscalls
    112  * These methods have special behaviour
    113  */
     114 *
     115 */
     116#define IPC_FF_ROUTE_FROM_ME  (1 << 0)
     117
     118/** Kernel IPC interfaces
     119 *
     120 */
     121#define IPC_IF_KERNEL  0
     122
     123/** System-specific methods - only through special syscalls
     124 *
     125 * These methods have special behaviour. These methods also
     126 * have the implicit kernel interface 0.
     127 *
     128 */
     129
    114130/** Clone connection.
    115131 *
     
    117133 *
    118134 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection.
    119  *        - The callee gets the new phone from ARG1.
     135 *        - The callee gets the new phone from ARG1.
     136 *
    120137 * - on answer, the callee acknowledges the new connection by sending EOK back
    121138 *   or the kernel closes it
    122  */
    123 #define IPC_M_CONNECTION_CLONE  1
     139 *
     140 */
     141#define IPC_M_CONNECTION_CLONE  1
     142
    124143/** Protocol for CONNECT - ME
    125144 *
    126145 * Through this call, the recipient learns about the new cloned connection.
    127  * 
     146 *
    128147 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone
    129148 * - on asnwer, the callee acknowledges the new connection by sending EOK back
    130149 *   or the kernel closes it
    131  */
    132 #define IPC_M_CONNECT_ME        2
    133 /** Protocol for CONNECT - TO - ME
     150 *
     151 */
     152#define IPC_M_CONNECT_ME  2
     153
     154/** Protocol for CONNECT - TO - ME
    134155 *
    135156 * Calling process asks the callee to create a callback connection,
     
    144165 *                       error is sent back to caller. Otherwise
    145166 *                       the call is accepted and the response is sent back.
    146  *                     - the allocated phoneid is passed to userspace
     167 *                     - the hash of the client task is passed to userspace
     168 *                       (on the receiving side) as ARG4 of the call.
     169 *                     - the hash of the allocated phone is passed to userspace
    147170 *                       (on the receiving side) as ARG5 of the call.
    148  */
    149 #define IPC_M_CONNECT_TO_ME     3       
     171 *
     172 */
     173#define IPC_M_CONNECT_TO_ME  3
     174
    150175/** Protocol for CONNECT - ME - TO
    151176 *
     
    165190 *
    166191 */
    167 #define IPC_M_CONNECT_ME_TO     4       
    168 /** This message is sent to answerbox when the phone
    169  * is hung up
    170  */
    171 #define IPC_M_PHONE_HUNGUP      5
     192#define IPC_M_CONNECT_ME_TO  4
     193
     194/** This message is sent to answerbox when the phone is hung up
     195 *
     196 */
     197#define IPC_M_PHONE_HUNGUP  5
    172198
    173199/** Send as_area over IPC.
     
    175201 * - ARG2 - size of source as_area (filled automatically by kernel)
    176202 * - ARG3 - flags of the as_area being sent
    177  * 
     203 *
    178204 * on answer, the recipient must set:
    179205 * - ARG1 - dst as_area base adress
    180  */
    181 #define IPC_M_SHARE_OUT         6       
     206 *
     207 */
     208#define IPC_M_SHARE_OUT  6
    182209
    183210/** Receive as_area over IPC.
     
    185212 * - ARG2 - destination as_area size
    186213 * - ARG3 - user defined argument
    187  * 
     214 *
    188215 * on answer, the recipient must set:
    189216 *
    190217 * - ARG1 - source as_area base address
    191218 * - ARG2 - flags that will be used for sharing
    192  */
    193 #define IPC_M_SHARE_IN          7       
     219 *
     220 */
     221#define IPC_M_SHARE_IN  7
    194222
    195223/** Send data to another address space over IPC.
     
    201229 * - ARG1 - final destination address space virtual address
    202230 * - ARG2 - final size of data to be copied
    203  */
    204 #define IPC_M_DATA_WRITE        8
     231 *
     232 */
     233#define IPC_M_DATA_WRITE  8
    205234
    206235/** Receive data from another address space over IPC.
     
    212241 * - ARG1 - source virtual address in the destination address space
    213242 * - ARG2 - final size of data to be copied
    214  */
    215 #define IPC_M_DATA_READ         9
     243 *
     244 */
     245#define IPC_M_DATA_READ  9
    216246
    217247/** Debug the recipient.
    218248 * - ARG1 - specifies the debug method (from udebug_method_t)
    219249 * - other arguments are specific to the debug method
    220  */
    221 #define IPC_M_DEBUG_ALL         10
     250 *
     251 */
     252#define IPC_M_DEBUG_ALL  10
    222253
    223254/* Well-known methods */
    224 #define IPC_M_LAST_SYSTEM       511
    225 #define IPC_M_PING              512
     255#define IPC_M_LAST_SYSTEM  511
     256#define IPC_M_PING         512
     257
    226258/* User methods */
    227 #define IPC_FIRST_USER_METHOD   1024
     259#define IPC_FIRST_USER_METHOD  1024
    228260
    229261#ifdef KERNEL
    230262
    231 #define IPC_MAX_PHONES  16
     263#define IPC_MAX_PHONES  32
    232264
    233265#include <synch/spinlock.h>
     
    261293
    262294typedef struct answerbox {
    263         SPINLOCK_DECLARE(lock);
    264 
     295        IRQ_SPINLOCK_DECLARE(lock);
     296       
    265297        struct task *task;
    266 
     298       
    267299        waitq_t wq;
    268 
     300       
     301        /** Linkage for the list of task's synchronous answerboxes. */
     302        link_t sync_box_link;
     303       
    269304        /** Phones connected to this answerbox. */
    270305        link_t connected_phones;
    271306        /** Received calls. */
    272         link_t calls;                   
    273         link_t dispatched_calls;        /* Should be hash table in the future */
    274 
     307        link_t calls;
     308        link_t dispatched_calls;  /* Should be hash table in the future */
     309       
    275310        /** Answered calls. */
    276311        link_t answers;
    277 
    278         SPINLOCK_DECLARE(irq_lock);
     312       
     313        IRQ_SPINLOCK_DECLARE(irq_lock);
     314       
    279315        /** Notifications from IRQ handlers. */
    280316        link_t irq_notifs;
     
    284320
    285321typedef struct {
    286         unative_t args[IPC_CALL_LEN];
     322        sysarg_t args[IPC_CALL_LEN];
     323        /** Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME. */
     324        struct task *task;
     325        /** Phone which made or last masqueraded this call. */
    287326        phone_t *phone;
    288327} ipc_data_t;
     
    290329typedef struct {
    291330        link_t link;
    292 
    293         int flags;
    294 
     331       
     332        unsigned int flags;
     333       
    295334        /** Identification of the caller. */
    296335        struct task *sender;
    297         /** The caller box is different from sender->answerbox for synchronous
    298          *  calls. */
     336       
     337        /*
     338         * The caller box is different from sender->answerbox
     339         * for synchronous calls.
     340         */
    299341        answerbox_t *callerbox;
    300 
     342       
    301343        /** Private data to internal IPC. */
    302         unative_t priv;
    303 
     344        sysarg_t priv;
     345       
    304346        /** Data passed from/to userspace. */
    305347        ipc_data_t data;
    306 
     348       
    307349        /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */
    308350        uint8_t *buffer;
    309 
     351       
    310352        /*
    311353         * The forward operation can masquerade the caller phone. For those
     
    316358} call_t;
    317359
     360extern answerbox_t *ipc_phone_0;
     361
    318362extern void ipc_init(void);
    319 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int);
    320 extern void ipc_answer(answerbox_t *, call_t *);
     363
     364extern call_t *ipc_call_alloc(unsigned int);
     365extern void ipc_call_free(call_t *);
     366
    321367extern int ipc_call(phone_t *, call_t *);
    322368extern int ipc_call_sync(phone_t *, call_t *);
     369extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
     370extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int);
     371extern void ipc_answer(answerbox_t *, call_t *);
     372
    323373extern void ipc_phone_init(phone_t *);
    324374extern void ipc_phone_connect(phone_t *, answerbox_t *);
    325 extern void ipc_call_free(call_t *);
    326 extern call_t * ipc_call_alloc(int);
     375extern int ipc_phone_hangup(phone_t *);
     376
    327377extern void ipc_answerbox_init(answerbox_t *, struct task *);
    328 extern void ipc_call_static_init(call_t *);
    329 extern void task_print_list(void);
    330 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int);
     378
    331379extern void ipc_cleanup(void);
    332 extern int ipc_phone_hangup(phone_t *);
    333 extern void ipc_backsend_err(phone_t *, call_t *, unative_t);
    334 extern void ipc_print_task(task_id_t);
     380extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t);
    335381extern void ipc_answerbox_slam_phones(answerbox_t *, bool);
    336382extern void ipc_cleanup_call_list(link_t *);
    337383
    338 extern answerbox_t *ipc_phone_0;
     384extern void ipc_print_task(task_id_t);
     385
     386#endif /* KERNEL */
    339387
    340388#endif
    341389
    342 #endif
    343 
    344390/** @}
    345391 */
  • kernel/generic/include/ipc/ipcrsc.h

    rb50b5af2 r04803bf  
    3939#include <ipc/ipc.h>
    4040
    41 extern call_t * get_call(unative_t callid);
     41extern call_t * get_call(sysarg_t callid);
    4242extern int phone_alloc(task_t *t);
    4343extern void phone_connect(int phoneid, answerbox_t *box);
  • kernel/generic/include/ipc/irq.h

    rb50b5af2 r04803bf  
    3737
    3838/** Maximum length of IPC IRQ program */
    39 #define IRQ_MAX_PROG_SIZE       20
     39#define IRQ_MAX_PROG_SIZE  20
    4040
    4141#include <ipc/ipc.h>
    4242#include <ddi/irq.h>
    43 #include <arch/types.h>
     43#include <typedefs.h>
    4444#include <adt/list.h>
    4545
    46 extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, unative_t,
     46extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, sysarg_t,
    4747    irq_code_t *);
    4848
     
    5858 */
    5959#define ipc_irq_send_msg_0(irq) \
    60     ipc_irq_send_msg((irq), 0, 0, 0, 0, 0)
     60        ipc_irq_send_msg((irq), 0, 0, 0, 0, 0)
     61
    6162#define ipc_irq_send_msg_1(irq, a1) \
    62     ipc_irq_send_msg((irq), (a1), 0, 0, 0, 0)
     63        ipc_irq_send_msg((irq), (a1), 0, 0, 0, 0)
     64
    6365#define ipc_irq_send_msg_2(irq, a1, a2) \
    64     ipc_irq_send_msg((irq), (a1), (a2), 0, 0, 0)
     66        ipc_irq_send_msg((irq), (a1), (a2), 0, 0, 0)
     67
    6568#define ipc_irq_send_msg_3(irq, a1, a2, a3) \
    66     ipc_irq_send_msg((irq), (a1), (a2), (a3), 0, 0)
     69        ipc_irq_send_msg((irq), (a1), (a2), (a3), 0, 0)
     70
    6771#define ipc_irq_send_msg_4(irq, a1, a2, a3, a4) \
    68     ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), 0)
     72        ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), 0)
     73
    6974#define ipc_irq_send_msg_5(irq, a1, a2, a3, a4, a5) \
    70     ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), (a5))
     75        ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), (a5))
    7176
    72 extern void ipc_irq_send_msg(irq_t *, unative_t, unative_t, unative_t, unative_t,
    73     unative_t);
     77extern void ipc_irq_send_msg(irq_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     78    sysarg_t);
    7479
    7580#endif
  • kernel/generic/include/ipc/sysipc.h

    rb50b5af2 r04803bf  
    3838#include <ipc/ipc.h>
    3939#include <ipc/irq.h>
    40 #include <arch/types.h>
     40#include <typedefs.h>
    4141
    42 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
    43     unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data);
    44 unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
    45     ipc_data_t *reply);
    46 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
    47     unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
    48 unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data);
    49 unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
    50     unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
    51 unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
    52 unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
    53     int nonblocking);
    54 unative_t sys_ipc_poke(void);
    55 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
    56     unative_t method, unative_t arg1, unative_t arg2, int mode);
    57 unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
    58     ipc_data_t *data, int mode);
    59 unative_t sys_ipc_hangup(int phoneid);
    60 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
    61     irq_code_t *ucode);
    62 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
    63 unative_t sys_ipc_connect_kbox(sysarg64_t *task_id);
     42extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t,
     43    sysarg_t, sysarg_t, ipc_data_t *);
     44extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *);
     45extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t,
     46    sysarg_t, sysarg_t, sysarg_t);
     47extern sysarg_t sys_ipc_call_async_slow(sysarg_t, ipc_data_t *);
     48extern sysarg_t sys_ipc_answer_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     49    sysarg_t, sysarg_t);
     50extern sysarg_t sys_ipc_answer_slow(sysarg_t, ipc_data_t *);
     51extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *, uint32_t, unsigned int);
     52extern sysarg_t sys_ipc_poke(void);
     53extern sysarg_t sys_ipc_forward_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     54    sysarg_t, unsigned int);
     55extern sysarg_t sys_ipc_forward_slow(sysarg_t, sysarg_t, ipc_data_t *,
     56    unsigned int);
     57extern sysarg_t sys_ipc_hangup(sysarg_t);
     58extern sysarg_t sys_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *);
     59extern sysarg_t sys_unregister_irq(inr_t, devno_t);
     60
     61#ifdef __32_BITS__
     62
     63extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *);
     64
     65#endif  /* __32_BITS__ */
     66
     67#ifdef __64_BITS__
     68
     69extern sysarg_t sys_ipc_connect_kbox(sysarg_t);
     70
     71#endif  /* __64_BITS__ */
    6472
    6573#endif
  • kernel/generic/include/lib/elf.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3737
    3838#include <arch/elf.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141/**
    4242 * current ELF version
    4343 */
    44 #define EV_CURRENT      1
    45 
    46 /** 
    47  * ELF types 
    48  */
    49 #define ET_NONE         0       /* No type */
    50 #define ET_REL          1       /* Relocatable file */
    51 #define ET_EXEC         2       /* Executable */
    52 #define ET_DYN          3       /* Shared object */
    53 #define ET_CORE         4       /* Core */
    54 #define ET_LOPROC       0xff00  /* Processor specific */
    55 #define ET_HIPROC       0xffff  /* Processor specific */
    56 
    57 /** 
     44#define EV_CURRENT  1
     45
     46/**
     47 * ELF types
     48 */
     49#define ET_NONE    0       /* No type */
     50#define ET_REL     1       /* Relocatable file */
     51#define ET_EXEC    2       /* Executable */
     52#define ET_DYN     3       /* Shared object */
     53#define ET_CORE    4       /* Core */
     54#define ET_LOPROC  0xff00  /* Processor specific */
     55#define ET_HIPROC  0xffff  /* Processor specific */
     56
     57/**
    5858 * ELF machine types
    5959 */
    60 #define EM_NO           0       /* No machine */
    61 #define EM_SPARC        2       /* SPARC */
    62 #define EM_386          3       /* i386 */
    63 #define EM_MIPS         8       /* MIPS RS3000 */
    64 #define EM_MIPS_RS3_LE  10      /* MIPS RS3000 LE */
    65 #define EM_PPC          20      /* PPC32 */
    66 #define EM_PPC64        21      /* PPC64 */
    67 #define EM_ARM          40      /* ARM */
    68 #define EM_SPARCV9      43      /* SPARC64 */
    69 #define EM_IA_64        50      /* IA-64 */
    70 #define EM_X86_64       62      /* AMD64/EMT64 */
     60#define EM_NO           0   /* No machine */
     61#define EM_SPARC        2   /* SPARC */
     62#define EM_386          3   /* i386 */
     63#define EM_MIPS         8   /* MIPS RS3000 */
     64#define EM_MIPS_RS3_LE  10  /* MIPS RS3000 LE */
     65#define EM_PPC          20  /* PPC32 */
     66#define EM_PPC64        21  /* PPC64 */
     67#define EM_ARM          40  /* ARM */
     68#define EM_SPARCV9      43  /* SPARC64 */
     69#define EM_IA_64        50  /* IA-64 */
     70#define EM_X86_64       62  /* AMD64/EMT64 */
    7171
    7272/**
    7373 * ELF identification indexes
    7474 */
    75 #define EI_MAG0         0
    76 #define EI_MAG1         1
    77 #define EI_MAG2         2
    78 #define EI_MAG3         3
    79 #define EI_CLASS        4               /* File class */
    80 #define EI_DATA         5               /* Data encoding */
    81 #define EI_VERSION      6               /* File version */
    82 #define EI_OSABI        7
    83 #define EI_ABIVERSION   8
    84 #define EI_PAD          9               /* Start of padding bytes */
    85 #define EI_NIDENT       16              /* ELF identification table size */
     75#define EI_MAG0        0
     76#define EI_MAG1        1
     77#define EI_MAG2        2
     78#define EI_MAG3        3
     79#define EI_CLASS       4   /* File class */
     80#define EI_DATA        5   /* Data encoding */
     81#define EI_VERSION     6   /* File version */
     82#define EI_OSABI       7
     83#define EI_ABIVERSION  8
     84#define EI_PAD         9   /* Start of padding bytes */
     85#define EI_NIDENT      16  /* ELF identification table size */
    8686
    8787/**
    8888 * ELF magic number
    8989 */
    90 #define ELFMAG0         0x7f
    91 #define ELFMAG1         'E'
    92 #define ELFMAG2         'L'
    93 #define ELFMAG3         'F'
     90#define ELFMAG0  0x7f
     91#define ELFMAG1  'E'
     92#define ELFMAG2  'L'
     93#define ELFMAG3  'F'
    9494
    9595/**
    9696 * ELF file classes
    9797 */
    98 #define ELFCLASSNONE    0
    99 #define ELFCLASS32      1
    100 #define ELFCLASS64      2
     98#define ELFCLASSNONE  0
     99#define ELFCLASS32    1
     100#define ELFCLASS64    2
    101101
    102102/**
    103103 * ELF data encoding types
    104104 */
    105 #define ELFDATANONE     0
    106 #define ELFDATA2LSB     1               /* Least significant byte first (little endian) */
    107 #define ELFDATA2MSB     2               /* Most signigicant byte first (big endian) */
     105#define ELFDATANONE  0
     106#define ELFDATA2LSB  1  /* Least significant byte first (little endian) */
     107#define ELFDATA2MSB  2  /* Most signigicant byte first (big endian) */
    108108
    109109/**
    110110 * ELF error return codes
    111111 */
    112 #define EE_OK                   0       /* No error */
    113 #define EE_INVALID              1       /* Invalid ELF image */
    114 #define EE_MEMORY               2       /* Cannot allocate address space */
    115 #define EE_INCOMPATIBLE         3       /* ELF image is not compatible with current architecture */
    116 #define EE_UNSUPPORTED          4       /* Non-supported ELF (e.g. dynamic ELFs) */
    117 #define EE_LOADER               5       /* The image is actually a program loader */
    118 #define EE_IRRECOVERABLE        6
     112#define EE_OK             0  /* No error */
     113#define EE_INVALID        1  /* Invalid ELF image */
     114#define EE_MEMORY         2  /* Cannot allocate address space */
     115#define EE_INCOMPATIBLE   3  /* ELF image is not compatible with current architecture */
     116#define EE_UNSUPPORTED    4  /* Non-supported ELF (e.g. dynamic ELFs) */
     117#define EE_LOADER         5  /* The image is actually a program loader */
     118#define EE_IRRECOVERABLE  6
    119119
    120120/**
    121121 * ELF section types
    122122 */
    123 #define SHT_NULL                0
    124 #define SHT_PROGBITS            1
    125 #define SHT_SYMTAB              2
    126 #define SHT_STRTAB              3
    127 #define SHT_RELA                4
    128 #define SHT_HASH                5
    129 #define SHT_DYNAMIC             6
    130 #define SHT_NOTE                7
    131 #define SHT_NOBITS              8
    132 #define SHT_REL                 9
    133 #define SHT_SHLIB               10
    134 #define SHT_DYNSYM              11
    135 #define SHT_LOOS                0x60000000
    136 #define SHT_HIOS                0x6fffffff
    137 #define SHT_LOPROC              0x70000000
    138 #define SHT_HIPROC              0x7fffffff
    139 #define SHT_LOUSER              0x80000000
    140 #define SHT_HIUSER              0xffffffff
     123#define SHT_NULL      0
     124#define SHT_PROGBITS  1
     125#define SHT_SYMTAB    2
     126#define SHT_STRTAB    3
     127#define SHT_RELA      4
     128#define SHT_HASH      5
     129#define SHT_DYNAMIC   6
     130#define SHT_NOTE      7
     131#define SHT_NOBITS    8
     132#define SHT_REL       9
     133#define SHT_SHLIB     10
     134#define SHT_DYNSYM    11
     135#define SHT_LOOS      0x60000000
     136#define SHT_HIOS      0x6fffffff
     137#define SHT_LOPROC    0x70000000
     138#define SHT_HIPROC    0x7fffffff
     139#define SHT_LOUSER    0x80000000
     140#define SHT_HIUSER    0xffffffff
    141141
    142142/**
    143143 * ELF section flags
    144144 */
    145 #define SHF_WRITE               0x1
    146 #define SHF_ALLOC               0x2
    147 #define SHF_EXECINSTR           0x4
    148 #define SHF_TLS                 0x400
    149 #define SHF_MASKPROC            0xf0000000
     145#define SHF_WRITE      0x1
     146#define SHF_ALLOC      0x2
     147#define SHF_EXECINSTR  0x4
     148#define SHF_TLS        0x400
     149#define SHF_MASKPROC   0xf0000000
    150150
    151151/**
    152152 * Symbol binding
    153153 */
    154 #define STB_LOCAL               0
    155 #define STB_GLOBAL              1
    156 #define STB_WEAK                2
    157 #define STB_LOPROC              13
    158 #define STB_HIPROC              15
     154#define STB_LOCAL   0
     155#define STB_GLOBAL  1
     156#define STB_WEAK    2
     157#define STB_LOPROC  13
     158#define STB_HIPROC  15
    159159
    160160/**
    161161 * Symbol types
    162162 */
    163 #define STT_NOTYPE              0
    164 #define STT_OBJECT              1
    165 #define STT_FUNC                2
    166 #define STT_SECTION             3
    167 #define STT_FILE                4
    168 #define STT_LOPROC              13
    169 #define STT_HIPROC              15
     163#define STT_NOTYPE   0
     164#define STT_OBJECT   1
     165#define STT_FUNC     2
     166#define STT_SECTION  3
     167#define STT_FILE     4
     168#define STT_LOPROC   13
     169#define STT_HIPROC   15
    170170
    171171/**
    172172 * Program segment types
    173173 */
    174 #define PT_NULL                 0
    175 #define PT_LOAD                 1
    176 #define PT_DYNAMIC              2
    177 #define PT_INTERP               3
    178 #define PT_NOTE                 4
    179 #define PT_SHLIB                5
    180 #define PT_PHDR                 6
    181 #define PT_LOPROC               0x70000000
    182 #define PT_HIPROC               0x7fffffff
     174#define PT_NULL     0
     175#define PT_LOAD     1
     176#define PT_DYNAMIC  2
     177#define PT_INTERP   3
     178#define PT_NOTE     4
     179#define PT_SHLIB    5
     180#define PT_PHDR     6
     181#define PT_LOPROC   0x70000000
     182#define PT_HIPROC   0x7fffffff
    183183
    184184/**
    185185 * Program segment attributes.
    186186 */
    187 #define PF_X    1
    188 #define PF_W    2
    189 #define PF_R    4
     187#define PF_X  1
     188#define PF_W  2
     189#define PF_R  4
    190190
    191191/**
     
    195195 * ELF object file specifications. They are the only types used
    196196 * in ELF header.
     197 *
    197198 */
    198199typedef uint64_t elf_xword;
     
    206207 *
    207208 * These types are specific for 32-bit format.
     209 *
    208210 */
    209211typedef uint32_t elf32_addr;
     
    214216 *
    215217 * These types are specific for 64-bit format.
     218 *
    216219 */
    217220typedef uint64_t elf64_addr;
     
    235238        elf_half e_shstrndx;
    236239};
     240
    237241struct elf64_header {
    238242        uint8_t e_ident[EI_NIDENT];
     
    252256};
    253257
    254 /*
     258/**
    255259 * ELF segment header.
    256260 * Segments headers are also known as program headers.
     
    266270        elf_word p_align;
    267271};
     272
    268273struct elf64_segment_header {
    269274        elf_word p_type;
     
    277282};
    278283
    279 /*
     284/**
    280285 * ELF section header
    281286 */
     
    292297        elf_word sh_entsize;
    293298};
     299
    294300struct elf64_section_header {
    295301        elf_word sh_name;
     
    305311};
    306312
    307 /*
     313/**
    308314 * ELF symbol table entry
    309315 */
     
    316322        elf_half st_shndx;
    317323};
     324
    318325struct elf64_symbol {
    319326        elf_word st_name;
     
    325332};
    326333
    327 #ifdef __32_BITS__ 
     334#ifdef __32_BITS__
    328335typedef struct elf32_header elf_header_t;
    329336typedef struct elf32_segment_header elf_segment_header_t;
     
    331338typedef struct elf32_symbol elf_symbol_t;
    332339#endif
     340
    333341#ifdef __64_BITS__
    334342typedef struct elf64_header elf_header_t;
     
    338346#endif
    339347
    340 extern char *elf_error(unsigned int rc);
    341 
    342 /* Interpreter string used to recognize the program loader */
    343 #define ELF_INTERP_ZSTR "kernel"
     348extern const char *elf_error(unsigned int rc);
     349
     350/** Interpreter string used to recognize the program loader */
     351#define ELF_INTERP_ZSTR  "kernel"
    344352#define ELF_INTERP_ZLEN  sizeof(ELF_INTERP_ZSTR)
    345353
  • kernel/generic/include/lib/rd.h

    rb50b5af2 r04803bf  
    3636#define KERN_RD_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040/**
    4141 * RAM disk version
    4242 */
    43 #define RD_VERSION      1
     43#define RD_VERSION      1
    4444
    4545/**
  • kernel/generic/include/macros.h

    rb50b5af2 r04803bf  
    3838#ifndef __ASM__
    3939
    40 #include <arch/types.h>
     40#include <typedefs.h>
     41#include <trace.h>
    4142
    4243/** Return true if the intervals overlap.
     
    4647 * @param s2  Start address of the second interval.
    4748 * @param sz2 Size of the second interval.
     49 *
    4850 */
    49 static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2)
     51NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2,
     52    uint64_t sz2)
    5053{
    51         uintptr_t e1 = s1 + sz1;
    52         uintptr_t e2 = s2 + sz2;
     54        uint64_t e1 = s1 + sz1;
     55        uint64_t e2 = s2 + sz2;
    5356       
    5457        return ((s1 < e2) && (s2 < e1));
     58}
     59
     60/** Return true if the second interval is within the first interval.
     61 *
     62 * @param s1  Start address of the first interval.
     63 * @param sz1 Size of the first interval.
     64 * @param s2  Start address of the second interval.
     65 * @param sz2 Size of the second interval.
     66 *
     67 */
     68NO_TRACE static inline int iswithin(uint64_t s1, uint64_t sz1, uint64_t s2,
     69    uint64_t sz2)
     70{
     71        uint64_t e1 = s1 + sz1;
     72        uint64_t e2 = s2 + sz2;
     73       
     74        return ((s1 <= s2) && (e1 >= e2));
    5575}
    5676
     
    7292
    7393/* Compute overlapping of physical addresses */
    74 #define PA_overlaps(x, szx, y, szy) \
     94#define PA_OVERLAPS(x, szx, y, szy) \
    7595        overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy))
    7696
     
    84104#define STRING_ARG(arg)  #arg
    85105
    86 #define LOWER32(arg)  ((arg) & 0xffffffff)
    87 #define UPPER32(arg)  (((arg) >> 32) & 0xffffffff)
     106#define LOWER32(arg)  (((uint64_t) (arg)) & UINT32_C(0xffffffff))
     107#define UPPER32(arg)  (((((uint64_t) arg)) >> 32) & UINT32_C(0xffffffff))
    88108
    89109#define MERGE_LOUP32(lo, up) \
    90         ((((uint64_t) (lo)) & 0xffffffff) \
    91             | ((((uint64_t) (up)) & 0xffffffff) << 32))
     110        ((((uint64_t) (lo)) & UINT32_C(0xffffffff)) \
     111            | ((((uint64_t) (up)) & UINT32_C(0xffffffff)) << 32))
    92112
    93113/** Pseudorandom generator
  • kernel/generic/include/main/main.h

    rb50b5af2 r04803bf  
    3232/** @file
    3333 */
    34  
     34
    3535#ifndef KERN_MAIN_H_
    3636#define KERN_MAIN_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.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/main/uinit.h

    rb50b5af2 r04803bf  
    3636#define KERN_UINIT_H_
    3737
    38 #include <arch/types.h>
    39 
    4038extern void uinit(void *arg);
    4139
  • kernel/generic/include/main/version.h

    rb50b5af2 r04803bf  
    4242/** @}
    4343 */
    44 
  • kernel/generic/include/memstr.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_MEMSTR_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <arch/memstr.h>
    4040
  • kernel/generic/include/mm/as.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    3636#define KERN_AS_H_
    3737
     38#ifdef KERNEL
     39        #include <typedefs.h>
     40#else
     41        #include <sys/types.h>
     42#endif
     43
    3844/** Address space area flags. */
    39 #define AS_AREA_READ            1
    40 #define AS_AREA_WRITE           2
    41 #define AS_AREA_EXEC            4
    42 #define AS_AREA_CACHEABLE       8
     45#define AS_AREA_READ       1
     46#define AS_AREA_WRITE      2
     47#define AS_AREA_EXEC       4
     48#define AS_AREA_CACHEABLE  8
     49
     50/** Address space area info exported to userspace. */
     51typedef struct {
     52        /** Starting address */
     53        uintptr_t start_addr;
     54       
     55        /** Area size */
     56        size_t size;
     57       
     58        /** Area flags */
     59        unsigned int flags;
     60} as_area_info_t;
    4361
    4462#ifdef KERNEL
     
    4765#include <arch/mm/as.h>
    4866#include <arch/mm/asid.h>
    49 #include <arch/types.h>
     67#include <typedefs.h>
    5068#include <synch/spinlock.h>
    5169#include <synch/mutex.h>
     
    5775 * Defined to be true if user address space and kernel address space shadow each
    5876 * other.
    59  */
    60 #define KERNEL_ADDRESS_SPACE_SHADOWED   KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
    61 
    62 #define KERNEL_ADDRESS_SPACE_START      KERNEL_ADDRESS_SPACE_START_ARCH
    63 #define KERNEL_ADDRESS_SPACE_END        KERNEL_ADDRESS_SPACE_END_ARCH
    64 #define USER_ADDRESS_SPACE_START        USER_ADDRESS_SPACE_START_ARCH
    65 #define USER_ADDRESS_SPACE_END          USER_ADDRESS_SPACE_END_ARCH
    66 
    67 #define USTACK_ADDRESS                  USTACK_ADDRESS_ARCH
     77 *
     78 */
     79#define KERNEL_ADDRESS_SPACE_SHADOWED  KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
     80
     81#define KERNEL_ADDRESS_SPACE_START  KERNEL_ADDRESS_SPACE_START_ARCH
     82#define KERNEL_ADDRESS_SPACE_END    KERNEL_ADDRESS_SPACE_END_ARCH
     83#define USER_ADDRESS_SPACE_START    USER_ADDRESS_SPACE_START_ARCH
     84#define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
     85
     86#define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
    6887
    6988/** Kernel address space. */
    70 #define FLAG_AS_KERNEL                  (1 << 0)       
     89#define FLAG_AS_KERNEL  (1 << 0)
    7190
    7291/* Address space area attributes. */
    73 #define AS_AREA_ATTR_NONE       0
    74 #define AS_AREA_ATTR_PARTIAL    1       /**< Not fully initialized area. */
     92#define AS_AREA_ATTR_NONE     0
     93#define AS_AREA_ATTR_PARTIAL  1  /**< Not fully initialized area. */
    7594
    7695/** The page fault was not resolved by as_page_fault(). */
    77 #define AS_PF_FAULT             0
     96#define AS_PF_FAULT  0
     97
    7898/** The page fault was resolved by as_page_fault(). */
    79 #define AS_PF_OK                1
     99#define AS_PF_OK  1
     100
    80101/** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
    81 #define AS_PF_DEFER             2
     102#define AS_PF_DEFER  2
    82103
    83104/** Address space structure.
     
    87108 * supposed to figure in the list as they are shared by all tasks and
    88109 * set up during system initialization.
     110 *
    89111 */
    90112typedef struct as {
    91113        /** Protected by asidlock. */
    92114        link_t inactive_as_with_asid_link;
     115       
    93116        /**
    94          * Number of processors on wich is this address space active.
    95          * Protected by asidlock.
     117         * Number of processors on which this
     118         * address space is active. Protected by
     119         * asidlock.
    96120         */
    97121        size_t cpu_refcount;
    98         /**
    99          * Address space identifier.
    100          * Constant on architectures that do not support ASIDs.
    101          * Protected by asidlock.
     122       
     123        /** Address space identifier.
     124         *
     125         * Constant on architectures that do not
     126         * support ASIDs. Protected by asidlock.
     127         *
    102128         */
    103129        asid_t asid;
    104 
    105         /** Number of references (i.e tasks that reference this as). */
     130       
     131        /** Number of references (i.e. tasks that reference this as). */
    106132        atomic_t refcount;
    107 
     133       
    108134        mutex_t lock;
    109 
     135       
    110136        /** B+tree of address space areas. */
    111137        btree_t as_area_btree;
     
    113139        /** Non-generic content. */
    114140        as_genarch_t genarch;
    115 
     141       
    116142        /** Architecture specific content. */
    117143        as_arch_t arch;
     
    119145
    120146typedef struct {
    121         pte_t *(* page_table_create)(int flags);
    122         void (* page_table_destroy)(pte_t *page_table);
    123         void (* page_table_lock)(as_t *as, bool lock);
    124         void (* page_table_unlock)(as_t *as, bool unlock);
     147        pte_t *(* page_table_create)(unsigned int);
     148        void (* page_table_destroy)(pte_t *);
     149        void (* page_table_lock)(as_t *, bool);
     150        void (* page_table_unlock)(as_t *, bool);
     151        bool (* page_table_locked)(as_t *);
    125152} as_operations_t;
    126153
     
    128155 * This structure contains information associated with the shared address space
    129156 * area.
     157 *
    130158 */
    131159typedef struct {
    132160        /** This lock must be acquired only when the as_area lock is held. */
    133         mutex_t lock;           
     161        mutex_t lock;
    134162        /** This structure can be deallocated if refcount drops to 0. */
    135163        size_t refcount;
     164       
    136165        /**
    137166         * B+tree containing complete map of anonymous pages of the shared area.
     
    144173        PF_ACCESS_READ,
    145174        PF_ACCESS_WRITE,
    146         PF_ACCESS_EXEC
     175        PF_ACCESS_EXEC,
     176        PF_ACCESS_UNKNOWN
    147177} pf_access_t;
    148178
     
    151181/** Backend data stored in address space area. */
    152182typedef union mem_backend_data {
    153         struct {        /**< elf_backend members */
     183        /** elf_backend members */
     184        struct {
    154185                elf_header_t *elf;
    155186                elf_segment_header_t *segment;
    156187        };
    157         struct {        /**< phys_backend members */
     188       
     189        /** phys_backend members */
     190        struct {
    158191                uintptr_t base;
    159192                size_t frames;
     
    164197 *
    165198 * Each as_area_t structure describes one contiguous area of virtual memory.
     199 *
    166200 */
    167201typedef struct {
    168202        mutex_t lock;
     203       
    169204        /** Containing address space. */
    170         as_t *as;               
    171         /**
    172          * Flags related to the memory represented by the address space area.
    173          */
    174         int flags;
    175         /** Attributes related to the address space area itself. */
    176         int attributes;
    177         /** Size of this area in multiples of PAGE_SIZE. */
     205        as_t *as;
     206       
     207        /** Memory flags. */
     208        unsigned int flags;
     209       
     210        /** Address space area attributes. */
     211        unsigned int attributes;
     212       
     213        /** Number of pages in the area. */
    178214        size_t pages;
     215       
     216        /** Number of resident pages in the area. */
     217        size_t resident;
     218       
    179219        /** Base address of this area. */
    180220        uintptr_t base;
     221       
    181222        /** Map of used space. */
    182223        btree_t used_space;
    183 
     224       
    184225        /**
    185          * If the address space area has been shared, this pointer will
    186          * reference the share info structure.
     226         * If the address space area is shared. this is
     227         * a reference to the share info structure.
    187228         */
    188229        share_info_t *sh_info;
    189 
     230       
    190231        /** Memory backend backing this address space area. */
    191232        struct mem_backend *backend;
    192 
     233       
    193234        /** Data to be used by the backend. */
    194235        mem_backend_data_t backend_data;
     
    197238/** Address space area backend structure. */
    198239typedef struct mem_backend {
    199         int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
    200         void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
    201         void (* share)(as_area_t *area);
     240        int (* page_fault)(as_area_t *, uintptr_t, pf_access_t);
     241        void (* frame_free)(as_area_t *, uintptr_t, uintptr_t);
     242        void (* share)(as_area_t *);
    202243} mem_backend_t;
    203244
     
    209250extern void as_init(void);
    210251
    211 extern as_t *as_create(int flags);
    212 extern void as_destroy(as_t *as);
    213 extern void as_switch(as_t *old_as, as_t *new_as);
    214 extern int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate);
    215 
    216 extern as_area_t *as_area_create(as_t *as, int flags, size_t size,
    217     uintptr_t base, int attrs, mem_backend_t *backend,
    218     mem_backend_data_t *backend_data);
    219 extern int as_area_destroy(as_t *as, uintptr_t address);       
    220 extern int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags);
    221 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
    222     as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);
    223 extern int as_area_change_flags(as_t *as, int flags, uintptr_t address);
    224 
    225 extern int as_area_get_flags(as_area_t *area);
    226 extern bool as_area_check_access(as_area_t *area, pf_access_t access);
    227 extern size_t as_area_get_size(uintptr_t base);
    228 extern int used_space_insert(as_area_t *a, uintptr_t page, size_t count);
    229 extern int used_space_remove(as_area_t *a, uintptr_t page, size_t count);
    230 
     252extern as_t *as_create(unsigned int);
     253extern void as_destroy(as_t *);
     254extern void as_hold(as_t *);
     255extern void as_release(as_t *);
     256extern void as_switch(as_t *, as_t *);
     257extern int as_page_fault(uintptr_t, pf_access_t, istate_t *);
     258
     259extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t,
     260    unsigned int, mem_backend_t *, mem_backend_data_t *);
     261extern int as_area_destroy(as_t *, uintptr_t);
     262extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int);
     263extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t,
     264    unsigned int);
     265extern int as_area_change_flags(as_t *, unsigned int, uintptr_t);
     266
     267extern unsigned int as_area_get_flags(as_area_t *);
     268extern bool as_area_check_access(as_area_t *, pf_access_t);
     269extern size_t as_area_get_size(uintptr_t);
     270extern bool used_space_insert(as_area_t *, uintptr_t, size_t);
     271extern bool used_space_remove(as_area_t *, uintptr_t, size_t);
    231272
    232273/* Interface to be implemented by architectures. */
     274
    233275#ifndef as_constructor_arch
    234 extern int as_constructor_arch(as_t *as, int flags);
     276extern int as_constructor_arch(as_t *, unsigned int);
    235277#endif /* !def as_constructor_arch */
     278
    236279#ifndef as_destructor_arch
    237 extern int as_destructor_arch(as_t *as);
     280extern int as_destructor_arch(as_t *);
    238281#endif /* !def as_destructor_arch */
     282
    239283#ifndef as_create_arch
    240 extern int as_create_arch(as_t *as, int flags);
     284extern int as_create_arch(as_t *, unsigned int);
    241285#endif /* !def as_create_arch */
     286
    242287#ifndef as_install_arch
    243 extern void as_install_arch(as_t *as);
     288extern void as_install_arch(as_t *);
    244289#endif /* !def as_install_arch */
     290
    245291#ifndef as_deinstall_arch
    246 extern void as_deinstall_arch(as_t *as);
     292extern void as_deinstall_arch(as_t *);
    247293#endif /* !def as_deinstall_arch */
    248294
     
    252298extern mem_backend_t phys_backend;
    253299
    254 /** 
     300/**
    255301 * This flags is passed when running the loader, otherwise elf_load()
    256302 * would return with a EE_LOADER error code.
    257  */
    258 #define ELD_F_NONE      0
    259 #define ELD_F_LOADER    1
    260 
    261 extern unsigned int elf_load(elf_header_t *header, as_t *as, int flags);
     303 *
     304 */
     305#define ELD_F_NONE    0
     306#define ELD_F_LOADER  1
     307
     308extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int);
    262309
    263310/* Address space area related syscalls. */
    264 extern unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);
    265 extern unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags);
    266 extern unative_t sys_as_area_change_flags(uintptr_t address, int flags);
    267 extern unative_t sys_as_area_destroy(uintptr_t address);
     311extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int);
     312extern sysarg_t sys_as_area_resize(uintptr_t, size_t, unsigned int);
     313extern sysarg_t sys_as_area_change_flags(uintptr_t, unsigned int);
     314extern sysarg_t sys_as_area_destroy(uintptr_t);
     315extern sysarg_t sys_as_get_unmapped_area(uintptr_t, size_t);
    268316
    269317/* Introspection functions. */
    270 extern void as_print(as_t *as);
     318extern void as_get_area_info(as_t *, as_area_info_t **, size_t *);
     319extern void as_print(as_t *);
    271320
    272321#endif /* KERNEL */
  • kernel/generic/include/mm/buddy.h

    rb50b5af2 r04803bf  
    3636#define KERN_BUDDY_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <adt/list.h>
    4040
  • kernel/generic/include/mm/frame.h

    rb50b5af2 r04803bf  
    3737#define KERN_FRAME_H_
    3838
    39 #include <arch/types.h>
     39#include <typedefs.h>
     40#include <trace.h>
    4041#include <adt/list.h>
    4142#include <mm/buddy.h>
     
    8182
    8283typedef struct {
    83         size_t refcount;     /**< Tracking of shared frames */
     84        size_t refcount;      /**< Tracking of shared frames */
    8485        uint8_t buddy_order;  /**< Buddy system block order */
    8586        link_t buddy_link;    /**< Link to the next free block inside
     
    9192        pfn_t base;                    /**< Frame_no of the first frame
    9293                                        in the frames array */
    93         size_t count;                 /**< Size of zone */
    94         size_t free_count;            /**< Number of free frame_t
     94        size_t count;                  /**< Size of zone */
     95        size_t free_count;             /**< Number of free frame_t
    9596                                        structures */
    96         size_t busy_count;            /**< Number of busy frame_t
     97        size_t busy_count;             /**< Number of busy frame_t
    9798                                        structures */
    9899        zone_flags_t flags;            /**< Type of the zone */
     
    108109 */
    109110typedef struct {
    110         SPINLOCK_DECLARE(lock);
     111        IRQ_SPINLOCK_DECLARE(lock);
    111112        size_t count;
    112113        zone_t info[ZONES_MAX];
     
    115116extern zones_t zones;
    116117
    117 static inline uintptr_t PFN2ADDR(pfn_t frame)
     118NO_TRACE static inline uintptr_t PFN2ADDR(pfn_t frame)
    118119{
    119120        return (uintptr_t) (frame << FRAME_WIDTH);
    120121}
    121122
    122 static inline pfn_t ADDR2PFN(uintptr_t addr)
     123NO_TRACE static inline pfn_t ADDR2PFN(uintptr_t addr)
    123124{
    124125        return (pfn_t) (addr >> FRAME_WIDTH);
    125126}
    126127
    127 static inline size_t SIZE2FRAMES(size_t size)
     128NO_TRACE static inline size_t SIZE2FRAMES(size_t size)
    128129{
    129130        if (!size)
     
    132133}
    133134
    134 static inline size_t FRAMES2SIZE(size_t frames)
     135NO_TRACE static inline size_t FRAMES2SIZE(size_t frames)
    135136{
    136137        return (size_t) (frames << FRAME_WIDTH);
    137138}
    138139
    139 static inline bool zone_flags_available(zone_flags_t flags)
     140NO_TRACE static inline bool zone_flags_available(zone_flags_t flags)
    140141{
    141142        return ((flags & (ZONE_RESERVED | ZONE_FIRMWARE)) == 0);
     
    143144
    144145#define IS_BUDDY_ORDER_OK(index, order) \
    145     ((~(((unative_t) -1) << (order)) & (index)) == 0)
     146    ((~(((sysarg_t) -1) << (order)) & (index)) == 0)
    146147#define IS_BUDDY_LEFT_BLOCK(zone, frame) \
    147148    (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 0)
     
    166167extern void frame_set_parent(pfn_t, void *, size_t);
    167168extern void frame_mark_unavailable(pfn_t, size_t);
    168 extern uintptr_t zone_conf_size(size_t);
     169extern size_t zone_conf_size(size_t);
    169170extern bool zone_merge(size_t, size_t);
    170171extern void zone_merge_all(void);
    171 extern uint64_t zone_total_size(void);
     172extern uint64_t zones_total_size(void);
     173extern void zones_stats(uint64_t *, uint64_t *, uint64_t *, uint64_t *);
    172174
    173175/*
    174176 * Console functions
    175177 */
    176 extern void zone_print_list(void);
     178extern void zones_print_list(void);
    177179extern void zone_print_one(size_t);
    178180
  • kernel/generic/include/mm/page.h

    rb50b5af2 r04803bf  
    3636#define KERN_PAGE_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <mm/as.h>
    4040#include <memstr.h>
     
    4242/** Operations to manipulate page mappings. */
    4343typedef struct {
    44         void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame,
    45             int flags);
    46         void (* mapping_remove)(as_t *as, uintptr_t page);
    47         pte_t *(* mapping_find)(as_t *as, uintptr_t page);
     44        void (* mapping_insert)(as_t *, uintptr_t, uintptr_t, unsigned int);
     45        void (* mapping_remove)(as_t *, uintptr_t);
     46        pte_t *(* mapping_find)(as_t *, uintptr_t);
    4847} page_mapping_operations_t;
    4948
     
    5150
    5251extern void page_init(void);
    53 extern void page_table_lock(as_t *as, bool lock);
    54 extern void page_table_unlock(as_t *as, bool unlock);
    55 extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
    56     int flags);
    57 extern void page_mapping_remove(as_t *as, uintptr_t page);
    58 extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
    59 extern pte_t *page_table_create(int flags);
    60 extern void page_table_destroy(pte_t *page_table);
    61 extern void map_structure(uintptr_t s, size_t size);
     52extern void page_table_lock(as_t *, bool);
     53extern void page_table_unlock(as_t *, bool);
     54extern bool page_table_locked(as_t *);
     55extern void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
     56extern void page_mapping_remove(as_t *, uintptr_t);
     57extern pte_t *page_mapping_find(as_t *, uintptr_t);
     58extern pte_t *page_table_create(unsigned int);
     59extern void page_table_destroy(pte_t *);
     60extern void map_structure(uintptr_t, size_t);
    6261
    63 extern uintptr_t hw_map(uintptr_t physaddr, size_t size);
     62extern uintptr_t hw_map(uintptr_t, size_t);
    6463
    6564#endif
  • kernel/generic/include/mm/slab.h

    rb50b5af2 r04803bf  
    8484} slab_mag_cache_t;
    8585
    86 
    8786typedef struct {
    88         char *name;
     87        const char *name;
    8988       
    9089        link_t link;
     
    9493        size_t size;
    9594       
    96         int (*constructor)(void *obj, int kmflag);
    97         int (*destructor)(void *obj);
     95        int (*constructor)(void *obj, unsigned int kmflag);
     96        size_t (*destructor)(void *obj);
    9897       
    9998        /** Flags changing behaviour of cache */
    100         int flags;
     99        unsigned int flags;
    101100       
    102101        /* Computed values */
    103         uint8_t order;         /**< Order of frames to be allocated */
    104         unsigned int objects;  /**< Number of objects that fit in */
     102        uint8_t order;   /**< Order of frames to be allocated */
     103        size_t objects;  /**< Number of objects that fit in */
    105104       
    106105        /* Statistics */
     
    109108        atomic_t cached_objs;
    110109        /** How many magazines in magazines list */
    111         atomic_t magazine_counter; 
     110        atomic_t magazine_counter;
    112111       
    113112        /* Slabs */
     
    123122} slab_cache_t;
    124123
    125 extern slab_cache_t *slab_cache_create(char *, size_t, size_t,
    126     int (*)(void *, int), int (*)(void *), int);
     124extern slab_cache_t *slab_cache_create(const char *, size_t, size_t,
     125    int (*)(void *, unsigned int), size_t (*)(void *), unsigned int);
    127126extern void slab_cache_destroy(slab_cache_t *);
    128127
    129 extern void * slab_alloc(slab_cache_t *, int);
     128extern void *slab_alloc(slab_cache_t *, unsigned int)
     129    __attribute__((malloc));
    130130extern void slab_free(slab_cache_t *, void *);
    131 extern size_t slab_reclaim(int);
     131extern size_t slab_reclaim(unsigned int);
    132132
    133133/* slab subsytem initialization */
     
    139139
    140140/* malloc support */
    141 extern void *malloc(unsigned int, int);
    142 extern void *realloc(void *, unsigned int, int);
     141extern void *malloc(size_t, unsigned int)
     142    __attribute__((malloc));
     143extern void *realloc(void *, size_t, unsigned int);
    143144extern void free(void *);
    144145
  • kernel/generic/include/mm/tlb.h

    rb50b5af2 r04803bf  
    3737
    3838#include <arch/mm/asid.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141/**
     
    6868
    6969#ifdef CONFIG_SMP
    70 extern void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid,
    71     uintptr_t page, size_t count);
    72 extern void tlb_shootdown_finalize(void);
     70extern ipl_t tlb_shootdown_start(tlb_invalidate_type_t, asid_t, uintptr_t,
     71    size_t);
     72extern void tlb_shootdown_finalize(ipl_t);
    7373extern void tlb_shootdown_ipi_recv(void);
    7474#else
    75 #define tlb_shootdown_start(w, x, y, z)
    76 #define tlb_shootdown_finalize()
     75#define tlb_shootdown_start(w, x, y, z) (0)
     76#define tlb_shootdown_finalize(i)       ((i) = (i));
    7777#define tlb_shootdown_ipi_recv()
    7878#endif /* CONFIG_SMP */
     
    8484
    8585extern void tlb_invalidate_all(void);
    86 extern void tlb_invalidate_asid(asid_t asid);
    87 extern void tlb_invalidate_pages(asid_t asid, uintptr_t page, size_t cnt);
     86extern void tlb_invalidate_asid(asid_t);
     87extern void tlb_invalidate_pages(asid_t, uintptr_t, size_t);
    8888#endif
    8989
  • kernel/generic/include/panic.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_PANIC_H_
    3737
    38 #ifdef CONFIG_DEBUG
    39 #       define panic(format, ...) \
    40                 panic_printf("Kernel panic in %s() at %s:%u: " format "\n", \
    41                 __func__, __FILE__, __LINE__, ##__VA_ARGS__);
    42 #else
    43 #       define panic(format, ...) \
    44                 panic_printf("Kernel panic: " format "\n", ##__VA_ARGS__);
    45 #endif
     38#include <typedefs.h>
     39#include <print.h>
    4640
    47 extern void panic_printf(char *fmt, ...) __attribute__((noreturn));
     41#define panic(fmt, ...) \
     42        panic_common(PANIC_OTHER, NULL, 0, 0, fmt, ##__VA_ARGS__)
     43
     44#define panic_assert(fmt, ...) \
     45        panic_common(PANIC_ASSERT, NULL, 0, 0, fmt, ##__VA_ARGS__)
     46
     47#define panic_badtrap(istate, n, fmt, ...) \
     48        panic_common(PANIC_BADTRAP, istate, 0, n, fmt, ##__VA_ARGS__)
     49
     50#define panic_memtrap(istate, access, addr, fmt, ...) \
     51        panic_common(PANIC_MEMTRAP, istate, access, addr, fmt, ##__VA_ARGS__)
     52
     53typedef enum {
     54        PANIC_OTHER,
     55        PANIC_ASSERT,
     56        PANIC_BADTRAP,
     57        PANIC_MEMTRAP
     58} panic_category_t;
     59
     60struct istate;
     61
     62extern bool silent;
     63
     64extern void panic_common(panic_category_t, struct istate *, int,
     65    uintptr_t, const char *, ...) __attribute__ ((noreturn))
     66    PRINTF_ATTRIBUTE(5, 6);
    4867
    4968#endif
  • kernel/generic/include/preemption.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
  • kernel/generic/include/print.h

    rb50b5af2 r04803bf  
    3636#define KERN_PRINT_H_
    3737
    38 #include <arch/types.h>
    39 #include <arch/arg.h>
     38#include <typedefs.h>
     39#include <stdarg.h>
    4040
    41 #define EOF (-1)
     41#ifndef NVERIFY_PRINTF
     42
     43#define PRINTF_ATTRIBUTE(start, end) \
     44        __attribute__((format(gnu_printf, start, end)))
     45
     46#else /* NVERIFY_PRINTF */
     47
     48#define PRINTF_ATTRIBUTE(start, end)
     49
     50#endif /* NVERIFY_PRINTF */
     51
     52#define EOF  (-1)
    4253
    4354extern int puts(const char *s);
    44 extern int printf(const char *fmt, ...);
    45 extern int snprintf(char *str, size_t size, const char *fmt, ...);
     55extern int printf(const char *fmt, ...)
     56    PRINTF_ATTRIBUTE(1, 2);
     57extern int snprintf(char *str, size_t size, const char *fmt, ...)
     58    PRINTF_ATTRIBUTE(3, 4);
    4659
    4760extern int vprintf(const char *fmt, va_list ap);
  • kernel/generic/include/printf/printf_core.h

    rb50b5af2 r04803bf  
    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. */
     
    5151} printf_spec_t;
    5252
    53 int printf_core(const char *fmt, printf_spec_t *ps, va_list ap);
     53extern int printf_core(const char *fmt, printf_spec_t *ps, va_list ap);
    5454
    5555#endif
  • kernel/generic/include/proc/program.h

    rb50b5af2 r04803bf  
    3636#define KERN_PROGRAM_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040struct task;
     
    4545 * A program is an abstraction of a freshly created (not yet running)
    4646 * userspace task containing a main thread along with its userspace stack.
     47 *
    4748 */
    4849typedef struct program {
    49         struct task *task;              /**< Program task */
    50         struct thread *main_thread;     /**< Program main thread */
     50        struct task *task;           /**< Program task */
     51        struct thread *main_thread;  /**< Program main thread */
    5152} program_t;
    5253
    5354extern void *program_loader;
    5455
    55 extern void program_create(as_t *as, uintptr_t entry_addr, char *name,
    56     program_t *p);
    57 extern int program_create_from_image(void *image_addr, char *name,
    58     program_t *p);
    59 extern int program_create_loader(program_t *p, char *name);
    60 extern void program_ready(program_t *p);
     56extern int program_create(as_t *, uintptr_t, char *, program_t *);
     57extern int program_create_from_image(void *, char *, program_t *);
     58extern int program_create_loader(program_t *, char *);
     59extern void program_ready(program_t *);
    6160
    62 extern unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len);
     61extern sysarg_t sys_program_spawn_loader(char *, size_t);
    6362
    6463#endif
  • kernel/generic/include/proc/scheduler.h

    rb50b5af2 r04803bf  
    3737
    3838#include <synch/spinlock.h>
    39 #include <time/clock.h>         /* HZ */
     39#include <time/clock.h>
     40#include <typedefs.h>
    4041#include <atomic.h>
    4142#include <adt/list.h>
    4243
    43 #define RQ_COUNT                16
    44 #define NEEDS_RELINK_MAX        (HZ)
     44#define RQ_COUNT          16
     45#define NEEDS_RELINK_MAX  (HZ)
    4546
    4647/** Scheduler run queue structure. */
    4748typedef struct {
    48         SPINLOCK_DECLARE(lock);
    49         link_t rq_head;         /**< List of ready threads. */
    50         size_t n;               /**< Number of threads in rq_ready. */
     49        IRQ_SPINLOCK_DECLARE(lock);
     50        link_t rq_head;              /**< List of ready threads. */
     51        size_t n;                    /**< Number of threads in rq_ready. */
    5152} runq_t;
    5253
     
    6162
    6263/*
    63  * To be defined by architectures:
     64 * To be defined by architectures.
    6465 */
    6566extern void before_task_runs_arch(void);
  • kernel/generic/include/proc/task.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    4040#include <synch/spinlock.h>
    4141#include <synch/mutex.h>
    42 #include <synch/rwlock.h>
    4342#include <synch/futex.h>
    4443#include <adt/avl.h>
     
    5554#include <udebug/udebug.h>
    5655#include <ipc/kbox.h>
    57 
    58 #define TASK_NAME_BUFLEN        20
     56#include <mm/as.h>
     57#include <sysinfo/abi.h>
    5958
    6059struct thread;
     
    7069         * threads.
    7170         */
    72         SPINLOCK_DECLARE(lock);
    73 
     71        IRQ_SPINLOCK_DECLARE(lock);
     72       
    7473        char name[TASK_NAME_BUFLEN];
    7574        /** List of threads contained in this task. */
     
    8079        task_id_t taskid;
    8180        /** Task security context. */
    82         context_id_t context;   
    83 
     81        context_id_t context;
     82       
    8483        /** Number of references (i.e. threads). */
    8584        atomic_t refcount;
    8685        /** Number of threads that haven't exited yet. */
    8786        atomic_t lifecount;
    88 
     87       
    8988        /** Task capabilities. */
    90         cap_t capabilities;     
    91 
     89        cap_t capabilities;
     90       
    9291        /* IPC stuff */
    9392        answerbox_t answerbox;  /**< Communication endpoint */
    9493        phone_t phones[IPC_MAX_PHONES];
    95         /**
    96          * Active asynchronous messages. It is used for limiting uspace to
    97          * certain extent.
    98          */
    99         atomic_t active_calls;
    100 
     94        stats_ipc_t ipc_info;   /**< IPC statistics */
     95        /** List of synchronous answerboxes. */
     96        link_t sync_box_head;
     97       
    10198#ifdef CONFIG_UDEBUG
    10299        /** Debugging stuff. */
    103100        udebug_task_t udebug;
    104 
     101       
    105102        /** Kernel answerbox. */
    106103        kbox_t kb;
    107 #endif
    108 
     104#endif /* CONFIG_UDEBUG */
     105       
    109106        /** Architecture specific task data. */
    110107        task_arch_t arch;
     
    116113        mutex_t futexes_lock;
    117114        /** B+tree of futexes referenced by this task. */
    118         btree_t futexes;       
     115        btree_t futexes;
    119116       
    120117        /** Accumulated accounting. */
    121         uint64_t cycles;
     118        uint64_t ucycles;
     119        uint64_t kcycles;
    122120} task_t;
    123121
    124 SPINLOCK_EXTERN(tasks_lock);
     122IRQ_SPINLOCK_EXTERN(tasks_lock);
    125123extern avltree_t tasks_tree;
    126124
    127125extern void task_init(void);
    128126extern void task_done(void);
    129 extern task_t *task_create(as_t *as, char *name);
    130 extern void task_destroy(task_t *t);
    131 extern task_t *task_find_by_id(task_id_t id);
    132 extern int task_kill(task_id_t id);
    133 extern uint64_t task_get_accounting(task_t *t);
     127extern task_t *task_create(as_t *, const char *);
     128extern void task_destroy(task_t *);
     129extern void task_hold(task_t *);
     130extern void task_release(task_t *);
     131extern task_t *task_find_by_id(task_id_t);
     132extern int task_kill(task_id_t);
     133extern void task_kill_self(bool) __attribute__((noreturn));
     134extern void task_get_accounting(task_t *, uint64_t *, uint64_t *);
     135extern void task_print_list(bool);
    134136
    135 extern void cap_set(task_t *t, cap_t caps);
    136 extern cap_t cap_get(task_t *t);
     137extern void cap_set(task_t *, cap_t);
     138extern cap_t cap_get(task_t *);
    137139
    138140#ifndef task_create_arch
    139 extern void task_create_arch(task_t *t);
     141extern void task_create_arch(task_t *);
    140142#endif
    141143
    142144#ifndef task_destroy_arch
    143 extern void task_destroy_arch(task_t *t);
     145extern void task_destroy_arch(task_t *);
    144146#endif
    145147
    146 extern unative_t sys_task_get_id(task_id_t *uspace_task_id);
    147 extern unative_t sys_task_set_name(const char *uspace_name, size_t name_len);
     148#ifdef __32_BITS__
     149extern sysarg_t sys_task_get_id(sysarg64_t *);
     150#endif
     151
     152#ifdef __64_BITS__
     153extern sysarg_t sys_task_get_id(void);
     154#endif
     155
     156extern sysarg_t sys_task_set_name(const char *, size_t);
     157extern sysarg_t sys_task_kill(task_id_t *);
     158extern sysarg_t sys_task_exit(sysarg_t);
    148159
    149160#endif
  • kernel/generic/include/proc/thread.h

    rb50b5af2 r04803bf  
    4040#include <time/timeout.h>
    4141#include <cpu.h>
    42 #include <synch/rwlock.h>
    4342#include <synch/spinlock.h>
    4443#include <adt/avl.h>
     
    4847#include <proc/uarg.h>
    4948#include <udebug/udebug.h>
    50 
    51 #define THREAD_STACK_SIZE       STACK_SIZE
    52 #define THREAD_NAME_BUFLEN      20
    53 
    54 extern char *thread_states[];
     49#include <sysinfo/abi.h>
     50
     51#define THREAD_STACK_SIZE   STACK_SIZE
     52#define THREAD_NAME_BUFLEN  20
     53
     54extern const char *thread_states[];
    5555
    5656/* Thread flags */
     
    6060 * When using this flag, the caller must set cpu in the thread_t
    6161 * structure manually before calling thread_ready (even on uniprocessor).
    62  */
    63 #define THREAD_FLAG_WIRED       (1 << 0)
     62 *
     63 */
     64#define THREAD_FLAG_WIRED  (1 << 0)
     65
    6466/** Thread was migrated to another CPU and has not run yet. */
    65 #define THREAD_FLAG_STOLEN      (1 << 1)
     67#define THREAD_FLAG_STOLEN  (1 << 1)
     68
    6669/** Thread executes in userspace. */
    67 #define THREAD_FLAG_USPACE      (1 << 2)
     70#define THREAD_FLAG_USPACE  (1 << 2)
     71
    6872/** Thread will be attached by the caller. */
    69 #define THREAD_FLAG_NOATTACH    (1 << 3)
    70 
    71 /** Thread states. */
    72 typedef enum {
    73         /** It is an error, if thread is found in this state. */
    74         Invalid,
    75         /** State of a thread that is currently executing on some CPU. */
    76         Running,
    77         /** Thread in this state is waiting for an event. */
    78         Sleeping,
    79         /** State of threads in a run queue. */
    80         Ready,
    81         /** Threads are in this state before they are first readied. */
    82         Entering,
    83         /** After a thread calls thread_exit(), it is put into Exiting state. */
    84         Exiting,
    85         /** Threads that were not detached but exited are Lingering. */
    86         Lingering
    87 } state_t;
     73#define THREAD_FLAG_NOATTACH  (1 << 3)
    8874
    8975/** Thread structure. There is one per thread. */
    9076typedef struct thread {
    91         link_t rq_link;         /**< Run queue link. */
    92         link_t wq_link;         /**< Wait queue link. */
    93         link_t th_link;         /**< Links to threads within containing task. */
    94 
     77        link_t rq_link;  /**< Run queue link. */
     78        link_t wq_link;  /**< Wait queue link. */
     79        link_t th_link;  /**< Links to threads within containing task. */
     80       
    9581        /** Threads linkage to the threads_tree. */
    9682        avltree_node_t threads_tree_node;
     
    10086         * Protects the whole thread structure except list links above.
    10187         */
    102         SPINLOCK_DECLARE(lock);
    103 
     88        IRQ_SPINLOCK_DECLARE(lock);
     89       
    10490        char name[THREAD_NAME_BUFLEN];
    105 
     91       
    10692        /** Function implementing the thread. */
    107         void (* thread_code)(void *);
     93        void (*thread_code)(void *);
    10894        /** Argument passed to thread_code() function. */
    10995        void *thread_arg;
    110 
    111         /**
    112          * From here, the stored context is restored when the thread is
    113          * scheduled.
     96       
     97        /**
     98         * From here, the stored context is restored
     99         * when the thread is scheduled.
    114100         */
    115101        context_t saved_context;
    116         /**
    117          * From here, the stored timeout context is restored when sleep times
    118          * out.
     102       
     103        /**
     104         * From here, the stored timeout context
     105         * is restored when sleep times out.
    119106         */
    120107        context_t sleep_timeout_context;
    121         /**
    122          * From here, the stored interruption context is restored when sleep is
    123          * interrupted.
     108       
     109        /**
     110         * From here, the stored interruption context
     111         * is restored when sleep is interrupted.
    124112         */
    125113        context_t sleep_interruption_context;
    126 
     114       
    127115        /** If true, the thread can be interrupted from sleep. */
    128116        bool sleep_interruptible;
     
    132120        timeout_t sleep_timeout;
    133121        /** Flag signalling sleep timeout in progress. */
    134         volatile int timeout_pending;
    135 
     122        volatile bool timeout_pending;
     123       
    136124        /**
    137125         * True if this thread is executing copy_from_uspace().
     
    139127         */
    140128        bool in_copy_from_uspace;
     129       
    141130        /**
    142131         * True if this thread is executing copy_to_uspace().
     
    149138         * thread_exit() before returning to userspace.
    150139         */
    151         bool interrupted;                       
     140        bool interrupted;
    152141       
    153142        /** If true, thread_join_timeout() cannot be used on this thread. */
     
    157146        /** Link used in the joiner_head list. */
    158147        link_t joiner_link;
    159 
     148       
    160149        fpu_context_t *saved_fpu_context;
    161150        int fpu_context_exists;
    162 
     151       
    163152        /*
    164153         * Defined only if thread doesn't run.
     
    167156         */
    168157        int fpu_context_engaged;
    169 
    170         rwlock_type_t rwlock_holder_type;
    171 
    172         /** Callback fired in scheduler before the thread is put asleep. */
    173         void (* call_me)(void *);
    174         /** Argument passed to call_me(). */
    175         void *call_me_with;
    176 
     158       
    177159        /** Thread's state. */
    178160        state_t state;
    179161        /** Thread's flags. */
    180         int flags;
     162        unsigned int flags;
    181163       
    182164        /** Thread's CPU. */
     
    184166        /** Containing task. */
    185167        task_t *task;
    186 
     168       
    187169        /** Ticks before preemption. */
    188170        uint64_t ticks;
    189171       
    190172        /** Thread accounting. */
    191         uint64_t cycles;
     173        uint64_t ucycles;
     174        uint64_t kcycles;
    192175        /** Last sampled cycle. */
    193176        uint64_t last_cycle;
    194         /** Thread doesn't affect accumulated accounting. */   
     177        /** Thread doesn't affect accumulated accounting. */
    195178        bool uncounted;
    196 
     179       
    197180        /** Thread's priority. Implemented as index to CPU->rq */
    198181        int priority;
     
    202185        /** Architecture-specific data. */
    203186        thread_arch_t arch;
    204 
     187       
    205188        /** Thread's kernel stack. */
    206189        uint8_t *kstack;
    207 
     190       
    208191#ifdef CONFIG_UDEBUG
     192        /**
     193         * If true, the scheduler will print a stack trace
     194         * to the kernel console upon scheduling this thread.
     195         */
     196        bool btrace;
     197       
    209198        /** Debugging stuff */
    210199        udebug_thread_t udebug;
    211 #endif
    212 
     200#endif /* CONFIG_UDEBUG */
    213201} thread_t;
    214202
     
    219207 *
    220208 */
    221 SPINLOCK_EXTERN(threads_lock);
     209IRQ_SPINLOCK_EXTERN(threads_lock);
    222210
    223211/** AVL tree containing all threads. */
     
    225213
    226214extern void thread_init(void);
    227 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
    228     int flags, char *name, bool uncounted);
    229 extern void thread_attach(thread_t *t, task_t *task);
    230 extern void thread_ready(thread_t *t);
     215extern thread_t *thread_create(void (*)(void *), void *, task_t *,
     216    unsigned int, const char *, bool);
     217extern void thread_attach(thread_t *, task_t *);
     218extern void thread_ready(thread_t *);
    231219extern void thread_exit(void) __attribute__((noreturn));
    232220
    233221#ifndef thread_create_arch
    234 extern void thread_create_arch(thread_t *t);
    235 #endif
     222extern void thread_create_arch(thread_t *);
     223#endif
     224
    236225#ifndef thr_constructor_arch
    237 extern void thr_constructor_arch(thread_t *t);
    238 #endif
     226extern void thr_constructor_arch(thread_t *);
     227#endif
     228
    239229#ifndef thr_destructor_arch
    240 extern void thr_destructor_arch(thread_t *t);
    241 #endif
    242 
    243 extern void thread_sleep(uint32_t sec);
    244 extern void thread_usleep(uint32_t usec);
     230extern void thr_destructor_arch(thread_t *);
     231#endif
     232
     233extern void thread_sleep(uint32_t);
     234extern void thread_usleep(uint32_t);
    245235
    246236#define thread_join(t) \
    247237        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    248 extern int thread_join_timeout(thread_t *t, uint32_t usec, int flags);
    249 extern void thread_detach(thread_t *t);
    250 
    251 extern void thread_register_call_me(void (* call_me)(void *),
    252     void *call_me_with);
    253 extern void thread_print_list(void);
    254 extern void thread_destroy(thread_t *t);
    255 extern void thread_update_accounting(void);
    256 extern bool thread_exists(thread_t *t);
     238
     239extern int thread_join_timeout(thread_t *, uint32_t, unsigned int);
     240extern void thread_detach(thread_t *);
     241
     242extern void thread_print_list(bool);
     243extern void thread_destroy(thread_t *, bool);
     244extern thread_t *thread_find_by_id(thread_id_t);
     245extern void thread_update_accounting(bool);
     246extern bool thread_exists(thread_t *);
     247
     248#ifdef CONFIG_UDEBUG
     249extern void thread_stack_trace(thread_id_t);
     250#endif
    257251
    258252/** Fpu context slab cache. */
     
    260254
    261255/* Thread syscall prototypes. */
    262 extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg,
    263     char *uspace_name, size_t name_len, thread_id_t *uspace_thread_id);
    264 extern unative_t sys_thread_exit(int uspace_status);
    265 extern unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
     256extern sysarg_t sys_thread_create(uspace_arg_t *, char *, size_t,
     257    thread_id_t *);
     258extern sysarg_t sys_thread_exit(int);
     259extern sysarg_t sys_thread_get_id(thread_id_t *);
     260extern sysarg_t sys_thread_usleep(uint32_t);
    266261
    267262#endif
  • kernel/generic/include/security/cap.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3535/**
    3636 * @file
    37  * @brief       Capabilities definitions.
     37 * @brief Capabilities definitions.
    3838 *
    3939 * Capabilities represent virtual rights that entitle their
     
    4848#define __CAP_H__
    4949
    50 #include <syscall/sysarg64.h>
    51 #include <arch/types.h>
     50#include <typedefs.h>
    5251
    5352/**
     
    5554 * privilege to/from other tasks.
    5655 */
    57 #define CAP_CAP                 (1<<0)
     56#define CAP_CAP  (1 << 0)
    5857
    5958/**
     
    6160 * to other tasks.
    6261 */
    63 #define CAP_MEM_MANAGER         (1<<1)
     62#define CAP_MEM_MANAGER  (1 << 1)
    6463
    6564/**
     
    6766 * to other tasks.
    6867 */
    69 #define CAP_IO_MANAGER          (1<<2)
    70 
    71 /**
    72  * CAP_PREEMPT_CONTROL allows its holder to disable/enable preemption.
    73  */
    74 #define CAP_PREEMPT_CONTROL     (1<<3)
     68#define CAP_IO_MANAGER  (1 << 2)
    7569
    7670/**
    7771 * CAP_IRQ_REG entitles its holder to register IRQ handlers.
    7872 */
    79 #define CAP_IRQ_REG             (1<<4)
     73#define CAP_IRQ_REG  (1 << 3)
    8074
    8175typedef uint32_t cap_t;
    8276
    83 extern unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
    84 extern unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
     77#ifdef __32_BITS__
     78
     79extern sysarg_t sys_cap_grant(sysarg64_t *, cap_t);
     80extern sysarg_t sys_cap_revoke(sysarg64_t *, cap_t);
     81
     82#endif  /* __32_BITS__ */
     83
     84#ifdef __64_BITS__
     85
     86extern sysarg_t sys_cap_grant(sysarg_t, cap_t);
     87extern sysarg_t sys_cap_revoke(sysarg_t, cap_t);
     88
     89#endif  /* __64_BITS__ */
    8590
    8691#endif
  • kernel/generic/include/smp/ipi.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3737
    3838#ifdef CONFIG_SMP
    39 extern void ipi_broadcast(int ipi);
    40 extern void ipi_broadcast_arch(int ipi);
     39
     40extern void ipi_broadcast(int);
     41extern void ipi_broadcast_arch(int);
     42
    4143#else
    42 #define ipi_broadcast(x)        ;
     44
     45#define ipi_broadcast(ipi)
     46
    4347#endif /* CONFIG_SMP */
    4448
  • kernel/generic/include/smp/smp.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    4141
    4242#ifdef CONFIG_SMP
     43
    4344extern void smp_init(void);
    4445extern void kmp(void *arg);
    45 #else
     46
     47#else /* CONFIG_SMP */
     48
    4649#define smp_init()
     50
    4751#endif /* CONFIG_SMP */
    4852
  • kernel/generic/include/sort.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_SORT_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    40 /*
    41  * sorting routines
    42  */
    43 extern void bubblesort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b));
    44 extern void qsort(void * data, size_t n, size_t e_size, int (* cmp) (void * a, void * b));
     40typedef int (* sort_cmp_t)(void *, void *, void *);
    4541
    46 /*
    47  * default sorting comparators
    48  */
    49 extern int int_cmp(void * a, void * b);
    50 extern int uint32_t_cmp(void * a, void * b);
    51 extern int uint16_t_cmp(void * a, void * b);
    52 extern int uint8_t_cmp(void * a, void * b);
     42extern bool gsort(void *, size_t, size_t, sort_cmp_t, void *);
     43extern bool qsort(void *, size_t, size_t, sort_cmp_t, void *);
    5344
    5445#endif
  • kernel/generic/include/stdarg.h

    rb50b5af2 r04803bf  
    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/str.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef KERN_STRING_H_
    36 #define KERN_STRING_H_
     35#ifndef KERN_STR_H_
     36#define KERN_STR_H_
    3737
    3838#include <typedefs.h>
     
    8787extern void str_cpy(char *dest, size_t size, const char *src);
    8888extern void str_ncpy(char *dest, size_t size, const char *src, size_t n);
    89 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size);
     89extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
     90
     91extern char *str_dup(const char *src);
     92extern char *str_ndup(const char *src, size_t n);
    9093
    9194extern char *str_chr(const char *str, wchar_t ch);
     
    9497extern bool wstr_remove(wchar_t *str, size_t pos);
    9598
     99extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
     100
     101extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix);
     102
    96103#endif
    97104
  • kernel/generic/include/symtab.h

    rb50b5af2 r04803bf  
    3636#define KERN_SYMTAB_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    40 #define MAX_SYMBOL_NAME 64
     40#define MAX_SYMBOL_NAME  64
    4141
    4242struct symtab_entry {
     
    4545};
    4646
    47 extern int symtab_name_lookup(unative_t addr, char **name);
    48 extern char *symtab_fmt_name_lookup(unative_t addr);
    49 extern int symtab_addr_lookup(const char *name, uintptr_t *addr);
    50 extern void symtab_print_search(const char *name);
    51 extern int symtab_compl(char *input, size_t size);
     47extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *);
     48extern const char *symtab_fmt_name_lookup(uintptr_t);
     49extern int symtab_addr_lookup(const char *, uintptr_t *);
     50extern void symtab_print_search(const char *);
     51extern int symtab_compl(char *, size_t);
    5252
    5353#ifdef CONFIG_SYMTAB
    5454
    55 /* Symtable linked together by build process */
     55/** Symtable linked together by build process
     56 *
     57 */
    5658extern struct symtab_entry symbol_table[];
    5759
    58 #endif
     60#endif /* CONFIG_SYMTAB */
    5961
    6062#endif
  • kernel/generic/include/synch/condvar.h

    rb50b5af2 r04803bf  
    3636#define KERN_CONDVAR_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <synch/waitq.h>
    4040#include <synch/mutex.h>
  • kernel/generic/include/synch/futex.h

    rb50b5af2 r04803bf  
    3636#define KERN_FUTEX_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <synch/waitq.h>
    40 #include <genarch/mm/page_ht.h>
    41 #include <genarch/mm/page_pt.h>
    4240
    4341/** Kernel-side futex structure. */
     
    5452
    5553extern void futex_init(void);
    56 extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec,
    57     int flags);
    58 extern unative_t sys_futex_wakeup(uintptr_t uaddr);
     54extern sysarg_t sys_futex_sleep(uintptr_t);
     55extern sysarg_t sys_futex_wakeup(uintptr_t);
    5956
    6057extern void futex_cleanup(void);
  • kernel/generic/include/synch/mutex.h

    rb50b5af2 r04803bf  
    3636#define KERN_MUTEX_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <synch/semaphore.h>
    4040#include <synch/synch.h>
     
    5050} mutex_t;
    5151
    52 #define mutex_lock(mtx)                 \
     52#define mutex_lock(mtx) \
    5353        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    54 #define mutex_trylock(mtx)              \
     54
     55#define mutex_trylock(mtx) \
    5556        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
    56 #define mutex_lock_timeout(mtx, usec)   \
     57
     58#define mutex_lock_timeout(mtx, usec) \
    5759        _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
    5860
    5961extern void mutex_initialize(mutex_t *, mutex_type_t);
    60 extern int _mutex_lock_timeout(mutex_t *, uint32_t, int);
     62extern bool mutex_locked(mutex_t *);
     63extern int _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int);
    6164extern void mutex_unlock(mutex_t *);
    6265
  • kernel/generic/include/synch/semaphore.h

    rb50b5af2 r04803bf  
    3636#define KERN_SEMAPHORE_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <synch/waitq.h>
    4040#include <synch/synch.h>
     
    4646#define semaphore_down(s) \
    4747        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     48
    4849#define semaphore_trydown(s) \
    4950        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
     51
    5052#define semaphore_down_timeout(s, usec) \
    5153        _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE)
    5254
    53 extern void semaphore_initialize(semaphore_t *s, int val);
    54 extern int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags);
    55 extern void semaphore_up(semaphore_t *s);
     55extern void semaphore_initialize(semaphore_t *, int);
     56extern int _semaphore_down_timeout(semaphore_t *, uint32_t, unsigned int);
     57extern void semaphore_up(semaphore_t *);
     58extern int semaphore_count_get(semaphore_t *);
    5659
    5760#endif
  • kernel/generic/include/synch/smc.h

    rb50b5af2 r04803bf  
    3636#define KERN_SMC_H_
    3737
    38 extern unative_t sys_smc_coherence(uintptr_t va, size_t size);
     38extern sysarg_t sys_smc_coherence(uintptr_t va, size_t size);
    3939
    4040#endif
  • kernel/generic/include/synch/spinlock.h

    rb50b5af2 r04803bf  
    3636#define KERN_SPINLOCK_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <arch/barrier.h>
    4040#include <preemption.h>
    4141#include <atomic.h>
    4242#include <debug.h>
     43#include <arch/asm.h>
    4344
    4445#ifdef CONFIG_SMP
     
    4849       
    4950#ifdef CONFIG_DEBUG_SPINLOCK
    50         char *name;
    51 #endif
     51        const char *name;
     52#endif /* CONFIG_DEBUG_SPINLOCK */
    5253} spinlock_t;
    5354
     
    6061
    6162/*
    62  * SPINLOCK_INITIALIZE is to be used for statically allocated spinlocks.
    63  * It declares and initializes the lock.
     63 * SPINLOCK_INITIALIZE and SPINLOCK_STATIC_INITIALIZE are to be used
     64 * for statically allocated spinlocks. They declare (either as global
     65 * or static) symbol and initialize the lock.
    6466 */
    6567#ifdef CONFIG_DEBUG_SPINLOCK
     
    7779        }
    7880
    79 #define spinlock_lock(lock)  spinlock_lock_debug(lock)
    80 
    81 #else
     81#define ASSERT_SPINLOCK(expr, lock) \
     82        ASSERT_VERBOSE(expr, (lock)->name)
     83
     84#define spinlock_lock(lock)    spinlock_lock_debug((lock))
     85#define spinlock_unlock(lock)  spinlock_unlock_debug((lock))
     86
     87#else /* CONFIG_DEBUG_SPINLOCK */
    8288
    8389#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     
    9197        }
    9298
    93 #define spinlock_lock(lock)  atomic_lock_arch(&(lock)->val)
    94 
    95 #endif
     99#define ASSERT_SPINLOCK(expr, lock) \
     100        ASSERT(expr)
     101
     102#define spinlock_lock(lock)    atomic_lock_arch(&(lock)->val)
     103#define spinlock_unlock(lock)  spinlock_unlock_nondebug((lock))
     104
     105#endif /* CONFIG_DEBUG_SPINLOCK */
    96106
    97107#define SPINLOCK_INITIALIZE(lock_name) \
     
    101111        SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
    102112
    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);
     113extern void spinlock_initialize(spinlock_t *, const char *);
     114extern int spinlock_trylock(spinlock_t *);
     115extern void spinlock_lock_debug(spinlock_t *);
     116extern void spinlock_unlock_debug(spinlock_t *);
     117extern bool spinlock_locked(spinlock_t *);
    106118
    107119/** Unlock spinlock
    108120 *
    109  * Unlock spinlock.
     121 * Unlock spinlock for non-debug kernels.
    110122 *
    111123 * @param sl Pointer to spinlock_t structure.
    112  */
    113 static inline void spinlock_unlock(spinlock_t *lock)
     124 *
     125 */
     126NO_TRACE static inline void spinlock_unlock_nondebug(spinlock_t *lock)
    114127{
    115         ASSERT(atomic_get(&lock->val) != 0);
    116        
    117128        /*
    118129         * Prevent critical section code from bleeding out this way down.
     
    135146        if ((pname)++ > (value)) { \
    136147                (pname) = 0; \
    137                 printf("Deadlock probe %s: exceeded threshold %u\n", \
     148                printf("Deadlock probe %s: exceeded threshold %u\n" \
    138149                    "cpu%u: function=%s, line=%u\n", \
    139150                    #pname, (value), CPU->id, __func__, __LINE__); \
    140151        }
    141152
    142 #else
     153#else /* CONFIG_DEBUG_SPINLOCK */
    143154
    144155#define DEADLOCK_PROBE_INIT(pname)
    145156#define DEADLOCK_PROBE(pname, value)
    146157
    147 #endif
     158#endif /* CONFIG_DEBUG_SPINLOCK */
    148159
    149160#else /* CONFIG_SMP */
     
    159170#define SPINLOCK_INITIALIZE_NAME(name, desc_name)
    160171#define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name)
     172
     173#define ASSERT_SPINLOCK(expr, lock)  ASSERT(expr)
    161174
    162175#define spinlock_initialize(lock, name)
     
    165178#define spinlock_trylock(lock)  (preemption_disable(), 1)
    166179#define spinlock_unlock(lock)   preemption_enable()
     180#define spinlock_locked(lock)   1
     181#define spinlock_unlocked(lock) 1
    167182
    168183#define DEADLOCK_PROBE_INIT(pname)
    169184#define DEADLOCK_PROBE(pname, value)
    170185
     186#endif /* CONFIG_SMP */
     187
     188typedef struct {
     189        SPINLOCK_DECLARE(lock);  /**< Spinlock */
     190        bool guard;              /**< Flag whether ipl is valid */
     191        ipl_t ipl;               /**< Original interrupt level */
     192} irq_spinlock_t;
     193
     194#define IRQ_SPINLOCK_DECLARE(lock_name)  irq_spinlock_t lock_name
     195#define IRQ_SPINLOCK_EXTERN(lock_name)   extern irq_spinlock_t lock_name
     196
     197#ifdef CONFIG_SMP
     198
     199#define ASSERT_IRQ_SPINLOCK(expr, irq_lock) \
     200        ASSERT_SPINLOCK(expr, &((irq_lock)->lock))
     201
     202/*
     203 * IRQ_SPINLOCK_INITIALIZE and IRQ_SPINLOCK_STATIC_INITIALIZE are to be used
     204 * for statically allocated interrupts-disabled spinlocks. They declare (either
     205 * as global or static symbol) and initialize the lock.
     206 */
     207#ifdef CONFIG_DEBUG_SPINLOCK
     208
     209#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     210        irq_spinlock_t lock_name = { \
     211                .lock = { \
     212                        .name = desc_name, \
     213                        .val = { 0 } \
     214                }, \
     215                .guard = false, \
     216                .ipl = 0 \
     217        }
     218
     219#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     220        static irq_spinlock_t lock_name = { \
     221                .lock = { \
     222                        .name = desc_name, \
     223                        .val = { 0 } \
     224                }, \
     225                .guard = false, \
     226                .ipl = 0 \
     227        }
     228
     229#else /* CONFIG_DEBUG_SPINLOCK */
     230
     231#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     232        irq_spinlock_t lock_name = { \
     233                .lock = { \
     234                        .val = { 0 } \
     235                }, \
     236                .guard = false, \
     237                .ipl = 0 \
     238        }
     239
     240#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     241        static irq_spinlock_t lock_name = { \
     242                .lock = { \
     243                        .val = { 0 } \
     244                }, \
     245                .guard = false, \
     246                .ipl = 0 \
     247        }
     248
     249#endif /* CONFIG_DEBUG_SPINLOCK */
     250
     251#else /* CONFIG_SMP */
     252
     253/*
     254 * Since the spinlocks are void on UP systems, we also need
     255 * to have a special variant of interrupts-disabled spinlock
     256 * macros which take this into account.
     257 */
     258
     259#define ASSERT_IRQ_SPINLOCK(expr, irq_lock) \
     260        ASSERT_SPINLOCK(expr, NULL)
     261
     262#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     263        irq_spinlock_t lock_name = { \
     264                .guard = false, \
     265                .ipl = 0 \
     266        }
     267
     268#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     269        static irq_spinlock_t lock_name = { \
     270                .guard = false, \
     271                .ipl = 0 \
     272        }
     273
     274#endif /* CONFIG_SMP */
     275
     276#define IRQ_SPINLOCK_INITIALIZE(lock_name) \
     277        IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, #lock_name)
     278
     279#define IRQ_SPINLOCK_STATIC_INITIALIZE(lock_name) \
     280        IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
     281
     282extern void irq_spinlock_initialize(irq_spinlock_t *, const char *);
     283extern void irq_spinlock_lock(irq_spinlock_t *, bool);
     284extern void irq_spinlock_unlock(irq_spinlock_t *, bool);
     285extern int irq_spinlock_trylock(irq_spinlock_t *);
     286extern void irq_spinlock_pass(irq_spinlock_t *, irq_spinlock_t *);
     287extern void irq_spinlock_exchange(irq_spinlock_t *, irq_spinlock_t *);
     288extern bool irq_spinlock_locked(irq_spinlock_t *);
     289
    171290#endif
    172291
    173 #endif
    174 
    175292/** @}
    176293 */
  • kernel/generic/include/synch/waitq.h

    rb50b5af2 r04803bf  
    3636#define KERN_WAITQ_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <synch/spinlock.h>
    4040#include <synch/synch.h>
     
    4646} wakeup_mode_t;
    4747
    48 /** Wait queue structure. */
     48/** Wait queue structure.
     49 *
     50 */
    4951typedef struct {
    50 
    5152        /** Lock protecting wait queue structure.
    5253         *
    5354         * Must be acquired before T.lock for each T of type thread_t.
    5455         */
    55         SPINLOCK_DECLARE(lock);
    56 
     56        IRQ_SPINLOCK_DECLARE(lock);
     57       
    5758        /**
    5859         * Number of waitq_wakeup() calls that didn't find a thread to wake up.
     60         *
    5961         */
    6062        int missed_wakeups;
     63       
    6164        /** List of sleeping threads for wich there was no missed_wakeup. */
    6265        link_t head;
     
    6972
    7073extern void waitq_initialize(waitq_t *);
    71 extern int waitq_sleep_timeout(waitq_t *, uint32_t, int);
     74extern int waitq_sleep_timeout(waitq_t *, uint32_t, unsigned int);
    7275extern ipl_t waitq_sleep_prepare(waitq_t *);
    73 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int);
     76extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, unsigned int);
    7477extern void waitq_sleep_finish(waitq_t *, int, ipl_t);
    7578extern void waitq_wakeup(waitq_t *, wakeup_mode_t);
     
    7780extern void waitq_interrupt_sleep(struct thread *);
    7881extern void waitq_unsleep(waitq_t *);
     82extern int waitq_count_get(waitq_t *);
     83extern void waitq_count_set(waitq_t *, int val);
    7984
    8085#endif
  • kernel/generic/include/syscall/copy.h

    rb50b5af2 r04803bf  
    3636#define KERN_COPY_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040/** Label within memcpy_from_uspace() that contains return -1. */
  • kernel/generic/include/syscall/syscall.h

    rb50b5af2 r04803bf  
    3838typedef enum {
    3939        SYS_KLOG = 0,
    40         SYS_TLS_SET = 1, /* Hardcoded in AMD64, IA32 uspace - fibril.S */
     40        SYS_TLS_SET = 1,  /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */
    4141       
    4242        SYS_THREAD_CREATE,
    4343        SYS_THREAD_EXIT,
    4444        SYS_THREAD_GET_ID,
     45        SYS_THREAD_USLEEP,
    4546       
    4647        SYS_TASK_GET_ID,
    4748        SYS_TASK_SET_NAME,
     49        SYS_TASK_KILL,
     50        SYS_TASK_EXIT,
    4851        SYS_PROGRAM_SPAWN_LOADER,
    4952       
     
    5659        SYS_AS_AREA_CHANGE_FLAGS,
    5760        SYS_AS_AREA_DESTROY,
     61        SYS_AS_GET_UNMAPPED_AREA,
    5862       
    5963        SYS_IPC_CALL_SYNC_FAST,
     
    6872        SYS_IPC_POKE,
    6973        SYS_IPC_HANGUP,
    70         SYS_IPC_REGISTER_IRQ,
    71         SYS_IPC_UNREGISTER_IRQ,
    72 
     74        SYS_IPC_CONNECT_KBOX,
     75       
    7376        SYS_EVENT_SUBSCRIBE,
    7477       
     
    7982        SYS_PHYSMEM_MAP,
    8083        SYS_IOSPACE_ENABLE,
    81         SYS_PREEMPT_CONTROL,
     84        SYS_REGISTER_IRQ,
     85        SYS_UNREGISTER_IRQ,
    8286       
    83         SYS_SYSINFO_VALID,
    84         SYS_SYSINFO_VALUE,
    85 
     87        SYS_SYSINFO_GET_TAG,
     88        SYS_SYSINFO_GET_VALUE,
     89        SYS_SYSINFO_GET_DATA_SIZE,
     90        SYS_SYSINFO_GET_DATA,
     91       
    8692        SYS_DEBUG_PUTINT,
    8793        SYS_DEBUG_ENABLE_CONSOLE,
    8894        SYS_DEBUG_DISABLE_CONSOLE,
    89         SYS_IPC_CONNECT_KBOX,
     95       
    9096        SYSCALL_END
    9197} syscall_t;
     
    9399#ifdef KERNEL
    94100
    95 #include <arch/types.h>
     101#include <typedefs.h>
    96102
    97 typedef unative_t (*syshandler_t)(unative_t, unative_t, unative_t, unative_t,
    98     unative_t, unative_t);
     103typedef sysarg_t (*syshandler_t)(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     104    sysarg_t, sysarg_t);
    99105
    100106extern syshandler_t syscall_table[SYSCALL_END];
    101 extern unative_t syscall_handler(unative_t, unative_t, unative_t, unative_t,
    102     unative_t, unative_t, unative_t);
    103 extern unative_t sys_tls_set(unative_t);
     107extern sysarg_t syscall_handler(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     108    sysarg_t, sysarg_t, sysarg_t);
     109extern sysarg_t sys_tls_set(sysarg_t);
    104110
    105111#endif
  • kernel/generic/include/sysinfo/sysinfo.h

    rb50b5af2 r04803bf  
    3636#define KERN_SYSINFO_H_
    3737
    38 #include <arch/types.h>
    39 #include <string.h>
     38#include <typedefs.h>
     39#include <str.h>
    4040
     41/** Framebuffer info exported flags */
    4142extern bool fb_exported;
    4243
    43 typedef union sysinfo_item_val {
    44         unative_t val;
    45         void *fn;
     44/** Item value type
     45 *
     46 */
     47typedef enum {
     48        SYSINFO_VAL_UNDEFINED = 0,     /**< Undefined value */
     49        SYSINFO_VAL_VAL = 1,           /**< Constant numeric value */
     50        SYSINFO_VAL_DATA = 2,          /**< Constant binary data */
     51        SYSINFO_VAL_FUNCTION_VAL = 3,  /**< Generated numeric value */
     52        SYSINFO_VAL_FUNCTION_DATA = 4  /**< Generated binary data */
     53} sysinfo_item_val_type_t;
     54
     55/** Subtree type
     56 *
     57 */
     58typedef enum {
     59        SYSINFO_SUBTREE_NONE = 0,     /**< No subtree (leaf item) */
     60        SYSINFO_SUBTREE_TABLE = 1,    /**< Fixed subtree */
     61        SYSINFO_SUBTREE_FUNCTION = 2  /**< Generated subtree */
     62} sysinfo_subtree_type_t;
     63
     64struct sysinfo_item;
     65
     66/** Gerated numeric value function */
     67typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
     68
     69/** Generated binary data function */
     70typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
     71
     72/** Sysinfo item binary data
     73 *
     74 */
     75typedef struct {
     76        void *data;   /**< Data */
     77        size_t size;  /**< Size (bytes) */
     78} sysinfo_data_t;
     79
     80/** Sysinfo item value (union)
     81 *
     82 */
     83typedef union {
     84        sysarg_t val;               /**< Constant numberic value */
     85        sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
     86        sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
     87        sysinfo_data_t data;        /**< Constant binary data */
    4688} sysinfo_item_val_t;
    4789
     90/** Sysinfo return holder
     91 *
     92 * This structure is generated from the constant
     93 * items or by the generating functions. Note that
     94 * the validity of the data is limited by the scope
     95 * of single sysinfo invocation guarded by sysinfo_lock.
     96 *
     97 */
     98typedef struct {
     99        sysinfo_item_val_type_t tag;  /**< Return value type */
     100        union {
     101                sysarg_t val;             /**< Numberic value */
     102                sysinfo_data_t data;      /**< Binary data */
     103        };
     104} sysinfo_return_t;
     105
     106/** Generated subtree function */
     107typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
     108
     109/** Sysinfo subtree (union)
     110 *
     111 */
     112typedef union {
     113        struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
     114        sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
     115} sysinfo_subtree_t;
     116
     117/** Sysinfo item
     118 *
     119 */
    48120typedef struct sysinfo_item {
    49         char *name;
    50         union {
    51                 unative_t val;
    52                 void *fn;
    53         } val;
    54 
    55         union {
    56                 struct sysinfo_item *table;
    57                 void *fn;
    58         } subinfo;
    59 
    60         struct sysinfo_item *next;
    61         int val_type;
    62         int subinfo_type;
     121        char *name;                           /**< Item name */
     122       
     123        sysinfo_item_val_type_t val_type;     /**< Item value type */
     124        sysinfo_item_val_t val;               /**< Item value */
     125       
     126        sysinfo_subtree_type_t subtree_type;  /**< Subtree type */
     127        sysinfo_subtree_t subtree;            /**< Subtree */
     128       
     129        struct sysinfo_item *next;            /**< Sibling item */
    63130} sysinfo_item_t;
    64131
    65 #define SYSINFO_VAL_VAL        0
    66 #define SYSINFO_VAL_FUNCTION   1
    67 #define SYSINFO_VAL_UNDEFINED  U_SPECIAL
     132extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t);
     133extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
     134    size_t);
     135extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
     136    sysinfo_fn_val_t);
     137extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
     138    sysinfo_fn_data_t);
     139extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
    68140
    69 #define SYSINFO_SUBINFO_NONE      0
    70 #define SYSINFO_SUBINFO_TABLE     1
    71 #define SYSINFO_SUBINFO_FUNCTION  2
     141extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
     142    sysinfo_fn_subtree_t);
    72143
    73 typedef unative_t (*sysinfo_val_fn_t)(sysinfo_item_t *root);
    74 typedef unative_t (*sysinfo_subinfo_fn_t)(const char *subname);
     144extern void sysinfo_init(void);
     145extern void sysinfo_dump(sysinfo_item_t *);
    75146
    76 typedef struct sysinfo_rettype {
    77         unative_t val;
    78         unative_t valid;
    79 } sysinfo_rettype_t;
    80 
    81 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, unative_t val);
    82 void sysinfo_dump(sysinfo_item_t **root, int depth);
    83 void sysinfo_set_item_function(const char *name, sysinfo_item_t **root, sysinfo_val_fn_t fn);
    84 void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root);
    85 
    86 sysinfo_rettype_t sysinfo_get_val(const char *name, sysinfo_item_t **root);
    87 
    88 unative_t sys_sysinfo_valid(unative_t ptr, unative_t len);
    89 unative_t sys_sysinfo_value(unative_t ptr, unative_t len);
     147extern sysarg_t sys_sysinfo_get_tag(void *, size_t);
     148extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
     149extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *);
     150extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *);
    90151
    91152#endif
  • kernel/generic/include/time/clock.h

    rb50b5af2 r04803bf  
    3636#define KERN_CLOCK_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    40 #define HZ              100
     40#define HZ  100
    4141
    4242/** Uptime structure */
    4343typedef struct {
    44         unative_t seconds1;
    45         unative_t useconds;
    46         unative_t seconds2;
     44        sysarg_t seconds1;
     45        sysarg_t useconds;
     46        sysarg_t seconds2;
    4747} uptime_t;
    4848
  • kernel/generic/include/time/delay.h

    rb50b5af2 r04803bf  
    3636#define KERN_DELAY_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040extern void delay(uint32_t microseconds);
  • kernel/generic/include/time/timeout.h

    rb50b5af2 r04803bf  
    3636#define KERN_TIMEOUT_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <adt/list.h>
    4040#include <cpu.h>
     
    4343
    4444typedef struct {
    45         SPINLOCK_DECLARE(lock);
    46 
     45        IRQ_SPINLOCK_DECLARE(lock);
     46       
    4747        /** Link to the list of active timeouts on THE->cpu */
    4848        link_t link;
    49         /** Timeout will be activated in this amount of clock() ticks. */       
     49        /** Timeout will be activated in this amount of clock() ticks. */
    5050        uint64_t ticks;
    5151        /** Function that will be called on timeout activation. */
     
    5757} timeout_t;
    5858
    59 #define us2ticks(us)    ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
     59#define us2ticks(us)  ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
    6060
    6161extern void timeout_init(void);
    62 extern void timeout_initialize(timeout_t *t);
    63 extern void timeout_reinitialize(timeout_t *t);
    64 extern void timeout_register(timeout_t *t, uint64_t usec, timeout_handler_t f,
    65     void *arg);
    66 extern bool timeout_unregister(timeout_t *t);
     62extern void timeout_initialize(timeout_t *);
     63extern void timeout_reinitialize(timeout_t *);
     64extern void timeout_register(timeout_t *, uint64_t, timeout_handler_t, void *);
     65extern bool timeout_unregister(timeout_t *);
    6766
    6867#endif
  • kernel/generic/include/typedefs.h

    rb50b5af2 r04803bf  
    3636#define KERN_TYPEDEFS_H_
    3737
     38#include <stdint.h>
     39#include <arch/common.h>
    3840#include <arch/types.h>
    3941
    40 #define NULL 0
    41 #define false 0
    42 #define true 1
     42#define NULL  ((void *) 0)
     43
     44#define false  0
     45#define true   1
     46
     47typedef struct {
     48        uint64_t lo;
     49        int64_t hi;
     50} int128_t;
     51
     52typedef struct {
     53        uint64_t lo;
     54        uint64_t hi;
     55} uint128_t;
     56
     57typedef struct {
     58        volatile atomic_count_t count;
     59} atomic_t;
    4360
    4461typedef void (* function)();
     
    5269typedef int32_t devno_t;
    5370
    54 typedef int32_t wchar_t;
    55 
    5671typedef volatile uint8_t ioport8_t;
    5772typedef volatile uint16_t ioport16_t;
    5873typedef volatile uint32_t ioport32_t;
     74
     75#ifdef __32_BITS__
     76
     77/** Explicit 64-bit arguments passed to syscalls. */
     78typedef uint64_t sysarg64_t;
     79
     80#endif /* __32_BITS__ */
    5981
    6082#endif
  • kernel/generic/include/udebug/udebug.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_UDEBUG_H_
    3737
     38#define UDEBUG_EVMASK(event)  (1 << ((event) - 1))
     39
     40typedef enum { /* udebug_method_t */
     41       
     42        /** Start debugging the recipient.
     43         *
     44         * Causes all threads in the receiving task to stop. When they
     45         * are all stoped, an answer with retval 0 is generated.
     46         *
     47         */
     48        UDEBUG_M_BEGIN = 1,
     49       
     50        /** Finish debugging the recipient.
     51         *
     52         * Answers all pending GO and GUARD messages.
     53         *
     54         */
     55        UDEBUG_M_END,
     56       
     57        /** Set which events should be captured. */
     58        UDEBUG_M_SET_EVMASK,
     59       
     60        /** Make sure the debugged task is still there.
     61         *
     62         * This message is answered when the debugged task dies
     63         * or the debugging session ends.
     64         *
     65         */
     66        UDEBUG_M_GUARD,
     67       
     68        /** Run a thread until a debugging event occurs.
     69         *
     70         * This message is answered when the thread stops
     71         * in a debugging event.
     72         *
     73         * - ARG2 - id of the thread to run
     74         *
     75         */
     76        UDEBUG_M_GO,
     77       
     78        /** Stop a thread being debugged.
     79         *
     80         * Creates a special STOP event in the thread, causing
     81         * it to answer a pending GO message (if any).
     82         *
     83         */
     84        UDEBUG_M_STOP,
     85       
     86        /** Read arguments of a syscall.
     87         *
     88         * - ARG2 - thread identification
     89         * - ARG3 - destination address in the caller's address space
     90         *
     91         */
     92        UDEBUG_M_ARGS_READ,
     93       
     94        /** Read thread's userspace register state (istate_t).
     95         *
     96         * - ARG2 - thread identification
     97         * - ARG3 - destination address in the caller's address space
     98         *
     99         * or, on error, retval will be
     100         * - ENOENT - thread does not exist
     101         * - EBUSY - register state not available
     102         */
     103        UDEBUG_M_REGS_READ,
     104       
     105        /** Read the list of the debugged tasks's threads.
     106         *
     107         * - ARG2 - destination address in the caller's address space
     108         * - ARG3 - size of receiving buffer in bytes
     109         *
     110         * The kernel fills the buffer with a series of sysarg_t values
     111         * (thread ids). On answer, the kernel will set:
     112         *
     113         * - ARG2 - number of bytes that were actually copied
     114         * - ARG3 - number of bytes of the complete data
     115         *
     116         */
     117        UDEBUG_M_THREAD_READ,
     118       
     119        /** Read the name of the debugged task.
     120         *
     121         * - ARG2 - destination address in the caller's address space
     122         * - ARG3 - size of receiving buffer in bytes
     123         *
     124         * The kernel fills the buffer with a non-terminated string.
     125         *
     126         * - ARG2 - number of bytes that were actually copied
     127         * - ARG3 - number of bytes of the complete data
     128         *
     129         */
     130        UDEBUG_M_NAME_READ,
     131       
     132        /** Read the list of the debugged task's address space areas.
     133         *
     134         * - ARG2 - destination address in the caller's address space
     135         * - ARG3 - size of receiving buffer in bytes
     136         *
     137         * The kernel fills the buffer with a series of as_area_info_t structures.
     138         * Upon answer, the kernel will set:
     139         *
     140         * - ARG2 - number of bytes that were actually copied
     141         * - ARG3 - number of bytes of the complete data
     142         *
     143         */
     144        UDEBUG_M_AREAS_READ,
     145       
     146        /** Read the debugged tasks's memory.
     147         *
     148         * - ARG2 - destination address in the caller's address space
     149         * - ARG3 - source address in the recipient's address space
     150         * - ARG4 - size of receiving buffer in bytes
     151         *
     152         */
     153        UDEBUG_M_MEM_READ
     154} udebug_method_t;
     155
     156typedef enum {
     157        UDEBUG_EVENT_FINISHED = 1,  /**< Debuging session has finished */
     158        UDEBUG_EVENT_STOP,          /**< Stopped on DEBUG_STOP request */
     159        UDEBUG_EVENT_SYSCALL_B,     /**< Before beginning syscall execution */
     160        UDEBUG_EVENT_SYSCALL_E,     /**< After finishing syscall execution */
     161        UDEBUG_EVENT_THREAD_B,      /**< The task created a new thread */
     162        UDEBUG_EVENT_THREAD_E       /**< A thread exited */
     163} udebug_event_t;
     164
     165typedef enum {
     166        UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
     167        UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
     168        UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
     169        UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
     170        UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
     171        UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
     172        UDEBUG_EM_ALL =
     173            (UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
     174            UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
     175            UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
     176            UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
     177            UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
     178            UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E))
     179} udebug_evmask_t;
     180
     181#ifdef KERNEL
     182
    38183#include <ipc/ipc.h>
    39 
    40 typedef enum { /* udebug_method_t */
    41 
    42 /** Start debugging the recipient.
    43  * Causes all threads in the receiving task to stop. When they
    44  * are all stoped, an answer with retval 0 is generated.
    45  */
    46 UDEBUG_M_BEGIN = 1,
    47 
    48 /** Finish debugging the recipient.
    49  * Answers all pending GO and GUARD messages.
    50  */
    51 UDEBUG_M_END,
    52 
    53 /** Set which events should be captured.
    54  */
    55 UDEBUG_M_SET_EVMASK,
    56 
    57 /** Make sure the debugged task is still there.
    58  * This message is answered when the debugged task dies
    59  * or the debugging session ends.
    60  */
    61 UDEBUG_M_GUARD,
    62 
    63 /** Run a thread until a debugging event occurs.
    64  * This message is answered when the thread stops
    65  * in a debugging event.
    66  *
    67  * - ARG2 - id of the thread to run
    68  */
    69 UDEBUG_M_GO,
    70 
    71 /** Stop a thread being debugged.
    72  * Creates a special STOP event in the thread, causing
    73  * it to answer a pending GO message (if any).
    74  */
    75 UDEBUG_M_STOP,
    76 
    77 /** Read arguments of a syscall.
    78  *
    79  * - ARG2 - thread identification
    80  * - ARG3 - destination address in the caller's address space
    81  *
    82  */
    83 UDEBUG_M_ARGS_READ,
    84 
    85 /** Read the list of the debugged tasks's threads.
    86  *
    87  * - ARG2 - destination address in the caller's address space
    88  * - ARG3 - size of receiving buffer in bytes
    89  *
    90  * The kernel fills the buffer with a series of sysarg_t values
    91  * (thread ids). On answer, the kernel will set:
    92  *
    93  * - ARG2 - number of bytes that were actually copied
    94  * - ARG3 - number of bytes of the complete data
    95  *
    96  */
    97 UDEBUG_M_THREAD_READ,
    98 
    99 /** Read the debugged tasks's memory.
    100  *
    101  * - ARG2 - destination address in the caller's address space
    102  * - ARG3 - source address in the recipient's address space
    103  * - ARG4 - size of receiving buffer in bytes
    104  *
    105  */
    106 UDEBUG_M_MEM_READ,
    107 
    108 } udebug_method_t;
    109 
    110                                
    111 typedef enum {
    112         UDEBUG_EVENT_FINISHED = 1,      /**< Debuging session has finished */
    113         UDEBUG_EVENT_STOP,              /**< Stopped on DEBUG_STOP request */
    114         UDEBUG_EVENT_SYSCALL_B,         /**< Before beginning syscall execution */
    115         UDEBUG_EVENT_SYSCALL_E,         /**< After finishing syscall execution */
    116         UDEBUG_EVENT_THREAD_B,          /**< The task created a new thread */
    117         UDEBUG_EVENT_THREAD_E           /**< A thread exited */
    118 } udebug_event_t;
    119 
    120 #define UDEBUG_EVMASK(event) (1 << ((event) - 1))
    121 
    122 typedef enum {
    123         UDEBUG_EM_FINISHED      = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
    124         UDEBUG_EM_STOP          = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
    125         UDEBUG_EM_SYSCALL_B     = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
    126         UDEBUG_EM_SYSCALL_E     = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
    127         UDEBUG_EM_THREAD_B      = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
    128         UDEBUG_EM_THREAD_E      = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
    129         UDEBUG_EM_ALL           =
    130                 UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
    131                 UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
    132                 UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
    133                 UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
    134                 UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
    135                 UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E)
    136 } udebug_evmask_t;
    137 
    138 #ifdef KERNEL
    139 
    140184#include <synch/mutex.h>
     185#include <synch/condvar.h>
    141186#include <arch/interrupt.h>
    142187#include <atomic.h>
     
    157202        mutex_t lock;
    158203        char *lock_owner;
    159 
     204       
    160205        udebug_task_state_t dt_state;
    161206        call_t *begin_call;
     
    170215        /** Synchronize debug ops on this thread / access to this structure. */
    171216        mutex_t lock;
    172 
     217       
    173218        waitq_t go_wq;
    174219        call_t *go_call;
    175         unative_t syscall_args[6];
     220        sysarg_t syscall_args[6];
    176221        istate_t *uspace_state;
    177 
     222       
    178223        /** What type of event are we stopped in or 0 if none. */
    179224        udebug_event_t cur_event;
    180         bool go;                /**< thread is GO */
    181         bool stoppable;         /**< thread is stoppable */
    182         bool active;            /**< thread is in a debugging session */
     225        bool go;         /**< Thread is GO */
     226        bool stoppable;  /**< Thread is stoppable */
     227        bool active;     /**< Thread is in a debugging session */
     228        condvar_t active_cv;
    183229} udebug_thread_t;
    184230
     
    186232struct thread;
    187233
    188 void udebug_task_init(udebug_task_t *ut);
    189 void udebug_thread_initialize(udebug_thread_t *ut);
    190 
    191 void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
    192     unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,
    193     bool end_variant);
    194 
    195 void udebug_thread_b_event_attach(struct thread *t, struct task *ta);
     234void udebug_task_init(udebug_task_t *);
     235void udebug_thread_initialize(udebug_thread_t *);
     236
     237void udebug_syscall_event(sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     238    sysarg_t, sysarg_t, sysarg_t, bool);
     239
     240void udebug_thread_b_event_attach(struct thread *, struct task *);
    196241void udebug_thread_e_event(void);
    197242
     
    201246void udebug_before_thread_runs(void);
    202247
    203 int udebug_task_cleanup(struct task *ta);
     248int udebug_task_cleanup(struct task *);
     249void udebug_thread_fault(void);
    204250
    205251#endif
  • kernel/generic/include/udebug/udebug_ipc.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    4141void udebug_call_receive(call_t *call);
    4242
    43 
    4443#endif
    4544
  • kernel/generic/include/udebug/udebug_ops.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    4545int udebug_stop(thread_t *t, call_t *call);
    4646
    47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *n);
     47int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
     48    size_t *needed);
     49int udebug_name_read(char **data, size_t *data_size);
    4850int udebug_args_read(thread_t *t, void **buffer);
    4951
    50 int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer);
     52int udebug_regs_read(thread_t *t, void **buffer);
     53
     54int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer);
    5155
    5256#endif
  • kernel/generic/include/userspace.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3737
    3838#include <proc/thread.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141/** Switch to user-space (CPU user priviledge level) */
Note: See TracChangeset for help on using the changeset viewer.