mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #4784 from leoetlino/mios
IOS: Implement MIOS functionality
This commit is contained in:
@@ -37,6 +37,7 @@ public:
|
||||
// Returns true if a map file exists, false if none could be found.
|
||||
static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file,
|
||||
std::string* title_id = nullptr);
|
||||
static bool LoadMapFromFilename();
|
||||
|
||||
private:
|
||||
static bool DVDRead(u64 dvd_offset, u32 output_address, u32 length, bool decrypt);
|
||||
@@ -44,7 +45,6 @@ private:
|
||||
|
||||
static void UpdateDebugger_MapLoaded();
|
||||
|
||||
static bool LoadMapFromFilename();
|
||||
static bool Boot_ELF(const std::string& filename);
|
||||
static bool Boot_WiiWAD(const std::string& filename);
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ bool CBoot::SetupWiiMemory(u64 ios_title_id)
|
||||
Memory::Write_U16(0x8201, 0x000030e6); // Dev console / debug capable
|
||||
Memory::Write_U32(0x00000000, 0x000030f0); // Apploader
|
||||
|
||||
if (!IOS::HLE::SetupMemory(ios_title_id))
|
||||
if (!IOS::HLE::Reload(ios_title_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ const char* ElfReader::GetSectionName(int section) const
|
||||
}
|
||||
|
||||
// This is just a simple elf loader, good enough to load elfs generated by devkitPPC
|
||||
bool ElfReader::LoadIntoMemory()
|
||||
bool ElfReader::LoadIntoMemory(bool only_in_mem1)
|
||||
{
|
||||
INFO_LOG(MASTER_LOG, "String section: %i", header->e_shstrndx);
|
||||
|
||||
@@ -133,6 +133,9 @@ bool ElfReader::LoadIntoMemory()
|
||||
u32 srcSize = p->p_filesz;
|
||||
u32 dstSize = p->p_memsz;
|
||||
|
||||
if (only_in_mem1 && p->p_vaddr >= Memory::REALRAM_SIZE)
|
||||
continue;
|
||||
|
||||
Memory::CopyToEmu(writeAddr, src, srcSize);
|
||||
if (srcSize < dstSize)
|
||||
Memory::Memset(writeAddr + srcSize, 0, dstSize - srcSize); // zero out bss
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); }
|
||||
u32 GetEntryPoint() const { return entryPoint; }
|
||||
u32 GetFlags() const { return (u32)(header->e_flags); }
|
||||
bool LoadIntoMemory();
|
||||
bool LoadIntoMemory(bool only_in_mem1 = false);
|
||||
bool LoadSymbols();
|
||||
|
||||
int GetNumSegments() const { return (int)(header->e_phnum); }
|
||||
|
||||
@@ -140,6 +140,7 @@ set(SRCS ActionReplay.cpp
|
||||
IOS/Device.cpp
|
||||
IOS/DeviceStub.cpp
|
||||
IOS/IPC.cpp
|
||||
IOS/MIOS.cpp
|
||||
IOS/DI/DI.cpp
|
||||
IOS/ES/ES.cpp
|
||||
IOS/ES/Formats.cpp
|
||||
|
||||
@@ -188,6 +188,7 @@ struct SConfig : NonCopyable
|
||||
BOOT_ELF,
|
||||
BOOT_DOL,
|
||||
BOOT_WII_NAND,
|
||||
BOOT_MIOS,
|
||||
BOOT_BS2,
|
||||
BOOT_DFF
|
||||
};
|
||||
|
||||
@@ -528,9 +528,11 @@ void EmuThread()
|
||||
Wiimote::LoadConfig();
|
||||
|
||||
// Activate Wiimotes which don't have source set to "None"
|
||||
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
|
||||
IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
for (unsigned int i = 0; i != MAX_BBMOTES; ++i)
|
||||
if (g_wiimote_sources[i])
|
||||
IOS::HLE::GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(true);
|
||||
if (g_wiimote_sources[i] && bt)
|
||||
bt->AccessWiiMote(i | 0x100)->Activate(true);
|
||||
}
|
||||
|
||||
AudioCommon::InitSoundStream();
|
||||
@@ -632,10 +634,6 @@ void EmuThread()
|
||||
|
||||
FileMon::Close();
|
||||
|
||||
// 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()
|
||||
s_hardware_initialized = false;
|
||||
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
|
||||
|
||||
@@ -172,6 +172,7 @@
|
||||
<ClCompile Include="IOS\Device.cpp" />
|
||||
<ClCompile Include="IOS\DeviceStub.cpp" />
|
||||
<ClCompile Include="IOS\IPC.cpp" />
|
||||
<ClCompile Include="IOS\MIOS.cpp" />
|
||||
<ClCompile Include="IOS\DI\DI.cpp" />
|
||||
<ClCompile Include="IOS\ES\ES.cpp" />
|
||||
<ClCompile Include="IOS\ES\Formats.cpp" />
|
||||
@@ -408,6 +409,7 @@
|
||||
<ClInclude Include="IOS\Device.h" />
|
||||
<ClInclude Include="IOS\DeviceStub.h" />
|
||||
<ClInclude Include="IOS\IPC.h" />
|
||||
<ClInclude Include="IOS\MIOS.h" />
|
||||
<ClInclude Include="IOS\DI\DI.h" />
|
||||
<ClInclude Include="IOS\ES\ES.h" />
|
||||
<ClInclude Include="IOS\ES\Formats.h" />
|
||||
|
||||
@@ -752,6 +752,9 @@
|
||||
<ClCompile Include="IOS\IPC.cpp">
|
||||
<Filter>IOS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOS\MIOS.cpp">
|
||||
<Filter>IOS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOS\Network\Net.cpp">
|
||||
<Filter>IOS\Network</Filter>
|
||||
</ClCompile>
|
||||
@@ -1419,6 +1422,9 @@
|
||||
<ClInclude Include="IOS\IPC.h">
|
||||
<Filter>IOS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOS\MIOS.h">
|
||||
<Filter>IOS</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
|
||||
@@ -364,6 +364,16 @@ void LogPendingEvents()
|
||||
}
|
||||
}
|
||||
|
||||
// Should only be called from the CPU thread after the PPC clock has changed
|
||||
void AdjustEventQueueTimes(u32 new_ppc_clock, u32 old_ppc_clock)
|
||||
{
|
||||
for (Event& ev : s_event_queue)
|
||||
{
|
||||
const s64 ticks = (ev.time - g_global_timer) * new_ppc_clock / old_ppc_clock;
|
||||
ev.time = g_global_timer + ticks;
|
||||
}
|
||||
}
|
||||
|
||||
void Idle()
|
||||
{
|
||||
if (SConfig::GetInstance().bSyncGPUOnSkipIdleHack)
|
||||
|
||||
@@ -91,6 +91,8 @@ void LogPendingEvents();
|
||||
|
||||
std::string GetScheduledEventsSummary();
|
||||
|
||||
void AdjustEventQueueTimes(u32 new_ppc_clock, u32 old_ppc_clock);
|
||||
|
||||
u32 GetFakeDecStartValue();
|
||||
void SetFakeDecStartValue(u32 val);
|
||||
u64 GetFakeDecStartTicks();
|
||||
|
||||
@@ -177,6 +177,13 @@ DSPEmulator* GetDSPEmulator()
|
||||
}
|
||||
|
||||
void Init(bool hle)
|
||||
{
|
||||
Reinit(hle);
|
||||
s_et_GenerateDSPInterrupt = CoreTiming::RegisterEvent("DSPint", GenerateDSPInterrupt);
|
||||
s_et_CompleteARAM = CoreTiming::RegisterEvent("ARAMint", CompleteARAM);
|
||||
}
|
||||
|
||||
void Reinit(bool hle)
|
||||
{
|
||||
s_dsp_emulator = CreateDSPEmulator(hle);
|
||||
s_dsp_is_lle = s_dsp_emulator->IsLLE();
|
||||
@@ -206,9 +213,6 @@ void Init(bool hle)
|
||||
s_ARAM_Info.Hex = 0;
|
||||
s_AR_MODE = 1; // ARAM Controller has init'd
|
||||
s_AR_REFRESH = 156; // 156MHz
|
||||
|
||||
s_et_GenerateDSPInterrupt = CoreTiming::RegisterEvent("DSPint", GenerateDSPInterrupt);
|
||||
s_et_CompleteARAM = CoreTiming::RegisterEvent("ARAMint", CompleteARAM);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
|
||||
@@ -60,6 +60,7 @@ union UDSPControl
|
||||
};
|
||||
|
||||
void Init(bool hle);
|
||||
void Reinit(bool hle);
|
||||
void Shutdown();
|
||||
|
||||
void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
|
||||
|
||||
@@ -37,6 +37,12 @@ static bool s_request_disable_thread;
|
||||
|
||||
DSPLLE::DSPLLE() = default;
|
||||
|
||||
DSPLLE::~DSPLLE()
|
||||
{
|
||||
DSPCore_Shutdown();
|
||||
DSP_StopSoundStream();
|
||||
}
|
||||
|
||||
void DSPLLE::DoState(PointerWrap& p)
|
||||
{
|
||||
bool is_hle = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ class DSPLLE : public DSPEmulator
|
||||
{
|
||||
public:
|
||||
DSPLLE();
|
||||
~DSPLLE();
|
||||
|
||||
bool Initialize(bool wii, bool dsp_thread) override;
|
||||
void Shutdown() override;
|
||||
|
||||
@@ -419,8 +419,24 @@ void Init()
|
||||
{
|
||||
DVDThread::Start();
|
||||
|
||||
s_DISR.Hex = 0;
|
||||
Reset();
|
||||
s_DICVR.Hex = 1; // Disc Channel relies on cover being open when no disc is inserted
|
||||
s_disc_inside = false;
|
||||
|
||||
s_eject_disc = CoreTiming::RegisterEvent("EjectDisc", EjectDiscCallback);
|
||||
s_insert_disc = CoreTiming::RegisterEvent("InsertDisc", InsertDiscCallback);
|
||||
|
||||
s_finish_executing_command =
|
||||
CoreTiming::RegisterEvent("FinishExecutingCommand", FinishExecutingCommandCallback);
|
||||
|
||||
u64 userdata = PackFinishExecutingCommandUserdata(ReplyType::DTK, DIInterruptType::INT_TCINT);
|
||||
CoreTiming::ScheduleEvent(0, s_finish_executing_command, userdata);
|
||||
}
|
||||
|
||||
// This doesn't reset any inserted disc or the cover state.
|
||||
void Reset()
|
||||
{
|
||||
s_DISR.Hex = 0;
|
||||
s_DICMDBUF[0].Hex = 0;
|
||||
s_DICMDBUF[1].Hex = 0;
|
||||
s_DICMDBUF[2].Hex = 0;
|
||||
@@ -441,7 +457,6 @@ void Init()
|
||||
s_pending_samples = 0;
|
||||
|
||||
s_error_code = 0;
|
||||
s_disc_inside = false;
|
||||
|
||||
// The buffer is empty at start
|
||||
s_read_buffer_start_offset = 0;
|
||||
@@ -450,15 +465,6 @@ void Init()
|
||||
s_read_buffer_end_time = 0;
|
||||
|
||||
s_disc_path_to_insert.clear();
|
||||
|
||||
s_eject_disc = CoreTiming::RegisterEvent("EjectDisc", EjectDiscCallback);
|
||||
s_insert_disc = CoreTiming::RegisterEvent("InsertDisc", InsertDiscCallback);
|
||||
|
||||
s_finish_executing_command =
|
||||
CoreTiming::RegisterEvent("FinishExecutingCommand", FinishExecutingCommandCallback);
|
||||
|
||||
u64 userdata = PackFinishExecutingCommandUserdata(ReplyType::DTK, DIInterruptType::INT_TCINT);
|
||||
CoreTiming::ScheduleEvent(0, s_finish_executing_command, userdata);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
|
||||
@@ -102,6 +102,7 @@ enum class ReplyType : u32
|
||||
};
|
||||
|
||||
void Init();
|
||||
void Reset();
|
||||
void Shutdown();
|
||||
void DoState(PointerWrap& p);
|
||||
|
||||
|
||||
@@ -232,7 +232,10 @@ void CEXIIPL::SetCS(int _iCS)
|
||||
|
||||
void CEXIIPL::UpdateRTC()
|
||||
{
|
||||
u32 epoch = SConfig::GetInstance().bWii ? WII_EPOCH : GC_EPOCH;
|
||||
u32 epoch =
|
||||
(SConfig::GetInstance().bWii || SConfig::GetInstance().m_BootType == SConfig::BOOT_MIOS) ?
|
||||
WII_EPOCH :
|
||||
GC_EPOCH;
|
||||
u32 rtc = Common::swap32(GetEmulatedTime(epoch));
|
||||
std::memcpy(m_RTC, &rtc, sizeof(u32));
|
||||
}
|
||||
|
||||
@@ -61,12 +61,11 @@ void Init()
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
// IOS should always be shut down regardless of bWii because it can be running in GC mode (MIOS).
|
||||
IOS::HLE::Shutdown(); // Depends on Memory
|
||||
IOS::Shutdown();
|
||||
if (SConfig::GetInstance().bWii)
|
||||
{
|
||||
IOS::HLE::Shutdown(); // Depends on Memory
|
||||
IOS::Shutdown();
|
||||
Core::ShutdownWiiRoot();
|
||||
}
|
||||
|
||||
SystemTimers::Shutdown();
|
||||
CPU::Shutdown();
|
||||
|
||||
@@ -223,10 +223,17 @@ static void ThrottleCallback(u64 last_time, s64 cyclesLate)
|
||||
// SystemTimers::Init
|
||||
void PreInit()
|
||||
{
|
||||
if (SConfig::GetInstance().bWii)
|
||||
ChangePPCClock(SConfig::GetInstance().bWii ? Mode::Wii : Mode::GC);
|
||||
}
|
||||
|
||||
void ChangePPCClock(Mode mode)
|
||||
{
|
||||
const u32 previous_clock = s_cpu_core_clock;
|
||||
if (mode == Mode::Wii)
|
||||
s_cpu_core_clock = 729000000u;
|
||||
else
|
||||
s_cpu_core_clock = 486000000u;
|
||||
CoreTiming::AdjustEventQueueTimes(s_cpu_core_clock, previous_clock);
|
||||
}
|
||||
|
||||
void Init()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user