diff --git a/src/LibHac/Fs/Impl/SdHandleManager.cs b/src/LibHac/Fs/Impl/SdHandleManager.cs
index 1495d124..16e53134 100644
--- a/src/LibHac/Fs/Impl/SdHandleManager.cs
+++ b/src/LibHac/Fs/Impl/SdHandleManager.cs
@@ -3,31 +3,29 @@ using LibHac.FsSrv.Storage;
namespace LibHac.Fs.Impl;
+///
+/// Allows getting the current handle for the SD card and checking to see if a provided handle is still valid.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
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;
- }
}
\ No newline at end of file
diff --git a/src/LibHac/FsSrv/FileSystemServerInitializer.cs b/src/LibHac/FsSrv/FileSystemServerInitializer.cs
index ea543f8e..b6aa323f 100644
--- a/src/LibHac/FsSrv/FileSystemServerInitializer.cs
+++ b/src/LibHac/FsSrv/FileSystemServerInitializer.cs
@@ -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;
diff --git a/src/LibHac/FsSrv/FsCreator/ISdStorageCreator.cs b/src/LibHac/FsSrv/FsCreator/ISdStorageCreator.cs
index 6c6351f0..ec88014c 100644
--- a/src/LibHac/FsSrv/FsCreator/ISdStorageCreator.cs
+++ b/src/LibHac/FsSrv/FsCreator/ISdStorageCreator.cs
@@ -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 outStorage);
}
\ No newline at end of file
diff --git a/src/LibHac/FsSrv/FsCreator/SdStorageCreator.cs b/src/LibHac/FsSrv/FsCreator/SdStorageCreator.cs
new file mode 100644
index 00000000..c4193ce4
--- /dev/null
+++ b/src/LibHac/FsSrv/FsCreator/SdStorageCreator.cs
@@ -0,0 +1,30 @@
+using LibHac.Common;
+using LibHac.Fs;
+using LibHac.FsSrv.Storage;
+
+namespace LibHac.FsSrv.FsCreator;
+
+///
+/// Creates s for accessing the inserted SD card's storage.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
+public class SdStorageCreator : ISdStorageCreator
+{
+ // LibHac addition
+ private readonly FileSystemServer _fsServer;
+
+ public SdStorageCreator(FileSystemServer fsServer)
+ {
+ _fsServer = fsServer;
+ }
+
+ public void Dispose()
+ {
+ // ...
+ }
+
+ public Result Create(ref SharedRef outStorage)
+ {
+ return _fsServer.Storage.OpenSdStorage(ref outStorage).Ret();
+ }
+}
\ No newline at end of file
diff --git a/src/LibHac/FsSrv/Storage/EmulatedStorageDeviceManagerFactory.cs b/src/LibHac/FsSrv/Storage/EmulatedStorageDeviceManagerFactory.cs
index 8ced2ede..73bc571e 100644
--- a/src/LibHac/FsSrv/Storage/EmulatedStorageDeviceManagerFactory.cs
+++ b/src/LibHac/FsSrv/Storage/EmulatedStorageDeviceManagerFactory.cs
@@ -199,6 +199,8 @@ public class EmulatedStorageDeviceManagerFactory : IStorageDeviceManagerFactory
if (!_sdCardDeviceManager.HasValue)
{
+ // Missing: Register device address space
+
using SharedRef manager = SdCardManager.CreateShared(_sdmmc);
_sdCardDeviceManager.SetByMove(ref manager.Ref);
diff --git a/src/LibHac/FsSrv/Storage/IStorageDeviceManagerFactory.cs b/src/LibHac/FsSrv/Storage/IStorageDeviceManagerFactory.cs
index ed631286..1aa55838 100644
--- a/src/LibHac/FsSrv/Storage/IStorageDeviceManagerFactory.cs
+++ b/src/LibHac/FsSrv/Storage/IStorageDeviceManagerFactory.cs
@@ -5,6 +5,11 @@ using LibHac.Sf;
namespace LibHac.FsSrv.Storage;
+///
+/// Manages setting storage devices as ready or not ready, and allows opening s for
+/// each storage device.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public interface IStorageDeviceManagerFactory : IDisposable
{
Result Create(ref SharedRef outDeviceManager, StorageDevicePortId portId);
diff --git a/src/LibHac/FsSrv/Storage/Sf/IStorageDevice.cs b/src/LibHac/FsSrv/Storage/Sf/IStorageDevice.cs
index aa127913..3304d159 100644
--- a/src/LibHac/FsSrv/Storage/Sf/IStorageDevice.cs
+++ b/src/LibHac/FsSrv/Storage/Sf/IStorageDevice.cs
@@ -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
+///
+/// Allows reading from or writing to a storage device's storage like an , getting or validating
+/// its current handle, and opening an for the storage device.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public interface IStorageDevice : IStorage
{
Result GetHandle(out uint handle);
diff --git a/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceManager.cs b/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceManager.cs
index 39f69df6..2da4c897 100644
--- a/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceManager.cs
+++ b/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceManager.cs
@@ -5,6 +5,10 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.FsSrv.Storage.Sf;
+///
+/// Allows getting the current state of a storage device and opening various interfaces to operate on it.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public interface IStorageDeviceManager : IDisposable
{
Result IsInserted(out bool isInserted);
diff --git a/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceOperator.cs b/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceOperator.cs
index 1a56f5da..0c21954e 100644
--- a/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceOperator.cs
+++ b/src/LibHac/FsSrv/Storage/Sf/IStorageDeviceOperator.cs
@@ -3,6 +3,13 @@ using LibHac.Sf;
namespace LibHac.FsSrv.Storage.Sf;
+///
+/// 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.
+///
+/// Operation IDs are not common between implementers of the interface. Every implementer will have its own operations
+/// and expected input data.
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public interface IStorageDeviceOperator : IDisposable
{
Result Operate(int operationId);
diff --git a/src/LibHac/GcSrv/DummyGameCardManager.cs b/src/LibHac/GcSrv/DummyGameCardManager.cs
index 163b8f33..cc526a76 100644
--- a/src/LibHac/GcSrv/DummyGameCardManager.cs
+++ b/src/LibHac/GcSrv/DummyGameCardManager.cs
@@ -10,6 +10,10 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.GcSrv;
+///
+/// The game card manager used on consoles without a game card slot.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public class DummyGameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IGameCardKeyManager
{
private SharedRef _eventNotifier;
diff --git a/src/LibHac/GcSrv/GameCardDetectionEventManager.cs b/src/LibHac/GcSrv/GameCardDetectionEventManager.cs
index 1c4be90c..64079916 100644
--- a/src/LibHac/GcSrv/GameCardDetectionEventManager.cs
+++ b/src/LibHac/GcSrv/GameCardDetectionEventManager.cs
@@ -6,7 +6,7 @@ namespace LibHac.GcSrv;
///
/// Manages registering events and signaling them when a game card is inserted or removed.
///
-/// Based on nnSdk 14.3.0 (FS 14.1.0)
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class GameCardDetectionEventManager : CardDeviceDetectionEventManager
{
private IGcApi _gc;
diff --git a/src/LibHac/GcSrv/GameCardDeviceOperator.cs b/src/LibHac/GcSrv/GameCardDeviceOperator.cs
index 4229aa61..8ecd7f34 100644
--- a/src/LibHac/GcSrv/GameCardDeviceOperator.cs
+++ b/src/LibHac/GcSrv/GameCardDeviceOperator.cs
@@ -10,6 +10,11 @@ using static LibHac.Gc.Values;
namespace LibHac.GcSrv;
+///
+/// Performs various operations on the inserted game card.
+/// All available operations are listed in .
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class GameCardDeviceOperator : IStorageDeviceOperator
{
private SharedRef _storageDevice;
diff --git a/src/LibHac/GcSrv/GameCardManager.cs b/src/LibHac/GcSrv/GameCardManager.cs
index d0dcfbfa..b1cb8f23 100644
--- a/src/LibHac/GcSrv/GameCardManager.cs
+++ b/src/LibHac/GcSrv/GameCardManager.cs
@@ -19,6 +19,17 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.GcSrv;
+///
+/// Provides access to the game card and game card ASIC.
+///
+/// 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.
+/// This class implements the interface, and all available operations are
+/// listed in .
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IGameCardManager, IGameCardKeyManager
{
private enum CardState
diff --git a/src/LibHac/GcSrv/GameCardStorage.cs b/src/LibHac/GcSrv/GameCardStorage.cs
index 1bd934d2..c20b0a92 100644
--- a/src/LibHac/GcSrv/GameCardStorage.cs
+++ b/src/LibHac/GcSrv/GameCardStorage.cs
@@ -14,7 +14,7 @@ namespace LibHac.GcSrv;
///
/// Provides an interface for reading from the game card.
///
-/// Based on nnSdk 14.3.0 (FS 14.1.0)
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class ReadOnlyGameCardStorage : IStorage
{
private SharedRef _deviceManager;
@@ -97,7 +97,7 @@ internal class ReadOnlyGameCardStorage : IStorage
///
/// Provides an interface for writing to the game card.
///
-/// Based on nnSdk 14.3.0 (FS 14.1.0)
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class WriteOnlyGameCardStorage : IStorage
{
private SharedRef _deviceManager;
@@ -165,9 +165,10 @@ internal class WriteOnlyGameCardStorage : IStorage
}
///
-/// An adapter that provides an interface for a .
+/// An adapter that directly translates sf calls to calls with no checks
+/// or validations.
///
-/// Based on nnSdk 14.3.0 (FS 14.1.0)
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal abstract class GameCardStorageInterfaceAdapter : IStorageSf
{
private SharedRef _baseStorage;
diff --git a/src/LibHac/GcSrv/GameCardStorageDevice.cs b/src/LibHac/GcSrv/GameCardStorageDevice.cs
index fbf1310a..f71aa12c 100644
--- a/src/LibHac/GcSrv/GameCardStorageDevice.cs
+++ b/src/LibHac/GcSrv/GameCardStorageDevice.cs
@@ -10,6 +10,10 @@ using LibHac.Sf;
namespace LibHac.GcSrv;
+///
+/// An that handles interacting with the currently inserted game card.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class GameCardStorageDevice : GameCardStorageInterfaceAdapter, IStorageDevice
{
private SharedRef _manager;
diff --git a/src/LibHac/GcSrv/GcSrvEnums.cs b/src/LibHac/GcSrv/GcSrvEnums.cs
index dcac60f4..972374f3 100644
--- a/src/LibHac/GcSrv/GcSrvEnums.cs
+++ b/src/LibHac/GcSrv/GcSrvEnums.cs
@@ -1,5 +1,9 @@
namespace LibHac.GcSrv;
+///
+/// The operations that can perform on the game card ASIC and writable game cards.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum GameCardManagerOperationIdValue
{
Finalize = 1,
@@ -18,6 +22,10 @@ public enum GameCardManagerOperationIdValue
SimulateDetectionEventSignaled = 14
}
+///
+/// The operations that can perform on the inserted game card.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum GameCardOperationIdValue
{
EraseGameCard = 1,
@@ -29,6 +37,10 @@ public enum GameCardOperationIdValue
GetGameCardStatus = 7
}
+///
+/// Specifies which mode the game card storage should be opened as.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum OpenGameCardAttribute : long
{
ReadOnly = 0,
diff --git a/src/LibHac/GcSrv/IGameCardKeyManager.cs b/src/LibHac/GcSrv/IGameCardKeyManager.cs
index 247f710e..011f2862 100644
--- a/src/LibHac/GcSrv/IGameCardKeyManager.cs
+++ b/src/LibHac/GcSrv/IGameCardKeyManager.cs
@@ -2,6 +2,10 @@
namespace LibHac.GcSrv;
+///
+/// Sets the certificate and key used for communicating with the game card ASIC.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public interface IGameCardKeyManager : IDisposable
{
void PresetInternalKeys(ReadOnlySpan gameCardKey, ReadOnlySpan gameCardCertificate);
diff --git a/src/LibHac/GcSrv/IGameCardManager.cs b/src/LibHac/GcSrv/IGameCardManager.cs
index 513fa602..c6176b39 100644
--- a/src/LibHac/GcSrv/IGameCardManager.cs
+++ b/src/LibHac/GcSrv/IGameCardManager.cs
@@ -3,6 +3,10 @@ using LibHac.Os;
namespace LibHac.GcSrv;
+///
+/// Handles granting access to the game card, and keeps track of the current game card handle.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal interface IGameCardManager : IDisposable
{
Result AcquireReadLock(ref SharedLock outLock, GameCardHandle handle);
diff --git a/src/LibHac/Sdmmc/Common.cs b/src/LibHac/Sdmmc/Common.cs
index 67e5f600..f7a5f12f 100644
--- a/src/LibHac/Sdmmc/Common.cs
+++ b/src/LibHac/Sdmmc/Common.cs
@@ -107,6 +107,11 @@ public partial class SdmmcApi
public void Deactivate(Port port)
{
+ if (port == Port.SdCard0)
+ {
+ return;
+ }
+
throw new NotImplementedException();
}
diff --git a/src/LibHac/SdmmcSrv/ISdmmcDeviceManager.cs b/src/LibHac/SdmmcSrv/ISdmmcDeviceManager.cs
index e080f219..7e9f37a6 100644
--- a/src/LibHac/SdmmcSrv/ISdmmcDeviceManager.cs
+++ b/src/LibHac/SdmmcSrv/ISdmmcDeviceManager.cs
@@ -5,6 +5,10 @@ using LibHac.Sdmmc;
namespace LibHac.SdmmcSrv;
+///
+/// Manages locking and getting the storage from sdmmc devices.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal interface ISdmmcDeviceManager : IDisposable
{
Result Lock(ref UniqueLockRef outLock, SdmmcHandle handle);
diff --git a/src/LibHac/SdmmcSrv/MmcDeviceOperator.cs b/src/LibHac/SdmmcSrv/MmcDeviceOperator.cs
index 8f2da126..8de8f47c 100644
--- a/src/LibHac/SdmmcSrv/MmcDeviceOperator.cs
+++ b/src/LibHac/SdmmcSrv/MmcDeviceOperator.cs
@@ -12,6 +12,11 @@ using MmcPartition = LibHac.Sdmmc.MmcPartition;
namespace LibHac.SdmmcSrv;
+///
+/// Performs various operations on the internal MMC storage.
+/// All available operations are listed in .
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class MmcDeviceOperator : IStorageDeviceOperator
{
private SharedRef _storageDevice;
diff --git a/src/LibHac/SdmmcSrv/MmcManager.cs b/src/LibHac/SdmmcSrv/MmcManager.cs
index b7a5fe54..1a09a7f3 100644
--- a/src/LibHac/SdmmcSrv/MmcManager.cs
+++ b/src/LibHac/SdmmcSrv/MmcManager.cs
@@ -11,6 +11,12 @@ using MmcPartition = LibHac.Fs.MmcPartition;
namespace LibHac.SdmmcSrv;
+///
+/// Manages the state of the internal MMC and allows reading and writing the MMC storage.
+///
+/// This class implements the interface, and all available
+/// operations are listed in .
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
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();
diff --git a/src/LibHac/SdmmcSrv/MmcPartitionStorageDevice.cs b/src/LibHac/SdmmcSrv/MmcPartitionStorageDevice.cs
index 053041a5..046e761d 100644
--- a/src/LibHac/SdmmcSrv/MmcPartitionStorageDevice.cs
+++ b/src/LibHac/SdmmcSrv/MmcPartitionStorageDevice.cs
@@ -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;
+///
+/// Provides base functionality for MMC classes. Derived classes will need to provide
+/// methods for reading/writing the MMC storage.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal abstract class MmcPartitionStorageDevice : IDisposable
{
private SharedRef _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.
+///
+/// An adapter that directly translates sf calls to calls with no checks
+/// or validations.
+///
+/// The Mmc*PartitionStorageDevice classes inherit both from
+/// and . Because C# doesn't have multiple inheritance, we make a copy of the
+/// class that inherits from .
+/// This class must mirror any changes made to .
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal abstract class MmcPartitionStorageDeviceInterfaceAdapter : MmcPartitionStorageDevice, IStorageDevice
{
private readonly IStorage _baseStorage;
@@ -129,12 +141,16 @@ internal abstract class MmcPartitionStorageDeviceInterfaceAdapter : MmcPartition
}
}
+///
+/// An that handles interacting with the partition
+/// on the internal MMC.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class MmcUserDataPartitionStorageDevice : MmcPartitionStorageDeviceInterfaceAdapter
{
private MmcUserDataPartitionStorageDevice(ref SharedRef 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 CreateShared(ref SharedRef manager,
SdmmcHandle handle, SdmmcApi sdmmc)
@@ -189,12 +205,16 @@ internal class MmcUserDataPartitionStorageDevice : MmcPartitionStorageDeviceInte
}
}
+///
+/// An that handles interacting with the and
+/// partitions on the internal MMC.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class MmcBootPartitionStorageDevice : MmcPartitionStorageDeviceInterfaceAdapter
{
private MmcBootPartitionStorageDevice(Fs.MmcPartition partition, ref SharedRef 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 CreateShared(Fs.MmcPartition partition,
ref SharedRef manager, SdmmcHandle handle, SdmmcApi sdmmc)
diff --git a/src/LibHac/SdmmcSrv/PatrolReader.cs b/src/LibHac/SdmmcSrv/PatrolReader.cs
index c30d4b13..9b4c32c3 100644
--- a/src/LibHac/SdmmcSrv/PatrolReader.cs
+++ b/src/LibHac/SdmmcSrv/PatrolReader.cs
@@ -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.
-/// Based on nnSdk 14.3.0 (FS 14.1.0)
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class PatrolReader
{
// Note: This class won't work until events and timer events are properly implemented.
diff --git a/src/LibHac/SdmmcSrv/SdCardDetectionEventManager.cs b/src/LibHac/SdmmcSrv/SdCardDetectionEventManager.cs
index d91b8ce1..d0fa7038 100644
--- a/src/LibHac/SdmmcSrv/SdCardDetectionEventManager.cs
+++ b/src/LibHac/SdmmcSrv/SdCardDetectionEventManager.cs
@@ -3,6 +3,10 @@ using LibHac.Sdmmc;
namespace LibHac.SdmmcSrv;
+///
+/// Registers an sdmmc detection callback when constructed, and unregisters the callback when disposed.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class SdCardDetectionEventManager : CardDeviceDetectionEventManager
{
// LibHac addition
diff --git a/src/LibHac/SdmmcSrv/SdCardDeviceOperator.cs b/src/LibHac/SdmmcSrv/SdCardDeviceOperator.cs
index 267815e3..556741ea 100644
--- a/src/LibHac/SdmmcSrv/SdCardDeviceOperator.cs
+++ b/src/LibHac/SdmmcSrv/SdCardDeviceOperator.cs
@@ -9,6 +9,11 @@ using static LibHac.SdmmcSrv.SdmmcResultConverter;
namespace LibHac.SdmmcSrv;
+///
+/// Performs various operations on the inserted SD card.
+/// All available operations are listed in .
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class SdCardDeviceOperator : IStorageDeviceOperator
{
private SharedRef _storageDevice;
diff --git a/src/LibHac/SdmmcSrv/SdCardManager.cs b/src/LibHac/SdmmcSrv/SdCardManager.cs
index 206295a0..f975e218 100644
--- a/src/LibHac/SdmmcSrv/SdCardManager.cs
+++ b/src/LibHac/SdmmcSrv/SdCardManager.cs
@@ -13,6 +13,12 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.SdmmcSrv;
+///
+/// Manages the state of the SD card and allows reading and writing the SD card storage.
+///
+/// This class implements the interface, and all available
+/// operations are listed in .
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
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 outStorageDevice, ulong attribute)
@@ -195,7 +202,7 @@ public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdm
using ScopedLock scopedLock = ScopedLock.Lock(ref _mutex);
DeactivateIfCardRemoved();
-
+
if (IsShutDown())
{
outHandle = InvalidHandle;
diff --git a/src/LibHac/SdmmcSrv/SdCardStorageDevice.cs b/src/LibHac/SdmmcSrv/SdCardStorageDevice.cs
index 7a9968c4..dc7450d1 100644
--- a/src/LibHac/SdmmcSrv/SdCardStorageDevice.cs
+++ b/src/LibHac/SdmmcSrv/SdCardStorageDevice.cs
@@ -7,6 +7,10 @@ using LibHac.Sf;
namespace LibHac.SdmmcSrv;
+///
+/// An that handles interacting with the currently inserted game card.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class SdCardStorageDevice : SdmmcStorageInterfaceAdapter, IStorageDevice
{
private SharedRef _manager;
diff --git a/src/LibHac/SdmmcSrv/SdmmcResultConverter.cs b/src/LibHac/SdmmcSrv/SdmmcResultConverter.cs
index e76bd7a8..bf1e86bb 100644
--- a/src/LibHac/SdmmcSrv/SdmmcResultConverter.cs
+++ b/src/LibHac/SdmmcSrv/SdmmcResultConverter.cs
@@ -3,6 +3,10 @@ using LibHac.Sdmmc;
namespace LibHac.SdmmcSrv;
+///
+/// Contains functions to convert s to their equivalent.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public static class SdmmcResultConverter
{
public static Result GetFsResult(Port port, Result result)
diff --git a/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs b/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs
index 0732ec66..06d8e69e 100644
--- a/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs
+++ b/src/LibHac/SdmmcSrv/SdmmcSrvEnums.cs
@@ -1,5 +1,9 @@
namespace LibHac.SdmmcSrv;
+///
+/// The operations that can perform on the SD card device.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum SdCardManagerOperationIdValue
{
GetAndClearErrorInfo = 1,
@@ -8,6 +12,10 @@ public enum SdCardManagerOperationIdValue
SimulateDetectionEventSignaled = 4
}
+///
+/// The operations that can perform on the inserted SD card.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum SdCardOperationIdValue
{
GetSpeedMode = 1,
@@ -18,6 +26,10 @@ public enum SdCardOperationIdValue
GetProtectedAreaSize = 6
}
+///
+/// The operations that can perform on the internal MMC device.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum MmcManagerOperationIdValue
{
GetAndClearErrorInfo = 1,
@@ -29,6 +41,10 @@ public enum MmcManagerOperationIdValue
ResumePatrol = 7
}
+///
+/// The operations that can perform on the internal MMC storage.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
public enum MmcOperationIdValue
{
GetSpeedMode = 1,
diff --git a/src/LibHac/SdmmcSrv/SdmmcStorage.cs b/src/LibHac/SdmmcSrv/SdmmcStorage.cs
index 7643da57..ba338b4b 100644
--- a/src/LibHac/SdmmcSrv/SdmmcStorage.cs
+++ b/src/LibHac/SdmmcSrv/SdmmcStorage.cs
@@ -14,6 +14,11 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage;
namespace LibHac.SdmmcSrv;
+///
+/// Provides an interface for calling the sdmmc Read and Write functions.
+/// The offset and size of reads and writes must be aligned to 0x200 bytes ().
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class SdmmcStorage : IStorage
{
private Port _port;
@@ -142,6 +147,11 @@ internal class SdmmcStorage : IStorage
}
}
+///
+/// An adapter that directly translates sf calls to calls with no checks
+/// or validations.
+///
+/// Based on nnSdk 15.3.0 (FS 15.0.0)
internal class SdmmcStorageInterfaceAdapter : IStorageSf
{
private IStorage _baseStorage;