Changeset 04803bf in mainline for kernel/generic/include
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- 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. - Location:
- kernel/generic/include
- Files:
-
- 6 added
- 73 edited
- 1 moved
-
adt/avl.h (modified) (3 diffs)
-
adt/bitmap.h (modified) (1 diff)
-
adt/btree.h (modified) (1 diff)
-
adt/hash_table.h (modified) (4 diffs)
-
adt/list.h (modified) (10 diffs)
-
arch.h (modified) (4 diffs)
-
atomic.h (modified) (2 diffs)
-
bitops.h (modified) (4 diffs)
-
byteorder.h (modified) (1 diff)
-
config.h (modified) (2 diffs)
-
console/chardev.h (modified) (4 diffs)
-
console/console.h (modified) (2 diffs)
-
console/kconsole.h (modified) (3 diffs)
-
context.h (modified) (2 diffs)
-
cpu.h (modified) (4 diffs)
-
ddi/ddi.h (modified) (2 diffs)
-
ddi/ddi_arg.h (modified) (2 diffs)
-
ddi/device.h (modified) (1 diff)
-
ddi/irq.h (modified) (9 diffs)
-
debug.h (modified) (3 diffs)
-
func.h (modified) (2 diffs)
-
interrupt.h (modified) (1 diff)
-
ipc/event.h (modified) (4 diffs)
-
ipc/event_types.h (modified) (1 diff)
-
ipc/ipc.h (modified) (13 diffs)
-
ipc/ipcrsc.h (modified) (1 diff)
-
ipc/irq.h (modified) (2 diffs)
-
ipc/sysipc.h (modified) (1 diff)
-
lib/elf.h (modified) (15 diffs)
-
lib/rd.h (modified) (1 diff)
-
macros.h (modified) (4 diffs)
-
main/main.h (modified) (1 diff)
-
main/uinit.h (modified) (1 diff)
-
main/version.h (modified) (1 diff)
-
memstr.h (modified) (2 diffs)
-
mm/as.h (modified) (14 diffs)
-
mm/buddy.h (modified) (1 diff)
-
mm/frame.h (modified) (8 diffs)
-
mm/page.h (modified) (3 diffs)
-
mm/slab.h (modified) (5 diffs)
-
mm/tlb.h (modified) (3 diffs)
-
panic.h (modified) (3 diffs)
-
preemption.h (modified) (1 diff)
-
print.h (modified) (1 diff)
-
printf/printf_core.h (modified) (2 diffs)
-
proc/program.h (modified) (2 diffs)
-
proc/scheduler.h (modified) (2 diffs)
-
proc/task.h (modified) (6 diffs)
-
proc/thread.h (modified) (14 diffs)
-
security/cap.h (modified) (6 diffs)
-
smp/ipi.h (modified) (2 diffs)
-
smp/smp.h (modified) (2 diffs)
-
sort.h (modified) (2 diffs)
-
stacktrace.h (added)
-
stdarg.h (modified) (3 diffs)
-
stdint.h (added)
-
str.h (moved) (moved from kernel/generic/include/string.h ) (3 diffs)
-
symtab.h (modified) (2 diffs)
-
synch/condvar.h (modified) (1 diff)
-
synch/futex.h (modified) (2 diffs)
-
synch/mutex.h (modified) (2 diffs)
-
synch/semaphore.h (modified) (2 diffs)
-
synch/smc.h (modified) (1 diff)
-
synch/spinlock.h (modified) (9 diffs)
-
synch/waitq.h (modified) (4 diffs)
-
syscall/copy.h (modified) (1 diff)
-
syscall/syscall.h (modified) (5 diffs)
-
sysinfo/abi.h (added)
-
sysinfo/stats.h (added)
-
sysinfo/sysinfo.h (modified) (1 diff)
-
time/clock.h (modified) (1 diff)
-
time/delay.h (modified) (1 diff)
-
time/timeout.h (modified) (3 diffs)
-
trace.h (added)
-
typedefs.h (modified) (2 diffs)
-
udebug/udebug.h (modified) (6 diffs)
-
udebug/udebug_ipc.h (modified) (2 diffs)
-
udebug/udebug_ops.h (modified) (2 diffs)
-
userspace.h (modified) (2 diffs)
-
verify.h (added)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/avl.h
rb50b5af2 r04803bf 34 34 35 35 #ifndef KERN_AVLTREE_H_ 36 #define KERN_AVLTREE_H_ 36 #define KERN_AVLTREE_H_ 37 37 38 #include <arch/types.h>39 38 #include <typedefs.h> 39 #include <trace.h> 40 40 41 41 /** … … 111 111 * @param t AVL tree. 112 112 */ 113 static inline void avltree_create(avltree_t *t)113 NO_TRACE static inline void avltree_create(avltree_t *t) 114 114 { 115 115 t->root = NULL; … … 121 121 * @param node Node which is initialized. 122 122 */ 123 static inline void avltree_node_initialize(avltree_node_t *node)123 NO_TRACE static inline void avltree_node_initialize(avltree_node_t *node) 124 124 { 125 125 node->key = 0; -
kernel/generic/include/adt/bitmap.h
rb50b5af2 r04803bf 36 36 #define KERN_BITMAP_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 #define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0) -
kernel/generic/include/adt/btree.h
rb50b5af2 r04803bf 36 36 #define KERN_BTREE_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <adt/list.h> 40 40 -
kernel/generic/include/adt/hash_table.h
rb50b5af2 r04803bf 37 37 38 38 #include <adt/list.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 /** Set of operations for hash table. */ … … 48 48 * @return Index into hash table. 49 49 */ 50 size_t (* hash)( unative_t key[]);50 size_t (* hash)(sysarg_t key[]); 51 51 52 52 /** Hash table item comparison function. … … 57 57 * @return true if the keys match, false otherwise. 58 58 */ 59 bool (*compare)( unative_t key[], size_t keys, link_t *item);59 bool (*compare)(sysarg_t key[], size_t keys, link_t *item); 60 60 61 61 /** Hash table item removal callback. … … 79 79 extern void hash_table_create(hash_table_t *h, size_t m, size_t max_keys, 80 80 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);81 extern void hash_table_insert(hash_table_t *h, sysarg_t key[], link_t *item); 82 extern link_t *hash_table_find(hash_table_t *h, sysarg_t key[]); 83 extern void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys); 84 84 85 85 #endif -
kernel/generic/include/adt/list.h
rb50b5af2 r04803bf 36 36 #define KERN_LIST_H_ 37 37 38 #include <arch/types.h>39 38 #include <typedefs.h> 39 #include <trace.h> 40 40 41 41 /** Doubly linked list head and link type. */ … … 58 58 * @param link Pointer to link_t structure to be initialized. 59 59 */ 60 static inline void link_initialize(link_t *link)60 NO_TRACE static inline void link_initialize(link_t *link) 61 61 { 62 62 link->prev = NULL; … … 70 70 * @param head Pointer to link_t structure representing head of the list. 71 71 */ 72 static inline void list_initialize(link_t *head)72 NO_TRACE static inline void list_initialize(link_t *head) 73 73 { 74 74 head->prev = head; … … 83 83 * @param head Pointer to link_t structure representing head of the list. 84 84 */ 85 static inline void list_prepend(link_t *link, link_t *head)85 NO_TRACE static inline void list_prepend(link_t *link, link_t *head) 86 86 { 87 87 link->next = head->next; … … 98 98 * @param head Pointer to link_t structure representing head of the list. 99 99 */ 100 static inline void list_append(link_t *link, link_t *head)100 NO_TRACE static inline void list_append(link_t *link, link_t *head) 101 101 { 102 102 link->prev = head->prev; … … 113 113 * contained in. 114 114 */ 115 static inline void list_remove(link_t *link)115 NO_TRACE static inline void list_remove(link_t *link) 116 116 { 117 117 link->next->prev = link->prev; … … 126 126 * @param head Pointer to link_t structure representing head of the list. 127 127 */ 128 static inline bool list_empty(link_t *head)128 NO_TRACE static inline bool list_empty(link_t *head) 129 129 { 130 130 return head->next == head ? true : false; … … 144 144 * headless) list. 145 145 */ 146 static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)146 NO_TRACE static inline void headless_list_split_or_concat(link_t *part1, link_t *part2) 147 147 { 148 148 link_t *hlp; … … 165 165 * headless list. 166 166 */ 167 static inline void headless_list_split(link_t *part1, link_t *part2)167 NO_TRACE static inline void headless_list_split(link_t *part1, link_t *part2) 168 168 { 169 169 headless_list_split_or_concat(part1, part2); … … 177 177 * @param part2 Pointer to link_t structure leading the second headless list. 178 178 */ 179 static inline void headless_list_concat(link_t *part1, link_t *part2)179 NO_TRACE static inline void headless_list_concat(link_t *part1, link_t *part2) 180 180 { 181 181 headless_list_split_or_concat(part1, part2); -
kernel/generic/include/arch.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 39 39 #include <proc/thread.h> 40 40 #include <proc/task.h> 41 #include <mm/as.h> 41 42 42 #define DEFAULT_CONTEXT 043 #define DEFAULT_CONTEXT 0 43 44 44 #define CPU THE->cpu45 #define THREAD THE->thread46 #define TASK THE->task47 #define AS THE->as48 #define CONTEXT (THE->task ? THE->task->context : DEFAULT_CONTEXT)49 #define PREEMPTION_DISABLED THE->preemption_disabled45 #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 50 51 51 #define context_check(ctx1, ctx2) ((ctx1) == (ctx2))52 #define context_check(ctx1, ctx2) ((ctx1) == (ctx2)) 52 53 53 54 /** … … 57 58 */ 58 59 typedef 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. */ 64 65 } the_t; 65 66 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 */ 66 73 #define THE ((the_t * )(get_stack_base())) 67 74 68 extern void the_initialize(the_t * the);69 extern void the_copy(the_t * src, the_t *dst);75 extern void the_initialize(the_t *); 76 extern void the_copy(the_t *, the_t *); 70 77 71 78 extern void arch_pre_mm_init(void); … … 79 86 extern void reboot(void); 80 87 extern void arch_reboot(void); 81 extern void *arch_construct_function(fncptr_t * fptr, void *addr, void *caller);88 extern void *arch_construct_function(fncptr_t *, void *, void *); 82 89 83 90 #endif -
kernel/generic/include/atomic.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ATOMIC_H_ 37 37 38 typedef struct atomic { 39 volatile long count; 40 } atomic_t; 38 #include <typedefs.h> 39 #include <arch/atomic.h> 40 #include <verify.h> 41 41 42 #include <arch/atomic.h> 43 44 static inline void atomic_set(atomic_t *val, long i)42 NO_TRACE ATOMIC static inline void atomic_set(atomic_t *val, atomic_count_t i) 43 WRITES(&val->count) 44 REQUIRES_EXTENT_MUTABLE(val) 45 45 { 46 46 val->count = i; 47 47 } 48 48 49 static inline long atomic_get(atomic_t *val) 49 NO_TRACE ATOMIC static inline atomic_count_t atomic_get(atomic_t *val) 50 REQUIRES_EXTENT_MUTABLE(val) 50 51 { 51 52 return val->count; -
kernel/generic/include/bitops.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_BITOPS_H_ 37 37 38 #include <trace.h> 38 39 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). 40 49 * 41 * If number is zero, it returns 0 50 * @return 0 (if the number is zero) or [log_2(arg)]. 51 * 42 52 */ 43 static inline int fnzb32(uint32_t arg)53 NO_TRACE static inline uint8_t fnzb32(uint32_t arg) 44 54 { 45 int n = 0;46 55 uint8_t n = 0; 56 47 57 if (arg >> 16) { 48 58 arg >>= 16; … … 65 75 } 66 76 67 if (arg >> 1) { 68 arg >>= 1; 77 if (arg >> 1) 69 78 n += 1; 70 }71 79 72 80 return n; 73 81 } 74 82 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 */ 88 NO_TRACE static inline uint8_t fnzb64(uint64_t arg) 76 89 { 77 int n = 0;78 90 uint8_t n = 0; 91 79 92 if (arg >> 32) { 80 93 arg >>= 32; … … 85 98 } 86 99 87 #define fnzb(x) fnzb32(x)88 89 100 #endif 90 101 -
kernel/generic/include/byteorder.h
rb50b5af2 r04803bf 36 36 #define KERN_BYTEORDER_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 #if !(defined(__BE__) ^ defined(__LE__)) -
kernel/generic/include/config.h
rb50b5af2 r04803bf 36 36 #define KERN_CONFIG_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <arch/mm/page.h> 40 40 … … 66 66 67 67 typedef struct { 68 size_t cpu_count;/**< Number of processors detected. */68 unsigned int cpu_count; /**< Number of processors detected. */ 69 69 volatile size_t cpu_active; /**< Number of processors that are up and running. */ 70 70 71 71 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 */ 73 73 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 */ 76 76 } config_t; 77 77 -
kernel/generic/include/console/chardev.h
rb50b5af2 r04803bf 37 37 38 38 #include <adt/list.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <synch/waitq.h> 41 41 #include <synch/spinlock.h> … … 53 53 /** Character input device. */ 54 54 typedef struct indev { 55 c har *name;55 const char *name; 56 56 waitq_t wq; 57 57 58 58 /** Protects everything below. */ 59 SPINLOCK_DECLARE(lock);59 IRQ_SPINLOCK_DECLARE(lock); 60 60 wchar_t buffer[INDEV_BUFLEN]; 61 61 size_t counter; … … 81 81 /** Character output device. */ 82 82 typedef struct outdev { 83 c har *name;83 const char *name; 84 84 85 85 /** Protects everything below. */ … … 95 95 } outdev_t; 96 96 97 extern void indev_initialize(c har *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);97 extern void indev_initialize(const char *, indev_t *, 98 indev_operations_t *); 99 extern void indev_push_character(indev_t *, wchar_t); 100 extern wchar_t indev_pop_character(indev_t *); 101 101 102 extern void outdev_initialize(c har *name, outdev_t *outdev,103 outdev_operations_t * op);102 extern void outdev_initialize(const char *, outdev_t *, 103 outdev_operations_t *); 104 104 105 extern bool check_poll(indev_t * indev);105 extern bool check_poll(indev_t *); 106 106 107 107 #endif /* KERN_CHARDEV_H_ */ -
kernel/generic/include/console/console.h
rb50b5af2 r04803bf 36 36 #define KERN_CONSOLE_H_ 37 37 38 #include <arch/types.h> 38 #include <typedefs.h> 39 #include <print.h> 39 40 #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) 40 54 41 55 extern indev_t *stdin; 42 56 extern outdev_t *stdout; 43 extern bool silent; 57 58 extern void early_putchar(wchar_t); 44 59 45 60 extern indev_t *stdin_wire(void); … … 52 67 extern wchar_t getc(indev_t *indev); 53 68 extern 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);69 extern sysarg_t sys_klog(int fd, const void *buf, size_t size); 55 70 56 71 extern void grab_console(void); 57 72 extern void release_console(void); 58 73 59 extern unative_t sys_debug_enable_console(void);60 extern unative_t sys_debug_disable_console(void);74 extern sysarg_t sys_debug_enable_console(void); 75 extern sysarg_t sys_debug_disable_console(void); 61 76 62 77 #endif /* KERN_CONSOLE_H_ */ -
kernel/generic/include/console/kconsole.h
rb50b5af2 r04803bf 47 47 ARG_TYPE_INT, 48 48 ARG_TYPE_STRING, 49 /** Optional string */ 50 ARG_TYPE_STRING_OPTIONAL, 49 51 /** Variable type - either symbol or string. */ 50 52 ARG_TYPE_VAR … … 60 62 size_t len; 61 63 /** Integer value. */ 62 unative_t intval;64 sysarg_t intval; 63 65 /** Resulting type of variable arg */ 64 66 cmd_arg_type_t vartype; … … 94 96 extern void kconsole_notify_init(void); 95 97 extern bool kconsole_check_poll(void); 96 extern void kconsole(c har *prompt,char *msg, bool kcon);98 extern void kconsole(const char *prompt, const char *msg, bool kcon); 97 99 extern void kconsole_thread(void *data); 98 100 -
kernel/generic/include/context.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_CONTEXT_H_ 37 37 38 #include <arch/types.h> 38 #include <typedefs.h> 39 #include <trace.h> 39 40 #include <arch/context.h> 40 41 42 #define context_set_generic(ctx, _pc, stack, size) \ 43 (ctx)->pc = (uintptr_t) (_pc); \ 44 (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; 41 45 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)); 46 extern int context_save_arch(context_t *ctx) __attribute__((returns_twice)); 47 extern void context_restore_arch(context_t *ctx) __attribute__((noreturn)); 50 48 51 49 /** Save register context. 52 50 * 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 57 53 * address as the corresponding call to context_save(). 58 54 * 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: 62 57 * 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. 64 74 * 65 75 * @return context_save() returns 1, context_restore() returns 0. 76 * 66 77 */ 67 #define context_save(c ) context_save_arch(c)78 #define context_save(ctx) context_save_arch(ctx) 68 79 69 80 /** Restore register context. 70 81 * 71 * Restore previously saved register context (including stack pointers)72 * fromcontext structure.82 * Restore a previously saved register context (including stack pointer) from 83 * a context structure. 73 84 * 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. 78 88 * 79 * @param c Context structure. 89 * @param ctx Context structure. 90 * 80 91 */ 81 static inline void context_restore(context_t *c)92 NO_TRACE static inline void context_restore(context_t *ctx) 82 93 { 83 context_restore_arch(c );94 context_restore_arch(ctx); 84 95 } 85 96 -
kernel/generic/include/cpu.h
rb50b5af2 r04803bf 42 42 #include <arch/context.h> 43 43 44 #define CPU_STACK_SIZE STACK_SIZE44 #define CPU_STACK_SIZE STACK_SIZE 45 45 46 46 /** CPU structure. … … 48 48 * There is one structure like this for every processor. 49 49 */ 50 typedef struct {51 SPINLOCK_DECLARE(lock);52 50 typedef struct cpu { 51 IRQ_SPINLOCK_DECLARE(lock); 52 53 53 tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN]; 54 54 size_t tlb_messages_count; 55 55 56 56 context_t saved_context; 57 57 58 58 atomic_t nrdy; 59 59 runq_t rq[RQ_COUNT]; 60 60 volatile size_t needs_relink; 61 62 SPINLOCK_DECLARE(timeoutlock);61 62 IRQ_SPINLOCK_DECLARE(timeoutlock); 63 63 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 70 82 /** 71 83 * Processor ID assigned by kernel. … … 73 85 unsigned int id; 74 86 75 intactive;76 inttlb_active;77 87 bool active; 88 bool tlb_active; 89 78 90 uint16_t frequency_mhz; 79 91 uint32_t delay_loop_const; 80 92 81 93 cpu_arch_t arch; 82 94 83 95 struct thread *fpu_owner; 84 96 … … 96 108 extern void cpu_arch_init(void); 97 109 extern void cpu_identify(void); 98 extern void cpu_print_report(cpu_t * m);110 extern void cpu_print_report(cpu_t *); 99 111 100 112 #endif -
kernel/generic/include/ddi/ddi.h
rb50b5af2 r04803bf 37 37 38 38 #include <ddi/ddi_arg.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <proc/task.h> 41 41 #include <adt/list.h> … … 43 43 /** Structure representing contiguous physical memory area. */ 44 44 typedef 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 */ 47 46 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. */ 49 50 } parea_t; 50 51 51 52 extern void ddi_init(void); 52 extern void ddi_parea_register(parea_t * parea);53 extern void ddi_parea_register(parea_t *); 53 54 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); 55 extern sysarg_t sys_physmem_map(sysarg_t, sysarg_t, sysarg_t, sysarg_t); 56 extern sysarg_t sys_iospace_enable(ddi_ioarg_t *); 58 57 59 58 /* 60 59 * Interface to be implemented by all architectures. 61 60 */ 62 extern int ddi_iospace_enable_arch(task_t * task, uintptr_t ioaddr, size_t size);61 extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t); 63 62 64 63 #endif -
kernel/generic/include/ddi/ddi_arg.h
rb50b5af2 r04803bf 36 36 #define KERN_DDI_ARG_H_ 37 37 38 #ifdef KERNEL 39 40 #include <typedefs.h> 41 42 #endif /* KERNEL */ 43 38 44 /** Structure encapsulating arguments for SYS_PHYSMEM_MAP syscall. */ 39 45 typedef struct { 40 46 /** ID of the destination task. */ 41 u nsigned long longtask_id;47 uint64_t task_id; 42 48 /** Physical address of starting frame. */ 43 49 void *phys_base; … … 45 51 void *virt_base; 46 52 /** Number of pages to map. */ 47 unsigned longpages;53 size_t pages; 48 54 /** Address space area flags for the mapping. */ 49 int flags;55 unsigned int flags; 50 56 } ddi_memarg_t; 51 57 52 58 /** Structure encapsulating arguments for SYS_ENABLE_IOSPACE syscall. */ 53 59 typedef struct { 54 u nsigned 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. */ 57 63 } ddi_ioarg_t; 58 64 -
kernel/generic/include/ddi/device.h
rb50b5af2 r04803bf 36 36 #define KERN_DEVICE_H_ 37 37 38 #include <arch/types.h>39 38 #include <typedefs.h> 40 39 41 40 extern devno_t device_assign_devno(void); 42 extern unative_t sys_device_assign_devno(void);41 extern sysarg_t sys_device_assign_devno(void); 43 42 44 43 #endif -
kernel/generic/include/ddi/irq.h
rb50b5af2 r04803bf 36 36 #define KERN_IRQ_H_ 37 37 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_LAST50 } 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 65 38 #ifdef KERNEL 66 39 67 #include < arch/types.h>40 #include <typedefs.h> 68 41 #include <adt/list.h> 69 42 #include <adt/hash_table.h> … … 72 45 #include <ipc/ipc.h> 73 46 47 #endif /* KERNEL */ 48 74 49 typedef 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 101 typedef 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 109 typedef struct { 110 size_t cmdcount; 111 irq_cmd_t *cmds; 112 } irq_code_t; 113 114 #ifdef KERNEL 115 116 typedef enum { 117 IRQ_DECLINE, /**< Decline to service. */ 118 IRQ_ACCEPT /**< Accept to service. */ 77 119 } irq_ownership_t; 78 120 … … 92 134 * Primarily, this structure is encapsulated in the irq_t structure. 93 135 * It is protected by irq_t::lock. 136 * 94 137 */ 95 138 typedef struct { … … 98 141 /** Answerbox for notifications. */ 99 142 answerbox_t *answerbox; 100 /** Method to be used for the notification. */101 unative_tmethod;143 /** Interface and method to be used for the notification. */ 144 sysarg_t imethod; 102 145 /** Arguments that will be sent if the IRQ is claimed. */ 103 u native_t scratch[IPC_CALL_LEN];146 uint32_t scratch[IPC_CALL_LEN]; 104 147 /** Top-half pseudocode. */ 105 148 irq_code_t *code; 106 149 /** Counter. */ 107 150 size_t counter; 151 108 152 /** 109 153 * Link between IRQs that are notifying the same answerbox. The list is … … 117 161 * If one device has multiple interrupts, there will be multiple irq_t 118 162 * instantions with the same devno. 163 * 119 164 */ 120 165 typedef struct irq { 121 166 /** Hash table link. */ 122 167 link_t link; 123 168 124 169 /** Lock protecting everything in this structure 125 170 * except the link member. When both the IRQ … … 127 172 * this lock must not be taken first. 128 173 */ 129 SPINLOCK_DECLARE(lock);174 IRQ_SPINLOCK_DECLARE(lock); 130 175 131 176 /** Send EOI before processing the interrupt. … … 136 181 */ 137 182 bool preack; 138 183 139 184 /** Unique device number. -1 if not yet assigned. */ 140 185 devno_t devno; 141 186 142 187 /** Actual IRQ number. -1 if not yet assigned. */ 143 188 inr_t inr; … … 150 195 /** Instance argument for the handler and the claim function. */ 151 196 void *instance; 152 197 153 198 /** Clear interrupt routine. */ 154 199 cir_t cir; 155 200 /** First argument to the clear interrupt routine. */ 156 201 void *cir_arg; 157 202 158 203 /** Notification configuration structure. */ 159 204 ipc_notif_cfg_t notif_cfg; 160 205 } irq_t; 161 206 162 SPINLOCK_EXTERN(irq_uspace_hash_table_lock);207 IRQ_SPINLOCK_EXTERN(irq_uspace_hash_table_lock); 163 208 extern hash_table_t irq_uspace_hash_table; 209 210 extern inr_t last_inr; 164 211 165 212 extern void irq_init(size_t, size_t); … … 168 215 extern irq_t *irq_dispatch_and_lock(inr_t); 169 216 217 #endif /* KERNEL */ 218 170 219 #endif 171 220 172 #endif173 174 221 /** @} 175 222 */ -
kernel/generic/include/debug.h
rb50b5af2 r04803bf 37 37 38 38 #include <panic.h> 39 #include < arch/debug.h>39 #include <symtab.h> 40 40 41 #define CALLER ((uintptr_t) __builtin_return_address(0))41 #define CALLER ((uintptr_t) __builtin_return_address(0)) 42 42 43 #ifndef HERE 44 /** Current Instruction Pointer address */ 45 # define HERE ((uintptr_t *) 0) 46 #endif 43 #ifdef CONFIG_DEBUG 47 44 48 45 /** Debugging ASSERT macro … … 55 52 * 56 53 */ 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 65 87 66 88 /** Extensive logging output macro … … 71 93 * 72 94 */ 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) 73 101 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 */ 81 103 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, ...) 89 105 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 */ 100 107 108 #ifdef CONFIG_TRACE 109 110 extern void __cyg_profile_func_enter(void *, void *); 111 extern void __cyg_profile_func_exit(void *, void *); 112 113 #endif /* CONFIG_TRACE */ 101 114 102 115 #endif -
kernel/generic/include/func.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_FUNC_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <atomic.h> 40 40 41 41 extern atomic_t haltstate; 42 42 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); 43 extern void halt(void) __attribute__((noreturn)); 46 44 47 45 #endif -
kernel/generic/include/interrupt.h
rb50b5af2 r04803bf 37 37 38 38 #include <arch/interrupt.h> 39 #include <arch/types.h> 39 #include <print.h> 40 #include <typedefs.h> 40 41 #include <proc/task.h> 41 42 #include <proc/thread.h> 42 43 #include <arch.h> 43 44 #include <ddi/irq.h> 45 #include <stacktrace.h> 44 46 45 typedef void (* iroutine )(int n, istate_t *istate);47 typedef void (* iroutine_t)(unsigned int, istate_t *); 46 48 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 } 49 typedef struct { 50 const char *name; 51 bool hot; 52 iroutine_t handler; 53 uint64_t cycles; 54 uint64_t count; 55 } exc_table_t; 57 56 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); 57 IRQ_SPINLOCK_EXTERN(exctbl_lock); 58 extern exc_table_t exc_table[]; 59 60 extern void fault_if_from_uspace(istate_t *, const char *, ...) 61 PRINTF_ATTRIBUTE(2, 3); 62 extern istate_t *istate_get(thread_t *); 63 extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t); 64 extern void exc_dispatch(unsigned int, istate_t *); 65 extern void exc_init(void); 66 67 extern void irq_initialize_arch(irq_t *); 68 69 extern void istate_decode(istate_t *); 61 70 62 71 #endif -
kernel/generic/include/ipc/event.h
rb50b5af2 r04803bf 37 37 38 38 #include <ipc/event_types.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <synch/spinlock.h> 41 41 #include <ipc/ipc.h> … … 47 47 /** Answerbox for notifications. */ 48 48 answerbox_t *answerbox; 49 /** Method to be used for the notification. */50 unative_tmethod;49 /** Interface and method to be used for the notification. */ 50 sysarg_t imethod; 51 51 /** Counter. */ 52 52 size_t counter; … … 54 54 55 55 extern void event_init(void); 56 extern unative_t sys_event_subscribe(unative_t, unative_t);56 extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t); 57 57 extern bool event_is_subscribed(event_type_t); 58 58 extern void event_cleanup_answerbox(answerbox_t *); … … 71 71 event_notify((e), (a1), (a2), (a3), (a4), (a5)) 72 72 73 extern void event_notify(event_type_t, unative_t, unative_t, unative_t,74 unative_t, unative_t);73 extern void event_notify(event_type_t, sysarg_t, sysarg_t, sysarg_t, 74 sysarg_t, sysarg_t); 75 75 76 76 #endif -
kernel/generic/include/ipc/event_types.h
rb50b5af2 r04803bf 37 37 38 38 typedef enum event_type { 39 /** New data available in kernel log */ 39 40 EVENT_KLOG = 0, 41 /** Returning from kernel console to userspace */ 40 42 EVENT_KCONSOLE, 43 /** A task/thread has faulted and will be terminated */ 44 EVENT_FAULT, 41 45 EVENT_END 42 46 } event_type_t; -
kernel/generic/include/ipc/ipc.h
rb50b5af2 r04803bf 36 36 #define KERN_IPC_H_ 37 37 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 48 47 49 48 /* Flags for calls */ 50 49 51 50 /** 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 55 53 /** 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 57 56 /** Call was forwarded */ 58 #define IPC_CALL_FORWARDED (1 << 3) 57 #define IPC_CALL_FORWARDED (1 << 2) 58 59 59 /** Identify connect_me_to answer */ 60 #define IPC_CALL_CONN_ME_TO (1 << 4) 60 #define IPC_CALL_CONN_ME_TO (1 << 3) 61 61 62 /** 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 * 66 68 * The addresses are aligned at least to 4 that is why we can use the 2 least 67 69 * significant bits of the call address. 68 */ 70 * 71 */ 72 69 73 /** Type of this call is 'answer' */ 70 #define IPC_CALLID_ANSWERED 1 74 #define IPC_CALLID_ANSWERED 1 75 71 76 /** Type of this call is 'notification' */ 72 #define IPC_CALLID_NOTIFICATION 277 #define IPC_CALLID_NOTIFICATION 2 73 78 74 79 /* Return values from sys_ipc_call_async(). */ 75 #define IPC_CALLRET_FATAL -176 #define IPC_CALLRET_TEMPORARY -280 #define IPC_CALLRET_FATAL -1 81 #define IPC_CALLRET_TEMPORARY -2 77 82 78 83 79 84 /* 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]) 96 101 97 102 /* Well known phone descriptors */ 98 #define PHONE_NS 0103 #define PHONE_NS 0 99 104 100 105 /* Forwarding flags. */ 101 #define IPC_FF_NONE 0 106 #define IPC_FF_NONE 0 107 102 108 /** 103 109 * The call will be routed as though it was initially sent via the phone used to … … 106 112 * calls that were initially sent by the forwarder to the same destination. This 107 113 * 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 114 130 /** Clone connection. 115 131 * … … 117 133 * 118 134 * - 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 * 120 137 * - on answer, the callee acknowledges the new connection by sending EOK back 121 138 * or the kernel closes it 122 */ 123 #define IPC_M_CONNECTION_CLONE 1 139 * 140 */ 141 #define IPC_M_CONNECTION_CLONE 1 142 124 143 /** Protocol for CONNECT - ME 125 144 * 126 145 * Through this call, the recipient learns about the new cloned connection. 127 * 146 * 128 147 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone 129 148 * - on asnwer, the callee acknowledges the new connection by sending EOK back 130 149 * 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 134 155 * 135 156 * Calling process asks the callee to create a callback connection, … … 144 165 * error is sent back to caller. Otherwise 145 166 * 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 147 170 * (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 150 175 /** Protocol for CONNECT - ME - TO 151 176 * … … 165 190 * 166 191 */ 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 172 198 173 199 /** Send as_area over IPC. … … 175 201 * - ARG2 - size of source as_area (filled automatically by kernel) 176 202 * - ARG3 - flags of the as_area being sent 177 * 203 * 178 204 * on answer, the recipient must set: 179 205 * - ARG1 - dst as_area base adress 180 */ 181 #define IPC_M_SHARE_OUT 6 206 * 207 */ 208 #define IPC_M_SHARE_OUT 6 182 209 183 210 /** Receive as_area over IPC. … … 185 212 * - ARG2 - destination as_area size 186 213 * - ARG3 - user defined argument 187 * 214 * 188 215 * on answer, the recipient must set: 189 216 * 190 217 * - ARG1 - source as_area base address 191 218 * - 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 194 222 195 223 /** Send data to another address space over IPC. … … 201 229 * - ARG1 - final destination address space virtual address 202 230 * - 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 205 234 206 235 /** Receive data from another address space over IPC. … … 212 241 * - ARG1 - source virtual address in the destination address space 213 242 * - 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 216 246 217 247 /** Debug the recipient. 218 248 * - ARG1 - specifies the debug method (from udebug_method_t) 219 249 * - 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 222 253 223 254 /* 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 226 258 /* User methods */ 227 #define IPC_FIRST_USER_METHOD 1024259 #define IPC_FIRST_USER_METHOD 1024 228 260 229 261 #ifdef KERNEL 230 262 231 #define IPC_MAX_PHONES 16263 #define IPC_MAX_PHONES 32 232 264 233 265 #include <synch/spinlock.h> … … 261 293 262 294 typedef struct answerbox { 263 SPINLOCK_DECLARE(lock);264 295 IRQ_SPINLOCK_DECLARE(lock); 296 265 297 struct task *task; 266 298 267 299 waitq_t wq; 268 300 301 /** Linkage for the list of task's synchronous answerboxes. */ 302 link_t sync_box_link; 303 269 304 /** Phones connected to this answerbox. */ 270 305 link_t connected_phones; 271 306 /** 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 275 310 /** Answered calls. */ 276 311 link_t answers; 277 278 SPINLOCK_DECLARE(irq_lock); 312 313 IRQ_SPINLOCK_DECLARE(irq_lock); 314 279 315 /** Notifications from IRQ handlers. */ 280 316 link_t irq_notifs; … … 284 320 285 321 typedef 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. */ 287 326 phone_t *phone; 288 327 } ipc_data_t; … … 290 329 typedef struct { 291 330 link_t link; 292 293 int flags;294 331 332 unsigned int flags; 333 295 334 /** Identification of the caller. */ 296 335 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 */ 299 341 answerbox_t *callerbox; 300 342 301 343 /** Private data to internal IPC. */ 302 unative_t priv;303 344 sysarg_t priv; 345 304 346 /** Data passed from/to userspace. */ 305 347 ipc_data_t data; 306 348 307 349 /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */ 308 350 uint8_t *buffer; 309 351 310 352 /* 311 353 * The forward operation can masquerade the caller phone. For those … … 316 358 } call_t; 317 359 360 extern answerbox_t *ipc_phone_0; 361 318 362 extern 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 364 extern call_t *ipc_call_alloc(unsigned int); 365 extern void ipc_call_free(call_t *); 366 321 367 extern int ipc_call(phone_t *, call_t *); 322 368 extern int ipc_call_sync(phone_t *, call_t *); 369 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int); 370 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int); 371 extern void ipc_answer(answerbox_t *, call_t *); 372 323 373 extern void ipc_phone_init(phone_t *); 324 374 extern void ipc_phone_connect(phone_t *, answerbox_t *); 325 extern void ipc_call_free(call_t *);326 extern call_t * ipc_call_alloc(int); 375 extern int ipc_phone_hangup(phone_t *); 376 327 377 extern 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 331 379 extern 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); 380 extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t); 335 381 extern void ipc_answerbox_slam_phones(answerbox_t *, bool); 336 382 extern void ipc_cleanup_call_list(link_t *); 337 383 338 extern answerbox_t *ipc_phone_0; 384 extern void ipc_print_task(task_id_t); 385 386 #endif /* KERNEL */ 339 387 340 388 #endif 341 389 342 #endif343 344 390 /** @} 345 391 */ -
kernel/generic/include/ipc/ipcrsc.h
rb50b5af2 r04803bf 39 39 #include <ipc/ipc.h> 40 40 41 extern call_t * get_call( unative_t callid);41 extern call_t * get_call(sysarg_t callid); 42 42 extern int phone_alloc(task_t *t); 43 43 extern void phone_connect(int phoneid, answerbox_t *box); -
kernel/generic/include/ipc/irq.h
rb50b5af2 r04803bf 37 37 38 38 /** Maximum length of IPC IRQ program */ 39 #define IRQ_MAX_PROG_SIZE 2039 #define IRQ_MAX_PROG_SIZE 20 40 40 41 41 #include <ipc/ipc.h> 42 42 #include <ddi/irq.h> 43 #include < arch/types.h>43 #include <typedefs.h> 44 44 #include <adt/list.h> 45 45 46 extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, unative_t,46 extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, sysarg_t, 47 47 irq_code_t *); 48 48 … … 58 58 */ 59 59 #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 61 62 #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 63 65 #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 65 68 #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 67 71 #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 69 74 #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)) 71 76 72 extern void ipc_irq_send_msg(irq_t *, unative_t, unative_t, unative_t, unative_t,73 unative_t);77 extern void ipc_irq_send_msg(irq_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 78 sysarg_t); 74 79 75 80 #endif -
kernel/generic/include/ipc/sysipc.h
rb50b5af2 r04803bf 38 38 #include <ipc/ipc.h> 39 39 #include <ipc/irq.h> 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 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); 42 extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t, 43 sysarg_t, sysarg_t, ipc_data_t *); 44 extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *); 45 extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t, 46 sysarg_t, sysarg_t, sysarg_t); 47 extern sysarg_t sys_ipc_call_async_slow(sysarg_t, ipc_data_t *); 48 extern sysarg_t sys_ipc_answer_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 49 sysarg_t, sysarg_t); 50 extern sysarg_t sys_ipc_answer_slow(sysarg_t, ipc_data_t *); 51 extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *, uint32_t, unsigned int); 52 extern sysarg_t sys_ipc_poke(void); 53 extern sysarg_t sys_ipc_forward_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 54 sysarg_t, unsigned int); 55 extern sysarg_t sys_ipc_forward_slow(sysarg_t, sysarg_t, ipc_data_t *, 56 unsigned int); 57 extern sysarg_t sys_ipc_hangup(sysarg_t); 58 extern sysarg_t sys_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *); 59 extern sysarg_t sys_unregister_irq(inr_t, devno_t); 60 61 #ifdef __32_BITS__ 62 63 extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *); 64 65 #endif /* __32_BITS__ */ 66 67 #ifdef __64_BITS__ 68 69 extern sysarg_t sys_ipc_connect_kbox(sysarg_t); 70 71 #endif /* __64_BITS__ */ 64 72 65 73 #endif -
kernel/generic/include/lib/elf.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <arch/elf.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 /** 42 42 * current ELF version 43 43 */ 44 #define EV_CURRENT145 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 /** 58 58 * ELF machine types 59 59 */ 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 */ 71 71 72 72 /** 73 73 * ELF identification indexes 74 74 */ 75 #define EI_MAG0 076 #define EI_MAG1 177 #define EI_MAG2 278 #define EI_MAG3 379 #define EI_CLASS 4/* File class */80 #define EI_DATA 5/* Data encoding */81 #define EI_VERSION 6/* File version */82 #define EI_OSABI 783 #define EI_ABIVERSION 884 #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 */ 86 86 87 87 /** 88 88 * ELF magic number 89 89 */ 90 #define ELFMAG0 0x7f91 #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' 94 94 95 95 /** 96 96 * ELF file classes 97 97 */ 98 #define ELFCLASSNONE 099 #define ELFCLASS32 1100 #define ELFCLASS64 298 #define ELFCLASSNONE 0 99 #define ELFCLASS32 1 100 #define ELFCLASS64 2 101 101 102 102 /** 103 103 * ELF data encoding types 104 104 */ 105 #define ELFDATANONE 0106 #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) */ 108 108 109 109 /** 110 110 * ELF error return codes 111 111 */ 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 6112 #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 119 119 120 120 /** 121 121 * ELF section types 122 122 */ 123 #define SHT_NULL 0124 #define SHT_PROGBITS 1125 #define SHT_SYMTAB 2126 #define SHT_STRTAB 3127 #define SHT_RELA 4128 #define SHT_HASH 5129 #define SHT_DYNAMIC 6130 #define SHT_NOTE 7131 #define SHT_NOBITS 8132 #define SHT_REL 9133 #define SHT_SHLIB 10134 #define SHT_DYNSYM 11135 #define SHT_LOOS 0x60000000136 #define SHT_HIOS 0x6fffffff137 #define SHT_LOPROC 0x70000000138 #define SHT_HIPROC 0x7fffffff139 #define SHT_LOUSER 0x80000000140 #define SHT_HIUSER 0xffffffff123 #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 141 141 142 142 /** 143 143 * ELF section flags 144 144 */ 145 #define SHF_WRITE 0x1146 #define SHF_ALLOC 0x2147 #define SHF_EXECINSTR 0x4148 #define SHF_TLS 0x400149 #define SHF_MASKPROC 0xf0000000145 #define SHF_WRITE 0x1 146 #define SHF_ALLOC 0x2 147 #define SHF_EXECINSTR 0x4 148 #define SHF_TLS 0x400 149 #define SHF_MASKPROC 0xf0000000 150 150 151 151 /** 152 152 * Symbol binding 153 153 */ 154 #define STB_LOCAL 0155 #define STB_GLOBAL 1156 #define STB_WEAK 2157 #define STB_LOPROC 13158 #define STB_HIPROC 15154 #define STB_LOCAL 0 155 #define STB_GLOBAL 1 156 #define STB_WEAK 2 157 #define STB_LOPROC 13 158 #define STB_HIPROC 15 159 159 160 160 /** 161 161 * Symbol types 162 162 */ 163 #define STT_NOTYPE 0164 #define STT_OBJECT 1165 #define STT_FUNC 2166 #define STT_SECTION 3167 #define STT_FILE 4168 #define STT_LOPROC 13169 #define STT_HIPROC 15163 #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 170 170 171 171 /** 172 172 * Program segment types 173 173 */ 174 #define PT_NULL 0175 #define PT_LOAD 1176 #define PT_DYNAMIC 2177 #define PT_INTERP 3178 #define PT_NOTE 4179 #define PT_SHLIB 5180 #define PT_PHDR 6181 #define PT_LOPROC 0x70000000182 #define PT_HIPROC 0x7fffffff174 #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 183 183 184 184 /** 185 185 * Program segment attributes. 186 186 */ 187 #define PF_X 1188 #define PF_W 2189 #define PF_R 4187 #define PF_X 1 188 #define PF_W 2 189 #define PF_R 4 190 190 191 191 /** … … 195 195 * ELF object file specifications. They are the only types used 196 196 * in ELF header. 197 * 197 198 */ 198 199 typedef uint64_t elf_xword; … … 206 207 * 207 208 * These types are specific for 32-bit format. 209 * 208 210 */ 209 211 typedef uint32_t elf32_addr; … … 214 216 * 215 217 * These types are specific for 64-bit format. 218 * 216 219 */ 217 220 typedef uint64_t elf64_addr; … … 235 238 elf_half e_shstrndx; 236 239 }; 240 237 241 struct elf64_header { 238 242 uint8_t e_ident[EI_NIDENT]; … … 252 256 }; 253 257 254 /* 258 /** 255 259 * ELF segment header. 256 260 * Segments headers are also known as program headers. … … 266 270 elf_word p_align; 267 271 }; 272 268 273 struct elf64_segment_header { 269 274 elf_word p_type; … … 277 282 }; 278 283 279 /* 284 /** 280 285 * ELF section header 281 286 */ … … 292 297 elf_word sh_entsize; 293 298 }; 299 294 300 struct elf64_section_header { 295 301 elf_word sh_name; … … 305 311 }; 306 312 307 /* 313 /** 308 314 * ELF symbol table entry 309 315 */ … … 316 322 elf_half st_shndx; 317 323 }; 324 318 325 struct elf64_symbol { 319 326 elf_word st_name; … … 325 332 }; 326 333 327 #ifdef __32_BITS__ 334 #ifdef __32_BITS__ 328 335 typedef struct elf32_header elf_header_t; 329 336 typedef struct elf32_segment_header elf_segment_header_t; … … 331 338 typedef struct elf32_symbol elf_symbol_t; 332 339 #endif 340 333 341 #ifdef __64_BITS__ 334 342 typedef struct elf64_header elf_header_t; … … 338 346 #endif 339 347 340 extern c har *elf_error(unsigned int rc);341 342 /* Interpreter string used to recognize the program loader */343 #define ELF_INTERP_ZSTR "kernel"348 extern const char *elf_error(unsigned int rc); 349 350 /** Interpreter string used to recognize the program loader */ 351 #define ELF_INTERP_ZSTR "kernel" 344 352 #define ELF_INTERP_ZLEN sizeof(ELF_INTERP_ZSTR) 345 353 -
kernel/generic/include/lib/rd.h
rb50b5af2 r04803bf 36 36 #define KERN_RD_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 /** 41 41 * RAM disk version 42 42 */ 43 #define RD_VERSION 143 #define RD_VERSION 1 44 44 45 45 /** -
kernel/generic/include/macros.h
rb50b5af2 r04803bf 38 38 #ifndef __ASM__ 39 39 40 #include <arch/types.h> 40 #include <typedefs.h> 41 #include <trace.h> 41 42 42 43 /** Return true if the intervals overlap. … … 46 47 * @param s2 Start address of the second interval. 47 48 * @param sz2 Size of the second interval. 49 * 48 50 */ 49 static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2) 51 NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2, 52 uint64_t sz2) 50 53 { 51 uint ptr_t e1 = s1 + sz1;52 uint ptr_t e2 = s2 + sz2;54 uint64_t e1 = s1 + sz1; 55 uint64_t e2 = s2 + sz2; 53 56 54 57 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 */ 68 NO_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)); 55 75 } 56 76 … … 72 92 73 93 /* Compute overlapping of physical addresses */ 74 #define PA_ overlaps(x, szx, y, szy) \94 #define PA_OVERLAPS(x, szx, y, szy) \ 75 95 overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy)) 76 96 … … 84 104 #define STRING_ARG(arg) #arg 85 105 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)) 88 108 89 109 #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)) 92 112 93 113 /** Pseudorandom generator -
kernel/generic/include/main/main.h
rb50b5af2 r04803bf 32 32 /** @file 33 33 */ 34 34 35 35 #ifndef KERN_MAIN_H_ 36 36 #define KERN_MAIN_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 extern size_t hardcoded_kdata_size; 41 extern size_t hardcoded_ktext_size; 42 extern uintptr_t hardcoded_load_address; 40 43 extern uintptr_t stack_safe; 41 44 -
kernel/generic/include/main/uinit.h
rb50b5af2 r04803bf 36 36 #define KERN_UINIT_H_ 37 37 38 #include <arch/types.h>39 40 38 extern void uinit(void *arg); 41 39 -
kernel/generic/include/main/version.h
rb50b5af2 r04803bf 42 42 /** @} 43 43 */ 44 -
kernel/generic/include/memstr.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_MEMSTR_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <arch/memstr.h> 40 40 -
kernel/generic/include/mm/as.h
rb50b5af2 r04803bf 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 36 36 #define KERN_AS_H_ 37 37 38 #ifdef KERNEL 39 #include <typedefs.h> 40 #else 41 #include <sys/types.h> 42 #endif 43 38 44 /** 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. */ 51 typedef 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; 43 61 44 62 #ifdef KERNEL … … 47 65 #include <arch/mm/as.h> 48 66 #include <arch/mm/asid.h> 49 #include < arch/types.h>67 #include <typedefs.h> 50 68 #include <synch/spinlock.h> 51 69 #include <synch/mutex.h> … … 57 75 * Defined to be true if user address space and kernel address space shadow each 58 76 * 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 68 87 69 88 /** Kernel address space. */ 70 #define FLAG_AS_KERNEL (1 << 0)89 #define FLAG_AS_KERNEL (1 << 0) 71 90 72 91 /* Address space area attributes. */ 73 #define AS_AREA_ATTR_NONE 074 #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. */ 75 94 76 95 /** The page fault was not resolved by as_page_fault(). */ 77 #define AS_PF_FAULT 0 96 #define AS_PF_FAULT 0 97 78 98 /** The page fault was resolved by as_page_fault(). */ 79 #define AS_PF_OK 1 99 #define AS_PF_OK 1 100 80 101 /** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */ 81 #define AS_PF_DEFER 2102 #define AS_PF_DEFER 2 82 103 83 104 /** Address space structure. … … 87 108 * supposed to figure in the list as they are shared by all tasks and 88 109 * set up during system initialization. 110 * 89 111 */ 90 112 typedef struct as { 91 113 /** Protected by asidlock. */ 92 114 link_t inactive_as_with_asid_link; 115 93 116 /** 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. 96 120 */ 97 121 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 * 102 128 */ 103 129 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). */ 106 132 atomic_t refcount; 107 133 108 134 mutex_t lock; 109 135 110 136 /** B+tree of address space areas. */ 111 137 btree_t as_area_btree; … … 113 139 /** Non-generic content. */ 114 140 as_genarch_t genarch; 115 141 116 142 /** Architecture specific content. */ 117 143 as_arch_t arch; … … 119 145 120 146 typedef 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 *); 125 152 } as_operations_t; 126 153 … … 128 155 * This structure contains information associated with the shared address space 129 156 * area. 157 * 130 158 */ 131 159 typedef struct { 132 160 /** This lock must be acquired only when the as_area lock is held. */ 133 mutex_t lock; 161 mutex_t lock; 134 162 /** This structure can be deallocated if refcount drops to 0. */ 135 163 size_t refcount; 164 136 165 /** 137 166 * B+tree containing complete map of anonymous pages of the shared area. … … 144 173 PF_ACCESS_READ, 145 174 PF_ACCESS_WRITE, 146 PF_ACCESS_EXEC 175 PF_ACCESS_EXEC, 176 PF_ACCESS_UNKNOWN 147 177 } pf_access_t; 148 178 … … 151 181 /** Backend data stored in address space area. */ 152 182 typedef union mem_backend_data { 153 struct { /**< elf_backend members */ 183 /** elf_backend members */ 184 struct { 154 185 elf_header_t *elf; 155 186 elf_segment_header_t *segment; 156 187 }; 157 struct { /**< phys_backend members */ 188 189 /** phys_backend members */ 190 struct { 158 191 uintptr_t base; 159 192 size_t frames; … … 164 197 * 165 198 * Each as_area_t structure describes one contiguous area of virtual memory. 199 * 166 200 */ 167 201 typedef struct { 168 202 mutex_t lock; 203 169 204 /** 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. */ 178 214 size_t pages; 215 216 /** Number of resident pages in the area. */ 217 size_t resident; 218 179 219 /** Base address of this area. */ 180 220 uintptr_t base; 221 181 222 /** Map of used space. */ 182 223 btree_t used_space; 183 224 184 225 /** 185 * If the address space area has been shared, this pointer will186 * referencethe share info structure.226 * If the address space area is shared. this is 227 * a reference to the share info structure. 187 228 */ 188 229 share_info_t *sh_info; 189 230 190 231 /** Memory backend backing this address space area. */ 191 232 struct mem_backend *backend; 192 233 193 234 /** Data to be used by the backend. */ 194 235 mem_backend_data_t backend_data; … … 197 238 /** Address space area backend structure. */ 198 239 typedef 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 *); 202 243 } mem_backend_t; 203 244 … … 209 250 extern void as_init(void); 210 251 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 252 extern as_t *as_create(unsigned int); 253 extern void as_destroy(as_t *); 254 extern void as_hold(as_t *); 255 extern void as_release(as_t *); 256 extern void as_switch(as_t *, as_t *); 257 extern int as_page_fault(uintptr_t, pf_access_t, istate_t *); 258 259 extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t, 260 unsigned int, mem_backend_t *, mem_backend_data_t *); 261 extern int as_area_destroy(as_t *, uintptr_t); 262 extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int); 263 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, 264 unsigned int); 265 extern int as_area_change_flags(as_t *, unsigned int, uintptr_t); 266 267 extern unsigned int as_area_get_flags(as_area_t *); 268 extern bool as_area_check_access(as_area_t *, pf_access_t); 269 extern size_t as_area_get_size(uintptr_t); 270 extern bool used_space_insert(as_area_t *, uintptr_t, size_t); 271 extern bool used_space_remove(as_area_t *, uintptr_t, size_t); 231 272 232 273 /* Interface to be implemented by architectures. */ 274 233 275 #ifndef as_constructor_arch 234 extern int as_constructor_arch(as_t * as, int flags);276 extern int as_constructor_arch(as_t *, unsigned int); 235 277 #endif /* !def as_constructor_arch */ 278 236 279 #ifndef as_destructor_arch 237 extern int as_destructor_arch(as_t * as);280 extern int as_destructor_arch(as_t *); 238 281 #endif /* !def as_destructor_arch */ 282 239 283 #ifndef as_create_arch 240 extern int as_create_arch(as_t * as, int flags);284 extern int as_create_arch(as_t *, unsigned int); 241 285 #endif /* !def as_create_arch */ 286 242 287 #ifndef as_install_arch 243 extern void as_install_arch(as_t * as);288 extern void as_install_arch(as_t *); 244 289 #endif /* !def as_install_arch */ 290 245 291 #ifndef as_deinstall_arch 246 extern void as_deinstall_arch(as_t * as);292 extern void as_deinstall_arch(as_t *); 247 293 #endif /* !def as_deinstall_arch */ 248 294 … … 252 298 extern mem_backend_t phys_backend; 253 299 254 /** 300 /** 255 301 * This flags is passed when running the loader, otherwise elf_load() 256 302 * 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 308 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int); 262 309 263 310 /* 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); 311 extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int); 312 extern sysarg_t sys_as_area_resize(uintptr_t, size_t, unsigned int); 313 extern sysarg_t sys_as_area_change_flags(uintptr_t, unsigned int); 314 extern sysarg_t sys_as_area_destroy(uintptr_t); 315 extern sysarg_t sys_as_get_unmapped_area(uintptr_t, size_t); 268 316 269 317 /* Introspection functions. */ 270 extern void as_print(as_t *as); 318 extern void as_get_area_info(as_t *, as_area_info_t **, size_t *); 319 extern void as_print(as_t *); 271 320 272 321 #endif /* KERNEL */ -
kernel/generic/include/mm/buddy.h
rb50b5af2 r04803bf 36 36 #define KERN_BUDDY_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <adt/list.h> 40 40 -
kernel/generic/include/mm/frame.h
rb50b5af2 r04803bf 37 37 #define KERN_FRAME_H_ 38 38 39 #include <arch/types.h> 39 #include <typedefs.h> 40 #include <trace.h> 40 41 #include <adt/list.h> 41 42 #include <mm/buddy.h> … … 81 82 82 83 typedef struct { 83 size_t refcount; /**< Tracking of shared frames */84 size_t refcount; /**< Tracking of shared frames */ 84 85 uint8_t buddy_order; /**< Buddy system block order */ 85 86 link_t buddy_link; /**< Link to the next free block inside … … 91 92 pfn_t base; /**< Frame_no of the first frame 92 93 in the frames array */ 93 size_t count; /**< Size of zone */94 size_t free_count; /**< Number of free frame_t94 size_t count; /**< Size of zone */ 95 size_t free_count; /**< Number of free frame_t 95 96 structures */ 96 size_t busy_count; /**< Number of busy frame_t97 size_t busy_count; /**< Number of busy frame_t 97 98 structures */ 98 99 zone_flags_t flags; /**< Type of the zone */ … … 108 109 */ 109 110 typedef struct { 110 SPINLOCK_DECLARE(lock);111 IRQ_SPINLOCK_DECLARE(lock); 111 112 size_t count; 112 113 zone_t info[ZONES_MAX]; … … 115 116 extern zones_t zones; 116 117 117 static inline uintptr_t PFN2ADDR(pfn_t frame)118 NO_TRACE static inline uintptr_t PFN2ADDR(pfn_t frame) 118 119 { 119 120 return (uintptr_t) (frame << FRAME_WIDTH); 120 121 } 121 122 122 static inline pfn_t ADDR2PFN(uintptr_t addr)123 NO_TRACE static inline pfn_t ADDR2PFN(uintptr_t addr) 123 124 { 124 125 return (pfn_t) (addr >> FRAME_WIDTH); 125 126 } 126 127 127 static inline size_t SIZE2FRAMES(size_t size)128 NO_TRACE static inline size_t SIZE2FRAMES(size_t size) 128 129 { 129 130 if (!size) … … 132 133 } 133 134 134 static inline size_t FRAMES2SIZE(size_t frames)135 NO_TRACE static inline size_t FRAMES2SIZE(size_t frames) 135 136 { 136 137 return (size_t) (frames << FRAME_WIDTH); 137 138 } 138 139 139 static inline bool zone_flags_available(zone_flags_t flags)140 NO_TRACE static inline bool zone_flags_available(zone_flags_t flags) 140 141 { 141 142 return ((flags & (ZONE_RESERVED | ZONE_FIRMWARE)) == 0); … … 143 144 144 145 #define IS_BUDDY_ORDER_OK(index, order) \ 145 ((~((( unative_t) -1) << (order)) & (index)) == 0)146 ((~(((sysarg_t) -1) << (order)) & (index)) == 0) 146 147 #define IS_BUDDY_LEFT_BLOCK(zone, frame) \ 147 148 (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 0) … … 166 167 extern void frame_set_parent(pfn_t, void *, size_t); 167 168 extern void frame_mark_unavailable(pfn_t, size_t); 168 extern uintptr_t zone_conf_size(size_t);169 extern size_t zone_conf_size(size_t); 169 170 extern bool zone_merge(size_t, size_t); 170 171 extern void zone_merge_all(void); 171 extern uint64_t zone_total_size(void); 172 extern uint64_t zones_total_size(void); 173 extern void zones_stats(uint64_t *, uint64_t *, uint64_t *, uint64_t *); 172 174 173 175 /* 174 176 * Console functions 175 177 */ 176 extern void zone _print_list(void);178 extern void zones_print_list(void); 177 179 extern void zone_print_one(size_t); 178 180 -
kernel/generic/include/mm/page.h
rb50b5af2 r04803bf 36 36 #define KERN_PAGE_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <mm/as.h> 40 40 #include <memstr.h> … … 42 42 /** Operations to manipulate page mappings. */ 43 43 typedef 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); 48 47 } page_mapping_operations_t; 49 48 … … 51 50 52 51 extern 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);52 extern void page_table_lock(as_t *, bool); 53 extern void page_table_unlock(as_t *, bool); 54 extern bool page_table_locked(as_t *); 55 extern void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 56 extern void page_mapping_remove(as_t *, uintptr_t); 57 extern pte_t *page_mapping_find(as_t *, uintptr_t); 58 extern pte_t *page_table_create(unsigned int); 59 extern void page_table_destroy(pte_t *); 60 extern void map_structure(uintptr_t, size_t); 62 61 63 extern uintptr_t hw_map(uintptr_t physaddr, size_t size);62 extern uintptr_t hw_map(uintptr_t, size_t); 64 63 65 64 #endif -
kernel/generic/include/mm/slab.h
rb50b5af2 r04803bf 84 84 } slab_mag_cache_t; 85 85 86 87 86 typedef struct { 88 c har *name;87 const char *name; 89 88 90 89 link_t link; … … 94 93 size_t size; 95 94 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); 98 97 99 98 /** Flags changing behaviour of cache */ 100 int flags;99 unsigned int flags; 101 100 102 101 /* 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 */ 105 104 106 105 /* Statistics */ … … 109 108 atomic_t cached_objs; 110 109 /** How many magazines in magazines list */ 111 atomic_t magazine_counter; 110 atomic_t magazine_counter; 112 111 113 112 /* Slabs */ … … 123 122 } slab_cache_t; 124 123 125 extern slab_cache_t *slab_cache_create(c har *, size_t, size_t,126 int (*)(void *, int), int (*)(void *),int);124 extern slab_cache_t *slab_cache_create(const char *, size_t, size_t, 125 int (*)(void *, unsigned int), size_t (*)(void *), unsigned int); 127 126 extern void slab_cache_destroy(slab_cache_t *); 128 127 129 extern void * slab_alloc(slab_cache_t *, int); 128 extern void *slab_alloc(slab_cache_t *, unsigned int) 129 __attribute__((malloc)); 130 130 extern void slab_free(slab_cache_t *, void *); 131 extern size_t slab_reclaim( int);131 extern size_t slab_reclaim(unsigned int); 132 132 133 133 /* slab subsytem initialization */ … … 139 139 140 140 /* malloc support */ 141 extern void *malloc(unsigned int, int); 142 extern void *realloc(void *, unsigned int, int); 141 extern void *malloc(size_t, unsigned int) 142 __attribute__((malloc)); 143 extern void *realloc(void *, size_t, unsigned int); 143 144 extern void free(void *); 144 145 -
kernel/generic/include/mm/tlb.h
rb50b5af2 r04803bf 37 37 38 38 #include <arch/mm/asid.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 /** … … 68 68 69 69 #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);70 extern ipl_t tlb_shootdown_start(tlb_invalidate_type_t, asid_t, uintptr_t, 71 size_t); 72 extern void tlb_shootdown_finalize(ipl_t); 73 73 extern void tlb_shootdown_ipi_recv(void); 74 74 #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)); 77 77 #define tlb_shootdown_ipi_recv() 78 78 #endif /* CONFIG_SMP */ … … 84 84 85 85 extern 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);86 extern void tlb_invalidate_asid(asid_t); 87 extern void tlb_invalidate_pages(asid_t, uintptr_t, size_t); 88 88 #endif 89 89 -
kernel/generic/include/panic.h
rb50b5af2 r04803bf 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_PANIC_H_ 37 37 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> 46 40 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 53 typedef enum { 54 PANIC_OTHER, 55 PANIC_ASSERT, 56 PANIC_BADTRAP, 57 PANIC_MEMTRAP 58 } panic_category_t; 59 60 struct istate; 61 62 extern bool silent; 63 64 extern void panic_common(panic_category_t, struct istate *, int, 65 uintptr_t, const char *, ...) __attribute__ ((noreturn)) 66 PRINTF_ATTRIBUTE(5, 6); 48 67 49 68 #endif -
kernel/generic/include/preemption.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ -
kernel/generic/include/print.h
rb50b5af2 r04803bf 36 36 #define KERN_PRINT_H_ 37 37 38 #include < arch/types.h>39 #include < arch/arg.h>38 #include <typedefs.h> 39 #include <stdarg.h> 40 40 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) 42 53 43 54 extern int puts(const char *s); 44 extern int printf(const char *fmt, ...); 45 extern int snprintf(char *str, size_t size, const char *fmt, ...); 55 extern int printf(const char *fmt, ...) 56 PRINTF_ATTRIBUTE(1, 2); 57 extern int snprintf(char *str, size_t size, const char *fmt, ...) 58 PRINTF_ATTRIBUTE(3, 4); 46 59 47 60 extern int vprintf(const char *fmt, va_list ap); -
kernel/generic/include/printf/printf_core.h
rb50b5af2 r04803bf 37 37 38 38 #include <typedefs.h> 39 #include < arch/arg.h>39 #include <stdarg.h> 40 40 41 41 /** Structure for specifying output methods for different printf clones. */ … … 51 51 } printf_spec_t; 52 52 53 int printf_core(const char *fmt, printf_spec_t *ps, va_list ap);53 extern int printf_core(const char *fmt, printf_spec_t *ps, va_list ap); 54 54 55 55 #endif -
kernel/generic/include/proc/program.h
rb50b5af2 r04803bf 36 36 #define KERN_PROGRAM_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 struct task; … … 45 45 * A program is an abstraction of a freshly created (not yet running) 46 46 * userspace task containing a main thread along with its userspace stack. 47 * 47 48 */ 48 49 typedef 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 */ 51 52 } program_t; 52 53 53 54 extern void *program_loader; 54 55 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); 56 extern int program_create(as_t *, uintptr_t, char *, program_t *); 57 extern int program_create_from_image(void *, char *, program_t *); 58 extern int program_create_loader(program_t *, char *); 59 extern void program_ready(program_t *); 61 60 62 extern unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len);61 extern sysarg_t sys_program_spawn_loader(char *, size_t); 63 62 64 63 #endif -
kernel/generic/include/proc/scheduler.h
rb50b5af2 r04803bf 37 37 38 38 #include <synch/spinlock.h> 39 #include <time/clock.h> /* HZ */ 39 #include <time/clock.h> 40 #include <typedefs.h> 40 41 #include <atomic.h> 41 42 #include <adt/list.h> 42 43 43 #define RQ_COUNT 1644 #define NEEDS_RELINK_MAX (HZ)44 #define RQ_COUNT 16 45 #define NEEDS_RELINK_MAX (HZ) 45 46 46 47 /** Scheduler run queue structure. */ 47 48 typedef 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. */ 51 52 } runq_t; 52 53 … … 61 62 62 63 /* 63 * To be defined by architectures :64 * To be defined by architectures. 64 65 */ 65 66 extern void before_task_runs_arch(void); -
kernel/generic/include/proc/task.h
rb50b5af2 r04803bf 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 40 40 #include <synch/spinlock.h> 41 41 #include <synch/mutex.h> 42 #include <synch/rwlock.h>43 42 #include <synch/futex.h> 44 43 #include <adt/avl.h> … … 55 54 #include <udebug/udebug.h> 56 55 #include <ipc/kbox.h> 57 58 # define TASK_NAME_BUFLEN 2056 #include <mm/as.h> 57 #include <sysinfo/abi.h> 59 58 60 59 struct thread; … … 70 69 * threads. 71 70 */ 72 SPINLOCK_DECLARE(lock);73 71 IRQ_SPINLOCK_DECLARE(lock); 72 74 73 char name[TASK_NAME_BUFLEN]; 75 74 /** List of threads contained in this task. */ … … 80 79 task_id_t taskid; 81 80 /** Task security context. */ 82 context_id_t context; 83 81 context_id_t context; 82 84 83 /** Number of references (i.e. threads). */ 85 84 atomic_t refcount; 86 85 /** Number of threads that haven't exited yet. */ 87 86 atomic_t lifecount; 88 87 89 88 /** Task capabilities. */ 90 cap_t capabilities; 91 89 cap_t capabilities; 90 92 91 /* IPC stuff */ 93 92 answerbox_t answerbox; /**< Communication endpoint */ 94 93 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 101 98 #ifdef CONFIG_UDEBUG 102 99 /** Debugging stuff. */ 103 100 udebug_task_t udebug; 104 101 105 102 /** Kernel answerbox. */ 106 103 kbox_t kb; 107 #endif 108 104 #endif /* CONFIG_UDEBUG */ 105 109 106 /** Architecture specific task data. */ 110 107 task_arch_t arch; … … 116 113 mutex_t futexes_lock; 117 114 /** B+tree of futexes referenced by this task. */ 118 btree_t futexes; 115 btree_t futexes; 119 116 120 117 /** Accumulated accounting. */ 121 uint64_t cycles; 118 uint64_t ucycles; 119 uint64_t kcycles; 122 120 } task_t; 123 121 124 SPINLOCK_EXTERN(tasks_lock);122 IRQ_SPINLOCK_EXTERN(tasks_lock); 125 123 extern avltree_t tasks_tree; 126 124 127 125 extern void task_init(void); 128 126 extern 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); 127 extern task_t *task_create(as_t *, const char *); 128 extern void task_destroy(task_t *); 129 extern void task_hold(task_t *); 130 extern void task_release(task_t *); 131 extern task_t *task_find_by_id(task_id_t); 132 extern int task_kill(task_id_t); 133 extern void task_kill_self(bool) __attribute__((noreturn)); 134 extern void task_get_accounting(task_t *, uint64_t *, uint64_t *); 135 extern void task_print_list(bool); 134 136 135 extern void cap_set(task_t * t, cap_t caps);136 extern cap_t cap_get(task_t * t);137 extern void cap_set(task_t *, cap_t); 138 extern cap_t cap_get(task_t *); 137 139 138 140 #ifndef task_create_arch 139 extern void task_create_arch(task_t * t);141 extern void task_create_arch(task_t *); 140 142 #endif 141 143 142 144 #ifndef task_destroy_arch 143 extern void task_destroy_arch(task_t * t);145 extern void task_destroy_arch(task_t *); 144 146 #endif 145 147 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__ 149 extern sysarg_t sys_task_get_id(sysarg64_t *); 150 #endif 151 152 #ifdef __64_BITS__ 153 extern sysarg_t sys_task_get_id(void); 154 #endif 155 156 extern sysarg_t sys_task_set_name(const char *, size_t); 157 extern sysarg_t sys_task_kill(task_id_t *); 158 extern sysarg_t sys_task_exit(sysarg_t); 148 159 149 160 #endif -
kernel/generic/include/proc/thread.h
rb50b5af2 r04803bf 40 40 #include <time/timeout.h> 41 41 #include <cpu.h> 42 #include <synch/rwlock.h>43 42 #include <synch/spinlock.h> 44 43 #include <adt/avl.h> … … 48 47 #include <proc/uarg.h> 49 48 #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 54 extern const char *thread_states[]; 55 55 56 56 /* Thread flags */ … … 60 60 * When using this flag, the caller must set cpu in the thread_t 61 61 * 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 64 66 /** 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 66 69 /** Thread executes in userspace. */ 67 #define THREAD_FLAG_USPACE (1 << 2) 70 #define THREAD_FLAG_USPACE (1 << 2) 71 68 72 /** 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) 88 74 89 75 /** Thread structure. There is one per thread. */ 90 76 typedef 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 95 81 /** Threads linkage to the threads_tree. */ 96 82 avltree_node_t threads_tree_node; … … 100 86 * Protects the whole thread structure except list links above. 101 87 */ 102 SPINLOCK_DECLARE(lock);103 88 IRQ_SPINLOCK_DECLARE(lock); 89 104 90 char name[THREAD_NAME_BUFLEN]; 105 91 106 92 /** Function implementing the thread. */ 107 void (* thread_code)(void *);93 void (*thread_code)(void *); 108 94 /** Argument passed to thread_code() function. */ 109 95 void *thread_arg; 110 111 /** 112 * From here, the stored context is restored when the thread is113 * scheduled.96 97 /** 98 * From here, the stored context is restored 99 * when the thread is scheduled. 114 100 */ 115 101 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. 119 106 */ 120 107 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. 124 112 */ 125 113 context_t sleep_interruption_context; 126 114 127 115 /** If true, the thread can be interrupted from sleep. */ 128 116 bool sleep_interruptible; … … 132 120 timeout_t sleep_timeout; 133 121 /** Flag signalling sleep timeout in progress. */ 134 volatile inttimeout_pending;135 122 volatile bool timeout_pending; 123 136 124 /** 137 125 * True if this thread is executing copy_from_uspace(). … … 139 127 */ 140 128 bool in_copy_from_uspace; 129 141 130 /** 142 131 * True if this thread is executing copy_to_uspace(). … … 149 138 * thread_exit() before returning to userspace. 150 139 */ 151 bool interrupted; 140 bool interrupted; 152 141 153 142 /** If true, thread_join_timeout() cannot be used on this thread. */ … … 157 146 /** Link used in the joiner_head list. */ 158 147 link_t joiner_link; 159 148 160 149 fpu_context_t *saved_fpu_context; 161 150 int fpu_context_exists; 162 151 163 152 /* 164 153 * Defined only if thread doesn't run. … … 167 156 */ 168 157 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 177 159 /** Thread's state. */ 178 160 state_t state; 179 161 /** Thread's flags. */ 180 int flags;162 unsigned int flags; 181 163 182 164 /** Thread's CPU. */ … … 184 166 /** Containing task. */ 185 167 task_t *task; 186 168 187 169 /** Ticks before preemption. */ 188 170 uint64_t ticks; 189 171 190 172 /** Thread accounting. */ 191 uint64_t cycles; 173 uint64_t ucycles; 174 uint64_t kcycles; 192 175 /** Last sampled cycle. */ 193 176 uint64_t last_cycle; 194 /** Thread doesn't affect accumulated accounting. */ 177 /** Thread doesn't affect accumulated accounting. */ 195 178 bool uncounted; 196 179 197 180 /** Thread's priority. Implemented as index to CPU->rq */ 198 181 int priority; … … 202 185 /** Architecture-specific data. */ 203 186 thread_arch_t arch; 204 187 205 188 /** Thread's kernel stack. */ 206 189 uint8_t *kstack; 207 190 208 191 #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 209 198 /** Debugging stuff */ 210 199 udebug_thread_t udebug; 211 #endif 212 200 #endif /* CONFIG_UDEBUG */ 213 201 } thread_t; 214 202 … … 219 207 * 220 208 */ 221 SPINLOCK_EXTERN(threads_lock);209 IRQ_SPINLOCK_EXTERN(threads_lock); 222 210 223 211 /** AVL tree containing all threads. */ … … 225 213 226 214 extern 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);215 extern thread_t *thread_create(void (*)(void *), void *, task_t *, 216 unsigned int, const char *, bool); 217 extern void thread_attach(thread_t *, task_t *); 218 extern void thread_ready(thread_t *); 231 219 extern void thread_exit(void) __attribute__((noreturn)); 232 220 233 221 #ifndef thread_create_arch 234 extern void thread_create_arch(thread_t *t); 235 #endif 222 extern void thread_create_arch(thread_t *); 223 #endif 224 236 225 #ifndef thr_constructor_arch 237 extern void thr_constructor_arch(thread_t *t); 238 #endif 226 extern void thr_constructor_arch(thread_t *); 227 #endif 228 239 229 #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);230 extern void thr_destructor_arch(thread_t *); 231 #endif 232 233 extern void thread_sleep(uint32_t); 234 extern void thread_usleep(uint32_t); 245 235 246 236 #define thread_join(t) \ 247 237 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 239 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int); 240 extern void thread_detach(thread_t *); 241 242 extern void thread_print_list(bool); 243 extern void thread_destroy(thread_t *, bool); 244 extern thread_t *thread_find_by_id(thread_id_t); 245 extern void thread_update_accounting(bool); 246 extern bool thread_exists(thread_t *); 247 248 #ifdef CONFIG_UDEBUG 249 extern void thread_stack_trace(thread_id_t); 250 #endif 257 251 258 252 /** Fpu context slab cache. */ … … 260 254 261 255 /* 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); 256 extern sysarg_t sys_thread_create(uspace_arg_t *, char *, size_t, 257 thread_id_t *); 258 extern sysarg_t sys_thread_exit(int); 259 extern sysarg_t sys_thread_get_id(thread_id_t *); 260 extern sysarg_t sys_thread_usleep(uint32_t); 266 261 267 262 #endif -
kernel/generic/include/security/cap.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 35 35 /** 36 36 * @file 37 * @brief Capabilities definitions.37 * @brief Capabilities definitions. 38 38 * 39 39 * Capabilities represent virtual rights that entitle their … … 48 48 #define __CAP_H__ 49 49 50 #include <syscall/sysarg64.h> 51 #include <arch/types.h> 50 #include <typedefs.h> 52 51 53 52 /** … … 55 54 * privilege to/from other tasks. 56 55 */ 57 #define CAP_CAP (1<<0)56 #define CAP_CAP (1 << 0) 58 57 59 58 /** … … 61 60 * to other tasks. 62 61 */ 63 #define CAP_MEM_MANAGER (1<<1)62 #define CAP_MEM_MANAGER (1 << 1) 64 63 65 64 /** … … 67 66 * to other tasks. 68 67 */ 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) 75 69 76 70 /** 77 71 * CAP_IRQ_REG entitles its holder to register IRQ handlers. 78 72 */ 79 #define CAP_IRQ_REG (1<<4)73 #define CAP_IRQ_REG (1 << 3) 80 74 81 75 typedef uint32_t cap_t; 82 76 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 79 extern sysarg_t sys_cap_grant(sysarg64_t *, cap_t); 80 extern sysarg_t sys_cap_revoke(sysarg64_t *, cap_t); 81 82 #endif /* __32_BITS__ */ 83 84 #ifdef __64_BITS__ 85 86 extern sysarg_t sys_cap_grant(sysarg_t, cap_t); 87 extern sysarg_t sys_cap_revoke(sysarg_t, cap_t); 88 89 #endif /* __64_BITS__ */ 85 90 86 91 #endif -
kernel/generic/include/smp/ipi.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 37 37 38 38 #ifdef CONFIG_SMP 39 extern void ipi_broadcast(int ipi); 40 extern void ipi_broadcast_arch(int ipi); 39 40 extern void ipi_broadcast(int); 41 extern void ipi_broadcast_arch(int); 42 41 43 #else 42 #define ipi_broadcast(x) ; 44 45 #define ipi_broadcast(ipi) 46 43 47 #endif /* CONFIG_SMP */ 44 48 -
kernel/generic/include/smp/smp.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 41 41 42 42 #ifdef CONFIG_SMP 43 43 44 extern void smp_init(void); 44 45 extern void kmp(void *arg); 45 #else 46 47 #else /* CONFIG_SMP */ 48 46 49 #define smp_init() 50 47 51 #endif /* CONFIG_SMP */ 48 52 -
kernel/generic/include/sort.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_SORT_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 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)); 40 typedef int (* sort_cmp_t)(void *, void *, void *); 45 41 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); 42 extern bool gsort(void *, size_t, size_t, sort_cmp_t, void *); 43 extern bool qsort(void *, size_t, size_t, sort_cmp_t, void *); 53 44 54 45 #endif -
kernel/generic/include/stdarg.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 37 37 * for all architectures with compiler support for __builtin_va_*. 38 38 */ 39 39 40 40 #ifndef KERN_STDARG_H_ 41 41 #define KERN_STDARG_H_ … … 43 43 typedef __builtin_va_list va_list; 44 44 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) 49 49 50 50 #endif -
kernel/generic/include/str.h
rb50b5af2 r04803bf 33 33 */ 34 34 35 #ifndef KERN_STR ING_H_36 #define KERN_STR ING_H_35 #ifndef KERN_STR_H_ 36 #define KERN_STR_H_ 37 37 38 38 #include <typedefs.h> … … 87 87 extern void str_cpy(char *dest, size_t size, const char *src); 88 88 extern 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); 89 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 90 91 extern char *str_dup(const char *src); 92 extern char *str_ndup(const char *src, size_t n); 90 93 91 94 extern char *str_chr(const char *str, wchar_t ch); … … 94 97 extern bool wstr_remove(wchar_t *str, size_t pos); 95 98 99 extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *); 100 101 extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix); 102 96 103 #endif 97 104 -
kernel/generic/include/symtab.h
rb50b5af2 r04803bf 36 36 #define KERN_SYMTAB_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 #define MAX_SYMBOL_NAME 6440 #define MAX_SYMBOL_NAME 64 41 41 42 42 struct symtab_entry { … … 45 45 }; 46 46 47 extern int symtab_name_lookup(u native_t addr, char **name);48 extern c har *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);47 extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *); 48 extern const char *symtab_fmt_name_lookup(uintptr_t); 49 extern int symtab_addr_lookup(const char *, uintptr_t *); 50 extern void symtab_print_search(const char *); 51 extern int symtab_compl(char *, size_t); 52 52 53 53 #ifdef CONFIG_SYMTAB 54 54 55 /* Symtable linked together by build process */ 55 /** Symtable linked together by build process 56 * 57 */ 56 58 extern struct symtab_entry symbol_table[]; 57 59 58 #endif 60 #endif /* CONFIG_SYMTAB */ 59 61 60 62 #endif -
kernel/generic/include/synch/condvar.h
rb50b5af2 r04803bf 36 36 #define KERN_CONDVAR_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 40 #include <synch/mutex.h> -
kernel/generic/include/synch/futex.h
rb50b5af2 r04803bf 36 36 #define KERN_FUTEX_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 #include <genarch/mm/page_ht.h>41 #include <genarch/mm/page_pt.h>42 40 43 41 /** Kernel-side futex structure. */ … … 54 52 55 53 extern 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); 54 extern sysarg_t sys_futex_sleep(uintptr_t); 55 extern sysarg_t sys_futex_wakeup(uintptr_t); 59 56 60 57 extern void futex_cleanup(void); -
kernel/generic/include/synch/mutex.h
rb50b5af2 r04803bf 36 36 #define KERN_MUTEX_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/semaphore.h> 40 40 #include <synch/synch.h> … … 50 50 } mutex_t; 51 51 52 #define mutex_lock(mtx) \52 #define mutex_lock(mtx) \ 53 53 _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 54 #define mutex_trylock(mtx) \ 54 55 #define mutex_trylock(mtx) \ 55 56 _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) \ 57 59 _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING) 58 60 59 61 extern void mutex_initialize(mutex_t *, mutex_type_t); 60 extern int _mutex_lock_timeout(mutex_t *, uint32_t, int); 62 extern bool mutex_locked(mutex_t *); 63 extern int _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int); 61 64 extern void mutex_unlock(mutex_t *); 62 65 -
kernel/generic/include/synch/semaphore.h
rb50b5af2 r04803bf 36 36 #define KERN_SEMAPHORE_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 40 #include <synch/synch.h> … … 46 46 #define semaphore_down(s) \ 47 47 _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 48 48 49 #define semaphore_trydown(s) \ 49 50 _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING) 51 50 52 #define semaphore_down_timeout(s, usec) \ 51 53 _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE) 52 54 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); 55 extern void semaphore_initialize(semaphore_t *, int); 56 extern int _semaphore_down_timeout(semaphore_t *, uint32_t, unsigned int); 57 extern void semaphore_up(semaphore_t *); 58 extern int semaphore_count_get(semaphore_t *); 56 59 57 60 #endif -
kernel/generic/include/synch/smc.h
rb50b5af2 r04803bf 36 36 #define KERN_SMC_H_ 37 37 38 extern unative_t sys_smc_coherence(uintptr_t va, size_t size);38 extern sysarg_t sys_smc_coherence(uintptr_t va, size_t size); 39 39 40 40 #endif -
kernel/generic/include/synch/spinlock.h
rb50b5af2 r04803bf 36 36 #define KERN_SPINLOCK_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <arch/barrier.h> 40 40 #include <preemption.h> 41 41 #include <atomic.h> 42 42 #include <debug.h> 43 #include <arch/asm.h> 43 44 44 45 #ifdef CONFIG_SMP … … 48 49 49 50 #ifdef CONFIG_DEBUG_SPINLOCK 50 c har *name;51 #endif 51 const char *name; 52 #endif /* CONFIG_DEBUG_SPINLOCK */ 52 53 } spinlock_t; 53 54 … … 60 61 61 62 /* 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. 64 66 */ 65 67 #ifdef CONFIG_DEBUG_SPINLOCK … … 77 79 } 78 80 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 */ 82 88 83 89 #define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \ … … 91 97 } 92 98 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 */ 96 106 97 107 #define SPINLOCK_INITIALIZE(lock_name) \ … … 101 111 SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name) 102 112 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); 113 extern void spinlock_initialize(spinlock_t *, const char *); 114 extern int spinlock_trylock(spinlock_t *); 115 extern void spinlock_lock_debug(spinlock_t *); 116 extern void spinlock_unlock_debug(spinlock_t *); 117 extern bool spinlock_locked(spinlock_t *); 106 118 107 119 /** Unlock spinlock 108 120 * 109 * Unlock spinlock .121 * Unlock spinlock for non-debug kernels. 110 122 * 111 123 * @param sl Pointer to spinlock_t structure. 112 */ 113 static inline void spinlock_unlock(spinlock_t *lock) 124 * 125 */ 126 NO_TRACE static inline void spinlock_unlock_nondebug(spinlock_t *lock) 114 127 { 115 ASSERT(atomic_get(&lock->val) != 0);116 117 128 /* 118 129 * Prevent critical section code from bleeding out this way down. … … 135 146 if ((pname)++ > (value)) { \ 136 147 (pname) = 0; \ 137 printf("Deadlock probe %s: exceeded threshold %u\n" ,\148 printf("Deadlock probe %s: exceeded threshold %u\n" \ 138 149 "cpu%u: function=%s, line=%u\n", \ 139 150 #pname, (value), CPU->id, __func__, __LINE__); \ 140 151 } 141 152 142 #else 153 #else /* CONFIG_DEBUG_SPINLOCK */ 143 154 144 155 #define DEADLOCK_PROBE_INIT(pname) 145 156 #define DEADLOCK_PROBE(pname, value) 146 157 147 #endif 158 #endif /* CONFIG_DEBUG_SPINLOCK */ 148 159 149 160 #else /* CONFIG_SMP */ … … 159 170 #define SPINLOCK_INITIALIZE_NAME(name, desc_name) 160 171 #define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name) 172 173 #define ASSERT_SPINLOCK(expr, lock) ASSERT(expr) 161 174 162 175 #define spinlock_initialize(lock, name) … … 165 178 #define spinlock_trylock(lock) (preemption_disable(), 1) 166 179 #define spinlock_unlock(lock) preemption_enable() 180 #define spinlock_locked(lock) 1 181 #define spinlock_unlocked(lock) 1 167 182 168 183 #define DEADLOCK_PROBE_INIT(pname) 169 184 #define DEADLOCK_PROBE(pname, value) 170 185 186 #endif /* CONFIG_SMP */ 187 188 typedef 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 282 extern void irq_spinlock_initialize(irq_spinlock_t *, const char *); 283 extern void irq_spinlock_lock(irq_spinlock_t *, bool); 284 extern void irq_spinlock_unlock(irq_spinlock_t *, bool); 285 extern int irq_spinlock_trylock(irq_spinlock_t *); 286 extern void irq_spinlock_pass(irq_spinlock_t *, irq_spinlock_t *); 287 extern void irq_spinlock_exchange(irq_spinlock_t *, irq_spinlock_t *); 288 extern bool irq_spinlock_locked(irq_spinlock_t *); 289 171 290 #endif 172 291 173 #endif174 175 292 /** @} 176 293 */ -
kernel/generic/include/synch/waitq.h
rb50b5af2 r04803bf 36 36 #define KERN_WAITQ_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/spinlock.h> 40 40 #include <synch/synch.h> … … 46 46 } wakeup_mode_t; 47 47 48 /** Wait queue structure. */ 48 /** Wait queue structure. 49 * 50 */ 49 51 typedef struct { 50 51 52 /** Lock protecting wait queue structure. 52 53 * 53 54 * Must be acquired before T.lock for each T of type thread_t. 54 55 */ 55 SPINLOCK_DECLARE(lock);56 56 IRQ_SPINLOCK_DECLARE(lock); 57 57 58 /** 58 59 * Number of waitq_wakeup() calls that didn't find a thread to wake up. 60 * 59 61 */ 60 62 int missed_wakeups; 63 61 64 /** List of sleeping threads for wich there was no missed_wakeup. */ 62 65 link_t head; … … 69 72 70 73 extern void waitq_initialize(waitq_t *); 71 extern int waitq_sleep_timeout(waitq_t *, uint32_t, int);74 extern int waitq_sleep_timeout(waitq_t *, uint32_t, unsigned int); 72 75 extern ipl_t waitq_sleep_prepare(waitq_t *); 73 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int);76 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, unsigned int); 74 77 extern void waitq_sleep_finish(waitq_t *, int, ipl_t); 75 78 extern void waitq_wakeup(waitq_t *, wakeup_mode_t); … … 77 80 extern void waitq_interrupt_sleep(struct thread *); 78 81 extern void waitq_unsleep(waitq_t *); 82 extern int waitq_count_get(waitq_t *); 83 extern void waitq_count_set(waitq_t *, int val); 79 84 80 85 #endif -
kernel/generic/include/syscall/copy.h
rb50b5af2 r04803bf 36 36 #define KERN_COPY_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 /** Label within memcpy_from_uspace() that contains return -1. */ -
kernel/generic/include/syscall/syscall.h
rb50b5af2 r04803bf 38 38 typedef enum { 39 39 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) */ 41 41 42 42 SYS_THREAD_CREATE, 43 43 SYS_THREAD_EXIT, 44 44 SYS_THREAD_GET_ID, 45 SYS_THREAD_USLEEP, 45 46 46 47 SYS_TASK_GET_ID, 47 48 SYS_TASK_SET_NAME, 49 SYS_TASK_KILL, 50 SYS_TASK_EXIT, 48 51 SYS_PROGRAM_SPAWN_LOADER, 49 52 … … 56 59 SYS_AS_AREA_CHANGE_FLAGS, 57 60 SYS_AS_AREA_DESTROY, 61 SYS_AS_GET_UNMAPPED_AREA, 58 62 59 63 SYS_IPC_CALL_SYNC_FAST, … … 68 72 SYS_IPC_POKE, 69 73 SYS_IPC_HANGUP, 70 SYS_IPC_REGISTER_IRQ, 71 SYS_IPC_UNREGISTER_IRQ, 72 74 SYS_IPC_CONNECT_KBOX, 75 73 76 SYS_EVENT_SUBSCRIBE, 74 77 … … 79 82 SYS_PHYSMEM_MAP, 80 83 SYS_IOSPACE_ENABLE, 81 SYS_PREEMPT_CONTROL, 84 SYS_REGISTER_IRQ, 85 SYS_UNREGISTER_IRQ, 82 86 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 86 92 SYS_DEBUG_PUTINT, 87 93 SYS_DEBUG_ENABLE_CONSOLE, 88 94 SYS_DEBUG_DISABLE_CONSOLE, 89 SYS_IPC_CONNECT_KBOX,95 90 96 SYSCALL_END 91 97 } syscall_t; … … 93 99 #ifdef KERNEL 94 100 95 #include < arch/types.h>101 #include <typedefs.h> 96 102 97 typedef unative_t (*syshandler_t)(unative_t, unative_t, unative_t, unative_t,98 unative_t, unative_t);103 typedef sysarg_t (*syshandler_t)(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 104 sysarg_t, sysarg_t); 99 105 100 106 extern 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);107 extern sysarg_t syscall_handler(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 108 sysarg_t, sysarg_t, sysarg_t); 109 extern sysarg_t sys_tls_set(sysarg_t); 104 110 105 111 #endif -
kernel/generic/include/sysinfo/sysinfo.h
rb50b5af2 r04803bf 36 36 #define KERN_SYSINFO_H_ 37 37 38 #include < arch/types.h>39 #include <str ing.h>38 #include <typedefs.h> 39 #include <str.h> 40 40 41 /** Framebuffer info exported flags */ 41 42 extern bool fb_exported; 42 43 43 typedef union sysinfo_item_val { 44 unative_t val; 45 void *fn; 44 /** Item value type 45 * 46 */ 47 typedef 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 */ 58 typedef 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 64 struct sysinfo_item; 65 66 /** Gerated numeric value function */ 67 typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *); 68 69 /** Generated binary data function */ 70 typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool); 71 72 /** Sysinfo item binary data 73 * 74 */ 75 typedef struct { 76 void *data; /**< Data */ 77 size_t size; /**< Size (bytes) */ 78 } sysinfo_data_t; 79 80 /** Sysinfo item value (union) 81 * 82 */ 83 typedef 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 */ 46 88 } sysinfo_item_val_t; 47 89 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 */ 98 typedef 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 */ 107 typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool); 108 109 /** Sysinfo subtree (union) 110 * 111 */ 112 typedef 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 */ 48 120 typedef 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 */ 63 130 } sysinfo_item_t; 64 131 65 #define SYSINFO_VAL_VAL 0 66 #define SYSINFO_VAL_FUNCTION 1 67 #define SYSINFO_VAL_UNDEFINED U_SPECIAL 132 extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t); 133 extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *, 134 size_t); 135 extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **, 136 sysinfo_fn_val_t); 137 extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **, 138 sysinfo_fn_data_t); 139 extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **); 68 140 69 #define SYSINFO_SUBINFO_NONE 0 70 #define SYSINFO_SUBINFO_TABLE 1 71 #define SYSINFO_SUBINFO_FUNCTION 2 141 extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **, 142 sysinfo_fn_subtree_t); 72 143 73 typedef unative_t (*sysinfo_val_fn_t)(sysinfo_item_t *root);74 typedef unative_t (*sysinfo_subinfo_fn_t)(const char *subname);144 extern void sysinfo_init(void); 145 extern void sysinfo_dump(sysinfo_item_t *); 75 146 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); 147 extern sysarg_t sys_sysinfo_get_tag(void *, size_t); 148 extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *); 149 extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *); 150 extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *); 90 151 91 152 #endif -
kernel/generic/include/time/clock.h
rb50b5af2 r04803bf 36 36 #define KERN_CLOCK_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 #define HZ 10040 #define HZ 100 41 41 42 42 /** Uptime structure */ 43 43 typedef 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; 47 47 } uptime_t; 48 48 -
kernel/generic/include/time/delay.h
rb50b5af2 r04803bf 36 36 #define KERN_DELAY_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 extern void delay(uint32_t microseconds); -
kernel/generic/include/time/timeout.h
rb50b5af2 r04803bf 36 36 #define KERN_TIMEOUT_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <adt/list.h> 40 40 #include <cpu.h> … … 43 43 44 44 typedef struct { 45 SPINLOCK_DECLARE(lock);46 45 IRQ_SPINLOCK_DECLARE(lock); 46 47 47 /** Link to the list of active timeouts on THE->cpu */ 48 48 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. */ 50 50 uint64_t ticks; 51 51 /** Function that will be called on timeout activation. */ … … 57 57 } timeout_t; 58 58 59 #define us2ticks(us) ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))59 #define us2ticks(us) ((uint64_t) (((uint32_t) (us) / (1000000 / HZ)))) 60 60 61 61 extern 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); 62 extern void timeout_initialize(timeout_t *); 63 extern void timeout_reinitialize(timeout_t *); 64 extern void timeout_register(timeout_t *, uint64_t, timeout_handler_t, void *); 65 extern bool timeout_unregister(timeout_t *); 67 66 68 67 #endif -
kernel/generic/include/typedefs.h
rb50b5af2 r04803bf 36 36 #define KERN_TYPEDEFS_H_ 37 37 38 #include <stdint.h> 39 #include <arch/common.h> 38 40 #include <arch/types.h> 39 41 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 47 typedef struct { 48 uint64_t lo; 49 int64_t hi; 50 } int128_t; 51 52 typedef struct { 53 uint64_t lo; 54 uint64_t hi; 55 } uint128_t; 56 57 typedef struct { 58 volatile atomic_count_t count; 59 } atomic_t; 43 60 44 61 typedef void (* function)(); … … 52 69 typedef int32_t devno_t; 53 70 54 typedef int32_t wchar_t;55 56 71 typedef volatile uint8_t ioport8_t; 57 72 typedef volatile uint16_t ioport16_t; 58 73 typedef volatile uint32_t ioport32_t; 74 75 #ifdef __32_BITS__ 76 77 /** Explicit 64-bit arguments passed to syscalls. */ 78 typedef uint64_t sysarg64_t; 79 80 #endif /* __32_BITS__ */ 59 81 60 82 #endif -
kernel/generic/include/udebug/udebug.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_UDEBUG_H_ 37 37 38 #define UDEBUG_EVMASK(event) (1 << ((event) - 1)) 39 40 typedef 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 156 typedef 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 165 typedef 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 38 183 #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 they44 * 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 dies59 * 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 stops65 * in a debugging event.66 *67 * - ARG2 - id of the thread to run68 */69 UDEBUG_M_GO,70 71 /** Stop a thread being debugged.72 * Creates a special STOP event in the thread, causing73 * 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 identification80 * - ARG3 - destination address in the caller's address space81 *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 space88 * - ARG3 - size of receiving buffer in bytes89 *90 * The kernel fills the buffer with a series of sysarg_t values91 * (thread ids). On answer, the kernel will set:92 *93 * - ARG2 - number of bytes that were actually copied94 * - ARG3 - number of bytes of the complete data95 *96 */97 UDEBUG_M_THREAD_READ,98 99 /** Read the debugged tasks's memory.100 *101 * - ARG2 - destination address in the caller's address space102 * - ARG3 - source address in the recipient's address space103 * - ARG4 - size of receiving buffer in bytes104 *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 KERNEL139 140 184 #include <synch/mutex.h> 185 #include <synch/condvar.h> 141 186 #include <arch/interrupt.h> 142 187 #include <atomic.h> … … 157 202 mutex_t lock; 158 203 char *lock_owner; 159 204 160 205 udebug_task_state_t dt_state; 161 206 call_t *begin_call; … … 170 215 /** Synchronize debug ops on this thread / access to this structure. */ 171 216 mutex_t lock; 172 217 173 218 waitq_t go_wq; 174 219 call_t *go_call; 175 unative_t syscall_args[6];220 sysarg_t syscall_args[6]; 176 221 istate_t *uspace_state; 177 222 178 223 /** What type of event are we stopped in or 0 if none. */ 179 224 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; 183 229 } udebug_thread_t; 184 230 … … 186 232 struct thread; 187 233 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); 234 void udebug_task_init(udebug_task_t *); 235 void udebug_thread_initialize(udebug_thread_t *); 236 237 void udebug_syscall_event(sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 238 sysarg_t, sysarg_t, sysarg_t, bool); 239 240 void udebug_thread_b_event_attach(struct thread *, struct task *); 196 241 void udebug_thread_e_event(void); 197 242 … … 201 246 void udebug_before_thread_runs(void); 202 247 203 int udebug_task_cleanup(struct task *ta); 248 int udebug_task_cleanup(struct task *); 249 void udebug_thread_fault(void); 204 250 205 251 #endif -
kernel/generic/include/udebug/udebug_ipc.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 41 41 void udebug_call_receive(call_t *call); 42 42 43 44 43 #endif 45 44 -
kernel/generic/include/udebug/udebug_ops.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 45 45 int udebug_stop(thread_t *t, call_t *call); 46 46 47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *n); 47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored, 48 size_t *needed); 49 int udebug_name_read(char **data, size_t *data_size); 48 50 int udebug_args_read(thread_t *t, void **buffer); 49 51 50 int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer); 52 int udebug_regs_read(thread_t *t, void **buffer); 53 54 int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer); 51 55 52 56 #endif -
kernel/generic/include/userspace.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <proc/thread.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 /** Switch to user-space (CPU user priviledge level) */
Note:
See TracChangeset
for help on using the changeset viewer.
