IOS HLE: Clean up naming and remove unused defines

Removes #defines which have been unused for years and cleans up
naming.

This also changes IPC_REP_ASYNC to simply IPC_REPLY because it turns
out it's actually not specific to async replies, but used for all
command replies.
This commit is contained in:
Léo Lam 2016-12-03 22:53:47 +01:00
parent 7dcb3c5d55
commit c28b148783
13 changed files with 73 additions and 79 deletions

View File

@ -470,8 +470,8 @@ void EnqueueReply(u32 address, int cycles_in_future, CoreTiming::FromThread from
{
// IOS writes back the command that was responded to in the FD field.
Memory::Write_U32(Memory::Read_U32(address), address + 8);
// IOS also overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, address);
// IOS also overwrites the command type with the reply type.
Memory::Write_U32(IPC_REPLY, address);
CoreTiming::ScheduleEvent(cycles_in_future, s_event_enqueue, address, from);
}

View File

@ -30,17 +30,12 @@ enum IPCCommandType : u32
IPC_CMD_SEEK = 5,
IPC_CMD_IOCTL = 6,
IPC_CMD_IOCTLV = 7,
// IPC_REP_ASYNC is used for messages that are automatically
// sent to an IOS queue when an asynchronous syscall completes.
// Reference: http://wiibrew.org/wiki/IOS
IPC_REP_ASYNC = 8
// This is used for replies to commands.
IPC_REPLY = 8,
};
namespace WII_IPC_HLE_Interface
{
#define IPC_FIRST_ID 0x00 // First IPC device ID
#define IPC_MAX_FILES 0x10 // First IPC file ID
// Init
void Init();
@ -51,19 +46,19 @@ void Reinit();
void Shutdown();
// Reset
void Reset(bool _bHard = false);
void Reset(bool hard = false);
// Do State
void DoState(PointerWrap& p);
// Set default content file
void SetDefaultContentFile(const std::string& _rFilename);
void SetDefaultContentFile(const std::string& file_name);
void ES_DIVerify(const std::vector<u8>& tmd);
void SDIO_EventNotify();
std::shared_ptr<IWII_IPC_HLE_Device> GetDeviceByName(const std::string& _rDeviceName);
std::shared_ptr<IWII_IPC_HLE_Device> AccessDeviceByID(u32 _ID);
std::shared_ptr<IWII_IPC_HLE_Device> GetDeviceByName(const std::string& device_name);
std::shared_ptr<IWII_IPC_HLE_Device> AccessDeviceByID(u32 id);
// Update
void Update();
@ -71,11 +66,11 @@ void Update();
// Update Devices
void UpdateDevices();
void ExecuteCommand(u32 _Address);
void ExecuteCommand(u32 address);
void EnqueueRequest(u32 address);
void EnqueueReply(u32 address, int cycles_in_future = 0,
CoreTiming::FromThread from = CoreTiming::FromThread::CPU);
void EnqueueCommandAcknowledgement(u32 _Address, int cycles_in_future = 0);
void EnqueueCommandAcknowledgement(u32 address, int cycles_in_future = 0);
} // end of namespace WII_IPC_HLE_Interface

View File

@ -48,63 +48,63 @@ SIOCtlVBuffer::SIOCtlVBuffer(const u32 address) : m_Address(address)
IWII_IPC_HLE_Device::IWII_IPC_HLE_Device(const u32 device_id, const std::string& device_name,
const bool hardware)
: m_Name(device_name), m_DeviceID(device_id), m_Hardware(hardware)
: m_name(device_name), m_device_id(device_id), m_is_hardware(hardware)
{
}
void IWII_IPC_HLE_Device::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_Active);
p.Do(m_is_active);
}
void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
{
p.Do(m_Name);
p.Do(m_DeviceID);
p.Do(m_Hardware);
p.Do(m_Active);
p.Do(m_name);
p.Do(m_device_id);
p.Do(m_is_hardware);
p.Do(m_is_active);
}
IPCCommandResult IWII_IPC_HLE_Device::Open(u32 command_address, u32 mode)
{
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Close(u32 command_address, bool force)
{
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Seek(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Seek()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s does not support Seek()", m_name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Read(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Read()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s does not support Read()", m_name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Write(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Write()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s does not support Write()", m_name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::IOCtl(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtl()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtl()", m_name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::IOCtlV(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtlV()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtlV()", m_name.c_str());
return GetDefaultReply();
}

View File

@ -70,8 +70,8 @@ public:
virtual void DoState(PointerWrap& p);
void DoStateShared(PointerWrap& p);
const std::string& GetDeviceName() const { return m_Name; }
u32 GetDeviceID() const { return m_DeviceID; }
const std::string& GetDeviceName() const { return m_name; }
u32 GetDeviceID() const { return m_device_id; }
virtual IPCCommandResult Open(u32 command_address, u32 mode);
virtual IPCCommandResult Close(u32 command_address, bool force = false);
virtual IPCCommandResult Seek(u32 command_address);
@ -81,18 +81,18 @@ public:
virtual IPCCommandResult IOCtlV(u32 command_address);
virtual u32 Update() { return 0; }
virtual bool IsHardware() const { return m_Hardware; }
virtual bool IsOpened() const { return m_Active; }
virtual bool IsHardware() const { return m_is_hardware; }
virtual bool IsOpened() const { return m_is_active; }
static IPCCommandResult GetDefaultReply();
static IPCCommandResult GetNoReply();
std::string m_Name;
std::string m_name;
protected:
// STATE_TO_SAVE
u32 m_DeviceID;
bool m_Hardware;
bool m_Active = false;
u32 m_device_id;
bool m_is_hardware;
bool m_is_active = false;
// Write out the IPC struct from command_address to number_of_commands numbers
// of 4 byte commands.

View File

@ -76,14 +76,14 @@ CWII_IPC_HLE_Device_FileIO::~CWII_IPC_HLE_Device_FileIO()
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Close %s (DeviceID=%08x)", m_Name.c_str(), m_DeviceID);
INFO_LOG(WII_IPC_FILEIO, "FileIO: Close %s (DeviceID=%08x)", m_name.c_str(), m_device_id);
m_Mode = 0;
// Let go of our pointer to the file, it will automatically close if we are the last handle
// accessing it.
m_file.reset();
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}
@ -93,13 +93,13 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 command_address, u32 mode)
static const char* const Modes[] = {"Unk Mode", "Read only", "Write only", "Read and Write"};
m_filepath = HLE_IPC_BuildFilename(m_Name);
m_filepath = HLE_IPC_BuildFilename(m_name);
// The file must exist before we can open it
// It should be created by ISFS_CreateFile, not here
if (File::Exists(m_filepath) && !File::IsDirectory(m_filepath))
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_Name.c_str(), Modes[mode], mode);
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_name.c_str(), Modes[mode], mode);
OpenFile();
}
else
@ -110,7 +110,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 command_address, u32 mode)
Memory::Write_U32(FS_ENOENT, command_address + 4);
}
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -134,14 +134,14 @@ void CWII_IPC_HLE_Device_FileIO::OpenFile()
// - The Beatles: Rock Band (saving doesn't work)
// Check if the file has already been opened.
auto search = openFiles.find(m_Name);
auto search = openFiles.find(m_name);
if (search != openFiles.end())
{
m_file = search->second.lock(); // Lock a shared pointer to use.
}
else
{
std::string path = m_Name;
std::string path = m_name;
// This code will be called when all references to the shared pointer below have been removed.
auto deleter = [path](File::IOFile* ptr) {
delete ptr; // IOFile's deconstructor closes the file.
@ -170,7 +170,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
const s32 fileSize = (s32)m_file->GetSize();
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)",
SeekPosition, Mode, m_Name.c_str(), fileSize);
SeekPosition, Mode, m_name.c_str(), fileSize);
switch (Mode)
{
@ -235,12 +235,12 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(u32 _CommandAddress)
{
WARN_LOG(WII_IPC_FILEIO,
"FileIO: Attempted to read 0x%x bytes to 0x%08x on a write-only file %s", Size,
Address, m_Name.c_str());
Address, m_name.c_str());
}
else
{
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Read 0x%x bytes to 0x%08x from %s", Size, Address,
m_Name.c_str());
m_name.c_str());
m_file->Seek(m_SeekPos, SEEK_SET); // File might be opened twice, need to seek before we read
ReturnValue = (u32)fread(Memory::GetPointer(Address), 1, Size, m_file->GetHandle());
if (ReturnValue != Size && ferror(m_file->GetHandle()))
@ -257,7 +257,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(u32 _CommandAddress)
{
ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could "
"not be opened or does not exist",
m_Name.c_str(), Address, Size);
m_name.c_str(), Address, Size);
ReturnValue = FS_ENOENT;
}
@ -278,12 +278,12 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress)
{
WARN_LOG(WII_IPC_FILEIO,
"FileIO: Attempted to write 0x%x bytes from 0x%08x to a read-only file %s", Size,
Address, m_Name.c_str());
Address, m_name.c_str());
}
else
{
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Write 0x%04x bytes from 0x%08x to %s", Size, Address,
m_Name.c_str());
m_name.c_str());
m_file->Seek(m_SeekPos,
SEEK_SET); // File might be opened twice, need to seek before we write
if (m_file->WriteBytes(Memory::GetPointer(Address), Size))
@ -297,7 +297,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress)
{
ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could "
"not be opened or does not exist",
m_Name.c_str(), Address, Size);
m_name.c_str(), Address, Size);
ReturnValue = FS_ENOENT;
}
@ -307,7 +307,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress)
IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
{
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: IOCtl (Device=%s)", m_Name.c_str());
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: IOCtl (Device=%s)", m_name.c_str());
#if defined(_DEBUG) || defined(DEBUGFAST)
DumpCommands(_CommandAddress);
#endif
@ -323,7 +323,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
u32 m_FileLength = (u32)m_file->GetSize();
const u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
DEBUG_LOG(WII_IPC_FILEIO, " File: %s, Length: %i, Pos: %i", m_Name.c_str(), m_FileLength,
DEBUG_LOG(WII_IPC_FILEIO, " File: %s, Length: %i, Pos: %i", m_name.c_str(), m_FileLength,
m_SeekPos);
Memory::Write_U32(m_FileLength, BufferOut);
@ -362,7 +362,7 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p)
p.Do(m_Mode);
p.Do(m_SeekPos);
m_filepath = HLE_IPC_BuildFilename(m_Name);
m_filepath = HLE_IPC_BuildFilename(m_name);
// The file was closed during state (and might now be pointing at another file)
// Open it again

View File

@ -184,9 +184,9 @@ IPCCommandResult CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
{
OpenInternal();
if (m_Active)
if (m_is_active)
INFO_LOG(WII_IPC_ES, "Device was re-opened.");
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -198,7 +198,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress, bool _bForce
m_AccessIdentID = 0x6000000;
INFO_LOG(WII_IPC_ES, "ES: Close");
m_Active = false;
m_is_active = false;
// clear the NAND content cache to make sure nothing remains open.
DiscIO::CNANDContentManager::Access().ClearCache();
return GetDefaultReply();
@ -1061,9 +1061,9 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
if (!bReset)
{
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, _CommandAddress);
// IOS also seems to write back the command that was responded to in the FD field.
// The command type is overwritten with the reply type.
Memory::Write_U32(IPC_REPLY, _CommandAddress);
// IOS also writes back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTLV, _CommandAddress + 8);
}

View File

@ -52,7 +52,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
File::CreateDir(Path);
}
m_Active = true;
m_is_active = true;
return GetFSReply();
}

View File

@ -77,7 +77,7 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _
OpenInternal();
m_registers.fill(0);
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -89,7 +89,7 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::Close(u32 _CommandAddress, bool
m_BlockLength = 0;
m_BusWidth = 0;
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}

View File

@ -92,7 +92,7 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::Close(u32 command_address, b
{
s_event_hook_address = 0;
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}
@ -119,7 +119,7 @@ bool CWII_IPC_HLE_Device_stm_eventhook::HasHookInstalled() const
void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const
{
if (!m_Active || s_event_hook_address == 0)
if (!m_is_active || s_event_hook_address == 0)
{
// If the device isn't open, ignore the button press.
return;

View File

@ -13,28 +13,28 @@ CWII_IPC_HLE_Device_stub::CWII_IPC_HLE_Device_stub(u32 device_id, const std::str
IPCCommandResult CWII_IPC_HLE_Device_stub::Open(u32 command_address, u32 mode)
{
WARN_LOG(WII_IPC_HLE, "%s faking Open()", m_Name.c_str());
m_Active = true;
WARN_LOG(WII_IPC_HLE, "%s faking Open()", m_name.c_str());
m_is_active = true;
return GetDefaultReply();
}
IPCCommandResult CWII_IPC_HLE_Device_stub::Close(u32 command_address, bool force)
{
WARN_LOG(WII_IPC_HLE, "%s faking Close()", m_Name.c_str());
m_Active = false;
WARN_LOG(WII_IPC_HLE, "%s faking Close()", m_name.c_str());
m_is_active = false;
return GetDefaultReply();
}
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtl(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_name.c_str());
Memory::Write_U32(IPC_SUCCESS, command_address + 4);
return GetDefaultReply();
}
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtlV(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_Name.c_str());
WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_name.c_str());
Memory::Write_U32(IPC_SUCCESS, command_address + 4);
return GetDefaultReply();
}

View File

@ -123,7 +123,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DoState(PointerWrap& p)
return;
}
p.Do(m_Active);
p.Do(m_is_active);
p.Do(m_ControllerBD);
p.Do(m_CtrlSetup);
p.Do(m_ACLSetup);
@ -154,7 +154,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Open(u32 _CommandAddre
m_HCIEndpoint.m_cmd_address = 0;
m_ACLEndpoint.m_cmd_address = 0;
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -168,7 +168,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close(u32 _CommandAddr
m_HCIEndpoint.m_cmd_address = 0;
m_ACLEndpoint.m_cmd_address = 0;
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}

View File

@ -141,7 +141,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(u32 command_addr
StartTransferThread();
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -155,7 +155,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Close(u32 command_add
m_handle = nullptr;
}
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}

View File

@ -57,8 +57,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mod
m_OldModifiers = 0x00;
// m_MessageQueue.push(SMessageData(MSG_KBD_CONNECT, 0, nullptr));
Memory::Write_U32(m_DeviceID, _CommandAddress + 4);
m_Active = true;
m_is_active = true;
return GetDefaultReply();
}
@ -67,7 +66,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Close(u32 _CommandAddress, bool _b
INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Close");
while (!m_MessageQueue.empty())
m_MessageQueue.pop();
m_Active = false;
m_is_active = false;
return GetDefaultReply();
}
@ -109,7 +108,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key)
u32 CWII_IPC_HLE_Device_usb_kbd::Update()
{
if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_Active)
if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_is_active)
return 0;
u8 Modifiers = 0x00;