void Hub::sendMessage(const Message *message, const Stream* sourceStream) { // dump if requested if (dump) { dumpTime(cout, rawTime); message->dump(wcout); cout << std::endl; } // Called from the dbus thread, not the Hub thread, need to lock lock(); // write on all connected streams for (StreamsSet::iterator it = dataStreams.begin(); it != dataStreams.end();++it) { Stream* destStream(*it); if ((forward) && (destStream == sourceStream)) continue; try { message->serialize(destStream); destStream->flush(); } catch (DashelException e) { // if this stream has a problem, ignore it for now, and let Hub call connectionClosed later. std::cerr << "error while writing message" << std::endl; } } unlock(); }
/* * Load an endpoint's FIFO */ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) { void __iomem *fifo; if(mtk_musb->is_host) fifo = hw_ep->fifo; else fifo = mtk_musb->mregs + MUSB_FIFO_OFFSET(hw_ep->ep_in.current_epnum); prefetch((u8 *)src); DBG(4, "%cX ep%d fifo %p count %d buf %p\n", 'T', hw_ep->epnum, fifo, len, src); /* we can't assume unaligned reads work */ if (likely((0x01 & (unsigned long) src) == 0)) { u16 index = 0; /* best case is 32bit-aligned source address */ if ((0x02 & (unsigned long) src) == 0) { if (len >= 4) { writesl(fifo, src + index, len >> 2); index += len & ~0x03; } if (len & 0x02) { dumpTime(funcWritew, 0); musb_writew(fifo, 0, *(u16 *)&src[index]); index += 2; } } else {
void Hub::connectionCreated(Stream *stream) { if (verbose) { dumpTime(cout, rawTime); cout << "Incoming connection from " << stream->getTargetName() << endl; } }
/* * Tries to start B-device HNP negotiation if enabled via sysfs */ static inline void musb_try_b_hnp_enable(struct musb *musb) { void __iomem *mbase = musb->mregs; u8 devctl; DBG(1, "HNP: Setting HR\n"); devctl = musb_readb(mbase, MUSB_DEVCTL); dumpTime(funcWriteb, 0); musb_writeb(mbase, MUSB_DEVCTL, devctl | MUSB_DEVCTL_HR); }
void Hub::connectionClosed(Stream* stream, bool abnormal) { if (verbose) { dumpTime(cout); if (abnormal) cout << "Abnormal connection closed to " << stream->getTargetName() << " : " << stream->getFailReason() << endl; else cout << "Normal connection closed to " << stream->getTargetName() << endl; } }
static void musb_id_pin_work(struct work_struct *data) { //bool is_ready = mtk_musb->is_ready; //u8 opstate = 0; down(&mtk_musb->musb_lock); DBG(0, "work start, is_host=%d\n", mtk_musb->is_host); if(mtk_musb->in_ipo_off) { DBG(0, "do nothing due to in_ipo_off\n"); goto out; } //mtk_musb->is_ready = FALSE; mtk_musb ->is_host = musb_is_host(); DBG(0,"musb is as %s\n",mtk_musb->is_host?"host":"device"); switch_set_state((struct switch_dev *)&otg_state,mtk_musb->is_host); if(mtk_musb ->is_host) { //setup fifo for host mode ep_config_from_table_for_host(mtk_musb); wake_lock(&mtk_musb->usb_lock); ignore_vbuserr = false; musb_set_vbus(mtk_musb,true); musb_start(mtk_musb); switch_int_to_device(); } else { DBG(0,"devctl is %x\n",musb_readb(mtk_musb->mregs,MUSB_DEVCTL)); dumpTime(funcWriteb, 0); musb_writeb(mtk_musb->mregs,MUSB_DEVCTL,0); wake_unlock(&mtk_musb->usb_lock); musb_set_vbus(mtk_musb,FALSE); /* opstate = musb_readb(mtk_musb->mregs,MUSB_OPSTATE); while(opstate != OTG_IDLE) { msleep(10); DBG(1,"wait OTG enter IDLE,opstate is %d\n",opstate); opstate = musb_readb(mtk_musb->mregs,MUSB_OPSTATE); } */ DBG(0,"musb_stop is called\n"); //switch_int_to_host(); // move to musb_stop musb_stop(mtk_musb); } //mtk_musb->is_ready = is_ready; out: DBG(0, "work end, is_host=%d\n", mtk_musb->is_host); up(&mtk_musb->musb_lock); }
static void dumpHeader() { static bool fullOnce = false; QmcMetric *metric; bool instFlag = false; QString noneStr = "none"; QString srcStr = "Source"; QString metricStr = "Metric"; QString instStr = "Inst"; QString normStr = "Normal"; QString unitStr = "Units"; QString columnStr = "Column"; const char *timeStr; int m; int i; int c; int v; int p; int len = 0; if (niceFlag) { struct timeval pos = { 0, 0 }; timeStr = dumpTime(pos); len = strlen(timeStr); } if (fullFlag) { fullOnce = true; for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; for (i = 0; i < metric->numValues(); i++, v++) { cout << '[' << qSetFieldWidth(2) << v << qSetFieldWidth(0) << "] " << metric->spec(sourceFlag, true, i) << endl; } } cout << endl; } if (fullOnce) { if (timeFlag) { if (len < columnStr.length()) { columnStr.remove(len, columnStr.length() - len); } cout << qSetFieldWidth(len) << columnStr << qSetFieldWidth(0) << delimiter; } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; for (i = 0; i < metric->numValues(); i++) { cout << qSetFieldWidth(width) << v << qSetFieldWidth(0); if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } if (niceFlag && sourceFlag) { if (timeFlag) { if (len < srcStr.length()) { srcStr.remove(len, srcStr.length() - len); } cout << qSetFieldWidth(len) << srcStr << qSetFieldWidth(0) << delimiter; } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; QString const& str = metric->context()->source().host(); strncpy(buffer, (const char *)str.toAscii(), width); buffer[width] = '\0'; for (i = 0; i < metric->numValues(); i++) { cout << qSetFieldWidth(width) << buffer << qSetFieldWidth(0); if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } if (metricFlag || (sourceFlag && !niceFlag)) { if (timeFlag) { if (niceFlag) { if (len < metricStr.length()) { metricStr.remove(len, metricStr.length() - len); } cout << qSetFieldWidth(len) << metricStr << qSetFieldWidth(0); cout << delimiter; } else cout << "Time" << delimiter; } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; if (niceFlag && !instFlag && metric->hasInstances()) instFlag = true; for (i = 0; i < metric->numValues(); i++) { if (niceFlag) { QString const &str = metric->spec(false, false, i); p = str.length() - width; if (p > 0) { for (c = (p - 1 > 0 ? p - 1 : 0); c < str.length(); c++) { if (str[c] == '.') { c++; break; } } if (c < str.length()) cout << qSetFieldWidth(width) << ((const char *)str.toAscii() + c) << qSetFieldWidth(0); else cout << qSetFieldWidth(width) << ((const char *)str.toAscii() + p) << qSetFieldWidth(0); } else { cout << qSetFieldWidth(width) << str << qSetFieldWidth(0); } } else cout << metric->spec(sourceFlag, true, i); if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } if (instFlag) { if (timeFlag) { if (niceFlag) { if (len < instStr.length()) { instStr.remove(len, instStr.length() - len); } cout << qSetFieldWidth(len) << instStr << qSetFieldWidth(0) << delimiter; } else { cout << qSetFieldWidth(len) << errStr << qSetFieldWidth(0) << delimiter; } } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; for (i = 0; i < metric->numValues(); i++) { if (metric->hasInstances()) { QString const &str = metric->instName(i); strncpy(buffer, (const char *)str.toAscii(), width); buffer[width] = '\0'; cout << qSetFieldWidth(width) << buffer << qSetFieldWidth(0); } else cout << qSetFieldWidth(width) << "n/a" << qSetFieldWidth(0); if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } if (normFlag) { if (timeFlag) { if (niceFlag) { if (len < normStr.length()) { normStr.remove(len, normStr.length() - len); } cout << qSetFieldWidth(len) << normStr << qSetFieldWidth(0) << delimiter; } else cout << errStr << delimiter; } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; for (i = 0; i < metric->numValues(); i++) { if (shortFlag) cout << qSetRealNumberPrecision(precision) << qSetFieldWidth(width) << metric->scale() << qSetFieldWidth(0); else if (descFlag) cout << qSetFieldWidth(width) << QmcMetric::formatNumber(metric->scale()) << qSetFieldWidth(0); else cout << fixed << qSetRealNumberPrecision(precision) << qSetFieldWidth(width) << metric->scale() << qSetFieldWidth(0); if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } if (unitFlag) { if (timeFlag) { if (niceFlag) { if (len < unitStr.length()) { unitStr.remove(len, unitStr.length() - len); } cout << qSetFieldWidth(len) << unitStr << qSetFieldWidth(0) << delimiter; } else cout << noneStr << delimiter; } for (m = 0, v = 1; m < metrics.size(); m++) { metric = metrics[m]; QString const &str = (niceFlag ? metric->desc().shortUnits() : metric->desc().units()); for (i = 0; i < metric->numValues(); i++) { if (niceFlag) if (str.length() > width) cout << qSetFieldWidth(width) << ((const char *)str.toAscii() + str.length() - width) << qSetFieldWidth(0); else cout << qSetFieldWidth(width) << str << qSetFieldWidth(0); else cout << str; if (v < numValues) { cout << delimiter; v++; } } } cout << endl; } }