mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
TwlSDK r3040- 対応
FATFS用ヒープの削除 (OS_Alloc全面禁止) Printfをメインメモリに書き出す仕掛けを含めた TitleIDの差し替え git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@361 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
8d4458be8e
commit
76ae04a117
@ -17,14 +17,6 @@
|
|||||||
#include <firm.h>
|
#include <firm.h>
|
||||||
#include <twl/mcu.h>
|
#include <twl/mcu.h>
|
||||||
|
|
||||||
#define FATFS_HEAP_SIZE (1024) // FATFS用ヒープ (サイズ調整必要)
|
|
||||||
|
|
||||||
#define THREAD_PRIO_FS 15
|
|
||||||
#define THREAD_PRIO_FATFS 8
|
|
||||||
#define FS_DMA_NO 3
|
|
||||||
|
|
||||||
static u8 fatfsHeap[FATFS_HEAP_SIZE] __attribute__ ((aligned (32)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
||||||
利用するためには、main.cかどこかに、u32 profile[256]; u32 pf_cnt = 0; を
|
利用するためには、main.cかどこかに、u32 profile[256]; u32 pf_cnt = 0; を
|
||||||
@ -38,17 +30,12 @@ static u8 fatfsHeap[FATFS_HEAP_SIZE] __attribute__ ((aligned (32)));
|
|||||||
#define USE_DEBUG_LED
|
#define USE_DEBUG_LED
|
||||||
|
|
||||||
/*
|
/*
|
||||||
デバッグでアイドルスレッドが必要なときに定義します。
|
PRINT_MEMORY_ADDR を定義すると、そのアドレスからSPrintfを行います(このファイルのみ)
|
||||||
(最終的にいらないはず)
|
FINALROM版でもコードが残るので注意してください。
|
||||||
*/
|
*/
|
||||||
//#define USE_IDLE_THREAD
|
#define PRINT_MEMORY_ADDR 0x02000400
|
||||||
|
|
||||||
|
|
||||||
//#ifdef SDK_FINALROM // FINALROMで無効化
|
|
||||||
//#undef PROFILE_ENABLE
|
|
||||||
//#undef USE_DEBUG_LED
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
#define PROFILE_MAX 16
|
#define PROFILE_MAX 16
|
||||||
u32 profile[PROFILE_MAX];
|
u32 profile[PROFILE_MAX];
|
||||||
@ -67,6 +54,19 @@ static u8 step = 0x80;
|
|||||||
#define SetDebugLED(pattern) ((void)0)
|
#define SetDebugLED(pattern) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PRINT_MEMORY_ADDR
|
||||||
|
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
|
||||||
|
#undef OS_TPrintf
|
||||||
|
#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
|
||||||
|
#undef OS_Panic
|
||||||
|
#define OS_Panic(...) (OS_TPrintf(__VA_ARGS__), OS_Terminate())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define THREAD_PRIO_FATFS 8
|
||||||
|
#define DMA_NO_FATFS 3
|
||||||
|
|
||||||
|
extern void* SDNandContext; /* NAND初期化パラメータ */
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
PreInit
|
PreInit
|
||||||
|
|
||||||
@ -92,6 +92,13 @@ static void PreInit(void)
|
|||||||
*/
|
*/
|
||||||
//if ( MCUi_ReadRegister( MCU_REG_BATTELY ) < 0x02 )
|
//if ( MCUi_ReadRegister( MCU_REG_BATTELY ) < 0x02 )
|
||||||
//if ( MCUi_ReadRegister( MCU_REG_IRQ ) & MCU_IRQ_NO_BATTELY )
|
//if ( MCUi_ReadRegister( MCU_REG_IRQ ) & MCU_IRQ_NO_BATTELY )
|
||||||
|
/*
|
||||||
|
ちゃんとTWLと識別できているかチェック
|
||||||
|
#ifdef USE_DEBUG_LED
|
||||||
|
SetDebugLED(OS_IsRunOnTwl() ? 0xC3 : 0xff);
|
||||||
|
OS_SpinWaitCpuCycles(0x1000000);
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
@ -109,63 +116,6 @@ static void EraseAll(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
|
||||||
FsInit
|
|
||||||
|
|
||||||
FS周りの初期化
|
|
||||||
***************************************************************/
|
|
||||||
extern void* SDNandContext; /* NAND初期化パラメータ */
|
|
||||||
static BOOL FsInit(void)
|
|
||||||
{
|
|
||||||
/* FATFSライブラリ用にカレントヒープに設定 */
|
|
||||||
/* WRAM上のfatfsHeapをメインメモリヒープとして登録している */
|
|
||||||
{
|
|
||||||
OSHeapHandle hh;
|
|
||||||
u8 *lo = (u8*)fatfsHeap;
|
|
||||||
u8 *hi = (u8*)fatfsHeap + FATFS_HEAP_SIZE;
|
|
||||||
//MI_CpuFillFast(fatfsHeap, 0xcccccccc, FATFS_HEAP_SIZE);
|
|
||||||
lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1);
|
|
||||||
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo);
|
|
||||||
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, OS_GetSubPrivArenaLo(), hi);
|
|
||||||
OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3: after OS_CreateHeap
|
|
||||||
PUSH_PROFILE();
|
|
||||||
SetDebugLED(++step); // 0x85
|
|
||||||
|
|
||||||
SDNandContext = &OSi_GetFromFirmAddr()->SDNandContext;
|
|
||||||
|
|
||||||
//FS_Init( FS_DMA_NO ); // just CARD_Init
|
|
||||||
//FS_CreateReadServerThread( THREAD_PRIO_FS ); // just CARD_SetThreadPriority
|
|
||||||
|
|
||||||
if ( !FATFS_Init( FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS ) )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_IDLE_THREAD
|
|
||||||
static void IdleThread(void* arg)
|
|
||||||
{
|
|
||||||
(void)arg;
|
|
||||||
OS_EnableInterrupts();
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
OS_Halt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static OSThread idle;
|
|
||||||
static u32 idleStack[16] ATTRIBUTE_ALIGN(32);
|
|
||||||
static void CreateIdleThread( void )
|
|
||||||
{
|
|
||||||
OS_CreateThread( &idle, IdleThread, NULL, &idleStack[16], sizeof(idleStack), OS_THREAD_PRIORITY_MAX );
|
|
||||||
OS_WakeupThreadDirect( &idle );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void TwlSpMain( void )
|
void TwlSpMain( void )
|
||||||
{
|
{
|
||||||
int fd; // menu file descriptor
|
int fd; // menu file descriptor
|
||||||
@ -195,15 +145,16 @@ void TwlSpMain( void )
|
|||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
if ( !FsInit() )
|
SDNandContext = &OSi_GetFromFirmAddr()->SDNandContext;
|
||||||
|
if ( !FATFS_Init( DMA_NO_FATFS, THREAD_PRIO_FATFS ) )
|
||||||
{
|
{
|
||||||
OS_TPrintf("Failed to call FsInit().\n");
|
OS_TPrintf("Failed to call FATFS_Init().\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4: after FS_Init
|
// 3: after FS_Init
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x86
|
SetDebugLED(++step); // 0x85
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -222,9 +173,9 @@ SetDebugLED(0x02);
|
|||||||
CreateIdleThread();
|
CreateIdleThread();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 5: after PXI
|
// 4: after PXI
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x87
|
SetDebugLED(++step); // 0x86
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -234,9 +185,9 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6: after FS_OpenSrl
|
// 5: after FS_OpenSrl
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x88
|
SetDebugLED(++step); // 0x87
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -246,9 +197,9 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7: after FS_LoadHeader
|
// 6: after FS_LoadHeader
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x89
|
SetDebugLED(++step); // 0x88
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -258,18 +209,18 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8: after PXI
|
// 7: after PXI
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8a
|
SetDebugLED(++step); // 0x89
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
AESi_InitKeysFIRM();
|
AESi_InitKeysFIRM();
|
||||||
AESi_RecvSeed();
|
AESi_RecvSeed();
|
||||||
|
|
||||||
// 9: after AESi_RecvSeed
|
// 8: after AESi_RecvSeed
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8b
|
SetDebugLED(++step); // 0x8a
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -279,9 +230,9 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10: after FS_LoadStatic
|
// 9: after FS_LoadStatic
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8c
|
SetDebugLED(++step); // 0x8b
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -291,12 +242,11 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 11: after PXI
|
// 10: after PXI
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
MI_CpuCopy8( profile, (void*)0x02000080, sizeof(profile) );
|
|
||||||
PXI_RecvID();
|
PXI_RecvID();
|
||||||
OS_TPrintf("\n[ARM7] Begin\n");
|
OS_TPrintf("\n[ARM7] Begin\n");
|
||||||
for (i = 0; i < PROFILE_MAX; i++)
|
for (i = 0; i < PROFILE_MAX; i++)
|
||||||
@ -317,6 +267,7 @@ SetDebugLED(0x02);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SetDebugLED( 0 );
|
SetDebugLED( 0 );
|
||||||
|
|
||||||
PM_BackLightOn( TRUE ); // last chance
|
PM_BackLightOn( TRUE ); // last chance
|
||||||
|
|
||||||
OS_BootFromFIRM();
|
OS_BootFromFIRM();
|
||||||
@ -327,10 +278,10 @@ end:
|
|||||||
EraseAll();
|
EraseAll();
|
||||||
|
|
||||||
// failed
|
// failed
|
||||||
// while (1)
|
|
||||||
{
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
}
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
OS_Terminate();
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ static const u8 rsa_key[128] =
|
|||||||
static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32)));
|
static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32)));
|
||||||
static SVCSignHeapContext acPool;
|
static SVCSignHeapContext acPool;
|
||||||
|
|
||||||
#define MENU_TITLE_ID 0x0001000152434e4cULL
|
#define MENU_TITLE_ID 0x000100014c4e4352ULL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
||||||
@ -49,6 +49,12 @@ static SVCSignHeapContext acPool;
|
|||||||
*/
|
*/
|
||||||
#define PROFILE_ENABLE
|
#define PROFILE_ENABLE
|
||||||
|
|
||||||
|
/*
|
||||||
|
PRINT_MEMORY_ADDR を定義すると、そのアドレスからSPrintfを行います(このファイルのみ)
|
||||||
|
FINALROM版でもコードが残るので注意してください。
|
||||||
|
*/
|
||||||
|
#define PRINT_MEMORY_ADDR 0x02000000
|
||||||
|
|
||||||
//#ifdef SDK_FINALROM // FINALROMで無効化
|
//#ifdef SDK_FINALROM // FINALROMで無効化
|
||||||
//#undef PROFILE_ENABLE
|
//#undef PROFILE_ENABLE
|
||||||
//#endif
|
//#endif
|
||||||
@ -62,6 +68,13 @@ u32 pf_cnt = 0;
|
|||||||
#define PUSH_PROFILE() ((void)0)
|
#define PUSH_PROFILE() ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PRINT_MEMORY_ADDR
|
||||||
|
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
|
||||||
|
#undef OS_TPrintf
|
||||||
|
#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
|
||||||
|
#undef OS_Panic
|
||||||
|
#define OS_Panic(...) (OS_TPrintf(__VA_ARGS__), OS_Terminate())
|
||||||
|
#endif
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
PreInit
|
PreInit
|
||||||
|
|
||||||
@ -246,7 +259,6 @@ PXI_NotifyID( FIRM_PXI_ID_NULL );
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OS_TPrintf("\n[ARM9] End\n");
|
OS_TPrintf("\n[ARM9] End\n");
|
||||||
MI_CpuCopy8( profile, (void*)0x02000000, sizeof(profile) );
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_NULL );
|
PXI_NotifyID( FIRM_PXI_ID_NULL );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -257,10 +269,10 @@ end:
|
|||||||
EraseAll();
|
EraseAll();
|
||||||
|
|
||||||
// failed
|
// failed
|
||||||
// while (1)
|
|
||||||
{
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
}
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
OS_Terminate();
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,14 +18,6 @@
|
|||||||
#include <twl/mcu.h>
|
#include <twl/mcu.h>
|
||||||
#include <twl/aes.h>
|
#include <twl/aes.h>
|
||||||
|
|
||||||
#define FATFS_HEAP_SIZE (1024) // FATFS用ヒープ (サイズ調整必要)
|
|
||||||
|
|
||||||
#define THREAD_PRIO_FS 15
|
|
||||||
#define THREAD_PRIO_FATFS 8
|
|
||||||
#define FS_DMA_NO 3
|
|
||||||
|
|
||||||
static u8 fatfsHeap[FATFS_HEAP_SIZE] __attribute__ ((aligned (32)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
||||||
利用するためには、main.cかどこかに、u32 profile[256]; u32 pf_cnt = 0; を
|
利用するためには、main.cかどこかに、u32 profile[256]; u32 pf_cnt = 0; を
|
||||||
@ -38,9 +30,12 @@ static u8 fatfsHeap[FATFS_HEAP_SIZE] __attribute__ ((aligned (32)));
|
|||||||
*/
|
*/
|
||||||
#define USE_DEBUG_LED
|
#define USE_DEBUG_LED
|
||||||
|
|
||||||
//#ifdef SDK_FINALROM // FINALROMで無効化
|
/*
|
||||||
//#undef PROFILE_ENABLE
|
PRINT_MEMORY_ADDR を定義すると、そのアドレスからSPrintfを行います(このファイルのみ)
|
||||||
//#endif
|
FINALROM版でもコードが残るので注意してください。
|
||||||
|
*/
|
||||||
|
#define PRINT_MEMORY_ADDR 0x02000400
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
#define PROFILE_MAX 16
|
#define PROFILE_MAX 16
|
||||||
@ -60,6 +55,19 @@ static u8 step = 0x80;
|
|||||||
#define SetDebugLED(pattern) ((void)0)
|
#define SetDebugLED(pattern) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PRINT_MEMORY_ADDR
|
||||||
|
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
|
||||||
|
#undef OS_TPrintf
|
||||||
|
#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
|
||||||
|
#undef OS_Panic
|
||||||
|
#define OS_Panic(...) (OS_TPrintf(__VA_ARGS__), OS_Terminate())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define THREAD_PRIO_FATFS 8
|
||||||
|
#define DMA_NO_FATFS 3
|
||||||
|
|
||||||
|
extern void* SDNandContext; /* NAND初期化パラメータ */
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
PreInit
|
PreInit
|
||||||
|
|
||||||
@ -85,6 +93,13 @@ static void PreInit(void)
|
|||||||
*/
|
*/
|
||||||
//if ( MCUi_ReadRegister( MCU_REG_BATTELY ) < 0x02 )
|
//if ( MCUi_ReadRegister( MCU_REG_BATTELY ) < 0x02 )
|
||||||
//if ( MCUi_ReadRegister( MCU_REG_IRQ ) & MCU_IRQ_NO_BATTELY )
|
//if ( MCUi_ReadRegister( MCU_REG_IRQ ) & MCU_IRQ_NO_BATTELY )
|
||||||
|
/*
|
||||||
|
ちゃんとTWLと識別できているかチェック
|
||||||
|
#ifdef USE_DEBUG_LED
|
||||||
|
SetDebugLED(OS_IsRunOnTwl() ? 0xC3 : 0xff);
|
||||||
|
OS_SpinWaitCpuCycles(0x1000000);
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
@ -102,43 +117,6 @@ static void EraseAll(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
|
||||||
FsInit
|
|
||||||
|
|
||||||
FS周りの初期化
|
|
||||||
***************************************************************/
|
|
||||||
extern void* SDNandContext; /* NAND初期化パラメータ */
|
|
||||||
static BOOL FsInit(void)
|
|
||||||
{
|
|
||||||
/* FATFSライブラリ用にカレントヒープに設定 */
|
|
||||||
/* WRAM上のfatfsHeapをメインメモリヒープとして登録している */
|
|
||||||
{
|
|
||||||
OSHeapHandle hh;
|
|
||||||
u8 *lo = (u8*)fatfsHeap;
|
|
||||||
u8 *hi = (u8*)fatfsHeap + FATFS_HEAP_SIZE;
|
|
||||||
lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1);
|
|
||||||
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo);
|
|
||||||
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, OS_GetSubPrivArenaLo(), hi);
|
|
||||||
OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3: after OS_CreateHeap
|
|
||||||
PUSH_PROFILE();
|
|
||||||
SetDebugLED(++step); // 0x85
|
|
||||||
|
|
||||||
SDNandContext = &OSi_GetFromFirmAddr()->SDNandContext;
|
|
||||||
|
|
||||||
//FS_Init( FS_DMA_NO ); // just CARD_Init
|
|
||||||
//FS_CreateReadServerThread( THREAD_PRIO_FS ); // just CARD_SetThreadPriority
|
|
||||||
|
|
||||||
if ( !FATFS_Init( FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS ) )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TwlSpMain( void )
|
void TwlSpMain( void )
|
||||||
{
|
{
|
||||||
InitDebugLED();
|
InitDebugLED();
|
||||||
@ -167,15 +145,16 @@ void TwlSpMain( void )
|
|||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
if ( !FsInit() )
|
SDNandContext = &OSi_GetFromFirmAddr()->SDNandContext;
|
||||||
|
if ( !FATFS_Init( DMA_NO_FATFS, THREAD_PRIO_FATFS ) )
|
||||||
{
|
{
|
||||||
OS_TPrintf("Failed to call FsInit().\n");
|
OS_TPrintf("Failed to call FATFS_Init().\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4: after FS_Init
|
// 3: after FS_Init
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x86
|
SetDebugLED(++step); // 0x85
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -184,6 +163,12 @@ SetDebugLED(0x01);
|
|||||||
PXI_RecvID();
|
PXI_RecvID();
|
||||||
SetDebugLED(0x02);
|
SetDebugLED(0x02);
|
||||||
|
|
||||||
|
// 4:
|
||||||
|
PUSH_PROFILE();
|
||||||
|
SetDebugLED(++step); // 0x86
|
||||||
|
|
||||||
|
//PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
// 5:
|
// 5:
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x87
|
SetDebugLED(++step); // 0x87
|
||||||
@ -196,36 +181,30 @@ SetDebugLED(0x02);
|
|||||||
|
|
||||||
//PM_BackLightOn( FALSE );
|
//PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
// 7:
|
|
||||||
PUSH_PROFILE();
|
|
||||||
SetDebugLED(++step); // 0x89
|
|
||||||
|
|
||||||
//PM_BackLightOn( FALSE );
|
|
||||||
|
|
||||||
if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER )
|
if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER )
|
||||||
{
|
{
|
||||||
OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n");
|
OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8: after PXI
|
// 7: after PXI
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8a
|
SetDebugLED(++step); // 0x89
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
AESi_InitKeysFIRM();
|
AESi_InitKeysFIRM();
|
||||||
AESi_RecvSeed();
|
AESi_RecvSeed();
|
||||||
|
|
||||||
// 9: after AESi_RecvSeed
|
// 8: after AESi_RecvSeed
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8b
|
SetDebugLED(++step); // 0x8a
|
||||||
|
|
||||||
PM_BackLightOn( FALSE );
|
PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
// 10:
|
// 9:
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
SetDebugLED(++step); // 0x8c
|
SetDebugLED(++step); // 0x8b
|
||||||
|
|
||||||
//PM_BackLightOn( FALSE );
|
//PM_BackLightOn( FALSE );
|
||||||
|
|
||||||
@ -235,12 +214,11 @@ SetDebugLED(0x02);
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 11: after PXI
|
// 10: after PXI
|
||||||
PUSH_PROFILE();
|
PUSH_PROFILE();
|
||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
MI_CpuCopy8( profile, (void*)0x02000080, sizeof(profile) );
|
|
||||||
PXI_RecvID();
|
PXI_RecvID();
|
||||||
OS_TPrintf("\n[ARM7] Begin\n");
|
OS_TPrintf("\n[ARM7] Begin\n");
|
||||||
for (i = 0; i < PROFILE_MAX; i++)
|
for (i = 0; i < PROFILE_MAX; i++)
|
||||||
@ -261,6 +239,7 @@ SetDebugLED(0x02);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SetDebugLED( 0 );
|
SetDebugLED( 0 );
|
||||||
|
|
||||||
PM_BackLightOn( TRUE ); // last chance
|
PM_BackLightOn( TRUE ); // last chance
|
||||||
|
|
||||||
OS_BootFromFIRM();
|
OS_BootFromFIRM();
|
||||||
@ -271,10 +250,10 @@ end:
|
|||||||
EraseAll();
|
EraseAll();
|
||||||
|
|
||||||
// failed
|
// failed
|
||||||
// while (1)
|
|
||||||
{
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
}
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
OS_Terminate();
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ static const u8 rsa_key[128] =
|
|||||||
static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32)));
|
static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32)));
|
||||||
static SVCSignHeapContext acPool;
|
static SVCSignHeapContext acPool;
|
||||||
|
|
||||||
#define MENU_TITLE_ID 0x0001000152434e4cULL
|
#define MENU_TITLE_ID 0x000100014c4e4352ULL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
PROFILE_ENABLE を定義するとある程度のパフォーマンスチェックができます。
|
||||||
@ -50,6 +50,12 @@ static SVCSignHeapContext acPool;
|
|||||||
*/
|
*/
|
||||||
#define PROFILE_ENABLE
|
#define PROFILE_ENABLE
|
||||||
|
|
||||||
|
/*
|
||||||
|
PRINT_MEMORY_ADDR を定義すると、そのアドレスからSPrintfを行います(このファイルのみ)
|
||||||
|
FINALROM版でもコードが残るので注意してください。
|
||||||
|
*/
|
||||||
|
#define PRINT_MEMORY_ADDR 0x02000000
|
||||||
|
|
||||||
//#ifdef SDK_FINALROM // FINALROMで無効化
|
//#ifdef SDK_FINALROM // FINALROMで無効化
|
||||||
//#undef PROFILE_ENABLE
|
//#undef PROFILE_ENABLE
|
||||||
//#endif
|
//#endif
|
||||||
@ -63,6 +69,13 @@ u32 pf_cnt = 0;
|
|||||||
#define PUSH_PROFILE() ((void)0)
|
#define PUSH_PROFILE() ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PRINT_MEMORY_ADDR
|
||||||
|
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
|
||||||
|
#undef OS_TPrintf
|
||||||
|
#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
|
||||||
|
#undef OS_Panic
|
||||||
|
#define OS_Panic(...) (OS_TPrintf(__VA_ARGS__), OS_Terminate())
|
||||||
|
#endif
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
PreInit
|
PreInit
|
||||||
|
|
||||||
@ -253,7 +266,6 @@ PXI_NotifyID( FIRM_PXI_ID_NULL );
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OS_TPrintf("\n[ARM9] End\n");
|
OS_TPrintf("\n[ARM9] End\n");
|
||||||
MI_CpuCopy8( profile, (void*)0x02000000, sizeof(profile) );
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_NULL );
|
PXI_NotifyID( FIRM_PXI_ID_NULL );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -264,10 +276,10 @@ end:
|
|||||||
EraseAll();
|
EraseAll();
|
||||||
|
|
||||||
// failed
|
// failed
|
||||||
// while (1)
|
|
||||||
{
|
|
||||||
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
}
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
|
PXI_NotifyID( FIRM_PXI_ID_ERR );
|
||||||
OS_Terminate();
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user