Changeset 984a9ba in mainline for uspace/lib/drv/generic/remote_ahci.c


Ignore:
Timestamp:
2018-07-05T09:34:09Z (6 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63d46341
Parents:
76f566d
Message:

do not expose the call capability handler from the async framework

Keep the call capability handler encapsulated within the async framework
and do not expose it explicitly via its API. Use the pointer to
ipc_call_t as the sole object identifying an IPC call in the code that
uses the async framework.

This plugs a major leak in the abstraction and also simplifies both the
async framework (slightly) and all IPC servers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_ahci.c

    r76f566d r984a9ba  
    182182}
    183183
    184 static void remote_ahci_get_sata_device_name(ddf_fun_t *, void *, cap_call_handle_t,
    185     ipc_call_t *);
    186 static void remote_ahci_get_num_blocks(ddf_fun_t *, void *, cap_call_handle_t,
    187     ipc_call_t *);
    188 static void remote_ahci_get_block_size(ddf_fun_t *, void *, cap_call_handle_t,
    189     ipc_call_t *);
    190 static void remote_ahci_read_blocks(ddf_fun_t *, void *, cap_call_handle_t,
    191     ipc_call_t *);
    192 static void remote_ahci_write_blocks(ddf_fun_t *, void *, cap_call_handle_t,
    193     ipc_call_t *);
     184static void remote_ahci_get_sata_device_name(ddf_fun_t *, void *, ipc_call_t *);
     185static void remote_ahci_get_num_blocks(ddf_fun_t *, void *, ipc_call_t *);
     186static void remote_ahci_get_block_size(ddf_fun_t *, void *, ipc_call_t *);
     187static void remote_ahci_read_blocks(ddf_fun_t *, void *, ipc_call_t *);
     188static void remote_ahci_write_blocks(ddf_fun_t *, void *, ipc_call_t *);
    194189
    195190/** Remote AHCI interface operations. */
     
    210205
    211206void remote_ahci_get_sata_device_name(ddf_fun_t *fun, void *iface,
    212     cap_call_handle_t chandle, ipc_call_t *call)
     207    ipc_call_t *call)
    213208{
    214209        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    215210
    216211        if (ahci_iface->get_sata_device_name == NULL) {
    217                 async_answer_0(chandle, ENOTSUP);
     212                async_answer_0(call, ENOTSUP);
    218213                return;
    219214        }
     
    224219        char *sata_dev_name = malloc(sata_dev_name_length);
    225220        if (sata_dev_name == NULL) {
    226                 async_answer_0(chandle, ENOMEM);
     221                async_answer_0(call, ENOMEM);
    227222                return;
    228223        }
     
    231226            sata_dev_name_length, sata_dev_name);
    232227
     228        ipc_call_t data;
    233229        size_t real_size;
    234         cap_call_handle_t call_handle;
    235         if ((async_data_read_receive(&call_handle, &real_size)) &&
     230        if ((async_data_read_receive(&data, &real_size)) &&
    236231            (real_size == sata_dev_name_length))
    237                 async_data_read_finalize(call_handle, sata_dev_name,
     232                async_data_read_finalize(&data, sata_dev_name,
    238233                    sata_dev_name_length);
    239234
    240235        free(sata_dev_name);
    241         async_answer_0(chandle, ret);
     236        async_answer_0(call, ret);
    242237}
    243238
    244239static void remote_ahci_get_num_blocks(ddf_fun_t *fun, void *iface,
    245     cap_call_handle_t chandle, ipc_call_t *call)
     240    ipc_call_t *call)
    246241{
    247242        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    248243
    249244        if (ahci_iface->get_num_blocks == NULL) {
    250                 async_answer_0(chandle, ENOTSUP);
     245                async_answer_0(call, ENOTSUP);
    251246                return;
    252247        }
     
    256251
    257252        if (ret != EOK)
    258                 async_answer_0(chandle, ret);
     253                async_answer_0(call, ret);
    259254        else
    260                 async_answer_2(chandle, EOK, HI(blocks), LO(blocks));
     255                async_answer_2(call, EOK, HI(blocks), LO(blocks));
    261256}
    262257
    263258static void remote_ahci_get_block_size(ddf_fun_t *fun, void *iface,
    264     cap_call_handle_t chandle, ipc_call_t *call)
     259    ipc_call_t *call)
    265260{
    266261        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    267262
    268263        if (ahci_iface->get_block_size == NULL) {
    269                 async_answer_0(chandle, ENOTSUP);
     264                async_answer_0(call, ENOTSUP);
    270265                return;
    271266        }
     
    275270
    276271        if (ret != EOK)
    277                 async_answer_0(chandle, ret);
     272                async_answer_0(call, ret);
    278273        else
    279                 async_answer_1(chandle, EOK, blocks);
    280 }
    281 
    282 void remote_ahci_read_blocks(ddf_fun_t *fun, void *iface,
    283     cap_call_handle_t chandle, ipc_call_t *call)
     274                async_answer_1(call, EOK, blocks);
     275}
     276
     277void remote_ahci_read_blocks(ddf_fun_t *fun, void *iface, ipc_call_t *call)
    284278{
    285279        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    286280
    287281        if (ahci_iface->read_blocks == NULL) {
    288                 async_answer_0(chandle, ENOTSUP);
    289                 return;
    290         }
    291 
     282                async_answer_0(call, ENOTSUP);
     283                return;
     284        }
     285
     286        ipc_call_t data;
    292287        size_t maxblock_size;
    293288        unsigned int flags;
    294 
    295         cap_call_handle_t call_handle;
    296         async_share_out_receive(&call_handle, &maxblock_size, &flags);
     289        async_share_out_receive(&data, &maxblock_size, &flags);
    297290
    298291        void *buf;
    299         async_share_out_finalize(call_handle, &buf);
     292        async_share_out_finalize(&data, &buf);
    300293
    301294        const uint64_t blocknum =
     
    306299        const errno_t ret = ahci_iface->read_blocks(fun, blocknum, cnt, buf);
    307300
    308         async_answer_0(chandle, ret);
    309 }
    310 
    311 void remote_ahci_write_blocks(ddf_fun_t *fun, void *iface, cap_call_handle_t chandle,
    312     ipc_call_t *call)
     301        async_answer_0(call, ret);
     302}
     303
     304void remote_ahci_write_blocks(ddf_fun_t *fun, void *iface, ipc_call_t *call)
    313305{
    314306        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    315307
    316308        if (ahci_iface->read_blocks == NULL) {
    317                 async_answer_0(chandle, ENOTSUP);
    318                 return;
    319         }
    320 
     309                async_answer_0(call, ENOTSUP);
     310                return;
     311        }
     312
     313        ipc_call_t data;
    321314        size_t maxblock_size;
    322315        unsigned int flags;
    323 
    324         cap_call_handle_t call_handle;
    325         async_share_out_receive(&call_handle, &maxblock_size, &flags);
     316        async_share_out_receive(&data, &maxblock_size, &flags);
    326317
    327318        void *buf;
    328         async_share_out_finalize(call_handle, &buf);
     319        async_share_out_finalize(&data, &buf);
    329320
    330321        const uint64_t blocknum =
     
    335326        const errno_t ret = ahci_iface->write_blocks(fun, blocknum, cnt, buf);
    336327
    337         async_answer_0(chandle, ret);
     328        async_answer_0(call, ret);
    338329}
    339330
Note: See TracChangeset for help on using the changeset viewer.