mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 23:45:30 +03:00
Extend time services with support for the steady clock
The steady clock has a fixed timepoint that can not change while an application is running.
This commit is contained in:
parent
e3313ae731
commit
c2fadffe60
@ -92,6 +92,7 @@ add_library(skyline SHARED
|
|||||||
${source_DIR}/skyline/services/hid/IAppletResource.cpp
|
${source_DIR}/skyline/services/hid/IAppletResource.cpp
|
||||||
${source_DIR}/skyline/services/timesrv/IStaticService.cpp
|
${source_DIR}/skyline/services/timesrv/IStaticService.cpp
|
||||||
${source_DIR}/skyline/services/timesrv/ISystemClock.cpp
|
${source_DIR}/skyline/services/timesrv/ISystemClock.cpp
|
||||||
|
${source_DIR}/skyline/services/timesrv/ISteadyClock.cpp
|
||||||
${source_DIR}/skyline/services/timesrv/ITimeZoneService.cpp
|
${source_DIR}/skyline/services/timesrv/ITimeZoneService.cpp
|
||||||
${source_DIR}/skyline/services/fssrv/IFileSystemProxy.cpp
|
${source_DIR}/skyline/services/fssrv/IFileSystemProxy.cpp
|
||||||
${source_DIR}/skyline/services/fssrv/IFileSystem.cpp
|
${source_DIR}/skyline/services/fssrv/IFileSystem.cpp
|
||||||
|
@ -55,6 +55,7 @@ namespace skyline::service {
|
|||||||
timesrv_IStaticService,
|
timesrv_IStaticService,
|
||||||
timesrv_ISystemClock,
|
timesrv_ISystemClock,
|
||||||
timesrv_ITimeZoneService,
|
timesrv_ITimeZoneService,
|
||||||
|
timesrv_ISteadyClock,
|
||||||
fssrv_IFileSystemProxy,
|
fssrv_IFileSystemProxy,
|
||||||
fssrv_IFileSystem,
|
fssrv_IFileSystem,
|
||||||
fssrv_IStorage,
|
fssrv_IStorage,
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
#include "IStaticService.h"
|
#include "ISteadyClock.h"
|
||||||
#include "ISystemClock.h"
|
#include "ISystemClock.h"
|
||||||
#include "ITimeZoneService.h"
|
#include "ITimeZoneService.h"
|
||||||
|
#include "IStaticService.h"
|
||||||
|
|
||||||
namespace skyline::service::timesrv {
|
namespace skyline::service::timesrv {
|
||||||
IStaticService::IStaticService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::timesrv_IStaticService, "timesrv:IStaticService", {
|
IStaticService::IStaticService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::timesrv_IStaticService, "timesrv:IStaticService", {
|
||||||
{0x0, SFUNC(IStaticService::GetStandardUserSystemClock)},
|
{0x0, SFUNC(IStaticService::GetStandardUserSystemClock)},
|
||||||
{0x1, SFUNC(IStaticService::GetStandardNetworkSystemClock)},
|
{0x1, SFUNC(IStaticService::GetStandardNetworkSystemClock)},
|
||||||
|
{0x2, SFUNC(IStaticService::GetStandardSteadyClock)},
|
||||||
{0x3, SFUNC(IStaticService::GetTimeZoneService)},
|
{0x3, SFUNC(IStaticService::GetTimeZoneService)},
|
||||||
{0x4, SFUNC(IStaticService::GetStandardLocalSystemClock)}
|
{0x4, SFUNC(IStaticService::GetStandardLocalSystemClock)}
|
||||||
}) {}
|
}) {}
|
||||||
@ -21,6 +23,10 @@ namespace skyline::service::timesrv {
|
|||||||
manager.RegisterService(std::make_shared<ISystemClock>(SystemClockType::Network, state, manager), session, response);
|
manager.RegisterService(std::make_shared<ISystemClock>(SystemClockType::Network, state, manager), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IStaticService::GetStandardSteadyClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
manager.RegisterService(std::make_shared<ISteadyClock>(state, manager), session, response);
|
||||||
|
}
|
||||||
|
|
||||||
void IStaticService::GetTimeZoneService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void IStaticService::GetTimeZoneService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
manager.RegisterService(std::make_shared<ITimeZoneService>(state, manager), session, response);
|
manager.RegisterService(std::make_shared<ITimeZoneService>(state, manager), session, response);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,11 @@ namespace skyline::service::timesrv {
|
|||||||
*/
|
*/
|
||||||
void GetStandardNetworkSystemClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
void GetStandardNetworkSystemClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This returns a handle to a ISteadyClock for a steady timepoint
|
||||||
|
*/
|
||||||
|
void GetStandardSteadyClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This returns a handle to a ITimeZoneService for reading time zone information
|
* @brief This returns a handle to a ITimeZoneService for reading time zone information
|
||||||
*/
|
*/
|
||||||
|
14
app/src/main/cpp/skyline/services/timesrv/ISteadyClock.cpp
Normal file
14
app/src/main/cpp/skyline/services/timesrv/ISteadyClock.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
|
#include "ISteadyClock.h"
|
||||||
|
|
||||||
|
namespace skyline::service::timesrv {
|
||||||
|
ISteadyClock::ISteadyClock(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::timesrv_ISteadyClock, "timesrv:ISteadyClock", {
|
||||||
|
{0x0, SFUNC(ISteadyClock::GetCurrentTimePoint)}
|
||||||
|
}) {}
|
||||||
|
|
||||||
|
void ISteadyClock::GetCurrentTimePoint(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
response.Push(SteadyClockTimePoint{static_cast<u64>(std::time(nullptr))});
|
||||||
|
}
|
||||||
|
}
|
30
app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h
Normal file
30
app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <services/base_service.h>
|
||||||
|
#include <services/serviceman.h>
|
||||||
|
|
||||||
|
namespace skyline::service::timesrv {
|
||||||
|
/**
|
||||||
|
* @brief This holds a steady clock timepoint (https://switchbrew.org/wiki/PSC_services#SteadyClockTimePoint)
|
||||||
|
*/
|
||||||
|
struct SteadyClockTimePoint {
|
||||||
|
u64 timepoint; //!< The point in time of this timepoint
|
||||||
|
u8 id[0x10]; //!< The ID of the source clock
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ISteadyClock is used to retrieve a steady time that increments uniformly for the lifetime on an application (https://switchbrew.org/wiki/PSC_services#ISteadyClock)
|
||||||
|
*/
|
||||||
|
class ISteadyClock : public BaseService {
|
||||||
|
public:
|
||||||
|
ISteadyClock(const DeviceState &state, ServiceManager &manager);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This returns the current value of the steady clock
|
||||||
|
*/
|
||||||
|
void GetCurrentTimePoint(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
};
|
||||||
|
}
|
@ -1,14 +1,21 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
|
#include "ISteadyClock.h"
|
||||||
#include "ISystemClock.h"
|
#include "ISystemClock.h"
|
||||||
|
|
||||||
namespace skyline::service::timesrv {
|
namespace skyline::service::timesrv {
|
||||||
ISystemClock::ISystemClock(const SystemClockType clockType, const DeviceState &state, ServiceManager &manager) : type(clockType), BaseService(state, manager, Service::timesrv_ISystemClock, "timesrv:ISystemClock", {
|
ISystemClock::ISystemClock(const SystemClockType clockType, const DeviceState &state, ServiceManager &manager) : type(clockType), BaseService(state, manager, Service::timesrv_ISystemClock, "timesrv:ISystemClock", {
|
||||||
{0x0, SFUNC(ISystemClock::GetCurrentTime)}
|
{0x0, SFUNC(ISystemClock::GetCurrentTime)},
|
||||||
|
{0x2, SFUNC(ISystemClock::GetSystemClockContext)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
void ISystemClock::GetCurrentTime(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void ISystemClock::GetCurrentTime(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
response.Push<u64>(static_cast<u64>(std::time(nullptr)));
|
response.Push<u64>(static_cast<u64>(std::time(nullptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ISystemClock::GetSystemClockContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
response.Push<u64>(static_cast<u64>(std::time(nullptr)));
|
||||||
|
response.Push(SteadyClockTimePoint{static_cast<u64>(std::time(nullptr))});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,10 @@ namespace skyline::service::timesrv {
|
|||||||
* @brief This returns the amount of seconds since epoch
|
* @brief This returns the amount of seconds since epoch
|
||||||
*/
|
*/
|
||||||
void GetCurrentTime(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
void GetCurrentTime(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This returns the system clock context
|
||||||
|
*/
|
||||||
|
void GetSystemClockContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user