From 73be79f4e0ee181792e9c3b2c8844e6411b5cca7 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 25 Aug 2013 02:49:58 +0200 Subject: [PATCH] Fix trailing whitespaces in all files where some were added --- CMakeLists.txt | 7 +- Source/Core/Common/Src/SettingsHandler.cpp | 2 +- Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp | 36 ++-- Source/Core/Core/Src/Core.cpp | 42 ++-- Source/Core/Core/Src/CoreParameter.cpp | 50 ++--- Source/Core/Core/Src/HLE/HLE_OS.cpp | 20 +- Source/Core/Core/Src/IPC_HLE/ICMPWin.cpp | 2 +- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp | 28 +-- .../Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 120 +++++------ .../Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h | 10 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp | 108 +++++----- .../Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h | 8 +- .../IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp | 48 ++--- .../Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h | 4 +- Source/Core/Core/Src/IPC_HLE/WII_Socket.h | 6 +- Source/Core/Core/Src/IPC_HLE/fakepoll.h | 14 +- Source/Core/Core/Src/PowerPC/GDBStub.cpp | 196 +++++++++--------- .../Src/PowerPC/Interpreter/Interpreter.cpp | 22 +- Source/Core/Core/Src/ec_wii.cpp | 34 +-- Source/Core/Core/Src/ec_wii.h | 36 ++-- 20 files changed, 395 insertions(+), 398 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac573fa64a..c29d09c10a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -569,11 +569,8 @@ endif() include(FindLibUSB OPTIONAL) if(LIBUSB_FOUND) message("Using shared LibUSB") - add_definitions(-D__LIBUSB__) include_directories(${LIBUSB_INCLUDE_DIR}) -else(LIBUSB_FOUND) - endif(LIBUSB_FOUND) set(SFML_FIND_VERSION TRUE) @@ -665,7 +662,7 @@ if(NOT DISABLE_WX AND NOT ANDROID) FIND_PACKAGE(wxWidgets COMPONENTS core aui adv) if(wxWidgets_FOUND) - EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" ${wxWidgets_CONFIG_OPTIONS} --version OUTPUT_VARIABLE wxWidgets_VERSION @@ -772,7 +769,7 @@ if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) endif() include(FindGettext) if(GETTEXT_FOUND AND NOT DISABLE_WX) - file(GLOB LINGUAS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Languages/po/*.po) + file(GLOB LINGUAS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Languages/po/*.po) GETTEXT_CREATE_TRANSLATIONS(Languages/po/dolphin-emu.pot ALL ${LINGUAS}) endif() if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|Darwin")) diff --git a/Source/Core/Common/Src/SettingsHandler.cpp b/Source/Core/Common/Src/SettingsHandler.cpp index 7eba971087..b9de9624d4 100644 --- a/Source/Core/Common/Src/SettingsHandler.cpp +++ b/Source/Core/Common/Src/SettingsHandler.cpp @@ -75,7 +75,7 @@ void SettingsHandler::Decrypt() { const u8 *str = m_buffer; while (*str != 0) - { + { if (m_position >= SETTINGS_SIZE) return; decoded.push_back((u8)(m_buffer[m_position] ^ m_key)); diff --git a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp index fa5b902b8d..7266fe1deb 100644 --- a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp @@ -35,7 +35,7 @@ void CBoot::RunFunction(u32 _iAddr) } // __________________________________________________________________________________________________ -// GameCube Bootstrap 2 HLE: +// GameCube Bootstrap 2 HLE: // copy the apploader to 0x81200000 // execute the apploader, function by function, using the above utility. bool CBoot::EmulatedBS2_GC() @@ -119,7 +119,7 @@ bool CBoot::EmulatedBS2_GC() DEBUG_LOG(MASTER_LOG, "Call iAppLoaderInit"); PowerPC::ppcState.gpr[3] = 0x81300000; RunFunction(iAppLoaderInit); - + // iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem). // To give you an idea about where the stuff is located on the disc take a look at yagcd // ch 13. @@ -135,7 +135,7 @@ bool CBoot::EmulatedBS2_GC() u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); u32 iLength = Memory::ReadUnchecked_U32(0x81300008); u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c); - + INFO_LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset, iRamAddress, iLength); DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); @@ -151,7 +151,7 @@ bool CBoot::EmulatedBS2_GC() // Load patches std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); PatchEngine::LoadPatches(gameID.c_str()); - + PowerPC::ppcState.DebugCount = 0; // If we have any patches that need to be applied very early, here's a good place @@ -167,7 +167,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) // Write the 256 byte setting.txt to memory. std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING); std::string area, model, code, video, game; - + switch((DiscIO::IVolume::ECountry)_CountryCode) { @@ -176,8 +176,8 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) video = "NTSC"; game = "KR"; code = "LKH"; - break; - case DiscIO::IVolume::COUNTRY_TAIWAN: + break; + case DiscIO::IVolume::COUNTRY_TAIWAN: // TODO: Determine if Taiwan have their own specific settings. case DiscIO::IVolume::COUNTRY_JAPAN: area = "JPN"; @@ -221,7 +221,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) } File::Delete(settings_Filename); } - + if (serno.empty() || serno == "000000000") { serno = gen.generateSerialNumber(); @@ -246,10 +246,10 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) { File::IOFile settingsFileHandle(settings_Filename, "wb"); - + if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE)) { - PanicAlertT("SetupWiiMem: Cant create setting file"); + PanicAlertT("SetupWiiMem: Cant create setting file"); return false; } Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE); @@ -310,7 +310,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) Memory::Write_U16(0x0000, 0x000030e0); // PADInit Memory::Write_U32(0x80000000, 0x00003184); // GameID Address - // Fake the VI Init of the IPL + // Fake the VI Init of the IPL Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC); // Clear exception handler. Why? Don't we begin with only zeros? @@ -322,7 +322,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) } // __________________________________________________________________________________________________ -// Wii Bootstrap 2 HLE: +// Wii Bootstrap 2 HLE: // copy the apploader to 0x81200000 // execute the apploader bool CBoot::EmulatedBS2_Wii() @@ -339,12 +339,12 @@ bool CBoot::EmulatedBS2_Wii() // This is some kind of consistency check that is compared to the 0x00 // values as the game boots. This location keep the 4 byte ID for as long // as the game is running. The 6 byte ID at 0x00 is overwritten sometime - // after this check during booting. + // after this check during booting. VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4); // Execute the apploader bool apploaderRan = false; - if (VolumeHandler::IsValid() && VolumeHandler::IsWii()) + if (VolumeHandler::IsValid() && VolumeHandler::IsWii()) { UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); m_MSR.FP = 1; @@ -362,7 +362,7 @@ bool CBoot::EmulatedBS2_Wii() // Load Apploader to Memory u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); - if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) + if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) { ERROR_LOG(BOOT, "Invalid apploader. Probably your image is corrupted."); return false; @@ -375,7 +375,7 @@ bool CBoot::EmulatedBS2_Wii() u32 iAppLoaderFuncAddr = 0x80004000; PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; - PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; + PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; RunFunction(iAppLoaderEntry); u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); @@ -383,14 +383,14 @@ bool CBoot::EmulatedBS2_Wii() // iAppLoaderInit DEBUG_LOG(BOOT, "Run iAppLoaderInit"); - PowerPC::ppcState.gpr[3] = 0x81300000; + PowerPC::ppcState.gpr[3] = 0x81300000; RunFunction(iAppLoaderInit); // Let the apploader load the exe to memory. At this point I get an unknown IPC command // (command zero) when I load Wii Sports or other games a second time. I don't notice // any side effects however. It's a little disconcerting however that Start after Stop // behaves differently than the first Start after starting Dolphin. It means something - // was not reset correctly. + // was not reset correctly. DEBUG_LOG(BOOT, "Run iAppLoaderMain"); do { diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 3fc1b2c41a..bfb80ff626 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -105,7 +105,7 @@ std::string StopMessage(bool bMainThread, std::string Message) bMainThread ? "Main Thread" : "Video Thread", Common::CurrentThreadId(), MemUsage().c_str(), Message.c_str()); } -// +// bool PanicAlertToVideo(const char* text, bool yes_no) { DisplayMessage(text, 3000); @@ -123,7 +123,7 @@ void DisplayMessage(const char *message, int time_in_ms) return; g_video_backend->Video_AddMessage(message, time_in_ms); - + if (_CoreParameter.bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar) { @@ -202,7 +202,7 @@ bool Init() Host_UpdateMainFrame(); // Disable any menus or buttons at boot g_aspect_wide = _CoreParameter.bWii; - if (g_aspect_wide) + if (g_aspect_wide) { IniFile gameIni; gameIni.Load(_CoreParameter.m_strGameIni.c_str()); @@ -216,7 +216,7 @@ bool Init() // within g_video_backend->Initialize() g_pWindowHandle = Host_GetRenderHandle(); - // Start the emu thread + // Start the emu thread g_EmuThread = std::thread(EmuThread); return true; @@ -254,12 +254,12 @@ void Stop() // - Hammertime! // will continue concurrently with the rest of the commands // in this function. We no longer rely on Postmessage. INFO_LOG(CONSOLE, "%s", StopMessage(true, "Wait for Video Loop to exit ...").c_str()); - + g_video_backend->Video_ExitLoop(); } INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping Emu thread ...").c_str()); - + g_EmuThread.join(); // Wait for emuthread to close. INFO_LOG(CONSOLE, "%s", StopMessage(true, "Main Emu thread stopped").c_str()); @@ -273,7 +273,7 @@ void Stop() // - Hammertime! // Close the trace file Core::StopTrace(); - + // Reload sysconf file in order to see changes committed during emulation if (_CoreParameter.bWii) SConfig::GetInstance().m_SYSCONF->Reload(); @@ -311,7 +311,7 @@ void CpuThread() g_bStarted = true; - + #ifdef USE_GDBSTUB if(_CoreParameter.iGDBPort > 0) { @@ -320,12 +320,12 @@ void CpuThread() gdb_break(); } #endif - + // Enter CPU run loop. When we leave it - we are done. CCPU::Run(); g_bStarted = false; - + if (!_CoreParameter.bCPUThread) g_video_backend->Video_Cleanup(); @@ -356,7 +356,7 @@ void FifoPlayerThread() } g_bStarted = false; - + if(!_CoreParameter.bCPUThread) g_video_backend->Video_Cleanup(); @@ -379,7 +379,7 @@ void EmuThread() Movie::Init(); - HW::Init(); + HW::Init(); if (!g_video_backend->Initialize(g_pWindowHandle)) { @@ -401,7 +401,7 @@ void EmuThread() } Pad::Initialize(g_pWindowHandle); - // Load and Init Wiimotes - only if we are booting in wii mode + // Load and Init Wiimotes - only if we are booting in wii mode if (g_CoreStartupParameter.bWii) { Wiimote::Initialize(g_pWindowHandle, !g_stateFileName.empty()); @@ -410,7 +410,7 @@ void EmuThread() for (unsigned int i = 0; i != MAX_BBMOTES; ++i) if (g_wiimote_sources[i]) GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(true); - + } // The hardware is initialized. @@ -441,7 +441,7 @@ void EmuThread() cpuThreadFunc = FifoPlayerThread; else cpuThreadFunc = CpuThread; - + // ENTER THE VIDEO THREAD LOOP if (_CoreParameter.bCPUThread) { @@ -481,17 +481,17 @@ void EmuThread() // Wait for g_cpu_thread to exit INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping CPU-GPU thread ...").c_str()); - + #ifdef USE_GDBSTUB INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB ...").c_str()); gdb_deinit(); INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB stopped.").c_str()); #endif - + g_cpu_thread.join(); INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str()); - + if(_CoreParameter.bCPUThread) g_video_backend->Video_Cleanup(); @@ -501,7 +501,7 @@ void EmuThread() // Stop audio thread - Actually this does nothing when using HLE // emulation, but stops the DSP Interpreter when using LLE emulation. DSP::GetDSPEmulator()->DSP_StopSoundStream(); - + // We must set up this flag before executing HW::Shutdown() g_bHwInit = false; INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str()); @@ -576,7 +576,7 @@ void SaveScreenShot() SetState(CORE_PAUSE); g_video_backend->Video_Screenshot(GenerateScreenshotName().c_str()); - + if (!bPaused) SetState(CORE_RUN); } @@ -698,7 +698,7 @@ void UpdateTitle() u32 Speed = DrawnVideo * (100 * 1000) / (VideoInterface::TargetRefreshRate * ElapseTime); // Settings are shown the same for both extended and summary info - std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC", + std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC", g_video_backend->GetName().c_str(), _CoreParameter.bDSPHLE ? "HLE" : "LLE"); // Use extended or summary information. The summary information does not print the ticks data, diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 58997407c6..93dd4be5a2 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -30,7 +30,7 @@ SCoreStartupParameter::SCoreStartupParameter() bJITPairedOff(false), bJITSystemRegistersOff(false), bJITBranchOff(false), bJITProfiledReJIT(false), bJITILTimeProfiling(false), bJITILOutputIR(false), - bEnableFPRF(false), + bEnableFPRF(false), bCPUThread(true), bDSPThread(false), bDSPHLE(true), bSkipIdle(true), bNTSC(false), bForceNTSCJ(false), bHLE_BS2(true), bEnableCheats(false), @@ -105,26 +105,26 @@ void SCoreStartupParameter::LoadDefaults() m_strUniqueID = "00000000"; } -bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) +bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) { std::string Region(EUR_DIR); - + switch (_BootBS2) { case BOOT_DEFAULT: { bool bootDrive = cdio_is_cdrom(m_strFilename); // Check if the file exist, we may have gotten it from a --elf command line - // that gave an incorrect file name + // that gave an incorrect file name if (!bootDrive && !File::Exists(m_strFilename)) { PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str()); return false; } - + std::string Extension; SplitPath(m_strFilename, NULL, NULL, &Extension); - if (!strcasecmp(Extension.c_str(), ".gcm") || + if (!strcasecmp(Extension.c_str(), ".gcm") || !strcasecmp(Extension.c_str(), ".iso") || !strcasecmp(Extension.c_str(), ".wbfs") || !strcasecmp(Extension.c_str(), ".ciso") || @@ -147,48 +147,48 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) } m_strName = pVolume->GetName(); m_strUniqueID = pVolume->GetUniqueID(); - + // Check if we have a Wii disc bWii = DiscIO::IsVolumeWiiDisc(pVolume); switch (pVolume->GetCountry()) { case DiscIO::IVolume::COUNTRY_USA: bNTSC = true; - Region = USA_DIR; + Region = USA_DIR; break; - + case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_KOREA: // TODO: Should these have their own Region Dir? case DiscIO::IVolume::COUNTRY_JAPAN: bNTSC = true; - Region = JAP_DIR; + Region = JAP_DIR; break; - + case DiscIO::IVolume::COUNTRY_EUROPE: case DiscIO::IVolume::COUNTRY_FRANCE: case DiscIO::IVolume::COUNTRY_ITALY: case DiscIO::IVolume::COUNTRY_RUSSIA: bNTSC = false; - Region = EUR_DIR; + Region = EUR_DIR; break; - + default: if (PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)." "\nContinue with PAL region?")) { bNTSC = false; - Region = EUR_DIR; + Region = EUR_DIR; break; }else return false; } - + delete pVolume; } else if (!strcasecmp(Extension.c_str(), ".elf")) { bWii = CBoot::IsElfWii(m_strFilename.c_str()); - Region = USA_DIR; + Region = USA_DIR; m_BootType = BOOT_ELF; bNTSC = true; } @@ -196,7 +196,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) { CDolLoader dolfile(m_strFilename.c_str()); bWii = dolfile.IsWii(); - Region = USA_DIR; + Region = USA_DIR; m_BootType = BOOT_DOL; bNTSC = true; } @@ -219,7 +219,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) { const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str()); const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename); - + if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL) { //WAD is valid yet cannot be booted. Install instead. @@ -233,9 +233,9 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) { case DiscIO::IVolume::COUNTRY_USA: bNTSC = true; - Region = USA_DIR; + Region = USA_DIR; break; - + case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_KOREA: // TODO: Should these have their own Region Dir? @@ -243,15 +243,15 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) bNTSC = true; Region = JAP_DIR; break; - + case DiscIO::IVolume::COUNTRY_EUROPE: case DiscIO::IVolume::COUNTRY_FRANCE: case DiscIO::IVolume::COUNTRY_ITALY: case DiscIO::IVolume::COUNTRY_RUSSIA: bNTSC = false; - Region = EUR_DIR; + Region = EUR_DIR; break; - + default: bNTSC = false; Region = EUR_DIR; @@ -278,7 +278,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) // or if it is not ascii characters (specifically sysmenu could potentially apply to other things) char titleidstr[17]; snprintf(titleidstr, 17, "%016llx", ContentLoader.GetTitleID()); - + if (!m_strName.length()) { m_strName = titleidstr; @@ -309,7 +309,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) bNTSC = true; break; - case BOOT_BS2_EUR: + case BOOT_BS2_EUR: Region = EUR_DIR; m_strFilename.clear(); bNTSC = false; diff --git a/Source/Core/Core/Src/HLE/HLE_OS.cpp b/Source/Core/Core/Src/HLE/HLE_OS.cpp index 425fa26513..ed80a68154 100644 --- a/Source/Core/Core/Src/HLE/HLE_OS.cpp +++ b/Source/Core/Core/Src/HLE/HLE_OS.cpp @@ -40,7 +40,7 @@ void HLE_GeneralDebugPrint() NPC = LR; //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); } void HLE_VPrintf() @@ -53,13 +53,13 @@ void HLE_VPrintf() for(int i = 4; i<= 10; i++){ GPR(i) = Memory::Read_U32(offset+(i-(check == 0x01000000? 3 : 2))*4); //NOTICE_LOG(OSREPORT, "r%d: %08X",i, GPR(i)); - } + } GetStringVA(ReportMessage); - + NPC = LR; - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); } // Generalized func for just printing string pointed to by r3. void HLE_GeneralDebugPrintWithInt() @@ -69,7 +69,7 @@ void HLE_GeneralDebugPrintWithInt() NPC = LR; //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); } // __write_console is slightly abnormal @@ -80,14 +80,14 @@ void HLE_write_console() NPC = LR; //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); } void GetStringVA(std::string& _rOutBuffer, u32 strReg) { _rOutBuffer = ""; char ArgumentBuffer[256]; - u32 ParameterCounter = strReg+1; + u32 ParameterCounter = strReg+1; u32 FloatingParameterCounter = 1; char *pString = (char*)Memory::GetPointer(GPR(strReg)); if (!pString) @@ -143,10 +143,10 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg) _rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter); break; } - + case 'f': { - _rOutBuffer += StringFromFormat(ArgumentBuffer, + _rOutBuffer += StringFromFormat(ArgumentBuffer, rPS0(FloatingParameterCounter)); FloatingParameterCounter++; ParameterCounter--; @@ -166,7 +166,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg) } else { - _rOutBuffer += StringFromFormat("%c", *pString); + _rOutBuffer += StringFromFormat("%c", *pString); pString++; } } diff --git a/Source/Core/Core/Src/IPC_HLE/ICMPWin.cpp b/Source/Core/Core/Src/IPC_HLE/ICMPWin.cpp index a5d0cd240e..55ccb9e5c8 100644 --- a/Source/Core/Core/Src/IPC_HLE/ICMPWin.cpp +++ b/Source/Core/Core/Src/IPC_HLE/ICMPWin.cpp @@ -14,7 +14,7 @@ enum #pragma pack(push, 1) struct icmp_hdr -{ +{ u8 type; u8 code; u16 checksum; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index 110023c14d..9e52b70e5a 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -88,7 +88,7 @@ void EnqueReplyCallback(u64 userdata, int) void Init() { - + _dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init"); CWII_IPC_HLE_Device_es::m_ContentFile = ""; u32 i; @@ -129,15 +129,15 @@ void Init() #endif g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/usb/oh1")); i++; g_DeviceMap[i] = new IWII_IPC_HLE_Device(i, std::string("_Unimplemented_Device_")); i++; - + enque_reply = CoreTiming::RegisterEvent("IPCReply", EnqueReplyCallback); } void Reset(bool _bHard) { - + CoreTiming::RemoveAllEvents(enque_reply); - + u32 i; for (i=0; i lk(s_reply_queue); @@ -257,7 +257,7 @@ IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName void DoState(PointerWrap &p) { std::lock_guard lk(s_reply_queue); - + p.Do(request_queue); p.Do(reply_queue); p.Do(last_reply_time); @@ -359,11 +359,11 @@ void ExecuteCommand(u32 _Address) { u32 Mode = Memory::Read_U32(_Address + 0x10); DeviceID = getFreeDeviceId(); - + std::string DeviceName; Memory::GetString(DeviceName, Memory::Read_U32(_Address + 0xC)); - + WARN_LOG(WII_IPC_HLE, "Trying to open %s as %d", DeviceName.c_str(), DeviceID); if (DeviceID >= 0) { @@ -529,7 +529,7 @@ void ExecuteCommand(u32 _Address) if (CmdSuccess) { // It seems that the original hardware overwrites the command after it has been - // executed. We write 8 which is not any valid command, and what IOS does + // executed. We write 8 which is not any valid command, and what IOS does Memory::Write_U32(8, _Address); // IOS seems to write back the command that was responded to Memory::Write_U32(Command, _Address + 8); @@ -537,14 +537,14 @@ void ExecuteCommand(u32 _Address) // Ensure replies happen in order, fairly ugly // Without this, tons of games fail now that DI commands have different reply delays int reply_delay = pDevice ? pDevice->GetCmdDelay(_Address) : 0; - + const s64 ticks_til_last_reply = last_reply_time - CoreTiming::GetTicks(); - + if (ticks_til_last_reply > 0) reply_delay = ticks_til_last_reply; - + last_reply_time = CoreTiming::GetTicks() + reply_delay; - + // Generate a reply to the IPC command EnqReply(_Address, reply_delay); } @@ -594,7 +594,7 @@ void Update() Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG); #endif } - + // lock due to using reply_queue { std::lock_guard lk(s_reply_queue); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index d384c1c88e..e7a2310fc6 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -46,20 +46,20 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) tv.tv_usec = 500; while (hid->usb_thread_running) { - + static u16 timeToFill = 0; if (timeToFill == 0) { if (hid->deviceCommandAddress != 0){ hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C)); - + Memory::Write_U32(8, hid->deviceCommandAddress); // IOS seems to write back the command that was responded to Memory::Write_U32(/*COMMAND_IOCTL*/ 6, hid->deviceCommandAddress + 8); - + // Return value Memory::Write_U32(0, hid->deviceCommandAddress + 4); - + WII_IPC_HLE_Interface::EnqueReplyCallback(hid->deviceCommandAddress); hid->deviceCommandAddress = 0; } @@ -67,7 +67,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) timeToFill+=8; libusb_handle_events_timeout(NULL, &tv); } - + return; } @@ -79,16 +79,16 @@ void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer *transfer) { ret = transfer->length; } - + Memory::Write_U32(8, replyAddress); // IOS seems to write back the command that was responded to Memory::Write_U32(/*COMMAND_IOCTL*/ 6, replyAddress + 8); - + // Return value Memory::Write_U32(ret, replyAddress + 4); - + WII_IPC_HLE_Interface::EnqueReplyCallback(replyAddress); - //DEBUG_LOG(WII_IPC_HID, "OMG OMG OMG I GOT A CALLBACK, IMMA BE FAMOUS %d %d %d", transfer->actual_length, transfer->length, transfer->status); + //DEBUG_LOG(WII_IPC_HID, "OMG OMG OMG I GOT A CALLBACK, IMMA BE FAMOUS %d %d %d", transfer->actual_length, transfer->length, transfer->status); } @@ -98,7 +98,7 @@ CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::strin deviceCommandAddress = 0; memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases)); libusb_init(NULL); - + usb_thread_running = true; usb_thread = std::thread(checkUsbUpdates, this); } @@ -107,14 +107,14 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() { usb_thread_running = false; usb_thread.join(); - + for ( std::map::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter ) { libusb_close(iter->second); } open_devices.clear(); - - + + libusb_exit(NULL); } @@ -137,7 +137,7 @@ bool CWII_IPC_HLE_Device_hid::Close(u32 _CommandAddress, bool _bForce) u32 CWII_IPC_HLE_Device_hid::Update() { - + u32 work_done = 0; return work_done; } @@ -148,7 +148,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); - u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); + u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 ReturnValue = 0; switch (Parameter) @@ -191,7 +191,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) ERROR CODES: -4 Cant find device specified */ - + u32 dev_num = Memory::Read_U32(BufferIn+0x10); u8 bmRequestType = Memory::Read_U8(BufferIn+0x14); u8 bRequest = Memory::Read_U8(BufferIn+0x15); @@ -199,11 +199,11 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) u16 wIndex = Memory::Read_U16(BufferIn+0x18); u16 wLength = Memory::Read_U16(BufferIn+0x1A); u32 data = Memory::Read_U32(BufferIn+0x1C); - + ReturnValue = HIDERR_NO_DEVICE_FOUND; - + libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num); - + if (dev_handle == NULL) { DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); @@ -211,7 +211,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) } struct libusb_transfer *transfer = libusb_alloc_transfer(0); transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER; - + u8 * buffer = (u8*)malloc(wLength + LIBUSB_CONTROL_SETUP_SIZE); libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, wLength); memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, Memory::GetPointer(data), wLength); @@ -220,7 +220,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) //DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Control)(%02X, %02X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", // bmRequestType, bRequest, BufferIn, BufferInSize, BufferOut, BufferOutSize); - + // It's the async way! return false; break; @@ -233,17 +233,17 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) u32 length = Memory::Read_U32(BufferIn+0x18); u32 data = Memory::Read_U32(BufferIn+0x1C); - + ReturnValue = HIDERR_NO_DEVICE_FOUND; - + libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num); - + if (dev_handle == NULL) { DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); break; } - + struct libusb_transfer *transfer = libusb_alloc_transfer(0); transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; libusb_fill_interrupt_transfer(transfer, dev_handle, endpoint, Memory::GetPointer(data), length, @@ -252,7 +252,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) //DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", // Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, BufferIn, BufferInSize, BufferOut, BufferOutSize); - + // It's the async way! return false; break; @@ -287,19 +287,19 @@ bool CWII_IPC_HLE_Device_hid::ClaimDevice(libusb_device_handle * dev) DEBUG_LOG(WII_IPC_HID, "libusb_kernel_driver_active error ret = %d", ret); return false; } - + if ((ret = libusb_claim_interface(dev, 0))) { DEBUG_LOG(WII_IPC_HID, "libusb_claim_interface failed with error: %d", ret); return false; } - + return true; } bool CWII_IPC_HLE_Device_hid::IOCtlV(u32 _CommandAddress) { - + Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HID, LogTypes::LWARNING); u32 ReturnValue = 0; SIOCtlVBuffer CommandBuffer(_CommandAddress); @@ -320,7 +320,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtlV(u32 _CommandAddress) } - + void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src) { memcpy(dest,src,sizeof(WiiHIDDeviceDescriptor)); @@ -354,7 +354,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) int OffsetStart = 0; //int OffsetDevice = 0; int d,c,ic,i,e; /* config, interface container, interface, endpoint */ - + libusb_device **list; //libusb_device *found = NULL; ssize_t cnt = libusb_get_device_list(NULL, &list); @@ -380,12 +380,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) Memory::WriteBigEData((const u8*)&wii_device, OffsetBuffer, Align(wii_device.bLength, 4)); OffsetBuffer += Align(wii_device.bLength, 4); bool deviceValid = true; - + for (c = 0; deviceValid && c < desc.bNumConfigurations; c++) { struct libusb_config_descriptor *config = NULL; int cRet = libusb_get_config_descriptor(device, c, &config); - + // do not try to use usb devices with more than one interface, games can crash if(cRet == 0 && config->bNumInterfaces <= MAX_HID_INTERFACES) { @@ -393,7 +393,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) ConvertConfigToWii(&wii_config, config); Memory::WriteBigEData((const u8*)&wii_config, OffsetBuffer, Align(wii_config.bLength, 4)); OffsetBuffer += Align(wii_config.bLength, 4); - + for (ic = 0; ic < config->bNumInterfaces; ic++) { const struct libusb_interface *interfaceContainer = &config->interface[ic]; @@ -414,7 +414,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) ConvertEndpointToWii(&wii_endpoint, endpoint); Memory::WriteBigEData((const u8*)&wii_endpoint, OffsetBuffer, Align(wii_endpoint.bLength, 4)); OffsetBuffer += Align(wii_endpoint.bLength, 4); - + } //endpoints } // interfaces } // interface containters @@ -429,11 +429,11 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) OffsetBuffer = OffsetStart; } } // configs - + if (deviceValid) { Memory::Write_U32(OffsetBuffer-OffsetStart, OffsetStart); // fill in length - + int devNum = GetAvaiableDevNum(desc.idVendor, desc.idProduct, libusb_get_bus_number (device), @@ -447,13 +447,13 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) OffsetBuffer = OffsetStart; continue; } - + DEBUG_LOG(WII_IPC_HID, "Found device with Vendor: %X Product: %X Devnum: %d", desc.idVendor, desc.idProduct, devNum); - + Memory::Write_U32(devNum , OffsetStart+4); //write device num } } - + // Find devices that no longer exists and free them for (i=0; i= MAX_DEVICE_DEVNUM) return NULL; - - + + std::lock_guard lk(s_open_devices); - + if (open_devices.find(devNum) != open_devices.end()) { handle = open_devices[devNum]; @@ -510,14 +510,14 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) { libusb_close(handle); open_devices.erase(devNum); - } + } } - + cnt = libusb_get_device_list(NULL, &list); - + if (cnt < 0) return NULL; - + for (i = 0; i < cnt; i++) { libusb_device *device = list[i]; struct libusb_device_descriptor desc; @@ -534,14 +534,14 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) { if( dRet ) { - ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID ????:???? (couldn't get id).", - bus, + ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID ????:???? (couldn't get id).", + bus, port ); } else{ - ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.", - bus, + ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.", + bus, port, desc.idVendor, desc.idProduct @@ -560,15 +560,15 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) } continue; } - - + + if (!ClaimDevice(handle)) { ERROR_LOG(WII_IPC_HID, "Could not claim the device for handle: %X", devNum); libusb_close(handle); continue; } - + open_devices[devNum] = handle; break; } @@ -577,7 +577,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) handle = NULL; } } - + libusb_free_device_list(list, 1); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h index 6faa65ce48..512c5c0d8e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h @@ -28,7 +28,7 @@ #define HIDERR_NO_DEVICE_FOUND -4 -/* Connection timed out */ +/* Connection timed out */ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device { @@ -131,21 +131,21 @@ private: int Align(int num, int alignment); static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid); static void LIBUSB_CALL handleUsbUpdates(struct libusb_transfer *transfer); - + struct libusb_device_handle * GetDeviceByDevNum(u32 devNum); std::map open_devices; std::mutex s_open_devices; std::map device_identifiers; - + std::thread usb_thread; bool usb_thread_running; - + typedef struct { u32 enq_address; u32 type; void * context; } _hidevent; - + std::list<_hidevent> event_list; }; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index 66ab28d1d9..ebb26ede71 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -46,7 +46,7 @@ it failed) #include #include "fakepoll.h" -#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) #elif defined(__linux__) or defined(__APPLE__) @@ -74,7 +74,7 @@ const u8 default_address[] = { 0x00, 0x17, 0xAB, 0x99, 0x99, 0x99 }; // ********************************************************************************** // Handle /dev/net/kd/request requests -CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName) +CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) { } @@ -100,19 +100,19 @@ bool CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress, bool _bForce return true; } -bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) +bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) { u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); - u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); + u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 ReturnValue = 0; switch (Parameter) { case IOCTL_NWC24_SUSPEND_SCHEDULAR: - // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) + // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); Memory::Write_U32(0, BufferOut); // no error break; @@ -158,7 +158,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) SettingsHandler gen; std::string area, model; bool _GotSettings = false; - + if (File::Exists(settings_Filename)) { File::IOFile settingsFileHandle(settings_Filename, "rb"); @@ -169,31 +169,31 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) model = gen.GetValue("MODEL"); _GotSettings = true; } - + } if (_GotSettings) { u8 area_code = GetAreaCode(area.c_str()); u8 id_ctr = config.IdGen(); u8 hardware_model = GetHardwareModel(model.c_str()); - + EcWii &ec = EcWii::GetInstance(); u32 HollywoodID = ec.getNgId(); u64 UserID = 0; - + s32 ret = NWC24MakeUserID(&UserID, HollywoodID, id_ctr, hardware_model, area_code); config.SetId(UserID); config.IncrementIdGen(); config.SetCreationStage(nwc24_config_t::NWC24_IDCS_GENERATED); config.WriteConfig(); - + Memory::Write_U32(ret, BufferOut); } else { - Memory::Write_U32(WC24_ERR_FATAL, BufferOut); + Memory::Write_U32(WC24_ERR_FATAL, BufferOut); } - + } else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED) { @@ -228,7 +228,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) // g_ReplyQueueLater.push(std::pair(_CommandAddress, GetDeviceName())); Memory::Write_U32(ReturnValue, _CommandAddress + 4); - return true; + return true; } @@ -244,7 +244,7 @@ u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode( const char * area ) return regions_[i]; } } - + return 7; } @@ -286,10 +286,10 @@ s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 holly { const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7}; const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, 0xC, 0x2, 0x6, 0xE, 0x8, 0x0, 0xA, 0x5}; - + u64 mix_id = ((u64)area_code<<50) | ((u64)hardware_model<<47) | ((u64)hollywood_id<<15) | ((u64)id_ctr<<10); u64 mix_id_copy1 = mix_id; - + int ctr = 0; for (ctr = 0; ctr <= 42; ctr++) { @@ -300,46 +300,46 @@ s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 holly mix_id ^= value; } } - + mix_id = (mix_id_copy1 | (mix_id & 0xFFFFFFFFUL)) ^ 0x0000B3B3B3B3B3B3ULL; mix_id = (mix_id >> 10) | ((mix_id & 0x3FF) << (11+32)); - + for (ctr = 0; ctr <= 5; ctr++) { u8 ret = u64_get_byte(mix_id, ctr); u8 foobar = ((table1[(ret>>4)&0xF])<<4) | (table1[ret&0xF]); mix_id = u64_insert_byte(mix_id, ctr, foobar & 0xff); - } + } u64 mix_id_copy2 = mix_id; - + for (ctr = 0; ctr <= 5; ctr++) { u8 ret = u64_get_byte(mix_id_copy2, ctr); mix_id = u64_insert_byte(mix_id, table2[ctr], ret); } - + mix_id &= 0x001FFFFFFFFFFFFFULL; mix_id = (mix_id << 1) | ((mix_id >> 52) & 1); - + mix_id ^= 0x00005E5E5E5E5E5EULL; mix_id &= 0x001FFFFFFFFFFFFFULL; - + *nwc24_id = mix_id; - + if (mix_id > 9999999999999999ULL) return WC24_ERR_FATAL; - + return WC24_OK; } // ********************************************************************************** // Handle /dev/net/ncd/manage requests -CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName) +CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) { } -CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage() +CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage() { } @@ -458,12 +458,12 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress) // ********************************************************************************** // Handle /dev/net/wd/command requests -CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName) +CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName) : IWII_IPC_HLE_Device(DeviceID, DeviceName) { } -CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command() +CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command() { } @@ -556,7 +556,7 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress) { WARN_LOG(WII_IPC_NET, "in %i addr %x size %i", i, CommandBuffer.InBuffer.at(i).m_Address, CommandBuffer.InBuffer.at(i).m_Size); - WARN_LOG(WII_IPC_NET, "%s", + WARN_LOG(WII_IPC_NET, "%s", ArrayToString( Memory::GetPointer(CommandBuffer.InBuffer.at(i).m_Address), CommandBuffer.InBuffer.at(i).m_Size).c_str() @@ -576,7 +576,7 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress) // ********************************************************************************** // Handle /dev/net/ip/top requests -CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName) +CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) { #ifdef _WIN32 @@ -585,7 +585,7 @@ CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, co #endif } -CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() +CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() { #ifdef _WIN32 WSACleanup(); @@ -658,8 +658,8 @@ static unsigned int opt_name_mapping[][2] = { { SO_ERROR, 0x1009 } }; -bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) -{ +bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) +{ u32 Command = Memory::Read_U32(_CommandAddress + 0x0C); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); @@ -673,7 +673,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) { WARN_LOG(WII_IPC_NET, "IOCTL_SO_STARTUP " "BufferIn: (%08x, %i), BufferOut: (%08x, %i)", - BufferIn, BufferInSize, BufferOut, BufferOutSize); + BufferIn, BufferInSize, BufferOut, BufferOutSize); break; } case IOCTL_SO_SOCKET: @@ -692,7 +692,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) case IOCTL_SO_CLOSE: { u32 sock = Memory::Read_U32(BufferIn); - + WiiSockMan &sm = WiiSockMan::getInstance(); ReturnValue = sm.delSocket(sock); @@ -746,7 +746,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) WARN_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT " "BufferIn: (%08x, %i), BufferOut: (%08x, %i)", BufferIn, BufferInSize, BufferOut, BufferOutSize); - + u32 sock = Memory::Read_U32(BufferIn); socklen_t addrlen; @@ -762,7 +762,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) ///////////////////////////////////////////////////////////// // TODO: ALL BELOW // ///////////////////////////////////////////////////////////// - + case IOCTL_SO_SHUTDOWN: { @@ -903,7 +903,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) Memory::Write_U8(BufferOutSize, BufferOut); Memory::Write_U8(AF_INET, BufferOut + 1); Memory::WriteBigEData((u8*)&sa.sa_data, BufferOut + 2, BufferOutSize - 2); - + WARN_LOG(WII_IPC_NET, "IOCTL_SO_GETPEERNAME(%x)", sock); ReturnValue = ret; @@ -1015,7 +1015,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) for (int i = 0; igetSSLFreeID(); if (freeSSL) { @@ -202,7 +202,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress) memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context)); goto _SSL_NEW_ERROR; } - + havege_init(&_SSL[sslID].hs); ssl_set_rng(&_SSL[sslID].ctx, havege_random, &_SSL[sslID].hs); @@ -213,7 +213,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress) ssl_set_session(&_SSL[sslID].ctx, &_SSL[sslID].session); ssl_set_verify(&_SSL[sslID].ctx, _verify_certificate_callback, NULL); - + ssl_set_endpoint(&_SSL[sslID].ctx, SSL_IS_CLIENT); ssl_set_authmode(&_SSL[sslID].ctx, SSL_VERIFY_NONE); ssl_set_renegotiation(&_SSL[sslID].ctx, SSL_RENEGOTIATION_ENABLED); @@ -257,7 +257,7 @@ _SSL_NEW_ERROR: memset(&_SSL[sslID].session, 0, sizeof(ssl_session)); memset(&_SSL[sslID].hs, 0, sizeof(havege_state)); memset(_SSL[sslID].hostname, 0, NET_SSL_MAX_HOSTNAME_LEN); - + _SSL[sslID].active = false; Memory::Write_U32(SSL_OK, _BufferIn); @@ -284,13 +284,13 @@ _SSL_NEW_ERROR: _BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); - + int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) - { + { int ret = x509parse_crt_der( - &_SSL[sslID].cacert, + &_SSL[sslID].cacert, Memory::GetPointer(BufferOut2), BufferOutSize2); @@ -304,7 +304,7 @@ _SSL_NEW_ERROR: Memory::Write_U32(SSL_OK, _BufferIn); } - WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); + WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); } else { @@ -341,7 +341,7 @@ _SSL_NEW_ERROR: ssl_set_own_cert(&_SSL[sslID].ctx, &_SSL[sslID].clicert, &_SSL[sslID].rsa); Memory::Write_U32(SSL_OK, _BufferIn); } - + WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, rsa_ret); } else @@ -385,7 +385,7 @@ _SSL_NEW_ERROR: if (SSLID_VALID(sslID)) { std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX)); - + int ret = x509parse_crtfile(&_SSL[sslID].cacert, (cert_base_path + "rootca.pem").c_str()); if (ret) { @@ -475,7 +475,7 @@ _SSL_NEW_ERROR: } case IOCTLV_NET_SSL_READ: { - + int ret = 0; int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) @@ -551,9 +551,9 @@ _SSL_NEW_ERROR: BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; } - + Memory::Write_U32(ReturnValue, _CommandAddress+4); - return true; + return true; } u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command, diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h index fb64f9597e..a49a08f5b7 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h @@ -44,7 +44,7 @@ enum ssl_err_t SSL_ERR_VCHAIN = -11, // verify failed: certificate chain SSL_ERR_VDATE = -12, // verify failed: date invalid SSL_ERR_SERVER_CERT = -13, // certificate cert invalid -}; +}; enum SSL_IOCTL { @@ -83,7 +83,7 @@ class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device { public: - CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName); + CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName); virtual ~CWII_IPC_HLE_Device_net_ssl(); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h index a07c90ac6d..b44f36a364 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h @@ -12,7 +12,7 @@ #include #include "fakepoll.h" -#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) #elif defined(__linux__) or defined(__APPLE__) @@ -170,7 +170,7 @@ public: WiiSocket() : fd(-1), nonBlock(false) {} ~WiiSocket(); void operator=(WiiSocket const&); // Don't implement - + }; class WiiSockMan @@ -196,7 +196,7 @@ public: { if (WiiSockets.find(sock) == WiiSockets.end()) { - ERROR_LOG(WII_IPC_NET, + ERROR_LOG(WII_IPC_NET, "doSock: Error, fd not found (%08x, %08X, %08X)", sock, CommandAddress, type); EnqueueReply(CommandAddress, -SO_EBADF); diff --git a/Source/Core/Core/Src/IPC_HLE/fakepoll.h b/Source/Core/Core/Src/IPC_HLE/fakepoll.h index 5940c1a43e..e5254592fd 100644 --- a/Source/Core/Core/Src/IPC_HLE/fakepoll.h +++ b/Source/Core/Core/Src/IPC_HLE/fakepoll.h @@ -6,13 +6,13 @@ // Warning: a call to this poll() takes about 4K of stack space. // Greg Parker gparker-web@sealiesoftware.com December 2000 -// This code is in the public domain and may be copied or modified without -// permission. +// This code is in the public domain and may be copied or modified without +// permission. -// Updated May 2002: +// Updated May 2002: // * fix crash when an fd is less than 0 // * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE -// * don't set POLLIN or POLLOUT in revents if it wasn't requested +// * don't set POLLIN or POLLOUT in revents if it wasn't requested // in events (only happens when an fd is in the poll set twice) #if (_WIN32_WINNT < _WIN32_WINNT_VISTA) @@ -70,7 +70,7 @@ inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout) writep = NULL; exceptp = NULL; maxFD = 0; - } + } else { pollEnd = pollSet + pollCount; readp = &readFDs; @@ -119,11 +119,11 @@ inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout) if (selected < 0) { // Error during select result = -1; - } + } else if (selected > 0) { // Select found something // Transcribe result from fd sets to poll set. - // Also count the number of selected fds. poll returns the + // Also count the number of selected fds. poll returns the // number of ready fds; select returns the number of bits set. int polled = 0; for (p = pollSet; p < pollEnd; p++) { diff --git a/Source/Core/Core/Src/PowerPC/GDBStub.cpp b/Source/Core/Core/Src/PowerPC/GDBStub.cpp index d97048f5ae..a6391043a7 100644 --- a/Source/Core/Core/Src/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/Src/PowerPC/GDBStub.cpp @@ -76,7 +76,7 @@ static u8 hex2char(u8 hex) return hex - 'a' + 0xa; else if (hex >= 'A' && hex <= 'F') return hex - 'A' + 0xa; - + ERROR_LOG(GDB_STUB, "Invalid nibble: %c (%02x)\n", hex, hex); return 0; } @@ -93,7 +93,7 @@ static u8 nibble2hex(u8 n) static void mem2hex(u8 *dst, u8 *src, u32 len) { u8 tmp; - + while (len-- > 0) { tmp = *src++; *dst++ = nibble2hex(tmp>>4); @@ -113,14 +113,14 @@ static u8 gdb_read_byte() { ssize_t res; u8 c = '+'; - + res = recv(sock, &c, 1, MSG_WAITALL); if (res != 1) { ERROR_LOG(GDB_STUB, "recv failed : %ld", res); gdb_deinit(); } - + return c; } @@ -129,10 +129,10 @@ static u8 gdb_calc_chksum() u32 len = cmd_len; u8 *ptr = cmd_bfr; u8 c = 0; - + while(len-- > 0) c += *ptr++; - + return c; } @@ -156,16 +156,16 @@ static gdb_bp_t *gdb_bp_empty_slot(u32 type) { gdb_bp_t *p; u32 i; - + p = gdb_bp_ptr(type); if (p == NULL) return NULL; - + for (i = 0; i < GDB_MAX_BP; i++) { if (p[i].active == 0) return &p[i]; } - + return NULL; } @@ -173,25 +173,25 @@ static gdb_bp_t *gdb_bp_find(u32 type, u32 addr, u32 len) { gdb_bp_t *p; u32 i; - + p = gdb_bp_ptr(type); if (p == NULL) return NULL; - + for (i = 0; i < GDB_MAX_BP; i++) { if (p[i].active == 1 && p[i].addr == addr && p[i].len == len) return &p[i]; } - + return NULL; } static void gdb_bp_remove(u32 type, u32 addr, u32 len) { gdb_bp_t *p; - + do { p = gdb_bp_find(type, addr, len); if (p != NULL) { @@ -206,17 +206,17 @@ static int gdb_bp_check(u32 addr, u32 type) { gdb_bp_t *p; u32 i; - + p = gdb_bp_ptr(type); if (p == NULL) return 0; - + for (i = 0; i < GDB_MAX_BP; i++) { if (p[i].active == 1 && (addr >= p[i].addr && addr < p[i].addr + p[i].len)) return 1; } - + return 0; } @@ -224,7 +224,7 @@ static void gdb_nak() { const char nak = GDB_STUB_NAK; ssize_t res; - + res = send(sock, &nak, 1, 0); if (res != 1) ERROR_LOG(GDB_STUB, "send failed"); @@ -234,7 +234,7 @@ static void gdb_ack() { const char ack = GDB_STUB_ACK; ssize_t res; - + res = send(sock, &ack, 1, 0); if (res != 1) ERROR_LOG(GDB_STUB, "send failed"); @@ -244,10 +244,10 @@ static void gdb_read_command() { u8 c; u8 chk_read, chk_calc; - + cmd_len = 0; memset(cmd_bfr, 0, sizeof cmd_bfr); - + c = gdb_read_byte(); if (c == '+') { @@ -264,7 +264,7 @@ static void gdb_read_command() DEBUG_LOG(GDB_STUB, "gdb: read invalid byte %02x\n", c); return; } - + while ((c = gdb_read_byte()) != GDB_STUB_END) { cmd_bfr[cmd_len++] = c; if (cmd_len == sizeof cmd_bfr) @@ -274,20 +274,20 @@ static void gdb_read_command() return; } } - + chk_read = hex2char(gdb_read_byte()) << 4; chk_read |= hex2char(gdb_read_byte()); - + chk_calc = gdb_calc_chksum(); - + if (chk_calc != chk_read) { ERROR_LOG(GDB_STUB, "gdb: invalid checksum: calculated %02x and read %02x for $%s# (length: %d)\n", chk_calc, chk_read, cmd_bfr, cmd_len); cmd_len = 0; - + gdb_nak(); return; } - + DEBUG_LOG(GDB_STUB, "gdb: read command %c with a length of %d: %s\n", cmd_bfr[0], cmd_len, cmd_bfr); gdb_ack(); } @@ -295,19 +295,19 @@ static void gdb_read_command() static int gdb_data_available() { struct timeval t; fd_set _fds, *fds = &_fds; - + FD_ZERO(fds); FD_SET(sock, fds); - + t.tv_sec = 0; t.tv_usec = 20; - + if (select(sock + 1, fds, NULL, NULL, &t) < 0) { ERROR_LOG(GDB_STUB, "select failed"); return 0; } - + if (FD_ISSET(sock, fds)) return 1; return 0; @@ -319,18 +319,18 @@ static void gdb_reply(const char *reply) u32 left; u8 *ptr; int n; - + if(!gdb_active()) return; - + memset(cmd_bfr, 0, sizeof cmd_bfr); - + cmd_len = strlen(reply); if (cmd_len + 4 > sizeof cmd_bfr) ERROR_LOG(GDB_STUB, "cmd_bfr overflow in gdb_reply"); - + memcpy(cmd_bfr + 1, reply, cmd_len); - + cmd_len++; chk = gdb_calc_chksum(); cmd_len--; @@ -338,9 +338,9 @@ static void gdb_reply(const char *reply) cmd_bfr[cmd_len + 1] = GDB_STUB_END; cmd_bfr[cmd_len + 2] = nibble2hex(chk >> 4); cmd_bfr[cmd_len + 3] = nibble2hex(chk); - + DEBUG_LOG(GDB_STUB, "gdb: reply (len: %d): %s\n", cmd_len, cmd_bfr); - + ptr = cmd_bfr; left = cmd_len + 4; while (left > 0) { @@ -358,12 +358,12 @@ static void gdb_reply(const char *reply) static void gdb_handle_query() { DEBUG_LOG(GDB_STUB, "gdb: query '%s'\n", cmd_bfr+1); - + if (!strcmp((const char *)(cmd_bfr+1), "TStatus")) { return gdb_reply("T0"); } - + gdb_reply(""); } @@ -403,10 +403,10 @@ static u32 re32hex(u8 *p) { u32 i; u32 res = 0; - + for (i = 0; i < 8; i++) res = (res << 4) | hex2char(p[i]); - + return res; } @@ -414,10 +414,10 @@ static u64 re64hex(u8 *p) { u32 i; u64 res = 0; - + for (i = 0; i < 16; i++) res = (res << 4) | hex2char(p[i]); - + return res; } @@ -425,7 +425,7 @@ static void gdb_read_register() { static u8 reply[64]; u32 id; - + memset(reply, 0, sizeof reply); id = hex2char(cmd_bfr[1]); if (cmd_bfr[2] != '\0') @@ -433,8 +433,8 @@ static void gdb_read_register() id <<= 4; id |= hex2char(cmd_bfr[2]); } - - + + switch (id) { case 0 ... 31: wbe32hex(reply, GPR(id)); @@ -470,7 +470,7 @@ static void gdb_read_register() return gdb_reply("E01"); break; } - + gdb_reply((char *)reply); } @@ -479,14 +479,14 @@ static void gdb_read_registers() static u8 bfr[GDB_BFR_MAX - 4]; u8 * bufptr = bfr; u32 i; - + memset(bfr, 0, sizeof bfr); - + for (i = 0; i < 32; i++) { wbe32hex(bufptr + i*8, GPR(i)); } bufptr += 32 * 8; - + /* for (i = 0; i < 32; i++) { wbe32hex(bufptr + i*8, riPS0(i)); @@ -496,15 +496,15 @@ static void gdb_read_registers() wbe32hex(bufptr, MSR); bufptr += 4; wbe32hex(bufptr, GetCR()); bufptr += 4; wbe32hex(bufptr, LR); bufptr += 4; - - + + wbe32hex(bufptr, CTR); bufptr += 4; wbe32hex(bufptr, PowerPC::ppcState.spr[SPR_XER]); bufptr += 4; // MQ register not used. wbe32hex(bufptr, 0x0BADC0DE); bufptr += 4; */ - - + + gdb_reply((char *)bfr); } @@ -512,21 +512,21 @@ static void gdb_write_registers() { u32 i; u8 * bufptr = cmd_bfr; - + for (i = 0; i < 32; i++) { GPR(i) = re32hex(bufptr + i*8); } bufptr += 32 * 8; - + gdb_reply("OK"); } static void gdb_write_register() { u32 id; - + u8 * bufptr = cmd_bfr + 3; - + id = hex2char(cmd_bfr[1]); if (cmd_bfr[2] != '=') { @@ -534,7 +534,7 @@ static void gdb_write_register() id <<= 4; id |= hex2char(cmd_bfr[2]); } - + switch (id) { case 0 ... 31: GPR(id) = re32hex(bufptr); @@ -570,7 +570,7 @@ static void gdb_write_register() return gdb_reply("E01"); break; } - + gdb_reply("OK"); } @@ -579,18 +579,18 @@ static void gdb_read_mem() static u8 reply[GDB_BFR_MAX - 4]; u32 addr, len; u32 i; - + i = 1; addr = 0; while (cmd_bfr[i] != ',') addr = (addr << 4) | hex2char(cmd_bfr[i++]); i++; - + len = 0; while (i < cmd_len) len = (len << 4) | hex2char(cmd_bfr[i++]); DEBUG_LOG(GDB_STUB, "gdb: read memory: %08x bytes from %08x\n", len, addr); - + if (len*2 > sizeof reply) gdb_reply("E01"); u8 * data = Memory::GetPointer(addr); @@ -598,25 +598,25 @@ static void gdb_read_mem() return gdb_reply("E0"); mem2hex(reply, data, len); reply[len*2] = '\0'; - gdb_reply((char *)reply); + gdb_reply((char *)reply); } static void gdb_write_mem() { u32 addr, len; u32 i; - + i = 1; addr = 0; while (cmd_bfr[i] != ',') addr = (addr << 4) | hex2char(cmd_bfr[i++]); i++; - + len = 0; while (cmd_bfr[i] != ':') len = (len << 4) | hex2char(cmd_bfr[i++]); DEBUG_LOG(GDB_STUB, "gdb: write memory: %08x bytes to %08x\n", len, addr); - + u8 * dst = Memory::GetPointer(addr); if (!dst) return gdb_reply("E00"); @@ -647,11 +647,11 @@ bool gdb_add_bp(u32 type, u32 addr, u32 len) bp = gdb_bp_empty_slot(type); if (bp == NULL) return false; - + bp->active = 1; bp->addr = addr; bp->len = len; - + DEBUG_LOG(GDB_STUB, "gdb: added %d breakpoint: %08x bytes at %08x\n", type, bp->len, bp->addr); return true; } @@ -660,7 +660,7 @@ static void _gdb_add_bp() { u32 type; u32 i, addr = 0, len = 0; - + type = hex2char(cmd_bfr[1]); switch (type) { case 0: @@ -679,15 +679,15 @@ static void _gdb_add_bp() default: return gdb_reply("E01"); } - + i = 3; while (cmd_bfr[i] != ',') addr = addr << 4 | hex2char(cmd_bfr[i++]); i++; - + while (i < cmd_len) len = len << 4 | hex2char(cmd_bfr[i++]); - + if (!gdb_add_bp(type, addr, len)) return gdb_reply("E02"); gdb_reply("OK"); @@ -696,7 +696,7 @@ static void _gdb_add_bp() static void gdb_remove_bp() { u32 type, addr, len, i; - + type = hex2char(cmd_bfr[1]); switch (type) { case 0: @@ -715,18 +715,18 @@ static void gdb_remove_bp() default: return gdb_reply("E01"); } - + addr = 0; len = 0; - + i = 3; while (cmd_bfr[i] != ',') addr = (addr << 4) | hex2char(cmd_bfr[i++]); i++; - + while (i < cmd_len) len = (len << 4) | hex2char(cmd_bfr[i++]); - + gdb_bp_remove(type, addr, len); gdb_reply("OK"); } @@ -739,7 +739,7 @@ void gdb_handle_exception() gdb_read_command(); if (cmd_len == 0) continue; - + switch(cmd_bfr[0]) { case 'q': gdb_handle_query(); @@ -807,38 +807,38 @@ void gdb_init(u32 port) #ifdef _WIN32 WSAStartup(MAKEWORD(2,2), &InitData); #endif - + memset(bp_x, 0, sizeof bp_x); memset(bp_r, 0, sizeof bp_r); memset(bp_w, 0, sizeof bp_w); memset(bp_a, 0, sizeof bp_a); - + tmpsock = socket(AF_INET, SOCK_STREAM, 0); if (tmpsock == -1) ERROR_LOG(GDB_STUB, "Failed to create gdb socket"); - + on = 1; if (setsockopt(tmpsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on) < 0) ERROR_LOG(GDB_STUB, "Failed to setsockopt"); - + memset(&saddr_server, 0, sizeof saddr_server); saddr_server.sin_family = AF_INET; saddr_server.sin_port = htons(port); saddr_server.sin_addr.s_addr = INADDR_ANY; - + if (bind(tmpsock, (struct sockaddr *)&saddr_server, sizeof saddr_server) < 0) ERROR_LOG(GDB_STUB, "Failed to bind gdb socket"); - + if (listen(tmpsock, 1) < 0) ERROR_LOG(GDB_STUB, "Failed to listen to gdb socket"); - + INFO_LOG(GDB_STUB, "Waiting for gdb to connect...\n"); - + sock = accept(tmpsock, (struct sockaddr *)&saddr_client, &len); if (sock < 0) ERROR_LOG(GDB_STUB, "Failed to accept gdb client"); INFO_LOG(GDB_STUB, "Client connected.\n"); - + saddr_client.sin_addr.s_addr = ntohl(saddr_client.sin_addr.s_addr); /*if (((saddr_client.sin_addr.s_addr >> 24) & 0xff) != 127 || * ((saddr_client.sin_addr.s_addr >> 16) & 0xff) != 0 || @@ -863,7 +863,7 @@ void gdb_deinit() shutdown(sock, SHUT_RDWR); sock = -1; } - + #ifdef _WIN32 WSACleanup(); #endif @@ -878,14 +878,14 @@ int gdb_signal(u32 s) { if (sock == -1) return 1; - + sig = s; - + if (send_signal) { gdb_handle_signal(); send_signal = 0; } - + return 0; } @@ -893,15 +893,15 @@ int gdb_bp_x(u32 addr) { if (sock == -1) return 0; - + if (step_break) { step_break = 0; - + DEBUG_LOG(GDB_STUB, "Step was successful."); return 1; } - + return gdb_bp_check(addr, GDB_BP_TYPE_X); } @@ -909,7 +909,7 @@ int gdb_bp_r(u32 addr) { if (sock == -1) return 0; - + return gdb_bp_check(addr, GDB_BP_TYPE_R); } @@ -917,7 +917,7 @@ int gdb_bp_w(u32 addr) { if (sock == -1) return 0; - + return gdb_bp_check(addr, GDB_BP_TYPE_W); } @@ -925,6 +925,6 @@ int gdb_bp_a(u32 addr) { if (sock == -1) return 0; - + return gdb_bp_check(addr, GDB_BP_TYPE_A); } diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp index af7325c365..ca98489fd3 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp @@ -113,28 +113,28 @@ int Interpreter::SingleStepInner(void) { #ifdef USE_GDBSTUB if (gdb_active() && gdb_bp_x(PC)) { - + Host_UpdateDisasmDialog(); - + gdb_signal(SIGTRAP); gdb_handle_exception(); } #endif - + NPC = PC + sizeof(UGeckoInstruction); instCode.hex = Memory::Read_Opcode(PC); - + // Uncomment to trace the interpreter //if ((PC & 0xffffff)>=0x0ab54c && (PC & 0xffffff)<=0x0ab624) // startTrace = 1; //else // startTrace = 0; - + if (startTrace) { Trace(instCode); } - + if (instCode.hex != 0) { UReg_MSR& msr = (UReg_MSR&)MSR; @@ -176,7 +176,7 @@ int Interpreter::SingleStepInner(void) } last_pc = PC; PC = NPC; - + #if defined(_DEBUG) || defined(DEBUGFAST) if (PowerPC::ppcState.gpr[1] == 0) { @@ -191,9 +191,9 @@ int Interpreter::SingleStepInner(void) } void Interpreter::SingleStep() -{ +{ SingleStepInner(); - + CoreTiming::slicelength = 1; CoreTiming::downcount = 0; CoreTiming::Advance(); @@ -240,8 +240,8 @@ void Interpreter::Run() if (PCVec.size() > ShowSteps) PCVec.erase(PCVec.begin()); #endif - - + + //2: check for breakpoint if (PowerPC::breakpoints.IsAddressBreakPoint(PC)) { diff --git a/Source/Core/Core/Src/ec_wii.cpp b/Source/Core/Core/Src/ec_wii.cpp index 0bf42f1284..eebde66ab6 100644 --- a/Source/Core/Core/Src/ec_wii.cpp +++ b/Source/Core/Core/Src/ec_wii.cpp @@ -48,7 +48,7 @@ void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, c NG_priv = default_NG_priv; NG_sig = default_NG_sig; } - + sprintf(name, "NG%08x", NG_id); make_blanksig_ec_cert(ng_cert_out, "Root-CA00000001-MS00000002", name, NG_priv, NG_key_id); memcpy(ng_cert_out + 4, NG_sig, 60); @@ -71,29 +71,29 @@ void get_ap_sig_and_cert(u8 *sig_out, u8 *ap_cert_out, u64 title_id, u8 *data, u u8 ap_priv[30]; char signer[64]; char name[64]; - + if((NG_id==0)||(NG_priv == NULL)) { NG_priv = default_NG_priv; NG_id = default_NG_id; } - - + + memset(ap_priv, 0, 0x1e); ap_priv[0x1d] = 1; // setup random ap_priv here if desired // get_rand_bytes(ap_priv, 0x1e); // ap_priv[0] &= 1; - + memset(ap_cert_out+4, 0, 60); - + sprintf(signer, "Root-CA00000001-MS00000002-NG%08x", NG_id); sprintf(name, "AP%08x%08x", (u32)(title_id>>32), (u32)(title_id&0xffffffff)); make_blanksig_ec_cert(ap_cert_out, signer, name, ap_priv, 0); - + sha1(ap_cert_out + 0x80, 0x100, hash); generate_ecdsa(ap_cert_out+4, ap_cert_out+34, NG_priv, hash); - + sha1(data, data_size, hash); generate_ecdsa(sig_out, sig_out + 30, ap_priv, hash); } @@ -102,7 +102,7 @@ void make_blanksig_ec_cert(u8 *cert_out, const char *signer, const char *name, c { memset(cert_out, 0, 0x180); *(u32*)cert_out = Common::swap32(0x10002); - + strncpy((char*)cert_out + 0x80, signer, 0x40); *(u32*)(cert_out + 0xc0) = Common::swap32(2); strncpy((char*)cert_out + 0xc4, name, 0x40); @@ -123,12 +123,12 @@ void get_shared_secret(u8* shared_secret_out, u8* remote_public_key, u8* NG_priv { NG_priv = default_NG_priv; } - + // required point_mul in Source/Core/Common/Src/Crypto/ec.cpp // to be made non-static - + point_mul(shared_secret_out, NG_priv, remote_public_key); - + } EcWii::EcWii() @@ -143,7 +143,7 @@ EcWii::EcWii() if(keys_f.ReadBytes(&BootMiiKeysBin, sizeof(BootMiiKeysBin))) { init = false; - + INFO_LOG(WII_IPC_ES, "Successfully loaded keys.bin created by: %s", BootMiiKeysBin.creator); } else @@ -159,8 +159,8 @@ EcWii::EcWii() else { ERROR_LOG(WII_IPC_ES, "%s could not be found. Using default values. We recommend you grab keys.bin from BootMii.", keys_path.c_str()); - } - + } + if(init) InitDefaults(); } @@ -172,10 +172,10 @@ EcWii::~EcWii() void EcWii::InitDefaults() { memset(&BootMiiKeysBin, 0, sizeof(BootMiiKeysBin)); - + BootMiiKeysBin.ng_id = Common::swap32(default_NG_id); BootMiiKeysBin.ng_key_id = Common::swap32(default_NG_key_id); - + memcpy(BootMiiKeysBin.ng_priv, default_NG_priv, sizeof(BootMiiKeysBin.ng_priv)); memcpy(BootMiiKeysBin.ng_sig, default_NG_sig, sizeof(BootMiiKeysBin.ng_sig)); } diff --git a/Source/Core/Core/Src/ec_wii.h b/Source/Core/Core/Src/ec_wii.h index 263343fceb..b50efe9570 100644 --- a/Source/Core/Core/Src/ec_wii.h +++ b/Source/Core/Core/Src/ec_wii.h @@ -4,16 +4,16 @@ // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt /* - * + * * Structs for keys.bin taken from: - * + * * mini - a Free Software replacement for the Nintendo/BroadOn IOS. * crypto hardware support - * + * * Copyright (C) 2008, 2009 Haxx Enterprises * Copyright (C) 2008, 2009 Sven Peter * Copyright (C) 2008, 2009 Hector Martin "marcan" - * + * * # This code is licensed to you under the terms of the GNU GPL, version 2; * # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ @@ -43,7 +43,7 @@ public: const u8* getNgSig() {return BootMiiKeysBin.ng_sig;}; private: void InitDefaults(); - + #pragma pack(push,1) typedef struct { @@ -55,11 +55,11 @@ private: u16 checksum; } #ifndef _WIN32 - __attribute__((packed)) + __attribute__((packed)) #endif eep_ctr_t; - - struct + + struct { u8 creator [0x100]; // 0x000 u8 boot1_hash [ 0x14]; // 0x100 @@ -68,7 +68,7 @@ private: union { struct { u8 ng_priv [ 0x1e]; // 0x128 - u8 pad1 [ 0x12]; + u8 pad1 [ 0x12]; }; struct { u8 pad2 [ 0x1c]; @@ -80,7 +80,7 @@ private: u32 unk1; //0x178 u32 unk2; //0x17C u8 eeprom_pad [ 0x80]; //0x180 - + u32 ms_id; //0x200 u32 ca_id; //0x204 u32 ng_key_id; //0x208 @@ -91,19 +91,19 @@ private: u8 pad3 [ 0x74]; //0x284 u16 prng_seed [ 0x02]; //0x2F8 u8 pad4 [ 0x04]; //0x2FC - + u8 crack_pad [0x100]; //0x300 - - } - + + } + #ifndef _WIN32 - __attribute__((packed)) + __attribute__((packed)) #endif - + BootMiiKeysBin; - + #pragma pack(pop) - + }; #endif