Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9504 from leoetlino/ios-class-name-cleanup
IOS: Use less ambiguous names for classes
  • Loading branch information
leoetlino committed Feb 13, 2021
2 parents c5ee86c + 522cb6b commit 3e1646a
Show file tree
Hide file tree
Showing 82 changed files with 664 additions and 707 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/Boot/Boot_BS2Emu.cpp
Expand Up @@ -471,8 +471,8 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume)
if (!SetupWiiMemory(console_type) || !IOS::HLE::GetIOS()->BootIOS(tmd.GetIOSId()))
return false;

auto di = std::static_pointer_cast<IOS::HLE::Device::DI>(
IOS::HLE::GetIOS()->GetDeviceByName("/dev/di"));
auto di =
std::static_pointer_cast<IOS::HLE::DIDevice>(IOS::HLE::GetIOS()->GetDeviceByName("/dev/di"));

di->InitializeIfFirstTime();
di->ChangePartition(data_partition);
Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/HW/DVD/DVDInterface.cpp
Expand Up @@ -561,8 +561,7 @@ bool UpdateRunningGameMetadata(std::optional<u64> title_id)
if (!DVDThread::HasDisc())
return false;

return DVDThread::UpdateRunningGameMetadata(IOS::HLE::Device::DI::GetCurrentPartition(),
title_id);
return DVDThread::UpdateRunningGameMetadata(IOS::HLE::DIDevice::GetCurrentPartition(), title_id);
}

void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
Expand Down Expand Up @@ -1312,7 +1311,7 @@ void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type

case ReplyType::IOS:
{
IOS::HLE::Device::DI::InterruptFromDVDInterface(interrupt_type);
IOS::HLE::DIDevice::InterruptFromDVDInterface(interrupt_type);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/ProcessorInterface.cpp
Expand Up @@ -233,7 +233,7 @@ static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate)

auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->ResetButton();
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->ResetButton();
}

static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate)
Expand All @@ -244,7 +244,7 @@ static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate)

auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->PowerButton();
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->PowerButton();
}

void ResetButton_Tap()
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/SystemTimers.cpp
Expand Up @@ -34,7 +34,7 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule:
// If the AclFrameQue is empty this will call Wiimote_Update() and make it send
the current input status to the game. I'm not sure if this occurs approximately
once every frame or if the frequency is not exactly tied to rendered frames
IOS::HLE::Device::BluetoothEmu::Update()
IOS::HLE::BluetoothEmuDevice::Update()
PluginWiimote::Wiimote_Update()
// This is also a device updated by IOS::HLE::Update() but it doesn't
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/Wiimote.cpp
Expand Up @@ -53,7 +53,7 @@ void UpdateSource(unsigned int index)
if (!ios)
return;

const auto bluetooth = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
const auto bluetooth = std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
if (!bluetooth)
return;
Expand Down
58 changes: 29 additions & 29 deletions Source/Core/Core/IOS/DI/DI.cpp
Expand Up @@ -39,15 +39,15 @@ static RegisterWrapper<0x0D806018> DILENGTH;
static RegisterWrapper<0x0D80601C> DICR;
static RegisterWrapper<0x0D806020> DIIMMBUF;

namespace IOS::HLE::Device
namespace IOS::HLE
{
CoreTiming::EventType* DI::s_finish_executing_di_command;
CoreTiming::EventType* DIDevice::s_finish_executing_di_command;

DI::DI(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
DIDevice::DIDevice(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
{
}

void DI::DoState(PointerWrap& p)
void DIDevice::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_commands_to_execute);
Expand All @@ -57,13 +57,13 @@ void DI::DoState(PointerWrap& p)
p.Do(m_last_length);
}

IPCCommandResult DI::Open(const OpenRequest& request)
IPCCommandResult DIDevice::Open(const OpenRequest& request)
{
InitializeIfFirstTime();
return Device::Open(request);
}

IPCCommandResult DI::IOCtl(const IOCtlRequest& request)
IPCCommandResult DIDevice::IOCtl(const IOCtlRequest& request)
{
InitializeIfFirstTime();

Expand Down Expand Up @@ -94,11 +94,11 @@ IPCCommandResult DI::IOCtl(const IOCtlRequest& request)
return GetNoReply();
}

void DI::ProcessQueuedIOCtl()
void DIDevice::ProcessQueuedIOCtl()
{
if (m_commands_to_execute.empty())
{
PanicAlertFmt("IOS::HLE::Device::DI: There is no command to execute!");
PanicAlertFmt("IOS::HLE::DIDevice: There is no command to execute!");
return;
}

Expand All @@ -115,7 +115,7 @@ void DI::ProcessQueuedIOCtl()
}
}

std::optional<DI::DIResult> DI::WriteIfFits(const IOCtlRequest& request, u32 value)
std::optional<DIDevice::DIResult> DIDevice::WriteIfFits(const IOCtlRequest& request, u32 value)
{
if (request.buffer_out_size < 4)
{
Expand All @@ -129,7 +129,7 @@ std::optional<DI::DIResult> DI::WriteIfFits(const IOCtlRequest& request, u32 val
}
}

std::optional<DI::DIResult> DI::StartIOCtl(const IOCtlRequest& request)
std::optional<DIDevice::DIResult> DIDevice::StartIOCtl(const IOCtlRequest& request)
{
if (request.buffer_in_size != 0x20)
{
Expand Down Expand Up @@ -482,7 +482,8 @@ std::optional<DI::DIResult> DI::StartIOCtl(const IOCtlRequest& request)
}
}

std::optional<DI::DIResult> DI::StartDMATransfer(u32 command_length, const IOCtlRequest& request)
std::optional<DIDevice::DIResult> DIDevice::StartDMATransfer(u32 command_length,
const IOCtlRequest& request)
{
if (request.buffer_out_size < command_length)
{
Expand Down Expand Up @@ -517,8 +518,8 @@ std::optional<DI::DIResult> DI::StartDMATransfer(u32 command_length, const IOCtl
// Reply will be posted when done by FinishIOCtl.
return {};
}
std::optional<DI::DIResult> DI::StartImmediateTransfer(const IOCtlRequest& request,
bool write_to_buf)
std::optional<DIDevice::DIResult> DIDevice::StartImmediateTransfer(const IOCtlRequest& request,
bool write_to_buf)
{
if (write_to_buf && request.buffer_out_size < 4)
{
Expand All @@ -536,17 +537,17 @@ std::optional<DI::DIResult> DI::StartImmediateTransfer(const IOCtlRequest& reque
return {};
}

static std::shared_ptr<DI> GetDevice()
static std::shared_ptr<DIDevice> GetDevice()
{
auto ios = IOS::HLE::GetIOS();
if (!ios)
return nullptr;
auto di = ios->GetDeviceByName("/dev/di");
// di may be empty, but static_pointer_cast returns empty in that case
return std::static_pointer_cast<DI>(di);
return std::static_pointer_cast<DIDevice>(di);
}

void DI::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type)
void DIDevice::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type)
{
DIResult result;
switch (interrupt_type)
Expand All @@ -558,7 +559,7 @@ void DI::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type)
result = DIResult::DriveError;
break;
default:
PanicAlertFmt("IOS::HLE::Device::DI: Unexpected DVDInterface interrupt {0}!",
PanicAlertFmt("IOS::HLE::DIDevice: Unexpected DVDInterface interrupt {0}!",
static_cast<int>(interrupt_type));
result = DIResult::DriveError;
break;
Expand All @@ -571,28 +572,27 @@ void DI::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type)
}
else
{
PanicAlertFmt("IOS::HLE::Device::DI: Received interrupt from DVDInterface when device wasn't "
PanicAlertFmt("IOS::HLE::DIDevice: Received interrupt from DVDInterface when device wasn't "
"registered!");
}
}

void DI::FinishDICommandCallback(u64 userdata, s64 ticksbehind)
void DIDevice::FinishDICommandCallback(u64 userdata, s64 ticksbehind)
{
const DIResult result = static_cast<DIResult>(userdata);

auto di = GetDevice();
if (di)
di->FinishDICommand(result);
else
PanicAlertFmt(
"IOS::HLE::Device::DI: Received interrupt from DI when device wasn't registered!");
PanicAlertFmt("IOS::HLE::DIDevice: Received interrupt from DI when device wasn't registered!");
}

void DI::FinishDICommand(DIResult result)
void DIDevice::FinishDICommand(DIResult result)
{
if (!m_executing_command.has_value())
{
PanicAlertFmt("IOS::HLE::Device::DI: There is no command to finish!");
PanicAlertFmt("IOS::HLE::DIDevice: There is no command to finish!");
return;
}

Expand All @@ -612,7 +612,7 @@ void DI::FinishDICommand(DIResult result)
}
}

IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request)
IPCCommandResult DIDevice::IOCtlV(const IOCtlVRequest& request)
{
// IOCtlVs are not queued since they don't (currently) go into DVDInterface and act
// asynchronously. This does mean that an IOCtlV can be executed while an IOCtl is in progress,
Expand Down Expand Up @@ -707,12 +707,12 @@ IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request)
return GetDefaultReply(static_cast<s32>(return_value));
}

void DI::ChangePartition(const DiscIO::Partition partition)
void DIDevice::ChangePartition(const DiscIO::Partition partition)
{
m_current_partition = partition;
}

DiscIO::Partition DI::GetCurrentPartition()
DiscIO::Partition DIDevice::GetCurrentPartition()
{
auto di = GetDevice();
// Note that this function is called in Gamecube mode for UpdateRunningGameMetadata,
Expand All @@ -722,7 +722,7 @@ DiscIO::Partition DI::GetCurrentPartition()
return di->m_current_partition;
}

void DI::InitializeIfFirstTime()
void DIDevice::InitializeIfFirstTime()
{
// Match the behavior of Nintendo's initDvdDriverStage2, which is called the first time
// an open/ioctl/ioctlv occurs. This behavior is observable by directly reading the DI registers,
Expand All @@ -738,7 +738,7 @@ void DI::InitializeIfFirstTime()
}
}

void DI::ResetDIRegisters()
void DIDevice::ResetDIRegisters()
{
// Clear transfer complete and error interrupts (normally r/z, but here we just directly write
// zero)
Expand All @@ -751,4 +751,4 @@ void DI::ResetDIRegisters()
// Close the current partition, if there is one
ChangePartition(DiscIO::PARTITION_NONE);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
8 changes: 4 additions & 4 deletions Source/Core/Core/IOS/DI/DI.h
Expand Up @@ -30,12 +30,12 @@ namespace IOS::HLE
void Init();
}

namespace IOS::HLE::Device
namespace IOS::HLE
{
class DI : public Device
class DIDevice : public Device
{
public:
DI(Kernel& ios, const std::string& device_name);
DIDevice(Kernel& ios, const std::string& device_name);

static void InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type);
static DiscIO::Partition GetCurrentPartition();
Expand Down Expand Up @@ -145,4 +145,4 @@ class DI : public Device
bool m_has_initialized = false;
u32 m_last_length = 0;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
3 changes: 0 additions & 3 deletions Source/Core/Core/IOS/Device.cpp
Expand Up @@ -142,8 +142,6 @@ void IOCtlVRequest::DumpUnknown(const std::string& description, Common::Log::LOG
Dump("Unknown IOCtlV - " + description, type, level);
}

namespace Device
{
Device::Device(Kernel& ios, const std::string& device_name, const DeviceType type)
: m_ios(ios), m_name(device_name), m_device_type(type)
{
Expand Down Expand Up @@ -208,5 +206,4 @@ IPCCommandResult Device::GetNoReply()
{
return {IPC_SUCCESS, false, 0};
}
} // namespace Device
} // namespace IOS::HLE
3 changes: 0 additions & 3 deletions Source/Core/Core/IOS/Device.h
Expand Up @@ -166,8 +166,6 @@ struct IOCtlVRequest final : Request
Common::Log::LOG_LEVELS level = Common::Log::LERROR) const;
};

namespace Device
{
class Device
{
public:
Expand Down Expand Up @@ -213,5 +211,4 @@ class Device
private:
IPCCommandResult Unsupported(const Request& request);
};
} // namespace Device
} // namespace IOS::HLE
10 changes: 5 additions & 5 deletions Source/Core/Core/IOS/DeviceStub.cpp
Expand Up @@ -6,24 +6,24 @@

#include "Common/Logging/Log.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
IPCCommandResult Stub::Open(const OpenRequest& request)
IPCCommandResult DeviceStub::Open(const OpenRequest& request)
{
WARN_LOG_FMT(IOS, "{} faking Open()", m_name);
m_is_active = true;
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult Stub::IOCtl(const IOCtlRequest& request)
IPCCommandResult DeviceStub::IOCtl(const IOCtlRequest& request)
{
WARN_LOG_FMT(IOS, "{} faking IOCtl()", m_name);
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult Stub::IOCtlV(const IOCtlVRequest& request)
IPCCommandResult DeviceStub::IOCtlV(const IOCtlVRequest& request)
{
WARN_LOG_FMT(IOS, "{} faking IOCtlV()", m_name);
return GetDefaultReply(IPC_SUCCESS);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
6 changes: 3 additions & 3 deletions Source/Core/Core/IOS/DeviceStub.h
Expand Up @@ -10,9 +10,9 @@
#include "Core/IOS/Device.h"
#include "Core/IOS/IOS.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
class Stub final : public Device
class DeviceStub final : public Device
{
public:
// Inherit the constructor from the Device class, since we don't need to do anything special.
Expand All @@ -21,4 +21,4 @@ class Stub final : public Device
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
IPCCommandResult IOCtlV(const IOCtlVRequest& request) override;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
4 changes: 2 additions & 2 deletions Source/Core/Core/IOS/DolphinDevice.cpp
Expand Up @@ -19,7 +19,7 @@
#include "Core/HW/Memmap.h"
#include "Core/IOS/DolphinDevice.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
namespace
{
Expand Down Expand Up @@ -187,4 +187,4 @@ IPCCommandResult DolphinDevice::IOCtlV(const IOCtlVRequest& request)
return GetDefaultReply(IPC_EINVAL);
}
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
4 changes: 2 additions & 2 deletions Source/Core/Core/IOS/DolphinDevice.h
Expand Up @@ -6,7 +6,7 @@

#include "Core/IOS/Device.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
class DolphinDevice final : public Device
{
Expand All @@ -15,4 +15,4 @@ class DolphinDevice final : public Device
using Device::Device;
IPCCommandResult IOCtlV(const IOCtlVRequest& request) override;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE

0 comments on commit 3e1646a

Please sign in to comment.