Changeset 3869c596 in mainline


Ignore:
Timestamp:
2012-08-30T18:15:10Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
57b28f9
Parents:
f3fb83a
Message:

isa dma: Use size_t to transfer remaining buffer size.

Be more careful with dma size bit magic.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/i8237.c

    rf3fb83a r3869c596  
    3838#include <bool.h>
    3939#include <errno.h>
     40#include <ddi.h>
     41#include <ddf/log.h>
    4042#include <fibril_synch.h>
    41 #include <ddi.h>
    4243#include <libarch/ddi.h>
    43 #include <ddf/log.h>
    4444#include "i8237.h"
    4545
     
    454454 * @return Error code.
    455455 */
    456 int dma_channel_remain(unsigned channel, uint16_t *size)
     456int dma_channel_remain(unsigned channel, size_t *size)
    457457{
    458458        assert(size);
     
    484484        fibril_mutex_unlock(&guard);
    485485
    486         const int remain = (value_high << 8 | value_low) + 1;
    487         /* 16 bit DMA size is in words */
    488         *size =  is_dma16(channel) ? remain << 1 : remain;
     486        uint16_t remain = (value_high << 8 | value_low) ;
     487        /* 16 bit DMA size is in words,
     488         * the upper bits are bogus for 16bit transfers so we need to get
     489         * rid of them. Using limited type works well.*/
     490        if (is_dma16(channel))
     491                remain <<= 1;
     492        *size =  is_dma16(channel) ? remain + 2: remain + 1;
    489493        return EOK;
    490494}
  • uspace/drv/bus/isa/i8237.h

    rf3fb83a r3869c596  
    3939
    4040extern int dma_channel_setup(unsigned, uint32_t, uint16_t, uint8_t);
    41 extern int dma_channel_remain(unsigned, uint16_t *);
     41extern int dma_channel_remain(unsigned, size_t *);
    4242
    4343#endif
  • uspace/drv/bus/isa/isa.c

    rf3fb83a r3869c596  
    170170
    171171static int isa_fun_remain_dma(ddf_fun_t *fnode,
    172     unsigned channel, uint16_t *size)
     172    unsigned channel, size_t *size)
    173173{
    174174        assert(size);
  • uspace/lib/drv/generic/remote_hw_res.c

    rf3fb83a r3869c596  
    130130        }
    131131        const unsigned channel = DEV_IPC_GET_ARG1(*call);
    132         uint16_t remain = 0;
     132        size_t remain = 0;
    133133        const int ret = hw_res_ops->dma_channel_remain(fun, channel, &remain);
    134134        async_answer_1(callid, ret, remain);
  • uspace/lib/drv/include/ops/hw_res.h

    rf3fb83a r3869c596  
    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 *);
     47        int (*dma_channel_remain)(ddf_fun_t *, unsigned, size_t *);
    4848} hw_res_ops_t;
    4949
Note: See TracChangeset for help on using the changeset viewer.