early-access version 3398

This commit is contained in:
pineappleEA 2023-02-14 02:55:04 +01:00
parent f597da9384
commit 64f91090ad
73 changed files with 292 additions and 315 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3397. This is the source code for early-access 3398.
## Legal Notice ## Legal Notice

View file

@ -127,7 +127,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
render_device = params.rendering_device; render_device = params.rendering_device;
execution_mode = params.execution_mode; execution_mode = params.execution_mode;
core.Memory().ZeroBlock(*core.ApplicationProcess(), transfer_memory->GetSourceAddress(), core.Memory().ZeroBlock(*core.Kernel().CurrentProcess(), transfer_memory->GetSourceAddress(),
transfer_memory_size); transfer_memory_size);
// Note: We're not actually using the transfer memory because it's a pain to code for. // Note: We're not actually using the transfer memory because it's a pain to code for.

View file

@ -270,7 +270,7 @@ void SinkStream::Stall() {
if (stalled_lock) { if (stalled_lock) {
return; return;
} }
stalled_lock = system.StallApplication(); stalled_lock = system.StallProcesses();
} }
void SinkStream::Unstall() { void SinkStream::Unstall() {
@ -278,7 +278,7 @@ void SinkStream::Unstall() {
if (!stalled_lock) { if (!stalled_lock) {
return; return;
} }
system.UnstallApplication(); system.UnstallProcesses();
stalled_lock.unlock(); stalled_lock.unlock();
} }

View file

@ -43,9 +43,9 @@ void ARM_Interface::SymbolicateBacktrace(Core::System& system, std::vector<Backt
std::map<std::string, Symbols::Symbols> symbols; std::map<std::string, Symbols::Symbols> symbols;
for (const auto& module : modules) { for (const auto& module : modules) {
symbols.insert_or_assign( symbols.insert_or_assign(module.second,
module.second, Symbols::GetSymbols(module.first, system.Memory(), Symbols::GetSymbols(module.first, system.Memory(),
system.ApplicationProcess()->Is64BitProcess())); system.CurrentProcess()->Is64BitProcess()));
} }
for (auto& entry : out) { for (auto& entry : out) {

View file

@ -186,7 +186,7 @@ struct System::Impl {
void Run() { void Run() {
std::unique_lock<std::mutex> lk(suspend_guard); std::unique_lock<std::mutex> lk(suspend_guard);
kernel.SuspendApplication(false); kernel.Suspend(false);
core_timing.SyncPause(false); core_timing.SyncPause(false);
is_paused.store(false, std::memory_order_relaxed); is_paused.store(false, std::memory_order_relaxed);
} }
@ -195,7 +195,7 @@ struct System::Impl {
std::unique_lock<std::mutex> lk(suspend_guard); std::unique_lock<std::mutex> lk(suspend_guard);
core_timing.SyncPause(true); core_timing.SyncPause(true);
kernel.SuspendApplication(true); kernel.Suspend(true);
is_paused.store(true, std::memory_order_relaxed); is_paused.store(true, std::memory_order_relaxed);
} }
@ -203,17 +203,17 @@ struct System::Impl {
return is_paused.load(std::memory_order_relaxed); return is_paused.load(std::memory_order_relaxed);
} }
std::unique_lock<std::mutex> StallApplication() { std::unique_lock<std::mutex> StallProcesses() {
std::unique_lock<std::mutex> lk(suspend_guard); std::unique_lock<std::mutex> lk(suspend_guard);
kernel.SuspendApplication(true); kernel.Suspend(true);
core_timing.SyncPause(true); core_timing.SyncPause(true);
return lk; return lk;
} }
void UnstallApplication() { void UnstallProcesses() {
if (!IsPaused()) { if (!IsPaused()) {
core_timing.SyncPause(false); core_timing.SyncPause(false);
kernel.SuspendApplication(false); kernel.Suspend(false);
} }
} }
@ -221,7 +221,7 @@ struct System::Impl {
debugger = std::make_unique<Debugger>(system, port); debugger = std::make_unique<Debugger>(system, port);
} }
SystemResultStatus SetupForApplicationProcess(System& system, Frontend::EmuWindow& emu_window) { SystemResultStatus SetupForMainProcess(System& system, Frontend::EmuWindow& emu_window) {
LOG_DEBUG(Core, "initialized OK"); LOG_DEBUG(Core, "initialized OK");
// Setting changes may require a full system reinitialization (e.g., disabling multicore). // Setting changes may require a full system reinitialization (e.g., disabling multicore).
@ -273,7 +273,7 @@ struct System::Impl {
return SystemResultStatus::ErrorGetLoader; return SystemResultStatus::ErrorGetLoader;
} }
SystemResultStatus init_result{SetupForApplicationProcess(system, emu_window)}; SystemResultStatus init_result{SetupForMainProcess(system, emu_window)};
if (init_result != SystemResultStatus::Success) { if (init_result != SystemResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
static_cast<int>(init_result)); static_cast<int>(init_result));
@ -302,7 +302,7 @@ struct System::Impl {
static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
} }
AddGlueRegistrationForProcess(*app_loader, *main_process); AddGlueRegistrationForProcess(*app_loader, *main_process);
kernel.MakeApplicationProcess(main_process); kernel.MakeCurrentProcess(main_process);
kernel.InitializeCores(); kernel.InitializeCores();
// Initialize cheat engine // Initialize cheat engine
@ -585,12 +585,12 @@ void System::DetachDebugger() {
} }
} }
std::unique_lock<std::mutex> System::StallApplication() { std::unique_lock<std::mutex> System::StallProcesses() {
return impl->StallApplication(); return impl->StallProcesses();
} }
void System::UnstallApplication() { void System::UnstallProcesses() {
impl->UnstallApplication(); impl->UnstallProcesses();
} }
void System::InitializeDebugger() { void System::InitializeDebugger() {
@ -648,8 +648,8 @@ const Kernel::GlobalSchedulerContext& System::GlobalSchedulerContext() const {
return impl->kernel.GlobalSchedulerContext(); return impl->kernel.GlobalSchedulerContext();
} }
Kernel::KProcess* System::ApplicationProcess() { Kernel::KProcess* System::CurrentProcess() {
return impl->kernel.ApplicationProcess(); return impl->kernel.CurrentProcess();
} }
Core::DeviceMemory& System::DeviceMemory() { Core::DeviceMemory& System::DeviceMemory() {
@ -660,8 +660,8 @@ const Core::DeviceMemory& System::DeviceMemory() const {
return *impl->device_memory; return *impl->device_memory;
} }
const Kernel::KProcess* System::ApplicationProcess() const { const Kernel::KProcess* System::CurrentProcess() const {
return impl->kernel.ApplicationProcess(); return impl->kernel.CurrentProcess();
} }
ARM_Interface& System::ArmInterface(std::size_t core_index) { ARM_Interface& System::ArmInterface(std::size_t core_index) {
@ -760,8 +760,8 @@ const Core::SpeedLimiter& System::SpeedLimiter() const {
return impl->speed_limiter; return impl->speed_limiter;
} }
u64 System::GetApplicationProcessProgramID() const { u64 System::GetCurrentProcessProgramID() const {
return impl->kernel.ApplicationProcess()->GetProgramID(); return impl->kernel.CurrentProcess()->GetProgramID();
} }
Loader::ResultStatus System::GetGameName(std::string& out) const { Loader::ResultStatus System::GetGameName(std::string& out) const {
@ -880,11 +880,11 @@ bool System::GetExitLock() const {
return impl->exit_lock; return impl->exit_lock;
} }
void System::SetApplicationProcessBuildID(const CurrentBuildProcessID& id) { void System::SetCurrentProcessBuildID(const CurrentBuildProcessID& id) {
impl->build_id = id; impl->build_id = id;
} }
const System::CurrentBuildProcessID& System::GetApplicationProcessBuildID() const { const System::CurrentBuildProcessID& System::GetCurrentProcessBuildID() const {
return impl->build_id; return impl->build_id;
} }

View file

@ -184,8 +184,8 @@ public:
/// Forcibly detach the debugger if it is running. /// Forcibly detach the debugger if it is running.
void DetachDebugger(); void DetachDebugger();
std::unique_lock<std::mutex> StallApplication(); std::unique_lock<std::mutex> StallProcesses();
void UnstallApplication(); void UnstallProcesses();
/** /**
* Initialize the debugger. * Initialize the debugger.
@ -295,11 +295,11 @@ public:
/// Gets the manager for the guest device memory /// Gets the manager for the guest device memory
[[nodiscard]] const Core::DeviceMemory& DeviceMemory() const; [[nodiscard]] const Core::DeviceMemory& DeviceMemory() const;
/// Provides a pointer to the application process /// Provides a pointer to the current process
[[nodiscard]] Kernel::KProcess* ApplicationProcess(); [[nodiscard]] Kernel::KProcess* CurrentProcess();
/// Provides a constant pointer to the application process. /// Provides a constant pointer to the current process.
[[nodiscard]] const Kernel::KProcess* ApplicationProcess() const; [[nodiscard]] const Kernel::KProcess* CurrentProcess() const;
/// Provides a reference to the core timing instance. /// Provides a reference to the core timing instance.
[[nodiscard]] Timing::CoreTiming& CoreTiming(); [[nodiscard]] Timing::CoreTiming& CoreTiming();
@ -331,7 +331,7 @@ public:
/// Provides a constant reference to the speed limiter /// Provides a constant reference to the speed limiter
[[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const; [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const;
[[nodiscard]] u64 GetApplicationProcessProgramID() const; [[nodiscard]] u64 GetCurrentProcessProgramID() const;
/// Gets the name of the current game /// Gets the name of the current game
[[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
@ -396,8 +396,8 @@ public:
void SetExitLock(bool locked); void SetExitLock(bool locked);
[[nodiscard]] bool GetExitLock() const; [[nodiscard]] bool GetExitLock() const;
void SetApplicationProcessBuildID(const CurrentBuildProcessID& id); void SetCurrentProcessBuildID(const CurrentBuildProcessID& id);
[[nodiscard]] const CurrentBuildProcessID& GetApplicationProcessBuildID() const; [[nodiscard]] const CurrentBuildProcessID& GetCurrentProcessBuildID() const;
/// Register a host thread as an emulated CPU Core. /// Register a host thread as an emulated CPU Core.
void RegisterCoreThread(std::size_t id); void RegisterCoreThread(std::size_t id);

View file

@ -96,7 +96,7 @@ static std::string EscapeXML(std::string_view data) {
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_) GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
: DebuggerFrontend(backend_), system{system_} { : DebuggerFrontend(backend_), system{system_} {
if (system.ApplicationProcess()->Is64BitProcess()) { if (system.CurrentProcess()->Is64BitProcess()) {
arch = std::make_unique<GDBStubA64>(); arch = std::make_unique<GDBStubA64>();
} else { } else {
arch = std::make_unique<GDBStubA32>(); arch = std::make_unique<GDBStubA32>();
@ -340,15 +340,15 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) {
success = true; success = true;
break; break;
case BreakpointType::WriteWatch: case BreakpointType::WriteWatch:
success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size, success = system.CurrentProcess()->InsertWatchpoint(system, addr, size,
Kernel::DebugWatchpointType::Write); Kernel::DebugWatchpointType::Write);
break; break;
case BreakpointType::ReadWatch: case BreakpointType::ReadWatch:
success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size, success = system.CurrentProcess()->InsertWatchpoint(system, addr, size,
Kernel::DebugWatchpointType::Read); Kernel::DebugWatchpointType::Read);
break; break;
case BreakpointType::AccessWatch: case BreakpointType::AccessWatch:
success = system.ApplicationProcess()->InsertWatchpoint( success = system.CurrentProcess()->InsertWatchpoint(
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
break; break;
case BreakpointType::Hardware: case BreakpointType::Hardware:
@ -391,15 +391,15 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
break; break;
} }
case BreakpointType::WriteWatch: case BreakpointType::WriteWatch:
success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size, success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size,
Kernel::DebugWatchpointType::Write); Kernel::DebugWatchpointType::Write);
break; break;
case BreakpointType::ReadWatch: case BreakpointType::ReadWatch:
success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size, success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size,
Kernel::DebugWatchpointType::Read); Kernel::DebugWatchpointType::Read);
break; break;
case BreakpointType::AccessWatch: case BreakpointType::AccessWatch:
success = system.ApplicationProcess()->RemoveWatchpoint( success = system.CurrentProcess()->RemoveWatchpoint(
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
break; break;
case BreakpointType::Hardware: case BreakpointType::Hardware:
@ -482,7 +482,7 @@ static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory&
static std::optional<std::string> GetThreadName(Core::System& system, static std::optional<std::string> GetThreadName(Core::System& system,
const Kernel::KThread* thread) { const Kernel::KThread* thread) {
if (system.ApplicationProcess()->Is64BitProcess()) { if (system.CurrentProcess()->Is64BitProcess()) {
return GetNameFromThreadType64(system.Memory(), thread); return GetNameFromThreadType64(system.Memory(), thread);
} else { } else {
return GetNameFromThreadType32(system.Memory(), thread); return GetNameFromThreadType32(system.Memory(), thread);
@ -555,7 +555,7 @@ void GDBStub::HandleQuery(std::string_view command) {
SendReply(fmt::format("TextSeg={:x}", main->first)); SendReply(fmt::format("TextSeg={:x}", main->first));
} else { } else {
SendReply(fmt::format("TextSeg={:x}", SendReply(fmt::format("TextSeg={:x}",
system.ApplicationProcess()->PageTable().GetCodeRegionStart())); system.CurrentProcess()->PageTable().GetCodeRegionStart()));
} }
} else if (command.starts_with("Xfer:libraries:read::")) { } else if (command.starts_with("Xfer:libraries:read::")) {
Loader::AppLoader::Modules modules; Loader::AppLoader::Modules modules;
@ -729,7 +729,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()}; std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()};
std::string reply; std::string reply;
auto* process = system.ApplicationProcess(); auto* process = system.CurrentProcess();
auto& page_table = process->PageTable(); auto& page_table = process->PageTable();
const char* commands = "Commands:\n" const char* commands = "Commands:\n"

View file

@ -172,7 +172,7 @@ std::string SaveDataFactory::GetFullPath(Core::System& system, VirtualDir dir,
// be interpreted as the title id of the current process. // be interpreted as the title id of the current process.
if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) { if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) {
if (title_id == 0) { if (title_id == 0) {
title_id = system.GetApplicationProcessProgramID(); title_id = system.GetCurrentProcessProgramID();
} }
} }

View file

@ -148,7 +148,7 @@ public:
if (context->GetManager()->IsDomain()) { if (context->GetManager()->IsDomain()) {
context->AddDomainObject(std::move(iface)); context->AddDomainObject(std::move(iface));
} else { } else {
kernel.ApplicationProcess()->GetResourceLimit()->Reserve( kernel.CurrentProcess()->GetResourceLimit()->Reserve(
Kernel::LimitableResource::SessionCountMax, 1); Kernel::LimitableResource::SessionCountMax, 1);
auto* session = Kernel::KSession::Create(kernel); auto* session = Kernel::KSession::Create(kernel);

View file

@ -60,8 +60,7 @@ bool KClientPort::IsSignaled() const {
Result KClientPort::CreateSession(KClientSession** out) { Result KClientPort::CreateSession(KClientSession** out) {
// Reserve a new session from the resource limit. // Reserve a new session from the resource limit.
//! FIXME: we are reserving this from the wrong resource limit! KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(),
KScopedResourceReservation session_reservation(kernel.ApplicationProcess()->GetResourceLimit(),
LimitableResource::SessionCountMax); LimitableResource::SessionCountMax);
R_UNLESS(session_reservation.Succeeded(), ResultLimitReached); R_UNLESS(session_reservation.Succeeded(), ResultLimitReached);

View file

@ -21,7 +21,7 @@ KCodeMemory::KCodeMemory(KernelCore& kernel_)
Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) {
// Set members. // Set members.
m_owner = GetCurrentProcessPointer(kernel); m_owner = kernel.CurrentProcess();
// Get the owner page table. // Get the owner page table.
auto& page_table = m_owner->PageTable(); auto& page_table = m_owner->PageTable();
@ -74,7 +74,7 @@ Result KCodeMemory::Map(VAddr address, size_t size) {
R_UNLESS(!m_is_mapped, ResultInvalidState); R_UNLESS(!m_is_mapped, ResultInvalidState);
// Map the memory. // Map the memory.
R_TRY(GetCurrentProcess(kernel).PageTable().MapPageGroup( R_TRY(kernel.CurrentProcess()->PageTable().MapPageGroup(
address, *m_page_group, KMemoryState::CodeOut, KMemoryPermission::UserReadWrite)); address, *m_page_group, KMemoryState::CodeOut, KMemoryPermission::UserReadWrite));
// Mark ourselves as mapped. // Mark ourselves as mapped.
@ -91,8 +91,8 @@ Result KCodeMemory::Unmap(VAddr address, size_t size) {
KScopedLightLock lk(m_lock); KScopedLightLock lk(m_lock);
// Unmap the memory. // Unmap the memory.
R_TRY(GetCurrentProcess(kernel).PageTable().UnmapPageGroup(address, *m_page_group, R_TRY(kernel.CurrentProcess()->PageTable().UnmapPageGroup(address, *m_page_group,
KMemoryState::CodeOut)); KMemoryState::CodeOut));
// Mark ourselves as unmapped. // Mark ourselves as unmapped.
m_is_mapped = false; m_is_mapped = false;

View file

@ -164,8 +164,8 @@ Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value)
R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask)); R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask));
// Get the lock owner thread. // Get the lock owner thread.
owner_thread = GetCurrentProcess(kernel) owner_thread = kernel.CurrentProcess()
.GetHandleTable() ->GetHandleTable()
.GetObjectWithoutPseudoHandle<KThread>(handle) .GetObjectWithoutPseudoHandle<KThread>(handle)
.ReleasePointerUnsafe(); .ReleasePointerUnsafe();
R_UNLESS(owner_thread != nullptr, ResultInvalidHandle); R_UNLESS(owner_thread != nullptr, ResultInvalidHandle);
@ -213,8 +213,8 @@ void KConditionVariable::SignalImpl(KThread* thread) {
thread->EndWait(ResultSuccess); thread->EndWait(ResultSuccess);
} else { } else {
// Get the previous owner. // Get the previous owner.
KThread* owner_thread = GetCurrentProcess(kernel) KThread* owner_thread = kernel.CurrentProcess()
.GetHandleTable() ->GetHandleTable()
.GetObjectWithoutPseudoHandle<KThread>( .GetObjectWithoutPseudoHandle<KThread>(
static_cast<Handle>(prev_tag & ~Svc::HandleWaitMask)) static_cast<Handle>(prev_tag & ~Svc::HandleWaitMask))
.ReleasePointerUnsafe(); .ReleasePointerUnsafe();

View file

@ -90,7 +90,7 @@ public:
// Handle pseudo-handles. // Handle pseudo-handles.
if constexpr (std::derived_from<KProcess, T>) { if constexpr (std::derived_from<KProcess, T>) {
if (handle == Svc::PseudoHandle::CurrentProcess) { if (handle == Svc::PseudoHandle::CurrentProcess) {
auto* const cur_process = GetCurrentProcessPointer(m_kernel); auto* const cur_process = m_kernel.CurrentProcess();
ASSERT(cur_process != nullptr); ASSERT(cur_process != nullptr);
return cur_process; return cur_process;
} }

View file

@ -16,7 +16,7 @@ void HandleInterrupt(KernelCore& kernel, s32 core_id) {
auto& current_thread = GetCurrentThread(kernel); auto& current_thread = GetCurrentThread(kernel);
if (auto* process = GetCurrentProcessPointer(kernel); process) { if (auto* process = kernel.CurrentProcess(); process) {
// If the user disable count is set, we may need to pin the current thread. // If the user disable count is set, we may need to pin the current thread.
if (current_thread.GetUserDisableCount() && !process->GetPinnedThread(core_id)) { if (current_thread.GetUserDisableCount() && !process->GetPinnedThread(core_id)) {
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};

View file

@ -328,7 +328,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) {
} }
void KScheduler::SwitchThread(KThread* next_thread) { void KScheduler::SwitchThread(KThread* next_thread) {
KProcess* const cur_process = GetCurrentProcessPointer(kernel); KProcess* const cur_process = kernel.CurrentProcess();
KThread* const cur_thread = GetCurrentThreadPointer(kernel); KThread* const cur_thread = GetCurrentThreadPointer(kernel);
// We never want to schedule a null thread, so use the idle thread if we don't have a next. // We never want to schedule a null thread, so use the idle thread if we don't have a next.
@ -689,11 +689,11 @@ void KScheduler::RotateScheduledQueue(KernelCore& kernel, s32 core_id, s32 prior
void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) { void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) {
// Validate preconditions. // Validate preconditions.
ASSERT(CanSchedule(kernel)); ASSERT(CanSchedule(kernel));
ASSERT(GetCurrentProcessPointer(kernel) != nullptr); ASSERT(kernel.CurrentProcess() != nullptr);
// Get the current thread and process. // Get the current thread and process.
KThread& cur_thread = GetCurrentThread(kernel); KThread& cur_thread = GetCurrentThread(kernel);
KProcess& cur_process = GetCurrentProcess(kernel); KProcess& cur_process = *kernel.CurrentProcess();
// If the thread's yield count matches, there's nothing for us to do. // If the thread's yield count matches, there's nothing for us to do.
if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {
@ -728,11 +728,11 @@ void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) {
void KScheduler::YieldWithCoreMigration(KernelCore& kernel) { void KScheduler::YieldWithCoreMigration(KernelCore& kernel) {
// Validate preconditions. // Validate preconditions.
ASSERT(CanSchedule(kernel)); ASSERT(CanSchedule(kernel));
ASSERT(GetCurrentProcessPointer(kernel) != nullptr); ASSERT(kernel.CurrentProcess() != nullptr);
// Get the current thread and process. // Get the current thread and process.
KThread& cur_thread = GetCurrentThread(kernel); KThread& cur_thread = GetCurrentThread(kernel);
KProcess& cur_process = GetCurrentProcess(kernel); KProcess& cur_process = *kernel.CurrentProcess();
// If the thread's yield count matches, there's nothing for us to do. // If the thread's yield count matches, there's nothing for us to do.
if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {
@ -816,11 +816,11 @@ void KScheduler::YieldWithCoreMigration(KernelCore& kernel) {
void KScheduler::YieldToAnyThread(KernelCore& kernel) { void KScheduler::YieldToAnyThread(KernelCore& kernel) {
// Validate preconditions. // Validate preconditions.
ASSERT(CanSchedule(kernel)); ASSERT(CanSchedule(kernel));
ASSERT(GetCurrentProcessPointer(kernel) != nullptr); ASSERT(kernel.CurrentProcess() != nullptr);
// Get the current thread and process. // Get the current thread and process.
KThread& cur_thread = GetCurrentThread(kernel); KThread& cur_thread = GetCurrentThread(kernel);
KProcess& cur_process = GetCurrentProcess(kernel); KProcess& cur_process = *kernel.CurrentProcess();
// If the thread's yield count matches, there's nothing for us to do. // If the thread's yield count matches, there's nothing for us to do.
if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {

View file

@ -33,8 +33,7 @@ void KSession::Initialize(KClientPort* port_, const std::string& name_) {
name = name_; name = name_;
// Set our owner process. // Set our owner process.
//! FIXME: this is the wrong process! process = kernel.CurrentProcess();
process = kernel.ApplicationProcess();
process->Open(); process->Open();
// Set our port. // Set our port.

View file

@ -1266,14 +1266,6 @@ KThread& GetCurrentThread(KernelCore& kernel) {
return *GetCurrentThreadPointer(kernel); return *GetCurrentThreadPointer(kernel);
} }
KProcess* GetCurrentProcessPointer(KernelCore& kernel) {
return GetCurrentThread(kernel).GetOwnerProcess();
}
KProcess& GetCurrentProcess(KernelCore& kernel) {
return *GetCurrentProcessPointer(kernel);
}
s32 GetCurrentCoreId(KernelCore& kernel) { s32 GetCurrentCoreId(KernelCore& kernel) {
return GetCurrentThread(kernel).GetCurrentCore(); return GetCurrentThread(kernel).GetCurrentCore();
} }

View file

@ -110,8 +110,6 @@ enum class StepState : u32 {
void SetCurrentThread(KernelCore& kernel, KThread* thread); void SetCurrentThread(KernelCore& kernel, KThread* thread);
[[nodiscard]] KThread* GetCurrentThreadPointer(KernelCore& kernel); [[nodiscard]] KThread* GetCurrentThreadPointer(KernelCore& kernel);
[[nodiscard]] KThread& GetCurrentThread(KernelCore& kernel); [[nodiscard]] KThread& GetCurrentThread(KernelCore& kernel);
[[nodiscard]] KProcess* GetCurrentProcessPointer(KernelCore& kernel);
[[nodiscard]] KProcess& GetCurrentProcess(KernelCore& kernel);
[[nodiscard]] s32 GetCurrentCoreId(KernelCore& kernel); [[nodiscard]] s32 GetCurrentCoreId(KernelCore& kernel);
class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>, class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>,

View file

@ -16,7 +16,7 @@ KTransferMemory::~KTransferMemory() = default;
Result KTransferMemory::Initialize(VAddr address_, std::size_t size_, Result KTransferMemory::Initialize(VAddr address_, std::size_t size_,
Svc::MemoryPermission owner_perm_) { Svc::MemoryPermission owner_perm_) {
// Set members. // Set members.
owner = GetCurrentProcessPointer(kernel); owner = kernel.CurrentProcess();
// TODO(bunnei): Lock for transfer memory // TODO(bunnei): Lock for transfer memory

View file

@ -102,13 +102,13 @@ struct KernelCore::Impl {
void InitializeCores() { void InitializeCores() {
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
cores[core_id]->Initialize((*application_process).Is64BitProcess()); cores[core_id]->Initialize((*current_process).Is64BitProcess());
system.Memory().SetCurrentPageTable(*application_process, core_id); system.Memory().SetCurrentPageTable(*current_process, core_id);
} }
} }
void CloseApplicationProcess() { void CloseCurrentProcess() {
KProcess* old_process = application_process.exchange(nullptr); KProcess* old_process = current_process.exchange(nullptr);
if (old_process == nullptr) { if (old_process == nullptr) {
return; return;
} }
@ -182,7 +182,7 @@ struct KernelCore::Impl {
} }
} }
CloseApplicationProcess(); CloseCurrentProcess();
// Track kernel objects that were not freed on shutdown // Track kernel objects that were not freed on shutdown
{ {
@ -363,8 +363,8 @@ struct KernelCore::Impl {
} }
} }
void MakeApplicationProcess(KProcess* process) { void MakeCurrentProcess(KProcess* process) {
application_process = process; current_process = process;
} }
static inline thread_local u8 host_thread_id = UINT8_MAX; static inline thread_local u8 host_thread_id = UINT8_MAX;
@ -812,7 +812,7 @@ struct KernelCore::Impl {
// Lists all processes that exist in the current session. // Lists all processes that exist in the current session.
std::vector<KProcess*> process_list; std::vector<KProcess*> process_list;
std::atomic<KProcess*> application_process{}; std::atomic<KProcess*> current_process{};
std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context; std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
std::unique_ptr<Kernel::KHardwareTimer> hardware_timer; std::unique_ptr<Kernel::KHardwareTimer> hardware_timer;
@ -932,20 +932,20 @@ void KernelCore::AppendNewProcess(KProcess* process) {
impl->process_list.push_back(process); impl->process_list.push_back(process);
} }
void KernelCore::MakeApplicationProcess(KProcess* process) { void KernelCore::MakeCurrentProcess(KProcess* process) {
impl->MakeApplicationProcess(process); impl->MakeCurrentProcess(process);
} }
KProcess* KernelCore::ApplicationProcess() { KProcess* KernelCore::CurrentProcess() {
return impl->application_process; return impl->current_process;
} }
const KProcess* KernelCore::ApplicationProcess() const { const KProcess* KernelCore::CurrentProcess() const {
return impl->application_process; return impl->current_process;
} }
void KernelCore::CloseApplicationProcess() { void KernelCore::CloseCurrentProcess() {
impl->CloseApplicationProcess(); impl->CloseCurrentProcess();
} }
const std::vector<KProcess*>& KernelCore::GetProcessList() const { const std::vector<KProcess*>& KernelCore::GetProcessList() const {
@ -1193,12 +1193,12 @@ const Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() const {
return *impl->hidbus_shared_mem; return *impl->hidbus_shared_mem;
} }
void KernelCore::SuspendApplication(bool suspended) { void KernelCore::Suspend(bool suspended) {
const bool should_suspend{exception_exited || suspended}; const bool should_suspend{exception_exited || suspended};
const auto activity = should_suspend ? ProcessActivity::Paused : ProcessActivity::Runnable; const auto activity = should_suspend ? ProcessActivity::Paused : ProcessActivity::Runnable;
// Get the application process. //! This refers to the application process, not the current process.
KScopedAutoObject<KProcess> process = ApplicationProcess(); KScopedAutoObject<KProcess> process = CurrentProcess();
if (process.IsNull()) { if (process.IsNull()) {
return; return;
} }
@ -1209,8 +1209,8 @@ void KernelCore::SuspendApplication(bool suspended) {
// Wait for process execution to stop. // Wait for process execution to stop.
bool must_wait{should_suspend}; bool must_wait{should_suspend};
// KernelCore::SuspendApplication must be called from locked context, // KernelCore::Suspend must be called from locked context, or we
// or we could race another call to SetActivity, interfering with waiting. // could race another call to SetActivity, interfering with waiting.
while (must_wait) { while (must_wait) {
KScopedSchedulerLock sl{*this}; KScopedSchedulerLock sl{*this};
@ -1244,9 +1244,9 @@ bool KernelCore::IsShuttingDown() const {
return impl->IsShuttingDown(); return impl->IsShuttingDown();
} }
void KernelCore::ExceptionalExitApplication() { void KernelCore::ExceptionalExit() {
exception_exited = true; exception_exited = true;
SuspendApplication(true); Suspend(true);
} }
void KernelCore::EnterSVCProfile() { void KernelCore::EnterSVCProfile() {

View file

@ -131,17 +131,17 @@ public:
/// Adds the given shared pointer to an internal list of active processes. /// Adds the given shared pointer to an internal list of active processes.
void AppendNewProcess(KProcess* process); void AppendNewProcess(KProcess* process);
/// Makes the given process the new application process. /// Makes the given process the new current process.
void MakeApplicationProcess(KProcess* process); void MakeCurrentProcess(KProcess* process);
/// Retrieves a pointer to the application process. /// Retrieves a pointer to the current process.
KProcess* ApplicationProcess(); KProcess* CurrentProcess();
/// Retrieves a const pointer to the application process. /// Retrieves a const pointer to the current process.
const KProcess* ApplicationProcess() const; const KProcess* CurrentProcess() const;
/// Closes the application process. /// Closes the current process.
void CloseApplicationProcess(); void CloseCurrentProcess();
/// Retrieves the list of processes. /// Retrieves the list of processes.
const std::vector<KProcess*>& GetProcessList() const; const std::vector<KProcess*>& GetProcessList() const;
@ -288,11 +288,11 @@ public:
/// Gets the shared memory object for HIDBus services. /// Gets the shared memory object for HIDBus services.
const Kernel::KSharedMemory& GetHidBusSharedMem() const; const Kernel::KSharedMemory& GetHidBusSharedMem() const;
/// Suspend/unsuspend application process. /// Suspend/unsuspend all processes.
void SuspendApplication(bool suspend); void Suspend(bool suspend);
/// Exceptional exit application process. /// Exceptional exit all processes.
void ExceptionalExitApplication(); void ExceptionalExit();
/// Notify emulated CPU cores to shut down. /// Notify emulated CPU cores to shut down.
void ShutdownCores(); void ShutdownCores();

View file

@ -4426,7 +4426,7 @@ void Call(Core::System& system, u32 imm) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
kernel.EnterSVCProfile(); kernel.EnterSVCProfile();
if (GetCurrentProcess(system.Kernel()).Is64BitProcess()) { if (system.CurrentProcess()->Is64BitProcess()) {
Call64(system, imm); Call64(system, imm);
} else { } else {
Call32(system, imm); Call32(system, imm);

View file

@ -23,12 +23,11 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle,
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Check that the activity is being set on a non-current thread for the current process. // Check that the activity is being set on a non-current thread for the current process.
R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(system.Kernel()), R_UNLESS(thread->GetOwnerProcess() == system.Kernel().CurrentProcess(), ResultInvalidHandle);
ResultInvalidHandle);
R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy); R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy);
// Set the activity. // Set the activity.

View file

@ -72,7 +72,7 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t
timeout = timeout_ns; timeout = timeout_ns;
} }
return GetCurrentProcess(system.Kernel()).WaitAddressArbiter(address, arb_type, value, timeout); return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout);
} }
// Signals to an address (via Address Arbiter) // Signals to an address (via Address Arbiter)
@ -95,8 +95,8 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty
return ResultInvalidEnumValue; return ResultInvalidEnumValue;
} }
return GetCurrentProcess(system.Kernel()) return system.Kernel().CurrentProcess()->SignalAddressArbiter(address, signal_type, value,
.SignalAddressArbiter(address, signal_type, value, count); count);
} }
Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value, Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value,

View file

@ -38,7 +38,7 @@ Result FlushProcessDataCache(Core::System& system, Handle process_handle, u64 ad
// Get the process from its handle. // Get the process from its handle.
KScopedAutoObject process = KScopedAutoObject process =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle); R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Verify the region is within range. // Verify the region is within range.

View file

@ -46,7 +46,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
R_UNLESS(code_mem != nullptr, ResultOutOfResource); R_UNLESS(code_mem != nullptr, ResultOutOfResource);
// Verify that the region is in range. // Verify that the region is in range.
R_UNLESS(GetCurrentProcess(system.Kernel()).PageTable().Contains(address, size), R_UNLESS(system.CurrentProcess()->PageTable().Contains(address, size),
ResultInvalidCurrentMemory); ResultInvalidCurrentMemory);
// Initialize the code memory. // Initialize the code memory.
@ -56,7 +56,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
KCodeMemory::Register(kernel, code_mem); KCodeMemory::Register(kernel, code_mem);
// Add the code memory to the handle table. // Add the code memory to the handle table.
R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, code_mem)); R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, code_mem));
code_mem->Close(); code_mem->Close();
@ -79,9 +79,8 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
R_UNLESS((address < address + size), ResultInvalidCurrentMemory); R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
// Get the code memory from its handle. // Get the code memory from its handle.
KScopedAutoObject code_mem = GetCurrentProcess(system.Kernel()) KScopedAutoObject code_mem =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KCodeMemory>(code_memory_handle);
.GetObject<KCodeMemory>(code_memory_handle);
R_UNLESS(code_mem.IsNotNull(), ResultInvalidHandle); R_UNLESS(code_mem.IsNotNull(), ResultInvalidHandle);
// NOTE: Here, Atmosphere extends the SVC to allow code memory operations on one's own process. // NOTE: Here, Atmosphere extends the SVC to allow code memory operations on one's own process.
@ -91,10 +90,9 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
switch (operation) { switch (operation) {
case CodeMemoryOperation::Map: { case CodeMemoryOperation::Map: {
// Check that the region is in range. // Check that the region is in range.
R_UNLESS(GetCurrentProcess(system.Kernel()) R_UNLESS(
.PageTable() system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut),
.CanContain(address, size, KMemoryState::CodeOut), ResultInvalidMemoryRegion);
ResultInvalidMemoryRegion);
// Check the memory permission. // Check the memory permission.
R_UNLESS(IsValidMapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission); R_UNLESS(IsValidMapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);
@ -104,10 +102,9 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
} break; } break;
case CodeMemoryOperation::Unmap: { case CodeMemoryOperation::Unmap: {
// Check that the region is in range. // Check that the region is in range.
R_UNLESS(GetCurrentProcess(system.Kernel()) R_UNLESS(
.PageTable() system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut),
.CanContain(address, size, KMemoryState::CodeOut), ResultInvalidMemoryRegion);
ResultInvalidMemoryRegion);
// Check the memory permission. // Check the memory permission.
R_UNLESS(IsValidUnmapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission); R_UNLESS(IsValidUnmapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);

View file

@ -43,8 +43,8 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke
} }
// Wait on the condition variable. // Wait on the condition variable.
return GetCurrentProcess(system.Kernel()) return system.Kernel().CurrentProcess()->WaitConditionVariable(
.WaitConditionVariable(address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
} }
/// Signal process wide key /// Signal process wide key
@ -52,8 +52,8 @@ void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) {
LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count); LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count);
// Signal the condition variable. // Signal the condition variable.
return GetCurrentProcess(system.Kernel()) return system.Kernel().CurrentProcess()->SignalConditionVariable(
.SignalConditionVariable(Common::AlignDown(cv_key, sizeof(u32)), count); Common::AlignDown(cv_key, sizeof(u32)), count);
} }
Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key, Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key,

View file

@ -37,16 +37,15 @@ Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_
KDeviceAddressSpace::Register(system.Kernel(), das); KDeviceAddressSpace::Register(system.Kernel(), das);
// Add to the handle table. // Add to the handle table.
R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, das)); R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, das));
R_SUCCEED(); R_SUCCEED();
} }
Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
// Get the device address space. // Get the device address space.
KScopedAutoObject das = GetCurrentProcess(system.Kernel()) KScopedAutoObject das =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
.GetObject<KDeviceAddressSpace>(das_handle);
R_UNLESS(das.IsNotNull(), ResultInvalidHandle); R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
// Attach. // Attach.
@ -55,9 +54,8 @@ Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Ha
Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
// Get the device address space. // Get the device address space.
KScopedAutoObject das = GetCurrentProcess(system.Kernel()) KScopedAutoObject das =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
.GetObject<KDeviceAddressSpace>(das_handle);
R_UNLESS(das.IsNotNull(), ResultInvalidHandle); R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
// Detach. // Detach.
@ -96,14 +94,13 @@ Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Han
R_UNLESS(reserved == 0, ResultInvalidEnumValue); R_UNLESS(reserved == 0, ResultInvalidEnumValue);
// Get the device address space. // Get the device address space.
KScopedAutoObject das = GetCurrentProcess(system.Kernel()) KScopedAutoObject das =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
.GetObject<KDeviceAddressSpace>(das_handle);
R_UNLESS(das.IsNotNull(), ResultInvalidHandle); R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
// Get the process. // Get the process.
KScopedAutoObject process = KScopedAutoObject process =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle); system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle); R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Validate that the process address is within range. // Validate that the process address is within range.
@ -137,14 +134,13 @@ Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Han
R_UNLESS(reserved == 0, ResultInvalidEnumValue); R_UNLESS(reserved == 0, ResultInvalidEnumValue);
// Get the device address space. // Get the device address space.
KScopedAutoObject das = GetCurrentProcess(system.Kernel()) KScopedAutoObject das =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
.GetObject<KDeviceAddressSpace>(das_handle);
R_UNLESS(das.IsNotNull(), ResultInvalidHandle); R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
// Get the process. // Get the process.
KScopedAutoObject process = KScopedAutoObject process =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle); system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle); R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Validate that the process address is within range. // Validate that the process address is within range.
@ -169,14 +165,13 @@ Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle p
ResultInvalidCurrentMemory); ResultInvalidCurrentMemory);
// Get the device address space. // Get the device address space.
KScopedAutoObject das = GetCurrentProcess(system.Kernel()) KScopedAutoObject das =
.GetHandleTable() system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
.GetObject<KDeviceAddressSpace>(das_handle);
R_UNLESS(das.IsNotNull(), ResultInvalidHandle); R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
// Get the process. // Get the process.
KScopedAutoObject process = KScopedAutoObject process =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle); system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle); R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Validate that the process address is within range. // Validate that the process address is within range.

View file

@ -15,7 +15,7 @@ Result SignalEvent(Core::System& system, Handle event_handle) {
LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table. // Get the current handle table.
const KHandleTable& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const KHandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
// Get the event. // Get the event.
KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle); KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle);
@ -28,7 +28,7 @@ Result ClearEvent(Core::System& system, Handle event_handle) {
LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table. // Get the current handle table.
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
// Try to clear the writable event. // Try to clear the writable event.
{ {
@ -56,10 +56,10 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
// Get the kernel reference and handle table. // Get the kernel reference and handle table.
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
// Reserve a new event from the process resource limit // Reserve a new event from the process resource limit
KScopedResourceReservation event_reservation(GetCurrentProcessPointer(kernel), KScopedResourceReservation event_reservation(kernel.CurrentProcess(),
LimitableResource::EventCountMax); LimitableResource::EventCountMax);
R_UNLESS(event_reservation.Succeeded(), ResultLimitReached); R_UNLESS(event_reservation.Succeeded(), ResultLimitReached);
@ -68,7 +68,7 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
R_UNLESS(event != nullptr, ResultOutOfResource); R_UNLESS(event != nullptr, ResultOutOfResource);
// Initialize the event. // Initialize the event.
event->Initialize(GetCurrentProcessPointer(kernel)); event->Initialize(kernel.CurrentProcess());
// Commit the thread reservation. // Commit the thread reservation.
event_reservation.Commit(); event_reservation.Commit();

View file

@ -44,7 +44,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
return ResultInvalidEnumValue; return ResultInvalidEnumValue;
} }
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(handle);
if (process.IsNull()) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}", LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}",
@ -154,7 +154,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
return ResultInvalidCombination; return ResultInvalidCombination;
} }
KProcess* const current_process = GetCurrentProcessPointer(system.Kernel()); KProcess* const current_process = system.Kernel().CurrentProcess();
KHandleTable& handle_table = current_process->GetHandleTable(); KHandleTable& handle_table = current_process->GetHandleTable();
const auto resource_limit = current_process->GetResourceLimit(); const auto resource_limit = current_process->GetResourceLimit();
if (!resource_limit) { if (!resource_limit) {
@ -183,7 +183,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
return ResultInvalidCombination; return ResultInvalidCombination;
} }
*result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id); *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id);
return ResultSuccess; return ResultSuccess;
case InfoType::InitialProcessIdRange: case InfoType::InitialProcessIdRange:
@ -200,9 +200,9 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
return ResultInvalidCombination; return ResultInvalidCombination;
} }
KScopedAutoObject thread = GetCurrentProcess(system.Kernel()) KScopedAutoObject thread =
.GetHandleTable() system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(
.GetObject<KThread>(static_cast<Handle>(handle)); static_cast<Handle>(handle));
if (thread.IsNull()) { if (thread.IsNull()) {
LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}",
static_cast<Handle>(handle)); static_cast<Handle>(handle));
@ -249,7 +249,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
R_UNLESS(info_sub_id == 0, ResultInvalidCombination); R_UNLESS(info_sub_id == 0, ResultInvalidCombination);
// Get the handle table. // Get the handle table.
KProcess* current_process = GetCurrentProcessPointer(system.Kernel()); KProcess* current_process = system.Kernel().CurrentProcess();
KHandleTable& handle_table = current_process->GetHandleTable(); KHandleTable& handle_table = current_process->GetHandleTable();
// Get a new handle for the current process. // Get a new handle for the current process.

View file

@ -12,9 +12,11 @@ namespace Kernel::Svc {
/// Makes a blocking IPC call to a service. /// Makes a blocking IPC call to a service.
Result SendSyncRequest(Core::System& system, Handle handle) { Result SendSyncRequest(Core::System& system, Handle handle) {
auto& kernel = system.Kernel();
// Get the client session from its handle. // Get the client session from its handle.
KScopedAutoObject session = KScopedAutoObject session =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KClientSession>(handle); kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle);
R_UNLESS(session.IsNotNull(), ResultInvalidHandle); R_UNLESS(session.IsNotNull(), ResultInvalidHandle);
LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
@ -38,7 +40,7 @@ Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_ha
Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles, Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
Handle reply_target, s64 timeout_ns) { Handle reply_target, s64 timeout_ns) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable();
R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange); R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
R_UNLESS(system.Memory().IsValidVirtualAddressRange( R_UNLESS(system.Memory().IsValidVirtualAddressRange(

View file

@ -24,7 +24,7 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address,
return ResultInvalidAddress; return ResultInvalidAddress;
} }
return GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag); return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag);
} }
/// Unlock a mutex /// Unlock a mutex
@ -43,7 +43,7 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) {
return ResultInvalidAddress; return ResultInvalidAddress;
} }
return GetCurrentProcess(system.Kernel()).SignalToAddress(address); return system.Kernel().CurrentProcess()->SignalToAddress(address);
} }
Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) {

View file

@ -113,7 +113,7 @@ Result SetMemoryPermission(Core::System& system, VAddr address, u64 size, Memory
R_UNLESS(IsValidSetMemoryPermission(perm), ResultInvalidNewMemoryPermission); R_UNLESS(IsValidSetMemoryPermission(perm), ResultInvalidNewMemoryPermission);
// Validate that the region is in range for the current process. // Validate that the region is in range for the current process.
auto& page_table = GetCurrentProcess(system.Kernel()).PageTable(); auto& page_table = system.Kernel().CurrentProcess()->PageTable();
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
// Set the memory attribute. // Set the memory attribute.
@ -137,7 +137,7 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas
R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination); R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination);
// Validate that the region is in range for the current process. // Validate that the region is in range for the current process.
auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()}; auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
// Set the memory attribute. // Set the memory attribute.
@ -149,7 +149,7 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size)
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size); src_addr, size);
auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()}; auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) { result.IsError()) {
@ -164,7 +164,7 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size); src_addr, size);
auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()}; auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) { result.IsError()) {

View file

@ -16,7 +16,7 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize); R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize);
// Set the heap size. // Set the heap size.
R_TRY(GetCurrentProcess(system.Kernel()).PageTable().SetHeapSize(out_address, size)); R_TRY(system.Kernel().CurrentProcess()->PageTable().SetHeapSize(out_address, size));
return ResultSuccess; return ResultSuccess;
} }
@ -45,7 +45,7 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return ResultInvalidMemoryRegion; return ResultInvalidMemoryRegion;
} }
KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; KProcess* const current_process{system.Kernel().CurrentProcess()};
auto& page_table{current_process->PageTable()}; auto& page_table{current_process->PageTable()};
if (current_process->GetSystemResourceSize() == 0) { if (current_process->GetSystemResourceSize() == 0) {
@ -94,7 +94,7 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return ResultInvalidMemoryRegion; return ResultInvalidMemoryRegion;
} }
KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; KProcess* const current_process{system.Kernel().CurrentProcess()};
auto& page_table{current_process->PageTable()}; auto& page_table{current_process->PageTable()};
if (current_process->GetSystemResourceSize() == 0) { if (current_process->GetSystemResourceSize() == 0) {

View file

@ -34,7 +34,7 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add
// Get the current handle table. // Get the current handle table.
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
// Find the client port. // Find the client port.
auto port = kernel.CreateNamedServicePort(port_name); auto port = kernel.CreateNamedServicePort(port_name);

View file

@ -9,7 +9,7 @@ namespace Kernel::Svc {
/// Exits the current process /// Exits the current process
void ExitProcess(Core::System& system) { void ExitProcess(Core::System& system) {
auto* current_process = GetCurrentProcessPointer(system.Kernel()); auto* current_process = system.Kernel().CurrentProcess();
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID());
ASSERT_MSG(current_process->GetState() == KProcess::State::Running, ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
@ -23,9 +23,9 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
// Get the object from the handle table. // Get the object from the handle table.
KScopedAutoObject obj = GetCurrentProcess(system.Kernel()) KScopedAutoObject obj =
.GetHandleTable() system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KAutoObject>(
.GetObject<KAutoObject>(static_cast<Handle>(handle)); static_cast<Handle>(handle));
R_UNLESS(obj.IsNotNull(), ResultInvalidHandle); R_UNLESS(obj.IsNotNull(), ResultInvalidHandle);
// Get the process from the object. // Get the process from the object.
@ -63,10 +63,10 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_pr
return ResultOutOfRange; return ResultOutOfRange;
} }
auto& kernel = system.Kernel(); const auto& kernel = system.Kernel();
const auto total_copy_size = out_process_ids_size * sizeof(u64); const auto total_copy_size = out_process_ids_size * sizeof(u64);
if (out_process_ids_size > 0 && !GetCurrentProcess(kernel).PageTable().IsInsideAddressSpace( if (out_process_ids_size > 0 && !kernel.CurrentProcess()->PageTable().IsInsideAddressSpace(
out_process_ids, total_copy_size)) { out_process_ids, total_copy_size)) {
LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}", LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
out_process_ids, out_process_ids + total_copy_size); out_process_ids, out_process_ids + total_copy_size);
@ -92,7 +92,7 @@ Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle,
ProcessInfoType info_type) { ProcessInfoType info_type) {
LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type); LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type);
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",

View file

@ -45,7 +45,7 @@ Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, V
// Get the process from its handle. // Get the process from its handle.
KScopedAutoObject process = KScopedAutoObject process =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle); system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle); R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Validate that the address is in range. // Validate that the address is in range.
@ -71,7 +71,7 @@ Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_
R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory); R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
// Get the processes. // Get the processes.
KProcess* dst_process = GetCurrentProcessPointer(system.Kernel()); KProcess* dst_process = system.CurrentProcess();
KScopedAutoObject src_process = KScopedAutoObject src_process =
dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle); dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle); R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@ -114,7 +114,7 @@ Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle proces
R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory); R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
// Get the processes. // Get the processes.
KProcess* dst_process = GetCurrentProcessPointer(system.Kernel()); KProcess* dst_process = system.CurrentProcess();
KScopedAutoObject src_process = KScopedAutoObject src_process =
dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle); dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle); R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@ -174,7 +174,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst
return ResultInvalidCurrentMemory; return ResultInvalidCurrentMemory;
} }
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
@ -242,7 +242,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
return ResultInvalidCurrentMemory; return ResultInvalidCurrentMemory;
} }
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",

View file

@ -22,7 +22,7 @@ Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out
Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
Handle process_handle, uint64_t address) { Handle process_handle, uint64_t address) {
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",

View file

@ -27,7 +27,7 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
KResourceLimit::Register(kernel, resource_limit); KResourceLimit::Register(kernel, resource_limit);
// Add the limit to the handle table. // Add the limit to the handle table.
R_TRY(GetCurrentProcess(kernel).GetHandleTable().Add(out_handle, resource_limit)); R_TRY(kernel.CurrentProcess()->GetHandleTable().Add(out_handle, resource_limit));
return ResultSuccess; return ResultSuccess;
} }
@ -41,9 +41,9 @@ Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value,
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit. // Get the resource limit.
KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel()) auto& kernel = system.Kernel();
.GetHandleTable() KScopedAutoObject resource_limit =
.GetObject<KResourceLimit>(resource_limit_handle); kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Get the limit value. // Get the limit value.
@ -61,9 +61,9 @@ Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit. // Get the resource limit.
KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel()) auto& kernel = system.Kernel();
.GetHandleTable() KScopedAutoObject resource_limit =
.GetObject<KResourceLimit>(resource_limit_handle); kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Get the current value. // Get the current value.
@ -81,9 +81,9 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit. // Get the resource limit.
KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel()) auto& kernel = system.Kernel();
.GetHandleTable() KScopedAutoObject resource_limit =
.GetObject<KResourceLimit>(resource_limit_handle); kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Set the limit value. // Set the limit value.

View file

@ -13,7 +13,7 @@ namespace {
template <typename T> template <typename T>
Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) { Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) {
auto& process = GetCurrentProcess(system.Kernel()); auto& process = *system.CurrentProcess();
auto& handle_table = process.GetHandleTable(); auto& handle_table = process.GetHandleTable();
// Declare the session we're going to allocate. // Declare the session we're going to allocate.

View file

@ -42,7 +42,7 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
R_UNLESS(IsValidSharedMemoryPermission(map_perm), ResultInvalidNewMemoryPermission); R_UNLESS(IsValidSharedMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
// Get the current process. // Get the current process.
auto& process = GetCurrentProcess(system.Kernel()); auto& process = *system.Kernel().CurrentProcess();
auto& page_table = process.PageTable(); auto& page_table = process.PageTable();
// Get the shared memory. // Get the shared memory.
@ -75,7 +75,7 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres
R_UNLESS((address < address + size), ResultInvalidCurrentMemory); R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
// Get the current process. // Get the current process.
auto& process = GetCurrentProcess(system.Kernel()); auto& process = *system.Kernel().CurrentProcess();
auto& page_table = process.PageTable(); auto& page_table = process.PageTable();
// Get the shared memory. // Get the shared memory.

View file

@ -14,7 +14,7 @@ Result CloseHandle(Core::System& system, Handle handle) {
LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
// Remove the handle. // Remove the handle.
R_UNLESS(GetCurrentProcess(system.Kernel()).GetHandleTable().Remove(handle), R_UNLESS(system.Kernel().CurrentProcess()->GetHandleTable().Remove(handle),
ResultInvalidHandle); ResultInvalidHandle);
return ResultSuccess; return ResultSuccess;
@ -25,7 +25,7 @@ Result ResetSignal(Core::System& system, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
// Get the current handle table. // Get the current handle table.
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
// Try to reset as readable event. // Try to reset as readable event.
{ {
@ -59,7 +59,7 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
std::vector<KSynchronizationObject*> objs(num_handles); std::vector<KSynchronizationObject*> objs(num_handles);
const auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); const auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
Handle* handles = system.Memory().GetPointer<Handle>(handles_address); Handle* handles = system.Memory().GetPointer<Handle>(handles_address);
// Copy user handles. // Copy user handles.
@ -91,7 +91,7 @@ Result CancelSynchronization(Core::System& system, Handle handle) {
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Cancel the thread's wait. // Cancel the thread's wait.
@ -106,7 +106,7 @@ void SynchronizePreemptionState(Core::System& system) {
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};
// If the current thread is pinned, unpin it. // If the current thread is pinned, unpin it.
KProcess* cur_process = GetCurrentProcessPointer(kernel); KProcess* cur_process = system.Kernel().CurrentProcess();
const auto core_id = GetCurrentCoreId(kernel); const auto core_id = GetCurrentCoreId(kernel);
if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) { if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) {

View file

@ -28,7 +28,7 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
// Adjust core id, if it's the default magic. // Adjust core id, if it's the default magic.
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
auto& process = GetCurrentProcess(kernel); auto& process = *kernel.CurrentProcess();
if (core_id == IdealCoreUseProcessValue) { if (core_id == IdealCoreUseProcessValue) {
core_id = process.GetIdealCoreId(); core_id = process.GetIdealCoreId();
} }
@ -53,9 +53,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
} }
// Reserve a new thread from the process resource limit (waiting up to 100ms). // Reserve a new thread from the process resource limit (waiting up to 100ms).
KScopedResourceReservation thread_reservation(&process, LimitableResource::ThreadCountMax, 1, KScopedResourceReservation thread_reservation(
system.CoreTiming().GetGlobalTimeNs().count() + kernel.CurrentProcess(), LimitableResource::ThreadCountMax, 1,
100000000); system.CoreTiming().GetGlobalTimeNs().count() + 100000000);
if (!thread_reservation.Succeeded()) { if (!thread_reservation.Succeeded()) {
LOG_ERROR(Kernel_SVC, "Could not reserve a new thread"); LOG_ERROR(Kernel_SVC, "Could not reserve a new thread");
return ResultLimitReached; return ResultLimitReached;
@ -97,7 +97,7 @@ Result StartThread(Core::System& system, Handle thread_handle) {
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Try to start the thread. // Try to start the thread.
@ -156,11 +156,11 @@ Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(kernel).GetHandleTable().GetObject<KThread>(thread_handle); kernel.CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Require the handle be to a non-current thread in the current process. // Require the handle be to a non-current thread in the current process.
const auto* current_process = GetCurrentProcessPointer(kernel); const auto* current_process = kernel.CurrentProcess();
R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId); R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId);
// Verify that the thread isn't terminated. // Verify that the thread isn't terminated.
@ -211,7 +211,7 @@ Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle)
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the thread's priority. // Get the thread's priority.
@ -222,7 +222,7 @@ Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle)
/// Sets the priority for the specified thread /// Sets the priority for the specified thread
Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) { Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) {
// Get the current process. // Get the current process.
KProcess& process = GetCurrentProcess(system.Kernel()); KProcess& process = *system.Kernel().CurrentProcess();
// Validate the priority. // Validate the priority.
R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority, R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority,
@ -253,7 +253,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_threa
return ResultOutOfRange; return ResultOutOfRange;
} }
auto* const current_process = GetCurrentProcessPointer(system.Kernel()); auto* const current_process = system.Kernel().CurrentProcess();
const auto total_copy_size = out_thread_ids_size * sizeof(u64); const auto total_copy_size = out_thread_ids_size * sizeof(u64);
if (out_thread_ids_size > 0 && if (out_thread_ids_size > 0 &&
@ -284,7 +284,7 @@ Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affini
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the core mask. // Get the core mask.
@ -297,11 +297,11 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
u64 affinity_mask) { u64 affinity_mask) {
// Determine the core id/affinity mask. // Determine the core id/affinity mask.
if (core_id == IdealCoreUseProcessValue) { if (core_id == IdealCoreUseProcessValue) {
core_id = GetCurrentProcess(system.Kernel()).GetIdealCoreId(); core_id = system.Kernel().CurrentProcess()->GetIdealCoreId();
affinity_mask = (1ULL << core_id); affinity_mask = (1ULL << core_id);
} else { } else {
// Validate the affinity mask. // Validate the affinity mask.
const u64 process_core_mask = GetCurrentProcess(system.Kernel()).GetCoreMask(); const u64 process_core_mask = system.Kernel().CurrentProcess()->GetCoreMask();
R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, ResultInvalidCoreId); R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, ResultInvalidCoreId);
R_UNLESS(affinity_mask != 0, ResultInvalidCombination); R_UNLESS(affinity_mask != 0, ResultInvalidCombination);
@ -316,7 +316,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Set the core mask. // Set the core mask.
@ -329,7 +329,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the thread's id. // Get the thread's id.

View file

@ -39,11 +39,11 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
R_UNLESS(IsValidTransferMemoryPermission(map_perm), ResultInvalidNewMemoryPermission); R_UNLESS(IsValidTransferMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
// Get the current process and handle table. // Get the current process and handle table.
auto& process = GetCurrentProcess(kernel); auto& process = *kernel.CurrentProcess();
auto& handle_table = process.GetHandleTable(); auto& handle_table = process.GetHandleTable();
// Reserve a new transfer memory from the process resource limit. // Reserve a new transfer memory from the process resource limit.
KScopedResourceReservation trmem_reservation(&process, KScopedResourceReservation trmem_reservation(kernel.CurrentProcess(),
LimitableResource::TransferMemoryCountMax); LimitableResource::TransferMemoryCountMax);
R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached); R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached);

View file

@ -592,7 +592,7 @@ void Call(Core::System& system, u32 imm) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
kernel.EnterSVCProfile(); kernel.EnterSVCProfile();
if (GetCurrentProcess(system.Kernel()).Is64BitProcess()) { if (system.CurrentProcess()->Is64BitProcess()) {
Call64(system, imm); Call64(system, imm);
} else { } else {
Call32(system, imm); Call32(system, imm);

View file

@ -762,7 +762,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
// processes emulated. As we don't actually have pid support we should assume we're just using // processes emulated. As we don't actually have pid support we should assume we're just using
// our own process // our own process
const auto launch_property = const auto launch_property =
system.GetARPManager().GetLaunchProperty(system.GetApplicationProcessProgramID()); system.GetARPManager().GetLaunchProperty(system.GetCurrentProcessProgramID());
if (launch_property.Failed()) { if (launch_property.Failed()) {
LOG_ERROR(Service_ACC, "Failed to get launch property"); LOG_ERROR(Service_ACC, "Failed to get launch property");
@ -806,7 +806,7 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
bool is_locked = false; bool is_locked = false;
if (res != Loader::ResultStatus::Success) { if (res != Loader::ResultStatus::Success) {
const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(), const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(),
system.GetFileSystemController(), system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};
const auto nacp_unique = pm.GetControlMetadata().first; const auto nacp_unique = pm.GetControlMetadata().first;

View file

@ -79,7 +79,7 @@ IWindowController::IWindowController(Core::System& system_)
IWindowController::~IWindowController() = default; IWindowController::~IWindowController() = default;
void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
const u64 process_id = system.ApplicationProcess()->GetProcessID(); const u64 process_id = system.CurrentProcess()->GetProcessID();
LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id); LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
@ -1252,7 +1252,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
} }
auto transfer_mem = auto transfer_mem =
system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
if (transfer_mem.IsNull()) { if (transfer_mem.IsNull()) {
LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
@ -1286,7 +1286,7 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
} }
auto transfer_mem = auto transfer_mem =
system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
if (transfer_mem.IsNull()) { if (transfer_mem.IsNull()) {
LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
@ -1465,12 +1465,11 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) { const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) {
return system.GetFileSystemController().GetBCATDirectory(tid); return system.GetFileSystemController().GetBCATDirectory(tid);
}); });
const auto build_id_full = system.GetApplicationProcessBuildID(); const auto build_id_full = system.GetCurrentProcessBuildID();
u64 build_id{}; u64 build_id{};
std::memcpy(&build_id, build_id_full.data(), sizeof(u64)); std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
auto data = auto data = backend->GetLaunchParameter({system.GetCurrentProcessProgramID(), build_id});
backend->GetLaunchParameter({system.GetApplicationProcessProgramID(), build_id});
if (data.has_value()) { if (data.has_value()) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -1522,7 +1521,7 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]);
FileSys::SaveDataAttribute attribute{}; FileSys::SaveDataAttribute attribute{};
attribute.title_id = system.GetApplicationProcessProgramID(); attribute.title_id = system.GetCurrentProcessProgramID();
attribute.user_id = user_id; attribute.user_id = user_id;
attribute.type = FileSys::SaveDataType::SaveData; attribute.type = FileSys::SaveDataType::SaveData;
const auto res = system.GetFileSystemController().CreateSaveData( const auto res = system.GetFileSystemController().CreateSaveData(
@ -1552,7 +1551,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
std::array<u8, 0x10> version_string{}; std::array<u8, 0x10> version_string{};
const auto res = [this] { const auto res = [this] {
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};
@ -1589,7 +1588,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
u32 supported_languages = 0; u32 supported_languages = 0;
const auto res = [this] { const auto res = [this] {
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};
@ -1697,8 +1696,7 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size); static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
system.GetFileSystemController().WriteSaveDataSize( system.GetFileSystemController().WriteSaveDataSize(
type, system.GetApplicationProcessProgramID(), user_id, type, system.GetCurrentProcessProgramID(), user_id, {new_normal_size, new_journal_size});
{new_normal_size, new_journal_size});
IPC::ResponseBuilder rb{ctx, 4}; IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -1722,7 +1720,7 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
user_id[0]); user_id[0]);
const auto size = system.GetFileSystemController().ReadSaveDataSize( const auto size = system.GetFileSystemController().ReadSaveDataSize(
type, system.GetApplicationProcessProgramID(), user_id); type, system.GetCurrentProcessProgramID(), user_id);
IPC::ResponseBuilder rb{ctx, 6}; IPC::ResponseBuilder rb{ctx, 6};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View file

@ -166,7 +166,7 @@ void Error::Execute() {
} }
const auto callback = [this] { DisplayCompleted(); }; const auto callback = [this] { DisplayCompleted(); };
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
const auto& reporter{system.GetReporter()}; const auto& reporter{system.GetReporter()};
switch (mode) { switch (mode) {

View file

@ -186,7 +186,7 @@ void PhotoViewer::Execute() {
const auto callback = [this] { ViewFinished(); }; const auto callback = [this] { ViewFinished(); };
switch (mode) { switch (mode) {
case PhotoViewerAppletMode::CurrentApp: case PhotoViewerAppletMode::CurrentApp:
frontend.ShowPhotosForApplication(system.GetApplicationProcessProgramID(), callback); frontend.ShowPhotosForApplication(system.GetCurrentProcessProgramID(), callback);
break; break;
case PhotoViewerAppletMode::AllApps: case PhotoViewerAppletMode::AllApps:
frontend.ShowAllPhotos(callback); frontend.ShowAllPhotos(callback);

View file

@ -393,7 +393,7 @@ void WebBrowser::InitializeOffline() {
switch (document_kind) { switch (document_kind) {
case DocumentKind::OfflineHtmlPage: case DocumentKind::OfflineHtmlPage:
default: default:
title_id = system.GetApplicationProcessProgramID(); title_id = system.GetCurrentProcessProgramID();
nca_type = FileSys::ContentRecordType::HtmlDocument; nca_type = FileSys::ContentRecordType::HtmlDocument;
additional_paths = "html-document"; additional_paths = "html-document";
break; break;

View file

@ -155,7 +155,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
const auto current = system.GetApplicationProcessProgramID(); const auto current = system.GetCurrentProcessProgramID();
const auto& disabled = Settings::values.disabled_addons[current]; const auto& disabled = Settings::values.disabled_addons[current];
if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
@ -182,7 +182,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
process_id); process_id);
const auto current = system.GetApplicationProcessProgramID(); const auto current = system.GetCurrentProcessProgramID();
std::vector<u32> out; std::vector<u32> out;
const auto& disabled = Settings::values.disabled_addons[current]; const auto& disabled = Settings::values.disabled_addons[current];
@ -228,7 +228,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 4}; IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};

View file

@ -455,7 +455,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) {
return; return;
} }
const auto& handle_table{system.ApplicationProcess()->GetHandleTable()}; const auto& handle_table{system.CurrentProcess()->GetHandleTable()};
auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)}; auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)};
auto transfer_memory{ auto transfer_memory{
process->GetHandleTable().GetObject<Kernel::KTransferMemory>(transfer_memory_handle)}; process->GetHandleTable().GetObject<Kernel::KTransferMemory>(transfer_memory_handle)};

View file

@ -176,8 +176,8 @@ private:
void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_BCAT, "called"); LOG_DEBUG(Service_BCAT, "called");
backend.Synchronize({system.GetApplicationProcessProgramID(), backend.Synchronize({system.GetCurrentProcessProgramID(),
GetCurrentBuildID(system.GetApplicationProcessBuildID())}, GetCurrentBuildID(system.GetCurrentProcessBuildID())},
GetProgressBackend(SyncType::Normal)); GetProgressBackend(SyncType::Normal));
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -193,8 +193,8 @@ private:
LOG_DEBUG(Service_BCAT, "called, name={}", name); LOG_DEBUG(Service_BCAT, "called, name={}", name);
backend.SynchronizeDirectory({system.GetApplicationProcessProgramID(), backend.SynchronizeDirectory({system.GetCurrentProcessProgramID(),
GetCurrentBuildID(system.GetApplicationProcessBuildID())}, GetCurrentBuildID(system.GetCurrentProcessBuildID())},
name, GetProgressBackend(SyncType::Directory)); name, GetProgressBackend(SyncType::Directory));
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -554,7 +554,7 @@ private:
void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_BCAT, "called"); LOG_DEBUG(Service_BCAT, "called");
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id));

View file

@ -63,7 +63,7 @@ enum class FatalType : u32 {
}; };
static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) { static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) {
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
std::string crash_report = fmt::format( std::string crash_report = fmt::format(
"Yuzu {}-{} crash report\n" "Yuzu {}-{} crash report\n"
"Title ID: {:016x}\n" "Title ID: {:016x}\n"

View file

@ -317,7 +317,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess()
return ResultUnknown; return ResultUnknown;
} }
return romfs_factory->OpenCurrentProcess(system.GetApplicationProcessProgramID()); return romfs_factory->OpenCurrentProcess(system.GetCurrentProcessProgramID());
} }
ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS( ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS(
@ -502,7 +502,7 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
const auto res = system.GetAppLoader().ReadControlData(nacp); const auto res = system.GetAppLoader().ReadControlData(nacp);
if (res != Loader::ResultStatus::Success) { if (res != Loader::ResultStatus::Success) {
const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(), const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(),
system.GetFileSystemController(), system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};
const auto metadata = pm.GetControlMetadata(); const auto metadata = pm.GetControlMetadata();

View file

@ -1036,9 +1036,8 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_FS, "called, program_index={}", program_index); LOG_DEBUG(Service_FS, "called, program_index={}", program_index);
auto patched_romfs = auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex(
fsc.OpenPatchedRomFSWithProgramIndex(system.GetApplicationProcessProgramID(), program_index, system.GetCurrentProcessProgramID(), program_index, FileSys::ContentRecordType::Program);
FileSys::ContentRecordType::Program);
if (patched_romfs.Failed()) { if (patched_romfs.Failed()) {
// TODO: Find the right error code to use here // TODO: Find the right error code to use here

View file

@ -1830,7 +1830,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes"); ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes");
ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes"); ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes");
auto t_mem_1 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem_1 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
t_mem_1_handle); t_mem_1_handle);
if (t_mem_1.IsNull()) { if (t_mem_1.IsNull()) {
@ -1840,7 +1840,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
return; return;
} }
auto t_mem_2 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem_2 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
t_mem_2_handle); t_mem_2_handle);
if (t_mem_2.IsNull()) { if (t_mem_2.IsNull()) {
@ -2127,8 +2127,8 @@ void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes"); ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes");
auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem =
t_mem_handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle);
if (t_mem.IsNull()) { if (t_mem.IsNull()) {
LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);

View file

@ -449,8 +449,8 @@ void HidBus::EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes"); ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes");
auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem =
t_mem_handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle);
if (t_mem.IsNull()) { if (t_mem.IsNull()) {
LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);

View file

@ -196,8 +196,8 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()}; const auto parameters{rp.PopRaw<Parameters>()};
const auto t_mem_handle{ctx.GetCopyHandle(0)}; const auto t_mem_handle{ctx.GetCopyHandle(0)};
auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem =
t_mem_handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle);
if (t_mem.IsNull()) { if (t_mem.IsNull()) {
LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
@ -445,8 +445,8 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()}; const auto parameters{rp.PopRaw<Parameters>()};
const auto t_mem_handle{ctx.GetCopyHandle(0)}; const auto t_mem_handle{ctx.GetCopyHandle(0)};
auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem =
t_mem_handle); system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle);
u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress()); u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress());

View file

@ -353,9 +353,9 @@ public:
return; return;
} }
// Fetch using the handle table for the application process here, // Fetch using the handle table for the current process here,
// since we are not multiprocess yet. // since we are not multiprocess yet.
const auto& handle_table{system.ApplicationProcess()->GetHandleTable()}; const auto& handle_table{system.CurrentProcess()->GetHandleTable()};
auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)}; auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)};
if (process.IsNull()) { if (process.IsNull()) {

View file

@ -246,7 +246,7 @@ public:
return; return;
} }
if (system.GetApplicationProcessProgramID() != header.application_id) { if (system.GetCurrentProcessProgramID() != header.application_id) {
LOG_ERROR(Service_LDR, LOG_ERROR(Service_LDR,
"Attempting to load NRR with title ID other than current process. (actual " "Attempting to load NRR with title ID other than current process. (actual "
"{:016X})!", "{:016X})!",
@ -542,16 +542,15 @@ public:
} }
// Map memory for the NRO // Map memory for the NRO
const auto map_result{MapNro(system.ApplicationProcess(), nro_address, nro_size, const auto map_result{MapNro(system.CurrentProcess(), nro_address, nro_size, bss_address,
bss_address, bss_size, nro_size + bss_size)}; bss_size, nro_size + bss_size)};
if (map_result.Failed()) { if (map_result.Failed()) {
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(map_result.Code()); rb.Push(map_result.Code());
} }
// Load the NRO into the mapped memory // Load the NRO into the mapped memory
if (const auto result{ if (const auto result{LoadNro(system.CurrentProcess(), header, nro_address, *map_result)};
LoadNro(system.ApplicationProcess(), header, nro_address, *map_result)};
result.IsError()) { result.IsError()) {
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(map_result.Code()); rb.Push(map_result.Code());
@ -571,7 +570,7 @@ public:
Result UnmapNro(const NROInfo& info) { Result UnmapNro(const NROInfo& info) {
// Each region must be unmapped separately to validate memory state // Each region must be unmapped separately to validate memory state
auto& page_table{system.ApplicationProcess()->PageTable()}; auto& page_table{system.CurrentProcess()->PageTable()};
if (info.bss_size != 0) { if (info.bss_size != 0) {
CASCADE_CODE(page_table.UnmapCodeMemory( CASCADE_CODE(page_table.UnmapCodeMemory(
@ -642,7 +641,7 @@ public:
LOG_WARNING(Service_LDR, "(STUBBED) called"); LOG_WARNING(Service_LDR, "(STUBBED) called");
initialized = true; initialized = true;
current_map_addr = system.ApplicationProcess()->PageTable().GetAliasCodeRegionStart(); current_map_addr = system.CurrentProcess()->PageTable().GetAliasCodeRegionStart();
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View file

@ -618,7 +618,7 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat
sizeof(ApplicationArea) - data.size()); sizeof(ApplicationArea) - data.size());
// TODO: Investigate why the title id needs to be moddified // TODO: Investigate why the title id needs to be moddified
tag_data.title_id = system.GetApplicationProcessProgramID(); tag_data.title_id = system.GetCurrentProcessProgramID();
tag_data.title_id = tag_data.title_id | 0x30000000ULL; tag_data.title_id = tag_data.title_id | 0x30000000ULL;
tag_data.settings.settings.appdata_initialized.Assign(1); tag_data.settings.settings.appdata_initialized.Assign(1);
tag_data.application_area_id = access_id; tag_data.application_area_id = access_id;

View file

@ -150,9 +150,9 @@ NvResult nvhost_ctrl::IocCtrlEventWait(std::span<const u8> input, std::vector<u8
const auto check_failing = [&]() { const auto check_failing = [&]() {
if (events[slot].fails > 2) { if (events[slot].fails > 2) {
{ {
auto lk = system.StallApplication(); auto lk = system.StallProcesses();
host1x_syncpoint_manager.WaitHost(fence_id, target_value); host1x_syncpoint_manager.WaitHost(fence_id, target_value);
system.UnstallApplication(); system.UnstallProcesses();
} }
params.value.raw = target_value; params.value.raw = target_value;
return true; return true;

View file

@ -127,7 +127,7 @@ NvResult nvmap::IocAlloc(std::span<const u8> input, std::vector<u8>& output) {
return result; return result;
} }
bool is_out_io{}; bool is_out_io{};
ASSERT(system.ApplicationProcess() ASSERT(system.CurrentProcess()
->PageTable() ->PageTable()
.LockForMapDeviceAddressSpace(&is_out_io, handle_description->address, .LockForMapDeviceAddressSpace(&is_out_io, handle_description->address,
handle_description->size, handle_description->size,
@ -254,7 +254,7 @@ NvResult nvmap::IocFree(std::span<const u8> input, std::vector<u8>& output) {
if (auto freeInfo{file.FreeHandle(params.handle, false)}) { if (auto freeInfo{file.FreeHandle(params.handle, false)}) {
if (freeInfo->can_unlock) { if (freeInfo->can_unlock) {
ASSERT(system.ApplicationProcess() ASSERT(system.CurrentProcess()
->PageTable() ->PageTable()
.UnlockForDeviceAddressSpace(freeInfo->address, freeInfo->size) .UnlockForDeviceAddressSpace(freeInfo->address, freeInfo->size)
.IsSuccess()); .IsSuccess());

View file

@ -187,7 +187,7 @@ private:
// TODO(ogniK): Recovery flag initialization for pctl:r // TODO(ogniK): Recovery flag initialization for pctl:r
const auto tid = system.GetApplicationProcessProgramID(); const auto tid = system.GetCurrentProcessProgramID();
if (tid != 0) { if (tid != 0) {
const FileSys::PatchManager pm{tid, system.GetFileSystemController(), const FileSys::PatchManager pm{tid, system.GetFileSystemController(),
system.GetContentProvider()}; system.GetContentProvider()};

View file

@ -71,7 +71,7 @@ private:
Type, process_id, data1.size(), data2.size()); Type, process_id, data1.size(), data2.size());
const auto& reporter{system.GetReporter()}; const auto& reporter{system.GetReporter()};
reporter.SavePlayReport(Type, system.GetApplicationProcessProgramID(), {data1, data2}, reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2},
process_id); process_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
@ -99,7 +99,7 @@ private:
Type, user_id[1], user_id[0], process_id, data1.size(), data2.size()); Type, user_id[1], user_id[0], process_id, data1.size(), data2.size());
const auto& reporter{system.GetReporter()}; const auto& reporter{system.GetReporter()};
reporter.SavePlayReport(Type, system.GetApplicationProcessProgramID(), {data1, data2}, reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2},
process_id, user_id); process_id, user_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};

View file

@ -145,7 +145,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
// Apply cheats if they exist and the program has a valid title ID // Apply cheats if they exist and the program has a valid title ID
if (pm) { if (pm) {
system.SetApplicationProcessBuildID(nso_header.build_id); system.SetCurrentProcessBuildID(nso_header.build_id);
const auto cheats = pm->CreateCheatList(nso_header.build_id); const auto cheats = pm->CreateCheatList(nso_header.build_id);
if (!cheats.empty()) { if (!cheats.empty()) {
system.RegisterCheatList(cheats, nso_header.build_id, load_base, image_size); system.RegisterCheatList(cheats, nso_header.build_id, load_base, image_size);

View file

@ -247,11 +247,11 @@ struct Memory::Impl {
} }
void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) {
ReadBlockImpl<false>(*system.ApplicationProcess(), src_addr, dest_buffer, size); ReadBlockImpl<false>(*system.CurrentProcess(), src_addr, dest_buffer, size);
} }
void ReadBlockUnsafe(const VAddr src_addr, void* dest_buffer, const std::size_t size) { void ReadBlockUnsafe(const VAddr src_addr, void* dest_buffer, const std::size_t size) {
ReadBlockImpl<true>(*system.ApplicationProcess(), src_addr, dest_buffer, size); ReadBlockImpl<true>(*system.CurrentProcess(), src_addr, dest_buffer, size);
} }
template <bool UNSAFE> template <bool UNSAFE>
@ -279,11 +279,11 @@ struct Memory::Impl {
} }
void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) {
WriteBlockImpl<false>(*system.ApplicationProcess(), dest_addr, src_buffer, size); WriteBlockImpl<false>(*system.CurrentProcess(), dest_addr, src_buffer, size);
} }
void WriteBlockUnsafe(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { void WriteBlockUnsafe(const VAddr dest_addr, const void* src_buffer, const std::size_t size) {
WriteBlockImpl<true>(*system.ApplicationProcess(), dest_addr, src_buffer, size); WriteBlockImpl<true>(*system.CurrentProcess(), dest_addr, src_buffer, size);
} }
void ZeroBlock(const Kernel::KProcess& process, const VAddr dest_addr, const std::size_t size) { void ZeroBlock(const Kernel::KProcess& process, const VAddr dest_addr, const std::size_t size) {
@ -711,7 +711,7 @@ void Memory::UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) {
} }
bool Memory::IsValidVirtualAddress(const VAddr vaddr) const { bool Memory::IsValidVirtualAddress(const VAddr vaddr) const {
const Kernel::KProcess& process = *system.ApplicationProcess(); const Kernel::KProcess& process = *system.CurrentProcess();
const auto& page_table = process.PageTable().PageTableImpl(); const auto& page_table = process.PageTable().PageTableImpl();
const size_t page = vaddr >> YUZU_PAGEBITS; const size_t page = vaddr >> YUZU_PAGEBITS;
if (page >= page_table.pointers.size()) { if (page >= page_table.pointers.size()) {

View file

@ -191,10 +191,10 @@ void CheatEngine::Initialize() {
}); });
core_timing.ScheduleLoopingEvent(CHEAT_ENGINE_NS, CHEAT_ENGINE_NS, event); core_timing.ScheduleLoopingEvent(CHEAT_ENGINE_NS, CHEAT_ENGINE_NS, event);
metadata.process_id = system.ApplicationProcess()->GetProcessID(); metadata.process_id = system.CurrentProcess()->GetProcessID();
metadata.title_id = system.GetApplicationProcessProgramID(); metadata.title_id = system.GetCurrentProcessProgramID();
const auto& page_table = system.ApplicationProcess()->PageTable(); const auto& page_table = system.CurrentProcess()->PageTable();
metadata.heap_extents = { metadata.heap_extents = {
.base = page_table.GetHeapRegionStart(), .base = page_table.GetHeapRegionStart(),
.size = page_table.GetHeapRegionSize(), .size = page_table.GetHeapRegionSize(),

View file

@ -110,7 +110,7 @@ json GetProcessorStateData(const std::string& architecture, u64 entry_point, u64
} }
json GetProcessorStateDataAuto(Core::System& system) { json GetProcessorStateDataAuto(Core::System& system) {
const auto* process{system.ApplicationProcess()}; const auto* process{system.CurrentProcess()};
auto& arm{system.CurrentArmInterface()}; auto& arm{system.CurrentArmInterface()};
Core::ARM_Interface::ThreadContext64 context{}; Core::ARM_Interface::ThreadContext64 context{};
@ -234,7 +234,7 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64
} }
const auto timestamp = GetTimestamp(); const auto timestamp = GetTimestamp();
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
auto out = GetFullDataAuto(timestamp, title_id, system); auto out = GetFullDataAuto(timestamp, title_id, system);
auto break_out = json{ auto break_out = json{
@ -261,7 +261,7 @@ void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u
} }
const auto timestamp = GetTimestamp(); const auto timestamp = GetTimestamp();
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
auto out = GetFullDataAuto(timestamp, title_id, system); auto out = GetFullDataAuto(timestamp, title_id, system);
auto function_out = GetHLERequestContextData(ctx, system.Memory()); auto function_out = GetHLERequestContextData(ctx, system.Memory());
@ -283,7 +283,7 @@ void Reporter::SaveUnimplementedAppletReport(
} }
const auto timestamp = GetTimestamp(); const auto timestamp = GetTimestamp();
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
auto out = GetFullDataAuto(timestamp, title_id, system); auto out = GetFullDataAuto(timestamp, title_id, system);
out["applet_common_args"] = { out["applet_common_args"] = {
@ -376,7 +376,7 @@ void Reporter::SaveUserReport() const {
} }
const auto timestamp = GetTimestamp(); const auto timestamp = GetTimestamp();
const auto title_id = system.GetApplicationProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
SaveToFile(GetFullDataAuto(timestamp, title_id, system), SaveToFile(GetFullDataAuto(timestamp, title_id, system),
GetPath("user_report", title_id, timestamp)); GetPath("user_report", title_id, timestamp));

View file

@ -67,7 +67,7 @@ void EmuThread::run() {
emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
if (Settings::values.use_disk_shader_cache.GetValue()) { if (Settings::values.use_disk_shader_cache.GetValue()) {
m_system.Renderer().ReadRasterizer()->LoadDiskResources( m_system.Renderer().ReadRasterizer()->LoadDiskResources(
m_system.GetApplicationProcessProgramID(), stop_token, m_system.GetCurrentProcessProgramID(), stop_token,
[this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) {
emit LoadProgress(stage, value, total); emit LoadProgress(stage, value, total);
}); });

View file

@ -1779,7 +1779,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())} std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}
.filename()); .filename());
} }
const bool is_64bit = system->Kernel().ApplicationProcess()->Is64BitProcess(); const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess();
const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)");
title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit")
.arg(QString::fromStdString(title_name), instruction_set_suffix) .arg(QString::fromStdString(title_name), instruction_set_suffix)
@ -3544,7 +3544,7 @@ void GMainWindow::OnToggleGraphicsAPI() {
} }
void GMainWindow::OnConfigurePerGame() { void GMainWindow::OnConfigurePerGame() {
const u64 title_id = system->GetApplicationProcessProgramID(); const u64 title_id = system->GetCurrentProcessProgramID();
OpenPerGameConfiguration(title_id, current_game_path.toStdString()); OpenPerGameConfiguration(title_id, current_game_path.toStdString());
} }
@ -3703,7 +3703,7 @@ void GMainWindow::OnCaptureScreenshot() {
return; return;
} }
const u64 title_id = system->GetApplicationProcessProgramID(); const u64 title_id = system->GetCurrentProcessProgramID();
const auto screenshot_path = const auto screenshot_path =
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir));
const auto date = const auto date =

View file

@ -405,7 +405,7 @@ int main(int argc, char** argv) {
if (Settings::values.use_disk_shader_cache.GetValue()) { if (Settings::values.use_disk_shader_cache.GetValue()) {
system.Renderer().ReadRasterizer()->LoadDiskResources( system.Renderer().ReadRasterizer()->LoadDiskResources(
system.GetApplicationProcessProgramID(), std::stop_token{}, system.GetCurrentProcessProgramID(), std::stop_token{},
[](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
} }