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,132 +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 "impl/dd_device_address_space_impl.hpp"
namespace ams::dd {
Result CreateDeviceAddressSpace(DeviceAddressSpaceType *das, u64 address, u64 size) {
/* Check pre-conditions. */
AMS_ASSERT(util::IsAligned(address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(size, os::MemoryPageSize));
AMS_ASSERT(size > 0);
/* Ensure we leave in a consistent state. */
auto state_guard = SCOPE_GUARD { das->state = DeviceAddressSpaceType::State_NotInitialized; };
/* Create the address space. */
DeviceAddressSpaceHandle handle;
R_TRY(impl::DeviceAddressSpaceImpl::Create(std::addressof(handle), address, size));
/* Set the values in the das. */
das->device_handle = handle;
das->is_handle_managed = true;
das->state = DeviceAddressSpaceType::State_Initialized;
/* We succeeded. */
state_guard.Cancel();
R_SUCCEED();
}
Result CreateDeviceAddressSpace(DeviceAddressSpaceType *das, u64 size) {
R_RETURN(CreateDeviceAddressSpace(das, 0, size));
}
void DestroyDeviceAddressSpace(DeviceAddressSpaceType *das) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
/* Destroy the handle. */
if (das->is_handle_managed) {
impl::DeviceAddressSpaceImpl::Close(das->device_handle);
}
das->device_handle = 0;
das->is_handle_managed = false;
das->state = DeviceAddressSpaceType::State_NotInitialized;
}
void AttachDeviceAddressSpaceHandle(DeviceAddressSpaceType *das, DeviceAddressSpaceHandle handle, bool managed) {
/* Check pre-conditions. */
AMS_ASSERT(handle != os::InvalidNativeHandle);
das->device_handle = handle;
das->is_handle_managed = managed;
das->state = DeviceAddressSpaceType::State_Initialized;
}
DeviceAddressSpaceHandle GetDeviceAddressSpaceHandle(DeviceAddressSpaceType *das) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
return das->device_handle;
}
Result MapDeviceAddressSpaceAligned(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address, MemoryPermission device_perm) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
AMS_ASSERT(util::IsAligned(process_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(device_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(size, os::MemoryPageSize));
AMS_ASSERT(process_address + size > process_address);
AMS_ASSERT(device_address + size > device_address);
AMS_ASSERT(size > 0);
AMS_ASSERT((process_address & (4_MB - 1)) == (device_address & (4_MB - 1)));
R_RETURN(impl::DeviceAddressSpaceImpl::MapAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm));
}
Result MapDeviceAddressSpaceNotAligned(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address, MemoryPermission device_perm) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
AMS_ASSERT(util::IsAligned(process_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(device_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(size, os::MemoryPageSize));
AMS_ASSERT(process_address + size > process_address);
AMS_ASSERT(device_address + size > device_address);
AMS_ASSERT(size > 0);
R_RETURN(impl::DeviceAddressSpaceImpl::MapNotAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm));
}
void UnmapDeviceAddressSpace(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
AMS_ASSERT(util::IsAligned(process_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(device_address, os::MemoryPageSize));
AMS_ASSERT(util::IsAligned(size, os::MemoryPageSize));
AMS_ASSERT(process_address + size > process_address);
AMS_ASSERT(device_address + size > device_address);
AMS_ASSERT(size > 0);
return impl::DeviceAddressSpaceImpl::Unmap(das->device_handle, process_handle, process_address, size, device_address);
}
Result AttachDeviceAddressSpace(DeviceAddressSpaceType *das, DeviceName device_name) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
R_RETURN(impl::DeviceAddressSpaceImpl::Attach(das, device_name));
}
void DetachDeviceAddressSpace(DeviceAddressSpaceType *das, DeviceName device_name) {
/* Check pre-conditions. */
AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized);
return impl::DeviceAddressSpaceImpl::Detach(das, device_name);
}
}

View File

@@ -1,54 +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/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::dd::impl {
class DeviceAddressSpaceImplByWindows {
public:
static Result Create(DeviceAddressSpaceHandle *, u64, u64) {
R_THROW(dd::ResultNotSupported());
}
static void Close(DeviceAddressSpaceHandle) {
/* ... */
}
static Result MapAligned(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress, dd::MemoryPermission) {
R_THROW(dd::ResultNotSupported());
}
static Result MapNotAligned(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress, dd::MemoryPermission) {
R_THROW(dd::ResultNotSupported());
}
static void Unmap(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress) {
/* ... */
}
static Result Attach(DeviceAddressSpaceType *, DeviceName) {
R_THROW(dd::ResultNotSupported());
}
static void Detach(DeviceAddressSpaceType *, DeviceName) {
/* ... */
}
};
using DeviceAddressSpaceImpl = DeviceAddressSpaceImplByWindows;
}

View File

@@ -1,23 +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/>.
*/
#pragma once
#include <stratosphere.hpp>
#if defined(ATMOSPHERE_OS_HORIZON)
#include "dd_device_address_space_impl.os.horizon.hpp"
#else
#include "dd_device_address_space_impl.generic.hpp"
#endif

View File

@@ -1,88 +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 "dd_device_address_space_impl.os.horizon.hpp"
namespace ams::dd::impl {
static_assert(static_cast<int>(dd::MemoryPermission_None) == static_cast<int>(svc::MemoryPermission_None));
static_assert(static_cast<int>(dd::MemoryPermission_ReadOnly) == static_cast<int>(svc::MemoryPermission_Read));
static_assert(static_cast<int>(dd::MemoryPermission_WriteOnly) == static_cast<int>(svc::MemoryPermission_Write));
static_assert(static_cast<int>(dd::MemoryPermission_ReadWrite) == static_cast<int>(svc::MemoryPermission_ReadWrite));
Result DeviceAddressSpaceImplByHorizon::Create(DeviceAddressSpaceHandle *out, u64 address, u64 size) {
/* Create the space. */
svc::Handle handle;
R_TRY_CATCH(svc::CreateDeviceAddressSpace(std::addressof(handle), address, size)) {
R_CONVERT(svc::ResultOutOfMemory, dd::ResultOutOfMemory())
R_CONVERT(svc::ResultOutOfResource, dd::ResultOutOfResource())
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
*out = static_cast<DeviceAddressSpaceHandle>(handle);
R_SUCCEED();
}
void DeviceAddressSpaceImplByHorizon::Close(DeviceAddressSpaceHandle handle) {
const auto svc_handle = svc::Handle(handle);
if (svc_handle == svc::PseudoHandle::CurrentThread || svc_handle == svc::PseudoHandle::CurrentProcess) {
return;
}
R_ABORT_UNLESS(svc::CloseHandle(svc_handle));
}
Result DeviceAddressSpaceImplByHorizon::MapAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm) {
/* Check alignment. */
AMS_ABORT_UNLESS((process_address & (4_MB - 1)) == (device_address & (4_MB - 1)));
R_TRY_CATCH(svc::MapDeviceAddressSpaceAligned(svc::Handle(handle), svc::Handle(process_handle), process_address, process_size, device_address, svc::MapDeviceAddressSpaceOption::Encode(static_cast<svc::MemoryPermission>(device_perm), svc::MapDeviceAddressSpaceFlag_None))) {
R_CONVERT(svc::ResultInvalidHandle, dd::ResultInvalidHandle())
R_CONVERT(svc::ResultOutOfMemory, dd::ResultOutOfMemory())
R_CONVERT(svc::ResultOutOfResource, dd::ResultOutOfResource())
R_CONVERT(svc::ResultInvalidCurrentMemory, dd::ResultInvalidMemoryState())
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
R_SUCCEED();
}
Result DeviceAddressSpaceImplByHorizon::MapNotAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm) {
R_TRY_CATCH(svc::MapDeviceAddressSpaceByForce(svc::Handle(handle), svc::Handle(process_handle), process_address, process_size, device_address, svc::MapDeviceAddressSpaceOption::Encode(static_cast<svc::MemoryPermission>(device_perm), svc::MapDeviceAddressSpaceFlag_None))) {
R_CONVERT(svc::ResultInvalidHandle, dd::ResultInvalidHandle())
R_CONVERT(svc::ResultOutOfMemory, dd::ResultOutOfMemory())
R_CONVERT(svc::ResultOutOfResource, dd::ResultOutOfResource())
R_CONVERT(svc::ResultInvalidCurrentMemory, dd::ResultInvalidMemoryState())
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
R_SUCCEED();
}
void DeviceAddressSpaceImplByHorizon::Unmap(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address) {
R_ABORT_UNLESS(svc::UnmapDeviceAddressSpace(svc::Handle(handle), svc::Handle(process_handle), process_address, process_size, device_address));
}
Result DeviceAddressSpaceImplByHorizon::Attach(DeviceAddressSpaceType *das, DeviceName device_name) {
R_TRY_CATCH(svc::AttachDeviceAddressSpace(static_cast<svc::DeviceName>(device_name), svc::Handle(das->device_handle))) {
R_CONVERT(svc::ResultOutOfMemory, dd::ResultOutOfMemory())
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
R_SUCCEED();
}
void DeviceAddressSpaceImplByHorizon::Detach(DeviceAddressSpaceType *das, DeviceName device_name) {
R_ABORT_UNLESS(svc::DetachDeviceAddressSpace(static_cast<svc::DeviceName>(device_name), svc::Handle(das->device_handle)));
}
}

View File

@@ -1,36 +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/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::dd::impl {
class DeviceAddressSpaceImplByHorizon {
public:
static Result Create(DeviceAddressSpaceHandle *out, u64 address, u64 size);
static void Close(DeviceAddressSpaceHandle handle);
static Result MapAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm);
static Result MapNotAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm);
static void Unmap(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address);
static Result Attach(DeviceAddressSpaceType *das, DeviceName device_name);
static void Detach(DeviceAddressSpaceType *das, DeviceName device_name);
};
using DeviceAddressSpaceImpl = DeviceAddressSpaceImplByHorizon;
}