mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
MIライブラリのSetup、Restartを利用するように修正
TwlSDKのcrt0に合わた修正(使っていないが) 1つ残っていたAPI名のFirmをFIRMに修正 sdmc-launcherでブート前にprofileのダンプ表示の追加 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@96 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
02ff4d08a4
commit
36354e62c0
@ -29,66 +29,6 @@ extern u32 NAND_FAT_PARTITION_COUNT;
|
||||
#define DMA_PIPE 2
|
||||
#define DMA_RECV 3
|
||||
|
||||
/*
|
||||
専用DMA関数
|
||||
MI_NDmaライブラリが全然足りないので、APIを追加
|
||||
最終的には標準ライブラリだけで全部できて欲しい
|
||||
*/
|
||||
//---------------- register setting
|
||||
static inline void MIi_SetSrc( u32 ndmaNo, u32 src )
|
||||
{
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_SAD_WOFFSET ) = src;
|
||||
}
|
||||
static inline void MIi_SetDest( u32 ndmaNo, u32 dest )
|
||||
{
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_DAD_WOFFSET ) = dest;
|
||||
}
|
||||
static inline void MIi_SetTotalWordCount( u32 ndmaNo, u32 size )
|
||||
{
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_TCNT_WOFFSET ) = size;
|
||||
}
|
||||
static inline void MIi_SetWordCount( u32 ndmaNo, u32 size )
|
||||
{
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_WCNT_WOFFSET ) = size;
|
||||
}
|
||||
static inline void MIi_SetInterval( u32 ndmaNo, u32 intervalTimer, u32 prescaler )
|
||||
{
|
||||
#ifdef SDK_ARM7
|
||||
//---- In case of ARM7, intervalTimer==1 is nonsense
|
||||
SDK_ASSERT(intervalTimer != 1);
|
||||
#endif
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_BCNT_WOFFSET ) = intervalTimer | prescaler;
|
||||
}
|
||||
static inline void MIi_SetControl( u32 ndmaNo, u32 contData )
|
||||
{
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_CNT_WOFFSET ) = contData;
|
||||
}
|
||||
static inline void MIi_Sd1_NDmaRecv(u32 ndmaNo, void *dest, u32 size)
|
||||
{
|
||||
MIi_SetSrc( ndmaNo, (u32)SDIF_FI );
|
||||
MIi_SetDest( ndmaNo, (u32)dest );
|
||||
MIi_SetInterval( ndmaNo, MI_NDMA_NO_INTERVAL, MI_NDMA_INTERVAL_PS_1 );
|
||||
MIi_SetTotalWordCount( ndmaNo, size/4 );
|
||||
MIi_SetWordCount( ndmaNo, SECTOR_SIZE/4 );
|
||||
MIi_SetControl( ndmaNo, MI_NDMA_BWORD_128 | MI_NDMA_SRC_FIX | MI_NDMA_DEST_INC | MI_NDMA_TIMING_SD_1 | MI_NDMA_ENABLE );
|
||||
}
|
||||
|
||||
static inline void MIi_NDmaPipeSetup(u32 ndmaNo, const void *src, void *dest, u32 size)
|
||||
{
|
||||
MIi_SetSrc( ndmaNo, (u32)src );
|
||||
MIi_SetDest( ndmaNo, (u32)dest );
|
||||
MIi_SetInterval( ndmaNo, MI_NDMA_NO_INTERVAL, MI_NDMA_INTERVAL_PS_1 );
|
||||
MIi_SetTotalWordCount( ndmaNo, size/4 );
|
||||
MIi_SetWordCount( ndmaNo, size/4 );
|
||||
MIi_SetControl( ndmaNo, MI_NDMA_BWORD_8 | MI_NDMA_SRC_FIX | MI_NDMA_DEST_FIX | MI_NDMA_IMM_MODE_ON ); // AESi_Run is required BWORD_8
|
||||
}
|
||||
|
||||
static inline void MIi_NDmaRestart(u32 ndmaNo)
|
||||
{
|
||||
MI_WaitNDma( ndmaNo );
|
||||
MI_NDMA_REG( ndmaNo, MI_NDMA_REG_CNT_WOFFSET ) |= MI_NDMA_ENABLE;
|
||||
}
|
||||
|
||||
/*
|
||||
専用SD関数
|
||||
*/
|
||||
@ -243,9 +183,15 @@ void FATFS_DisableAES( void )
|
||||
*---------------------------------------------------------------------------*/
|
||||
static u16 ReadNormal(u32 block, void *dest, u16 count)
|
||||
{
|
||||
//OS_TPrintf("ReadNormal(%d, 0x%08X, %d) is calling.\n", block, dest, count);
|
||||
|
||||
MIi_Sd1_NDmaRecv( DMA_PIPE, dest, (u32)(count * SECTOR_SIZE) );
|
||||
MINDmaConfig config =
|
||||
{
|
||||
MI_NDMA_NO_INTERVAL,
|
||||
MI_NDMA_INTERVAL_PS_1,
|
||||
MI_NDMA_BWORD_128,
|
||||
SECTOR_SIZE/4
|
||||
};
|
||||
// OS_TPrintf("ReadNormal(0x%X, 0x%08X, 0x%X) is calling.\n", block, dest, count);
|
||||
MI_NDmaRecvExAsync_Dev( DMA_PIPE, SDIF_FI, dest, (u32)(count * SECTOR_SIZE), NULL, NULL, &config, MI_NDMA_TIMING_SD_1 );
|
||||
StartToRead( block, count );
|
||||
MI_WaitNDma( DMA_PIPE );
|
||||
StopToRead();
|
||||
@ -275,8 +221,8 @@ static u16 ReadAES(u32 block, void *dest, u16 count)
|
||||
{
|
||||
u32 offset = 0; // in bytes
|
||||
|
||||
//OS_TPrintf("ReadAES(%d, 0x%08X, %d) is calling.\n", block, dest, count);
|
||||
MIi_NDmaPipeSetup( DMA_PIPE, (void*)SDIF_FI, (void*)REG_AES_IFIFO_ADDR, PIPE_SIZE );
|
||||
// OS_TPrintf("ReadAES(0x%X, 0x%08X, 0x%X) is calling.\n", block, dest, count);
|
||||
MI_NDmaPipeAsync_SetUp( DMA_PIPE, (void*)SDIF_FI, (void*)REG_AES_IFIFO_ADDR, PIPE_SIZE, NULL, NULL );
|
||||
|
||||
/*
|
||||
AESのセットアップ&出力DMA設定
|
||||
@ -309,7 +255,7 @@ static u16 ReadAES(u32 block, void *dest, u16 count)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
MIi_NDmaRestart( DMA_PIPE );
|
||||
MI_NDmaRestart( DMA_PIPE );
|
||||
offset += PIPE_SIZE;
|
||||
}
|
||||
MI_WaitNDma( DMA_PIPE );
|
||||
@ -520,7 +466,7 @@ BOOL FATFS_InitFIRM( void* nandContext )
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: FATFS_MountDriveFirm
|
||||
Name: FATFS_MountDriveFIRM
|
||||
|
||||
Description: mount specified partition
|
||||
|
||||
@ -534,7 +480,7 @@ BOOL FATFS_InitFIRM( void* nandContext )
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL FATFS_MountDriveFirm( int driveno, FATFSMediaType media, int partition_no )
|
||||
BOOL FATFS_MountDriveFIRM( int driveno, FATFSMediaType media, int partition_no )
|
||||
{
|
||||
if ( media == FATFS_MEDIA_TYPE_NAND )
|
||||
{
|
||||
|
||||
@ -147,6 +147,7 @@ static BOOL FATFS_LoadBuffer(u32 offset, u32 size)
|
||||
static int count = 0;
|
||||
|
||||
// seek first
|
||||
// OS_TPrintf("po_lseek(offset=%X);\n", offset);
|
||||
if (po_lseek(menu_fd, (s32)offset, PSEEK_SET) < 0)
|
||||
{
|
||||
return FALSE;
|
||||
@ -160,7 +161,6 @@ static BOOL FATFS_LoadBuffer(u32 offset, u32 size)
|
||||
{
|
||||
u8* dest = base + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE; // target buffer address
|
||||
u32 unit = size < HW_FIRM_LOAD_BUFFER_UNIT_SIZE ? size : HW_FIRM_LOAD_BUFFER_UNIT_SIZE; // size
|
||||
//OS_TPrintf("%s: dest=%X, unit=%X\n", __func__, dest, unit);
|
||||
while (MI_GetWramBankMaster_B(count) != MI_WRAM_ARM7) // waiting to be master
|
||||
{
|
||||
}
|
||||
@ -168,6 +168,7 @@ static BOOL FATFS_LoadBuffer(u32 offset, u32 size)
|
||||
// x3...: after to wait ARM9
|
||||
profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick());
|
||||
#endif
|
||||
// OS_TPrintf("po_read(dest=%X, unit=%X);\n", dest, unit);
|
||||
if (po_read(menu_fd, (u8*)dest, (int)unit) < 0) // reading
|
||||
{
|
||||
return FALSE;
|
||||
|
||||
@ -369,11 +369,6 @@ static asm void detect_main_memory_size( void )
|
||||
bne @1
|
||||
|
||||
//---- 4MB
|
||||
// check SMX_CNT
|
||||
ldr r2, =REG_SMX_CNT_ADDR
|
||||
ldrh r1, [r2]
|
||||
tst r1, #0
|
||||
orrne r0, r0, #OS_CHIPTYPE_SMX_MASK
|
||||
b @4
|
||||
|
||||
//---- 8MB or 16MB or 32MB
|
||||
@ -410,6 +405,12 @@ static asm void detect_main_memory_size( void )
|
||||
ldrh r0, [r2]
|
||||
and r0, r0, #REG_SCFG_OP_OPT_MASK
|
||||
|
||||
// check SMX_CNT
|
||||
ldr r2, =REG_SMX_CNT_ADDR
|
||||
ldrh r1, [r2]
|
||||
tst r1, #0
|
||||
orrne r0, r0, #OS_CHIPTYPE_SMX_MASK
|
||||
|
||||
//---- detect jtag
|
||||
ldr r2, =REG_JTAG_ADDR
|
||||
ldrh r1, [r2]
|
||||
|
||||
@ -135,7 +135,7 @@ void TwlSpMain( void )
|
||||
#endif
|
||||
OS_SetDebugLED(++step);
|
||||
|
||||
if ( FATFS_MountDriveFirm( DRIVE_NO, BOOT_DEVICE, PARTITION_NO ) )
|
||||
if ( FATFS_MountDriveFIRM( DRIVE_NO, BOOT_DEVICE, PARTITION_NO ) )
|
||||
{
|
||||
BOOL result;
|
||||
#ifndef SDK_FINALROM
|
||||
|
||||
@ -42,8 +42,8 @@ static u8 step = 0x80;
|
||||
Profile
|
||||
*/
|
||||
#ifndef SDK_FINALROM
|
||||
#define PRFILE_MAX 0x100
|
||||
u32 profile[PRFILE_MAX];
|
||||
#define PROFILE_MAX 0x100
|
||||
u32 profile[PROFILE_MAX];
|
||||
u32 pf_cnt = 0;
|
||||
#endif
|
||||
|
||||
@ -141,7 +141,7 @@ void TwlSpMain( void )
|
||||
OS_SetDebugLED(++step);
|
||||
PM_BackLightOn( FALSE );
|
||||
|
||||
if ( FATFS_MountDriveFirm( DRIVE_NO, BOOT_DEVICE, PARTITION_NO ) )
|
||||
if ( FATFS_MountDriveFIRM( DRIVE_NO, BOOT_DEVICE, PARTITION_NO ) )
|
||||
{
|
||||
BOOL result;
|
||||
#ifndef SDK_FINALROM
|
||||
@ -187,11 +187,21 @@ void TwlSpMain( void )
|
||||
{
|
||||
#ifndef SDK_FINALROM
|
||||
// 127: before Boot
|
||||
pf_cnt = PRFILE_MAX-1;
|
||||
pf_cnt = PROFILE_MAX-1;
|
||||
profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick());
|
||||
{
|
||||
int i;
|
||||
PXI_RecvID();
|
||||
OS_TPrintf("\n[ARM7] Begin\n");
|
||||
for (i = 0; i < PROFILE_MAX; i++)
|
||||
{
|
||||
OS_TPrintf("0x%08X\n", profile[i]);
|
||||
}
|
||||
OS_TPrintf("\n[ARM7] End\n");
|
||||
}
|
||||
#endif
|
||||
OS_SetDebugLED(++step);
|
||||
PM_BackLightOn( TRUE );
|
||||
PM_BackLightOn( TRUE ); // last chance
|
||||
|
||||
FATFS_Boot();
|
||||
}
|
||||
|
||||
@ -39,8 +39,8 @@ static SVCSignHeapContext acPool;
|
||||
Profile
|
||||
*/
|
||||
#ifndef SDK_FINALROM
|
||||
#define PRFILE_MAX 0x100
|
||||
u32 profile[PRFILE_MAX];
|
||||
#define PROFILE_MAX 0x100
|
||||
u32 profile[PROFILE_MAX];
|
||||
u32 pf_cnt = 0;
|
||||
#endif
|
||||
|
||||
@ -145,8 +145,18 @@ void TwlMain( void )
|
||||
{
|
||||
#ifndef SDK_FINALROM
|
||||
// 127: before Boot
|
||||
pf_cnt = PRFILE_MAX-1;
|
||||
pf_cnt = PROFILE_MAX-1;
|
||||
profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick());
|
||||
{
|
||||
int i;
|
||||
OS_TPrintf("\n[ARM9] Begin\n");
|
||||
for (i = 0; i < PROFILE_MAX; i++)
|
||||
{
|
||||
OS_TPrintf("0x%08X\n", profile[i]);
|
||||
}
|
||||
OS_TPrintf("\n[ARM9] End\n");
|
||||
PXI_NotifyID( FIRM_PXI_ID_NULL );
|
||||
}
|
||||
#endif
|
||||
|
||||
MI_Boot();
|
||||
|
||||
@ -60,7 +60,7 @@ void FATFS_DisableAES( void );
|
||||
BOOL FATFS_InitFIRM( void* nandContext );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: FATFS_MountDriveFirm
|
||||
Name: FATFS_MountDriveFIRM
|
||||
|
||||
Description: mount nand partition
|
||||
|
||||
@ -68,7 +68,7 @@ BOOL FATFS_InitFIRM( void* nandContext );
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL FATFS_MountDriveFirm( int driveno, FATFSMediaType media, int partition_no );
|
||||
BOOL FATFS_MountDriveFIRM( int driveno, FATFSMediaType media, int partition_no );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user