Changeset 03a8a8e in mainline for kernel/generic/src/ipc/ipc.c


Ignore:
Timestamp:
2012-09-15T18:19:04Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e9fe33b
Parents:
c97b086
Message:

Link each phone to its containing task.

This makes it possible to set the call's sender reliably using just the
info stored in the phone used to make the call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    rc97b086 r03a8a8e  
    7676        call->active = false;
    7777        call->forget = false;
    78         call->sender = TASK;
     78        call->sender = NULL;
    7979        call->buffer = NULL;
    8080}
     
    175175 *
    176176 * @param phone Phone structure to be initialized.
    177  *
    178  */
    179 void ipc_phone_init(phone_t *phone)
     177 * @param caller Owning task.
     178 *
     179 */
     180void ipc_phone_init(phone_t *phone, task_t *caller)
    180181{
    181182        mutex_initialize(&phone->lock, MUTEX_PASSIVE);
     183        phone->caller = caller;
    182184        phone->callee = NULL;
    183185        phone->state = IPC_PHONE_FREE;
     
    265267void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err)
    266268{
     269        task_t *caller = phone->caller;
     270
    267271        atomic_inc(&phone->active_calls);
    268272        call->caller_phone = phone;
     273        call->sender = caller;
    269274
    270275        call->active = true;
    271         spinlock_lock(&TASK->active_calls_lock);
    272         list_append(&call->ta_link, &TASK->active_calls);
    273         spinlock_unlock(&TASK->active_calls_lock);
     276        spinlock_lock(&caller->active_calls_lock);
     277        list_append(&call->ta_link, &caller->active_calls);
     278        spinlock_unlock(&caller->active_calls_lock);
    274279
    275280        call->data.phone = phone;
     
    288293static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
    289294{
     295        task_t *caller = phone->caller;
     296
    290297        /* Count sent ipc call */
    291         irq_spinlock_lock(&TASK->lock, true);
    292         TASK->ipc_info.call_sent++;
    293         irq_spinlock_unlock(&TASK->lock, true);
     298        irq_spinlock_lock(&caller->lock, true);
     299        caller->ipc_info.call_sent++;
     300        irq_spinlock_unlock(&caller->lock, true);
    294301       
    295302        if (!(call->flags & IPC_CALL_FORWARDED)) {
    296303                atomic_inc(&phone->active_calls);
    297304                call->caller_phone = phone;
     305                call->sender = caller;
    298306
    299307                call->active = true;
    300                 spinlock_lock(&TASK->active_calls_lock);
    301                 list_append(&call->ta_link, &TASK->active_calls);
    302                 spinlock_unlock(&TASK->active_calls_lock);
     308                spinlock_lock(&caller->active_calls_lock);
     309                list_append(&call->ta_link, &caller->active_calls);
     310                spinlock_unlock(&caller->active_calls_lock);
    303311
    304312                call->data.phone = phone;
    305                 call->data.task_id = TASK->taskid;
     313                call->data.task_id = phone->caller->taskid;
    306314        }
    307315       
     
    559567                        // FIXME: phone can become deallocated at any time now
    560568
    561                         // FIXME: call->sender == TASK
    562                        
    563569                        /*
    564570                         * Send one message to the answerbox for each
Note: See TracChangeset for help on using the changeset viewer.