Changeset 357b5f5 in mainline for kernel/generic/src
- Timestamp:
- 2011-01-23T20:09:13Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdb9982c
- Parents:
- cead2aa (diff), 7e36c8d (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/src
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/adt/avl.c
rcead2aa r357b5f5 723 723 void avltree_walk(avltree_t *t, avltree_walker_t walker, void *arg) 724 724 { 725 _avltree_walk(t->root, walker, arg); 725 if (t->root) 726 _avltree_walk(t->root, walker, arg); 726 727 } 727 728 -
kernel/generic/src/adt/hash_table.c
rcead2aa r357b5f5 82 82 * @param item Item to be inserted into the hash table. 83 83 */ 84 void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item)84 void hash_table_insert(hash_table_t *h, sysarg_t key[], link_t *item) 85 85 { 86 86 size_t chain; … … 105 105 * @return Matching item on success, NULL if there is no such item. 106 106 */ 107 link_t *hash_table_find(hash_table_t *h, unative_t key[])107 link_t *hash_table_find(hash_table_t *h, sysarg_t key[]) 108 108 { 109 109 link_t *cur; … … 138 138 * @param keys Number of keys in the key array. 139 139 */ 140 void hash_table_remove(hash_table_t *h, unative_t key[], size_t keys)140 void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys) 141 141 { 142 142 size_t chain; -
kernel/generic/src/console/cmd.c
rcead2aa r357b5f5 601 601 602 602 /* This doesn't have to be very accurate */ 603 unative_t sec = uptime->seconds1;603 sysarg_t sec = uptime->seconds1; 604 604 605 605 printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n", … … 656 656 uintptr_t symaddr; 657 657 char *symbol; 658 unative_t (*fnc)(void);658 sysarg_t (*fnc)(void); 659 659 fncptr_t fptr; 660 660 int rc; … … 672 672 673 673 ipl = interrupts_disable(); 674 fnc = ( unative_t (*)(void)) arch_construct_function(&fptr,674 fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr, 675 675 (void *) symaddr, (void *) cmd_call0); 676 676 printf("Calling %s() (%p)\n", symbol, (void *) symaddr); … … 720 720 uintptr_t symaddr; 721 721 char *symbol; 722 unative_t (*fnc)(unative_t, ...);723 unative_t arg1 = argv[1].intval;722 sysarg_t (*fnc)(sysarg_t, ...); 723 sysarg_t arg1 = argv[1].intval; 724 724 fncptr_t fptr; 725 725 int rc; … … 737 737 738 738 ipl = interrupts_disable(); 739 fnc = ( unative_t (*)(unative_t, ...))739 fnc = (sysarg_t (*)(sysarg_t, ...)) 740 740 arch_construct_function(&fptr, (void *) symaddr, 741 741 (void *) cmd_call1); … … 756 756 uintptr_t symaddr; 757 757 char *symbol; 758 unative_t (*fnc)(unative_t, unative_t, ...);759 unative_t arg1 = argv[1].intval;760 unative_t arg2 = argv[2].intval;758 sysarg_t (*fnc)(sysarg_t, sysarg_t, ...); 759 sysarg_t arg1 = argv[1].intval; 760 sysarg_t arg2 = argv[2].intval; 761 761 fncptr_t fptr; 762 762 int rc; … … 774 774 775 775 ipl = interrupts_disable(); 776 fnc = ( unative_t (*)(unative_t, unative_t, ...))776 fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...)) 777 777 arch_construct_function(&fptr, (void *) symaddr, 778 778 (void *) cmd_call2); … … 792 792 uintptr_t symaddr; 793 793 char *symbol; 794 unative_t (*fnc)(unative_t, unative_t, unative_t, ...);795 unative_t arg1 = argv[1].intval;796 unative_t arg2 = argv[2].intval;797 unative_t arg3 = argv[3].intval;794 sysarg_t (*fnc)(sysarg_t, sysarg_t, sysarg_t, ...); 795 sysarg_t arg1 = argv[1].intval; 796 sysarg_t arg2 = argv[2].intval; 797 sysarg_t arg3 = argv[3].intval; 798 798 fncptr_t fptr; 799 799 int rc; … … 811 811 812 812 ipl = interrupts_disable(); 813 fnc = ( unative_t (*)(unative_t, unative_t, unative_t, ...))813 fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...)) 814 814 arch_construct_function(&fptr, (void *) symaddr, 815 815 (void *) cmd_call3); -
kernel/generic/src/console/console.c
rcead2aa r357b5f5 162 162 ddi_parea_register(&klog_parea); 163 163 164 sysinfo_set_item_val("klog.faddr", NULL, ( unative_t) faddr);164 sysinfo_set_item_val("klog.faddr", NULL, (sysarg_t) faddr); 165 165 sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES); 166 166 … … 193 193 194 194 /** Tell kernel to get keyboard/console access again */ 195 unative_t sys_debug_enable_console(void)195 sysarg_t sys_debug_enable_console(void) 196 196 { 197 197 #ifdef CONFIG_KCONSOLE … … 204 204 205 205 /** Tell kernel to relinquish keyboard/console access */ 206 unative_t sys_debug_disable_console(void)206 sysarg_t sys_debug_disable_console(void) 207 207 { 208 208 release_console(); … … 333 333 * 334 334 */ 335 unative_t sys_klog(int fd, const void *buf, size_t size)335 sysarg_t sys_klog(int fd, const void *buf, size_t size) 336 336 { 337 337 char *data; … … 339 339 340 340 if (size > PAGE_SIZE) 341 return ( unative_t) ELIMIT;341 return (sysarg_t) ELIMIT; 342 342 343 343 if (size > 0) { 344 344 data = (char *) malloc(size + 1, 0); 345 345 if (!data) 346 return ( unative_t) ENOMEM;346 return (sysarg_t) ENOMEM; 347 347 348 348 rc = copy_from_uspace(data, buf, size); 349 349 if (rc) { 350 350 free(data); 351 return ( unative_t) rc;351 return (sysarg_t) rc; 352 352 } 353 353 data[size] = 0; -
kernel/generic/src/console/kconsole.c
rcead2aa r357b5f5 426 426 427 427 NO_TRACE static bool parse_int_arg(const char *text, size_t len, 428 unative_t *result)428 sysarg_t *result) 429 429 { 430 430 bool isaddr = false; … … 461 461 case EOK: 462 462 if (isaddr) 463 *result = ( unative_t) symaddr;463 *result = (sysarg_t) symaddr; 464 464 else if (isptr) 465 *result = **(( unative_t **) symaddr);465 *result = **((sysarg_t **) symaddr); 466 466 else 467 *result = *(( unative_t *) symaddr);467 *result = *((sysarg_t *) symaddr); 468 468 break; 469 469 default: … … 483 483 return false; 484 484 case EOK: 485 *result = ( unative_t) value;485 *result = (sysarg_t) value; 486 486 if (isptr) 487 *result = *(( unative_t *) *result);487 *result = *((sysarg_t *) *result); 488 488 break; 489 489 default: … … 629 629 cmdline + start + 1, 630 630 (end - start) - 1); 631 cmd->argv[i].intval = ( unative_t) buf;631 cmd->argv[i].intval = (sysarg_t) buf; 632 632 cmd->argv[i].vartype = ARG_TYPE_STRING; 633 633 } else { -
kernel/generic/src/ddi/ddi.c
rcead2aa r357b5f5 232 232 * 233 233 */ 234 unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base,235 unative_t pages, unative_t flags)236 { 237 return ( unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,234 sysarg_t sys_physmem_map(sysarg_t phys_base, sysarg_t virt_base, 235 sysarg_t pages, sysarg_t flags) 236 { 237 return (sysarg_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base, 238 238 FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE), 239 239 (size_t) pages, (int) flags); … … 247 247 * 248 248 */ 249 unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg)249 sysarg_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg) 250 250 { 251 251 ddi_ioarg_t arg; 252 252 int rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 253 253 if (rc != 0) 254 return ( unative_t) rc;255 256 return ( unative_t) ddi_iospace_enable((task_id_t) arg.task_id,254 return (sysarg_t) rc; 255 256 return (sysarg_t) ddi_iospace_enable((task_id_t) arg.task_id, 257 257 (uintptr_t) arg.ioaddr, (size_t) arg.size); 258 258 } 259 259 260 /** Disable or enable specified interrupts.261 *262 * @param irq the interrupt to be enabled/disabled.263 * @param enable if true enable the interrupt, disable otherwise.264 *265 * @retutn Zero on success, error code otherwise.266 */267 unative_t sys_interrupt_enable(int irq, int enable)268 {269 /* FIXME: this needs to be generic code, or better not be in kernel at all. */270 #if 0271 cap_t task_cap = cap_get(TASK);272 if (!(task_cap & CAP_IRQ_REG))273 return EPERM;274 275 if (irq < 0 || irq > 16) {276 return EINVAL;277 }278 279 uint16_t irq_mask = (uint16_t)(1 << irq);280 if (enable) {281 trap_virtual_enable_irqs(irq_mask);282 } else {283 trap_virtual_disable_irqs(irq_mask);284 }285 286 #endif287 return 0;288 }289 290 260 /** @} 291 261 */ -
kernel/generic/src/ddi/device.c
rcead2aa r357b5f5 54 54 } 55 55 56 unative_t sys_device_assign_devno(void)56 sysarg_t sys_device_assign_devno(void) 57 57 { 58 return ( unative_t) device_assign_devno();58 return (sysarg_t) device_assign_devno(); 59 59 } 60 60 -
kernel/generic/src/ddi/irq.c
rcead2aa r357b5f5 106 106 * 107 107 */ 108 static size_t irq_ht_hash( unative_t *key);109 static bool irq_ht_compare( unative_t *key, size_t keys, link_t *item);108 static size_t irq_ht_hash(sysarg_t *key); 109 static bool irq_ht_compare(sysarg_t *key, size_t keys, link_t *item); 110 110 static void irq_ht_remove(link_t *item); 111 111 … … 123 123 * 124 124 */ 125 static size_t irq_lin_hash( unative_t *key);126 static bool irq_lin_compare( unative_t *key, size_t keys, link_t *item);125 static size_t irq_lin_hash(sysarg_t *key); 126 static bool irq_lin_compare(sysarg_t *key, size_t keys, link_t *item); 127 127 static void irq_lin_remove(link_t *item); 128 128 … … 136 136 static size_t buckets; 137 137 138 /** Last valid INR. */ 139 inr_t last_inr = 0; 140 138 141 /** Initialize IRQ subsystem. 139 142 * … … 145 148 { 146 149 buckets = chains; 150 last_inr = inrs - 1; 151 147 152 /* 148 153 * Be smart about the choice of the hash table operations. … … 194 199 void irq_register(irq_t *irq) 195 200 { 196 unative_t key[] = {197 ( unative_t) irq->inr,198 ( unative_t) irq->devno201 sysarg_t key[] = { 202 (sysarg_t) irq->inr, 203 (sysarg_t) irq->devno 199 204 }; 200 205 … … 212 217 { 213 218 link_t *lnk; 214 unative_t key[] = {215 ( unative_t) inr,216 ( unative_t) -1 /* Search will use claim() instead of devno */219 sysarg_t key[] = { 220 (sysarg_t) inr, 221 (sysarg_t) -1 /* Search will use claim() instead of devno */ 217 222 }; 218 223 … … 235 240 { 236 241 link_t *lnk; 237 unative_t key[] = {238 ( unative_t) inr,239 ( unative_t) -1 /* Search will use claim() instead of devno */242 sysarg_t key[] = { 243 (sysarg_t) inr, 244 (sysarg_t) -1 /* Search will use claim() instead of devno */ 240 245 }; 241 246 … … 306 311 * 307 312 */ 308 size_t irq_ht_hash( unative_t key[])313 size_t irq_ht_hash(sysarg_t key[]) 309 314 { 310 315 inr_t inr = (inr_t) key[KEY_INR]; … … 333 338 * 334 339 */ 335 bool irq_ht_compare( unative_t key[], size_t keys, link_t *item)340 bool irq_ht_compare(sysarg_t key[], size_t keys, link_t *item) 336 341 { 337 342 irq_t *irq = hash_table_get_instance(item, irq_t, link); … … 381 386 * 382 387 */ 383 size_t irq_lin_hash( unative_t key[])388 size_t irq_lin_hash(sysarg_t key[]) 384 389 { 385 390 inr_t inr = (inr_t) key[KEY_INR]; … … 408 413 * 409 414 */ 410 bool irq_lin_compare( unative_t key[], size_t keys, link_t *item)415 bool irq_lin_compare(sysarg_t key[], size_t keys, link_t *item) 411 416 { 412 417 irq_t *irq = list_get_instance(item, irq_t, link); -
kernel/generic/src/interrupt/interrupt.c
rcead2aa r357b5f5 197 197 /* Notify the subscriber that a fault occurred. */ 198 198 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid), 199 UPPER32(TASK->taskid), ( unative_t) THREAD);199 UPPER32(TASK->taskid), (sysarg_t) THREAD); 200 200 201 201 #ifdef CONFIG_UDEBUG … … 207 207 task_kill(TASK->taskid); 208 208 thread_exit(); 209 } 210 211 /** Get istate structure of a thread. 212 * 213 * Get pointer to the istate structure at the bottom of the kernel stack. 214 * 215 * This function can be called in interrupt or user context. In interrupt 216 * context the istate structure is created by the low-level exception 217 * handler. In user context the istate structure is created by the 218 * low-level syscall handler. 219 */ 220 istate_t *istate_get(thread_t *thread) 221 { 222 /* 223 * The istate structure should be right at the bottom of the kernel 224 * stack. 225 */ 226 return (istate_t *) ((uint8_t *) thread->kstack + THREAD_STACK_SIZE - 227 sizeof(istate_t)); 209 228 } 210 229 … … 263 282 264 283 const char *symbol = 265 symtab_fmt_name_lookup(( unative_t) exc_table[i].handler);284 symtab_fmt_name_lookup((sysarg_t) exc_table[i].handler); 266 285 267 286 #ifdef __32_BITS__ -
kernel/generic/src/ipc/event.c
rcead2aa r357b5f5 57 57 events[i].answerbox = NULL; 58 58 events[i].counter = 0; 59 events[i]. method = 0;59 events[i].imethod = 0; 60 60 } 61 61 } 62 62 63 static int event_subscribe(event_type_t evno, unative_tmethod,63 static int event_subscribe(event_type_t evno, sysarg_t imethod, 64 64 answerbox_t *answerbox) 65 65 { … … 73 73 if (events[evno].answerbox == NULL) { 74 74 events[evno].answerbox = answerbox; 75 events[evno]. method =method;75 events[evno].imethod = imethod; 76 76 events[evno].counter = 0; 77 77 res = EOK; … … 84 84 } 85 85 86 unative_t sys_event_subscribe(unative_t evno, unative_tmethod)86 sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod) 87 87 { 88 return ( unative_t) event_subscribe((event_type_t) evno, (unative_t)89 method, &TASK->answerbox);88 return (sysarg_t) event_subscribe((event_type_t) evno, (sysarg_t) 89 imethod, &TASK->answerbox); 90 90 } 91 91 … … 113 113 events[i].answerbox = NULL; 114 114 events[i].counter = 0; 115 events[i]. method = 0;115 events[i].imethod = 0; 116 116 } 117 117 spinlock_unlock(&events[i].lock); … … 119 119 } 120 120 121 void event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3,122 unative_t a4, unative_t a5)121 void event_notify(event_type_t evno, sysarg_t a1, sysarg_t a2, sysarg_t a3, 122 sysarg_t a4, sysarg_t a5) 123 123 { 124 124 ASSERT(evno < EVENT_END); … … 130 130 call->flags |= IPC_CALL_NOTIF; 131 131 call->priv = ++events[evno].counter; 132 IPC_SET_ METHOD(call->data, events[evno].method);132 IPC_SET_IMETHOD(call->data, events[evno].imethod); 133 133 IPC_SET_ARG1(call->data, a1); 134 134 IPC_SET_ARG2(call->data, a2); -
kernel/generic/src/ipc/ipc.c
rcead2aa r357b5f5 270 270 * 271 271 */ 272 void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)272 void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err) 273 273 { 274 274 call->data.phone = phone; … … 367 367 368 368 call_t *call = ipc_call_alloc(0); 369 IPC_SET_ METHOD(call->data, IPC_M_PHONE_HUNGUP);369 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP); 370 370 call->flags |= IPC_CALL_DISCARD_ANSWER; 371 371 _ipc_call(phone, box, call); … … 547 547 * disconnected. 548 548 */ 549 IPC_SET_ METHOD(call->data, IPC_M_PHONE_HUNGUP);549 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP); 550 550 call->flags |= IPC_CALL_DISCARD_ANSWER; 551 551 _ipc_call(phone, box, call); … … 655 655 (call->flags & IPC_CALL_NOTIF)); 656 656 657 /*658 * Record the receipt of this call in the current task's counter659 * of active calls. IPC_M_PHONE_HUNGUP calls do not contribute660 * to this counter so do not record answers to them either.661 */662 if (!(call->flags & IPC_CALL_DISCARD_ANSWER))663 atomic_dec(&TASK->active_calls);664 665 657 ipc_call_free(call); 666 658 } … … 714 706 break; 715 707 case IPC_PHONE_CONNECTED: 716 printf("connected to: %p ", 717 task->phones[i].callee); 708 printf("connected to: %p (%" PRIu64 ") ", 709 task->phones[i].callee, 710 task->phones[i].callee->task->taskid); 718 711 break; 719 712 case IPC_PHONE_SLAMMED: … … 749 742 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, 750 743 call->sender->taskid, 751 IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),744 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 752 745 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 753 746 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), … … 765 758 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, 766 759 call->sender->taskid, 767 IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),760 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 768 761 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 769 762 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), … … 779 772 printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun 780 773 " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", 781 call, IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),774 call, IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 782 775 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 783 776 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), -
kernel/generic/src/ipc/ipcrsc.c
rcead2aa r357b5f5 144 144 * 145 145 */ 146 call_t *get_call( unative_t callid)146 call_t *get_call(sysarg_t callid) 147 147 { 148 148 link_t *lst; … … 153 153 lst != &TASK->answerbox.dispatched_calls; lst = lst->next) { 154 154 call_t *call = list_get_instance(lst, call_t, link); 155 if (( unative_t) call == callid) {155 if ((sysarg_t) call == callid) { 156 156 result = call; 157 157 break; -
kernel/generic/src/ipc/irq.c
rcead2aa r357b5f5 42 42 * 43 43 * The structure of a notification message is as follows: 44 * - METHOD: method as registered by the SYS_IPC_REGISTER_IRQ syscall 44 * - IMETHOD: interface and method as registered by the SYS_IPC_REGISTER_IRQ 45 * syscall 45 46 * - ARG1: payload modified by a 'top-half' handler 46 47 * - ARG2: payload modified by a 'top-half' handler … … 49 50 * - ARG5: payload modified by a 'top-half' handler 50 51 * - in_phone_hash: interrupt counter (may be needed to assure correct order 51 * in multithreaded drivers)52 * in multithreaded drivers) 52 53 * 53 54 * Note on synchronization for ipc_irq_register(), ipc_irq_unregister(), … … 130 131 /** Register an answerbox as a receiving end for IRQ notifications. 131 132 * 132 * @param box 133 * @param inr 134 * @param devno 135 * @param method Method to be associated with the notification.136 * @param ucode Uspace pointer to top-half pseudocode.137 * 138 * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.133 * @param box Receiving answerbox. 134 * @param inr IRQ number. 135 * @param devno Device number. 136 * @param imethod Interface and method to be associated with the 137 * notification. 138 * @param ucode Uspace pointer to top-half pseudocode. 139 * @return EOK on success or a negative error code. 139 140 * 140 141 */ 141 142 int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, 142 unative_tmethod, irq_code_t *ucode)143 { 144 unative_t key[] = {145 ( unative_t) inr,146 ( unative_t) devno143 sysarg_t imethod, irq_code_t *ucode) 144 { 145 sysarg_t key[] = { 146 (sysarg_t) inr, 147 (sysarg_t) devno 147 148 }; 149 150 if ((inr < 0) || (inr > last_inr)) 151 return ELIMIT; 148 152 149 153 irq_code_t *code; … … 167 171 irq->notif_cfg.notify = true; 168 172 irq->notif_cfg.answerbox = box; 169 irq->notif_cfg. method =method;173 irq->notif_cfg.imethod = imethod; 170 174 irq->notif_cfg.code = code; 171 175 irq->notif_cfg.counter = 0; … … 206 210 /** Unregister task from IRQ notification. 207 211 * 208 * @param box 209 * @param inr 210 * @param devno 211 * 212 * @param box Answerbox associated with the notification. 213 * @param inr IRQ number. 214 * @param devno Device number. 215 * @return EOK on success or a negative error code. 212 216 */ 213 217 int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno) 214 218 { 215 unative_t key[] = {216 ( unative_t) inr,217 ( unative_t) devno219 sysarg_t key[] = { 220 (sysarg_t) inr, 221 (sysarg_t) devno 218 222 }; 223 224 if ((inr < 0) || (inr > last_inr)) 225 return ELIMIT; 219 226 220 227 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); … … 290 297 } 291 298 292 unative_t key[2];299 sysarg_t key[2]; 293 300 key[0] = irq->inr; 294 301 key[1] = irq->devno; … … 397 404 (uint32_t) code->cmds[i].value); 398 405 break; 406 case CMD_PIO_WRITE_A_8: 407 if (srcarg) { 408 pio_write_8((ioport8_t *) code->cmds[i].addr, 409 (uint8_t) scratch[srcarg]); 410 } 411 break; 412 case CMD_PIO_WRITE_A_16: 413 if (srcarg) { 414 pio_write_16((ioport16_t *) code->cmds[i].addr, 415 (uint16_t) scratch[srcarg]); 416 } 417 break; 418 case CMD_PIO_WRITE_A_32: 419 if (srcarg) { 420 pio_write_32((ioport32_t *) code->cmds[i].addr, 421 (uint32_t) scratch[srcarg]); 422 } 423 break; 399 424 case CMD_BTEST: 400 425 if ((srcarg) && (dstarg)) { … … 444 469 445 470 /* Set up args */ 446 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);471 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 447 472 IPC_SET_ARG1(call->data, irq->notif_cfg.scratch[1]); 448 473 IPC_SET_ARG2(call->data, irq->notif_cfg.scratch[2]); … … 465 490 * 466 491 */ 467 void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3,468 unative_t a4, unative_t a5)492 void ipc_irq_send_msg(irq_t *irq, sysarg_t a1, sysarg_t a2, sysarg_t a3, 493 sysarg_t a4, sysarg_t a5) 469 494 { 470 495 irq_spinlock_lock(&irq->lock, true); … … 481 506 call->priv = ++irq->notif_cfg.counter; 482 507 483 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);508 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 484 509 IPC_SET_ARG1(call->data, a1); 485 510 IPC_SET_ARG2(call->data, a2); -
kernel/generic/src/ipc/kbox.c
rcead2aa r357b5f5 167 167 continue; /* Try again. */ 168 168 169 switch (IPC_GET_ METHOD(call->data)) {169 switch (IPC_GET_IMETHOD(call->data)) { 170 170 171 171 case IPC_M_DEBUG_ALL: … … 192 192 } 193 193 194 195 194 /** Connect phone to a task kernel-box specified by id. 196 195 * -
kernel/generic/src/ipc/sysipc.c
rcead2aa r357b5f5 49 49 #include <syscall/copy.h> 50 50 #include <security/cap.h> 51 #include <console/console.h> 51 52 #include <mm/as.h> 52 53 #include <print.h> … … 68 69 * 69 70 */ 70 static int phone_get( unative_t phoneid, phone_t **phone)71 static int phone_get(sysarg_t phoneid, phone_t **phone) 71 72 { 72 73 if (phoneid >= IPC_MAX_PHONES) … … 77 78 } 78 79 79 /** Decide if the method is a system method. 80 * 81 * @param method Method to be decided. 82 * 83 * @return true if the method is a system method. 84 * 85 */ 86 static inline bool method_is_system(unative_t method) 87 { 88 if (method <= IPC_M_LAST_SYSTEM) 80 /** Decide if the interface and method is a system method. 81 * 82 * @param imethod Interface and method to be decided. 83 * 84 * @return True if the interface and method is a system 85 * interface and method. 86 * 87 */ 88 static inline bool method_is_system(sysarg_t imethod) 89 { 90 if (imethod <= IPC_M_LAST_SYSTEM) 89 91 return true; 90 92 … … 92 94 } 93 95 94 /** Decide if the message with this method is forwardable.95 * 96 * - some system messages may be forwarded, for some of them97 * it is useless98 * 99 * @param method Method to be decided.100 * 101 * @return true if themethod is forwardable.102 * 103 */ 104 static inline bool method_is_forwardable( unative_tmethod)105 { 106 switch ( method) {96 /** Decide if the message with this interface and method is forwardable. 97 * 98 * Some system messages may be forwarded, for some of them 99 * it is useless. 100 * 101 * @param imethod Interface and method to be decided. 102 * 103 * @return True if the interface and method is forwardable. 104 * 105 */ 106 static inline bool method_is_forwardable(sysarg_t imethod) 107 { 108 switch (imethod) { 107 109 case IPC_M_CONNECTION_CLONE: 108 110 case IPC_M_CONNECT_ME: … … 115 117 } 116 118 117 /** Decide if the message with this method is immutable on forward.118 * 119 * - some system messages may be forwarded but their content cannot be altered120 * 121 * @param method Method to be decided.122 * 123 * @return true if themethod is immutable on forward.124 * 125 */ 126 static inline bool method_is_immutable( unative_tmethod)127 { 128 switch ( method) {119 /** Decide if the message with this interface and method is immutable on forward. 120 * 121 * Some system messages may be forwarded but their content cannot be altered. 122 * 123 * @param imethod Interface and method to be decided. 124 * 125 * @return True if the interface and method is immutable on forward. 126 * 127 */ 128 static inline bool method_is_immutable(sysarg_t imethod) 129 { 130 switch (imethod) { 129 131 case IPC_M_SHARE_OUT: 130 132 case IPC_M_SHARE_IN: … … 152 154 static inline bool answer_need_old(call_t *call) 153 155 { 154 switch (IPC_GET_ METHOD(call->data)) {156 switch (IPC_GET_IMETHOD(call->data)) { 155 157 case IPC_M_CONNECTION_CLONE: 156 158 case IPC_M_CONNECT_ME: … … 196 198 return 0; 197 199 198 if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECTION_CLONE) {200 if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECTION_CLONE) { 199 201 int phoneid = IPC_GET_ARG1(*olddata); 200 202 phone_t *phone = &TASK->phones[phoneid]; … … 218 220 mutex_unlock(&phone->lock); 219 221 } 220 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME) {222 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME) { 221 223 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 222 224 … … 237 239 mutex_unlock(&phone->lock); 238 240 } 239 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {241 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_TO_ME) { 240 242 int phoneid = IPC_GET_ARG5(*olddata); 241 243 … … 248 250 /* Set 'phone hash' as arg5 of response */ 249 251 IPC_SET_ARG5(answer->data, 250 ( unative_t) &TASK->phones[phoneid]);251 } 252 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {252 (sysarg_t) &TASK->phones[phoneid]); 253 } 254 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME_TO) { 253 255 /* If the users accepted call, connect */ 254 256 if (IPC_GET_RETVAL(answer->data) == EOK) { … … 256 258 &TASK->answerbox); 257 259 } 258 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_OUT) {260 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_OUT) { 259 261 if (!IPC_GET_RETVAL(answer->data)) { 260 262 /* Accepted, handle as_area receipt */ … … 270 272 return rc; 271 273 } 272 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_IN) {274 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) { 273 275 if (!IPC_GET_RETVAL(answer->data)) { 274 276 irq_spinlock_lock(&answer->sender->lock, true); … … 281 283 IPC_SET_RETVAL(answer->data, rc); 282 284 } 283 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_READ) {285 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_READ) { 284 286 ASSERT(!answer->buffer); 285 287 if (!IPC_GET_RETVAL(answer->data)) { … … 310 312 } 311 313 } 312 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_WRITE) {314 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_WRITE) { 313 315 ASSERT(answer->buffer); 314 316 if (!IPC_GET_RETVAL(answer->data)) { … … 363 365 static int request_preprocess(call_t *call, phone_t *phone) 364 366 { 365 switch (IPC_GET_ METHOD(call->data)) {367 switch (IPC_GET_IMETHOD(call->data)) { 366 368 case IPC_M_CONNECTION_CLONE: { 367 369 phone_t *cloned_phone; … … 399 401 } 400 402 case IPC_M_CONNECT_ME: 401 IPC_SET_ARG5(call->data, ( unative_t) phone);403 IPC_SET_ARG5(call->data, (sysarg_t) phone); 402 404 break; 403 405 case IPC_M_CONNECT_ME_TO: { … … 407 409 408 410 /* Set arg5 for server */ 409 IPC_SET_ARG5(call->data, ( unative_t) &TASK->phones[newphid]);411 IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]); 410 412 call->flags |= IPC_CALL_CONN_ME_TO; 411 413 call->priv = newphid; … … 503 505 static int process_request(answerbox_t *box, call_t *call) 504 506 { 505 if (IPC_GET_ METHOD(call->data) == IPC_M_CONNECT_TO_ME) {507 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) { 506 508 int phoneid = phone_alloc(TASK); 507 509 if (phoneid < 0) { /* Failed to allocate phone */ … … 514 516 } 515 517 516 switch (IPC_GET_ METHOD(call->data)) {518 switch (IPC_GET_IMETHOD(call->data)) { 517 519 case IPC_M_DEBUG_ALL: 518 520 return -1; … … 530 532 * 531 533 * @param phoneid Phone handle for the call. 532 * @param method Method of the call.534 * @param imethod Interface and method of the call. 533 535 * @param arg1 Service-defined payload argument. 534 536 * @param arg2 Service-defined payload argument. 535 537 * @param arg3 Service-defined payload argument. 536 * @param data Address of user space structure where the reply call will538 * @param data Address of user-space structure where the reply call will 537 539 * be stored. 538 540 * … … 541 543 * 542 544 */ 543 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_tmethod,544 unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data)545 sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod, 546 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data) 545 547 { 546 548 phone_t *phone; 547 549 if (phone_get(phoneid, &phone) != EOK) 548 550 return ENOENT; 549 551 550 552 call_t *call = ipc_call_alloc(0); 551 IPC_SET_ METHOD(call->data,method);553 IPC_SET_IMETHOD(call->data, imethod); 552 554 IPC_SET_ARG1(call->data, arg1); 553 555 IPC_SET_ARG2(call->data, arg2); … … 579 581 580 582 process_answer(call); 581 582 583 } else 583 584 IPC_SET_RETVAL(call->data, res); … … 593 594 /** Make a synchronous IPC call allowing to transmit the entire payload. 594 595 * 595 * @param phoneid 596 * @param question Userspace address of call data with the request.597 * @param reply Userspace address of call data where to store the598 * 596 * @param phoneid Phone handle for the call. 597 * @param request User-space address of call data with the request. 598 * @param reply User-space address of call data where to store the 599 * answer. 599 600 * 600 601 * @return Zero on success or an error code. 601 602 * 602 603 */ 603 unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,604 sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request, 604 605 ipc_data_t *reply) 605 606 { … … 607 608 if (phone_get(phoneid, &phone) != EOK) 608 609 return ENOENT; 609 610 610 611 call_t *call = ipc_call_alloc(0); 611 int rc = copy_from_uspace(&call->data.args, & question->args,612 int rc = copy_from_uspace(&call->data.args, &request->args, 612 613 sizeof(call->data.args)); 613 614 if (rc != 0) { 614 615 ipc_call_free(call); 615 return ( unative_t) rc;616 return (sysarg_t) rc; 616 617 } 617 618 … … 644 645 } 645 646 646 /** Check that the task did not exceed the allowed limit of asynchronous calls. 647 /** Check that the task did not exceed the allowed limit of asynchronous calls 648 * made over a phone. 649 * 650 * @param phone Phone to check the limit against. 647 651 * 648 652 * @return 0 if limit not reached or -1 if limit exceeded. 649 653 * 650 654 */ 651 static int check_call_limit(void) 652 { 653 if (atomic_preinc(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) { 654 atomic_dec(&TASK->active_calls); 655 static int check_call_limit(phone_t *phone) 656 { 657 if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS) 655 658 return -1; 656 }657 659 658 660 return 0; … … 665 667 * 666 668 * @param phoneid Phone handle for the call. 667 * @param method Method of the call.669 * @param imethod Interface and method of the call. 668 670 * @param arg1 Service-defined payload argument. 669 671 * @param arg2 Service-defined payload argument. … … 677 679 * 678 680 */ 679 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method, 680 unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4) 681 { 682 if (check_call_limit()) 683 return IPC_CALLRET_TEMPORARY; 684 681 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod, 682 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 683 { 685 684 phone_t *phone; 686 685 if (phone_get(phoneid, &phone) != EOK) 687 686 return IPC_CALLRET_FATAL; 688 687 688 if (check_call_limit(phone)) 689 return IPC_CALLRET_TEMPORARY; 690 689 691 call_t *call = ipc_call_alloc(0); 690 IPC_SET_ METHOD(call->data,method);692 IPC_SET_IMETHOD(call->data, imethod); 691 693 IPC_SET_ARG1(call->data, arg1); 692 694 IPC_SET_ARG2(call->data, arg2); … … 707 709 ipc_backsend_err(phone, call, res); 708 710 709 return ( unative_t) call;711 return (sysarg_t) call; 710 712 } 711 713 … … 718 720 * 719 721 */ 720 unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data) 721 { 722 if (check_call_limit()) 723 return IPC_CALLRET_TEMPORARY; 724 722 sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data) 723 { 725 724 phone_t *phone; 726 725 if (phone_get(phoneid, &phone) != EOK) 727 726 return IPC_CALLRET_FATAL; 727 728 if (check_call_limit(phone)) 729 return IPC_CALLRET_TEMPORARY; 728 730 729 731 call_t *call = ipc_call_alloc(0); … … 732 734 if (rc != 0) { 733 735 ipc_call_free(call); 734 return ( unative_t) rc;736 return (sysarg_t) rc; 735 737 } 736 738 … … 742 744 ipc_backsend_err(phone, call, res); 743 745 744 return ( unative_t) call;746 return (sysarg_t) call; 745 747 } 746 748 … … 751 753 * @param callid Hash of the call to forward. 752 754 * @param phoneid Phone handle to use for forwarding. 753 * @param method Newmethod to use for the forwarded call.755 * @param imethod New interface and method to use for the forwarded call. 754 756 * @param arg1 New value of the first argument for the forwarded call. 755 757 * @param arg2 New value of the second argument for the forwarded call. … … 767 769 * 768 770 */ 769 static unative_t sys_ipc_forward_common(unative_t callid, unative_t phoneid,770 unative_t method, unative_t arg1, unative_t arg2, unative_t arg3,771 unative_t arg4, unative_t arg5, unsigned int mode, bool slow)771 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid, 772 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 773 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) 772 774 { 773 775 call_t *call = get_call(callid); … … 784 786 } 785 787 786 if (!method_is_forwardable(IPC_GET_ METHOD(call->data))) {788 if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) { 787 789 IPC_SET_RETVAL(call->data, EFORWARD); 788 790 ipc_answer(&TASK->answerbox, call); … … 791 793 792 794 /* 793 * Userspace is not allowed to change method of system methods on794 * forward, allow changing ARG1, ARG2, ARG3 and ARG4 by means of method,795 * arg1, arg2 and arg3.796 * If the method is immutable, don't change anything.795 * Userspace is not allowed to change interface and method of system 796 * methods on forward, allow changing ARG1, ARG2, ARG3 and ARG4 by 797 * means of method, arg1, arg2 and arg3. 798 * If the interface and method is immutable, don't change anything. 797 799 */ 798 if (!method_is_immutable(IPC_GET_ METHOD(call->data))) {799 if (method_is_system(IPC_GET_ METHOD(call->data))) {800 if (IPC_GET_ METHOD(call->data) == IPC_M_CONNECT_TO_ME)800 if (!method_is_immutable(IPC_GET_IMETHOD(call->data))) { 801 if (method_is_system(IPC_GET_IMETHOD(call->data))) { 802 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) 801 803 phone_dealloc(IPC_GET_ARG5(call->data)); 802 804 803 IPC_SET_ARG1(call->data, method);805 IPC_SET_ARG1(call->data, imethod); 804 806 IPC_SET_ARG2(call->data, arg1); 805 807 IPC_SET_ARG3(call->data, arg2); … … 813 815 } 814 816 } else { 815 IPC_SET_ METHOD(call->data,method);817 IPC_SET_IMETHOD(call->data, imethod); 816 818 IPC_SET_ARG1(call->data, arg1); 817 819 IPC_SET_ARG2(call->data, arg2); … … 829 831 /** Forward a received call to another destination - fast version. 830 832 * 831 * In case the original method is a system method, ARG1, ARG2 and ARG3 are832 * overwritten in the forwarded message with the new method and the new833 * arg1 and arg2, respectively. Otherwise the METHOD, ARG1 and ARG2 are834 * rewritten with the new method, arg1 and arg2, respectively. Also note there835 * is a set of immutable methods, for which the new method and arguments are not836 * set and these values are ignored.833 * In case the original interface and method is a system method, ARG1, ARG2 834 * and ARG3 are overwritten in the forwarded message with the new method and 835 * the new arg1 and arg2, respectively. Otherwise the IMETHOD, ARG1 and ARG2 836 * are rewritten with the new interface and method, arg1 and arg2, respectively. 837 * Also note there is a set of immutable methods, for which the new method and 838 * arguments are not set and these values are ignored. 837 839 * 838 840 * @param callid Hash of the call to forward. 839 841 * @param phoneid Phone handle to use for forwarding. 840 * @param method Newmethod to use for the forwarded call.842 * @param imethod New interface and method to use for the forwarded call. 841 843 * @param arg1 New value of the first argument for the forwarded call. 842 844 * @param arg2 New value of the second argument for the forwarded call. … … 846 848 * 847 849 */ 848 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,849 unative_t method, unative_t arg1, unative_t arg2, unsigned int mode)850 { 851 return sys_ipc_forward_common(callid, phoneid, method, arg1, arg2, 0, 0,850 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid, 851 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 852 { 853 return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0, 852 854 0, mode, false); 853 855 } … … 856 858 * 857 859 * This function is the slow verision of the sys_ipc_forward_fast interface. 858 * It can copy all five new arguments and the new method from the userspace.859 * It naturally extends the functionality of the fast version. For system860 * methods, it additionally stores the new value of arg3 to ARG4. For non-system861 * methods, it additionally stores the new value of arg3, arg4 and arg5,862 * respectively, to ARG3, ARG4 and ARG5, respectively.860 * It can copy all five new arguments and the new interface and method from 861 * the userspace. It naturally extends the functionality of the fast version. 862 * For system methods, it additionally stores the new value of arg3 to ARG4. 863 * For non-system methods, it additionally stores the new value of arg3, arg4 864 * and arg5, respectively, to ARG3, ARG4 and ARG5, respectively. 863 865 * 864 866 * @param callid Hash of the call to forward. … … 870 872 * 871 873 */ 872 unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,874 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid, 873 875 ipc_data_t *data, unsigned int mode) 874 876 { … … 877 879 sizeof(newdata.args)); 878 880 if (rc != 0) 879 return ( unative_t) rc;881 return (sysarg_t) rc; 880 882 881 883 return sys_ipc_forward_common(callid, phoneid, 882 IPC_GET_ METHOD(newdata), IPC_GET_ARG1(newdata),884 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 883 885 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), 884 886 IPC_GET_ARG4(newdata), IPC_GET_ARG5(newdata), mode, true); … … 900 902 * 901 903 */ 902 unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,903 unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)904 sysarg_t sys_ipc_answer_fast(sysarg_t callid, sysarg_t retval, 905 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 904 906 { 905 907 /* Do not answer notification callids */ … … 945 947 * 946 948 */ 947 unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data)949 sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data) 948 950 { 949 951 /* Do not answer notification callids */ … … 982 984 * 983 985 */ 984 unative_t sys_ipc_hangup(unative_t phoneid)986 sysarg_t sys_ipc_hangup(sysarg_t phoneid) 985 987 { 986 988 phone_t *phone; … … 1008 1010 * 1009 1011 */ 1010 unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,1012 sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 1011 1013 unsigned int flags) 1012 1014 { … … 1037 1039 ipc_call_free(call); 1038 1040 1039 return (( unative_t) call) | IPC_CALLID_NOTIFICATION;1041 return ((sysarg_t) call) | IPC_CALLID_NOTIFICATION; 1040 1042 } 1041 1043 … … 1046 1048 ipc_call_free(call); 1047 1049 goto restart; 1048 } else {1049 /*1050 * Decrement the counter of active calls only if the1051 * call is not an answer to IPC_M_PHONE_HUNGUP,1052 * which doesn't contribute to the counter.1053 */1054 atomic_dec(&TASK->active_calls);1055 1050 } 1056 1051 … … 1058 1053 ipc_call_free(call); 1059 1054 1060 return (( unative_t) call) | IPC_CALLID_ANSWERED;1055 return ((sysarg_t) call) | IPC_CALLID_ANSWERED; 1061 1056 } 1062 1057 … … 1086 1081 } 1087 1082 1088 return ( unative_t) call;1083 return (sysarg_t) call; 1089 1084 } 1090 1085 … … 1092 1087 * 1093 1088 */ 1094 unative_t sys_ipc_poke(void)1089 sysarg_t sys_ipc_poke(void) 1095 1090 { 1096 1091 waitq_unsleep(&TASK->answerbox.wq); … … 1100 1095 /** Connect an IRQ handler to a task. 1101 1096 * 1102 * @param inr IRQ number.1103 * @param devno Device number.1104 * @param method Method to be associated with the notification.1105 * @param ucode Uspace pointer to the top-half pseudocode.1097 * @param inr IRQ number. 1098 * @param devno Device number. 1099 * @param imethod Interface and method to be associated with the notification. 1100 * @param ucode Uspace pointer to the top-half pseudocode. 1106 1101 * 1107 1102 * @return EPERM or a return code returned by ipc_irq_register(). 1108 1103 * 1109 1104 */ 1110 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_tmethod,1105 sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t imethod, 1111 1106 irq_code_t *ucode) 1112 1107 { … … 1114 1109 return EPERM; 1115 1110 1116 return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);1111 return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode); 1117 1112 } 1118 1113 … … 1125 1120 * 1126 1121 */ 1127 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)1122 sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno) 1128 1123 { 1129 1124 if (!(cap_get(TASK) & CAP_IRQ_REG)) … … 1135 1130 } 1136 1131 1137 #i nclude <console/console.h>1138 1139 /** Syscall connect to a task by id.1132 #ifdef __32_BITS__ 1133 1134 /** Syscall connect to a task by ID (32 bits) 1140 1135 * 1141 1136 * @return Phone id on success, or negative error code. 1142 1137 * 1143 1138 */ 1144 unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)1139 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid) 1145 1140 { 1146 1141 #ifdef CONFIG_UDEBUG 1147 sysarg64_t taskid _arg;1148 int rc = copy_from_uspace(&taskid _arg, uspace_taskid_arg, sizeof(sysarg64_t));1142 sysarg64_t taskid; 1143 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 1149 1144 if (rc != 0) 1150 return (unative_t) rc; 1151 1152 LOG("sys_ipc_connect_kbox(%" PRIu64 ")", taskid_arg.value); 1153 1154 return ipc_connect_kbox(taskid_arg.value); 1145 return (sysarg_t) rc; 1146 1147 return ipc_connect_kbox((task_id_t) taskid); 1155 1148 #else 1156 return ( unative_t) ENOTSUP;1149 return (sysarg_t) ENOTSUP; 1157 1150 #endif 1158 1151 } 1159 1152 1153 #endif /* __32_BITS__ */ 1154 1155 #ifdef __64_BITS__ 1156 1157 /** Syscall connect to a task by ID (64 bits) 1158 * 1159 * @return Phone id on success, or negative error code. 1160 * 1161 */ 1162 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid) 1163 { 1164 #ifdef CONFIG_UDEBUG 1165 return ipc_connect_kbox((task_id_t) taskid); 1166 #else 1167 return (sysarg_t) ENOTSUP; 1168 #endif 1169 } 1170 1171 #endif /* __64_BITS__ */ 1172 1160 1173 /** @} 1161 1174 */ -
kernel/generic/src/lib/memstr.c
rcead2aa r357b5f5 62 62 unsigned int i, j; 63 63 64 if (ALIGN_UP((uintptr_t) src, sizeof( unative_t)) != (uintptr_t) src ||65 ALIGN_UP((uintptr_t) dst, sizeof( unative_t)) != (uintptr_t) dst) {64 if (ALIGN_UP((uintptr_t) src, sizeof(sysarg_t)) != (uintptr_t) src || 65 ALIGN_UP((uintptr_t) dst, sizeof(sysarg_t)) != (uintptr_t) dst) { 66 66 for (i = 0; i < cnt; i++) 67 67 ((uint8_t *) dst)[i] = ((uint8_t *) src)[i]; 68 68 } else { 69 for (i = 0; i < cnt / sizeof( unative_t); i++)70 (( unative_t *) dst)[i] = ((unative_t *) src)[i];69 for (i = 0; i < cnt / sizeof(sysarg_t); i++) 70 ((sysarg_t *) dst)[i] = ((sysarg_t *) src)[i]; 71 71 72 for (j = 0; j < cnt % sizeof( unative_t); j++)73 ((uint8_t *)((( unative_t *) dst) + i))[j] =74 ((uint8_t *)((( unative_t *) src) + i))[j];72 for (j = 0; j < cnt % sizeof(sysarg_t); j++) 73 ((uint8_t *)(((sysarg_t *) dst) + i))[j] = 74 ((uint8_t *)(((sysarg_t *) src) + i))[j]; 75 75 } 76 76 -
kernel/generic/src/lib/rd.c
rcead2aa r357b5f5 96 96 sysinfo_set_item_val("rd.size", NULL, dsize); 97 97 sysinfo_set_item_val("rd.address.physical", NULL, 98 ( unative_t)KA2PA((void *) header + hsize));98 (sysarg_t) KA2PA((void *) header + hsize)); 99 99 100 100 return RE_OK; -
kernel/generic/src/main/main.c
rcead2aa r357b5f5 185 185 LOG("\nconfig.base=%p config.kernel_size=%zu" 186 186 "\nconfig.stack_base=%p config.stack_size=%zu", 187 config.base, config.kernel_size, config.stack_base,188 config.stack_size);187 (void *) config.base, config.kernel_size, 188 (void *) config.stack_base, config.stack_size); 189 189 190 190 #ifdef CONFIG_KCONSOLE … … 242 242 for (i = 0; i < init.cnt; i++) 243 243 LOG("init[%zu].addr=%p, init[%zu].size=%zu", 244 i, init.tasks[i].addr, i, init.tasks[i].size);244 i, (void *) init.tasks[i].addr, i, init.tasks[i].size); 245 245 } else 246 246 printf("No init binaries found.\n"); -
kernel/generic/src/mm/as.c
rcead2aa r357b5f5 2000 2000 2001 2001 /** Wrapper for as_area_create(). */ 2002 unative_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags)2002 sysarg_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags) 2003 2003 { 2004 2004 if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address, 2005 2005 AS_AREA_ATTR_NONE, &anon_backend, NULL)) 2006 return ( unative_t) address;2006 return (sysarg_t) address; 2007 2007 else 2008 return ( unative_t) -1;2008 return (sysarg_t) -1; 2009 2009 } 2010 2010 2011 2011 /** Wrapper for as_area_resize(). */ 2012 unative_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags)2013 { 2014 return ( unative_t) as_area_resize(AS, address, size, 0);2012 sysarg_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags) 2013 { 2014 return (sysarg_t) as_area_resize(AS, address, size, 0); 2015 2015 } 2016 2016 2017 2017 /** Wrapper for as_area_change_flags(). */ 2018 unative_t sys_as_area_change_flags(uintptr_t address, unsigned int flags)2019 { 2020 return ( unative_t) as_area_change_flags(AS, flags, address);2018 sysarg_t sys_as_area_change_flags(uintptr_t address, unsigned int flags) 2019 { 2020 return (sysarg_t) as_area_change_flags(AS, flags, address); 2021 2021 } 2022 2022 2023 2023 /** Wrapper for as_area_destroy(). */ 2024 unative_t sys_as_area_destroy(uintptr_t address)2025 { 2026 return ( unative_t) as_area_destroy(AS, address);2024 sysarg_t sys_as_area_destroy(uintptr_t address) 2025 { 2026 return (sysarg_t) as_area_destroy(AS, address); 2027 2027 } 2028 2028 -
kernel/generic/src/mm/slab.c
rcead2aa r357b5f5 612 612 cache->name = name; 613 613 614 if (align < sizeof( unative_t))615 align = sizeof( unative_t);614 if (align < sizeof(sysarg_t)) 615 align = sizeof(sysarg_t); 616 616 617 617 size = ALIGN_UP(size, align); … … 806 806 } 807 807 808 /** Go through all caches and reclaim what is possible 809 * 810 * Interrupts must be disabled before calling this function, 811 * otherwise memory allocation from interrupts can deadlock. 812 * 813 */ 808 /** Go through all caches and reclaim what is possible */ 814 809 size_t slab_reclaim(unsigned int flags) 815 810 { 816 irq_spinlock_lock(&slab_cache_lock, false);811 irq_spinlock_lock(&slab_cache_lock, true); 817 812 818 813 size_t frames = 0; … … 824 819 } 825 820 826 irq_spinlock_unlock(&slab_cache_lock, false);821 irq_spinlock_unlock(&slab_cache_lock, true); 827 822 828 823 return frames; -
kernel/generic/src/proc/program.c
rcead2aa r357b5f5 210 210 * 211 211 */ 212 unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len)212 sysarg_t sys_program_spawn_loader(char *uspace_name, size_t name_len) 213 213 { 214 214 /* Cap length of name and copy it from userspace. */ … … 219 219 int rc = copy_from_uspace(namebuf, uspace_name, name_len); 220 220 if (rc != 0) 221 return ( unative_t) rc;221 return (sysarg_t) rc; 222 222 223 223 namebuf[name_len] = 0; -
kernel/generic/src/proc/task.c
rcead2aa r357b5f5 151 151 atomic_set(&task->refcount, 0); 152 152 atomic_set(&task->lifecount, 0); 153 atomic_set(&task->active_calls, 0);154 153 155 154 irq_spinlock_initialize(&task->lock, "task_t_lock"); … … 291 290 } 292 291 293 /** Syscall for reading task ID from userspace. 294 * 295 * @param uspace_task_id Userspace address of 8-byte buffer 296 * where to store current task ID. 292 #ifdef __32_BITS__ 293 294 /** Syscall for reading task ID from userspace (32 bits) 295 * 296 * @param uspace_taskid Pointer to user-space buffer 297 * where to store current task ID. 297 298 * 298 299 * @return Zero on success or an error code from @ref errno.h. 299 300 * 300 301 */ 301 unative_t sys_task_get_id(task_id_t *uspace_task_id)302 sysarg_t sys_task_get_id(sysarg64_t *uspace_taskid) 302 303 { 303 304 /* … … 305 306 * the lifespan of the task. 306 307 */ 307 return ( unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid,308 return (sysarg_t) copy_to_uspace(uspace_taskid, &TASK->taskid, 308 309 sizeof(TASK->taskid)); 309 310 } 311 312 #endif /* __32_BITS__ */ 313 314 #ifdef __64_BITS__ 315 316 /** Syscall for reading task ID from userspace (64 bits) 317 * 318 * @return Current task ID. 319 * 320 */ 321 sysarg_t sys_task_get_id(void) 322 { 323 /* 324 * No need to acquire lock on TASK because taskid remains constant for 325 * the lifespan of the task. 326 */ 327 return TASK->taskid; 328 } 329 330 #endif /* __64_BITS__ */ 310 331 311 332 /** Syscall for setting the task name. … … 319 340 * 320 341 */ 321 unative_t sys_task_set_name(const char *uspace_name, size_t name_len)342 sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len) 322 343 { 323 344 int rc; … … 331 352 rc = copy_from_uspace(namebuf, uspace_name, name_len); 332 353 if (rc != 0) 333 return ( unative_t) rc;354 return (sysarg_t) rc; 334 355 335 356 namebuf[name_len] = '\0'; … … 337 358 338 359 return EOK; 360 } 361 362 /** Syscall to forcefully terminate a task 363 * 364 * @param uspace_taskid Pointer to task ID in user space. 365 * 366 * @return 0 on success or an error code from @ref errno.h. 367 * 368 */ 369 sysarg_t sys_task_kill(task_id_t *uspace_taskid) 370 { 371 task_id_t taskid; 372 int rc; 373 374 rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid)); 375 if (rc != 0) 376 return (sysarg_t) rc; 377 378 return (sysarg_t) task_kill(taskid); 339 379 } 340 380 … … 478 518 #ifdef __32_BITS__ 479 519 if (*additional) 480 printf("%-8" PRIu64 " %9" PRIua " %7" PRIua, task->taskid,481 atomic_get(&task->refcount) , atomic_get(&task->active_calls));520 printf("%-8" PRIu64 " %9" PRIua, task->taskid, 521 atomic_get(&task->refcount)); 482 522 else 483 523 printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %10p %10p" … … 490 530 if (*additional) 491 531 printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c " 492 "%9" PRIua " %7" PRIua, 493 task->taskid, ucycles, usuffix, kcycles, ksuffix, 494 atomic_get(&task->refcount), atomic_get(&task->active_calls)); 532 "%9" PRIua, task->taskid, ucycles, usuffix, kcycles, 533 ksuffix, atomic_get(&task->refcount)); 495 534 else 496 535 printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %18p %18p\n", -
kernel/generic/src/proc/thread.c
rcead2aa r357b5f5 755 755 * 756 756 */ 757 unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,757 sysarg_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, 758 758 size_t name_len, thread_id_t *uspace_thread_id) 759 759 { … … 764 764 int rc = copy_from_uspace(namebuf, uspace_name, name_len); 765 765 if (rc != 0) 766 return ( unative_t) rc;766 return (sysarg_t) rc; 767 767 768 768 namebuf[name_len] = 0; … … 779 779 if (rc != 0) { 780 780 free(kernel_uarg); 781 return ( unative_t) rc;781 return (sysarg_t) rc; 782 782 } 783 783 … … 804 804 free(kernel_uarg); 805 805 806 return ( unative_t) rc;806 return (sysarg_t) rc; 807 807 } 808 808 } … … 827 827 free(kernel_uarg); 828 828 829 return ( unative_t) ENOMEM;829 return (sysarg_t) ENOMEM; 830 830 } 831 831 … … 833 833 * 834 834 */ 835 unative_t sys_thread_exit(int uspace_status)835 sysarg_t sys_thread_exit(int uspace_status) 836 836 { 837 837 thread_exit(); … … 849 849 * 850 850 */ 851 unative_t sys_thread_get_id(thread_id_t *uspace_thread_id)851 sysarg_t sys_thread_get_id(thread_id_t *uspace_thread_id) 852 852 { 853 853 /* … … 856 856 * 857 857 */ 858 return ( unative_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,858 return (sysarg_t) copy_to_uspace(uspace_thread_id, &THREAD->tid, 859 859 sizeof(THREAD->tid)); 860 860 } 861 861 862 862 /** Syscall wrapper for sleeping. */ 863 unative_t sys_thread_usleep(uint32_t usec)863 sysarg_t sys_thread_usleep(uint32_t usec) 864 864 { 865 865 thread_usleep(usec); -
kernel/generic/src/security/cap.c
rcead2aa r357b5f5 41 41 #include <proc/task.h> 42 42 #include <synch/spinlock.h> 43 #include <syscall/sysarg64.h>44 43 #include <syscall/copy.h> 45 44 #include <arch.h> … … 79 78 * The calling task must have the CAP_CAP capability. 80 79 * 81 * @param uspace_taskid_arg Userspace structure holding destination task ID.82 * @param caps Capabilities to grant.83 * 84 * @return Zero on success or an error code from @ref errno.h. 85 * 86 */ 87 unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps)80 * @param taskid Destination task ID. 81 * @param caps Capabilities to grant. 82 * 83 * @return Zero on success or an error code from @ref errno.h. 84 * 85 */ 86 static sysarg_t cap_grant(task_id_t taskid, cap_t caps) 88 87 { 89 88 if (!(cap_get(TASK) & CAP_CAP)) 90 return (unative_t) EPERM; 91 92 sysarg64_t taskid_arg; 93 int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 94 if (rc != 0) 95 return (unative_t) rc; 89 return (sysarg_t) EPERM; 96 90 97 91 irq_spinlock_lock(&tasks_lock, true); 98 task_t *task = task_find_by_id( (task_id_t) taskid_arg.value);92 task_t *task = task_find_by_id(taskid); 99 93 100 94 if ((!task) || (!context_check(CONTEXT, task->context))) { 101 95 irq_spinlock_unlock(&tasks_lock, true); 102 return ( unative_t) ENOENT;96 return (sysarg_t) ENOENT; 103 97 } 104 98 … … 116 110 * attempt to revoke capabilities from itself. 117 111 * 118 * @param uspace_taskid_arg Userspace structure holding destination task ID. 119 * @param caps Capabilities to revoke. 120 * 121 * @return Zero on success or an error code from @ref errno.h. 122 * 123 */ 124 unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps) 125 { 126 sysarg64_t taskid_arg; 127 int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 128 if (rc != 0) 129 return (unative_t) rc; 130 112 * @param taskid Destination task ID. 113 * @param caps Capabilities to revoke. 114 * 115 * @return Zero on success or an error code from @ref errno.h. 116 * 117 */ 118 static sysarg_t cap_revoke(task_id_t taskid, cap_t caps) 119 { 131 120 irq_spinlock_lock(&tasks_lock, true); 132 121 133 task_t *task = task_find_by_id( (task_id_t) taskid_arg.value);122 task_t *task = task_find_by_id(taskid); 134 123 if ((!task) || (!context_check(CONTEXT, task->context))) { 135 124 irq_spinlock_unlock(&tasks_lock, true); 136 return ( unative_t) ENOENT;125 return (sysarg_t) ENOENT; 137 126 } 138 127 … … 147 136 irq_spinlock_unlock(&TASK->lock, false); 148 137 irq_spinlock_unlock(&tasks_lock, true); 149 return ( unative_t) EPERM;138 return (sysarg_t) EPERM; 150 139 } 151 140 … … 157 146 } 158 147 148 #ifdef __32_BITS__ 149 150 /** Grant capabilities to a task (32 bits) 151 * 152 * The calling task must have the CAP_CAP capability. 153 * 154 * @param uspace_taskid User-space pointer to destination task ID. 155 * @param caps Capabilities to grant. 156 * 157 * @return Zero on success or an error code from @ref errno.h. 158 * 159 */ 160 sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid, cap_t caps) 161 { 162 sysarg64_t taskid; 163 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 164 if (rc != 0) 165 return (sysarg_t) rc; 166 167 return cap_grant((task_id_t) taskid, caps); 168 } 169 170 /** Revoke capabilities from a task (32 bits) 171 * 172 * The calling task must have the CAP_CAP capability or the caller must 173 * attempt to revoke capabilities from itself. 174 * 175 * @param uspace_taskid User-space pointer to destination task ID. 176 * @param caps Capabilities to revoke. 177 * 178 * @return Zero on success or an error code from @ref errno.h. 179 * 180 */ 181 sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid, cap_t caps) 182 { 183 sysarg64_t taskid; 184 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 185 if (rc != 0) 186 return (sysarg_t) rc; 187 188 return cap_revoke((task_id_t) taskid, caps); 189 } 190 191 #endif /* __32_BITS__ */ 192 193 #ifdef __64_BITS__ 194 195 /** Grant capabilities to a task (64 bits) 196 * 197 * The calling task must have the CAP_CAP capability. 198 * 199 * @param taskid Destination task ID. 200 * @param caps Capabilities to grant. 201 * 202 * @return Zero on success or an error code from @ref errno.h. 203 * 204 */ 205 sysarg_t sys_cap_grant(sysarg_t taskid, cap_t caps) 206 { 207 return cap_grant((task_id_t) taskid, caps); 208 } 209 210 /** Revoke capabilities from a task (64 bits) 211 * 212 * The calling task must have the CAP_CAP capability or the caller must 213 * attempt to revoke capabilities from itself. 214 * 215 * @param taskid Destination task ID. 216 * @param caps Capabilities to revoke. 217 * 218 * @return Zero on success or an error code from @ref errno.h. 219 * 220 */ 221 sysarg_t sys_cap_revoke(sysarg_t taskid, cap_t caps) 222 { 223 return cap_revoke((task_id_t) taskid, caps); 224 } 225 226 #endif /* __64_BITS__ */ 227 159 228 /** @} 160 229 */ -
kernel/generic/src/synch/futex.c
rcead2aa r357b5f5 60 60 61 61 static futex_t *futex_find(uintptr_t paddr); 62 static size_t futex_ht_hash( unative_t *key);63 static bool futex_ht_compare( unative_t *key, size_t keys, link_t *item);62 static size_t futex_ht_hash(sysarg_t *key); 63 static bool futex_ht_compare(sysarg_t *key, size_t keys, link_t *item); 64 64 static void futex_ht_remove_callback(link_t *item); 65 65 … … 108 108 * synch.h. 109 109 */ 110 unative_t sys_futex_sleep(uintptr_t uaddr)110 sysarg_t sys_futex_sleep(uintptr_t uaddr) 111 111 { 112 112 futex_t *futex; … … 122 122 if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) { 123 123 page_table_unlock(AS, true); 124 return ( unative_t) ENOENT;124 return (sysarg_t) ENOENT; 125 125 } 126 126 paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE)); … … 136 136 udebug_stoppable_end(); 137 137 #endif 138 return ( unative_t) rc;138 return (sysarg_t) rc; 139 139 } 140 140 … … 145 145 * @return ENOENT if there is no physical mapping for uaddr. 146 146 */ 147 unative_t sys_futex_wakeup(uintptr_t uaddr)147 sysarg_t sys_futex_wakeup(uintptr_t uaddr) 148 148 { 149 149 futex_t *futex; … … 158 158 if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) { 159 159 page_table_unlock(AS, true); 160 return ( unative_t) ENOENT;160 return (sysarg_t) ENOENT; 161 161 } 162 162 paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE)); … … 235 235 * @return Index into futex hash table. 236 236 */ 237 size_t futex_ht_hash( unative_t *key)237 size_t futex_ht_hash(sysarg_t *key) 238 238 { 239 239 return (*key & (FUTEX_HT_SIZE - 1)); … … 247 247 * @return True if the item matches the key. False otherwise. 248 248 */ 249 bool futex_ht_compare( unative_t *key, size_t keys, link_t *item)249 bool futex_ht_compare(sysarg_t *key, size_t keys, link_t *item) 250 250 { 251 251 futex_t *futex; -
kernel/generic/src/synch/smc.c
rcead2aa r357b5f5 42 42 #include <synch/smc.h> 43 43 44 unative_t sys_smc_coherence(uintptr_t va, size_t size)44 sysarg_t sys_smc_coherence(uintptr_t va, size_t size) 45 45 { 46 46 if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE)) -
kernel/generic/src/syscall/syscall.c
rcead2aa r357b5f5 45 45 #include <debug.h> 46 46 #include <ddi/device.h> 47 #include <interrupt.h> 47 48 #include <ipc/sysipc.h> 48 49 #include <synch/futex.h> … … 56 57 57 58 /** Dispatch system call */ 58 unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3,59 unative_t a4, unative_t a5, unative_t a6, unative_t id)59 sysarg_t syscall_handler(sysarg_t a1, sysarg_t a2, sysarg_t a3, 60 sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id) 60 61 { 61 62 /* Do userpace accounting */ … … 66 67 #ifdef CONFIG_UDEBUG 67 68 /* 69 * An istate_t-compatible record was created on the stack by the 70 * low-level syscall handler. This is the userspace space state 71 * structure. 72 */ 73 THREAD->udebug.uspace_state = istate_get(THREAD); 74 75 /* 68 76 * Early check for undebugged tasks. We do not lock anything as this 69 77 * test need not be precise in either direction. 70 *71 78 */ 72 79 if (THREAD->udebug.active) … … 74 81 #endif 75 82 76 unative_t rc;83 sysarg_t rc; 77 84 if (id < SYSCALL_END) { 78 85 rc = syscall_table[id](a1, a2, a3, a4, a5, a6); … … 98 105 udebug_stoppable_end(); 99 106 } 107 108 /* Clear userspace state pointer */ 109 THREAD->udebug.uspace_state = NULL; 100 110 #endif 101 111 … … 120 130 (syshandler_t) sys_task_get_id, 121 131 (syshandler_t) sys_task_set_name, 132 (syshandler_t) sys_task_kill, 122 133 (syshandler_t) sys_program_spawn_loader, 123 134 … … 147 158 (syshandler_t) sys_ipc_register_irq, 148 159 (syshandler_t) sys_ipc_unregister_irq, 160 (syshandler_t) sys_ipc_connect_kbox, 149 161 150 162 /* Event notification syscalls. */ … … 159 171 (syshandler_t) sys_physmem_map, 160 172 (syshandler_t) sys_iospace_enable, 161 (syshandler_t) sys_interrupt_enable,162 173 163 174 /* Sysinfo syscalls */ … … 169 180 /* Debug calls */ 170 181 (syshandler_t) sys_debug_enable_console, 171 (syshandler_t) sys_debug_disable_console, 172 173 (syshandler_t) sys_ipc_connect_kbox 182 (syshandler_t) sys_debug_disable_console 174 183 }; 175 184 -
kernel/generic/src/sysinfo/stats.c
rcead2aa r357b5f5 87 87 * 88 88 */ 89 static unative_t get_stats_uptime(struct sysinfo_item *item)89 static sysarg_t get_stats_uptime(struct sysinfo_item *item) 90 90 { 91 91 /* This doesn't have to be very accurate */ -
kernel/generic/src/sysinfo/sysinfo.c
rcead2aa r357b5f5 296 296 */ 297 297 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, 298 unative_t val)298 sysarg_t val) 299 299 { 300 300 /* Protect sysinfo tree consistency */ … … 481 481 sysinfo_indent(depth); 482 482 483 unative_t val;483 sysarg_t val; 484 484 size_t size; 485 485 … … 660 660 * 661 661 */ 662 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)662 sysarg_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size) 663 663 { 664 664 /* … … 679 679 ret.tag = SYSINFO_VAL_DATA; 680 680 681 return ( unative_t) ret.tag;681 return (sysarg_t) ret.tag; 682 682 } 683 683 … … 696 696 * 697 697 */ 698 unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,698 sysarg_t sys_sysinfo_get_value(void *path_ptr, size_t path_size, 699 699 void *value_ptr) 700 700 { … … 715 715 rc = EINVAL; 716 716 717 return ( unative_t) rc;717 return (sysarg_t) rc; 718 718 } 719 719 … … 732 732 * 733 733 */ 734 unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,734 sysarg_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size, 735 735 void *size_ptr) 736 736 { … … 752 752 rc = EINVAL; 753 753 754 return ( unative_t) rc;754 return (sysarg_t) rc; 755 755 } 756 756 … … 774 774 * 775 775 */ 776 unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,776 sysarg_t sys_sysinfo_get_data(void *path_ptr, size_t path_size, 777 777 void *buffer_ptr, size_t buffer_size) 778 778 { … … 797 797 free(ret.data.data); 798 798 799 return ( unative_t) rc;799 return (sysarg_t) rc; 800 800 } 801 801 -
kernel/generic/src/time/clock.c
rcead2aa r357b5f5 70 70 * 71 71 */ 72 static unative_t secfrag = 0;72 static sysarg_t secfrag = 0; 73 73 74 74 /** Initialize realtime clock counter … … 100 100 * 101 101 */ 102 sysinfo_set_item_val("clock.cacheable", NULL, ( unative_t) true);103 sysinfo_set_item_val("clock.faddr", NULL, ( unative_t) faddr);102 sysinfo_set_item_val("clock.cacheable", NULL, (sysarg_t) true); 103 sysinfo_set_item_val("clock.faddr", NULL, (sysarg_t) faddr); 104 104 } 105 105 -
kernel/generic/src/udebug/udebug.c
rcead2aa r357b5f5 219 219 * 220 220 */ 221 void udebug_syscall_event( unative_t a1, unative_t a2, unative_t a3,222 unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,221 void udebug_syscall_event(sysarg_t a1, sysarg_t a2, sysarg_t a3, 222 sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id, sysarg_t rc, 223 223 bool end_variant) 224 224 { … … 314 314 IPC_SET_RETVAL(call->data, 0); 315 315 IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B); 316 IPC_SET_ARG2(call->data, ( unative_t) thread);316 IPC_SET_ARG2(call->data, (sysarg_t) thread); 317 317 318 318 /* -
kernel/generic/src/udebug/udebug_ipc.c
rcead2aa r357b5f5 210 210 static void udebug_receive_name_read(call_t *call) 211 211 { 212 unative_t uspace_addr;213 unative_t to_copy;212 sysarg_t uspace_addr; 213 sysarg_t to_copy; 214 214 size_t data_size; 215 215 size_t buf_size; … … 257 257 static void udebug_receive_areas_read(call_t *call) 258 258 { 259 unative_t uspace_addr;260 unative_t to_copy;259 sysarg_t uspace_addr; 260 sysarg_t to_copy; 261 261 size_t data_size; 262 262 size_t buf_size; … … 304 304 { 305 305 thread_t *t; 306 unative_t uspace_addr;306 sysarg_t uspace_addr; 307 307 int rc; 308 308 void *buffer; … … 328 328 (no way to distinguish method in answer) */ 329 329 IPC_SET_ARG1(call->data, uspace_addr); 330 IPC_SET_ARG2(call->data, 6 * sizeof( unative_t));330 IPC_SET_ARG2(call->data, 6 * sizeof(sysarg_t)); 331 331 call->buffer = buffer; 332 332 … … 341 341 { 342 342 thread_t *t; 343 unative_t uspace_addr;344 unative_t to_copy;343 sysarg_t uspace_addr; 344 sysarg_t to_copy; 345 345 void *buffer; 346 346 int rc; … … 382 382 static void udebug_receive_mem_read(call_t *call) 383 383 { 384 unative_t uspace_dst;385 unative_t uspace_src;384 sysarg_t uspace_dst; 385 sysarg_t uspace_src; 386 386 unsigned size; 387 387 void *buffer; -
kernel/generic/src/udebug/udebug_ops.c
rcead2aa r357b5f5 371 371 372 372 /* Allocate a buffer to hold thread IDs */ 373 unative_t *id_buffer = malloc(buf_size + 1, 0);373 sysarg_t *id_buffer = malloc(buf_size + 1, 0); 374 374 375 375 mutex_lock(&TASK->udebug.lock); … … 385 385 /* Copy down the thread IDs */ 386 386 387 size_t max_ids = buf_size / sizeof( unative_t);387 size_t max_ids = buf_size / sizeof(sysarg_t); 388 388 size_t copied_ids = 0; 389 389 size_t extra_ids = 0; … … 404 404 if (copied_ids < max_ids) { 405 405 /* Using thread struct pointer as identification hash */ 406 id_buffer[copied_ids++] = ( unative_t) thread;406 id_buffer[copied_ids++] = (sysarg_t) thread; 407 407 } else 408 408 extra_ids++; … … 414 414 415 415 *buffer = id_buffer; 416 *stored = copied_ids * sizeof( unative_t);417 *needed = (copied_ids + extra_ids) * sizeof( unative_t);416 *stored = copied_ids * sizeof(sysarg_t); 417 *needed = (copied_ids + extra_ids) * sizeof(sysarg_t); 418 418 419 419 return 0; … … 463 463 { 464 464 /* Prepare a buffer to hold the arguments. */ 465 unative_t *arg_buffer = malloc(6 * sizeof(unative_t), 0);465 sysarg_t *arg_buffer = malloc(6 * sizeof(sysarg_t), 0); 466 466 467 467 /* On success, this will lock t->udebug.lock. */ … … 478 478 479 479 /* Copy to a local buffer before releasing the lock. */ 480 memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof( unative_t));480 memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof(sysarg_t)); 481 481 482 482 _thread_op_end(thread); … … 539 539 * 540 540 */ 541 int udebug_mem_read( unative_t uspace_addr, size_t n, void **buffer)541 int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer) 542 542 { 543 543 /* Verify task state */
Note:
See TracChangeset
for help on using the changeset viewer.