Changeset 8565a42 in mainline for kernel/generic/src/ipc


Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
kernel/generic/src/ipc
Files:
12 edited

Legend:

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

    r3061bc1 r8565a42  
    6161{
    6262        assert(evno < EVENT_TASK_END);
    63        
     63
    6464        event_t *event;
    65        
     65
    6666        if (evno < EVENT_END)
    6767                event = &events[(event_type_t) evno];
    6868        else
    6969                event = &task->events[(event_task_type_t) evno - EVENT_END];
    70        
     70
    7171        return event;
    7272}
     
    9696        for (unsigned int i = 0; i < EVENT_END; i++) {
    9797                spinlock_lock(&events[i].lock);
    98                
     98
    9999                if (events[i].answerbox == answerbox) {
    100100                        events[i].answerbox = NULL;
     
    103103                        events[i].masked = false;
    104104                }
    105                
     105
    106106                spinlock_unlock(&events[i].lock);
    107107        }
     
    125125{
    126126        assert(evno < EVENT_END);
    127        
     127
    128128        _event_set_unmask_callback(evno2event(evno, NULL), callback);
    129129}
     
    134134        assert(evno >= (int) EVENT_END);
    135135        assert(evno < EVENT_TASK_END);
    136                
     136
    137137        _event_set_unmask_callback(evno2event(evno, task), callback);
    138138}
     
    144144
    145145        spinlock_lock(&event->lock);
    146        
     146
    147147        if (event->answerbox != NULL) {
    148148                if (!event->masked) {
    149149                        call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    150                        
     150
    151151                        if (call) {
    152152                                call->flags |= IPC_CALL_NOTIF;
    153153                                call->priv = ++event->counter;
    154                                
     154
    155155                                IPC_SET_IMETHOD(call->data, event->imethod);
    156156                                IPC_SET_ARG1(call->data, a1);
     
    159159                                IPC_SET_ARG4(call->data, a4);
    160160                                IPC_SET_ARG5(call->data, a5);
    161                                
     161
    162162                                call->data.task_id = TASK ? TASK->taskid : 0;
    163                                
     163
    164164                                irq_spinlock_lock(&event->answerbox->irq_lock,
    165165                                    true);
     
    168168                                irq_spinlock_unlock(&event->answerbox->irq_lock,
    169169                                    true);
    170                                
     170
    171171                                waitq_wakeup(&event->answerbox->wq,
    172172                                    WAKEUP_FIRST);
    173                                
     173
    174174                                if (mask)
    175175                                        event->masked = true;
    176                                
     176
    177177                                res = EOK;
    178178                        } else
     
    182182        } else
    183183                res = ENOENT;
    184        
     184
    185185        spinlock_unlock(&event->lock);
    186186        return res;
     
    210210{
    211211        assert(evno < EVENT_END);
    212        
     212
    213213        return event_enqueue(evno2event(evno, NULL), mask, a1, a2, a3, a4, a5);
    214214}
     
    239239        assert(evno >= (int) EVENT_END);
    240240        assert(evno < EVENT_TASK_END);
    241        
     241
    242242        return event_enqueue(evno2event(evno, task), mask, a1, a2, a3, a4, a5);
    243243}
     
    259259{
    260260        errno_t res;
    261        
    262         spinlock_lock(&event->lock);
    263        
     261
     262        spinlock_lock(&event->lock);
     263
    264264        if (event->answerbox == NULL) {
    265265                event->answerbox = answerbox;
     
    270270        } else
    271271                res = EEXIST;
    272        
    273         spinlock_unlock(&event->lock);
    274        
     272
     273        spinlock_unlock(&event->lock);
     274
    275275        return res;
    276276}
     
    289289{
    290290        errno_t res;
    291        
    292         spinlock_lock(&event->lock);
    293        
     291
     292        spinlock_lock(&event->lock);
     293
    294294        if (event->answerbox == answerbox) {
    295295                event->answerbox = NULL;
     
    300300        } else
    301301                res = ENOENT;
    302        
    303         spinlock_unlock(&event->lock);
    304        
     302
     303        spinlock_unlock(&event->lock);
     304
    305305        return res;
    306306}
     
    317317        event_callback_t callback = event->unmask_callback;
    318318        spinlock_unlock(&event->lock);
    319        
     319
    320320        /*
    321321         * Check if there is an unmask callback
     
    342342        if (evno >= EVENT_TASK_END)
    343343                return ELIMIT;
    344        
     344
    345345        return (sys_errno_t) event_subscribe(evno2event(evno, TASK),
    346346            (sysarg_t) imethod, &TASK->answerbox);
     
    361361        if (evno >= EVENT_TASK_END)
    362362                return ELIMIT;
    363        
     363
    364364        return (sys_errno_t) event_unsubscribe(evno2event(evno, TASK),
    365365            &TASK->answerbox);
     
    383383        if (evno >= EVENT_TASK_END)
    384384                return ELIMIT;
    385        
     385
    386386        event_unmask(evno2event(evno, TASK));
    387387
  • kernel/generic/src/ipc/ipc.c

    r3061bc1 r8565a42  
    127127        kobject_initialize(kobj, KOBJECT_TYPE_CALL, call, &call_kobject_ops);
    128128        call->kobject = kobj;
    129        
     129
    130130        return call;
    131131}
     
    212212        answerbox_t *mybox = slab_alloc(answerbox_cache, 0);
    213213        ipc_answerbox_init(mybox, TASK);
    214        
     214
    215215        /* We will receive data in a special box. */
    216216        request->callerbox = mybox;
    217        
     217
    218218        errno_t rc = ipc_call(phone, request);
    219219        if (rc != EOK) {
     
    247247                        ipc_forget_call(request);       /* releases locks */
    248248                        rc = EINTR;
    249                        
     249
    250250                } else {
    251251                        spinlock_unlock(&TASK->active_calls_lock);
     
    264264        }
    265265        assert(!answer || request == answer);
    266        
     266
    267267        slab_free(answerbox_cache, mybox);
    268268        return rc;
     
    305305            &call->sender->answerbox;
    306306        bool do_lock = ((!selflocked) || (callerbox != &TASK->answerbox));
    307        
     307
    308308        call->flags |= IPC_CALL_ANSWERED;
    309        
     309
    310310        call->data.task_id = TASK->taskid;
    311        
     311
    312312        if (do_lock)
    313313                irq_spinlock_lock(&callerbox->lock, true);
    314        
     314
    315315        list_append(&call->ab_link, &callerbox->answers);
    316        
     316
    317317        if (do_lock)
    318318                irq_spinlock_unlock(&callerbox->lock, true);
    319        
     319
    320320        waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
    321321}
     
    333333        list_remove(&call->ab_link);
    334334        irq_spinlock_unlock(&box->lock, true);
    335        
     335
    336336        /* Send back answer */
    337337        _ipc_answer_free_call(call, false);
     
    395395        caller->ipc_info.call_sent++;
    396396        irq_spinlock_unlock(&caller->lock, true);
    397        
     397
    398398        if (!(call->flags & IPC_CALL_FORWARDED))
    399399                _ipc_call_actions_internal(phone, call, preforget);
    400        
     400
    401401        irq_spinlock_lock(&box->lock, true);
    402402        list_append(&call->ab_link, &box->calls);
    403403        irq_spinlock_unlock(&box->lock, true);
    404        
     404
    405405        waitq_wakeup(&box->wq, WAKEUP_FIRST);
    406406}
     
    426426                                ipc_backsend_err(phone, call, ENOENT);
    427427                }
    428                
     428
    429429                return ENOENT;
    430430        }
    431        
     431
    432432        answerbox_t *box = phone->callee;
    433433        _ipc_call(phone, box, call, false);
    434        
     434
    435435        mutex_unlock(&phone->lock);
    436436        return 0;
     
    457457                return EINVAL;
    458458        }
    459        
     459
    460460        answerbox_t *box = phone->callee;
    461461        if (phone->state != IPC_PHONE_SLAMMED) {
     
    467467                /* Drop the answerbox reference */
    468468                kobject_put(phone->kobject);
    469                
     469
    470470                call_t *call = ipc_call_alloc(0);
    471471                IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
     
    474474                _ipc_call(phone, box, call, false);
    475475        }
    476        
     476
    477477        phone->state = IPC_PHONE_HUNGUP;
    478478        mutex_unlock(&phone->lock);
    479        
     479
    480480        return EOK;
    481481}
     
    504504        list_remove(&call->ab_link);
    505505        irq_spinlock_unlock(&oldbox->lock, true);
    506        
     506
    507507        if (mode & IPC_FF_ROUTE_FROM_ME) {
    508508                call->data.phone = newphone;
    509509                call->data.task_id = TASK->taskid;
    510510        }
    511        
     511
    512512        return ipc_call(newphone, call);
    513513}
     
    536536        uint64_t call_cnt = 0;
    537537        errno_t rc;
    538        
     538
    539539restart:
    540540        rc = waitq_sleep_timeout(&box->wq, usec, flags, NULL);
    541541        if (rc != EOK)
    542542                return NULL;
    543        
     543
    544544        irq_spinlock_lock(&box->lock, true);
    545545        if (!list_empty(&box->irq_notifs)) {
    546546                /* Count received IRQ notification */
    547547                irq_cnt++;
    548                
     548
    549549                irq_spinlock_lock(&box->irq_lock, false);
    550                
     550
    551551                request = list_get_instance(list_first(&box->irq_notifs),
    552552                    call_t, ab_link);
    553553                list_remove(&request->ab_link);
    554                
     554
    555555                irq_spinlock_unlock(&box->irq_lock, false);
    556556        } else if (!list_empty(&box->answers)) {
    557557                /* Count received answer */
    558558                answer_cnt++;
    559                
     559
    560560                /* Handle asynchronous answers */
    561561                request = list_get_instance(list_first(&box->answers),
     
    566566                /* Count received call */
    567567                call_cnt++;
    568                
     568
    569569                /* Handle requests */
    570570                request = list_get_instance(list_first(&box->calls),
    571571                    call_t, ab_link);
    572572                list_remove(&request->ab_link);
    573                
     573
    574574                /* Append request to dispatch queue */
    575575                list_append(&request->ab_link, &box->dispatched_calls);
     
    579579                goto restart;
    580580        }
    581        
     581
    582582        irq_spinlock_pass(&box->lock, &TASK->lock);
    583        
     583
    584584        TASK->ipc_info.irq_notif_received += irq_cnt;
    585585        TASK->ipc_info.answer_received += answer_cnt;
    586586        TASK->ipc_info.call_received += call_cnt;
    587        
     587
    588588        irq_spinlock_unlock(&TASK->lock, true);
    589        
     589
    590590        return request;
    591591}
     
    602602                call_t *call = list_get_instance(list_first(lst), call_t,
    603603                    ab_link);
    604                
     604
    605605                list_remove(&call->ab_link);
    606606
     
    631631        phone_t *phone;
    632632        DEADLOCK_PROBE_INIT(p_phonelck);
    633        
     633
    634634        /* Disconnect all phones connected to our answerbox */
    635635restart_phones:
     
    643643                        goto restart_phones;
    644644                }
    645                
     645
    646646                /* Disconnect phone */
    647647                assert(phone->state == IPC_PHONE_CONNECTED);
    648                
     648
    649649                list_remove(&phone->link);
    650650                phone->state = IPC_PHONE_SLAMMED;
    651                
     651
    652652                if (notify_box) {
    653653                        task_hold(phone->caller);
     
    671671
    672672                        kobject_put(phone->kobject);
    673                        
     673
    674674                        /* Must start again */
    675675                        goto restart_phones;
    676676                }
    677                
     677
    678678                mutex_unlock(&phone->lock);
    679679                kobject_put(phone->kobject);
    680680        }
    681        
     681
    682682        irq_spinlock_unlock(&box->lock, true);
    683683}
     
    727727                return;
    728728        }
    729        
     729
    730730        call = list_get_instance(list_first(&TASK->active_calls), call_t,
    731731            ta_link);
     
    811811        if (restart)
    812812                goto restart;
    813        
     813
    814814        call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
    815815            SYNCH_FLAGS_NONE);
     
    872872        caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_PHONE,
    873873            phone_cap_cleanup_cb, NULL);
    874        
     874
    875875        /* Unsubscribe from any event notifications. */
    876876        event_cleanup_answerbox(&TASK->answerbox);
    877        
     877
    878878        /* Disconnect all connected IRQs */
    879879        caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_IRQ, irq_cap_cleanup_cb,
    880880            NULL);
    881        
     881
    882882        /* Disconnect all phones connected to our regular answerbox */
    883883        ipc_answerbox_slam_phones(&TASK->answerbox, false);
    884        
     884
    885885#ifdef CONFIG_UDEBUG
    886886        /* Clean up kbox thread and communications */
     
    891891        caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_CALL, call_cap_cleanup_cb,
    892892            NULL);
    893        
     893
    894894        /* Answer all messages in 'calls' and 'dispatched_calls' queues */
    895895        ipc_cleanup_call_list(&TASK->answerbox, &TASK->answerbox.calls);
    896896        ipc_cleanup_call_list(&TASK->answerbox,
    897897            &TASK->answerbox.dispatched_calls);
    898        
     898
    899899        ipc_forget_all_active_calls();
    900900        ipc_wait_for_all_answered_calls();
     
    921921                printf("%10p ", call);
    922922#endif
    923                
     923
    924924#ifdef __64_BITS__
    925925                printf("%18p ", call);
    926926#endif
    927                
     927
    928928                spinlock_lock(&call->forget_lock);
    929929
     
    954954                printf("%-11d %7" PRIun " ", cap->handle,
    955955                    atomic_get(&phone->active_calls));
    956                
     956
    957957                switch (phone->state) {
    958958                case IPC_PHONE_CONNECTING:
     
    973973                        break;
    974974                }
    975                
     975
    976976                printf("\n");
    977977        }
     
    996996        task_hold(task);
    997997        irq_spinlock_unlock(&tasks_lock, true);
    998        
     998
    999999        printf("[phone cap] [calls] [state\n");
    1000        
     1000
    10011001        caps_apply_to_kobject_type(task, KOBJECT_TYPE_PHONE,
    10021002            print_task_phone_cb, NULL);
    1003        
     1003
    10041004        irq_spinlock_lock(&task->lock, true);
    10051005        irq_spinlock_lock(&task->answerbox.lock, false);
    1006        
     1006
    10071007#ifdef __32_BITS__
    10081008        printf("[call id ] [method] [arg1] [arg2] [arg3] [arg4] [arg5]"
    10091009            " [flags] [sender\n");
    10101010#endif
    1011        
     1011
    10121012#ifdef __64_BITS__
    10131013        printf("[call id         ] [method] [arg1] [arg2] [arg3] [arg4]"
    10141014            " [arg5] [flags] [sender\n");
    10151015#endif
    1016        
     1016
    10171017        printf(" --- incomming calls ---\n");
    10181018        ipc_print_call_list(&task->answerbox.calls);
     
    10211021        printf(" --- incoming answers ---\n");
    10221022        ipc_print_call_list(&task->answerbox.answers);
    1023        
     1023
    10241024        irq_spinlock_unlock(&task->answerbox.lock, false);
    10251025        irq_spinlock_unlock(&task->lock, true);
  • kernel/generic/src/ipc/ipcrsc.c

    r3061bc1 r8565a42  
    193193                    &phone_kobject_ops);
    194194                phone->kobject = kobject;
    195                
     195
    196196                cap_publish(task, handle, kobject);
    197197
     
    213213        if (!kobj)
    214214                return;
    215        
     215
    216216        assert(kobj->phone);
    217217        assert(kobj->phone->state == IPC_PHONE_CONNECTING);
    218        
     218
    219219        kobject_put(kobj);
    220220        cap_free(TASK, handle);
     
    232232        if (!phone_obj)
    233233                return false;
    234        
     234
    235235        assert(phone_obj->phone->state == IPC_PHONE_CONNECTING);
    236        
     236
    237237        /* Hand over phone_obj reference to the answerbox */
    238238        return ipc_phone_connect(phone_obj->phone, box);
  • kernel/generic/src/ipc/irq.c

    r3061bc1 r8565a42  
    8585        for (size_t i = 0; i < rangecount; i++)
    8686                pbase[i] = ranges[i].base;
    87        
     87
    8888        /* Map the PIO ranges into the kernel virtual address space. */
    8989        for (size_t i = 0; i < rangecount; i++) {
     
    100100                }
    101101        }
    102        
     102
    103103        /* Rewrite the IRQ code addresses from physical to kernel virtual. */
    104104        for (size_t i = 0; i < cmdcount; i++) {
    105105                uintptr_t addr;
    106106                size_t size;
    107                
     107
    108108                /* Process only commands that use an address. */
    109109                switch (cmds[i].cmd) {
     
    127127                        continue;
    128128                }
    129                
     129
    130130                addr = (uintptr_t) cmds[i].addr;
    131                
     131
    132132                size_t j;
    133133                for (j = 0; j < rangecount; j++) {
     
    135135                        if (!iswithin(pbase[j], ranges[j].size, addr, size))
    136136                                continue;
    137                        
     137
    138138                        /* Switch the command to a kernel virtual address. */
    139139                        addr -= pbase[j];
    140140                        addr += ranges[j].base;
    141                        
     141
    142142                        cmds[i].addr = (void *) addr;
    143143                        break;
    144144                }
    145                
     145
    146146                if (j == rangecount) {
    147147                        /*
     
    154154                }
    155155        }
    156        
     156
    157157        free(pbase);
    158158        return EOK;
     
    172172                if (cmds[i].cmd >= CMD_LAST)
    173173                        return EINVAL;
    174                
     174
    175175                if (cmds[i].srcarg >= IPC_CALL_LEN)
    176176                        return EINVAL;
    177                
     177
    178178                if (cmds[i].dstarg >= IPC_CALL_LEN)
    179179                        return EINVAL;
    180                
     180
    181181                switch (cmds[i].cmd) {
    182182                case CMD_PREDICATE:
     
    188188                        if (i + cmds[i].value > cmdcount)
    189189                                return EINVAL;
    190                        
     190
    191191                        break;
    192192                default:
     
    194194                }
    195195        }
    196        
     196
    197197        return EOK;
    198198}
     
    224224        irq_pio_range_t *ranges = NULL;
    225225        irq_cmd_t *cmds = NULL;
    226        
     226
    227227        irq_code_t *code = malloc(sizeof(*code), 0);
    228228        errno_t rc = copy_from_uspace(code, ucode, sizeof(*code));
    229229        if (rc != EOK)
    230230                goto error;
    231        
     231
    232232        if ((code->rangecount > IRQ_MAX_RANGE_COUNT) ||
    233233            (code->cmdcount > IRQ_MAX_PROG_SIZE))
    234234                goto error;
    235        
     235
    236236        ranges = malloc(sizeof(code->ranges[0]) * code->rangecount, 0);
    237237        rc = copy_from_uspace(ranges, code->ranges,
     
    239239        if (rc != EOK)
    240240                goto error;
    241        
     241
    242242        cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
    243243        rc = copy_from_uspace(cmds, code->cmds,
     
    245245        if (rc != EOK)
    246246                goto error;
    247        
     247
    248248        rc = code_check(cmds, code->cmdcount);
    249249        if (rc != EOK)
    250250                goto error;
    251        
     251
    252252        rc = ranges_map_and_apply(ranges, code->rangecount, cmds,
    253253            code->cmdcount);
    254254        if (rc != EOK)
    255255                goto error;
    256        
     256
    257257        code->ranges = ranges;
    258258        code->cmds = cmds;
    259        
     259
    260260        return code;
    261        
     261
    262262error:
    263263        if (cmds)
    264264                free(cmds);
    265        
     265
    266266        if (ranges)
    267267                free(ranges);
    268        
     268
    269269        free(code);
    270270        return NULL;
     
    275275        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
    276276        irq_spinlock_lock(&irq->lock, false);
    277        
     277
    278278        if (irq->notif_cfg.hashed_in) {
    279279                /* Remove the IRQ from the uspace IRQ hash table. */
     
    318318        if ((inr < 0) || (inr > last_inr))
    319319                return ELIMIT;
    320        
     320
    321321        irq_code_t *code;
    322322        if (ucode) {
     
    326326        } else
    327327                code = NULL;
    328        
     328
    329329        /*
    330330         * Allocate and populate the IRQ kernel object.
     
    334334        if (rc != EOK)
    335335                return rc;
    336        
     336
    337337        rc = copy_to_uspace(uspace_handle, &handle, sizeof(cap_handle_t));
    338338        if (rc != EOK) {
     
    353353                return ENOMEM;
    354354        }
    355        
     355
    356356        irq_initialize(irq);
    357357        irq->inr = inr;
     
    363363        irq->notif_cfg.code = code;
    364364        irq->notif_cfg.counter = 0;
    365        
     365
    366366        /*
    367367         * Insert the IRQ structure into the uspace IRQ hash table.
     
    369369        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
    370370        irq_spinlock_lock(&irq->lock, false);
    371        
     371
    372372        irq->notif_cfg.hashed_in = true;
    373373        hash_table_insert(&irq_uspace_hash_table, &irq->link);
    374        
     374
    375375        irq_spinlock_unlock(&irq->lock, false);
    376376        irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
     
    378378        kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq, &irq_kobject_ops);
    379379        cap_publish(TASK, handle, kobject);
    380        
     380
    381381        return EOK;
    382382}
     
    395395        if (!kobj)
    396396                return ENOENT;
    397        
     397
    398398        assert(kobj->irq->notif_cfg.answerbox == box);
    399399
     
    402402        kobject_put(kobj);
    403403        cap_free(TASK, handle);
    404        
     404
    405405        return EOK;
    406406}
     
    419419        list_append(&call->ab_link, &irq->notif_cfg.answerbox->irq_notifs);
    420420        irq_spinlock_unlock(&irq->notif_cfg.answerbox->irq_lock, false);
    421        
     421
    422422        waitq_wakeup(&irq->notif_cfg.answerbox->wq, WAKEUP_FIRST);
    423423}
     
    435435        irq_code_t *code = irq->notif_cfg.code;
    436436        uint32_t *scratch = irq->notif_cfg.scratch;
    437        
     437
    438438        if (!irq->notif_cfg.notify)
    439439                return IRQ_DECLINE;
    440        
     440
    441441        if (!code)
    442442                return IRQ_DECLINE;
    443        
     443
    444444        for (size_t i = 0; i < code->cmdcount; i++) {
    445445                uintptr_t srcarg = code->cmds[i].srcarg;
    446446                uintptr_t dstarg = code->cmds[i].dstarg;
    447                
     447
    448448                switch (code->cmds[i].cmd) {
    449449                case CMD_PIO_READ_8:
     
    493493                        if (scratch[srcarg] == 0)
    494494                                i += code->cmds[i].value;
    495                        
     495
    496496                        break;
    497497                case CMD_ACCEPT:
     
    502502                }
    503503        }
    504        
     504
    505505        return IRQ_DECLINE;
    506506}
     
    516516{
    517517        assert(irq);
    518        
     518
    519519        assert(interrupts_disabled());
    520520        assert(irq_spinlock_locked(&irq->lock));
    521        
     521
    522522        if (irq->notif_cfg.answerbox) {
    523523                call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    524524                if (!call)
    525525                        return;
    526                
     526
    527527                call->flags |= IPC_CALL_NOTIF;
    528528                /* Put a counter to the message */
    529529                call->priv = ++irq->notif_cfg.counter;
    530                
     530
    531531                /* Set up args */
    532532                IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
     
    536536                IPC_SET_ARG4(call->data, irq->notif_cfg.scratch[4]);
    537537                IPC_SET_ARG5(call->data, irq->notif_cfg.scratch[5]);
    538                
     538
    539539                send_call(irq, call);
    540540        }
     
    555555{
    556556        irq_spinlock_lock(&irq->lock, true);
    557        
     557
    558558        if (irq->notif_cfg.answerbox) {
    559559                call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     
    562562                        return;
    563563                }
    564                
     564
    565565                call->flags |= IPC_CALL_NOTIF;
    566566                /* Put a counter to the message */
    567567                call->priv = ++irq->notif_cfg.counter;
    568                
     568
    569569                IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
    570570                IPC_SET_ARG1(call->data, a1);
     
    573573                IPC_SET_ARG4(call->data, a4);
    574574                IPC_SET_ARG5(call->data, a5);
    575                
     575
    576576                send_call(irq, call);
    577577        }
    578        
     578
    579579        irq_spinlock_unlock(&irq->lock, true);
    580580}
  • kernel/generic/src/ipc/kbox.c

    r3061bc1 r8565a42  
    6363        TASK->kb.finished = true;
    6464        mutex_unlock(&TASK->kb.cleanup_lock);
    65        
     65
    6666        bool have_kb_thread = (TASK->kb.thread != NULL);
    67        
     67
    6868        /*
    6969         * From now on nobody will try to connect phones or attach
    7070         * kbox threads
    7171         */
    72        
     72
    7373        /*
    7474         * Disconnect all phones connected to our kbox. Passing true for
     
    7878         */
    7979        ipc_answerbox_slam_phones(&TASK->kb.box, have_kb_thread);
    80        
     80
    8181        /*
    8282         * If the task was being debugged, clean up debugging session.
     
    8787        udebug_task_cleanup(TASK);
    8888        mutex_unlock(&TASK->udebug.lock);
    89        
     89
    9090        if (have_kb_thread) {
    9191                LOG("Join kb.thread.");
     
    9595                TASK->kb.thread = NULL;
    9696        }
    97        
     97
    9898        /* Answer all messages in 'calls' and 'dispatched_calls' queues. */
    9999        ipc_cleanup_call_list(&TASK->kb.box, &TASK->kb.box.calls);
     
    120120                LOG("Was not debugger.");
    121121        }
    122        
     122
    123123        LOG("Continue with hangup message.");
    124124        IPC_SET_RETVAL(call->data, 0);
    125125        ipc_answer(&TASK->kb.box, call);
    126        
     126
    127127        mutex_lock(&TASK->kb.cleanup_lock);
    128        
     128
    129129        irq_spinlock_lock(&TASK->lock, true);
    130130        irq_spinlock_lock(&TASK->kb.box.lock, false);
     
    134134                 * gets freed and signal to the caller.
    135135                 */
    136                
     136
    137137                /* Only detach kbox thread unless already terminating. */
    138138                if (TASK->kb.finished == false) {
     
    141141                        TASK->kb.thread = NULL;
    142142                }
    143                
     143
    144144                LOG("Phone list is empty.");
    145145                *last = true;
    146146        } else
    147147                *last = false;
    148        
     148
    149149        irq_spinlock_unlock(&TASK->kb.box.lock, false);
    150150        irq_spinlock_unlock(&TASK->lock, true);
    151        
     151
    152152        mutex_unlock(&TASK->kb.cleanup_lock);
    153153}
     
    166166        LOG("Starting.");
    167167        bool done = false;
    168        
     168
    169169        while (!done) {
    170170                call_t *call = ipc_wait_for_call(&TASK->kb.box, SYNCH_NO_TIMEOUT,
    171171                    SYNCH_FLAGS_NONE);
    172                
     172
    173173                if (call == NULL)
    174174                        continue;  /* Try again. */
    175                
     175
    176176                switch (IPC_GET_IMETHOD(call->data)) {
    177                
     177
    178178                case IPC_M_DEBUG:
    179179                        /* Handle debug call. */
    180180                        udebug_call_receive(call);
    181181                        break;
    182                
     182
    183183                case IPC_M_PHONE_HUNGUP:
    184184                        /*
     
    189189                        kbox_proc_phone_hungup(call, &done);
    190190                        break;
    191                
     191
    192192                default:
    193193                        /* Ignore */
     
    195195                }
    196196        }
    197        
     197
    198198        LOG("Exiting.");
    199199}
     
    213213{
    214214        irq_spinlock_lock(&tasks_lock, true);
    215        
     215
    216216        task_t *task = task_find_by_id(taskid);
    217217        if (task == NULL) {
     
    219219                return ENOENT;
    220220        }
    221        
     221
    222222        atomic_inc(&task->refcount);
    223        
     223
    224224        irq_spinlock_unlock(&tasks_lock, true);
    225        
     225
    226226        mutex_lock(&task->kb.cleanup_lock);
    227        
     227
    228228        if (atomic_predec(&task->refcount) == 0) {
    229229                mutex_unlock(&task->kb.cleanup_lock);
     
    231231                return ENOENT;
    232232        }
    233        
     233
    234234        if (task->kb.finished) {
    235235                mutex_unlock(&task->kb.cleanup_lock);
    236236                return EINVAL;
    237237        }
    238        
     238
    239239        /* Create a kbox thread if necessary. */
    240240        if (task->kb.thread == NULL) {
    241241                thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
    242242                    THREAD_FLAG_NONE, "kbox");
    243                
     243
    244244                if (!kb_thread) {
    245245                        mutex_unlock(&task->kb.cleanup_lock);
    246246                        return ENOMEM;
    247247                }
    248                
     248
    249249                task->kb.thread = kb_thread;
    250250                thread_ready(kb_thread);
    251251        }
    252        
     252
    253253        /* Allocate a new phone. */
    254254        cap_handle_t phone_handle;
     
    258258                return rc;
    259259        }
    260        
     260
    261261        kobject_t *phone_obj = kobject_get(TASK, phone_handle,
    262262            KOBJECT_TYPE_PHONE);
     
    264264        /* Hand over phone_obj's reference to ipc_phone_connect() */
    265265        (void) ipc_phone_connect(phone_obj->phone, &task->kb.box);
    266        
     266
    267267        mutex_unlock(&task->kb.cleanup_lock);
    268268        *out_phone = phone_handle;
  • kernel/generic/src/ipc/ops/conctmeto.c

    r3061bc1 r8565a42  
    108108                IPC_SET_ARG5(answer->data, phone_handle);
    109109        }
    110        
     110
    111111        return EOK;
    112112}
  • kernel/generic/src/ipc/ops/dataread.c

    r3061bc1 r8565a42  
    7474                         */
    7575                        IPC_SET_ARG1(answer->data, dst);
    76                                
     76
    7777                        answer->buffer = malloc(size, 0);
    7878                        errno_t rc = copy_from_uspace(answer->buffer,
  • kernel/generic/src/ipc/ops/datawrite.c

    r3061bc1 r8565a42  
    6565                return rc;
    6666        }
    67                
     67
    6868        return EOK;
    6969}
     
    7878                size_t size = (size_t)IPC_GET_ARG2(answer->data);
    7979                size_t max_size = (size_t)IPC_GET_ARG2(*olddata);
    80                        
     80
    8181                if (size <= max_size) {
    8282                        errno_t rc = copy_to_uspace((void *) dst,
  • kernel/generic/src/ipc/ops/pagein.c

    r3061bc1 r8565a42  
    9292                page_table_unlock(AS, true);
    9393        }
    94        
     94
    9595        return EOK;
    9696}
  • kernel/generic/src/ipc/ops/sharein.c

    r3061bc1 r8565a42  
    4747                as_t *as = answer->sender->as;
    4848                irq_spinlock_unlock(&answer->sender->lock, true);
    49                        
     49
    5050                uintptr_t dst_base = (uintptr_t) -1;
    5151                errno_t rc = as_area_share(AS, IPC_GET_ARG1(answer->data),
     
    5555                IPC_SET_RETVAL(answer->data, rc);
    5656        }
    57        
     57
    5858        return EOK;
    5959}
  • kernel/generic/src/ipc/ops/shareout.c

    r3061bc1 r8565a42  
    6868                    IPC_GET_ARG2(*olddata), AS, IPC_GET_ARG3(*olddata),
    6969                    &dst_base, IPC_GET_ARG1(answer->data));
    70                        
     70
    7171                if (rc == EOK) {
    7272                        rc = copy_to_uspace((void *) IPC_GET_ARG2(answer->data),
    7373                            &dst_base, sizeof(dst_base));
    7474                }
    75                        
     75
    7676                IPC_SET_RETVAL(answer->data, rc);
    7777        }
  • kernel/generic/src/ipc/sysipc.c

    r3061bc1 r8565a42  
    6969        if (imethod <= IPC_M_LAST_SYSTEM)
    7070                return true;
    71        
     71
    7272        return false;
    7373}
     
    207207                mutex_unlock(&phone->lock);
    208208        }
    209        
     209
    210210        if (!olddata)
    211211                return rc;
     
    242242            (call->flags & IPC_CALL_FORWARDED))
    243243                IPC_SET_RETVAL(call->data, EFORWARD);
    244        
     244
    245245        SYSIPC_OP(answer_process, call);
    246246}
     
    276276        if (!kobj->phone)
    277277                return ENOENT;
    278        
     278
    279279        call_t *call = ipc_call_alloc(0);
    280280        call->priv = priv;
    281281        memcpy(call->data.args, data->args, sizeof(data->args));
    282        
     282
    283283        errno_t rc = request_preprocess(call, kobj->phone);
    284284        if (!rc) {
     
    322322        } else
    323323                IPC_SET_RETVAL(call->data, rc);
    324        
     324
    325325        memcpy(data->args, call->data.args, sizeof(data->args));
    326326        kobject_put(call->kobject);
    327327        kobject_put(kobj);
    328        
     328
    329329        return EOK;
    330330}
     
    342342        if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS)
    343343                return -1;
    344        
     344
    345345        return 0;
    346346}
     
    368368        if (!kobj)
    369369                return ENOENT;
    370        
     370
    371371        if (check_call_limit(kobj->phone)) {
    372372                kobject_put(kobj);
    373373                return ELIMIT;
    374374        }
    375        
     375
    376376        call_t *call = ipc_call_alloc(0);
    377377        IPC_SET_IMETHOD(call->data, imethod);
     
    379379        IPC_SET_ARG2(call->data, arg2);
    380380        IPC_SET_ARG3(call->data, arg3);
    381        
     381
    382382        /*
    383383         * To achieve deterministic behavior, zero out arguments that are beyond
     
    388388        /* Set the user-defined label */
    389389        call->data.label = label;
    390        
     390
    391391        errno_t res = request_preprocess(call, kobj->phone);
    392        
     392
    393393        if (!res)
    394394                ipc_call(kobj->phone, call);
    395395        else
    396396                ipc_backsend_err(kobj->phone, call, res);
    397        
     397
    398398        kobject_put(kobj);
    399399        return EOK;
     
    432432        /* Set the user-defined label */
    433433        call->data.label = label;
    434        
     434
    435435        errno_t res = request_preprocess(call, kobj->phone);
    436        
     436
    437437        if (!res)
    438438                ipc_call(kobj->phone, call);
    439439        else
    440440                ipc_backsend_err(kobj->phone, call, res);
    441        
     441
    442442        kobject_put(kobj);
    443443        return EOK;
     
    473473        if (!ckobj)
    474474                return ENOENT;
    475        
     475
    476476        call_t *call = ckobj->call;
    477477
     
    480480        if (need_old)
    481481                old = call->data;
    482        
     482
    483483        bool after_forward = false;
    484484        errno_t rc;
     
    489489                goto error;
    490490        }
    491        
     491
    492492        if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) {
    493493                rc = EPERM;
    494494                goto error;
    495495        }
    496        
     496
    497497        call->flags |= IPC_CALL_FORWARDED;
    498        
     498
    499499        /*
    500500         * User space is not allowed to change interface and method of system
     
    507507                        if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME)
    508508                                phone_dealloc(IPC_GET_ARG5(call->data));
    509                        
     509
    510510                        IPC_SET_ARG1(call->data, imethod);
    511511                        IPC_SET_ARG2(call->data, arg1);
    512512                        IPC_SET_ARG3(call->data, arg2);
    513                        
     513
    514514                        if (slow)
    515515                                IPC_SET_ARG4(call->data, arg3);
    516                        
     516
    517517                        /*
    518518                         * For system methods we deliberately don't
     
    530530                }
    531531        }
    532        
     532
    533533        rc = ipc_forward(call, pkobj->phone, &TASK->answerbox, mode);
    534534        if (rc != EOK) {
     
    609609        if (rc != EOK)
    610610                return (sys_errno_t) rc;
    611        
     611
    612612        return sys_ipc_forward_common(chandle, phandle,
    613613            IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata),
     
    637637        if (!kobj)
    638638                return ENOENT;
    639        
     639
    640640        call_t *call = kobj->call;
    641641
    642642        ipc_data_t saved_data;
    643643        bool saved;
    644        
     644
    645645        if (answer_need_old(call)) {
    646646                memcpy(&saved_data, &call->data, sizeof(call->data));
     
    648648        } else
    649649                saved = false;
    650        
     650
    651651        IPC_SET_RETVAL(call->data, retval);
    652652        IPC_SET_ARG1(call->data, arg1);
     
    654654        IPC_SET_ARG3(call->data, arg3);
    655655        IPC_SET_ARG4(call->data, arg4);
    656        
     656
    657657        /*
    658658         * To achieve deterministic behavior, zero out arguments that are beyond
     
    661661        IPC_SET_ARG5(call->data, 0);
    662662        errno_t rc = answer_preprocess(call, saved ? &saved_data : NULL);
    663        
     663
    664664        ipc_answer(&TASK->answerbox, call);
    665665
     
    683683        if (!kobj)
    684684                return ENOENT;
    685        
     685
    686686        call_t *call = kobj->call;
    687687
    688688        ipc_data_t saved_data;
    689689        bool saved;
    690        
     690
    691691        if (answer_need_old(call)) {
    692692                memcpy(&saved_data, &call->data, sizeof(call->data));
     
    694694        } else
    695695                saved = false;
    696        
     696
    697697        errno_t rc = copy_from_uspace(&call->data.args, &data->args,
    698698            sizeof(call->data.args));
     
    704704                return rc;
    705705        }
    706        
     706
    707707        rc = answer_preprocess(call, saved ? &saved_data : NULL);
    708        
     708
    709709        ipc_answer(&TASK->answerbox, call);
    710710
     
    727727        if (!kobj)
    728728                return ENOENT;
    729        
     729
    730730        errno_t rc = ipc_phone_hangup(kobj->phone);
    731731        kobject_put(kobj);
     
    746746{
    747747        call_t *call;
    748        
     748
    749749restart:
    750        
     750
    751751#ifdef CONFIG_UDEBUG
    752752        udebug_stoppable_begin();
    753753#endif
    754        
     754
    755755        call = ipc_wait_for_call(&TASK->answerbox, usec,
    756756            flags | SYNCH_FLAGS_INTERRUPTIBLE);
    757        
     757
    758758#ifdef CONFIG_UDEBUG
    759759        udebug_stoppable_end();
     
    766766                return EOK;
    767767        }
    768        
     768
    769769        call->data.flags = call->flags;
    770770        if (call->flags & IPC_CALL_NOTIF) {
    771771                /* Set in_phone_hash to the interrupt counter */
    772772                call->data.phone = (void *) call->priv;
    773                
     773
    774774                call->data.cap_handle = CAP_NIL;
    775775
    776776                STRUCT_TO_USPACE(calldata, &call->data);
    777777                kobject_put(call->kobject);
    778                
     778
    779779                return EOK;
    780780        }
    781        
     781
    782782        if (call->flags & IPC_CALL_ANSWERED) {
    783783                process_answer(call);
    784                
     784
    785785                if (call->flags & IPC_CALL_DISCARD_ANSWER) {
    786786                        kobject_put(call->kobject);
     
    789789
    790790                call->data.cap_handle = CAP_NIL;
    791                
     791
    792792                STRUCT_TO_USPACE(calldata, &call->data);
    793793                kobject_put(call->kobject);
    794                
     794
    795795                return EOK;
    796796        }
    797        
     797
    798798        if (process_request(&TASK->answerbox, call))
    799799                goto restart;
    800        
     800
    801801        cap_handle_t handle;
    802802        errno_t rc = cap_alloc(TASK, &handle);
     
    804804                goto error;
    805805        }
    806        
     806
    807807        call->data.cap_handle = handle;
    808808
     
    871871        if (!(perm_get(TASK) & PERM_IRQ_REG))
    872872                return EPERM;
    873        
     873
    874874        return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode, uspace_handle);
    875875}
     
    887887        if (!(perm_get(TASK) & PERM_IRQ_REG))
    888888                return EPERM;
    889        
     889
    890890        ipc_irq_unsubscribe(&TASK->answerbox, cap);
    891        
     891
    892892        return 0;
    893893}
     
    903903        task_id_t taskid;
    904904        cap_handle_t phone;
    905        
     905
    906906        errno_t rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(task_id_t));
    907907        if (rc == EOK) {
    908908                rc = ipc_connect_kbox((task_id_t) taskid, &phone);
    909909        }
    910        
     910
    911911        if (rc == EOK) {
    912912                rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t));
     
    916916                }
    917917        }
    918        
     918
    919919        return (sys_errno_t) rc;
    920920#else
Note: See TracChangeset for help on using the changeset viewer.