Rev 3424 | Rev 3431 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3424 | Rev 3425 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | call_t *ipc_call_alloc(int flags) |
86 | call_t *ipc_call_alloc(int flags) |
87 | { |
87 | { |
88 | call_t *call; |
88 | call_t *call; |
89 | 89 | ||
90 | call = slab_alloc(ipc_call_slab, flags); |
90 | call = slab_alloc(ipc_call_slab, flags); |
- | 91 | if (call) |
|
91 | _ipc_call_init(call); |
92 | _ipc_call_init(call); |
92 | 93 | ||
93 | return call; |
94 | return call; |
94 | } |
95 | } |
95 | 96 | ||
96 | /** Initialize a statically allocated call structure. |
97 | /** Initialize a statically allocated call structure. |
Line 159... | Line 160... | ||
159 | * |
160 | * |
160 | * @param phone Phone structure to be initialized. |
161 | * @param phone Phone structure to be initialized. |
161 | */ |
162 | */ |
162 | void ipc_phone_init(phone_t *phone) |
163 | void ipc_phone_init(phone_t *phone) |
163 | { |
164 | { |
164 | mutex_initialize(&phone->lock); |
165 | mutex_initialize(&phone->lock, MUTEX_PASSIVE); |
165 | phone->callee = NULL; |
166 | phone->callee = NULL; |
166 | phone->state = IPC_PHONE_FREE; |
167 | phone->state = IPC_PHONE_FREE; |
167 | atomic_set(&phone->active_calls, 0); |
168 | atomic_set(&phone->active_calls, 0); |
168 | } |
169 | } |
169 | 170 | ||
170 | /** Helper function to facilitate synchronous calls. |
171 | /** Helper function to facilitate synchronous calls. |
171 | * |
172 | * |
172 | * @param phone Destination kernel phone structure. |
173 | * @param phone Destination kernel phone structure. |
173 | * @param request Call structure with request. |
174 | * @param request Call structure with request. |
- | 175 | * |
|
- | 176 | * @return EOK on success or EINTR if the sleep was interrupted. |
|
174 | */ |
177 | */ |
175 | void ipc_call_sync(phone_t *phone, call_t *request) |
178 | int ipc_call_sync(phone_t *phone, call_t *request) |
176 | { |
179 | { |
177 | answerbox_t sync_box; |
180 | answerbox_t sync_box; |
178 | 181 | ||
179 | ipc_answerbox_init(&sync_box, TASK); |
182 | ipc_answerbox_init(&sync_box, TASK); |
180 | 183 | ||
181 | /* We will receive data in a special box. */ |
184 | /* We will receive data in a special box. */ |
182 | request->callerbox = &sync_box; |
185 | request->callerbox = &sync_box; |
183 | 186 | ||
184 | ipc_call(phone, request); |
187 | ipc_call(phone, request); |
185 | ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE); |
188 | if (!ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, |
- | 189 | SYNCH_FLAGS_INTERRUPTIBLE)) |
|
- | 190 | return EINTR; |
|
- | 191 | return EOK; |
|
186 | } |
192 | } |
187 | 193 | ||
188 | /** Answer a message which was not dispatched and is not listed in any queue. |
194 | /** Answer a message which was not dispatched and is not listed in any queue. |
189 | * |
195 | * |
190 | * @param call Call structure to be answered. |
196 | * @param call Call structure to be answered. |
Line 193... | Line 199... | ||
193 | { |
199 | { |
194 | answerbox_t *callerbox = call->callerbox; |
200 | answerbox_t *callerbox = call->callerbox; |
195 | 201 | ||
196 | call->flags |= IPC_CALL_ANSWERED; |
202 | call->flags |= IPC_CALL_ANSWERED; |
197 | 203 | ||
- | 204 | if (call->flags & IPC_CALL_FORWARDED) { |
|
- | 205 | if (call->caller_phone) { |
|
- | 206 | /* Demasquerade the caller phone. */ |
|
- | 207 | call->data.phone = call->caller_phone; |
|
- | 208 | } |
|
- | 209 | } |
|
- | 210 | ||
198 | spinlock_lock(&callerbox->lock); |
211 | spinlock_lock(&callerbox->lock); |
199 | list_append(&call->link, &callerbox->answers); |
212 | list_append(&call->link, &callerbox->answers); |
200 | spinlock_unlock(&callerbox->lock); |
213 | spinlock_unlock(&callerbox->lock); |
201 | waitq_wakeup(&callerbox->wq, WAKEUP_FIRST); |
214 | waitq_wakeup(&callerbox->wq, WAKEUP_FIRST); |
202 | } |
215 | } |
Line 345... | Line 358... | ||
345 | { |
358 | { |
346 | spinlock_lock(&oldbox->lock); |
359 | spinlock_lock(&oldbox->lock); |
347 | list_remove(&call->link); |
360 | list_remove(&call->link); |
348 | spinlock_unlock(&oldbox->lock); |
361 | spinlock_unlock(&oldbox->lock); |
349 | 362 | ||
350 | if (mode & IPC_FF_ROUTE_FROM_ME) |
363 | if (mode & IPC_FF_ROUTE_FROM_ME) { |
- | 364 | if (!call->caller_phone) |
|
- | 365 | call->caller_phone = call->data.phone; |
|
351 | call->data.phone = newphone; |
366 | call->data.phone = newphone; |
- | 367 | } |
|
352 | 368 | ||
353 | return ipc_call(newphone, call); |
369 | return ipc_call(newphone, call); |
354 | } |
370 | } |
355 | 371 | ||
356 | 372 | ||
Line 664... | Line 680... | ||
664 | printf("ABOX - CALLS:\n"); |
680 | printf("ABOX - CALLS:\n"); |
665 | for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls; |
681 | for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls; |
666 | tmp = tmp->next) { |
682 | tmp = tmp->next) { |
667 | call = list_get_instance(tmp, call_t, link); |
683 | call = list_get_instance(tmp, call_t, link); |
668 | printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
684 | printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
669 | " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
685 | " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
670 | " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, call->sender->taskid, |
686 | " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, |
- | 687 | call->sender->taskid, |
|
671 | IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
688 | IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
672 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
689 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
673 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
690 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
674 | call->flags); |
691 | call->flags); |
675 | } |
692 | } |
Line 678... | Line 695... | ||
678 | for (tmp = task->answerbox.dispatched_calls.next; |
695 | for (tmp = task->answerbox.dispatched_calls.next; |
679 | tmp != &task->answerbox.dispatched_calls; |
696 | tmp != &task->answerbox.dispatched_calls; |
680 | tmp = tmp->next) { |
697 | tmp = tmp->next) { |
681 | call = list_get_instance(tmp, call_t, link); |
698 | call = list_get_instance(tmp, call_t, link); |
682 | printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
699 | printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
683 | " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
700 | " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
684 | " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, call->sender->taskid, |
701 | " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, |
- | 702 | call->sender->taskid, |
|
685 | IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
703 | IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
686 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
704 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
687 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
705 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
688 | call->flags); |
706 | call->flags); |
689 | } |
707 | } |
690 | /* Print answerbox - calls */ |
708 | /* Print answerbox - calls */ |
691 | printf("ABOX - ANSWERS:\n"); |
709 | printf("ABOX - ANSWERS:\n"); |
692 | for (tmp = task->answerbox.answers.next; tmp != &task->answerbox.answers; |
710 | for (tmp = task->answerbox.answers.next; |
- | 711 | tmp != &task->answerbox.answers; |
|
693 | tmp = tmp->next) { |
712 | tmp = tmp->next) { |
694 | call = list_get_instance(tmp, call_t, link); |
713 | call = list_get_instance(tmp, call_t, link); |
695 | printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun |
714 | printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun |
696 | " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", |
715 | " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", |
697 | call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
716 | call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data), |
698 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
717 | IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), |
699 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
718 | IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), |
700 | call->flags); |
719 | call->flags); |
701 | } |
720 | } |