- Timestamp:
- 2018-10-31T06:03:38Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 53ee7a0
- Parents:
- 94ab1fee
- git-author:
- Jakub Jermar <jakub@…> (2018-10-28 12:42:35)
- git-committer:
- Jakub Jermar <jakub@…> (2018-10-31 06:03:38)
- Location:
- kernel/generic
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/ipc.h
r94ab1fee r6769005 69 69 ipc_phone_state_t state; 70 70 atomic_t active_calls; 71 /** User-defined label */ 72 sysarg_t label; 71 73 kobject_t *kobject; 72 74 } phone_t; … … 101 103 list_t irq_notifs; 102 104 } answerbox_t; 103 104 typedef struct {105 sysarg_t args[IPC_CALL_LEN];106 /**107 * Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME,108 * or the task which answered the call.109 */110 task_id_t task_id;111 /** Phone which made or last masqueraded this call. */112 phone_t *phone;113 /** Flags */114 unsigned flags;115 /** User-defined label */116 sysarg_t label;117 /** Capability handle */118 cap_call_handle_t cap_handle;119 } ipc_data_t;120 105 121 106 typedef struct call { -
kernel/generic/src/ipc/ipc.c
r94ab1fee r6769005 205 205 phone->state = IPC_PHONE_FREE; 206 206 atomic_store(&phone->active_calls, 0); 207 phone->label = 0; 207 208 phone->kobject = NULL; 208 209 } … … 371 372 } 372 373 373 call->data. phone = phone;374 call->data.request_label = phone->label; 374 375 call->data.task_id = caller->taskid; 375 376 } … … 520 521 521 522 if (mode & IPC_FF_ROUTE_FROM_ME) { 522 call->data. phone = newphone;523 call->data.request_label = newphone->label; 523 524 call->data.task_id = TASK->taskid; 524 525 } … … 670 671 list_remove(&phone->link); 671 672 phone->state = IPC_PHONE_SLAMMED; 673 phone->label = 0; 672 674 673 675 if (notify_box) { -
kernel/generic/src/ipc/ops/conctmeto.c
r94ab1fee r6769005 46 46 * That will be done once the phone is connected. 47 47 */ 48 cap_phone_handle_t ph one_handle;49 kobject_t *p hone_obj;50 errno_t rc = phone_alloc(TASK, false, &ph one_handle, &phone_obj);48 cap_phone_handle_t phandle; 49 kobject_t *pobj; 50 errno_t rc = phone_alloc(TASK, false, &phandle, &pobj); 51 51 if (rc != EOK) { 52 call->priv = -1;52 call->priv = 0; 53 53 return rc; 54 54 } 55 55 56 /* Hand over phone_obj's reference to ARG5 */ 57 IPC_SET_ARG5(call->data, (sysarg_t) phone_obj->phone); 56 /* Move pobj's reference to call->priv */ 57 call->priv = (sysarg_t) pobj; 58 pobj = NULL; 58 59 59 60 /* Remember the handle */ 60 call->priv = CAP_HANDLE_RAW(phone_handle);61 IPC_SET_ARG5(call->data, (sysarg_t) phandle); 61 62 62 63 return EOK; … … 65 66 static errno_t request_forget(call_t *call) 66 67 { 67 cap_phone_handle_t ph one_handle = (cap_handle_t) call->priv;68 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call->data); 68 69 69 if (CAP_HANDLE_RAW(ph one_handle) < 0)70 if (CAP_HANDLE_RAW(phandle) < 0) 70 71 return EOK; 71 72 72 /* Hand over reference from ARG5 to phone->kobject */ 73 phone_t *phone = (phone_t *) IPC_GET_ARG5(call->data); 74 /* Drop phone->kobject's reference */ 75 kobject_put(phone->kobject); 76 cap_free(TASK, phone_handle); 73 /* Move reference from call->priv to pobj */ 74 kobject_t *pobj = (kobject_t *) call->priv; 75 call->priv = 0; 76 /* Drop pobj's reference */ 77 kobject_put(pobj); 78 cap_free(TASK, phandle); 77 79 78 80 return EOK; … … 81 83 static errno_t answer_preprocess(call_t *answer, ipc_data_t *olddata) 82 84 { 83 /* Hand over reference from ARG5 to phone */ 84 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 85 /* Get an extra reference for phone */ 86 kobject_t *pobj = (kobject_t *) answer->priv; 87 kobject_add_ref(pobj); 85 88 86 /* 87 * Get an extra reference and pass it in the answer data.88 */ 89 kobject_add_ref(phone->kobject);90 IPC_SET_ARG5(answer->data, (sysarg_t) phone);89 /* Set the recipient-assigned label */ 90 pobj->phone->label = IPC_GET_ARG5(answer->data); 91 92 /* Restore phone handle in answer's ARG5 */ 93 IPC_SET_ARG5(answer->data, IPC_GET_ARG5(*olddata)); 91 94 92 95 /* If the user accepted the call, connect */ 93 96 if (IPC_GET_RETVAL(answer->data) == EOK) { 94 /* Hand over reference from p honeto the answerbox */95 (void) ipc_phone_connect(p hone, &TASK->answerbox);97 /* Hand over reference from pobj to the answerbox */ 98 (void) ipc_phone_connect(pobj->phone, &TASK->answerbox); 96 99 } else { 97 kobject_put(phone->kobject); 100 /* Drop the extra reference */ 101 kobject_put(pobj); 98 102 } 99 103 … … 103 107 static errno_t answer_process(call_t *answer) 104 108 { 105 cap_phone_handle_t phone_handle = (cap_handle_t) answer->priv; 106 phone_t *phone = (phone_t *) IPC_GET_ARG5(answer->data); 109 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(answer->data); 110 /* Move the reference from answer->priv to pobj */ 111 kobject_t *pobj = (kobject_t *) answer->priv; 112 answer->priv = 0; 107 113 108 114 if (IPC_GET_RETVAL(answer->data)) { 109 if (CAP_HANDLE_RAW(ph one_handle) >= 0) {115 if (CAP_HANDLE_RAW(phandle) >= 0) { 110 116 /* 111 117 * Cleanup the unpublished capability and drop 112 118 * phone->kobject's reference. 113 119 */ 114 kobject_put(p hone->kobject);115 cap_free(TASK, ph one_handle);120 kobject_put(pobj); 121 cap_free(TASK, phandle); 116 122 } 117 123 } else { … … 121 127 * capability for each phone that wasn't hung up by the user. 122 128 */ 123 cap_publish(TASK, phone_handle, phone->kobject); 124 125 IPC_SET_ARG5(answer->data, CAP_HANDLE_RAW(phone_handle)); 129 cap_publish(TASK, phandle, pobj); 126 130 } 127 131 -
kernel/generic/src/ipc/ops/concttome.c
r94ab1fee r6769005 42 42 static int request_process(call_t *call, answerbox_t *box) 43 43 { 44 cap_phone_handle_t phone_handle; 45 kobject_t *phone_obj; 46 errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj); 47 call->priv = (sysarg_t) phone_obj; 48 IPC_SET_ARG5(call->data, 49 (rc == EOK) ? CAP_HANDLE_RAW(phone_handle) : CAP_NIL); 44 cap_phone_handle_t phandle = CAP_NIL; 45 kobject_t *pobj = NULL; 46 errno_t rc = phone_alloc(TASK, false, &phandle, &pobj); 47 if (rc == EOK) { 48 /* 49 * Set the sender-assigned label to the new phone. 50 */ 51 pobj->phone->label = IPC_GET_ARG5(call->data); 52 } 53 call->priv = (sysarg_t) pobj; 54 IPC_SET_ARG5(call->data, CAP_HANDLE_RAW(phandle)); 50 55 return 0; 51 56 } … … 53 58 static errno_t answer_cleanup(call_t *answer, ipc_data_t *olddata) 54 59 { 55 cap_phone_handle_t ph one_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);56 kobject_t *p hone_obj = (kobject_t *) answer->priv;60 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*olddata); 61 kobject_t *pobj = (kobject_t *) answer->priv; 57 62 58 if (CAP_HANDLE_VALID(ph one_handle)) {59 kobject_put(p hone_obj);60 cap_free(TASK, ph one_handle);63 if (CAP_HANDLE_VALID(phandle)) { 64 kobject_put(pobj); 65 cap_free(TASK, phandle); 61 66 } 62 67 … … 66 71 static errno_t answer_preprocess(call_t *answer, ipc_data_t *olddata) 67 72 { 68 cap_phone_handle_t ph one_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);69 kobject_t *p hone_obj = (kobject_t *) answer->priv;73 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*olddata); 74 kobject_t *pobj = (kobject_t *) answer->priv; 70 75 71 76 if (IPC_GET_RETVAL(answer->data) != EOK) { 72 77 /* The connection was not accepted */ 73 78 answer_cleanup(answer, olddata); 74 } else if (CAP_HANDLE_VALID(ph one_handle)) {79 } else if (CAP_HANDLE_VALID(phandle)) { 75 80 /* 76 81 * The connection was accepted … … 81 86 * will be consumed by ipc_phone_connect(). 82 87 */ 83 kobject_add_ref(p hone_obj);88 kobject_add_ref(pobj); 84 89 85 if (ipc_phone_connect(p hone_obj->phone,90 if (ipc_phone_connect(pobj->phone, 86 91 &answer->sender->answerbox)) { 87 92 /* Pass the reference to the capability */ 88 cap_publish(TASK, phone_handle, phone_obj); 89 /* Set 'phone hash' as ARG5 of response */ 90 IPC_SET_ARG5(answer->data, 91 (sysarg_t) phone_obj->phone); 93 cap_publish(TASK, phandle, pobj); 92 94 } else { 93 95 /* The answerbox is shutting down. */ -
kernel/generic/src/ipc/sysipc.c
r94ab1fee r6769005 202 202 kobject_put(phone->kobject); 203 203 phone->state = IPC_PHONE_SLAMMED; 204 phone->label = 0; 204 205 irq_spinlock_unlock(&phone->callee->lock, true); 205 206 } … … 386 387 387 388 /* Set the user-defined label */ 388 call->data. label = label;389 call->data.answer_label = label; 389 390 390 391 errno_t res = request_preprocess(call, kobj->phone); … … 430 431 431 432 /* Set the user-defined label */ 432 call->data. label = label;433 call->data.answer_label = label; 433 434 434 435 errno_t res = request_preprocess(call, kobj->phone); … … 504 505 if (!method_is_immutable(IPC_GET_IMETHOD(call->data))) { 505 506 if (method_is_system(IPC_GET_IMETHOD(call->data))) { 506 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) 507 phone_dealloc((cap_phone_handle_t) 508 IPC_GET_ARG5(call->data)); 507 if (IPC_GET_IMETHOD(call->data) == 508 IPC_M_CONNECT_TO_ME) { 509 kobject_put((kobject_t *) call->priv); 510 call->priv = 0; 511 cap_free(TASK, 512 (cap_handle_t) IPC_GET_ARG5(call->data)); 513 } 509 514 510 515 IPC_SET_ARG1(call->data, imethod); … … 771 776 call->data.flags = call->flags; 772 777 if (call->flags & IPC_CALL_NOTIF) { 773 /* Set in_phone_hashto the interrupt counter */774 call->data. phone = (void *) call->priv;778 /* Set the request_label to the interrupt counter */ 779 call->data.request_label = (sysarg_t) call->priv; 775 780 776 781 call->data.cap_handle = CAP_NIL;
Note:
See TracChangeset
for help on using the changeset viewer.