/*---------------------------------------------------------------------------* 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 #include #include #include #include #define MY_STACK_SIZE (4*1024) void nandSetFormatRequest( u16 partition_num, u32* partition_sectors); NandPageCacheFormat NandPageCache[1]; u32 BlockBuf[2*1024/4]; u32 my_heap[0x40400/4]; u16 WfsWorkBuf[(WFS_MIN_WORK_SPACE_SIZE/2)+512]; u16* WfsAlignedWorkBuf; WFSResult WFSDebugSetTitleId(WFSTitleId titleId); OSThread my_tsk; u64 my_stack[MY_STACK_SIZE / sizeof(u64)]; void MyThread( void* arg) { (void)osEnableInterrupts(); while( 1) { osSleep( 1); }; } 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(); (void)osEnableInterrupts(); /**/ // osCreateThread( &my_tsk, MyThread, NULL, (my_stack+MY_STACK_SIZE / sizeof(u64)), MY_STACK_SIZE, 14); // osWakeupThreadDirect( &my_tsk); /*nandドライバ初期化*/ nandInit(); nandEnable( NandPageCache); { char path_str[128]; char wfsVolumeId[16]; WFSFileHandle fileHandle; WFSResult wfsResult; buddy_allocator_init( my_heap, 0x40000); //32KB /*--- WFSライブラリ初期化 ---*/ WfsAlignedWorkBuf = (u16*)(MATH_ROUNDUP( (int)WfsWorkBuf, 512)); osTPrintf( "aligned buffer : 0x%x\n", (u32)WfsAlignedWorkBuf); wfsResult = WFSInit( WfsAlignedWorkBuf, WFS_MIN_WORK_SPACE_SIZE); osTPrintf( "WFSInit : %d\n", wfsResult); /*--- フォーマット ---*/ WFSDebugSetTitleId( WFS_ROOT_ID); wfsResult = WFSInitializeDevice( "msc01"); osTPrintf( "WFSInitializeDevice : %d\n", wfsResult); /*--- マウント ---*/ wfsResult = WFSGetVolumeId( "msc01", wfsVolumeId); osTPrintf( "WFSGetVolumeId : %d\n", wfsResult); wfsResult = WFSMountDevice( "msc01", wfsVolumeId); osTPrintf( "WFSMountDevice : %d\n", wfsResult); osTPrintf( "/vol/%s\n", wfsVolumeId); #if 1 /*--- ディレクトリ ---*/ osSPrintf( (char*)path_str, "/vol/%s/%s", wfsVolumeId, "home"); osTPrintf( "createdir ... %s\n", path_str); // wfsResult = WFSCreateDirectory( (char*)path_str, (WFS_PERM_READ | WFS_PERM_ADD_OR_DELETE_FILE | WFS_PERM_LIST | WFS_PERM_DELETE_OR_MOVE), 0); wfsResult = WFSCreateDirectory( (char*)path_str, WFS_PERM_FULL, 0); osTPrintf( "WFSCreateDirectory : %d\n", wfsResult); #endif /*--- 空きサイズ取得 ---*/ { u32 freesize[2]; freesize[1] = freesize[0] = 0; osSPrintf( (char*)path_str, "/vol/%s/", wfsVolumeId); WFSGetFreeSpaceSize( path_str, &freesize); osTPrintf( "WFSGetFreeSpaceSize : 0x%x%x\n", freesize[1], freesize[0]); } WFSExit(); } 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) ); } }