Changeset 41ef5b9 in mainline for uspace/drv/usbflbk/main.c
- Timestamp:
- 2011-03-21T17:16:10Z (14 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbflbk/main.c
rfd9f6e4c r41ef5b9 1 1 /* 2 * Copyright (c) 2011 Jan Vesely2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbohcihc 28 29 /** @addtogroup drvusbfallback 29 30 * @{ 30 31 */ 31 /** @file 32 * @brief OHCI Host controller driver routines 32 /** 33 * @file 34 * Main routines of USB fallback driver. 33 35 */ 36 #include <usb/devdrv.h> 37 #include <usb/debug.h> 34 38 #include <errno.h> 35 39 #include <str_error.h> 36 #include <adt/list.h>37 #include <libarch/ddi.h>38 40 39 #include <usb/debug.h> 40 #include <usb/usb.h> 41 #include <usb/ddfiface.h> 42 #include <usb_iface.h> 41 #define NAME "usbflbk" 43 42 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 */ 48 static int usbfallback_add_device(usb_device_t *dev) 49 { 50 int rc; 51 const char *fun_name = "ctl"; 45 52 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; 54 58 } 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 } 58 65 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); 59 70 60 ohci_rh_init(&instance->rh, instance->registers);61 /* TODO: implement */62 /* TODO: register root hub */63 71 return EOK; 64 72 } 65 /*----------------------------------------------------------------------------*/ 66 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch) 73 74 /** USB fallback driver ops. */ 75 static usb_driver_ops_t usbfallback_driver_ops = { 76 .add_device = usbfallback_add_device, 77 }; 78 79 /** USB fallback driver. */ 80 static usb_driver_t usbfallback_driver = { 81 .name = NAME, 82 .ops = &usbfallback_driver_ops, 83 .endpoints = NULL 84 }; 85 86 int main(int argc, char *argv[]) 67 87 { 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); 76 91 } 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 85 93 /** 86 94 * @}
Note:
See TracChangeset
for help on using the changeset viewer.