Esempio n. 1
0
void mem_Term(void)
{
	MMU_term();
	sh4_mmr_term();
	sh4_area0_Term();

	//write back Flash/SRAM
#ifdef _WIN32
	SaveRomFiles(get_writable_data_path("data\\"));
#else
	SaveRomFiles(get_writable_data_path("data/"));
#endif
	
	//mem_b.Term(); // handled by vmem

	//vmem
	_vmem_term();
}
Esempio n. 2
0
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_config(JNIEnv *env,jobject obj,jstring dirName)
{
  // Set home directory based on User config
  const char* D = dirName? env->GetStringUTFChars(dirName,0):0;
	set_user_config_dir(D);
	set_user_data_dir(D);
	printf("Config dir is: %s\n", get_writable_config_path("/").c_str());
	printf("Data dir is:   %s\n", get_writable_data_path("/").c_str());
  env->ReleaseStringUTFChars(dirName,D);
}
Esempio n. 3
0
void dc_term()
{
	sh4_cpu.Term();
	plugins_Term();
	_vmem_release();

#ifndef _ANDROID
	SaveSettings();
#endif
	SaveRomFiles(get_writable_data_path("/data/"));
}
Esempio n. 4
0
void mem_Term()
{
	MMU_term();
	sh4_mmr_term();
	sh4_area0_Term();

	//write back Flash/SRAM
	SaveRomFiles(get_writable_data_path("/data/"));
	
	//mem_b.Term(); // handled by vmem

	//vmem
	_vmem_term();
}
Esempio n. 5
0
string get_readonly_data_path(const string& filename)
{
    string user_filepath = get_writable_data_path(filename);
    if(file_exists(user_filepath))
    {
        return user_filepath;
    }

    string filepath;
    for (unsigned int i = 0; i < system_data_dirs.size(); i++) {
        filepath = system_data_dirs[i] + filename;
        if (file_exists(filepath))
        {
            return filepath;
        }
    }

    // Not found, so we return the user variant
    return user_filepath;
}
Esempio n. 6
0
static void* profiler_main(void *ptr)
{
	FILE* prof_out;
	char line[512];

	sprintf(line, "/%d.reprof", tick_count);

		string logfile=get_writable_data_path(line);


		printf("Profiler thread logging to -> %s\n", logfile.c_str());

		prof_out = fopen(logfile.c_str(), "wb");
		if (!prof_out)
		{
			printf("Failed to open profiler file\n");
			return 0;
		}

		set<string> libs;

		prof_head(prof_out, "vaddr", "");
		FILE* maps = fopen("/proc/self/maps", "r");
		while (!feof(maps))
		{
			fgets(line, 512, maps);
			fputs(line, prof_out);

			if (strstr(line, ".so"))
			{
				char file[512];
				file[0] = 0;
				sscanf(line, "%*x-%*x %*s %*x %*x:%*x %*d %s\n", file);
				if (strlen(file))
					libs.insert(file);
			}
		}

		//Write map file
		prof_head(prof_out, ".map", "");
		fwrite(syms_ptr, 1, syms_len, prof_out);

		//write exports from .so's
		for (set<string>::iterator it = libs.begin(); it != libs.end(); it++)
		{
			elf_syms(prof_out, it->c_str());
		}

		//Write shrec syms file !
		prof_head(prof_out, "jitsym", "SH4");
		
		#if FEAT_SHREC != DYNAREC_NONE
		sh4_jitsym(prof_out);
		#endif

		//Write arm7rec syms file ! -> to do
		//prof_head(prof_out,"jitsym","ARM7");

		prof_head(prof_out, "samples", prof_wait);

		do
		{
			tick_count++;
			// printf("Sending SIGPROF %08X %08X\n",thread[0],thread[1]);
			for (int i = 0; i < 2; i++) pthread_kill(thread[i], SIGPROF);
			// printf("Sent SIGPROF\n");
			usleep(prof_wait);
			// fwrite(&prof_address[0],1,sizeof(prof_address[0])*2,prof_out);
			fprintf(prof_out, "%p %p\n", prof_address[0], prof_address[1]);

			if (!(tick_count % 10000))
			{
				printf("Profiler: %d ticks, flusing ..\n", tick_count);
				fflush(prof_out);
			}
		} while (prof_run);

		fclose(maps);
		fclose(prof_out);
    
    return 0;
}
Esempio n. 7
0
void print_blocks()
{
	FILE* f=0;

	if (print_stats)
	{
		f=fopen(get_writable_data_path("/blkmap.lst").c_str(),"w");
		print_stats=0;

		printf("Writing blocks to %p\n",f);
	}

	for (size_t i=0;i<all_blocks.size();i++)
	{
		RuntimeBlockInfo* blk=all_blocks[i];

		if (f)
		{
			fprintf(f,"block: %08X\n",blk);
			fprintf(f,"addr: %08X\n",blk->addr);
			fprintf(f,"hash: %s\n",blk->hash());
			fprintf(f,"hash_rloc: %s\n",blk->hash(false,true));
			fprintf(f,"code: %08X\n",blk->code);
			fprintf(f,"runs: %d\n",blk->runs);
			fprintf(f,"BlockType: %d\n",blk->BlockType);
			fprintf(f,"NextBlock: %08X\n",blk->NextBlock);
			fprintf(f,"BranchBlock: %08X\n",blk->BranchBlock);
			fprintf(f,"pNextBlock: %08X\n",blk->pNextBlock);
			fprintf(f,"pBranchBlock: %08X\n",blk->pBranchBlock);
			fprintf(f,"guest_cycles: %d\n",blk->guest_cycles);
			fprintf(f,"guest_opcodes: %d\n",blk->guest_opcodes);
			fprintf(f,"host_opcodes: %d\n",blk->host_opcodes);
			fprintf(f,"il_opcodes: %d\n",blk->oplist.size());

			u32 hcode=0;
			s32 gcode=-1;
			u8* pucode=(u8*)blk->code;

			size_t j=0;
			
			fprintf(f,"{\n");
			for (;j<blk->oplist.size();j++)
			{
				shil_opcode* op=&all_blocks[i]->oplist[j];
				fprint_hex(f,"//h:",pucode,hcode,op->host_offs);

				if (gcode!=op->guest_offs)
				{
					gcode=op->guest_offs;
					u32 rpc=blk->addr+gcode;
					u16 op=ReadMem16(rpc);

					char temp[128];
					OpDesc[op]->Dissasemble(temp,rpc,op);

					fprintf(f,"//g:%s\n",temp);
				}

				string s=op->dissasm();
				fprintf(f,"//il:%d:%d:%s\n",op->guest_offs,op->host_offs,s.c_str());
			}
			
			fprint_hex(f,"//h:",pucode,hcode,blk->host_code_size);

			fprintf(f,"}\n");
		}

		all_blocks[i]->runs=0;
	}

	if (f) fclose(f);
}