Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"

This reverts commit 15b7df8ef1.
This commit is contained in:
souldbminersmwc
2025-11-09 16:14:52 -05:00
parent 22ec140738
commit 21a3f953d7
3804 changed files with 435 additions and 570162 deletions

View File

@@ -1,92 +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 <switch.h>
#include "pm_ams.os.horizon.h"
Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 program_id) {
return serviceDispatchInOut(pminfoGetServiceSession(), 65000, program_id, *out_pid);
}
Result pminfoAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id) {
u8 tmp = 0;
Result rc = serviceDispatchInOut(pminfoGetServiceSession(), 65001, program_id, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid) {
struct {
NcmProgramLocation loc;
CfgOverrideStatus status;
} out;
Result rc = serviceDispatchInOut(pminfoGetServiceSession(), 65002, pid, out);
if (R_SUCCEEDED(rc)) {
if (loc_out) *loc_out = out.loc;
if (status_out) *status_out = out.status;
}
return rc;
}
Result pmdmntAtmosphereGetProcessInfo(Handle* handle_out, NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid) {
Handle tmp_handle;
struct {
NcmProgramLocation loc;
CfgOverrideStatus status;
} out;
Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65000, pid, out,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &tmp_handle,
);
if (R_SUCCEEDED(rc)) {
if (handle_out) {
*handle_out = tmp_handle;
} else {
svcCloseHandle(tmp_handle);
}
if (loc_out) *loc_out = out.loc;
if (status_out) *status_out = out.status;
}
return rc;
}
Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource) {
const struct {
u32 group;
u32 resource;
} in = { group, resource };
struct {
u64 cur;
u64 lim;
} out;
Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65001, in, out);
if (R_SUCCEEDED(rc)) {
if (out_cur) *out_cur = out.cur;
if (out_lim) *out_lim = out.lim;
}
return rc;
}

View File

@@ -1,33 +0,0 @@
/**
* @file pm_ams.h
* @brief Process Manager (pm:*) IPC wrapper for Atmosphere extensions.
* @author SciresM
* @copyright libnx Authors
*/
#pragma once
#if defined(ATMOSPHERE_OS_HORIZON)
#include <switch.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u64 keys_held;
u64 flags;
} CfgOverrideStatus;
Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 program_id);
Result pminfoAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id);
Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid);
Result pmdmntAtmosphereGetProcessInfo(Handle *out, NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid);
Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,42 +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::pm::bm {
/* Boot Mode API. */
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
#if defined(ATMOSPHERE_OS_HORIZON)
BootMode WEAK_SYMBOL GetBootMode() {
PmBootMode boot_mode = PmBootMode_Normal;
R_ABORT_UNLESS(pmbmGetBootMode(std::addressof(boot_mode)));
return static_cast<BootMode>(boot_mode);
}
void WEAK_SYMBOL SetMaintenanceBoot() {
R_ABORT_UNLESS(pmbmSetMaintenanceBoot());
}
#else
BootMode WEAK_SYMBOL GetBootMode() {
AMS_ABORT("TODO");
}
void WEAK_SYMBOL SetMaintenanceBoot() {
AMS_ABORT("TODO");
}
#endif
}

View File

@@ -1,69 +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>
#include "pm_ams.os.horizon.h"
namespace ams::pm::dmnt {
/* Debug Monitor API. */
#if defined(ATMOSPHERE_OS_HORIZON)
Result StartProcess(os::ProcessId process_id) {
R_RETURN(pmdmntStartProcess(static_cast<u64>(process_id)));
}
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id) {
R_RETURN(pmdmntGetProgramId(reinterpret_cast<u64 *>(out_program_id), static_cast<u64>(process_id)));
}
Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id) {
R_RETURN(pmdmntGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(program_id)));
}
Result GetApplicationProcessId(os::ProcessId *out_process_id) {
R_RETURN(pmdmntGetApplicationProcessId(reinterpret_cast<u64 *>(out_process_id)));
}
Result HookToCreateApplicationProcess(os::NativeHandle *out_handle) {
Event evt;
R_TRY(pmdmntHookToCreateApplicationProcess(std::addressof(evt)));
*out_handle = evt.revent;
R_SUCCEED();
}
Result HookToCreateProcess(os::NativeHandle *out_handle, const ncm::ProgramId program_id) {
Event evt;
R_TRY(pmdmntHookToCreateProcess(std::addressof(evt), static_cast<u64>(program_id)));
*out_handle = evt.revent;
R_SUCCEED();
}
Result AtmosphereGetProcessInfo(os::NativeHandle *out_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id) {
*out_handle = os::InvalidNativeHandle;
*out_loc = {};
*out_status = {};
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus));
R_RETURN(pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<NcmProgramLocation *>(out_loc), reinterpret_cast<CfgOverrideStatus *>(out_status), static_cast<u64>(process_id)));
}
Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, svc::LimitableResource resource) {
*out_current_value = 0;
*out_limit_value = 0;
R_RETURN(pmdmntAtmosphereGetCurrentLimitInfo(out_current_value, out_limit_value, group, resource));
}
#endif
}

View File

@@ -1,72 +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>
#include "pm_ams.os.horizon.h"
namespace ams::pm::info {
/* Information API. */
#if defined(ATMOSPHERE_OS_HORIZON)
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id) {
R_RETURN(pminfoGetProgramId(reinterpret_cast<u64 *>(out_program_id), static_cast<u64>(process_id)));
}
Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id) {
R_RETURN(pminfoAtmosphereGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(program_id)));
}
Result GetAppletResourceLimitCurrentValue(pm::ResourceLimitValue *out) {
static_assert(sizeof(pm::ResourceLimitValue) == sizeof(::PmResourceLimitValues));
R_RETURN(pminfoGetAppletCurrentResourceLimitValues(reinterpret_cast<PmResourceLimitValues *>(out)));
}
Result GetAppletResourceLimitPeakValue(pm::ResourceLimitValue *out) {
static_assert(sizeof(pm::ResourceLimitValue) == sizeof(::PmResourceLimitValues));
R_RETURN(pminfoGetAppletPeakResourceLimitValues(reinterpret_cast<PmResourceLimitValues *>(out)));
}
Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id) {
*out_loc = {};
*out_status = {};
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus));
R_RETURN(pminfoAtmosphereGetProcessInfo(reinterpret_cast<NcmProgramLocation *>(out_loc), reinterpret_cast<CfgOverrideStatus *>(out_status), static_cast<u64>(process_id)));
}
bool HasLaunchedBootProgram(ncm::ProgramId program_id) {
bool has_launched = false;
R_ABORT_UNLESS(HasLaunchedBootProgram(std::addressof(has_launched), program_id));
return has_launched;
}
Result IsHblProcessId(bool *out, os::ProcessId process_id) {
ncm::ProgramLocation loc;
cfg::OverrideStatus override_status;
R_TRY(GetProcessInfo(std::addressof(loc), std::addressof(override_status), process_id));
*out = override_status.IsHbl();
R_SUCCEED();
}
Result IsHblProgramId(bool *out, ncm::ProgramId program_id) {
os::ProcessId process_id;
R_TRY(GetProcessId(std::addressof(process_id), program_id));
R_RETURN(IsHblProcessId(out, process_id));
}
#endif
}

View File

@@ -1,31 +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>
#include "pm_ams.os.horizon.h"
namespace ams::pm::info {
/* Information API. */
#if defined(ATMOSPHERE_OS_HORIZON)
Result WEAK_SYMBOL HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) {
bool has_launched = false;
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(std::addressof(has_launched), static_cast<u64>(program_id)));
*out = has_launched;
R_SUCCEED();
}
#endif
}

View File

@@ -1,63 +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>
#include "pm_ams.os.horizon.h"
namespace ams::pm::shell {
/* Shell API. */
#if defined(ATMOSPHERE_OS_HORIZON)
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) {
static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation));
static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation));
R_RETURN(pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<u64 *>(out)));
}
Result TerminateProcess(os::ProcessId process_id) {
R_RETURN(::pmshellTerminateProcess(static_cast<u64>(process_id)));
}
Result GetProcessEventEvent(os::SystemEvent *out) {
::Event evt;
R_TRY(::pmshellGetProcessEventHandle(std::addressof(evt)));
out->Attach(evt.revent, true, svc::InvalidHandle, false, os::EventClearMode_ManualClear);
R_SUCCEED();
}
Result GetProcessEventInfo(ProcessEventInfo *out) {
static_assert(sizeof(*out) == sizeof(::PmProcessEventInfo));
R_RETURN(::pmshellGetProcessEventInfo(reinterpret_cast<::PmProcessEventInfo *>(out)));
}
Result GetApplicationProcessIdForShell(os::ProcessId *out) {
static_assert(sizeof(*out) == sizeof(u64));
R_RETURN(::pmshellGetApplicationProcessIdForShell(reinterpret_cast<u64 *>(out)));
}
Result BoostSystemMemoryResourceLimit(u64 size) {
R_RETURN(::pmshellBoostSystemMemoryResourceLimit(size));
}
Result BoostApplicationThreadResourceLimit() {
R_RETURN(::pmshellBoostApplicationThreadResourceLimit());
}
Result BoostSystemThreadResourceLimit() {
R_RETURN(::pmshellBoostSystemThreadResourceLimit());
}
#endif
}