diff --git a/build/libraries/devices/sdmc/ARM7/drnand.c b/build/libraries/devices/sdmc/ARM7/drnand.c index bd2488d..3b1c1a4 100644 --- a/build/libraries/devices/sdmc/ARM7/drnand.c +++ b/build/libraries/devices/sdmc/ARM7/drnand.c @@ -21,12 +21,7 @@ #include "sdif_reg.h" #if (SD_DEBUG_PRINT_ON == 1) - #if (CTR_DEF_ENVIRONMENT_DSEMU == 1) - #define PRINTDEBUG osTPrintf - #else - #include - #define PRINTDEBUG vlink_dos_printf - #endif + #define PRINTDEBUG OS_TPrintf #else #define PRINTDEBUG( ...) ((void)0) #endif @@ -63,7 +58,7 @@ static int nand_drive_no; *---------------------------------------------------------------------------*/ static void sdi_get_CHS_params( void); static u32 sdi_get_ceil( u32 cval, u32 mval); -static void sdi_get_nom( void); +static void sdi_get_nom( u16 min_nom); static void sdi_get_fatparams( void); static void sdi_build_partition_table( void); @@ -196,7 +191,7 @@ int nandRtfsCtrl( int driveno, int opcode, void* pargs) i_sdmcCalcSize(); //TODO:sdmc_current_specを構造体に入れること sdi_get_CHS_params(); //最初に呼ぶこと sdi_get_fatparams(); - sdi_get_nom(); + sdi_get_nom( (8*1024*1024)/512); //8MBytes <= NOM PRINTDEBUG( "heads : 0x%x\n", sdmc_current_spec.heads); PRINTDEBUG( "secptrack : 0x%x\n", sdmc_current_spec.secptrack); @@ -413,7 +408,7 @@ static u32 sdi_get_ceil( u32 cval, u32 mval) /*マスターブートセクタのセクタ数を返す*/ -static void sdi_get_nom( void) +static void sdi_get_nom( u16 MIN_NOM) { u32 RSC = 1; //FAT12,16では1 u32 RDE = 512; //ルートディレクトリエントリ。FIX @@ -428,7 +423,10 @@ static void sdi_get_nom( void) /*-----------------------SDHCのとき----------------------------*/ if( sdmc_current_spec.csd_ver2_flag) { - sdmc_current_spec.NOM = sdmc_current_spec.BU; + /*nandの場合、NOMは少なくともMIN_NOM以上*/ + sdmc_current_spec.NOM = sdi_get_ceil( MIN_NOM, sdmc_current_spec.BU) * + sdmc_current_spec.BU; + //sdmc_current_spec.NOM = sdmc_current_spec.BU; do { n = sdi_get_ceil( 2*sdmc_current_spec.SF, sdmc_current_spec.BU); sdmc_current_spec.RSC = (sdmc_current_spec.BU * n) - ( 2 * sdmc_current_spec.SF); @@ -456,6 +454,9 @@ static void sdi_get_nom( void) do { sdmc_current_spec.SSA = RSC + ( 2 * sdmc_current_spec.SF) + sdi_get_ceil( 32*RDE, SS); n = sdi_get_ceil( sdmc_current_spec.SSA, sdmc_current_spec.BU); + /*nandの場合、NOMは少なくともMIN_NOM以上*/ + n+= sdi_get_ceil( MIN_NOM, sdmc_current_spec.BU); + sdmc_current_spec.NOM = (sdmc_current_spec.BU * n) - sdmc_current_spec.SSA; if( sdmc_current_spec.NOM != sdmc_current_spec.BU) { sdmc_current_spec.NOM += sdmc_current_spec.BU; diff --git a/build/libraries/devices/sdmc/ARM7/drsdmc.c b/build/libraries/devices/sdmc/ARM7/drsdmc.c index 3a2877a..99d6478 100644 --- a/build/libraries/devices/sdmc/ARM7/drsdmc.c +++ b/build/libraries/devices/sdmc/ARM7/drsdmc.c @@ -21,12 +21,7 @@ #include "sdif_reg.h" #if (SD_DEBUG_PRINT_ON == 1) - #if (CTR_DEF_ENVIRONMENT_DSEMU == 1) - #define PRINTDEBUG osTPrintf - #else - #include - #define PRINTDEBUG vlink_dos_printf - #endif + #define PRINTDEBUG OS_TPrintf #else #define PRINTDEBUG( ...) ((void)0) #endif diff --git a/build/libraries/devices/sdmc/ARM7/sdif.c b/build/libraries/devices/sdmc/ARM7/sdif.c index 92fd93a..f8d791c 100644 --- a/build/libraries/devices/sdmc/ARM7/sdif.c +++ b/build/libraries/devices/sdmc/ARM7/sdif.c @@ -11,16 +11,11 @@ #include #include "sdif_ip.h" /* IP 対応フラグ定義 */ -#if (SD_DEBUG_PRINT_ON == 1) - #if (CTR_DEF_ENVIRONMENT_DSEMU == 1) - #define PRINTDEBUG osTPrintf - #else - #include - #define PRINTDEBUG vlink_dos_printf - #endif -#else +//#if (SD_DEBUG_PRINT_ON == 1) +// #define PRINTDEBUG OS_TPrintf +//#else #define PRINTDEBUG( ...) ((void)0) -#endif +//#endif #define ADD_CHECK 1 diff --git a/build/tests/fatfs/nand_formatter_kmc/ARM7/Makefile b/build/tests/fatfs/nand_formatter_kmc/ARM7/Makefile new file mode 100644 index 0000000..2d22ce8 --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/ARM7/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - CAMERA - demos - camera-1 +# File: Makefile +# +# Copyright 2007 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LCFILE_SPEC = main.lsf + +#---------------------------------------------------------------------------- + +#TWL_CODEGEN = THUMB +TWL_PROC = ARM7 + +TARGET_BIN = main.axf + +SRCS = main.c + +INCDIR += $(TWLSDK_ROOT)/include/twl \ + $(TWLSDK_ROOT)/include/twl/devices/sdmc/ARM7 \ + $(TWLSDK_ROOT)/include/twl/fatfs/ARM7 \ + +LLIBRARY_DIRS = $(TWLSDK_ROOT)/lib/ARM-BB/Release +LLIBRARIES = libfatfs_sp.twl.a \ + libsd_sp.twl.a \ + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tests/fatfs/nand_formatter_kmc/ARM7/main.lsf b/build/tests/fatfs/nand_formatter_kmc/ARM7/main.lsf new file mode 100644 index 0000000..9eac241 --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/ARM7/main.lsf @@ -0,0 +1,40 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM7-BB.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x02004000 + Library crt0.o + StackSize 1024 512 +} + +#Objects on MAIN RAM # nothing for elf2bin +#Autoload MAIN +#{ +# Address 0x027e0000 +# Library +#} + +Autoload MAIN +{ + Address 0x02020000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.wram) +} diff --git a/build/tests/fatfs/nand_formatter_kmc/ARM7/src/main.c b/build/tests/fatfs/nand_formatter_kmc/ARM7/src/main.c new file mode 100644 index 0000000..f3bb26b --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/ARM7/src/main.c @@ -0,0 +1,276 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - nand_formatter_kmc + File: main.c + + Copyright 2007 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. + + $Log: main.c,v $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include + +#define DBG_PRINTF OS_TPrintf +#define DBG_CHAR OS_PutChar +#define kmc_getchar() ((char)vlink_dos_get_console()) +#define kmc_putchar(x) vlink_dos_put_console((char)(x)) + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define PRINTDEBUG OS_TPrintf + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystem(void); +static void VBlankIntr(void); + +/*---------------------------------------------------------------------------* + + *---------------------------------------------------------------------------*/ +u32 BlockBuf[(512*3)/4]; +u32 BlockBuf2[(512*3)/4]; + + +static BOOL getchar_yes_no_prompt(void) +{ + char c; + while( 1 ) { + c = kmc_getchar(); + kmc_putchar(c); + if( c == 'y' ) { + return TRUE; + } + else if( c == 'n' ) { + return FALSE; + } + else if( c == 'q' ) { + DBG_PRINTF("\nEnter infinite loop\n"); + while( 1 ) { ; } + } + else { + DBG_PRINTF("\nInput y or n\n"); + } + } +} + + + +/*---------------------------------------------------------------------------* + Name: TwlSpMain + + Description: Initialize and do main + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void TwlSpMain(void) +{ + u16 i; + OSHeapHandle heapHandle; + SDMC_ERR_CODE result; + SdmcResultInfo SdResult; + /**/ + PCFD fd; + CHKDISK_STATS dstat; + DEV_GEOMETRY geometry; + + + // OS初期化 + OS_Init(); + + OS_InitTick(); + OS_InitAlarm(); + + // PXI初期化、ARM9と同期 + PXI_Init(); + + // ヒープ領域設定 + heapHandle = InitializeAllocateSystem(); + + + // ボタン入力サーチ初期化 + (void)PAD_InitXYButton(); + + // 割込み許可 + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + OS_InitThread(); + + + /**/ + PRINTDEBUG("Sample program starts.\n"); + { + OSHeapHandle hh; + OS_SetSubPrivArenaLo( OS_InitAlloc( OS_ARENA_MAIN_SUBPRIV, OS_GetSubPrivArenaLo(), OS_GetSubPrivArenaHi(), 1)); + hh = OS_CreateHeap( OS_ARENA_MAIN_SUBPRIV, OS_GetSubPrivArenaLo(), OS_GetSubPrivArenaHi()); + OS_SetCurrentHeap( OS_ARENA_MAIN_SUBPRIV, hh); + if( rtfs_init() == FALSE) { + PRINTDEBUG( "rtfs_init failed.\n"); + }else{ + PRINTDEBUG( "rtfs_init success.\n"); + } + } + + MI_DmaFill32( 2, BlockBuf, 0x55AA55AA, 512*3); + MI_DmaFill32( 2, BlockBuf2, 0x00FF00FF, 512*3); + + /*SDドライバ初期化*/ + result = sdmcInit( SDMC_NOUSE_DMA, NULL, NULL); + if( result != SDMC_NORMAL) { + PRINTDEBUG( "sdmcInit : failed\n"); + while( 1) {}; + }else{ + PRINTDEBUG( "sdmcInit : success\n"); + } + + /*デバイスドライバの登録*/ + PRINTDEBUG( "attach start\n"); + if( nandRtfsAttach( 5) == FALSE) { //nandをFドライブにする + PRINTDEBUG( "nandRtfsAttach failed.\n"); + }else{ + if( nandRtfsAttach( 5) == FALSE) { + PRINTDEBUG( "nandRtfsAttach success.\n"); + }else{ + PRINTDEBUG( "nandRtfsAttach error!.\n"); + } + } + + if( !rtfs_pc_set_default_drive( (unsigned char*)"F:")) { + PRINTDEBUG( "pc_set_default_drive failed\n"); + while( 1){}; + } + PRINTDEBUG( "pc_set_default_drive success\n"); + + /**/ + PRINTDEBUG( "pc_check_disk start. please wait.\n"); + pc_check_disk( (byte*)"F:", &dstat, 0, 1, 1); + PRINTDEBUG( "pc_check_disk end.\n"); + + + if( !rtfs_pc_get_media_parms( (byte*)"F:", &geometry)) { + PRINTDEBUG( "pc_get_media_parms failed\n"); + } + + if( !pc_format_media( (byte*)"F:", &geometry)) { + PRINTDEBUG( "pc_format_media failed\n"); + } + + if( !pc_format_volume( (byte*)"F:", &geometry)) { + PRINTDEBUG( "pc_format_volume failed\n"); + } + + + PRINTDEBUG( "Sample program ends.\n"); + + + while (TRUE) + { + OS_Halt(); + + //---- check reset + if (OS_IsResetOccurred()) + { + OS_ResetSystem(); + } + } +} + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + + Description: メモリ割当てシステムを初期化する。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystem(void) +{ + void *tempLo; + OSHeapHandle hh; + + OS_TPrintf("OS_GetWramSubPrivArenaLo() = %p\n", OS_GetWramSubPrivArenaLo()); + OS_TPrintf("OS_GetWramSubPrivArenaHi() = %p\n", OS_GetWramSubPrivArenaHi()); + OS_TPrintf("OS_GetWramSubArenaLo() = %p\n", OS_GetWramSubArenaLo()); + OS_TPrintf("OS_GetWramSubArenaHi() = %p\n", OS_GetWramSubArenaHi()); + OS_TPrintf("OS_GetSubPrivArenaLo() = %p\n", OS_GetSubPrivArenaLo()); + OS_TPrintf("OS_GetSubPrivArenaHi() = %p\n", OS_GetSubPrivArenaHi()); + + OS_TPrintf("call OS_SetWramSubPrivArenaHi(0x0380f980); to fix arena.\n"); + OS_SetWramSubPrivArenaHi((void*)0x0380f980); + + // メモリ割当て初期化 + tempLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, + OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi(), 1); + + // アリーナを0クリア + MI_CpuClear8(tempLo, (u32)OS_GetWramSubPrivArenaHi() - (u32)tempLo); + + // アリーナ下位アドレスを設定 + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, tempLo); + + // ヒープ作成 + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, + OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi()); + + if (hh < 0) + { + OS_Panic("ARM7: Fail to create heap.\n"); + } + + // カレントヒープに設定 + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + return hh; +} + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + + Description: VBlank interrupt handler + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +#ifndef SDK_TEG + +extern BOOL PMi_Initialized; +void PM_SelfBlinkProc(void); + +static void VBlankIntr(void) +{ + //---- LED blink system + if (PMi_Initialized) + { + PM_SelfBlinkProc(); + } +} + +#else + +static void VBlankIntr(void) +{ +} + +#endif + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/fatfs/nand_formatter_kmc/ARM9/Makefile b/build/tests/fatfs/nand_formatter_kmc/ARM9/Makefile new file mode 100644 index 0000000..c5404f3 --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/ARM9/Makefile @@ -0,0 +1,41 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - CAMERA - demos - camera-1 +# File: Makefile +# +# Copyright 2007 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. +# +# $Log: Makefile,v $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +SUBDIRS = + + +#---------------------------------------------------------------------------- + +#TWL_CODEGEN = THUMB + +TARGET_BIN = main.axf + +SRCS = main.c + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/fatfs/nand_formatter_kmc/ARM9/src/main.c b/build/tests/fatfs/nand_formatter_kmc/ARM9/src/main.c new file mode 100644 index 0000000..7a100f1 --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/ARM9/src/main.c @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - SND - demos - capture + File: main.c + + Copyright 2007 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. + + $Log: main.c,v $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#include + +static void VBlankIntr(void); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void TwlMain() +{ + // 初期化 + OS_Init(); + GX_Init(); + OS_InitTick(); + + // Vブランク割り込み設定 + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + { + u16 bg_color = GX_RGB(31, 0, 0); + GX_LoadBGPltt(&bg_color, 0, sizeof(u16)); + } + + while (1) + { + OS_WaitVBlankIntr(); + } +} + +//-------------------------------------------------------------------------------- +// Vブランク割り込み処理 +// +void VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt +} diff --git a/build/tests/fatfs/nand_formatter_kmc/Makefile b/build/tests/fatfs/nand_formatter_kmc/Makefile new file mode 100644 index 0000000..078ec37 --- /dev/null +++ b/build/tests/fatfs/nand_formatter_kmc/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - build +# File: Makefile +# +# Copyright 2007 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + ARM7 \ + ARM9 \ + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile =====