summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp2
-rw-r--r--src/core/core.cpp7
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/file_sys/ips_layer.cpp75
-rw-r--r--src/core/file_sys/ips_layer.h11
-rw-r--r--src/core/file_sys/patch_manager.cpp15
-rw-r--r--src/core/file_sys/patch_manager.h5
-rw-r--r--src/core/hle/kernel/kernel.cpp12
-rw-r--r--src/core/hle/kernel/kernel.h10
-rw-r--r--src/core/hle/kernel/scheduler.cpp8
-rw-r--r--src/core/hle/kernel/svc.cpp37
-rw-r--r--src/core/hle/kernel/thread.cpp8
-rw-r--r--src/core/hle/kernel/thread.h8
-rw-r--r--src/core/loader/nsp.cpp2
-rw-r--r--src/core/loader/nsp.h2
-rw-r--r--src/core/loader/xci.cpp2
-rw-r--r--src/core/loader/xci.h2
-rw-r--r--src/core/telemetry_session.cpp12
-rw-r--r--src/core/telemetry_session.h4
19 files changed, 144 insertions, 88 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index 7e978cf7a..0762321a9 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -129,7 +129,7 @@ public:
};
std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const {
- auto& current_process = Core::CurrentProcess();
+ auto* current_process = Core::CurrentProcess();
auto** const page_table = current_process->VMManager().page_table.pointers.data();
Dynarmic::A64::UserConfig config;
diff --git a/src/core/core.cpp b/src/core/core.cpp
index b6acfb3e4..e2fb9e038 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -136,7 +136,8 @@ struct System::Impl {
if (virtual_filesystem == nullptr)
virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
- kernel.MakeCurrentProcess(Kernel::Process::Create(kernel, "main"));
+ auto main_process = Kernel::Process::Create(kernel, "main");
+ kernel.MakeCurrentProcess(main_process.get());
cpu_barrier = std::make_shared<CpuBarrier>();
cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size());
@@ -361,11 +362,11 @@ const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(std::size_t core_ind
return impl->cpu_cores[core_index]->Scheduler();
}
-Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() {
+Kernel::Process* System::CurrentProcess() {
return impl->kernel.CurrentProcess();
}
-const Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() const {
+const Kernel::Process* System::CurrentProcess() const {
return impl->kernel.CurrentProcess();
}
diff --git a/src/core/core.h b/src/core/core.h
index f9a3e97e3..ea4d53914 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -174,11 +174,11 @@ public:
/// Gets the scheduler for the CPU core with the specified index
const std::shared_ptr<Kernel::Scheduler>& Scheduler(std::size_t core_index);
- /// Provides a reference to the current process
- Kernel::SharedPtr<Kernel::Process>& CurrentProcess();
+ /// Provides a pointer to the current process
+ Kernel::Process* CurrentProcess();
- /// Provides a constant reference to the current process.
- const Kernel::SharedPtr<Kernel::Process>& CurrentProcess() const;
+ /// Provides a constant pointer to the current process.
+ const Kernel::Process* CurrentProcess() const;
/// Provides a reference to the kernel instance.
Kernel::KernelCore& Kernel();
@@ -246,7 +246,7 @@ inline TelemetrySession& Telemetry() {
return System::GetInstance().TelemetrySession();
}
-inline Kernel::SharedPtr<Kernel::Process>& CurrentProcess() {
+inline Kernel::Process* CurrentProcess() {
return System::GetInstance().CurrentProcess();
}
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp
index 0cadbc375..554eae9bc 100644
--- a/src/core/file_sys/ips_layer.cpp
+++ b/src/core/file_sys/ips_layer.cpp
@@ -2,9 +2,15 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
+#include <cstring>
+#include <map>
#include <sstream>
-#include "common/assert.h"
+#include <string>
+#include <utility>
+
#include "common/hex_util.h"
+#include "common/logging/log.h"
#include "common/swap.h"
#include "core/file_sys/ips_layer.h"
#include "core/file_sys/vfs_vector.h"
@@ -17,22 +23,48 @@ enum class IPSFileType {
Error,
};
-constexpr std::array<std::pair<const char*, const char*>, 11> ESCAPE_CHARACTER_MAP{
- std::pair{"\\a", "\a"}, {"\\b", "\b"}, {"\\f", "\f"}, {"\\n", "\n"},
- {"\\r", "\r"}, {"\\t", "\t"}, {"\\v", "\v"}, {"\\\\", "\\"},
- {"\\\'", "\'"}, {"\\\"", "\""}, {"\\\?", "\?"},
-};
+constexpr std::array<std::pair<const char*, const char*>, 11> ESCAPE_CHARACTER_MAP{{
+ {"\\a", "\a"},
+ {"\\b", "\b"},
+ {"\\f", "\f"},
+ {"\\n", "\n"},
+ {"\\r", "\r"},
+ {"\\t", "\t"},
+ {"\\v", "\v"},
+ {"\\\\", "\\"},
+ {"\\\'", "\'"},
+ {"\\\"", "\""},
+ {"\\\?", "\?"},
+}};
static IPSFileType IdentifyMagic(const std::vector<u8>& magic) {
- if (magic.size() != 5)
+ if (magic.size() != 5) {
return IPSFileType::Error;
- if (magic == std::vector<u8>{'P', 'A', 'T', 'C', 'H'})
+ }
+
+ constexpr std::array<u8, 5> patch_magic{{'P', 'A', 'T', 'C', 'H'}};
+ if (std::equal(magic.begin(), magic.end(), patch_magic.begin())) {
return IPSFileType::IPS;
- if (magic == std::vector<u8>{'I', 'P', 'S', '3', '2'})
+ }
+
+ constexpr std::array<u8, 5> ips32_magic{{'I', 'P', 'S', '3', '2'}};
+ if (std::equal(magic.begin(), magic.end(), ips32_magic.begin())) {
return IPSFileType::IPS32;
+ }
+
return IPSFileType::Error;
}
+static bool IsEOF(IPSFileType type, const std::vector<u8>& data) {
+ constexpr std::array<u8, 3> eof{{'E', 'O', 'F'}};
+ if (type == IPSFileType::IPS && std::equal(data.begin(), data.end(), eof.begin())) {
+ return true;
+ }
+
+ constexpr std::array<u8, 4> eeof{{'E', 'E', 'O', 'F'}};
+ return type == IPSFileType::IPS32 && std::equal(data.begin(), data.end(), eeof.begin());
+}
+
VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
if (in == nullptr || ips == nullptr)
return nullptr;
@@ -47,8 +79,7 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
u64 offset = 5; // After header
while (ips->Read(temp.data(), temp.size(), offset) == temp.size()) {
offset += temp.size();
- if (type == IPSFileType::IPS32 && temp == std::vector<u8>{'E', 'E', 'O', 'F'} ||
- type == IPSFileType::IPS && temp == std::vector<u8>{'E', 'O', 'F'}) {
+ if (IsEOF(type, temp)) {
break;
}
@@ -76,23 +107,32 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
return nullptr;
if (real_offset + rle_size > in_data.size())
- rle_size = in_data.size() - real_offset;
+ rle_size = static_cast<u16>(in_data.size() - real_offset);
std::memset(in_data.data() + real_offset, data.get(), rle_size);
} else { // Standard Patch
auto read = data_size;
if (real_offset + read > in_data.size())
- read = in_data.size() - real_offset;
+ read = static_cast<u16>(in_data.size() - real_offset);
if (ips->Read(in_data.data() + real_offset, read, offset) != data_size)
return nullptr;
offset += data_size;
}
}
- if (temp != std::vector<u8>{'E', 'E', 'O', 'F'} && temp != std::vector<u8>{'E', 'O', 'F'})
+ if (!IsEOF(type, temp)) {
return nullptr;
- return std::make_shared<VectorVfsFile>(in_data, in->GetName(), in->GetContainingDirectory());
+ }
+
+ return std::make_shared<VectorVfsFile>(std::move(in_data), in->GetName(),
+ in->GetContainingDirectory());
}
+struct IPSwitchCompiler::IPSwitchPatch {
+ std::string name;
+ bool enabled;
+ std::map<u32, std::vector<u8>> records;
+};
+
IPSwitchCompiler::IPSwitchCompiler(VirtualFile patch_text_) : patch_text(std::move(patch_text_)) {
Parse();
}
@@ -225,7 +265,7 @@ void IPSwitchCompiler::Parse() {
if (patch_line.length() < 11)
break;
auto offset = std::stoul(patch_line.substr(0, 8), nullptr, 16);
- offset += offset_shift;
+ offset += static_cast<unsigned long>(offset_shift);
std::vector<u8> replace;
// 9 - first char of replacement val
@@ -291,7 +331,8 @@ VirtualFile IPSwitchCompiler::Apply(const VirtualFile& in) const {
}
}
- return std::make_shared<VectorVfsFile>(in_data, in->GetName(), in->GetContainingDirectory());
+ return std::make_shared<VectorVfsFile>(std::move(in_data), in->GetName(),
+ in->GetContainingDirectory());
}
} // namespace FileSys
diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h
index 57da00da8..450b2f71e 100644
--- a/src/core/file_sys/ips_layer.h
+++ b/src/core/file_sys/ips_layer.h
@@ -4,8 +4,11 @@
#pragma once
+#include <array>
#include <memory>
+#include <vector>
+#include "common/common_types.h"
#include "core/file_sys/vfs.h"
namespace FileSys {
@@ -22,17 +25,13 @@ public:
VirtualFile Apply(const VirtualFile& in) const;
private:
+ struct IPSwitchPatch;
+
void ParseFlag(const std::string& flag);
void Parse();
bool valid = false;
- struct IPSwitchPatch {
- std::string name;
- bool enabled;
- std::map<u32, std::vector<u8>> records;
- };
-
VirtualFile patch_text;
std::vector<IPSwitchPatch> patches;
std::array<u8, 0x20> nso_build_id{};
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index b14d7cb0a..019caebe9 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -345,23 +345,22 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
return out;
}
-std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
+std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
const auto& installed{Service::FileSystem::GetUnionContents()};
const auto base_control_nca = installed->GetEntry(title_id, ContentRecordType::Control);
if (base_control_nca == nullptr)
return {};
- return ParseControlNCA(base_control_nca);
+ return ParseControlNCA(*base_control_nca);
}
-std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
- const std::shared_ptr<NCA>& nca) const {
- const auto base_romfs = nca->GetRomFS();
+std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(const NCA& nca) const {
+ const auto base_romfs = nca.GetRomFS();
if (base_romfs == nullptr)
return {};
- const auto romfs = PatchRomFS(base_romfs, nca->GetBaseIVFCOffset(), ContentRecordType::Control);
+ const auto romfs = PatchRomFS(base_romfs, nca.GetBaseIVFCOffset(), ContentRecordType::Control);
if (romfs == nullptr)
return {};
@@ -373,7 +372,7 @@ std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
if (nacp_file == nullptr)
nacp_file = extracted->GetFile("Control.nacp");
- const auto nacp = nacp_file == nullptr ? nullptr : std::make_shared<NACP>(nacp_file);
+ auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file);
VirtualFile icon_file;
for (const auto& language : FileSys::LANGUAGE_NAMES) {
@@ -382,6 +381,6 @@ std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
break;
}
- return {nacp, icon_file};
+ return {std::move(nacp), icon_file};
}
} // namespace FileSys
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h
index eb6fc4607..7d168837f 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -57,11 +57,10 @@ public:
// Given title_id of the program, attempts to get the control data of the update and parse it,
// falling back to the base control data.
- std::pair<std::shared_ptr<NACP>, VirtualFile> GetControlMetadata() const;
+ std::pair<std::unique_ptr<NACP>, VirtualFile> GetControlMetadata() const;
// Version of GetControlMetadata that takes an arbitrary NCA
- std::pair<std::shared_ptr<NACP>, VirtualFile> ParseControlNCA(
- const std::shared_ptr<NCA>& nca) const;
+ std::pair<std::unique_ptr<NACP>, VirtualFile> ParseControlNCA(const NCA& nca) const;
private:
u64 title_id;
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 98eb74298..bd680adfe 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -116,7 +116,7 @@ struct KernelCore::Impl {
next_thread_id = 1;
process_list.clear();
- current_process.reset();
+ current_process = nullptr;
handle_table.Clear();
resource_limits.fill(nullptr);
@@ -207,7 +207,7 @@ struct KernelCore::Impl {
// Lists all processes that exist in the current session.
std::vector<SharedPtr<Process>> process_list;
- SharedPtr<Process> current_process;
+ Process* current_process = nullptr;
Kernel::HandleTable handle_table;
std::array<SharedPtr<ResourceLimit>, 4> resource_limits;
@@ -266,15 +266,15 @@ void KernelCore::AppendNewProcess(SharedPtr<Process> process) {
impl->process_list.push_back(std::move(process));
}
-void KernelCore::MakeCurrentProcess(SharedPtr<Process> process) {
- impl->current_process = std::move(process);
+void KernelCore::MakeCurrentProcess(Process* process) {
+ impl->current_process = process;
}
-SharedPtr<Process>& KernelCore::CurrentProcess() {
+Process* KernelCore::CurrentProcess() {
return impl->current_process;
}
-const SharedPtr<Process>& KernelCore::CurrentProcess() const {
+const Process* KernelCore::CurrentProcess() const {
return impl->current_process;
}
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index c0771ecf0..41554821f 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -66,13 +66,13 @@ public:
void AppendNewProcess(SharedPtr<Process> process);
/// Makes the given process the new current process.
- void MakeCurrentProcess(SharedPtr<Process> process);
+ void MakeCurrentProcess(Process* process);
- /// Retrieves a reference to the current process.
- SharedPtr<Process>& CurrentProcess();
+ /// Retrieves a pointer to the current process.
+ Process* CurrentProcess();
- /// Retrieves a const reference to the current process.
- const SharedPtr<Process>& CurrentProcess() const;
+ /// Retrieves a const pointer to the current process.
+ const Process* CurrentProcess() const;
/// Adds a port to the named port table
void AddNamedPort(std::string name, SharedPtr<ClientPort> port);
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index cfd6e1bad..1342c597e 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -9,7 +9,7 @@
#include "common/logging/log.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
-#include "core/core_timing.h"
+#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/scheduler.h"
@@ -78,16 +78,16 @@ void Scheduler::SwitchContext(Thread* new_thread) {
// Cancel any outstanding wakeup events for this thread
new_thread->CancelWakeupTimer();
- auto previous_process = Core::CurrentProcess();
+ auto* const previous_process = Core::CurrentProcess();
current_thread = new_thread;
ready_queue.remove(new_thread->GetPriority(), new_thread);
new_thread->SetStatus(ThreadStatus::Running);
- const auto thread_owner_process = current_thread->GetOwnerProcess();
+ auto* const thread_owner_process = current_thread->GetOwnerProcess();
if (previous_process != thread_owner_process) {
- Core::CurrentProcess() = thread_owner_process;
+ Core::System::GetInstance().Kernel().MakeCurrentProcess(thread_owner_process);
SetCurrentPageTable(&Core::CurrentProcess()->VMManager().page_table);
}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 6c4af7e47..3afcce3fe 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -301,13 +301,28 @@ static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
return Mutex::Release(mutex_addr);
}
+struct BreakReason {
+ union {
+ u64 raw;
+ BitField<31, 1, u64> dont_kill_application;
+ };
+};
+
/// Break program execution
static void Break(u64 reason, u64 info1, u64 info2) {
- LOG_CRITICAL(
- Debug_Emulated,
- "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
- reason, info1, info2);
- ASSERT(false);
+ BreakReason break_reason{reason};
+ if (break_reason.dont_kill_application) {
+ LOG_ERROR(
+ Debug_Emulated,
+ "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
+ reason, info1, info2);
+ } else {
+ LOG_CRITICAL(
+ Debug_Emulated,
+ "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
+ reason, info1, info2);
+ ASSERT(false);
+ }
}
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
@@ -326,7 +341,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
info_sub_id, handle);
- const auto& current_process = Core::CurrentProcess();
+ const auto* current_process = Core::CurrentProcess();
const auto& vm_manager = current_process->VMManager();
switch (static_cast<GetInfoType>(info_id)) {
@@ -424,7 +439,7 @@ static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
return ERR_INVALID_HANDLE;
}
- const auto current_process = Core::CurrentProcess();
+ const auto* current_process = Core::CurrentProcess();
if (thread->GetOwnerProcess() != current_process) {
return ERR_INVALID_HANDLE;
}
@@ -516,7 +531,7 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s
return ERR_INVALID_HANDLE;
}
- return shared_memory->Map(Core::CurrentProcess().get(), addr, permissions_type,
+ return shared_memory->Map(Core::CurrentProcess(), addr, permissions_type,
MemoryPermission::DontCare);
}
@@ -535,7 +550,7 @@ static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64
auto& kernel = Core::System::GetInstance().Kernel();
auto shared_memory = kernel.HandleTable().Get<SharedMemory>(shared_memory_handle);
- return shared_memory->Unmap(Core::CurrentProcess().get(), addr);
+ return shared_memory->Unmap(Core::CurrentProcess(), addr);
}
/// Query process memory
@@ -573,7 +588,7 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAdd
/// Exits the current process
static void ExitProcess() {
- auto& current_process = Core::CurrentProcess();
+ auto* current_process = Core::CurrentProcess();
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID());
ASSERT_MSG(current_process->GetStatus() == ProcessStatus::Running,
@@ -621,7 +636,7 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
auto& kernel = Core::System::GetInstance().Kernel();
CASCADE_RESULT(SharedPtr<Thread> thread,
Thread::Create(kernel, name, entry_point, priority, arg, processor_id, stack_top,
- Core::CurrentProcess()));
+ *Core::CurrentProcess()));
const auto new_guest_handle = kernel.HandleTable().Create(thread);
if (new_guest_handle.Failed()) {
return new_guest_handle.Code();
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 8e514cf9a..33aed8c23 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -194,7 +194,7 @@ static void ResetThreadContext(Core::ARM_Interface::ThreadContext& context, VAdd
ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name, VAddr entry_point,
u32 priority, u64 arg, s32 processor_id,
- VAddr stack_top, SharedPtr<Process> owner_process) {
+ VAddr stack_top, Process& owner_process) {
// Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > THREADPRIO_LOWEST) {
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
@@ -208,7 +208,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
// TODO(yuriks): Other checks, returning 0xD9001BEA
- if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) {
+ if (!Memory::IsValidVirtualAddress(owner_process, entry_point)) {
LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:016X}", name, entry_point);
// TODO (bunnei): Find the correct error code to use here
return ResultCode(-1);
@@ -232,7 +232,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
thread->wait_handle = 0;
thread->name = std::move(name);
thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap();
- thread->owner_process = owner_process;
+ thread->owner_process = &owner_process;
thread->scheduler = Core::System::GetInstance().Scheduler(processor_id).get();
thread->scheduler->AddThread(thread, priority);
thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread);
@@ -264,7 +264,7 @@ SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 pri
// Initialize new "main" thread
const VAddr stack_top = owner_process.VMManager().GetTLSIORegionEndAddress();
auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, THREADPROCESSORID_0,
- stack_top, &owner_process);
+ stack_top, owner_process);
SharedPtr<Thread> thread = std::move(thread_res).Unwrap();
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index c6ffbd28c..f4d7bd235 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -89,7 +89,7 @@ public:
static ResultVal<SharedPtr<Thread>> Create(KernelCore& kernel, std::string name,
VAddr entry_point, u32 priority, u64 arg,
s32 processor_id, VAddr stack_top,
- SharedPtr<Process> owner_process);
+ Process& owner_process);
std::string GetName() const override {
return name;
@@ -262,11 +262,11 @@ public:
return processor_id;
}
- SharedPtr<Process>& GetOwnerProcess() {
+ Process* GetOwnerProcess() {
return owner_process;
}
- const SharedPtr<Process>& GetOwnerProcess() const {
+ const Process* GetOwnerProcess() const {
return owner_process;
}
@@ -386,7 +386,7 @@ private:
u64 tpidr_el0 = 0; ///< TPIDR_EL0 read/write system register.
/// Process that owns this thread
- SharedPtr<Process> owner_process;
+ Process* owner_process;
/// Objects that the thread is waiting on, in the same order as they were
/// passed to WaitSynchronization1/N.
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp
index 5534ce01c..13e57848d 100644
--- a/src/core/loader/nsp.cpp
+++ b/src/core/loader/nsp.cpp
@@ -35,7 +35,7 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file)
return;
std::tie(nacp_file, icon_file) =
- FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(control_nca);
+ FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca);
}
AppLoader_NSP::~AppLoader_NSP() = default;
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h
index b006594a6..db91cd01e 100644
--- a/src/core/loader/nsp.h
+++ b/src/core/loader/nsp.h
@@ -49,7 +49,7 @@ private:
std::unique_ptr<AppLoader> secondary_loader;
FileSys::VirtualFile icon_file;
- std::shared_ptr<FileSys::NACP> nacp_file;
+ std::unique_ptr<FileSys::NACP> nacp_file;
u64 title_id;
};
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index ee5452eb9..7a619acb4 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -30,7 +30,7 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file)
return;
std::tie(nacp_file, icon_file) =
- FileSys::PatchManager(xci->GetProgramTitleID()).ParseControlNCA(control_nca);
+ FileSys::PatchManager(xci->GetProgramTitleID()).ParseControlNCA(*control_nca);
}
AppLoader_XCI::~AppLoader_XCI() = default;
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h
index 770ed1437..46f8dfc9e 100644
--- a/src/core/loader/xci.h
+++ b/src/core/loader/xci.h
@@ -49,7 +49,7 @@ private:
std::unique_ptr<AppLoader_NCA> nca_loader;
FileSys::VirtualFile icon_file;
- std::shared_ptr<FileSys::NACP> nacp_file;
+ std::unique_ptr<FileSys::NACP> nacp_file;
};
} // namespace Loader
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index f29fff1e7..7b04792b5 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -2,12 +2,16 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <array>
+
+#include <mbedtls/ctr_drbg.h>
+#include <mbedtls/entropy.h>
+
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
+#include "common/logging/log.h"
-#include <mbedtls/ctr_drbg.h>
-#include <mbedtls/entropy.h>
#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
@@ -28,11 +32,11 @@ static u64 GenerateTelemetryId() {
mbedtls_entropy_context entropy;
mbedtls_entropy_init(&entropy);
mbedtls_ctr_drbg_context ctr_drbg;
- std::string personalization = "yuzu Telemetry ID";
+ constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}};
mbedtls_ctr_drbg_init(&ctr_drbg);
ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
- reinterpret_cast<const unsigned char*>(personalization.c_str()),
+ reinterpret_cast<const unsigned char*>(personalization.data()),
personalization.size()) == 0);
ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id),
sizeof(u64)) == 0);
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h
index cec271df0..2a4845797 100644
--- a/src/core/telemetry_session.h
+++ b/src/core/telemetry_session.h
@@ -5,6 +5,7 @@
#pragma once
#include <memory>
+#include <string>
#include "common/telemetry.h"
namespace Core {
@@ -30,8 +31,6 @@ public:
field_collection.AddField(type, name, std::move(value));
}
- static void FinalizeAsyncJob();
-
private:
Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session
std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields
@@ -53,7 +52,6 @@ u64 RegenerateTelemetryId();
* Verifies the username and token.
* @param username yuzu username to use for authentication.
* @param token yuzu token to use for authentication.
- * @param func A function that gets exectued when the verification is finished
* @returns Future with bool indicating whether the verification succeeded
*/
bool VerifyLogin(const std::string& username, const std::string& token);