2020-04-17 05:57:01 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-04-17 05:57:01 +00:00
|
|
|
*
|
|
|
|
* 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 "hos_version_api_private.hpp"
|
2021-05-02 17:33:15 +00:00
|
|
|
#include "../os/impl/os_rng_manager.hpp"
|
2020-04-17 05:57:01 +00:00
|
|
|
|
|
|
|
namespace ams::os {
|
|
|
|
|
|
|
|
void InitializeForStratosphereInternal();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-05-02 17:33:15 +00:00
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
/* Provide libnx address space allocation shim. */
|
|
|
|
uintptr_t __libnx_virtmem_rng(void) {
|
|
|
|
return static_cast<uintptr_t>(::ams::os::impl::GetRngManager().GenerateRandomU64());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-17 05:57:01 +00:00
|
|
|
namespace ams::hos {
|
|
|
|
|
|
|
|
void InitializeForStratosphere() {
|
|
|
|
/* Initialize the global os resource managers. This *must* be done before anything else in stratosphere. */
|
|
|
|
os::InitializeForStratosphereInternal();
|
|
|
|
|
|
|
|
/* Initialize hos::Version API. */
|
|
|
|
hos::SetVersionForLibnxInternal();
|
2021-09-05 17:08:30 +00:00
|
|
|
|
|
|
|
/* Check that we're running under mesosphere. */
|
|
|
|
AMS_ABORT_UNLESS(svc::IsKernelMesosphere());
|
2020-04-17 05:57:01 +00:00
|
|
|
}
|
|
|
|
|
2020-05-11 22:04:51 +00:00
|
|
|
void InitializeForStratosphereDebug(hos::Version debug_version) {
|
|
|
|
/* Initialize the global os resource managers. This *must* be done before anything else in stratosphere. */
|
|
|
|
os::InitializeForStratosphereInternal();
|
|
|
|
|
|
|
|
/* Initialize hos::Version API. */
|
|
|
|
hos::SetVersionForLibnxInternalDebug(debug_version);
|
2021-09-05 17:08:30 +00:00
|
|
|
|
|
|
|
/* Check that we're running under mesosphere. */
|
|
|
|
AMS_ABORT_UNLESS(svc::IsKernelMesosphere());
|
2020-05-11 22:04:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 05:57:01 +00:00
|
|
|
}
|