ctr_firmware/trunk/firmware/build/tests/nfs/ARM11/main.c
(no author) aeb80dda11 (shirait) nfsテスト追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@284 b871894f-2f95-9b40-918c-086798483c85
2009-02-13 00:35:13 +00:00

148 lines
4.5 KiB
C
Raw Blame History

/*---------------------------------------------------------------------------*
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>
//REG_NAND_COMMAND
#define NAND_START (0x0100)
#define NAND_BUSY NAND_START
#define NAND_RESET 6
#define NAND_READ_STATUS 5
#define NAND_ERASE_BLOCK 4
#define NAND_PROGRAM_PAGE 3
#define NAND_READ_PAGE 1
//REG_NAND_ECC
#define NAND_ENABLE_ECC 1
#define REG_NAND_ADR_LO (0x18019840)
#define REG_NAND_ADR_HI (0x18019842)
#define REG_NAND_COMMAND (0x1801984E)
#define REG_NAND_ECC (0x18019850)
#define REG_NAND_DATA (0x18019000)
#define REG_NAND_SPARE (0x18019800)
void NandReset( void);
void NandErase( u16 adr_hi, u16 adr_lo);
void NandWrite( u16 adr_hi, u16 adr_lo, u32* buf);
void NandRead( u16 adr_hi, u16 adr_lo);
u32 CalcECC( u32* buf);
u32 CalcCP( u32* buf, u32 st, u32 cmp, u32 logic);
u32 CalcLP( u32* buf, u32 st, u32 cmp, u32 logic);
BOOL i_nandCheckECC( u32* data, u32* stored_ecc, u32 new_ecc);
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);
#define MY_STACK_SIZE (4*1024)
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<6E>h<EFBFBD><68><EFBFBD>C<EFBFBD>o<EFBFBD><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
nandInit();
nandEnable( NandPageCache);
{
char path_str[128];
char wfsVolumeId[16];
WFSFileHandle fileHandle;
WFSResult wfsResult;
buddy_allocator_init( my_heap, 0x40000); //32KB
/*--- WFS<46><53><EFBFBD>C<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---*/
osTPrintf( "ok\n");
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);
/*--- <20>t<EFBFBD>H<EFBFBD>[<5B>}<7D>b<EFBFBD>g ---*/
WFSDebugSetTitleId( WFS_ROOT_ID);
wfsResult = WFSInitializeDevice( "msc01");
osTPrintf( "WFSInitializeDevice : %d\n", wfsResult);
/*--- <20>}<7D>E<EFBFBD><45><EFBFBD>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
/*--- <20>f<EFBFBD>B<EFBFBD><42><EFBFBD>N<EFBFBD>g<EFBFBD><67> ---*/
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
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) );
}
}