Skip to content

Commit

Permalink
Rework MonitorReboot (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Oct 20, 2017
1 parent 2de82a0 commit 11e4d60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ public void PrepareForSend(byte[] signature, uint keyIndex)
}
}

public class Monitor_Reboot
public class MonitorReboot
{
public const uint c_NormalReboot = 0;
public const uint c_EnterBootloader = 1;
public const uint c_ClrRebootOnly = 2;
public const uint c_ClrWaitForDbg = 4;
public const uint NormalReboot = 0;
public const uint EnterBootloader = 1;
public const uint ClrRebootOnly = 2;
public const uint ClrWaitForDbg = 4;

public uint m_flags = 0;
public uint flags = 0;
}

public class Monitor_DeploymentMap
Expand Down Expand Up @@ -1572,7 +1572,7 @@ public static object ResolveCommandToPayload(uint cmd, bool fReply, CLRCapabilit
case c_Monitor_EraseMemory: return new Monitor_EraseMemory();
case c_Monitor_Execute: return new Monitor_Execute();
case c_Monitor_MemoryMap: return new Monitor_MemoryMap();
case c_Monitor_Reboot: return new Monitor_Reboot();
case c_Monitor_Reboot: return new MonitorReboot();
case c_Monitor_DeploymentMap: return new Monitor_DeploymentMap();
case c_Monitor_FlashSectorMap: return new Monitor_FlashSectorMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,25 +665,28 @@ public async Task<bool> ExecuteMemoryAsync(uint address)

public async Task RebootDeviceAsync(RebootOption option = RebootOption.NormalReboot)
{
Commands.Monitor_Reboot cmd = new Commands.Monitor_Reboot();
Commands.MonitorReboot cmd = new Commands.MonitorReboot();

bool fThrowOnCommunicationFailureSav = m_fThrowOnCommunicationFailure;
bool disconnectRequired = false;

m_fThrowOnCommunicationFailure = false;

switch (option)
{
case RebootOption.EnterBootloader:
cmd.m_flags = Commands.Monitor_Reboot.c_EnterBootloader;
cmd.flags = Commands.MonitorReboot.EnterBootloader;
disconnectRequired = true;
break;
case RebootOption.RebootClrOnly:
cmd.m_flags = Capabilities.SoftReboot ? Commands.Monitor_Reboot.c_ClrRebootOnly : Commands.Monitor_Reboot.c_NormalReboot;
cmd.flags = Capabilities.SoftReboot ? Commands.MonitorReboot.ClrRebootOnly : Commands.MonitorReboot.NormalReboot;
break;
case RebootOption.RebootClrWaitForDebugger:
cmd.m_flags = Capabilities.SoftReboot ? Commands.Monitor_Reboot.c_ClrWaitForDbg : Commands.Monitor_Reboot.c_NormalReboot;
cmd.flags = Capabilities.SoftReboot ? Commands.MonitorReboot.ClrWaitForDbg : Commands.MonitorReboot.NormalReboot;
break;
default:
cmd.m_flags = Commands.Monitor_Reboot.c_NormalReboot;
cmd.flags = Commands.MonitorReboot.NormalReboot;
disconnectRequired = true;
break;
}

Expand All @@ -693,8 +696,8 @@ public async Task RebootDeviceAsync(RebootOption option = RebootOption.NormalReb

await PerformRequestAsync(Commands.c_Monitor_Reboot, Flags.c_NoCaching, cmd, 0, 100);

// need to disconnect from the device if this is normal reboot
if ((cmd.m_flags & Commands.Monitor_Reboot.c_NormalReboot) == Commands.Monitor_Reboot.c_NormalReboot)
// need to disconnect from the device?
if (disconnectRequired)
{
Device.Disconnect();
}
Expand Down

0 comments on commit 11e4d60

Please sign in to comment.