Changeset a46e56b in mainline for uspace/lib/graph/graph.c


Ignore:
Timestamp:
2018-03-22T06:49:35Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
77f0a1d
Parents:
3e242d2
git-author:
Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
git-committer:
Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
Message:

Prefer handle over ID in naming handle variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/graph/graph.c

    r3e242d2 ra46e56b  
    239239}
    240240
    241 static void vs_claim(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
     241static void vs_claim(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
    242242{
    243243        vs->client_side_handle = IPC_GET_ARG1(*icall);
    244244        errno_t rc = vs->ops.claim(vs);
    245         async_answer_0(iid, rc);
    246 }
    247 
    248 static void vs_yield(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
     245        async_answer_0(icall_handle, rc);
     246}
     247
     248static void vs_yield(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
    249249{
    250250        /* Deallocate resources for the current mode. */
     
    264264                vs->mode_set = false;
    265265
    266         async_answer_0(iid, rc);
    267 }
    268 
    269 static void vs_enumerate_modes(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
    270 {
    271         cap_call_handle_t callid;
     266        async_answer_0(icall_handle, rc);
     267}
     268
     269static void vs_enumerate_modes(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
     270{
     271        cap_call_handle_t chandle;
    272272        size_t len;
    273273
    274         if (!async_data_read_receive(&callid, &len)) {
    275                 async_answer_0(callid, EREFUSED);
    276                 async_answer_0(iid, EREFUSED);
     274        if (!async_data_read_receive(&chandle, &len)) {
     275                async_answer_0(chandle, EREFUSED);
     276                async_answer_0(icall_handle, EREFUSED);
    277277                return;
    278278        }
     
    285285                    list_get_instance(link, vslmode_list_element_t, link);
    286286
    287                 errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    288                 async_answer_0(iid, rc);
     287                errno_t rc = async_data_read_finalize(chandle, &mode_elem->mode, len);
     288                async_answer_0(icall_handle, rc);
    289289        } else {
    290                 async_answer_0(callid, ENOENT);
    291                 async_answer_0(iid, ENOENT);
     290                async_answer_0(chandle, ENOENT);
     291                async_answer_0(icall_handle, ENOENT);
    292292        }
    293293
     
    295295}
    296296
    297 static void vs_get_default_mode(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
    298 {
    299         cap_call_handle_t callid;
     297static void vs_get_default_mode(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
     298{
     299        cap_call_handle_t chandle;
    300300        size_t len;
    301301
    302         if (!async_data_read_receive(&callid, &len)) {
    303                 async_answer_0(callid, EREFUSED);
    304                 async_answer_0(iid, EREFUSED);
     302        if (!async_data_read_receive(&chandle, &len)) {
     303                async_answer_0(chandle, EREFUSED);
     304                async_answer_0(icall_handle, EREFUSED);
    305305                return;
    306306        }
     
    317317
    318318        if (mode_elem != NULL) {
    319                 errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    320                 async_answer_0(iid, rc);
     319                errno_t rc = async_data_read_finalize(chandle, &mode_elem->mode, len);
     320                async_answer_0(icall_handle, rc);
    321321        } else {
    322322                fibril_mutex_unlock(&vs->mode_mtx);
    323                 async_answer_0(callid, ENOENT);
    324                 async_answer_0(iid, ENOENT);
     323                async_answer_0(chandle, ENOENT);
     324                async_answer_0(icall_handle, ENOENT);
    325325        }
    326326
     
    328328}
    329329
    330 static void vs_get_current_mode(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
    331 {
    332         cap_call_handle_t callid;
     330static void vs_get_current_mode(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
     331{
     332        cap_call_handle_t chandle;
    333333        size_t len;
    334334
    335         if (!async_data_read_receive(&callid, &len)) {
    336                 async_answer_0(callid, EREFUSED);
    337                 async_answer_0(iid, EREFUSED);
     335        if (!async_data_read_receive(&chandle, &len)) {
     336                async_answer_0(chandle, EREFUSED);
     337                async_answer_0(icall_handle, EREFUSED);
    338338                return;
    339339        }
    340340
    341341        if (vs->mode_set) {
    342                 errno_t rc = async_data_read_finalize(callid, &vs->cur_mode, len);
    343                 async_answer_0(iid, rc);
     342                errno_t rc = async_data_read_finalize(chandle, &vs->cur_mode, len);
     343                async_answer_0(icall_handle, rc);
    344344        } else {
    345                 async_answer_0(callid, ENOENT);
    346                 async_answer_0(iid, ENOENT);
    347         }
    348 }
    349 
    350 static void vs_get_mode(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
    351 {
    352         cap_call_handle_t callid;
     345                async_answer_0(chandle, ENOENT);
     346                async_answer_0(icall_handle, ENOENT);
     347        }
     348}
     349
     350static void vs_get_mode(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
     351{
     352        cap_call_handle_t chandle;
    353353        size_t len;
    354354
    355         if (!async_data_read_receive(&callid, &len)) {
    356                 async_answer_0(callid, EREFUSED);
    357                 async_answer_0(iid, EREFUSED);
     355        if (!async_data_read_receive(&chandle, &len)) {
     356                async_answer_0(chandle, EREFUSED);
     357                async_answer_0(icall_handle, EREFUSED);
    358358                return;
    359359        }
     
    372372
    373373        if (mode_elem != NULL) {
    374                 errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    375                 async_answer_0(iid, rc);
     374                errno_t rc = async_data_read_finalize(chandle, &mode_elem->mode, len);
     375                async_answer_0(icall_handle, rc);
    376376        } else {
    377                 async_answer_0(callid, ENOENT);
    378                 async_answer_0(iid, ENOENT);
     377                async_answer_0(chandle, ENOENT);
     378                async_answer_0(icall_handle, ENOENT);
    379379        }
    380380
     
    382382}
    383383
    384 static void vs_set_mode(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
    385 {
    386         cap_call_handle_t callid;
     384static void vs_set_mode(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
     385{
     386        cap_call_handle_t chandle;
    387387        size_t size;
    388388        unsigned int flags;
    389389
    390390        /* Retrieve the shared cell storage for the new mode. */
    391         if (!async_share_out_receive(&callid, &size, &flags)) {
    392                 async_answer_0(callid, EREFUSED);
    393                 async_answer_0(iid, EREFUSED);
     391        if (!async_share_out_receive(&chandle, &size, &flags)) {
     392                async_answer_0(chandle, EREFUSED);
     393                async_answer_0(icall_handle, EREFUSED);
    394394                return;
    395395        }
     
    412412        if (mode_elem == NULL) {
    413413                fibril_mutex_unlock(&vs->mode_mtx);
    414                 async_answer_0(callid, ENOENT);
    415                 async_answer_0(iid, ENOENT);
     414                async_answer_0(chandle, ENOENT);
     415                async_answer_0(icall_handle, ENOENT);
    416416                return;
    417417        }
     
    423423        /* Check whether the mode is still up-to-date. */
    424424        if (new_mode.version != mode_version) {
    425                 async_answer_0(callid, EINVAL);
    426                 async_answer_0(iid, EINVAL);
     425                async_answer_0(chandle, EINVAL);
     426                async_answer_0(icall_handle, EINVAL);
    427427                return;
    428428        }
    429429
    430430        void *new_cell_storage;
    431         errno_t rc = async_share_out_finalize(callid, &new_cell_storage);
     431        errno_t rc = async_share_out_finalize(chandle, &new_cell_storage);
    432432        if ((rc != EOK) || (new_cell_storage == AS_MAP_FAILED)) {
    433                 async_answer_0(iid, ENOMEM);
     433                async_answer_0(icall_handle, ENOMEM);
    434434                return;
    435435        }
     
    441441        if (rc != EOK) {
    442442                as_area_destroy(new_cell_storage);
    443                 async_answer_0(iid, ENOMEM);
     443                async_answer_0(icall_handle, ENOMEM);
    444444                return;
    445445        }
     
    464464        vs->mode_set = true;
    465465
    466         async_answer_0(iid, EOK);
    467 }
    468 
    469 static void vs_update_damaged_region(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
     466        async_answer_0(icall_handle, EOK);
     467}
     468
     469static void vs_update_damaged_region(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
    470470{
    471471        sysarg_t x_offset = (IPC_GET_ARG5(*icall) >> 16);
     
    476476            IPC_GET_ARG3(*icall), IPC_GET_ARG4(*icall),
    477477            x_offset, y_offset);
    478         async_answer_0(iid, rc);
    479 }
    480 
    481 static void vs_suspend(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
     478        async_answer_0(icall_handle, rc);
     479}
     480
     481static void vs_suspend(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
    482482{
    483483        errno_t rc = vs->ops.suspend(vs);
    484         async_answer_0(iid, rc);
    485 }
    486 
    487 static void vs_wakeup(visualizer_t *vs, cap_call_handle_t iid, ipc_call_t *icall)
     484        async_answer_0(icall_handle, rc);
     485}
     486
     487static void vs_wakeup(visualizer_t *vs, cap_call_handle_t icall_handle, ipc_call_t *icall)
    488488{
    489489        errno_t rc = vs->ops.wakeup(vs);
    490         async_answer_0(iid, rc);
     490        async_answer_0(icall_handle, rc);
    491491}
    492492
    493493void graph_visualizer_connection(visualizer_t *vs,
    494     cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     494    cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    495495{
    496496        ipc_call_t call;
    497         cap_call_handle_t callid;
     497        cap_call_handle_t chandle;
    498498
    499499        /* Claim the visualizer. */
    500500        if (!cas(&vs->ref_cnt, 0, 1)) {
    501                 async_answer_0(iid, ELIMIT);
     501                async_answer_0(icall_handle, ELIMIT);
    502502                return;
    503503        }
    504504
    505505        /* Accept the connection. */
    506         async_answer_0(iid, EOK);
     506        async_answer_0(icall_handle, EOK);
    507507
    508508        /* Establish callback session. */
    509         callid = async_get_call(&call);
     509        chandle = async_get_call(&call);
    510510        vs->notif_sess = async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
    511511        if (vs->notif_sess != NULL)
    512                 async_answer_0(callid, EOK);
     512                async_answer_0(chandle, EOK);
    513513        else
    514                 async_answer_0(callid, ELIMIT);
     514                async_answer_0(chandle, ELIMIT);
    515515
    516516        /* Enter command loop. */
    517517        while (true) {
    518                 callid = async_get_call(&call);
     518                chandle = async_get_call(&call);
    519519
    520520                if (!IPC_GET_IMETHOD(call)) {
    521                         async_answer_0(callid, EINVAL);
     521                        async_answer_0(chandle, EINVAL);
    522522                        break;
    523523                }
     
    525525                switch (IPC_GET_IMETHOD(call)) {
    526526                case VISUALIZER_CLAIM:
    527                         vs_claim(vs, callid, &call);
     527                        vs_claim(vs, chandle, &call);
    528528                        break;
    529529                case VISUALIZER_YIELD:
    530                         vs_yield(vs, callid, &call);
     530                        vs_yield(vs, chandle, &call);
    531531                        goto terminate;
    532532                case VISUALIZER_ENUMERATE_MODES:
    533                         vs_enumerate_modes(vs, callid, &call);
     533                        vs_enumerate_modes(vs, chandle, &call);
    534534                        break;
    535535                case VISUALIZER_GET_DEFAULT_MODE:
    536                         vs_get_default_mode(vs, callid, &call);
     536                        vs_get_default_mode(vs, chandle, &call);
    537537                        break;
    538538                case VISUALIZER_GET_CURRENT_MODE:
    539                         vs_get_current_mode(vs, callid, &call);
     539                        vs_get_current_mode(vs, chandle, &call);
    540540                        break;
    541541                case VISUALIZER_GET_MODE:
    542                         vs_get_mode(vs, callid, &call);
     542                        vs_get_mode(vs, chandle, &call);
    543543                        break;
    544544                case VISUALIZER_SET_MODE:
    545                         vs_set_mode(vs, callid, &call);
     545                        vs_set_mode(vs, chandle, &call);
    546546                        break;
    547547                case VISUALIZER_UPDATE_DAMAGED_REGION:
    548                         vs_update_damaged_region(vs, callid, &call);
     548                        vs_update_damaged_region(vs, chandle, &call);
    549549                        break;
    550550                case VISUALIZER_SUSPEND:
    551                         vs_suspend(vs, callid, &call);
     551                        vs_suspend(vs, chandle, &call);
    552552                        break;
    553553                case VISUALIZER_WAKE_UP:
    554                         vs_wakeup(vs, callid, &call);
     554                        vs_wakeup(vs, chandle, &call);
    555555                        break;
    556556                default:
    557                         async_answer_0(callid, EINVAL);
     557                        async_answer_0(chandle, EINVAL);
    558558                        goto terminate;
    559559                }
     
    567567
    568568void graph_renderer_connection(renderer_t *rnd,
    569     cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     569    cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    570570{
    571571        // TODO
    572572
    573573        ipc_call_t call;
    574         cap_call_handle_t callid;
     574        cap_call_handle_t chandle;
    575575
    576576        /* Accept the connection. */
    577577        atomic_inc(&rnd->ref_cnt);
    578         async_answer_0(iid, EOK);
     578        async_answer_0(icall_handle, EOK);
    579579
    580580        /* Enter command loop. */
    581581        while (true) {
    582                 callid = async_get_call(&call);
     582                chandle = async_get_call(&call);
    583583
    584584                if (!IPC_GET_IMETHOD(call)) {
    585                         async_answer_0(callid, EINVAL);
     585                        async_answer_0(chandle, EINVAL);
    586586                        break;
    587587                }
     
    589589                switch (IPC_GET_IMETHOD(call)) {
    590590                default:
    591                         async_answer_0(callid, EINVAL);
     591                        async_answer_0(chandle, EINVAL);
    592592                        goto terminate;
    593593                }
     
    598598}
    599599
    600 void graph_client_connection(cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     600void graph_client_connection(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    601601{
    602602        /* Find the visualizer or renderer with the given service ID. */
     
    605605
    606606        if (vs != NULL)
    607                 graph_visualizer_connection(vs, iid, icall, arg);
     607                graph_visualizer_connection(vs, icall_handle, icall, arg);
    608608        else if (rnd != NULL)
    609                 graph_renderer_connection(rnd, iid, icall, arg);
     609                graph_renderer_connection(rnd, icall_handle, icall, arg);
    610610        else
    611                 async_answer_0(iid, ENOENT);
     611                async_answer_0(icall_handle, ENOENT);
    612612}
    613613
Note: See TracChangeset for help on using the changeset viewer.