Changeset 46c20c8 in mainline for kernel/generic/include
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (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:
-
- 4 added
- 70 edited
- 2 moved
-
adt/avl.h (modified) (3 diffs)
-
adt/bitmap.h (modified) (1 diff)
-
adt/btree.h (modified) (1 diff)
-
adt/hash_table.h (modified) (1 diff)
-
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) (1 diff)
-
console/kconsole.h (modified) (2 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) (13 diffs)
-
debug.h (modified) (3 diffs)
-
func.h (modified) (3 diffs)
-
interrupt.h (modified) (2 diffs)
-
ipc/event.h (modified) (1 diff)
-
ipc/ipc.h (modified) (13 diffs)
-
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) (19 diffs)
-
mm/buddy.h (modified) (1 diff)
-
mm/frame.h (modified) (7 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) (1 diff)
-
proc/program.h (modified) (2 diffs)
-
proc/scheduler.h (modified) (2 diffs)
-
proc/task.h (modified) (7 diffs)
-
proc/thread.h (modified) (15 diffs)
-
security/cap.h (modified) (4 diffs)
-
smp/ipi.h (modified) (2 diffs)
-
smp/smp.h (modified) (2 diffs)
-
sort.h (modified) (2 diffs)
-
stacktrace.h (modified) (4 diffs)
-
stdint.h (added)
-
str.h (moved) (moved from kernel/generic/include/string.h ) (3 diffs)
-
symtab.h (modified) (3 diffs)
-
synch/condvar.h (modified) (1 diff)
-
synch/futex.h (modified) (1 diff)
-
synch/mutex.h (modified) (2 diffs)
-
synch/semaphore.h (modified) (2 diffs)
-
synch/spinlock.h (modified) (9 diffs)
-
synch/waitq.h (modified) (4 diffs)
-
syscall/copy.h (modified) (1 diff)
-
syscall/sysarg64.h (modified) (1 diff)
-
syscall/syscall.h (modified) (3 diffs)
-
sysinfo/abi.h (added)
-
sysinfo/stats.h (moved) (moved from kernel/arch/abs32le/include/debug.h ) (2 diffs)
-
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_ipc.h (modified) (2 diffs)
-
udebug/udebug_ops.h (modified) (1 diff)
-
userspace.h (modified) (2 diffs)
-
verify.h (added)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/avl.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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. */ -
kernel/generic/include/adt/list.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 41 41 #include <mm/as.h> 42 42 43 #define DEFAULT_CONTEXT 043 #define DEFAULT_CONTEXT 0 44 44 45 #define CPU THE->cpu46 #define THREAD THE->thread47 #define TASK THE->task48 #define AS THE->as49 #define CONTEXT (THE->task ? THE->task->context : DEFAULT_CONTEXT)50 #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 51 51 52 #define context_check(ctx1, ctx2) ((ctx1) == (ctx2))52 #define context_check(ctx1, ctx2) ((ctx1) == (ctx2)) 53 53 54 54 /** … … 58 58 */ 59 59 typedef struct { 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. */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. */ 65 65 } the_t; 66 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 */ 67 73 #define THE ((the_t * )(get_stack_base())) 68 74 69 extern void the_initialize(the_t * the);70 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 *); 71 77 72 78 extern void arch_pre_mm_init(void); … … 80 86 extern void reboot(void); 81 87 extern void arch_reboot(void); 82 extern void *arch_construct_function(fncptr_t * fptr, void *addr, void *caller);88 extern void *arch_construct_function(fncptr_t *, void *, void *); 83 89 84 90 #endif -
kernel/generic/include/atomic.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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); -
kernel/generic/include/console/kconsole.h
rfb150d78 r46c20c8 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 … … 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
rfb150d78 r46c20c8 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 … … 87 88 * 88 89 * @param ctx Context structure. 90 * 89 91 */ 90 static inline void context_restore(context_t *ctx)92 NO_TRACE static inline void context_restore(context_t *ctx) 91 93 { 92 94 context_restore_arch(ctx); -
kernel/generic/include/cpu.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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> … … 50 50 51 51 extern void ddi_init(void); 52 extern void ddi_parea_register(parea_t * parea);52 extern void ddi_parea_register(parea_t *); 53 53 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); 54 extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t); 55 extern unative_t sys_iospace_enable(ddi_ioarg_t *); 56 extern unative_t sys_interrupt_enable(int irq, int enable); 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); 62 63 63 64 64 #endif -
kernel/generic/include/ddi/ddi_arg.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 36 36 #define KERN_DEVICE_H_ 37 37 38 #include <arch/types.h>39 38 #include <typedefs.h> 40 39 -
kernel/generic/include/ddi/irq.h
rfb150d78 r46c20c8 35 35 #ifndef KERN_IRQ_H_ 36 36 #define KERN_IRQ_H_ 37 38 #ifdef KERNEL 39 40 #include <typedefs.h> 41 #include <adt/list.h> 42 #include <adt/hash_table.h> 43 #include <synch/spinlock.h> 44 #include <proc/task.h> 45 #include <ipc/ipc.h> 46 47 #endif /* KERNEL */ 37 48 38 49 typedef enum { … … 49 60 /** Write 4 bytes to the I/O space. */ 50 61 CMD_PIO_WRITE_32, 62 51 63 /** 52 64 * Perform a bit test on the source argument and store the result into … … 54 66 */ 55 67 CMD_BTEST, 68 56 69 /** 57 70 * Predicate the execution of the following N commands by the boolean … … 59 72 */ 60 73 CMD_PREDICATE, 74 61 75 /** Accept the interrupt. */ 62 76 CMD_ACCEPT, … … 69 83 irq_cmd_type cmd; 70 84 void *addr; 71 u nsigned long longvalue;72 u nsigned int srcarg;73 u nsigned int dstarg;85 uint32_t value; 86 uintptr_t srcarg; 87 uintptr_t dstarg; 74 88 } irq_cmd_t; 75 89 76 90 typedef struct { 77 unsigned int cmdcount;91 size_t cmdcount; 78 92 irq_cmd_t *cmds; 79 93 } irq_code_t; … … 81 95 #ifdef KERNEL 82 96 83 #include <arch/types.h>84 #include <adt/list.h>85 #include <adt/hash_table.h>86 #include <synch/spinlock.h>87 #include <proc/task.h>88 #include <ipc/ipc.h>89 90 97 typedef enum { 91 IRQ_DECLINE, /**< Decline to service. */92 IRQ_ACCEPT /**< Accept to service. */98 IRQ_DECLINE, /**< Decline to service. */ 99 IRQ_ACCEPT /**< Accept to service. */ 93 100 } irq_ownership_t; 94 101 … … 108 115 * Primarily, this structure is encapsulated in the irq_t structure. 109 116 * It is protected by irq_t::lock. 117 * 110 118 */ 111 119 typedef struct { … … 117 125 unative_t method; 118 126 /** Arguments that will be sent if the IRQ is claimed. */ 119 u native_t scratch[IPC_CALL_LEN];127 uint32_t scratch[IPC_CALL_LEN]; 120 128 /** Top-half pseudocode. */ 121 129 irq_code_t *code; 122 130 /** Counter. */ 123 131 size_t counter; 132 124 133 /** 125 134 * Link between IRQs that are notifying the same answerbox. The list is … … 133 142 * If one device has multiple interrupts, there will be multiple irq_t 134 143 * instantions with the same devno. 144 * 135 145 */ 136 146 typedef struct irq { 137 147 /** Hash table link. */ 138 148 link_t link; 139 149 140 150 /** Lock protecting everything in this structure 141 151 * except the link member. When both the IRQ … … 143 153 * this lock must not be taken first. 144 154 */ 145 SPINLOCK_DECLARE(lock);155 IRQ_SPINLOCK_DECLARE(lock); 146 156 147 157 /** Send EOI before processing the interrupt. … … 152 162 */ 153 163 bool preack; 154 164 155 165 /** Unique device number. -1 if not yet assigned. */ 156 166 devno_t devno; 157 167 158 168 /** Actual IRQ number. -1 if not yet assigned. */ 159 169 inr_t inr; … … 166 176 /** Instance argument for the handler and the claim function. */ 167 177 void *instance; 168 178 169 179 /** Clear interrupt routine. */ 170 180 cir_t cir; 171 181 /** First argument to the clear interrupt routine. */ 172 182 void *cir_arg; 173 183 174 184 /** Notification configuration structure. */ 175 185 ipc_notif_cfg_t notif_cfg; 176 186 } irq_t; 177 187 178 SPINLOCK_EXTERN(irq_uspace_hash_table_lock);188 IRQ_SPINLOCK_EXTERN(irq_uspace_hash_table_lock); 179 189 extern hash_table_t irq_uspace_hash_table; 180 190 … … 184 194 extern irq_t *irq_dispatch_and_lock(inr_t); 185 195 196 #endif /* KERNEL */ 197 186 198 #endif 187 199 188 #endif189 190 200 /** @} 191 201 */ -
kernel/generic/include/debug.h
rfb150d78 r46c20c8 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", #expr); \ 58 } while (0) 59 60 /** Debugging verbose ASSERT macro 61 * 62 * If CONFIG_DEBUG is set, the ASSERT() macro 63 * evaluates expr and if it is false raises 64 * kernel panic. The panic message contains also 65 * the supplied message. 66 * 67 * @param expr Expression which is expected to be true. 68 * @param msg Additional message to show (string). 69 * 70 */ 71 #define ASSERT_VERBOSE(expr, msg) \ 72 do { \ 73 if (!(expr)) \ 74 panic_assert("%s, %s", #expr, msg); \ 75 } while (0) 76 77 #else /* CONFIG_DEBUG */ 78 79 #define ASSERT(expr) 80 #define ASSERT_VERBOSE(expr, msg) 81 82 #endif /* CONFIG_DEBUG */ 83 84 #ifdef CONFIG_LOG 65 85 66 86 /** Extensive logging output macro … … 71 91 * 72 92 */ 93 #define LOG(format, ...) \ 94 do { \ 95 printf("%s() from %s at %s:%u: " format "\n", __func__, \ 96 symtab_fmt_name_lookup(CALLER), __FILE__, __LINE__, \ 97 ##__VA_ARGS__); \ 98 } while (0) 73 99 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 100 #else /* CONFIG_LOG */ 81 101 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 */ 102 #define LOG(format, ...) 89 103 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 104 #endif /* CONFIG_LOG */ 100 105 106 #ifdef CONFIG_TRACE 107 108 extern void __cyg_profile_func_enter(void *, void *); 109 extern void __cyg_profile_func_exit(void *, void *); 110 111 #endif /* CONFIG_TRACE */ 101 112 102 113 #endif -
kernel/generic/include/func.h
rfb150d78 r46c20c8 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 … … 42 42 43 43 extern void halt(void) __attribute__((noreturn)); 44 extern unative_t atoi(const char *text);45 extern void order(const uint64_t val, uint64_t *rv, char *suffix);46 44 47 45 #endif -
kernel/generic/include/interrupt.h
rfb150d78 r46c20c8 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> … … 44 45 #include <stacktrace.h> 45 46 46 typedef void (* iroutine )(int n, istate_t *istate);47 typedef void (* iroutine_t)(unsigned int, istate_t *); 47 48 48 extern void fault_if_from_uspace(istate_t *istate, char *fmt, ...); 49 extern iroutine exc_register(int n, const char *name, iroutine f); 50 extern void exc_dispatch(int n, istate_t *t); 51 void exc_init(void); 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; 52 56 53 extern void irq_initialize_arch(irq_t *irq); 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 iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t); 63 extern void exc_dispatch(unsigned int, istate_t *); 64 extern void exc_init(void); 65 66 extern void irq_initialize_arch(irq_t *); 67 68 extern void istate_decode(istate_t *); 54 69 55 70 #endif -
kernel/generic/include/ipc/event.h
rfb150d78 r46c20c8 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> -
kernel/generic/include/ipc/ipc.h
rfb150d78 r46c20c8 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 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 41 44 42 45 /** Maximum active async calls per thread */ 43 46 #ifdef CONFIG_DEBUG 44 #define IPC_MAX_ASYNC_CALLS447 #define IPC_MAX_ASYNC_CALLS 4 45 48 #else 46 #define IPC_MAX_ASYNC_CALLS400049 #define IPC_MAX_ASYNC_CALLS 4000 47 50 #endif 48 51 … … 50 53 51 54 /** This is answer to a call */ 52 #define IPC_CALL_ANSWERED (1 << 0) 55 #define IPC_CALL_ANSWERED (1 << 0) 56 53 57 /** Answer will not be passed to userspace, will be discarded */ 54 #define IPC_CALL_DISCARD_ANSWER (1 << 1) 58 #define IPC_CALL_DISCARD_ANSWER (1 << 1) 59 55 60 /** Call was forwarded */ 56 #define IPC_CALL_FORWARDED (1 << 2) 61 #define IPC_CALL_FORWARDED (1 << 2) 62 57 63 /** Identify connect_me_to answer */ 58 #define IPC_CALL_CONN_ME_TO (1 << 3) 64 #define IPC_CALL_CONN_ME_TO (1 << 3) 65 59 66 /** Interrupt notification */ 60 #define IPC_CALL_NOTIF (1 << 4) 61 62 /* 63 * Bits used in call hashes. 67 #define IPC_CALL_NOTIF (1 << 4) 68 69 70 /** Bits used in call hashes. 71 * 64 72 * The addresses are aligned at least to 4 that is why we can use the 2 least 65 73 * significant bits of the call address. 66 */ 74 * 75 */ 76 67 77 /** Type of this call is 'answer' */ 68 #define IPC_CALLID_ANSWERED 1 78 #define IPC_CALLID_ANSWERED 1 79 69 80 /** Type of this call is 'notification' */ 70 #define IPC_CALLID_NOTIFICATION 281 #define IPC_CALLID_NOTIFICATION 2 71 82 72 83 /* Return values from sys_ipc_call_async(). */ 73 #define IPC_CALLRET_FATAL -174 #define IPC_CALLRET_TEMPORARY -284 #define IPC_CALLRET_FATAL -1 85 #define IPC_CALLRET_TEMPORARY -2 75 86 76 87 77 88 /* Macros for manipulating calling data */ 78 #define IPC_SET_RETVAL(data, retval) ((data).args[0] = (retval))79 #define IPC_SET_METHOD(data, val) ((data).args[0] = (val))80 #define IPC_SET_ARG1(data, val) ((data).args[1] = (val))81 #define IPC_SET_ARG2(data, val) ((data).args[2] = (val))82 #define IPC_SET_ARG3(data, val) ((data).args[3] = (val))83 #define IPC_SET_ARG4(data, val) ((data).args[4] = (val))84 #define IPC_SET_ARG5(data, val) ((data).args[5] = (val))85 86 #define IPC_GET_METHOD(data) ((data).args[0])87 #define IPC_GET_RETVAL(data) ((data).args[0])88 89 #define IPC_GET_ARG1(data) ((data).args[1])90 #define IPC_GET_ARG2(data) ((data).args[2])91 #define IPC_GET_ARG3(data) ((data).args[3])92 #define IPC_GET_ARG4(data) ((data).args[4])93 #define IPC_GET_ARG5(data) ((data).args[5])89 #define IPC_SET_RETVAL(data, retval) ((data).args[0] = (retval)) 90 #define IPC_SET_METHOD(data, val) ((data).args[0] = (val)) 91 #define IPC_SET_ARG1(data, val) ((data).args[1] = (val)) 92 #define IPC_SET_ARG2(data, val) ((data).args[2] = (val)) 93 #define IPC_SET_ARG3(data, val) ((data).args[3] = (val)) 94 #define IPC_SET_ARG4(data, val) ((data).args[4] = (val)) 95 #define IPC_SET_ARG5(data, val) ((data).args[5] = (val)) 96 97 #define IPC_GET_METHOD(data) ((data).args[0]) 98 #define IPC_GET_RETVAL(data) ((data).args[0]) 99 100 #define IPC_GET_ARG1(data) ((data).args[1]) 101 #define IPC_GET_ARG2(data) ((data).args[2]) 102 #define IPC_GET_ARG3(data) ((data).args[3]) 103 #define IPC_GET_ARG4(data) ((data).args[4]) 104 #define IPC_GET_ARG5(data) ((data).args[5]) 94 105 95 106 /* Well known phone descriptors */ 96 #define PHONE_NS 0107 #define PHONE_NS 0 97 108 98 109 /* Forwarding flags. */ 99 #define IPC_FF_NONE 0 110 #define IPC_FF_NONE 0 111 100 112 /** 101 113 * The call will be routed as though it was initially sent via the phone used to … … 104 116 * calls that were initially sent by the forwarder to the same destination. This 105 117 * flag has no imapct on routing replies. 106 */ 107 #define IPC_FF_ROUTE_FROM_ME (1 << 0) 108 109 /* System-specific methods - only through special syscalls 118 * 119 */ 120 #define IPC_FF_ROUTE_FROM_ME (1 << 0) 121 122 /** System-specific methods - only through special syscalls 110 123 * These methods have special behaviour 111 */ 124 * 125 */ 126 112 127 /** Clone connection. 113 128 * … … 115 130 * 116 131 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection. 117 * - The callee gets the new phone from ARG1. 132 * - The callee gets the new phone from ARG1. 133 * 118 134 * - on answer, the callee acknowledges the new connection by sending EOK back 119 135 * or the kernel closes it 120 */ 121 #define IPC_M_CONNECTION_CLONE 1 136 * 137 */ 138 #define IPC_M_CONNECTION_CLONE 1 139 122 140 /** Protocol for CONNECT - ME 123 141 * 124 142 * Through this call, the recipient learns about the new cloned connection. 125 * 143 * 126 144 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone 127 145 * - on asnwer, the callee acknowledges the new connection by sending EOK back 128 146 * or the kernel closes it 129 */ 130 #define IPC_M_CONNECT_ME 2 131 /** Protocol for CONNECT - TO - ME 147 * 148 */ 149 #define IPC_M_CONNECT_ME 2 150 151 /** Protocol for CONNECT - TO - ME 132 152 * 133 153 * Calling process asks the callee to create a callback connection, … … 144 164 * - the allocated phoneid is passed to userspace 145 165 * (on the receiving side) as ARG5 of the call. 146 */ 147 #define IPC_M_CONNECT_TO_ME 3 166 * 167 */ 168 #define IPC_M_CONNECT_TO_ME 3 169 148 170 /** Protocol for CONNECT - ME - TO 149 171 * … … 163 185 * 164 186 */ 165 #define IPC_M_CONNECT_ME_TO 4 166 /** This message is sent to answerbox when the phone 167 * is hung up 168 */ 169 #define IPC_M_PHONE_HUNGUP 5 187 #define IPC_M_CONNECT_ME_TO 4 188 189 /** This message is sent to answerbox when the phone is hung up 190 * 191 */ 192 #define IPC_M_PHONE_HUNGUP 5 170 193 171 194 /** Send as_area over IPC. … … 173 196 * - ARG2 - size of source as_area (filled automatically by kernel) 174 197 * - ARG3 - flags of the as_area being sent 175 * 198 * 176 199 * on answer, the recipient must set: 177 200 * - ARG1 - dst as_area base adress 178 */ 179 #define IPC_M_SHARE_OUT 6 201 * 202 */ 203 #define IPC_M_SHARE_OUT 6 180 204 181 205 /** Receive as_area over IPC. … … 183 207 * - ARG2 - destination as_area size 184 208 * - ARG3 - user defined argument 185 * 209 * 186 210 * on answer, the recipient must set: 187 211 * 188 212 * - ARG1 - source as_area base address 189 213 * - ARG2 - flags that will be used for sharing 190 */ 191 #define IPC_M_SHARE_IN 7 214 * 215 */ 216 #define IPC_M_SHARE_IN 7 192 217 193 218 /** Send data to another address space over IPC. … … 199 224 * - ARG1 - final destination address space virtual address 200 225 * - ARG2 - final size of data to be copied 201 */ 202 #define IPC_M_DATA_WRITE 8 226 * 227 */ 228 #define IPC_M_DATA_WRITE 8 203 229 204 230 /** Receive data from another address space over IPC. … … 210 236 * - ARG1 - source virtual address in the destination address space 211 237 * - ARG2 - final size of data to be copied 212 */ 213 #define IPC_M_DATA_READ 9 238 * 239 */ 240 #define IPC_M_DATA_READ 9 214 241 215 242 /** Debug the recipient. 216 243 * - ARG1 - specifies the debug method (from udebug_method_t) 217 244 * - other arguments are specific to the debug method 218 */ 219 #define IPC_M_DEBUG_ALL 10 245 * 246 */ 247 #define IPC_M_DEBUG_ALL 10 220 248 221 249 /* Well-known methods */ 222 #define IPC_M_LAST_SYSTEM 511 223 #define IPC_M_PING 512 250 #define IPC_M_LAST_SYSTEM 511 251 #define IPC_M_PING 512 252 224 253 /* User methods */ 225 #define IPC_FIRST_USER_METHOD 1024254 #define IPC_FIRST_USER_METHOD 1024 226 255 227 256 #ifdef KERNEL 228 257 229 #define IPC_MAX_PHONES 16258 #define IPC_MAX_PHONES 32 230 259 231 260 #include <synch/spinlock.h> … … 259 288 260 289 typedef struct answerbox { 261 SPINLOCK_DECLARE(lock);262 290 IRQ_SPINLOCK_DECLARE(lock); 291 263 292 struct task *task; 264 293 265 294 waitq_t wq; 266 295 267 296 /** Linkage for the list of task's synchronous answerboxes. */ 268 297 link_t sync_box_link; 269 298 270 299 /** Phones connected to this answerbox. */ 271 300 link_t connected_phones; 272 301 /** Received calls. */ 273 link_t calls; 274 link_t dispatched_calls; /* Should be hash table in the future */275 302 link_t calls; 303 link_t dispatched_calls; /* Should be hash table in the future */ 304 276 305 /** Answered calls. */ 277 306 link_t answers; 278 279 SPINLOCK_DECLARE(irq_lock); 307 308 IRQ_SPINLOCK_DECLARE(irq_lock); 309 280 310 /** Notifications from IRQ handlers. */ 281 311 link_t irq_notifs; … … 291 321 typedef struct { 292 322 link_t link; 293 294 int flags;295 323 324 unsigned int flags; 325 296 326 /** Identification of the caller. */ 297 327 struct task *sender; 298 /** The caller box is different from sender->answerbox for synchronous 299 * calls. */ 328 329 /* 330 * The caller box is different from sender->answerbox 331 * for synchronous calls. 332 * 333 */ 300 334 answerbox_t *callerbox; 301 335 302 336 /** Private data to internal IPC. */ 303 337 unative_t priv; 304 338 305 339 /** Data passed from/to userspace. */ 306 340 ipc_data_t data; 307 341 308 342 /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */ 309 343 uint8_t *buffer; 310 344 311 345 /* 312 346 * The forward operation can masquerade the caller phone. For those 313 347 * cases, we must keep it aside so that the answer is processed 314 348 * correctly. 349 * 315 350 */ 316 351 phone_t *caller_phone; 317 352 } call_t; 318 353 319 320 354 extern answerbox_t *ipc_phone_0; 321 355 322 323 356 extern void ipc_init(void); 324 357 325 extern call_t * ipc_call_alloc(int);358 extern call_t *ipc_call_alloc(unsigned int); 326 359 extern void ipc_call_free(call_t *); 327 360 328 361 extern int ipc_call(phone_t *, call_t *); 329 362 extern int ipc_call_sync(phone_t *, call_t *); 330 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int);331 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int);363 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int); 364 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int); 332 365 extern void ipc_answer(answerbox_t *, call_t *); 333 366 … … 345 378 extern void ipc_print_task(task_id_t); 346 379 380 #endif /* KERNEL */ 381 347 382 #endif 348 383 349 #endif350 351 384 /** @} 352 385 */ -
kernel/generic/include/ipc/irq.h
rfb150d78 r46c20c8 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 … … 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 77 extern void ipc_irq_send_msg(irq_t *, unative_t, unative_t, unative_t, unative_t, -
kernel/generic/include/ipc/sysipc.h
rfb150d78 r46c20c8 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,42 extern unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method, 43 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,44 extern unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question, 45 45 ipc_data_t *reply); 46 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,46 extern unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method, 47 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,48 extern unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data); 49 extern unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval, 50 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,51 extern unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data); 52 extern unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 53 unsigned int nonblocking); 54 extern unative_t sys_ipc_poke(void); 55 extern unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, 56 unative_t method, unative_t arg1, unative_t arg2, unsigned int mode); 57 extern unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid, 58 ipc_data_t *data, unsigned int mode); 59 extern unative_t sys_ipc_hangup(unative_t phoneid); 60 extern unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method, 61 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);62 extern unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno); 63 extern unative_t sys_ipc_connect_kbox(sysarg64_t *task_id); 64 64 65 65 #endif -
kernel/generic/include/lib/elf.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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 40 extern size_t hardcoded_kdata_size; -
kernel/generic/include/main/uinit.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 42 42 /** @} 43 43 */ 44 -
kernel/generic/include/memstr.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 37 37 38 38 #ifdef KERNEL 39 #include <arch/types.h>39 #include <typedefs.h> 40 40 #else 41 #include <sys/types.h>41 #include <sys/types.h> 42 42 #endif 43 43 44 44 /** Address space area flags. */ 45 #define AS_AREA_READ 146 #define AS_AREA_WRITE 247 #define AS_AREA_EXEC 448 #define AS_AREA_CACHEABLE 845 #define AS_AREA_READ 1 46 #define AS_AREA_WRITE 2 47 #define AS_AREA_EXEC 4 48 #define AS_AREA_CACHEABLE 8 49 49 50 50 /** Address space area info exported to userspace. */ … … 52 52 /** Starting address */ 53 53 uintptr_t start_addr; 54 54 55 55 /** Area size */ 56 56 size_t size; 57 57 58 58 /** Area flags */ 59 int flags;59 unsigned int flags; 60 60 } as_area_info_t; 61 61 … … 65 65 #include <arch/mm/as.h> 66 66 #include <arch/mm/asid.h> 67 #include < arch/types.h>67 #include <typedefs.h> 68 68 #include <synch/spinlock.h> 69 69 #include <synch/mutex.h> … … 75 75 * Defined to be true if user address space and kernel address space shadow each 76 76 * other. 77 */ 78 #define KERNEL_ADDRESS_SPACE_SHADOWED KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 79 80 #define KERNEL_ADDRESS_SPACE_START KERNEL_ADDRESS_SPACE_START_ARCH 81 #define KERNEL_ADDRESS_SPACE_END KERNEL_ADDRESS_SPACE_END_ARCH 82 #define USER_ADDRESS_SPACE_START USER_ADDRESS_SPACE_START_ARCH 83 #define USER_ADDRESS_SPACE_END USER_ADDRESS_SPACE_END_ARCH 84 85 #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 86 87 87 88 /** Kernel address space. */ 88 #define FLAG_AS_KERNEL (1 << 0)89 #define FLAG_AS_KERNEL (1 << 0) 89 90 90 91 /* Address space area attributes. */ 91 #define AS_AREA_ATTR_NONE 092 #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. */ 93 94 94 95 /** The page fault was not resolved by as_page_fault(). */ 95 #define AS_PF_FAULT 0 96 #define AS_PF_FAULT 0 97 96 98 /** The page fault was resolved by as_page_fault(). */ 97 #define AS_PF_OK 1 99 #define AS_PF_OK 1 100 98 101 /** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */ 99 #define AS_PF_DEFER 2102 #define AS_PF_DEFER 2 100 103 101 104 /** Address space structure. … … 105 108 * supposed to figure in the list as they are shared by all tasks and 106 109 * set up during system initialization. 110 * 107 111 */ 108 112 typedef struct as { 109 113 /** Protected by asidlock. */ 110 114 link_t inactive_as_with_asid_link; 115 111 116 /** 112 117 * Number of processors on wich is this address space active. … … 114 119 */ 115 120 size_t cpu_refcount; 121 116 122 /** 117 123 * Address space identifier. … … 120 126 */ 121 127 asid_t asid; 122 128 123 129 /** Number of references (i.e tasks that reference this as). */ 124 130 atomic_t refcount; 125 131 126 132 mutex_t lock; 127 133 128 134 /** B+tree of address space areas. */ 129 135 btree_t as_area_btree; … … 131 137 /** Non-generic content. */ 132 138 as_genarch_t genarch; 133 139 134 140 /** Architecture specific content. */ 135 141 as_arch_t arch; … … 137 143 138 144 typedef struct { 139 pte_t *(* page_table_create)(int flags); 140 void (* page_table_destroy)(pte_t *page_table); 141 void (* page_table_lock)(as_t *as, bool lock); 142 void (* page_table_unlock)(as_t *as, bool unlock); 145 pte_t *(* page_table_create)(unsigned int); 146 void (* page_table_destroy)(pte_t *); 147 void (* page_table_lock)(as_t *, bool); 148 void (* page_table_unlock)(as_t *, bool); 149 bool (* page_table_locked)(as_t *); 143 150 } as_operations_t; 144 151 … … 146 153 * This structure contains information associated with the shared address space 147 154 * area. 155 * 148 156 */ 149 157 typedef struct { 150 158 /** This lock must be acquired only when the as_area lock is held. */ 151 mutex_t lock; 159 mutex_t lock; 152 160 /** This structure can be deallocated if refcount drops to 0. */ 153 161 size_t refcount; 162 154 163 /** 155 164 * B+tree containing complete map of anonymous pages of the shared area. … … 162 171 PF_ACCESS_READ, 163 172 PF_ACCESS_WRITE, 164 PF_ACCESS_EXEC 173 PF_ACCESS_EXEC, 174 PF_ACCESS_UNKNOWN 165 175 } pf_access_t; 166 176 … … 169 179 /** Backend data stored in address space area. */ 170 180 typedef union mem_backend_data { 171 struct { /**< elf_backend members */ 181 /** elf_backend members */ 182 struct { 172 183 elf_header_t *elf; 173 184 elf_segment_header_t *segment; 174 185 }; 175 struct { /**< phys_backend members */ 186 187 /** phys_backend members */ 188 struct { 176 189 uintptr_t base; 177 190 size_t frames; … … 182 195 * 183 196 * Each as_area_t structure describes one contiguous area of virtual memory. 197 * 184 198 */ 185 199 typedef struct { 186 200 mutex_t lock; 187 201 /** Containing address space. */ 188 as_t *as; 202 as_t *as; 203 189 204 /** 190 205 * Flags related to the memory represented by the address space area. 191 206 */ 192 int flags; 207 unsigned int flags; 208 193 209 /** Attributes related to the address space area itself. */ 194 int attributes;210 unsigned int attributes; 195 211 /** Size of this area in multiples of PAGE_SIZE. */ 196 212 size_t pages; … … 199 215 /** Map of used space. */ 200 216 btree_t used_space; 201 217 202 218 /** 203 219 * If the address space area has been shared, this pointer will … … 205 221 */ 206 222 share_info_t *sh_info; 207 223 208 224 /** Memory backend backing this address space area. */ 209 225 struct mem_backend *backend; 210 226 211 227 /** Data to be used by the backend. */ 212 228 mem_backend_data_t backend_data; … … 215 231 /** Address space area backend structure. */ 216 232 typedef struct mem_backend { 217 int (* page_fault)(as_area_t * area, uintptr_t addr, pf_access_t access);218 void (* frame_free)(as_area_t * area, uintptr_t page, uintptr_t frame);219 void (* share)(as_area_t * area);233 int (* page_fault)(as_area_t *, uintptr_t, pf_access_t); 234 void (* frame_free)(as_area_t *, uintptr_t, uintptr_t); 235 void (* share)(as_area_t *); 220 236 } mem_backend_t; 221 237 … … 227 243 extern void as_init(void); 228 244 229 extern as_t *as_create(int flags); 230 extern void as_destroy(as_t *as); 231 extern void as_switch(as_t *old_as, as_t *new_as); 232 extern int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate); 233 234 extern as_area_t *as_area_create(as_t *as, int flags, size_t size, 235 uintptr_t base, int attrs, mem_backend_t *backend, 236 mem_backend_data_t *backend_data); 237 extern int as_area_destroy(as_t *as, uintptr_t address); 238 extern int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags); 239 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size, 240 as_t *dst_as, uintptr_t dst_base, int dst_flags_mask); 241 extern int as_area_change_flags(as_t *as, int flags, uintptr_t address); 242 243 extern int as_area_get_flags(as_area_t *area); 244 extern bool as_area_check_access(as_area_t *area, pf_access_t access); 245 extern size_t as_area_get_size(uintptr_t base); 246 extern int used_space_insert(as_area_t *a, uintptr_t page, size_t count); 247 extern int used_space_remove(as_area_t *a, uintptr_t page, size_t count); 245 extern as_t *as_create(unsigned int); 246 extern void as_destroy(as_t *); 247 extern void as_hold(as_t *); 248 extern void as_release(as_t *); 249 extern void as_switch(as_t *, as_t *); 250 extern int as_page_fault(uintptr_t, pf_access_t, istate_t *); 251 252 extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t, 253 unsigned int, mem_backend_t *, mem_backend_data_t *); 254 extern int as_area_destroy(as_t *, uintptr_t); 255 extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int); 256 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, 257 unsigned int); 258 extern int as_area_change_flags(as_t *, unsigned int, uintptr_t); 259 260 extern unsigned int as_area_get_flags(as_area_t *); 261 extern bool as_area_check_access(as_area_t *, pf_access_t); 262 extern size_t as_area_get_size(uintptr_t); 263 extern int used_space_insert(as_area_t *, uintptr_t, size_t); 264 extern int used_space_remove(as_area_t *, uintptr_t, size_t); 248 265 249 266 250 267 /* Interface to be implemented by architectures. */ 268 251 269 #ifndef as_constructor_arch 252 extern int as_constructor_arch(as_t * as, int flags);270 extern int as_constructor_arch(as_t *, unsigned int); 253 271 #endif /* !def as_constructor_arch */ 272 254 273 #ifndef as_destructor_arch 255 extern int as_destructor_arch(as_t * as);274 extern int as_destructor_arch(as_t *); 256 275 #endif /* !def as_destructor_arch */ 276 257 277 #ifndef as_create_arch 258 extern int as_create_arch(as_t * as, int flags);278 extern int as_create_arch(as_t *, unsigned int); 259 279 #endif /* !def as_create_arch */ 280 260 281 #ifndef as_install_arch 261 extern void as_install_arch(as_t * as);282 extern void as_install_arch(as_t *); 262 283 #endif /* !def as_install_arch */ 284 263 285 #ifndef as_deinstall_arch 264 extern void as_deinstall_arch(as_t * as);286 extern void as_deinstall_arch(as_t *); 265 287 #endif /* !def as_deinstall_arch */ 266 288 … … 270 292 extern mem_backend_t phys_backend; 271 293 272 /** 294 /** 273 295 * This flags is passed when running the loader, otherwise elf_load() 274 296 * would return with a EE_LOADER error code. 275 */ 276 #define ELD_F_NONE 0 277 #define ELD_F_LOADER 1 278 279 extern unsigned int elf_load(elf_header_t *header, as_t *as, int flags); 297 * 298 */ 299 #define ELD_F_NONE 0 300 #define ELD_F_LOADER 1 301 302 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int); 280 303 281 304 /* Address space area related syscalls. */ 282 extern unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);283 extern unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags);284 extern unative_t sys_as_area_change_flags(uintptr_t address, int flags);285 extern unative_t sys_as_area_destroy(uintptr_t address);305 extern unative_t sys_as_area_create(uintptr_t, size_t, unsigned int); 306 extern unative_t sys_as_area_resize(uintptr_t, size_t, unsigned int); 307 extern unative_t sys_as_area_change_flags(uintptr_t, unsigned int); 308 extern unative_t sys_as_area_destroy(uintptr_t); 286 309 287 310 /* Introspection functions. */ 288 extern void as_get_area_info(as_t * as, as_area_info_t **obuf, size_t *osize);289 extern void as_print(as_t * as);311 extern void as_get_area_info(as_t *, as_area_info_t **, size_t *); 312 extern void as_print(as_t *); 290 313 291 314 #endif /* KERNEL */ -
kernel/generic/include/mm/buddy.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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); … … 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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 #include < stacktrace.h>38 #include <typedefs.h> 39 39 #include <print.h> 40 40 41 #ifdef CONFIG_DEBUG 42 # define panic(format, ...) \ 43 do { \ 44 printf("Kernel panic in %s() at %s:%u.\n", \ 45 __func__, __FILE__, __LINE__); \ 46 stack_trace(); \ 47 panic_printf("Panic message: " format "\n", \ 48 ##__VA_ARGS__);\ 49 } while (0) 50 #else 51 # define panic(format, ...) \ 52 panic_printf("Kernel panic: " format "\n", ##__VA_ARGS__); 53 #endif 41 #define panic(fmt, ...) \ 42 panic_common(PANIC_OTHER, NULL, 0, 0, fmt, ##__VA_ARGS__) 54 43 55 extern void panic_printf(char *fmt, ...) __attribute__((noreturn)); 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); 56 67 57 68 #endif -
kernel/generic/include/preemption.h
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ -
kernel/generic/include/print.h
rfb150d78 r46c20c8 36 36 #define KERN_PRINT_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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 unative_t sys_program_spawn_loader(char *, size_t); 63 62 64 63 #endif -
kernel/generic/include/proc/scheduler.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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> … … 56 55 #include <ipc/kbox.h> 57 56 #include <mm/as.h> 58 59 #define TASK_NAME_BUFLEN 20 57 #include <sysinfo/abi.h> 60 58 61 59 struct thread; … … 71 69 * threads. 72 70 */ 73 SPINLOCK_DECLARE(lock);74 71 IRQ_SPINLOCK_DECLARE(lock); 72 75 73 char name[TASK_NAME_BUFLEN]; 76 74 /** List of threads contained in this task. */ … … 81 79 task_id_t taskid; 82 80 /** Task security context. */ 83 context_id_t context; 84 81 context_id_t context; 82 85 83 /** Number of references (i.e. threads). */ 86 84 atomic_t refcount; 87 85 /** Number of threads that haven't exited yet. */ 88 86 atomic_t lifecount; 89 87 90 88 /** Task capabilities. */ 91 cap_t capabilities; 92 89 cap_t capabilities; 90 93 91 /* IPC stuff */ 94 92 answerbox_t answerbox; /**< Communication endpoint */ 95 93 phone_t phones[IPC_MAX_PHONES]; 94 stats_ipc_t ipc_info; /**< IPC statistics */ 96 95 /** 97 96 * Active asynchronous messages. It is used for limiting uspace to … … 101 100 /** List of synchronous answerboxes. */ 102 101 link_t sync_box_head; 103 102 104 103 #ifdef CONFIG_UDEBUG 105 104 /** Debugging stuff. */ 106 105 udebug_task_t udebug; 107 106 108 107 /** Kernel answerbox. */ 109 108 kbox_t kb; 110 #endif 111 109 #endif /* CONFIG_UDEBUG */ 110 112 111 /** Architecture specific task data. */ 113 112 task_arch_t arch; … … 119 118 mutex_t futexes_lock; 120 119 /** B+tree of futexes referenced by this task. */ 121 btree_t futexes; 120 btree_t futexes; 122 121 123 122 /** Accumulated accounting. */ 124 uint64_t cycles; 123 uint64_t ucycles; 124 uint64_t kcycles; 125 125 } task_t; 126 126 127 SPINLOCK_EXTERN(tasks_lock);127 IRQ_SPINLOCK_EXTERN(tasks_lock); 128 128 extern avltree_t tasks_tree; 129 129 130 130 extern void task_init(void); 131 131 extern void task_done(void); 132 extern task_t *task_create(as_t *as, char *name); 133 extern void task_destroy(task_t *t); 134 extern task_t *task_find_by_id(task_id_t id); 135 extern int task_kill(task_id_t id); 136 extern uint64_t task_get_accounting(task_t *t); 137 extern void task_print_list(void); 132 extern task_t *task_create(as_t *, const char *); 133 extern void task_destroy(task_t *); 134 extern void task_hold(task_t *); 135 extern void task_release(task_t *); 136 extern task_t *task_find_by_id(task_id_t); 137 extern int task_kill(task_id_t); 138 extern void task_get_accounting(task_t *, uint64_t *, uint64_t *); 139 extern void task_print_list(bool); 138 140 139 extern void cap_set(task_t * t, cap_t caps);140 extern cap_t cap_get(task_t * t);141 extern void cap_set(task_t *, cap_t); 142 extern cap_t cap_get(task_t *); 141 143 142 144 #ifndef task_create_arch 143 extern void task_create_arch(task_t * t);145 extern void task_create_arch(task_t *); 144 146 #endif 145 147 146 148 #ifndef task_destroy_arch 147 extern void task_destroy_arch(task_t * t);149 extern void task_destroy_arch(task_t *); 148 150 #endif 149 151 150 extern unative_t sys_task_get_id(task_id_t * uspace_task_id);151 extern unative_t sys_task_set_name(const char * uspace_name, size_t name_len);152 extern unative_t sys_task_get_id(task_id_t *); 153 extern unative_t sys_task_set_name(const char *, size_t); 152 154 153 155 #endif -
kernel/generic/include/proc/thread.h
rfb150d78 r46c20c8 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 93 void (* thread_code)(void *); 108 94 /** Argument passed to thread_code() function. */ 109 95 void *thread_arg; 110 96 111 97 /** 112 98 * From here, the stored context is restored when the thread is … … 124 110 */ 125 111 context_t sleep_interruption_context; 126 112 127 113 /** If true, the thread can be interrupted from sleep. */ 128 114 bool sleep_interruptible; … … 132 118 timeout_t sleep_timeout; 133 119 /** Flag signalling sleep timeout in progress. */ 134 volatile inttimeout_pending;135 120 volatile bool timeout_pending; 121 136 122 /** 137 123 * True if this thread is executing copy_from_uspace(). … … 149 135 * thread_exit() before returning to userspace. 150 136 */ 151 bool interrupted; 137 bool interrupted; 152 138 153 139 /** If true, thread_join_timeout() cannot be used on this thread. */ … … 157 143 /** Link used in the joiner_head list. */ 158 144 link_t joiner_link; 159 145 160 146 fpu_context_t *saved_fpu_context; 161 147 int fpu_context_exists; 162 148 163 149 /* 164 150 * Defined only if thread doesn't run. … … 167 153 */ 168 154 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 155 177 156 /** Thread's state. */ 178 157 state_t state; 179 158 /** Thread's flags. */ 180 int flags;159 unsigned int flags; 181 160 182 161 /** Thread's CPU. */ … … 184 163 /** Containing task. */ 185 164 task_t *task; 186 165 187 166 /** Ticks before preemption. */ 188 167 uint64_t ticks; 189 168 190 169 /** Thread accounting. */ 191 uint64_t cycles; 170 uint64_t ucycles; 171 uint64_t kcycles; 192 172 /** Last sampled cycle. */ 193 173 uint64_t last_cycle; 194 /** Thread doesn't affect accumulated accounting. */ 174 /** Thread doesn't affect accumulated accounting. */ 195 175 bool uncounted; 196 176 197 177 /** Thread's priority. Implemented as index to CPU->rq */ 198 178 int priority; … … 202 182 /** Architecture-specific data. */ 203 183 thread_arch_t arch; 204 184 205 185 /** Thread's kernel stack. */ 206 186 uint8_t *kstack; 207 187 208 188 #ifdef CONFIG_UDEBUG 209 189 /** Debugging stuff */ 210 190 udebug_thread_t udebug; 211 #endif 212 191 #endif /* CONFIG_UDEBUG */ 213 192 } thread_t; 214 193 … … 219 198 * 220 199 */ 221 SPINLOCK_EXTERN(threads_lock);200 IRQ_SPINLOCK_EXTERN(threads_lock); 222 201 223 202 /** AVL tree containing all threads. */ … … 225 204 226 205 extern void thread_init(void); 227 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int, char *,228 bool);206 extern thread_t *thread_create(void (*)(void *), void *, task_t *, 207 unsigned int, const char *, bool); 229 208 extern void thread_attach(thread_t *, task_t *); 230 209 extern void thread_ready(thread_t *); … … 234 213 extern void thread_create_arch(thread_t *); 235 214 #endif 215 236 216 #ifndef thr_constructor_arch 237 217 extern void thr_constructor_arch(thread_t *); 238 218 #endif 219 239 220 #ifndef thr_destructor_arch 240 221 extern void thr_destructor_arch(thread_t *); … … 246 227 #define thread_join(t) \ 247 228 thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 248 extern int thread_join_timeout(thread_t *, uint32_t, int); 229 230 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int); 249 231 extern void thread_detach(thread_t *); 250 232 251 extern void thread_ register_call_me(void (*)(void *), void *);252 extern void thread_ print_list(void);253 extern void thread_destroy(thread_t *);254 extern void thread_update_accounting( void);233 extern void thread_print_list(bool); 234 extern void thread_destroy(thread_t *, bool); 235 extern thread_t *thread_find_by_id(thread_id_t); 236 extern void thread_update_accounting(bool); 255 237 extern bool thread_exists(thread_t *); 256 238 -
kernel/generic/include/security/cap.h
rfb150d78 r46c20c8 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 … … 49 49 50 50 #include <syscall/sysarg64.h> 51 #include < arch/types.h>51 #include <typedefs.h> 52 52 53 53 /** … … 70 70 71 71 /** 72 * CAP_PREEMPT_CONTROL allows its holder to disable/enable preemption.73 */74 #define CAP_PREEMPT_CONTROL (1<<3)75 76 /**77 72 * CAP_IRQ_REG entitles its holder to register IRQ handlers. 78 73 */ 79 #define CAP_IRQ_REG (1<< 4)74 #define CAP_IRQ_REG (1<<3) 80 75 81 76 typedef uint32_t cap_t; -
kernel/generic/include/smp/ipi.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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/stacktrace.h
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup genericdebug 29 /** @addtogroup genericdebug 30 30 * @{ 31 31 */ … … 36 36 #define KERN_STACKTRACE_H_ 37 37 38 #include <arch/types.h>39 38 #include <typedefs.h> 40 39 41 /* Forward declaration s. */40 /* Forward declaration. */ 42 41 struct istate; 43 42 44 43 typedef struct { 45 bool (* frame_pointer_validate)(uintptr_t); 46 bool (* frame_pointer_prev)(uintptr_t, uintptr_t *); 47 bool (* return_address_get)(uintptr_t, uintptr_t *); 48 bool (* symbol_resolve)(uintptr_t, char **, uintptr_t *); 44 uintptr_t fp; 45 uintptr_t pc; 46 struct istate *istate; 47 } stack_trace_context_t; 48 49 typedef struct { 50 bool (* stack_trace_context_validate)(stack_trace_context_t *); 51 bool (* frame_pointer_prev)(stack_trace_context_t *, uintptr_t *); 52 bool (* return_address_get)(stack_trace_context_t *, uintptr_t *); 53 bool (* symbol_resolve)(uintptr_t, const char **, uintptr_t *); 49 54 } stack_trace_ops_t; 50 55 … … 54 59 extern void stack_trace(void); 55 60 extern void stack_trace_istate(struct istate *); 56 extern void stack_trace_ fp_pc(stack_trace_ops_t *, uintptr_t, uintptr_t);61 extern void stack_trace_ctx(stack_trace_ops_t *, stack_trace_context_t *); 57 62 58 63 /* … … 62 67 extern uintptr_t program_counter_get(void); 63 68 64 extern bool kernel_ frame_pointer_validate(uintptr_t);65 extern bool kernel_frame_pointer_prev( uintptr_t, uintptr_t *);66 extern bool kernel_return_address_get( uintptr_t, uintptr_t *);69 extern bool kernel_stack_trace_context_validate(stack_trace_context_t *); 70 extern bool kernel_frame_pointer_prev(stack_trace_context_t *, uintptr_t *); 71 extern bool kernel_return_address_get(stack_trace_context_t *, uintptr_t *); 67 72 68 extern bool uspace_ frame_pointer_validate(uintptr_t);69 extern bool uspace_frame_pointer_prev( uintptr_t, uintptr_t *);70 extern bool uspace_return_address_get( uintptr_t, uintptr_t *);73 extern bool uspace_stack_trace_context_validate(stack_trace_context_t *); 74 extern bool uspace_frame_pointer_prev(stack_trace_context_t *, uintptr_t *); 75 extern bool uspace_return_address_get(stack_trace_context_t *, uintptr_t *); 71 76 72 77 #endif -
kernel/generic/include/str.h
rfb150d78 r46c20c8 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> … … 89 89 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 90 90 91 extern char *str_dup(const char *src); 92 extern char *str_ndup(const char *src, size_t n); 93 91 94 extern char *str_chr(const char *str, wchar_t ch); 92 95 … … 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
rfb150d78 r46c20c8 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(uintptr_t, c har **, uintptr_t *);48 extern c har *symtab_fmt_name_lookup(uintptr_t);47 extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *); 48 extern const char *symtab_fmt_name_lookup(uintptr_t); 49 49 extern int symtab_addr_lookup(const char *, uintptr_t *); 50 50 extern void symtab_print_search(const char *); … … 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 36 36 #define KERN_FUTEX_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 40 -
kernel/generic/include/synch/mutex.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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/spinlock.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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/sysarg64.h
rfb150d78 r46c20c8 33 33 /** 34 34 * @file 35 * @brief Wrapper for explicit 64-bit arguments passed to syscalls.35 * @brief Wrapper for explicit 64-bit arguments passed to syscalls. 36 36 */ 37 37 -
kernel/generic/include/syscall/syscall.h
rfb150d78 r46c20c8 71 71 SYS_IPC_REGISTER_IRQ, 72 72 SYS_IPC_UNREGISTER_IRQ, 73 73 74 74 SYS_EVENT_SUBSCRIBE, 75 75 … … 80 80 SYS_PHYSMEM_MAP, 81 81 SYS_IOSPACE_ENABLE, 82 SYS_ PREEMPT_CONTROL,82 SYS_INTERRUPT_ENABLE, 83 83 84 SYS_SYSINFO_VALID, 85 SYS_SYSINFO_VALUE, 84 SYS_SYSINFO_GET_TAG, 85 SYS_SYSINFO_GET_VALUE, 86 SYS_SYSINFO_GET_DATA_SIZE, 87 SYS_SYSINFO_GET_DATA, 86 88 87 89 SYS_DEBUG_ENABLE_CONSOLE, 88 90 SYS_DEBUG_DISABLE_CONSOLE, 91 89 92 SYS_IPC_CONNECT_KBOX, 90 93 SYSCALL_END … … 93 96 #ifdef KERNEL 94 97 95 #include < arch/types.h>98 #include <typedefs.h> 96 99 97 100 typedef unative_t (*syshandler_t)(unative_t, unative_t, unative_t, unative_t, -
kernel/generic/include/sysinfo/stats.h
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup abs32ledebug29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_ abs32le_DEBUG_H_36 #define KERN_ abs32le_DEBUG_H_35 #ifndef KERN_STATS_H_ 36 #define KERN_STATS_H_ 37 37 38 #include <arch/asm.h> 39 40 #define HERE get_ip() 38 extern void kload(void *arg); 39 extern void stats_init(void); 41 40 42 41 #endif -
kernel/generic/include/sysinfo/sysinfo.h
rfb150d78 r46c20c8 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 unative_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 unative_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 unative_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 **, unative_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 unative_t sys_sysinfo_get_tag(void *, size_t); 148 extern unative_t sys_sysinfo_get_value(void *, size_t, void *); 149 extern unative_t sys_sysinfo_get_data_size(void *, size_t, void *); 150 extern unative_t sys_sysinfo_get_data(void *, size_t, void *, size_t); 90 151 91 152 #endif -
kernel/generic/include/time/clock.h
rfb150d78 r46c20c8 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 */ -
kernel/generic/include/time/delay.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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; -
kernel/generic/include/udebug/udebug_ipc.h
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ -
kernel/generic/include/userspace.h
rfb150d78 r46c20c8 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.
