From 253c0cb0112cd2e8d9310330476701b7e8fc3133 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 30 Oct 2023 21:24:46 -0700 Subject: [PATCH] Fix GameCardErrorReportInfo --- src/LibHac/Fs/GameCard.cs | 29 +++++++++++++++--------- src/LibHac/GcSrv/GameCardManager.cs | 10 ++++---- tests/LibHac.Tests/Fs/TypeLayoutTests.cs | 29 +++++++++++++++--------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/LibHac/Fs/GameCard.cs b/src/LibHac/Fs/GameCard.cs index ba94d7c2..3383904d 100644 --- a/src/LibHac/Fs/GameCard.cs +++ b/src/LibHac/Fs/GameCard.cs @@ -72,28 +72,35 @@ public enum GameCardCompatibilityType : byte public struct GameCardErrorInfo { - public ushort GameCardCrcErrorCount; + public ushort GameCardCrcErrorNum; public ushort Reserved2; - public ushort AsicCrcErrorCount; + public ushort AsicCrcErrorNum; public ushort Reserved6; - public ushort RefreshCount; + public ushort RefreshNum; public ushort ReservedA; - public ushort ReadRetryCount; - public ushort TimeoutRetryErrorCount; + public ushort RetryLimitOutNum; + public ushort TimeoutRetryNum; } public struct GameCardErrorReportInfo { - public GameCardErrorInfo ErrorInfo; + public ushort GameCardCrcErrorNum; + public ushort Reserved2; + public ushort AsicCrcErrorNum; + public ushort Reserved6; + public ushort RefreshNum; + public ushort ReservedA; + public ushort RetryLimitOutNum; + public ushort TimeoutRetryNum; public ushort AsicReinitializeFailureDetail; public ushort InsertionCount; public ushort RemovalCount; - public ushort AsicReinitializeCount; - public uint AsicInitializeCount; - public ushort AsicReinitializeFailureCount; - public ushort AwakenFailureCount; + public ushort AsicReinitializeNum; + public uint AsicInitializeNum; + public ushort AsicReinitializeFailureNum; + public ushort AwakenFailureNum; public ushort Reserved20; - public ushort RefreshCount; + public ushort RefreshSucceededCount; public uint LastReadErrorPageAddress; public uint LastReadErrorPageCount; public uint AwakenCount; diff --git a/src/LibHac/GcSrv/GameCardManager.cs b/src/LibHac/GcSrv/GameCardManager.cs index 94698aa9..789dd4f3 100644 --- a/src/LibHac/GcSrv/GameCardManager.cs +++ b/src/LibHac/GcSrv/GameCardManager.cs @@ -865,11 +865,11 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG Result res = _gc.GetErrorInfo(out GameCardErrorReportInfo errorInfo); if (res.IsFailure()) return res.Miss(); - outErrorInfo.GameCardCrcErrorCount = errorInfo.ErrorInfo.GameCardCrcErrorCount; - outErrorInfo.AsicCrcErrorCount = errorInfo.ErrorInfo.AsicCrcErrorCount; - outErrorInfo.RefreshCount = errorInfo.ErrorInfo.RefreshCount; - outErrorInfo.TimeoutRetryErrorCount = errorInfo.ErrorInfo.TimeoutRetryErrorCount; - outErrorInfo.ReadRetryCount = errorInfo.ErrorInfo.ReadRetryCount; + outErrorInfo.GameCardCrcErrorNum = errorInfo.GameCardCrcErrorNum; + outErrorInfo.AsicCrcErrorNum = errorInfo.AsicCrcErrorNum; + outErrorInfo.RefreshNum = errorInfo.RefreshNum; + outErrorInfo.TimeoutRetryNum = errorInfo.TimeoutRetryNum; + outErrorInfo.RetryLimitOutNum = errorInfo.RetryLimitOutNum; return Result.Success; } diff --git a/tests/LibHac.Tests/Fs/TypeLayoutTests.cs b/tests/LibHac.Tests/Fs/TypeLayoutTests.cs index 2cc07bda..0f3b1f5c 100644 --- a/tests/LibHac.Tests/Fs/TypeLayoutTests.cs +++ b/tests/LibHac.Tests/Fs/TypeLayoutTests.cs @@ -502,14 +502,14 @@ public class TypeLayoutTests Assert.Equal(0x10, Unsafe.SizeOf()); - Assert.Equal(0x0, GetOffset(in s, in s.GameCardCrcErrorCount)); + Assert.Equal(0x0, GetOffset(in s, in s.GameCardCrcErrorNum)); Assert.Equal(0x2, GetOffset(in s, in s.Reserved2)); - Assert.Equal(0x4, GetOffset(in s, in s.AsicCrcErrorCount)); + Assert.Equal(0x4, GetOffset(in s, in s.AsicCrcErrorNum)); Assert.Equal(0x6, GetOffset(in s, in s.Reserved6)); - Assert.Equal(0x8, GetOffset(in s, in s.RefreshCount)); + Assert.Equal(0x8, GetOffset(in s, in s.RefreshNum)); Assert.Equal(0xA, GetOffset(in s, in s.ReservedA)); - Assert.Equal(0xC, GetOffset(in s, in s.ReadRetryCount)); - Assert.Equal(0xE, GetOffset(in s, in s.TimeoutRetryErrorCount)); + Assert.Equal(0xC, GetOffset(in s, in s.RetryLimitOutNum)); + Assert.Equal(0xE, GetOffset(in s, in s.TimeoutRetryNum)); } [Fact] @@ -519,16 +519,23 @@ public class TypeLayoutTests Assert.Equal(0x40, Unsafe.SizeOf()); - Assert.Equal(0x00, GetOffset(in s, in s.ErrorInfo)); + Assert.Equal(0x00, GetOffset(in s, in s.GameCardCrcErrorNum)); + Assert.Equal(0x02, GetOffset(in s, in s.Reserved2)); + Assert.Equal(0x04, GetOffset(in s, in s.AsicCrcErrorNum)); + Assert.Equal(0x06, GetOffset(in s, in s.Reserved6)); + Assert.Equal(0x08, GetOffset(in s, in s.RefreshNum)); + Assert.Equal(0x0A, GetOffset(in s, in s.ReservedA)); + Assert.Equal(0x0C, GetOffset(in s, in s.RetryLimitOutNum)); + Assert.Equal(0x0E, GetOffset(in s, in s.TimeoutRetryNum)); Assert.Equal(0x10, GetOffset(in s, in s.AsicReinitializeFailureDetail)); Assert.Equal(0x12, GetOffset(in s, in s.InsertionCount)); Assert.Equal(0x14, GetOffset(in s, in s.RemovalCount)); - Assert.Equal(0x16, GetOffset(in s, in s.AsicReinitializeCount)); - Assert.Equal(0x18, GetOffset(in s, in s.AsicInitializeCount)); - Assert.Equal(0x1C, GetOffset(in s, in s.AsicReinitializeFailureCount)); - Assert.Equal(0x1E, GetOffset(in s, in s.AwakenFailureCount)); + Assert.Equal(0x16, GetOffset(in s, in s.AsicReinitializeNum)); + Assert.Equal(0x18, GetOffset(in s, in s.AsicInitializeNum)); + Assert.Equal(0x1C, GetOffset(in s, in s.AsicReinitializeFailureNum)); + Assert.Equal(0x1E, GetOffset(in s, in s.AwakenFailureNum)); Assert.Equal(0x20, GetOffset(in s, in s.Reserved20)); - Assert.Equal(0x22, GetOffset(in s, in s.RefreshCount)); + Assert.Equal(0x22, GetOffset(in s, in s.RefreshSucceededCount)); Assert.Equal(0x24, GetOffset(in s, in s.LastReadErrorPageAddress)); Assert.Equal(0x28, GetOffset(in s, in s.LastReadErrorPageCount)); Assert.Equal(0x2C, GetOffset(in s, in s.AwakenCount));