Changeset 6fd365d in mainline


Ignore:
Timestamp:
2012-08-18T14:20:28Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1864948
Parents:
bc6762f
Message:

libc,libdrv: Add remaining bytes query to DMA(hw_res) interface.

Location:
uspace/lib
Files:
4 edited

Legend:

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

    rbc6762f r6fd365d  
    115115}
    116116
     117/**
     118 * Query remaining bytes in the buffer.
     119 * @param channel DMA Channel 1,2,3 for 8 bit transfers, 5,6,7 for 16 bit.
     120 * @return Number of bytes remaining in the buffer(>=0) or error code(<0).
     121 */
     122int hw_res_dma_channel_remain(async_sess_t *sess, unsigned channel)
     123{
     124        async_exch_t *exch = async_exchange_begin(sess);
     125        if (exch == NULL)
     126                return ENOMEM;
     127        sysarg_t remain;
     128        const int ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     129            HW_RES_DMA_CHANNEL_REMAIN, channel, &remain);
     130        async_exchange_end(exch);
     131        if (ret == EOK)
     132                return remain;
     133        return ret;
     134}
     135
    117136/** @}
    118137 */
  • uspace/lib/c/include/device/hw_res.h

    rbc6762f r6fd365d  
    5353        HW_RES_ENABLE_INTERRUPT,
    5454        HW_RES_DMA_CHANNEL_SETUP,
     55        HW_RES_DMA_CHANNEL_REMAIN,
    5556} hw_res_method_t;
    5657
     
    116117extern int hw_res_dma_channel_setup(async_sess_t *, unsigned int, uint32_t,
    117118    uint16_t, uint8_t);
     119extern int hw_res_dma_channel_remain(async_sess_t *, unsigned);
    118120
    119121#endif
  • uspace/lib/drv/generic/remote_hw_res.c

    rbc6762f r6fd365d  
    4646static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_callid_t,
    4747    ipc_call_t *);
     48static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, ipc_callid_t,
     49    ipc_call_t *);
    4850
    4951static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
     
    5153        [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt,
    5254        [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup,
     55        [HW_RES_DMA_CHANNEL_REMAIN] = &remote_hw_res_dma_channel_remain,
    5356};
    5457
     
    117120}
    118121
     122static void remote_hw_res_dma_channel_remain(ddf_fun_t *fun, void *ops,
     123    ipc_callid_t callid, ipc_call_t *call)
     124{
     125        hw_res_ops_t *hw_res_ops = ops;
     126
     127        if (hw_res_ops->dma_channel_setup == NULL) {
     128                async_answer_0(callid, ENOTSUP);
     129                return;
     130        }
     131        const unsigned channel = DEV_IPC_GET_ARG1(*call);
     132        uint16_t remain = 0;
     133        const int ret = hw_res_ops->dma_channel_remain(fun, channel, &remain);
     134        async_answer_1(callid, ret, remain);
     135}
    119136/**
    120137 * @}
  • uspace/lib/drv/include/ops/hw_res.h

    rbc6762f r6fd365d  
    4545        bool (*enable_interrupt)(ddf_fun_t *);
    4646        int (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint16_t, uint8_t);
     47        int (*dma_channel_remain)(ddf_fun_t *, unsigned, uint16_t *);
    4748} hw_res_ops_t;
    4849
Note: See TracChangeset for help on using the changeset viewer.