2020-01-29 06:09:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020 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 <mesosphere.hpp>
|
|
|
|
|
|
|
|
namespace ams::kern {
|
|
|
|
|
|
|
|
NORETURN void HorizonKernelMain(s32 core_id) {
|
2020-01-29 22:26:24 +00:00
|
|
|
/* Setup the Core Local Region, and note that we're initializing. */
|
2020-01-31 09:53:30 +00:00
|
|
|
Kernel::InitializeCoreLocalRegion(core_id);
|
2020-01-29 22:26:24 +00:00
|
|
|
Kernel::SetState(Kernel::State::Initializing);
|
|
|
|
|
|
|
|
/* Ensure that all cores get to this point before proceeding. */
|
2020-01-29 06:09:47 +00:00
|
|
|
cpu::SynchronizeAllCores();
|
2020-01-29 22:26:24 +00:00
|
|
|
|
2020-01-30 06:06:25 +00:00
|
|
|
/* Initialize the main and idle thread for each core. */
|
|
|
|
/* Synchronize after each init to ensure the cores go in order. */
|
|
|
|
for (size_t i = 0; i < cpu::NumCores; i++) {
|
|
|
|
if (static_cast<s32>(i) == core_id) {
|
2020-01-31 09:53:30 +00:00
|
|
|
Kernel::InitializeMainAndIdleThreads(core_id);
|
2020-01-30 06:06:25 +00:00
|
|
|
}
|
|
|
|
cpu::SynchronizeAllCores();
|
|
|
|
}
|
|
|
|
|
2020-01-30 09:41:59 +00:00
|
|
|
if (core_id == 0) {
|
2020-02-06 09:05:35 +00:00
|
|
|
/* Initialize KSystemControl. */
|
|
|
|
KSystemControl::Initialize();
|
|
|
|
|
2020-02-07 01:40:57 +00:00
|
|
|
/* Initialize the memory manager. */
|
|
|
|
{
|
|
|
|
const auto &metadata_region = KMemoryLayout::GetMetadataPoolRegion();
|
|
|
|
Kernel::GetMemoryManager().Initialize(metadata_region.GetAddress(), metadata_region.GetSize());
|
|
|
|
}
|
|
|
|
|
2020-01-30 09:41:59 +00:00
|
|
|
/* Note: this is not actually done here, it's done later in main after more stuff is setup. */
|
|
|
|
/* However, for testing (and to manifest this code in the produced binary, this is here for now. */
|
|
|
|
/* TODO: Do this better. */
|
|
|
|
init::InitializeSlabHeaps();
|
|
|
|
}
|
|
|
|
|
2020-01-29 22:26:24 +00:00
|
|
|
/* TODO: Implement more of Main() */
|
2020-02-06 13:34:38 +00:00
|
|
|
cpu::SynchronizeAllCores();
|
2020-01-29 06:09:47 +00:00
|
|
|
while (true) { /* ... */ }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|