git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@11 7061adef-622a-194b-ae81-725974e89856

This commit is contained in:
miya 2008-10-20 05:12:14 +00:00
parent 44dd8fb415
commit c64e44cb58
9 changed files with 773 additions and 483 deletions

View File

@ -603,28 +603,29 @@ static BOOL CheckSystemApp(char path[])
}
}
#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;
u64 *buf;
u64 *buf = NULL;
char c;
u8 hex;
if( head == NULL ) {
*pBuffer = buf;
*size = count;
}
else {
for( list_temp = head ; list_temp->next != NULL ; list_temp = list_temp->next ) {
if( list_temp->src_path ) {
#ifdef MYDEBUG
count++;
#else
if( FALSE == CheckSystemApp( list_temp->src_path) ) {
count++;
}
#else
count++;
#endif
}
}
@ -636,7 +637,7 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
STD_MemSet((void *)buf, 0, count * sizeof(u64));
}
else {
buf = NULL;
}
*pBuffer = buf;
*size = count;
@ -656,7 +657,7 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
*/
#ifdef MYDEBUG
#ifndef MYDEBUG
if( FALSE == CheckSystemApp( list_temp->src_path ) ) {
#endif
count++;
@ -704,7 +705,7 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
buf++;
OS_TPrintf("User App. count2 = %d\n", count);
#ifdef MYDEBUG
#ifndef MYDEBUG
}
#endif
/*
@ -1309,8 +1310,6 @@ BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd)
/* SDカードがあるかどうか */
BOOL SDCardValidation(void)
{
@ -1374,13 +1373,10 @@ BOOL CheckShopRecord(FSFile *log_fd)
}
int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_parent_dir_info_flag, char *log_file_name )
int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_parent_dir_info_flag, char *log_file_name, int level )
{
static int recursive_count = 0;
static FSFile log_fd;
static BOOL log_active = FALSE;
// static char *log_file_name = "sdmc:/miya/nandinfo_find_title_save_data.txt";
FSFile f_src;
FSDirectoryEntryInfo entry_src;
@ -1394,16 +1390,16 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
/* ここでSDカードがあるかどうか調べる */
if( recursive_count == 0 ) {
if( level == 0 ) {
log_active = Log_File_Open( &log_fd, log_file_name );
}
recursive_count++;
level++;
// recursive_count 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( recursive_count > 4 ) {
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( level > 4 ) {
ret_value = 0;
goto end_process;
}
@ -1428,19 +1424,20 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
ret_value = -1;
goto end_process;
}
path_src_full = (char *)OS_Alloc( FILE_PATH_LEN );
if( path_src_full == NULL ) {
miya_log_fprintf(&log_fd, "Error: alloc error src_full\n");
ret_value = -1;
goto end_process;
}
STD_MemSet((void *)path_src_dir, 0, FILE_PATH_LEN);
STD_MemSet((void *)path_src_full, 0, FILE_PATH_LEN);
STD_StrCpy(path_src_dir, path_src);
STD_StrCat(path_src_dir, "/");
while( FS_ReadDirectory(&f_src, &entry_src) ) {
if( STD_StrCmp(entry_src.longname, ".") == 0 ) {
/* とりあえずカレントディレクトリエントリを残しておく */
STD_CopyMemory( (void *)&entry_current_dir, (void *)&entry_src ,sizeof(FSDirectoryEntryInfo) );
@ -1460,30 +1457,30 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
if( (entry_src.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) {
/* ディレクトリの場合 */
// recursive_count 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( recursive_count == 1 ) {
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( level == 1 ) {
if( my_fs_is_Title_Hi_dir_name( entry_src.longname ) == TRUE ) {
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name, level );
}
}
if( recursive_count == 2 ) {
if( level == 2 ) {
if( my_fs_is_Title_Lo_dir_name( entry_src.longname ) == TRUE ) {
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name, level );
}
}
else if( (recursive_count == 3) ) {
else if( (level == 3) ) {
if( !STD_StrCmp( entry_src.longname, "content" ) ) {
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
get_title_id( headp, path_src_full , &save_parent_dir_info_flag_temp, log_file_name, level );
}
}
}
else {
// recursive_count 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/content/title.tmd
if( (recursive_count == 4) ) {
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/content/title.tmd
if( (level == 4) ) {
if( !STD_StrCmp( entry_src.longname, "title.tmd" ) ) {
/* 目的のファイルを見つけた。 */
#if 0
@ -1498,7 +1495,7 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
if( save_parent_dir_info_flag_temp == 1 ) {
// OS_TPrintf("save dir info = %s\n\n",path_src);
if( recursive_count == 3 ) {
if( level == 3 ) {
my_fs_add_list( headp, &entry_current_dir, path_src, NULL, &log_fd);
}
else {
@ -1524,9 +1521,9 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
OS_Free(path_src_full);
}
recursive_count--;
level--;
if( recursive_count == 0 ) {
if( level == 0 ) {
if( log_active ) {
Log_File_Close(&log_fd);
}
@ -1537,9 +1534,8 @@ int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_pare
int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, int *save_parent_dir_info_flag, char *log_file_name )
int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, int *save_parent_dir_info_flag, char *log_file_name, int level )
{
static int recursive_count = 0;
static FSFile log_fd;
static BOOL log_active = FALSE;
// static char *log_file_name = "sdmc:/miya/nandinfo_find_title_save_data.txt";
@ -1558,16 +1554,16 @@ int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const
/* ここでSDカードがあるかどうか調べる */
if( recursive_count == 0 ) {
if( level == 0 ) {
log_active = Log_File_Open( &log_fd, log_file_name );
}
recursive_count++;
level++;
// recursive_count 1 2 3 4
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( recursive_count > 4 ) {
if( level > 4 ) {
ret_value = 0;
goto end_process;
}
@ -1616,30 +1612,30 @@ int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const
if( (entry_src.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) {
/* ディレクトリの場合 */
// recursive_count 1 2 3 4
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( recursive_count == 1 ) {
if( level == 1 ) {
if( my_fs_is_Title_Hi_dir_name( entry_src.longname ) == TRUE ) {
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name , level );
}
}
if( recursive_count == 2 ) {
if( level == 2 ) {
if( my_fs_is_Title_Lo_dir_name( entry_src.longname ) == TRUE ) {
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name, level );
}
}
else if( (recursive_count == 3) ) {
else if( (level == 3) ) {
if( !STD_StrCmp( entry_src.longname, "data" ) ) {
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name );
find_title_save_data( headp, path_dst_full, path_src_full , &save_parent_dir_info_flag_temp, log_file_name, level );
}
}
}
else {
// recursive_count 1 2 3 4
// level 1 2 3 4
// nand:/title
// nand:/title/00000000/00000000/data/*.sav
if( (recursive_count == 4) ) {
if( (level == 4) ) {
if( !STD_StrCmp( entry_src.longname, "public.sav" ) ) {
/* 目的のファイルを見つけた。 */
my_fs_add_list(headp, &entry_src, path_src_full, path_dst_full, &log_fd);
@ -1679,9 +1675,9 @@ int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const
Path_Buffers_Clean( path_src_dir, path_src_full, path_dst_dir, path_dst_full );
recursive_count--;
level--;
if( recursive_count == 0 ) {
if( level == 0 ) {
if( log_active ) {
Log_File_Close(&log_fd);
}
@ -1692,9 +1688,8 @@ int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const
int find_copy(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src,
char *extension, int max_recursive_count, int *save_parent_dir_info_flag, char *log_file_name )
char *extension, int max_level, int *save_parent_dir_info_flag, char *log_file_name, int level )
{
static int recursive_count = 0;
static FSFile log_fd;
static BOOL log_active = FALSE;
// static char *log_file_name = "sdmc:/miya/nandinfo_find_copy.txt";
@ -1713,16 +1708,16 @@ int find_copy(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_
/* ここでSDカードがあるかどうか調べる */
if( recursive_count == 0 ) {
if( level == 0 ) {
log_active = Log_File_Open( &log_fd, log_file_name );
}
if( recursive_count > max_recursive_count ) {
if( level > max_level ) {
ret_value = 0;
goto end_process;
}
recursive_count++;
level++;
/* ソースディレクトリオープン */
FS_InitFile(&f_src);
@ -1764,7 +1759,7 @@ int find_copy(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_
}
if( (entry_src.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) {
find_copy( headp, path_dst_full, path_src_full , extension, max_recursive_count, &save_parent_dir_info_flag_temp , log_file_name);
find_copy( headp, path_dst_full, path_src_full , extension, max_level, &save_parent_dir_info_flag_temp , log_file_name, level);
}
else {
/* ここで拡張子比較 */
@ -1809,8 +1804,8 @@ int find_copy(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_
Path_Buffers_Clean( path_src_dir, path_src_full, path_dst_dir, path_dst_full );
recursive_count--;
if( recursive_count == 0 ) {
level--;
if( level == 0 ) {
if( log_active ) {
Log_File_Close(&log_fd);
}
@ -1820,9 +1815,8 @@ int find_copy(MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_
}
int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, char *log_file_name )
int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, char *log_file_name, int level )
{
static int recursive_count = 0;
static FSFile log_fd;
static BOOL log_active = FALSE;
// static char *log_file_name = "sdmc:/nandinfo_copy_r.txt";
@ -1838,11 +1832,11 @@ int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_sr
char *path_dst_full = NULL;
/* ここでSDカードがあるかどうか調べる */
if( recursive_count == 0 ) {
if( level == 0 ) {
log_active = Log_File_Open( &log_fd, log_file_name );
}
recursive_count++;
level++;
/* ソースディレクトリオープン */
FS_InitFile(&f_src);
@ -1886,7 +1880,7 @@ int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_sr
}
if( (entry_src.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) {
copy_r( headp, path_dst_full, path_src_full, log_file_name );
copy_r( headp, path_dst_full, path_src_full, log_file_name, level );
}
else {
my_fs_add_list(headp, &entry_src, path_src_full, path_dst_full, &log_fd);
@ -1912,8 +1906,8 @@ int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_sr
Path_Buffers_Clean( path_src_dir, path_src_full, path_dst_dir, path_dst_full );
recursive_count--;
if( recursive_count == 0 ) {
level--;
if( level == 0 ) {
if( log_active ) {
Log_File_Close(&log_fd);
}

View File

@ -19,12 +19,12 @@ extern "C" {
char *my_fs_util_get_fs_result_word( FSResult res );
int find_title_save_data(MY_DIR_ENTRY_LIST **headp, const char *path_dst,
const char *path_src, int *save_dir_info, char *log_file_name );
const char *path_src, int *save_dir_info, char *log_file_name , int level);
int find_copy( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src,
char *extension, int level, int *save_info, char *log_file_name );
int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, char *log_file_name );
char *extension, int max_level, int *save_info, char *log_file_name , int level);
int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_src, char *log_file_name, int level );
int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src,
int *save_parent_dir_info_flag, char *log_file_name );
int *save_parent_dir_info_flag, char *log_file_name, int level );
void PrintDirEntryListForward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd );
void PrintDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd );

View File

@ -0,0 +1,27 @@
#ifndef _MY_DATA_H_
#define _MY_DATA_H_
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;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* _MY_DATA_H_ */

View File

@ -0,0 +1,119 @@
#include <twl.h>
#include "myfilename.h"
static char path_base[256];
static char path_log[256];
static char path[256];
void MyFile_SetPathBase(const char *str)
{
STD_StrCpy( path_base , str );
}
void MyFile_AddPathBase(const char *str)
{
STD_StrCat( path_base , str );
}
char *MyFile_GetUniqueIDFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_UNIQUE_ID );
return path;
}
char *MyFile_GetWifiParamFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_WIFI_PARAM );
return path;
}
char *MyFile_GetUserSettingsFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_USER_SETTINGS );
return path;
}
char *MyFile_GetAppSharedSaveDirName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_DIR_NAME_APP_SHARED );
return path;
}
char *MyFile_GetAppSharedLogFileName(void)
{
STD_StrCpy( path_log , path_base );
STD_StrCat( path_log , MY_FILE_NAME_APP_SHARED_LOG );
return path_log;
}
char *MyFile_GetAppSharedListFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_APP_SHARED_LIST );
return path;
}
char *MyFile_GetPhotoSaveDirName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_DIR_NAME_PHOTO );
return path;
}
char *MyFile_GetPhotoLogFileName(void)
{
STD_StrCpy( path_log , path_base );
STD_StrCat( path_log , MY_FILE_NAME_PHOTO_LOG );
return path_log;
}
char *MyFile_GetPhotoListFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_PHOTO_LIST );
return path;
}
char *MyFile_GetAppDataSaveDirName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_DIR_NAME_TITLE );
return path;
}
char *MyFile_GetAppDataLogFileName(void)
{
STD_StrCpy( path_log , path_base );
STD_StrCat( path_log , MY_FILE_NAME_TITLE_LOG );
return path_log;
}
char *MyFile_GetAppDataListFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_TITLE_LIST );
return path;
}
char *MyFile_GetDownloadTitleIDLogFileName(void)
{
STD_StrCpy( path_log , path_base );
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_LOG );
return path_log;
}
char *MyFile_GetDownloadTitleIDFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_DOWNLOAD_TITLE_ID_DATA );
return path;
}
char *MyFile_GetGlobalInformationFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_ORG_DATA );
return path;
}

View File

@ -0,0 +1,57 @@
#ifndef _MY_FILE_NAME_H_
#define _MY_FILE_NAME_H_
#define MY_FILE_NAME_UNIQUE_ID ("twl_ninfo.dat")
#define MY_FILE_NAME_WIFI_PARAM ("twl_nor.bin")
#define MY_FILE_NAME_USER_SETTINGS ("twl_cfg.dat")
#define MY_FILE_NAME_APP_SHARED_LIST ("shared2.lst")
#define MY_FILE_NAME_APP_SHARED_LOG ("shared2.txt")
#define MY_DIR_NAME_APP_SHARED ("shared2")
#define MY_FILE_NAME_PHOTO_LIST ("photo.lst")
#define MY_FILE_NAME_PHOTO_LOG ("photolog.txt")
#define MY_DIR_NAME_PHOTO ("photo")
#define MY_FILE_NAME_TITLE_LIST ("title.lst")
#define MY_FILE_NAME_TITLE_LOG ("titlelog.txt")
#define MY_DIR_NAME_TITLE ("title")
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_DATA ("title_id.dat")
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_LOG ("title_id.txt" )
#define MY_DIR_NAME_DOWNLOAD_TITLE_ID ("title")
#define MY_FILE_NAME_ORG_DATA ("global.dat")
#define MY_FILE_NAME_ORG_LOG ("global.txt");
#ifdef __cplusplus
extern "C" {
#endif
void MyFile_SetPathBase(const char *str);
void MyFile_AddPathBase(const char *str);
char *MyFile_GetUniqueIDFileName(void);
char *MyFile_GetWifiParamFileName(void);
char *MyFile_GetUserSettingsFileName(void);
char *MyFile_GetAppSharedSaveDirName(void);
char *MyFile_GetAppSharedLogFileName(void);
char *MyFile_GetAppSharedListFileName(void);
char *MyFile_GetPhotoListFileName(void);
char *MyFile_GetPhotoSaveDirName(void);
char *MyFile_GetPhotoLogFileName(void);
char *MyFile_GetAppDataSaveDirName(void);
char *MyFile_GetAppDataLogFileName(void);
char *MyFile_GetAppDataListFileName(void);
char *MyFile_GetDownloadTitleIDLogFileName(void);
char *MyFile_GetDownloadTitleIDFileName(void);
char *MyFile_GetGlobalInformationFileName(void);
#ifdef __cplusplus
}
#endif
#endif /* _MY_FILE_NAME_H_ */

View File

@ -26,7 +26,7 @@ SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \
gfx.c hwi.c mynvram.c my_fs_util.c \
kpsc.cpp ecdl.cpp hatamotolib.cpp \
sitedefs.c wcm_control.c netconnect.c mywlan.c \
nuc.c nuc_error_msg.c stream.c
nuc.c nuc_error_msg.c stream.c myfilename.c
TARGET_BIN = copy_dst.srl
ROM_SPEC = copy_dst.rsf

View File

@ -1,5 +1,5 @@
/*---------------------------------------------------------------------------*
Project: TWLSDK - demos - MI - ndma-1
Project:
File: main.c
Copyright 2007 Nintendo. All rights reserved.
@ -26,21 +26,15 @@
#include "key.h"
#include "my_fs_util.h"
#include "mynvram.h"
#include "stream.h"
#include "hwi.h"
#include "hatamotolib.h"
#include "ecdl.h"
#include "mywlan.h"
#include "mydata.h"
#include "nuc.h"
#include "nuc.h"
//#define DEBUG_PRINT 1
#include "myfilename.h"
//================================================================================
@ -62,18 +56,316 @@ static void SDEvents(void *userdata, FSEvent event, void *arg)
}
}
typedef struct {
RTCDate rtc_date;
RTCTime rtc_time;
BOOL shop_record_flag;
u8 movableUniqueID[ LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN ]; // 移行可能なユニークID 16byte
} MyData;
static MyData mydata;
static int vram_num_main = 1;
static int vram_num_sub = 0;
static LCFGTWLHWNormalInfo hwn_info;
static LCFGTWLHWSecureInfo hws_info;
#define MY_STACK_SIZE (1024*16) /* でかいほうがいい */
#define MY_THREAD_PRIO 20
static OSThread MyThread;
static u64 MyStack[MY_STACK_SIZE / sizeof(u64)];
static void MyThreadProc(void *arg);
static OSMessage MyMesgBuffer[1];
static OSMessageQueue MyMesgQueue;
static void init_my_thread(void)
{
OS_InitMessageQueue(&MyMesgQueue, &MyMesgBuffer[0], 1);
OS_CreateThread(&MyThread, MyThreadProc,
NULL, MyStack + MY_STACK_SIZE / sizeof(u64),
MY_STACK_SIZE, MY_THREAD_PRIO);
OS_WakeupThreadDirect(&MyThread);
}
static void start_my_thread(void)
{
(void)OS_SendMessage(&MyMesgQueue, (OSMessage)0, OS_MESSAGE_NOBLOCK);
}
static void RestoreFromSDCard(void)
{
/* ユーザーデータ書き込みモード */
if( TRUE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) {
OS_TPrintf("SSID = %s\n", GetWlanSSID());
OS_TPrintf("MODE = ");
switch( GetWlanMode() ) {
case 1:
OS_TPrintf("OPEN\n");
break;
case 2:
OS_TPrintf("WEP128\n");
break;
case 3:
OS_TPrintf("WPA-TKIP\n");
break;
case 4:
OS_TPrintf("WPA2-TKIP\n");
break;
case 5:
OS_TPrintf("WPA-AES\n");
break;
case 6:
OS_TPrintf("WPA2-AES\n");
break;
defalut:
OS_TPrintf("Unknow mode..\n");
break;
}
OS_TPrintf("KEY STR = %s\n", GetWlanKEYSTR());
{
u8 buf[256];
int len;
int i;
len = GetWlanKEYBIN(buf);
if( len ) {
OS_TPrintf("KEY BIN = 0x");
for( i = 0 ; i < len ; i++ ) {
OS_TPrintf("%02X",buf[i]);
}
OS_TPrintf("\n");
}
}
}
else {
OS_TPrintf("Invalid wlan cfg file\n");
}
nuc_main();
}
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 j;
u64 *ptr;
//miya mprintf("BACKUP to SD Card\n");
/************************************/
MyFile_SetPathBase("sdmc:/");
MyFile_AddPathBase((const char *)hws_info.serialNo );
MyFile_AddPathBase("/");
/* nand:/sysディレクトリまわりの保存 */
mprintf("Unique ID backup ");
if( TRUE == MiyaBackupHWNormalInfo( MyFile_GetUniqueIDFileName() ) ) {
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設定の保存 */
mprintf("WirelessLAN param. backup ");
if( TRUE == nvram_backup( MyFile_GetWifiParamFileName() ) ) {
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ディレクトリまわりの保存 */
mprintf("User setting param. backup ");
if( TRUE == MiyaBackupTWLSettings( MyFile_GetUserSettingsFileName() ) ) {
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/*
*/
mprintf("App. shared files backup ");
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetAppSharedSaveDirName() , "nand:/shared2" , MyFile_GetAppSharedLogFileName(),0 ) ) {
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
mydata.num_of_shared2_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetAppSharedListFileName() );
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/*.*
*/
mprintf("Photo files backup ");
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetPhotoSaveDirName() , "nand2:/photo" , MyFile_GetPhotoLogFileName(), 0 ) ) {
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
mydata.num_of_photo_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetPhotoListFileName() );
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ファイルをすべてバックアップ
*/
mprintf("App. save data backup ");
if( 0 == find_title_save_data( &dir_entry_list_head, MyFile_GetAppDataSaveDirName(), "nand:/title",
&save_dir_info, MyFile_GetAppDataLogFileName(), 0 ) )
{
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
mydata.num_of_app_save_data = SaveDirEntryList( dir_entry_list_head , MyFile_GetAppDataListFileName() );
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
^
|
|
*/
// STD_StrCpy( path , path_base );
// STD_StrCat( path , MY_FILE_NAME_DOWNLOAD_TITLE_ID_DATA );
if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info, MyFile_GetDownloadTitleIDLogFileName(), 0 ) ) {
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( MyFile_GetDownloadTitleIDFileName(), 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");
}
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( MyFile_GetGlobalInformationFileName(), (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 */
}
static void MyThreadProc(void *arg)
{
#pragma unused(arg)
OSMessage message;
while( 1 ) {
(void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK);
//RestoreFromSDCard();
BackupToSDCard();
}
}
void TwlMain(void)
{
void* newArenaLo;
@ -84,13 +376,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,9 +395,34 @@ 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);
Gfx_Init();
RTC_Init();
SCFG_Init();
NVRAMi_Init();
SND_Init();
stream_main();
/*
0 -> black
1 -> red
@ -131,29 +445,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 +456,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,70 +485,53 @@ 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");
for( i = 0; i < LCFG_TWL_HWINFO_SERIALNO_LEN_MAX/2 ; i++ ) {
mprintf("%02X:", hws_info.serialNo[i]);
}
mprintf("\n 0x");
for( ; i < LCFG_TWL_HWINFO_SERIALNO_LEN_MAX ; i++ ) {
if( hws_info.serialNo[i] ) {
mprintf("%02X:", hws_info.serialNo[i]);
}
else {
// #define LCFG_TWL_HWINFO_SERIALNO_LEN_MAX 15 // 本体シリアルNo.長Max(終端付きなので、14bytesまで拡張
// 終端をみつけたらブレーク
break;
}
}
mprintf("\n");
mprintf("%s\n", hws_info.serialNo);
mprintf(" validLang.bmp = 0x%08x\n", hws_info.validLanguageBitmap );
mprintf(" wifi disable flag = %d\n", hws_info.flags.forceDisableWireless );
mprintf(" lchr-TitleIDLo = " );
for( i = 0 ; i < 4 ; i++ ) {
mprintf("%02X:", hws_info.launcherTitleID_Lo[i]);
}
mprintf("\n Region data = 0x%02x\n\n", hws_info.region );
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
m_set_palette(tc[0], 0xF); /* white */
mprintf(" %s\n\n", hws_info.serialNo);
}
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");
m_set_palette(tc[0], 0xF); /* white */
}
else {
sd_card_flag = TRUE;
mprintf("Detect SD Card\n");
}
// miya あとで消す。
// sd_card_flag = FALSE;
FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL);
init_my_thread();
STD_StrCpy( path_base , "sdmc:/" );
STD_StrCat( path_base , (const char *)hws_info.serialNo );
STD_StrCat( path_base , "/" );
if( sd_card_flag == TRUE ) {
start_my_thread();
}
while( 1 ) {
@ -261,238 +548,30 @@ 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
^
|
|
*/
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;
#if 0
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);
}
#endif
}
PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
}
(void)ClearDirEntryList( &dir_entry_list_head );
start_my_thread();
}
else {
mprintf("insert SD card\n");
}
}
else if ( keyData & PAD_BUTTON_B ) {
/* ユーザーデータ書き込みモード */
if( TRUE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) {
OS_TPrintf("SSID = %s\n", GetWlanSSID());
OS_TPrintf("MODE = ");
switch( GetWlanMode() ) {
case 1:
OS_TPrintf("OPEN\n");
break;
case 2:
OS_TPrintf("WEP128\n");
break;
case 3:
OS_TPrintf("WPA-TKIP\n");
break;
case 4:
OS_TPrintf("WPA2-TKIP\n");
break;
case 5:
OS_TPrintf("WPA-AES\n");
break;
case 6:
OS_TPrintf("WPA2-AES\n");
break;
defalut:
OS_TPrintf("Unknow mode..\n");
break;
}
OS_TPrintf("KEY STR = %s\n", GetWlanKEYSTR());
{
u8 buf[256];
int len;
int i;
len = GetWlanKEYBIN(buf);
if( len ) {
OS_TPrintf("KEY BIN = 0x");
for( i = 0 ; i < len ; i++ ) {
OS_TPrintf("%02X",buf[i]);
}
OS_TPrintf("\n");
}
}
}
else {
OS_TPrintf("Invalid wlan cfg file\n");
}
nuc_main();
}
else if ( keyData & PAD_BUTTON_START ) {
}

View File

@ -26,7 +26,7 @@ SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \
gfx.c hwi.c mynvram.c my_fs_util.c \
kpsc.cpp ecdl.cpp hatamotolib.cpp \
sitedefs.c wcm_control.c netconnect.c mywlan.c \
nuc.c nuc_error_msg.c stream.c
nuc.c nuc_error_msg.c stream.c myfilename.c
TARGET_BIN = copy_org.srl
ROM_SPEC = copy_org.rsf

View File

@ -31,8 +31,11 @@
#include "hatamotolib.h"
#include "ecdl.h"
#include "mywlan.h"
#include "mydata.h"
#include "nuc.h"
#include "myfilename.h"
//================================================================================
static FSEventHook sSDHook;
@ -53,25 +56,17 @@ static void SDEvents(void *userdata, FSEvent event, void *arg)
}
}
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;
static MyData mydata;
static int vram_num_main = 1;
static int vram_num_sub = 0;
#if 0
static char path_base[256];
static char path_log[256];
static char path[256];
#endif
static LCFGTWLHWNormalInfo hwn_info;
static LCFGTWLHWSecureInfo hws_info;
@ -104,32 +99,12 @@ static void start_my_thread(void)
}
static void BackupToSDCard(void)
static BOOL SDBackupToSDCard1(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 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 ) ) {
if( TRUE == MiyaBackupHWNormalInfo( MyFile_GetUniqueIDFileName() ) ) {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -138,13 +113,15 @@ static void BackupToSDCard(void)
mprintf("NG.\n");
}
m_set_palette(tc[0], 0xF); /* white */
return TRUE;
}
static BOOL SDBackupToSDCard2(void)
{
/* Wifi設定の保存 */
STD_StrCpy( path , path_base );
STD_StrCat( path , "twl_nor.bin" );
mprintf("WirelessLAN param. backup ");
if( TRUE == nvram_backup( path ) ) {
if( TRUE == nvram_backup( MyFile_GetWifiParamFileName() ) ) {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -153,13 +130,15 @@ static void BackupToSDCard(void)
mprintf("NG.\n");
}
m_set_palette(tc[0], 0xF); /* white */
return TRUE;
}
static BOOL SDBackupToSDCard3(void)
{
/* 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 ) ) {
if( TRUE == MiyaBackupTWLSettings( MyFile_GetUserSettingsFileName() ) ) {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -168,24 +147,23 @@ static void BackupToSDCard(void)
mprintf("NG.\n");
}
m_set_palette(tc[0], 0xF); /* white */
return TRUE;
}
static BOOL SDBackupToSDCard4(void)
{
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
int save_dir_info = 0;
/*
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 ) ) {
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetAppSharedSaveDirName() , "nand:/shared2" , MyFile_GetAppSharedLogFileName(), 0) ) {
// 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 );
mydata.num_of_shared2_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetAppSharedListFileName() );
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -195,24 +173,23 @@ static void BackupToSDCard(void)
}
m_set_palette(tc[0], 0xF); /* white */
(void)ClearDirEntryList( &dir_entry_list_head );
return TRUE;
}
static BOOL SDBackupToSDCard5(void)
{
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
int save_dir_info = 0;
/*
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 ) ) {
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetPhotoSaveDirName() , "nand2:/photo" , MyFile_GetPhotoLogFileName(),0 ) ) {
// 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 );
mydata.num_of_photo_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetPhotoListFileName() );
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -224,27 +201,30 @@ static void BackupToSDCard(void)
(void)ClearDirEntryList( &dir_entry_list_head );
/* nand:/ticketはチケット同期でうまいこと合わせてくれるんでバックアップ不要 */
return TRUE;
}
static BOOL SDBackupToSDCard6(void)
{
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
int save_dir_info = 0;
/* 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");
}
if( 0 == find_title_save_data( &dir_entry_list_head, MyFile_GetAppDataSaveDirName(), "nand:/title",
&save_dir_info, MyFile_GetAppDataLogFileName(),0 ) )
{
// PrintDirEntryListBackward( dir_entry_list_head, NULL );
mydata.num_of_app_save_data = SaveDirEntryList( dir_entry_list_head , MyFile_GetAppDataListFileName() );
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
else {
m_set_palette(tc[0], 0x1); /* red */
mprintf("NG.\n");
@ -252,7 +232,17 @@ static void BackupToSDCard(void)
m_set_palette(tc[0], 0xF); /* white */
(void)ClearDirEntryList( &dir_entry_list_head );
return TRUE;
}
static BOOL SDBackupToSDCard7(void)
{
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
int save_dir_info = 0;
u64 *pBuffer;
int count;
int j;
u64 *ptr;
/* タイトルリストの生成 */
/*
@ -277,38 +267,46 @@ static void BackupToSDCard(void)
|
*/
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");
mprintf("User title list backup ");
OS_TPrintf("User title list backup \n");
if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info, MyFile_GetDownloadTitleIDLogFileName(), 0 ) ) {
GetDirEntryList( dir_entry_list_head, &pBuffer, &count);
OS_TPrintf("count = %d\n", count );
OS_TPrintf("title id 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_TPrintf("No. %d %llx\n",j,*ptr);
mfprintf(tc[2],"No. %d %llx\n",j,*ptr);
ptr++;
}
OS_Free(pBuffer);
}
// (void)TitleIDSave(path, u64 *pData, count, NULL);
(void)TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL);
OS_Free(pBuffer);
PrintSrcDirEntryListBackward( dir_entry_list_head, 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)ClearDirEntryList( &dir_entry_list_head );
return TRUE;
}
static BOOL SDBackupToSDCard8(void)
{
RTCDate rtc_date;
RTCTime rtc_time;
/* オリジナルのグローバルデータのバックアップ */
/* オリジナルのデータのバックアップ */
if( TRUE == CheckShopRecord(NULL) ) {
mydata.shop_record_flag = TRUE;
OS_TPrintf("shop record exist - you don't have to connect the network.\n");
@ -320,8 +318,6 @@ static void BackupToSDCard(void)
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");
}
@ -334,7 +330,7 @@ static void BackupToSDCard(void)
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) ) {
if( TRUE == MydataSave( MyFile_GetGlobalInformationFileName(), (void *)&mydata, sizeof(MyData), NULL) ) {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
}
@ -343,16 +339,40 @@ static void BackupToSDCard(void)
mprintf("NG.\n");
}
m_set_palette(tc[0], 0xF); /* white */
return TRUE;
}
typedef BOOL (*function_ptr)(void);
static function_ptr function_table[] =
{
SDBackupToSDCard1,
SDBackupToSDCard2,
SDBackupToSDCard3,
SDBackupToSDCard4,
SDBackupToSDCard5,
SDBackupToSDCard6,
SDBackupToSDCard7,
SDBackupToSDCard8
};
static int function_table_max = sizeof(function_table) / sizeof(*function_table);
static int function_counter = 0;
static void MyThreadProc(void *arg)
{
#pragma unused(arg)
OSMessage message;
while( 1 ) {
(void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK);
BackupToSDCard();
MyFile_SetPathBase("sdmc:/");
MyFile_AddPathBase((const char *)hws_info.serialNo );
MyFile_AddPathBase("/");
for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) {
(void)(function_table[function_counter])();
}
}
}
@ -367,8 +387,6 @@ void TwlMain(void)
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
RTCDate rtc_date;
RTCTime rtc_time;
// LCFGTWLHWNormalInfo hwn_info;
// LCFGTWLHWSecureInfo hws_info;
int i;
int n;
u8 macAddress[6];
@ -548,11 +566,9 @@ void TwlMain(void)
init_my_thread();
#if 1 // miya あとでコメントアウトはずす
if( sd_card_flag == TRUE ) {
start_my_thread();
}
#endif
while( 1 ) {
OS_WaitVBlankIntr();
@ -683,10 +699,8 @@ void TwlMain(void)
mfprintf(tc[1], "press A -> Store to SD Card\n");
mfprintf(tc[1], "press B -> Load to NAND Flash\n");
mfprintf(tc[1], "\n");
mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max);
loop_counter++;
}