Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #8445 from Leseratte10/master
Add /dev/dolphin for homebrew to get information about Dolphin
- Loading branch information
Showing
8 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include <algorithm> | ||
| #include <cstring> | ||
|
|
||
| #include "Common/Logging/Log.h" | ||
| #include "Common/Timer.h" | ||
| #include "Common/scmrev.h" | ||
| #include "Core/BootManager.h" | ||
| #include "Core/ConfigManager.h" | ||
| #include "Core/Core.h" | ||
| #include "Core/HW/Memmap.h" | ||
| #include "Core/IOS/DolphinDevice.h" | ||
|
|
||
| namespace IOS::HLE::Device | ||
| { | ||
| namespace | ||
| { | ||
| enum | ||
| { | ||
| IOCTL_DOLPHIN_GET_SYSTEM_TIME = 0x01, | ||
| IOCTL_DOLPHIN_GET_VERSION = 0x02, | ||
| IOCTL_DOLPHIN_GET_SPEED_LIMIT = 0x03, | ||
| IOCTL_DOLPHIN_SET_SPEED_LIMIT = 0x04, | ||
| IOCTL_DOLPHIN_GET_CPU_SPEED = 0x05, | ||
|
|
||
| }; | ||
|
|
||
| IPCCommandResult GetSystemTime(const IOCtlVRequest& request) | ||
| { | ||
| if (!request.HasNumberOfValidVectors(0, 1)) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| if (request.io_vectors[0].size != 4) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| const u32 milliseconds = Common::Timer::GetTimeMs(); | ||
|
|
||
| Memory::Write_U32(milliseconds, request.io_vectors[0].address); | ||
| return DolphinDevice::GetDefaultReply(IPC_SUCCESS); | ||
| } | ||
|
|
||
| IPCCommandResult GetVersion(const IOCtlVRequest& request) | ||
| { | ||
| if (!request.HasNumberOfValidVectors(0, 1)) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| const auto length = std::min(size_t(request.io_vectors[0].size), std::strlen(SCM_DESC_STR)); | ||
|
|
||
| Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size); | ||
| Memory::CopyToEmu(request.io_vectors[0].address, SCM_DESC_STR, length); | ||
|
|
||
| return DolphinDevice::GetDefaultReply(IPC_SUCCESS); | ||
| } | ||
|
|
||
| IPCCommandResult GetCPUSpeed(const IOCtlVRequest& request) | ||
| { | ||
| if (!request.HasNumberOfValidVectors(0, 1)) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| if (request.io_vectors[0].size != 4) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| const SConfig& config = SConfig::GetInstance(); | ||
| const float oc = config.m_OCEnable ? config.m_OCFactor : 1.0f; | ||
|
|
||
| const u32 core_clock = u32(float(SystemTimers::GetTicksPerSecond()) * oc); | ||
|
|
||
| Memory::Write_U32(core_clock, request.io_vectors[0].address); | ||
|
|
||
| return DolphinDevice::GetDefaultReply(IPC_SUCCESS); | ||
| } | ||
|
|
||
| IPCCommandResult GetSpeedLimit(const IOCtlVRequest& request) | ||
| { | ||
| // get current speed limit | ||
| if (!request.HasNumberOfValidVectors(0, 1)) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| if (request.io_vectors[0].size != 4) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| const SConfig& config = SConfig::GetInstance(); | ||
| const u32 speed_percent = config.m_EmulationSpeed * 100; | ||
| Memory::Write_U32(speed_percent, request.io_vectors[0].address); | ||
|
|
||
| return DolphinDevice::GetDefaultReply(IPC_SUCCESS); | ||
| } | ||
|
|
||
| IPCCommandResult SetSpeedLimit(const IOCtlVRequest& request) | ||
| { | ||
| // set current speed limit | ||
| if (!request.HasNumberOfValidVectors(1, 0)) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| if (request.in_vectors[0].size != 4) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EINVAL); | ||
| } | ||
|
|
||
| const float speed = float(Memory::Read_U32(request.in_vectors[0].address)) / 100.0f; | ||
| SConfig::GetInstance().m_EmulationSpeed = speed; | ||
| BootManager::SetEmulationSpeedReset(true); | ||
|
|
||
| return DolphinDevice::GetDefaultReply(IPC_SUCCESS); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| IPCCommandResult DolphinDevice::IOCtlV(const IOCtlVRequest& request) | ||
| { | ||
| if (Core::WantsDeterminism()) | ||
| { | ||
| return DolphinDevice::GetDefaultReply(IPC_EACCES); | ||
| } | ||
|
|
||
| switch (request.request) | ||
| { | ||
| case IOCTL_DOLPHIN_GET_SYSTEM_TIME: | ||
| return GetSystemTime(request); | ||
| case IOCTL_DOLPHIN_GET_VERSION: | ||
| return GetVersion(request); | ||
| case IOCTL_DOLPHIN_GET_SPEED_LIMIT: | ||
| return GetSpeedLimit(request); | ||
| case IOCTL_DOLPHIN_SET_SPEED_LIMIT: | ||
| return SetSpeedLimit(request); | ||
| case IOCTL_DOLPHIN_GET_CPU_SPEED: | ||
| return GetCPUSpeed(request); | ||
| default: | ||
| return GetDefaultReply(IPC_EINVAL); | ||
| } | ||
| } | ||
| } // namespace IOS::HLE::Device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Core/IOS/Device.h" | ||
|
|
||
| namespace IOS::HLE::Device | ||
| { | ||
| class DolphinDevice final : public Device | ||
| { | ||
| public: | ||
| // Inherit the constructor from the Device class, since we don't need to do anything special. | ||
| using Device::Device; | ||
| IPCCommandResult IOCtlV(const IOCtlVRequest& request) override; | ||
| }; | ||
| } // namespace IOS::HLE::Device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters