void X86ReadTraceCacheConfig(struct config_t *config) { char *section; char *file_name; /* Section in configuration file */ section = "TraceCache"; file_name = config_get_file_name(config); /* Read variables */ x86_trace_cache_present = config_read_bool(config, section, "Present", 0); x86_trace_cache_num_sets = config_read_int(config, section, "Sets", 64); x86_trace_cache_assoc = config_read_int(config, section, "Assoc", 4); x86_trace_cache_trace_size = config_read_int(config, section, "TraceSize", 16); x86_trace_cache_branch_max = config_read_int(config, section, "BranchMax", 3); x86_trace_cache_queue_size = config_read_int(config, section, "QueueSize", 32); /* Integrity checks */ if ((x86_trace_cache_num_sets & (x86_trace_cache_num_sets - 1)) || !x86_trace_cache_num_sets) fatal("%s: %s: 'Sets' must be a power of 2 greater than 0", file_name, section); if ((x86_trace_cache_assoc & (x86_trace_cache_assoc - 1)) || !x86_trace_cache_assoc) fatal("%s: %s: 'Assoc' must be a power of 2 greater than 0", file_name, section); if (!x86_trace_cache_trace_size) fatal("%s: %s: Invalid value for 'TraceSize'", file_name, section); if (!x86_trace_cache_branch_max) fatal("%s: %s: Invalid value for 'BranchMax'", file_name, section); if (x86_trace_cache_branch_max > x86_trace_cache_trace_size) fatal("%s: %s: 'BranchMax' must be equal or less than 'TraceSize'", file_name, section); if (x86_trace_cache_branch_max > 31) fatal("%s: %s: Maximum value for 'BranchMax' is 31", file_name, section); }
void X86CpuReadConfig(void) { struct config_t *config; char *section; /* Open file */ config = config_create(x86_config_file_name); if (*x86_config_file_name) config_load(config); /* General configuration */ section = "General"; x86_cpu_frequency = config_read_int(config, section, "Frequency", x86_cpu_frequency); if (!IN_RANGE(x86_cpu_frequency, 1, ESIM_MAX_FREQUENCY)) fatal("%s: invalid value for 'Frequency'.", x86_config_file_name); x86_cpu_num_cores = config_read_int(config, section, "Cores", x86_cpu_num_cores); x86_cpu_num_threads = config_read_int(config, section, "Threads", x86_cpu_num_threads); x86_cpu_fast_forward_count = config_read_llint(config, section, "FastForward", 0); x86_cpu_context_quantum = config_read_int(config, section, "ContextQuantum", 100000); x86_cpu_thread_quantum = config_read_int(config, section, "ThreadQuantum", 1000); x86_cpu_thread_switch_penalty = config_read_int(config, section, "ThreadSwitchPenalty", 0); x86_cpu_recover_kind = config_read_enum(config, section, "RecoverKind", x86_cpu_recover_kind_writeback, x86_cpu_recover_kind_map, 2); x86_cpu_recover_penalty = config_read_int(config, section, "RecoverPenalty", 0); x86_emu_process_prefetch_hints = config_read_bool(config, section, "ProcessPrefetchHints", 1); prefetch_history_size = config_read_int(config, section, "PrefetchHistorySize", 10); /* Section '[ Pipeline ]' */ section = "Pipeline"; x86_cpu_fetch_kind = config_read_enum(config, section, "FetchKind", x86_cpu_fetch_kind_timeslice, x86_cpu_fetch_kind_map, 3); x86_cpu_decode_width = config_read_int(config, section, "DecodeWidth", 4); x86_cpu_dispatch_kind = config_read_enum(config, section, "DispatchKind", x86_cpu_dispatch_kind_timeslice, x86_cpu_dispatch_kind_map, 2); x86_cpu_dispatch_width = config_read_int(config, section, "DispatchWidth", 4); x86_cpu_issue_kind = config_read_enum(config, section, "IssueKind", x86_cpu_issue_kind_timeslice, x86_cpu_issue_kind_map, 2); x86_cpu_issue_width = config_read_int(config, section, "IssueWidth", 4); x86_cpu_commit_kind = config_read_enum(config, section, "CommitKind", x86_cpu_commit_kind_shared, x86_cpu_commit_kind_map, 2); x86_cpu_commit_width = config_read_int(config, section, "CommitWidth", 4); x86_cpu_occupancy_stats = config_read_bool(config, section, "OccupancyStats", 0); /* Section '[ Queues ]' */ section = "Queues"; x86_fetch_queue_size = config_read_int(config, section, "FetchQueueSize", 64); x86_uop_queue_size = config_read_int(config, section, "UopQueueSize", 32); x86_rob_kind = config_read_enum(config, section, "RobKind", x86_rob_kind_private, x86_rob_kind_map, 2); x86_rob_size = config_read_int(config, section, "RobSize", 64); x86_iq_kind = config_read_enum(config, section, "IqKind", x86_iq_kind_private, x86_iq_kind_map, 2); x86_iq_size = config_read_int(config, section, "IqSize", 40); x86_lsq_kind = config_read_enum(config, section, "LsqKind", x86_lsq_kind_private, x86_lsq_kind_map, 2); x86_lsq_size = config_read_int(config, section, "LsqSize", 20); /* Register file */ X86ReadRegFileConfig(config); /* Functional Units */ X86ReadFunctionalUnitsConfig(config); /* Branch predictor */ X86ReadBranchPredConfig(config); /* Trace Cache */ X86ReadTraceCacheConfig(config); /* Close file */ config_check(config); config_free(config); }
/*------------------------------------------------------------------------- Read emulator settings from the config file. Input: Config Pointer to the config file stucture. ---------------------------------------------------------------------------*/ void config_load_settings ( CONFIG_FILE *Config ) { if ( !config_find_section ( Config, "Settings" ) ) return; config_read_bool ( Config, "Show Debugger", &neogeo_debugger_enabled ); config_read_enum ( Config, "Debugger Key", &neogeo_debugger_key, config_key_enum ); config_read_enum ( Config, "Nationality", &neogeo_machine_nationality, config_nationality_enum ); config_read_bool ( Config, "Fullscreen", &video_fullscreen ); config_read_bool ( Config, "Full Throttle", &neogeo_fullthrottle_enable ); config_read_integer ( Config, "Audio Buffer Size", &neogeo_audio_buffer_size ); config_read_integer ( Config, "Latency", &neogeo_audio_latency ); config_read_integer ( Config, "CD Volume", &neogeo_cd_volume ); if ( neogeo_cd_volume > 100 ) neogeo_cd_volume = 100; config_read_integer ( Config, "YM2610 Volume", &neogeo_ym2610_volume ); if ( neogeo_ym2610_volume > 100 ) neogeo_ym2610_volume = 100; config_read_bool ( Config, "Display Border", &video_display_border ); config_read_enum ( Config, "Window Interpolation", &video_window_interpolation, config_filter_enum ); config_read_integer ( Config, "Window Resolution X", &video_window_resolution_x ); if ( video_window_resolution_x < 640 ) video_window_resolution_x = 640; config_read_integer ( Config, "Window Resolution Y", &video_window_resolution_y ); if ( video_window_resolution_y < 480 ) video_window_resolution_y = 480; config_read_enum ( Config, "Fullscreen Interpolation", &video_fullscreen_interpolation, config_filter_enum ); config_read_integer ( Config, "Fullscreen Resolution X", &video_fullscreen_resolution_x ); if ( video_fullscreen_resolution_x < 640 ) video_fullscreen_resolution_x = 640; config_read_integer ( Config, "Fullscreen Resolution Y", &video_fullscreen_resolution_y ); if ( video_fullscreen_resolution_y < 480 ) video_fullscreen_resolution_y = 480; config_read_bool ( Config, "Vsync", &video_vsync ); if ( video_vsync ) video_lag_tolerance = 0; else video_lag_tolerance = -30; config_read_bool ( Config, "Keep Aspect Ratio", &video_keep_aspect_ratio ); config_read_enum ( Config, "Controller 1 Up Key", &neogeo_controller1_up_key, config_key_enum ); config_read_enum ( Config, "Controller 1 Down Key", &neogeo_controller1_down_key, config_key_enum ); config_read_enum ( Config, "Controller 1 Left Key", &neogeo_controller1_left_key, config_key_enum ); config_read_enum ( Config, "Controller 1 Right Key", &neogeo_controller1_right_key, config_key_enum ); config_read_enum ( Config, "Controller 1 A Key", &neogeo_controller1_a_key, config_key_enum ); config_read_enum ( Config, "Controller 1 B Key", &neogeo_controller1_b_key, config_key_enum ); config_read_enum ( Config, "Controller 1 C Key", &neogeo_controller1_c_key, config_key_enum ); config_read_enum ( Config, "Controller 1 D Key", &neogeo_controller1_d_key, config_key_enum ); config_read_enum ( Config, "Controller 1 Start Key", &neogeo_controller1_start_key, config_key_enum ); config_read_enum ( Config, "Controller 1 Select Key", &neogeo_controller1_select_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Up Key", &neogeo_controller2_up_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Down Key", &neogeo_controller2_down_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Left Key", &neogeo_controller2_left_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Right Key", &neogeo_controller2_right_key, config_key_enum ); config_read_enum ( Config, "Controller 2 A Key", &neogeo_controller2_a_key, config_key_enum ); config_read_enum ( Config, "Controller 2 B Key", &neogeo_controller2_b_key, config_key_enum ); config_read_enum ( Config, "Controller 2 C Key", &neogeo_controller2_c_key, config_key_enum ); config_read_enum ( Config, "Controller 2 D Key", &neogeo_controller2_d_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Start Key", &neogeo_controller2_start_key, config_key_enum ); config_read_enum ( Config, "Controller 2 Select Key", &neogeo_controller2_select_key, config_key_enum ); if ( sdl_joystick1 ) { if ( config_find_subsection ( Config, SDL_JoystickName ( 0 ) ) ) { config_read_integer ( Config, "X Axis", &neogeo_controller1_x_axis ); config_read_integer ( Config, "Y Axis", &neogeo_controller1_y_axis ); config_read_integer ( Config, "Hat", &neogeo_controller1_hat ); config_read_integer ( Config, "A Button", &neogeo_controller1_a_button ); config_read_integer ( Config, "B Button", &neogeo_controller1_b_button ); config_read_integer ( Config, "C Button", &neogeo_controller1_c_button ); config_read_integer ( Config, "D Button", &neogeo_controller1_d_button ); config_read_integer ( Config, "Start Button", &neogeo_controller1_start_button ); config_read_integer ( Config, "Select Button", &neogeo_controller1_select_button ); fprintf ( stdout, "Loaded profile %s for joystick 0.\n", SDL_JoystickName ( 0 ) ); } else fprintf ( stdout, "Using default settings for joystick 0.\n" ); } if ( sdl_joystick2 ) { if ( config_find_subsection ( Config, SDL_JoystickName ( 1 ) ) ) { config_read_integer ( Config, "X Axis", &neogeo_controller2_x_axis ); config_read_integer ( Config, "Y Axis", &neogeo_controller2_y_axis ); config_read_integer ( Config, "Hat", &neogeo_controller2_hat ); config_read_integer ( Config, "A Button", &neogeo_controller2_a_button ); config_read_integer ( Config, "B Button", &neogeo_controller2_b_button ); config_read_integer ( Config, "C Button", &neogeo_controller2_c_button ); config_read_integer ( Config, "D Button", &neogeo_controller2_d_button ); config_read_integer ( Config, "Start Button", &neogeo_controller2_start_button ); config_read_integer ( Config, "Select Button", &neogeo_controller2_select_button ); fprintf ( stdout, "Loaded profile %s for joystick 1.\n", SDL_JoystickName ( 1 ) ); } else fprintf ( stdout, "Using default settings for joystick 1.\n" ); } }
/* Check CPU configuration file */ static void x86_cpu_config_check(void) { struct config_t *config; char *section; /* Open file */ config = config_create(x86_config_file_name); if (*x86_config_file_name) config_load(config); /* General configuration */ section = "General"; x86_cpu_num_cores = config_read_int(config, section, "Cores", x86_cpu_num_cores); x86_cpu_num_threads = config_read_int(config, section, "Threads", x86_cpu_num_threads); x86_cpu_fast_forward_count = config_read_llint(config, section, "FastForward", 0); x86_cpu_context_switch = config_read_bool(config, section, "ContextSwitch", 1); x86_cpu_context_quantum = config_read_int(config, section, "ContextQuantum", 100000); x86_cpu_thread_quantum = config_read_int(config, section, "ThreadQuantum", 1000); x86_cpu_thread_switch_penalty = config_read_int(config, section, "ThreadSwitchPenalty", 0); x86_cpu_recover_kind = config_read_enum(config, section, "RecoverKind", x86_cpu_recover_kind_writeback, x86_cpu_recover_kind_map, 2); x86_cpu_recover_penalty = config_read_int(config, section, "RecoverPenalty", 0); mmu_page_size = config_read_int(config, section, "PageSize", 4096); x86_emu_process_prefetch_hints = config_read_bool(config, section, "ProcessPrefetchHints", 1); prefetch_history_size = config_read_int(config, section, "PrefetchHistorySize", 10); /* Section '[ Pipeline ]' */ section = "Pipeline"; x86_cpu_fetch_kind = config_read_enum(config, section, "FetchKind", x86_cpu_fetch_kind_timeslice, x86_cpu_fetch_kind_map, 3); x86_cpu_decode_width = config_read_int(config, section, "DecodeWidth", 4); x86_cpu_dispatch_kind = config_read_enum(config, section, "DispatchKind", x86_cpu_dispatch_kind_timeslice, x86_cpu_dispatch_kind_map, 2); x86_cpu_dispatch_width = config_read_int(config, section, "DispatchWidth", 4); x86_cpu_issue_kind = config_read_enum(config, section, "IssueKind", x86_cpu_issue_kind_timeslice, x86_cpu_issue_kind_map, 2); x86_cpu_issue_width = config_read_int(config, section, "IssueWidth", 4); x86_cpu_commit_kind = config_read_enum(config, section, "CommitKind", x86_cpu_commit_kind_shared, x86_cpu_commit_kind_map, 2); x86_cpu_commit_width = config_read_int(config, section, "CommitWidth", 4); x86_cpu_occupancy_stats = config_read_bool(config, section, "OccupancyStats", 0); /* Section '[ Queues ]' */ section = "Queues"; x86_fetch_queue_size = config_read_int(config, section, "FetchQueueSize", 64); x86_uop_queue_size = config_read_int(config, section, "UopQueueSize", 32); x86_rob_kind = config_read_enum(config, section, "RobKind", x86_rob_kind_private, x86_rob_kind_map, 2); x86_rob_size = config_read_int(config, section, "RobSize", 64); x86_iq_kind = config_read_enum(config, section, "IqKind", x86_iq_kind_private, x86_iq_kind_map, 2); x86_iq_size = config_read_int(config, section, "IqSize", 40); x86_lsq_kind = config_read_enum(config, section, "LsqKind", x86_lsq_kind_private, x86_lsq_kind_map, 2); x86_lsq_size = config_read_int(config, section, "LsqSize", 20); x86_reg_file_kind = config_read_enum(config, section, "RfKind", x86_reg_file_kind_private, x86_reg_file_kind_map, 2); x86_reg_file_int_size = config_read_int(config, section, "RfIntSize", 80); x86_reg_file_fp_size = config_read_int(config, section, "RfFpSize", 40); x86_reg_file_xmm_size = config_read_int(config, section, "RfXmmSize", 40); /* Functional Units */ section = "FunctionalUnits"; x86_fu_res_pool[x86_fu_intadd].count = config_read_int(config, section, "IntAdd.Count", 4); x86_fu_res_pool[x86_fu_intadd].oplat = config_read_int(config, section, "IntAdd.OpLat", 2); x86_fu_res_pool[x86_fu_intadd].issuelat = config_read_int(config, section, "IntAdd.IssueLat", 1); x86_fu_res_pool[x86_fu_intmult].count = config_read_int(config, section, "IntMult.Count", 1); x86_fu_res_pool[x86_fu_intmult].oplat = config_read_int(config, section, "IntMult.OpLat", 3); x86_fu_res_pool[x86_fu_intmult].issuelat = config_read_int(config, section, "IntMult.IssueLat", 3); x86_fu_res_pool[x86_fu_intdiv].count = config_read_int(config, section, "IntDiv.Count", 1); x86_fu_res_pool[x86_fu_intdiv].oplat = config_read_int(config, section, "IntDiv.OpLat", 20); x86_fu_res_pool[x86_fu_intdiv].issuelat = config_read_int(config, section, "IntDiv.IssueLat", 20); x86_fu_res_pool[x86_fu_effaddr].count = config_read_int(config, section, "EffAddr.Count", 4); x86_fu_res_pool[x86_fu_effaddr].oplat = config_read_int(config, section, "EffAddr.OpLat", 2); x86_fu_res_pool[x86_fu_effaddr].issuelat = config_read_int(config, section, "EffAddr.IssueLat", 1); x86_fu_res_pool[x86_fu_logic].count = config_read_int(config, section, "Logic.Count", 4); x86_fu_res_pool[x86_fu_logic].oplat = config_read_int(config, section, "Logic.OpLat", 1); x86_fu_res_pool[x86_fu_logic].issuelat = config_read_int(config, section, "Logic.IssueLat", 1); x86_fu_res_pool[x86_fu_fpsimple].count = config_read_int(config, section, "FpSimple.Count", 2); x86_fu_res_pool[x86_fu_fpsimple].oplat = config_read_int(config, section, "FpSimple.OpLat", 2); x86_fu_res_pool[x86_fu_fpsimple].issuelat = config_read_int(config, section, "FpSimple.IssueLat", 2); x86_fu_res_pool[x86_fu_fpadd].count = config_read_int(config, section, "FpAdd.Count", 2); x86_fu_res_pool[x86_fu_fpadd].oplat = config_read_int(config, section, "FpAdd.OpLat", 5); x86_fu_res_pool[x86_fu_fpadd].issuelat = config_read_int(config, section, "FpAdd.IssueLat", 5); x86_fu_res_pool[x86_fu_fpmult].count = config_read_int(config, section, "FpMult.Count", 1); x86_fu_res_pool[x86_fu_fpmult].oplat = config_read_int(config, section, "FpMult.OpLat", 10); x86_fu_res_pool[x86_fu_fpmult].issuelat = config_read_int(config, section, "FpMult.IssueLat", 10); x86_fu_res_pool[x86_fu_fpdiv].count = config_read_int(config, section, "FpDiv.Count", 1); x86_fu_res_pool[x86_fu_fpdiv].oplat = config_read_int(config, section, "FpDiv.OpLat", 20); x86_fu_res_pool[x86_fu_fpdiv].issuelat = config_read_int(config, section, "FpDiv.IssueLat", 20); x86_fu_res_pool[x86_fu_fpcomplex].count = config_read_int(config, section, "FpComplex.Count", 1); x86_fu_res_pool[x86_fu_fpcomplex].oplat = config_read_int(config, section, "FpComplex.OpLat", 40); x86_fu_res_pool[x86_fu_fpcomplex].issuelat = config_read_int(config, section, "FpComplex.IssueLat", 40); x86_fu_res_pool[x86_fu_xmm_int].count = config_read_int(config, section, "XMMInt.Count", 1); x86_fu_res_pool[x86_fu_xmm_int].oplat = config_read_int(config, section, "XMMInt.OpLat", 2); x86_fu_res_pool[x86_fu_xmm_int].issuelat = config_read_int(config, section, "XMMInt.IssueLat", 2); x86_fu_res_pool[x86_fu_xmm_float].count = config_read_int(config, section, "XMMFloat.Count", 1); x86_fu_res_pool[x86_fu_xmm_float].oplat = config_read_int(config, section, "XMMFloat.OpLat", 10); x86_fu_res_pool[x86_fu_xmm_float].issuelat = config_read_int(config, section, "XMMFloat.IssueLat", 10); x86_fu_res_pool[x86_fu_xmm_logic].count = config_read_int(config, section, "XMMLogic.Count", 1); x86_fu_res_pool[x86_fu_xmm_logic].oplat = config_read_int(config, section, "XMMLogic.OpLat", 1); x86_fu_res_pool[x86_fu_xmm_logic].issuelat = config_read_int(config, section, "XMMLogic.IssueLat", 1); /* Branch Predictor */ section = "BranchPredictor"; x86_bpred_kind = config_read_enum(config, section, "Kind", x86_bpred_kind_twolevel, x86_bpred_kind_map, 6); x86_bpred_btb_sets = config_read_int(config, section, "BTB.Sets", 256); x86_bpred_btb_assoc = config_read_int(config, section, "BTB.Assoc", 4); x86_bpred_bimod_size = config_read_int(config, section, "Bimod.Size", 1024); x86_bpred_choice_size = config_read_int(config, section, "Choice.Size", 1024); x86_bpred_ras_size = config_read_int(config, section, "RAS.Size", 32); x86_bpred_twolevel_l1size = config_read_int(config, section, "TwoLevel.L1Size", 1); x86_bpred_twolevel_l2size = config_read_int(config, section, "TwoLevel.L2Size", 1024); x86_bpred_twolevel_hist_size = config_read_int(config, section, "TwoLevel.HistorySize", 8); /* Trace Cache */ x86_trace_cache_config_check(config); /* Close file */ config_check(config); config_free(config); }