Simulation: Change how simulated UART data availability is signaled. The last change is not safe (but I don't like this workaround either -- maybe something better will come to me).

This commit is contained in:
Gregory Nutt 2014-10-01 14:59:51 -06:00
parent df5e768675
commit 2a3b6ddc10
3 changed files with 43 additions and 4 deletions

View File

@ -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();

View File

@ -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
**************************************************************************/

View File

@ -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
}
}