void net_init(void) { /* Load network configuration file */ net_read_config(); /* Register events for network handler*/ EV_NET_SEND = esim_register_event_with_name(net_event_handler, net_domain_index, "net_send"); EV_NET_OUTPUT_BUFFER = esim_register_event_with_name( net_event_handler, net_domain_index, "net_output_buffer"); EV_NET_INPUT_BUFFER = esim_register_event_with_name( net_event_handler, net_domain_index, "net_input_buffer"); EV_NET_RECEIVE = esim_register_event_with_name( net_event_handler, net_domain_index, "net_receive"); /* Report file */ if (*net_report_file_name) { net_report_file = file_open_for_write(net_report_file_name); if (!net_report_file) fatal("%s: cannot write on network report file", net_report_file_name); } /* Visualization File */ if (*net_visual_file_name) { net_visual_file = file_open_for_write(net_visual_file_name); if (!net_visual_file) fatal("%s: cannot write on network visualization file", net_visual_file_name); } }
void net_init(void) { /* Load network configuration file */ net_read_config(); /* Register events for network handler*/ EV_NET_SEND = esim_register_event_with_name(net_event_handler, net_domain_index, "net_send"); EV_NET_OUTPUT_BUFFER = esim_register_event_with_name(net_event_handler, net_domain_index, "net_output_buffer"); EV_NET_INPUT_BUFFER = esim_register_event_with_name(net_event_handler, net_domain_index, "net_input_buffer"); EV_NET_RECEIVE = esim_register_event_with_name(net_event_handler, net_domain_index, "net_receive"); if (net_table) { struct net_t *net; for (hash_table_find_first(net_table, (void **) &net); net; hash_table_find_next(net_table, (void **) &net)) { net_initiation(net); } } }
static void net_config_command_create(struct net_t *net, struct config_t *config, char *section) { char *command_line; char command_var[MAX_STRING_SIZE]; int command_var_id; /* Checks */ if (net_injection_rate > 0.001) fatal("Network %s:%s: Using Command section; \n" "\t option --net-injection-rate should not be used \n", net->name,section); /* Read commands */ net_injection_rate = 0; if (strcmp(net_traffic_pattern, "") && (strcmp(net_traffic_pattern, "command"))) fatal("Network %s: Command option doesn't comply with other " "traffic pattern\n (%s)", net->name, net_traffic_pattern); net_traffic_pattern = "command"; command_var_id = 0; /* Register events for command handler*/ EV_NET_COMMAND = esim_register_event_with_name(net_command_handler, net_domain_index, "net_command"); EV_NET_COMMAND_RCV = esim_register_event_with_name(net_command_handler, net_domain_index, "net_command_receive"); while (1) { /* Get command */ snprintf(command_var, sizeof command_var, "Command[%d]", command_var_id); command_line = config_read_string(config, section, command_var, NULL); if (!command_line) break; /* Schedule event to process command */ struct net_stack_t *stack; stack = net_stack_create(net,ESIM_EV_NONE, NULL); stack->net = net; stack->command = xstrdup(command_line); esim_schedule_event(EV_NET_COMMAND, stack, 0); /* Next command */ command_var_id++; } }
void esim_init() { /* Create structures */ esim_event_info_list = list_create(); esim_event_heap = heap_create(20); esim_end_event_list = linked_list_create(); /* List of frequency domains */ esim_domain_list = list_create(); list_add(esim_domain_list, NULL); /* Initialize global timer */ esim_timer = m2s_timer_create(NULL); m2s_timer_start(esim_timer); /* Register special events */ ESIM_EV_INVALID = esim_register_event_with_name(NULL, 0, "Invalid"); ESIM_EV_NONE = esim_register_event_with_name(NULL, 0, "None"); }
void x86_emu_init(void) { union { unsigned int as_uint; unsigned char as_uchar[4]; } endian; /* Endian check */ endian.as_uint = 0x33221100; if (endian.as_uchar[0]) fatal("%s: host machine is not little endian", __FUNCTION__); /* Register architecture */ x86_emu_arch = arch_list_register("x86", "x86"); x86_emu_arch->sim_kind = x86_emu_sim_kind; /* Host types */ M2S_HOST_GUEST_MATCH(sizeof(long long), 8); M2S_HOST_GUEST_MATCH(sizeof(int), 4); M2S_HOST_GUEST_MATCH(sizeof(short), 2); /* Initialization */ x86_sys_init(); x86_isa_init(); /* Create */ x86_emu = xcalloc(1, sizeof(struct x86_emu_t)); /* Event for context IPC reports */ EV_X86_CTX_IPC_REPORT = esim_register_event_with_name(x86_ctx_ipc_report_handler, "x86_ctx_ipc_report"); /* Initialize */ x86_emu->current_pid = 1000; /* Initial assigned pid */ x86_emu->timer = m2s_timer_create("x86 emulation timer"); /* Initialize mutex for variables controlling calls to 'x86_emu_process_events()' */ pthread_mutex_init(&x86_emu->process_events_mutex, NULL); /* Initialize GPU emulators */ x86_emu->gpu_kind = x86_emu_gpu_evergreen; #ifdef HAVE_OPENGL /* GLUT */ x86_glut_init(); #endif /* OpenGL */ x86_opengl_init(); }
static void dram_config_request_create(struct dram_system_t *system, struct config_t *config, char *section) { char *request_line; char request_var[MAX_STRING_SIZE]; int request_var_id; /* Read Requests */ request_var_id = 0; /* Register events for request handler*/ EV_DRAM_REQUEST = esim_register_event_with_name(dram_request_handler, dram_domain_index, "dram_request"); while (1) { /* Get request */ snprintf(request_var, sizeof request_var, "Request[%d]", request_var_id); request_line = config_read_string(config, section, request_var, NULL); if (!request_line) break; /* Schedule event to process request */ struct request_stack_t *stack; stack = dram_request_stack_create(); request_line = xstrdup(request_line); stack->request_line = request_line; stack->system = system; esim_schedule_event(EV_DRAM_REQUEST, stack, 0); /* Next command */ request_var_id++; } }