📄 flash_faults.c
字号:
if (strcmp(argv[5], "PKT") == 0) { rp.is_vp = 0; rp.datalen = 16; } else { Tcl_AppendResult(interp, "bad packet type \"", argv[5], "\"", NULL); return TCL_ERROR; } for (i = 0; i < rp.datalen*sizeof(LL)/sizeof(unsigned); i++) if ((code = get_arg(interp, argv[11+i], dp+i, "bad data") != TCL_OK)) return code; if (InsertPacket(rn, pn, ln, &rp) == 1) return TCL_OK; Tcl_AppendResult(interp, "cannot insert packet", NULL); return TCL_ERROR;}static int cmdInsertVP(Tcl_Interp *interp, int argc, char *argv[]){ int rn=0, pn=0, ln=0; RouterPacket rp; int* hp = (int*)&rp.h; int* dp = (int*)rp.data; int* ep = (int*)&rp.errbits; int code, i; if ((code = get_arg(interp, argv[2], &rn, "bad router")) != TCL_OK || (code = get_arg(interp, argv[3], &pn, "bad port")) != TCL_OK || (code = get_arg(interp, argv[4], &ln, "bad lane")) != TCL_OK || (code = get_arg(interp, argv[6], hp+0, "bad h0")) != TCL_OK || (code = get_arg(interp, argv[7], hp+1, "bad h1")) != TCL_OK || (code = get_arg(interp, argv[8], hp+2, "bad h2")) != TCL_OK || (code = get_arg(interp, argv[9], hp+3, "bad h3")) != TCL_OK || (code = get_arg(interp, argv[10],ep, "bad errbits"))!= TCL_OK) return code; if (strcmp(argv[5], "VP") == 0) { rp.is_vp = 1; rp.datalen = 1; } else { Tcl_AppendResult(interp, "bad packet type \"", argv[5], "\"", NULL); return TCL_ERROR; } for (i = 0; i < (rp.datalen+1)*sizeof(LL)/sizeof(unsigned); i++) if ((code = get_arg(interp, argv[11+i], dp+i, "bad data") != TCL_OK)) return code; if (InsertPacket(rn, pn, ln, &rp) == 1) return TCL_OK; Tcl_AppendResult(interp, "cannot insert packet", NULL); return TCL_ERROR;}static intcmdSeverlink(Tcl_Interp *interp, int argc, char *argv[]){ char* routerName = argv[2]; char* portName = argv[3]; char* bholeStr = argv[4]; int routerNum, portNum, bhole; int code; if ((code = Tcl_GetInt(interp, routerName, &routerNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad router num \"", routerName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, portName, &portNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad port num \"", portName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, bholeStr, &bhole)) != TCL_OK) { Tcl_AppendResult(interp, "bad blackhole arg \"", bholeStr, "\"", NULL); return code; }#ifndef SOLO if (SeverLink(routerNum, portNum, bhole) != 1) { Tcl_AppendResult(interp, "couldn't sever link", NULL); return TCL_ERROR; }#endif return TCL_OK;}static intcmdBlockNode(Tcl_Interp *interp, int argc, char *argv[]){ char* nodeName = argv[2]; int nodeNum; int code; if ((code = Tcl_GetInt(interp, nodeName, &nodeNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad node num \"", nodeName, "\"", NULL); return code; } if (BlockNode(nodeNum) != 1) { Tcl_AppendResult(interp, "couldn't block node", NULL); return TCL_ERROR; } return TCL_OK;}static int cmdReroute(Tcl_Interp *interp, int argc, char *argv[]){ char *badLink = argv[2]; if (!strcmp(badLink, "top")) { BadLinkReroute(LINK_TOP); } else if (!strcmp(badLink, "bottom")) { BadLinkReroute(LINK_BOTTOM); } else if (!strcmp(badLink, "left")) { BadLinkReroute(LINK_LEFT); } else if (!strcmp(badLink, "right")) { BadLinkReroute(LINK_RIGHT); } else { Tcl_AppendResult(interp, "link \"", badLink, "\"must be top|bottom|left|right", NULL); return TCL_ERROR; } return TCL_OK;}static int cmdPowerfail(Tcl_Interp *interp, int argc, char *argv[]){ Tcl_AppendResult(interp, "router powerfail unimplemented", NULL); return TCL_ERROR;}static int cmdPacket(Tcl_Interp *interp, int argc, char *argv[]){ char* routerName = argv[2]; char* portName = argv[3]; char* laneName = argv[4]; char* packetName = argv[5]; int routerNum, portNum, laneNum, packetNum; RouterPacket rp; unsigned* pp; int i, code; static char buf[512]; unsigned dlen; if ((code = Tcl_GetInt(interp, routerName, &routerNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad router num \"", routerName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, portName, &portNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad port num \"", portName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, laneName, &laneNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad lane num \"", laneName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, packetName, &packetNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad packet num \"", packetName, "\"", NULL); return code; }#ifndef SOLO /* get all the information on this packet */ GetPacketInfo(routerNum, portNum, laneNum, packetNum, &rp); /* Shrink-wrap it, then off you go */ Tcl_AppendElement(interp, rp.is_vp ? "VP" : "PKT"); pp = (unsigned*)&rp.h; /* 2 dwords, that's 4 words */ for (i = 0; i < sizeof(rp.h)/sizeof(unsigned); i++) { sprintf(buf, "0x%08x", *(pp+i)); Tcl_AppendElement(interp, buf); } { sprintf(buf, "0x%08x", rp.errbits); Tcl_AppendElement(interp, buf); } pp = (unsigned*)rp.data; dlen = rp.datalen + (rp.is_vp ? 1 : 0); for (i = 0; i < dlen*sizeof(LL)/sizeof(unsigned); i++) { sprintf(buf, "0x%08x", *(pp+i)); Tcl_AppendElement(interp, buf); }#endif return TCL_OK;}static int cmdWatch(Tcl_Interp *interp, int argc, char *argv[]){ int routerNum, val, code; char* routerName = argv[2]; char* valName = argv[3]; if ((code = Tcl_GetInt(interp, routerName, &routerNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad router num \"", routerName, "\"", NULL); return code; } if (!strcmp(valName, "off")) { val = 0; } else if (!strcmp(valName, "on")) { val = 1; } else { Tcl_AppendResult(interp, "bad setting \"", valName, "\"", NULL); return TCL_ERROR; } switch (WatchRouter(routerNum, val)) { case ROUTERTCL_OK: return TCL_OK; case ROUTERTCL_BADROUTER: Tcl_AppendResult(interp, "router num ", routerName, " out of range", NULL); return TCL_ERROR; default: Tcl_AppendResult(interp, "unexpected return code from WatchRouter in router watch", NULL); return TCL_ERROR; }}/* note: the following is called when a new packet is received by * a router for which watch has been turned on. Lacking a better way * of passing arguments to the annotation body, this will first set * the following variables: * router_ann_routerNum * router_ann_portNum * router_ann_lane */void NotifyPacketArrived(int routerNum, int portNum, int lane){ char buf[32]; sprintf(buf, "%d", routerNum); Tcl_SetVar(TCLInterp, "router_ann_routerNum", buf, TCL_GLOBAL_ONLY); sprintf(buf, "%d", portNum); Tcl_SetVar(TCLInterp, "router_ann_portNum", buf, TCL_GLOBAL_ONLY); sprintf(buf, "%d",lane); Tcl_SetVar(TCLInterp, "router_ann_lane", buf, TCL_GLOBAL_ONLY); AnnExec(AnnFindInt("router", routerNum));}static intcmdMRoute(Tcl_Interp *interp, int argc, char *argv[]){ char* nodeName = argv[2]; int nodeNum; char* destName = argv[3]; int destNum; char* portName = argv[4]; int portNum; int code; if ((code = Tcl_GetInt(interp, nodeName, &nodeNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad node num \"", nodeName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, destName, &destNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad dest num \"", destName, "\"", NULL); return code; } if ((code = Tcl_GetInt(interp, portName, &portNum)) != TCL_OK) { Tcl_AppendResult(interp, "bad port num \"", portName, "\"", NULL); return code; } if (SetMAGICRouteBin(nodeNum, destNum, portNum) != 1) { Tcl_AppendResult(interp, "couldn't set MAGIC route table bin", NULL); return TCL_ERROR; } return TCL_OK;}#else /* USE_FLASHLITE */int LinkSymbolToRetrieveFlashFaultInit = 0;void FlashFaultInit(Tcl_Interp* interp) {}#endif /* USE_FLASHLITE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -