mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Name GameCardManager.DeactivateReason enum members
This commit is contained in:
parent
283ecf81ff
commit
de84c72d2a
1 changed files with 32 additions and 22 deletions
|
@ -42,19 +42,21 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
|
|
||||||
private enum DeactivateReason : byte
|
private enum DeactivateReason : byte
|
||||||
{
|
{
|
||||||
Reason0 = 0,
|
None = 0,
|
||||||
Reason1 = 1,
|
Invalidated = 1,
|
||||||
Reason2 = 2,
|
AcquireReadLockInvalidHandle = 2,
|
||||||
Reason3 = 3,
|
CardActivationInvalidInAcquireSecureLock = 3,
|
||||||
Reason4 = 4,
|
GameCardAccessResultFailure = 4,
|
||||||
Reason5 = 5,
|
CardActivationInvalidInGetHandle = 5,
|
||||||
Reason6 = 6,
|
CardActivationInvalidInNormalMode = 6,
|
||||||
Reason7 = 7,
|
SecureToNormalModeTransition = 7,
|
||||||
Reason8 = 8,
|
CardActivationInvalidInSecureMode = 8,
|
||||||
Reason9 = 9,
|
WriteModeTransition = 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Missing: SettingsReadyEvent
|
||||||
private ReaderWriterLock _rwLock;
|
private ReaderWriterLock _rwLock;
|
||||||
|
// Missing: PooledBuffer
|
||||||
private bool _isInitialized;
|
private bool _isInitialized;
|
||||||
private bool _isFinalized;
|
private bool _isFinalized;
|
||||||
private CardState _state;
|
private CardState _state;
|
||||||
|
@ -62,6 +64,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
private GameCardHandle _currentHandle;
|
private GameCardHandle _currentHandle;
|
||||||
private GameCardDetectionEventManager _detectionEventManager;
|
private GameCardDetectionEventManager _detectionEventManager;
|
||||||
private Result _lastDeactivateReasonResult;
|
private Result _lastDeactivateReasonResult;
|
||||||
|
// Missing: Device address space stuff
|
||||||
|
|
||||||
// LibHac additions
|
// LibHac additions
|
||||||
private WeakRef<GameCardManager> _selfReference;
|
private WeakRef<GameCardManager> _selfReference;
|
||||||
|
@ -71,6 +74,13 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
private GameCardManager(IGcApi gc, FileSystemServer fsServer)
|
private GameCardManager(IGcApi gc, FileSystemServer fsServer)
|
||||||
{
|
{
|
||||||
_rwLock = new ReaderWriterLock(fsServer.Hos.Os);
|
_rwLock = new ReaderWriterLock(fsServer.Hos.Os);
|
||||||
|
|
||||||
|
_lastDeactivateReasonResult = Result.Success;
|
||||||
|
_isInitialized = false;
|
||||||
|
_isFinalized = false;
|
||||||
|
_state = CardState.Initial;
|
||||||
|
_lastDeactivateReason = DeactivateReason.None;
|
||||||
|
_currentHandle = 0;
|
||||||
|
|
||||||
_fsServer = fsServer;
|
_fsServer = fsServer;
|
||||||
_gc = gc;
|
_gc = gc;
|
||||||
|
@ -179,7 +189,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
UnsafeHelpers.SkipParamInit(out outNewHandle);
|
UnsafeHelpers.SkipParamInit(out outNewHandle);
|
||||||
|
|
||||||
if (_state == CardState.Normal)
|
if (_state == CardState.Normal)
|
||||||
CheckGameCardAndDeactivate(DeactivateReason.Reason6);
|
CheckGameCardAndDeactivate(DeactivateReason.CardActivationInvalidInNormalMode);
|
||||||
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +210,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
case CardState.Secure:
|
case CardState.Secure:
|
||||||
{
|
{
|
||||||
// Secure -> Initial -> Normal
|
// Secure -> Initial -> Normal
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason7);
|
DeactivateAndChangeState(DeactivateReason.SecureToNormalModeTransition);
|
||||||
|
|
||||||
Result res = ActivateGameCard();
|
Result res = ActivateGameCard();
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
@ -211,7 +221,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
case CardState.Write:
|
case CardState.Write:
|
||||||
{
|
{
|
||||||
// Write -> Initial -> Normal
|
// Write -> Initial -> Normal
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason9);
|
DeactivateAndChangeState(DeactivateReason.WriteModeTransition);
|
||||||
_gc.Writer.ChangeMode(AsicMode.Read);
|
_gc.Writer.ChangeMode(AsicMode.Read);
|
||||||
|
|
||||||
Result res = ActivateGameCard();
|
Result res = ActivateGameCard();
|
||||||
|
@ -234,7 +244,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
UnsafeHelpers.SkipParamInit(out outNewHandle);
|
UnsafeHelpers.SkipParamInit(out outNewHandle);
|
||||||
|
|
||||||
if (_state == CardState.Secure)
|
if (_state == CardState.Secure)
|
||||||
CheckGameCardAndDeactivate(DeactivateReason.Reason8);
|
CheckGameCardAndDeactivate(DeactivateReason.CardActivationInvalidInSecureMode);
|
||||||
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
|
@ -268,7 +278,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
case CardState.Write:
|
case CardState.Write:
|
||||||
{
|
{
|
||||||
// Write -> Initial -> Normal -> Secure
|
// Write -> Initial -> Normal -> Secure
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason9);
|
DeactivateAndChangeState(DeactivateReason.WriteModeTransition);
|
||||||
_gc.Writer.ChangeMode(AsicMode.Read);
|
_gc.Writer.ChangeMode(AsicMode.Read);
|
||||||
|
|
||||||
Result res = ActivateGameCard();
|
Result res = ActivateGameCard();
|
||||||
|
@ -310,7 +320,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
case CardState.Secure:
|
case CardState.Secure:
|
||||||
{
|
{
|
||||||
// Normal/Secure -> Initial -> Write
|
// Normal/Secure -> Initial -> Write
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason9);
|
DeactivateAndChangeState(DeactivateReason.WriteModeTransition);
|
||||||
|
|
||||||
_gc.Writer.ChangeMode(AsicMode.Write);
|
_gc.Writer.ChangeMode(AsicMode.Write);
|
||||||
Result res = ActivateGameCardForWriter();
|
Result res = ActivateGameCardForWriter();
|
||||||
|
@ -640,7 +650,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
|
|
||||||
public Result Invalidate()
|
public Result Invalidate()
|
||||||
{
|
{
|
||||||
InvalidateImpl(DeactivateReason.Reason1);
|
InvalidateImpl(DeactivateReason.Invalidated);
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
@ -1079,7 +1089,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateImpl(DeactivateReason.Reason2);
|
InvalidateImpl(DeactivateReason.AcquireReadLockInvalidHandle);
|
||||||
|
|
||||||
return ResultFs.GameCardFsCheckHandleInAcquireReadLock.Log();
|
return ResultFs.GameCardFsCheckHandleInAcquireReadLock.Log();
|
||||||
}
|
}
|
||||||
|
@ -1097,7 +1107,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
if (_state != CardState.Initial && !_gc.IsCardActivationValid())
|
if (_state != CardState.Initial && !_gc.IsCardActivationValid())
|
||||||
{
|
{
|
||||||
readLock.Unlock();
|
readLock.Unlock();
|
||||||
InvalidateImpl(DeactivateReason.Reason3);
|
InvalidateImpl(DeactivateReason.CardActivationInvalidInAcquireSecureLock);
|
||||||
}
|
}
|
||||||
else if (_currentHandle == inOutHandle)
|
else if (_currentHandle == inOutHandle)
|
||||||
{
|
{
|
||||||
|
@ -1161,7 +1171,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
|
|
||||||
if (result.IsFailure())
|
if (result.IsFailure())
|
||||||
{
|
{
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason4);
|
DeactivateAndChangeState(DeactivateReason.GameCardAccessResultFailure);
|
||||||
_lastDeactivateReasonResult = result;
|
_lastDeactivateReasonResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1184,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
|
|
||||||
if (_state == CardState.Normal || _state == CardState.Secure)
|
if (_state == CardState.Normal || _state == CardState.Secure)
|
||||||
{
|
{
|
||||||
CheckGameCardAndDeactivate(DeactivateReason.Reason5);
|
CheckGameCardAndDeactivate(DeactivateReason.CardActivationInvalidInGetHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
|
@ -1191,7 +1201,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
break;
|
break;
|
||||||
case CardState.Write:
|
case CardState.Write:
|
||||||
{
|
{
|
||||||
DeactivateAndChangeState(DeactivateReason.Reason9);
|
DeactivateAndChangeState(DeactivateReason.WriteModeTransition);
|
||||||
_gc.Writer.ChangeMode(AsicMode.Read);
|
_gc.Writer.ChangeMode(AsicMode.Read);
|
||||||
|
|
||||||
Result res = ActivateGameCard();
|
Result res = ActivateGameCard();
|
||||||
|
|
Loading…
Reference in a new issue