IOS: Deduplicate IPC_OVERHEAD_TICKS timing constant

This commit is contained in:
Léo Lam 2021-02-18 21:06:41 +01:00
parent f750208aa3
commit e3bf5fca93
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 10 additions and 17 deletions

View File

@ -109,7 +109,7 @@ void DIDevice::ProcessQueuedIOCtl()
auto finished = StartIOCtl(request);
if (finished)
{
CoreTiming::ScheduleEvent(2700 * SystemTimers::TIMER_RATIO, s_finish_executing_di_command,
CoreTiming::ScheduleEvent(IPC_OVERHEAD_TICKS, s_finish_executing_di_command,
static_cast<u64>(finished.value()));
return;
}

View File

@ -366,8 +366,6 @@ private:
std::string GetContentPath(u64 title_id, const ES::Content& content, Ticks ticks = {}) const;
static constexpr u64 IPC_OVERHEAD_TICKS = 2700_tbticks;
struct OpenedContent
{
bool m_opened = false;

View File

@ -22,16 +22,9 @@ namespace IOS::HLE
{
using namespace IOS::HLE::FS;
static constexpr u64 GetIPCOverheadTicks()
{
// According to hardware tests, FS takes at least 2700 TB ticks to reply to commands.
return 2700;
}
static IPCReply GetFSReply(s32 return_value, u64 extra_tb_ticks = 0)
{
return IPCReply{return_value,
(GetIPCOverheadTicks() + extra_tb_ticks) * SystemTimers::TIMER_RATIO};
return IPCReply{return_value, IPC_OVERHEAD_TICKS + extra_tb_ticks * SystemTimers::TIMER_RATIO};
}
/// Duration of a superblock write (in timebase ticks).
@ -169,7 +162,7 @@ std::optional<IPCReply> FSDevice::Open(const OpenRequest& request)
s64 FSDevice::Open(FS::Uid uid, FS::Gid gid, const std::string& path, FS::Mode mode,
std::optional<u32> ipc_fd, Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
if (m_fd_map.size() >= 16)
return ConvertResult(ResultCode::NoFreeHandle);
@ -204,7 +197,7 @@ std::optional<IPCReply> FSDevice::Close(u32 fd)
s32 FSDevice::Close(u64 fd, Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
const auto& handle = m_fd_map[fd];
if (handle.fs_fd != INVALID_FD)
@ -318,7 +311,7 @@ std::optional<IPCReply> FSDevice::Read(const ReadWriteRequest& request)
s32 FSDevice::Read(u64 fd, u8* data, u32 size, std::optional<u32> ipc_buffer_addr, Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
const Handle& handle = m_fd_map[fd];
if (handle.fs_fd == INVALID_FD)
@ -347,7 +340,7 @@ std::optional<IPCReply> FSDevice::Write(const ReadWriteRequest& request)
s32 FSDevice::Write(u64 fd, const u8* data, u32 size, std::optional<u32> ipc_buffer_addr,
Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
const Handle& handle = m_fd_map[fd];
if (handle.fs_fd == INVALID_FD)
@ -375,7 +368,7 @@ std::optional<IPCReply> FSDevice::Seek(const SeekRequest& request)
s32 FSDevice::Seek(u64 fd, u32 offset, FS::SeekMode mode, Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
const Handle& handle = m_fd_map[fd];
if (handle.fs_fd == INVALID_FD)
@ -679,7 +672,7 @@ IPCReply FSDevice::GetFileStats(const Handle& handle, const IOCtlRequest& reques
FS::Result<FS::FileStatus> FSDevice::GetFileStatus(u64 fd, Ticks ticks)
{
ticks.AddTimeBaseTicks(GetIPCOverheadTicks());
ticks.AddTimeBaseTicks(IPC_OVERHEAD_TICKS);
const auto& handle = m_fd_map[fd];
if (handle.fs_fd == INVALID_FD)
return ResultCode::Invalid;

View File

@ -46,6 +46,8 @@ struct IPCReply
u64 reply_delay_ticks;
};
constexpr u64 IPC_OVERHEAD_TICKS = 2700_tbticks;
// Used to make it more convenient for functions to return timing information
// without having to explicitly keep track of ticks in callers.
class Ticks