diff --git a/src/LibHac/FsSrv/Storage/MmcService.cs b/src/LibHac/FsSrv/Storage/MmcService.cs index b1d03c5b..dcb6b291 100644 --- a/src/LibHac/FsSrv/Storage/MmcService.cs +++ b/src/LibHac/FsSrv/Storage/MmcService.cs @@ -11,13 +11,29 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage; namespace LibHac.FsSrv.Storage; +/// +/// Contains global MMC-storage-related functions. +/// +/// Based on FS 13.1.0 (nnSdk 13.4.0) +public static class MmcServiceGlobalMethods +{ + public static Result GetAndClearPatrolReadAllocateBufferCount(this FileSystemServer fsSrv, out long successCount, + out long failureCount) + { + return fsSrv.Storage.GetAndClearPatrolReadAllocateBufferCount(out successCount, out failureCount); + } +} + +/// +/// Contains functions for interacting with the MMC storage device. +/// +/// Based on FS 13.1.0 (nnSdk 13.4.0) internal static class MmcService { private static int MakeOperationId(MmcManagerOperationIdValue operation) => (int)operation; private static int MakeOperationId(MmcOperationIdValue operation) => (int)operation; - private static Result GetMmcManager(this StorageService service, - ref SharedRef outManager) + private static Result GetMmcManager(this StorageService service, ref SharedRef outManager) { return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.Mmc); } @@ -146,7 +162,7 @@ internal static class MmcService public static Result EraseMmc(this StorageService service, MmcPartition partition) { using var mmcOperator = new SharedRef(); - Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), MmcPartition.UserData); + Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), partition); if (rc.IsFailure()) return rc; return mmcOperator.Get.Operate(MakeOperationId(MmcOperationIdValue.Erase)); @@ -157,7 +173,7 @@ internal static class MmcService UnsafeHelpers.SkipParamInit(out size); using var mmcOperator = new SharedRef(); - Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), MmcPartition.UserData); + Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), partition); if (rc.IsFailure()) return rc; int operationId = MakeOperationId(MmcOperationIdValue.GetPartitionSize); @@ -242,7 +258,7 @@ internal static class MmcService return mmcOperator.Get.OperateOut2(out _, successCountBuffer, out _, failureCountBuffer, operationId); } - public static Result SuspendSdmmcControl(this StorageService service) + public static Result SuspendMmcControl(this StorageService service) { using var mmcOperator = new SharedRef(); Result rc = service.GetMmcManagerOperator(ref mmcOperator.Ref()); @@ -259,4 +275,4 @@ internal static class MmcService return mmcOperator.Get.Operate(MakeOperationId(MmcManagerOperationIdValue.ResumeControl)); } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSrv/Storage/SdCardService.cs b/src/LibHac/FsSrv/Storage/SdCardService.cs index d4e2b442..b0a63431 100644 --- a/src/LibHac/FsSrv/Storage/SdCardService.cs +++ b/src/LibHac/FsSrv/Storage/SdCardService.cs @@ -14,13 +14,16 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage; namespace LibHac.FsSrv.Storage; +/// +/// Contains functions for interacting with the SD card storage device. +/// +/// Based on FS 13.1.0 (nnSdk 13.4.0) internal static class SdCardService { private static int MakeOperationId(SdCardManagerOperationIdValue operation) => (int)operation; private static int MakeOperationId(SdCardOperationIdValue operation) => (int)operation; - private static Result GetSdCardManager(this StorageService service, - ref SharedRef outManager) + private static Result GetSdCardManager(this StorageService service, ref SharedRef outManager) { return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.SdCard); } @@ -280,4 +283,4 @@ internal static class SdCardService return sdCardOperator.Get.Operate(MakeOperationId(SdCardManagerOperationIdValue.ResumeControl)); } -} +} \ No newline at end of file diff --git a/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs b/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs index 16d27086..0732ec66 100644 --- a/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs +++ b/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs @@ -10,23 +10,23 @@ public enum SdCardManagerOperationIdValue public enum SdCardOperationIdValue { - GetSpeedMode = 0x1, - GetCid = 0x2, - GetUserAreaNumSectors = 0x3, - GetUserAreaSize = 0x4, - GetProtectedAreaNumSectors = 0x5, - GetProtectedAreaSize = 0x6 + GetSpeedMode = 1, + GetCid = 2, + GetUserAreaNumSectors = 3, + GetUserAreaSize = 4, + GetProtectedAreaNumSectors = 5, + GetProtectedAreaSize = 6 } public enum MmcManagerOperationIdValue { - GetAndClearErrorInfo = 0x1, - SuspendControl = 0x2, - ResumeControl = 0x3, - GetAndClearPatrolReadAllocateBufferCount = 0x4, - GetPatrolCount = 0x5, - SuspendPatrol = 0x6, - ResumePatrol = 0x7 + GetAndClearErrorInfo = 1, + SuspendControl = 2, + ResumeControl = 3, + GetAndClearPatrolReadAllocateBufferCount = 4, + GetPatrolCount = 5, + SuspendPatrol = 6, + ResumePatrol = 7 } public enum MmcOperationIdValue @@ -36,4 +36,4 @@ public enum MmcOperationIdValue GetPartitionSize = 3, GetExtendedCsd = 4, Erase = 5 -} +} \ No newline at end of file