Changeset 5f70118 in mainline for kernel/generic/include


Ignore:
Timestamp:
2010-01-10T12:16:59Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c77a64f
Parents:
309ede1 (diff), 1ac3a52 (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.

Location:
kernel/generic/include
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/arch.h

    r309ede1 r5f70118  
    3939#include <proc/thread.h>
    4040#include <proc/task.h>
     41#include <mm/as.h>
    4142
    4243#define DEFAULT_CONTEXT         0
  • kernel/generic/include/context.h

    r309ede1 r5f70118  
    5151/** Save register context.
    5252 *
    53  * Save current register context (including stack pointers)
    54  * to context structure.
    55  *
    56  * Note that call to context_restore() will return at the same
     53 * Save the current register context (including stack pointer) to a context
     54 * structure. A subsequent call to context_restore() will return to the same
    5755 * address as the corresponding call to context_save().
    5856 *
    59  * This MUST be a macro, gcc -O0 does not inline functions even
    60  * if they are marked inline and context_save_arch must be called
    61  * from level <= that when context_restore is called.
     57 * Note that context_save_arch() must reuse the stack frame of the function
     58 * which called context_save(). We guarantee this by:
    6259 *
    63  * @param c Context structure.
     60 *   a) implementing context_save_arch() in assembly so that it does not create
     61 *      its own stack frame, and by
     62 *   b) defining context_save() as a macro because the inline keyword is just a
     63 *      hint for the compiler, not a real constraint; the application of a macro
     64 *      will definitely not create a stack frame either.
    6465 *
    65  * @return context_save() returns 1, context_restore() returns 0.
     66 * To imagine what could happen if there were some extra stack frames created
     67 * either by context_save() or context_save_arch(), we need to realize that the
     68 * sp saved in the contex_t structure points to the current stack frame as it
     69 * existed when context_save_arch() was executing. After the return from
     70 * context_save_arch() and context_save(), any extra stack frames created by
     71 * these functions will be destroyed and their contents sooner or later
     72 * overwritten by functions called next. Any attempt to restore to a context
     73 * saved like that would therefore lead to a disaster.
     74 *
     75 * @param c             Context structure.
     76 *
     77 * @return              context_save() returns 1, context_restore() returns 0.
    6678 */
    6779#define context_save(c)   context_save_arch(c)
     
    6981/** Restore register context.
    7082 *
    71  * Restore previously saved register context (including stack pointers)
    72  * from context structure.
     83 * Restore a previously saved register context (including stack pointer) from
     84 * a context structure.
    7385 *
    74  * Note that this function does not normally return.
    75  * Instead, it returns at the same address as the
    76  * corresponding call to context_save(), the only
    77  * difference being return value.
     86 * Note that this function does not normally return.  Instead, it returns to the
     87 * same address as the corresponding call to context_save(), the only difference
     88 * being return value.
    7889 *
    79  * @param c Context structure.
     90 * @param c             Context structure.
    8091 */
    8192static inline void context_restore(context_t *c)
  • kernel/generic/include/debug.h

    r309ede1 r5f70118  
    7575#       define LOG(format, ...) \
    7676                printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \
    77                         __LINE__, ##__VA_ARGS__);
     77                    __LINE__, ##__VA_ARGS__);
    7878#else
    7979#       define LOG(format, ...)
     
    9292                { \
    9393                        printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \
    94                         __LINE__); \
     94                            __LINE__); \
    9595                        fnc; \
    9696                }
  • kernel/generic/include/interrupt.h

    r309ede1 r5f70118  
    4242#include <arch.h>
    4343#include <ddi/irq.h>
     44#include <stacktrace.h>
    4445
    4546typedef void (* iroutine)(int n, istate_t *istate);
     
    4950        if (istate_from_uspace(istate)) { \
    5051                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__); \
     52                printf("Task %s (%" PRIu64 ") killed due to an exception at " \
     53                    "program counter %p.\n", task->name, task->taskid, istate_get_pc(istate)); \
     54                stack_trace_istate(istate); \
     55                printf("Kill message: " fmt "\n", ##__VA_ARGS__); \
    5356                task_kill(task->taskid); \
    5457                thread_exit(); \
  • kernel/generic/include/ipc/ipc.h

    r309ede1 r5f70118  
    5151/** This is answer to a call */
    5252#define IPC_CALL_ANSWERED       (1 << 0)
    53 /** This call will not be freed on error */
    54 #define IPC_CALL_STATIC_ALLOC   (1 << 1)
    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)
    5755/** Call was forwarded */
    58 #define IPC_CALL_FORWARDED      (1 << 3)
     56#define IPC_CALL_FORWARDED      (1 << 2)
    5957/** Identify connect_me_to answer */
    60 #define IPC_CALL_CONN_ME_TO     (1 << 4)
     58#define IPC_CALL_CONN_ME_TO     (1 << 3)
    6159/** Interrupt notification */
    62 #define IPC_CALL_NOTIF          (1 << 5)
     60#define IPC_CALL_NOTIF          (1 << 4)
    6361
    6462/*
     
    267265        waitq_t wq;
    268266
     267        /** Linkage for the list of task's synchronous answerboxes. */
     268        link_t sync_box_link;
     269
    269270        /** Phones connected to this answerbox. */
    270271        link_t connected_phones;
     
    316317} call_t;
    317318
     319
     320extern answerbox_t *ipc_phone_0;
     321
     322
    318323extern 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 *);
     324
     325extern call_t * ipc_call_alloc(int);
     326extern void ipc_call_free(call_t *);
     327
    321328extern int ipc_call(phone_t *, call_t *);
    322329extern int ipc_call_sync(phone_t *, call_t *);
     330extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int);
     331extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int);
     332extern void ipc_answer(answerbox_t *, call_t *);
     333
    323334extern void ipc_phone_init(phone_t *);
    324335extern void ipc_phone_connect(phone_t *, answerbox_t *);
    325 extern void ipc_call_free(call_t *);
    326 extern call_t * ipc_call_alloc(int);
     336extern int ipc_phone_hangup(phone_t *);
     337
    327338extern 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);
     339
    331340extern void ipc_cleanup(void);
    332 extern int ipc_phone_hangup(phone_t *);
    333341extern void ipc_backsend_err(phone_t *, call_t *, unative_t);
    334 extern void ipc_print_task(task_id_t);
    335342extern void ipc_answerbox_slam_phones(answerbox_t *, bool);
    336343extern void ipc_cleanup_call_list(link_t *);
    337344
    338 extern answerbox_t *ipc_phone_0;
     345extern void ipc_print_task(task_id_t);
    339346
    340347#endif
  • kernel/generic/include/main/main.h

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

    r309ede1 r5f70118  
    3636#define KERN_PANIC_H_
    3737
     38#include <stacktrace.h>
     39#include <print.h>
     40
    3841#ifdef CONFIG_DEBUG
    3942#       define panic(format, ...) \
    40                 panic_printf("Kernel panic in %s() at %s:%u: " format "\n", \
    41                 __func__, __FILE__, __LINE__, ##__VA_ARGS__);
     43                do { \
     44                        printf("Kernel panic in %s() at %s:%u.\n", \
     45                            __func__, __FILE__, __LINE__); \
     46                        stack_trace(); \
     47                        panic_printf("Panic message: " format "\n", \
     48                            ##__VA_ARGS__);\
     49                } while (0)
    4250#else
    4351#       define panic(format, ...) \
  • kernel/generic/include/print.h

    r309ede1 r5f70118  
    3737
    3838#include <arch/types.h>
    39 #include <arch/arg.h>
     39#include <stdarg.h>
    4040
    4141#define EOF (-1)
  • kernel/generic/include/printf/printf_core.h

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

    r309ede1 r5f70118  
    5555#include <udebug/udebug.h>
    5656#include <ipc/kbox.h>
     57#include <mm/as.h>
    5758
    5859#define TASK_NAME_BUFLEN        20
     
    9899         */
    99100        atomic_t active_calls;
     101        /** List of synchronous answerboxes. */
     102        link_t sync_box_head;
    100103
    101104#ifdef CONFIG_UDEBUG
     
    132135extern int task_kill(task_id_t id);
    133136extern uint64_t task_get_accounting(task_t *t);
     137extern void task_print_list(void);
    134138
    135139extern void cap_set(task_t *t, cap_t caps);
  • kernel/generic/include/proc/thread.h

    r309ede1 r5f70118  
    225225
    226226extern 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);
     227extern thread_t *thread_create(void (*)(void *), void *, task_t *, int, char *,
     228    bool);
     229extern void thread_attach(thread_t *, task_t *);
     230extern void thread_ready(thread_t *);
    231231extern void thread_exit(void) __attribute__((noreturn));
    232232
    233233#ifndef thread_create_arch
    234 extern void thread_create_arch(thread_t *t);
     234extern void thread_create_arch(thread_t *);
    235235#endif
    236236#ifndef thr_constructor_arch
    237 extern void thr_constructor_arch(thread_t *t);
     237extern void thr_constructor_arch(thread_t *);
    238238#endif
    239239#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);
     240extern void thr_destructor_arch(thread_t *);
     241#endif
     242
     243extern void thread_sleep(uint32_t);
     244extern void thread_usleep(uint32_t);
    245245
    246246#define thread_join(t) \
    247247        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);
     248extern int thread_join_timeout(thread_t *, uint32_t, int);
     249extern void thread_detach(thread_t *);
     250
     251extern void thread_register_call_me(void (*)(void *), void *);
    253252extern void thread_print_list(void);
    254 extern void thread_destroy(thread_t *t);
     253extern void thread_destroy(thread_t *);
    255254extern void thread_update_accounting(void);
    256 extern bool thread_exists(thread_t *t);
     255extern bool thread_exists(thread_t *);
    257256
    258257/** Fpu context slab cache. */
     
    260259
    261260/* 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);
     261extern unative_t sys_thread_create(uspace_arg_t *, char *, size_t,
     262    thread_id_t *);
     263extern unative_t sys_thread_exit(int);
     264extern unative_t sys_thread_get_id(thread_id_t *);
     265extern unative_t sys_thread_usleep(uint32_t);
    266266
    267267#endif
  • kernel/generic/include/stdarg.h

    r309ede1 r5f70118  
    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/string.h

    r309ede1 r5f70118  
    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);
    9090
    9191extern char *str_chr(const char *str, wchar_t ch);
  • kernel/generic/include/symtab.h

    r309ede1 r5f70118  
    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, char **, uintptr_t *);
     48extern 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
  • kernel/generic/include/synch/futex.h

    r309ede1 r5f70118  
    3838#include <arch/types.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 unative_t sys_futex_sleep(uintptr_t);
     55extern unative_t sys_futex_wakeup(uintptr_t);
    5956
    6057extern void futex_cleanup(void);
  • kernel/generic/include/syscall/syscall.h

    r309ede1 r5f70118  
    4343        SYS_THREAD_EXIT,
    4444        SYS_THREAD_GET_ID,
     45        SYS_THREAD_USLEEP,
    4546       
    4647        SYS_TASK_GET_ID,
Note: See TracChangeset for help on using the changeset viewer.