Ignore:
File:
1 edited

Legend:

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

    r85c4cc45 r0bbd13e  
    5252#include <dirent.h>
    5353#include <fcntl.h>
     54#include <ipc/irc.h>
     55#include <ipc/services.h>
     56#include <sysinfo.h>
     57#include <ns.h>
    5458#include <sys/stat.h>
    5559#include <ipc/irc.h>
     
    6266#include <ops/hw_res.h>
    6367
    64 #include <devman.h>
    65 #include <ipc/devman.h>
    6668#include <device/hw_res.h>
    6769
    68 #include "dma_controller.h"
     70#include "i8237.h"
    6971
    7072#define NAME "isa"
     
    8991        fibril_mutex_t mutex;
    9092        ddf_fun_t *fnode;
    91         hw_resource_t resources[ISA_MAX_HW_RES];
    9293        hw_resource_list_t hw_resources;
    9394        link_t bus_link;
     
    146147
    147148static int isa_dma_channel_fun_setup(ddf_fun_t *fnode,
    148     unsigned channel, uint32_t pa, uint16_t size, uint8_t mode)
     149    unsigned int channel, uint32_t pa, uint16_t size, uint8_t mode)
    149150{
    150151        assert(fnode);
     
    152153        const hw_resource_list_t *res = &isa_fun->hw_resources;
    153154        assert(res);
    154         const int ch = channel;
     155       
     156        const unsigned int ch = channel;
    155157        for (size_t i = 0; i < res->count; ++i) {
    156                 if ((res->resources[i].type == DMA_CHANNEL_16 &&
    157                     res->resources[i].res.dma_channel.dma16 == ch) ||
    158                     (res->resources[i].type == DMA_CHANNEL_8 &&
    159                     res->resources[i].res.dma_channel.dma8 == ch)) {
     158                if (((res->resources[i].type == DMA_CHANNEL_16) &&
     159                    (res->resources[i].res.dma_channel.dma16 == ch)) ||
     160                    ((res->resources[i].type == DMA_CHANNEL_8) &&
     161                    (res->resources[i].res.dma_channel.dma8 == ch))) {
    160162                        return dma_setup_channel(channel, pa, size, mode);
    161163                }
    162164        }
     165       
    163166        return EINVAL;
    164167}
     
    172175static ddf_dev_ops_t isa_fun_ops;
    173176
    174 static int isa_add_device(ddf_dev_t *dev);
     177static int isa_dev_add(ddf_dev_t *dev);
    175178static int isa_dev_remove(ddf_dev_t *dev);
    176179static int isa_fun_online(ddf_fun_t *fun);
     
    179182/** The isa device driver's standard operations */
    180183static driver_ops_t isa_ops = {
    181         .add_device = &isa_add_device,
     184        .dev_add = &isa_dev_add,
    182185        .dev_remove = &isa_dev_remove,
    183186        .fun_online = &isa_fun_online,
     
    198201
    199202        isa_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(isa_fun_t));
    200         if (fun == NULL)
     203        if (fun == NULL) {
     204                ddf_fun_destroy(fnode);
    201205                return NULL;
     206        }
    202207
    203208        fibril_mutex_initialize(&fun->mutex);
    204         fun->hw_resources.resources = fun->resources;
    205 
    206209        fun->fnode = fnode;
    207210        return fun;
     
    344347        size_t count = fun->hw_resources.count;
    345348        hw_resource_t *resources = fun->hw_resources.resources;
    346 
     349       
    347350        if (count < ISA_MAX_HW_RES) {
    348                 if (dma > 0 && dma < 4) {
     351                if ((dma > 0) && (dma < 4)) {
    349352                        resources[count].type = DMA_CHANNEL_8;
    350353                        resources[count].res.dma_channel.dma8 = dma;
    351 
     354                       
    352355                        fun->hw_resources.count++;
    353356                        ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
    354357                            fun->fnode->name);
     358                       
    355359                        return;
    356360                }
    357361
    358                 if (dma > 4 && dma < 8) {
     362                if ((dma > 4) && (dma < 8)) {
    359363                        resources[count].type = DMA_CHANNEL_16;
    360364                        resources[count].res.dma_channel.dma16 = dma;
    361 
     365                       
    362366                        fun->hw_resources.count++;
    363367                        ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
    364368                            fun->fnode->name);
     369                       
    365370                        return;
    366371                }
    367 
     372               
    368373                ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma,
    369374                    fun->fnode->name);
     
    396401
    397402        val = skip_spaces(val);
    398         irq = (int)strtol(val, &end, 0x10);
     403        irq = (int) strtol(val, &end, 10);
    399404
    400405        if (val != end)
     
    404409static void fun_parse_dma(isa_fun_t *fun, char *val)
    405410{
    406         int dma = 0;
     411        unsigned int dma = 0;
    407412        char *end = NULL;
    408 
     413       
    409414        val = skip_spaces(val);
    410         dma = (int)strtol(val, &end, 10);
    411 
     415        dma = (unsigned int) strtol(val, &end, 10);
     416       
    412417        if (val != end)
    413418                isa_fun_set_dma(fun, dma);
     
    513518}
    514519
     520static void fun_hw_res_alloc(isa_fun_t *fun)
     521{
     522        fun->hw_resources.resources =
     523            (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);
     524}
     525
     526static void fun_hw_res_free(isa_fun_t *fun)
     527{
     528        free(fun->hw_resources.resources);
     529        fun->hw_resources.resources = NULL;
     530}
     531
    515532static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa)
    516533{
     
    541558                return NULL;
    542559        }
     560
     561        /* Allocate buffer for the list of hardware resources of the device. */
     562        fun_hw_res_alloc(fun);
    543563
    544564        /* Get properties of the device (match ids, irq and io range). */
     
    589609}
    590610
    591 static int isa_add_device(ddf_dev_t *dev)
     611static int isa_dev_add(ddf_dev_t *dev)
    592612{
    593613        isa_bus_t *isa;
    594614
    595         ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d",
     615        ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d",
    596616            (int) dev->handle);
    597617
     
    657677                list_remove(&fun->bus_link);
    658678
     679                fun_hw_res_free(fun);
    659680                ddf_fun_destroy(fun->fnode);
    660681        }
Note: See TracChangeset for help on using the changeset viewer.