Changeset 153cc76a in mainline for uspace/drv/bus


Ignore:
Timestamp:
2011-12-23T16:42:22Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e1b130
Parents:
4291215 (diff), 2f0dd2a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

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

Legend:

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

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

    r4291215 r153cc76a  
    22 * Copyright (c) 2010 Lenka Trochtova
    33 * Copyright (c) 2011 Jiri Svoboda
     4 * Copyright (c) 2011 Jan Vesely
    45 * All rights reserved.
    56 *
     
    5253#include <fcntl.h>
    5354#include <sys/stat.h>
     55#include <ipc/irc.h>
     56#include <ipc/services.h>
     57#include <sysinfo.h>
     58#include <ns.h>
    5459
    5560#include <ddf/driver.h>
     
    6166#include <device/hw_res.h>
    6267
     68#include "i8237.h"
     69
    6370#define NAME "isa"
    6471#define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev"
     
    7077#define ISA_FUN(fun) ((isa_fun_t *) ((fun)->driver_data))
    7178
    72 #define ISA_MAX_HW_RES 4
     79#define ISA_MAX_HW_RES 5
    7380
    7481typedef struct {
     
    96103static bool isa_enable_fun_interrupt(ddf_fun_t *fnode)
    97104{
    98         /* TODO */
    99 
    100         return false;
     105        /* This is an old ugly way, copied from pci driver */
     106        assert(fnode);
     107        isa_fun_t *isa_fun = fnode->driver_data;
     108
     109        sysarg_t apic;
     110        sysarg_t i8259;
     111       
     112        async_sess_t *irc_sess = NULL;
     113       
     114        if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
     115            || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {
     116                irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     117                    SERVICE_IRC, 0, 0);
     118        }
     119       
     120        if (!irc_sess)
     121                return false;
     122       
     123        assert(isa_fun);
     124        const hw_resource_list_t *res = &isa_fun->hw_resources;
     125        assert(res);
     126        for (size_t i = 0; i < res->count; ++i) {
     127                if (res->resources[i].type == INTERRUPT) {
     128                        const int irq = res->resources[i].res.interrupt.irq;
     129                       
     130                        async_exch_t *exch = async_exchange_begin(irc_sess);
     131                        const int rc =
     132                            async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq);
     133                        async_exchange_end(exch);
     134                       
     135                        if (rc != EOK) {
     136                                async_hangup(irc_sess);
     137                                return false;
     138                        }
     139                }
     140        }
     141       
     142        async_hangup(irc_sess);
     143        return true;
     144}
     145
     146static int isa_dma_channel_fun_setup(ddf_fun_t *fnode,
     147    unsigned int 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       
     154        const unsigned int ch = channel;
     155        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))) {
     160                        return dma_setup_channel(channel, pa, size, mode);
     161                }
     162        }
     163       
     164        return EINVAL;
    101165}
    102166
    103167static hw_res_ops_t isa_fun_hw_res_ops = {
    104         &isa_get_fun_resources,
    105         &isa_enable_fun_interrupt
     168        .get_resource_list = isa_get_fun_resources,
     169        .enable_interrupt = isa_enable_fun_interrupt,
     170        .dma_channel_setup = isa_dma_channel_fun_setup,
    106171};
    107172
     
    274339}
    275340
     341static void isa_fun_set_dma(isa_fun_t *fun, int dma)
     342{
     343        size_t count = fun->hw_resources.count;
     344        hw_resource_t *resources = fun->hw_resources.resources;
     345       
     346        if (count < ISA_MAX_HW_RES) {
     347                if ((dma > 0) && (dma < 4)) {
     348                        resources[count].type = DMA_CHANNEL_8;
     349                        resources[count].res.dma_channel.dma8 = dma;
     350                       
     351                        fun->hw_resources.count++;
     352                        ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
     353                            fun->fnode->name);
     354                       
     355                        return;
     356                }
     357
     358                if ((dma > 4) && (dma < 8)) {
     359                        resources[count].type = DMA_CHANNEL_16;
     360                        resources[count].res.dma_channel.dma16 = dma;
     361                       
     362                        fun->hw_resources.count++;
     363                        ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
     364                            fun->fnode->name);
     365                       
     366                        return;
     367                }
     368               
     369                ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma,
     370                    fun->fnode->name);
     371        }
     372}
     373
    276374static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len)
    277375{
     
    303401        if (val != end)
    304402                isa_fun_set_irq(fun, irq);
     403}
     404
     405static void fun_parse_dma(isa_fun_t *fun, char *val)
     406{
     407        unsigned int dma = 0;
     408        char *end = NULL;
     409       
     410        val = skip_spaces(val);
     411        dma = (unsigned int) strtol(val, &end, 10);
     412       
     413        if (val != end)
     414                isa_fun_set_dma(fun, dma);
    305415}
    306416
     
    396506        if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
    397507            !prop_parse(fun, line, "irq", &fun_parse_irq) &&
     508            !prop_parse(fun, line, "dma", &fun_parse_dma) &&
    398509            !prop_parse(fun, line, "match", &fun_parse_match_id)) {
    399510
     
    406517{
    407518        fun->hw_resources.resources =
    408             (hw_resource_t *)malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);
     519            (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);
    409520}
    410521
     
    590701
    591702
    592 static void isa_init() 
     703static void isa_init()
    593704{
    594705        ddf_log_init(NAME, LVL_ERROR);
  • uspace/drv/bus/isa/isa.dev

    r4291215 r153cc76a  
    1818        irq 5
    1919        io_range 300 20
     20
     21sb16:
     22        match 100 isa/sb16
     23        io_range 220 20
     24        io_range 330 2
     25        irq 5
     26        dma 1
     27        dma 5
  • uspace/drv/bus/pci/pciintel/pci.c

    r4291215 r153cc76a  
    187187
    188188static hw_res_ops_t pciintel_hw_res_ops = {
    189         &pciintel_get_resources,
    190         &pciintel_enable_interrupt
     189        .get_resource_list = &pciintel_get_resources,
     190        .enable_interrupt = &pciintel_enable_interrupt,
    191191};
    192192
  • uspace/drv/bus/usb/ohci/utils/malloc32.h

    r4291215 r153cc76a  
    5656        uintptr_t result;
    5757        int ret = as_get_physical_mapping(addr, &result);
    58 
     58       
    5959        if (ret != EOK)
    6060                return 0;
    61         return (result | ((uintptr_t)addr & 0xfff));
     61       
     62        return result;
    6263}
    6364/*----------------------------------------------------------------------------*/
  • uspace/drv/bus/usb/uhci/utils/malloc32.h

    r4291215 r153cc76a  
    5454        if (addr == NULL)
    5555                return 0;
    56 
     56       
    5757        uintptr_t result;
    5858        const int ret = as_get_physical_mapping(addr, &result);
    5959        if (ret != EOK)
    6060                return 0;
    61         return (result | ((uintptr_t)addr & 0xfff));
     61       
     62        return result;
    6263}
    6364/*----------------------------------------------------------------------------*/
     
    9798static inline void * get_page(void)
    9899{
    99         void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    100         if (free_address == 0)
     100        void *address = as_area_create((void *) -1, UHCI_REQUIRED_PAGE_SIZE,
     101            AS_AREA_READ | AS_AREA_WRITE);
     102        if (address == (void *) -1)
    101103                return NULL;
    102         void *address = as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    103                   AS_AREA_READ | AS_AREA_WRITE);
    104         if (address != free_address)
    105                 return NULL;
     104       
    106105        return address;
    107106}
  • uspace/drv/bus/usb/usbmast/main.c

    r4291215 r153cc76a  
    300300                return;
    301301        }
    302 
    303         comm_buf = as_get_mappable_page(comm_size);
    304         if (comm_buf == NULL) {
     302       
     303        (void) async_share_out_finalize(callid, &comm_buf);
     304        if (comm_buf == (void *) -1) {
    305305                async_answer_0(callid, EHANGUP);
    306306                return;
    307307        }
    308 
    309         (void) async_share_out_finalize(callid, comm_buf);
    310 
     308       
    311309        mfun = (usbmast_fun_t *) ((ddf_fun_t *)arg)->driver_data;
    312310
Note: See TracChangeset for help on using the changeset viewer.