mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@287 b871894f-2f95-9b40-918c-086798483c85
156 lines
5.3 KiB
C
156 lines
5.3 KiB
C
/*---------------------------------------------------------------------------*
|
|
Project: TwlBrom - thread
|
|
File: main.c
|
|
|
|
Copyright 2008 Nintendo. All rights reserved.
|
|
|
|
These coded instructions, statements, and computer programs contain
|
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
|
Company Ltd., and are protected by Federal copyright law. They may
|
|
not be disclosed to third parties or copied or duplicated in any form,
|
|
in whole or in part, without the prior written consent of Nintendo.
|
|
|
|
$Date:: $
|
|
$Rev$
|
|
$Author$
|
|
*---------------------------------------------------------------------------*/
|
|
#include <brom.h>
|
|
#include <brom/nand/nand.h>
|
|
#include <firm/fatfs/rtfs.h>
|
|
|
|
|
|
void nandSetFormatRequest( u16 partition_num, u32* partition_sectors);
|
|
|
|
NandPageCacheFormat NandPageCache[1];
|
|
u32 BlockBuf[2*1024/4];
|
|
|
|
|
|
void BromMain( void )
|
|
{
|
|
u32 partition_sectors[5];
|
|
DEV_GEOMETRY dgeometry;
|
|
PCFD fd;
|
|
int result;
|
|
u32 s_ecc, n_ecc;
|
|
|
|
osInitException();
|
|
osInitBROM();
|
|
|
|
osPrintf( "ARM11: start\n" );
|
|
|
|
osInitThread();
|
|
|
|
/*nandレイアウト*/
|
|
partition_sectors[0] = (( 1*1024*1024)/512); // 1MB
|
|
partition_sectors[1] = ((96*1024*1024)/512); // 96MB
|
|
partition_sectors[2] = ((24*1024*1024)/512); // 24MB
|
|
partition_sectors[3] = (( 1*1024*1024)/512); // rest
|
|
partition_sectors[4] = (0);
|
|
|
|
/*nandドライバ初期化*/
|
|
nandInit();
|
|
nandEnable( NandPageCache);
|
|
|
|
|
|
/*fatfsライブラリ初期化*/
|
|
rtfs_init();
|
|
|
|
/*マウント*/
|
|
nandRtfsAttach( /*drive*/0, /*partition*/0); // "A:"...partition0
|
|
nandRtfsAttach( /*drive*/1, /*partition*/1); // "B:"...partition1
|
|
nandRtfsAttach( /*drive*/2, /*partition*/2); // "C:"...partition2
|
|
|
|
#if 0
|
|
/*メディアフォーマット*/
|
|
nandSetFormatRequest( 3, partition_sectors);
|
|
if( pc_get_media_parms( (u8*)L"A:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_get_media_parms : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_get_media_parms : SUCCESS\n");
|
|
}
|
|
|
|
if( pc_format_media( (u8*)L"A:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_format_media : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_format_media : SUCCESS\n");
|
|
}
|
|
|
|
/*パーティション0フォーマット*/
|
|
if( pc_format_volume( (u8*)L"A:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(0) : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(0) : SUCCESS\n");
|
|
}
|
|
|
|
|
|
/*パーティション1フォーマット*/
|
|
if( pc_get_media_parms( (u8*)L"B:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_get_media_parms : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_get_media_parms : SUCCESS\n");
|
|
}
|
|
if( pc_format_volume( (u8*)L"B:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(1) : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(1) : SUCCESS\n");
|
|
}
|
|
/*パーティション2フォーマット*/
|
|
if( pc_get_media_parms( (u8*)L"C:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_get_media_parms : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_get_media_parms : SUCCESS\n");
|
|
}
|
|
if( pc_format_volume( (u8*)L"C:", &dgeometry) == FALSE) {
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(2) : FAILURE\n");
|
|
}else{
|
|
osTPrintf( "pc_format_volume for FAT-PARTITION(2) : SUCCESS\n");
|
|
}
|
|
nandFlush();
|
|
osTPrintf( "fat format finished.\n");
|
|
osTPrintf( "\n");
|
|
{
|
|
u32 total_blocks, free_blocks;
|
|
osTPrintf( "pc_free for FAT-PARTITION(0) results follow.\n");
|
|
osTPrintf( "free bytes : 0x%x\n", pc_free( (u8*)L"A:", &total_blocks, &free_blocks));
|
|
osTPrintf( "total_blocks : 0x%x, free_blocks : 0x%x\n", total_blocks, free_blocks);
|
|
osTPrintf( "\n");
|
|
|
|
osTPrintf( "pc_free for FAT-PARTITION(1) results follow.\n");
|
|
osTPrintf( "free bytes : 0x%x\n", pc_free( (u8*)L"B:", &total_blocks, &free_blocks));
|
|
osTPrintf( "total_blocks : 0x%x, free_blocks : 0x%x\n", total_blocks, free_blocks);
|
|
osTPrintf( "\n");
|
|
|
|
osTPrintf( "pc_free for FAT-PARTITION(2) results follow.\n");
|
|
osTPrintf( "free bytes : 0x%x\n", pc_free( (u8*)L"C:", &total_blocks, &free_blocks));
|
|
osTPrintf( "total_blocks : 0x%x, free_blocks : 0x%x\n", total_blocks, free_blocks);
|
|
osTPrintf( "\n");
|
|
}
|
|
osTPrintf( "finished.\n");
|
|
#else
|
|
{
|
|
u32 total_blocks, free_blocks;
|
|
osTPrintf( "pc_free\n");
|
|
osTPrintf( "free bytes : 0x%x\n", pc_free( (u8*)L"A:", &total_blocks, &free_blocks));
|
|
osTPrintf( "total_blocks : 0x%x, free_blocks : 0x%x\n", total_blocks, free_blocks);
|
|
}
|
|
|
|
osTPrintf( "po_open\n");
|
|
fd = po_open( "A:\\test2.bin", (PO_BINARY | PO_RDWR | PO_CREAT), PS_IWRITE);
|
|
osTPrintf( "fd : 0x%x\n", fd);
|
|
result = po_close( fd);
|
|
osTPrintf( "po_close : %d\n", result);
|
|
#endif
|
|
|
|
|
|
while (1)
|
|
{
|
|
u32 pmon = osGetPerfMonitor(OS_MONITOR_1);
|
|
OSTick tick = osGetTick();
|
|
osSleep(1000);
|
|
tick = osGetTick() - tick;
|
|
pmon = osGetPerfMonitor(OS_MONITOR_1) - pmon;
|
|
osTPrintf( "sleep tick = %llu msec\n", OS_TICK_TO_MSEC(tick) );
|
|
osTPrintf( "sleep mon = %llu msec\n", OS_PMON_TO_MSEC(pmon) );
|
|
}
|
|
}
|