Exemplo n.º 1
0
void SIM_start(void){
	sky_pref_t *pref;
	/* get the current preference for simulator */
	pref = get_skyeye_pref();
	skyeye_config_t* config = get_current_config();
	if(pref->conf_filename)
		skyeye_read_config(pref->conf_filename);

	if(config->arch == NULL){
		skyeye_log(Error_log, __FUNCTION__, "Should provide valid arch option in your config file.\n");
		return;
	}
	generic_arch_t *arch_instance = get_arch_instance(config->arch->arch_name);

	if(config->mach == NULL){
		skyeye_log(Error_log, __FUNCTION__, "Should provide valid mach option in your config file.\n");
		return;
	}

	arch_instance->init();
	
	/* reset all the memory */
	mem_reset();

	config->mach->mach_init(arch_instance, config->mach);
	/* reset current arch_instanc */
	arch_instance->reset();
	/* reset all the values of mach */
	io_reset(arch_instance);
	
	if(pref->exec_file){
		exception_t ret;
		/* 
		 * If no relocation is indicated, we will load elf file by 
		 * virtual address
		 */
		if((((~pref->exec_load_mask) & pref->exec_load_base) == 0x0) &&
			(arch_instance->mmu_write != NULL))
			ret = load_elf(pref->exec_file, Virt_addr);
		else
			ret = load_elf(pref->exec_file, Phys_addr);
	}

	/* set pc from config */
	generic_address_t pc = (config->start_address & pref->exec_load_mask)|pref->exec_load_base; 
	skyeye_log(Info_log, __FUNCTION__, "Set PC to the address 0x%x\n", pc);
	arch_instance->set_pc(pc);

	/* Call bootmach callback */
	exec_callback(Bootmach_callback, arch_instance);	

	pthread_t id;
	create_thread(skyeye_loop, arch_instance, &id);
	
	/* 
	 * At this time, if we set conf file, then we parse it
	 * Or do it later.
	 */

	/*
	if(pref->conf_filename)
		skyeye_read_config(pref->conf_filename);
	*/
#if 0	
	else{
		/* try to run in batch mode */
		if(skyeye_read_config(pref->conf_filename) == No_exp){
Exemplo n.º 2
0
/**
 *  Initialize all the gloval variable
 */
static int
init ()
{
	static int done = 0;
	int ret = -1;
	if (!done) {
		done = 1;
		/*some option should init before read config. e.g. uart option. */
#if 0 /*move to common/ctrl related function */
		initialize_all_devices ();
		initialize_all_arch ();
		/* parse skyeye.conf to set skyeye_config */
		skyeye_option_init (&skyeye_config);
		if((ret = skyeye_read_config()) < 0)
			return ret;

#endif

#if 0
		/* we should check if some members of skyeye_config is initialized */
		if(!skyeye_config.arch){
			fprintf(stderr, "arch is not initialization or you have not provide arch option in skyeye.conf.\n");
                        skyeye_exit(-1);
		}
		if(!skyeye_config.mach){
			fprintf(stderr, "mach is not initialization or you have not provide mach option in skyeye.conf.\n");
			skyeye_exit(-1);
		}	
#endif

#if 0 /*move to module loading stage */
		/* initialize register type for gdb server */
		if((ret = init_register_type()) < 0)
			return ret;/* Failed to initialize register type */
#endif

#if 0
		arch_instance =
			(generic_arch_t *) malloc (sizeof (generic_arch_t));
		if (!arch_instance) {
			printf ("malloc error!\n");
			return -1;
		}
		arch_instance->init = skyeye_config.arch->init;
		arch_instance->reset = skyeye_config.arch->reset;
		arch_instance->step_once = skyeye_config.arch->step_once;
		arch_instance->set_pc = skyeye_config.arch->set_pc;
		arch_instance->get_pc = skyeye_config.arch->get_pc;
		arch_instance->ICE_write_byte = skyeye_config.arch->ICE_write_byte;
		arch_instance->ICE_read_byte = skyeye_config.arch->ICE_read_byte;

		arch_instance->init ();
		arch_instance->reset ();
		arch_instance->big_endian = Big_endian;
#endif
#if 0 /* move to module loading stage */
		skyeye_uart_converter_setup();
#endif
#if 0
		if(skyeye_config.code_cov.prof_on)
			cov_init(skyeye_config.code_cov.start, skyeye_config.code_cov.end);
#endif

#if 0
		mem_reset(); /* initialize of memory module */
#endif
	}
	return 1;
}