Changeset 3869c596 in mainline for uspace/drv/bus/isa/i8237.c


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.

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.