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@21 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
b80658b8df
commit
c1645acba5
@ -1,959 +0,0 @@
|
||||
#include "ecdl.h"
|
||||
#include <twl/sea.h>
|
||||
#include <twl/lcfg.h>
|
||||
#include <twl/na.h>
|
||||
#include <twl/nam.h>
|
||||
|
||||
|
||||
#include <NitroWiFi/nhttp.h>
|
||||
#include "nssl.h"
|
||||
|
||||
|
||||
#include "netconnect.h"
|
||||
#include "sitedefs.h"
|
||||
#include "wcm_control.h"
|
||||
|
||||
#include "hatamotolib.h"
|
||||
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
#include "logprintf.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();
|
||||
void* p = OS_Alloc(size);
|
||||
OS_RestoreInterrupts(old);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void Free(void* ptr)
|
||||
{
|
||||
if( ptr != NULL )
|
||||
{
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
OS_Free(ptr);
|
||||
OS_RestoreInterrupts(old);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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); }
|
||||
static void* AllocForNSSL (u32 size) { return Alloc(size); }
|
||||
static void* AllocForNAM (u32 size) { return Alloc(size); }
|
||||
static void FreeForNHTTP (void* p) { Free(p); }
|
||||
static void FreeForEC (void* p) { Free(p); }
|
||||
static void FreeForNSSL (void* p) { Free(p); }
|
||||
static void FreeForNAM (void* p) { Free(p); }
|
||||
static void* ReallocForNSSL(void* p, u32 size)
|
||||
{
|
||||
if( p != NULL )
|
||||
{
|
||||
void* newp = Alloc(size);
|
||||
MI_CpuCopy8(p, newp, size);
|
||||
Free(p);
|
||||
return newp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Alloc(size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PrintBytes(const void* pv, u32 size)
|
||||
{
|
||||
const u8* p = reinterpret_cast<const u8*>(pv);
|
||||
|
||||
for( u32 i = 0; i < size; i++ )
|
||||
{
|
||||
OS_TPrintf("%02X", p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct StringMap
|
||||
{
|
||||
int value;
|
||||
const char* string;
|
||||
};
|
||||
|
||||
static const char*
|
||||
FindString(const StringMap* pMap, int value)
|
||||
{
|
||||
while( pMap->string != NULL )
|
||||
{
|
||||
if( pMap->value == value )
|
||||
{
|
||||
return pMap->string;
|
||||
}
|
||||
|
||||
pMap++;
|
||||
}
|
||||
|
||||
return "unknwon value";
|
||||
}
|
||||
|
||||
|
||||
static const char* GetECErrorString(ECError err)
|
||||
{
|
||||
static const StringMap STRING_MAP[] =
|
||||
{
|
||||
#include "string_map_ec_error.inc"
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
return FindString(STRING_MAP, err);
|
||||
}
|
||||
|
||||
static const char*
|
||||
GetECOperationString(ECOperation op)
|
||||
{
|
||||
static const StringMap STRING_MAP[] =
|
||||
{
|
||||
#include "string_map_ec_op.inc"
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
return FindString(STRING_MAP, op);
|
||||
}
|
||||
|
||||
static const char*
|
||||
GetECOpPhaseString(ECOpPhase phase)
|
||||
{
|
||||
static const StringMap STRING_MAP[] =
|
||||
{
|
||||
#include "string_map_ec_phase.inc"
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
return FindString(STRING_MAP, phase);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char*
|
||||
GetOSTWLRegionString(u8 x)
|
||||
{
|
||||
static const StringMap STRING_MAP[] =
|
||||
{
|
||||
{ OS_TWL_REGION_JAPAN, "japan" },
|
||||
{ OS_TWL_REGION_AMERICA, "america" },
|
||||
{ OS_TWL_REGION_EUROPE, "europe" },
|
||||
{ OS_TWL_REGION_AUSTRALIA, "australia" },
|
||||
{ OS_TWL_REGION_CHINA, "china" },
|
||||
{ OS_TWL_REGION_KOREA, "korea" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
return FindString(STRING_MAP, x);
|
||||
}
|
||||
|
||||
|
||||
void SetupUserInfo(void)
|
||||
{
|
||||
BOOL bSuccess;
|
||||
BOOL bModified = FALSE;
|
||||
void* pWork;
|
||||
|
||||
// LCFG_ReadTWLSettings を行う前に LCFG_ReadHWSecureInfo が必要
|
||||
{
|
||||
bSuccess = LCFG_ReadHWSecureInfo();
|
||||
SDK_ASSERT(bSuccess);
|
||||
}
|
||||
|
||||
// 設定の読み込み
|
||||
{
|
||||
pWork = Alloc(LCFG_READ_TEMP);
|
||||
SDK_POINTER_ASSERT(pWork);
|
||||
|
||||
bSuccess = LCFG_ReadTWLSettings(reinterpret_cast<u8 (*)[LCFG_READ_TEMP]>(pWork));
|
||||
SDK_ASSERT(bSuccess);
|
||||
|
||||
Free(pWork);
|
||||
}
|
||||
|
||||
{
|
||||
// ニックネームが空なら適当に設定
|
||||
if( *LCFG_TSD_GetNicknamePtr() == L'\0' )
|
||||
{
|
||||
LCFG_TSD_SetNickname(reinterpret_cast<const u16*>(L"ecdl"));
|
||||
bModified = TRUE;
|
||||
}
|
||||
|
||||
// 国が選択されていないなら適当に設定
|
||||
if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED )
|
||||
{
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN);
|
||||
bModified = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// 設定が変更されているなら書き出す
|
||||
if( bModified )
|
||||
{
|
||||
pWork = Alloc(LCFG_WRITE_TEMP);
|
||||
SDK_POINTER_ASSERT(pWork);
|
||||
|
||||
bSuccess = LCFG_WriteTWLSettings(reinterpret_cast<u8 (*)[LCFG_WRITE_TEMP]>(pWork));
|
||||
SDK_ASSERT(bSuccess);
|
||||
|
||||
Free(pWork);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupVerData(void)
|
||||
{
|
||||
BOOL bSuccess;
|
||||
|
||||
void* pWork = Alloc(NA_VERSION_DATA_WORK_SIZE);
|
||||
SDK_POINTER_ASSERT(pWork);
|
||||
|
||||
bSuccess = NA_LoadVersionDataArchive(pWork, NA_VERSION_DATA_WORK_SIZE);
|
||||
|
||||
SDK_ASSERT(bSuccess);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrintDeviceInfo(void)
|
||||
{
|
||||
ESId deviceId;
|
||||
u8 region;
|
||||
u32 launcherInitialCode;
|
||||
const u8* pSerial;
|
||||
const u8* pMovable;
|
||||
u32 movableLen1;
|
||||
u32 movableLen2;
|
||||
u64 fuseId;
|
||||
char bmsDeviceId[32];
|
||||
|
||||
LCFG_ReadHWNormalInfo();
|
||||
LCFG_ReadHWSecureInfo();
|
||||
|
||||
// region
|
||||
region = LCFG_THW_GetRegion();
|
||||
|
||||
// launcher initial code
|
||||
LCFG_THW_GetLauncherTitleID_Lo(reinterpret_cast<u8*>(&launcherInitialCode));
|
||||
|
||||
// ES Device ID
|
||||
ES_GetDeviceId(&deviceId);
|
||||
snprintf(bmsDeviceId, sizeof(bmsDeviceId), "%lld", ((0x3ull << 32) | deviceId));
|
||||
|
||||
// serial
|
||||
pSerial = LCFG_THW_GetSerialNoPtr();
|
||||
|
||||
// movable id
|
||||
pMovable = LCFG_THW_GetMovableUniqueIDPtr();
|
||||
movableLen1 = LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN / 2;
|
||||
movableLen2 = LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN - movableLen1;
|
||||
|
||||
// fuse id
|
||||
fuseId = SCFG_ReadFuseData();
|
||||
|
||||
OS_TPrintf("Region: %-10s %08X\n", GetOSTWLRegionString(region), launcherInitialCode);
|
||||
OS_TPrintf("DeviceID: %08X %u\n", deviceId, deviceId);
|
||||
OS_TPrintf(" %s\n", bmsDeviceId);
|
||||
OS_TPrintf("Serial: %s\n", pSerial);
|
||||
OS_TPrintf("MovableID: "); PrintBytes(pMovable, movableLen1); OS_TPrintf("\n");
|
||||
OS_TPrintf(" "); PrintBytes(pMovable + movableLen1, movableLen2); OS_TPrintf("\n");
|
||||
OS_TPrintf("FuseID: %08X%08X\n", static_cast<u32>(fuseId >> 32), static_cast<u32>(fuseId));
|
||||
}
|
||||
|
||||
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
NAMTitleId tid;
|
||||
|
||||
// OS_TPrintf("%s %d num=%d\n",__FUNCTION__,__LINE__,numTitleIds);
|
||||
|
||||
for( u32 i = 0; i < numTitleIds; i++ )
|
||||
{
|
||||
tid = pTitleIds[i];
|
||||
// OS_TPrintf("%s %d 0x%016X\n",__FUNCTION__,__LINE__,(u64)tid);
|
||||
NAM_SetupTitleDataFile(tid);
|
||||
//OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteECDirectory(void)
|
||||
{
|
||||
char buf[64];
|
||||
OSTitleId tid = OS_GetTitleId();
|
||||
|
||||
STD_TSNPrintf(buf, sizeof(buf), "nand:/title/%08x/%08x",
|
||||
(u32)(tid >> 32), (u32)(tid >> 0) );
|
||||
|
||||
FS_DeleteDirectoryAuto(buf);
|
||||
}
|
||||
|
||||
void SetupShopTitleId(void)
|
||||
{
|
||||
*(u64 *)(HW_TWL_ROM_HEADER_BUF + 0x230) = 0x00030015484E4641ull;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SetupNSSL(void)
|
||||
{
|
||||
NSSLConfig conf;
|
||||
|
||||
conf.maxId = 8;
|
||||
conf.alloc = AllocForNSSL;
|
||||
conf.free = FreeForNSSL;
|
||||
conf.realloc = ReallocForNSSL;
|
||||
conf.fixedHeapSize = 0;
|
||||
NSSL_Init(&conf);
|
||||
}
|
||||
|
||||
BOOL SetupNHTTP(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = NHTTPStartup(AllocForNHTTP, FreeForNHTTP, 18);
|
||||
NHTTP_SetBuiltinRootCAAsDefault(NSSL_ROOTCA_NINTENDO_2);
|
||||
|
||||
if (rv != NHTTP_ERROR_NONE)
|
||||
{
|
||||
OS_TPrintf("Failed to start NHTTP, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
GetDeviceCode(char *deviceCode, u32 bufSize)
|
||||
{
|
||||
u64 eFuseData;
|
||||
u32 i;
|
||||
u8 digit;
|
||||
|
||||
/* Fake the device code, seeded from the eFuse data */
|
||||
SCFG_Init();
|
||||
eFuseData = SCFG_ReadFuseData();
|
||||
|
||||
for (i = 0; i < (bufSize - 1); i++) {
|
||||
digit = (u8) (eFuseData % 10);
|
||||
deviceCode[i] = (char) (digit + 48);
|
||||
eFuseData /= 10;
|
||||
}
|
||||
|
||||
deviceCode[bufSize - 1] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
Dummy_WWW_AddJSPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL
|
||||
LoadCert(void** ppCert, u32* pSize, const char* name)
|
||||
{
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
s32 readSize;
|
||||
s32 result;
|
||||
char path[64];
|
||||
|
||||
void* pCert;
|
||||
u32 certSize;
|
||||
|
||||
FS_InitFile(&f);
|
||||
|
||||
STD_TSNPrintf(path, sizeof(path), "verdata:/%s", name);
|
||||
|
||||
bSuccess = FS_OpenFile(&f, path);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("Cannot open %s\n", path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
certSize = FS_GetFileLength(&f);
|
||||
pCert = OS_Alloc(certSize);
|
||||
if ( pCert == NULL )
|
||||
{
|
||||
OS_TPrintf("Cannot allocate work memroy\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
readSize = FS_ReadFile(&f, pCert, static_cast<s32>(certSize));
|
||||
if( readSize != certSize )
|
||||
{
|
||||
OS_TPrintf("fail to read file\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FS_CloseFile(&f);
|
||||
|
||||
result = NA_DecodeVersionData(pCert, certSize, pCert, certSize);
|
||||
if( result <= 0 )
|
||||
{
|
||||
OS_TPrintf("fail to decode version info %d\n", result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*ppCert = pCert;
|
||||
*pSize = certSize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL SetupEC(void)
|
||||
{
|
||||
static u32 logLevel, clientCertSize, clientKeySize;
|
||||
static char deviceCode[17];
|
||||
|
||||
ECError rv = EC_ERROR_OK;
|
||||
void* pClientCert;
|
||||
void* pClientKey;
|
||||
|
||||
// Initialize the EC library
|
||||
|
||||
logLevel = EC_LOG_FINE;
|
||||
// logLevel = EC_LOG_NONE;
|
||||
|
||||
LoadCert(&pClientCert, &clientCertSize, ".twl-nup-cert.der");
|
||||
LoadCert(&pClientKey, &clientKeySize, ".twl-nup-prvkey.der");
|
||||
GetDeviceCode(deviceCode, sizeof(deviceCode));
|
||||
|
||||
ECNameValue initArgs[] =
|
||||
{
|
||||
{ EC_ALLOC, &AllocForEC },
|
||||
{ EC_FREE, &FreeForEC },
|
||||
{ EC_LOG_LEVEL, &logLevel },
|
||||
{ EC_CLIENT_CERT, pClientCert },
|
||||
{ EC_CLIENT_CERT_SIZE, &clientCertSize },
|
||||
{ EC_CLIENT_KEY, pClientKey },
|
||||
{ EC_CLIENT_KEY_SIZE, &clientKeySize },
|
||||
{ EC_DEVICE_CODE, deviceCode },
|
||||
{ EC_ADD_JS_PLUGIN_CALLBACK, &Dummy_WWW_AddJSPlugin },
|
||||
};
|
||||
const u32 nInitArgs = sizeof(initArgs) / sizeof(initArgs[0]);
|
||||
|
||||
rv = EC_Init(initArgs, nInitArgs);
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to initialize EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to initialize EC, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rv = EC_SetWebSvcUrls( "https://ecs.t.shop.nintendowifi.net/ecs/services/ECommerceSOAP",
|
||||
"https://ias.t.shop.nintendowifi.net/ias/services/IdentityAuthenticationSOAP",
|
||||
"https://cas.t.shop.nintendowifi.net/cas/services/CatalogingSOAP" );
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetWebSvcUrls, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to EC_SetWebSvcUrls, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rv = EC_SetContentUrls( "http://ccs.t.shop.nintendowifi.net/ccs/download",
|
||||
"http://ccs.t.shop.nintendowifi.net/ccs/download" );
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetContentUrls, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to EC_SetContentUrls, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WaitEC(ECOpId opId)
|
||||
{
|
||||
ECError result;
|
||||
ECProgress progress;
|
||||
ECProgress progress_prev;
|
||||
|
||||
if( opId < 0 )
|
||||
{
|
||||
OS_TPrintf("error %d %s\n", opId, GetECErrorString(opId));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MI_CpuClear(&progress_prev, sizeof(progress_prev));
|
||||
|
||||
for(;;)
|
||||
{
|
||||
result = EC_GetProgress(opId, &progress);
|
||||
if( (result != EC_ERROR_OK) && (result != EC_ERROR_NOT_DONE) )
|
||||
{
|
||||
if( result == EC_ERROR_NOT_ACTIVE )
|
||||
{
|
||||
OS_TPrintf("opId=%d\n", opId);
|
||||
}
|
||||
OS_TPrintf("Failed to EC_GetProgress, result=%d %s\n", result, GetECErrorString(result));
|
||||
mprintf("EC_GetProgress failed %d\n %s\n", result, GetECErrorString(result));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//#ifdef SDK_DEBUG
|
||||
if( MI_CpuComp8(&progress_prev, &progress, sizeof(progress)) != 0 )
|
||||
{
|
||||
OS_TPrintf("---------\n");
|
||||
OS_TPrintf("progress report\n");
|
||||
OS_TPrintf(" status %5d %s\n", progress.status, GetECErrorString(progress.status));
|
||||
OS_TPrintf(" operation %5d %s\n", progress.operation, GetECOperationString(progress.operation));
|
||||
OS_TPrintf(" phase %5d %s\n", progress.phase, GetECOpPhaseString(progress.phase));
|
||||
OS_TPrintf(" isCancelRequested %5d\n", progress.isCancelRequested);
|
||||
OS_TPrintf(" totalSize %5d\n", progress.totalSize);
|
||||
OS_TPrintf(" downloadedSize %5d\n", progress.downloadedSize);
|
||||
OS_TPrintf(" errCode %5d\n", progress.errCode);
|
||||
OS_TPrintf(" errInfo %s\n", progress.errInfo);
|
||||
progress_prev = progress;
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
if( progress.phase == EC_PHASE_Done )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
OS_Sleep(300);
|
||||
}
|
||||
return TRUE;;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
char CheckRegistration()
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
ECDeviceInfo di;
|
||||
|
||||
ECDL_LOG("check registeration");
|
||||
progress = EC_CheckRegistration();
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return '\0'; // 微妙・・
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
BOOL GetChallenge(char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
|
||||
ECDL_LOG("get challenge");
|
||||
progress = EC_SendChallengeReq();
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ecError = EC_GetChallengeResp(challenge);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SyncRegistration(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync registration");
|
||||
progress = EC_SyncRegistration(challenge);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Register(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("register");
|
||||
progress = EC_Register(challenge, NULL, NULL);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Transfer(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("transfer");
|
||||
progress = EC_Transfer(challenge);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SyncTickets()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync tickets");
|
||||
progress = EC_SyncTickets(EC_SYNC_TYPE_IMPORT_ALL);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("download");
|
||||
for( u32 i = 0; i < numTitleIds; i++ )
|
||||
{
|
||||
NAMTitleId tid = pTitleIds[i];
|
||||
progress = EC_DownloadTitle(tid, EC_DT_UPDATE_REQUIRED_CONTENTS);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
char challenge[EC_CHALLENGE_BUF_SIZE];
|
||||
char status;
|
||||
|
||||
// mprintf("-CheckRegistration..\n");
|
||||
status = CheckRegistration();
|
||||
// U unregistered
|
||||
// R registered
|
||||
// P pending
|
||||
// T transfered
|
||||
#if 0
|
||||
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 );
|
||||
#else
|
||||
if( status == 'U') {
|
||||
mprintf(" acount not transfered yet.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if( status == 'R') {
|
||||
mprintf(" already registered. please delete acount.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if( (status != 'P') && (status != 'T') ) {
|
||||
mprintf(" invalid registration status '%c'\n", status );
|
||||
return FALSE;
|
||||
}
|
||||
// mprintf(" succeeded.");
|
||||
#endif
|
||||
|
||||
mprintf("-get challenge1 ");
|
||||
if( FALSE == GetChallenge(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-transfer ");
|
||||
if( FALSE == Transfer(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
mprintf("-get challenge2 ");
|
||||
if( FALSE == GetChallenge(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-sync registration ");
|
||||
if( FALSE == SyncRegistration(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
mprintf("-sync tickets ");
|
||||
if( FALSE == SyncTickets() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-download titles ");
|
||||
if( FALSE == DownloadTitles(pTitleIds, numTitleIds) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL KPSClient()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
OS_TPrintf("generate key pair\n");
|
||||
mprintf("-generate key pair ");
|
||||
progress = EC_GenerateKeyPair();
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
OS_TPrintf("confirm key pair\n");
|
||||
mprintf("-confirm key pair ");
|
||||
progress = EC_ConfirmKeyPair();
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL hatamotolib_main(u64 *title_id_buf, u32 num_title)
|
||||
{
|
||||
ECError rv = EC_ERROR_OK;
|
||||
|
||||
// 不要:デバイス情報の表示
|
||||
PrintDeviceInfo();
|
||||
|
||||
OS_TPrintf("--------------------------------\n");
|
||||
|
||||
// setup
|
||||
// 必須:タイトル ID の偽装
|
||||
SetupShopTitleId();
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
SetupUserInfo();
|
||||
|
||||
// 必須:バージョンデータのマウント
|
||||
SetupVerData();
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
/******** ネットワークにつないだ *************/
|
||||
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
mprintf("-start NHTTP ");
|
||||
SetupNSSL();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
/******** NHTTP & NSSLにつないだ *************/
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
mprintf("-start EC ");
|
||||
if( FALSE == SetupEC() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// 必須:デバイス証明書の発行
|
||||
if( FALSE == KPSClient() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 必須:指定タイトルをダウンロード
|
||||
// ダウンロードすべきタイトルの指定
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x0003000434616141ull,
|
||||
// 0x0003000434616241ull,
|
||||
// 0x000300043461644aull,
|
||||
// 0x0003000434616741ull,
|
||||
// 0x0003000434616a41ull,
|
||||
// 0x0003000434617441ull,
|
||||
// 0x0003000434626141ull,
|
||||
// 0x0003000434626341ull,
|
||||
// 0x0003000434626641ull,
|
||||
// 0x0003000434626841ull,
|
||||
// 0x0003000434626941ull,
|
||||
// 0x0003000434636341ull,
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x00030004346b6241ull,
|
||||
// 0x00030004346b6341ull,
|
||||
|
||||
if( FALSE == ECDownload((NAMTitleId *)title_id_buf , num_title) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 不要:セーブデータ領域を作成
|
||||
// NAM_Init を忘れてた
|
||||
SetupTitlesDataFile((NAMTitleId *)title_id_buf , num_title);
|
||||
|
||||
if( title_id_buf != NULL && num_title != 0 ) {
|
||||
OS_Free( title_id_buf );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
// EC の終了処理
|
||||
mprintf("-EC_Shutdown.. ");
|
||||
rv = EC_Shutdown();
|
||||
// SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
|
||||
|
||||
|
||||
// ネットワークからの切断
|
||||
OS_TPrintf("Disconnecting ..\n");
|
||||
mprintf("-Disconnecting... ");
|
||||
|
||||
NHTTP_Cleanup();
|
||||
// int NSSL_Finish( void )
|
||||
NSSL_Finish();
|
||||
|
||||
|
||||
NcFinish();
|
||||
// つなぎっぱなしにするならいらない。
|
||||
TerminateWcmControl();
|
||||
|
||||
OS_TPrintf("Done.\n");
|
||||
mprintf("Done.\n");
|
||||
|
||||
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する
|
||||
DeleteECDirectory();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -257,6 +257,7 @@ void NcStart(const char* apClass)
|
||||
{
|
||||
int counter = 0;
|
||||
s32 wcm_phase;
|
||||
int i;
|
||||
|
||||
SiteDefs_Init();
|
||||
|
||||
@ -312,6 +313,16 @@ void NcStart(const char* apClass)
|
||||
#define WCM_PHASE_TERMINATING 13 // WCM ライブラリの強制停止シーケンス中
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
mprintf("\r-LINK UP. ");
|
||||
for( i = 0 ; i < counter ; i++ ) {
|
||||
m_putchar(tc[0], '.');
|
||||
}
|
||||
for( ; i < 6 ; i++ ) {
|
||||
m_putchar(tc[0], ' ');
|
||||
}
|
||||
i %= 6;
|
||||
#else
|
||||
switch( counter ) {
|
||||
case 0:
|
||||
mprintf("\r-LINK UP. ");
|
||||
@ -333,7 +344,8 @@ void NcStart(const char* apClass)
|
||||
counter = -1;
|
||||
break;
|
||||
}
|
||||
OS_Sleep(100);
|
||||
#endif
|
||||
OS_Sleep(200);
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ 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 \
|
||||
hatamotolib.cpp \
|
||||
sitedefs.c wcm_control.c netconnect.c mywlan.c \
|
||||
nuc.c nuc_error_msg.c stream.c myfilename.c
|
||||
mynuc.c nuc_error_msg.c stream.c myfilename.c
|
||||
|
||||
TARGET_BIN = copy_dst.srl
|
||||
ROM_SPEC = copy_dst.rsf
|
||||
@ -40,6 +40,7 @@ LINCLUDES = $(TWLSDK_ROOT)/build/libraries/lcfg/ARM9.TWL/include ../c
|
||||
$(ES_ROOT)/twl/include $(ES_ROOT)/common/lib/ec/include
|
||||
|
||||
LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE) ../wifilib
|
||||
# LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE)
|
||||
|
||||
|
||||
LLIBRARIES += libecx$(TWL_LIBSUFFIX).a \
|
||||
|
||||
@ -532,10 +532,8 @@ BOOL WaitEC(ECOpId opId)
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
static char CheckRegistration()
|
||||
{
|
||||
char CheckRegistration()
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
ECDeviceInfo di;
|
||||
@ -584,10 +582,10 @@ namespace
|
||||
#endif
|
||||
|
||||
return di.registrationStatus[0];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL GetChallenge(char* challenge)
|
||||
{
|
||||
static BOOL GetChallenge(char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
|
||||
@ -600,10 +598,10 @@ namespace
|
||||
ecError = EC_GetChallengeResp(challenge);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL SyncRegistration(const char* challenge)
|
||||
{
|
||||
static BOOL SyncRegistration(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync registration");
|
||||
@ -612,10 +610,10 @@ namespace
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Register(const char* challenge)
|
||||
{
|
||||
static BOOL Register(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("register");
|
||||
@ -624,10 +622,10 @@ namespace
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Transfer(const char* challenge)
|
||||
{
|
||||
static BOOL Transfer(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("transfer");
|
||||
@ -636,10 +634,10 @@ namespace
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL SyncTickets()
|
||||
{
|
||||
static BOOL SyncTickets()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync tickets");
|
||||
@ -648,10 +646,10 @@ namespace
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
static BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("download");
|
||||
@ -664,11 +662,8 @@ namespace
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
char challenge[EC_CHALLENGE_BUF_SIZE];
|
||||
@ -713,7 +708,6 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-transfer ");
|
||||
if( FALSE == Transfer(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
@ -767,7 +761,6 @@ BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-download titles ");
|
||||
if( FALSE == DownloadTitles(pTitleIds, numTitleIds) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
@ -824,136 +817,4 @@ BOOL KPSClient()
|
||||
}
|
||||
|
||||
|
||||
BOOL hatamotolib_main(u64 *title_id_buf, u32 num_title)
|
||||
{
|
||||
ECError rv = EC_ERROR_OK;
|
||||
|
||||
// 不要:デバイス情報の表示
|
||||
PrintDeviceInfo();
|
||||
|
||||
OS_TPrintf("--------------------------------\n");
|
||||
|
||||
// setup
|
||||
// 必須:タイトル ID の偽装
|
||||
SetupShopTitleId();
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
SetupUserInfo();
|
||||
|
||||
// 必須:バージョンデータのマウント
|
||||
SetupVerData();
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
/******** ネットワークにつないだ *************/
|
||||
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
mprintf("-start NHTTP ");
|
||||
SetupNSSL();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
/******** NHTTP & NSSLにつないだ *************/
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
mprintf("-start EC ");
|
||||
if( FALSE == SetupEC() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// 必須:デバイス証明書の発行
|
||||
if( FALSE == KPSClient() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 必須:指定タイトルをダウンロード
|
||||
// ダウンロードすべきタイトルの指定
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x0003000434616141ull,
|
||||
// 0x0003000434616241ull,
|
||||
// 0x000300043461644aull,
|
||||
// 0x0003000434616741ull,
|
||||
// 0x0003000434616a41ull,
|
||||
// 0x0003000434617441ull,
|
||||
// 0x0003000434626141ull,
|
||||
// 0x0003000434626341ull,
|
||||
// 0x0003000434626641ull,
|
||||
// 0x0003000434626841ull,
|
||||
// 0x0003000434626941ull,
|
||||
// 0x0003000434636341ull,
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x00030004346b6241ull,
|
||||
// 0x00030004346b6341ull,
|
||||
|
||||
if( FALSE == ECDownload((NAMTitleId *)title_id_buf , num_title) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 不要:セーブデータ領域を作成
|
||||
// NAM_Init を忘れてた
|
||||
SetupTitlesDataFile((NAMTitleId *)title_id_buf , num_title);
|
||||
|
||||
if( title_id_buf != NULL && num_title != 0 ) {
|
||||
OS_Free( title_id_buf );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
// EC の終了処理
|
||||
mprintf("-EC_Shutdown.. ");
|
||||
rv = EC_Shutdown();
|
||||
// SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
|
||||
|
||||
|
||||
// ネットワークからの切断
|
||||
OS_TPrintf("Disconnecting ..\n");
|
||||
mprintf("-Disconnecting... ");
|
||||
|
||||
NHTTP_Cleanup();
|
||||
// int NSSL_Finish( void )
|
||||
NSSL_Finish();
|
||||
|
||||
|
||||
NcFinish();
|
||||
// つなぎっぱなしにするならいらない。
|
||||
TerminateWcmControl();
|
||||
|
||||
OS_TPrintf("Done.\n");
|
||||
mprintf("Done.\n");
|
||||
|
||||
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する
|
||||
DeleteECDirectory();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
#include <twl/lcfg.h>
|
||||
#include <twl/na.h>
|
||||
#include <twl/nam.h>
|
||||
#include <NitroWiFi/nhttp.h>
|
||||
#include "nssl.h"
|
||||
|
||||
#include "font.h"
|
||||
#include "text.h"
|
||||
@ -32,16 +34,22 @@
|
||||
#include "ecdl.h"
|
||||
#include "mywlan.h"
|
||||
#include "mydata.h"
|
||||
#include "netconnect.h"
|
||||
#include "sitedefs.h"
|
||||
#include "wcm_control.h"
|
||||
#include "nuc.h"
|
||||
#include "mynuc.h"
|
||||
|
||||
#include "myfilename.h"
|
||||
#include "mfiler.h"
|
||||
|
||||
|
||||
//================================================================================
|
||||
|
||||
static FSEventHook sSDHook;
|
||||
static BOOL sd_card_flag = FALSE;
|
||||
|
||||
static u8 WorkForNA[NA_VERSION_DATA_WORK_SIZE];
|
||||
|
||||
static void SDEvents(void *userdata, FSEvent event, void *arg)
|
||||
{
|
||||
@ -49,14 +57,21 @@ static void SDEvents(void *userdata, FSEvent event, void *arg)
|
||||
(void)arg;
|
||||
if (event == FS_EVENT_MEDIA_REMOVED) {
|
||||
sd_card_flag = FALSE;
|
||||
mprintf("sdmc:removed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("SD card:removed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
}
|
||||
else if (event == FS_EVENT_MEDIA_INSERTED) {
|
||||
sd_card_flag = TRUE;
|
||||
mprintf("sdmc:inserted!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("SD card:inserted!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
mprintf("Push A button to start\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static MyData mydata;
|
||||
|
||||
static int vram_num_main = 1;
|
||||
@ -73,6 +88,7 @@ static LCFGTWLHWSecureInfo hws_info;
|
||||
static OSThread MyThread;
|
||||
static u64 MyStack[MY_STACK_SIZE / sizeof(u64)];
|
||||
static void MyThreadProc(void *arg);
|
||||
static void MyThreadProcNuc(void *arg);
|
||||
|
||||
static OSMessage MyMesgBuffer[1];
|
||||
static OSMessageQueue MyMesgQueue;
|
||||
@ -88,6 +104,18 @@ static void init_my_thread(void)
|
||||
OS_WakeupThreadDirect(&MyThread);
|
||||
}
|
||||
|
||||
static void init_my_thread_nuc(void)
|
||||
{
|
||||
|
||||
OS_InitMessageQueue(&MyMesgQueue, &MyMesgBuffer[0], 1);
|
||||
|
||||
OS_CreateThread(&MyThread, MyThreadProcNuc,
|
||||
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);
|
||||
@ -102,7 +130,7 @@ static BOOL RestoreFromSDCard1(void)
|
||||
したがって MyData mydata にはデータが入っている。
|
||||
*/
|
||||
// static BOOL SDBackupToSDCard8(void)
|
||||
mprintf("RTC restore ");
|
||||
mprintf("RTC data restore ");
|
||||
if( RTC_RESULT_SUCCESS != RTC_SetDate( &(mydata.rtc_date) ) ) {
|
||||
flag = FALSE;
|
||||
}
|
||||
@ -224,6 +252,28 @@ static BOOL RestoreFromSDCard6(void)
|
||||
}
|
||||
|
||||
|
||||
static BOOL RestoreFromSDCard8(void)
|
||||
{
|
||||
|
||||
// static BOOL SDBackupToSDCard6(void)
|
||||
mprintf("App. save data restore ");
|
||||
if( TRUE == RestoreDirEntryList( MyFile_GetAppDataListFileName() , MyFile_GetAppDataRestoreLogFileName() )) {
|
||||
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)
|
||||
{
|
||||
/* ユーザーデータ書き込みモード */
|
||||
@ -278,59 +328,172 @@ static BOOL LoadWlanConfig(void)
|
||||
|
||||
static BOOL RestoreFromSDCard7(void)
|
||||
{
|
||||
u64 *title_id_buf_ptr = NULL;
|
||||
int title_id_count = 0;
|
||||
u64 *title_id_buf_ptr;
|
||||
int title_id_count;
|
||||
int i;
|
||||
ECError rv;
|
||||
|
||||
title_id_buf_ptr = NULL;
|
||||
title_id_count = 0;
|
||||
rv = EC_ERROR_OK;
|
||||
|
||||
/* hws_info.serialNoは戻せない */
|
||||
/* */
|
||||
// static BOOL SDBackupToSDCard7(void)
|
||||
|
||||
// for DEBUG
|
||||
mydata.shop_record_flag = TRUE;
|
||||
// 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");
|
||||
OS_TPrintf("no shop record\n");
|
||||
mprintf(" (--no shop record--)\n");
|
||||
}
|
||||
else {
|
||||
mprintf("User title list restore ");
|
||||
OS_TPrintf("User title list restore \n");
|
||||
mprintf("Connect to the internet\n");
|
||||
|
||||
mprintf("-user title list loading.. ");
|
||||
OS_TPrintf("user title list loading\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"); }
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
for( i = 0; i < title_id_count ; i++ ) {
|
||||
u64 tid = *(title_id_buf_ptr + i );
|
||||
mprintf(" id %02d %08X %08X\n", i,(u32)(tid >> 32), (u32)tid);
|
||||
}
|
||||
}
|
||||
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.. ");
|
||||
// mprintf(" ");
|
||||
mprintf("-wireless AP conf. loading.. ");
|
||||
if( TRUE == LoadWlanConfig() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
|
||||
// nuc_main(); /* ネットワーク接続 */
|
||||
hatamotolib_main(); /* ネットワーク接続 */
|
||||
/* nand:/ticketはチケット同期でダウンロード */
|
||||
// 不要:デバイス情報の表示
|
||||
PrintDeviceInfo();
|
||||
|
||||
OS_TPrintf("--------------------------------\n");
|
||||
|
||||
// setup
|
||||
// 必須:タイトル ID の偽装
|
||||
SetupShopTitleId();
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
SetupUserInfo();
|
||||
|
||||
// 必須:バージョンデータのマウント
|
||||
SetupVerData();
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
/******** ネットワークにつないだ *************/
|
||||
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
mprintf("-start NHTTP ");
|
||||
SetupNSSL();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
/******** NHTTP & NSSLにつないだ *************/
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
mprintf("-start EC ");
|
||||
if( FALSE == SetupEC() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// 必須:デバイス証明書の発行
|
||||
if( FALSE == KPSClient() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( FALSE == ECDownload((NAMTitleId *)title_id_buf_ptr , (u32)title_id_count) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 不要:セーブデータ領域を作成
|
||||
// NAM_Init を忘れてた
|
||||
SetupTitlesDataFile((NAMTitleId *)title_id_buf_ptr , (u32)title_id_count);
|
||||
|
||||
if( title_id_buf_ptr != NULL && title_id_count != 0 ) {
|
||||
OS_Free( title_id_buf_ptr );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
// EC の終了処理
|
||||
mprintf("-EC_Shutdown.. ");
|
||||
rv = EC_Shutdown();
|
||||
// SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
|
||||
// ネットワークからの切断
|
||||
OS_TPrintf("disconnecting ..\n");
|
||||
mprintf("-disconnecting... ");
|
||||
|
||||
NHTTP_Cleanup();
|
||||
NSSL_Finish();
|
||||
|
||||
NcFinish();
|
||||
//OS_TPrintf("NSSL_Finish() return = %d\n", NSSL_Finish());
|
||||
|
||||
TerminateWcmControl();
|
||||
|
||||
OS_TPrintf("done.\n");
|
||||
mprintf("done.\n");
|
||||
|
||||
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する
|
||||
DeleteECDirectory();
|
||||
|
||||
}
|
||||
else {
|
||||
/* mprintf("-Wireless AP conf. loading.. "); */
|
||||
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;
|
||||
@ -341,15 +504,14 @@ typedef BOOL (*function_ptr)(void);
|
||||
|
||||
static function_ptr function_table[] =
|
||||
{
|
||||
#if 1
|
||||
RestoreFromSDCard1,
|
||||
RestoreFromSDCard2,
|
||||
RestoreFromSDCard3,
|
||||
RestoreFromSDCard4,
|
||||
RestoreFromSDCard5,
|
||||
RestoreFromSDCard6,
|
||||
#endif
|
||||
RestoreFromSDCard7
|
||||
RestoreFromSDCard7,
|
||||
RestoreFromSDCard8
|
||||
};
|
||||
|
||||
static int function_table_max = sizeof(function_table) / sizeof(*function_table);
|
||||
@ -360,22 +522,101 @@ static void MyThreadProc(void *arg)
|
||||
{
|
||||
#pragma unused(arg)
|
||||
OSMessage message;
|
||||
BOOL flag;
|
||||
while( 1 ) {
|
||||
(void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK);
|
||||
|
||||
flag = TRUE;
|
||||
/* MydataLoadはすでにやっているのでいらない。 */
|
||||
for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) {
|
||||
(void)(function_table[function_counter])();
|
||||
if( FALSE == (function_table[function_counter])() ) {
|
||||
flag = FALSE;
|
||||
}
|
||||
}
|
||||
mprintf("\n");
|
||||
if( flag == TRUE ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("Restore completed.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("Restore failed.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
mprintf("\n");
|
||||
/* 全部成功したらフォルダを消す */
|
||||
if( TRUE == stream_is_play1_end() ) {
|
||||
OS_TPrintf("stream play\n");
|
||||
stream_play1();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void MyThreadProcNuc(void *arg)
|
||||
{
|
||||
#pragma unused(arg)
|
||||
OSMessage message;
|
||||
while( 1 ) {
|
||||
(void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK);
|
||||
mprintf("-Wireless AP conf. loading.. ");
|
||||
if( TRUE == LoadWlanConfig() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
/* NSSL_Init()呼んではダメ! */
|
||||
if( TRUE == my_numc_proc() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
OS_TPrintf("Network Update Completed!\n");
|
||||
mprintf("Network Update Completed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
NcFinish();
|
||||
TerminateWcmControl();
|
||||
|
||||
if( TRUE == stream_is_play1_end() ) {
|
||||
stream_play1();
|
||||
}
|
||||
/* ハードウェアリセットを行い、自分自身を起動します。 */
|
||||
OS_Sleep(30000);
|
||||
OS_RebootSystem();
|
||||
}
|
||||
else {
|
||||
// NUC_Init() failed, error code=34416 はどこかでNSSL_Initを呼んでるので消す。
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("network update failed!\n");
|
||||
OS_TPrintf("Network Update failed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* mprintf("-Wireless AP conf. loading.. "); */
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *AllocForNAM(size_t size)
|
||||
{
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
void* p = OS_Alloc(size);
|
||||
OS_RestoreInterrupts(old);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void FreeForNAM(void* ptr)
|
||||
{
|
||||
if( ptr != NULL )
|
||||
{
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
OS_Free(ptr);
|
||||
OS_RestoreInterrupts(old);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TwlMain(void)
|
||||
{
|
||||
void* newArenaLo;
|
||||
@ -390,6 +631,7 @@ void TwlMain(void)
|
||||
int n;
|
||||
u8 macAddress[6];
|
||||
MY_ENTRY_LIST *mfiler_list_head = NULL;
|
||||
BOOL reboot_flag;
|
||||
|
||||
OS_Init();
|
||||
OS_InitThread();
|
||||
@ -430,59 +672,135 @@ void TwlMain(void)
|
||||
SND_Init();
|
||||
stream_main();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
0 -> black
|
||||
1 -> red
|
||||
2 -> green
|
||||
3 -> blue
|
||||
4 -> yellow
|
||||
5 -> purple
|
||||
6 -> sky blue
|
||||
7 -> red
|
||||
8 -> green
|
||||
9 -> blue
|
||||
0xA -> yellow
|
||||
0xB -> purple
|
||||
0xC -> sky blue
|
||||
0xD -> white
|
||||
0xE -> white
|
||||
0xF -> white
|
||||
|
||||
*/
|
||||
// m_set_palette(tc[0], 0xF);
|
||||
|
||||
|
||||
|
||||
// 必須;SEA の初期化
|
||||
SEA_Init();
|
||||
|
||||
reboot_flag = OS_IsRebooted();
|
||||
|
||||
/* デバッグのために強制的に */
|
||||
// reboot_flag = TRUE;
|
||||
|
||||
if( FALSE == reboot_flag ) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL);
|
||||
|
||||
|
||||
/* 最初にネットワークアップデート。 */
|
||||
// NSSL_Init(&s_sslConfig);
|
||||
// SetupNSSL();
|
||||
if (!NA_LoadVersionDataArchive(WorkForNA, NA_VERSION_DATA_WORK_SIZE)) {
|
||||
OS_TPrintf("NA load error\n");
|
||||
mprintf("NA load error\n");
|
||||
}
|
||||
else {
|
||||
if (!NUC_LoadCert()) {
|
||||
// WRAMにロード
|
||||
OS_TPrintf("Client cert load error\n");
|
||||
mprintf("Client cert load error\n");
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
OS_TPrintf("Client cert load success\n");
|
||||
mprintf("Client cert load success\n");
|
||||
}
|
||||
#endif
|
||||
(void)NA_UnloadVersionDataArchive();
|
||||
}
|
||||
init_my_thread_nuc();
|
||||
|
||||
|
||||
if( sd_card_flag == TRUE ) {
|
||||
start_my_thread();
|
||||
}
|
||||
|
||||
while( 1 ) {
|
||||
Gfx_Render( vram_num_main , vram_num_sub );
|
||||
OS_WaitVBlankIntr();
|
||||
(void)RTC_GetDate( &rtc_date );
|
||||
(void)RTC_GetTime( &rtc_time );
|
||||
keyData = m_get_key_trigger();
|
||||
|
||||
// ARM7コマンド応答受信
|
||||
while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL)
|
||||
{
|
||||
}
|
||||
// コマンドフラッシュ(フラッシュして即座に実行を要求)
|
||||
(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 ) {
|
||||
start_my_thread();
|
||||
}
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_B ) {
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_START ) {
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_SELECT ) {
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_X ) {
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_Y ) {
|
||||
}
|
||||
else if ( keyData & PAD_KEY_UP ) {
|
||||
}
|
||||
mfprintf(tc[1], "\f%4d/%02d/%02d %02d:%02d:%02d\n\n",
|
||||
rtc_date.year + 2000, rtc_date.month , rtc_date.day,
|
||||
rtc_time.hour , rtc_time.minute , rtc_time.second );
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 不要:NAM の初期化
|
||||
// NAM_Init(&AllocForNAM, &FreeForNAM);
|
||||
NAM_Init(&AllocForNAM, &FreeForNAM);
|
||||
|
||||
// 必須:ES の初期化
|
||||
ES_InitLib();
|
||||
|
||||
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("rtc date read error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("rtc time read error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// mprintf("HW Normal Info. read ");
|
||||
mprintf("Unique ID read ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("Unique ID:\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf("read error!.\n");
|
||||
m_set_palette(tc[0], 0xF);
|
||||
}
|
||||
else {
|
||||
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]);
|
||||
@ -498,45 +816,38 @@ void TwlMain(void)
|
||||
|
||||
|
||||
// mprintf("HW Secure Info. read ");
|
||||
mprintf("Serial No. read ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("Serial No. ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf("read error.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
mprintf(" %s\n", hws_info.serialNo);
|
||||
mprintf("%s\n", hws_info.serialNo);
|
||||
}
|
||||
mprintf("\n");
|
||||
|
||||
OS_GetMacAddress( macAddress );
|
||||
mprintf("MAC Address 0x");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("MAC add.(HEX):");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
for ( i = 0 ; i < 6 ; 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");
|
||||
mprintf("No SD card\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
}
|
||||
else {
|
||||
sd_card_flag = TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
mprintf("\n\n");
|
||||
mprintf( "function no.%d/%d\n", function_counter, function_table_max);
|
||||
mprintf("\n\n");
|
||||
#endif
|
||||
|
||||
|
||||
FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL);
|
||||
|
||||
init_my_thread();
|
||||
@ -582,7 +893,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. restore ");
|
||||
mprintf("Personal data. restore ");
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
@ -647,7 +958,7 @@ 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], "function no.%d/%d\n\n", function_counter, function_table_max);
|
||||
|
||||
// mfprintf(tc[1], "cwd = %s\n\n", MFILER_Get_CurrentDir());
|
||||
|
||||
@ -658,9 +969,34 @@ void TwlMain(void)
|
||||
loop_counter++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
OS_Terminate();
|
||||
}
|
||||
|
||||
//#define ENABLE_PROXY 1
|
||||
|
||||
#ifdef ENABLE_PROXY
|
||||
// DWC_GetProxySetting 関数で、接続している設定のproxy設定を格納する構造体
|
||||
typedef struct DWCstProxySetting // Proxy 設定情報
|
||||
{
|
||||
u16 authType; // Proxy 認証形式
|
||||
u16 port; // Proxy port
|
||||
u8 hostName [ 0x64 ]; // Proxy hostname
|
||||
u8 authId [ 0x20 ]; // proxy basic認証用 ID
|
||||
u8 authPass [ 0x20 ]; // proxy basic認証用 パスワード
|
||||
} DWCProxySetting;
|
||||
BOOL DWC_GetProxySetting( DWCProxySetting* proxy );
|
||||
BOOL DWC_GetProxySetting( DWCProxySetting* proxy )
|
||||
{
|
||||
MI_CpuClear8(proxy, sizeof(proxy));
|
||||
STD_StrCpy((char*)proxy->hostName, "proxy.testbox");
|
||||
proxy->port = 8080;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*====== End of main.c ======*/
|
||||
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
#ifndef _MFILER_H_
|
||||
#define _MFILER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _MY_ENTRY_LIST {
|
||||
struct _MY_ENTRY_LIST *prev;
|
||||
@ -9,7 +13,6 @@ typedef struct _MY_ENTRY_LIST {
|
||||
char src_path[ 512 ];
|
||||
} MY_ENTRY_LIST;
|
||||
|
||||
|
||||
void MFILER_CurrentDir_Init(void);
|
||||
char *MFILER_Get_CurrentDir(void);
|
||||
void MFILER_Change_CurrentDir(const char *path);
|
||||
@ -29,4 +32,9 @@ char *MFILER_GetCursorEntryPath(MY_ENTRY_LIST **headp);
|
||||
BOOL MFILER_Is_Cursor_Dir(MY_ENTRY_LIST **headp);
|
||||
BOOL MFILER_Is_Cursor_TextFile(MY_ENTRY_LIST **headp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _MFILER_H_ */
|
||||
|
||||
389
build/tools/sctools/copy_dst/src/mynuc.c
Normal file
389
build/tools/sctools/copy_dst/src/mynuc.c
Normal file
@ -0,0 +1,389 @@
|
||||
#include <twl.h>
|
||||
#include <twl/sea.h>
|
||||
#include <twl/na.h>
|
||||
// #include <TwlWiFi/nuc.h>
|
||||
|
||||
#include "netconnect.h"
|
||||
#include "sitedefs.h"
|
||||
#include "nuc.h"
|
||||
#include "nuc_error_msg.h"
|
||||
#include "mynuc.h"
|
||||
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
|
||||
#define STRING_ANIM_CNT 20
|
||||
|
||||
static volatile NetConnectState NetConnect = NET_CONNECT_NONE;
|
||||
|
||||
// state管理
|
||||
static struct
|
||||
{
|
||||
NucPhaseState state;
|
||||
u32 count;
|
||||
} TestState;
|
||||
|
||||
static inline void ChangeState(NucPhaseState state)
|
||||
{
|
||||
TestState.state = state;
|
||||
TestState.count = 0;
|
||||
}
|
||||
|
||||
// titleID 取得用
|
||||
static NUCTitleId TitleIds[NUC_MAX_TITLE_UPDATE_COUNT];
|
||||
static u32 TitleIdNum;
|
||||
|
||||
static u8 WorkForNA[NA_VERSION_DATA_WORK_SIZE];
|
||||
|
||||
static BOOL AllocFailTest = FALSE;
|
||||
|
||||
static void *alloc(u32 size, int align)
|
||||
{
|
||||
u32 *ptr = NULL, *realPtr = NULL;
|
||||
u32 realSize;
|
||||
OSIntrMode old;
|
||||
|
||||
old = OS_DisableInterrupts();
|
||||
|
||||
/* realSize is size plus alignment and header */
|
||||
if (align < 4)
|
||||
{
|
||||
align = 4;
|
||||
}
|
||||
realSize = size + align + 4;
|
||||
|
||||
realPtr = (u32 *) OS_Alloc(realSize);
|
||||
ptr = (u32 *)((((u32) realPtr) + 4 + align - 1) & ~(align - 1));
|
||||
|
||||
*((u32 *)(((u32)ptr) - 4)) = (u32) realPtr;
|
||||
(void)OS_RestoreInterrupts( old );
|
||||
|
||||
end:
|
||||
SDK_ASSERT(((u32)ptr & (align - 1)) == 0);
|
||||
return (void *) ptr;
|
||||
}
|
||||
|
||||
static void free(void *p)
|
||||
{
|
||||
u32 realPtr = *((u32 *)(((u32)p) - 4));
|
||||
OS_Free((void *) realPtr);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: InitNupLib
|
||||
Description: NUCライブラリを開始します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL InitNupLib()
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
char *error_msg[] = {
|
||||
"NUC_ERROR_NO_SPACE",
|
||||
"NUC_ERROR_CONNECT",
|
||||
"NUC_ERROR_INTERNET",
|
||||
"NUC_ERROR_UPDATE"
|
||||
};
|
||||
|
||||
ret = NUC_Init(alloc, free);
|
||||
|
||||
if (ret == FALSE) {
|
||||
// NUC_Init() failed, error code=34416
|
||||
OS_TPrintf("NUC_Init() failed, error code=%d\n", NUC_GetLastError());
|
||||
OS_TPrintf(" error type:%s\n", error_msg[ NUC_GetErrorType(NUC_GetLastError())] );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: StartNupCheck
|
||||
Description: ダウンロードリスト一覧の取得を開始します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL StartNupCheck(void)
|
||||
{
|
||||
BOOL ret;
|
||||
TitleIdNum = sizeof(TitleIds) / sizeof(TitleIds[0]);
|
||||
|
||||
ret = NUC_CheckAsync(TitleIds, &TitleIdNum);
|
||||
if (ret == FALSE)
|
||||
{
|
||||
OS_TPrintf("NUC_CheckAsync() failed, error code=%d\n", NUC_GetLastError());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: ProgressNupCheck
|
||||
Description: ダウンロードリスト一覧の取得状況を確認します
|
||||
*---------------------------------------------------------------------------*/
|
||||
NucStatus ProgressNupCheck(void)
|
||||
{
|
||||
u64 CurrentSize, TotalSize;
|
||||
NucStatus status;
|
||||
|
||||
NUC_GetProgress(&CurrentSize, &TotalSize, &status);
|
||||
if (status == NUC_STATUS_ERROR)
|
||||
{
|
||||
// NUC_GetProgress() failed in checking, error code=34303
|
||||
OS_TPrintf("NUC_GetProgress() failed in checking, error code=%d\n", NUC_GetLastError());
|
||||
}
|
||||
if (TestState.count++ % STRING_ANIM_CNT == 0)
|
||||
{
|
||||
u32 num = (TestState.count / STRING_ANIM_CNT) % 3;
|
||||
const char* msg[] = {
|
||||
"Now checking list. ",
|
||||
"Now checking list.. ",
|
||||
"Now checking list... "};
|
||||
|
||||
mprintf("%s\r", msg[num]);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: StartNupDownload
|
||||
Description: ダウンロードを開始します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL StartNupDownload(void)
|
||||
{
|
||||
/* こいつが呼ばれたらFSが切り離されてしまうのでリブートが必要 */
|
||||
BOOL ret = NUC_DownloadAsync(TitleIds, TitleIdNum);
|
||||
|
||||
if (ret == FALSE)
|
||||
{
|
||||
OS_TPrintf("NUP_DownloadAsync() failed, error code=%d\n", NUC_GetLastError());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: ProgressNupDownload
|
||||
Description: ダウンロードの進行状況を表示します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
NucStatus ProgressNupDownload(void)
|
||||
{
|
||||
u64 CurrentSize, TotalSize;
|
||||
NucStatus status;
|
||||
|
||||
NUC_GetProgress(&CurrentSize, &TotalSize, &status);
|
||||
if (status == NUC_STATUS_ERROR)
|
||||
{ // エラー発生
|
||||
// NUC_GetProgress() failed in checking, error code=34303
|
||||
OS_TPrintf("NUC_GetProgress() failed in download, error code=%d\n", NUC_GetLastError());
|
||||
mprintf("\nNUC_GetProgress() failed\n in download\n error code=%d\n", NUC_GetLastError());
|
||||
}
|
||||
|
||||
if (TestState.count++ % STRING_ANIM_CNT == 0)
|
||||
{
|
||||
u32 num = (TestState.count / STRING_ANIM_CNT) % 3;
|
||||
const char* msg[] = {
|
||||
"Now downloading. ",
|
||||
"Now downloading.. ",
|
||||
"Now downloading... "};
|
||||
mprintf("%s\r", msg[num]);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: CleanNupLib
|
||||
Description: NUCライブラリを終了します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL CleanNupLib(void)
|
||||
{
|
||||
BOOL ret = NUC_Cleanup(TitleIds, TitleIdNum);
|
||||
if (ret == FALSE)
|
||||
{
|
||||
OS_TPrintf("NUP_CleanUp() failed, error code=%d\n", NUC_GetLastError());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: ProgressNetConnect
|
||||
Description: ネットワーク接続を待ちます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void ProgressNetConnect(void)
|
||||
{
|
||||
if (TestState.count++ % STRING_ANIM_CNT == 0)
|
||||
{
|
||||
u32 num = (TestState.count / STRING_ANIM_CNT) % 3;
|
||||
const char* msg[] = {
|
||||
"Connecting network. ",
|
||||
"Connecting network.. ",
|
||||
"Connecting network..."};
|
||||
mprintf("%s\r", msg[num]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShowErrorMsg(int error_code)
|
||||
{
|
||||
|
||||
mprintf("Error Occurred ");
|
||||
|
||||
if (error_code > 0) {
|
||||
mprintf("Error Code:%d", error_code);
|
||||
mprintf("%s", GetPublicMsg(error_code));
|
||||
mprintf("%s", GetPrivateMsg(error_code));
|
||||
|
||||
OS_TPrintf( "Error Code:%d\n", error_code);
|
||||
OS_TPrintf( "%s\n", GetPublicMsg(error_code));
|
||||
OS_TPrintf( "%s\n", GetPrivateMsg(error_code));
|
||||
}
|
||||
else
|
||||
{
|
||||
OS_TPrintf( "%s\n", "Network Error occurred.\nTry again later.");
|
||||
// ネットワークエラー時の表示メッセージ(暫定)
|
||||
mprintf( "%s", "Network Error occurred.\nTry again later.");
|
||||
}
|
||||
}
|
||||
|
||||
BOOL my_numc_proc(void)
|
||||
{
|
||||
BOOL ret;
|
||||
NucStatus status;
|
||||
int error_code = 0;
|
||||
|
||||
ChangeState(PHASE_NUP_BREAK);
|
||||
|
||||
while(1) {
|
||||
OS_Sleep( 16 ); /* OS_WaitVBlankIntrの代わり */
|
||||
|
||||
switch ( TestState.state ) {
|
||||
case PHASE_NUP_BREAK:
|
||||
mprintf("NUP Initialize\n");
|
||||
ret = InitNupLib();
|
||||
if (ret == FALSE)
|
||||
{ // エラー発生
|
||||
ChangeState(PHASE_ERROR_OCCURRED);
|
||||
error_code = NUC_GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeState(PHASE_NUP_READY);
|
||||
}
|
||||
break;
|
||||
|
||||
case PHASE_NUP_READY: // 更新情報の取得を開始します。
|
||||
mprintf("NUP Check\n");
|
||||
ret = StartNupCheck();
|
||||
if (ret == FALSE)
|
||||
{ // エラー発生
|
||||
error_code = NUC_GetLastError();
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeState(PHASE_NUP_CHECK);
|
||||
}
|
||||
break;
|
||||
|
||||
case PHASE_NUP_CHECK: // 更新情報の取得状況を表示します。
|
||||
status = ProgressNupCheck();
|
||||
if (status == NUC_STATUS_ERROR)
|
||||
{ // エラー発生
|
||||
mprintf("\n");
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
error_code = NUC_GetLastError();
|
||||
}
|
||||
else if (status == NUC_STATUS_COMPLETED)
|
||||
{ // 更新リスト 取得終了
|
||||
mprintf("\n");
|
||||
if (TitleIdNum > 0 )
|
||||
{ // ダウンロードへ
|
||||
int i;
|
||||
for (i = 0; i < TitleIdNum; i++) {
|
||||
OS_TPrintf("DL list:%3d:0x%llx\n", i, TitleIds[i]);
|
||||
mprintf("DL list:%3d:0x%llx\n", i, TitleIds[i]);
|
||||
}
|
||||
ChangeState(PHASE_NUP_DOWNLOAD);
|
||||
}
|
||||
else
|
||||
{ // 更新すべきものがない
|
||||
mprintf("No title to update\n");
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PHASE_NUP_DOWNLOAD: // ダウンロードを開始します。
|
||||
mprintf("NUP Download\n");
|
||||
ret = StartNupDownload();
|
||||
if (ret == FALSE)
|
||||
{ // エラー発生
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
error_code = NUC_GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeState(PHASE_NUP_PROCESS);
|
||||
}
|
||||
break;
|
||||
|
||||
case PHASE_NUP_PROCESS: // ダウンロードの進行状況を表示します。
|
||||
status = ProgressNupDownload();
|
||||
if (status == NUC_STATUS_ERROR)
|
||||
{ // エラー発生
|
||||
mprintf("\n");
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
error_code = NUC_GetLastError();
|
||||
}
|
||||
else if (status == NUC_STATUS_COMPLETED)
|
||||
{ // ダウンロード完了
|
||||
mprintf("\n");
|
||||
ChangeState(PHASE_NUP_CLEANUP);
|
||||
}
|
||||
break;
|
||||
|
||||
case PHASE_NUP_CLEANUP: // NUPライブラリのクリーンアップ
|
||||
mprintf("NUP Cleanup\n");
|
||||
ret = CleanNupLib();
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
if (ret == FALSE && error_code == 0)
|
||||
{ // 他でエラーが起こっていない場合のみ上書きします。
|
||||
error_code = NUC_GetLastError();
|
||||
}
|
||||
// ネットの切断と後始末
|
||||
ChangeState(PHASE_FINISHED);
|
||||
break;
|
||||
|
||||
case PHASE_FINISHED: // ネットワークアップデートが正常終了しました。
|
||||
if( error_code == 0 ) {
|
||||
if (TitleIdNum > 0) {
|
||||
OS_TPrintf("%d file is updated\n", TitleIdNum);
|
||||
mprintf("%d file is updated\n", TitleIdNum);
|
||||
}
|
||||
else {
|
||||
OS_TPrintf("Nothing is updated\n");
|
||||
mprintf("Nothing is updated\n");
|
||||
}
|
||||
}
|
||||
goto end;
|
||||
break;
|
||||
|
||||
case PHASE_ERROR_OCCURRED: // エラーが発生しています。
|
||||
ShowErrorMsg(error_code);
|
||||
goto end;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
end:
|
||||
if( error_code != 0 ) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
55
build/tools/sctools/copy_dst/src/mynuc.h
Normal file
55
build/tools/sctools/copy_dst/src/mynuc.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef _MY_NUC_H_
|
||||
#define _MY_NUC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Network Updateのフェーズを表す
|
||||
typedef enum{
|
||||
|
||||
PHASE_INIT, // 初期状態
|
||||
PHASE_READY, // 開始
|
||||
PHASE_CONNECTING_NETWORK, // ネットワーク接続中
|
||||
PHASE_TEST_READY, // 接続テスト開始
|
||||
PHASE_TEST_PROCESS, // 接続テスト中
|
||||
PHASE_TEST_GETTING_WII_ID, // Wii ID取得処理
|
||||
PHASE_TEST_FINISHED, // 接続テスト完了
|
||||
PHASE_TEST_CLEANUP, // 接続テスト後処理
|
||||
PHASE_NUP_BREAK, // <キー入力待ち>アップデート前確認待ち
|
||||
PHASE_NUP_READY, // ネットワークアップデート開始
|
||||
PHASE_NUP_CHECK, // ネットワークアップデート更新情報取得中
|
||||
PHASE_NUP_DOWNLOAD, // ネットワークアップデート ダウンロード開始
|
||||
PHASE_NUP_PROCESS, // ネットワークアップデート中
|
||||
PHASE_NUP_FINISHED, // ネットワークアップデート完了
|
||||
PHASE_NUP_CLEANUP, // ネットワークアップデート後処理
|
||||
PHASE_NUP_SKIPPED, // ネットワークアップデートがスキップされた
|
||||
PHASE_CLEANING_UP, // 後処理
|
||||
PHASE_FINISHED, // 完了
|
||||
PHASE_ERROR_OCCURRED // エラー発生
|
||||
} NucPhaseState;
|
||||
|
||||
|
||||
// ネットワーク接続状態
|
||||
typedef enum{
|
||||
NET_CONNECT_NONE,
|
||||
NET_CONNECT_OK,
|
||||
NET_CONNECT_ERROR
|
||||
} NetConnectState;
|
||||
|
||||
|
||||
BOOL InitNupLib(void);
|
||||
BOOL StartNupCheck(void);
|
||||
NucStatus ProgressNupCheck(void);
|
||||
BOOL StartNupDownload(void);
|
||||
NucStatus ProgressNupDownload(void);
|
||||
BOOL CleanNupLib(void);
|
||||
void ProgressNetConnect(void);
|
||||
void ShowErrorMsg(int error_code);
|
||||
BOOL my_numc_proc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MY_NUC_H_ */
|
||||
@ -24,9 +24,8 @@ 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 \
|
||||
hatamotolib.cpp \
|
||||
sitedefs.c wcm_control.c netconnect.c mywlan.c \
|
||||
nuc.c nuc_error_msg.c stream.c myfilename.c
|
||||
nuc_error_msg.c stream.c myfilename.c
|
||||
|
||||
TARGET_BIN = copy_org.srl
|
||||
ROM_SPEC = copy_org.rsf
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include "mynvram.h"
|
||||
#include "stream.h"
|
||||
#include "hwi.h"
|
||||
#include "hatamotolib.h"
|
||||
// #include "hatamotolib.h"
|
||||
#include "ecdl.h"
|
||||
#include "mywlan.h"
|
||||
#include "mydata.h"
|
||||
@ -48,11 +48,16 @@ static void SDEvents(void *userdata, FSEvent event, void *arg)
|
||||
(void)arg;
|
||||
if (event == FS_EVENT_MEDIA_REMOVED) {
|
||||
sd_card_flag = FALSE;
|
||||
mprintf("sdmc:removed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("SD card:removed!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
}
|
||||
else if (event == FS_EVENT_MEDIA_INSERTED) {
|
||||
sd_card_flag = TRUE;
|
||||
mprintf("sdmc:inserted!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
mprintf("SD card:inserted!\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,11 +67,6 @@ 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;
|
||||
|
||||
@ -100,23 +100,6 @@ static void start_my_thread(void)
|
||||
|
||||
|
||||
|
||||
static BOOL SDBackupToSDCard1(void)
|
||||
{
|
||||
/* 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 */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static BOOL SDBackupToSDCard2(void)
|
||||
{
|
||||
/* Wifi設定の保存 */
|
||||
@ -267,24 +250,25 @@ static BOOL SDBackupToSDCard7(void)
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
mprintf("User title list backup ");
|
||||
OS_TPrintf("User title list backup \n");
|
||||
mprintf("User title list backup ");
|
||||
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("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 %llx\n",j,*ptr);
|
||||
mfprintf(tc[2],"No. %d %llx\n",j,*ptr);
|
||||
OS_TPrintf("No. %d 0x%016llx\n",j,*ptr);
|
||||
mfprintf(tc[2],"No. %d 0x%016llx\n",j,*ptr);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
|
||||
if( TRUE == TitleIDSave( MyFile_GetDownloadTitleIDFileName(), pBuffer, count, NULL) ) {
|
||||
//MyFile_GetDownloadTitleIDLogFileName()
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
@ -292,17 +276,17 @@ static BOOL SDBackupToSDCard7(void)
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf("NG.(save ids)\n");
|
||||
}
|
||||
if( pBuffer ) {
|
||||
OS_Free(pBuffer);
|
||||
PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf("NG.(get ids)\n");
|
||||
}
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
|
||||
(void)ClearDirEntryList( &dir_entry_list_head );
|
||||
|
||||
return TRUE;
|
||||
@ -317,12 +301,12 @@ static BOOL SDBackupToSDCard8(void)
|
||||
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");
|
||||
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");
|
||||
mprintf(" (--no shop record--)\n");
|
||||
}
|
||||
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
@ -336,7 +320,8 @@ static BOOL SDBackupToSDCard8(void)
|
||||
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 ");
|
||||
|
||||
mprintf("Personal data backup ");
|
||||
if( TRUE == MydataSave( MyFile_GetGlobalInformationFileName(), (void *)&mydata, sizeof(MyData), NULL) ) {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
@ -354,7 +339,7 @@ typedef BOOL (*function_ptr)(void);
|
||||
|
||||
static function_ptr function_table[] =
|
||||
{
|
||||
SDBackupToSDCard1,
|
||||
// SDBackupToSDCard1,
|
||||
SDBackupToSDCard2,
|
||||
SDBackupToSDCard3,
|
||||
SDBackupToSDCard4,
|
||||
@ -371,16 +356,31 @@ static int function_counter = 0;
|
||||
static void MyThreadProc(void *arg)
|
||||
{
|
||||
#pragma unused(arg)
|
||||
BOOL flag;
|
||||
OSMessage message;
|
||||
while( 1 ) {
|
||||
(void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK);
|
||||
flag = TRUE;
|
||||
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])();
|
||||
if( FALSE == (function_table[function_counter])() ) {
|
||||
flag = FALSE;
|
||||
}
|
||||
OS_TPrintf("stream on\n");
|
||||
}
|
||||
mprintf("\n");
|
||||
if( flag == TRUE ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("Backup completed.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("Backup failed.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
mprintf("\n");
|
||||
if( TRUE == stream_is_play1_end() ) {
|
||||
stream_play1();
|
||||
}
|
||||
@ -442,30 +442,6 @@ void TwlMain(void)
|
||||
stream_main();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
0 -> black
|
||||
1 -> red
|
||||
2 -> green
|
||||
3 -> blue
|
||||
4 -> yellow
|
||||
5 -> purple
|
||||
6 -> sky blue
|
||||
7 -> red
|
||||
8 -> green
|
||||
9 -> blue
|
||||
0xA -> yellow
|
||||
0xB -> purple
|
||||
0xC -> sky blue
|
||||
0xD -> white
|
||||
0xE -> white
|
||||
0xF -> white
|
||||
|
||||
*/
|
||||
// m_set_palette(tc[0], 0xF);
|
||||
|
||||
|
||||
|
||||
// 必須;SEA の初期化
|
||||
SEA_Init();
|
||||
|
||||
@ -477,23 +453,26 @@ void TwlMain(void)
|
||||
|
||||
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
|
||||
mprintf("rtc read date error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("rtc date read error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
}
|
||||
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
|
||||
mprintf("rtc read time error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("rtc time read error.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// mprintf("HW Normal Info. read ");
|
||||
mprintf("Unique ID read ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mprintf("Unique ID:\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf(" read error.\n");
|
||||
m_set_palette(tc[0], 0xF);
|
||||
}
|
||||
else {
|
||||
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]);
|
||||
@ -503,55 +482,28 @@ void TwlMain(void)
|
||||
mprintf("%02X:", hwn_info.movableUniqueID[i]);
|
||||
}
|
||||
mprintf("\n");
|
||||
// mprintf(" RTC Adjust data = 0x%02x\n", hwn_info.rtcAdjust );
|
||||
}
|
||||
mprintf("\n");
|
||||
|
||||
|
||||
// mprintf("HW Secure Info. read ");
|
||||
mprintf("Serial No. read ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mprintf("Serial No. ");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("NG.\n");
|
||||
mprintf("read error.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], 0x2); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
mprintf(" %s\n", hws_info.serialNo);
|
||||
#if 0
|
||||
mprintf(" 0x");
|
||||
for( i = 0; i < LCFG_TWL_HWINFO_SERIALNO_LEN_MAX/2 ; i++ ) {
|
||||
mprintf("%02X:", hws_info.serialNo[i]);
|
||||
mprintf("%s\n", hws_info.serialNo);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mprintf("\n");
|
||||
|
||||
#if 0
|
||||
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 );
|
||||
#endif
|
||||
}
|
||||
|
||||
OS_GetMacAddress( macAddress );
|
||||
mprintf("MAC Address 0x");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mprintf("MAC add.(HEX):");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
for ( i = 0 ; i < 6 ; i++ ) {
|
||||
mprintf("%02X", macAddress[i]);
|
||||
}
|
||||
@ -562,7 +514,7 @@ void TwlMain(void)
|
||||
if( FALSE == SDCardValidation() ) {
|
||||
sd_card_flag = FALSE;
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("No SD Card\n");
|
||||
mprintf("No SD card\n");
|
||||
}
|
||||
else {
|
||||
sd_card_flag = TRUE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user