First set of changes to incorporate the RGMP port

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3595 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-05-12 17:42:01 +00:00
parent 0faef6c9f0
commit fff9db3c57
30 changed files with 3896 additions and 6 deletions

View file

@ -1737,3 +1737,11 @@
interpreter has been moved to apps/interpreter/Makefile.
* tools/mkdep.sh: Should not report an error if there are no files on the command
line. This happens normally in certain configurations.
* drivers/usbhost: Sheref Younan reported an error in the error handling when
connection to a USB device fails. In certain fail cases, the logic would try
to free the device class instance twice, the first was okay, but the second
caused a crash.
* graphics/nxbe/nxbe_colormap.c: Fix error noted by Bassem Fahmy. The function
nxbe_colormap was change to nxbe_configure... apparently "search-and-replace"
error. This error was not noticed before because most NX platforms do not use
colormapping.

View file

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: May 10, 2011</p>
<p>Last Updated: May 12, 2011</p>
</td>
</tr>
</table>
@ -2199,6 +2199,16 @@ nuttx-6.3 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
build time
* Makefile: Removed support for Pascal pcode interpreter. Support for that
interpreter has been moved to apps/interpreter/Makefile.
* tools/mkdep.sh: Should not report an error if there are no files on the command
line. This happens normally in certain configurations.
* drivers/usbhost: Sheref Younan reported an error in the error handling when
connection to a USB device fails. In certain fail cases, the logic would try
to free the device class instance twice, the first was okay, but the second
caused a crash.
* graphics/nxbe/nxbe_colormap.c: Fix error noted by Bassem Fahmy. The function
nxbe_colormap was change to nxbe_configure... apparently "search-and-replace"
error. This error was not noticed before because most NX platforms do not use
colormapping.
apps-6.3 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
@ -2206,6 +2216,11 @@ apps-6.3 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
on module now installs and builds under this directory.
* apps/interpreter/ficl: Added logic to build Ficl (the "Forth Inspired
Command Language"). See http://ficl.sourceforge.net/.
* apps/netutils/dhcpc, dhcpcd, and tftp. If these directories are included
in the configuration but CONFIG_NET_UDP is disable (which is not very wise),
then a make error occurs because tools/mkdep.sh is called with no files.
* system/free: Move Uros' custom free command from vsn/free
* system/install: Add a new install command submitted by Uros Platise.
pascal-3.0 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;

72
arch/rgmp/include/arch.h Normal file
View file

@ -0,0 +1,72 @@
/****************************************************************************
* arch/rgmp/include/arch.h
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#ifndef __RGMP_ARCH_ARCH_H
#define __RGMP_ARCH_ARCH_H
#ifndef __ASSEMBLY__
#include <nuttx/sched.h>
#include <rgmp/hpet.h>
struct up_wait {
struct up_wait *next;
_TCB *task;
};
extern _TCB *current_task;
void up_sigentry(void);
int up_register_bridge(char *name, int size);
int up_unregister_bridge(char *name);
static inline void up_mdelay(uint32_t msec)
{
hpet_ndelay(msec*1000000);
}
static inline void up_udelay(uint32_t usec)
{
hpet_udelay(usec*1000);
}
#endif
#endif

59
arch/rgmp/include/com.h Normal file
View file

@ -0,0 +1,59 @@
/****************************************************************************
* arch/rgmp/include/com.h
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_RGMP_INCLUDE_COM_H
#define __ARCH_RGMP_INCLUDE_COM_H
#define COM_SET_BAUD 1
#define COM_SET_PARITY 2
#define COM_NO_PARITY 0
#define COM_ODD_PARITY 1
#define COM_EVEN_PARITY 3
#define COM_SET_STOPBITS 3
#define COM_ONE_STOPBITS 0
#define COM_TWO_STOPBITS 1
#define COM_SET_BITS 4
#define COM_8_BITS 3
#define COM_7_BITS 2
#define COM_6_BITS 1
#define COM_5_BITS 0
void up_serialinit(void);
#endif

72
arch/rgmp/include/irq.h Normal file
View file

@ -0,0 +1,72 @@
/****************************************************************************
* arch/rgmp/include/irq.h
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_RGMP_INCLUDE_IRQ_H
#define __ARCH_RGMP_INCLUDE_IRQ_H
#define NR_IRQS 0
#ifndef __ASSEMBLY__
#include <rgmp/trap.h>
#include <rgmp/spinlock.h>
#include <arch/types.h>
struct xcptcontext {
struct Trapframe *tf;
// for signal using
unsigned int save_eip;
unsigned int save_eflags;
void *sigdeliver;
};
extern int nest_irq;
static inline irqstate_t irqsave(void)
{
return pushcli();
}
static inline void irqrestore(irqstate_t flags)
{
popcli(flags);
}
#endif
#endif

View file

@ -0,0 +1,81 @@
/************************************************************
* arch/rgmp/include/limits.h
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 Gregory Nutt 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.
*
************************************************************/
#ifndef __ARCH_RGMP_INCLUDE_LIMITS_H
#define __ARCH_RGMP_INCLUDE_LIMITS_H
/************************************************************
* Included Files
************************************************************/
/************************************************************
* Definitions
************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN 0x80
#define SCHAR_MAX 0x7f
#define UCHAR_MAX 0xff
/* These could be different on machines where char is unsigned */
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#define SHRT_MIN 0x8000
#define SHRT_MAX 0x7fff
#define USHRT_MAX 0xffff
#define INT_MIN 0x80000000
#define INT_MAX 0x7fffffff
#define UINT_MAX 0xffffffff
/* These change on 32-bit and 64-bit platforms */
#define LONG_MAX 0x80000000
#define LONG_MIN 0x7fffffff
#define ULONG_MAX 0xffffffff
#define LLONG_MAX 0x8000000000000000
#define LLONG_MIN 0x7fffffffffffffff
#define ULLONG_MAX 0xffffffffffffffff
/* A pointer is 4 bytes */
#define PTR_MIN 0x80000000
#define PTR_MAX 0x7fffffff
#define UPTR_MAX 0xffffffff
#endif /* __ARCH_RGMP_INCLUDE_LIMITS_H */

96
arch/rgmp/include/types.h Normal file
View file

@ -0,0 +1,96 @@
/************************************************************************
* arch/rgmp/include/types.h
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 Gregory Nutt 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.
*
************************************************************************/
/* This file should never be included directed but, rather,
* only indirectly through sys/types.h
*/
#ifndef __ARCH_RGMP_INCLUDE_TYPES_H
#define __ARCH_RGMP_INCLUDE_TYPES_H
/************************************************************************
* Included Files
************************************************************************/
/************************************************************************
* Definitions
************************************************************************/
/************************************************************************
* Type Declarations
************************************************************************/
#ifndef __ASSEMBLY__
/* These are the sizes of the standard integer types. NOTE that these type
* names have a leading underscore character. This file will be included
* (indirectly) by include/stdint.h and typedef'ed to the final name without
* the underscore character. This roundabout way of doings things allows
* the stdint.h to be removed from the include/ directory in the event that
* the user prefers to use the definitions provided by their toolchain header
* files
*/
typedef char _int8_t;
typedef unsigned char _uint8_t;
typedef short _int16_t;
typedef unsigned short _uint16_t;
typedef int _int32_t;
typedef unsigned int _uint32_t;
typedef long long _int64_t;
typedef unsigned long long _uint64_t;
#define __INT64_DEFINED
/* A pointer is 4 bytes */
typedef unsigned int _intptr_t;
typedef unsigned int _uintptr_t;
/* This is the size of the interrupt state save returned by
* irqsave()
*/
typedef unsigned int irqstate_t;
#endif /* __ASSEMBLY__ */
/************************************************************************
* Global Function Prototypes
************************************************************************/
#endif /* __ARCH_RGMP_INCLUDE_TYPES_H */

93
arch/rgmp/src/Makefile Normal file
View file

@ -0,0 +1,93 @@
############################################################################
# arch/rgmp/src/Makefile
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
-include $(TOPDIR)/Make.defs
CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs
ASRCS = sigentry.S
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = nuttx.c rgmp.c bridge.c com.c
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
LDFLAGS += -T$(RGMPLKSCPT)
LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
LDPATHS += -L$(RGMPLIBDIR)
LDLIBS += -lrgmp -lm -ltest /usr/lib/gcc/$(shell gcc -dumpmachine)/$(shell gcc -dumpversion)/libgcc.a
all: libarch$(LIBEXT)
.PHONY: clean distclean depend
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
# The architecture-specific library
libarch$(LIBEXT): $(OBJS)
@( for obj in $(OBJS) ; do \
$(call ARCHIVE, $@, $${obj}); \
done ; )
# Generate the final NuttX binary by linking the host-specific objects with the NuttX
# specific objects (with munged names)
nuttx$(EXEEXT):
@echo "LD: nuttx$(EXEEXT)"
@$(LD) $(LDFLAGS) $(LDPATHS) --start-group $(LDLIBS) --end-group -o $(TOPDIR)/$@
@$(OBJDUMP) -S $(TOPDIR)/$@ > $(TOPDIR)/nuttx.asm
@$(NM) -n $(TOPDIR)/$@ > $(TOPDIR)/nuttx.sym
@$(OBJCOPY) -S -O binary $(TOPDIR)/$@ nuttx.img
.depend: Makefile $(SRCS)
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
@rm -f libarch$(LIBEXT) *~ .*.swp
$(call CLEAN)
distclean: clean
@rm -f Make.dep .depend
-include Make.dep

104
arch/rgmp/src/bridge.c Normal file
View file

@ -0,0 +1,104 @@
/****************************************************************************
* arch/rgmp/src/bridge.c
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#include <sys/types.h>
#include <stdbool.h>
#include <nuttx/fs.h>
#include <nuttx/kmalloc.h>
#include <fs_internal.h>
#include <queue.h>
#include <arch/irq.h>
#include <rgmp/bridge.h>
#include <rgmp/string.h>
#include <rgmp/stdio.h>
static ssize_t up_bridge_read(struct file *filp, char *buffer, size_t len)
{
struct rgmp_bridge *b;
b = filp->f_inode->i_private;
return rgmp_bridge_read(b, buffer, len);
}
static ssize_t up_bridge_write(struct file *filp, const char *buffer, size_t len)
{
struct rgmp_bridge *b;
b = filp->f_inode->i_private;
return rgmp_bridge_write(b, (char *)buffer, len);
}
static int up_bridge_open(struct file *filp)
{
return 0;
}
static int up_bridge_close(struct file *filp)
{
return 0;
}
static const struct file_operations up_bridge_fops =
{
.read = up_bridge_read,
.write = up_bridge_write,
.open = up_bridge_open,
.close = up_bridge_close,
};
void up_register_bridges(void)
{
int err;
char path[30] = {'/', 'd', 'e', 'v', '/'};
struct rgmp_bridge *b;
for (b=bridge_list.next; b!=NULL; b=b->next) {
// make rgmp_bridge0 to be the console
if (strcmp(b->vdev->name, "rgmp_bridge0") == 0)
strlcpy(path+5, "console", 25);
else
strlcpy(path+5, b->vdev->name, 25);
err = register_driver(path, &up_bridge_fops, 0666, b);
if (err == ERROR)
cprintf("NuttX: register bridge %s fail\n", b->vdev->name);
}
}

627
arch/rgmp/src/com.c Normal file
View file

@ -0,0 +1,627 @@
/****************************************************************************
* arch/rgmp/src/com.c
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Authors: Yu Qiang <yuq825@gmail.com>
* Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <semaphore.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/serial.h>
#include <nuttx/kmalloc.h>
#include <arch/com.h>
#include <rgmp/trap.h>
#include <rgmp/console.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define COM1 0x3F8
#define COM2 0x2f8
#define COM3 0x3e8
#define COM4 0x2e8
#define COM_RX 0 // In: Receive buffer (DLAB=0)
#define COM_DLL 0 // Out: Divisor Latch Low (DLAB=1)
#define COM_TX 0 // Out: Transmit buffer (DLAB=0)
#define COM_DLM 1 // Out: Divisor Latch High (DLAB=1)
#define COM_IER 1 // Out: Interrupt Enable Register
#define COM_IER_TEI 0x02 // Enable transmit buffer empty interrupt
#define COM_IER_RDI 0x01 // Enable receiver data interrupt
#define COM_IIR 2 // In: Interrupt ID Register
#define COM_FCR 2 // Out: FIFO Control Register
#define COM_LCR 3 // Out: Line Control Register
#define COM_LCR_DLAB 0x80 // Divisor latch access bit
#define COM_LCR_WLEN8 0x03 // Wordlength: 8 bits
#define COM_MCR 4 // Out: Modem Control Register
#define COM_MCR_RTS 0x02 // RTS complement
#define COM_MCR_DTR 0x01 // DTR complement
#define COM_MCR_OUT2 0x08 // Out2 complement
#define COM_LSR 5 // In: Line Status Register
#define COM_LSR_DATA 0x01 // Data available
#define COM_LSR_ETR 0x20 // buffer has space
#define COM_LSR_EDR 0x40 // buffer empty
/****************************************************************************
* Private Types
****************************************************************************/
#ifndef CONFIG_COM_RXBUFSIZE
#define CONFIG_COM_RXBUFSIZE 64
#endif
#ifndef CONFIG_COM_TXBUFSIZE
#define CONFIG_COM_TXBUFSIZE 64
#endif
struct up_dev_s
{
unsigned int base; /* Base address of COM registers */
unsigned int baud; /* Configured baud */
int irq; /* IRQ associated with this COM */
struct irq_action action;
union {
uint8_t val;
struct {
unsigned bits : 2; /* 3=8 bits, 2=7 bits, 1=6 bits, 0=5 bits */
unsigned stopbits : 1; /* 0=1 stop bit, 1=2 stop bits */
unsigned parity : 3; /* xx0=none, 001=odd, 011=even */
unsigned ebreak : 1;
unsigned dlab : 1;
} sep;
} lcr;
char rxbuff[CONFIG_COM_RXBUFSIZE]; /* receive buffer */
char txbuff[CONFIG_COM_TXBUFSIZE]; /* transmit buffer */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
static irqreturn_t up_com_int_handler(struct Trapframe *tf, void *dev_id);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, unsigned int *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
static bool up_rxavailable(struct uart_dev_s *dev);
static void up_send(struct uart_dev_s *dev, int ch);
static void up_txint(struct uart_dev_s *dev, bool enable);
static bool up_txready(struct uart_dev_s *dev);
static bool up_txempty(struct uart_dev_s *dev);
/****************************************************************************
* Private Variables
****************************************************************************/
static struct uart_ops_s g_com_ops =
{
.setup = up_setup,
.shutdown = up_shutdown,
.attach = up_attach,
.detach = up_detach,
.ioctl = up_ioctl,
.receive = up_receive,
.rxint = up_rxint,
.rxavailable = up_rxavailable,
.send = up_send,
.txint = up_txint,
.txready = up_txready,
.txempty = up_txempty,
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: up_alloc_com
****************************************************************************/
static uart_dev_t *up_alloc_com(unsigned int base, int irq)
{
uart_dev_t *dev;
struct up_dev_s *priv;
priv = kzmalloc(sizeof(struct up_dev_s));
if (priv == NULL)
goto err0;
dev = kzmalloc(sizeof(uart_dev_t));
if (dev == NULL)
goto err1;
priv->base = base;
priv->irq = irq;
priv->baud = 115200;
priv->lcr.val = 0;
priv->lcr.sep.parity = 0;
priv->lcr.sep.bits = 3;
priv->lcr.sep.stopbits = 0;
priv->action.handler = up_com_int_handler;
priv->action.dev_id = dev;
dev->recv.size = CONFIG_COM_RXBUFSIZE;
dev->recv.buffer = priv->rxbuff;
dev->xmit.size = CONFIG_COM_TXBUFSIZE;
dev->xmit.buffer = priv->txbuff;
dev->ops = &g_com_ops;
dev->priv = priv;
return dev;
err1:
kfree(priv);
err0:
return NULL;
}
/****************************************************************************
* Name: up_alloc_com
****************************************************************************/
static inline void up_free_com(uart_dev_t *com)
{
kfree(com->priv);
kfree(com);
}
/****************************************************************************
* Name: up_setup
*
* Description:
* Configure the UART baud, bits, parity, fifos, etc. This
* method is called the first time that the serial port is
* opened.
*
****************************************************************************/
static int up_setup(struct uart_dev_s *dev)
{
struct up_dev_s *priv = dev->priv;
uint16_t base = priv->base;
union {
uint16_t val;
struct {
uint8_t low;
uint8_t high;
} sep;
} data;
// clear and disable FIFO
outb(base+COM_FCR, 1);
outb(base+COM_FCR, 3);
outb(base+COM_FCR, 0);
// Clear any preexisting overrun indications and interrupts
// Serial port doesn't exist if COM_LSR returns 0xFF
inb(base+COM_LSR);
inb(base+COM_IIR);
inb(base+COM_RX);
if (inb(base+COM_LSR) == 0xff) {
dbg("COM %d does not exist\n", base);
return -1;
}
// Set speed; requires DLAB latch
outb(base+COM_LCR, COM_LCR_DLAB);
data.val = 115200 / priv->baud;
outb(base+COM_DLL, data.sep.low);
outb(base+COM_DLM, data.sep.high);
// set data bits, stop bit, parity; turn off DLAB latch
outb(base+COM_LCR, priv->lcr.val);
// OUT2 must be set to enable interrupt
outb(base+COM_MCR, COM_MCR_OUT2);
// setup FIFO
outb(base+COM_FCR, 1);
// disable COM interrupts
outb(base+COM_IER, 0);
return OK;
}
/****************************************************************************
* Name: up_shutdown
*
* Description:
* Disable the UART. This method is called when the serial port is closed
*
****************************************************************************/
static void up_shutdown(struct uart_dev_s *dev)
{
struct up_dev_s *priv = dev->priv;
uint16_t base = priv->base;
// disable COM interrupts
outb(base+COM_IER, 0);
}
/****************************************************************************
* Name: up_attach
*
* Description:
* Configure the UART to operation in interrupt driven mode. This method is
* called when the serial port is opened. Normally, this is just after the
* the setup() method is called, however, the serial console may operate in
* a non-interrupt driven mode during the boot phase.
*
* RX and TX interrupts are not enabled when by the attach method (unless the
* hardware supports multiple levels of interrupt enabling). The RX and TX
* interrupts are not enabled until the txint() and rxint() methods are called.
*
****************************************************************************/
static int up_attach(struct uart_dev_s *dev)
{
struct up_dev_s *priv = dev->priv;
int err;
err = rgmp_request_irq(priv->irq, &priv->action, 0);
return err;
}
/****************************************************************************
* Name: up_detach
*
* Description:
* Detach UART interrupts. This method is called when the serial port is
* closed normally just before the shutdown method is called. The exception is
* the serial console which is never shutdown.
*
****************************************************************************/
static void up_detach(struct uart_dev_s *dev)
{
struct up_dev_s *priv = dev->priv;
rgmp_free_irq(priv->irq, &priv->action);
}
/****************************************************************************
* Name: up_com_int_handler
*
* Description:
* This is the UART interrupt handler. It will be invoked
* when an interrupt received on the 'irq' It should call
* uart_transmitchars or uart_receivechar to perform the
* appropriate data transfers. The interrupt handling logic\
* must be able to map the 'irq' number into the approprite
* uart_dev_s structure in order to call these functions.
*
****************************************************************************/
static irqreturn_t up_com_int_handler(struct Trapframe *tf, void *dev_id)
{
struct uart_dev_s *dev = dev_id;
struct up_dev_s *priv = dev->priv;
uint16_t base = priv->base;
//uint8_t cause = inb(base+COM_IIR);
uint8_t state = inb(base+COM_LSR);
if (state & COM_LSR_DATA)
uart_recvchars(dev);
if (state & COM_LSR_ETR)
uart_xmitchars(dev);
return IRQ_HANDLED;
}
/****************************************************************************
* Name: up_ioctl
*
* Description:
* All ioctl calls will be routed through this method
*
****************************************************************************/
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
{
struct inode *inode = filep->f_inode;
struct uart_dev_s *dev = inode->i_private;
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
switch (cmd) {
case COM_SET_BAUD:
priv->baud = arg;
break;
case COM_SET_PARITY:
priv->lcr.sep.parity = arg;
break;
case COM_SET_STOPBITS:
priv->lcr.sep.stopbits = arg;
break;
case COM_SET_BITS:
priv->lcr.sep.bits = arg;
break;
default:
return ERROR;
}
if (up_setup(dev) != OK)
return ERROR;
up_rxint(dev, 1);
return OK;
}
/****************************************************************************
* Name: up_receive
*
* Description:
* Called (usually) from the interrupt level to receive one character from
* the UART. Error bits associated with the receipt are provided in the
* the return 'status'.
*
****************************************************************************/
static int up_receive(struct uart_dev_s *dev, unsigned int *status)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
return inb(base+COM_RX);
}
/****************************************************************************
* Name: up_rxint
*
* Description:
* Call to enable or disable RX interrupts
*
****************************************************************************/
static void up_rxint(struct uart_dev_s *dev, bool enable)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
uint8_t ier;
ier = inb(base+COM_IER);
if (enable)
ier |= COM_IER_RDI;
else
ier &= ~COM_IER_RDI;
outb(base+COM_IER, ier);
}
/****************************************************************************
* Name: up_rxavailable
*
* Description:
* Return true if the receive fifo is not empty
*
****************************************************************************/
static bool up_rxavailable(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
return inb(base+COM_LSR) & COM_LSR_DATA;
}
/****************************************************************************
* Name: up_send
*
* Description:
* This method will send one byte on the UART
*
****************************************************************************/
static void up_send(struct uart_dev_s *dev, int ch)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
outb(base+COM_TX, ch);
}
/****************************************************************************
* Name: up_txint
*
* Description:
* Call to enable or disable TX interrupts
*
****************************************************************************/
static void up_txint(struct uart_dev_s *dev, bool enable)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
uint8_t ier;
ier = inb(base+COM_IER);
if (enable) {
ier |= COM_IER_TEI;
/* Fake a TX interrupt here by just calling uart_xmitchars() with
* interrupts disabled (note this may recurse).
*/
uart_xmitchars(dev);
}
else {
ier &= ~COM_IER_TEI;
}
outb(base+COM_IER, ier);
}
/****************************************************************************
* Name: up_txready
*
* Description:
* Return true if the tranmsit fifo is not full
*
****************************************************************************/
static bool up_txready(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
return inb(base+COM_LSR) & COM_LSR_ETR;
}
/****************************************************************************
* Name: up_txempty
*
* Description:
* Return true if the transmit fifo is empty
*
****************************************************************************/
static bool up_txempty(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
uint16_t base = priv->base;
return inb(base+COM_LSR) & COM_LSR_EDR;
}
/****************************************************************************
* Public Funtions
****************************************************************************/
/****************************************************************************
* Name: up_serialinit
*
* Description:
* Performs the low level UART initialization early in
* debug so that the serial console will be available
* during bootup. This must be called before up_serialinit.
*
****************************************************************************/
void up_earlyserialinit(void)
{
}
/****************************************************************************
* Name: up_serialinit
*
* Description:
* Register serial console and serial ports. This assumes
* that up_earlyserialinit was called previously.
*
****************************************************************************/
void up_serialinit(void)
{
uart_dev_t *dev;
int err;
#ifdef CONFIG_COM1
dev = up_alloc_com(COM1, 4);
if (dev == NULL)
dbg("alloc com1 fail\n");
else {
err = uart_register("/dev/ttyS0", dev);
if (err)
dbg("register com1 fail\n");
}
#endif
#ifdef CONFIG_COM2
dev = up_alloc_com(COM2, 3);
if (dev == NULL)
dbg("alloc com2 fail\n");
else {
err = uart_register("/dev/ttyS1", dev);
if (err)
dbg("register com2 fail\n");
}
#endif
#ifdef CONFIG_COM3
dev = up_alloc_com(COM3, 4);
if (dev == NULL)
dbg("alloc com3 fail\n");
else {
err = uart_register("/dev/ttyS2", dev);
if (err)
dbg("register com3 fail\n");
}
#endif
#ifdef CONFIG_COM4
dev = up_alloc_com(COM4, 3);
if (dev == NULL)
dbg("alloc com4 fail\n");
else {
err = uart_register("/dev/ttyS3", dev);
if (err)
dbg("register com4 fail\n");
}
#endif
}
/****************************************************************************
* Name: up_putc
*
* Description:
* Provide priority, low-level access to support OS debug
* writes
*
****************************************************************************/
int up_putc(int ch)
{
cons_putc(ch);
return ch;
}

526
arch/rgmp/src/nuttx.c Normal file
View file

@ -0,0 +1,526 @@
/****************************************************************************
* arch/rgmp/src/bridge.c
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#include <rgmp/boot.h>
#include <rgmp/pmap.h>
#include <rgmp/x86.h>
#include <rgmp/assert.h>
#include <rgmp/spinlock.h>
#include <rgmp/console.h>
#include <rgmp/string.h>
#include <rgmp/fpu.h>
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <stdio.h>
#include <stdlib.h>
#include <arch/irq.h>
#include <arch/arch.h>
#include <arch/com.h>
#include <os_internal.h>
_TCB *current_task = NULL;
/**
* This function is called in non-interrupt context
* to switch tasks.
* Assumption: global interrupt is disabled.
*/
static inline void up_switchcontext(_TCB *ctcb, _TCB *ntcb)
{
// do nothing if two tasks are the same
if (ctcb == ntcb)
return;
// this function can not be called in interrupt
if (up_interrupt_context()) {
panic("%s: try to switch context in interrupt\n", __func__);
}
// start switch
current_task = ntcb;
asm volatile ("int $0x40"
::"a"(ctcb?&ctcb->xcp.tf:NULL),
"b"(ntcb->xcp.tf));
}
void up_initialize(void)
{
extern pidhash_t g_pidhash[];
extern void up_register_bridges(void);
extern void vnet_initialize(void);
// intialize the current_task to g_idletcb
current_task = g_pidhash[PIDHASH(0)].tcb;
// setup console
up_register_bridges();
// setup net device
vnet_initialize();
// setup COM device
up_serialinit();
// enable interrupt
sti();
}
void up_idle(void)
{
asm volatile("hlt");
}
void up_initial_state(_TCB *tcb)
{
struct Trapframe *tf;
if (tcb->pid != 0) {
tf = (struct Trapframe *)tcb->adj_stack_ptr-1;
memset(tf, 0, sizeof(struct Trapframe));
tf->tf_fpu = rgmp_fpu_init_regs;
tf->tf_eflags = 0x00000202;
tf->tf_cs = GD_KT;
tf->tf_ds = GD_KD;
tf->tf_es = GD_KD;
tf->tf_eip = (uint32_t)tcb->start;
tcb->xcp.tf = tf;
}
}
void up_allocate_heap(void **heap_start, size_t *heap_size)
{
*heap_start = boot_freemem;
*heap_size = KERNBASE + boot_param.mem_size - (uint32_t)boot_freemem;
}
int up_create_stack(_TCB *tcb, size_t stack_size)
{
int ret = ERROR;
size_t *adj_stack_ptr;
/* Move up to next even word boundary if necessary */
size_t adj_stack_size = (stack_size + 3) & ~3;
size_t adj_stack_words = adj_stack_size >> 2;
/* Allocate the memory for the stack */
uint32_t *stack_alloc_ptr = (uint32_t*)kmalloc(adj_stack_size);
if (stack_alloc_ptr) {
/* This is the address of the last word in the allocation */
adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1];
/* Save the values in the TCB */
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack_alloc_ptr;
tcb->adj_stack_ptr = adj_stack_ptr;
ret = OK;
}
return ret;
}
int up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
{
/* Move up to next even word boundary if necessary */
size_t adj_stack_size = stack_size & ~3;
size_t adj_stack_words = adj_stack_size >> 2;
/* This is the address of the last word in the allocation */
size_t *adj_stack_ptr = &((size_t*)stack)[adj_stack_words - 1];
/* Save the values in the TCB */
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack;
tcb->adj_stack_ptr = adj_stack_ptr;
return OK;
}
void up_release_stack(_TCB *dtcb)
{
if (dtcb->stack_alloc_ptr) {
free(dtcb->stack_alloc_ptr);
}
dtcb->stack_alloc_ptr = NULL;
dtcb->adj_stack_size = 0;
dtcb->adj_stack_ptr = NULL;
}
/****************************************************************************
* Name: up_block_task
*
* Description:
* The currently executing task at the head of
* the ready to run list must be stopped. Save its context
* and move it to the inactive list specified by task_state.
*
* This function is called only from the NuttX scheduling
* logic. Interrupts will always be disabled when this
* function is called.
*
* Inputs:
* tcb: Refers to a task in the ready-to-run list (normally
* the task at the head of the list). It most be
* stopped, its context saved and moved into one of the
* waiting task lists. It it was the task at the head
* of the ready-to-run list, then a context to the new
* ready to run task must be performed.
* task_state: Specifies which waiting task list should be
* hold the blocked task TCB.
*
****************************************************************************/
void up_block_task(_TCB *tcb, tstate_t task_state)
{
/* Verify that the context switch can be performed */
if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) ||
(tcb->task_state > LAST_READY_TO_RUN_STATE)) {
warn("%s: task sched error\n", __func__);
return;
}
else {
_TCB *rtcb = current_task;
bool switch_needed;
/* Remove the tcb task from the ready-to-run list. If we
* are blocking the task at the head of the task list (the
* most likely case), then a context switch to the next
* ready-to-run task is needed. In this case, it should
* also be true that rtcb == tcb.
*/
switch_needed = sched_removereadytorun(tcb);
/* Add the task to the specified blocked task list */
sched_addblocked(tcb, (tstate_t)task_state);
/* Now, perform the context switch if one is needed */
if (switch_needed) {
_TCB *nexttcb;
// this part should not be executed in interrupt context
if (up_interrupt_context()) {
panic("%s: %d\n", __func__, __LINE__);
}
// If there are any pending tasks, then add them to the g_readytorun
// task list now. It should be the up_realease_pending() called from
// sched_unlock() to do this for disable preemption. But it block
// itself, so it's OK.
if (g_pendingtasks.head) {
warn("Disable preemption failed for task block itself\n");
sched_mergepending();
}
nexttcb = (_TCB*)g_readytorun.head;
// context switch
up_switchcontext(rtcb, nexttcb);
}
}
}
/****************************************************************************
* Name: up_unblock_task
*
* Description:
* A task is currently in an inactive task list
* but has been prepped to execute. Move the TCB to the
* ready-to-run list, restore its context, and start execution.
*
* Inputs:
* tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority
* ready to run taks, executed.
*
****************************************************************************/
void up_unblock_task(_TCB *tcb)
{
/* Verify that the context switch can be performed */
if ((tcb->task_state < FIRST_BLOCKED_STATE) ||
(tcb->task_state > LAST_BLOCKED_STATE)) {
warn("%s: task sched error\n", __func__);
return;
}
else {
_TCB *rtcb = current_task;
/* Remove the task from the blocked task list */
sched_removeblocked(tcb);
/* Reset its timeslice. This is only meaningful for round
* robin tasks but it doesn't here to do it for everything
*/
#if CONFIG_RR_INTERVAL > 0
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
#endif
// Add the task in the correct location in the prioritized
// g_readytorun task list.
if (sched_addreadytorun(tcb) && !up_interrupt_context()) {
/* The currently active task has changed! */
_TCB *nexttcb = (_TCB*)g_readytorun.head;
// context switch
up_switchcontext(rtcb, nexttcb);
}
}
}
/**
* This function is called from sched_unlock() which will check not
* in interrupt context and disable interrupt.
*/
void up_release_pending(void)
{
_TCB *rtcb = current_task;
/* Merge the g_pendingtasks list into the g_readytorun task list */
if (sched_mergepending()) {
/* The currently active task has changed! */
_TCB *nexttcb = (_TCB*)g_readytorun.head;
// context switch
up_switchcontext(rtcb, nexttcb);
}
}
void up_reprioritize_rtr(_TCB *tcb, uint8_t priority)
{
/* Verify that the caller is sane */
if (tcb->task_state < FIRST_READY_TO_RUN_STATE ||
tcb->task_state > LAST_READY_TO_RUN_STATE
#if SCHED_PRIORITY_MIN > UINT8_MIN
|| priority < SCHED_PRIORITY_MIN
#endif
#if SCHED_PRIORITY_MAX < UINT8_MAX
|| priority > SCHED_PRIORITY_MAX
#endif
) {
warn("%s: task sched error\n", __func__);
return;
}
else {
_TCB *rtcb = current_task;
bool switch_needed;
/* Remove the tcb task from the ready-to-run list.
* sched_removereadytorun will return true if we just
* remove the head of the ready to run list.
*/
switch_needed = sched_removereadytorun(tcb);
/* Setup up the new task priority */
tcb->sched_priority = (uint8_t)priority;
/* Return the task to the specified blocked task list.
* sched_addreadytorun will return true if the task was
* added to the new list. We will need to perform a context
* switch only if the EXCLUSIVE or of the two calls is non-zero
* (i.e., one and only one the calls changes the head of the
* ready-to-run list).
*/
switch_needed ^= sched_addreadytorun(tcb);
/* Now, perform the context switch if one is needed */
if (switch_needed && !up_interrupt_context()) {
_TCB *nexttcb;
// If there are any pending tasks, then add them to the g_readytorun
// task list now. It should be the up_realease_pending() called from
// sched_unlock() to do this for disable preemption. But it block
// itself, so it's OK.
if (g_pendingtasks.head) {
warn("Disable preemption failed for reprioritize task\n");
sched_mergepending();
}
nexttcb = (_TCB*)g_readytorun.head;
// context switch
up_switchcontext(rtcb, nexttcb);
}
}
}
void _exit(int status)
{
_TCB* tcb;
/* Destroy the task at the head of the ready to run list. */
(void)task_deletecurrent();
/* Now, perform the context switch to the new ready-to-run task at the
* head of the list.
*/
tcb = (_TCB*)g_readytorun.head;
/* Then switch contexts */
up_switchcontext(NULL, tcb);
}
void up_assert(const uint8_t *filename, int line)
{
fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line);
// in interrupt context or idle task means kernel error
// which will stop the OS
// if in user space just terminate the task
if (up_interrupt_context() || current_task->pid == 0) {
panic("%s: %d\n", __func__, __LINE__);
}
else {
exit(EXIT_FAILURE);
}
}
void up_assert_code(const uint8_t *filename, int line, int code)
{
fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n",
filename, line, code);
// in interrupt context or idle task means kernel error
// which will stop the OS
// if in user space just terminate the task
if (up_interrupt_context() || current_task->pid == 0) {
panic("%s: %d\n", __func__, __LINE__);
}
else {
exit(EXIT_FAILURE);
}
}
#ifndef CONFIG_DISABLE_SIGNALS
void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
{
/* Refuse to handle nested signal actions */
if (!tcb->xcp.sigdeliver) {
int flags;
/* Make sure that interrupts are disabled */
flags = pushcli();
// First, handle some special cases when the signal is
// being delivered to the currently executing task.
if (tcb == current_task) {
// CASE 1: We are not in an interrupt handler and
// a task is signalling itself for some reason.
if (!up_interrupt_context()) {
// In this case just deliver the signal now.
sigdeliver(tcb);
}
// CASE 2: We are in an interrupt handler AND the
// interrupted task is the same as the one that
// must receive the signal.
else {
tcb->xcp.sigdeliver = sigdeliver;
}
}
// Otherwise, we are (1) signaling a task is not running
// from an interrupt handler or (2) we are not in an
// interrupt handler and the running task is signalling
// some non-running task.
else {
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.save_eip = tcb->xcp.tf->tf_eip;
tcb->xcp.save_eflags = tcb->xcp.tf->tf_eflags;
// Then set up to the trampoline with interrupts disabled
tcb->xcp.tf->tf_eip = (uint32_t)up_sigentry;
tcb->xcp.tf->tf_eflags = 0;
}
popcli(flags);
}
}
#endif /* !CONFIG_DISABLE_SIGNALS */
bool up_interrupt_context(void)
{
if (nest_irq)
return true;
return false;
}
#ifndef CONFIG_ARCH_NOINTC
void up_disable_irq(int irq)
{
}
void up_enable_irq(int irq)
{
}
#endif
#ifdef CONFIG_ARCH_IRQPRIO
int up_prioritize_irq(int irq, int priority)
{
}
#endif
void up_sigdeliver(struct Trapframe *tf)
{
sig_deliver_t sigdeliver;
tf->tf_eip = current_task->xcp.save_eip;
tf->tf_eflags = current_task->xcp.save_eflags;
sigdeliver = current_task->xcp.sigdeliver;
current_task->xcp.sigdeliver = NULL;
sti();
sigdeliver(current_task);
cli();
}

157
arch/rgmp/src/rgmp.c Normal file
View file

@ -0,0 +1,157 @@
/****************************************************************************
* arch/rgmp/src/rgmp.c
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
#include <rgmp/x86.h>
#include <rgmp/trap.h>
#include <nuttx/config.h>
#include <nuttx/init.h>
#include <nuttx/arch.h>
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
#include <semaphore.h>
#include <queue.h>
#include <stdlib.h>
#include <arch/arch.h>
#include <os_internal.h>
int nest_irq = 0;
// the default time is 10ms
#ifdef CONFIG_MSEC_PER_TICK
unsigned int rtos_tick_time = CONFIG_MSEC_PER_TICK;
#else
unsigned int rtos_tick_time = 10;
#endif
void rtos_entry(void)
{
os_start();
}
void *rtos_get_page(void)
{
return memalign(4096, 4096);
}
void rtos_free_page(void *page)
{
free(page);
}
/**
* The interrupt can be nested. The pair of rtos_enter_interrupt()
* and rtos_exit_interrupt() make sure the context switch is
* performed only in the last IRQ exit.
*/
void rtos_enter_interrupt(struct Trapframe *tf)
{
nest_irq++;
}
void rtos_exit_interrupt(struct Trapframe *tf)
{
cli();
nest_irq--;
if (!nest_irq) {
_TCB *rtcb = current_task;
_TCB *ntcb;
if (rtcb->xcp.sigdeliver) {
rtcb->xcp.save_eip = tf->tf_eip;
rtcb->xcp.save_eflags = tf->tf_eflags;
// Then set up to the trampoline with interrupts disabled
tf->tf_eip = (uint32_t)up_sigentry;
tf->tf_eflags = 0;
}
ntcb = (_TCB*)g_readytorun.head;
// switch needed
if (rtcb != ntcb) {
rtcb->xcp.tf = tf;
current_task = ntcb;
rgmp_pop_tf(ntcb->xcp.tf);
}
}
}
void rtos_timer_isr(struct Trapframe *tf)
{
sched_process_timer();
}
/**
* RTOS mutex operation
*/
const int rtos_mutex_size = sizeof(sem_t);
void rtos_mutex_init(void *lock)
{
sem_init(lock, 0, 1);
}
int rtos_mutex_lock(void *lock)
{
return sem_wait(lock);
}
int rtos_mutex_unlock(void *lock)
{
return sem_post(lock);
}
/**
* RTOS semaphore operation
*/
const int rtos_semaphore_size = sizeof(sem_t);
void rtos_sem_init(void *sem, int val)
{
sem_init(sem, 0, val);
}
int rtos_sem_up(void *sem)
{
return sem_post(sem);
}
int rtos_sem_down(void *sem)
{
return sem_wait(sem);
}

55
arch/rgmp/src/sigentry.S Normal file
View file

@ -0,0 +1,55 @@
/****************************************************************************
* arch/rgmp/src/sigentry.S
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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.
*
****************************************************************************/
.globl up_sigentry
up_sigentry:
subl $172, %esp # 172 is the size of TrapFrame
pushl %esp
movl %esp, %eax
call up_sigdeliver
addl $8, %esp # skip parameter and current_task
frstor 0(%esp)
addl $108, %esp
popal
popl %es
popl %ds
addl $0x8, %esp # trapno and errcode
iret

View file

@ -1078,6 +1078,17 @@ configs/pjrc-8051
8051 Microcontroller. This port uses the PJRC 87C52 development system
and the SDCC toolchain. This port is not quite ready for prime time.
configs/rgmp
RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
running GPOS and RTOS simultaneously on multi-processor platforms. You can
port your favorite RTOS to RGMP together with an unmodified Linux to form a
hybrid operating system. This makes your application able to use both RTOS
and GPOS feathures.
See http://rgmp.sourceforge.net/wiki/index.php/Main_Page for further
information about RGMP.
configs/sim
A user-mode port of NuttX to the x86 Linux platform is available.
The purpose of this port is primarily to support OS feature development.

11
configs/rgmp/README.txt Executable file
View file

@ -0,0 +1,11 @@
RGMP README File
================
RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
running GPOS and RTOS simultaneously on multi-processor platforms. You can
port your favorite RTOS to RGMP together with an unmodified Linux to form a
hybrid operating system. This makes your application able to use both RTOS
and GPOS feathures.
See http://rgmp.sourceforge.net/wiki/index.php/Main_Page for further
information about RGMP.

View file

@ -0,0 +1,119 @@
############################################################################
# configs/rgmp/default/Make.defs
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
include ${TOPDIR}/.config
RGMPLIBDIR := $(RGMP_INST_DIR)/lib
RGMPINCDIR := $(RGMP_INST_DIR)/include
RGMPLKSCPT := $(RGMP_INST_DIR)/etc/x86.ld
HOSTOS = ${shell uname -o}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -O2 -gstabs
else
ARCHOPTIMIZATION = -O2
endif
ARCHCPUFLAGS = -fno-builtin -nostdinc -fno-stack-protector
ARCHPICFLAGS = -fpic
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHDEFINES =
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include -I$(RGMPINCDIR) \
-I$(TOPDIR)/configs/rgmp/include
ARCHSCRIPT =
CROSSDEV =
CC = $(CROSSDEV)gcc
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) -pipe
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
OBJEXT = .o
LIBEXT = .a
ifeq ($(HOSTOS),Cygwin)
EXEEXT = .exe
else
EXEEXT =
endif
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
LDFLAGS += -g
endif
LDFLAGS += -nostdlib
EXTRA_LIBS =
define PREPROCESS
@echo "CPP: $1->$2"
@$(CPP) $(CPPFLAGS) $1 -o $2
endef
define COMPILE
@echo "CC: $1"
@$(CC) -c $(CFLAGS) $1 -o $2
endef
define ASSEMBLE
@echo "AS: $1"
@$(CC) -c $(AFLAGS) $1 -o $2
endef
define ARCHIVE
echo "AR: $2"; \
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
endef
define CLEAN
@rm -f *.o *.a
endef
MKDEP = $(TOPDIR)/tools/mkdeps.sh
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) -pipe
HOSTLDFLAGS =

View file

@ -0,0 +1,39 @@
############################################################################
# configs/sim/default/appconfig
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
# Path to example in apps/examples containing the user_start entry point
CONFIGURED_APPS += examples/rgmp

View file

@ -0,0 +1,393 @@
############################################################################
# configs/rgmp/default/defconfig
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
#
# Architecture selection
#
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
# processor architecture.
# CONFIG_ARCH_name - for use in C code. This identifies the particular
# processor architecture (CONFIG_ARCH_SIM).
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
# the board that supports the particular chip or SoC.
# CONFIG_ARCH_BOARD_name - for use in C code
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
#
CONFIG_ARCH=rgmp
CONFIG_ARCH_RGMP=y
CONFIG_ARCH_BOARD=rgmp
CONFIG_ARCH_BOARD_RGMP=y
#
# General OS setup
#
# CONFIG_APPS_DIR - Identifies the relative path to the directory
# that builds the application to link with NuttX. Default: ../apps
# CONFIG_DEBUG - enables built-in debug options
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
# CONFIG_DEBUG_SYMBOLS - build without optimization and with
# debug symbols (needed for use with a debugger).
# CONFIG_MM_REGIONS - If the architecture includes multiple
# regions of memory to allocate from, this specifies the
# number of memory regions that the memory manager must
# handle and enables the API mm_addregion(start, end);
# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot
# time console output
# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz
# or MSEC_PER_TICK=10. This setting may be defined to
# inform NuttX that the processor hardware is providing
# system timer interrupts at some interrupt interval other
# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
# scheduler to monitor system performance
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
# task name to save in the TCB. Useful if scheduler
# instrumentation is selected. Set to zero to disable.
# CONFIG_JULIAN_TIME - Enables Julian time conversions
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
# Used to initialize the internal time logic.
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
# provides /dev/console. Enables stdout, stderr, stdin.
# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console
# driver (minimul support)
# CONFIG_MUTEX_TYPES: Set to enable support for recursive and
# errorcheck mutexes. Enables pthread_mutexattr_settype().
# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority
# inheritance on mutexes and semaphores.
# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority
# inheritance is enabled. It defines the maximum number of
# different threads (minus one) that can take counts on a
# semaphore with priority inheritance support. This may be
# set to zero if priority inheritance is disabled OR if you
# are only using semaphores as mutexes (only one holder) OR
# if no more than two threads participate using a counting
# semaphore.
# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled,
# then this setting is the maximum number of higher priority
# threads (minus 1) than can be waiting for another thread
# to release a count on a semaphore. This value may be set
# to zero if no more than one thread is expected to wait for
# a semaphore.
# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors
# by task_create() when a new task is started. If set, all
# files/drivers will appear to be closed in the new task.
# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first
# three file descriptors (stdin, stdout, stderr) by task_create()
# when a new task is started. If set, all files/drivers will
# appear to be closed in the new task except for stdin, stdout,
# and stderr.
# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket
# desciptors by task_create() when a new task is started. If
# set, all sockets will appear to be closed in the new task.
#
#CONFIG_APPS_DIR=
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
CONFIG_MSEC_PER_TICK=1
CONFIG_RR_INTERVAL=0
CONFIG_SCHED_INSTRUMENTATION=n
CONFIG_TASK_NAME_SIZE=32
CONFIG_START_YEAR=2007
CONFIG_START_MONTH=2
CONFIG_START_DAY=27
CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y
CONFIG_DEV_LOWCONSOLE=n
CONFIG_MUTEX_TYPES=n
CONFIG_PRIORITY_INHERITANCE=n
CONFIG_SEM_PREALLOCHOLDERS=0
CONFIG_SEM_NNESTPRIO=0
CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
#
# The following can be used to disable categories of
# APIs supported by the OS. If the compiler supports
# weak functions, then it should not be necessary to
# disable functions unless you want to restrict usage
# of those APIs.
#
# There are certain dependency relationships in these
# features.
#
# o mq_notify logic depends on signals to awaken tasks
# waiting for queues to become full or empty.
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
CONFIG_DISABLE_CLOCK=n
CONFIG_DISABLE_POSIX_TIMERS=n
CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
CONFIG_DISABLE_MOUNTPOINT=n
CONFIG_DISABLE_ENVIRON=n
CONFIG_DISABLE_POLL=y
#
# Misc libc settings
#
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
# little smaller if we do not support fieldwidthes
#
CONFIG_NOPRINTF_FIELDWIDTH=n
#
# Allow for architecture optimized implementations
#
# The architecture can provide optimized versions of the
# following to improve sysem performance
#
CONFIG_ARCH_MEMCPY=y
CONFIG_ARCH_MEMCMP=y
CONFIG_ARCH_MEMMOVE=y
CONFIG_ARCH_MEMSET=y
CONFIG_ARCH_STRCMP=y
CONFIG_ARCH_STRCPY=y
CONFIG_ARCH_STRNCPY=y
CONFIG_ARCH_STRLEN=y
CONFIG_ARCH_STRNLEN=y
CONFIG_ARCH_BZERO=n
#
# General build options
#
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com using the tools/mkimage.sh script
# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format
# used with many different loaders using the GNU objcopy program
# Should not be selected if you are not using the GNU toolchain.
# CONFIG_RAW_BINARY - make a raw binary format file used with many
# different loaders using the GNU objcopy program. This option
# should not be selected if you are not using the GNU toolchain.
# CONFIG_HAVE_LIBM - toolchain supports libm.a
#
CONFIG_RRLOAD_BINARY=n
CONFIG_INTELHEX_BINARY=n
CONFIG_RAW_BINARY=n
CONFIG_HAVE_LIBM=n
#
# Sizes of configurable things (0 disables)
#
# CONFIG_MAX_TASKS - The maximum number of simultaneously
# active tasks. This value must be a power of two.
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
# of parameters that a task may receive (i.e., maxmum value
# of 'argc')
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
# descriptors (one for each open)
# CONFIG_NFILE_STREAMS - The maximum number of streams that
# can be fopen'ed
# CONFIG_NAME_MAX - The maximum size of a file name.
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_NUNGET_CHARS - Number of characters that can be
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
# structures. The system manages a pool of preallocated
# message structures to minimize dynamic allocations
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
# timer structures. The system manages a pool of preallocated
# timer structures to minimize dynamic allocations. Set to
# zero for all dynamic allocations.
#
CONFIG_MAX_TASKS=64
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
CONFIG_NAME_MAX=32
CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
CONFIG_PREALLOC_TIMERS=8
#
# FAT filesystem configuration
# CONFIG_FS_FAT - Enable FAT filesystem support
# CONFIG_FAT_SECTORSIZE - Max supported sector size
# CONFIG_FS_ROMFS - Enable ROMFS filesystem support
CONFIG_FS_FAT=n
CONFIG_FS_ROMFS=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
# CONFIG_NET_IPv6 - Build in support for IPv6
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
# CONFIG_NET_BUFSIZE - uIP buffer size
# CONFIG_NET_TCP - TCP support on or off
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
# CONFIG_NET_ICMP - ICMP ping response support on or off
# CONFIG_NET_ICMP_PING - ICMP ping request support on or off
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
# CONFIG_NET_STATISTICS - uIP statistics on or off
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
# CONFIG_NET_BROADCAST - Broadcast support
# CONFIG_NET_LLH_LEN - The link level header length
# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
CONFIG_NET=y
CONFIG_NET_IPv6=n
CONFIG_NSOCKET_DESCRIPTORS=5
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=1514
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
#CONFIG_NET_UDP_CONNS=10
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_PING=y
#CONFIG_NET_PINGADDRCONF=0
CONFIG_NET_STATISTICS=y
#CONFIG_NET_RECEIVE_WINDOW=128
#CONFIG_NET_ARPTAB_SIZE=8
CONFIG_NET_BROADCAST=n
#CONFIG_NET_LLH_LEN=14
#CONFIG_NET_FWCACHE_SIZE=2
#
# UIP Network Utilities
# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
CONFIG_NET_DHCP_LIGHT=n
CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/uip
CONFIG_EXAMPLE_UIP_IPADDR=(192<<24|168<<16|10<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|10<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n
#
# Settings for examples/nettest
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=n
CONFIG_EXAMPLE_NETTEST_IPADDR=(192<<24|168<<16|0<<8|128)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106)
#
# Settings for examples/nsh
CONFIG_EXAMPLES_NSH_CONSOLE=y
CONFIG_EXAMPLES_NSH_TELNET=n
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
CONFIG_EXAMPLES_NSH_STACKSIZE=4096
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
#
# Stack and heap information
#
# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP
# operation from FLASH but must copy initialized .data sections to RAM.
# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH
# but copy themselves entirely into RAM for better performance.
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
# all stack operations outside of the nuttx model.
# CONFIG_STACK_POINTER - The initial stack pointer
# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack.
# This is the thread that (1) performs the inital boot of the system up
# to the point where user_start() is spawned, and (2 after is the
# IDLE thread that executes only when there is no other thread ready to
# run.
# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate
# for the main user thread that begins at the user_start() entry point.
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
# CONFIG_HEAP_BASE - The beginning of the heap
# CONFIG_HEAP_SIZE - The size of the heap
#
CONFIG_BOOT_RUNFROMFLASH=n
CONFIG_BOOT_COPYTORAM=n
CONFIG_CUSTOM_STACK=n
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_USERMAIN_STACKSIZE=4096
CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=8192
CONFIG_HEAP_BASE=
CONFIG_HEAP_SIZE=
#
# RGMP specific configuration
#
CONFIG_NET_VNET=y
CONFIG_VNET_NINTERFACES=1
CONFIG_COM1=y
CONFIG_COM2=y
CONFIG_COM3=n
CONFIG_COM4=n
CONFIG_E1000=n

47
configs/rgmp/default/setenv.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# config/rgmp/default/setenv.sh
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
if [ "$(basename $0)" = "setenv.sh" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
#export NUTTX_BIN=
#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
echo "PATH : ${PATH}"

View file

@ -0,0 +1 @@
This directory is reserved for RGMP header files

23
configs/rgmp/include/stdarg.h Executable file
View file

@ -0,0 +1,23 @@
#ifndef _RGMP_STDARG_H
#define _RGMP_STDARG_H
typedef char *va_list;
#define __va_size(type) \
(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#ifndef va_start
#define va_start(ap, last) \
((ap) = (va_list)&(last) + __va_size(last))
#endif
#ifndef va_arg
#define va_arg(ap, type) \
(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#endif
#ifndef va_end
#define va_end(ap) ((void)0)
#endif
#endif

119
configs/rgmp/nsh/Make.defs Normal file
View file

@ -0,0 +1,119 @@
############################################################################
# configs/rgmp/nsh/Make.defs
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
include ${TOPDIR}/.config
RGMPLIBDIR := $(RGMP_INST_DIR)/lib
RGMPINCDIR := $(RGMP_INST_DIR)/include
RGMPLKSCPT := $(RGMP_INST_DIR)/etc/x86.ld
HOSTOS = ${shell uname -o}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -O2 -gstabs
else
ARCHOPTIMIZATION = -O2
endif
ARCHCPUFLAGS = -fno-builtin -nostdinc -fno-stack-protector
ARCHPICFLAGS = -fpic
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHDEFINES =
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include -I$(RGMPINCDIR) \
-I$(TOPDIR)/configs/rgmp/include
ARCHSCRIPT =
CROSSDEV =
CC = $(CROSSDEV)gcc
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) -pipe
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
OBJEXT = .o
LIBEXT = .a
ifeq ($(HOSTOS),Cygwin)
EXEEXT = .exe
else
EXEEXT =
endif
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
LDFLAGS += -g
endif
LDFLAGS += -nostdlib
EXTRA_LIBS =
define PREPROCESS
@echo "CPP: $1->$2"
@$(CPP) $(CPPFLAGS) $1 -o $2
endef
define COMPILE
@echo "CC: $1"
@$(CC) -c $(CFLAGS) $1 -o $2
endef
define ASSEMBLE
@echo "AS: $1"
@$(CC) -c $(AFLAGS) $1 -o $2
endef
define ARCHIVE
echo "AR: $2"; \
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
endef
define CLEAN
@rm -f *.o *.a
endef
MKDEP = $(TOPDIR)/tools/mkdeps.sh
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) -pipe
HOSTLDFLAGS =

View file

@ -0,0 +1,43 @@
############################################################################
# configs/rgmp/nsh/appconfig
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
# Path to example in apps/examples containing the user_start entry point
CONFIGURED_APPS += examples/nsh
# The NSH Library
CONFIGURED_APPS += nshlib

394
configs/rgmp/nsh/defconfig Normal file
View file

@ -0,0 +1,394 @@
############################################################################
# configs/rgmp/nsh/defconfig
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
############################################################################
#
# Architecture selection
#
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
# processor architecture.
# CONFIG_ARCH_name - for use in C code. This identifies the particular
# processor architecture (CONFIG_ARCH_SIM).
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
# the board that supports the particular chip or SoC.
# CONFIG_ARCH_BOARD_name - for use in C code
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
#
CONFIG_ARCH=rgmp
CONFIG_ARCH_RGMP=y
CONFIG_ARCH_BOARD=rgmp
CONFIG_ARCH_BOARD_RGMP=y
#
# General OS setup
#
# CONFIG_APPS_DIR - Identifies the relative path to the directory
# that builds the application to link with NuttX. Default: ../apps
# CONFIG_DEBUG - enables built-in debug options
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
# CONFIG_DEBUG_SYMBOLS - build without optimization and with
# debug symbols (needed for use with a debugger).
# CONFIG_MM_REGIONS - If the architecture includes multiple
# regions of memory to allocate from, this specifies the
# number of memory regions that the memory manager must
# handle and enables the API mm_addregion(start, end);
# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot
# time console output
# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz
# or MSEC_PER_TICK=10. This setting may be defined to
# inform NuttX that the processor hardware is providing
# system timer interrupts at some interrupt interval other
# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
# scheduler to monitor system performance
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
# task name to save in the TCB. Useful if scheduler
# instrumentation is selected. Set to zero to disable.
# CONFIG_JULIAN_TIME - Enables Julian time conversions
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
# Used to initialize the internal time logic.
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
# provides /dev/console. Enables stdout, stderr, stdin.
# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console
# driver (minimul support)
# CONFIG_MUTEX_TYPES: Set to enable support for recursive and
# errorcheck mutexes. Enables pthread_mutexattr_settype().
# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority
# inheritance on mutexes and semaphores.
# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority
# inheritance is enabled. It defines the maximum number of
# different threads (minus one) that can take counts on a
# semaphore with priority inheritance support. This may be
# set to zero if priority inheritance is disabled OR if you
# are only using semaphores as mutexes (only one holder) OR
# if no more than two threads participate using a counting
# semaphore.
# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled,
# then this setting is the maximum number of higher priority
# threads (minus 1) than can be waiting for another thread
# to release a count on a semaphore. This value may be set
# to zero if no more than one thread is expected to wait for
# a semaphore.
# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors
# by task_create() when a new task is started. If set, all
# files/drivers will appear to be closed in the new task.
# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first
# three file descriptors (stdin, stdout, stderr) by task_create()
# when a new task is started. If set, all files/drivers will
# appear to be closed in the new task except for stdin, stdout,
# and stderr.
# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket
# desciptors by task_create() when a new task is started. If
# set, all sockets will appear to be closed in the new task.
#
#CONFIG_APPS_DIR=
CONFIG_DEBUG=y
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=y
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
CONFIG_MSEC_PER_TICK=1
CONFIG_RR_INTERVAL=0
CONFIG_SCHED_INSTRUMENTATION=n
CONFIG_TASK_NAME_SIZE=32
CONFIG_START_YEAR=2007
CONFIG_START_MONTH=2
CONFIG_START_DAY=27
CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y
CONFIG_DEV_LOWCONSOLE=n
CONFIG_MUTEX_TYPES=n
CONFIG_PRIORITY_INHERITANCE=n
CONFIG_SEM_PREALLOCHOLDERS=0
CONFIG_SEM_NNESTPRIO=0
CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
#
# The following can be used to disable categories of
# APIs supported by the OS. If the compiler supports
# weak functions, then it should not be necessary to
# disable functions unless you want to restrict usage
# of those APIs.
#
# There are certain dependency relationships in these
# features.
#
# o mq_notify logic depends on signals to awaken tasks
# waiting for queues to become full or empty.
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
CONFIG_DISABLE_CLOCK=n
CONFIG_DISABLE_POSIX_TIMERS=n
CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
CONFIG_DISABLE_MOUNTPOINT=n
CONFIG_DISABLE_ENVIRON=n
CONFIG_DISABLE_POLL=y
#
# Misc libc settings
#
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
# little smaller if we do not support fieldwidthes
#
CONFIG_NOPRINTF_FIELDWIDTH=n
#
# Allow for architecture optimized implementations
#
# The architecture can provide optimized versions of the
# following to improve sysem performance
#
CONFIG_ARCH_MEMCPY=y
CONFIG_ARCH_MEMCMP=y
CONFIG_ARCH_MEMMOVE=y
CONFIG_ARCH_MEMSET=y
CONFIG_ARCH_STRCMP=y
CONFIG_ARCH_STRCPY=y
CONFIG_ARCH_STRNCPY=y
CONFIG_ARCH_STRLEN=y
CONFIG_ARCH_STRNLEN=y
CONFIG_ARCH_BZERO=n
#
# General build options
#
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com using the tools/mkimage.sh script
# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format
# used with many different loaders using the GNU objcopy program
# Should not be selected if you are not using the GNU toolchain.
# CONFIG_RAW_BINARY - make a raw binary format file used with many
# different loaders using the GNU objcopy program. This option
# should not be selected if you are not using the GNU toolchain.
# CONFIG_HAVE_LIBM - toolchain supports libm.a
#
CONFIG_RRLOAD_BINARY=n
CONFIG_INTELHEX_BINARY=n
CONFIG_RAW_BINARY=n
CONFIG_HAVE_LIBM=n
#
# Sizes of configurable things (0 disables)
#
# CONFIG_MAX_TASKS - The maximum number of simultaneously
# active tasks. This value must be a power of two.
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
# of parameters that a task may receive (i.e., maxmum value
# of 'argc')
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
# descriptors (one for each open)
# CONFIG_NFILE_STREAMS - The maximum number of streams that
# can be fopen'ed
# CONFIG_NAME_MAX - The maximum size of a file name.
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_NUNGET_CHARS - Number of characters that can be
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
# structures. The system manages a pool of preallocated
# message structures to minimize dynamic allocations
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
# timer structures. The system manages a pool of preallocated
# timer structures to minimize dynamic allocations. Set to
# zero for all dynamic allocations.
#
CONFIG_MAX_TASKS=64
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
CONFIG_NAME_MAX=32
CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
CONFIG_PREALLOC_TIMERS=8
#
# FAT filesystem configuration
# CONFIG_FS_FAT - Enable FAT filesystem support
# CONFIG_FAT_SECTORSIZE - Max supported sector size
# CONFIG_FS_ROMFS - Enable ROMFS filesystem support
CONFIG_FS_FAT=n
CONFIG_FS_ROMFS=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
# CONFIG_NET_IPv6 - Build in support for IPv6
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
# CONFIG_NET_BUFSIZE - uIP buffer size
# CONFIG_NET_TCP - TCP support on or off
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
# CONFIG_NET_ICMP - ICMP ping response support on or off
# CONFIG_NET_ICMP_PING - ICMP ping request support on or off
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
# CONFIG_NET_STATISTICS - uIP statistics on or off
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
# CONFIG_NET_BROADCAST - Broadcast support
# CONFIG_NET_LLH_LEN - The link level header length
# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
CONFIG_NET=y
CONFIG_NET_IPv6=n
CONFIG_NSOCKET_DESCRIPTORS=5
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=1514
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
#CONFIG_NET_UDP_CONNS=10
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_PING=y
#CONFIG_NET_PINGADDRCONF=0
CONFIG_NET_STATISTICS=y
CONFIG_NET_RECEIVE_WINDOW=128
CONFIG_NET_ARPTAB_SIZE=8
CONFIG_NET_BROADCAST=n
#CONFIG_NET_LLH_LEN=14
#CONFIG_NET_FWCACHE_SIZE=2
#
# UIP Network Utilities
# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
CONFIG_NET_DHCP_LIGHT=n
CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/uip
CONFIG_EXAMPLE_UIP_IPADDR=(192<<24|168<<16|0<<8|128)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|0<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n
#
# Settings for examples/nettest
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=n
CONFIG_EXAMPLE_NETTEST_IPADDR=(192<<24|168<<16|0<<8|128)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106)
#
# Settings for apps/nshlib
#
CONFIG_EXAMPLES_NSH_CONSOLE=y
CONFIG_EXAMPLES_NSH_TELNET=n
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
CONFIG_EXAMPLES_NSH_STACKSIZE=4096
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(192<<24|168<<16|10<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(192<<24|168<<16|10<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
#
# Stack and heap information
#
# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP
# operation from FLASH but must copy initialized .data sections to RAM.
# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH
# but copy themselves entirely into RAM for better performance.
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
# all stack operations outside of the nuttx model.
# CONFIG_STACK_POINTER - The initial stack pointer
# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack.
# This is the thread that (1) performs the inital boot of the system up
# to the point where user_start() is spawned, and (2 after is the
# IDLE thread that executes only when there is no other thread ready to
# run.
# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate
# for the main user thread that begins at the user_start() entry point.
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
# CONFIG_HEAP_BASE - The beginning of the heap
# CONFIG_HEAP_SIZE - The size of the heap
#
CONFIG_BOOT_RUNFROMFLASH=n
CONFIG_BOOT_COPYTORAM=n
CONFIG_CUSTOM_STACK=n
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_USERMAIN_STACKSIZE=4096
CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=8192
CONFIG_HEAP_BASE=
CONFIG_HEAP_SIZE=
#
# RGMP specific configuration
#
CONFIG_NET_VNET=y
CONFIG_VNET_NINTERFACES=1
CONFIG_COM1=y
CONFIG_COM2=y
CONFIG_COM3=n
CONFIG_COM4=n
CONFIG_E1000=n

47
configs/rgmp/nsh/setenv.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# config/rgmp/nsh/setenv.sh
#
# Copyright (C) 2011 Yu Qiang. All rights reserved.
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Authors: Yu Qiang <yuq825@gmail.com>
# Gregory Nutt <spudmonkey@racsa.co.cr>
#
# 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.
#
if [ "$(basename $0)" = "setenv.sh" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
#export NUTTX_BIN=
#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
echo "PATH : ${PATH}"

1
configs/rgmp/src/README.txt Executable file
View file

@ -0,0 +1 @@
This directory is reserved for RGMP source files

View file

@ -46,6 +46,9 @@ endif
ifeq ($(CONFIG_NET_ENC28J60),y)
NET_CSRCS += enc28j60.c
endif
ifeq ($(CONFIG_NET_VNET),y)
NET_CSRCS += vnet.c
endif
ifeq ($(CONFIG_NET_SLIP),y)
NET_CSRCS += slip.c
endif

View file

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/net/cs89x0.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -551,7 +551,7 @@ static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq)
return g_cs89x0[i];
}
}
return NULL'
return NULL;
}
#endif

674
drivers/net/vnet.c Normal file
View file

@ -0,0 +1,674 @@
/****************************************************************************
* drivers/net/vnet.c
*
* Copyright (C) 2011 Yu Qiang. All rights reserved.
* Author: Yu Qiang <yuq825@gmail.com>
*
* This file is a part of NuttX:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* 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 <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_VNET)
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <string.h>
#include <debug.h>
#include <wdog.h>
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arp.h>
#include <net/uip/uip-arch.h>
#include <rgmp/vnet.h>
#include <rgmp/stdio.h>
/****************************************************************************
* Definitions
****************************************************************************/
/* CONFIG_VNET_NINTERFACES determines the number of physical interfaces
* that will be supported.
*/
#ifndef CONFIG_VNET_NINTERFACES
# define CONFIG_VNET_NINTERFACES 1
#endif
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define VNET_WDDELAY (1*CLK_TCK)
#define VNET_POLLHSEC (1*2)
/* TX timeout = 1 minute */
#define VNET_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */
#define BUF ((struct uip_eth_hdr *)vnet->sk_dev.d_buf)
/****************************************************************************
* Private Types
****************************************************************************/
/* The vnet_driver_s encapsulates all state information for a single hardware
* interface
*/
struct vnet_driver_s
{
bool sk_bifup; /* true:ifup false:ifdown */
WDOG_ID sk_txpoll; /* TX poll timer */
//WDOG_ID sk_txtimeout; /* TX timeout timer */
/* This holds the information visible to uIP/NuttX */
struct rgmp_vnet *vnet;
struct uip_driver_s sk_dev; /* Interface understood by uIP */
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct vnet_driver_s g_vnet[CONFIG_VNET_NINTERFACES];
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* Common TX logic */
static int vnet_transmit(FAR struct vnet_driver_s *vnet);
static int vnet_uiptxpoll(struct uip_driver_s *dev);
/* Interrupt handling */
static void vnet_receive(FAR struct vnet_driver_s *vnet);
static void vnet_txdone(FAR struct vnet_driver_s *vnet);
/* Watchdog timer expirations */
static void vnet_polltimer(int argc, uint32_t arg, ...);
static void vnet_txtimeout(int argc, uint32_t arg, ...);
/* NuttX callback functions */
static int vnet_ifup(struct uip_driver_s *dev);
static int vnet_ifdown(struct uip_driver_s *dev);
static int vnet_txavail(struct uip_driver_s *dev);
#ifdef CONFIG_NET_IGMP
static int vnet_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac);
static int vnet_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac);
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Function: vnet_transmit
*
* Description:
* Start hardware transmission. Called either from the txdone interrupt
* handling or from watchdog based polling.
*
* Parameters:
* vnet - Reference to the driver state structure
*
* Returned Value:
* OK on success; a negated errno on failure
*
* Assumptions:
* May or may not be called from an interrupt handler. In either case,
* global interrupts are disabled, either explicitly or indirectly through
* interrupt handling logic.
*
****************************************************************************/
static int vnet_transmit(FAR struct vnet_driver_s *vnet)
{
int err;
/* Verify that the hardware is ready to send another packet. If we get
* here, then we are committed to sending a packet; Higher level logic
* must have assured that there is not transmission in progress.
*/
/* Increment statistics */
/* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
if (err) {
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
//(void)wd_start(vnet->sk_txtimeout, VNET_TXTIMEOUT, vnet_txtimeout, 1, (uint32_t)vnet);
// When vnet_xmit fail, it means TX buffer is full. Watchdog
// is of no use here because no TX done INT will happen. So
// we reset the TX buffer directly.
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
#endif
return ERROR;
}
else {
// this step may be unnecessary here
vnet_txdone(vnet);
}
return OK;
}
/****************************************************************************
* Function: vnet_uiptxpoll
*
* Description:
* The transmitter is available, check if uIP has any outgoing packets ready
* to send. This is a callback from uip_poll(). uip_poll() may be called:
*
* 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset
* 3. During normal TX polling
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* OK on success; a negated errno on failure
*
* Assumptions:
* May or may not be called from an interrupt handler. In either case,
* global interrupts are disabled, either explicitly or indirectly through
* interrupt handling logic.
*
****************************************************************************/
static int vnet_uiptxpoll(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
if (vnet->sk_dev.d_len > 0)
{
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
/* Check if there is room in the device to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
if (vnet_is_txbuff_full(vnet->vnet))
return 1;
}
/* If zero is returned, the polling will continue until all connections have
* been examined.
*/
return 0;
}
/****************************************************************************
* Function: vnet_receive
*
* Description:
* An interrupt was received indicating the availability of a new RX packet
*
* Parameters:
* vnet - Reference to the driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Global interrupts are disabled by interrupt handling logic.
*
****************************************************************************/
void rtos_vnet_recv(struct rgmp_vnet *vnet_dummy, char *data, int len)
{
// now only support 1 vnet
struct vnet_driver_s *vnet = &g_vnet[0];
do {
/* Check for errors and update statistics */
/* Check if the packet is a valid size for the uIP buffer configuration */
if (len > CONFIG_NET_BUFSIZE || len < 14) {
#ifdef CONFIG_DEBUG
cprintf("VNET: receive invalid packet of size %d\n", len);
#endif
return;
}
// Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
// amount of data in vnet->sk_dev.d_len
memcpy(vnet->sk_dev.d_buf, data, len);
vnet->sk_dev.d_len = len;
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
#else
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
{
uip_arp_ipin(&vnet->sk_dev);
uip_input(&vnet->sk_dev);
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin(&vnet->sk_dev);
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
vnet_transmit(vnet);
}
}
}
while (0); /* While there are more packets to be processed */
}
/****************************************************************************
* Function: vnet_txdone
*
* Description:
* An interrupt was received indicating that the last TX packet(s) is done
*
* Parameters:
* vnet - Reference to the driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Global interrupts are disabled by the watchdog logic.
*
****************************************************************************/
static void vnet_txdone(FAR struct vnet_driver_s *vnet)
{
/* Check for errors and update statistics */
/* If no further xmits are pending, then cancel the TX timeout and
* disable further Tx interrupts.
*/
//wd_cancel(vnet->sk_txtimeout);
/* Then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
/****************************************************************************
* Function: vnet_txtimeout
*
* Description:
* Our TX watchdog timed out. Called from the timer interrupt handler.
* The last TX never completed. Reset the hardware and start again.
*
* Parameters:
* argc - The number of available arguments
* arg - The first argument
*
* Returned Value:
* None
*
* Assumptions:
* Global interrupts are disabled by the watchdog logic.
*
****************************************************************************/
static void vnet_txtimeout(int argc, uint32_t arg, ...)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
/* Increment statistics and dump debug info */
/* Then reset the hardware */
/* Then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
/****************************************************************************
* Function: vnet_polltimer
*
* Description:
* Periodic timer handler. Called from the timer interrupt handler.
*
* Parameters:
* argc - The number of available arguments
* arg - The first argument
*
* Returned Value:
* None
*
* Assumptions:
* Global interrupts are disabled by the watchdog logic.
*
****************************************************************************/
static void vnet_polltimer(int argc, uint32_t arg, ...)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
if (vnet_is_txbuff_full(vnet->vnet)) {
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
#endif
return;
}
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
*/
(void)uip_timer(&vnet->sk_dev, vnet_uiptxpoll, VNET_POLLHSEC);
/* Setup the watchdog poll timer again */
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, arg);
}
/****************************************************************************
* Function: vnet_ifup
*
* Description:
* NuttX Callback: Bring up the Ethernet interface when an IP address is
* provided
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
static int vnet_ifup(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
ndbg("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
/* Set and activate a timer process */
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet);
vnet->sk_bifup = true;
return OK;
}
/****************************************************************************
* Function: vnet_ifdown
*
* Description:
* NuttX Callback: Stop the interface.
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
static int vnet_ifdown(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
/* Disable the Ethernet interrupt */
flags = irqsave();
/* Cancel the TX poll timer and TX timeout timers */
wd_cancel(vnet->sk_txpoll);
//wd_cancel(vnet->sk_txtimeout);
/* Put the the EMAC is its reset, non-operational state. This should be
* a known configuration that will guarantee the vnet_ifup() always
* successfully brings the interface back up.
*/
/* Mark the device "down" */
vnet->sk_bifup = false;
irqrestore(flags);
return OK;
}
/****************************************************************************
* Function: vnet_txavail
*
* Description:
* Driver callback invoked when new TX data is available. This is a
* stimulus perform an out-of-cycle poll and, thereby, reduce the TX
* latency.
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Called in normal user mode
*
****************************************************************************/
static int vnet_txavail(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
flags = irqsave();
/* Ignore the notification if the interface is not yet up */
if (vnet->sk_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
if (vnet_is_txbuff_full(vnet->vnet)) {
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
#endif
goto out;
}
/* If so, then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
out:
irqrestore(flags);
return OK;
}
/****************************************************************************
* Function: vnet_addmac
*
* Description:
* NuttX Callback: Add the specified MAC address to the hardware multicast
* address filtering
*
* Parameters:
* dev - Reference to the NuttX driver state structure
* mac - The MAC address to be added
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
#ifdef CONFIG_NET_IGMP
static int vnet_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
return OK;
}
#endif
/****************************************************************************
* Function: vnet_rmmac
*
* Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast
* address filtering
*
* Parameters:
* dev - Reference to the NuttX driver state structure
* mac - The MAC address to be removed
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
#ifdef CONFIG_NET_IGMP
static int vnet_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Function: vnet_initialize
*
* Description:
* Initialize the Ethernet controller and driver
*
* Parameters:
* intf - In the case where there are multiple EMACs, this value
* identifies which EMAC is to be initialized.
*
* Returned Value:
* OK on success; Negated errno on failure.
*
* Assumptions:
*
****************************************************************************/
void vnet_initialize(void)
{
struct vnet_driver_s *priv;
struct rgmp_vnet *vnet = vnet_list.next;
int i;
for (i=0; i<CONFIG_VNET_NINTERFACES; i++) {
if (vnet == NULL)
break;
priv = &g_vnet[i];
/* Initialize the driver structure */
memset(priv, 0, sizeof(struct vnet_driver_s));
priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
#ifdef CONFIG_NET_IGMP
priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
#endif
priv->sk_dev.d_private = (void*)g_vnet; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmisstions */
priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
//priv->sk_txtimeout = wd_create(); /* Create TX timeout timer */
priv->vnet = vnet;
/* Register the device with the OS */
(void)netdev_register(&priv->sk_dev);
vnet = vnet->next;
}
}
#endif /* CONFIG_NET && CONFIG_NET_VNET */

View file

@ -1,7 +1,7 @@
/************************************************************************************
* drivers/serial/serial.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -169,7 +169,7 @@ static void uart_putxmitchar(FAR uart_dev_t *dev, int ch)
nexthead = 0;
}
for(;;)
for (;;)
{
if (nexthead != dev->xmit.tail)
{
@ -271,7 +271,7 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t
uart_putxmitchar(dev, ch);
/* If this is the console, then we should replace LF with LF-CR */
/* If this is the console, then we should replace LF with LF-CR */
if (dev->isconsole && ch == '\n')
{