Example #1
0
static struct agent *agent_by_tid(struct agent_q *q, int tid)
{
	struct agent *a = agent_by_tid_or_null(q, tid);
	if (a == NULL) {
		conf_object_t *cpu = SIM_get_object("cpu0");
		char *stack = stack_trace(cpu, GET_CPU_ATTR(cpu, eip), -1);
		lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "TID %d isn't in the "
			 "right queue; probably incorrect annotations?\n", tid);
		lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "Current stack: %s\n"
			 COLOUR_DEFAULT, stack);
		assert(0);
	}
	return a;
}
Example #2
0
/* A more user-friendly way of asserting NO_ACTION. */
static void assert_no_action(struct sched_state *s, const char *new_act)
{
	bool failed = false;
	CHECK_NOT_ACTION(failed, s, handling_timer);
	CHECK_NOT_ACTION(failed, s, context_switch);
	CHECK_NOT_ACTION(failed, s, forking);
	CHECK_NOT_ACTION(failed, s, sleeping);
	CHECK_NOT_ACTION(failed, s, vanishing);
	CHECK_NOT_ACTION(failed, s, readlining);
	if (failed) {
		conf_object_t *cpu = SIM_get_object("cpu0");
		char *stack = stack_trace(cpu, GET_CPU_ATTR(cpu, eip),
					  s->cur_agent->tid);
		lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "While trying to do %s;"
			 " probably incorrect annotations?\n", new_act);
		lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "Current stack: %s\n",
			 stack);
		assert(0);
	}
}
Example #3
0
conf_object_t *get_symtable()
{
	conf_object_t *cell0_context = SIM_get_object("cell0_context");
	if (cell0_context == NULL) {
		lsprintf(ALWAYS, "WARNING: couldn't get cell0_context\n");
		return NULL;
	}
	attr_value_t table = SIM_get_attribute(cell0_context, "symtable");
	if (!SIM_attr_is_object(table)) {
		SIM_free_attribute(table);
		// ugh, wtf simics
		table = SIM_get_attribute(cell0_context, "symtable");
		if (!SIM_attr_is_object(table)) {
			SIM_free_attribute(table);
			lsprintf(ALWAYS, "WARNING: cell0_context.symtable not an obj\n");
			assert(0);
			return NULL;
		}
	}
	conf_object_t *symtable = SIM_attr_object(table);
	SIM_free_attribute(table);
	return symtable;
}
Example #4
0
static void agent_deschedule(struct sched_state *s, int tid)
{
	struct agent *a = agent_by_tid_or_null(&s->rq, tid);
	if (a != NULL) {
		Q_REMOVE(&s->rq, a, nobe);
		Q_INSERT_FRONT(&s->dq, a, nobe);
	/* If it's not on the runqueue, we must have already special-case moved
	 * it off in the thread-change event. */
	} else if (agent_by_tid_or_null(&s->sq, tid) == NULL) {
		/* Either it's on the sleep queue, or it vanished. */
		if (agent_by_tid_or_null(&s->dq, tid) != NULL) {
			conf_object_t *cpu = SIM_get_object("cpu0");
			char *stack = stack_trace(cpu, GET_CPU_ATTR(cpu, eip),
						  s->cur_agent->tid);
			lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "TID %d is "
				 "already off the runqueue at tell_off_rq(); "
				 "probably incorrect annotations?\n", tid);
			lsprintf(ALWAYS, COLOUR_BOLD COLOUR_RED "Current stack: %s\n"
				 COLOUR_DEFAULT, stack);
			assert(0);
		}
	}
}
Example #5
0
//**************************************************************************
void init_local() {
  class_data_t   ruby_funcs;
  conf_class_t  *ruby_class;
  conf_object_t *ruby_obj;
  attr_value_t   val;
  conf_object_t *phys_mem0;

  /* Initialize and register the class "ruby-class". */
  bzero(&ruby_funcs, sizeof(class_data_t));
  ruby_funcs.new_instance = ruby_new_instance;
  ruby_funcs.delete_instance = NULL;
  ruby_class = SIM_register_class("ruby", &ruby_funcs);

  /* initialize the variable reader: sets all global variables to defaults */
  init_variables();

  /* Initialize and register the timing-model interface */
  ruby_timing_interface = MM_ZALLOC(1, timing_model_interface_t);
  ruby_timing_interface->operate = ruby_operate;
  SIM_register_interface(ruby_class, "timing-model", ruby_timing_interface);

  ruby_obj = SIM_new_object(ruby_class, "ruby0");

  phys_mem0 = SIM_get_object("phys_mem0");

  if(phys_mem0 == NULL) {

    /* Look for an object called "phys_mem" instead */
    SIM_clear_exception();
    phys_mem0 = SIM_get_object("phys_mem");

  }

  if(phys_mem0 == NULL) {
    /* Okay, now we can panic */

#ifndef SIMICS30
    /*
     * Must load a checkpoint BEFORE load-module ruby
     */
    printf("Please load a checkpoint BEFORE executing \"load-module ruby\"\n");
#endif
  
#ifdef SIMICS30
    /*
     * This case arises because of Simics 3.0:
     * Simics 3.0 loads and "digitally signs" modules immediately after compiling them.
     * This raises havoc with Multifacet's modules, since most of them require a checkpoint
     * to be loaded BEFORE the module.
     */
    printf("\033[34;1m\n");
    printf(" /***************************************************************************\\\n");
    printf(" > Physical Memory object cannot be found. If you are NOT compiling Ruby and <\n");
    printf(" > you see this message, something is wrong.                                 <\n");
    printf(" > This message is part of the normal compilation process.                   <\n");
    printf(" \\***************************************************************************/\033[m\n\n");
#endif
    SIM_clear_exception();
    return;
  }

  val.kind = Sim_Val_Object;
  val.u.object = ruby_obj;

  set_error_t install_error = SIM_set_attribute(phys_mem0, "timing_model", &val);

  if (install_error == Sim_Set_Ok) {
    printf( "successful installation of the ruby timing model.\n");
  } else {
    printf( "error installing ruby timing model.\n");
    exit(1);
  }

  /* Initialize the snoop interface if we are tracking values in simics */
  if (init_use_snoop() == 1) {
    ruby_observe_interface = MM_ZALLOC(1, timing_model_interface_t);
    ruby_observe_interface->operate = ruby_observe;
    SIM_register_interface(ruby_class, "snoop-memory", ruby_observe_interface);
    SIM_set_attribute(phys_mem0, "snoop_device", &val);    
  }

  /* init_opal_interface calls to a static function in OpalInterface.C
   * to determine is opal is installed. If it is, it registers itself,
   * and notifies opal that ruby is loaded. Otherwise, it does nothing. */
  opal_interface = MM_ZALLOC(1, mf_ruby_api_t);
  SIM_register_interface(ruby_class, "mf-ruby-api", opal_interface);
  init_opal_interface( opal_interface );

  // register a number of commands
#define RUBY_COMMAND( COMMAND ) \
  SIM_register_attribute( ruby_class, COMMAND,  \
                          initvar_dispatch_get, (void *) COMMAND,  \
                          initvar_dispatch_set, (void *) COMMAND,  \
                          Sim_Attr_Session,  \
                          "See documentation with associated ruby command." )

  RUBY_COMMAND( "init" );
  RUBY_COMMAND( "readparam" );
  RUBY_COMMAND( "saveparam" );
  RUBY_COMMAND( "param" );
  RUBY_COMMAND( "dump-stats" );
  RUBY_COMMAND( "dump-short-stats" );
  RUBY_COMMAND( "periodic-stats-file" );
  RUBY_COMMAND( "periodic-stats-interval" );
  RUBY_COMMAND( "clear-stats" );
  RUBY_COMMAND( "system-recovery" );
  RUBY_COMMAND( "debug-verb" );
  RUBY_COMMAND( "debug-filter" );
  RUBY_COMMAND( "debug-output-file" );
  RUBY_COMMAND( "debug-start-time" );
  RUBY_COMMAND( "set-checkpoint-interval" );
  RUBY_COMMAND( "load-caches" );
  RUBY_COMMAND( "save-caches" );
  RUBY_COMMAND( "dump-cache" );
  RUBY_COMMAND( "dump-cache-data" );
  RUBY_COMMAND( "tracer-output-file" );
  RUBY_COMMAND( "set-procs-per-chip" );
  RUBY_COMMAND( "abort-all" );
  RUBY_COMMAND( "xact-visualizer-file" );
  RUBY_COMMAND( "print-temp" );
  RUBY_COMMAND( "reset-temp" );
  RUBY_COMMAND( "print-reuse" );
  RUBY_COMMAND( "reset-reuse" );


  // Add end_transaction magic callback
  SIM_hap_add_callback("Core_Magic_Instruction", (obj_hap_func_t) magic_instruction_callback, NULL);
#ifdef SPARC
  SIM_hap_add_callback("Core_Exception", (obj_hap_func_t) ctrl_exception_start, NULL);
  SIM_hap_add_callback("Core_Exception_Return", (obj_hap_func_t) ctrl_exception_done, NULL);
  SIM_hap_add_callback("Core_Mode_Change", (obj_hap_func_t) change_mode_callback, NULL); 
  /// for MMU
  SIM_hap_add_callback("MMU_Data_TLB_Demap", (obj_hap_func_t) dtlb_demap_callback, NULL);
  SIM_hap_add_callback("MMU_Data_TLB_Map", (obj_hap_func_t) dtlb_map_callback, NULL);
  SIM_hap_add_callback("MMU_Data_TLB_Overwrite", (obj_hap_func_t) dtlb_overwrite_callback, NULL);
  SIM_hap_add_callback("MMU_Data_TLB_Replace", (obj_hap_func_t) dtlb_replace_callback, NULL);

  // Add callbacks to abort transactions on exceptions in Rock.
  //
  SIM_hap_add_callback("Core_Exception", (obj_hap_func_t) rock_exception_start, (void *) NULL);
  SIM_hap_add_callback("Core_Exception_Return", (obj_hap_func_t) rock_exception_done, (void *) NULL);
  // Add instruction decoder to install handlers for Rock-specific behavior.
  //
  decoder_t* decoder = ATMTP_create_instruction_decoder();
  SIM_register_arch_decoder(decoder, NULL, 0);
#endif

  // CM 2/2003:
  // Note: Please register other callbacks in the appropriate interface file,
  //       instead of here. This module should only register callbacks that
  //       are common to the "Driver" class (parent class to SimicsInterface
  //       and OpalInterface).
  //       If its only used by SimicsInterface, put it in that class.

}