Changeset 7ce0fe3 in mainline


Ignore:
Timestamp:
2011-02-01T22:02:23Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
afcd86e
Parents:
993a1e1
Message:

Root ub driver uses unified debug logging and some other polishing.

Location:
uspace/drv/uhci-rhd
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/main.c

    r993a1e1 r7ce0fe3  
    2828#include <driver.h>
    2929#include <errno.h>
    30 #include <str_error.h>
     30
    3131#include <usb_iface.h>
     32#include <usb/debug.h>
    3233
    33 #include "debug.h"
    34 //#include "iface.h"
    3534#include "root_hub.h"
     35
     36#define NAME "uhci-rhd"
    3637
    3738static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    3839{
    39         /* This shall be called only for the UHCI itself. */
    4040        assert(dev);
    4141        assert(dev->driver_data);
     42        assert(handle);
     43
    4244        *handle = ((uhci_root_hub_t*)dev->driver_data)->hc_handle;
     45        usb_log_debug("Answering HC handle: %d.\n", *handle);
    4346
    4447        return EOK;
     
    5861                return ENOTSUP;
    5962
    60         uhci_print_info("%s called device %d\n", __FUNCTION__, device->handle);
     63        usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
    6164        device->ops = &uhci_rh_ops;
    6265
    6366        uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
    6467        if (!rh) {
     68                usb_log_error("Failed to allocate memory for driver instance.\n");
    6569                return ENOMEM;
    6670        }
     71
     72        /* TODO: get register values from hc */
    6773        int ret = uhci_root_hub_init(rh, (void*)0xc030, 4, device);
    6874        if (ret != EOK) {
     75                usb_log_error("Failed(%d) to initialize driver instance.\n", ret);
    6976                free(rh);
    7077                return ret;
    7178        }
     79
    7280        device->driver_data = rh;
     81        usb_log_info("Sucessfully initialized driver isntance for device:%d.\n",
     82            device->handle);
    7383        return EOK;
    7484}
     
    8595int main(int argc, char *argv[])
    8696{
    87         /*
    88          * Do some global initializations.
    89          */
    90         usb_dprintf_enable(NAME, DEBUG_LEVEL_INFO);
    91 
     97        usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
    9298        return driver_main(&uhci_rh_driver);
    9399}
  • uspace/drv/uhci-rhd/port.c

    r993a1e1 r7ce0fe3  
    11
    22#include <errno.h>
     3
    34#include <usb/usb.h>    /* usb_address_t */
    45#include <usb/usbdrv.h> /* usb_drv_*     */
     6#include <usb/debug.h>
    57
    6 #include "debug.h"
    78#include "port.h"
    89#include "port_status.h"
     
    2728        port->checker = fibril_create(uhci_port_check, port);
    2829        if (port->checker == 0) {
    29                 uhci_print_error(": failed to launch root hub fibril.");
     30                usb_log_error(": failed to launch root hub fibril.");
    3031                return ENOMEM;
    3132        }
    3233        fibril_add_ready(port->checker);
    33         uhci_print_verbose(
     34        usb_log_debug(
    3435          "Added fibril for port %d: %p.\n", number, port->checker);
    3536        return EOK;
     
    4950
    5051        while (1) {
    51                 uhci_print_verbose("Port(%d) status address %p:\n",
     52                usb_log_debug("Port(%d) status address %p:\n",
    5253                  port_instance->number, port_instance->address);
    5354
     
    5758
    5859                /* debug print */
    59                 uhci_print_info("Port(%d) status %#.4x\n",
     60                usb_log_info("Port(%d) status %#.4x\n",
    6061                  port_instance->number, port_status);
    6162                print_port_status(port_status);
     
    7980        assert(port->hc_phone);
    8081
    81         uhci_print_info("Adding new device on port %d.\n", port->number);
     82        usb_log_info("Adding new device on port %d.\n", port->number);
    8283
    8384
     
    8586        int ret = usb_drv_reserve_default_address(port->hc_phone);
    8687        if (ret != EOK) {
    87                 uhci_print_error("Failed to reserve default address.\n");
     88                usb_log_error("Failed to reserve default address.\n");
    8889                return ret;
    8990        }
     
    9293
    9394        if (usb_address <= 0) {
    94                 uhci_print_error("Recieved invalid address(%d).\n", usb_address);
     95                usb_log_error("Recieved invalid address(%d).\n", usb_address);
    9596                return usb_address;
    9697        }
     
    122123
    123124        if (ret != EOK) { /* address assigning went wrong */
    124                 uhci_print_error("Failed(%d) to assign address to the device.\n", ret);
     125                usb_log_error("Failed(%d) to assign address to the device.\n", ret);
    125126                uhci_port_set_enabled(port, false);
    126127                int release = usb_drv_release_default_address(port->hc_phone);
    127128                if (release != EOK) {
    128                         uhci_print_fatal("Failed to release default address.\n");
     129                        usb_log_error("Failed to release default address.\n");
    129130                        return release;
    130131                }
     
    135136        ret = usb_drv_release_default_address(port->hc_phone);
    136137        if (ret != EOK) {
    137                 uhci_print_fatal("Failed to release default address.\n");
     138                usb_log_error("Failed to release default address.\n");
    138139                return ret;
    139140        }
     
    146147
    147148        if (ret != EOK) { /* something went wrong */
    148                 uhci_print_error("Failed(%d) in usb_drv_register_child.\n", ret);
     149                usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret);
    149150                uhci_port_set_enabled(port, false);
    150151                return ENOMEM;
    151152        }
    152         uhci_print_info("Sucessfully added device on port(%d) address(%d).\n",
     153        usb_log_info("Sucessfully added device on port(%d) address(%d).\n",
    153154                port->number, usb_address);
    154155
     
    160161static int uhci_port_remove_device(uhci_port_t *port)
    161162{
    162         uhci_print_error("Don't know how to remove device %#x.\n",
     163        usb_log_error("Don't know how to remove device %#x.\n",
    163164                (unsigned int)port->attached_device);
    164165        uhci_port_set_enabled(port, false);
     
    182183        port_status_write(port->address, port_status);
    183184
    184         uhci_print_info("%s port %d.\n",
     185        usb_log_info("%s port %d.\n",
    185186          enabled ? "Enabled" : "Disabled", port->number);
    186187        return EOK;
  • uspace/drv/uhci-rhd/port_status.c

    r993a1e1 r7ce0fe3  
    22#include <stdio.h>
    33
    4 #include "debug.h"
     4#include <usb/debug.h>
     5
    56#include "port_status.h"
    67
     
    3031        unsigned i = 0;
    3132        for (;i < sizeof(flags)/sizeof(struct flag_name); ++i) {
    32                 uhci_print_verbose("\t%s status: %s.\n", flags[i].name,
     33                usb_log_debug("\t%s status: %s.\n", flags[i].name,
    3334                  value & flags[i].flag ? "YES" : "NO");
    3435        }
  • uspace/drv/uhci-rhd/port_status.h

    r993a1e1 r7ce0fe3  
    3535#define DRV_UHCI_TD_PORT_STATUS_H
    3636
    37 #include <libarch/ddi.h>
     37#include <libarch/ddi.h> /* pio_read and pio_write */
     38
    3839#include <stdint.h>
    3940
     
    5960
    6061static inline void port_status_write(
    61   port_status_t * address, port_status_t value)
     62  port_status_t *address, port_status_t value)
    6263        { pio_write_16(address, value); }
    6364
  • uspace/drv/uhci-rhd/root_hub.c

    r993a1e1 r7ce0fe3  
    66
    77#include <usb/usbdrv.h>
     8#include <usb/debug.h>
    89
    9 #include "debug.h"
    1010#include "root_hub.h"
    1111
     
    1818        int ret;
    1919        ret = usb_drv_find_hc(rh, &instance->hc_handle);
    20         uhci_print_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle);
     20        usb_log_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle);
    2121        if (ret != EOK) {
    2222                return ret;
     
    2727        //usb_drv_hc_connect(rh, instance->hc_handle, 0);
    2828        if (rh->parent_phone < 0) {
    29                 uhci_print_error("Failed to connect to the HC device.\n");
     29                usb_log_error("Failed to connect to the HC device.\n");
    3030                return rh->parent_phone;
    3131        }
     
    3838
    3939        if (ret < 0) {
    40                 uhci_print_error(": Failed to gain access to port registers at %p\n", regs);
     40                usb_log_error("Failed to gain access to port registers at %p\n", regs);
    4141                return ret;
    4242        }
  • uspace/drv/uhci-rhd/root_hub.h

    r993a1e1 r7ce0fe3  
    5252  uhci_root_hub_t *instance, void *addr, size_t size, device_t *rh);
    5353
    54 int uhci_root_hub_fini(uhci_root_hub_t* instance);
     54int uhci_root_hub_fini(uhci_root_hub_t *instance);
    5555#endif
    5656/**
Note: See TracChangeset for help on using the changeset viewer.