Compare commits
4 Commits
android-22
...
android-21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28a23c4380 | ||
|
|
c768c19898 | ||
|
|
7273701bc2 | ||
|
|
3bf0492edb |
4
.github/workflows/verify.yml
vendored
4
.github/workflows/verify.yml
vendored
@@ -73,7 +73,7 @@ jobs:
|
||||
build-mac:
|
||||
name: 'test build (macos)'
|
||||
needs: format
|
||||
runs-on: macos-14
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
export Qt5_DIR="$(brew --prefix qt@5)/lib/cmake"
|
||||
export Qt5_DIR="/usr/local/opt/qt@5/lib/cmake"
|
||||
cmake .. -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DYUZU_USE_BUNDLED_VCPKG=OFF -DYUZU_TESTS=OFF -DENABLE_WEB_SERVICE=OFF -DENABLE_LIBUSB=OFF
|
||||
ninja
|
||||
build-msvc:
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -64,6 +64,3 @@
|
||||
[submodule "oaknut"]
|
||||
path = externals/oaknut
|
||||
url = https://github.com/merryhime/oaknut
|
||||
[submodule "Vulkan-Utility-Libraries"]
|
||||
path = externals/Vulkan-Utility-Libraries
|
||||
url = https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
|
||||
|
||||
@@ -36,8 +36,6 @@ option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}")
|
||||
|
||||
option(YUZU_USE_EXTERNAL_VULKAN_HEADERS "Use Vulkan-Headers from externals" ON)
|
||||
|
||||
option(YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES "Use Vulkan-Utility-Libraries from externals" ON)
|
||||
|
||||
option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF)
|
||||
|
||||
option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF)
|
||||
@@ -310,10 +308,6 @@ if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS)
|
||||
find_package(Vulkan 1.3.274 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (NOT YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES)
|
||||
find_package(VulkanUtilityLibraries REQUIRED)
|
||||
endif()
|
||||
|
||||
if (ENABLE_LIBUSB)
|
||||
find_package(libusb 1.0.24 MODULE)
|
||||
endif()
|
||||
@@ -322,10 +316,6 @@ if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64)
|
||||
find_package(xbyak 6 CONFIG)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_arm64)
|
||||
find_package(oaknut 2.0.1 CONFIG)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
|
||||
find_package(dynarmic 6.4.0 CONFIG)
|
||||
endif()
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [12461](https://github.com/yuzu-emu/yuzu-android//pull/12461) | [`e1f31cfe5`](https://github.com/yuzu-emu/yuzu-android//pull/12461/files) | Rework Nvdec and VIC to fix out-of-order videos, and speed up decoding. | [Kelebek1](https://github.com/Kelebek1/) | Yes |
|
||||
| [12749](https://github.com/yuzu-emu/yuzu-android//pull/12749) | [`aad4b0d6f`](https://github.com/yuzu-emu/yuzu-android//pull/12749/files) | general: workarounds for SMMU syncing issues | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12848](https://github.com/yuzu-emu/yuzu-android//pull/12848) | [`4afca6bf5`](https://github.com/yuzu-emu/yuzu-android//pull/12848/files) | service: capsrv: Migrate to new IPC | [german77](https://github.com/german77/) | Yes |
|
||||
| [12874](https://github.com/yuzu-emu/yuzu-android//pull/12874) | [`f410cf681`](https://github.com/yuzu-emu/yuzu-android//pull/12874/files) | Revert "shader_recompiler: fix Offset operand usage for non-OpImage*Gather" | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12875](https://github.com/yuzu-emu/yuzu-android//pull/12875) | [`5cb9fe781`](https://github.com/yuzu-emu/yuzu-android//pull/12875/files) | SwBlitter: Fix Pitch linear reading/writting | [FernandoS27](https://github.com/FernandoS27/) | Yes |
|
||||
| [12749](https://github.com/yuzu-emu/yuzu-android//pull/12749) | [`e3171486d`](https://github.com/yuzu-emu/yuzu-android//pull/12749/files) | general: workarounds for SMMU syncing issues | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12760](https://github.com/yuzu-emu/yuzu-android//pull/12760) | [`2c33ba278`](https://github.com/yuzu-emu/yuzu-android//pull/12760/files) | am: rewrite for multiprocess support | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12802](https://github.com/yuzu-emu/yuzu-android//pull/12802) | [`c5e88c654`](https://github.com/yuzu-emu/yuzu-android//pull/12802/files) | service: mii: Migrate service to new interface | [german77](https://github.com/german77/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
||||
10
externals/CMakeLists.txt
vendored
10
externals/CMakeLists.txt
vendored
@@ -14,17 +14,16 @@ set(BUILD_SHARED_LIBS OFF)
|
||||
# Skip install rules for all externals
|
||||
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
|
||||
# Xbyak (also used by Dynarmic, so needs to be added first)
|
||||
# xbyak
|
||||
if ((ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) AND NOT TARGET xbyak::xbyak)
|
||||
add_subdirectory(xbyak)
|
||||
endif()
|
||||
|
||||
# Oaknut (also used by Dynarmic, so needs to be added first)
|
||||
# Dynarmic
|
||||
if (ARCHITECTURE_arm64 AND NOT TARGET merry::oaknut)
|
||||
add_subdirectory(oaknut)
|
||||
endif()
|
||||
|
||||
# Dynarmic
|
||||
if ((ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) AND NOT TARGET dynarmic::dynarmic)
|
||||
set(DYNARMIC_IGNORE_ASSERTS ON)
|
||||
add_subdirectory(dynarmic)
|
||||
@@ -155,11 +154,6 @@ if (YUZU_USE_EXTERNAL_VULKAN_HEADERS)
|
||||
add_subdirectory(Vulkan-Headers)
|
||||
endif()
|
||||
|
||||
# Vulkan-Utility-Libraries
|
||||
if (YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES)
|
||||
add_subdirectory(Vulkan-Utility-Libraries)
|
||||
endif()
|
||||
|
||||
# TZDB (Time Zone Database)
|
||||
add_subdirectory(nx_tzdb)
|
||||
|
||||
|
||||
1
externals/Vulkan-Utility-Libraries
vendored
1
externals/Vulkan-Utility-Libraries
vendored
Submodule externals/Vulkan-Utility-Libraries deleted from 524f8910d0
2
externals/dynarmic
vendored
2
externals/dynarmic
vendored
Submodule externals/dynarmic updated: ca0e264f4f...0df09e2f6b
2
externals/oaknut
vendored
2
externals/oaknut
vendored
Submodule externals/oaknut updated: 9d091109de...918bd94f02
4
externals/tz/tz/tz.cpp
vendored
4
externals/tz/tz/tz.cpp
vendored
@@ -1625,11 +1625,11 @@ s32 ParseTimeZoneBinary(Rule& out_rule, std::span<const u8> binary) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool localtime_rz(CalendarTimeInternal* tmp, Rule const* sp, time_t* timep) {
|
||||
bool localtime_rz(CalendarTimeInternal* tmp, Rule* sp, time_t* timep) {
|
||||
return localsub(sp, timep, 0, tmp) == nullptr;
|
||||
}
|
||||
|
||||
u32 mktime_tzname(time_t* out_time, Rule const* sp, CalendarTimeInternal* tmp) {
|
||||
u32 mktime_tzname(time_t* out_time, Rule* sp, CalendarTimeInternal* tmp) {
|
||||
return time1(out_time, tmp, localsub, sp, 0);
|
||||
}
|
||||
|
||||
|
||||
4
externals/tz/tz/tz.h
vendored
4
externals/tz/tz/tz.h
vendored
@@ -75,7 +75,7 @@ static_assert(sizeof(CalendarTimeInternal) == 0x3C, "CalendarTimeInternal has th
|
||||
|
||||
s32 ParseTimeZoneBinary(Rule& out_rule, std::span<const u8> binary);
|
||||
|
||||
bool localtime_rz(CalendarTimeInternal* tmp, Rule const* sp, time_t* timep);
|
||||
u32 mktime_tzname(time_t* out_time, Rule const* sp, CalendarTimeInternal* tmp);
|
||||
bool localtime_rz(CalendarTimeInternal* tmp, Rule* sp, time_t* timep);
|
||||
u32 mktime_tzname(time_t* out_time, Rule* sp, CalendarTimeInternal* tmp);
|
||||
|
||||
} // namespace Tz
|
||||
|
||||
@@ -261,7 +261,7 @@ object NativeLibrary {
|
||||
/**
|
||||
* Begins emulation.
|
||||
*/
|
||||
external fun run(path: String?, programIndex: Int, frontendInitiated: Boolean)
|
||||
external fun run(path: String?)
|
||||
|
||||
// Surface Handling
|
||||
external fun surfaceChanged(surf: Surface?)
|
||||
@@ -489,12 +489,6 @@ object NativeLibrary {
|
||||
sEmulationActivity.get()!!.onEmulationStopped(status)
|
||||
}
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun onProgramChanged(programIndex: Int) {
|
||||
sEmulationActivity.get()!!.onProgramChanged(programIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the Yuzu version, Android version and, CPU.
|
||||
*/
|
||||
|
||||
@@ -76,6 +76,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
|
||||
override fun onDestroy() {
|
||||
stopForegroundService(this)
|
||||
emulationViewModel.clear()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@@ -445,14 +446,9 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
}
|
||||
|
||||
fun onEmulationStopped(status: Int) {
|
||||
if (status == 0 && emulationViewModel.programChanged.value == -1) {
|
||||
if (status == 0) {
|
||||
finish()
|
||||
}
|
||||
emulationViewModel.setEmulationStopped(true)
|
||||
}
|
||||
|
||||
fun onProgramChanged(programIndex: Int) {
|
||||
emulationViewModel.setProgramChanged(programIndex)
|
||||
}
|
||||
|
||||
private fun startMotionSensorListener() {
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.CardDriverOptionBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||
import org.yuzu.yuzu_emu.model.Driver
|
||||
@@ -58,9 +57,13 @@ class DriverAdapter(private val driverViewModel: DriverViewModel) :
|
||||
title.text = model.title
|
||||
version.text = model.version
|
||||
description.text = model.description
|
||||
if (model.title != binding.root.context.getString(R.string.system_gpu_driver)) {
|
||||
if (model.description.isNotEmpty()) {
|
||||
version.visibility = View.VISIBLE
|
||||
description.visibility = View.VISIBLE
|
||||
buttonDelete.visibility = View.VISIBLE
|
||||
} else {
|
||||
version.visibility = View.GONE
|
||||
description.visibility = View.GONE
|
||||
buttonDelete.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,38 +424,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
emulationViewModel.programChanged.collect {
|
||||
if (it != 0) {
|
||||
emulationViewModel.setEmulationStarted(false)
|
||||
binding.drawerLayout.close()
|
||||
binding.drawerLayout
|
||||
.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
||||
ViewUtils.hideView(binding.surfaceInputOverlay)
|
||||
ViewUtils.showView(binding.loadingIndicator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
emulationViewModel.emulationStopped.collect {
|
||||
if (it && emulationViewModel.programChanged.value != -1) {
|
||||
if (perfStatsUpdater != null) {
|
||||
perfStatsUpdateHandler.removeCallbacks(perfStatsUpdater!!)
|
||||
}
|
||||
emulationState.changeProgram(emulationViewModel.programChanged.value)
|
||||
emulationViewModel.setProgramChanged(-1)
|
||||
emulationViewModel.setEmulationStopped(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startEmulation(programIndex: Int = 0) {
|
||||
private fun startEmulation() {
|
||||
if (!NativeLibrary.isRunning() && !NativeLibrary.isPaused()) {
|
||||
if (!DirectoryInitialization.areDirectoriesReady) {
|
||||
DirectoryInitialization.start()
|
||||
@@ -463,7 +435,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
|
||||
updateScreenLayout()
|
||||
|
||||
emulationState.run(emulationActivity!!.isActivityRecreated, programIndex)
|
||||
emulationState.run(emulationActivity!!.isActivityRecreated)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +833,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
) {
|
||||
private var state: State
|
||||
private var surface: Surface? = null
|
||||
lateinit var emulationThread: Thread
|
||||
|
||||
init {
|
||||
// Starting state is stopped.
|
||||
@@ -907,7 +878,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun run(isActivityRecreated: Boolean, programIndex: Int = 0) {
|
||||
fun run(isActivityRecreated: Boolean) {
|
||||
if (isActivityRecreated) {
|
||||
if (NativeLibrary.isRunning()) {
|
||||
state = State.PAUSED
|
||||
@@ -918,20 +889,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
|
||||
// If the surface is set, run now. Otherwise, wait for it to get set.
|
||||
if (surface != null) {
|
||||
runWithValidSurface(programIndex)
|
||||
runWithValidSurface()
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun changeProgram(programIndex: Int) {
|
||||
emulationThread.join()
|
||||
emulationThread = Thread({
|
||||
Log.debug("[EmulationFragment] Starting emulation thread.")
|
||||
NativeLibrary.run(gamePath, programIndex, false)
|
||||
}, "NativeEmulation")
|
||||
emulationThread.start()
|
||||
}
|
||||
|
||||
// Surface callbacks
|
||||
@Synchronized
|
||||
fun newSurface(surface: Surface?) {
|
||||
@@ -971,7 +932,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
private fun runWithValidSurface(programIndex: Int = 0) {
|
||||
private fun runWithValidSurface() {
|
||||
NativeLibrary.surfaceChanged(surface)
|
||||
if (!emulationCanStart.invoke()) {
|
||||
return
|
||||
@@ -979,9 +940,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
|
||||
when (state) {
|
||||
State.STOPPED -> {
|
||||
emulationThread = Thread({
|
||||
val emulationThread = Thread({
|
||||
Log.debug("[EmulationFragment] Starting emulation thread.")
|
||||
NativeLibrary.run(gamePath, programIndex, true)
|
||||
NativeLibrary.run(gamePath)
|
||||
}, "NativeEmulation")
|
||||
emulationThread.start()
|
||||
}
|
||||
|
||||
@@ -66,13 +66,10 @@ class DriverViewModel : ViewModel() {
|
||||
|
||||
fun updateDriverList() {
|
||||
val selectedDriver = GpuDriverHelper.customDriverSettingData
|
||||
val systemDriverData = GpuDriverHelper.getSystemDriverInfo()
|
||||
val newDriverList = mutableListOf(
|
||||
Driver(
|
||||
selectedDriver == GpuDriverMetadata(),
|
||||
YuzuApplication.appContext.getString(R.string.system_gpu_driver),
|
||||
systemDriverData?.get(0) ?: "",
|
||||
systemDriverData?.get(1) ?: ""
|
||||
YuzuApplication.appContext.getString(R.string.system_gpu_driver)
|
||||
)
|
||||
)
|
||||
driverData.forEach {
|
||||
|
||||
@@ -15,12 +15,6 @@ class EmulationViewModel : ViewModel() {
|
||||
val isEmulationStopping: StateFlow<Boolean> get() = _isEmulationStopping
|
||||
private val _isEmulationStopping = MutableStateFlow(false)
|
||||
|
||||
private val _emulationStopped = MutableStateFlow(false)
|
||||
val emulationStopped = _emulationStopped.asStateFlow()
|
||||
|
||||
private val _programChanged = MutableStateFlow(-1)
|
||||
val programChanged = _programChanged.asStateFlow()
|
||||
|
||||
val shaderProgress: StateFlow<Int> get() = _shaderProgress
|
||||
private val _shaderProgress = MutableStateFlow(0)
|
||||
|
||||
@@ -41,17 +35,6 @@ class EmulationViewModel : ViewModel() {
|
||||
_isEmulationStopping.value = value
|
||||
}
|
||||
|
||||
fun setEmulationStopped(value: Boolean) {
|
||||
if (value) {
|
||||
_emulationStarted.value = false
|
||||
}
|
||||
_emulationStopped.value = value
|
||||
}
|
||||
|
||||
fun setProgramChanged(programIndex: Int) {
|
||||
_programChanged.value = programIndex
|
||||
}
|
||||
|
||||
fun setShaderProgress(progress: Int) {
|
||||
_shaderProgress.value = progress
|
||||
}
|
||||
@@ -73,4 +56,20 @@ class EmulationViewModel : ViewModel() {
|
||||
fun setDrawerOpen(value: Boolean) {
|
||||
_drawerOpen.value = value
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
setEmulationStarted(false)
|
||||
setIsEmulationStopping(false)
|
||||
setShaderProgress(0)
|
||||
setTotalShaders(0)
|
||||
setShaderMessage("")
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_EMULATION_STARTED = "EmulationStarted"
|
||||
const val KEY_IS_EMULATION_STOPPING = "IsEmulationStarting"
|
||||
const val KEY_SHADER_PROGRESS = "ShaderProgress"
|
||||
const val KEY_TOTAL_SHADERS = "TotalShaders"
|
||||
const val KEY_SHADER_MESSAGE = "ShaderMessage"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.utils
|
||||
|
||||
import android.graphics.SurfaceTexture
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.view.Surface
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
@@ -197,11 +195,6 @@ object GpuDriverHelper {
|
||||
|
||||
external fun supportsCustomDriverLoading(): Boolean
|
||||
|
||||
external fun getSystemDriverInfo(
|
||||
surface: Surface = Surface(SurfaceTexture(true)),
|
||||
hookLibPath: String = GpuDriverHelper.hookLibPath!!
|
||||
): Array<String>?
|
||||
|
||||
// Parse the custom driver metadata to retrieve the name.
|
||||
val installedCustomDriverData: GpuDriverMetadata
|
||||
get() = GpuDriverMetadata(File(driverInstallationPath + META_JSON_FILENAME))
|
||||
|
||||
@@ -22,7 +22,7 @@ add_library(yuzu-android SHARED
|
||||
|
||||
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
|
||||
|
||||
target_link_libraries(yuzu-android PRIVATE audio_core common core input_common frontend_common Vulkan::Headers)
|
||||
target_link_libraries(yuzu-android PRIVATE audio_core common core input_common frontend_common)
|
||||
target_link_libraries(yuzu-android PRIVATE android camera2ndk EGL glad jnigraphics log)
|
||||
if (ARCHITECTURE_arm64)
|
||||
target_link_libraries(yuzu-android PRIVATE adrenotools)
|
||||
|
||||
@@ -19,7 +19,6 @@ static jmethodID s_exit_emulation_activity;
|
||||
static jmethodID s_disk_cache_load_progress;
|
||||
static jmethodID s_on_emulation_started;
|
||||
static jmethodID s_on_emulation_stopped;
|
||||
static jmethodID s_on_program_changed;
|
||||
|
||||
static jclass s_game_class;
|
||||
static jmethodID s_game_constructor;
|
||||
@@ -124,10 +123,6 @@ jmethodID GetOnEmulationStopped() {
|
||||
return s_on_emulation_stopped;
|
||||
}
|
||||
|
||||
jmethodID GetOnProgramChanged() {
|
||||
return s_on_program_changed;
|
||||
}
|
||||
|
||||
jclass GetGameClass() {
|
||||
return s_game_class;
|
||||
}
|
||||
@@ -311,8 +306,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V");
|
||||
s_on_emulation_stopped =
|
||||
env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V");
|
||||
s_on_program_changed =
|
||||
env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V");
|
||||
|
||||
const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game");
|
||||
s_game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class));
|
||||
|
||||
@@ -19,7 +19,6 @@ jmethodID GetExitEmulationActivity();
|
||||
jmethodID GetDiskCacheLoadProgress();
|
||||
jmethodID GetOnEmulationStarted();
|
||||
jmethodID GetOnEmulationStopped();
|
||||
jmethodID GetOnProgramChanged();
|
||||
|
||||
jclass GetGameClass();
|
||||
jmethodID GetGameConstructor();
|
||||
|
||||
@@ -61,9 +61,6 @@
|
||||
#include "jni/id_cache.h"
|
||||
#include "jni/native.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
#include "video_core/vulkan_common/vulkan_instance.h"
|
||||
#include "video_core/vulkan_common/vulkan_surface.h"
|
||||
|
||||
#define jconst [[maybe_unused]] const auto
|
||||
#define jauto [[maybe_unused]] auto
|
||||
@@ -218,9 +215,7 @@ void EmulationSession::SetAppletId(int applet_id) {
|
||||
static_cast<Service::AM::AppletId>(m_applet_id));
|
||||
}
|
||||
|
||||
Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath,
|
||||
const std::size_t program_index,
|
||||
const bool frontend_initiated) {
|
||||
Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
|
||||
// Create the render window.
|
||||
@@ -252,9 +247,6 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string
|
||||
// Load the ROM.
|
||||
Service::AM::FrontendAppletParameters params{
|
||||
.applet_id = static_cast<Service::AM::AppletId>(m_applet_id),
|
||||
.launch_type = frontend_initiated ? Service::AM::LaunchType::FrontendInitiated
|
||||
: Service::AM::LaunchType::ApplicationInitiated,
|
||||
.program_index = static_cast<s32>(program_index),
|
||||
};
|
||||
m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath, params);
|
||||
if (m_load_result != Core::SystemResultStatus::Success) {
|
||||
@@ -266,12 +258,6 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string
|
||||
m_system.GetCpuManager().OnGpuReady();
|
||||
m_system.RegisterExitCallback([&] { HaltEmulation(); });
|
||||
|
||||
// Register an ExecuteProgram callback such that Core can execute a sub-program
|
||||
m_system.RegisterExecuteProgramCallback([&](std::size_t program_index_) {
|
||||
m_next_program_index = program_index_;
|
||||
EmulationSession::GetInstance().HaltEmulation();
|
||||
});
|
||||
|
||||
OnEmulationStarted();
|
||||
return Core::SystemResultStatus::Success;
|
||||
}
|
||||
@@ -279,11 +265,6 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string
|
||||
void EmulationSession::ShutdownEmulation() {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
|
||||
if (m_next_program_index != -1) {
|
||||
ChangeProgram(m_next_program_index);
|
||||
m_next_program_index = -1;
|
||||
}
|
||||
|
||||
m_is_running = false;
|
||||
|
||||
// Unload user input.
|
||||
@@ -434,12 +415,6 @@ void EmulationSession::OnEmulationStopped(Core::SystemResultStatus result) {
|
||||
static_cast<jint>(result));
|
||||
}
|
||||
|
||||
void EmulationSession::ChangeProgram(std::size_t program_index) {
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnProgramChanged(),
|
||||
static_cast<jint>(program_index));
|
||||
}
|
||||
|
||||
u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) {
|
||||
auto program_id_string = GetJString(env, jprogramId);
|
||||
try {
|
||||
@@ -449,9 +424,7 @@ u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) {
|
||||
}
|
||||
}
|
||||
|
||||
static Core::SystemResultStatus RunEmulation(const std::string& filepath,
|
||||
const size_t program_index,
|
||||
const bool frontend_initiated) {
|
||||
static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
|
||||
MicroProfileOnThreadCreate("EmuThread");
|
||||
SCOPE_EXIT({ MicroProfileShutdown(); });
|
||||
|
||||
@@ -464,8 +437,7 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath,
|
||||
|
||||
SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); });
|
||||
|
||||
jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index,
|
||||
frontend_initiated);
|
||||
jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath);
|
||||
if (result != Core::SystemResultStatus::Success) {
|
||||
return result;
|
||||
}
|
||||
@@ -562,37 +534,6 @@ jboolean JNICALL Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_supportsCustomDri
|
||||
#endif
|
||||
}
|
||||
|
||||
jobjectArray Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getSystemDriverInfo(
|
||||
JNIEnv* env, jobject j_obj, jobject j_surf, jstring j_hook_lib_dir) {
|
||||
const char* file_redirect_dir_{};
|
||||
int featureFlags{};
|
||||
std::string hook_lib_dir = GetJString(env, j_hook_lib_dir);
|
||||
auto handle = adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(),
|
||||
nullptr, nullptr, file_redirect_dir_, nullptr);
|
||||
auto driver_library = std::make_shared<Common::DynamicLibrary>(handle);
|
||||
InputCommon::InputSubsystem input_subsystem;
|
||||
auto m_window = std::make_unique<EmuWindow_Android>(
|
||||
&input_subsystem, ANativeWindow_fromSurface(env, j_surf), driver_library);
|
||||
|
||||
Vulkan::vk::InstanceDispatch dld;
|
||||
Vulkan::vk::Instance vk_instance = Vulkan::CreateInstance(
|
||||
*driver_library, dld, VK_API_VERSION_1_1, Core::Frontend::WindowSystemType::Android);
|
||||
|
||||
auto surface = Vulkan::CreateSurface(vk_instance, m_window->GetWindowInfo());
|
||||
|
||||
auto device = Vulkan::CreateDevice(vk_instance, dld, *surface);
|
||||
|
||||
auto driver_version = device.GetDriverVersion();
|
||||
auto version_string =
|
||||
fmt::format("{}.{}.{}", VK_API_VERSION_MAJOR(driver_version),
|
||||
VK_API_VERSION_MINOR(driver_version), VK_API_VERSION_PATCH(driver_version));
|
||||
|
||||
jobjectArray j_driver_info =
|
||||
env->NewObjectArray(2, IDCache::GetStringClass(), ToJString(env, version_string));
|
||||
env->SetObjectArrayElement(j_driver_info, 1, ToJString(env, device.GetDriverName()));
|
||||
return j_driver_info;
|
||||
}
|
||||
|
||||
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_reloadKeys(JNIEnv* env, jclass clazz) {
|
||||
Core::Crypto::KeyManager::Instance().ReloadKeys();
|
||||
return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded());
|
||||
@@ -761,13 +702,11 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj
|
||||
Settings::LogSettings();
|
||||
}
|
||||
|
||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path,
|
||||
jint j_program_index,
|
||||
jboolean j_frontend_initiated) {
|
||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_run__Ljava_lang_String_2(JNIEnv* env, jclass clazz,
|
||||
jstring j_path) {
|
||||
const std::string path = GetJString(env, j_path);
|
||||
|
||||
const Core::SystemResultStatus result{
|
||||
RunEmulation(path, j_program_index, j_frontend_initiated)};
|
||||
const Core::SystemResultStatus result{RunEmulation(path)};
|
||||
if (result != Core::SystemResultStatus::Success) {
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
||||
IDCache::GetExitEmulationActivity(), static_cast<int>(result));
|
||||
|
||||
@@ -46,9 +46,7 @@ public:
|
||||
void ConfigureFilesystemProvider(const std::string& filepath);
|
||||
void InitializeSystem(bool reload);
|
||||
void SetAppletId(int applet_id);
|
||||
Core::SystemResultStatus InitializeEmulation(const std::string& filepath,
|
||||
const std::size_t program_index,
|
||||
const bool frontend_initiated);
|
||||
Core::SystemResultStatus InitializeEmulation(const std::string& filepath);
|
||||
|
||||
bool IsHandheldOnly();
|
||||
void SetDeviceType([[maybe_unused]] int index, int type);
|
||||
@@ -63,7 +61,6 @@ public:
|
||||
private:
|
||||
static void LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress, int max);
|
||||
static void OnEmulationStopped(Core::SystemResultStatus result);
|
||||
static void ChangeProgram(std::size_t program_index);
|
||||
|
||||
private:
|
||||
// Window management
|
||||
@@ -89,7 +86,4 @@ private:
|
||||
// Synchronization
|
||||
std::condition_variable_any m_cv;
|
||||
mutable std::mutex m_mutex;
|
||||
|
||||
// Program index for next boot
|
||||
std::atomic<s32> m_next_program_index = -1;
|
||||
};
|
||||
|
||||
@@ -34,10 +34,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="false"
|
||||
android:defaultFocusHighlightEnabled="false"
|
||||
android:clickable="false"
|
||||
app:rippleColor="@android:color/transparent">
|
||||
android:clickable="false">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/loading_layout"
|
||||
|
||||
@@ -210,6 +210,8 @@ add_library(audio_core STATIC
|
||||
sink/sink_stream.h
|
||||
)
|
||||
|
||||
create_target_directory_groups(audio_core)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(audio_core PRIVATE
|
||||
/we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
|
||||
@@ -265,5 +267,3 @@ endif()
|
||||
if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||
target_precompile_headers(audio_core PRIVATE precompiled_headers.h)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(audio_core)
|
||||
|
||||
@@ -89,13 +89,11 @@ u32 AudioRenderer::Receive(Direction dir) {
|
||||
}
|
||||
|
||||
void AudioRenderer::SetCommandBuffer(s32 session_id, CpuAddr buffer, u64 size, u64 time_limit,
|
||||
u64 applet_resource_user_id, Kernel::KProcess* process,
|
||||
bool reset) noexcept {
|
||||
u64 applet_resource_user_id, bool reset) noexcept {
|
||||
command_buffers[session_id].buffer = buffer;
|
||||
command_buffers[session_id].size = size;
|
||||
command_buffers[session_id].time_limit = time_limit;
|
||||
command_buffers[session_id].applet_resource_user_id = applet_resource_user_id;
|
||||
command_buffers[session_id].process = process;
|
||||
command_buffers[session_id].reset_buffer = reset;
|
||||
}
|
||||
|
||||
@@ -175,8 +173,7 @@ void AudioRenderer::Main(std::stop_token stop_token) {
|
||||
// If there are no remaining commands (from the previous list),
|
||||
// this is a new command list, initialize it.
|
||||
if (command_buffer.remaining_command_count == 0) {
|
||||
command_list_processor.Initialize(system, *command_buffer.process,
|
||||
command_buffer.buffer,
|
||||
command_list_processor.Initialize(system, command_buffer.buffer,
|
||||
command_buffer.size, streams[index]);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ namespace Core {
|
||||
class System;
|
||||
} // namespace Core
|
||||
|
||||
namespace Kernel {
|
||||
class KProcess;
|
||||
}
|
||||
|
||||
namespace AudioCore {
|
||||
namespace Sink {
|
||||
class Sink;
|
||||
@@ -73,8 +69,7 @@ public:
|
||||
u32 Receive(Direction dir);
|
||||
|
||||
void SetCommandBuffer(s32 session_id, CpuAddr buffer, u64 size, u64 time_limit,
|
||||
u64 applet_resource_user_id, Kernel::KProcess* process,
|
||||
bool reset) noexcept;
|
||||
u64 applet_resource_user_id, bool reset) noexcept;
|
||||
u32 GetRemainCommandCount(s32 session_id) const noexcept;
|
||||
void ClearRemainCommandCount(s32 session_id) noexcept;
|
||||
u64 GetRenderingStartTick(s32 session_id) const noexcept;
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
#include "audio_core/common/common.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Kernel {
|
||||
class KProcess;
|
||||
}
|
||||
|
||||
namespace AudioCore::ADSP::AudioRenderer {
|
||||
|
||||
struct CommandBuffer {
|
||||
@@ -18,7 +14,6 @@ struct CommandBuffer {
|
||||
u64 size{};
|
||||
u64 time_limit{};
|
||||
u64 applet_resource_user_id{};
|
||||
Kernel::KProcess* process{};
|
||||
bool reset_buffer{};
|
||||
// Set by the DSP
|
||||
u32 remaining_command_count{};
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace AudioCore::ADSP::AudioRenderer {
|
||||
|
||||
void CommandListProcessor::Initialize(Core::System& system_, Kernel::KProcess& process,
|
||||
CpuAddr buffer, u64 size, Sink::SinkStream* stream_) {
|
||||
void CommandListProcessor::Initialize(Core::System& system_, CpuAddr buffer, u64 size,
|
||||
Sink::SinkStream* stream_) {
|
||||
system = &system_;
|
||||
memory = &process.GetMemory();
|
||||
memory = &system->ApplicationMemory();
|
||||
stream = stream_;
|
||||
header = reinterpret_cast<Renderer::CommandListHeader*>(buffer);
|
||||
commands = reinterpret_cast<u8*>(buffer + sizeof(Renderer::CommandListHeader));
|
||||
|
||||
@@ -16,10 +16,6 @@ class Memory;
|
||||
class System;
|
||||
} // namespace Core
|
||||
|
||||
namespace Kernel {
|
||||
class KProcess;
|
||||
}
|
||||
|
||||
namespace AudioCore {
|
||||
namespace Sink {
|
||||
class SinkStream;
|
||||
@@ -44,8 +40,7 @@ public:
|
||||
* @param size - The size of the buffer.
|
||||
* @param stream - The stream to be used for sending the samples.
|
||||
*/
|
||||
void Initialize(Core::System& system, Kernel::KProcess& process, CpuAddr buffer, u64 size,
|
||||
Sink::SinkStream* stream);
|
||||
void Initialize(Core::System& system, CpuAddr buffer, u64 size, Sink::SinkStream* stream);
|
||||
|
||||
/**
|
||||
* Set the maximum processing time for this command list.
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "audio_core/renderer/audio_renderer.h"
|
||||
#include "audio_core/renderer/system_manager.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/hle/service/audio/errors.h"
|
||||
|
||||
@@ -18,8 +17,7 @@ Renderer::Renderer(Core::System& system_, Manager& manager_, Kernel::KEvent* ren
|
||||
Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory,
|
||||
const u64 transfer_memory_size, const u32 process_handle,
|
||||
Kernel::KProcess& process, const u64 applet_resource_user_id,
|
||||
const s32 session_id) {
|
||||
const u64 applet_resource_user_id, const s32 session_id) {
|
||||
if (params.execution_mode == ExecutionMode::Auto) {
|
||||
if (!manager.AddSystem(system)) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
@@ -30,7 +28,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
system.Initialize(params, transfer_memory, transfer_memory_size, process_handle, process,
|
||||
system.Initialize(params, transfer_memory, transfer_memory_size, process_handle,
|
||||
applet_resource_user_id, session_id);
|
||||
|
||||
return ResultSuccess;
|
||||
|
||||
@@ -14,8 +14,7 @@ class System;
|
||||
|
||||
namespace Kernel {
|
||||
class KTransferMemory;
|
||||
class KProcess;
|
||||
} // namespace Kernel
|
||||
}
|
||||
|
||||
namespace AudioCore {
|
||||
struct AudioRendererParameterInternal;
|
||||
@@ -45,8 +44,7 @@ public:
|
||||
*/
|
||||
Result Initialize(const AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle, Kernel::KProcess& process, u64 applet_resource_user_id,
|
||||
s32 session_id);
|
||||
u32 process_handle, u64 applet_resource_user_id, s32 session_id);
|
||||
|
||||
/**
|
||||
* Finalize the renderer for shutdown.
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
@@ -102,8 +101,7 @@ System::System(Core::System& core_, Kernel::KEvent* adsp_rendered_event_)
|
||||
|
||||
Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle_, Kernel::KProcess& process_,
|
||||
u64 applet_resource_user_id_, s32 session_id_) {
|
||||
u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) {
|
||||
if (!CheckValidRevision(params.revision)) {
|
||||
return Service::Audio::ResultInvalidRevision;
|
||||
}
|
||||
@@ -119,7 +117,6 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
behavior.SetUserLibRevision(params.revision);
|
||||
|
||||
process_handle = process_handle_;
|
||||
process = &process_;
|
||||
applet_resource_user_id = applet_resource_user_id_;
|
||||
session_id = session_id_;
|
||||
|
||||
@@ -132,7 +129,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
render_device = params.rendering_device;
|
||||
execution_mode = params.execution_mode;
|
||||
|
||||
process->GetMemory().ZeroBlock(transfer_memory->GetSourceAddress(), transfer_memory_size);
|
||||
core.ApplicationMemory().ZeroBlock(transfer_memory->GetSourceAddress(), transfer_memory_size);
|
||||
|
||||
// Note: We're not actually using the transfer memory because it's a pain to code for.
|
||||
// Allocate the memory normally instead and hope the game doesn't try to read anything back
|
||||
@@ -616,8 +613,7 @@ void System::SendCommandToDsp() {
|
||||
static_cast<u64>((time_limit_percent / 100) * 2'880'000.0 *
|
||||
(static_cast<f32>(render_time_limit_percent) / 100.0f))};
|
||||
audio_renderer.SetCommandBuffer(session_id, translated_addr, command_size, time_limit,
|
||||
applet_resource_user_id, process,
|
||||
reset_command_buffers);
|
||||
applet_resource_user_id, reset_command_buffers);
|
||||
reset_command_buffers = false;
|
||||
command_buffer_size = command_size;
|
||||
if (remaining_command_count == 0) {
|
||||
|
||||
@@ -29,7 +29,6 @@ class System;
|
||||
|
||||
namespace Kernel {
|
||||
class KEvent;
|
||||
class KProcess;
|
||||
class KTransferMemory;
|
||||
} // namespace Kernel
|
||||
|
||||
@@ -81,8 +80,7 @@ public:
|
||||
*/
|
||||
Result Initialize(const AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle, Kernel::KProcess& process, u64 applet_resource_user_id,
|
||||
s32 session_id);
|
||||
u32 process_handle, u64 applet_resource_user_id, s32 session_id);
|
||||
|
||||
/**
|
||||
* Finalize the system.
|
||||
@@ -277,8 +275,6 @@ private:
|
||||
Common::Event terminate_event{};
|
||||
/// Does what locks do
|
||||
std::mutex lock{};
|
||||
/// Process this audio render is operating within, used for memory reads/writes.
|
||||
Kernel::KProcess* process{};
|
||||
/// Handle for the process for this system, unused
|
||||
u32 process_handle{};
|
||||
/// Applet resource id for this system, unused
|
||||
|
||||
@@ -245,6 +245,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(common)
|
||||
|
||||
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
|
||||
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
|
||||
|
||||
@@ -256,5 +258,3 @@ endif()
|
||||
if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||
target_precompile_headers(common PRIVATE precompiled_headers.h)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(common)
|
||||
|
||||
@@ -15,34 +15,25 @@ namespace Common {
|
||||
|
||||
#if _MSC_VER
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected);
|
||||
template <typename T>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected, T& actual);
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected) {
|
||||
const u8 result =
|
||||
_InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected);
|
||||
return result == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, u16 expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u16* pointer, u16 value, u16 expected) {
|
||||
const u16 result =
|
||||
_InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected);
|
||||
return result == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, u32 expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u32* pointer, u32 value, u32 expected) {
|
||||
const u32 result =
|
||||
_InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected);
|
||||
return result == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, u64 expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u64 value, u64 expected) {
|
||||
const u64 result = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer),
|
||||
value, expected);
|
||||
return result == expected;
|
||||
@@ -54,32 +45,29 @@ template <>
|
||||
reinterpret_cast<__int64*>(expected.data())) != 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected, u8& actual) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected,
|
||||
u8& actual) {
|
||||
actual =
|
||||
_InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, u16 expected,
|
||||
u16& actual) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u16* pointer, u16 value, u16 expected,
|
||||
u16& actual) {
|
||||
actual =
|
||||
_InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, u32 expected,
|
||||
u32& actual) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u32* pointer, u32 value, u32 expected,
|
||||
u32& actual) {
|
||||
actual =
|
||||
_InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
template <>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, u64 expected,
|
||||
u64& actual) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u64 value, u64 expected,
|
||||
u64& actual) {
|
||||
actual = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer), value,
|
||||
expected);
|
||||
return actual == expected;
|
||||
@@ -103,12 +91,23 @@ template <>
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected) {
|
||||
return __sync_bool_compare_and_swap(pointer, expected, value);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(u64* pointer, u128 value, u128 expected) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u16* pointer, u16 value, u16 expected) {
|
||||
return __sync_bool_compare_and_swap(pointer, expected, value);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u32* pointer, u32 value, u32 expected) {
|
||||
return __sync_bool_compare_and_swap(pointer, expected, value);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u64 value, u64 expected) {
|
||||
return __sync_bool_compare_and_swap(pointer, expected, value);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u128 value, u128 expected) {
|
||||
unsigned __int128 value_a;
|
||||
unsigned __int128 expected_a;
|
||||
std::memcpy(&value_a, value.data(), sizeof(u128));
|
||||
@@ -116,13 +115,31 @@ template <typename T>
|
||||
return __sync_bool_compare_and_swap((unsigned __int128*)pointer, expected_a, value_a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected, T& actual) {
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected,
|
||||
u8& actual) {
|
||||
actual = __sync_val_compare_and_swap(pointer, expected, value);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(u64* pointer, u128 value, u128 expected,
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u16* pointer, u16 value, u16 expected,
|
||||
u16& actual) {
|
||||
actual = __sync_val_compare_and_swap(pointer, expected, value);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u32* pointer, u32 value, u32 expected,
|
||||
u32& actual) {
|
||||
actual = __sync_val_compare_and_swap(pointer, expected, value);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u64 value, u64 expected,
|
||||
u64& actual) {
|
||||
actual = __sync_val_compare_and_swap(pointer, expected, value);
|
||||
return actual == expected;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool AtomicCompareAndSwap(volatile u64* pointer, u128 value, u128 expected,
|
||||
u128& actual) {
|
||||
unsigned __int128 value_a;
|
||||
unsigned __int128 expected_a;
|
||||
@@ -134,7 +151,7 @@ template <typename T>
|
||||
return actual_a == expected_a;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline u128 AtomicLoad128(u64* pointer) {
|
||||
[[nodiscard]] inline u128 AtomicLoad128(volatile u64* pointer) {
|
||||
unsigned __int128 zeros_a = 0;
|
||||
unsigned __int128 result_a =
|
||||
__sync_val_compare_and_swap((unsigned __int128*)pointer, zeros_a, zeros_a);
|
||||
|
||||
@@ -134,12 +134,12 @@ struct Values {
|
||||
Linkage linkage{};
|
||||
|
||||
// Audio
|
||||
SwitchableSetting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine",
|
||||
Category::Audio, Specialization::RuntimeList};
|
||||
SwitchableSetting<std::string> audio_output_device_id{
|
||||
linkage, "auto", "output_device", Category::Audio, Specialization::RuntimeList};
|
||||
SwitchableSetting<std::string> audio_input_device_id{
|
||||
linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList};
|
||||
Setting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio,
|
||||
Specialization::RuntimeList};
|
||||
Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio,
|
||||
Specialization::RuntimeList};
|
||||
Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio,
|
||||
Specialization::RuntimeList};
|
||||
SwitchableSetting<AudioMode, true> sound_index{
|
||||
linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround,
|
||||
"sound_index", Category::SystemAudio, Specialization::Default, true,
|
||||
|
||||
@@ -979,6 +979,8 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(core)
|
||||
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network video_core nx_tzdb tz)
|
||||
target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls RenderDoc::API)
|
||||
if (MINGW)
|
||||
@@ -1056,5 +1058,3 @@ endif()
|
||||
if (YUZU_ENABLE_LTO)
|
||||
set_property(TARGET core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(core)
|
||||
|
||||
@@ -201,22 +201,22 @@ struct System::Impl {
|
||||
system.ServiceManager().GetService<Service::PSC::Time::StaticService>("time:s", true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> user_clock;
|
||||
static_service_a->GetStandardUserSystemClock(&user_clock);
|
||||
static_service_a->GetStandardUserSystemClock(user_clock);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> local_clock;
|
||||
static_service_a->GetStandardLocalSystemClock(&local_clock);
|
||||
static_service_a->GetStandardLocalSystemClock(local_clock);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> network_clock;
|
||||
static_service_s->GetStandardNetworkSystemClock(&network_clock);
|
||||
static_service_s->GetStandardNetworkSystemClock(network_clock);
|
||||
|
||||
std::shared_ptr<Service::Glue::Time::TimeZoneService> timezone_service;
|
||||
static_service_a->GetTimeZoneService(&timezone_service);
|
||||
static_service_a->GetTimeZoneService(timezone_service);
|
||||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
auto new_name = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
|
||||
std::memcpy(name.data(), new_name.data(), std::min(name.size(), new_name.size()));
|
||||
std::memcpy(name.name.data(), new_name.data(), std::min(name.name.size(), new_name.size()));
|
||||
|
||||
timezone_service->SetDeviceLocationName(name);
|
||||
timezone_service->SetDeviceLocation(name);
|
||||
|
||||
u64 time_offset = 0;
|
||||
if (Settings::values.custom_rtc_enabled) {
|
||||
@@ -234,7 +234,7 @@ struct System::Impl {
|
||||
|
||||
local_clock->SetCurrentTime(new_time);
|
||||
|
||||
network_clock->GetSystemClockContext(&context);
|
||||
network_clock->GetSystemClockContext(context);
|
||||
settings_service->SetNetworkSystemClockContext(context);
|
||||
network_clock->SetCurrentTime(new_time);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bit>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -43,8 +42,6 @@ public:
|
||||
DeviceMemoryManager(const DeviceMemory& device_memory);
|
||||
~DeviceMemoryManager();
|
||||
|
||||
static constexpr bool HAS_FLUSH_INVALIDATION = true;
|
||||
|
||||
void BindInterface(DeviceInterface* device_inter);
|
||||
|
||||
DAddr Allocate(size_t size);
|
||||
@@ -184,28 +181,24 @@ private:
|
||||
}
|
||||
|
||||
Common::VirtualBuffer<VAddr> cpu_backing_address;
|
||||
using CounterType = u8;
|
||||
using CounterAtomicType = std::atomic_uint8_t;
|
||||
static constexpr size_t subentries = 8 / sizeof(CounterType);
|
||||
static constexpr size_t subentries = 8 / sizeof(u8);
|
||||
static constexpr size_t subentries_mask = subentries - 1;
|
||||
static constexpr size_t subentries_shift =
|
||||
std::countr_zero(sizeof(u64)) - std::countr_zero(sizeof(CounterType));
|
||||
class CounterEntry final {
|
||||
public:
|
||||
CounterEntry() = default;
|
||||
|
||||
CounterAtomicType& Count(std::size_t page) {
|
||||
std::atomic_uint8_t& Count(std::size_t page) {
|
||||
return values[page & subentries_mask];
|
||||
}
|
||||
|
||||
const CounterAtomicType& Count(std::size_t page) const {
|
||||
const std::atomic_uint8_t& Count(std::size_t page) const {
|
||||
return values[page & subentries_mask];
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<CounterAtomicType, subentries> values{};
|
||||
std::array<std::atomic_uint8_t, subentries> values{};
|
||||
};
|
||||
static_assert(sizeof(CounterEntry) == subentries * sizeof(CounterType),
|
||||
static_assert(sizeof(CounterEntry) == subentries * sizeof(u8),
|
||||
"CounterEntry should be 8 bytes!");
|
||||
|
||||
static constexpr size_t num_counter_entries =
|
||||
|
||||
@@ -213,8 +213,8 @@ void DeviceMemoryManager<Traits>::Free(DAddr start, size_t size) {
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size_t size, Asid asid,
|
||||
bool track) {
|
||||
void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size_t size,
|
||||
Asid asid, bool track) {
|
||||
Core::Memory::Memory* process_memory = registered_processes[asid.id];
|
||||
size_t start_page_d = address >> Memory::YUZU_PAGEBITS;
|
||||
size_t num_pages = Common::AlignUp(size, Memory::YUZU_PAGESIZE) >> Memory::YUZU_PAGEBITS;
|
||||
@@ -519,36 +519,22 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
const size_t page_end = Common::DivCeil(addr + size, Memory::YUZU_PAGESIZE);
|
||||
size_t page = addr >> Memory::YUZU_PAGEBITS;
|
||||
auto [asid, base_vaddress] = ExtractCPUBacking(page);
|
||||
size_t vpage = base_vaddress >> Memory::YUZU_PAGEBITS;
|
||||
auto* memory_device_inter = registered_processes[asid.id];
|
||||
const auto release_pending = [&] {
|
||||
if (uncache_bytes > 0) {
|
||||
MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS,
|
||||
uncache_bytes, false);
|
||||
uncache_bytes = 0;
|
||||
}
|
||||
if (cache_bytes > 0) {
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS,
|
||||
cache_bytes, true);
|
||||
cache_bytes = 0;
|
||||
}
|
||||
};
|
||||
for (; page != page_end; ++page) {
|
||||
CounterAtomicType& count = cached_pages->at(page >> subentries_shift).Count(page);
|
||||
auto [asid_2, vpage] = ExtractCPUBacking(page);
|
||||
vpage >>= Memory::YUZU_PAGEBITS;
|
||||
std::atomic_uint8_t& count = cached_pages->at(page >> 3).Count(page);
|
||||
|
||||
if (vpage == 0) [[unlikely]] {
|
||||
release_pending();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (asid.id != asid_2.id) [[unlikely]] {
|
||||
release_pending();
|
||||
memory_device_inter = registered_processes[asid_2.id];
|
||||
if (delta > 0) {
|
||||
ASSERT_MSG(count.load(std::memory_order::relaxed) < std::numeric_limits<u8>::max(),
|
||||
"Count may overflow!");
|
||||
} else if (delta < 0) {
|
||||
ASSERT_MSG(count.load(std::memory_order::relaxed) > 0, "Count may underflow!");
|
||||
} else {
|
||||
ASSERT_MSG(false, "Delta must be non-zero!");
|
||||
}
|
||||
|
||||
// Adds or subtracts 1, as count is a unsigned 8-bit value
|
||||
count.fetch_add(static_cast<CounterType>(delta), std::memory_order_release);
|
||||
count.fetch_add(static_cast<u8>(delta), std::memory_order_release);
|
||||
|
||||
// Assume delta is either -1 or 1
|
||||
if (count.load(std::memory_order::relaxed) == 0) {
|
||||
@@ -567,12 +553,20 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
}
|
||||
cache_bytes += Memory::YUZU_PAGESIZE;
|
||||
} else if (cache_bytes > 0) {
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS,
|
||||
cache_bytes, true);
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes,
|
||||
true);
|
||||
cache_bytes = 0;
|
||||
}
|
||||
vpage++;
|
||||
}
|
||||
if (uncache_bytes > 0) {
|
||||
MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes,
|
||||
false);
|
||||
}
|
||||
if (cache_bytes > 0) {
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes,
|
||||
true);
|
||||
}
|
||||
release_pending();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -44,32 +44,15 @@ public:
|
||||
GuestMemory() = delete;
|
||||
explicit GuestMemory(M& memory, u64 addr, std::size_t size,
|
||||
Common::ScratchBuffer<T>* backup = nullptr)
|
||||
: m_memory{&memory}, m_addr{addr}, m_size{size} {
|
||||
: m_memory{memory}, m_addr{addr}, m_size{size} {
|
||||
static_assert(FLAGS & GuestMemoryFlags::Read || FLAGS & GuestMemoryFlags::Write);
|
||||
if constexpr (!(FLAGS & GuestMemoryFlags::Read)) {
|
||||
if (!this->TrySetSpan()) {
|
||||
if (backup) {
|
||||
backup->resize_destructive(this->size());
|
||||
m_data_span = *backup;
|
||||
m_span_valid = true;
|
||||
m_is_data_copy = true;
|
||||
} else {
|
||||
m_data_copy.resize(this->size());
|
||||
m_data_span = std::span(m_data_copy);
|
||||
m_span_valid = true;
|
||||
m_is_data_copy = true;
|
||||
}
|
||||
}
|
||||
} else if constexpr (FLAGS & GuestMemoryFlags::Read) {
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Read) {
|
||||
Read(addr, size, backup);
|
||||
}
|
||||
}
|
||||
|
||||
~GuestMemory() = default;
|
||||
|
||||
GuestMemory(GuestMemory&& rhs) = default;
|
||||
GuestMemory& operator=(GuestMemory&& rhs) = default;
|
||||
|
||||
T* data() noexcept {
|
||||
return m_data_span.data();
|
||||
}
|
||||
@@ -126,8 +109,8 @@ public:
|
||||
}
|
||||
|
||||
if (this->TrySetSpan()) {
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Safe && M::HAS_FLUSH_INVALIDATION) {
|
||||
m_memory->FlushRegion(m_addr, this->size_bytes());
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Safe) {
|
||||
m_memory.FlushRegion(m_addr, this->size_bytes());
|
||||
}
|
||||
} else {
|
||||
if (backup) {
|
||||
@@ -140,9 +123,9 @@ public:
|
||||
m_is_data_copy = true;
|
||||
m_span_valid = true;
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Safe) {
|
||||
m_memory->ReadBlock(m_addr, this->data(), this->size_bytes());
|
||||
m_memory.ReadBlock(m_addr, this->data(), this->size_bytes());
|
||||
} else {
|
||||
m_memory->ReadBlockUnsafe(m_addr, this->data(), this->size_bytes());
|
||||
m_memory.ReadBlockUnsafe(m_addr, this->data(), this->size_bytes());
|
||||
}
|
||||
}
|
||||
return m_data_span;
|
||||
@@ -150,19 +133,18 @@ public:
|
||||
|
||||
void Write(std::span<T> write_data) noexcept {
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Cached) {
|
||||
m_memory->WriteBlockCached(m_addr, write_data.data(), this->size_bytes());
|
||||
m_memory.WriteBlockCached(m_addr, write_data.data(), this->size_bytes());
|
||||
} else if constexpr (FLAGS & GuestMemoryFlags::Safe) {
|
||||
m_memory->WriteBlock(m_addr, write_data.data(), this->size_bytes());
|
||||
m_memory.WriteBlock(m_addr, write_data.data(), this->size_bytes());
|
||||
} else {
|
||||
m_memory->WriteBlockUnsafe(m_addr, write_data.data(), this->size_bytes());
|
||||
m_memory.WriteBlockUnsafe(m_addr, write_data.data(), this->size_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
bool TrySetSpan() noexcept {
|
||||
if (u8* ptr = m_memory->GetSpan(m_addr, this->size_bytes()); ptr) {
|
||||
if (u8* ptr = m_memory.GetSpan(m_addr, this->size_bytes()); ptr) {
|
||||
m_data_span = {reinterpret_cast<T*>(ptr), this->size()};
|
||||
m_span_valid = true;
|
||||
m_is_data_copy = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -177,7 +159,7 @@ protected:
|
||||
return m_addr_changed;
|
||||
}
|
||||
|
||||
M* m_memory;
|
||||
M& m_memory;
|
||||
u64 m_addr{};
|
||||
size_t m_size{};
|
||||
std::span<T> m_data_span{};
|
||||
@@ -193,7 +175,17 @@ public:
|
||||
GuestMemoryScoped() = delete;
|
||||
explicit GuestMemoryScoped(M& memory, u64 addr, std::size_t size,
|
||||
Common::ScratchBuffer<T>* backup = nullptr)
|
||||
: GuestMemory<M, T, FLAGS>(memory, addr, size, backup) {}
|
||||
: GuestMemory<M, T, FLAGS>(memory, addr, size, backup) {
|
||||
if constexpr (!(FLAGS & GuestMemoryFlags::Read)) {
|
||||
if (!this->TrySetSpan()) {
|
||||
if (backup) {
|
||||
this->m_data_span = *backup;
|
||||
this->m_span_valid = true;
|
||||
this->m_is_data_copy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~GuestMemoryScoped() {
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Write) {
|
||||
@@ -204,17 +196,15 @@ public:
|
||||
if (this->AddressChanged() || this->IsDataCopy()) {
|
||||
ASSERT(this->m_span_valid);
|
||||
if constexpr (FLAGS & GuestMemoryFlags::Cached) {
|
||||
this->m_memory->WriteBlockCached(this->m_addr, this->data(),
|
||||
this->size_bytes());
|
||||
this->m_memory.WriteBlockCached(this->m_addr, this->data(), this->size_bytes());
|
||||
} else if constexpr (FLAGS & GuestMemoryFlags::Safe) {
|
||||
this->m_memory->WriteBlock(this->m_addr, this->data(), this->size_bytes());
|
||||
this->m_memory.WriteBlock(this->m_addr, this->data(), this->size_bytes());
|
||||
} else {
|
||||
this->m_memory->WriteBlockUnsafe(this->m_addr, this->data(),
|
||||
this->size_bytes());
|
||||
this->m_memory.WriteBlockUnsafe(this->m_addr, this->data(), this->size_bytes());
|
||||
}
|
||||
} else if constexpr ((FLAGS & GuestMemoryFlags::Safe) ||
|
||||
(FLAGS & GuestMemoryFlags::Cached)) {
|
||||
this->m_memory->InvalidateRegion(this->m_addr, this->size_bytes());
|
||||
this->m_memory.InvalidateRegion(this->m_addr, this->size_bytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,8 +543,7 @@ void KThread::Unpin() {
|
||||
ASSERT(m_parent != nullptr);
|
||||
|
||||
// Resume any threads that began waiting on us while we were pinned.
|
||||
for (auto it = m_pinned_waiter_list.begin(); it != m_pinned_waiter_list.end();
|
||||
it = m_pinned_waiter_list.erase(it)) {
|
||||
for (auto it = m_pinned_waiter_list.begin(); it != m_pinned_waiter_list.end(); ++it) {
|
||||
it->EndWait(ResultSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,8 +303,8 @@ void AppletManager::CreateAndInsertByFrontendAppletParameters(
|
||||
}
|
||||
|
||||
// Applet was started by frontend, so it is foreground.
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
||||
applet->focus_state = FocusState::InFocus;
|
||||
|
||||
this->InsertApplet(std::move(applet));
|
||||
|
||||
@@ -207,7 +207,7 @@ void Error::Execute() {
|
||||
|
||||
void Error::DisplayCompleted() {
|
||||
complete = true;
|
||||
PushOutData(std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
|
||||
PushOutData(std::make_shared<IStorage>(system, std::vector<u8>()));
|
||||
Exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,26 +85,24 @@ AppletProgramId AppletIdToProgramId(AppletId applet_id) {
|
||||
applet->library_applet_mode = mode;
|
||||
|
||||
// Set focus state
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
switch (mode) {
|
||||
case LibraryAppletMode::AllForeground:
|
||||
case LibraryAppletMode::NoUI:
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
||||
applet->focus_state = FocusState::InFocus;
|
||||
applet->hid_registration.EnableAppletToGetInput(true);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
break;
|
||||
case LibraryAppletMode::AllForegroundInitiallyHidden:
|
||||
applet->system_buffer_manager.SetWindowVisibility(false);
|
||||
applet->focus_state = FocusState::NotInFocus;
|
||||
applet->hid_registration.EnableAppletToGetInput(false);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
break;
|
||||
case LibraryAppletMode::Background:
|
||||
case LibraryAppletMode::BackgroundIndirectDisplay:
|
||||
default:
|
||||
applet->focus_state = FocusState::Background;
|
||||
applet->hid_registration.EnableAppletToGetInput(true);
|
||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ void AOC_U::ListAddOnContent(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
|
||||
process_id);
|
||||
|
||||
const auto current = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID());
|
||||
const auto current = system.GetApplicationProcessProgramID();
|
||||
|
||||
std::vector<u32> out;
|
||||
const auto& disabled = Settings::values.disabled_addons[current];
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/audio/audctl.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/set/system_settings_server.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
|
||||
namespace Service::Audio {
|
||||
|
||||
@@ -21,15 +19,15 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
|
||||
{6, nullptr, "IsTargetConnected"},
|
||||
{7, nullptr, "SetDefaultTarget"},
|
||||
{8, nullptr, "GetDefaultTarget"},
|
||||
{9, &AudCtl::GetAudioOutputMode, "GetAudioOutputMode"},
|
||||
{10, &AudCtl::SetAudioOutputMode, "SetAudioOutputMode"},
|
||||
{9, nullptr, "GetAudioOutputMode"},
|
||||
{10, nullptr, "SetAudioOutputMode"},
|
||||
{11, nullptr, "SetForceMutePolicy"},
|
||||
{12, &AudCtl::GetForceMutePolicy, "GetForceMutePolicy"},
|
||||
{13, &AudCtl::GetOutputModeSetting, "GetOutputModeSetting"},
|
||||
{14, &AudCtl::SetOutputModeSetting, "SetOutputModeSetting"},
|
||||
{14, nullptr, "SetOutputModeSetting"},
|
||||
{15, nullptr, "SetOutputTarget"},
|
||||
{16, nullptr, "SetInputTargetForceEnabled"},
|
||||
{17, &AudCtl::SetHeadphoneOutputLevelMode, "SetHeadphoneOutputLevelMode"},
|
||||
{17, nullptr, "SetHeadphoneOutputLevelMode"},
|
||||
{18, &AudCtl::GetHeadphoneOutputLevelMode, "GetHeadphoneOutputLevelMode"},
|
||||
{19, nullptr, "AcquireAudioVolumeUpdateEventForPlayReport"},
|
||||
{20, nullptr, "AcquireAudioOutputDeviceUpdateEventForPlayReport"},
|
||||
@@ -42,7 +40,7 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
|
||||
{27, nullptr, "SetVolumeMappingTableForDev"},
|
||||
{28, nullptr, "GetAudioOutputChannelCountForPlayReport"},
|
||||
{29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"},
|
||||
{30, &AudCtl::SetSpeakerAutoMuteEnabled, "SetSpeakerAutoMuteEnabled"},
|
||||
{30, nullptr, "SetSpeakerAutoMuteEnabled"},
|
||||
{31, &AudCtl::IsSpeakerAutoMuteEnabled, "IsSpeakerAutoMuteEnabled"},
|
||||
{32, nullptr, "GetActiveOutputTarget"},
|
||||
{33, nullptr, "GetTargetDeviceInfo"},
|
||||
@@ -70,9 +68,6 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
m_set_sys =
|
||||
system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
|
||||
}
|
||||
|
||||
AudCtl::~AudCtl() = default;
|
||||
@@ -101,33 +96,6 @@ void AudCtl::GetTargetVolumeMax(HLERequestContext& ctx) {
|
||||
rb.Push(target_max_volume);
|
||||
}
|
||||
|
||||
void AudCtl::GetAudioOutputMode(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()};
|
||||
|
||||
Set::AudioOutputMode output_mode{};
|
||||
const auto result = m_set_sys->GetAudioOutputMode(output_mode, target);
|
||||
|
||||
LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.PushEnum(output_mode);
|
||||
}
|
||||
|
||||
void AudCtl::SetAudioOutputMode(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()};
|
||||
const auto output_mode{rp.PopEnum<Set::AudioOutputMode>()};
|
||||
|
||||
const auto result = m_set_sys->SetAudioOutputMode(target, output_mode);
|
||||
|
||||
LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void AudCtl::GetForceMutePolicy(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Audio, "(STUBBED) called");
|
||||
|
||||
@@ -138,31 +106,13 @@ void AudCtl::GetForceMutePolicy(HLERequestContext& ctx) {
|
||||
|
||||
void AudCtl::GetOutputModeSetting(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()};
|
||||
const auto value = rp.Pop<u32>();
|
||||
|
||||
LOG_WARNING(Audio, "(STUBBED) called, target={}", target);
|
||||
LOG_WARNING(Audio, "(STUBBED) called, value={}", value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(Set::AudioOutputMode::ch_7_1);
|
||||
}
|
||||
|
||||
void AudCtl::SetOutputModeSetting(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()};
|
||||
const auto output_mode{rp.PopEnum<Set::AudioOutputMode>()};
|
||||
|
||||
LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void AudCtl::SetHeadphoneOutputLevelMode(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Audio, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(AudioOutputMode::PcmAuto);
|
||||
}
|
||||
|
||||
void AudCtl::GetHeadphoneOutputLevelMode(HLERequestContext& ctx) {
|
||||
@@ -173,28 +123,14 @@ void AudCtl::GetHeadphoneOutputLevelMode(HLERequestContext& ctx) {
|
||||
rb.PushEnum(HeadphoneOutputLevelMode::Normal);
|
||||
}
|
||||
|
||||
void AudCtl::SetSpeakerAutoMuteEnabled(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto is_speaker_auto_mute_enabled{rp.Pop<bool>()};
|
||||
|
||||
LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}",
|
||||
is_speaker_auto_mute_enabled);
|
||||
|
||||
const auto result = m_set_sys->SetSpeakerAutoMuteFlag(is_speaker_auto_mute_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void AudCtl::IsSpeakerAutoMuteEnabled(HLERequestContext& ctx) {
|
||||
bool is_speaker_auto_mute_enabled{};
|
||||
const auto result = m_set_sys->GetSpeakerAutoMuteFlag(is_speaker_auto_mute_enabled);
|
||||
const bool is_speaker_auto_mute_enabled = false;
|
||||
|
||||
LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}",
|
||||
is_speaker_auto_mute_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u8>(is_speaker_auto_mute_enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,6 @@ namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::Set {
|
||||
class ISystemSettingsServer;
|
||||
}
|
||||
|
||||
namespace Service::Audio {
|
||||
|
||||
class AudCtl final : public ServiceFramework<AudCtl> {
|
||||
@@ -21,6 +17,14 @@ public:
|
||||
~AudCtl() override;
|
||||
|
||||
private:
|
||||
enum class AudioOutputMode {
|
||||
Invalid,
|
||||
Pcm1ch,
|
||||
Pcm2ch,
|
||||
Pcm6ch,
|
||||
PcmAuto,
|
||||
};
|
||||
|
||||
enum class ForceMutePolicy {
|
||||
Disable,
|
||||
SpeakerMuteOnHeadphoneUnplugged,
|
||||
@@ -33,18 +37,10 @@ private:
|
||||
|
||||
void GetTargetVolumeMin(HLERequestContext& ctx);
|
||||
void GetTargetVolumeMax(HLERequestContext& ctx);
|
||||
void GetAudioOutputMode(HLERequestContext& ctx);
|
||||
void SetAudioOutputMode(HLERequestContext& ctx);
|
||||
void GetForceMutePolicy(HLERequestContext& ctx);
|
||||
void GetOutputModeSetting(HLERequestContext& ctx);
|
||||
void SetOutputModeSetting(HLERequestContext& ctx);
|
||||
void SetHeadphoneOutputLevelMode(HLERequestContext& ctx);
|
||||
void GetHeadphoneOutputLevelMode(HLERequestContext& ctx);
|
||||
void SetSpeakerAutoMuteEnabled(HLERequestContext& ctx);
|
||||
void IsSpeakerAutoMuteEnabled(HLERequestContext& ctx);
|
||||
void AcquireTargetNotification(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||
};
|
||||
|
||||
} // namespace Service::Audio
|
||||
|
||||
@@ -35,11 +35,10 @@ public:
|
||||
explicit IAudioRenderer(Core::System& system_, Manager& manager_,
|
||||
AudioCore::AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle, Kernel::KProcess& process_,
|
||||
u64 applet_resource_user_id, s32 session_id)
|
||||
u32 process_handle, u64 applet_resource_user_id, s32 session_id)
|
||||
: ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"},
|
||||
rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_},
|
||||
impl{std::make_unique<Renderer>(system_, manager, rendered_event)}, process{process_} {
|
||||
impl{std::make_unique<Renderer>(system_, manager, rendered_event)} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
|
||||
@@ -60,15 +59,13 @@ public:
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
|
||||
process.Open();
|
||||
impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle, process,
|
||||
impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle,
|
||||
applet_resource_user_id, session_id);
|
||||
}
|
||||
|
||||
~IAudioRenderer() override {
|
||||
impl->Finalize();
|
||||
service_context.CloseEvent(rendered_event);
|
||||
process.Close();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -238,7 +235,6 @@ private:
|
||||
Kernel::KEvent* rendered_event;
|
||||
Manager& manager;
|
||||
std::unique_ptr<Renderer> impl;
|
||||
Kernel::KProcess& process;
|
||||
Common::ScratchBuffer<u8> output_buffer;
|
||||
Common::ScratchBuffer<u8> performance_buffer;
|
||||
};
|
||||
@@ -459,7 +455,7 @@ void AudRenU::OpenAudioRenderer(HLERequestContext& ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(process_handle).GetPointerUnsafe()};
|
||||
auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(process_handle)};
|
||||
auto transfer_memory{ctx.GetObjectFromHandle<Kernel::KTransferMemory>(transfer_memory_handle)};
|
||||
|
||||
const auto session_id{impl->GetSessionId()};
|
||||
@@ -476,7 +472,7 @@ void AudRenU::OpenAudioRenderer(HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IAudioRenderer>(system, *impl, params, transfer_memory.GetPointerUnsafe(),
|
||||
transfer_memory_size, process_handle, *process,
|
||||
transfer_memory_size, process_handle,
|
||||
applet_resource_user_id, session_id);
|
||||
}
|
||||
|
||||
@@ -526,7 +522,7 @@ void AudRenU::GetAudioDeviceService(HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
void AudRenU::OpenAudioRendererForManualExecution(HLERequestContext& ctx) {
|
||||
LOG_ERROR(Service_Audio, "called. Implement me!");
|
||||
LOG_DEBUG(Service_Audio, "called");
|
||||
}
|
||||
|
||||
void AudRenU::GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "core/hle/service/caps/caps_a.h"
|
||||
#include "core/hle/service/caps/caps_manager.h"
|
||||
#include "core/hle/service/caps/caps_result.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
|
||||
namespace Service::Capture {
|
||||
@@ -18,9 +18,9 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
|
||||
{0, nullptr, "GetAlbumFileCount"},
|
||||
{1, nullptr, "GetAlbumFileList"},
|
||||
{2, nullptr, "LoadAlbumFile"},
|
||||
{3, C<&IAlbumAccessorService::DeleteAlbumFile>, "DeleteAlbumFile"},
|
||||
{3, &IAlbumAccessorService::DeleteAlbumFile, "DeleteAlbumFile"},
|
||||
{4, nullptr, "StorageCopyAlbumFile"},
|
||||
{5, C<&IAlbumAccessorService::IsAlbumMounted>, "IsAlbumMounted"},
|
||||
{5, &IAlbumAccessorService::IsAlbumMounted, "IsAlbumMounted"},
|
||||
{6, nullptr, "GetAlbumUsage"},
|
||||
{7, nullptr, "GetAlbumFileSize"},
|
||||
{8, nullptr, "LoadAlbumFileThumbnail"},
|
||||
@@ -33,18 +33,18 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
|
||||
{15, nullptr, "GetAlbumUsage3"},
|
||||
{16, nullptr, "GetAlbumMountResult"},
|
||||
{17, nullptr, "GetAlbumUsage16"},
|
||||
{18, C<&IAlbumAccessorService::Unknown18>, "Unknown18"},
|
||||
{18, &IAlbumAccessorService::Unknown18, "Unknown18"},
|
||||
{19, nullptr, "Unknown19"},
|
||||
{100, nullptr, "GetAlbumFileCountEx0"},
|
||||
{101, C<&IAlbumAccessorService::GetAlbumFileListEx0>, "GetAlbumFileListEx0"},
|
||||
{101, &IAlbumAccessorService::GetAlbumFileListEx0, "GetAlbumFileListEx0"},
|
||||
{202, nullptr, "SaveEditedScreenShot"},
|
||||
{301, nullptr, "GetLastThumbnail"},
|
||||
{302, nullptr, "GetLastOverlayMovieThumbnail"},
|
||||
{401, C<&IAlbumAccessorService::GetAutoSavingStorage>, "GetAutoSavingStorage"},
|
||||
{401, &IAlbumAccessorService::GetAutoSavingStorage, "GetAutoSavingStorage"},
|
||||
{501, nullptr, "GetRequiredStorageSpaceSizeToCopyAll"},
|
||||
{1001, nullptr, "LoadAlbumScreenShotThumbnailImageEx0"},
|
||||
{1002, C<&IAlbumAccessorService::LoadAlbumScreenShotImageEx1>, "LoadAlbumScreenShotImageEx1"},
|
||||
{1003, C<&IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1>, "LoadAlbumScreenShotThumbnailImageEx1"},
|
||||
{1002, &IAlbumAccessorService::LoadAlbumScreenShotImageEx1, "LoadAlbumScreenShotImageEx1"},
|
||||
{1003, &IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1, "LoadAlbumScreenShotThumbnailImageEx1"},
|
||||
{8001, nullptr, "ForceAlbumUnmounted"},
|
||||
{8002, nullptr, "ResetAlbumMountStatus"},
|
||||
{8011, nullptr, "RefreshAlbumCache"},
|
||||
@@ -62,70 +62,138 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
|
||||
|
||||
IAlbumAccessorService::~IAlbumAccessorService() = default;
|
||||
|
||||
Result IAlbumAccessorService::DeleteAlbumFile(AlbumFileId file_id) {
|
||||
void IAlbumAccessorService::DeleteAlbumFile(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto file_id{rp.PopRaw<AlbumFileId>()};
|
||||
|
||||
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}",
|
||||
file_id.application_id, file_id.storage, file_id.type);
|
||||
|
||||
const Result result = manager->DeleteAlbumFile(file_id);
|
||||
R_RETURN(TranslateResult(result));
|
||||
Result result = manager->DeleteAlbumFile(file_id);
|
||||
result = TranslateResult(result);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage) {
|
||||
void IAlbumAccessorService::IsAlbumMounted(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto storage{rp.PopEnum<AlbumStorage>()};
|
||||
|
||||
LOG_INFO(Service_Capture, "called, storage={}", storage);
|
||||
|
||||
const Result result = manager->IsAlbumMounted(storage);
|
||||
*out_is_mounted = result.IsSuccess();
|
||||
R_RETURN(TranslateResult(result));
|
||||
Result result = manager->IsAlbumMounted(storage);
|
||||
const bool is_mounted = result.IsSuccess();
|
||||
result = TranslateResult(result);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.Push<u8>(is_mounted);
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::Unknown18(
|
||||
Out<u32> out_buffer_size,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_buffer) {
|
||||
void IAlbumAccessorService::Unknown18(HLERequestContext& ctx) {
|
||||
struct UnknownBuffer {
|
||||
INSERT_PADDING_BYTES(0x10);
|
||||
};
|
||||
static_assert(sizeof(UnknownBuffer) == 0x10, "UnknownBuffer is an invalid size");
|
||||
|
||||
LOG_WARNING(Service_Capture, "(STUBBED) called");
|
||||
*out_buffer_size = 0;
|
||||
R_SUCCEED();
|
||||
|
||||
std::vector<UnknownBuffer> buffer{};
|
||||
|
||||
if (!buffer.empty()) {
|
||||
ctx.WriteBuffer(buffer);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(static_cast<u32>(buffer.size()));
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::GetAlbumFileListEx0(
|
||||
Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
|
||||
OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
|
||||
void IAlbumAccessorService::GetAlbumFileListEx0(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto storage{rp.PopEnum<AlbumStorage>()};
|
||||
const auto flags{rp.Pop<u8>()};
|
||||
const auto album_entry_size{ctx.GetWriteBufferNumElements<AlbumEntry>()};
|
||||
|
||||
LOG_INFO(Service_Capture, "called, storage={}, flags={}", storage, flags);
|
||||
|
||||
const Result result = manager->GetAlbumFileList(out_entries, *out_entries_size, storage, flags);
|
||||
R_RETURN(TranslateResult(result));
|
||||
std::vector<AlbumEntry> entries;
|
||||
Result result = manager->GetAlbumFileList(entries, storage, flags);
|
||||
result = TranslateResult(result);
|
||||
|
||||
entries.resize(std::min(album_entry_size, entries.size()));
|
||||
|
||||
if (!entries.empty()) {
|
||||
ctx.WriteBuffer(entries);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(result);
|
||||
rb.Push<u64>(entries.size());
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::GetAutoSavingStorage(Out<bool> out_is_autosaving) {
|
||||
void IAlbumAccessorService::GetAutoSavingStorage(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_Capture, "(STUBBED) called");
|
||||
|
||||
const Result result = manager->GetAutoSavingStorage(*out_is_autosaving);
|
||||
R_RETURN(TranslateResult(result));
|
||||
bool is_autosaving{};
|
||||
Result result = manager->GetAutoSavingStorage(is_autosaving);
|
||||
result = TranslateResult(result);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.Push<u8>(is_autosaving);
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::LoadAlbumScreenShotImageEx1(
|
||||
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
|
||||
OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
|
||||
void IAlbumAccessorService::LoadAlbumScreenShotImageEx1(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto file_id{rp.PopRaw<AlbumFileId>()};
|
||||
const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
|
||||
const auto image_buffer_size{ctx.GetWriteBufferSize(1)};
|
||||
|
||||
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
|
||||
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
|
||||
|
||||
const Result result =
|
||||
manager->LoadAlbumScreenShotImage(*out_image_output, out_image, file_id, decoder_options);
|
||||
R_RETURN(TranslateResult(result));
|
||||
std::vector<u8> image;
|
||||
LoadAlbumScreenShotImageOutput image_output;
|
||||
Result result =
|
||||
manager->LoadAlbumScreenShotImage(image_output, image, file_id, decoder_options);
|
||||
result = TranslateResult(result);
|
||||
|
||||
if (image.size() > image_buffer_size) {
|
||||
result = ResultWorkMemoryError;
|
||||
}
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
ctx.WriteBuffer(image_output, 0);
|
||||
ctx.WriteBuffer(image, 1);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(
|
||||
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
|
||||
OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
|
||||
void IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto file_id{rp.PopRaw<AlbumFileId>()};
|
||||
const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
|
||||
|
||||
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
|
||||
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
|
||||
|
||||
const Result result = manager->LoadAlbumScreenShotThumbnail(*out_image_output, out_image,
|
||||
file_id, decoder_options);
|
||||
R_RETURN(TranslateResult(result));
|
||||
std::vector<u8> image(ctx.GetWriteBufferSize(1));
|
||||
LoadAlbumScreenShotImageOutput image_output;
|
||||
Result result =
|
||||
manager->LoadAlbumScreenShotThumbnail(image_output, image, file_id, decoder_options);
|
||||
result = TranslateResult(result);
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
ctx.WriteBuffer(image_output, 0);
|
||||
ctx.WriteBuffer(image, 1);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
Result IAlbumAccessorService::TranslateResult(Result in_result) {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -21,31 +19,13 @@ public:
|
||||
~IAlbumAccessorService() override;
|
||||
|
||||
private:
|
||||
Result DeleteAlbumFile(AlbumFileId file_id);
|
||||
|
||||
Result IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage);
|
||||
|
||||
Result Unknown18(
|
||||
Out<u32> out_buffer_size,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure>
|
||||
out_buffer);
|
||||
|
||||
Result GetAlbumFileListEx0(Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
|
||||
OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries);
|
||||
|
||||
Result GetAutoSavingStorage(Out<bool> out_is_autosaving);
|
||||
|
||||
Result LoadAlbumScreenShotImageEx1(
|
||||
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
|
||||
OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
|
||||
|
||||
Result LoadAlbumScreenShotThumbnailImageEx1(
|
||||
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
|
||||
OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
|
||||
OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
|
||||
void DeleteAlbumFile(HLERequestContext& ctx);
|
||||
void IsAlbumMounted(HLERequestContext& ctx);
|
||||
void Unknown18(HLERequestContext& ctx);
|
||||
void GetAlbumFileListEx0(HLERequestContext& ctx);
|
||||
void GetAutoSavingStorage(HLERequestContext& ctx);
|
||||
void LoadAlbumScreenShotImageEx1(HLERequestContext& ctx);
|
||||
void LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx);
|
||||
|
||||
Result TranslateResult(Result in_result);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "core/hle/service/caps/caps_manager.h"
|
||||
#include "core/hle/service/caps/caps_result.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
|
||||
namespace Service::Capture {
|
||||
@@ -18,7 +17,7 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, nullptr, "CaptureRawImage"},
|
||||
{2, nullptr, "CaptureRawImageWithTimeout"},
|
||||
{33, C<&IAlbumControlService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
|
||||
{33, &IAlbumControlService::SetShimLibraryVersion, "SetShimLibraryVersion"},
|
||||
{1001, nullptr, "RequestTakingScreenShot"},
|
||||
{1002, nullptr, "RequestTakingScreenShotWithTimeout"},
|
||||
{1011, nullptr, "NotifyTakingScreenShotRefused"},
|
||||
@@ -43,11 +42,16 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
|
||||
|
||||
IAlbumControlService::~IAlbumControlService() = default;
|
||||
|
||||
Result IAlbumControlService::SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
void IAlbumControlService::SetShimLibraryVersion(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto library_version{rp.Pop<u64>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
|
||||
library_version, aruid.pid);
|
||||
R_SUCCEED();
|
||||
library_version, applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
} // namespace Service::Capture
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -12,7 +11,6 @@ class System;
|
||||
|
||||
namespace Service::Capture {
|
||||
class AlbumManager;
|
||||
enum class ShimLibraryVersion : u64;
|
||||
|
||||
class IAlbumControlService final : public ServiceFramework<IAlbumControlService> {
|
||||
public:
|
||||
@@ -21,8 +19,7 @@ public:
|
||||
~IAlbumControlService() override;
|
||||
|
||||
private:
|
||||
Result SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid);
|
||||
void SetShimLibraryVersion(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<AlbumManager> manager = nullptr;
|
||||
};
|
||||
|
||||
@@ -58,8 +58,8 @@ Result AlbumManager::IsAlbumMounted(AlbumStorage storage) {
|
||||
return is_mounted ? ResultSuccess : ResultIsNotMounted;
|
||||
}
|
||||
|
||||
Result AlbumManager::GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
|
||||
AlbumStorage storage, u8 flags) const {
|
||||
Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
|
||||
u8 flags) const {
|
||||
if (storage > AlbumStorage::Sd) {
|
||||
return ResultInvalidStorage;
|
||||
}
|
||||
@@ -72,55 +72,51 @@ Result AlbumManager::GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& ou
|
||||
if (file_id.storage != storage) {
|
||||
continue;
|
||||
}
|
||||
if (out_entries_count >= SdAlbumFileLimit) {
|
||||
break;
|
||||
}
|
||||
if (out_entries_count >= out_entries.size()) {
|
||||
if (out_entries.size() >= SdAlbumFileLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
const auto entry_size = Common::FS::GetSize(path);
|
||||
out_entries[out_entries_count++] = {
|
||||
out_entries.push_back({
|
||||
.entry_size = entry_size,
|
||||
.file_id = file_id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
|
||||
u64& out_entries_count, ContentType content_type,
|
||||
s64 start_posix_time, s64 end_posix_time, u64 aruid) const {
|
||||
Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
|
||||
ContentType content_type, s64 start_posix_time,
|
||||
s64 end_posix_time, u64 aruid) const {
|
||||
if (!is_mounted) {
|
||||
return ResultIsNotMounted;
|
||||
}
|
||||
|
||||
std::vector<ApplicationAlbumEntry> album_entries(out_entries.size());
|
||||
std::vector<ApplicationAlbumEntry> album_entries;
|
||||
const auto start_date = ConvertToAlbumDateTime(start_posix_time);
|
||||
const auto end_date = ConvertToAlbumDateTime(end_posix_time);
|
||||
const auto result = GetAlbumFileList(album_entries, out_entries_count, content_type, start_date,
|
||||
end_date, aruid);
|
||||
const auto result = GetAlbumFileList(album_entries, content_type, start_date, end_date, aruid);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < out_entries_count; i++) {
|
||||
out_entries[i] = {
|
||||
.entry = album_entries[i],
|
||||
.datetime = album_entries[i].datetime,
|
||||
for (const auto& album_entry : album_entries) {
|
||||
ApplicationAlbumFileEntry entry{
|
||||
.entry = album_entry,
|
||||
.datetime = album_entry.datetime,
|
||||
.unknown = {},
|
||||
};
|
||||
out_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries,
|
||||
u64& out_entries_count, ContentType content_type,
|
||||
AlbumFileDateTime start_date, AlbumFileDateTime end_date,
|
||||
u64 aruid) const {
|
||||
Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
|
||||
ContentType content_type, AlbumFileDateTime start_date,
|
||||
AlbumFileDateTime end_date, u64 aruid) const {
|
||||
if (!is_mounted) {
|
||||
return ResultIsNotMounted;
|
||||
}
|
||||
@@ -135,15 +131,12 @@ Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entri
|
||||
if (file_id.date < end_date) {
|
||||
continue;
|
||||
}
|
||||
if (out_entries_count >= SdAlbumFileLimit) {
|
||||
break;
|
||||
}
|
||||
if (out_entries_count >= out_entries.size()) {
|
||||
if (out_entries.size() >= SdAlbumFileLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
const auto entry_size = Common::FS::GetSize(path);
|
||||
out_entries[out_entries_count++] = {
|
||||
ApplicationAlbumEntry entry{
|
||||
.size = entry_size,
|
||||
.hash{},
|
||||
.datetime = file_id.date,
|
||||
@@ -151,6 +144,7 @@ Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entri
|
||||
.content = content_type,
|
||||
.unknown = 1,
|
||||
};
|
||||
out_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
@@ -162,7 +156,8 @@ Result AlbumManager::GetAutoSavingStorage(bool& out_is_autosaving) const {
|
||||
}
|
||||
|
||||
Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
|
||||
std::span<u8> out_image, const AlbumFileId& file_id,
|
||||
std::vector<u8>& out_image,
|
||||
const AlbumFileId& file_id,
|
||||
const ScreenShotDecodeOption& decoder_options) const {
|
||||
if (file_id.storage > AlbumStorage::Sd) {
|
||||
return ResultInvalidStorage;
|
||||
@@ -181,9 +176,7 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
|
||||
.orientation = AlbumImageOrientation::None,
|
||||
.unknown_1{},
|
||||
.unknown_2{},
|
||||
.pad163{},
|
||||
},
|
||||
.pad179{},
|
||||
};
|
||||
|
||||
std::filesystem::path path;
|
||||
@@ -193,12 +186,14 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
|
||||
return result;
|
||||
}
|
||||
|
||||
out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
|
||||
|
||||
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
|
||||
+static_cast<int>(out_image_output.height), decoder_options.flags);
|
||||
}
|
||||
|
||||
Result AlbumManager::LoadAlbumScreenShotThumbnail(
|
||||
LoadAlbumScreenShotImageOutput& out_image_output, std::span<u8> out_image,
|
||||
LoadAlbumScreenShotImageOutput& out_image_output, std::vector<u8>& out_image,
|
||||
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options) const {
|
||||
if (file_id.storage > AlbumStorage::Sd) {
|
||||
return ResultInvalidStorage;
|
||||
@@ -217,9 +212,7 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
|
||||
.orientation = AlbumImageOrientation::None,
|
||||
.unknown_1{},
|
||||
.unknown_2{},
|
||||
.pad163{},
|
||||
},
|
||||
.pad179{},
|
||||
};
|
||||
|
||||
std::filesystem::path path;
|
||||
@@ -229,6 +222,8 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
|
||||
return result;
|
||||
}
|
||||
|
||||
out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
|
||||
|
||||
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
|
||||
+static_cast<int>(out_image_output.height), decoder_options.flags);
|
||||
}
|
||||
@@ -251,10 +246,10 @@ Result AlbumManager::SaveScreenShot(ApplicationAlbumEntry& out_entry,
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> user_clock{};
|
||||
static_service->GetStandardUserSystemClock(&user_clock);
|
||||
static_service->GetStandardUserSystemClock(user_clock);
|
||||
|
||||
s64 posix_time{};
|
||||
auto result = user_clock->GetCurrentTime(&posix_time);
|
||||
auto result = user_clock->GetCurrentTime(posix_time);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
@@ -273,10 +268,10 @@ Result AlbumManager::SaveEditedScreenShot(ApplicationAlbumEntry& out_entry,
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> user_clock{};
|
||||
static_service->GetStandardUserSystemClock(&user_clock);
|
||||
static_service->GetStandardUserSystemClock(user_clock);
|
||||
|
||||
s64 posix_time{};
|
||||
auto result = user_clock->GetCurrentTime(&posix_time);
|
||||
auto result = user_clock->GetCurrentTime(posix_time);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
@@ -475,11 +470,11 @@ AlbumFileDateTime AlbumManager::ConvertToAlbumDateTime(u64 posix_time) const {
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::Glue::Time::TimeZoneService> timezone_service{};
|
||||
static_service->GetTimeZoneService(&timezone_service);
|
||||
static_service->GetTimeZoneService(timezone_service);
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
timezone_service->ToCalendarTimeWithMyRule(&calendar_time, &additional_info, posix_time);
|
||||
timezone_service->ToCalendarTimeWithMyRule(calendar_time, additional_info, posix_time);
|
||||
|
||||
return {
|
||||
.year = calendar_time.year,
|
||||
|
||||
@@ -42,20 +42,20 @@ public:
|
||||
|
||||
Result DeleteAlbumFile(const AlbumFileId& file_id);
|
||||
Result IsAlbumMounted(AlbumStorage storage);
|
||||
Result GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
|
||||
AlbumStorage storage, u8 flags) const;
|
||||
Result GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
|
||||
u64& out_entries_count, ContentType content_type, s64 start_posix_time,
|
||||
s64 end_posix_time, u64 aruid) const;
|
||||
Result GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries, u64& out_entries_count,
|
||||
Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
|
||||
u8 flags) const;
|
||||
Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
|
||||
ContentType content_type, s64 start_posix_time, s64 end_posix_time,
|
||||
u64 aruid) const;
|
||||
Result GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
|
||||
ContentType content_type, AlbumFileDateTime start_date,
|
||||
AlbumFileDateTime end_date, u64 aruid) const;
|
||||
Result GetAutoSavingStorage(bool& out_is_autosaving) const;
|
||||
Result LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
|
||||
std::span<u8> out_image, const AlbumFileId& file_id,
|
||||
std::vector<u8>& out_image, const AlbumFileId& file_id,
|
||||
const ScreenShotDecodeOption& decoder_options) const;
|
||||
Result LoadAlbumScreenShotThumbnail(LoadAlbumScreenShotImageOutput& out_image_output,
|
||||
std::span<u8> out_image, const AlbumFileId& file_id,
|
||||
std::vector<u8>& out_image, const AlbumFileId& file_id,
|
||||
const ScreenShotDecodeOption& decoder_options) const;
|
||||
|
||||
Result SaveScreenShot(ApplicationAlbumEntry& out_entry, const ScreenShotAttribute& attribute,
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/caps/caps_manager.h"
|
||||
#include "core/hle/service/caps/caps_ss.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
|
||||
#include "core/hle/service/caps/caps_ss.h"
|
||||
|
||||
namespace Service::Capture {
|
||||
|
||||
IScreenShotService::IScreenShotService(Core::System& system_,
|
||||
@@ -16,9 +17,9 @@ IScreenShotService::IScreenShotService(Core::System& system_,
|
||||
static const FunctionInfo functions[] = {
|
||||
{201, nullptr, "SaveScreenShot"},
|
||||
{202, nullptr, "SaveEditedScreenShot"},
|
||||
{203, C<&IScreenShotService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
|
||||
{203, &IScreenShotService::SaveScreenShotEx0, "SaveScreenShotEx0"},
|
||||
{204, nullptr, "SaveEditedScreenShotEx0"},
|
||||
{206, C<&IScreenShotService::SaveEditedScreenShotEx1>, "SaveEditedScreenShotEx1"},
|
||||
{206, &IScreenShotService::SaveEditedScreenShotEx1, "SaveEditedScreenShotEx1"},
|
||||
{208, nullptr, "SaveScreenShotOfMovieEx1"},
|
||||
{1000, nullptr, "Unknown1000"},
|
||||
};
|
||||
@@ -29,38 +30,69 @@ IScreenShotService::IScreenShotService(Core::System& system_,
|
||||
|
||||
IScreenShotService::~IScreenShotService() = default;
|
||||
|
||||
Result IScreenShotService::SaveScreenShotEx0(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer) {
|
||||
void IScreenShotService::SaveScreenShotEx0(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ScreenShotAttribute attribute{};
|
||||
AlbumReportOption report_option{};
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 applet_resource_user_id{};
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto image_data_buffer = ctx.ReadBuffer();
|
||||
|
||||
LOG_INFO(Service_Capture,
|
||||
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
|
||||
report_option, image_data_buffer.size(), aruid.pid);
|
||||
parameters.report_option, image_data_buffer.size(),
|
||||
parameters.applet_resource_user_id);
|
||||
|
||||
ApplicationAlbumEntry entry{};
|
||||
manager->FlipVerticallyOnWrite(false);
|
||||
R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
|
||||
aruid.pid));
|
||||
const auto result =
|
||||
manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
|
||||
image_data_buffer, parameters.applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(result);
|
||||
rb.PushRaw(entry);
|
||||
}
|
||||
|
||||
Result IScreenShotService::SaveEditedScreenShotEx1(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
|
||||
u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
|
||||
const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
thumbnail_image_data_buffer) {
|
||||
void IScreenShotService::SaveEditedScreenShotEx1(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ScreenShotAttribute attribute;
|
||||
u64 width;
|
||||
u64 height;
|
||||
u64 thumbnail_width;
|
||||
u64 thumbnail_height;
|
||||
AlbumFileId file_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x78, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto application_data_buffer = ctx.ReadBuffer(0);
|
||||
const auto image_data_buffer = ctx.ReadBuffer(1);
|
||||
const auto thumbnail_image_data_buffer = ctx.ReadBuffer(2);
|
||||
|
||||
LOG_INFO(Service_Capture,
|
||||
"called, width={}, height={}, thumbnail_width={}, thumbnail_height={}, "
|
||||
"application_id={:016x}, storage={}, type={}, "
|
||||
"application_id={:016x}, storage={}, type={}, app_data_buffer_size={}, "
|
||||
"image_data_buffer_size={}, thumbnail_image_buffer_size={}",
|
||||
width, height, thumbnail_width, thumbnail_height, file_id.application_id,
|
||||
file_id.storage, file_id.type, image_data_buffer.size(),
|
||||
thumbnail_image_data_buffer.size());
|
||||
parameters.width, parameters.height, parameters.thumbnail_width,
|
||||
parameters.thumbnail_height, parameters.file_id.application_id,
|
||||
parameters.file_id.storage, parameters.file_id.type, application_data_buffer.size(),
|
||||
image_data_buffer.size(), thumbnail_image_data_buffer.size());
|
||||
|
||||
ApplicationAlbumEntry entry{};
|
||||
manager->FlipVerticallyOnWrite(false);
|
||||
R_RETURN(manager->SaveEditedScreenShot(*out_entry, attribute, file_id, image_data_buffer));
|
||||
const auto result = manager->SaveEditedScreenShot(entry, parameters.attribute,
|
||||
parameters.file_id, image_data_buffer);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(result);
|
||||
rb.PushRaw(entry);
|
||||
}
|
||||
|
||||
} // namespace Service::Capture
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -19,20 +17,8 @@ public:
|
||||
~IScreenShotService() override;
|
||||
|
||||
private:
|
||||
Result SaveScreenShotEx0(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer);
|
||||
|
||||
Result SaveEditedScreenShotEx1(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
|
||||
u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
|
||||
const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
thumbnail_image_data_buffer);
|
||||
void SaveScreenShotEx0(HLERequestContext& ctx);
|
||||
void SaveEditedScreenShotEx1(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<AlbumManager> manager;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "core/hle/service/caps/caps_manager.h"
|
||||
#include "core/hle/service/caps/caps_su.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
||||
@@ -17,10 +16,10 @@ IScreenShotApplicationService::IScreenShotApplicationService(
|
||||
: ServiceFramework{system_, "caps:su"}, manager{album_manager} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{32, C<&IScreenShotApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
|
||||
{32, &IScreenShotApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
|
||||
{201, nullptr, "SaveScreenShot"},
|
||||
{203, C<&IScreenShotApplicationService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
|
||||
{205, C<&IScreenShotApplicationService::SaveScreenShotEx1>, "SaveScreenShotEx1"},
|
||||
{203, &IScreenShotApplicationService::SaveScreenShotEx0, "SaveScreenShotEx0"},
|
||||
{205, &IScreenShotApplicationService::SaveScreenShotEx1, "SaveScreenShotEx1"},
|
||||
{210, nullptr, "SaveScreenShotEx2"},
|
||||
};
|
||||
// clang-format on
|
||||
@@ -30,40 +29,77 @@ IScreenShotApplicationService::IScreenShotApplicationService(
|
||||
|
||||
IScreenShotApplicationService::~IScreenShotApplicationService() = default;
|
||||
|
||||
Result IScreenShotApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
void IScreenShotApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto library_version{rp.Pop<u64>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
|
||||
library_version, aruid.pid);
|
||||
R_SUCCEED();
|
||||
library_version, applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
Result IScreenShotApplicationService::SaveScreenShotEx0(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer) {
|
||||
void IScreenShotApplicationService::SaveScreenShotEx0(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ScreenShotAttribute attribute{};
|
||||
AlbumReportOption report_option{};
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 applet_resource_user_id{};
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto image_data_buffer = ctx.ReadBuffer();
|
||||
|
||||
LOG_INFO(Service_Capture,
|
||||
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
|
||||
report_option, image_data_buffer.size(), aruid.pid);
|
||||
parameters.report_option, image_data_buffer.size(),
|
||||
parameters.applet_resource_user_id);
|
||||
|
||||
ApplicationAlbumEntry entry{};
|
||||
manager->FlipVerticallyOnWrite(false);
|
||||
R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
|
||||
aruid.pid));
|
||||
const auto result =
|
||||
manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
|
||||
image_data_buffer, parameters.applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(result);
|
||||
rb.PushRaw(entry);
|
||||
}
|
||||
|
||||
Result IScreenShotApplicationService::SaveScreenShotEx1(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer) {
|
||||
void IScreenShotApplicationService::SaveScreenShotEx1(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ScreenShotAttribute attribute{};
|
||||
AlbumReportOption report_option{};
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 applet_resource_user_id{};
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto app_data_buffer = ctx.ReadBuffer(0);
|
||||
const auto image_data_buffer = ctx.ReadBuffer(1);
|
||||
|
||||
LOG_INFO(Service_Capture,
|
||||
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
|
||||
report_option, image_data_buffer.size(), aruid.pid);
|
||||
parameters.report_option, image_data_buffer.size(),
|
||||
parameters.applet_resource_user_id);
|
||||
|
||||
ApplicationAlbumEntry entry{};
|
||||
ApplicationData app_data{};
|
||||
std::memcpy(&app_data, app_data_buffer.data(), sizeof(ApplicationData));
|
||||
manager->FlipVerticallyOnWrite(false);
|
||||
R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, *app_data_buffer,
|
||||
image_data_buffer, aruid.pid));
|
||||
const auto result =
|
||||
manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option, app_data,
|
||||
image_data_buffer, parameters.applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(result);
|
||||
rb.PushRaw(entry);
|
||||
}
|
||||
|
||||
void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption report_option) {
|
||||
@@ -76,7 +112,6 @@ void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption r
|
||||
.orientation = Capture::AlbumImageOrientation::None,
|
||||
.unknown_1{},
|
||||
.unknown_2{},
|
||||
.pad163{},
|
||||
};
|
||||
|
||||
renderer.RequestScreenshot(
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -28,19 +26,9 @@ private:
|
||||
static constexpr std::size_t screenshot_height = 720;
|
||||
static constexpr std::size_t bytes_per_pixel = 4;
|
||||
|
||||
Result SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid);
|
||||
Result SaveScreenShotEx0(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer);
|
||||
Result SaveScreenShotEx1(
|
||||
Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
|
||||
AlbumReportOption report_option, ClientAppletResourceUserId aruid,
|
||||
const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
|
||||
const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
|
||||
image_data_buffer);
|
||||
void SetShimLibraryVersion(HLERequestContext& ctx);
|
||||
void SaveScreenShotEx0(HLERequestContext& ctx);
|
||||
void SaveScreenShotEx1(HLERequestContext& ctx);
|
||||
|
||||
std::array<u8, screenshot_width * screenshot_height * bytes_per_pixel> image_data;
|
||||
|
||||
|
||||
@@ -41,10 +41,6 @@ enum class ScreenShotDecoderFlag : u64 {
|
||||
EnableBlockSmoothing = 1 << 1,
|
||||
};
|
||||
|
||||
enum class ShimLibraryVersion : u64 {
|
||||
Version1 = 1,
|
||||
};
|
||||
|
||||
// This is nn::capsrv::AlbumFileDateTime
|
||||
struct AlbumFileDateTime {
|
||||
s16 year{};
|
||||
@@ -148,23 +144,19 @@ static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
|
||||
"ApplicationAlbumFileEntry has incorrect size.");
|
||||
|
||||
struct ApplicationData {
|
||||
std::array<u8, 0x400> data;
|
||||
u32 data_size;
|
||||
std::array<u8, 0x400> data{};
|
||||
u32 data_size{};
|
||||
};
|
||||
static_assert(sizeof(ApplicationData) == 0x404, "ApplicationData is an invalid size");
|
||||
static_assert(std::is_trivial_v<ApplicationData>,
|
||||
"ApplicationData type must be trivially copyable.");
|
||||
|
||||
struct ScreenShotAttribute {
|
||||
u32 unknown_0;
|
||||
AlbumImageOrientation orientation;
|
||||
u32 unknown_1;
|
||||
u32 unknown_2;
|
||||
INSERT_PADDING_BYTES_NOINIT(0x30);
|
||||
u32 unknown_0{};
|
||||
AlbumImageOrientation orientation{};
|
||||
u32 unknown_1{};
|
||||
u32 unknown_2{};
|
||||
INSERT_PADDING_BYTES(0x30);
|
||||
};
|
||||
static_assert(sizeof(ScreenShotAttribute) == 0x40, "ScreenShotAttribute is an invalid size");
|
||||
static_assert(std::is_trivial_v<ScreenShotAttribute>,
|
||||
"ScreenShotAttribute type must be trivially copyable.");
|
||||
|
||||
struct ScreenShotDecodeOption {
|
||||
ScreenShotDecoderFlag flags{};
|
||||
@@ -173,15 +165,13 @@ struct ScreenShotDecodeOption {
|
||||
static_assert(sizeof(ScreenShotDecodeOption) == 0x20, "ScreenShotDecodeOption is an invalid size");
|
||||
|
||||
struct LoadAlbumScreenShotImageOutput {
|
||||
s64 width;
|
||||
s64 height;
|
||||
ScreenShotAttribute attribute;
|
||||
INSERT_PADDING_BYTES_NOINIT(0x400);
|
||||
s64 width{};
|
||||
s64 height{};
|
||||
ScreenShotAttribute attribute{};
|
||||
INSERT_PADDING_BYTES(0x400);
|
||||
};
|
||||
static_assert(sizeof(LoadAlbumScreenShotImageOutput) == 0x450,
|
||||
"LoadAlbumScreenShotImageOutput is an invalid size");
|
||||
static_assert(std::is_trivial_v<LoadAlbumScreenShotImageOutput>,
|
||||
"LoadAlbumScreenShotImageOutput type must be trivially copyable.");
|
||||
|
||||
struct LoadAlbumScreenShotImageOutputForApplication {
|
||||
s64 width{};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "core/hle/service/caps/caps_manager.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/caps/caps_u.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
|
||||
namespace Service::Capture {
|
||||
@@ -15,8 +14,8 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
|
||||
: ServiceFramework{system_, "caps:u"}, manager{album_manager} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{32, C<&IAlbumApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
|
||||
{102, C<&IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated>, "GetAlbumFileList0AafeAruidDeprecated"},
|
||||
{32, &IAlbumApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
|
||||
{102, &IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated, "GetAlbumFileList0AafeAruidDeprecated"},
|
||||
{103, nullptr, "DeleteAlbumFileByAruid"},
|
||||
{104, nullptr, "GetAlbumFileSizeByAruid"},
|
||||
{105, nullptr, "DeleteAlbumFileByAruidForDebug"},
|
||||
@@ -25,7 +24,7 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
|
||||
{130, nullptr, "PrecheckToCreateContentsByAruid"},
|
||||
{140, nullptr, "GetAlbumFileList1AafeAruidDeprecated"},
|
||||
{141, nullptr, "GetAlbumFileList2AafeUidAruidDeprecated"},
|
||||
{142, C<&IAlbumApplicationService::GetAlbumFileList3AaeAruid>, "GetAlbumFileList3AaeAruid"},
|
||||
{142, &IAlbumApplicationService::GetAlbumFileList3AaeAruid, "GetAlbumFileList3AaeAruid"},
|
||||
{143, nullptr, "GetAlbumFileList4AaeUidAruid"},
|
||||
{144, nullptr, "GetAllAlbumFileList3AaeAruid"},
|
||||
{60002, nullptr, "OpenAccessorSessionForApplication"},
|
||||
@@ -37,40 +36,101 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
|
||||
|
||||
IAlbumApplicationService::~IAlbumApplicationService() = default;
|
||||
|
||||
Result IAlbumApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
void IAlbumApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto library_version{rp.Pop<u64>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
|
||||
library_version, aruid.pid);
|
||||
R_SUCCEED();
|
||||
library_version, applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
Result IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(
|
||||
Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time, s64 end_posix_time,
|
||||
ClientAppletResourceUserId aruid,
|
||||
OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries) {
|
||||
void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ContentType content_type;
|
||||
INSERT_PADDING_BYTES(7);
|
||||
s64 start_posix_time;
|
||||
s64 end_posix_time;
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_Capture,
|
||||
"(STUBBED) called. content_type={}, start_posix_time={}, end_posix_time={}, "
|
||||
"applet_resource_user_id={}",
|
||||
content_type, start_posix_time, end_posix_time, aruid.pid);
|
||||
parameters.content_type, parameters.start_posix_time, parameters.end_posix_time,
|
||||
parameters.applet_resource_user_id);
|
||||
|
||||
R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
|
||||
R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
|
||||
start_posix_time, end_posix_time, aruid.pid));
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = manager->IsAlbumMounted(AlbumStorage::Sd);
|
||||
}
|
||||
|
||||
std::vector<ApplicationAlbumFileEntry> entries;
|
||||
if (result.IsSuccess()) {
|
||||
result = manager->GetAlbumFileList(entries, parameters.content_type,
|
||||
parameters.start_posix_time, parameters.end_posix_time,
|
||||
parameters.applet_resource_user_id);
|
||||
}
|
||||
|
||||
if (!entries.empty()) {
|
||||
ctx.WriteBuffer(entries);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(result);
|
||||
rb.Push<u64>(entries.size());
|
||||
}
|
||||
|
||||
Result IAlbumApplicationService::GetAlbumFileList3AaeAruid(
|
||||
Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
|
||||
AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
|
||||
OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
|
||||
void IAlbumApplicationService::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
ContentType content_type;
|
||||
INSERT_PADDING_BYTES(1);
|
||||
AlbumFileDateTime start_date_time;
|
||||
AlbumFileDateTime end_date_time;
|
||||
INSERT_PADDING_BYTES(6);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_Capture,
|
||||
"(STUBBED) called. content_type={}, start_date={}/{}/{}, "
|
||||
"end_date={}/{}/{}, applet_resource_user_id={}",
|
||||
content_type, start_date_time.year, start_date_time.month, start_date_time.day,
|
||||
end_date_time.year, end_date_time.month, end_date_time.day, aruid.pid);
|
||||
parameters.content_type, parameters.start_date_time.year,
|
||||
parameters.start_date_time.month, parameters.start_date_time.day,
|
||||
parameters.end_date_time.year, parameters.end_date_time.month,
|
||||
parameters.end_date_time.day, parameters.applet_resource_user_id);
|
||||
|
||||
R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
|
||||
R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
|
||||
start_date_time, end_date_time, aruid.pid));
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = manager->IsAlbumMounted(AlbumStorage::Sd);
|
||||
}
|
||||
|
||||
std::vector<ApplicationAlbumEntry> entries;
|
||||
if (result.IsSuccess()) {
|
||||
result =
|
||||
manager->GetAlbumFileList(entries, parameters.content_type, parameters.start_date_time,
|
||||
parameters.end_date_time, parameters.applet_resource_user_id);
|
||||
}
|
||||
|
||||
if (!entries.empty()) {
|
||||
ctx.WriteBuffer(entries);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(result);
|
||||
rb.Push<u64>(entries.size());
|
||||
}
|
||||
|
||||
} // namespace Service::Capture
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -20,18 +19,9 @@ public:
|
||||
~IAlbumApplicationService() override;
|
||||
|
||||
private:
|
||||
Result SetShimLibraryVersion(ShimLibraryVersion library_version,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result GetAlbumFileList0AafeAruidDeprecated(
|
||||
Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time,
|
||||
s64 end_posix_time, ClientAppletResourceUserId aruid,
|
||||
OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries);
|
||||
|
||||
Result GetAlbumFileList3AaeAruid(
|
||||
Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
|
||||
AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
|
||||
OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries);
|
||||
void SetShimLibraryVersion(HLERequestContext& ctx);
|
||||
void GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx);
|
||||
void GetAlbumFileList3AaeAruid(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<AlbumManager> manager = nullptr;
|
||||
};
|
||||
|
||||
@@ -12,109 +12,6 @@
|
||||
namespace Service {
|
||||
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
struct UnwrapArg {
|
||||
using Type = std::remove_cvref_t<T>;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
struct UnwrapArg<InLargeData<T, A>> {
|
||||
using Type = std::remove_cv_t<typename InLargeData<T, A>::Type>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct UnwrapArg<Out<T>> {
|
||||
using Type = AutoOut<typename Out<T>::Type>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct UnwrapArg<OutCopyHandle<T>> {
|
||||
using Type = AutoOut<typename OutCopyHandle<T>::Type>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct UnwrapArg<OutMoveHandle<T>> {
|
||||
using Type = AutoOut<typename OutMoveHandle<T>::Type>;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
struct UnwrapArg<OutLargeData<T, A>> {
|
||||
using Type = AutoOut<typename OutLargeData<T, A>::Type>;
|
||||
};
|
||||
|
||||
enum class ArgumentType {
|
||||
InProcessId,
|
||||
InData,
|
||||
InInterface,
|
||||
InCopyHandle,
|
||||
OutData,
|
||||
OutInterface,
|
||||
OutCopyHandle,
|
||||
OutMoveHandle,
|
||||
InBuffer,
|
||||
InLargeData,
|
||||
OutBuffer,
|
||||
OutLargeData,
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits;
|
||||
|
||||
template <>
|
||||
struct ArgumentTraits<ClientProcessId> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InProcessId;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<SharedPointer<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InInterface;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<InCopyHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InCopyHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<Out<SharedPointer<T>>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutInterface;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<Out<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutData;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<OutCopyHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutCopyHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<OutMoveHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutMoveHandle;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
struct ArgumentTraits<Buffer<T, A>> {
|
||||
static constexpr ArgumentType Type = (A & BufferAttr_In) == 0 ? ArgumentType::OutBuffer : ArgumentType::InBuffer;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
struct ArgumentTraits<InLargeData<T, A>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InLargeData;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
struct ArgumentTraits<OutLargeData<T, A>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutLargeData;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits {
|
||||
static constexpr ArgumentType Type = ArgumentType::InData;
|
||||
};
|
||||
|
||||
struct RequestLayout {
|
||||
u32 copy_handle_count;
|
||||
u32 move_handle_count;
|
||||
@@ -122,14 +19,14 @@ struct RequestLayout {
|
||||
u32 domain_interface_count;
|
||||
};
|
||||
|
||||
template <typename MethodArguments, size_t PrevAlign = 1, size_t DataOffset = 0, size_t ArgIndex = 0>
|
||||
constexpr u32 GetInRawDataSize() {
|
||||
template <ArgumentType Type1, ArgumentType Type2, typename MethodArguments, size_t PrevAlign = 1, size_t DataOffset = 0, size_t ArgIndex = 0>
|
||||
constexpr u32 GetArgumentRawDataSize() {
|
||||
if constexpr (ArgIndex >= std::tuple_size_v<MethodArguments>) {
|
||||
return static_cast<u32>(DataOffset);
|
||||
} else {
|
||||
using ArgType = std::tuple_element_t<ArgIndex, MethodArguments>;
|
||||
|
||||
if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InData || ArgumentTraits<ArgType>::Type == ArgumentType::InProcessId) {
|
||||
if constexpr (ArgumentTraits<ArgType>::Type == Type1 || ArgumentTraits<ArgType>::Type == Type2) {
|
||||
constexpr size_t ArgAlign = alignof(ArgType);
|
||||
constexpr size_t ArgSize = sizeof(ArgType);
|
||||
|
||||
@@ -138,33 +35,9 @@ constexpr u32 GetInRawDataSize() {
|
||||
constexpr size_t ArgOffset = Common::AlignUp(DataOffset, ArgAlign);
|
||||
constexpr size_t ArgEnd = ArgOffset + ArgSize;
|
||||
|
||||
return GetInRawDataSize<MethodArguments, ArgAlign, ArgEnd, ArgIndex + 1>();
|
||||
return GetArgumentRawDataSize<Type1, Type2, MethodArguments, ArgAlign, ArgEnd, ArgIndex + 1>();
|
||||
} else {
|
||||
return GetInRawDataSize<MethodArguments, PrevAlign, DataOffset, ArgIndex + 1>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename MethodArguments, size_t PrevAlign = 1, size_t DataOffset = 0, size_t ArgIndex = 0>
|
||||
constexpr u32 GetOutRawDataSize() {
|
||||
if constexpr (ArgIndex >= std::tuple_size_v<MethodArguments>) {
|
||||
return static_cast<u32>(DataOffset);
|
||||
} else {
|
||||
using ArgType = std::tuple_element_t<ArgIndex, MethodArguments>;
|
||||
|
||||
if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutData) {
|
||||
using RawArgType = typename ArgType::Type;
|
||||
constexpr size_t ArgAlign = alignof(RawArgType);
|
||||
constexpr size_t ArgSize = sizeof(RawArgType);
|
||||
|
||||
static_assert(PrevAlign <= ArgAlign, "Output argument is not ordered by alignment");
|
||||
|
||||
constexpr size_t ArgOffset = Common::AlignUp(DataOffset, ArgAlign);
|
||||
constexpr size_t ArgEnd = ArgOffset + ArgSize;
|
||||
|
||||
return GetOutRawDataSize<MethodArguments, ArgAlign, ArgEnd, ArgIndex + 1>();
|
||||
} else {
|
||||
return GetOutRawDataSize<MethodArguments, PrevAlign, DataOffset, ArgIndex + 1>();
|
||||
return GetArgumentRawDataSize<Type1, Type2, MethodArguments, PrevAlign, DataOffset, ArgIndex + 1>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +62,7 @@ constexpr RequestLayout GetNonDomainReplyInLayout() {
|
||||
return RequestLayout{
|
||||
.copy_handle_count = GetArgumentTypeCount<ArgumentType::InCopyHandle, MethodArguments>(),
|
||||
.move_handle_count = 0,
|
||||
.cmif_raw_data_size = GetInRawDataSize<MethodArguments>(),
|
||||
.cmif_raw_data_size = GetArgumentRawDataSize<ArgumentType::InData, ArgumentType::InProcessId, MethodArguments>(),
|
||||
.domain_interface_count = 0,
|
||||
};
|
||||
}
|
||||
@@ -199,7 +72,7 @@ constexpr RequestLayout GetDomainReplyInLayout() {
|
||||
return RequestLayout{
|
||||
.copy_handle_count = GetArgumentTypeCount<ArgumentType::InCopyHandle, MethodArguments>(),
|
||||
.move_handle_count = 0,
|
||||
.cmif_raw_data_size = GetInRawDataSize<MethodArguments>(),
|
||||
.cmif_raw_data_size = GetArgumentRawDataSize<ArgumentType::InData, ArgumentType::InProcessId, MethodArguments>(),
|
||||
.domain_interface_count = GetArgumentTypeCount<ArgumentType::InInterface, MethodArguments>(),
|
||||
};
|
||||
}
|
||||
@@ -209,7 +82,7 @@ constexpr RequestLayout GetNonDomainReplyOutLayout() {
|
||||
return RequestLayout{
|
||||
.copy_handle_count = GetArgumentTypeCount<ArgumentType::OutCopyHandle, MethodArguments>(),
|
||||
.move_handle_count = GetArgumentTypeCount<ArgumentType::OutMoveHandle, MethodArguments>() + GetArgumentTypeCount<ArgumentType::OutInterface, MethodArguments>(),
|
||||
.cmif_raw_data_size = GetOutRawDataSize<MethodArguments>(),
|
||||
.cmif_raw_data_size = GetArgumentRawDataSize<ArgumentType::OutData, ArgumentType::OutData, MethodArguments>(),
|
||||
.domain_interface_count = 0,
|
||||
};
|
||||
}
|
||||
@@ -219,7 +92,7 @@ constexpr RequestLayout GetDomainReplyOutLayout() {
|
||||
return RequestLayout{
|
||||
.copy_handle_count = GetArgumentTypeCount<ArgumentType::OutCopyHandle, MethodArguments>(),
|
||||
.move_handle_count = GetArgumentTypeCount<ArgumentType::OutMoveHandle, MethodArguments>(),
|
||||
.cmif_raw_data_size = GetOutRawDataSize<MethodArguments>(),
|
||||
.cmif_raw_data_size = GetArgumentRawDataSize<ArgumentType::OutData, ArgumentType::OutData, MethodArguments>(),
|
||||
.domain_interface_count = GetArgumentTypeCount<ArgumentType::OutInterface, MethodArguments>(),
|
||||
};
|
||||
}
|
||||
@@ -249,8 +122,6 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE
|
||||
|
||||
static_assert(PrevAlign <= ArgAlign, "Input argument is not ordered by alignment");
|
||||
static_assert(!RawDataFinished, "All input interface arguments must appear after raw data");
|
||||
static_assert(!std::is_pointer_v<ArgType>, "Input raw data must not be a pointer");
|
||||
static_assert(std::is_trivially_copyable_v<ArgType>, "Input raw data must be trivially copyable");
|
||||
|
||||
constexpr size_t ArgOffset = Common::AlignUp(DataOffset, ArgAlign);
|
||||
constexpr size_t ArgEnd = ArgOffset + ArgSize;
|
||||
@@ -283,7 +154,7 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE
|
||||
|
||||
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex + 1, InBufferIndex, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InLargeData) {
|
||||
constexpr size_t BufferSize = sizeof(typename ArgType::Type);
|
||||
constexpr size_t BufferSize = sizeof(ArgType);
|
||||
|
||||
// Clear the existing data.
|
||||
std::memset(&std::get<ArgIndex>(args), 0, BufferSize);
|
||||
@@ -324,10 +195,10 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE
|
||||
|
||||
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex + 1, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) {
|
||||
constexpr size_t BufferSize = sizeof(typename ArgType::Type);
|
||||
constexpr size_t BufferSize = sizeof(ArgType);
|
||||
|
||||
// Clear the existing data.
|
||||
std::memset(&std::get<ArgIndex>(args).raw, 0, BufferSize);
|
||||
std::memset(&std::get<ArgIndex>(args), 0, BufferSize);
|
||||
|
||||
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex, OutBufferIndex + 1, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutBuffer) {
|
||||
@@ -361,40 +232,36 @@ void WriteOutArgument(bool is_domain, CallArguments& args, u8* raw_data, HLERequ
|
||||
using ArgType = std::tuple_element_t<ArgIndex, MethodArguments>;
|
||||
|
||||
if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutData) {
|
||||
using RawArgType = decltype(std::get<ArgIndex>(args).raw);
|
||||
constexpr size_t ArgAlign = alignof(RawArgType);
|
||||
constexpr size_t ArgSize = sizeof(RawArgType);
|
||||
constexpr size_t ArgAlign = alignof(ArgType);
|
||||
constexpr size_t ArgSize = sizeof(ArgType);
|
||||
|
||||
static_assert(PrevAlign <= ArgAlign, "Output argument is not ordered by alignment");
|
||||
static_assert(!RawDataFinished, "All output interface arguments must appear after raw data");
|
||||
static_assert(!std::is_pointer_v<ArgType>, "Output raw data must not be a pointer");
|
||||
static_assert(!std::is_pointer_v<RawArgType>, "Output raw data must not be a pointer");
|
||||
static_assert(std::is_trivially_copyable_v<RawArgType>, "Output raw data must be trivially copyable");
|
||||
|
||||
constexpr size_t ArgOffset = Common::AlignUp(DataOffset, ArgAlign);
|
||||
constexpr size_t ArgEnd = ArgOffset + ArgSize;
|
||||
|
||||
std::memcpy(raw_data + ArgOffset, &std::get<ArgIndex>(args).raw, ArgSize);
|
||||
std::memcpy(raw_data + ArgOffset, &std::get<ArgIndex>(args), ArgSize);
|
||||
|
||||
return WriteOutArgument<MethodArguments, CallArguments, ArgAlign, ArgEnd, OutBufferIndex, false, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutInterface) {
|
||||
if (is_domain) {
|
||||
ctx.AddDomainObject(std::get<ArgIndex>(args).raw);
|
||||
ctx.AddDomainObject(std::get<ArgIndex>(args));
|
||||
} else {
|
||||
ctx.AddMoveInterface(std::get<ArgIndex>(args).raw);
|
||||
ctx.AddMoveInterface(std::get<ArgIndex>(args));
|
||||
}
|
||||
|
||||
return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, true, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutCopyHandle) {
|
||||
ctx.AddCopyObject(std::get<ArgIndex>(args).raw);
|
||||
ctx.AddCopyObject(std::get<ArgIndex>(args));
|
||||
|
||||
return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutMoveHandle) {
|
||||
ctx.AddMoveObject(std::get<ArgIndex>(args).raw);
|
||||
ctx.AddMoveObject(std::get<ArgIndex>(args));
|
||||
|
||||
return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) {
|
||||
constexpr size_t BufferSize = sizeof(typename ArgType::Type);
|
||||
constexpr size_t BufferSize = sizeof(ArgType);
|
||||
|
||||
ASSERT(ctx.CanWriteBuffer(OutBufferIndex));
|
||||
if constexpr (ArgType::Attr & BufferAttr_HipcAutoSelect) {
|
||||
@@ -435,10 +302,10 @@ void CmifReplyWrapImpl(HLERequestContext& ctx, T& t, Result (T::*f)(A...)) {
|
||||
}
|
||||
const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false;
|
||||
|
||||
using MethodArguments = std::tuple<std::remove_cvref_t<A>...>;
|
||||
using MethodArguments = std::tuple<std::remove_reference_t<A>...>;
|
||||
|
||||
OutTemporaryBuffers buffers{};
|
||||
auto call_arguments = std::tuple<typename UnwrapArg<A>::Type...>();
|
||||
auto call_arguments = std::tuple<typename RemoveOut<A>::Type...>();
|
||||
|
||||
// Read inputs.
|
||||
const size_t offset_plus_command_id = ctx.GetDataPayloadOffset() + 2;
|
||||
|
||||
@@ -12,31 +12,22 @@
|
||||
namespace Service {
|
||||
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
struct AutoOut {
|
||||
T raw;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Out {
|
||||
public:
|
||||
using Type = T;
|
||||
|
||||
/* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ Out(Type* t) : raw(t) {}
|
||||
/* implicit */ Out(Type& t) : raw(&t) {}
|
||||
~Out() = default;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
Type& operator*() const {
|
||||
Type& operator*() {
|
||||
return *raw;
|
||||
}
|
||||
|
||||
Type* operator->() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
@@ -44,9 +35,6 @@ private:
|
||||
template <typename T>
|
||||
using SharedPointer = std::shared_ptr<T>;
|
||||
|
||||
template <typename T>
|
||||
using OutInterface = Out<SharedPointer<T>>;
|
||||
|
||||
struct ClientProcessId {
|
||||
explicit operator bool() const {
|
||||
return pid != 0;
|
||||
@@ -113,21 +101,17 @@ class OutCopyHandle {
|
||||
public:
|
||||
using Type = T*;
|
||||
|
||||
/* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ OutCopyHandle(Type* t) : raw(t) {}
|
||||
/* implicit */ OutCopyHandle(Type& t) : raw(&t) {}
|
||||
~OutCopyHandle() = default;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
Type& operator*() const {
|
||||
Type& operator*() {
|
||||
return *raw;
|
||||
}
|
||||
|
||||
Type* operator->() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
@@ -137,34 +121,30 @@ class OutMoveHandle {
|
||||
public:
|
||||
using Type = T*;
|
||||
|
||||
/* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ OutMoveHandle(Type* t) : raw(t) {}
|
||||
/* implicit */ OutMoveHandle(Type& t) : raw(&t) {}
|
||||
~OutMoveHandle() = default;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
Type& operator*() const {
|
||||
Type& operator*() {
|
||||
return *raw;
|
||||
}
|
||||
|
||||
Type* operator->() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
|
||||
enum BufferAttr : int {
|
||||
/* 0x01 */ BufferAttr_In = (1U << 0),
|
||||
/* 0x02 */ BufferAttr_Out = (1U << 1),
|
||||
/* 0x04 */ BufferAttr_HipcMapAlias = (1U << 2),
|
||||
/* 0x08 */ BufferAttr_HipcPointer = (1U << 3),
|
||||
/* 0x10 */ BufferAttr_FixedSize = (1U << 4),
|
||||
/* 0x20 */ BufferAttr_HipcAutoSelect = (1U << 5),
|
||||
/* 0x40 */ BufferAttr_HipcMapTransferAllowsNonSecure = (1U << 6),
|
||||
/* 0x80 */ BufferAttr_HipcMapTransferAllowsNonDevice = (1U << 7),
|
||||
BufferAttr_In = (1U << 0),
|
||||
BufferAttr_Out = (1U << 1),
|
||||
BufferAttr_HipcMapAlias = (1U << 2),
|
||||
BufferAttr_HipcPointer = (1U << 3),
|
||||
BufferAttr_FixedSize = (1U << 4),
|
||||
BufferAttr_HipcAutoSelect = (1U << 5),
|
||||
BufferAttr_HipcMapTransferAllowsNonSecure = (1U << 6),
|
||||
BufferAttr_HipcMapTransferAllowsNonDevice = (1U << 7),
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
@@ -192,80 +172,123 @@ struct Buffer : public std::span<T> {
|
||||
}
|
||||
};
|
||||
|
||||
template <int A>
|
||||
template <BufferAttr A>
|
||||
using InBuffer = Buffer<const u8, BufferAttr_In | A>;
|
||||
|
||||
template <typename T, int A>
|
||||
template <typename T, BufferAttr A>
|
||||
using InArray = Buffer<T, BufferAttr_In | A>;
|
||||
|
||||
template <int A>
|
||||
template <BufferAttr A>
|
||||
using OutBuffer = Buffer<u8, BufferAttr_Out | A>;
|
||||
|
||||
template <typename T, int A>
|
||||
template <typename T, BufferAttr A>
|
||||
using OutArray = Buffer<T, BufferAttr_Out | A>;
|
||||
|
||||
template <typename T, int A>
|
||||
class InLargeData {
|
||||
public:
|
||||
struct LargeData : public T {
|
||||
static_assert(std::is_trivially_copyable_v<T>, "LargeData type must be trivially copyable");
|
||||
static_assert((A & BufferAttr_Out) == 0, "InLargeData attr must not be Out");
|
||||
static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize);
|
||||
using Type = const T;
|
||||
static_assert((A & BufferAttr_FixedSize) != 0, "LargeData attr must contain FixedSize");
|
||||
static_assert(((A & BufferAttr_In) == 0) ^ ((A & BufferAttr_Out) == 0), "LargeData attr must be In or Out");
|
||||
static constexpr BufferAttr Attr = static_cast<BufferAttr>(A);
|
||||
using Type = T;
|
||||
|
||||
/* implicit */ InLargeData(Type& t) : raw(&t) {}
|
||||
~InLargeData() = default;
|
||||
/* implicit */ LargeData(const T& rhs) : T(rhs) {}
|
||||
/* implicit */ LargeData() = default;
|
||||
};
|
||||
|
||||
InLargeData& operator=(Type* rhs) {
|
||||
raw = rhs;
|
||||
return *this;
|
||||
}
|
||||
template <typename T, BufferAttr A>
|
||||
using InLargeData = LargeData<T, BufferAttr_FixedSize | BufferAttr_In | A>;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
}
|
||||
template <typename T, BufferAttr A>
|
||||
using OutLargeData = LargeData<T, BufferAttr_FixedSize | BufferAttr_Out | A>;
|
||||
|
||||
Type& operator*() const {
|
||||
return *raw;
|
||||
}
|
||||
template <typename T>
|
||||
struct RemoveOut {
|
||||
using Type = std::remove_reference_t<T>;
|
||||
};
|
||||
|
||||
Type* operator->() const {
|
||||
return raw;
|
||||
}
|
||||
template <typename T>
|
||||
struct RemoveOut<Out<T>> {
|
||||
using Type = typename Out<T>::Type;
|
||||
};
|
||||
|
||||
explicit operator bool() const {
|
||||
return raw != nullptr;
|
||||
}
|
||||
template <typename T>
|
||||
struct RemoveOut<OutCopyHandle<T>> {
|
||||
using Type = typename OutCopyHandle<T>::Type;
|
||||
};
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
template <typename T>
|
||||
struct RemoveOut<OutMoveHandle<T>> {
|
||||
using Type = typename OutMoveHandle<T>::Type;
|
||||
};
|
||||
|
||||
enum class ArgumentType {
|
||||
InProcessId,
|
||||
InData,
|
||||
InInterface,
|
||||
InCopyHandle,
|
||||
OutData,
|
||||
OutInterface,
|
||||
OutCopyHandle,
|
||||
OutMoveHandle,
|
||||
InBuffer,
|
||||
InLargeData,
|
||||
OutBuffer,
|
||||
OutLargeData,
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits;
|
||||
|
||||
template <>
|
||||
struct ArgumentTraits<ClientProcessId> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InProcessId;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<SharedPointer<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InInterface;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<InCopyHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::InCopyHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<Out<SharedPointer<T>>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutInterface;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<Out<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutData;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<OutCopyHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutCopyHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ArgumentTraits<OutMoveHandle<T>> {
|
||||
static constexpr ArgumentType Type = ArgumentType::OutMoveHandle;
|
||||
};
|
||||
|
||||
template <typename T, int A>
|
||||
class OutLargeData {
|
||||
public:
|
||||
static_assert(std::is_trivially_copyable_v<T>, "LargeData type must be trivially copyable");
|
||||
static_assert((A & BufferAttr_In) == 0, "OutLargeData attr must not be In");
|
||||
static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize);
|
||||
using Type = T;
|
||||
struct ArgumentTraits<Buffer<T, A>> {
|
||||
static constexpr ArgumentType Type = (A & BufferAttr_In) == 0 ? ArgumentType::OutBuffer : ArgumentType::InBuffer;
|
||||
};
|
||||
|
||||
/* implicit */ OutLargeData(Type* t) : raw(t) {}
|
||||
/* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {}
|
||||
template <typename T, int A>
|
||||
struct ArgumentTraits<LargeData<T, A>> {
|
||||
static constexpr ArgumentType Type = (A & BufferAttr_In) == 0 ? ArgumentType::OutLargeData : ArgumentType::InLargeData;
|
||||
};
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
Type& operator*() const {
|
||||
return *raw;
|
||||
}
|
||||
|
||||
Type* operator->() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
template <typename T>
|
||||
struct ArgumentTraits {
|
||||
static constexpr ArgumentType Type = ArgumentType::InData;
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
} // namespace Service
|
||||
} // namespace Service
|
||||
|
||||
@@ -41,7 +41,7 @@ bool AlarmWorker::GetClosestAlarmInfo(Service::PSC::Time::AlarmInfo& out_alarm_i
|
||||
Service::PSC::Time::AlarmInfo alarm_info{};
|
||||
s64 closest_time{};
|
||||
|
||||
auto res = m_time_m->GetClosestAlarmInfo(&is_valid, &alarm_info, &closest_time);
|
||||
auto res = m_time_m->GetClosestAlarmInfo(is_valid, alarm_info, closest_time);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
if (is_valid) {
|
||||
@@ -76,7 +76,6 @@ void AlarmWorker::OnPowerStateChanged() {
|
||||
|
||||
Result AlarmWorker::AttachToClosestAlarmEvent() {
|
||||
m_time_m->GetClosestAlarmUpdatedEvent(&m_event);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
void Initialize(std::shared_ptr<Service::PSC::Time::ServiceManager> time_m);
|
||||
|
||||
Kernel::KReadableEvent& GetEvent() {
|
||||
Kernel::KEvent& GetEvent() {
|
||||
return *m_event;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
KernelHelpers::ServiceContext m_ctx;
|
||||
std::shared_ptr<Service::PSC::Time::ServiceManager> m_time_m;
|
||||
|
||||
Kernel::KReadableEvent* m_event{};
|
||||
Kernel::KEvent* m_event{};
|
||||
Kernel::KEvent* m_timer_event{};
|
||||
std::shared_ptr<Core::Timing::EventType> m_timer_timing_event;
|
||||
StandardSteadyClockResource& m_steady_clock_resource;
|
||||
|
||||
@@ -13,8 +13,8 @@ void FileTimestampWorker::SetFilesystemPosixTime() {
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
|
||||
if (m_initialized && m_system_clock->GetCurrentTime(&time) == ResultSuccess &&
|
||||
m_time_zone->ToCalendarTimeWithMyRule(&calendar_time, &additional_info, time) ==
|
||||
if (m_initialized && m_system_clock->GetCurrentTime(time) == ResultSuccess &&
|
||||
m_time_zone->ToCalendarTimeWithMyRule(calendar_time, additional_info, time) ==
|
||||
ResultSuccess) {
|
||||
// TODO IFileSystemProxy::SetCurrentPosixTime
|
||||
}
|
||||
|
||||
@@ -79,18 +79,18 @@ Service::PSC::Time::LocationName GetTimeZoneString(Service::PSC::Time::LocationN
|
||||
auto configured_zone = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
|
||||
|
||||
Service::PSC::Time::LocationName configured_name{};
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
std::memcpy(configured_name.name.data(), configured_zone.data(),
|
||||
std::min(configured_name.name.size(), configured_zone.size()));
|
||||
|
||||
if (!IsTimeZoneBinaryValid(configured_name)) {
|
||||
configured_zone = Common::TimeZone::FindSystemTimeZone();
|
||||
configured_name = {};
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
std::memcpy(configured_name.name.data(), configured_zone.data(),
|
||||
std::min(configured_name.name.size(), configured_zone.size()));
|
||||
}
|
||||
|
||||
ASSERT_MSG(IsTimeZoneBinaryValid(configured_name), "Invalid time zone {}!",
|
||||
configured_name.data());
|
||||
configured_name.name.data());
|
||||
|
||||
return configured_name;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ TimeManager::TimeManager(Core::System& system)
|
||||
m_time_m =
|
||||
system.ServiceManager().GetService<Service::PSC::Time::ServiceManager>("time:m", true);
|
||||
|
||||
auto res = m_time_m->GetStaticServiceAsServiceManager(&m_time_sm);
|
||||
auto res = m_time_m->GetStaticServiceAsServiceManager(m_time_sm);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys =
|
||||
@@ -114,10 +114,10 @@ TimeManager::TimeManager(Core::System& system)
|
||||
|
||||
m_worker.Initialize(m_time_sm, m_set_sys);
|
||||
|
||||
res = m_time_sm->GetStandardUserSystemClock(&m_file_timestamp_worker.m_system_clock);
|
||||
res = m_time_sm->GetStandardUserSystemClock(m_file_timestamp_worker.m_system_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetTimeZoneService(&m_file_timestamp_worker.m_time_zone);
|
||||
res = m_time_sm->GetTimeZoneService(m_file_timestamp_worker.m_time_zone);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = SetupStandardSteadyClockCore();
|
||||
@@ -161,8 +161,8 @@ TimeManager::TimeManager(Core::System& system)
|
||||
automatic_correction_time_point);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupStandardUserSystemClockCore(is_automatic_correction_enabled,
|
||||
automatic_correction_time_point);
|
||||
res = m_time_m->SetupStandardUserSystemClockCore(automatic_correction_time_point,
|
||||
is_automatic_correction_enabled);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupEphemeralNetworkSystemClockCore();
|
||||
@@ -184,12 +184,12 @@ TimeManager::TimeManager(Core::System& system)
|
||||
m_file_timestamp_worker.m_initialized = true;
|
||||
|
||||
s64 system_clock_time{};
|
||||
if (m_file_timestamp_worker.m_system_clock->GetCurrentTime(&system_clock_time) ==
|
||||
if (m_file_timestamp_worker.m_system_clock->GetCurrentTime(system_clock_time) ==
|
||||
ResultSuccess) {
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo calendar_additional{};
|
||||
if (m_file_timestamp_worker.m_time_zone->ToCalendarTimeWithMyRule(
|
||||
&calendar_time, &calendar_additional, system_clock_time) == ResultSuccess) {
|
||||
calendar_time, calendar_additional, system_clock_time) == ResultSuccess) {
|
||||
// TODO IFileSystemProxy::SetCurrentPosixTime(system_clock_time,
|
||||
// calendar_additional.ut_offset)
|
||||
}
|
||||
@@ -228,9 +228,10 @@ Result TimeManager::SetupStandardSteadyClockCore() {
|
||||
m_set_sys->SetExternalSteadyClockSourceId(clock_source_id);
|
||||
}
|
||||
|
||||
res = m_time_m->SetupStandardSteadyClockCore(
|
||||
reset_detected, clock_source_id, m_steady_clock_resource.GetTime(),
|
||||
external_steady_clock_internal_offset_ns, standard_steady_clock_test_offset_ns);
|
||||
res = m_time_m->SetupStandardSteadyClockCore(clock_source_id, m_steady_clock_resource.GetTime(),
|
||||
external_steady_clock_internal_offset_ns,
|
||||
standard_steady_clock_test_offset_ns,
|
||||
reset_detected);
|
||||
ASSERT(res == ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
@@ -242,15 +243,14 @@ Result TimeManager::SetupTimeZoneServiceCore() {
|
||||
|
||||
auto configured_zone = GetTimeZoneString(name);
|
||||
|
||||
if (configured_zone != name) {
|
||||
if (configured_zone.name != name.name) {
|
||||
m_set_sys->SetDeviceTimeZoneLocationName(configured_zone);
|
||||
name = configured_zone;
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> local_clock;
|
||||
m_time_sm->GetStandardLocalSystemClock(&local_clock);
|
||||
|
||||
m_time_sm->GetStandardLocalSystemClock(local_clock);
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
local_clock->GetSystemClockContext(&context);
|
||||
local_clock->GetSystemClockContext(context);
|
||||
m_set_sys->SetDeviceTimeZoneLocationUpdatedTime(context.steady_time_point);
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ Result TimeManager::SetupTimeZoneServiceCore() {
|
||||
res = GetTimeZoneRule(rule_buffer, rule_size, name);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupTimeZoneServiceCore(name, rule_version, location_count, time_point,
|
||||
res = m_time_m->SetupTimeZoneServiceCore(name, time_point, rule_version, location_count,
|
||||
rule_buffer);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/glue/time/file_timestamp_worker.h"
|
||||
#include "core/hle/service/glue/time/static.h"
|
||||
#include "core/hle/service/psc/time/errors.h"
|
||||
@@ -43,25 +41,25 @@ StaticService::StaticService(Core::System& system_,
|
||||
time->m_steady_clock_resource} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&StaticService::GetStandardUserSystemClock>, "GetStandardUserSystemClock"},
|
||||
{1, D<&StaticService::GetStandardNetworkSystemClock>, "GetStandardNetworkSystemClock"},
|
||||
{2, D<&StaticService::GetStandardSteadyClock>, "GetStandardSteadyClock"},
|
||||
{3, D<&StaticService::GetTimeZoneService>, "GetTimeZoneService"},
|
||||
{4, D<&StaticService::GetStandardLocalSystemClock>, "GetStandardLocalSystemClock"},
|
||||
{5, D<&StaticService::GetEphemeralNetworkSystemClock>, "GetEphemeralNetworkSystemClock"},
|
||||
{20, D<&StaticService::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
|
||||
{50, D<&StaticService::SetStandardSteadyClockInternalOffset>, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, D<&StaticService::GetStandardSteadyClockRtcValue>, "GetStandardSteadyClockRtcValue"},
|
||||
{100, D<&StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled>, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, D<&StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled>, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, D<&StaticService::GetStandardUserSystemClockInitialYear>, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, D<&StaticService::IsStandardNetworkSystemClockAccuracySufficient>, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, D<&StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime>, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, D<&StaticService::CalculateMonotonicSystemClockBaseTimePoint>, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, D<&StaticService::GetClockSnapshot>, "GetClockSnapshot"},
|
||||
{401, D<&StaticService::GetClockSnapshotFromSystemClockContext>, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, D<&StaticService::CalculateStandardUserSystemClockDifferenceByUser>, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, D<&StaticService::CalculateSpanBetween>, "CalculateSpanBetween"},
|
||||
{0, &StaticService::Handle_GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||
{1, &StaticService::Handle_GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
|
||||
{2, &StaticService::Handle_GetStandardSteadyClock, "GetStandardSteadyClock"},
|
||||
{3, &StaticService::Handle_GetTimeZoneService, "GetTimeZoneService"},
|
||||
{4, &StaticService::Handle_GetStandardLocalSystemClock, "GetStandardLocalSystemClock"},
|
||||
{5, &StaticService::Handle_GetEphemeralNetworkSystemClock, "GetEphemeralNetworkSystemClock"},
|
||||
{20, &StaticService::Handle_GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"},
|
||||
{50, &StaticService::Handle_SetStandardSteadyClockInternalOffset, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, &StaticService::Handle_GetStandardSteadyClockRtcValue, "GetStandardSteadyClockRtcValue"},
|
||||
{100, &StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, &StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, &StaticService::Handle_GetStandardUserSystemClockInitialYear, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, &StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, &StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, &StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, &StaticService::Handle_GetClockSnapshot, "GetClockSnapshot"},
|
||||
{401, &StaticService::Handle_GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, &StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, &StaticService::Handle_CalculateSpanBetween, "CalculateSpanBetween"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -73,80 +71,314 @@ StaticService::StaticService(Core::System& system_,
|
||||
if (m_setup_info.can_write_local_clock && m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock && m_setup_info.can_write_timezone_device_location &&
|
||||
!m_setup_info.can_write_steady_clock && !m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsAdmin(&m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsAdmin(m_wrapped_service);
|
||||
} else if (!m_setup_info.can_write_local_clock && !m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock &&
|
||||
!m_setup_info.can_write_timezone_device_location &&
|
||||
!m_setup_info.can_write_steady_clock &&
|
||||
!m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsUser(&m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsUser(m_wrapped_service);
|
||||
} else if (!m_setup_info.can_write_local_clock && !m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock &&
|
||||
!m_setup_info.can_write_timezone_device_location &&
|
||||
m_setup_info.can_write_steady_clock && !m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsRepair(&m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsRepair(m_wrapped_service);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
auto res = m_wrapped_service->GetTimeZoneService(&m_time_zone);
|
||||
auto res = m_wrapped_service->GetTimeZoneService(m_time_zone);
|
||||
ASSERT(res == ResultSuccess);
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClock(
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
void StaticService::Handle_GetStandardUserSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardUserSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock> service{};
|
||||
auto res = GetStandardSteadyClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetTimeZoneService(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<TimeZoneService> service{};
|
||||
auto res = GetTimeZoneService(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardLocalSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardLocalSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetEphemeralNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KSharedMemory* shared_memory{};
|
||||
auto res = GetSharedMemoryNativeHandle(&shared_memory);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(shared_memory);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto offset_ns{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetStandardSteadyClockInternalOffset(offset_ns);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 rtc_value{};
|
||||
auto res = GetStandardSteadyClockRtcValue(rtc_value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(rtc_value);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_enabled{};
|
||||
auto res = IsStandardUserSystemClockAutomaticCorrectionEnabled(is_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_enabled);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto automatic_correction{rp.Pop<bool>()};
|
||||
|
||||
auto res = SetStandardUserSystemClockAutomaticCorrectionEnabled(automatic_correction);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s32 initial_year{};
|
||||
auto res = GetStandardUserSystemClockInitialYear(initial_year);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(initial_year);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_sufficient{};
|
||||
auto res = IsStandardNetworkSystemClockAccuracySufficient(is_sufficient);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_sufficient);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
auto res = GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + sizeof(Service::PSC::Time::SteadyClockTimePoint) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateMonotonicSystemClockBaseTimePoint(time, context);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push<s64>(time);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshot(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto type{rp.PopEnum<Service::PSC::Time::TimeType>()};
|
||||
|
||||
Service::PSC::Time::ClockSnapshot snapshot{};
|
||||
auto res = GetClockSnapshot(snapshot, type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto clock_type{rp.PopEnum<Service::PSC::Time::TimeType>()};
|
||||
[[maybe_unused]] auto alignment{rp.Pop<u32>()};
|
||||
auto user_context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
auto network_context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
|
||||
Service::PSC::Time::ClockSnapshot snapshot{};
|
||||
auto res =
|
||||
GetClockSnapshotFromSystemClockContext(snapshot, user_context, network_context, clock_type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::ClockSnapshot a{};
|
||||
Service::PSC::Time::ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
|
||||
s64 difference{};
|
||||
auto res = CalculateStandardUserSystemClockDifferenceByUser(difference, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(difference);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateSpanBetween(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::ClockSnapshot a{};
|
||||
Service::PSC::Time::ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateSpanBetween(time, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(time);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result StaticService::GetStandardUserSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
R_RETURN(m_wrapped_service->GetStandardUserSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardNetworkSystemClock(
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
R_RETURN(m_wrapped_service->GetStandardNetworkSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClock(
|
||||
OutInterface<Service::PSC::Time::SteadyClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock>& out_service) {
|
||||
R_RETURN(m_wrapped_service->GetStandardSteadyClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetTimeZoneService(OutInterface<TimeZoneService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service = std::make_shared<TimeZoneService>(
|
||||
m_system, m_file_timestamp_worker, m_setup_info.can_write_timezone_device_location,
|
||||
m_time_zone);
|
||||
Result StaticService::GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service) {
|
||||
out_service = std::make_shared<TimeZoneService>(m_system, m_file_timestamp_worker,
|
||||
m_setup_info.can_write_timezone_device_location,
|
||||
m_time_zone);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardLocalSystemClock(
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
R_RETURN(m_wrapped_service->GetStandardLocalSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetEphemeralNetworkSystemClock(
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
R_RETURN(m_wrapped_service->GetEphemeralNetworkSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetSharedMemoryNativeHandle(
|
||||
OutCopyHandle<Kernel::KSharedMemory> out_shared_memory) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result StaticService::GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory) {
|
||||
R_RETURN(m_wrapped_service->GetSharedMemoryNativeHandle(out_shared_memory));
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) {
|
||||
LOG_DEBUG(Service_Time, "called. offset_ns={}", offset_ns);
|
||||
|
||||
R_UNLESS(m_setup_info.can_write_steady_clock, Service::PSC::Time::ResultPermissionDenied);
|
||||
|
||||
R_RETURN(m_set_sys->SetExternalSteadyClockInternalOffset(
|
||||
@@ -154,92 +386,62 @@ Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) {
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(1)).count()));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); });
|
||||
|
||||
R_RETURN(m_standard_steady_clock_resource.GetRtcTimeInSeconds(*out_rtc_value));
|
||||
Result StaticService::GetStandardSteadyClockRtcValue(s64& out_rtc_value) {
|
||||
R_RETURN(m_standard_steady_clock_resource.GetRtcTimeInSeconds(out_rtc_value));
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
Out<bool> out_automatic_correction) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. out_automatic_correction={}", *out_automatic_correction);
|
||||
});
|
||||
|
||||
bool& out_automatic_correction) {
|
||||
R_RETURN(m_wrapped_service->IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
out_automatic_correction));
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
bool automatic_correction) {
|
||||
LOG_DEBUG(Service_Time, "called. automatic_correction={}", automatic_correction);
|
||||
|
||||
R_RETURN(m_wrapped_service->SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
automatic_correction));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockInitialYear(Out<s32> out_year) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); });
|
||||
|
||||
*out_year = GetSettingsItemValue<s32>(m_set_sys, "time", "standard_user_clock_initial_year");
|
||||
Result StaticService::GetStandardUserSystemClockInitialYear(s32& out_year) {
|
||||
out_year = GetSettingsItemValue<s32>(m_set_sys, "time", "standard_user_clock_initial_year");
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); });
|
||||
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient) {
|
||||
R_RETURN(m_wrapped_service->IsStandardNetworkSystemClockAccuracySufficient(out_is_sufficient));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); });
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
|
||||
R_RETURN(m_wrapped_service->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
out_time_point));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(
|
||||
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
|
||||
|
||||
s64& out_time, Service::PSC::Time::SystemClockContext& context) {
|
||||
R_RETURN(m_wrapped_service->CalculateMonotonicSystemClockBaseTimePoint(out_time, context));
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot,
|
||||
Result StaticService::GetClockSnapshot(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::TimeType type) {
|
||||
SCOPE_EXIT(
|
||||
{ LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); });
|
||||
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshot(out_snapshot, type));
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshotFromSystemClockContext(
|
||||
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
|
||||
Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. type={} out_snapshot={} user_context={} network_context={}", type,
|
||||
*out_snapshot, user_context, network_context);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshotFromSystemClockContext(
|
||||
type, out_snapshot, user_context, network_context));
|
||||
Service::PSC::Time::SystemClockContext& network_context, Service::PSC::Time::TimeType type) {
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshotFromSystemClockContext(out_snapshot, user_context,
|
||||
network_context, type));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_time,
|
||||
InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); });
|
||||
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(
|
||||
s64& out_time, Service::PSC::Time::ClockSnapshot& a, Service::PSC::Time::ClockSnapshot& b) {
|
||||
R_RETURN(m_wrapped_service->CalculateStandardUserSystemClockDifferenceByUser(out_time, a, b));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); });
|
||||
|
||||
Result StaticService::CalculateSpanBetween(s64& out_time, Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b) {
|
||||
R_RETURN(m_wrapped_service->CalculateSpanBetween(out_time, a, b));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/glue/time/manager.h"
|
||||
#include "core/hle/service/glue/time/time_zone.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
@@ -30,10 +29,6 @@ class FileTimestampWorker;
|
||||
class StandardSteadyClockResource;
|
||||
|
||||
class StaticService final : public ServiceFramework<StaticService> {
|
||||
using InClockSnapshot = InLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
using OutClockSnapshot =
|
||||
OutLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
|
||||
public:
|
||||
explicit StaticService(Core::System& system,
|
||||
Service::PSC::Time::StaticServiceSetupInfo setup_info,
|
||||
@@ -41,34 +36,65 @@ public:
|
||||
|
||||
~StaticService() override = default;
|
||||
|
||||
Result GetStandardUserSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetStandardNetworkSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetStandardSteadyClock(OutInterface<Service::PSC::Time::SteadyClock> out_service);
|
||||
Result GetTimeZoneService(OutInterface<TimeZoneService> out_service);
|
||||
Result GetStandardLocalSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetStandardUserSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetStandardNetworkSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetStandardSteadyClock(std::shared_ptr<Service::PSC::Time::SteadyClock>& out_service);
|
||||
Result GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service);
|
||||
Result GetStandardLocalSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetEphemeralNetworkSystemClock(
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetSharedMemoryNativeHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory);
|
||||
Result SetStandardSteadyClockInternalOffset(s64 offset_ns);
|
||||
Result GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(Out<bool> out_is_enabled);
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory);
|
||||
Result SetStandardSteadyClockInternalOffset(s64 offset);
|
||||
Result GetStandardSteadyClockRtcValue(s64& out_rtc_value);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(bool& out_automatic_correction);
|
||||
Result SetStandardUserSystemClockAutomaticCorrectionEnabled(bool automatic_correction);
|
||||
Result GetStandardUserSystemClockInitialYear(Out<s32> out_year);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient);
|
||||
Result GetStandardUserSystemClockInitialYear(s32& out_year);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient);
|
||||
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point);
|
||||
Result CalculateMonotonicSystemClockBaseTimePoint(
|
||||
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context);
|
||||
Result GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type);
|
||||
s64& out_time, Service::PSC::Time::SystemClockContext& context);
|
||||
Result GetClockSnapshot(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::TimeType type);
|
||||
Result GetClockSnapshotFromSystemClockContext(
|
||||
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
|
||||
Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
|
||||
InClockSnapshot a, InClockSnapshot b);
|
||||
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
|
||||
Service::PSC::Time::SystemClockContext& network_context, Service::PSC::Time::TimeType type);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(s64& out_time,
|
||||
Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b);
|
||||
Result CalculateSpanBetween(s64& out_time, Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b);
|
||||
|
||||
private:
|
||||
Result GetClockSnapshotImpl(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context,
|
||||
Service::PSC::Time::TimeType type);
|
||||
|
||||
void Handle_GetStandardUserSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClock(HLERequestContext& ctx);
|
||||
void Handle_GetTimeZoneService(HLERequestContext& ctx);
|
||||
void Handle_GetStandardLocalSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx);
|
||||
void Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx);
|
||||
void Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx);
|
||||
void Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
|
||||
void Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshot(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx);
|
||||
void Handle_CalculateStandardUserSystemClockDifferenceByUser(HLERequestContext& ctx);
|
||||
void Handle_CalculateSpanBetween(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/glue/time/file_timestamp_worker.h"
|
||||
#include "core/hle/service/glue/time/time_zone.h"
|
||||
#include "core/hle/service/glue/time/time_zone_binary.h"
|
||||
@@ -30,20 +28,20 @@ TimeZoneService::TimeZoneService(
|
||||
m_wrapped_service{std::move(time_zone_service)}, m_operation_event{m_system} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"},
|
||||
{1, D<&TimeZoneService::SetDeviceLocationName>, "SetDeviceLocationName"},
|
||||
{2, D<&TimeZoneService::GetTotalLocationNameCount>, "GetTotalLocationNameCount"},
|
||||
{3, D<&TimeZoneService::LoadLocationNameList>, "LoadLocationNameList"},
|
||||
{4, D<&TimeZoneService::LoadTimeZoneRule>, "LoadTimeZoneRule"},
|
||||
{5, D<&TimeZoneService::GetTimeZoneRuleVersion>, "GetTimeZoneRuleVersion"},
|
||||
{6, D<&TimeZoneService::GetDeviceLocationNameAndUpdatedTime>, "GetDeviceLocationNameAndUpdatedTime"},
|
||||
{7, D<&TimeZoneService::SetDeviceLocationNameWithTimeZoneRule>, "SetDeviceLocationNameWithTimeZoneRule"},
|
||||
{8, D<&TimeZoneService::ParseTimeZoneBinary>, "ParseTimeZoneBinary"},
|
||||
{20, D<&TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle>, "GetDeviceLocationNameOperationEventReadableHandle"},
|
||||
{100, D<&TimeZoneService::ToCalendarTime>, "ToCalendarTime"},
|
||||
{101, D<&TimeZoneService::ToCalendarTimeWithMyRule>, "ToCalendarTimeWithMyRule"},
|
||||
{201, D<&TimeZoneService::ToPosixTime>, "ToPosixTime"},
|
||||
{202, D<&TimeZoneService::ToPosixTimeWithMyRule>, "ToPosixTimeWithMyRule"},
|
||||
{0, &TimeZoneService::Handle_GetDeviceLocationName, "GetDeviceLocationName"},
|
||||
{1, &TimeZoneService::Handle_SetDeviceLocationName, "SetDeviceLocationName"},
|
||||
{2, &TimeZoneService::Handle_GetTotalLocationNameCount, "GetTotalLocationNameCount"},
|
||||
{3, &TimeZoneService::Handle_LoadLocationNameList, "LoadLocationNameList"},
|
||||
{4, &TimeZoneService::Handle_LoadTimeZoneRule, "LoadTimeZoneRule"},
|
||||
{5, &TimeZoneService::Handle_GetTimeZoneRuleVersion, "GetTimeZoneRuleVersion"},
|
||||
{6, &TimeZoneService::Handle_GetDeviceLocationNameAndUpdatedTime, "GetDeviceLocationNameAndUpdatedTime"},
|
||||
{7, &TimeZoneService::Handle_SetDeviceLocationNameWithTimeZoneRule, "SetDeviceLocationNameWithTimeZoneRule"},
|
||||
{8, &TimeZoneService::Handle_ParseTimeZoneBinary, "ParseTimeZoneBinary"},
|
||||
{20, &TimeZoneService::Handle_GetDeviceLocationNameOperationEventReadableHandle, "GetDeviceLocationNameOperationEventReadableHandle"},
|
||||
{100, &TimeZoneService::Handle_ToCalendarTime, "ToCalendarTime"},
|
||||
{101, &TimeZoneService::Handle_ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
|
||||
{201, &TimeZoneService::Handle_ToPosixTime, "ToPosixTime"},
|
||||
{202, &TimeZoneService::Handle_ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
@@ -55,16 +53,220 @@ TimeZoneService::TimeZoneService(
|
||||
|
||||
TimeZoneService::~TimeZoneService() = default;
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationName(
|
||||
Out<Service::PSC::Time::LocationName> out_location_name) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); });
|
||||
void TimeZoneService::Handle_GetDeviceLocationName(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
auto res = GetDeviceLocationName(name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::LocationName>(name);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_SetDeviceLocationName(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
|
||||
|
||||
auto res = SetDeviceLocation(name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetTotalLocationNameCount(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
u32 count{};
|
||||
auto res = GetTotalLocationNameCount(count);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_LoadLocationNameList(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto index{rp.Pop<u32>()};
|
||||
|
||||
auto max_names{ctx.GetWriteBufferSize() / sizeof(Service::PSC::Time::LocationName)};
|
||||
|
||||
std::vector<Service::PSC::Time::LocationName> names{};
|
||||
u32 count{};
|
||||
auto res = LoadLocationNameList(count, names, max_names, index);
|
||||
|
||||
ctx.WriteBuffer(names);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_LoadTimeZoneRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
|
||||
|
||||
Tz::Rule rule{};
|
||||
auto res = LoadTimeZoneRule(rule, name);
|
||||
|
||||
ctx.WriteBuffer(rule);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetTimeZoneRuleVersion(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::RuleVersion rule_version{};
|
||||
auto res = GetTimeZoneRuleVersion(rule_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::RuleVersion) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::RuleVersion>(rule_version);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetDeviceLocationNameAndUpdatedTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
auto res = GetDeviceLocationNameAndUpdatedTime(time_point, name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::LocationName) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::SteadyClockTimePoint) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::LocationName>(name);
|
||||
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_SetDeviceLocationNameWithTimeZoneRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
auto res = SetDeviceLocationNameWithTimeZoneRule();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ParseTimeZoneBinary(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetDeviceLocationNameOperationEventReadableHandle(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetDeviceLocationNameOperationEventReadableHandle(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToCalendarTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
auto rule_buffer{ctx.ReadBuffer()};
|
||||
Tz::Rule rule{};
|
||||
std::memcpy(&rule, rule_buffer.data(), sizeof(Tz::Rule));
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
auto res = ToCalendarTime(calendar_time, additional_info, time, rule);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::CalendarTime) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::CalendarAdditionalInfo) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarTime>(calendar_time);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarAdditionalInfo>(additional_info);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToCalendarTimeWithMyRule(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
LOG_DEBUG(Service_Time, "called. time={}", time);
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
auto res = ToCalendarTimeWithMyRule(calendar_time, additional_info, time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::CalendarTime) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::CalendarAdditionalInfo) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarTime>(calendar_time);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarAdditionalInfo>(additional_info);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToPosixTime(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto calendar{rp.PopRaw<Service::PSC::Time::CalendarTime>()};
|
||||
|
||||
LOG_DEBUG(Service_Time, "called. calendar year {} month {} day {} hour {} minute {} second {}",
|
||||
calendar.year, calendar.month, calendar.day, calendar.hour, calendar.minute,
|
||||
calendar.second);
|
||||
|
||||
auto binary{ctx.ReadBuffer()};
|
||||
|
||||
Tz::Rule rule{};
|
||||
std::memcpy(&rule, binary.data(), sizeof(Tz::Rule));
|
||||
|
||||
u32 count{};
|
||||
std::array<s64, 2> times{};
|
||||
u32 times_count{static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(s64))};
|
||||
|
||||
auto res = ToPosixTime(count, times, times_count, calendar, rule);
|
||||
|
||||
ctx.WriteBuffer(times);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToPosixTimeWithMyRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto calendar{rp.PopRaw<Service::PSC::Time::CalendarTime>()};
|
||||
|
||||
u32 count{};
|
||||
std::array<s64, 2> times{};
|
||||
u32 times_count{static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(s64))};
|
||||
|
||||
auto res = ToPosixTimeWithMyRule(count, times, times_count, calendar);
|
||||
|
||||
ctx.WriteBuffer(times);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationName(Service::PSC::Time::LocationName& out_location_name) {
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationName(out_location_name));
|
||||
}
|
||||
|
||||
Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName& location_name) {
|
||||
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
|
||||
|
||||
Result TimeZoneService::SetDeviceLocation(Service::PSC::Time::LocationName& location_name) {
|
||||
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
|
||||
R_UNLESS(IsTimeZoneBinaryValid(location_name), Service::PSC::Time::ResultTimeZoneNotFound);
|
||||
|
||||
@@ -80,7 +282,7 @@ Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName&
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
Service::PSC::Time::LocationName name{};
|
||||
R_TRY(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(&name, &time_point));
|
||||
R_TRY(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(time_point, name));
|
||||
|
||||
m_set_sys->SetDeviceTimeZoneLocationName(name);
|
||||
m_set_sys->SetDeviceTimeZoneLocationUpdatedTime(time_point);
|
||||
@@ -92,27 +294,19 @@ Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName&
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetTotalLocationNameCount(Out<u32> out_count) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); });
|
||||
|
||||
Result TimeZoneService::GetTotalLocationNameCount(u32& out_count) {
|
||||
R_RETURN(m_wrapped_service->GetTotalLocationNameCount(out_count));
|
||||
}
|
||||
|
||||
Result TimeZoneService::LoadLocationNameList(
|
||||
Out<u32> out_count,
|
||||
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. index={} out_count={} out_names[0]={} out_names[1]={}",
|
||||
index, *out_count, out_names[0], out_names[1]);
|
||||
});
|
||||
|
||||
u32& out_count, std::vector<Service::PSC::Time::LocationName>& out_names, size_t max_names,
|
||||
u32 index) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
R_RETURN(GetTimeZoneLocationList(*out_count, out_names, out_names.size(), index));
|
||||
R_RETURN(GetTimeZoneLocationList(out_count, out_names, max_names, index));
|
||||
}
|
||||
|
||||
Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& name) {
|
||||
LOG_DEBUG(Service_Time, "called. name={}", name);
|
||||
|
||||
Result TimeZoneService::LoadTimeZoneRule(Tz::Rule& out_rule,
|
||||
Service::PSC::Time::LocationName& name) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
std::span<const u8> binary{};
|
||||
size_t binary_size{};
|
||||
@@ -120,43 +314,23 @@ Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::L
|
||||
R_RETURN(m_wrapped_service->ParseTimeZoneBinary(out_rule, binary));
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetTimeZoneRuleVersion(
|
||||
Out<Service::PSC::Time::RuleVersion> out_rule_version) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); });
|
||||
|
||||
Result TimeZoneService::GetTimeZoneRuleVersion(Service::PSC::Time::RuleVersion& out_rule_version) {
|
||||
R_RETURN(m_wrapped_service->GetTimeZoneRuleVersion(out_rule_version));
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime(
|
||||
Out<Service::PSC::Time::LocationName> location_name,
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. location_name={} out_time_point={}", *location_name,
|
||||
*out_time_point);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(location_name, out_time_point));
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point,
|
||||
Service::PSC::Time::LocationName& location_name) {
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(out_time_point, location_name));
|
||||
}
|
||||
|
||||
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule(
|
||||
Service::PSC::Time::LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
|
||||
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
|
||||
|
||||
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule() {
|
||||
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
|
||||
R_RETURN(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result TimeZoneService::ParseTimeZoneBinary(OutRule out_rule,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> binary) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent** out_event) {
|
||||
if (!operation_event_initialized) {
|
||||
operation_event_initialized = false;
|
||||
|
||||
@@ -168,56 +342,36 @@ Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(
|
||||
g_list_nodes.push_back(m_operation_event);
|
||||
}
|
||||
|
||||
*out_event = &m_operation_event.m_event->GetReadableEvent();
|
||||
*out_event = m_operation_event.m_event;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToCalendarTime(
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time, InRule rule) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time,
|
||||
*out_calendar_time, *out_additional_info);
|
||||
});
|
||||
|
||||
Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time, Tz::Rule& rule) {
|
||||
R_RETURN(m_wrapped_service->ToCalendarTime(out_calendar_time, out_additional_info, time, rule));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToCalendarTimeWithMyRule(
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time,
|
||||
*out_calendar_time, *out_additional_info);
|
||||
});
|
||||
|
||||
Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time) {
|
||||
R_RETURN(
|
||||
m_wrapped_service->ToCalendarTimeWithMyRule(out_calendar_time, out_additional_info, time));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToPosixTime(Out<u32> out_count,
|
||||
OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
const Service::PSC::Time::CalendarTime& calendar_time,
|
||||
InRule rule) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}",
|
||||
calendar_time, *out_count, out_times[0], out_times[1]);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->ToPosixTime(out_count, out_times, calendar_time, rule));
|
||||
Result TimeZoneService::ToPosixTime(u32& out_count, std::span<s64, 2> out_times,
|
||||
u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time,
|
||||
Tz::Rule& rule) {
|
||||
R_RETURN(
|
||||
m_wrapped_service->ToPosixTime(out_count, out_times, out_times_count, calendar_time, rule));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToPosixTimeWithMyRule(
|
||||
Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
const Service::PSC::Time::CalendarTime& calendar_time) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}",
|
||||
calendar_time, *out_count, out_times[0], out_times[1]);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, calendar_time));
|
||||
Result TimeZoneService::ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times,
|
||||
u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time) {
|
||||
R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, out_times_count,
|
||||
calendar_time));
|
||||
}
|
||||
|
||||
} // namespace Service::Glue::Time
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
@@ -34,9 +33,6 @@ namespace Service::Glue::Time {
|
||||
class FileTimestampWorker;
|
||||
|
||||
class TimeZoneService final : public ServiceFramework<TimeZoneService> {
|
||||
using InRule = InLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;
|
||||
using OutRule = OutLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;
|
||||
|
||||
public:
|
||||
explicit TimeZoneService(
|
||||
Core::System& system, FileTimestampWorker& file_timestamp_worker,
|
||||
@@ -45,35 +41,46 @@ public:
|
||||
|
||||
~TimeZoneService() override;
|
||||
|
||||
Result GetDeviceLocationName(Out<Service::PSC::Time::LocationName> out_location_name);
|
||||
Result SetDeviceLocationName(Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTotalLocationNameCount(Out<u32> out_count);
|
||||
Result LoadLocationNameList(
|
||||
Out<u32> out_count,
|
||||
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index);
|
||||
Result LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTimeZoneRuleVersion(Out<Service::PSC::Time::RuleVersion> out_rule_version);
|
||||
Result GetDeviceLocationName(Service::PSC::Time::LocationName& out_location_name);
|
||||
Result SetDeviceLocation(Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTotalLocationNameCount(u32& out_count);
|
||||
Result LoadLocationNameList(u32& out_count,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
size_t max_names, u32 index);
|
||||
Result LoadTimeZoneRule(Tz::Rule& out_rule, Service::PSC::Time::LocationName& name);
|
||||
Result GetTimeZoneRuleVersion(Service::PSC::Time::RuleVersion& out_rule_version);
|
||||
Result GetDeviceLocationNameAndUpdatedTime(
|
||||
Out<Service::PSC::Time::LocationName> location_name,
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
|
||||
Result SetDeviceLocationNameWithTimeZoneRule(Service::PSC::Time::LocationName& location_name,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> binary);
|
||||
Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
|
||||
Result GetDeviceLocationNameOperationEventReadableHandle(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result ToCalendarTime(Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info,
|
||||
s64 time, InRule rule);
|
||||
Result ToCalendarTimeWithMyRule(
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time);
|
||||
Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
const Service::PSC::Time::CalendarTime& calendar_time, InRule rule);
|
||||
Result ToPosixTimeWithMyRule(Out<u32> out_count,
|
||||
OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
const Service::PSC::Time::CalendarTime& calendar_time);
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point,
|
||||
Service::PSC::Time::LocationName& location_name);
|
||||
Result SetDeviceLocationNameWithTimeZoneRule();
|
||||
Result GetDeviceLocationNameOperationEventReadableHandle(Kernel::KEvent** out_event);
|
||||
Result ToCalendarTime(Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
Tz::Rule& rule);
|
||||
Result ToCalendarTimeWithMyRule(Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info,
|
||||
s64 time);
|
||||
Result ToPosixTime(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time, Tz::Rule& rule);
|
||||
Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time);
|
||||
|
||||
private:
|
||||
void Handle_GetDeviceLocationName(HLERequestContext& ctx);
|
||||
void Handle_SetDeviceLocationName(HLERequestContext& ctx);
|
||||
void Handle_GetTotalLocationNameCount(HLERequestContext& ctx);
|
||||
void Handle_LoadLocationNameList(HLERequestContext& ctx);
|
||||
void Handle_LoadTimeZoneRule(HLERequestContext& ctx);
|
||||
void Handle_GetTimeZoneRuleVersion(HLERequestContext& ctx);
|
||||
void Handle_GetDeviceLocationNameAndUpdatedTime(HLERequestContext& ctx);
|
||||
void Handle_SetDeviceLocationNameWithTimeZoneRule(HLERequestContext& ctx);
|
||||
void Handle_ParseTimeZoneBinary(HLERequestContext& ctx);
|
||||
void Handle_GetDeviceLocationNameOperationEventReadableHandle(HLERequestContext& ctx);
|
||||
void Handle_ToCalendarTime(HLERequestContext& ctx);
|
||||
void Handle_ToCalendarTimeWithMyRule(HLERequestContext& ctx);
|
||||
void Handle_ToPosixTime(HLERequestContext& ctx);
|
||||
void Handle_ToPosixTimeWithMyRule(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName
|
||||
return;
|
||||
}
|
||||
// out_path = fmt::format("{}:/zoneinfo/{}", "TimeZoneBinary", name);
|
||||
out_path = fmt::format("/zoneinfo/{}", name.data());
|
||||
out_path = fmt::format("/zoneinfo/{}", name.name.data());
|
||||
}
|
||||
|
||||
bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name) {
|
||||
@@ -169,7 +169,7 @@ Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
|
||||
}
|
||||
|
||||
Result GetTimeZoneLocationList(u32& out_count,
|
||||
std::span<Service::PSC::Time::LocationName> out_names,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
size_t max_names, u32 index) {
|
||||
std::string path{};
|
||||
GetTimeZoneBinaryListPath(path);
|
||||
@@ -193,7 +193,7 @@ Result GetTimeZoneLocationList(u32& out_count,
|
||||
|
||||
if (chr == '\n') {
|
||||
if (name_count >= index) {
|
||||
out_names[out_count] = current_name;
|
||||
out_names.push_back(current_name);
|
||||
out_count++;
|
||||
if (out_count >= max_names) {
|
||||
break;
|
||||
@@ -209,9 +209,10 @@ Result GetTimeZoneLocationList(u32& out_count,
|
||||
break;
|
||||
}
|
||||
|
||||
R_UNLESS(current_name_len <= current_name.size() - 2, Service::PSC::Time::ResultFailed);
|
||||
R_UNLESS(current_name_len <= current_name.name.size() - 2,
|
||||
Service::PSC::Time::ResultFailed);
|
||||
|
||||
current_name[current_name_len++] = chr;
|
||||
current_name.name[current_name_len++] = chr;
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
|
||||
@@ -26,7 +26,7 @@ Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version);
|
||||
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
|
||||
Service::PSC::Time::LocationName& name);
|
||||
Result GetTimeZoneLocationList(u32& out_count,
|
||||
std::span<Service::PSC::Time::LocationName> out_names,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
size_t max_names, u32 index);
|
||||
|
||||
} // namespace Service::Glue::Time
|
||||
|
||||
@@ -38,12 +38,11 @@ T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set
|
||||
|
||||
TimeWorker::TimeWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource,
|
||||
FileTimestampWorker& file_timestamp_worker)
|
||||
: m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, m_event{m_ctx.CreateEvent(
|
||||
"Glue:TimeWorker:Event")},
|
||||
: m_system{system}, m_ctx{m_system, "Glue:58"}, m_event{m_ctx.CreateEvent("Glue:58:Event")},
|
||||
m_steady_clock_resource{steady_clock_resource},
|
||||
m_file_timestamp_worker{file_timestamp_worker}, m_timer_steady_clock{m_ctx.CreateEvent(
|
||||
"Glue:TimeWorker:SteadyClockTimerEvent")},
|
||||
m_timer_file_system{m_ctx.CreateEvent("Glue:TimeWorker:FileTimeTimerEvent")},
|
||||
"Glue:58:SteadyClockTimerEvent")},
|
||||
m_timer_file_system{m_ctx.CreateEvent("Glue:58:FileTimeTimerEvent")},
|
||||
m_alarm_worker{m_system, m_steady_clock_resource}, m_pm_state_change_handler{m_alarm_worker} {
|
||||
g_ig_report_network_clock_context_set = false;
|
||||
g_report_network_clock_context = {};
|
||||
@@ -114,17 +113,17 @@ void TimeWorker::Initialize(std::shared_ptr<Service::PSC::Time::StaticService> t
|
||||
std::chrono::nanoseconds(fs_notify_time_ns),
|
||||
m_timer_file_system_timing_event);
|
||||
|
||||
auto res = m_time_sm->GetStandardLocalSystemClock(&m_local_clock);
|
||||
auto res = m_time_sm->GetStandardLocalSystemClock(m_local_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res = m_time_m->GetStandardLocalClockOperationEvent(&m_local_clock_event);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetStandardNetworkSystemClock(&m_network_clock);
|
||||
res = m_time_sm->GetStandardNetworkSystemClock(m_network_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res = m_time_m->GetStandardNetworkClockOperationEventForServiceManager(&m_network_clock_event);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetEphemeralNetworkSystemClock(&m_ephemeral_clock);
|
||||
res = m_time_sm->GetEphemeralNetworkSystemClock(m_ephemeral_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res =
|
||||
m_time_m->GetEphemeralNetworkClockOperationEventForServiceManager(&m_ephemeral_clock_event);
|
||||
@@ -184,19 +183,22 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
||||
AddWaiter(&m_event->GetReadableEvent(), EventType::Exit);
|
||||
// TODO
|
||||
// AddWaiter(gIPmModuleService::GetEvent(), 1);
|
||||
AddWaiter(&m_alarm_worker.GetEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetEvent().GetReadableEvent(), EventType::PowerStateChange);
|
||||
} else {
|
||||
AddWaiter(&m_event->GetReadableEvent(), EventType::Exit);
|
||||
// TODO
|
||||
// AddWaiter(gIPmModuleService::GetEvent(), 1);
|
||||
AddWaiter(&m_alarm_worker.GetEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetEvent().GetReadableEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetTimerEvent().GetReadableEvent(), EventType::SignalAlarms);
|
||||
AddWaiter(m_local_clock_event, EventType::UpdateLocalSystemClock);
|
||||
AddWaiter(m_network_clock_event, EventType::UpdateNetworkSystemClock);
|
||||
AddWaiter(m_ephemeral_clock_event, EventType::UpdateEphemeralSystemClock);
|
||||
AddWaiter(&m_local_clock_event->GetReadableEvent(), EventType::UpdateLocalSystemClock);
|
||||
AddWaiter(&m_network_clock_event->GetReadableEvent(),
|
||||
EventType::UpdateNetworkSystemClock);
|
||||
AddWaiter(&m_ephemeral_clock_event->GetReadableEvent(),
|
||||
EventType::UpdateEphemeralSystemClock);
|
||||
AddWaiter(&m_timer_steady_clock->GetReadableEvent(), EventType::UpdateSteadyClock);
|
||||
AddWaiter(&m_timer_file_system->GetReadableEvent(), EventType::UpdateFileTimestamp);
|
||||
AddWaiter(m_standard_user_auto_correct_clock_event, EventType::AutoCorrect);
|
||||
AddWaiter(&m_standard_user_auto_correct_clock_event->GetReadableEvent(),
|
||||
EventType::AutoCorrect);
|
||||
}
|
||||
|
||||
s32 out_index{-1};
|
||||
@@ -235,7 +237,7 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
||||
m_local_clock_event->Clear();
|
||||
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_local_clock->GetSystemClockContext(&context);
|
||||
auto res = m_local_clock->GetSystemClockContext(context);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys->SetUserSystemClockContext(context);
|
||||
@@ -246,12 +248,12 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
||||
case EventType::UpdateNetworkSystemClock: {
|
||||
m_network_clock_event->Clear();
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_network_clock->GetSystemClockContext(&context);
|
||||
auto res = m_network_clock->GetSystemClockContext(context);
|
||||
ASSERT(res == ResultSuccess);
|
||||
m_set_sys->SetNetworkSystemClockContext(context);
|
||||
|
||||
s64 time{};
|
||||
if (m_network_clock->GetCurrentTime(&time) != ResultSuccess) {
|
||||
if (m_network_clock->GetCurrentTime(time) != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -273,13 +275,13 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
||||
m_ephemeral_clock_event->Clear();
|
||||
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_ephemeral_clock->GetSystemClockContext(&context);
|
||||
auto res = m_ephemeral_clock->GetSystemClockContext(context);
|
||||
if (res != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
|
||||
s64 time{};
|
||||
res = m_ephemeral_clock->GetCurrentTime(&time);
|
||||
res = m_ephemeral_clock->GetCurrentTime(time);
|
||||
if (res != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
@@ -315,11 +317,11 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
||||
|
||||
bool automatic_correction{};
|
||||
auto res = m_time_sm->IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
&automatic_correction);
|
||||
automatic_correction);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
res = m_time_sm->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(&time_point);
|
||||
res = m_time_sm->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys->SetUserSystemClockAutomaticCorrectionEnabled(automatic_correction);
|
||||
|
||||
@@ -49,10 +49,10 @@ private:
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> m_ephemeral_clock;
|
||||
StandardSteadyClockResource& m_steady_clock_resource;
|
||||
FileTimestampWorker& m_file_timestamp_worker;
|
||||
Kernel::KReadableEvent* m_local_clock_event{};
|
||||
Kernel::KReadableEvent* m_network_clock_event{};
|
||||
Kernel::KReadableEvent* m_ephemeral_clock_event{};
|
||||
Kernel::KReadableEvent* m_standard_user_auto_correct_clock_event{};
|
||||
Kernel::KEvent* m_local_clock_event{};
|
||||
Kernel::KEvent* m_network_clock_event{};
|
||||
Kernel::KEvent* m_ephemeral_clock_event{};
|
||||
Kernel::KEvent* m_standard_user_auto_correct_clock_event{};
|
||||
Kernel::KEvent* m_timer_steady_clock{};
|
||||
std::shared_ptr<Core::Timing::EventType> m_timer_steady_clock_timing_event;
|
||||
Kernel::KEvent* m_timer_file_system{};
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/hid/hid_server.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/memory.h"
|
||||
@@ -154,7 +153,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
|
||||
{104, &IHidServer::DeactivateNpad, "DeactivateNpad"},
|
||||
{106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"},
|
||||
{107, &IHidServer::DisconnectNpad, "DisconnectNpad"},
|
||||
{108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"},
|
||||
{108, &IHidServer::GetPlayerLedPattern, "GetPlayerLedPattern"},
|
||||
{109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"},
|
||||
{120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
|
||||
{121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
|
||||
@@ -1137,39 +1136,19 @@ void IHidServer::DisconnectNpad(HLERequestContext& ctx) {
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
|
||||
Core::HID::LedPattern pattern{0, 0, 0, 0};
|
||||
auto controller = GetResourceManager()->GetNpad();
|
||||
const auto result = controller->GetLedPattern(npad_id, pattern);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
|
||||
|
||||
switch (npad_id) {
|
||||
case Core::HID::NpadIdType::Player1:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 0, 0, 0};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player2:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 1, 0, 0};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player3:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 1, 1, 0};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player4:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 1, 1, 1};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player5:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 0, 0, 1};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player6:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 0, 1, 0};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player7:
|
||||
*out_led_pattern = Core::HID::LedPattern{1, 0, 1, 1};
|
||||
R_SUCCEED();
|
||||
case Core::HID::NpadIdType::Player8:
|
||||
*out_led_pattern = Core::HID::LedPattern{0, 1, 1, 0};
|
||||
R_SUCCEED();
|
||||
default:
|
||||
*out_led_pattern = Core::HID::LedPattern{0, 0, 0, 0};
|
||||
R_SUCCEED();
|
||||
}
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(result);
|
||||
rb.Push(pattern.raw);
|
||||
}
|
||||
|
||||
void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) {
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "hid_core/hid_types.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@@ -68,8 +66,7 @@ private:
|
||||
void DeactivateNpad(HLERequestContext& ctx);
|
||||
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
|
||||
void DisconnectNpad(HLERequestContext& ctx);
|
||||
Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
|
||||
Core::HID::NpadIdType npad_id);
|
||||
void GetPlayerLedPattern(HLERequestContext& ctx);
|
||||
void ActivateNpadWithRevision(HLERequestContext& ctx);
|
||||
void SetNpadJoyHoldType(HLERequestContext& ctx);
|
||||
void GetNpadJoyHoldType(HLERequestContext& ctx);
|
||||
|
||||
@@ -111,8 +111,7 @@ private:
|
||||
R_RETURN(result);
|
||||
}
|
||||
|
||||
Result UpdateLatest(Out<CharInfo> out_char_info, const CharInfo& char_info,
|
||||
SourceFlag source_flag) {
|
||||
Result UpdateLatest(Out<CharInfo> out_char_info, CharInfo& char_info, SourceFlag source_flag) {
|
||||
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
||||
|
||||
R_RETURN(manager->UpdateLatest(metadata, *out_char_info, char_info, source_flag));
|
||||
@@ -160,7 +159,7 @@ private:
|
||||
R_RETURN(result);
|
||||
}
|
||||
|
||||
Result UpdateLatest1(Out<StoreData> out_store_data, const StoreData& store_data,
|
||||
Result UpdateLatest1(Out<StoreData> out_store_data, StoreData& store_data,
|
||||
SourceFlag source_flag) {
|
||||
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
||||
R_UNLESS(is_system, ResultPermissionDenied);
|
||||
@@ -244,7 +243,7 @@ private:
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result GetIndex(Out<s32> out_index, const CharInfo& char_info) {
|
||||
Result GetIndex(Out<s32> out_index, CharInfo& char_info) {
|
||||
LOG_DEBUG(Service_Mii, "called");
|
||||
|
||||
R_RETURN(manager->GetIndex(metadata, char_info, *out_index));
|
||||
@@ -258,25 +257,25 @@ private:
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Convert(Out<CharInfo> out_char_info, const Ver3StoreData& mii_v3) {
|
||||
Result Convert(Out<CharInfo> out_char_info, Ver3StoreData& mii_v3) {
|
||||
LOG_INFO(Service_Mii, "called");
|
||||
|
||||
R_RETURN(manager->ConvertV3ToCharInfo(*out_char_info, mii_v3));
|
||||
}
|
||||
|
||||
Result ConvertCoreDataToCharInfo(Out<CharInfo> out_char_info, const CoreData& core_data) {
|
||||
Result ConvertCoreDataToCharInfo(Out<CharInfo> out_char_info, CoreData& core_data) {
|
||||
LOG_INFO(Service_Mii, "called");
|
||||
|
||||
R_RETURN(manager->ConvertCoreDataToCharInfo(*out_char_info, core_data));
|
||||
}
|
||||
|
||||
Result ConvertCharInfoToCoreData(Out<CoreData> out_core_data, const CharInfo& char_info) {
|
||||
Result ConvertCharInfoToCoreData(Out<CoreData> out_core_data, CharInfo& char_info) {
|
||||
LOG_INFO(Service_Mii, "called");
|
||||
|
||||
R_RETURN(manager->ConvertCharInfoToCoreData(*out_core_data, char_info));
|
||||
}
|
||||
|
||||
Result Append(const CharInfo& char_info) {
|
||||
Result Append(CharInfo& char_info) {
|
||||
LOG_INFO(Service_Mii, "called");
|
||||
|
||||
R_RETURN(manager->Append(metadata, char_info));
|
||||
|
||||
@@ -1405,7 +1405,7 @@ NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const {
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::Glue::Time::TimeZoneService> timezone_service{};
|
||||
static_service->GetTimeZoneService(&timezone_service);
|
||||
static_service->GetTimeZoneService(timezone_service);
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
@@ -1416,7 +1416,7 @@ NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const {
|
||||
amiibo_date.SetMonth(1);
|
||||
amiibo_date.SetDay(1);
|
||||
|
||||
if (timezone_service->ToCalendarTimeWithMyRule(&calendar_time, &additional_info, posix_time) ==
|
||||
if (timezone_service->ToCalendarTimeWithMyRule(calendar_time, additional_info, posix_time) ==
|
||||
ResultSuccess) {
|
||||
amiibo_date.SetYear(calendar_time.year);
|
||||
amiibo_date.SetMonth(calendar_time.month);
|
||||
@@ -1431,10 +1431,10 @@ s64 NfcDevice::GetCurrentPosixTime() const {
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock> steady_clock{};
|
||||
static_service->GetStandardSteadyClock(&steady_clock);
|
||||
static_service->GetStandardSteadyClock(steady_clock);
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(&time_point));
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(time_point));
|
||||
return time_point.time_point;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,10 +91,10 @@ Result DeviceManager::ListDevices(std::vector<u64>& nfp_devices, std::size_t max
|
||||
true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock> steady_clock{};
|
||||
static_service->GetStandardSteadyClock(&steady_clock);
|
||||
static_service->GetStandardSteadyClock(steady_clock);
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(&time_point));
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(time_point));
|
||||
|
||||
const s64 elapsed_time = time_point.time_point - time_since_last_error;
|
||||
if (time_since_last_error != 0 && elapsed_time < MinimumRecoveryTime) {
|
||||
@@ -754,10 +754,10 @@ Result DeviceManager::VerifyDeviceResult(std::shared_ptr<NfcDevice> device,
|
||||
system.ServiceManager().GetService<Service::Glue::Time::StaticService>("time:u", true);
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock> steady_clock{};
|
||||
static_service->GetStandardSteadyClock(&steady_clock);
|
||||
static_service->GetStandardSteadyClock(steady_clock);
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(&time_point));
|
||||
R_ASSERT(steady_clock->GetCurrentTimePoint(time_point));
|
||||
|
||||
time_since_last_error = time_point.time_point;
|
||||
}
|
||||
|
||||
@@ -83,9 +83,7 @@ SessionId Container::OpenSession(Kernel::KProcess* process) {
|
||||
|
||||
// Check if this memory block is heap.
|
||||
if (svc_mem_info.state == Kernel::Svc::MemoryState::Normal) {
|
||||
if (region_start + region_size == svc_mem_info.base_address) {
|
||||
region_size += svc_mem_info.size;
|
||||
} else if (svc_mem_info.size > region_size) {
|
||||
if (svc_mem_info.size > region_size) {
|
||||
region_size = svc_mem_info.size;
|
||||
region_start = svc_mem_info.base_address;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,10 @@ public:
|
||||
const SyncpointManager& GetSyncpointManager() const;
|
||||
|
||||
struct Host1xDeviceFileData {
|
||||
std::unordered_map<DeviceFD, u32> fd_to_id{};
|
||||
std::deque<u32> syncpts_accumulated{};
|
||||
u32 nvdec_next_id{};
|
||||
u32 vic_next_id{};
|
||||
};
|
||||
|
||||
Host1xDeviceFileData& Host1xDeviceFile();
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/devices/ioctl_serialization.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_nvdec.h"
|
||||
#include "video_core/host1x/host1x.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
@@ -22,8 +21,13 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
switch (command.group) {
|
||||
case 0x0:
|
||||
switch (command.cmd) {
|
||||
case 0x1:
|
||||
case 0x1: {
|
||||
auto& host1x_file = core.Host1xDeviceFile();
|
||||
if (!host1x_file.fd_to_id.contains(fd)) {
|
||||
host1x_file.fd_to_id[fd] = host1x_file.nvdec_next_id++;
|
||||
}
|
||||
return WrapFixedVariable(this, &nvhost_nvdec::Submit, input, output, fd);
|
||||
}
|
||||
case 0x2:
|
||||
return WrapFixed(this, &nvhost_nvdec::GetSyncpoint, input, output);
|
||||
case 0x3:
|
||||
@@ -68,12 +72,15 @@ void nvhost_nvdec::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
|
||||
LOG_INFO(Service_NVDRV, "NVDEC video stream started");
|
||||
system.SetNVDECActive(true);
|
||||
sessions[fd] = session_id;
|
||||
host1x.StartDevice(fd, Tegra::Host1x::ChannelType::NvDec, channel_syncpoint);
|
||||
}
|
||||
|
||||
void nvhost_nvdec::OnClose(DeviceFD fd) {
|
||||
LOG_INFO(Service_NVDRV, "NVDEC video stream ended");
|
||||
host1x.StopDevice(fd, Tegra::Host1x::ChannelType::NvDec);
|
||||
auto& host1x_file = core.Host1xDeviceFile();
|
||||
const auto iter = host1x_file.fd_to_id.find(fd);
|
||||
if (iter != host1x_file.fd_to_id.end()) {
|
||||
system.GPU().ClearCdmaInstance(iter->second);
|
||||
}
|
||||
system.SetNVDECActive(false);
|
||||
auto it = sessions.find(fd);
|
||||
if (it != sessions.end()) {
|
||||
|
||||
@@ -55,9 +55,8 @@ std::size_t WriteVectors(std::span<u8> dst, const std::vector<T>& src, std::size
|
||||
|
||||
nvhost_nvdec_common::nvhost_nvdec_common(Core::System& system_, NvCore::Container& core_,
|
||||
NvCore::ChannelType channel_type_)
|
||||
: nvdevice{system_}, host1x{system_.Host1x()}, core{core_},
|
||||
syncpoint_manager{core.GetSyncpointManager()}, nvmap{core.GetNvMapFile()},
|
||||
channel_type{channel_type_} {
|
||||
: nvdevice{system_}, core{core_}, syncpoint_manager{core.GetSyncpointManager()},
|
||||
nvmap{core.GetNvMapFile()}, channel_type{channel_type_} {
|
||||
auto& syncpts_accumulated = core.Host1xDeviceFile().syncpts_accumulated;
|
||||
if (syncpts_accumulated.empty()) {
|
||||
channel_syncpoint = syncpoint_manager.AllocateSyncpoint(false);
|
||||
@@ -96,24 +95,24 @@ NvResult nvhost_nvdec_common::Submit(IoctlSubmit& params, std::span<u8> data, De
|
||||
offset += SliceVectors(data, syncpt_increments, params.syncpoint_count, offset);
|
||||
offset += SliceVectors(data, fence_thresholds, params.fence_count, offset);
|
||||
|
||||
auto& gpu = system.GPU();
|
||||
auto* session = core.GetSession(sessions[fd]);
|
||||
|
||||
for (std::size_t i = 0; i < syncpt_increments.size(); i++) {
|
||||
const SyncptIncr& syncpt_incr = syncpt_increments[i];
|
||||
fence_thresholds[i] =
|
||||
syncpoint_manager.IncrementSyncpointMaxExt(syncpt_incr.id, syncpt_incr.increments);
|
||||
if (gpu.UseNvdec()) {
|
||||
for (std::size_t i = 0; i < syncpt_increments.size(); i++) {
|
||||
const SyncptIncr& syncpt_incr = syncpt_increments[i];
|
||||
fence_thresholds[i] =
|
||||
syncpoint_manager.IncrementSyncpointMaxExt(syncpt_incr.id, syncpt_incr.increments);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& cmd_buffer : command_buffers) {
|
||||
const auto object = nvmap.GetHandle(cmd_buffer.memory_id);
|
||||
ASSERT_OR_EXECUTE(object, return NvResult::InvalidState;);
|
||||
Core::Memory::CpuGuestMemory<Tegra::ChCommandHeader,
|
||||
Core::Memory::GuestMemoryFlags::SafeRead>
|
||||
cmdlist(session->process->GetMemory(), object->address + cmd_buffer.offset,
|
||||
cmd_buffer.word_count);
|
||||
host1x.PushEntries(fd, std::move(cmdlist));
|
||||
Tegra::ChCommandHeaderList cmdlist(cmd_buffer.word_count);
|
||||
session->process->GetMemory().ReadBlock(object->address + cmd_buffer.offset, cmdlist.data(),
|
||||
cmdlist.size() * sizeof(u32));
|
||||
gpu.PushCommandBuffer(core.Host1xDeviceFile().fd_to_id[fd], cmdlist);
|
||||
}
|
||||
|
||||
// Some games expect command_buffers to be written back
|
||||
offset = 0;
|
||||
offset += WriteVectors(data, command_buffers, offset);
|
||||
|
||||
@@ -119,7 +119,6 @@ protected:
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
||||
Tegra::Host1x::Host1x& host1x;
|
||||
u32 channel_syncpoint;
|
||||
s32_le nvmap_fd{};
|
||||
u32_le submit_timeout{};
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/devices/ioctl_serialization.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_vic.h"
|
||||
#include "video_core/host1x/host1x.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
@@ -22,8 +21,13 @@ NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||
switch (command.group) {
|
||||
case 0x0:
|
||||
switch (command.cmd) {
|
||||
case 0x1:
|
||||
case 0x1: {
|
||||
auto& host1x_file = core.Host1xDeviceFile();
|
||||
if (!host1x_file.fd_to_id.contains(fd)) {
|
||||
host1x_file.fd_to_id[fd] = host1x_file.vic_next_id++;
|
||||
}
|
||||
return WrapFixedVariable(this, &nvhost_vic::Submit, input, output, fd);
|
||||
}
|
||||
case 0x2:
|
||||
return WrapFixed(this, &nvhost_vic::GetSyncpoint, input, output);
|
||||
case 0x3:
|
||||
@@ -66,11 +70,14 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||
|
||||
void nvhost_vic::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
|
||||
sessions[fd] = session_id;
|
||||
host1x.StartDevice(fd, Tegra::Host1x::ChannelType::VIC, channel_syncpoint);
|
||||
}
|
||||
|
||||
void nvhost_vic::OnClose(DeviceFD fd) {
|
||||
host1x.StopDevice(fd, Tegra::Host1x::ChannelType::VIC);
|
||||
auto& host1x_file = core.Host1xDeviceFile();
|
||||
const auto iter = host1x_file.fd_to_id.find(fd);
|
||||
if (iter != host1x_file.fd_to_id.end()) {
|
||||
system.GPU().ClearCdmaInstance(iter->second);
|
||||
}
|
||||
sessions.erase(fd);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/intrusive_list.h"
|
||||
@@ -22,14 +21,8 @@ class System;
|
||||
namespace Service::PSC::Time {
|
||||
using ClockSourceId = Common::UUID;
|
||||
|
||||
enum class TimeType : u8 {
|
||||
UserSystemClock = 0,
|
||||
NetworkSystemClock = 1,
|
||||
LocalSystemClock = 2,
|
||||
};
|
||||
|
||||
struct SteadyClockTimePoint {
|
||||
constexpr bool IdMatches(const SteadyClockTimePoint& other) const {
|
||||
constexpr bool IdMatches(SteadyClockTimePoint& other) {
|
||||
return clock_source_id == other.clock_source_id;
|
||||
}
|
||||
bool operator==(const SteadyClockTimePoint& other) const = default;
|
||||
@@ -49,6 +42,12 @@ struct SystemClockContext {
|
||||
static_assert(sizeof(SystemClockContext) == 0x20, "SystemClockContext has the wrong size!");
|
||||
static_assert(std::is_trivial_v<SystemClockContext>);
|
||||
|
||||
enum class TimeType : u8 {
|
||||
UserSystemClock,
|
||||
NetworkSystemClock,
|
||||
LocalSystemClock,
|
||||
};
|
||||
|
||||
struct CalendarTime {
|
||||
s16 year;
|
||||
s8 month;
|
||||
@@ -68,10 +67,14 @@ struct CalendarAdditionalInfo {
|
||||
};
|
||||
static_assert(sizeof(CalendarAdditionalInfo) == 0x18, "CalendarAdditionalInfo has the wrong size!");
|
||||
|
||||
using LocationName = std::array<char, 0x24>;
|
||||
struct LocationName {
|
||||
std::array<char, 36> name;
|
||||
};
|
||||
static_assert(sizeof(LocationName) == 0x24, "LocationName has the wrong size!");
|
||||
|
||||
using RuleVersion = std::array<char, 0x10>;
|
||||
struct RuleVersion {
|
||||
std::array<char, 16> version;
|
||||
};
|
||||
static_assert(sizeof(RuleVersion) == 0x10, "RuleVersion has the wrong size!");
|
||||
|
||||
struct ClockSnapshot {
|
||||
@@ -149,8 +152,8 @@ constexpr inline std::chrono::nanoseconds ConvertToTimeSpan(s64 ticks) {
|
||||
return std::chrono::nanoseconds(a + b);
|
||||
}
|
||||
|
||||
constexpr inline Result GetSpanBetweenTimePoints(s64* out_seconds, const SteadyClockTimePoint& a,
|
||||
const SteadyClockTimePoint& b) {
|
||||
constexpr inline Result GetSpanBetweenTimePoints(s64* out_seconds, SteadyClockTimePoint& a,
|
||||
SteadyClockTimePoint& b) {
|
||||
R_UNLESS(out_seconds, ResultInvalidArgument);
|
||||
R_UNLESS(a.IdMatches(b), ResultInvalidArgument);
|
||||
R_UNLESS(a.time_point >= 0 || b.time_point <= a.time_point + std::numeric_limits<s64>::max(),
|
||||
@@ -163,111 +166,3 @@ constexpr inline Result GetSpanBetweenTimePoints(s64* out_seconds, const SteadyC
|
||||
}
|
||||
|
||||
} // namespace Service::PSC::Time
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::TimeType> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(Service::PSC::Time::TimeType type, FormatContext& ctx) {
|
||||
const string_view name = [type] {
|
||||
using Service::PSC::Time::TimeType;
|
||||
switch (type) {
|
||||
case TimeType::UserSystemClock:
|
||||
return "UserSystemClock";
|
||||
case TimeType::NetworkSystemClock:
|
||||
return "NetworkSystemClock";
|
||||
case TimeType::LocalSystemClock:
|
||||
return "LocalSystemClock";
|
||||
}
|
||||
return "Invalid";
|
||||
}();
|
||||
return formatter<string_view>::format(name, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::SteadyClockTimePoint> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::SteadyClockTimePoint& time_point,
|
||||
FormatContext& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "[time_point={}]", time_point.time_point);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::SystemClockContext> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::SystemClockContext& context, FormatContext& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "[offset={} steady_time_point={}]", context.offset,
|
||||
context.steady_time_point.time_point);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::CalendarTime> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::CalendarTime& calendar, FormatContext& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "[{:02}/{:02}/{:04} {:02}:{:02}:{:02}]", calendar.day,
|
||||
calendar.month, calendar.year, calendar.hour, calendar.minute,
|
||||
calendar.second);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::CalendarAdditionalInfo>
|
||||
: fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::CalendarAdditionalInfo& additional,
|
||||
FormatContext& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "[weekday={} yearday={} name={} is_dst={} ut_offset={}]",
|
||||
additional.day_of_week, additional.day_of_year,
|
||||
additional.name.data(), additional.is_dst, additional.ut_offset);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::LocationName> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::LocationName& name, FormatContext& ctx) const {
|
||||
return formatter<string_view>::format(name.data(), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::RuleVersion> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::RuleVersion& version, FormatContext& ctx) const {
|
||||
return formatter<string_view>::format(version.data(), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::ClockSnapshot> : fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::ClockSnapshot& snapshot, FormatContext& ctx) const {
|
||||
return fmt::format_to(
|
||||
ctx.out(),
|
||||
"[user_context={} network_context={} user_time={} network_time={} "
|
||||
"user_calendar_time={} "
|
||||
"network_calendar_time={} user_calendar_additional_time={} "
|
||||
"network_calendar_additional_time={} steady_clock_time_point={} location={} "
|
||||
"is_automatic_correction_enabled={} type={}]",
|
||||
snapshot.user_context, snapshot.network_context, snapshot.user_time,
|
||||
snapshot.network_time, snapshot.user_calendar_time, snapshot.network_calendar_time,
|
||||
snapshot.user_calendar_additional_time, snapshot.network_calendar_additional_time,
|
||||
snapshot.steady_clock_time_point, snapshot.location_name,
|
||||
snapshot.is_automatic_correction_enabled, snapshot.type);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<Service::PSC::Time::ContinuousAdjustmentTimePoint>
|
||||
: fmt::formatter<fmt::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Service::PSC::Time::ContinuousAdjustmentTimePoint& time_point,
|
||||
FormatContext& ctx) const {
|
||||
return fmt::format_to(ctx.out(),
|
||||
"[rtc_offset={} diff_scale={} shift_amount={} lower={} upper={}]",
|
||||
time_point.rtc_offset, time_point.diff_scale, time_point.shift_amount,
|
||||
time_point.lower, time_point.upper);
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/psc/time/power_state_service.h"
|
||||
|
||||
namespace Service::PSC::Time {
|
||||
@@ -12,34 +11,39 @@ IPowerStateRequestHandler::IPowerStateRequestHandler(
|
||||
power_state_request_manager} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle>, "GetPowerStateRequestEventReadableHandle"},
|
||||
{1, D<&IPowerStateRequestHandler::GetAndClearPowerStateRequest>, "GetAndClearPowerStateRequest"},
|
||||
{0, &IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle, "GetPowerStateRequestEventReadableHandle"},
|
||||
{1, &IPowerStateRequestHandler::GetAndClearPowerStateRequest, "GetAndClearPowerStateRequest"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
void IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_power_state_request_manager.GetReadableEvent();
|
||||
R_SUCCEED();
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(m_power_state_request_manager.GetReadableEvent());
|
||||
}
|
||||
|
||||
Result IPowerStateRequestHandler::GetAndClearPowerStateRequest(Out<bool> out_cleared,
|
||||
Out<u32> out_priority) {
|
||||
void IPowerStateRequestHandler::GetAndClearPowerStateRequest(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
u32 priority{};
|
||||
auto cleared = m_power_state_request_manager.GetAndClearPowerStateRequest(priority);
|
||||
*out_cleared = cleared;
|
||||
|
||||
if (cleared) {
|
||||
*out_priority = priority;
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(priority);
|
||||
rb.Push(cleared);
|
||||
return;
|
||||
}
|
||||
R_SUCCEED();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(cleared);
|
||||
}
|
||||
|
||||
} // namespace Service::PSC::Time
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/power_state_request_manager.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
@@ -22,10 +21,10 @@ public:
|
||||
|
||||
~IPowerStateRequestHandler() override = default;
|
||||
|
||||
Result GetPowerStateRequestEventReadableHandle(OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetAndClearPowerStateRequest(Out<bool> out_cleared, Out<u32> out_priority);
|
||||
|
||||
private:
|
||||
void GetPowerStateRequestEventReadableHandle(HLERequestContext& ctx);
|
||||
void GetAndClearPowerStateRequest(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
PowerStateRequestManager& m_power_state_request_manager;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/psc/time/power_state_service.h"
|
||||
#include "core/hle/service/psc/time/service_manager.h"
|
||||
#include "core/hle/service/psc/time/static.h"
|
||||
@@ -26,24 +25,24 @@ ServiceManager::ServiceManager(Core::System& system_, std::shared_ptr<TimeManage
|
||||
m_local_operation{m_system}, m_network_operation{m_system}, m_ephemeral_operation{m_system} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&ServiceManager::GetStaticServiceAsUser>, "GetStaticServiceAsUser"},
|
||||
{5, D<&ServiceManager::GetStaticServiceAsAdmin>, "GetStaticServiceAsAdmin"},
|
||||
{6, D<&ServiceManager::GetStaticServiceAsRepair>, "GetStaticServiceAsRepair"},
|
||||
{9, D<&ServiceManager::GetStaticServiceAsServiceManager>, "GetStaticServiceAsServiceManager"},
|
||||
{10, D<&ServiceManager::SetupStandardSteadyClockCore>, "SetupStandardSteadyClockCore"},
|
||||
{11, D<&ServiceManager::SetupStandardLocalSystemClockCore>, "SetupStandardLocalSystemClockCore"},
|
||||
{12, D<&ServiceManager::SetupStandardNetworkSystemClockCore>, "SetupStandardNetworkSystemClockCore"},
|
||||
{13, D<&ServiceManager::SetupStandardUserSystemClockCore>, "SetupStandardUserSystemClockCore"},
|
||||
{14, D<&ServiceManager::SetupTimeZoneServiceCore>, "SetupTimeZoneServiceCore"},
|
||||
{15, D<&ServiceManager::SetupEphemeralNetworkSystemClockCore>, "SetupEphemeralNetworkSystemClockCore"},
|
||||
{50, D<&ServiceManager::GetStandardLocalClockOperationEvent>, "GetStandardLocalClockOperationEvent"},
|
||||
{51, D<&ServiceManager::GetStandardNetworkClockOperationEventForServiceManager>, "GetStandardNetworkClockOperationEventForServiceManager"},
|
||||
{52, D<&ServiceManager::GetEphemeralNetworkClockOperationEventForServiceManager>, "GetEphemeralNetworkClockOperationEventForServiceManager"},
|
||||
{60, D<&ServiceManager::GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent>, "GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent"},
|
||||
{100, D<&ServiceManager::SetStandardSteadyClockBaseTime>, "SetStandardSteadyClockBaseTime"},
|
||||
{200, D<&ServiceManager::GetClosestAlarmUpdatedEvent>, "GetClosestAlarmUpdatedEvent"},
|
||||
{201, D<&ServiceManager::CheckAndSignalAlarms>, "CheckAndSignalAlarms"},
|
||||
{202, D<&ServiceManager::GetClosestAlarmInfo>, "GetClosestAlarmInfo "},
|
||||
{0, &ServiceManager::Handle_GetStaticServiceAsUser, "GetStaticServiceAsUser"},
|
||||
{5, &ServiceManager::Handle_GetStaticServiceAsAdmin, "GetStaticServiceAsAdmin"},
|
||||
{6, &ServiceManager::Handle_GetStaticServiceAsRepair, "GetStaticServiceAsRepair"},
|
||||
{9, &ServiceManager::Handle_GetStaticServiceAsServiceManager, "GetStaticServiceAsServiceManager"},
|
||||
{10, &ServiceManager::Handle_SetupStandardSteadyClockCore, "SetupStandardSteadyClockCore"},
|
||||
{11, &ServiceManager::Handle_SetupStandardLocalSystemClockCore, "SetupStandardLocalSystemClockCore"},
|
||||
{12, &ServiceManager::Handle_SetupStandardNetworkSystemClockCore, "SetupStandardNetworkSystemClockCore"},
|
||||
{13, &ServiceManager::Handle_SetupStandardUserSystemClockCore, "SetupStandardUserSystemClockCore"},
|
||||
{14, &ServiceManager::Handle_SetupTimeZoneServiceCore, "SetupTimeZoneServiceCore"},
|
||||
{15, &ServiceManager::Handle_SetupEphemeralNetworkSystemClockCore, "SetupEphemeralNetworkSystemClockCore"},
|
||||
{50, &ServiceManager::Handle_GetStandardLocalClockOperationEvent, "GetStandardLocalClockOperationEvent"},
|
||||
{51, &ServiceManager::Handle_GetStandardNetworkClockOperationEventForServiceManager, "GetStandardNetworkClockOperationEventForServiceManager"},
|
||||
{52, &ServiceManager::Handle_GetEphemeralNetworkClockOperationEventForServiceManager, "GetEphemeralNetworkClockOperationEventForServiceManager"},
|
||||
{60, &ServiceManager::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent, "GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent"},
|
||||
{100, &ServiceManager::Handle_SetStandardSteadyClockBaseTime, "SetStandardSteadyClockBaseTime"},
|
||||
{200, &ServiceManager::Handle_GetClosestAlarmUpdatedEvent, "GetClosestAlarmUpdatedEvent"},
|
||||
{201, &ServiceManager::Handle_CheckAndSignalAlarms, "CheckAndSignalAlarms"},
|
||||
{202, &ServiceManager::Handle_GetClosestAlarmInfo, "GetClosestAlarmInfo "},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
@@ -53,39 +52,302 @@ ServiceManager::ServiceManager(Core::System& system_, std::shared_ptr<TimeManage
|
||||
m_ephemeral_system_context_writer.Link(m_ephemeral_operation);
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsUser(OutInterface<StaticService> out_service) {
|
||||
void ServiceManager::SetupSAndP() {
|
||||
if (!m_is_s_and_p_setup) {
|
||||
m_is_s_and_p_setup = true;
|
||||
m_server_manager.RegisterNamedService(
|
||||
"time:s", std::make_shared<StaticService>(
|
||||
m_system, StaticServiceSetupInfo{0, 0, 1, 0, 0, 0}, m_time, "time:s"));
|
||||
m_server_manager.RegisterNamedService("time:p",
|
||||
std::make_shared<IPowerStateRequestHandler>(
|
||||
m_system, m_time->m_power_state_request_manager));
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceManager::CheckAndSetupServicesSAndP() {
|
||||
if (m_local_system_clock.IsInitialized() && m_user_system_clock.IsInitialized() &&
|
||||
m_network_system_clock.IsInitialized() && m_steady_clock.IsInitialized() &&
|
||||
m_time_zone.IsInitialized() && m_ephemeral_network_clock.IsInitialized()) {
|
||||
SetupSAndP();
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStaticServiceAsUser(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<StaticService> service{};
|
||||
auto res = GetStaticServiceAsUser(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<StaticService>(std::move(service));
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStaticServiceAsAdmin(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<StaticService> service{};
|
||||
auto res = GetStaticServiceAsAdmin(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<StaticService>(std::move(service));
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStaticServiceAsRepair(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<StaticService> service{};
|
||||
auto res = GetStaticServiceAsRepair(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<StaticService>(std::move(service));
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStaticServiceAsServiceManager(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<StaticService> service{};
|
||||
auto res = GetStaticServiceAsServiceManager(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<StaticService>(std::move(service));
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupStandardSteadyClockCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
struct Parameters {
|
||||
bool reset_detected;
|
||||
Common::UUID clock_source_id;
|
||||
s64 rtc_offset;
|
||||
s64 internal_offset;
|
||||
s64 test_offset;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x30);
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto params{rp.PopRaw<Parameters>()};
|
||||
|
||||
auto res = SetupStandardSteadyClockCore(params.clock_source_id, params.rtc_offset,
|
||||
params.internal_offset, params.test_offset,
|
||||
params.reset_detected);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupStandardLocalSystemClockCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<SystemClockContext>()};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetupStandardLocalSystemClockCore(context, time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupStandardNetworkSystemClockCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<SystemClockContext>()};
|
||||
auto accuracy{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetupStandardNetworkSystemClockCore(context, accuracy);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupStandardUserSystemClockCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
struct Parameters {
|
||||
bool automatic_correction;
|
||||
SteadyClockTimePoint time_point;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x20);
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto params{rp.PopRaw<Parameters>()};
|
||||
|
||||
auto res = SetupStandardUserSystemClockCore(params.time_point, params.automatic_correction);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupTimeZoneServiceCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
struct Parameters {
|
||||
u32 location_count;
|
||||
LocationName name;
|
||||
SteadyClockTimePoint time_point;
|
||||
RuleVersion rule_version;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x50);
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto params{rp.PopRaw<Parameters>()};
|
||||
|
||||
auto rule_buffer{ctx.ReadBuffer()};
|
||||
|
||||
auto res = SetupTimeZoneServiceCore(params.name, params.time_point, params.rule_version,
|
||||
params.location_count, rule_buffer);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetupEphemeralNetworkSystemClockCore(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
auto res = SetupEphemeralNetworkSystemClockCore();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStandardLocalClockOperationEvent(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetStandardLocalClockOperationEvent(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStandardNetworkClockOperationEventForServiceManager(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetStandardNetworkClockOperationEventForServiceManager(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetEphemeralNetworkClockOperationEventForServiceManager(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetEphemeralNetworkClockOperationEventForServiceManager(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_SetStandardSteadyClockBaseTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto base_time{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetStandardSteadyClockBaseTime(base_time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetClosestAlarmUpdatedEvent(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetClosestAlarmUpdatedEvent(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_CheckAndSignalAlarms(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
auto res = CheckAndSignalAlarms();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void ServiceManager::Handle_GetClosestAlarmInfo(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
AlarmInfo alarm_info{};
|
||||
bool is_valid{};
|
||||
s64 time{};
|
||||
auto res = GetClosestAlarmInfo(is_valid, alarm_info, time);
|
||||
|
||||
struct OutParameters {
|
||||
bool is_valid;
|
||||
AlarmInfo alarm_info;
|
||||
s64 time;
|
||||
};
|
||||
static_assert(sizeof(OutParameters) == 0x20);
|
||||
|
||||
OutParameters out_params{
|
||||
.is_valid = is_valid,
|
||||
.alarm_info = alarm_info,
|
||||
.time = time,
|
||||
};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(OutParameters) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<OutParameters>(out_params);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result ServiceManager::GetStaticService(std::shared_ptr<StaticService>& out_service,
|
||||
StaticServiceSetupInfo setup_info, const char* name) {
|
||||
out_service = std::make_shared<StaticService>(m_system, setup_info, m_time, name);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsUser(std::shared_ptr<StaticService>& out_service) {
|
||||
R_RETURN(GetStaticService(out_service, StaticServiceSetupInfo{0, 0, 0, 0, 0, 0}, "time:u"));
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsAdmin(OutInterface<StaticService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsAdmin(std::shared_ptr<StaticService>& out_service) {
|
||||
R_RETURN(GetStaticService(out_service, StaticServiceSetupInfo{1, 1, 0, 1, 0, 0}, "time:a"));
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsRepair(OutInterface<StaticService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsRepair(std::shared_ptr<StaticService>& out_service) {
|
||||
R_RETURN(GetStaticService(out_service, StaticServiceSetupInfo{0, 0, 0, 0, 1, 0}, "time:r"));
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsServiceManager(OutInterface<StaticService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result ServiceManager::GetStaticServiceAsServiceManager(
|
||||
std::shared_ptr<StaticService>& out_service) {
|
||||
R_RETURN(GetStaticService(out_service, StaticServiceSetupInfo{1, 1, 1, 1, 1, 0}, "time:sm"));
|
||||
}
|
||||
|
||||
Result ServiceManager::SetupStandardSteadyClockCore(bool is_rtc_reset_detected,
|
||||
Common::UUID& clock_source_id, s64 rtc_offset,
|
||||
s64 internal_offset, s64 test_offset) {
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. is_rtc_reset_detected={} clock_source_id={} rtc_offset={} "
|
||||
"internal_offset={} test_offset={}",
|
||||
is_rtc_reset_detected, clock_source_id.RawString(), rtc_offset, internal_offset,
|
||||
test_offset);
|
||||
|
||||
Result ServiceManager::SetupStandardSteadyClockCore(Common::UUID& clock_source_id, s64 rtc_offset,
|
||||
s64 internal_offset, s64 test_offset,
|
||||
bool is_rtc_reset_detected) {
|
||||
m_steady_clock.Initialize(clock_source_id, rtc_offset, internal_offset, test_offset,
|
||||
is_rtc_reset_detected);
|
||||
auto time = m_steady_clock.GetRawTime();
|
||||
@@ -103,10 +365,6 @@ Result ServiceManager::SetupStandardSteadyClockCore(bool is_rtc_reset_detected,
|
||||
}
|
||||
|
||||
Result ServiceManager::SetupStandardLocalSystemClockCore(SystemClockContext& context, s64 time) {
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. context={} context.steady_time_point.clock_source_id={} time={}", context,
|
||||
context.steady_time_point.clock_source_id.RawString(), time);
|
||||
|
||||
m_local_system_clock.SetContextWriter(m_local_system_context_writer);
|
||||
m_local_system_clock.Initialize(context, time);
|
||||
|
||||
@@ -116,12 +374,12 @@ Result ServiceManager::SetupStandardLocalSystemClockCore(SystemClockContext& con
|
||||
|
||||
Result ServiceManager::SetupStandardNetworkSystemClockCore(SystemClockContext& context,
|
||||
s64 accuracy) {
|
||||
LOG_DEBUG(Service_Time, "called. context={} steady_time_point.clock_source_id={} accuracy={}",
|
||||
context, context.steady_time_point.clock_source_id.RawString(), accuracy);
|
||||
|
||||
// TODO this is a hack! The network clock should be updated independently, from the ntc service
|
||||
// and maybe elsewhere. We do not do that, so fix the clock to the local clock.
|
||||
m_local_system_clock.GetContext(context);
|
||||
// and maybe elsewhere. We do not do that, so fix the clock to the local clock on first boot
|
||||
// to avoid it being stuck at 0.
|
||||
if (context == Service::PSC::Time::SystemClockContext{}) {
|
||||
m_local_system_clock.GetContext(context);
|
||||
}
|
||||
|
||||
m_network_system_clock.SetContextWriter(m_network_system_context_writer);
|
||||
m_network_system_clock.Initialize(context, accuracy);
|
||||
@@ -130,10 +388,14 @@ Result ServiceManager::SetupStandardNetworkSystemClockCore(SystemClockContext& c
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::SetupStandardUserSystemClockCore(bool automatic_correction,
|
||||
SteadyClockTimePoint& time_point) {
|
||||
LOG_DEBUG(Service_Time, "called. automatic_correction={} time_point={} clock_source_id={}",
|
||||
automatic_correction, time_point, time_point.clock_source_id.RawString());
|
||||
Result ServiceManager::SetupStandardUserSystemClockCore(SteadyClockTimePoint& time_point,
|
||||
bool automatic_correction) {
|
||||
// TODO this is a hack! The user clock should be updated independently, from the ntc service
|
||||
// and maybe elsewhere. We do not do that, so fix the clock to the local clock on first boot
|
||||
// to avoid it being stuck at 0.
|
||||
if (time_point == Service::PSC::Time::SteadyClockTimePoint{}) {
|
||||
m_local_system_clock.GetCurrentTimePoint(time_point);
|
||||
}
|
||||
|
||||
m_user_system_clock.SetAutomaticCorrection(automatic_correction);
|
||||
m_user_system_clock.SetTimePointAndSignal(time_point);
|
||||
@@ -144,16 +406,10 @@ Result ServiceManager::SetupStandardUserSystemClockCore(bool automatic_correctio
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::SetupTimeZoneServiceCore(LocationName& name, RuleVersion& rule_version,
|
||||
u32 location_count,
|
||||
Result ServiceManager::SetupTimeZoneServiceCore(LocationName& name,
|
||||
SteadyClockTimePoint& time_point,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> rule_buffer) {
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. name={} rule_version={} location_count={} time_point={} "
|
||||
"clock_source_id={}",
|
||||
name, rule_version, location_count, time_point,
|
||||
time_point.clock_source_id.RawString());
|
||||
|
||||
RuleVersion& rule_version, u32 location_count,
|
||||
std::span<const u8> rule_buffer) {
|
||||
if (m_time_zone.ParseBinary(name, rule_buffer) != ResultSuccess) {
|
||||
LOG_ERROR(Service_Time, "Failed to parse time zone binary!");
|
||||
}
|
||||
@@ -168,8 +424,6 @@ Result ServiceManager::SetupTimeZoneServiceCore(LocationName& name, RuleVersion&
|
||||
}
|
||||
|
||||
Result ServiceManager::SetupEphemeralNetworkSystemClockCore() {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
m_ephemeral_network_clock.SetContextWriter(m_ephemeral_system_context_writer);
|
||||
m_ephemeral_network_clock.SetInitialized();
|
||||
|
||||
@@ -177,41 +431,30 @@ Result ServiceManager::SetupEphemeralNetworkSystemClockCore() {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStandardLocalClockOperationEvent(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_local_operation.m_event->GetReadableEvent();
|
||||
Result ServiceManager::GetStandardLocalClockOperationEvent(Kernel::KEvent** out_event) {
|
||||
*out_event = m_local_operation.m_event;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStandardNetworkClockOperationEventForServiceManager(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_network_operation.m_event->GetReadableEvent();
|
||||
Kernel::KEvent** out_event) {
|
||||
*out_event = m_network_operation.m_event;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetEphemeralNetworkClockOperationEventForServiceManager(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_ephemeral_operation.m_event->GetReadableEvent();
|
||||
Kernel::KEvent** out_event) {
|
||||
*out_event = m_ephemeral_operation.m_event;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_user_system_clock.GetEvent().GetReadableEvent();
|
||||
Kernel::KEvent** out_event) {
|
||||
*out_event = &m_user_system_clock.GetEvent();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::SetStandardSteadyClockBaseTime(s64 base_time) {
|
||||
LOG_DEBUG(Service_Time, "called. base_time={}", base_time);
|
||||
|
||||
m_steady_clock.SetRtcOffset(base_time);
|
||||
auto time = m_steady_clock.GetRawTime();
|
||||
auto ticks = m_system.CoreTiming().GetClockTicks();
|
||||
@@ -225,63 +468,26 @@ Result ServiceManager::SetStandardSteadyClockBaseTime(s64 base_time) {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetClosestAlarmUpdatedEvent(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_event = &m_alarms.GetEvent().GetReadableEvent();
|
||||
Result ServiceManager::GetClosestAlarmUpdatedEvent(Kernel::KEvent** out_event) {
|
||||
*out_event = &m_alarms.GetEvent();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::CheckAndSignalAlarms() {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
m_alarms.CheckAndSignal();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ServiceManager::GetClosestAlarmInfo(Out<bool> out_is_valid, Out<AlarmInfo> out_info,
|
||||
Out<s64> out_time) {
|
||||
Result ServiceManager::GetClosestAlarmInfo(bool& out_is_valid, AlarmInfo& out_info, s64& out_time) {
|
||||
Alarm* alarm{nullptr};
|
||||
*out_is_valid = m_alarms.GetClosestAlarm(&alarm);
|
||||
if (*out_is_valid) {
|
||||
*out_info = {
|
||||
out_is_valid = m_alarms.GetClosestAlarm(&alarm);
|
||||
if (out_is_valid) {
|
||||
out_info = {
|
||||
.alert_time = alarm->GetAlertTime(),
|
||||
.priority = alarm->GetPriority(),
|
||||
};
|
||||
*out_time = m_alarms.GetRawTime();
|
||||
out_time = m_alarms.GetRawTime();
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. out_is_valid={} out_info.alert_time={} out_info.priority={}, out_time={}",
|
||||
*out_is_valid, out_info->alert_time, out_info->priority, *out_time);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void ServiceManager::CheckAndSetupServicesSAndP() {
|
||||
if (m_local_system_clock.IsInitialized() && m_user_system_clock.IsInitialized() &&
|
||||
m_network_system_clock.IsInitialized() && m_steady_clock.IsInitialized() &&
|
||||
m_time_zone.IsInitialized() && m_ephemeral_network_clock.IsInitialized()) {
|
||||
SetupSAndP();
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceManager::SetupSAndP() {
|
||||
if (!m_is_s_and_p_setup) {
|
||||
m_is_s_and_p_setup = true;
|
||||
m_server_manager.RegisterNamedService(
|
||||
"time:s", std::make_shared<StaticService>(
|
||||
m_system, StaticServiceSetupInfo{0, 0, 1, 0, 0, 0}, m_time, "time:s"));
|
||||
m_server_manager.RegisterNamedService("time:p",
|
||||
std::make_shared<IPowerStateRequestHandler>(
|
||||
m_system, m_time->m_power_state_request_manager));
|
||||
}
|
||||
}
|
||||
|
||||
Result ServiceManager::GetStaticService(OutInterface<StaticService> out_service,
|
||||
StaticServiceSetupInfo setup_info, const char* name) {
|
||||
*out_service = std::make_shared<StaticService>(m_system, setup_info, m_time, name);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/psc/time/manager.h"
|
||||
@@ -30,38 +29,55 @@ public:
|
||||
ServerManager* server_manager);
|
||||
~ServiceManager() override = default;
|
||||
|
||||
Result GetStaticServiceAsUser(OutInterface<StaticService> out_service);
|
||||
Result GetStaticServiceAsAdmin(OutInterface<StaticService> out_service);
|
||||
Result GetStaticServiceAsRepair(OutInterface<StaticService> out_service);
|
||||
Result GetStaticServiceAsServiceManager(OutInterface<StaticService> out_service);
|
||||
Result SetupStandardSteadyClockCore(bool is_rtc_reset_detected, Common::UUID& clock_source_id,
|
||||
s64 rtc_offset, s64 internal_offset, s64 test_offset);
|
||||
Result GetStaticServiceAsUser(std::shared_ptr<StaticService>& out_service);
|
||||
Result GetStaticServiceAsAdmin(std::shared_ptr<StaticService>& out_service);
|
||||
Result GetStaticServiceAsRepair(std::shared_ptr<StaticService>& out_service);
|
||||
Result GetStaticServiceAsServiceManager(std::shared_ptr<StaticService>& out_service);
|
||||
Result SetupStandardSteadyClockCore(Common::UUID& clock_source_id, s64 rtc_offset,
|
||||
s64 internal_offset, s64 test_offset,
|
||||
bool is_rtc_reset_detected);
|
||||
Result SetupStandardLocalSystemClockCore(SystemClockContext& context, s64 time);
|
||||
Result SetupStandardNetworkSystemClockCore(SystemClockContext& context, s64 accuracy);
|
||||
Result SetupStandardUserSystemClockCore(bool automatic_correction,
|
||||
SteadyClockTimePoint& time_point);
|
||||
Result SetupTimeZoneServiceCore(LocationName& name, RuleVersion& rule_version,
|
||||
u32 location_count, SteadyClockTimePoint& time_point,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> rule_buffer);
|
||||
Result SetupStandardUserSystemClockCore(SteadyClockTimePoint& time_point,
|
||||
bool automatic_correction);
|
||||
Result SetupTimeZoneServiceCore(LocationName& name, SteadyClockTimePoint& time_point,
|
||||
RuleVersion& rule_version, u32 location_count,
|
||||
std::span<const u8> rule_buffer);
|
||||
Result SetupEphemeralNetworkSystemClockCore();
|
||||
Result GetStandardLocalClockOperationEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetStandardNetworkClockOperationEventForServiceManager(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetEphemeralNetworkClockOperationEventForServiceManager(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetStandardLocalClockOperationEvent(Kernel::KEvent** out_event);
|
||||
Result GetStandardNetworkClockOperationEventForServiceManager(Kernel::KEvent** out_event);
|
||||
Result GetEphemeralNetworkClockOperationEventForServiceManager(Kernel::KEvent** out_event);
|
||||
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(Kernel::KEvent** out_event);
|
||||
Result SetStandardSteadyClockBaseTime(s64 base_time);
|
||||
Result GetClosestAlarmUpdatedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetClosestAlarmUpdatedEvent(Kernel::KEvent** out_event);
|
||||
Result CheckAndSignalAlarms();
|
||||
Result GetClosestAlarmInfo(Out<bool> out_is_valid, Out<AlarmInfo> out_info, Out<s64> out_time);
|
||||
Result GetClosestAlarmInfo(bool& out_is_valid, AlarmInfo& out_info, s64& out_time);
|
||||
|
||||
private:
|
||||
void CheckAndSetupServicesSAndP();
|
||||
void SetupSAndP();
|
||||
Result GetStaticService(OutInterface<StaticService> out_service,
|
||||
Result GetStaticService(std::shared_ptr<StaticService>& out_service,
|
||||
StaticServiceSetupInfo setup_info, const char* name);
|
||||
|
||||
void Handle_GetStaticServiceAsUser(HLERequestContext& ctx);
|
||||
void Handle_GetStaticServiceAsAdmin(HLERequestContext& ctx);
|
||||
void Handle_GetStaticServiceAsRepair(HLERequestContext& ctx);
|
||||
void Handle_GetStaticServiceAsServiceManager(HLERequestContext& ctx);
|
||||
void Handle_SetupStandardSteadyClockCore(HLERequestContext& ctx);
|
||||
void Handle_SetupStandardLocalSystemClockCore(HLERequestContext& ctx);
|
||||
void Handle_SetupStandardNetworkSystemClockCore(HLERequestContext& ctx);
|
||||
void Handle_SetupStandardUserSystemClockCore(HLERequestContext& ctx);
|
||||
void Handle_SetupTimeZoneServiceCore(HLERequestContext& ctx);
|
||||
void Handle_SetupEphemeralNetworkSystemClockCore(HLERequestContext& ctx);
|
||||
void Handle_GetStandardLocalClockOperationEvent(HLERequestContext& ctx);
|
||||
void Handle_GetStandardNetworkClockOperationEventForServiceManager(HLERequestContext& ctx);
|
||||
void Handle_GetEphemeralNetworkClockOperationEventForServiceManager(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedEvent(HLERequestContext& ctx);
|
||||
void Handle_SetStandardSteadyClockBaseTime(HLERequestContext& ctx);
|
||||
void Handle_GetClosestAlarmUpdatedEvent(HLERequestContext& ctx);
|
||||
void Handle_CheckAndSignalAlarms(HLERequestContext& ctx);
|
||||
void Handle_GetClosestAlarmInfo(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
std::shared_ptr<TimeManager> m_time;
|
||||
ServerManager& m_server_manager;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/psc/time/clocks/ephemeral_network_system_clock_core.h"
|
||||
#include "core/hle/service/psc/time/clocks/standard_local_system_clock_core.h"
|
||||
#include "core/hle/service/psc/time/clocks/standard_network_system_clock_core.h"
|
||||
@@ -41,122 +39,358 @@ StaticService::StaticService(Core::System& system_, StaticServiceSetupInfo setup
|
||||
m_time->m_shared_memory} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&StaticService::GetStandardUserSystemClock>, "GetStandardUserSystemClock"},
|
||||
{1, D<&StaticService::GetStandardNetworkSystemClock>, "GetStandardNetworkSystemClock"},
|
||||
{2, D<&StaticService::GetStandardSteadyClock>, "GetStandardSteadyClock"},
|
||||
{3, D<&StaticService::GetTimeZoneService>, "GetTimeZoneService"},
|
||||
{4, D<&StaticService::GetStandardLocalSystemClock>, "GetStandardLocalSystemClock"},
|
||||
{5, D<&StaticService::GetEphemeralNetworkSystemClock>, "GetEphemeralNetworkSystemClock"},
|
||||
{20, D<&StaticService::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
|
||||
{50, D<&StaticService::SetStandardSteadyClockInternalOffset>, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, D<&StaticService::GetStandardSteadyClockRtcValue>, "GetStandardSteadyClockRtcValue"},
|
||||
{100, D<&StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled>, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, D<&StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled>, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, D<&StaticService::GetStandardUserSystemClockInitialYear>, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, D<&StaticService::IsStandardNetworkSystemClockAccuracySufficient>, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, D<&StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime>, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, D<&StaticService::CalculateMonotonicSystemClockBaseTimePoint>, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, D<&StaticService::GetClockSnapshot>, "GetClockSnapshot"},
|
||||
{401, D<&StaticService::GetClockSnapshotFromSystemClockContext>, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, D<&StaticService::CalculateStandardUserSystemClockDifferenceByUser>, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, D<&StaticService::CalculateSpanBetween>, "CalculateSpanBetween"},
|
||||
{0, &StaticService::Handle_GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||
{1, &StaticService::Handle_GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
|
||||
{2, &StaticService::Handle_GetStandardSteadyClock, "GetStandardSteadyClock"},
|
||||
{3, &StaticService::Handle_GetTimeZoneService, "GetTimeZoneService"},
|
||||
{4, &StaticService::Handle_GetStandardLocalSystemClock, "GetStandardLocalSystemClock"},
|
||||
{5, &StaticService::Handle_GetEphemeralNetworkSystemClock, "GetEphemeralNetworkSystemClock"},
|
||||
{20, &StaticService::Handle_GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"},
|
||||
{50, &StaticService::Handle_SetStandardSteadyClockInternalOffset, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, &StaticService::Handle_GetStandardSteadyClockRtcValue, "GetStandardSteadyClockRtcValue"},
|
||||
{100, &StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, &StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, &StaticService::Handle_GetStandardUserSystemClockInitialYear, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, &StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, &StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, &StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, &StaticService::Handle_GetClockSnapshot, "GetClockSnapshot"},
|
||||
{401, &StaticService::Handle_GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, &StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, &StaticService::Handle_CalculateSpanBetween, "CalculateSpanBetween"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClock(OutInterface<SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
Result StaticService::GetClockSnapshotImpl(ClockSnapshot& out_snapshot,
|
||||
SystemClockContext& user_context,
|
||||
SystemClockContext& network_context, TimeType type) {
|
||||
out_snapshot.user_context = user_context;
|
||||
out_snapshot.network_context = network_context;
|
||||
|
||||
*out_service = std::make_shared<SystemClock>(m_system, m_user_system_clock,
|
||||
m_setup_info.can_write_user_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_TRY(
|
||||
m_time->m_standard_steady_clock.GetCurrentTimePoint(out_snapshot.steady_clock_time_point));
|
||||
|
||||
out_snapshot.is_automatic_correction_enabled = m_user_system_clock.GetAutomaticCorrection();
|
||||
|
||||
R_TRY(m_time_zone.GetLocationName(out_snapshot.location_name));
|
||||
|
||||
R_TRY(GetTimeFromTimePointAndContext(
|
||||
&out_snapshot.user_time, out_snapshot.steady_clock_time_point, out_snapshot.user_context));
|
||||
|
||||
R_TRY(m_time_zone.ToCalendarTimeWithMyRule(out_snapshot.user_calendar_time,
|
||||
out_snapshot.user_calendar_additional_time,
|
||||
out_snapshot.user_time));
|
||||
|
||||
if (GetTimeFromTimePointAndContext(&out_snapshot.network_time,
|
||||
out_snapshot.steady_clock_time_point,
|
||||
out_snapshot.network_context) != ResultSuccess) {
|
||||
out_snapshot.network_time = 0;
|
||||
}
|
||||
|
||||
R_TRY(m_time_zone.ToCalendarTimeWithMyRule(out_snapshot.network_calendar_time,
|
||||
out_snapshot.network_calendar_additional_time,
|
||||
out_snapshot.network_time));
|
||||
out_snapshot.type = type;
|
||||
out_snapshot.unk_CE = 0;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardNetworkSystemClock(OutInterface<SystemClock> out_service) {
|
||||
void StaticService::Handle_GetStandardUserSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service = std::make_shared<SystemClock>(m_system, m_network_system_clock,
|
||||
m_setup_info.can_write_network_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
std::shared_ptr<SystemClock> service{};
|
||||
auto res = GetStandardUserSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<SystemClock> service{};
|
||||
auto res = GetStandardNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<SteadyClock> service{};
|
||||
auto res = GetStandardSteadyClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetTimeZoneService(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<TimeZoneService> service{};
|
||||
auto res = GetTimeZoneService(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardLocalSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<SystemClock> service{};
|
||||
auto res = GetStandardLocalSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<SystemClock> service{};
|
||||
auto res = GetEphemeralNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KSharedMemory* shared_memory{};
|
||||
auto res = GetSharedMemoryNativeHandle(&shared_memory);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(shared_memory);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(m_setup_info.can_write_steady_clock ? ResultNotImplemented : ResultPermissionDenied);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultNotImplemented);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_enabled{};
|
||||
auto res = IsStandardUserSystemClockAutomaticCorrectionEnabled(is_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_enabled);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto automatic_correction{rp.Pop<bool>()};
|
||||
|
||||
auto res = SetStandardUserSystemClockAutomaticCorrectionEnabled(automatic_correction);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultNotImplemented);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_sufficient{};
|
||||
auto res = IsStandardNetworkSystemClockAccuracySufficient(is_sufficient);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_sufficient);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
SteadyClockTimePoint time_point{};
|
||||
auto res = GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(SteadyClockTimePoint) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<SystemClockContext>()};
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateMonotonicSystemClockBaseTimePoint(time, context);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push<s64>(time);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshot(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto type{rp.PopEnum<TimeType>()};
|
||||
|
||||
ClockSnapshot snapshot{};
|
||||
auto res = GetClockSnapshot(snapshot, type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto clock_type{rp.PopEnum<TimeType>()};
|
||||
[[maybe_unused]] auto alignment{rp.Pop<u32>()};
|
||||
auto user_context{rp.PopRaw<SystemClockContext>()};
|
||||
auto network_context{rp.PopRaw<SystemClockContext>()};
|
||||
|
||||
ClockSnapshot snapshot{};
|
||||
auto res =
|
||||
GetClockSnapshotFromSystemClockContext(snapshot, user_context, network_context, clock_type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
ClockSnapshot a{};
|
||||
ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(ClockSnapshot));
|
||||
|
||||
s64 difference{};
|
||||
auto res = CalculateStandardUserSystemClockDifferenceByUser(difference, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(difference);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateSpanBetween(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
ClockSnapshot a{};
|
||||
ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(ClockSnapshot));
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateSpanBetween(time, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(time);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result StaticService::GetStandardUserSystemClock(std::shared_ptr<SystemClock>& out_service) {
|
||||
out_service = std::make_shared<SystemClock>(m_system, m_user_system_clock,
|
||||
m_setup_info.can_write_user_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClock(OutInterface<SteadyClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
Result StaticService::GetStandardNetworkSystemClock(std::shared_ptr<SystemClock>& out_service) {
|
||||
out_service = std::make_shared<SystemClock>(m_system, m_network_system_clock,
|
||||
m_setup_info.can_write_network_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
*out_service =
|
||||
Result StaticService::GetStandardSteadyClock(std::shared_ptr<SteadyClock>& out_service) {
|
||||
out_service =
|
||||
std::make_shared<SteadyClock>(m_system, m_time, m_setup_info.can_write_steady_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetTimeZoneService(OutInterface<TimeZoneService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service =
|
||||
Result StaticService::GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service) {
|
||||
out_service =
|
||||
std::make_shared<TimeZoneService>(m_system, m_time->m_standard_steady_clock, m_time_zone,
|
||||
m_setup_info.can_write_timezone_device_location);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardLocalSystemClock(OutInterface<SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service = std::make_shared<SystemClock>(m_system, m_local_system_clock,
|
||||
m_setup_info.can_write_local_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
Result StaticService::GetStandardLocalSystemClock(std::shared_ptr<SystemClock>& out_service) {
|
||||
out_service = std::make_shared<SystemClock>(m_system, m_local_system_clock,
|
||||
m_setup_info.can_write_local_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetEphemeralNetworkSystemClock(OutInterface<SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service = std::make_shared<SystemClock>(m_system, m_ephemeral_network_clock,
|
||||
m_setup_info.can_write_network_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
Result StaticService::GetEphemeralNetworkSystemClock(std::shared_ptr<SystemClock>& out_service) {
|
||||
out_service = std::make_shared<SystemClock>(m_system, m_ephemeral_network_clock,
|
||||
m_setup_info.can_write_network_clock,
|
||||
m_setup_info.can_write_uninitialized_clock);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetSharedMemoryNativeHandle(
|
||||
OutCopyHandle<Kernel::KSharedMemory> out_shared_memory) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result StaticService::GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory) {
|
||||
*out_shared_memory = &m_shared_memory.GetKSharedMemory();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) {
|
||||
LOG_DEBUG(Service_Time, "called. This function is not implemented!");
|
||||
|
||||
R_UNLESS(m_setup_info.can_write_steady_clock, ResultPermissionDenied);
|
||||
|
||||
R_RETURN(ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value) {
|
||||
LOG_DEBUG(Service_Time, "called. This function is not implemented!");
|
||||
|
||||
R_RETURN(ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
Out<bool> out_is_enabled) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_enabled={}", *out_is_enabled); });
|
||||
|
||||
Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled(bool& out_is_enabled) {
|
||||
R_UNLESS(m_user_system_clock.IsInitialized(), ResultClockUninitialized);
|
||||
|
||||
*out_is_enabled = m_user_system_clock.GetAutomaticCorrection();
|
||||
|
||||
out_is_enabled = m_user_system_clock.GetAutomaticCorrection();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
bool automatic_correction) {
|
||||
LOG_DEBUG(Service_Time, "called. automatic_correction={}", automatic_correction);
|
||||
|
||||
R_UNLESS(m_user_system_clock.IsInitialized() && m_time->m_standard_steady_clock.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
R_UNLESS(m_setup_info.can_write_user_clock, ResultPermissionDenied);
|
||||
@@ -173,35 +407,22 @@ Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockInitialYear(Out<s32> out_year) {
|
||||
LOG_DEBUG(Service_Time, "called. This function is not implemented!");
|
||||
|
||||
R_RETURN(ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); });
|
||||
|
||||
*out_is_sufficient = m_network_system_clock.IsAccuracySufficient();
|
||||
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient) {
|
||||
out_is_sufficient = m_network_system_clock.IsAccuracySufficient();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Out<SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); });
|
||||
|
||||
SteadyClockTimePoint& out_time_point) {
|
||||
R_UNLESS(m_user_system_clock.IsInitialized(), ResultClockUninitialized);
|
||||
|
||||
m_user_system_clock.GetTimePoint(*out_time_point);
|
||||
m_user_system_clock.GetTimePoint(out_time_point);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(Out<s64> out_time,
|
||||
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(s64& out_time,
|
||||
SystemClockContext& context) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
|
||||
|
||||
R_UNLESS(m_time->m_standard_steady_clock.IsInitialized(), ResultClockUninitialized);
|
||||
|
||||
SteadyClockTimePoint time_point{};
|
||||
@@ -212,16 +433,12 @@ Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(Out<s64> out_ti
|
||||
auto one_second_ns{
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(1)).count()};
|
||||
auto ticks{m_system.CoreTiming().GetClockTicks()};
|
||||
auto current_time_ns{ConvertToTimeSpan(ticks).count()};
|
||||
*out_time = ((context.offset + time_point.time_point) - (current_time_ns / one_second_ns));
|
||||
|
||||
auto current_time{ConvertToTimeSpan(ticks).count()};
|
||||
out_time = ((context.offset + time_point.time_point) - (current_time / one_second_ns));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType type) {
|
||||
SCOPE_EXIT(
|
||||
{ LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); });
|
||||
|
||||
Result StaticService::GetClockSnapshot(ClockSnapshot& out_snapshot, TimeType type) {
|
||||
SystemClockContext user_context{};
|
||||
R_TRY(m_user_system_clock.GetContext(user_context));
|
||||
|
||||
@@ -231,101 +448,53 @@ Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType t
|
||||
R_RETURN(GetClockSnapshotImpl(out_snapshot, user_context, network_context, type));
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshotFromSystemClockContext(TimeType type,
|
||||
OutClockSnapshot out_snapshot,
|
||||
Result StaticService::GetClockSnapshotFromSystemClockContext(ClockSnapshot& out_snapshot,
|
||||
SystemClockContext& user_context,
|
||||
SystemClockContext& network_context) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. type={} user_context={} network_context={} out_snapshot={}", type,
|
||||
user_context, network_context, *out_snapshot);
|
||||
});
|
||||
|
||||
SystemClockContext& network_context,
|
||||
TimeType type) {
|
||||
R_RETURN(GetClockSnapshotImpl(out_snapshot, user_context, network_context, type));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
|
||||
InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. a={} b={} out_difference={}", *a, *b, *out_difference);
|
||||
});
|
||||
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(s64& out_time,
|
||||
ClockSnapshot& a,
|
||||
ClockSnapshot& b) {
|
||||
auto diff_s =
|
||||
std::chrono::seconds(b->user_context.offset) - std::chrono::seconds(a->user_context.offset);
|
||||
std::chrono::seconds(b.user_context.offset) - std::chrono::seconds(a.user_context.offset);
|
||||
|
||||
if (a->user_context == b->user_context ||
|
||||
!a->user_context.steady_time_point.IdMatches(b->user_context.steady_time_point)) {
|
||||
*out_difference = 0;
|
||||
if (a.user_context == b.user_context ||
|
||||
!a.user_context.steady_time_point.IdMatches(b.user_context.steady_time_point)) {
|
||||
out_time = 0;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
if (!a->is_automatic_correction_enabled || !b->is_automatic_correction_enabled) {
|
||||
*out_difference = std::chrono::duration_cast<std::chrono::nanoseconds>(diff_s).count();
|
||||
if (!a.is_automatic_correction_enabled || !b.is_automatic_correction_enabled) {
|
||||
out_time = std::chrono::duration_cast<std::chrono::nanoseconds>(diff_s).count();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
if (a->network_context.steady_time_point.IdMatches(a->steady_clock_time_point) ||
|
||||
b->network_context.steady_time_point.IdMatches(b->steady_clock_time_point)) {
|
||||
*out_difference = 0;
|
||||
if (a.network_context.steady_time_point.IdMatches(a.steady_clock_time_point) ||
|
||||
b.network_context.steady_time_point.IdMatches(b.steady_clock_time_point)) {
|
||||
out_time = 0;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
*out_difference = std::chrono::duration_cast<std::chrono::nanoseconds>(diff_s).count();
|
||||
out_time = std::chrono::duration_cast<std::chrono::nanoseconds>(diff_s).count();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); });
|
||||
|
||||
Result StaticService::CalculateSpanBetween(s64& out_time, ClockSnapshot& a, ClockSnapshot& b) {
|
||||
s64 time_s{};
|
||||
auto res =
|
||||
GetSpanBetweenTimePoints(&time_s, a->steady_clock_time_point, b->steady_clock_time_point);
|
||||
GetSpanBetweenTimePoints(&time_s, a.steady_clock_time_point, b.steady_clock_time_point);
|
||||
|
||||
if (res != ResultSuccess) {
|
||||
R_UNLESS(a->network_time != 0 && b->network_time != 0, ResultTimeNotFound);
|
||||
time_s = b->network_time - a->network_time;
|
||||
R_UNLESS(a.network_time != 0 && b.network_time != 0, ResultTimeNotFound);
|
||||
time_s = b.network_time - a.network_time;
|
||||
}
|
||||
|
||||
*out_time =
|
||||
out_time =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(time_s)).count();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshotImpl(OutClockSnapshot out_snapshot,
|
||||
SystemClockContext& user_context,
|
||||
SystemClockContext& network_context, TimeType type) {
|
||||
out_snapshot->user_context = user_context;
|
||||
out_snapshot->network_context = network_context;
|
||||
|
||||
R_TRY(
|
||||
m_time->m_standard_steady_clock.GetCurrentTimePoint(out_snapshot->steady_clock_time_point));
|
||||
|
||||
out_snapshot->is_automatic_correction_enabled = m_user_system_clock.GetAutomaticCorrection();
|
||||
|
||||
R_TRY(m_time_zone.GetLocationName(out_snapshot->location_name));
|
||||
|
||||
R_TRY(GetTimeFromTimePointAndContext(&out_snapshot->user_time,
|
||||
out_snapshot->steady_clock_time_point,
|
||||
out_snapshot->user_context));
|
||||
|
||||
R_TRY(m_time_zone.ToCalendarTimeWithMyRule(out_snapshot->user_calendar_time,
|
||||
out_snapshot->user_calendar_additional_time,
|
||||
out_snapshot->user_time));
|
||||
|
||||
if (GetTimeFromTimePointAndContext(&out_snapshot->network_time,
|
||||
out_snapshot->steady_clock_time_point,
|
||||
out_snapshot->network_context) != ResultSuccess) {
|
||||
out_snapshot->network_time = 0;
|
||||
}
|
||||
|
||||
R_TRY(m_time_zone.ToCalendarTimeWithMyRule(out_snapshot->network_calendar_time,
|
||||
out_snapshot->network_calendar_additional_time,
|
||||
out_snapshot->network_time));
|
||||
out_snapshot->type = type;
|
||||
out_snapshot->unk_CE = 0;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::PSC::Time
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
@@ -30,44 +29,58 @@ class EphemeralNetworkSystemClockCore;
|
||||
class SharedMemory;
|
||||
|
||||
class StaticService final : public ServiceFramework<StaticService> {
|
||||
using InClockSnapshot = InLargeData<ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
using OutClockSnapshot = OutLargeData<ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
|
||||
public:
|
||||
explicit StaticService(Core::System& system, StaticServiceSetupInfo setup_info,
|
||||
std::shared_ptr<TimeManager> time, const char* name);
|
||||
|
||||
~StaticService() override = default;
|
||||
|
||||
Result GetStandardUserSystemClock(OutInterface<SystemClock> out_service);
|
||||
Result GetStandardNetworkSystemClock(OutInterface<SystemClock> out_service);
|
||||
Result GetStandardSteadyClock(OutInterface<SteadyClock> out_service);
|
||||
Result GetTimeZoneService(OutInterface<TimeZoneService> out_service);
|
||||
Result GetStandardLocalSystemClock(OutInterface<SystemClock> out_service);
|
||||
Result GetEphemeralNetworkSystemClock(OutInterface<SystemClock> out_service);
|
||||
Result GetSharedMemoryNativeHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory);
|
||||
Result SetStandardSteadyClockInternalOffset(s64 offset_ns);
|
||||
Result GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(Out<bool> out_is_enabled);
|
||||
Result GetStandardUserSystemClock(std::shared_ptr<SystemClock>& out_service);
|
||||
Result GetStandardNetworkSystemClock(std::shared_ptr<SystemClock>& out_service);
|
||||
Result GetStandardSteadyClock(std::shared_ptr<SteadyClock>& out_service);
|
||||
Result GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service);
|
||||
Result GetStandardLocalSystemClock(std::shared_ptr<SystemClock>& out_service);
|
||||
Result GetEphemeralNetworkSystemClock(std::shared_ptr<SystemClock>& out_service);
|
||||
Result GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(bool& out_is_enabled);
|
||||
Result SetStandardUserSystemClockAutomaticCorrectionEnabled(bool automatic_correction);
|
||||
Result GetStandardUserSystemClockInitialYear(Out<s32> out_year);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient);
|
||||
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Out<SteadyClockTimePoint> out_time_point);
|
||||
Result CalculateMonotonicSystemClockBaseTimePoint(Out<s64> out_time,
|
||||
SystemClockContext& context);
|
||||
Result GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType type);
|
||||
Result GetClockSnapshotFromSystemClockContext(TimeType type, OutClockSnapshot out_snapshot,
|
||||
SteadyClockTimePoint& out_time_point);
|
||||
Result CalculateMonotonicSystemClockBaseTimePoint(s64& out_time, SystemClockContext& context);
|
||||
Result GetClockSnapshot(ClockSnapshot& out_snapshot, TimeType type);
|
||||
Result GetClockSnapshotFromSystemClockContext(ClockSnapshot& out_snapshot,
|
||||
SystemClockContext& user_context,
|
||||
SystemClockContext& network_context);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
|
||||
InClockSnapshot a, InClockSnapshot b);
|
||||
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
|
||||
SystemClockContext& network_context,
|
||||
TimeType type);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(s64& out_time, ClockSnapshot& a,
|
||||
ClockSnapshot& b);
|
||||
Result CalculateSpanBetween(s64& out_time, ClockSnapshot& a, ClockSnapshot& b);
|
||||
|
||||
private:
|
||||
Result GetClockSnapshotImpl(OutClockSnapshot out_snapshot, SystemClockContext& user_context,
|
||||
Result GetClockSnapshotImpl(ClockSnapshot& out_snapshot, SystemClockContext& user_context,
|
||||
SystemClockContext& network_context, TimeType type);
|
||||
|
||||
void Handle_GetStandardUserSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClock(HLERequestContext& ctx);
|
||||
void Handle_GetTimeZoneService(HLERequestContext& ctx);
|
||||
void Handle_GetStandardLocalSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx);
|
||||
void Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx);
|
||||
void Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx);
|
||||
void Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
|
||||
void Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshot(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx);
|
||||
void Handle_CalculateStandardUserSystemClockDifferenceByUser(HLERequestContext& ctx);
|
||||
void Handle_CalculateSpanBetween(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
StaticServiceSetupInfo m_setup_info;
|
||||
std::shared_ptr<TimeManager> m_time;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/psc/time/steady_clock.h"
|
||||
|
||||
namespace Service::PSC::Time {
|
||||
@@ -16,40 +14,114 @@ SteadyClock::SteadyClock(Core::System& system_, std::shared_ptr<TimeManager> man
|
||||
can_write_uninitialized_clock} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&SteadyClock::GetCurrentTimePoint>, "GetCurrentTimePoint"},
|
||||
{2, D<&SteadyClock::GetTestOffset>, "GetTestOffset"},
|
||||
{3, D<&SteadyClock::SetTestOffset>, "SetTestOffset"},
|
||||
{100, D<&SteadyClock::GetRtcValue>, "GetRtcValue"},
|
||||
{101, D<&SteadyClock::IsRtcResetDetected>, "IsRtcResetDetected"},
|
||||
{102, D<&SteadyClock::GetSetupResultValue>, "GetSetupResultValue"},
|
||||
{200, D<&SteadyClock::GetInternalOffset>, "GetInternalOffset"},
|
||||
{0, &SteadyClock::Handle_GetCurrentTimePoint, "GetCurrentTimePoint"},
|
||||
{2, &SteadyClock::Handle_GetTestOffset, "GetTestOffset"},
|
||||
{3, &SteadyClock::Handle_SetTestOffset, "SetTestOffset"},
|
||||
{100, &SteadyClock::Handle_GetRtcValue, "GetRtcValue"},
|
||||
{101, &SteadyClock::Handle_IsRtcResetDetected, "IsRtcResetDetected"},
|
||||
{102, &SteadyClock::Handle_GetSetupResultValue, "GetSetupResultValue"},
|
||||
{200, &SteadyClock::Handle_GetInternalOffset, "GetInternalOffset"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result SteadyClock::GetCurrentTimePoint(Out<SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); });
|
||||
void SteadyClock::Handle_GetCurrentTimePoint(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
SteadyClockTimePoint time_point{};
|
||||
auto res = GetCurrentTimePoint(time_point);
|
||||
|
||||
R_RETURN(m_clock_core.GetCurrentTimePoint(*out_time_point));
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(SteadyClockTimePoint) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
Result SteadyClock::GetTestOffset(Out<s64> out_test_offset) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_test_offset={}", *out_test_offset); });
|
||||
void SteadyClock::Handle_GetTestOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 test_offset{};
|
||||
auto res = GetTestOffset(test_offset);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(test_offset);
|
||||
}
|
||||
|
||||
void SteadyClock::Handle_SetTestOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto test_offset{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetTestOffset(test_offset);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void SteadyClock::Handle_GetRtcValue(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 rtc_value{};
|
||||
auto res = GetRtcValue(rtc_value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(rtc_value);
|
||||
}
|
||||
|
||||
void SteadyClock::Handle_IsRtcResetDetected(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool reset_detected{false};
|
||||
auto res = IsRtcResetDetected(reset_detected);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(reset_detected);
|
||||
}
|
||||
|
||||
void SteadyClock::Handle_GetSetupResultValue(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result result_value{ResultSuccess};
|
||||
auto res = GetSetupResultValue(result_value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(result_value);
|
||||
}
|
||||
|
||||
void SteadyClock::Handle_GetInternalOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 internal_offset{};
|
||||
auto res = GetInternalOffset(internal_offset);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(internal_offset);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result SteadyClock::GetCurrentTimePoint(SteadyClockTimePoint& out_time_point) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
*out_test_offset = m_clock_core.GetTestOffset();
|
||||
R_RETURN(m_clock_core.GetCurrentTimePoint(out_time_point));
|
||||
}
|
||||
|
||||
Result SteadyClock::GetTestOffset(s64& out_test_offset) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
out_test_offset = m_clock_core.GetTestOffset();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SteadyClock::SetTestOffset(s64 test_offset) {
|
||||
LOG_DEBUG(Service_Time, "called. test_offset={}", test_offset);
|
||||
|
||||
R_UNLESS(m_can_write_steady_clock, ResultPermissionDenied);
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
@@ -58,43 +130,34 @@ Result SteadyClock::SetTestOffset(s64 test_offset) {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SteadyClock::GetRtcValue(Out<s64> out_rtc_value) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); });
|
||||
|
||||
Result SteadyClock::GetRtcValue(s64& out_rtc_value) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
R_RETURN(m_clock_core.GetRtcValue(*out_rtc_value));
|
||||
R_RETURN(m_clock_core.GetRtcValue(out_rtc_value));
|
||||
}
|
||||
|
||||
Result SteadyClock::IsRtcResetDetected(Out<bool> out_is_detected) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_detected={}", *out_is_detected); });
|
||||
|
||||
Result SteadyClock::IsRtcResetDetected(bool& out_is_detected) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
*out_is_detected = m_clock_core.IsResetDetected();
|
||||
out_is_detected = m_clock_core.IsResetDetected();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SteadyClock::GetSetupResultValue(Out<Result> out_result) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_result=0x{:X}", out_result->raw); });
|
||||
|
||||
Result SteadyClock::GetSetupResultValue(Result& out_result) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
*out_result = m_clock_core.GetSetupResultValue();
|
||||
out_result = m_clock_core.GetSetupResultValue();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SteadyClock::GetInternalOffset(Out<s64> out_internal_offset) {
|
||||
SCOPE_EXIT(
|
||||
{ LOG_DEBUG(Service_Time, "called. out_internal_offset={}", *out_internal_offset); });
|
||||
|
||||
Result SteadyClock::GetInternalOffset(s64& out_internal_offset) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
*out_internal_offset = m_clock_core.GetInternalOffset();
|
||||
out_internal_offset = m_clock_core.GetInternalOffset();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/psc/time/manager.h"
|
||||
@@ -23,15 +22,23 @@ public:
|
||||
|
||||
~SteadyClock() override = default;
|
||||
|
||||
Result GetCurrentTimePoint(Out<SteadyClockTimePoint> out_time_point);
|
||||
Result GetTestOffset(Out<s64> out_test_offset);
|
||||
Result GetCurrentTimePoint(SteadyClockTimePoint& out_time_point);
|
||||
Result GetTestOffset(s64& out_test_offset);
|
||||
Result SetTestOffset(s64 test_offset);
|
||||
Result GetRtcValue(Out<s64> out_rtc_value);
|
||||
Result IsRtcResetDetected(Out<bool> out_is_detected);
|
||||
Result GetSetupResultValue(Out<Result> out_result);
|
||||
Result GetInternalOffset(Out<s64> out_internal_offset);
|
||||
Result GetRtcValue(s64& out_rtc_value);
|
||||
Result IsRtcResetDetected(bool& out_is_detected);
|
||||
Result GetSetupResultValue(Result& out_result);
|
||||
Result GetInternalOffset(s64& out_internal_offset);
|
||||
|
||||
private:
|
||||
void Handle_GetCurrentTimePoint(HLERequestContext& ctx);
|
||||
void Handle_GetTestOffset(HLERequestContext& ctx);
|
||||
void Handle_SetTestOffset(HLERequestContext& ctx);
|
||||
void Handle_GetRtcValue(HLERequestContext& ctx);
|
||||
void Handle_IsRtcResetDetected(HLERequestContext& ctx);
|
||||
void Handle_GetSetupResultValue(HLERequestContext& ctx);
|
||||
void Handle_GetInternalOffset(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
StandardSteadyClockCore& m_clock_core;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/psc/time/system_clock.h"
|
||||
|
||||
namespace Service::PSC::Time {
|
||||
@@ -15,28 +13,83 @@ SystemClock::SystemClock(Core::System& system_, SystemClockCore& clock_core, boo
|
||||
can_write_uninitialized_clock} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&SystemClock::GetCurrentTime>, "GetCurrentTime"},
|
||||
{1, D<&SystemClock::SetCurrentTime>, "SetCurrentTime"},
|
||||
{2, D<&SystemClock::GetSystemClockContext>, "GetSystemClockContext"},
|
||||
{3, D<&SystemClock::SetSystemClockContext>, "SetSystemClockContext"},
|
||||
{4, D<&SystemClock::GetOperationEventReadableHandle>, "GetOperationEventReadableHandle"},
|
||||
{0, &SystemClock::Handle_GetCurrentTime, "GetCurrentTime"},
|
||||
{1, &SystemClock::Handle_SetCurrentTime, "SetCurrentTime"},
|
||||
{2, &SystemClock::Handle_GetSystemClockContext, "GetSystemClockContext"},
|
||||
{3, &SystemClock::Handle_SetSystemClockContext, "SetSystemClockContext"},
|
||||
{4, &SystemClock::Handle_GetOperationEventReadableHandle, "GetOperationEventReadableHandle"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result SystemClock::GetCurrentTime(Out<s64> out_time) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time={}", *out_time); });
|
||||
void SystemClock::Handle_GetCurrentTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 time{};
|
||||
auto res = GetCurrentTime(time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push<s64>(time);
|
||||
}
|
||||
|
||||
void SystemClock::Handle_SetCurrentTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetCurrentTime(time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void SystemClock::Handle_GetSystemClockContext(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
SystemClockContext context{};
|
||||
auto res = GetSystemClockContext(context);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(SystemClockContext) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<SystemClockContext>(context);
|
||||
}
|
||||
|
||||
void SystemClock::Handle_SetSystemClockContext(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<SystemClockContext>()};
|
||||
|
||||
auto res = SetSystemClockContext(context);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void SystemClock::Handle_GetOperationEventReadableHandle(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetOperationEventReadableHandle(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event->GetReadableEvent());
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result SystemClock::GetCurrentTime(s64& out_time) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
R_RETURN(m_clock_core.GetCurrentTime(out_time.Get()));
|
||||
R_RETURN(m_clock_core.GetCurrentTime(&out_time));
|
||||
}
|
||||
|
||||
Result SystemClock::SetCurrentTime(s64 time) {
|
||||
LOG_DEBUG(Service_Time, "called. time={}", time);
|
||||
|
||||
R_UNLESS(m_can_write_clock, ResultPermissionDenied);
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
@@ -44,18 +97,14 @@ Result SystemClock::SetCurrentTime(s64 time) {
|
||||
R_RETURN(m_clock_core.SetCurrentTime(time));
|
||||
}
|
||||
|
||||
Result SystemClock::GetSystemClockContext(Out<SystemClockContext> out_context) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_context={}", *out_context); });
|
||||
|
||||
Result SystemClock::GetSystemClockContext(SystemClockContext& out_context) {
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
|
||||
R_RETURN(m_clock_core.GetContext(*out_context));
|
||||
R_RETURN(m_clock_core.GetContext(out_context));
|
||||
}
|
||||
|
||||
Result SystemClock::SetSystemClockContext(SystemClockContext& context) {
|
||||
LOG_DEBUG(Service_Time, "called. context={}", context);
|
||||
|
||||
R_UNLESS(m_can_write_clock, ResultPermissionDenied);
|
||||
R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(),
|
||||
ResultClockUninitialized);
|
||||
@@ -63,10 +112,7 @@ Result SystemClock::SetSystemClockContext(SystemClockContext& context) {
|
||||
R_RETURN(m_clock_core.SetContextAndWrite(context));
|
||||
}
|
||||
|
||||
Result SystemClock::GetOperationEventReadableHandle(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Result SystemClock::GetOperationEventReadableHandle(Kernel::KEvent** out_event) {
|
||||
if (!m_operation_event) {
|
||||
m_operation_event = std::make_unique<OperationEvent>(m_system);
|
||||
R_UNLESS(m_operation_event != nullptr, ResultFailed);
|
||||
@@ -74,7 +120,7 @@ Result SystemClock::GetOperationEventReadableHandle(
|
||||
m_clock_core.LinkOperationEvent(*m_operation_event);
|
||||
}
|
||||
|
||||
*out_event = &m_operation_event->m_event->GetReadableEvent();
|
||||
*out_event = m_operation_event->m_event;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/psc/time/manager.h"
|
||||
@@ -23,13 +22,19 @@ public:
|
||||
|
||||
~SystemClock() override = default;
|
||||
|
||||
Result GetCurrentTime(Out<s64> out_time);
|
||||
Result GetCurrentTime(s64& out_time);
|
||||
Result SetCurrentTime(s64 time);
|
||||
Result GetSystemClockContext(Out<SystemClockContext> out_context);
|
||||
Result GetSystemClockContext(SystemClockContext& out_context);
|
||||
Result SetSystemClockContext(SystemClockContext& context);
|
||||
Result GetOperationEventReadableHandle(OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result GetOperationEventReadableHandle(Kernel::KEvent** out_event);
|
||||
|
||||
private:
|
||||
void Handle_GetCurrentTime(HLERequestContext& ctx);
|
||||
void Handle_SetCurrentTime(HLERequestContext& ctx);
|
||||
void Handle_GetSystemClockContext(HLERequestContext& ctx);
|
||||
void Handle_SetSystemClockContext(HLERequestContext& ctx);
|
||||
void Handle_GetOperationEventReadableHandle(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
SystemClockCore& m_clock_core;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace Service::PSC::Time {
|
||||
namespace {
|
||||
constexpr Result ValidateRule(const Tz::Rule& rule) {
|
||||
constexpr Result ValidateRule(Tz::Rule& rule) {
|
||||
if (rule.typecnt > static_cast<s32>(Tz::TZ_MAX_TYPES) ||
|
||||
rule.timecnt > static_cast<s32>(Tz::TZ_MAX_TIMES) ||
|
||||
rule.charcnt > static_cast<s32>(Tz::TZ_MAX_CHARS)) {
|
||||
@@ -26,7 +26,7 @@ constexpr Result ValidateRule(const Tz::Rule& rule) {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
constexpr bool GetTimeZoneTime(s64& out_time, const Tz::Rule& rule, s64 time, s32 index,
|
||||
constexpr bool GetTimeZoneTime(s64& out_time, Tz::Rule& rule, s64 time, s32 index,
|
||||
s32 index_offset) {
|
||||
s32 found_idx{};
|
||||
s32 expected_index{index + index_offset};
|
||||
@@ -107,7 +107,7 @@ Result TimeZone::GetTimePoint(SteadyClockTimePoint& out_time_point) {
|
||||
|
||||
Result TimeZone::ToCalendarTime(CalendarTime& out_calendar_time,
|
||||
CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
const Tz::Rule& rule) {
|
||||
Tz::Rule& rule) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
R_RETURN(ToCalendarTimeImpl(out_calendar_time, out_additional_info, time, rule));
|
||||
}
|
||||
@@ -140,11 +140,11 @@ Result TimeZone::ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary)
|
||||
R_RETURN(ParseBinaryImpl(out_rule, binary));
|
||||
}
|
||||
|
||||
Result TimeZone::ToPosixTime(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
|
||||
const CalendarTime& calendar, const Tz::Rule& rule) {
|
||||
Result TimeZone::ToPosixTime(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
CalendarTime& calendar, Tz::Rule& rule) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
|
||||
auto res = ToPosixTimeImpl(out_count, out_times, out_times_max_count, calendar, rule, -1);
|
||||
auto res = ToPosixTimeImpl(out_count, out_times, out_times_count, calendar, rule, -1);
|
||||
|
||||
if (res != ResultSuccess) {
|
||||
if (res == ResultTimeZoneNotFound) {
|
||||
@@ -157,11 +157,11 @@ Result TimeZone::ToPosixTime(u32& out_count, std::span<s64> out_times, size_t ou
|
||||
R_RETURN(res);
|
||||
}
|
||||
|
||||
Result TimeZone::ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times,
|
||||
size_t out_times_max_count, const CalendarTime& calendar) {
|
||||
Result TimeZone::ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times,
|
||||
u32 out_times_count, CalendarTime& calendar) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
|
||||
auto res = ToPosixTimeImpl(out_count, out_times, out_times_max_count, calendar, m_my_rule, -1);
|
||||
auto res = ToPosixTimeImpl(out_count, out_times, out_times_count, calendar, m_my_rule, -1);
|
||||
|
||||
if (res != ResultSuccess) {
|
||||
if (res == ResultTimeZoneNotFound) {
|
||||
@@ -183,7 +183,7 @@ Result TimeZone::ParseBinaryImpl(Tz::Rule& out_rule, std::span<const u8> binary)
|
||||
|
||||
Result TimeZone::ToCalendarTimeImpl(CalendarTime& out_calendar_time,
|
||||
CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
const Tz::Rule& rule) {
|
||||
Tz::Rule& rule) {
|
||||
R_TRY(ValidateRule(rule));
|
||||
|
||||
Tz::CalendarTimeInternal calendar_internal{};
|
||||
@@ -212,23 +212,20 @@ Result TimeZone::ToCalendarTimeImpl(CalendarTime& out_calendar_time,
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times,
|
||||
size_t out_times_max_count, const CalendarTime& calendar,
|
||||
const Tz::Rule& rule, s32 is_dst) {
|
||||
Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
CalendarTime& calendar, Tz::Rule& rule, s32 is_dst) {
|
||||
R_TRY(ValidateRule(rule));
|
||||
|
||||
CalendarTime local_calendar{calendar};
|
||||
|
||||
local_calendar.month -= 1;
|
||||
local_calendar.year -= 1900;
|
||||
calendar.month -= 1;
|
||||
calendar.year -= 1900;
|
||||
|
||||
Tz::CalendarTimeInternal internal{
|
||||
.tm_sec = local_calendar.second,
|
||||
.tm_min = local_calendar.minute,
|
||||
.tm_hour = local_calendar.hour,
|
||||
.tm_mday = local_calendar.day,
|
||||
.tm_mon = local_calendar.month,
|
||||
.tm_year = local_calendar.year,
|
||||
.tm_sec = calendar.second,
|
||||
.tm_min = calendar.minute,
|
||||
.tm_hour = calendar.hour,
|
||||
.tm_mday = calendar.day,
|
||||
.tm_mon = calendar.month,
|
||||
.tm_year = calendar.year,
|
||||
.tm_wday = 0,
|
||||
.tm_yday = 0,
|
||||
.tm_isdst = is_dst,
|
||||
@@ -246,9 +243,9 @@ Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times,
|
||||
R_RETURN(ResultTimeZoneNotFound);
|
||||
}
|
||||
|
||||
if (internal.tm_sec != local_calendar.second || internal.tm_min != local_calendar.minute ||
|
||||
internal.tm_hour != local_calendar.hour || internal.tm_mday != local_calendar.day ||
|
||||
internal.tm_mon != local_calendar.month || internal.tm_year != local_calendar.year) {
|
||||
if (internal.tm_sec != calendar.second || internal.tm_min != calendar.minute ||
|
||||
internal.tm_hour != calendar.hour || internal.tm_mday != calendar.day ||
|
||||
internal.tm_mon != calendar.month || internal.tm_year != calendar.year) {
|
||||
R_RETURN(ResultTimeZoneNotFound);
|
||||
}
|
||||
|
||||
@@ -257,7 +254,7 @@ Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times,
|
||||
}
|
||||
|
||||
out_times[0] = time;
|
||||
if (out_times_max_count < 2) {
|
||||
if (out_times_count < 2) {
|
||||
out_count = 1;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -32,24 +32,23 @@ public:
|
||||
Result GetTimePoint(SteadyClockTimePoint& out_time_point);
|
||||
|
||||
Result ToCalendarTime(CalendarTime& out_calendar_time,
|
||||
CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
const Tz::Rule& rule);
|
||||
CalendarAdditionalInfo& out_additional_info, s64 time, Tz::Rule& rule);
|
||||
Result ToCalendarTimeWithMyRule(CalendarTime& calendar_time,
|
||||
CalendarAdditionalInfo& calendar_additional, s64 time);
|
||||
Result ParseBinary(LocationName& name, std::span<const u8> binary);
|
||||
Result ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary);
|
||||
Result ToPosixTime(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
|
||||
const CalendarTime& calendar, const Tz::Rule& rule);
|
||||
Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times,
|
||||
size_t out_times_max_count, const CalendarTime& calendar);
|
||||
Result ToPosixTime(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
CalendarTime& calendar, Tz::Rule& rule);
|
||||
Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
CalendarTime& calendar);
|
||||
|
||||
private:
|
||||
Result ParseBinaryImpl(Tz::Rule& out_rule, std::span<const u8> binary);
|
||||
Result ToCalendarTimeImpl(CalendarTime& out_calendar_time,
|
||||
CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
const Tz::Rule& rule);
|
||||
Result ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
|
||||
const CalendarTime& calendar, const Tz::Rule& rule, s32 is_dst);
|
||||
Tz::Rule& rule);
|
||||
Result ToPosixTimeImpl(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
CalendarTime& calendar, Tz::Rule& rule, s32 is_dst);
|
||||
|
||||
bool m_initialized{};
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user