mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 13:52:21 +00:00
fusee_cpp: skeleton the remaining code flow
This commit is contained in:
parent
ecbf13e45d
commit
80999988d4
7 changed files with 151 additions and 4 deletions
|
@ -23,6 +23,7 @@ SECTIONS {
|
|||
BYTE(0x00);
|
||||
}
|
||||
.ovl_mtc_erista {
|
||||
KEEP(*(.text._ZN3ams6nxboot22DoMemoryTrainingEristaEv))
|
||||
fusee_mtc_erista.o(.text*);
|
||||
fusee_mtc_erista.o(.rodata*);
|
||||
fusee_mtc_erista.o(.data*);
|
||||
|
@ -32,6 +33,7 @@ SECTIONS {
|
|||
BYTE(0x00);
|
||||
}
|
||||
.ovl_mtc_mariko {
|
||||
KEEP(*(.text._ZN3ams6nxboot22DoMemoryTrainingMarikoEv))
|
||||
fusee_mtc_mariko.o(.text*);
|
||||
fusee_mtc_mariko.o(.rodata*);
|
||||
fusee_mtc_mariko.o(.data*);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "fusee_sd_card.hpp"
|
||||
#include "fusee_fatal.hpp"
|
||||
#include "fusee_secondary_archive.hpp"
|
||||
#include "fusee_setup_horizon.hpp"
|
||||
#include "fusee_secmon_sync.hpp"
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
|
@ -61,6 +63,10 @@ namespace ams::nxboot {
|
|||
}
|
||||
}
|
||||
|
||||
void CloseSecondaryArchive() {
|
||||
fs::CloseFile(g_archive_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Main() {
|
||||
|
@ -108,11 +114,29 @@ namespace ams::nxboot {
|
|||
InitializeDisplay();
|
||||
ShowDisplay();
|
||||
|
||||
/* TODO */
|
||||
WaitForReboot();
|
||||
/* Close the secondary archive. */
|
||||
CloseSecondaryArchive();
|
||||
|
||||
/* TODO */
|
||||
AMS_INFINITE_LOOP();
|
||||
/* Perform rest of the boot process. */
|
||||
SetupAndStartHorizon();
|
||||
|
||||
/* Finalize display. */
|
||||
FinalizeDisplay();
|
||||
|
||||
/* Finalize the data cache. */
|
||||
hw::FinalizeDataCache();
|
||||
|
||||
/* Downclock the bpmp. */
|
||||
clkrst::SetBpmpClockRate(clkrst::BpmpClockRate_408MHz);
|
||||
|
||||
/* Signal to the secure monitor that we're done. */
|
||||
SetBootloaderState(pkg1::BootloaderState_Done);
|
||||
|
||||
/* Halt ourselves. */
|
||||
while (true) {
|
||||
reg::Write(secmon::MemoryRegionPhysicalDeviceFlowController.GetAddress() + FLOW_CTLR_HALT_COP_EVENTS, FLOW_REG_BITS_ENUM(HALT_COP_EVENTS_MODE, FLOW_MODE_STOP),
|
||||
FLOW_REG_BITS_ENUM(HALT_COP_EVENTS_JTAG, ENABLED));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
44
fusee_cpp/program/source/fusee_secmon_sync.cpp
Normal file
44
fusee_cpp/program/source/fusee_secmon_sync.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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 <exosphere.hpp>
|
||||
#include "fusee_secmon_sync.hpp"
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
namespace {
|
||||
|
||||
ALWAYS_INLINE pkg1::SecureMonitorParameters &GetSecureMonitorParameters() {
|
||||
return *secmon::MemoryRegionPhysicalDeviceBootloaderParams.GetPointer<pkg1::SecureMonitorParameters>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WaitSecureMonitorState(pkg1::SecureMonitorState state) {
|
||||
auto &secmon_params = GetSecureMonitorParameters();
|
||||
|
||||
while (secmon_params.secmon_state != state) {
|
||||
hw::InvalidateDataCache(std::addressof(secmon_params.secmon_state), sizeof(secmon_params.secmon_state));
|
||||
util::WaitMicroSeconds(1);
|
||||
}
|
||||
}
|
||||
|
||||
void SetBootloaderState(pkg1::BootloaderState state) {
|
||||
auto &secmon_params = GetSecureMonitorParameters();
|
||||
secmon_params.bootloader_state = state;
|
||||
hw::FlushDataCache(std::addressof(secmon_params.bootloader_state), sizeof(secmon_params.bootloader_state));
|
||||
}
|
||||
|
||||
}
|
24
fusee_cpp/program/source/fusee_secmon_sync.hpp
Normal file
24
fusee_cpp/program/source/fusee_secmon_sync.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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 <exosphere.hpp>
|
||||
#pragma once
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
void WaitSecureMonitorState(pkg1::SecureMonitorState state);
|
||||
void SetBootloaderState(pkg1::BootloaderState state);
|
||||
|
||||
}
|
27
fusee_cpp/program/source/fusee_setup_horizon.cpp
Normal file
27
fusee_cpp/program/source/fusee_setup_horizon.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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 <exosphere.hpp>
|
||||
#include "fusee_setup_horizon.hpp"
|
||||
#include "fusee_fatal.hpp"
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
void SetupAndStartHorizon() {
|
||||
/* TODO */
|
||||
ShowFatalError("SetupAndStartHorizon not fully implemented\n");
|
||||
}
|
||||
|
||||
}
|
23
fusee_cpp/program/source/fusee_setup_horizon.hpp
Normal file
23
fusee_cpp/program/source/fusee_setup_horizon.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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 <exosphere.hpp>
|
||||
#pragma once
|
||||
|
||||
namespace ams::nxboot {
|
||||
|
||||
void SetupAndStartHorizon();
|
||||
|
||||
}
|
|
@ -1099,6 +1099,9 @@ namespace ams::nxboot {
|
|||
} else /* if (soc_type == fuse::SocType_Mariko) */ {
|
||||
InitializeSdram<fuse::SocType_Mariko>(sdram_params);
|
||||
}
|
||||
|
||||
/* Lock DRAM scratch. */
|
||||
pmc::LockSecureRegister(pmc::SecureRegister_DramParameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue