void uv_inject(page_desc_t *pd, page_desc_t *pdbegin, page_desc_t *pdend, unsigned long pages, unsigned long addr, unsigned long addrend, unsigned int pagesize, unsigned long mattr, unsigned long nodeid, unsigned long paddr, char *pte_str, unsigned long nodeid_start, unsigned long mattr_start, unsigned long addr_start, int mce_opt) { int count = 0; eid.cpu = sched_getcpu(); for (pd=pdbegin, pdend=pd+pages; pd<pdend && addr < addrend; pd++, addr += pagesize) { if (pd->flags & PD_HOLE) { pagesize = pd->pte; mattr = 0; nodeid = -1; } else { nodeid = get_pnodeid(*pd); paddr = get_paddr(*pd); if (nodeid == INVALID_NODE) nodeid = 0; mattr = get_memory_attr(*pd); pagesize = get_pagesize(*pd); if (mattr && paddr) { if ((pd_total / 2) == count){ sprintf(pte_str, " 0x%016lx ", pd->pte); printf("\t[%012lx] -> 0x%012lx on %s %3s %s%s\n", addr, paddr, idstr(), nodestr(nodeid), pte_str, get_memory_attr_str(nodeid, mattr)); /* Setting value at memory location for recovery * before injecting. */ memset((void *)addr, 'A', pagesize); injecteddata = (char *)addr; printf("Data:%x\n",*injecteddata); eid.addr = paddr; eid.cpu = nodeid; break;//only allow once for now } } } count++; } if (delay){ printf("Enter char to inject.."); getchar(); } if(!manual){ inject_uc(eid.addr, 0 /*int notrigger*/); } }
void SynchroniseDateTime(struct mbn_handler *mbn, time_t time) { struct timeval tv; tv.tv_usec = 0; tv.tv_sec = time; settimeofday(&tv, NULL); /* Neither POSIX nor Linux provide a nice API to do this, so run hwclock instead * NOTE: this command can block a few seconds */ system("/sbin/hwclock --systohc"); log_write("Setting system time to %ld, request from %s\n", time, nodestr(mbn)); }
int ReceiveMessage(struct mbn_handler *mbn, struct mbn_message *msg) { struct mbn_handler *dest = NULL; int i; /* don't forward anything that's targeted to us */ if(msg->AddressTo == this_node.MambaNetAddr) return 0; /* figure out to which interface we need to send */ if(msg->AddressTo != MBN_BROADCAST_ADDRESS) { if(can != NULL && mbnNodeStatus(can, msg->AddressTo) != NULL) dest = can; else if(eth != NULL && mbnNodeStatus(eth, msg->AddressTo) != NULL) dest = eth; else if(tcp != NULL && mbnNodeStatus(tcp, msg->AddressTo) != NULL) dest = tcp; else if(udp != NULL && mbnNodeStatus(udp, msg->AddressTo) != NULL) dest = udp; else if(unx != NULL && mbnNodeStatus(unx, msg->AddressTo) != NULL) dest = unx; /* don't forward if the destination is on the same network, except for unx (unix sockets and tcp?) */ if((dest == mbn) && ((dest != unx) && (dest != udp))) return 0; } /* print out what's happening */ if(verbose) { printf(" %s %1X %08lX %08lX %03X %1X:", nodestr(mbn), msg->AcknowledgeReply, msg->AddressTo, msg->AddressFrom, msg->MessageID, msg->MessageType); for(i=0;i<msg->bufferlength;i++) printf(" %02X", msg->buffer[i]); printf("\n"); } /* forward message */ #define fwd(m) mbnSendMessage(m, msg, MBN_SEND_IGNOREVALID | MBN_SEND_FORCEADDR | MBN_SEND_NOCREATE | MBN_SEND_FORCEID) if(dest != NULL) fwd(dest); else { if(eth != NULL && mbn != eth) fwd(eth); if(tcp != NULL && mbn != tcp) fwd(tcp); if(udp != NULL && mbn != udp) fwd(udp); if(can != NULL && mbn != can) { /* filter out address reservation packets to can */ if(!(dest == NULL && msg->MessageType == MBN_MSGTYPE_ADDRESS && msg->Message.Address.Action == MBN_ADDR_ACTION_INFO)) fwd(can); } if(unx != NULL && mbn != unx) fwd(unx); } #undef fwd return 0; }
void OnlineStatus(struct mbn_handler *mbn, unsigned long addr, char valid) { if(verbose) printf("OnlineStatus on %s: %08lX %s\n", nodestr(mbn), addr, valid ? "validated" : "invalid"); if(valid) { if(can != NULL && mbn != can) mbnForceAddress(can, addr); if(unx != NULL && mbn != unx) mbnForceAddress(unx, addr); if(eth != NULL && mbn != eth) mbnForceAddress(eth, addr); if(tcp != NULL && mbn != tcp) mbnForceAddress(tcp, addr); if(udp != NULL && mbn != udp) mbnForceAddress(udp, addr); } this_node.MambaNetAddr = addr; }
/* Outputs a node in indented tree form. This is * not a full serialization, but mainly an aid for * understanding and debugging. */ static void outnode(Node *n, FILE *fd, int depth) { size_t i; char *ty; int tid; indent(fd, depth); if (!n) { fprintf(fd, "Nil\n"); return; } fprintf(fd, "%s", nodestr(n->type)); switch(n->type) { case Nfile: fprintf(fd, "(name = %s)\n", n->file.name); indent(fd, depth + 1); fprintf(fd, "Globls:\n"); outstab(n->file.globls, fd, depth + 2); indent(fd, depth + 1); fprintf(fd, "Exports:\n"); outstab(n->file.exports, fd, depth + 2); for (i = 0; i < n->file.nuses; i++) outnode(n->file.uses[i], fd, depth + 1); for (i = 0; i < n->file.nstmts; i++) outnode(n->file.stmts[i], fd, depth + 1); break; case Ndecl: fprintf(fd, "(did = %zd, isconst = %d, isgeneric = %d, isextern = %d, vis = %d)\n", n->decl.did, n->decl.isconst, n->decl.isgeneric, n->decl.isextern, n->decl.vis); outsym(n, fd, depth + 1); outnode(n->decl.init, fd, depth + 1); break; case Nblock: fprintf(fd, "\n"); outstab(n->block.scope, fd, depth + 1); for (i = 0; i < n->block.nstmts; i++) outnode(n->block.stmts[i], fd, depth+1); break; case Nifstmt: fprintf(fd, "\n"); outnode(n->ifstmt.cond, fd, depth+1); outnode(n->ifstmt.iftrue, fd, depth+1); outnode(n->ifstmt.iffalse, fd, depth+1); break; case Nloopstmt: fprintf(fd, "\n"); outnode(n->loopstmt.init, fd, depth+1); outnode(n->loopstmt.cond, fd, depth+1); outnode(n->loopstmt.step, fd, depth+1); outnode(n->loopstmt.body, fd, depth+1); break; case Niterstmt: fprintf(fd, "\n"); outnode(n->iterstmt.elt, fd, depth+1); outnode(n->iterstmt.seq, fd, depth+1); outnode(n->iterstmt.body, fd, depth+1); break; case Nmatchstmt: fprintf(fd, "\n"); outnode(n->matchstmt.val, fd, depth+1); for (i = 0; i < n->matchstmt.nmatches; i++) outnode(n->matchstmt.matches[i], fd, depth+1); break; case Nmatch: fprintf(fd, "\n"); outnode(n->match.pat, fd, depth+1); outnode(n->match.block, fd, depth+1); break; case Nuse: fprintf(fd, " (name = %s, islocal = %d)\n", n->use.name, n->use.islocal); break; case Nexpr: if (exprop(n) == Ovar) assert(decls[n->expr.did]->decl.did == n->expr.did); ty = tystr(n->expr.type); if (n->expr.type) tid = n->expr.type->tid; else tid = -1; fprintf(fd, " (type = %s [tid %d], op = %s, isconst = %d, did=%zd)\n", ty, tid, opstr(n->expr.op), n->expr.isconst, n->expr.did); free(ty); outnode(n->expr.idx, fd, depth + 1); for (i = 0; i < n->expr.nargs; i++) outnode(n->expr.args[i], fd, depth+1); break; case Nlit: switch (n->lit.littype) { case Lchr: fprintf(fd, " Lchr %c\n", n->lit.chrval); break; case Lbool: fprintf(fd, " Lbool %s\n", n->lit.boolval ? "true" : "false"); break; case Lint: fprintf(fd, " Lint %llu\n", n->lit.intval); break; case Lflt: fprintf(fd, " Lflt %lf\n", n->lit.fltval); break; case Lstr: fprintf(fd, " Lstr %s\n", n->lit.strval); break; case Llbl: fprintf(fd, " Llbl %s\n", n->lit.lblval); break; case Lfunc: fprintf(fd, " Lfunc\n"); outnode(n->lit.fnval, fd, depth+1); break; } break; case Nfunc: fprintf(fd, " (args =\n"); for (i = 0; i < n->func.nargs; i++) outnode(n->func.args[i], fd, depth+1); indent(fd, depth); fprintf(fd, ")\n"); outstab(n->func.scope, fd, depth + 1); outnode(n->func.body, fd, depth+1); break; case Nname: fprintf(fd, "("); if (n->name.ns) fprintf(fd, "%s.", n->name.ns); fprintf(fd, "%s", n->name.name); fprintf(fd, ")\n"); break; case Ntrait: fprintf(fd, "Trait definition"); break; case Nnone: fprintf(stderr, "Nnone not a real node type!"); fprintf(fd, "Nnone\n"); break; } }
void Error(struct mbn_handler *mbn, int code, char *msg) { if(verbose) printf("Error(%s, %d, \"%s\")\n", nodestr(mbn), code, msg); }