diff --git a/libraries/libstratosphere/include/stratosphere/erpt/erpt_types.hpp b/libraries/libstratosphere/include/stratosphere/erpt/erpt_types.hpp index 9ae14fc..899de49 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/erpt_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/erpt_types.hpp @@ -246,24 +246,24 @@ constexpr inline u32 ErrorCodeSizeMax = 15; constexpr inline u32 ProgramIdSizeMax = 17; - struct RecentReportEntry { + struct NotifiableErrorCodeReportEntry { char error_code[ErrorCodeSizeMax]; char program_id[ProgramIdSizeMax]; u8 is_visible; u8 is_system_abort; u8 is_application_abort; }; - static_assert(sizeof(RecentReportEntry) == 35); + static_assert(sizeof(NotifiableErrorCodeReportEntry) == 35); - struct RecentReportSummary : public sf::LargeData, public sf::PrefersAutoSelectTransferMode { + struct NotifiableErrorCodesData : public sf::LargeData, public sf::PrefersAutoSelectTransferMode { u32 entry_count; - RecentReportEntry entries[50]; + NotifiableErrorCodeReportEntry entries[50]; char firmware_display_version[0x18]; char private_os_version[96]; char product_model[16]; char region_code[34]; }; - static_assert(sizeof(RecentReportSummary) == 0x784); + static_assert(sizeof(NotifiableErrorCodesData) == 0x784); struct SystemInfo { char os_version[0x18]; diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp index b91ade8..5ce1751 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp @@ -25,7 +25,7 @@ AMS_SF_METHOD_INFO(C, H, 4, Result, GetStorageUsageStatistics, (ams::sf::Out out), (out), hos::Version_5_0_0) \ AMS_SF_METHOD_INFO(C, H, 5, Result, GetAttachmentListDeprecated, (const ams::sf::OutBuffer &out_buf, const erpt::ReportId &report_id), (out_buf, report_id), hos::Version_8_0_0, hos::Version_19_0_1) \ AMS_SF_METHOD_INFO(C, H, 6, Result, GetAttachmentList, (ams::sf::Out out_count, const ams::sf::OutBuffer &out_buf, const erpt::ReportId &report_id), (out_count, out_buf, report_id), hos::Version_20_0_0) \ - AMS_SF_METHOD_INFO(C, H, 7, Result, GetRecentReportSummary, (ams::sf::Out out), (out), hos::Version_22_0_0) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, PopNotifiableErrorCodes, (ams::sf::Out out), (out), hos::Version_22_0_0) \ AMS_SF_METHOD_INFO(C, H, 10, Result, GetReportSizeMax, (ams::sf::Out out), (out), hos::Version_20_0_0) diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp index f610382..54754ce 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp @@ -21,7 +21,7 @@ #include "erpt_srv_journal.hpp" #include "erpt_srv_service.hpp" #include "erpt_srv_forced_shutdown.hpp" -#include "erpt_srv_recent_report.hpp" +#include "erpt_srv_notifiable_errors.hpp" namespace ams::erpt::srv { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp index 62f072e..b4843d3 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp @@ -16,7 +16,7 @@ #include #include "erpt_srv_manager_impl.hpp" #include "erpt_srv_journal.hpp" -#include "erpt_srv_recent_report.hpp" +#include "erpt_srv_notifiable_errors.hpp" namespace ams::erpt::srv { @@ -60,7 +60,7 @@ Result ManagerImpl::CleanupReports() { Journal::CleanupReports(); Journal::CleanupAttachments(); - RecentReport::Clear(); + NotifiableErrorCodeReport::Clear(); R_RETURN(Journal::Commit()); } @@ -101,13 +101,13 @@ Result ManagerImpl::GetReportSizeMax(ams::sf::Out out) { /* TODO: Where is this size defined? */ - constexpr size_t ReportSizeMax = 0x35D3D; + constexpr size_t ReportSizeMax = 0x3FF4F; *out = ReportSizeMax; R_SUCCEED(); } - Result ManagerImpl::GetRecentReportSummary(ams::sf::Out out) { - RecentReport::GetSummary(out.GetPointer()); + Result ManagerImpl::PopNotifiableErrorCodes(ams::sf::Out out) { + NotifiableErrorCodeReport::PopNotifiableErrorCodes(out.GetPointer()); R_SUCCEED(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp index 81b76ef..e9d4a10 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp @@ -36,7 +36,7 @@ Result GetStorageUsageStatistics(ams::sf::Out out); Result GetAttachmentListDeprecated(const ams::sf::OutBuffer &out_buf, const ReportId &report_id); Result GetAttachmentList(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buf, const ReportId &report_id); - Result GetRecentReportSummary(ams::sf::Out out); + Result PopNotifiableErrorCodes(ams::sf::Out out); Result GetReportSizeMax(ams::sf::Out out); }; static_assert(erpt::sf::IsIManager); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.cpp new file mode 100644 index 0000000..a0ac14c --- /dev/null +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.cpp @@ -0,0 +1,93 @@ +/* + * 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 . + */ +#include +#include "erpt_srv_notifiable_errors.hpp" + +namespace ams::erpt::srv { + + namespace { + + constexpr size_t MaxEntriesPerType = 25; + + struct NotifiableErrorCodeReportState { + u32 report_counts[ReportType_Count]; + NotifiableErrorCodeReportEntry report_entries[ReportType_Count][MaxEntriesPerType]; + os::Tick last_tick; + u32 consecutive_count; + }; + + constinit NotifiableErrorCodeReportState g_state = { + .report_counts = {}, + .report_entries = {}, + .last_tick = os::Tick{}, + .consecutive_count = 0, + }; + + } + + void NotifiableErrorCodeReport::PushEntry(const char *error_code, const char *program_id, ReportType type, bool is_system_abort, bool is_application_abort) { + u32 &count = g_state.report_counts[type]; + NotifiableErrorCodeReportEntry *entries = g_state.report_entries[type]; + + /* If we're full, shift the oldest entry out. */ + if (count >= MaxEntriesPerType) { + std::memmove(entries, entries + 1, sizeof(NotifiableErrorCodeReportEntry) * (MaxEntriesPerType - 1)); + count = MaxEntriesPerType - 1; + } + + /* Fill the new entry. */ + NotifiableErrorCodeReportEntry &entry = entries[count]; + util::Strlcpy(entry.error_code, error_code, sizeof(entry.error_code)); + util::Strlcpy(entry.program_id, program_id, sizeof(entry.program_id)); + entry.is_visible = (type == ReportType_Visible); + entry.is_system_abort = is_system_abort; + entry.is_application_abort = is_application_abort; + + count++; + } + + void NotifiableErrorCodeReport::PopNotifiableErrorCodes(NotifiableErrorCodesData *out) { + /* Fill basic info from lazily-initialized system info. */ + const auto &sys_info = srv::GetSystemInfo(); + util::Strlcpy(out->firmware_display_version, sys_info.os_version, sizeof(out->firmware_display_version)); + util::Strlcpy(out->private_os_version, sys_info.private_os_version, sizeof(out->private_os_version)); + util::Strlcpy(out->product_model, sys_info.product_model, sizeof(out->product_model)); + util::Strlcpy(out->region_code, sys_info.region, sizeof(out->region_code)); + + u32 total_count = 0; + + /* Copy entries. */ + for (u32 i = 0; i < ReportType_Count; i++) { + if (g_state.report_counts[i] == 0) { + continue; + } + std::memcpy(out->entries + total_count, g_state.report_entries[i], sizeof(NotifiableErrorCodeReportEntry) * g_state.report_counts[i]); + total_count += g_state.report_counts[i]; + + /* Reset count (destructive read). */ + g_state.report_counts[i] = 0; + } + + out->entry_count = total_count; + } + + void NotifiableErrorCodeReport::Clear() { + for (u32 i = 0; i < ReportType_Count; i++) { + g_state.report_counts[i] = 0; + } + } + +} \ No newline at end of file diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.hpp new file mode 100644 index 0000000..50847aa --- /dev/null +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_notifiable_errors.hpp @@ -0,0 +1,28 @@ +/* + * 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 . + */ +#pragma once +#include + +namespace ams::erpt::srv { + + class NotifiableErrorCodeReport { + public: + static void PushEntry(const char *error_code, const char *program_id, ReportType type, bool is_system_abort, bool is_application_abort); + static void PopNotifiableErrorCodes(NotifiableErrorCodesData *out); + static void Clear(); + }; + +} \ No newline at end of file diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.cpp deleted file mode 100644 index ac38151..0000000 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.cpp +++ /dev/null @@ -1,93 +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 . - */ -#include -#include "erpt_srv_recent_report.hpp" - -namespace ams::erpt::srv { - - namespace { - - constexpr size_t MaxEntriesPerType = 25; - - struct RecentReportState { - u32 report_counts[ReportType_Count]; - RecentReportEntry report_entries[ReportType_Count][MaxEntriesPerType]; - os::Tick last_tick; - u32 consecutive_count; - }; - - constinit RecentReportState g_state = { - .report_counts = {}, - .report_entries = {}, - .last_tick = os::Tick{}, - .consecutive_count = 0, - }; - - } - - void RecentReport::PushEntry(const char *error_code, const char *program_id, ReportType type, bool is_system_abort, bool is_application_abort) { - u32 &count = g_state.report_counts[type]; - RecentReportEntry *entries = g_state.report_entries[type]; - - /* If we're full, shift the oldest entry out. */ - if (count >= MaxEntriesPerType) { - std::memmove(entries, entries + 1, sizeof(RecentReportEntry) * (MaxEntriesPerType - 1)); - count = MaxEntriesPerType - 1; - } - - /* Fill the new entry. */ - RecentReportEntry &entry = entries[count]; - util::Strlcpy(entry.error_code, error_code, sizeof(entry.error_code)); - util::Strlcpy(entry.program_id, program_id, sizeof(entry.program_id)); - entry.is_visible = (type == ReportType_Visible); - entry.is_system_abort = is_system_abort; - entry.is_application_abort = is_application_abort; - - count++; - } - - void RecentReport::GetSummary(RecentReportSummary *out) { - /* Fill basic info from lazily-initialized system info. */ - const auto &sys_info = srv::GetSystemInfo(); - util::Strlcpy(out->firmware_display_version, sys_info.os_version, sizeof(out->firmware_display_version)); - util::Strlcpy(out->private_os_version, sys_info.private_os_version, sizeof(out->private_os_version)); - util::Strlcpy(out->product_model, sys_info.product_model, sizeof(out->product_model)); - util::Strlcpy(out->region_code, sys_info.region, sizeof(out->region_code)); - - u32 total_count = 0; - - /* Copy entries. */ - for (u32 i = 0; i < ReportType_Count; i++) { - if (g_state.report_counts[i] == 0) { - continue; - } - std::memcpy(out->entries + total_count, g_state.report_entries[i], sizeof(RecentReportEntry) * g_state.report_counts[i]); - total_count += g_state.report_counts[i]; - - /* Reset count (destructive read). */ - g_state.report_counts[i] = 0; - } - - out->entry_count = total_count; - } - - void RecentReport::Clear() { - for (u32 i = 0; i < ReportType_Count; i++) { - g_state.report_counts[i] = 0; - } - } - -} \ No newline at end of file diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.hpp deleted file mode 100644 index 065f822..0000000 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_recent_report.hpp +++ /dev/null @@ -1,28 +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 . - */ -#pragma once -#include - -namespace ams::erpt::srv { - - class RecentReport { - public: - static void PushEntry(const char *error_code, const char *program_id, ReportType type, bool is_system_abort, bool is_application_abort); - static void GetSummary(RecentReportSummary *out); - static void Clear(); - }; - -} \ No newline at end of file diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 0ef5e2f..a1314cc 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -20,7 +20,7 @@ #include "erpt_srv_context_record.hpp" #include "erpt_srv_context.hpp" #include "erpt_srv_fs_info.hpp" -#include "erpt_srv_recent_report.hpp" +#include "erpt_srv_notifiable_errors.hpp" namespace ams::erpt::srv { @@ -536,7 +536,7 @@ } } - RecentReport::PushEntry(error_code, program_id, type, is_system_abort, is_application_abort); + NotifiableErrorCodeReport::PushEntry(error_code, program_id, type, is_system_abort, is_application_abort); } /* Generate report id. */