Merge pull request #11629 from AdmiralCurtiss/globals-hsp
HW/HSP: Refactor to class, move to System.
This commit is contained in:
commit
0461fae99e
|
@ -610,7 +610,7 @@ static void Do_ARAM_DMA()
|
||||||
{
|
{
|
||||||
while (state.aram_dma.Cnt.count)
|
while (state.aram_dma.Cnt.count)
|
||||||
{
|
{
|
||||||
memory.Write_U64(HSP::Read(state.aram_dma.ARAddr), state.aram_dma.MMAddr);
|
memory.Write_U64(system.GetHSP().Read(state.aram_dma.ARAddr), state.aram_dma.MMAddr);
|
||||||
state.aram_dma.MMAddr += 8;
|
state.aram_dma.MMAddr += 8;
|
||||||
state.aram_dma.ARAddr += 8;
|
state.aram_dma.ARAddr += 8;
|
||||||
state.aram_dma.Cnt.count -= 8;
|
state.aram_dma.Cnt.count -= 8;
|
||||||
|
@ -662,7 +662,7 @@ static void Do_ARAM_DMA()
|
||||||
{
|
{
|
||||||
while (state.aram_dma.Cnt.count)
|
while (state.aram_dma.Cnt.count)
|
||||||
{
|
{
|
||||||
HSP::Write(state.aram_dma.ARAddr, memory.Read_U64(state.aram_dma.MMAddr));
|
system.GetHSP().Write(state.aram_dma.ARAddr, memory.Read_U64(state.aram_dma.MMAddr));
|
||||||
|
|
||||||
state.aram_dma.MMAddr += 8;
|
state.aram_dma.MMAddr += 8;
|
||||||
state.aram_dma.ARAddr += 8;
|
state.aram_dma.ARAddr += 8;
|
||||||
|
|
|
@ -11,58 +11,59 @@
|
||||||
|
|
||||||
namespace HSP
|
namespace HSP
|
||||||
{
|
{
|
||||||
static std::unique_ptr<IHSPDevice> s_device;
|
HSPManager::HSPManager() = default;
|
||||||
|
HSPManager::~HSPManager() = default;
|
||||||
|
|
||||||
void Init()
|
void HSPManager::Init()
|
||||||
{
|
{
|
||||||
AddDevice(Config::Get(Config::MAIN_HSP_DEVICE));
|
AddDevice(Config::Get(Config::MAIN_HSP_DEVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void HSPManager::Shutdown()
|
||||||
{
|
{
|
||||||
RemoveDevice();
|
RemoveDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 Read(u32 address)
|
u64 HSPManager::Read(u32 address)
|
||||||
{
|
{
|
||||||
DEBUG_LOG_FMT(HSP, "HSP read from 0x{:08x}", address);
|
DEBUG_LOG_FMT(HSP, "HSP read from 0x{:08x}", address);
|
||||||
if (s_device)
|
if (m_device)
|
||||||
return s_device->Read(address);
|
return m_device->Read(address);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write(u32 address, u64 value)
|
void HSPManager::Write(u32 address, u64 value)
|
||||||
{
|
{
|
||||||
DEBUG_LOG_FMT(HSP, "HSP write to 0x{:08x}: 0x{:016x}", address, value);
|
DEBUG_LOG_FMT(HSP, "HSP write to 0x{:08x}: 0x{:016x}", address, value);
|
||||||
if (s_device)
|
if (m_device)
|
||||||
s_device->Write(address, value);
|
m_device->Write(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoState(PointerWrap& p)
|
void HSPManager::DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
HSPDeviceType type = s_device->GetDeviceType();
|
HSPDeviceType type = m_device->GetDeviceType();
|
||||||
p.Do(type);
|
p.Do(type);
|
||||||
|
|
||||||
// If the type doesn't match, switch to the right device type
|
// If the type doesn't match, switch to the right device type
|
||||||
if (type != s_device->GetDeviceType())
|
if (type != m_device->GetDeviceType())
|
||||||
AddDevice(type);
|
AddDevice(type);
|
||||||
|
|
||||||
s_device->DoState(p);
|
m_device->DoState(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDevice(std::unique_ptr<IHSPDevice> device)
|
void HSPManager::AddDevice(std::unique_ptr<IHSPDevice> device)
|
||||||
{
|
{
|
||||||
// Set the new one
|
// Set the new one
|
||||||
s_device = std::move(device);
|
m_device = std::move(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDevice(const HSPDeviceType device)
|
void HSPManager::AddDevice(const HSPDeviceType device)
|
||||||
{
|
{
|
||||||
AddDevice(HSPDevice_Create(device));
|
AddDevice(HSPDevice_Create(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveDevice()
|
void HSPManager::RemoveDevice()
|
||||||
{
|
{
|
||||||
s_device.reset();
|
m_device.reset();
|
||||||
}
|
}
|
||||||
} // namespace HSP
|
} // namespace HSP
|
||||||
|
|
|
@ -14,6 +14,16 @@ namespace HSP
|
||||||
class IHSPDevice;
|
class IHSPDevice;
|
||||||
enum class HSPDeviceType : int;
|
enum class HSPDeviceType : int;
|
||||||
|
|
||||||
|
class HSPManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HSPManager();
|
||||||
|
HSPManager(const HSPManager& other) = delete;
|
||||||
|
HSPManager(HSPManager&& other) = delete;
|
||||||
|
HSPManager& operator=(const HSPManager& other) = delete;
|
||||||
|
HSPManager& operator=(HSPManager&& other) = delete;
|
||||||
|
~HSPManager();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
|
@ -25,4 +35,8 @@ void DoState(PointerWrap& p);
|
||||||
void RemoveDevice();
|
void RemoveDevice();
|
||||||
void AddDevice(std::unique_ptr<IHSPDevice> device);
|
void AddDevice(std::unique_ptr<IHSPDevice> device);
|
||||||
void AddDevice(HSPDeviceType device);
|
void AddDevice(HSPDeviceType device);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<IHSPDevice> m_device;
|
||||||
|
};
|
||||||
} // namespace HSP
|
} // namespace HSP
|
||||||
|
|
|
@ -45,7 +45,7 @@ void Init(const Sram* override_sram)
|
||||||
SerialInterface::Init();
|
SerialInterface::Init();
|
||||||
system.GetProcessorInterface().Init();
|
system.GetProcessorInterface().Init();
|
||||||
ExpansionInterface::Init(override_sram); // Needs to be initialized before Memory
|
ExpansionInterface::Init(override_sram); // Needs to be initialized before Memory
|
||||||
HSP::Init();
|
system.GetHSP().Init();
|
||||||
system.GetMemory().Init(); // Needs to be initialized before AddressSpace
|
system.GetMemory().Init(); // Needs to be initialized before AddressSpace
|
||||||
AddressSpace::Init();
|
AddressSpace::Init();
|
||||||
MemoryInterface::Init();
|
MemoryInterface::Init();
|
||||||
|
@ -77,7 +77,7 @@ void Shutdown()
|
||||||
MemoryInterface::Shutdown();
|
MemoryInterface::Shutdown();
|
||||||
AddressSpace::Shutdown();
|
AddressSpace::Shutdown();
|
||||||
system.GetMemory().Shutdown();
|
system.GetMemory().Shutdown();
|
||||||
HSP::Shutdown();
|
system.GetHSP().Shutdown();
|
||||||
ExpansionInterface::Shutdown();
|
ExpansionInterface::Shutdown();
|
||||||
SerialInterface::Shutdown();
|
SerialInterface::Shutdown();
|
||||||
AudioInterface::Shutdown();
|
AudioInterface::Shutdown();
|
||||||
|
@ -109,7 +109,7 @@ void DoState(PointerWrap& p)
|
||||||
p.DoMarker("ExpansionInterface");
|
p.DoMarker("ExpansionInterface");
|
||||||
AudioInterface::DoState(p);
|
AudioInterface::DoState(p);
|
||||||
p.DoMarker("AudioInterface");
|
p.DoMarker("AudioInterface");
|
||||||
HSP::DoState(p);
|
system.GetHSP().DoState(p);
|
||||||
p.DoMarker("HSP");
|
p.DoMarker("HSP");
|
||||||
|
|
||||||
if (SConfig::GetInstance().bWii)
|
if (SConfig::GetInstance().bWii)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Core/HW/DVD/DVDThread.h"
|
#include "Core/HW/DVD/DVDThread.h"
|
||||||
#include "Core/HW/EXI/EXI.h"
|
#include "Core/HW/EXI/EXI.h"
|
||||||
#include "Core/HW/GPFifo.h"
|
#include "Core/HW/GPFifo.h"
|
||||||
|
#include "Core/HW/HSP/HSP.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/HW/MemoryInterface.h"
|
#include "Core/HW/MemoryInterface.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
|
@ -52,6 +53,7 @@ struct System::Impl
|
||||||
Fifo::FifoManager m_fifo;
|
Fifo::FifoManager m_fifo;
|
||||||
GeometryShaderManager m_geometry_shader_manager;
|
GeometryShaderManager m_geometry_shader_manager;
|
||||||
GPFifo::GPFifoManager m_gp_fifo;
|
GPFifo::GPFifoManager m_gp_fifo;
|
||||||
|
HSP::HSPManager m_hsp;
|
||||||
IOS::HLE::USB::SkylanderPortal m_skylander_portal;
|
IOS::HLE::USB::SkylanderPortal m_skylander_portal;
|
||||||
Memory::MemoryManager m_memory;
|
Memory::MemoryManager m_memory;
|
||||||
MemoryInterface::MemoryInterfaceState m_memory_interface_state;
|
MemoryInterface::MemoryInterfaceState m_memory_interface_state;
|
||||||
|
@ -158,6 +160,11 @@ GPFifo::GPFifoManager& System::GetGPFifo() const
|
||||||
return m_impl->m_gp_fifo;
|
return m_impl->m_gp_fifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HSP::HSPManager& System::GetHSP() const
|
||||||
|
{
|
||||||
|
return m_impl->m_hsp;
|
||||||
|
}
|
||||||
|
|
||||||
IOS::HLE::USB::SkylanderPortal& System::GetSkylanderPortal() const
|
IOS::HLE::USB::SkylanderPortal& System::GetSkylanderPortal() const
|
||||||
{
|
{
|
||||||
return m_impl->m_skylander_portal;
|
return m_impl->m_skylander_portal;
|
||||||
|
|
|
@ -47,6 +47,10 @@ namespace GPFifo
|
||||||
{
|
{
|
||||||
class GPFifoManager;
|
class GPFifoManager;
|
||||||
}
|
}
|
||||||
|
namespace HSP
|
||||||
|
{
|
||||||
|
class HSPManager;
|
||||||
|
}
|
||||||
namespace IOS::HLE::USB
|
namespace IOS::HLE::USB
|
||||||
{
|
{
|
||||||
class SkylanderPortal;
|
class SkylanderPortal;
|
||||||
|
@ -124,6 +128,7 @@ public:
|
||||||
Fifo::FifoManager& GetFifo() const;
|
Fifo::FifoManager& GetFifo() const;
|
||||||
GeometryShaderManager& GetGeometryShaderManager() const;
|
GeometryShaderManager& GetGeometryShaderManager() const;
|
||||||
GPFifo::GPFifoManager& GetGPFifo() const;
|
GPFifo::GPFifoManager& GetGPFifo() const;
|
||||||
|
HSP::HSPManager& GetHSP() const;
|
||||||
IOS::HLE::USB::SkylanderPortal& GetSkylanderPortal() const;
|
IOS::HLE::USB::SkylanderPortal& GetSkylanderPortal() const;
|
||||||
Memory::MemoryManager& GetMemory() const;
|
Memory::MemoryManager& GetMemory() const;
|
||||||
MemoryInterface::MemoryInterfaceState& GetMemoryInterfaceState() const;
|
MemoryInterface::MemoryInterfaceState& GetMemoryInterfaceState() const;
|
||||||
|
|
Loading…
Reference in New Issue