Skip to content

Commit

Permalink
Work on CLR events (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jan 16, 2018
1 parent 79e4947 commit 89894ac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/CLR/CorLib/corlib_native_System_AppDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ HRESULT Library_corlib_native_System_AppDomain::Unload___STATIC__VOID__SystemApp

NANOCLR_CHECK_HRESULT(GetAppDomain( stack.ThisRef(), appDomain, appDomainSav, false ));

hbTimeout.SetInteger( 5 * 1000 );
hbTimeout.SetInteger( 5 * 1000 * TIME_CONVERSION__TO_MILLISECONDS);

if(stack.m_customState == 0)
{
//Attempt to unload the AppDomain only once
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.UnloadAppDomain( appDomain, stack.m_owningThread ));
}

NANOCLR_CHECK_HRESULT(stack.SetupTimeout( hbTimeout, timeout ));
NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks( hbTimeout, timeout ));

fRes = true;
while(fRes)
Expand Down
5 changes: 3 additions & 2 deletions src/CLR/Core/CLR_RT_StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,8 @@ void CLR_RT_StackFrame::NegateResult()

//--//

HRESULT CLR_RT_StackFrame::SetupTimeout( CLR_RT_HeapBlock& input, CLR_INT64*& output )
// input HeapBlock has timeout value in ticks
HRESULT CLR_RT_StackFrame::SetupTimeoutFromTicks( CLR_RT_HeapBlock& input, CLR_INT64*& output )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();
Expand All @@ -1125,7 +1126,7 @@ HRESULT CLR_RT_StackFrame::SetupTimeout( CLR_RT_HeapBlock& input, CLR_INT64*& ou
//
// Initialize timeout and save it on the stack.
//
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitTimeout( timeExpire, input.NumericByRef().s4 ));
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitTimeout( timeExpire, input.NumericByRef().s8 ));

ref.SetInteger( timeExpire );

Expand Down
20 changes: 10 additions & 10 deletions src/CLR/Core/Hardware/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ void CLR_HW_Hardware::ProcessActivity()
#endif
}

if( events & (SYSTEM_EVENT_FLAG_COM_IN | SYSTEM_EVENT_FLAG_COM_OUT) )
if(events & SYSTEM_EVENT_FLAG_COM_IN)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_SerialPort;
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_SerialPortIn;
}

// UNDONE: FIXME: if(events & SYSTEM_EVENT_I2C_XACTION)
//{
// eventsCLR |= CLR_RT_ExecutionEngine::c_Event_I2C;
//}
if(events & SYSTEM_EVENT_FLAG_COM_OUT)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_SerialPortOut;
}

if((events & SYSTEM_EVENT_HW_INTERRUPT)
#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
Expand All @@ -148,10 +148,10 @@ void CLR_HW_Hardware::ProcessActivity()
ProcessInterrupts();
}

if(events & SYSTEM_EVENT_FLAG_SOCKET)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_Socket;
}
// UNDONE: FIXME: if(events & SYSTEM_EVENT_FLAG_SOCKET)
// {
// eventsCLR |= CLR_RT_ExecutionEngine::c_Event_Socket;
// }

if(events & SYSTEM_EVENT_FLAG_IO)
{
Expand Down
20 changes: 8 additions & 12 deletions src/CLR/Include/nanoCLR_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ struct CLR_RT_StackFrame : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOC
void SetResult_Object ( CLR_RT_HeapBlock* val );
HRESULT SetResult_String ( const char* val );

HRESULT SetupTimeout( CLR_RT_HeapBlock& input, CLR_INT64*& output );
HRESULT SetupTimeoutFromTicks( CLR_RT_HeapBlock& input, CLR_INT64*& output );

void ConvertResultToBoolean();
void NegateResult ();
Expand Down Expand Up @@ -2728,17 +2728,13 @@ extern bool g_CLR_RT_fBadStack;

struct CLR_RT_ExecutionEngine
{
static const CLR_UINT32 c_Event_SerialPort = 0x00000002;
static const CLR_UINT32 c_Event_Battery = 0x00000008;
static const CLR_UINT32 c_Event_AirPressure = 0x00000010;
static const CLR_UINT32 c_Event_HeartRate = 0x00000020;
static const CLR_UINT32 c_Event_I2C = 0x00000040;
static const CLR_UINT32 c_Event_IO = 0x00000080;
static const CLR_UINT32 c_Event_EndPoint = 0x01000000;
static const CLR_UINT32 c_Event_AppDomain = 0x02000000;
static const CLR_UINT32 c_Event_Socket = 0x20000000;
static const CLR_UINT32 c_Event_IdleCPU = 0x40000000;
static const CLR_UINT32 c_Event_LowMemory = 0x80000000; // Wait for a low-memory condition.
static const CLR_UINT32 c_Event_SerialPortIn = 0x00000002;
static const CLR_UINT32 c_Event_SerialPortOut = 0x00000004;
static const CLR_UINT32 c_Event_EndPoint = 0x00000008;
static const CLR_UINT32 c_Event_IO = 0x00000080;
static const CLR_UINT32 c_Event_AppDomain = 0x02000000;
static const CLR_UINT32 c_Event_IdleCPU = 0x40000000;
static const CLR_UINT32 c_Event_LowMemory = 0x80000000; // Wait for a low-memory condition.


////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 89894ac

Please sign in to comment.