Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"
This reverts commit 15b7df8ef1.
This commit is contained in:
@@ -1,115 +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>
|
||||
|
||||
extern "C" {
|
||||
|
||||
constinit u32 __nx_fs_num_sessions = 1;
|
||||
constinit u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
constinit bool __nx_fsdev_support_cwd = false;
|
||||
|
||||
extern int __system_argc;
|
||||
extern char** __system_argv;
|
||||
|
||||
alignas(16) constinit u8 __nx_exception_stack[::ams::os::MemoryPageSize];
|
||||
constinit u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
||||
|
||||
}
|
||||
|
||||
namespace ams {
|
||||
|
||||
namespace hos {
|
||||
|
||||
void InitializeForStratosphere();
|
||||
|
||||
}
|
||||
|
||||
namespace init {
|
||||
|
||||
void InitializeSystemModuleBeforeConstructors();
|
||||
|
||||
void InitializeSystemModule();
|
||||
void FinalizeSystemModule();
|
||||
|
||||
void Startup();
|
||||
|
||||
}
|
||||
|
||||
void Main();
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constinit char *g_empty_argv = nullptr;
|
||||
|
||||
}
|
||||
|
||||
extern "C" void __libnx_exception_handler(ThreadExceptionDump *ctx) {
|
||||
::ams::CrashHandler(ctx);
|
||||
}
|
||||
|
||||
extern "C" void __libnx_initheap(void) {
|
||||
/* Stratosphere system modules do not support newlib heap. */
|
||||
}
|
||||
|
||||
extern "C" void __appInit(void) {
|
||||
/* The very first thing all stratosphere code must do is initialize the os library. */
|
||||
::ams::hos::InitializeForStratosphere();
|
||||
|
||||
/* Perform pre-C++ constructor init. */
|
||||
::ams::init::InitializeSystemModuleBeforeConstructors();
|
||||
}
|
||||
|
||||
extern "C" void __appExit(void) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
extern "C" void argvSetup(void) {
|
||||
/* We don't use newlib argc/argv, so we can clear these. */
|
||||
__system_argc = 0;
|
||||
__system_argv = std::addressof(g_empty_argv);
|
||||
}
|
||||
|
||||
extern "C" int main(int argc, char **argv) {
|
||||
/* We don't use newlib argc/argv. */
|
||||
AMS_UNUSED(argc, argv);
|
||||
|
||||
/* Perform remainder of logic with system module initialized. */
|
||||
{
|
||||
::ams::init::InitializeSystemModule();
|
||||
ON_SCOPE_EXIT { ::ams::init::FinalizeSystemModule(); };
|
||||
|
||||
/* Perform miscellaneous startup. */
|
||||
::ams::init::Startup();
|
||||
|
||||
/* Invoke ams main. */
|
||||
::ams::Main();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" WEAK_SYMBOL void *__libnx_alloc(size_t) {
|
||||
AMS_ABORT("__libnx_alloc was called");
|
||||
}
|
||||
|
||||
extern "C" WEAK_SYMBOL void *__libnx_aligned_alloc(size_t, size_t) {
|
||||
AMS_ABORT("__libnx_aligned_alloc was called");
|
||||
}
|
||||
|
||||
extern "C" WEAK_SYMBOL void __libnx_free(void *) {
|
||||
AMS_ABORT("__libnx_free was called");
|
||||
}
|
||||
@@ -1,177 +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>
|
||||
|
||||
/* NOTE: If AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC is defined, the relevant os primitives should be hooked up. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
#define AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC
|
||||
#elif defined(ATMOSPHERE_OS_WINDOWS)
|
||||
//#define AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC
|
||||
#elif defined(ATMOSPHERE_OS_LINUX)
|
||||
//#define AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC
|
||||
#elif defined(ATMOSPHERE_OS_MACOS)
|
||||
//#define AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC
|
||||
#else
|
||||
#error "Unknown OS for enabling StandardAllocator backing impl for malloc"
|
||||
#endif
|
||||
|
||||
namespace ams::init {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC)
|
||||
constinit void *g_malloc_region_address = nullptr;
|
||||
constinit size_t g_malloc_region_size = 0;
|
||||
|
||||
constinit util::TypedStorage<mem::StandardAllocator> g_malloc_allocator = {};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void InitializeAllocator(void *address, size_t size, bool cache_enabled) {
|
||||
#if defined(AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC)
|
||||
/* Check pre-conditions. */
|
||||
AMS_ABORT_UNLESS(g_malloc_region_size == 0);
|
||||
AMS_ABORT_UNLESS(size > 0);
|
||||
|
||||
/* Construct malloc allocator. */
|
||||
util::ConstructAt(g_malloc_allocator);
|
||||
|
||||
/* Initialize allocator. */
|
||||
util::GetReference(g_malloc_allocator).Initialize(address, size, cache_enabled);
|
||||
|
||||
/* Set malloc globals. */
|
||||
g_malloc_region_address = address;
|
||||
g_malloc_region_size = size;
|
||||
#else
|
||||
AMS_UNUSED(address, size, cache_enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void InitializeAllocator(void *address, size_t size) {
|
||||
return InitializeAllocator(address, size, false);
|
||||
}
|
||||
|
||||
void InitializeDefaultAllocator() {
|
||||
/* TODO: What should default heap size be? This uses virtual address space memory. */
|
||||
return InitializeAllocator(nullptr, 128_MB, false);
|
||||
}
|
||||
|
||||
mem::StandardAllocator *GetAllocator() {
|
||||
#if defined(AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC)
|
||||
/* Check pre-conditions. */
|
||||
AMS_ASSERT(g_malloc_region_size > 0);
|
||||
|
||||
return util::GetPointer(g_malloc_allocator);
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if defined(AMS_INIT_USE_STANDARD_ALLOCATOR_FOR_MALLOC)
|
||||
extern "C" void *malloc(size_t size) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Try to allocate. */
|
||||
void *ptr = ::ams::util::GetReference(::ams::init::g_malloc_allocator).Allocate(size);
|
||||
if (ptr == nullptr) {
|
||||
errno = ENOMEM;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void free(void *ptr) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr != nullptr) {
|
||||
::ams::util::GetReference(::ams::init::g_malloc_allocator).Free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void *calloc(size_t num, size_t size) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Allocate the total needed space. */
|
||||
const size_t total = num * size;
|
||||
void *ptr = std::malloc(total);
|
||||
|
||||
/* Zero the memory if needed. */
|
||||
if (ptr != nullptr) {
|
||||
std::memset(ptr, 0, total);
|
||||
} else {
|
||||
errno = ENOMEM;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *realloc(void *ptr, size_t new_size) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Try to reallocate. */
|
||||
void *r = ::ams::util::GetReference(::ams::init::g_malloc_allocator).Reallocate(ptr, new_size);
|
||||
if (r == nullptr) {
|
||||
errno = ENOMEM;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
extern "C" void *aligned_alloc(size_t align, size_t size) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Try to allocate. */
|
||||
void *ptr = ::ams::util::GetReference(::ams::init::g_malloc_allocator).Allocate(size, align);
|
||||
if (ptr == nullptr) {
|
||||
errno = ENOMEM;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" size_t malloc_usable_size(void *ptr) {
|
||||
/* We require that an allocator region exists. */
|
||||
if (::ams::init::g_malloc_region_size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Try to get the usable size. */
|
||||
if (ptr == nullptr) {
|
||||
errno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ::ams::util::GetReference(::ams::init::g_malloc_allocator).GetSizeOf(ptr);
|
||||
}
|
||||
#endif
|
||||
@@ -1,48 +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>
|
||||
|
||||
WEAK_SYMBOL void *operator new(size_t size) {
|
||||
return std::malloc(size);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void *operator new(size_t size, const std::nothrow_t &) noexcept {
|
||||
return std::malloc(size);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void operator delete(void *p) noexcept {
|
||||
return std::free(p);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void operator delete(void *p, size_t) noexcept {
|
||||
return std::free(p);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void *operator new[](size_t size) {
|
||||
return std::malloc(size);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void *operator new[](size_t size, const std::nothrow_t &) noexcept {
|
||||
return std::malloc(size);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void operator delete[](void *p) noexcept {
|
||||
return std::free(p);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void operator delete[](void *p, size_t) noexcept {
|
||||
return std::free(p);
|
||||
}
|
||||
@@ -1,38 +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::init {
|
||||
|
||||
WEAK_SYMBOL void InitializeSystemModuleBeforeConstructors() {
|
||||
/* This should only be used in exceptional circumstances. */
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void InitializeSystemModule() {
|
||||
/* TODO: What should we do here, if anything? */
|
||||
/* Nintendo does nndiagStartup(); nn::diag::InitializeSystemProcessAbortObserver(); */
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void FinalizeSystemModule() {
|
||||
/* Do nothing by default. */
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void Startup() {
|
||||
/* TODO: What should we do here, if anything? */
|
||||
/* Nintendo determines heap size and does init::InitializeAllocator, as relevant. */
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user