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_hw_res.c

    r76f566d r984a9ba  
    4141#include "ddf/driver.h"
    4242
    43 static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, cap_call_handle_t,
    44     ipc_call_t *);
    45 static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, cap_call_handle_t,
    46     ipc_call_t *);
    47 static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, cap_call_handle_t,
    48     ipc_call_t *);
    49 static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, cap_call_handle_t,
    50     ipc_call_t *);
    51 static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, cap_call_handle_t,
    52     ipc_call_t *);
    53 static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, cap_call_handle_t,
    54     ipc_call_t *);
     43static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, ipc_call_t *);
     44static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_call_t *);
     45static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, ipc_call_t *);
     46static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, ipc_call_t *);
     47static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_call_t *);
     48static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, ipc_call_t *);
    5549
    5650static const remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
     
    6963
    7064static void remote_hw_res_enable_interrupt(ddf_fun_t *fun, void *ops,
    71     cap_call_handle_t chandle, ipc_call_t *call)
     65    ipc_call_t *call)
    7266{
    7367        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    7468
    7569        if (hw_res_ops->enable_interrupt == NULL) {
    76                 async_answer_0(chandle, ENOTSUP);
     70                async_answer_0(call, ENOTSUP);
    7771                return;
    7872        }
     
    8074        const int irq = DEV_IPC_GET_ARG1(*call);
    8175        const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
    82         async_answer_0(chandle, ret);
     76        async_answer_0(call, ret);
    8377}
    8478
    8579static void remote_hw_res_disable_interrupt(ddf_fun_t *fun, void *ops,
    86     cap_call_handle_t chandle, ipc_call_t *call)
     80    ipc_call_t *call)
    8781{
    8882        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    8983
    9084        if (hw_res_ops->disable_interrupt == NULL) {
    91                 async_answer_0(chandle, ENOTSUP);
     85                async_answer_0(call, ENOTSUP);
    9286                return;
    9387        }
     
    9589        const int irq = DEV_IPC_GET_ARG1(*call);
    9690        const errno_t ret = hw_res_ops->disable_interrupt(fun, irq);
    97         async_answer_0(chandle, ret);
     91        async_answer_0(call, ret);
    9892}
    9993
    10094static void remote_hw_res_clear_interrupt(ddf_fun_t *fun, void *ops,
    101     cap_call_handle_t chandle, ipc_call_t *call)
     95    ipc_call_t *call)
    10296{
    10397        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    10498
    10599        if (hw_res_ops->clear_interrupt == NULL) {
    106                 async_answer_0(chandle, ENOTSUP);
     100                async_answer_0(call, ENOTSUP);
    107101                return;
    108102        }
     
    110104        const int irq = DEV_IPC_GET_ARG1(*call);
    111105        const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
    112         async_answer_0(chandle, ret);
     106        async_answer_0(call, ret);
    113107}
    114108
    115109static void remote_hw_res_get_resource_list(ddf_fun_t *fun, void *ops,
    116     cap_call_handle_t chandle, ipc_call_t *call)
     110    ipc_call_t *call)
    117111{
    118112        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    119113
    120114        if (hw_res_ops->get_resource_list == NULL) {
    121                 async_answer_0(chandle, ENOTSUP);
     115                async_answer_0(call, ENOTSUP);
    122116                return;
    123117        }
     
    125119        hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun);
    126120        if (hw_resources == NULL) {
    127                 async_answer_0(chandle, ENOENT);
     121                async_answer_0(call, ENOENT);
    128122                return;
    129123        }
    130124
    131         async_answer_1(chandle, EOK, hw_resources->count);
     125        async_answer_1(call, EOK, hw_resources->count);
    132126
     127        ipc_call_t data;
    133128        size_t len;
    134         if (!async_data_read_receive(&chandle, &len)) {
     129        if (!async_data_read_receive(&data, &len)) {
    135130                /* Protocol error - the recipient is not accepting data */
    136131                return;
    137132        }
    138         async_data_read_finalize(chandle, hw_resources->resources, len);
     133
     134        async_data_read_finalize(&data, hw_resources->resources, len);
    139135}
    140136
    141137static void remote_hw_res_dma_channel_setup(ddf_fun_t *fun, void *ops,
    142     cap_call_handle_t chandle, ipc_call_t *call)
     138    ipc_call_t *call)
    143139{
    144140        hw_res_ops_t *hw_res_ops = ops;
    145141
    146142        if (hw_res_ops->dma_channel_setup == NULL) {
    147                 async_answer_0(chandle, ENOTSUP);
     143                async_answer_0(call, ENOTSUP);
    148144                return;
    149145        }
     146
    150147        const unsigned channel = DEV_IPC_GET_ARG1(*call) & 0xffff;
    151148        const uint8_t  mode = DEV_IPC_GET_ARG1(*call) >> 16;
     
    155152        const errno_t ret = hw_res_ops->dma_channel_setup(
    156153            fun, channel, address, size, mode);
    157         async_answer_0(chandle, ret);
     154        async_answer_0(call, ret);
    158155}
    159156
    160157static void remote_hw_res_dma_channel_remain(ddf_fun_t *fun, void *ops,
    161     cap_call_handle_t chandle, ipc_call_t *call)
     158    ipc_call_t *call)
    162159{
    163160        hw_res_ops_t *hw_res_ops = ops;
    164161
    165162        if (hw_res_ops->dma_channel_setup == NULL) {
    166                 async_answer_0(chandle, ENOTSUP);
     163                async_answer_0(call, ENOTSUP);
    167164                return;
    168165        }
     166
    169167        const unsigned channel = DEV_IPC_GET_ARG1(*call);
    170168        size_t remain = 0;
    171169        const errno_t ret = hw_res_ops->dma_channel_remain(fun, channel, &remain);
    172         async_answer_1(chandle, ret, remain);
     170        async_answer_1(call, ret, remain);
    173171}
     172
    174173/**
    175174 * @}
Note: See TracChangeset for help on using the changeset viewer.