Ensure SdCardService and MmcService are updated for 13.1.0

This commit is contained in:
Alex Barney 2022-01-29 19:41:19 -07:00
parent 91e1e65aff
commit 2fb3d88261
3 changed files with 42 additions and 23 deletions

View file

@ -11,13 +11,29 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.FsSrv.Storage; namespace LibHac.FsSrv.Storage;
/// <summary>
/// Contains global MMC-storage-related functions.
/// </summary>
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
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);
}
}
/// <summary>
/// Contains functions for interacting with the MMC storage device.
/// </summary>
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
internal static class MmcService internal static class MmcService
{ {
private static int MakeOperationId(MmcManagerOperationIdValue operation) => (int)operation; private static int MakeOperationId(MmcManagerOperationIdValue operation) => (int)operation;
private static int MakeOperationId(MmcOperationIdValue operation) => (int)operation; private static int MakeOperationId(MmcOperationIdValue operation) => (int)operation;
private static Result GetMmcManager(this StorageService service, private static Result GetMmcManager(this StorageService service, ref SharedRef<IStorageDeviceManager> outManager)
ref SharedRef<IStorageDeviceManager> outManager)
{ {
return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.Mmc); return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.Mmc);
} }
@ -146,7 +162,7 @@ internal static class MmcService
public static Result EraseMmc(this StorageService service, MmcPartition partition) public static Result EraseMmc(this StorageService service, MmcPartition partition)
{ {
using var mmcOperator = new SharedRef<IStorageDeviceOperator>(); using var mmcOperator = new SharedRef<IStorageDeviceOperator>();
Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), MmcPartition.UserData); Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), partition);
if (rc.IsFailure()) return rc; if (rc.IsFailure()) return rc;
return mmcOperator.Get.Operate(MakeOperationId(MmcOperationIdValue.Erase)); return mmcOperator.Get.Operate(MakeOperationId(MmcOperationIdValue.Erase));
@ -157,7 +173,7 @@ internal static class MmcService
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
using var mmcOperator = new SharedRef<IStorageDeviceOperator>(); using var mmcOperator = new SharedRef<IStorageDeviceOperator>();
Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), MmcPartition.UserData); Result rc = service.GetMmcOperator(ref mmcOperator.Ref(), partition);
if (rc.IsFailure()) return rc; if (rc.IsFailure()) return rc;
int operationId = MakeOperationId(MmcOperationIdValue.GetPartitionSize); int operationId = MakeOperationId(MmcOperationIdValue.GetPartitionSize);
@ -242,7 +258,7 @@ internal static class MmcService
return mmcOperator.Get.OperateOut2(out _, successCountBuffer, out _, failureCountBuffer, operationId); 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<IStorageDeviceOperator>(); using var mmcOperator = new SharedRef<IStorageDeviceOperator>();
Result rc = service.GetMmcManagerOperator(ref mmcOperator.Ref()); Result rc = service.GetMmcManagerOperator(ref mmcOperator.Ref());

View file

@ -14,13 +14,16 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.FsSrv.Storage; namespace LibHac.FsSrv.Storage;
/// <summary>
/// Contains functions for interacting with the SD card storage device.
/// </summary>
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
internal static class SdCardService internal static class SdCardService
{ {
private static int MakeOperationId(SdCardManagerOperationIdValue operation) => (int)operation; private static int MakeOperationId(SdCardManagerOperationIdValue operation) => (int)operation;
private static int MakeOperationId(SdCardOperationIdValue operation) => (int)operation; private static int MakeOperationId(SdCardOperationIdValue operation) => (int)operation;
private static Result GetSdCardManager(this StorageService service, private static Result GetSdCardManager(this StorageService service, ref SharedRef<IStorageDeviceManager> outManager)
ref SharedRef<IStorageDeviceManager> outManager)
{ {
return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.SdCard); return service.CreateStorageDeviceManager(ref outManager, StorageDevicePortId.SdCard);
} }

View file

@ -10,23 +10,23 @@ public enum SdCardManagerOperationIdValue
public enum SdCardOperationIdValue public enum SdCardOperationIdValue
{ {
GetSpeedMode = 0x1, GetSpeedMode = 1,
GetCid = 0x2, GetCid = 2,
GetUserAreaNumSectors = 0x3, GetUserAreaNumSectors = 3,
GetUserAreaSize = 0x4, GetUserAreaSize = 4,
GetProtectedAreaNumSectors = 0x5, GetProtectedAreaNumSectors = 5,
GetProtectedAreaSize = 0x6 GetProtectedAreaSize = 6
} }
public enum MmcManagerOperationIdValue public enum MmcManagerOperationIdValue
{ {
GetAndClearErrorInfo = 0x1, GetAndClearErrorInfo = 1,
SuspendControl = 0x2, SuspendControl = 2,
ResumeControl = 0x3, ResumeControl = 3,
GetAndClearPatrolReadAllocateBufferCount = 0x4, GetAndClearPatrolReadAllocateBufferCount = 4,
GetPatrolCount = 0x5, GetPatrolCount = 5,
SuspendPatrol = 0x6, SuspendPatrol = 6,
ResumePatrol = 0x7 ResumePatrol = 7
} }
public enum MmcOperationIdValue public enum MmcOperationIdValue