Ignore:
File:
1 edited

Legend:

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

    ra35b458 r5a6cc679  
    9191        snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE,
    9292            namespace_idx, VISUALIZER_NAME, visualizer_idx++);
    93 
     93       
    9494        category_id_t cat;
    9595        errno_t rc = loc_category_get_id("visualizer", &cat, 0);
    9696        if (rc != EOK)
    9797                return rc;
    98 
     98       
    9999        rc = loc_service_register(node, &vs->reg_svc_handle);
    100100        if (rc != EOK)
    101101                return rc;
    102 
     102       
    103103        rc = loc_service_add_to_cat(vs->reg_svc_handle, cat);
    104104        if (rc != EOK) {
     
    106106                return rc;
    107107        }
    108 
     108       
    109109        fibril_mutex_lock(&visualizer_list_mtx);
    110110        list_append(&vs->link, &visualizer_list);
    111111        fibril_mutex_unlock(&visualizer_list_mtx);
    112 
     112       
    113113        return rc;
    114114}
     
    119119        snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE,
    120120            namespace_idx, RENDERER_NAME, renderer_idx++);
    121 
     121       
    122122        category_id_t cat;
    123123        errno_t rc = loc_category_get_id("renderer", &cat, 0);
    124124        if (rc != EOK)
    125125                return rc;
    126 
     126       
    127127        rc = loc_service_register(node, &rnd->reg_svc_handle);
    128128        if (rc != EOK)
    129129                return rc;
    130 
     130       
    131131        rc = loc_service_add_to_cat(rnd->reg_svc_handle, cat);
    132132        if (rc != EOK) {
     
    134134                return rc;
    135135        }
    136 
     136       
    137137        fibril_mutex_lock(&renderer_list_mtx);
    138138        list_append(&rnd->link, &renderer_list);
    139139        fibril_mutex_unlock(&renderer_list_mtx);
    140 
     140       
    141141        return rc;
    142142}
     
    145145{
    146146        visualizer_t *vs = NULL;
    147 
     147       
    148148        fibril_mutex_lock(&visualizer_list_mtx);
    149 
     149       
    150150        list_foreach(visualizer_list, link, visualizer_t, vcur) {
    151151                if (vcur->reg_svc_handle == handle) {
     
    154154                }
    155155        }
    156 
     156       
    157157        fibril_mutex_unlock(&visualizer_list_mtx);
    158 
     158       
    159159        return vs;
    160160}
     
    163163{
    164164        renderer_t *rnd = NULL;
    165 
     165       
    166166        fibril_mutex_lock(&renderer_list_mtx);
    167 
     167       
    168168        list_foreach(renderer_list, link, renderer_t, rcur) {
    169169                if (rcur->reg_svc_handle == handle) {
     
    172172                }
    173173        }
    174 
     174       
    175175        fibril_mutex_unlock(&renderer_list_mtx);
    176 
     176       
    177177        return rnd;
    178178}
     
    184184        list_remove(&vs->link);
    185185        fibril_mutex_unlock(&visualizer_list_mtx);
    186 
     186       
    187187        return rc;
    188188}
     
    194194        list_remove(&rnd->link);
    195195        fibril_mutex_unlock(&renderer_list_mtx);
    196 
     196       
    197197        return rc;
    198198}
     
    207207        assert(vs->cells.data == NULL);
    208208        assert(vs->dev_ctx == NULL);
    209 
     209       
    210210        free(vs);
    211211}
     
    215215        // TODO
    216216        assert(atomic_get(&rnd->ref_cnt) == 0);
    217 
     217       
    218218        free(rnd);
    219219}
     
    224224        errno_t ret = async_req_2_0(exch, VISUALIZER_MODE_CHANGE, handle, mode_idx);
    225225        async_exchange_end(exch);
    226 
     226       
    227227        return ret;
    228228}
     
    233233        errno_t ret = async_req_1_0(exch, VISUALIZER_DISCONNECT, handle);
    234234        async_exchange_end(exch);
    235 
     235       
    236236        async_hangup(sess);
    237 
     237       
    238238        return ret;
    239239}
     
    255255                }
    256256        }
    257 
     257       
    258258        /* Driver might also deallocate resources for the current mode. */
    259259        errno_t rc = vs->ops.yield(vs);
    260 
     260       
    261261        /* Now that the driver was given a chance to deallocate resources,
    262262         * current mode can be unset. */
    263263        if (vs->mode_set)
    264264                vs->mode_set = false;
    265 
     265       
    266266        async_answer_0(iid, rc);
    267267}
     
    271271        ipc_callid_t callid;
    272272        size_t len;
    273 
     273       
    274274        if (!async_data_read_receive(&callid, &len)) {
    275275                async_answer_0(callid, EREFUSED);
     
    277277                return;
    278278        }
    279 
     279       
    280280        fibril_mutex_lock(&vs->mode_mtx);
    281281        link_t *link = list_nth(&vs->modes, IPC_GET_ARG1(*icall));
    282 
     282       
    283283        if (link != NULL) {
    284284                vslmode_list_element_t *mode_elem =
    285285                    list_get_instance(link, vslmode_list_element_t, link);
    286 
     286               
    287287                errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    288288                async_answer_0(iid, rc);
     
    291291                async_answer_0(iid, ENOENT);
    292292        }
    293 
     293       
    294294        fibril_mutex_unlock(&vs->mode_mtx);
    295295}
     
    299299        ipc_callid_t callid;
    300300        size_t len;
    301 
     301       
    302302        if (!async_data_read_receive(&callid, &len)) {
    303303                async_answer_0(callid, EREFUSED);
     
    305305                return;
    306306        }
    307 
     307       
    308308        fibril_mutex_lock(&vs->mode_mtx);
    309309        vslmode_list_element_t *mode_elem = NULL;
    310 
     310       
    311311        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    312312                if (cur->mode.index == vs->def_mode_idx) {
     
    315315                }
    316316        }
    317 
     317       
    318318        if (mode_elem != NULL) {
    319319                errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
     
    324324                async_answer_0(iid, ENOENT);
    325325        }
    326 
     326       
    327327        fibril_mutex_unlock(&vs->mode_mtx);
    328328}
     
    332332        ipc_callid_t callid;
    333333        size_t len;
    334 
     334       
    335335        if (!async_data_read_receive(&callid, &len)) {
    336336                async_answer_0(callid, EREFUSED);
     
    338338                return;
    339339        }
    340 
     340       
    341341        if (vs->mode_set) {
    342342                errno_t rc = async_data_read_finalize(callid, &vs->cur_mode, len);
     
    352352        ipc_callid_t callid;
    353353        size_t len;
    354 
     354       
    355355        if (!async_data_read_receive(&callid, &len)) {
    356356                async_answer_0(callid, EREFUSED);
     
    358358                return;
    359359        }
    360 
     360       
    361361        sysarg_t mode_idx = IPC_GET_ARG1(*icall);
    362 
     362       
    363363        fibril_mutex_lock(&vs->mode_mtx);
    364364        vslmode_list_element_t *mode_elem = NULL;
    365 
     365       
    366366        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    367367                if (cur->mode.index == mode_idx) {
     
    370370                }
    371371        }
    372 
     372       
    373373        if (mode_elem != NULL) {
    374374                errno_t rc = async_data_read_finalize(callid, &mode_elem->mode, len);
     
    378378                async_answer_0(iid, ENOENT);
    379379        }
    380 
     380       
    381381        fibril_mutex_unlock(&vs->mode_mtx);
    382382}
     
    387387        size_t size;
    388388        unsigned int flags;
    389 
     389       
    390390        /* Retrieve the shared cell storage for the new mode. */
    391391        if (!async_share_out_receive(&callid, &size, &flags)) {
     
    394394                return;
    395395        }
    396 
     396       
    397397        /* Retrieve mode index and version. */
    398398        sysarg_t mode_idx = IPC_GET_ARG1(*icall);
    399399        sysarg_t mode_version = IPC_GET_ARG2(*icall);
    400 
     400       
    401401        /* Find mode in the list. */
    402402        fibril_mutex_lock(&vs->mode_mtx);
    403403        vslmode_list_element_t *mode_elem = NULL;
    404 
     404       
    405405        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    406406                if (cur->mode.index == mode_idx) {
     
    409409                }
    410410        }
    411 
     411       
    412412        if (mode_elem == NULL) {
    413413                fibril_mutex_unlock(&vs->mode_mtx);
     
    416416                return;
    417417        }
    418 
     418       
    419419        /* Extract mode description from the list node. */
    420420        vslmode_t new_mode = mode_elem->mode;
    421421        fibril_mutex_unlock(&vs->mode_mtx);
    422 
     422       
    423423        /* Check whether the mode is still up-to-date. */
    424424        if (new_mode.version != mode_version) {
     
    427427                return;
    428428        }
    429 
     429       
    430430        void *new_cell_storage;
    431431        errno_t rc = async_share_out_finalize(callid, &new_cell_storage);
     
    434434                return;
    435435        }
    436 
     436       
    437437        /* Change device internal state. */
    438438        rc = vs->ops.change_mode(vs, new_mode);
    439 
     439       
    440440        /* Device driver could not establish new mode. Rollback. */
    441441        if (rc != EOK) {
     
    444444                return;
    445445        }
    446 
     446       
    447447        /*
    448448         * Because resources for the new mode were successfully
     
    456456                }
    457457        }
    458 
     458       
    459459        /* Insert new mode into the visualizer. */
    460460        vs->cells.width = new_mode.screen_width;
     
    463463        vs->cur_mode = new_mode;
    464464        vs->mode_set = true;
    465 
     465       
    466466        async_answer_0(iid, EOK);
    467467}
     
    471471        sysarg_t x_offset = (IPC_GET_ARG5(*icall) >> 16);
    472472        sysarg_t y_offset = (IPC_GET_ARG5(*icall) & 0x0000ffff);
    473 
     473       
    474474        errno_t rc = vs->ops.handle_damage(vs,
    475475            IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall),
     
    496496        ipc_call_t call;
    497497        ipc_callid_t callid;
    498 
     498       
    499499        /* Claim the visualizer. */
    500500        if (!cas(&vs->ref_cnt, 0, 1)) {
     
    502502                return;
    503503        }
    504 
     504       
    505505        /* Accept the connection. */
    506506        async_answer_0(iid, EOK);
    507 
     507       
    508508        /* Establish callback session. */
    509509        callid = async_get_call(&call);
     
    513513        else
    514514                async_answer_0(callid, ELIMIT);
    515 
     515       
    516516        /* Enter command loop. */
    517517        while (true) {
    518518                callid = async_get_call(&call);
    519 
     519               
    520520                if (!IPC_GET_IMETHOD(call)) {
    521521                        async_answer_0(callid, EINVAL);
    522522                        break;
    523523                }
    524 
     524               
    525525                switch (IPC_GET_IMETHOD(call)) {
    526526                case VISUALIZER_CLAIM:
     
    559559                }
    560560        }
    561 
     561       
    562562terminate:
    563563        async_hangup(vs->notif_sess);
     
    570570{
    571571        // TODO
    572 
     572       
    573573        ipc_call_t call;
    574574        ipc_callid_t callid;
    575 
     575       
    576576        /* Accept the connection. */
    577577        atomic_inc(&rnd->ref_cnt);
    578578        async_answer_0(iid, EOK);
    579 
     579       
    580580        /* Enter command loop. */
    581581        while (true) {
    582582                callid = async_get_call(&call);
    583 
     583               
    584584                if (!IPC_GET_IMETHOD(call)) {
    585585                        async_answer_0(callid, EINVAL);
    586586                        break;
    587587                }
    588 
     588               
    589589                switch (IPC_GET_IMETHOD(call)) {
    590590                default:
     
    593593                }
    594594        }
    595 
     595       
    596596terminate:
    597597        atomic_dec(&rnd->ref_cnt);
     
    603603        visualizer_t *vs = graph_get_visualizer(IPC_GET_ARG2(*icall));
    604604        renderer_t *rnd = graph_get_renderer(IPC_GET_ARG2(*icall));
    605 
     605       
    606606        if (vs != NULL)
    607607                graph_visualizer_connection(vs, iid, icall, arg);
Note: See TracChangeset for help on using the changeset viewer.