Changeset 1864948 in mainline


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

isa: Implement DMA remain size query.

Location:
uspace/drv/bus/isa
Files:
3 edited

Legend:

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

    r6fd365d r1864948  
    429429}
    430430
     431extern int dma_channel_remain(unsigned channel, uint16_t *size)
     432{
     433        assert(size);
     434        if ((channel == 0) || (channel == 4))
     435                return ENOTSUP;
     436       
     437        if (channel > 7)
     438                return ENOENT;
     439       
     440        fibril_mutex_lock(&guard);
     441        if (!controller_8237.initialized) {
     442                fibril_mutex_unlock(&guard);
     443                return EIO;
     444        }
     445
     446        const dma_channel_t dma_channel = controller_8237.channels[channel];
     447        /* Get size - reset flip-flop */
     448        pio_write_8(dma_channel.flip_flop_address, 0);
     449       
     450        /* Low byte */
     451        const uint8_t value_low = pio_read_8(dma_channel.size_reg_address);
     452        ddf_msg(LVL_DEBUG2, "Read size low byte: %p:%zx.",
     453            dma_channel.size_reg_address, value_low);
     454       
     455        /* High byte */
     456        const uint8_t value_high = pio_read_8(dma_channel.size_reg_address);
     457        ddf_msg(LVL_DEBUG2, "Read size high byte: %p:%zx.",
     458            dma_channel.size_reg_address, value_high);
     459        fibril_mutex_unlock(&guard);
     460
     461        const int remain = (value_high << 8 | value_low) + 1;
     462        /* 16 bit DMA size is in words */
     463        *size =  channel >= 4 ? remain << 1 : remain;
     464        return EOK;
     465}
    431466/**
    432467 * @}
  • uspace/drv/bus/isa/i8237.h

    r6fd365d r1864948  
    3939
    4040extern int dma_channel_setup(unsigned, uint32_t, uint16_t, uint8_t);
     41extern int dma_channel_remain(unsigned, uint16_t *);
    4142
    4243#endif
  • uspace/drv/bus/isa/isa.c

    r6fd365d r1864948  
    169169}
    170170
     171static int isa_fun_remain_dma(ddf_fun_t *fnode,
     172    unsigned channel, uint16_t *size)
     173{
     174        assert(size);
     175        assert(fnode);
     176        isa_fun_t *isa_fun = fnode->driver_data;
     177        assert(isa_fun);
     178        const hw_resource_list_t *res = &isa_fun->hw_resources;
     179        assert(res);
     180       
     181        for (size_t i = 0; i < res->count; ++i) {
     182                /* Check for assigned channel */
     183                if (((res->resources[i].type == DMA_CHANNEL_16) &&
     184                    (res->resources[i].res.dma_channel.dma16 == channel)) ||
     185                    ((res->resources[i].type == DMA_CHANNEL_8) &&
     186                    (res->resources[i].res.dma_channel.dma8 == channel))) {
     187                        return dma_channel_remain(channel, size);
     188                }
     189        }
     190       
     191        return EINVAL;
     192}
     193
    171194static hw_res_ops_t isa_fun_hw_res_ops = {
    172195        .get_resource_list = isa_fun_get_resources,
    173196        .enable_interrupt = isa_fun_enable_interrupt,
    174197        .dma_channel_setup = isa_fun_setup_dma,
     198        .dma_channel_remain = isa_fun_remain_dma,
    175199};
    176200
Note: See TracChangeset for help on using the changeset viewer.