From 3306e7be0283dd220a33eb83f88b568b915ea7b8 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 10 Mar 2011 04:13:44 +0000 Subject: Add QEMU NSH configuration git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3358 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/ChangeLog | 3 + nuttx/Documentation/NuttX.html | 5 +- nuttx/arch/x86/src/qemu/qemu_lowsetup.c | 6 + nuttx/arch/x86/src/qemu/qemu_serial.c | 29 +- nuttx/configs/qemu-i486/nsh/Make.defs | 126 +++++++ nuttx/configs/qemu-i486/nsh/defconfig | 541 +++++++++++++++++++++++++++++++ nuttx/configs/qemu-i486/nsh/ld.script | 91 ++++++ nuttx/configs/qemu-i486/nsh/setenv.sh | 48 +++ nuttx/configs/qemu-i486/ostest/Make.defs | 2 +- nuttx/configs/qemu-i486/ostest/defconfig | 10 +- nuttx/configs/qemu-i486/ostest/setenv.sh | 4 +- nuttx/drivers/serial/Make.defs | 7 +- nuttx/drivers/serial/uart_16550.c | 372 ++++++++++++--------- nuttx/include/nuttx/uart_16550.h | 18 +- 14 files changed, 1090 insertions(+), 172 deletions(-) create mode 100644 nuttx/configs/qemu-i486/nsh/Make.defs create mode 100644 nuttx/configs/qemu-i486/nsh/defconfig create mode 100755 nuttx/configs/qemu-i486/nsh/ld.script create mode 100755 nuttx/configs/qemu-i486/nsh/setenv.sh (limited to 'nuttx') diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 3101aa93e..5ad653a30 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1532,3 +1532,6 @@ (and others). Contributed by Uros Platise. * examples/nsh and tools/mkromfsimg.sh -- Add support for platform-specific ROMFS-based NSH start-up scripts. + * drivers/uart_16550.c and include/nuttx/uart_16550.h - Support for a generic + 16550 UART. + * configure/qemu-i486/nsh - QEMU NSH example. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 95b132afa..38e62ec95 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: March 7, 2011

+

Last Updated: March 9, 2011

@@ -2156,6 +2156,9 @@ nuttx-5.19 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> (and others). Contributed by Uros Platise. * examples/nsh and tools/mkromfsimg.sh -- Add support for platform-specific ROMFS-based NSH start-up scripts. + * drivers/uart_16550.c and include/nuttx/uart_16550.h - Support for a generic + 16550 UART. + * configure/qemu-i486/nsh - QEMU NSH example. pascal-2.1 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/arch/x86/src/qemu/qemu_lowsetup.c b/nuttx/arch/x86/src/qemu/qemu_lowsetup.c index bc5aa52e7..20250c33d 100644 --- a/nuttx/arch/x86/src/qemu/qemu_lowsetup.c +++ b/nuttx/arch/x86/src/qemu/qemu_lowsetup.c @@ -127,6 +127,12 @@ void up_lowsetup(void) up_gdtinit(); + /* Early serial driver initialization */ + +#ifdef CONFIG_USE_EARLYSERIALINIT + up_earlyserialinit(); +#endif + /* Now perform board-specific initializations */ up_boardinitialize(); diff --git a/nuttx/arch/x86/src/qemu/qemu_serial.c b/nuttx/arch/x86/src/qemu/qemu_serial.c index 743ccb691..527ca0c05 100644 --- a/nuttx/arch/x86/src/qemu/qemu_serial.c +++ b/nuttx/arch/x86/src/qemu/qemu_serial.c @@ -40,10 +40,18 @@ #include #include +#include + +#include + #include "up_internal.h" +/* This is a "stub" file to suppport up_putc if no real serial driver is + * configured. Normally, drivers/serial/uart_16550.c provides the serial + * driver for this platform. + */ + #ifdef CONFIG_USE_SERIALDRIVER -#error "Serial driver support not initialized" /**************************************************************************** * Pre-processor Definitions @@ -61,6 +69,25 @@ * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: uart_getreg(), uart_putreg() + * + * Description: + * These functions must be provided by the processor-specific code in order + * to correctly access 16550 registers + * + ****************************************************************************/ + +uart_datawidth_t uart_getreg(uart_addrwidth_t base, unsigned int offset) +{ + return inb(base + offset); +} + +void uart_putreg(uart_addrwidth_t base, unsigned int offset, uart_datawidth_t value) +{ + outb(value, base + offset); +} + #else /* CONFIG_USE_SERIALDRIVER */ /**************************************************************************** diff --git a/nuttx/configs/qemu-i486/nsh/Make.defs b/nuttx/configs/qemu-i486/nsh/Make.defs new file mode 100644 index 000000000..1e17529c5 --- /dev/null +++ b/nuttx/configs/qemu-i486/nsh/Make.defs @@ -0,0 +1,126 @@ +############################################################################ +# configs/qemu-i486/nsh/Make.defs +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config + +HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = -O2 +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/winlink.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/ld.script}" + MAXOPTIMIZATION = -O2 +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/ld.script +endif + +ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin +ARCHPICFLAGS = -fpic +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHDEFINES = + +# We have to use a cross-development toolchain under Cygwin because the native +# Cygwin toolchains don't generate ELF binaries. + +ifeq ($(HOSTOS),Cygwin) +CROSSDEV = i486-elf- +else +CROSSDEV = +endif + +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 +EXEEXT = .elf + +ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") + LDFLAGS += -g +endif + +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 +HOSTINCLUDESv = -I. +HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) -pipe +HOSTLDFLAGS = diff --git a/nuttx/configs/qemu-i486/nsh/defconfig b/nuttx/configs/qemu-i486/nsh/defconfig new file mode 100644 index 000000000..8244e35bc --- /dev/null +++ b/nuttx/configs/qemu-i486/nsh/defconfig @@ -0,0 +1,541 @@ +############################################################################ +# configs/qemu-i486/nsh/defconfig +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +# +# Architecture selection +# +# CONFIG_ARCH - identifies the arch subdirectory and, hence, the +# processor architecture. +# CONFIG_ARCH_architecture - for use in C code. This identifies the +# specific architecture within the chip familyl. +# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory +# CONFIG_ARCH_CHIP_name - For use in C code +# 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_BOARD_LOOPSPERMSEC - for delay loops +# CONFIG_DRAM_SIZE - Describes the installed DRAM. +# CONFIG_DRAM_START - The start address of DRAM (physical) +# CONFIG_DRAM_END - Last address+1 of installed RAM +# CONFIG_ARCH_NOINTC - define if the architecture does not +# support an interrupt controller or otherwise cannot support +# APIs like up_enable_irq() and up_disable_irq(). +# CONFIG_ARCH_IRQPRIO - Set if the architecture supports interrupt prioritization +# CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt +# stack. If defined, this symbol is the size of the interrupt +# stack in bytes. If not defined, the user task stacks will be +# used during interrupt handling. +# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions +# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader. +# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture. +# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture. +# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that +# cause a 100 second delay during boot-up. This 100 second delay +# serves no purpose other than it allows you to calibrate +# CONFIG_BOARD_LOOPSPERMSEC. You simply use a stop watch to measure +# the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until +# the delay actually is 100 seconds. +# CONFIG_ARCH_DMA - Support DMA initialization +# +CONFIG_ARCH=x86 +CONFIG_ARCH_X86=y +CONFIG_ARCH_I486=y +CONFIG_ARCH_CHIP=qemu +CONFIG_ARCH_CHIP_QEMU=y +CONFIG_ARCH_BOARD=qemu-i486 +CONFIG_ARCH_BOARD_QEMU_I486=y +CONFIG_BOARD_LOOPSPERMSEC=999 +CONFIG_DRAM_SIZE=0x00100000 +CONFIG_DRAM_START=0x00100000 +CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE) +CONFIG_ARCH_NOINTC=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_LEDS=n +CONFIG_ARCH_BUTTONS=n +CONFIG_ARCH_CALIBRATION=n +CONFIG_ARCH_DMA=n + +# +# 16550 UART Settings +# +# CONFIG_16550_UART - Enable 16550 UART support +# CONFIG_16550_REGINCR - Address increment between registers (1, 2, or 4) +# CONFIG_16550_REGWIDTH - Width of a register in bits (8, 16, or 32) +# CONFIG_16550_ADDRWIDTH - Width of register address in bytes (8, 16, or 32) +# CONFIG_16550_UARTn - 'y' to enable UARTn +# CONFIG_16550_UARTn_BASE - Base address for UARTn +# CONFIG_16550_UARTn_CLOCK - Input clock for UARTn +# CONFIG_16550_UARTn_IRQ - IRQ for UARTn +# +CONFIG_16550_UART=y +CONFIG_16550_REGINCR=1 +CONFIG_16550_REGWIDTH=8 +CONFIG_16550_ADDRWIDTH=16 +CONFIG_16550_SUPRESS_CONFIG=y +CONFIG_SUPPRESS_SERIAL_INTS=n +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x3f8 +CONFIG_16550_UART0_CLOCK=16000000 +CONFIG_16550_UART0_IRQ=IRQ4 +CONFIG_16550_UART1=n +CONFIG_16550_UART1_BASE=0x2f8 +CONFIG_16550_UART1_CLOCK=16000000 +CONFIG_16550_UART1_IRQ=IRQ3 +CONFIG_16550_UART2=n +CONFIG_16550_UART2_BASE=0x3e8 +CONFIG_16550_UART2_CLOCK=16000000 +CONFIG_16550_UART2_IRQ=IRQ4 +CONFIG_16550_UART3=n +CONFIG_16550_UART3_BASE=0x2e8 +CONFIG_16550_UART3_CLOCK=16000000 +CONFIG_16550_UART3_IRQ=IRQ3 + +# +# Serial device driver settings +# +# CONFIG_UARTn_SERIAL_CONSOLE - selects the UARTn for the +# console and ttys0 (default is the UART1). +# CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received. +# This specific the size of the receive buffer +# CONFIG_UARTn_TXBUFSIZE - Characters are buffered before +# being sent. This specific the size of the transmit buffer +# CONFIG_UARTn_BAUD - The configure BAUD of the UART. Must be +# CONFIG_UARTn_BITS - The number of bits. Must be either 7 or 8. +# CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity +# CONFIG_UARTn_2STOP - Two stop bits +# +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_UART1_SERIAL_CONSOLE=n +CONFIG_UART2_SERIAL_CONSOLE=n +CONFIG_UART3_SERIAL_CONSOLE=n + +CONFIG_UART0_TXBUFSIZE=256 +CONFIG_UART1_TXBUFSIZE=256 +CONFIG_UART2_TXBUFSIZE=256 +CONFIG_UART3_TXBUFSIZE=256 + +CONFIG_UART0_RXBUFSIZE=256 +CONFIG_UART1_RXBUFSIZE=256 +CONFIG_UART2_RXBUFSIZE=256 +CONFIG_UART3_RXBUFSIZE=256 + +CONFIG_UART0_BAUD=57600 +CONFIG_UART2_BAUD=57600 +CONFIG_UART3_BAUD=57600 +CONFIG_UART1_BAUD=57600 + +CONFIG_UART0_BITS=8 +CONFIG_UART1_BITS=8 +CONFIG_UART2_BITS=8 +CONFIG_UART3_BITS=8 + +CONFIG_UART0_PARITY=0 +CONFIG_UART1_PARITY=0 +CONFIG_UART2_PARITY=0 +CONFIG_UART3_PARITY=0 + +CONFIG_UART0_2STOP=0 +CONFIG_UART1_2STOP=0 +CONFIG_UART2_2STOP=0 +CONFIG_UART3_2STOP=0 + +# +# General OS setup +# +# CONFIG_APP_DIR - Identifies the relative path to the directory that builds +# the application to link with NuttX. +# 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_TICKS_PER_MSEC - The default system timer is 100Hz or TICKS_PER_MSEC=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 +# (minimal 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_APP_DIR=examples/nsh +CONFIG_DEBUG=n +CONFIG_DEBUG_VERBOSE=n +CONFIG_DEBUG_SYMBOLS=n +CONFIG_MM_REGIONS=1 +CONFIG_ARCH_LOWPUTC=y +CONFIG_RR_INTERVAL=0 +CONFIG_SCHED_INSTRUMENTATION=n +CONFIG_TASK_NAME_SIZE=32 +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=3 +CONFIG_START_DAY=3 +CONFIG_JULIAN_TIME=n +CONFIG_DEV_CONSOLE=y +CONFIG_DEV_LOWCONSOLE=n +CONFIG_MUTEX_TYPES=y +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 ofAPIs 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 +# system performance +# +CONFIG_ARCH_MEMCPY=n +CONFIG_ARCH_MEMCMP=n +CONFIG_ARCH_MEMMOVE=n +CONFIG_ARCH_MEMSET=n +CONFIG_ARCH_STRCMP=n +CONFIG_ARCH_STRCPY=n +CONFIG_ARCH_STRNCPY=n +CONFIG_ARCH_STRLEN=n +CONFIG_ARCH_STRNLEN=n +CONFIG_ARCH_BZERO=n +CONFIG_ARCH_KMALLOC=n +CONFIG_ARCH_KZMALLOC=n +CONFIG_ARCH_KFREE=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=y + +# +# 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=y +CONFIG_FS_ROMFS=y + +# +# 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=n +CONFIG_NET_IPv6=n +CONFIG_NSOCKET_DESCRIPTORS=0 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_BUFSIZE=420 +CONFIG_NET_TCP=n +CONFIG_NET_TCP_CONNS=40 +CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_UDP=n +CONFIG_NET_UDP_CHECKSUMS=y +#CONFIG_NET_UDP_CONNS=10 +CONFIG_NET_ICMP=n +CONFIG_NET_ICMP_PING=n +#CONFIG_NET_PINGADDRCONF=0 +CONFIG_NET_STATISTICS=y +#CONFIG_NET_RECEIVE_WINDOW= +#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 examples/ostest +CONFIG_EXAMPLES_OSTEST_LOOPS=100 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=4096 + +# +# Settings for examples/nsh +# +# CONFIG_EXAMPLES_NSH_FILEIOSIZE - Size of a static I/O buffer +# CONFIG_EXAMPLES_NSH_STRERROR - Use strerror(errno) +# CONFIG_EXAMPLES_NSH_LINELEN - Maximum length of one command line +# CONFIG_EXAMPLES_NSH_STACKSIZE - Stack size to use for new threads. +# CONFIG_EXAMPLES_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi +# CONFIG_EXAMPLES_NSH_DISABLESCRIPT - Disable scripting support +# CONFIG_EXAMPLES_NSH_DISABLEBG - Disable background commands +# CONFIG_EXAMPLES_NSH_ROMFSETC - Use startup script in /etc +# CONFIG_EXAMPLES_NSH_CONSOLE - Use serial console front end +# CONFIG_EXAMPLES_NSH_TELNET - Use telnetd console front end +# CONFIG_EXAMPLES_NSH_ARCHINIT - Platform provides architecture +# specific initialization (nsh_archinitialize()). +# +# If CONFIG_EXAMPLES_NSH_TELNET is selected: +# CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size +# CONFIG_EXAMPLES_NSH_DHCPC - Obtain address using DHCP +# CONFIG_EXAMPLES_NSH_IPADDR - Provides static IP address +# CONFIG_EXAMPLES_NSH_DRIPADDR - Provides static router IP address +# CONFIG_EXAMPLES_NSH_NETMASK - Provides static network mask +# CONFIG_EXAMPLES_NSH_NOMAC - Use a bogus MAC address +# +# If CONFIG_EXAMPLES_NSH_ROMFSETC is selected: +# CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT - ROMFS mountpoint +# CONFIG_EXAMPLES_NSH_INITSCRIPT - Relative path to init script +# CONFIG_EXAMPLES_NSH_ROMFSDEVNO - ROMFS RAM device minor +# CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE - ROMF sector size +# CONFIG_EXAMPLES_NSH_FATDEVNO - FAT FS RAM device minor +# CONFIG_EXAMPLES_NSH_FATSECTSIZE - FAT FS sector size +# CONFIG_EXAMPLES_NSH_FATNSECTORS - FAT FS number of sectors +# CONFIG_EXAMPLES_NSH_FATMOUNTPT - FAT FS mountpoint +# +CONFIG_EXAMPLES_NSH_FILEIOSIZE=512 +CONFIG_EXAMPLES_NSH_STRERROR=n +CONFIG_EXAMPLES_NSH_LINELEN=64 +CONFIG_EXAMPLES_NSH_STACKSIZE=2048 +CONFIG_EXAMPLES_NSH_NESTDEPTH=3 +CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n +CONFIG_EXAMPLES_NSH_DISABLEBG=n +CONFIG_EXAMPLES_NSH_ROMFSETC=n +CONFIG_EXAMPLES_NSH_CONSOLE=y +CONFIG_EXAMPLES_NSH_TELNET=n +CONFIG_EXAMPLES_NSH_ARCHINIT=n +CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512 +CONFIG_EXAMPLES_NSH_DHCPC=n +CONFIG_EXAMPLES_NSH_NOMAC=y +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) +CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT="/etc" +CONFIG_EXAMPLES_NSH_INITSCRIPT="init.d/rcS" +CONFIG_EXAMPLES_NSH_ROMFSDEVNO=0 +CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE=64 +CONFIG_EXAMPLES_NSH_FATDEVNO=1 +CONFIG_EXAMPLES_NSH_FATSECTSIZE=512 +CONFIG_EXAMPLES_NSH_FATNSECTORS=1024 +CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp + +# +# 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) there 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=2048 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_HEAP_BASE= +CONFIG_HEAP_SIZE= diff --git a/nuttx/configs/qemu-i486/nsh/ld.script b/nuttx/configs/qemu-i486/nsh/ld.script new file mode 100755 index 000000000..d0abd245d --- /dev/null +++ b/nuttx/configs/qemu-i486/nsh/ld.script @@ -0,0 +1,91 @@ +/**************************************************************************** + * configs/qemu-i486/nsh/ld.script + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +OUTPUT_ARCH(i386) +ENTRY(__start) +SECTIONS +{ + . = 0x00100000; + + .text : { + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.gnu.linkonce.t.*) + _etext = ABSOLUTE(.); + } + + .text ALIGN (0x1000) : { + _srodata = ABSOLUTE(.); + *(.rodata .rodata.*) + *(.fixup) + *(.gnu.warning) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _erodata = ABSOLUTE(.); + } + + .data ALIGN (0x1000) : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } + + /* Stabs debugging sections */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/nuttx/configs/qemu-i486/nsh/setenv.sh b/nuttx/configs/qemu-i486/nsh/setenv.sh new file mode 100755 index 000000000..de427d2b6 --- /dev/null +++ b/nuttx/configs/qemu-i486/nsh/setenv.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# configs/qemu-i486/nsh/setenv.sh +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +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 + +# Uncomment and modify the following if you are using anything other +# than the system GCC +# WD=`pwd` +# export BUILDROOT_BIN="${WD}/../../../buildroot/build_i486/staging_dir/bin" +# export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/qemu-i486/ostest/Make.defs b/nuttx/configs/qemu-i486/ostest/Make.defs index 14efb3f32..35eb24979 100644 --- a/nuttx/configs/qemu-i486/ostest/Make.defs +++ b/nuttx/configs/qemu-i486/ostest/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# configs/qemu-i486/Make.defs +# configs/qemu-i486/ostest/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. # Author: Gregory Nutt diff --git a/nuttx/configs/qemu-i486/ostest/defconfig b/nuttx/configs/qemu-i486/ostest/defconfig index f0e558d4a..8b17c30b8 100644 --- a/nuttx/configs/qemu-i486/ostest/defconfig +++ b/nuttx/configs/qemu-i486/ostest/defconfig @@ -362,7 +362,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106) # # Settings for examples/ostest CONFIG_EXAMPLES_OSTEST_LOOPS=100 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=4096 # # Settings for examples/nsh @@ -370,7 +370,7 @@ 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_STACKSIZE=2048 CONFIG_EXAMPLES_NSH_DHCPC=n CONFIG_EXAMPLES_NSH_NOMAC=n CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2) @@ -402,9 +402,9 @@ CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0) CONFIG_BOOT_RUNFROMFLASH=n CONFIG_BOOT_COPYTORAM=n CONFIG_CUSTOM_STACK=n -CONFIG_IDLETHREAD_STACKSIZE=4096 -CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_USERMAIN_STACKSIZE=2048 CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=8192 +CONFIG_PTHREAD_STACK_DEFAULT=2048 CONFIG_HEAP_BASE= CONFIG_HEAP_SIZE= diff --git a/nuttx/configs/qemu-i486/ostest/setenv.sh b/nuttx/configs/qemu-i486/ostest/setenv.sh index b119c7e62..50ace04dd 100755 --- a/nuttx/configs/qemu-i486/ostest/setenv.sh +++ b/nuttx/configs/qemu-i486/ostest/setenv.sh @@ -1,7 +1,7 @@ #!/bin/bash -# configs/qemu-i486/setenv.sh +# configs/qemu-i486/ostest/setenv.sh # -# Copyright (C) 2010 Gregory Nutt. All rights reserved. +# Copyright (C) 2011 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without diff --git a/nuttx/drivers/serial/Make.defs b/nuttx/drivers/serial/Make.defs index 089e797d4..7799233db 100644 --- a/nuttx/drivers/serial/Make.defs +++ b/nuttx/drivers/serial/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # drivers/serial/Make.defs # -# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -33,9 +33,12 @@ # ############################################################################ -SERIAL_ASRCS = +SERIAL_ASRCS = ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) SERIAL_CSRCS = serial.c serialirq.c lowconsole.c +ifeq ($(CONFIG_16550_UART),y) +SERIAL_CSRCS += uart_16550.c +endif else SERIAL_CSRCS = endif diff --git a/nuttx/drivers/serial/uart_16550.c b/nuttx/drivers/serial/uart_16550.c index e65d5cced..07c0dae36 100755 --- a/nuttx/drivers/serial/uart_16550.c +++ b/nuttx/drivers/serial/uart_16550.c @@ -52,11 +52,12 @@ #include #include #include +#include #include #include -#ifdef CONFIG_UART_16550 +#ifdef CONFIG_16550_UART /**************************************************************************** * Pre-processor definitions @@ -66,35 +67,43 @@ * Private Types ****************************************************************************/ -struct uart_16550_s +struct u16550_s { uart_addrwidth_t uartbase; /* Base address of UART registers */ +#ifndef CONFIG_16550_SUPRESS_CONFIG uint32_t baud; /* Configured baud */ uint32_t uartclk; /* UART clock frequency */ +#endif +#ifndef CONFIG_SUPPRESS_SERIAL_INTS uart_datawidth_t ier; /* Saved IER value */ uint8_t irq; /* IRQ associated with this UART */ +#endif +#ifndef CONFIG_16550_SUPRESS_CONFIG uint8_t parity; /* 0=none, 1=odd, 2=even */ uint8_t bits; /* Number of bits (7 or 8) */ bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */ +#endif }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int uart_setup(struct uart_dev_s *dev); -static void uart_shutdown(struct uart_dev_s *dev); -static int uart_attach(struct uart_dev_s *dev); -static void uart_detach(struct uart_dev_s *dev); -static int uart_interrupt(int irq, void *context); -static int uart_ioctl(struct file *filep, int cmd, unsigned long arg); -static int uart_receive(struct uart_dev_s *dev, uint32_t *status); -static void uart_rxint(struct uart_dev_s *dev, bool enable); -static bool uart_rxavailable(struct uart_dev_s *dev); -static void uart_send(struct uart_dev_s *dev, int ch); -static void uart_txint(struct uart_dev_s *dev, bool enable); -static bool uart_txready(struct uart_dev_s *dev); -static bool uart_txempty(struct uart_dev_s *dev); +static int u16550_setup(struct uart_dev_s *dev); +static void u16550_shutdown(struct uart_dev_s *dev); +static int u16550_attach(struct uart_dev_s *dev); +static void u16550_detach(struct uart_dev_s *dev); +#ifndef CONFIG_SUPPRESS_SERIAL_INTS +static int u16550_interrupt(int irq, void *context); +#endif +static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg); +static int u16550_receive(struct uart_dev_s *dev, uint32_t *status); +static void u16550_rxint(struct uart_dev_s *dev, bool enable); +static bool u16550_rxavailable(struct uart_dev_s *dev); +static void u16550_send(struct uart_dev_s *dev, int ch); +static void u16550_txint(struct uart_dev_s *dev, bool enable); +static bool u16550_txready(struct uart_dev_s *dev); +static bool u16550_txempty(struct uart_dev_s *dev); /**************************************************************************** * Private Variables @@ -102,18 +111,18 @@ static bool uart_txempty(struct uart_dev_s *dev); struct uart_ops_s g_uart_ops = { - .setup = uart_setup, - .shutdown = uart_shutdown, - .attach = uart_attach, - .detach = uart_detach, - .ioctl = uart_ioctl, - .receive = uart_receive, - .rxint = uart_rxint, - .rxavailable = uart_rxavailable, - .send = uart_send, - .txint = uart_txint, - .txready = uart_txready, - .txempty = uart_txempty, + .setup = u16550_setup, + .shutdown = u16550_shutdown, + .attach = u16550_attach, + .detach = u16550_detach, + .ioctl = u16550_ioctl, + .receive = u16550_receive, + .rxint = u16550_rxint, + .rxavailable = u16550_rxavailable, + .send = u16550_send, + .txint = u16550_txint, + .txready = u16550_txready, + .txempty = u16550_txempty, }; /* I/O buffers */ @@ -138,15 +147,21 @@ static char g_uart3txbuffer[CONFIG_UART1_TXBUFSIZE]; /* This describes the state of the LPC17xx uart0 port. */ #ifdef CONFIG_16550_UART0 -static struct uart_16550_s g_uart0priv = +static struct u16550_s g_uart0priv = { .uartbase = CONFIG_16550_UART0_BASE, +#ifndef CONFIG_16550_SUPRESS_CONFIG .baud = CONFIG_UART0_BAUD, .uartclk = CONFIG_16550_UART0_CLOCK, +#endif +#ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART0_IRQ, +#endif +#ifndef CONFIG_16550_SUPRESS_CONFIG .parity = CONFIG_UART0_PARITY, .bits = CONFIG_UART0_BITS, .stopbits2 = CONFIG_UART0_2STOP, +#endif }; static uart_dev_t g_uart0port = @@ -169,15 +184,21 @@ static uart_dev_t g_uart0port = /* This describes the state of the LPC17xx uart1 port. */ #ifdef CONFIG_16550_UART1 -static struct uart_16550_s g_uart1priv = +static struct u16550_s g_uart1priv = { .uartbase = CONFIG_16550_UART1_BASE, +#ifndef CONFIG_16550_SUPRESS_CONFIG .baud = CONFIG_UART1_BAUD, .uartclk = CONFIG_16550_UART1_CLOCK, +#endif +#ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART1_IRQ, +#endif +#ifndef CONFIG_16550_SUPRESS_CONFIG .parity = CONFIG_UART1_PARITY, .bits = CONFIG_UART1_BITS, .stopbits2 = CONFIG_UART1_2STOP, +#endif }; static uart_dev_t g_uart1port = @@ -200,15 +221,21 @@ static uart_dev_t g_uart1port = /* This describes the state of the LPC17xx uart1 port. */ #ifdef CONFIG_16550_UART2 -static struct uart_16550_s g_uart2priv = +static struct u16550_s g_uart2priv = { .uartbase = CONFIG_16550_UART2_BASE, +#ifndef CONFIG_16550_SUPRESS_CONFIG .baud = CONFIG_UART2_BAUD, .uartclk = CONFIG_16550_UART2_CLOCK, +#endif +#ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART2_IRQ, +#endif +#ifndef CONFIG_16550_SUPRESS_CONFIG .parity = CONFIG_UART2_PARITY, .bits = CONFIG_UART2_BITS, .stopbits2 = CONFIG_UART2_2STOP, +#endif }; static uart_dev_t g_uart2port = @@ -231,15 +258,21 @@ static uart_dev_t g_uart2port = /* This describes the state of the LPC17xx uart1 port. */ #ifdef CONFIG_16550_UART3 -static struct uart_16550_s g_uart3priv = +static struct u16550_s g_uart3priv = { .uartbase = CONFIG_16550_UART3_BASE, +#ifndef CONFIG_16550_SUPRESS_CONFIG .baud = CONFIG_UART3_BAUD, .uartclk = CONFIG_16550_UART3_CLOCK, +#endif +#ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART3_IRQ, +#endif +#ifndef CONFIG_16550_SUPRESS_CONFIG .parity = CONFIG_UART3_PARITY, .bits = CONFIG_UART3_BITS, .stopbits2 = CONFIG_UART3_2STOP, +#endif }; static uart_dev_t g_uart3port = @@ -425,28 +458,29 @@ static uart_dev_t g_uart3port = ************************************************************************************/ /**************************************************************************** - * Name: uart_serialin + * Name: u16550_serialin ****************************************************************************/ -static inline uart_datawidth_t uart_serialin(struct uart_16550_s *priv, int offset) +static inline uart_datawidth_t u16550_serialin(struct u16550_s *priv, int offset) { return uart_getreg(priv->uartbase, offset); } /**************************************************************************** - * Name: uart_serialout + * Name: u16550_serialout ****************************************************************************/ -static inline void uart_serialout(struct uart_16550_s *priv, int offset, uart_datawidth_t value) +static inline void u16550_serialout(struct u16550_s *priv, int offset, uart_datawidth_t value) { uart_putreg(priv->uartbase, offset, value); } /**************************************************************************** - * Name: uart_disableuartint + * Name: u16550_disableuartint ****************************************************************************/ -static inline void uart_disableuartint(struct uart_16550_s *priv, uart_datawidth_t *ier) +#ifndef CONFIG_SUPPRESS_SERIAL_INTS +static inline void u16550_disableuartint(struct u16550_s *priv, uart_datawidth_t *ier) { if (ier) { @@ -454,26 +488,33 @@ static inline void uart_disableuartint(struct uart_16550_s *priv, uart_datawidth } priv->ier &= ~UART_IER_ALLIE; - uart_serialout(priv, UART_IER_OFFSET, priv->ier); + u16550_serialout(priv, UART_IER_OFFSET, priv->ier); } +#else +# define u16550_disableuartint(priv,ier) +#endif /**************************************************************************** - * Name: uart_restoreuartint + * Name: u16550_restoreuartint ****************************************************************************/ -static inline void uart_restoreuartint(struct uart_16550_s *priv, uint32_t ier) +#ifndef CONFIG_SUPPRESS_SERIAL_INTS +static inline void u16550_restoreuartint(struct u16550_s *priv, uint32_t ier) { priv->ier |= ier & UART_IER_ALLIE; - uart_serialout(priv, UART_IER_OFFSET, priv->ier); + u16550_serialout(priv, UART_IER_OFFSET, priv->ier); } +#else +# define u16550_restoreuartint(priv,ier) +#endif /**************************************************************************** - * Name: uart_enablebreaks + * Name: u16550_enablebreaks ****************************************************************************/ -static inline void uart_enablebreaks(struct uart_16550_s *priv, bool enable) +static inline void u16550_enablebreaks(struct u16550_s *priv, bool enable) { - uint32_t lcr = uart_serialin(priv, UART_LCR_OFFSET); + uint32_t lcr = u16550_serialin(priv, UART_LCR_OFFSET); if (enable) { lcr |= UART_LCR_BRK; @@ -482,11 +523,11 @@ static inline void uart_enablebreaks(struct uart_16550_s *priv, bool enable) { lcr &= ~UART_LCR_BRK; } - uart_serialout(priv, UART_LCR_OFFSET, lcr); + u16550_serialout(priv, UART_LCR_OFFSET, lcr); } /************************************************************************************ - * Name: uart_divisor + * Name: u16550_divisor * * Descrption: * Select a divider to produce the BAUD from the UART_CLK. @@ -498,17 +539,19 @@ static inline void uart_enablebreaks(struct uart_16550_s *priv, bool enable) * ************************************************************************************/ -static inline uint32_t uart_divisor(struct uart_16550_s *priv) +#ifndef CONFIG_16550_SUPRESS_CONFIG +static inline uint32_t u16550_divisor(struct u16550_s *priv) { - return (priv->uartclk + (priv->baud << 3)) / (priv->baurd << 4); + return (priv->uartclk + (priv->baud << 3)) / (priv->baud << 4); } +#endif /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: uart_setup + * Name: u16550_setup * * Description: * Configure the UART baud, bits, parity, fifos, etc. This @@ -517,24 +560,26 @@ static inline uint32_t uart_divisor(struct uart_16550_s *priv) * ****************************************************************************/ -static int uart_setup(struct uart_dev_s *dev) +static int u16550_setup(struct uart_dev_s *dev) { #ifndef CONFIG_16550_SUPRESS_CONFIG - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; + struct u16550_s *priv = (struct u16550_s*)dev->priv; uint16_t div; uint32_t lcr; /* Clear fifos */ - uart_serialout(priv, UART_FCR_OFFSET, (UART_FCR_RXRST|UART_FCR_TXRST)); + u16550_serialout(priv, UART_FCR_OFFSET, (UART_FCR_RXRST|UART_FCR_TXRST)); /* Set trigger */ - uart_serialout(priv, UART_FCR_OFFSET, (UART_FCR_FIFOEN|UART_FCR_RXTRIGGER_8)); + u16550_serialout(priv, UART_FCR_OFFSET, (UART_FCR_FIFOEN|UART_FCR_RXTRIGGER_8)); /* Set up the IER */ - priv->ier = uart_serialin(priv, UART_IER_OFFSET); +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + priv->ier = u16550_serialin(priv, UART_IER_OFFSET); +#endif /* Set up the LCR */ @@ -575,28 +620,28 @@ static int uart_setup(struct uart_dev_s *dev) /* Enter DLAB=1 */ - uart_serialout(priv, UART_LCR_OFFSET, (lcr | UART_LCR_DLAB)); + u16550_serialout(priv, UART_LCR_OFFSET, (lcr | UART_LCR_DLAB)); /* Set the BAUD divisor */ - div = uart_divisor(priv); - uart_serialout(priv, UART_DLM_OFFSET, div >> 8); - uart_serialout(priv, UART_DLL_OFFSET, div & 0xff); + div = u16550_divisor(priv); + u16550_serialout(priv, UART_DLM_OFFSET, div >> 8); + u16550_serialout(priv, UART_DLL_OFFSET, div & 0xff); /* Clear DLAB */ - uart_serialout(priv, UART_LCR_OFFSET, lcr); + u16550_serialout(priv, UART_LCR_OFFSET, lcr); /* Configure the FIFOs */ - uart_serialout(priv, UART_FCR_OFFSET, - (UART_FCR_RXTRIGGER_8|UART_FCR_TXRST|UART_FCR_RXRST|UART_FCR_FIFOEN)); + u16550_serialout(priv, UART_FCR_OFFSET, + (UART_FCR_RXTRIGGER_8|UART_FCR_TXRST|UART_FCR_RXRST|UART_FCR_FIFOEN)); #endif return OK; } /**************************************************************************** - * Name: uart_shutdown + * Name: u16550_shutdown * * Description: * Disable the UART. This method is called when the serial @@ -604,14 +649,14 @@ static int uart_setup(struct uart_dev_s *dev) * ****************************************************************************/ -static void uart_shutdown(struct uart_dev_s *dev) +static void u16550_shutdown(struct uart_dev_s *dev) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - uart_disableuartint(priv, NULL); + struct u16550_s *priv = (struct u16550_s*)dev->priv; + u16550_disableuartint(priv, NULL); } /**************************************************************************** - * Name: uart_attach + * Name: u16550_attach * * Description: * Configure the UART to operation in interrupt driven mode. This method is @@ -625,14 +670,15 @@ static void uart_shutdown(struct uart_dev_s *dev) * ****************************************************************************/ -static int uart_attach(struct uart_dev_s *dev) +static int u16550_attach(struct uart_dev_s *dev) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + struct u16550_s *priv = (struct u16550_s*)dev->priv; int ret; /* Attach and enable the IRQ */ - ret = irq_attach(priv->irq, uart_interrupt); + ret = irq_attach(priv->irq, u16550_interrupt); #ifndef CONFIG_ARCH_NOINTC if (ret == OK) { @@ -640,14 +686,17 @@ static int uart_attach(struct uart_dev_s *dev) * in the UART */ - uart_enable_irq(priv->irq); + up_enable_irq(priv->irq); } -endif +#endif return ret; +#else + return OK; +#endif } /**************************************************************************** - * Name: uart_detach + * Name: u16550_detach * * Description: * Detach UART interrupts. This method is called when the serial port is @@ -656,33 +705,36 @@ endif * ****************************************************************************/ -static void uart_detach(struct uart_dev_s *dev) +static void u16550_detach(struct uart_dev_s *dev) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + struct u16550_s *priv = (struct u16550_s*)dev->priv; #ifndef CONFIG_ARCH_NOINTC - uart_disable_irq(priv->irq); + up_disable_irq(priv->irq); #endif irq_detach(priv->irq); +#endif } /**************************************************************************** - * Name: uart_interrupt + * Name: u16550_interrupt * * 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 - * appropriate uart_16550_s structure in order to call these functions. + * appropriate u16550_s structure in order to call these functions. * ****************************************************************************/ -static int uart_interrupt(int irq, void *context) +#ifndef CONFIG_SUPPRESS_SERIAL_INTS +static int u16550_interrupt(int irq, void *context) { - struct uart_dev_s *dev = NULL; - struct uart_16550_s *priv; - uint32_t status; - int passes; + struct uart_dev_s *dev = NULL; + struct u16550_s *priv; + uint32_t status; + int passes; #ifdef CONFIG_16550_UART0 if (g_uart0priv.irq == irq) @@ -710,12 +762,9 @@ static int uart_interrupt(int irq, void *context) { dev = &g_uart3port; } - else #endif - { - PANIC(OSERR_INTERNAL); - } - priv = (struct uart_16550_s*)dev->priv; + ASSERT(dev != NULL); + priv = (struct u16550_s*)dev->priv; /* Loop until there are no characters to be transferred or, * until we have been looping for a long time. @@ -727,7 +776,7 @@ static int uart_interrupt(int irq, void *context) * termination conditions */ - status = uart_serialin(priv, UART_IIR_OFFSET); + status = u16550_serialin(priv, UART_IIR_OFFSET); /* The UART_IIR_INTSTATUS bit should be zero if there are pending * interrupts @@ -769,7 +818,7 @@ static int uart_interrupt(int irq, void *context) { /* Read the modem status register (MSR) to clear */ - status = uart_serialin(priv, UART_MSR_OFFSET); + status = u16550_serialin(priv, UART_MSR_OFFSET); vdbg("MSR: %02x\n", status); break; } @@ -780,7 +829,7 @@ static int uart_interrupt(int irq, void *context) { /* Read the line status register (LSR) to clear */ - status = uart_serialin(priv, UART_LSR_OFFSET); + status = u16550_serialin(priv, UART_LSR_OFFSET); vdbg("LSR: %02x\n", status); break; } @@ -796,27 +845,28 @@ static int uart_interrupt(int irq, void *context) } return OK; } +#endif /**************************************************************************** - * Name: uart_ioctl + * Name: u16550_ioctl * * Description: * All ioctl calls will be routed through this method * ****************************************************************************/ -static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) +static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg) { - struct inode *inode = filep->f_inode; - struct uart_dev_s *dev = inode->i_private; - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - int ret = OK; + struct inode *inode = filep->f_inode; + struct uart_dev_s *dev = inode->i_private; + struct u16550_s *priv = (struct u16550_s*)dev->priv; + int ret = OK; switch (cmd) { case TIOCSERGSTRUCT: { - struct uart_16550_s *user = (struct uart_16550_s*)arg; + struct u16550_s *user = (struct u16550_s*)arg; if (!user) { *get_errno_ptr() = EINVAL; @@ -824,7 +874,7 @@ static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) } else { - memcpy(user, dev, sizeof(struct uart_16550_s)); + memcpy(user, dev, sizeof(struct u16550_s)); } } break; @@ -832,7 +882,7 @@ static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { irqstate_t flags = irqsave(); - uart_enablebreaks(priv, true); + u16550_enablebreaks(priv, true); irqrestore(flags); } break; @@ -841,7 +891,7 @@ static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) { irqstate_t flags; flags = irqsave(); - uart_enablebreaks(priv, false); + u16550_enablebreaks(priv, false); irqrestore(flags); } break; @@ -856,7 +906,7 @@ static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) } /**************************************************************************** - * Name: uart_receive + * Name: u16550_receive * * Description: * Called (usually) from the interrupt level to receive one @@ -865,129 +915,143 @@ static int uart_ioctl(struct file *filep, int cmd, unsigned long arg) * ****************************************************************************/ -static int uart_receive(struct uart_dev_s *dev, uint32_t *status) +static int u16550_receive(struct uart_dev_s *dev, uint32_t *status) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; + struct u16550_s *priv = (struct u16550_s*)dev->priv; uint32_t rbr; - *status = uart_serialin(priv, UART_LSR_OFFSET); - rbr = uart_serialin(priv, UART_RBR_OFFSET); + *status = u16550_serialin(priv, UART_LSR_OFFSET); + rbr = u16550_serialin(priv, UART_RBR_OFFSET); return rbr; } /**************************************************************************** - * Name: uart_rxint + * Name: u16550_rxint * * Description: * Call to enable or disable RX interrupts * ****************************************************************************/ -static void uart_rxint(struct uart_dev_s *dev, bool enable) +static void u16550_rxint(struct uart_dev_s *dev, bool enable) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + struct u16550_s *priv = (struct u16550_s*)dev->priv; if (enable) { -#ifndef CONFIG_SUPPRESS_SERIAL_INTS priv->ier |= UART_IER_ERBFI; -#endif } else { priv->ier &= ~UART_IER_ERBFI; } - uart_serialout(priv, UART_IER_OFFSET, priv->ier); + u16550_serialout(priv, UART_IER_OFFSET, priv->ier); +#endif } /**************************************************************************** - * Name: uart_rxavailable + * Name: u16550_rxavailable * * Description: * Return true if the receive fifo is not empty * ****************************************************************************/ -static bool uart_rxavailable(struct uart_dev_s *dev) +static bool u16550_rxavailable(struct uart_dev_s *dev) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - return ((uart_serialin(priv, UART_LSR_OFFSET) & UART_LSR_RDR) != 0); + struct u16550_s *priv = (struct u16550_s*)dev->priv; + return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_DR) != 0); } /**************************************************************************** - * Name: uart_send + * Name: u16550_send * * Description: * This method will send one byte on the UART * ****************************************************************************/ -static void uart_send(struct uart_dev_s *dev, int ch) +static void u16550_send(struct uart_dev_s *dev, int ch) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - uart_serialout(priv, UART_THR_OFFSET, (uint32_t)ch); + struct u16550_s *priv = (struct u16550_s*)dev->priv; + u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch); } /**************************************************************************** - * Name: uart_txint + * Name: u16550_txint * * Description: * Call to enable or disable TX interrupts * ****************************************************************************/ -static void uart_txint(struct uart_dev_s *dev, bool enable) +static void u16550_txint(struct uart_dev_s *dev, bool enable) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + struct u16550_s *priv = (struct u16550_s*)dev->priv; irqstate_t flags; flags = irqsave(); if (enable) { -#ifndef CONFIG_SUPPRESS_SERIAL_INTS priv->ier |= UART_IER_ETBEI; - uart_serialout(priv, UART_IER_OFFSET, priv->ier); + u16550_serialout(priv, UART_IER_OFFSET, priv->ier); /* Fake a TX interrupt here by just calling uart_xmitchars() with * interrupts disabled (note this may recurse). */ uart_xmitchars(dev); -#endif } else { priv->ier &= ~UART_IER_ETBEI; - uart_serialout(priv, UART_IER_OFFSET, priv->ier); + u16550_serialout(priv, UART_IER_OFFSET, priv->ier); } irqrestore(flags); +#endif } /**************************************************************************** - * Name: uart_txready + * Name: u16550_txready * * Description: * Return true if the tranmsit fifo is not full * ****************************************************************************/ -static bool uart_txready(struct uart_dev_s *dev) +static bool u16550_txready(struct uart_dev_s *dev) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - return ((uart_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0); + struct u16550_s *priv = (struct u16550_s*)dev->priv; + return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0); } /**************************************************************************** - * Name: uart_txempty + * Name: u16550_txempty * * Description: * Return true if the transmit fifo is empty * ****************************************************************************/ -static bool uart_txempty(struct uart_dev_s *dev) +static bool u16550_txempty(struct uart_dev_s *dev) +{ + struct u16550_s *priv = (struct u16550_s*)dev->priv; + return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0); +} + +/**************************************************************************** + * Name: u16550_putc + * + * Description: + * Write one character to the UART (polled) + * + ****************************************************************************/ + +static void u16550_putc(struct u16550_s *priv, int ch) { - struct uart_16550_s *priv = (struct uart_16550_s*)dev->priv; - return ((uart_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0); + while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0); + u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch); } /**************************************************************************** @@ -995,7 +1059,7 @@ static bool uart_txempty(struct uart_dev_s *dev) ****************************************************************************/ /**************************************************************************** - * Name: uart_serialinit + * Name: up_earlyserialinit * * Description: * Performs the low level UART initialization early in debug so that the @@ -1007,39 +1071,41 @@ static bool uart_txempty(struct uart_dev_s *dev) * ****************************************************************************/ -void uart_earlyserialinit(void) +void up_earlyserialinit(void) { /* Configure all UARTs (except the CONSOLE UART) and disable interrupts */ #ifdef CONFIG_16550_UART0 - uart_disableuartint(&g_uart0priv, NULL); + u16550_disableuartint(&g_uart0priv, NULL); #endif #ifdef CONFIG_16550_UART1 - uart_disableuartint(&g_uart1priv, NULL); + u16550_disableuartint(&g_uart1priv, NULL); #endif - uart_disableuartint(&g_uart2priv, NULL); +#ifdef CONFIG_16550_UART2 + u16550_disableuartint(&g_uart2priv, NULL); #endif - uart_disableuartint(&g_uart3priv, NULL); +#ifdef CONFIG_16550_UART3 + u16550_disableuartint(&g_uart3priv, NULL); #endif /* Configuration whichever one is the console */ #ifdef CONSOLE_DEV CONSOLE_DEV.isconsole = true; - uart_setup(&CONSOLE_DEV); + u16550_setup(&CONSOLE_DEV); #endif } /**************************************************************************** - * Name: uart_serialinit + * Name: up_serialinit * * Description: * Register serial console and serial ports. This assumes that - * uart_earlyserialinit was called previously. + * up_earlyserialinit was called previously. * ****************************************************************************/ -void uart_serialinit(void) +void up_serialinit(void) { #ifdef CONSOLE_DEV (void)uart_register("/dev/console", &CONSOLE_DEV); @@ -1059,7 +1125,7 @@ void uart_serialinit(void) } /**************************************************************************** - * Name: uart_putc + * Name: up_putc * * Description: * Provide priority, low-level access to support OS debug writes @@ -1067,12 +1133,14 @@ void uart_serialinit(void) ****************************************************************************/ #ifdef HAVE_16550_CONSOLE -int uart_putc(int ch) +int up_putc(int ch) { - struct uart_16550_s *priv = (struct uart_16550_s*)CONSOLE_DEV.priv; + struct u16550_s *priv = (struct u16550_s*)CONSOLE_DEV.priv; +#ifndef CONFIG_SUPPRESS_SERIAL_INTS uart_datawidth_t ier; - uart_disableuartint(priv, &ier); + u16550_disableuartint(priv, &ier); +#endif /* Check for LF */ @@ -1080,11 +1148,13 @@ int uart_putc(int ch) { /* Add CR */ - uart_lowputc('\r'); + u16550_putc(priv, '\r'); } - uart_lowputc(ch); - uart_restoreuartint(priv, ier); + u16550_putc(priv, ch); +#ifndef CONFIG_SUPPRESS_SERIAL_INTS + u16550_restoreuartint(priv, ier); +#endif return ch; } #endif diff --git a/nuttx/include/nuttx/uart_16550.h b/nuttx/include/nuttx/uart_16550.h index cdad637e0..3ab6552b0 100755 --- a/nuttx/include/nuttx/uart_16550.h +++ b/nuttx/include/nuttx/uart_16550.h @@ -43,7 +43,7 @@ #include -#ifdef CONFIG_UART_16550 +#ifdef CONFIG_16550_UART /************************************************************************************ * Pre-processor Definitions @@ -75,7 +75,7 @@ # error "CONFIG_16550_REGWIDTH not defined" #endif -#if CONFIG_16550_REGWIDTH != 1 && CONFIG_16550_REGWIDTH != 2 && CONFIG_16550_REGWIDTH != 4 +#if CONFIG_16550_REGWIDTH != 8 && CONFIG_16550_REGWIDTH != 16 && CONFIG_16550_REGWIDTH != 32 # error "CONFIG_16550_REGWIDTH not supported" #endif @@ -83,7 +83,7 @@ # error "CONFIG_16550_ADDRWIDTH not defined" #endif -#if CONFIG_16550_ADDRWIDTH != 1 && CONFIG_16550_ADDRWIDTH != 2 && CONFIG_16550_ADDRWIDTH != 4 +#if CONFIG_16550_ADDRWIDTH != 8 && CONFIG_16550_ADDRWIDTH != 16 && CONFIG_16550_ADDRWIDTH != 32 # error "CONFIG_16550_ADDRWIDTH not supported" #endif @@ -311,19 +311,19 @@ * Public Types ************************************************************************************/ -#if CONFIG_16550_REGWIDTH == 1 +#if CONFIG_16550_REGWIDTH == 8 typedef uint8_t uart_datawidth_t; -#elif CONFIG_16550_REGWIDTH == 2 +#elif CONFIG_16550_REGWIDTH == 16 typedef uint16_t uart_datawidth_t; -#elif CONFIG_16550_REGWIDTH == 4 +#elif CONFIG_16550_REGWIDTH == 32 typedef uint32_t uart_datawidth_t; #endif -#if CONFIG_16550_REGWIDTH == 1 +#if CONFIG_16550_ADDRWIDTH == 8 typedef uint8_t uart_addrwidth_t; -#elif CONFIG_16550_REGWIDTH == 2 +#elif CONFIG_16550_ADDRWIDTH == 16 typedef uint16_t uart_addrwidth_t; -#elif CONFIG_16550_REGWIDTH == 4 +#elif CONFIG_16550_ADDRWIDTH == 32 typedef uint32_t uart_addrwidth_t; #endif -- cgit v1.2.3