diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 2514861de4..addd262955 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -44,9 +44,9 @@ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c CSRCS += up_createstack.c up_usestack.c up_releasestack.c up_stackframe.c CSRCS += up_unblocktask.c up_blocktask.c up_releasepending.c CSRCS += up_reprioritizertr.c up_exit.c up_schedulesigaction.c up_spiflash.c -CSRCS += up_allocateheap.c up_devconsole.c +CSRCS += up_allocateheap.c up_devconsole.c up_uartwait.c -HOSTSRCS = up_stdio.c up_hostusleep.c +HOSTSRCS = up_stdio.c up_hostusleep.c up_simuart.c ifeq ($(CONFIG_SCHED_TICKLESS),y) CSRCS += up_tickless.c diff --git a/arch/sim/src/up_internal.h b/arch/sim/src/sim.h similarity index 91% rename from arch/sim/src/up_internal.h rename to arch/sim/src/sim.h index 5e62a6d051..33e170ffab 100644 --- a/arch/sim/src/up_internal.h +++ b/arch/sim/src/sim.h @@ -1,5 +1,5 @@ /************************************************************************** - * up_internal.h + * sim.h * * Copyright (C) 2007, 2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * **************************************************************************/ -#ifndef __ARCH_UP_INTERNAL_H -#define __ARCH_UP_INTERNAL_H +#ifndef __ARCH_SIM_SRC_SIM_H +#define __ARCH_SIM_SRC_SIM_H /************************************************************************** * Included Files @@ -77,6 +77,12 @@ # endif #endif +/* Simulated console UART input buffer size */ + +#ifndef CONFIG_SIM_UART_BUFSIZE +# define CONFIG_SIM_UART_BUFSIZE 256 +#endif + /* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG @@ -144,6 +150,12 @@ extern volatile int g_eventloop; #endif #endif +/* up_simuart.c ***********************************************************/ + +extern char g_uartbuffer[CONFIG_SIM_UART_BUFSIZE]; +extern volatile int g_uarthead; +extern volatile int g_uarttail; + /************************************************************************** * Public Function Prototypes **************************************************************************/ @@ -164,6 +176,16 @@ void up_timer_update(void); void up_devconsole(void); void up_registerblockdevice(void); +/* up_simuart.c ***********************************************************/ + +void *up_simuart(void *arg); + +/* up_uartwait.c **********************************************************/ + +void uart_wait_initialize(void); +void up_simuart_post(void); +void up_simuart_wait(void); + /* up_deviceimage.c *******************************************************/ char *up_deviceimage(void); @@ -241,4 +263,4 @@ struct spi_dev_s *up_spiflashinitialize(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __ARCH_UP_INTERNAL_H */ +#endif /* __ARCH_SIM_SRC_SIM_H */ diff --git a/arch/sim/src/up_allocateheap.c b/arch/sim/src/up_allocateheap.c index da6511c65e..e6641805e6 100644 --- a/arch/sim/src/up_allocateheap.c +++ b/arch/sim/src/up_allocateheap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_allocateheap.c + * arch/sim/src/up_allocateheap.c * * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -46,10 +46,10 @@ #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_blockdevice.c b/arch/sim/src/up_blockdevice.c index abfda4a6ab..41a66b7e2f 100644 --- a/arch/sim/src/up_blockdevice.c +++ b/arch/sim/src/up_blockdevice.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_blockdevice.c + * arch/sim/src/up_blockdevice.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -46,10 +46,10 @@ #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #define NSECTORS 2048 diff --git a/arch/sim/src/up_blocktask.c b/arch/sim/src/up_blocktask.c index ef1e940f04..b708fd80d2 100644 --- a/arch/sim/src/up_blocktask.c +++ b/arch/sim/src/up_blocktask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_blocktask.c + * arch/sim/src/up_blocktask.c * * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -46,10 +46,10 @@ #include #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_createstack.c b/arch/sim/src/up_createstack.c index 0587ae05e1..9fbe1bc49e 100644 --- a/arch/sim/src/up_createstack.c +++ b/arch/sim/src/up_createstack.c @@ -45,10 +45,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_devconsole.c b/arch/sim/src/up_devconsole.c index 07c4267191..7e65a26a37 100644 --- a/arch/sim/src/up_devconsole.c +++ b/arch/sim/src/up_devconsole.c @@ -44,10 +44,10 @@ #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_deviceimage.c b/arch/sim/src/up_deviceimage.c index 6c541c3e12..4dfe726ffc 100644 --- a/arch/sim/src/up_deviceimage.c +++ b/arch/sim/src/up_deviceimage.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_deviceimage.c + * arch/sim/src/up_deviceimage.c * * Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -50,11 +50,11 @@ # include -# include "up_internal.h" +# include "sim.h" #endif /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #ifdef VFAT_STANDALONE diff --git a/arch/sim/src/up_exit.c b/arch/sim/src/up_exit.c index 332d1ff61d..7b6161da7e 100644 --- a/arch/sim/src/up_exit.c +++ b/arch/sim/src/up_exit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_exit.c + * arch/sim/src/up_exit.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -46,10 +46,10 @@ #include "task/task.h" #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_framebuffer.c b/arch/sim/src/up_framebuffer.c index e20dd92e38..86b4b65d74 100644 --- a/arch/sim/src/up_framebuffer.c +++ b/arch/sim/src/up_framebuffer.c @@ -45,10 +45,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_SIM_FBWIDTH diff --git a/arch/sim/src/up_head.c b/arch/sim/src/up_head.c index 00018865f1..1289361836 100644 --- a/arch/sim/src/up_head.c +++ b/arch/sim/src/up_head.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_head.c + * arch/sim/src/up_head.c * * Copyright (C) 2007-2009, 2011-2113 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/sim/src/up_hostusleep.c b/arch/sim/src/up_hostusleep.c index df65d7be5c..49baa84ba1 100644 --- a/arch/sim/src/up_hostusleep.c +++ b/arch/sim/src/up_hostusleep.c @@ -40,7 +40,7 @@ #include /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_idle.c b/arch/sim/src/up_idle.c index 783b57eeab..eaea6d7fe2 100644 --- a/arch/sim/src/up_idle.c +++ b/arch/sim/src/up_idle.c @@ -44,10 +44,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 0623f44d9b..2fb5ec54b8 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_initialize.c + * arch/sim/src/up_initialize.c * * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -47,10 +47,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_initialstate.c b/arch/sim/src/up_initialstate.c index dfa1149954..ff4898a912 100644 --- a/arch/sim/src/up_initialstate.c +++ b/arch/sim/src/up_initialstate.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_initialstate.c + * arch/sim/src/up_initialstate.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,10 +44,10 @@ #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_interruptcontext.c b/arch/sim/src/up_interruptcontext.c index 83a17d3b6d..6dda092aac 100644 --- a/arch/sim/src/up_interruptcontext.c +++ b/arch/sim/src/up_interruptcontext.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_interruptcontext.c + * arch/sim/src/up_interruptcontext.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -41,10 +41,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_netdev.c b/arch/sim/src/up_netdev.c index e02b30ef6d..237c42a69a 100644 --- a/arch/sim/src/up_netdev.c +++ b/arch/sim/src/up_netdev.c @@ -41,7 +41,7 @@ #include /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef NULL diff --git a/arch/sim/src/up_netdriver.c b/arch/sim/src/up_netdriver.c index 45c106b7fd..8d40d7d30e 100644 --- a/arch/sim/src/up_netdriver.c +++ b/arch/sim/src/up_netdriver.c @@ -56,10 +56,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #define BUF ((struct ether_header*)g_sim_dev.d_buf) diff --git a/arch/sim/src/up_releasepending.c b/arch/sim/src/up_releasepending.c index 4859ef3326..fb324bab17 100644 --- a/arch/sim/src/up_releasepending.c +++ b/arch/sim/src/up_releasepending.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_releasepending.c + * arch/sim/src/up_releasepending.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,10 +44,10 @@ #include #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_releasestack.c b/arch/sim/src/up_releasestack.c index f8f47c44d3..dde67a0f1b 100644 --- a/arch/sim/src/up_releasestack.c +++ b/arch/sim/src/up_releasestack.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_releasestack.c + * arch/sim/src/up_releasestack.c * * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,10 +44,10 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_reprioritizertr.c b/arch/sim/src/up_reprioritizertr.c index 4abb348028..5bea181140 100644 --- a/arch/sim/src/up_reprioritizertr.c +++ b/arch/sim/src/up_reprioritizertr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_reprioritizertr.c + * arch/sim/src/up_reprioritizertr.c * * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -47,10 +47,10 @@ #include #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_romgetc.c b/arch/sim/src/up_romgetc.c index 9b75ecd653..d22cc8054a 100644 --- a/arch/sim/src/up_romgetc.c +++ b/arch/sim/src/up_romgetc.c @@ -44,7 +44,7 @@ #ifdef CONFIG_ARCH_ROMGETC /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_schedulesigaction.c b/arch/sim/src/up_schedulesigaction.c index 11c7bdde9f..d1ea0a5703 100644 --- a/arch/sim/src/up_schedulesigaction.c +++ b/arch/sim/src/up_schedulesigaction.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_schedulesigaction.c + * arch/sim/src/up_schedulesigaction.c * * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -45,10 +45,10 @@ #include #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_setjmp.S b/arch/sim/src/up_setjmp.S index b3c8c68264..23cdda4df4 100644 --- a/arch/sim/src/up_setjmp.S +++ b/arch/sim/src/up_setjmp.S @@ -1,5 +1,5 @@ /************************************************************************** - * up_setjmp.S + * arch/sim/src/up_setjmp.S * * Copyright (C) 2007, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -37,10 +37,10 @@ * Included Files **************************************************************************/ -#include "up_internal.h" +#include "sim.h" /************************************************************************** - * Pr-processor Definitions + * Pre-processor Definitions **************************************************************************/ #ifdef __CYGWIN__ diff --git a/arch/sim/src/up_simuart.c b/arch/sim/src/up_simuart.c new file mode 100644 index 0000000000..51a65f427b --- /dev/null +++ b/arch/sim/src/up_simuart.c @@ -0,0 +1,153 @@ +/**************************************************************************** + * arch/sim/src/up_hostusleep.c + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "sim.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +char g_uartbuffer[CONFIG_SIM_UART_BUFSIZE]; +volatile int g_uarthead; +volatile int g_uarttail; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: setrawmode + ****************************************************************************/ + +static void setrawmode(void) +{ + struct termios term; + + (void)tcgetattr(0, &term); + + term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + term.c_oflag &= ~OPOST; + term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + term.c_cflag &= ~(CSIZE | PARENB); + term.c_cflag |= CS8; + + (void)tcsetattr(0, TCSANOW, &term); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_simuart + ****************************************************************************/ + +void *up_simuart(void *arg) +{ + unsigned char ch; + ssize_t nread; + + /* This thread runs in the host domain */ + /* Initialize the NuttX domain semaphore */ + + uart_wait_initialize(); + + /* Put stdin into raw mode */ + + setrawmode(); + + /* Now loop, collecting a buffering data from stdin forever */ + + for (;;) + { + /* Read one character from stdin */ + + nread = read(0, ch, 1); + + /* Check for failures (but don't do anything) */ + + if (nread == 1) + { + /* Get the index to the next slot in the UART buffer */ + + int next = g_uarthead + 1; + if (next >= CONFIG_SIM_UART_BUFSIZE) + { + next = 0; + } + + /* Would adding this character cause an overflow? */ + + if (next != g_uarttail) + { + /* No.. Add the character to the UART buffer */ + + g_uartbuffer[g_uarthead] = ch; + + /* Was the buffer previously empty? */ + + if (g_uarthead == g_uarttail) + { + /* Yes.. signal any (NuttX) threads waiting for serial + * input. + */ + + up_simuart_post(); + } + + /* Update the head index */ + + g_uarthead = next; + } + } + } + + return NULL; +} diff --git a/arch/sim/src/up_spiflash.c b/arch/sim/src/up_spiflash.c index bd5a611418..04329dcb42 100644 --- a/arch/sim/src/up_spiflash.c +++ b/arch/sim/src/up_spiflash.c @@ -50,12 +50,12 @@ #include #include -#include "up_internal.h" +#include "sim.h" #if defined(CONFIG_SIM_SPIFLASH) /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Configuration ********************************************************************/ diff --git a/arch/sim/src/up_stackframe.c b/arch/sim/src/up_stackframe.c index ef64985983..648e94a841 100644 --- a/arch/sim/src/up_stackframe.c +++ b/arch/sim/src/up_stackframe.c @@ -47,7 +47,7 @@ #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** * Pre-processor Macros diff --git a/arch/sim/src/up_stdio.c b/arch/sim/src/up_stdio.c index b6da9cb2fc..99ab517c02 100644 --- a/arch/sim/src/up_stdio.c +++ b/arch/sim/src/up_stdio.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_stdio.c + * arch/sim/src/up_stdio.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -40,7 +40,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_tapdev.c b/arch/sim/src/up_tapdev.c index 91166ceb11..32ddade602 100644 --- a/arch/sim/src/up_tapdev.c +++ b/arch/sim/src/up_tapdev.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_tapdev.c + * arch/sim/src/up_tapdev.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -65,7 +65,7 @@ extern int syslog(const char *format, ...); extern int netdriver_setmacaddr(unsigned char *macaddr); /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #define TAPDEV_DEBUG 1 diff --git a/arch/sim/src/up_touchscreen.c b/arch/sim/src/up_touchscreen.c index 9ee99cbe92..95cae2e33a 100644 --- a/arch/sim/src/up_touchscreen.c +++ b/arch/sim/src/up_touchscreen.c @@ -59,7 +59,7 @@ #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** * Pre-processor Definitions diff --git a/arch/sim/src/up_uartwait.c b/arch/sim/src/up_uartwait.c new file mode 100644 index 0000000000..b7b83ed9e5 --- /dev/null +++ b/arch/sim/src/up_uartwait.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * arch/sim/src/up_uartwait.c + * + * Copyright (C) 20014Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "sim.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static sem_t g_uartavail; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: uart_wait_initialize + ****************************************************************************/ + +void uart_wait_initialize(void) +{ + sem_init(&g_uartavail, 0, 0); +} + +/**************************************************************************** + * Name: up_simuart_post + ****************************************************************************/ + +void up_simuart_post(void) +{ + sem_post(&g_uartavail); +} + +/**************************************************************************** + * Name: up_simuart_wait + ****************************************************************************/ + +void up_simuart_wait(void) +{ + while (g_uarthead == g_uarttail) + { + (void)sem_wait(&g_uartavail); + } +} diff --git a/arch/sim/src/up_unblocktask.c b/arch/sim/src/up_unblocktask.c index 42f943352e..2d6e6fc91a 100644 --- a/arch/sim/src/up_unblocktask.c +++ b/arch/sim/src/up_unblocktask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_unblocktask.c + * arch/sim/src/up_unblocktask.c * * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -45,10 +45,10 @@ #include "clock/clock.h" #include "sched/sched.h" -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_usestack.c b/arch/sim/src/up_usestack.c index 5cb9dd2654..7fcc3c9d1c 100644 --- a/arch/sim/src/up_usestack.c +++ b/arch/sim/src/up_usestack.c @@ -41,10 +41,10 @@ #include #include #include -#include "up_internal.h" +#include "sim.h" /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_wpcap.c b/arch/sim/src/up_wpcap.c index dabbe0dab0..6225751db6 100644 --- a/arch/sim/src/up_wpcap.c +++ b/arch/sim/src/up_wpcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_wcap.c + * arch/sim/src/up_wcap.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/sim/src/up_x11eventloop.c b/arch/sim/src/up_x11eventloop.c index e2354dbeca..630bc80e1b 100644 --- a/arch/sim/src/up_x11eventloop.c +++ b/arch/sim/src/up_x11eventloop.c @@ -42,7 +42,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/arch/sim/src/up_x11framebuffer.c b/arch/sim/src/up_x11framebuffer.c index f59320a461..39bd3647e3 100644 --- a/arch/sim/src/up_x11framebuffer.c +++ b/arch/sim/src/up_x11framebuffer.c @@ -52,7 +52,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /****************************************************************************