Compare commits
62 Commits
android-19
...
android-19
Author | SHA1 | Date | |
---|---|---|---|
872825d4aa | |||
ed294d35d4 | |||
5f4efa456d | |||
e52e4871ff | |||
5e45e469d3 | |||
760e601a00 | |||
dfb63caefc | |||
0409886ebb | |||
803ccd7a57 | |||
3092855d5a | |||
72f803c366 | |||
c87b96435d | |||
116f76e4b6 | |||
915efa4236 | |||
4548e5ae1d | |||
46c2435235 | |||
2c29c2b8dd | |||
16abda59be | |||
90ab89a0b0 | |||
6531ad56a6 | |||
e8671ed04e | |||
2044ae6b3a | |||
c683ec2bcb | |||
2e4e33156e | |||
04f4eeaca2 | |||
2e4b32204c | |||
34db13486a | |||
c6c6bb4041 | |||
a2ffb419c9 | |||
0127cec371 | |||
db3a6075f5 | |||
8876a15227 | |||
954eb40237 | |||
d4acdac168 | |||
817c7c445d | |||
da714a362b | |||
7b3941e5d4 | |||
15d8a40529 | |||
cdeaca73c4 | |||
bee22540a1 | |||
76880b84f9 | |||
2f0b57ca13 | |||
f90a022d3a | |||
f2fed21c11 | |||
d940974789 | |||
f7a3c135e2 | |||
fcb0dff67c | |||
b5dac5f525 | |||
2a0d707ce1 | |||
aae9eea532 | |||
d3ba6b334b | |||
dac8c4ce4d | |||
9e974d4c7e | |||
6bfc3c530c | |||
93239f191a | |||
b17db2b462 | |||
9130366a58 | |||
ad0066a6b6 | |||
78c323c4eb | |||
51ad2d10de | |||
63b835f822 | |||
200b371d13 |
@ -32,3 +32,6 @@ if [ ! -z "$DIFF" ]; then
|
||||
echo "$DIFF"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd src/android
|
||||
./gradlew ktlintCheck
|
||||
|
@ -8,17 +8,7 @@ variables:
|
||||
DisplayVersion: $[counter(variables['DisplayPrefix'], 1)]
|
||||
|
||||
stages:
|
||||
- stage: format
|
||||
displayName: 'format'
|
||||
jobs:
|
||||
- job: format
|
||||
displayName: 'clang'
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
steps:
|
||||
- template: ./templates/format-check.yml
|
||||
- stage: build
|
||||
dependsOn: format
|
||||
displayName: 'build'
|
||||
jobs:
|
||||
- job: build
|
||||
@ -43,7 +33,6 @@ stages:
|
||||
cache: 'true'
|
||||
version: $(DisplayVersion)
|
||||
- stage: build_win
|
||||
dependsOn: format
|
||||
displayName: 'build-windows'
|
||||
jobs:
|
||||
- job: build
|
||||
|
8
.github/workflows/verify.yml
vendored
8
.github/workflows/verify.yml
vendored
@ -13,13 +13,15 @@ jobs:
|
||||
format:
|
||||
name: 'verify format'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: yuzuemu/build-environments:linux-clang-format
|
||||
options: -u 1001
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: 'Verify Formatting'
|
||||
run: bash -ex ./.ci/scripts/format/script.sh
|
||||
build:
|
||||
|
13
README.md
13
README.md
@ -1,10 +1,13 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [12579](https://github.com/yuzu-emu/yuzu-android//pull/12579) | [`66ae60a9e`](https://github.com/yuzu-emu/yuzu-android//pull/12579/files) | Core: Implement Device Mapping & GPU SMMU | [FernandoS27](https://github.com/FernandoS27/) | Yes |
|
||||
| [12605](https://github.com/yuzu-emu/yuzu-android//pull/12605) | [`0683fb5a7`](https://github.com/yuzu-emu/yuzu-android//pull/12605/files) | service: hid: Create abstracted pad structure | [german77](https://github.com/german77/) | Yes |
|
||||
| [12610](https://github.com/yuzu-emu/yuzu-android//pull/12610) | [`200b371d1`](https://github.com/yuzu-emu/yuzu-android//pull/12610/files) | server_manager: respond to session close correctly | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12612](https://github.com/yuzu-emu/yuzu-android//pull/12612) | [`aae9eea53`](https://github.com/yuzu-emu/yuzu-android//pull/12612/files) | fsp-srv: use program registry for SetCurrentProcess | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12642](https://github.com/yuzu-emu/yuzu-android//pull/12642) | [`d3ba6b334`](https://github.com/yuzu-emu/yuzu-android//pull/12642/files) | android: Refactor list adapters | [t895](https://github.com/t895/) | Yes |
|
||||
| [12579](https://github.com/yuzu-emu/yuzu-android//pull/12579) | [`93ef41f03`](https://github.com/yuzu-emu/yuzu-android//pull/12579/files) | Core: Implement Device Mapping & GPU SMMU | [FernandoS27](https://github.com/FernandoS27/) | Yes |
|
||||
| [12644](https://github.com/yuzu-emu/yuzu-android//pull/12644) | [`2044a289f`](https://github.com/yuzu-emu/yuzu-android//pull/12644/files) | shader_recompiler: fix Offset operand usage for non-OpImage*Gather | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12660](https://github.com/yuzu-emu/yuzu-android//pull/12660) | [`2cacb9d48`](https://github.com/yuzu-emu/yuzu-android//pull/12660/files) | service: hid: Fully implement abstract vibration | [german77](https://github.com/german77/) | Yes |
|
||||
| [12678](https://github.com/yuzu-emu/yuzu-android//pull/12678) | [`7f5adf898`](https://github.com/yuzu-emu/yuzu-android//pull/12678/files) | service: set: Implement stubbed functions | [german77](https://github.com/german77/) | Yes |
|
||||
| [12683](https://github.com/yuzu-emu/yuzu-android//pull/12683) | [`c661b9586`](https://github.com/yuzu-emu/yuzu-android//pull/12683/files) | service: nfc: Create backup when none exist | [german77](https://github.com/german77/) | Yes |
|
||||
| [12687](https://github.com/yuzu-emu/yuzu-android//pull/12687) | [`0b0e9ef18`](https://github.com/yuzu-emu/yuzu-android//pull/12687/files) | core: hid: Disable special features before disconnecting the controllers | [german77](https://github.com/german77/) | Yes |
|
||||
| [12688](https://github.com/yuzu-emu/yuzu-android//pull/12688) | [`e9eb017aa`](https://github.com/yuzu-emu/yuzu-android//pull/12688/files) | renderer_vulkan: recreate swapchain when frame size changes | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12701](https://github.com/yuzu-emu/yuzu-android//pull/12701) | [`e4bbb24dc`](https://github.com/yuzu-emu/yuzu-android//pull/12701/files) | vi: check layer state before opening or closing | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
@ -188,8 +188,15 @@ tasks.create<Delete>("ktlintReset") {
|
||||
delete(File(buildDir.path + File.separator + "intermediates/ktLint"))
|
||||
}
|
||||
|
||||
val showFormatHelp = {
|
||||
logger.lifecycle(
|
||||
"If this check fails, please try running \"gradlew ktlintFormat\" for automatic " +
|
||||
"codestyle fixes"
|
||||
)
|
||||
}
|
||||
tasks.getByPath("ktlintKotlinScriptCheck").doFirst { showFormatHelp.invoke() }
|
||||
tasks.getByPath("ktlintMainSourceSetCheck").doFirst { showFormatHelp.invoke() }
|
||||
tasks.getByPath("loadKtlintReporters").dependsOn("ktlintReset")
|
||||
tasks.getByPath("preBuild").dependsOn("ktlintCheck")
|
||||
|
||||
ktlint {
|
||||
version.set("0.47.1")
|
||||
@ -228,71 +235,33 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
|
||||
}
|
||||
|
||||
fun getGitVersion(): String {
|
||||
var versionName = "0.0"
|
||||
|
||||
try {
|
||||
versionName = ProcessBuilder("git", "describe", "--always", "--long")
|
||||
fun runGitCommand(command: List<String>): String {
|
||||
return try {
|
||||
ProcessBuilder(command)
|
||||
.directory(project.rootDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start().inputStream.bufferedReader().use { it.readText() }
|
||||
.trim()
|
||||
} catch (e: Exception) {
|
||||
logger.error("Cannot find git")
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
fun getGitVersion(): String {
|
||||
val versionName = if (System.getenv("GITHUB_ACTIONS") != null) {
|
||||
val gitTag = System.getenv("GIT_TAG_NAME") ?: ""
|
||||
gitTag
|
||||
} else {
|
||||
runGitCommand(listOf("git", "describe", "--always", "--long"))
|
||||
.replace(Regex("(-0)?-[^-]+$"), "")
|
||||
} catch (e: Exception) {
|
||||
logger.error("Cannot find git, defaulting to dummy version number")
|
||||
}
|
||||
|
||||
if (System.getenv("GITHUB_ACTIONS") != null) {
|
||||
val gitTag = System.getenv("GIT_TAG_NAME")
|
||||
versionName = gitTag ?: versionName
|
||||
}
|
||||
|
||||
return versionName
|
||||
return versionName.ifEmpty { "0.0" }
|
||||
}
|
||||
|
||||
fun getGitHash(): String {
|
||||
try {
|
||||
val processBuilder = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
|
||||
processBuilder.directory(project.rootDir)
|
||||
val process = processBuilder.start()
|
||||
val inputStream = process.inputStream
|
||||
val errorStream = process.errorStream
|
||||
process.waitFor()
|
||||
fun getGitHash(): String =
|
||||
runGitCommand(listOf("git", "rev-parse", "--short", "HEAD")).ifEmpty { "dummy-hash" }
|
||||
|
||||
return if (process.exitValue() == 0) {
|
||||
inputStream.bufferedReader()
|
||||
.use { it.readText().trim() } // return the value of gitHash
|
||||
} else {
|
||||
val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
|
||||
logger.error("Error running git command: $errorMessage")
|
||||
"dummy-hash" // return a dummy hash value in case of an error
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logger.error("$e: Cannot find git, defaulting to dummy build hash")
|
||||
return "dummy-hash" // return a dummy hash value in case of an error
|
||||
}
|
||||
}
|
||||
|
||||
fun getBranch(): String {
|
||||
try {
|
||||
val processBuilder = ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
processBuilder.directory(project.rootDir)
|
||||
val process = processBuilder.start()
|
||||
val inputStream = process.inputStream
|
||||
val errorStream = process.errorStream
|
||||
process.waitFor()
|
||||
|
||||
return if (process.exitValue() == 0) {
|
||||
inputStream.bufferedReader()
|
||||
.use { it.readText().trim() } // return the value of gitHash
|
||||
} else {
|
||||
val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
|
||||
logger.error("Error running git command: $errorMessage")
|
||||
"dummy-hash" // return a dummy hash value in case of an error
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logger.error("$e: Cannot find git, defaulting to dummy build hash")
|
||||
return "dummy-hash" // return a dummy hash value in case of an error
|
||||
}
|
||||
}
|
||||
fun getBranch(): String =
|
||||
runGitCommand(listOf("git", "rev-parse", "--abbrev-ref", "HEAD")).ifEmpty { "dummy-hash" }
|
||||
|
@ -49,7 +49,6 @@ import org.yuzu.yuzu_emu.utils.ForegroundService
|
||||
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
import org.yuzu.yuzu_emu.utils.NfcReader
|
||||
import org.yuzu.yuzu_emu.utils.ThemeHelper
|
||||
import java.text.NumberFormat
|
||||
@ -171,11 +170,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
stopMotionSensorListener()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
NativeConfig.saveGlobalConfig()
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
if (BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && !isInPictureInPictureMode) {
|
||||
|
@ -76,8 +76,8 @@ class AboutFragment : Fragment() {
|
||||
binding.root.findNavController().navigate(R.id.action_aboutFragment_to_licensesFragment)
|
||||
}
|
||||
|
||||
binding.textBuildHash.text = BuildConfig.GIT_HASH
|
||||
binding.buttonBuildHash.setOnClickListener {
|
||||
binding.textVersionName.text = BuildConfig.VERSION_NAME
|
||||
binding.textVersionName.setOnClickListener {
|
||||
val clipBoard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText(getString(R.string.build), BuildConfig.GIT_HASH)
|
||||
|
@ -554,6 +554,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
findItem(R.id.menu_touchscreen).isChecked = BooleanSetting.TOUCHSCREEN.getBoolean()
|
||||
}
|
||||
|
||||
popup.setOnDismissListener { NativeConfig.saveGlobalConfig() }
|
||||
popup.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_toggle_fps -> {
|
||||
@ -720,7 +721,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.emulation_control_adjust)
|
||||
.setView(adjustBinding.root)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
|
||||
NativeConfig.saveGlobalConfig()
|
||||
}
|
||||
.setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int ->
|
||||
setControlScale(50)
|
||||
setControlOpacity(100)
|
||||
|
@ -104,7 +104,7 @@ object FileUtil {
|
||||
|
||||
/**
|
||||
* Reference: https://stackoverflow.com/questions/42186820/documentfile-is-very-slow
|
||||
* This function will be faster than DoucmentFile.listFiles
|
||||
* This function will be faster than DocumentFile.listFiles
|
||||
* @param uri Directory uri.
|
||||
* @return CheapDocument lists.
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ void AndroidConfig::ReloadAllValues() {
|
||||
}
|
||||
|
||||
void AndroidConfig::SaveAllValues() {
|
||||
Save();
|
||||
SaveValues();
|
||||
SaveAndroidValues();
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsRuntimeModifiable(JNIEn
|
||||
jstring jkey) {
|
||||
auto setting = getSetting<std::string>(env, jkey);
|
||||
if (setting != nullptr) {
|
||||
return setting->RuntimeModfiable();
|
||||
return setting->RuntimeModifiable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@
|
||||
android:layout_marginHorizontal="20dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_build_hash"
|
||||
android:id="@+id/button_version_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -164,7 +164,7 @@
|
||||
android:textAlignment="viewStart" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text_build_hash"
|
||||
android:id="@+id/text_version_name"
|
||||
style="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -148,7 +148,7 @@
|
||||
android:layout_marginHorizontal="20dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_build_hash"
|
||||
android:id="@+id/button_version_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingVertical="16dp"
|
||||
@ -165,7 +165,7 @@
|
||||
android:text="@string/build" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text_build_hash"
|
||||
android:id="@+id/text_version_name"
|
||||
style="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -29,7 +29,7 @@
|
||||
<item>@string/language_dutch</item>
|
||||
<item>@string/language_english</item>
|
||||
<item>@string/language_french</item>
|
||||
<item>@string/langauge_german</item>
|
||||
<item>@string/language_german</item>
|
||||
<item>@string/language_italian</item>
|
||||
<item>@string/language_japanese</item>
|
||||
<item>@string/language_korean</item>
|
||||
@ -228,10 +228,10 @@
|
||||
<item>R</item>
|
||||
<item>ZL</item>
|
||||
<item>ZR</item>
|
||||
<item>@string/gamepad_left_stick</item>
|
||||
<item>@string/gamepad_right_stick</item>
|
||||
<item>L3</item>
|
||||
<item>R3</item>
|
||||
<item>@string/gamepad_left_stick</item>
|
||||
<item>@string/gamepad_right_stick</item>
|
||||
<item>@string/gamepad_d_pad</item>
|
||||
</string-array>
|
||||
|
||||
|
@ -410,7 +410,7 @@
|
||||
<string name="language_japanese" translatable="false">日本語</string>
|
||||
<string name="language_english" translatable="false">English</string>
|
||||
<string name="language_french" translatable="false">Français</string>
|
||||
<string name="langauge_german" translatable="false">Deutsch</string>
|
||||
<string name="language_german" translatable="false">Deutsch</string>
|
||||
<string name="language_italian" translatable="false">Italiano</string>
|
||||
<string name="language_spanish" translatable="false">Español</string>
|
||||
<string name="language_chinese" translatable="false">简体中文</string>
|
||||
|
@ -11,7 +11,7 @@ ADSP::ADSP(Core::System& system, Sink::Sink& sink) {
|
||||
opus_decoder = std::make_unique<OpusDecoder::OpusDecoder>(system);
|
||||
opus_decoder->Send(Direction::DSP, OpusDecoder::Message::Start);
|
||||
if (opus_decoder->Receive(Direction::Host) != OpusDecoder::Message::StartOK) {
|
||||
LOG_ERROR(Service_Audio, "OpusDeocder failed to initialize.");
|
||||
LOG_ERROR(Service_Audio, "OpusDecoder failed to initialize.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "core/guest_memory.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
|
||||
namespace AudioCore {
|
||||
|
||||
using namespace std::literals;
|
||||
@ -26,7 +28,7 @@ DeviceSession::~DeviceSession() {
|
||||
}
|
||||
|
||||
Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_format_,
|
||||
u16 channel_count_, size_t session_id_, u32 handle_,
|
||||
u16 channel_count_, size_t session_id_, Kernel::KProcess* handle_,
|
||||
u64 applet_resource_user_id_, Sink::StreamType type_) {
|
||||
if (stream) {
|
||||
Finalize();
|
||||
@ -37,6 +39,7 @@ Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_for
|
||||
channel_count = channel_count_;
|
||||
session_id = session_id_;
|
||||
handle = handle_;
|
||||
handle->Open();
|
||||
applet_resource_user_id = applet_resource_user_id_;
|
||||
|
||||
if (type == Sink::StreamType::In) {
|
||||
@ -55,6 +58,11 @@ void DeviceSession::Finalize() {
|
||||
sink->CloseStream(stream);
|
||||
stream = nullptr;
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
handle->Close();
|
||||
handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSession::Start() {
|
||||
@ -92,7 +100,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) {
|
||||
stream->AppendBuffer(new_buffer, tmp_samples);
|
||||
} else {
|
||||
Core::Memory::CpuGuestMemory<s16, Core::Memory::GuestMemoryFlags::UnsafeRead> samples(
|
||||
system.ApplicationMemory(), buffer.samples, buffer.size / sizeof(s16));
|
||||
handle->GetMemory(), buffer.samples, buffer.size / sizeof(s16));
|
||||
stream->AppendBuffer(new_buffer, samples);
|
||||
}
|
||||
}
|
||||
@ -101,7 +109,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) {
|
||||
void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const {
|
||||
if (type == Sink::StreamType::In) {
|
||||
auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))};
|
||||
system.ApplicationMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
handle->GetMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,10 @@ struct EventType;
|
||||
} // namespace Timing
|
||||
} // namespace Core
|
||||
|
||||
namespace Kernel {
|
||||
class KProcess;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace AudioCore {
|
||||
|
||||
namespace Sink {
|
||||
@ -44,13 +48,13 @@ public:
|
||||
* @param sample_format - Sample format for this device's output.
|
||||
* @param channel_count - Number of channels for this device (2 or 6).
|
||||
* @param session_id - This session's id.
|
||||
* @param handle - Handle for this device session (unused).
|
||||
* @param handle - Process handle for this device session.
|
||||
* @param applet_resource_user_id - Applet resource user id for this device session (unused).
|
||||
* @param type - Type of this stream (Render, In, Out).
|
||||
* @return Result code for this call.
|
||||
*/
|
||||
Result Initialize(std::string_view name, SampleFormat sample_format, u16 channel_count,
|
||||
size_t session_id, u32 handle, u64 applet_resource_user_id,
|
||||
size_t session_id, Kernel::KProcess* handle, u64 applet_resource_user_id,
|
||||
Sink::StreamType type);
|
||||
|
||||
/**
|
||||
@ -137,8 +141,8 @@ private:
|
||||
u16 channel_count{};
|
||||
/// Session id of this device session
|
||||
size_t session_id{};
|
||||
/// Handle of this device session
|
||||
u32 handle{};
|
||||
/// Process handle of device memory owner
|
||||
Kernel::KProcess* handle{};
|
||||
/// Applet resource user id of this device session
|
||||
u64 applet_resource_user_id{};
|
||||
/// Total number of samples played by this device session
|
||||
|
@ -57,7 +57,7 @@ Result System::IsConfigValid(const std::string_view device_name,
|
||||
}
|
||||
|
||||
Result System::Initialize(std::string device_name, const AudioInParameter& in_params,
|
||||
const u32 handle_, const u64 applet_resource_user_id_) {
|
||||
Kernel::KProcess* handle_, const u64 applet_resource_user_id_) {
|
||||
auto result{IsConfigValid(device_name, in_params)};
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
|
@ -19,7 +19,8 @@ class System;
|
||||
|
||||
namespace Kernel {
|
||||
class KEvent;
|
||||
}
|
||||
class KProcess;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace AudioCore::AudioIn {
|
||||
|
||||
@ -93,12 +94,12 @@ public:
|
||||
*
|
||||
* @param device_name - The name of the requested input device.
|
||||
* @param in_params - Input parameters, see AudioInParameter.
|
||||
* @param handle - Unused.
|
||||
* @param handle - Process handle.
|
||||
* @param applet_resource_user_id - Unused.
|
||||
* @return Result code.
|
||||
*/
|
||||
Result Initialize(std::string device_name, const AudioInParameter& in_params, u32 handle,
|
||||
u64 applet_resource_user_id);
|
||||
Result Initialize(std::string device_name, const AudioInParameter& in_params,
|
||||
Kernel::KProcess* handle, u64 applet_resource_user_id);
|
||||
|
||||
/**
|
||||
* Start this system.
|
||||
@ -244,8 +245,8 @@ public:
|
||||
private:
|
||||
/// Core system
|
||||
Core::System& system;
|
||||
/// (Unused)
|
||||
u32 handle{};
|
||||
/// Process handle
|
||||
Kernel::KProcess* handle{};
|
||||
/// (Unused)
|
||||
u64 applet_resource_user_id{};
|
||||
/// Buffer event, signalled when a buffer is ready
|
||||
|
@ -48,8 +48,8 @@ Result System::IsConfigValid(std::string_view device_name,
|
||||
return Service::Audio::ResultInvalidChannelCount;
|
||||
}
|
||||
|
||||
Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle_,
|
||||
u64 applet_resource_user_id_) {
|
||||
Result System::Initialize(std::string device_name, const AudioOutParameter& in_params,
|
||||
Kernel::KProcess* handle_, u64 applet_resource_user_id_) {
|
||||
auto result = IsConfigValid(device_name, in_params);
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
|
@ -19,7 +19,8 @@ class System;
|
||||
|
||||
namespace Kernel {
|
||||
class KEvent;
|
||||
}
|
||||
class KProcess;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace AudioCore::AudioOut {
|
||||
|
||||
@ -84,12 +85,12 @@ public:
|
||||
*
|
||||
* @param device_name - The name of the requested output device.
|
||||
* @param in_params - Input parameters, see AudioOutParameter.
|
||||
* @param handle - Unused.
|
||||
* @param handle - Process handle.
|
||||
* @param applet_resource_user_id - Unused.
|
||||
* @return Result code.
|
||||
*/
|
||||
Result Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle,
|
||||
u64 applet_resource_user_id);
|
||||
Result Initialize(std::string device_name, const AudioOutParameter& in_params,
|
||||
Kernel::KProcess* handle, u64 applet_resource_user_id);
|
||||
|
||||
/**
|
||||
* Start this system.
|
||||
@ -228,8 +229,8 @@ public:
|
||||
private:
|
||||
/// Core system
|
||||
Core::System& system;
|
||||
/// (Unused)
|
||||
u32 handle{};
|
||||
/// Process handle
|
||||
Kernel::KProcess* handle{};
|
||||
/// (Unused)
|
||||
u64 applet_resource_user_id{};
|
||||
/// Buffer event, signalled when a buffer is ready
|
||||
|
@ -41,7 +41,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info,
|
||||
const VoiceState& voice_state, const s8 channel) {
|
||||
if (voice_info.mix_id == UnusedMixId) {
|
||||
if (voice_info.splitter_id != UnusedSplitterId) {
|
||||
auto destination{splitter_context.GetDesintationData(voice_info.splitter_id, 0)};
|
||||
auto destination{splitter_context.GetDestinationData(voice_info.splitter_id, 0)};
|
||||
u32 dest_id{0};
|
||||
while (destination != nullptr) {
|
||||
if (destination->IsConfigured()) {
|
||||
@ -55,7 +55,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info,
|
||||
}
|
||||
}
|
||||
dest_id++;
|
||||
destination = splitter_context.GetDesintationData(voice_info.splitter_id, dest_id);
|
||||
destination = splitter_context.GetDestinationData(voice_info.splitter_id, dest_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -234,7 +234,7 @@ void CommandGenerator::GenerateVoiceCommand(VoiceInfo& voice_info) {
|
||||
if (voice_info.mix_id == UnusedMixId) {
|
||||
if (voice_info.splitter_id != UnusedSplitterId) {
|
||||
auto i{channel};
|
||||
auto destination{splitter_context.GetDesintationData(voice_info.splitter_id, i)};
|
||||
auto destination{splitter_context.GetDestinationData(voice_info.splitter_id, i)};
|
||||
while (destination != nullptr) {
|
||||
if (destination->IsConfigured()) {
|
||||
const auto mix_id{destination->GetMixId()};
|
||||
@ -249,7 +249,7 @@ void CommandGenerator::GenerateVoiceCommand(VoiceInfo& voice_info) {
|
||||
}
|
||||
}
|
||||
i += voice_info.channel_count;
|
||||
destination = splitter_context.GetDesintationData(voice_info.splitter_id, i);
|
||||
destination = splitter_context.GetDestinationData(voice_info.splitter_id, i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -591,7 +591,7 @@ void CommandGenerator::GenerateMixCommands(MixInfo& mix_info) {
|
||||
if (mix_info.dst_splitter_id != UnusedSplitterId) {
|
||||
s16 dest_id{0};
|
||||
auto destination{
|
||||
splitter_context.GetDesintationData(mix_info.dst_splitter_id, dest_id)};
|
||||
splitter_context.GetDestinationData(mix_info.dst_splitter_id, dest_id)};
|
||||
while (destination != nullptr) {
|
||||
if (destination->IsConfigured()) {
|
||||
auto splitter_mix_id{destination->GetMixId()};
|
||||
@ -612,7 +612,7 @@ void CommandGenerator::GenerateMixCommands(MixInfo& mix_info) {
|
||||
}
|
||||
dest_id++;
|
||||
destination =
|
||||
splitter_context.GetDesintationData(mix_info.dst_splitter_id, dest_id);
|
||||
splitter_context.GetDestinationData(mix_info.dst_splitter_id, dest_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ bool MixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const InParameter& in_pa
|
||||
|
||||
for (u32 i = 0; i < destination_count; i++) {
|
||||
auto destination{
|
||||
splitter_context.GetDesintationData(in_params.dest_splitter_id, i)};
|
||||
splitter_context.GetDestinationData(in_params.dest_splitter_id, i)};
|
||||
|
||||
if (destination) {
|
||||
const auto destination_id{destination->GetMixId()};
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace AudioCore::Renderer {
|
||||
|
||||
SplitterDestinationData* SplitterContext::GetDesintationData(const s32 splitter_id,
|
||||
SplitterDestinationData* SplitterContext::GetDestinationData(const s32 splitter_id,
|
||||
const s32 destination_id) {
|
||||
return splitter_infos[splitter_id].GetData(destination_id);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
* @param destination_id - Destination index within the splitter.
|
||||
* @return Pointer to the found destination. May be nullptr.
|
||||
*/
|
||||
SplitterDestinationData* GetDesintationData(s32 splitter_id, s32 destination_id);
|
||||
SplitterDestinationData* GetDestinationData(s32 splitter_id, s32 destination_id);
|
||||
|
||||
/**
|
||||
* Get a splitter from the given index.
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/page_table.h"
|
||||
#include "common/scope_exit.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
@ -11,29 +12,10 @@ PageTable::~PageTable() noexcept = default;
|
||||
|
||||
bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context,
|
||||
Common::ProcessAddress address) const {
|
||||
// Setup invalid defaults.
|
||||
out_entry->phys_addr = 0;
|
||||
out_entry->block_size = page_size;
|
||||
out_context->next_page = 0;
|
||||
out_context->next_offset = GetInteger(address);
|
||||
out_context->next_page = address / page_size;
|
||||
|
||||
// Validate that we can read the actual entry.
|
||||
const auto page = address / page_size;
|
||||
if (page >= backing_addr.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate that the entry is mapped.
|
||||
const auto phys_addr = backing_addr[page];
|
||||
if (phys_addr == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Populate the results.
|
||||
out_entry->phys_addr = phys_addr + GetInteger(address);
|
||||
out_context->next_page = page + 1;
|
||||
out_context->next_offset = GetInteger(address) + page_size;
|
||||
|
||||
return true;
|
||||
return this->ContinueTraversal(out_entry, out_context);
|
||||
}
|
||||
|
||||
bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const {
|
||||
@ -41,6 +23,12 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c
|
||||
out_entry->phys_addr = 0;
|
||||
out_entry->block_size = page_size;
|
||||
|
||||
// Regardless of whether the page was mapped, advance on exit.
|
||||
SCOPE_EXIT({
|
||||
context->next_page += 1;
|
||||
context->next_offset += page_size;
|
||||
});
|
||||
|
||||
// Validate that we can read the actual entry.
|
||||
const auto page = context->next_page;
|
||||
if (page >= backing_addr.size()) {
|
||||
@ -55,8 +43,6 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c
|
||||
|
||||
// Populate the results.
|
||||
out_entry->phys_addr = phys_addr + context->next_offset;
|
||||
context->next_page = page + 1;
|
||||
context->next_offset += page_size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ bool BasicSetting::Save() const {
|
||||
return save;
|
||||
}
|
||||
|
||||
bool BasicSetting::RuntimeModfiable() const {
|
||||
bool BasicSetting::RuntimeModifiable() const {
|
||||
return runtime_modifiable;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public:
|
||||
/**
|
||||
* @returns true if the current setting can be changed while the guest is running.
|
||||
*/
|
||||
[[nodiscard]] bool RuntimeModfiable() const;
|
||||
[[nodiscard]] bool RuntimeModifiable() const;
|
||||
|
||||
/**
|
||||
* @returns A unique number corresponding to the setting.
|
||||
|
@ -716,22 +716,23 @@ add_library(core STATIC
|
||||
hle/service/server_manager.h
|
||||
hle/service/service.cpp
|
||||
hle/service/service.h
|
||||
hle/service/set/appln_settings.cpp
|
||||
hle/service/set/appln_settings.h
|
||||
hle/service/set/device_settings.cpp
|
||||
hle/service/set/device_settings.h
|
||||
hle/service/set/setting_formats/appln_settings.cpp
|
||||
hle/service/set/setting_formats/appln_settings.h
|
||||
hle/service/set/setting_formats/device_settings.cpp
|
||||
hle/service/set/setting_formats/device_settings.h
|
||||
hle/service/set/setting_formats/system_settings.cpp
|
||||
hle/service/set/setting_formats/system_settings.h
|
||||
hle/service/set/setting_formats/private_settings.cpp
|
||||
hle/service/set/setting_formats/private_settings.h
|
||||
hle/service/set/factory_settings_server.cpp
|
||||
hle/service/set/factory_settings_server.h
|
||||
hle/service/set/firmware_debug_settings_server.cpp
|
||||
hle/service/set/firmware_debug_settings_server.h
|
||||
hle/service/set/private_settings.cpp
|
||||
hle/service/set/private_settings.h
|
||||
hle/service/set/settings.cpp
|
||||
hle/service/set/settings.h
|
||||
hle/service/set/settings_server.cpp
|
||||
hle/service/set/settings_server.h
|
||||
hle/service/set/system_settings.cpp
|
||||
hle/service/set/system_settings.h
|
||||
hle/service/set/settings_types.h
|
||||
hle/service/set/system_settings_server.cpp
|
||||
hle/service/set/system_settings_server.h
|
||||
hle/service/sm/sm.cpp
|
||||
|
@ -22,14 +22,10 @@ using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters;
|
||||
constexpr size_t MaxRelativeBranch = 128_MiB;
|
||||
constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32);
|
||||
|
||||
Patcher::Patcher() : c(m_patch_instructions) {}
|
||||
|
||||
Patcher::~Patcher() = default;
|
||||
|
||||
void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
const Kernel::CodeSet::Segment& code) {
|
||||
// Branch to the first instruction of the module.
|
||||
this->BranchToModule(0);
|
||||
Patcher::Patcher() : c(m_patch_instructions) {
|
||||
// The first word of the patch section is always a branch to the first instruction of the
|
||||
// module.
|
||||
c.dw(0);
|
||||
|
||||
// Write save context helper function.
|
||||
c.l(m_save_context);
|
||||
@ -38,6 +34,25 @@ void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
// Write load context helper function.
|
||||
c.l(m_load_context);
|
||||
WriteLoadContext();
|
||||
}
|
||||
|
||||
Patcher::~Patcher() = default;
|
||||
|
||||
bool Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
const Kernel::CodeSet::Segment& code) {
|
||||
// If we have patched modules but cannot reach the new module, then it needs its own patcher.
|
||||
const size_t image_size = program_image.size();
|
||||
if (total_program_size + image_size > MaxRelativeBranch && total_program_size > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add a new module patch to our list
|
||||
modules.emplace_back();
|
||||
curr_patch = &modules.back();
|
||||
|
||||
// The first word of the patch section is always a branch to the first instruction of the
|
||||
// module.
|
||||
curr_patch->m_branch_to_module_relocations.push_back({0, 0});
|
||||
|
||||
// Retrieve text segment data.
|
||||
const auto text = std::span{program_image}.subspan(code.offset, code.size);
|
||||
@ -94,16 +109,17 @@ void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
}
|
||||
|
||||
if (auto exclusive = Exclusive{inst}; exclusive.Verify()) {
|
||||
m_exclusives.push_back(i);
|
||||
curr_patch->m_exclusives.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine patching mode for the final relocation step
|
||||
const size_t image_size = program_image.size();
|
||||
total_program_size += image_size;
|
||||
this->mode = image_size > MaxRelativeBranch ? PatchMode::PreText : PatchMode::PostData;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
bool Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
const Kernel::CodeSet::Segment& code,
|
||||
Kernel::PhysicalMemory& program_image,
|
||||
EntryTrampolines* out_trampolines) {
|
||||
@ -120,7 +136,7 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
if (mode == PatchMode::PreText) {
|
||||
rc.B(rel.patch_offset - patch_size - rel.module_offset);
|
||||
} else {
|
||||
rc.B(image_size - rel.module_offset + rel.patch_offset);
|
||||
rc.B(total_program_size - rel.module_offset + rel.patch_offset);
|
||||
}
|
||||
};
|
||||
|
||||
@ -129,7 +145,7 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
if (mode == PatchMode::PreText) {
|
||||
rc.B(patch_size - rel.patch_offset + rel.module_offset);
|
||||
} else {
|
||||
rc.B(rel.module_offset - image_size - rel.patch_offset);
|
||||
rc.B(rel.module_offset - total_program_size - rel.patch_offset);
|
||||
}
|
||||
};
|
||||
|
||||
@ -137,7 +153,7 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
if (mode == PatchMode::PreText) {
|
||||
return GetInteger(load_base) + patch_offset;
|
||||
} else {
|
||||
return GetInteger(load_base) + image_size + patch_offset;
|
||||
return GetInteger(load_base) + total_program_size + patch_offset;
|
||||
}
|
||||
};
|
||||
|
||||
@ -150,39 +166,50 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
};
|
||||
|
||||
// We are now ready to relocate!
|
||||
for (const Relocation& rel : m_branch_to_patch_relocations) {
|
||||
auto& patch = modules[m_relocate_module_index++];
|
||||
for (const Relocation& rel : patch.m_branch_to_patch_relocations) {
|
||||
ApplyBranchToPatchRelocation(text_words.data() + rel.module_offset / sizeof(u32), rel);
|
||||
}
|
||||
for (const Relocation& rel : m_branch_to_module_relocations) {
|
||||
for (const Relocation& rel : patch.m_branch_to_module_relocations) {
|
||||
ApplyBranchToModuleRelocation(m_patch_instructions.data() + rel.patch_offset / sizeof(u32),
|
||||
rel);
|
||||
}
|
||||
|
||||
// Rewrite PC constants and record post trampolines
|
||||
for (const Relocation& rel : m_write_module_pc_relocations) {
|
||||
for (const Relocation& rel : patch.m_write_module_pc_relocations) {
|
||||
oaknut::CodeGenerator rc{m_patch_instructions.data() + rel.patch_offset / sizeof(u32)};
|
||||
rc.dx(RebasePc(rel.module_offset));
|
||||
}
|
||||
for (const Trampoline& rel : m_trampolines) {
|
||||
for (const Trampoline& rel : patch.m_trampolines) {
|
||||
out_trampolines->insert({RebasePc(rel.module_offset), RebasePatch(rel.patch_offset)});
|
||||
}
|
||||
|
||||
// Cortex-A57 seems to treat all exclusives as ordered, but newer processors do not.
|
||||
// Convert to ordered to preserve this assumption.
|
||||
for (const ModuleTextAddress i : m_exclusives) {
|
||||
for (const ModuleTextAddress i : patch.m_exclusives) {
|
||||
auto exclusive = Exclusive{text_words[i]};
|
||||
text_words[i] = exclusive.AsOrdered();
|
||||
}
|
||||
|
||||
// Copy to program image
|
||||
if (this->mode == PatchMode::PreText) {
|
||||
std::memcpy(program_image.data(), m_patch_instructions.data(),
|
||||
m_patch_instructions.size() * sizeof(u32));
|
||||
} else {
|
||||
program_image.resize(image_size + patch_size);
|
||||
std::memcpy(program_image.data() + image_size, m_patch_instructions.data(),
|
||||
m_patch_instructions.size() * sizeof(u32));
|
||||
// Remove the patched module size from the total. This is done so total_program_size
|
||||
// always represents the distance from the currently patched module to the patch section.
|
||||
total_program_size -= image_size;
|
||||
|
||||
// Only copy to the program image of the last module
|
||||
if (m_relocate_module_index == modules.size()) {
|
||||
if (this->mode == PatchMode::PreText) {
|
||||
ASSERT(image_size == total_program_size);
|
||||
std::memcpy(program_image.data(), m_patch_instructions.data(),
|
||||
m_patch_instructions.size() * sizeof(u32));
|
||||
} else {
|
||||
program_image.resize(image_size + patch_size);
|
||||
std::memcpy(program_image.data() + image_size, m_patch_instructions.data(),
|
||||
m_patch_instructions.size() * sizeof(u32));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t Patcher::GetSectionSize() const noexcept {
|
||||
@ -322,7 +349,7 @@ void Patcher::WriteSvcTrampoline(ModuleDestLabel module_dest, u32 svc_id) {
|
||||
|
||||
// Write the post-SVC trampoline address, which will jump back to the guest after restoring its
|
||||
// state.
|
||||
m_trampolines.push_back({c.offset(), module_dest});
|
||||
curr_patch->m_trampolines.push_back({c.offset(), module_dest});
|
||||
|
||||
// Host called this location. Save the return address so we can
|
||||
// unwind the stack properly when jumping back.
|
||||
|
@ -31,9 +31,9 @@ public:
|
||||
explicit Patcher();
|
||||
~Patcher();
|
||||
|
||||
void PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
bool PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
const Kernel::CodeSet::Segment& code);
|
||||
void RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code,
|
||||
bool RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code,
|
||||
Kernel::PhysicalMemory& program_image, EntryTrampolines* out_trampolines);
|
||||
size_t GetSectionSize() const noexcept;
|
||||
|
||||
@ -61,16 +61,16 @@ private:
|
||||
|
||||
private:
|
||||
void BranchToPatch(uintptr_t module_dest) {
|
||||
m_branch_to_patch_relocations.push_back({c.offset(), module_dest});
|
||||
curr_patch->m_branch_to_patch_relocations.push_back({c.offset(), module_dest});
|
||||
}
|
||||
|
||||
void BranchToModule(uintptr_t module_dest) {
|
||||
m_branch_to_module_relocations.push_back({c.offset(), module_dest});
|
||||
curr_patch->m_branch_to_module_relocations.push_back({c.offset(), module_dest});
|
||||
c.dw(0);
|
||||
}
|
||||
|
||||
void WriteModulePc(uintptr_t module_dest) {
|
||||
m_write_module_pc_relocations.push_back({c.offset(), module_dest});
|
||||
curr_patch->m_write_module_pc_relocations.push_back({c.offset(), module_dest});
|
||||
c.dx(0);
|
||||
}
|
||||
|
||||
@ -84,15 +84,22 @@ private:
|
||||
uintptr_t module_offset; ///< Offset in bytes from the start of the text section.
|
||||
};
|
||||
|
||||
struct ModulePatch {
|
||||
std::vector<Trampoline> m_trampolines;
|
||||
std::vector<Relocation> m_branch_to_patch_relocations{};
|
||||
std::vector<Relocation> m_branch_to_module_relocations{};
|
||||
std::vector<Relocation> m_write_module_pc_relocations{};
|
||||
std::vector<ModuleTextAddress> m_exclusives{};
|
||||
};
|
||||
|
||||
oaknut::VectorCodeGenerator c;
|
||||
std::vector<Trampoline> m_trampolines;
|
||||
std::vector<Relocation> m_branch_to_patch_relocations{};
|
||||
std::vector<Relocation> m_branch_to_module_relocations{};
|
||||
std::vector<Relocation> m_write_module_pc_relocations{};
|
||||
std::vector<ModuleTextAddress> m_exclusives{};
|
||||
oaknut::Label m_save_context{};
|
||||
oaknut::Label m_load_context{};
|
||||
PatchMode mode{PatchMode::None};
|
||||
size_t total_program_size{};
|
||||
size_t m_relocate_module_index{};
|
||||
std::vector<ModulePatch> modules;
|
||||
ModulePatch* curr_patch;
|
||||
};
|
||||
|
||||
} // namespace Core::NCE
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
|
||||
Kernel::KThread* GetActiveThread() override {
|
||||
return state->active_thread;
|
||||
return state->active_thread.GetPointerUnsafe();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -147,11 +147,14 @@ private:
|
||||
|
||||
std::scoped_lock lk{connection_lock};
|
||||
|
||||
// Find the process we are going to debug.
|
||||
SetDebugProcess();
|
||||
|
||||
// Ensure everything is stopped.
|
||||
PauseEmulation();
|
||||
|
||||
// Set up the new frontend.
|
||||
frontend = std::make_unique<GDBStub>(*this, system);
|
||||
frontend = std::make_unique<GDBStub>(*this, system, debug_process.GetPointerUnsafe());
|
||||
|
||||
// Set the new state. This will tear down any existing state.
|
||||
state = ConnectionState{
|
||||
@ -194,15 +197,20 @@ private:
|
||||
UpdateActiveThread();
|
||||
|
||||
if (state->info.type == SignalType::Watchpoint) {
|
||||
frontend->Watchpoint(state->active_thread, *state->info.watchpoint);
|
||||
frontend->Watchpoint(std::addressof(*state->active_thread),
|
||||
*state->info.watchpoint);
|
||||
} else {
|
||||
frontend->Stopped(state->active_thread);
|
||||
frontend->Stopped(std::addressof(*state->active_thread));
|
||||
}
|
||||
|
||||
break;
|
||||
case SignalType::ShuttingDown:
|
||||
frontend->ShuttingDown();
|
||||
|
||||
// Release members.
|
||||
state->active_thread.Reset(nullptr);
|
||||
debug_process.Reset(nullptr);
|
||||
|
||||
// Wait for emulation to shut down gracefully now.
|
||||
state->signal_pipe.close();
|
||||
state->client_socket.shutdown(boost::asio::socket_base::shutdown_both);
|
||||
@ -222,7 +230,7 @@ private:
|
||||
stopped = true;
|
||||
PauseEmulation();
|
||||
UpdateActiveThread();
|
||||
frontend->Stopped(state->active_thread);
|
||||
frontend->Stopped(state->active_thread.GetPointerUnsafe());
|
||||
break;
|
||||
}
|
||||
case DebuggerAction::Continue:
|
||||
@ -232,7 +240,7 @@ private:
|
||||
MarkResumed([&] {
|
||||
state->active_thread->SetStepState(Kernel::StepState::StepPending);
|
||||
state->active_thread->Resume(Kernel::SuspendType::Debug);
|
||||
ResumeEmulation(state->active_thread);
|
||||
ResumeEmulation(state->active_thread.GetPointerUnsafe());
|
||||
});
|
||||
break;
|
||||
case DebuggerAction::StepThreadLocked: {
|
||||
@ -255,6 +263,7 @@ private:
|
||||
}
|
||||
|
||||
void PauseEmulation() {
|
||||
Kernel::KScopedLightLock ll{debug_process->GetListLock()};
|
||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||
|
||||
// Put all threads to sleep on next scheduler round.
|
||||
@ -264,6 +273,9 @@ private:
|
||||
}
|
||||
|
||||
void ResumeEmulation(Kernel::KThread* except = nullptr) {
|
||||
Kernel::KScopedLightLock ll{debug_process->GetListLock()};
|
||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||
|
||||
// Wake up all threads.
|
||||
for (auto& thread : ThreadList()) {
|
||||
if (std::addressof(thread) == except) {
|
||||
@ -277,15 +289,16 @@ private:
|
||||
|
||||
template <typename Callback>
|
||||
void MarkResumed(Callback&& cb) {
|
||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||
stopped = false;
|
||||
cb();
|
||||
}
|
||||
|
||||
void UpdateActiveThread() {
|
||||
Kernel::KScopedLightLock ll{debug_process->GetListLock()};
|
||||
|
||||
auto& threads{ThreadList()};
|
||||
for (auto& thread : threads) {
|
||||
if (std::addressof(thread) == state->active_thread) {
|
||||
if (std::addressof(thread) == state->active_thread.GetPointerUnsafe()) {
|
||||
// Thread is still alive, no need to update.
|
||||
return;
|
||||
}
|
||||
@ -293,12 +306,18 @@ private:
|
||||
state->active_thread = std::addressof(threads.front());
|
||||
}
|
||||
|
||||
private:
|
||||
void SetDebugProcess() {
|
||||
debug_process = std::move(system.Kernel().GetProcessList().back());
|
||||
}
|
||||
|
||||
Kernel::KProcess::ThreadList& ThreadList() {
|
||||
return system.ApplicationProcess()->GetThreadList();
|
||||
return debug_process->GetThreadList();
|
||||
}
|
||||
|
||||
private:
|
||||
System& system;
|
||||
Kernel::KScopedAutoObject<Kernel::KProcess> debug_process;
|
||||
std::unique_ptr<DebuggerFrontend> frontend;
|
||||
|
||||
boost::asio::io_context io_context;
|
||||
@ -310,7 +329,7 @@ private:
|
||||
boost::process::async_pipe signal_pipe;
|
||||
|
||||
SignalInfo info;
|
||||
Kernel::KThread* active_thread;
|
||||
Kernel::KScopedAutoObject<Kernel::KThread> active_thread;
|
||||
std::array<u8, 4096> client_data;
|
||||
bool pipe_data;
|
||||
};
|
||||
|
@ -108,9 +108,9 @@ static std::string EscapeXML(std::string_view data) {
|
||||
return escaped;
|
||||
}
|
||||
|
||||
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
|
||||
: DebuggerFrontend(backend_), system{system_} {
|
||||
if (system.ApplicationProcess()->Is64Bit()) {
|
||||
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_, Kernel::KProcess* debug_process_)
|
||||
: DebuggerFrontend(backend_), system{system_}, debug_process{debug_process_} {
|
||||
if (GetProcess()->Is64Bit()) {
|
||||
arch = std::make_unique<GDBStubA64>();
|
||||
} else {
|
||||
arch = std::make_unique<GDBStubA32>();
|
||||
@ -276,7 +276,7 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction
|
||||
const size_t size{static_cast<size_t>(strtoll(command.data() + sep, nullptr, 16))};
|
||||
|
||||
std::vector<u8> mem(size);
|
||||
if (system.ApplicationMemory().ReadBlock(addr, mem.data(), size)) {
|
||||
if (GetMemory().ReadBlock(addr, mem.data(), size)) {
|
||||
// Restore any bytes belonging to replaced instructions.
|
||||
auto it = replaced_instructions.lower_bound(addr);
|
||||
for (; it != replaced_instructions.end() && it->first < addr + size; it++) {
|
||||
@ -310,8 +310,8 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction
|
||||
const auto mem_substr{std::string_view(command).substr(mem_sep)};
|
||||
const auto mem{Common::HexStringToVector(mem_substr, false)};
|
||||
|
||||
if (system.ApplicationMemory().WriteBlock(addr, mem.data(), size)) {
|
||||
Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, size);
|
||||
if (GetMemory().WriteBlock(addr, mem.data(), size)) {
|
||||
Core::InvalidateInstructionCacheRange(GetProcess(), addr, size);
|
||||
SendReply(GDB_STUB_REPLY_OK);
|
||||
} else {
|
||||
SendReply(GDB_STUB_REPLY_ERR);
|
||||
@ -353,7 +353,7 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) {
|
||||
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))};
|
||||
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))};
|
||||
|
||||
if (!system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) {
|
||||
if (!GetMemory().IsValidVirtualAddressRange(addr, size)) {
|
||||
SendReply(GDB_STUB_REPLY_ERR);
|
||||
return;
|
||||
}
|
||||
@ -362,22 +362,20 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) {
|
||||
|
||||
switch (type) {
|
||||
case BreakpointType::Software:
|
||||
replaced_instructions[addr] = system.ApplicationMemory().Read32(addr);
|
||||
system.ApplicationMemory().Write32(addr, arch->BreakpointInstruction());
|
||||
Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, sizeof(u32));
|
||||
replaced_instructions[addr] = GetMemory().Read32(addr);
|
||||
GetMemory().Write32(addr, arch->BreakpointInstruction());
|
||||
Core::InvalidateInstructionCacheRange(GetProcess(), addr, sizeof(u32));
|
||||
success = true;
|
||||
break;
|
||||
case BreakpointType::WriteWatch:
|
||||
success = system.ApplicationProcess()->InsertWatchpoint(addr, size,
|
||||
Kernel::DebugWatchpointType::Write);
|
||||
success = GetProcess()->InsertWatchpoint(addr, size, Kernel::DebugWatchpointType::Write);
|
||||
break;
|
||||
case BreakpointType::ReadWatch:
|
||||
success = system.ApplicationProcess()->InsertWatchpoint(addr, size,
|
||||
Kernel::DebugWatchpointType::Read);
|
||||
success = GetProcess()->InsertWatchpoint(addr, size, Kernel::DebugWatchpointType::Read);
|
||||
break;
|
||||
case BreakpointType::AccessWatch:
|
||||
success = system.ApplicationProcess()->InsertWatchpoint(
|
||||
addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
|
||||
success =
|
||||
GetProcess()->InsertWatchpoint(addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
|
||||
break;
|
||||
case BreakpointType::Hardware:
|
||||
default:
|
||||
@ -400,7 +398,7 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
|
||||
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))};
|
||||
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))};
|
||||
|
||||
if (!system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) {
|
||||
if (!GetMemory().IsValidVirtualAddressRange(addr, size)) {
|
||||
SendReply(GDB_STUB_REPLY_ERR);
|
||||
return;
|
||||
}
|
||||
@ -411,24 +409,22 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
|
||||
case BreakpointType::Software: {
|
||||
const auto orig_insn{replaced_instructions.find(addr)};
|
||||
if (orig_insn != replaced_instructions.end()) {
|
||||
system.ApplicationMemory().Write32(addr, orig_insn->second);
|
||||
Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, sizeof(u32));
|
||||
GetMemory().Write32(addr, orig_insn->second);
|
||||
Core::InvalidateInstructionCacheRange(GetProcess(), addr, sizeof(u32));
|
||||
replaced_instructions.erase(addr);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BreakpointType::WriteWatch:
|
||||
success = system.ApplicationProcess()->RemoveWatchpoint(addr, size,
|
||||
Kernel::DebugWatchpointType::Write);
|
||||
success = GetProcess()->RemoveWatchpoint(addr, size, Kernel::DebugWatchpointType::Write);
|
||||
break;
|
||||
case BreakpointType::ReadWatch:
|
||||
success = system.ApplicationProcess()->RemoveWatchpoint(addr, size,
|
||||
Kernel::DebugWatchpointType::Read);
|
||||
success = GetProcess()->RemoveWatchpoint(addr, size, Kernel::DebugWatchpointType::Read);
|
||||
break;
|
||||
case BreakpointType::AccessWatch:
|
||||
success = system.ApplicationProcess()->RemoveWatchpoint(
|
||||
addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
|
||||
success =
|
||||
GetProcess()->RemoveWatchpoint(addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
|
||||
break;
|
||||
case BreakpointType::Hardware:
|
||||
default:
|
||||
@ -466,10 +462,10 @@ void GDBStub::HandleQuery(std::string_view command) {
|
||||
const auto target_xml{arch->GetTargetXML()};
|
||||
SendReply(PaginateBuffer(target_xml, command.substr(30)));
|
||||
} else if (command.starts_with("Offsets")) {
|
||||
const auto main_offset = Core::FindMainModuleEntrypoint(system.ApplicationProcess());
|
||||
const auto main_offset = Core::FindMainModuleEntrypoint(GetProcess());
|
||||
SendReply(fmt::format("TextSeg={:x}", GetInteger(main_offset)));
|
||||
} else if (command.starts_with("Xfer:libraries:read::")) {
|
||||
auto modules = Core::FindModules(system.ApplicationProcess());
|
||||
auto modules = Core::FindModules(GetProcess());
|
||||
|
||||
std::string buffer;
|
||||
buffer += R"(<?xml version="1.0"?>)";
|
||||
@ -483,7 +479,7 @@ void GDBStub::HandleQuery(std::string_view command) {
|
||||
SendReply(PaginateBuffer(buffer, command.substr(21)));
|
||||
} else if (command.starts_with("fThreadInfo")) {
|
||||
// beginning of list
|
||||
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
||||
const auto& threads = GetProcess()->GetThreadList();
|
||||
std::vector<std::string> thread_ids;
|
||||
for (const auto& thread : threads) {
|
||||
thread_ids.push_back(fmt::format("{:x}", thread.GetThreadId()));
|
||||
@ -497,7 +493,7 @@ void GDBStub::HandleQuery(std::string_view command) {
|
||||
buffer += R"(<?xml version="1.0"?>)";
|
||||
buffer += "<threads>";
|
||||
|
||||
const auto& threads = system.ApplicationProcess()->GetThreadList();
|
||||
const auto& threads = GetProcess()->GetThreadList();
|
||||
for (const auto& thread : threads) {
|
||||
auto thread_name{Core::GetThreadName(&thread)};
|
||||
if (!thread_name) {
|
||||
@ -613,7 +609,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
||||
std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()};
|
||||
std::string reply;
|
||||
|
||||
auto* process = system.ApplicationProcess();
|
||||
auto* process = GetProcess();
|
||||
auto& page_table = process->GetPageTable();
|
||||
|
||||
const char* commands = "Commands:\n"
|
||||
@ -714,7 +710,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
||||
}
|
||||
|
||||
Kernel::KThread* GDBStub::GetThreadByID(u64 thread_id) {
|
||||
auto& threads{system.ApplicationProcess()->GetThreadList()};
|
||||
auto& threads{GetProcess()->GetThreadList()};
|
||||
for (auto& thread : threads) {
|
||||
if (thread.GetThreadId() == thread_id) {
|
||||
return std::addressof(thread);
|
||||
@ -783,4 +779,12 @@ void GDBStub::SendStatus(char status) {
|
||||
backend.WriteToClient(buf);
|
||||
}
|
||||
|
||||
Kernel::KProcess* GDBStub::GetProcess() {
|
||||
return debug_process;
|
||||
}
|
||||
|
||||
Core::Memory::Memory& GDBStub::GetMemory() {
|
||||
return GetProcess()->GetMemory();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
@ -12,13 +12,22 @@
|
||||
#include "core/debugger/debugger_interface.h"
|
||||
#include "core/debugger/gdbstub_arch.h"
|
||||
|
||||
namespace Kernel {
|
||||
class KProcess;
|
||||
}
|
||||
|
||||
namespace Core::Memory {
|
||||
class Memory;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class System;
|
||||
|
||||
class GDBStub : public DebuggerFrontend {
|
||||
public:
|
||||
explicit GDBStub(DebuggerBackend& backend, Core::System& system);
|
||||
explicit GDBStub(DebuggerBackend& backend, Core::System& system,
|
||||
Kernel::KProcess* debug_process);
|
||||
~GDBStub() override;
|
||||
|
||||
void Connected() override;
|
||||
@ -42,8 +51,12 @@ private:
|
||||
void SendReply(std::string_view data);
|
||||
void SendStatus(char status);
|
||||
|
||||
Kernel::KProcess* GetProcess();
|
||||
Core::Memory::Memory& GetMemory();
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
Kernel::KProcess* debug_process;
|
||||
std::unique_ptr<GDBStubArch> arch;
|
||||
std::vector<char> current_command;
|
||||
std::map<VAddr, u32> replaced_instructions;
|
||||
|
@ -28,6 +28,10 @@ class Memory;
|
||||
template <typename DTraits>
|
||||
struct DeviceMemoryManagerAllocator;
|
||||
|
||||
struct Asid {
|
||||
size_t id;
|
||||
};
|
||||
|
||||
template <typename Traits>
|
||||
class DeviceMemoryManager {
|
||||
using DeviceInterface = typename Traits::DeviceInterface;
|
||||
@ -43,15 +47,14 @@ public:
|
||||
void AllocateFixed(DAddr start, size_t size);
|
||||
void Free(DAddr start, size_t size);
|
||||
|
||||
void Map(DAddr address, VAddr virtual_address, size_t size, size_t process_id,
|
||||
bool track = false);
|
||||
void Map(DAddr address, VAddr virtual_address, size_t size, Asid asid, bool track = false);
|
||||
|
||||
void Unmap(DAddr address, size_t size);
|
||||
|
||||
void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, size_t process_id);
|
||||
void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, size_t process_id) {
|
||||
void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, Asid asid);
|
||||
void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, Asid asid) {
|
||||
std::scoped_lock lk(mapping_guard);
|
||||
TrackContinuityImpl(address, virtual_address, size, process_id);
|
||||
TrackContinuityImpl(address, virtual_address, size, asid);
|
||||
}
|
||||
|
||||
// Write / Read
|
||||
@ -105,8 +108,8 @@ public:
|
||||
void WriteBlock(DAddr address, const void* src_pointer, size_t size);
|
||||
void WriteBlockUnsafe(DAddr address, const void* src_pointer, size_t size);
|
||||
|
||||
size_t RegisterProcess(Memory::Memory* memory);
|
||||
void UnregisterProcess(size_t id);
|
||||
Asid RegisterProcess(Memory::Memory* memory);
|
||||
void UnregisterProcess(Asid id);
|
||||
|
||||
void UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta);
|
||||
|
||||
@ -163,17 +166,17 @@ private:
|
||||
static constexpr size_t guest_max_as_bits = 39;
|
||||
static constexpr size_t guest_as_size = 1ULL << guest_max_as_bits;
|
||||
static constexpr size_t guest_mask = guest_as_size - 1ULL;
|
||||
static constexpr size_t process_id_start_bit = guest_max_as_bits;
|
||||
static constexpr size_t asid_start_bit = guest_max_as_bits;
|
||||
|
||||
std::pair<size_t, VAddr> ExtractCPUBacking(size_t page_index) {
|
||||
std::pair<Asid, VAddr> ExtractCPUBacking(size_t page_index) {
|
||||
auto content = cpu_backing_address[page_index];
|
||||
const VAddr address = content & guest_mask;
|
||||
const size_t process_id = static_cast<size_t>(content >> process_id_start_bit);
|
||||
return std::make_pair(process_id, address);
|
||||
const Asid asid{static_cast<size_t>(content >> asid_start_bit)};
|
||||
return std::make_pair(asid, address);
|
||||
}
|
||||
|
||||
void InsertCPUBacking(size_t page_index, VAddr address, size_t process_id) {
|
||||
cpu_backing_address[page_index] = address | (process_id << process_id_start_bit);
|
||||
void InsertCPUBacking(size_t page_index, VAddr address, Asid asid) {
|
||||
cpu_backing_address[page_index] = address | (asid.id << asid_start_bit);
|
||||
}
|
||||
|
||||
Common::VirtualBuffer<VAddr> cpu_backing_address;
|
||||
@ -205,4 +208,4 @@ private:
|
||||
std::mutex mapping_guard;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
} // namespace Core
|
||||
|
@ -215,8 +215,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,
|
||||
size_t process_id, bool track) {
|
||||
Core::Memory::Memory* process_memory = registered_processes[process_id];
|
||||
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;
|
||||
std::scoped_lock lk(mapping_guard);
|
||||
@ -229,7 +229,7 @@ void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size
|
||||
}
|
||||
auto phys_addr = static_cast<u32>(GetRawPhysicalAddr(ptr) >> Memory::YUZU_PAGEBITS) + 1U;
|
||||
compressed_physical_ptr[start_page_d + i] = phys_addr;
|
||||
InsertCPUBacking(start_page_d + i, new_vaddress, process_id);
|
||||
InsertCPUBacking(start_page_d + i, new_vaddress, asid);
|
||||
const u32 base_dev = compressed_device_addr[phys_addr - 1U];
|
||||
const u32 new_dev = static_cast<u32>(start_page_d + i);
|
||||
if (base_dev == 0) [[likely]] {
|
||||
@ -244,7 +244,7 @@ void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size
|
||||
impl->multi_dev_address.Register(new_dev, start_id);
|
||||
}
|
||||
if (track) {
|
||||
TrackContinuityImpl(address, virtual_address, size, process_id);
|
||||
TrackContinuityImpl(address, virtual_address, size, asid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,8 +277,8 @@ void DeviceMemoryManager<Traits>::Unmap(DAddr address, size_t size) {
|
||||
}
|
||||
template <typename Traits>
|
||||
void DeviceMemoryManager<Traits>::TrackContinuityImpl(DAddr address, VAddr virtual_address,
|
||||
size_t size, size_t process_id) {
|
||||
Core::Memory::Memory* process_memory = registered_processes[process_id];
|
||||
size_t size, Asid asid) {
|
||||
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;
|
||||
uintptr_t last_ptr = 0;
|
||||
@ -488,8 +488,8 @@ void DeviceMemoryManager<Traits>::WriteBlockUnsafe(DAddr address, const void* sr
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
size_t DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_device_inter) {
|
||||
size_t new_id;
|
||||
Asid DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_device_inter) {
|
||||
size_t new_id{};
|
||||
if (!id_pool.empty()) {
|
||||
new_id = id_pool.front();
|
||||
id_pool.pop_front();
|
||||
@ -498,29 +498,23 @@ size_t DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_devic
|
||||
registered_processes.emplace_back(memory_device_inter);
|
||||
new_id = registered_processes.size() - 1U;
|
||||
}
|
||||
return new_id;
|
||||
return Asid{new_id};
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
void DeviceMemoryManager<Traits>::UnregisterProcess(size_t id) {
|
||||
registered_processes[id] = nullptr;
|
||||
id_pool.push_front(id);
|
||||
void DeviceMemoryManager<Traits>::UnregisterProcess(Asid asid) {
|
||||
registered_processes[asid.id] = nullptr;
|
||||
id_pool.push_front(asid.id);
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta) {
|
||||
bool locked = false;
|
||||
auto lock = [&] {
|
||||
if (!locked) {
|
||||
counter_guard.lock();
|
||||
locked = true;
|
||||
std::unique_lock<std::mutex> lk(counter_guard, std::defer_lock);
|
||||
const auto Lock = [&] {
|
||||
if (!lk) {
|
||||
lk.lock();
|
||||
}
|
||||
};
|
||||
SCOPE_EXIT({
|
||||
if (locked) {
|
||||
counter_guard.unlock();
|
||||
}
|
||||
});
|
||||
u64 uncache_begin = 0;
|
||||
u64 cache_begin = 0;
|
||||
u64 uncache_bytes = 0;
|
||||
@ -530,9 +524,9 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
const size_t page_end = Common::DivCeil(addr + size, Memory::YUZU_PAGESIZE);
|
||||
size_t page = addr >> Memory::YUZU_PAGEBITS;
|
||||
auto [process_id, base_vaddress] = ExtractCPUBacking(page);
|
||||
auto [asid, base_vaddress] = ExtractCPUBacking(page);
|
||||
size_t vpage = base_vaddress >> Memory::YUZU_PAGEBITS;
|
||||
auto* memory_device_inter = registered_processes[process_id];
|
||||
auto* memory_device_inter = registered_processes[asid.id];
|
||||
for (; page != page_end; ++page) {
|
||||
std::atomic_uint8_t& count = cached_pages->at(page >> 3).Count(page);
|
||||
|
||||
@ -555,7 +549,7 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
}
|
||||
uncache_bytes += Memory::YUZU_PAGESIZE;
|
||||
} else if (uncache_bytes > 0) {
|
||||
lock();
|
||||
Lock();
|
||||
MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS,
|
||||
uncache_bytes, false);
|
||||
uncache_bytes = 0;
|
||||
@ -566,7 +560,7 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
}
|
||||
cache_bytes += Memory::YUZU_PAGESIZE;
|
||||
} else if (cache_bytes > 0) {
|
||||
lock();
|
||||
Lock();
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes,
|
||||
true);
|
||||
cache_bytes = 0;
|
||||
@ -574,12 +568,12 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size
|
||||
vpage++;
|
||||
}
|
||||
if (uncache_bytes > 0) {
|
||||
lock();
|
||||
Lock();
|
||||
MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes,
|
||||
false);
|
||||
}
|
||||
if (cache_bytes > 0) {
|
||||
lock();
|
||||
Lock();
|
||||
MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes,
|
||||
true);
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ Result KMemoryBlockManager::Initialize(KProcessAddress st, KProcessAddress nd,
|
||||
}
|
||||
|
||||
void KMemoryBlockManager::Finalize(KMemoryBlockSlabManager* slab_manager,
|
||||
HostUnmapCallback&& host_unmap_callback) {
|
||||
BlockCallback&& block_callback) {
|
||||
// Erase every block until we have none left.
|
||||
auto it = m_memory_block_tree.begin();
|
||||
while (it != m_memory_block_tree.end()) {
|
||||
KMemoryBlock* block = std::addressof(*it);
|
||||
it = m_memory_block_tree.erase(it);
|
||||
block_callback(block->GetAddress(), block->GetSize());
|
||||
slab_manager->Free(block);
|
||||
host_unmap_callback(block->GetAddress(), block->GetSize());
|
||||
}
|
||||
|
||||
ASSERT(m_memory_block_tree.empty());
|
||||
|
@ -85,11 +85,11 @@ public:
|
||||
public:
|
||||
KMemoryBlockManager();
|
||||
|
||||
using HostUnmapCallback = std::function<void(Common::ProcessAddress, u64)>;
|
||||
using BlockCallback = std::function<void(Common::ProcessAddress, u64)>;
|
||||
|
||||
Result Initialize(KProcessAddress st, KProcessAddress nd,
|
||||
KMemoryBlockSlabManager* slab_manager);
|
||||
void Finalize(KMemoryBlockSlabManager* slab_manager, HostUnmapCallback&& host_unmap_callback);
|
||||
void Finalize(KMemoryBlockSlabManager* slab_manager, BlockCallback&& block_callback);
|
||||
|
||||
iterator end() {
|
||||
return m_memory_block_tree.end();
|
||||
|
@ -431,15 +431,43 @@ Result KPageTableBase::InitializeForProcess(Svc::CreateProcessFlag as_type, bool
|
||||
m_memory_block_slab_manager));
|
||||
}
|
||||
|
||||
Result KPageTableBase::FinalizeProcess() {
|
||||
// Only process tables should be finalized.
|
||||
ASSERT(!this->IsKernel());
|
||||
|
||||
// NOTE: Here Nintendo calls an unknown OnFinalize function.
|
||||
// this->OnFinalize();
|
||||
|
||||
// NOTE: Here Nintendo calls a second unknown OnFinalize function.
|
||||
// this->OnFinalize2();
|
||||
|
||||
// NOTE: Here Nintendo does a page table walk to discover heap pages to free.
|
||||
// We will use the block manager finalization below to free them.
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void KPageTableBase::Finalize() {
|
||||
auto HostUnmapCallback = [&](KProcessAddress addr, u64 size) {
|
||||
if (Settings::IsFastmemEnabled()) {
|
||||
this->FinalizeProcess();
|
||||
|
||||
auto BlockCallback = [&](KProcessAddress addr, u64 size) {
|
||||
if (m_impl->fastmem_arena) {
|
||||
m_system.DeviceMemory().buffer.Unmap(GetInteger(addr), size, false);
|
||||
}
|
||||
|
||||
// Get physical pages.
|
||||
KPageGroup pg(m_kernel, m_block_info_manager);
|
||||
this->MakePageGroup(pg, addr, size / PageSize);
|
||||
|
||||
// Free the pages.
|
||||
pg.CloseAndReset();
|
||||
};
|
||||
|
||||
// Finalize memory blocks.
|
||||
m_memory_block_manager.Finalize(m_memory_block_slab_manager, std::move(HostUnmapCallback));
|
||||
{
|
||||
KScopedLightLock lk(m_general_lock);
|
||||
m_memory_block_manager.Finalize(m_memory_block_slab_manager, std::move(BlockCallback));
|
||||
}
|
||||
|
||||
// Free any unsafe mapped memory.
|
||||
if (m_mapped_unsafe_physical_memory) {
|
||||
|
@ -241,6 +241,7 @@ public:
|
||||
KResourceLimit* resource_limit, Core::Memory::Memory& memory,
|
||||
KProcessAddress aslr_space_start);
|
||||
|
||||
Result FinalizeProcess();
|
||||
void Finalize();
|
||||
|
||||
bool IsKernel() const {
|
||||
|
@ -172,6 +172,12 @@ void KProcess::Finalize() {
|
||||
m_resource_limit->Close();
|
||||
}
|
||||
|
||||
// Clear expensive resources, as the destructor is not called for guest objects.
|
||||
for (auto& interface : m_arm_interfaces) {
|
||||
interface.reset();
|
||||
}
|
||||
m_exclusive_monitor.reset();
|
||||
|
||||
// Perform inherited finalization.
|
||||
KSynchronizationObject::Finalize();
|
||||
}
|
||||
@ -1233,10 +1239,10 @@ void KProcess::LoadModule(CodeSet code_set, KProcessAddress base_addr) {
|
||||
ReprotectSegment(code_set.DataSegment(), Svc::MemoryPermission::ReadWrite);
|
||||
|
||||
#ifdef HAS_NCE
|
||||
if (this->IsApplication() && Settings::IsNceEnabled()) {
|
||||
const auto& patch = code_set.PatchSegment();
|
||||
if (this->IsApplication() && Settings::IsNceEnabled() && patch.size != 0) {
|
||||
auto& buffer = m_kernel.System().DeviceMemory().buffer;
|
||||
const auto& code = code_set.CodeSegment();
|
||||
const auto& patch = code_set.PatchSegment();
|
||||
buffer.Protect(GetInteger(base_addr + code.addr), code.size,
|
||||
Common::MemoryPermission::Read | Common::MemoryPermission::Execute);
|
||||
buffer.Protect(GetInteger(base_addr + patch.addr), patch.size,
|
||||
|
@ -112,7 +112,14 @@ struct KernelCore::Impl {
|
||||
old_process->Close();
|
||||
}
|
||||
|
||||
process_list.clear();
|
||||
{
|
||||
std::scoped_lock lk{process_list_lock};
|
||||
for (auto* const process : process_list) {
|
||||
process->Terminate();
|
||||
process->Close();
|
||||
}
|
||||
process_list.clear();
|
||||
}
|
||||
|
||||
next_object_id = 0;
|
||||
next_kernel_process_id = KProcess::InitialProcessIdMin;
|
||||
@ -770,6 +777,7 @@ struct KernelCore::Impl {
|
||||
std::atomic<u64> next_thread_id{1};
|
||||
|
||||
// Lists all processes that exist in the current session.
|
||||
std::mutex process_list_lock;
|
||||
std::vector<KProcess*> process_list;
|
||||
std::atomic<KProcess*> application_process{};
|
||||
std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
|
||||
@ -869,9 +877,19 @@ KResourceLimit* KernelCore::GetSystemResourceLimit() {
|
||||
}
|
||||
|
||||
void KernelCore::AppendNewProcess(KProcess* process) {
|
||||
process->Open();
|
||||
|
||||
std::scoped_lock lk{impl->process_list_lock};
|
||||
impl->process_list.push_back(process);
|
||||
}
|
||||
|
||||
void KernelCore::RemoveProcess(KProcess* process) {
|
||||
std::scoped_lock lk{impl->process_list_lock};
|
||||
if (std::erase(impl->process_list, process)) {
|
||||
process->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void KernelCore::MakeApplicationProcess(KProcess* process) {
|
||||
impl->MakeApplicationProcess(process);
|
||||
}
|
||||
@ -884,8 +902,15 @@ const KProcess* KernelCore::ApplicationProcess() const {
|
||||
return impl->application_process;
|
||||
}
|
||||
|
||||
const std::vector<KProcess*>& KernelCore::GetProcessList() const {
|
||||
return impl->process_list;
|
||||
std::list<KScopedAutoObject<KProcess>> KernelCore::GetProcessList() {
|
||||
std::list<KScopedAutoObject<KProcess>> processes;
|
||||
std::scoped_lock lk{impl->process_list_lock};
|
||||
|
||||
for (auto* const process : impl->process_list) {
|
||||
processes.emplace_back(process);
|
||||
}
|
||||
|
||||
return processes;
|
||||
}
|
||||
|
||||
Kernel::GlobalSchedulerContext& KernelCore::GlobalSchedulerContext() {
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@ -116,8 +117,9 @@ public:
|
||||
/// Retrieves a shared pointer to the system resource limit instance.
|
||||
KResourceLimit* GetSystemResourceLimit();
|
||||
|
||||
/// Adds the given shared pointer to an internal list of active processes.
|
||||
/// Adds/removes the given pointer to an internal list of active processes.
|
||||
void AppendNewProcess(KProcess* process);
|
||||
void RemoveProcess(KProcess* process);
|
||||
|
||||
/// Makes the given process the new application process.
|
||||
void MakeApplicationProcess(KProcess* process);
|
||||
@ -129,7 +131,7 @@ public:
|
||||
const KProcess* ApplicationProcess() const;
|
||||
|
||||
/// Retrieves the list of processes.
|
||||
const std::vector<KProcess*>& GetProcessList() const;
|
||||
std::list<KScopedAutoObject<KProcess>> GetProcessList();
|
||||
|
||||
/// Gets the sole instance of the global scheduler
|
||||
Kernel::GlobalSchedulerContext& GlobalSchedulerContext();
|
||||
|
@ -74,13 +74,15 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, u64 out_proc
|
||||
}
|
||||
|
||||
auto& memory = GetCurrentMemory(kernel);
|
||||
const auto& process_list = kernel.GetProcessList();
|
||||
auto process_list = kernel.GetProcessList();
|
||||
auto it = process_list.begin();
|
||||
|
||||
const auto num_processes = process_list.size();
|
||||
const auto copy_amount =
|
||||
std::min(static_cast<std::size_t>(out_process_ids_size), num_processes);
|
||||
|
||||
for (std::size_t i = 0; i < copy_amount; ++i) {
|
||||
memory.Write64(out_process_ids, process_list[i]->GetProcessId());
|
||||
for (std::size_t i = 0; i < copy_amount && it != process_list.end(); ++i, ++it) {
|
||||
memory.Write64(out_process_ids, (*it)->GetProcessId());
|
||||
out_process_ids += sizeof(u64);
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,7 @@ ProfileManager::ProfileManager() {
|
||||
OpenUser(*GetUser(current));
|
||||
}
|
||||
|
||||
ProfileManager::~ProfileManager() {
|
||||
WriteUserSaveFile();
|
||||
}
|
||||
ProfileManager::~ProfileManager() = default;
|
||||
|
||||
/// After a users creation it needs to be "registered" to the system. AddToProfiles handles the
|
||||
/// internal management of the users profiles
|
||||
@ -113,6 +111,8 @@ Result ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username)
|
||||
return ERROR_USER_ALREADY_EXISTS;
|
||||
}
|
||||
|
||||
is_save_needed = true;
|
||||
|
||||
return AddUser({
|
||||
.user_uuid = uuid,
|
||||
.username = username,
|
||||
@ -326,6 +326,9 @@ bool ProfileManager::RemoveUser(UUID uuid) {
|
||||
profiles[*index] = ProfileInfo{};
|
||||
std::stable_partition(profiles.begin(), profiles.end(),
|
||||
[](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); });
|
||||
|
||||
is_save_needed = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -340,6 +343,8 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
|
||||
profile.username = profile_new.username;
|
||||
profile.creation_time = profile_new.timestamp;
|
||||
|
||||
is_save_needed = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -348,6 +353,7 @@ bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase&
|
||||
const auto index = GetUserIndex(uuid);
|
||||
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
||||
profiles[*index].data = data_new;
|
||||
is_save_needed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -391,6 +397,10 @@ void ProfileManager::ParseUserSaveFile() {
|
||||
}
|
||||
|
||||
void ProfileManager::WriteUserSaveFile() {
|
||||
if (!is_save_needed) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProfileDataRaw raw{};
|
||||
|
||||
for (std::size_t i = 0; i < MAX_USERS; ++i) {
|
||||
@ -423,7 +433,10 @@ void ProfileManager::WriteUserSaveFile() {
|
||||
if (!save.IsOpen() || !save.SetSize(sizeof(ProfileDataRaw)) || !save.WriteObject(raw)) {
|
||||
LOG_WARNING(Service_ACC, "Failed to write save data to file... No changes to user data "
|
||||
"made in current session will be saved.");
|
||||
return;
|
||||
}
|
||||
|
||||
is_save_needed = false;
|
||||
}
|
||||
|
||||
}; // namespace Service::Account
|
||||
|
@ -103,6 +103,7 @@ private:
|
||||
std::optional<std::size_t> AddToProfiles(const ProfileInfo& profile);
|
||||
bool RemoveProfileAtIndex(std::size_t index);
|
||||
|
||||
bool is_save_needed{};
|
||||
std::array<ProfileInfo, MAX_USERS> profiles{};
|
||||
std::array<ProfileInfo, MAX_USERS> stored_opened_profiles{};
|
||||
std::size_t user_count{};
|
||||
|
@ -18,11 +18,11 @@ using namespace AudioCore::AudioIn;
|
||||
class IAudioIn final : public ServiceFramework<IAudioIn> {
|
||||
public:
|
||||
explicit IAudioIn(Core::System& system_, Manager& manager, size_t session_id,
|
||||
const std::string& device_name, const AudioInParameter& in_params, u32 handle,
|
||||
u64 applet_resource_user_id)
|
||||
const std::string& device_name, const AudioInParameter& in_params,
|
||||
Kernel::KProcess* handle, u64 applet_resource_user_id)
|
||||
: ServiceFramework{system_, "IAudioIn"},
|
||||
service_context{system_, "IAudioIn"}, event{service_context.CreateEvent("AudioInEvent")},
|
||||
impl{std::make_shared<In>(system_, manager, event, session_id)} {
|
||||
process{handle}, impl{std::make_shared<In>(system_, manager, event, session_id)} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IAudioIn::GetAudioInState, "GetAudioInState"},
|
||||
@ -45,6 +45,8 @@ public:
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
process->Open();
|
||||
|
||||
if (impl->GetSystem()
|
||||
.Initialize(device_name, in_params, handle, applet_resource_user_id)
|
||||
.IsError()) {
|
||||
@ -55,6 +57,7 @@ public:
|
||||
~IAudioIn() override {
|
||||
impl->Free();
|
||||
service_context.CloseEvent(event);
|
||||
process->Close();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<In> GetImpl() {
|
||||
@ -196,6 +199,7 @@ private:
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* event;
|
||||
Kernel::KProcess* process;
|
||||
std::shared_ptr<AudioCore::AudioIn::In> impl;
|
||||
Common::ScratchBuffer<u64> released_buffer;
|
||||
};
|
||||
@ -267,6 +271,14 @@ void AudInU::OpenAudioIn(HLERequestContext& ctx) {
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(handle)};
|
||||
if (process.IsNull()) {
|
||||
LOG_ERROR(Service_Audio, "Failed to get process handle");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock l{impl->mutex};
|
||||
auto link{impl->LinkToManager()};
|
||||
if (link.IsError()) {
|
||||
@ -287,8 +299,9 @@ void AudInU::OpenAudioIn(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Audio, "Opening new AudioIn, sessionid={}, free sessions={}", new_session_id,
|
||||
impl->num_free_sessions);
|
||||
|
||||
auto audio_in = std::make_shared<IAudioIn>(system, *impl, new_session_id, device_name,
|
||||
in_params, handle, applet_resource_user_id);
|
||||
auto audio_in =
|
||||
std::make_shared<IAudioIn>(system, *impl, new_session_id, device_name, in_params,
|
||||
process.GetPointerUnsafe(), applet_resource_user_id);
|
||||
impl->sessions[new_session_id] = audio_in->GetImpl();
|
||||
impl->applet_resource_user_ids[new_session_id] = applet_resource_user_id;
|
||||
|
||||
@ -318,6 +331,14 @@ void AudInU::OpenAudioInProtocolSpecified(HLERequestContext& ctx) {
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(handle)};
|
||||
if (process.IsNull()) {
|
||||
LOG_ERROR(Service_Audio, "Failed to get process handle");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock l{impl->mutex};
|
||||
auto link{impl->LinkToManager()};
|
||||
if (link.IsError()) {
|
||||
@ -338,8 +359,9 @@ void AudInU::OpenAudioInProtocolSpecified(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Audio, "Opening new AudioIn, sessionid={}, free sessions={}", new_session_id,
|
||||
impl->num_free_sessions);
|
||||
|
||||
auto audio_in = std::make_shared<IAudioIn>(system, *impl, new_session_id, device_name,
|
||||
in_params, handle, applet_resource_user_id);
|
||||
auto audio_in =
|
||||
std::make_shared<IAudioIn>(system, *impl, new_session_id, device_name, in_params,
|
||||
process.GetPointerUnsafe(), applet_resource_user_id);
|
||||
impl->sessions[new_session_id] = audio_in->GetImpl();
|
||||
impl->applet_resource_user_ids[new_session_id] = applet_resource_user_id;
|
||||
|
||||
|
@ -26,9 +26,10 @@ class IAudioOut final : public ServiceFramework<IAudioOut> {
|
||||
public:
|
||||
explicit IAudioOut(Core::System& system_, AudioCore::AudioOut::Manager& manager,
|
||||
size_t session_id, const std::string& device_name,
|
||||
const AudioOutParameter& in_params, u32 handle, u64 applet_resource_user_id)
|
||||
const AudioOutParameter& in_params, Kernel::KProcess* handle,
|
||||
u64 applet_resource_user_id)
|
||||
: ServiceFramework{system_, "IAudioOut"}, service_context{system_, "IAudioOut"},
|
||||
event{service_context.CreateEvent("AudioOutEvent")},
|
||||
event{service_context.CreateEvent("AudioOutEvent")}, process{handle},
|
||||
impl{std::make_shared<AudioCore::AudioOut::Out>(system_, manager, event, session_id)} {
|
||||
|
||||
// clang-format off
|
||||
@ -50,11 +51,14 @@ public:
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
|
||||
process->Open();
|
||||
}
|
||||
|
||||
~IAudioOut() override {
|
||||
impl->Free();
|
||||
service_context.CloseEvent(event);
|
||||
process->Close();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<AudioCore::AudioOut::Out> GetImpl() {
|
||||
@ -206,6 +210,7 @@ private:
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* event;
|
||||
Kernel::KProcess* process;
|
||||
std::shared_ptr<AudioCore::AudioOut::Out> impl;
|
||||
Common::ScratchBuffer<u64> released_buffer;
|
||||
};
|
||||
@ -257,6 +262,14 @@ void AudOutU::OpenAudioOut(HLERequestContext& ctx) {
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(handle)};
|
||||
if (process.IsNull()) {
|
||||
LOG_ERROR(Service_Audio, "Failed to get process handle");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
auto link{impl->LinkToManager()};
|
||||
if (link.IsError()) {
|
||||
LOG_ERROR(Service_Audio, "Failed to link Audio Out to Audio Manager");
|
||||
@ -276,10 +289,11 @@ void AudOutU::OpenAudioOut(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Audio, "Opening new AudioOut, sessionid={}, free sessions={}", new_session_id,
|
||||
impl->num_free_sessions);
|
||||
|
||||
auto audio_out = std::make_shared<IAudioOut>(system, *impl, new_session_id, device_name,
|
||||
in_params, handle, applet_resource_user_id);
|
||||
result = audio_out->GetImpl()->GetSystem().Initialize(device_name, in_params, handle,
|
||||
applet_resource_user_id);
|
||||
auto audio_out =
|
||||
std::make_shared<IAudioOut>(system, *impl, new_session_id, device_name, in_params,
|
||||
process.GetPointerUnsafe(), applet_resource_user_id);
|
||||
result = audio_out->GetImpl()->GetSystem().Initialize(
|
||||
device_name, in_params, process.GetPointerUnsafe(), applet_resource_user_id);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_Audio, "Failed to initialize the AudioOut System!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
@ -15,9 +15,10 @@
|
||||
namespace Service::Glue {
|
||||
|
||||
namespace {
|
||||
std::optional<u64> GetTitleIDForProcessID(const Core::System& system, u64 process_id) {
|
||||
const auto& list = system.Kernel().GetProcessList();
|
||||
const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) {
|
||||
std::optional<u64> GetTitleIDForProcessID(Core::System& system, u64 process_id) {
|
||||
auto list = system.Kernel().GetProcessList();
|
||||
|
||||
const auto iter = std::find_if(list.begin(), list.end(), [&process_id](auto& process) {
|
||||
return process->GetProcessId() == process_id;
|
||||
});
|
||||
|
||||
|
@ -20,14 +20,13 @@ void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
|
||||
std::shared_ptr<HidFirmwareSettings> firmware_settings =
|
||||
std::make_shared<HidFirmwareSettings>();
|
||||
std::make_shared<HidFirmwareSettings>(system);
|
||||
|
||||
// TODO: Remove this hack until this service is emulated properly.
|
||||
const auto process_list = system.Kernel().GetProcessList();
|
||||
if (!process_list.empty()) {
|
||||
resource_manager->Initialize();
|
||||
resource_manager->RegisterAppletResourceUserId(process_list[0]->GetId(), true);
|
||||
}
|
||||
// TODO: Remove this hack when am is emulated properly.
|
||||
resource_manager->Initialize();
|
||||
resource_manager->RegisterAppletResourceUserId(system.ApplicationProcess()->GetProcessId(),
|
||||
true);
|
||||
resource_manager->SetAruidValidForVibration(system.ApplicationProcess()->GetProcessId(), true);
|
||||
|
||||
server_manager->RegisterNamedService(
|
||||
"hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings));
|
||||
|
@ -22,12 +22,16 @@
|
||||
#include "hid_core/resources/mouse/mouse.h"
|
||||
#include "hid_core/resources/npad/npad.h"
|
||||
#include "hid_core/resources/npad/npad_types.h"
|
||||
#include "hid_core/resources/npad/npad_vibration.h"
|
||||
#include "hid_core/resources/palma/palma.h"
|
||||
#include "hid_core/resources/six_axis/console_six_axis.h"
|
||||
#include "hid_core/resources/six_axis/seven_six_axis.h"
|
||||
#include "hid_core/resources/six_axis/six_axis.h"
|
||||
#include "hid_core/resources/touch_screen/gesture.h"
|
||||
#include "hid_core/resources/touch_screen/touch_screen.h"
|
||||
#include "hid_core/resources/vibration/gc_vibration_device.h"
|
||||
#include "hid_core/resources/vibration/n64_vibration_device.h"
|
||||
#include "hid_core/resources/vibration/vibration_device.h"
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
@ -38,7 +42,7 @@ public:
|
||||
: ServiceFramework{system_, "IActiveVibrationDeviceList"}, resource_manager(resource) {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IActiveVibrationDeviceList::InitializeVibrationDevice, "InitializeVibrationDevice"},
|
||||
{0, &IActiveVibrationDeviceList::ActivateVibrationDevice, "ActivateVibrationDevice"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@ -46,22 +50,49 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeVibrationDevice(HLERequestContext& ctx) {
|
||||
void ActivateVibrationDevice(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()};
|
||||
|
||||
if (resource_manager != nullptr && resource_manager->GetNpad()) {
|
||||
resource_manager->GetNpad()->InitializeVibrationDevice(vibration_device_handle);
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, npad_type={}, npad_id={}, device_index={}",
|
||||
vibration_device_handle.npad_type, vibration_device_handle.npad_id,
|
||||
vibration_device_handle.device_index);
|
||||
|
||||
const auto result = ActivateVibrationDeviceImpl(vibration_device_handle);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
Result ActivateVibrationDeviceImpl(const Core::HID::VibrationDeviceHandle& handle) {
|
||||
std::scoped_lock lock{mutex};
|
||||
|
||||
const Result is_valid = IsVibrationHandleValid(handle);
|
||||
if (is_valid.IsError()) {
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < list_size; i++) {
|
||||
if (handle.device_index == vibration_device_list[i].device_index &&
|
||||
handle.npad_id == vibration_device_list[i].npad_id &&
|
||||
handle.npad_type == vibration_device_list[i].npad_type) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
}
|
||||
if (list_size == vibration_device_list.size()) {
|
||||
return ResultVibrationDeviceIndexOutOfRange;
|
||||
}
|
||||
const Result result = resource_manager->GetVibrationDevice(handle)->Activate();
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
}
|
||||
vibration_device_list[list_size++] = handle;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
mutable std::mutex mutex;
|
||||
std::size_t list_size{};
|
||||
std::array<Core::HID::VibrationDeviceHandle, 0x100> vibration_device_list{};
|
||||
std::shared_ptr<ResourceManager> resource_manager;
|
||||
};
|
||||
|
||||
@ -153,7 +184,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
|
||||
{209, &IHidServer::BeginPermitVibrationSession, "BeginPermitVibrationSession"},
|
||||
{210, &IHidServer::EndPermitVibrationSession, "EndPermitVibrationSession"},
|
||||
{211, &IHidServer::IsVibrationDeviceMounted, "IsVibrationDeviceMounted"},
|
||||
{212, nullptr, "SendVibrationValueInBool"},
|
||||
{212, &IHidServer::SendVibrationValueInBool, "SendVibrationValueInBool"},
|
||||
{300, &IHidServer::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"},
|
||||
{301, &IHidServer::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"},
|
||||
{302, &IHidServer::StopConsoleSixAxisSensor, "StopConsoleSixAxisSensor"},
|
||||
@ -1492,59 +1523,13 @@ void IHidServer::ClearNpadCaptureButtonAssignment(HLERequestContext& ctx) {
|
||||
void IHidServer::GetVibrationDeviceInfo(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()};
|
||||
const auto controller = GetResourceManager()->GetNpad();
|
||||
|
||||
Core::HID::VibrationDeviceInfo vibration_device_info;
|
||||
bool check_device_index = false;
|
||||
|
||||
switch (vibration_device_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::Fullkey:
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
vibration_device_info.type = Core::HID::VibrationDeviceType::LinearResonantActuator;
|
||||
check_device_index = true;
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
vibration_device_info.type = Core::HID::VibrationDeviceType::GcErm;
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::N64:
|
||||
vibration_device_info.type = Core::HID::VibrationDeviceType::N64;
|
||||
break;
|
||||
default:
|
||||
vibration_device_info.type = Core::HID::VibrationDeviceType::Unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
vibration_device_info.position = Core::HID::VibrationDevicePosition::None;
|
||||
if (check_device_index) {
|
||||
switch (vibration_device_handle.device_index) {
|
||||
case Core::HID::DeviceIndex::Left:
|
||||
vibration_device_info.position = Core::HID::VibrationDevicePosition::Left;
|
||||
break;
|
||||
case Core::HID::DeviceIndex::Right:
|
||||
vibration_device_info.position = Core::HID::VibrationDevicePosition::Right;
|
||||
break;
|
||||
case Core::HID::DeviceIndex::None:
|
||||
default:
|
||||
ASSERT_MSG(false, "DeviceIndex should never be None!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}",
|
||||
vibration_device_info.type, vibration_device_info.position);
|
||||
|
||||
const auto result = IsVibrationHandleValid(vibration_device_handle);
|
||||
if (result.IsError()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
Core::HID::VibrationDeviceInfo vibration_device_info{};
|
||||
const auto result = GetResourceManager()->GetVibrationDeviceInfo(vibration_device_info,
|
||||
vibration_device_handle);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
rb.PushRaw(vibration_device_info);
|
||||
}
|
||||
|
||||
@ -1560,16 +1545,16 @@ void IHidServer::SendVibrationValue(HLERequestContext& ctx) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
GetResourceManager()->GetNpad()->VibrateController(parameters.applet_resource_user_id,
|
||||
parameters.vibration_device_handle,
|
||||
parameters.vibration_value);
|
||||
|
||||
LOG_DEBUG(Service_HID,
|
||||
"called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
|
||||
parameters.vibration_device_handle.npad_type,
|
||||
parameters.vibration_device_handle.npad_id,
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
|
||||
|
||||
GetResourceManager()->SendVibrationValue(parameters.applet_resource_user_id,
|
||||
parameters.vibration_device_handle,
|
||||
parameters.vibration_value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
@ -1591,10 +1576,28 @@ void IHidServer::GetActualVibrationValue(HLERequestContext& ctx) {
|
||||
parameters.vibration_device_handle.npad_id,
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
|
||||
|
||||
bool has_active_aruid{};
|
||||
NpadVibrationDevice* device{nullptr};
|
||||
Core::HID::VibrationValue vibration_value{};
|
||||
Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
|
||||
has_active_aruid);
|
||||
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
result = IsVibrationHandleValid(parameters.vibration_device_handle);
|
||||
}
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
device = GetResourceManager()->GetNSVibrationDevice(parameters.vibration_device_handle);
|
||||
}
|
||||
if (device != nullptr) {
|
||||
result = device->GetActualVibrationValue(vibration_value);
|
||||
}
|
||||
if (result.IsError()) {
|
||||
vibration_value = Core::HID::DEFAULT_VIBRATION_VALUE;
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(GetResourceManager()->GetNpad()->GetLastVibration(
|
||||
parameters.applet_resource_user_id, parameters.vibration_device_handle));
|
||||
rb.PushRaw(vibration_value);
|
||||
}
|
||||
|
||||
void IHidServer::CreateActiveVibrationDeviceList(HLERequestContext& ctx) {
|
||||
@ -1609,25 +1612,27 @@ void IHidServer::PermitVibration(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto can_vibrate{rp.Pop<bool>()};
|
||||
|
||||
// nnSDK saves this value as a float. Since it can only be 1.0f or 0.0f we simplify this value
|
||||
// by converting it to a bool
|
||||
Settings::values.vibration_enabled.SetValue(can_vibrate);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, can_vibrate={}", can_vibrate);
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->SetVibrationMasterVolume(
|
||||
can_vibrate ? 1.0f : 0.0f);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::IsVibrationPermitted(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_HID, "called");
|
||||
|
||||
// nnSDK checks if a float is greater than zero. We return the bool we stored earlier
|
||||
const auto is_enabled = Settings::values.vibration_enabled.GetValue();
|
||||
f32 master_volume{};
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->GetVibrationMasterVolume(
|
||||
master_volume);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(is_enabled);
|
||||
rb.Push(result);
|
||||
rb.Push(master_volume > 0.0f);
|
||||
}
|
||||
|
||||
void IHidServer::SendVibrationValues(HLERequestContext& ctx) {
|
||||
@ -1645,13 +1650,22 @@ void IHidServer::SendVibrationValues(HLERequestContext& ctx) {
|
||||
auto vibration_values = std::span(
|
||||
reinterpret_cast<const Core::HID::VibrationValue*>(vibration_data.data()), vibration_count);
|
||||
|
||||
GetResourceManager()->GetNpad()->VibrateControllers(applet_resource_user_id,
|
||||
vibration_device_handles, vibration_values);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
Result result = ResultSuccess;
|
||||
if (handle_count != vibration_count) {
|
||||
result = ResultVibrationArraySizeMismatch;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < handle_count; i++) {
|
||||
if (result.IsSuccess()) {
|
||||
result = GetResourceManager()->SendVibrationValue(
|
||||
applet_resource_user_id, vibration_device_handles[i], vibration_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::SendVibrationGcErmCommand(HLERequestContext& ctx) {
|
||||
@ -1666,43 +1680,6 @@ void IHidServer::SendVibrationGcErmCommand(HLERequestContext& ctx) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
/**
|
||||
* Note: This uses yuzu-specific behavior such that the StopHard command produces
|
||||
* vibrations where freq_low == 0.0f and freq_high == 0.0f, as defined below,
|
||||
* in order to differentiate between Stop and StopHard commands.
|
||||
* This is done to reuse the controller vibration functions made for regular controllers.
|
||||
*/
|
||||
const auto vibration_value = [parameters] {
|
||||
switch (parameters.gc_erm_command) {
|
||||
case Core::HID::VibrationGcErmCommand::Stop:
|
||||
return Core::HID::VibrationValue{
|
||||
.low_amplitude = 0.0f,
|
||||
.low_frequency = 160.0f,
|
||||
.high_amplitude = 0.0f,
|
||||
.high_frequency = 320.0f,
|
||||
};
|
||||
case Core::HID::VibrationGcErmCommand::Start:
|
||||
return Core::HID::VibrationValue{
|
||||
.low_amplitude = 1.0f,
|
||||
.low_frequency = 160.0f,
|
||||
.high_amplitude = 1.0f,
|
||||
.high_frequency = 320.0f,
|
||||
};
|
||||
case Core::HID::VibrationGcErmCommand::StopHard:
|
||||
return Core::HID::VibrationValue{
|
||||
.low_amplitude = 0.0f,
|
||||
.low_frequency = 0.0f,
|
||||
.high_amplitude = 0.0f,
|
||||
.high_frequency = 0.0f,
|
||||
};
|
||||
default:
|
||||
return Core::HID::DEFAULT_VIBRATION_VALUE;
|
||||
}
|
||||
}();
|
||||
|
||||
GetResourceManager()->GetNpad()->VibrateController(
|
||||
parameters.applet_resource_user_id, parameters.vibration_device_handle, vibration_value);
|
||||
|
||||
LOG_DEBUG(Service_HID,
|
||||
"called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, "
|
||||
"gc_erm_command={}",
|
||||
@ -1711,8 +1688,23 @@ void IHidServer::SendVibrationGcErmCommand(HLERequestContext& ctx) {
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id,
|
||||
parameters.gc_erm_command);
|
||||
|
||||
bool has_active_aruid{};
|
||||
NpadGcVibrationDevice* gc_device{nullptr};
|
||||
Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
|
||||
has_active_aruid);
|
||||
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
result = IsVibrationHandleValid(parameters.vibration_device_handle);
|
||||
}
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
gc_device = GetResourceManager()->GetGcVibrationDevice(parameters.vibration_device_handle);
|
||||
}
|
||||
if (gc_device != nullptr) {
|
||||
result = gc_device->SendVibrationGcErmCommand(parameters.gc_erm_command);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::GetActualVibrationGcErmCommand(HLERequestContext& ctx) {
|
||||
@ -1725,33 +1717,31 @@ void IHidServer::GetActualVibrationGcErmCommand(HLERequestContext& ctx) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
const auto last_vibration = GetResourceManager()->GetNpad()->GetLastVibration(
|
||||
parameters.applet_resource_user_id, parameters.vibration_device_handle);
|
||||
|
||||
const auto gc_erm_command = [last_vibration] {
|
||||
if (last_vibration.low_amplitude != 0.0f || last_vibration.high_amplitude != 0.0f) {
|
||||
return Core::HID::VibrationGcErmCommand::Start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: This uses yuzu-specific behavior such that the StopHard command produces
|
||||
* vibrations where freq_low == 0.0f and freq_high == 0.0f, as defined in the HID function
|
||||
* SendVibrationGcErmCommand, in order to differentiate between Stop and StopHard commands.
|
||||
* This is done to reuse the controller vibration functions made for regular controllers.
|
||||
*/
|
||||
if (last_vibration.low_frequency == 0.0f && last_vibration.high_frequency == 0.0f) {
|
||||
return Core::HID::VibrationGcErmCommand::StopHard;
|
||||
}
|
||||
|
||||
return Core::HID::VibrationGcErmCommand::Stop;
|
||||
}();
|
||||
|
||||
LOG_DEBUG(Service_HID,
|
||||
"called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
|
||||
parameters.vibration_device_handle.npad_type,
|
||||
parameters.vibration_device_handle.npad_id,
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
|
||||
|
||||
bool has_active_aruid{};
|
||||
NpadGcVibrationDevice* gc_device{nullptr};
|
||||
Core::HID::VibrationGcErmCommand gc_erm_command{};
|
||||
Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
|
||||
has_active_aruid);
|
||||
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
result = IsVibrationHandleValid(parameters.vibration_device_handle);
|
||||
}
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
gc_device = GetResourceManager()->GetGcVibrationDevice(parameters.vibration_device_handle);
|
||||
}
|
||||
if (gc_device != nullptr) {
|
||||
result = gc_device->GetActualVibrationGcErmCommand(gc_erm_command);
|
||||
}
|
||||
if (result.IsError()) {
|
||||
gc_erm_command = Core::HID::VibrationGcErmCommand::Stop;
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(gc_erm_command);
|
||||
@ -1761,21 +1751,24 @@ void IHidServer::BeginPermitVibrationSession(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
GetResourceManager()->GetNpad()->SetPermitVibrationSession(true);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->BeginPermitVibrationSession(
|
||||
applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::EndPermitVibrationSession(HLERequestContext& ctx) {
|
||||
GetResourceManager()->GetNpad()->SetPermitVibrationSession(false);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called");
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->EndPermitVibrationSession();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::IsVibrationDeviceMounted(HLERequestContext& ctx) {
|
||||
@ -1795,10 +1788,61 @@ void IHidServer::IsVibrationDeviceMounted(HLERequestContext& ctx) {
|
||||
parameters.vibration_device_handle.npad_id,
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
|
||||
|
||||
bool is_mounted{};
|
||||
NpadVibrationBase* device{nullptr};
|
||||
Result result = IsVibrationHandleValid(parameters.vibration_device_handle);
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
device = GetResourceManager()->GetVibrationDevice(parameters.vibration_device_handle);
|
||||
}
|
||||
|
||||
if (device != nullptr) {
|
||||
is_mounted = device->IsVibrationMounted();
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(GetResourceManager()->GetNpad()->IsVibrationDeviceMounted(
|
||||
parameters.applet_resource_user_id, parameters.vibration_device_handle));
|
||||
rb.Push(result);
|
||||
rb.Push(is_mounted);
|
||||
}
|
||||
|
||||
void IHidServer::SendVibrationValueInBool(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::HID::VibrationDeviceHandle vibration_device_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
bool is_vibrating;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_DEBUG(Service_HID,
|
||||
"called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, "
|
||||
"is_vibrating={}",
|
||||
parameters.vibration_device_handle.npad_type,
|
||||
parameters.vibration_device_handle.npad_id,
|
||||
parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id,
|
||||
parameters.is_vibrating);
|
||||
|
||||
bool has_active_aruid{};
|
||||
NpadN64VibrationDevice* n64_device{nullptr};
|
||||
Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
|
||||
has_active_aruid);
|
||||
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
result = IsVibrationHandleValid(parameters.vibration_device_handle);
|
||||
}
|
||||
if (result.IsSuccess() && has_active_aruid) {
|
||||
n64_device =
|
||||
GetResourceManager()->GetN64VibrationDevice(parameters.vibration_device_handle);
|
||||
}
|
||||
if (n64_device != nullptr) {
|
||||
result = n64_device->SendValueInBool(parameters.is_vibrating);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) {
|
||||
|
@ -97,6 +97,7 @@ private:
|
||||
void BeginPermitVibrationSession(HLERequestContext& ctx);
|
||||
void EndPermitVibrationSession(HLERequestContext& ctx);
|
||||
void IsVibrationDeviceMounted(HLERequestContext& ctx);
|
||||
void SendVibrationValueInBool(HLERequestContext& ctx);
|
||||
void ActivateConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||
void StartConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||
void StopConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "hid_core/resource_manager.h"
|
||||
#include "hid_core/resources/npad/npad.h"
|
||||
#include "hid_core/resources/npad/npad_types.h"
|
||||
#include "hid_core/resources/npad/npad_vibration.h"
|
||||
#include "hid_core/resources/palma/palma.h"
|
||||
#include "hid_core/resources/touch_screen/touch_screen.h"
|
||||
|
||||
@ -67,14 +68,14 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{501, &IHidSystemServer::RegisterAppletResourceUserId, "RegisterAppletResourceUserId"},
|
||||
{502, &IHidSystemServer::UnregisterAppletResourceUserId, "UnregisterAppletResourceUserId"},
|
||||
{503, &IHidSystemServer::EnableAppletToGetInput, "EnableAppletToGetInput"},
|
||||
{504, nullptr, "SetAruidValidForVibration"},
|
||||
{504, &IHidSystemServer::SetAruidValidForVibration, "SetAruidValidForVibration"},
|
||||
{505, &IHidSystemServer::EnableAppletToGetSixAxisSensor, "EnableAppletToGetSixAxisSensor"},
|
||||
{506, &IHidSystemServer::EnableAppletToGetPadInput, "EnableAppletToGetPadInput"},
|
||||
{507, &IHidSystemServer::EnableAppletToGetTouchScreen, "EnableAppletToGetTouchScreen"},
|
||||
{510, nullptr, "SetVibrationMasterVolume"},
|
||||
{511, nullptr, "GetVibrationMasterVolume"},
|
||||
{512, nullptr, "BeginPermitVibrationSession"},
|
||||
{513, nullptr, "EndPermitVibrationSession"},
|
||||
{510, &IHidSystemServer::SetVibrationMasterVolume, "SetVibrationMasterVolume"},
|
||||
{511, &IHidSystemServer::GetVibrationMasterVolume, "GetVibrationMasterVolume"},
|
||||
{512, &IHidSystemServer::BeginPermitVibrationSession, "BeginPermitVibrationSession"},
|
||||
{513, &IHidSystemServer::EndPermitVibrationSession, "EndPermitVibrationSession"},
|
||||
{514, nullptr, "Unknown514"},
|
||||
{520, nullptr, "EnableHandheldHids"},
|
||||
{521, nullptr, "DisableHandheldHids"},
|
||||
@ -156,7 +157,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
|
||||
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
|
||||
{1154, nullptr, "IsFirmwareAvailableForNotification"},
|
||||
{1155, nullptr, "SetForceHandheldStyleVibration"},
|
||||
{1155, &IHidSystemServer::SetForceHandheldStyleVibration, "SetForceHandheldStyleVibration"},
|
||||
{1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"},
|
||||
{1157, nullptr, "CancelConnectionTrigger"},
|
||||
{1200, nullptr, "IsButtonConfigSupported"},
|
||||
@ -538,6 +539,27 @@ void IHidSystemServer::EnableAppletToGetInput(HLERequestContext& ctx) {
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::SetAruidValidForVibration(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
bool is_enabled;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, is_enabled={}, applet_resource_user_id={}",
|
||||
parameters.is_enabled, parameters.applet_resource_user_id);
|
||||
|
||||
GetResourceManager()->SetAruidValidForVibration(parameters.applet_resource_user_id,
|
||||
parameters.is_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::EnableAppletToGetSixAxisSensor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
@ -601,6 +623,57 @@ void IHidSystemServer::EnableAppletToGetTouchScreen(HLERequestContext& ctx) {
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::SetVibrationMasterVolume(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto master_volume{rp.Pop<f32>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, volume={}", master_volume);
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->SetVibrationMasterVolume(
|
||||
master_volume);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetVibrationMasterVolume(HLERequestContext& ctx) {
|
||||
f32 master_volume{};
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->GetVibrationMasterVolume(
|
||||
master_volume);
|
||||
|
||||
LOG_INFO(Service_HID, "called, volume={}", master_volume);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.Push(master_volume);
|
||||
}
|
||||
|
||||
void IHidSystemServer::BeginPermitVibrationSession(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->BeginPermitVibrationSession(
|
||||
applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidSystemServer::EndPermitVibrationSession(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->GetVibrationHandler()->EndPermitVibrationSession();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidSystemServer::IsJoyConAttachedOnAllRail(HLERequestContext& ctx) {
|
||||
const bool is_attached = true;
|
||||
|
||||
@ -749,6 +822,19 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx
|
||||
rb.PushRaw(touchscreen_config);
|
||||
}
|
||||
|
||||
void IHidSystemServer::SetForceHandheldStyleVibration(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto is_forced{rp.Pop<bool>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, is_forced={}", is_forced);
|
||||
|
||||
GetResourceManager()->SetForceHandheldStyleVibration(is_forced);
|
||||
GetResourceManager()->GetNpad()->UpdateHandheldAbstractState();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::IsUsingCustomButtonConfig(HLERequestContext& ctx) {
|
||||
const bool is_enabled = false;
|
||||
|
||||
|
@ -42,9 +42,14 @@ private:
|
||||
void RegisterAppletResourceUserId(HLERequestContext& ctx);
|
||||
void UnregisterAppletResourceUserId(HLERequestContext& ctx);
|
||||
void EnableAppletToGetInput(HLERequestContext& ctx);
|
||||
void SetAruidValidForVibration(HLERequestContext& ctx);
|
||||
void EnableAppletToGetSixAxisSensor(HLERequestContext& ctx);
|
||||
void EnableAppletToGetPadInput(HLERequestContext& ctx);
|
||||
void EnableAppletToGetTouchScreen(HLERequestContext& ctx);
|
||||
void SetVibrationMasterVolume(HLERequestContext& ctx);
|
||||
void GetVibrationMasterVolume(HLERequestContext& ctx);
|
||||
void BeginPermitVibrationSession(HLERequestContext& ctx);
|
||||
void EndPermitVibrationSession(HLERequestContext& ctx);
|
||||
void IsJoyConAttachedOnAllRail(HLERequestContext& ctx);
|
||||
void AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx);
|
||||
void AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx);
|
||||
@ -61,6 +66,7 @@ private:
|
||||
void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx);
|
||||
void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
|
||||
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
|
||||
void SetForceHandheldStyleVibration(HLERequestContext& ctx);
|
||||
void IsUsingCustomButtonConfig(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||
|
@ -441,7 +441,10 @@ Result NfcDevice::Mount(NFP::ModelType model_type, NFP::MountTarget mount_target
|
||||
device_state = DeviceState::TagMounted;
|
||||
mount_target = mount_target_;
|
||||
|
||||
if (!is_corrupted && mount_target != NFP::MountTarget::Rom) {
|
||||
const bool create_backup =
|
||||
mount_target == NFP::MountTarget::All || mount_target == NFP::MountTarget::Ram ||
|
||||
(mount_target == NFP::MountTarget::Rom && HasBackup(encrypted_tag_data.uuid).IsError());
|
||||
if (!is_corrupted && create_backup) {
|
||||
std::vector<u8> data(sizeof(NFP::EncryptedNTAG215File));
|
||||
memcpy(data.data(), &encrypted_tag_data, sizeof(encrypted_tag_data));
|
||||
WriteBackupData(encrypted_tag_data.uuid, data);
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
namespace Service::Nvidia::NvCore {
|
||||
|
||||
Session::Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_)
|
||||
: id{id_}, process{process_}, smmu_id{smmu_id_},
|
||||
has_preallocated_area{}, mapper{}, is_active{} {}
|
||||
Session::Session(SessionId id_, Kernel::KProcess* process_, Core::Asid asid_)
|
||||
: id{id_}, process{process_}, asid{asid_}, has_preallocated_area{}, mapper{}, is_active{} {}
|
||||
|
||||
Session::~Session() = default;
|
||||
|
||||
@ -41,7 +40,9 @@ Container::Container(Tegra::Host1x::Host1x& host1x_) {
|
||||
|
||||
Container::~Container() = default;
|
||||
|
||||
size_t Container::OpenSession(Kernel::KProcess* process) {
|
||||
SessionId Container::OpenSession(Kernel::KProcess* process) {
|
||||
using namespace Common::Literals;
|
||||
|
||||
std::scoped_lock lk(impl->session_guard);
|
||||
for (auto& session : impl->sessions) {
|
||||
if (!session.is_active) {
|
||||
@ -54,14 +55,14 @@ size_t Container::OpenSession(Kernel::KProcess* process) {
|
||||
size_t new_id{};
|
||||
auto* memory_interface = &process->GetMemory();
|
||||
auto& smmu = impl->host1x.MemoryManager();
|
||||
auto smmu_id = smmu.RegisterProcess(memory_interface);
|
||||
auto asid = smmu.RegisterProcess(memory_interface);
|
||||
if (!impl->id_pool.empty()) {
|
||||
new_id = impl->id_pool.front();
|
||||
impl->id_pool.pop_front();
|
||||
impl->sessions[new_id] = Session{new_id, process, smmu_id};
|
||||
impl->sessions[new_id] = Session{SessionId{new_id}, process, asid};
|
||||
} else {
|
||||
new_id = impl->new_ids++;
|
||||
impl->sessions.emplace_back(new_id, process, smmu_id);
|
||||
impl->sessions.emplace_back(SessionId{new_id}, process, asid);
|
||||
}
|
||||
auto& session = impl->sessions[new_id];
|
||||
session.is_active = true;
|
||||
@ -80,7 +81,7 @@ size_t Container::OpenSession(Kernel::KProcess* process) {
|
||||
cur_addr));
|
||||
auto svc_mem_info = mem_info.GetSvcMemoryInfo();
|
||||
|
||||
// check if this memory block is heap
|
||||
// Check if this memory block is heap.
|
||||
if (svc_mem_info.state == Kernel::Svc::MemoryState::Normal) {
|
||||
if (svc_mem_info.size > region_size) {
|
||||
region_size = svc_mem_info.size;
|
||||
@ -97,21 +98,21 @@ size_t Container::OpenSession(Kernel::KProcess* process) {
|
||||
cur_addr = next_address;
|
||||
}
|
||||
session.has_preallocated_area = false;
|
||||
auto start_region = (region_size >> 15) >= 1024 ? smmu.Allocate(region_size) : 0;
|
||||
auto start_region = region_size >= 32_MiB ? smmu.Allocate(region_size) : 0;
|
||||
if (start_region != 0) {
|
||||
session.mapper = std::make_unique<HeapMapper>(region_start, start_region, region_size,
|
||||
smmu_id, impl->host1x);
|
||||
smmu.TrackContinuity(start_region, region_start, region_size, smmu_id);
|
||||
asid, impl->host1x);
|
||||
smmu.TrackContinuity(start_region, region_start, region_size, asid);
|
||||
session.has_preallocated_area = true;
|
||||
LOG_CRITICAL(Debug, "Preallocation created!");
|
||||
LOG_DEBUG(Debug, "Preallocation created!");
|
||||
}
|
||||
}
|
||||
return new_id;
|
||||
return SessionId{new_id};
|
||||
}
|
||||
|
||||
void Container::CloseSession(size_t id) {
|
||||
void Container::CloseSession(SessionId session_id) {
|
||||
std::scoped_lock lk(impl->session_guard);
|
||||
auto& session = impl->sessions[id];
|
||||
auto& session = impl->sessions[session_id.id];
|
||||
auto& smmu = impl->host1x.MemoryManager();
|
||||
if (session.has_preallocated_area) {
|
||||
const DAddr region_start = session.mapper->GetRegionStart();
|
||||
@ -121,13 +122,13 @@ void Container::CloseSession(size_t id) {
|
||||
session.has_preallocated_area = false;
|
||||
}
|
||||
session.is_active = false;
|
||||
smmu.UnregisterProcess(impl->sessions[id].smmu_id);
|
||||
impl->id_pool.emplace_front(id);
|
||||
smmu.UnregisterProcess(impl->sessions[session_id.id].asid);
|
||||
impl->id_pool.emplace_front(session_id.id);
|
||||
}
|
||||
|
||||
Session* Container::GetSession(size_t id) {
|
||||
Session* Container::GetSession(SessionId session_id) {
|
||||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
return &impl->sessions[id];
|
||||
return &impl->sessions[session_id.id];
|
||||
}
|
||||
|
||||
NvMap& Container::GetNvMapFile() {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "core/device_memory_manager.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
|
||||
namespace Kernel {
|
||||
@ -26,8 +27,12 @@ class SyncpointManager;
|
||||
|
||||
struct ContainerImpl;
|
||||
|
||||
struct SessionId {
|
||||
size_t id;
|
||||
};
|
||||
|
||||
struct Session {
|
||||
Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_);
|
||||
Session(SessionId id_, Kernel::KProcess* process_, Core::Asid asid_);
|
||||
~Session();
|
||||
|
||||
Session(const Session&) = delete;
|
||||
@ -35,9 +40,9 @@ struct Session {
|
||||
Session(Session&&) = default;
|
||||
Session& operator=(Session&&) = default;
|
||||
|
||||
size_t id;
|
||||
SessionId id;
|
||||
Kernel::KProcess* process;
|
||||
size_t smmu_id;
|
||||
Core::Asid asid;
|
||||
bool has_preallocated_area{};
|
||||
std::unique_ptr<HeapMapper> mapper{};
|
||||
bool is_active{};
|
||||
@ -48,10 +53,10 @@ public:
|
||||
explicit Container(Tegra::Host1x::Host1x& host1x);
|
||||
~Container();
|
||||
|
||||
size_t OpenSession(Kernel::KProcess* process);
|
||||
void CloseSession(size_t id);
|
||||
SessionId OpenSession(Kernel::KProcess* process);
|
||||
void CloseSession(SessionId id);
|
||||
|
||||
Session* GetSession(size_t id);
|
||||
Session* GetSession(SessionId id);
|
||||
|
||||
NvMap& GetNvMapFile();
|
||||
|
||||
|
@ -109,9 +109,9 @@ struct HeapMapper::HeapMapperInternal {
|
||||
std::mutex guard;
|
||||
};
|
||||
|
||||
HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, size_t smmu_id,
|
||||
HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid,
|
||||
Tegra::Host1x::Host1x& host1x)
|
||||
: m_vaddress{start_vaddress}, m_daddress{start_daddress}, m_size{size}, m_smmu_id{smmu_id} {
|
||||
: m_vaddress{start_vaddress}, m_daddress{start_daddress}, m_size{size}, m_asid{asid} {
|
||||
m_internal = std::make_unique<HeapMapperInternal>(host1x);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ DAddr HeapMapper::Map(VAddr start, size_t size) {
|
||||
const size_t offset = inter_addr - m_vaddress;
|
||||
const size_t sub_size = inter_addr_end - inter_addr;
|
||||
m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size,
|
||||
m_smmu_id);
|
||||
m_asid);
|
||||
}
|
||||
}
|
||||
m_internal->mapping_overlaps += std::make_pair(interval, 1);
|
||||
@ -172,4 +172,4 @@ void HeapMapper::Unmap(VAddr start, size_t size) {
|
||||
m_internal->base_set.clear();
|
||||
}
|
||||
|
||||
} // namespace Service::Nvidia::NvCore
|
||||
} // namespace Service::Nvidia::NvCore
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/device_memory_manager.h"
|
||||
|
||||
namespace Tegra::Host1x {
|
||||
class Host1x;
|
||||
@ -15,7 +16,7 @@ namespace Service::Nvidia::NvCore {
|
||||
|
||||
class HeapMapper {
|
||||
public:
|
||||
HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, size_t smmu_id,
|
||||
HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid,
|
||||
Tegra::Host1x::Host1x& host1x);
|
||||
~HeapMapper();
|
||||
|
||||
@ -41,8 +42,8 @@ private:
|
||||
VAddr m_vaddress;
|
||||
DAddr m_daddress;
|
||||
size_t m_size;
|
||||
size_t m_smmu_id;
|
||||
Core::Asid m_asid;
|
||||
std::unique_ptr<HeapMapperInternal> m_internal;
|
||||
};
|
||||
|
||||
} // namespace Service::Nvidia::NvCore
|
||||
} // namespace Service::Nvidia::NvCore
|
||||
|
@ -22,7 +22,8 @@ NvMap::Handle::Handle(u64 size_, Id id_)
|
||||
flags.raw = 0;
|
||||
}
|
||||
|
||||
NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, size_t pSessionId) {
|
||||
NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress,
|
||||
NvCore::SessionId pSessionId) {
|
||||
std::scoped_lock lock(mutex);
|
||||
// Handles cannot be allocated twice
|
||||
if (allocated) {
|
||||
@ -223,7 +224,7 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, bool low_area_pin) {
|
||||
}
|
||||
|
||||
handle_description->d_address = address;
|
||||
smmu.Map(address, vaddress, map_size, session->smmu_id, true);
|
||||
smmu.Map(address, vaddress, map_size, session->asid, true);
|
||||
handle_description->in_heap = false;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
|
||||
namespace Tegra {
|
||||
@ -71,7 +72,7 @@ public:
|
||||
u8 kind{}; //!< Used for memory compression
|
||||
bool allocated{}; //!< If the handle has been allocated with `Alloc`
|
||||
bool in_heap{};
|
||||
size_t session_id{};
|
||||
NvCore::SessionId session_id{};
|
||||
|
||||
DAddr d_address{}; //!< The memory location in the device's AS that this handle corresponds
|
||||
//!< to, this can also be in the nvdrv tmem
|
||||
@ -83,7 +84,7 @@ public:
|
||||
* if a 0 address is passed
|
||||
*/
|
||||
[[nodiscard]] NvResult Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress,
|
||||
size_t pSessionId);
|
||||
NvCore::SessionId pSessionId);
|
||||
|
||||
/**
|
||||
* @brief Increases the dupe counter of the handle for the given session
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
|
||||
namespace Core {
|
||||
@ -62,7 +63,7 @@ public:
|
||||
* Called once a device is opened
|
||||
* @param fd The device fd
|
||||
*/
|
||||
virtual void OnOpen(size_t session_id, DeviceFD fd) = 0;
|
||||
virtual void OnOpen(NvCore::SessionId session_id, DeviceFD fd) = 0;
|
||||
|
||||
/**
|
||||
* Called once a device is closed
|
||||
|
@ -35,7 +35,7 @@ NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvdisp_disp0::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvdisp_disp0::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvdisp_disp0::OnClose(DeviceFD fd) {}
|
||||
|
||||
void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width,
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
/// Performs a screen flip, drawing the buffer pointed to by the handle.
|
||||
|
@ -86,7 +86,7 @@ NvResult nvhost_as_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> i
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_as_gpu::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvhost_as_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvhost_as_gpu::OnClose(DeviceFD fd) {}
|
||||
|
||||
NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) {
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
@ -76,7 +76,7 @@ NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inp
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_ctrl::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvhost_ctrl::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
|
||||
void nvhost_ctrl::OnClose(DeviceFD fd) {}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
@ -82,7 +82,7 @@ NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8>
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_ctrl_gpu::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvhost_ctrl_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvhost_ctrl_gpu::OnClose(DeviceFD fd) {}
|
||||
|
||||
NvResult nvhost_ctrl_gpu::GetCharacteristics1(IoctlCharacteristics& params) {
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
@ -120,7 +120,7 @@ NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_gpu::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvhost_gpu::OnClose(DeviceFD fd) {}
|
||||
|
||||
NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) {
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
@ -68,7 +68,7 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_nvdec::OnOpen(size_t session_id, DeviceFD fd) {
|
||||
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;
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
};
|
||||
|
||||
|
@ -127,7 +127,7 @@ protected:
|
||||
NvCore::NvMap& nvmap;
|
||||
NvCore::ChannelType channel_type;
|
||||
std::array<u32, MaxSyncPoints> device_syncpoints{};
|
||||
std::unordered_map<DeviceFD, size_t> sessions;
|
||||
std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
|
||||
};
|
||||
}; // namespace Devices
|
||||
} // namespace Service::Nvidia
|
||||
|
@ -44,7 +44,7 @@ NvResult nvhost_nvjpg::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_nvjpg::OnOpen(size_t session_id, DeviceFD fd) {}
|
||||
void nvhost_nvjpg::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvhost_nvjpg::OnClose(DeviceFD fd) {}
|
||||
|
||||
NvResult nvhost_nvjpg::SetNVMAPfd(IoctlSetNvmapFD& params) {
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
private:
|
||||
|
@ -68,7 +68,7 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvhost_vic::OnOpen(size_t session_id, DeviceFD fd) {
|
||||
void nvhost_vic::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
|
||||
sessions[fd] = session_id;
|
||||
}
|
||||
|
||||
@ -78,10 +78,7 @@ void nvhost_vic::OnClose(DeviceFD fd) {
|
||||
if (iter != host1x_file.fd_to_id.end()) {
|
||||
system.GPU().ClearCdmaInstance(iter->second);
|
||||
}
|
||||
auto it = sessions.find(fd);
|
||||
if (it != sessions.end()) {
|
||||
sessions.erase(it);
|
||||
}
|
||||
sessions.erase(fd);
|
||||
}
|
||||
|
||||
} // namespace Service::Nvidia::Devices
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
};
|
||||
} // namespace Service::Nvidia::Devices
|
||||
|
@ -67,7 +67,7 @@ NvResult nvmap::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, st
|
||||
return NvResult::NotImplemented;
|
||||
}
|
||||
|
||||
void nvmap::OnOpen(size_t session_id, DeviceFD fd) {
|
||||
void nvmap::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
|
||||
sessions[fd] = session_id;
|
||||
}
|
||||
void nvmap::OnClose(DeviceFD fd) {
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output,
|
||||
std::span<u8> inline_output) override;
|
||||
|
||||
void OnOpen(size_t session_id, DeviceFD fd) override;
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
enum class HandleParameterType : u32_le {
|
||||
@ -115,7 +115,7 @@ private:
|
||||
|
||||
NvCore::Container& container;
|
||||
NvCore::NvMap& file;
|
||||
std::unordered_map<DeviceFD, size_t> sessions;
|
||||
std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
|
||||
};
|
||||
|
||||
} // namespace Service::Nvidia::Devices
|
||||
|
@ -52,15 +52,15 @@ void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system) {
|
||||
return std::make_shared<NVDRV>(system, module, "nvdrv:a");
|
||||
};
|
||||
const auto NvdrvInterfaceFactoryForSysmodules = [&, module] {
|
||||
return std::make_shared<NVDRV>(system, module, "nvdrv:a");
|
||||
return std::make_shared<NVDRV>(system, module, "nvdrv:s");
|
||||
};
|
||||
const auto NvdrvInterfaceFactory = [&, module] {
|
||||
const auto NvdrvInterfaceFactoryForTesting = [&, module] {
|
||||
return std::make_shared<NVDRV>(system, module, "nvdrv:t");
|
||||
};
|
||||
server_manager->RegisterNamedService("nvdrv", NvdrvInterfaceFactoryForApplication);
|
||||
server_manager->RegisterNamedService("nvdrv:a", NvdrvInterfaceFactoryForApplets);
|
||||
server_manager->RegisterNamedService("nvdrv:s", NvdrvInterfaceFactoryForSysmodules);
|
||||
server_manager->RegisterNamedService("nvdrv:t", NvdrvInterfaceFactory);
|
||||
server_manager->RegisterNamedService("nvdrv:t", NvdrvInterfaceFactoryForTesting);
|
||||
server_manager->RegisterNamedService("nvmemp", std::make_shared<NVMEMP>(system));
|
||||
nvnflinger.SetNVDrvInstance(module);
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
@ -122,7 +122,7 @@ NvResult Module::VerifyFD(DeviceFD fd) const {
|
||||
return NvResult::Success;
|
||||
}
|
||||
|
||||
DeviceFD Module::Open(const std::string& device_name, size_t session_id) {
|
||||
DeviceFD Module::Open(const std::string& device_name, NvCore::SessionId session_id) {
|
||||
auto it = builders.find(device_name);
|
||||
if (it == builders.end()) {
|
||||
LOG_ERROR(Service_NVDRV, "Trying to open unknown device {}", device_name);
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
NvResult VerifyFD(DeviceFD fd) const;
|
||||
|
||||
/// Opens a device node and returns a file descriptor to it.
|
||||
DeviceFD Open(const std::string& device_name, size_t session_id);
|
||||
DeviceFD Open(const std::string& device_name, NvCore::SessionId session_id);
|
||||
|
||||
/// Sends an ioctl command to the specified file descriptor.
|
||||
NvResult Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output);
|
||||
|
@ -35,7 +35,7 @@ private:
|
||||
|
||||
u64 pid{};
|
||||
bool is_initialized{};
|
||||
size_t session_id{};
|
||||
NvCore::SessionId session_id{};
|
||||
Common::ScratchBuffer<u8> output_buffer;
|
||||
Common::ScratchBuffer<u8> inline_output_buffer;
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/math_util.h"
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
#include "core/hle/service/nvnflinger/nvnflinger.h"
|
||||
#include "core/hle/service/nvnflinger/ui/fence.h"
|
||||
@ -55,7 +56,7 @@ private:
|
||||
u32 m_buffer_nvmap_handle = 0;
|
||||
SharedMemoryPoolLayout m_pool_layout = {};
|
||||
Nvidia::DeviceFD m_nvmap_fd = {};
|
||||
size_t m_session_id = {};
|
||||
Nvidia::NvCore::SessionId m_session_id = {};
|
||||
std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group;
|
||||
|
||||
std::mutex m_guard;
|
||||
|
@ -112,9 +112,7 @@ void Nvnflinger::ShutdownLayers() {
|
||||
{
|
||||
const auto lock_guard = Lock();
|
||||
for (auto& display : displays) {
|
||||
for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) {
|
||||
display.GetLayer(layer).GetConsumer().Abandon();
|
||||
}
|
||||
display.Abandon();
|
||||
}
|
||||
|
||||
is_abandoned = true;
|
||||
@ -126,7 +124,7 @@ void Nvnflinger::ShutdownLayers() {
|
||||
|
||||
void Nvnflinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
|
||||
nvdrv = std::move(instance);
|
||||
disp_fd = nvdrv->Open("/dev/nvdisp_disp0", 0);
|
||||
disp_fd = nvdrv->Open("/dev/nvdisp_disp0", {});
|
||||
}
|
||||
|
||||
std::optional<u64> Nvnflinger::OpenDisplay(std::string_view name) {
|
||||
@ -176,24 +174,28 @@ void Nvnflinger::CreateLayerAtId(VI::Display& display, u64 layer_id) {
|
||||
display.CreateLayer(layer_id, buffer_id, nvdrv->container);
|
||||
}
|
||||
|
||||
void Nvnflinger::OpenLayer(u64 layer_id) {
|
||||
bool Nvnflinger::OpenLayer(u64 layer_id) {
|
||||
const auto lock_guard = Lock();
|
||||
|
||||
for (auto& display : displays) {
|
||||
if (auto* layer = display.FindLayer(layer_id); layer) {
|
||||
layer->Open();
|
||||
return layer->Open();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Nvnflinger::CloseLayer(u64 layer_id) {
|
||||
bool Nvnflinger::CloseLayer(u64 layer_id) {
|
||||
const auto lock_guard = Lock();
|
||||
|
||||
for (auto& display : displays) {
|
||||
if (auto* layer = display.FindLayer(layer_id); layer) {
|
||||
layer->Close();
|
||||
return layer->Close();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Nvnflinger::DestroyLayer(u64 layer_id) {
|
||||
|
@ -74,10 +74,10 @@ public:
|
||||
[[nodiscard]] std::optional<u64> CreateLayer(u64 display_id);
|
||||
|
||||
/// Opens a layer on all displays for the given layer ID.
|
||||
void OpenLayer(u64 layer_id);
|
||||
bool OpenLayer(u64 layer_id);
|
||||
|
||||
/// Closes a layer on all displays for the given layer ID.
|
||||
void CloseLayer(u64 layer_id);
|
||||
bool CloseLayer(u64 layer_id);
|
||||
|
||||
/// Destroys the given layer ID.
|
||||
void DestroyLayer(u64 layer_id);
|
||||
|
@ -22,27 +22,26 @@ constexpr Result ResultProcessNotFound{ErrorModule::PM, 1};
|
||||
|
||||
constexpr u64 NO_PROCESS_FOUND_PID{0};
|
||||
|
||||
std::optional<Kernel::KProcess*> SearchProcessList(
|
||||
const std::vector<Kernel::KProcess*>& process_list,
|
||||
std::function<bool(Kernel::KProcess*)> predicate) {
|
||||
using ProcessList = std::list<Kernel::KScopedAutoObject<Kernel::KProcess>>;
|
||||
|
||||
template <typename F>
|
||||
Kernel::KScopedAutoObject<Kernel::KProcess> SearchProcessList(ProcessList& process_list,
|
||||
F&& predicate) {
|
||||
const auto iter = std::find_if(process_list.begin(), process_list.end(), predicate);
|
||||
|
||||
if (iter == process_list.end()) {
|
||||
return std::nullopt;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return *iter;
|
||||
return iter->GetPointerUnsafe();
|
||||
}
|
||||
|
||||
void GetApplicationPidGeneric(HLERequestContext& ctx,
|
||||
const std::vector<Kernel::KProcess*>& process_list) {
|
||||
const auto process = SearchProcessList(process_list, [](const auto& proc) {
|
||||
return proc->GetProcessId() == Kernel::KProcess::ProcessIdMin;
|
||||
});
|
||||
void GetApplicationPidGeneric(HLERequestContext& ctx, ProcessList& process_list) {
|
||||
auto process = SearchProcessList(process_list, [](auto& p) { return p->IsApplication(); });
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(process.has_value() ? (*process)->GetProcessId() : NO_PROCESS_FOUND_PID);
|
||||
rb.Push(process.IsNull() ? NO_PROCESS_FOUND_PID : process->GetProcessId());
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
@ -80,8 +79,7 @@ private:
|
||||
|
||||
class DebugMonitor final : public ServiceFramework<DebugMonitor> {
|
||||
public:
|
||||
explicit DebugMonitor(Core::System& system_)
|
||||
: ServiceFramework{system_, "pm:dmnt"}, kernel{system_.Kernel()} {
|
||||
explicit DebugMonitor(Core::System& system_) : ServiceFramework{system_, "pm:dmnt"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetJitDebugProcessIdList"},
|
||||
@ -106,12 +104,11 @@ private:
|
||||
|
||||
LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id);
|
||||
|
||||
const auto process =
|
||||
SearchProcessList(kernel.GetProcessList(), [program_id](const auto& proc) {
|
||||
return proc->GetProgramId() == program_id;
|
||||
});
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process = SearchProcessList(
|
||||
list, [program_id](auto& p) { return p->GetProgramId() == program_id; });
|
||||
|
||||
if (!process.has_value()) {
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
@ -119,12 +116,13 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push((*process)->GetProcessId());
|
||||
rb.Push(process->GetProcessId());
|
||||
}
|
||||
|
||||
void GetApplicationProcessId(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
GetApplicationPidGeneric(ctx, kernel.GetProcessList());
|
||||
auto list = kernel.GetProcessList();
|
||||
GetApplicationPidGeneric(ctx, list);
|
||||
}
|
||||
|
||||
void AtmosphereGetProcessInfo(HLERequestContext& ctx) {
|
||||
@ -135,11 +133,10 @@ private:
|
||||
|
||||
LOG_WARNING(Service_PM, "(Partial Implementation) called, pid={:016X}", pid);
|
||||
|
||||
const auto process = SearchProcessList(kernel.GetProcessList(), [pid](const auto& proc) {
|
||||
return proc->GetProcessId() == pid;
|
||||
});
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process = SearchProcessList(list, [pid](auto& p) { return p->GetProcessId() == pid; });
|
||||
|
||||
if (!process.has_value()) {
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
@ -159,7 +156,7 @@ private:
|
||||
|
||||
OverrideStatus override_status{};
|
||||
ProgramLocation program_location{
|
||||
.program_id = (*process)->GetProgramId(),
|
||||
.program_id = process->GetProgramId(),
|
||||
.storage_id = 0,
|
||||
};
|
||||
|
||||
@ -169,14 +166,11 @@ private:
|
||||
rb.PushRaw(program_location);
|
||||
rb.PushRaw(override_status);
|
||||
}
|
||||
|
||||
const Kernel::KernelCore& kernel;
|
||||
};
|
||||
|
||||
class Info final : public ServiceFramework<Info> {
|
||||
public:
|
||||
explicit Info(Core::System& system_, const std::vector<Kernel::KProcess*>& process_list_)
|
||||
: ServiceFramework{system_, "pm:info"}, process_list{process_list_} {
|
||||
explicit Info(Core::System& system_) : ServiceFramework{system_, "pm:info"} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &Info::GetProgramId, "GetProgramId"},
|
||||
{65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"},
|
||||
@ -193,11 +187,11 @@ private:
|
||||
|
||||
LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id);
|
||||
|
||||
const auto process = SearchProcessList(process_list, [process_id](const auto& proc) {
|
||||
return proc->GetProcessId() == process_id;
|
||||
});
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process = SearchProcessList(
|
||||
list, [process_id](auto& p) { return p->GetProcessId() == process_id; });
|
||||
|
||||
if (!process.has_value()) {
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
@ -205,7 +199,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push((*process)->GetProgramId());
|
||||
rb.Push(process->GetProgramId());
|
||||
}
|
||||
|
||||
void AtmosphereGetProcessId(HLERequestContext& ctx) {
|
||||
@ -214,11 +208,11 @@ private:
|
||||
|
||||
LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id);
|
||||
|
||||
const auto process = SearchProcessList(process_list, [program_id](const auto& proc) {
|
||||
return proc->GetProgramId() == program_id;
|
||||
});
|
||||
auto list = system.Kernel().GetProcessList();
|
||||
auto process = SearchProcessList(
|
||||
list, [program_id](auto& p) { return p->GetProgramId() == program_id; });
|
||||
|
||||
if (!process.has_value()) {
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
@ -226,16 +220,13 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push((*process)->GetProcessId());
|
||||
rb.Push(process->GetProcessId());
|
||||
}
|
||||
|
||||
const std::vector<Kernel::KProcess*>& process_list;
|
||||
};
|
||||
|
||||
class Shell final : public ServiceFramework<Shell> {
|
||||
public:
|
||||
explicit Shell(Core::System& system_)
|
||||
: ServiceFramework{system_, "pm:shell"}, kernel{system_.Kernel()} {
|
||||
explicit Shell(Core::System& system_) : ServiceFramework{system_, "pm:shell"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "LaunchProgram"},
|
||||
@ -257,10 +248,9 @@ public:
|
||||
private:
|
||||
void GetApplicationProcessIdForShell(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
GetApplicationPidGeneric(ctx, kernel.GetProcessList());
|
||||
auto list = kernel.GetProcessList();
|
||||
GetApplicationPidGeneric(ctx, list);
|
||||
}
|
||||
|
||||
const Kernel::KernelCore& kernel;
|
||||
};
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
@ -268,8 +258,7 @@ void LoopProcess(Core::System& system) {
|
||||
|
||||
server_manager->RegisterNamedService("pm:bm", std::make_shared<BootMode>(system));
|
||||
server_manager->RegisterNamedService("pm:dmnt", std::make_shared<DebugMonitor>(system));
|
||||
server_manager->RegisterNamedService(
|
||||
"pm:info", std::make_shared<Info>(system, system.Kernel().GetProcessList()));
|
||||
server_manager->RegisterNamedService("pm:info", std::make_shared<Info>(system));
|
||||
server_manager->RegisterNamedService("pm:shell", std::make_shared<Shell>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/time/clock_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
/// This is nn::settings::system::InitialLaunchFlag
|
||||
struct InitialLaunchFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> InitialLaunchCompletionFlag;
|
||||
BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
|
||||
BitField<16, 1, u32> InitialLaunchTimestampFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::InitialLaunchSettings
|
||||
struct InitialLaunchSettings {
|
||||
InitialLaunchFlag flags;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
Service::Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
|
||||
|
||||
#pragma pack(push, 4)
|
||||
struct InitialLaunchSettingsPacked {
|
||||
InitialLaunchFlag flags;
|
||||
Service::Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,
|
||||
"InitialLaunchSettingsPacked is incorrect size");
|
||||
|
||||
struct PrivateSettings {
|
||||
std::array<u8, 0x10> reserved_00;
|
||||
|
||||
// nn::settings::system::InitialLaunchSettings
|
||||
InitialLaunchSettings initial_launch_settings;
|
||||
|
||||
std::array<u8, 0x20> reserved_30;
|
||||
|
||||
Common::UUID external_clock_source_id;
|
||||
s64 shutdown_rtc_value;
|
||||
s64 external_steady_clock_internal_offset;
|
||||
|
||||
std::array<u8, 0x60> reserved_70;
|
||||
|
||||
// nn::settings::system::PlatformRegion
|
||||
std::array<u8, 0x4> platform_region;
|
||||
|
||||
std::array<u8, 0x4> reserved_D4;
|
||||
};
|
||||
static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10);
|
||||
static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50);
|
||||
static_assert(offsetof(PrivateSettings, reserved_70) == 0x70);
|
||||
static_assert(offsetof(PrivateSettings, platform_region) == 0xD0);
|
||||
static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!");
|
||||
|
||||
PrivateSettings DefaultPrivateSettings();
|
||||
|
||||
} // namespace Service::Set
|
@ -1,12 +1,16 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/appln_settings.h"
|
||||
#include "core/hle/service/set/setting_formats/appln_settings.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
ApplnSettings DefaultApplnSettings() {
|
||||
return {};
|
||||
ApplnSettings settings{};
|
||||
|
||||
settings.mii_author_id = Common::UUID::MakeDefault();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
} // namespace Service::Set
|
@ -7,24 +7,23 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/set/settings_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
struct ApplnSettings {
|
||||
std::array<u8, 0x10> reserved_000;
|
||||
INSERT_PADDING_BYTES(0x10); // Reserved
|
||||
|
||||
// nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0
|
||||
std::array<u8, 0x10> mii_author_id;
|
||||
|
||||
std::array<u8, 0x30> reserved_020;
|
||||
Common::UUID mii_author_id;
|
||||
INSERT_PADDING_BYTES(0x30); // Reserved
|
||||
|
||||
// nn::settings::system::ServiceDiscoveryControlSettings
|
||||
std::array<u8, 0x4> service_discovery_control_settings;
|
||||
|
||||
std::array<u8, 0x20> reserved_054;
|
||||
u32 service_discovery_control_settings;
|
||||
INSERT_PADDING_BYTES(0x20); // Reserved
|
||||
|
||||
bool in_repair_process_enable_flag;
|
||||
|
||||
std::array<u8, 0x3> pad_075;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
};
|
||||
static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10);
|
||||
static_assert(offsetof(ApplnSettings, service_discovery_control_settings) == 0x50);
|
@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/device_settings.h"
|
||||
#include "core/hle/service/set/setting_formats/device_settings.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
@ -7,10 +7,12 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/vector_math.h"
|
||||
#include "core/hle/service/set/settings_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
struct DeviceSettings {
|
||||
std::array<u8, 0x10> reserved_000;
|
||||
INSERT_PADDING_BYTES(0x10); // Reserved
|
||||
|
||||
// nn::settings::BatteryLot
|
||||
std::array<u8, 0x18> ptm_battery_lot;
|
||||
@ -19,26 +21,24 @@ struct DeviceSettings {
|
||||
u8 ptm_battery_version;
|
||||
// nn::settings::system::PtmCycleCountReliability
|
||||
u32 ptm_cycle_count_reliability;
|
||||
|
||||
std::array<u8, 0x48> reserved_048;
|
||||
INSERT_PADDING_BYTES(0x48); // Reserved
|
||||
|
||||
// nn::settings::system::AnalogStickUserCalibration L
|
||||
std::array<u8, 0x10> analog_user_stick_calibration_l;
|
||||
// nn::settings::system::AnalogStickUserCalibration R
|
||||
std::array<u8, 0x10> analog_user_stick_calibration_r;
|
||||
|
||||
std::array<u8, 0x20> reserved_0B0;
|
||||
INSERT_PADDING_BYTES(0x20); // Reserved
|
||||
|
||||
// nn::settings::system::ConsoleSixAxisSensorAccelerationBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_acceleration_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_angular_velocity_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAccelerationGain
|
||||
std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
|
||||
std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_angular_velocity_time_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
|
||||
std::array<u8, 0x24> console_six_axis_sensor_angular_acceleration;
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/private_settings.h"
|
||||
#include "core/hle/service/set/setting_formats/private_settings.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
39
src/core/hle/service/set/setting_formats/private_settings.h
Normal file
39
src/core/hle/service/set/setting_formats/private_settings.h
Normal file
@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/set/settings_types.h"
|
||||
#include "core/hle/service/time/clock_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
struct PrivateSettings {
|
||||
INSERT_PADDING_BYTES(0x10); // Reserved
|
||||
|
||||
InitialLaunchSettings initial_launch_settings;
|
||||
INSERT_PADDING_BYTES(0x20); // Reserved
|
||||
|
||||
Common::UUID external_clock_source_id;
|
||||
s64 shutdown_rtc_value;
|
||||
s64 external_steady_clock_internal_offset;
|
||||
INSERT_PADDING_BYTES(0x60); // Reserved
|
||||
|
||||
// nn::settings::system::PlatformRegion
|
||||
s32 platform_region;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
};
|
||||
static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10);
|
||||
static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50);
|
||||
static_assert(offsetof(PrivateSettings, shutdown_rtc_value) == 0x60);
|
||||
static_assert(offsetof(PrivateSettings, external_steady_clock_internal_offset) == 0x68);
|
||||
static_assert(offsetof(PrivateSettings, platform_region) == 0xD0);
|
||||
static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!");
|
||||
|
||||
PrivateSettings DefaultPrivateSettings();
|
||||
|
||||
} // namespace Service::Set
|
@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/system_settings.h"
|
||||
#include "core/hle/service/set/setting_formats/system_settings.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
@ -11,6 +11,8 @@ SystemSettings DefaultSystemSettings() {
|
||||
settings.version = 0x140000;
|
||||
settings.flags = 7;
|
||||
|
||||
settings.mii_author_id = Common::UUID::MakeDefault();
|
||||
|
||||
settings.color_set_id = ColorSet::BasicWhite;
|
||||
|
||||
settings.notification_settings = {
|
||||
@ -45,6 +47,10 @@ SystemSettings DefaultSystemSettings() {
|
||||
settings.device_time_zone_location_name = {"UTC"};
|
||||
settings.user_system_clock_automatic_correction_enabled = false;
|
||||
|
||||
settings.primary_album_storage = PrimaryAlbumStorage::SdCard;
|
||||
settings.battery_percentage_flag = true;
|
||||
settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
@ -8,272 +8,14 @@
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/set/private_settings.h"
|
||||
#include "common/uuid.h"
|
||||
#include "common/vector_math.h"
|
||||
#include "core/hle/service/set/setting_formats/private_settings.h"
|
||||
#include "core/hle/service/set/settings_types.h"
|
||||
#include "core/hle/service/time/clock_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64.
|
||||
enum class LanguageCode : u64 {
|
||||
JA = 0x000000000000616A,
|
||||
EN_US = 0x00000053552D6E65,
|
||||
FR = 0x0000000000007266,
|
||||
DE = 0x0000000000006564,
|
||||
IT = 0x0000000000007469,
|
||||
ES = 0x0000000000007365,
|
||||
ZH_CN = 0x0000004E432D687A,
|
||||
KO = 0x0000000000006F6B,
|
||||
NL = 0x0000000000006C6E,
|
||||
PT = 0x0000000000007470,
|
||||
RU = 0x0000000000007572,
|
||||
ZH_TW = 0x00000057542D687A,
|
||||
EN_GB = 0x00000042472D6E65,
|
||||
FR_CA = 0x00000041432D7266,
|
||||
ES_419 = 0x00003931342D7365,
|
||||
ZH_HANS = 0x00736E61482D687A,
|
||||
ZH_HANT = 0x00746E61482D687A,
|
||||
PT_BR = 0x00000052422D7470,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ErrorReportSharePermission
|
||||
enum class ErrorReportSharePermission : u32 {
|
||||
NotConfirmed,
|
||||
Granted,
|
||||
Denied,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ChineseTraditionalInputMethod
|
||||
enum class ChineseTraditionalInputMethod : u32 {
|
||||
Unknown0 = 0,
|
||||
Unknown1 = 1,
|
||||
Unknown2 = 2,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::HomeMenuScheme
|
||||
struct HomeMenuScheme {
|
||||
u32 main;
|
||||
u32 back;
|
||||
u32 sub;
|
||||
u32 bezel;
|
||||
u32 extra;
|
||||
};
|
||||
static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
|
||||
|
||||
/// Indicates the current theme set by the system settings
|
||||
enum class ColorSet : u32 {
|
||||
BasicWhite = 0,
|
||||
BasicBlack = 1,
|
||||
};
|
||||
|
||||
/// Indicates the current console is a retail or kiosk unit
|
||||
enum class QuestFlag : u8 {
|
||||
Retail = 0,
|
||||
Kiosk = 1,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::RegionCode
|
||||
enum class RegionCode : u32 {
|
||||
Japan,
|
||||
Usa,
|
||||
Europe,
|
||||
Australia,
|
||||
HongKongTaiwanKorea,
|
||||
China,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::AccountSettings
|
||||
struct AccountSettings {
|
||||
u32 flags;
|
||||
};
|
||||
static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::NotificationVolume
|
||||
enum class NotificationVolume : u32 {
|
||||
Mute,
|
||||
Low,
|
||||
High,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::NotificationFlag
|
||||
struct NotificationFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> RingtoneFlag;
|
||||
BitField<1, 1, u32> DownloadCompletionFlag;
|
||||
BitField<8, 1, u32> EnablesNews;
|
||||
BitField<9, 1, u32> IncomingLampFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::NotificationTime
|
||||
struct NotificationTime {
|
||||
u32 hour;
|
||||
u32 minute;
|
||||
};
|
||||
static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::NotificationSettings
|
||||
struct NotificationSettings {
|
||||
NotificationFlag flags;
|
||||
NotificationVolume volume;
|
||||
NotificationTime start_time;
|
||||
NotificationTime stop_time;
|
||||
};
|
||||
static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::AccountNotificationFlag
|
||||
struct AccountNotificationFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> FriendOnlineFlag;
|
||||
BitField<1, 1, u32> FriendRequestFlag;
|
||||
BitField<8, 1, u32> CoralInvitationFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::FriendPresenceOverlayPermission
|
||||
enum class FriendPresenceOverlayPermission : u8 {
|
||||
NotConfirmed,
|
||||
NoDisplay,
|
||||
FavoriteFriends,
|
||||
Friends,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::AccountNotificationSettings
|
||||
struct AccountNotificationSettings {
|
||||
Common::UUID uid;
|
||||
AccountNotificationFlag flags;
|
||||
FriendPresenceOverlayPermission friend_presence_permission;
|
||||
FriendPresenceOverlayPermission friend_invitation_permission;
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
};
|
||||
static_assert(sizeof(AccountNotificationSettings) == 0x18,
|
||||
"AccountNotificationSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::TvFlag
|
||||
struct TvFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> Allows4k;
|
||||
BitField<1, 1, u32> Allows3d;
|
||||
BitField<2, 1, u32> AllowsCec;
|
||||
BitField<3, 1, u32> PreventsScreenBurnIn;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::TvResolution
|
||||
enum class TvResolution : u32 {
|
||||
Auto,
|
||||
Resolution1080p,
|
||||
Resolution720p,
|
||||
Resolution480p,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::HdmiContentType
|
||||
enum class HdmiContentType : u32 {
|
||||
None,
|
||||
Graphics,
|
||||
Cinema,
|
||||
Photo,
|
||||
Game,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::RgbRange
|
||||
enum class RgbRange : u32 {
|
||||
Auto,
|
||||
Full,
|
||||
Limited,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::CmuMode
|
||||
enum class CmuMode : u32 {
|
||||
None,
|
||||
ColorInvert,
|
||||
HighContrast,
|
||||
GrayScale,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::TvSettings
|
||||
struct TvSettings {
|
||||
TvFlag flags;
|
||||
TvResolution tv_resolution;
|
||||
HdmiContentType hdmi_content_type;
|
||||
RgbRange rgb_range;
|
||||
CmuMode cmu_mode;
|
||||
u32 tv_underscan;
|
||||
f32 tv_gama;
|
||||
f32 contrast_ratio;
|
||||
};
|
||||
static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::PrimaryAlbumStorage
|
||||
enum class PrimaryAlbumStorage : u32 {
|
||||
Nand,
|
||||
SdCard,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::HandheldSleepPlan
|
||||
enum class HandheldSleepPlan : u32 {
|
||||
Sleep1Min,
|
||||
Sleep3Min,
|
||||
Sleep5Min,
|
||||
Sleep10Min,
|
||||
Sleep30Min,
|
||||
Never,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ConsoleSleepPlan
|
||||
enum class ConsoleSleepPlan : u32 {
|
||||
Sleep1Hour,
|
||||
Sleep2Hour,
|
||||
Sleep3Hour,
|
||||
Sleep6Hour,
|
||||
Sleep12Hour,
|
||||
Never,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::SleepFlag
|
||||
struct SleepFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> SleepsWhilePlayingMedia;
|
||||
BitField<1, 1, u32> WakesAtPowerStateChange;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::SleepSettings
|
||||
struct SleepSettings {
|
||||
SleepFlag flags;
|
||||
HandheldSleepPlan handheld_sleep_plan;
|
||||
ConsoleSleepPlan console_sleep_plan;
|
||||
};
|
||||
static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
|
||||
|
||||
/// This is nn::settings::system::EulaVersionClockType
|
||||
enum class EulaVersionClockType : u32 {
|
||||
NetworkSystemClock,
|
||||
SteadyClock,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::EulaVersion
|
||||
struct EulaVersion {
|
||||
u32 version;
|
||||
RegionCode region_code;
|
||||
EulaVersionClockType clock_type;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
s64 posix_time;
|
||||
Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
||||
|
||||
struct SystemSettings {
|
||||
// 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000
|
||||
// (5.0.0-5.1.0), 0x60000 (6.0.0-6.2.0), 0x70000 (7.0.0), 0x80000 (8.0.0-8.1.1), 0x90000
|
||||
@ -283,20 +25,16 @@ struct SystemSettings {
|
||||
// 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+).
|
||||
// if (flags & 2), defaults are written for AnalogStickUserCalibration
|
||||
u32 flags;
|
||||
INSERT_PADDING_BYTES(0x8); // Reserved
|
||||
|
||||
std::array<u8, 0x8> reserved_00008;
|
||||
|
||||
// nn::settings::LanguageCode
|
||||
LanguageCode language_code;
|
||||
|
||||
std::array<u8, 0x38> reserved_00018;
|
||||
INSERT_PADDING_BYTES(0x38); // Reserved
|
||||
|
||||
// nn::settings::system::NetworkSettings
|
||||
u32 network_setting_count;
|
||||
bool wireless_lan_enable_flag;
|
||||
std::array<u8, 0x3> pad_00055;
|
||||
|
||||
std::array<u8, 0x8> reserved_00058;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x8); // Reserved
|
||||
|
||||
// nn::settings::system::NetworkSettings
|
||||
std::array<std::array<u8, 0x400>, 32> network_settings_1B0;
|
||||
@ -304,161 +42,142 @@ struct SystemSettings {
|
||||
// nn::settings::system::BluetoothDevicesSettings
|
||||
std::array<u8, 0x4> bluetooth_device_settings_count;
|
||||
bool bluetooth_enable_flag;
|
||||
std::array<u8, 0x3> pad_08065;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
bool bluetooth_afh_enable_flag;
|
||||
std::array<u8, 0x3> pad_08069;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
bool bluetooth_boost_enable_flag;
|
||||
std::array<u8, 0x3> pad_0806D;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
std::array<std::array<u8, 0x200>, 10> bluetooth_device_settings_first_10;
|
||||
|
||||
s32 ldn_channel;
|
||||
|
||||
std::array<u8, 0x3C> reserved_09474;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
// nn::util::Uuid MiiAuthorId
|
||||
std::array<u8, 0x10> mii_author_id;
|
||||
Common::UUID mii_author_id;
|
||||
|
||||
std::array<u8, 0x30> reserved_094C0;
|
||||
INSERT_PADDING_BYTES(0x30); // Reserved
|
||||
|
||||
// nn::settings::system::NxControllerSettings
|
||||
u32 nx_controller_settings_count;
|
||||
|
||||
std::array<u8, 0xC> reserved_094F4;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
|
||||
// nn::settings::system::NxControllerSettings,
|
||||
// nn::settings::system::NxControllerLegacySettings on 13.0.0+
|
||||
std::array<std::array<u8, 0x40>, 10> nx_controller_legacy_settings;
|
||||
|
||||
std::array<u8, 0x170> reserved_09780;
|
||||
INSERT_PADDING_BYTES(0x170); // Reserved
|
||||
|
||||
bool external_rtc_reset_flag;
|
||||
std::array<u8, 0x3> pad_098F1;
|
||||
|
||||
std::array<u8, 0x3C> reserved_098F4;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
s32 push_notification_activity_mode_on_sleep;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
std::array<u8, 0x3C> reserved_09934;
|
||||
|
||||
// nn::settings::system::ErrorReportSharePermission
|
||||
ErrorReportSharePermission error_report_share_permission;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
std::array<u8, 0x3C> reserved_09974;
|
||||
|
||||
// nn::settings::KeyboardLayout
|
||||
std::array<u8, 0x4> keyboard_layout;
|
||||
|
||||
std::array<u8, 0x3C> reserved_099B4;
|
||||
KeyboardLayout keyboard_layout;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
bool web_inspector_flag;
|
||||
std::array<u8, 0x3> pad_099F1;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
|
||||
// nn::settings::system::AllowedSslHost
|
||||
u32 allowed_ssl_host_count;
|
||||
|
||||
bool memory_usage_rate_flag;
|
||||
std::array<u8, 0x3> pad_099F9;
|
||||
|
||||
std::array<u8, 0x34> reserved_099FC;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x34); // Reserved
|
||||
|
||||
// nn::settings::system::HostFsMountPoint
|
||||
std::array<u8, 0x100> host_fs_mount_point;
|
||||
|
||||
// nn::settings::system::AllowedSslHost
|
||||
std::array<std::array<u8, 0x100>, 8> allowed_ssl_hosts;
|
||||
|
||||
std::array<u8, 0x6C0> reserved_0A330;
|
||||
INSERT_PADDING_BYTES(0x6C0); // Reserved
|
||||
|
||||
// nn::settings::system::BlePairingSettings
|
||||
u32 ble_pairing_settings_count;
|
||||
std::array<u8, 0xC> reserved_0A9F4;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
std::array<std::array<u8, 0x80>, 10> ble_pairing_settings;
|
||||
|
||||
// nn::settings::system::AccountOnlineStorageSettings
|
||||
u32 account_online_storage_settings_count;
|
||||
std::array<u8, 0xC> reserved_0AF04;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
std::array<std::array<u8, 0x40>, 8> account_online_storage_settings;
|
||||
|
||||
bool pctl_ready_flag;
|
||||
std::array<u8, 0x3> pad_0B111;
|
||||
|
||||
std::array<u8, 0x3C> reserved_0B114;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
// nn::settings::system::ThemeId
|
||||
std::array<u8, 0x80> theme_id_type0;
|
||||
std::array<u8, 0x80> theme_id_type1;
|
||||
INSERT_PADDING_BYTES(0x100); // Reserved
|
||||
|
||||
std::array<u8, 0x100> reserved_0B250;
|
||||
|
||||
// nn::settings::ChineseTraditionalInputMethod
|
||||
ChineseTraditionalInputMethod chinese_traditional_input_method;
|
||||
|
||||
std::array<u8, 0x3C> reserved_0B354;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
bool zoom_flag;
|
||||
std::array<u8, 0x3> pad_0B391;
|
||||
|
||||
std::array<u8, 0x3C> reserved_0B394;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
// nn::settings::system::ButtonConfigRegisteredSettings
|
||||
u32 button_config_registered_settings_count;
|
||||
std::array<u8, 0xC> reserved_0B3D4;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
|
||||
// nn::settings::system::ButtonConfigSettings
|
||||
u32 button_config_settings_count;
|
||||
std::array<u8, 0x4> reserved_0B3E4;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
std::array<std::array<u8, 0x5A8>, 5> button_config_settings;
|
||||
std::array<u8, 0x13B0> reserved_0D030;
|
||||
INSERT_PADDING_BYTES(0x13B0); // Reserved
|
||||
u32 button_config_settings_embedded_count;
|
||||
std::array<u8, 0x4> reserved_0E3E4;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
std::array<std::array<u8, 0x5A8>, 5> button_config_settings_embedded;
|
||||
std::array<u8, 0x13B0> reserved_10030;
|
||||
INSERT_PADDING_BYTES(0x13B0); // Reserved
|
||||
u32 button_config_settings_left_count;
|
||||
std::array<u8, 0x4> reserved_113E4;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
std::array<std::array<u8, 0x5A8>, 5> button_config_settings_left;
|
||||
std::array<u8, 0x13B0> reserved_13030;
|
||||
INSERT_PADDING_BYTES(0x13B0); // Reserved
|
||||
u32 button_config_settings_right_count;
|
||||
std::array<u8, 0x4> reserved_143E4;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
std::array<std::array<u8, 0x5A8>, 5> button_config_settings_right;
|
||||
std::array<u8, 0x73B0> reserved_16030;
|
||||
INSERT_PADDING_BYTES(0x73B0); // Reserved
|
||||
// nn::settings::system::ButtonConfigRegisteredSettings
|
||||
std::array<u8, 0x5C8> button_config_registered_settings_embedded;
|
||||
std::array<std::array<u8, 0x5C8>, 10> button_config_registered_settings;
|
||||
|
||||
std::array<u8, 0x7FF8> reserved_21378;
|
||||
INSERT_PADDING_BYTES(0x7FF8); // Reserved
|
||||
|
||||
// nn::settings::system::ConsoleSixAxisSensorAccelerationBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_acceleration_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_angular_velocity_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAccelerationGain
|
||||
std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
|
||||
std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
|
||||
std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias;
|
||||
Common::Vec3<f32> console_six_axis_sensor_angular_velocity_time_bias;
|
||||
// nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
|
||||
std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_acceleration;
|
||||
|
||||
std::array<u8, 0x70> reserved_29400;
|
||||
INSERT_PADDING_BYTES(0x70); // Reserved
|
||||
|
||||
bool lock_screen_flag;
|
||||
std::array<u8, 0x3> pad_29471;
|
||||
|
||||
std::array<u8, 0x4> reserved_249274;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
|
||||
ColorSet color_set_id;
|
||||
|
||||
QuestFlag quest_flag;
|
||||
|
||||
// nn::settings::system::RegionCode
|
||||
RegionCode region_code;
|
||||
SystemRegionCode region_code;
|
||||
|
||||
// Different to nn::settings::system::InitialLaunchSettings?
|
||||
InitialLaunchSettingsPacked initial_launch_settings_packed;
|
||||
|
||||
bool battery_percentage_flag;
|
||||
std::array<u8, 0x3> pad_294A1;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
|
||||
// BitFlagSet<32, nn::settings::system::AppletLaunchFlag>
|
||||
u32 applet_launch_flag;
|
||||
@ -469,33 +188,26 @@ struct SystemSettings {
|
||||
std::array<u8, 0x10> theme_key;
|
||||
|
||||
bool field_testing_flag;
|
||||
std::array<u8, 0x3> pad_294C1;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
|
||||
s32 panel_crc_mode;
|
||||
|
||||
std::array<u8, 0x28> reserved_294C8;
|
||||
INSERT_PADDING_BYTES(0x28); // Reserved
|
||||
|
||||
// nn::settings::system::BacklightSettings
|
||||
std::array<u8, 0x2C> backlight_settings_mixed_up;
|
||||
INSERT_PADDING_BYTES(0x64); // Reserved
|
||||
|
||||
std::array<u8, 0x64> reserved_2951C;
|
||||
|
||||
// nn::time::SystemClockContext
|
||||
Service::Time::Clock::SystemClockContext user_system_clock_context;
|
||||
Service::Time::Clock::SystemClockContext network_system_clock_context;
|
||||
bool user_system_clock_automatic_correction_enabled;
|
||||
std::array<u8, 0x3> pad_295C1;
|
||||
std::array<u8, 0x4> reserved_295C4;
|
||||
// nn::time::SteadyClockTimePoint
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
Service::Time::Clock::SteadyClockTimePoint
|
||||
user_system_clock_automatic_correction_updated_time_point;
|
||||
INSERT_PADDING_BYTES(0x10); // Reserved
|
||||
|
||||
std::array<u8, 0x10> reserved_295E0;
|
||||
|
||||
// nn::settings::system::AccountSettings
|
||||
AccountSettings account_settings;
|
||||
|
||||
std::array<u8, 0xFC> reserved_295F4;
|
||||
INSERT_PADDING_BYTES(0xFC); // Reserved
|
||||
|
||||
// nn::settings::system::AudioVolume
|
||||
std::array<u8, 0x8> audio_volume_type0;
|
||||
@ -505,47 +217,42 @@ struct SystemSettings {
|
||||
s32 audio_output_mode_type1;
|
||||
s32 audio_output_mode_type2;
|
||||
bool force_mute_on_headphone_removed;
|
||||
std::array<u8, 0x3> pad_2970D;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
s32 headphone_volume_warning_count;
|
||||
bool heaphone_volume_update_flag;
|
||||
std::array<u8, 0x3> pad_29715;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
// nn::settings::system::AudioVolume
|
||||
std::array<u8, 0x8> audio_volume_type2;
|
||||
// nn::settings::system::AudioOutputMode
|
||||
s32 audio_output_mode_type3;
|
||||
s32 audio_output_mode_type4;
|
||||
bool hearing_protection_safeguard_flag;
|
||||
std::array<u8, 0x3> pad_29729;
|
||||
std::array<u8, 0x4> reserved_2972C;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
s64 hearing_protection_safeguard_remaining_time;
|
||||
std::array<u8, 0x38> reserved_29738;
|
||||
INSERT_PADDING_BYTES(0x38); // Reserved
|
||||
|
||||
bool console_information_upload_flag;
|
||||
std::array<u8, 0x3> pad_29771;
|
||||
|
||||
std::array<u8, 0x3C> reserved_29774;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
bool automatic_application_download_flag;
|
||||
std::array<u8, 0x3> pad_297B1;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
|
||||
std::array<u8, 0x4> reserved_297B4;
|
||||
|
||||
// nn::settings::system::NotificationSettings
|
||||
NotificationSettings notification_settings;
|
||||
|
||||
std::array<u8, 0x60> reserved_297D0;
|
||||
INSERT_PADDING_BYTES(0x60); // Reserved
|
||||
|
||||
// nn::settings::system::AccountNotificationSettings
|
||||
u32 account_notification_settings_count;
|
||||
std::array<u8, 0xC> reserved_29834;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
std::array<AccountNotificationSettings, 8> account_notification_settings;
|
||||
|
||||
std::array<u8, 0x140> reserved_29900;
|
||||
INSERT_PADDING_BYTES(0x140); // Reserved
|
||||
|
||||
f32 vibration_master_volume;
|
||||
|
||||
bool usb_full_key_enable_flag;
|
||||
std::array<u8, 0x3> pad_29A45;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
|
||||
// nn::settings::system::AnalogStickUserCalibration
|
||||
std::array<u8, 0x10> analog_stick_user_calibration_left;
|
||||
@ -553,85 +260,68 @@ struct SystemSettings {
|
||||
|
||||
// nn::settings::system::TouchScreenMode
|
||||
s32 touch_screen_mode;
|
||||
INSERT_PADDING_BYTES(0x14); // Reserved
|
||||
|
||||
std::array<u8, 0x14> reserved_29A6C;
|
||||
|
||||
// nn::settings::system::TvSettings
|
||||
TvSettings tv_settings;
|
||||
|
||||
// nn::settings::system::Edid
|
||||
std::array<u8, 0x100> edid;
|
||||
|
||||
std::array<u8, 0x2E0> reserved_29BA0;
|
||||
INSERT_PADDING_BYTES(0x2E0); // Reserved
|
||||
|
||||
// nn::settings::system::DataDeletionSettings
|
||||
std::array<u8, 0x8> data_deletion_settings;
|
||||
|
||||
std::array<u8, 0x38> reserved_29E88;
|
||||
INSERT_PADDING_BYTES(0x38); // Reserved
|
||||
|
||||
// nn::ncm::ProgramId
|
||||
std::array<u8, 0x8> initial_system_applet_program_id;
|
||||
std::array<u8, 0x8> overlay_disp_program_id;
|
||||
|
||||
std::array<u8, 0x4> reserved_29ED0;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
|
||||
bool requires_run_repair_time_reviser;
|
||||
INSERT_PADDING_BYTES(0x6B); // Reserved
|
||||
|
||||
std::array<u8, 0x6B> reserved_29ED5;
|
||||
|
||||
// nn::time::LocationName
|
||||
Service::Time::TimeZone::LocationName device_time_zone_location_name;
|
||||
std::array<u8, 0x4> reserved_29F64;
|
||||
// nn::time::SteadyClockTimePoint
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time;
|
||||
|
||||
std::array<u8, 0xC0> reserved_29F80;
|
||||
INSERT_PADDING_BYTES(0xC0); // Reserved
|
||||
|
||||
// nn::settings::system::PrimaryAlbumStorage
|
||||
PrimaryAlbumStorage primary_album_storage;
|
||||
|
||||
std::array<u8, 0x3C> reserved_2A044;
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
bool usb_30_enable_flag;
|
||||
std::array<u8, 0x3> pad_2A081;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
bool usb_30_host_enable_flag;
|
||||
std::array<u8, 0x3> pad_2A085;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
bool usb_30_device_enable_flag;
|
||||
std::array<u8, 0x3> pad_2A089;
|
||||
|
||||
std::array<u8, 0x34> reserved_2A08C;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x34); // Reserved
|
||||
|
||||
bool nfc_enable_flag;
|
||||
std::array<u8, 0x3> pad_2A0C1;
|
||||
|
||||
std::array<u8, 0x3C> reserved_2A0C4;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x3C); // Reserved
|
||||
|
||||
// nn::settings::system::SleepSettings
|
||||
SleepSettings sleep_settings;
|
||||
|
||||
std::array<u8, 0x34> reserved_2A10C;
|
||||
INSERT_PADDING_BYTES(0x34); // Reserved
|
||||
|
||||
// nn::settings::system::EulaVersion
|
||||
u32 eula_version_count;
|
||||
std::array<u8, 0xC> reserved_2A144;
|
||||
INSERT_PADDING_BYTES(0xC); // Reserved
|
||||
std::array<EulaVersion, 32> eula_versions;
|
||||
|
||||
std::array<u8, 0x200> reserved_2A750;
|
||||
INSERT_PADDING_BYTES(0x200); // Reserved
|
||||
|
||||
// nn::settings::system::DeviceNickName
|
||||
std::array<u8, 0x80> device_nick_name;
|
||||
|
||||
std::array<u8, 0x80> reserved_2A9D0;
|
||||
INSERT_PADDING_BYTES(0x80); // Reserved
|
||||
|
||||
bool auto_update_enable_flag;
|
||||
std::array<u8, 0x3> pad_2AA51;
|
||||
|
||||
std::array<u8, 0x4C> reserved_2AA54;
|
||||
INSERT_PADDING_BYTES(0x3);
|
||||
INSERT_PADDING_BYTES(0x4C); // Reserved
|
||||
|
||||
// nn::settings::system::BluetoothDevicesSettings
|
||||
std::array<std::array<u8, 0x200>, 14> bluetooth_device_settings_last_14;
|
||||
|
||||
std::array<u8, 0x2000> reserved_2C6A0;
|
||||
INSERT_PADDING_BYTES(0x2000); // Reserved
|
||||
|
||||
// nn::settings::system::NxControllerSettings
|
||||
std::array<std::array<u8, 0x800>, 10> nx_controller_settings_data_from_offset_30;
|
@ -4,72 +4,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/set/system_settings.h"
|
||||
#include "core/hle/service/set/settings_types.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::Set {
|
||||
enum class KeyboardLayout : u64 {
|
||||
Japanese = 0,
|
||||
EnglishUs = 1,
|
||||
EnglishUsInternational = 2,
|
||||
EnglishUk = 3,
|
||||
French = 4,
|
||||
FrenchCa = 5,
|
||||
Spanish = 6,
|
||||
SpanishLatin = 7,
|
||||
German = 8,
|
||||
Italian = 9,
|
||||
Portuguese = 10,
|
||||
Russian = 11,
|
||||
Korean = 12,
|
||||
ChineseSimplified = 13,
|
||||
ChineseTraditional = 14,
|
||||
};
|
||||
|
||||
constexpr std::array<LanguageCode, 18> available_language_codes = {{
|
||||
LanguageCode::JA,
|
||||
LanguageCode::EN_US,
|
||||
LanguageCode::FR,
|
||||
LanguageCode::DE,
|
||||
LanguageCode::IT,
|
||||
LanguageCode::ES,
|
||||
LanguageCode::ZH_CN,
|
||||
LanguageCode::KO,
|
||||
LanguageCode::NL,
|
||||
LanguageCode::PT,
|
||||
LanguageCode::RU,
|
||||
LanguageCode::ZH_TW,
|
||||
LanguageCode::EN_GB,
|
||||
LanguageCode::FR_CA,
|
||||
LanguageCode::ES_419,
|
||||
LanguageCode::ZH_HANS,
|
||||
LanguageCode::ZH_HANT,
|
||||
LanguageCode::PT_BR,
|
||||
}};
|
||||
|
||||
static constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_layout{{
|
||||
{LanguageCode::JA, KeyboardLayout::Japanese},
|
||||
{LanguageCode::EN_US, KeyboardLayout::EnglishUs},
|
||||
{LanguageCode::FR, KeyboardLayout::French},
|
||||
{LanguageCode::DE, KeyboardLayout::German},
|
||||
{LanguageCode::IT, KeyboardLayout::Italian},
|
||||
{LanguageCode::ES, KeyboardLayout::Spanish},
|
||||
{LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified},
|
||||
{LanguageCode::KO, KeyboardLayout::Korean},
|
||||
{LanguageCode::NL, KeyboardLayout::EnglishUsInternational},
|
||||
{LanguageCode::PT, KeyboardLayout::Portuguese},
|
||||
{LanguageCode::RU, KeyboardLayout::Russian},
|
||||
{LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional},
|
||||
{LanguageCode::EN_GB, KeyboardLayout::EnglishUk},
|
||||
{LanguageCode::FR_CA, KeyboardLayout::FrenchCa},
|
||||
{LanguageCode::ES_419, KeyboardLayout::SpanishLatin},
|
||||
{LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified},
|
||||
{LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional},
|
||||
{LanguageCode::PT_BR, KeyboardLayout::Portuguese},
|
||||
}};
|
||||
|
||||
LanguageCode GetLanguageCodeFromIndex(std::size_t idx);
|
||||
|
||||
|
451
src/core/hle/service/set/settings_types.h
Normal file
451
src/core/hle/service/set/settings_types.h
Normal file
@ -0,0 +1,451 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/time/clock_types.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
/// This is nn::settings::system::AudioOutputMode
|
||||
enum class AudioOutputMode : u32 {
|
||||
ch_1,
|
||||
ch_2,
|
||||
ch_5_1,
|
||||
ch_7_1,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::AudioOutputModeTarget
|
||||
enum class AudioOutputModeTarget : u32 {
|
||||
Hdmi,
|
||||
Speaker,
|
||||
Headphone,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::AudioVolumeTarget
|
||||
enum class AudioVolumeTarget : u32 {
|
||||
Speaker,
|
||||
Headphone,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ClockSourceId
|
||||
enum class ClockSourceId : u32 {
|
||||
NetworkSystemClock,
|
||||
SteadyClock,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::CmuMode
|
||||
enum class CmuMode : u32 {
|
||||
None,
|
||||
ColorInvert,
|
||||
HighContrast,
|
||||
GrayScale,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ChineseTraditionalInputMethod
|
||||
enum class ChineseTraditionalInputMethod : u32 {
|
||||
Unknown0 = 0,
|
||||
Unknown1 = 1,
|
||||
Unknown2 = 2,
|
||||
};
|
||||
|
||||
/// Indicates the current theme set by the system settings
|
||||
enum class ColorSet : u32 {
|
||||
BasicWhite = 0,
|
||||
BasicBlack = 1,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ConsoleSleepPlan
|
||||
enum class ConsoleSleepPlan : u32 {
|
||||
Sleep1Hour,
|
||||
Sleep2Hour,
|
||||
Sleep3Hour,
|
||||
Sleep6Hour,
|
||||
Sleep12Hour,
|
||||
Never,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::ErrorReportSharePermission
|
||||
enum class ErrorReportSharePermission : u32 {
|
||||
NotConfirmed,
|
||||
Granted,
|
||||
Denied,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::EulaVersionClockType
|
||||
enum class EulaVersionClockType : u32 {
|
||||
NetworkSystemClock,
|
||||
SteadyClock,
|
||||
};
|
||||
|
||||
/// This is nn::settings::factory::RegionCode
|
||||
enum class FactoryRegionCode : u32 {
|
||||
Japan,
|
||||
Usa,
|
||||
Europe,
|
||||
Australia,
|
||||
China,
|
||||
Korea,
|
||||
Taiwan,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::FriendPresenceOverlayPermission
|
||||
enum class FriendPresenceOverlayPermission : u8 {
|
||||
NotConfirmed,
|
||||
NoDisplay,
|
||||
FavoriteFriends,
|
||||
Friends,
|
||||
};
|
||||
|
||||
enum class GetFirmwareVersionType {
|
||||
Version1,
|
||||
Version2,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::HandheldSleepPlan
|
||||
enum class HandheldSleepPlan : u32 {
|
||||
Sleep1Min,
|
||||
Sleep3Min,
|
||||
Sleep5Min,
|
||||
Sleep10Min,
|
||||
Sleep30Min,
|
||||
Never,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::HdmiContentType
|
||||
enum class HdmiContentType : u32 {
|
||||
None,
|
||||
Graphics,
|
||||
Cinema,
|
||||
Photo,
|
||||
Game,
|
||||
};
|
||||
|
||||
enum class KeyboardLayout : u32 {
|
||||
Japanese = 0,
|
||||
EnglishUs = 1,
|
||||
EnglishUsInternational = 2,
|
||||
EnglishUk = 3,
|
||||
French = 4,
|
||||
FrenchCa = 5,
|
||||
Spanish = 6,
|
||||
SpanishLatin = 7,
|
||||
German = 8,
|
||||
Italian = 9,
|
||||
Portuguese = 10,
|
||||
Russian = 11,
|
||||
Korean = 12,
|
||||
ChineseSimplified = 13,
|
||||
ChineseTraditional = 14,
|
||||
};
|
||||
|
||||
/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64.
|
||||
enum class LanguageCode : u64 {
|
||||
JA = 0x000000000000616A,
|
||||
EN_US = 0x00000053552D6E65,
|
||||
FR = 0x0000000000007266,
|
||||
DE = 0x0000000000006564,
|
||||
IT = 0x0000000000007469,
|
||||
ES = 0x0000000000007365,
|
||||
ZH_CN = 0x0000004E432D687A,
|
||||
KO = 0x0000000000006F6B,
|
||||
NL = 0x0000000000006C6E,
|
||||
PT = 0x0000000000007470,
|
||||
RU = 0x0000000000007572,
|
||||
ZH_TW = 0x00000057542D687A,
|
||||
EN_GB = 0x00000042472D6E65,
|
||||
FR_CA = 0x00000041432D7266,
|
||||
ES_419 = 0x00003931342D7365,
|
||||
ZH_HANS = 0x00736E61482D687A,
|
||||
ZH_HANT = 0x00746E61482D687A,
|
||||
PT_BR = 0x00000052422D7470,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::NotificationVolume
|
||||
enum class NotificationVolume : u32 {
|
||||
Mute,
|
||||
Low,
|
||||
High,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::PrimaryAlbumStorage
|
||||
enum class PrimaryAlbumStorage : u32 {
|
||||
Nand,
|
||||
SdCard,
|
||||
};
|
||||
|
||||
/// Indicates the current console is a retail or kiosk unit
|
||||
enum class QuestFlag : u8 {
|
||||
Retail = 0,
|
||||
Kiosk = 1,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::RgbRange
|
||||
enum class RgbRange : u32 {
|
||||
Auto,
|
||||
Full,
|
||||
Limited,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::RegionCode
|
||||
enum class SystemRegionCode : u32 {
|
||||
Japan,
|
||||
Usa,
|
||||
Europe,
|
||||
Australia,
|
||||
HongKongTaiwanKorea,
|
||||
China,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::TouchScreenMode
|
||||
enum class TouchScreenMode : u32 {
|
||||
Stylus,
|
||||
Standard,
|
||||
};
|
||||
|
||||
/// This is nn::settings::system::TvResolution
|
||||
enum class TvResolution : u32 {
|
||||
Auto,
|
||||
Resolution1080p,
|
||||
Resolution720p,
|
||||
Resolution480p,
|
||||
};
|
||||
|
||||
constexpr std::array<LanguageCode, 18> available_language_codes = {{
|
||||
LanguageCode::JA,
|
||||
LanguageCode::EN_US,
|
||||
LanguageCode::FR,
|
||||
LanguageCode::DE,
|
||||
LanguageCode::IT,
|
||||
LanguageCode::ES,
|
||||
LanguageCode::ZH_CN,
|
||||
LanguageCode::KO,
|
||||
LanguageCode::NL,
|
||||
LanguageCode::PT,
|
||||
LanguageCode::RU,
|
||||
LanguageCode::ZH_TW,
|
||||
LanguageCode::EN_GB,
|
||||
LanguageCode::FR_CA,
|
||||
LanguageCode::ES_419,
|
||||
LanguageCode::ZH_HANS,
|
||||
LanguageCode::ZH_HANT,
|
||||
LanguageCode::PT_BR,
|
||||
}};
|
||||
|
||||
static constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_layout{{
|
||||
{LanguageCode::JA, KeyboardLayout::Japanese},
|
||||
{LanguageCode::EN_US, KeyboardLayout::EnglishUs},
|
||||
{LanguageCode::FR, KeyboardLayout::French},
|
||||
{LanguageCode::DE, KeyboardLayout::German},
|
||||
{LanguageCode::IT, KeyboardLayout::Italian},
|
||||
{LanguageCode::ES, KeyboardLayout::Spanish},
|
||||
{LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified},
|
||||
{LanguageCode::KO, KeyboardLayout::Korean},
|
||||
{LanguageCode::NL, KeyboardLayout::EnglishUsInternational},
|
||||
{LanguageCode::PT, KeyboardLayout::Portuguese},
|
||||
{LanguageCode::RU, KeyboardLayout::Russian},
|
||||
{LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional},
|
||||
{LanguageCode::EN_GB, KeyboardLayout::EnglishUk},
|
||||
{LanguageCode::FR_CA, KeyboardLayout::FrenchCa},
|
||||
{LanguageCode::ES_419, KeyboardLayout::SpanishLatin},
|
||||
{LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified},
|
||||
{LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional},
|
||||
{LanguageCode::PT_BR, KeyboardLayout::Portuguese},
|
||||
}};
|
||||
|
||||
/// This is nn::settings::system::AccountNotificationFlag
|
||||
struct AccountNotificationFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> FriendOnlineFlag;
|
||||
BitField<1, 1, u32> FriendRequestFlag;
|
||||
BitField<8, 1, u32> CoralInvitationFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::AccountSettings
|
||||
struct AccountSettings {
|
||||
u32 flags;
|
||||
};
|
||||
static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::DataDeletionFlag
|
||||
struct DataDeletionFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> AutomaticDeletionFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(DataDeletionFlag) == 4, "DataDeletionFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::InitialLaunchFlag
|
||||
struct InitialLaunchFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> InitialLaunchCompletionFlag;
|
||||
BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
|
||||
BitField<16, 1, u32> InitialLaunchTimestampFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::SleepFlag
|
||||
struct SleepFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> SleepsWhilePlayingMedia;
|
||||
BitField<1, 1, u32> WakesAtPowerStateChange;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::NotificationFlag
|
||||
struct NotificationFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> RingtoneFlag;
|
||||
BitField<1, 1, u32> DownloadCompletionFlag;
|
||||
BitField<8, 1, u32> EnablesNews;
|
||||
BitField<9, 1, u32> IncomingLampFlag;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::TvFlag
|
||||
struct TvFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> Allows4k;
|
||||
BitField<1, 1, u32> Allows3d;
|
||||
BitField<2, 1, u32> AllowsCec;
|
||||
BitField<3, 1, u32> PreventsScreenBurnIn;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::UserSelectorFlag
|
||||
struct UserSelectorFlag {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> SkipIfSingleUser;
|
||||
BitField<31, 1, u32> Unknown;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(UserSelectorFlag) == 4, "UserSelectorFlag is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::AccountNotificationSettings
|
||||
struct AccountNotificationSettings {
|
||||
Common::UUID uid;
|
||||
AccountNotificationFlag flags;
|
||||
FriendPresenceOverlayPermission friend_presence_permission;
|
||||
FriendPresenceOverlayPermission friend_invitation_permission;
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
};
|
||||
static_assert(sizeof(AccountNotificationSettings) == 0x18,
|
||||
"AccountNotificationSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::EulaVersion
|
||||
struct EulaVersion {
|
||||
u32 version;
|
||||
SystemRegionCode region_code;
|
||||
EulaVersionClockType clock_type;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
s64 posix_time;
|
||||
Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
||||
|
||||
struct FirmwareVersionFormat {
|
||||
u8 major;
|
||||
u8 minor;
|
||||
u8 micro;
|
||||
INSERT_PADDING_BYTES(1);
|
||||
u8 revision_major;
|
||||
u8 revision_minor;
|
||||
INSERT_PADDING_BYTES(2);
|
||||
std::array<char, 0x20> platform;
|
||||
std::array<u8, 0x40> version_hash;
|
||||
std::array<char, 0x18> display_version;
|
||||
std::array<char, 0x80> display_title;
|
||||
};
|
||||
static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::HomeMenuScheme
|
||||
struct HomeMenuScheme {
|
||||
u32 main;
|
||||
u32 back;
|
||||
u32 sub;
|
||||
u32 bezel;
|
||||
u32 extra;
|
||||
};
|
||||
static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
|
||||
|
||||
/// This is nn::settings::system::InitialLaunchSettings
|
||||
struct InitialLaunchSettings {
|
||||
InitialLaunchFlag flags;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
Service::Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
|
||||
|
||||
#pragma pack(push, 4)
|
||||
struct InitialLaunchSettingsPacked {
|
||||
InitialLaunchFlag flags;
|
||||
Service::Time::Clock::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,
|
||||
"InitialLaunchSettingsPacked is incorrect size");
|
||||
|
||||
/// This is nn::settings::system::NotificationTime
|
||||
struct NotificationTime {
|
||||
u32 hour;
|
||||
u32 minute;
|
||||
};
|
||||
static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::NotificationSettings
|
||||
struct NotificationSettings {
|
||||
NotificationFlag flags;
|
||||
NotificationVolume volume;
|
||||
NotificationTime start_time;
|
||||
NotificationTime stop_time;
|
||||
};
|
||||
static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
|
||||
|
||||
/// This is nn::settings::system::SleepSettings
|
||||
struct SleepSettings {
|
||||
SleepFlag flags;
|
||||
HandheldSleepPlan handheld_sleep_plan;
|
||||
ConsoleSleepPlan console_sleep_plan;
|
||||
};
|
||||
static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
|
||||
|
||||
/// This is nn::settings::system::TvSettings
|
||||
struct TvSettings {
|
||||
TvFlag flags;
|
||||
TvResolution tv_resolution;
|
||||
HdmiContentType hdmi_content_type;
|
||||
RgbRange rgb_range;
|
||||
CmuMode cmu_mode;
|
||||
u32 tv_underscan;
|
||||
f32 tv_gama;
|
||||
f32 contrast_ratio;
|
||||
};
|
||||
static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
|
||||
|
||||
} // namespace Service::Set
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user