diff --git a/arch/sim/src/up_idle.c b/arch/sim/src/up_idle.c index 0106c29597..cfe4a7d6d0 100644 --- a/arch/sim/src/up_idle.c +++ b/arch/sim/src/up_idle.c @@ -106,15 +106,26 @@ void up_idle(void) sched_process_timer(); #endif - /* Run the network if enabled */ +#if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_SIM_UART_DATAPOST) + /* Handle UART data availability */ + + if (g_uart_data_available) + { + g_uart_data_available = 0; + simuart_post(); + } +#endif + #ifdef CONFIG_NET + /* Run the network if enabled */ + netdriver_loop(); #endif +#ifdef CONFIG_PM /* Fake some power management stuff for testing purposes */ -#ifdef CONFIG_PM { static enum pm_state_e state = PM_NORMAL; enum pm_state_e newstate; @@ -130,11 +141,11 @@ void up_idle(void) } #endif +#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB) /* Wait a bit so that the sched_process_timer() is called close to the * correct rate. */ -#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB) (void)up_hostusleep(1000000 / CLK_TCK); /* Handle X11-related events */ @@ -142,9 +153,9 @@ void up_idle(void) #ifdef CONFIG_SIM_X11FB if (g_x11initialized) { +#ifdef CONFIG_SIM_TOUCHSCREEN /* Drive the X11 event loop */ -#ifdef CONFIG_SIM_TOUCHSCREEN if (g_eventloop) { up_x11events(); diff --git a/arch/sim/src/up_internal.h b/arch/sim/src/up_internal.h index da0c0c2bbe..5cfb715609 100644 --- a/arch/sim/src/up_internal.h +++ b/arch/sim/src/up_internal.h @@ -84,6 +84,10 @@ # undef CONFIG_RAMLOG_SYSLOG #endif +/* The design for how we signal UART data availability is up in the air */ + +#undef CONFIG_SIM_UART_DATAPOST + /* Context Switching Definitions ******************************************/ /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ @@ -144,6 +148,10 @@ extern volatile int g_eventloop; #endif #endif +#if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_SIM_UART_DATAPOST) +extern volatile int g_uart_data_available; +#endif + /************************************************************************** * Public Function Prototypes **************************************************************************/ diff --git a/arch/sim/src/up_simuart.c b/arch/sim/src/up_simuart.c index cd14700d42..ba237fb7e7 100644 --- a/arch/sim/src/up_simuart.c +++ b/arch/sim/src/up_simuart.c @@ -50,6 +50,10 @@ #define SIMUART_BUFSIZE 256 +/* The design for how we signal UART data availability is up in the air */ + +#undef CONFIG_SIM_UART_DATAPOST + /**************************************************************************** * Private Data ****************************************************************************/ @@ -58,6 +62,14 @@ static char g_uartbuffer[SIMUART_BUFSIZE]; static volatile int g_uarthead; static volatile int g_uarttail; +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef CONFIG_SIM_UART_DATAPOST +volatile int g_uart_data_available; +#endif + /**************************************************************************** * NuttX Domain Public Function Prototypes ****************************************************************************/ @@ -115,7 +127,9 @@ static void *simuart_thread(void *arg) if (nread == 1) { +#ifdef CONFIG_SIM_UART_DATAPOST sched_lock(); +#endif /* Get the index to the next slot in the UART buffer */ @@ -146,10 +160,15 @@ static void *simuart_thread(void *arg) * input. */ +#ifdef CONFIG_SIM_UART_DATAPOST simuart_post(); +#else + g_uart_data_available = 1; +#endif } } +#ifdef CONFIG_SIM_UART_DATAPOST /* REVISIT: This is very weird and scary here. When sched_unlock() * is called, we may do a lonjmp() style context switch meaning * that the logic will be run running on this thread! (but with a @@ -159,6 +178,7 @@ static void *simuart_thread(void *arg) */ sched_unlock(); +#endif } }