Skip to content

Commit d163a7b

Browse files
committed
Update Runtime.Native
- Add implementation for RebootDevice overload with parameter for reboot option. - Update native.runtime assembly declaration. - Change declaration of ExecutionEngine::Reboot to accept reboot option instead of just hard reset parameter. - Update implementation of ExecutionEngine::Reboot to deal with reboot option.
1 parent c224f7d commit d163a7b

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

src/CLR/Core/Execution.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,25 @@ HRESULT CLR_RT_ExecutionEngine::StartHardware()
294294
NANOCLR_NOCLEANUP();
295295
}
296296

297-
void CLR_RT_ExecutionEngine::Reboot(bool fHard)
297+
void CLR_RT_ExecutionEngine::Reboot(uint16_t rebootOptions)
298298
{
299299
NATIVE_PROFILE_CLR_CORE();
300300

301-
if (fHard)
301+
if (CLR_DBG_Commands::Monitor_Reboot::c_EnterNanoBooter ==
302+
(rebootOptions & CLR_DBG_Commands::Monitor_Reboot::c_EnterNanoBooter))
302303
{
303-
::CPU_Reset();
304+
RequestToLaunchNanoBooter(0);
304305
}
305-
else
306+
else if (
307+
CLR_DBG_Commands::Monitor_Reboot::c_EnterProprietaryBooter ==
308+
(rebootOptions & CLR_DBG_Commands::Monitor_Reboot::c_EnterProprietaryBooter))
306309
{
307-
CLR_EE_REBOOT_CLR;
308-
CLR_EE_DBG_SET(RebootPending);
310+
RequestToLaunchProprietaryBootloader();
309311
}
312+
313+
// apply reboot options and set reboot pending flag
314+
g_CLR_RT_ExecutionEngine.m_iReboot_Options = rebootOptions;
315+
CLR_EE_DBG_SET(RebootPending);
310316
}
311317

312318
CLR_INT64 CLR_RT_ExecutionEngine::GetUptime()

src/CLR/Include/nanoCLR_Debugging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct CLR_DBG_Commands
5252

5353
/////////////////////////////////////////////////////////////////////////////////////////////////////////
5454
// !!! KEEP IN SYNC WITH nanoFramework.Tools.Debugger.WireProtocol.RebootOptions (in managed code) !!! //
55+
// !!! KEEP IN SYNC WITH nanoFramework.Runtime.Native.WireProtocol.RebootOption (in managed code) !!! //
5556
// CONSTANTS VALUES NEED TO BE 'FLAG' TYPE //
5657
/////////////////////////////////////////////////////////////////////////////////////////////////////////
5758
struct Monitor_Reboot

src/CLR/Include/nanoCLR_Runtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3688,7 +3688,7 @@ struct CLR_RT_ExecutionEngine
36883688

36893689
HRESULT StartHardware();
36903690

3691-
static void Reboot(bool fHard);
3691+
static void Reboot(uint16_t rebootOptions);
36923692

36933693
void JoinAllThreadsAndExecuteFinalizer();
36943694

src/nanoFramework.Runtime.Native/nf_rt_native.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
1919
NULL,
2020
NULL,
2121
NULL,
22-
Library_nf_rt_native_nanoFramework_Runtime_Native_Power::NativeReboot___STATIC__VOID,
22+
Library_nf_rt_native_nanoFramework_Runtime_Native_Power::NativeReboot___STATIC__VOID__nanoFrameworkRuntimeNativeRebootOption,
2323
NULL,
2424
NULL,
2525
NULL,
@@ -42,9 +42,9 @@ static const CLR_RT_MethodHandler method_lookup[] =
4242
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Runtime_Native =
4343
{
4444
"nanoFramework.Runtime.Native",
45-
0x109F6F22,
45+
0x0EAE898B,
4646
method_lookup,
47-
{ 100, 0, 9, 0 }
47+
{ 100, 0, 10, 0 }
4848
};
4949

5050
// clang-format on

src/nanoFramework.Runtime.Native/nf_rt_native.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
#include <nanoCLR_Interop.h>
1111
#include <nanoCLR_Runtime.h>
1212

13+
typedef enum __nfpack RebootOption
14+
{
15+
RebootOption_NormalReboot = 0,
16+
RebootOption_EnterNanoBooter = 1,
17+
RebootOption_ClrOnly = 2,
18+
RebootOption_EnterProprietaryBooter = 8,
19+
} RebootOption;
20+
1321
typedef enum __nfpack SystemInfo_FloatingPoint
1422
{
1523
SystemInfo_FloatingPoint_None = 0,
@@ -38,7 +46,7 @@ struct Library_nf_rt_native_nanoFramework_Runtime_Native_Power
3846
{
3947
static const int FIELD_STATIC__OnRebootEvent = 0;
4048

41-
NANOCLR_NATIVE_DECLARE(NativeReboot___STATIC__VOID);
49+
NANOCLR_NATIVE_DECLARE(NativeReboot___STATIC__VOID__nanoFrameworkRuntimeNativeRebootOption);
4250

4351
//--//
4452
};

src/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_Power.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6-
76
#include "nf_rt_native.h"
7+
#include <nanoCLR_Debugging.h>
88

9-
HRESULT Library_nf_rt_native_nanoFramework_Runtime_Native_Power::NativeReboot___STATIC__VOID( CLR_RT_StackFrame& stack )
9+
HRESULT Library_nf_rt_native_nanoFramework_Runtime_Native_Power::
10+
NativeReboot___STATIC__VOID__nanoFrameworkRuntimeNativeRebootOption(CLR_RT_StackFrame &stack)
1011
{
11-
(void)stack;
12-
1312
NANOCLR_HEADER();
14-
{
15-
g_CLR_RT_ExecutionEngine.Reboot(true);
16-
}
13+
14+
RebootOption rebootOption = (RebootOption)stack.Arg0().NumericByRef().u4;
15+
16+
g_CLR_RT_ExecutionEngine.Reboot(rebootOption);
17+
1718
NANOCLR_NOCLEANUP_NOLABEL();
1819
}

0 commit comments

Comments
 (0)