Changeset 925a21e in mainline for kernel/generic
- Timestamp:
- 2011-09-24T14:20:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (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
- Files:
-
- 41 edited
-
include/adt/list.h (modified) (4 diffs)
-
include/console/console.h (modified) (1 diff)
-
include/ddi/ddi.h (modified) (1 diff)
-
include/ddi/irq.h (modified) (5 diffs)
-
include/errno.h (modified) (2 diffs)
-
include/ipc/event.h (modified) (3 diffs)
-
include/ipc/ipc.h (modified) (3 diffs)
-
include/lib/elf.h (modified) (1 diff)
-
include/mm/as.h (modified) (2 diffs)
-
include/proc/task.h (modified) (3 diffs)
-
include/proc/thread.h (modified) (1 diff)
-
include/synch/condvar.h (modified) (1 diff)
-
include/synch/mutex.h (modified) (1 diff)
-
include/synch/semaphore.h (modified) (1 diff)
-
include/synch/waitq.h (modified) (1 diff)
-
include/syscall/syscall.h (modified) (2 diffs)
-
include/sysinfo/sysinfo.h (modified) (2 diffs)
-
include/typedefs.h (modified) (2 diffs)
-
include/udebug/udebug.h (modified) (2 diffs)
-
src/adt/btree.c (modified) (7 diffs)
-
src/adt/list.c (modified) (2 diffs)
-
src/console/console.c (modified) (3 diffs)
-
src/ddi/ddi.c (modified) (1 diff)
-
src/ipc/event.c (modified) (11 diffs)
-
src/ipc/ipc.c (modified) (4 diffs)
-
src/ipc/kbox.c (modified) (1 diff)
-
src/ipc/sysipc.c (modified) (8 diffs)
-
src/mm/frame.c (modified) (1 diff)
-
src/mm/slab.c (modified) (1 diff)
-
src/printf/printf_core.c (modified) (5 diffs)
-
src/proc/program.c (modified) (1 diff)
-
src/proc/task.c (modified) (3 diffs)
-
src/proc/thread.c (modified) (2 diffs)
-
src/synch/condvar.c (modified) (1 diff)
-
src/synch/futex.c (modified) (1 diff)
-
src/synch/mutex.c (modified) (1 diff)
-
src/synch/semaphore.c (modified) (1 diff)
-
src/synch/waitq.c (modified) (1 diff)
-
src/syscall/syscall.c (modified) (1 diff)
-
src/sysinfo/stats.c (modified) (1 diff)
-
src/sysinfo/sysinfo.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
r867e2555 r925a21e 72 72 73 73 #define assert_link_not_used(link) \ 74 ASSERT(( link)->prev == NULL && (link)->next == NULL)74 ASSERT(((link)->prev == NULL) && ((link)->next == NULL)) 75 75 76 76 /** Initialize doubly-linked circular list link … … 158 158 NO_TRACE static inline void list_remove(link_t *link) 159 159 { 160 link->next->prev = link->prev; 161 link->prev->next = link->next; 160 if ((link->prev != NULL) && (link->next != NULL)) { 161 link->next->prev = link->prev; 162 link->prev->next = link->next; 163 } 164 162 165 link_initialize(link); 163 166 } … … 170 173 * 171 174 */ 172 NO_TRACE static inline int list_empty( list_t *list)175 NO_TRACE static inline int list_empty(const list_t *list) 173 176 { 174 177 return (list->head.next == &list->head); … … 183 186 * 184 187 */ 185 static inline link_t *list_first( list_t *list)188 static inline link_t *list_first(const list_t *list) 186 189 { 187 190 return ((list->head.next == &list->head) ? NULL : list->head.next); -
kernel/generic/include/console/console.h
r867e2555 r925a21e 63 63 64 64 extern void klog_init(void); 65 extern void klog_update(void );65 extern void klog_update(void *); 66 66 67 67 extern wchar_t getc(indev_t *indev); -
kernel/generic/include/ddi/ddi.h
r867e2555 r925a21e 36 36 #define KERN_DDI_H_ 37 37 38 #include <ddi/ddi_arg.h>39 38 #include <typedefs.h> 39 #include <abi/ddi/arg.h> 40 40 #include <proc/task.h> 41 41 #include <adt/list.h> -
kernel/generic/include/ddi/irq.h
r867e2555 r925a21e 33 33 */ 34 34 35 #ifndef KERN_IRQ_H_ 36 #define KERN_IRQ_H_ 37 38 #ifdef KERNEL 35 #ifndef KERN_DDI_IRQ_H_ 36 #define KERN_DDI_IRQ_H_ 39 37 40 38 #include <typedefs.h> 39 #include <abi/ddi/irq.h> 41 40 #include <adt/list.h> 42 41 #include <adt/hash_table.h> … … 44 43 #include <proc/task.h> 45 44 #include <ipc/ipc.h> 46 47 #endif /* KERNEL */48 49 typedef enum {50 /** Read 1 byte from the I/O space. */51 CMD_PIO_READ_8 = 1,52 /** Read 2 bytes from the I/O space. */53 CMD_PIO_READ_16,54 /** Read 4 bytes from the I/O space. */55 CMD_PIO_READ_32,56 57 /** Write 1 byte to the I/O space. */58 CMD_PIO_WRITE_8,59 /** Write 2 bytes to the I/O space. */60 CMD_PIO_WRITE_16,61 /** Write 4 bytes to the I/O space. */62 CMD_PIO_WRITE_32,63 64 /**65 * Write 1 byte from the source argument66 * to the I/O space.67 */68 CMD_PIO_WRITE_A_8,69 /**70 * Write 2 bytes from the source argument71 * to the I/O space.72 */73 CMD_PIO_WRITE_A_16,74 /**75 * Write 4 bytes from the source argument76 * to the I/O space.77 */78 CMD_PIO_WRITE_A_32,79 80 /** Read 1 byte from the memory space. */81 CMD_MEM_READ_8,82 /** Read 2 bytes from the memory space. */83 CMD_MEM_READ_16,84 /** Read 4 bytes from the memory space. */85 CMD_MEM_READ_32,86 87 /** Write 1 byte to the memory space. */88 CMD_MEM_WRITE_8,89 /** Write 2 bytes to the memory space. */90 CMD_MEM_WRITE_16,91 /** Write 4 bytes to the memory space. */92 CMD_MEM_WRITE_32,93 94 /** Write 1 byte from the source argument to the memory space. */95 CMD_MEM_WRITE_A_8,96 /** Write 2 bytes from the source argument to the memory space. */97 CMD_MEM_WRITE_A_16,98 /** Write 4 bytes from the source argument to the memory space. */99 CMD_MEM_WRITE_A_32,100 101 /**102 * Perform a bit masking on the source argument103 * and store the result into the destination argument.104 */105 CMD_BTEST,106 107 /**108 * Predicate the execution of the following109 * N commands by the boolean value of the source110 * argument.111 */112 CMD_PREDICATE,113 114 /** Accept the interrupt. */115 CMD_ACCEPT,116 117 /** Decline the interrupt. */118 CMD_DECLINE,119 CMD_LAST120 } irq_cmd_type;121 122 typedef struct {123 irq_cmd_type cmd;124 void *addr;125 uint32_t value;126 uintptr_t srcarg;127 uintptr_t dstarg;128 } irq_cmd_t;129 130 typedef struct {131 size_t cmdcount;132 irq_cmd_t *cmds;133 } irq_code_t;134 135 #ifdef KERNEL136 45 137 46 typedef enum { … … 146 55 147 56 struct irq; 57 148 58 typedef void (* irq_handler_t)(struct irq *); 149 59 … … 224 134 /** Notification configuration structure. */ 225 135 ipc_notif_cfg_t notif_cfg; 226 136 227 137 as_t *driver_as; 228 138 } irq_t; … … 238 148 extern irq_t *irq_dispatch_and_lock(inr_t); 239 149 240 #endif /* KERNEL */241 242 150 #endif 243 151 -
kernel/generic/include/errno.h
r867e2555 r925a21e 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ERRNO_H_ 37 37 38 /* 1-255 are kernel error codes, 256-512 are user error codes */ 39 40 #define EOK 0 /* No error */ 41 #define ENOENT -1 /* No such entry */ 42 #define ENOMEM -2 /* Not enough memory */ 43 #define ELIMIT -3 /* Limit exceeded */ 44 #define EREFUSED -4 /* Connection refused */ 45 #define EFORWARD -5 /* Forward error */ 46 #define EPERM -6 /* Permission denied */ 47 #define EHANGUP -7 /* Answerbox closed connection, call 48 * sys_ipc_hangup() to close the connection. 49 * Used by answerbox to close the connection. 50 */ 51 #define EPARTY -8 /* The other party encountered an error when 52 * receiving the call. 53 */ 54 #define EEXISTS -9 /* Entry already exists */ 55 #define EBADMEM -10 /* Bad memory pointer */ 56 #define ENOTSUP -11 /* Not supported */ 57 #define EADDRNOTAVAIL -12 /* Address not available. */ 58 #define ETIMEOUT -13 /* Timeout expired */ 59 #define EINVAL -14 /* Invalid value */ 60 #define EBUSY -15 /* Resource is busy */ 61 #define EOVERFLOW -16 /* The result does not fit its size. */ 62 #define EINTR -17 /* Operation was interrupted. */ 38 #include <abi/errno.h> 63 39 64 40 #endif -
kernel/generic/include/ipc/event.h
r867e2555 r925a21e 36 36 #define KERN_EVENT_H_ 37 37 38 #include < ipc/event_types.h>38 #include <abi/ipc/event.h> 39 39 #include <typedefs.h> 40 40 #include <synch/spinlock.h> 41 41 #include <ipc/ipc.h> 42 42 43 typedef void (*event_callback_t)(void); 43 struct task; 44 45 typedef void (*event_callback_t)(void *); 44 46 45 47 /** Event notification structure. */ … … 61 63 62 64 extern void event_init(void); 65 extern void event_task_init(struct task *); 63 66 extern void event_cleanup_answerbox(answerbox_t *); 64 67 extern void event_set_unmask_callback(event_type_t, event_callback_t); 68 extern void event_task_set_unmask_callback(struct task *, event_task_type_t, 69 event_callback_t); 65 70 66 71 #define event_notify_0(e, m) \ … … 77 82 event_notify((e), (m), (a1), (a2), (a3), (a4), (a5)) 78 83 84 #define event_task_notify_0(t, e, m) \ 85 event_task_notify((t), (e), (m), 0, 0, 0, 0, 0) 86 #define event_task_notify_1(t, e, m, a1) \ 87 event_task_notify((t), (e), (m), (a1), 0, 0, 0, 0) 88 #define event_task_notify_2(t, e, m, a1, a2) \ 89 event_task_notify((t), (e), (m), (a1), (a2), 0, 0, 0) 90 #define event_task_notify_3(t, e, m, a1, a2, a3) \ 91 event_task_notify((t), (e), (m), (a1), (a2), (a3), 0, 0) 92 #define event_task_notify_4(t, e, m, a1, a2, a3, a4) \ 93 event_task_notify((t), (e), (m), (a1), (a2), (a3), (a4), 0) 94 #define event_task_notify_5(t, e, m, a1, a2, a3, a4, a5) \ 95 event_task_notify((t), (e), (m), (a1), (a2), (a3), (a4), (a5)) 96 79 97 extern int event_notify(event_type_t, bool, sysarg_t, sysarg_t, sysarg_t, 80 98 sysarg_t, sysarg_t); 99 extern int event_task_notify(struct task *, event_task_type_t, bool, sysarg_t, sysarg_t, 100 sysarg_t, sysarg_t, sysarg_t); 81 101 82 102 extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t); -
kernel/generic/include/ipc/ipc.h
r867e2555 r925a21e 36 36 #define KERN_IPC_H_ 37 37 38 /** Length of data being transfered with IPC call39 *40 * The uspace may not be able to utilize full length41 *42 */43 #define IPC_CALL_LEN 644 45 /** Maximum active async calls per phone */46 #define IPC_MAX_ASYNC_CALLS 447 48 /* Flags for calls */49 50 /** This is answer to a call */51 #define IPC_CALL_ANSWERED (1 << 0)52 53 /** Answer will not be passed to userspace, will be discarded */54 #define IPC_CALL_DISCARD_ANSWER (1 << 1)55 56 /** Call was forwarded */57 #define IPC_CALL_FORWARDED (1 << 2)58 59 /** Identify connect_me_to answer */60 #define IPC_CALL_CONN_ME_TO (1 << 3)61 62 /** Interrupt notification */63 #define IPC_CALL_NOTIF (1 << 4)64 65 66 /** Bits used in call hashes.67 *68 * The addresses are aligned at least to 4 that is why we can use the 2 least69 * significant bits of the call address.70 *71 */72 73 /** Type of this call is 'answer' */74 #define IPC_CALLID_ANSWERED 175 76 /** Type of this call is 'notification' */77 #define IPC_CALLID_NOTIFICATION 278 79 /* Return values from sys_ipc_call_async(). */80 #define IPC_CALLRET_FATAL -181 #define IPC_CALLRET_TEMPORARY -282 83 84 /* Macros for manipulating calling data */85 #define IPC_SET_RETVAL(data, retval) ((data).args[0] = (retval))86 #define IPC_SET_IMETHOD(data, val) ((data).args[0] = (val))87 #define IPC_SET_ARG1(data, val) ((data).args[1] = (val))88 #define IPC_SET_ARG2(data, val) ((data).args[2] = (val))89 #define IPC_SET_ARG3(data, val) ((data).args[3] = (val))90 #define IPC_SET_ARG4(data, val) ((data).args[4] = (val))91 #define IPC_SET_ARG5(data, val) ((data).args[5] = (val))92 93 #define IPC_GET_IMETHOD(data) ((data).args[0])94 #define IPC_GET_RETVAL(data) ((data).args[0])95 96 #define IPC_GET_ARG1(data) ((data).args[1])97 #define IPC_GET_ARG2(data) ((data).args[2])98 #define IPC_GET_ARG3(data) ((data).args[3])99 #define IPC_GET_ARG4(data) ((data).args[4])100 #define IPC_GET_ARG5(data) ((data).args[5])101 102 /* Forwarding flags. */103 #define IPC_FF_NONE 0104 105 /**106 * The call will be routed as though it was initially sent via the phone used to107 * forward it. This feature is intended to support the situation in which the108 * forwarded call needs to be handled by the same connection fibril as any other109 * calls that were initially sent by the forwarder to the same destination. This110 * flag has no imapct on routing replies.111 *112 */113 #define IPC_FF_ROUTE_FROM_ME (1 << 0)114 115 /* Data transfer flags. */116 #define IPC_XF_NONE 0117 118 /** Restrict the transfer size if necessary. */119 #define IPC_XF_RESTRICT (1 << 0)120 121 /** User-defined IPC methods */122 #define IPC_FIRST_USER_METHOD 1024123 124 #ifdef KERNEL125 126 #define IPC_MAX_PHONES 32127 128 38 #include <synch/spinlock.h> 129 39 #include <synch/mutex.h> 130 40 #include <synch/waitq.h> 41 #include <abi/ipc/ipc.h> 42 #include <abi/proc/task.h> 43 #include <typedefs.h> 44 45 #define IPC_MAX_PHONES 64 131 46 132 47 struct answerbox; … … 184 99 typedef struct { 185 100 sysarg_t args[IPC_CALL_LEN]; 186 /** Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME. */ 187 struct task *task; 101 /** 102 * Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME, 103 * or the task which answered the call. 104 */ 105 task_id_t task_id; 188 106 /** Phone which made or last masqueraded this call. */ 189 107 phone_t *phone; … … 247 165 extern void ipc_print_task(task_id_t); 248 166 249 #endif /* KERNEL */250 251 167 #endif 252 168 -
kernel/generic/include/lib/elf.h
r867e2555 r925a21e 36 36 #define KERN_ELF_H_ 37 37 38 #include <typedefs.h> 39 #include <abi/elf.h> 38 40 #include <arch/elf.h> 39 #include <typedefs.h>40 41 /**42 * current ELF version43 */44 #define EV_CURRENT 145 46 /**47 * ELF types48 */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 * ELF machine types59 */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 72 /**73 * ELF identification indexes74 */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 */86 87 /**88 * ELF magic number89 */90 #define ELFMAG0 0x7f91 #define ELFMAG1 'E'92 #define ELFMAG2 'L'93 #define ELFMAG3 'F'94 95 /**96 * ELF file classes97 */98 #define ELFCLASSNONE 099 #define ELFCLASS32 1100 #define ELFCLASS64 2101 102 /**103 * ELF data encoding types104 */105 #define ELFDATANONE 0106 #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */107 #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */108 109 /**110 * ELF section types111 */112 #define SHT_NULL 0113 #define SHT_PROGBITS 1114 #define SHT_SYMTAB 2115 #define SHT_STRTAB 3116 #define SHT_RELA 4117 #define SHT_HASH 5118 #define SHT_DYNAMIC 6119 #define SHT_NOTE 7120 #define SHT_NOBITS 8121 #define SHT_REL 9122 #define SHT_SHLIB 10123 #define SHT_DYNSYM 11124 #define SHT_LOOS 0x60000000125 #define SHT_HIOS 0x6fffffff126 #define SHT_LOPROC 0x70000000127 #define SHT_HIPROC 0x7fffffff128 #define SHT_LOUSER 0x80000000129 #define SHT_HIUSER 0xffffffff130 131 /**132 * ELF section flags133 */134 #define SHF_WRITE 0x1135 #define SHF_ALLOC 0x2136 #define SHF_EXECINSTR 0x4137 #define SHF_TLS 0x400138 #define SHF_MASKPROC 0xf0000000139 140 /** Macros for decomposing elf_symbol.st_info into binging and type */141 #define ELF_ST_BIND(i) ((i) >> 4)142 #define ELF_ST_TYPE(i) ((i) & 0x0f)143 #define ELF_ST_INFO(b, t) (((b) << 4) + ((t) & 0x0f))144 145 /**146 * Symbol binding147 */148 #define STB_LOCAL 0149 #define STB_GLOBAL 1150 #define STB_WEAK 2151 #define STB_LOPROC 13152 #define STB_HIPROC 15153 154 /**155 * Symbol types156 */157 #define STT_NOTYPE 0158 #define STT_OBJECT 1159 #define STT_FUNC 2160 #define STT_SECTION 3161 #define STT_FILE 4162 #define STT_LOPROC 13163 #define STT_HIPROC 15164 165 /**166 * Program segment types167 */168 #define PT_NULL 0169 #define PT_LOAD 1170 #define PT_DYNAMIC 2171 #define PT_INTERP 3172 #define PT_NOTE 4173 #define PT_SHLIB 5174 #define PT_PHDR 6175 #define PT_LOPROC 0x70000000176 #define PT_HIPROC 0x7fffffff177 178 /**179 * Program segment attributes.180 */181 #define PF_X 1182 #define PF_W 2183 #define PF_R 4184 185 /**186 * ELF data types187 *188 * These types are found to be identical in both 32-bit and 64-bit189 * ELF object file specifications. They are the only types used190 * in ELF header.191 */192 typedef uint64_t elf_xword;193 typedef int64_t elf_sxword;194 typedef uint32_t elf_word;195 typedef int32_t elf_sword;196 typedef uint16_t elf_half;197 198 /**199 * 32-bit ELF data types.200 *201 * These types are specific for 32-bit format.202 */203 typedef uint32_t elf32_addr;204 typedef uint32_t elf32_off;205 206 /**207 * 64-bit ELF data types.208 *209 * These types are specific for 64-bit format.210 */211 typedef uint64_t elf64_addr;212 typedef uint64_t elf64_off;213 214 /** ELF header */215 struct elf32_header {216 uint8_t e_ident[EI_NIDENT];217 elf_half e_type;218 elf_half e_machine;219 elf_word e_version;220 elf32_addr e_entry;221 elf32_off e_phoff;222 elf32_off e_shoff;223 elf_word e_flags;224 elf_half e_ehsize;225 elf_half e_phentsize;226 elf_half e_phnum;227 elf_half e_shentsize;228 elf_half e_shnum;229 elf_half e_shstrndx;230 };231 struct elf64_header {232 uint8_t e_ident[EI_NIDENT];233 elf_half e_type;234 elf_half e_machine;235 elf_word e_version;236 elf64_addr e_entry;237 elf64_off e_phoff;238 elf64_off e_shoff;239 elf_word e_flags;240 elf_half e_ehsize;241 elf_half e_phentsize;242 elf_half e_phnum;243 elf_half e_shentsize;244 elf_half e_shnum;245 elf_half e_shstrndx;246 };247 248 /*249 * ELF segment header.250 * Segments headers are also known as program headers.251 */252 struct elf32_segment_header {253 elf_word p_type;254 elf32_off p_offset;255 elf32_addr p_vaddr;256 elf32_addr p_paddr;257 elf_word p_filesz;258 elf_word p_memsz;259 elf_word p_flags;260 elf_word p_align;261 };262 struct elf64_segment_header {263 elf_word p_type;264 elf_word p_flags;265 elf64_off p_offset;266 elf64_addr p_vaddr;267 elf64_addr p_paddr;268 elf_xword p_filesz;269 elf_xword p_memsz;270 elf_xword p_align;271 };272 273 /*274 * ELF section header275 */276 struct elf32_section_header {277 elf_word sh_name;278 elf_word sh_type;279 elf_word sh_flags;280 elf32_addr sh_addr;281 elf32_off sh_offset;282 elf_word sh_size;283 elf_word sh_link;284 elf_word sh_info;285 elf_word sh_addralign;286 elf_word sh_entsize;287 };288 struct elf64_section_header {289 elf_word sh_name;290 elf_word sh_type;291 elf_xword sh_flags;292 elf64_addr sh_addr;293 elf64_off sh_offset;294 elf_xword sh_size;295 elf_word sh_link;296 elf_word sh_info;297 elf_xword sh_addralign;298 elf_xword sh_entsize;299 };300 301 /*302 * ELF symbol table entry303 */304 struct elf32_symbol {305 elf_word st_name;306 elf32_addr st_value;307 elf_word st_size;308 uint8_t st_info;309 uint8_t st_other;310 elf_half st_shndx;311 };312 struct elf64_symbol {313 elf_word st_name;314 uint8_t st_info;315 uint8_t st_other;316 elf_half st_shndx;317 elf64_addr st_value;318 elf_xword st_size;319 };320 321 /*322 * ELF note segment entry323 */324 struct elf32_note {325 elf_word namesz;326 elf_word descsz;327 elf_word type;328 };329 struct elf64_note {330 elf_xword namesz;331 elf_xword descsz;332 elf_xword type;333 };334 335 #ifdef __32_BITS__336 typedef struct elf32_header elf_header_t;337 typedef struct elf32_segment_header elf_segment_header_t;338 typedef struct elf32_section_header elf_section_header_t;339 typedef struct elf32_symbol elf_symbol_t;340 typedef struct elf32_note elf_note_t;341 #endif342 #ifdef __64_BITS__343 typedef struct elf64_header elf_header_t;344 typedef struct elf64_segment_header elf_segment_header_t;345 typedef struct elf64_section_header elf_section_header_t;346 typedef struct elf64_symbol elf_symbol_t;347 typedef struct elf64_note elf_note_t;348 #endif349 41 350 42 /** Interpreter string used to recognize the program loader */ -
kernel/generic/include/mm/as.h
r867e2555 r925a21e 36 36 #define KERN_AS_H_ 37 37 38 #ifdef KERNEL 39 #include <typedefs.h> 40 #else 41 #include <sys/types.h> 42 #endif 43 44 /** Address space area flags. */ 45 #define AS_AREA_READ 1 46 #define AS_AREA_WRITE 2 47 #define AS_AREA_EXEC 4 48 #define AS_AREA_CACHEABLE 8 49 50 /** Address space area info exported to userspace. */ 51 typedef struct { 52 /** Starting address */ 53 uintptr_t start_addr; 54 55 /** Area size */ 56 size_t size; 57 58 /** Area flags */ 59 unsigned int flags; 60 } as_area_info_t; 61 62 #ifdef KERNEL 63 38 #include <typedefs.h> 39 #include <abi/mm/as.h> 64 40 #include <arch/mm/page.h> 65 41 #include <arch/mm/as.h> … … 318 294 extern void as_print(as_t *); 319 295 320 #endif /* KERNEL */321 322 296 #endif 323 297 -
kernel/generic/include/proc/task.h
r867e2555 r925a21e 38 38 #include <cpu.h> 39 39 #include <ipc/ipc.h> 40 #include <ipc/event.h> 41 #include <ipc/kbox.h> 40 42 #include <synch/spinlock.h> 41 43 #include <synch/mutex.h> … … 53 55 #include <proc/scheduler.h> 54 56 #include <udebug/udebug.h> 55 #include <ipc/kbox.h>56 57 #include <mm/as.h> 57 #include < sysinfo/abi.h>58 #include <abi/sysinfo.h> 58 59 59 60 struct thread; … … 93 94 phone_t phones[IPC_MAX_PHONES]; 94 95 stats_ipc_t ipc_info; /**< IPC statistics */ 95 /**List of synchronous answerboxes. */96 list_t sync_boxes;96 list_t sync_boxes; /**< List of synchronous answerboxes. */ 97 event_t events[EVENT_TASK_END - EVENT_END]; 97 98 98 99 #ifdef CONFIG_UDEBUG -
kernel/generic/include/proc/thread.h
r867e2555 r925a21e 45 45 #include <arch/cpu.h> 46 46 #include <mm/tlb.h> 47 #include < proc/uarg.h>47 #include <abi/proc/uarg.h> 48 48 #include <udebug/udebug.h> 49 #include < sysinfo/abi.h>49 #include <abi/sysinfo.h> 50 50 51 51 #define THREAD_NAME_BUFLEN 20 -
kernel/generic/include/synch/condvar.h
r867e2555 r925a21e 39 39 #include <synch/waitq.h> 40 40 #include <synch/mutex.h> 41 #include < synch/synch.h>41 #include <abi/synch.h> 42 42 43 43 typedef struct { -
kernel/generic/include/synch/mutex.h
r867e2555 r925a21e 38 38 #include <typedefs.h> 39 39 #include <synch/semaphore.h> 40 #include < synch/synch.h>40 #include <abi/synch.h> 41 41 42 42 typedef enum { -
kernel/generic/include/synch/semaphore.h
r867e2555 r925a21e 38 38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 #include < synch/synch.h>40 #include <abi/synch.h> 41 41 42 42 typedef struct { -
kernel/generic/include/synch/waitq.h
r867e2555 r925a21e 38 38 #include <typedefs.h> 39 39 #include <synch/spinlock.h> 40 #include < synch/synch.h>40 #include <abi/synch.h> 41 41 #include <adt/list.h> 42 42 -
kernel/generic/include/syscall/syscall.h
r867e2555 r925a21e 36 36 #define KERN_SYSCALL_H_ 37 37 38 typedef enum {39 SYS_KLOG = 0,40 SYS_TLS_SET = 1, /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */41 42 SYS_THREAD_CREATE,43 SYS_THREAD_EXIT,44 SYS_THREAD_GET_ID,45 SYS_THREAD_USLEEP,46 SYS_THREAD_UDELAY,47 48 SYS_TASK_GET_ID,49 SYS_TASK_SET_NAME,50 SYS_TASK_KILL,51 SYS_TASK_EXIT,52 SYS_PROGRAM_SPAWN_LOADER,53 54 SYS_FUTEX_SLEEP,55 SYS_FUTEX_WAKEUP,56 SYS_SMC_COHERENCE,57 58 SYS_AS_AREA_CREATE,59 SYS_AS_AREA_RESIZE,60 SYS_AS_AREA_CHANGE_FLAGS,61 SYS_AS_AREA_DESTROY,62 SYS_AS_GET_UNMAPPED_AREA,63 64 SYS_PAGE_FIND_MAPPING,65 66 SYS_IPC_CALL_SYNC_FAST,67 SYS_IPC_CALL_SYNC_SLOW,68 SYS_IPC_CALL_ASYNC_FAST,69 SYS_IPC_CALL_ASYNC_SLOW,70 SYS_IPC_ANSWER_FAST,71 SYS_IPC_ANSWER_SLOW,72 SYS_IPC_FORWARD_FAST,73 SYS_IPC_FORWARD_SLOW,74 SYS_IPC_WAIT,75 SYS_IPC_POKE,76 SYS_IPC_HANGUP,77 SYS_IPC_CONNECT_KBOX,78 79 SYS_EVENT_SUBSCRIBE,80 SYS_EVENT_UNMASK,81 82 SYS_CAP_GRANT,83 SYS_CAP_REVOKE,84 85 SYS_DEVICE_ASSIGN_DEVNO,86 SYS_PHYSMEM_MAP,87 SYS_IOSPACE_ENABLE,88 SYS_REGISTER_IRQ,89 SYS_UNREGISTER_IRQ,90 91 SYS_SYSINFO_GET_TAG,92 SYS_SYSINFO_GET_VALUE,93 SYS_SYSINFO_GET_DATA_SIZE,94 SYS_SYSINFO_GET_DATA,95 96 SYS_DEBUG_ACTIVATE_CONSOLE,97 98 SYSCALL_END99 } syscall_t;100 101 #ifdef KERNEL102 103 38 #include <typedefs.h> 39 #include <abi/syscall.h> 104 40 105 41 typedef sysarg_t (*syshandler_t)(sysarg_t, sysarg_t, sysarg_t, sysarg_t, … … 113 49 #endif 114 50 115 #endif116 117 51 /** @} 118 52 */ -
kernel/generic/include/sysinfo/sysinfo.h
r867e2555 r925a21e 38 38 #include <typedefs.h> 39 39 #include <str.h> 40 #include <abi/sysinfo.h> 40 41 41 42 /** Framebuffer info exported flags */ 42 43 extern bool fb_exported; 43 44 /** Item value type45 *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 44 55 45 /** Subtree type … … 145 135 extern void sysinfo_dump(sysinfo_item_t *); 146 136 147 extern sysarg_t sys_sysinfo_get_ tag(void *, size_t);137 extern sysarg_t sys_sysinfo_get_val_type(void *, size_t); 148 138 extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *); 149 139 extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *); -
kernel/generic/include/typedefs.h
r867e2555 r925a21e 39 39 #include <arch/common.h> 40 40 #include <arch/types.h> 41 #include <abi/bool.h> 41 42 42 43 #define NULL ((void *) 0) … … 61 62 typedef void (* function)(); 62 63 63 typedef uint8_t bool;64 typedef uint64_t thread_id_t;65 typedef uint64_t task_id_t;66 64 typedef uint32_t container_id_t; 67 65 -
kernel/generic/include/udebug/udebug.h
r867e2555 r925a21e 36 36 #define KERN_UDEBUG_H_ 37 37 38 #define UDEBUG_EVMASK(event) (1 << ((event) - 1)) 39 40 typedef enum { /* udebug_method_t */ 41 42 /** Start debugging the recipient. 43 * 44 * Causes all threads in the receiving task to stop. When they 45 * are all stoped, an answer with retval 0 is generated. 46 * 47 */ 48 UDEBUG_M_BEGIN = 1, 49 50 /** Finish debugging the recipient. 51 * 52 * Answers all pending GO and GUARD messages. 53 * 54 */ 55 UDEBUG_M_END, 56 57 /** Set which events should be captured. */ 58 UDEBUG_M_SET_EVMASK, 59 60 /** Make sure the debugged task is still there. 61 * 62 * This message is answered when the debugged task dies 63 * or the debugging session ends. 64 * 65 */ 66 UDEBUG_M_GUARD, 67 68 /** Run a thread until a debugging event occurs. 69 * 70 * This message is answered when the thread stops 71 * in a debugging event. 72 * 73 * - ARG2 - id of the thread to run 74 * 75 */ 76 UDEBUG_M_GO, 77 78 /** Stop a thread being debugged. 79 * 80 * Creates a special STOP event in the thread, causing 81 * it to answer a pending GO message (if any). 82 * 83 */ 84 UDEBUG_M_STOP, 85 86 /** Read arguments of a syscall. 87 * 88 * - ARG2 - thread identification 89 * - ARG3 - destination address in the caller's address space 90 * 91 */ 92 UDEBUG_M_ARGS_READ, 93 94 /** Read thread's userspace register state (istate_t). 95 * 96 * - ARG2 - thread identification 97 * - ARG3 - destination address in the caller's address space 98 * 99 * or, on error, retval will be 100 * - ENOENT - thread does not exist 101 * - EBUSY - register state not available 102 */ 103 UDEBUG_M_REGS_READ, 104 105 /** Read the list of the debugged tasks's threads. 106 * 107 * - ARG2 - destination address in the caller's address space 108 * - ARG3 - size of receiving buffer in bytes 109 * 110 * The kernel fills the buffer with a series of sysarg_t values 111 * (thread ids). On answer, the kernel will set: 112 * 113 * - ARG2 - number of bytes that were actually copied 114 * - ARG3 - number of bytes of the complete data 115 * 116 */ 117 UDEBUG_M_THREAD_READ, 118 119 /** Read the name of the debugged task. 120 * 121 * - ARG2 - destination address in the caller's address space 122 * - ARG3 - size of receiving buffer in bytes 123 * 124 * The kernel fills the buffer with a non-terminated string. 125 * 126 * - ARG2 - number of bytes that were actually copied 127 * - ARG3 - number of bytes of the complete data 128 * 129 */ 130 UDEBUG_M_NAME_READ, 131 132 /** Read the list of the debugged task's address space areas. 133 * 134 * - ARG2 - destination address in the caller's address space 135 * - ARG3 - size of receiving buffer in bytes 136 * 137 * The kernel fills the buffer with a series of as_area_info_t structures. 138 * Upon answer, the kernel will set: 139 * 140 * - ARG2 - number of bytes that were actually copied 141 * - ARG3 - number of bytes of the complete data 142 * 143 */ 144 UDEBUG_M_AREAS_READ, 145 146 /** Read the debugged tasks's memory. 147 * 148 * - ARG2 - destination address in the caller's address space 149 * - ARG3 - source address in the recipient's address space 150 * - ARG4 - size of receiving buffer in bytes 151 * 152 */ 153 UDEBUG_M_MEM_READ 154 } udebug_method_t; 155 156 typedef enum { 157 UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ 158 UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */ 159 UDEBUG_EVENT_SYSCALL_B, /**< Before beginning syscall execution */ 160 UDEBUG_EVENT_SYSCALL_E, /**< After finishing syscall execution */ 161 UDEBUG_EVENT_THREAD_B, /**< The task created a new thread */ 162 UDEBUG_EVENT_THREAD_E /**< A thread exited */ 163 } udebug_event_t; 164 165 typedef enum { 166 UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED), 167 UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP), 168 UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B), 169 UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E), 170 UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B), 171 UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E), 172 UDEBUG_EM_ALL = 173 (UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) | 174 UDEBUG_EVMASK(UDEBUG_EVENT_STOP) | 175 UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) | 176 UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) | 177 UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) | 178 UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E)) 179 } udebug_evmask_t; 180 181 #ifdef KERNEL 182 38 #include <abi/udebug.h> 183 39 #include <ipc/ipc.h> 184 40 #include <synch/mutex.h> … … 251 107 #endif 252 108 253 #endif254 255 109 /** @} 256 110 */ -
kernel/generic/src/adt/btree.c
r867e2555 r925a21e 38 38 * 39 39 * The B+tree has the following properties: 40 * @li it is a bal lanced 3-4-5 tree (i.e. BTREE_M = 5)40 * @li it is a balanced 3-4-5 tree (i.e. BTREE_M = 5) 41 41 * @li values (i.e. pointers to values) are stored only in leaves 42 42 * @li leaves are linked in a list 43 43 * 44 * Be careful lwhen using these trees. They need to allocate44 * Be careful when using these trees. They need to allocate 45 45 * and deallocate memory for their index nodes and as such 46 46 * can sleep. … … 146 146 * also makes use of this feature. 147 147 * 148 * @param node B-tree node into w ich the new key is to be inserted.148 * @param node B-tree node into which the new key is to be inserted. 149 149 * @param key The key to be inserted. 150 150 * @param value Pointer to value to be inserted. … … 270 270 * This feature is used during insert by right rotation. 271 271 * 272 * @param node B-tree node into w ich the new key is to be inserted.272 * @param node B-tree node into which the new key is to be inserted. 273 273 * @param key The key to be inserted. 274 274 * @param value Pointer to value to be inserted. … … 463 463 if (rnode->keys < BTREE_MAX_KEYS) { 464 464 /* 465 * The rota ion can be done. The right sibling has free space.465 * The rotation can be done. The right sibling has free space. 466 466 */ 467 467 node_insert_key_and_rsubtree(node, inskey, insvalue, rsubtree); … … 484 484 * the median will be copied there. 485 485 * 486 * @param node B-tree node w ich is going to be split.486 * @param node B-tree node which is going to be split. 487 487 * @param key The key to be inserted. 488 488 * @param value Pointer to the value to be inserted. … … 562 562 if (node->keys < BTREE_MAX_KEYS) { 563 563 /* 564 * Node con atins enough space, the key can be stored immediately.564 * Node contains enough space, the key can be stored immediately. 565 565 */ 566 566 node_insert_key_and_rsubtree(node, key, value, rsubtree); … … 806 806 807 807 /* 808 * The key can be immediatel ly removed.808 * The key can be immediately removed. 809 809 * 810 810 * Note that the right subtree is removed because when -
kernel/generic/src/adt/list.c
r867e2555 r925a21e 33 33 /** 34 34 * @file 35 * @brief Functions completing doubly linked circular list implementa ion.35 * @brief Functions completing doubly linked circular list implementation. 36 36 * 37 37 * This file contains some of the functions implementing doubly linked circular lists. … … 49 49 * @param list List to look in. 50 50 * 51 * @return true if link is contained in head, false otherwise.51 * @return true if link is contained in list, false otherwise. 52 52 * 53 53 */ -
kernel/generic/src/console/console.c
r867e2555 r925a21e 248 248 } 249 249 250 void klog_update(void )250 void klog_update(void *event) 251 251 { 252 252 if (!atomic_get(&klog_inited)) … … 327 327 /* Force notification on newline */ 328 328 if (ch == '\n') 329 klog_update( );329 klog_update(NULL); 330 330 } 331 331 … … 358 358 free(data); 359 359 } else 360 klog_update( );360 klog_update(NULL); 361 361 362 362 return size; -
kernel/generic/src/ddi/ddi.c
r867e2555 r925a21e 41 41 42 42 #include <ddi/ddi.h> 43 #include <ddi/ddi_arg.h>44 43 #include <proc/task.h> 45 44 #include <security/cap.h> -
kernel/generic/src/ipc/event.c
r867e2555 r925a21e 36 36 37 37 #include <ipc/event.h> 38 #include <ipc/event_types.h>39 38 #include <mm/slab.h> 40 39 #include <typedefs.h> 41 40 #include <synch/spinlock.h> 42 41 #include <console/console.h> 42 #include <proc/task.h> 43 43 #include <memstr.h> 44 44 #include <errno.h> … … 48 48 static event_t events[EVENT_END]; 49 49 50 static void event_initialize(event_t *event) 51 { 52 spinlock_initialize(&event->lock, "event.lock"); 53 event->answerbox = NULL; 54 event->counter = 0; 55 event->imethod = 0; 56 event->masked = false; 57 event->unmask_callback = NULL; 58 } 59 60 static event_t *evno2event(int evno, task_t *t) 61 { 62 ASSERT(evno < EVENT_TASK_END); 63 64 event_t *event; 65 66 if (evno < EVENT_END) 67 event = &events[(event_type_t) evno]; 68 else 69 event = &t->events[(event_task_type_t) evno - EVENT_END]; 70 71 return event; 72 } 73 50 74 /** Initialize kernel events. 51 75 * … … 53 77 void event_init(void) 54 78 { 55 for (unsigned int i = 0; i < EVENT_END; i++) { 56 spinlock_initialize(&events[i].lock, "event.lock"); 57 events[i].answerbox = NULL; 58 events[i].counter = 0; 59 events[i].imethod = 0; 60 events[i].masked = false; 61 events[i].unmask_callback = NULL; 62 } 63 } 79 for (unsigned int i = 0; i < EVENT_END; i++) 80 event_initialize(evno2event(i, NULL)); 81 } 82 83 void event_task_init(task_t *task) 84 { 85 for (unsigned int i = EVENT_END; i < EVENT_TASK_END; i++) 86 event_initialize(evno2event(i, task)); 87 } 88 64 89 65 90 /** Unsubscribe kernel events associated with an answerbox … … 84 109 } 85 110 111 static void _event_set_unmask_callback(event_t *event, event_callback_t callback) 112 { 113 spinlock_lock(&event->lock); 114 event->unmask_callback = callback; 115 spinlock_unlock(&event->lock); 116 } 117 86 118 /** Define a callback function for the event unmask event. 87 119 * … … 95 127 ASSERT(evno < EVENT_END); 96 128 97 spinlock_lock(&events[evno].lock); 98 events[evno].unmask_callback = callback; 99 spinlock_unlock(&events[evno].lock); 129 _event_set_unmask_callback(evno2event(evno, NULL), callback); 130 } 131 132 void event_task_set_unmask_callback(task_t *task, event_task_type_t evno, 133 event_callback_t callback) 134 { 135 ASSERT(evno >= (int) EVENT_END); 136 ASSERT(evno < EVENT_TASK_END); 137 138 _event_set_unmask_callback(evno2event(evno, task), callback); 139 } 140 141 static int event_enqueue(event_t *event, bool mask, sysarg_t a1, sysarg_t a2, 142 sysarg_t a3, sysarg_t a4, sysarg_t a5) 143 { 144 int res; 145 146 spinlock_lock(&event->lock); 147 148 if (event->answerbox != NULL) { 149 if (!event->masked) { 150 call_t *call = ipc_call_alloc(FRAME_ATOMIC); 151 152 if (call) { 153 call->flags |= IPC_CALL_NOTIF; 154 call->priv = ++event->counter; 155 156 IPC_SET_IMETHOD(call->data, event->imethod); 157 IPC_SET_ARG1(call->data, a1); 158 IPC_SET_ARG2(call->data, a2); 159 IPC_SET_ARG3(call->data, a3); 160 IPC_SET_ARG4(call->data, a4); 161 IPC_SET_ARG5(call->data, a5); 162 163 call->data.task_id = TASK ? TASK->taskid : 0; 164 165 irq_spinlock_lock(&event->answerbox->irq_lock, true); 166 list_append(&call->link, &event->answerbox->irq_notifs); 167 irq_spinlock_unlock(&event->answerbox->irq_lock, true); 168 169 waitq_wakeup(&event->answerbox->wq, WAKEUP_FIRST); 170 171 if (mask) 172 event->masked = true; 173 174 res = EOK; 175 } else 176 res = ENOMEM; 177 } else 178 res = EBUSY; 179 } else 180 res = ENOENT; 181 182 spinlock_unlock(&event->lock); 183 return res; 100 184 } 101 185 … … 124 208 ASSERT(evno < EVENT_END); 125 209 126 spinlock_lock(&events[evno].lock); 127 128 int ret; 129 130 if (events[evno].answerbox != NULL) { 131 if (!events[evno].masked) { 132 call_t *call = ipc_call_alloc(FRAME_ATOMIC); 133 134 if (call) { 135 call->flags |= IPC_CALL_NOTIF; 136 call->priv = ++events[evno].counter; 137 138 IPC_SET_IMETHOD(call->data, events[evno].imethod); 139 IPC_SET_ARG1(call->data, a1); 140 IPC_SET_ARG2(call->data, a2); 141 IPC_SET_ARG3(call->data, a3); 142 IPC_SET_ARG4(call->data, a4); 143 IPC_SET_ARG5(call->data, a5); 144 145 irq_spinlock_lock(&events[evno].answerbox->irq_lock, true); 146 list_append(&call->link, &events[evno].answerbox->irq_notifs); 147 irq_spinlock_unlock(&events[evno].answerbox->irq_lock, true); 148 149 waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST); 150 151 if (mask) 152 events[evno].masked = true; 153 154 ret = EOK; 155 } else 156 ret = ENOMEM; 157 } else 158 ret = EBUSY; 159 } else 160 ret = ENOENT; 161 162 spinlock_unlock(&events[evno].lock); 163 164 return ret; 210 return event_enqueue(evno2event(evno, NULL), mask, a1, a2, a3, a4, a5); 211 } 212 213 /** Send per-task kernel notification event 214 * 215 * @param task Destination task. 216 * @param evno Event type. 217 * @param mask Mask further notifications after a successful 218 * sending. 219 * @param a1 First argument. 220 * @param a2 Second argument. 221 * @param a3 Third argument. 222 * @param a4 Fourth argument. 223 * @param a5 Fifth argument. 224 * 225 * @return EOK if notification was successfully sent. 226 * @return ENOMEM if the notification IPC message failed to allocate. 227 * @return EBUSY if the notifications of the given type are 228 * currently masked. 229 * @return ENOENT if the notifications of the given type are 230 * currently not subscribed. 231 * 232 */ 233 int event_task_notify(task_t *task, event_task_type_t evno, bool mask, 234 sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4, sysarg_t a5) 235 { 236 ASSERT(evno >= (int) EVENT_END); 237 ASSERT(evno < EVENT_TASK_END); 238 239 return event_enqueue(evno2event(evno, task), mask, a1, a2, a3, a4, a5); 165 240 } 166 241 … … 177 252 * 178 253 */ 179 static int event_subscribe(event_t ype_t evno, sysarg_t imethod,254 static int event_subscribe(event_t *event, sysarg_t imethod, 180 255 answerbox_t *answerbox) 181 256 { 182 ASSERT(evno < EVENT_END);183 184 spinlock_lock(&events[evno].lock);185 186 257 int res; 187 188 if (events[evno].answerbox == NULL) { 189 events[evno].answerbox = answerbox; 190 events[evno].imethod = imethod; 191 events[evno].counter = 0; 192 events[evno].masked = false; 258 259 spinlock_lock(&event->lock); 260 261 if (event->answerbox == NULL) { 262 event->answerbox = answerbox; 263 event->imethod = imethod; 264 event->counter = 0; 265 event->masked = false; 193 266 res = EOK; 194 267 } else 195 268 res = EEXISTS; 196 269 197 spinlock_unlock(&event s[evno].lock);270 spinlock_unlock(&event->lock); 198 271 199 272 return res; … … 205 278 * 206 279 */ 207 static void event_unmask(event_type_t evno) 208 { 209 ASSERT(evno < EVENT_END); 210 211 spinlock_lock(&events[evno].lock); 212 events[evno].masked = false; 213 event_callback_t callback = events[evno].unmask_callback; 214 spinlock_unlock(&events[evno].lock); 280 static void event_unmask(event_t *event) 281 { 282 spinlock_lock(&event->lock); 283 event->masked = false; 284 event_callback_t callback = event->unmask_callback; 285 spinlock_unlock(&event->lock); 215 286 216 287 /* … … 219 290 */ 220 291 if (callback != NULL) 221 callback( );292 callback(event); 222 293 } 223 294 … … 236 307 sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod) 237 308 { 238 if (evno >= EVENT_ END)309 if (evno >= EVENT_TASK_END) 239 310 return ELIMIT; 240 311 241 return (sysarg_t) event_subscribe( (event_type_t) evno, (sysarg_t)242 imethod, &TASK->answerbox);312 return (sysarg_t) event_subscribe(evno2event(evno, TASK), 313 (sysarg_t) imethod, &TASK->answerbox); 243 314 } 244 315 … … 258 329 sysarg_t sys_event_unmask(sysarg_t evno) 259 330 { 260 if (evno >= EVENT_ END)331 if (evno >= EVENT_TASK_END) 261 332 return ELIMIT; 262 333 263 event_unmask((event_type_t) evno); 334 event_unmask(evno2event(evno, TASK)); 335 264 336 return EOK; 265 337 } -
kernel/generic/src/ipc/ipc.c
r867e2555 r925a21e 38 38 */ 39 39 40 #include <synch/synch.h>41 40 #include <synch/spinlock.h> 42 41 #include <synch/mutex.h> 43 42 #include <synch/waitq.h> 44 #include <synch/synch.h>45 43 #include <ipc/ipc.h> 46 #include < ipc/ipc_methods.h>44 #include <abi/ipc/methods.h> 47 45 #include <ipc/kbox.h> 48 46 #include <ipc/event.h> … … 232 230 } 233 231 } 232 233 call->data.task_id = TASK->taskid; 234 234 235 235 if (do_lock) … … 296 296 atomic_inc(&phone->active_calls); 297 297 call->data.phone = phone; 298 call->data.task = TASK;298 call->data.task_id = TASK->taskid; 299 299 } 300 300 … … 408 408 call->caller_phone = call->data.phone; 409 409 call->data.phone = newphone; 410 call->data.task = TASK;410 call->data.task_id = TASK->taskid; 411 411 } 412 412 -
kernel/generic/src/ipc/kbox.c
r867e2555 r925a21e 33 33 */ 34 34 35 #include <synch/synch.h>36 35 #include <synch/spinlock.h> 37 36 #include <synch/mutex.h> 38 37 #include <ipc/ipc.h> 39 #include < ipc/ipc_methods.h>38 #include <abi/ipc/methods.h> 40 39 #include <ipc/ipcrsc.h> 41 40 #include <arch.h> -
kernel/generic/src/ipc/sysipc.c
r867e2555 r925a21e 40 40 #include <debug.h> 41 41 #include <ipc/ipc.h> 42 #include < ipc/ipc_methods.h>42 #include <abi/ipc/methods.h> 43 43 #include <ipc/sysipc.h> 44 44 #include <ipc/irq.h> 45 45 #include <ipc/ipcrsc.h> 46 #include <ipc/event.h> 46 47 #include <ipc/kbox.h> 47 48 #include <synch/waitq.h> … … 53 54 #include <mm/as.h> 54 55 #include <print.h> 56 #include <macros.h> 55 57 56 58 /** … … 134 136 case IPC_M_DATA_WRITE: 135 137 case IPC_M_DATA_READ: 138 case IPC_M_STATE_CHANGE_AUTHORIZE: 136 139 return true; 137 140 default: … … 164 167 case IPC_M_DATA_WRITE: 165 168 case IPC_M_DATA_READ: 169 case IPC_M_STATE_CHANGE_AUTHORIZE: 166 170 return true; 167 171 default: … … 249 253 /* The connection was accepted */ 250 254 phone_connect(phoneid, &answer->sender->answerbox); 251 /* Set 'task hash' as arg4 of response */252 IPC_SET_ARG4(answer->data, (sysarg_t) TASK);253 255 /* Set 'phone hash' as arg5 of response */ 254 256 IPC_SET_ARG5(answer->data, … … 334 336 free(answer->buffer); 335 337 answer->buffer = NULL; 338 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_STATE_CHANGE_AUTHORIZE) { 339 if (!IPC_GET_RETVAL(answer->data)) { 340 /* The recipient authorized the change of state. */ 341 phone_t *recipient_phone; 342 task_t *other_task_s; 343 task_t *other_task_r; 344 int rc; 345 346 rc = phone_get(IPC_GET_ARG1(answer->data), 347 &recipient_phone); 348 if (rc != EOK) { 349 IPC_SET_RETVAL(answer->data, ENOENT); 350 return ENOENT; 351 } 352 353 mutex_lock(&recipient_phone->lock); 354 if (recipient_phone->state != IPC_PHONE_CONNECTED) { 355 mutex_unlock(&recipient_phone->lock); 356 IPC_SET_RETVAL(answer->data, EINVAL); 357 return EINVAL; 358 } 359 360 other_task_r = recipient_phone->callee->task; 361 other_task_s = (task_t *) IPC_GET_ARG5(*olddata); 362 363 /* 364 * See if both the sender and the recipient meant the 365 * same third party task. 366 */ 367 if (other_task_r != other_task_s) { 368 IPC_SET_RETVAL(answer->data, EINVAL); 369 rc = EINVAL; 370 } else { 371 rc = event_task_notify_5(other_task_r, 372 EVENT_TASK_STATE_CHANGE, false, 373 IPC_GET_ARG1(*olddata), 374 IPC_GET_ARG2(*olddata), 375 IPC_GET_ARG3(*olddata), 376 LOWER32(olddata->task_id), 377 UPPER32(olddata->task_id)); 378 IPC_SET_RETVAL(answer->data, rc); 379 } 380 381 mutex_unlock(&recipient_phone->lock); 382 return rc; 383 } 336 384 } 337 385 … … 427 475 case IPC_M_DATA_READ: { 428 476 size_t size = IPC_GET_ARG2(call->data); 429 if (size <= 0)430 return ELIMIT;431 477 if (size > DATA_XFER_LIMIT) { 432 478 int flags = IPC_GET_ARG3(call->data); … … 458 504 } 459 505 506 break; 507 } 508 case IPC_M_STATE_CHANGE_AUTHORIZE: { 509 phone_t *sender_phone; 510 task_t *other_task_s; 511 512 if (phone_get(IPC_GET_ARG5(call->data), &sender_phone) != EOK) 513 return ENOENT; 514 515 mutex_lock(&sender_phone->lock); 516 if (sender_phone->state != IPC_PHONE_CONNECTED) { 517 mutex_unlock(&sender_phone->lock); 518 return EINVAL; 519 } 520 521 other_task_s = sender_phone->callee->task; 522 523 mutex_unlock(&sender_phone->lock); 524 525 /* Remember the third party task hash. */ 526 IPC_SET_ARG5(call->data, (sysarg_t) other_task_s); 460 527 break; 461 528 } -
kernel/generic/src/mm/frame.c
r867e2555 r925a21e 1142 1142 size_t znum = find_zone(pfn, 1, 0); 1143 1143 1144 1145 1144 ASSERT(znum != (size_t) -1); 1146 1145 -
kernel/generic/src/mm/slab.c
r867e2555 r925a21e 180 180 unsigned int flags) 181 181 { 182 183 184 182 size_t zone = 0; 185 183 -
kernel/generic/src/printf/printf_core.c
r867e2555 r925a21e 75 75 #define PRINT_NUMBER_BUFFER_SIZE (64 + 5) 76 76 77 /** Get signed or unsigned integer argument */ 78 #define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \ 79 ({ \ 80 unsigned type res; \ 81 \ 82 if ((flags) & __PRINTF_FLAG_SIGNED) { \ 83 signed type arg = va_arg((ap), signed type); \ 84 \ 85 if (arg < 0) { \ 86 res = -arg; \ 87 (flags) |= __PRINTF_FLAG_NEGATIVE; \ 88 } else \ 89 res = arg; \ 90 } else \ 91 res = va_arg((ap), unsigned type); \ 92 \ 93 res; \ 94 }) 95 77 96 /** Enumeration of possible arguments types. 78 97 */ … … 207 226 } 208 227 209 return (int) (counter + 1);228 return (int) (counter); 210 229 } 211 230 … … 245 264 } 246 265 247 return (int) (counter + 1);266 return (int) (counter); 248 267 } 249 268 … … 832 851 size_t size; 833 852 uint64_t number; 853 834 854 switch (qualifier) { 835 855 case PrintfQualifierByte: 836 856 size = sizeof(unsigned char); 837 number = (uint64_t) va_arg(ap, unsigned int);857 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 838 858 break; 839 859 case PrintfQualifierShort: 840 860 size = sizeof(unsigned short); 841 number = (uint64_t) va_arg(ap, unsigned int);861 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 842 862 break; 843 863 case PrintfQualifierInt: 844 864 size = sizeof(unsigned int); 845 number = (uint64_t) va_arg(ap, unsigned int);865 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 846 866 break; 847 867 case PrintfQualifierLong: 848 868 size = sizeof(unsigned long); 849 number = (uint64_t) va_arg(ap, unsigned long);869 number = PRINTF_GET_INT_ARGUMENT(long, ap, flags); 850 870 break; 851 871 case PrintfQualifierLongLong: 852 872 size = sizeof(unsigned long long); 853 number = (uint64_t) va_arg(ap, unsigned long long);873 number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags); 854 874 break; 855 875 case PrintfQualifierPointer: … … 866 886 counter = -counter; 867 887 goto out; 868 }869 870 if (flags & __PRINTF_FLAG_SIGNED) {871 if (number & (0x1 << (size * 8 - 1))) {872 flags |= __PRINTF_FLAG_NEGATIVE;873 874 if (size == sizeof(uint64_t)) {875 number = -((int64_t) number);876 } else {877 number = ~number;878 number &=879 ~(0xFFFFFFFFFFFFFFFFll <<880 (size * 8));881 number++;882 }883 }884 888 } 885 889 -
kernel/generic/src/proc/program.c
r867e2555 r925a21e 40 40 #include <proc/thread.h> 41 41 #include <proc/task.h> 42 #include <proc/uarg.h>43 42 #include <mm/as.h> 44 43 #include <mm/slab.h> -
kernel/generic/src/proc/task.c
r867e2555 r925a21e 50 50 #include <ipc/ipc.h> 51 51 #include <ipc/ipcrsc.h> 52 #include <ipc/event.h> 52 53 #include <print.h> 53 54 #include <errno.h> … … 57 58 #include <syscall/copy.h> 58 59 #include <macros.h> 59 #include <ipc/event.h>60 60 61 61 /** Spinlock protecting the tasks_tree AVL tree. */ … … 201 201 task->ipc_info.irq_notif_received = 0; 202 202 task->ipc_info.forwarded = 0; 203 204 event_task_init(task); 203 205 204 206 #ifdef CONFIG_UDEBUG -
kernel/generic/src/proc/thread.c
r867e2555 r925a21e 39 39 #include <proc/thread.h> 40 40 #include <proc/task.h> 41 #include <proc/uarg.h>42 41 #include <mm/frame.h> 43 42 #include <mm/page.h> … … 45 44 #include <arch/cycle.h> 46 45 #include <arch.h> 47 #include <synch/synch.h>48 46 #include <synch/spinlock.h> 49 47 #include <synch/waitq.h> -
kernel/generic/src/synch/condvar.c
r867e2555 r925a21e 39 39 #include <synch/mutex.h> 40 40 #include <synch/waitq.h> 41 #include <synch/synch.h>42 41 #include <arch.h> 43 42 -
kernel/generic/src/synch/futex.c
r867e2555 r925a21e 39 39 #include <synch/mutex.h> 40 40 #include <synch/spinlock.h> 41 #include <synch/synch.h>42 41 #include <mm/frame.h> 43 42 #include <mm/page.h> -
kernel/generic/src/synch/mutex.c
r867e2555 r925a21e 38 38 #include <synch/mutex.h> 39 39 #include <synch/semaphore.h> 40 #include <synch/synch.h>41 40 #include <debug.h> 42 41 #include <arch.h> -
kernel/generic/src/synch/semaphore.c
r867e2555 r925a21e 39 39 #include <synch/waitq.h> 40 40 #include <synch/spinlock.h> 41 #include <synch/synch.h>42 41 #include <arch/asm.h> 43 42 #include <arch.h> -
kernel/generic/src/synch/waitq.c
r867e2555 r925a21e 45 45 46 46 #include <synch/waitq.h> 47 #include <synch/synch.h>48 47 #include <synch/spinlock.h> 49 48 #include <proc/thread.h> -
kernel/generic/src/syscall/syscall.c
r867e2555 r925a21e 181 181 182 182 /* Sysinfo syscalls. */ 183 (syshandler_t) sys_sysinfo_get_ tag,183 (syshandler_t) sys_sysinfo_get_val_type, 184 184 (syshandler_t) sys_sysinfo_get_value, 185 185 (syshandler_t) sys_sysinfo_get_data_size, -
kernel/generic/src/sysinfo/stats.c
r867e2555 r925a21e 35 35 36 36 #include <typedefs.h> 37 #include < sysinfo/abi.h>37 #include <abi/sysinfo.h> 38 38 #include <sysinfo/stats.h> 39 39 #include <sysinfo/sysinfo.h> -
kernel/generic/src/sysinfo/sysinfo.c
r867e2555 r925a21e 661 661 * 662 662 */ 663 sysarg_t sys_sysinfo_get_ tag(void *path_ptr, size_t path_size)663 sysarg_t sys_sysinfo_get_val_type(void *path_ptr, size_t path_size) 664 664 { 665 665 /*
Note:
See TracChangeset
for help on using the changeset viewer.
