diff --git a/build/libraries/fs/ARM7/Makefile b/build/libraries/fs/ARM7/Makefile index 20d58305..f76a36c4 100644 --- a/build/libraries/fs/ARM7/Makefile +++ b/build/libraries/fs/ARM7/Makefile @@ -32,8 +32,9 @@ LINCLUDES = \ $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \ $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 -SRCS = fs_firm.c fs_firm_ex.c fs_loader.c +SRCS = fs_firm.c fs_firm_ex.c fs_loader.c fs_unicode.c +SRCDIR = ./src ../common/src TARGET_LIB = libfs_sp$(FIRM_LIBSUFFIX).a diff --git a/build/libraries/fs/ARM9/Makefile b/build/libraries/fs/ARM9/Makefile index 5a6beaac..66a6fa7a 100644 --- a/build/libraries/fs/ARM9/Makefile +++ b/build/libraries/fs/ARM9/Makefile @@ -24,8 +24,9 @@ SUBMAKES = LINCLUDES = $(ES_ROOT)/twl/include -SRCS = fs_firm.c fs_loader.c +SRCS = fs_firm.c fs_loader.c fs_unicode.c +SRCDIR = ./src ../common/src TARGET_LIB = libfs$(FIRM_LIBSUFFIX).a diff --git a/build/libraries/fs/ARM9/src/fs_firm.c b/build/libraries/fs/ARM9/src/fs_firm.c index 394dfbff..21b8cd8f 100644 --- a/build/libraries/fs/ARM9/src/fs_firm.c +++ b/build/libraries/fs/ARM9/src/fs_firm.c @@ -208,6 +208,8 @@ BOOL FS_GetTitleBootContentPathFast(char* buf, OSTitleId titleId) /*---------------------------------------------------------------------------* Name: SEA_Decrypt + SEA_GetCryptoBufferAddr + SEA_GetCryptoBufferSize Description: stub function @@ -224,6 +226,11 @@ SDK_WEAK_SYMBOL AESResult SEA_Decrypt(const void* src, u32 srcSize, void* dst) (void)dst; return AES_RESULT_SUCCESS; } +#define SEA_ADDR_WRAM_1 ((u32)0x03004000u) +u32 SEA_GetCryptoBufferAddr(void); +SDK_WEAK_SYMBOL u32 SEA_GetCryptoBufferAddr(void) __attribute__((never_inline)) { return SEA_ADDR_WRAM_1; } +u32 SEA_GetCryptoBufferSize(void); +SDK_WEAK_SYMBOL u32 SEA_GetCryptoBufferSize(void) __attribute__((never_inline)) { return HW_WRAM_1_SIZE; } /*---------------------------------------------------------------------------* Name: FS_ResolveSrl diff --git a/build/libraries/fs/common/src/fs_unicode.c b/build/libraries/fs/common/src/fs_unicode.c new file mode 100644 index 00000000..e9a49dc2 --- /dev/null +++ b/build/libraries/fs/common/src/fs_unicode.c @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_unicode.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. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +/*---------------------------------------------------------------------------* + Name: FSi_ConvertStringSjisToUnicode + + Description: ShiftJIS文字列をUnicode文字列に変換。 + 扱うパス名が明らかにASCIIのみである場合など + UnicodeとShiftJISの相互変換を簡略化できる場合は + この関数をオーバーライドすることによって + STDライブラリの標準処理がリンクされるのを防ぐことができる。 + + Arguments: dst 変換先バッファ. + NULL を指定すると格納処理は無視される. + dst_len 変換先バッファの最大文字数を格納して渡し, + 実際に格納された文字数を受け取るポインタ. + NULL を与えた場合は無視される. + src 変換元バッファ. + src_len 変換すべき最大文字数を格納して渡し, + 実際に変換された文字数を受け取るポインタ. + この指定よりも文字列終端の位置が優先される. + 負の値を格納して渡すか NULL を与えた場合は + 終端位置までの文字数を指定したとみなされる. + callback 変換できない文字が現れた時に呼ばれるコールバック. + NULLを指定した場合, 変換できない文字の位置で + 変換処理を終了する. + + Returns: 変換処理の結果. + *---------------------------------------------------------------------------*/ +STDResult FSi_ConvertStringSjisToUnicode(u16 *dst, int *dst_len, + const char *src, int *src_len, + STDConvertUnicodeCallback callback) +{ +#pragma unused(callback) + STDResult result = STD_RESULT_SUCCESS; + int i; + int max = 0x7FFFFFFF; + if (src_len && (*src_len >= 0)) + { + max = *src_len; + } + if (dst && dst_len && (*dst_len >= 0) && (*dst_len < max)) + { + max = *dst_len; + } + for (i = 0; i < max; ++i) + { + int c = ((const u8 *)src)[i]; + if (c == 0) + { + break; + } + else if (c >= 0x80) + { + result = STD_RESULT_ERROR; + break; + } + dst[i] = (u16)c; + } + if (src_len) + { + *src_len = i; + } + if (dst_len) + { + *dst_len = i; + } + return result; +} + +/*---------------------------------------------------------------------------* + Name: FSi_ConvertStringUnicodeToSjis + + Description: Unicode文字列をShiftJIS文字列に変換。 + 扱うパス名が明らかにASCIIのみである場合など + UnicodeとShiftJISの相互変換を簡略化できる場合は + この関数をオーバーライドすることによって + STDライブラリの標準処理がリンクされるのを防ぐことができる。 + + Arguments: dst 変換先バッファ. + NULL を指定すると格納処理は無視される. + dst_len 変換先バッファの最大文字数を格納して渡し, + 実際に格納された文字数を受け取るポインタ. + NULL を与えた場合は無視される. + src 変換元バッファ. + src_len 変換すべき最大文字数を格納して渡し, + 実際に変換された文字数を受け取るポインタ. + この指定よりも文字列終端の位置が優先される. + 負の値を格納して渡すか NULL を与えた場合は + 終端位置までの文字数を指定したとみなされる. + callback 変換できない文字が現れた時に呼ばれるコールバック. + NULLを指定した場合, 変換できない文字の位置で + 変換処理を終了する. + + Returns: 変換処理の結果. + *---------------------------------------------------------------------------*/ +STDResult FSi_ConvertStringUnicodeToSjis(char *dst, int *dst_len, + const u16 *src, int *src_len, + STDConvertSjisCallback callback) +{ +#pragma unused(callback) + STDResult result = STD_RESULT_SUCCESS; + int i; + int max = 0x7FFFFFFF; + if (src_len && (*src_len >= 0)) + { + max = *src_len; + } + if (dst && dst_len && (*dst_len >= 0) && (*dst_len < max)) + { + max = *dst_len; + } + for (i = 0; i < max; ++i) + { + int c = ((const u16 *)src)[i]; + if (c == 0) + { + break; + } + else if (c >= 0x80) + { + result = STD_RESULT_ERROR; + break; + } + dst[i] = (char)c; + } + if (src_len) + { + *src_len = i; + } + if (dst_len) + { + *dst_len = i; + } + return result; +}