Changeset 36a4738 in mainline for uspace/drv/uhci-hcd/main.c


Ignore:
Timestamp:
2011-02-16T21:30:43Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
30a4301
Parents:
9013ad3
Message:

Add interrupt registration and debug

File:
1 edited

Legend:

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

    r9013ad3 r36a4738  
    4646#define NAME "uhci-hcd"
    4747
     48static int uhci_add_device(device_t *device);
     49static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle);
     50/*----------------------------------------------------------------------------*/
    4851static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    4952{
     
    5457        return EOK;
    5558}
    56 
     59/*----------------------------------------------------------------------------*/
    5760static usb_iface_t hc_usb_iface = {
    5861        .get_hc_handle = usb_iface_get_hc_handle
    5962};
    60 
     63/*----------------------------------------------------------------------------*/
    6164static device_ops_t uhci_ops = {
    6265        .interfaces[USB_DEV_IFACE] = &hc_usb_iface,
    6366        .interfaces[USBHC_DEV_IFACE] = &uhci_iface
    6467};
    65 
     68/*----------------------------------------------------------------------------*/
     69static driver_ops_t uhci_driver_ops = {
     70        .add_device = uhci_add_device,
     71};
     72/*----------------------------------------------------------------------------*/
     73static driver_t uhci_driver = {
     74        .name = NAME,
     75        .driver_ops = &uhci_driver_ops
     76};
     77/*----------------------------------------------------------------------------*/
     78static void irq_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *call)
     79{
     80        usb_log_error("LOL interrupt %x %x.\n", iid, call);
     81}
     82/*----------------------------------------------------------------------------*/
    6683static int uhci_add_device(device_t *device)
    6784{
     
    7592        int irq;
    7693
    77         int rc = pci_get_my_registers(device,
     94        int ret = pci_get_my_registers(device,
    7895            &io_reg_base, &io_reg_size, &irq);
    7996
    80         if (rc != EOK) {
     97        if (ret != EOK) {
    8198                usb_log_error("Failed(%d) to get I/O registers addresses for device:.\n",
    82                     rc, device->handle);
    83                 return rc;
     99                    ret, device->handle);
     100                return ret;
    84101        }
    85102
     
    89106        uhci_t *uhci_hc = malloc(sizeof(uhci_t));
    90107        if (!uhci_hc) {
    91                 usb_log_error("Failed to allocaete memory for uhci hcd driver.\n");
     108                usb_log_error("Failed to allocate memory for uhci hcd driver.\n");
    92109                return ENOMEM;
    93110        }
    94111
    95         int ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
     112        ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
    96113        if (ret != EOK) {
    97114                usb_log_error("Failed to init uhci-hcd.\n");
     
    100117        device_t *rh;
    101118        ret = setup_root_hub(&rh, device);
    102 
    103119        if (ret != EOK) {
    104120                usb_log_error("Failed to setup uhci root hub.\n");
     
    116132        device->driver_data = uhci_hc;
    117133
     134        ret = register_interrupt_handler(device, irq, irq_handler, NULL);
     135        usb_log_error("registered interrupt handler %d.\n", ret);
     136
    118137        return EOK;
    119138}
    120 
    121 static driver_ops_t uhci_driver_ops = {
    122         .add_device = uhci_add_device,
    123 };
    124 
    125 static driver_t uhci_driver = {
    126         .name = NAME,
    127         .driver_ops = &uhci_driver_ops
    128 };
    129 
     139/*----------------------------------------------------------------------------*/
    130140int main(int argc, char *argv[])
    131141{
    132         /*
    133          * Do some global initializations.
    134          */
    135         sleep(5);
    136         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     142        sleep(3);
     143        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    137144
    138145        return driver_main(&uhci_driver);
Note: See TracChangeset for help on using the changeset viewer.