sm/tipc: minor cleanup

This commit is contained in:
Michael Scire
2021-10-12 00:20:21 -07:00
parent 124a1a1ea0
commit 0189c5f1e6
15 changed files with 394 additions and 599 deletions

View File

@@ -1,62 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
namespace ams::cfg {
namespace {
constinit os::SdkMutex g_lock;
constinit bool g_got_privileged_process_status = false;
constinit os::ProcessId g_min_initial_process_id = os::InvalidProcessId, g_max_initial_process_id = os::InvalidProcessId;
constinit os::ProcessId g_cur_process_id = os::InvalidProcessId;
ALWAYS_INLINE void EnsurePrivilegedProcessStatusCached() {
if (AMS_LIKELY(g_got_privileged_process_status)) {
return;
}
std::scoped_lock lk(g_lock);
if (AMS_LIKELY(!g_got_privileged_process_status)) {
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_min_initial_process_id.value), svc::SystemInfoType_InitialProcessIdRange, svc::InvalidHandle, svc::InitialProcessIdRangeInfo_Minimum));
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_max_initial_process_id.value), svc::SystemInfoType_InitialProcessIdRange, svc::InvalidHandle, svc::InitialProcessIdRangeInfo_Maximum));
g_cur_process_id = os::GetCurrentProcessId();
g_got_privileged_process_status = true;
}
}
}
bool IsInitialProcess() {
/* Cache initial process range and extents. */
EnsurePrivilegedProcessStatusCached();
/* Determine if we're Initial. */
return g_min_initial_process_id <= g_cur_process_id && g_cur_process_id <= g_max_initial_process_id;
}
void GetInitialProcessRange(os::ProcessId *out_min, os::ProcessId *out_max) {
/* Cache initial process range and extents. */
EnsurePrivilegedProcessStatusCached();
/* Set output. */
*out_min = g_min_initial_process_id;
*out_max = g_max_initial_process_id;
}
}

View File

@@ -171,7 +171,7 @@ namespace ams::pgl::srv {
}
Result ShellInterfaceTipc::GetShellEventObserver(ams::tipc::OutMoveHandle out) {
return pgl::srv::AllocateShellEventObserverForTipc(out.GetHandlePointer());
return pgl::srv::AllocateShellEventObserverForTipc(out.GetPointer());
}
}