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@295 b871894f-2f95-9b40-918c-086798483c85
133 lines
3.9 KiB
C
133 lines
3.9 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>
|
||
#include <revolution/wfstypes.h>
|
||
#include <revolution/wfs.h>
|
||
|
||
#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ƒhƒ‰ƒCƒo<C692>‰Šú‰»*/
|
||
nandInit();
|
||
nandEnable( NandPageCache);
|
||
|
||
{
|
||
char path_str[128];
|
||
char wfsVolumeId[16];
|
||
WFSFileHandle fileHandle;
|
||
WFSResult wfsResult;
|
||
|
||
buddy_allocator_init( my_heap, 0x40000); //32KB
|
||
|
||
/*--- WFSƒ‰ƒCƒuƒ‰ƒŠ<C692>‰Šú‰» ---*/
|
||
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);
|
||
|
||
/*--- ƒtƒH<C692>[ƒ}ƒbƒg ---*/
|
||
WFSDebugSetTitleId( WFS_ROOT_ID);
|
||
wfsResult = WFSInitializeDevice( "msc01");
|
||
osTPrintf( "WFSInitializeDevice : %d\n", wfsResult);
|
||
|
||
/*--- ƒ}ƒEƒ“ƒg ---*/
|
||
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
|
||
/*--- ƒfƒBƒŒƒNƒgƒŠ ---*/
|
||
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
|
||
|
||
/*--- ‹ó‚«ƒTƒCƒYŽæ“¾ ---*/
|
||
{
|
||
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) );
|
||
}
|
||
}
|