fatal: restructure, skeleton disp

This commit is contained in:
Michael Scire 2020-11-18 13:24:30 -08:00 committed by SciresM
parent b96b162b0b
commit a843cc0ee7
4 changed files with 89 additions and 20 deletions

View file

@ -0,0 +1,37 @@
/*
* 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 "fatal_device_page_table.hpp"
namespace ams::secmon::fatal {
void InitializeDisplay() {
/* TODO */
AMS_SECMON_LOG("InitializeDisplay not yet implemented\n");
}
void ShowDisplay(const ams::impl::FatalErrorContext *f_ctx, const Result save_result) {
/* TODO */
AMS_UNUSED(f_ctx, save_result);
AMS_SECMON_LOG("ShowDisplay not yet implemented\n");
}
void FinalizeDisplay() {
/* TODO */
AMS_SECMON_LOG("FinalizeDisplay not yet implemented\n");
}
}

View file

@ -0,0 +1,25 @@
/*
* 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/>.
*/
#pragma once
#include <exosphere.hpp>
namespace ams::secmon::fatal {
void InitializeDisplay();
void ShowDisplay(const ams::impl::FatalErrorContext *f_ctx, const Result save_result);
void FinalizeDisplay();
}

View file

@ -16,6 +16,7 @@
#include <exosphere.hpp>
#include "fatal_sdmmc.hpp"
#include "fatal_save_context.hpp"
#include "fatal_display.hpp"
namespace ams::secmon::fatal {
@ -48,35 +49,26 @@ namespace ams::secmon::fatal {
AMS_SECMON_LOG("%s\n", "Fatal start.");
/* Initialize the sdmmc driver. */
Result result = InitializeSdCard();
AMS_SECMON_LOG("InitializeSdCard: %08x\n", result.GetValue());
/* Get the connection status. */
#if defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING)
{
sdmmc::SpeedMode speed_mode;
sdmmc::BusWidth bus_width;
result = CheckSdCardConnection(std::addressof(speed_mode), std::addressof(bus_width));
AMS_SECMON_LOG("CheckSdCardConnection: %08x\n", result.GetValue());
AMS_SECMON_LOG(" Speed Mode: %u\n", static_cast<u32>(speed_mode));
AMS_SECMON_LOG(" Bus Width: %u\n", static_cast<u32>(bus_width));
}
#endif
/* Save the fatal error context. */
const auto *f_ctx = GetFatalErrorContext();
AMS_DUMP(f_ctx, sizeof(*f_ctx));
result = SaveFatalErrorContext(f_ctx);
Result result = SaveFatalErrorContext(f_ctx);
if (R_SUCCEEDED(result)) {
AMS_SECMON_LOG("Saved fatal error context to /atmosphere/fatal_reports/report_%016" PRIx64 ".bin!\n", f_ctx->report_identifier);
} else {
AMS_SECMON_LOG("Failed to save fatal error context: %08x\n", result.GetValue());
}
/* TODO */
/* Display the fatal error. */
{
InitializeDisplay();
ShowDisplay(f_ctx, result);
FinalizeDisplay();
}
/* Ensure we have nothing waiting to be logged. */
AMS_LOG_FLUSH();
/* TODO: Wait for a button press, then reboot. */
AMS_INFINITE_LOOP();
}

View file

@ -15,11 +15,26 @@
*/
#include <exosphere.hpp>
#include "fatal_save_context.hpp"
#include "fatal_sdmmc.hpp"
#include "fs/fatal_fs_api.hpp"
namespace ams::secmon::fatal {
Result SaveFatalErrorContext(const ams::impl::FatalErrorContext *ctx) {
/* Initialize the sdmmc driver. */
R_TRY(InitializeSdCard());
/* Get the connection status. */
#if defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING)
{
sdmmc::SpeedMode speed_mode;
sdmmc::BusWidth bus_width;
R_TRY(CheckSdCardConnection(std::addressof(speed_mode), std::addressof(bus_width)));
AMS_SECMON_LOG(" Speed Mode: %u\n", static_cast<u32>(speed_mode));
AMS_SECMON_LOG(" Bus Width: %u\n", static_cast<u32>(bus_width));
}
#endif
/* Mount the SD card. */
R_UNLESS(fs::MountSdCard(), fs::ResultPartitionNotFound());