//----------------------------------------------------------------------------- bool pes_initialise(address_t address) { // Read number of PES learning rules that are configured g_num_pes_learning_rules = address[0]; io_printf(IO_BUF, "PES learning: Num rules:%u\n", g_num_pes_learning_rules); if(g_num_pes_learning_rules > 0) { // Allocate memory MALLOC_FAIL_FALSE(g_pes_learning_rules, g_num_pes_learning_rules * sizeof(pes_parameters_t)); // Copy learning rules from region into new array memcpy(g_pes_learning_rules, &address[1], g_num_pes_learning_rules * sizeof(pes_parameters_t)); // Display debug for(uint32_t l = 0; l < g_num_pes_learning_rules; l++) { const pes_parameters_t *parameters = &g_pes_learning_rules[l]; io_printf(IO_BUF, "\tRule %u, Learning rate:%k, Error signal index:%u, " "Error signal start dimension:%u, Error signal end dimensions:%u," "Decoder row:%u, Activity filter index:%d\n", l, parameters->learning_rate, parameters->error_sig_index, parameters->error_start_dim, parameters->error_end_dim, parameters->decoder_row, parameters->activity_filter_index); } } return true; }
static int time_timer(int nt, int ni) {int it, rv; double ap, tt; volatile double ta; io_printf(stdout, "\t\t\ttime timer ........ "); rv = TRUE; tt = SC_wall_clock_time(); ni *= 200; for (it = 0; it < ni; it++) ta = SC_wall_clock_time(); SC_ASSERT(ta > tt); tt = SC_wall_clock_time() - tt; ap = tt/((double) ni); io_printf(stdout, "ok\n\n"); io_printf(stdout, "\t\t Iter Ttot Tper\n"); io_printf(stdout, "\t\t%8d %10.2e %10.2e\n\n", it, tt, ap); return(rv);}
/* * count and list all acc world (prim terminal) drivers */ void mei_count_drivers(handle inst, handle net) { int count = 0; handle term; char s1[1024], s2[1024]; io_printf(" ... processing drivers for %s:\n", acc_fetch_fullname(net)); for (term = acc_next_driver(net, NULL); term != NULL; term = acc_next_driver(net, term)) { if (mei_isinside(inst, term) == 1) { strcpy(s1, "inside"); count++; } else strcpy(s1, "outside"); if (acc_fetch_type(term) == accTerminal) { sprintf(s2, "prim %s port %d", acc_fetch_fullname(acc_handle_parent(term)), acc_fetch_index(term)); } else strcpy(s2, acc_fetch_fullname(term)); io_printf(" +++ %s is %s driver of %s in %s.\n", s2, s1, acc_fetch_fullname(net), acc_fetch_fullname(inst)); } io_printf("net %s has %d inside drivers.\n", acc_fetch_name(net), count); }
void c_main (void) { uint coreID = spin1_get_core_id(); uint chipID = spin1_get_chip_id(); if(chipID == 0 && coreID == 1) { io_printf (IO_STD, "Hello world! (via SDP)\n"); io_printf (IO_BUF, "Hello world! (via the terminal)\n"); if(spin_devin_init() == 0) { io_printf(IO_BUF, "Error: could not connect to the SpiNNaker!\n"); } spin_devin_send_motor(2000 << 16 | 2000); uint cam = spin_devin_get_camera(); io_printf(IO_BUF, "camera: %08x\n", cam); spin1_set_timer_tick(10000); spin1_callback_on(TIMER_TICK, upd, 0); spin_devin_dispose(); } spin1_start(); }
/****f* main.c/c_main * * SUMMARY * This function is called at application start-up. The application programmer * must implement the function body to configure hardware, register callbacks, * and finally begin the simulation. * * SYNOPSIS * int c_main() * * SOURCE */ void c_main() { io_printf(IO_STD, "Hello, World!\nBooting application...\n"); // Set the number of chips in the simulation spin1_set_core_map(64, (uint *)(0x74220000)); // FIXME make the number of chips dynamic // Set timer tick (in microseconds) spin1_set_timer_tick(1000*1); // Configure simulation load_application_data(); load_mc_routing_tables(); configure_app_frame(); #ifdef STDP load_stdp_config_data(); alloc_stdp_post_TS_mem(); #endif // Register callbacks spin1_callback_on(DMA_TRANSFER_DONE, dma_callback, 0); spin1_callback_on(TIMER_TICK, timer_callback, 2); spin1_callback_on(SDP_PACKET_RX, sdp_packet_callback, 1); // Go! // scheduling a callback at t=0 to evaluate the first time step spin1_schedule_callback(timer_callback, 0, 0, 2); io_printf(IO_STD, "Application booted!\nStarting simulation...\n"); spin1_start(); }
// saving (printing param code) void save_() { int i = 0; // w_V_array for(i = 0; i < N_MFM; i++) { io_printf(IO_STD, "w_V_x_array[%d] = %d.0/1000.0;\n", i, (int)(w_V_x_array[i]*1000)); } for(i = 0; i < N_MFM; i++) { io_printf(IO_STD, "w_V_y_array[%d] = %d.0/1000.0;\n", i, (int)(w_V_y_array[i]*1000)); } // w_A_theta_array for(i = 0; i < N_MFM; i++) { io_printf(IO_STD, "w_A_theta_array[%d] = %d.0/1000.0;\n", i, (int)(w_A_theta_array[i]*1000)); } // w_A_psi_array for(i = 0; i < N_MFM; i++) { io_printf(IO_STD, "w_A_psi_array[%d] = %d.0/1000.0;\n", i, (int)(w_A_psi_array[i]*1000)); } }
// setup function which needs to be called in main program before any neuron code executes // MUST BE: inimum 100, then in 100usec steps... void provide_machine_timestep( uint16_t microsecs ){ const uint16_t time_step_divider = 100; refractory_time_update = microsecs / time_step_divider; // 10 for 1ms time step, 1 for 0.1ms time step which is minimum #ifdef CORRECT_FOR_REFRACTORY_GRANULARITY io_printf( IO_STD, "\n *** Refractory granularity correction \n" ); #endif #ifdef CORRECT_FOR_THRESHOLD_GRANULARITY io_printf( IO_STD, "\n *** Threshold granularity correction \n" ); refract_threshold_correction[0] = (uint8_t) round( (double)refractory_time_update * 0.16667 ); refract_threshold_correction[1] = (uint8_t) round( (double)refractory_time_update * 0.50000 ); refract_threshold_correction[2] = (uint8_t) round( (double)refractory_time_update * 0.83333 ); io_printf( IO_STD, "\n refractory updates %u %u %u \n", refract_threshold_correction[0], refract_threshold_correction[1], refract_threshold_correction[2] ); #endif #ifdef SIMPLE_COMBINED_GRANULARITY io_printf( IO_STD, "\n *** Simple combined granularity correction \n" ); simple_thresh_update = refractory_time_update / 2; // nasty integer divide lets hope it's an even number always! io_printf( IO_STD, "\n refractory_time_update %u simp thresh update %u \n", refractory_time_update, simple_thresh_update ); #endif }
/****f* spin1_api.c/report_debug * * SUMMARY * This function reports warnings if requested * at compile time * * SYNOPSIS * void report_debug () * * SOURCE */ void report_debug () { #if API_DEBUG == TRUE if (leadAp) // Only the leader appl. core reports router data { // Report router counters io_printf (IO_API, "\t\t[api_debug] RTR mc packets: %d\n", rtr[RTR_DGC0] + rtr[RTR_DGC1]); io_delay (API_PRINT_DELAY); io_printf (IO_API, "\t\t[api_debug] RTR dpd mc packets: %d\n", rtr[RTR_DGC8]); io_delay (API_PRINT_DELAY); } io_printf (IO_API, "\t\t[api_debug] ISR thrown packets: %d\n", thrown); io_delay (API_PRINT_DELAY); // Report DMAC counters io_printf (IO_API, "\t\t[api_debug] DMA bursts: %d\n", dma[DMA_STAT0]); io_delay (API_PRINT_DELAY); #endif }
/****f* spin1_api.c/report_warns * * SUMMARY * This function reports warnings if requested * at compile time * * SYNOPSIS * void report_warns () * * SOURCE */ void report_warns () { #if API_WARN == TRUE // report warnings if (warnings & TASK_QUEUE_FULL) { io_printf (IO_API, "\t\t[api_warn] warning: task queue full (%u)\n", fullq); io_delay (API_PRINT_DELAY); } if (warnings & DMA_QUEUE_FULL) { io_printf (IO_API, "\t\t[api_warn] warning: DMA queue full (%u)\n", dfull); io_delay (API_PRINT_DELAY); } if (warnings & PACKET_QUEUE_FULL) { io_printf (IO_API, "\t\t[api_warn] warning: packet queue full (%u)\n", pfull); io_delay (API_PRINT_DELAY); } # if USE_WRITE_BUFFER == TRUE if (warnings & WRITE_BUFFER_ERROR) { io_printf (IO_API, "\t\t[api_warn] warning: write buffer errors (%u)\n", wberrors); io_delay (API_PRINT_DELAY); } #endif #endif }
void collectData(uint None, uint Unused) { /* #if(DEBUG_LEVEL>0) if(sv->p2p_addr==0) io_printf(IO_STD, "trig!\n"); #endif */ // convert from phys to virt cpu for(uint i=0; i<18; i++) { virt_cpu = sv->p2v_map[i]; // the the virtual cpu id virt_cpu_idle_cntr[virt_cpu] = stored_cpu_idle_cntr[i]; } sark_mem_cpy((void *)&reportMsg.cmd_rc, (void *)&myProfile, sizeof(pro_info_t)); //sark_mem_cpy((void *)reportMsg.data, (void *)stored_cpu_idle_cntr, 18); sark_mem_cpy((void *)reportMsg.data, (void *)virt_cpu_idle_cntr, 18); #if(DEBUG_LEVEL>2) if(sv->p2p_addr==0) { if(streaming==FALSE) io_printf(IO_STD, "no streaming!\n"); else io_printf(IO_STD, "do streaming!\n"); } return; #endif if(streaming==FALSE) return; /* #if(DEBUG_LEVEL>0) io_printf(IO_BUF, "Send!\n"); return; #endif */ spin1_send_sdp_msg (&reportMsg, DEF_TIMEOUT); }
static void print_code_blocks(parser_t *p, lang_c_ctx_t *ctx) { code_block_t *node; code_block_list_t *head; dbg_ifb (p == NULL) return; dbg_ifb (ctx == NULL) return; io_printf(p->out, "\n\n" "static void exec_page(dypage_args_t *_dyp_args) \n" "{ \n" " request = _dyp_args->rq; \n" " response = _dyp_args->rs; \n" " session = _dyp_args->ss; \n" " in = request_io(request); \n" " out = response_io(response); \n" " u_unused_args(SCRIPT_NAME, request, response, session, in, out);\n" " %s () ; \n ", ctx->ti->dfun ); head = &ctx->code_blocks; for(node = head->tqh_first; node != NULL; node = node->np.tqe_next) { io_printf(p->out, "\n"); io_write(p->out, node->buf, node->sz); } io_printf(p->out, "goto klone_script_exit;\n" /* just to avoid a warning */ "klone_script_exit: \n" " return; \n" "} \n" ); }
err_t oah_query( hashmap_t *hash_map, ion_key_t key, ion_value_t value) { int loc; if (oah_find_item_loc(hash_map, key, &loc) == err_ok) { #if DEBUG io_printf("Item found at location %d\n", loc); #endif int data_length = hash_map->super.record.key_size + hash_map->super.record.value_size; hash_bucket_t * item = (((hash_bucket_t *)((hash_map->entry + (data_length + SIZEOF(STATUS)) * loc)))); //*value = (ion_value_t)malloc(sizeof(char) * (hash_map->super.record.value_size)); memcpy(value, (ion_value_t)(item->data+hash_map->super.record.key_size), hash_map->super.record.value_size); return err_ok; } else { #if DEBUG io_printf("Item not found in hash table.\n"); #endif value = NULL; /**set the number of bytes to 0 */ return err_item_not_found; } }
err_t oah_delete( hashmap_t *hash_map, ion_key_t key ) { int loc; if (oah_find_item_loc(hash_map, key, &loc) == err_item_not_found) { #if DEBUG io_printf("Item not found when trying to oah_delete.\n"); #endif return err_item_not_found; } else { //locate item hash_bucket_t * item = (((hash_bucket_t *)((hash_map->entry + (hash_map->super.record.key_size + hash_map->super.record.value_size + SIZEOF(STATUS)) * loc)))); item->status = DELETED; //delete item #if DEBUG io_printf("Item deleted at location %d\n", loc); #endif return err_ok; } }
void timer_callback(uint ticks, uint null) { if(ticks >= app_data.run_time) { io_printf(IO_STD, "Simulation complete.\n"); io_printf(IO_STD, "Received %d events, sent %d events.\n", events_received, events_sent); io_printf(IO_STD, "Missed %d events because of queue full\n", missed_events); spin1_stop(); } }
void vmm_xvc_tcl_execute_file(char *test_file) { int tcl_error; char xvc_home_path[200]; char *xvc_tcl_utils_file_fullpath; char xvc_tcl_cmd_buf[1000]; /* perform creation and inits of the TCL interpreter */ tcl_error = xvc_tcl_init(); if (tcl_error != TCL_OK) { io_printf("Error in initialization of TCL for VMM xvc manager\n"); abort(); } /* Source the startup script */ /* Check for +vmm_path=%s string, if present, it overrides VCS_HOME/etc/vmm as the location to pickup the vmm_xvc_parse.tcl initialization file */ if (mc_scan_plusargs("vmm_path")) { char *str; str = mc_scan_plusargs("vmm_path") + 1; strcpy(xvc_home_path,str); strcat(xvc_home_path,"/"); } else { /* get VCS_HOME env. variable */ char *vcs_home_path; vcs_home_path = getenv("VCS_HOME"); if (vcs_home_path == NULL) { io_printf("VCS_HOME env. variable not set, needed for xvc manager\n"); abort(); } strcpy(xvc_home_path,vcs_home_path); strcat(xvc_home_path,"/etc/vmm/"); } //ToDo: Error out if xvc_home_path is NULL xvc_tcl_utils_file_fullpath = strcat(xvc_home_path, "vmm_xvc_parse.tcl"); tcl_error = Tcl_EvalFile(xvc_tcl_interp, xvc_tcl_utils_file_fullpath); if (tcl_error != TCL_OK) { io_printf("Error: xvc manager: could not eval file %s\n",xvc_tcl_utils_file_fullpath); io_printf(" Either +vmm_path=<str> or VCS_HOME env. variable needs to be provided\n"); abort(); } /* register user TCL functions */ xvc_register_tcl_functions(); //execute the parse-start command from C sprintf(xvc_tcl_cmd_buf, "execute_file %s", test_file); tcl_error = Tcl_Eval(xvc_tcl_interp, xvc_tcl_cmd_buf); if (tcl_error != TCL_OK) { io_printf("Error: xvc manager: in executing file %s: File does not exist ?\n", test_file); abort(); } }
void array_test(svLogicVecVal data[31]) { io_printf("data[0].aval = %d\n", data[0].aval); io_printf("data[1].aval = %d\n", data[1].aval); data[0].aval = 1; data[0].bval = 0; data[1].aval = 2; data[1].bval = 0; }
/****f* simple.c/app_init * * SUMMARY * This function is called at application start-up. * It's used to say hello, setup multicast routing table entries, * and initialise application variables. * * SYNOPSIS * void app_init () * * SOURCE */ void app_init () { uint i; /* ------------------------------------------------------------------- */ /* initialise routing entries */ /* ------------------------------------------------------------------- */ /* set a MC routing table entry to send my packets back to me */ spin1_set_mc_table_entry(coreID, // entry coreID, // key 0xffffffff, // mask (uint) (1 << (coreID+6)) // route ); /* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */ /* initialize the application processor resources */ /* ------------------------------------------------------------------- */ /* say hello */ io_printf (IO_STD, "[core %d] -----------------------\n", coreID); spin1_delay_us (PRINT_DLY); io_printf (IO_STD, "[core %d] starting simulation\n", coreID); spin1_delay_us (PRINT_DLY); /* use a buffer in the middle of system RAM - avoid conflict with RTK */ sysram_buffer = (uint *) (SPINN_SYSRAM_BASE + SPINN_SYSRAM_SIZE/2 + (coreID * BUFFER_SIZE * sizeof(uint))); /* use a buffer somewhere in SDRAM */ sdram_buffer = (uint *) (SPINN_SDRAM_BASE + SPINN_SDRAM_SIZE/8 + (coreID * BUFFER_SIZE * sizeof(uint))); /* allocate buffer in DTCM */ if ((dtcm_buffer = (uint *) spin1_malloc(BUFFER_SIZE*sizeof(uint))) == 0) { test_DMA = FALSE; io_printf (IO_STD, "[core %d] error - cannot allocate dtcm buffer\n", coreID); spin1_delay_us (PRINT_DLY); } else { test_DMA = TRUE; /* initialize sections of DTCM, system RAM and SDRAM */ for (i=0; i<BUFFER_SIZE; i++) { dtcm_buffer[i] = i; sysram_buffer[i] = 0xa5a5a5a5; sdram_buffer[i] = 0x5a5a5a5a; } io_printf (IO_STD, "[core %d] dtcm buffer @ 0x%8z\n", coreID, (uint) dtcm_buffer); spin1_delay_us (PRINT_DLY); } /* ------------------------------------------------------------------- */ }
void enable_packet_received(uint key, uint payload) { io_printf(IO_STD, "this was an enable message (no payload)! %08x.%08x \n", key, payload); io_printf(IO_STD, "enabling compass tracking!"); if (heading < 0) { // register compass callback on first notification spin1_callback_on(MCPL_PACKET_RECEIVED, compass_received, MC_PACKET_EVENT_PRIORITY); } heading = payload; }
#endif void print_module_table() { struct module_rec * el = &module_root; io_printf("--- Loaded Module Table ---\n"); while((el = el->next)) { io_printf("module = %s, module_struct = %p, load_status = %d\n",
void compass_received(uint key, uint payload) { io_printf(IO_STD, "this was a compass message: %08x,%08x \n", key, payload); if ( abs(heading - payload) > 100000) { spin1_send_mc_packet(0x111002a0,0x40,1); // slowly forwards io_printf(IO_STD, "Go forwards again.\n"); spin1_send_mc_packet(0x111002a2,0,1); // no roll spin1_callback_off(MCPL_PACKET_RECEIVED); // deregister my callback heading = -1; //reset heading } }
int util_get_plus_args_num() { /* Example use integer num_vectors; // number of test vectors integer MAX_FAILURES; // max failed vectors before aborting initial begin // get integers from plus argument values num_vectors = $util_get_plus_args_num("num_vectors"); MAX_FAILURES = $util_get_plus_args_num("max_failures"); $display("%d VECTORS IN TEST FILE.", num_vectors); $display("Maximum number of failures is %d", MAX_FAILURES); end */ /* Input: [unsigned int which is a string | * C string ] * Returns: Arg. value in 32 bit integer. * On error returns VERILOG_C_ERROR * Action: Gets the parameter, calls 'mc_scan_plusargs' * to get the arg. value. * */ int np; char *cp; np = tf_nump(); if ( np != 1 ) { if (DEBUG_PLUS_ARGS) { io_printf("get_plus_args_num(): Error: Number of args != 1.\n"); } tf_putp(0, VERILOG_ERROR); return(VERILOG_ERROR); } cp = mc_scan_plusargs(tf_getcstringp(1)); if (cp == NULL ) { if (DEBUG_PLUS_ARGS) { io_printf("get_plus_args_num(): Matching number is not found: %d\n", tf_getcstringp(1)); } tf_putp(0, VERILOG_ERROR); return(VERILOG_ERROR); } if (DEBUG_PLUS_ARGS) io_printf("get_plus_args_num(): Got integer value: %d\n", atoi(cp)); tf_putp(0, atoi(cp) ); return(VERILOG_OK); }
/* print */ void xvc_cmd_print(xvc_parse_cmd_t *cmd) { int i; io_printf("-------DPI: %s[%s] -------\n", cmd->testfile, cmd->linec); for (i = 0; i < cmd->argc; i++) { io_printf(" %s\n", cmd->argv[i]); } if (cmd->err_msg) io_printf(" %s\n", cmd->err_msg); }
/* OBS! For fsrouter to work it must be initialized from globals.c:init_globals() */ int io_load_file33(const char * filename, void ** addr, unsigned long * size) { static l4_threadid_t fs_drvc_id; l4_threadid_t dm_id; l4dm_dataspace_t ds; CORBA_Environment _env = dice_default_environment; char drv = get_drv(filename); if(drv == '\0') { //io_printf("io.c Warning, no drive in filename, assume c: for now.\n"); drv = 'c'; } /* How to find the working directory? From this thread ( l4thread_myself() ) find the thread's process (our own prcess structure) and lookup the working directory there. L4 has a task- and thread number, as seen in output by [x.y] */ struct I_Fs_srv *target_fs_srv = FSRouter_route(&fsrouter, drv ); //io_printf("io_load_file: '%s'\n", filename); if(target_fs_srv) { if (!names_waitfor_name(target_fs_srv->server, &fs_drvc_id, 10000)) { io_printf("File provider %s doesn't answer\n", target_fs_srv->mountpoint); return 2; }; dm_id = l4env_get_default_dsm(); if (l4_is_invalid_id(dm_id)) { io_printf("Bad dataspace!\n"); return 1; } int f_status = l4fprov_file_open_call(&fs_drvc_id, filename, /* OBS! Ta bort enheten från sökvägen! */ &dm_id, 0, &ds, size, &_env); if(f_status) return 2; f_status=l4rm_attach(&ds, *size, 0, L4DM_RO | L4RM_MAP, addr); if(f_status) { io_printf("error %s\n", l4env_errstr(f_status)); return 2; } //io_printf("io_load_file(: '%s', 0x%x, %d )\n", filename, *addr, *size); return 0; } else { io_printf("target_fs_srv: 0x%x\n", target_fs_srv); return 2; /* ERROR_FILE_NOT_FOUND; */ }
void error_call(int data, int reason) { char *ptr_mipname; char *ptr; int i; int ms, us, ns, ps; get_time (&ms, &us, &ns, &ps); ptr_mipname = tf_mipname(); /* Requires at least two arguments */ if (tf_nump() < ARG2) { tf_error("$error requires at least two arguments, error-disable-tag, and format-string"); tf_dofinish(); return; } /* First argument to $error() must be a string */ if (tf_typep(ARG1) != tf_string) { tf_error("First argument to $error must be a value"); tf_dofinish(); } /* Second argument to $error() must be a string */ if (tf_typep(ARG2) != tf_string) { tf_error("Second argument to $error must be a formating string"); tf_dofinish(); } for (i = 0; i < diserr_num; i++) { ptr = strchr(diserr_arr[i], '.'); if (ptr == NULL) { if (strcmp (tf_getcstringp(ARG1), diserr_arr[i]) == 0) { io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms,us,ns,ps, ptr_mipname, format(ptr_mipname)); return; } } else { sprintf (format_buffer, "%s.%s\0", tf_getcstringp(ARG1), ptr_mipname); if (strcmp (format_buffer, diserr_arr[i]) == 0) { io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms,us,ns,ps, ptr_mipname, format(ptr_mipname)); return; } } } io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms,us,ns,ps, ptr_mipname, format(ptr_mipname)); if (!error_disable) tf_dofinish(); return; }
void _backend_print_tree(tree *t) { t_data = t; // Генерируем секцию .text io_printf(".text\n"); b_calc_tree(t); // Генерируем секцию .data io_printf(".data\n"); b_data_tree(t); // HACK io_printf("const_format:\n.string \"%%d\"\n"); io_printf(".long 0"); }
void c_main (void) { char buf[64]; io_printf (IO_STD, "Hello world! (via SDP)\n"); io_printf (IO_BUF, "Hello world! (via SDRAM)\n"); // io_printf can also do sprintf! io_printf (buf, "Hello world! (via printf...)\n"); io_printf (IO_BUF, buf); }
static int print_var_definition(parser_t *p, int comp, const char *varname, const char *buf, size_t bufsz) { codec_t *zip = NULL; io_t *ios = NULL; int rc, i; unsigned char c; dbg_err_if(p == NULL); dbg_err_if(varname == NULL); dbg_err_if(buf == NULL); /* create an io_t around the HTML block */ dbg_err_if(io_mem_create((char*)buf, bufsz, 0, &ios)); #ifdef HAVE_LIBZ /* if compression is enabled zip the data block */ if(comp) { /* apply a gzip codec */ dbg_err_if(codec_gzip_create(GZIP_COMPRESS, &zip)); dbg_err_if(io_codec_add_tail(ios, zip)); zip = NULL; /* io_free() will free the codec */ } #endif io_printf(p->out, "static const char %s[] = {\n", varname); for(i = 1; (rc = io_getc(ios, (char*)&c)) > 0; ++i) { io_printf(p->out, "0x%02X, ", c); if(i % 12 == 0) io_printf(p->out, "\n"); } dbg_err_if(rc < 0); /* input stream error */ io_printf(p->out, "};\n"); io_free(ios); return 0; err: if(zip) codec_free(zip); if(ios) io_free(ios); return ~0; }
struct LX_module * LXLoadStream(char * stream_fh, int str_size, struct LX_module * lx_mod) { lx_mod->lx_fseek = &lx_fseek_stream; /* Copy functionpointer which does fseek on memory buffer. An attempt to streamline access to booth disk files and memory buffers.*/ lx_mod->lx_fread = &lx_fread_stream; lx_mod->lx_file_stream = stream_fh; lx_mod->lx_stream_size = str_size; lx_mod->lx_stream_pos = 0; lx_mod->lx_head_e32_exe = 0; lx_mod->offs_lx_head = 0; lx_mod->fh = 0; /* No filehandle to a disk file is used. */ if(LXLoadHeader(lx_mod)) { //io_printf("Succeeded to load LX header.\n"); LXLoadLoaderSection(lx_mod); LXLoadFixupSection(lx_mod); } else { io_printf("Could not load LX header!!!!\n"); return 0; } return lx_mod; }
/* Copy in a set of routing entries. * * `routes` should be an array of `_if_routes` preceded with a single word * indicating the number of entries. */ void input_filtering_get_routes(if_collection_t *filters, uint32_t *routes) { // Copy in the number of routing entries filters->n_routes = routes[0]; routes++; // Advance the pointer to the first entry debug("Loading %d filter routes\n", filters->n_routes); // Malloc sufficient room for the entries MALLOC_OR_DIE(filters->routes, filters->n_routes * sizeof(if_route_t)); // Copy the entries across spin1_memcpy(filters->routes, routes, filters->n_routes * sizeof(if_route_t)); // DEBUG: Print the route entries #ifdef DEBUG for (uint32_t n = 0; n < filters->n_routes; n++) { io_printf(IO_BUF, "\tRoute[%d] = (0x%08x, 0x%08x) dmask=0x%08x => %d\n", n, filters->routes[n].key, filters->routes[n].mask, filters->routes[n].dimension_mask, filters->routes[n].input_index); } #endif }
void c_main (void) { uint core = sark_core_id (); // Get core ID io_printf (IO_BUF, "Started core %d\n", core); // and print it sark_srand ((sark_chip_id () << 8) + core * sv->time_ms); // Init randgen event_register_timer (SLOT_0); // Set up the timer event mechanism event_queue_proc (timer_proc, 0, 0, PRIO_0); // Queue the first timer call uint rc = event_start (0, 0, SYNC_NOWAIT); // Start event handling io_printf (IO_BUF, "Terminated rc %d\n", rc); // Printed if event_stop used... }