3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * Description: See init.h
40 #include "EventQueue.hh"
43 #include "Profiler.hh"
45 #include "OpalInterface.hh"
47 #include "interface.hh"
49 #ifdef CONTIGUOUS_ADDRESSES
50 #include "ContiguousAddressTranslator.hh"
52 /* Declared in interface.C */
53 extern ContiguousAddressTranslator
* g_p_ca_translator
;
55 #endif // #ifdef CONTIGUOUS_ADDRESSES
64 // #include "simics/api.hh"
67 #include "FakeSimicsDataTypes.hh"
72 // A generated file containing the default parameters in string form
73 // The defaults are stored in the variable global_default_param
74 #include "default_param.hh"
76 attr_value_t
ruby_session_get( void *id
, void *obj
,
80 // all session attributes default to return invalid
81 ret
.kind
= Sim_Val_Invalid
;
85 set_error_t
ruby_session_set( void *id
, void *obj
,
86 attr_value_t
*val
, attr_value_t
*idx
) {
87 const char *command
= (const char *) id
;
88 // Add new ruby commands to this function
90 #if 0 // Eventually add these commands back in
91 if (!strcmp(command
, "dump-stats" ) ) {
92 char* filename
= (char*) val
->u
.string
;
93 if(strcmp(filename
, "")){
94 ruby_dump_stats(filename
);
96 ruby_dump_stats(NULL
);
99 } else if (!strcmp(command
, "dump-short-stats" ) ) {
100 char* filename
= (char*) val
->u
.string
;
101 if(strcmp(filename
, "")){
102 ruby_dump_short_stats(filename
);
104 ruby_dump_short_stats(NULL
);
107 } else if (!strcmp(command
, "periodic-stats-file" ) ) {
108 char* filename
= (char*) val
->u
.string
;
109 ruby_set_periodic_stats_file(filename
);
111 } else if (!strcmp(command
, "periodic-stats-interval" ) ) {
112 int interval
= val
->u
.integer
;
113 ruby_set_periodic_stats_interval(interval
);
115 } else if (!strcmp(command
, "clear-stats" ) ) {
118 } else if (!strcmp(command
, "debug-verb" ) ) {
119 char* new_verbosity
= (char*) val
->u
.string
;
120 ruby_change_debug_verbosity(new_verbosity
);
122 } else if (!strcmp(command
, "debug-filter" ) ) {
123 char* new_debug_filter
= (char*) val
->u
.string
;
124 ruby_change_debug_filter(new_debug_filter
);
126 } else if (!strcmp(command
, "debug-output-file" ) ) {
127 char* new_filename
= (char*) val
->u
.string
;
128 ruby_set_debug_output_file(new_filename
);
130 } else if (!strcmp(command
, "debug-start-time" ) ) {
131 char* new_start_time
= (char*) val
->u
.string
;
132 ruby_set_debug_start_time(new_start_time
);
134 } else if (!strcmp(command
, "load-caches" ) ) {
135 char* filename
= (char*) val
->u
.string
;
136 ruby_load_caches(filename
);
138 } else if (!strcmp(command
, "save-caches" ) ) {
139 char* filename
= (char*) val
->u
.string
;
140 ruby_save_caches(filename
);
142 } else if (!strcmp(command
, "dump-cache" ) ) {
143 int cpuNumber
= val
->u
.integer
;
144 ruby_dump_cache(cpuNumber
);
146 } else if (!strcmp(command
, "dump-cache-data" ) ) {
147 int cpuNumber
= val
->u
.list
.vector
[0].u
.integer
;
148 char *filename
= (char*) val
->u
.list
.vector
[1].u
.string
;
149 ruby_dump_cache_data( cpuNumber
, filename
);
151 } else if (!strcmp(command
, "tracer-output-file" ) ) {
152 char* new_filename
= (char*) val
->u
.string
;
153 ruby_set_tracer_output_file(new_filename
);
155 } else if (!strcmp(command
, "xact-visualizer-file" ) ) {
156 char* new_filename
= (char*) val
->u
.string
;
157 ruby_xact_visualizer_file(new_filename
);
160 fprintf( stderr
, "error: unrecognized command: %s\n", command
);
162 return Sim_Set_Illegal_Value
;
165 static initvar_t
*ruby_initvar_obj
= NULL
;
167 //***************************************************************************
168 static void init_generate_values( void )
170 /* update generated values, based on input configuration */
173 //***************************************************************************
174 void init_variables( void )
176 // allocate the "variable initialization" package
177 ruby_initvar_obj
= new initvar_t( "ruby", "../../../ruby/",
178 global_default_param
,
180 &init_generate_values
,
185 void init_simulator()
187 // Set things to NULL to make sure we don't de-reference them
188 // without a seg. fault.
191 g_eventQueue_ptr
= NULL
;
193 cout
<< "Ruby Timing Mode" << endl
;
194 #ifndef MULTIFACET_NO_OPT_WARN
195 cerr
<< "Warning: optimizations not enabled." << endl
;
199 // LUKE - if we don't set the default SMT threads in condor scripts,
201 if(g_NUM_SMT_THREADS
== 0){
202 g_NUM_SMT_THREADS
= 1;
204 if(g_NUM_PROCESSORS
== 0){
205 //only set to default if value not set in condor scripts
206 // Account for SMT systems also
207 g_NUM_PROCESSORS
= SIMICS_number_processors()/g_NUM_SMT_THREADS
;
213 g_debug_ptr
= new Debug( DEBUG_FILTER_STRING
,
214 DEBUG_VERBOSITY_STRING
,
216 DEBUG_OUTPUT_FILENAME
);
218 cout
<< "Creating event queue..." << endl
;
219 g_eventQueue_ptr
= new EventQueue
;
220 cout
<< "Creating event queue done" << endl
;
222 cout
<< "Creating system..." << endl
;
223 cout
<< " Processors: " << RubyConfig::numberOfProcessors() << endl
;
225 g_system_ptr
= new System
;
226 cout
<< "Creating system done" << endl
;
228 // if opal is loaded, its static interface object (inst) will be non-null,
229 // and the opal object needs to be notified that ruby is now loaded.
230 // "1" indicates a load and should be replaced with an enumerated type.
231 if (OpalInterface::inst
!= NULL
) {
232 OpalInterface::inst
->notify( 1 );
235 #ifdef CONTIGUOUS_ADDRESSES
237 cout
<< "Establishing Contiguous Address Space Mappings..." << flush
;
238 g_p_ca_translator
= new ContiguousAddressTranslator();
239 assert(g_p_ca_translator
!=NULL
);
240 if(g_p_ca_translator
->AddressesAreContiguous()) {
241 cout
<< "Physical Memory Addresses are already contiguous." << endl
;
242 delete g_p_ca_translator
;
243 g_p_ca_translator
= NULL
;
245 cout
<< "Done." << endl
;
248 g_p_ca_translator
= NULL
;
250 #endif // #ifdef CONTIGUOUS_ADDRESSES
252 cout
<< "Ruby initialization complete" << endl
;
255 void init_opal_interface( mf_ruby_api_t
*api
)
257 OpalInterface::installInterface( api
);
263 // The "snoop interface" defined by simics allows ruby to see store
264 // data values (from simics). If DATA_BLOCK is defined, we are tracking
265 // data, so we need to install the snoop interface.
266 return ((DATA_BLOCK
== true) || (XACT_MEMORY
));
272 void destroy_simulator()
274 cout
<< "Deleting system..." << endl
;
276 cout
<< "Deleting system done" << endl
;
278 cout
<< "Deleting event queue..." << endl
;
279 delete g_eventQueue_ptr
;
280 cout
<< "Deleting event queue done" << endl
;
285 /*-------------------------------------------------------------------------+
286 | DG: These are the external load and unload hooks that will be called by |
287 | M5 in phase 1 integration, and possibly afterwards, too. |
288 +-------------------------------------------------------------------------*/