2018-02-24 14:14:54 +01:00
|
|
|
// Copyright 2018 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
|
|
|
class DelayGenerator {
|
|
|
|
public:
|
2018-09-06 22:03:28 +02:00
|
|
|
virtual u64 GetReadDelayNs(std::size_t length) = 0;
|
2018-02-24 14:14:54 +01:00
|
|
|
|
|
|
|
// TODO (B3N30): Add getter for all other file/directory io operations
|
|
|
|
};
|
|
|
|
|
|
|
|
class DefaultDelayGenerator : public DelayGenerator {
|
|
|
|
public:
|
2018-09-06 22:03:28 +02:00
|
|
|
u64 GetReadDelayNs(std::size_t length) override {
|
2018-02-24 14:14:54 +01:00
|
|
|
// This is the delay measured for a romfs read.
|
|
|
|
// For now we will take that as a default
|
|
|
|
static constexpr u64 slope(94);
|
|
|
|
static constexpr u64 offset(582778);
|
|
|
|
static constexpr u64 minimum(663124);
|
|
|
|
u64 IPCDelayNanoseconds = std::max<u64>(static_cast<u64>(length) * slope + offset, minimum);
|
|
|
|
return IPCDelayNanoseconds;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FileSys
|