Changeset da1bafb in mainline for kernel/generic/include
- Timestamp:
- 2010-05-24T18:57:31Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0095368
- Parents:
- 666f492
- Location:
- kernel/generic/include
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/console/chardev.h
r666f492 rda1bafb 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; … … 95 95 } outdev_t; 96 96 97 extern void indev_initialize(const char * name, indev_t *indev,98 indev_operations_t * op);99 extern void indev_push_character(indev_t * indev, wchar_t ch);100 extern wchar_t indev_pop_character(indev_t * indev);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(const char * 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/cpu.h
r666f492 rda1bafb 42 42 #include <arch/context.h> 43 43 44 #define CPU_STACK_SIZE 44 #define CPU_STACK_SIZE STACK_SIZE 45 45 46 46 /** CPU structure. … … 49 49 */ 50 50 typedef struct cpu { 51 SPINLOCK_DECLARE(lock);52 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 70 74 bool idle; 71 75 uint64_t idle_ticks; 72 76 uint64_t busy_ticks; 73 77 74 78 /** 75 79 * Processor ID assigned by kernel. 76 80 */ 77 unsigned int id;81 size_t id; 78 82 79 83 bool active; 80 inttlb_active;81 84 bool tlb_active; 85 82 86 uint16_t frequency_mhz; 83 87 uint32_t delay_loop_const; 84 88 85 89 cpu_arch_t arch; 86 90 87 91 struct thread *fpu_owner; 88 92 … … 100 104 extern void cpu_arch_init(void); 101 105 extern void cpu_identify(void); 102 extern void cpu_print_report(cpu_t * m);106 extern void cpu_print_report(cpu_t *); 103 107 104 108 #endif -
kernel/generic/include/ddi/ddi.h
r666f492 rda1bafb 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_preempt_control(int); 58 57 59 58 /* 60 59 * Interface to be implemented by all architectures. 61 60 */ 62 extern int ddi_iospace_enable_arch(task_t * task, uintptr_t ioaddr, size_t size);61 extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t); 63 62 64 63 #endif -
kernel/generic/include/ddi/ddi_arg.h
r666f492 rda1bafb 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; 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/irq.h
r666f492 rda1bafb 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 <typedefs.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, 92 IRQ_ACCEPT 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/interrupt.h
r666f492 rda1bafb 44 44 #include <stacktrace.h> 45 45 46 typedef void (* iroutine)(int n, istate_t *istate);46 typedef void (* iroutine)(int, istate_t *); 47 47 48 extern void fault_if_from_uspace(istate_t * istate, const 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);48 extern void fault_if_from_uspace(istate_t *, const char *, ...); 49 extern iroutine exc_register(int, const char *, iroutine); 50 extern void exc_dispatch(int, istate_t *); 51 extern void exc_init(void); 52 52 53 extern void irq_initialize_arch(irq_t * irq);53 extern void irq_initialize_arch(irq_t *); 54 54 55 55 #endif -
kernel/generic/include/ipc/ipc.h
r666f492 rda1bafb 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 81 #define IPC_CALLID_NOTIFICATION 2 71 82 72 83 /* Return values from sys_ipc_call_async(). */ 73 #define IPC_CALLRET_FATAL 74 #define IPC_CALLRET_TEMPORARY 84 #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) 79 #define IPC_SET_METHOD(data, val) 80 #define IPC_SET_ARG1(data, val) 81 #define IPC_SET_ARG2(data, val) 82 #define IPC_SET_ARG3(data, val) 83 #define IPC_SET_ARG4(data, val) 84 #define IPC_SET_ARG5(data, val) 85 86 #define IPC_GET_METHOD(data) 87 #define IPC_GET_RETVAL(data) 88 89 #define IPC_GET_ARG1(data) 90 #define IPC_GET_ARG2(data) 91 #define IPC_GET_ARG3(data) 92 #define IPC_GET_ARG4(data) 93 #define IPC_GET_ARG5(data) 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 107 #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 254 #define IPC_FIRST_USER_METHOD 1024 226 255 227 256 #ifdef KERNEL … … 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; 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
r666f492 rda1bafb 37 37 38 38 /** Maximum length of IPC IRQ program */ 39 #define IRQ_MAX_PROG_SIZE 39 #define IRQ_MAX_PROG_SIZE 20 40 40 41 41 #include <ipc/ipc.h> … … 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 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
r666f492 rda1bafb 40 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(unative_t 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/mm/as.h
r666f492 rda1bafb 43 43 44 44 /** Address space area flags. */ 45 #define AS_AREA_READ 46 #define AS_AREA_WRITE 47 #define AS_AREA_EXEC 48 #define AS_AREA_CACHEABLE 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 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 … … 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 92 #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 102 #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); 143 149 } as_operations_t; 144 150 … … 146 152 * This structure contains information associated with the shared address space 147 153 * area. 154 * 148 155 */ 149 156 typedef struct { 150 157 /** This lock must be acquired only when the as_area lock is held. */ 151 mutex_t lock; 158 mutex_t lock; 152 159 /** This structure can be deallocated if refcount drops to 0. */ 153 160 size_t refcount; 161 154 162 /** 155 163 * B+tree containing complete map of anonymous pages of the shared area. … … 169 177 /** Backend data stored in address space area. */ 170 178 typedef union mem_backend_data { 171 struct { /**< elf_backend members */ 179 /** elf_backend members */ 180 struct { 172 181 elf_header_t *elf; 173 182 elf_segment_header_t *segment; 174 183 }; 175 struct { /**< phys_backend members */ 184 185 /** phys_backend members */ 186 struct { 176 187 uintptr_t base; 177 188 size_t frames; … … 182 193 * 183 194 * Each as_area_t structure describes one contiguous area of virtual memory. 195 * 184 196 */ 185 197 typedef struct { 186 198 mutex_t lock; 187 199 /** Containing address space. */ 188 as_t *as; 200 as_t *as; 201 189 202 /** 190 203 * Flags related to the memory represented by the address space area. 191 204 */ 192 int flags; 205 unsigned int flags; 206 193 207 /** Attributes related to the address space area itself. */ 194 int attributes;208 unsigned int attributes; 195 209 /** Size of this area in multiples of PAGE_SIZE. */ 196 210 size_t pages; … … 199 213 /** Map of used space. */ 200 214 btree_t used_space; 201 215 202 216 /** 203 217 * If the address space area has been shared, this pointer will … … 205 219 */ 206 220 share_info_t *sh_info; 207 221 208 222 /** Memory backend backing this address space area. */ 209 223 struct mem_backend *backend; 210 224 211 225 /** Data to be used by the backend. */ 212 226 mem_backend_data_t backend_data; … … 215 229 /** Address space area backend structure. */ 216 230 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);231 int (* page_fault)(as_area_t *, uintptr_t, pf_access_t); 232 void (* frame_free)(as_area_t *, uintptr_t, uintptr_t); 233 void (* share)(as_area_t *); 220 234 } mem_backend_t; 221 235 … … 227 241 extern void as_init(void); 228 242 229 extern as_t *as_create( int);243 extern as_t *as_create(unsigned int); 230 244 extern void as_destroy(as_t *); 231 245 extern void as_hold(as_t *); … … 234 248 extern int as_page_fault(uintptr_t, pf_access_t, istate_t *); 235 249 236 extern as_area_t *as_area_create(as_t *, int, size_t, uintptr_t, int,237 mem_backend_t *, mem_backend_data_t *);250 extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t, 251 unsigned int, mem_backend_t *, mem_backend_data_t *); 238 252 extern int as_area_destroy(as_t *, uintptr_t); 239 extern int as_area_resize(as_t *, uintptr_t, size_t, int); 240 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, int); 241 extern int as_area_change_flags(as_t *, int, uintptr_t); 242 243 extern int as_area_get_flags(as_area_t *); 253 extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int); 254 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, 255 unsigned int); 256 extern int as_area_change_flags(as_t *, unsigned int, uintptr_t); 257 258 extern unsigned int as_area_get_flags(as_area_t *); 244 259 extern bool as_area_check_access(as_area_t *, pf_access_t); 245 260 extern size_t as_area_get_size(uintptr_t); … … 249 264 250 265 /* Interface to be implemented by architectures. */ 266 251 267 #ifndef as_constructor_arch 252 extern int as_constructor_arch(as_t *, int);268 extern int as_constructor_arch(as_t *, unsigned int); 253 269 #endif /* !def as_constructor_arch */ 270 254 271 #ifndef as_destructor_arch 255 272 extern int as_destructor_arch(as_t *); 256 273 #endif /* !def as_destructor_arch */ 274 257 275 #ifndef as_create_arch 258 extern int as_create_arch(as_t *, int);276 extern int as_create_arch(as_t *, unsigned int); 259 277 #endif /* !def as_create_arch */ 278 260 279 #ifndef as_install_arch 261 280 extern void as_install_arch(as_t *); 262 281 #endif /* !def as_install_arch */ 282 263 283 #ifndef as_deinstall_arch 264 284 extern void as_deinstall_arch(as_t *); … … 270 290 extern mem_backend_t phys_backend; 271 291 272 /** 292 /** 273 293 * This flags is passed when running the loader, otherwise elf_load() 274 294 * 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 *, as_t *, int); 295 * 296 */ 297 #define ELD_F_NONE 0 298 #define ELD_F_LOADER 1 299 300 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int); 280 301 281 302 /* Address space area related syscalls. */ 282 extern unative_t sys_as_area_create(uintptr_t, size_t, int);283 extern unative_t sys_as_area_resize(uintptr_t, size_t, int);284 extern unative_t sys_as_area_change_flags(uintptr_t, int);303 extern unative_t sys_as_area_create(uintptr_t, size_t, unsigned int); 304 extern unative_t sys_as_area_resize(uintptr_t, size_t, unsigned int); 305 extern unative_t sys_as_area_change_flags(uintptr_t, unsigned int); 285 306 extern unative_t sys_as_area_destroy(uintptr_t); 286 307 -
kernel/generic/include/mm/frame.h
r666f492 rda1bafb 81 81 82 82 typedef struct { 83 size_t refcount; /**< Tracking of shared frames */83 size_t refcount; /**< Tracking of shared frames */ 84 84 uint8_t buddy_order; /**< Buddy system block order */ 85 85 link_t buddy_link; /**< Link to the next free block inside … … 91 91 pfn_t base; /**< Frame_no of the first frame 92 92 in the frames array */ 93 size_t count; /**< Size of zone */94 size_t free_count; /**< Number of free frame_t93 size_t count; /**< Size of zone */ 94 size_t free_count; /**< Number of free frame_t 95 95 structures */ 96 size_t busy_count; /**< Number of busy frame_t96 size_t busy_count; /**< Number of busy frame_t 97 97 structures */ 98 98 zone_flags_t flags; /**< Type of the zone */ … … 108 108 */ 109 109 typedef struct { 110 SPINLOCK_DECLARE(lock);110 IRQ_SPINLOCK_DECLARE(lock); 111 111 size_t count; 112 112 zone_t info[ZONES_MAX]; -
kernel/generic/include/mm/page.h
r666f492 rda1bafb 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 void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 55 extern void page_mapping_remove(as_t *, uintptr_t); 56 extern pte_t *page_mapping_find(as_t *, uintptr_t); 57 extern pte_t *page_table_create(unsigned int); 58 extern void page_table_destroy(pte_t *); 59 extern void map_structure(uintptr_t, size_t); 62 60 63 extern uintptr_t hw_map(uintptr_t physaddr, size_t size);61 extern uintptr_t hw_map(uintptr_t, size_t); 64 62 65 63 #endif -
kernel/generic/include/mm/slab.h
r666f492 rda1bafb 84 84 } slab_mag_cache_t; 85 85 86 87 86 typedef struct { 88 87 const char *name; … … 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; 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 */ … … 124 123 125 124 extern slab_cache_t *slab_cache_create(const char *, size_t, size_t, 126 int (*)(void *, int), int (*)(void *),int);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); 130 129 extern void slab_free(slab_cache_t *, void *); 131 extern size_t slab_reclaim( int);130 extern size_t slab_reclaim(unsigned int); 132 131 133 132 /* slab subsytem initialization */ … … 139 138 140 139 /* malloc support */ 141 extern void *malloc( unsigned int,int);142 extern void *realloc(void *, unsigned int,int);140 extern void *malloc(size_t, unsigned int); 141 extern void *realloc(void *, size_t, unsigned int); 143 142 extern void free(void *); 144 143 -
kernel/generic/include/proc/scheduler.h
r666f492 rda1bafb 47 47 /** Scheduler run queue structure. */ 48 48 typedef struct { 49 SPINLOCK_DECLARE(lock);50 link_t rq_head; /**< List of ready threads. */51 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. */ 52 52 } runq_t; 53 53 -
kernel/generic/include/proc/task.h
r666f492 rda1bafb 70 70 * threads. 71 71 */ 72 SPINLOCK_DECLARE(lock);73 72 IRQ_SPINLOCK_DECLARE(lock); 73 74 74 char name[TASK_NAME_BUFLEN]; 75 75 /** List of threads contained in this task. */ … … 81 81 /** Task security context. */ 82 82 context_id_t context; 83 83 84 84 /** Number of references (i.e. threads). */ 85 85 atomic_t refcount; 86 86 /** Number of threads that haven't exited yet. */ 87 87 atomic_t lifecount; 88 88 89 89 /** Task capabilities. */ 90 90 cap_t capabilities; 91 91 92 92 /* IPC stuff */ 93 93 answerbox_t answerbox; /**< Communication endpoint */ … … 101 101 /** List of synchronous answerboxes. */ 102 102 link_t sync_box_head; 103 103 104 104 #ifdef CONFIG_UDEBUG 105 105 /** Debugging stuff. */ 106 106 udebug_task_t udebug; 107 107 108 108 /** Kernel answerbox. */ 109 109 kbox_t kb; 110 #endif 111 110 #endif /* CONFIG_UDEBUG */ 111 112 112 /** Architecture specific task data. */ 113 113 task_arch_t arch; … … 126 126 } task_t; 127 127 128 SPINLOCK_EXTERN(tasks_lock);128 IRQ_SPINLOCK_EXTERN(tasks_lock); 129 129 extern avltree_t tasks_tree; 130 130 -
kernel/generic/include/proc/thread.h
r666f492 rda1bafb 50 50 #include <sysinfo/abi.h> 51 51 52 #define THREAD_STACK_SIZE 53 #define THREAD_NAME_BUFLEN 52 #define THREAD_STACK_SIZE STACK_SIZE 53 #define THREAD_NAME_BUFLEN 20 54 54 55 55 extern const char *thread_states[]; … … 61 61 * When using this flag, the caller must set cpu in the thread_t 62 62 * structure manually before calling thread_ready (even on uniprocessor). 63 */ 64 #define THREAD_FLAG_WIRED (1 << 0) 63 * 64 */ 65 #define THREAD_FLAG_WIRED (1 << 0) 66 65 67 /** Thread was migrated to another CPU and has not run yet. */ 66 #define THREAD_FLAG_STOLEN (1 << 1) 68 #define THREAD_FLAG_STOLEN (1 << 1) 69 67 70 /** Thread executes in userspace. */ 68 #define THREAD_FLAG_USPACE (1 << 2) 71 #define THREAD_FLAG_USPACE (1 << 2) 72 69 73 /** Thread will be attached by the caller. */ 70 #define THREAD_FLAG_NOATTACH 74 #define THREAD_FLAG_NOATTACH (1 << 3) 71 75 72 76 /** Thread structure. There is one per thread. */ 73 77 typedef struct thread { 74 link_t rq_link; 75 link_t wq_link; 76 link_t th_link; 77 78 link_t rq_link; /**< Run queue link. */ 79 link_t wq_link; /**< Wait queue link. */ 80 link_t th_link; /**< Links to threads within containing task. */ 81 78 82 /** Threads linkage to the threads_tree. */ 79 83 avltree_node_t threads_tree_node; … … 83 87 * Protects the whole thread structure except list links above. 84 88 */ 85 SPINLOCK_DECLARE(lock);86 89 IRQ_SPINLOCK_DECLARE(lock); 90 87 91 char name[THREAD_NAME_BUFLEN]; 88 92 89 93 /** Function implementing the thread. */ 90 94 void (* thread_code)(void *); 91 95 /** Argument passed to thread_code() function. */ 92 96 void *thread_arg; 93 97 94 98 /** 95 99 * From here, the stored context is restored when the thread is … … 107 111 */ 108 112 context_t sleep_interruption_context; 109 113 110 114 /** If true, the thread can be interrupted from sleep. */ 111 115 bool sleep_interruptible; … … 115 119 timeout_t sleep_timeout; 116 120 /** Flag signalling sleep timeout in progress. */ 117 volatile inttimeout_pending;118 121 volatile bool timeout_pending; 122 119 123 /** 120 124 * True if this thread is executing copy_from_uspace(). … … 132 136 * thread_exit() before returning to userspace. 133 137 */ 134 bool interrupted; 138 bool interrupted; 135 139 136 140 /** If true, thread_join_timeout() cannot be used on this thread. */ … … 140 144 /** Link used in the joiner_head list. */ 141 145 link_t joiner_link; 142 146 143 147 fpu_context_t *saved_fpu_context; 144 148 int fpu_context_exists; 145 149 146 150 /* 147 151 * Defined only if thread doesn't run. … … 150 154 */ 151 155 int fpu_context_engaged; 152 156 153 157 rwlock_type_t rwlock_holder_type; 154 158 155 159 /** Callback fired in scheduler before the thread is put asleep. */ 156 160 void (* call_me)(void *); 157 161 /** Argument passed to call_me(). */ 158 162 void *call_me_with; 159 163 160 164 /** Thread's state. */ 161 165 state_t state; 162 166 /** Thread's flags. */ 163 int flags;167 unsigned int flags; 164 168 165 169 /** Thread's CPU. */ … … 167 171 /** Containing task. */ 168 172 task_t *task; 169 173 170 174 /** Ticks before preemption. */ 171 175 uint64_t ticks; … … 176 180 /** Last sampled cycle. */ 177 181 uint64_t last_cycle; 178 /** Thread doesn't affect accumulated accounting. */ 182 /** Thread doesn't affect accumulated accounting. */ 179 183 bool uncounted; 180 184 181 185 /** Thread's priority. Implemented as index to CPU->rq */ 182 186 int priority; … … 186 190 /** Architecture-specific data. */ 187 191 thread_arch_t arch; 188 192 189 193 /** Thread's kernel stack. */ 190 194 uint8_t *kstack; 191 195 192 196 #ifdef CONFIG_UDEBUG 193 197 /** Debugging stuff */ 194 198 udebug_thread_t udebug; 195 #endif 196 199 #endif /* CONFIG_UDEBUG */ 197 200 } thread_t; 198 201 … … 203 206 * 204 207 */ 205 SPINLOCK_EXTERN(threads_lock);208 IRQ_SPINLOCK_EXTERN(threads_lock); 206 209 207 210 /** AVL tree containing all threads. */ … … 209 212 210 213 extern void thread_init(void); 211 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,212 const char *, bool);214 extern thread_t *thread_create(void (*)(void *), void *, task_t *, 215 unsigned int, const char *, bool); 213 216 extern void thread_attach(thread_t *, task_t *); 214 217 extern void thread_ready(thread_t *); … … 218 221 extern void thread_create_arch(thread_t *); 219 222 #endif 223 220 224 #ifndef thr_constructor_arch 221 225 extern void thr_constructor_arch(thread_t *); 222 226 #endif 227 223 228 #ifndef thr_destructor_arch 224 229 extern void thr_destructor_arch(thread_t *); … … 230 235 #define thread_join(t) \ 231 236 thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 232 extern int thread_join_timeout(thread_t *, uint32_t, int); 237 238 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int); 233 239 extern void thread_detach(thread_t *); 234 240 235 241 extern void thread_register_call_me(void (*)(void *), void *); 236 242 extern void thread_print_list(void); 237 extern void thread_destroy(thread_t * );243 extern void thread_destroy(thread_t *, bool); 238 244 extern thread_t *thread_find_by_id(thread_id_t); 239 245 extern void thread_update_accounting(bool); -
kernel/generic/include/stacktrace.h
r666f492 rda1bafb 38 38 #include <typedefs.h> 39 39 40 /* Forward declaration s. */40 /* Forward declaration. */ 41 41 struct istate; 42 42 -
kernel/generic/include/symtab.h
r666f492 rda1bafb 38 38 #include <typedefs.h> 39 39 40 #define MAX_SYMBOL_NAME 6440 #define MAX_SYMBOL_NAME 64 41 41 42 42 struct symtab_entry { … … 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/mutex.h
r666f492 rda1bafb 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 int _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int); 61 63 extern void mutex_unlock(mutex_t *); 62 64 -
kernel/generic/include/synch/rwlock.h
r666f492 rda1bafb 48 48 49 49 typedef struct { 50 SPINLOCK_DECLARE(lock); 50 IRQ_SPINLOCK_DECLARE(lock); 51 51 52 /** 52 53 * Mutex for writers, readers can bypass it if readers_in is positive. 54 * 53 55 */ 54 56 mutex_t exclusive; 57 55 58 /** Number of readers in critical section. */ 56 59 size_t readers_in; … … 59 62 #define rwlock_write_lock(rwl) \ 60 63 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 64 61 65 #define rwlock_read_lock(rwl) \ 62 66 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 67 63 68 #define rwlock_write_trylock(rwl) \ 64 69 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 65 70 SYNCH_FLAGS_NON_BLOCKING) 71 66 72 #define rwlock_read_trylock(rwl) \ 67 73 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 68 74 SYNCH_FLAGS_NON_BLOCKING) 75 69 76 #define rwlock_write_lock_timeout(rwl, usec) \ 70 77 _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 78 71 79 #define rwlock_read_lock_timeout(rwl, usec) \ 72 80 _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 73 81 74 extern void rwlock_initialize(rwlock_t * rwl);75 extern void rwlock_read_unlock(rwlock_t * rwl);76 extern void rwlock_write_unlock(rwlock_t * rwl);77 extern int _rwlock_read_lock_timeout(rwlock_t * rwl, uint32_t usec, int flags);78 extern int _rwlock_write_lock_timeout(rwlock_t * rwl, uint32_t usec, int flags);82 extern void rwlock_initialize(rwlock_t *); 83 extern void rwlock_read_unlock(rwlock_t *); 84 extern void rwlock_write_unlock(rwlock_t *); 85 extern int _rwlock_read_lock_timeout(rwlock_t *, uint32_t, unsigned int); 86 extern int _rwlock_write_lock_timeout(rwlock_t *, uint32_t, unsigned int); 79 87 80 88 #endif -
kernel/generic/include/synch/semaphore.h
r666f492 rda1bafb 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 *); 56 58 57 59 #endif -
kernel/generic/include/synch/spinlock.h
r666f492 rda1bafb 170 170 #define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name) 171 171 172 #define ASSERT_SPINLOCK(expr, lock) 172 #define ASSERT_SPINLOCK(expr, lock) ASSERT(expr) 173 173 174 174 #define spinlock_initialize(lock, name) -
kernel/generic/include/synch/waitq.h
r666f492 rda1bafb 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); -
kernel/generic/include/sysinfo/abi.h
r666f492 rda1bafb 38 38 39 39 /** Number of load components */ 40 #define LOAD_STEPS 40 #define LOAD_STEPS 3 41 41 42 42 /** Maximum task name size */ … … 65 65 */ 66 66 typedef struct { 67 unsigned int id;/**< CPU ID as stored by kernel */67 size_t id; /**< CPU ID as stored by kernel */ 68 68 bool active; /**< CPU is activate */ 69 69 uint16_t frequency_mhz; /**< Frequency in MHz */ -
kernel/generic/include/time/timeout.h
r666f492 rda1bafb 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) 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
Note:
See TracChangeset
for help on using the changeset viewer.