static int dbus_usb_dlrun(void *bus) { usb_info_t *usbinfo = BUS_INFO(bus, usb_info_t); void *osinfo; rdl_state_t state; int err = DBUS_OK; DBUSTRACE(("%s\n", __FUNCTION__)); if (usbinfo == NULL) return DBUS_ERR; if (USB_DEV_ISBAD(usbinfo)) return DBUS_ERR; osinfo = usbinfo->usbosl_info; ASSERT(osinfo); /* Check we are runnable */ dbus_usbos_dl_cmd(osinfo, DL_GETSTATE, &state, sizeof(rdl_state_t)); state.state = ltoh32(state.state); state.bytes = ltoh32(state.bytes); /* Start the image */ if (state.state == DL_RUNNABLE) { DBUSTRACE(("%s: Issue DL_GO\n", __FUNCTION__)); dbus_usbos_dl_cmd(osinfo, DL_GO, &state, sizeof(rdl_state_t)); /* FIX: Need this for 4326 for some reason * Same issue under both Linux/Windows */ if (usbinfo->pub->attrib.devid == TEST_CHIP) dbus_usbos_wait(osinfo, USB_DLGO_SPINWAIT); dbus_usb_resetcfg(usbinfo); /* The Donlge may go for re-enumeration. */ } else { DBUSERR(("%s: Dongle not runnable\n", __FUNCTION__)); err = DBUS_ERR; } return err; }
void * dbus_usb_attach(dbus_pub_t *pub, void *cbarg, dbus_intf_callbacks_t *cbs) { usb_info_t *usb_info; if ((g_dbusintf == NULL) || (g_dbusintf->attach == NULL)) return NULL; /* Sanity check for BUS_INFO() */ ASSERT(OFFSETOF(usb_info_t, pub) == 0); usb_info = MALLOC(pub->osh, sizeof(usb_info_t)); if (usb_info == NULL) return NULL; bzero(usb_info, sizeof(usb_info_t)); usb_info->pub = pub; usb_info->cbarg = cbarg; usb_info->cbs = cbs; usb_info->usbosl_info = (dbus_pub_t *)g_dbusintf->attach(pub, usb_info, &dbus_usb_intf_cbs); if (usb_info->usbosl_info == NULL) { MFREE(pub->osh, usb_info, sizeof(usb_info_t)); return NULL; } /* Save USB OS-specific driver entry points */ usb_info->drvintf = g_dbusintf; pub->bus = usb_info; #ifndef BCM_DNGL_EMBEDIMAGE usb_info->pub->busstate = DBUS_STATE_DL_DONE; if (dbus_usb_resetcfg(usb_info)) { return NULL; } #endif /* Return Lower layer info */ return (void *) usb_info->usbosl_info; }