Merge pull request #2766 from alula/erpt-crash-fix
erpt: Fix rare aborts caused by ResultInvalidPowerState
This commit is contained in:
@@ -111,6 +111,7 @@ namespace ams::erpt {
|
||||
|
||||
struct CreateReportOptionFlag {
|
||||
using SubmitFsInfo = util::BitFlagSet<BITSIZEOF(u32), CreateReportOptionFlag>::Flag<0>;
|
||||
using Unknown0x20000 = util::BitFlagSet<BITSIZEOF(u32), CreateReportOptionFlag>::Flag<17>; /* TODO: What is this, it's checked in Reporter::CreateReport or below */
|
||||
};
|
||||
|
||||
using CreateReportOptionFlagSet = util::BitFlagSet<BITSIZEOF(u32), CreateReportOptionFlag>;
|
||||
|
||||
@@ -52,7 +52,8 @@ namespace ams::fs {
|
||||
|
||||
struct GameCardErrorReportInfo {
|
||||
u16 game_card_crc_error_num;
|
||||
u16 reserved1;
|
||||
u8 last_deactivate_reason;
|
||||
u8 reserved1;
|
||||
u16 asic_crc_error_num;
|
||||
u16 reserved2;
|
||||
u16 refresh_num;
|
||||
@@ -73,7 +74,8 @@ namespace ams::fs {
|
||||
u32 awaken_count;
|
||||
u32 read_count_from_insert;
|
||||
u32 read_count_from_awaken;
|
||||
u8 reserved5[8];
|
||||
u32 last_deactivate_reason_result;
|
||||
u32 reserved5;
|
||||
};
|
||||
static_assert(util::is_pod<GameCardErrorReportInfo>::value);
|
||||
static_assert(sizeof(GameCardErrorReportInfo) == 0x40);
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
namespace ams::erpt::srv {
|
||||
|
||||
Result SubmitFsInfo();
|
||||
void ClearFsInfo();
|
||||
|
||||
}
|
||||
|
||||
@@ -363,6 +363,8 @@ namespace ams::erpt::srv {
|
||||
R_ABORT_UNLESS(record->Add(FieldId_GameCardReadCountFromAwaken, ei.read_count_from_awaken));
|
||||
R_ABORT_UNLESS(record->Add(FieldId_GameCardLastReadErrorPageAddress, ei.last_read_error_page_address));
|
||||
R_ABORT_UNLESS(record->Add(FieldId_GameCardLastReadErrorPageCount, ei.last_read_error_page_count));
|
||||
R_ABORT_UNLESS(record->Add(FieldId_GameCardLastDeactivateReasonResult, ei.last_deactivate_reason_result));
|
||||
R_ABORT_UNLESS(record->Add(FieldId_GameCardLastDeactivateReason, ei.last_deactivate_reason));
|
||||
|
||||
/* Submit the record. */
|
||||
R_ABORT_UNLESS(Context::SubmitContextRecord(std::move(record)));
|
||||
@@ -496,4 +498,27 @@ namespace ams::erpt::srv {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void ClearFsInfo() {
|
||||
Context::ClearContext(CategoryId_NANDTypeInfo);
|
||||
Context::ClearContext(CategoryId_NANDSpeedModeInfo);
|
||||
Context::ClearContext(CategoryId_NANDExtendedCsd);
|
||||
Context::ClearContext(CategoryId_NANDPatrolInfo);
|
||||
Context::ClearContext(CategoryId_NANDErrorInfo);
|
||||
Context::ClearContext(CategoryId_NANDDriverLog);
|
||||
Context::ClearContext(CategoryId_MicroSDTypeInfo);
|
||||
Context::ClearContext(CategoryId_MicroSDSpeedModeInfo);
|
||||
Context::ClearContext(CategoryId_SdCardSizeSpec);
|
||||
Context::ClearContext(CategoryId_SdCardActivationInfo);
|
||||
Context::ClearContext(CategoryId_SdCardErrorInfo);
|
||||
Context::ClearContext(CategoryId_SdCardDriverLog);
|
||||
Context::ClearContext(CategoryId_GameCardCIDInfo);
|
||||
Context::ClearContext(CategoryId_GameCardErrorInfo);
|
||||
Context::ClearContext(CategoryId_GameCardDetailedErrorInfo);
|
||||
Context::ClearContext(CategoryId_GameCardLogInfo);
|
||||
Context::ClearContext(CategoryId_FsProxyErrorInfo);
|
||||
Context::ClearContext(CategoryId_FsProxyErrorInfo2);
|
||||
Context::ClearContext(CategoryId_FsProxyErrorInfo3);
|
||||
Context::ClearContext(CategoryId_FsMemoryInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -423,7 +423,11 @@ namespace ams::erpt::srv {
|
||||
|
||||
auto report = std::make_unique<Report>(record.get(), redirect_new_reports);
|
||||
R_UNLESS(report != nullptr, erpt::ResultOutOfMemory());
|
||||
auto report_guard = SCOPE_GUARD { const auto delete_res = report->Delete(); R_ASSERT(delete_res); AMS_UNUSED(delete_res); };
|
||||
auto report_guard = SCOPE_GUARD {
|
||||
const auto delete_res = report->Delete();
|
||||
R_ASSERT(delete_res);
|
||||
AMS_UNUSED(delete_res);
|
||||
};
|
||||
|
||||
R_TRY(Context::WriteContextsToReport(report.get()));
|
||||
R_TRY(report->GetSize(std::addressof(record->m_info.report_size)));
|
||||
@@ -434,7 +438,7 @@ namespace ams::erpt::srv {
|
||||
} else {
|
||||
/* If we are redirecting new reports, we don't want to store the report in the journal. */
|
||||
/* We should take this opportunity to delete any attachments associated with the report. */
|
||||
R_ABORT_UNLESS(JournalForAttachments::DeleteAttachments(report_id));
|
||||
R_TRY(JournalForAttachments::DeleteAttachments(report_id));
|
||||
}
|
||||
|
||||
R_TRY(Journal::Commit());
|
||||
@@ -489,6 +493,20 @@ namespace ams::erpt::srv {
|
||||
static_cast<void>(Context::ClearContext(CategoryId_ErrorInfo));
|
||||
static_cast<void>(Context::ClearContext(CategoryId_ErrorInfoAuto));
|
||||
static_cast<void>(Context::ClearContext(CategoryId_ErrorInfoDefaults));
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* TODO: What else is missing? */
|
||||
if (hos::GetVersion() >= hos::Version_17_0_0 && flags.Test<CreateReportOptionFlag::SubmitFsInfo>()) {
|
||||
ClearFsInfo();
|
||||
}
|
||||
|
||||
/* if (erpt::ResultInvalidPowerState::Includes(...)) {
|
||||
* Nintendo ignores this and sends "power_state_violation" play report if this error happens.
|
||||
* } else {
|
||||
* Nintendo sends "write_failure" play report if any other error happens.
|
||||
* }
|
||||
*/
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Get the context entry pointer. */
|
||||
|
||||
Reference in New Issue
Block a user