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

This commit is contained in:
miya 2008-11-06 11:06:13 +00:00
parent e4a581a3ba
commit 8736c15189
4 changed files with 139 additions and 47 deletions

View File

@ -31,10 +31,6 @@
extern "C" {
#endif
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
BOOL KPSClient();
BOOL WaitEC(ECOpId opId);
#ifdef __cplusplus
}

View File

@ -650,15 +650,16 @@ static BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
return ret_flag;
}
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
int ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
{
char challenge[EC_CHALLENGE_BUF_SIZE];
char status;
BOOL ret_flag;
// BOOL ret_flag;
mprintf("-check registration.. ");
miya_log_fprintf(log_fd, "-check registration...");
status = CheckRegistration();
// U unregistered
// R registered
// P pending
@ -670,16 +671,23 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
mprintf(" my error.\n");
miya_log_fprintf(log_fd, " my error.\n");
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else if( status == 'U') {
miya_log_fprintf(log_fd, "NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
miya_log_fprintf(log_fd, "OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
mprintf("OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" acount not transfered yet,\n");
mprintf(" OR, acount already cleared\n\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
mprintf(" acount not transfered yet.\n");
miya_log_fprintf(log_fd, " acount not transfered yet.\n");
return FALSE;
miya_log_fprintf(log_fd, " OR acount already cleared by user.\n");
// 「ご利用記録の削除」をした場合、ここでエラーになる。
// ここでOKにする?
return ECDOWNLOAD_NO_REGISTER;
}
else if( status == 'R') {
miya_log_fprintf(log_fd, "NG.\n");
@ -688,7 +696,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
mprintf(" already registered. please delete acount.\n");
miya_log_fprintf(log_fd, " already registered. please delete acount.\n");
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else if( (status != 'P') && (status != 'T') ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
@ -696,7 +704,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
mprintf(" invalid registration status '%c'\n", status );
miya_log_fprintf(log_fd, " invalid registration status '%c'\n", status );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -712,7 +720,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -728,7 +736,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -745,7 +753,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -762,7 +770,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -778,7 +786,7 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
return ECDOWNLOAD_FAILURE;
}
else {
miya_log_fprintf(log_fd, "OK.\n");
@ -791,9 +799,16 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
miya_log_fprintf(log_fd, "-download titles\n");
mprintf("-download titles\n");
ret_flag = DownloadTitles(pTitleIds, numTitleIds);
if( FALSE == DownloadTitles(pTitleIds, numTitleIds) ) {
return ECDOWNLOAD_FAILURE;
}
return ret_flag;
//#define ECDOWNLOAD_DUMMY 0
//#define ECDOWNLOAD_SUCCESS 1
//#define ECDOWNLOAD_NO_REGISTER 2
//#define ECDOWNLOAD_FAILURE 3
return ECDOWNLOAD_SUCCESS;
}

View File

@ -5,6 +5,17 @@
extern "C" {
#endif
#define ECDOWNLOAD_DUMMY 0
#define ECDOWNLOAD_SUCCESS 1
#define ECDOWNLOAD_NO_REGISTER 2
#define ECDOWNLOAD_FAILURE 3
int ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
BOOL KPSClient();
BOOL WaitEC(ECOpId opId);
void PrintDeviceInfo(void);
void SetupShopTitleId(void);
void SetupUserInfo(void);

View File

@ -65,6 +65,11 @@ static BOOL sd_card_flag = FALSE;
//static BOOL reboot_flag = FALSE;
static BOOL ec_download_success_flag = FALSE;
static BOOL ec_download_no_registered_flag = FALSE;
static BOOL wlan_active_flag = TRUE;
static u8 org_region = 0;
static u64 org_fuseId = 0;
@ -239,6 +244,7 @@ static BOOL RestoreFromSDCard2(void)
return TRUE;
}
mprintf("No original Unique ID\n");
return TRUE;
}
@ -298,6 +304,7 @@ static BOOL RestoreFromSDCard5(void)
// static BOOL SDBackupToSDCard4(void)
int list_count;
int error_count;
BOOL ret_flag = TRUE;
Error_Report_Init();
@ -314,6 +321,7 @@ static BOOL RestoreFromSDCard5(void)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
ret_flag = FALSE;
}
}
else if( mydata.num_of_shared2_files == 0 ) {
@ -328,14 +336,14 @@ static BOOL RestoreFromSDCard5(void)
}
Error_Report_End();
return TRUE;
return ret_flag;
}
static BOOL RestoreFromSDCard6(void)
{
int list_count;
int error_count;
BOOL ret_flag = TRUE;
Error_Report_Init();
@ -354,6 +362,7 @@ static BOOL RestoreFromSDCard6(void)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
ret_flag = FALSE;
}
}
else if( mydata.num_of_photo_files == 0 ) {
@ -368,7 +377,7 @@ static BOOL RestoreFromSDCard6(void)
}
Error_Report_End();
return TRUE;
return ret_flag;
}
@ -376,15 +385,15 @@ static BOOL RestoreFromSDCard8(void)
{
int list_count;
int error_count;
BOOL ret_flag = TRUE;
Error_Report_Init();
if( mydata.num_of_app_save_data > 0 ) {
if( (no_network_flag == TRUE) || (ec_download_success_flag == FALSE) ) {
if( (no_network_flag == TRUE)
|| (ec_download_success_flag == FALSE)
|| (ec_download_no_registered_flag == TRUE ) ) {
mprintf("Sys-App. save data restore ");
if( TRUE == RestoreDirEntryListSystemBackupOnly( MyFile_GetSaveDataListFileName() ,
MyFile_GetSaveDataRestoreLogFileName(),
@ -398,6 +407,7 @@ static BOOL RestoreFromSDCard8(void)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
ret_flag = FALSE;
}
}
else {
@ -414,6 +424,7 @@ static BOOL RestoreFromSDCard8(void)
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
ret_flag = FALSE;
}
}
}
@ -429,7 +440,7 @@ static BOOL RestoreFromSDCard8(void)
}
Error_Report_End();
return TRUE;
return ret_flag;
}
@ -549,6 +560,7 @@ static BOOL RestoreFromSDCard7(void)
ECError rv;
BOOL ret_flag = TRUE;
FSFile *log_fd;
int ec_download_ret;
title_id_buf_ptr = NULL;
title_id_count = 0;
@ -672,9 +684,20 @@ static BOOL RestoreFromSDCard7(void)
goto end_ec_f;
}
if( FALSE == ECDownload((NAMTitleId *)title_id_buf_ptr , (u32)title_id_count) ) {
ec_download_ret = ECDownload((NAMTitleId *)title_id_buf_ptr , (u32)title_id_count);
if( ec_download_ret == ECDOWNLOAD_FAILURE ) {
ret_flag = FALSE;
miya_log_fprintf(log_fd, "%s failed ECDownload\n", __FUNCTION__);
miya_log_fprintf(log_fd, "%s failed ECDownload 1\n", __FUNCTION__);
goto end_ec_f;
}
else if( ec_download_ret == ECDOWNLOAD_DUMMY ) {
ret_flag = FALSE;
miya_log_fprintf(log_fd, "%s failed ECDownload 2\n", __FUNCTION__);
goto end_ec_f;
}
else if(ec_download_ret == ECDOWNLOAD_NO_REGISTER ) {
// ret_flag = FALSE;どうする?
ec_download_no_registered_flag = TRUE;
goto end_ec_f;
}
@ -1155,18 +1178,24 @@ void TwlMain(void)
OS_TPrintf("DeviceID: %s\n", mydata.bmsDeviceId);
}
if( FALSE == OS_IsAvailableWireless() ) {
wlan_active_flag = FALSE;
}
if( FALSE == reboot_flag ) {
mprintf("Network update mode\n");
/* 最初はネットワークアップデート。 */
if( FALSE == OS_IsAvailableWireless() ) {
if( FALSE == wlan_active_flag ) {
// m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("Warning:WLAN Enable flag = OFF\n");
m_set_palette(tc[0], 0xF); /* white */
mprintf("Error:WLAN Enable flag = OFF\n");
OS_TPrintf("WLAN Enable flag OFF\n");
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
Gfx_Set_BG1_Color((u16)M_TEXT_COLOR_DARKRED);
goto loop_start;
}
// NSSL_Init(&s_sslConfig);
@ -1198,6 +1227,13 @@ void TwlMain(void)
}
else {
if( FALSE == wlan_active_flag ) {
select_mode = 1;
no_network_flag = TRUE;
}
dir_select_mode = TRUE;
mprintf("user data restore mode\n");
@ -1229,7 +1265,7 @@ void TwlMain(void)
stream_play0(); /* cursor.aiff */
}
loop_start:
while( 1 ) {
Gfx_Render( vram_num_main , vram_num_sub );
OS_WaitVBlankIntr();
@ -1256,12 +1292,13 @@ void TwlMain(void)
}
}
else if ( keyData & (PAD_BUTTON_A | PAD_BUTTON_START) ) {
if( sd_card_flag == TRUE ) {
if( FALSE == reboot_flag ) {
/* ネットワークアップデート */
text_blink_clear(tc[0]);
start_my_thread();
if( wlan_active_flag != FALSE ) {
/* ネットワークアップデート */
text_blink_clear(tc[0]);
start_my_thread();
}
}
else {
/* リストア */
@ -1297,8 +1334,11 @@ void TwlMain(void)
mprintf("Personal data. restore ");
MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(),
&mydata, sizeof(MyData), NULL);
/*
NGになるようにされて
*/
if( mydata.sys_ver_flag == TRUE ) {
sys_version_org = (s64)(((u32)(mydata.sys_ver_major)) << 16 | (u32)(mydata.sys_ver_minor));
@ -1314,29 +1354,37 @@ void TwlMain(void)
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" invalid region code.\n");
mprintf(" \n");
mprintf(" \n");
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
}
else if( mydata.version_major != MY_DATA_VERSION_MAJOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" illegal tool data format.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
}
else if( mydata.version_minor != MY_DATA_VERSION_MINOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" illegal tool data format.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
}
else if( s_flag && mydata.sys_ver_flag && (sys_version < sys_version_org) ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
@ -1347,6 +1395,9 @@ void TwlMain(void)
mprintf(" cur. version %d.%d\n", s_major,s_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
}
else {
m_set_palette(tc[0], 0x2); /* green */
@ -1366,6 +1417,9 @@ void TwlMain(void)
mprintf("NG.\n");
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
}
}
}
@ -1400,7 +1454,8 @@ void TwlMain(void)
only_wifi_config_data_trans_flag = FALSE;
user_and_wifi_config_data_trans_flag = FALSE;
Miya_debug_OFF();
select_mode++;
select_mode %= 5;
switch( select_mode ) {
@ -1591,7 +1646,22 @@ void TwlMain(void)
mfprintf(tc[2],"\n\n\n");
}
else if( MydataLoadDecrypt_message_flag == FALSE ) {
if( mydata.version_major != MY_DATA_VERSION_MAJOR ) {
if( s_flag && mydata.sys_ver_flag && (sys_version < sys_version_org) ) {
m_set_palette(tc[2], M_TEXT_COLOR_YELLOW );
mfprintf(tc[2], " illegal System menu version.\n");
mfprintf(tc[2], " org. version %d.%d\n", mydata.sys_ver_major,mydata.sys_ver_minor);
mfprintf(tc[2], " cur. version %d.%d\n", s_major,s_minor);
mfprintf(tc[2], " \n");
m_set_palette(tc[2], 0xF); /* white */
}
else if( org_region != mydata.region ) {
mfprintf(tc[2]," invalid region code.\n");
mfprintf(tc[2]," \n");
mfprintf(tc[2]," \n");
mfprintf(tc[2]," \n");
m_set_palette(tc[2], 0xF); /* white */
}
else if( mydata.version_major != MY_DATA_VERSION_MAJOR ) {
mfprintf(tc[2]," illegal format version.\n");
mfprintf(tc[2]," %s\n",MyFile_GetGlobalInformationFileName());
mfprintf(tc[2]," version %d.%d\n", mydata.version_major,mydata.version_minor);