2019-06-26 08:52:34 +02:00
|
|
|
// Copyright 2019 yuzu emulator team
|
2019-06-25 16:45:53 +02:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/hle/service/time/time_sharedmemory.h"
|
|
|
|
|
|
|
|
namespace Service::Time {
|
2019-06-26 08:52:34 +02:00
|
|
|
const std::size_t SHARED_MEMORY_SIZE = 0x1000;
|
2019-06-25 16:45:53 +02:00
|
|
|
|
|
|
|
SharedMemory::SharedMemory(Core::System& system) : system(system) {
|
|
|
|
shared_memory_holder = Kernel::SharedMemory::Create(
|
|
|
|
system.Kernel(), nullptr, SHARED_MEMORY_SIZE, Kernel::MemoryPermission::ReadWrite,
|
|
|
|
Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "Time:SharedMemory");
|
2019-06-26 08:52:34 +02:00
|
|
|
|
|
|
|
// Seems static from 1.0.0 -> 8.1.0. Specific games seem to check this value and crash
|
|
|
|
// if it's set to anything else
|
|
|
|
shared_memory_format.format_version = 14;
|
|
|
|
std::memcpy(shared_memory_holder->GetPointer(), &shared_memory_format, sizeof(Format));
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SharedMemory::~SharedMemory() = default;
|
|
|
|
|
2019-11-25 02:15:51 +01:00
|
|
|
std::shared_ptr<Kernel::SharedMemory> SharedMemory::GetSharedMemoryHolder() const {
|
2019-06-25 16:45:53 +02:00
|
|
|
return shared_memory_holder;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SharedMemory::SetStandardSteadyClockTimepoint(const SteadyClockTimePoint& timepoint) {
|
2019-06-26 08:52:34 +02:00
|
|
|
shared_memory_format.standard_steady_clock_timepoint.StoreData(
|
|
|
|
shared_memory_holder->GetPointer(), timepoint);
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedMemory::SetStandardLocalSystemClockContext(const SystemClockContext& context) {
|
2019-06-26 08:52:34 +02:00
|
|
|
shared_memory_format.standard_local_system_clock_context.StoreData(
|
|
|
|
shared_memory_holder->GetPointer(), context);
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedMemory::SetStandardNetworkSystemClockContext(const SystemClockContext& context) {
|
2019-06-26 08:52:34 +02:00
|
|
|
shared_memory_format.standard_network_system_clock_context.StoreData(
|
|
|
|
shared_memory_holder->GetPointer(), context);
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:52:34 +02:00
|
|
|
void SharedMemory::SetStandardUserSystemClockAutomaticCorrectionEnabled(bool enabled) {
|
|
|
|
shared_memory_format.standard_user_system_clock_automatic_correction.StoreData(
|
|
|
|
shared_memory_holder->GetPointer(), enabled);
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:52:34 +02:00
|
|
|
SteadyClockTimePoint SharedMemory::GetStandardSteadyClockTimepoint() {
|
|
|
|
return shared_memory_format.standard_steady_clock_timepoint.ReadData(
|
|
|
|
shared_memory_holder->GetPointer());
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:52:34 +02:00
|
|
|
SystemClockContext SharedMemory::GetStandardLocalSystemClockContext() {
|
|
|
|
return shared_memory_format.standard_local_system_clock_context.ReadData(
|
|
|
|
shared_memory_holder->GetPointer());
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:52:34 +02:00
|
|
|
SystemClockContext SharedMemory::GetStandardNetworkSystemClockContext() {
|
|
|
|
return shared_memory_format.standard_network_system_clock_context.ReadData(
|
|
|
|
shared_memory_holder->GetPointer());
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:52:34 +02:00
|
|
|
bool SharedMemory::GetStandardUserSystemClockAutomaticCorrectionEnabled() {
|
|
|
|
return shared_memory_format.standard_user_system_clock_automatic_correction.ReadData(
|
|
|
|
shared_memory_holder->GetPointer());
|
2019-06-25 16:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::Time
|