Skeleton the sdmmc api

This commit is contained in:
Alex Barney 2022-06-28 19:59:45 -07:00
parent 56765598a7
commit e76166d6d0
8 changed files with 352 additions and 34 deletions

1
src/LibHac/Fs/Sdmmc.cs Normal file
View file

@ -0,0 +1 @@
global using SdmmcHandle = System.UInt32;

View file

@ -10,6 +10,7 @@ using LibHac.Gc;
using LibHac.Sdmmc;
using LibHac.Sf;
using LibHac.Util;
using MmcPartition = LibHac.Fs.MmcPartition;
namespace LibHac.FsSrv.Impl;

View file

@ -8,6 +8,7 @@ using LibHac.Sdmmc;
using LibHac.SdmmcSrv;
using LibHac.Sf;
using IStorageSf = LibHac.FsSrv.Sf.IStorage;
using MmcPartition = LibHac.Fs.MmcPartition;
namespace LibHac.FsSrv.Storage;

152
src/LibHac/Sdmmc/Common.cs Normal file
View file

@ -0,0 +1,152 @@
using System;
namespace LibHac.Sdmmc;
public enum BusPower
{
// ReSharper disable InconsistentNaming
PowerOff = 0,
Power1_8V = 1,
Power3_3V = 2,
// ReSharper restore InconsistentNaming
}
public enum BusWidth
{
Width1Bit = 0,
Width4Bit = 1,
Width8Bit = 2,
}
public enum SpeedMode
{
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 Port
{
Mmc0 = 0,
SdCard0 = 1,
GcAsic0 = 2
}
public struct ErrorInfo
{
public uint NumActivationFailures;
public uint NumActivationErrorCorrections;
public uint NumReadWriteFailures;
public uint NumReadWriteErrorCorrections;
}
public delegate void DeviceDetectionEventCallback(object args);
public partial class SdmmcApi
{
public const int SectorSize = 0x200;
public const int DeviceCidSize = 0x10;
public const int DeviceCsdSize = 0x10;
public void SwitchToPcvClockResetControl()
{
throw new NotImplementedException();
}
public void Initialize(Port port)
{
throw new NotImplementedException();
}
public void Finalize(Port port)
{
throw new NotImplementedException();
}
public void ChangeCheckTransferInterval(Port port, uint ms)
{
throw new NotImplementedException();
}
public void SetDefaultCheckTransferInterval(Port port)
{
throw new NotImplementedException();
}
public Result Activate(Port port)
{
throw new NotImplementedException();
}
public void Deactivate(Port port)
{
throw new NotImplementedException();
}
public Result Read(Span<byte> destination, Port port, uint sectorIndex, uint sectorCount)
{
throw new NotImplementedException();
}
public Result Write(Port port, uint sectorIndex, uint sectorCount, ReadOnlySpan<byte> source)
{
throw new NotImplementedException();
}
public Result CheckConnection(out SpeedMode outSpeedMode, out BusWidth outBusWidth, Port port)
{
throw new NotImplementedException();
}
public Result GetDeviceSpeedMode(out SpeedMode outSpeedMode, Port port)
{
throw new NotImplementedException();
}
public Result GetDeviceMemoryCapacity(out uint outNumSectors, Port port)
{
throw new NotImplementedException();
}
public Result GetDeviceStatus(out uint outDeviceStatus, Port port)
{
throw new NotImplementedException();
}
public Result GetDeviceCid(Span<byte> outBuffer, Port port)
{
throw new NotImplementedException();
}
public Result GetDeviceCsd(Span<byte> outBuffer, Port port)
{
throw new NotImplementedException();
}
public void GetAndClearErrorInfo(out ErrorInfo outErrorInfo, out int outLogSize, Span<byte> outLogBuffer, Port port)
{
throw new NotImplementedException();
}
public void RegisterDeviceVirtualAddress(Port port, Memory<byte> buffer, ulong bufferDeviceVirtualAddress)
{
throw new NotImplementedException();
}
public void UnregisterDeviceVirtualAddress(Port port, Memory<byte> buffer, ulong bufferDeviceVirtualAddress)
{
throw new NotImplementedException();
}
}

View file

@ -0,0 +1,53 @@
using System;
namespace LibHac.Sdmmc;
public partial class SdmmcApi
{
public const int GcAsicOperationSize = 0x40;
public void PutGcAsicToSleep(Port port)
{
throw new NotImplementedException();
}
public Result AwakenGcAsic(Port port)
{
throw new NotImplementedException();
}
public Result WriteGcAsicOperation(Port port, ReadOnlySpan<byte> operationBuffer)
{
throw new NotImplementedException();
}
public Result FinishGcAsicOperation(Port port)
{
throw new NotImplementedException();
}
public Result AbortGcAsicOperation(Port port)
{
throw new NotImplementedException();
}
public Result SleepGcAsic(Port port)
{
throw new NotImplementedException();
}
public Result UpdateGcAsicKey(Port port)
{
throw new NotImplementedException();
}
public void SignalGcRemovedEvent(Port port)
{
throw new NotImplementedException();
}
public void ClearGcRemovedEvent(Port port)
{
throw new NotImplementedException();
}
}

57
src/LibHac/Sdmmc/Mmc.cs Normal file
View file

@ -0,0 +1,57 @@
using System;
namespace LibHac.Sdmmc;
public enum MmcPartition
{
UserData = 0,
BootPartition1 = 1,
BootPartition2 = 2,
Unknown = 3
}
public partial class SdmmcApi
{
public const int MmcExtendedCsdSize = 0x200;
public const int MmcWorkBufferSize = MmcExtendedCsdSize;
public void SetMmcWorkBuffer(Port port, Memory<byte> workBuffer)
{
throw new NotImplementedException();
}
public void PutMmcToSleep(Port port)
{
throw new NotImplementedException();
}
public void AwakenMmc(Port port)
{
throw new NotImplementedException();
}
public Result SelectMmcPartition(Port port, MmcPartition mmcPartition)
{
throw new NotImplementedException();
}
public Result EraseMmc(Port port)
{
throw new NotImplementedException();
}
public Result GetMmcBootPartitionCapacity(out uint outNumSectors, Port port)
{
throw new NotImplementedException();
}
public Result GetMmcExtendedCsd(Span<byte> outBuffer, Port port)
{
throw new NotImplementedException();
}
public Result CheckMmcConnection(out SpeedMode outSpeedMode, out BusWidth outBusWidth, Port port)
{
throw new NotImplementedException();
}
}

View file

@ -0,0 +1,87 @@
using System;
namespace LibHac.Sdmmc;
public enum SdCardSwitchFunction
{
CheckSupportedFunction = 0,
CheckDefault = 1,
CheckHighSpeed = 2,
CheckSdr50 = 3,
CheckSdr104 = 4,
CheckDdr50 = 5
};
public partial class SdmmcApi
{
public const int SdCardScrSize = 8;
public const int SdCardSwitchFunctionStatusSize = 0x40;
public const int SdCardSdStatusSize = 0x40;
public const int SdCardWorkBufferSize = SdCardSdStatusSize;
public void SetSdCardWorkBuffer(Port port, Memory<byte> workBuffer)
{
throw new NotImplementedException();
}
public void PutSdCardToSleep(Port port)
{
throw new NotImplementedException();
}
public void AwakenSdCard(Port port)
{
throw new NotImplementedException();
}
public Result GetSdCardProtectedAreaCapacity(out uint outNumSectors, Port port)
{
throw new NotImplementedException();
}
public Result GetSdCardScr(Span<byte> outBuffer, Port port)
{
throw new NotImplementedException();
}
public Result GetSdCardSwitchFunctionStatus(Span<byte> outBuffer, Port port, SdCardSwitchFunction switchFunction)
{
throw new NotImplementedException();
}
public Result GetSdCardCurrentConsumption(out ushort outCurrentConsumption, Port port, SpeedMode speedMode)
{
throw new NotImplementedException();
}
public Result GetSdCardSdStatus(Span<byte> outBuffer, Port port)
{
throw new NotImplementedException();
}
public Result CheckSdCardConnection(out SpeedMode outSpeedMode, out BusWidth outBusWidth, Port port)
{
throw new NotImplementedException();
}
public void RegisterSdCardDetectionEventCallback(Port port, DeviceDetectionEventCallback callback, object args)
{
throw new NotImplementedException();
}
public void UnregisterSdCardDetectionEventCallback(Port port)
{
throw new NotImplementedException();
}
public bool IsSdCardInserted(Port port)
{
throw new NotImplementedException();
}
public bool IsSdCardRemoved(Port port)
{
throw new NotImplementedException();
}
}

View file

@ -1,34 +0,0 @@
namespace LibHac.Sdmmc;
public enum BusWidth
{
Width1Bit = 0,
Width4Bit = 1,
Width8Bit = 2,
}
public enum SpeedMode
{
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 Port
{
Mmc0 = 0,
SdCard0 = 1,
GcAsic0 = 2
}