Changeset ec388d7 in mainline


Ignore:
Timestamp:
2011-11-14T10:03:49Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a0d1d9d
Parents:
8a5962f
Message:

isa: Add DMA controller driver implementation.

Location:
uspace/drv/bus/isa
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/Makefile

    r8a5962f rec388d7  
    11#
    22# Copyright (c) 2010 Lenka Trochtova
     3# Copyright (c) 2011 Jan Vesely
    34# All rights reserved.
    45#
     
    3334
    3435SOURCES = \
     36        dma_controller.c \
    3537        isa.c
    3638
  • uspace/drv/bus/isa/isa.c

    r8a5962f rec388d7  
    22 * Copyright (c) 2010 Lenka Trochtova
    33 * Copyright (c) 2011 Jiri Svoboda
     4 * Copyright (c) 2011 Jan Vesely
    45 * All rights reserved.
    56 *
     
    6566#include <device/hw_res.h>
    6667
     68#include "dma_controller.h"
     69
    6770#define NAME "isa"
    6871#define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev"
     
    119122
    120123        assert(isa_fun);
    121         hw_resource_list_t *res = &isa_fun->hw_resources;
     124        const hw_resource_list_t *res = &isa_fun->hw_resources;
    122125        assert(res);
    123         for (size_t i = 0; i < res->count; i++) {
     126        for (size_t i = 0; i < res->count; ++i) {
    124127                if (res->resources[i].type == INTERRUPT) {
    125128                        const int irq = res->resources[i].res.interrupt.irq;
     
    141144}
    142145
     146static int isa_dma_channel_fun_setup(ddf_fun_t *fnode,
     147    unsigned channel, uint32_t pa, uint16_t size, uint8_t mode)
     148{
     149        assert(fnode);
     150        isa_fun_t *isa_fun = fnode->driver_data;
     151        const hw_resource_list_t *res = &isa_fun->hw_resources;
     152        assert(res);
     153        const int ch = channel;
     154        for (size_t i = 0; i < res->count; ++i) {
     155                if ((res->resources[i].type == DMA_CHANNEL_16 &&
     156                    res->resources[i].res.dma_channel.dma16 == ch) ||
     157                    (res->resources[i].type == DMA_CHANNEL_8 &&
     158                    res->resources[i].res.dma_channel.dma8 == ch)) {
     159                        return dma_setup_channel(channel, pa, size, mode);
     160                }
     161        }
     162        return EINVAL;
     163}
     164
    143165static hw_res_ops_t isa_fun_hw_res_ops = {
    144         .get_resource_list = &isa_get_fun_resources,
    145         .enable_interrupt = &isa_enable_fun_interrupt,
     166        .get_resource_list = isa_get_fun_resources,
     167        .enable_interrupt = isa_enable_fun_interrupt,
     168        .dma_channel_setup = isa_dma_channel_fun_setup,
    146169};
    147170
Note: See TracChangeset for help on using the changeset viewer.