Changeset 9991c47 in mainline


Ignore:
Timestamp:
2011-11-13T22:18:58Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8a5962f
Parents:
e6def65
Message:

libc, libdrv: Add support for DMA channel handling.

Location:
uspace/lib
Files:
4 edited

Legend:

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

    re6def65 r9991c47  
    8484}
    8585
     86int hw_res_dma_channel_setup(async_sess_t *sess,
     87    unsigned channel, uint32_t pa, uint16_t size, uint8_t mode)
     88{
     89        async_exch_t *exch = async_exchange_begin(sess);
     90        if (exch == NULL)
     91                return ENOMEM;
     92        uint32_t packed = size | (mode << 16);
     93        int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     94            HW_RES_DMA_CHANNEL_SETUP, channel, pa, packed);
     95        async_exchange_end(exch);
     96       
     97        return ret;
     98}
     99
    86100/** @}
    87101 */
  • uspace/lib/c/include/device/hw_res.h

    re6def65 r9991c47  
    4343typedef enum {
    4444        HW_RES_GET_RESOURCE_LIST = 0,
    45         HW_RES_ENABLE_INTERRUPT
     45        HW_RES_ENABLE_INTERRUPT,
     46        HW_RES_DMA_CHANNEL_SETUP,
    4647} hw_res_method_t;
    4748
     
    105106extern bool hw_res_enable_interrupt(async_sess_t *);
    106107
     108#define DMA_MODE_WRITE (1 << 2)
     109#define DMA_MODE_READ (1 << 3)
     110#define DMA_MODE_AUTO (1 << 4)
     111#define DMA_MODE_DOWN (1 << 5)
     112#define DMA_MODE_SINGLE (1 << 6)
     113#define DMA_MODE_BLOCK (1 << 7)
     114#define DMA_MODE_ON_DEMAND (0)
     115
     116extern int hw_res_dma_channel_setup(async_sess_t *,
     117    unsigned, uint32_t, uint16_t, uint8_t);
     118
    107119#endif
    108120
  • uspace/lib/drv/generic/remote_hw_res.c

    re6def65 r9991c47  
    4343static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
    4444    ipc_call_t *);
     45static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_callid_t,
     46    ipc_call_t *);
    4547
    4648static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
    47         &remote_hw_res_get_resource_list,
    48         &remote_hw_res_enable_interrupt
     49        [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list,
     50        [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt,
     51        [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup,
    4952};
    5053
     
    9497}
    9598
     99static void remote_hw_res_dma_channel_setup(ddf_fun_t *fun, void *ops,
     100    ipc_callid_t callid, ipc_call_t *call)
     101{
     102        hw_res_ops_t *hw_res_ops = ops;
     103
     104        if (hw_res_ops->dma_channel_setup == NULL) {
     105                async_answer_0(callid, ENOTSUP);
     106                return;
     107        }
     108        const unsigned channel = DEV_IPC_GET_ARG1(*call);
     109        const uint32_t address = DEV_IPC_GET_ARG2(*call);
     110        const uint16_t size = DEV_IPC_GET_ARG3(*call) & 0xffff;
     111        const uint8_t mode = DEV_IPC_GET_ARG3(*call) >> 16;
     112
     113        const int ret = hw_res_ops->dma_channel_setup(
     114            channel, address, size, mode);
     115        async_answer_0(callid, ret);
     116}
     117
    96118/**
    97119 * @}
  • uspace/lib/drv/include/ops/hw_res.h

    re6def65 r9991c47  
    4444         hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
    4545         bool (*enable_interrupt)(ddf_fun_t *);
     46         int (*dma_channel_setup)(unsigned, uintptr_t, uint16_t, uint8_t);
    4647} hw_res_ops_t;
    4748
Note: See TracChangeset for help on using the changeset viewer.