private StateSaveAndReload ( bool startupState, bool doPowerCycle ) : void | ||
startupState | bool | |
doPowerCycle | bool | |
Результат | void |
private void StateSaveAndReload(bool startupState, bool doPowerCycle)
{
CheckConsistency();
ContextSaveEverything();
CheckConsistency();
// Record TPM state so that we can check it's the same through shutdown.
// The exception is entities that are marked volatileLoad which are destroyed on S4.
TpmHandle[] startHandles = GetAllLoadedEntities(Tpm);
Tpm.Shutdown(Su.State);
// Optionally cycle the power (if the power is not cycled the TPM should be able to carry on as if nothing had happened.
string stateTransition = "none";
if (doPowerCycle)
{
TpmDevice.PowerCycle();
// Re-init through simulated S3 and S4 alternately
// ReSharper disable once RedundantAssignment
stateTransition = "";
if (startupState)
{
stateTransition = "S3";
Tpm.Startup(Su.State);
}
else
{
stateTransition = "S4";
Tpm.Startup(Su.Clear);
}
}
// Check everything is the same
TpmHandle[] endHandles = GetAllLoadedEntities(Tpm);
bool match = true;
if (startHandles.Length == endHandles.Length)
{
for (int j = 0; j < startHandles.Length; j++)
{
if (startHandles[j].handle != endHandles[j].handle)
{
match = false;
}
}
}
else
{
match = false;
}
if (!match)
{
string message = "Handle set did not survive " + stateTransition;
throw new Exception(message);
}
}