diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile index 4225387a..23dc3056 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile @@ -52,7 +52,8 @@ SRCS = main.c \ kami_pxi.c \ kami_write_nandfirm.c \ hw_info.c \ - keypad.c + keypad.c \ + kami_copy_file.c LINCLUDES = include \ ../common/include \ diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/include/kami_copy_file.h b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/include/kami_copy_file.h new file mode 100644 index 00000000..d2fb008c --- /dev/null +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/include/kami_copy_file.h @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - SystemUpdater + File: kami_copy_file.h + + 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$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_COPY_FILE_H_ +#define KAMI_COPY_FILE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +BOOL kamiCopyFile(char* srcPath, char* dstPath); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_COPY_FILE_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/main.rsf b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/main.rsf index fe28d02a..741fdbe7 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/main.rsf +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/main.rsf @@ -228,5 +228,5 @@ RomSpec File $(HWINFO_PRIVKEY) HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_tools/NandInitializerRed/data Root /data - File camera_volatile_info.bin + File camera_volatile_info.bin TWLFontTable.dat } diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/kami_copy_file.c b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/kami_copy_file.c new file mode 100644 index 00000000..c9365276 --- /dev/null +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/kami_copy_file.c @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_copy_file.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 "kami_font.h" +#include "kami_copy_file.h" + +/*---------------------------------------------------------------------------* + マクロ + *---------------------------------------------------------------------------*/ + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +BOOL kamiCopyFile(char* srcPath, char* dstPath) +{ + FSFile file; + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + + // ROMファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, srcPath); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", srcPath); + return FALSE; + } + + // ROMファイルリード + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", srcPath); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMファイルクローズ + FS_CloseFile(&file); + + // 一旦対象データを削除する + (void)FS_DeleteFile(dstPath); + + // ターゲットファイル作成 + if (!FS_CreateFile(dstPath, FS_PERMIT_R | FS_PERMIT_W)) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_CreateFile(%s) failed.\n", dstPath); + result = FALSE; + } + else + { + // ターゲットファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFileEx(&file, dstPath, FS_FILEMODE_W); + if (!open_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_OpenFile(%s) failed.\n", dstPath); + result = FALSE; + } + // nand:sys/TWLFontTable.dat書き込み + else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_WritFile() failed.\n"); + result = FALSE; + } + (void)FS_CloseFile(&file); + } + + OS_Free(pTempBuf); + + return result; +} + diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c index 76b0ff8e..b08cb70d 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c @@ -24,6 +24,7 @@ #include "kami_pxi.h" #include "kami_font.h" #include "kami_write_nandfirm.h" +#include "kami_copy_file.h" #include "import.h" #include "hw_info.h" #include "graphics.h" @@ -45,11 +46,18 @@ typedef struct _SystemUpdaterLog int reserve[5]; } SystemUpdaterLog; +typedef struct _CopyFileList +{ + char* srcPath; + char* dstPath; +} CopyFileList; + /*---------------------------------------------------------------------------* 内部定数定義 *---------------------------------------------------------------------------*/ #define SYSTEM_UPDATER_LOG_PATH "nand:/sys/log/updater.log" +#define NAND_FIRM_PATH_IN_ROM "rom:/data/menu_launcher.nand" #define SYSTEM_UPDATER_MAGIC_CODE 44001111 @@ -63,13 +71,17 @@ static const char* ImportTadFileList[] = "rom:/data/HNCA.tad" }; -static const char* NandFirmPath = "rom:/data/menu_launcher.nand"; +static const CopyFileList sCopyFileList[] = +{ + { "rom:/data/TWLFontTable.dat", "nand:sys/TWLFontTable.dat" } +}; /*---------------------------------------------------------------------------* 内部変数定義 *---------------------------------------------------------------------------*/ static NAMTitleId titleId; +static s16 printLine; /*---------------------------------------------------------------------------* 内部関数定義 @@ -215,7 +227,7 @@ TwlMain() hw_info_result = WriteHWInfoFile(OS_GetRegion(), OS_IsForceDisableWireless()); if (hw_info_result) { - kamiFontPrintf( 0, (s16)0, FONT_COLOR_GREEN, "Write Hardware Info Success."); + kamiFontPrintf( 0, printLine++, FONT_COLOR_GREEN, "Write Hardware Info Success."); break; } else @@ -226,7 +238,21 @@ TwlMain() if ( hw_info_result == FALSE) { result = FALSE; - kamiFontPrintf( 0, (s16)0, FONT_COLOR_RED, "Write Hardware Info Failure!"); + kamiFontPrintf( 0, printLine++, FONT_COLOR_RED, "Write Hardware Info Failure!"); + } + + // 必要なファイルの書き込み + for (i=0;i