Changeset 41ef5b9 in mainline for uspace/drv/usbflbk/main.c


Ignore:
Timestamp:
2011-03-21T17:16:10Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4d0c40b
Parents:
fd9f6e4c (diff), 434ef65 (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 from usb/development

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbflbk/main.c

    rfd9f6e4c r41ef5b9  
    11/*
    2  * Copyright (c) 2011 Jan Vesely
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbohcihc
     28
     29/** @addtogroup drvusbfallback
    2930 * @{
    3031 */
    31 /** @file
    32  * @brief OHCI Host controller driver routines
     32/**
     33 * @file
     34 * Main routines of USB fallback driver.
    3335 */
     36#include <usb/devdrv.h>
     37#include <usb/debug.h>
    3438#include <errno.h>
    3539#include <str_error.h>
    36 #include <adt/list.h>
    37 #include <libarch/ddi.h>
    3840
    39 #include <usb/debug.h>
    40 #include <usb/usb.h>
    41 #include <usb/ddfiface.h>
    42 #include <usb_iface.h>
     41#define NAME "usbflbk"
    4342
    44 #include "ohci_hc.h"
     43/** Callback when new device is attached and recognized by DDF.
     44 *
     45 * @param dev Representation of a generic DDF device.
     46 * @return Error code.
     47 */
     48static int usbfallback_add_device(usb_device_t *dev)
     49{
     50        int rc;
     51        const char *fun_name = "ctl";
    4552
    46 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,
    47     uintptr_t regs, size_t reg_size, bool interrupts)
    48 {
    49         assert(instance);
    50         int ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    51         if (ret != EOK) {
    52                 usb_log_error("Failed to gain access to device registers.\n");
    53                 return ret;
     53        ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed,
     54            fun_name);
     55        if (ctl_fun == NULL) {
     56                usb_log_error("Failed to create control function.\n");
     57                return ENOMEM;
    5458        }
    55         instance->registers->interrupt_disable = 0;
    56         /* enable interrupt on root hub status change */
    57         instance->registers->interupt_enable |= IE_RHSC | IE_MIE;
     59        rc = ddf_fun_bind(ctl_fun);
     60        if (rc != EOK) {
     61                usb_log_error("Failed to bind control function: %s.\n",
     62                    str_error(rc));
     63                return rc;
     64        }
    5865
     66        usb_log_info("Pretending to control %s `%s'" \
     67            " (node `%s', handle %llu).\n",
     68            dev->interface_no < 0 ? "device" : "interface",
     69            dev->ddf_dev->name, fun_name, dev->ddf_dev->handle);
    5970
    60         ohci_rh_init(&instance->rh, instance->registers);
    61         /* TODO: implement */
    62         /* TODO: register root hub */
    6371        return EOK;
    6472}
    65 /*----------------------------------------------------------------------------*/
    66 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch)
     73
     74/** USB fallback driver ops. */
     75static usb_driver_ops_t usbfallback_driver_ops = {
     76        .add_device = usbfallback_add_device,
     77};
     78
     79/** USB fallback driver. */
     80static usb_driver_t usbfallback_driver = {
     81        .name = NAME,
     82        .ops = &usbfallback_driver_ops,
     83        .endpoints = NULL
     84};
     85
     86int main(int argc, char *argv[])
    6787{
    68         assert(instance);
    69         assert(batch);
    70         if (batch->target.address == instance->rh.address) {
    71                 ohci_rh_request(&instance->rh, batch);
    72                 return EOK;
    73         }
    74         /* TODO: implement */
    75         return EOK;
     88        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     89
     90        return usb_driver_main(&usbfallback_driver);
    7691}
    77 /*----------------------------------------------------------------------------*/
    78 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status)
    79 {
    80         assert(instance);
    81         /* TODO: Check for interrupt cause */
    82         ohci_rh_interrupt(&instance->rh);
    83         /* TODO: implement */
    84 }
     92
    8593/**
    8694 * @}
Note: See TracChangeset for help on using the changeset viewer.