Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move events from CLR_RT_ExecutionEngine to a separate enum #1714

Merged
merged 6 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 155 additions & 132 deletions src/CLR/CorLib/corlib_native_System_AppDomain.cpp

Large diffs are not rendered by default.

2,362 changes: 1,267 additions & 1,095 deletions src/CLR/Core/Execution.cpp

Large diffs are not rendered by default.

88 changes: 45 additions & 43 deletions src/CLR/Core/Hardware/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ HRESULT CLR_HW_Hardware::Hardware_Initialize()

NANOCLR_HEADER();

if(m_fInitialized == false)
if (m_fInitialized == false)
{
Time_Initialize();

m_interruptData.m_HalQueue.Initialize( (CLR_HW_Hardware::HalInterruptRecord*)&g_scratchInterruptDispatchingStorage, InterruptRecords() );
m_interruptData.m_HalQueue.Initialize(
(CLR_HW_Hardware::HalInterruptRecord *)&g_scratchInterruptDispatchingStorage,
InterruptRecords());

m_interruptData.m_applicationQueue.DblLinkedList_Initialize ();
m_interruptData.m_applicationQueue.DblLinkedList_Initialize();

m_interruptData.m_queuedInterrupts = 0;

m_DebuggerEventsMask = 0;
m_DebuggerEventsMask = 0;

#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
m_DebuggerEventsMask |= ExtractEventFromTransport( HalSystemConfig.DebuggerPort );
m_DebuggerEventsMask |= ExtractEventFromTransport(HalSystemConfig.DebuggerPort);
#endif

m_wakeupEvents = c_Default_WakeupEvents | m_DebuggerEventsMask;
m_powerLevel = PowerLevel__Active;
m_powerLevel = PowerLevel__Active;

m_fInitialized = true;
}

Expand All @@ -68,7 +70,7 @@ void CLR_HW_Hardware::Hardware_Cleanup()
{
NATIVE_PROFILE_CLR_HARDWARE();

if(m_fInitialized == true)
if (m_fInitialized == true)
{
m_fInitialized = false;
}
Expand All @@ -85,96 +87,96 @@ void CLR_HW_Hardware::ProcessActivity()
{
NATIVE_PROFILE_CLR_HARDWARE();

for(int i=0; i<10; i++)
for (int i = 0; i < 10; i++)
{
if(!HAL_CONTINUATION::Dequeue_And_Execute()) break;
if (!HAL_CONTINUATION::Dequeue_And_Execute())
break;
}

// UNDONE: FIXME:
//if(!msg.IsDebuggerInitialized())
// UNDONE: FIXME:
// if(!msg.IsDebuggerInitialized())
//{
// msg.InitializeDebugger();
//}
// UNDONE: FIXME:msg.PurgeCache();
// UNDONE: FIXME:dbg.PurgeCache();
// UNDONE: FIXME:msg.PurgeCache();

// UNDONE: FIXME:dbg.PurgeCache();

uint32_t events = ::Events_Get( m_wakeupEvents );
uint32_t events = ::Events_Get(m_wakeupEvents);
uint32_t eventsCLR = 0;

if(events & m_DebuggerEventsMask)
if (events & m_DebuggerEventsMask)
{
//dbg.ProcessCommands();
// dbg.ProcessCommands();

#if defined(PLATFORM_ARM) || defined(PLATFORM_ESP32)
if(CLR_EE_DBG_IS(RebootPending))
if (CLR_EE_DBG_IS(RebootPending))
{
#if !defined(BUILD_RTM)
CLR_Debug::Printf( "Rebooting...\r\n" );
CLR_Debug::Printf("Rebooting...\r\n");
#endif

if(!CLR_EE_REBOOT_IS(ClrOnly))
if (!CLR_EE_REBOOT_IS(ClrOnly))
{
CLR_RT_ExecutionEngine::Reboot( false );
CLR_RT_ExecutionEngine::Reboot(false);
}
}
#endif
}

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

if(events & SYSTEM_EVENT_FLAG_COM_OUT)
if (events & SYSTEM_EVENT_FLAG_COM_OUT)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_SerialPortOut;
eventsCLR |= Event_SerialPortOut;
}

if((events & SYSTEM_EVENT_HW_INTERRUPT)
if ((events & SYSTEM_EVENT_HW_INTERRUPT)
#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
|| (!CLR_EE_DBG_IS(Stopped) && !g_CLR_HW_Hardware.m_interruptData.m_applicationQueue.IsEmpty())
#endif //#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
)
)
{
ProcessInterrupts();
}

if(events & SYSTEM_EVENT_FLAG_SOCKET)
if (events & SYSTEM_EVENT_FLAG_SOCKET)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_Socket;
eventsCLR |= Event_Socket;
}

if(events & SYSTEM_EVENT_FLAG_SPI_MASTER)
if (events & SYSTEM_EVENT_FLAG_SPI_MASTER)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_SpiMaster;
eventsCLR |= Event_SpiMaster;
}

if(events & SYSTEM_EVENT_FLAG_I2C_MASTER)
if (events & SYSTEM_EVENT_FLAG_I2C_MASTER)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_I2cMaster;
eventsCLR |= Event_I2cMaster;
}

if(events & SYSTEM_EVENT_FLAG_ONEWIRE_MASTER)
if (events & SYSTEM_EVENT_FLAG_ONEWIRE_MASTER)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_OneWireMaster;
eventsCLR |= Event_OneWireMaster;
}

if(events & SYSTEM_EVENT_FLAG_STORAGE_IO)
if (events & SYSTEM_EVENT_FLAG_STORAGE_IO)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_StorageIo;
eventsCLR |= Event_StorageIo;
}

if(events & SYSTEM_EVENT_FLAG_RADIO)
if (events & SYSTEM_EVENT_FLAG_RADIO)
{
eventsCLR |= CLR_RT_ExecutionEngine::c_Event_Radio;
eventsCLR |= Event_Radio;
}

if(eventsCLR)
if (eventsCLR)
{
g_CLR_RT_ExecutionEngine.SignalEvents( eventsCLR );
g_CLR_RT_ExecutionEngine.SignalEvents(eventsCLR);
}
}

//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//--//

28 changes: 15 additions & 13 deletions src/CLR/Include/nanoCLR_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -3351,22 +3351,24 @@ extern bool g_CLR_RT_fBadStack;
#endif

//--//
typedef enum Events
{
Event_SerialPortIn = 0x00000002,
Event_SerialPortOut = 0x00000004,
Event_EndPoint = 0x00000008,
Event_StorageIo = 0x00000020,
Event_I2cMaster = 0x00000080,
Event_SpiMaster = 0x00000100,
Event_OneWireMaster = 0x00000200,
Event_Radio = 0x00000400,
Event_AppDomain = 0x02000000,
Event_Socket = 0x20000000,
Event_IdleCPU = 0x40000000,
Event_LowMemory = 0x80000000,
} Events;

struct CLR_RT_ExecutionEngine
{
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_StorageIo = 0x00000020;
static const CLR_UINT32 c_Event_I2cMaster = 0x00000080;
static const CLR_UINT32 c_Event_SpiMaster = 0x00000100;
static const CLR_UINT32 c_Event_OneWireMaster = 0x00000200;
static const CLR_UINT32 c_Event_Radio = 0x00000400;
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_Compile_CPP = 0x00000001;
Expand Down
Loading