static void hd_out(struct hd_i_struct *disk, unsigned int nsect, unsigned int sect, unsigned int head, unsigned int cyl, unsigned int cmd, void (*intr_addr)(void)) { unsigned short port; #if (HD_DELAY > 0) while (read_timer() - last_req < HD_DELAY) /* nothing */; #endif if (reset) return; if (!controller_ready(disk->unit, head)) { reset = 1; return; } SET_HANDLER(intr_addr); outb_p(disk->ctl,HD_CMD); port=HD_DATA; outb_p(disk->wpcom>>2,++port); outb_p(nsect,++port); outb_p(sect,++port); outb_p(cyl,++port); outb_p(cyl>>8,++port); outb_p(0xA0|(disk->unit<<4)|head,++port); outb_p(cmd,++port); }
static void write_intr(void) { struct request *req = hd_req; int i; int retries = 100000; do { i = (unsigned) inb_p(HD_STATUS); if (i & BUSY_STAT) continue; if (!OK_STATUS(i)) break; if ((blk_rq_sectors(req) <= 1) || (i & DRQ_STAT)) goto ok_to_write; } while (--retries > 0); dump_status("write_intr", i); bad_rw_intr(); hd_request(); return; ok_to_write: if (hd_end_request(0, 512)) { SET_HANDLER(&write_intr); outsw(HD_DATA, req->buffer, 256); return; } #if (HD_DELAY > 0) last_req = read_timer(); #endif hd_request(); }
// Set up handlers for a oneof field. static void add_handlers_for_oneof_field(upb_handlers *h, const upb_fielddef *f, size_t offset, size_t oneof_case_offset) { upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; upb_handlerattr_sethandlerdata( &attr, newoneofhandlerdata(h, offset, oneof_case_offset, f)); switch (upb_fielddef_type(f)) { #define SET_HANDLER(utype, ltype) \ case utype: \ upb_handlers_set##ltype(h, f, oneof##ltype##_handler, &attr); \ break; SET_HANDLER(UPB_TYPE_BOOL, bool); SET_HANDLER(UPB_TYPE_INT32, int32); SET_HANDLER(UPB_TYPE_UINT32, uint32); SET_HANDLER(UPB_TYPE_ENUM, int32); SET_HANDLER(UPB_TYPE_FLOAT, float); SET_HANDLER(UPB_TYPE_INT64, int64); SET_HANDLER(UPB_TYPE_UINT64, uint64); SET_HANDLER(UPB_TYPE_DOUBLE, double); #undef SET_HANDLER case UPB_TYPE_STRING: case UPB_TYPE_BYTES: { bool is_bytes = upb_fielddef_type(f) == UPB_TYPE_BYTES; upb_handlers_setstartstr(h, f, is_bytes ? oneofbytes_handler : oneofstr_handler, &attr); upb_handlers_setstring(h, f, stringdata_handler, NULL); break; } case UPB_TYPE_MESSAGE: { upb_handlers_setstartsubmsg(h, f, oneofsubmsg_handler, &attr); break; } } upb_handlerattr_uninit(&attr); }
NetTesterSM(ProxyMutex *_mutex, NetVConnection *_vc) : Continuation(_mutex) { MUTEX_TRY_LOCK(lock, mutex, _vc->thread); ink_release_assert(lock); vc = _vc; Debug("net_test", "Accepted a connection"); SET_HANDLER(&NetTesterSM::handle_read); req_buf = new_MIOBuffer(1); reader = req_buf->alloc_reader(); read_vio = vc->do_io_read(this, INT64_MAX, req_buf); // vc->set_inactivity_timeout(HRTIME_SECONDS(60)); resp_buf = new_empty_MIOBuffer(6); resp_buf->append_block(resp_blk->clone()); req_len = 0; resp_reader = resp_buf->alloc_reader(); }
static void read_intr(void) { struct request *req; int i, retries = 100000; do { i = (unsigned) inb_p(HD_STATUS); if (i & BUSY_STAT) continue; if (!OK_STATUS(i)) break; if (i & DRQ_STAT) goto ok_to_read; } while (--retries > 0); dump_status("read_intr", i); bad_rw_intr(); hd_request(); return; ok_to_read: req = CURRENT; insw(HD_DATA,req->buffer,256); req->sector++; req->buffer += 512; req->errors = 0; i = --req->nr_sectors; --req->current_nr_sectors; #ifdef DEBUG printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", req->rq_disk->disk_name, req->sector, req->nr_sectors, req->buffer+512); #endif if (req->current_nr_sectors <= 0) end_request(req, 1); if (i > 0) { SET_HANDLER(&read_intr); return; } (void) inb_p(HD_STATUS); #if (HD_DELAY > 0) last_req = read_timer(); #endif if (elv_next_request(QUEUE)) hd_request(); return; }
int handle_read(int event, void *data) { int r; char *str; switch (event) { case VC_EVENT_READ_READY: r = reader->read_avail(); reader->read(&request[req_len], r); req_len += r; request[req_len] = 0; Debug("net_test", "%s\n", request); fflush(stdout); // vc->set_inactivity_timeout(HRTIME_SECONDS(30)); if (strcmp(&request[req_len - 4], "\r\n\r\n") == 0) { Debug("net_test", "The request header is :\n%s\n", request); // parse and get the doc size SET_HANDLER(&NetTesterSM::handle_write); ink_assert(doc_len == resp_reader->read_avail()); vc->do_io_write(this, doc_len, resp_reader); // vc->set_inactivity_timeout(HRTIME_SECONDS(10)); } break; case VC_EVENT_READ_COMPLETE: /* FALLSTHROUGH */ case VC_EVENT_EOS: r = reader->read_avail(); str = new char[r + 10]; reader->read(str, r); Debug("net_test", "%s", str); fflush(stdout); case VC_EVENT_ERROR: case VC_EVENT_INACTIVITY_TIMEOUT: vc->do_io_close(); // fixme // handle timeout events break; default: ink_release_assert(!"unknown event"); } return EVENT_CONT; }
static void write_intr(void) { struct request *req = CURRENT; int i; int retries = 100000; do { i = (unsigned) inb_p(HD_STATUS); if (i & BUSY_STAT) continue; if (!OK_STATUS(i)) break; if ((req->nr_sectors <= 1) || (i & DRQ_STAT)) goto ok_to_write; } while (--retries > 0); dump_status("write_intr", i); bad_rw_intr(); hd_request(); return; ok_to_write: req->sector++; i = --req->nr_sectors; --req->current_nr_sectors; req->buffer += 512; if (!i || (req->bio && req->current_nr_sectors <= 0)) end_request(req, 1); if (i > 0) { SET_HANDLER(&write_intr); outsw(HD_DATA,req->buffer,256); local_irq_enable(); } else { #if (HD_DELAY > 0) last_req = read_timer(); #endif hd_request(); } return; }
static void read_intr(void) { struct request *req; int i, retries = 100000; do { i = (unsigned) inb_p(HD_STATUS); if (i & BUSY_STAT) continue; if (!OK_STATUS(i)) break; if (i & DRQ_STAT) goto ok_to_read; } while (--retries > 0); dump_status("read_intr", i); bad_rw_intr(); hd_request(); return; ok_to_read: req = hd_req; insw(HD_DATA, req->buffer, 256); #ifdef DEBUG printk("%s: read: sector %ld, remaining = %u, buffer=%p\n", req->rq_disk->disk_name, blk_rq_pos(req) + 1, blk_rq_sectors(req) - 1, req->buffer+512); #endif if (hd_end_request(0, 512)) { SET_HANDLER(&read_intr); return; } (void) inb_p(HD_STATUS); #if (HD_DELAY > 0) last_req = read_timer(); #endif hd_request(); }
int pload (int tbl) { int c = 0, i, status; if (verbose > 0) { fprintf (stderr, "Starting %d children to load %s", children, tdefs[tbl].comment); } for (c = 0; c < children; c++) { pids[c] = SPAWN (); if (pids[c] == -1) { perror ("Child loader not created"); kill_load (); exit (-1); } else if (pids[c] == 0) /* CHILD */ { SET_HANDLER (stop_proc); verbose = 0; partial (tbl, c+1); exit (0); } else if (verbose > 0) /* PARENT */ fprintf (stderr, "."); } if (verbose > 0) fprintf (stderr, "waiting..."); c = children; while (c) { i = WAIT (&status, pids[c - 1]); if (i == -1 && children) { if (errno == ECHILD) fprintf (stderr, "\nCould not wait on pid %d\n", pids[c - 1]); else if (errno == EINTR) fprintf (stderr, "\nProcess %d stopped abnormally\n", pids[c - 1]); else if (errno == EINVAL) fprintf (stderr, "\nProgram bug\n"); } if (! WIFEXITED(status)) { (void) fprintf(stderr, "\nProcess %d: ", i); if (WIFSIGNALED(status)) { (void) fprintf(stderr, "rcvd signal %d\n", WTERMSIG(status)); } else if (WIFSTOPPED(status)) { (void) fprintf(stderr, "stopped, signal %d\n", WSTOPSIG(status)); } } c--; } if (verbose > 0) fprintf (stderr, "done\n"); return (0); }
CObjectClassesHandler::CObjectClassesHandler() { #define SET_HANDLER_CLASS(STRING, CLASSNAME) handlerConstructors[STRING] = std::make_shared<CLASSNAME>; #define SET_HANDLER(STRING, TYPENAME) handlerConstructors[STRING] = std::make_shared<CDefaultObjectTypeHandler<TYPENAME>> // list of all known handlers, hardcoded for now since the only way to add new objects is via C++ code //Note: should be in sync with registerTypesMapObjectTypes function SET_HANDLER_CLASS("configurable", CRewardableConstructor); SET_HANDLER_CLASS("dwelling", CDwellingInstanceConstructor); SET_HANDLER_CLASS("hero", CHeroInstanceConstructor); SET_HANDLER_CLASS("town", CTownInstanceConstructor); SET_HANDLER_CLASS("bank", CBankInstanceConstructor); SET_HANDLER_CLASS("static", CObstacleConstructor); SET_HANDLER_CLASS("", CObstacleConstructor); SET_HANDLER("randomArtifact", CGArtifact); SET_HANDLER("randomHero", CGHeroInstance); SET_HANDLER("randomResource", CGResource); SET_HANDLER("randomTown", CGTownInstance); SET_HANDLER("randomMonster", CGCreature); SET_HANDLER("randomDwelling", CGDwelling); SET_HANDLER("generic", CGObjectInstance); SET_HANDLER("market", CGMarket); SET_HANDLER("cartographer", CCartographer); SET_HANDLER("artifact", CGArtifact); SET_HANDLER("blackMarket", CGBlackMarket); SET_HANDLER("boat", CGBoat); SET_HANDLER("bonusingObject", CGBonusingObject); SET_HANDLER("borderGate", CGBorderGate); SET_HANDLER("borderGuard", CGBorderGuard); SET_HANDLER("monster", CGCreature); SET_HANDLER("denOfThieves", CGDenOfthieves); SET_HANDLER("event", CGEvent); SET_HANDLER("garrison", CGGarrison); SET_HANDLER("heroPlaceholder", CGHeroPlaceholder); SET_HANDLER("keymaster", CGKeymasterTent); SET_HANDLER("lighthouse", CGLighthouse); SET_HANDLER("magi", CGMagi); SET_HANDLER("magicSpring", CGMagicSpring); SET_HANDLER("magicWell", CGMagicWell); SET_HANDLER("market", CGMarket); SET_HANDLER("mine", CGMine); SET_HANDLER("obelisk", CGObelisk); SET_HANDLER("observatory", CGObservatory); SET_HANDLER("onceVisitable", CGOnceVisitable); SET_HANDLER("pandora", CGPandoraBox); SET_HANDLER("pickable", CGPickable); SET_HANDLER("prison", CGHeroInstance); SET_HANDLER("questGuard", CGQuestGuard); SET_HANDLER("resource", CGResource); SET_HANDLER("scholar", CGScholar); SET_HANDLER("seerHut", CGSeerHut); SET_HANDLER("shipyard", CGShipyard); SET_HANDLER("shrine", CGShrine); SET_HANDLER("sign", CGSignBottle); SET_HANDLER("siren", CGSirens); SET_HANDLER("monolith", CGMonolith); SET_HANDLER("subterraneanGate", CGSubterraneanGate); SET_HANDLER("whirlpool", CGWhirlpool); SET_HANDLER("university", CGUniversity); SET_HANDLER("oncePerHero", CGVisitableOPH); SET_HANDLER("oncePerWeek", CGVisitableOPW); SET_HANDLER("witch", CGWitchHut); #undef SET_HANDLER_CLASS #undef SET_HANDLER }
Stop(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&Stop::stop); }
NetTesterAccept(ProxyMutex *_mutex) : Continuation(_mutex) { SET_HANDLER(&NetTesterAccept::handle_accept); }