mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add/skeleton SignedSystemPartition/SdmmcControl
This commit is contained in:
parent
c389f471d4
commit
795bcf0960
6 changed files with 127 additions and 9 deletions
|
@ -189,13 +189,6 @@ public enum CommitOptionFlag
|
|||
SetRestoreFlag = 2
|
||||
}
|
||||
|
||||
public enum SdmmcPort
|
||||
{
|
||||
Mmc = 0,
|
||||
SdCard = 1,
|
||||
GcAsic = 2
|
||||
}
|
||||
|
||||
public enum CacheStorageTargetMedia
|
||||
{
|
||||
None = 0,
|
||||
|
@ -261,4 +254,37 @@ public enum SdCardSpeedMode
|
|||
Sdr104 = 6,
|
||||
Ddr50 = 7,
|
||||
Unknown = 8
|
||||
}
|
||||
|
||||
public enum SdmmcBusWidth
|
||||
{
|
||||
Width1Bit = 0,
|
||||
Width4Bit = 1,
|
||||
Width8Bit = 2,
|
||||
}
|
||||
|
||||
public enum SdmmcSpeedMode
|
||||
{
|
||||
MmcIdentification = 0,
|
||||
MmcLegacySpeed = 1,
|
||||
MmcHighSpeed = 2,
|
||||
MmcHs200 = 3,
|
||||
MmcHs400 = 4,
|
||||
SdCardIdentification = 5,
|
||||
SdCardDefaultSpeed = 6,
|
||||
SdCardHighSpeed = 7,
|
||||
SdCardSdr12 = 8,
|
||||
SdCardSdr25 = 9,
|
||||
SdCardSdr50 = 10,
|
||||
SdCardSdr104 = 11,
|
||||
SdCardDdr50 = 12,
|
||||
GcAsicFpgaSpeed = 13,
|
||||
GcAsicSpeed = 14
|
||||
}
|
||||
|
||||
public enum SdmmcPort
|
||||
{
|
||||
Mmc = 0,
|
||||
SdCard = 1,
|
||||
GcAsic = 2
|
||||
}
|
|
@ -371,6 +371,6 @@ public enum QueryId
|
|||
/// </summary>
|
||||
SetConcatenationFileAttribute = 0,
|
||||
UpdateMac = 1,
|
||||
IsSignedSystemPartitionOnSdCardValid = 2,
|
||||
IsSignedSystemPartition = 2,
|
||||
QueryUnpreparedFileInformation = 3
|
||||
}
|
26
src/LibHac/Fs/Shim/SdmmcControl.cs
Normal file
26
src/LibHac/Fs/Shim/SdmmcControl.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace LibHac.Fs.Shim;
|
||||
|
||||
/// <summary>
|
||||
/// Contains functions for suspending, resuming, and checking sdmmc status.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 13.4.0</remarks>
|
||||
public static class SdmmcControl
|
||||
{
|
||||
public static Result GetSdmmcConnectionStatus(this FileSystemClient fs, out SdmmcSpeedMode speedMode,
|
||||
out SdmmcBusWidth busWidth, SdmmcPort port)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Result SuspendSdmmcControl()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Result ResumeSdmmcControl()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
52
src/LibHac/Fs/Shim/SignedSystemPartition.cs
Normal file
52
src/LibHac/Fs/Shim/SignedSystemPartition.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Impl;
|
||||
|
||||
namespace LibHac.Fs.Shim;
|
||||
|
||||
/// <summary>
|
||||
/// Contains functions for checking if a mounted file system was created from a signed system partition.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 13.4.0</remarks>
|
||||
public static class SignedSystemPartition
|
||||
{
|
||||
public static bool IsValidSignedSystemPartitionOnSdCard(this FileSystemClient fs, U8Span path)
|
||||
{
|
||||
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span _, path);
|
||||
fs.Impl.LogResultErrorMessage(rc);
|
||||
Abort.DoAbortUnlessSuccess(rc);
|
||||
|
||||
bool isValid = false;
|
||||
|
||||
rc = Operate(ref isValid, fileSystem);
|
||||
fs.Impl.LogResultErrorMessage(rc);
|
||||
Abort.DoAbortUnlessSuccess(rc);
|
||||
|
||||
return isValid;
|
||||
|
||||
static Result Operate(ref bool isValid, FileSystemAccessor fileSystem)
|
||||
{
|
||||
Result rc = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref isValid), ReadOnlySpan<byte>.Empty,
|
||||
QueryId.IsSignedSystemPartition, new U8Span(new[] { (byte)'/' }));
|
||||
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
// Any IFileSystems other than a signed system partition IFileSystem should
|
||||
// return an "UnsupportedOperation" result
|
||||
if (ResultFs.UnsupportedOperation.Includes(rc))
|
||||
{
|
||||
rc.Catch();
|
||||
isValid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return rc.Miss();
|
||||
}
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -566,7 +566,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
|
|||
static Result PermissionCheck(QueryId queryId, FileSystemInterfaceAdapter fsAdapter)
|
||||
{
|
||||
if (queryId == QueryId.SetConcatenationFileAttribute ||
|
||||
queryId == QueryId.IsSignedSystemPartitionOnSdCardValid ||
|
||||
queryId == QueryId.IsSignedSystemPartition ||
|
||||
queryId == QueryId.QueryUnpreparedFileInformation)
|
||||
{
|
||||
return Result.Success;
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
namespace LibHac.Sdmmc;
|
||||
|
||||
public enum BusWidth
|
||||
{
|
||||
Width1Bit = 0,
|
||||
Width4Bit = 1,
|
||||
Width8Bit = 2,
|
||||
}
|
||||
|
||||
public enum SpeedMode
|
||||
{
|
||||
MmcIdentification = 0,
|
||||
|
@ -18,3 +25,10 @@ public enum SpeedMode
|
|||
GcAsicFpgaSpeed = 13,
|
||||
GcAsicSpeed = 14
|
||||
}
|
||||
|
||||
public enum Port
|
||||
{
|
||||
Mmc0 = 0,
|
||||
SdCard0 = 1,
|
||||
GcAsic0 = 2
|
||||
}
|
Loading…
Reference in a new issue