add nand formatter (testing:partition0 begin 8MB offset)

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@139 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
shirait 2007-06-27 06:37:53 +00:00
parent 29e5aff217
commit 7d81fcc01a
9 changed files with 517 additions and 25 deletions

View File

@ -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 <ctr/vlink.h>
#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;

View File

@ -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 <ctr/vlink.h>
#define PRINTDEBUG vlink_dos_printf
#endif
#define PRINTDEBUG OS_TPrintf
#else
#define PRINTDEBUG( ...) ((void)0)
#endif

View File

@ -11,16 +11,11 @@
#include <twl/sdmc.h>
#include "sdif_ip.h" /* IP 対応フラグ定義 */
#if (SD_DEBUG_PRINT_ON == 1)
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
#define PRINTDEBUG osTPrintf
#else
#include <ctr/vlink.h>
#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

View File

@ -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 =====

View File

@ -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)
}

View File

@ -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 <twl_sp.h>
#include <twl/vlink.h>
#include <twl/fatfs/ARM7/rtfs.h>
#include <twl/devices/sdmc/ARM7/sdmc.h>
#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
*---------------------------------------------------------------------------*/

View File

@ -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 =====

View File

@ -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 <twl.h>
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
}

View File

@ -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 =====