Changeset 6a44ee4 in mainline for uspace/drv


Ignore:
Timestamp:
2011-07-20T15:26:21Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
efcebe1
Parents:
25bef0ff (diff), a701812 (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:

Merge mainline changes.

Location:
uspace/drv
Files:
140 added
34 moved

Legend:

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

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/bus/isa/isa.c

    r25bef0ff r6a44ee4  
    352352                    str_error(rc));
    353353        }
     354
     355        free(id);
    354356}
    355357
  • uspace/drv/bus/pci/pciintel/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/bus/pci/pciintel/pci.c

    r25bef0ff r6a44ee4  
    5252#include <ipc/devman.h>
    5353#include <ipc/dev_iface.h>
     54#include <ipc/irc.h>
     55#include <ns.h>
     56#include <ipc/services.h>
     57#include <sysinfo.h>
    5458#include <ops/hw_res.h>
    5559#include <device/hw_res.h>
    5660#include <ddi.h>
    5761#include <libarch/ddi.h>
     62#include <pci_dev_iface.h>
    5863
    5964#include "pci.h"
     
    8489static bool pciintel_enable_interrupt(ddf_fun_t *fnode)
    8590{
    86         /* TODO */
    87        
    88         return false;
     91        /* This is an old ugly way, copied from ne2000 driver */
     92        assert(fnode);
     93        pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data;
     94       
     95        sysarg_t apic;
     96        sysarg_t i8259;
     97       
     98        async_sess_t *irc_sess = NULL;
     99       
     100        if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
     101            || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {
     102                irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     103                    SERVICE_IRC, 0, 0);
     104        }
     105       
     106        if (!irc_sess)
     107                return false;
     108       
     109        size_t i = 0;
     110        hw_resource_list_t *res = &dev_data->hw_resources;
     111        for (; i < res->count; i++) {
     112                if (res->resources[i].type == INTERRUPT) {
     113                        const int irq = res->resources[i].res.interrupt.irq;
     114                       
     115                        async_exch_t *exch = async_exchange_begin(irc_sess);
     116                        const int rc =
     117                            async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq);
     118                        async_exchange_end(exch);
     119                       
     120                        if (rc != EOK) {
     121                                async_hangup(irc_sess);
     122                                return false;
     123                        }
     124                }
     125        }
     126       
     127        async_hangup(irc_sess);
     128        return true;
     129}
     130
     131static int pci_config_space_write_32(ddf_fun_t *fun, uint32_t address,
     132    uint32_t data)
     133{
     134        if (address > 252)
     135                return EINVAL;
     136        pci_conf_write_32(PCI_FUN(fun), address, data);
     137        return EOK;
     138}
     139
     140static int pci_config_space_write_16(
     141    ddf_fun_t *fun, uint32_t address, uint16_t data)
     142{
     143        if (address > 254)
     144                return EINVAL;
     145        pci_conf_write_16(PCI_FUN(fun), address, data);
     146        return EOK;
     147}
     148
     149static int pci_config_space_write_8(
     150    ddf_fun_t *fun, uint32_t address, uint8_t data)
     151{
     152        if (address > 255)
     153                return EINVAL;
     154        pci_conf_write_8(PCI_FUN(fun), address, data);
     155        return EOK;
     156}
     157
     158static int pci_config_space_read_32(
     159    ddf_fun_t *fun, uint32_t address, uint32_t *data)
     160{
     161        if (address > 252)
     162                return EINVAL;
     163        *data = pci_conf_read_32(PCI_FUN(fun), address);
     164        return EOK;
     165}
     166
     167static int pci_config_space_read_16(
     168    ddf_fun_t *fun, uint32_t address, uint16_t *data)
     169{
     170        if (address > 254)
     171                return EINVAL;
     172        *data = pci_conf_read_16(PCI_FUN(fun), address);
     173        return EOK;
     174}
     175
     176static int pci_config_space_read_8(
     177    ddf_fun_t *fun, uint32_t address, uint8_t *data)
     178{
     179        if (address > 255)
     180                return EINVAL;
     181        *data = pci_conf_read_8(PCI_FUN(fun), address);
     182        return EOK;
    89183}
    90184
     
    94188};
    95189
    96 static ddf_dev_ops_t pci_fun_ops;
     190static pci_dev_iface_t pci_dev_ops = {
     191        .config_space_read_8 = &pci_config_space_read_8,
     192        .config_space_read_16 = &pci_config_space_read_16,
     193        .config_space_read_32 = &pci_config_space_read_32,
     194        .config_space_write_8 = &pci_config_space_write_8,
     195        .config_space_write_16 = &pci_config_space_write_16,
     196        .config_space_write_32 = &pci_config_space_write_32
     197};
     198
     199static ddf_dev_ops_t pci_fun_ops = {
     200        .interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops,
     201        .interfaces[PCI_DEV_IFACE] = &pci_dev_ops
     202};
    97203
    98204static int pci_add_device(ddf_dev_t *);
     
    236342        }
    237343       
     344        free(match_id_str);
     345       
    238346        /* TODO add more ids (with subsys ids, using class id etc.) */
    239347}
     
    288396        /* Get the value of the BAR. */
    289397        val = pci_conf_read_32(fun, addr);
     398
     399#define IO_MASK  (~0x3)
     400#define MEM_MASK (~0xf)
    290401       
    291402        io = (bool) (val & 1);
    292403        if (io) {
    293404                addrw64 = false;
     405                mask = IO_MASK;
    294406        } else {
     407                mask = MEM_MASK;
    295408                switch ((val >> 1) & 3) {
    296409                case 0:
     
    308421        /* Get the address mask. */
    309422        pci_conf_write_32(fun, addr, 0xffffffff);
    310         mask = pci_conf_read_32(fun, addr);
     423        mask &= pci_conf_read_32(fun, addr);
    311424       
    312425        /* Restore the original value. */
     
    469582       
    470583        ddf_msg(LVL_DEBUG, "pci_add_device");
    471         dnode->parent_phone = -1;
     584        dnode->parent_sess = NULL;
    472585       
    473586        bus = pci_bus_new();
     
    480593        dnode->driver_data = bus;
    481594       
    482         dnode->parent_phone = devman_parent_device_connect(dnode->handle,
    483             IPC_FLAG_BLOCKING);
    484         if (dnode->parent_phone < 0) {
     595        dnode->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
     596            dnode->handle, IPC_FLAG_BLOCKING);
     597        if (!dnode->parent_sess) {
    485598                ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the "
    486                     "parent's driver.");
    487                 rc = dnode->parent_phone;
     599                    "parent driver.");
     600                rc = ENOENT;
    488601                goto fail;
    489602        }
     
    491604        hw_resource_list_t hw_resources;
    492605       
    493         rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
     606        rc = hw_res_get_resource_list(dnode->parent_sess, &hw_resources);
    494607        if (rc != EOK) {
    495608                ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources "
     
    544657        if (bus != NULL)
    545658                pci_bus_delete(bus);
    546         if (dnode->parent_phone >= 0)
    547                 async_hangup(dnode->parent_phone);
     659       
     660        if (dnode->parent_sess)
     661                async_hangup(dnode->parent_sess);
     662       
    548663        if (got_res)
    549664                hw_res_clean_resource_list(&hw_resources);
     665       
    550666        if (ctl != NULL)
    551667                ddf_fun_destroy(ctl);
    552 
     668       
    553669        return rc;
    554670}
     
    558674        ddf_log_init(NAME, LVL_ERROR);
    559675        pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
     676        pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops;
    560677}
    561678
     
    629746size_t pci_bar_mask_to_size(uint32_t mask)
    630747{
    631         return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
     748        size_t size = mask & ~(mask - 1);
     749        return size;
    632750}
    633751
  • uspace/drv/bus/usb/ehci/ehci.h

    r25bef0ff r6a44ee4  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup drvusbehci
    3130 * @{
    3231 */
    3332/** @file
     33 * Common EHCI definitions.
    3434 */
     35#ifndef DRV_EHCI_EHCI_H
     36#define DRV_EHCI_EHCI_H
    3537
    36 #ifndef LIBC_IPC_MOUSE_H_
    37 #define LIBC_IPC_MOUSE_H_
     38#include <usbhc_iface.h>
    3839
    39 #include <ipc/common.h>
     40#define NAME "ehci"
    4041
    41 typedef enum {
    42         MEVENT_BUTTON = IPC_FIRST_USER_METHOD,
    43         MEVENT_MOVE
    44 } mouse_notif_t;
     42extern usbhc_iface_t ehci_hc_iface;
    4543
    4644#endif
    47 
    4845/**
    4946 * @}
    5047 */
     48
  • uspace/drv/bus/usb/uhci/uhci.h

    r25bef0ff r6a44ee4  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup drvusbuhci
    3130 * @{
    3231 */
    3332/** @file
     33 * @brief UHCI driver main structure for both host controller and root-hub.
    3434 */
     35#ifndef DRV_UHCI_UHCI_H
     36#define DRV_UHCI_UHCI_H
     37#include <ddf/driver.h>
    3538
    36 #ifndef CHAR_MOUSE_H_
    37 #define CHAR_MOUSE_H_
    38 
    39 extern void mouse_handle_byte(int);
    40 extern void mouse_ev_btn(int button, int press);
    41 extern void mouse_ev_move(int dx, int dy);
    42 
     39int device_setup_uhci(ddf_dev_t *device);
    4340#endif
    44 
    4541/**
    4642 * @}
  • uspace/drv/bus/usb/usbhub/main.c

    r25bef0ff r6a44ee4  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2010 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
     29/** @addtogroup drvusbhub
    3030 * @{
    31  */
    32 /** @file
    33  * @brief
    3431 */
    3532
    36 #include <ipc/adb.h>
     33#include <ddf/driver.h>
     34#include <errno.h>
    3735#include <async.h>
    38 #include <vfs/vfs.h>
    39 #include <fcntl.h>
    40 #include <errno.h>
     36#include <stdio.h>
    4137
    42 #include "adb_mouse.h"
    43 #include "adb_dev.h"
     38#include <usb/dev/driver.h>
     39#include <usb/classes/classes.h>
    4440
    45 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall);
     41#include "usbhub.h"
     42#include "usbhub_private.h"
    4643
    47 static int dev_phone;
     44/** Hub status-change endpoint description.
     45 *
     46 * For more information see section 11.15.1 of USB 1.1 specification.
     47 */
     48static usb_endpoint_description_t hub_status_change_endpoint_description = {
     49        .transfer_type = USB_TRANSFER_INTERRUPT,
     50        .direction = USB_DIRECTION_IN,
     51        .interface_class = USB_CLASS_HUB,
     52        .interface_subclass = 0,
     53        .interface_protocol = 0,
     54        .flags = 0
     55};
    4856
    49 int adb_dev_init(void)
     57/**
     58 * usb hub driver operations
     59 *
     60 * The most important one is add_device, which is set to usb_hub_add_device.
     61 */
     62static usb_driver_ops_t usb_hub_driver_ops = {
     63        .add_device = usb_hub_add_device
     64};
     65
     66/**
     67 * hub endpoints, excluding control endpoint
     68 */
     69static usb_endpoint_description_t *usb_hub_endpoints[] = {
     70        &hub_status_change_endpoint_description,
     71        NULL
     72};
     73
     74/**
     75 * static usb hub driver information
     76 */
     77static usb_driver_t usb_hub_driver = {
     78        .name = NAME,
     79        .ops = &usb_hub_driver_ops,
     80        .endpoints = usb_hub_endpoints
     81};
     82
     83
     84int main(int argc, char *argv[])
    5085{
    51         const char *input = "/dev/adb/mouse";
    52         int input_fd;
     86        printf(NAME ": HelenOS USB hub driver.\n");
    5387
    54         printf(NAME ": open %s\n", input);
     88        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    5589
    56         input_fd = open(input, O_RDONLY);
    57         if (input_fd < 0) {
    58                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    59                 return false;
    60         }
    61 
    62         dev_phone = fd_phone(input_fd);
    63         if (dev_phone < 0) {
    64                 printf(NAME ": Failed to connect to device\n");
    65                 return false;
    66         }
    67 
    68         /* NB: The callback connection is slotted for removal */
    69         if (async_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) {
    70                 printf(NAME ": Failed to create callback from device\n");
    71                 return false;
    72         }
    73        
    74         return 0;
    75 }
    76 
    77 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall)
    78 {
    79         /* Ignore parameters, the connection is already opened */
    80         while (true) {
    81 
    82                 ipc_call_t call;
    83                 ipc_callid_t callid = async_get_call(&call);
    84 
    85                 int retval;
    86 
    87                 switch (IPC_GET_IMETHOD(call)) {
    88                 case IPC_M_PHONE_HUNGUP:
    89                         /* TODO: Handle hangup */
    90                         return;
    91                 case IPC_FIRST_USER_METHOD:
    92                         mouse_handle_data(IPC_GET_ARG1(call));
    93                         break;
    94                 default:
    95                         retval = ENOENT;
    96                 }
    97                 async_answer_0(callid, retval);
    98         }
     90        return usb_driver_main(&usb_hub_driver);
    9991}
    10092
     
    10294 * @}
    10395 */
     96
  • uspace/drv/char/ns8250/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/char/ns8250/ns8250.c

    r25bef0ff r6a44ee4  
    263263static void ns8250_dev_cleanup(ns8250_t *ns)
    264264{
    265         if (ns->dev->parent_phone > 0) {
    266                 async_hangup(ns->dev->parent_phone);
    267                 ns->dev->parent_phone = 0;
     265        if (ns->dev->parent_sess) {
     266                async_hangup(ns->dev->parent_sess);
     267                ns->dev->parent_sess = NULL;
    268268        }
    269269}
     
    337337       
    338338        /* Connect to the parent's driver. */
    339         ns->dev->parent_phone = devman_parent_device_connect(ns->dev->handle,
    340             IPC_FLAG_BLOCKING);
    341         if (ns->dev->parent_phone < 0) {
     339        ns->dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
     340            ns->dev->handle, IPC_FLAG_BLOCKING);
     341        if (!ns->dev->parent_sess) {
    342342                ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
    343343                    "device %s.", ns->dev->name);
    344                 ret = ns->dev->parent_phone;
     344                ret = ENOENT;
    345345                goto failed;
    346346        }
    347347       
    348348        /* Get hw resources. */
    349         ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
     349        ret = hw_res_get_resource_list(ns->dev->parent_sess, &hw_resources);
    350350        if (ret != EOK) {
    351351                ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
  • uspace/drv/infrastructure/root/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/infrastructure/root/root.c

    r25bef0ff r6a44ee4  
    176176        }
    177177
     178        free(match_id);
     179
    178180        rc = ddf_fun_bind(fun);
    179181        if (rc != EOK) {
  • uspace/drv/infrastructure/rootpc/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/infrastructure/rootvirt/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/infrastructure/rootvirt/devices.def

    r25bef0ff r6a44ee4  
    2626},
    2727#endif
     28#ifdef CONFIG_RUN_VIRTUAL_USB_HC
     29/* Virtual USB host controller. */
     30{
     31        .name = "usbhc",
     32        .match_id = "usb&hc=vhc"
     33},
     34#endif
  • uspace/drv/test/test1/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
  • uspace/drv/test/test1/test1.c

    r25bef0ff r6a44ee4  
    7474        }
    7575
    76         rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
     76        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7777        if (rc != EOK) {
    7878                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
  • uspace/drv/test/test2/Makefile

    r25bef0ff r6a44ee4  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29USPACE_PREFIX = ../../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
Note: See TracChangeset for help on using the changeset viewer.