Changeset d51838f in mainline for uspace/lib


Ignore:
Timestamp:
2017-10-14T22:49:18Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75911d24
Parents:
ce732e74
Message:

Let leaf drivers enable/disable/clear interrupts via hw_res instead of directly using irc.

Location:
uspace/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/hw_res.c

    rce732e74 rd51838f  
    8686}
    8787
     88int hw_res_disable_interrupt(async_sess_t *sess, int irq)
     89{
     90        async_exch_t *exch = async_exchange_begin(sess);
     91       
     92        int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     93            HW_RES_DISABLE_INTERRUPT, irq);
     94        async_exchange_end(exch);
     95       
     96        return rc;
     97}
     98
     99int hw_res_clear_interrupt(async_sess_t *sess, int irq)
     100{
     101        async_exch_t *exch = async_exchange_begin(sess);
     102       
     103        int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     104            HW_RES_CLEAR_INTERRUPT, irq);
     105        async_exchange_end(exch);
     106       
     107        return rc;
     108}
     109
    88110/** Setup DMA channel to specified place and mode.
    89111 *
  • uspace/lib/c/include/device/hw_res.h

    rce732e74 rd51838f  
    5252        HW_RES_GET_RESOURCE_LIST = 0,
    5353        HW_RES_ENABLE_INTERRUPT,
     54        HW_RES_DISABLE_INTERRUPT,
     55        HW_RES_CLEAR_INTERRUPT,
    5456        HW_RES_DMA_CHANNEL_SETUP,
    5557        HW_RES_DMA_CHANNEL_REMAIN,
     
    116118extern int hw_res_get_resource_list(async_sess_t *, hw_resource_list_t *);
    117119extern int hw_res_enable_interrupt(async_sess_t *, int);
     120extern int hw_res_disable_interrupt(async_sess_t *, int);
     121extern int hw_res_clear_interrupt(async_sess_t *, int);
    118122
    119123extern int hw_res_dma_channel_setup(async_sess_t *, unsigned int, uint32_t,
  • uspace/lib/drv/generic/remote_hw_res.c

    rce732e74 rd51838f  
    4545static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
    4646    ipc_call_t *);
     47static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
     48    ipc_call_t *);
     49static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, ipc_callid_t,
     50    ipc_call_t *);
    4751static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_callid_t,
    4852    ipc_call_t *);
     
    5357        [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list,
    5458        [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt,
     59        [HW_RES_DISABLE_INTERRUPT] = &remote_hw_res_disable_interrupt,
     60        [HW_RES_CLEAR_INTERRUPT] = &remote_hw_res_clear_interrupt,
    5561        [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup,
    5662        [HW_RES_DMA_CHANNEL_REMAIN] = &remote_hw_res_dma_channel_remain,
     
    6874       
    6975        if (hw_res_ops->enable_interrupt == NULL) {
     76                async_answer_0(callid, ENOTSUP);
     77                return;
     78        }
     79       
     80        const int irq = DEV_IPC_GET_ARG1(*call);
     81        const int ret = hw_res_ops->enable_interrupt(fun, irq);
     82        async_answer_0(callid, ret);
     83}
     84
     85static void remote_hw_res_disable_interrupt(ddf_fun_t *fun, void *ops,
     86    ipc_callid_t callid, ipc_call_t *call)
     87{
     88        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
     89       
     90        if (hw_res_ops->disable_interrupt == NULL) {
     91                async_answer_0(callid, ENOTSUP);
     92                return;
     93        }
     94       
     95        const int irq = DEV_IPC_GET_ARG1(*call);
     96        const int ret = hw_res_ops->disable_interrupt(fun, irq);
     97        async_answer_0(callid, ret);
     98}
     99
     100static void remote_hw_res_clear_interrupt(ddf_fun_t *fun, void *ops,
     101    ipc_callid_t callid, ipc_call_t *call)
     102{
     103        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
     104       
     105        if (hw_res_ops->clear_interrupt == NULL) {
    70106                async_answer_0(callid, ENOTSUP);
    71107                return;
  • uspace/lib/drv/include/ops/hw_res.h

    rce732e74 rd51838f  
    4545        hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
    4646        int (*enable_interrupt)(ddf_fun_t *, int);
     47        int (*disable_interrupt)(ddf_fun_t *, int);
     48        int (*clear_interrupt)(ddf_fun_t *, int);
    4749        int (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint32_t, uint8_t);
    4850        int (*dma_channel_remain)(ddf_fun_t *, unsigned, size_t *);
Note: See TracChangeset for help on using the changeset viewer.