mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
thumbコード対応
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/branches/20101202_Majikon_Patch@2989 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
1439b84686
commit
362babd945
@ -27,15 +27,17 @@
|
||||
#define MAJIKON_PATCH_ADDR 0x02fff800
|
||||
|
||||
#ifdef MAJIKON_APP_CHECK_BY_CARD_PULLOUT_FUNC
|
||||
// カード抜け関数チェック用
|
||||
#define MAJIKON_APP_TARGET_COMMAND_ARM 0xE12FFF1E // [bx lr] 命令
|
||||
#define MAJIKON_APP_TARGET_COMMAND_THUMB 0x4718 // [bx r3] 命令
|
||||
#define TARGET_ARM_CODE_MAX_SIZE 0x40
|
||||
#define TARGET_THUMB_CODE_MAX_SIZE 0x80
|
||||
#define TARGET_ARM_CODE_NUM 8
|
||||
#define TARGET_ARM_CODE_NUM 7
|
||||
#define TARGET_THUMB_CODE_NUM 1
|
||||
#else
|
||||
// _start関数チェック用
|
||||
#define MAJIKON_APP_TARGET_COMMAND_ARM 0xE12FFF11 // [bx r1] 命令
|
||||
#define TARGET__ARM_CODE_MAX_SIZE 0x48
|
||||
#define TARGET_ARM_CODE_MAX_SIZE 0x48
|
||||
#define TARGET_ARM_CODE_NUM 6
|
||||
#endif
|
||||
|
||||
@ -52,10 +54,13 @@ u32 patch_jump_arm[] =
|
||||
};
|
||||
|
||||
#ifdef MAJIKON_APP_CHECK_BY_CARD_PULLOUT_FUNC
|
||||
// 注:dcdで定義される値は4バイトアライメントがとれているところに置かないとデータがずれる
|
||||
u16 patch_jump_thumb[] =
|
||||
{
|
||||
0xFFFF,
|
||||
0xFFFF
|
||||
{
|
||||
0x4801, // ldr r0, [pc, #4] ※#2が指定できないのでnopを入れて調整する
|
||||
0x4700, // bx r0
|
||||
0x46C0, // nop nop
|
||||
0xF800, 0x023F // dcd MAJIKON_PATCH_ADDR;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -232,7 +237,7 @@ u32 target_code_list_arm[TARGET_ARM_CODE_NUM][TARGET_ARM_CODE_MAX_SIZE] =
|
||||
0x1afffff7, 0xe8bd40f8, 0xe12fff1e, 0x03809420,
|
||||
0x027ffc40, 0x038070b4,
|
||||
},
|
||||
|
||||
/*
|
||||
// デバッグ用
|
||||
{
|
||||
0xE92D40F8, 0xE59F00E4, 0xE5900004, 0xE3500000,
|
||||
@ -252,7 +257,7 @@ u32 target_code_list_arm[TARGET_ARM_CODE_NUM][TARGET_ARM_CODE_MAX_SIZE] =
|
||||
0xE3500000, 0x1AFFFFF7, 0xE8BD40F8, 0xE12FFF1E,
|
||||
0x0380C6A0, 0x03809EA8, 0x02FFFC3C
|
||||
},
|
||||
|
||||
*/
|
||||
#else
|
||||
|
||||
// crt0.cの_start関数を検出する
|
||||
|
||||
@ -153,7 +153,6 @@ static u32 SearchBinaryArm( void )
|
||||
{
|
||||
elem[i] = (u32)(p - target_code_list_arm[i]) * sizeof(u32);
|
||||
}
|
||||
OS_TPrintf("code %d size is 0x%x (%d)\n", i, elem[i], elem[i]);
|
||||
}
|
||||
|
||||
for( i = 0; i < TARGET_ARM_CODE_NUM; i++ )
|
||||
@ -164,7 +163,6 @@ static u32 SearchBinaryArm( void )
|
||||
u32 hit = 0;
|
||||
BOOL isFinish = FALSE;
|
||||
|
||||
OS_TPrintf("search code %d start\n", i);
|
||||
while( search_size >= elem[i] || hit )
|
||||
{
|
||||
if( *(u32 *)current != *codep )
|
||||
@ -210,16 +208,12 @@ static u32 SearchBinaryArm( void )
|
||||
OS_TPrintf("Match!!\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
OS_TPrintf("No Match...\n");
|
||||
}
|
||||
}
|
||||
|
||||
OS_TPrintf("\ntarget address : 0x%08x\n", target_command_address);
|
||||
OS_TPrintf("=====================================\n");
|
||||
|
||||
return (target_command_address - sizeof(u32)); // 埋め込むコードは2命令あるので、1つ前のアドレスを返す
|
||||
return target_command_address;
|
||||
}
|
||||
|
||||
|
||||
@ -240,9 +234,8 @@ static u32 SearchBinaryThumb( void )
|
||||
p = (u32 *)MI_CpuFind32( target_code_list_thumb[i], 0x0, TARGET_THUMB_CODE_MAX_SIZE * sizeof(u16) );
|
||||
if( p )
|
||||
{
|
||||
elem[i] = (u32)(p - (u32 *)target_code_list_thumb[i]) * sizeof(u16);
|
||||
elem[i] = (u32)((u16 *)p - target_code_list_thumb[i]) * sizeof(u16);
|
||||
}
|
||||
OS_TPrintf("code %d size is 0x%x (%d)\n", i, elem[i], elem[i]);
|
||||
}
|
||||
|
||||
for( i = 0; i < TARGET_THUMB_CODE_NUM; i++ )
|
||||
@ -299,17 +292,12 @@ static u32 SearchBinaryThumb( void )
|
||||
OS_TPrintf("Match!!\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
OS_TPrintf("No Match...\n");
|
||||
}
|
||||
}
|
||||
|
||||
OS_TPrintf("\ntarget address : 0x%08x\n", target_command_address);
|
||||
OS_TPrintf("=====================================\n");
|
||||
|
||||
// [TODO] 2命令前でいいの?要確認。
|
||||
return (target_command_address - sizeof(u16)); // 埋め込むコードは2命令あるので、1つ前のアドレスを返す
|
||||
return target_command_address;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -334,7 +322,7 @@ BOOL BOOT_WaitStart( void )
|
||||
target_address_arm = SearchBinaryArm();
|
||||
|
||||
#ifdef MAJIKON_APP_CHECK_BY_CARD_PULLOUT_FUNC
|
||||
if( !target_address_arm )
|
||||
if( target_address_arm == 0x0 )
|
||||
{
|
||||
target_address_thumb = SearchBinaryThumb();
|
||||
}
|
||||
@ -346,7 +334,8 @@ BOOL BOOT_WaitStart( void )
|
||||
MI_CpuCopy8( patch_core_arm, (u32 *)MAJIKON_PATCH_ADDR, sizeof(patch_core_arm));
|
||||
|
||||
// パッチに飛ばす処理埋め込み
|
||||
MI_CpuCopy8( patch_jump_arm, (u32 *)target_address_arm, sizeof(patch_jump_arm));
|
||||
// 埋め込むコードは2命令あるので、1つ前のアドレスを返す
|
||||
MI_CpuCopy8( patch_jump_arm, (u32 *)(target_address_arm - sizeof(u32)), sizeof(patch_jump_arm));
|
||||
}
|
||||
#ifdef MAJIKON_APP_CHECK_BY_CARD_PULLOUT_FUNC
|
||||
else if( target_address_thumb )
|
||||
@ -355,6 +344,11 @@ BOOL BOOT_WaitStart( void )
|
||||
MI_CpuCopy8( patch_core_arm, (u32 *)MAJIKON_PATCH_ADDR, sizeof(patch_core_arm));
|
||||
|
||||
// パッチに飛ばす処理埋め込み
|
||||
// dcd部分が4バイトアライメントとれてないとダメなので調整。
|
||||
if( !(target_address_thumb % 0x4) )
|
||||
{
|
||||
target_address_thumb -= 0x2;
|
||||
}
|
||||
MI_CpuCopy8( patch_jump_thumb, (u32 *)target_address_thumb, sizeof(patch_jump_thumb));
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user