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@18 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
1b10713025
commit
7e63bdf031
@ -1,169 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - tools - ecdl
|
||||
File: main.c
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: 2008-09-24#$
|
||||
$Rev: 8618 $
|
||||
$Author: hatamoto_minoru $
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ecdl.h"
|
||||
|
||||
#ifdef SDK_DEBUG
|
||||
#define ECDL_LOG(msg) OS_TPrintf("----\nECDL-LOG: %s\n----\n", msg);
|
||||
#endif
|
||||
#ifdef SDK_RELEASE
|
||||
#define ECDL_LOG(msg) OS_TPrintf("ECDL-LOG: %s\n", msg);
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
char CheckRegistration()
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
ECDeviceInfo di;
|
||||
|
||||
ECDL_LOG("check registeration");
|
||||
progress = EC_CheckRegistration();
|
||||
WaitEC(progress);
|
||||
|
||||
ecError = EC_GetDeviceInfo(&di);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
|
||||
#ifdef SDK_DEBUG
|
||||
#define ECDL_DI_FMT "%-30s"
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isKeyPairConfirmed", di.isKeyPairConfirmed);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "deviceId", di.deviceId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "serial", di.serial);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "originalSerial", di.originalSerial);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountId", di.accountId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "registrationStatus", di.registrationStatus);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "extAccountId", di.extAccountId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "country", di.country);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountCountry", di.accountCountry);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "region", di.region);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "language", di.language);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "blockSize", di.blockSize);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "usedBlocks", di.usedBlocks);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "totalBlocks", di.totalBlocks);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "netContentRestrictions", di.netContentRestrictions);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "userAge", di.userAge);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "parentalControlFlags", di.parentalControlFlags);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "parentalControlOgn", di.parentalControlOgn);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isParentalControlEnabled", di.isParentalControlEnabled);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isNeedTicketSync", di.isNeedTicketSync);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "lastTicketSyncTime", di.lastTicketSyncTime);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "wirelessMACAddr", di.wirelessMACAddr);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "bluetoothMACAddr", di.bluetoothMACAddr);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "titleId", di.titleId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "freeChannelAppCount", di.freeChannelAppCount);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "usedUserInodes", di.usedUserInodes);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "maxUserInodes", di.maxUserInodes);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "deviceCode", di.deviceCode);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountDeviceCode", di.accountDeviceCode);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isNeedTicketSyncImportAll", di.isNeedTicketSyncImportAll);
|
||||
#endif
|
||||
|
||||
return di.registrationStatus[0];
|
||||
}
|
||||
|
||||
void GetChallenge(char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
|
||||
ECDL_LOG("get challenge");
|
||||
progress = EC_SendChallengeReq();
|
||||
WaitEC(progress);
|
||||
|
||||
ecError = EC_GetChallengeResp(challenge);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
}
|
||||
|
||||
void SyncRegistration(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync registration");
|
||||
progress = EC_SyncRegistration(challenge);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void Register(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("register");
|
||||
progress = EC_Register(challenge, NULL, NULL);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void Transfer(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("transfer");
|
||||
progress = EC_Transfer(challenge);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void SyncTickets()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync tickets");
|
||||
progress = EC_SyncTickets(EC_SYNC_TYPE_IMPORT_ALL);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("download");
|
||||
for( u32 i = 0; i < numTitleIds; ++i )
|
||||
{
|
||||
NAMTitleId tid = pTitleIds[i];
|
||||
|
||||
OS_TPrintf("download %08X %08X\n", (u32)(tid >> 32), (u32)tid);
|
||||
progress = EC_DownloadTitle(tid, EC_DT_UPDATE_REQUIRED_CONTENTS);
|
||||
WaitEC(progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
char challenge[EC_CHALLENGE_BUF_SIZE];
|
||||
char status;
|
||||
|
||||
status = CheckRegistration();
|
||||
// U unregistered
|
||||
// R registered
|
||||
// P pending
|
||||
// T transfered
|
||||
SDK_ASSERTMSG(status != 'U', "acount not transfered yet.");
|
||||
SDK_ASSERTMSG(status != 'R', "already registered. please delete acount.");
|
||||
SDK_ASSERTMSG( (status == 'P') || (status == 'T'), "invalid registration status '%c'", status );
|
||||
|
||||
GetChallenge(challenge);
|
||||
Transfer(challenge);
|
||||
|
||||
GetChallenge(challenge);
|
||||
SyncRegistration(challenge);
|
||||
|
||||
SyncTickets();
|
||||
DownloadTitles(pTitleIds, numTitleIds);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ extern "C" {
|
||||
|
||||
void ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
|
||||
void KPSClient();
|
||||
void WaitEC(ECOpId opId);
|
||||
BOOL WaitEC(ECOpId opId);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -4,10 +4,6 @@
|
||||
#include <twl/na.h>
|
||||
#include <twl/nam.h>
|
||||
|
||||
#ifdef USE_DWC
|
||||
#include <dwc.h>
|
||||
#include <ac/dwc_ac.h>
|
||||
#endif
|
||||
|
||||
#include <NitroWiFi/nhttp.h>
|
||||
#include "nssl.h"
|
||||
@ -19,6 +15,16 @@
|
||||
|
||||
#include "hatamotolib.h"
|
||||
|
||||
|
||||
#ifdef SDK_DEBUG
|
||||
#define ECDL_LOG(msg) OS_TPrintf("----\nECDL-LOG: %s\n----\n", msg);
|
||||
#endif
|
||||
#ifdef SDK_RELEASE
|
||||
#define ECDL_LOG(msg) OS_TPrintf("ECDL-LOG: %s\n", msg);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void *Alloc(size_t size)
|
||||
{
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
@ -37,17 +43,6 @@ static void Free(void* ptr)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_DWC
|
||||
static void* AllocForDWC(DWCAllocType name, u32 size, int align)
|
||||
{
|
||||
SDK_ASSERT(align <= 32);(void)name;(void)align; return Alloc(static_cast<u32>(size));
|
||||
}
|
||||
|
||||
static void FreeForDWC(DWCAllocType name, void* ptr, u32 size)
|
||||
{
|
||||
(void)name;(void)size; Free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void* AllocForNHTTP(u32 size, int align) { SDK_ASSERT(align <= 32);(void)align; return Alloc(size); }
|
||||
static void* AllocForEC (u32 size, int align) { SDK_ASSERT(align <= 32);(void)align; return Alloc(size); }
|
||||
@ -143,20 +138,6 @@ GetECOpPhaseString(ECOpPhase phase)
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_DWC
|
||||
static const char*
|
||||
GetDWCApInfoTypeString(DWCApInfoType type)
|
||||
{
|
||||
static const StringMap STRING_MAP[] =
|
||||
{
|
||||
#include "string_map_dwc_apinfo_type.inc"
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
return FindString(STRING_MAP, type);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static const char*
|
||||
GetOSTWLRegionString(u8 x)
|
||||
@ -313,122 +294,6 @@ void SetupShopTitleId(void)
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_DWC
|
||||
static u8 sDwcWork[ DWC_INIT_WORK_SIZE ] ATTRIBUTE_ALIGN(32);
|
||||
static DWCInetControl sDwcInetCtrl;
|
||||
|
||||
static void PollConnection_DWC()
|
||||
{
|
||||
int errCode;
|
||||
int counter = 0;
|
||||
while( ! DWC_CheckInet() )
|
||||
{
|
||||
DWC_ProcessInet();
|
||||
OS_Sleep(16);
|
||||
OS_TPrintf("*** %s %d %d\n",__FUNCTION__, __LINE__, counter);
|
||||
counter++;
|
||||
}
|
||||
|
||||
OS_TPrintf("*** %s %d\n",__FUNCTION__, __LINE__);
|
||||
|
||||
switch ( DWC_GetInetStatus() )
|
||||
{
|
||||
case DWC_CONNECTINET_STATE_NOT_INITIALIZED:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_NOT_INITIALIZED\n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_IDLE:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_IDLE \n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_OPERATING:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_OPERATING \n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_OPERATED:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_OPERATED \n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_CONNECTED:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_CONNECTED \n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_DISCONNECTING:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_DISCONNECTING \n" );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_DISCONNECTED:
|
||||
OS_TPrintf(" DWC_CONNECTINET_STATE_DISCONNECTED %d\n");
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_ERROR:
|
||||
DWC_GetLastError(&errCode);
|
||||
OS_Panic(" DWC_CONNECTINET_STATE_ERROR %d\n", errCode );
|
||||
break;
|
||||
case DWC_CONNECTINET_STATE_FATAL_ERROR:
|
||||
DWC_GetLastError(&errCode);
|
||||
OS_Panic(" DWC_CONNECTINET_STATE_FATAL_ERROR %d\n", errCode );
|
||||
break;
|
||||
default:
|
||||
DWC_GetLastError(&errCode);
|
||||
OS_Panic(" DWC_CONNECTINET_STATE_UNKNOWN_ERROR %d\n", errCode );
|
||||
}
|
||||
}
|
||||
|
||||
static bool ConnectionResult_DWC()
|
||||
{
|
||||
DWCApInfo apinfo;
|
||||
|
||||
if ( DWC_GetApInfo( &apinfo ) == TRUE )
|
||||
{
|
||||
OS_TPrintf(" AP type: %s\n", GetDWCApInfoTypeString(apinfo.aptype));
|
||||
OS_TPrintf(" ESSID : %s\n", &apinfo.essid);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWCError error;
|
||||
int errorCode;
|
||||
DWCErrorType errorType;
|
||||
// 接続失敗のエラーコード表示
|
||||
error = DWC_GetLastErrorEx( &errorCode, &errorType );
|
||||
OS_TPrintf(" error point : %d\n", error );
|
||||
OS_TPrintf(" error no : %d\n", -errorCode );
|
||||
OS_TPrintf(" error type : %d\n", errorType );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void NetworkAutoConnect_DWC(void)
|
||||
{
|
||||
|
||||
DWC_SetReportLevel(DWC_REPORTFLAG_ALL);
|
||||
|
||||
int result = DWC_Init(sDwcWork);
|
||||
|
||||
if ( result == DWC_INIT_RESULT_DESTROY_OTHER_SETTING )
|
||||
{
|
||||
OS_TPrintf( "Wi-Fi setting might be broken.\n" );
|
||||
}
|
||||
|
||||
DWC_SetMemFunc( &AllocForDWC, &FreeForDWC );
|
||||
|
||||
DWC_InitInet( &sDwcInetCtrl );
|
||||
|
||||
DWC_SetDisableEulaCheck();
|
||||
|
||||
DWC_ConnectInetAsync();
|
||||
|
||||
|
||||
PollConnection_DWC();
|
||||
|
||||
if( ! ConnectionResult_DWC() )
|
||||
{
|
||||
OS_Panic("auto connect failed");
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkShutdown_DWC(void)
|
||||
{
|
||||
DWC_CleanupInet();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SetupNSSL(void)
|
||||
{
|
||||
@ -442,7 +307,7 @@ void SetupNSSL(void)
|
||||
NSSL_Init(&conf);
|
||||
}
|
||||
|
||||
void SetupNHTTP(void)
|
||||
BOOL SetupNHTTP(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
@ -451,8 +316,10 @@ void SetupNHTTP(void)
|
||||
|
||||
if (rv != NHTTP_ERROR_NONE)
|
||||
{
|
||||
OS_Panic("Failed to start NHTTP, rv=%d\n", rv);
|
||||
OS_TPrintf("Failed to start NHTTP, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -482,7 +349,7 @@ Dummy_WWW_AddJSPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
static BOOL
|
||||
LoadCert(void** ppCert, u32* pSize, const char* name)
|
||||
{
|
||||
FSFile f;
|
||||
@ -501,20 +368,23 @@ LoadCert(void** ppCert, u32* pSize, const char* name)
|
||||
bSuccess = FS_OpenFile(&f, path);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_Panic("Cannot open %s\n", path);
|
||||
OS_TPrintf("Cannot open %s\n", path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
certSize = FS_GetFileLength(&f);
|
||||
pCert = OS_Alloc(certSize);
|
||||
if ( pCert == NULL )
|
||||
{
|
||||
OS_Panic("Cannot allocate work memroy\n");
|
||||
OS_TPrintf("Cannot allocate work memroy\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
readSize = FS_ReadFile(&f, pCert, static_cast<s32>(certSize));
|
||||
if( readSize != certSize )
|
||||
{
|
||||
OS_Panic("fail to read file\n");
|
||||
OS_TPrintf("fail to read file\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FS_CloseFile(&f);
|
||||
@ -522,11 +392,13 @@ LoadCert(void** ppCert, u32* pSize, const char* name)
|
||||
result = NA_DecodeVersionData(pCert, certSize, pCert, certSize);
|
||||
if( result <= 0 )
|
||||
{
|
||||
OS_Panic("fail to decode version info %d\n", result);
|
||||
OS_TPrintf("fail to decode version info %d\n", result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*ppCert = pCert;
|
||||
*pSize = certSize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -576,7 +448,7 @@ void SetupEC(void)
|
||||
}
|
||||
|
||||
|
||||
void WaitEC(ECOpId opId)
|
||||
BOOL WaitEC(ECOpId opId)
|
||||
{
|
||||
ECError result;
|
||||
ECProgress progress;
|
||||
@ -584,7 +456,8 @@ void WaitEC(ECOpId opId)
|
||||
|
||||
if( opId < 0 )
|
||||
{
|
||||
OS_TPanic("error %d %s\n", opId, GetECErrorString(opId));
|
||||
OS_TPrintf("error %d %s\n", opId, GetECErrorString(opId));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MI_CpuClear(&progress_prev, sizeof(progress_prev));
|
||||
@ -599,7 +472,8 @@ void WaitEC(ECOpId opId)
|
||||
{
|
||||
OS_TPrintf("opId=%d\n", opId);
|
||||
}
|
||||
OS_TPanic("Failed to EC_GetProgress, result=%d %s\n", result, GetECErrorString(result));
|
||||
OS_TPrintf("Failed to EC_GetProgress, result=%d %s\n", result, GetECErrorString(result));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//#ifdef SDK_DEBUG
|
||||
@ -625,11 +499,181 @@ void WaitEC(ECOpId opId)
|
||||
|
||||
OS_Sleep(300);
|
||||
}
|
||||
return TRUE;;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void hatamotolib_main(void)
|
||||
|
||||
namespace
|
||||
{
|
||||
char CheckRegistration()
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
ECDeviceInfo di;
|
||||
|
||||
ECDL_LOG("check registeration");
|
||||
progress = EC_CheckRegistration();
|
||||
WaitEC(progress);
|
||||
|
||||
ecError = EC_GetDeviceInfo(&di);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
|
||||
#ifdef SDK_DEBUG
|
||||
#define ECDL_DI_FMT "%-30s"
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isKeyPairConfirmed", di.isKeyPairConfirmed);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "deviceId", di.deviceId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "serial", di.serial);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "originalSerial", di.originalSerial);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountId", di.accountId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "registrationStatus", di.registrationStatus);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "extAccountId", di.extAccountId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "country", di.country);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountCountry", di.accountCountry);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "region", di.region);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "language", di.language);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "blockSize", di.blockSize);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "usedBlocks", di.usedBlocks);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "totalBlocks", di.totalBlocks);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "netContentRestrictions", di.netContentRestrictions);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "userAge", di.userAge);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "parentalControlFlags", di.parentalControlFlags);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "parentalControlOgn", di.parentalControlOgn);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isParentalControlEnabled", di.isParentalControlEnabled);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isNeedTicketSync", di.isNeedTicketSync);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "lastTicketSyncTime", di.lastTicketSyncTime);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "wirelessMACAddr", di.wirelessMACAddr);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "bluetoothMACAddr", di.bluetoothMACAddr);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "titleId", di.titleId);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "freeChannelAppCount", di.freeChannelAppCount);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "usedUserInodes", di.usedUserInodes);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "maxUserInodes", di.maxUserInodes);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "deviceCode", di.deviceCode);
|
||||
OS_TPrintf(ECDL_DI_FMT " %s\n", "accountDeviceCode", di.accountDeviceCode);
|
||||
OS_TPrintf(ECDL_DI_FMT " %d\n", "isNeedTicketSyncImportAll", di.isNeedTicketSyncImportAll);
|
||||
#endif
|
||||
|
||||
return di.registrationStatus[0];
|
||||
}
|
||||
|
||||
void GetChallenge(char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
|
||||
ECDL_LOG("get challenge");
|
||||
progress = EC_SendChallengeReq();
|
||||
WaitEC(progress);
|
||||
|
||||
ecError = EC_GetChallengeResp(challenge);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
}
|
||||
|
||||
void SyncRegistration(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync registration");
|
||||
progress = EC_SyncRegistration(challenge);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void Register(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("register");
|
||||
progress = EC_Register(challenge, NULL, NULL);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void Transfer(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("transfer");
|
||||
progress = EC_Transfer(challenge);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void SyncTickets()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync tickets");
|
||||
progress = EC_SyncTickets(EC_SYNC_TYPE_IMPORT_ALL);
|
||||
WaitEC(progress);
|
||||
}
|
||||
|
||||
void DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("download");
|
||||
for( u32 i = 0; i < numTitleIds; ++i )
|
||||
{
|
||||
NAMTitleId tid = pTitleIds[i];
|
||||
|
||||
OS_TPrintf("download %08X %08X\n", (u32)(tid >> 32), (u32)tid);
|
||||
progress = EC_DownloadTitle(tid, EC_DT_UPDATE_REQUIRED_CONTENTS);
|
||||
WaitEC(progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
char challenge[EC_CHALLENGE_BUF_SIZE];
|
||||
char status;
|
||||
|
||||
status = CheckRegistration();
|
||||
// U unregistered
|
||||
// R registered
|
||||
// P pending
|
||||
// T transfered
|
||||
SDK_ASSERTMSG(status != 'U', "acount not transfered yet.");
|
||||
SDK_ASSERTMSG(status != 'R', "already registered. please delete acount.");
|
||||
SDK_ASSERTMSG( (status == 'P') || (status == 'T'), "invalid registration status '%c'", status );
|
||||
|
||||
GetChallenge(challenge);
|
||||
Transfer(challenge);
|
||||
|
||||
GetChallenge(challenge);
|
||||
SyncRegistration(challenge);
|
||||
|
||||
SyncTickets();
|
||||
DownloadTitles(pTitleIds, numTitleIds);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KPSClient()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
OS_TPrintf("generate key pair\n");
|
||||
progress = EC_GenerateKeyPair();
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
OS_TPrintf("confirm key pair\n");
|
||||
progress = EC_ConfirmKeyPair();
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL hatamotolib_main(void)
|
||||
{
|
||||
// 不要:デバイス情報の表示
|
||||
PrintDeviceInfo();
|
||||
@ -649,15 +693,18 @@ void hatamotolib_main(void)
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
OS_TPrintf("connecting to AP....\n");
|
||||
#ifdef USE_DWC
|
||||
NetworkAutoConnect_DWC();
|
||||
#endif
|
||||
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
|
||||
OS_TPrintf("connected\n");
|
||||
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
SetupNSSL();
|
||||
SetupNHTTP();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
@ -706,13 +753,11 @@ void hatamotolib_main(void)
|
||||
SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
|
||||
// ネットワークからの切断
|
||||
#ifdef USE_DWC
|
||||
NetworkShutdown_DWC();
|
||||
#endif
|
||||
NcFinish();
|
||||
}
|
||||
|
||||
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する
|
||||
DeleteECDirectory();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -12,13 +12,13 @@ void SetupVerData(void);
|
||||
void NetworkAutoConnect_DWC(void);
|
||||
void NetworkShutdown_DWC(void);
|
||||
void SetupNSSL(void);
|
||||
void SetupNHTTP(void);
|
||||
BOOL SetupNHTTP(void);
|
||||
void SetupEC(void);
|
||||
void WaitEC(ECOpId opId);
|
||||
BOOL WaitEC(ECOpId opId);
|
||||
void DeleteECDirectory(void);
|
||||
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds);
|
||||
|
||||
void hatamotolib_main(void);
|
||||
BOOL hatamotolib_main(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - tools - ecdl
|
||||
File: kpsc.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: 2008-09-22#$
|
||||
$Rev: 8604 $
|
||||
$Author: hatamoto_minoru $
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ecdl.h"
|
||||
|
||||
|
||||
void
|
||||
KPSClient()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
OS_TPrintf("generate key pair\n");
|
||||
progress = EC_GenerateKeyPair();
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
OS_TPrintf("confirm key pair\n");
|
||||
progress = EC_ConfirmKeyPair();
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
}
|
||||
|
||||
@ -866,7 +866,7 @@ int SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path )
|
||||
/********************************************
|
||||
* NANDにディレクトリエントリとファイルを復活させる。
|
||||
*********************************************/
|
||||
BOOL RestoreDirEntryList( char *path )
|
||||
BOOL RestoreDirEntryList( char *path , char *log_file_name)
|
||||
{
|
||||
FSFile f;
|
||||
FSFile f_dir;
|
||||
@ -880,7 +880,7 @@ BOOL RestoreDirEntryList( char *path )
|
||||
|
||||
FSFile log_fd;
|
||||
BOOL log_active = FALSE;
|
||||
char *log_file_name = "sdmc:/miya/restore_dir_entry_log.txt";
|
||||
|
||||
|
||||
/* ここでSDカードがあるかどうか調べる */
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ void PrintDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd );
|
||||
void PrintSrcDirEntryListBackward( MY_DIR_ENTRY_LIST *head, FSFile *log_fd);
|
||||
|
||||
int SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path );
|
||||
BOOL RestoreDirEntryList( char *path );
|
||||
BOOL RestoreDirEntryList( char *path, char *log_file_name);
|
||||
BOOL ClearDirEntryList( MY_DIR_ENTRY_LIST **headp );
|
||||
void write_debug_data(void);
|
||||
BOOL SDCardValidation(void);
|
||||
|
||||
@ -50,6 +50,13 @@ char *MyFile_GetAppSharedLogFileName(void)
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetAppSharedRestoreLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_APP_SHARED_RESTORE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetAppSharedListFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
@ -63,6 +70,7 @@ char *MyFile_GetPhotoSaveDirName(void)
|
||||
STD_StrCat( path , MY_DIR_NAME_PHOTO );
|
||||
return path;
|
||||
}
|
||||
|
||||
char *MyFile_GetPhotoLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
@ -70,6 +78,13 @@ char *MyFile_GetPhotoLogFileName(void)
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetPhotoRestoreLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_PHOTO_RESTORE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetPhotoListFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
@ -83,12 +98,21 @@ char *MyFile_GetAppDataSaveDirName(void)
|
||||
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_GetAppDataRestoreLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_TITLE_RESTORE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetAppDataListFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
@ -102,6 +126,14 @@ char *MyFile_GetDownloadTitleIDLogFileName(void)
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetDownloadTitleIDRestoreLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_RESTORE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetDownloadTitleIDFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
@ -116,4 +148,18 @@ char *MyFile_GetGlobalInformationFileName(void)
|
||||
return path;
|
||||
}
|
||||
|
||||
char *MyFile_GetGlobalInformationLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , MY_FILE_NAME_ORG_LOG );
|
||||
return path;
|
||||
}
|
||||
|
||||
char *MyFile_GetGlobalInformationRestoreFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , MY_FILE_NAME_ORG_RESTORE_LOG );
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,25 +6,30 @@
|
||||
#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_APP_SHARED_LOG ("shared2.txt")
|
||||
#define MY_FILE_NAME_APP_SHARED_LIST ("shared2.lst")
|
||||
#define MY_FILE_NAME_APP_SHARED_RESTORE_LOG ("shared2_rst.txt")
|
||||
|
||||
|
||||
#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_PHOTO_LOG ("photo.txt")
|
||||
#define MY_FILE_NAME_PHOTO_LIST ("photo.lst")
|
||||
#define MY_FILE_NAME_PHOTO_RESTORE_LOG ("photo_rst.txt")
|
||||
|
||||
#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_TITLE_LOG ("title.txt")
|
||||
#define MY_FILE_NAME_TITLE_LIST ("title.lst")
|
||||
#define MY_FILE_NAME_TITLE_RESTORE_LOG ("title_rst.txt")
|
||||
|
||||
|
||||
#define MY_DIR_NAME_DOWNLOAD_TITLE_ID ("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_DOWNLOAD_TITLE_ID_RESTORE_LOG ("title_id_rst.txt" )
|
||||
|
||||
#define MY_FILE_NAME_ORG_DATA ("global.dat")
|
||||
#define MY_FILE_NAME_ORG_LOG ("global.txt");
|
||||
#define MY_FILE_NAME_ORG_LOG ("global.txt")
|
||||
#define MY_FILE_NAME_ORG_RESTORE_LOG ("global_rst.txt")
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -33,21 +38,34 @@ extern "C" {
|
||||
|
||||
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_GetAppSharedRestoreLogFileName(void);
|
||||
|
||||
char *MyFile_GetPhotoListFileName(void);
|
||||
char *MyFile_GetPhotoSaveDirName(void);
|
||||
char *MyFile_GetPhotoLogFileName(void);
|
||||
char *MyFile_GetPhotoRestoreLogFileName(void);
|
||||
|
||||
char *MyFile_GetAppDataSaveDirName(void);
|
||||
char *MyFile_GetAppDataLogFileName(void);
|
||||
char *MyFile_GetAppDataListFileName(void);
|
||||
char *MyFile_GetAppDataRestoreLogFileName(void);
|
||||
|
||||
char *MyFile_GetDownloadTitleIDLogFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDRestoreLogFileName(void);
|
||||
|
||||
char *MyFile_GetGlobalInformationFileName(void);
|
||||
char *MyFile_GetGlobalInformationRestoreFileName(void);
|
||||
char *MyFile_GetGlobalInformationLogFileName(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ BOOL nvram_restore(char *path)
|
||||
OS_TPrintf("\n");
|
||||
bSuccess = FS_CloseFile(&nor_fd);
|
||||
|
||||
mprintf("nvram write completed.\n");
|
||||
// mprintf("nvram write completed.\n");
|
||||
OS_TPrintf( "nvram write completed.\n");
|
||||
|
||||
return TRUE;
|
||||
|
||||
@ -24,7 +24,7 @@ SRCDIR = ../common/src ./src
|
||||
|
||||
SRCS = main.c mfiler.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 \
|
||||
hatamotolib.cpp \
|
||||
sitedefs.c wcm_control.c netconnect.c mywlan.c \
|
||||
nuc.c nuc_error_msg.c stream.c myfilename.c
|
||||
|
||||
|
||||
@ -93,88 +93,147 @@ static void start_my_thread(void)
|
||||
(void)OS_SendMessage(&MyMesgQueue, (OSMessage)0, OS_MESSAGE_NOBLOCK);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static BOOL RestoreFromSDCard1(void)
|
||||
{
|
||||
BOOL flag = TRUE;
|
||||
/* 基本的にこいつらの逆をやる(Get -> Set, Save->Loadなど) */
|
||||
/*
|
||||
ちなみにすでにMydataLoad関数は成功しているものとする。
|
||||
したがって MyData mydata にはデータが入っている。
|
||||
*/
|
||||
// static BOOL SDBackupToSDCard8(void)
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
mprintf("RTC restore ");
|
||||
if( RTC_RESULT_SUCCESS != RTC_SetDate( &(mydata.rtc_date) ) ) {
|
||||
flag = FALSE;
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
if( RTC_RESULT_SUCCESS != RTC_SetTime( &(mydata.rtc_time) ) ) {
|
||||
flag = FALSE;
|
||||
}
|
||||
|
||||
STD_CopyMemory( (void *)(mydata.movableUniqueID), (void *)hwn_info.movableUniqueID,
|
||||
LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
|
||||
|
||||
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
|
||||
}
|
||||
|
||||
/* hws_info.serialNoは戻せない */
|
||||
/* */
|
||||
|
||||
// static BOOL SDBackupToSDCard7(void)
|
||||
if( 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( flag == TRUE ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
mprintf("User title list backup ");
|
||||
OS_TPrintf("User title list backup \n");
|
||||
|
||||
// (void)TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL);
|
||||
|
||||
nuc_main(); /* ネットワーク接続 */
|
||||
/* nand:/ticketはチケット同期でダウンロード */
|
||||
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
// static BOOL SDBackupToSDCard6(void)
|
||||
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 ) ) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
static BOOL RestoreFromSDCard2(void)
|
||||
{
|
||||
mprintf("Unique ID restore ");
|
||||
/* すでにブート時に一度 hwn_info はリードしている。 */
|
||||
STD_CopyMemory( (void *)hwn_info.movableUniqueID, (void *)(mydata.movableUniqueID),
|
||||
LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
|
||||
|
||||
if ( LCFGi_THW_WriteNormalInfoDirect( &hwn_info )) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
|
||||
// static BOOL SDBackupToSDCard5(void)
|
||||
mprintf("Photo files backup ");
|
||||
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetPhotoSaveDirName() , "nand2:/photo" , MyFile_GetPhotoLogFileName(),0 ) ) {
|
||||
}
|
||||
|
||||
// static BOOL SDBackupToSDCard4(void)
|
||||
mprintf("App. shared files backup ");
|
||||
if( 0 == copy_r( &dir_entry_list_head, MyFile_GetAppSharedSaveDirName() , "nand:/shared2" , MyFile_GetAppSharedLogFileName(), 0) ) {
|
||||
}
|
||||
|
||||
// static BOOL SDBackupToSDCard3(void)
|
||||
mprintf("User setting param. backup ");
|
||||
if( TRUE == MiyaBackupTWLSettings( MyFile_GetUserSettingsFileName() ) ) {
|
||||
}
|
||||
|
||||
// static BOOL SDBackupToSDCard2(void)
|
||||
mprintf("WirelessLAN param. backup ");
|
||||
if( TRUE == nvram_backup( MyFile_GetWifiParamFileName() ) ) {
|
||||
else {
|
||||
// error
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
#if 0
|
||||
// いらんやんか・・
|
||||
// static BOOL SDBackupToSDCard1(void)
|
||||
mprintf("Unique ID backup ");
|
||||
if( TRUE == MiyaBackupHWNormalInfo( MyFile_GetUniqueIDFileName() ) ) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL RestoreFromSDCard(void)
|
||||
static BOOL RestoreFromSDCard3(void)
|
||||
{
|
||||
// static BOOL SDBackupToSDCard2(void)
|
||||
mprintf("WirelessLAN param. restore ");
|
||||
if( TRUE == nvram_restore( MyFile_GetWifiParamFileName() ) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
// error
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL RestoreFromSDCard4(void)
|
||||
{
|
||||
// static BOOL SDBackupToSDCard3(void)
|
||||
mprintf("User setting param. restore ");
|
||||
if( TRUE == MiyaRestoreTWLSettings( MyFile_GetUserSettingsFileName() ) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
// error
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL RestoreFromSDCard5(void)
|
||||
{
|
||||
// static BOOL SDBackupToSDCard4(void)
|
||||
mprintf("App. shared files restore ");
|
||||
if( TRUE == RestoreDirEntryList( MyFile_GetAppSharedListFileName(), MyFile_GetAppSharedRestoreLogFileName() )) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
// error
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL RestoreFromSDCard6(void)
|
||||
{
|
||||
// static BOOL SDBackupToSDCard5(void)
|
||||
mprintf("Photo files restore ");
|
||||
if( TRUE == RestoreDirEntryList( MyFile_GetPhotoListFileName() , MyFile_GetPhotoRestoreLogFileName() )) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
// error
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static BOOL LoadWlanConfig(void)
|
||||
{
|
||||
/* ユーザーデータ書き込みモード */
|
||||
if( TRUE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) {
|
||||
OS_TPrintf("SSID = %s\n", GetWlanSSID());
|
||||
OS_TPrintf("MODE = ");
|
||||
OS_TPrintf("MODE = ");
|
||||
|
||||
switch( GetWlanMode() ) {
|
||||
case 1:
|
||||
OS_TPrintf("OPEN\n");
|
||||
OS_TPrintf("NONE\n");
|
||||
break;
|
||||
case 2:
|
||||
OS_TPrintf("WEP128\n");
|
||||
@ -213,15 +272,84 @@ static BOOL RestoreFromSDCard(void)
|
||||
else {
|
||||
OS_TPrintf("Invalid wlan cfg file\n");
|
||||
}
|
||||
nuc_main();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static BOOL RestoreFromSDCard7(void)
|
||||
{
|
||||
u64 *title_id_buf_ptr = NULL;
|
||||
int title_id_count = 0;
|
||||
/* hws_info.serialNoは戻せない */
|
||||
/* */
|
||||
// static BOOL SDBackupToSDCard7(void)
|
||||
|
||||
// for DEBUG
|
||||
mydata.shop_record_flag = TRUE;
|
||||
|
||||
if( 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");
|
||||
}
|
||||
else {
|
||||
mprintf("User title list restore ");
|
||||
OS_TPrintf("User title list restore \n");
|
||||
// (void)TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL);
|
||||
if( TRUE == TitleIDLoad( MyFile_GetDownloadTitleIDFileName(), &title_id_buf_ptr,
|
||||
&title_id_count, NULL) ) {
|
||||
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n"); }
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
mprintf("Wireless AP conf. loading.. ");
|
||||
if( TRUE == LoadWlanConfig() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
|
||||
// nuc_main(); /* ネットワーク接続 */
|
||||
hatamotolib_main(); /* ネットワーク接続 */
|
||||
/* nand:/ticketはチケット同期でダウンロード */
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
#if 0
|
||||
// static BOOL SDBackupToSDCard6(void)
|
||||
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 ) ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 最後にネットワークアップデート。 */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
typedef BOOL (*function_ptr)(void);
|
||||
|
||||
static function_ptr function_table[] =
|
||||
{
|
||||
RestoreFromSDCard
|
||||
#if 1
|
||||
RestoreFromSDCard1,
|
||||
RestoreFromSDCard2,
|
||||
RestoreFromSDCard3,
|
||||
RestoreFromSDCard4,
|
||||
RestoreFromSDCard5,
|
||||
RestoreFromSDCard6,
|
||||
#endif
|
||||
RestoreFromSDCard7
|
||||
};
|
||||
|
||||
static int function_table_max = sizeof(function_table) / sizeof(*function_table);
|
||||
@ -239,6 +367,7 @@ static void MyThreadProc(void *arg)
|
||||
for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) {
|
||||
(void)(function_table[function_counter])();
|
||||
}
|
||||
/* 全部成功したらフォルダを消す */
|
||||
if( TRUE == stream_is_play1_end() ) {
|
||||
OS_TPrintf("stream play\n");
|
||||
stream_play1();
|
||||
@ -453,7 +582,7 @@ void TwlMain(void)
|
||||
MyFile_AddPathBase((const char *)MFILER_GetCursorEntryPath( &mfiler_list_head ) );
|
||||
MyFile_AddPathBase("/");
|
||||
if(TRUE == MydataLoad( MyFile_GetGlobalInformationFileName(), &mydata, sizeof(MyData), NULL) ) {
|
||||
mprintf("global info. data restore ");
|
||||
mprintf("global info. restore ");
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
@ -518,6 +647,8 @@ void TwlMain(void)
|
||||
rtc_date.year + 2000, rtc_date.month , rtc_date.day,
|
||||
rtc_time.hour , rtc_time.minute , rtc_time.second );
|
||||
|
||||
mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max);
|
||||
|
||||
// mfprintf(tc[1], "cwd = %s\n\n", MFILER_Get_CurrentDir());
|
||||
|
||||
MFILER_ClearDir(&mfiler_list_head);
|
||||
|
||||
@ -24,7 +24,7 @@ SRCDIR = ../common/src ./src
|
||||
|
||||
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 \
|
||||
hatamotolib.cpp \
|
||||
sitedefs.c wcm_control.c netconnect.c mywlan.c \
|
||||
nuc.c nuc_error_msg.c stream.c myfilename.c
|
||||
|
||||
|
||||
@ -269,7 +269,8 @@ static BOOL SDBackupToSDCard7(void)
|
||||
*/
|
||||
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 ) ) {
|
||||
if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info,
|
||||
MyFile_GetDownloadTitleIDLogFileName(), 0 ) ) {
|
||||
|
||||
GetDirEntryList( dir_entry_list_head, &pBuffer, &count);
|
||||
|
||||
@ -284,11 +285,17 @@ static BOOL SDBackupToSDCard7(void)
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
(void)TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL);
|
||||
if( TRUE == TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL) ) {
|
||||
//MyFile_GetDownloadTitleIDLogFileName()
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
}
|
||||
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 */
|
||||
@ -612,54 +619,6 @@ void TwlMain(void)
|
||||
}
|
||||
}
|
||||
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 ) {
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user