- add hack for firmware boot in JIT mode (JIT block size change to 12 until finish firmware boot process);
This commit is contained in:
mtabachenko 2013-08-23 14:31:06 +00:00
parent c739c7ab32
commit d5ccf2939c
7 changed files with 50 additions and 36 deletions

View File

@ -4193,6 +4193,11 @@ void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val)
#endif
//The NDS7 register can be written to only from code executed in BIOS.
if (NDS_ARM7.instruct_adr > 0x3FFF) return;
#ifdef HAVE_JIT
// hack for firmware boot in JIT mode
if (CommonSettings.UseExtFirmware && CommonSettings.BootFromFirmware && firmware->loaded() && val == 1)
CommonSettings.jit_max_block_size = saveBlockSizeJIT;
#endif
break;
case REG_HALTCNT:

View File

@ -2535,13 +2535,16 @@ void NDS_Reset()
}
firmware = new CFIRMWARE();
// TODO: fw_success should be global
bool fw_success = firmware->load();
firmware->load();
//the firmware can't be booted without the roms, for the following reasons:
//TBD
if (NDS_ARM7.BIOS_loaded && NDS_ARM9.BIOS_loaded && CommonSettings.BootFromFirmware && fw_success)
if (NDS_ARM7.BIOS_loaded && NDS_ARM9.BIOS_loaded && CommonSettings.BootFromFirmware && firmware->loaded())
{
#ifdef HAVE_JIT
// hack for firmware boot in JIT mode
CommonSettings.jit_max_block_size = 12;
#endif
//crazymax: how would it have got whacked? dont think we need this
//gameInfo.restoreSecureArea();
@ -2599,7 +2602,7 @@ void NDS_Reset()
//EDIT - whats this firmware and how is it relating to the dummy firmware below
//how do these even get used? what is the purpose of unpack and why is it not used by the firmware boot process?
if (CommonSettings.UseExtFirmware && fw_success)
if (CommonSettings.UseExtFirmware && firmware->loaded())
{
firmware->unpack();
firmware->loadSettings();
@ -2721,32 +2724,32 @@ void NDS_Reset()
NDS_ARM9.R[13] = NDS_ARM9.R13_usr;
//n.b.: im not sure about all these, I dont know enough about arm9 svc/irq/etc modes
//and how theyre named in desmume to match them up correctly. i just guessed.
//--------------------------------
//setup the homebrew argv
//this is useful for nitrofs apps which are emulating themselves via cflash
//struct __argv {
// int argvMagic; //!< argv magic number, set to 0x5f617267 ('_arg') if valid
// char *commandLine; //!< base address of command line, set of null terminated strings
// int length; //!< total length of command line
// int argc; //!< internal use, number of arguments
// char **argv; //!< internal use, argv pointer
//};
std::string rompath = "fat:/" + path.RomName;
const u32 kCommandline = 0x027E0000;
//const u32 kCommandline = 0x027FFF84;
//
_MMU_write32<ARMCPU_ARM9>(0x02FFFE70, 0x5f617267);
_MMU_write32<ARMCPU_ARM9>(0x02FFFE74, kCommandline); //(commandline starts here)
_MMU_write32<ARMCPU_ARM9>(0x02FFFE78, rompath.size()+1);
//0x027FFF7C (argc)
//0x027FFF80 (argv)
for(size_t i=0;i<rompath.size();i++)
_MMU_write08<ARMCPU_ARM9>(kCommandline+i, rompath[i]);
_MMU_write08<ARMCPU_ARM9>(kCommandline+rompath.size(), 0);
//--------------------------------
}
//--------------------------------
//setup the homebrew argv
//this is useful for nitrofs apps which are emulating themselves via cflash
//struct __argv {
// int argvMagic; //!< argv magic number, set to 0x5f617267 ('_arg') if valid
// char *commandLine; //!< base address of command line, set of null terminated strings
// int length; //!< total length of command line
// int argc; //!< internal use, number of arguments
// char **argv; //!< internal use, argv pointer
//};
std::string rompath = "fat:/" + path.RomName;
const u32 kCommandline = 0x027E0000;
//const u32 kCommandline = 0x027FFF84;
//
_MMU_write32<ARMCPU_ARM9>(0x02FFFE70, 0x5f617267);
_MMU_write32<ARMCPU_ARM9>(0x02FFFE74, kCommandline); //(commandline starts here)
_MMU_write32<ARMCPU_ARM9>(0x02FFFE78, rompath.size()+1);
//0x027FFF7C (argc)
//0x027FFF80 (argv)
for(size_t i=0;i<rompath.size();i++)
_MMU_write08<ARMCPU_ARM9>(kCommandline+i, rompath[i]);
_MMU_write08<ARMCPU_ARM9>(kCommandline+rompath.size(), 0);
//--------------------------------
delete header;

View File

@ -16,8 +16,8 @@
*/
// Games with NAND Flash:
// - Ore/WarioWare D.I.Y. - 8Mbit
// - Daigassou! Band Brothers DX - 64MBit
// - Ore/WarioWare D.I.Y. - 128Mbit
// - Daigassou! Band Brothers DX - 64MBit (NAND?)
// Ore/WarioWare D.I.Y. - chip: SAMSUNG 004
// KLC2811ANB-P204

View File

@ -77,6 +77,8 @@ using namespace AsmJit;
#ifdef MAPPED_JIT_FUNCS
CACHE_ALIGN JIT_struct JIT;
u32 saveBlockSizeJIT = 0;
uintptr_t *JIT_struct::JIT_MEM[2][0x4000] = {{0}};
static uintptr_t *JIT_MEM[2][32] = {
@ -4219,10 +4221,12 @@ void arm_jit_reset(bool enable)
scratchptr = scratchpad;
#endif
printf("CPU mode: %s\n", enable?"JIT":"Interpreter");
saveBlockSizeJIT = CommonSettings.jit_max_block_size;
if (enable)
{
printf("JIT: max block size %d instruction(s)\n", CommonSettings.jit_max_block_size);
#ifdef MAPPED_JIT_FUNCS
//these pointers are allocated by asmjit and need freeing

View File

@ -65,5 +65,6 @@ extern uintptr_t compiled_funcs[];
#define JIT_MAPPED(adr, PROCNUM) true
#endif
extern u32 saveBlockSizeJIT;
#endif

View File

@ -303,6 +303,7 @@ bool CFIRMWARE::load()
std::string extFilePath = CFIRMWARE::GetExternalFilePath();
strncpy(MMU.fw.userfile, extFilePath.c_str(), MAX_PATH);
successLoad = true;
return true;
}

View File

@ -40,8 +40,10 @@ private:
u32 decrypt(const u8 *in, u8* &out);
u32 decompress(const u8 *in, u8* &out);
bool successLoad;
public:
CFIRMWARE(): size9(0), size7(0), ARM9bootAddr(0), ARM7bootAddr(0), patched(0), userDataAddr(0x3FE00) {};
CFIRMWARE(): size9(0), size7(0), ARM9bootAddr(0), ARM7bootAddr(0), patched(0), userDataAddr(0x3FE00), successLoad(false) {};
bool load();
bool unpack();
@ -50,10 +52,8 @@ public:
static std::string GetExternalFilePath();
u32 getID()
{
return header.fw_identifier;
}
u32 getID() { return header.fw_identifier; }
bool loaded() { return successLoad; }
struct HEADER
{