mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@8 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
6867b64f4a
commit
7979f8d430
@ -66,7 +66,7 @@ static void *proutPrintf(void *fd, const char *buf, size_t n)
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
OS_PutChar( buf[i] );
|
||||
m_putchar( (void *)tc[0], buf[i] );
|
||||
// m_putchar( (void *)tc[0], buf[i] );
|
||||
}
|
||||
|
||||
if( fd != NULL ) {
|
||||
|
||||
@ -564,6 +564,7 @@ static BOOL CheckSystemApp(char path[])
|
||||
char c;
|
||||
int num;
|
||||
/*
|
||||
|
||||
No. 0 0003000f484e4c41
|
||||
No. 1 0003000f484e4841
|
||||
No. 2 0003000f484e4341
|
||||
@ -573,11 +574,18 @@ static BOOL CheckSystemApp(char path[])
|
||||
| ここの最下位ビットが1のやつがシステムアプリ
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
|
||||
012345678901234567890123456789
|
||||
nand:/title/00030017/484e4141 は ランチャー
|
||||
|
||||
*/
|
||||
c = path[19];
|
||||
if( ('a' <= c) && (c <= 'f') ) {
|
||||
num = (int)( c - 'a' + 10 );
|
||||
}
|
||||
if( ('A' <= c) && (c <= 'F') ) {
|
||||
num = (int)( c - 'A' + 10 );
|
||||
}
|
||||
else if( ('0' <= c) && (c <= '9') ) {
|
||||
num = (int)( c - '0' );
|
||||
}
|
||||
@ -595,32 +603,42 @@ static BOOL CheckSystemApp(char path[])
|
||||
}
|
||||
}
|
||||
|
||||
void GetDirEntryList( MY_DIR_ENTRY_LIST *head, void **pBuffer, int *size)
|
||||
#define MYDEBUG 1
|
||||
|
||||
void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
{
|
||||
int i;
|
||||
int count = 0;
|
||||
MY_DIR_ENTRY_LIST *list_temp;
|
||||
char *buf;
|
||||
|
||||
u64 *buf;
|
||||
char c;
|
||||
u8 hex;
|
||||
|
||||
if( head == NULL ) {
|
||||
}
|
||||
else {
|
||||
for( list_temp = head ; list_temp->next != NULL ; list_temp = list_temp->next ) {
|
||||
if( list_temp->src_path ) {
|
||||
#ifdef MYDEBUG
|
||||
if( FALSE == CheckSystemApp( list_temp->src_path) ) {
|
||||
count++;
|
||||
}
|
||||
#else
|
||||
count++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
OS_TPrintf("User App. count1 = %d\n", count);
|
||||
|
||||
if( count ) {
|
||||
buf = (char *)OS_Alloc( (u32)(count * 16) );
|
||||
STD_MemSet((void *)buf, 0, sizeof(count * 16));
|
||||
buf = (u64 *)OS_Alloc( (u32)(count * sizeof(u64)) );
|
||||
STD_MemSet((void *)buf, 0, count * sizeof(u64));
|
||||
}
|
||||
else {
|
||||
buf = NULL;
|
||||
}
|
||||
*pBuffer = (void *)buf;
|
||||
*pBuffer = buf;
|
||||
*size = count;
|
||||
|
||||
|
||||
@ -638,18 +656,59 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, void **pBuffer, int *size)
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
#ifdef MYDEBUG
|
||||
if( FALSE == CheckSystemApp( list_temp->src_path ) ) {
|
||||
#endif
|
||||
count++;
|
||||
|
||||
/* User App. */
|
||||
for( i = 0 ; i < 8 ; i++ ) {
|
||||
*buf++ = list_temp->src_path[12 + i];
|
||||
c = list_temp->src_path[12 + i];
|
||||
hex = 0;
|
||||
if( ('a' <= c) && (c <= 'f') ) {
|
||||
hex = (u8)( c - 'a' + 10 );
|
||||
}
|
||||
else if( ('A' <= c) && (c <= 'F') ) {
|
||||
hex = (u8)( c - 'A' + 10 );
|
||||
}
|
||||
else if( ('0' <= c) && (c <= '9') ) {
|
||||
hex = (u8)(c - '0');
|
||||
}
|
||||
else {
|
||||
/* error! */
|
||||
count--;
|
||||
return;
|
||||
}
|
||||
*buf |= (((u64)hex) << ((7-i)*4 + 32 ));
|
||||
}
|
||||
|
||||
for( i = 0 ; i < 8 ; i++ ) {
|
||||
*buf++ = list_temp->src_path[21 + i];
|
||||
c = list_temp->src_path[21 + i];
|
||||
hex = 0;
|
||||
if( ('a' <= c) && (c <= 'f') ) {
|
||||
hex = (u8)( c - 'a' + 10 );
|
||||
}
|
||||
else if( ('A' <= c) && (c <= 'F') ) {
|
||||
hex = (u8)( c - 'A' + 10 );
|
||||
}
|
||||
else if( ('0' <= c) && (c <= '9') ) {
|
||||
hex = (u8)(c - '0');
|
||||
}
|
||||
else {
|
||||
/* error! */
|
||||
count--;
|
||||
return;
|
||||
}
|
||||
*buf |= (((u64)hex) << ((7-i)*4 ));
|
||||
}
|
||||
buf++;
|
||||
OS_TPrintf("User App. count2 = %d\n", count);
|
||||
|
||||
#ifdef MYDEBUG
|
||||
}
|
||||
OS_TPrintf("User App. count = %d\n", count);
|
||||
#endif
|
||||
/*
|
||||
012345678901234567890123456789
|
||||
nand:/title/00030017/484e4141 は ランチャー
|
||||
nand:/title/00030015/484e4641 は shop
|
||||
nand:/title/00030015/484e4241 は 本体設定
|
||||
@ -689,7 +748,7 @@ void PrintSrcDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd)
|
||||
|
||||
|
||||
|
||||
BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
int SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
{
|
||||
FSFile f;
|
||||
FSFile f_src;
|
||||
@ -700,36 +759,39 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
MY_DIR_ENTRY_LIST *list_temp;
|
||||
int list_count = 0;
|
||||
|
||||
FSFile log_fd;
|
||||
FSFile log_fd_real;
|
||||
FSFile *log_fd;
|
||||
BOOL log_active = FALSE;
|
||||
// char *log_file_name = "sdmc:/miya/save_dir_entry_log.txt";
|
||||
char *log_file_name = NULL;
|
||||
|
||||
/* ここでSDカードがあるかどうか調べる */
|
||||
log_fd = &log_fd_real;
|
||||
|
||||
log_active = Log_File_Open( &log_fd, log_file_name );
|
||||
/* ここでSDカードがあるかどうか調べる */
|
||||
log_active = Log_File_Open( log_fd, log_file_name );
|
||||
if( !log_active ) {
|
||||
log_fd = NULL;
|
||||
}
|
||||
|
||||
/* 最初にSD側のルートディレクトリのデータを消しとくべきか?
|
||||
せっかくファイルリストに記録してるのでもったいない→必要ない */
|
||||
FS_InitFile(&f);
|
||||
FS_InitFile(&f_src);
|
||||
FS_InitFile(&f_dst);
|
||||
|
||||
if( path == NULL ) {
|
||||
miya_log_fprintf(&log_fd, "%s %d not specify entry save file\n",__FUNCTION__,__LINE__ );
|
||||
return FALSE;
|
||||
miya_log_fprintf(log_fd, "%s %d not specify entry save file\n",__FUNCTION__,__LINE__ );
|
||||
return -1;
|
||||
}
|
||||
FS_CreateFileAuto(path, (FS_PERMIT_R|FS_PERMIT_W));
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
|
||||
if (bSuccess == FALSE) {
|
||||
fsResult = FS_GetArchiveResultCode(path);
|
||||
miya_log_fprintf(&log_fd, "Failed create file - dir entry list file:%d\n", fsResult );
|
||||
return FALSE;
|
||||
miya_log_fprintf(log_fd, "Failed create file - dir entry list file:%d\n", fsResult );
|
||||
return -1;
|
||||
}
|
||||
|
||||
fsResult = FS_SetFileLength(&f, 0);
|
||||
if( fsResult != FS_RESULT_SUCCESS ) {
|
||||
miya_log_fprintf(&log_fd, "Failed set file len - dir entry list file:%d\n", fsResult );
|
||||
miya_log_fprintf(log_fd, "Failed set file len - dir entry list file:%d\n", fsResult );
|
||||
}
|
||||
|
||||
/* バックワードでファイルに保存 */
|
||||
@ -743,14 +805,14 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
// OS_TPrintf( "name = %s\n", list_temp->src_path );
|
||||
/* SDにログを残す場合 */
|
||||
if( log_active ) {
|
||||
miya_log_fprintf(&log_fd, "%s\n", list_temp->src_path);
|
||||
miya_log_fprintf(log_fd, "%s\n", list_temp->src_path);
|
||||
}
|
||||
|
||||
writtenSize = FS_WriteFile(&f, (void *)list_temp, (s32)sizeof(MY_DIR_ENTRY_LIST) );
|
||||
if( writtenSize != sizeof(MY_DIR_ENTRY_LIST) ) {
|
||||
miya_log_fprintf(&log_fd, "%s %d: Failed write file\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(&log_fd, " %s\n", path);
|
||||
miya_log_fprintf(&log_fd, " entry count %d\n", list_count );
|
||||
miya_log_fprintf(log_fd, "%s %d: Failed write file\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(log_fd, " %s\n", path);
|
||||
miya_log_fprintf(log_fd, " entry count %d\n", list_count );
|
||||
}
|
||||
|
||||
/* SD側にディレクトリの作成とファイルのコピー */
|
||||
@ -761,10 +823,10 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
if(!bSuccess) {
|
||||
fsResult = FS_GetArchiveResultCode(list_temp->dst_path);
|
||||
if( fsResult != FS_RESULT_ALREADY_DONE ) {
|
||||
miya_log_fprintf(&log_fd, "%s %d: Failed Create DST Directory\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(&log_fd, " %s\n", list_temp->dst_path);
|
||||
miya_log_fprintf(&log_fd, " %s\n", my_fs_util_get_fs_result_word( fsResult ) );
|
||||
return FALSE;
|
||||
miya_log_fprintf(log_fd, "%s %d: Failed Create DST Directory\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(log_fd, " %s\n", list_temp->dst_path);
|
||||
miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( fsResult ) );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -776,7 +838,7 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
else {
|
||||
/* NANDからSDにコピーする */
|
||||
// CopyFile( dst <= src );
|
||||
CopyFile(list_temp->dst_path, list_temp->src_path, &log_fd );
|
||||
CopyFile(list_temp->dst_path, list_temp->src_path, log_fd );
|
||||
}
|
||||
}
|
||||
list_count++;
|
||||
@ -786,16 +848,18 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
FS_FlushFile(&f);
|
||||
|
||||
if( FS_CloseFile(&f) == FALSE) {
|
||||
miya_log_fprintf(&log_fd, "%s %d: Failed Close file\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(&log_fd, " %s\n", path);
|
||||
miya_log_fprintf(&log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ) );
|
||||
miya_log_fprintf(log_fd, "%s %d: Failed Close file\n", __FUNCTION__ , __LINE__ );
|
||||
miya_log_fprintf(log_fd, " %s\n", path);
|
||||
miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ) );
|
||||
}
|
||||
miya_log_fprintf(NULL, "write etnry list count %d\n", list_count);
|
||||
|
||||
if( log_active ) {
|
||||
Log_File_Close(&log_fd);
|
||||
miya_log_fprintf(log_fd, "write entry list count %d\n", list_count);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
if( log_active ) {
|
||||
Log_File_Close(log_fd);
|
||||
}
|
||||
return list_count;
|
||||
}
|
||||
|
||||
/********************************************
|
||||
@ -1102,11 +1166,11 @@ BOOL MydataSave(const char *path, void *pData, int size, FSFile *log_fd)
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
|
||||
if( ! bSuccess ) {
|
||||
FS_CreateFileAuto( path, FS_PERMIT_W);
|
||||
FS_CreateFileAuto( path, FS_PERMIT_W|FS_PERMIT_R);
|
||||
bSuccess = FS_OpenFileEx(&f, path , FS_FILEMODE_W );
|
||||
if( ! bSuccess ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "log file open error %s\n", path );
|
||||
miya_log_fprintf(NULL, "%s file open error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed open file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
@ -1128,6 +1192,125 @@ BOOL MydataSave(const char *path, void *pData, int size, FSFile *log_fd)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL TitleIDLoad(const char *path, u64 **pBuffer, int *count, FSFile *log_fd)
|
||||
{
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
// u32 fileSize;
|
||||
s32 readSize = 0;
|
||||
int id_count= 0;
|
||||
int size;
|
||||
|
||||
FS_InitFile(&f);
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_R);
|
||||
if( ! bSuccess ) {
|
||||
miya_log_fprintf(log_fd, "Failed Open File %s\n",__FUNCTION__);
|
||||
miya_log_fprintf(log_fd, " path=%s\n", path );
|
||||
miya_log_fprintf(log_fd, " res=%s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( sizeof(int) != FS_ReadFile(&f, &id_count, (s32)sizeof(int)) ) {
|
||||
miya_log_fprintf(log_fd, "Failed Read File %s\n",__FUNCTION__);
|
||||
miya_log_fprintf(log_fd, " path=%s\n", path );
|
||||
miya_log_fprintf(log_fd, " res=%s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
*count = id_count;
|
||||
size = (int)sizeof(u64) * id_count;
|
||||
|
||||
*pBuffer = (u64 *)OS_Alloc( (u32)size );
|
||||
if( *pBuffer == NULL ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
readSize = FS_ReadFile(&f, *pBuffer, (s32)size );
|
||||
if( readSize != size ) {
|
||||
miya_log_fprintf(log_fd, "Failed Read File: %s\n",path);
|
||||
}
|
||||
bSuccess = FS_CloseFile(&f);
|
||||
if( ! bSuccess ) {
|
||||
miya_log_fprintf(log_fd, "Failed Close File\n");
|
||||
miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path)));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd)
|
||||
{
|
||||
#pragma unused(log_fd)
|
||||
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
FSResult res;
|
||||
FSResult fsResult;
|
||||
// s32 writtenSize;
|
||||
|
||||
FS_InitFile(&f);
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
|
||||
if( ! bSuccess ) {
|
||||
FS_CreateFileAuto( path, FS_PERMIT_W|FS_PERMIT_R);
|
||||
bSuccess = FS_OpenFileEx(&f, path , FS_FILEMODE_W );
|
||||
if( ! bSuccess ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file open error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed open file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
fsResult = FS_SetFileLength(&f, 0);
|
||||
if( fsResult != FS_RESULT_SUCCESS ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file length error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed file lenght :%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( sizeof(int) != FS_WriteFile(&f, &count, (s32)sizeof(int)) ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
nand:/title/00030005/484e4541
|
||||
nand:/title/00030005/484e4441
|
||||
nand:/title/0003000f/484e4c4a
|
||||
nand:/title/0003000f/484e4841
|
||||
nand:/title/0003000f/484e4341
|
||||
nand:/title/00030015/484e424a
|
||||
nand:/title/00030017/484e414a
|
||||
*/
|
||||
|
||||
/* 16文字だから */
|
||||
if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FS_FlushFile(&f);
|
||||
bSuccess = FS_CloseFile(&f);
|
||||
if( bSuccess ) {
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* SDカードがあるかどうか */
|
||||
BOOL SDCardValidation(void)
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ void PrintDirEntryListForward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd );
|
||||
void PrintDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd );
|
||||
void PrintSrcDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd);
|
||||
|
||||
BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path );
|
||||
int SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path );
|
||||
BOOL RestoreDirEntryList( char *path );
|
||||
BOOL ClearDirEntryList( MY_DIR_ENTRY_LIST **headp );
|
||||
void write_debug_data(void);
|
||||
@ -38,7 +38,9 @@ BOOL SDCardValidation(void);
|
||||
BOOL CheckShopRecord(FSFile *log_fd);
|
||||
BOOL MydataSave(const char *path, void *pData, int size, FSFile *log_fd);
|
||||
BOOL MydataLoad(const char *path, void *pBuffer, int size, FSFile *log_fd);
|
||||
void GetDirEntryList( MY_DIR_ENTRY_LIST *head, void **pBuffer, int *size);
|
||||
void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size);
|
||||
BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd);
|
||||
BOOL TitleIDLoad(const char *path, u64 **pBuffer, int *count, FSFile *log_fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
#define NVRAM_INTERNAL_BUF_SIZE 0x100
|
||||
static u8 nvram_buffer[NVRAM_INTERNAL_BUF_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
//static char nor_file_path[FS_FILE_NAME_MAX];
|
||||
|
||||
|
||||
static BOOL my_nvram_read( u32 offset, u32 size, void *buf)
|
||||
{
|
||||
u32 internal_size = size;
|
||||
@ -102,16 +105,33 @@ static const char * const fs_result_strings[] =
|
||||
"FS_RESULT_ALREADY_DONE",
|
||||
"FS_RESULT_PERMISSION_DENIED",
|
||||
"FS_RESULT_MEDIA_FATAL",
|
||||
"FS_RESULT_NO_ENTRY",
|
||||
"FS_RESULT_MEDIA_NOTHING",
|
||||
"FS_RESULT_MEDIA_UNKNOWN",
|
||||
"FS_RESULT_BAD_FORMAT"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const size_t fs_result_string_max = sizeof(fs_result_strings) / sizeof(*fs_result_strings);
|
||||
|
||||
static void ReportLastErrorPath(const char *path)
|
||||
{
|
||||
FSResult result = FS_GetArchiveResultCode(path);
|
||||
if( (result >= 0) && (result < fs_result_string_max)) {
|
||||
OS_TPrintf("FS error: \"%s\" %s\n", path, fs_result_strings[result]);
|
||||
mprintf("FS error: \"%s\" %s\n", path, fs_result_strings[result]);
|
||||
}
|
||||
else {
|
||||
OS_TPrintf("FS error: unknown\n");
|
||||
mprintf("FS error:\n unknown\n");
|
||||
}
|
||||
|
||||
SDK_ASSERT((result >= 0) && (result < fs_result_string_max));
|
||||
mprintf("FS error:\n \"%s\"\n %s\n",
|
||||
path, fs_result_strings[result]);
|
||||
}
|
||||
|
||||
BOOL nvram_backup(char *path)
|
||||
@ -121,20 +141,19 @@ BOOL nvram_backup(char *path)
|
||||
u16 offset;
|
||||
u32 vol;
|
||||
int len;
|
||||
char nor_file_path[FS_FILE_NAME_MAX];
|
||||
#define BUF_SIZE 0x100
|
||||
u8 nor_buf[BUF_SIZE];
|
||||
|
||||
char *nor_file_path = path;
|
||||
|
||||
FS_InitFile(&nor_fd);
|
||||
// STD_TSNPrintf(nor_file_path, sizeof(nor_file_path), "sdmc:/twl_nor.bin");
|
||||
STD_TSNPrintf(nor_file_path, sizeof(nor_file_path), path );
|
||||
|
||||
// STD_TSNPrintf(nor_file_path, sizeof(nor_file_path), path );
|
||||
bSuccess = FS_OpenFileEx(&nor_fd, nor_file_path, (FS_FILEMODE_R|FS_FILEMODE_W));
|
||||
if( ! bSuccess )
|
||||
{
|
||||
if( !FS_CreateFile(nor_file_path, FS_PERMIT_R | FS_PERMIT_W)) {
|
||||
if( !FS_CreateFileAuto(nor_file_path, FS_PERMIT_R | FS_PERMIT_W)) {
|
||||
ReportLastErrorPath(nor_file_path);
|
||||
OS_TWarning("2 FS_CreateFile(%s) failed.", nor_file_path);
|
||||
OS_TPrintf("2 FS_CreateFileAuto(%s) failed.", nor_file_path);
|
||||
return FALSE;
|
||||
}
|
||||
bSuccess = FS_OpenFileEx(&nor_fd, nor_file_path, (FS_FILEMODE_R|FS_FILEMODE_W));
|
||||
@ -143,14 +162,13 @@ BOOL nvram_backup(char *path)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if( TRUE != my_nvram_read( NVRAM_PERSONAL_DATA_OFFSET , sizeof(u16), (void* )&offset) ) {
|
||||
OS_TPrintf( "nvram error: %s %s %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else {
|
||||
OS_TPrintf( "nvram success: offset = 0x%02x\n", offset);
|
||||
}
|
||||
|
||||
|
||||
if( offset == 0 ) {
|
||||
OS_TPrintf( "nvram error: offset = 0x%02x\n", offset);
|
||||
return FALSE;
|
||||
@ -158,7 +176,7 @@ BOOL nvram_backup(char *path)
|
||||
|
||||
offset *= 8;
|
||||
offset -= 0xA00;
|
||||
|
||||
|
||||
for( vol = 0 ; vol < NVRAM_PERSONAL_DATA_SIZE ; vol += BUF_SIZE ) {
|
||||
OS_TPrintf(".");
|
||||
if( TRUE != my_nvram_read( offset+vol , BUF_SIZE, (void* )nor_buf) ) {
|
||||
@ -168,7 +186,7 @@ BOOL nvram_backup(char *path)
|
||||
len = FS_WriteFile(&nor_fd, nor_buf, BUF_SIZE);
|
||||
if (len != BUF_SIZE)
|
||||
{
|
||||
OS_TWarning("FS_WriteFile() failed.");
|
||||
OS_TPrintf("FS_WriteFile() failed.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -190,12 +208,14 @@ BOOL nvram_restore(char *path)
|
||||
u16 offset;
|
||||
u32 vol;
|
||||
int len;
|
||||
char nor_file_path[FS_FILE_NAME_MAX];
|
||||
// char nor_file_path[FS_FILE_NAME_MAX];
|
||||
char *nor_file_path = path;
|
||||
|
||||
#define BUF_SIZE 0x100
|
||||
u8 nor_buf[BUF_SIZE];
|
||||
|
||||
FS_InitFile(&nor_fd);
|
||||
STD_TSNPrintf(nor_file_path, sizeof(nor_file_path), path );
|
||||
// STD_TSNPrintf(nor_file_path, sizeof(nor_file_path), path );
|
||||
bSuccess = FS_OpenFileEx(&nor_fd, nor_file_path, FS_FILEMODE_R);
|
||||
if( ! bSuccess ) {
|
||||
OS_TPrintf("error %s %s %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@ -223,7 +243,7 @@ BOOL nvram_restore(char *path)
|
||||
|
||||
len = FS_ReadFile(&nor_fd, nor_buf, BUF_SIZE);
|
||||
if (len != BUF_SIZE) {
|
||||
OS_TWarning("FS_ReadFile() failed.");
|
||||
OS_TPrintf("FS_ReadFile() failed.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -249,7 +249,7 @@ BOOL LoadWlanConfigFile(char *path)
|
||||
}
|
||||
else if( ('A' <= c) && (c <= 'F') ) {
|
||||
if( lo_hi == 0 ) {
|
||||
hex = (u8)(( c - 'a' + 10 ) * 16);
|
||||
hex = (u8)(( c - 'A' + 10 ) * 16);
|
||||
}
|
||||
else {
|
||||
hex += (u8)( c - 'a' + 10 );
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#define R_CHANNEL 5
|
||||
#define ALARM_NUM 0
|
||||
#define STREAM_THREAD_PRIO 12
|
||||
#define THREAD_STACK_SIZE 1024
|
||||
#define THREAD_STACK_SIZE (1024 * 4)
|
||||
#define STRM_BUF_PAGESIZE 1024*32
|
||||
#define STRM_BUF_SIZE STRM_BUF_PAGESIZE*2
|
||||
|
||||
|
||||
@ -413,6 +413,7 @@ void TwlMain(void)
|
||||
int count;
|
||||
int i,j;
|
||||
char *ptr;
|
||||
#if 0
|
||||
GetDirEntryList( dir_entry_list_head, &pBuffer, &count);
|
||||
OS_TPrintf("count = %d\n", count );
|
||||
ptr = (char *)pBuffer;
|
||||
@ -428,6 +429,8 @@ void TwlMain(void)
|
||||
}
|
||||
OS_Free(pBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -66,6 +66,10 @@ typedef struct {
|
||||
RTCDate rtc_date;
|
||||
RTCTime rtc_time;
|
||||
BOOL shop_record_flag;
|
||||
int num_of_user_download_app;
|
||||
int num_of_app_save_data;
|
||||
int num_of_photo_files;
|
||||
int num_of_shared2_files;
|
||||
u8 movableUniqueID[ LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN ]; // 移行可能なユニークID 16byte
|
||||
} MyData;
|
||||
|
||||
@ -74,6 +78,259 @@ static MyData mydata;
|
||||
static int vram_num_main = 1;
|
||||
static int vram_num_sub = 0;
|
||||
|
||||
static char path_base[256];
|
||||
static char path_log[256];
|
||||
static char path[256];
|
||||
static LCFGTWLHWNormalInfo hwn_info;
|
||||
static LCFGTWLHWSecureInfo hws_info;
|
||||
|
||||
|
||||
|
||||
static void BackupToSDCard(void)
|
||||
{
|
||||
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
|
||||
RTCDate rtc_date;
|
||||
RTCTime rtc_time;
|
||||
int save_dir_info = 0;
|
||||
u64 *pBuffer;
|
||||
int count;
|
||||
int i,j;
|
||||
u64 *ptr;
|
||||
|
||||
|
||||
//miya mprintf("BACKUP to SD Card\n");
|
||||
/************************************/
|
||||
STD_StrCpy( path_base , "sdmc:/" );
|
||||
STD_StrCat( path_base , (const char *)hws_info.serialNo );
|
||||
STD_StrCat( path_base , "/" );
|
||||
|
||||
|
||||
|
||||
/* nand:/sysディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_ninfo.dat" );
|
||||
// mprintf("HWInfo Normal backup ");
|
||||
mprintf("Unique ID backup ");
|
||||
if( TRUE == MiyaBackupHWNormalInfo( path ) ) {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
|
||||
/* Wifi設定の保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_nor.bin" );
|
||||
mprintf("WirelessLAN param. backup ");
|
||||
if( TRUE == nvram_backup( path ) ) {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
/* nand:/shared1ディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_cfg.dat" );
|
||||
//mprintf("TWL CFG backup ");
|
||||
mprintf("User setting param. backup ");
|
||||
if( TRUE == MiyaBackupTWLSettings( path ) ) {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
nand:/shared2ディレクトリまわりの保存
|
||||
内容はアプリケーション共有ファイル
|
||||
nand:/shared2/*
|
||||
*/
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "shared2" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "shared2.txt" );
|
||||
mprintf("App. shared files backup ");
|
||||
if( 0 == copy_r( &dir_entry_list_head, path, "nand:/shared2" , path_log ) ) {
|
||||
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "shared2.lst" );
|
||||
mydata.num_of_shared2_files = SaveDirEntryList( dir_entry_list_head, path );
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
/*
|
||||
nand2:/photoディレクトリまわりの保存
|
||||
内容は写真長のJPEGファイル
|
||||
nand2:/photo/*.*
|
||||
*/
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "photo" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "photolog.txt" );
|
||||
// mprintf("copy_r photo completed.\n");
|
||||
mprintf("Photo files backup ");
|
||||
if( 0 == copy_r( &dir_entry_list_head, path , "nand2:/photo" , path_log ) ) {
|
||||
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "photo.lst" );
|
||||
mydata.num_of_photo_files = SaveDirEntryList( dir_entry_list_head, path );
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
/* nand:/ticketはチケット同期?でうまいこと合わせてくれるんでバックアップ不要 */
|
||||
|
||||
|
||||
/*
|
||||
nand:/titleディレクトリまわりの保存
|
||||
nand:/title/*.savファイルをすべてバックアップ
|
||||
*/
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "title" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "titlelog.txt" );
|
||||
// mprintf("find_title_save_data completed.\n");
|
||||
mprintf("App. save data backup ");
|
||||
if( 0 == find_title_save_data( &dir_entry_list_head, path , "nand:/title", &save_dir_info, path_log ) ) {
|
||||
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "title.lst" );
|
||||
mydata.num_of_app_save_data = SaveDirEntryList( dir_entry_list_head , path );
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
|
||||
/* タイトルリストの生成 */
|
||||
/*
|
||||
nand:/title/00030004/
|
||||
|
||||
nand:/title/00030004/34626241/content/title.tmd
|
||||
nand:/title/00030004/34626241/content/00000000.app
|
||||
nand:/title/00030004/34626241/data/
|
||||
|
||||
nand:/title/00030017/484e4141 は ランチャー
|
||||
nand:/title/00030015/484e4641 は shop
|
||||
nand:/title/00030015/484e4241 は 本体設定
|
||||
|
||||
|
||||
No. 0 0003000f484e4c41
|
||||
No. 1 0003000f484e4841
|
||||
No. 2 0003000f484e4341
|
||||
No. 3 00030015484e4241
|
||||
No. 4 00030017484e4141 launcher
|
||||
^
|
||||
| ここの最下位ビットが1のやつがシステムアプリ
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "title_id.dat" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "title2log.txt" );
|
||||
if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info, path_log ) ) {
|
||||
mprintf("get_title_id completed.\n");
|
||||
OS_TPrintf("get_title_id completed.\n");
|
||||
|
||||
GetDirEntryList( dir_entry_list_head, &pBuffer, &count);
|
||||
OS_TPrintf("count = %d\n", count );
|
||||
ptr = pBuffer;
|
||||
mydata.num_of_user_download_app = count;
|
||||
|
||||
if( ptr != NULL && count != 0 ) {
|
||||
for( j = 0 ; j < count ; j++ ) {
|
||||
OS_TPrintf("No. %d ",j);
|
||||
mfprintf(tc[2],"No. %d ",j);
|
||||
|
||||
OS_TPrintf("%llx\n", *ptr);
|
||||
mfprintf(tc[2],"%llx\n", *ptr);
|
||||
ptr++;
|
||||
}
|
||||
OS_Free(pBuffer);
|
||||
}
|
||||
// (void)TitleIDSave(path, u64 *pData, count, NULL);
|
||||
PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
}
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
|
||||
/* オリジナルのグローバルデータのバックアップ */
|
||||
if( TRUE == CheckShopRecord(NULL) ) {
|
||||
mydata.shop_record_flag = TRUE;
|
||||
OS_TPrintf("shop record exist - you don't have to connect the network.\n");
|
||||
mprintf("shop record exist\n");
|
||||
}
|
||||
else {
|
||||
mydata.shop_record_flag = FALSE;
|
||||
OS_TPrintf("no shop record\n - you don't have to connect the network.\n");
|
||||
mprintf("no shop record\n");
|
||||
}
|
||||
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_rtc.dat" );
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
}
|
||||
|
||||
STD_CopyMemory( (void *)&(mydata.rtc_date), (void *)&rtc_date, sizeof(RTCDate) );
|
||||
STD_CopyMemory( (void *)&(mydata.rtc_time), (void *)&rtc_time, sizeof(RTCTime) );
|
||||
STD_CopyMemory( (void *)(mydata.movableUniqueID), (void *)hwn_info.movableUniqueID,
|
||||
LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
|
||||
mprintf("org. data backup ");
|
||||
if( TRUE == MydataSave(path, (void *)&mydata, sizeof(MyData), NULL) ) {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TwlMain(void)
|
||||
{
|
||||
void* newArenaLo;
|
||||
@ -84,13 +341,10 @@ void TwlMain(void)
|
||||
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
|
||||
RTCDate rtc_date;
|
||||
RTCTime rtc_time;
|
||||
LCFGTWLHWNormalInfo hwn_info;
|
||||
LCFGTWLHWSecureInfo hws_info;
|
||||
// LCFGTWLHWNormalInfo hwn_info;
|
||||
// LCFGTWLHWSecureInfo hws_info;
|
||||
int i;
|
||||
int n;
|
||||
char path_base[256];
|
||||
char path_log[256];
|
||||
char path[256];
|
||||
u8 macAddress[6];
|
||||
|
||||
OS_Init();
|
||||
@ -106,6 +360,31 @@ void TwlMain(void)
|
||||
// IRQ 割り込みを許可します
|
||||
(void)OS_EnableInterrupts();
|
||||
|
||||
// ARM7との通信FIFO割り込み許可
|
||||
(void)OS_EnableIrqMask(OS_IE_SPFIFO_RECV);
|
||||
|
||||
// ファイルシステム初期化
|
||||
FS_Init( FS_DMA_NOT_USE );
|
||||
|
||||
|
||||
// メインアリーナのアロケートシステムを初期化
|
||||
newArenaLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
|
||||
OS_SetMainArenaLo(newArenaLo);
|
||||
|
||||
// メインアリーナ上にヒープを作成
|
||||
hHeap = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
|
||||
OS_SetCurrentHeap(OS_ARENA_MAIN, hHeap);
|
||||
|
||||
|
||||
RTC_Init();
|
||||
|
||||
SCFG_Init();
|
||||
|
||||
NVRAMi_Init();
|
||||
|
||||
SND_Init();
|
||||
stream_main();
|
||||
|
||||
|
||||
Gfx_Init();
|
||||
|
||||
@ -131,29 +410,6 @@ void TwlMain(void)
|
||||
// m_set_palette(tc[0], 0xF);
|
||||
|
||||
|
||||
// ARM7との通信FIFO割り込み許可
|
||||
(void)OS_EnableIrqMask(OS_IE_SPFIFO_RECV);
|
||||
|
||||
// ファイルシステム初期化
|
||||
FS_Init( FS_DMA_NOT_USE );
|
||||
|
||||
|
||||
// メインアリーナのアロケートシステムを初期化
|
||||
newArenaLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
|
||||
OS_SetMainArenaLo(newArenaLo);
|
||||
|
||||
// メインアリーナ上にヒープを作成
|
||||
hHeap = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
|
||||
OS_SetCurrentHeap(OS_ARENA_MAIN, hHeap);
|
||||
|
||||
RTC_Init();
|
||||
|
||||
SCFG_Init();
|
||||
|
||||
NVRAMi_Init();
|
||||
|
||||
SND_Init();
|
||||
stream_main();
|
||||
|
||||
// 必須;SEA の初期化
|
||||
SEA_Init();
|
||||
@ -165,12 +421,25 @@ void TwlMain(void)
|
||||
ES_InitLib();
|
||||
|
||||
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
}
|
||||
|
||||
// mprintf("HW Normal Info. read ");
|
||||
mprintf("Unique ID read ");
|
||||
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
|
||||
mprintf("HW Normal Info. read error\n");
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], 0xF);
|
||||
}
|
||||
else {
|
||||
mprintf("HW Normal Info. read succeeded.\n");
|
||||
mprintf("UniqueID\n 0x");
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
mprintf(" 0x");
|
||||
for( i = 0; i < LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN/2 ; i++ ) {
|
||||
mprintf("%02X:", hwn_info.movableUniqueID[i]);
|
||||
}
|
||||
@ -181,16 +450,23 @@ void TwlMain(void)
|
||||
mprintf("\n");
|
||||
// mprintf(" RTC Adjust data = 0x%02x\n", hwn_info.rtcAdjust );
|
||||
}
|
||||
|
||||
mprintf("\n");
|
||||
|
||||
|
||||
// mprintf("HW Secure Info. read ");
|
||||
mprintf("Serial No. read ");
|
||||
if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) {
|
||||
mprintf("HW Secure Info. - read failed\n");
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
}
|
||||
else {
|
||||
mprintf("HW Secure Info. - read succeeded.\n");
|
||||
|
||||
mprintf(" Serial No.\n 0x");
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
mprintf(" %s\n", hws_info.serialNo);
|
||||
#if 0
|
||||
mprintf(" 0x");
|
||||
for( i = 0; i < LCFG_TWL_HWINFO_SERIALNO_LEN_MAX/2 ; i++ ) {
|
||||
mprintf("%02X:", hws_info.serialNo[i]);
|
||||
}
|
||||
@ -205,9 +481,10 @@ void TwlMain(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mprintf("\n");
|
||||
mprintf("%s\n", hws_info.serialNo);
|
||||
|
||||
#if 0
|
||||
mprintf(" validLang.bmp = 0x%08x\n", hws_info.validLanguageBitmap );
|
||||
mprintf(" wifi disable flag = %d\n", hws_info.flags.forceDisableWireless );
|
||||
mprintf(" lchr-TitleIDLo = " );
|
||||
@ -215,37 +492,38 @@ void TwlMain(void)
|
||||
mprintf("%02X:", hws_info.launcherTitleID_Lo[i]);
|
||||
}
|
||||
mprintf("\n Region data = 0x%02x\n\n", hws_info.region );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
OS_GetMacAddress( macAddress );
|
||||
mprintf("macAddress ");
|
||||
mprintf("MAC Address 0x");
|
||||
for ( i = 0 ; i < 6 ; i++ ) {
|
||||
mprintf("%02X:", macAddress[i]);
|
||||
mprintf("%02X", macAddress[i]);
|
||||
}
|
||||
mprintf("\n");
|
||||
mprintf("\n\n");
|
||||
|
||||
|
||||
|
||||
if( FALSE == SDCardValidation() ) {
|
||||
sd_card_flag = FALSE;
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("No SD Card\n");
|
||||
}
|
||||
else {
|
||||
sd_card_flag = TRUE;
|
||||
mprintf("Detect SD Card\n");
|
||||
// m_set_palette(tc[0], 0x2); /* green */
|
||||
// mprintf("Detect SD Card\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
|
||||
FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL);
|
||||
|
||||
|
||||
STD_StrCpy( path_base , "sdmc:/" );
|
||||
STD_StrCat( path_base , (const char *)hws_info.serialNo );
|
||||
STD_StrCat( path_base , "/" );
|
||||
|
||||
|
||||
|
||||
#if 1 // miya あとでコメントアウトはずす
|
||||
if( sd_card_flag == TRUE ) {
|
||||
BackupToSDCard();
|
||||
}
|
||||
#endif
|
||||
|
||||
while( 1 ) {
|
||||
OS_WaitVBlankIntr();
|
||||
@ -261,181 +539,24 @@ void TwlMain(void)
|
||||
// コマンドフラッシュ(フラッシュして即座に実行を要求)
|
||||
(void)SND_FlushCommand(SND_COMMAND_NOBLOCK | SND_COMMAND_IMMEDIATE);
|
||||
|
||||
|
||||
if ( keyData & PAD_BUTTON_R ) {
|
||||
vram_num_main++;
|
||||
if( vram_num_main > (MAX_VRAM_NUM-1) ) {
|
||||
vram_num_main = 0;
|
||||
}
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_L ) {
|
||||
vram_num_main--;
|
||||
if( vram_num_main < 0 ) {
|
||||
vram_num_main = (MAX_VRAM_NUM-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if ( keyData & PAD_BUTTON_A ) {
|
||||
/* ユーザーデータ吸出しモード */
|
||||
if( sd_card_flag == TRUE ) {
|
||||
|
||||
mprintf("BACKUP to SD Card\n");
|
||||
/************************************/
|
||||
|
||||
/* ショップの履歴確認 */
|
||||
if( TRUE == CheckShopRecord(NULL) ) {
|
||||
mydata.shop_record_flag = TRUE;
|
||||
}
|
||||
else {
|
||||
mydata.shop_record_flag = FALSE;
|
||||
mprintf("no shop record\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 日時の保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_rtc.dat" );
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
}
|
||||
|
||||
STD_CopyMemory( (void *)&(mydata.rtc_date), (void *)&rtc_date, sizeof(RTCDate) );
|
||||
STD_CopyMemory( (void *)&(mydata.rtc_time), (void *)&rtc_time, sizeof(RTCTime) );
|
||||
STD_CopyMemory( (void *)(mydata.movableUniqueID), (void *)hwn_info.movableUniqueID, LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
|
||||
if( TRUE == MydataSave(path, (void *)&mydata, sizeof(MyData), NULL) ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* nand:/sysディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_ninfo.dat" );
|
||||
if( TRUE == MiyaBackupHWNormalInfo( path ) ) {
|
||||
mprintf("HWInfo Normal backup completed.\n");
|
||||
}
|
||||
|
||||
/* Wifi設定の保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_nor.bin" );
|
||||
if( TRUE == nvram_backup( path ) ) {
|
||||
mprintf("nvram backup completed.\n");
|
||||
}
|
||||
|
||||
/* nand:/shared1ディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "twl_cfg.dat" );
|
||||
if( TRUE == MiyaBackupTWLSettings( path ) ) {
|
||||
mprintf("TWL CFG backup completed.\n");
|
||||
}
|
||||
|
||||
|
||||
/* nand:/shared2ディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "shared2" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "shared2.txt" );
|
||||
|
||||
if( 0 == copy_r( &dir_entry_list_head, path, "nand:/shared2" , path_log ) ) {
|
||||
mprintf("copy_r shared2 completed.\n");
|
||||
PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "shared2.lst" );
|
||||
SaveDirEntryList( dir_entry_list_head, path );
|
||||
}
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
/* nand2:/photoディレクトリまわりの保存 */
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "photo" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "photolog.txt" );
|
||||
|
||||
if( 0 == copy_r( &dir_entry_list_head, path , "nand2:/photo" , path_log ) ) {
|
||||
mprintf("copy_r photo completed.\n");
|
||||
PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "photo.lst" );
|
||||
SaveDirEntryList( dir_entry_list_head, path );
|
||||
}
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
/* nand:/ticketはチケット同期?でうまいこと合わせてくれるんでバックアップ不要 */
|
||||
|
||||
/* nand:/titleディレクトリまわりの保存 */
|
||||
/* **.savファイルをすべてバックアップ */
|
||||
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "title" );
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "titlelog.txt" );
|
||||
|
||||
if( 0 == find_title_save_data( &dir_entry_list_head, path , "nand:/title", &save_dir_info, path_log ) ) {
|
||||
mprintf("find_title_save_data completed.\n");
|
||||
PrintDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , "title.lst" );
|
||||
|
||||
SaveDirEntryList( dir_entry_list_head , path );
|
||||
}
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
|
||||
|
||||
/* タイトルリストの生成 */
|
||||
/*
|
||||
nand:/title/00030004/
|
||||
|
||||
nand:/title/00030004/34626241/content/title.tmd
|
||||
nand:/title/00030004/34626241/content/00000000.app
|
||||
nand:/title/00030004/34626241/data/
|
||||
|
||||
nand:/title/00030017/484e4141 は ランチャー
|
||||
nand:/title/00030015/484e4641 は shop
|
||||
nand:/title/00030015/484e4241 は 本体設定
|
||||
|
||||
|
||||
No. 0 0003000f484e4c41
|
||||
No. 1 0003000f484e4841
|
||||
No. 2 0003000f484e4341
|
||||
No. 3 00030015484e4241
|
||||
No. 4 00030017484e4141 launcher
|
||||
^
|
||||
| ここの最下位ビットが1のやつがシステムアプリ
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , "title2log.txt" );
|
||||
if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info, path_log ) ) {
|
||||
mprintf("get_title_id completed.\n");
|
||||
|
||||
// STD_StrCpy( path , path_base );
|
||||
// STD_StrCat( path , "titlelist.txt" );
|
||||
{
|
||||
void *pBuffer;
|
||||
int count;
|
||||
int i,j;
|
||||
char *ptr;
|
||||
GetDirEntryList( dir_entry_list_head, &pBuffer, &count);
|
||||
OS_TPrintf("count = %d\n", count );
|
||||
ptr = (char *)pBuffer;
|
||||
|
||||
if( ptr != NULL && count != 0 ) {
|
||||
for( j = 0 ; j < count ; j++ ) {
|
||||
OS_TPrintf("No. %d ",j);
|
||||
for( i = 0 ; i < 16 ; i++ ) {
|
||||
OS_TPrintf("%c", *ptr);
|
||||
ptr++;
|
||||
}
|
||||
OS_TPrintf("\n");
|
||||
}
|
||||
OS_Free(pBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
}
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
BackupToSDCard();
|
||||
}
|
||||
else {
|
||||
mprintf("insert SD card\n");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user