mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Replace the old EmulatedSdCard class
This commit is contained in:
parent
0964ecb2ee
commit
a45c541aca
7 changed files with 34 additions and 281 deletions
|
@ -13,7 +13,7 @@ public class DefaultFsServerObjects
|
||||||
{
|
{
|
||||||
public FileSystemCreatorInterfaces FsCreators { get; set; }
|
public FileSystemCreatorInterfaces FsCreators { get; set; }
|
||||||
public EmulatedGameCard GameCard { get; set; }
|
public EmulatedGameCard GameCard { get; set; }
|
||||||
public EmulatedSdCard SdCard { get; set; }
|
public SdmmcApi Sdmmc { get; set; }
|
||||||
public GameCardDummy GameCardNew { get; set; }
|
public GameCardDummy GameCardNew { get; set; }
|
||||||
public EmulatedStorageDeviceManagerFactory StorageDeviceManagerFactory { get; set; }
|
public EmulatedStorageDeviceManagerFactory StorageDeviceManagerFactory { get; set; }
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ public class DefaultFsServerObjects
|
||||||
{
|
{
|
||||||
var creators = new FileSystemCreatorInterfaces();
|
var creators = new FileSystemCreatorInterfaces();
|
||||||
var gameCard = new EmulatedGameCard(keySet);
|
var gameCard = new EmulatedGameCard(keySet);
|
||||||
var sdCard = new EmulatedSdCard();
|
|
||||||
|
|
||||||
var gameCardNew = new GameCardDummy();
|
var gameCardNew = new GameCardDummy();
|
||||||
var sdmmcNew = new SdmmcApi(fsServer);
|
var sdmmcNew = new SdmmcApi(fsServer);
|
||||||
|
@ -43,7 +42,7 @@ public class DefaultFsServerObjects
|
||||||
creators.GameCardFileSystemCreator = new EmulatedGameCardFsCreator(gcStorageCreator, gameCard);
|
creators.GameCardFileSystemCreator = new EmulatedGameCardFsCreator(gcStorageCreator, gameCard);
|
||||||
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keySet);
|
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keySet);
|
||||||
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(ref sharedRootFileSystem.Ref);
|
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(ref sharedRootFileSystem.Ref);
|
||||||
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdCard, ref sharedRootFileSystemCopy.Ref);
|
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdmmcNew, ref sharedRootFileSystemCopy.Ref);
|
||||||
|
|
||||||
var storageDeviceManagerFactory = new EmulatedStorageDeviceManagerFactory(fsServer, sdmmcNew, gameCardNew, hasGameCard: true);
|
var storageDeviceManagerFactory = new EmulatedStorageDeviceManagerFactory(fsServer, sdmmcNew, gameCardNew, hasGameCard: true);
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class DefaultFsServerObjects
|
||||||
{
|
{
|
||||||
FsCreators = creators,
|
FsCreators = creators,
|
||||||
GameCard = gameCard,
|
GameCard = gameCard,
|
||||||
SdCard = sdCard,
|
Sdmmc = sdmmcNew,
|
||||||
GameCardNew = gameCardNew,
|
GameCardNew = gameCardNew,
|
||||||
StorageDeviceManagerFactory = storageDeviceManagerFactory
|
StorageDeviceManagerFactory = storageDeviceManagerFactory
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,250 +0,0 @@
|
||||||
using System;
|
|
||||||
using LibHac.Common;
|
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.FsSrv.Sf;
|
|
||||||
using LibHac.Sf;
|
|
||||||
|
|
||||||
namespace LibHac.FsSrv;
|
|
||||||
|
|
||||||
public class EmulatedDeviceOperator : IDeviceOperator
|
|
||||||
{
|
|
||||||
private EmulatedGameCard GameCard { get; set; }
|
|
||||||
private EmulatedSdCard SdCard { get; set; }
|
|
||||||
|
|
||||||
public EmulatedDeviceOperator(EmulatedGameCard gameCard, EmulatedSdCard sdCard)
|
|
||||||
{
|
|
||||||
GameCard = gameCard;
|
|
||||||
SdCard = sdCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
|
|
||||||
public Result IsSdCardInserted(out bool outIsInserted)
|
|
||||||
{
|
|
||||||
outIsInserted = SdCard.IsSdCardInserted();
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSdCardSpeedMode(out long outSpeedMode)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSdCardCid(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSdCardUserAreaSize(out long outSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSdCardProtectedAreaSize(out long outSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetAndClearSdCardErrorInfo(out StorageErrorInfo outStorageErrorInfo, out long outLogSize,
|
|
||||||
OutBuffer logBuffer, long logBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetMmcCid(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetMmcSpeedMode(out long outSpeedMode)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result EraseMmc(uint partitionId)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetMmcPartitionSize(out long outSize, uint partitionId)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetMmcPatrolCount(out uint outCount)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetAndClearMmcErrorInfo(out StorageErrorInfo outStorageErrorInfo, out long outLogSize,
|
|
||||||
OutBuffer logBuffer, long logBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetMmcExtendedCsd(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result SuspendMmcPatrol()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ResumeMmcPatrol()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result IsGameCardInserted(out bool outIsInserted)
|
|
||||||
{
|
|
||||||
outIsInserted = GameCard.IsGameCardInserted();
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result EraseGameCard(uint gameCardSize, ulong romAreaStartPageAddress)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardUpdatePartitionInfo(out uint outCupVersion, out ulong outCupId, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result FinalizeGameCardDriver()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardAttribute(out byte outAttribute, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardDeviceCertificate(OutBuffer outBuffer, long outBufferSize, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardAsicInfo(OutBuffer outRmaInfoBuffer, long rmaInfoBufferSize, InBuffer asicFirmwareBuffer,
|
|
||||||
long asicFirmwareBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardIdSet(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result WriteToGameCardDirectly(long offset, OutBuffer buffer, long bufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result SetVerifyWriteEnableFlag(bool isEnabled)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardImageHash(OutBuffer outBuffer, long outBufferSize, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardDeviceIdForProdCard(OutBuffer outBuffer, long outBufferSize, InBuffer devHeaderBuffer,
|
|
||||||
long devHeaderBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result EraseAndWriteParamDirectly(InBuffer inBuffer, long inBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ReadParamDirectly(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ForceEraseGameCard()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardErrorInfo(out GameCardErrorInfo outErrorInfo)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardErrorReportInfo(out GameCardErrorReportInfo outErrorInfo)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardDeviceId(OutBuffer outBuffer, long outBufferSize)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ChallengeCardExistence(OutBuffer outResponseBuffer, InBuffer challengeSeedBuffer,
|
|
||||||
InBuffer challengeValueBuffer, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardCompatibilityType(out byte outCompatibilityType, uint handle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result SetSpeedEmulationMode(int mode)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSpeedEmulationMode(out int outMode)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result SuspendSdmmcControl()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ResumeSdmmcControl()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetSdmmcConnectionStatus(out int outSpeedMode, out int outBusWidth, int port)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result SetDeviceSimulationEvent(uint port, uint simulatedOperationType, uint simulatedFailureType,
|
|
||||||
uint failureResult, bool autoClearEvent)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result ClearDeviceSimulationEvent(uint port)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result GetGameCardHandle(out GameCardHandle handle)
|
|
||||||
{
|
|
||||||
UnsafeHelpers.SkipParamInit(out handle);
|
|
||||||
|
|
||||||
if (!GameCard.IsGameCardInserted())
|
|
||||||
return ResultFs.GameCardFsGetHandleFailure.Log();
|
|
||||||
|
|
||||||
handle = GameCard.GetGameCardHandle();
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
namespace LibHac.FsSrv;
|
|
||||||
|
|
||||||
public class EmulatedSdCard
|
|
||||||
{
|
|
||||||
private bool IsInserted { get; set; }
|
|
||||||
|
|
||||||
public bool IsSdCardInserted()
|
|
||||||
{
|
|
||||||
return IsInserted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSdCardInsertionStatus(bool isInserted)
|
|
||||||
{
|
|
||||||
IsInserted = isInserted;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
|
using LibHac.Sdmmc;
|
||||||
using LibHac.Util;
|
using LibHac.Util;
|
||||||
using Utility = LibHac.FsSrv.Impl.Utility;
|
using Utility = LibHac.FsSrv.Impl.Utility;
|
||||||
|
|
||||||
|
@ -11,20 +12,20 @@ public class EmulatedSdCardFileSystemCreator : ISdCardProxyFileSystemCreator, ID
|
||||||
{
|
{
|
||||||
private const string DefaultPath = "/sdcard";
|
private const string DefaultPath = "/sdcard";
|
||||||
|
|
||||||
private EmulatedSdCard _sdCard;
|
private SdmmcApi _sdmmc;
|
||||||
private SharedRef<IFileSystem> _rootFileSystem;
|
private SharedRef<IFileSystem> _rootFileSystem;
|
||||||
private SharedRef<IFileSystem> _sdCardFileSystem;
|
private SharedRef<IFileSystem> _sdCardFileSystem;
|
||||||
private string _path;
|
private string _path;
|
||||||
|
|
||||||
public EmulatedSdCardFileSystemCreator(EmulatedSdCard sdCard, ref SharedRef<IFileSystem> rootFileSystem)
|
public EmulatedSdCardFileSystemCreator(SdmmcApi sdmmc, ref SharedRef<IFileSystem> rootFileSystem)
|
||||||
{
|
{
|
||||||
_sdCard = sdCard;
|
_sdmmc = sdmmc;
|
||||||
_rootFileSystem = SharedRef<IFileSystem>.CreateMove(ref rootFileSystem);
|
_rootFileSystem = SharedRef<IFileSystem>.CreateMove(ref rootFileSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmulatedSdCardFileSystemCreator(EmulatedSdCard sdCard, ref SharedRef<IFileSystem> rootFileSystem, string path)
|
public EmulatedSdCardFileSystemCreator(SdmmcApi sdmmc, ref SharedRef<IFileSystem> rootFileSystem, string path)
|
||||||
{
|
{
|
||||||
_sdCard = sdCard;
|
_sdmmc = sdmmc;
|
||||||
_rootFileSystem = SharedRef<IFileSystem>.CreateMove(ref rootFileSystem);
|
_rootFileSystem = SharedRef<IFileSystem>.CreateMove(ref rootFileSystem);
|
||||||
_path = path;
|
_path = path;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ public class EmulatedSdCardFileSystemCreator : ISdCardProxyFileSystemCreator, ID
|
||||||
|
|
||||||
public Result Create(ref SharedRef<IFileSystem> outFileSystem, bool openCaseSensitive)
|
public Result Create(ref SharedRef<IFileSystem> outFileSystem, bool openCaseSensitive)
|
||||||
{
|
{
|
||||||
if (!_sdCard.IsSdCardInserted())
|
if (!_sdmmc.IsSdCardInserted(Port.SdCard0))
|
||||||
{
|
{
|
||||||
return ResultFs.PortSdCardNoDevice.Log();
|
return ResultFs.PortSdCardNoDevice.Log();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,12 @@ public partial class SdmmcApi
|
||||||
|
|
||||||
public Result Activate(Port port)
|
public Result Activate(Port port)
|
||||||
{
|
{
|
||||||
|
if (port == Port.SdCard0)
|
||||||
|
{
|
||||||
|
_isSdCardRemoved = false;
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,19 @@ public partial class SdmmcApi
|
||||||
|
|
||||||
public const int SdCardWorkBufferSize = SdCardSdStatusSize;
|
public const int SdCardWorkBufferSize = SdCardSdStatusSize;
|
||||||
|
|
||||||
|
private bool _isSdCardInserted;
|
||||||
|
private bool _isSdCardRemoved;
|
||||||
|
|
||||||
|
public void SetSdCardInserted(bool isInserted)
|
||||||
|
{
|
||||||
|
if (_isSdCardInserted && isInserted == false)
|
||||||
|
{
|
||||||
|
_isSdCardRemoved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isSdCardInserted = isInserted;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSdCardWorkBuffer(Port port, Memory<byte> workBuffer)
|
public void SetSdCardWorkBuffer(Port port, Memory<byte> workBuffer)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -67,21 +80,21 @@ public partial class SdmmcApi
|
||||||
|
|
||||||
public void RegisterSdCardDetectionEventCallback(Port port, DeviceDetectionEventCallback callback, object args)
|
public void RegisterSdCardDetectionEventCallback(Port port, DeviceDetectionEventCallback callback, object args)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnregisterSdCardDetectionEventCallback(Port port)
|
public void UnregisterSdCardDetectionEventCallback(Port port)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSdCardInserted(Port port)
|
public bool IsSdCardInserted(Port port)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _isSdCardInserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSdCardRemoved(Port port)
|
public bool IsSdCardRemoved(Port port)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _isSdCardRemoved;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@ public static class FileSystemServerFactory
|
||||||
DefaultFsServerObjects.GetDefaultEmulatedCreators(hos.RootFileSystem, keySet, hos.FsServer,
|
DefaultFsServerObjects.GetDefaultEmulatedCreators(hos.RootFileSystem, keySet, hos.FsServer,
|
||||||
randomGenerator);
|
randomGenerator);
|
||||||
|
|
||||||
defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted);
|
defaultObjects.Sdmmc.SetSdCardInserted(sdCardInserted);
|
||||||
|
|
||||||
var config = new FileSystemServerConfig();
|
var config = new FileSystemServerConfig();
|
||||||
config.FsCreators = defaultObjects.FsCreators;
|
config.FsCreators = defaultObjects.FsCreators;
|
||||||
|
|
Loading…
Reference in a new issue