From 46af748d2f600f818141f268160b6ae4ed1c5c94 Mon Sep 17 00:00:00 2001 From: N2614 Date: Thu, 28 Mar 2013 06:29:41 +0000 Subject: [PATCH] =?UTF-8?q?CTR=E3=80=81SPR=E3=82=88=E3=82=8A=E5=BE=8C?= =?UTF-8?q?=E3=81=AE=E3=83=A2=E3=83=87=E3=83=AB=E3=81=A7=E3=81=AFX?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=A7=E7=84=A1=E7=B7=9AON/OFF?= =?UTF-8?q?=E3=82=92=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=82=89=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=82=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=89=E3=81=AB=E3=81=AFnwm=5FExtAPI.cpp=E3=82=92=E5=B7=AE?= =?UTF-8?q?=E3=81=97=E6=9B=BF=E3=81=88=E3=82=8B=E5=BF=85=E8=A6=81=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@731 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleDataMigration/documents/Readme.txt | 6 +- .../sources/ConsoleBackup/ConsoleBackup.cpp | 9 +- .../sources/ConsoleRestore/ConsoleRestore.cpp | 9 +- .../sources/common/DrawSystemState.cpp | 19 +- .../sources/common/DrawSystemState.h | 3 +- .../sources/common/Util.cpp | 67 ++++++ .../sources/common/Util.h | 24 ++- .../sources/common/nwm_ExtAPI.cpp | 193 ++++++++++++++++++ 8 files changed, 324 insertions(+), 6 deletions(-) create mode 100644 trunk/ConsoleDataMigration/sources/common/nwm_ExtAPI.cpp diff --git a/trunk/ConsoleDataMigration/documents/Readme.txt b/trunk/ConsoleDataMigration/documents/Readme.txt index 17fb8b1..834019c 100644 --- a/trunk/ConsoleDataMigration/documents/Readme.txt +++ b/trunk/ConsoleDataMigration/documents/Readme.txt @@ -1,6 +1,6 @@ 【ビルド環境】 ・SDK -CTR_SDK-3_3 branch r45925 +CTR_SDK-3_3 branch r45925 + r51434 ・コンパイラ ARM C/C++ Compiler, 4.1 [Build 1049] for Nintendo @@ -21,6 +21,10 @@ QR でビルドすること。 +無線ON/OFF切り替えのため、sources/common/nwm_ExtAPI.cpp を +$HORIZON_ROOT/sources/libraries/nwm/CTR +にコピーしてからnwmをリビルドする必要がある。 + 【リリース時の注意】 ConsoleRestoreのReleaseビルドは、ショップ接続時などにで無限ループする不具合があるためDevelopmentビルドを使用する。 diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp index 7d6a1cf..48d3f46 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp @@ -187,6 +187,12 @@ extern "C" void nnMain(void) flip = !flip; } + // X繝懊ち繝ウ縺ァWiFi On/Off + if(padStatus.trigger & nn::hid::BUTTON_X) + { + s_HwUtility.ToggleWifiStatus(); + } + // 繧ウ繝ウ繧ス繝シ繝ォ繧ケ繧ッ繝ュ繝シ繝ォ if(padStatus.hold & nn::hid::BUTTON_UP) { @@ -244,7 +250,8 @@ extern "C" void nnMain(void) operationMessage, s_HwUtility.GetRegion(), s_HwUtility.GetSerialNumber(), - s_HwUtility.HasReadFriendCode() + s_HwUtility.HasReadFriendCode(), + s_HwUtility.IsWifiOn() ); if (GetBackupMode() == BACKUP_MODE_DELETE_IF_FAILED) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp index d382df6..59dfaf9 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp @@ -212,6 +212,13 @@ extern "C" void nnMain(void) flip = !flip; } + // X繝懊ち繝ウ縺ァWiFi On/Off + if(padStatus.trigger & nn::hid::BUTTON_X) + { + s_HwUtility.ToggleWifiStatus(); + } + + // 蟾ヲ繝懊ち繝ウ縺ァQR蛻譖ソ if(padStatus.trigger & nn::hid::BUTTON_RIGHT) { @@ -296,7 +303,7 @@ extern "C" void nnMain(void) s_HwUtility.GetCupMicroVersion(), s_HwUtility.GetNupVersion(), s_HwUtility.GetBatteryRemain(), s_HwUtility.GetInfraDeviceId(), s_HwUtility.GetFriendcode(), GetProgress(), IsRestoreFailed(), IsRestoreSucceeded(), false, s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(), - s_HwUtility.GetSerialNumber(), s_HwUtility.HasReadFriendCode()); + s_HwUtility.GetSerialNumber(), s_HwUtility.HasReadFriendCode(), s_HwUtility.IsWifiOn()); if (GetRestoreMode() != RESTORE_MODE_RESTORE) { diff --git a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp index 31c0569..12cbf09 100644 --- a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp +++ b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp @@ -41,6 +41,7 @@ std::string s_AdapterState; u8 s_Progress; OperationMessage* s_OperationMessage; bool s_ReadFriendCode; +bool s_IsWifiOn; } @@ -49,7 +50,21 @@ void SetTextWriterCore() GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255)); GetTextWriter()->Print("\n"); + f32 cursorX = GetTextWriter()->GetCursorX(); + f32 cursorY = GetTextWriter()->GetCursorY(); GetTextWriter()->Printf("System Ver. %d.%d.%d-%d\n", s_CupMajor, s_CupMinor, s_CupMicro, s_NupMajor); + GetTextWriter()->SetCursorX(cursorX); + GetTextWriter()->SetCursorY(cursorY); + if(s_IsWifiOn) + { + GetTextWriter()->Printf(" WiFi ON\n"); + } + else + { + GetTextWriter()->SetTextColor(nn::util::Color8(80, 80, 80, 255)); + GetTextWriter()->Printf(" WiFi OFF\n"); + GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255)); + } GetTextWriter()->Printf("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(s_Region)); GetTextWriter()->Printf("Serial No. %s\n", s_SerialNo); GetTextWriter()->Printf("Device ID %s\n", s_DeviceIdStr); @@ -97,7 +112,8 @@ void DrawSystemState OperationMessage& operationMessage, nn::cfg::CTR::CfgRegionCode region, u8* serialNo, - bool readFriendCode + bool readFriendCode, + bool isWifiOn ) { @@ -120,6 +136,7 @@ void DrawSystemState s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = '\0'; s_OperationMessage = &operationMessage; s_ReadFriendCode = readFriendCode; + s_IsWifiOn = isWifiOn; // 繝繝輔か繝ォ繝医〒荳顔判髱「縺ォ謠冗判縺吶k繧ゅョ diff --git a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h index 6881042..121c721 100644 --- a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h +++ b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h @@ -69,7 +69,8 @@ void DrawSystemState OperationMessage& operationMessage, nn::cfg::CTR::CfgRegionCode region, u8* s_SerialNo, - bool readFriendCode + bool readFriendCode, + bool isWifiOn ); } diff --git a/trunk/ConsoleDataMigration/sources/common/Util.cpp b/trunk/ConsoleDataMigration/sources/common/Util.cpp index 218e436..cf3c5ae 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.cpp +++ b/trunk/ConsoleDataMigration/sources/common/Util.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "Util.h" #include "FileName.h" @@ -109,6 +111,12 @@ void Util::Initialize() // IVS縺ョ蜿門セ ReadIvs(m_VerData.cup.majorVersion); + // 繝「繝繝ォ縺ョ蜿門セ + GetModel(); + + // nwm縺ョ蛻晄悄蛹 + nn::nwm::InitializeExtControl(); + // MAC繧「繝峨Ξ繧ケ縺ョ蜿門セ nn::nwm::Mac mac; @@ -130,9 +138,38 @@ void Util::FinalizeForRestore() void Util::Finalize() { + nn::nwm::FinalizeExtControl(); nn::mcu::CTR::FinalizeHwCheck(&m_McuSession); } +void Util::ToggleWifiStatus() +{ + if(!CanChangeWifi()) + { + return; + } + + if(nn::nwm::IsWifiOn()) + { + COMMON_LOGGER_RESULT_IF_FAILED( + nn::nwm::Ext::SetWifiOff() + ); + } + else + { + COMMON_LOGGER_RESULT_IF_FAILED( + nn::nwm::Ext::SetWifiOn() + ); + } +} + +// 辟。邱夂憾諷九r蜿門セ励☆繧 +bool Util::IsWifiOn() +{ + return nn::nwm::IsWifiOn(); +} + + void Util::ReadIvs(u8 cupMajorVersion) { if (cupMajorVersion < common::CUP_MAJOR_VER_2ND_NUP) @@ -187,6 +224,36 @@ void Util::ReadIvs(u8 cupMajorVersion) } } +void Util::GetModel() +{ + nn::mcu::CTR::HwCheck mcu(m_McuSession); + u8 buf[10]; + const u8 RETRY = 10; + + for(u8 i = 0; i < RETRY; i++) + { + nn::Result result = mcu.GetInfoRegisters(buf, sizeof(buf)); + if(result.IsSuccess()) + { + break; + } + nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(16)); + } + + // 讖溽ィョ諠蝣ア繧 cfg 縺ォ蜿肴丐 + m_Model= buf[9]; +} + +bool Util::CanChangeWifi() +{ + if(m_Model == TARGET_MODEL_CTR || m_Model == TARGET_MODEL_SPR) + { + return false; + } + + return true; +} + // NULL邨らォッ縺輔l縺溘す繝ェ繧「繝ォ繝翫Φ繝舌シ繧貞女縺大叙繧 // NULL邨らォッ縺輔l縺溷エ謇縺ォ繝√ぉ繝繧ッ繝繧ク繝繝医r莉伜刈縺励※譁ー縺溘↓NULL邨らォッ縺吶k void Util::AddCheckDigit(char* serial) diff --git a/trunk/ConsoleDataMigration/sources/common/Util.h b/trunk/ConsoleDataMigration/sources/common/Util.h index 22ebf0b..8af0484 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.h +++ b/trunk/ConsoleDataMigration/sources/common/Util.h @@ -30,6 +30,18 @@ namespace common class Util { public: + enum TargetModel + { + TARGET_MODEL_CTR, //!< CTR 繧定。ィ縺励∪縺吶 + TARGET_MODEL_SPR, //!< SPR 繧定。ィ縺励∪縺吶 + TARGET_MODEL_RESERVE_2, //!< 莠育エ + TARGET_MODEL_RESERVE_3, //!< 莠育エ + TARGET_MODEL_RESERVE_4, //!< 莠育エ + TARGET_MODEL_RESERVE_5, //!< 莠育エ + TARGET_MODEL_RESERVE_6, //!< 莠育エ + TARGET_MODEL_RESERVE_7 //!< 莠育エ + }; + Util(); virtual ~Util(); @@ -39,6 +51,12 @@ public: void FinalizeForBackup(); void FinalizeForRestore(); + // 辟。邱夂憾諷九r螟画峩縺吶k + void ToggleWifiStatus(); + + // 辟。邱夂憾諷九r蜿門セ励☆繧 + bool IsWifiOn(); + // 繧キ繝ェ繧「繝ォ繝翫Φ繝舌シ縺ォ繝「繧ク繝・繝ゥ繧ケ10 繧ヲ繧ァ繧、繝3繝サ1シM10W31シ峨〒繝√ぉ繝繧ッ繝繧ク繝繝医r莉伜刈縺吶k void AddCheckDigit(char* serial); @@ -123,6 +141,8 @@ private: void Initialize(); void Finalize(); void ReadIvs(u8 cupMajorVersion); + void GetModel(); + bool CanChangeWifi(); NN_PADDING4; // 繝輔Ξ繝ウ繝峨さ繝シ繝 @@ -169,7 +189,9 @@ private: // FriendCode繧定ェュ繧薙□縺九←縺縺 bool m_HasReadFriendCode; - NN_PADDING3; + // 讖溽ィョ諠蝣ア + u8 m_Model; + NN_PADDING2; NN_PADDING4; }; diff --git a/trunk/ConsoleDataMigration/sources/common/nwm_ExtAPI.cpp b/trunk/ConsoleDataMigration/sources/common/nwm_ExtAPI.cpp new file mode 100644 index 0000000..b3dc146 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/common/nwm_ExtAPI.cpp @@ -0,0 +1,193 @@ +サソ/*---------------------------------------------------------------------------* + Project: Horizon + File: nwm_ExtAPI.cpp + + Copyright (C)2009-2011 Nintendo Co., Ltd. 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. + + $Rev$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "nwm_Ext.h" +#include +#include +#include + +using namespace nn; +using namespace nn::nwm::CTR; + + +namespace nn { +namespace nwm { +namespace CTR { + +Result InitializeExtControl() +{ + return detail::InitializeBase(&detail::Ext::s_Session, PORT_NAME_EXT); +} + +Result FinalizeExtControl() +{ + return detail::FinalizeBase(&detail::Ext::s_Session); +} + +namespace Ext { + +Result GetMacAddress( Mac& mac ) +{ + return nn::nwm::CTR::GetMacAddress( mac ); +} + +Result GetState( u16* pState ) +{ + return detail::Ext::GetState( pState ); +} + +bool IsWifiOn() +{ + return nn::nwm::CTR::IsWifiOn(); +} + +Result GetLinkLevel( LinkLevel* pLinkLevel ) +{ + if ( pLinkLevel ) + { + *pLinkLevel = nn::nwm::CTR::GetLinkLevel(); + return ResultSuccess(); + } + else + { + return ResultInvalidPointer(); + } +} + +Result GetCommunicationMode( Mode* pMode ) +{ + if ( pMode ) + { + *pMode = nn::nwm::CTR::GetCommunicationMode(); + return ResultSuccess(); + } + else + { + return ResultInvalidPointer(); + } +} + +// 莉・荳九`P逕ィAPI + +Result OpenMpMode() +{ + return detail::Ext::OpenMpMode(); +} + +Result CloseMpMode() +{ + return detail::Ext::CloseMpMode(); +} + +Result UpdateMpLinkLevel( LinkLevel linkLevel ) +{ + return detail::Ext::UpdateMpLinkLevel( linkLevel ); +} + +Result NotifyWifiOffPreparationComplete() +{ + return detail::Ext::NotifyWifiOffPreparationComplete(); +} + +Result PrepareLegacyMode(u8 pParameters[32]) +{ + return detail::Ext::PrepareLegacyMode(pParameters); +} + +Result GetHardwareInfo(HardwareInfo &info) +{ + return detail::Ext::GetHardwareInfo(&info); +} + +Result SetWifiOn() +{ + Result result; + + nn::cfg::Initialize(); + +#if 0 + // 繝繝舌ャ繧ー繝「繝シ繝峨ヵ繝ゥ繧ー縺梧怏蜉ケ縺ェ蝣エ蜷医ョ縺ソ縲∵桃菴懊r陦後≧縲 + if( nn::cfg::IsDebugMode() == true ) + { +#endif + result = detail::Ext::PseudoToggleWifiButton(false); +#if 0 + } + else + { + result = ResultNotAuthorized(); + } +#endif + nn::cfg::Finalize(); + + return result; +} + +Result SetWifiOff() +{ + Result result; + + nn::cfg::Initialize(); + +#if 0 + // 繝繝舌ャ繧ー繝「繝シ繝峨ヵ繝ゥ繧ー縺梧怏蜉ケ縺ェ蝣エ蜷医ョ縺ソ縲∵桃菴懊r陦後≧縲 + if( nn::cfg::IsDebugMode() == true ) + { +#endif + result = detail::Ext::PseudoToggleWifiButton(true); +#if 0 + } + else + { + result = ResultNotAuthorized(); + } +#endif + + nn::cfg::Finalize(); + + return result; +} + +Result SimulateFirmwareError() +{ + Result result; + + nn::cfg::Initialize(); + + // 繝繝舌ャ繧ー繝「繝シ繝峨ヵ繝ゥ繧ー縺梧怏蜉ケ縺ェ蝣エ蜷医ョ縺ソ縲∵桃菴懊r陦後≧縲 + if( nn::cfg::IsDebugMode() == true ) + { + result = detail::Ext::SimulateFirmwareError(); + } + else + { + result = ResultNotAuthorized(); + } + nn::cfg::Finalize(); + + return result; +} + +} // namespace Ext + +} // namespace CTR +} // namespace nwm +} // namespace nn