Changeset d51a0d6 in mainline
- Timestamp:
- 2017-11-21T22:23:00Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 35f2bb1
- Parents:
- c4c6025
- Location:
- kernel/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
rc4c6025 rd51a0d6 53 53 54 54 typedef enum { 55 KOBJECT_TYPE_CALL, 56 KOBJECT_TYPE_IRQ, 55 57 KOBJECT_TYPE_PHONE, 56 KOBJECT_TYPE_IRQ,57 58 KOBJECT_TYPE_MAX 58 59 } kobject_type_t; 59 60 60 61 struct task; 62 63 struct call; 64 struct irq; 61 65 struct phone; 62 struct irq;63 66 64 67 struct kobject; … … 79 82 union { 80 83 void *raw; 84 struct call *call; 85 struct irq *irq; 81 86 struct phone *phone; 82 struct irq *irq;83 87 }; 84 88 } kobject_t; -
kernel/generic/include/ipc/ipc.h
rc4c6025 rd51a0d6 109 109 110 110 typedef struct { 111 kobject_t *kobject; 112 111 113 /** 112 114 * Task link. … … 115 117 */ 116 118 link_t ta_link; 117 118 atomic_t refcnt;119 119 120 120 /** Answerbox link. */ -
kernel/generic/src/ipc/ipc.c
rc4c6025 rd51a0d6 87 87 } 88 88 89 void ipc_call_hold(call_t *call) 90 { 91 atomic_inc(&call->refcnt); 92 } 93 94 void ipc_call_release(call_t *call) 95 { 96 if (atomic_predec(&call->refcnt) == 0) { 97 if (call->buffer) 98 free(call->buffer); 99 if (call->caller_phone) 100 kobject_put(call->caller_phone->kobject); 101 slab_free(call_slab, call); 102 } 103 } 89 static void call_destroy(void *arg) 90 { 91 call_t *call = (call_t *) arg; 92 93 if (call->buffer) 94 free(call->buffer); 95 if (call->caller_phone) 96 kobject_put(call->caller_phone->kobject); 97 slab_free(call_slab, call); 98 } 99 100 static kobject_ops_t call_kobject_ops = { 101 .destroy = call_destroy 102 }; 104 103 105 104 /** Allocate and initialize a call structure. … … 117 116 { 118 117 call_t *call = slab_alloc(call_slab, flags); 119 if (call) { 120 _ipc_call_init(call); 121 ipc_call_hold(call); 122 } 118 if (!call) 119 return NULL; 120 kobject_t *kobj = (kobject_t *) malloc(sizeof(kobject_t), flags); 121 if (!kobj) { 122 slab_free(call_slab, call); 123 return NULL; 124 } 125 126 _ipc_call_init(call); 127 kobject_initialize(kobj, KOBJECT_TYPE_CALL, call, &call_kobject_ops); 128 call->kobject = kobj; 123 129 124 130 return call; 125 }126 127 /** Deallocate a call structure.128 *129 * @param call Call structure to be freed.130 *131 */132 void ipc_call_free(call_t *call)133 {134 ipc_call_release(call);135 131 } 136 132 … … 290 286 /* This is a forgotten call and call->sender is not valid. */ 291 287 spinlock_unlock(&call->forget_lock); 292 ipc_call_free(call);288 kobject_put(call->kobject); 293 289 return; 294 290 } else { … … 705 701 * must hold a reference to it. 706 702 */ 707 ipc_call_hold(call);703 kobject_add_ref(call->kobject); 708 704 709 705 spinlock_unlock(&call->forget_lock); … … 714 710 SYSIPC_OP(request_forget, call); 715 711 716 ipc_call_release(call);712 kobject_put(call->kobject); 717 713 } 718 714 … … 822 818 SYSIPC_OP(answer_process, call); 823 819 824 ipc_call_free(call);820 kobject_put(call->kobject); 825 821 goto restart; 826 822 } -
kernel/generic/src/ipc/sysipc.c
rc4c6025 rd51a0d6 286 286 #endif 287 287 288 ipc_call_hold(call);288 kobject_add_ref(call->kobject); 289 289 rc = ipc_call_sync(kobj->phone, call); 290 290 spinlock_lock(&call->forget_lock); 291 291 bool forgotten = call->forget; 292 292 spinlock_unlock(&call->forget_lock); 293 ipc_call_release(call);293 kobject_put(call->kobject); 294 294 295 295 #ifdef CONFIG_UDEBUG … … 306 306 * deallocation. 307 307 */ 308 ipc_call_free(call);308 kobject_put(call->kobject); 309 309 } else { 310 310 /* … … 323 323 324 324 memcpy(data->args, call->data.args, sizeof(data->args)); 325 ipc_call_free(call);325 kobject_put(call->kobject); 326 326 kobject_put(kobj); 327 327 … … 420 420 sizeof(call->data.args)); 421 421 if (rc != 0) { 422 ipc_call_free(call);422 kobject_put(call->kobject); 423 423 kobject_put(kobj); 424 424 return (sysarg_t) rc; … … 753 753 STRUCT_TO_USPACE(calldata, &call->data); 754 754 755 ipc_call_free(call);755 kobject_put(call->kobject); 756 756 757 757 return ((sysarg_t) call) | IPC_CALLID_NOTIFICATION; … … 762 762 763 763 if (call->flags & IPC_CALL_DISCARD_ANSWER) { 764 ipc_call_free(call);764 kobject_put(call->kobject); 765 765 goto restart; 766 766 } 767 767 768 768 STRUCT_TO_USPACE(calldata, &call->data); 769 ipc_call_free(call);769 kobject_put(call->kobject); 770 770 771 771 return ((sysarg_t) call) | IPC_CALLID_ANSWERED;
Note:
See TracChangeset
for help on using the changeset viewer.