mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add some XML docs for GcSrv and SdmmcSrv
This commit is contained in:
parent
94221ef073
commit
fa9d5422cf
31 changed files with 225 additions and 35 deletions
|
@ -3,31 +3,29 @@ using LibHac.FsSrv.Storage;
|
|||
|
||||
namespace LibHac.Fs.Impl;
|
||||
|
||||
/// <summary>
|
||||
/// Allows getting the current handle for the SD card and checking to see if a provided handle is still valid.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdHandleManager : IDeviceHandleManager
|
||||
{
|
||||
// LibHac addition
|
||||
private readonly FileSystemServer _fsServer;
|
||||
|
||||
public SdHandleManager(FileSystemServer fsServer)
|
||||
{
|
||||
_fsServer = fsServer;
|
||||
}
|
||||
|
||||
public Result GetHandle(out StorageDeviceHandle handle)
|
||||
{
|
||||
return GetCurrentSdCardHandle(out handle);
|
||||
return _fsServer.Storage.GetCurrentSdCardHandle(out handle).Ret();
|
||||
}
|
||||
|
||||
public bool IsValid(in StorageDeviceHandle handle)
|
||||
{
|
||||
// Note: Nintendo ignores the result here.
|
||||
IsSdCardHandleValid(out bool isValid, in handle).IgnoreResult();
|
||||
_fsServer.Storage.IsSdCardHandleValid(out bool isValid, in handle).IgnoreResult();
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// Todo: Use FsSrv.Storage
|
||||
private static Result GetCurrentSdCardHandle(out StorageDeviceHandle handle)
|
||||
{
|
||||
handle = new StorageDeviceHandle(1, StorageDevicePortId.SdCard);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
private static Result IsSdCardHandleValid(out bool isValid, in StorageDeviceHandle handle)
|
||||
{
|
||||
isValid = handle.PortId == StorageDevicePortId.SdCard;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ public static class FileSystemServerInitializer
|
|||
var debugConfigurationService = new DebugConfigurationServiceImpl(in debugConfigurationServiceConfig);
|
||||
|
||||
var saveDataIndexerManager = new SaveDataIndexerManager(server.Hos.Fs, Fs.SaveData.SaveIndexerId,
|
||||
new ArrayPoolMemoryResource(), new SdHandleManager(), false);
|
||||
new ArrayPoolMemoryResource(), new SdHandleManager(server), false);
|
||||
|
||||
var programRegistryConfig = new ProgramRegistryServiceImpl.Configuration();
|
||||
programRegistryConfig.FsServer = server;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using LibHac.Fs;
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
||||
public interface ISdStorageCreator
|
||||
public interface ISdStorageCreator: IDisposable
|
||||
{
|
||||
Result Create(out IStorage storage);
|
||||
Result Create(ref SharedRef<IStorage> outStorage);
|
||||
}
|
30
src/LibHac/FsSrv/FsCreator/SdStorageCreator.cs
Normal file
30
src/LibHac/FsSrv/FsCreator/SdStorageCreator.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Storage;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
||||
/// <summary>
|
||||
/// Creates <see cref="IStorage"/>s for accessing the inserted SD card's storage.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public class SdStorageCreator : ISdStorageCreator
|
||||
{
|
||||
// LibHac addition
|
||||
private readonly FileSystemServer _fsServer;
|
||||
|
||||
public SdStorageCreator(FileSystemServer fsServer)
|
||||
{
|
||||
_fsServer = fsServer;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
public Result Create(ref SharedRef<IStorage> outStorage)
|
||||
{
|
||||
return _fsServer.Storage.OpenSdStorage(ref outStorage).Ret();
|
||||
}
|
||||
}
|
|
@ -199,6 +199,8 @@ public class EmulatedStorageDeviceManagerFactory : IStorageDeviceManagerFactory
|
|||
|
||||
if (!_sdCardDeviceManager.HasValue)
|
||||
{
|
||||
// Missing: Register device address space
|
||||
|
||||
using SharedRef<SdCardManager> manager = SdCardManager.CreateShared(_sdmmc);
|
||||
_sdCardDeviceManager.SetByMove(ref manager.Ref);
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@ using LibHac.Sf;
|
|||
|
||||
namespace LibHac.FsSrv.Storage;
|
||||
|
||||
/// <summary>
|
||||
/// Manages setting storage devices as ready or not ready, and allows opening <see cref="IStorageDeviceManager"/>s for
|
||||
/// each storage device.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public interface IStorageDeviceManagerFactory : IDisposable
|
||||
{
|
||||
Result Create(ref SharedRef<IStorageDeviceManager> outDeviceManager, StorageDevicePortId portId);
|
||||
|
|
|
@ -5,6 +5,11 @@ namespace LibHac.FsSrv.Storage.Sf;
|
|||
|
||||
// Note: This interface doesn't actually implement IStorage. We're giving it IStorage as a base because
|
||||
// StorageServiceObjectAdapter is a template that is used with either IStorage or IStorageDevice
|
||||
/// <summary>
|
||||
/// Allows reading from or writing to a storage device's storage like an <see cref="IStorage"/>, getting or validating
|
||||
/// its current handle, and opening an <see cref="IStorageDeviceOperator"/> for the storage device.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public interface IStorageDevice : IStorage
|
||||
{
|
||||
Result GetHandle(out uint handle);
|
||||
|
|
|
@ -5,6 +5,10 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
|||
|
||||
namespace LibHac.FsSrv.Storage.Sf;
|
||||
|
||||
/// <summary>
|
||||
/// Allows getting the current state of a storage device and opening various interfaces to operate on it.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public interface IStorageDeviceManager : IDisposable
|
||||
{
|
||||
Result IsInserted(out bool isInserted);
|
||||
|
|
|
@ -3,6 +3,13 @@ using LibHac.Sf;
|
|||
|
||||
namespace LibHac.FsSrv.Storage.Sf;
|
||||
|
||||
/// <summary>
|
||||
/// A generic interface for operating on a storage device or a storage device manager, containing methods that all take
|
||||
/// an operation ID and various combinations of on offset/size, input buffers, and output buffers.
|
||||
/// </summary>
|
||||
/// <remarks><para>Operation IDs are not common between implementers of the interface. Every implementer will have its own operations
|
||||
/// and expected input data.</para>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
public interface IStorageDeviceOperator : IDisposable
|
||||
{
|
||||
Result Operate(int operationId);
|
||||
|
|
|
@ -10,6 +10,10 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// The game card manager used on consoles without a game card slot.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public class DummyGameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IGameCardKeyManager
|
||||
{
|
||||
private SharedRef<DummyEventNotifier> _eventNotifier;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace LibHac.GcSrv;
|
|||
/// <summary>
|
||||
/// Manages registering events and signaling them when a game card is inserted or removed.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 14.3.0 (FS 14.1.0)</remarks>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class GameCardDetectionEventManager : CardDeviceDetectionEventManager
|
||||
{
|
||||
private IGcApi _gc;
|
||||
|
|
|
@ -10,6 +10,11 @@ using static LibHac.Gc.Values;
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Performs various operations on the inserted game card.
|
||||
/// All available operations are listed in <see cref="GameCardOperationIdValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class GameCardDeviceOperator : IStorageDeviceOperator
|
||||
{
|
||||
private SharedRef<GameCardStorageDevice> _storageDevice;
|
||||
|
|
|
@ -19,6 +19,17 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Provides access to the game card and game card ASIC.
|
||||
/// </summary>
|
||||
/// <remarks><para> he manager keeps track of the state of the ASIC and uses a handle system to control access to the
|
||||
/// storage device. When a consumer wants to access the device, they are given a handle that will be used to make sure
|
||||
/// they're accessing the same device that they originally opened. The manager's internal handle is incremented every
|
||||
/// time the game card is deactivated. This ensures the consumer doesn't do things like accidentally continue reading
|
||||
/// from the game card after the card has been swapped.</para>
|
||||
/// <para>This class implements the <see cref="IStorageDeviceOperator"/> interface, and all available operations are
|
||||
/// listed in <see cref="GameCardManagerOperationIdValue"/>.</para>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IGameCardManager, IGameCardKeyManager
|
||||
{
|
||||
private enum CardState
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace LibHac.GcSrv;
|
|||
/// <summary>
|
||||
/// Provides an <see cref="IStorage"/> interface for reading from the game card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 14.3.0 (FS 14.1.0)</remarks>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class ReadOnlyGameCardStorage : IStorage
|
||||
{
|
||||
private SharedRef<IGameCardManager> _deviceManager;
|
||||
|
@ -97,7 +97,7 @@ internal class ReadOnlyGameCardStorage : IStorage
|
|||
/// <summary>
|
||||
/// Provides an <see cref="IStorage"/> interface for writing to the game card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 14.3.0 (FS 14.1.0)</remarks>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class WriteOnlyGameCardStorage : IStorage
|
||||
{
|
||||
private SharedRef<IGameCardManager> _deviceManager;
|
||||
|
@ -165,9 +165,10 @@ internal class WriteOnlyGameCardStorage : IStorage
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// An adapter that provides an <see cref="IStorageSf"/> interface for a <see cref="IStorage"/>.
|
||||
/// An adapter that directly translates <see cref="IStorageSf"/> sf calls to <see cref="IStorage"/> calls with no checks
|
||||
/// or validations.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 14.3.0 (FS 14.1.0)</remarks>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal abstract class GameCardStorageInterfaceAdapter : IStorageSf
|
||||
{
|
||||
private SharedRef<IStorage> _baseStorage;
|
||||
|
|
|
@ -10,6 +10,10 @@ using LibHac.Sf;
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IStorageDevice"/> that handles interacting with the currently inserted game card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class GameCardStorageDevice : GameCardStorageInterfaceAdapter, IStorageDevice
|
||||
{
|
||||
private SharedRef<IGameCardManager> _manager;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="GameCardManager"/> can perform on the game card ASIC and writable game cards.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum GameCardManagerOperationIdValue
|
||||
{
|
||||
Finalize = 1,
|
||||
|
@ -18,6 +22,10 @@ public enum GameCardManagerOperationIdValue
|
|||
SimulateDetectionEventSignaled = 14
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="GameCardDeviceOperator"/> can perform on the inserted game card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum GameCardOperationIdValue
|
||||
{
|
||||
EraseGameCard = 1,
|
||||
|
@ -29,6 +37,10 @@ public enum GameCardOperationIdValue
|
|||
GetGameCardStatus = 7
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies which mode the game card storage should be opened as.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum OpenGameCardAttribute : long
|
||||
{
|
||||
ReadOnly = 0,
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the certificate and key used for communicating with the game card ASIC.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public interface IGameCardKeyManager : IDisposable
|
||||
{
|
||||
void PresetInternalKeys(ReadOnlySpan<byte> gameCardKey, ReadOnlySpan<byte> gameCardCertificate);
|
||||
|
|
|
@ -3,6 +3,10 @@ using LibHac.Os;
|
|||
|
||||
namespace LibHac.GcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Handles granting access to the game card, and keeps track of the current game card handle.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal interface IGameCardManager : IDisposable
|
||||
{
|
||||
Result AcquireReadLock(ref SharedLock<ReaderWriterLock> outLock, GameCardHandle handle);
|
||||
|
|
|
@ -107,6 +107,11 @@ public partial class SdmmcApi
|
|||
|
||||
public void Deactivate(Port port)
|
||||
{
|
||||
if (port == Port.SdCard0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ using LibHac.Sdmmc;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Manages locking and getting the storage from sdmmc devices.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal interface ISdmmcDeviceManager : IDisposable
|
||||
{
|
||||
Result Lock(ref UniqueLockRef<SdkMutexType> outLock, SdmmcHandle handle);
|
||||
|
|
|
@ -12,6 +12,11 @@ using MmcPartition = LibHac.Sdmmc.MmcPartition;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Performs various operations on the internal MMC storage.
|
||||
/// All available operations are listed in <see cref="MmcOperationIdValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class MmcDeviceOperator : IStorageDeviceOperator
|
||||
{
|
||||
private SharedRef<MmcPartitionStorageDevice> _storageDevice;
|
||||
|
|
|
@ -11,6 +11,12 @@ using MmcPartition = LibHac.Fs.MmcPartition;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the state of the internal MMC and allows reading and writing the MMC storage.
|
||||
/// </summary>
|
||||
/// <remarks><para>This class implements the <see cref="IStorageDeviceOperator"/> interface, and all available
|
||||
/// operations are listed in <see cref="MmcManagerOperationIdValue"/>.</para>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
internal class MmcManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmmcDeviceManager
|
||||
{
|
||||
private const SdmmcHandle MmcHandle = 1;
|
||||
|
@ -28,6 +34,8 @@ internal class MmcManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmm
|
|||
|
||||
private MmcManager(SdmmcApi sdmmc)
|
||||
{
|
||||
// Missing: An optional parameter with the device address space info is passed in and stored in the MmcManager.
|
||||
|
||||
_port = Port.Mmc0;
|
||||
_mutex = new SdkMutex();
|
||||
|
||||
|
|
|
@ -7,9 +7,15 @@ using LibHac.Os;
|
|||
using LibHac.Sdmmc;
|
||||
using LibHac.Sf;
|
||||
using MmcPartition = LibHac.Sdmmc.MmcPartition;
|
||||
using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
||||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Provides base functionality for MMC <see cref="IStorageDevice"/> classes. Derived classes will need to provide
|
||||
/// methods for reading/writing the MMC storage.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal abstract class MmcPartitionStorageDevice : IDisposable
|
||||
{
|
||||
private SharedRef<ISdmmcDeviceManager> _manager;
|
||||
|
@ -81,9 +87,15 @@ internal abstract class MmcPartitionStorageDevice : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
// The Mmc*PartitionStorageDevice classes inherit both from SdmmcStorageInterfaceAdapter and MmcPartitionStorageDevice
|
||||
// Because C# doesn't have multiple inheritance, we make a copy of the SdmmcStorageInterfaceAdapter class that inherits
|
||||
// from MmcPartitionStorageDevice. This class must mirror any changes made to SdmmcStorageInterfaceAdapter.
|
||||
/// <summary>
|
||||
/// An adapter that directly translates <see cref="IStorageSf"/> sf calls to <see cref="IStorage"/> calls with no checks
|
||||
/// or validations.
|
||||
/// </summary>
|
||||
/// <remarks><para>The Mmc*PartitionStorageDevice classes inherit both from <see cref="SdmmcStorageInterfaceAdapter"/>
|
||||
/// and <see cref="MmcPartitionStorageDevice"/>. Because C# doesn't have multiple inheritance, we make a copy of the
|
||||
/// <see cref="SdmmcStorageInterfaceAdapter"/> class that inherits from <see cref="MmcPartitionStorageDevice"/>.
|
||||
/// This class must mirror any changes made to <see cref="SdmmcStorageInterfaceAdapter"/>.</para>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
internal abstract class MmcPartitionStorageDeviceInterfaceAdapter : MmcPartitionStorageDevice, IStorageDevice
|
||||
{
|
||||
private readonly IStorage _baseStorage;
|
||||
|
@ -129,12 +141,16 @@ internal abstract class MmcPartitionStorageDeviceInterfaceAdapter : MmcPartition
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IStorageDevice"/> that handles interacting with the <see cref="MmcPartition.UserData"/> partition
|
||||
/// on the internal MMC.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class MmcUserDataPartitionStorageDevice : MmcPartitionStorageDeviceInterfaceAdapter
|
||||
{
|
||||
private MmcUserDataPartitionStorageDevice(ref SharedRef<ISdmmcDeviceManager> manager, SdmmcHandle handle,
|
||||
SdmmcApi sdmmc)
|
||||
: base(manager.Get.GetStorage(), MmcPartition.UserData, ref manager, handle, sdmmc)
|
||||
{ }
|
||||
: base(manager.Get.GetStorage(), MmcPartition.UserData, ref manager, handle, sdmmc) { }
|
||||
|
||||
public static SharedRef<MmcUserDataPartitionStorageDevice> CreateShared(ref SharedRef<ISdmmcDeviceManager> manager,
|
||||
SdmmcHandle handle, SdmmcApi sdmmc)
|
||||
|
@ -189,12 +205,16 @@ internal class MmcUserDataPartitionStorageDevice : MmcPartitionStorageDeviceInte
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IStorageDevice"/> that handles interacting with the <see cref="MmcPartition.BootPartition1"/> and
|
||||
/// <see cref="MmcPartition.BootPartition2"/> partitions on the internal MMC.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class MmcBootPartitionStorageDevice : MmcPartitionStorageDeviceInterfaceAdapter
|
||||
{
|
||||
private MmcBootPartitionStorageDevice(Fs.MmcPartition partition, ref SharedRef<ISdmmcDeviceManager> manager,
|
||||
SdmmcHandle handle, SdmmcApi sdmmc)
|
||||
: base(manager.Get.GetStorage(), GetPartition(partition), ref manager, handle, sdmmc)
|
||||
{ }
|
||||
: base(manager.Get.GetStorage(), GetPartition(partition), ref manager, handle, sdmmc) { }
|
||||
|
||||
public static SharedRef<MmcBootPartitionStorageDevice> CreateShared(Fs.MmcPartition partition,
|
||||
ref SharedRef<ISdmmcDeviceManager> manager, SdmmcHandle handle, SdmmcApi sdmmc)
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace LibHac.SdmmcSrv;
|
|||
/// Every 2 hours it will save the current state of the patrol read to Boot Partition 1 on the MMC.
|
||||
/// This state contains the next sector index to be read and the number of times the MMC has been patrolled
|
||||
/// from start to finish.</para>
|
||||
/// <para>Based on nnSdk 14.3.0 (FS 14.1.0)</para></remarks>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
internal class PatrolReader
|
||||
{
|
||||
// Note: This class won't work until events and timer events are properly implemented.
|
||||
|
|
|
@ -3,6 +3,10 @@ using LibHac.Sdmmc;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Registers an sdmmc detection callback when constructed, and unregisters the callback when disposed.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdCardDetectionEventManager : CardDeviceDetectionEventManager
|
||||
{
|
||||
// LibHac addition
|
||||
|
|
|
@ -9,6 +9,11 @@ using static LibHac.SdmmcSrv.SdmmcResultConverter;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Performs various operations on the inserted SD card.
|
||||
/// All available operations are listed in <see cref="SdCardOperationIdValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdCardDeviceOperator : IStorageDeviceOperator
|
||||
{
|
||||
private SharedRef<SdCardStorageDevice> _storageDevice;
|
||||
|
|
|
@ -13,6 +13,12 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the state of the SD card and allows reading and writing the SD card storage.
|
||||
/// </summary>
|
||||
/// <remarks><para>This class implements the <see cref="IStorageDeviceOperator"/> interface, and all available
|
||||
/// operations are listed in <see cref="SdCardManagerOperationIdValue"/>.</para>
|
||||
/// <para>Based on nnSdk 15.3.0 (FS 15.0.0)</para></remarks>
|
||||
public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmmcDeviceManager
|
||||
{
|
||||
private const SdmmcHandle InvalidHandle = 0;
|
||||
|
@ -37,6 +43,8 @@ public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdm
|
|||
|
||||
private SdCardManager(SdmmcApi sdmmc)
|
||||
{
|
||||
// Missing: An optional parameter with the device address space info is passed in and stored in the SdCardManager.
|
||||
|
||||
_port = Port.SdCard0;
|
||||
_mutex = new SdkMutexType();
|
||||
_sdStorage = new SdmmcStorage(_port, sdmmc);
|
||||
|
@ -141,7 +149,6 @@ public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdm
|
|||
outDeviceOperator.SetByMove(ref deviceOperator.Ref);
|
||||
|
||||
return Result.Success;
|
||||
|
||||
}
|
||||
|
||||
public Result OpenDevice(ref SharedRef<IStorageDevice> outStorageDevice, ulong attribute)
|
||||
|
|
|
@ -7,6 +7,10 @@ using LibHac.Sf;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IStorageDevice"/> that handles interacting with the currently inserted game card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdCardStorageDevice : SdmmcStorageInterfaceAdapter, IStorageDevice
|
||||
{
|
||||
private SharedRef<ISdmmcDeviceManager> _manager;
|
||||
|
|
|
@ -3,6 +3,10 @@ using LibHac.Sdmmc;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Contains functions to convert <see cref="ResultSdmmc"/> <see cref="Result"/>s to their <see cref="ResultFs"/> equivalent.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public static class SdmmcResultConverter
|
||||
{
|
||||
public static Result GetFsResult(Port port, Result result)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="SdCardManager"/> can perform on the SD card device.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum SdCardManagerOperationIdValue
|
||||
{
|
||||
GetAndClearErrorInfo = 1,
|
||||
|
@ -8,6 +12,10 @@ public enum SdCardManagerOperationIdValue
|
|||
SimulateDetectionEventSignaled = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="SdCardDeviceOperator"/> can perform on the inserted SD card.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum SdCardOperationIdValue
|
||||
{
|
||||
GetSpeedMode = 1,
|
||||
|
@ -18,6 +26,10 @@ public enum SdCardOperationIdValue
|
|||
GetProtectedAreaSize = 6
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="MmcManager"/> can perform on the internal MMC device.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum MmcManagerOperationIdValue
|
||||
{
|
||||
GetAndClearErrorInfo = 1,
|
||||
|
@ -29,6 +41,10 @@ public enum MmcManagerOperationIdValue
|
|||
ResumePatrol = 7
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The operations that <see cref="MmcDeviceOperator"/> can perform on the internal MMC storage.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
public enum MmcOperationIdValue
|
||||
{
|
||||
GetSpeedMode = 1,
|
||||
|
|
|
@ -14,6 +14,11 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
|||
|
||||
namespace LibHac.SdmmcSrv;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an <see cref="IStorage"/> interface for calling the sdmmc Read and Write functions.
|
||||
/// The offset and size of reads and writes must be aligned to 0x200 bytes (<see cref="SdmmcApi.SectorSize"/>).
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdmmcStorage : IStorage
|
||||
{
|
||||
private Port _port;
|
||||
|
@ -142,6 +147,11 @@ internal class SdmmcStorage : IStorage
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An adapter that directly translates <see cref="IStorageSf"/> sf calls to <see cref="IStorage"/> calls with no checks
|
||||
/// or validations.
|
||||
/// </summary>
|
||||
/// <remarks>Based on nnSdk 15.3.0 (FS 15.0.0)</remarks>
|
||||
internal class SdmmcStorageInterfaceAdapter : IStorageSf
|
||||
{
|
||||
private IStorage _baseStorage;
|
||||
|
|
Loading…
Reference in a new issue