Changeset c4e0b47 in mainline


Ignore:
Timestamp:
2011-04-04T08:18:54Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97ab321
Parents:
c593b21 (diff), 3094804b (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 development/ changes

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/pciintel/pci.c

    rc593b21 rc4e0b47  
    107107        }
    108108
    109         size_t i;
    110         for (i = 0; i < dev_data->hw_resources.count; i++) {
    111                 if (dev_data->hw_resources.resources[i].type == INTERRUPT) {
    112                         int irq = dev_data->hw_resources.resources[i].res.interrupt.irq;
    113                         int rc = async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
     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                        const int rc =
     115                            async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
    114116                        if (rc != EOK) {
    115117                                async_hangup(irc_phone);
  • uspace/drv/uhci-rhd/main.c

    rc593b21 rc4e0b47  
    4444
    4545#define NAME "uhci-rhd"
     46
    4647static int hc_get_my_registers(ddf_dev_t *dev,
    4748    uintptr_t *io_reg_address, size_t *io_reg_size);
    48 #if 0
    4949/*----------------------------------------------------------------------------*/
    50 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
    51 {
    52         assert(fun);
    53         assert(fun->driver_data);
    54         assert(handle);
    55 
    56         *handle = ((uhci_root_hub_t*)fun->driver_data)->hc_handle;
    57 
    58         return EOK;
    59 }
    60 /*----------------------------------------------------------------------------*/
    61 static usb_iface_t uhci_rh_usb_iface = {
    62         .get_hc_handle = usb_iface_get_hc_handle,
    63         .get_address = usb_iface_get_address_hub_impl
    64 };
    65 /*----------------------------------------------------------------------------*/
    66 static ddf_dev_ops_t uhci_rh_ops = {
    67         .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface,
    68 };
    69 #endif
    70 /*----------------------------------------------------------------------------*/
    71 /** Initialize a new ddf driver instance of UHCI root hub.
    72  *
    73  * @param[in] device DDF instance of the device to initialize.
    74  * @return Error code.
    75  */
    76 static int uhci_rh_add_device(ddf_dev_t *device)
    77 {
    78         if (!device)
    79                 return ENOTSUP;
    80 
    81         usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
    82 
    83         //device->ops = &uhci_rh_ops;
    84         uintptr_t io_regs = 0;
    85         size_t io_size = 0;
    86 
    87         int ret = hc_get_my_registers(device, &io_regs, &io_size);
    88         if (ret != EOK) {
    89                 usb_log_error("Failed to get registers from parent HC: %s.\n",
    90                     str_error(ret));
    91         }
    92         usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size);
    93 
    94         uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
    95         if (!rh) {
    96                 usb_log_error("Failed to allocate driver instance.\n");
    97                 return ENOMEM;
    98         }
    99 
    100         ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    101         if (ret != EOK) {
    102                 usb_log_error("Failed to initialize driver instance: %s.\n",
    103                     str_error(ret));
    104                 free(rh);
    105                 return ret;
    106         }
    107 
    108         device->driver_data = rh;
    109         usb_log_info("Controlling root hub `%s' (%llu).\n",
    110             device->name, device->handle);
    111         return EOK;
    112 }
     50static int uhci_rh_add_device(ddf_dev_t *device);
    11351/*----------------------------------------------------------------------------*/
    11452static driver_ops_t uhci_rh_driver_ops = {
     
    13270{
    13371        printf(NAME ": HelenOS UHCI root hub driver.\n");
     72        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     73        return ddf_driver_main(&uhci_rh_driver);
     74}
     75/*----------------------------------------------------------------------------*/
     76/** Initialize a new ddf driver instance of UHCI root hub.
     77 *
     78 * @param[in] device DDF instance of the device to initialize.
     79 * @return Error code.
     80 */
     81static int uhci_rh_add_device(ddf_dev_t *device)
     82{
     83        if (!device)
     84                return EINVAL;
    13485
    135         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     86        usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
    13687
    137         return ddf_driver_main(&uhci_rh_driver);
     88        uintptr_t io_regs = 0;
     89        size_t io_size = 0;
     90        uhci_root_hub_t *rh = NULL;
     91        int ret = EOK;
     92
     93#define CHECK_RET_FREE_RH_RETURN(ret, message...) \
     94if (ret != EOK) { \
     95        usb_log_error(message); \
     96        if (rh) \
     97                free(rh); \
     98        return ret; \
     99} else (void)0
     100
     101        ret = hc_get_my_registers(device, &io_regs, &io_size);
     102        CHECK_RET_FREE_RH_RETURN(ret,
     103            "Failed(%d) to get registers from HC: %s.\n", ret, str_error(ret));
     104        usb_log_debug("I/O regs at %#x (size %zu).\n", io_regs, io_size);
     105
     106        rh = malloc(sizeof(uhci_root_hub_t));
     107        ret = (rh == NULL) ? ENOMEM : EOK;
     108        CHECK_RET_FREE_RH_RETURN(ret,
     109            "Failed to allocate rh driver instance.\n");
     110
     111        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
     112        CHECK_RET_FREE_RH_RETURN(ret,
     113            "Failed(%d) to initialize rh driver instance: %s.\n",
     114            ret, str_error(ret));
     115
     116        device->driver_data = rh;
     117        usb_log_info("Controlling root hub '%s' (%llu).\n",
     118            device->name, device->handle);
     119        return EOK;
    138120}
    139121/*----------------------------------------------------------------------------*/
     
    156138        }
    157139
    158         int rc;
    159 
    160140        hw_resource_list_t hw_resources;
    161         rc = hw_res_get_resource_list(parent_phone, &hw_resources);
    162         if (rc != EOK) {
    163                 goto leave;
     141        int ret = hw_res_get_resource_list(parent_phone, &hw_resources);
     142        if (ret != EOK) {
     143                async_hangup(parent_phone);
     144                return ret;
    164145        }
    165146
     
    168149        bool io_found = false;
    169150
    170         size_t i;
    171         for (i = 0; i < hw_resources.count; i++) {
     151        size_t i = 0;
     152        for (; i < hw_resources.count; i++) {
    172153                hw_resource_t *res = &hw_resources.resources[i];
    173                 switch (res->type)
    174                 {
    175                 case IO_RANGE:
    176                         io_address = (uintptr_t) res->res.io_range.address;
     154                if (res->type == IO_RANGE) {
     155                        io_address = res->res.io_range.address;
    177156                        io_size = res->res.io_range.size;
    178157                        io_found = true;
    179 
    180                 default:
    181                         break;
    182158                }
    183159        }
     160        async_hangup(parent_phone);
    184161
    185162        if (!io_found) {
    186                 rc = ENOENT;
    187                 goto leave;
     163                return ENOENT;
    188164        }
    189 
    190165        if (io_reg_address != NULL) {
    191166                *io_reg_address = io_address;
     
    194169                *io_reg_size = io_size;
    195170        }
    196         rc = EOK;
    197 
    198 leave:
    199         async_hangup(parent_phone);
    200         return rc;
     171        return EOK;
    201172}
    202173/**
  • uspace/drv/uhci-rhd/port.c

    rc593b21 rc4e0b47  
    4343#include "port.h"
    4444
     45static int uhci_port_check(void *port);
     46static int uhci_port_reset_enable(int portno, void *arg);
    4547static int uhci_port_new_device(uhci_port_t *port, usb_speed_t speed);
    4648static int uhci_port_remove_device(uhci_port_t *port);
    4749static int uhci_port_set_enabled(uhci_port_t *port, bool enabled);
    48 static int uhci_port_check(void *port);
    49 static int uhci_port_reset_enable(int portno, void *arg);
    5050static void uhci_port_print_status(
    5151    uhci_port_t *port, const port_status_t value);
     
    7474        pio_write_16(port->address, value);
    7575}
    76 
    7776/*----------------------------------------------------------------------------*/
    7877/** Initialize UHCI root hub port instance.
     
    259258
    260259        usb_address_t dev_addr;
    261         int rc = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
     260        int ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
    262261            speed, uhci_port_reset_enable, port->number, port,
    263262            &dev_addr, &port->attached_device, NULL, NULL, NULL);
    264263
    265         if (rc != EOK) {
     264        if (ret != EOK) {
    266265                usb_log_error("%s: Failed(%d) to add device: %s.\n",
    267                     port->id_string, rc, str_error(rc));
     266                    port->id_string, ret, str_error(ret));
    268267                uhci_port_set_enabled(port, false);
    269                 return rc;
     268                return ret;
    270269        }
    271270
     
    287286int uhci_port_remove_device(uhci_port_t *port)
    288287{
    289         usb_log_error("%s: Don't know how to remove device %d.\n",
    290             port->id_string, (unsigned int)port->attached_device);
    291         return EOK;
     288        usb_log_error("%s: Don't know how to remove device %llu.\n",
     289            port->id_string, port->attached_device);
     290        return ENOTSUP;
    292291}
    293292/*----------------------------------------------------------------------------*/
     
    341340            (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
    342341            (value & STATUS_CONNECTED) ? " CONNECTED," : "",
    343             (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
     342            (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERR: NO ALWAYS ONE"
    344343        );
    345344}
  • uspace/drv/uhci-rhd/root_hub.c

    rc593b21 rc4e0b47  
    5151        assert(instance);
    5252        assert(rh);
    53         int ret;
    5453
    5554        /* Allow access to root hub port registers */
    5655        assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT <= size);
    5756        port_status_t *regs;
    58         ret = pio_enable(addr, size, (void**)&regs);
     57        int ret = pio_enable(addr, size, (void**)&regs);
    5958        if (ret < 0) {
    6059                usb_log_error(
     
    8483 *
    8584 * @param[in] instance Root hub structure to use.
    86  * @return Error code.
    8785 */
    88 int uhci_root_hub_fini(uhci_root_hub_t* instance)
     86void uhci_root_hub_fini(uhci_root_hub_t* instance)
    8987{
    9088        assert(instance);
     
    9391                uhci_port_fini(&instance->ports[i]);
    9492        }
    95         return EOK;
    9693}
    9794/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-rhd/root_hub.h

    rc593b21 rc4e0b47  
    5050  uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh);
    5151
    52 int uhci_root_hub_fini(uhci_root_hub_t *instance);
     52void uhci_root_hub_fini(uhci_root_hub_t *instance);
    5353#endif
    5454/**
  • uspace/srv/hw/irc/apic/apic.c

    rc593b21 rc4e0b47  
    8787                        async_answer_0(callid, EOK);
    8888                        break;
     89                case IPC_M_PHONE_HUNGUP:
     90                        /* The other side has hung up. */
     91                        async_answer_0(callid, EOK);
     92                        return;
    8993                default:
    9094                        async_answer_0(callid, EINVAL);
  • uspace/srv/hw/irc/i8259/i8259.c

    rc593b21 rc4e0b47  
    121121                        async_answer_0(callid, EOK);
    122122                        break;
     123                case IPC_M_PHONE_HUNGUP:
     124                        /* The other side has hung up. */
     125                        async_answer_0(callid, EOK);
     126                        return;
    123127                default:
    124128                        async_answer_0(callid, EINVAL);
Note: See TracChangeset for help on using the changeset viewer.