struct ltt_trace * find_or_add_task_trace(const char *name, int pid, int tgid) { struct tdata tdata, *ret; tdata.pid = pid; ret = tfind(&tdata, &root, compare); if (name && strcmp(name, "swapper") == 0) { name = "idle thread"; tgid = 0; } if (!ret) { struct ltt_trace *data; /* this can happen if we on the first cs from this process */ if (!name) name = "????"; //printf("insert pid %d\n", pid); data = calloc(2, sizeof(struct ltt_trace)); assert(data); ret = malloc(sizeof(struct tdata)); assert(ret); ret->pid = pid; ret->tgid = tgid; ret->data = data; ret = tsearch(ret, &root, compare); assert(ret); init_trace(&data[0], TG_PROCESS, 1.0 + (tgid<<16) + pid, TRACE_SYM_F_BITS, PROCESS_STATE, tgid, pid, name); init_trace(&data[1], /*TG_PROCESS*/0, 1.1 + (tgid<<16) + pid, TRACE_SYM_F_STRING, PROCESS_INFO, tgid, pid, name); data[0].value.state = NULL; ret = *((void**)ret); } else if (strcmp(name, "no name") != 0 && strcmp(name, "kthreadd") != 0 /* XXX */ ) { ret = *((void**)ret); if (tgid == 0 && ret->tgid != 0) { tgid = ret->tgid; } ret->tgid = tgid; refresh_name(&ret->data[0], PROCESS_STATE, tgid, pid, name); refresh_name(&ret->data[1], PROCESS_INFO, tgid, pid, name); } return ret->data; }
static struct trace *add_trace(const char *condstr, const char *file, unsigned int line, bool expect) { struct trace *trace = malloc(sizeof(*trace)); init_trace(trace, condstr, file, line, expect); htable_add(htable, hash_trace(trace), trace); return trace; }
int main(void) { uint8_t rc; uint8_t bytes; cli(); set_cpu_8mhz(); init_trace(); onewire0_init(); sei(); while (1) { toggle_b(); rc = onewire0_reset(); set_c(); onewire0_readrom(&device_id); toggle_c(); // Issue skip rom command onewire0_skiprom(); toggle_c(); // Start a temperature conversion onewire0_convert(); toggle_c(); // Setup a delay onewire0_convertdelay(); toggle_c(); // Wait until it is finished while (! onewire0_isidle()) { } toggle_c(); onewire0_reset(); toggle_c(); onewire0_skiprom(); toggle_c(); onewire0_readscratchpad(); toggle_c(); for (bytes = 0; bytes < 9; ++bytes) { onewire0_readbyte(); } toggle_c(); while (! onewire0_isidle()) { } toggle_c(); } }
InterceptorState::InterceptorState() { /* Initialize the pointers to the orginal versions of the intercepted functions */ FunctionPointers::init_fptrs(); /* Initialize the tracing */ init_trace(); }
int main(int argc, char *argv[]) { set_args args; process_args(argc, argv, &args); init_trace(args.verbose); check_file_exists(args.file); set_tsdb_values(&args); return 0; }
static void userspace_message_process(const char *modname, int pass, double clock, int cpu, void *args) { const char * str = get_arg_str(args, "message"); if (pass == 1) init_trace(&trace_g, TG_PROCESS, 0.1, TRACE_SYM_F_STRING, "user event"); if (pass == 2) emit_trace(&trace_g, (union ltt_value)"%s", str); }
/* --- */ int init_parser(int argc, char **argv) { print_welcome(); process_cla(argc, argv, 1); print_hs_1(); init_storage(); init_subrs(); init_trace(); init_slibu(); init_ss(); init_ndbm(); init_regex(); init_tar(); return 0; }
static void userspace_event_stop_process(const char *modname, int pass, double clock, int cpu, void *args) { int num = (int)get_arg_i64(args, "event_stop"); if (pass == 1) { if (num < (int)(sizeof(traces)/sizeof(traces[0])) && num >= 0) init_trace(&traces[num], TG_PROCESS, 0.1+0.1*num, TRACE_SYM_F_BITS, "user event %d", num); } if (pass == 2) { if (num < (int)(sizeof(traces)/sizeof(traces[0])) && num >= 0) { emit_trace(&traces[num], (union ltt_value)LT_IDLE); } } }
long _likely_trace(bool cond, bool expect, const char *condstr, const char *file, unsigned int line) { struct trace *p, trace; init_trace(&trace, condstr, file, line, expect); p = thash_get(&htable, &trace); if (!p) p = add_trace(&trace); p->count++; if (cond == expect) p->right++; return cond; }
static void ardupilot_end_process(const char *modname, int pass, double clock, int cpu, void *args) { const char *name = get_arg_str(args, "name_field"); struct perf_apm *perf = find_or_add_perf(name); if (pass == 1) { init_trace(&perf->trace, TG_APM, 1 + 0.1 * perf->pos, TRACE_SYM_F_BITS, "%s", name); } if (pass == 2) { emit_trace(&perf->trace, (union ltt_value)LT_IDLE); } }
void uos_init (void) { /* Configure 16 Mbyte of external Flash memory at nCS3. */ MC_CSCON3 = MC_CSCON_WS (4); /* Wait states */ /* Выделяем место для динамической памяти */ extern unsigned __bss_end[]; #ifdef ELVEES_DATA_SDRAM /* Динамическая память в SDRAM */ if (((unsigned) __bss_end & 0xF0000000) == 0x80000000) mem_init (&pool, (unsigned) __bss_end, 0x82000000); else mem_init (&pool, (unsigned) __bss_end, 0xa2000000); #else /* Динамическая память в CRAM */ extern unsigned _estack[]; mem_init (&pool, (unsigned) __bss_end, (unsigned) _estack - 256); #endif timer_init (&timer, KHZ, 20); /* * Create a group of two locks: timer and eth. */ mutex_group_t *g = mutex_group_init (group, sizeof(group)); mutex_group_add (g, ð->netif.lock); mutex_group_add (g, &timer.decisec); arp = arp_init (arp_data, sizeof(arp_data), &ip); ip_init (&ip, &pool, 70, &timer, arp, g); /* * Create interface eth0 */ const unsigned char my_macaddr[] = { 0, 9, 0x94, 0xf1, 0xf2, 0xf3 }; eth_init (eth, "eth0", 80, &pool, arp, my_macaddr); unsigned char my_ip[] = { 172, 0, 0, 18 }; route_add_netif (&ip, &route, my_ip, 24, ð->netif); h_udp_task = task_create (udp_task, 0, "udp", 65, stack_udp, sizeof (stack_udp)); init_trace(); }
long _likely_trace(bool cond, bool expect, const char *condstr, const char *file, unsigned int line) { struct trace *p, trace; if (!htable) htable = htable_new(rehash, NULL); init_trace(&trace, condstr, file, line, expect); p = htable_get(htable, hash_trace(&trace), hash_cmp, &trace); if (!p) p = add_trace(condstr, file, line, expect); p->count++; if (cond == expect) p->right++; return cond; }
/* --- */ int init_parser(int argc, char **argv) { print_welcome(); process_cla(siod_argc, siod_argv, 1); process_cla(argc, argv, 1); print_hs_1(); init_storage(); init_subrs(); init_trace(); init_slibu(); init_ss(); init_ndbm(); init_regex(); init_tar(); init_subr_0("row", get_row); init_subr_0("col", get_col); init_subr_2("exec-expr", lexec_expr); /*XtAppAddActions(app_context, actions, XtNumber(actions));*/ return register_interpreter("SIOD", NULL, execute_siod); }
static void kernel_parrot_evt_stop_process(struct ltt_module *mod, struct parse_result *res, int pass) { int id; kernel_common(res, pass); if (sscanf(res->values, " id = %d", &id) != 1) { PARSE_ERROR(mod, res->values); return; } if (pass == 1) { init_traces(); if (id < sizeof(parrot_evt_n)/sizeof(parrot_evt_n[0]) && id >= 0) init_trace(&parrot_evt_n[id], TG_PROCESS, 0.0+0.1*id, TRACE_SYM_F_BITS, "kernel event %d", id); } if (pass == 2) { emit_trace(&parrot_evt, (union ltt_value)"%d->", id); if (id < sizeof(parrot_evt_n)/sizeof(parrot_evt_n[0]) && id >= 0) emit_trace(&parrot_evt_n[id], (union ltt_value)LT_IDLE); } }
/* * Parses the command line to execute the utilities defined in samdb.h. * The command line format is: samdb command fsname opts */ int main( int argc, char **argv) { char *util_name; samdb_util_t *util; samdb_opts_t *util_opts; samdb_args_t util_args; sam_db_conf_t *db_conf; int errflg = 0; char opt; init_trace(FALSE, 0); memset(&util_args, 0, sizeof (samdb_args_t)); if (argc < 3) { samdb_usage(NULL); return (EXIT_FAILURE); } /* All commands except for help have fsname as their second parameter */ util_name = argv[1]; if (strcmp("help", util_name) == 0) { argc -= 1; argv += 1; } else { util_args.fsname = argv[2]; argc -= 2; argv += 2; } /* Find the utility to execute */ for (util = samdb_utils; util->name != NULL; util++) { if (strcmp(util_name, util->name) == 0) { break; } } if (util->name == NULL) { printf("Command '%s' not found\n", util_name); samdb_usage(NULL); return (EXIT_FAILURE); } /* Process opts. Uses the proc_opt function for each utility */ util_args.util = util; util_opts = util->getopts(); if (util_opts != NULL) { while ((opt = getopt(argc, argv, util_opts->optstr)) != -1) { switch (opt) { case ':': fprintf(stderr, "Option -%c requires an operand\n", optopt); errflg++; break; case '?': fprintf(stderr, "Unrecognized option: -%c\n", optopt); errflg++; break; default: if (util_opts->proc_opt(opt, optarg) < 0) { fprintf(stderr, "Error processing %s option -%c\n", util->name, opt); errflg++; } } } } if (errflg) { samdb_usage(&util_args); return (EXIT_FAILURE); } /* Initialize database configuration */ if (strcmp("help", util_name) != 0) { db_conf = sam_db_conf_get(SAMDB_ACCESS_FILE, util_args.fsname); if (db_conf == NULL) { fprintf(stderr, "No database configured for %s\n", util_args.fsname); return (EXIT_FAILURE); } util_args.con = sam_db_context_conf_new(db_conf); sam_db_conf_free(db_conf); } /* Populate remaining arguments and execute utility */ util_args.argc = argc - optind; util_args.argv = util_args.argc <= 0 ? NULL : &argv[optind]; if (util->exec(&util_args) < 0) { fprintf(stderr, "Error occured executing %s\n", util->name); return (EXIT_FAILURE); } return (EXIT_SUCCESS); }
/* * Initialize the daemon and database configuration. */ static int dbupd_init(int argc, char **argv) { sam_db_conf_t *db_conf; /* Check to make sure fsd started */ if (strcmp(GetParentName(), SAM_FSD) != 0) { #ifdef DEBUG is_daemon = FALSE; #else fprintf(stderr, "%s may only be started from "SAM_FSD"\n", program_name); return (-1); #endif /* DEBUG */ } /* Process args */ if (argc < 2) { fprintf(stderr, "usage: "SAM_DBUPD" fsname\n"); return (-1); } fs_name = argv[1]; init_trace(is_daemon, TI_dbupd); /* * Set up signal handling. Exit on SIGINT and SIGTERM. * sam-fsd sends a SIGHUP on a configure -- ignore it. */ signal(SIGINT, dbupd_signal); signal(SIGTERM, dbupd_signal); signal(SIGHUP, SIG_IGN); /* Change to daemon directory */ if (is_daemon) { snprintf(daemon_path, MAXPATHLEN, "%s/%s/%s/%s", SAM_VARIABLE_PATH, "fsalogd", fs_name, program_name); MakeDir(daemon_path); if (chdir(daemon_path)) { /* cannot chdir to %s */ SendCustMsg(HERE, 3038, daemon_path); exit(EXIT_FAILURE); } } else { daemon_path[0] = '\0'; } /* Create inventory path */ snprintf(fsa_path, MAXPATHLEN, "%s/%s", FSA_DEFAULT_LOG_PATH, fs_name); /* Get database config and create context */ db_conf = sam_db_conf_get(SAMDB_ACCESS_FILE, fs_name); if (db_conf == NULL) { /* Could not find fs_name in SAMDB_ACCESS_FILE */ SendCustMsg(HERE, 26000, SAMDB_ACCESS_FILE, fs_name); return (-1); } /* Create database context */ db_ctx = sam_db_context_conf_new(db_conf); if (db_ctx == NULL) { /* Could not create database context */ SendCustMsg(HERE, 26001); sam_db_conf_free(db_conf); return (-1); } sam_db_conf_free(db_conf); return (0); }
/* Naive recombination of modular factors: combine up to maxK modular * factors, degree <= klim and divisible by hint * * target = polynomial we want to factor * famod = array of modular factors. Product should be congruent to * target/lc(target) modulo p^a * For true factors: S1,S2 <= p^b, with b <= a and p^(b-a) < 2^31 */ static GEN nfcmbf(nfcmbf_t *T, GEN p, long a, long maxK, long klim) { GEN pol = T->pol, nf = T->nf, famod = T->fact, dn = T->dn; GEN bound = T->bound; GEN nfpol = gel(nf,1); long K = 1, cnt = 1, i,j,k, curdeg, lfamod = lg(famod)-1, dnf = degpol(nfpol); GEN res = cgetg(3, t_VEC); pari_sp av0 = avma; GEN pk = gpowgs(p,a), pks2 = shifti(pk,-1); GEN ind = cgetg(lfamod+1, t_VECSMALL); GEN degpol = cgetg(lfamod+1, t_VECSMALL); GEN degsofar = cgetg(lfamod+1, t_VECSMALL); GEN listmod = cgetg(lfamod+1, t_COL); GEN fa = cgetg(lfamod+1, t_COL); GEN lc = absi(leading_term(pol)), lt = is_pm1(lc)? NULL: lc; GEN C2ltpol, C = T->L->topowden, Tpk = T->L->Tpk; GEN Clt = mul_content(C, lt); GEN C2lt = mul_content(C,Clt); const double Bhigh = get_Bhigh(lfamod, dnf); trace_data _T1, _T2, *T1, *T2; pari_timer ti; TIMERstart(&ti); if (maxK < 0) maxK = lfamod-1; C2ltpol = C2lt? gmul(C2lt,pol): pol; { GEN q = ceil_safe(sqrtr(T->BS_2)); GEN t1,t2, ltdn, lt2dn; GEN trace1 = cgetg(lfamod+1, t_MAT); GEN trace2 = cgetg(lfamod+1, t_MAT); ltdn = mul_content(lt, dn); lt2dn= mul_content(ltdn, lt); for (i=1; i <= lfamod; i++) { pari_sp av = avma; GEN P = gel(famod,i); long d = degpol(P); degpol[i] = d; P += 2; t1 = gel(P,d-1);/* = - S_1 */ t2 = gsqr(t1); if (d > 1) t2 = gsub(t2, gmul2n(gel(P,d-2), 1)); /* t2 = S_2 Newton sum */ t2 = typ(t2)!=t_INT? FpX_rem(t2, Tpk, pk): modii(t2, pk); if (lt) { if (typ(t2)!=t_INT) { t1 = FpX_red(gmul(ltdn, t1), pk); t2 = FpX_red(gmul(lt2dn,t2), pk); } else { t1 = remii(mulii(ltdn, t1), pk); t2 = remii(mulii(lt2dn,t2), pk); } } gel(trace1,i) = gclone( nf_bestlift(t1, NULL, T->L) ); gel(trace2,i) = gclone( nf_bestlift(t2, NULL, T->L) ); avma = av; } T1 = init_trace(&_T1, trace1, T->L, q); T2 = init_trace(&_T2, trace2, T->L, q); for (i=1; i <= lfamod; i++) { gunclone(gel(trace1,i)); gunclone(gel(trace2,i)); } } degsofar[0] = 0; /* sentinel */ /* ind runs through strictly increasing sequences of length K, * 1 <= ind[i] <= lfamod */ nextK: if (K > maxK || 2*K > lfamod) goto END; if (DEBUGLEVEL > 3) fprintferr("\n### K = %d, %Z combinations\n", K,binomial(utoipos(lfamod), K)); setlg(ind, K+1); ind[1] = 1; i = 1; curdeg = degpol[ind[1]]; for(;;) { /* try all combinations of K factors */ for (j = i; j < K; j++) { degsofar[j] = curdeg; ind[j+1] = ind[j]+1; curdeg += degpol[ind[j+1]]; } if (curdeg <= klim && curdeg % T->hint == 0) /* trial divide */ { GEN t, y, q, list; pari_sp av; av = avma; /* d - 1 test */ if (T1) { t = get_trace(ind, T1); if (rtodbl(QuickNormL2(t,DEFAULTPREC)) > Bhigh) { if (DEBUGLEVEL>6) fprintferr("."); avma = av; goto NEXT; } } /* d - 2 test */ if (T2) { t = get_trace(ind, T2); if (rtodbl(QuickNormL2(t,DEFAULTPREC)) > Bhigh) { if (DEBUGLEVEL>3) fprintferr("|"); avma = av; goto NEXT; } } avma = av; y = lt; /* full computation */ for (i=1; i<=K; i++) { GEN q = gel(famod, ind[i]); if (y) q = gmul(y, q); y = FqX_centermod(q, Tpk, pk, pks2); } y = nf_pol_lift(y, bound, T); if (!y) { if (DEBUGLEVEL>3) fprintferr("@"); avma = av; goto NEXT; } /* try out the new combination: y is the candidate factor */ q = RgXQX_divrem(C2ltpol, y, nfpol, ONLY_DIVIDES); if (!q) { if (DEBUGLEVEL>3) fprintferr("*"); avma = av; goto NEXT; } /* found a factor */ list = cgetg(K+1, t_VEC); gel(listmod,cnt) = list; for (i=1; i<=K; i++) list[i] = famod[ind[i]]; y = Q_primpart(y); gel(fa,cnt++) = QXQX_normalize(y, nfpol); /* fix up pol */ pol = q; for (i=j=k=1; i <= lfamod; i++) { /* remove used factors */ if (j <= K && i == ind[j]) j++; else { famod[k] = famod[i]; update_trace(T1, k, i); update_trace(T2, k, i); degpol[k] = degpol[i]; k++; } } lfamod -= K; if (lfamod < 2*K) goto END; i = 1; curdeg = degpol[ind[1]]; if (C2lt) pol = Q_primpart(pol); if (lt) lt = absi(leading_term(pol)); Clt = mul_content(C, lt); C2lt = mul_content(C,Clt); C2ltpol = C2lt? gmul(C2lt,pol): pol; if (DEBUGLEVEL > 2) { fprintferr("\n"); msgTIMER(&ti, "to find factor %Z",y); fprintferr("remaining modular factor(s): %ld\n", lfamod); } continue; } NEXT: for (i = K+1;;) { if (--i == 0) { K++; goto nextK; } if (++ind[i] <= lfamod - K + i) { curdeg = degsofar[i-1] + degpol[ind[i]]; if (curdeg <= klim) break; } } } END: if (degpol(pol) > 0) { /* leftover factor */ if (signe(leading_term(pol)) < 0) pol = gneg_i(pol); if (C2lt && lfamod < 2*K) pol = QXQX_normalize(Q_primpart(pol), nfpol); setlg(famod, lfamod+1); gel(listmod,cnt) = shallowcopy(famod); gel(fa,cnt++) = pol; } if (DEBUGLEVEL>6) fprintferr("\n"); if (cnt == 2) { avma = av0; gel(res,1) = mkvec(T->pol); gel(res,2) = mkvec(T->fact); } else { setlg(listmod, cnt); setlg(fa, cnt); gel(res,1) = fa; gel(res,2) = listmod; res = gerepilecopy(av0, res); } return res; }
static void kernel_irq_entry_process(struct ltt_module *mod, struct parse_result *res, int pass) { int kernel_mode; unsigned int ip,irq; #if defined(ARCH_2_6_3X) void *handler; #endif kernel_common(res, pass); #if defined(ARCH_2_6_3X) if (sscanf(res->values, " ip = %u, handler = %p, irq_id = %u, kernel_mode = %d", &ip, &handler, &irq, &kernel_mode) != 4) { PARSE_ERROR(mod, res->values); return; } #else if (sscanf(res->values, " ip = %u, irq_id = %u, kernel_mode = %d", &ip, &irq, &kernel_mode) != 3) { PARSE_ERROR(mod, res->values); return; } #endif if (irq >= MAX_IRQS) { DIAG("invalid IRQ vector ? (%d)\n", irq); return; } if (pass == 1 && irq_tag[irq]) { init_trace(&trace[irq], TG_IRQ, 1.0+irq, TRACE_SYM_F_BITS, irq_tag[irq]); atag_store(ip); } if (pass == 2) { if (!irq_tag[irq]) { char name[20]; snprintf(name, sizeof(name), "irq %d", irq); init_trace(&trace[irq], TG_IRQ, 1.0+irq, TRACE_SYM_F_BITS, strdup(name)); } if (irqlevel >= MAX_IRQS) { DIAG("IRQ nesting level is too high (%d)\n", irqlevel); return; } if (irqlevel > 0 && irq == irqtab[irqlevel-1]) { DIAG("IRQ reentering in same irq (broken trace ?) %d\n", irqlevel); return; } if (irqlevel > 0) { TDIAG(res, "nesting irq %s -> %s\n", irq_tag[irqtab[irqlevel-1]], irq_tag[irq]); emit_trace(&trace[irqtab[irqlevel-1]], (union ltt_value)IRQ_PREEMPT); } emit_trace(&trace[irq], (union ltt_value)IRQ_RUNNING); emit_trace(&irq_pc, (union ltt_value)ip); irqtab[irqlevel++] = irq; if (irqlevel == 1) emit_cpu_idle_state(res, (union ltt_value)IDLE_CPU_PREEMPT); /* stat stuff */ #ifndef ARCH_2_6_3X if (irq == 19) { static double timer3clock; static double timer3diff; if (timer3clock > 0) { double diff = res->clock - timer3clock; if (timer3diff > 0) { /* we allow a jitter of 0,1 ms */ if (diff > timer3diff + 0.0001) { TDIAG(res, "late irq !!! system timer took %fs (instead of %fs)\n", diff, timer3diff); } } else timer3diff = diff; } timer3clock = res->clock; } #endif /* only account on the first irq */ if (irqlevel == 1) irqtime = res->clock; /* end stat stuff */ } }
int main(int argc, char **argv) { int errors = 0; int daemon = 0; int verbose = 0; #ifdef GEN_OLD_FILES char *usage = "Usage: %s [-f config_file] [-g | -t | -x | -a] [-v];\n\t where g=FlapGraph, t= FlapTableDaily, x=ASExplorer, a= all three.\n"; #else char *usage = "Usage: %s [-f config_file] [-p uii_port ] [-v] [-d]\n"; #endif GEN_OLD_FILES char *config_file = CONFIG; char *port = PORT; char c; int found_one = 0; tzset(); /* needed by my_mktime, must be before multi-thread */ appname = strdup(argv[0]); #ifdef GEN_OLD_FILES /* check if no args supplied */ if (argc == 1) { fprintf (stderr, usage, appname); printf ("\nDerived from: DataDistiller %s (MRT %s) compiled on %s\n\n", DATADSTL_VERSION, MRT_VERSION, __DATE__); exit (1); } while ((c = getopt (argc, argv, "f:gtxav")) != -1) { #else while ((c = getopt (argc, argv, "f:p:vd")) != -1) { #endif GEN_OLD_FILES switch (c) { case 'f': /* config file */ config_file = optarg; break; #ifdef GEN_OLD_FILES case 'g': /* old FlapGraph files */ if (found_one) { errors++; } else { dump_fg = 1; found_one = 1; } break; case 't': /* old FlapTableDaily files */ if (found_one) { errors++; } else { dump_ftd = 1; found_one = 1; } break; case 'x': if (found_one) { errors++; } else { dump_ase = 1; /* old ASExplorer files */ found_one = 1; } break; case 'a': /* all 3 above */ if (found_one) { errors++; } else { dump_fg = dump_ftd = dump_ase = 1; found_one = 1; } break; #else case 'p': /* uii port number */ port = optarg; break; #endif GEN_OLD_FILES case 'v': /* verbose */ verbose = 1; break; #ifndef GEN_OLD_FILES case 'd': /* set self up as daemon */ daemon = 1; break; #endif GEN_OLD_FILES default: errors++; break; } } if (errors) { fprintf (stderr, usage, appname); printf ("\nDataDistiller %s (MRT %s) compiled on %s\n\n", DATADSTL_VERSION, MRT_VERSION, __DATE__); exit (1); } default_trace = New_Trace2(appname); if (daemon) daemon_init(); if (verbose) set_trace (default_trace, TRACE_FLAGS, NORM | TR_ERROR, TRACE_LOGFILE, "stdout", NULL); /* XXX check for NULL pointers */ init_trace(appname, 0); init_mrt(default_trace); init_mrt_reboot(argc, argv); init_interfaces (default_trace); init_uii(default_trace); init_mrtd_config (default_trace); set_prompt(strrchr(appname, '/')+1); /* after init_mrtd_config so it sticks */ init_config(default_trace); init_BGP (default_trace); init_asExplorerPublisher(default_trace); start_publisher_thread(default_trace); register_command_handlers(); register_config_writers(); config_bgp_init (); config_from_file2 (default_trace, config_file); #ifdef GEN_OLD_FILES if (dump_fg) { flapGraphAndTablePublisher_FGDump(); } if (dump_ftd) { if (dump_fg) { /* if we are in dump all mode */ reinitialize_ixpinfo(); } flapGraphAndTablePublisher_FTDDump (); } if (dump_ase) { asExplorerPublisher_Dump(); } mrt_exit (0); #else publish_timer_fg = New_Timer (flapGraphAndTablePublisher_doFGUpdate, publish_interval_fg, "FlapGraph Update Timer", NULL); if (publish_interval_fg > 0) { flapGraphAndTablePublisher_doFGUpdate(); Timer_Turn_ON (publish_timer_fg); } publish_timer_ftd = New_Timer (flapGraphAndTablePublisher_doFTDUpdate, publish_interval_fg, "FlapTableDaily Update Timer", NULL); if (publish_interval_ftd > 0) { flapGraphAndTablePublisher_doFTDUpdate(); Timer_Turn_ON (publish_timer_ftd); } publish_timer_ase = New_Timer (asExplorerPublisher_doUpdate, publish_interval_ase, "ASExplorer Update Timer", NULL); if (publish_interval_ase > 0) { asExplorerPublisher_doUpdate(); Timer_Turn_ON (publish_timer_ase); } #endif GEN_OLD_FILES listen_uii2(port); mrt_main_loop(); /* not reached */ return 0; /* just to make gcc happy */ } void set_interval_fg(uii_connection_t *uii, int num_seconds) { if (num_seconds < 0) { uii_send_data (uii, "Publish interval must be non-negative.\n"); return; } publish_interval_fg = num_seconds; /* reading config file at startup -- not yet initialized */ if (publish_timer_fg == NULL) return; if (num_seconds == 0) Timer_Turn_OFF (publish_timer_fg); else { flapGraphAndTablePublisher_doFGUpdate(); Timer_Set_Time (publish_timer_fg, publish_interval_fg); Timer_Reset_Time (publish_timer_fg); /* necessary? */ Timer_Turn_ON (publish_timer_fg); } } void set_interval_ftd(uii_connection_t *uii, int num_seconds) { if (num_seconds < 0) { uii_send_data (uii, "Publish interval must be non-negative.\n"); return; } publish_interval_ftd = num_seconds; /* reading config file at startup -- not yet initialized */ if (publish_timer_ftd == NULL) return; if (num_seconds == 0) Timer_Turn_OFF (publish_timer_ftd); else { flapGraphAndTablePublisher_doFTDUpdate(); Timer_Set_Time (publish_timer_ftd, publish_interval_ftd); Timer_Reset_Time (publish_timer_ftd); /* necessary? */ Timer_Turn_ON (publish_timer_ftd); } } void set_interval_ase(uii_connection_t *uii, int num_seconds) { if (num_seconds < 0) { uii_send_data (uii, "Publish interval must be non-negative.\n"); return; } publish_interval_ase = num_seconds; /* reading config file at startup -- not yet initialized */ if (publish_timer_ase == NULL) return; if (num_seconds == 0) Timer_Turn_OFF (publish_timer_ase); else { asExplorerPublisher_doUpdate(); Timer_Set_Time (publish_timer_ase, publish_interval_ase); Timer_Reset_Time (publish_timer_ase); /* necessary? */ Timer_Turn_ON (publish_timer_ase); } } void get_interval_fg(void *ignored) { config_add_output (PARAM_FG_PUBLISH_INTERVAL " %d\r\n", publish_interval_fg); }
FrontendTester(sc_module_name nm) : sc_module(nm), uut("uut"), memInAdp("inadp"), memOutAdp("outadp"), rowIndAdp("riadp"), colLenAdp("cladp"), bfsMemory("mem") { inpVecPtr = 0; resVecPtr = MEM_WORD_COUNT / 2; uut.clk(clk); uut.reset(reset); uut.io_start(io_start); uut.io_memFill(io_memFill); uut.io_memDump(io_memDump); uut.io_colCount(io_colCount); uut.io_state(io_state); uut.io_portA_writeEn(io_portA_writeEn); uut.io_portB_dataIn(io_portB_dataIn); uut.io_portB_writeEn(io_portB_writeEn); uut.io_portB_dataOut(io_portB_dataOut); uut.io_portA_addr(io_portA_addr); uut.io_portB_addr(io_portB_addr); uut.io_portA_dataIn(io_portA_dataIn); uut.io_portA_dataOut(io_portA_dataOut); uut.io_inputVecOffset(inpVecPtr); uut.io_outputVecOffset(resVecPtr); bfsMemory.clk(clk); bfsMemory.portA_addr(io_portA_addr); bfsMemory.portA_dataIn(io_portA_dataIn); bfsMemory.portA_dataOut(io_portA_dataOut); bfsMemory.portA_writeEn(io_portA_writeEn); bfsMemory.portB_addr(io_portB_addr); bfsMemory.portB_dataIn(io_portB_dataIn); bfsMemory.portB_dataOut(io_portB_dataOut); bfsMemory.portB_writeEn(io_portB_writeEn); // wrap vector memory in FIFO memInAdp.clk(clk); memInAdp.fifoInput.bind(memIn); memInAdp.bindSignalInterface(uut.io_vectorMemDataIn_valid, uut.io_vectorMemDataIn_ready, uut.io_vectorMemDataIn_bits); // wrap vector memory out FIFO memOutAdp.clk(clk); memOutAdp.fifoOutput.bind(memOut); memOutAdp.bindSignalInterface(uut.io_vectorMemDataOut_valid, uut.io_vectorMemDataOut_ready, uut.io_vectorMemDataOut_bits); // wrap col lengths FIFO colLenAdp.clk(clk); colLenAdp.fifoInput.bind(colLen); colLenAdp.bindSignalInterface(uut.io_colLengths_valid, uut.io_colLengths_ready, uut.io_colLengths_bits); // wrap row indices FIFO rowIndAdp.clk(clk); rowIndAdp.fifoInput.bind(rowInd); rowIndAdp.bindSignalInterface(uut.io_rowIndices_valid, uut.io_rowIndices_ready, uut.io_rowIndices_bits); SC_THREAD(runFrontendTests); sensitive << clk.pos(); init_trace(); }
static void init_traces(void) { init_trace(&irq_pc, TG_IRQ, 0.0, TRACE_SYM_F_ADDR, "IRQ (pc)"); init_trace(&sirq[0], TG_IRQ, 100.0, TRACE_SYM_F_BITS, "softirq"); init_trace(&sirq[1], TG_IRQ, 100.01, TRACE_SYM_F_STRING, "softirq (info)"); init_trace(&sirq[2], TG_IRQ, 100.02, TRACE_SYM_F_STRING, "softirq (info2)"); init_trace(&tlow[0], TG_IRQ, 101.0, TRACE_SYM_F_BITS, "tasklet_low"); init_trace(&tlow[1], TG_IRQ, 101.01, TRACE_SYM_F_ADDR, "tasklet_low (info)"); init_trace(&syscall_id, TG_PROCESS, 0.0, TRACE_SYM_F_U16, "SYSCALL"); init_trace(&syscall_pc, TG_PROCESS, 0.0, TRACE_SYM_F_ADDR, "SYSCALL (pc)"); init_trace(&sched_event, TG_PROCESS, 0.0, TRACE_SYM_F_STRING, "Sched event"); init_trace(&mode, TG_PROCESS, 0.0, TRACE_SYM_F_STRING, "MODE"); init_trace(&printk_pc, TG_PROCESS, 0.0, TRACE_SYM_F_ADDR, "printk (pc)"); init_trace(&jiffies, TG_IRQ, 0.0, TRACE_SYM_F_INTEGER, "jiffies"); init_trace(&parrot_evt, TG_PROCESS, 0.0, TRACE_SYM_F_STRING, "kernel event"); init_trace(&idle_cpu, TG_PROCESS, 0.0, TRACE_SYM_F_BITS, "global idle"); init_trace(&cpu_load, TG_IRQ, 0.0, TRACE_SYM_F_ANALOG, "cpu load"); init_trace(&trace_fault[0], TG_MM, 1.00, TRACE_SYM_F_BITS, "fault"); init_trace(&trace_fault[1], TG_MM, 1.01, TRACE_SYM_F_STRING, "fault (info)"); init_trace(&trace_fault[2], TG_MM, 1.02, TRACE_SYM_F_BITS, "get user fault"); init_trace(&trace_fault[3], TG_MM, 1.03, TRACE_SYM_F_STRING, "get user fault (info)"); }
void main (int argc, char *argv[]) { char c, *p, *name = argv[0]; extern char *optarg; /* getopt stuff */ extern int optind; /* getopt stuff */ int errors = 0; int daemon = 0; char *port = "ricd"; char *rib_file = NULL; int kernel_read_flag = 1; int kernel_install_flag4 = 1; int kernel_install_flag6 = 1; int rib_install_flag = 1; char *usage = "Usage: %s [-f config_file] [-p uii_port ] [-v] [-n]\n"; char *config_file = NULL; trace_t *default_trace; if ((p = strrchr (name, '/')) != NULL) { name = p + 1; } if (strcasecmp (name, "ricd") == 0 || strcasecmp (name, "ricd.purify") == 0) { config_file = "/etc/ricd.conf"; /* unix convension */ daemon = 1; } #ifdef MCHECK mcheck (0); #endif default_trace = New_Trace2 ("RICd"); set_trace (default_trace, TRACE_PREPEND_STRING, "RICD", 0); set_trace (default_trace, TRACE_MAX_ERRORS, DEFAULT_MAX_ERRORS, 0); /* set_trace (default_trace, TRACE_FLAGS, TR_ALL, 0); */ while ((c = getopt (argc, argv, "46rhnkvf:p:l:i:")) != -1) switch (c) { case 'v': /* verbose */ set_trace (default_trace, TRACE_FLAGS, TR_ALL, TRACE_LOGFILE, "stdout", 0); daemon = 0; break; case 'f': /* config file */ config_file = optarg; break; case '4': kernel_install_flag4 = 0; break; case '6': kernel_install_flag6 = 0; break; case 'n': /* no kernel installation */ kernel_install_flag4 = 0; kernel_install_flag6 = 0; daemon = 0; break; case 'k': /* no kernel read */ kernel_read_flag = 0; break; case 'r': /* no rib installation */ rib_install_flag = 0; break; case 'p': /* uii port number */ port = optarg; break; case 'l': /* load rib on disk (mainly for testing) */ case 'i': /* load rib on disk (mainly for testing) */ rib_file = optarg; break; case 'h': default: errors++; break; } if (errors) { fprintf (stderr, usage, name); printf ("\nMRT %s compiled on %s\n\n", RICD_VERSION, __DATE__); exit (1); } #ifdef notdef if (getuid ()) { fprintf (stderr, "must be root\n"); exit (1); } #endif /* init_trace (name, daemon); */ init_trace (name, 1); /* always syslog */ /* no thread creates here */ init_mrt (default_trace); init_uii (default_trace); init_uii_port (port); init_mrt_reboot (argc, argv); trace (TR_INFO, MRT->trace, "%s compiled on %s started\n", MRT->version, MRT->date); if (daemon) { /* * Now going into daemon mode */ MRT->daemon_mode = 1; daemonize (); } /* read information on all interfaces from the kernel */ init_interfaces (default_trace); init_mrtd_config (default_trace); ricd_init (default_trace, AF_INET); #ifdef HAVE_IPV6 ricd_init (default_trace, AF_INET6); #endif /* HAVE_IPV6 */ set_uii (UII, UII_PROMPT, UII_UNPREV, "Password: "******"RICD> ", 0); kernel_init (); /* open routing socket */ /* * read configuration here */ ricd_init_config (); /* default_trace may be modified by debug statement in config file */ if (config_from_file (default_trace, config_file) < 0) { config_create_default (); } /* CONFIGURATION DEPENDENT INITIALIZATION PART */ ricd_start (AF_INET); #ifdef HAVE_IPV6 ricd_start (AF_INET6); #endif /* HAVE_IPV6 */ listen_uii2 (NULL); if (daemon) { int status = 0; if (write (channel[1], &status, sizeof (int)) < 0) perror ("write"); } /* timers never fire until going into loop */ /* select never fire until going into loop */ mrt_main_loop (); exit (0); }