From 5be790b6ddb5cd8daa0a0b3037a4c8bcb8393f5c Mon Sep 17 00:00:00 2001 From: Heath Petersen Date: Wed, 13 Jul 2016 02:57:01 +0000 Subject: [PATCH 001/152] update / correct some compilation and linkage settings HOSTCFLAGS: Should not be set the same as CFLAGS since CFLAGS may be for a completely different platform. Use sane defaults like other configs/*/*/Make.defs. ARCHCPUFLAGS: Depending on how the GNU compiler was built we may need -fno-stack-protector. Since we always want it we can just default to specifying it instead of depending on the compiler default. LDFLAGS: If compiling for a 32 bit target from a 64 bit platform we need to tell the linker to generate a 32 bit elf file with -m elf_i386. --- configs/qemu-i486/ostest/Make.defs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/qemu-i486/ostest/Make.defs b/configs/qemu-i486/ostest/Make.defs index e2ac40b09f2..5075731826a 100644 --- a/configs/qemu-i486/ostest/Make.defs +++ b/configs/qemu-i486/ostest/Make.defs @@ -63,8 +63,7 @@ else ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/ld.script endif -ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -#ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -fno-stack-protector +ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -fno-stack-protector ARCHPICFLAGS = -fpic ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHDEFINES = @@ -73,6 +72,7 @@ ARCHDEFINES = ifeq ($(CONFIG_ARCH_X86_M32),y) ARCHCPUFLAGS += -m32 +LDFLAGS += -m elf_i386 endif # We have to use a cross-development toolchain under Cygwin because the native @@ -109,5 +109,5 @@ MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) HOSTCC = gcc HOSTINCLUDESv = -I. -HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe HOSTLDFLAGS = From 9d999eeb34a8a44305d47a71bcf3d401759623c8 Mon Sep 17 00:00:00 2001 From: Heath Petersen Date: Wed, 13 Jul 2016 03:01:58 +0000 Subject: [PATCH 002/152] update / correct some compilation and linkage settings HOSTCFLAGS: Should not be set the same as CFLAGS since CFLAGS may be for a completely different platform. Use sane defaults like other configs/*/*/Make.defs. ARCHCPUFLAGS: Depending on how the GNU compiler was built we may need -fno-stack-protector. Since we always want it we can just default to specifying it instead of depending on the compiler default. LDFLAGS: If compiling for a 32 bit target from a 64 bit platform we need to tell the linker to generate a 32 bit elf file with -m elf_i386. --- configs/qemu-i486/nsh/Make.defs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/qemu-i486/nsh/Make.defs b/configs/qemu-i486/nsh/Make.defs index 0d16a608b0d..4f857d81dec 100644 --- a/configs/qemu-i486/nsh/Make.defs +++ b/configs/qemu-i486/nsh/Make.defs @@ -63,8 +63,7 @@ else ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/ld.script endif -ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -#ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -fno-stack-protector +ARCHCPUFLAGS = -march=i486 -mtune=i486 -fno-builtin -fno-stack-protector ARCHPICFLAGS = -fpic ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHDEFINES = @@ -73,6 +72,7 @@ ARCHDEFINES = ifeq ($(CONFIG_ARCH_X86_M32),y) ARCHCPUFLAGS += -m32 +LDFLAGS += -m elf_i386 endif # We have to use a cross-development toolchain under Cygwin because the native @@ -109,5 +109,5 @@ MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) HOSTCC = gcc HOSTINCLUDESv = -I. -HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe HOSTLDFLAGS = From 76a0cccbb157676bf2f3aba5fe777eae04f34d34 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 07:04:19 -0600 Subject: [PATCH 003/152] K6x Ethernet: Fix some conditional logic --- arch/arm/src/kinetis/kinetis_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 6c30bac4158..dc0be25e164 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -1840,7 +1840,7 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv) phydata = 0xffff; ret = kinetis_readmii(priv, phyaddr, MII_PHYID1, &phydata); } - while (ret >= 0 && phydata == 0xffff && ++retries < 3); + while ((ret < 0 || phydata == 0xffff) && ++retries < 3); /* If we successfully read anything then break out, using this PHY address */ From 590af73bd2d351cef5fee63ee811930655cc1b0a Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Wed, 13 Jul 2016 07:10:09 -0600 Subject: [PATCH 004/152] STM32L4 Serial: Remove some STM32Fxxx conditional logic; fix a link error resulting from an over-aggressive rename. --- arch/arm/src/stm32l4/stm32l4_serial.c | 91 ++++++--------------------- 1 file changed, 20 insertions(+), 71 deletions(-) diff --git a/arch/arm/src/stm32l4/stm32l4_serial.c b/arch/arm/src/stm32l4/stm32l4_serial.c index 548d1e19571..e85e73a3e35 100644 --- a/arch/arm/src/stm32l4/stm32l4_serial.c +++ b/arch/arm/src/stm32l4/stm32l4_serial.c @@ -139,65 +139,27 @@ /* DMA priority */ # ifndef CONFIG_USART_DMAPRIO -# if defined(CONFIG_STM32L4_STM32L15XX) || defined(CONFIG_STM32L4_STM32F10XX) || \ - defined(CONFIG_STM32L4_STM32F30XX) || defined(CONFIG_STM32L4_STM32F37XX) -# define CONFIG_USART_DMAPRIO DMA_CCR_PRIMED -# elif defined(CONFIG_STM32L4_STM32F20XX) || defined(CONFIG_STM32L4_STM32F40XX) -# define CONFIG_USART_DMAPRIO DMA_SCR_PRIMED -# else -# error "Unknown STM32 DMA" -# endif +# define CONFIG_USART_DMAPRIO DMA_CCR_PRIMED # endif -# if defined(CONFIG_STM32L4_STM32L15XX) || defined(CONFIG_STM32L4_STM32F10XX) || \ - defined(CONFIG_STM32L4_STM32F30XX) || defined(CONFIG_STM32L4_STM32F37XX) -# if (CONFIG_USART_DMAPRIO & ~DMA_CCR_PL_MASK) != 0 -# error "Illegal value for CONFIG_USART_DMAPRIO" -# endif -# elif defined(CONFIG_STM32L4_STM32F20XX) || defined(CONFIG_STM32L4_STM32F40XX) -# if (CONFIG_USART_DMAPRIO & ~DMA_SCR_PL_MASK) != 0 -# error "Illegal value for CONFIG_USART_DMAPRIO" -# endif -# else -# error "Unknown STM32 DMA" +# if (CONFIG_USART_DMAPRIO & ~DMA_CCR_PL_MASK) != 0 +# error "Illegal value for CONFIG_USART_DMAPRIO" # endif /* DMA control words */ -# if defined(CONFIG_STM32L4_STM32F20XX) || defined(CONFIG_STM32L4_STM32F40XX) -# define SERIAL_DMA_CONTROL_WORD \ - (DMA_SCR_DIR_P2M | \ - DMA_SCR_CIRC | \ - DMA_SCR_MINC | \ - DMA_SCR_PSIZE_8BITS | \ - DMA_SCR_MSIZE_8BITS | \ - CONFIG_USART_DMAPRIO | \ - DMA_SCR_PBURST_SINGLE | \ - DMA_SCR_MBURST_SINGLE) -# ifdef CONFIG_SERIAL_IFLOWCONTROL -# define SERIAL_DMA_IFLOW_CONTROL_WORD \ - (DMA_SCR_DIR_P2M | \ - DMA_SCR_MINC | \ - DMA_SCR_PSIZE_8BITS | \ - DMA_SCR_MSIZE_8BITS | \ - CONFIG_USART_DMAPRIO | \ - DMA_SCR_PBURST_SINGLE | \ - DMA_SCR_MBURST_SINGLE) -# endif -# else -# define SERIAL_DMA_CONTROL_WORD \ - (DMA_CCR_CIRC | \ - DMA_CCR_MINC | \ - DMA_CCR_PSIZE_8BITS | \ - DMA_CCR_MSIZE_8BITS | \ - CONFIG_USART_DMAPRIO) -# ifdef CONFIG_SERIAL_IFLOWCONTROL -# define SERIAL_DMA_IFLOW_CONTROL_WORD \ - (DMA_CCR_MINC | \ - DMA_CCR_PSIZE_8BITS | \ - DMA_CCR_MSIZE_8BITS | \ - CONFIG_USART_DMAPRIO) -# endif -# endif +# define SERIAL_DMA_CONTROL_WORD \ + (DMA_CCR_CIRC | \ + DMA_CCR_MINC | \ + DMA_CCR_PSIZE_8BITS | \ + DMA_CCR_MSIZE_8BITS | \ + CONFIG_USART_DMAPRIO) +# ifdef CONFIG_SERIAL_IFLOWCONTROL +# define SERIAL_DMA_IFLOW_CONTROL_WORD \ + (DMA_CCR_MINC | \ + DMA_CCR_PSIZE_8BITS | \ + DMA_CCR_MSIZE_8BITS | \ + CONFIG_USART_DMAPRIO) +# endif #endif @@ -1590,12 +1552,11 @@ static int up_interrupt_common(FAR struct stm32l4_serial_s *priv) static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { -#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) \ - || defined(CONFIG_STM32F7_SERIALBRK_BSDCOMPAT) +#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) FAR struct inode *inode = filep->f_inode; FAR struct uart_dev_s *dev = inode->i_private; #endif -#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_STM32F7_SERIALBRK_BSDCOMPAT) +#if defined(CONFIG_SERIAL_TERMIOS) FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; #endif int ret = OK; @@ -1619,6 +1580,7 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, #endif #ifdef CONFIG_STM32L4_USART_SINGLEWIRE +#warning please review the potential use of ALTERNATE_FUNCTION_OPENDRAIN case TIOCSSINGLEWIRE: { /* Change the TX port to be open-drain/push-pull and enable/disable @@ -1627,18 +1589,6 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, uint32_t cr = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); -#if defined(CONFIG_STM32L4_STM32F10XX) - if (arg == SER_SINGLEWIRE_ENABLED) - { - stm32l4_configgpio((priv->tx_gpio & ~(GPIO_CNF_MASK)) | GPIO_CNF_AFOD); - cr |= USART_CR3_HDSEL; - } - else - { - stm32l4_configgpio((priv->tx_gpio & ~(GPIO_CNF_MASK)) | GPIO_CNF_AFPP); - cr &= ~USART_CR3_HDSEL; - } -#else if (arg == SER_SINGLEWIRE_ENABLED) { stm32l4_configgpio(priv->tx_gpio | GPIO_OPENDRAIN); @@ -1649,7 +1599,6 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, stm32l4_configgpio(priv->tx_gpio | GPIO_PUSHPULL); cr &= ~USART_CR3_HDSEL; } -#endif stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, cr); } @@ -2484,7 +2433,7 @@ void up_earlyserialinit(void) * ****************************************************************************/ -void stm32l4serial_getregit(void) +void up_serialinit(void) { #ifdef HAVE_UART char devname[16]; From 2f12de6f283c67e69d827a2db41c6d8f8f27ef3e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 09:23:57 -0600 Subject: [PATCH 005/152] Freedom-K64F: Add hooks for automounter; Change NSH configuration to use Windows --- arch/arm/src/kinetis/kinetis_sdhc.c | 2 +- configs/freedom-k64f/Kconfig | 30 +++++ configs/freedom-k64f/README.txt | 144 ++++++++++++++++++++-- configs/freedom-k64f/nsh/defconfig | 18 ++- configs/freedom-k64f/nsh/setenv.sh | 4 +- configs/freedom-k64f/src/Makefile | 7 ++ configs/freedom-k64f/src/freedom-k64f.h | 154 ++++++++++++++++++++++-- configs/freedom-k64f/src/k64_bringup.c | 154 +++++------------------- configs/samv71-xult/src/sam_hsmci.c | 12 +- 9 files changed, 368 insertions(+), 157 deletions(-) diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c index afc85f59892..144007c9c3e 100644 --- a/arch/arm/src/kinetis/kinetis_sdhc.c +++ b/arch/arm/src/kinetis/kinetis_sdhc.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/kinetis/kinetis_sdhc.c * - * Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/configs/freedom-k64f/Kconfig b/configs/freedom-k64f/Kconfig index 7c0f1fe281d..e1c32bbfb04 100644 --- a/configs/freedom-k64f/Kconfig +++ b/configs/freedom-k64f/Kconfig @@ -4,4 +4,34 @@ # if ARCH_BOARD_FREEDOM_K64F + +config FRDMK64F_SDHC_AUTOMOUNT + bool "SDHC automounter" + default n + depends on FS_AUTOMOUNTER && SAMA5_SDHC + +if FRDMK64F_SDHC_AUTOMOUNT + +config FRDMK64F_SDHC_AUTOMOUNT_FSTYPE + string "SDHC file system type" + default "vfat" + +config FRDMK64F_SDHC_AUTOMOUNT_BLKDEV + string "SDHC block device" + default "/dev/mmcsd0" + +config FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT + string "SDHC mount point" + default "/mnt/sdcard0" + +config FRDMK64F_SDHC_AUTOMOUNT_DDELAY + int "SDHC debounce delay (milliseconds)" + default 1000 + +config FRDMK64F_SDHC_AUTOMOUNT_UDELAY + int "SDHC unmount retry delay (milliseconds)" + default 2000 + +endif # FRDMK64F_SDHC_AUTOMOUNT + endif diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 0aaeb99a9cc..96594370910 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -11,6 +11,7 @@ Contents o Serial Console o LEDs and Buttons o Networking Support + o SD Card Support o Development Environment o GNU Toolchain Options o Freedom K64F Configuration Options @@ -409,6 +410,134 @@ f Application Configuration -> Network Utilities CONFIG_NSH_NETINIT_RETRYMSEC=2000 : Configure the network monitor as you like CONFIG_NSH_NETINIT_SIGNO=18 +SD Card Support +=============== + + Card Slot + --------- + A micro Secure Digital (SD) card slot is available on the FRDM-K64F connected to + the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro + format SD memory cards. The SD card detect pin (PTE6) is an open switch that + shorts with VDD when card is inserted. + + ------------ ------------- -------- + SD Card Slot Board Signal K64F Pin + ------------ ------------- -------- + DAT0 SDHC0_D0 PTE0 + DAT1 SDHC0_D1 PTE1 + DAT2 SDHC0_D2 PTE5 + CD/DAT3 SDHC0_D3 PTE4 + CMD SDHC0_CMD PTE3 + CLK SDHC0_DCLK PTE2 + SWITCH D_CARD_DETECT PTE6 + ------------ ------------- -------- + + There is no Write Protect pin available to the K64F. + + Configuration Settings + ---------------------- + Enabling SDHC support. The Freedom K64F provides one microSD memory card + slot. Support for the SD slots can be enabled with the following + settings: + + System Type->Kinetic Peripheral Selection + CONFIG_KINETIS_SDHC=y : To enable SDHC0 support + + System Type + CONFIG_GPIO_IRQ=y : GPIO interrupts needed + CONFIG_KINETIS_PORTEINTS=y : Card detect pin is on PTE6 + + Device Drivers -> MMC/SD Driver Support + CONFIG_MMCSD=y : Enable MMC/SD support + CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance + CONFIG_MMCSD_MULTIBLOCK_DISABLE=y : (REVISIT) + CONFIG_MMCSD_HAVECARDDETECT=y : Supports card-detect PIOs + CONFIG_MMCSD_MMCSUPPORT=n : Interferes with some SD cards + CONFIG_MMCSD_SPI=n : No SPI-based MMC/SD support + CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support + CONFIG_SDIO_DMA=y : Use SDIO DMA + CONFIG_SDIO_BLOCKSETUP=y : Needs to know block sizes + + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support + CONFIG_SCHED_HPWORK=y + + Application Configuration -> NSH Library + CONFIG_NSH_ARCHINIT=y : NSH board-initialization, and + CONFIG_LIB_BOARDCTL=y : Or + CONFIG_BOARD_INITIALIZE=y + + Using the SD card + ----------------- + + 1. After booting, the SDHC device will appear as /dev/mmcsd0. + 2. If you try mounting an SD card with nothing in the slot, the mount will + fail: + + nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0 + nsh: mount: mount failed: 19 + + NSH can be configured to provide errors as strings instead of + numbers. But in this case, only the error number is reported. The + error numbers can be found in nuttx/include/errno.h: + + #define ENODEV 19 + #define ENODEV_STR "No such device" + + So the mount command is saying that there is no device or, more + correctly, that there is no card in the SD card slot. + + 3. Insert the SD card. Then the mount should succeed. + + nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0 + nsh> ls /mnt/sd1 + /mnt/sd1: + atest.txt + nsh> cat /mnt/sd1/atest.txt + This is a test + + NOTE: See the next section entitled "Auto-Mounter" for another way + to mount your SD card. + + 4. Before removing the card, you must umount the file system. This is + equivalent to "ejecting" or "safely removing" the card on Windows: It + flushes any cached data to an SD card and makes the SD card unavailable + to the applications. + + nsh> umount -t /mnt/sd0 + + It is now safe to remove the card. NuttX provides into callbacks + that can be used by an application to automatically unmount the + volume when it is removed. But those callbacks are not used in + these configurations. + + Auto-Mounter + ------------ + NuttX implements an auto-mounter than can make working with SD cards + easier. With the auto-mounter, the file system will be automatically + mounted when the SD card is inserted into the SDHC slot and automatically + unmounted when the SD card is removed. + + Here is a sample configuration for the auto-mounter: + + File System Configuration + CONFIG_FS_AUTOMOUNTER=y + + Board-Specific Options + CONFIG_FRDMK64F_SDHC_AUTOMOUNT=y + CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE="vfat" + CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV="/dev/mmcsd0" + CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard" + CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY=1000 + CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY=2000 + + WARNING: SD cards should never be removed without first unmounting + them. This is to avoid data and possible corruption of the file + system. Certainly this is the case if you are writing to the SD card + at the time of the removal. If you use the SD card for read-only access, + however, then I cannot think of any reason why removing the card without + mounting would be harmful. + Development Environment ======================= @@ -639,13 +768,6 @@ Where is one of the following: 1. Most of the notes associated with the nsh configuration apply here as well (see below). - 2. Default platform/toolchain: - - CONFIG_HOST_WINDOWS=y : Cygwin under Windows - CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) - CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary - 3. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU is requests status of the Ethernet link connection. Internal pullup is required when port configuration for MDIO signal is enabled: @@ -682,9 +804,9 @@ Where is one of the following: 2. Default platform/toolchain: - CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). - CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : Buildroot (arm-nuttx-elf-gcc) - CONFIG_ARMV7M_OABI_TOOLCHAIN=y : The older OABI version + CONFIG_HOST_WINDOWS=y : Cygwin under Windows + CONFIG_WINDOWS_CYGWIN=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART3 with the correct pin @@ -723,7 +845,7 @@ Status 2016-07-12: Added support for the KSZ8081 PHY and added the netnsh configuration. The network is basically functional, but a lot more testing is needed to confirm that. - + In testing, I notice a strange thing. If I run at full optimization the code runs (albeit with bugs-to-be-solved). But with no optimization or even at -O1, the system fails to boot. This seems to be related to the diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 7fb687ca4a6..4dd783b2264 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -8,10 +8,14 @@ # # CONFIG_EXPERIMENTAL is not set # CONFIG_DEFAULT_SMALL is not set -CONFIG_HOST_LINUX=y +# CONFIG_HOST_LINUX is not set # CONFIG_HOST_OSX is not set -# CONFIG_HOST_WINDOWS is not set +CONFIG_HOST_WINDOWS=y # CONFIG_HOST_OTHER is not set +# CONFIG_WINDOWS_NATIVE is not set +CONFIG_WINDOWS_CYGWIN=y +# CONFIG_WINDOWS_MSYS is not set +# CONFIG_WINDOWS_OTHER is not set # # Build Configuration @@ -135,12 +139,18 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y # CONFIG_ARMV7M_HAVE_DCACHE is not set # CONFIG_ARMV7M_HAVE_ITCM is not set # CONFIG_ARMV7M_HAVE_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARW is not set # CONFIG_ARMV7M_TOOLCHAIN_IARL is not set -CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y +# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set # CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set # CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set +# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set -CONFIG_ARMV7M_OABI_TOOLCHAIN=y +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y +# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set diff --git a/configs/freedom-k64f/nsh/setenv.sh b/configs/freedom-k64f/nsh/setenv.sh index 45d7f9dd118..abb64617f41 100644 --- a/configs/freedom-k64f/nsh/setenv.sh +++ b/configs/freedom-k64f/nsh/setenv.sh @@ -61,7 +61,7 @@ fi # This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors" # You can this free toolchain here https://launchpad.net/gcc-arm-embedded -#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin" +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin" # This is the path to the location where I installed the devkitARM toolchain # You can get this free toolchain from http://devkitpro.org/ or http://sourceforge.net/projects/devkitpro/ @@ -69,7 +69,7 @@ fi # This is the Cygwin path to the location where I build the buildroot # toolchain. -export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin" +# export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin" # Add the path to the toolchain to the PATH varialble export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" diff --git a/configs/freedom-k64f/src/Makefile b/configs/freedom-k64f/src/Makefile index 65cba8c536c..3538dc384be 100644 --- a/configs/freedom-k64f/src/Makefile +++ b/configs/freedom-k64f/src/Makefile @@ -54,6 +54,13 @@ else ifeq ($(CONFIG_BOARD_INITIALIZE),y) CSRCS += k64_bringup.c endif +ifeq ($(CONFIG_KINETIS_SDHC),y) +CSRCS += k64_sdhc.c +ifeq ($(CONFIG_FS_AUTOMOUNTER),y) +CSRCS += k64_automount.c +endif +endif + ifeq ($(CONFIG_USBDEV),y) CSRCS += k64_usbdev.c endif diff --git a/configs/freedom-k64f/src/freedom-k64f.h b/configs/freedom-k64f/src/freedom-k64f.h index a6758ebb0f6..227a6c71a22 100644 --- a/configs/freedom-k64f/src/freedom-k64f.h +++ b/configs/freedom-k64f/src/freedom-k64f.h @@ -53,9 +53,10 @@ /* Assume we have everything */ -#define HAVE_PROC 1 -#define NSH_HAVEUSBDEV 1 -#define NSH_HAVEMMCSD 1 +#define HAVE_PROC 1 +#define HAVE_MMCSD 1 +#define HAVE_AUTOMOUNTER 1 +#define HAVE_USBDEV 1 /* Automount procfs */ @@ -83,12 +84,18 @@ */ #if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC) -# undef NSH_HAVEMMCSD +# undef HAVE_MMCSD #endif -#ifdef NSH_HAVEMMCSD +#ifdef HAVE_MMCSD # if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 -# error "Only one MMC/SD slot, slot 0" +# error Only one MMC/SD slot, slot 0 +# endif + +# ifdef CONFIG_NSH_MMCSDMINOR +# define MMSCD_MINOR CONFIG_NSH_MMCSDMINOR +# else +# define MMSCD_MINOR 0 # endif /* We expect to receive GPIO interrupts for card insertion events */ @@ -100,12 +107,49 @@ # ifndef CONFIG_KINETIS_PORTEINTS # error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt" # endif + #endif +/* Automounter */ + +#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_MMCSD) +# undef HAVE_AUTOMOUNTER +# undef CONFIG_FRDMK64F_SDHC_AUTOMOUNT +#endif + +#ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT +# undef HAVE_AUTOMOUNTER +#endif + +/* Automounter defaults */ + +#ifdef HAVE_AUTOMOUNTER + +# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE "vfat" +# endif + +# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV "/dev/mmcds0" +# endif + +# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0" +# endif + +# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY 1000 +# endif + +# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY 2000 +# endif +#endif /* HAVE_AUTOMOUNTER */ + /* Can't support USB features if USB is not enabled */ #ifndef CONFIG_USBDEV -# undef NSH_HAVEUSBDEV +# undef HAVE_USBDEV #endif /* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI @@ -126,6 +170,18 @@ * format SD memory cards. The SD card detect pin (PTE6) is an open switch that * shorts with VDD when card is inserted. * + * ------------ ------------- -------- + * SD Card Slot Board Signal K64F Pin + * ------------ ------------- -------- + * DAT0 SDHC0_D0 PTE0 + * DAT1 SDHC0_D1 PTE1 + * DAT2 SDHC0_D2 PTE5 + * CD/DAT3 SDHC0_D3 PTE4 + * CMD SDHC0_CMD PTE3 + * CLK SDHC0_DCLK PTE2 + * SWITCH D_CARD_DETECT PTE6 + * ------------ ------------- -------- + * * There is no Write Protect pin available to the K64F. */ @@ -200,5 +256,89 @@ void weak_function k64_usbinitialize(void); int k64_bringup(void); #endif +/**************************************************************************** + * Name: k64_sdhc_initialize + * + * Description: + * Inititialize the SDHC SD card slot + * + ****************************************************************************/ + +#ifdef HAVE_MMCSD +int k64_sdhc_initialize(void); +#else +# define k64_sdhc_initialize() (OK) +#endif + +/************************************************************************************ + * Name: k64_cardinserted + * + * Description: + * Check if a card is inserted into the SDHC slot + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +bool k64_cardinserted(void); +#else +# define k64_cardinserted() (false) +#endif + +/************************************************************************************ + * Name: k64_writeprotected + * + * Description: + * Check if the card in the MMC/SD slot is write protected + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +bool k64_writeprotected(void); +#else +# define k64_writeprotected() (false) +#endif + +/************************************************************************************ + * Name: k64_automount_initialize + * + * Description: + * Configure auto-mounter for the configured SDHC slot + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +void k64_automount_initialize(void); +#endif + +/************************************************************************************ + * Name: k64_automount_event + * + * Description: + * The SDHC card detection logic has detected an insertion or removal event. It + * has already scheduled the MMC/SD block driver operations. Now we need to + * schedule the auto-mount event which will occur with a substantial delay to make + * sure that everything has settle down. + * + * Input Parameters: + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +void k64_automount_event(bool inserted); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_FREEDOM_K64F_SRC_FREEDOM_K64F_H */ diff --git a/configs/freedom-k64f/src/k64_bringup.c b/configs/freedom-k64f/src/k64_bringup.c index 0cbbb1bb280..9cfa47b1183 100644 --- a/configs/freedom-k64f/src/k64_bringup.c +++ b/configs/freedom-k64f/src/k64_bringup.c @@ -39,112 +39,26 @@ #include +#include #include -#include -#include #include #include -#ifdef CONFIG_KINETIS_SDHC -# include -# include -#endif - -#include "kinetis.h" #include "freedom-k64f.h" #if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE) -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* This structure encapsulates the global variable used in this file and - * reduces the probability of name collistions. - */ - -#ifdef NSH_HAVEMMCSD -struct k64_nsh_s -{ - FAR struct sdio_dev_s *sdhc; /* SDIO driver handle */ - bool inserted; /* True: card is inserted */ -}; -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#ifdef NSH_HAVEMMCSD -static struct k64_nsh_s g_nsh; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: k64_mediachange - ****************************************************************************/ - -#ifdef NSH_HAVEMMCSD -static void k64_mediachange(void) -{ - bool inserted; - - /* Get the current value of the card detect pin. This pin is pulled up on - * board. So low means that a card is present. - */ - - inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); - - /* Has the pin changed state? */ - - if (inserted != g_nsh.inserted) - { - /* Yes.. perform the appropriate action (this might need some debounce). */ - - g_nsh.inserted = inserted; - sdhc_mediachange(g_nsh.sdhc, inserted); - - /* If the card has been inserted, then check if it is write protected - * as well. The pin is pulled up, but apparently logic high means - * write protected. - */ - - if (inserted) - { - sdhc_wrprotect(g_nsh.sdhc, kinetis_gpioread(GPIO_SD_WRPROTECT)); - } - } -} -#endif - -/**************************************************************************** - * Name: k64_cdinterrupt - ****************************************************************************/ - -#ifdef NSH_HAVEMMCSD -static int k64_cdinterrupt(int irq, FAR void *context) -{ - /* All of the work is done by k64_mediachange() */ - - k64_mediachange(); - return OK; -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: k64_bringup * * Description: * Bring up board features * - ************************************************************************************/ + ****************************************************************************/ int k64_bringup(void) { @@ -165,52 +79,40 @@ int k64_bringup(void) } #endif -#ifdef NSH_HAVEMMCSD - /* Configure GPIO pins */ +#ifdef HAVE_MMCSD + /* Initialize the SDHC driver */ - /* Attached the card detect interrupt (but don't enable it yet) */ - - kinetis_pinconfig(GPIO_SD_CARDDETECT); - kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt); - - /* Configure the write protect GPIO */ - - //kinetis_pinconfig(GPIO_SD_WRPROTECT); - - /* Mount the SDHC-based MMC/SD block driver */ - /* First, get an instance of the SDHC interface */ - - syslog(LOG_INFO, "Initializing SDHC slot %d\n", MMCSD_SLOTNO); - - g_nsh.sdhc = sdhc_initialize(MMCSD_SLOTNO); - if (!g_nsh.sdhc) + ret = k64_sdhc_initialize(0); + if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize SDHC slot %d\n", - MMCSD_SLOTNO); - return -ENODEV; + mcerr("ERROR: k64_sdhc_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, 0, ret); } - /* Now bind the SDHC interface to the MMC/SD driver */ - - syslog(LOG_INFO, "Bind SDHC to the MMC/SD driver, minor=%d\n", - CONFIG_NSH_MMCSDMINOR); - - ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_nsh.sdhc); - if (ret != OK) +#ifdef CONFIG_FRDMK64F_SDHC_MOUNT + else { - syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); - return ret; + /* REVISIT: A delay seems to be required here or the mount will fail. */ + /* Mount the volume on HSMCI0 */ + + ret = mount(CONFIG_FRDMK64F_SDHC_MOUNT_BLKDEV, + CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT, + CONFIG_FRDMK64F_SDHC_MOUNT_FSTYPE, + 0, NULL); + + if (ret < 0) + { + mcerr("ERROR: Failed to mount %s: %d\n", + CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT, errno); + } } - syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n"); +#endif /* CONFIG_FRDMK64F_SDHC_MOUNT */ +#endif /* HAVE_MMCSD */ - /* Handle the initial card state */ +#ifdef HAVE_AUTOMOUNTER + /* Initialize the auto-mounter */ - k64_mediachange(); - - /* Enable CD interrupts to handle subsequent media changes */ - - kinetis_pinirqenable(GPIO_SD_CARDDETECT); + k64_automount_initialize(); #endif UNUSED(ret); diff --git a/configs/samv71-xult/src/sam_hsmci.c b/configs/samv71-xult/src/sam_hsmci.c index 85e66b048d5..2b4cb3295f8 100644 --- a/configs/samv71-xult/src/sam_hsmci.c +++ b/configs/samv71-xult/src/sam_hsmci.c @@ -129,7 +129,7 @@ bool sam_cardinserted_internal(struct sam_hsmci_state_s *state) /* Get the state of the PIO pin */ inserted = sam_gpioread(state->cdcfg); - finfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES"); + mcinfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES"); return !inserted; } @@ -221,12 +221,12 @@ int sam_hsmci_initialize(int slotno, int minor) struct sam_hsmci_state_s *state; int ret; - /* Get the static HSMI description */ + /* Get the static HSMCI description */ state = sam_hsmci_state(slotno); if (!state) { - ferr("ERROR: No state for slotno %d\n", slotno); + mcerr("ERROR: No state for slotno %d\n", slotno); return -EINVAL; } @@ -247,7 +247,7 @@ int sam_hsmci_initialize(int slotno, int minor) state->hsmci = sdio_initialize(slotno); if (!state->hsmci) { - ferr("ERROR: Failed to initialize SDIO slot %d\n", slotno); + mcerr("ERROR: Failed to initialize SDIO slot %d\n", slotno); return -ENODEV; } @@ -256,7 +256,7 @@ int sam_hsmci_initialize(int slotno, int minor) ret = mmcsd_slotinitialize(minor, state->hsmci); if (ret != OK) { - ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + mcerr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); return ret; } @@ -293,7 +293,7 @@ bool sam_cardinserted(int slotno) state = sam_hsmci_state(slotno); if (!state) { - ferr("ERROR: No state for slotno %d\n", slotno); + mcerr("ERROR: No state for slotno %d\n", slotno); return false; } From 0503701b0dd04c1fefc84bf247a0f08eb156362b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 09:24:58 -0600 Subject: [PATCH 006/152] Freedom-K64F: Add hooks for automounter; Change NSH configuration to use Windows --- configs/freedom-k64f/src/k64_automount.c | 327 +++++++++++++++++++++++ configs/freedom-k64f/src/k64_sdhc.c | 239 +++++++++++++++++ 2 files changed, 566 insertions(+) create mode 100644 configs/freedom-k64f/src/k64_automount.c create mode 100644 configs/freedom-k64f/src/k64_sdhc.c diff --git a/configs/freedom-k64f/src/k64_automount.c b/configs/freedom-k64f/src/k64_automount.c new file mode 100644 index 00000000000..4862d55dad4 --- /dev/null +++ b/configs/freedom-k64f/src/k64_automount.c @@ -0,0 +1,327 @@ +/************************************************************************************ + * configs/freedom-k64f/src/k64_automount.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS) +# define CONFIG_DEBUG_FS 1 +#endif + +#include + +#include +#include +#include + +#include "freedom-k64f.h" + +#ifdef HAVE_AUTOMOUNTER + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#ifndef NULL +# define NULL (FAR void *)0 +#endif + +#ifndef OK +# define OK 0 +#endif + +/************************************************************************************ + * Private Types + ************************************************************************************/ +/* This structure represents the changeable state of the automounter */ + +struct k64_automount_state_s +{ + volatile automount_handler_t handler; /* Upper half handler */ + FAR void *arg; /* Handler argument */ + bool enable; /* Fake interrupt enable */ + bool pending; /* Set if there an event while disabled */ +}; + +/* This structure represents the static configuration of an automounter */ + +struct k64_automount_config_s +{ + /* This must be first thing in structure so that we can simply cast from struct + * automount_lower_s to struct k64_automount_config_s + */ + + struct automount_lower_s lower; /* Publicly visible part */ + FAR struct k64_automount_state_s *state; /* Changeable state */ +}; + +/************************************************************************************ + * Private Function Prototypes + ************************************************************************************/ + +static int k64_attach(FAR const struct automount_lower_s *lower, + automount_handler_t isr, FAR void *arg); +static void k64_enable(FAR const struct automount_lower_s *lower, bool enable); +static bool k64_inserted(FAR const struct automount_lower_s *lower); + +/************************************************************************************ + * Private Data + ************************************************************************************/ + +static struct k64_automount_state_s g_sdhc_state; +static const struct k64_automount_config_s g_sdhc_config = +{ + .lower = + { + .fstype = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE, + .blockdev = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV, + .mountpoint = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT, + .ddelay = MSEC2TICK(CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY), + .udelay = MSEC2TICK(CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY), + .attach = k64_attach, + .enable = k64_enable, + .inserted = k64_inserted + }, + .state = &g_sdhc_state +}; + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: k64_attach + * + * Description: + * Attach a new SDHC event handler + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * isr - The new event handler to be attach + * arg - Client data to be provided when the event handler is invoked. + * + * Returned Value: + * Always returns OK + * + ************************************************************************************/ + +static int k64_attach(FAR const struct automount_lower_s *lower, + automount_handler_t isr, FAR void *arg) +{ + FAR const struct k64_automount_config_s *config; + FAR struct k64_automount_state_s *state; + + /* Recover references to our structure */ + + config = (FAR struct k64_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the new handler info (clearing the handler first to eliminate race + * conditions). + */ + + state->handler = NULL; + state->pending = false; + state->arg = arg; + state->handler = isr; + return OK; +} + +/************************************************************************************ + * Name: k64_enable + * + * Description: + * Enable card insertion/removal event detection + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * enable - True: enable event detection; False: disable + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void k64_enable(FAR const struct automount_lower_s *lower, bool enable) +{ + FAR const struct k64_automount_config_s *config; + FAR struct k64_automount_state_s *state; + irqstate_t flags; + + /* Recover references to our structure */ + + config = (FAR struct k64_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the fake enable setting */ + + flags = enter_critical_section(); + state->enable = enable; + + /* Did an interrupt occur while interrupts were disabled? */ + + if (enable && state->pending) + { + /* Yes.. perform the fake interrupt if the interrutp is attached */ + + if (state->handler) + { + bool inserted = k64_cardinserted(); + (void)state->handler(&config->lower, state->arg, inserted); + } + + state->pending = false; + } + + leave_critical_section(flags); +} + +/************************************************************************************ + * Name: k64_inserted + * + * Description: + * Check if a card is inserted into the slot. + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * + * Returned Value: + * True if the card is inserted; False otherwise + * + ************************************************************************************/ + +static bool k64_inserted(FAR const struct automount_lower_s *lower) +{ + FAR const struct k64_automount_config_s *config; + + config = (FAR struct k64_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + return k64_cardinserted(); +} + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: k64_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured SDHC + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +void k64_automount_initialize(void) +{ + FAR void *handle; + + finfo("Initializing automounter(s)\n"); + + /* Initialize the SDHC0 auto-mounter */ + + handle = automount_initialize(&g_sdhc_config.lower); + if (!handle) + { + ferr("ERROR: Failed to initialize auto-mounter for SDHC0\n"); + } +} + +/************************************************************************************ + * Name: k64_automount_event + * + * Description: + * The SDHC card detection logic has detected an insertion or removal event. It + * has already scheduled the MMC/SD block driver operations. Now we need to + * schedule the auto-mount event which will occur with a substantial delay to make + * sure that everything has settle down. + * + * Input Parameters: + * slotno - Identifies the SDHC0 slot: SDHC0_SLOTNO or SDHC1_SLOTNO. There is a + * terminology problem here: Each SDHC supports two slots, slot A and slot B. + * Only slot A is used. So this is not a really a slot, but an HSCMI peripheral + * number. + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ************************************************************************************/ + +void k64_automount_event(bool inserted) +{ + FAR const struct k64_automount_config_s *config = &g_sdhc_config; + FAR struct k64_automount_state_s *state = &g_sdhc_state; + + /* Is the auto-mounter interrupt attached? */ + + if (state->handler) + { + /* Yes.. Have we been asked to hold off interrupts? */ + + if (!state->enable) + { + /* Yes.. just remember the there is a pending interrupt. We will + * deliver the interrupt when interrupts are "re-enabled." + */ + + state->pending = true; + } + else + { + /* No.. forward the event to the handler */ + + (void)state->handler(&config->lower, state->arg, inserted); + } + } +} + +#endif /* HAVE_AUTOMOUNTER */ diff --git a/configs/freedom-k64f/src/k64_sdhc.c b/configs/freedom-k64f/src/k64_sdhc.c new file mode 100644 index 00000000000..7c33abddaaf --- /dev/null +++ b/configs/freedom-k64f/src/k64_sdhc.c @@ -0,0 +1,239 @@ +/**************************************************************************** + * config/freedom-k64f/src/k64_sdhc.c + * + * Copyright (C) 2016 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. + * + ****************************************************************************/ + +/* A micro Secure Digital (SD) card slot is available on the FRDM-K64F connected to + * the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro + * format SD memory cards. The SD card detect pin (PTE6) is an open switch that + * shorts with VDD when card is inserted. + * + * ------------ ------------- -------- + * SD Card Slot Board Signal K64F Pin + * ------------ ------------- -------- + * DAT0 SDHC0_D0 PTE0 + * DAT1 SDHC0_D1 PTE1 + * DAT2 SDHC0_D2 PTE5 + * CD/DAT3 SDHC0_D3 PTE4 + * CMD SDHC0_CMD PTE3 + * CLK SDHC0_DCLK PTE2 + * SWITCH D_CARD_DETECT PTE6 + * ------------ ------------- -------- + * + * There is no Write Protect pin available to the K64F. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "kinetis.h" + +#include "freedom-k64f.h" + +#ifdef HAVE_MMCSD + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ +/* This structure holds static information unique to one SDHC peripheral */ + +struct k64_sdhc_state_s +{ + struct sdio_dev_s *sdhc; /* R/W device handle */ + bool inserted; /* TRUE: card is inserted */ +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* HSCMI device state */ + +static struct k64_sdhc_state_s g_sdhc; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: k64_mediachange + ****************************************************************************/ + +static void k64_mediachange(void) +{ + bool inserted; + + /* Get the current value of the card detect pin. This pin is pulled up on + * board. So low means that a card is present. + */ + + inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); + + /* Has the pin changed state? */ + + if (inserted != g_sdhc.inserted) + { + /* Yes.. perform the appropriate action (this might need some debounce). */ + + g_sdhc.inserted = inserted; + sdhc_mediachange(g_sdhc.sdhc, inserted); + +#ifdef CONFIG_FRDMK64F_SDHC_AUTOMOUNT + /* Let the automounter know about the insertion event */ + + k64_automount_event(SDHC0_SLOTNO, k64_cardinserted()); +#endif + } +} + +/**************************************************************************** + * Name: k64_cdinterrupt + ****************************************************************************/ + +static int k64_cdinterrupt(int irq, FAR void *context) +{ + /* All of the work is done by k64_mediachange() */ + + k64_mediachange(); + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: k64_sdhc_initialize + * + * Description: + * Inititialize the SDHC SD card slot + * + ****************************************************************************/ + +int k64_sdhc_initialize(void) +{ + struct k64_sdhc_state_s *state = &g_sdhc; + int ret; + + /* Configure GPIO pins */ + + /* Attached the card detect interrupt (but don't enable it yet) */ + + kinetis_pinconfig(GPIO_SD_CARDDETECT); + kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt); + + /* Configure the write protect GPIO -- None */ + + /* Mount the SDHC-based MMC/SD block driver */ + /* First, get an instance of the SDHC interface */ + + mcinfo("Initializing SDHC slot %d\n", MMCSD_SLOTNO); + + g_sdhc.sdhc = sdhc_initialize(MMCSD_SLOTNO); + if (!g_sdhc.sdhc) + { + mcerr("ERROR: Failed to initialize SDHC slot %d\n", MMCSD_SLOTNO); + return -ENODEV; + } + + /* Now bind the SDHC interface to the MMC/SD driver */ + + mcinfo("Bind SDHC to the MMC/SD driver, minor=%d\n", MMSCD_MINOR); + + ret = mmcsd_slotinitialize(MMSCD_MINOR, g_sdhc.sdhc); + if (ret != OK) + { + syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); + return ret; + } + + syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n"); + + /* Handle the initial card state */ + + k64_mediachange(); + + /* Enable CD interrupts to handle subsequent media changes */ + + kinetis_pinirqenable(GPIO_SD_CARDDETECT); + return OK; +} + +/**************************************************************************** + * Name: k64_cardinserted + * + * Description: + * Check if a card is inserted into the SDHC slot + * + ****************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +bool k64_cardinserted(void) +{ + return !kinetis_gpioread(GPIO_SD_CARDDETECT); +} +#endif + +/**************************************************************************** + * Name: k64_writeprotected + * + * Description: + * Check if a card is inserted into the SDHC slot + * + ****************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +bool k64_writeprotected(void) +{ + /* There are no write protect pins */ + + return false; +} +#endif + +#endif /* HAVE_MMCSD */ From a7d8279714c3069344455f2094782ded3c1dfd5a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 09:56:02 -0600 Subject: [PATCH 007/152] Kinetis and Freedom-K64F: Remove unused configuration variable; fix some compile issues; SDHC is now enabled in the nsh configuration (but does not work) --- arch/arm/src/kinetis/Kconfig | 7 ---- arch/arm/src/kinetis/kinetis_sdhc.c | 4 --- configs/freedom-k64f/README.txt | 5 +++ configs/freedom-k64f/nsh/defconfig | 47 ++++++++++++++++++++------ configs/freedom-k64f/src/k64_bringup.c | 5 +-- configs/freedom-k64f/src/k64_sdhc.c | 2 +- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index 6a0c0367657..4be634107b2 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -615,13 +615,6 @@ config KINETIS_SD4BIT_FREQ Frequency to use for transferring data to/from an SD card using all four data lines. endif - -config KINETIS_SDHC_DMAPRIO - int "SDHC DMA priority" - depends on SDIO_DMA - ---help--- - SDHC DMA priority - endmenu # Kinetis SDHC Configuration menu "Kinetis UART Configuration" diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c index 144007c9c3e..0f1197b6e7b 100644 --- a/arch/arm/src/kinetis/kinetis_sdhc.c +++ b/arch/arm/src/kinetis/kinetis_sdhc.c @@ -85,10 +85,6 @@ # define CONFIG_KINETIS_SDHC_PRIO NVIC_SYSH_PRIORITY_DEFAULT #endif -#ifndef CONFIG_KINETIS_SDHC_DMAPRIO -# define CONFIG_KINETIS_SDHC_DMAPRIO DMA_CCR_PRIMED -#endif - #ifndef CONFIG_DEBUG_MEMCARD_INFO # undef CONFIG_SDIO_XFRDEBUG #endif diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 96594370910..2540914f5f1 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -851,3 +851,8 @@ Status even at -O1, the system fails to boot. This seems to be related to the watchdog timer. + 2016-07-13: Add SD automounter logic; broke out SDHC logic into a separate + file. The nsh configuration now has SDHC enabled be default. Does not + yet work. You might want to disable SDHC and MMC/SD if you are using + this configuration. + \ No newline at end of file diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 4dd783b2264..e13146ac73d 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -140,12 +140,9 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y # CONFIG_ARMV7M_HAVE_ITCM is not set # CONFIG_ARMV7M_HAVE_DTCM is not set # CONFIG_ARMV7M_TOOLCHAIN_IARW is not set -# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set # CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set # CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set -# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set -# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set # CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set # CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set @@ -218,7 +215,7 @@ CONFIG_KINETIS_UART3=y # CONFIG_KINETIS_ADC1 is not set # CONFIG_KINETIS_CMP is not set # CONFIG_KINETIS_VREF is not set -# CONFIG_KINETIS_SDHC is not set +CONFIG_KINETIS_SDHC=y # CONFIG_KINETIS_FTM0 is not set # CONFIG_KINETIS_FTM1 is not set # CONFIG_KINETIS_FTM2 is not set @@ -239,11 +236,23 @@ CONFIG_KINETIS_UART3=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +CONFIG_GPIO_IRQ=y +# CONFIG_KINETIS_PORTAINTS is not set +# CONFIG_KINETIS_PORTBINTS is not set +# CONFIG_KINETIS_PORTCINTS is not set +# CONFIG_KINETIS_PORTDINTS is not set +CONFIG_KINETIS_PORTEINTS=y + +# +# Kinetis SDHC Configuration +# +# CONFIG_KINETIS_SDHC_ABSFREQ is not set # # Kinetis UART Configuration # +CONFIG_SDIO_DMA=y +# CONFIG_SDIO_WIDTH_D1_ONLY is not set # # Architecture Options @@ -403,6 +412,7 @@ CONFIG_NAME_MAX=32 # CONFIG_SCHED_STARTHOOK is not set # CONFIG_SCHED_ATEXIT is not set # CONFIG_SCHED_ONEXIT is not set +# CONFIG_SIG_EVTHREAD is not set # # Signal Numbers @@ -411,6 +421,7 @@ CONFIG_SIG_SIGUSR1=1 CONFIG_SIG_SIGUSR2=2 CONFIG_SIG_SIGALARM=3 CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGWORK=17 # # POSIX Message Queue Options @@ -422,8 +433,11 @@ CONFIG_MQ_MAXMSGSIZE=32 # # Work queue support # -# CONFIG_SCHED_WORKQUEUE is not set -# CONFIG_SCHED_HPWORK is not set +CONFIG_SCHED_WORKQUEUE=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=224 +CONFIG_SCHED_HPWORKPERIOD=50000 +CONFIG_SCHED_HPWORKSTACKSIZE=2048 # CONFIG_SCHED_LPWORK is not set # @@ -489,7 +503,18 @@ CONFIG_DEV_NULL=y # CONFIG_RGBLED is not set # CONFIG_PCA9635PW is not set # CONFIG_NCP5623C is not set -# CONFIG_MMCSD is not set +CONFIG_MMCSD=y +CONFIG_MMCSD_NSLOTS=1 +# CONFIG_MMCSD_READONLY is not set +CONFIG_MMCSD_MULTIBLOCK_DISABLE=y +# CONFIG_MMCSD_MMCSUPPORT is not set +CONFIG_MMCSD_HAVECARDDETECT=y +CONFIG_ARCH_HAVE_SDIO=y +# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set +CONFIG_MMCSD_SDIO=y +# CONFIG_SDIO_PREFLIGHT is not set +# CONFIG_SDIO_MUXBUS is not set +CONFIG_SDIO_BLOCKSETUP=y # CONFIG_MODEM is not set # CONFIG_MTD is not set # CONFIG_EEPROM is not set @@ -594,8 +619,9 @@ CONFIG_FS_WRITABLE=y CONFIG_FS_MQUEUE_MPATH="/var/mqueue" # CONFIG_FS_RAMMAP is not set CONFIG_FS_FAT=y -# CONFIG_FAT_LCNAMES is not set -# CONFIG_FAT_LFN is not set +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 # CONFIG_FS_FATTIME is not set # CONFIG_FAT_FORCE_INDIRECT is not set # CONFIG_FAT_DMAMEMORY is not set @@ -874,6 +900,7 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_WGET is not set # CONFIG_NSH_DISABLE_XD is not set CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 # # Configure Command Options diff --git a/configs/freedom-k64f/src/k64_bringup.c b/configs/freedom-k64f/src/k64_bringup.c index 9cfa47b1183..b307c7038ec 100644 --- a/configs/freedom-k64f/src/k64_bringup.c +++ b/configs/freedom-k64f/src/k64_bringup.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "freedom-k64f.h" @@ -82,10 +83,10 @@ int k64_bringup(void) #ifdef HAVE_MMCSD /* Initialize the SDHC driver */ - ret = k64_sdhc_initialize(0); + ret = k64_sdhc_initialize(); if (ret < 0) { - mcerr("ERROR: k64_sdhc_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, 0, ret); + mcerr("ERROR: k64_sdhc_initialize() failed: %d\n", ret); } #ifdef CONFIG_FRDMK64F_SDHC_MOUNT diff --git a/configs/freedom-k64f/src/k64_sdhc.c b/configs/freedom-k64f/src/k64_sdhc.c index 7c33abddaaf..6b4dcf35e36 100644 --- a/configs/freedom-k64f/src/k64_sdhc.c +++ b/configs/freedom-k64f/src/k64_sdhc.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -157,7 +158,6 @@ static int k64_cdinterrupt(int irq, FAR void *context) int k64_sdhc_initialize(void) { - struct k64_sdhc_state_s *state = &g_sdhc; int ret; /* Configure GPIO pins */ From f673b2d02a07395d8f2e05a6f37e5ba7cc25b9cb Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Wed, 13 Jul 2016 10:09:14 -0600 Subject: [PATCH 008/152] This commit solves a problem which causes data loss while sending data via USB. This problem is caused by an incorrect handling of the endpoint state in the USB driver sam_usbdevhs. This leads under some circumstances to situations in which an DMA transfer is setup while a previous DMA transfer is currently active. Amongst other things I introduced the new endpoint state USBHS_EPSTATE_SENDING_DMA for the fix. To reproduce the problem, I used a program which send as many data as possible via a CDC/ACM device and verified the received data on the PC. --- arch/arm/src/samv7/sam_usbdevhs.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c index 07bfe1d2d4b..087db9c0e1a 100644 --- a/arch/arm/src/samv7/sam_usbdevhs.c +++ b/arch/arm/src/samv7/sam_usbdevhs.c @@ -301,6 +301,7 @@ enum sam_epstate_e USBHS_EPSTATE_STALLED, /* Endpoint is stalled */ USBHS_EPSTATE_IDLE, /* Endpoint is idle (i.e. ready for transmission) */ USBHS_EPSTATE_SENDING, /* Endpoint is sending data */ + USBHS_EPSTATE_SENDING_DMA, /* Endpoint is sending data via DMA */ USBHS_EPSTATE_NBUSYBK, /* Endpoint DMA complete, waiting for NBUSYBK==0 */ USBHS_EPSTATE_RECEIVING, /* Endpoint is receiving data */ /* --- Endpoint 0 Only --- */ @@ -1006,7 +1007,7 @@ static void sam_dma_wrsetup(struct sam_usbdev_s *priv, struct sam_ep_s *privep, /* Switch to the sending state */ - privep->epstate = USBHS_EPSTATE_SENDING; + privep->epstate = USBHS_EPSTATE_SENDING_DMA; privreq->inflight = 0; /* Get the endpoint number */ @@ -1211,16 +1212,23 @@ static void sam_req_complete(struct sam_ep_s *privep, int16_t result) privreq->req.result = result; - /* Callback to the request completion handler */ - - privreq->flink = NULL; - privreq->req.callback(&privep->ep, &privreq->req); - - /* Reset the endpoint state and restore the stalled indication */ + /* Reset the endpoint state and restore the stalled indication. + * + * At least the USB class CDC/ACM calls the function sam_ep_submit within + * the callback. This function uses sam_req_write or sam_req_read to process + * the request, both functions can change the state. Therefore it is verry + * important to set the state to USBHS_EPSTATE_IDLE before the callback is + * called. + */ privep->epstate = USBHS_EPSTATE_IDLE; privep->zlpneeded = false; privep->zlpsent = false; + + /* Callback to the request completion handler */ + + privreq->flink = NULL; + privreq->req.callback(&privep->ep, &privreq->req); } } @@ -2497,7 +2505,8 @@ static void sam_dma_interrupt(struct sam_usbdev_s *priv, int epno) /* Were we sending? Or receiving? */ - if (privep->epstate == USBHS_EPSTATE_SENDING) + if (privep->epstate == USBHS_EPSTATE_SENDING || + privep->epstate == USBHS_EPSTATE_SENDING_DMA) { uint32_t nbusybk; uint32_t byct; @@ -2923,7 +2932,8 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno) */ if (privep->epstate == USBHS_EPSTATE_RECEIVING || - privep->epstate == USBHS_EPSTATE_SENDING) + privep->epstate == USBHS_EPSTATE_SENDING || + privep->epstate == USBHS_EPSTATE_SENDING_DMA) { sam_req_complete(privep, -EPROTO); } From b38c6da401ec822c03b824fb638af15a883aff4e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 10:11:41 -0600 Subject: [PATCH 009/152] Update a README --- configs/freedom-k64f/README.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 2540914f5f1..c53b23a15b9 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -843,8 +843,8 @@ Status error. 2016-07-12: Added support for the KSZ8081 PHY and added the netnsh - configuration. The network is basically functional, but a lot more - testing is needed to confirm that. + configuration. The network is basically functional. More testing is + needed, but I have not seen any obvious network failures. In testing, I notice a strange thing. If I run at full optimization the code runs (albeit with bugs-to-be-solved). But with no optimization or From b18369d77257dc38901f029fdc13d2a8e5750bf5 Mon Sep 17 00:00:00 2001 From: Max Neklyudov Date: Wed, 13 Jul 2016 10:12:14 -0600 Subject: [PATCH 010/152] ADC: add macros to call ADC routines --- include/nuttx/analog/adc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/nuttx/analog/adc.h b/include/nuttx/analog/adc.h index 0044c03364d..a566f2a0ded 100644 --- a/include/nuttx/analog/adc.h +++ b/include/nuttx/analog/adc.h @@ -72,6 +72,12 @@ # define CONFIG_ADC_FIFOSIZE 255 #endif +#define ADC_RESET(dev) ((dev)->ad_ops->ao_reset((dev))) +#define ADC_SETUP(dev) ((dev)->ad_ops->ao_setup((dev))) +#define ADC_SHUTDOWN(dev) ((dev)->ad_ops->ao_shutdown((dev))) +#define ADC_RXINT(dev) ((dev)->ad_ops->ao_rxint((dev))) +#define ADC_IOCTL(dev,cmd,arg) ((dev)->ad_ops->ao_ioctl((dev),(cmd),(arg))) + /************************************************************************************ * Public Types ************************************************************************************/ From 067f63fc186d738a42eb1e63599e45744212561d Mon Sep 17 00:00:00 2001 From: Max Neklyudov Date: Wed, 13 Jul 2016 10:20:38 -0600 Subject: [PATCH 011/152] STM32: Fix bug in oneshot timer --- arch/arm/src/stm32/stm32_oneshot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_oneshot.c b/arch/arm/src/stm32/stm32_oneshot.c index 8f5e89df622..a47307e7212 100644 --- a/arch/arm/src/stm32/stm32_oneshot.c +++ b/arch/arm/src/stm32/stm32_oneshot.c @@ -95,9 +95,10 @@ static int stm32_oneshot_handler(int irq, void *context) * Disable the TC now and disable any further interrupts. */ + STM32_TIM_SETISR(oneshot->tch, NULL, 0); + STM32_TIM_DISABLEINT(oneshot->tch, 0); STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED); STM32_TIM_ACKINT(oneshot->tch, 0); - STM32_TIM_DISABLEINT(oneshot->tch, 0); /* The timer is no longer running */ @@ -351,6 +352,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot, /* Now we can disable the interrupt and stop the timer. */ STM32_TIM_DISABLEINT(oneshot->tch, 0); + STM32_TIM_SETISR(oneshot->tch, NULL, 0); STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED); oneshot->running = false; From abf909d2c0a0abdb83cb52a0d122f0935eef351f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 14:09:24 -0600 Subject: [PATCH 012/152] Freedom K64F: Calibrate timing loop --- configs/freedom-k64f/netnsh/defconfig | 2 +- configs/freedom-k64f/nsh/defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index a4a8968bdd5..bb0ee7a5817 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -285,7 +285,7 @@ CONFIG_ARCH_HAVE_RAMVECTORS=y # # Board Settings # -CONFIG_BOARD_LOOPSPERMSEC=9535 +CONFIG_BOARD_LOOPSPERMSEC=10016 # CONFIG_ARCH_CALIBRATION is not set # diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index e13146ac73d..347552c2ed8 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -286,7 +286,7 @@ CONFIG_ARCH_HAVE_RAMVECTORS=y # # Board Settings # -CONFIG_BOARD_LOOPSPERMSEC=9535 +CONFIG_BOARD_LOOPSPERMSEC=10016 # CONFIG_ARCH_CALIBRATION is not set # From 6fda0366151fbb762754ad74686e126733476461 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 14:09:51 -0600 Subject: [PATCH 013/152] Eliminate a warning --- drivers/mmcsd/mmcsd_sdio.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index be934950b9e..46ee65a9d54 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -171,7 +171,7 @@ static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]); static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]); -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32_t cid[4]); #else @@ -558,7 +558,7 @@ static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) { -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO struct mmcsd_csd_s decoded; #endif unsigned int readbllen; @@ -578,7 +578,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) * TRANSFER_RATE_UNIT 2:0 Rate mantissa */ -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO memset(&decoded, 0, sizeof(struct mmcsd_csd_s)); decoded.csdstructure = csd[0] >> 30; decoded.mmcspecvers = (csd[0] >> 26) & 0x0f; @@ -606,7 +606,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) priv->dsrimp = (csd[1] >> 12) & 1; readbllen = (csd[1] >> 16) & 0x0f; -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO decoded.ccc = (csd[1] >> 20) & 0x0fff; decoded.readbllen = (csd[1] >> 16) & 0x0f; decoded.readblpartial = (csd[1] >> 15) & 1; @@ -667,7 +667,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) priv->blocksize = 1 << 9; priv->nblocks = priv->capacity >> 9; -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO decoded.u.sdblock.csize = csize; decoded.u.sdblock.sderblen = (csd[2] >> 14) & 1; decoded.u.sdblock.sdsectorsize = (csd[2] >> 7) & 0x7f; @@ -703,7 +703,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) priv->blockshift = 9; } -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO if (IS_SD(priv->type)) { decoded.u.sdbyte.csize = csize; @@ -753,7 +753,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) tmpwriteprotect = (csd[3] >> 12) & 1; priv->wrprotect = (permwriteprotect || tmpwriteprotect); -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO decoded.wpgrpen = csd[3] >> 31; decoded.mmcdfltecc = (csd[3] >> 29) & 3; decoded.r2wfactor = (csd[3] >> 26) & 7; @@ -844,7 +844,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) * ****************************************************************************/ -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32_t cid[4]) { struct mmcsd_cid_s decoded; @@ -910,7 +910,7 @@ static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32_t cid[4]) static void mmcsd_decodeSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) { -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO struct mmcsd_scr_s decoded; #endif @@ -923,14 +923,14 @@ struct mmcsd_scr_s decoded; * Reserved 47:32 16-bit SD reserved space */ -#ifdef CONFIG_ENDIAN_BIG /* Card transfers SCR in big-endian order */ +#ifdef CONFIG_ENDIAN_BIG /* Card transfers SCR in big-endian order */ priv->buswidth = (scr[0] >> 16) & 15; #else priv->buswidth = (scr[0] >> 8) & 15; #endif -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) -#ifdef CONFIG_ENDIAN_BIG /* Card SCR is big-endian order / CPU also big-endian +#ifdef CONFIG_DEBUG_FS_INFO +#ifdef CONFIG_ENDIAN_BIG /* Card SCR is big-endian order / CPU also big-endian * 60 56 52 48 44 40 36 32 * VVVV SSSS ESSS BBBB RRRR RRRR RRRR RRRR */ decoded.scrversion = scr[0] >> 28; @@ -952,7 +952,7 @@ struct mmcsd_scr_s decoded; * Reserved 31:0 32-bits reserved for manufacturing usage. */ -#if defined(CONFIG_DEBUG_FEATURES) && defined (CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS) +#ifdef CONFIG_DEBUG_FS_INFO decoded.mfgdata = scr[1]; /* Might be byte reversed! */ finfo("SCR:\n"); From 02eda2fdece6a9e6212026090a17d41736c233e6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 14:26:18 -0600 Subject: [PATCH 014/152] Freedom K64F: SDHC-related changes from bring-up testing. --- configs/freedom-k64f/Kconfig | 7 +++---- configs/freedom-k64f/README.txt | 5 ++++- configs/freedom-k64f/src/freedom-k64f.h | 2 +- configs/freedom-k64f/src/k64_automount.c | 9 ++------- configs/freedom-k64f/src/k64_sdhc.c | 18 +++++++++++++++--- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/configs/freedom-k64f/Kconfig b/configs/freedom-k64f/Kconfig index e1c32bbfb04..86130927032 100644 --- a/configs/freedom-k64f/Kconfig +++ b/configs/freedom-k64f/Kconfig @@ -8,7 +8,7 @@ if ARCH_BOARD_FREEDOM_K64F config FRDMK64F_SDHC_AUTOMOUNT bool "SDHC automounter" default n - depends on FS_AUTOMOUNTER && SAMA5_SDHC + depends on FS_AUTOMOUNTER && KINETIS_SDHC if FRDMK64F_SDHC_AUTOMOUNT @@ -22,7 +22,7 @@ config FRDMK64F_SDHC_AUTOMOUNT_BLKDEV config FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT string "SDHC mount point" - default "/mnt/sdcard0" + default "/mnt/sdcard" config FRDMK64F_SDHC_AUTOMOUNT_DDELAY int "SDHC debounce delay (milliseconds)" @@ -33,5 +33,4 @@ config FRDMK64F_SDHC_AUTOMOUNT_UDELAY default 2000 endif # FRDMK64F_SDHC_AUTOMOUNT - -endif +endif # ARCH_BOARD_FREEDOM_K64F diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index c53b23a15b9..9b7e6862967 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -853,6 +853,9 @@ Status 2016-07-13: Add SD automounter logic; broke out SDHC logic into a separate file. The nsh configuration now has SDHC enabled be default. Does not - yet work. You might want to disable SDHC and MMC/SD if you are using + yet work. The basic problem seems to be that it does not sense the + presence of the SD card on PTE6. No interrupts are generated when the + SD card is inserted or removed. You might want to disable SDHC and + MMC/SD if you are using this configuration. \ No newline at end of file diff --git a/configs/freedom-k64f/src/freedom-k64f.h b/configs/freedom-k64f/src/freedom-k64f.h index 227a6c71a22..aac232930bd 100644 --- a/configs/freedom-k64f/src/freedom-k64f.h +++ b/configs/freedom-k64f/src/freedom-k64f.h @@ -134,7 +134,7 @@ # endif # ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT -# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0" +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard" # endif # ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY diff --git a/configs/freedom-k64f/src/k64_automount.c b/configs/freedom-k64f/src/k64_automount.c index 4862d55dad4..8ec1be29ffe 100644 --- a/configs/freedom-k64f/src/k64_automount.c +++ b/configs/freedom-k64f/src/k64_automount.c @@ -149,7 +149,7 @@ static int k64_attach(FAR const struct automount_lower_s *lower, /* Recover references to our structure */ config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); + DEBUGASSERT(config != NULL && config->state != NULL); state = config->state; @@ -188,7 +188,7 @@ static void k64_enable(FAR const struct automount_lower_s *lower, bool enable) /* Recover references to our structure */ config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); + DEBUGASSERT(config != NULL && config->state != NULL); state = config->state; @@ -231,11 +231,6 @@ static void k64_enable(FAR const struct automount_lower_s *lower, bool enable) static bool k64_inserted(FAR const struct automount_lower_s *lower) { - FAR const struct k64_automount_config_s *config; - - config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); - return k64_cardinserted(); } diff --git a/configs/freedom-k64f/src/k64_sdhc.c b/configs/freedom-k64f/src/k64_sdhc.c index 6b4dcf35e36..4083235048b 100644 --- a/configs/freedom-k64f/src/k64_sdhc.c +++ b/configs/freedom-k64f/src/k64_sdhc.c @@ -114,11 +114,14 @@ static void k64_mediachange(void) */ inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); + mcinfo("inserted: %s\n", inserted ? "Yes" : "No"); /* Has the pin changed state? */ if (inserted != g_sdhc.inserted) { + mcinfo("Media change: %d->%d\n", g_sdhc.inserted, inserted); + /* Yes.. perform the appropriate action (this might need some debounce). */ g_sdhc.inserted = inserted; @@ -127,7 +130,7 @@ static void k64_mediachange(void) #ifdef CONFIG_FRDMK64F_SDHC_AUTOMOUNT /* Let the automounter know about the insertion event */ - k64_automount_event(SDHC0_SLOTNO, k64_cardinserted()); + k64_automount_event(k64_cardinserted()); #endif } } @@ -162,9 +165,10 @@ int k64_sdhc_initialize(void) /* Configure GPIO pins */ + kinetis_pinconfig(GPIO_SD_CARDDETECT); + /* Attached the card detect interrupt (but don't enable it yet) */ - kinetis_pinconfig(GPIO_SD_CARDDETECT); kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt); /* Configure the write protect GPIO -- None */ @@ -215,7 +219,15 @@ int k64_sdhc_initialize(void) #ifdef HAVE_AUTOMOUNTER bool k64_cardinserted(void) { - return !kinetis_gpioread(GPIO_SD_CARDDETECT); + bool inserted; + + /* Get the current value of the card detect pin. This pin is pulled up on + * board. So low means that a card is present. + */ + + inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); + mcinfo("inserted: %s\n", inserted ? "Yes" : "No"); + return inserted; } #endif From 37e10a54ae62f01bb6db5b853d928622d0767368 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 13 Jul 2016 15:38:47 -0600 Subject: [PATCH 015/152] Kinetis: Eliminate a warning. Freedom-K64F: Update a README file --- arch/arm/src/kinetis/kinetis_usbdev.c | 4 +- configs/freedom-k64f/README.txt | 121 +++++++++++++++++++++----- 2 files changed, 100 insertions(+), 25 deletions(-) diff --git a/arch/arm/src/kinetis/kinetis_usbdev.c b/arch/arm/src/kinetis/kinetis_usbdev.c index d8d9512cabf..231fc014303 100644 --- a/arch/arm/src/kinetis/kinetis_usbdev.c +++ b/arch/arm/src/kinetis/kinetis_usbdev.c @@ -2738,7 +2738,7 @@ static int khci_interrupt(int irq, void *context) #ifdef CONFIG_USBOTG /* Session Request Protocol (SRP) Time Out Check */ - /* if USB OTG SRP is ready */ + /* Check if USB OTG SRP is ready */ # warning "Missing logic" { /* Check if the 1 millisecond timer has expired */ @@ -2960,6 +2960,8 @@ x } } + UNUSED(otgir); /* May not be used, depending on above conditional logic */ + /* Clear the pending USB interrupt. Goto is used in the above to assure * that all interrupt exists pass through this logic. */ diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 9b7e6862967..f3530f16a19 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -12,6 +12,7 @@ Contents o LEDs and Buttons o Networking Support o SD Card Support + o USB Device Controller Support o Development Environment o GNU Toolchain Options o Freedom K64F Configuration Options @@ -538,6 +539,73 @@ SD Card Support however, then I cannot think of any reason why removing the card without mounting would be harmful. +USB Device Controller Support +============================== + + USB Device Controller Support + ----------------------------- + The USBHS device controller driver is enabled with he following + configurationsettings: + + Device Drivers -> USB Device Driver Support + CONFIG_USBDEV=y : Enable USB device support + For full-speed/low-power mode: + CONFIG_USBDEV_DUALSPEED=n : Disable High speed support + For high-speed/normal mode: + CONFIG_USBDEV_DUALSPEED=y : Enable High speed support + CONFIG_USBDEV_DMA=y : Enable DMA methods + CONFIG_USBDEV_MAXPOWER=100 : Maximum power consumption + CONFIG_USBDEV_SELFPOWERED=y : Self-powered device + + System Type -> Kinetis Peripheral Selection + CONFIG_KINETIS_USBOTG=y + + CDC/ACM Device Class + -------------------- + In order to be usable, you must all enabled some class driver(s) for the + USBHS device controller. Here, for example, is how to configure the CDC/ACM + serial device class: + + Device Drivers -> USB Device Driver Support + CONFIG_CDCACM=y : USB Modem (CDC ACM) support + CONFIG_CDCACM_EP0MAXPACKET=64 : Enpoint 0 packet size + CONFIG_CDCACM_EPINTIN=1 : Interrupt IN endpoint number + CONFIG_CDCACM_EPINTIN_FSSIZE=64 : Full speed packet size + CONFIG_CDCACM_EPINTIN_HSSIZE=64 : High speed packet size + CONFIG_CDCACM_EPBULKOUT=3 : Bulk OUT endpoint number + CONFIG_CDCACM_EPBULKOUT_FSSIZE=64 : Full speed packet size + CONFIG_CDCACM_EPBULKOUT_HSSIZE=512 : High speed packet size + CONFIG_CDCACM_EPBULKIN=2 : Bulk IN endpoint number + CONFIG_CDCACM_EPBULKIN_FSSIZE=64 : Full speed packet size + CONFIG_CDCACM_EPBULKIN_HSSIZE=512 : High speed packet size + CONFIG_CDCACM_NWRREQS=4 : Number of write requests + CONFIG_CDCACM_NRDREQS=8 : Number of read requests + CONFIG_CDCACM_BULKIN_REQLEN=96 : Size of write request buffer (for full speed) + CONFIG_CDCACM_BULKIN_REQLEN=768 : Size of write request buffer (for high speed) + CONFIG_CDCACM_RXBUFSIZE=257 : Serial read buffer size + CONFIG_CDCACM_TXBUFSIZE=193 : Serial transmit buffer size (for full speed) + CONFIG_CDCACM_TXBUFSIZE=769 : Serial transmit buffer size (for high speed) + CONFIG_CDCACM_VENDORID=0x0525 : Vendor ID + CONFIG_CDCACM_PRODUCTID=0xa4a7 : Product ID + CONFIG_CDCACM_VENDORSTR="NuttX" : Vendor string + CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial" : Product string + + Device Drivers -> Serial Driver Support + CONFIG_SERIAL_REMOVABLE=y : Support for removable serial device + + The CDC/ACM application provides commands to connect and disconnect the + CDC/ACM serial device: + + CONFIG_SYSTEM_CDCACM=y : Enable connect/disconnect support + CONFIG_SYSTEM_CDCACM_DEVMINOR=0 : Use device /dev/ttyACM0 + CONFIG_CDCACM_RXBUFSIZE=??? : A large RX may be needed + + If you include this CDC/ACM application, then you can connect the CDC/ACM + serial device to the host by entering the command 'sercon' and you detach + the serial device with the command 'serdis'. If you do no use this + application, they you will have to write logic in your board initialization + code to initialize and attach the USB device. + Development Environment ======================= @@ -765,16 +833,35 @@ Where is one of the following: NOTES: - 1. Most of the notes associated with the nsh configuration apply here - as well (see below). + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: - 3. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + see additional README.txt files in the NuttX tools repository. + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Default platform/toolchain: + + CONFIG_HOST_WINDOWS=y : Cygwin under Windows + CONFIG_WINDOWS_CYGWIN=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary + + 3. The Serial Console is provided on UART3 with the correct pin + configuration for use with an Arduino Serial Shield. + + 4. SDHC support is not enabled in this configuration. Refer to the + configuration settings listed above under "SD Card Support". + + 5. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU is requests status of the Ethernet link connection. Internal pullup is required when port configuration for MDIO signal is enabled: CONFIG_KINETIS_ENET_MDIOPULLUP=y - 4. Configured to use a fixed IPv4 address: + 6. Configured to use a fixed IPv4 address: CONFIG_NSH_IPADDR=0x0a000002 CONFIG_NSH_DRIPADDR=0x0a000001 @@ -812,26 +899,12 @@ Where is one of the following: 3. The Serial Console is provided on UART3 with the correct pin configuration for use with an Arduino Serial Shield. - 4. An SDHC driver is has not yet been tested but can be enabled in the NSH - configuration by setting the following configuration values as follows: - - CONFIG_KINETIS_SDHC=y : Enable the SDHC driver - - CONFIG_MMCSD=y : Enable MMC/SD support - CONFIG_MMCSD_SDIO=y : Use the SDIO-based MMC/SD driver - CONFIG_MMCSD_NSLOTS=1 : One MMC/SD slot - - CONFIG_FAT=y : Eable FAT file system - CONFIG_FAT_LCNAMES=y : FAT lower case name support - CONFIG_FAT_LFN=y : FAT long file name support - CONFIG_FAT_MAXFNAME=32 : Maximum lenght of a long file name - - CONFIG_GPIO_IRQ=y : Enable GPIO interrupts - CONFIG_KINETIS_PORTEINTS=y : Enable PortE GPIO interrupts - - CONFIG_SCHED_WORKQUEUE=y : Enable the NuttX workqueue - - CONFIG_NSH_ARCHINIT=y : Provide NSH initializeation logic + 4. An SDHC driver is enabled in this configuration but does not yet work. + The basic problem seems to be that it does not sense the presence of + the SD card on PTE6. No interrupts are generated when the SD card is + inserted or removed. You might want to disable SDHC and MMC/SD if + you are using this configuration. Refer to the configuration + settings listed above under "SD Card Support". Status ====== From 9a6c5b271a9fa65fe8387ae5666f4860ae13ec9c Mon Sep 17 00:00:00 2001 From: ziggurat29 Date: Wed, 13 Jul 2016 17:00:06 -0500 Subject: [PATCH 016/152] port foward bugfix from stm32 of oneshot timer --- arch/arm/src/stm32l4/stm32l4_oneshot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot.c b/arch/arm/src/stm32l4/stm32l4_oneshot.c index 6c8027e15cb..073ca62d423 100644 --- a/arch/arm/src/stm32l4/stm32l4_oneshot.c +++ b/arch/arm/src/stm32l4/stm32l4_oneshot.c @@ -96,9 +96,10 @@ static int stm32l4_oneshot_handler(int irq, FAR void *context) * Disable the TC now and disable any further interrupts. */ + STM32L4_TIM_SETISR(oneshot->tch, NULL, 0); + STM32L4_TIM_DISABLEINT(oneshot->tch, 0); STM32L4_TIM_SETMODE(oneshot->tch, STM32L4_TIM_MODE_DISABLED); STM32L4_TIM_ACKINT(oneshot->tch, 0); - STM32L4_TIM_DISABLEINT(oneshot->tch, 0); /* The timer is no longer running */ @@ -353,6 +354,7 @@ int stm32l4_oneshot_cancel(FAR struct stm32l4_oneshot_s *oneshot, /* Now we can disable the interrupt and stop the timer. */ STM32L4_TIM_DISABLEINT(oneshot->tch, 0); + STM32L4_TIM_SETISR(oneshot->tch, NULL, 0); STM32L4_TIM_SETMODE(oneshot->tch, STM32L4_TIM_MODE_DISABLED); oneshot->running = false; From 76f12b1f69a448fd751deb141ec2a4893b30ecc4 Mon Sep 17 00:00:00 2001 From: Pierre-noel Bouteville Date: Thu, 14 Jul 2016 07:28:38 -0600 Subject: [PATCH 017/152] I'm using syslog through ITM. In this case syslog_channel function is call before ram initialisation in stm32_clockconfig. But syslog channel uses a global variable that is reset to default by the RAM initialization. --- arch/arm/src/efm32/efm32_clockconfig.c | 3 --- arch/arm/src/efm32/efm32_start.c | 6 ++++++ arch/arm/src/stm32/stm32_start.c | 6 ++++++ arch/arm/src/stm32/stm32f40xxx_rcc.c | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/efm32/efm32_clockconfig.c b/arch/arm/src/efm32/efm32_clockconfig.c index 5ecdf03c12f..aeef784326b 100644 --- a/arch/arm/src/efm32/efm32_clockconfig.c +++ b/arch/arm/src/efm32/efm32_clockconfig.c @@ -909,9 +909,6 @@ static inline void efm32_itm_syslog(void) efm32_enable_auxhfrco(); - /* Then perform ARMv7-M ITM SYSLOG initialization */ - - itm_syslog_initialize(); } #else # define efm32_itm_syslog() diff --git a/arch/arm/src/efm32/efm32_start.c b/arch/arm/src/efm32/efm32_start.c index f62e1461d51..59c45afaa32 100644 --- a/arch/arm/src/efm32/efm32_start.c +++ b/arch/arm/src/efm32/efm32_start.c @@ -275,6 +275,12 @@ void __start(void) showprogress('C'); +#ifdef CONFIG_ARMV7M_ITMSYSLOG + /* Perform ARMv7-M ITM SYSLOG initialization */ + + itm_syslog_initialize(); +#endif + /* Perform early serial initialization */ up_earlyserialinit(); diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 480d5f58b46..ac16478b337 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -282,6 +282,12 @@ void __start(void) showprogress('C'); +#ifdef CONFIG_ARMV7M_ITMSYSLOG + /* Perform ARMv7-M ITM SYSLOG initialization */ + + itm_syslog_initialize(); +#endif + /* Perform early serial initialization */ #ifdef USE_EARLYSERIALINIT diff --git a/arch/arm/src/stm32/stm32f40xxx_rcc.c b/arch/arm/src/stm32/stm32f40xxx_rcc.c index 3d259ec5c39..347d8a3d62b 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rcc.c @@ -919,7 +919,6 @@ static inline void rcc_itm_syslog(void) modifyreg32(STM32_DBGMCU_CR, DBGMCU_CR_TRACEMODE_MASK, DBGMCU_CR_ASYNCH | DBGMCU_CR_TRACEIOEN); - itm_syslog_initialize(); } #else # define rcc_itm_syslog() From e42e3bd58c306fa43b24944c09bd00b1e7ab4b05 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 10:10:37 -0600 Subject: [PATCH 018/152] Update README --- configs/freedom-k64f/README.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index f3530f16a19..8814e0cb9a7 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -911,9 +911,14 @@ Status 2016-07-11: Received hardware today and the board came up on the very first try. That does not happen often. At this point, the very basic - NSH configuration is working and LEDs are working. The only odd - behavior that I see is that pressing SW3 causes an unexpected interrupt - error. + NSH configuration is working and LEDs are working. + + The only odd behavior that I see is that pressing SW3 causes an NMI + interrupt (followed by a crash): + + kinetis_nmi: PANIC!!! NMI received + + I don't yet understand why this is. 2016-07-12: Added support for the KSZ8081 PHY and added the netnsh configuration. The network is basically functional. More testing is @@ -929,6 +934,10 @@ Status yet work. The basic problem seems to be that it does not sense the presence of the SD card on PTE6. No interrupts are generated when the SD card is inserted or removed. You might want to disable SDHC and - MMC/SD if you are using - this configuration. + MMC/SD if you are using this configuration. + + The nsh configuration now builds successfully with USB device enabled. + USB device, however, has not yet been tested. I have not yet looked + into 48MHz clocking requirements. + \ No newline at end of file From 3f6835fda96f2896b03d41c9db110a071072526a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 10:11:19 -0600 Subject: [PATCH 019/152] If CONFIG_SPIFI_SECTOR512 undefined, lpc43_bwrite doesn't do actual write (probably copy/paste errors). Still not sure about current state of lpc43_spifi implementation, but for me NXFFS works with this patch. From Vytautas Lukenskas. --- arch/arm/src/lpc43xx/lpc43_spifi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/lpc43xx/lpc43_spifi.c b/arch/arm/src/lpc43xx/lpc43_spifi.c index 71920dc4775..4d4d425a2e0 100644 --- a/arch/arm/src/lpc43xx/lpc43_spifi.c +++ b/arch/arm/src/lpc43xx/lpc43_spifi.c @@ -785,6 +785,7 @@ static ssize_t lpc43_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t FAR struct lpc43_dev_s *priv = (FAR struct lpc43_dev_s *)dev; FAR uint8_t *dest; + int ret; finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); @@ -792,19 +793,17 @@ static ssize_t lpc43_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t dest = SPIFI_BASE + (startblock << SPIFI_BLKSHIFT); -#if defined(CONFIG_SPIFI_SECTOR512) /* Write all of the erase blocks to FLASH */ - ret = lpc43_pagewrite(priv, dest, buffer, nblocks << SPIFI_512SHIFT); + ret = lpc43_pagewrite(priv, dest, buffer, nblocks << SPIFI_BLKSHIFT); if (ret < 0) { ferr("ERROR: lpc43_pagewrite failed: %d\n", ret); return ret; } -#endif - lpc43_dumpbuffer(__func__, buffer, nblocks << SPIFI_BLKSHIFT) - return nblocks; + lpc43_dumpbuffer(__func__, buffer, nblocks << SPIFI_BLKSHIFT); + return (int)nblocks; #endif } From 54bc6c88ddbcf6e155163871e722690f17bd06dd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 10:21:31 -0600 Subject: [PATCH 020/152] Fix cast of return value --- arch/arm/src/lpc43xx/lpc43_spifi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/lpc43xx/lpc43_spifi.c b/arch/arm/src/lpc43xx/lpc43_spifi.c index 4d4d425a2e0..57349370c02 100644 --- a/arch/arm/src/lpc43xx/lpc43_spifi.c +++ b/arch/arm/src/lpc43xx/lpc43_spifi.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43/lpc43_spifi.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -779,7 +779,7 @@ static ssize_t lpc43_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t lpc43_cachewrite(priv, buffer, startblock, nblocks); lpc43_dumpbuffer(__func__, buffer, nblocks << SPIFI_512SHIFT) - return nblocks; + return (ssize_t)nblocks; #else @@ -803,7 +803,7 @@ static ssize_t lpc43_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t } lpc43_dumpbuffer(__func__, buffer, nblocks << SPIFI_BLKSHIFT); - return (int)nblocks; + return (ssize_t)nblocks; #endif } From fea2aaba05f67939ae737c0b686b39f676e2b412 Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Thu, 14 Jul 2016 10:31:28 -0600 Subject: [PATCH 021/152] SMART MTD layer: Fixes freesector logic error when sectorsPerBlk=256, adds DEBUGASSERT for invalid geometry and additional memory debug logic. Also fixes the dangling pointer on error bug. --- drivers/mtd/smart.c | 204 +++++++++++++++++++++++--------------------- 1 file changed, 109 insertions(+), 95 deletions(-) diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index e763e6bcba3..bbd7be3cdd0 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -3,7 +3,7 @@ * * Sector Mapped Allocation for Really Tiny (SMART) Flash block driver. * - * Copyright (C) 2013-2015 Ken Pettit. All rights reserved. + * Copyright (C) 2013-2016 Ken Pettit. All rights reserved. * Author: Ken Pettit * * Redistribution and use in source and binary forms, with or without @@ -73,7 +73,7 @@ #define SMART_STATUS_COMMITTED 0x80 #define SMART_STATUS_RELEASED 0x40 #define SMART_STATUS_CRC 0x20 -#define SMART_STATUS_SIZEBITS 0x1C +#define SMART_STATUS_SIZEBITS 0x1c #define SMART_STATUS_VERBITS 0x03 #if defined(CONFIG_SMART_CRC_16) @@ -87,7 +87,7 @@ #define SMART_SECTSIZE_256 0x00 #define SMART_SECTSIZE_512 0x04 #define SMART_SECTSIZE_1024 0x08 -#define SMART_SECTSIZE_2048 0x0C +#define SMART_SECTSIZE_2048 0x0c #define SMART_SECTSIZE_4096 0x10 #define SMART_SECTSIZE_8192 0x14 #define SMART_SECTSIZE_16384 0x18 @@ -134,7 +134,7 @@ #define offsetof(type, member) ( (size_t) &( ( (type *) 0)->member)) #endif -#define SMART_MAX_ALLOCS 6 +#define SMART_MAX_ALLOCS 10 //#define CONFIG_MTD_SMART_PACK_COUNTS #ifndef CONFIG_MTD_SMART_ALLOC_DEBUG @@ -147,7 +147,7 @@ #define SMART_WEAR_MIN_LEVEL 5 #define SMART_WEAR_FORCE_REORG_THRESHOLD 1 #define SMART_WEAR_BIT_DIVIDE 1 -#define SMART_WEAR_ZERO_MASK 0x0F +#define SMART_WEAR_ZERO_MASK 0x0f #define SMART_WEAR_BLOCK_MASK 0x01 /* Bit mapping for wear level bits */ @@ -167,10 +167,10 @@ static const uint8_t gWearLevelToBitMap4[] = { - 0x0F, 0x0E, 0x0C, 0x08, /* Single bit erased (x3) */ + 0x0f, 0x0e, 0x0c, 0x08, /* Single bit erased (x3) */ 0x07, 0x06, 0x04, 0x00, /* Single bit erased (x3) */ - 0x0B, 0x0A, 0x02, /* Single bit erased (x2) */ - 0x0D, 0x09, 0x01, /* Single bit erased (x2) */ + 0x0b, 0x0a, 0x02, /* Single bit erased (x2) */ + 0x0d, 0x09, 0x01, /* Single bit erased (x2) */ 0x03, 0x05 }; @@ -473,6 +473,18 @@ FAR static void *smart_malloc(FAR struct smart_struct_s *dev, FAR void *ret = kmm_malloc(bytes); uint8_t x; + /* Test if we are allocating the dev struct */ + + if (dev == NULL) + { + dev = ret; + dev->bytesalloc = 0; + for (x = 0; x < SMART_MAX_ALLOCS; x++) + { + dev->alloc[x].ptr = NULL; + } + } + /* Keep track of the total allocation */ if (ret != NULL) @@ -545,11 +557,11 @@ static void smart_set_count(FAR struct smart_struct_s *dev, FAR uint8_t *pCount, if (block & 0x01) { - pCount[block >> 1] = (pCount[block >> 1] & 0xF0) | (count & 0x0F); + pCount[block >> 1] = (pCount[block >> 1] & 0xf0) | (count & 0x0f); } else { - pCount[block >> 1] = (pCount[block >> 1] & 0x0F) | ((count & 0x0F) << 4); + pCount[block >> 1] = (pCount[block >> 1] & 0x0f) | ((count & 0x0f) << 4); } /* If we have 16 sectors per block, then the upper bit (representing 16) @@ -595,7 +607,7 @@ static uint8_t smart_get_count(FAR struct smart_struct_s *dev, if (block & 0x01) { - count = pCount[block >> 1] & 0x0F; + count = pCount[block >> 1] & 0x0f; } else { @@ -999,6 +1011,9 @@ static int smart_setsectorsize(FAR struct smart_struct_s *dev, uint16_t size) dev->sectorsize = size; dev->mtdBlksPerSector = dev->sectorsize / dev->geo.blocksize; + DEBUGASSERT(dev->sectorsize >= dev->geo.blocksize); + DEBUGASSERT(erasesize / dev->sectorsize <= 256); + if (erasesize / dev->sectorsize > 256) { /* We can't throw a error message here becasue it is too early. @@ -1051,7 +1066,7 @@ static int smart_setsectorsize(FAR struct smart_struct_s *dev, uint16_t size) } dev->cache_entries = 0; - dev->cache_lastlog = 0xFFFF; + dev->cache_lastlog = 0xffff; dev->cache_nextbirth = 0; #endif @@ -1359,7 +1374,7 @@ static int smart_add_sector_to_cache(FAR struct smart_struct_s *dev, { /* Cache is full. We must find the least accessed entry and replace it */ - oldest = 0xFFFF; + oldest = 0xffff; for (x = 0; x < CONFIG_MTD_SMART_SECTOR_CACHE_SIZE; x++) { /* Never replace cache entries for system sectors */ @@ -1427,7 +1442,7 @@ static uint16_t smart_cache_lookup(FAR struct smart_struct_s *dev, uint16_t logi struct smart_sect_header_s header; size_t readaddress; - physical = 0xFFFF; + physical = 0xffff; /* Test if searching for the last sector used */ @@ -1453,7 +1468,7 @@ static uint16_t smart_cache_lookup(FAR struct smart_struct_s *dev, uint16_t logi * for it and add it to the cache. */ - if (physical == 0xFFFF) + if (physical == 0xffff) { /* Now scan the MTD device. Instead of scanning start to end, we * span the erase blocks and read one sector from each at a time. @@ -1462,7 +1477,7 @@ static uint16_t smart_cache_lookup(FAR struct smart_struct_s *dev, uint16_t logi * numbers in each erase block first. */ - for (sector = 0; sector < dev->sectorsPerBlk && physical == 0xFFFF; sector++) + for (sector = 0; sector < dev->availSectPerBlk && physical == 0xffff; sector++) { /* Now scan across each erase block */ @@ -1566,7 +1581,7 @@ static void smart_update_cache(FAR struct smart_struct_s *dev, uint16_t * the cache. */ - if (physical == 0xFFFF) + if (physical == 0xffff) { dev->sCache[x].logical = dev->sCache[dev->cache_entries-1].logical; dev->sCache[x].physical = dev->sCache[dev->cache_entries-1].physical; @@ -1615,7 +1630,7 @@ static uint8_t smart_get_wear_level(FAR struct smart_struct_s *dev, uint16_t blo { /* Use the lower nibble */ - bits &= 0x0F; + bits &= 0x0f; } /* Lookup and return the level using the BitToLevel map */ @@ -1732,14 +1747,14 @@ static int smart_set_wear_level(FAR struct smart_struct_s *dev, uint16_t block, { /* Use the upper nibble */ - dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] &= 0x0F; + dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] &= 0x0f; dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] |= bits << 4; } else { /* Use the lower nibble */ - dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] &= 0xF0; + dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] &= 0xf0; dev->wearstatus[block >> SMART_WEAR_BIT_DIVIDE] |= bits; } @@ -1817,10 +1832,10 @@ static int smart_scan(FAR struct smart_struct_s *dev) * a header and not sector data. */ - sectorsize = 0xFFFF; + sectorsize = 0xffff; offset = 16384; - while (sectorsize == 0xFFFF) + while (sectorsize == 0xffff) { readaddress = 0; @@ -1845,7 +1860,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) } offset >>= 1; - if (offset < 256 && sectorsize == 0xFFFF) + if (offset < 256 && sectorsize == 0xffff) { /* No valid sectors found on device. Default the * sector size to the CONFIG value @@ -2074,7 +2089,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) /* Test for duplicate logical sectors on the device */ #ifndef CONFIG_MTD_SMART_MINIMIZE_RAM - if (dev->sMap[logicalsector] != 0xFFFF) + if (dev->sMap[logicalsector] != 0xffff) #else if (dev->sBitMap[logicalsector >> 3] & (1 << (logicalsector & 0x07))) #endif @@ -2184,7 +2199,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) /* Now determine who wins */ - if ((seq1 > 0xFFF0 && seq2 < 10) || seq2 > seq1) + if ((seq1 > 0xfff0 && seq2 < 10) || seq2 > seq1) { /* Seq 2 is the winner ... bigger or it wrapped */ @@ -2212,7 +2227,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) goto err_out; } -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header.status &= ~SMART_STATUS_RELEASED; #else header.status |= SMART_STATUS_RELEASED; @@ -2248,7 +2263,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) /* We need to check if we are converting an older format with incorrect * wear leveling data in sector zero to the new format. The old format * put all zeros in the wear level bit locations, but the new (better) - * way is to leave them 0xFF. + * way is to leave them 0xff. */ #ifndef CONFIG_MTD_SMART_MINIMIZE_RAM @@ -2259,7 +2274,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) /* Validate the sector is valid ... may be an unformatted device */ - if (sector != 0xFFFF) + if (sector != 0xffff) { /* Read the sector data */ @@ -2276,11 +2291,11 @@ static int smart_scan(FAR struct smart_struct_s *dev) if (dev->rwbuffer[SMART_WEAR_LEVEL_FORMAT_SIG] == 0) { /* Old format detected. We must relocate sector zero and fill it - * in with 0xFF. + * in with 0xff. */ uint16_t newsector = smart_findfreephyssector(dev, FALSE); - if (newsector == 0xFFFF) + if (newsector == 0xffff) { /* Unable to find a free sector!!! */ @@ -2289,7 +2304,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) goto err_out; } - memset(&dev->rwbuffer[SMART_WEAR_LEVEL_FORMAT_SIG], 0xFF, + memset(&dev->rwbuffer[SMART_WEAR_LEVEL_FORMAT_SIG], 0xff, dev->mtdBlksPerSector * dev->geo.blocksize - SMART_WEAR_LEVEL_FORMAT_SIG); @@ -2677,7 +2692,7 @@ static int smart_relocate_static_data(FAR struct smart_struct_s *dev, uint16_t b /* Get next sector from 'block' */ newsector = nextsector++; - if (newsector == 0xFFFF) + if (newsector == 0xffff) { /* Unable to find a free sector!!! */ @@ -2903,7 +2918,7 @@ static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long a /* Set the sector logical sector to zero and setup the header status */ -#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xFF ) +#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xff ) *((FAR uint16_t *) sectorheader->logicalsector) = 0; sectorheader->status = (uint8_t) ~(SMART_STATUS_COMMITTED | SMART_STATUS_VERBITS | SMART_STATUS_SIZEBITS) | SMART_STATUS_VERSION | @@ -2912,14 +2927,14 @@ static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long a sectorheader->status &= ~SMART_STATUS_CRC; #endif /* CONFIG_MTD_SMART_ENABLE_CRC */ -#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ - *((FAR uint16_t *) sectorheader->logicalsector) = 0xFFFF; +#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */ + *((FAR uint16_t *) sectorheader->logicalsector) = 0xffff; sectorheader->status = (uint8_t) (SMART_STATUS_COMMITTED | SMART_STATUS_VERSION | sectsize); #ifdef CONFIG_MTD_SMART_ENABLE_CRC sectorheader->status |= SMART_STATUS_CRC; #endif /* CONFIG_MTD_SMART_ENABLE_CRC */ -#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ +#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */ /* Now add the format signature to the sector */ @@ -2933,7 +2948,7 @@ static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long a /* Record the number of root directory entries we have */ - dev->rwbuffer[SMART_FMT_ROOTDIRS_POS] = (uint8_t) (arg & 0xFF); + dev->rwbuffer[SMART_FMT_ROOTDIRS_POS] = (uint8_t) (arg & 0xff); #ifdef CONFIG_SMART_CRC_8 sectorheader->crc8 = smart_calc_sector_crc(dev); @@ -3059,7 +3074,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, /* Using 8-bit sequence */ header->seq++; - if (header->seq == 0xFF) + if (header->seq == 0xff) { header->seq = 1; } @@ -3070,7 +3085,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, /* Using 16-bit sequence and no CRC */ (*((FAR uint16_t *) &header->seq))++; - if (*((FAR uint16_t *) &header->seq) == 0xFFFF) + if (*((FAR uint16_t *) &header->seq) == 0xffff) { *((FAR uint16_t *) &header->seq) = 1; } @@ -3086,7 +3101,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, /* First pre-commit the sector */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header->status &= ~(SMART_STATUS_COMMITTED | SMART_STATUS_CRC); #else header->status |= SMART_STATUS_COMMITTED | SMART_STATUS_CRC; @@ -3109,7 +3124,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, #else /* CONFIG_MTD_SMART_ENABLE_CRC */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header->status |= SMART_STATUS_COMMITTED; #else header->status &= ~SMART_STATUS_COMMITTED; @@ -3124,7 +3139,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, offset = newsector * dev->mtdBlksPerSector * dev->geo.blocksize + offsetof(struct smart_sect_header_s, status); -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff newstatus = header->status & ~SMART_STATUS_COMMITTED; #else newstatus = header->status | SMART_STATUS_COMMITTED; @@ -3139,7 +3154,7 @@ static int smart_relocate_sector(FAR struct smart_struct_s *dev, /* Release the old physical sector */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff newstatus = header->status & ~(SMART_STATUS_RELEASED | SMART_STATUS_COMMITTED); #else newstatus = header->status | SMART_STATUS_RELEASED | SMART_STATUS_COMMITTED; @@ -3267,7 +3282,7 @@ static int smart_relocate_block(FAR struct smart_struct_s *dev, uint16_t block) if (allocsector) { newsector = smart_findfreephyssector(dev, FALSE); - if (newsector == 0xFFFF) + if (newsector == 0xffff) { /* Unable to find a free sector!!! */ @@ -3299,7 +3314,7 @@ static int smart_relocate_block(FAR struct smart_struct_s *dev, uint16_t block) /* Find a new sector where it can live, NOT in this erase block */ newsector = smart_findfreephyssector(dev, FALSE); - if (newsector == 0xFFFF) + if (newsector == 0xffff) { /* Unable to find a free sector!!! */ @@ -3441,14 +3456,14 @@ static int smart_findfreephyssector(FAR struct smart_struct_s *dev, retry: #endif allocfreecount = 0; - allocblock = 0xFFFF; + allocblock = 0xffff; #ifdef CONFIG_MTD_SMART_WEAR_LEVEL wornfreecount = 0; - wornblock = 0xFFFF; + wornblock = 0xffff; wornlevel = 15; maxwearlevel = 0; #endif - physicalsector = 0xFFFF; + physicalsector = 0xffff; if (++dev->lastallocblock >= dev->neraseblocks) { dev->lastallocblock = 0; @@ -3514,7 +3529,7 @@ retry: /* Check if we found an allocblock. */ - if (allocblock == 0xFFFF) + if (allocblock == 0xffff) { /* No un-worn blocks with free sectors */ @@ -3558,7 +3573,7 @@ retry: /* Test if we found a worn block with free sectors */ - if (wornblock != 0xFFFF) + if (wornblock != 0xffff) { allocblock = wornblock; } @@ -3624,9 +3639,9 @@ retry: return -1; } - if ((*((FAR uint16_t *) header.logicalsector) == 0xFFFF) && + if ((*((FAR uint16_t *) header.logicalsector) == 0xffff) && #if SMART_STATUS_VERSION == 1 - (*((FAR uint16_t *) &header.seq) == 0xFFFF) && + (*((FAR uint16_t *) &header.seq) == 0xffff) && #else (header.seq == CONFIG_SMARTFS_ERASEDSTATE) && #endif @@ -3639,7 +3654,7 @@ retry: } } - if (physicalsector == 0xFFFF) + if (physicalsector == 0xffff) { ferr("ERROR: Program bug! Expected a free sector\n"); } @@ -3700,7 +3715,7 @@ static int smart_garbagecollect(FAR struct smart_struct_s *dev) { /* Find the block with the most released sectors */ - collectblock = 0xFFFF; + collectblock = 0xffff; releasemax = 0; for (x = 0; x < dev->neraseblocks; x++) { @@ -3731,7 +3746,7 @@ static int smart_garbagecollect(FAR struct smart_struct_s *dev) //releasemax = smart_get_count(dev, dev->releasecount, collectblock); - if (collectblock == 0xFFFF) + if (collectblock == 0xffff) { /* Need to collect, but no sectors with released blocks! */ @@ -3801,7 +3816,7 @@ static int smart_write_wearstatus(struct smart_struct_s *dev) sector = 0; remaining = dev->geo.neraseblocks >> 1; - memset(buffer, 0xFF, sizeof(buffer)); + memset(buffer, 0xff, sizeof(buffer)); #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS) if (dev->blockerases > 0) @@ -3932,8 +3947,8 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev) /* Check for erased state */ -#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xFF ) - if (dev->uneven_wearcount == 0xFFFFFFFF) +#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xff ) + if (dev->uneven_wearcount == 0xffffffff) { dev->uneven_wearcount = 0; } @@ -3943,8 +3958,8 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev) /* Get the block erases count */ dev->blockerases = *((uint32_t *) buffer); -#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xFF ) - if (dev->blockerases == 0xFFFFFFFF) +#if ( CONFIG_SMARTFS_ERASEDSTATE == 0xff ) + if (dev->blockerases == 0xffffffff) { dev->blockerases = 0; } @@ -3979,7 +3994,7 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev) #else physsector = smart_cache_lookup(dev, req.logsector); #endif - if ((sector != 0) && (physsector == 0xFFFF)) + if ((sector != 0) && (physsector == 0xffff)) { #ifdef CONFIG_FS_WRITABLE @@ -4073,7 +4088,7 @@ static int smart_write_alloc_sector(FAR struct smart_struct_s *dev, #endif sectsize = dev->sectorsize >> 7; -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header->status = ~(SMART_STATUS_COMMITTED | SMART_STATUS_SIZEBITS | SMART_STATUS_VERBITS) | SMART_STATUS_VERSION | sectsize; #ifdef CONFIG_MTD_SMART_ENABLE_CRC @@ -4238,7 +4253,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, #else physsector = smart_cache_lookup(dev, req->logsector); #endif - if (physsector == 0xFFFF) + if (physsector == 0xffff) { ferr("ERROR: Logical sector %d not allocated\n", req->logsector); ret = -EINVAL; @@ -4294,7 +4309,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, /* Test if the next byte can be written to the flash */ byte = dev->rwbuffer[sizeof(struct smart_sect_header_s) + req->offset + x]; -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff if (((byte ^ req->buffer[x]) | byte) != byte) { needsrelocate = TRUE; @@ -4322,7 +4337,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, oldphyssector = physsector; physsector = smart_findfreephyssector(dev, FALSE); - if (physsector == 0xFFFF) + if (physsector == 0xffff) { ferr("ERROR: Error relocating sector %d\n", req->logsector); ret = -EIO; @@ -4336,7 +4351,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, { #endif header->seq++; - if (header->seq == 0xFF) + if (header->seq == 0xff) { header->seq = 0; } @@ -4345,13 +4360,13 @@ static int smart_writesector(FAR struct smart_struct_s *dev, else { (*((FAR uint16_t *) &header->seq))++; - if (*((FAR uint16_t *) &header->seq) == 0xFFFF) + if (*((FAR uint16_t *) &header->seq) == 0xffff) *((FAR uint16_t *) &header->seq) = 1; } #else header->seq++; #endif -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header->status |= SMART_STATUS_COMMITTED; #else header->status &= SMART_STATUS_COMMITTED; @@ -4409,7 +4424,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, /* Commit the sector ahead of time. The CRC will protect us */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header->status &= ~(SMART_STATUS_COMMITTED | SMART_STATUS_CRC); #else header->status |= SMART_STATUS_COMMITTED | SMART_STATUS_CRC; @@ -4453,7 +4468,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, #ifndef CONFIG_MTD_SMART_ENABLE_CRC -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff byte = header->status & ~SMART_STATUS_COMMITTED; #else byte = header->status | SMART_STATUS_COMMITTED; @@ -4471,7 +4486,7 @@ static int smart_writesector(FAR struct smart_struct_s *dev, /* Release the old physical sector */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff byte = header->status & ~(SMART_STATUS_RELEASED | SMART_STATUS_COMMITTED); #else byte = header->status | SMART_STATUS_RELEASED | SMART_STATUS_COMMITTED; @@ -4614,7 +4629,7 @@ static int smart_readsector(FAR struct smart_struct_s *dev, #else physsector = smart_cache_lookup(dev, req->logsector); #endif - if (physsector == 0xFFFF) + if (physsector == 0xffff) { ferr("ERROR: Logical sector %d not allocated\n", req->logsector); ret = -EINVAL; @@ -4729,7 +4744,7 @@ errout: static inline int smart_allocsector(FAR struct smart_struct_s *dev, unsigned long requested) { - uint16_t logsector = 0xFFFF; /* Logical sector number selected */ + uint16_t logsector = 0xffff; /* Logical sector number selected */ uint16_t physicalsector; /* The selected physical sector */ #ifndef CONFIG_MTD_SMART_ENABLE_CRC int ret; @@ -4745,7 +4760,7 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev, { /* Do a garbage collect and then test freesectors again */ - if (dev->releasesectors + dev->freesectors > dev->availSectPerBlk + 4) + if (dev->releasesectors + dev->freesectors > dev->sectorsPerBlk + 4) { for (x = 0; x < dev->availSectPerBlk; x++) @@ -4814,7 +4829,7 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev, /* Check if we need to scan for an available logical sector */ - if (logsector == 0xFFFF) + if (logsector == 0xffff) { /* Loop through all sectors and find one to allocate */ @@ -4865,7 +4880,7 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev, /* Test for an error allocating a sector */ - if (logsector == 0xFFFF) + if (logsector == 0xffff) { /* Hmmm. We think we had enough logical sectors, but * something happened and we didn't find any free @@ -4896,6 +4911,11 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev, logsector, physicalsector, physicalsector / dev->sectorsPerBlk, dev->freesectors, dev->releasecount); + if (physicalsector == 0xffff) + { + return -ENOSPC; + } + #ifdef CONFIG_MTD_SMART_ENABLE_CRC /* When CRC is enabled, we don't write the header to the device until @@ -5023,7 +5043,7 @@ static inline int smart_freesector(FAR struct smart_struct_s *dev, /* Mark the sector as released */ -#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF +#if CONFIG_SMARTFS_ERASEDSTATE == 0xff header.status &= ~SMART_STATUS_RELEASED; #else header.status |= SMART_STATUS_RELEASED; @@ -5055,7 +5075,7 @@ static inline int smart_freesector(FAR struct smart_struct_s *dev, dev->sMap[logicalsector] = (uint16_t) -1; #else dev->sBitMap[logicalsector >> 3] &= ~(1 << (logicalsector & 0x07)); - smart_update_cache(dev, logicalsector, 0xFFFF); + smart_update_cache(dev, logicalsector, 0xffff); #endif /* If this block has only released blocks, then erase it */ @@ -5291,19 +5311,13 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, FAR const char *partn /* Allocate a SMART device structure */ - dev = (FAR struct smart_struct_s *)kmm_malloc(sizeof(struct smart_struct_s)); + dev = (FAR struct smart_struct_s *)smart_malloc(NULL, sizeof(struct smart_struct_s), + "Dev struct"); if (dev) { /* Initialize the SMART device structure */ dev->mtd = mtd; -#ifdef CONFIG_MTD_SMART_ALLOC_DEBUG - dev->bytesalloc = 0; - for (totalsectors = 0; totalsectors < SMART_MAX_ALLOCS; totalsectors++) - { - dev->alloc[totalsectors].ptr = NULL; - } -#endif /* Get the device geometry. (casting to uintptr_t first eliminates * complaints on some architectures where the sizeof long is different @@ -5380,6 +5394,15 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, FAR const char *partn dev->minor = minor; #endif + /* Do a scan of the device */ + + ret = smart_scan(dev); + if (ret < 0) + { + ferr("ERROR: smart_scan failed: %d\n", -ret); + goto errout; + } + /* Create a MTD block device name */ #ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS @@ -5431,15 +5454,6 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, FAR const char *partn ferr("ERROR: register_blockdriver failed: %d\n", -ret); goto errout; } - - /* Do a scan of the device */ - - ret = smart_scan(dev); - if (ret < 0) - { - ferr("ERROR: smart_scan failed: %d\n", -ret); - goto errout; - } } #ifdef CONFIG_SMART_DEV_LOOP From a19c099c7579c21d0fdb1ed69ce030b2b394ad47 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 16:07:23 -0600 Subject: [PATCH 022/152] Update ChangeLog --- ChangeLog | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/ChangeLog b/ChangeLog index 06eba68671d..8f3cefa8ffc 100755 --- a/ChangeLog +++ b/ChangeLog @@ -12295,3 +12295,83 @@ Matthias Renner (2016-07-08). * drivers/pipe: Add missing configuration for pipe ring buffer size. From Frank Benkert (2016-07-08). + * STM32L4: Fix incorrect clock setup for LPTIM1. From ziggurat29 + (2016-07-08). + * nucleo-l476rg and stm32lf76vg-disco: Define timer clock frequencies on + STM32L4-based boards. From ziggurat29 (2016-07-08). + * STM32L4: Add support for tickless OS, and incidentally timers, pwm, + oneshot, free-running.... From ziggurat29 (2016-07-08). + * SAM3/4 I2C: Fix reversed logic in twi_startmessage(). From Wolfgang + Reissnegger (2016-07-09). + * VFS ioctl(). Per comments from David Sidrane, file_ioctl() should not + return succeed if the ioctl method is not supported. It probably + should return ENOTTY in that case (2016-07-09). + * libm: This change should significantly improve the performance of + single precision floating point math library functions. The vast + majority of changes have to do with preventing the compiler from + needlessly promoting floats to doubles, performing the calculation + with doubles, only to demote the result to float. These changes only + affect the math lib functions that return float. From David Alessio + (2016-07-11). + * STM32F4 Discovery: Add FPU support for ostest for the STM32F4Discovery + platform. From David Alessio (2016-07-11). + * Build system: Remove the includes/apps link to apps/include. It is + no longer used. From Sebastien Lorquet (2016-07-11). + * printf(): If there are no streams, let printf() fall back to use + syslog() for output (2016-07-11). + * Qemu-i486: Fix qemu-i486/ostest/Make.defs test for M32. From Heath + Petersen (2016-07-12). + * UART 16550: Handle when CONFIG_SERIAL_UART_ARCH_IOCTL is not enabled. + From Heath Petersen (2016-07-12). + * Kinetis Ethernet: Add support for the KSZ8081 PHY (2016-07-12). + * SST26 Driver: Before accessing the sst26 flash, the "Global Unlock" + command must me executed, which I do in the sst26 driver. BUT re- + reading the datasheet, the WREN instruction is required to enable the + execution of this command. This was not done. I have no idea how the + driver currently works except by chance. The writes should never + happen at all, the flash is half-enabled! From Sebastien Lorquet + (2016-07-12). + * Freedom K64F: Add a networking NSH configuration. (2016-07-12). + * N25Qxx Driver: Alter the notion of 'blocksize' to be equivalent to + 'flash write page size' in order to align with assumptions in the + smartfs driver (at least, maybe other things do as well). Correct a + bug that was previously masked by having blocksize=eraseblocksize + which would cause buffer overflows and delicious hardfaults. Trivial + spelling changes in comments, etc. From ziggurat29 (2016-07-12). + * STM32L476 Discovery: Update stm32l476 disco to include init code for + smartfs and nxffs for cases where those fs are included in build. + From ziggurat29 (2016-07-12). + * Kinetis Ethernet and Freedom-K64F: Freedcom-K64F PHY address was + wrong. Modified Ethernet driver to try all PHY addresses and then + only fail if the driver cannot find a usable PHY address. MDIO pin + must have an internal pull-up on the Freedom-K64F (2016-07-12). + * Kinetis Ethernet: Add support for CONFIG_NET_NOINTS (2016-07-12). + * SmartFS: Fix a 32-byte memory leak. From Ken Pettit (2016-07-12). + * Freedom-K64F: SDHC is now enabled in the nsh configuration (but does + not work)Add hooks for automounter; Change NSH configuration to use + Windows (2016-07-13). + * SAMV7 USBHS Device: This change solves a problem which causes data + loss while sending data via USB. This problem is caused by an incorrect + handling of the endpoint state in the USB driver sam_usbdevhs. This + leads under some circumstances to situations in which an DMA transfer + is setup while a previous DMA transfer is currently active. Amongst + other things I introduced the new endpoint state USBHS_EPSTATE_SENDING_DMA + for the fix. To reproduce the problem, I used a program which send as + many data as possible via a CDC/ACM device and verified the received + data on the PC. From Stefan Kolb (2016-07-13). + * STM32: Fix bug in oneshot timer. From Max Neklyudov (2016-07-13). + * STM32L4: Port foward bugfix from stm32 of oneshot timer. From + ziggurat29 (2016-07-13). + * STM32 and EFM32: I'm using syslog through ITM. In this case + syslog_channel function is call before RAM initialisation in + stm32_clockconfig. But syslog channel uses a global variable that is + reset to default by the RAM initialization. From Pierre-noel + Bouteville (2016-07-14). + * LPC43xx SPIFI: If CONFIG_SPIFI_SECTOR512 undefined, lpc43_bwrite + doesn't do actual write (probably copy/paste errors). Still not sure + about current state of lpc43_spifi implementation, but for me NXFFS + works with this patch. From Vytautas Lukenskas (2016-07-14). + * SMART MTD layer: Fixes freesector logic error when sectorsPerBlk=256, + adds DEBUGASSERT for invalid geometry and additional memory debug + logic. Also fixes the dangling pointer on error bug. From Ken + Pettit (2016-07-14). From f982180ec7119d7ec00d32c813b329cdc403794e Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Thu, 14 Jul 2016 18:17:05 -0600 Subject: [PATCH 023/152] SAM3/4 Timer: Remove broken definitions for BMR register. Per documentation SAM4S and SAM4E have the BMR register values as they are already defined. No need for chip specific values. In addition: - CONFIG_ARCH_CHIP_SAM4s has wrong lower case 's' so the definitions would not be used anyways for SAM4S builds. - TC_BMR_TC2XC2S_TIOA2 does not make sense. There is no way to loop back TC2's TIOA2 into itself. --- arch/arm/src/sam34/chip/sam_tc.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/sam34/chip/sam_tc.h b/arch/arm/src/sam34/chip/sam_tc.h index bb1bd15f0c1..68a4bac43da 100644 --- a/arch/arm/src/sam34/chip/sam_tc.h +++ b/arch/arm/src/sam34/chip/sam_tc.h @@ -537,16 +537,10 @@ # define TC_BMR_TC1XC1S_TIOA2 (3 << TC_BMR_TC1XC1S_SHIFT) #define TC_BMR_TC2XC2S_SHIFT (4) /* Bits 4-5: External Clock Signal 2 Selection */ #define TC_BMR_TC2XC2S_MASK (3 << TC_BMR_TC2XC2S_SHIFT) -#if defined(CONFIG_ARCH_CHIP_SAM4s) || defined(CONFIG_ARCH_CHIP_SAM4E) -# define TC_BMR_TC2XC2S_TCLK2 (0 << TC_BMR_TC2XC2S_SHIFT) -# define TC_BMR_TC2XC2S_TIOA1 (2 << TC_BMR_TC2XC2S_SHIFT) -# define TC_BMR_TC2XC2S_TIOA2 (3 << TC_BMR_TC2XC2S_SHIFT) -#else -# define TC_BMR_TC2XC2S_TCLK2 (0 << TC_BMR_TC2XC2S_SHIFT) -# define TC_BMR_TC2XC2S_NONE (1 << TC_BMR_TC2XC2S_SHIFT) -# define TC_BMR_TC2XC2S_TIOA0 (2 << TC_BMR_TC2XC2S_SHIFT) -# define TC_BMR_TC2XC2S_TIOA1 (3 << TC_BMR_TC2XC2S_SHIFT) -#endif +#define TC_BMR_TC2XC2S_TCLK2 (0 << TC_BMR_TC2XC2S_SHIFT) +#define TC_BMR_TC2XC2S_NONE (1 << TC_BMR_TC2XC2S_SHIFT) +#define TC_BMR_TC2XC2S_TIOA0 (2 << TC_BMR_TC2XC2S_SHIFT) +#define TC_BMR_TC2XC2S_TIOA1 (3 << TC_BMR_TC2XC2S_SHIFT) #define TC_BMR_QDEN (1 << 8) /* Bit 8: Quadrature Decoder Enabled */ #define TC_BMR_POSEN (1 << 9) /* Bit 9: Position Enabled */ #define TC_BMR_SPEEDEN (1 << 10) /* Bit 10: Speed Enabled */ From 18059d682122776ecbb7db174439d088e199875a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 18:39:51 -0600 Subject: [PATCH 024/152] Restore Wolfgang Reissnegger's PR as submitted. My mistake is it late here. --- arch/arm/src/sam34/chip/sam_tc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/sam34/chip/sam_tc.h b/arch/arm/src/sam34/chip/sam_tc.h index 68a4bac43da..e5951fcdc9a 100644 --- a/arch/arm/src/sam34/chip/sam_tc.h +++ b/arch/arm/src/sam34/chip/sam_tc.h @@ -2,7 +2,7 @@ * arch/arm/src/sam34/chip/sam_tc.h * Timer Counter (TC) definitions for the SAM3U, SAM4E, and SAM4S * - * Copyright (C) 2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2013-2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -537,10 +537,10 @@ # define TC_BMR_TC1XC1S_TIOA2 (3 << TC_BMR_TC1XC1S_SHIFT) #define TC_BMR_TC2XC2S_SHIFT (4) /* Bits 4-5: External Clock Signal 2 Selection */ #define TC_BMR_TC2XC2S_MASK (3 << TC_BMR_TC2XC2S_SHIFT) -#define TC_BMR_TC2XC2S_TCLK2 (0 << TC_BMR_TC2XC2S_SHIFT) -#define TC_BMR_TC2XC2S_NONE (1 << TC_BMR_TC2XC2S_SHIFT) -#define TC_BMR_TC2XC2S_TIOA0 (2 << TC_BMR_TC2XC2S_SHIFT) -#define TC_BMR_TC2XC2S_TIOA1 (3 << TC_BMR_TC2XC2S_SHIFT) +# define TC_BMR_TC2XC2S_TCLK2 (0 << TC_BMR_TC2XC2S_SHIFT) +# define TC_BMR_TC2XC2S_NONE (1 << TC_BMR_TC2XC2S_SHIFT) +# define TC_BMR_TC2XC2S_TIOA0 (2 << TC_BMR_TC2XC2S_SHIFT) +# define TC_BMR_TC2XC2S_TIOA1 (3 << TC_BMR_TC2XC2S_SHIFT) #define TC_BMR_QDEN (1 << 8) /* Bit 8: Quadrature Decoder Enabled */ #define TC_BMR_POSEN (1 << 9) /* Bit 9: Position Enabled */ #define TC_BMR_SPEEDEN (1 << 10) /* Bit 10: Speed Enabled */ From 912ad2d3455228f3430bdf095536934ef42d1752 Mon Sep 17 00:00:00 2001 From: David Alessio Date: Thu, 14 Jul 2016 20:15:37 -0600 Subject: [PATCH 025/152] Fix bug in logf() algorithm that caused erroneous INFINITY results. --- libc/math/lib_erf.c | 3 ++- libc/math/lib_logf.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libc/math/lib_erf.c b/libc/math/lib_erf.c index 1923638dbad..215c1017204 100644 --- a/libc/math/lib_erf.c +++ b/libc/math/lib_erf.c @@ -67,6 +67,7 @@ double erf(double x) sign = (x >= 0 ? 1 : -1); t = 1.0/(1.0 + p*x); - return sign * (1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * expf(-x * x)); + return sign * (1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * + (double)expf(-x * x)); } #endif diff --git a/libc/math/lib_logf.c b/libc/math/lib_logf.c index 2d097d228e3..9abc5eff986 100644 --- a/libc/math/lib_logf.c +++ b/libc/math/lib_logf.c @@ -32,6 +32,8 @@ #include #include +#define FLT_MAX_EXP_X 88.0F + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -50,25 +52,25 @@ float logf(float x) ey = exp(y); y -= (ey - x) / ey; - if (y > 700.0F) + if (y > FLT_MAX_EXP_X) { - y = 700.0F; + y = FLT_MAX_EXP_X; } - if (y < -700.0F) + if (y < -FLT_MAX_EXP_X) { - y = -700.0F; + y = -FLT_MAX_EXP_X; } epsilon = (fabsf(y) > 1.0F) ? fabsf(y) * FLT_EPSILON : FLT_EPSILON; } - if (y == 700.0F) + if (y == FLT_MAX_EXP_X) { return INFINITY; } - if (y == -700.0F) + if (y == -FLT_MAX_EXP_X) { return INFINITY; } From ccf4bfafcb9878d122b1792d28ceb576eb28d90c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Jul 2016 20:20:48 -0600 Subject: [PATCH 026/152] Prototype versions of ptmx/pty suppoprt. Still under developement; not yet hooked into build or configuration system. --- drivers/serial/ptmx.c | 330 +++++++++++++++++++++++++ drivers/serial/pty.c | 559 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 889 insertions(+) create mode 100644 drivers/serial/ptmx.c create mode 100644 drivers/serial/pty.c diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c new file mode 100644 index 00000000000..d0439c14f31 --- /dev/null +++ b/drivers/serial/ptmx.c @@ -0,0 +1,330 @@ +/**************************************************************************** + * drivers/serial/ptmx.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifndef CONFIG_PTY_MAXPTY +# define CONFIG_PTY_MAXPTY 32 +#endif + +#if CONFIG_PTY_MAXPTY > 256 +# define CONFIG_PTY_MAXPTY 256 +#endif + +#define PTY_MAX ((CONFIG_PTY_MAXPTY + 31) & ~31) +#define INDEX_MAX (PTY_MAX >> 5) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* PTMX device state */ + +struct ptmx_dev_s +{ + uint8_t px_next; /* Next minor number to allocate */ + sem_t px_exclsem; /* Supports mutual exclusion */ + uint32_t px_alloctab[INDEX_MAX]; /* Set of allocated PTYs */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int ptmx_open(FAR struct file *filep); +static ssize_t ptmx_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t ptmx_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations g_ptmx_fops = +{ + ptmx_open, /* open */ + NULL, /* close */ + ptmx_read, /* read */ + ptmx_write, /* write */ + NULL, /* seek */ + NULL /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , NULL /* poll */ +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL /* unlink */ +#endif +}; + +static struct ptmx_dev_s g_ptmx; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ptmx_semtake and ptmx_semgive + * + * Description: + * This is just a wrapper to handle the annoying behavior of semaphore + * waits that return due to the receipt of a signal. + * + ****************************************************************************/ + +static void ptmx_semtake(void) +{ + /* Take the semaphore (perhaps waiting) */ + + while (sem_wait(&g_ptmx.px_exclsem) != 0) + { + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(errno == EINTR); + } +} + +#define ptmx_semgive() sem_post(&g_ptmx.px_exclsem) + +/**************************************************************************** + * Name: ptmx_minor_allocate + * + * Description: + * Allocate a new unique PTY minor number. + * + * Assumptions: + * Caller hold the px_exclsem + * + ****************************************************************************/ + +static int ptmx_minor_allocate(FAR struct ptmx_dev_s *ptmx) +{ + uint8_t startaddr = g_ptmx.px_next; + uint8_t minor; + int index; + int bitno; + + /* Loop until we find a valid device address */ + + for (; ; ) + { + /* Try the next device address */ + + minor = g_ptmx.px_next; + if (g_ptmx.px_next >= PTY_MAX) + { + g_ptmx.px_next = 0; + } + else + { + g_ptmx.px_next++; + } + + /* Is this address already allocated? */ + + index = minor >> 5; + bitno = minor & 31; + if ((g_ptmx.px_alloctab[index] & (1 << bitno)) == 0) + { + /* No... allocate it now */ + + g_ptmx.px_alloctab[index] |= (1 << bitno); + return (int)minor; + } + + /* This address has already been allocated. The following logic will + * prevent (unexpected) infinite loops. + */ + + if (startaddr == minor) + { + /* We are back where we started... the are no free device address */ + + return -ENOMEM; + } + } +} + +/**************************************************************************** + * Name: ptmx_minor_free + * + * Description: + * De-allocate a PTY minor number. + * + * Assumptions: + * Caller hold the px_exclsem + * + ****************************************************************************/ + +static void ptmx_minor_free(uint8_t minor) +{ + int index; + int bitno; + + /* Free the address by clearing the associated bit in the px_alloctab[]; */ + + index = minor >> 5; + bitno = minor & 31; + + DEBUGASSERT((g_ptmx.px_alloctab[index] |= (1 << bitno)) != 0); + g_ptmx.px_alloctab[index] &= ~(1 << bitno); + + /* Reset the next pointer if the one just released has a lower value */ + + if (minor < g_ptmx.px_next) + { + g_ptmx.px_next = minor; + } +} + +/**************************************************************************** + * Name: ptmx_open + ****************************************************************************/ + +static int ptmx_open(FAR struct file *filep) +{ + char devname[16]; + int minor; + int fd; + int ret; + + /* Get exclusive access */ + + ptmx_semtake(); + + /* Allocate a PTY minor */ + + minor = ptmx_minor_allocate(); + if (minor < 0) + { + ret = minor; + goto errout_with_sem; + } + + /* Create the master slave pair */ + + ret = pty_register(minor); + if (ret < 0) + { + goto errout_with_minor; + } + + /* Open the master side */ + + snprintf(devname, 16, "/dev/ttyp%d", minor); + fd = open(devname, O_RDWR); + DEBUGASSERT(fd >= 0); /* open() should never fail */ + + /* No unlink the master. This will remove it from the VFS namespace, + * the the driver will still persist because of the open count on the + * driver. + */ + + ret = unlink(devname); + DEBUGASSERT(ret >= 0); /* unlink() should never fail */ + UNUSED(ret); + + /* Return the master file descriptor */ + + ptmx_semgive(); + return fd; + +errout_with_minor: + ptmx_minor_free(minor); + +errout_with_sem: + ptmx_semgive(); + return ret; +} + +/**************************************************************************** + * Name: ptmx_read + ****************************************************************************/ + +static ssize_t ptmx_read(FAR struct file *filep, FAR char *buffer, size_t len) +{ + return 0; /* Return EOF */ +} + +/**************************************************************************** + * Name: ptmx_write + ****************************************************************************/ + +static ssize_t ptmx_write(FAR struct file *filep, FAR const char *buffer, size_t len) +{ + return len; /* Say that everything was written */ +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ptmx_register + * + * Description: + * Register /dev/null + * + ****************************************************************************/ + +void ptmx_register(void) +{ + FAR struct ptmx_dev_s *ptmx; + + /* Initialize driver state */ + + sem_init(&g_ptmx.px_exclsem, 0, 1); + + /* Register the PTMX driver */ + + (void)register_driver("/dev/ptmx", &g_ptmx_fops, 0666, NULL); +} diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c new file mode 100644 index 00000000000..2719d6c35df --- /dev/null +++ b/drivers/serial/pty.c @@ -0,0 +1,559 @@ +/**************************************************************************** + * drivers/serial/pty.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int pty_open(FAR struct file *filep); +static int pty_close(FAR struct file *filep); +static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t pty_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +#ifndef CONFIG_DISABLE_POLL +static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup); +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int pty_unlink(FAR struct inode *inode); +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This device structure describes on memory of the PTY device pair */ + +struct pty_devpair_s; +struct pty_dev_s +{ + FAR struct pty_common_s *pd_devpair; + struct file pd_src; /* Provides data to read() method (pipe output) */ + struct file pd_sink; /* Accepts data from write() method (pipe input) */ +}; + +/* This structure describes the pipe pair */ + +struct pty_devpair_s +{ + struct pty_dev_s pp_ptyp; /* /dev/ptypN device */ + struct pty_dev_s pp_ttyp; /* /dev/ttypN device */ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + uint8_t pp_minor; /* Minor device number */ + uint16_t pp_nopen; /* Open file count */ + sem_t pp_exclsem; /* Mutual exclusion */ + bool pp_unlinked; /* File has been unlinked */ +#endif +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations pty_fops = +{ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + pty_open, /* open */ + pty_close, /* close */ +#else + NULL, /* open */ + NULL, /* close */ +#endif + pty_read, /* read */ + pty_write, /* write */ + NULL, /* seek */ + pty_ioctl /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , pty_poll /* poll */ +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , pty_unlink /* unlink */ +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pty_semtake + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static void pty_semtake(FAR struct pty_common_s *devpair) +{ + while (sem_wait(&devpair->pp_exclsem) < 0) + { + DEBUGASSERT(errno == EINTR); + } +} +#endif + +/**************************************************************************** + * Name: pty_semgive + ****************************************************************************/ + +#define pty_semgive(c) sem_post(&(c)->pp_exclsem) + +/**************************************************************************** + * Name: pty_destroy + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static void pty_destroy(FAR struct pty_common_s *devpair) +{ + char devname[16]; + + /* Un-register /dev/ptypN */ + + snprintf(devname, 16, "/dev/pp_ptyp%d", (int)devpair->pp_minor); + (void)unregister_driver(devname); + + /* Un-register /dev/ptypN */ + + snprintf(devname, 16, "/dev/ttyp%d", (int)devpair->pp_minor); + (void)unregister_driver(devname); + + /* Close the contained file structures */ + + (void)file_close_detached(&devpair->pp_ptyp.pd_src); + (void)file_close_detached(&devpair->pp_ptyp.pd_sink); + (void)file_close_detached(&devpair->pp_ttyp.pd_src); + (void)file_close_detached(&devpair->pp_ttyp.pd_sink); + + /* And free the device structure */ + + sem_destroy(&devpair->pp_exclsem); + kmm_free(upper); +} +#endif + +/**************************************************************************** + * Name: pty_open + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int pty_open(FAR struct file *filep) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + FAR struct pty_common_s *devpair; + int ret; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); + devpair = dev->pd_devpair; + + /* Get exclusive access */ + + pty_semtake(devpair); + + /* If one side of the driver has been unlinked, then refuse further + * opens. + */ + + if (cmd->pp_unlinked) + { + ret = -EIDRAM + } + else + { + /* Increment the count of open references on the driver */ + + devpair->pp_nopen++; + DEBUGASSERT(devpair->pp_nopen > 0); + + ret = OK; + } + + pty_semgive(devpair); + return ret; +} +#endif + +/**************************************************************************** + * Name: pty_open + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int pty_close(FAR struct file *filep) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + FAR struct pty_common_s *devpair; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); + devpair = dev->pd_devpair; + + /* Get exclusive access */ + + pty_semtake(devpair); + + /* Is this the last open reference? */ + + DEBUGASSERT(devpair->pp_nopen > 0); + if (devpair->pp_nopen <= 1 && devpair->pp_unlinked) + { + /* Free the device pair now (without freeing the semaphore) */ + + pty_destroy(devpair); + return OK; + } + else + { + /* Otherwise just decrement the open count */ + + devpair->pp_nopen--; + } + + pty_semgive(devpair); + return OK; +} +#endif + +/**************************************************************************** + * Name: pty_read + ****************************************************************************/ + +static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL); + + return file_read(&dev->src, buffer, len); +} + +/**************************************************************************** + * Name: pty_write + ****************************************************************************/ + +static ssize_t pty_write(FAR struct file *filep, FAR const char *buffer, size_t len) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL); + + return file_write(&dev->src, buffer, len); +} + +/**************************************************************************** + * Name: pty_ioctl + * + * Description: + * The standard ioctl method. This is where ALL of the PWM work is done. + * + ****************************************************************************/ + +static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + int ret; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL); + + /* Handle IOCTL commands */ + + switch (cmd) + { + /* PTY IOCTL commands would be handled here */ + /* There aren't any yet */ + + /* Any unrecognized IOCTL commands will be passed to the contained + * pipe driver. + */ + + default: + { + ret = file_ioctl(dev->pd_src, cmd, arg); + if (ret >= 0 || ret == -ENOTTY) + { + ret = file_ioctl(dev->pd_sink, cmd, arg); + } + } + break; + } + + sem_post(&upper->exclsem); + return ret; +} + +/**************************************************************************** + * Name: pty_poll + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_POLL +static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup) +{ +#warning Missing logic +} +#endif + +/**************************************************************************** + * Name: pty_unlink + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int pty_unlink(FAR struct inode *inode) +{ + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + FAR struct pty_common_s *devpair; + + DEBUGASSERT(filep != NULL && file->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); + devpair = dev->pd_devpair; + + /* Get exclusive access */ + + pty_semtake(devpair); + + /* Indicate that the driver has been unlinked */ + + devpair->pp_unlinked = true; + + /* If there are no further open references to the driver, then commit + * Hara-Kiri now. + */ + + if (devpair->pp_nopen == 0) + { + pty_destroy(devpair); + return OK; + } + + pty_semgive(devpair); + return OK; +} +#endif +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pty_register + * + * Input Parameters: + * + * Description: + * Register /dev/ttypN and /dev/ptpN where N=minor number + * + ****************************************************************************/ + +int pty_register(int minor) +{ + FAR struct pty_devpair_s *devpair; + int pipe_a[2]; + int pipe_b[2]; + char devname[16]; + + /* Allocate a device instance */ + + devpair = kmm_zalloc(sizeof(struct pty_devpair_s)); + if (devpair == NULL) + { + return -ENOMEM; + } + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + sem_init(&devpair->pp_exclsem, 0, 1); + devpair->pp_minor = minor; +#endif + devpair->pp_ptyp.pd_devpair = devpair; + devpair->pp_ttyp.pd_devpair = devpair; + + /* Create two pipes */ + + ret = pipe(pipe_a); + if (ret < 0) + { + goto errout_with_devpair; + } + + ret = pipe(pipe_b); + if (ret < 0) + { + goto errout_with_pipea; + } + + /* Detach the pipe file descriptors (closing them in the process) + * + * fd[0] is for reading; + * fd[1] is for writing. + */ + + ret = file_detach(pipe_a[0], &devpair->pp_ptyp.pd_src); + if (ret < 0) + { + goto errout_with_pipeb; + } + + pipe_a[0] = -1; + + ret = file_detach(pipe_a[1], &devpair->pp_ttyp.pd_sink); + if (ret < 0) + { + goto errout_with_pipeb; + } + + pipe_a[1] = -1; + + ret = file_detach(pipe_b[0], &devpair->pp_ttyp.pd_src); + if (ret < 0) + { + goto errout_with_pipeb; + } + + pipe_b[0] = -1; + + ret = file_detach(pipe_b[1], &devpair->pp_ptyp.pd_sink); + if (ret < 0) + { + goto errout_with_pipeb; + } + + pipe_b[1] = -1; + + /* Register /dev/ptypN */ + + snprintf(devname, 16, "/dev/pts/%d", minor); + + ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_ptyp); + if (ret < 0) + { + goto errout_with_pipeb; + } + + /* Register /dev/ptypN */ + + snprintf(devname, 16, "/dev/ttyp%d", minor); + + ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_ttyp); + if (ret < 0) + { + goto errout_with_ptyp; + } + + return OK; + +errout_with_ptyp: + snprintf(devname, 16, "/dev/ptyp%d", minor); + (void)unregister_driver(devname) + +errout_with_pipeb: + if (pipe_b[0] >= 0) + { + close(pipe_b[0]); + } + else + { + (void)file_close_detached(&devpair->pp_ptyp.pd_src); + } + + if (pipe_b[1] >= 0) + { + close(pipe_b[1]); + } + else + { + (void)file_close_detached(&devpair->pp_ttyp.pd_sink); + } + +errout_with_pipea: + if (pipe_a[0] >= 0) + { + close(pipe_a[0]); + } + else + { + (void)file_close_detached(&devpair->pp_ttyp.pd_src); + } + + if (pipe_a[1] >= 0) + { + close(pipe_a[1]); + } + else + { + (void)file_close_detached(&devpair->pp_ptyp.pd_sink); + } + +errout_with_devpair: +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + sem_destroy(&devpair->pp_exclsem); +#endif + kmm_free(devpair); + return ret; +} From 7005fafb95fb9ecdeb1f44a915b08dac279ee656 Mon Sep 17 00:00:00 2001 From: Young Date: Fri, 15 Jul 2016 11:03:48 +0800 Subject: [PATCH 027/152] Fix a bug of tiva i2c ports configuration --- arch/arm/src/tiva/chip/tm4c_pinmap.h | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/arch/arm/src/tiva/chip/tm4c_pinmap.h b/arch/arm/src/tiva/chip/tm4c_pinmap.h index ec9bceca5de..5d32959f062 100644 --- a/arch/arm/src/tiva/chip/tm4c_pinmap.h +++ b/arch/arm/src/tiva/chip/tm4c_pinmap.h @@ -1186,34 +1186,34 @@ # define GPIO_HIB_RTCCLK_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_5 | GPIO_PORTK | GPIO_PIN_7) # define GPIO_HIB_RTCCLK_3 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_7 | GPIO_PORTP | GPIO_PIN_3) -# define GPIO_I2C0_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_2 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C0_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_2) # define GPIO_I2C0_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_3 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C1_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTG | GPIO_PIN_0 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C1_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTG | GPIO_PIN_0) # define GPIO_I2C1_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTG | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C2_SCL_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTL | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C2_SCL_2 (GPIO_FUNC_PFODIO | GPIO_ALT_3 | GPIO_PORTN | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C2_SCL_3 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTP | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C2_SCL_1 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTL | GPIO_PIN_1) +# define GPIO_I2C2_SCL_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTP | GPIO_PIN_5) +# define GPIO_I2C2_SCL_3 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_3 | GPIO_PORTN | GPIO_PIN_5) # define GPIO_I2C2_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTL | GPIO_PIN_0 | GPIO_PADTYPE_ODWPU) # define GPIO_I2C2_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_3 | GPIO_PORTN | GPIO_PIN_4 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C3_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_4 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C3_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_4) # define GPIO_I2C3_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C4_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_6 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C4_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_6) # define GPIO_I2C4_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTK | GPIO_PIN_7 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C5_SCL_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_0 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C5_SCL_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_4 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C5_SCL_1 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_0) +# define GPIO_I2C5_SCL_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_4) # define GPIO_I2C5_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) # define GPIO_I2C5_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTB | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C6_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_6 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C6_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_6) # define GPIO_I2C6_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_7 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C7_SCL_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_4 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C7_SCL_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_0 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C7_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C7_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C8_SCL_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_2 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C8_SCL_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_2 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C8_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_3 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C8_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_3 | GPIO_PADTYPE_ODWPU) -# define GPIO_I2C9_SCL (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_0 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C7_SCL_1 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_0) +# define GPIO_I2C7_SCL_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_4) +# define GPIO_I2C7_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C7_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_5 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C8_SCL_1 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_2) +# define GPIO_I2C8_SCL_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_2) +# define GPIO_I2C8_SDA_1 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTD | GPIO_PIN_3 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C8_SDA_2 (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_3 | GPIO_PADTYPE_ODWPU) +# define GPIO_I2C9_SCL (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_0) # define GPIO_I2C9_SDA (GPIO_FUNC_PFODIO | GPIO_ALT_2 | GPIO_PORTA | GPIO_PIN_1 | GPIO_PADTYPE_ODWPU) # define GPIO_JTAG_SWCLK (GPIO_FUNC_PFINPUT | GPIO_ALT_1 | GPIO_PORTC | GPIO_PIN_0) From fd51393a378c008546df029ad2e9943b3e7cb95b Mon Sep 17 00:00:00 2001 From: Vladimir Komendantskiy Date: Fri, 15 Jul 2016 06:26:04 -0600 Subject: [PATCH 028/152] Correct typos in SAMV71-XULT and SAME70-Xplained header files. --- configs/same70-xplained/src/same70-xplained.h | 4 ++-- configs/samv71-xult/src/samv71-xult.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configs/same70-xplained/src/same70-xplained.h b/configs/same70-xplained/src/same70-xplained.h index 838e0668c11..7fe8493b4ab 100644 --- a/configs/same70-xplained/src/same70-xplained.h +++ b/configs/same70-xplained/src/same70-xplained.h @@ -91,11 +91,11 @@ # define CONFIG_NSH_MMCSDMINOR 0 #endif -#ifndef CONFIG_NSH_MMCSDMINOR +#ifndef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 #endif -#if CONFIG_NSH_MMCSDMINOR != 0 +#if CONFIG_NSH_MMCSDSLOTNO != 0 # error SAME70 has only one MMC/SD slot (CONFIG_NSH_MMCSDMINOR) # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 3ce8ed26731..21884b7191f 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -100,12 +100,12 @@ # define CONFIG_NSH_MMCSDMINOR 0 #endif -#ifndef CONFIG_NSH_MMCSDMINOR +#ifndef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 #endif -#if CONFIG_NSH_MMCSDMINOR != 0 -# error SAMV71 has only one MMC/SD slot (CONFIG_NSH_MMCSDMINOR) +#if CONFIG_NSH_MMCSDSLOTNO != 0 +# error SAMV71 has only one MMC/SD slot (CONFIG_NSH_MMCSDSLOTNO) # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 #endif From c9d7ae6f47307e52e78e12878287c38698e28392 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 06:29:46 -0600 Subject: [PATCH 029/152] Oops part of last commit was still in the editor. --- configs/same70-xplained/src/same70-xplained.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/same70-xplained/src/same70-xplained.h b/configs/same70-xplained/src/same70-xplained.h index 7fe8493b4ab..0859c0f450b 100644 --- a/configs/same70-xplained/src/same70-xplained.h +++ b/configs/same70-xplained/src/same70-xplained.h @@ -96,7 +96,7 @@ #endif #if CONFIG_NSH_MMCSDSLOTNO != 0 -# error SAME70 has only one MMC/SD slot (CONFIG_NSH_MMCSDMINOR) +# error SAME70 has only one MMC/SD slot (CONFIG_NSH_MMCSDSLOTNO) # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 #endif From 7fa5093fff95f67adafd6b4c026fa4d020ea50dd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 06:48:10 -0600 Subject: [PATCH 030/152] PTYs prototypes hooked into build and configuration system (as EXPERIMENTAL) --- drivers/serial/Kconfig | 36 +++++++++++ drivers/serial/Make.defs | 9 +++ drivers/serial/ptmx.c | 9 ++- drivers/serial/pty.c | 136 +++++++++++++++++++++++---------------- 4 files changed, 131 insertions(+), 59 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 5297a824f80..490d39601fe 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2011,3 +2011,39 @@ config SCI1_2STOP 1=Two stop bits endmenu # SCI1 Configuration + +config PSEUDOTERM + bool "Pseudo-Terminal (PTY) suppport" + default n + depends on EXPERIMENTAL + ---help--- + Enable support support for master and slave pseudo-terminal devices. + +choice + prompt "PTY model" + default PSEUDOTERM_BSD if DISABLE_PSEUDOFS_OPERATIONS + default PSEUDOTERM_SUSV1 if !DISABLE_PSEUDOFS_OPERATIONS + depends on PSEUDOTERM + +config PSEUDOTERM_BSD + bool "BSD style" + ---help--- + Deprecated BSD style PTYs. + + Master: /dev/ptyN + Slave: /dev/ttypN + + Where N is the minor number + +config PSEUDOTERM_SUSV1 + bool "SUSv1 style" + depends on !DISABLE_PSEUDOFS_OPERATIONS + ---help--- + PTYs as specified in the Single Unix Specification (SUSv1). + + Master: /dev/ptmx + Slave: /dev/pts/N + + Where N is the minor number + +endchoice # PTY model diff --git a/drivers/serial/Make.defs b/drivers/serial/Make.defs index bcbffd8368e..e7cc43426d2 100644 --- a/drivers/serial/Make.defs +++ b/drivers/serial/Make.defs @@ -47,6 +47,15 @@ ifeq ($(CONFIG_16550_UART),y) CSRCS += uart_16550.c endif +# Pseudo-terminal support + +ifeq ($(CONFIG_PSEUDOTERM),y) + CSRCS += pty.c +ifeq ($(CONFIG_PSEUDOTERM_SUSV1),y) + CSRCS += ptmx.c +endif +endif + # Include serial build support DEPPATH += --dep-path serial diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index d0439c14f31..d718702895c 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -41,9 +41,14 @@ #include #include +#include +#include +#include #include #include +#include #include + #include /**************************************************************************** @@ -146,7 +151,7 @@ static void ptmx_semtake(void) * ****************************************************************************/ -static int ptmx_minor_allocate(FAR struct ptmx_dev_s *ptmx) +static int ptmx_minor_allocate(void) { uint8_t startaddr = g_ptmx.px_next; uint8_t minor; @@ -318,8 +323,6 @@ static ssize_t ptmx_write(FAR struct file *filep, FAR const char *buffer, size_t void ptmx_register(void) { - FAR struct ptmx_dev_s *ptmx; - /* Initialize driver state */ sem_init(&g_ptmx.px_exclsem, 0, 1); diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 2719d6c35df..64cb061210d 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -43,11 +43,13 @@ #include #include #include +#include #include #include #include #include +#include #include /**************************************************************************** @@ -78,7 +80,7 @@ static int pty_unlink(FAR struct inode *inode); struct pty_devpair_s; struct pty_dev_s { - FAR struct pty_common_s *pd_devpair; + FAR struct pty_devpair_s *pd_devpair; struct file pd_src; /* Provides data to read() method (pipe output) */ struct file pd_sink; /* Accepts data from write() method (pipe input) */ }; @@ -87,8 +89,8 @@ struct pty_dev_s struct pty_devpair_s { - struct pty_dev_s pp_ptyp; /* /dev/ptypN device */ - struct pty_dev_s pp_ttyp; /* /dev/ttypN device */ + struct pty_dev_s pp_master; /* Maseter device */ + struct pty_dev_s pp_slave; /* Slave device */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS uint8_t pp_minor; /* Minor device number */ @@ -132,7 +134,7 @@ static const struct file_operations pty_fops = ****************************************************************************/ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS -static void pty_semtake(FAR struct pty_common_s *devpair) +static void pty_semtake(FAR struct pty_devpair_s *devpair) { while (sem_wait(&devpair->pp_exclsem) < 0) { @@ -152,31 +154,35 @@ static void pty_semtake(FAR struct pty_common_s *devpair) ****************************************************************************/ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS -static void pty_destroy(FAR struct pty_common_s *devpair) +static void pty_destroy(FAR struct pty_devpair_s *devpair) { char devname[16]; - /* Un-register /dev/ptypN */ + /* Un-register the slave device */ - snprintf(devname, 16, "/dev/pp_ptyp%d", (int)devpair->pp_minor); +#ifdef CONFIG_PSEUDOTERM_BSD + snprintf(devname, 16, "/dev/ttyp%d", devpair->pp_minor); +#else + snprintf(devname, 16, "/dev/pts/%d", devpair->pp_minor); +#endif (void)unregister_driver(devname); - - /* Un-register /dev/ptypN */ - snprintf(devname, 16, "/dev/ttyp%d", (int)devpair->pp_minor); + /* Un-register the master device (/dev/ptyN may have already been unlinked) */ + + snprintf(devname, 16, "/dev/pty%d", (int)devpair->pp_minor); (void)unregister_driver(devname); /* Close the contained file structures */ - (void)file_close_detached(&devpair->pp_ptyp.pd_src); - (void)file_close_detached(&devpair->pp_ptyp.pd_sink); - (void)file_close_detached(&devpair->pp_ttyp.pd_src); - (void)file_close_detached(&devpair->pp_ttyp.pd_sink); + (void)file_close_detached(&devpair->pp_master.pd_src); + (void)file_close_detached(&devpair->pp_master.pd_sink); + (void)file_close_detached(&devpair->pp_slave.pd_src); + (void)file_close_detached(&devpair->pp_slave.pd_sink); /* And free the device structure */ sem_destroy(&devpair->pp_exclsem); - kmm_free(upper); + kmm_free(devpair); } #endif @@ -189,10 +195,10 @@ static int pty_open(FAR struct file *filep) { FAR struct inode *inode; FAR struct pty_dev_s *dev; - FAR struct pty_common_s *devpair; + FAR struct pty_devpair_s *devpair; int ret; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); @@ -206,9 +212,9 @@ static int pty_open(FAR struct file *filep) * opens. */ - if (cmd->pp_unlinked) + if (devpair->pp_unlinked) { - ret = -EIDRAM + ret = -EIDRM; } else { @@ -234,9 +240,9 @@ static int pty_close(FAR struct file *filep) { FAR struct inode *inode; FAR struct pty_dev_s *dev; - FAR struct pty_common_s *devpair; + FAR struct pty_devpair_s *devpair; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); @@ -277,12 +283,12 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) FAR struct inode *inode; FAR struct pty_dev_s *dev; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); - return file_read(&dev->src, buffer, len); + return file_read(&dev->pd_src, buffer, len); } /**************************************************************************** @@ -294,12 +300,12 @@ static ssize_t pty_write(FAR struct file *filep, FAR const char *buffer, size_t FAR struct inode *inode; FAR struct pty_dev_s *dev; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); - return file_write(&dev->src, buffer, len); + return file_write(&dev->pd_sink, buffer, len); } /**************************************************************************** @@ -316,7 +322,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct pty_dev_s *dev; int ret; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); @@ -334,16 +340,15 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) default: { - ret = file_ioctl(dev->pd_src, cmd, arg); + ret = file_ioctl(&dev->pd_src, cmd, arg); if (ret >= 0 || ret == -ENOTTY) { - ret = file_ioctl(dev->pd_sink, cmd, arg); + ret = file_ioctl(&dev->pd_sink, cmd, arg); } } break; } - sem_post(&upper->exclsem); return ret; } @@ -366,15 +371,13 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS static int pty_unlink(FAR struct inode *inode) { - FAR struct inode *inode; FAR struct pty_dev_s *dev; - FAR struct pty_common_s *devpair; + FAR struct pty_devpair_s *devpair; - DEBUGASSERT(filep != NULL && file->f_inode != NULL); - inode = filep->f_inode; + DEBUGASSERT(inode != NULL && inode->i_private != NULL); dev = inode->i_private; - DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); devpair = dev->pd_devpair; + DEBUGASSERT(dev->pd_devpair != NULL); /* Get exclusive access */ @@ -406,9 +409,9 @@ static int pty_unlink(FAR struct inode *inode) * Name: pty_register * * Input Parameters: - * + * * Description: - * Register /dev/ttypN and /dev/ptpN where N=minor number + * Create and register PTY master and slave devices * ****************************************************************************/ @@ -418,6 +421,7 @@ int pty_register(int minor) int pipe_a[2]; int pipe_b[2]; char devname[16]; + int ret; /* Allocate a device instance */ @@ -431,8 +435,8 @@ int pty_register(int minor) sem_init(&devpair->pp_exclsem, 0, 1); devpair->pp_minor = minor; #endif - devpair->pp_ptyp.pd_devpair = devpair; - devpair->pp_ttyp.pd_devpair = devpair; + devpair->pp_master.pd_devpair = devpair; + devpair->pp_slave.pd_devpair = devpair; /* Create two pipes */ @@ -454,7 +458,7 @@ int pty_register(int minor) * fd[1] is for writing. */ - ret = file_detach(pipe_a[0], &devpair->pp_ptyp.pd_src); + ret = file_detach(pipe_a[0], &devpair->pp_master.pd_src); if (ret < 0) { goto errout_with_pipeb; @@ -462,7 +466,7 @@ int pty_register(int minor) pipe_a[0] = -1; - ret = file_detach(pipe_a[1], &devpair->pp_ttyp.pd_sink); + ret = file_detach(pipe_a[1], &devpair->pp_slave.pd_sink); if (ret < 0) { goto errout_with_pipeb; @@ -470,7 +474,7 @@ int pty_register(int minor) pipe_a[1] = -1; - ret = file_detach(pipe_b[0], &devpair->pp_ttyp.pd_src); + ret = file_detach(pipe_b[0], &devpair->pp_slave.pd_src); if (ret < 0) { goto errout_with_pipeb; @@ -478,7 +482,7 @@ int pty_register(int minor) pipe_b[0] = -1; - ret = file_detach(pipe_b[1], &devpair->pp_ptyp.pd_sink); + ret = file_detach(pipe_b[1], &devpair->pp_master.pd_sink); if (ret < 0) { goto errout_with_pipeb; @@ -486,31 +490,51 @@ int pty_register(int minor) pipe_b[1] = -1; - /* Register /dev/ptypN */ + /* Register the slave device + * + * BSD style (deprecated): /dev/ttypN + * SUSv1 style: /dev/pts/N + * + * Where N is the minor number + */ +#ifdef CONFIG_PSEUDOTERM_BSD + snprintf(devname, 16, "/dev/ttyp%d", minor); +#else snprintf(devname, 16, "/dev/pts/%d", minor); +#endif - ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_ptyp); + ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_slave); if (ret < 0) { goto errout_with_pipeb; } - - /* Register /dev/ptypN */ - snprintf(devname, 16, "/dev/ttyp%d", minor); + /* Register the master device + * + * BSD style (deprecated): /dev/ptyN + * SUSv1 style: Master: /dev/ptmx (see ptmx.c) + * + * Where N is the minor number + */ - ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_ttyp); + snprintf(devname, 16, "/dev/pty%d", minor); + + ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_master); if (ret < 0) { - goto errout_with_ptyp; + goto errout_with_slave; } return OK; -errout_with_ptyp: - snprintf(devname, 16, "/dev/ptyp%d", minor); - (void)unregister_driver(devname) +errout_with_slave: +#ifdef CONFIG_PSEUDOTERM_BSD + snprintf(devname, 16, "/dev/ttyp%d", minor); +#else + snprintf(devname, 16, "/dev/pts/%d", minor); +#endif + (void)unregister_driver(devname); errout_with_pipeb: if (pipe_b[0] >= 0) @@ -519,7 +543,7 @@ errout_with_pipeb: } else { - (void)file_close_detached(&devpair->pp_ptyp.pd_src); + (void)file_close_detached(&devpair->pp_master.pd_src); } if (pipe_b[1] >= 0) @@ -528,7 +552,7 @@ errout_with_pipeb: } else { - (void)file_close_detached(&devpair->pp_ttyp.pd_sink); + (void)file_close_detached(&devpair->pp_slave.pd_sink); } errout_with_pipea: @@ -538,7 +562,7 @@ errout_with_pipea: } else { - (void)file_close_detached(&devpair->pp_ttyp.pd_src); + (void)file_close_detached(&devpair->pp_slave.pd_src); } if (pipe_a[1] >= 0) @@ -547,7 +571,7 @@ errout_with_pipea: } else { - (void)file_close_detached(&devpair->pp_ptyp.pd_sink); + (void)file_close_detached(&devpair->pp_master.pd_sink); } errout_with_devpair: From e50646336b694fe5f102e04c9dc362e1d46ff005 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 07:18:12 -0600 Subject: [PATCH 031/152] Add PTY header files --- drivers/serial/ptmx.c | 16 ++++-- drivers/serial/pty.c | 10 +++- drivers/serial/pty.h | 83 ++++++++++++++++++++++++++++++ include/nuttx/serial/pty.h | 102 +++++++++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 drivers/serial/pty.h create mode 100644 include/nuttx/serial/pty.h diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index d718702895c..31f86d14213 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -50,6 +50,9 @@ #include #include +#include + +#include "pty.h" /**************************************************************************** * Private Function Prototypes @@ -316,12 +319,19 @@ static ssize_t ptmx_write(FAR struct file *filep, FAR const char *buffer, size_t /**************************************************************************** * Name: ptmx_register * + * Input Parameters: + * None + * * Description: - * Register /dev/null + * Register the master pseudo-terminal device at /dev/ptmx + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. * ****************************************************************************/ -void ptmx_register(void) +int ptmx_register(void) { /* Initialize driver state */ @@ -329,5 +339,5 @@ void ptmx_register(void) /* Register the PTMX driver */ - (void)register_driver("/dev/ptmx", &g_ptmx_fops, 0666, NULL); + return register_driver("/dev/ptmx", &g_ptmx_fops, 0666, NULL); } diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 64cb061210d..ebe8f9f9777 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -51,6 +51,9 @@ #include #include +#include + +#include "pty.h" /**************************************************************************** * Private Function Prototypes @@ -409,9 +412,14 @@ static int pty_unlink(FAR struct inode *inode) * Name: pty_register * * Input Parameters: + * minor - The number that qualifies the naming of the created devices. * * Description: - * Create and register PTY master and slave devices + * Create and register PTY master and slave devices. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. * ****************************************************************************/ diff --git a/drivers/serial/pty.h b/drivers/serial/pty.h new file mode 100644 index 00000000000..4d660d58870 --- /dev/null +++ b/drivers/serial/pty.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * drivers/serial/pty.h + * + * Copyright (C) 2016 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. + * + ****************************************************************************/ + +#ifndef __DRIVERS_SERIAL_PTY_H +#define __DRIVERS_SERIAL_PTY_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: pty_register + * + * Input Parameters: + * minor - The number that qualifies the naming of the created devices. + * + * Description: + * Create and register PTY master and slave devices. The master device + * will be registered at /dev/ptyN and slave at /dev/pts/N where N is + * the provided minor number. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_PSEUDOTERM_SUSV1 +int pty_register(int minor); +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __DRIVERS_SERIAL_PTY_H */ diff --git a/include/nuttx/serial/pty.h b/include/nuttx/serial/pty.h new file mode 100644 index 00000000000..15d83193cb3 --- /dev/null +++ b/include/nuttx/serial/pty.h @@ -0,0 +1,102 @@ +/**************************************************************************** + * include/nuttx/serial/pty.h + * + * Copyright (C) 2016 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SERIAL_PTY_H +#define __INCLUDE_NUTTX_SERIAL_PTY_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: ptmx_register + * + * Input Parameters: + * None + * + * Description: + * Register the master pseudo-terminal device at /dev/ptmx + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_PSEUDOTERM_SUSV1 +int ptmx_register(void); +#endif + +/**************************************************************************** + * Name: pty_register + * + * Input Parameters: + * minor - The number that qualifies the naming of the created devices. + * + * Description: + * Create and register PTY master and slave devices. The master device + * will be registered at /dev/ptyN and slave at /dev/ttypN where N is + * the provided minor number. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_PSEUDOTERM_BSD +int pty_register(int minor); +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_SERIAL_PTY_H */ From 14c216107ae36975ea851faa74d48a504a14e0f9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 07:22:36 -0600 Subject: [PATCH 032/152] PTY: Need to free PTMX minor number is slave is unlinked --- drivers/serial/ptmx.c | 64 +++++++++++++++++++++---------------------- drivers/serial/pty.c | 6 ++++ drivers/serial/pty.h | 15 ++++++++++ 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index 31f86d14213..f33d3a83fb2 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -202,38 +202,6 @@ static int ptmx_minor_allocate(void) } } -/**************************************************************************** - * Name: ptmx_minor_free - * - * Description: - * De-allocate a PTY minor number. - * - * Assumptions: - * Caller hold the px_exclsem - * - ****************************************************************************/ - -static void ptmx_minor_free(uint8_t minor) -{ - int index; - int bitno; - - /* Free the address by clearing the associated bit in the px_alloctab[]; */ - - index = minor >> 5; - bitno = minor & 31; - - DEBUGASSERT((g_ptmx.px_alloctab[index] |= (1 << bitno)) != 0); - g_ptmx.px_alloctab[index] &= ~(1 << bitno); - - /* Reset the next pointer if the one just released has a lower value */ - - if (minor < g_ptmx.px_next) - { - g_ptmx.px_next = minor; - } -} - /**************************************************************************** * Name: ptmx_open ****************************************************************************/ @@ -341,3 +309,35 @@ int ptmx_register(void) return register_driver("/dev/ptmx", &g_ptmx_fops, 0666, NULL); } + +/**************************************************************************** + * Name: ptmx_minor_free + * + * Description: + * De-allocate a PTY minor number. + * + * Assumptions: + * Caller hold the px_exclsem + * + ****************************************************************************/ + +void ptmx_minor_free(uint8_t minor) +{ + int index; + int bitno; + + /* Free the address by clearing the associated bit in the px_alloctab[]; */ + + index = minor >> 5; + bitno = minor & 31; + + DEBUGASSERT((g_ptmx.px_alloctab[index] |= (1 << bitno)) != 0); + g_ptmx.px_alloctab[index] &= ~(1 << bitno); + + /* Reset the next pointer if the one just released has a lower value */ + + if (minor < g_ptmx.px_next) + { + g_ptmx.px_next = minor; + } +} diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index ebe8f9f9777..7d3e92fe34c 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -182,6 +182,12 @@ static void pty_destroy(FAR struct pty_devpair_s *devpair) (void)file_close_detached(&devpair->pp_slave.pd_src); (void)file_close_detached(&devpair->pp_slave.pd_sink); +#ifdef CONFIG_PSEUDOTERM_SUSV1 + /* Free this minor number so that it can be reused */ + + ptmx_minor_free(devpair->pp_minor); +#endif + /* And free the device structure */ sem_destroy(&devpair->pp_exclsem); diff --git a/drivers/serial/pty.h b/drivers/serial/pty.h index 4d660d58870..09a413197f1 100644 --- a/drivers/serial/pty.h +++ b/drivers/serial/pty.h @@ -54,6 +54,21 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Name: ptmx_minor_free + * + * Description: + * De-allocate a PTY minor number. + * + * Assumptions: + * Caller hold the px_exclsem + * + ****************************************************************************/ + +#ifdef CONFIG_PSEUDOTERM_SUSV1 +void ptmx_minor_free(uint8_t minor); +#endif + /**************************************************************************** * Name: pty_register * From bcbe9806d29298ff815e614a537fe7227d251412 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 07:33:48 -0600 Subject: [PATCH 033/152] In SUSv1 model, need to tried the PTY driver pair as unlinked if the master closes its reference --- drivers/serial/pty.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 7d3e92fe34c..48c224d140e 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -86,6 +86,9 @@ struct pty_dev_s FAR struct pty_devpair_s *pd_devpair; struct file pd_src; /* Provides data to read() method (pipe output) */ struct file pd_sink; /* Accepts data from write() method (pipe input) */ +#ifdef CONFIG_PSEUDOTERM_SUSV1 + bool pd_master; /* True: this is the master */ +#endif }; /* This structure describes the pipe pair */ @@ -261,12 +264,28 @@ static int pty_close(FAR struct file *filep) pty_semtake(devpair); - /* Is this the last open reference? */ +#ifdef CONFIG_PSEUDOTERM_SUSV1 + /* Did the (single) master just close its reference? */ + + if (dev->pd_master) + { + /* Yes, then we are essentially unlinked and when all of the + * slaves close there references, then the PTY should be + * destroyed. + */ + + devpair->pp_unlinked = true; + } +#endif + + /* Is this the last open reference? If so, was the driver previously + * unlinked? + */ DEBUGASSERT(devpair->pp_nopen > 0); if (devpair->pp_nopen <= 1 && devpair->pp_unlinked) { - /* Free the device pair now (without freeing the semaphore) */ + /* Yes.. Free the device pair now (without freeing the semaphore) */ pty_destroy(devpair); return OK; @@ -447,10 +466,13 @@ int pty_register(int minor) #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS sem_init(&devpair->pp_exclsem, 0, 1); - devpair->pp_minor = minor; + devpair->pp_minor = minor; #endif devpair->pp_master.pd_devpair = devpair; - devpair->pp_slave.pd_devpair = devpair; + devpair->pp_slave.pd_devpair = devpair; +#ifdef CONFIG_PSEUDOTERM_SUSV1 + devpair->pp_master.pd_master = true; +#endif /* Create two pipes */ From 6139860c0b622a96e498783a4d6fee8a9bbf0a64 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 08:33:47 -0600 Subject: [PATCH 034/152] PTY: Added PTY IOCTL command definitions. Add support for TIOCGPTN. LIB: Implement ptsname() and ptsname_r() --- drivers/serial/pty.c | 37 ++++++++++++-- include/nuttx/serial/tioctl.h | 18 ++++--- include/stdlib.h | 12 +++++ libc/stdlib/Make.defs | 4 ++ libc/stdlib/lib_ptsname.c | 74 +++++++++++++++++++++++++++ libc/stdlib/lib_ptsnamer.c | 95 +++++++++++++++++++++++++++++++++++ 6 files changed, 230 insertions(+), 10 deletions(-) create mode 100644 libc/stdlib/lib_ptsname.c create mode 100644 libc/stdlib/lib_ptsnamer.c diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 48c224d140e..b6c06806f1a 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -348,19 +349,47 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { FAR struct inode *inode; FAR struct pty_dev_s *dev; + FAR struct pty_devpair_s *devpair; int ret; DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - inode = filep->f_inode; - dev = inode->i_private; - DEBUGASSERT(dev != NULL); + inode = filep->f_inode; + dev = inode->i_private; + DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); + devpair = dev->pd_devpair; /* Handle IOCTL commands */ switch (cmd) { /* PTY IOCTL commands would be handled here */ - /* There aren't any yet */ + + case TIOCGPTN: /* Get Pty Number (of pty-mux device): FAR int* */ + { +#ifdef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + ret = -ENOSYS; +#else + FAR int *ptyno = (FAR int *)((uintptr_t)arg); + if (ptyno == NULL) + { + ret = -EINVAL; + } + else + { + *ptyno = (int)devpair->pp_minor; + ret = OK; + } +#endif + } + break; + + case TIOCSPTLCK: /* Lock/unlock Pty: int */ + ret = -ENOSYS; /* Not implemented */ + break; + + case TIOCGPTLCK: /* Get Pty lock state: FAR int* */ + ret = -ENOSYS; /* Not implemented */ + break; /* Any unrecognized IOCTL commands will be passed to the contained * pipe driver. diff --git a/include/nuttx/serial/tioctl.h b/include/nuttx/serial/tioctl.h index 2044195e502..e4c01690edb 100644 --- a/include/nuttx/serial/tioctl.h +++ b/include/nuttx/serial/tioctl.h @@ -146,7 +146,7 @@ /* Marking a line as local */ -#define TIOCGSOFTCAR _TIOC(0x0023) /* Get software carrier flag: FAR int */ +#define TIOCGSOFTCAR _TIOC(0x0023) /* Get software carrier flag: FAR int* */ #define TIOCSSOFTCAR _TIOC(0x0024) /* Set software carrier flag: FAR const int */ /* Get/set serial line info */ @@ -160,10 +160,16 @@ #define TIOCMIWAIT _TIOC(0x0028) /* Wait for a change on serial input line(s): void */ #define TIOCGICOUNT _TIOC(0x0029) /* Read serial port interrupt count: FAR struct serial_icounter_struct */ +/* Pseudo-terminals */ + +#define TIOCGPTN _TIOC(0x002a) /* Get Pty Number (of pty-mux device): FAR int* */ +#define TIOCSPTLCK _TIOC(0x002b) /* Lock/unlock Pty: int */ +#define TIOCGPTLCK _TIOC(0x002c) /* Get Pty lock state: FAR int* */ + /* RS-485 Support */ -#define TIOCSRS485 _TIOC(0x002a) /* Set RS485 mode, arg: pointer to struct serial_rs485 */ -#define TIOCGRS485 _TIOC(0x002b) /* Get RS485 mode, arg: pointer to struct serial_rs485 */ +#define TIOCSRS485 _TIOC(0x002d) /* Set RS485 mode, arg: pointer to struct serial_rs485 */ +#define TIOCGRS485 _TIOC(0x002e) /* Get RS485 mode, arg: pointer to struct serial_rs485 */ /* Definitions for flags used in struct serial_rs485 (Linux compatible) */ @@ -174,14 +180,14 @@ /* Single-wire UART support */ -#define TIOCSSINGLEWIRE _TIOC(0x002c) /* Set single-wire mode */ -#define TIOCGSINGLEWIRE _TIOC(0x002d) /* Get single-wire mode */ +#define TIOCSSINGLEWIRE _TIOC(0x002f) /* Set single-wire mode */ +#define TIOCGSINGLEWIRE _TIOC(0x0030) /* Get single-wire mode */ # define SER_SINGLEWIRE_ENABLED (1 << 0) /* Enable/disable single-wire support */ /* Debugging */ -#define TIOCSERGSTRUCT _TIOC(0x002e) /* Get device TTY structure */ +#define TIOCSERGSTRUCT _TIOC(0x0031) /* Get device TTY structure */ /******************************************************************************************** * Public Type Definitions diff --git a/include/stdlib.h b/include/stdlib.h index aa259c9d50c..25d4e36c408 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -207,6 +207,18 @@ struct mallinfo mallinfo(void); int mallinfo(FAR struct mallinfo *info); #endif +/* Pseudo-Terminals */ + +#ifdef CONFIG_PSEUDOTERM_SUSV1 +FAR char *ptsname(int fd); +int ptsname_r(int fd, FAR char *buf, size_t buflen); + +#if 0 /* Not implemented */ +int grantpt(int fd); +int unlockpt(int fd); +#endif +#endif + /* Arithmetic */ int abs(int j); diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index 68eb75e68b4..460fb1dd8f9 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -45,6 +45,10 @@ ifeq ($(CONFIG_FS_WRITABLE),y) CSRCS += lib_mktemp.c lib_mkstemp.c endif +ifeq ($(CONFIG_PSEUDOTERM_SUSV1),y) +CSRCS += lib_ptsname.c lib_ptsnamer.c +endif + # Add the stdlib directory to the build DEPPATH += --dep-path stdlib diff --git a/libc/stdlib/lib_ptsname.c b/libc/stdlib/lib_ptsname.c new file mode 100644 index 00000000000..04cd6460dd5 --- /dev/null +++ b/libc/stdlib/lib_ptsname.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * libc/stdlib/lib_ptsname.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_PSEUDOTERM_SUSV1 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ptsname + * + * Description: + * The ptsname() function returns the name of the slave pseudoterminal + * device corresponding to the master referred to by fd. + * + * Returned Values: + * On success, ptsname() returns a pointer to a string in static storage + * which will be overwritten by subsequent calls. This pointer must not + * be freed. On failure, NULL is returned. + * + * ENOTTY fd does not refer to a pseudoterminal master device. + * + ****************************************************************************/ + +FAR char *ptsname(int fd) +{ + static char devname[16]; + int ret = ptsname_r(fd, devname, 16); + return ret < 0 ? NULL : devname; +} + +#endif /* CONFIG_PSEUDOTERM_SUSV1 */ diff --git a/libc/stdlib/lib_ptsnamer.c b/libc/stdlib/lib_ptsnamer.c new file mode 100644 index 00000000000..e5df9c0ec7e --- /dev/null +++ b/libc/stdlib/lib_ptsnamer.c @@ -0,0 +1,95 @@ +/**************************************************************************** + * libc/stdlib/lib_ptsnamer.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#ifdef CONFIG_PSEUDOTERM_SUSV1 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ptsname_r + * + * Description: + * The ptsname_r() function is the reentrant equivalent of ptsname(). + * It returns the name of the slave pseudoterminal device as a null- + * terminated string in the buffer pointed to by buf. The buflen + * argument specifies the number of bytes available in buf. + * + * Returned Values: + * On success, ptsname_r() returns 0. On failure, a nonzero value is + * returned and errno is set to indicate the error. + * + * EINVAL (ptsname_r() only) buf is NULL. + * ENOTTY fd does not refer to a pseudoterminal master device. + * ERANGE (ptsname_r() only) buf is too small. + * + ****************************************************************************/ + +int ptsname_r(int fd, FAR char *buf, size_t buflen) +{ + int ptyno; + int ret; + + DEBUGASSERT(buf != NULL); + + /* Get the slave PTY number */ + + ret = ioctl(fd, TIOCGPTN, (unsigned long)((uintptr_t)&ptyno)); + if (ret < 0) + { + return ret; + } + + /* Create the device name. This current does not handler EINVAL or ERANGE + * error detection. + */ + + snprintf(buf, buflen, "/dev/pts/%d", ptyno); + return OK; +} + +#endif /* CONFIG_PSEUDOTERM_SUSV1 */ From 95555a01991864aa14bd05b907b796240d821400 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 09:39:33 -0600 Subject: [PATCH 035/152] PTY: Add ioctls to support locking and unlocking of the slave. LIBC: Add implementation of unlockpt() --- drivers/serial/pty.c | 131 +++++++++++++++++++++++++++++++------ drivers/serial/pty.h | 9 ++- include/nuttx/serial/pty.h | 9 ++- include/stdlib.h | 11 ++-- libc/stdlib/Make.defs | 4 ++ libc/stdlib/lib_ptsname.c | 1 - libc/stdlib/lib_unlockpt.c | 75 +++++++++++++++++++++ 7 files changed, 209 insertions(+), 31 deletions(-) create mode 100644 libc/stdlib/lib_unlockpt.c diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index b6c06806f1a..2ceca4f3f96 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -87,9 +87,7 @@ struct pty_dev_s FAR struct pty_devpair_s *pd_devpair; struct file pd_src; /* Provides data to read() method (pipe output) */ struct file pd_sink; /* Accepts data from write() method (pipe input) */ -#ifdef CONFIG_PSEUDOTERM_SUSV1 bool pd_master; /* True: this is the master */ -#endif }; /* This structure describes the pipe pair */ @@ -97,14 +95,16 @@ struct pty_dev_s struct pty_devpair_s { struct pty_dev_s pp_master; /* Maseter device */ - struct pty_dev_s pp_slave; /* Slave device */ + struct pty_dev_s pp_slave; /* Slave device */ + bool pp_locked; /* Slave is locked */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + bool pp_unlinked; /* File has been unlinked */ uint8_t pp_minor; /* Minor device number */ uint16_t pp_nopen; /* Open file count */ - sem_t pp_exclsem; /* Mutual exclusion */ - bool pp_unlinked; /* File has been unlinked */ #endif + sem_t pp_slavesem; /* Slave lock semaphore */ + sem_t pp_exclsem; /* Mutual exclusion */ }; /**************************************************************************** @@ -140,7 +140,6 @@ static const struct file_operations pty_fops = * Name: pty_semtake ****************************************************************************/ -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS static void pty_semtake(FAR struct pty_devpair_s *devpair) { while (sem_wait(&devpair->pp_exclsem) < 0) @@ -148,7 +147,6 @@ static void pty_semtake(FAR struct pty_devpair_s *devpair) DEBUGASSERT(errno == EINTR); } } -#endif /**************************************************************************** * Name: pty_semgive @@ -217,9 +215,53 @@ static int pty_open(FAR struct file *filep) DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); devpair = dev->pd_devpair; - /* Get exclusive access */ + /* Wait if this is an attempt to open the slave device and the slave + * device is locked. + */ - pty_semtake(devpair); + if (!dev->pd_master) + { + /* Slave... Check if the slave driver is locked. We need to lock the + * scheduler while we are running to prevent asyncrhonous modification + * of pp_locked by pty_ioctl(). + */ + + sched_lock(); + while (devpair->pp_locked) + { + /* Wait until unlocked. We will also most certainly suspend here. */ + + sem_wait(&devpair->pp_slavesem); + + /* Get exclusive access to the device structure. This might also + * cause suspension. + */ + + pty_semtake(devpair); + + /* Check again in case something happened asynchronously while we + * were suspended. + */ + + if (devpair->pp_locked) + { + /* This cannot suspend because we have the scheduler locked. + * So pp_locked cannot change asyncrhonously between this test + * and the redundant test at the top of the loop. + */ + + pty_semgive(devpair); + } + } + + sched_unlock(); + } + else + { + /* Master ... Get exclusive access to the device structure */ + + pty_semtake(devpair); + } /* If one side of the driver has been unlinked, then refuse further * opens. @@ -358,6 +400,10 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(dev != NULL && dev->pd_devpair != NULL); devpair = dev->pd_devpair; + /* Get exclusive access */ + + pty_semtake(devpair); + /* Handle IOCTL commands */ switch (cmd) @@ -384,11 +430,54 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; case TIOCSPTLCK: /* Lock/unlock Pty: int */ - ret = -ENOSYS; /* Not implemented */ + { + if (arg == 0) + { + int sval; + + /* Unlocking */ + + sched_lock(); + devpair->pp_locked = false; + + /* Release any waiting threads */ + + do + { + DEBUGVERIFY(sem_getvalue(&devpair->pp_slavesem, &sval)); + if (sval < 0) + { + sem_post(&devpair->pp_slavesem); + } + } + while (sval < 0); + + sched_unlock(); + ret = OK; + } + else + { + /* Locking */ + + devpair->pp_locked = true; + ret = OK; + } + } break; case TIOCGPTLCK: /* Get Pty lock state: FAR int* */ - ret = -ENOSYS; /* Not implemented */ + { + FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr == NULL) + { + ret = -EINVAL; + } + else + { + *ptr = (int)devpair->pp_locked; + ret = OK; + } + } break; /* Any unrecognized IOCTL commands will be passed to the contained @@ -406,6 +495,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; } + pty_semgive(devpair); return ret; } @@ -465,12 +555,14 @@ static int pty_unlink(FAR struct inode *inode) /**************************************************************************** * Name: pty_register * + * Description: + * Create and register PTY master and slave devices. The slave side of + * the interface is always locked initially. The master must call + * unlockpt() before the slave device can be opened. + * * Input Parameters: * minor - The number that qualifies the naming of the created devices. * - * Description: - * Create and register PTY master and slave devices. - * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. @@ -493,15 +585,15 @@ int pty_register(int minor) return -ENOMEM; } -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + sem_init(&devpair->pp_slavesem, 0, 0); sem_init(&devpair->pp_exclsem, 0, 1); +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS devpair->pp_minor = minor; #endif + devpair->pp_locked = true; devpair->pp_master.pd_devpair = devpair; - devpair->pp_slave.pd_devpair = devpair; -#ifdef CONFIG_PSEUDOTERM_SUSV1 devpair->pp_master.pd_master = true; -#endif + devpair->pp_slave.pd_devpair = devpair; /* Create two pipes */ @@ -640,9 +732,8 @@ errout_with_pipea: } errout_with_devpair: -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS sem_destroy(&devpair->pp_exclsem); -#endif + sem_destroy(&devpair->pp_slavesem); kmm_free(devpair); return ret; } diff --git a/drivers/serial/pty.h b/drivers/serial/pty.h index 09a413197f1..1c3d96ae5d4 100644 --- a/drivers/serial/pty.h +++ b/drivers/serial/pty.h @@ -72,14 +72,17 @@ void ptmx_minor_free(uint8_t minor); /**************************************************************************** * Name: pty_register * - * Input Parameters: - * minor - The number that qualifies the naming of the created devices. - * * Description: * Create and register PTY master and slave devices. The master device * will be registered at /dev/ptyN and slave at /dev/pts/N where N is * the provided minor number. * + * The slave side of the interface is always locked initially. The + * master must call unlockpt() before the slave device can be opened. + * + * Input Parameters: + * minor - The number that qualifies the naming of the created devices. + * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. diff --git a/include/nuttx/serial/pty.h b/include/nuttx/serial/pty.h index 15d83193cb3..62f054b831e 100644 --- a/include/nuttx/serial/pty.h +++ b/include/nuttx/serial/pty.h @@ -76,14 +76,17 @@ int ptmx_register(void); /**************************************************************************** * Name: pty_register * - * Input Parameters: - * minor - The number that qualifies the naming of the created devices. - * * Description: * Create and register PTY master and slave devices. The master device * will be registered at /dev/ptyN and slave at /dev/ttypN where N is * the provided minor number. * + * The slave side of the interface is always locked initially. The + * master must call unlockpt() before the slave device can be opened. + * + * Input Parameters: + * minor - The number that qualifies the naming of the created devices. + * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. diff --git a/include/stdlib.h b/include/stdlib.h index 25d4e36c408..d08db9d5570 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -212,11 +212,14 @@ int mallinfo(FAR struct mallinfo *info); #ifdef CONFIG_PSEUDOTERM_SUSV1 FAR char *ptsname(int fd); int ptsname_r(int fd, FAR char *buf, size_t buflen); - -#if 0 /* Not implemented */ -int grantpt(int fd); -int unlockpt(int fd); #endif + +#ifdef CONFIG_PSEUDOTERM +int unlockpt(int fd); + +/* int grantpt(int fd); Not implemented */ + +#define grantpt(fd) (0) #endif /* Arithmetic */ diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index 460fb1dd8f9..625712e91e6 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -49,6 +49,10 @@ ifeq ($(CONFIG_PSEUDOTERM_SUSV1),y) CSRCS += lib_ptsname.c lib_ptsnamer.c endif +ifeq ($(CONFIG_PSEUDOTERM),y) +CSRCS += lib_unlockpt.c +endif + # Add the stdlib directory to the build DEPPATH += --dep-path stdlib diff --git a/libc/stdlib/lib_ptsname.c b/libc/stdlib/lib_ptsname.c index 04cd6460dd5..54cdabd69ef 100644 --- a/libc/stdlib/lib_ptsname.c +++ b/libc/stdlib/lib_ptsname.c @@ -39,7 +39,6 @@ #include -#include #include #ifdef CONFIG_PSEUDOTERM_SUSV1 diff --git a/libc/stdlib/lib_unlockpt.c b/libc/stdlib/lib_unlockpt.c new file mode 100644 index 00000000000..72e148b1bea --- /dev/null +++ b/libc/stdlib/lib_unlockpt.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * libc/stdlib/lib_unlockpt.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_PSEUDOTERM + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: unlockpt + * + * Description: + * The unlockpt() function unlocks the slave pseudoterminal device + * corresponding to the master pseudoterminal referred to by fd. + * unlockpt() must be called before opening the slave side of a + * pseudoterminal. + * + * Returned Values: + * When successful, unlockpt() returns 0. Otherwise, it returns -1 and + * sets errno appropriately. + * + * EBADF - The fd argument is not a file descriptor open for writing. + * EINVAL - The fd argument is not associated with a master + * pseudoterminal + * + ****************************************************************************/ + +int unlockpt(int fd) +{ + return ioctl(fd, TIOCSPTLCK, 0); +} + +#endif /* CONFIG_PSEUDOTERM */ From 4d1b81111728a63a7bad7f0a76f4ec6c5e0a8e66 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 10:07:33 -0600 Subject: [PATCH 036/152] PTY: Add support for the poll() method. --- drivers/serial/pty.c | 61 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 2ceca4f3f96..47904d04015 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -504,10 +504,69 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL +/* REVISIT: There is a file_poll() function, but it does not work in this + * context so the logic is implemented locally as my_file_poll(). + */ + +static my_file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) +{ + FAR struct inode *inode; + int ret = -ENOSYS; + + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); + inode = filep->f_inode; + + /* Is a driver registered? Does it support the poll method? + * If not, return -ENOSYS + */ + + if (inode != NULL && inode->u.i_ops != NULL && inode->u.i_ops->poll != NULL) + { + /* Yes, then setup the poll */ + + ret = (int)inode->u.i_ops->poll(filep, fds, setup); + } + + return ret; +} + static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) { -#warning Missing logic + FAR struct inode *inode; + FAR struct pty_dev_s *dev; + int ret = -ENOSYS; + + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); + inode = filep->f_inode; + dev = inode->i_private; + + /* REVISIT: If both POLLIN and POLLOUT are set, might the following logic + * fail? Could we not get POLLIN on the sink file and POLLOUT on the source + * file? + * + * REVISIT: There is a file_poll() function, but it does not work in this + * context so the logic is implemented locally as my_file_poll(). + */ + + /* POLLIN: Data other than high-priority data may be read without blocking. */ + + if ((fds->events & POLLIN) != 0) + { + ret = my_file_poll(dev->pd_src, fds, setup); + } + + if (ret >= OK || ret == -ENOTTY) + { + /* POLLOUT: Normal data may be written without blocking. */ + + if ((fds->events & POLLOUT) != 0) + { + ret = my_file_poll(dev->pd_sink, fds, setup); + } + } + + return ret; } #endif From f7f7036db84fb0037fced4cd5fa6fede92a38168 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 11:15:33 -0600 Subject: [PATCH 037/152] Update some comments --- drivers/serial/Kconfig | 2 +- drivers/serial/ptmx.c | 2 +- drivers/serial/pty.c | 2 +- include/nuttx/serial/pty.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 490d39601fe..68a8d597397 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2041,7 +2041,7 @@ config PSEUDOTERM_SUSV1 ---help--- PTYs as specified in the Single Unix Specification (SUSv1). - Master: /dev/ptmx + Master: /dev/ptmx (multiplexor) Slave: /dev/pts/N Where N is the minor number diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index f33d3a83fb2..ce332841890 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -291,7 +291,7 @@ static ssize_t ptmx_write(FAR struct file *filep, FAR const char *buffer, size_t * None * * Description: - * Register the master pseudo-terminal device at /dev/ptmx + * Register the master pseudo-terminal multiplexor device at /dev/ptmx * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 47904d04015..48bee433b34 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -729,7 +729,7 @@ int pty_register(int minor) /* Register the master device * * BSD style (deprecated): /dev/ptyN - * SUSv1 style: Master: /dev/ptmx (see ptmx.c) + * SUSv1 style: Master: /dev/ptmx (multiplexor, see ptmx.c) * * Where N is the minor number */ diff --git a/include/nuttx/serial/pty.h b/include/nuttx/serial/pty.h index 62f054b831e..8b8768909a1 100644 --- a/include/nuttx/serial/pty.h +++ b/include/nuttx/serial/pty.h @@ -61,7 +61,7 @@ extern "C" * None * * Description: - * Register the master pseudo-terminal device at /dev/ptmx + * Register the master pseudo-terminal multiplexor device at /dev/ptmx * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on From 6e6c04f778f6d3f1f69d70994cf20f112f305d0e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 11:21:11 -0600 Subject: [PATCH 038/152] Rename file_poll as fdesc_poll. The file_ namespace is used for other things. --- fs/vfs/fs_poll.c | 6 +++--- include/nuttx/fs/fs.h | 4 ++-- net/local/local_netpoll.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index b4163230fea..924c5c83712 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -121,7 +121,7 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup) } } - return file_poll(fd, fds, setup); + return fdesc_poll(fd, fds, setup); } #endif @@ -244,7 +244,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count, ****************************************************************************/ /**************************************************************************** - * Function: file_poll + * Function: fdesc_poll * * Description: * The standard poll() operation redirects operations on file descriptors @@ -262,7 +262,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count, ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 -int file_poll(int fd, FAR struct pollfd *fds, bool setup) +int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup) { FAR struct file *filep; FAR struct inode *inode; diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index f383c4ac06a..b9952a4eb87 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -930,7 +930,7 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap); #endif /**************************************************************************** - * Function: file_poll + * Function: fdesc_poll * * Description: * The standard poll() operation redirects operations on file descriptors @@ -948,7 +948,7 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap); ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 -int file_poll(int fd, FAR struct pollfd *fds, bool setup); +int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup); #endif /**************************************************************************** diff --git a/net/local/local_netpoll.c b/net/local/local_netpoll.c index 4b100d67d02..9800af3172c 100644 --- a/net/local/local_netpoll.c +++ b/net/local/local_netpoll.c @@ -233,13 +233,13 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Setup poll for both shadow pollfds. */ - ret = file_poll(conn->lc_infd, &shadowfds[0], true); + ret = fdesc_poll(conn->lc_infd, &shadowfds[0], true); if (ret >= 0) { - ret = file_poll(conn->lc_outfd, &shadowfds[1], true); + ret = fdesc_poll(conn->lc_outfd, &shadowfds[1], true); if (ret < 0) { - (void)file_poll(conn->lc_infd, &shadowfds[0], false); + (void)fdesc_poll(conn->lc_infd, &shadowfds[0], false); } } @@ -267,7 +267,7 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) goto pollerr; } - ret = file_poll(conn->lc_infd, fds, true); + ret = fdesc_poll(conn->lc_infd, fds, true); } break; @@ -281,7 +281,7 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) goto pollerr; } - ret = file_poll(conn->lc_outfd, fds, true); + ret = fdesc_poll(conn->lc_outfd, fds, true); } break; @@ -356,13 +356,13 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) /* Teardown for both shadow pollfds. */ - ret = file_poll(conn->lc_infd, &shadowfds[0], false); + ret = fdesc_poll(conn->lc_infd, &shadowfds[0], false); if (ret < 0) { status = ret; } - ret = file_poll(conn->lc_outfd, &shadowfds[1], false); + ret = fdesc_poll(conn->lc_outfd, &shadowfds[1], false); if (ret < 0) { status = ret; @@ -381,7 +381,7 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) return OK; } - status = file_poll(conn->lc_infd, fds, false); + status = fdesc_poll(conn->lc_infd, fds, false); } break; @@ -392,7 +392,7 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) return OK; } - status = file_poll(conn->lc_outfd, fds, false); + status = fdesc_poll(conn->lc_outfd, fds, false); } break; From 9ecd558002ba8e4f7eae24219557b2862f0d652f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 11:34:08 -0600 Subject: [PATCH 039/152] Add the correct implementation of the file_poll() function --- drivers/serial/pty.c | 33 ++--------------------- fs/vfs/fs_poll.c | 63 ++++++++++++++++++++++++++++++++----------- include/nuttx/fs/fs.h | 23 ++++++++++++++++ 3 files changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 48bee433b34..ad6d95ac0ca 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -504,32 +504,6 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -/* REVISIT: There is a file_poll() function, but it does not work in this - * context so the logic is implemented locally as my_file_poll(). - */ - -static my_file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) -{ - FAR struct inode *inode; - int ret = -ENOSYS; - - DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - inode = filep->f_inode; - - /* Is a driver registered? Does it support the poll method? - * If not, return -ENOSYS - */ - - if (inode != NULL && inode->u.i_ops != NULL && inode->u.i_ops->poll != NULL) - { - /* Yes, then setup the poll */ - - ret = (int)inode->u.i_ops->poll(filep, fds, setup); - } - - return ret; -} - static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) { @@ -544,16 +518,13 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, /* REVISIT: If both POLLIN and POLLOUT are set, might the following logic * fail? Could we not get POLLIN on the sink file and POLLOUT on the source * file? - * - * REVISIT: There is a file_poll() function, but it does not work in this - * context so the logic is implemented locally as my_file_poll(). */ /* POLLIN: Data other than high-priority data may be read without blocking. */ if ((fds->events & POLLIN) != 0) { - ret = my_file_poll(dev->pd_src, fds, setup); + ret = file_poll(dev->pd_src, fds, setup); } if (ret >= OK || ret == -ENOTTY) @@ -562,7 +533,7 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLOUT) != 0) { - ret = my_file_poll(dev->pd_sink, fds, setup); + ret = file_poll(dev->pd_sink, fds, setup); } } diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 924c5c83712..375267e11a1 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -243,6 +243,49 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count, * Public Functions ****************************************************************************/ +/**************************************************************************** + * Function: file_poll + * + * Description: + * Low-level poll operation based on struc file. This is used both to (1) + * support detached file, and also (2) by fdesc_poll() to perform all + * normal operations on file descriptors descriptors. + * + * Input Parameters: + * file File structure instance + * fds - The structure describing the events to be monitored, OR NULL if + * this is a request to stop monitoring events. + * setup - true: Setup up the poll; false: Teardown the poll + * + * Returned Value: + * 0: Success; Negated errno on failure + * + ****************************************************************************/ + +#if CONFIG_NFILE_DESCRIPTORS > 0 +int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) +{ + FAR struct inode *inode; + int ret = -ENOSYS; + + DEBUGASSERT(filep != NULL && filep->f_inode != NULL); + inode = filep->f_inode; + + /* Is a driver registered? Does it support the poll method? + * If not, return -ENOSYS + */ + + if (inode != NULL && inode->u.i_ops != NULL && inode->u.i_ops->poll != NULL) + { + /* Yes, it does... Setup the poll */ + + ret = (int)inode->u.i_ops->poll(filep, fds, setup); + } + + return ret; +} +#endif + /**************************************************************************** * Function: fdesc_poll * @@ -265,8 +308,6 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count, int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup) { FAR struct file *filep; - FAR struct inode *inode; - int ret = -ENOSYS; /* Get the file pointer corresponding to this file descriptor */ @@ -275,22 +316,14 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup) { /* The errno value has already been set */ - return -get_errno(); + int errorcode = get_errno(); + DEBUGASSERT(errcode > 0); + return -errcode; } - /* Is a driver registered? Does it support the poll method? - * If not, return -ENOSYS - */ + /* Let file_poll() do the rest */ - inode = filep->f_inode; - if (inode && inode->u.i_ops && inode->u.i_ops->poll) - { - /* Yes, then setup the poll */ - - ret = (int)inode->u.i_ops->poll(filep, fds, setup); - } - - return ret; + return file_poll(filep, fds, setup); } #endif diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index b9952a4eb87..5b6cfdc31eb 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -929,6 +929,29 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg); int file_vfcntl(FAR struct file *filep, int cmd, va_list ap); #endif +/**************************************************************************** + * Function: file_poll + * + * Description: + * Low-level poll operation based on struc file. This is used both to (1) + * support detached file, and also (2) by fdesc_poll() to perform all + * normal operations on file descriptors descriptors. + * + * Input Parameters: + * file File structure instance + * fds - The structure describing the events to be monitored, OR NULL if + * this is a request to stop monitoring events. + * setup - true: Setup up the poll; false: Teardown the poll + * + * Returned Value: + * 0: Success; Negated errno on failure + * + ****************************************************************************/ + +#if CONFIG_NFILE_DESCRIPTORS > 0 +int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); +#endif + /**************************************************************************** * Function: fdesc_poll * From d3b3c71d972144e80f43e125818df61bf5982f7a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 11:54:41 -0600 Subject: [PATCH 040/152] All architectures: Add logic to automatically register /dev/ptmx a boot time --- arch/arm/src/common/up_initialize.c | 35 ++++++++------ arch/avr/src/common/up_initialize.c | 24 ++++++++++ arch/hc/src/common/up_initialize.c | 24 ++++++++++ arch/mips/src/common/up_initialize.c | 24 ++++++++++ arch/rgmp/src/nuttx.c | 68 ++++++++++++++++++++++------ arch/rgmp/src/x86/arch_nuttx.c | 2 - arch/sh/src/common/up_initialize.c | 24 ++++++++++ arch/sim/src/up_initialize.c | 24 ++++++++++ arch/x86/src/common/up_initialize.c | 24 ++++++++++ arch/z16/src/common/up_initialize.c | 24 ++++++++++ arch/z80/src/common/up_initialize.c | 24 ++++++++++ 11 files changed, 265 insertions(+), 32 deletions(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 6b5117adf1b..6f0dc0bce78 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -228,22 +229,10 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the HW crypto and /dev/crypto */ +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ -#if defined(CONFIG_CRYPTO) - up_cryptoinitialize(); -#endif - -#if CONFIG_NFILE_DESCRIPTORS > 0 -#if defined(CONFIG_CRYPTO_CRYPTODEV) - devcrypto_register(); -#endif -#endif - - /* Initialize the Random Number Generator (RNG) */ - -#ifdef CONFIG_DEV_RANDOM - up_rnginitialize(); + (void)ptmx_register(); #endif /* Early initialization of the system logging device. Some SYSLOG channel @@ -253,6 +242,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 669821631c0..425b070d3c3 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -50,6 +50,8 @@ #include #include #include +#include +#include #include @@ -258,6 +260,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -265,6 +273,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index c5b1149d04a..51624646385 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include "up_arch.h" #include "up_internal.h" @@ -184,6 +186,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -191,6 +199,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index d6d634c9bc7..faa8edab970 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include @@ -186,6 +188,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -193,6 +201,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index 4a274264d7f..30824ccff02 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -45,14 +45,18 @@ #include #include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include + #include "task/task.h" #include "sched/sched.h" #include "group/group.h" @@ -85,23 +89,56 @@ static inline void up_switchcontext(struct tcb_s *ctcb, struct tcb_s *ntcb) void up_initialize(void) { - extern pidhash_t g_pidhash[]; - extern void vdev_init(void); - extern void nuttx_arch_init(void); + extern pidhash_t g_pidhash[]; + extern void vdev_init(void); + extern void nuttx_arch_init(void); - // initialize the current_task to g_idletcb - current_task = g_pidhash[PIDHASH(0)].tcb; + /* Initialize the current_task to g_idletcb */ - // OS memory alloc system is ready - use_os_kmalloc = 1; + current_task = g_pidhash[PIDHASH(0)].tcb; - // rgmp vdev init - vdev_init(); + /* OS memory alloc system is ready */ - nuttx_arch_init(); + use_os_kmalloc = 1; - // enable interrupt - local_irq_enable(); + /* rgmp vdev init */ + + vdev_init(); + + nuttx_arch_init(); + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ + + syslog_initialize(SYSLOG_INIT_EARLY); + +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + + /* Enable interrupt */ + + local_irq_enable(); } void up_idle(void) @@ -251,6 +288,7 @@ void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) * hold the blocked task TCB. * ****************************************************************************/ + void up_block_task(struct tcb_s *tcb, tstate_t task_state) { /* Verify that the context switch can be performed */ diff --git a/arch/rgmp/src/x86/arch_nuttx.c b/arch/rgmp/src/x86/arch_nuttx.c index d5ae6916862..32f919cd784 100644 --- a/arch/rgmp/src/x86/arch_nuttx.c +++ b/arch/rgmp/src/x86/arch_nuttx.c @@ -44,7 +44,6 @@ #include #include - void nuttx_arch_init(void) { extern void e1000_mod_init(void); @@ -57,7 +56,6 @@ void nuttx_arch_init(void) // setup e1000 e1000_mod_init(); #endif - } void nuttx_arch_exit(void) diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index c333f4b9939..6b62007d0bf 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include "up_arch.h" #include "up_internal.h" @@ -178,6 +180,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -185,6 +193,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index cb07619eabd..56f8f435aa7 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -52,6 +52,8 @@ #include #include #include +#include +#include #include "up_internal.h" @@ -168,6 +170,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -175,6 +183,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT) up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */ #endif diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 853304038bd..1d3270e3a3f 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include @@ -186,6 +188,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -193,6 +201,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index f6a020203aa..2bb5d7316eb 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include @@ -186,6 +188,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on only minimal OS initialization. @@ -193,6 +201,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 9684998ff36..3bd7c6e9abd 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -50,6 +50,8 @@ #include #include #include +#include +#include #include @@ -183,6 +185,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) + /* Register the master pseudo-terminal multiplexor device */ + + (void)ptmx_register(); +#endif + /* Early initialization of the system logging device. Some SYSLOG channel * can be initialized early in the initialization sequence because they * depend on minimal OS initialization. @@ -190,6 +198,22 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); +#if defined(CONFIG_CRYPTO) + /* Initialize the HW crypto and /dev/crypto */ + + up_cryptoinitialize(); +#endif + +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_CRYPTO_CRYPTODEV) + devcrypto_register(); +#endif + +#ifdef CONFIG_DEV_RANDOM + /* Initialize the Random Number Generator (RNG) */ + + up_rnginitialize(); +#endif + #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ From 7b298a828d340bde125945088ad21d3811665c0d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 13:11:28 -0600 Subject: [PATCH 041/152] up_pminitialize() needs to be called from instances of up_initialize() --- arch/arm/src/common/up_initialize.c | 5 +++-- arch/avr/src/common/up_initialize.c | 13 ++++++++++++- arch/hc/src/common/up_initialize.c | 13 ++++++++++++- arch/mips/src/common/up_initialize.c | 13 ++++++++++++- arch/rgmp/src/nuttx.c | 11 +++++++++++ arch/sh/src/common/up_initialize.c | 13 ++++++++++++- arch/sim/src/up_initialize.c | 13 ++++++++++++- arch/x86/src/common/up_initialize.c | 13 ++++++++++++- arch/z16/src/common/up_initialize.c | 15 +++++++++++++-- arch/z80/src/common/up_initialize.c | 15 +++++++++++++-- 10 files changed, 112 insertions(+), 12 deletions(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 6f0dc0bce78..973e2318f38 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -159,21 +160,21 @@ void up_initialize(void) up_irqinitialize(); +#ifdef CONFIG_PM /* Initialize the power management subsystem. This MCU-specific function * must be called *very* early in the initialization sequence *before* any * other device drivers are initialized (since they may attempt to register * with the power management subsystem). */ -#ifdef CONFIG_PM up_pminitialize(); #endif +#ifdef CONFIG_ARCH_DMA /* Initialize the DMA subsystem if the weak function up_dmainitialize has been * brought into the build */ -#ifdef CONFIG_ARCH_DMA #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (up_dmainitialize) #endif diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 425b070d3c3..d6df062b4b4 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -201,11 +202,21 @@ void up_initialize(void) up_irqinitialize(); +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + +#ifdef CONFIG_ARCH_DMA /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been * brought into the build */ -#ifdef CONFIG_ARCH_DMA #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (up_dmainitialize) #endif diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index 51624646385..881f8abd719 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "up_arch.h" #include "up_internal.h" @@ -127,11 +128,21 @@ void up_initialize(void) up_irqinitialize(); +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + +#ifdef CONFIG_ARCH_DMA /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been * brought into the build */ -#ifdef CONFIG_ARCH_DMA #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (up_dmainitialize) #endif diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index faa8edab970..185b475e1da 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -129,11 +130,21 @@ void up_initialize(void) up_irqinitialize(); +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + +#ifdef CONFIG_ARCH_DMA /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been * brought into the build */ -#ifdef CONFIG_ARCH_DMA #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (up_dmainitialize) #endif diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index 30824ccff02..ee6148e35e5 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -56,6 +56,7 @@ #include #include #include +#include #include "task/task.h" #include "sched/sched.h" @@ -107,6 +108,16 @@ void up_initialize(void) nuttx_arch_init(); +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + #if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_PSEUDOTERM_SUSV1) /* Register the master pseudo-terminal multiplexor device */ diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index 6b62007d0bf..c4389936555 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "up_arch.h" #include "up_internal.h" @@ -131,9 +132,19 @@ void up_initialize(void) up_irqinitialize(); - /* Initialize the system timer interrupt */ +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif #if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS) + /* Initialize the system timer interrupt */ + up_timer_initialize(); #endif diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 56f8f435aa7..5df82aec955 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "up_internal.h" @@ -126,15 +127,25 @@ static void up_init_smartfs(void) void up_initialize(void) { +#ifdef CONFIG_NET /* The real purpose of the following is to make sure that syslog * is drawn into the link. It is needed by up_tapdev which is linked * separately. */ -#ifdef CONFIG_NET syslog(LOG_INFO, "SIM: Initializing"); #endif +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + #if CONFIG_NFILE_DESCRIPTORS > 0 /* Register devices */ diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 1d3270e3a3f..6a9eca8d5ae 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -129,11 +130,21 @@ void up_initialize(void) up_irqinitialize(); +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif + +#ifdef CONFIG_ARCH_DMA /* Initialize the DMA subsystem if the weak function up_dmainitialize has been * brought into the build */ -#ifdef CONFIG_ARCH_DMA #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (up_dmainitialize) #endif diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 2bb5d7316eb..3f375763bd6 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -132,9 +133,9 @@ void up_initialize(void) up_calibratedelay(); +#if CONFIG_MM_REGIONS > 1 /* Add any extra memory fragments to the memory manager */ -#if CONFIG_MM_REGIONS > 1 up_addregion(); #endif @@ -142,9 +143,19 @@ void up_initialize(void) up_irqinitialize(); - /* Initialize the system timer interrupt */ +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif #if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS) + /* Initialize the system timer interrupt */ + up_timer_initialize(); #endif diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 3bd7c6e9abd..760f6c74a95 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -121,9 +122,9 @@ void up_initialize(void) up_calibratedelay(); +#if CONFIG_MM_REGIONS > 1 /* Add any extra memory fragments to the memory manager */ -#if CONFIG_MM_REGIONS > 1 up_addregion(); #endif @@ -131,9 +132,19 @@ void up_initialize(void) up_irqinitialize(); - /* Initialize the system timer interrupt */ +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + up_pminitialize(); +#endif #if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS) + /* Initialize the system timer interrupt */ + up_timer_initialize(); #endif From e7f0a564986a824e9659b5534fef00888472997e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 13:13:53 -0600 Subject: [PATCH 042/152] Correct some comments --- arch/avr/src/common/up_initialize.c | 2 +- arch/hc/src/common/up_initialize.c | 2 +- arch/mips/src/common/up_initialize.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index d6df062b4b4..4ac08dfd0b6 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -213,7 +213,7 @@ void up_initialize(void) #endif #ifdef CONFIG_ARCH_DMA - /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been + /* Initialize the DMA subsystem if the weak function up_dmainitialize has been * brought into the build */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index 881f8abd719..a0173046476 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -139,7 +139,7 @@ void up_initialize(void) #endif #ifdef CONFIG_ARCH_DMA - /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been + /* Initialize the DMA subsystem if the weak function up_dmainitialize has been * brought into the build */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 185b475e1da..940b3672e19 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -141,7 +141,7 @@ void up_initialize(void) #endif #ifdef CONFIG_ARCH_DMA - /* Initialize the DMA subsystem if the weak function stm32_dmainitialize has been + /* Initialize the DMA subsystem if the weak function up_dmainitialize has been * brought into the build */ From 4b5149b244d8a9f13d18880668671ab0aa8556da Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 14:09:02 -0600 Subject: [PATCH 043/152] PTY: Fix a few errors from early testing --- drivers/serial/ptmx.c | 12 +++++++++--- drivers/serial/pty.c | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index ce332841890..2099328a5a1 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -226,7 +226,13 @@ static int ptmx_open(FAR struct file *filep) goto errout_with_sem; } - /* Create the master slave pair */ + /* Create the master slave pair. This should create: + * + * Slave device: /dev/pts/N + * Master device: /dev/ptyN + * + * Where N=minor + */ ret = pty_register(minor); if (ret < 0) @@ -234,9 +240,9 @@ static int ptmx_open(FAR struct file *filep) goto errout_with_minor; } - /* Open the master side */ + /* Open the master device: /dev/ptyN, where N=minor */ - snprintf(devname, 16, "/dev/ttyp%d", minor); + snprintf(devname, 16, "/dev/pty%d", minor); fd = open(devname, O_RDWR); DEBUGASSERT(fd >= 0); /* open() should never fail */ diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index ad6d95ac0ca..f55dbddf650 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -111,7 +111,7 @@ struct pty_devpair_s * Private Data ****************************************************************************/ -static const struct file_operations pty_fops = +static const struct file_operations g_pty_fops = { #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS pty_open, /* open */ @@ -691,7 +691,7 @@ int pty_register(int minor) snprintf(devname, 16, "/dev/pts/%d", minor); #endif - ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_slave); + ret = register_driver(devname, &g_pty_fops, 0666, &devpair->pp_slave); if (ret < 0) { goto errout_with_pipeb; @@ -707,7 +707,7 @@ int pty_register(int minor) snprintf(devname, 16, "/dev/pty%d", minor); - ret = register_driver(devname, &pty_fops, 0666, &devpair->pp_master); + ret = register_driver(devname, &g_pty_fops, 0666, &devpair->pp_master); if (ret < 0) { goto errout_with_slave; From 4b1553d3ad8a640af057bd728a66ea59881bdb24 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 14:29:32 -0600 Subject: [PATCH 044/152] PTY: Fix some tricky issues. Now seems to be working. A lot more testing is needed --- drivers/serial/Kconfig | 1 - drivers/serial/pty.c | 7 ++++++- fs/vfs/fs_open.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 68a8d597397..ad738a4824b 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2015,7 +2015,6 @@ endmenu # SCI1 Configuration config PSEUDOTERM bool "Pseudo-Terminal (PTY) suppport" default n - depends on EXPERIMENTAL ---help--- Enable support support for master and slave pseudo-terminal devices. diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index f55dbddf650..ec2db0002e7 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -263,8 +263,12 @@ static int pty_open(FAR struct file *filep) pty_semtake(devpair); } +#ifndef CONFIG_PSEUDOTERM_SUSV1 /* If one side of the driver has been unlinked, then refuse further * opens. + * + * NOTE: We ignore this case in the SUSv1 case. In the SUSv1 case, the + * master side is always unlinked. */ if (devpair->pp_unlinked) @@ -272,6 +276,7 @@ static int pty_open(FAR struct file *filep) ret = -EIDRM; } else +#endif { /* Increment the count of open references on the driver */ @@ -505,7 +510,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) #ifndef CONFIG_DISABLE_POLL static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup) + bool setup) { FAR struct inode *inode; FAR struct pty_dev_s *dev; diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 81a2ef7f7cc..462aac6734e 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -233,6 +233,34 @@ int open(const char *path, int oflags, ...) goto errout_with_fd; } +#ifdef CONFIG_PSEUDOTERM_SUSV1 + /* If the return value from the open method is > 0, then we may assume that + * it is actually a file descriptor. This kind of logic is only needed for + * /dev/ptmx: When dev ptmx is opened, it does not return a file descriptor + * associated with the /dev/ptmx inode, but rather with the master device. + * + * REVISIT: This is a kludge. It is dangerous because (1) Zero is also a + * valid file descriptor, and (2) there could potentially be driver open + * methods that return values > 0 for normal success conditions. + */ + + if (ret > 0) + { + /* Release file descriptor and inode that we allocated. We don't + * need those. + */ + + files_release(fd); + inode_release(inode); + + /* Instead, return the descriptor associated with the master side + * device. + */ + + fd = ret; + } +#endif + return fd; errout_with_fd: From e7f31cc96789e467da7811d0450eb980aa83d422 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 14:58:20 -0600 Subject: [PATCH 045/152] Freedom-K64F: Enable built-in applications in all configurations --- configs/freedom-k64f/README.txt | 12 +++++++++--- configs/freedom-k64f/netnsh/defconfig | 13 ++++++++++--- configs/freedom-k64f/nsh/defconfig | 12 ++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 8814e0cb9a7..2c6608c8467 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -855,13 +855,16 @@ Where is one of the following: 4. SDHC support is not enabled in this configuration. Refer to the configuration settings listed above under "SD Card Support". - 5. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU + 5. Support for NSH built-in applications is enabled, but no built-in + applications have been configured in. + + 6. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU is requests status of the Ethernet link connection. Internal pullup is required when port configuration for MDIO signal is enabled: CONFIG_KINETIS_ENET_MDIOPULLUP=y - 6. Configured to use a fixed IPv4 address: + 7. Configured to use a fixed IPv4 address: CONFIG_NSH_IPADDR=0x0a000002 CONFIG_NSH_DRIPADDR=0x0a000001 @@ -899,7 +902,10 @@ Where is one of the following: 3. The Serial Console is provided on UART3 with the correct pin configuration for use with an Arduino Serial Shield. - 4. An SDHC driver is enabled in this configuration but does not yet work. + 4. Support for NSH built-in applications is enabled, but no built-in + applications have been configured in. + + 5. An SDHC driver is enabled in this configuration but does not yet work. The basic problem seems to be that it does not sense the presence of the SD card on PTE6. No interrupts are generated when the SD card is inserted or removed. You might want to disable SDHC and MMC/SD if diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index bb0ee7a5817..b9a711363f5 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -603,6 +603,7 @@ CONFIG_UART3_2STOP=0 # CONFIG_UART3_IFLOWCONTROL is not set # CONFIG_UART3_OFLOWCONTROL is not set # CONFIG_UART3_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set # CONFIG_HAVE_USBTRACE is not set @@ -772,6 +773,7 @@ CONFIG_FS_FAT=y # CONFIG_FS_ROMFS is not set # CONFIG_FS_TMPFS is not set # CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y @@ -813,7 +815,7 @@ CONFIG_MM_REGIONS=1 # CONFIG_BINFMT_EXEPATH is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set -# CONFIG_BUILTIN is not set +CONFIG_BUILTIN=y # CONFIG_PIC is not set # CONFIG_SYMTAB_ORDEREDBYNAME is not set @@ -883,6 +885,11 @@ CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0a000001 # Application Configuration # +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + # # CAN Utilities # @@ -922,7 +929,6 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_OSTEST is not set # CONFIG_EXAMPLES_PCA9635 is not set # CONFIG_EXAMPLES_PIPE is not set -# CONFIG_EXAMPLES_POLL is not set # CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_PPPD is not set # CONFIG_EXAMPLES_RGBLED is not set @@ -933,6 +939,7 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_SERLOOP is not set # CONFIG_EXAMPLES_SLCD is not set # CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set # CONFIG_EXAMPLES_SMP is not set # CONFIG_EXAMPLES_TCPECHO is not set # CONFIG_EXAMPLES_TELNETD is not set @@ -944,7 +951,6 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set -# CONFIG_EXAMPLES_WGET is not set # # File System Utilities @@ -1016,6 +1022,7 @@ CONFIG_NSH_MAXARGUMENTS=6 CONFIG_NSH_ARGCAT=y CONFIG_NSH_NESTDEPTH=3 # CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y # # Disable Individual commands diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 347552c2ed8..c87eee1940d 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -572,6 +572,7 @@ CONFIG_UART3_2STOP=0 # CONFIG_UART3_IFLOWCONTROL is not set # CONFIG_UART3_OFLOWCONTROL is not set # CONFIG_UART3_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set # CONFIG_HAVE_USBTRACE is not set @@ -630,6 +631,7 @@ CONFIG_FAT_MAXFNAME=32 # CONFIG_FS_ROMFS is not set # CONFIG_FS_TMPFS is not set # CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y @@ -670,7 +672,7 @@ CONFIG_MM_REGIONS=1 # CONFIG_BINFMT_EXEPATH is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set -# CONFIG_BUILTIN is not set +CONFIG_BUILTIN=y # CONFIG_PIC is not set # CONFIG_SYMTAB_ORDEREDBYNAME is not set @@ -731,6 +733,11 @@ CONFIG_ARCH_HAVE_TLS=y # Application Configuration # +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + # # CAN Utilities # @@ -768,7 +775,6 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_OSTEST is not set # CONFIG_EXAMPLES_PCA9635 is not set # CONFIG_EXAMPLES_PIPE is not set -# CONFIG_EXAMPLES_POLL is not set # CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_PPPD is not set # CONFIG_EXAMPLES_RGBLED is not set @@ -779,6 +785,7 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_SERLOOP is not set # CONFIG_EXAMPLES_SLCD is not set # CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set # CONFIG_EXAMPLES_SMP is not set # CONFIG_EXAMPLES_TCPECHO is not set # CONFIG_EXAMPLES_TELNETD is not set @@ -846,6 +853,7 @@ CONFIG_NSH_MAXARGUMENTS=6 CONFIG_NSH_ARGCAT=y CONFIG_NSH_NESTDEPTH=3 # CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y # # Disable Individual commands From c57672aeaba85824b3be6503922e5d01128f2eab Mon Sep 17 00:00:00 2001 From: Heath Petersen Date: Fri, 15 Jul 2016 17:50:00 -0500 Subject: [PATCH 046/152] EXEEXT only needs to be appended once --- arch/x86/src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/src/Makefile b/arch/x86/src/Makefile index 16fbc8206c1..a2d07ac0359 100644 --- a/arch/x86/src/Makefile +++ b/arch/x86/src/Makefile @@ -148,10 +148,10 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx$(EXEEXT)" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) $(NM) $(NUTTX)$(EXEEXT) | \ + $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(TOPDIR)/System.map endif From 6a75f2df89d2224f4206d3ab807268acaf73a0ac Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 17:13:04 -0600 Subject: [PATCH 047/152] PTY: Add some encode to reduce the likely of misinterpreting the return value of the file open() method --- drivers/serial/ptmx.c | 5 +++-- fs/vfs/fs_open.c | 24 +++++++++++++----------- include/nuttx/fs/fs.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index 2099328a5a1..dd6bd9fd3c5 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -255,10 +255,11 @@ static int ptmx_open(FAR struct file *filep) DEBUGASSERT(ret >= 0); /* unlink() should never fail */ UNUSED(ret); - /* Return the master file descriptor */ + /* Return the encoded, master file descriptor */ ptmx_semgive(); - return fd; + DEBUGASSERT((unsigned)fd <= OPEN_MAXFD); + return (int)OPEN_SETFD(fd); errout_with_minor: ptmx_minor_free(minor); diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 462aac6734e..08a3f24f647 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -234,17 +234,19 @@ int open(const char *path, int oflags, ...) } #ifdef CONFIG_PSEUDOTERM_SUSV1 - /* If the return value from the open method is > 0, then we may assume that - * it is actually a file descriptor. This kind of logic is only needed for - * /dev/ptmx: When dev ptmx is opened, it does not return a file descriptor - * associated with the /dev/ptmx inode, but rather with the master device. + /* If the return value from the open method is > 0, then it may actually + * be an encoded file descriptor. This kind of logic is currently only + * needed for /dev/ptmx: When dev ptmx is opened, it does not return a + * file descriptor associated with the /dev/ptmx inode, but rather with + * the inode of master device created by the /dev/ptmx open method. * - * REVISIT: This is a kludge. It is dangerous because (1) Zero is also a - * valid file descriptor, and (2) there could potentially be driver open - * methods that return values > 0 for normal success conditions. + * The encoding supports (a) returning file descriptor 0 (which really + * should not happen), and (b) avoiding confusion if some other open + * method returns a positive, non-zero value which is not a file + * descriptor. */ - if (ret > 0) + if (OPEN_ISFD(ret)) { /* Release file descriptor and inode that we allocated. We don't * need those. @@ -253,11 +255,11 @@ int open(const char *path, int oflags, ...) files_release(fd); inode_release(inode); - /* Instead, return the descriptor associated with the master side - * device. + /* Instead, decode and return the descriptor associated with the + * master side device. */ - fd = ret; + fd = (int)OPEN_GETFD(ret); } #endif diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 5b6cfdc31eb..03f62f976a6 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -111,6 +111,35 @@ #define DIRENT_SETPSEUDONODE(f) do (f) |= DIRENTFLAGS_PSEUDONODE; while (0) #define DIRENT_ISPSEUDONODE(f) (((f) & DIRENTFLAGS_PSEUDONODE) != 0) +/* The struct file_operations open(0) normally returns zero on success and + * a negated errno value on failure. There is one case, however, where + * the open method will redirect to another driver and return a file + * descriptor instead. + * + * This case is when SUSv1 pseudo-terminals are used (CONFIG_PSEUDOTERM_SUSV1=y). + * In this case, the output is encoded and decoded using these macros in + * order to support (a) returning file descriptor 0 (which really should + * not happen), and (b) avoiding confusion if some other open method returns + * a positive, non-zero value which is not a file descriptor. + * + * OPEN_ISFD(r) tests if the return value from the open method is + * really a file descriptor. + * OPEN_SETFD(f) is used by an implementation of the open() method + * in order to encode a file descriptor in the return value. + * OPEN_GETFD(r) is use by the upper level open() logic to decode + * the file descriptor encoded in the return value. + * + * REVISIT: This only works for file descriptors in the in range 0-255. + */ + +#define OPEN_MAGIC 0x4200 +#define OPEN_MASK 0x00ff +#define OPEN_MAXFD 0x00ff + +#define OPEN_ISFD(r) (((r) & ~OPEN_MASK) == OPEN_MAGIC) +#define OPEN_SETFD(f) ((f) | OPEN_MAGIC) +#define OPEN_GETFD(r) ((r) & OPEN_MASK) + /**************************************************************************** * Public Type Definitions ****************************************************************************/ From bcb6095f1f98fb641ff8f8f310fa7970d7e55803 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 15 Jul 2016 17:47:00 -0600 Subject: [PATCH 048/152] Add an assertion --- fs/vfs/fs_open.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 08a3f24f647..a66f62e869a 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -260,6 +260,7 @@ int open(const char *path, int oflags, ...) */ fd = (int)OPEN_GETFD(ret); + DEBUGASSERT((unsigned)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)); } #endif From 11fe9378df195361158c0071ab4f50496e0f6c5b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 16 Jul 2016 07:02:06 -0600 Subject: [PATCH 049/152] Fix some warnings --- fs/vfs/fs_epoll.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 47500d01f32..6678ae10f21 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -44,10 +44,11 @@ #include #include #include -#include #include #include +#include + #ifndef CONFIG_DISABLE_POLL /**************************************************************************** @@ -68,13 +69,17 @@ int epoll_create(int size) { FAR struct epoll_head *eph = - (FAR struct epoll_head *)malloc(sizeof(struct epoll_head)); + (FAR struct epoll_head *)kmm_malloc(sizeof(struct epoll_head)); eph->size = size; eph->occupied = 0; - eph->evs = malloc(sizeof(struct epoll_event) * eph->size); + eph->evs = kmm_malloc(sizeof(struct epoll_event) * eph->size); - return (int)eph; + /* REVISIT: This will not work on machines where: + * sizeof(struct epoll_head *) > sizeof(int) + */ + + return (int)((intptr_t)eph); } /**************************************************************************** @@ -90,10 +95,14 @@ int epoll_create(int size) void epoll_close(int epfd) { - struct epoll_head *eph = (struct epoll_head *)epfd; + /* REVISIT: This will not work on machines where: + * sizeof(struct epoll_head *) > sizeof(int) + */ - free(eph->evs); - free(eph); + FAR struct epoll_head *eph = (FAR struct epoll_head *)((intptr_t)epfd); + + kmm_free(eph->evs); + kmm_free(eph); } /**************************************************************************** @@ -109,7 +118,11 @@ void epoll_close(int epfd) int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) { - FAR struct epoll_head *eph = (FAR struct epoll_head *)epfd; + /* REVISIT: This will not work on machines where: + * sizeof(struct epoll_head *) > sizeof(int) + */ + + FAR struct epoll_head *eph = (FAR struct epoll_head *)((intptr_t)epfd); switch (op) { @@ -180,9 +193,13 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout) { - int i; + /* REVISIT: This will not work on machines where: + * sizeof(struct epoll_head *) > sizeof(int) + */ + + FAR struct epoll_head *eph = (FAR struct epoll_head *)((intptr_t)epfd); int rc; - FAR struct epoll_head *eph = (FAR struct epoll_head *)epfd; + int i; rc = poll((FAR struct pollfd *)eph->evs, eph->occupied, timeout); From 8fa14b8fedd14702adac2d9ab436c0f9924b0bcf Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Sat, 16 Jul 2016 07:03:38 -0600 Subject: [PATCH 050/152] Fix poll-related compile issues introduced with recent PTY changes --- drivers/serial/pty.c | 4 ++-- fs/vfs/fs_poll.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index ec2db0002e7..69fc6de8b43 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -529,7 +529,7 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) != 0) { - ret = file_poll(dev->pd_src, fds, setup); + ret = file_poll(&dev->pd_src, fds, setup); } if (ret >= OK || ret == -ENOTTY) @@ -538,7 +538,7 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLOUT) != 0) { - ret = file_poll(dev->pd_sink, fds, setup); + ret = file_poll(&dev->pd_sink, fds, setup); } } diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 375267e11a1..605147ec7f6 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -317,8 +317,8 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup) /* The errno value has already been set */ int errorcode = get_errno(); - DEBUGASSERT(errcode > 0); - return -errcode; + DEBUGASSERT(errorcode > 0); + return -errorcode; } /* Let file_poll() do the rest */ From ded91e451ba184897b2ed954ffe259f28e0c8ac0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 16 Jul 2016 10:43:44 -0600 Subject: [PATCH 051/152] PTY: Add TERMIOS support. --- drivers/serial/Kconfig | 1 + drivers/serial/pty.c | 193 +++++++++++++++++++++++++++++++++- include/nuttx/serial/serial.h | 2 +- 3 files changed, 193 insertions(+), 3 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ad738a4824b..ad1a503ac75 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2015,6 +2015,7 @@ endmenu # SCI1 Configuration config PSEUDOTERM bool "Pseudo-Terminal (PTY) suppport" default n + select ARCH_HAVE_SERIAL_TERMIOS ---help--- Enable support support for master and slave pseudo-terminal devices. diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 69fc6de8b43..cda35f9912c 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,13 @@ struct pty_dev_s struct file pd_src; /* Provides data to read() method (pipe output) */ struct file pd_sink; /* Accepts data from write() method (pipe input) */ bool pd_master; /* True: this is the master */ + +#ifdef CONFIG_SERIAL_TERMIOS + /* Terminal control flags */ + + tcflag_t pd_iflag; /* Terminal nput modes */ + tcflag_t pd_oflag; /* Terminal output modes */ +#endif }; /* This structure describes the pipe pair */ @@ -229,6 +237,12 @@ static int pty_open(FAR struct file *filep) sched_lock(); while (devpair->pp_locked) { + /* REVISIT: Should no block if the oflags include O_NONBLOCK. + * Also, how wouldwbe ripple the O_NONBLOCK characteristic + * to the contained drivers? And how would we change the + * O_NONBLOCK characteristic if it is changed via fcntl? + */ + /* Wait until unlocked. We will also most certainly suspend here. */ sem_wait(&devpair->pp_slavesem); @@ -358,13 +372,80 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) { FAR struct inode *inode; FAR struct pty_dev_s *dev; + ssize_t ntotal; +#ifdef CONFIG_SERIAL_TERMIOS + ssize_t nread; + size_t i; + char ch; +#endif DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); - return file_read(&dev->pd_src, buffer, len); +#ifdef CONFIG_SERIAL_TERMIOS + /* Do input processing if any is enabled + * + * Specifically not handled: + * + * All of the local modes; echo, line editing, etc. + * Anything to do with break or parity errors. + * ISTRIP - We should be 8-bit clean. + * IUCLC - Not Posix + * IXON/OXOFF - No xon/xoff flow control. + */ + + if (dev->pd_iflag & (INLCR | IGNCR | ICRNL)) + { + /* We will transfer one byte at a time, making the appropriae + * translations. + */ + + ntotal = 0; + for (i = 0; i < len; i++) + { + ch = *buffer++; + + /* \n -> \r or \r -> \n translation? */ + + if (ch == '\n' && (dev->pd_iflag & INLCR) != 0) + { + ch = '\r'; + } + else if (ch == '\r' && (dev->pd_iflag & ICRNL) != 0) + { + ch = '\n'; + } + + /* Discarding \r ? Print character if (1) character is not \r or + * if (2) we were not asked to ignore \r. + */ + + if (ch != '\r' || (dev->pd_iflag & IGNCR) == 0) + { + /* Transfer the byte */ + + nread = file_read(&dev->pd_src, &ch, 1); + if (nread < 0) + { + ntotal = nread; + break; + } + + /* Update the count of bytes transferred */ + + ntotal++; + } + } + } + else +#endif + { + ntotal = file_read(&dev->pd_src, buffer, len); + } + + return ntotal; } /**************************************************************************** @@ -375,13 +456,85 @@ static ssize_t pty_write(FAR struct file *filep, FAR const char *buffer, size_t { FAR struct inode *inode; FAR struct pty_dev_s *dev; + ssize_t ntotal; +#ifdef CONFIG_SERIAL_TERMIOS + ssize_t nwritten; + size_t i; + char ch; +#endif DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); - return file_write(&dev->pd_sink, buffer, len); +#ifdef CONFIG_SERIAL_TERMIOS + /* Do output post-processing */ + + if ((dev->pd_oflag & OPOST) != 0) + { + /* We will transfer one byte at a time, making the appropriae + * translations. Specifically not handled: + * + * OXTABS - primarily a full-screen terminal optimisation + * ONOEOT - Unix interoperability hack + * OLCUC - Not specified by POSIX + * ONOCR - low-speed interactive optimisation + */ + + ntotal = 0; + for (i = 0; i < len; i++) + { + ch = *buffer++; + + /* Mapping CR to NL? */ + + if (ch == '\r' && (dev->pd_oflag & OCRNL) != 0) + { + ch = '\n'; + } + + /* Are we interested in newline processing? */ + + if ((ch == '\n') && (dev->pd_oflag & (ONLCR | ONLRET)) != 0) + { + char cr = '\r'; + + /* Transfer the carriage return */ + + nwritten = file_write(&dev->pd_sink, &cr, 1); + if (nwritten < 0) + { + ntotal = nwritten; + break; + } + + /* Update the count of bytes transferred */ + + ntotal++; + } + + /* Transfer the (possibly translated) character. */ + + nwritten = file_write(&dev->pd_sink, &ch, 1); + if (nwritten < 0) + { + ntotal = nwritten; + break; + } + + /* Update the count of bytes transferred */ + + ntotal++; + } + } + else +#endif + { + ntotal = file_write(&dev->pd_sink, buffer, len); + } + + return ntotal; } /**************************************************************************** @@ -485,6 +638,42 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; +#ifdef CONFIG_SERIAL_TERMIOS + case TCGETS: + { + FAR struct termios *termiosp = (FAR struct termios *)arg; + + if (!termiosp) + { + ret = -EINVAL; + break; + } + + /* And update with flags from this layer */ + + termiosp->c_iflag = dev->pd_iflag; + termiosp->c_oflag = dev->pd_oflag; + termiosp->c_lflag = 0; + } + break; + + case TCSETS: + { + FAR struct termios *termiosp = (FAR struct termios *)arg; + + if (!termiosp) + { + ret = -EINVAL; + break; + } + + /* Update the flags we keep at this layer */ + + dev->pd_iflag = termiosp->c_iflag; + dev->pd_oflag = termiosp->c_oflag; + } + break; +#endif /* Any unrecognized IOCTL commands will be passed to the contained * pipe driver. */ diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h index 493c0d53bad..a5a29f25690 100644 --- a/include/nuttx/serial/serial.h +++ b/include/nuttx/serial/serial.h @@ -280,9 +280,9 @@ struct uart_dev_s #endif bool isconsole; /* true: This is the serial console */ +#ifdef CONFIG_SERIAL_TERMIOS /* Terminal control flags */ -#ifdef CONFIG_SERIAL_TERMIOS tcflag_t tc_iflag; /* Input modes */ tcflag_t tc_oflag; /* Output modes */ tcflag_t tc_lflag; /* Local modes */ From 8710b56670879218c355fa89fe88a4eea744cee7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 16 Jul 2016 11:30:43 -0600 Subject: [PATCH 052/152] STM32F4 Discovery: Add a pseudo-terminal example --- configs/stm32f4discovery/README.txt | 12 + configs/stm32f4discovery/include/board.h | 5 + configs/stm32f4discovery/pseudoterm/Make.defs | 113 ++ configs/stm32f4discovery/pseudoterm/defconfig | 1220 +++++++++++++++++ configs/stm32f4discovery/pseudoterm/setenv.sh | 80 ++ 5 files changed, 1430 insertions(+) create mode 100644 configs/stm32f4discovery/pseudoterm/Make.defs create mode 100644 configs/stm32f4discovery/pseudoterm/defconfig create mode 100644 configs/stm32f4discovery/pseudoterm/setenv.sh diff --git a/configs/stm32f4discovery/README.txt b/configs/stm32f4discovery/README.txt index 430f78c9134..2b1bb2501fa 100644 --- a/configs/stm32f4discovery/README.txt +++ b/configs/stm32f4discovery/README.txt @@ -1934,6 +1934,18 @@ Where is one of the following: 3. By default, this project assumes that you are *NOT* using the DFU bootloader. + pseudoterm: + ----------- + + This is a configuration to test the Pseudo Terminal support for NuttX. + + To test it you will need two USB/Serial dongles. The first dongle as + usual will be used to main NSH console port in UART2 (PA2 and PA3) and + the second dongle you will connect to UART3 (PB10 and PB11). + + In the main NSH console (in UART2) type: "pts_test &". It will create a + new console in UART3. Just press ENTER and start typing commands on it. + rgbled: ------- diff --git a/configs/stm32f4discovery/include/board.h b/configs/stm32f4discovery/include/board.h index 10cc583ab01..805d5f6ce12 100644 --- a/configs/stm32f4discovery/include/board.h +++ b/configs/stm32f4discovery/include/board.h @@ -267,6 +267,11 @@ # define GPIO_USART2_TX GPIO_USART2_TX_1 #endif +/* UART3: (Used in pseudoterm configuration) */ + +#define GPIO_USART3_TX GPIO_USART3_TX_1 +#define GPIO_USART3_RX GPIO_USART3_RX_1 + /* UART6: * * The STM32F4DIS-BB base board provides RS-232 drivers and a DB9 connector diff --git a/configs/stm32f4discovery/pseudoterm/Make.defs b/configs/stm32f4discovery/pseudoterm/Make.defs new file mode 100644 index 00000000000..d1dd82ebf0b --- /dev/null +++ b/configs/stm32f4discovery/pseudoterm/Make.defs @@ -0,0 +1,113 @@ +############################################################################ +# configs/stm32f4discovery/pseudoterm/Make.defs +# +# Copyright (C) 2016 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 +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +LDSCRIPT = ld.script + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.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)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/configs/stm32f4discovery/pseudoterm/defconfig b/configs/stm32f4discovery/pseudoterm/defconfig new file mode 100644 index 00000000000..7911dcfda8c --- /dev/null +++ b/configs/stm32f4discovery/pseudoterm/defconfig @@ -0,0 +1,1220 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +CONFIG_EXPERIMENTAL=y +# CONFIG_DEFAULT_SMALL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +CONFIG_INTELHEX_BINARY=y +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +# CONFIG_DEBUG_FEATURES is not set +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set +CONFIG_ARCH_HAVE_HEAPCHECK=y +# CONFIG_HEAP_COLORATION is not set +# CONFIG_DEBUG_SYMBOLS is not set +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# System Type +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_RGMP is not set +# CONFIG_ARCH_SH is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" + +# +# ARM Options +# +# CONFIG_ARCH_CHIP_A1X is not set +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_EFM32 is not set +# CONFIG_ARCH_CHIP_IMX1 is not set +# CONFIG_ARCH_CHIP_IMX6 is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_KL is not set +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set +# CONFIG_ARCH_CHIP_LPC11XX is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_NUC1XX is not set +# CONFIG_ARCH_CHIP_SAMA5 is not set +# CONFIG_ARCH_CHIP_SAMD is not set +# CONFIG_ARCH_CHIP_SAML is not set +# CONFIG_ARCH_CHIP_SAM34 is not set +# CONFIG_ARCH_CHIP_SAMV7 is not set +CONFIG_ARCH_CHIP_STM32=y +# CONFIG_ARCH_CHIP_STM32F7 is not set +# CONFIG_ARCH_CHIP_STM32L4 is not set +# CONFIG_ARCH_CHIP_STR71X is not set +# CONFIG_ARCH_CHIP_TMS570 is not set +# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_ARM7TDMI is not set +# CONFIG_ARCH_ARM926EJS is not set +# CONFIG_ARCH_ARM920T is not set +# CONFIG_ARCH_CORTEXM0 is not set +# CONFIG_ARCH_CORTEXM3 is not set +CONFIG_ARCH_CORTEXM4=y +# CONFIG_ARCH_CORTEXM7 is not set +# CONFIG_ARCH_CORTEXA5 is not set +# CONFIG_ARCH_CORTEXA8 is not set +# CONFIG_ARCH_CORTEXA9 is not set +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_CORTEXR4F is not set +# CONFIG_ARCH_CORTEXR5 is not set +# CONFIG_ARCH_CORTEX5F is not set +# CONFIG_ARCH_CORTEXR7 is not set +# CONFIG_ARCH_CORTEXR7F is not set +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="stm32" +# CONFIG_ARM_TOOLCHAIN_IAR is not set +CONFIG_ARM_TOOLCHAIN_GNU=y +# CONFIG_ARMV7M_USEBASEPRI is not set +CONFIG_ARCH_HAVE_CMNVECTOR=y +# CONFIG_ARMV7M_CMNVECTOR is not set +# CONFIG_ARMV7M_LAZYFPU is not set +CONFIG_ARCH_HAVE_FPU=y +# CONFIG_ARCH_HAVE_DPFPU is not set +# CONFIG_ARCH_FPU is not set +# CONFIG_ARCH_HAVE_TRUSTZONE is not set +CONFIG_ARM_HAVE_MPU_UNIFIED=y +# CONFIG_ARM_MPU is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_HAVE_ICACHE is not set +# CONFIG_ARMV7M_HAVE_DCACHE is not set +# CONFIG_ARMV7M_HAVE_ITCM is not set +# CONFIG_ARMV7M_HAVE_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y +CONFIG_ARMV7M_HAVE_STACKCHECK=y +# CONFIG_ARMV7M_STACKCHECK is not set +# CONFIG_ARMV7M_ITMSYSLOG is not set +# CONFIG_SERIAL_TERMIOS is not set + +# +# STM32 Configuration Options +# +# CONFIG_ARCH_CHIP_STM32L151C6 is not set +# CONFIG_ARCH_CHIP_STM32L151C8 is not set +# CONFIG_ARCH_CHIP_STM32L151CB is not set +# CONFIG_ARCH_CHIP_STM32L151R6 is not set +# CONFIG_ARCH_CHIP_STM32L151R8 is not set +# CONFIG_ARCH_CHIP_STM32L151RB is not set +# CONFIG_ARCH_CHIP_STM32L151V6 is not set +# CONFIG_ARCH_CHIP_STM32L151V8 is not set +# CONFIG_ARCH_CHIP_STM32L151VB is not set +# CONFIG_ARCH_CHIP_STM32L152C6 is not set +# CONFIG_ARCH_CHIP_STM32L152C8 is not set +# CONFIG_ARCH_CHIP_STM32L152CB is not set +# CONFIG_ARCH_CHIP_STM32L152R6 is not set +# CONFIG_ARCH_CHIP_STM32L152R8 is not set +# CONFIG_ARCH_CHIP_STM32L152RB is not set +# CONFIG_ARCH_CHIP_STM32L152V6 is not set +# CONFIG_ARCH_CHIP_STM32L152V8 is not set +# CONFIG_ARCH_CHIP_STM32L152VB is not set +# CONFIG_ARCH_CHIP_STM32L162ZD is not set +# CONFIG_ARCH_CHIP_STM32L162VE is not set +# CONFIG_ARCH_CHIP_STM32F100C8 is not set +# CONFIG_ARCH_CHIP_STM32F100CB is not set +# CONFIG_ARCH_CHIP_STM32F100R8 is not set +# CONFIG_ARCH_CHIP_STM32F100RB is not set +# CONFIG_ARCH_CHIP_STM32F100RC is not set +# CONFIG_ARCH_CHIP_STM32F100RD is not set +# CONFIG_ARCH_CHIP_STM32F100RE is not set +# CONFIG_ARCH_CHIP_STM32F100V8 is not set +# CONFIG_ARCH_CHIP_STM32F100VB is not set +# CONFIG_ARCH_CHIP_STM32F100VC is not set +# CONFIG_ARCH_CHIP_STM32F100VD is not set +# CONFIG_ARCH_CHIP_STM32F100VE is not set +# CONFIG_ARCH_CHIP_STM32F102CB is not set +# CONFIG_ARCH_CHIP_STM32F103T8 is not set +# CONFIG_ARCH_CHIP_STM32F103TB is not set +# CONFIG_ARCH_CHIP_STM32F103C4 is not set +# CONFIG_ARCH_CHIP_STM32F103C8 is not set +# CONFIG_ARCH_CHIP_STM32F103CB is not set +# CONFIG_ARCH_CHIP_STM32F103R8 is not set +# CONFIG_ARCH_CHIP_STM32F103RB is not set +# CONFIG_ARCH_CHIP_STM32F103RC is not set +# CONFIG_ARCH_CHIP_STM32F103RD is not set +# CONFIG_ARCH_CHIP_STM32F103RE is not set +# CONFIG_ARCH_CHIP_STM32F103RG is not set +# CONFIG_ARCH_CHIP_STM32F103V8 is not set +# CONFIG_ARCH_CHIP_STM32F103VB is not set +# CONFIG_ARCH_CHIP_STM32F103VC is not set +# CONFIG_ARCH_CHIP_STM32F103VE is not set +# CONFIG_ARCH_CHIP_STM32F103ZE is not set +# CONFIG_ARCH_CHIP_STM32F105VB is not set +# CONFIG_ARCH_CHIP_STM32F105RB is not set +# CONFIG_ARCH_CHIP_STM32F107VC is not set +# CONFIG_ARCH_CHIP_STM32F205RG is not set +# CONFIG_ARCH_CHIP_STM32F207IG is not set +# CONFIG_ARCH_CHIP_STM32F207ZE is not set +# CONFIG_ARCH_CHIP_STM32F302K6 is not set +# CONFIG_ARCH_CHIP_STM32F302K8 is not set +# CONFIG_ARCH_CHIP_STM32F302CB is not set +# CONFIG_ARCH_CHIP_STM32F302CC is not set +# CONFIG_ARCH_CHIP_STM32F302RB is not set +# CONFIG_ARCH_CHIP_STM32F302RC is not set +# CONFIG_ARCH_CHIP_STM32F302VB is not set +# CONFIG_ARCH_CHIP_STM32F302VC is not set +# CONFIG_ARCH_CHIP_STM32F303K6 is not set +# CONFIG_ARCH_CHIP_STM32F303K8 is not set +# CONFIG_ARCH_CHIP_STM32F303C6 is not set +# CONFIG_ARCH_CHIP_STM32F303C8 is not set +# CONFIG_ARCH_CHIP_STM32F303CB is not set +# CONFIG_ARCH_CHIP_STM32F303CC is not set +# CONFIG_ARCH_CHIP_STM32F303RB is not set +# CONFIG_ARCH_CHIP_STM32F303RC is not set +# CONFIG_ARCH_CHIP_STM32F303RD is not set +# CONFIG_ARCH_CHIP_STM32F303RE is not set +# CONFIG_ARCH_CHIP_STM32F303VB is not set +# CONFIG_ARCH_CHIP_STM32F303VC is not set +# CONFIG_ARCH_CHIP_STM32F372C8 is not set +# CONFIG_ARCH_CHIP_STM32F372R8 is not set +# CONFIG_ARCH_CHIP_STM32F372V8 is not set +# CONFIG_ARCH_CHIP_STM32F372CB is not set +# CONFIG_ARCH_CHIP_STM32F372RB is not set +# CONFIG_ARCH_CHIP_STM32F372VB is not set +# CONFIG_ARCH_CHIP_STM32F372CC is not set +# CONFIG_ARCH_CHIP_STM32F372RC is not set +# CONFIG_ARCH_CHIP_STM32F372VC is not set +# CONFIG_ARCH_CHIP_STM32F373C8 is not set +# CONFIG_ARCH_CHIP_STM32F373R8 is not set +# CONFIG_ARCH_CHIP_STM32F373V8 is not set +# CONFIG_ARCH_CHIP_STM32F373CB is not set +# CONFIG_ARCH_CHIP_STM32F373RB is not set +# CONFIG_ARCH_CHIP_STM32F373VB is not set +# CONFIG_ARCH_CHIP_STM32F373CC is not set +# CONFIG_ARCH_CHIP_STM32F373RC is not set +# CONFIG_ARCH_CHIP_STM32F373VC is not set +# CONFIG_ARCH_CHIP_STM32F401RE is not set +# CONFIG_ARCH_CHIP_STM32F411RE is not set +# CONFIG_ARCH_CHIP_STM32F411VE is not set +# CONFIG_ARCH_CHIP_STM32F405RG is not set +# CONFIG_ARCH_CHIP_STM32F405VG is not set +# CONFIG_ARCH_CHIP_STM32F405ZG is not set +# CONFIG_ARCH_CHIP_STM32F407VE is not set +CONFIG_ARCH_CHIP_STM32F407VG=y +# CONFIG_ARCH_CHIP_STM32F407ZE is not set +# CONFIG_ARCH_CHIP_STM32F407ZG is not set +# CONFIG_ARCH_CHIP_STM32F407IE is not set +# CONFIG_ARCH_CHIP_STM32F407IG is not set +# CONFIG_ARCH_CHIP_STM32F427V is not set +# CONFIG_ARCH_CHIP_STM32F427Z is not set +# CONFIG_ARCH_CHIP_STM32F427I is not set +# CONFIG_ARCH_CHIP_STM32F429V is not set +# CONFIG_ARCH_CHIP_STM32F429Z is not set +# CONFIG_ARCH_CHIP_STM32F429I is not set +# CONFIG_ARCH_CHIP_STM32F429B is not set +# CONFIG_ARCH_CHIP_STM32F429N is not set +# CONFIG_ARCH_CHIP_STM32F446M is not set +# CONFIG_ARCH_CHIP_STM32F446R is not set +# CONFIG_ARCH_CHIP_STM32F446V is not set +# CONFIG_ARCH_CHIP_STM32F446Z is not set +# CONFIG_ARCH_CHIP_STM32F469A is not set +# CONFIG_ARCH_CHIP_STM32F469I is not set +# CONFIG_ARCH_CHIP_STM32F469B is not set +# CONFIG_ARCH_CHIP_STM32F469N is not set +CONFIG_STM32_FLASH_CONFIG_DEFAULT=y +# CONFIG_STM32_FLASH_CONFIG_4 is not set +# CONFIG_STM32_FLASH_CONFIG_6 is not set +# CONFIG_STM32_FLASH_CONFIG_8 is not set +# CONFIG_STM32_FLASH_CONFIG_B is not set +# CONFIG_STM32_FLASH_CONFIG_C is not set +# CONFIG_STM32_FLASH_CONFIG_D is not set +# CONFIG_STM32_FLASH_CONFIG_E is not set +# CONFIG_STM32_FLASH_CONFIG_F is not set +# CONFIG_STM32_FLASH_CONFIG_G is not set +# CONFIG_STM32_FLASH_CONFIG_I is not set +# CONFIG_STM32_STM32L15XX is not set +# CONFIG_STM32_ENERGYLITE is not set +# CONFIG_STM32_STM32F10XX is not set +# CONFIG_STM32_VALUELINE is not set +# CONFIG_STM32_CONNECTIVITYLINE is not set +# CONFIG_STM32_PERFORMANCELINE is not set +# CONFIG_STM32_USBACCESSLINE is not set +# CONFIG_STM32_HIGHDENSITY is not set +# CONFIG_STM32_MEDIUMDENSITY is not set +# CONFIG_STM32_LOWDENSITY is not set +# CONFIG_STM32_STM32F20XX is not set +# CONFIG_STM32_STM32F205 is not set +# CONFIG_STM32_STM32F207 is not set +# CONFIG_STM32_STM32F30XX is not set +# CONFIG_STM32_STM32F302 is not set +# CONFIG_STM32_STM32F303 is not set +# CONFIG_STM32_STM32F37XX is not set +CONFIG_STM32_STM32F40XX=y +# CONFIG_STM32_STM32F401 is not set +# CONFIG_STM32_STM32F411 is not set +# CONFIG_STM32_STM32F405 is not set +CONFIG_STM32_STM32F407=y +# CONFIG_STM32_STM32F427 is not set +# CONFIG_STM32_STM32F429 is not set +# CONFIG_STM32_STM32F446 is not set +# CONFIG_STM32_STM32F469 is not set +# CONFIG_STM32_DFU is not set + +# +# STM32 Peripheral Support +# +CONFIG_STM32_HAVE_CCM=y +# CONFIG_STM32_HAVE_USBDEV is not set +CONFIG_STM32_HAVE_OTGFS=y +CONFIG_STM32_HAVE_FSMC=y +# CONFIG_STM32_HAVE_LTDC is not set +CONFIG_STM32_HAVE_USART3=y +CONFIG_STM32_HAVE_UART4=y +CONFIG_STM32_HAVE_UART5=y +CONFIG_STM32_HAVE_USART6=y +# CONFIG_STM32_HAVE_UART7 is not set +# CONFIG_STM32_HAVE_UART8 is not set +CONFIG_STM32_HAVE_TIM1=y +CONFIG_STM32_HAVE_TIM2=y +CONFIG_STM32_HAVE_TIM3=y +CONFIG_STM32_HAVE_TIM4=y +CONFIG_STM32_HAVE_TIM5=y +CONFIG_STM32_HAVE_TIM6=y +CONFIG_STM32_HAVE_TIM7=y +CONFIG_STM32_HAVE_TIM8=y +CONFIG_STM32_HAVE_TIM9=y +CONFIG_STM32_HAVE_TIM10=y +CONFIG_STM32_HAVE_TIM11=y +CONFIG_STM32_HAVE_TIM12=y +CONFIG_STM32_HAVE_TIM13=y +CONFIG_STM32_HAVE_TIM14=y +# CONFIG_STM32_HAVE_TIM15 is not set +# CONFIG_STM32_HAVE_TIM16 is not set +# CONFIG_STM32_HAVE_TIM17 is not set +CONFIG_STM32_HAVE_ADC2=y +CONFIG_STM32_HAVE_ADC3=y +# CONFIG_STM32_HAVE_ADC4 is not set +# CONFIG_STM32_HAVE_ADC1_DMA is not set +# CONFIG_STM32_HAVE_ADC2_DMA is not set +# CONFIG_STM32_HAVE_ADC3_DMA is not set +# CONFIG_STM32_HAVE_ADC4_DMA is not set +CONFIG_STM32_HAVE_CAN1=y +CONFIG_STM32_HAVE_CAN2=y +CONFIG_STM32_HAVE_DAC1=y +CONFIG_STM32_HAVE_DAC2=y +CONFIG_STM32_HAVE_RNG=y +CONFIG_STM32_HAVE_ETHMAC=y +CONFIG_STM32_HAVE_I2C2=y +CONFIG_STM32_HAVE_I2C3=y +CONFIG_STM32_HAVE_SPI2=y +CONFIG_STM32_HAVE_SPI3=y +# CONFIG_STM32_HAVE_SPI4 is not set +# CONFIG_STM32_HAVE_SPI5 is not set +# CONFIG_STM32_HAVE_SPI6 is not set +# CONFIG_STM32_HAVE_SAIPLL is not set +# CONFIG_STM32_HAVE_I2SPLL is not set +# CONFIG_STM32_ADC1 is not set +# CONFIG_STM32_ADC2 is not set +# CONFIG_STM32_ADC3 is not set +# CONFIG_STM32_BKPSRAM is not set +# CONFIG_STM32_CAN1 is not set +# CONFIG_STM32_CAN2 is not set +# CONFIG_STM32_CCMDATARAM is not set +# CONFIG_STM32_CRC is not set +# CONFIG_STM32_CRYP is not set +# CONFIG_STM32_DMA1 is not set +# CONFIG_STM32_DMA2 is not set +# CONFIG_STM32_DAC1 is not set +# CONFIG_STM32_DAC2 is not set +# CONFIG_STM32_DCMI is not set +# CONFIG_STM32_ETHMAC is not set +# CONFIG_STM32_FSMC is not set +# CONFIG_STM32_HASH is not set +# CONFIG_STM32_I2C1 is not set +# CONFIG_STM32_I2C2 is not set +# CONFIG_STM32_I2C3 is not set +CONFIG_STM32_OTGFS=y +# CONFIG_STM32_OTGHS is not set +CONFIG_STM32_PWR=y +# CONFIG_STM32_RNG is not set +# CONFIG_STM32_SDIO is not set +CONFIG_STM32_SPI1=y +# CONFIG_STM32_SPI2 is not set +# CONFIG_STM32_SPI3 is not set +CONFIG_STM32_SYSCFG=y +# CONFIG_STM32_TIM1 is not set +# CONFIG_STM32_TIM2 is not set +# CONFIG_STM32_TIM3 is not set +# CONFIG_STM32_TIM4 is not set +# CONFIG_STM32_TIM5 is not set +# CONFIG_STM32_TIM6 is not set +# CONFIG_STM32_TIM7 is not set +# CONFIG_STM32_TIM8 is not set +# CONFIG_STM32_TIM9 is not set +# CONFIG_STM32_TIM10 is not set +# CONFIG_STM32_TIM11 is not set +# CONFIG_STM32_TIM12 is not set +# CONFIG_STM32_TIM13 is not set +# CONFIG_STM32_TIM14 is not set +# CONFIG_STM32_USART1 is not set +CONFIG_STM32_USART2=y +CONFIG_STM32_USART3=y +# CONFIG_STM32_UART4 is not set +# CONFIG_STM32_UART5 is not set +# CONFIG_STM32_USART6 is not set +# CONFIG_STM32_IWDG is not set +# CONFIG_STM32_WWDG is not set +CONFIG_STM32_SPI=y +# CONFIG_STM32_NOEXT_VECTORS is not set + +# +# Alternate Pin Mapping +# +# CONFIG_STM32_FLASH_PREFETCH is not set +# CONFIG_STM32_JTAG_DISABLE is not set +# CONFIG_STM32_JTAG_FULL_ENABLE is not set +# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set +CONFIG_STM32_JTAG_SW_ENABLE=y +# CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG is not set +# CONFIG_STM32_FORCEPOWER is not set +# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set +# CONFIG_STM32_CCMEXCLUDE is not set + +# +# Timer Configuration +# +# CONFIG_STM32_ONESHOT is not set +# CONFIG_STM32_FREERUN is not set +# CONFIG_STM32_TIM1_CAP is not set +# CONFIG_STM32_TIM2_CAP is not set +# CONFIG_STM32_TIM3_CAP is not set +# CONFIG_STM32_TIM4_CAP is not set +# CONFIG_STM32_TIM5_CAP is not set +# CONFIG_STM32_TIM8_CAP is not set +# CONFIG_STM32_TIM9_CAP is not set +# CONFIG_STM32_TIM10_CAP is not set +# CONFIG_STM32_TIM11_CAP is not set +# CONFIG_STM32_TIM12_CAP is not set +# CONFIG_STM32_TIM13_CAP is not set +# CONFIG_STM32_TIM14_CAP is not set +CONFIG_STM32_USART=y +CONFIG_STM32_SERIALDRIVER=y + +# +# U[S]ART Configuration +# + +# +# U[S]ART Device Configuration +# +CONFIG_STM32_USART2_SERIALDRIVER=y +# CONFIG_STM32_USART2_1WIREDRIVER is not set +# CONFIG_USART2_RS485 is not set +CONFIG_STM32_USART3_SERIALDRIVER=y +# CONFIG_STM32_USART3_1WIREDRIVER is not set +# CONFIG_USART3_RS485 is not set + +# +# Serial Driver Configuration +# +# CONFIG_SERIAL_DISABLE_REORDERING is not set +# CONFIG_STM32_FLOWCONTROL_BROKEN is not set +# CONFIG_STM32_USART_BREAKS is not set +# CONFIG_STM32_USART_SINGLEWIRE is not set + +# +# SPI Configuration +# +# CONFIG_STM32_SPI_INTERRUPTS is not set +# CONFIG_STM32_SPI_DMA is not set +# CONFIG_STM32_HAVE_RTC_COUNTER is not set +# CONFIG_STM32_HAVE_RTC_SUBSECONDS is not set + +# +# USB FS Host Configuration +# + +# +# USB HS Host Configuration +# + +# +# USB Host Debug Configuration +# + +# +# USB Device Configuration +# + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +# CONFIG_ARCH_HAVE_MULTICPU is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_USE_MPU is not set +# CONFIG_ARCH_IRQPRIO is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=16717 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x20000000 +CONFIG_RAM_SIZE=114688 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y +# CONFIG_ARCH_BOARD_MIKROE_STM32F4 is not set +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="stm32f4discovery" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +# CONFIG_ARCH_IRQBUTTONS is not set + +# +# Board-Specific Options +# +# CONFIG_STM32F4DISBB is not set +# CONFIG_BOARD_CRASHDUMP is not set +# CONFIG_LIB_BOARDCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_ARCH_HAVE_TICKLESS=y +# CONFIG_SCHED_TICKLESS is not set +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=12 +CONFIG_START_DAY=6 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=16 +CONFIG_WDOG_INTRESERVE=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +# CONFIG_SPINLOCK is not set +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=31 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_MUTEX_TYPES is not set +CONFIG_NPTHREAD_KEYS=4 + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +# CONFIG_BOARD_INITIALIZE is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_HPWORK is not set +# CONFIG_SCHED_LPWORK is not set + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +# CONFIG_DISABLE_POLL is not set +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_DEV_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +CONFIG_ARCH_HAVE_I2CRESET=y +# CONFIG_I2C is not set +CONFIG_SPI=y +# CONFIG_SPI_SLAVE is not set +CONFIG_SPI_EXCHANGE=y +# CONFIG_SPI_CMDDATA is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_SPI_HWFEATURES is not set +# CONFIG_SPI_CRCGENERATION is not set +# CONFIG_SPI_CS_CONTROL is not set +# CONFIG_SPI_CS_DELAY_CONTROL is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_USERLED is not set +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +# CONFIG_MMCSD is not set +# CONFIG_MODEM is not set +# CONFIG_MTD is not set +# CONFIG_EEPROM is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +# CONFIG_SERCOMM_CONSOLE is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +# CONFIG_USART1_SERIALDRIVER is not set +CONFIG_USART2_SERIALDRIVER=y +CONFIG_USART3_SERIALDRIVER=y +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_SERIAL_NPOLLWAITERS=2 +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_USART2_SERIAL_CONSOLE=y +# CONFIG_USART3_SERIAL_CONSOLE is not set +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# USART2 Configuration +# +CONFIG_USART2_RXBUFSIZE=128 +CONFIG_USART2_TXBUFSIZE=128 +CONFIG_USART2_BAUD=115200 +CONFIG_USART2_BITS=8 +CONFIG_USART2_PARITY=0 +CONFIG_USART2_2STOP=0 +# CONFIG_USART2_IFLOWCONTROL is not set +# CONFIG_USART2_OFLOWCONTROL is not set +# CONFIG_USART2_DMA is not set + +# +# USART3 Configuration +# +CONFIG_USART3_RXBUFSIZE=256 +CONFIG_USART3_TXBUFSIZE=256 +CONFIG_USART3_BAUD=115200 +CONFIG_USART3_BITS=8 +CONFIG_USART3_PARITY=0 +CONFIG_USART3_2STOP=0 +# CONFIG_USART3_IFLOWCONTROL is not set +# CONFIG_USART3_OFLOWCONTROL is not set +# CONFIG_USART3_DMA is not set +CONFIG_PSEUDOTERM=y +# CONFIG_PSEUDOTERM_BSD is not set +CONFIG_PSEUDOTERM_SUSV1=y +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set +# CONFIG_DRIVERS_WIRELESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +# CONFIG_ARCH_HAVE_NET is not set +# CONFIG_ARCH_HAVE_PHY is not set +# CONFIG_NET is not set + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +CONFIG_FS_READABLE=y +# CONFIG_FS_WRITABLE is not set +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_FAT is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set +CONFIG_FS_PROCFS=y +# CONFIG_FS_PROCFS_REGISTER is not set + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_UNIONFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=2 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# +# CONFIG_WIRELESS is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +CONFIG_LIB_HOMEDIR="/" +# CONFIG_LIBM is not set +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_RAND_ORDER=1 +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_LIBC_EXECFUNCS is not set +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +# CONFIG_LIBC_LOCALTIME is not set +# CONFIG_TIME_EXTENDED is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set +CONFIG_ARCH_HAVE_TLS=y +# CONFIG_TLS is not set +# CONFIG_LIBC_NETDB is not set +# CONFIG_NETDB_HOSTFILE is not set + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +# CONFIG_CXX_NEWLONG is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CPUHOG is not set +# CONFIG_EXAMPLES_CXXTEST is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_NRF24L01TERM is not set +CONFIG_EXAMPLES_NSH=y +CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +CONFIG_EXAMPLES_PTYTEST=y +CONFIG_EXAMPLES_PTYTEST_PRIORITY=100 +CONFIG_EXAMPLES_PTYTEST_STACKSIZE=2048 +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_INIFILE is not set +# CONFIG_FSUTILS_PASSWD is not set + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_BAS is not set +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CHAT is not set +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_SMTP is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=64 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_NSH_MAXARGUMENTS=6 +# CONFIG_NSH_ARGCAT is not set +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +CONFIG_NSH_DISABLE_DATE=y +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_IFUPDOWN is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFIFO is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 + +# +# Configure Command Options +# +# CONFIG_NSH_CMDOPT_DF_H is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_NSH_PROC_MOUNTPOINT="/proc" +CONFIG_NSH_FILEIOSIZE=512 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_ALTCONDEV is not set +# CONFIG_NSH_ARCHINIT is not set +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set + +# +# NxWidgets/NxWM +# + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +# CONFIG_READLINE_TABCOMPLETION is not set +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set diff --git a/configs/stm32f4discovery/pseudoterm/setenv.sh b/configs/stm32f4discovery/pseudoterm/setenv.sh new file mode 100644 index 00000000000..d67e6fdc7df --- /dev/null +++ b/configs/stm32f4discovery/pseudoterm/setenv.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# configs/stm32f4discovery/nsh/setenv.sh +# +# Copyright (C) 2011-2012 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 [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi + +# This is the Cygwin path to the location where I installed the RIDE +# toolchain under windows. You will also have to edit this if you install +# the RIDE toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin" + +# This is the Cygwin path to the location where I installed the CodeSourcery +# toolchain under windows. You will also have to edit this if you install +# the CodeSourcery toolchain in any other location +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin" +#export TOOLCHAIN_BIN="/cygdrive/c/Users/MyName/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin" + +# This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors" +# You can this free toolchain here https://launchpad.net/gcc-arm-embedded +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin" + +# These are the Cygwin paths to the locations where I installed the Atollic +# toolchain under windows. You will also have to edit this if you install +# the Atollic toolchain in any other location. /usr/bin is added before +# the Atollic bin path because there is are binaries named gcc.exe and g++.exe +# at those locations as well. +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin" +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +#export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH variable +export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" From ba62b49190e1e132120137cd9627f9d893b673a6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 16 Jul 2016 16:14:18 -0600 Subject: [PATCH 053/152] SIM: Add more names to nuttx-namex.dat --- arch/sim/src/nuttx-names.dat | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/sim/src/nuttx-names.dat b/arch/sim/src/nuttx-names.dat index 698df015764..313d7b9caa5 100644 --- a/arch/sim/src/nuttx-names.dat +++ b/arch/sim/src/nuttx-names.dat @@ -1,34 +1,53 @@ +_exit NX_exit accept NXaccept +asprintf NXasprintf calloc NXcalloc +clearenv NXclearenv clock_gettime NXclock_gettime close NXclose closedir NXclosedir dup NXdup +dup2 NXdup2 +exit NXexit free NXfree fclose NXfclose +fdopen NXfdopen +fgetc NXfgetc fopen NXfopen +fprintf NXfprintf fputc NXfputc fcntl NXfcntl fputs NXfputs fread NXfread +fseek NXfseek fwrite NXfwrite fsync NXfsync getenv NXgetenv +getopt NXgetopt +getpid NXgetpid gettimeofday NXgettimeofday ioctl NXioctl isatty NXisatty +kill NXkill listen NXlisten lseek NXlseek +mallinfo NXmallinfo malloc NXmalloc malloc_init NXmalloc_init +memcpy NXmemcpy +memset NXmemset +mktime NXmktime +mq_close NXmq_close mkdir NXmkdir mount NXmount open NXopen opendir NXopendir nanosleep NXnanosleep +pipe NXpipe poll NXpoll printf NXprintf pthread_create NXpthread_create +pthread_exit NXpthread_exit pthread_getspecific NXpthread_getspecific pthread_key_create NXpthread_key_create pthread_kill NXpthread_kill @@ -56,22 +75,41 @@ sem_post NXsem_post sem_wait NXsem_wait send NXsend sendto NXsendto +setenv NXsetenv +setlogmask NXsetlogmask setsockopt NXsetsockopt sigaction NXsigaction +sigemptyset NXsigemptyset sighold NXsighold sigprocmask NXsigprocmask sigtimedwait NXsigtimedwait sigrelse NXsigrelse sleep NXsleep +snprintf NXsnprintf socket NXsocket +sprintf NXsprintf stat NXstat statfs NXstatfs +strchr NXstrchr +strcpy NXstrcpy +strcspn NXstrcspn +strdup NXstrdup +strftime NXstrftime +strlen NXstrlen +strncasecmp NXstrncasecmp +strncmp NXstrncmp +strncpy NXstrncpy +strtok_r NXstrtok_r +syslog NXsyslog system NXsystem tcgetattr NXtcgetattr tcsetattr NXtcsetattr umount2 NXumount2 unlink NXunlink +unsetenv NXunsetenv usleep NXusleep +vasprintf NXvasprintf vfork NXvfork +vfprint NXvfprint write NXwrite zmalloc NXzmalloc From 91ba0be667a53c1c7a428849ba9ad8b6e7d42922 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Sat, 16 Jul 2016 17:49:37 -0600 Subject: [PATCH 054/152] Enable TERMIOS support in stm32discovery/pseudoterm configuration --- arch/sim/src/nuttx-names.dat | 1 + configs/stm32f4discovery/pseudoterm/defconfig | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/sim/src/nuttx-names.dat b/arch/sim/src/nuttx-names.dat index 313d7b9caa5..400a591ec29 100644 --- a/arch/sim/src/nuttx-names.dat +++ b/arch/sim/src/nuttx-names.dat @@ -70,6 +70,7 @@ rmdir NXrmdir sched_yield NXsched_yield seekdir NXseekdir select NXselect +sem_getvalue NXsem_getvalue sem_init NXsem_init sem_post NXsem_post sem_wait NXsem_wait diff --git a/configs/stm32f4discovery/pseudoterm/defconfig b/configs/stm32f4discovery/pseudoterm/defconfig index 7911dcfda8c..f599aadadec 100644 --- a/configs/stm32f4discovery/pseudoterm/defconfig +++ b/configs/stm32f4discovery/pseudoterm/defconfig @@ -147,7 +147,7 @@ CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y CONFIG_ARMV7M_HAVE_STACKCHECK=y # CONFIG_ARMV7M_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_SERIAL_TERMIOS is not set +CONFIG_SERIAL_TERMIOS=y # # STM32 Configuration Options @@ -1032,8 +1032,11 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y # CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_PPPD is not set CONFIG_EXAMPLES_PTYTEST=y +CONFIG_EXAMPLES_PTYTEST_POLL=y +CONFIG_EXAMPLES_PTYTEST_SERIALDEV="/dev/ttyS1" CONFIG_EXAMPLES_PTYTEST_PRIORITY=100 CONFIG_EXAMPLES_PTYTEST_STACKSIZE=2048 +CONFIG_EXAMPLES_PTYTEST_DAEMONPRIO=100 # CONFIG_EXAMPLES_RGBLED is not set # CONFIG_EXAMPLES_RGMP is not set # CONFIG_EXAMPLES_SENDMAIL is not set From 6cefbc0c3f5772ccc54b7acf87b47970c3fb015a Mon Sep 17 00:00:00 2001 From: David Alessio Date: Sun, 17 Jul 2016 06:42:26 -0600 Subject: [PATCH 055/152] =?UTF-8?q?This=20change=20provides=20an=20option?= =?UTF-8?q?=20to=20add=20/dev/urandom=20to=20all=20architectures.=20=20The?= =?UTF-8?q?=20pseudo-random=20algorithm=20I=20choose=20strikes=20an=20argu?= =?UTF-8?q?ably-good=20balance=20between=20being=20"random"=20and=20small/?= =?UTF-8?q?fast=20enough=20for=208/16=20bit=20MCUs.=20=20It=E2=80=99s=20th?= =?UTF-8?q?e=20well-documented=20xorshift128=20algorithm.=20=20It=20has=20?= =?UTF-8?q?an=20internal=20state=20of=20128=20bits=20that=20can=20be=20[re?= =?UTF-8?q?-]seeded=20with=20a=20write.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/src/common/up_initialize.c | 4 + arch/avr/src/common/up_initialize.c | 4 + arch/hc/src/common/up_initialize.c | 4 + arch/mips/src/common/up_initialize.c | 4 + arch/rgmp/src/nuttx.c | 28 +++ arch/sh/src/common/up_initialize.c | 4 + arch/sim/src/up_initialize.c | 4 + arch/x86/src/common/up_initialize.c | 4 + arch/z16/src/common/up_initialize.c | 4 + arch/z80/src/common/up_initialize.c | 4 + drivers/Kconfig | 7 + drivers/Makefile | 4 + drivers/dev_urandom.c | 245 +++++++++++++++++++++++++++ include/nuttx/fs/fs.h | 10 ++ 14 files changed, 330 insertions(+) create mode 100644 drivers/dev_urandom.c diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 973e2318f38..9e4477d76a1 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -198,6 +198,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 4ac08dfd0b6..3290dab26ba 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -239,6 +239,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index a0173046476..fb953156623 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -165,6 +165,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 940b3672e19..6b2384b8ba3 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index ee6148e35e5..8e1b916b251 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include #include @@ -131,6 +133,32 @@ void up_initialize(void) syslog_initialize(SYSLOG_INIT_EARLY); + /* Register devices */ + +#if CONFIG_NFILE_DESCRIPTORS > 0 + +#if defined(CONFIG_DEV_NULL) + devnull_register(); /* Standard /dev/null */ +#endif + +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + +#if defined(CONFIG_DEV_ZERO) + devzero_register(); /* Standard /dev/zero */ +#endif + +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif +#endif /* CONFIG_NFILE_DESCRIPTORS */ + +#if defined(CONFIG_SCHED_INSTRUMENTATION_BUFFER) && \ + defined(CONFIG_DRIVER_NOTE) + note_register(); /* Non-standard /dev/note */ +#endif + #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index c4389936555..528a7c903e7 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -156,6 +156,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 5df82aec955..cc8c890ea69 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -153,6 +153,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 6a9eca8d5ae..e3041739308 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 3f375763bd6..499e74966ec 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 760f6c74a95..1820871fbef 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -164,6 +164,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_URANDOM) + devurandom_register(); /* Standard /dev/urandom */ +#endif + #if defined(CONFIG_DEV_ZERO) devzero_register(); /* Standard /dev/zero */ #endif diff --git a/drivers/Kconfig b/drivers/Kconfig index bc506ee1e00..819183c4806 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -30,6 +30,13 @@ config DEV_RANDOM default y depends on ARCH_HAVE_RNG +config DEV_URANDOM + bool "Enable /dev/urandom" + default n + ---help--- + xorshift128 is a pseudorandom number generator that's simple, + portable, and can also be used on 8-bit and 16-bit MCUs. + source drivers/loop/Kconfig menu "Buffering" diff --git a/drivers/Makefile b/drivers/Makefile index ff0a00b5b5a..cf97712926e 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -98,6 +98,10 @@ endif ifeq ($(CONFIG_PWM),y) CSRCS += pwm.c endif + +ifeq ($(CONFIG_DEV_URANDOM),y) + CSRCS += dev_urandom.c +endif endif AOBJS = $(ASRCS:.S=$(OBJEXT)) diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c new file mode 100644 index 00000000000..6a5e48a9323 --- /dev/null +++ b/drivers/dev_urandom.c @@ -0,0 +1,245 @@ +/**************************************************************************** + * drivers/dev_urandom.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: David S. Alessio + * + * 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. + * + ****************************************************************************/ + +/* This random number generator is simple, fast and portable. + * Ref: https://en.wikipedia.org/wiki/Xorshift + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +typedef union +{ + struct + { + uint32_t x; + uint32_t y; + uint32_t z; + uint32_t w; + }; + uint8_t u[16]; +} xorshift128_state_t; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#define min(a, b) (((a) < (b)) ? (a) : (b)) + +static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +#ifndef CONFIG_DISABLE_POLL +static int devurand_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations devurand_fops = +{ + NULL, /* open */ + NULL, /* close */ + devurand_read, /* read */ + devurand_write, /* write */ + NULL, /* seek */ + NULL /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , devurand_poll /* poll */ +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL /* unlink */ +#endif +}; + +static xorshift128_state_t prng; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static uint32_t xorshift128(void) +{ + uint32_t t = prng.x; + + t ^= t << 11; + t ^= t >> 8; + + prng.x = prng.y; + prng.y = prng.z; + prng.z = prng.w; + + prng.w ^= prng.w >> 19; + prng.w ^= t; + + return prng.w; +} + +/**************************************************************************** + * Name: devurand_read + ****************************************************************************/ + +static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, + size_t len) +{ + size_t n; + uint32_t rnd; + + n = len; + + /* Align buffer pointer to 4-byte boundry */ + + if ((unsigned)buffer & 0x03) + { + /* Generate a pseudo random number */ + + rnd = xorshift128(); + + while ((unsigned)buffer & 0x03) + { + if (n <= 0) + { + return len; + } + + *buffer++ = rnd & 0xFF; + rnd >>= 8; + --n; + } + } + + /* Stuff buffer with PRNGs 4 bytes at a time */ + + while (n >= 4) + { + *(uint32_t *) buffer = xorshift128(); + buffer += 4; + n -= 4; + } + + /* Stuff remaining 1, 2, or 3 bytes */ + + if (n > 0) + { + /* Generate a pseudo random number */ + + rnd = xorshift128(); + + do + { + *buffer++ = rnd & 0xFF; + rnd >>= 8; + } + while (--n > 0); + } + + return len; +} + +/**************************************************************************** + * Name: devurand_write + ****************************************************************************/ + +static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer, + size_t len) +{ + /* Write can be used to seed the PRNG state */ + + len = min(len, sizeof(prng.u)); + memcpy(&prng.u, buffer, len); + return len; +} + +/**************************************************************************** + * Name: devurand_poll + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_POLL +static int devurand_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup) +{ + if (setup) + { + fds->revents |= (fds->events & (POLLIN | POLLOUT)); + if (fds->revents != 0) + { + sem_post(fds->sem); + } + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +void devurandom_register(void) +{ + /* Seed the PRNG */ + + prng.w = 97; + prng.x = 101; + prng.y = prng.w << 17; + prng.z = prng.x << 25; + + (void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL); +} diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 03f62f976a6..ea0409cd84d 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1013,6 +1013,16 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup); void devnull_register(void); +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +void devurandom_register(void); + /**************************************************************************** * Name: devcrypto_register * From ffd3a31649a426f30aeb2bedaa81eed11abb613b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 07:11:09 -0600 Subject: [PATCH 056/152] Rename lib_rand.c to lib_srand.c --- drivers/dev_urandom.c | 6 +++--- libc/stdlib/Make.defs | 2 +- libc/stdlib/{lib_rand.c => lib_srand.c} | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) rename libc/stdlib/{lib_rand.c => lib_srand.c} (96%) diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index 6a5e48a9323..0c85d8cfa4c 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -138,20 +138,20 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, /* Align buffer pointer to 4-byte boundry */ - if ((unsigned)buffer & 0x03) + if (((unsigned)buffer & 0x03) != 0) { /* Generate a pseudo random number */ rnd = xorshift128(); - while ((unsigned)buffer & 0x03) + while (((unsigned)buffer & 0x03) != 0) { if (n <= 0) { return len; } - *buffer++ = rnd & 0xFF; + *buffer++ = rnd & 0xff; rnd >>= 8; --n; } diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index 625712e91e6..ecf8f5fefab 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -37,7 +37,7 @@ CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c -CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c +CSRCS += lib_bsearch.c lib_srand.c lib_qsort.c CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c CSRCS += lib_strtod.c lib_checkbase.c diff --git a/libc/stdlib/lib_rand.c b/libc/stdlib/lib_srand.c similarity index 96% rename from libc/stdlib/lib_rand.c rename to libc/stdlib/lib_srand.c index 453a4537a0f..726b4ab0f75 100644 --- a/libc/stdlib/lib_rand.c +++ b/libc/stdlib/lib_srand.c @@ -1,7 +1,7 @@ /**************************************************************************** - * libc/stdlib/lib_rand.c + * libc/stdlib/lib_srand.c * - * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -70,7 +70,7 @@ * Private Function Prototypes ****************************************************************************/ -static unsigned int nrand(unsigned int nLimit); +static unsigned int nrand(unsigned int limit); /* First order congruential generators */ @@ -111,7 +111,7 @@ static unsigned long g_randint3; * Private Functions ****************************************************************************/ -static unsigned int nrand(unsigned int nLimit) +static unsigned int nrand(unsigned int limit) { unsigned long result; double_t ratio; @@ -132,9 +132,9 @@ static unsigned int nrand(unsigned int nLimit) /* Then, produce the return-able value */ - result = (unsigned long)(((double_t)nLimit) * ratio); + result = (unsigned long)(((double_t)limit) * ratio); } - while (result >= (unsigned long)nLimit); + while (result >= (unsigned long)limit); return (unsigned int)result; } From 07e20479ad68a0f6e02ef957cf33db99a2604d71 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 07:56:25 -0600 Subject: [PATCH 057/152] /dev/random: Add configuration option to use the congruential PRNG. --- drivers/Kconfig | 20 +++++++++++ drivers/dev_urandom.c | 66 +++++++++++++++++++++++++++++++---- include/nuttx/lib.h | 6 +++- libc/stdlib/Make.defs | 4 +-- libc/stdlib/lib_rand.c | 63 ++++++++++++++++++++++++++++++++++ libc/stdlib/lib_srand.c | 76 +++++++++++++++++++++++------------------ 6 files changed, 193 insertions(+), 42 deletions(-) create mode 100644 libc/stdlib/lib_rand.c diff --git a/drivers/Kconfig b/drivers/Kconfig index 819183c4806..aba608676c9 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -33,10 +33,30 @@ config DEV_RANDOM config DEV_URANDOM bool "Enable /dev/urandom" default n + +if DEV_URANDOM + +choice + prompt "/dev/urandom algorithm" + default DEV_URANDOM_XORSHIFT128 + +config DEV_URANDOM_XORSHIFT128 + bool "xorshift128" ---help--- xorshift128 is a pseudorandom number generator that's simple, portable, and can also be used on 8-bit and 16-bit MCUs. +config DEV_URANDOM_CONGRUENTIAL + bool "Conguential" + ---help--- + Use the same congruential general used with srand(). This algorithm + is computationally more intense and uses double precision floating + point. NOTE: Good randomness from the congruential generator also + requires that you also select CONFIG_LIB_RAND_ORDER > 2 + +endchoice # /dev/urandom algorithm +endif # DEV_URANDOM + source drivers/loop/Kconfig menu "Buffering" diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index 0c85d8cfa4c..b1ea3696650 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -45,11 +45,29 @@ #include #include +#include #include #include #include + +#include #include +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if !defined(CONFIG_DEV_URANDOM_CONGRUENTIAL) && \ + !defined(CONFIG_DEV_URANDOM_XORSHIFT128) +# define CONFIG_DEV_URANDOM_XORSHIFT128 1 +#endif + +#ifdef CONFIG_DEV_URANDOM_XORSHIFT128 +# define PRNG() xorshift128() +#else /* CONFIG_DEV_URANDOM_CONGRUENTIAL */ +# define PRNG() congruential() +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -101,12 +119,19 @@ static const struct file_operations devurand_fops = #endif }; +#ifdef CONFIG_DEV_URANDOM_XORSHIFT128 static xorshift128_state_t prng; +#endif /**************************************************************************** * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: xorshift128 + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_XORSHIFT128 static uint32_t xorshift128(void) { uint32_t t = prng.x; @@ -123,6 +148,22 @@ static uint32_t xorshift128(void) return prng.w; } +#endif + +/**************************************************************************** + * Name: congruential + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_CONGRUENTIAL +static uint32_t congruential(void) +{ + /* REVISIT: We could probably generate a 32-bit value with a single + * call to nrand(). + */ + + return (uint32_t)nrand(65536L) << (uint32_t)nrand(65536L); +} +#endif /**************************************************************************** * Name: devurand_read @@ -138,13 +179,13 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, /* Align buffer pointer to 4-byte boundry */ - if (((unsigned)buffer & 0x03) != 0) + if (((uintptr_t)buffer & 0x03) != 0) { /* Generate a pseudo random number */ - rnd = xorshift128(); + rnd = PRNG(); - while (((unsigned)buffer & 0x03) != 0) + while (((uintptr_t)buffer & 0x03) != 0) { if (n <= 0) { @@ -161,7 +202,7 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, while (n >= 4) { - *(uint32_t *) buffer = xorshift128(); + *(uint32_t *)buffer = PRNG(); buffer += 4; n -= 4; } @@ -172,7 +213,7 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, { /* Generate a pseudo random number */ - rnd = xorshift128(); + rnd = PRNG(); do { @@ -192,11 +233,20 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer, size_t len) { - /* Write can be used to seed the PRNG state */ + /* Write can be used to re-seed the PRNG state. */ +#ifdef CONFIG_DEV_URANDOM_CONGRUENTIAL + unsigned int seed = 0; + + len = min(len, sizeof(unsigned int)); + memcpy(&seed, buffer, len); + srand(seed); + return len; +#else len = min(len, sizeof(prng.u)); memcpy(&prng.u, buffer, len); return len; +#endif } /**************************************************************************** @@ -234,12 +284,16 @@ static int devurand_poll(FAR struct file *filep, FAR struct pollfd *fds, void devurandom_register(void) { +#ifdef CONFIG_DEV_URANDOM_CONGRUENTIAL + srand(10197); +#else /* Seed the PRNG */ prng.w = 97; prng.x = 101; prng.y = prng.w << 17; prng.z = prng.x << 25; +#endif (void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL); } diff --git a/include/nuttx/lib.h b/include/nuttx/lib.h index 609f4f86f7e..24c1a8aec29 100644 --- a/include/nuttx/lib.h +++ b/include/nuttx/lib.h @@ -2,7 +2,7 @@ * include/nuttx/lib.h * Non-standard, internal APIs available in lib/. * - * Copyright (C) 2007-2009, 2012-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -77,6 +77,10 @@ void lib_stream_initialize(FAR struct task_group_s *group); void lib_stream_release(FAR struct task_group_s *group); #endif +/* Functions defined in lib_srand.c *****************************************/ + +unsigned long nrand(unsigned long limit); + #undef EXTERN #ifdef __cplusplus } diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index ecf8f5fefab..618b16a5450 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # libc/stdlib/Make.defs # -# Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,7 +37,7 @@ CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c -CSRCS += lib_bsearch.c lib_srand.c lib_qsort.c +CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c lib_srand.c CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c CSRCS += lib_strtod.c lib_checkbase.c diff --git a/libc/stdlib/lib_rand.c b/libc/stdlib/lib_rand.c new file mode 100644 index 00000000000..440372fe72e --- /dev/null +++ b/libc/stdlib/lib_rand.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * libc/stdlib/lib_rand.c + * + * Copyright (C) 2007, 2011, 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rand + * + * Description: + * Generate a non-negative, integer random number in the range of 0 through + * (RAND_MAX - 1) + * + ****************************************************************************/ + +int rand(void) +{ + return (int)nrand(32768L); +} diff --git a/libc/stdlib/lib_srand.c b/libc/stdlib/lib_srand.c index 726b4ab0f75..8586afca117 100644 --- a/libc/stdlib/lib_srand.c +++ b/libc/stdlib/lib_srand.c @@ -37,12 +37,17 @@ * Included Files ****************************************************************************/ +#include + #include #include +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* First, second, and thired order congruential generators are supported */ #ifndef CONFIG_LIB_RAND_ORDER @@ -70,8 +75,6 @@ * Private Function Prototypes ****************************************************************************/ -static unsigned int nrand(unsigned int limit); - /* First order congruential generators */ static inline unsigned long fgenerate1(void); @@ -111,34 +114,6 @@ static unsigned long g_randint3; * Private Functions ****************************************************************************/ -static unsigned int nrand(unsigned int limit) -{ - unsigned long result; - double_t ratio; - - /* Loop to be sure a legal random number is generated */ - - do - { - /* Get a random integer in the requested range */ - -#if (CONFIG_LIB_RAND_ORDER == 1) - ratio = frand1(); -#elif (CONFIG_LIB_RAND_ORDER == 2) - ratio = frand2(); -#else /* if (CONFIG_LIB_RAND_ORDER > 2) */ - ratio = frand3(); -#endif - - /* Then, produce the return-able value */ - - result = (unsigned long)(((double_t)limit) * ratio); - } - while (result >= (unsigned long)limit); - - return (unsigned int)result; -} - /* First order congruential generators */ static inline unsigned long fgenerate1(void) @@ -255,7 +230,11 @@ static double_t frand3(void) ****************************************************************************/ /**************************************************************************** - * Function: srand, rand + * Name: srand + * + * Description: + * Seed the confluent hypergeometric random number generator. + * ****************************************************************************/ void srand(unsigned int seed) @@ -271,7 +250,38 @@ void srand(unsigned int seed) #endif } -int rand(void) +/**************************************************************************** + * Name: nrand + * + * Description: + * Return a random unsigned long value in the range of 0 to (limit - 1) + * + ****************************************************************************/ + +unsigned long nrand(unsigned long limit) { - return (int)nrand(32768); + unsigned long result; + double_t ratio; + + /* Loop to be sure a legal random number is generated */ + + do + { + /* Get a random integer in the requested range */ + +#if (CONFIG_LIB_RAND_ORDER == 1) + ratio = frand1(); +#elif (CONFIG_LIB_RAND_ORDER == 2) + ratio = frand2(); +#else /* if (CONFIG_LIB_RAND_ORDER > 2) */ + ratio = frand3(); +#endif + + /* Then, produce the return-able value */ + + result = (unsigned long)(((double_t)limit) * ratio); + } + while (result >= limit); + + return result; } From 5a35abb488703be30856caa45571ed2eb377d1c0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 08:31:02 -0600 Subject: [PATCH 058/152] Improve some comments --- libc/stdlib/lib_srand.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libc/stdlib/lib_srand.c b/libc/stdlib/lib_srand.c index 8586afca117..0941fc8bd7d 100644 --- a/libc/stdlib/lib_srand.c +++ b/libc/stdlib/lib_srand.c @@ -233,7 +233,7 @@ static double_t frand3(void) * Name: srand * * Description: - * Seed the confluent hypergeometric random number generator. + * Seed the congruential random number generator. * ****************************************************************************/ @@ -254,7 +254,7 @@ void srand(unsigned int seed) * Name: nrand * * Description: - * Return a random unsigned long value in the range of 0 to (limit - 1) + * Return a random, unsigned long value in the range of 0 to (limit - 1) * ****************************************************************************/ @@ -267,7 +267,7 @@ unsigned long nrand(unsigned long limit) do { - /* Get a random integer in the requested range */ + /* Get a random integer in the range 0.0 - 1.0 */ #if (CONFIG_LIB_RAND_ORDER == 1) ratio = frand1(); @@ -277,9 +277,13 @@ unsigned long nrand(unsigned long limit) ratio = frand3(); #endif - /* Then, produce the return-able value */ + /* Then, produce the return-able value in the requested range */ result = (unsigned long)(((double_t)limit) * ratio); + + /* Loop because there is a (unlikely) possibility that round could but + * the result at the limit value. + */ } while (result >= limit); From 76dc238baf46c8321603900b78dec297bff5f0b5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 09:44:27 -0600 Subject: [PATCH 059/152] Add more name mappings to nuttx-names.dat --- arch/sim/src/nuttx-names.dat | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/sim/src/nuttx-names.dat b/arch/sim/src/nuttx-names.dat index 400a591ec29..13c064b1778 100644 --- a/arch/sim/src/nuttx-names.dat +++ b/arch/sim/src/nuttx-names.dat @@ -1,7 +1,9 @@ _exit NX_exit accept NXaccept asprintf NXasprintf +basename NXbasename calloc NXcalloc +chdir NXchdir clearenv NXclearenv clock_gettime NXclock_gettime close NXclose @@ -22,6 +24,7 @@ fread NXfread fseek NXfseek fwrite NXfwrite fsync NXfsync +ftell NXftell getenv NXgetenv getopt NXgetopt getpid NXgetpid @@ -34,8 +37,10 @@ lseek NXlseek mallinfo NXmallinfo malloc NXmalloc malloc_init NXmalloc_init +memcmp NXmemcmp memcpy NXmemcpy memset NXmemset +mkfifo NXmkfifo mktime NXmktime mq_close NXmq_close mkdir NXmkdir @@ -59,12 +64,15 @@ pthread_mutex_unlock NXpthread_mutex_unlock pthread_setspecific NXpthread_setspecific pthread_sigmask NXpthread_sigmask pthread_yield NXpthread_yield +ptsname NXptsname +ptsname_r NXptsname_r puts NXputs read NXread readdir NXreaddir realloc NXrealloc recv NXrecv recvfrom NXrecvfrom +rename NXrename rewinddir NXrewinddir rmdir NXrmdir sched_yield NXsched_yield @@ -80,8 +88,11 @@ setenv NXsetenv setlogmask NXsetlogmask setsockopt NXsetsockopt sigaction NXsigaction +sigdelset NXsigdelset sigemptyset NXsigemptyset +sigfillset NXsigfillset sighold NXsighold +sigismember NXsigismember sigprocmask NXsigprocmask sigtimedwait NXsigtimedwait sigrelse NXsigrelse @@ -91,7 +102,9 @@ socket NXsocket sprintf NXsprintf stat NXstat statfs NXstatfs +strcat NXstrcat strchr NXstrchr +strcmp NXstrcmp strcpy NXstrcpy strcspn NXstrcspn strdup NXstrdup @@ -100,17 +113,22 @@ strlen NXstrlen strncasecmp NXstrncasecmp strncmp NXstrncmp strncpy NXstrncpy +strrchr NXstrrchr strtok_r NXstrtok_r +strtol NXstrtol +strtoul NXstrtoul syslog NXsyslog system NXsystem tcgetattr NXtcgetattr tcsetattr NXtcsetattr umount2 NXumount2 unlink NXunlink +unlockpt NXunlockpt +uname NXuname unsetenv NXunsetenv usleep NXusleep vasprintf NXvasprintf vfork NXvfork -vfprint NXvfprint +vfprintf NXvfprintf write NXwrite zmalloc NXzmalloc From 1b7455c1713d72e3149ee93333772b7f3ea8fed9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 11:09:01 -0600 Subject: [PATCH 060/152] Update comments in a Kconfig --- drivers/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/Kconfig b/drivers/Kconfig index aba608676c9..1f0f7dbe3c4 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -33,6 +33,14 @@ config DEV_RANDOM config DEV_URANDOM bool "Enable /dev/urandom" default n + ---help--- + Enable support for /dev/urandom provided by a software PRNG + implementation. + + NOTE: This option may not be cryptographially secure and should not + be enabled if you are concerned about cyptographically secure + pseudo-random numbers (CPRNG) and do not know the characteristics + of the software PRNG impelementation! if DEV_URANDOM @@ -46,6 +54,8 @@ config DEV_URANDOM_XORSHIFT128 xorshift128 is a pseudorandom number generator that's simple, portable, and can also be used on 8-bit and 16-bit MCUs. + NOTE: Not cyptographically secure + config DEV_URANDOM_CONGRUENTIAL bool "Conguential" ---help--- @@ -54,6 +64,9 @@ config DEV_URANDOM_CONGRUENTIAL point. NOTE: Good randomness from the congruential generator also requires that you also select CONFIG_LIB_RAND_ORDER > 2 + NOTE: Cyptographically secure? Certainly not if CONFIG_LIB_RAND_ORDER + is small. + endchoice # /dev/urandom algorithm endif # DEV_URANDOM From 69637bf825d7c631ff45b870179c1b8c58c6b8d7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 13:39:21 -0600 Subject: [PATCH 061/152] Costmetic changes to better match coding style --- fs/hostfs/hostfs.c | 187 ++++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 89 deletions(-) diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c index ee57d8295f5..e4a09658ac4 100644 --- a/fs/hostfs/hostfs.c +++ b/fs/hostfs/hostfs.c @@ -161,7 +161,7 @@ const struct mountpt_operations hostfs_operations = * Name: hostfs_semtake ****************************************************************************/ -void hostfs_semtake(struct hostfs_mountpt_s *fs) +void hostfs_semtake(FAR struct hostfs_mountpt_s *fs) { /* Take the semaphore (perhaps waiting) */ @@ -179,7 +179,7 @@ void hostfs_semtake(struct hostfs_mountpt_s *fs) * Name: hostfs_semgive ****************************************************************************/ -void hostfs_semgive(struct hostfs_mountpt_s *fs) +void hostfs_semgive(FAR struct hostfs_mountpt_s *fs) { sem_post(fs->fs_sem); } @@ -191,12 +191,13 @@ void hostfs_semgive(struct hostfs_mountpt_s *fs) * ****************************************************************************/ -static void hostfs_mkpath(struct hostfs_mountpt_s *fs, const char *relpath, - char *path, int pathlen) +static void hostfs_mkpath(FAR struct hostfs_mountpt_s *fs, + FAR const char *relpath, + FAR char *path, int pathlen) { - int depth = 0; - int first; - int x; + int depth = 0; + int first; + int x; /* Copy base host path to output */ @@ -247,14 +248,14 @@ static void hostfs_mkpath(struct hostfs_mountpt_s *fs, const char *relpath, * Name: hostfs_open ****************************************************************************/ -static int hostfs_open(FAR struct file *filep, const char *relpath, +static int hostfs_open(FAR struct file *filep, FAR const char *relpath, int oflags, mode_t mode) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - int ret; - struct hostfs_ofile_s *hf; - char path[HOSTFS_MAX_PATH]; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -335,11 +336,11 @@ errout_with_semaphore: static int hostfs_close(FAR struct file *filep) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; - struct hostfs_ofile_s *nextfile; - struct hostfs_ofile_s *prevfile; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + FAR struct hostfs_ofile_s *nextfile; + FAR struct hostfs_ofile_s *prevfile; /* Sanity checks */ @@ -415,12 +416,13 @@ okout: * Name: hostfs_read ****************************************************************************/ -static ssize_t hostfs_read(FAR struct file *filep, char *buffer, size_t buflen) +static ssize_t hostfs_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; - int ret = OK; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + int ret = OK; /* Sanity checks */ @@ -453,10 +455,10 @@ static ssize_t hostfs_read(FAR struct file *filep, char *buffer, size_t buflen) static ssize_t hostfs_write(FAR struct file *filep, const char *buffer, size_t buflen) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; - int ret; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + int ret; /* Sanity checks. I have seen the following assertion misfire if * CONFIG_DEBUG_MM is enabled while re-directing output to a @@ -511,10 +513,10 @@ errout_with_semaphore: static off_t hostfs_seek(FAR struct file *filep, off_t offset, int whence) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; - int ret; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + int ret; /* Sanity checks */ @@ -546,10 +548,10 @@ static off_t hostfs_seek(FAR struct file *filep, off_t offset, int whence) static int hostfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; - int ret; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; + int ret; /* Sanity checks */ @@ -585,9 +587,9 @@ static int hostfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) static int hostfs_sync(FAR struct file *filep) { - struct inode *inode; - struct hostfs_mountpt_s *fs; - struct hostfs_ofile_s *hf; + FAR struct inode *inode; + FAR struct hostfs_mountpt_s *fs; + FAR struct hostfs_ofile_s *hf; /* Sanity checks */ @@ -620,7 +622,7 @@ static int hostfs_sync(FAR struct file *filep) static int hostfs_dup(FAR const struct file *oldp, FAR struct file *newp) { - struct hostfs_ofile_s *sf; + FAR struct hostfs_ofile_s *sf; /* Sanity checks */ @@ -649,11 +651,12 @@ static int hostfs_dup(FAR const struct file *oldp, FAR struct file *newp) * ****************************************************************************/ -static int hostfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir) +static int hostfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct fs_dirent_s *dir) { - struct hostfs_mountpt_s *fs; - int ret; - char path[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -696,7 +699,8 @@ errout_with_semaphore: * ****************************************************************************/ -static int hostfs_closedir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) +static int hostfs_closedir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir) { struct hostfs_mountpt_s *fs; @@ -727,11 +731,12 @@ static int hostfs_closedir(FAR struct inode *mountpt, FAR struct fs_dirent_s *di * ****************************************************************************/ -static int hostfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) +static int hostfs_readdir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir) { - struct hostfs_mountpt_s *fs; - int ret; - struct host_dirent_s entry; + FAR struct hostfs_mountpt_s *fs; + FAR struct host_dirent_s entry; + int ret; /* Sanity checks */ @@ -754,6 +759,7 @@ static int hostfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) if (ret == OK) { /* Copy the entry name */ + memset(dir->fd_dir.d_name, 0, sizeof(dir->fd_dir.d_name)); strncpy(dir->fd_dir.d_name, entry.d_name, sizeof(dir->fd_dir.d_name)); @@ -775,7 +781,8 @@ static int hostfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) * ****************************************************************************/ -static int hostfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) +static int hostfs_rewinddir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir) { /* Sanity checks */ @@ -799,13 +806,14 @@ static int hostfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) * ****************************************************************************/ -static int hostfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle) +static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle) { - struct hostfs_mountpt_s *fs; - struct host_stat_s buf; - int ret, len; - const char * options; + FAR struct hostfs_mountpt_s *fs; + struct host_stat_s buf; + FAR const char *options; + int len; + int ret; /* Validate the block driver is NULL */ @@ -896,7 +904,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, const void *data, ****************************************************************************/ static int hostfs_unbind(FAR void *handle, FAR struct inode **blkdriver, - unsigned int flags) + unsigned int flags) { FAR struct hostfs_mountpt_s *fs = (FAR struct hostfs_mountpt_s *)handle; int ret; @@ -935,10 +943,10 @@ static int hostfs_unbind(FAR void *handle, FAR struct inode **blkdriver, * ****************************************************************************/ -static int hostfs_statfs(struct inode *mountpt, struct statfs *buf) +static int hostfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) { - struct hostfs_mountpt_s *fs; - struct host_statfs_s host_buf; + FAR struct hostfs_mountpt_s *fs; + struct host_statfs_s host_buf; int ret; /* Sanity checks */ @@ -961,12 +969,12 @@ static int hostfs_statfs(struct inode *mountpt, struct statfs *buf) ret = host_statfs(fs->fs_root, &host_buf); buf->f_namelen = host_buf.f_namelen; - buf->f_bsize = host_buf.f_bsize; - buf->f_blocks = host_buf.f_blocks; - buf->f_bfree = host_buf.f_bfree; - buf->f_bavail = host_buf.f_bavail; - buf->f_files = host_buf.f_files; - buf->f_ffree = host_buf.f_ffree; + buf->f_bsize = host_buf.f_bsize; + buf->f_blocks = host_buf.f_blocks; + buf->f_bfree = host_buf.f_bfree; + buf->f_bavail = host_buf.f_bavail; + buf->f_files = host_buf.f_files; + buf->f_ffree = host_buf.f_ffree; hostfs_semgive(fs); return ret; @@ -979,11 +987,11 @@ static int hostfs_statfs(struct inode *mountpt, struct statfs *buf) * ****************************************************************************/ -static int hostfs_unlink(struct inode *mountpt, const char *relpath) +static int hostfs_unlink(FAR struct inode *mountpt, FAR const char *relpath) { - struct hostfs_mountpt_s *fs; - int ret; - char path[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -1014,11 +1022,12 @@ static int hostfs_unlink(struct inode *mountpt, const char *relpath) * ****************************************************************************/ -static int hostfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) +static int hostfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath, + mode_t mode) { - struct hostfs_mountpt_s *fs; - int ret; - char path[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -1049,11 +1058,11 @@ static int hostfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) * ****************************************************************************/ -int hostfs_rmdir(struct inode *mountpt, const char *relpath) +int hostfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath) { - struct hostfs_mountpt_s *fs; - int ret; - char path[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -1086,13 +1095,13 @@ int hostfs_rmdir(struct inode *mountpt, const char *relpath) * ****************************************************************************/ -int hostfs_rename(struct inode *mountpt, const char *oldrelpath, - const char *newrelpath) +int hostfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath, + FAR const char *newrelpath) { - struct hostfs_mountpt_s *fs; - int ret; - char oldpath[HOSTFS_MAX_PATH]; - char newpath[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + char oldpath[HOSTFS_MAX_PATH]; + char newpath[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -1126,12 +1135,13 @@ int hostfs_rename(struct inode *mountpt, const char *oldrelpath, * ****************************************************************************/ -static int hostfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) +static int hostfs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf) { - struct hostfs_mountpt_s *fs; - int ret; - struct host_stat_s host_buf; - char path[HOSTFS_MAX_PATH]; + FAR struct hostfs_mountpt_s *fs; + struct host_stat_s host_buf; + char path[HOSTFS_MAX_PATH]; + int ret; /* Sanity checks */ @@ -1150,7 +1160,6 @@ static int hostfs_stat(struct inode *mountpt, const char *relpath, struct stat * /* Call the host FS to do the mkdir */ ret = host_stat(path, &host_buf); - if (ret != 0) { goto errout_with_semaphore; From 2b28a1f3e5fd62a3c59989e21b8b5a950339ff5c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 15:59:45 -0600 Subject: [PATCH 062/152] SIM HOSTFS: First cut at changes to get it working on Cygwin. --- arch/sim/src/up_hostfs.c | 120 ++++++++++++++--------------- fs/hostfs/hostfs.c | 88 ++------------------- include/nuttx/fs/hostfs.h | 158 ++++++++++++++++++++++++++------------ 3 files changed, 169 insertions(+), 197 deletions(-) diff --git a/arch/sim/src/up_hostfs.c b/arch/sim/src/up_hostfs.c index f0928ed0dac..9a4a0ed4332 100644 --- a/arch/sim/src/up_hostfs.c +++ b/arch/sim/src/up_hostfs.c @@ -36,6 +36,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ + #define _BSD_SOURCE #include @@ -50,6 +51,7 @@ #include #include +#define __SIM__ 1 #include "hostfs.h" /**************************************************************************** @@ -62,40 +64,44 @@ int host_open(const char *pathname, int flags, int mode) /* Perform flag mapping */ - if ((flags & (HOSTFS_FLAG_RDOK | HOSTFS_FLAG_WROK)) == - (HOSTFS_FLAG_RDOK | HOSTFS_FLAG_WROK)) + if ((flags & NUTTX_O_RDWR) == NUTTX_O_RDWR) { mapflags = O_RDWR; } - else if (flags & HOSTFS_FLAG_RDOK) + else if (flags & NUTTX_O_RDONLY) { mapflags = O_RDONLY; } - else if (flags & HOSTFS_FLAG_WROK) + else if (flags & NUTTX_O_WRONLY) { mapflags = O_WRONLY; } - if (flags & HOSTFS_FLAG_APPEND) + if (flags & NUTTX_O_APPEND) { mapflags |= O_APPEND; } - if (flags & HOSTFS_FLAG_CREAT) + if (flags & NUTTX_O_CREAT) { mapflags |= O_CREAT; } - if (flags & HOSTFS_FLAG_EXCL) + if (flags & NUTTX_O_EXCL) { mapflags |= O_EXCL; } - if (flags & HOSTFS_FLAG_TRUNC) + if (flags & NUTTX_O_TRUNC) { mapflags |= O_TRUNC; } + if (flags & NUTTX_O_NONBLOCK) + { + mapflags |= O_NONBLOCK; + } + return open(pathname, mapflags, mode); } @@ -180,14 +186,14 @@ int host_dup(int fd) void *host_opendir(const char *name) { - return (void *) opendir(name); + return (void *)opendir(name); } /**************************************************************************** * Public Functions ****************************************************************************/ -int host_readdir(void* dirp, struct host_dirent_s* entry) +int host_readdir(void* dirp, struct nuttx_dirent_s* entry) { struct dirent *ent; @@ -206,19 +212,19 @@ int host_readdir(void* dirp, struct host_dirent_s* entry) entry->d_type = 0; if (ent->d_type == DT_REG) { - entry->d_type = HOSTFS_DTYPE_FILE; + entry->d_type = NUTTX_DTYPE_FILE; } else if (ent->d_type == DT_CHR) { - entry->d_type = HOSTFS_DTYPE_CHR; + entry->d_type = NUTTX_DTYPE_CHR; } else if (ent->d_type == DT_BLK) { - entry->d_type = HOSTFS_DTYPE_BLK; + entry->d_type = NUTTX_DTYPE_BLK; } else if (ent->d_type == DT_DIR) { - entry->d_type = HOSTFS_DTYPE_DIRECTORY; + entry->d_type = NUTTX_DTYPE_DIRECTORY; } } @@ -254,7 +260,7 @@ int host_closedir(void* dirp) * Public Functions ****************************************************************************/ -int host_statfs(const char *path, struct host_statfs_s *buf) +int host_statfs(const char *path, struct nuttx_statfs_s *buf) { int ret; struct statfs host_buf; @@ -263,18 +269,16 @@ int host_statfs(const char *path, struct host_statfs_s *buf) ret = statfs(path, &host_buf); - /* Map the return values */ + /* Map the struct statfs value */ buf->f_type = host_buf.f_type; + buf->f_namelen = host_buf.f_namelen; buf->f_bsize = host_buf.f_bsize; buf->f_blocks = host_buf.f_blocks; buf->f_bfree = host_buf.f_bfree; buf->f_bavail = host_buf.f_bavail; buf->f_files = host_buf.f_files; buf->f_ffree = host_buf.f_ffree; - buf->f_fsid = 0; - buf->f_namelen = host_buf.f_namelen; - buf->f_frsize = host_buf.f_frsize; return ret; } @@ -321,62 +325,50 @@ int host_rename(const char *oldpath, const char *newpath) * Public Functions ****************************************************************************/ -int host_stat(const char *path, struct host_stat_s *buf) +int host_stat(const char *path, struct nuttx_stat_s *buf) { - struct stat host_buf; - int ret; + struct stat host_buf; + int ret; /* Call the host's stat routine */ ret = stat(path, &host_buf); - /* Now map the return values to the common struct */ + /* Map the return values */ - buf->st_dev = host_buf.st_dev; /* ID of the device containing file */ - buf->st_ino = host_buf.st_ino;; /* inode number */ - buf->st_nlink = host_buf.st_nlink; /* number of hard links */ - buf->st_uid = host_buf.st_uid; /* user ID of owner */ - buf->st_gid = host_buf.st_gid; /* group ID of owner */ - buf->st_rdev = host_buf.st_rdev; /* device ID */ - buf->st_size = host_buf.st_size; /* total size, in bytes */ - buf->st_blksize = host_buf.st_blksize; /* blocksize for file system I/O */ - buf->st_blocks = host_buf.st_blocks; /* number of 512B blocks allocated */ - buf->st_atim = host_buf.st_atime; /* time of last access */ - buf->st_mtim = host_buf.st_mtime; /* time of last modification */ - buf->st_ctim = host_buf.st_ctime; /* time of last status change */ + buf->st_mode = host_buf.st_mode & 0777; - /* Map the mode bits */ - - buf->st_mode = host_buf.st_mode & 0xFFF; - if (S_ISREG(host_buf.st_mode)) + if (host_buf.st_mode & S_IFDIR) { - buf->st_mode |= HOST_ST_MODE_REG; + buf->st_mode |= NUTTX_S_IFDIR; + } + else if (host_buf.st_mode & S_IFREG) + { + buf->st_mode |= NUTTX_S_IFREG; + } + else if (host_buf.st_mode & S_IFCHR) + { + buf->st_mode |= NUTTX_S_IFCHR; + } + else if (host_buf.st_mode & S_IFBLK) + { + buf->st_mode |= NUTTX_S_IFBLK; + } + else if (host_buf.st_mode & S_IFLNK) + { + buf->st_mode |= NUTTX_S_IFLNK; + } + else /* if (host_buf.st_mode & S_IFIFO) */ + { + buf->st_mode |= NUTTX_S_IFIFO; } - if (S_ISDIR(host_buf.st_mode)) - { - buf->st_mode |= HOST_ST_MODE_DIR; - } - - if (S_ISCHR(host_buf.st_mode)) - { - buf->st_mode |= HOST_ST_MODE_CHR; - } - - if (S_ISBLK(host_buf.st_mode)) - { - buf->st_mode |= HOST_ST_MODE_BLK; - } - - if (S_ISFIFO(host_buf.st_mode)) - { - buf->st_mode |= HOST_ST_MODE_PIPE; - } - - if (S_ISLNK(host_buf.st_mode)) - { - buf->st_mode |= HOST_ST_MODE_LINK; - } + buf->st_size = host_buf.st_size; + buf->st_blksize = host_buf.st_blksize; + buf->st_blocks = host_buf.st_blocks; + buf->st_atim = host_buf.st_atim.tv_sec; + buf->st_mtim = host_buf.st_mtim.tv_sec; + buf->st_ctim = host_buf.st_ctim.tv_sec; return ret; } diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c index e4a09658ac4..afd3f9f1259 100644 --- a/fs/hostfs/hostfs.c +++ b/fs/hostfs/hostfs.c @@ -677,7 +677,6 @@ static int hostfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, /* Call the host's opendir function */ dir->u.hostfs.fs_dir = host_opendir(path); - if (dir->u.hostfs.fs_dir == NULL) { ret = -ENOENT; @@ -735,7 +734,7 @@ static int hostfs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) { FAR struct hostfs_mountpt_s *fs; - FAR struct host_dirent_s entry; + struct dirent entry; int ret; /* Sanity checks */ @@ -754,22 +753,6 @@ static int hostfs_readdir(FAR struct inode *mountpt, ret = host_readdir(dir->u.hostfs.fs_dir, &entry); - /* Save the entry name when successful */ - - if (ret == OK) - { - /* Copy the entry name */ - - memset(dir->fd_dir.d_name, 0, sizeof(dir->fd_dir.d_name)); - strncpy(dir->fd_dir.d_name, entry.d_name, sizeof(dir->fd_dir.d_name)); - - /* Copy the entry type */ - - /* TODO: May need to do some type mapping */ - - dir->fd_dir.d_type = entry.d_type; - } - hostfs_semgive(fs); return ret; } @@ -810,7 +793,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle) { FAR struct hostfs_mountpt_s *fs; - struct host_stat_s buf; + struct stat buf; FAR const char *options; int len; int ret; @@ -879,7 +862,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data, /* Try to stat the file in the host FS */ ret = host_stat(fs->fs_root, &buf); - if ((ret != 0) || ((buf.st_mode & HOST_ST_MODE_DIR) == 0)) + if (ret != 0 || (buf.st_mode & S_IFDIR) == 0) { hostfs_semgive(fs); kmm_free(fs); @@ -946,7 +929,6 @@ static int hostfs_unbind(FAR void *handle, FAR struct inode **blkdriver, static int hostfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) { FAR struct hostfs_mountpt_s *fs; - struct host_statfs_s host_buf; int ret; /* Sanity checks */ @@ -966,15 +948,7 @@ static int hostfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) /* Call the host fs to perform the statfs */ - ret = host_statfs(fs->fs_root, &host_buf); - - buf->f_namelen = host_buf.f_namelen; - buf->f_bsize = host_buf.f_bsize; - buf->f_blocks = host_buf.f_blocks; - buf->f_bfree = host_buf.f_bfree; - buf->f_bavail = host_buf.f_bavail; - buf->f_files = host_buf.f_files; - buf->f_ffree = host_buf.f_ffree; + ret = host_statfs(fs->fs_root, buf); hostfs_semgive(fs); return ret; @@ -1139,7 +1113,6 @@ static int hostfs_stat(FAR struct inode *mountpt, FAR const char *relpath, FAR struct stat *buf) { FAR struct hostfs_mountpt_s *fs; - struct host_stat_s host_buf; char path[HOSTFS_MAX_PATH]; int ret; @@ -1157,59 +1130,10 @@ static int hostfs_stat(FAR struct inode *mountpt, FAR const char *relpath, hostfs_mkpath(fs, relpath, path, sizeof(path)); - /* Call the host FS to do the mkdir */ + /* Call the host FS to do the stat operation */ - ret = host_stat(path, &host_buf); - if (ret != 0) - { - goto errout_with_semaphore; - } + ret = host_stat(path, buf); - /* Initialize the stat structure */ - - memset(buf, 0, sizeof(struct stat)); - - buf->st_mode = host_buf.st_mode & 0xFFF; - - if (host_buf.st_mode & HOST_ST_MODE_DIR) - { - buf->st_mode |= S_IFDIR; - } - - if (host_buf.st_mode & HOST_ST_MODE_REG) - { - buf->st_mode |= S_IFREG; - } - - if (host_buf.st_mode & HOST_ST_MODE_CHR) - { - buf->st_mode |= S_IFCHR; - } - - if (host_buf.st_mode & HOST_ST_MODE_BLK) - { - buf->st_mode |= S_IFBLK; - } - - if (host_buf.st_mode & HOST_ST_MODE_LINK) - { - buf->st_mode |= S_IFLNK; - } - - if (host_buf.st_mode & HOST_ST_MODE_PIPE) - { - buf->st_mode |= S_IFIFO; - } - - buf->st_size = host_buf.st_size; - buf->st_blksize = host_buf.st_blksize; - buf->st_blocks = host_buf.st_blocks; - buf->st_atime = host_buf.st_atim; - buf->st_ctime = host_buf.st_ctim; - - ret = OK; - -errout_with_semaphore: hostfs_semgive(fs); return ret; } diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h index 0a57797e57b..e82d0a3af5d 100644 --- a/include/nuttx/fs/hostfs.h +++ b/include/nuttx/fs/hostfs.h @@ -40,94 +40,150 @@ * Included Files ****************************************************************************/ +#ifndef __SIM__ +# include +# include +# include +# include +# include +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#define HOST_ST_MODE_REG 0x01000 -#define HOST_ST_MODE_DIR 0x02000 -#define HOST_ST_MODE_CHR 0x04000 -#define HOST_ST_MODE_BLK 0x08000 -#define HOST_ST_MODE_PIPE 0x10000 -#define HOST_ST_MODE_LINK 0x20000 +#ifdef __SIM__ -#define HOSTFS_FLAG_RDOK 0x0001 -#define HOSTFS_FLAG_WROK 0x0002 -#define HOSTFS_FLAG_CREAT 0x0004 -#define HOSTFS_FLAG_EXCL 0x0008 -#define HOSTFS_FLAG_APPEND 0x0010 -#define HOSTFS_FLAG_TRUNC 0x0020 +/* These must exactly match the definitions from include/dirent.h: */ -#define HOSTFS_DTYPE_FILE 0x0001 -#define HOSTFS_DTYPE_CHR 0x0002 -#define HOSTFS_DTYPE_BLK 0x0004 -#define HOSTFS_DTYPE_DIRECTORY 0x0008 +#define NUTTX_DTYPE_FILE 0x01 +#define NUTTX_DTYPE_CHR 0x02 +#define NUTTX_DTYPE_BLK 0x04 +#define NUTTX_DTYPE_DIRECTORY 0x08 + +/* These must exactly match the definitions from include/sys/stat.h: */ + +#define NUTTX_S_IFIFO 0010000 +#define NUTTX_S_IFCHR 0020000 +#define NUTTX_S_IFDIR 0040000 +#define NUTTX_S_IFBLK 0060000 +#define NUTTX_S_IFREG 0100000 +#define NUTTX_S_IFLNK 0120000 + +/* These must exactly match the definitions from include/fctnl.h: */ + +#define NUTTX_O_RDONLY (1 << 0) /* Open for read access (only) */ +#define NUTTX_O_WRONLY (1 << 1) /* Open for write access (only) */ +#define NUTTX_O_CREAT (1 << 2) /* Create file/sem/mq object */ +#define NUTTX_O_EXCL (1 << 3) /* Name must not exist when opened */ +#define NUTTX_O_APPEND (1 << 4) /* Keep contents, append to end */ +#define NUTTX_O_TRUNC (1 << 5) /* Delete contents */ +#define NUTTX_O_NONBLOCK (1 << 6) /* Don't wait for data */ +#define NUTTX_O_SYNC (1 << 7) /* Synchronize output on write */ +#define NUTTX_O_BINARY (1 << 8) /* Open the file in binary mode. */ + +#define NUTTX_O_RDWR (NUTTX_O_RDONLY | NUTTX_O_WRONLY) + +#endif /* __SIM__ */ /**************************************************************************** * Public Type Definitions ****************************************************************************/ -struct host_dirent_s +#ifdef __SIM__ + +/* These must match the definitions in include/sys/types.h */ + +typedef uintptr_t nuttx_size_t; +typedef int32_t nuttx_off_t; +typedef unsigned int nuttx_mode_t; +typedef int16_t nuttx_blksize_t; +typedef uint32_t nuttx_blkcnt_t; + +/* These must match the definition in include/time.h */ + +typedef uint32_t nuttx_time_t; + +/* These must exactly match the definition from include/dirent.h: */ + +struct nuttx_dirent_s { - size_t d_ino; - size_t d_off; - unsigned short d_reclen; - unsigned char d_type; - char d_name[256]; + uint8_t d_type; /* type of file */ + char d_name[NAME_MAX+1]; /* filename */ }; -struct host_statfs_s +/* These must exactly match the definition from include/sys/statfs.h: */ + +struct nuttx_statfs_s { - size_t f_type; /* Type of file system */ - size_t f_bsize; /* Optimal transfer block size */ - size_t f_blocks; /* Total data blocks in the file system */ - size_t f_bfree; /* Free blocks */ - size_t f_bavail; /* Free blocks available */ - size_t f_files; /* Total file nodes in file system */ - size_t f_ffree; /* Free file nodes in fs */ - size_t f_fsid; /* File Systme ID */ - size_t f_namelen; /* Max length of filenames */ - size_t f_frsize; /* Fragment size */ + uint32_t f_type; /* Type of filesystem */ + nuttx_size_t f_namelen; /* Maximum length of filenames */ + nuttx_size_t f_bsize; /* Optimal block size for transfers */ + nuttx_off_t f_blocks; /* Total data blocks in the file system of this size */ + nuttx_off_t f_bfree; /* Free blocks in the file system */ + nuttx_off_t f_bavail; /* Free blocks avail to non-superuser */ + nuttx_off_t f_files; /* Total file nodes in the file system */ + nuttx_off_t f_ffree; /* Free file nodes in the file system */ }; -struct host_stat_s +/* These must exactly match the definition from include/sys/stat.h: */ + +struct nuttx_stat_s { - int st_dev; /* ID of the device containing file */ - size_t st_ino; /* inode number */ - size_t st_mode; /* protection */ - size_t st_nlink; /* number of hard links */ - size_t st_uid; /* user ID of owner */ - size_t st_gid; /* group ID of owner */ - size_t st_rdev; /* device ID */ - size_t st_size; /* total size, in bytes */ - size_t st_blksize; /* blocksize for file system I/O */ - size_t st_blocks; /* number of 512B blocks allocated */ - size_t st_atim; /* time of last access */ - size_t st_mtim; /* time of last modification */ - size_t st_ctim; /* time of last status change */ + nuttx_mode_t st_mode; /* File type, atributes, and access mode bits */ + nuttx_off_t st_size; /* Size of file/directory, in bytes */ + nuttx_blksize_t st_blksize; /* Blocksize used for filesystem I/O */ + nuttx_blkcnt_t st_blocks; /* Number of blocks allocated */ + nuttx_time_t st_atim; /* Time of last access */ + nuttx_time_t st_mtim; /* Time of last modification */ + nuttx_time_t st_ctim; /* Time of last status change */ }; +#endif /* __SIM__ */ + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +#ifdef __SIM__ int host_open(const char *pathname, int flags, int mode); int host_close(int fd); -ssize_t host_read(int fd, void* buf, size_t count); +ssize_t host_read(int fd, void *buf, nuttx_size_t count); +ssize_t host_write(int fd, const void *buf, nuttx_size_t count); +off_t host_lseek(int fd, off_t offset, int whence); +int host_ioctl(int fd, int request, unsigned long arg); +void host_sync(int fd); +int host_dup(int fd); +void *host_opendir(const char *name); +int host_readdir(void* dirp, struct nuttx_dirent_s* entry); +void host_rewinddir(void* dirp); +int host_closedir(void* dirp); +int host_statfs(const char *path, struct nuttx_statfs_s *buf); +int host_unlink(const char *pathname); +int host_mkdir(const char *pathname, mode_t mode); +int host_rmdir(const char *pathname); +int host_rename(const char *oldpath, const char *newpath); +int host_stat(const char *path, struct nuttx_stat_s *buf); +#else +int host_open(const char *pathname, int flags, int mode); +int host_close(int fd); +ssize_t host_read(int fd, void *buf, size_t count); ssize_t host_write(int fd, const void *buf, size_t count); off_t host_lseek(int fd, off_t offset, int whence); int host_ioctl(int fd, int request, unsigned long arg); void host_sync(int fd); int host_dup(int fd); void *host_opendir(const char *name); -int host_readdir(void* dirp, struct host_dirent_s* entry); +int host_readdir(void* dirp, struct dirent *entry); void host_rewinddir(void* dirp); int host_closedir(void* dirp); -int host_statfs(const char *path, struct host_statfs_s *buf); +int host_statfs(const char *path, struct statfs *buf); int host_unlink(const char *pathname); int host_mkdir(const char *pathname, mode_t mode); int host_rmdir(const char *pathname); int host_rename(const char *oldpath, const char *newpath); -int host_stat(const char *path, struct host_stat_s *buf); +int host_stat(const char *path, struct stat *buf); + +#endif /* __SIM__ */ #endif /* __INCLUDE_NUTTX_FS_HOSTFS_H */ From 006f4a58189175bac72a618fd26d40137f5eb52f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 16:31:14 -0600 Subject: [PATCH 063/152] HOSTFS: Fix some errors in first cut at repartitioning --- arch/sim/src/up_hostfs.c | 10 +++------- fs/hostfs/hostfs.c | 3 +-- include/nuttx/fs/hostfs.h | 8 +++++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/sim/src/up_hostfs.c b/arch/sim/src/up_hostfs.c index 9a4a0ed4332..aeb566d5aed 100644 --- a/arch/sim/src/up_hostfs.c +++ b/arch/sim/src/up_hostfs.c @@ -195,12 +195,11 @@ void *host_opendir(const char *name) int host_readdir(void* dirp, struct nuttx_dirent_s* entry) { - struct dirent *ent; + struct dirent *ent; /* Call the host's readdir routine */ ent = readdir(dirp); - if (ent != NULL) { /* Copy the entry name */ @@ -226,10 +225,7 @@ int host_readdir(void* dirp, struct nuttx_dirent_s* entry) { entry->d_type = NUTTX_DTYPE_DIRECTORY; } - } - if (ent) - { return 0; } @@ -240,7 +236,7 @@ int host_readdir(void* dirp, struct nuttx_dirent_s* entry) * Public Functions ****************************************************************************/ -void host_rewinddir(void* dirp) +void host_rewinddir(void *dirp) { /* Just call the rewinddir routine */ @@ -251,7 +247,7 @@ void host_rewinddir(void* dirp) * Public Functions ****************************************************************************/ -int host_closedir(void* dirp) +int host_closedir(void *dirp) { return closedir(dirp); } diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c index afd3f9f1259..afee46afd46 100644 --- a/fs/hostfs/hostfs.c +++ b/fs/hostfs/hostfs.c @@ -734,7 +734,6 @@ static int hostfs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) { FAR struct hostfs_mountpt_s *fs; - struct dirent entry; int ret; /* Sanity checks */ @@ -751,7 +750,7 @@ static int hostfs_readdir(FAR struct inode *mountpt, /* Call the host OS's readdir function */ - ret = host_readdir(dir->u.hostfs.fs_dir, &entry); + ret = host_readdir(dir->u.hostfs.fs_dir, &dir->fd_dir); hostfs_semgive(fs); return ret; diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h index e82d0a3af5d..66cc304ee65 100644 --- a/include/nuttx/fs/hostfs.h +++ b/include/nuttx/fs/hostfs.h @@ -46,6 +46,8 @@ # include # include # include +#else +# include #endif /**************************************************************************** @@ -84,6 +86,10 @@ #define NUTTX_O_RDWR (NUTTX_O_RDONLY | NUTTX_O_WRONLY) +/* Should match definition in include/limits.h */ + +#define NUTTX_NAME_MAX 32 + #endif /* __SIM__ */ /**************************************************************************** @@ -109,7 +115,7 @@ typedef uint32_t nuttx_time_t; struct nuttx_dirent_s { uint8_t d_type; /* type of file */ - char d_name[NAME_MAX+1]; /* filename */ + char d_name[NUTTX_NAME_MAX+1]; /* filename */ }; /* These must exactly match the definition from include/sys/statfs.h: */ From fe315f867a63741cd377986b48cf293576c07074 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 Jul 2016 17:01:35 -0600 Subject: [PATCH 064/152] Costmetic --- arch/sim/src/up_hostfs.c | 2 ++ include/nuttx/fs/dirent.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/sim/src/up_hostfs.c b/arch/sim/src/up_hostfs.c index aeb566d5aed..5e1e1f79cb4 100644 --- a/arch/sim/src/up_hostfs.c +++ b/arch/sim/src/up_hostfs.c @@ -186,6 +186,8 @@ int host_dup(int fd) void *host_opendir(const char *name) { + /* Return the host DIR pointer */ + return (void *)opendir(name); } diff --git a/include/nuttx/fs/dirent.h b/include/nuttx/fs/dirent.h index efd270fbeec..f616f734737 100644 --- a/include/nuttx/fs/dirent.h +++ b/include/nuttx/fs/dirent.h @@ -184,7 +184,7 @@ struct fs_unionfsdir_s struct fs_hostfsdir_s { - FAR void * fs_dir; /* Opaque pointer to host DIR * */ + FAR void *fs_dir; /* Opaque pointer to host DIR * */ }; #endif From 39174da3be919d9ce4d6ca5284e2decd9b6c5ffc Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Sun, 17 Jul 2016 20:19:44 -0600 Subject: [PATCH 065/152] Remove naming conflict in drivers/mtd/filemntd.c --- drivers/mtd/filemtd.c | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c index 57c4f3d8349..6154de1d2d9 100644 --- a/drivers/mtd/filemtd.c +++ b/drivers/mtd/filemtd.c @@ -115,19 +115,19 @@ static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset, /* MTD driver methods */ -static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, +static int filemtd_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); -static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock, +static ssize_t filemtd_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf); -static ssize_t file_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, +static ssize_t filemtd_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buf); -static ssize_t file_byteread(FAR struct mtd_dev_s *dev, off_t offset, +static ssize_t filemtd_byteread(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buf); #ifdef CONFIG_MTD_BYTE_WRITE static ssize_t file_bytewrite(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR const uint8_t *buf); #endif -static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, +static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); /**************************************************************************** @@ -236,10 +236,10 @@ static ssize_t filemtd_read(FAR struct file_dev_s *priv, } /**************************************************************************** - * Name: file_erase + * Name: filemtd_erase ****************************************************************************/ -static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, +static int filemtd_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; @@ -289,10 +289,10 @@ static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, } /**************************************************************************** - * Name: file_bread + * Name: filemtd_bread ****************************************************************************/ -static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock, +static ssize_t filemtd_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; @@ -329,10 +329,10 @@ static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock, } /**************************************************************************** - * Name: file_bwrite + * Name: filemtd_bwrite ****************************************************************************/ -static ssize_t file_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, +static ssize_t filemtd_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buf) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; @@ -369,10 +369,10 @@ static ssize_t file_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, } /**************************************************************************** - * Name: file_byteread + * Name: filemtd_byteread ****************************************************************************/ -static ssize_t file_byteread(FAR struct mtd_dev_s *dev, off_t offset, +static ssize_t filemtd_byteread(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buf) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; @@ -419,10 +419,10 @@ static ssize_t file_bytewrite(FAR struct mtd_dev_s *dev, off_t offset, #endif /**************************************************************************** - * Name: file_ioctl + * Name: filemtd_ioctl ****************************************************************************/ -static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) +static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; int ret = -EINVAL; /* Assume good command with bad parameters */ @@ -456,7 +456,7 @@ static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) { /* Erase the entire device */ - file_erase(dev, 0, priv->nblocks); + filemtd_erase(dev, 0, priv->nblocks); ret = OK; } break; @@ -566,14 +566,14 @@ FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset, * nullified by kmm_zalloc). */ - priv->mtd.erase = file_erase; - priv->mtd.bread = file_bread; - priv->mtd.bwrite = file_bwrite; - priv->mtd.read = file_byteread; + priv->mtd.erase = filemtd_erase; + priv->mtd.bread = filemtd_bread; + priv->mtd.bwrite = filemtd_bwrite; + priv->mtd.read = filemtd_byteread; #ifdef CONFIG_MTD_BYTE_WRITE priv->mtd.write = file_bytewrite; #endif - priv->mtd.ioctl = file_ioctl; + priv->mtd.ioctl = filemtd_ioctl; priv->offset = offset; priv->nblocks = nblocks; @@ -632,7 +632,7 @@ bool filemtd_isfilemtd(FAR struct mtd_dev_s *dev) { FAR struct file_dev_s *priv = (FAR struct file_dev_s *) dev; - if (priv->mtd.erase == file_erase) + if (priv->mtd.erase == filemtd_erase) return 1; return 0; From bf25eef79fc52128065d262756e2cbeb92aa22de Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 06:43:08 -0600 Subject: [PATCH 066/152] Update comments in Kconfig --- drivers/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/Kconfig b/drivers/Kconfig index 1f0f7dbe3c4..87724553f52 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -64,8 +64,7 @@ config DEV_URANDOM_CONGRUENTIAL point. NOTE: Good randomness from the congruential generator also requires that you also select CONFIG_LIB_RAND_ORDER > 2 - NOTE: Cyptographically secure? Certainly not if CONFIG_LIB_RAND_ORDER - is small. + NOTE: Not cyptographically secure endchoice # /dev/urandom algorithm endif # DEV_URANDOM From e0aaa168aa2d1e729d0522fabec3aa3cc2a37e5d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 07:03:47 -0600 Subject: [PATCH 067/152] /dev/urandom: Add option to replace software PRNG with hardware TRNG. --- drivers/Kconfig | 19 ++++++++++++++++--- drivers/Makefile | 2 ++ drivers/dev_urandom.c | 4 ++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/Kconfig b/drivers/Kconfig index 87724553f52..5ee36f8a205 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -34,8 +34,8 @@ config DEV_URANDOM bool "Enable /dev/urandom" default n ---help--- - Enable support for /dev/urandom provided by a software PRNG - implementation. + Enable support for /dev/urandom provided by either a hardware TRNG or + by a software PRNG implementation. NOTE: This option may not be cryptographially secure and should not be enabled if you are concerned about cyptographically secure @@ -46,7 +46,8 @@ if DEV_URANDOM choice prompt "/dev/urandom algorithm" - default DEV_URANDOM_XORSHIFT128 + default DEV_URANDOM_ARCH if ARCH_HAVE_RNG + default DEV_URANDOM_XORSHIFT128 if !ARCH_HAVE_RNG config DEV_URANDOM_XORSHIFT128 bool "xorshift128" @@ -66,6 +67,18 @@ config DEV_URANDOM_CONGRUENTIAL NOTE: Not cyptographically secure +config DEV_URANDOM_ARCH + bool "Architecture-specific" + depends on ARCH_HAVE_RNG + ---help--- + The implementation of /dev/urandom is provided in archtecture- + specific logic using hardware TRNG logic. architecture-specific + logic must provide the whole implementation in this case, including + the function devurandom_register(). + + May or may not be cyptographically secure, depending upon the + implementation. + endchoice # /dev/urandom algorithm endif # DEV_URANDOM diff --git a/drivers/Makefile b/drivers/Makefile index cf97712926e..fefb6a718b5 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -100,9 +100,11 @@ ifeq ($(CONFIG_PWM),y) endif ifeq ($(CONFIG_DEV_URANDOM),y) +ifneq ($(CONFIG_DEV_URANDOM_ARCH),y) CSRCS += dev_urandom.c endif endif +endif # CONFIG_NFILE_DESCRIPTORS != 0 AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index b1ea3696650..0e0cf970313 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -53,6 +53,8 @@ #include #include +#if defined(CONFIG_DEV_URANDOM) && !defined(CONFIG_DEV_URANDOM_ARCH) + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -297,3 +299,5 @@ void devurandom_register(void) (void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL); } + +#endif /* CONFIG_DEV_URANDOM && CONFIG_DEV_URANDOM_ARCH */ From 6194467c130481961d15691a235df6a43eb0122f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 08:00:56 -0600 Subject: [PATCH 068/152] PTY: Fix termios read input processing.. what was I thinking? Also, if some data was read, pty_read() should not block on the empty FIFO. --- drivers/pipes/pipe_common.c | 3 +- drivers/serial/pty.c | 93 ++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 18 deletions(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index 759b7e474bc..74d36ec170c 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -397,7 +397,7 @@ int pipecommon_close(FAR struct file *filep) return OK; } #endif - } + } sem_post(&dev->d_bfsem); return OK; @@ -475,6 +475,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len) { dev->d_rdndx = 0; } + nread++; } diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index cda35f9912c..30bf4fbab19 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -57,6 +57,14 @@ #include "pty.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Should never be set... only for comparison to serial.c */ + +#undef CONFIG_PSEUDOTERM_FULLBLOCKS + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -180,7 +188,9 @@ static void pty_destroy(FAR struct pty_devpair_s *devpair) #endif (void)unregister_driver(devname); - /* Un-register the master device (/dev/ptyN may have already been unlinked) */ + /* Un-register the master device (/dev/ptyN may have already been + * unlinked). + */ snprintf(devname, 16, "/dev/pty%d", (int)devpair->pp_minor); (void)unregister_driver(devname); @@ -377,6 +387,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) ssize_t nread; size_t i; char ch; + int ret; #endif DEBUGASSERT(filep != NULL && filep->f_inode != NULL); @@ -389,24 +400,71 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) * * Specifically not handled: * - * All of the local modes; echo, line editing, etc. - * Anything to do with break or parity errors. - * ISTRIP - We should be 8-bit clean. - * IUCLC - Not Posix - * IXON/OXOFF - No xon/xoff flow control. + * All of the local modes; echo, line editing, etc. + * Anything to do with break or parity errors. + * ISTRIP - We should be 8-bit clean. + * IUCLC - Not Posix + * IXON/OXOFF - No xon/xoff flow control. */ if (dev->pd_iflag & (INLCR | IGNCR | ICRNL)) { - /* We will transfer one byte at a time, making the appropriae + /* We will transfer one byte at a time, making the appropriate * translations. */ ntotal = 0; for (i = 0; i < len; i++) { - ch = *buffer++; +#ifndef CONFIG_PSEUDOTERM_FULLBLOCKS + /* This logic should return if the pipe becomes empty after some + * bytes were read from the pipe. If we have already read some + * data, we use the FIONREAD ioctl to test if there are more bytes + * in the pipe. + * + * There is an inherent race condition in this test, but leaving + * a few bytes unnecessarily in the pipe should not be harmful. + * (we could lock the scheduler between the test and the + * file_read() below if we wanted to eliminate the race) + */ + if (ntotal > 0) + { + int nsrc; + + /* Check how many bytes are waiting in the pipe */ + + ret = file_ioctl(&dev->pd_src, FIONREAD, + (unsigned long)((uintptr_t)&nsrc)); + if (ret < 0) + { + ntotal = ret; + break; + } + + /* Break out of the loop and return ntotal if the pipe is + * empty. + */ + + if (nsrc < 1) + { + break; + } + } +#endif + + /* Read one byte from the source the byte. This call will block + * if the source pipe is empty. + */ + + nread = file_read(&dev->pd_src, &ch, 1); + if (nread < 0) + { + ntotal = nread; + break; + } + + /* Perform input processing */ /* \n -> \r or \r -> \n translation? */ if (ch == '\n' && (dev->pd_iflag & INLCR) != 0) @@ -424,17 +482,12 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) if (ch != '\r' || (dev->pd_iflag & IGNCR) == 0) { - /* Transfer the byte */ - nread = file_read(&dev->pd_src, &ch, 1); - if (nread < 0) - { - ntotal = nread; - break; - } - - /* Update the count of bytes transferred */ + /* Transfer the (possibly translated) character and update the + * count of bytes transferred. + */ + *buffer++ = ch; ntotal++; } } @@ -442,6 +495,12 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) else #endif { + /* NOTE: the source pipe will block is no data is available in + * the pipe. Otherwise, it will return data from the pipe. If + * there are fewer than 'len' bytes in the, it will return with + * ntotal < len. + */ + ntotal = file_read(&dev->pd_src, buffer, len); } From 1660329d0683f2e3e74834e5e76d90804ebf0baf Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 10:55:37 -0600 Subject: [PATCH 069/152] Rename up_rnginitialize to devrandom_register --- arch/arm/src/common/up_initialize.c | 2 +- arch/arm/src/common/up_internal.h | 6 ------ arch/arm/src/sama5/sam_trng.c | 16 +++++++++------- arch/arm/src/samv7/sam_trng.c | 16 +++++++++------- arch/arm/src/stm32/stm32_rng.c | 18 ++++++++++++++++-- arch/arm/src/stm32l4/stm32l4_rng.c | 18 ++++++++++++++++-- arch/avr/src/common/up_initialize.c | 2 +- arch/hc/src/common/up_initialize.c | 2 +- arch/mips/src/common/up_initialize.c | 2 +- arch/rgmp/src/nuttx.c | 2 +- arch/sh/src/common/up_initialize.c | 2 +- arch/sim/src/up_initialize.c | 2 +- arch/x86/src/common/up_initialize.c | 2 +- arch/z16/src/common/up_initialize.c | 2 +- arch/z80/src/common/up_initialize.c | 2 +- drivers/serial/pty.c | 8 +++++--- drivers/wireless/cc1101.c | 10 +++++++--- include/nuttx/fs/fs.h | 14 ++++++++++++++ 18 files changed, 86 insertions(+), 40 deletions(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 9e4477d76a1..9803304fd7a 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -260,7 +260,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h index feec4333558..36095a87a45 100644 --- a/arch/arm/src/common/up_internal.h +++ b/arch/arm/src/common/up_internal.h @@ -545,12 +545,6 @@ void up_usbuninitialize(void); # define up_usbuninitialize() #endif -/* Random Number Generator (RNG) ********************************************/ - -#ifdef CONFIG_DEV_RANDOM -void up_rnginitialize(void); -#endif - /* Debug ********************************************************************/ #ifdef CONFIG_STACK_COLORATION void up_stack_color(FAR void *stackbase, size_t nbytes); diff --git a/arch/arm/src/sama5/sam_trng.c b/arch/arm/src/sama5/sam_trng.c index a3eb102640e..b9294611423 100644 --- a/arch/arm/src/sama5/sam_trng.c +++ b/arch/arm/src/sama5/sam_trng.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sama5/sam_trng.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Derives, in part, from Max Holtzberg's STM32 RNG Nuttx driver: @@ -329,10 +329,10 @@ errout: ****************************************************************************/ /**************************************************************************** - * Name: up_rnginitialize + * Name: devrandom_register * * Description: - * Initialize the TRNG hardware and register the /dev/randome driver. + * Initialize the TRNG hardware and register the /dev/random driver. * * Input Parameters: * None @@ -342,7 +342,7 @@ errout: * ****************************************************************************/ -void up_rnginitialize(void) +int devrandom_register(void) { int ret; @@ -360,10 +360,11 @@ void up_rnginitialize(void) /* Initialize the TRNG interrupt */ - if (irq_attach(SAM_IRQ_TRNG, sam_interrupt)) + ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt); + if (ret < 0) { ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG); - return; + return ret; } /* Disable the interrupts at the TRNG */ @@ -380,10 +381,11 @@ void up_rnginitialize(void) if (ret < 0) { ferr("ERROR: Failed to register /dev/random\n"); - return; + return ret; } /* Enable the TRNG interrupt at the AIC */ up_enable_irq(SAM_IRQ_TRNG); + return OK; } diff --git a/arch/arm/src/samv7/sam_trng.c b/arch/arm/src/samv7/sam_trng.c index 7dc29a77d83..89c7630b21c 100644 --- a/arch/arm/src/samv7/sam_trng.c +++ b/arch/arm/src/samv7/sam_trng.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samv7/sam_trng.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Derives from the SAMA5D3 TRNG Nuttx driver which, in turn, derives, in @@ -330,10 +330,10 @@ errout: ****************************************************************************/ /**************************************************************************** - * Name: up_rnginitialize + * Name: devrandom_register * * Description: - * Initialize the TRNG hardware and register the /dev/randome driver. + * Initialize the TRNG hardware and register the /dev/random driver. * * Input Parameters: * None @@ -343,7 +343,7 @@ errout: * ****************************************************************************/ -void up_rnginitialize(void) +int devrandom_register(void) { int ret; @@ -361,10 +361,11 @@ void up_rnginitialize(void) /* Initialize the TRNG interrupt */ - if (irq_attach(SAM_IRQ_TRNG, sam_interrupt)) + ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt); + if (ret < 0) { ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG); - return; + return ret; } /* Disable the interrupts at the TRNG */ @@ -381,10 +382,11 @@ void up_rnginitialize(void) if (ret < 0) { ferr("ERROR: Failed to register /dev/random\n"); - return; + return ret; } /* Enable the TRNG interrupt at the AIC */ up_enable_irq(SAM_IRQ_TRNG); + return OK; } diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c index fce55ebf0a3..eda6f5d550c 100644 --- a/arch/arm/src/stm32/stm32_rng.c +++ b/arch/arm/src/stm32/stm32_rng.c @@ -258,8 +258,22 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen) * Public Functions ****************************************************************************/ -void up_rnginitialize() +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the RNG hardware and register the /dev/random driver. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +int devrandom_register(void) { stm32_rnginitialize(); - register_driver("/dev/random", &g_rngops, 0444, NULL); + return register_driver("/dev/random", &g_rngops, 0444, NULL); } diff --git a/arch/arm/src/stm32l4/stm32l4_rng.c b/arch/arm/src/stm32l4/stm32l4_rng.c index f9324fb6f1e..63a7b7428aa 100644 --- a/arch/arm/src/stm32l4/stm32l4_rng.c +++ b/arch/arm/src/stm32l4/stm32l4_rng.c @@ -289,10 +289,24 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen) * Public Functions ****************************************************************************/ -void up_rnginitialize(void) +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the RNG hardware and register the /dev/random driver. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +int devrandom_register(void) { stm32l4_rnginitialize(); - register_driver("/dev/random", &g_rngops, 0444, NULL); + return register_driver("/dev/random", &g_rngops, 0444, NULL); } #endif /* CONFIG_STM32L4_RNG */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 3290dab26ba..a38c0be2e5d 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -301,7 +301,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index fb953156623..a51d156f043 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -227,7 +227,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 6b2384b8ba3..bcd29d37fa0 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -229,7 +229,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index 8e1b916b251..fe5af0e4dd6 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -172,7 +172,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif /* Enable interrupt */ diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index 528a7c903e7..f4fd01baffb 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -221,7 +221,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index cc8c890ea69..d8f761f8855 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -211,7 +211,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT) diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index e3041739308..dc12de56030 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -229,7 +229,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 499e74966ec..6d239130be2 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -229,7 +229,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 1820871fbef..f3adc1dd613 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -226,7 +226,7 @@ void up_initialize(void) #ifdef CONFIG_DEV_RANDOM /* Initialize the Random Number Generator (RNG) */ - up_rnginitialize(); + devrandom_register(); #endif #ifndef CONFIG_NETDEV_LATEINIT diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 30bf4fbab19..f3c24b49822 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -424,7 +424,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) * * There is an inherent race condition in this test, but leaving * a few bytes unnecessarily in the pipe should not be harmful. - * (we could lock the scheduler between the test and the + * (we could lock the scheduler before the test and after the * file_read() below if we wanted to eliminate the race) */ @@ -443,7 +443,9 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) } /* Break out of the loop and return ntotal if the pipe is - * empty. + * empty. This is the race: The fifo was emtpy when we + * called file_ioctl() above, but it might not be empty right + * now. */ if (nsrc < 1) @@ -495,7 +497,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) else #endif { - /* NOTE: the source pipe will block is no data is available in + /* NOTE: the source pipe will block if no data is available in * the pipe. Otherwise, it will return data from the pipe. If * there are fewer than 'len' bytes in the, it will return with * ntotal < len. diff --git a/drivers/wireless/cc1101.c b/drivers/wireless/cc1101.c index 8d8958fc728..aa27eda883b 100644 --- a/drivers/wireless/cc1101.c +++ b/drivers/wireless/cc1101.c @@ -97,11 +97,13 @@ ****************************************************************************/ #include -#include + #include #include -#include #include +#include +#include +#include #include #include @@ -450,6 +452,8 @@ void cc1101_dumpregs(struct cc1101_dev_s * dev, uint8_t addr, uint8_t length) cc1101_access(dev, addr, (FAR uint8_t *)buf, length); + /* REVISIT: printf() should not be used from within the OS */ + printf("CC1101[%2x]: ", addr); for (i = 0; i < length; i++) { @@ -814,7 +818,7 @@ int cc1101_read(struct cc1101_dev_s * dev, uint8_t * buf, size_t size) if (nbytes > size || (nbytes <= size && !(buf[nbytes-1]&0x80))) { - printf("Flushing RX FIFO\n"); + ninfo("Flushing RX FIFO\n"); cc1101_strobe(dev, CC1101_SFRX); } diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index ea0409cd84d..b9866adaad4 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1013,6 +1013,18 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup); void devnull_register(void); +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the RNG hardware and register the /dev/random driver. + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_RANDOM +void devrandom_register(void); +#endif + /**************************************************************************** * Name: devurandom_register * @@ -1021,7 +1033,9 @@ void devnull_register(void); * ****************************************************************************/ +#ifdef CONFIG_DEV_URANDOM void devurandom_register(void); +#endif /**************************************************************************** * Name: devcrypto_register From 078bbe5e5c0b1cec9c4139abe677d1fcdb1da689 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 11:10:37 -0600 Subject: [PATCH 070/152] All H/W RNG Drivers: Can now be configured to register as /dev/random and/or /dev/urandom --- arch/arm/src/sama5/sam_trng.c | 92 ++++++++++++++++++++++++------ arch/arm/src/samv7/sam_trng.c | 91 +++++++++++++++++++++++------ arch/arm/src/stm32/stm32_rng.c | 33 ++++++++++- arch/arm/src/stm32l4/stm32l4_rng.c | 31 ++++++++-- 4 files changed, 208 insertions(+), 39 deletions(-) diff --git a/arch/arm/src/sama5/sam_trng.c b/arch/arm/src/sama5/sam_trng.c index b9294611423..089c9f248ef 100644 --- a/arch/arm/src/sama5/sam_trng.c +++ b/arch/arm/src/sama5/sam_trng.c @@ -59,6 +59,9 @@ #include "sam_periphclks.h" #include "sam_trng.h" +#if defined(CONFIG_SAMA5_TRNG) +#if defined(CONFIG_DEV_RANDOM) || defined(CONFIG_DEV_URANDOM_ARCH) + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -325,14 +328,10 @@ errout: } /**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: devrandom_register + * Name: sam_rng_initialize * * Description: - * Initialize the TRNG hardware and register the /dev/random driver. + * Initialize the TRNG hardware. * * Input Parameters: * None @@ -342,7 +341,7 @@ errout: * ****************************************************************************/ -int devrandom_register(void) +static int sam_rng_initialize(void) { int ret; @@ -375,17 +374,78 @@ int devrandom_register(void) putreg32(TRNG_CR_DISABLE | TRNG_CR_KEY, SAM_TRNG_CR); - /* Register the character driver */ - - ret = register_driver("/dev/random", &g_trngops, 0644, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to register /dev/random\n"); - return ret; - } - /* Enable the TRNG interrupt at the AIC */ up_enable_irq(SAM_IRQ_TRNG); return OK; } + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the TRNG hardware and register the /dev/random driver. + * Must be called BEFORE devurandom_register. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_RANDOM +int devrandom_register(void) +{ + int ret; + + ret = sam_rng_initialize(); + if (ret >= 0) + { + ret = register_driver("/dev/random", &g_trngops, 0644, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to register /dev/random\n"); + } + } + + return ret; +} +#endif + +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_ARCH +int devurandom_register(void) +{ + int ret; + +#ifndef CONFIG_DEV_RANDOM + ret = sam_rng_initialize(); + if (ret >= 0) +#endif + { + ret = register_driver("/dev/urandom", &g_trngops, 0644, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to register /dev/urandom\n"); + } + } + + return ret; +} +#endif + +#endif /* CONFIG_DEV_RANDOM || CONFIG_DEV_URANDOM_ARCH */ +#endif /* CONFIG_SAMA5_TRNG */ diff --git a/arch/arm/src/samv7/sam_trng.c b/arch/arm/src/samv7/sam_trng.c index 89c7630b21c..d9951cace36 100644 --- a/arch/arm/src/samv7/sam_trng.c +++ b/arch/arm/src/samv7/sam_trng.c @@ -60,6 +60,9 @@ #include "sam_periphclks.h" #include "sam_trng.h" +#if defined(CONFIG_SAMV7_TRNG) +#if defined(CONFIG_DEV_RANDOM) || defined(CONFIG_DEV_URANDOM_ARCH) + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -326,14 +329,10 @@ errout: } /**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: devrandom_register + * Name: sam_rng_initialize * * Description: - * Initialize the TRNG hardware and register the /dev/random driver. + * Initialize the TRNG hardware. * * Input Parameters: * None @@ -343,7 +342,7 @@ errout: * ****************************************************************************/ -int devrandom_register(void) +static int sam_rng_initialize(void) { int ret; @@ -376,17 +375,77 @@ int devrandom_register(void) putreg32(TRNG_CR_DISABLE | TRNG_CR_KEY, SAM_TRNG_CR); - /* Register the character driver */ - - ret = register_driver("/dev/random", &g_trngops, 0644, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to register /dev/random\n"); - return ret; - } - /* Enable the TRNG interrupt at the AIC */ up_enable_irq(SAM_IRQ_TRNG); return OK; } + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the TRNG hardware and register the /dev/random driver. + * Must be called BEFORE devurandom_register. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_RANDOM +int devrandom_register(void) +{ + int ret; + + ret = sam_rng_initialize(); + if (ret >= 0) + { + ret = register_driver("/dev/random", &g_trngops, 0644, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to register /dev/random\n"); + } + } + + return ret; +} +#endif + +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_ARCH +int devurandom_register(void) +{ + int ret; + +#ifndef CONFIG_DEV_RANDOM + ret = sam_rng_initialize(); + if (ret >= 0) +#endif + { + ret = register_driver("/dev/urandom", &g_trngops, 0644, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to register /dev/urandom\n"); + } + } + + return ret; +} +#endif + +#endif /* CONFIG_DEV_RANDOM || CONFIG_DEV_URANDOM_ARCH */ diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c index eda6f5d550c..57743d157d6 100644 --- a/arch/arm/src/stm32/stm32_rng.c +++ b/arch/arm/src/stm32/stm32_rng.c @@ -51,11 +51,14 @@ #include "chip/stm32_rng.h" #include "up_internal.h" +#if defined(CONFIG_STM32_RNG) +#if defined(CONFIG_DEV_RANDOM) || defined(CONFIG_DEV_URANDOM_ARCH) + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int stm32_rnginitialize(void); +static int stm32_rng_initialize(void); static int stm32_interrupt(int irq, void *context); static void stm32_enable(void); static void stm32_disable(void); @@ -98,7 +101,7 @@ static const struct file_operations g_rngops = * Private functions ****************************************************************************/ -static int stm32_rnginitialize() +static int stm32_rng_initialize() { uint32_t regval; @@ -263,6 +266,7 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen) * * Description: * Initialize the RNG hardware and register the /dev/random driver. + * Must be called BEFORE devurandom_register. * * Input Parameters: * None @@ -272,8 +276,31 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen) * ****************************************************************************/ +#ifdef CONFIG_DEV_RANDOM int devrandom_register(void) { - stm32_rnginitialize(); + stm32_rng_initialize(); return register_driver("/dev/random", &g_rngops, 0444, NULL); } +#endif + +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_ARCH +int devurandom_register(void) +{ +#ifndef CONFIG_DEV_RANDOM + stm32l4_rnginitialize(); +#endif + return register_driver("/dev/urandom", &g_rngops, 0444, NULL); +} +#endif + +#endif /* CONFIG_DEV_RANDOM || CONFIG_DEV_URANDOM_ARCH */ +#endif /* CONFIG_STM32_RNG */ diff --git a/arch/arm/src/stm32l4/stm32l4_rng.c b/arch/arm/src/stm32l4/stm32l4_rng.c index 63a7b7428aa..64f08dc04b4 100644 --- a/arch/arm/src/stm32l4/stm32l4_rng.c +++ b/arch/arm/src/stm32l4/stm32l4_rng.c @@ -52,13 +52,14 @@ #include "chip/stm32l4_rng.h" #include "up_internal.h" -#ifdef CONFIG_STM32L4_RNG +#if defined(CONFIG_STM32L4_RNG) +#if defined(CONFIG_DEV_RANDOM) || defined(CONFIG_DEV_URANDOM_ARCH) /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int stm32l4_rnginitialize(void); +static int stm32l4_rng_initialize(void); static int stm32l4_rnginterrupt(int irq, void *context); static void stm32l4_rngenable(void); static void stm32l4_rngdisable(void); @@ -105,7 +106,7 @@ static const struct file_operations g_rngops = * Private functions ****************************************************************************/ -static int stm32l4_rnginitialize(void) +static int stm32l4_rng_initialize(void) { _info("Initializing RNG\n"); @@ -294,6 +295,7 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen) * * Description: * Initialize the RNG hardware and register the /dev/random driver. + * Must be called BEFORE devurandom_register. * * Input Parameters: * None @@ -303,10 +305,31 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen) * ****************************************************************************/ +#ifdef CONFIG_DEV_RANDOM int devrandom_register(void) { - stm32l4_rnginitialize(); + stm32l4_rng_initialize(); return register_driver("/dev/random", &g_rngops, 0444, NULL); } +#endif +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM_ARCH +int devurandom_register(void) +{ +#ifndef CONFIG_DEV_RANDOM + stm32l4_rng_initialize(); +#endif + return register_driver("/dev/urandom", &g_rngops, 0444, NULL); +} +#endif + +#endif /* CONFIG_DEV_RANDOM || CONFIG_DEV_URANDOM_ARCH */ #endif /* CONFIG_STM32L4_RNG */ From d5388eca05ccf5b4ee3bf62246394dc1cd249add Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 11:24:04 -0600 Subject: [PATCH 071/152] devrandom_register() must be called before devurandom_register() --- arch/arm/src/common/up_initialize.c | 10 ++++------ arch/avr/src/common/up_initialize.c | 10 ++++------ arch/hc/src/common/up_initialize.c | 10 ++++------ arch/mips/src/common/up_initialize.c | 10 ++++------ arch/rgmp/src/nuttx.c | 10 ++++------ arch/sh/src/common/up_initialize.c | 10 ++++------ arch/sim/src/up_initialize.c | 10 ++++------ arch/x86/src/common/up_initialize.c | 10 ++++------ arch/z16/src/common/up_initialize.c | 10 ++++------ arch/z80/src/common/up_initialize.c | 10 ++++------ 10 files changed, 40 insertions(+), 60 deletions(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 9803304fd7a..b1f88c0d1b7 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -198,6 +198,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -257,12 +261,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index a38c0be2e5d..14c273c414b 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -239,6 +239,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -298,12 +302,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index a51d156f043..8ae73d30eb4 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -165,6 +165,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -224,12 +228,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index bcd29d37fa0..93652972e0c 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -226,12 +230,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index fe5af0e4dd6..3e694d503f8 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -141,6 +141,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -169,12 +173,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - /* Enable interrupt */ local_irq_enable(); diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index f4fd01baffb..80e93410cbd 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -156,6 +156,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -218,12 +222,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index d8f761f8855..cc670ef93ed 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -153,6 +153,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -208,12 +212,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT) up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */ #endif diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index dc12de56030..1261a5eb369 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -226,12 +230,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 6d239130be2..349e68b0d78 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -167,6 +167,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -226,12 +230,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index f3adc1dd613..a42635cbe8f 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -164,6 +164,10 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ #endif +#if defined(CONFIG_DEV_RANDOM) + devrandom_register(); /* Standard /dev/random */ +#endif + #if defined(CONFIG_DEV_URANDOM) devurandom_register(); /* Standard /dev/urandom */ #endif @@ -223,12 +227,6 @@ void up_initialize(void) devcrypto_register(); #endif -#ifdef CONFIG_DEV_RANDOM - /* Initialize the Random Number Generator (RNG) */ - - devrandom_register(); -#endif - #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ From d9fbf4c90febd501f055cda4e3fd19c1dab8a862 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 11:27:06 -0600 Subject: [PATCH 072/152] Eliminate some warnings --- drivers/serial/pty.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index f3c24b49822..8b7ed2ceae2 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -715,6 +715,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) termiosp->c_iflag = dev->pd_iflag; termiosp->c_oflag = dev->pd_oflag; termiosp->c_lflag = 0; + ret = OK; } break; @@ -732,6 +733,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) dev->pd_iflag = termiosp->c_iflag; dev->pd_oflag = termiosp->c_oflag; + ret = OK; } break; #endif From d36da2b560fb224d99904178c81b38bd98ec4122 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 12:25:05 -0600 Subject: [PATCH 073/152] Fix bad dev[u]random_register() function return value. --- arch/arm/src/sama5/sam_trng.c | 14 ++++++++------ arch/arm/src/samv7/sam_trng.c | 14 ++++++++------ arch/arm/src/stm32/stm32_rng.c | 14 ++++++++++---- arch/arm/src/stm32l4/stm32l4_rng.c | 14 ++++++++++---- include/nuttx/fs/fs.h | 30 ++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 20 deletions(-) diff --git a/arch/arm/src/sama5/sam_trng.c b/arch/arm/src/sama5/sam_trng.c index 089c9f248ef..9f9cec8e55b 100644 --- a/arch/arm/src/sama5/sam_trng.c +++ b/arch/arm/src/sama5/sam_trng.c @@ -400,7 +400,7 @@ static int sam_rng_initialize(void) ****************************************************************************/ #ifdef CONFIG_DEV_RANDOM -int devrandom_register(void) +void devrandom_register(void) { int ret; @@ -413,8 +413,6 @@ int devrandom_register(void) ferr("ERROR: Failed to register /dev/random\n"); } } - - return ret; } #endif @@ -424,10 +422,16 @@ int devrandom_register(void) * Description: * Register /dev/urandom * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_URANDOM_ARCH -int devurandom_register(void) +void devurandom_register(void) { int ret; @@ -442,8 +446,6 @@ int devurandom_register(void) ferr("ERROR: Failed to register /dev/urandom\n"); } } - - return ret; } #endif diff --git a/arch/arm/src/samv7/sam_trng.c b/arch/arm/src/samv7/sam_trng.c index d9951cace36..1634cc46f35 100644 --- a/arch/arm/src/samv7/sam_trng.c +++ b/arch/arm/src/samv7/sam_trng.c @@ -401,7 +401,7 @@ static int sam_rng_initialize(void) ****************************************************************************/ #ifdef CONFIG_DEV_RANDOM -int devrandom_register(void) +void devrandom_register(void) { int ret; @@ -414,8 +414,6 @@ int devrandom_register(void) ferr("ERROR: Failed to register /dev/random\n"); } } - - return ret; } #endif @@ -425,10 +423,16 @@ int devrandom_register(void) * Description: * Register /dev/urandom * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_URANDOM_ARCH -int devurandom_register(void) +void devurandom_register(void) { int ret; @@ -443,8 +447,6 @@ int devurandom_register(void) ferr("ERROR: Failed to register /dev/urandom\n"); } } - - return ret; } #endif diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c index 57743d157d6..2cc1e6409ca 100644 --- a/arch/arm/src/stm32/stm32_rng.c +++ b/arch/arm/src/stm32/stm32_rng.c @@ -277,10 +277,10 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen) ****************************************************************************/ #ifdef CONFIG_DEV_RANDOM -int devrandom_register(void) +void devrandom_register(void) { stm32_rng_initialize(); - return register_driver("/dev/random", &g_rngops, 0444, NULL); + (void)register_driver("/dev/random", &g_rngops, 0444, NULL); } #endif @@ -290,15 +290,21 @@ int devrandom_register(void) * Description: * Register /dev/urandom * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_URANDOM_ARCH -int devurandom_register(void) +void devurandom_register(void) { #ifndef CONFIG_DEV_RANDOM stm32l4_rnginitialize(); #endif - return register_driver("/dev/urandom", &g_rngops, 0444, NULL); + (void)register_driver("/dev/urandom", &g_rngops, 0444, NULL); } #endif diff --git a/arch/arm/src/stm32l4/stm32l4_rng.c b/arch/arm/src/stm32l4/stm32l4_rng.c index 64f08dc04b4..e048edda167 100644 --- a/arch/arm/src/stm32l4/stm32l4_rng.c +++ b/arch/arm/src/stm32l4/stm32l4_rng.c @@ -306,10 +306,10 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen) ****************************************************************************/ #ifdef CONFIG_DEV_RANDOM -int devrandom_register(void) +void devrandom_register(void) { stm32l4_rng_initialize(); - return register_driver("/dev/random", &g_rngops, 0444, NULL); + (void)register_driver("/dev/random", &g_rngops, 0444, NULL); } #endif @@ -319,15 +319,21 @@ int devrandom_register(void) * Description: * Register /dev/urandom * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_URANDOM_ARCH -int devurandom_register(void) +void devurandom_register(void) { #ifndef CONFIG_DEV_RANDOM stm32l4_rng_initialize(); #endif - return register_driver("/dev/urandom", &g_rngops, 0444, NULL); + (void)register_driver("/dev/urandom", &g_rngops, 0444, NULL); } #endif diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index b9866adaad4..ef99ff6f51b 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1009,6 +1009,12 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup); * Description: * Register /dev/null * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ void devnull_register(void); @@ -1019,6 +1025,12 @@ void devnull_register(void); * Description: * Initialize the RNG hardware and register the /dev/random driver. * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_RANDOM @@ -1031,6 +1043,12 @@ void devrandom_register(void); * Description: * Register /dev/urandom * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ #ifdef CONFIG_DEV_URANDOM @@ -1043,6 +1061,12 @@ void devurandom_register(void); * Description: * Register /dev/crypto * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ void devcrypto_register(void); @@ -1053,6 +1077,12 @@ void devcrypto_register(void); * Description: * Register /dev/zero * + * Input Parameters: + * None + * + * Returned Value: + * None + * ****************************************************************************/ void devzero_register(void); From 2119c5ce19b1d5ba7b7e503b340d0a04d92b70b4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 Jul 2016 12:40:27 -0600 Subject: [PATCH 074/152] Fix another function naming error --- arch/arm/src/stm32/stm32_rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c index 2cc1e6409ca..9d727e4fef5 100644 --- a/arch/arm/src/stm32/stm32_rng.c +++ b/arch/arm/src/stm32/stm32_rng.c @@ -302,7 +302,7 @@ void devrandom_register(void) void devurandom_register(void) { #ifndef CONFIG_DEV_RANDOM - stm32l4_rnginitialize(); + stm32_rng_initialize(); #endif (void)register_driver("/dev/urandom", &g_rngops, 0444, NULL); } From a4458c50161264dd7aaf64b08732de8932067857 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 06:45:02 -0600 Subject: [PATCH 075/152] PTY: Fix a race condition in test-fifo-empty-before-read logic --- drivers/Kconfig | 8 +++++--- drivers/serial/pty.c | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/Kconfig b/drivers/Kconfig index 5ee36f8a205..22f17127687 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -29,6 +29,7 @@ config DEV_RANDOM bool "Enable /dev/random" default y depends on ARCH_HAVE_RNG + Enable support for /dev/urandom provided by a hardware TRNG. config DEV_URANDOM bool "Enable /dev/urandom" @@ -52,7 +53,7 @@ choice config DEV_URANDOM_XORSHIFT128 bool "xorshift128" ---help--- - xorshift128 is a pseudorandom number generator that's simple, + xorshift128 is a pseudorandom number generator that is simple, portable, and can also be used on 8-bit and 16-bit MCUs. NOTE: Not cyptographically secure @@ -74,9 +75,10 @@ config DEV_URANDOM_ARCH The implementation of /dev/urandom is provided in archtecture- specific logic using hardware TRNG logic. architecture-specific logic must provide the whole implementation in this case, including - the function devurandom_register(). + the function devurandom_register(). In this case, /dev/urandom may + refer to the same driver as /dev/random. - May or may not be cyptographically secure, depending upon the + NOTE: May or may not be cyptographically secure, depending upon the implementation. endchoice # /dev/urandom algorithm diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 8b7ed2ceae2..74f278145ad 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -421,45 +422,66 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) * bytes were read from the pipe. If we have already read some * data, we use the FIONREAD ioctl to test if there are more bytes * in the pipe. - * - * There is an inherent race condition in this test, but leaving - * a few bytes unnecessarily in the pipe should not be harmful. - * (we could lock the scheduler before the test and after the - * file_read() below if we wanted to eliminate the race) */ if (ntotal > 0) { int nsrc; + /* There are inherent race conditions in this test. We lock + * the scheduler before the test and after the file_read() + * below to eliminate one race: (a) We detect that there is + * data in the source file, (b) we are suspended and another + * thread reads the data, emptying the fifo, then (c) we + * resume and call file_read(), blocking indefinitely. + */ + + sched_lock(); + /* Check how many bytes are waiting in the pipe */ ret = file_ioctl(&dev->pd_src, FIONREAD, (unsigned long)((uintptr_t)&nsrc)); if (ret < 0) { + sched_unlock(); ntotal = ret; break; } /* Break out of the loop and return ntotal if the pipe is - * empty. This is the race: The fifo was emtpy when we + * empty. This is another race: There fifo was empty when we * called file_ioctl() above, but it might not be empty right - * now. + * now. Losing that race should not lead to any bad behaviors, + * however, we the caller will get those bytes on the next + * read. */ if (nsrc < 1) { + sched_unlock(); break; } + + /* Read one byte from the source the byte. This should not + * block. + */ + + nread = file_read(&dev->pd_src, &ch, 1); + sched_unlock(); } + else #endif + { + /* Read one byte from the source the byte. This call will block + * if the source pipe is empty. + */ - /* Read one byte from the source the byte. This call will block - * if the source pipe is empty. - */ + nread = file_read(&dev->pd_src, &ch, 1); + } + + /* Check if file_read was successful */ - nread = file_read(&dev->pd_src, &ch, 1); if (nread < 0) { ntotal = nread; From f222d37aa79f8dcefd2d23785285d5fc579c8c49 Mon Sep 17 00:00:00 2001 From: Vytautas Lukenskas Date: Tue, 19 Jul 2016 07:11:04 -0600 Subject: [PATCH 076/152] Extend LPC43xx EMC code to support SDRAM on a dynamic memory interface. --- arch/arm/src/lpc43xx/Kconfig | 165 +++++++++++++ .../src/lpc43xx/chip/lpc435357_memorymap.h | 2 + .../lpc43xx/chip/lpc4357fet256_pinconfig.h | 160 ++++++------- arch/arm/src/lpc43xx/chip/lpc43_ccu.h | 20 +- arch/arm/src/lpc43xx/chip/lpc43_emc.h | 88 ++++++- arch/arm/src/lpc43xx/lpc43_allocateheap.c | 217 ++++++++++++++---- arch/arm/src/lpc43xx/lpc43_emc.c | 141 ++++++++++++ arch/arm/src/lpc43xx/lpc43_emc.h | 22 +- 8 files changed, 676 insertions(+), 139 deletions(-) create mode 100644 arch/arm/src/lpc43xx/lpc43_emc.c diff --git a/arch/arm/src/lpc43xx/Kconfig b/arch/arm/src/lpc43xx/Kconfig index e7f830ed2ba..80da35c00ca 100644 --- a/arch/arm/src/lpc43xx/Kconfig +++ b/arch/arm/src/lpc43xx/Kconfig @@ -81,36 +81,43 @@ config ARCH_FAMILY_LPC4320 bool default y if ARCH_CHIP_LPC4320FBD144 || ARCH_CHIP_LPC4320FET100 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4330 bool default y if ARCH_CHIP_LPC4330FBD144 || ARCH_CHIP_LPC4330FET100 || ARCH_CHIP_LPC4330FET180 || ARCH_CHIP_LPC4330FET256 || ARCH_CHIP_LPC4337JET100 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4337 bool default y if ARCH_CHIP_LPC4337JBD144 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4350 bool default y if ARCH_CHIP_LPC4350FBD208 || ARCH_CHIP_LPC4350FET180 || ARCH_CHIP_LPC4350FET256 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4353 bool default y if ARCH_CHIP_LPC4353FBD208 || ARCH_CHIP_LPC4353FET180 || ARCH_CHIP_LPC4353FET256 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4357 bool default y if ARCH_CHIP_LPC4357FET180 || ARCH_CHIP_LPC4357FBD208 || ARCH_CHIP_LPC4357FET256 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 config ARCH_FAMILY_LPC4370 bool default y if ARCH_CHIP_LPC4370FET100 select ARCH_HAVE_TICKLESS + select ARCH_HAVE_AHB_SRAM_BANK1 choice prompt "LPC43XX Boot Configuration" @@ -177,9 +184,15 @@ config LPC43_DAC config LPC43_EMC bool "External Memory Controller (EMC)" default n + select ARCH_HAVE_EXTSDRAM0 + select ARCH_HAVE_EXTSDRAM1 + select ARCH_HAVE_EXTSDRAM2 + select ARCH_HAVE_EXTSDRAM3 config LPC43_ETHERNET bool "Ethernet" + select NETDEVICES + select ARCH_HAVE_PHY default n config LPC43_EVNTMNTR @@ -320,6 +333,158 @@ config LPC43_GPIO_IRQ ---help--- Enable support for GPIO interrupts +menu "Internal Memory Configuration" + +config ARCH_HAVE_AHB_SRAM_BANK1 + bool + +if !LPC43_BOOT_SRAM + +config LPC43_USE_LOCSRAM_BANK1 + bool "Use local SRAM bank 1 memory region" + default n + ---help--- + Add local SRAM bank 1 memory region. + +endif # LPC43_BOOT_SRAM + +config LPC43_USE_AHBSRAM_BANK0 + bool "Use AHB SRAM bank 0 memory region" + default n + ---help--- + Add local AHB SRAM bank 0 memory region. + +config LPC43_USE_AHBSRAM_BANK1 + bool "Use AHB SRAM bank 1 memory region" + default n + depends on ARCH_HAVE_AHB_SRAM_BANK1 + ---help--- + Add local AHB SRAM bank 1 memory region. + +config LPC43_HEAP_AHBSRAM_BANK2 + bool "Use AHB SRAM bank 2 (ETB SRAM) memory region" + default n + ---help--- + Add local AHB SRAM bank 2 (ETB SRAM) memory region. + +endmenu # LPC43xx Internal Memory Configuration + +menu "External Memory Configuration" + +config ARCH_HAVE_EXTSDRAM0 + bool + +config ARCH_HAVE_EXTSDRAM1 + bool + +config ARCH_HAVE_EXTSDRAM2 + bool + +config ARCH_HAVE_EXTSDRAM3 + bool + +config LPC43_EXTSDRAM0 + bool "Configure external SDRAM0 (on DYNCS0)" + default n + depends on ARCH_HAVE_EXTSDRAM0 + select ARCH_HAVE_EXTSDRAM + ---help--- + Configure external SDRAM memory and, if applicable, map then external + SDRAM into the memory map. + +if LPC43_EXTSDRAM0 + +config LPC43_EXTSDRAM0_SIZE + int "External SDRAM0 size" + default 0 + ---help--- + Size of the external SDRAM on DYNCS0 in bytes. + +config LPC43_EXTSDRAM0_HEAP + bool "Add external SDRAM on DYNCS0 to the heap" + default y + ---help--- + Add the external SDRAM on DYNCS0 into the heap. + +endif # LCP43_EXTSDRAM0 + +config LPC43_EXTSDRAM1 + bool "Configure external SDRAM1 (on DYNCS1)" + default n + depends on ARCH_HAVE_EXTSDRAM1 + select ARCH_HAVE_EXTSDRAM + ---help--- + Configure external SDRAM memoryand, if applicable, map then external + SDRAM into the memory map. + +if LPC43_EXTSDRAM1 + +config LPC43_EXTSDRAM1_SIZE + int "External SDRAM1 size" + default 0 + ---help--- + Size of the external SDRAM on DYNCS1 in bytes. + +config LPC43_EXTSDRAM1_HEAP + bool "Add external SDRAM on DYNCS1 to the heap" + default y + ---help--- + Add the external SDRAM on DYNCS1 into the heap. + +endif # LCP43_EXTSDRAM1 + +config LPC43_EXTSDRAM2 + bool "Configure external SDRAM2 (on DYNCS2)" + default n + depends on ARCH_HAVE_EXTSDRAM2 + select ARCH_HAVE_EXTSDRAM + ---help--- + Configure external SDRAM memoryand, if applicable, map then external + SDRAM into the memory map. + +if LPC43_EXTSDRAM2 + +config LPC43_EXTSDRAM2_SIZE + int "External SDRAM2 size" + default 0 + ---help--- + Size of the external SDRAM on DYNCS2 in bytes. + +config LPC43_EXTSDRAM2_HEAP + bool "Add external SDRAM on DYNCS2 to the heap" + default y + ---help--- + Add the external SDRAM on DYNCS2 into the heap. + +endif # LCP43_EXTSDRAM2 + +config LPC43_EXTSDRAM3 + bool "Configure external SDRAM3 (on DYNCS3)" + default n + depends on ARCH_HAVE_EXTSDRAM3 + select ARCH_HAVE_EXTSDRAM + ---help--- + Configure external SDRAM memoryand, if applicable, map then external + SDRAM into the memory map. + +if LPC43_EXTSDRAM3 + +config LPC43_EXTSDRAM3_SIZE + int "External SDRAM3 size" + default 0 + ---help--- + Size of the external SDRAM in bytes. + +config LPC43_EXTSDRAM3_HEAP + bool "Add external SDRAM on DYNCS3 to the heap" + default y + ---help--- + Add the external SDRAM on DYNCS3 into the heap. + +endif # LCP43_EXTSDRAM3 + +endmenu # External Memory Configuration + if LPC43_ETHERNET menu "Ethernet MAC configuration" diff --git a/arch/arm/src/lpc43xx/chip/lpc435357_memorymap.h b/arch/arm/src/lpc43xx/chip/lpc435357_memorymap.h index 1b8312c965f..852bd2a862e 100644 --- a/arch/arm/src/lpc43xx/chip/lpc435357_memorymap.h +++ b/arch/arm/src/lpc43xx/chip/lpc435357_memorymap.h @@ -90,6 +90,8 @@ /* AHB SRAM */ #define LPC43_AHBSRAM_BANK0_BASE (LPC43_AHBSRAM_BASE) +#define LPC43_AHBSRAM_BANK1_BASE (LPC43_AHBSRAM_BASE + 0x00008000) +#define LPC43_AHBSRAM_BANK2_BASE (LPC43_AHBSRAM_BASE + 0x0000c000) #define LPC43_EEPROM_BASE (LPC43_AHBSRAM_BASE + 0x00004000) #define LPC43_AHBSRAM_BITBAND_BASE (LPC43_AHBSRAM_BASE + 0x02000000) diff --git a/arch/arm/src/lpc43xx/chip/lpc4357fet256_pinconfig.h b/arch/arm/src/lpc43xx/chip/lpc4357fet256_pinconfig.h index b29722479a3..41a5d939540 100644 --- a/arch/arm/src/lpc43xx/chip/lpc4357fet256_pinconfig.h +++ b/arch/arm/src/lpc43xx/chip/lpc4357fet256_pinconfig.h @@ -190,86 +190,86 @@ #define PINCONF_CTOUT15_2 (PINCONF_FUNC1|PINCONF_PINSD|PINCONF_PIN_0) #define PINCONF_CTOUT15_3 (PINCONF_FUNC2|PINCONF_PINS1|PINCONF_PIN_11) -#define PINCONF_EMC_A0 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_9) -#define PINCONF_EMC_A1 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_10) -#define PINCONF_EMC_A2 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_11) -#define PINCONF_EMC_A3 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_12) -#define PINCONF_EMC_A4 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_13) -#define PINCONF_EMC_A5 (PINCONF_FUNC2|PINCONF_PINS1|PINCONF_PIN_0) -#define PINCONF_EMC_A6 (PINCONF_FUNC2|PINCONF_PINS1|PINCONF_PIN_1) -#define PINCONF_EMC_A7 (PINCONF_FUNC2|PINCONF_PINS1|PINCONF_PIN_2) -#define PINCONF_EMC_A8 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_8) -#define PINCONF_EMC_A9 (PINCONF_FUNC3|PINCONF_PINS2|PINCONF_PIN_7) -#define PINCONF_EMC_A10 (PINCONF_FUNC2|PINCONF_PINS2|PINCONF_PIN_6) -#define PINCONF_EMC_A11 (PINCONF_FUNC2|PINCONF_PINS2|PINCONF_PIN_2) -#define PINCONF_EMC_A12 (PINCONF_FUNC2|PINCONF_PINS2|PINCONF_PIN_1) -#define PINCONF_EMC_A13 (PINCONF_FUNC2|PINCONF_PINS2|PINCONF_PIN_0) -#define PINCONF_EMC_A14 (PINCONF_FUNC1|PINCONF_PINS6|PINCONF_PIN_8) -#define PINCONF_EMC_A15 (PINCONF_FUNC1|PINCONF_PINS6|PINCONF_PIN_7) -#define PINCONF_EMC_A16 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_16) -#define PINCONF_EMC_A17 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_15) -#define PINCONF_EMC_A18 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_0) -#define PINCONF_EMC_A19 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_1) -#define PINCONF_EMC_A20 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_2) -#define PINCONF_EMC_A21 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_3) -#define PINCONF_EMC_A22 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_4) -#define PINCONF_EMC_A23 (PINCONF_FUNC3|PINCONF_PINSA|PINCONF_PIN_4) -#define PINCONF_EMC_BLS0 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_4) -#define PINCONF_EMC_BLS1 (PINCONF_FUNC1|PINCONF_PINS6|PINCONF_PIN_6) -#define PINCONF_EMC_BLS2 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_13) -#define PINCONF_EMC_BLS3 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_10) -#define PINCONF_EMC_CAS (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_4) -#define PINCONF_EMC_CKEOUT0 (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_11) -#define PINCONF_EMC_CKEOUT1 (PINCONF_FUNC1|PINCONF_PINS6|PINCONF_PIN_2) -#define PINCONF_EMC_CKEOUT2 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_1) -#define PINCONF_EMC_CKEOUT3 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_15) -#define PINCONF_EMC_CS0 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_5) -#define PINCONF_EMC_CS1 (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_3) -#define PINCONF_EMC_CS2 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_12) -#define PINCONF_EMC_CS3 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_11) -#define PINCONF_EMC_D0 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_7) -#define PINCONF_EMC_D1 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_8) -#define PINCONF_EMC_D2 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_9) -#define PINCONF_EMC_D3 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_10) -#define PINCONF_EMC_D4 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_11) -#define PINCONF_EMC_D5 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_12) -#define PINCONF_EMC_D6 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_13) -#define PINCONF_EMC_D7 (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_14) -#define PINCONF_EMC_D8 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_4) -#define PINCONF_EMC_D9 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_5) -#define PINCONF_EMC_D10 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_6) -#define PINCONF_EMC_D11 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_7) -#define PINCONF_EMC_D12 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_0) -#define PINCONF_EMC_D13 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_1) -#define PINCONF_EMC_D14 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_2) -#define PINCONF_EMC_D15 (PINCONF_FUNC2|PINCONF_PINS5|PINCONF_PIN_3) -#define PINCONF_EMC_D16 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_2) -#define PINCONF_EMC_D17 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_3) -#define PINCONF_EMC_D18 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_4) -#define PINCONF_EMC_D19 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_5) -#define PINCONF_EMC_D20 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_6) -#define PINCONF_EMC_D21 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_7) -#define PINCONF_EMC_D22 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_8) -#define PINCONF_EMC_D23 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_9) -#define PINCONF_EMC_D24 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_5) -#define PINCONF_EMC_D25 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_6) -#define PINCONF_EMC_D26 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_7) -#define PINCONF_EMC_D27 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_8) -#define PINCONF_EMC_D28 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_9) -#define PINCONF_EMC_D29 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_10) -#define PINCONF_EMC_D30 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_11) -#define PINCONF_EMC_D31 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_12) -#define PINCONF_EMC_DQMOUT0 (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_12) -#define PINCONF_EMC_DQMOUT1 (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_10) -#define PINCONF_EMC_DQMOUT2 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_0) -#define PINCONF_EMC_DQMOUT3 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_13) -#define PINCONF_EMC_DYCS0 (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_9) -#define PINCONF_EMC_DYCS1 (PINCONF_FUNC1|PINCONF_PINS6|PINCONF_PIN_1) -#define PINCONF_EMC_DYCS2 (PINCONF_FUNC2|PINCONF_PINSD|PINCONF_PIN_14) -#define PINCONF_EMC_DYCS3 (PINCONF_FUNC3|PINCONF_PINSE|PINCONF_PIN_14) -#define PINCONF_EMC_OE (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_3) -#define PINCONF_EMC_RAS (PINCONF_FUNC3|PINCONF_PINS6|PINCONF_PIN_5) -#define PINCONF_EMC_WE (PINCONF_FUNC3|PINCONF_PINS1|PINCONF_PIN_6) +#define PINCONF_EMC_A0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_9) +#define PINCONF_EMC_A1 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_10) +#define PINCONF_EMC_A2 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_11) +#define PINCONF_EMC_A3 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_12) +#define PINCONF_EMC_A4 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_13) +#define PINCONF_EMC_A5 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_0) +#define PINCONF_EMC_A6 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_1) +#define PINCONF_EMC_A7 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_2) +#define PINCONF_EMC_A8 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_8) +#define PINCONF_EMC_A9 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_7) +#define PINCONF_EMC_A10 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_6) +#define PINCONF_EMC_A11 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_2) +#define PINCONF_EMC_A12 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_1) +#define PINCONF_EMC_A13 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS2|PINCONF_PIN_0) +#define PINCONF_EMC_A14 (PINCONF_FUNC1|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_8) +#define PINCONF_EMC_A15 (PINCONF_FUNC1|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_7) +#define PINCONF_EMC_A16 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_16) +#define PINCONF_EMC_A17 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_15) +#define PINCONF_EMC_A18 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_0) +#define PINCONF_EMC_A19 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_1) +#define PINCONF_EMC_A20 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_2) +#define PINCONF_EMC_A21 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_3) +#define PINCONF_EMC_A22 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_4) +#define PINCONF_EMC_A23 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSA|PINCONF_PIN_4) +#define PINCONF_EMC_BLS0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_4) +#define PINCONF_EMC_BLS1 (PINCONF_FUNC1|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_6) +#define PINCONF_EMC_BLS2 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_13) +#define PINCONF_EMC_BLS3 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_10) +#define PINCONF_EMC_CAS (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_4) +#define PINCONF_EMC_CKEOUT0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_11) +#define PINCONF_EMC_CKEOUT1 (PINCONF_FUNC1|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_2) +#define PINCONF_EMC_CKEOUT2 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_1) +#define PINCONF_EMC_CKEOUT3 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_15) +#define PINCONF_EMC_CS0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_5) +#define PINCONF_EMC_CS1 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_3) +#define PINCONF_EMC_CS2 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_12) +#define PINCONF_EMC_CS3 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_11) +#define PINCONF_EMC_D0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_7) +#define PINCONF_EMC_D1 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_8) +#define PINCONF_EMC_D2 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_9) +#define PINCONF_EMC_D3 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_10) +#define PINCONF_EMC_D4 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_11) +#define PINCONF_EMC_D5 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_12) +#define PINCONF_EMC_D6 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_13) +#define PINCONF_EMC_D7 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_14) +#define PINCONF_EMC_D8 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_4) +#define PINCONF_EMC_D9 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_5) +#define PINCONF_EMC_D10 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_6) +#define PINCONF_EMC_D11 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_7) +#define PINCONF_EMC_D12 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_0) +#define PINCONF_EMC_D13 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_1) +#define PINCONF_EMC_D14 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_2) +#define PINCONF_EMC_D15 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS5|PINCONF_PIN_3) +#define PINCONF_EMC_D16 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_2) +#define PINCONF_EMC_D17 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_3) +#define PINCONF_EMC_D18 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_4) +#define PINCONF_EMC_D19 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_5) +#define PINCONF_EMC_D20 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_6) +#define PINCONF_EMC_D21 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_7) +#define PINCONF_EMC_D22 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_8) +#define PINCONF_EMC_D23 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_9) +#define PINCONF_EMC_D24 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_5) +#define PINCONF_EMC_D25 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_6) +#define PINCONF_EMC_D26 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_7) +#define PINCONF_EMC_D27 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_8) +#define PINCONF_EMC_D28 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_9) +#define PINCONF_EMC_D29 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_10) +#define PINCONF_EMC_D30 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_11) +#define PINCONF_EMC_D31 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_12) +#define PINCONF_EMC_DQMOUT0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_12) +#define PINCONF_EMC_DQMOUT1 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_10) +#define PINCONF_EMC_DQMOUT2 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_0) +#define PINCONF_EMC_DQMOUT3 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_13) +#define PINCONF_EMC_DYCS0 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_9) +#define PINCONF_EMC_DYCS1 (PINCONF_FUNC1|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_1) +#define PINCONF_EMC_DYCS2 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSD|PINCONF_PIN_14) +#define PINCONF_EMC_DYCS3 (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINSE|PINCONF_PIN_14) +#define PINCONF_EMC_OE (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_3) +#define PINCONF_EMC_RAS (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS6|PINCONF_PIN_5) +#define PINCONF_EMC_WE (PINCONF_FUNC3|PINCONF_INBUFFER|PINCONF_GLITCH|PINCONF_SLEW_FAST|PINCONF_PINS1|PINCONF_PIN_6) #define PINCONF_ENET_COL_1 (PINCONF_FUNC2|PINCONF_INBUFFER|PINCONF_SLEW_FAST|PINCONF_PINS0|PINCONF_PIN_1) #define PINCONF_ENET_COL_2 (PINCONF_FUNC5|PINCONF_INBUFFER|PINCONF_SLEW_FAST|PINCONF_PINS9|PINCONF_PIN_6) diff --git a/arch/arm/src/lpc43xx/chip/lpc43_ccu.h b/arch/arm/src/lpc43xx/chip/lpc43_ccu.h index a2cb20ca62f..51cdcdb9fc9 100644 --- a/arch/arm/src/lpc43xx/chip/lpc43_ccu.h +++ b/arch/arm/src/lpc43xx/chip/lpc43_ccu.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * arch/arm/src/lpc43xx/chip/lpc43_ccu.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ /**************************************************************************************************** * Pre-processor Definitions ****************************************************************************************************/ + /* Register Offsets *********************************************************************************/ #define LPC43_CCU1_PM_OFFSET 0x0000 /* CCU1 power mode register */ @@ -343,6 +344,23 @@ #define CCU_CLK_STAT_WAKEUP (1 << 2) /* Bit 2: Wake-up mechanism enable status */ /* Bits 3-31: Reserved */ +/* CCU1 Branch Clock EMCDIV Configuration Registers */ + +#define CCU_CLK_EMCDIV_CFG_RUN (1 << 0) /* Bit 0: Run enable */ +#define CCU_CLK_EMCDIV_CFG_AUTO (1 << 1) /* Bit 1: Auto (AHB disable mechanism) enable */ +#define CCU_CLK_EMCDIV_CFG_WAKEUP (1 << 2) /* Bit 2: Wake-up mechanism enable */ + /* Bits 3-4: Reserved */ +#define CCU_CLK_EMCDIV_CLOCK_DIV_SHIFT (5) /* Bits 5-7: Clock divider */ +#define CCU_CLK_EMCDIV_CLOCK_DIV_MASK (7 << CCU_CLK_EMCDIV_CLOCK_DIV_SHIFT) +# define CCU_CLK_EMCDIV_CFG_DIV_FUNC(n) ((n) << CCU_CLK_EMCDIV_CLOCK_DIV_SHIFT) +# define CCU_CLK_EMCDIV_CFG_DIV_NODIV (0 << CCU_CLK_EMCDIV_CLOCK_DIV_SHIFT) /* Bit 5-7: No division */ +# define CCU_CLK_EMCDIV_CFG_DIV_BY2 (1 << CCU_CLK_EMCDIV_CLOCK_DIV_SHIFT) /* Bit 5-7: Division by 2 */ + /* Bits 8-26: Reserved */ +#define CCU_CLK_EMCDIV_CLOCK_DIVSTAT_SHIFT (27) /* Bits 27-29: Clock divider status */ +#define CCU_CLK_EMCDIV_CLOCK_DIVSTAT_MASK (7 << CCU_CLK_EMCDIV_CLOCK_DIVSTAT_SHIFT) +# define CCU_CLK_EMCDIV_CFG_DIVSTAT_NODIV (0 << CCU_CLK_EMCDIV_CLOCK_DIVSTAT_SHIFT) /* Bit 27-29: No division */ +# define CCU_CLK_EMCDIV_CFG_DIVSTAT_BY2 (1 << CCU_CLK_EMCDIV_CLOCK_DIVSTAT_MASK) /* Bit 26-29: Divistion by 2 */ + /**************************************************************************************************** * Public Types ****************************************************************************************************/ diff --git a/arch/arm/src/lpc43xx/chip/lpc43_emc.h b/arch/arm/src/lpc43xx/chip/lpc43_emc.h index 4fb3ae38be6..b61cbcbc585 100644 --- a/arch/arm/src/lpc43xx/chip/lpc43_emc.h +++ b/arch/arm/src/lpc43xx/chip/lpc43_emc.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * arch/arm/src/lpc43xx/chip/lpc43_emc.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ /**************************************************************************************************** * Pre-processor Definitions ****************************************************************************************************/ + /* Register Offsets *********************************************************************************/ #define LPC43_EMC_CONTROL_OFFSET 0x0000 /* EMC Control register */ @@ -213,6 +214,7 @@ #define EMC_CONTROL_LOWPOWER (1 << 2) /* Bit 2: Low-power mode */ /* Bits 3-31: Reserved */ /* EMC Status register */ + #define EMC__ #define EMC_STATUS_BUSY (1 << 0) /* Bit 0: Busy */ #define EMC_STATUS_WB (1 << 1) /* Bit 1: Write buffer status */ @@ -333,13 +335,64 @@ # define EMC_DYNCONFIG_MD_SDRAM (0 << EMC_DYNCONFIG_MD_SHIFT) /* SDRAM (POR reset value) */ /* Bits 5-6: Reserved */ #define EMC_DYNCONFIG_AM0_SHIFT (7) /* Bits 7-12: AM0 Address mapping (see user manual) */ -#define EMC_DYNCONFIG_AM0_MASK (0x3f << EMC_DYNCONFIG_AM0_SHIFT) +#define EMC_DYNCONFIG_AM0_MASK (0x3F << EMC_DYNCONFIG_AM0_SHIFT) /* Bit 13: Reserved */ #define EMC_DYNCONFIG_AM1 (1 << 14) /* Bit 14: AM1 Address mapping (see user manual) */ /* Bits 15-18: Reserved */ -#define EMC_DYNCONFIG_BENA (1 << 10) /* Bit 19: Buffer enable */ +#define EMC_DYNCONFIG_BENA (1 << 19) /* Bit 19: Buffer enable */ #define EMC_DYNCONFIG_WP (1 << 20) /* Bit 20: Write protect. */ /* Bits 21-31: Reserved */ + +/* Dynamic Memory Configuration register Memory Configuration Values */ +/* TODO: complete configuration */ + +/* Data Bus Width Value in LPC43_EMC_DYNCONFIG register (bit 14) */ + +#define EMC_DYNCONFIG_DATA_BUS_16 (0 << 14) /* Data bus width 16 bit */ +#define EMC_DYNCONFIG_DATA_BUS_32 (1 << 14) /* Data bus width 32 bit */ + +/* Low power SDRAM value in LPC43_EMC_DYNCONFIG register (bit 12) */ + +#define EMC_DYNCONFIG_LPSDRAM (1 << 12) /* Low power SDRAM value (Bank, Row, Column)*/ +#define EMC_DYNCONFIG_HPSDRAM (0 << 12) /* High performance SDRAM value (Row, Bank, Column)*/ + +/* Address mapping table for LPC43_EMC_DYNCONFIG register (bits 7-11) */ + +/* Device size bits in LPC43_EMC_DYNCONFIG register (bits 9-11) */ + +#define EMC_DYNCONFIG_DEV_SIZE_SHIFT (9) +#define EMC_DYNCONFIG_DEV_SIZE_MASK (0x7) +# define EMC_DYNCONFIG_DEV_SIZE_16Mb (0x00 << EMC_DYNCONFIG_DEV_SIZE_SHIFT) +# define EMC_DYNCONFIG_DEV_SIZE_64Mb (0x01 << EMC_DYNCONFIG_DEV_SIZE_SHIFT) +# define EMC_DYNCONFIG_DEV_SIZE_128Mb (0x02 << EMC_DYNCONFIG_DEV_SIZE_SHIFT) +# define EMC_DYNCONFIG_DEV_SIZE_256Mb (0x03 << EMC_DYNCONFIG_DEV_SIZE_SHIFT) +# define EMC_DYNCONFIG_DEV_SIZE_512Mb (0x04 << EMC_DYNCONFIG_DEV_SIZE_SHIFT) + +/* Bus width bits in LPC43_EMC_DYNCONFIG register (bits 7-8) */ + +#define EMC_DYNCONFIG_DEV_BUS_SHIFT (7) +#define EMC_DYNCONFIG_DEV_BUS_MASK (0x3) +# define EMC_DYNCONFIG_DEV_BUS_8 (0x00 << EMC_DYNCONFIG_DEV_BUS_SHIFT) +# define EMC_DYNCONFIG_DEV_BUS_16 (0x01 << EMC_DYNCONFIG_DEV_BUS_SHIFT) +# define EMC_DYNCONFIG_DEV_BUS_32 (0x02 << EMC_DYNCONFIG_DEV_BUS_SHIFT) + +#define EMC_DYNCONFIG_2Mx8_2BANKS_11ROWS_9COLS ((0x0 << 9) | (0x0 << 7)) /* 16Mb (2Mx8), 2 banks, row length = 11, column length = 9 */ +#define EMC_DYNCONFIG_1Mx16_2BANKS_11ROWS_8COLS ((0x0 << 9) | (0x1 << 7)) /* 16Mb (1Mx16), 2 banks, row length = 11, column length = 8 */ +#define EMC_DYNCONFIG_8Mx8_4BANKS_12ROWS_9COLS ((0x1 << 9) | (0x0 << 7)) /* 64Mb (8Mx8), 4 banks, row length = 12, column length = 9 */ +#define EMC_DYNCONFIG_4Mx16_4BANKS_12ROWS_8COLS ((0x1 << 9) | (0x1 << 7)) /* 64Mb (4Mx16), 4 banks, row length = 12, column length = 8 */ +#define EMC_DYNCONFIG_2Mx32_4BANKS_11ROWS_8COLS ((0x1 << 9) | (0x2 << 7)) /* 64Mb (2Mx32), 4 banks, row length = 11, column length = 8, 32 bit bus only */ +#define EMC_DYNCONFIG_16Mx8_4BANKS_12ROWS_10COLS ((0x2 << 9) | (0x0 << 7)) /* 128Mb (16Mx8), 4 banks, row length = 12, column length = 10 */ +#define EMC_DYNCONFIG_8Mx16_4BANKS_12ROWS_9COLS ((0x2 << 9) | (0x1 << 7)) /* 128Mb (8Mx16), 4 banks, row length = 12, column length = 9 */ +#define EMC_DYNCONFIG_4Mx32_4BANKS_12ROWS_8COLS ((0x2 << 9) | (0x2 << 7)) /* 128Mb (4Mx32), 4 banks, row length = 12, column length = 8 */ +#define EMC_DYNCONFIG_32Mx8_4BANKS_13ROWS_10COLS ((0x3 << 9) | (0x0 << 7)) /* 256Mb (32Mx8), 4 banks, row length = 13, column length = 10, 32 bit bus only */ +#define EMC_DYNCONFIG_16Mx16_4BANKS_13ROWS_9COLS ((0x3 << 9) | (0x1 << 7)) /* 256Mb (16Mx16), 4 banks, row length = 13, column length = 9 */ +#define EMC_DYNCONFIG_8Mx32_4BANKS_13ROWS_8COLS ((0x3 << 9) | (0x2 << 7)) /* 256Mb (8Mx32), 4 banks, row length = 13, column length = 8, 32 bit bus only */ +#define EMC_DYNCONFIG_8Mx32_4BANKS_12ROWS_9COLS ((0x2 << 9) | (0x1 << 7)) /* 256Mb (8Mx32), 4 banks, row length = 12, column length = 9, 32 bit bus only */ +#define EMC_DYNCONFIG_64Mx8_4BANKS_13ROWS_10COLS ((0x4 << 9) | (0x0 << 7)) /* 512Mb (64Mx8), 4 banks, row length = 13, column length = 11 */ +#define EMC_DYNCONFIG_32Mx16_4BANKS_13ROWS_10COLS ((0x4 << 9) | (0x1 << 7)) /* 512Mb (32Mx16), 4 banks, row length = 13, column length = 10 */ +#define EMC_DYNCONFIG_16Mx32_4BANKS_13ROWS_9COLS ((0x3 << 9) | (0x1 << 7)) /* 512Mb (16Mx32), 4 banks, row length = 13, column length = 9, 32 bit bus only */ +#define EMC_DYNCONFIG_32Mx32_4BANKS_13ROWS_10COLS ((0x4 << 9) | (0x1 << 7)) /* 1Gb (32Mx32), 4 banks, row length = 13, column length = 10,32 bit bus only */ + /* Dynamic Memory RAS & CAS Delay registers */ #define EMC_DYNRASCAS_RAS_SHIFT (0) /* Bits 0-1: RAS latency (active to read/write delay) */ @@ -354,6 +407,35 @@ # define EMC_DYNRASCAS_CAS_2CCLK (2 << EMC_DYNRASCAS_CAS_SHIFT) /* Two CCLK cycles */ # define EMC_DYNRASCAS_CAS_3CCLK (3 << EMC_DYNRASCAS_CAS_SHIFT) /* Three CCLK cycles (POR reset value) */ /* Bits 10-31: Reserved */ + +/* Dynamic SDRAM mode register definitions */ + + /* Bits 0-2: Burst length. All other values are reserved. */ +#define EMC_DYNMODE_BURST_LENGTH_SHIFT (0) +#define EMC_DYNMODE_BURST_LENGTH_MASK (0x7) +# define EMC_DYNMODE_BURST_LENGTH_1 (0 << EMC_DYNMODE_BURST_LENGTH_SHIFT) +# define EMC_DYNMODE_BURST_LENGTH_2 (1 << EMC_DYNMODE_BURST_LENGTH_SHIFT) +# define EMC_DYNMODE_BURST_LENGTH_4 (2 << EMC_DYNMODE_BURST_LENGTH_SHIFT) +# define EMC_DYNMODE_BURST_LENGTH_8 (3 << EMC_DYNMODE_BURST_LENGTH_SHIFT) + /* Bit 3: Burst mode type */ +#define EMC_DYNMODE_BURST_TYPE_SHIFT (3) +# define EMC_DYNMODE_BURST_TYPE_SEQUENTIAL (0 << EMC_DYNMODE_BURST_TYPE_SHIFT) /* burst type sequential */ +# define EMC_DYNMODE_BURST_TYPE_INTERLEAVED (1 << EMC_DYNMODE_BURST_TYPE_INTERLEAVED) /* burst type interleaved */ + /* Bits 4-6: Latency mode. All other values are reserved. */ +#define EMC_DYNMODE_CAS_SHIFT (4) +#define EMC_DYNMODE_CAS_MASK (0x7) +# define EMC_DYNMODE_CAS_2 (2 << EMC_DYNMODE_CAS_SHIFT) /* CAS latency of 2 cycles */ +# define EMC_DYNMODE_CAS_3 (3 << EMC_DYNMODE_CAS_SHIFT) /* CAS latency of 3 cycles */ + /* Bits 7-8: Operating mode. All other values are reserved. */ +#define EMC_DYNMODE_OPMODE_SHIFT (7) +#define EMC_DYNMODE_OPMODE_MASK (0x3) +# define EMC_DYNMODE_OPMODE_STANDARD (0 << EMC_DYNMODE_OPMODE_SHIFT) /* dynamic standard operation mode */ + /* Bit 9: Write burst mode */ +#define EMC_DYNMODE_WBMODE_SHIFT (9) +# define EMC_DYNMODE_WBMODE_PROGRAMMED (0 << EMC_DYNMODE_WBMODE_SHIFT) /* write burst mode programmed */ +# define EMC_DYNMODE_WBMODE_SINGLE_LOC (1 << EMC_DYNMODE_WBMODE_SHIFT) /* write burst mode single loc */ + /* Bits 10-11: Reserved */ + /* Static Memory Configuration registers */ #define EMC_STATCONFIG_MW_SHIFT (0) /* Bits 0-1: Memory width */ diff --git a/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/arch/arm/src/lpc43xx/lpc43_allocateheap.c index 70a0bbe5873..84b918051fe 100644 --- a/arch/arm/src/lpc43xx/lpc43_allocateheap.c +++ b/arch/arm/src/lpc43xx/lpc43_allocateheap.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43xx/lpc43_allocateheap.c * - * Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013, 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Get customizations for each supported chip. * * SRAM Resources @@ -95,6 +96,25 @@ * NOTE 1: The 64Kb of AHB of SRAM on the LPC4350/30/20 span all AHB SRAM * banks but are treated as two banks of 48 an 16Kb by the NuttX memory * manager. This gives some symmetry to all of the members of the family. + * + * ---------------------------------------------------------------------- + * EMC SDRAM + * ---------------------------------------------------------------------- + * LPC43xx may have dynamic RAM connected on EMC bus. Up to 4 chips can be + * connected. + * + * DYCS0 (0x2800 0000) up to 128MB + * DYCS1 (0x3000 0000) up to 256MB + * DYCS2 (0x6000 0000) up to 256MB + * DYCS3 (0x7000 0000) up to 256MB + * + * LPC43xx may have static RAM connected on EMC bus. + * + * CS0 (0x1C00 0000) up to 16MB + * CS1 (0x1D00 0000) up to 16MB + * CS2 (0x1E00 0000) up to 16MB + * CS3 (0x1F00 0000) up to 16MB + * */ /* Configuration ************************************************************/ @@ -136,58 +156,88 @@ * * CONFIG_RAM_START = The start of the data RAM region which may be * either local SRAM bank 0 (Configuration A) or 1 (Configuration B). - * CONFIG_RAM_START = The size of the data RAM region. - * CONFIG_RAM_END = The sum of the above + * CONFIG_RAM_SIZE = The size of the data RAM region. + * CONFIG_RAM_END = The sum of the above. + */ + +/* External Memory Configuration + * + * Dynamic memory configuration + * For dynamic memory configuration at least one of LPC43_EXTSDRAMx + * should by defined. + * Also, together with LPC43_EXTSDRAMx should be defined: + * LPC43_EXTSDRAMxSIZE = External RAM size in bytes. + * LPC43_EXTSDRAMxHEAP = Should this RAM be use as heap space? */ /* Check for Configuration A. */ +#undef MM_USE_LOCSRAM_BANK0 +#undef MM_USE_LOCSRAM_BANK1 +#undef MM_USE_AHBSRAM_BANK0 +#undef MM_USE_AHBSRAM_BANK1 +#undef MM_USE_AHBSRAM_BANK2 +#undef MM_USE_EXTSDRAM0 +#undef MM_USE_EXTSDRAM1 +#undef MM_USE_EXTSDRAM2 +#undef MM_USE_EXTSDRAM3 + #ifndef CONFIG_LPC43_BOOT_SRAM /* Configuration A */ -/* CONFIG_RAM_START should be set to the base of AHB SRAM, local 0. */ +/* CONFIG_RAM_START shoudl be set to the base of local SRAM, Bank 0. */ # if CONFIG_RAM_START != LPC43_LOCSRAM_BANK0_BASE -# error "CONFIG_RAM_START must be set to the base address of RAM Bank 0" +# error "CONFIG_RAM_START must be set to the base address of RAM bank 0" # endif -/* The configured RAM size should be equal to the size of local SRAM Bank 0 */ +/* The configured RAM size should be equal to the size of local SRAM Bank 0. */ # if CONFIG_RAM_SIZE != LPC43_LOCSRAM_BANK0_SIZE -# error "CONFIG_RAM_SIZE must be set to size of AHB SRAM Bank 0" +# error "CONFIG_RAM_SIZE must be set to size of local SRAM Bank 0" # endif -/* Now we can assign all of the memory regions for configuration A */ +/* Local SRAM Bank 0 will be used as main memory region */ -# define MM_REGION1_BASE LPC43_LOCSRAM_BANK0_BASE -# define MM_REGION1_SIZE LPC43_LOCSRAM_BANK0_SIZE -# define MM_REGION2_BASE LPC43_LOCSRAM_BANK1_BASE -# define MM_REGION2_SIZE LPC43_LOCSRAM_BANK1_SIZE -# define MM_REGION3_BASE LPC43_AHBSRAM_BANK0_BASE -# define MM_REGION3_SIZE LPC43_AHBSRAM_BANK0_SIZE -#else +# define MM_USE_LOCSRAM_BANK0 0 + +/* Use local SRAM Bank 1 if configured */ + +# ifdef CONFIG_LPC43_USE_LOCSRAM_BANK1 +# define MM_USE_LOCSRAM_BANK1 1 +# endif + +#else /* CONFIG_LPC43_BOOT_SRAM */ /* Configuration B */ -/* CONFIG_RAM_START should be set to the base of local SRAM, bank 1. */ +/* CONFIG_RAM_START should be set to the base of local SRAM, Bank 1. */ # if CONFIG_RAM_START != LPC43_LOCSRAM_BANK1_BASE -# error "CONFIG_RAM_START must be set to the base address of SRAM Bank 1" +# error "CONFIG_RAM_START must be set to the base address of RAM bank 1" # endif -/* The configured RAM size should be equal to the size of local SRAM Bank 1 */ +/* The configured RAM size should be equal to the size of local SRAM Bank 1. */ # if CONFIG_RAM_SIZE != LPC43_LOCSRAM_BANK1_SIZE -# error "CONFIG_RAM_SIZE must be set to size of AHB SRAM Bank 1" +# error "CONFIG_RAM_SIZE must be set to size of local SRAM Bank 1" # endif -/* Now we can assign all of the memory regions for configuration B */ +/* Shouldn't use Local SRAM Bank 0 as system use it for code. + * Local SRAM Bank1 is used as main memory region. + */ -# define MM_REGION1_BASE LPC43_LOCSRAM_BANK1_BASE -# define MM_REGION1_SIZE LPC43_LOCSRAM_BANK1_SIZE -# define MM_REGION2_BASE LPC43_AHBSRAM_BANK0_BASE -# define MM_REGION2_SIZE LPC43_AHBSRAM_BANK0_SIZE -# undef MM_REGION3_BASE -# undef MM_REGION3_SIZE +# define MM_USE_LOCSRAM_BANK1 0 + +#endif /* CONFIG_LPC43_BOOT_SRAM */ + +/* Configure other memory banks */ + +#ifdef CONFIG_LPC43_AHBSRAM_BANK0 +# define MM_USE_AHBSRAM_BANK0 1 +#endif + +#ifdef CONFIG_LPC43_AHBSRAM_BANK1 +# define MM_USE_AHBSRAM_BANK1 1 #endif #define MM_DMAREGION_BASE LPC43_AHBSRAM_BANK2_BASE @@ -199,8 +249,61 @@ #warning "Missing Logic" -#define MM_DMAHEAP_BASE MM_DMAREGION_BASE /* For now... use it all */ -#define MM_DMAHEAP_SIZE MM_DMAREGION_SIZE +#ifdef CONFIG_LPC43_AHBSRAM_BANK2 +# define MM_USE_AHBSRAM_BANK2 1 +# define MM_DMAHEAP_BASE MM_DMAREGION_BASE /* For now... use it all */ +# define MM_DMAHEAP_SIZE MM_DMAREGION_SIZE +#endif + +/* External RAM configuration */ + +/* Check if external SDRAM is supported and, if so, it is intended to be used + * used as heap. + */ + +#if !defined(CONFIG_LPC43_EXTSDRAM0) || !defined(CONFIG_LPC43_EXTSDRAM0_HEAP) +# undef CONFIG_LPC43_EXTSDRAM0_SIZE +# define CONFIG_LPC43_EXTSDRAM0_SIZE 0 +#endif + +#if !defined(CONFIG_LPC43_EXTSDRAM1) || !defined(CONFIG_LPC43_EXTSDRAM1_HEAP) +# undef CONFIG_LPC43_EXTSDRAM1_SIZE +# define CONFIG_LPC43_EXTSDRAM1_SIZE 0 +#endif + +#if !defined(CONFIG_LPC43_EXTSDRAM2) || !defined(CONFIG_LPC43_EXTSDRAM2_HEAP) +# undef CONFIG_LPC43_EXTSDRAM2_SIZE +# define CONFIG_LPC43_EXTSDRAM2_SIZE 0 +#endif + +#if !defined(CONFIG_LPC43_EXTSDRAM3) || !defined(CONFIG_LPC43_EXTSDRAM3_HEAP) +# undef CONFIG_LPC43_EXTSDRAM3_SIZE +# define CONFIG_LPC43_EXTSDRAM3_SIZE 0 +#endif + +#if CONFIG_LPC43_EXTSDRAM0_SIZE > 0 +# define MM_USE_EXTSDRAM0 1 +# define MM_EXTSDRAM0_REGION LPC43_DYCS0_BASE +# define MM_EXTSDRAM0_SIZE CONFIG_LPC43_EXTSDRAM0_SIZE +#endif /* CONFIG_LPC43_EXTSDRAM0_SIZE */ + +#if CONFIG_LPC43_EXTSDRAM1_SIZE > 0 +# define MM_USE_EXTSDRAM1 1 +# define MM_EXTSDRAM1_REGION LPC43_DYCS1_BASE +# define MM_EXTSDRAM1_SIZE CONFIG_LPC43_EXTSDRAM1_SIZE +#endif /* CONFIG_LPC43_EXTSDRAM1_SIZE */ + +#if CONFIG_LPC43_EXTSDRAM2_SIZE > 0 +# define MM_USE_EXTSDRAM2 1 +# define MM_EXTSDRAM2_REGION LPC43_DYCS2_BASE +# define MM_EXTSDRAM2_SIZE CONFIG_LPC43_EXTSDRAM2_SIZE +#endif /* CONFIG_LPC43_EXTSDRAM1_SIZE */ + +#if CONFIG_LPC43_EXTSDRAM3_SIZE > 0 +# define HAVE_EXTSDRAM3_REGION 1 +# define MM_EXTSDRAM3_REGION LPC43_DYCS3_BASE +# define MM_EXTSDRAM3_SIZE CONFIG_LPC43_EXTSDRAM3_SIZE +#endif /* CONFIG_LPC43_EXTSDRAM3_SIZE */ /**************************************************************************** * Private Data @@ -216,15 +319,26 @@ * thread is the thread that the system boots on and, eventually, becomes the * idle, do nothing task that runs only when there is nothing else to run. * The heap continues from there until the configured end of memory. - * g_idle_topstack is the beginning of this heap region (not necessarily aligned). + * g_idle_topstack is the beginning of this heap region (not necessarily + * aligned). */ const uint32_t g_idle_topstack = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; +static uint32_t mem_region_next = 0; /**************************************************************************** * Private Functions ****************************************************************************/ +static void mem_addregion(FAR void *region_start, size_t region_size) +{ + if (mem_region_next <= CONFIG_MM_REGIONS) + { + kmm_addregion(region_start, region_size); + mem_region_next++; + } +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -266,34 +380,43 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) void up_addregion(void) { #if CONFIG_MM_REGIONS > 1 - /* Add the next SRAM region (which should exist) */ - kmm_addregion((FAR void *)MM_REGION2_BASE, MM_REGION2_SIZE); + /* start from second region */ -#ifdef MM_REGION3_BASE - /* Add the third SRAM region (which will not exist in configuration B) */ + mem_region_next = 2; -#if CONFIG_MM_REGIONS > 2 - /* Add the third SRAM region (which may not exist) */ +# ifdef MM_USE_LOCSRAM_BANK1 + mem_addregion((FAR void *)LPC43_LOCSRAM_BANK1_BASE, LPC43_LOCSRAM_BANK1_SIZE); +# endif - kmm_addregion((FAR void *)MM_REGION3_BASE, MM_REGION3_SIZE); +# ifdef MM_USE_AHBSRAM_BANK0 + mem_addregion((FAR void *)LPC43_AHBSRAM_BANK0_BASE, LPC43_AHBSRAM_BANK0_SIZE); +# endif -#if CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE) - /* Add the DMA region (which may not be available) */ +# ifdef MM_USE_AHBSRAM_BANK1 + mem_addregion((FAR void *)LPC43_AHBSRAM_BANK1_BASE, LPC43_AHBSRAM_BANK1_SIZE); +# endif - kmm_addregion((FAR void *)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE); +# ifdef MM_USE_AHBSRAM_BANK2 + mem_addregion((FAR void *)MM_DMAREGION_BASE, MM_DMAREGION_SIZE); +# endif -#endif /* CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE) */ -#endif /* CONFIG_MM_REGIONS > 2 */ -#else /* MM_REGION3_BASE */ +# ifdef MM_USE_EXTSDRAM0 + mem_addregion((FAR void *)MM_EXTSDRAM0_REGION, MM_EXTSDRAM0_SIZE); +# endif -#if CONFIG_MM_REGIONS > 2 && defined(MM_DMAHEAP_BASE) - /* Add the DMA region (which may not be available) */ +# ifdef MM_USE_EXTSDRAM1 + mem_addregion((FAR void *)MM_EXTSDRAM1_REGION, MM_EXTSDRAM1_SIZE); +# endif - kmm_addregion((FAR void *)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE); +# ifdef MM_USE_EXTSDRAM2 + mem_addregion((FAR void *)MM_EXTSDRAM2_REGION, MM_EXTSDRAM2_SIZE); +# endif + +# ifdef MM_USE_EXTSDRAM3 + mem_addregion((FAR void *)MM_EXTSDRAM3_REGION, MM_EXTSDRAM3_SIZE); +# endif -#endif /* CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE) */ -#endif /* MM_REGION3_BASE */ #endif /* CONFIG_MM_REGIONS > 1 */ } #endif diff --git a/arch/arm/src/lpc43xx/lpc43_emc.c b/arch/arm/src/lpc43xx/lpc43_emc.c new file mode 100644 index 00000000000..a15ecb5610d --- /dev/null +++ b/arch/arm/src/lpc43xx/lpc43_emc.c @@ -0,0 +1,141 @@ +/**************************************************************************** + * arch/arm/src/lpc43xx/lpc43_emc.c + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + +/* TODO: add #if defined(CONFIG_LPC43_EMC) */ + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include + +#include "up_internal.h" + +#include "chip.h" +#include "lpc43_pinconfig.h" +#include "lpc43_emc.h" +#include "chip/lpc43_creg.h" +#include "chip/lpc43_cgu.h" +#include "chip/lpc43_ccu.h" +#include "lpc43_rgu.h" +#include "lpc43_gpio.h" +#include "up_arch.h" +#include + + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lpc43_emcinit + * + * Description: + * Initialize EMC controller. Start in full power + * mode. + * + ****************************************************************************/ +void lpc43_emcinit(uint32_t enable, uint32_t clock_ratio, uint32_t endian_mode) +{ + uint32_t regval; + + /* Enable clock for EMC controller. */ + + regval = getreg32(LPC43_CCU1_M4_EMC_CFG); + regval |= CCU_CLK_CFG_RUN; + putreg32(regval, LPC43_CCU1_M4_EMC_CFG); + + /* Configure endian mode and clock ratio. */ + + regval = 0; + if (endian_mode) + regval |= EMC_CONFIG_EM; + if (clock_ratio) + regval |= EMC_CONFIG_CR; + + putreg32(regval, LPC43_EMC_CONFIG); + + /* Enable EMC 001 normal memory map, no low power mode. */ + + putreg32(EMC_CONTROL_ENA, LPC43_EMC_CONTROL); +} + +/**************************************************************************** + * Name: lpc43_lowpowermode + * + * Description: + * Set EMC lowpower mode. + * + ****************************************************************************/ +void lpc43_lowpowermode(uint8_t enable) +{ + uint32_t regval; + + regval = getreg32(LPC43_EMC_CONTROL); + if (enable) + { + regval |= EMC_CONTROL_LOWPOWER; + putreg32(regval, LPC43_EMC_CONTROL); + } + else + { + regval &= ~EMC_CONTROL_LOWPOWER; + putreg32(regval, LPC43_EMC_CONTROL); + } +} + +/**************************************************************************** + * Name: lpc43_emcenable + * + * Description: + * Enable or disable EMC controller. + * + ****************************************************************************/ +void lpc43_emcenable(uint8_t enable) +{ + uint32_t regval; + + regval = getreg32(LPC43_EMC_CONTROL); + if (enable) + { + regval |= EMC_CONTROL_ENA; + putreg32(regval, LPC43_EMC_CONTROL); + } + else + { + regval &= ~EMC_CONTROL_ENA; + putreg32(regval, LPC43_EMC_CONTROL); + } +} diff --git a/arch/arm/src/lpc43xx/lpc43_emc.h b/arch/arm/src/lpc43xx/lpc43_emc.h index 3c2bd2496fe..77b71d86120 100644 --- a/arch/arm/src/lpc43xx/lpc43_emc.h +++ b/arch/arm/src/lpc43xx/lpc43_emc.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/lpc43xx/lpc43_emc.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,16 +48,22 @@ * Pre-processor Definitions ************************************************************************************/ -/************************************************************************************ - * Public Types - ************************************************************************************/ +/* Chip select Definitions **********************************************************/ + +#define EMC_CS0 0 +#define EMC_CS1 1 +#define EMC_CS2 2 +#define EMC_CS3 3 + +#define EMC_DYNCS0 0 +#define EMC_DYNCS1 1 +#define EMC_DYNCS2 2 +#define EMC_DYNCS3 3 /************************************************************************************ - * Public Data + * Public Function Prototypes ************************************************************************************/ -/************************************************************************************ - * Public Functions - ************************************************************************************/ +void lpc43_emcinit(uint32_t enable, uint32_t clock_ratio, uint32_t endian_mode); #endif /* __ARCH_ARM_SRC_LPC43XX_LPC43_EMC_H */ From 148cf1ac221be631d475a905fc31fcf55b110880 Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Tue, 19 Jul 2016 07:33:44 -0600 Subject: [PATCH 077/152] Adds the simulated QSPI (N25Q) flash to the simulation and modify sim up_spiflash.c to enable it to run with different MTD drivers based on config options (currently m25p, sst26 and w25). --- arch/sim/Kconfig | 134 ++++++++++++++++++++++++++---- arch/sim/src/Makefile | 2 +- arch/sim/src/up_initialize.c | 76 ++++++++++++++--- arch/sim/src/up_internal.h | 7 +- arch/sim/src/up_spiflash.c | 154 +++++++++++++++++++++++++++++------ 5 files changed, 320 insertions(+), 53 deletions(-) diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index 7384d3d7230..614b8e7ef7e 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -245,20 +245,6 @@ config SIM_SPIFLASH_128M endchoice -config SIM_SPIFLASH_MANUFACTURER - hex "Hex ID of the FLASH manufacturer code" - default 0x20 - depends on SIM_SPIFLASH - ---help--- - Allows the simulated FLASH Manufacturer ID to be set. - -config SIM_SPIFLASH_MEMORY_TYPE - hex "Hex ID of the FLASH Memory Type code" - default 0x20 - depends on SIM_SPIFLASH - ---help--- - Allows the simulated FLASH Memory Type code to be set. - config SIM_SPIFLASH_SECTORSIZE int "FLASH Sector Erase Size" default 65536 @@ -277,6 +263,51 @@ config SIM_SPIFLASH_SUBSECTORSIZE Sets the smaller sub-sector erase size supported by the FLASH emulation +config SIM_SPIFLASH_M25P + bool "Enable M25Pxx FLASH" + depends on MTD_M25P + ---help--- + Enables simulation of an M25P type FLASH + +config SIM_SPIFLASH_SST26 + bool "Enable SST26 FLASH" + depends on MTD_SST26 + ---help--- + Enables simulation of an SST26 type FLASH + +config SIM_SPIFLASH_W25 + bool "Enable W25 FLASH" + depends on MTD_W25 + ---help--- + Enables simulation of a W25 type FLASH + +config SIM_SPIFLASH_CUSTOM + bool "Enable Emulation of a Custom Manufacturer / ID FLASH" + depends on SIM_SPIFLASH + ---help--- + Enables simulation of FLASH with a custom Manufacturer, ID and Capacity + +config SIM_SPIFLASH_MANUFACTURER + hex "Hex ID of the FLASH manufacturer code" + default 0x20 + depends on SIM_SPIFLASH_CUSTOM + ---help--- + Allows the simulated FLASH Manufacturer ID to be set. + +config SIM_SPIFLASH_MEMORY_TYPE + hex "Hex ID of the FLASH Memory Type code" + default 0x20 + depends on SIM_SPIFLASH_CUSTOM + ---help--- + Allows the simulated FLASH Memory Type code to be set. + +config SIM_SPIFLASH_CAPACITY + hex "Hex ID of the FLASH capacity code" + default 0x14 + depends on SIM_SPIFLASH_CUSTOM + ---help--- + Allows the simulated FLASH Memory Capacity code to be set. + config SIM_SPIFLASH_PAGESIZE int "FLASH Write / Program Page Size" default 256 @@ -289,4 +320,79 @@ config SIM_SPIFLASH_PAGESIZE "wrap" causing the initial data sent to be overwritten. This is consistent with standard SPI FLASH operation. +config SIM_QSPIFLASH + bool "Simulated QSPI FLASH with SMARTFS" + default n + select FS_SMARTFS + select MTD_SMART + ---help--- + Adds a simulated QSPI FLASH that responds to N25QXXX style + commands on the QSPI bus. + +choice + prompt "Simulated QSPI FLASH Size" + default SIM_QSPIFLASH_1M + depends on SIM_QSPIFLASH + +config SIM_QSPIFLASH_1M + bool "1 MBit (128K Byte)" + +config SIM_QSPIFLASH_8M + bool "8 MBit (1M Byte)" + +config SIM_QSPIFLASH_32M + bool "32 MBit (4M Byte)" + +config SIM_QSPIFLASH_64M + bool "64 MBit (8M Byte)" + +config SIM_QSPIFLASH_128M + bool "128 MBit (16M Byte)" + +endchoice + +config SIM_QSPIFLASH_MANUFACTURER + hex "Hex ID of the FLASH manufacturer code" + default 0x20 + depends on SIM_QSPIFLASH + ---help--- + Allows the simulated FLASH Manufacturer ID to be set. + +config SIM_QSPIFLASH_MEMORY_TYPE + hex "Hex ID of the FLASH Memory Type code" + default 0xba + depends on SIM_QSPIFLASH + ---help--- + Allows the simulated FLASH Memory Type code to be set. + +config SIM_QSPIFLASH_SECTORSIZE + int "FLASH Sector Erase Size" + default 65536 + depends on SIM_QSPIFLASH + ---help--- + Sets the large sector erase size that the part simulates. + This driver simulates QSPI devices that have both a large + sector erase as well as a "sub-sector" (per the datasheet) + erase size (typically 4K bytes). + +config SIM_QSPIFLASH_SUBSECTORSIZE + int "FLASH Sub-Sector Erase Size" + default 4096 + depends on SIM_QSPIFLASH + ---help--- + Sets the smaller sub-sector erase size supported by the + FLASH emulation + +config SIM_QSPIFLASH_PAGESIZE + int "FLASH Write / Program Page Size" + default 256 + depends on SIM_QSPIFLASH + ---help--- + Sets the size of a page program operation. The page size + represents the maximum number of bytes that can be sent + for a program operation. If more bytes than this are + sent on a single Page Program, then the address will + "wrap" causing the initial data sent to be overwritten. + This is consistent with standard SPI FLASH operation. + endif diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 72401d6c773..fdac7796be5 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -57,7 +57,7 @@ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c CSRCS += up_createstack.c up_usestack.c up_releasestack.c up_stackframe.c CSRCS += up_unblocktask.c up_blocktask.c up_releasepending.c CSRCS += up_reprioritizertr.c up_exit.c up_schedulesigaction.c up_spiflash.c -CSRCS += up_allocateheap.c up_devconsole.c +CSRCS += up_allocateheap.c up_devconsole.c up_qspiflash.c HOSTSRCS = up_hostusleep.c diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index cc670ef93ed..41f21a36941 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -71,32 +71,86 @@ * ****************************************************************************/ -#if defined(CONFIG_FS_SMARTFS) && defined(CONFIG_SIM_SPIFLASH) +#if defined(CONFIG_FS_SMARTFS) && (defined(CONFIG_SIM_SPIFLASH) || defined(CONFIG_SIM_QSPIFLASH)) static void up_init_smartfs(void) { FAR struct mtd_dev_s *mtd; + int minor = 0; +#if defined(CONFIG_MTD_M25P) || defined(CONFIG_MTD_W25) || defined(CONFIG_MTD_SST26) FAR struct spi_dev_s *spi; +#endif +#ifdef CONFIG_MTD_N25QXXX + FAR struct qspi_dev_s *qspi; +#endif +#ifdef CONFIG_SIM_SPIFLASH #ifdef CONFIG_MTD_M25P /* Initialize a simulated SPI FLASH block device m25p MTD driver */ - spi = up_spiflashinitialize(); - mtd = m25p_initialize(spi); + spi = up_spiflashinitialize("m25p"); + if (spi != NULL) + { + mtd = m25p_initialize(spi); - /* Now initialize a SMART Flash block device and bind it to the MTD device */ + /* Now initialize a SMART Flash block device and bind it to the MTD device */ - smart_initialize(0, mtd, NULL); + if (mtd != NULL) + { + smart_initialize(minor++, mtd, "_m25p"); + } + } +#endif + +#ifdef CONFIG_MTD_SST26 + /* Initialize a simulated SPI FLASH block device sst26 MTD driver */ + + spi = up_spiflashinitialize("sst26"); + if (spi != NULL) + { + mtd = sst26_initialize_spi(spi); + + /* Now initialize a SMART Flash block device and bind it to the MTD device */ + + if (mtd != NULL) + { + smart_initialize(minor++, mtd, "_sst26"); + } + } #endif #ifdef CONFIG_MTD_W25 - /* Initialize a simulated SPI FLASH block device m25p MTD driver */ + /* Initialize a simulated SPI FLASH block device w25 MTD driver */ - spi = up_spiflashinitialize(); - mtd = w25_initialize(spi); + spi = up_spiflashinitialize("w25"); + if (spi != NULL) + { + mtd = w25_initialize(spi); - /* Now initialize a SMART Flash block device and bind it to the MTD device */ + /* Now initialize a SMART Flash block device and bind it to the MTD device */ - smart_initialize(0, mtd, NULL); + if (mtd != NULL) + { + smart_initialize(minor++, mtd, "_w25"); + } + } +#endif +#endif /* CONFIG_SIM_SPIFLASH */ + +#if defined(CONFIG_MTD_N25QXXX) && defined(CONFIG_SIM_QSPIFLASH) + /* Initialize a simulated SPI FLASH block device n25qxxx MTD driver */ + + qspi = up_qspiflashinitialize(); + if (qspi != NULL) + { + mtd = n25qxxx_initialize(qspi, 0); + + /* Now initialize a SMART Flash block device and bind it to the MTD device */ + + if (mtd != NULL) + { + smart_initialize(minor++, mtd, "_n25q"); + } + } #endif } #endif @@ -238,7 +292,7 @@ void up_initialize(void) (void)telnet_initialize(); #endif -#if defined(CONFIG_FS_SMARTFS) && defined(CONFIG_SIM_SPIFLASH) +#if defined(CONFIG_FS_SMARTFS) && (defined(CONFIG_SIM_SPIFLASH) || defined(CONFIG_SIM_QSPIFLASH)) up_init_smartfs(); #endif } diff --git a/arch/sim/src/up_internal.h b/arch/sim/src/up_internal.h index f163e67a254..1304419af34 100644 --- a/arch/sim/src/up_internal.h +++ b/arch/sim/src/up_internal.h @@ -336,7 +336,12 @@ void netdriver_loop(void); #ifdef CONFIG_SIM_SPIFLASH struct spi_dev_s; -struct spi_dev_s *up_spiflashinitialize(void); +struct spi_dev_s *up_spiflashinitialize(FAR const char *name); +#endif + +#ifdef CONFIG_SIM_QSPIFLASH +struct qspi_dev_s; +struct qspi_dev_s *up_qspiflashinitialize(void); #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/sim/src/up_spiflash.c b/arch/sim/src/up_spiflash.c index fa3862727e3..f64a20b543a 100644 --- a/arch/sim/src/up_spiflash.c +++ b/arch/sim/src/up_spiflash.c @@ -1,7 +1,7 @@ /************************************************************************************ * arch/sim/src/up_spiflash.c * - * Copyright (C) 2014 Ken Pettit. All rights reserved. + * Copyright (C) 2014, 2016 Ken Pettit. All rights reserved. * Author: Ken Pettit * * Redistribution and use in source and binary forms, with or without @@ -63,33 +63,37 @@ /* Define the FLASH SIZE in bytes */ #ifdef CONFIG_SIM_SPIFLASH_1M -# define CONFIG_SPIFLASH_SIZE (128 * 1024) -# define CONFIG_SPIFLASH_CAPACITY 0x11 +# define CONFIG_SPIFLASH_SIZE (128 * 1024) +# define CONFIG_SPIFLASH_CAPACITY 0x11 #ifndef CONFIG_SIM_SPIFLASH_SECTORSIZE -# define CONFIG_SIM_SPIFLASH_SECTORSIZE 2048 +# define CONFIG_SIM_SPIFLASH_SECTORSIZE 2048 #endif #endif #ifdef CONFIG_SIM_SPIFLASH_8M -# define CONFIG_SPIFLASH_SIZE (1024 * 1024) -# define CONFIG_SPIFLASH_CAPACITY 0x14 +# define CONFIG_SPIFLASH_SIZE (1024 * 1024) +# define CONFIG_SPIFLASH_CAPACITY_SST26 0x3F +# define CONFIG_SPIFLASH_CAPACITY 0x14 #endif #ifdef CONFIG_SIM_SPIFLASH_32M -# define CONFIG_SPIFLASH_SIZE (4 * 1024 * 1024) -# define CONFIG_SPIFLASH_CAPACITY 0x16 +# define CONFIG_SPIFLASH_SIZE (4 * 1024 * 1024) +# define CONFIG_SPIFLASH_CAPACITY_SST26 0x42 +# define CONFIG_SPIFLASH_CAPACITY 0x16 #endif #ifdef CONFIG_SIM_SPIFLASH_64M -# define CONFIG_SPIFLASH_SIZE (8 * 1024 * 1024) -# define CONFIG_SPIFLASH_CAPACITY 0x17 +# define CONFIG_SPIFLASH_SIZE (8 * 1024 * 1024) +# define CONFIG_SPIFLASH_CAPACITY_SST26 0x43 +# define CONFIG_SPIFLASH_CAPACITY 0x17 #endif #ifdef CONFIG_SIM_SPIFLASH_128M -# define CONFIG_SPIFLASH_SIZE (16 * 1024 * 1024) -# define CONFIG_SPIFLASH_CAPACITY 0x18 +# define CONFIG_SPIFLASH_SIZE (16 * 1024 * 1024) +# define CONFIG_SPIFLASH_CAPACITY_SST26 0x44 +# define CONFIG_SPIFLASH_CAPACITY 0x18 #endif #ifndef CONFIG_SIM_SPIFLASH_MANUFACTURER @@ -169,14 +173,18 @@ struct sim_spiflashdev_s { - struct spi_dev_s spidev; /* Externally visible part of the SPI interface */ - uint32_t selected; /* SPIn base address */ - int wren; - int state; - uint16_t read_data; - uint8_t last_cmd; - unsigned long address; - unsigned char data[CONFIG_SPIFLASH_SIZE]; + struct spi_dev_s spidev; /* Externally visible part of the SPI interface */ + uint32_t selected; /* SPIn base address */ + FAR char * name; /* Name of the flash type (m25p, w25, etc.) */ + int wren; + int state; + uint16_t read_data; + uint8_t last_cmd; + uint8_t capacity; + uint8_t manuf; + uint8_t type; + unsigned long address; + unsigned char data[CONFIG_SPIFLASH_SIZE]; }; /************************************************************************************ @@ -236,9 +244,72 @@ static const struct spi_ops_s g_spiops = .registercallback = 0, }; -struct sim_spiflashdev_s g_spidev = +#ifdef CONFIG_SIM_SPIFLASH_M25P +struct sim_spiflashdev_s g_spidev_m25p = { .spidev = { &g_spiops }, + .name = "m25p", + .manuf = 0x20, + .type = 0x20, + .capacity = CONFIG_SPIFLASH_CAPACITY +}; +#endif + +#ifdef CONFIG_SIM_SPIFLASH_SST26 +struct sim_spiflashdev_s g_spidev_sst26 = +{ + .spidev = { &g_spiops }, + .name = "sst26", + .manuf = 0xBF, +#ifdef CONFIG_SST26_MEMORY_TYPE + .type = CONFIG_SST26_MEMORY_TYPE, +#else + .type = 0x25, +#endif + .capacity = CONFIG_SPIFLASH_CAPACITY_SST26 +}; +#endif + +#ifdef CONFIG_SIM_SPIFLASH_W25 +struct sim_spiflashdev_s g_spidev_w25 = +{ + .spidev = { &g_spiops }, + .name = "w25", + .manuf = 0xef, + .type = 0x30, + .capacity = CONFIG_SPIFLASH_CAPACITY +}; +#endif + +#ifdef CONFIG_SIM_SPIFLASH_CUSTOM +struct sim_spiflashdev_s g_spidev_custom = +{ + .spidev = { &g_spiops }, + .name = "custom", + .manuf = CONFIG_SIM_SPIFLASH_MANUFACTURER, + .type = CONFIG_SIM_SPIFLASH_MEMORY_TYPE, + .capacity = CONFIG_SIM_SPIFLASH_CAPACITY +}; +#endif + +struct sim_spiflashdev_s *gp_spidev[] = +{ +#ifdef CONFIG_SIM_SPIFLASH_M25P + &g_spidev_m25p, +#endif +#ifdef CONFIG_SIM_SPIFLASH_SST26 + &g_spidev_sst26, +#endif +#ifdef CONFIG_SIM_SPIFLASH_W25 + &g_spidev_w25, +#endif +#ifdef CONFIG_SIM_SPIFLASH_CUSTOM + &g_spidev_custom, +#endif + + // Null termination pointer at end of list + + NULL }; /************************************************************************************ @@ -662,17 +733,17 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data /* Read ID States */ case SPIFLASH_STATE_RDID1: - priv->read_data = CONFIG_SIM_SPIFLASH_MANUFACTURER; + priv->read_data = priv->manuf; //CONFIG_SIM_SPIFLASH_MANUFACTURER; priv->state = SPIFLASH_STATE_RDID2; break; case SPIFLASH_STATE_RDID2: - priv->read_data = CONFIG_SIM_SPIFLASH_MEMORY_TYPE; + priv->read_data = priv->type; //CONFIG_SIM_SPIFLASH_MEMORY_TYPE; priv->state = SPIFLASH_STATE_RDID3; break; case SPIFLASH_STATE_RDID3: - priv->read_data = CONFIG_SPIFLASH_CAPACITY; + priv->read_data = priv->capacity; //CONFIG_SPIFLASH_CAPACITY; priv->state = SPIFLASH_STATE_IDLE; break; @@ -834,13 +905,44 @@ static uint16_t spiflash_readword(FAR struct sim_spiflashdev_s *priv) * ************************************************************************************/ -FAR struct spi_dev_s *up_spiflashinitialize() +FAR struct spi_dev_s *up_spiflashinitialize(FAR const char *name) { FAR struct sim_spiflashdev_s *priv = NULL; + int x; irqstate_t flags = enter_critical_section(); - priv = &g_spidev; + /* Loop through all supported flash devices */ + + /* Default to custom FLASH if not specified */ + + if (name == NULL) + { + name = "custom"; + } + + for (x = 0; gp_spidev[x] != NULL; x++) + { + /* Search for the specified flash by name */ + + if (strcmp(name, gp_spidev[x]->name) == 0) + { + break; + } + } + + /* Test if flash device found */ + + if (gp_spidev[x] == NULL) + { + /* Specified device not supported */ + + return NULL; + } + + /* Configure the selected flash device */ + + priv = gp_spidev[x]; priv->selected = 0; priv->wren = 0; priv->address = 0; From 8eeecff79da940d5540c63e63b332a34858172c2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 08:19:53 -0600 Subject: [PATCH 078/152] Replace some C99 comnents with C89 comments --- arch/sim/src/up_spiflash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/sim/src/up_spiflash.c b/arch/sim/src/up_spiflash.c index f64a20b543a..ad367890697 100644 --- a/arch/sim/src/up_spiflash.c +++ b/arch/sim/src/up_spiflash.c @@ -307,7 +307,7 @@ struct sim_spiflashdev_s *gp_spidev[] = &g_spidev_custom, #endif - // Null termination pointer at end of list + /* Null termination pointer at end of list */ NULL }; @@ -733,17 +733,17 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data /* Read ID States */ case SPIFLASH_STATE_RDID1: - priv->read_data = priv->manuf; //CONFIG_SIM_SPIFLASH_MANUFACTURER; + priv->read_data = priv->manuf; /* CONFIG_SIM_SPIFLASH_MANUFACTURER; */ priv->state = SPIFLASH_STATE_RDID2; break; case SPIFLASH_STATE_RDID2: - priv->read_data = priv->type; //CONFIG_SIM_SPIFLASH_MEMORY_TYPE; + priv->read_data = priv->type; /* CONFIG_SIM_SPIFLASH_MEMORY_TYPE; */ priv->state = SPIFLASH_STATE_RDID3; break; case SPIFLASH_STATE_RDID3: - priv->read_data = priv->capacity; //CONFIG_SPIFLASH_CAPACITY; + priv->read_data = priv->capacity; /* CONFIG_SPIFLASH_CAPACITY; */ priv->state = SPIFLASH_STATE_IDLE; break; From ac2a5e079ca2691f7c41c82e68de342b9d944f03 Mon Sep 17 00:00:00 2001 From: Vytautas Lukenskas Date: Tue, 19 Jul 2016 09:28:15 -0600 Subject: [PATCH 079/152] Add change missing in Make.defs for last LPC43xx change --- arch/arm/src/lpc43xx/Make.defs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/src/lpc43xx/Make.defs b/arch/arm/src/lpc43xx/Make.defs index 6e5d7ef3a78..79ddaa4a022 100644 --- a/arch/arm/src/lpc43xx/Make.defs +++ b/arch/arm/src/lpc43xx/Make.defs @@ -126,6 +126,10 @@ ifeq ($(CONFIG_LPC43_ETHERNET),y) CHIP_CSRCS += lpc43_ethernet.c endif +ifeq ($(CONFIG_LPC43_EMC),y) +CHIP_CSRCS += lpc43_emc.c +endif + ifeq ($(CONFIG_LPC43_SPI),y) CHIP_CSRCS += lpc43_spi.c else From 8bf4684de80403593f9a3986522771cc74e08952 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 09:53:52 -0600 Subject: [PATCH 080/152] Update some comments --- drivers/serial/pty.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 74f278145ad..dcfae95cc84 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -471,10 +471,18 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) sched_unlock(); } else +#else + /* If we wanted to return full blocks of data, then file_read() + * may need to be called repeatedly. That is because the pipe + * read() method will return early if the fifo becomes empty + * after any data has been read. + */ + +# error Missing logic #endif { - /* Read one byte from the source the byte. This call will block - * if the source pipe is empty. + /* Read one byte from the source the byte. This call will + * block if the source pipe is empty. */ nread = file_read(&dev->pd_src, &ch, 1); From 9bd09d43c72b6c8c185d9af69b29515f0ee3b944 Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Tue, 19 Jul 2016 10:37:00 -0600 Subject: [PATCH 081/152] Add file was not included in the original commit --- arch/sim/src/up_qspiflash.c | 608 ++++++++++++++++++++++++++++++++++++ 1 file changed, 608 insertions(+) create mode 100644 arch/sim/src/up_qspiflash.c diff --git a/arch/sim/src/up_qspiflash.c b/arch/sim/src/up_qspiflash.c new file mode 100644 index 00000000000..5d3c7630096 --- /dev/null +++ b/arch/sim/src/up_qspiflash.c @@ -0,0 +1,608 @@ +/************************************************************************************ + * arch/sim/src/up_qspiflash.c + * + * Copyright (C) 2014,2016 Ken Pettit. All rights reserved. + * Author: Ken Pettit + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "up_internal.h" + +#if defined(CONFIG_SIM_QSPIFLASH) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ + +/* Define the FLASH SIZE in bytes */ + +#ifdef CONFIG_SIM_QSPIFLASH_1M +# define CONFIG_QSPIFLASH_SIZE (128 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x11 + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE 2048 +#endif + +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_8M +# define CONFIG_QSPIFLASH_SIZE (1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x14 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_32M +# define CONFIG_QSPIFLASH_SIZE (4 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x16 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_64M +# define CONFIG_QSPIFLASH_SIZE (8 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x17 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_128M +# define CONFIG_QSPIFLASH_SIZE (16 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x18 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_MANUFACTURER +# define CONFIG_SIM_QSPIFLASH_MANUFACTURER 0x20 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_MEMORY_TYPE +# define CONFIG_SIM_QSPIFLASH_MEMORY_TYPE 0xba +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE 65536 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE 4096 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK (~(CONFIG_SIM_QSPIFLASH_SECTORSIZE-1)) +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK +# define CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK (~(CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE-1)) +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_PAGESIZE +# define CONFIG_SIM_QSPIFLASH_PAGESIZE 256 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_PAGESIZE_MASK +# define CONFIG_SIM_QSPIFLASH_PAGESIZE_MASK (CONFIG_SIM_QSPIFLASH_PAGESIZE-1) +#endif + +/* Define FLASH States */ + +#define QSPIFLASH_STATE_IDLE 0 +#define QSPIFLASH_STATE_RDID1 1 +#define QSPIFLASH_STATE_RDID2 2 +#define QSPIFLASH_STATE_RDID3 3 +#define QSPIFLASH_STATE_WREN 4 +#define QSPIFLASH_STATE_RDSR 5 +#define QSPIFLASH_STATE_SE1 6 +#define QSPIFLASH_STATE_SE2 7 +#define QSPIFLASH_STATE_SE3 8 +#define QSPIFLASH_STATE_PP1 9 +#define QSPIFLASH_STATE_PP2 10 +#define QSPIFLASH_STATE_PP3 11 +#define QSPIFLASH_STATE_PP4 12 +#define QSPIFLASH_STATE_READ1 13 +#define QSPIFLASH_STATE_READ2 14 +#define QSPIFLASH_STATE_READ3 15 +#define QSPIFLASH_STATE_READ4 16 +#define QSPIFLASH_STATE_FREAD_WAIT 17 + +/* Instructions */ +/* Command Value N Description Addr Dummy Data */ +#define QSPIFLASH_WREN 0x06 /* 1 Write Enable 0 0 0 */ +#define QSPIFLASH_WRDI 0x04 /* 1 Write Disable 0 0 0 */ +#define QSPIFLASH_RDID 0x9f /* 1 Read Identification 0 0 1-3 */ +#define QSPIFLASH_RDSR 0x05 /* 1 Read Status Register 0 0 >=1 */ +#define QSPIFLASH_WRSR 0x01 /* 1 Write Status Register 0 0 1 */ +#define QSPIFLASH_READ 0x03 /* 1 Read Data Bytes 3 0 >=1 */ +#define QSPIFLASH_FAST_READ 0x0b /* 1 Higher speed read 3 1 >=1 */ +#define QSPIFLASH_PP 0x02 /* 1 Page Program 3 0 1-256 */ +#define QSPIFLASH_SE 0xd8 /* 1 Sector Erase 3 0 0 */ +#define QSPIFLASH_BE 0xc7 /* 1 Bulk Erase 0 0 0 */ +#define QSPIFLASH_DP 0xb9 /* 2 Deep power down 0 0 0 */ +#define QSPIFLASH_RES 0xab /* 2 Read Electronic Signature 0 3 >=1 */ +#define QSPIFLASH_SSE 0x20 /* 3 Sub-Sector Erase 0 0 0 */ + +#define QSPIFLASH_ID 0x9f /* JEDEC ID */ +#define QSPIFLASH_READ_QUAD 0xeb + +#define QSPIFLASH_DUMMY 0xa5 + +#define QSPIFLASH_WREN_SET 0x02 + +/************************************************************************************ + * Private Types + ************************************************************************************/ + +struct sim_qspiflashdev_s +{ + struct qspi_dev_s spidev; /* Externally visible part of the SPI interface */ + uint32_t selected; /* SPIn base address */ + int wren; + int state; + uint16_t read_data; + uint8_t last_cmd; + unsigned long address; + unsigned char data[CONFIG_QSPIFLASH_SIZE]; +}; + +/************************************************************************************ + * Private Function Prototypes + ************************************************************************************/ + +/* QSPI methods */ + +static int qspiflash_lock(FAR struct qspi_dev_s *dev, bool lock); +static uint32_t qspiflash_setfrequency(FAR struct qspi_dev_s *dev, uint32_t frequency); +static void qspiflash_setmode(FAR struct qspi_dev_s *dev, enum qspi_mode_e mode); +static void qspiflash_setbits(FAR struct qspi_dev_s *dev, int nbits); +static int qspiflash_command(FAR struct qspi_dev_s *dev, FAR struct qspi_cmdinfo_s *cmd); +static int qspiflash_memory(FAR struct qspi_dev_s *dev, FAR struct qspi_meminfo_s *mem); +static FAR void * qspiflash_alloc(FAR struct qspi_dev_s *dev, size_t buflen); +static void qspiflash_free(FAR struct qspi_dev_s *dev, FAR void *buffer); + +static void qspiflash_writeword(FAR struct sim_qspiflashdev_s *priv, uint16_t data, + FAR struct qspi_cmdinfo_s *cmdinfo); + +/************************************************************************************ + * Private Data + ************************************************************************************/ + +static const struct qspi_ops_s g_qspiops = +{ + .lock = qspiflash_lock, + .setfrequency = qspiflash_setfrequency, + .setmode = qspiflash_setmode, + .setbits = qspiflash_setbits, + .command = qspiflash_command, + .memory = qspiflash_memory, + .alloc = qspiflash_alloc, + .free = qspiflash_free +}; + +struct sim_qspiflashdev_s g_qspidev = +{ + .spidev = { &g_qspiops }, +}; + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: qspiflash_lock + * + * Description: + * On SPI buses where there are multiple devices, it will be necessary to + * lock SPI to have exclusive access to the buses for a sequence of + * transfers. The bus should be locked before the chip is selected. After + * locking the SPI bus, the caller should then also call the setfrequency, + * setbits, and setmode methods to make sure that the SPI is properly + * configured for the device. If the SPI buss is being shared, then it + * may have been left in an incompatible state. + * + * Input Parameters: + * dev - Device-specific state data + * lock - true: Lock spi bus, false: unlock SPI bus + * + * Returned Value: + * None + * + ************************************************************************************/ + +static int qspiflash_lock(FAR struct qspi_dev_s *dev, bool lock) +{ + //FAR struct sim_qspiflashdev_s *priv = (FAR struct sim_qspiflashdev_s *)dev; + //priv->state = QSPIFLASH_STATE_IDLE; + + return OK; +} + +/************************************************************************************ + * Name: qspiflash_memory + * + * Description: + * Perform QSPI Memory transaction operations + * + * Returned Value: + * Always returns zero + * + ************************************************************************************/ + +int qspiflash_memory(FAR struct qspi_dev_s *dev, FAR struct qspi_meminfo_s *mem) +{ + FAR struct sim_qspiflashdev_s *priv = (FAR struct sim_qspiflashdev_s *)dev; + + switch (mem->cmd) + { + case QSPIFLASH_READ_QUAD: + priv->wren = 0; + memcpy(mem->buffer, &priv->data[mem->addr], mem->buflen); + priv->address += mem->addr + mem->buflen; + priv->state = QSPIFLASH_STATE_IDLE; + break; + + case QSPIFLASH_PP: + if (priv->wren) + { + memcpy(&priv->data[mem->addr], mem->buffer, mem->buflen); + } + break; + } + + return 0; +} + +/************************************************************************************ + * Name: qspiflash_setfrequency + * + * Description: + * Set the SPI frequency. + * + * Input Parameters: + * dev - Device-specific state data + * frequency - The SPI frequency requested + * + * Returned Value: + * Returns the actual frequency selected + * + ************************************************************************************/ + +static uint32_t qspiflash_setfrequency(FAR struct qspi_dev_s *dev, uint32_t frequency) +{ + return frequency; +} + +/************************************************************************************ + * Name: qspiflash_setmode + * + * Description: + * Set the SPI mode. see enum spi_mode_e for mode definitions + * + * Input Parameters: + * dev - Device-specific state data + * mode - The SPI mode requested + * + * Returned Value: + * Returns the actual frequency selected + * + ************************************************************************************/ + +static void qspiflash_setmode(FAR struct qspi_dev_s *dev, enum qspi_mode_e mode) +{ +} + +/************************************************************************************ + * Name: qspiflash_setbits + * + * Description: + * Set the number of bits per word. + * + * Input Parameters: + * dev - Device-specific state data + * nbits - The number of bits requested + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_setbits(FAR struct qspi_dev_s *dev, int nbits) +{ +} + +/************************************************************************************ + * Name: qspiflash_alloc + * + * Description: + * Allocate a buffer and associate it with the QSPI device + * + * Input Parameters: + * dev - Device-specific state data + * buflen - Length of buffer to allocate + * + * Returned Value: + * None + * + ************************************************************************************/ + +static FAR void *qspiflash_alloc(FAR struct qspi_dev_s *dev, size_t buflen) +{ + return kmm_malloc(buflen); +} + +/************************************************************************************ + * Name: qspiflash_free + * + * Description: + * Allocate a buffer and associate it with the QSPI device + * + * Input Parameters: + * dev - Device-specific state data + * buflen - Length of buffer to allocate + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_free(FAR struct qspi_dev_s *dev, FAR void *buffer) +{ + kmm_free(buffer); +} + +/************************************************************************************ + * Name: qspiflash_sectorerase + * + * Description: + * Erase one sector + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_sectorerase(FAR struct sim_qspiflashdev_s *priv) +{ + uint32_t address; + uint32_t len; + + /* Ensure the WREN bit is set before any erase operation */ + + if (priv->wren) + { + address = priv->address; + if (priv->last_cmd == QSPIFLASH_SE) + { + address &= CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK; + len = CONFIG_SIM_QSPIFLASH_SECTORSIZE; + } + else if (priv->last_cmd == QSPIFLASH_SSE) + { + address &= CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK; + len = CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE; + } + + /* Now perform the erase */ + + memset(&priv->data[address], 0xFF, len); + } +} + +/************************************************************************************ + * Name: qspiflash_writeword + * + * Description: + * Write a word (byte in our case) to the FLASH state machine. + * + * Input Parameters: + * dev - Device-specific state data + * data - the data to send to the simulated FLASH + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_writeword(FAR struct sim_qspiflashdev_s *priv, uint16_t data, + FAR struct qspi_cmdinfo_s *cmdinfo) +{ + switch (priv->state) + { + case QSPIFLASH_STATE_IDLE: + priv->last_cmd = data; + priv->read_data = 0xff; + switch (data) + { + case QSPIFLASH_WREN: + priv->wren = 1; + break; + + case QSPIFLASH_WRDI: + priv->wren = 0; + break; + + /* Sector / Subsector erase */ + + case QSPIFLASH_SE: + case QSPIFLASH_SSE: + priv->address = cmdinfo->addr; + + /* Now perform the sector or sub-sector erase. Really this should + * be done during the deselect, but this is just a simulation . + */ + + qspiflash_sectorerase(priv); + break; + + /* Bulk Erase */ + + case QSPIFLASH_BE: + priv->state = QSPIFLASH_STATE_IDLE; + if (priv->wren) + { + memset(priv->data, 0xff, CONFIG_QSPIFLASH_SIZE); + } + break; + + default: + break; + } + break; + + default: + priv->state = QSPIFLASH_STATE_IDLE; + priv->read_data = 0xFF; + break; + } +} + +/************************************************************************************ + * Name: qspiflash_command + * + * Description: + * Perform QSPI Command operations + * + * Returned Value: + * Always returns zero + * + ************************************************************************************/ + +static int qspiflash_command(FAR struct qspi_dev_s *dev, FAR struct qspi_cmdinfo_s *cmdinfo) +{ + uint8_t *pBuf; + FAR struct sim_qspiflashdev_s *priv = (FAR struct sim_qspiflashdev_s *)dev; + + DEBUGASSERT(cmdinfo->cmd < 256); + + /* Does data accompany the command? */ + + if (QSPICMD_ISDATA(cmdinfo->flags)) + { + DEBUGASSERT(cmdinfo->buffer != NULL && cmdinfo->buflen > 0); + pBuf = (uint8_t *) cmdinfo->buffer; + + /* Read or write operation? */ + + if (QSPICMD_ISWRITE(cmdinfo->flags)) + { + /* Write data operation */ + + qspiflash_writeword(priv, cmdinfo->cmd, cmdinfo); + } + else + { + /* Read data operation */ + + switch (cmdinfo->cmd) + { + case QSPIFLASH_ID: + pBuf[0] = CONFIG_SIM_QSPIFLASH_MANUFACTURER; + pBuf[1] = CONFIG_SIM_QSPIFLASH_MEMORY_TYPE; + pBuf[2] = CONFIG_QSPIFLASH_CAPACITY; + break; + + case QSPIFLASH_RDSR: + if (priv->wren == 1) + pBuf[0] = QSPIFLASH_WREN_SET; + else + pBuf[0] = 0; + break; + + } + + } + } + else + { + /* Write data operation */ + + qspiflash_writeword(priv, cmdinfo->cmd, cmdinfo); + } + return 0; +} + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: up_qspiflashinitialize + * + * Description: + * Initialize the selected SPI port + * + * Input Parameter: + * Port number (for hardware that has multiple SPI interfaces) + * + * Returned Value: + * Valid SPI device structure reference on success; a NULL on failure + * + ************************************************************************************/ + +FAR struct qspi_dev_s *up_qspiflashinitialize() +{ + FAR struct sim_qspiflashdev_s *priv = NULL; + + irqstate_t flags = enter_critical_section(); + + priv = &g_qspidev; + priv->selected = 0; + priv->wren = 0; + priv->address = 0; + priv->state = QSPIFLASH_STATE_IDLE; + priv->read_data = 0xFF; + priv->last_cmd = 0xFF; + memset(&priv->data[0], 0xFF, sizeof(priv->data)); + + leave_critical_section(flags); + return (FAR struct qspi_dev_s *)priv; +} + +#endif /* CONFIG_SIM_QSPIFLASH */ From b926334a19491f48ec087410ca1daac6b7d2fb5c Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Tue, 19 Jul 2016 10:39:43 -0600 Subject: [PATCH 082/152] Add file was not included in the original commit --- arch/sim/src/up_qspiflash.c | 607 ++++++++++++++++++++++++++++++++++++ 1 file changed, 607 insertions(+) create mode 100644 arch/sim/src/up_qspiflash.c diff --git a/arch/sim/src/up_qspiflash.c b/arch/sim/src/up_qspiflash.c new file mode 100644 index 00000000000..f2cafe608bb --- /dev/null +++ b/arch/sim/src/up_qspiflash.c @@ -0,0 +1,607 @@ +/************************************************************************************ + * arch/sim/src/up_qspiflash.c + * + * Copyright (C) 2014, 2016 Ken Pettit. All rights reserved. + * Author: Ken Pettit + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "up_internal.h" + +#if defined(CONFIG_SIM_QSPIFLASH) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ + +/* Define the FLASH SIZE in bytes */ + +#ifdef CONFIG_SIM_QSPIFLASH_1M +# define CONFIG_QSPIFLASH_SIZE (128 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x11 + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE 2048 +#endif + +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_8M +# define CONFIG_QSPIFLASH_SIZE (1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x14 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_32M +# define CONFIG_QSPIFLASH_SIZE (4 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x16 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_64M +# define CONFIG_QSPIFLASH_SIZE (8 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x17 +#endif + +#ifdef CONFIG_SIM_QSPIFLASH_128M +# define CONFIG_QSPIFLASH_SIZE (16 * 1024 * 1024) +# define CONFIG_QSPIFLASH_CAPACITY 0x18 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_MANUFACTURER +# define CONFIG_SIM_QSPIFLASH_MANUFACTURER 0x20 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_MEMORY_TYPE +# define CONFIG_SIM_QSPIFLASH_MEMORY_TYPE 0xba +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE 65536 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE +# define CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE 4096 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK +# define CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK (~(CONFIG_SIM_QSPIFLASH_SECTORSIZE-1)) +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK +# define CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK (~(CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE-1)) +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_PAGESIZE +# define CONFIG_SIM_QSPIFLASH_PAGESIZE 256 +#endif + +#ifndef CONFIG_SIM_QSPIFLASH_PAGESIZE_MASK +# define CONFIG_SIM_QSPIFLASH_PAGESIZE_MASK (CONFIG_SIM_QSPIFLASH_PAGESIZE-1) +#endif + +/* Define FLASH States */ + +#define QSPIFLASH_STATE_IDLE 0 +#define QSPIFLASH_STATE_RDID1 1 +#define QSPIFLASH_STATE_RDID2 2 +#define QSPIFLASH_STATE_RDID3 3 +#define QSPIFLASH_STATE_WREN 4 +#define QSPIFLASH_STATE_RDSR 5 +#define QSPIFLASH_STATE_SE1 6 +#define QSPIFLASH_STATE_SE2 7 +#define QSPIFLASH_STATE_SE3 8 +#define QSPIFLASH_STATE_PP1 9 +#define QSPIFLASH_STATE_PP2 10 +#define QSPIFLASH_STATE_PP3 11 +#define QSPIFLASH_STATE_PP4 12 +#define QSPIFLASH_STATE_READ1 13 +#define QSPIFLASH_STATE_READ2 14 +#define QSPIFLASH_STATE_READ3 15 +#define QSPIFLASH_STATE_READ4 16 +#define QSPIFLASH_STATE_FREAD_WAIT 17 + +/* Instructions */ +/* Command Value N Description Addr Dummy Data */ +#define QSPIFLASH_WREN 0x06 /* 1 Write Enable 0 0 0 */ +#define QSPIFLASH_WRDI 0x04 /* 1 Write Disable 0 0 0 */ +#define QSPIFLASH_RDID 0x9f /* 1 Read Identification 0 0 1-3 */ +#define QSPIFLASH_RDSR 0x05 /* 1 Read Status Register 0 0 >=1 */ +#define QSPIFLASH_WRSR 0x01 /* 1 Write Status Register 0 0 1 */ +#define QSPIFLASH_READ 0x03 /* 1 Read Data Bytes 3 0 >=1 */ +#define QSPIFLASH_FAST_READ 0x0b /* 1 Higher speed read 3 1 >=1 */ +#define QSPIFLASH_PP 0x02 /* 1 Page Program 3 0 1-256 */ +#define QSPIFLASH_SE 0xd8 /* 1 Sector Erase 3 0 0 */ +#define QSPIFLASH_BE 0xc7 /* 1 Bulk Erase 0 0 0 */ +#define QSPIFLASH_DP 0xb9 /* 2 Deep power down 0 0 0 */ +#define QSPIFLASH_RES 0xab /* 2 Read Electronic Signature 0 3 >=1 */ +#define QSPIFLASH_SSE 0x20 /* 3 Sub-Sector Erase 0 0 0 */ + +#define QSPIFLASH_ID 0x9f /* JEDEC ID */ +#define QSPIFLASH_READ_QUAD 0xeb + +#define QSPIFLASH_DUMMY 0xa5 + +#define QSPIFLASH_WREN_SET 0x02 + +/************************************************************************************ + * Private Types + ************************************************************************************/ + +struct sim_qspiflashdev_s +{ + struct qspi_dev_s spidev; /* Externally visible part of the SPI interface */ + uint32_t selected; /* SPIn base address */ + int wren; + int state; + uint16_t read_data; + uint8_t last_cmd; + unsigned long address; + unsigned char data[CONFIG_QSPIFLASH_SIZE]; +}; + +/************************************************************************************ + * Private Function Prototypes + ************************************************************************************/ + +/* QSPI methods */ + +static int qspiflash_lock(FAR struct qspi_dev_s *dev, bool lock); +static uint32_t qspiflash_setfrequency(FAR struct qspi_dev_s *dev, + uint32_t frequency); +static void qspiflash_setmode(FAR struct qspi_dev_s *dev, + enum qspi_mode_e mode); +static void qspiflash_setbits(FAR struct qspi_dev_s *dev, int nbits); +static int qspiflash_command(FAR struct qspi_dev_s *dev, + FAR struct qspi_cmdinfo_s *cmd); +static int qspiflash_memory(FAR struct qspi_dev_s *dev, + FAR struct qspi_meminfo_s *mem); +static FAR void * qspiflash_alloc(FAR struct qspi_dev_s *dev, size_t buflen); +static void qspiflash_free(FAR struct qspi_dev_s *dev, FAR void *buffer); + +static void qspiflash_writeword(FAR struct sim_qspiflashdev_s *priv, + uint16_t data, FAR struct qspi_cmdinfo_s *cmdinfo); + +/************************************************************************************ + * Private Data + ************************************************************************************/ + +static const struct qspi_ops_s g_qspiops = +{ + .lock = qspiflash_lock, + .setfrequency = qspiflash_setfrequency, + .setmode = qspiflash_setmode, + .setbits = qspiflash_setbits, + .command = qspiflash_command, + .memory = qspiflash_memory, + .alloc = qspiflash_alloc, + .free = qspiflash_free +}; + +struct sim_qspiflashdev_s g_qspidev = +{ + .spidev = { &g_qspiops }, +}; + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: qspiflash_lock + * + * Description: + * On SPI buses where there are multiple devices, it will be necessary to + * lock SPI to have exclusive access to the buses for a sequence of + * transfers. The bus should be locked before the chip is selected. After + * locking the SPI bus, the caller should then also call the setfrequency, + * setbits, and setmode methods to make sure that the SPI is properly + * configured for the device. If the SPI buss is being shared, then it + * may have been left in an incompatible state. + * + * Input Parameters: + * dev - Device-specific state data + * lock - true: Lock spi bus, false: unlock SPI bus + * + * Returned Value: + * None + * + ************************************************************************************/ + +static int qspiflash_lock(FAR struct qspi_dev_s *dev, bool lock) +{ + return OK; +} + +/************************************************************************************ + * Name: qspiflash_memory + * + * Description: + * Perform QSPI Memory transaction operations + * + * Returned Value: + * Always returns zero + * + ************************************************************************************/ + +int qspiflash_memory(FAR struct qspi_dev_s *dev, FAR struct qspi_meminfo_s *mem) +{ + FAR struct sim_qspiflashdev_s *priv = (FAR struct sim_qspiflashdev_s *)dev; + + switch (mem->cmd) + { + case QSPIFLASH_READ_QUAD: + priv->wren = 0; + memcpy(mem->buffer, &priv->data[mem->addr], mem->buflen); + priv->address += mem->addr + mem->buflen; + priv->state = QSPIFLASH_STATE_IDLE; + break; + + case QSPIFLASH_PP: + if (priv->wren) + { + memcpy(&priv->data[mem->addr], mem->buffer, mem->buflen); + } + break; + + default: + return -EINVAL; + } + + return 0; +} + +/************************************************************************************ + * Name: qspiflash_setfrequency + * + * Description: + * Set the SPI frequency. + * + * Input Parameters: + * dev - Device-specific state data + * frequency - The SPI frequency requested + * + * Returned Value: + * Returns the actual frequency selected + * + ************************************************************************************/ + +static uint32_t qspiflash_setfrequency(FAR struct qspi_dev_s *dev, uint32_t frequency) +{ + return frequency; +} + +/************************************************************************************ + * Name: qspiflash_setmode + * + * Description: + * Set the SPI mode. see enum spi_mode_e for mode definitions + * + * Input Parameters: + * dev - Device-specific state data + * mode - The SPI mode requested + * + * Returned Value: + * Returns the actual frequency selected + * + ************************************************************************************/ + +static void qspiflash_setmode(FAR struct qspi_dev_s *dev, enum qspi_mode_e mode) +{ +} + +/************************************************************************************ + * Name: qspiflash_setbits + * + * Description: + * Set the number of bits per word. + * + * Input Parameters: + * dev - Device-specific state data + * nbits - The number of bits requested + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_setbits(FAR struct qspi_dev_s *dev, int nbits) +{ +} + +/************************************************************************************ + * Name: qspiflash_alloc + * + * Description: + * Allocate a buffer and associate it with the QSPI device + * + * Input Parameters: + * dev - Device-specific state data + * buflen - Length of buffer to allocate + * + * Returned Value: + * None + * + ************************************************************************************/ + +static FAR void *qspiflash_alloc(FAR struct qspi_dev_s *dev, size_t buflen) +{ + return kmm_malloc(buflen); +} + +/************************************************************************************ + * Name: qspiflash_free + * + * Description: + * Allocate a buffer and associate it with the QSPI device + * + * Input Parameters: + * dev - Device-specific state data + * buflen - Length of buffer to allocate + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_free(FAR struct qspi_dev_s *dev, FAR void *buffer) +{ + kmm_free(buffer); +} + +/************************************************************************************ + * Name: qspiflash_sectorerase + * + * Description: + * Erase one sector + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_sectorerase(FAR struct sim_qspiflashdev_s *priv) +{ + uint32_t address; + uint32_t len; + + /* Ensure the WREN bit is set before any erase operation */ + + if (priv->wren) + { + address = priv->address; + if (priv->last_cmd == QSPIFLASH_SE) + { + address &= CONFIG_SIM_QSPIFLASH_SECTORSIZE_MASK; + len = CONFIG_SIM_QSPIFLASH_SECTORSIZE; + } + else if (priv->last_cmd == QSPIFLASH_SSE) + { + address &= CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE_MASK; + len = CONFIG_SIM_QSPIFLASH_SUBSECTORSIZE; + } + + /* Now perform the erase */ + + memset(&priv->data[address], 0xFF, len); + } +} + +/************************************************************************************ + * Name: qspiflash_writeword + * + * Description: + * Write a word (byte in our case) to the FLASH state machine. + * + * Input Parameters: + * dev - Device-specific state data + * data - the data to send to the simulated FLASH + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void qspiflash_writeword(FAR struct sim_qspiflashdev_s *priv, uint16_t data, + FAR struct qspi_cmdinfo_s *cmdinfo) +{ + switch (priv->state) + { + case QSPIFLASH_STATE_IDLE: + priv->last_cmd = data; + priv->read_data = 0xff; + switch (data) + { + case QSPIFLASH_WREN: + priv->wren = 1; + break; + + case QSPIFLASH_WRDI: + priv->wren = 0; + break; + + /* Sector / Subsector erase */ + + case QSPIFLASH_SE: + case QSPIFLASH_SSE: + priv->address = cmdinfo->addr; + + /* Now perform the sector or sub-sector erase. Really this should + * be done during the deselect, but this is just a simulation . + */ + + qspiflash_sectorerase(priv); + break; + + /* Bulk Erase */ + + case QSPIFLASH_BE: + priv->state = QSPIFLASH_STATE_IDLE; + if (priv->wren) + { + memset(priv->data, 0xff, CONFIG_QSPIFLASH_SIZE); + } + break; + + default: + break; + } + break; + + default: + priv->state = QSPIFLASH_STATE_IDLE; + priv->read_data = 0xFF; + break; + } +} + +/************************************************************************************ + * Name: qspiflash_command + * + * Description: + * Perform QSPI Command operations + * + * Returned Value: + * Always returns zero + * + ************************************************************************************/ + +static int qspiflash_command(FAR struct qspi_dev_s *dev, FAR struct qspi_cmdinfo_s *cmdinfo) +{ + uint8_t *pBuf; + FAR struct sim_qspiflashdev_s *priv = (FAR struct sim_qspiflashdev_s *)dev; + + DEBUGASSERT(cmdinfo->cmd < 256); + + /* Does data accompany the command? */ + + if (QSPICMD_ISDATA(cmdinfo->flags)) + { + DEBUGASSERT(cmdinfo->buffer != NULL && cmdinfo->buflen > 0); + pBuf = (uint8_t *) cmdinfo->buffer; + + /* Read or write operation? */ + + if (QSPICMD_ISWRITE(cmdinfo->flags)) + { + /* Write data operation */ + + qspiflash_writeword(priv, cmdinfo->cmd, cmdinfo); + } + else + { + /* Read data operation */ + + switch (cmdinfo->cmd) + { + case QSPIFLASH_ID: + pBuf[0] = CONFIG_SIM_QSPIFLASH_MANUFACTURER; + pBuf[1] = CONFIG_SIM_QSPIFLASH_MEMORY_TYPE; + pBuf[2] = CONFIG_QSPIFLASH_CAPACITY; + break; + + case QSPIFLASH_RDSR: + if (priv->wren == 1) + pBuf[0] = QSPIFLASH_WREN_SET; + else + pBuf[0] = 0; + break; + } + } + } + else + { + /* Write data operation */ + + qspiflash_writeword(priv, cmdinfo->cmd, cmdinfo); + } + + return 0; +} + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: up_qspiflashinitialize + * + * Description: + * Initialize the selected SPI port + * + * Input Parameter: + * Port number (for hardware that has multiple SPI interfaces) + * + * Returned Value: + * Valid SPI device structure reference on success; a NULL on failure + * + ************************************************************************************/ + +FAR struct qspi_dev_s *up_qspiflashinitialize() +{ + FAR struct sim_qspiflashdev_s *priv = NULL; + + irqstate_t flags = enter_critical_section(); + + priv = &g_qspidev; + priv->selected = 0; + priv->wren = 0; + priv->address = 0; + priv->state = QSPIFLASH_STATE_IDLE; + priv->read_data = 0xFF; + priv->last_cmd = 0xFF; + memset(&priv->data[0], 0xFF, sizeof(priv->data)); + + leave_critical_section(flags); + return (FAR struct qspi_dev_s *)priv; +} + +#endif /* CONFIG_SIM_QSPIFLASH */ From 56582e22634f3ffbfc56e0498c21ffc45f6f2ddb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 10:40:23 -0600 Subject: [PATCH 083/152] Update some comments --- drivers/serial/pty.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index dcfae95cc84..c8edacd9871 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -422,6 +422,12 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) * bytes were read from the pipe. If we have already read some * data, we use the FIONREAD ioctl to test if there are more bytes * in the pipe. + * + * REVISIT: An alternative design might be to (1) configure the + * source file as non-blocking, then (2) wait using poll() for the + * first byte to be received. (3) Subsequent bytes would + * use file_read() without polling and would (4) terminate when no + * data is returned. */ if (ntotal > 0) From d6bf67f9ff1e6df3a4e3c3f6046e70e243691420 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 13:34:18 -0600 Subject: [PATCH 084/152] Alloc different sizes for pipe and fifo buffers --- drivers/Kconfig | 1 + drivers/pipes/Kconfig | 20 ++++++++++++++--- drivers/pipes/fifo.c | 6 ++--- drivers/pipes/pipe.c | 2 +- drivers/pipes/pipe_common.c | 24 +++++++++++--------- drivers/pipes/pipe_common.h | 45 +++++++++++++++++++++++++++++-------- 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/drivers/Kconfig b/drivers/Kconfig index 22f17127687..ce90630be47 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -29,6 +29,7 @@ config DEV_RANDOM bool "Enable /dev/random" default y depends on ARCH_HAVE_RNG + ---help--- Enable support for /dev/urandom provided by a hardware TRNG. config DEV_URANDOM diff --git a/drivers/pipes/Kconfig b/drivers/pipes/Kconfig index 64a3fb720b3..760f9384dda 100644 --- a/drivers/pipes/Kconfig +++ b/drivers/pipes/Kconfig @@ -3,8 +3,22 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config DEV_PIPE_SIZE - int "Pipe Size" +config DEV_PIPE_MAXSIZE + int "Maximum pipe/FIFO size" default 1024 ---help--- - Sets the size of the pipe ringbuffer in bytes. + Maximum configurable size of a pipe or FIFO at runtime. + +config DEV_PIPE_SIZE + int "Default pipe size" + default 1024 + ---help--- + Sets the default size of the pipe ringbuffer in bytes. A value of + zero disables pipe support. + +config DEV_FIFO_SIZE + int "Default FIFO size" + default 1024 + ---help--- + Sets the default size of the FIFO ringbuffer in bytes. A value of + zero disables FIFO support. diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index b63f9a18561..ec6c22e708c 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -48,7 +48,7 @@ #include "pipe_common.h" -#if CONFIG_DEV_PIPE_SIZE > 0 +#if CONFIG_DEV_FIFO_SIZE > 0 /**************************************************************************** * Private Data @@ -110,7 +110,7 @@ int mkfifo(FAR const char *pathname, mode_t mode) /* Allocate and initialize a new device structure instance */ - dev = pipecommon_allocdev(); + dev = pipecommon_allocdev(CONFIG_DEV_FIFO_SIZE); if (!dev) { return -ENOMEM; @@ -125,4 +125,4 @@ int mkfifo(FAR const char *pathname, mode_t mode) return ret; } -#endif /* CONFIG_DEV_PIPE_SIZE > 0 */ +#endif /* CONFIG_DEV_FIFO_SIZE > 0 */ diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index 715639d21c1..e006c3aac62 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -222,7 +222,7 @@ int pipe(int fd[2]) { /* No.. Allocate and initialize a new device structure instance */ - dev = pipecommon_allocdev(); + dev = pipecommon_allocdev(CONFIG_DEV_PIPE_SIZE); if (!dev) { (void)sem_post(&g_pipesem); diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index 74d36ec170c..25c51e76d45 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -62,7 +62,7 @@ #include "pipe_common.h" -#if CONFIG_DEV_PIPE_SIZE > 0 +#ifdef CONFIG_PIPES /**************************************************************************** * Pre-processor Definitions @@ -153,10 +153,12 @@ static void pipecommon_pollnotify(FAR struct pipe_dev_s *dev, * Name: pipecommon_allocdev ****************************************************************************/ -FAR struct pipe_dev_s *pipecommon_allocdev(void) +FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize) { FAR struct pipe_dev_s *dev; + DEBUGASSERT(bufsize <= CONFIG_DEV_PIPE_MAXSIZE) + /* Allocate a private structure to manage the pipe */ dev = (FAR struct pipe_dev_s *)kmm_malloc(sizeof(struct pipe_dev_s)); @@ -168,6 +170,8 @@ FAR struct pipe_dev_s *pipecommon_allocdev(void) sem_init(&dev->d_bfsem, 0, 1); sem_init(&dev->d_rdsem, 0, 0); sem_init(&dev->d_wrsem, 0, 0); + + dev->d_bufsize = bufsize; } return dev; @@ -217,7 +221,7 @@ int pipecommon_open(FAR struct file *filep) if (dev->d_refs == 0 && dev->d_buffer == NULL) { - dev->d_buffer = (FAR uint8_t *)kmm_malloc(CONFIG_DEV_PIPE_SIZE); + dev->d_buffer = (FAR uint8_t *)kmm_malloc(dev->d_bufsize); if (!dev->d_buffer) { (void)sem_post(&dev->d_bfsem); @@ -471,7 +475,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len) while ((size_t)nread < len && dev->d_wrndx != dev->d_rdndx) { *buffer++ = dev->d_buffer[dev->d_rdndx]; - if (++dev->d_rdndx >= CONFIG_DEV_PIPE_SIZE) + if (++dev->d_rdndx >= dev->d_bufsize) { dev->d_rdndx = 0; } @@ -546,7 +550,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, /* Calculate the write index AFTER the next byte is written */ nxtwrndx = dev->d_wrndx + 1; - if (nxtwrndx >= CONFIG_DEV_PIPE_SIZE) + if (nxtwrndx >= dev->d_bufsize) { nxtwrndx = 0; } @@ -677,14 +681,14 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, } else { - nbytes = (CONFIG_DEV_PIPE_SIZE-1) + dev->d_wrndx - dev->d_rdndx; + nbytes = (dev->d_bufsize - 1) + dev->d_wrndx - dev->d_rdndx; } /* Notify the POLLOUT event if the pipe is not full, but only if * there is readers. */ eventset = 0; - if (nbytes < (CONFIG_DEV_PIPE_SIZE-1)) + if (nbytes < (dev->d_bufsize - 1)) { eventset |= POLLOUT; } @@ -789,7 +793,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (dev->d_wrndx < dev->d_rdndx) { - count = (CONFIG_DEV_PIPE_SIZE - dev->d_rdndx) + dev->d_wrndx; + count = (dev->d_bufsize - dev->d_rdndx) + dev->d_wrndx; } else { @@ -813,7 +817,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } else { - count = ((CONFIG_DEV_PIPE_SIZE - dev->d_wrndx) + dev->d_rdndx) - 1; + count = ((dev->d_bufsize - dev->d_wrndx) + dev->d_rdndx) - 1; } *(FAR int *)((uintptr_t)arg) = count; @@ -865,4 +869,4 @@ int pipecommon_unlink(FAR struct inode *inode) } #endif -#endif /* CONFIG_DEV_PIPE_SIZE > 0 */ +#endif /* CONFIG_PIPES */ diff --git a/drivers/pipes/pipe_common.h b/drivers/pipes/pipe_common.h index ae301795ecf..ae8c401ebc2 100644 --- a/drivers/pipes/pipe_common.h +++ b/drivers/pipes/pipe_common.h @@ -47,15 +47,42 @@ #include #include +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Pipe/FIFO support */ + +#ifndef CONFIG_PIPES +# undef CONFIG_DEV_PIPE_MAXSIZE +# undef CONFIG_DEV_PIPE_SIZE +# undef CONFIG_DEV_FIFO_SIZE +# define CONFIG_DEV_PIPE_MAXSIZE 0 +# define CONFIG_DEV_PIPE_SIZE 0 +# define CONFIG_DEV_FIFO_SIZE 0 +#endif + +/* Pipe/FIFO size */ + +#ifndef CONFIG_DEV_PIPE_MAXSIZE +# define CONFIG_DEV_PIPE_MAXSIZE 1024 +#endif + +#if CONFIG_DEV_PIPE_MAXSIZE <= 0 +# undef CONFIG_PIPES +# undef CONFIG_DEV_PIPE_SIZE +# undef CONFIG_DEV_FIFO_SIZE +# define CONFIG_DEV_PIPE_SIZE 0 +# define CONFIG_DEV_FIFO_SIZE 0 +#endif + #ifndef CONFIG_DEV_PIPE_SIZE # define CONFIG_DEV_PIPE_SIZE 1024 #endif -#if CONFIG_DEV_PIPE_SIZE > 0 - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ +#ifndef CONFIG_DEV_FIFO_SIZE +# define CONFIG_DEV_FIFO_SIZE 1024 +#endif /* Maximum number of threads than can be waiting for POLL events */ @@ -87,9 +114,9 @@ /* Make the buffer index as small as possible for the configured pipe size */ -#if CONFIG_DEV_PIPE_SIZE > 65535 +#if CONFIG_DEV_PIPE_MAXSIZE > 65535 typedef uint32_t pipe_ndx_t; /* 32-bit index */ -#elif CONFIG_DEV_PIPE_SIZE > 255 +#elif CONFIG_DEV_PIPE_MAXSIZE > 255 typedef uint16_t pipe_ndx_t; /* 16-bit index */ #else typedef uint8_t pipe_ndx_t; /* 8-bit index */ @@ -107,6 +134,7 @@ struct pipe_dev_s sem_t d_wrsem; /* Full buffer - Writer waits for data read */ pipe_ndx_t d_wrndx; /* Index in d_buffer to save next byte written */ pipe_ndx_t d_rdndx; /* Index in d_buffer to return the next byte read */ + pipe_ndx_t d_bufsize; /* allocated size of d_buffer in bytes */ uint8_t d_refs; /* References counts on pipe (limited to 255) */ uint8_t d_nwriters; /* Number of reference counts for write access */ uint8_t d_nreaders; /* Number of reference counts for read access */ @@ -138,7 +166,7 @@ extern "C" { struct file; /* Forward reference */ struct inode; /* Forward reference */ -FAR struct pipe_dev_s *pipecommon_allocdev(void); +FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize); void pipecommon_freedev(FAR struct pipe_dev_s *dev); int pipecommon_open(FAR struct file *filep); int pipecommon_close(FAR struct file *filep); @@ -158,5 +186,4 @@ int pipecommon_unlink(FAR struct inode *priv); } #endif -#endif /* CONFIG_DEV_PIPE_SIZE > 0 */ #endif /* __DRIVERS_PIPES_PIPE_COMMON_H */ From 9a44f3017b0a24a739bd4cad9f4542ad65702b9b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 13:40:54 -0600 Subject: [PATCH 085/152] Fix a few typos in the last commit --- drivers/pipes/pipe_common.c | 2 +- drivers/pipes/pipe_common.h | 3 ++- net/local/Kconfig | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index 25c51e76d45..3bb5fc405e0 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -157,7 +157,7 @@ FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize) { FAR struct pipe_dev_s *dev; - DEBUGASSERT(bufsize <= CONFIG_DEV_PIPE_MAXSIZE) + DEBUGASSERT(bufsize <= CONFIG_DEV_PIPE_MAXSIZE); /* Allocate a private structure to manage the pipe */ diff --git a/drivers/pipes/pipe_common.h b/drivers/pipes/pipe_common.h index ae8c401ebc2..0986a27af17 100644 --- a/drivers/pipes/pipe_common.h +++ b/drivers/pipes/pipe_common.h @@ -158,7 +158,8 @@ struct pipe_dev_s #ifdef __cplusplus # define EXTERN extern "C" -extern "C" { +extern "C" +{ #else # define EXTERN extern #endif diff --git a/net/local/Kconfig b/net/local/Kconfig index 144844a6375..3125ab34a51 100644 --- a/net/local/Kconfig +++ b/net/local/Kconfig @@ -9,6 +9,7 @@ menu "Unix Domain Socket Support" config NET_LOCAL bool "Unix domain (local) sockets" default n + select PIPES ---help--- Enable or disable Unix domain (aka Local) sockets. From 671d7fae3134cf2d48e9156cdb0ff87a4da98ced Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 13:51:05 -0600 Subject: [PATCH 086/152] Add mkfifo2() and pipe2() which are just like mkfifo() and pipe(), but allow control of the size of the underlying, in-memory circular buffer --- drivers/pipes/fifo.c | 75 +++++++++++++++++++++++++++++++++----------- drivers/pipes/pipe.c | 33 +++++++++++++++++-- include/sys/stat.h | 1 + include/unistd.h | 3 +- 4 files changed, 90 insertions(+), 22 deletions(-) diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index ec6c22e708c..68f3f3a9157 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -74,6 +74,62 @@ static const struct file_operations fifo_fops = * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: mkfifo2 + * + * Description: + * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike + * Linux, a NuttX FIFO is not a special file type but simply a device + * driver instance. 'mode' specifies the FIFO's permissions. + * + * Once the FIFO has been created by mkfifo(), any thread can open it for + * reading or writing, in the same way as an ordinary file. However, it + * must have been opened from both reading and writing before input or + * output can be performed. This FIFO implementation will block all + * attempts to open a FIFO read-only until at least one thread has opened + * the FIFO for writing. + * + * If all threads that write to the FIFO have closed, subsequent calls to + * read() on the FIFO will return 0 (end-of-file). + * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * + * Inputs: + * pathname - The full path to the FIFO instance to attach to or to create + * (if not already created). + * mode - Ignored for now + * bufsize - The size of the in-memory, circular buffer in bytes. + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize) +{ + FAR struct pipe_dev_s *dev; + int ret; + + /* Allocate and initialize a new device structure instance */ + + dev = pipecommon_allocdev(bufsize); + if (!dev) + { + return -ENOMEM; + } + + ret = register_driver(pathname, &fifo_fops, mode, (FAR void *)dev); + if (ret != 0) + { + pipecommon_freedev(dev); + } + + return ret; +} + /**************************************************************************** * Name: mkfifo * @@ -105,24 +161,7 @@ static const struct file_operations fifo_fops = int mkfifo(FAR const char *pathname, mode_t mode) { - FAR struct pipe_dev_s *dev; - int ret; - - /* Allocate and initialize a new device structure instance */ - - dev = pipecommon_allocdev(CONFIG_DEV_FIFO_SIZE); - if (!dev) - { - return -ENOMEM; - } - - ret = register_driver(pathname, &fifo_fops, mode, (FAR void *)dev); - if (ret != 0) - { - pipecommon_freedev(dev); - } - - return ret; + return mkfifo2(pathname, mode, CONFIG_DEV_FIFO_SIZE); } #endif /* CONFIG_DEV_FIFO_SIZE > 0 */ diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index e006c3aac62..394b0cc3105 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -167,16 +167,21 @@ static int pipe_close(FAR struct file *filep) ****************************************************************************/ /**************************************************************************** - * Name: pipe + * Name: pipe2 * * Description: * pipe() creates a pair of file descriptors, pointing to a pipe inode, * and places them in the array pointed to by 'fd'. fd[0] is for reading, * fd[1] is for writing. * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * * Inputs: * fd[2] - The user provided array in which to catch the pipe file * descriptors + * bufsize - The size of the in-memory, circular buffer in bytes. * * Return: * 0 is returned on success; otherwise, -1 is returned with errno set @@ -184,7 +189,7 @@ static int pipe_close(FAR struct file *filep) * ****************************************************************************/ -int pipe(int fd[2]) +int pipe2(int fd[2], size_t bufsize) { FAR struct pipe_dev_s *dev = NULL; char devname[16]; @@ -222,7 +227,7 @@ int pipe(int fd[2]) { /* No.. Allocate and initialize a new device structure instance */ - dev = pipecommon_allocdev(CONFIG_DEV_PIPE_SIZE); + dev = pipecommon_allocdev(bufsize); if (!dev) { (void)sem_post(&g_pipesem); @@ -289,4 +294,26 @@ errout: return ERROR; } +/**************************************************************************** + * Name: pipe2 + * + * Description: + * pipe() creates a pair of file descriptors, pointing to a pipe inode, + * and places them in the array pointed to by 'fd'. fd[0] is for reading, + * fd[1] is for writing. + * + * Inputs: + * fd[2] - The user provided array in which to catch the pipe file + * descriptors + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +int pipe(int fd[2]) +{ + return pipe2(fd, CONFIG_DEV_PIPE_SIZE); +} #endif /* CONFIG_DEV_PIPE_SIZE > 0 */ diff --git a/include/sys/stat.h b/include/sys/stat.h index 3f2658b5f18..ae450257d04 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -130,6 +130,7 @@ extern "C" #endif int mkdir(FAR const char *pathname, mode_t mode); +int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); /* NuttX only */ int mkfifo(FAR const char *pathname, mode_t mode); int stat(const char *path, FAR struct stat *buf); #if 0 /* Not yet supported */ diff --git a/include/unistd.h b/include/unistd.h index e482109f5c1..cb9eabfd5de 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/unistd.h * - * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013-2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -174,6 +174,7 @@ FAR void *sbrk(intptr_t incr); /* Special devices */ +int pipe2(int fd[2], size_t bufsize); /* NuttX only */ int pipe(int fd[2]); /* Working directory operations */ From b28fa8a609a1fc1452c85de5691bc207bf65e2ae Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 14:15:26 -0600 Subject: [PATCH 087/152] Move pipe() and mkpipe() to nuttx/libc. Change syscalls to pipe2() and mkfifo2() --- drivers/pipes/fifo.c | 34 -------------- drivers/pipes/pipe.c | 22 --------- include/sys/syscall.h | 4 +- libc/misc/Make.defs | 12 +++-- libc/misc/lib_mkfifo.c | 86 ++++++++++++++++++++++++++++++++++++ libc/unistd/Make.defs | 4 ++ libc/unistd/lib_pipe.c | 74 +++++++++++++++++++++++++++++++ syscall/syscall.csv | 4 +- syscall/syscall_lookup.h | 12 ++--- syscall/syscall_stublookup.c | 5 ++- 10 files changed, 185 insertions(+), 72 deletions(-) create mode 100644 libc/misc/lib_mkfifo.c create mode 100644 libc/unistd/lib_pipe.c diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index 68f3f3a9157..ade2d620418 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -130,38 +130,4 @@ int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize) return ret; } -/**************************************************************************** - * Name: mkfifo - * - * Description: - * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike - * Linux, a NuttX FIFO is not a special file type but simply a device - * driver instance. 'mode' specifies the FIFO's permissions. - * - * Once the FIFO has been created by mkfifo(), any thread can open it for - * reading or writing, in the same way as an ordinary file. However, it - * must have been opened from both reading and writing before input or - * output can be performed. This FIFO implementation will block all - * attempts to open a FIFO read-only until at least one thread has opened - * the FIFO for writing. - * - * If all threads that write to the FIFO have closed, subsequent calls to - * read() on the FIFO will return 0 (end-of-file). - * - * Inputs: - * pathname - The full path to the FIFO instance to attach to or to create - * (if not already created). - * mode - Ignored for now - * - * Return: - * 0 is returned on success; otherwise, -1 is returned with errno set - * appropriately. - * - ****************************************************************************/ - -int mkfifo(FAR const char *pathname, mode_t mode) -{ - return mkfifo2(pathname, mode, CONFIG_DEV_FIFO_SIZE); -} - #endif /* CONFIG_DEV_FIFO_SIZE > 0 */ diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index 394b0cc3105..ed22db3fc5e 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -294,26 +294,4 @@ errout: return ERROR; } -/**************************************************************************** - * Name: pipe2 - * - * Description: - * pipe() creates a pair of file descriptors, pointing to a pipe inode, - * and places them in the array pointed to by 'fd'. fd[0] is for reading, - * fd[1] is for writing. - * - * Inputs: - * fd[2] - The user provided array in which to catch the pipe file - * descriptors - * - * Return: - * 0 is returned on success; otherwise, -1 is returned with errno set - * appropriately. - * - ****************************************************************************/ - -int pipe(int fd[2]) -{ - return pipe2(fd, CONFIG_DEV_PIPE_SIZE); -} #endif /* CONFIG_DEV_PIPE_SIZE > 0 */ diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 389c11bf08f..9868c3477b9 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -292,11 +292,11 @@ # define SYS_dup2 (__SYS_filedesc+2) # define SYS_fcntl (__SYS_filedesc+3) # define SYS_lseek (__SYS_filedesc+4) -# define SYS_mkfifo (__SYS_filedesc+5) +# define SYS_mkfifo2 (__SYS_filedesc+5) # define SYS_mmap (__SYS_filedesc+6) # define SYS_open (__SYS_filedesc+7) # define SYS_opendir (__SYS_filedesc+8) -# define SYS_pipe (__SYS_filedesc+9) +# define SYS_pipe2 (__SYS_filedesc+9) # define SYS_readdir (__SYS_filedesc+10) # define SYS_rewinddir (__SYS_filedesc+11) # define SYS_seekdir (__SYS_filedesc+12) diff --git a/libc/misc/Make.defs b/libc/misc/Make.defs index e25b6a783ad..dbdb3495471 100644 --- a/libc/misc/Make.defs +++ b/libc/misc/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # libc/misc/Make.defs # -# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -57,7 +57,11 @@ ifeq ($(CONFIG_LIBC_IOCTL_VARIADIC),y) CSRCS += lib_ioctl.c endif -else +ifeq ($(CONFIG_PIPES),y) +CSRCS += lib_mkfifo.c +endif + +else # CONFIG_NFILE_DESCRIPTORS > 0 ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0) CSRCS += lib_sendfile.c @@ -70,8 +74,8 @@ ifeq ($(CONFIG_LIBC_IOCTL_VARIADIC),y) CSRCS += lib_ioctl.c endif -endif -endif +endif # CONFIG_NSOCKET_DESCRIPTORS > 0 +endif # CONFIG_NFILE_DESCRIPTORS > 0 # Add the miscellaneous C files to the build diff --git a/libc/misc/lib_mkfifo.c b/libc/misc/lib_mkfifo.c new file mode 100644 index 00000000000..727ac0f3611 --- /dev/null +++ b/libc/misc/lib_mkfifo.c @@ -0,0 +1,86 @@ +/**************************************************************************** + * libc/misc/lib_mkfifo.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#if CONFIG_DEV_FIFO_SIZE > 0 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mkfifo + * + * Description: + * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike + * Linux, a NuttX FIFO is not a special file type but simply a device + * driver instance. 'mode' specifies the FIFO's permissions. + * + * Once the FIFO has been created by mkfifo(), any thread can open it for + * reading or writing, in the same way as an ordinary file. However, it + * must have been opened from both reading and writing before input or + * output can be performed. This FIFO implementation will block all + * attempts to open a FIFO read-only until at least one thread has opened + * the FIFO for writing. + * + * If all threads that write to the FIFO have closed, subsequent calls to + * read() on the FIFO will return 0 (end-of-file). + * + * Inputs: + * pathname - The full path to the FIFO instance to attach to or to create + * (if not already created). + * mode - Ignored for now + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +int mkfifo(FAR const char *pathname, mode_t mode) +{ + return mkfifo2(pathname, mode, CONFIG_DEV_FIFO_SIZE); +} + +#endif /* CONFIG_DEV_FIFO_SIZE > 0 */ + diff --git a/libc/unistd/Make.defs b/libc/unistd/Make.defs index ddb463c3db7..2aa942dd3ff 100644 --- a/libc/unistd/Make.defs +++ b/libc/unistd/Make.defs @@ -46,6 +46,10 @@ endif ifeq ($(CONFIG_LIBC_EXECFUNCS),y) CSRCS += lib_execl.c endif + +ifeq ($(CONFIG_PIPES),y) +CSRCS += lib_pipe.c +endif endif ifneq ($(CONFIG_DISABLE_SIGNALS),y) diff --git a/libc/unistd/lib_pipe.c b/libc/unistd/lib_pipe.c new file mode 100644 index 00000000000..e36a31ad414 --- /dev/null +++ b/libc/unistd/lib_pipe.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * libc/unistd/lib_pipe.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#if CONFIG_DEV_PIPE_SIZE > 0 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pipe + * + * Description: + * pipe() creates a pair of file descriptors, pointing to a pipe inode, + * and places them in the array pointed to by 'fd'. fd[0] is for reading, + * fd[1] is for writing. + * + * Inputs: + * fd[2] - The user provided array in which to catch the pipe file + * descriptors + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +int pipe(int fd[2]) +{ + return pipe2(fd, CONFIG_DEV_PIPE_SIZE); +} + +#endif /* CONFIG_DEV_PIPE_SIZE > 0 */ + diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 77b7ce750c4..d0213139252 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -34,7 +34,7 @@ "listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int" "lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int" "mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t" -"mkfifo","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t" +"mkfifo2","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t","size_t" "mmap","sys/mman.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR void*","FAR void*","size_t","int","int","int","off_t" "mount","sys/mount.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_READABLE)","int","const char*","const char*","const char*","unsigned long","const void*" "mq_close","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t" @@ -52,7 +52,7 @@ "open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..." "opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*" "pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int" -"pipe","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*" +"pipe2","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*","size_t" "poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int" "prctl","sys/prctl.h", "CONFIG_TASK_NAME_SIZE > 0","int","int","..." "pread","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t","off_t" diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index 4cd1a3d6765..881f8063a13 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -183,10 +183,10 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(pread, 4, STUB_pread) SYSCALL_LOOKUP(pwrite, 4, STUB_pwrite) # ifdef CONFIG_FS_AIO - SYSCALL_LOOKUP(aio_read, 1, SYS_aio_read) - SYSCALL_LOOKUP(aio_write, 1, SYS_aio_write) - SYSCALL_LOOKUP(aio_fsync, 2, SYS_aio_fsync) - SYSCALL_LOOKUP(aio_cancel, 2, SYS_aio_cancel) + SYSCALL_LOOKUP(aio_read, 1, STUB_aio_read) + SYSCALL_LOOKUP(aio_write, 1, STUB_aio_write) + SYSCALL_LOOKUP(aio_fsync, 2, STUB_aio_fsync) + SYSCALL_LOOKUP(aio_cancel, 2, STUB_aio_cancel) # endif # ifndef CONFIG_DISABLE_POLL SYSCALL_LOOKUP(poll, 3, STUB_poll) @@ -208,11 +208,11 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(dup2, 2, STUB_dup2) SYSCALL_LOOKUP(fcntl, 6, STUB_fcntl) SYSCALL_LOOKUP(lseek, 3, STUB_lseek) - SYSCALL_LOOKUP(mkfifo, 2, STUB_mkfifo) + SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) SYSCALL_LOOKUP(mmap, 6, STUB_mmap) SYSCALL_LOOKUP(open, 6, STUB_open) SYSCALL_LOOKUP(opendir, 1, STUB_opendir) - SYSCALL_LOOKUP(pipe, 1, STUB_pipe) + SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) SYSCALL_LOOKUP(readdir, 1, STUB_readdir) SYSCALL_LOOKUP(rewinddir, 1, STUB_rewinddir) SYSCALL_LOOKUP(seekdir, 2, STUB_seekdir) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 96862aa4062..6ba5a0fb678 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -214,7 +214,8 @@ uintptr_t STUB_fcntl(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm6); uintptr_t STUB_lseek(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); -uintptr_t STUB_mkfifo(int nbr, uintptr_t parm1, uintptr_t parm2); +uintptr_t STUB_mkfifo2(int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3); uintptr_t STUB_mmap(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); @@ -222,7 +223,7 @@ uintptr_t STUB_open(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); uintptr_t STUB_opendir(int nbr, uintptr_t parm1); -uintptr_t STUB_pipe(int nbr, uintptr_t parm1); +uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uinptr_t parm2); uintptr_t STUB_readdir(int nbr, uintptr_t parm1); uintptr_t STUB_rewinddir(int nbr, uintptr_t parm1); uintptr_t STUB_seekdir(int nbr, uintptr_t parm1, uintptr_t parm2); From 318f34fb7d1d454fd5ecdd349dac97b0709a2f04 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 14:26:41 -0600 Subject: [PATCH 088/152] Psuedo-terminal pipe size is now configurable --- drivers/serial/Kconfig | 19 +++++++++++++++++-- drivers/serial/pty.c | 10 +++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ad1a503ac75..2d53923eb3d 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2012,18 +2012,19 @@ config SCI1_2STOP endmenu # SCI1 Configuration -config PSEUDOTERM +menuconfig PSEUDOTERM bool "Pseudo-Terminal (PTY) suppport" default n select ARCH_HAVE_SERIAL_TERMIOS ---help--- Enable support support for master and slave pseudo-terminal devices. +if PSEUDOTERM + choice prompt "PTY model" default PSEUDOTERM_BSD if DISABLE_PSEUDOFS_OPERATIONS default PSEUDOTERM_SUSV1 if !DISABLE_PSEUDOFS_OPERATIONS - depends on PSEUDOTERM config PSEUDOTERM_BSD bool "BSD style" @@ -2047,3 +2048,17 @@ config PSEUDOTERM_SUSV1 Where N is the minor number endchoice # PTY model + +config PSEUDOTERM_RXBUFSIZE + int "Pseudo-Terminal Rx buffer size" + default 256 + ---help--- + Master-to-slave pipe buffer size. Default: 256 + +config PSEUDOTERM_TXBUFSIZE + int "Pseudo-Terminal Tx buffer size" + default 256 + ---help--- + Slave-to-master buffer size. Default: 256 + +endif # PSEUDOTERM diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index c8edacd9871..c3c090abcee 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -918,15 +918,19 @@ int pty_register(int minor) devpair->pp_master.pd_master = true; devpair->pp_slave.pd_devpair = devpair; - /* Create two pipes */ + /* Create two pipes: + * + * pipe_a: Master source, slave sink (TX, slave-to-master) + * pipe_b: Master sink, slave source (RX, master-to-slave) + */ - ret = pipe(pipe_a); + ret = pipe2(pipe_a, CONFIG_PSEUDOTERM_TXBUFSIZE); if (ret < 0) { goto errout_with_devpair; } - ret = pipe(pipe_b); + ret = pipe2(pipe_b, CONFIG_PSEUDOTERM_RXBUFSIZE); if (ret < 0) { goto errout_with_pipea; From 2cacc6204a623abfab8e525d0136a5d7e2d51229 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Jul 2016 14:26:40 -0600 Subject: [PATCH 089/152] Kconfig: If Pseudo-terminals are enabled, then pipes must be selected as well --- drivers/serial/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 2d53923eb3d..5b61b2db904 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2015,6 +2015,7 @@ endmenu # SCI1 Configuration menuconfig PSEUDOTERM bool "Pseudo-Terminal (PTY) suppport" default n + select PIPES select ARCH_HAVE_SERIAL_TERMIOS ---help--- Enable support support for master and slave pseudo-terminal devices. From e07bd757bae68ff5788926173c8f99e27f893707 Mon Sep 17 00:00:00 2001 From: Sagitta Li Date: Wed, 20 Jul 2016 08:51:03 -0600 Subject: [PATCH 090/152] STM32 F107: TIM8 not supported in F105/F107 --- arch/arm/src/stm32/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 932e74c81b5..3b7a1cf8cc8 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1206,7 +1206,6 @@ config STM32_CONNECTIVITYLINE select STM32_HAVE_TIM5 select STM32_HAVE_TIM6 select STM32_HAVE_TIM7 - select STM32_HAVE_TIM8 select STM32_HAVE_ADC2 select STM32_HAVE_CAN1 select STM32_HAVE_CAN2 From aa8a52aacd88b4a053141db607f3f1329c86f9ab Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 10:45:21 -0600 Subject: [PATCH 091/152] Update TODO list and NSH documentation --- Documentation/NuttShell.html | 4 ++-- TODO | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html index 90e0764a791..7af455d577e 100644 --- a/Documentation/NuttShell.html +++ b/Documentation/NuttShell.html @@ -8,7 +8,7 @@

NuttShell (NSH)

-

Last Updated: February 8, 2016

+

Last Updated: July 20, 2016

@@ -3277,7 +3277,7 @@ nsh> mkfifo - CONFIG_NFILE_DESCRIPTORS > 0 + CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_PIPES CONFIG_NSH_DISABLE_MKFIFO diff --git a/TODO b/TODO index bbc8f7657ac..9d3309122dc 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated July 3, 2016) +NuttX TODO List (Last updated July 20, 2016) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -447,6 +447,7 @@ o Kernel/Protected Build mkfatfs mkfatfs mkrd ramdisk_register() ping icmp_ping() + mount foreach_mountpoint() The busybox mkfatfs does not involve any OS calls; it does its job by simply opening the block driver (using open/xopen) @@ -1399,6 +1400,15 @@ o File system / Generic drivers (fs/, drivers/) socket structures. There really should be one array that is a union of file and socket descriptors. Then socket and file descriptors could lie in the same range. + + Another example of how the current implementation limits + functionality: I recently started an implement of the FILEMAX + (using pctl() instead sysctl()). My objective was to be able + to control the number of available file descriptors on a task- + by-task basis. The complexity due to the partitioning of + desciptor space in a range for file descriptors and a range + for socket descriptors made this feature nearly impossible to + implement. Status: Open Priority: Low From e73e82a923dfacf0804bf4a5bcdc744ee7ec188c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 11:57:18 -0600 Subject: [PATCH 092/152] Move prototypes of mkfifo2() from sys/stat.h and pipe2() from unistd.h. They are non-standard and should not be in such a public place. They are not in include/nuttx/fs/fs.h (which isn't a great place either). --- drivers/pipes/pipe.c | 4 ++- include/nuttx/fs/fs.h | 66 ++++++++++++++++++++++++++++++++++++++++++ include/sys/stat.h | 1 - include/unistd.h | 1 - libc/misc/lib_mkfifo.c | 6 ++-- libc/unistd/lib_pipe.c | 6 ++-- syscall/syscall.csv | 4 +-- 7 files changed, 79 insertions(+), 9 deletions(-) diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index ed22db3fc5e..a6fbba0ce42 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -44,13 +44,15 @@ #include #include -#include + #include #include #include #include #include +#include + #include "pipe_common.h" #if CONFIG_DEV_PIPE_SIZE > 0 diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index ef99ff6f51b..bf8d1b60ecd 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -60,6 +60,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Stream flags for the fs_flags field of in struct file_struct */ #define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */ @@ -1160,6 +1161,71 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len); +/**************************************************************************** + * Name: pipe2 + * + * Description: + * pipe() creates a pair of file descriptors, pointing to a pipe inode, + * and places them in the array pointed to by 'fd'. fd[0] is for reading, + * fd[1] is for writing. + * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * + * Inputs: + * fd[2] - The user provided array in which to catch the pipe file + * descriptors + * bufsize - The size of the in-memory, circular buffer in bytes. + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 +int pipe2(int fd[2], size_t bufsize); +#endif + +/**************************************************************************** + * Name: mkfifo2 + * + * Description: + * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike + * Linux, a NuttX FIFO is not a special file type but simply a device + * driver instance. 'mode' specifies the FIFO's permissions. + * + * Once the FIFO has been created by mkfifo(), any thread can open it for + * reading or writing, in the same way as an ordinary file. However, it + * must have been opened from both reading and writing before input or + * output can be performed. This FIFO implementation will block all + * attempts to open a FIFO read-only until at least one thread has opened + * the FIFO for writing. + * + * If all threads that write to the FIFO have closed, subsequent calls to + * read() on the FIFO will return 0 (end-of-file). + * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * + * Inputs: + * pathname - The full path to the FIFO instance to attach to or to create + * (if not already created). + * mode - Ignored for now + * bufsize - The size of the in-memory, circular buffer in bytes. + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 +int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/include/sys/stat.h b/include/sys/stat.h index ae450257d04..3f2658b5f18 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -130,7 +130,6 @@ extern "C" #endif int mkdir(FAR const char *pathname, mode_t mode); -int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); /* NuttX only */ int mkfifo(FAR const char *pathname, mode_t mode); int stat(const char *path, FAR struct stat *buf); #if 0 /* Not yet supported */ diff --git a/include/unistd.h b/include/unistd.h index cb9eabfd5de..909df0b3383 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -174,7 +174,6 @@ FAR void *sbrk(intptr_t incr); /* Special devices */ -int pipe2(int fd[2], size_t bufsize); /* NuttX only */ int pipe(int fd[2]); /* Working directory operations */ diff --git a/libc/misc/lib_mkfifo.c b/libc/misc/lib_mkfifo.c index 727ac0f3611..8357b6428f2 100644 --- a/libc/misc/lib_mkfifo.c +++ b/libc/misc/lib_mkfifo.c @@ -42,7 +42,9 @@ #include #include -#if CONFIG_DEV_FIFO_SIZE > 0 +#include + +#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 /**************************************************************************** * Public Functions @@ -82,5 +84,5 @@ int mkfifo(FAR const char *pathname, mode_t mode) return mkfifo2(pathname, mode, CONFIG_DEV_FIFO_SIZE); } -#endif /* CONFIG_DEV_FIFO_SIZE > 0 */ +#endif /* CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0 */ diff --git a/libc/unistd/lib_pipe.c b/libc/unistd/lib_pipe.c index e36a31ad414..fbee9803197 100644 --- a/libc/unistd/lib_pipe.c +++ b/libc/unistd/lib_pipe.c @@ -41,7 +41,9 @@ #include -#if CONFIG_DEV_PIPE_SIZE > 0 +#include + +#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 /**************************************************************************** * Public Functions @@ -70,5 +72,5 @@ int pipe(int fd[2]) return pipe2(fd, CONFIG_DEV_PIPE_SIZE); } -#endif /* CONFIG_DEV_PIPE_SIZE > 0 */ +#endif /* CONFIG_PIPES && CONFIG_DEV_PIPE_SIZE > 0 */ diff --git a/syscall/syscall.csv b/syscall/syscall.csv index d0213139252..42a9ba5f60c 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -34,7 +34,7 @@ "listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int" "lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int" "mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t" -"mkfifo2","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t","size_t" +"mkfifo2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char*","mode_t","size_t" "mmap","sys/mman.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR void*","FAR void*","size_t","int","int","int","off_t" "mount","sys/mount.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_READABLE)","int","const char*","const char*","const char*","unsigned long","const void*" "mq_close","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t" @@ -52,7 +52,7 @@ "open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..." "opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*" "pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int" -"pipe2","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*","size_t" +"pipe2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|int*","size_t" "poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int" "prctl","sys/prctl.h", "CONFIG_TASK_NAME_SIZE > 0","int","int","..." "pread","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t","off_t" From 69dca44ca600dd81ee491a48a8a79f4212c5c75c Mon Sep 17 00:00:00 2001 From: jmacintyre Date: Wed, 20 Jul 2016 13:28:34 -0500 Subject: [PATCH 093/152] changed default nsh serial to UART0 (openSDA usb) --- configs/freedom-k64f/nsh/defconfig | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index c87eee1940d..7a44fc835f5 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -193,10 +193,10 @@ CONFIG_ARCH_FAMILY_K64=y # # CONFIG_KINETIS_TRACE is not set # CONFIG_KINETIS_FLEXBUS is not set -# CONFIG_KINETIS_UART0 is not set +CONFIG_KINETIS_UART0=y # CONFIG_KINETIS_UART1 is not set # CONFIG_KINETIS_UART2 is not set -CONFIG_KINETIS_UART3=y +# CONFIG_KINETIS_UART3 is not set # CONFIG_KINETIS_UART4 is not set # CONFIG_KINETIS_UART5 is not set # CONFIG_KINETIS_ENET is not set @@ -529,10 +529,10 @@ CONFIG_SERIAL=y CONFIG_SERIAL_CONSOLE=y # CONFIG_16550_UART is not set # CONFIG_UART_SERIALDRIVER is not set -# CONFIG_UART0_SERIALDRIVER is not set +CONFIG_UART0_SERIALDRIVER=y # CONFIG_UART1_SERIALDRIVER is not set # CONFIG_UART2_SERIALDRIVER is not set -CONFIG_UART3_SERIALDRIVER=y +# CONFIG_UART3_SERIALDRIVER is not set # CONFIG_UART4_SERIALDRIVER is not set # CONFIG_UART5_SERIALDRIVER is not set # CONFIG_UART6_SERIALDRIVER is not set @@ -556,22 +556,22 @@ CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set # CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set -CONFIG_UART3_SERIAL_CONSOLE=y +CONFIG_UART0_SERIAL_CONSOLE=y # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set # -# UART3 Configuration +# UART0 Configuration # -CONFIG_UART3_RXBUFSIZE=256 -CONFIG_UART3_TXBUFSIZE=256 -CONFIG_UART3_BAUD=115200 -CONFIG_UART3_BITS=8 -CONFIG_UART3_PARITY=0 -CONFIG_UART3_2STOP=0 -# CONFIG_UART3_IFLOWCONTROL is not set -# CONFIG_UART3_OFLOWCONTROL is not set -# CONFIG_UART3_DMA is not set +CONFIG_UART0_RXBUFSIZE=256 +CONFIG_UART0_TXBUFSIZE=256 +CONFIG_UART0_BAUD=115200 +CONFIG_UART0_BITS=8 +CONFIG_UART0_PARITY=0 +CONFIG_UART0_2STOP=0 +# CONFIG_UART0_IFLOWCONTROL is not set +# CONFIG_UART0_OFLOWCONTROL is not set +# CONFIG_UART0_DMA is not set # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set From 4b4dbc79a2d0a316ed530dbfd305ef1356523fb4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 13:15:37 -0600 Subject: [PATCH 094/152] Move driver related prototypes out of include/nuttx/fs/fs.h and into new include/drivers/drivers.h --- arch/arm/src/common/up_initialize.c | 2 +- arch/arm/src/sama5/sam_trng.c | 2 + arch/arm/src/samv7/sam_trng.c | 2 + arch/arm/src/stm32/stm32_rng.c | 2 + arch/arm/src/stm32l4/stm32l4_rng.c | 2 + arch/avr/src/common/up_initialize.c | 2 +- arch/hc/src/common/up_initialize.c | 2 +- arch/mips/src/common/up_initialize.c | 2 +- arch/rgmp/src/nuttx.c | 2 +- arch/sh/src/common/up_initialize.c | 2 +- arch/sim/src/up_initialize.c | 2 +- arch/x86/src/common/up_initialize.c | 2 +- arch/z16/src/common/up_initialize.c | 2 +- arch/z80/src/common/up_initialize.c | 2 +- configs/sama5d4-ek/src/sam_at25.c | 4 +- configs/same70-xplained/src/sam_bringup.c | 2 +- configs/samv71-xult/src/sam_bringup.c | 2 +- configs/stm32l476vg-disco/src/stm32_appinit.c | 2 +- crypto/cryptodev.c | 1 + drivers/Kconfig | 4 +- drivers/bch/bchdev_driver.c | 3 +- drivers/bch/bchdev_register.c | 21 +- drivers/bch/bchdev_unregister.c | 19 +- drivers/bch/bchlib_cache.c | 16 +- drivers/bch/bchlib_read.c | 4 +- drivers/bch/bchlib_setup.c | 18 +- drivers/bch/bchlib_teardown.c | 18 +- drivers/bch/bchlib_write.c | 21 +- drivers/dev_null.c | 4 +- drivers/dev_urandom.c | 1 + drivers/dev_zero.c | 4 +- drivers/pipes/fifo.c | 5 +- drivers/pipes/pipe.c | 1 + drivers/serial/pty.c | 1 + fs/driver/driver.h | 2 - fs/driver/fs_blockproxy.c | 4 +- include/nuttx/drivers/drivers.h | 288 ++++++++++++++++++ include/nuttx/fs/fs.h | 237 +------------- libc/misc/lib_mkfifo.c | 2 +- libc/unistd/lib_pipe.c | 2 +- syscall/syscall.csv | 4 +- 41 files changed, 355 insertions(+), 363 deletions(-) create mode 100644 include/nuttx/drivers/drivers.h diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index b1f88c0d1b7..a97cd40a92e 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/src/sama5/sam_trng.c b/arch/arm/src/sama5/sam_trng.c index 9f9cec8e55b..4c0f5ab1bcc 100644 --- a/arch/arm/src/sama5/sam_trng.c +++ b/arch/arm/src/sama5/sam_trng.c @@ -52,6 +52,8 @@ #include #include +#include +#include #include "up_arch.h" #include "up_internal.h" diff --git a/arch/arm/src/samv7/sam_trng.c b/arch/arm/src/samv7/sam_trng.c index 1634cc46f35..098cf0ae68b 100644 --- a/arch/arm/src/samv7/sam_trng.c +++ b/arch/arm/src/samv7/sam_trng.c @@ -53,6 +53,8 @@ #include #include +#include +#include #include "up_arch.h" #include "up_internal.h" diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c index 9d727e4fef5..8dde6a6c35c 100644 --- a/arch/arm/src/stm32/stm32_rng.c +++ b/arch/arm/src/stm32/stm32_rng.c @@ -46,6 +46,8 @@ #include #include +#include +#include #include "up_arch.h" #include "chip/stm32_rng.h" diff --git a/arch/arm/src/stm32l4/stm32l4_rng.c b/arch/arm/src/stm32l4/stm32l4_rng.c index e048edda167..a544847061b 100644 --- a/arch/arm/src/stm32l4/stm32l4_rng.c +++ b/arch/arm/src/stm32l4/stm32l4_rng.c @@ -47,6 +47,8 @@ #include #include +#include +#include #include "up_arch.h" #include "chip/stm32l4_rng.h" diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 14c273c414b..55a9b167530 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index 8ae73d30eb4..1d75e24baf9 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 93652972e0c..609ce62f826 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index 3e694d503f8..07faf590fd7 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index 80e93410cbd..2cd40a07188 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 41f21a36941..ada5bb33ba0 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 1261a5eb369..a089d5a7746 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 349e68b0d78..cb423278b32 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index a42635cbe8f..b74368979d3 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/configs/sama5d4-ek/src/sam_at25.c b/configs/sama5d4-ek/src/sam_at25.c index 4df4e631e57..d2d8824b9a9 100644 --- a/configs/sama5d4-ek/src/sam_at25.c +++ b/configs/sama5d4-ek/src/sam_at25.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sama5d4-ek/src/sam_at25.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,10 +46,10 @@ #include #include -#include #include #include #include +#include #include "sam_spi.h" #include "sama5d4-ek.h" diff --git a/configs/same70-xplained/src/sam_bringup.c b/configs/same70-xplained/src/sam_bringup.c index 3ac5d205858..d136a7e7107 100644 --- a/configs/same70-xplained/src/sam_bringup.c +++ b/configs/same70-xplained/src/sam_bringup.c @@ -50,7 +50,7 @@ # include #endif -#include +#include #include #include #include diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 845e00df9a2..0ff1c5b3279 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -50,7 +50,7 @@ # include #endif -#include +#include #include #include #include diff --git a/configs/stm32l476vg-disco/src/stm32_appinit.c b/configs/stm32l476vg-disco/src/stm32_appinit.c index e242acc67e8..2d6a11d6dcb 100644 --- a/configs/stm32l476vg-disco/src/stm32_appinit.c +++ b/configs/stm32l476vg-disco/src/stm32_appinit.c @@ -58,7 +58,7 @@ #include #include -#include +#include #include #include #include diff --git a/crypto/cryptodev.c b/crypto/cryptodev.c index 9710acf0281..97099227421 100644 --- a/crypto/cryptodev.c +++ b/crypto/cryptodev.c @@ -46,6 +46,7 @@ #include #include +#include #include #include diff --git a/drivers/Kconfig b/drivers/Kconfig index ce90630be47..5418cd82892 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -406,8 +406,8 @@ menuconfig BCH ---help--- Contains logic that may be used to convert a block driver into a character driver. This is the complementary conversion as that - performed by loop.c. See include/nuttx/fs/fs.h for registration - information. + performed by loop.c. See include/nuttx/drivers/drivers.h for + registration information. if BCH source drivers/bch/Kconfig diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 198cd334b38..556709e8b83 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchdev_driver.c * - * Copyright (C) 2008-2009, 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2014-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -57,6 +57,7 @@ #include #include +#include #include "bch.h" diff --git a/drivers/bch/bchdev_register.c b/drivers/bch/bchdev_register.c index 2efb0e53381..b199dd4a4c2 100644 --- a/drivers/bch/bchdev_register.c +++ b/drivers/bch/bchdev_register.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchdev_register.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,24 +44,11 @@ #include #include +#include +#include + #include "bch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/bch/bchdev_unregister.c b/drivers/bch/bchdev_unregister.c index cf7d681de82..1b4e1e138e4 100644 --- a/drivers/bch/bchdev_unregister.c +++ b/drivers/bch/bchdev_unregister.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchdev_unregister.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -51,25 +51,10 @@ #include #include +#include #include "bch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/bch/bchlib_cache.c b/drivers/bch/bchlib_cache.c index aa54fb3213e..82090981cd1 100644 --- a/drivers/bch/bchlib_cache.c +++ b/drivers/bch/bchlib_cache.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_cache.c * - * Copyright (C) 2008-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,26 +45,12 @@ #include #include -#include - #include "bch.h" #if defined(CONFIG_BCH_ENCRYPTION) # include #endif -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c index 45804d3560b..5fe680acb49 100644 --- a/drivers/bch/bchlib_read.c +++ b/drivers/bch/bchlib_read.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_read.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,6 @@ #include #include -#include - #include "bch.h" /**************************************************************************** diff --git a/drivers/bch/bchlib_setup.c b/drivers/bch/bchlib_setup.c index 803c5058ce8..be20613fdcf 100644 --- a/drivers/bch/bchlib_setup.c +++ b/drivers/bch/bchlib_setup.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_setup.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -54,22 +54,6 @@ #include "bch.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/bch/bchlib_teardown.c b/drivers/bch/bchlib_teardown.c index d97d3b8ffcd..aa20b4b4ad3 100644 --- a/drivers/bch/bchlib_teardown.c +++ b/drivers/bch/bchlib_teardown.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_teardown.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,22 +49,6 @@ #include "bch.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 712839ef06e..f5fa2996572 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_write.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -51,22 +51,6 @@ #include "bch.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -80,7 +64,8 @@ * ****************************************************************************/ -ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len) +ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, + size_t len) { FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; size_t nsectors; diff --git a/drivers/dev_null.c b/drivers/dev_null.c index ff535df3444..2f2b6f2a755 100644 --- a/drivers/dev_null.c +++ b/drivers/dev_null.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/dev_null.c * - * Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,9 @@ #include #include #include + #include +#include /**************************************************************************** * Private Function Prototypes diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index 0e0cf970313..06f4038cc7e 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -52,6 +52,7 @@ #include #include +#include #if defined(CONFIG_DEV_URANDOM) && !defined(CONFIG_DEV_URANDOM_ARCH) diff --git a/drivers/dev_zero.c b/drivers/dev_zero.c index 5a0ce669252..93b14c31693 100644 --- a/drivers/dev_zero.c +++ b/drivers/dev_zero.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/dev_zero.c * - * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,9 @@ #include #include #include + #include +#include /**************************************************************************** * Private Function Prototypes diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index ade2d620418..43afa5556f9 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -41,11 +41,12 @@ #include #include - #include -#include #include +#include +#include + #include "pipe_common.h" #if CONFIG_DEV_FIFO_SIZE > 0 diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index a6fbba0ce42..b54f051cf56 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -52,6 +52,7 @@ #include #include +#include #include "pipe_common.h" diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index c3c090abcee..29b752fac90 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -54,6 +54,7 @@ #include #include +#include #include #include "pty.h" diff --git a/fs/driver/driver.h b/fs/driver/driver.h index 9b7f59bdb79..7cd14c56fa3 100644 --- a/fs/driver/driver.h +++ b/fs/driver/driver.h @@ -63,7 +63,6 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -/* fs_findblockdriver.c *****************************************************/ /**************************************************************************** * Name: find_blockdriver * @@ -92,7 +91,6 @@ int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode **ppinode); #endif -/* fs/drivers/fs_blockproxy.c ***********************************************/ /**************************************************************************** * Name: block_proxy * diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c index 045110ac404..8da06d3e0b3 100644 --- a/fs/driver/fs_blockproxy.c +++ b/fs/driver/fs_blockproxy.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/driver/fs_blockproxy.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ #include #include -#include +#include #if !defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && \ !defined(CONFIG_DISABLE_MOUNTPOINT) diff --git a/include/nuttx/drivers/drivers.h b/include/nuttx/drivers/drivers.h new file mode 100644 index 00000000000..612434d15b7 --- /dev/null +++ b/include/nuttx/drivers/drivers.h @@ -0,0 +1,288 @@ +/**************************************************************************** + * include/nuttx/fs/drivers.h + * + * Copyright (C) 2007-2009, 2011-2013, 2015-2016 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_FS_DRIVERS_H +#define __INCLUDE_NUTTX_FS_DRIVERS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: devnull_register + * + * Description: + * Register /dev/null + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void devnull_register(void); + +/**************************************************************************** + * Name: devrandom_register + * + * Description: + * Initialize the RNG hardware and register the /dev/random driver. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_RANDOM +void devrandom_register(void); +#endif + +/**************************************************************************** + * Name: devurandom_register + * + * Description: + * Register /dev/urandom + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_URANDOM +void devurandom_register(void); +#endif + +/**************************************************************************** + * Name: devcrypto_register + * + * Description: + * Register /dev/crypto + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void devcrypto_register(void); + +/**************************************************************************** + * Name: devzero_register + * + * Description: + * Register /dev/zero + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void devzero_register(void); + +/**************************************************************************** + * Name: bchdev_register + * + * Description: + * Setup so that it exports the block driver referenced by 'blkdev' as a + * character device 'chardev' + * + ****************************************************************************/ + +int bchdev_register(FAR const char *blkdev, FAR const char *chardev, + bool readonly); + +/**************************************************************************** + * Name: bchdev_unregister + * + * Description: + * Unregister character driver access to a block device that was created + * by a previous call to bchdev_register(). + * + ****************************************************************************/ + +int bchdev_unregister(FAR const char *chardev); + +/* Low level, direct access. NOTE: low-level access and character driver access + * are incompatible. One and only one access method should be implemented. + */ + +/**************************************************************************** + * Name: bchlib_setup + * + * Description: + * Setup so that the block driver referenced by 'blkdev' can be accessed + * similar to a character device. + * + ****************************************************************************/ + +int bchlib_setup(FAR const char *blkdev, bool readonly, FAR void **handle); + +/**************************************************************************** + * Name: bchlib_teardown + * + * Description: + * Setup so that the block driver referenced by 'blkdev' can be accessed + * similar to a character device. + * + ****************************************************************************/ + +int bchlib_teardown(FAR void *handle); + +/**************************************************************************** + * Name: bchlib_read + * + * Description: + * Read from the block device set-up by bchlib_setup as if it were a + * character device. + * + ****************************************************************************/ + +ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, + size_t len); + +/**************************************************************************** + * Name: bchlib_write + * + * Description: + * Write to the block device set-up by bchlib_setup as if it were a + * character device. + * + ****************************************************************************/ + +ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, + size_t len); + +/**************************************************************************** + * Name: pipe2 + * + * Description: + * pipe() creates a pair of file descriptors, pointing to a pipe inode, + * and places them in the array pointed to by 'fd'. fd[0] is for reading, + * fd[1] is for writing. + * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * + * Inputs: + * fd[2] - The user provided array in which to catch the pipe file + * descriptors + * bufsize - The size of the in-memory, circular buffer in bytes. + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 +int pipe2(int fd[2], size_t bufsize); +#endif + +/**************************************************************************** + * Name: mkfifo2 + * + * Description: + * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike + * Linux, a NuttX FIFO is not a special file type but simply a device + * driver instance. 'mode' specifies the FIFO's permissions. + * + * Once the FIFO has been created by mkfifo(), any thread can open it for + * reading or writing, in the same way as an ordinary file. However, it + * must have been opened from both reading and writing before input or + * output can be performed. This FIFO implementation will block all + * attempts to open a FIFO read-only until at least one thread has opened + * the FIFO for writing. + * + * If all threads that write to the FIFO have closed, subsequent calls to + * read() on the FIFO will return 0 (end-of-file). + * + * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since + * the NuttX FIFOs are based in in-memory, circular buffers, the ability + * to control the size of those buffers is critical for system tuning. + * + * Inputs: + * pathname - The full path to the FIFO instance to attach to or to create + * (if not already created). + * mode - Ignored for now + * bufsize - The size of the in-memory, circular buffer in bytes. + * + * Return: + * 0 is returned on success; otherwise, -1 is returned with errno set + * appropriately. + * + ****************************************************************************/ + +#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 +int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __INCLUDE_NUTTX_FS_DRIVERS_H */ diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index bf8d1b60ecd..238a6b8ef96 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fs/fs.h * - * Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -498,8 +498,9 @@ int foreach_mountpoint(foreach_mountpoint_t handler, FAR void *arg); * ****************************************************************************/ -int register_driver(FAR const char *path, FAR const struct file_operations *fops, - mode_t mode, FAR void *priv); +int register_driver(FAR const char *path, + FAR const struct file_operations *fops, mode_t mode, + FAR void *priv); /**************************************************************************** * Name: register_blockdriver @@ -526,8 +527,8 @@ int register_driver(FAR const char *path, FAR const struct file_operations *fops #ifndef CONFIG_DISABLE_MOUNTPOINT int register_blockdriver(FAR const char *path, - FAR const struct block_operations *bops, mode_t mode, - FAR void *priv); + FAR const struct block_operations *bops, + mode_t mode, FAR void *priv); #endif /**************************************************************************** @@ -538,7 +539,7 @@ int register_blockdriver(FAR const char *path, * ****************************************************************************/ -int unregister_driver(const char *path); +int unregister_driver(FAR const char *path); /**************************************************************************** * Name: unregister_blockdriver @@ -548,7 +549,7 @@ int unregister_driver(const char *path); * ****************************************************************************/ -int unregister_blockdriver(const char *path); +int unregister_blockdriver(FAR const char *path); /**************************************************************************** * Name: inode_checkflags @@ -1004,228 +1005,6 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup); #endif -/**************************************************************************** - * Name: devnull_register - * - * Description: - * Register /dev/null - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void devnull_register(void); - -/**************************************************************************** - * Name: devrandom_register - * - * Description: - * Initialize the RNG hardware and register the /dev/random driver. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_DEV_RANDOM -void devrandom_register(void); -#endif - -/**************************************************************************** - * Name: devurandom_register - * - * Description: - * Register /dev/urandom - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_DEV_URANDOM -void devurandom_register(void); -#endif - -/**************************************************************************** - * Name: devcrypto_register - * - * Description: - * Register /dev/crypto - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void devcrypto_register(void); - -/**************************************************************************** - * Name: devzero_register - * - * Description: - * Register /dev/zero - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void devzero_register(void); - -/**************************************************************************** - * Name: bchdev_register - * - * Description: - * Setup so that it exports the block driver referenced by 'blkdev' as a - * character device 'chardev' - * - ****************************************************************************/ - -int bchdev_register(FAR const char *blkdev, FAR const char *chardev, - bool readonly); - -/**************************************************************************** - * Name: bchdev_unregister - * - * Description: - * Unregister character driver access to a block device that was created - * by a previous call to bchdev_register(). - * - ****************************************************************************/ - -int bchdev_unregister(FAR const char *chardev); - -/* Low level, direct access. NOTE: low-level access and character driver access - * are incompatible. One and only one access method should be implemented. - */ - -/**************************************************************************** - * Name: bchlib_setup - * - * Description: - * Setup so that the block driver referenced by 'blkdev' can be accessed - * similar to a character device. - * - ****************************************************************************/ - -int bchlib_setup(FAR const char *blkdev, bool readonly, FAR void **handle); - -/**************************************************************************** - * Name: bchlib_teardown - * - * Description: - * Setup so that the block driver referenced by 'blkdev' can be accessed - * similar to a character device. - * - ****************************************************************************/ - -int bchlib_teardown(FAR void *handle); - -/**************************************************************************** - * Name: bchlib_read - * - * Description: - * Read from the block device set-up by bchlib_setup as if it were a - * character device. - * - ****************************************************************************/ - -ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, - size_t len); - -/**************************************************************************** - * Name: bchlib_write - * - * Description: - * Write to the block device set-up by bchlib_setup as if it were a - * character device. - * - ****************************************************************************/ - -ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, - size_t len); - -/**************************************************************************** - * Name: pipe2 - * - * Description: - * pipe() creates a pair of file descriptors, pointing to a pipe inode, - * and places them in the array pointed to by 'fd'. fd[0] is for reading, - * fd[1] is for writing. - * - * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since - * the NuttX FIFOs are based in in-memory, circular buffers, the ability - * to control the size of those buffers is critical for system tuning. - * - * Inputs: - * fd[2] - The user provided array in which to catch the pipe file - * descriptors - * bufsize - The size of the in-memory, circular buffer in bytes. - * - * Return: - * 0 is returned on success; otherwise, -1 is returned with errno set - * appropriately. - * - ****************************************************************************/ - -#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 -int pipe2(int fd[2], size_t bufsize); -#endif - -/**************************************************************************** - * Name: mkfifo2 - * - * Description: - * mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike - * Linux, a NuttX FIFO is not a special file type but simply a device - * driver instance. 'mode' specifies the FIFO's permissions. - * - * Once the FIFO has been created by mkfifo(), any thread can open it for - * reading or writing, in the same way as an ordinary file. However, it - * must have been opened from both reading and writing before input or - * output can be performed. This FIFO implementation will block all - * attempts to open a FIFO read-only until at least one thread has opened - * the FIFO for writing. - * - * If all threads that write to the FIFO have closed, subsequent calls to - * read() on the FIFO will return 0 (end-of-file). - * - * NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since - * the NuttX FIFOs are based in in-memory, circular buffers, the ability - * to control the size of those buffers is critical for system tuning. - * - * Inputs: - * pathname - The full path to the FIFO instance to attach to or to create - * (if not already created). - * mode - Ignored for now - * bufsize - The size of the in-memory, circular buffer in bytes. - * - * Return: - * 0 is returned on success; otherwise, -1 is returned with errno set - * appropriately. - * - ****************************************************************************/ - -#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 -int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); -#endif - #undef EXTERN #if defined(__cplusplus) } diff --git a/libc/misc/lib_mkfifo.c b/libc/misc/lib_mkfifo.c index 8357b6428f2..deb919aad1c 100644 --- a/libc/misc/lib_mkfifo.c +++ b/libc/misc/lib_mkfifo.c @@ -42,7 +42,7 @@ #include #include -#include +#include #if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 diff --git a/libc/unistd/lib_pipe.c b/libc/unistd/lib_pipe.c index fbee9803197..469dd5a1d50 100644 --- a/libc/unistd/lib_pipe.c +++ b/libc/unistd/lib_pipe.c @@ -41,7 +41,7 @@ #include -#include +#include #if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 42a9ba5f60c..49842f3f304 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -34,7 +34,7 @@ "listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int" "lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int" "mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t" -"mkfifo2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char*","mode_t","size_t" +"mkfifo2","nuttx/drivers/drivers.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char*","mode_t","size_t" "mmap","sys/mman.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR void*","FAR void*","size_t","int","int","int","off_t" "mount","sys/mount.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_READABLE)","int","const char*","const char*","const char*","unsigned long","const void*" "mq_close","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t" @@ -52,7 +52,7 @@ "open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..." "opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*" "pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int" -"pipe2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|int*","size_t" +"pipe2","nuttx/drivers/drivers.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|int*","size_t" "poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int" "prctl","sys/prctl.h", "CONFIG_TASK_NAME_SIZE > 0","int","int","..." "pread","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t","off_t" From ddcaa3d4255ad564ecdb0ce6f640efc7b88c6aef Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 13:38:36 -0600 Subject: [PATCH 095/152] can.h moved from include/nuttx/ to include/nuttx/drivers. --- Documentation/NuttxPortingGuide.html | 2 +- arch/arm/src/lpc17xx/lpc17_can.c | 2 +- arch/arm/src/sama5/sam_can.c | 2 +- arch/arm/src/sama5/sam_can.h | 2 +- arch/arm/src/samv7/sam_mcan.c | 2 +- arch/arm/src/samv7/sam_mcan.h | 2 +- arch/arm/src/stm32/stm32_can.c | 2 +- arch/arm/src/stm32/stm32_can.h | 2 +- arch/arm/src/stm32l4/stm32l4_can.c | 2 +- arch/arm/src/stm32l4/stm32l4_can.h | 2 +- configs/nucleo-f303re/src/stm32_can.c | 2 +- configs/olimex-lpc1766stk/src/lpc17_can.c | 2 +- configs/olimex-stm32-e407/src/stm32_can.c | 2 +- configs/olimex-stm32-h405/src/stm32_can.c | 2 +- configs/olimex-stm32-h407/src/stm32_can.c | 2 +- configs/olimex-stm32-p107/src/stm32_can.c | 2 +- configs/olimex-stm32-p207/src/stm32_can.c | 2 +- configs/olimexino-stm32/src/stm32_can.c | 2 +- configs/sama5d3-xplained/src/sam_can.c | 2 +- configs/sama5d3x-ek/src/sam_can.c | 2 +- configs/same70-xplained/src/sam_mcan.c | 2 +- configs/samv71-xult/src/sam_mcan.c | 2 +- configs/shenzhou/src/stm32_can.c | 2 +- configs/stm3210e-eval/src/stm32_can.c | 2 +- configs/stm3220g-eval/src/stm32_can.c | 2 +- configs/stm3240g-eval/src/stm32_can.c | 2 +- configs/stm32f4discovery/src/stm32_can.c | 2 +- configs/viewtool-stm32f107/src/stm32_can.c | 2 +- configs/zkit-arm-1769/src/lpc17_can.c | 2 +- drivers/Kconfig | 2 +- drivers/README.txt | 3 ++- drivers/can.c | 2 +- include/nuttx/analog/adc.h | 2 +- include/nuttx/analog/dac.h | 2 +- include/nuttx/{ => drivers}/can.h | 16 +++++++++------- include/nuttx/fs/ioctl.h | 2 +- 36 files changed, 45 insertions(+), 42 deletions(-) rename include/nuttx/{ => drivers}/can.h (98%) diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index d36ca6f2104..96973ec865e 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -4472,7 +4472,7 @@ void board_autoled_off(int led);

  • Interface Definition. - The header file for the NuttX CAN driver reside at include/nuttx/can.h. + The header file for the NuttX CAN driver resides at include/nuttx/drivers/can.h. This header file includes both the application level interface to the CAN driver as well as the interface between the "upper half" and "lower half" drivers. The CAN module uses a standard character driver framework.
  • diff --git a/arch/arm/src/lpc17xx/lpc17_can.c b/arch/arm/src/lpc17xx/lpc17_can.c index f25de325b9f..f961bef5493 100644 --- a/arch/arm/src/lpc17xx/lpc17_can.c +++ b/arch/arm/src/lpc17xx/lpc17_can.c @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include "up_internal.h" #include "up_arch.h" diff --git a/arch/arm/src/sama5/sam_can.c b/arch/arm/src/sama5/sam_can.c index 3e1b3d116a1..f801e6e8341 100644 --- a/arch/arm/src/sama5/sam_can.c +++ b/arch/arm/src/sama5/sam_can.c @@ -60,7 +60,7 @@ #include #include -#include +#include #include "up_internal.h" #include "up_arch.h" diff --git a/arch/arm/src/sama5/sam_can.h b/arch/arm/src/sama5/sam_can.h index c18361533f2..5a26fe83143 100644 --- a/arch/arm/src/sama5/sam_can.h +++ b/arch/arm/src/sama5/sam_can.h @@ -45,7 +45,7 @@ #include "chip.h" #include "chip/sam_can.h" -#include +#include #if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1)) diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c index 748b01b10b3..49e05f306b9 100644 --- a/arch/arm/src/samv7/sam_mcan.c +++ b/arch/arm/src/samv7/sam_mcan.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include "cache.h" #include "up_internal.h" diff --git a/arch/arm/src/samv7/sam_mcan.h b/arch/arm/src/samv7/sam_mcan.h index 540800b37d3..07ecdd71ad3 100644 --- a/arch/arm/src/samv7/sam_mcan.h +++ b/arch/arm/src/samv7/sam_mcan.h @@ -45,7 +45,7 @@ #include "chip.h" #include "chip/sam_mcan.h" -#include +#include #if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || \ defined(CONFIG_SAMV7_MCAN1)) diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c index 334c7337d62..ed973d57bd0 100644 --- a/arch/arm/src/stm32/stm32_can.c +++ b/arch/arm/src/stm32/stm32_can.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include "up_internal.h" #include "up_arch.h" diff --git a/arch/arm/src/stm32/stm32_can.h b/arch/arm/src/stm32/stm32_can.h index e78b3af34f7..765dc95c0ca 100644 --- a/arch/arm/src/stm32/stm32_can.h +++ b/arch/arm/src/stm32/stm32_can.h @@ -45,7 +45,7 @@ #include "chip.h" #include "chip/stm32_can.h" -#include +#include /************************************************************************************ * Pre-processor Definitions diff --git a/arch/arm/src/stm32l4/stm32l4_can.c b/arch/arm/src/stm32l4/stm32l4_can.c index 7891319e8f1..18b49a86e74 100644 --- a/arch/arm/src/stm32l4/stm32l4_can.c +++ b/arch/arm/src/stm32l4/stm32l4_can.c @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include "up_internal.h" #include "up_arch.h" diff --git a/arch/arm/src/stm32l4/stm32l4_can.h b/arch/arm/src/stm32l4/stm32l4_can.h index 453b031bda2..86eb26fb659 100644 --- a/arch/arm/src/stm32l4/stm32l4_can.h +++ b/arch/arm/src/stm32l4/stm32l4_can.h @@ -49,7 +49,7 @@ #include "chip.h" #include "chip/stm32l4_can.h" -#include +#include /************************************************************************************ * Pre-processor Definitions diff --git a/configs/nucleo-f303re/src/stm32_can.c b/configs/nucleo-f303re/src/stm32_can.c index 41eae2ff92b..ec689b3e917 100644 --- a/configs/nucleo-f303re/src/stm32_can.c +++ b/configs/nucleo-f303re/src/stm32_can.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "stm32.h" diff --git a/configs/olimex-lpc1766stk/src/lpc17_can.c b/configs/olimex-lpc1766stk/src/lpc17_can.c index 3282587dd42..afb1ff47a0c 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_can.c +++ b/configs/olimex-lpc1766stk/src/lpc17_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/olimex-stm32-e407/src/stm32_can.c b/configs/olimex-stm32-e407/src/stm32_can.c index d4fa00aa4c9..42def42a81b 100644 --- a/configs/olimex-stm32-e407/src/stm32_can.c +++ b/configs/olimex-stm32-e407/src/stm32_can.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include "stm32.h" #include "stm32_can.h" diff --git a/configs/olimex-stm32-h405/src/stm32_can.c b/configs/olimex-stm32-h405/src/stm32_can.c index ed2ee4a069d..62c94a0b19b 100644 --- a/configs/olimex-stm32-h405/src/stm32_can.c +++ b/configs/olimex-stm32-h405/src/stm32_can.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include "stm32.h" #include "stm32_can.h" diff --git a/configs/olimex-stm32-h407/src/stm32_can.c b/configs/olimex-stm32-h407/src/stm32_can.c index c401e0c4111..ec7f2d39ab3 100644 --- a/configs/olimex-stm32-h407/src/stm32_can.c +++ b/configs/olimex-stm32-h407/src/stm32_can.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include "stm32.h" #include "stm32_can.h" diff --git a/configs/olimex-stm32-p107/src/stm32_can.c b/configs/olimex-stm32-p107/src/stm32_can.c index b292036f14f..2687c08f9c3 100644 --- a/configs/olimex-stm32-p107/src/stm32_can.c +++ b/configs/olimex-stm32-p107/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/olimex-stm32-p207/src/stm32_can.c b/configs/olimex-stm32-p207/src/stm32_can.c index 16c71ae43e7..b05dcb24461 100644 --- a/configs/olimex-stm32-p207/src/stm32_can.c +++ b/configs/olimex-stm32-p207/src/stm32_can.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include "stm32.h" #include "stm32_can.h" diff --git a/configs/olimexino-stm32/src/stm32_can.c b/configs/olimexino-stm32/src/stm32_can.c index 483d561f9f1..c03a1c8d266 100644 --- a/configs/olimexino-stm32/src/stm32_can.c +++ b/configs/olimexino-stm32/src/stm32_can.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/sama5d3-xplained/src/sam_can.c b/configs/sama5d3-xplained/src/sam_can.c index 7befbcee65f..76b12f3b145 100644 --- a/configs/sama5d3-xplained/src/sam_can.c +++ b/configs/sama5d3-xplained/src/sam_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/sama5d3x-ek/src/sam_can.c b/configs/sama5d3x-ek/src/sam_can.c index dae9f4e61e7..f483e30dd0c 100644 --- a/configs/sama5d3x-ek/src/sam_can.c +++ b/configs/sama5d3x-ek/src/sam_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/same70-xplained/src/sam_mcan.c b/configs/same70-xplained/src/sam_mcan.c index 722e83c3613..2c5301c3a1c 100644 --- a/configs/same70-xplained/src/sam_mcan.c +++ b/configs/same70-xplained/src/sam_mcan.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include "sam_mcan.h" diff --git a/configs/samv71-xult/src/sam_mcan.c b/configs/samv71-xult/src/sam_mcan.c index e692eb40133..bb28cbb9b01 100644 --- a/configs/samv71-xult/src/sam_mcan.c +++ b/configs/samv71-xult/src/sam_mcan.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include "sam_mcan.h" diff --git a/configs/shenzhou/src/stm32_can.c b/configs/shenzhou/src/stm32_can.c index 8bfe95ac098..bc6472bef78 100644 --- a/configs/shenzhou/src/stm32_can.c +++ b/configs/shenzhou/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/stm3210e-eval/src/stm32_can.c b/configs/stm3210e-eval/src/stm32_can.c index 1d296be81c6..284e6098c0c 100644 --- a/configs/stm3210e-eval/src/stm32_can.c +++ b/configs/stm3210e-eval/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/stm3220g-eval/src/stm32_can.c b/configs/stm3220g-eval/src/stm32_can.c index a7a7bf2e177..5115a7b7d9a 100644 --- a/configs/stm3220g-eval/src/stm32_can.c +++ b/configs/stm3220g-eval/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/stm3240g-eval/src/stm32_can.c b/configs/stm3240g-eval/src/stm32_can.c index e5350615d23..75e138fd206 100644 --- a/configs/stm3240g-eval/src/stm32_can.c +++ b/configs/stm3240g-eval/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/stm32f4discovery/src/stm32_can.c b/configs/stm32f4discovery/src/stm32_can.c index bbc0f3e093e..beafd449d9c 100644 --- a/configs/stm32f4discovery/src/stm32_can.c +++ b/configs/stm32f4discovery/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/viewtool-stm32f107/src/stm32_can.c b/configs/viewtool-stm32f107/src/stm32_can.c index 2aad6dfdf21..ce2b5912f5d 100644 --- a/configs/viewtool-stm32f107/src/stm32_can.c +++ b/configs/viewtool-stm32f107/src/stm32_can.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/zkit-arm-1769/src/lpc17_can.c b/configs/zkit-arm-1769/src/lpc17_can.c index 0bdba844465..03176894a9a 100644 --- a/configs/zkit-arm-1769/src/lpc17_can.c +++ b/configs/zkit-arm-1769/src/lpc17_can.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/drivers/Kconfig b/drivers/Kconfig index 5418cd82892..090fbf5168b 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -148,7 +148,7 @@ menuconfig CAN default n ---help--- This selection enables building of the "upper-half" CAN driver. - See include/nuttx/can.h for further CAN driver information. + See include/nuttx/drivers/can.h for further CAN driver information. if CAN diff --git a/drivers/README.txt b/drivers/README.txt index 420988ccd48..7137db2aa0b 100644 --- a/drivers/README.txt +++ b/drivers/README.txt @@ -13,7 +13,8 @@ Files in this directory ^^^^^^^^^^^^^^^^^^^^^^^ can.c - This is a CAN driver. See include/nuttx/can.h for usage information. + This is a CAN driver. See include/nuttx/drivers/can.h for usage + information. dev_null.c and dev_zero.c These files provide the standard /dev/null and /dev/zero devices. diff --git a/drivers/can.c b/drivers/can.c index 8dc67601a7e..483769d7db5 100644 --- a/drivers/can.c +++ b/drivers/can.c @@ -56,7 +56,7 @@ #include #include -#include +#include #ifdef CONFIG_CAN_TXREADY # include diff --git a/include/nuttx/analog/adc.h b/include/nuttx/analog/adc.h index a566f2a0ded..639eddc5cf8 100644 --- a/include/nuttx/analog/adc.h +++ b/include/nuttx/analog/adc.h @@ -6,7 +6,7 @@ * Author: Li Zhuoyi * Gregory Nutt * - * Derived from include/nuttx/can.h + * Derived from include/nuttx/drivers/can.h * * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/include/nuttx/analog/dac.h b/include/nuttx/analog/dac.h index 5648b51a9a8..db2cf5a7368 100644 --- a/include/nuttx/analog/dac.h +++ b/include/nuttx/analog/dac.h @@ -5,7 +5,7 @@ * Author: Li Zhuoyi * History: 0.1 2011-08-04 initial version * - * Derived from include/nuttx/can.h + * Derived from include/nuttx/drivers/can.h * * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/include/nuttx/can.h b/include/nuttx/drivers/can.h similarity index 98% rename from include/nuttx/can.h rename to include/nuttx/drivers/can.h index 27ef01d77c4..ed570097fc4 100644 --- a/include/nuttx/can.h +++ b/include/nuttx/drivers/can.h @@ -1,7 +1,7 @@ /************************************************************************************ - * include/nuttx/can.h + * include/nuttx/drivers/can.h * - * Copyright (C) 2008, 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008, 2009, 2011-2012, 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef _INCLUDE_NUTTX_CAN_H -#define _INCLUDE_NUTTX_CAN_H +#ifndef _INCLUDE_NUTTX_DRVERS_CAN_H +#define _INCLUDE_NUTTX_DRVERS_CAN_H /************************************************************************************ * Included Files @@ -60,9 +60,11 @@ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ + /* Configuration ********************************************************************/ -/* CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or - * CONFIG_STM32_CAN2 must also be defined) +/* CONFIG_CAN - Enables CAN support (MCU-specific selections are also required. For + * STM32, as an example, one or both of CONFIG_STM32_CAN1 or CONFIG_STM32_CAN2 + * must also be defined) * CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default * Standard 11-bit IDs. * CONFIG_CAN_FD - Enable support for CAN FD mode. For the upper half driver, this @@ -794,4 +796,4 @@ int can_txready(FAR struct can_dev_s *dev); #endif #endif /* CONFIG_CAN */ -#endif /* _INCLUDE_NUTTX_CAN_H */ +#endif /* _INCLUDE_NUTTX_DRVERS_CAN_H */ diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index b79c783923f..adfa0446cd9 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -341,7 +341,7 @@ #define _RELAYIOC(nr) _IOC(_RELAYBASE,nr) /* CAN driver ioctl definitions *********************************************/ -/* (see nuttx/can.h */ +/* (see nuttx/drivers/can.h */ #define _CANIOCVALID(c) (_IOC_TYPE(c)==_CANBASE) #define _CANIOC(nr) _IOC(_CANBASE,nr) From 1b9b3a7b47124cf9c546e38786b9c050d92fc8fd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 13:48:24 -0600 Subject: [PATCH 096/152] pwm.h moved from include/nuttx/ to include/nuttx/drivers. --- Documentation/NuttxPortingGuide.html | 2 +- arch/arm/src/efm32/efm32_pwm.c | 2 +- arch/arm/src/efm32/efm32_pwm.h | 2 +- arch/arm/src/kinetis/kinetis_pwm.c | 2 +- arch/arm/src/kl/kl_pwm.c | 2 +- arch/arm/src/lpc11xx/lpc11_timer.c | 2 +- arch/arm/src/lpc17xx/lpc17_mcpwm.c | 2 +- arch/arm/src/lpc17xx/lpc17_pwm.c | 2 +- arch/arm/src/lpc17xx/lpc17_timer.c | 2 +- arch/arm/src/sama5/sam_pwm.c | 2 +- arch/arm/src/stm32/stm32_pwm.c | 2 +- arch/arm/src/stm32/stm32_pwm.h | 2 +- arch/arm/src/stm32l4/stm32l4_pwm.c | 2 +- arch/arm/src/stm32l4/stm32l4_pwm.h | 2 +- configs/freedom-kl25z/src/kl_pwm.c | 2 +- configs/freedom-kl26z/src/kl_pwm.c | 2 +- configs/lpcxpresso-lpc1115/src/lpc11_pwm.c | 2 +- configs/lpcxpresso-lpc1768/src/lpc17_pwm.c | 2 +- configs/mbed/src/lpc17_pwm.c | 2 +- configs/mikroe-stm32f4/src/stm32_pwm.c | 2 +- configs/nucleo-f303re/src/stm32_pwm.c | 2 +- configs/sama5d3-xplained/src/sam_pwm.c | 2 +- configs/sama5d3x-ek/src/sam_pwm.c | 2 +- configs/sama5d4-ek/src/sam_pwm.c | 2 +- configs/stm3220g-eval/src/stm32_pwm.c | 2 +- configs/stm3240g-eval/src/stm32_pwm.c | 2 +- configs/stm32_tiny/src/stm32_pwm.c | 2 +- configs/stm32f3discovery/src/stm32_pwm.c | 2 +- configs/stm32f4discovery/src/stm32_pwm.c | 2 +- configs/stm32f4discovery/src/stm32_rgbled.c | 2 +- configs/stm32ldiscovery/src/stm32_pwm.c | 2 +- configs/teensy-3.x/src/k20_pwm.c | 2 +- configs/teensy-lc/src/kl_pwm.c | 2 +- configs/u-blox-c027/src/lpc17_pwm.c | 2 +- drivers/Kconfig | 2 +- drivers/README.txt | 2 +- drivers/leds/rgbled.c | 2 +- drivers/pwm.c | 2 +- include/nuttx/{ => drivers}/pwm.h | 8 ++++---- include/nuttx/fs/ioctl.h | 2 +- include/nuttx/leds/rgbled.h | 2 +- 41 files changed, 44 insertions(+), 44 deletions(-) rename include/nuttx/{ => drivers}/pwm.h (98%) diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 96973ec865e..bf32596fef0 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -4439,7 +4439,7 @@ void board_autoled_off(int led);

    • Interface Definition. - The header file for the NuttX PWM driver reside at include/nuttx/pwm.h. + The header file for the NuttX PWM driver reside at include/nuttx/drivers/pwm.h. This header file includes both the application level interface to the PWM driver as well as the interface between the "upper half" and "lower half" drivers. The PWM module uses a standard character driver framework. However, since the PWM driver is a devices control interface and not a data transfer interface, diff --git a/arch/arm/src/efm32/efm32_pwm.c b/arch/arm/src/efm32/efm32_pwm.c index b34d8aeb2ff..f07a3eed4b7 100644 --- a/arch/arm/src/efm32/efm32_pwm.c +++ b/arch/arm/src/efm32/efm32_pwm.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "up_arch.h" diff --git a/arch/arm/src/efm32/efm32_pwm.h b/arch/arm/src/efm32/efm32_pwm.h index af46c3b6f8b..61e4f5f116d 100644 --- a/arch/arm/src/efm32/efm32_pwm.h +++ b/arch/arm/src/efm32/efm32_pwm.h @@ -39,7 +39,7 @@ /* The EFM32 does not have dedicated PWM hardware. Rather, pulsed output * control is a capability of the EFM32 timers. The logic in this file * implements the lower half of the standard, NuttX PWM interface using the - * EFM32 timers. That interface is described in include/nuttx/pwm.h. + * EFM32 timers. That interface is described in include/nuttx/drivers/pwm.h. */ /**************************************************************************** diff --git a/arch/arm/src/kinetis/kinetis_pwm.c b/arch/arm/src/kinetis/kinetis_pwm.c index 19de382634e..d4ccc74090c 100644 --- a/arch/arm/src/kinetis/kinetis_pwm.c +++ b/arch/arm/src/kinetis/kinetis_pwm.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/kl/kl_pwm.c b/arch/arm/src/kl/kl_pwm.c index 6f3f6e40503..a34aa0f8175 100644 --- a/arch/arm/src/kl/kl_pwm.c +++ b/arch/arm/src/kl/kl_pwm.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/lpc11xx/lpc11_timer.c b/arch/arm/src/lpc11xx/lpc11_timer.c index e742dc2de0b..a9ce65a073a 100644 --- a/arch/arm/src/lpc11xx/lpc11_timer.c +++ b/arch/arm/src/lpc11xx/lpc11_timer.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/lpc17xx/lpc17_mcpwm.c b/arch/arm/src/lpc17xx/lpc17_mcpwm.c index be526964c4a..db0d1a9d67d 100644 --- a/arch/arm/src/lpc17xx/lpc17_mcpwm.c +++ b/arch/arm/src/lpc17xx/lpc17_mcpwm.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/lpc17xx/lpc17_pwm.c b/arch/arm/src/lpc17xx/lpc17_pwm.c index dc073fc1a73..c284934570c 100644 --- a/arch/arm/src/lpc17xx/lpc17_pwm.c +++ b/arch/arm/src/lpc17xx/lpc17_pwm.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/lpc17xx/lpc17_timer.c b/arch/arm/src/lpc17xx/lpc17_timer.c index 9278578b678..434f416021f 100644 --- a/arch/arm/src/lpc17xx/lpc17_timer.c +++ b/arch/arm/src/lpc17xx/lpc17_timer.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/sama5/sam_pwm.c b/arch/arm/src/sama5/sam_pwm.c index 0de1d91dea0..d523da24a1c 100644 --- a/arch/arm/src/sama5/sam_pwm.c +++ b/arch/arm/src/sama5/sam_pwm.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include "chip/sam_pinmap.h" #include diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c index 7b8f4224e08..425f256ba05 100644 --- a/arch/arm/src/stm32/stm32_pwm.c +++ b/arch/arm/src/stm32/stm32_pwm.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/stm32/stm32_pwm.h b/arch/arm/src/stm32/stm32_pwm.h index e636ead3a37..1321389046e 100644 --- a/arch/arm/src/stm32/stm32_pwm.h +++ b/arch/arm/src/stm32/stm32_pwm.h @@ -41,7 +41,7 @@ /* The STM32 does not have dedicated PWM hardware. Rather, pulsed output control * is a capabilitiy of the STM32 timers. The logic in this file implements the * lower half of the standard, NuttX PWM interface using the STM32 timers. That - * interface is described in include/nuttx/pwm.h. + * interface is described in include/nuttx/drivers/pwm.h. */ /************************************************************************************ diff --git a/arch/arm/src/stm32l4/stm32l4_pwm.c b/arch/arm/src/stm32l4/stm32l4_pwm.c index b5cd35fb29d..d3478ea0df2 100644 --- a/arch/arm/src/stm32l4/stm32l4_pwm.c +++ b/arch/arm/src/stm32l4/stm32l4_pwm.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include "up_internal.h" diff --git a/arch/arm/src/stm32l4/stm32l4_pwm.h b/arch/arm/src/stm32l4/stm32l4_pwm.h index fff04e9e476..942aef0cfa5 100644 --- a/arch/arm/src/stm32l4/stm32l4_pwm.h +++ b/arch/arm/src/stm32l4/stm32l4_pwm.h @@ -41,7 +41,7 @@ /* The STM32L4 does not have dedicated PWM hardware. Rather, pulsed output control * is a capability of the STM32L4 timers. The logic in this file implements the * lower half of the standard, NuttX PWM interface using the STM32L4 timers. That - * interface is described in include/nuttx/pwm.h. + * interface is described in include/nuttx/drivers/pwm.h. */ /************************************************************************************ diff --git a/configs/freedom-kl25z/src/kl_pwm.c b/configs/freedom-kl25z/src/kl_pwm.c index e00d1ca52b9..1db53f5a267 100644 --- a/configs/freedom-kl25z/src/kl_pwm.c +++ b/configs/freedom-kl25z/src/kl_pwm.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include diff --git a/configs/freedom-kl26z/src/kl_pwm.c b/configs/freedom-kl26z/src/kl_pwm.c index 672d49e70e8..cb5b6af3f8a 100644 --- a/configs/freedom-kl26z/src/kl_pwm.c +++ b/configs/freedom-kl26z/src/kl_pwm.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include diff --git a/configs/lpcxpresso-lpc1115/src/lpc11_pwm.c b/configs/lpcxpresso-lpc1115/src/lpc11_pwm.c index 6f303e5f5e4..9ecbfcf85e8 100644 --- a/configs/lpcxpresso-lpc1115/src/lpc11_pwm.c +++ b/configs/lpcxpresso-lpc1115/src/lpc11_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/lpcxpresso-lpc1768/src/lpc17_pwm.c b/configs/lpcxpresso-lpc1768/src/lpc17_pwm.c index 4b261555cb6..5aec1613c14 100644 --- a/configs/lpcxpresso-lpc1768/src/lpc17_pwm.c +++ b/configs/lpcxpresso-lpc1768/src/lpc17_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/configs/mbed/src/lpc17_pwm.c b/configs/mbed/src/lpc17_pwm.c index c8b6881dc9b..5b312bd71b3 100644 --- a/configs/mbed/src/lpc17_pwm.c +++ b/configs/mbed/src/lpc17_pwm.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include diff --git a/configs/mikroe-stm32f4/src/stm32_pwm.c b/configs/mikroe-stm32f4/src/stm32_pwm.c index 0710d42f8b2..39ac1f2b6ce 100644 --- a/configs/mikroe-stm32f4/src/stm32_pwm.c +++ b/configs/mikroe-stm32f4/src/stm32_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include diff --git a/configs/nucleo-f303re/src/stm32_pwm.c b/configs/nucleo-f303re/src/stm32_pwm.c index 6b940e8879f..7ab25eac4d9 100644 --- a/configs/nucleo-f303re/src/stm32_pwm.c +++ b/configs/nucleo-f303re/src/stm32_pwm.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "stm32_pwm.h" #include "nucleo-f303re.h" diff --git a/configs/sama5d3-xplained/src/sam_pwm.c b/configs/sama5d3-xplained/src/sam_pwm.c index 91664c1d210..a6acea54d85 100644 --- a/configs/sama5d3-xplained/src/sam_pwm.c +++ b/configs/sama5d3-xplained/src/sam_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/configs/sama5d3x-ek/src/sam_pwm.c b/configs/sama5d3x-ek/src/sam_pwm.c index ef908554516..8cc1642e71a 100644 --- a/configs/sama5d3x-ek/src/sam_pwm.c +++ b/configs/sama5d3x-ek/src/sam_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/configs/sama5d4-ek/src/sam_pwm.c b/configs/sama5d4-ek/src/sam_pwm.c index b69d8f5e5a8..ebae4ce11b8 100644 --- a/configs/sama5d4-ek/src/sam_pwm.c +++ b/configs/sama5d4-ek/src/sam_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/configs/stm3220g-eval/src/stm32_pwm.c b/configs/stm3220g-eval/src/stm32_pwm.c index b934120856c..e689794d576 100644 --- a/configs/stm3220g-eval/src/stm32_pwm.c +++ b/configs/stm3220g-eval/src/stm32_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include diff --git a/configs/stm3240g-eval/src/stm32_pwm.c b/configs/stm3240g-eval/src/stm32_pwm.c index 4ccf6dad9c4..a565995d429 100644 --- a/configs/stm3240g-eval/src/stm32_pwm.c +++ b/configs/stm3240g-eval/src/stm32_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include diff --git a/configs/stm32_tiny/src/stm32_pwm.c b/configs/stm32_tiny/src/stm32_pwm.c index 8efec614b60..675e9d0c150 100644 --- a/configs/stm32_tiny/src/stm32_pwm.c +++ b/configs/stm32_tiny/src/stm32_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include diff --git a/configs/stm32f3discovery/src/stm32_pwm.c b/configs/stm32f3discovery/src/stm32_pwm.c index 1cdfb8c9c40..a11d2a464aa 100644 --- a/configs/stm32f3discovery/src/stm32_pwm.c +++ b/configs/stm32f3discovery/src/stm32_pwm.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include diff --git a/configs/stm32f4discovery/src/stm32_pwm.c b/configs/stm32f4discovery/src/stm32_pwm.c index 9e80b06c7ea..5d7d8ee7fd1 100644 --- a/configs/stm32f4discovery/src/stm32_pwm.c +++ b/configs/stm32f4discovery/src/stm32_pwm.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "chip.h" diff --git a/configs/stm32f4discovery/src/stm32_rgbled.c b/configs/stm32f4discovery/src/stm32_rgbled.c index 66dc4fd0f15..c1d320a05a7 100644 --- a/configs/stm32f4discovery/src/stm32_rgbled.c +++ b/configs/stm32f4discovery/src/stm32_rgbled.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include diff --git a/configs/stm32ldiscovery/src/stm32_pwm.c b/configs/stm32ldiscovery/src/stm32_pwm.c index 8da1601b715..1aeca320fcb 100644 --- a/configs/stm32ldiscovery/src/stm32_pwm.c +++ b/configs/stm32ldiscovery/src/stm32_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/configs/teensy-3.x/src/k20_pwm.c b/configs/teensy-3.x/src/k20_pwm.c index 97658c9e2b1..5fc7652f161 100644 --- a/configs/teensy-3.x/src/k20_pwm.c +++ b/configs/teensy-3.x/src/k20_pwm.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include diff --git a/configs/teensy-lc/src/kl_pwm.c b/configs/teensy-lc/src/kl_pwm.c index 91623d9e98b..13d58804db5 100644 --- a/configs/teensy-lc/src/kl_pwm.c +++ b/configs/teensy-lc/src/kl_pwm.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include diff --git a/configs/u-blox-c027/src/lpc17_pwm.c b/configs/u-blox-c027/src/lpc17_pwm.c index 435acf34737..03569cc11dd 100644 --- a/configs/u-blox-c027/src/lpc17_pwm.c +++ b/configs/u-blox-c027/src/lpc17_pwm.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include diff --git a/drivers/Kconfig b/drivers/Kconfig index 090fbf5168b..6cd2ac541ed 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -286,7 +286,7 @@ menuconfig PWM default n ---help--- This selection enables building of the "upper-half" PWM driver. - See include/nuttx/pwm.h for further PWM driver information. + See include/nuttx/drivers/pwm.h for further PWM driver information. if PWM diff --git a/drivers/README.txt b/drivers/README.txt index 7137db2aa0b..42989af1205 100644 --- a/drivers/README.txt +++ b/drivers/README.txt @@ -25,7 +25,7 @@ dev_null.c and dev_zero.c pwm.c Provides the "upper half" of a pulse width modulation (PWM) driver. The "lower half" of the PWM driver is provided by device-specific - logic. See include/nuttx/pwm.h for usage information. + logic. See include/nuttx/drivers/pwm.h for usage information. ramdisk.c Can be used to set up a block of memory or (read-only) FLASH as diff --git a/drivers/leds/rgbled.c b/drivers/leds/rgbled.c index 88eb2f62233..81b2ff55916 100644 --- a/drivers/leds/rgbled.c +++ b/drivers/leds/rgbled.c @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/pwm.c b/drivers/pwm.c index 7fb6b3436f5..f3de79a387d 100644 --- a/drivers/pwm.c +++ b/drivers/pwm.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include diff --git a/include/nuttx/pwm.h b/include/nuttx/drivers/pwm.h similarity index 98% rename from include/nuttx/pwm.h rename to include/nuttx/drivers/pwm.h index fe13a4efc69..7cf80b0d7b3 100644 --- a/include/nuttx/pwm.h +++ b/include/nuttx/drivers/pwm.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/pwm.h + * include/nuttx/drivers/pwm.h * * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_PWM_H -#define __INCLUDE_NUTTX_PWM_H +#ifndef __INCLUDE_NUTTX_DRIVERS_PWM_H +#define __INCLUDE_NUTTX_DRIVERS_PWM_H /* For the purposes of this driver, a PWM device is any device that generates * periodic output pulses s of controlled frequency and pulse width. Such a @@ -316,4 +316,4 @@ void pwm_expired(FAR void *handle); #endif #endif /* CONFIG_PWM */ -#endif /* __INCLUDE_NUTTX_PWM_H */ +#endif /* __INCLUDE_NUTTX_DRIVERS_PWM_H */ diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index adfa0446cd9..ba7586e3da6 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -251,7 +251,7 @@ * IN: None * OUT: None */ -/* NuttX PWM ioctl definitions (see nuttx/pwm.h) ****************************/ +/* NuttX PWM ioctl definitions (see nuttx/drivers/pwm.h) ****************************/ #define _PWMIOCVALID(c) (_IOC_TYPE(c)==_PWMIOCBASE) #define _PWMIOC(nr) _IOC(_PWMIOCBASE,nr) diff --git a/include/nuttx/leds/rgbled.h b/include/nuttx/leds/rgbled.h index 07560d6a6eb..554f0719ffd 100644 --- a/include/nuttx/leds/rgbled.h +++ b/include/nuttx/leds/rgbled.h @@ -45,7 +45,7 @@ #include -#include +#include #include #ifdef CONFIG_RGBLED From 46dbbe837e745d9d43cc9d9963ae52954f694f54 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 13:54:38 -0600 Subject: [PATCH 097/152] rwbuffer.h moved from include/nuttx/ to include/nuttx/drivers. --- drivers/mmcsd/mmcsd_sdio.c | 2 +- drivers/mtd/ftl.c | 2 +- drivers/mtd/mtd_rwbuffer.c | 2 +- drivers/rwbuffer.c | 2 +- include/nuttx/{ => drivers}/rwbuffer.h | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) rename include/nuttx/{ => drivers}/rwbuffer.h (97%) diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 46ee65a9d54..dbdf4e98ca8 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index 7fa0c5f4a0f..13f832c3515 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/drivers/mtd/mtd_rwbuffer.c b/drivers/mtd/mtd_rwbuffer.c index c152bc5f754..8d2ffc2d47e 100644 --- a/drivers/mtd/mtd_rwbuffer.c +++ b/drivers/mtd/mtd_rwbuffer.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include diff --git a/drivers/rwbuffer.c b/drivers/rwbuffer.c index fd5b6e53eea..a7db82e156d 100644 --- a/drivers/rwbuffer.c +++ b/drivers/rwbuffer.c @@ -52,7 +52,7 @@ #include #include -#include +#include #if defined(CONFIG_DRVR_WRITEBUFFER) || defined(CONFIG_DRVR_READAHEAD) diff --git a/include/nuttx/rwbuffer.h b/include/nuttx/drivers/rwbuffer.h similarity index 97% rename from include/nuttx/rwbuffer.h rename to include/nuttx/drivers/rwbuffer.h index c658117b686..ebb45ab8a42 100644 --- a/include/nuttx/rwbuffer.h +++ b/include/nuttx/drivers/rwbuffer.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/rwbuffer.h + * include/nuttx/drivers/rwbuffer.h * * Copyright (C) 2009, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_RWBUFFER_H -#define __INCLUDE_NUTTX_RWBUFFER_H +#ifndef __INCLUDE_NUTTX_DRIVERS_RWBUFFER_H +#define __INCLUDE_NUTTX_DRIVERS_RWBUFFER_H /**************************************************************************** * Included Files @@ -208,4 +208,4 @@ int rwb_invalidate(FAR struct rwbuffer_s *rwb, #endif #endif /* CONFIG_DRVR_WRITEBUFFER || CONFIG_DRVR_READAHEAD */ -#endif /* __INCLUDE_NUTTX_RWBUFFER_H */ +#endif /* __INCLUDE_NUTTX_DRIVERS_RWBUFFER_H */ From ee9c66186cda3ba16dc868575f487f2ae2f29f39 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 14:02:18 -0600 Subject: [PATCH 098/152] ramdisk.h moved from include/fs/nuttx/ to include/nuttx/drivers. --- arch/sim/src/up_blockdevice.c | 2 +- binfmt/pcode.c | 2 +- configs/ea3131/src/lpc31_usbmsc.c | 2 +- configs/ea3152/src/lpc31_usbmsc.c | 2 +- configs/sama5d4-ek/src/sam_bringup.c | 2 +- configs/same70-xplained/src/sam_bringup.c | 2 +- configs/samv71-xult/src/sam_bringup.c | 2 +- configs/sim/src/sim.h | 2 +- configs/sim/src/sim_zoneinfo.c | 4 ++-- configs/stm32l476vg-disco/src/stm32_appinit.c | 2 +- drivers/Kconfig | 2 +- drivers/README.txt | 2 +- drivers/ramdisk.c | 2 +- include/nuttx/{fs => drivers}/ramdisk.h | 10 +++++----- libc/zoneinfo/README.txt | 4 ++-- 15 files changed, 21 insertions(+), 21 deletions(-) rename include/nuttx/{fs => drivers}/ramdisk.h (94%) diff --git a/arch/sim/src/up_blockdevice.c b/arch/sim/src/up_blockdevice.c index 066df0a1dfe..b74480ecc06 100644 --- a/arch/sim/src/up_blockdevice.c +++ b/arch/sim/src/up_blockdevice.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include "up_internal.h" diff --git a/binfmt/pcode.c b/binfmt/pcode.c index f295e1291c2..7215a944570 100644 --- a/binfmt/pcode.c +++ b/binfmt/pcode.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include diff --git a/configs/ea3131/src/lpc31_usbmsc.c b/configs/ea3131/src/lpc31_usbmsc.c index 0d9736d4d6b..0965cf6a57a 100644 --- a/configs/ea3131/src/lpc31_usbmsc.c +++ b/configs/ea3131/src/lpc31_usbmsc.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/configs/ea3152/src/lpc31_usbmsc.c b/configs/ea3152/src/lpc31_usbmsc.c index b3e431eeba8..7e4909c838d 100644 --- a/configs/ea3152/src/lpc31_usbmsc.c +++ b/configs/ea3152/src/lpc31_usbmsc.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/configs/sama5d4-ek/src/sam_bringup.c b/configs/sama5d4-ek/src/sam_bringup.c index 831dc06da75..3aaccd3244a 100644 --- a/configs/sama5d4-ek/src/sam_bringup.c +++ b/configs/sama5d4-ek/src/sam_bringup.c @@ -50,7 +50,7 @@ # include #endif -#include +#include #include #include diff --git a/configs/same70-xplained/src/sam_bringup.c b/configs/same70-xplained/src/sam_bringup.c index d136a7e7107..7cc5fed0c00 100644 --- a/configs/same70-xplained/src/sam_bringup.c +++ b/configs/same70-xplained/src/sam_bringup.c @@ -51,7 +51,7 @@ #endif #include -#include +#include #include #include #include diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 0ff1c5b3279..3999c0ab24a 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -51,7 +51,7 @@ #endif #include -#include +#include #include #include #include diff --git a/configs/sim/src/sim.h b/configs/sim/src/sim.h index 0e1f27937d3..97d34040d55 100644 --- a/configs/sim/src/sim.h +++ b/configs/sim/src/sim.h @@ -90,7 +90,7 @@ int sim_bringup(void); * * - First, a ROM disk device must be created. This is done by calling * the function romdisk_register() as described in - * nuttx/include/nuttx/fs/ramdisk.h. This is an OS level operation + * nuttx/include/nuttx/drivers/ramdisk.h. This is an OS level operation * and must be done in the board-level logic before your appliction * starts. * diff --git a/configs/sim/src/sim_zoneinfo.c b/configs/sim/src/sim_zoneinfo.c index dbb85025e79..6dd056152c2 100644 --- a/configs/sim/src/sim_zoneinfo.c +++ b/configs/sim/src/sim_zoneinfo.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #ifdef CONFIG_LIB_ZONEINFO_ROMFS @@ -97,7 +97,7 @@ * * - First, a ROM disk device must be created. This is done by calling * the function romdisk_register() as described in - * nuttx/include/nuttx/fs/ramdisk.h. This is an OS level operation + * nuttx/include/nuttx/drivers/ramdisk.h. This is an OS level operation * and must be done in the board-level logic before your appliction * starts. * diff --git a/configs/stm32l476vg-disco/src/stm32_appinit.c b/configs/stm32l476vg-disco/src/stm32_appinit.c index 2d6a11d6dcb..4cccfd50392 100644 --- a/configs/stm32l476vg-disco/src/stm32_appinit.c +++ b/configs/stm32l476vg-disco/src/stm32_appinit.c @@ -59,7 +59,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/Kconfig b/drivers/Kconfig index 6cd2ac541ed..c3ef7aa49af 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -141,7 +141,7 @@ config RAMDISK ---help--- Can be used to set up a block of memory or (read-only) FLASH as a block driver that can be mounted as a files system. See - include/nuttx/fs/ramdisk.h. + include/nuttx/drivers/ramdisk.h. menuconfig CAN bool "CAN Driver Support" diff --git a/drivers/README.txt b/drivers/README.txt index 42989af1205..a76c0e3434f 100644 --- a/drivers/README.txt +++ b/drivers/README.txt @@ -30,7 +30,7 @@ pwm.c ramdisk.c Can be used to set up a block of memory or (read-only) FLASH as a block driver that can be mounted as a files system. See - include/nuttx/fs/ramdisk.h. + include/nuttx/drivers/ramdisk.h. rwbuffer.c A facility that can be use by any block driver in-order to add diff --git a/drivers/ramdisk.c b/drivers/ramdisk.c index 4ce4057103b..4473a41ad1d 100644 --- a/drivers/ramdisk.c +++ b/drivers/ramdisk.c @@ -51,7 +51,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/include/nuttx/fs/ramdisk.h b/include/nuttx/drivers/ramdisk.h similarity index 94% rename from include/nuttx/fs/ramdisk.h rename to include/nuttx/drivers/ramdisk.h index 0f425c46aaf..27cfb4e992a 100644 --- a/include/nuttx/fs/ramdisk.h +++ b/include/nuttx/drivers/ramdisk.h @@ -1,7 +1,7 @@ /**************************************************************************** - * include/nuttx/fs/ramdisk.h + * include/nuttx/drivers/ramdisk.h * - * Copyright (C) 2008-2009, 2012-2013, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013, 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_FS_RAMDISK_H -#define __INCLUDE_NUTTX_FS_RAMDISK_H +#ifndef __INCLUDE_NUTTX_DRIVERS_RAMDISK_H +#define __INCLUDE_NUTTX_DRIVERS_RAMDISK_H /**************************************************************************** * Included Files @@ -105,4 +105,4 @@ int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors, } #endif -#endif /* __INCLUDE_NUTTX_FS_RAMDISK_H */ +#endif /* __INCLUDE_NUTTX_DRIVERS_RAMDISK_H */ diff --git a/libc/zoneinfo/README.txt b/libc/zoneinfo/README.txt index 7aea826ea8b..9ceb5de8093 100644 --- a/libc/zoneinfo/README.txt +++ b/libc/zoneinfo/README.txt @@ -23,7 +23,7 @@ doing this: - First, a ROM disk device must be created. This is done by calling the function romdisk_register() as described in - nuttx/include/nuttx/fs/ramdisk.h. This is an OS level operation + nuttx/include/nuttx/drivers/ramdisk.h. This is an OS level operation and must be done in the board-level logic before your application starts. @@ -114,7 +114,7 @@ Sample Code to Mount the ROMFS Filesystem #include #include -#include +#include #include /**************************************************************************** From 129ddc2d443bf5327c363c8e324dfd155b87bf0e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 13:55:31 -0600 Subject: [PATCH 099/152] Fix typo introduced into syscall logic --- syscall/syscall_stublookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 6ba5a0fb678..17800fa1b7c 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -223,7 +223,7 @@ uintptr_t STUB_open(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); uintptr_t STUB_opendir(int nbr, uintptr_t parm1); -uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uinptr_t parm2); +uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_readdir(int nbr, uintptr_t parm1); uintptr_t STUB_rewinddir(int nbr, uintptr_t parm1); uintptr_t STUB_seekdir(int nbr, uintptr_t parm1, uintptr_t parm2); From 8082404381632dc65182e9eec805f9309844567f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 14:19:09 -0600 Subject: [PATCH 100/152] Update a README --- configs/freedom-k64f/README.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 2c6608c8467..d57f740e086 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -899,8 +899,12 @@ Where is one of the following: CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary - 3. The Serial Console is provided on UART3 with the correct pin - configuration for use with an Arduino Serial Shield. + 3. The Serial Console is provided on UART0 with the correct pin + configuration for use with the OpenSDAv2 VCOM. This can be switched + to use a RS-232 shield on UART3 by reconfiguring the serial console. + + NOTE: On my Windows 10 / Cygwin64 system, the OpenSDAv2 VCOM is not + recognized. I probably need to install a driver? 4. Support for NSH built-in applications is enabled, but no built-in applications have been configured in. From 600176bb9cea87296e5f3476a8da5bedf943ed6f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 14:21:06 -0600 Subject: [PATCH 101/152] Freedom K64F: Refresh configurations --- configs/freedom-k64f/netnsh/defconfig | 4 +--- configs/freedom-k64f/nsh/defconfig | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index b9a711363f5..03e1ec4e86f 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -454,6 +454,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -899,7 +900,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # # CONFIG_EXAMPLES_CHAT is not set # CONFIG_EXAMPLES_CONFIGDATA is not set -# CONFIG_EXAMPLES_CPUHOG is not set # CONFIG_EXAMPLES_DHCPD is not set # CONFIG_EXAMPLES_DISCOVER is not set # CONFIG_EXAMPLES_ELF is not set @@ -928,7 +928,6 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NXTEXT is not set # CONFIG_EXAMPLES_OSTEST is not set # CONFIG_EXAMPLES_PCA9635 is not set -# CONFIG_EXAMPLES_PIPE is not set # CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_PPPD is not set # CONFIG_EXAMPLES_RGBLED is not set @@ -1055,7 +1054,6 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_MB is not set # CONFIG_NSH_DISABLE_MKDIR is not set # CONFIG_NSH_DISABLE_MKFATFS is not set -# CONFIG_NSH_DISABLE_MKFIFO is not set # CONFIG_NSH_DISABLE_MKRD is not set # CONFIG_NSH_DISABLE_MH is not set # CONFIG_NSH_DISABLE_MOUNT is not set diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 7a44fc835f5..9611cee2269 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -251,6 +251,7 @@ CONFIG_KINETIS_PORTEINTS=y # # Kinetis UART Configuration # +# CONFIG_KINETIS_UARTFIFOS is not set CONFIG_SDIO_DMA=y # CONFIG_SDIO_WIDTH_D1_ONLY is not set @@ -455,6 +456,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -747,7 +749,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # # CONFIG_EXAMPLES_CHAT is not set # CONFIG_EXAMPLES_CONFIGDATA is not set -# CONFIG_EXAMPLES_CPUHOG is not set # CONFIG_EXAMPLES_DHCPD is not set # CONFIG_EXAMPLES_ELF is not set # CONFIG_EXAMPLES_FSTEST is not set @@ -774,7 +775,6 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NXTEXT is not set # CONFIG_EXAMPLES_OSTEST is not set # CONFIG_EXAMPLES_PCA9635 is not set -# CONFIG_EXAMPLES_PIPE is not set # CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_PPPD is not set # CONFIG_EXAMPLES_RGBLED is not set @@ -885,7 +885,6 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_MB is not set # CONFIG_NSH_DISABLE_MKDIR is not set # CONFIG_NSH_DISABLE_MKFATFS is not set -# CONFIG_NSH_DISABLE_MKFIFO is not set # CONFIG_NSH_DISABLE_MKRD is not set # CONFIG_NSH_DISABLE_MH is not set # CONFIG_NSH_DISABLE_MOUNT is not set From a7de34b88d2afcd40653e92ee8da36df10dca938 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 14:21:27 -0600 Subject: [PATCH 102/152] Update some configurations. Make sure that CONFIG_PIPES is set in configuratins that need it. --- configs/ez80f910200zco/poll/defconfig | 9 +++++++-- configs/ntosd-dm320/poll/defconfig | 20 +++++++++++++++++--- configs/sam4s-xplained-pro/nsh/defconfig | 22 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/configs/ez80f910200zco/poll/defconfig b/configs/ez80f910200zco/poll/defconfig index 1c2faa9bce2..f6ed6625456 100644 --- a/configs/ez80f910200zco/poll/defconfig +++ b/configs/ez80f910200zco/poll/defconfig @@ -325,6 +325,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=1024 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -417,7 +418,10 @@ CONFIG_ETH0_PHY_AM79C874=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -470,6 +474,7 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set # CONFIG_HAVE_USBTRACE is not set @@ -732,10 +737,10 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_EXAMPLES_NRF24L01TERM is not set # CONFIG_EXAMPLES_NSH is not set # CONFIG_EXAMPLES_NULL is not set -# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXFFS is not set # CONFIG_EXAMPLES_NXHELLO is not set # CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXLINES is not set # CONFIG_EXAMPLES_NXTERM is not set # CONFIG_EXAMPLES_NXTEXT is not set diff --git a/configs/ntosd-dm320/poll/defconfig b/configs/ntosd-dm320/poll/defconfig index 45e393b8e1f..83e3ba302ba 100644 --- a/configs/ntosd-dm320/poll/defconfig +++ b/configs/ntosd-dm320/poll/defconfig @@ -219,6 +219,7 @@ CONFIG_ARCH_HAVE_LEDS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -323,6 +324,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=4096 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -351,7 +353,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -403,7 +410,10 @@ CONFIG_DM9X_MODE_AUTO=y # CONFIG_NET_SLIP is not set # CONFIG_NET_FTMAC100 is not set # CONFIG_NET_VNET is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -472,8 +482,10 @@ CONFIG_UART1_2STOP=0 # CONFIG_UART1_IFLOWCONTROL is not set # CONFIG_UART1_OFLOWCONTROL is not set # CONFIG_UART1_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -488,6 +500,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -693,6 +706,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -732,10 +746,10 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_EXAMPLES_NRF24L01TERM is not set # CONFIG_EXAMPLES_NSH is not set # CONFIG_EXAMPLES_NULL is not set -# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXFFS is not set # CONFIG_EXAMPLES_NXHELLO is not set # CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXLINES is not set # CONFIG_EXAMPLES_NXTERM is not set # CONFIG_EXAMPLES_NXTEXT is not set @@ -832,7 +846,7 @@ CONFIG_NETUTILS_NETLIB=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/sam4s-xplained-pro/nsh/defconfig b/configs/sam4s-xplained-pro/nsh/defconfig index 9e87745c51b..f46df931273 100644 --- a/configs/sam4s-xplained-pro/nsh/defconfig +++ b/configs/sam4s-xplained-pro/nsh/defconfig @@ -364,8 +364,6 @@ CONFIG_ARCH_LEDS=y CONFIG_ARCH_HAVE_BUTTONS=y # CONFIG_ARCH_BUTTONS is not set CONFIG_ARCH_HAVE_IRQBUTTONS=y -CONFIG_NSH_MMCSDMINOR=0 -CONFIG_NSH_MMCSDSLOTNO=0 # # Board-Specific Options @@ -373,6 +371,7 @@ CONFIG_NSH_MMCSDSLOTNO=0 CONFIG_SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR=0 CONFIG_SAM4S_XPLAINED_PRO_SCHED_TIMER_DEVPATH="/dev/rtt0" CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH="/dev/tc0" +# CONFIG_BOARD_CRASHDUMP is not set CONFIG_LIB_BOARDCTL=y # CONFIG_BOARDCTL_RESET is not set # CONFIG_BOARDCTL_UNIQUEID is not set @@ -498,6 +497,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=4096 CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y CONFIG_DEV_ZERO=y +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -534,7 +534,12 @@ CONFIG_WATCHDOG_DEVPATH="/dev/watchdog0" # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -565,6 +570,9 @@ CONFIG_SDIO_BLOCKSETUP=y # CONFIG_MTD is not set # CONFIG_EEPROM is not set CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -646,6 +654,7 @@ CONFIG_USART1_2STOP=0 # CONFIG_USART1_IFLOWCONTROL is not set # CONFIG_USART1_OFLOWCONTROL is not set # CONFIG_USART1_DMA is not set +# CONFIG_PSEUDOTERM is not set CONFIG_USBDEV=y # @@ -688,6 +697,7 @@ CONFIG_CDCACM_VENDORSTR="NuttX" CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial" # CONFIG_USBMSC is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -702,6 +712,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -830,6 +841,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -885,10 +897,10 @@ CONFIG_EXAMPLES_CPUHOG_PRIORITY=50 CONFIG_EXAMPLES_NSH=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y # CONFIG_EXAMPLES_NULL is not set -# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXFFS is not set # CONFIG_EXAMPLES_NXHELLO is not set # CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXLINES is not set # CONFIG_EXAMPLES_NXTERM is not set # CONFIG_EXAMPLES_NXTEXT is not set @@ -1038,6 +1050,8 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_USLEEP is not set # CONFIG_NSH_DISABLE_WGET is not set # CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 # # Configure Command Options @@ -1082,7 +1096,7 @@ CONFIG_NSH_ARCHINIT=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set From bfc664af4997dac7ff5ac9bbbdd701ce5274f33c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 15:26:54 -0600 Subject: [PATCH 103/152] Fix pipe2() and mkfifo2() syscall logic --- include/sys/syscall.h | 43 +++++++++++++++++++++++------------- syscall/syscall_lookup.h | 10 +++++++-- syscall/syscall_stublookup.c | 7 +++--- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 9868c3477b9..6123c6822ab 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -292,24 +292,37 @@ # define SYS_dup2 (__SYS_filedesc+2) # define SYS_fcntl (__SYS_filedesc+3) # define SYS_lseek (__SYS_filedesc+4) -# define SYS_mkfifo2 (__SYS_filedesc+5) -# define SYS_mmap (__SYS_filedesc+6) -# define SYS_open (__SYS_filedesc+7) -# define SYS_opendir (__SYS_filedesc+8) -# define SYS_pipe2 (__SYS_filedesc+9) -# define SYS_readdir (__SYS_filedesc+10) -# define SYS_rewinddir (__SYS_filedesc+11) -# define SYS_seekdir (__SYS_filedesc+12) -# define SYS_stat (__SYS_filedesc+13) -# define SYS_statfs (__SYS_filedesc+14) -# define SYS_telldir (__SYS_filedesc+15) +# define SYS_mmap (__SYS_filedesc+5) +# define SYS_open (__SYS_filedesc+6) +# define SYS_opendir (__SYS_filedesc+7) +# define SYS_readdir (__SYS_filedesc+8) +# define SYS_rewinddir (__SYS_filedesc+9) +# define SYS_seekdir (__SYS_filedesc+10) +# define SYS_stat (__SYS_filedesc+11) +# define SYS_statfs (__SYS_filedesc+12) +# define SYS_telldir (__SYS_filedesc+13) + +# if defined(CONFIG_PIPES) && ONFIG_DEV_PIPE_SIZE > 0 +# define SYS_pipe2 (__SYS_filedesc+14) +# define __SYS_mkfifo2 (__SYS_filedesc+15) +# else +# define __SYS_mkfifo2 (__SYS_filedesc+14) +# endif + +# if defined(CONFIG_PIPES) && ONFIG_DEV_FIFO_SIZE > 0 +# define SYS_mkfifo2 (__SYS_mkfifo2+0) +# define __SYS_fs_fdopen (__SYS_mkfifo2+1) +# else +# define __SYS_fs_fdopen (__SYS_mkfifo2+0) +# endif +# endif # if CONFIG_NFILE_STREAMS > 0 -# define SYS_fs_fdopen (__SYS_filedesc+16) -# define SYS_sched_getstreams (__SYS_filedesc+17) -# define __SYS_sendfile (__SYS_filedesc+18) +# define SYS_fs_fdopen (__SYS_fs_fdopen+0) +# define SYS_sched_getstreams (__SYS_fs_fdopen+1) +# define __SYS_sendfile (__SYS_fs_fdopen+2) # else -# define __SYS_sendfile (__SYS_filedesc+16) +# define __SYS_sendfile (__SYS_fs_fdopen+0) # endif # if defined(CONFIG_NET_SENDFILE) diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index 881f8063a13..5a6742d6a77 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -208,11 +208,9 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(dup2, 2, STUB_dup2) SYSCALL_LOOKUP(fcntl, 6, STUB_fcntl) SYSCALL_LOOKUP(lseek, 3, STUB_lseek) - SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) SYSCALL_LOOKUP(mmap, 6, STUB_mmap) SYSCALL_LOOKUP(open, 6, STUB_open) SYSCALL_LOOKUP(opendir, 1, STUB_opendir) - SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) SYSCALL_LOOKUP(readdir, 1, STUB_readdir) SYSCALL_LOOKUP(rewinddir, 1, STUB_rewinddir) SYSCALL_LOOKUP(seekdir, 2, STUB_seekdir) @@ -220,6 +218,14 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(statfs, 2, STUB_statfs) SYSCALL_LOOKUP(telldir, 1, STUB_telldir) +# if defined(CONFIG_PIPES) && ONFIG_DEV_PIPE_SIZE > 0 + SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) +# endif + +# if defined(CONFIG_PIPES) && ONFIG_DEV_FIFO_SIZE > 0 + SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) +# endif + # if CONFIG_NFILE_STREAMS > 0 SYSCALL_LOOKUP(fdopen, 3, STUB_fs_fdopen) SYSCALL_LOOKUP(sched_getstreams, 0, STUB_sched_getstreams) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 17800fa1b7c..298ecc1a8e7 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -214,8 +214,6 @@ uintptr_t STUB_fcntl(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm6); uintptr_t STUB_lseek(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); -uintptr_t STUB_mkfifo2(int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3); uintptr_t STUB_mmap(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); @@ -223,7 +221,6 @@ uintptr_t STUB_open(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); uintptr_t STUB_opendir(int nbr, uintptr_t parm1); -uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_readdir(int nbr, uintptr_t parm1); uintptr_t STUB_rewinddir(int nbr, uintptr_t parm1); uintptr_t STUB_seekdir(int nbr, uintptr_t parm1, uintptr_t parm2); @@ -231,6 +228,10 @@ uintptr_t STUB_stat(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_statfs(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_telldir(int nbr, uintptr_t parm1); +uintptr_t STUB_mkfifo2(int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3); +uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2); + uintptr_t STUB_fs_fdopen(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); uintptr_t STUB_sched_getstreams(int nbr); From 321886261645e11608ad9e10aadd4a9bee8d4f21 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 15:32:56 -0600 Subject: [PATCH 104/152] Fix some backward conditional compilation --- include/sys/syscall.h | 1 - syscall/syscall_lookup.h | 4 ++-- syscall/syscall_stublookup.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 6123c6822ab..e3f0a78e513 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -315,7 +315,6 @@ # else # define __SYS_fs_fdopen (__SYS_mkfifo2+0) # endif -# endif # if CONFIG_NFILE_STREAMS > 0 # define SYS_fs_fdopen (__SYS_fs_fdopen+0) diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index 5a6742d6a77..d625f7e19a6 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -219,11 +219,11 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(telldir, 1, STUB_telldir) # if defined(CONFIG_PIPES) && ONFIG_DEV_PIPE_SIZE > 0 - SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) + SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) # endif # if defined(CONFIG_PIPES) && ONFIG_DEV_FIFO_SIZE > 0 - SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) + SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) # endif # if CONFIG_NFILE_STREAMS > 0 diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 298ecc1a8e7..a5cace0e37c 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -228,9 +228,9 @@ uintptr_t STUB_stat(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_statfs(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_telldir(int nbr, uintptr_t parm1); +uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_mkfifo2(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); -uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_fs_fdopen(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); From cf1d0e3222c00efaf0c842347de25f0261a36d37 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 15:34:53 -0600 Subject: [PATCH 105/152] Grrr.. more errors in same conditional compilation --- include/sys/syscall.h | 4 ++-- syscall/syscall_lookup.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sys/syscall.h b/include/sys/syscall.h index e3f0a78e513..5f36242b619 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -302,14 +302,14 @@ # define SYS_statfs (__SYS_filedesc+12) # define SYS_telldir (__SYS_filedesc+13) -# if defined(CONFIG_PIPES) && ONFIG_DEV_PIPE_SIZE > 0 +# if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 # define SYS_pipe2 (__SYS_filedesc+14) # define __SYS_mkfifo2 (__SYS_filedesc+15) # else # define __SYS_mkfifo2 (__SYS_filedesc+14) # endif -# if defined(CONFIG_PIPES) && ONFIG_DEV_FIFO_SIZE > 0 +# if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 # define SYS_mkfifo2 (__SYS_mkfifo2+0) # define __SYS_fs_fdopen (__SYS_mkfifo2+1) # else diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index d625f7e19a6..58602a19ace 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -218,11 +218,11 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(statfs, 2, STUB_statfs) SYSCALL_LOOKUP(telldir, 1, STUB_telldir) -# if defined(CONFIG_PIPES) && ONFIG_DEV_PIPE_SIZE > 0 +# if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2) # endif -# if defined(CONFIG_PIPES) && ONFIG_DEV_FIFO_SIZE > 0 +# if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 SYSCALL_LOOKUP(mkfifo2, 3, STUB_mkfifo2) # endif From 0d98507af1202e3b9c3ed6495576a721a497d679 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 16:47:23 -0600 Subject: [PATCH 106/152] Eliminate a warning --- arch/arm/src/lpc43xx/lpc43_allocateheap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/arch/arm/src/lpc43xx/lpc43_allocateheap.c index 84b918051fe..ad5ca8c9cd3 100644 --- a/arch/arm/src/lpc43xx/lpc43_allocateheap.c +++ b/arch/arm/src/lpc43xx/lpc43_allocateheap.c @@ -324,20 +324,22 @@ */ const uint32_t g_idle_topstack = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; -static uint32_t mem_region_next = 0; +static uint32_t g_mem_region_next = 0; /**************************************************************************** * Private Functions ****************************************************************************/ +#if CONFIG_MM_REGIONS > 1 static void mem_addregion(FAR void *region_start, size_t region_size) { - if (mem_region_next <= CONFIG_MM_REGIONS) + if (g_mem_region_next <= CONFIG_MM_REGIONS) { kmm_addregion(region_start, region_size); - mem_region_next++; + g_mem_region_next++; } } +#endif /**************************************************************************** * Public Functions @@ -379,11 +381,9 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { -#if CONFIG_MM_REGIONS > 1 - /* start from second region */ - mem_region_next = 2; + g_mem_region_next = 2; # ifdef MM_USE_LOCSRAM_BANK1 mem_addregion((FAR void *)LPC43_LOCSRAM_BANK1_BASE, LPC43_LOCSRAM_BANK1_SIZE); @@ -416,7 +416,5 @@ void up_addregion(void) # ifdef MM_USE_EXTSDRAM3 mem_addregion((FAR void *)MM_EXTSDRAM3_REGION, MM_EXTSDRAM3_SIZE); # endif - -#endif /* CONFIG_MM_REGIONS > 1 */ } #endif From e88eb85ded8c2612afda3ed23f6af421d53e9831 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 17:01:33 -0600 Subject: [PATCH 107/152] Update README --- configs/freedom-k64f/README.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index d57f740e086..c991cfb7b3d 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -894,18 +894,41 @@ Where is one of the following: 2. Default platform/toolchain: - CONFIG_HOST_WINDOWS=y : Cygwin under Windows - CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) - CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary + CONFIG_HOST_WINDOWS=y : Cygwin under Windows + CONFIG_WINDOWS_CYGWIN=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART0 with the correct pin configuration for use with the OpenSDAv2 VCOM. This can be switched to use a RS-232 shield on UART3 by reconfiguring the serial console. + -CONFIG_KINETIS_UART0=y + +CONFIG_KINETIS_UART3=y + -CONFIG_UART0_SERIALDRIVER=y + +CONFIG_UART3_SERIALDRIVER=y + -CONFIG_UART0_SERIAL_CONSOLE=y + +CONFIG_UART3_SERIAL_CONSOLE=y + -CONFIG_UART0_RXBUFSIZE=256 + +CONFIG_UART3_RXBUFSIZE=256 + -CONFIG_UART0_TXBUFSIZE=256 + +CONFIG_UART3_TXBUFSIZE=256 + -CONFIG_UART0_BAUD=115200 + +CONFIG_UART3_BAUD=115200 + -CONFIG_UART0_BITS=8 + +CONFIG_UART3_BITS=8 + -CONFIG_UART0_PARITY=0 + +CONFIG_UART3_PARITY=0 + -CONFIG_UART0_2STOP=0 + +CONFIG_UART3_2STOP=0 + NOTE: On my Windows 10 / Cygwin64 system, the OpenSDAv2 VCOM is not recognized. I probably need to install a driver? + There is a serial USB driver on the mbed web site. However, this + driver would not install on Windows 10 for me. I understand that + it installs OK on Windows 7. + 4. Support for NSH built-in applications is enabled, but no built-in applications have been configured in. From e2dad79301946728ce11da6b22548a36921c7a64 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 17:25:39 -0600 Subject: [PATCH 108/152] All THTTPD configurations need to select CONFIG_PIPES --- configs/eagle100/thttpd/defconfig | 18 ++++++++++++++++-- configs/lincoln60/thttpd-binfs/defconfig | 18 ++++++++++++++++-- configs/lpcxpresso-lpc1768/thttpd/defconfig | 18 ++++++++++++++++-- configs/ntosd-dm320/thttpd/defconfig | 18 ++++++++++++++++-- configs/olimex-lpc1766stk/slip-httpd/defconfig | 18 ++++++++++++++++-- .../olimex-lpc1766stk/thttpd-binfs/defconfig | 18 ++++++++++++++++-- .../olimex-lpc1766stk/thttpd-nxflat/defconfig | 18 ++++++++++++++++-- configs/shenzhou/thttpd/defconfig | 11 +++++++---- configs/zkit-arm-1769/thttpd/defconfig | 18 ++++++++++++++++-- 9 files changed, 135 insertions(+), 20 deletions(-) diff --git a/configs/eagle100/thttpd/defconfig b/configs/eagle100/thttpd/defconfig index da9c32d88ca..509f67357f7 100644 --- a/configs/eagle100/thttpd/defconfig +++ b/configs/eagle100/thttpd/defconfig @@ -331,6 +331,7 @@ CONFIG_ARCH_LEDS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -428,6 +429,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -456,7 +458,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -496,7 +503,10 @@ CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y # CONFIG_NET_SLIP is not set # CONFIG_NET_FTMAC100 is not set # CONFIG_NET_VNET is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -549,8 +559,10 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -565,6 +577,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -779,6 +792,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -954,7 +968,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/lincoln60/thttpd-binfs/defconfig b/configs/lincoln60/thttpd-binfs/defconfig index 41f2b819096..a7588e40572 100644 --- a/configs/lincoln60/thttpd-binfs/defconfig +++ b/configs/lincoln60/thttpd-binfs/defconfig @@ -316,6 +316,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -418,6 +419,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -446,7 +448,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -505,7 +512,10 @@ CONFIG_ETH0_PHY_KSZ8041=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -558,8 +568,10 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -574,6 +586,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -792,6 +805,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -971,7 +985,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/lpcxpresso-lpc1768/thttpd/defconfig b/configs/lpcxpresso-lpc1768/thttpd/defconfig index dc17b59f8ba..25372fc67ef 100644 --- a/configs/lpcxpresso-lpc1768/thttpd/defconfig +++ b/configs/lpcxpresso-lpc1768/thttpd/defconfig @@ -308,6 +308,7 @@ CONFIG_ARCH_LEDS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -410,6 +411,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -438,7 +440,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -497,7 +504,10 @@ CONFIG_ETH0_PHY_LAN8720=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -550,8 +560,10 @@ CONFIG_UART3_2STOP=0 # CONFIG_UART3_IFLOWCONTROL is not set # CONFIG_UART3_OFLOWCONTROL is not set # CONFIG_UART3_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -566,6 +578,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -780,6 +793,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -955,7 +969,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/ntosd-dm320/thttpd/defconfig b/configs/ntosd-dm320/thttpd/defconfig index e17efe6802f..456f6d2a370 100644 --- a/configs/ntosd-dm320/thttpd/defconfig +++ b/configs/ntosd-dm320/thttpd/defconfig @@ -219,6 +219,7 @@ CONFIG_ARCH_HAVE_LEDS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -316,6 +317,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=4096 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -344,7 +346,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -396,7 +403,10 @@ CONFIG_DM9X_MODE_AUTO=y # CONFIG_NET_SLIP is not set # CONFIG_NET_FTMAC100 is not set # CONFIG_NET_VNET is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -465,8 +475,10 @@ CONFIG_UART1_2STOP=0 # CONFIG_UART1_IFLOWCONTROL is not set # CONFIG_UART1_OFLOWCONTROL is not set # CONFIG_UART1_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -481,6 +493,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -696,6 +709,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -872,7 +886,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/olimex-lpc1766stk/slip-httpd/defconfig b/configs/olimex-lpc1766stk/slip-httpd/defconfig index 6033db7243b..9be7d7c1b45 100644 --- a/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -299,6 +299,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -396,6 +397,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -424,7 +426,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -445,7 +452,10 @@ CONFIG_DEV_NULL=y # CONFIG_EEPROM is not set # CONFIG_NETDEVICES is not set CONFIG_NET_SLIP=y -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -514,8 +524,10 @@ CONFIG_UART1_2STOP=0 # CONFIG_UART1_IFLOWCONTROL is not set # CONFIG_UART1_OFLOWCONTROL is not set # CONFIG_UART1_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -530,6 +542,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -742,6 +755,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -917,7 +931,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig index bf7ea997727..75db6d6d1a3 100644 --- a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig @@ -316,6 +316,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -418,6 +419,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -446,7 +448,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -505,7 +512,10 @@ CONFIG_ETH0_PHY_KS8721=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -558,8 +568,10 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -574,6 +586,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -789,6 +802,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -968,7 +982,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig index f53e7d5f4a8..5fb4e9d369e 100644 --- a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig @@ -309,6 +309,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -411,6 +412,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -439,7 +441,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -498,7 +505,10 @@ CONFIG_ETH0_PHY_KS8721=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -551,8 +561,10 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -567,6 +579,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -781,6 +794,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -956,7 +970,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set diff --git a/configs/shenzhou/thttpd/defconfig b/configs/shenzhou/thttpd/defconfig index 4c36758aa3d..7bfc514586d 100644 --- a/configs/shenzhou/thttpd/defconfig +++ b/configs/shenzhou/thttpd/defconfig @@ -333,7 +333,7 @@ CONFIG_STM32_HAVE_TIM4=y CONFIG_STM32_HAVE_TIM5=y CONFIG_STM32_HAVE_TIM6=y CONFIG_STM32_HAVE_TIM7=y -CONFIG_STM32_HAVE_TIM8=y +# CONFIG_STM32_HAVE_TIM8 is not set # CONFIG_STM32_HAVE_TIM9 is not set # CONFIG_STM32_HAVE_TIM10 is not set # CONFIG_STM32_HAVE_TIM11 is not set @@ -389,7 +389,6 @@ CONFIG_STM32_SPI1=y # CONFIG_STM32_TIM5 is not set # CONFIG_STM32_TIM6 is not set # CONFIG_STM32_TIM7 is not set -# CONFIG_STM32_TIM8 is not set # CONFIG_STM32_USART1 is not set CONFIG_STM32_USART2=y # CONFIG_STM32_USART3 is not set @@ -423,7 +422,6 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y # CONFIG_STM32_TIM3_CAP is not set # CONFIG_STM32_TIM4_CAP is not set # CONFIG_STM32_TIM5_CAP is not set -# CONFIG_STM32_TIM8_CAP is not set CONFIG_STM32_USART=y CONFIG_STM32_SERIALDRIVER=y @@ -689,6 +687,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -832,7 +831,10 @@ CONFIG_TELNET_TXBUFFER_SIZE=256 # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set CONFIG_ETH0_PHY_DM9161=y -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -887,6 +889,7 @@ CONFIG_USART2_2STOP=0 # CONFIG_USART2_IFLOWCONTROL is not set # CONFIG_USART2_OFLOWCONTROL is not set # CONFIG_USART2_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set # CONFIG_HAVE_USBTRACE is not set diff --git a/configs/zkit-arm-1769/thttpd/defconfig b/configs/zkit-arm-1769/thttpd/defconfig index 21283879063..3b8d9a613a6 100644 --- a/configs/zkit-arm-1769/thttpd/defconfig +++ b/configs/zkit-arm-1769/thttpd/defconfig @@ -309,6 +309,7 @@ CONFIG_ARCH_LEDS=y # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_LIB_BOARDCTL is not set # @@ -411,6 +412,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048 # CONFIG_DISABLE_POLL is not set CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -439,7 +441,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -498,7 +505,10 @@ CONFIG_ETH0_PHY_DP83848C=y # CONFIG_ETH0_PHY_LAN8740A is not set # CONFIG_ETH0_PHY_LAN8742A is not set # CONFIG_ETH0_PHY_DM9161 is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set @@ -551,8 +561,10 @@ CONFIG_UART0_2STOP=0 # CONFIG_UART0_IFLOWCONTROL is not set # CONFIG_UART0_OFLOWCONTROL is not set # CONFIG_UART0_DMA is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # @@ -567,6 +579,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -781,6 +794,7 @@ CONFIG_ARCH_HAVE_TLS=y # CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -956,7 +970,7 @@ CONFIG_THTTPD_TILDE_MAP_NONE=y # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_RAMTEST is not set From 2803acbe06c54ffb496a40517eb0ef88ff4f6402 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 20 Jul 2016 17:28:39 -0600 Subject: [PATCH 109/152] All configurations with CONFIG_NET_LOCAL=y need to select CONFIG_PIPES --- configs/sim/udgram/defconfig | 46 ++++++++++++++++++++++++----------- configs/sim/ustream/defconfig | 46 ++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 28 deletions(-) diff --git a/configs/sim/udgram/defconfig b/configs/sim/udgram/defconfig index 7ed422934d7..51558d5c523 100644 --- a/configs/sim/udgram/defconfig +++ b/configs/sim/udgram/defconfig @@ -42,9 +42,10 @@ CONFIG_BUILD_FLAT=y # # Debug Options # +# CONFIG_DEBUG_ALERT is not set # CONFIG_DEBUG_FEATURES is not set -# CONFIG_ARCH_HAVE_HEAPCHECK is not set # CONFIG_ARCH_HAVE_STACKCHECK is not set +# CONFIG_ARCH_HAVE_HEAPCHECK is not set CONFIG_DEBUG_SYMBOLS=y # CONFIG_ARCH_HAVE_CUSTOMOPT is not set CONFIG_DEBUG_NOOPT=y @@ -78,6 +79,7 @@ CONFIG_SIM_NET_HOST_ROUTE=y # CONFIG_SIM_NET_BRIDGE is not set # CONFIG_SIM_FRAMEBUFFER is not set # CONFIG_SIM_SPIFLASH is not set +# CONFIG_SIM_QSPIFLASH is not set # # Architecture Options @@ -142,11 +144,11 @@ CONFIG_ARCH_BOARD="sim" # # Common Board Options # -CONFIG_NSH_MMCSDMINOR=0 # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set CONFIG_LIB_BOARDCTL=y # CONFIG_BOARDCTL_POWEROFF is not set # CONFIG_BOARDCTL_UNIQUEID is not set @@ -270,6 +272,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=8192 CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -298,7 +301,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -311,19 +319,25 @@ CONFIG_DEV_NULL=y # # CONFIG_RGBLED is not set # CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set # CONFIG_MMCSD is not set # CONFIG_MODEM is not set # CONFIG_MTD is not set # CONFIG_EEPROM is not set # CONFIG_NETDEVICES is not set # CONFIG_NET_SLIP is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set # CONFIG_SERCOMM_CONSOLE is not set CONFIG_SERIAL=y # CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y # CONFIG_16550_UART is not set # CONFIG_UART_SERIALDRIVER is not set # CONFIG_UART0_SERIALDRIVER is not set @@ -353,19 +367,25 @@ CONFIG_SERIAL=y # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set # CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set -# -# System Logging Device Options -# - # # System Logging # +# CONFIG_ARCH_SYSLOG is not set # CONFIG_RAMLOG is not set -# CONFIG_CONSOLE_SYSLOG is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -499,11 +519,6 @@ CONFIG_FS_PROCFS=y # CONFIG_FS_UNIONFS is not set # CONFIG_FS_HOSTFS is not set -# -# System Logging -# -# CONFIG_SYSLOG_TIMESTAMP is not set - # # Graphics Support # @@ -583,8 +598,10 @@ CONFIG_LIBC_NETDB=y # # Non-standard Library Support # +# CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -786,6 +803,7 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_USLEEP is not set # CONFIG_NSH_DISABLE_WGET is not set # CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 # # Configure Command Options @@ -852,7 +870,7 @@ CONFIG_NSH_MAX_ROUNDTRIP=20 # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_NETDB is not set diff --git a/configs/sim/ustream/defconfig b/configs/sim/ustream/defconfig index 38338722ee7..1e339f236e2 100644 --- a/configs/sim/ustream/defconfig +++ b/configs/sim/ustream/defconfig @@ -42,9 +42,10 @@ CONFIG_BUILD_FLAT=y # # Debug Options # +# CONFIG_DEBUG_ALERT is not set # CONFIG_DEBUG_FEATURES is not set -# CONFIG_ARCH_HAVE_HEAPCHECK is not set # CONFIG_ARCH_HAVE_STACKCHECK is not set +# CONFIG_ARCH_HAVE_HEAPCHECK is not set CONFIG_DEBUG_SYMBOLS=y # CONFIG_ARCH_HAVE_CUSTOMOPT is not set CONFIG_DEBUG_NOOPT=y @@ -78,6 +79,7 @@ CONFIG_SIM_NET_HOST_ROUTE=y # CONFIG_SIM_NET_BRIDGE is not set # CONFIG_SIM_FRAMEBUFFER is not set # CONFIG_SIM_SPIFLASH is not set +# CONFIG_SIM_QSPIFLASH is not set # # Architecture Options @@ -142,11 +144,11 @@ CONFIG_ARCH_BOARD="sim" # # Common Board Options # -CONFIG_NSH_MMCSDMINOR=0 # # Board-Specific Options # +# CONFIG_BOARD_CRASHDUMP is not set CONFIG_LIB_BOARDCTL=y # CONFIG_BOARDCTL_POWEROFF is not set # CONFIG_BOARDCTL_UNIQUEID is not set @@ -270,6 +272,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=8192 CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set # CONFIG_DEV_LOOP is not set # @@ -298,7 +301,12 @@ CONFIG_DEV_NULL=y # CONFIG_VIDEO_DEVICES is not set # CONFIG_BCH is not set # CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# # CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set # # LCD Driver Support @@ -311,19 +319,25 @@ CONFIG_DEV_NULL=y # # CONFIG_RGBLED is not set # CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set # CONFIG_MMCSD is not set # CONFIG_MODEM is not set # CONFIG_MTD is not set # CONFIG_EEPROM is not set # CONFIG_NETDEVICES is not set # CONFIG_NET_SLIP is not set -# CONFIG_PIPES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=1024 +CONFIG_DEV_FIFO_SIZE=1024 # CONFIG_PM is not set # CONFIG_POWER is not set # CONFIG_SENSORS is not set # CONFIG_SERCOMM_CONSOLE is not set CONFIG_SERIAL=y # CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y # CONFIG_16550_UART is not set # CONFIG_UART_SERIALDRIVER is not set # CONFIG_UART0_SERIALDRIVER is not set @@ -353,19 +367,25 @@ CONFIG_SERIAL=y # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set # CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set +# CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set -# -# System Logging Device Options -# - # # System Logging # +# CONFIG_ARCH_SYSLOG is not set # CONFIG_RAMLOG is not set -# CONFIG_CONSOLE_SYSLOG is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -499,11 +519,6 @@ CONFIG_FS_PROCFS=y # CONFIG_FS_UNIONFS is not set # CONFIG_FS_HOSTFS is not set -# -# System Logging -# -# CONFIG_SYSLOG_TIMESTAMP is not set - # # Graphics Support # @@ -583,8 +598,10 @@ CONFIG_LIBC_NETDB=y # # Non-standard Library Support # +# CONFIG_LIB_CRC64_FAST is not set # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set # # Basic CXX Support @@ -781,6 +798,7 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_USLEEP is not set # CONFIG_NSH_DISABLE_WGET is not set # CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 # # Configure Command Options @@ -847,7 +865,7 @@ CONFIG_NSH_MAX_ROUNDTRIP=20 # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FREE is not set -# CONFIG_LIB_HEX2BIN is not set +# CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_NETDB is not set From 96d5b734a841d793a0b82f213f0b72767ad5abe6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 08:01:59 -0600 Subject: [PATCH 110/152] Add missing TWI definitions --- arch/arm/src/sam34/chip/sam3x_memorymap.h | 1 + arch/arm/src/sam34/chip/sam4cm_memorymap.h | 4 ++++ arch/arm/src/sam34/chip/sam4e_memorymap.h | 1 + arch/arm/src/sam34/chip/sam4l_memorymap.h | 3 +++ arch/arm/src/sam34/chip/sam4s_memorymap.h | 1 + arch/arm/src/sam34/chip/sam_twi.h | 4 ++++ 6 files changed, 14 insertions(+) diff --git a/arch/arm/src/sam34/chip/sam3x_memorymap.h b/arch/arm/src/sam34/chip/sam3x_memorymap.h index e32e6ec226e..ba053d3c353 100644 --- a/arch/arm/src/sam34/chip/sam3x_memorymap.h +++ b/arch/arm/src/sam34/chip/sam3x_memorymap.h @@ -91,6 +91,7 @@ # define SAM_TC8_BASE 0x40088080 /* 0x40088080-0x400880bf: Timer Counter 5 */ /* 0x400880c0-0x4008ffff Reserved */ #define SAM_TWI_BASE 0x4008c000 /* 0x4008c000-0x4001ffff: Two-Wire Interface */ +# define SAM_TWIN_BASE(n) (SAM_TWI_BASE + ((n) << 14)) # define SAM_TWI0_BASE 0x4008c000 /* 0x4008c000-0x4008ffff: Two-Wire Interface 0 */ # define SAM_TWI1_BASE 0x40090000 /* 0x40090000-0x40093fff: Two-Wire Interface 1 */ #define SAM_PWM_BASE 0x40094000 /* 0x40020000-0x4003ffff: Pulse Width Modulation */ diff --git a/arch/arm/src/sam34/chip/sam4cm_memorymap.h b/arch/arm/src/sam34/chip/sam4cm_memorymap.h index 15505238845..c0b2de041b8 100644 --- a/arch/arm/src/sam34/chip/sam4cm_memorymap.h +++ b/arch/arm/src/sam34/chip/sam4cm_memorymap.h @@ -77,8 +77,12 @@ #define SAM_TC3_BASE 0x40014000 #define SAM_TC4_BASE 0x40014040 #define SAM_TC5_BASE 0x40014080 + +#define SAM_TWI_BASE 0x40018000 +#define SAM_TWIN_BASE(n) (SAM_TWI_BASE + ((n) << 14)) #define SAM_TWI0_BASE 0x40018000 #define SAM_TWI1_BASE 0x4001C000 + #define SAM_USART0_BASE 0x40024000 #define SAM_USART1_BASE 0x40028000 #define SAM_USART2_BASE 0x4002C000 diff --git a/arch/arm/src/sam34/chip/sam4e_memorymap.h b/arch/arm/src/sam34/chip/sam4e_memorymap.h index 95bfdef2eb7..1cf95993996 100644 --- a/arch/arm/src/sam34/chip/sam4e_memorymap.h +++ b/arch/arm/src/sam34/chip/sam4e_memorymap.h @@ -108,6 +108,7 @@ # define SAM_USART0_BASE 0x400a0000 /* 0x400a0000-0x400a3fff: USART0 */ # define SAM_USART1_BASE 0x400a4000 /* 0x400a4000-0x400abfff: USART1 */ #define SAM_TWI_BASE 0x400a8000 /* 0x400a8000-0x400affff: Two-Wire Interface */ +# define SAM_TWIN_BASE(n) (SAM_TWI_BASE + ((n) << 14)) # define SAM_TWI0_BASE 0x400a8000 /* 0x400a8000-0x400abfff: Two-Wire Interface 0 */ # define SAM_TWI1_BASE 0x400ac000 /* 0x400ac000-0x400affff: Two-Wire Interface 1 */ #define SAM_AFEC_BASE 0x400b0000 /* 0x400b0000-0x400b7fff: Analog Front End */ diff --git a/arch/arm/src/sam34/chip/sam4l_memorymap.h b/arch/arm/src/sam34/chip/sam4l_memorymap.h index 56810fe442c..62a8c6a0c5c 100644 --- a/arch/arm/src/sam34/chip/sam4l_memorymap.h +++ b/arch/arm/src/sam34/chip/sam4l_memorymap.h @@ -82,6 +82,9 @@ /* 0x4000c000-0x4000ffff: Reserved */ #define SAM_TC0_BASE 0x40100000 /* 0x40100000-0x4013ffff: Timer Counter 0 */ #define SAM_TC1_BASE 0x40140000 /* 0x40180000-0x4017ffff: Timer Counter 1 */ + +#define SAM_TWIMS_BASE 0x40180000 /* 0x40180000-0x401fffff: Two-wire Master/Slave */ +#define SAM_TWIN_BASE(n) (SAM_TWIMS_BASE + ((n) << 14)) #define SAM_TWIMS0_BASE 0x40180000 /* 0x40180000-0x401bffff: Two-wire Master/Slave Interface 0 */ #define SAM_TWIMS1_BASE 0x401c0000 /* 0x401c0000-0x401fffff: Two-wire Master/Slave Interface 1 */ /* 0x40020000-0x40023fff: Reserved */ diff --git a/arch/arm/src/sam34/chip/sam4s_memorymap.h b/arch/arm/src/sam34/chip/sam4s_memorymap.h index 0ebf658866c..45e8a97a3f6 100644 --- a/arch/arm/src/sam34/chip/sam4s_memorymap.h +++ b/arch/arm/src/sam34/chip/sam4s_memorymap.h @@ -84,6 +84,7 @@ # define SAM_TC5_BASE 0x40014080 /* 0x40014080-0x400140bf: Timer Counter 5 */ #define SAM_TWI_BASE 0x40018000 /* 0x40018000-0x4001ffff: Two-Wire Interface */ +# define SAM_TWIN_BASE(n) (SAM_TWI_BASE + ((n) << 14)) # define SAM_TWI0_BASE 0x40018000 /* 0x40018000-0x4001bfff: Two-Wire Interface 0 */ # define SAM_TWI1_BASE 0x4001c000 /* 0x4001c000-0x4001ffff: Two-Wire Interface 1 */ #define SAM_PWM_BASE 0x40020000 /* 0x40020000-0x4003ffff: Pulse Width Modulation */ diff --git a/arch/arm/src/sam34/chip/sam_twi.h b/arch/arm/src/sam34/chip/sam_twi.h index 8ad5a0f8aeb..2f843dd07c3 100644 --- a/arch/arm/src/sam34/chip/sam_twi.h +++ b/arch/arm/src/sam34/chip/sam_twi.h @@ -143,6 +143,7 @@ #define TWI_MMR_MREAD (1 << 12) /* Bit 12: Master Read Direction */ #define TWI_MMR_DADR_SHIFT (16) /* Bits 16-22: Device Address */ #define TWI_MMR_DADR_MASK (0x7f << TWI_MMR_DADR_SHIFT) +# define TWI_MMR_DADR(n) ((uint32_t)(n) << TWI_MMR_DADR_SHIFT) /* TWI Slave Mode Register */ @@ -186,6 +187,9 @@ #define TWI_INT_RXBUFF (1 << 14) /* Bit 14: RX Buffer */ #define TWI_INT_TXBUFE (1 << 15) /* Bit 15: TX Buffer Empty */ +#define TWI_INT_ERRORS (0x00000340) +#define TWI_INT_ALL (0x0000ffff) + /* TWI Receive Holding Register */ #define TWI_RHR_RXDATA_SHIFT (0) /* Bits 0-7: Master or Slave Receive Holding Data */ From 10fff9011a6d379b255a42fa5d94f80b1c3300c4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 13:34:54 -0600 Subject: [PATCH 111/152] Move include/nuttx/configdata.h to include/nuttx/mtd/configdata.h --- configs/mikroe-stm32f4/src/stm32_appinit.c | 2 +- configs/same70-xplained/src/sam_at24config.c | 2 +- configs/samv71-xult/src/sam_at24config.c | 2 +- configs/stm32f429i-disco/src/stm32_appinit.c | 2 +- drivers/mtd/mtd_config.c | 2 +- drivers/serial/Kconfig | 2 +- include/nuttx/{ => mtd}/configdata.h | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) rename include/nuttx/{ => mtd}/configdata.h (96%) diff --git a/configs/mikroe-stm32f4/src/stm32_appinit.c b/configs/mikroe-stm32f4/src/stm32_appinit.c index 7d43cf72ed2..5cb5d176651 100644 --- a/configs/mikroe-stm32f4/src/stm32_appinit.c +++ b/configs/mikroe-stm32f4/src/stm32_appinit.c @@ -61,7 +61,7 @@ #ifdef CONFIG_MIKROE_FLASH_CONFIG_PART #ifdef CONFIG_PLATFORM_CONFIGDATA -# include +# include #endif #endif diff --git a/configs/same70-xplained/src/sam_at24config.c b/configs/same70-xplained/src/sam_at24config.c index 69d27a02ced..74eea58ee4c 100644 --- a/configs/same70-xplained/src/sam_at24config.c +++ b/configs/same70-xplained/src/sam_at24config.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include diff --git a/configs/samv71-xult/src/sam_at24config.c b/configs/samv71-xult/src/sam_at24config.c index 4a324ac07be..af13bf34fa5 100644 --- a/configs/samv71-xult/src/sam_at24config.c +++ b/configs/samv71-xult/src/sam_at24config.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include diff --git a/configs/stm32f429i-disco/src/stm32_appinit.c b/configs/stm32f429i-disco/src/stm32_appinit.c index 415884fa5bf..26b92f3e4cc 100644 --- a/configs/stm32f429i-disco/src/stm32_appinit.c +++ b/configs/stm32f429i-disco/src/stm32_appinit.c @@ -65,7 +65,7 @@ #ifdef CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART #ifdef CONFIG_PLATFORM_CONFIGDATA -# include +# include #endif #endif diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 6bfe0d7fc6f..35131461c65 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #ifdef CONFIG_MTD_CONFIG diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 5b61b2db904..53ef72c3cb5 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -2060,6 +2060,6 @@ config PSEUDOTERM_TXBUFSIZE int "Pseudo-Terminal Tx buffer size" default 256 ---help--- - Slave-to-master buffer size. Default: 256 + Slave-to-master pipe buffer size. Default: 256 endif # PSEUDOTERM diff --git a/include/nuttx/configdata.h b/include/nuttx/mtd/configdata.h similarity index 96% rename from include/nuttx/configdata.h rename to include/nuttx/mtd/configdata.h index 60539993aae..65965c61959 100644 --- a/include/nuttx/configdata.h +++ b/include/nuttx/mtd/configdata.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/configdata.h + * include/nuttx/mtd/configdata.h * * Copyright (C) 2013 Ken Pettit. All rights reserved. * Author: Ken Pettit @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_CONFIGDATA_H -#define __INCLUDE_NUTTX_CONFIGDATA_H +#ifndef __INCLUDE_NUTTX_MTD_CONFIGDATA_H +#define __INCLUDE_NUTTX_MTD_CONFIGDATA_H /* The configdata device details kernel level services for providing * application config data from kernel control objects, such as partitions @@ -133,4 +133,4 @@ int mtdconfig_register(FAR struct mtd_dev_s *mtd); } #endif -#endif /* __INCLUDE_NUTTX_CONFIGDATA_H */ +#endif /* __INCLUDE_NUTTX_MTD_CONFIGDATA_H */ From 72a45c82b700de41fa426a331e2ca83bc11cd77d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 13:42:18 -0600 Subject: [PATCH 112/152] Move include/nuttx/regex.h to include/nuttx/lib/regex.h --- fs/procfs/fs_procfs.c | 2 +- include/nuttx/{ => lib}/regex.h | 10 +++++----- libc/libc.csv | 2 +- libc/misc/lib_match.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename include/nuttx/{ => lib}/regex.h (93%) diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index b350809c970..4f9f2de5188 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -60,7 +60,7 @@ #include #include #include -#include +#include #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) diff --git a/include/nuttx/regex.h b/include/nuttx/lib/regex.h similarity index 93% rename from include/nuttx/regex.h rename to include/nuttx/lib/regex.h index e26eed91409..660058c6cc8 100644 --- a/include/nuttx/regex.h +++ b/include/nuttx/lib/regex.h @@ -1,8 +1,8 @@ /**************************************************************************** - * include/nuttx/regex.h + * include/nuttx/lib/regex.h * Non-standard, pattern-matching APIs available in lib/. * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -34,8 +34,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_REGEX_H -#define __INCLUDE_NUTTX_REGEX_H +#ifndef __INCLUDE_NUTTX_LIB_REGEX_H +#define __INCLUDE_NUTTX_LIB_REGEX_H /**************************************************************************** * Included Files @@ -80,4 +80,4 @@ int match(const char *pattern, const char *string); } #endif -#endif /* __INCLUDE_NUTTX_REGEX_H */ +#endif /* __INCLUDE_NUTTX_LIB_REGEX_H */ diff --git a/libc/libc.csv b/libc/libc.csv index 9a385a215b9..86bf8d126cb 100644 --- a/libc/libc.csv +++ b/libc/libc.csv @@ -64,7 +64,7 @@ "lib_dumpbuffer","debug.h","","void","FAR const char *","FAR const uint8_t *","unsigned int" "lio_listio","aio.h","defined(CONFIG_FS_AIO)","int","int","FAR struct aiocb *const []|FAR struct aiocb *const *","int","FAR struct sigevent *" "llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int" -"match","nuttx/regex.h","","int","const char *","const char *" +"match","nuttx/lib/regex.h","","int","const char *","const char *" "memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t" "memchr","string.h","","FAR void","FAR const void *","int c","size_t" "memcmp","string.h","","int","FAR const void *","FAR const void *","size_t" diff --git a/libc/misc/lib_match.c b/libc/misc/lib_match.c index 690d111a5c7..2b3085d6635 100644 --- a/libc/misc/lib_match.c +++ b/libc/misc/lib_match.c @@ -39,7 +39,7 @@ ****************************************************************************/ #include -#include +#include /**************************************************************************** * Private Functions From ea589e2d6c99015cb5dddf2fcf658e7916417ce3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 13:48:20 -0600 Subject: [PATCH 113/152] Move include/nuttx/stdarg.h to include/nuttx/lib/stdarg.h --- Kconfig | 4 ++-- Makefile.unix | 8 ++++---- include/nuttx/{ => lib}/stdarg.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) rename include/nuttx/{ => lib}/stdarg.h (92%) diff --git a/Kconfig b/Kconfig index c174c16e4cb..b030aee96e3 100644 --- a/Kconfig +++ b/Kconfig @@ -371,7 +371,7 @@ config ARCH_STDARG_H default n ---help--- There is also a redirecting version of stdarg.h in the source tree - as well. It also resides out-of-the-way at include/nuttx/stdarg.h. + as well. It also resides out-of-the-way at include/nuttx/lib/stdarg.h. This is because you should normally use your toolchain's stdarg.h file. But sometimes, your toolchain's stdarg.h file may have other header file dependencies and so may not be usable in the NuttX build @@ -379,7 +379,7 @@ config ARCH_STDARG_H specific stdarg.h header file at nuttx/arch//include/stdarg.h If ARCH_STDARG_H=y is defined, the top-level makefile will copy the - re-directing stdarg.h header file from include/nuttx/stdarg.h to + re-directing stdarg.h header file from include/nuttx/lib/stdarg.h to include/stdarg.h. So for the architectures that cannot use their toolchain's stdarg.h file, they can use this alternative by defining ARCH_STDARG_H=y and providing. If ARCH_STDARG_H, is not defined, then diff --git a/Makefile.unix b/Makefile.unix index a117f171fc1..6d509018b81 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -227,14 +227,14 @@ else include/float.h: endif -# Target used to copy include/nuttx/stdarg.h. If CONFIG_ARCH_STDARG_H is +# Target used to copy include/nuttx/lib/stdarg.h. If CONFIG_ARCH_STDARG_H is # defined, then there is an architecture specific stdarg.h header file -# that will be included indirectly from include/stdarg.h. But first, we +# that will be included indirectly from include/lib/stdarg.h. But first, we # have to copy stdarg.h from include/nuttx/. to include/. ifeq ($(CONFIG_ARCH_STDARG_H),y) -include/stdarg.h: include/nuttx/stdarg.h - $(Q) cp -f include/nuttx/stdarg.h include/stdarg.h +include/stdarg.h: include/nuttx/lib/stdarg.h + $(Q) cp -f include/nuttx/lib/stdarg.h include/stdarg.h else include/stdarg.h: endif diff --git a/include/nuttx/stdarg.h b/include/nuttx/lib/stdarg.h similarity index 92% rename from include/nuttx/stdarg.h rename to include/nuttx/lib/stdarg.h index 2bda8cbd617..6d0ef173daf 100644 --- a/include/nuttx/stdarg.h +++ b/include/nuttx/lib/stdarg.h @@ -1,7 +1,7 @@ /**************************************************************************** - * include/nuttx/stdarg.h + * include/nuttx/lib/stdarg.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_STDARG_H -#define __INCLUDE_NUTTX_STDARG_H +#ifndef __INCLUDE_NUTTX_LIB_STDARG_H +#define __INCLUDE_NUTTX_LIB_STDARG_H /**************************************************************************** * Included Files @@ -61,4 +61,4 @@ * Public Function Prototypes ****************************************************************************/ -#endif /* __INCLUDE_NUTTX_STDARG_H */ +#endif /* __INCLUDE_NUTTX_LIB_STDARG_H */ From a2035f7efd5eb13e3a4d1fb69487867b41d0bc89 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 13:51:28 -0600 Subject: [PATCH 114/152] Move include/nuttx/1wire.h to include/nuttx/drivers/1wire.h --- arch/arm/src/stm32/stm32_1wire.c | 2 +- include/nuttx/{ => drivers}/1wire.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename include/nuttx/{ => drivers}/1wire.h (97%) diff --git a/arch/arm/src/stm32/stm32_1wire.c b/arch/arm/src/stm32/stm32_1wire.c index 4c0fa6c0f77..d0afa9d8bba 100644 --- a/arch/arm/src/stm32/stm32_1wire.c +++ b/arch/arm/src/stm32/stm32_1wire.c @@ -54,9 +54,9 @@ #include #include -#include #include #include +#include #include diff --git a/include/nuttx/1wire.h b/include/nuttx/drivers/1wire.h similarity index 97% rename from include/nuttx/1wire.h rename to include/nuttx/drivers/1wire.h index 49786a32aa9..5f2974e89e6 100644 --- a/include/nuttx/1wire.h +++ b/include/nuttx/drivers/1wire.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/1wire.h + * include/nuttx/drivers/1wire.h * * Copyright (C) 2016 Aleksandr Vyhovanec. All rights reserved. * Author: Aleksandr Vyhovanec @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_1WIRE_H -#define __INCLUDE_NUTTX_1WIRE_H +#ifndef __INCLUDE_NUTTX_DRIVERS_1WIRE_H +#define __INCLUDE_NUTTX_DRIVERS_1WIRE_H /**************************************************************************** * Included Files @@ -163,4 +163,4 @@ struct onewire_dev_s * Public Functions ****************************************************************************/ -#endif /* __INCLUDE_NUTTX_1WIRE_H */ +#endif /* __INCLUDE_NUTTX_DRIVERS_1WIRE_H */ From 23a876ab9ce09834fd577f4ce9d7994ed4ff1c5f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 13:58:09 -0600 Subject: [PATCH 115/152] Move include/nuttx/math.h to include/nuttx/lib/math.h --- Kconfig | 4 ++-- Makefile.unix | 10 +++++----- README.txt | 4 ++-- drivers/audio/vs1053.c | 2 +- drivers/audio/wm8904.c | 2 +- include/nuttx/{ => lib}/math.h | 10 +++++----- libc/math/Kconfig | 5 +++-- 7 files changed, 19 insertions(+), 18 deletions(-) rename include/nuttx/{ => lib}/math.h (98%) diff --git a/Kconfig b/Kconfig index b030aee96e3..31f6f54629c 100644 --- a/Kconfig +++ b/Kconfig @@ -339,10 +339,10 @@ config ARCH_MATH_H default n ---help--- There is also a re-directing version of math.h in the source tree. - However, it resides out-of-the-way at include/nuttx/math.h because it + However, it resides out-of-the-way at include/nuttx/lib/math.h because it conflicts too often with the system math.h. If ARCH_MATH_H=y is defined, however, the top-level makefile will copy the redirecting - math.h header file from include/nuttx/math.h to include/math.h. math.h + math.h header file from include/nuttx/lib/math.h to include/math.h. math.h will then include the architecture-specific version of math.h that you must provide at nuttx/arch/>architecture/include/math.h. There - is a stub math.h header file located at include/nuttx/math.h. This stub + is a stub math.h header file located at include/nuttx/lib/math.h. This stub header file can be used to "redirect" the inclusion to an architecture- specific math.h header file. If you add an architecture specific math.h header file then you should also define CONFIG_ARCH_MATH_H=y in your NuttX Configuration file. If CONFIG_ARCH_MATH_H is selected, then the top-level Makefile will copy the stub math.h header file from - include/nuttx/math.h to include/math.h where it will become the system + include/nuttx/lib/math.h to include/math.h where it will become the system math.h header file. The stub math.h header file does nothing other than to include that architecture-specific math.h header file as the system math.h header file. diff --git a/drivers/audio/vs1053.c b/drivers/audio/vs1053.c index fd00b37444c..aa4eb861a79 100644 --- a/drivers/audio/vs1053.c +++ b/drivers/audio/vs1053.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include "vs1053.h" diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c index 2bd2502b8df..4489ae0f221 100644 --- a/drivers/audio/wm8904.c +++ b/drivers/audio/wm8904.c @@ -69,7 +69,7 @@ #include #include #include -#include +#include #include "wm8904.h" diff --git a/include/nuttx/math.h b/include/nuttx/lib/math.h similarity index 98% rename from include/nuttx/math.h rename to include/nuttx/lib/math.h index d6963a50137..108706c2b92 100644 --- a/include/nuttx/math.h +++ b/include/nuttx/lib/math.h @@ -1,7 +1,7 @@ /**************************************************************************** - * include/nuttx/math.h + * include/nuttx/lib/math.h * - * Copyright (C) 2009, 2012, 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012, 2014-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_MATH_H -#define __INCLUDE_NUTTX_MATH_H +#ifndef __INCLUDE_NUTTX_LIB_MATH_H +#define __INCLUDE_NUTTX_LIB_MATH_H /**************************************************************************** * Included Files @@ -406,4 +406,4 @@ long double truncl (long double x); #endif #endif /* CONFIG_LIBM */ -#endif /* __INCLUDE_NUTTX_MATH_H */ +#endif /* __INCLUDE_NUTTX_LIB_MATH_H */ diff --git a/libc/math/Kconfig b/libc/math/Kconfig index 6fb14ec2724..a3a859824e4 100644 --- a/libc/math/Kconfig +++ b/libc/math/Kconfig @@ -17,8 +17,9 @@ config LIBM Another possibility is that you have a custom, architecture-specific math libary and that the corresponding math.h file resides at arch//include/math.h. - The option is selected via ARCH_MATH_H. If ARCH_MATH_H is selected,then the include/nuttx/math.h - header file will be copied to include/math.h where it can be used by your applications. + The option is selected via ARCH_MATH_H. If ARCH_MATH_H is selected,then the + include/nuttx/libmath.h header file will be copied to include/math.h where it can + be used by your applications. If ARCH_MATH_H is not defined, then this option can be selected to build a generic, math library built into NuttX. This math library comes from the Rhombus OS and From 779d3f98ed09ff212c89ab86aa79f54f8ac86e61 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 14:00:15 -0600 Subject: [PATCH 116/152] Move include/nuttx/math32.h to include/nuttx/lib/math32.h --- include/nuttx/{ => lib}/math32.h | 8 ++++---- libc/misc/lib_uadd32x64.c | 2 +- libc/misc/lib_uadd64.c | 2 +- libc/misc/lib_umul32.c | 2 +- libc/misc/lib_umul32x64.c | 2 +- libc/misc/lib_umul64.c | 2 +- libc/misc/lib_usub64.c | 2 +- libc/misc/lib_usub64x32.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) rename include/nuttx/{ => lib}/math32.h (98%) diff --git a/include/nuttx/math32.h b/include/nuttx/lib/math32.h similarity index 98% rename from include/nuttx/math32.h rename to include/nuttx/lib/math32.h index 64e993d7905..ba70f3184d1 100644 --- a/include/nuttx/math32.h +++ b/include/nuttx/lib/math32.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/math32.h + * include/nuttx/lib/math32.h * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_MATH32_H -#define __INCLUDE_NUTTX_MATH32_H +#ifndef __INCLUDE_NUTTX_LIB_MATH32_H +#define __INCLUDE_NUTTX_LIB_MATH32_H /**************************************************************************** * Included Files @@ -238,4 +238,4 @@ void umul64(FAR const struct uint64_s *factor1, } #endif -#endif /* __INCLUDE_NUTTX_MATH32_H */ +#endif /* __INCLUDE_NUTTX_LIB_MATH32_H */ diff --git a/libc/misc/lib_uadd32x64.c b/libc/misc/lib_uadd32x64.c index 68800e55295..291a282d7c7 100644 --- a/libc/misc/lib_uadd32x64.c +++ b/libc/misc/lib_uadd32x64.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_uadd64.c b/libc/misc/lib_uadd64.c index c9e634d1eef..8d071687915 100644 --- a/libc/misc/lib_uadd64.c +++ b/libc/misc/lib_uadd64.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_umul32.c b/libc/misc/lib_umul32.c index b245e10ee05..27540c08efa 100644 --- a/libc/misc/lib_umul32.c +++ b/libc/misc/lib_umul32.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_umul32x64.c b/libc/misc/lib_umul32x64.c index ca37fa2ea8d..b7c4510f013 100644 --- a/libc/misc/lib_umul32x64.c +++ b/libc/misc/lib_umul32x64.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_umul64.c b/libc/misc/lib_umul64.c index d20612638ef..29cbd37a9e2 100644 --- a/libc/misc/lib_umul64.c +++ b/libc/misc/lib_umul64.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_usub64.c b/libc/misc/lib_usub64.c index 2a327245ece..49742ac27d8 100644 --- a/libc/misc/lib_usub64.c +++ b/libc/misc/lib_usub64.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/misc/lib_usub64x32.c b/libc/misc/lib_usub64x32.c index b691e5105fb..7bda326e2a2 100644 --- a/libc/misc/lib_usub64x32.c +++ b/libc/misc/lib_usub64x32.c @@ -37,7 +37,7 @@ * Included Files ****************************************************************************/ -#include +#include /**************************************************************************** * Public Functions From a2a47eb3343335574fe4c5791d35cec97088ce35 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 14:03:35 -0600 Subject: [PATCH 117/152] Move include/nuttx/float.h to include/nuttx/lib/float.h --- Makefile.unix | 4 ++-- include/nuttx/{ => lib}/float.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename include/nuttx/{ => lib}/float.h (96%) diff --git a/Makefile.unix b/Makefile.unix index a51ae6eab9d..bb249788974 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -221,8 +221,8 @@ endif # the settings in this float.h are actually correct for your platform! ifeq ($(CONFIG_ARCH_FLOAT_H),y) -include/float.h: include/nuttx/float.h - $(Q) cp -f include/nuttx/float.h include/float.h +include/float.h: include/nuttx/lib/float.h + $(Q) cp -f include/nuttx/lib/float.h include/float.h else include/float.h: endif diff --git a/include/nuttx/float.h b/include/nuttx/lib/float.h similarity index 96% rename from include/nuttx/float.h rename to include/nuttx/lib/float.h index a4d8945ee57..2ff2b4252c6 100644 --- a/include/nuttx/float.h +++ b/include/nuttx/lib/float.h @@ -1,7 +1,7 @@ /**************************************************************************** - * include/nuttx/float.h + * include/nuttx/lib/float.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Reference: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/float.h.html @@ -35,8 +35,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_FLOAT_H -#define __INCLUDE_NUTTX_FLOAT_H +#ifndef __INCLUDE_NUTTX_LIB_FLOAT_H +#define __INCLUDE_NUTTX_LIB_FLOAT_H /* TODO: These values could vary with architectures toolchains. This * logic should be move at least to the include/arch directory. @@ -222,4 +222,4 @@ # define LDBL_MIN DBL_MIN #endif -#endif /* __INCLUDE_NUTTX_FLOAT_H */ +#endif /* __INCLUDE_NUTTX_LIB_FLOAT_H */ From 7370d3171a7fb6b9496d2187489c2b3c7abd9c40 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 14:05:44 -0600 Subject: [PATCH 118/152] Move include/nuttx/lib.h to include/nuttx/lib/lib.h --- drivers/dev_urandom.c | 2 +- include/nuttx/{ => lib}/lib.h | 8 ++++---- libc/misc/lib_stream.c | 2 +- libc/stdlib/lib_rand.c | 2 +- libc/stdlib/lib_srand.c | 2 +- sched/group/group_leave.c | 2 +- sched/group/group_setupstreams.c | 2 +- sched/init/os_start.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) rename include/nuttx/{ => lib}/lib.h (96%) diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index 06f4038cc7e..4923544eae2 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include diff --git a/include/nuttx/lib.h b/include/nuttx/lib/lib.h similarity index 96% rename from include/nuttx/lib.h rename to include/nuttx/lib/lib.h index 24c1a8aec29..5a55af8046a 100644 --- a/include/nuttx/lib.h +++ b/include/nuttx/lib/lib.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/lib.h + * include/nuttx/lib/lib.h * Non-standard, internal APIs available in lib/. * * Copyright (C) 2007-2009, 2012-2014, 2016 Gregory Nutt. All rights reserved. @@ -34,8 +34,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_LIB_H -#define __INCLUDE_NUTTX_LIB_H +#ifndef __INCLUDE_NUTTX_LIB_LIB_H +#define __INCLUDE_NUTTX_LIB_LIB_H /**************************************************************************** * Included Files @@ -87,4 +87,4 @@ unsigned long nrand(unsigned long limit); #endif #endif /* __ASSEMBLY__ */ -#endif /* __INCLUDE_NUTTX_LIB_H */ +#endif /* __INCLUDE_NUTTX_LIB_LIB_H */ diff --git a/libc/misc/lib_stream.c b/libc/misc/lib_stream.c index bcf78389b09..276d40d5e2e 100644 --- a/libc/misc/lib_stream.c +++ b/libc/misc/lib_stream.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include "libc.h" diff --git a/libc/stdlib/lib_rand.c b/libc/stdlib/lib_rand.c index 440372fe72e..8de8c763d04 100644 --- a/libc/stdlib/lib_rand.c +++ b/libc/stdlib/lib_rand.c @@ -42,7 +42,7 @@ #include #include -#include +#include /**************************************************************************** * Public Functions diff --git a/libc/stdlib/lib_srand.c b/libc/stdlib/lib_srand.c index 0941fc8bd7d..a1c87f0d436 100644 --- a/libc/stdlib/lib_srand.c +++ b/libc/stdlib/lib_srand.c @@ -42,7 +42,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index 9c5cf0f50b0..7339e61cf0e 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include "environ/environ.h" #include "signal/signal.h" diff --git a/sched/group/group_setupstreams.c b/sched/group/group_setupstreams.c index 02df7b7b53e..63929de8e6f 100644 --- a/sched/group/group_setupstreams.c +++ b/sched/group/group_setupstreams.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include "group/group.h" diff --git a/sched/init/os_start.c b/sched/init/os_start.c index 1a65af1403c..54ef7b4a276 100644 --- a/sched/init/os_start.c +++ b/sched/init/os_start.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include From d5acc120a4d42715d5ddfa0de2da74b64b868afa Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 14:22:00 -0600 Subject: [PATCH 119/152] Kinetis K60: Fix some bad conditional compilation --- arch/arm/src/kinetis/chip/kinetis_k60memorymap.h | 4 ++-- arch/arm/src/kinetis/kinetis_clockconfig.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k60memorymap.h b/arch/arm/src/kinetis/chip/kinetis_k60memorymap.h index 8b00303ef7b..135da475536 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k60memorymap.h +++ b/arch/arm/src/kinetis/chip/kinetis_k60memorymap.h @@ -44,7 +44,7 @@ #include "chip.h" -#ifdef KINETIS_K64 +#ifdef KINETIS_K60 /************************************************************************************ * Pre-processor Definitions @@ -192,5 +192,5 @@ * Public Functions ************************************************************************************/ -#endif /* KINETIS_K64 */ +#endif /* KINETIS_K60 */ #endif /* __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_K60MEMORYMAP_H */ diff --git a/arch/arm/src/kinetis/kinetis_clockconfig.c b/arch/arm/src/kinetis/kinetis_clockconfig.c index 2f703ea96e7..7d3d6ecb22a 100644 --- a/arch/arm/src/kinetis/kinetis_clockconfig.c +++ b/arch/arm/src/kinetis/kinetis_clockconfig.c @@ -39,8 +39,6 @@ #include -#include - #include "up_arch.h" #include "kinetis.h" @@ -50,6 +48,8 @@ #include "chip/kinetis_llwu.h" #include "chip/kinetis_pinmux.h" +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ From 67900beaaa88e3ae497159a876a32006a828dafc Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 15:15:56 -0600 Subject: [PATCH 120/152] LP43 Heap: REALLY eliminate the warning this time --- arch/arm/src/lpc43xx/lpc43_allocateheap.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/arch/arm/src/lpc43xx/lpc43_allocateheap.c index ad5ca8c9cd3..beeb851f706 100644 --- a/arch/arm/src/lpc43xx/lpc43_allocateheap.c +++ b/arch/arm/src/lpc43xx/lpc43_allocateheap.c @@ -181,6 +181,7 @@ #undef MM_USE_EXTSDRAM1 #undef MM_USE_EXTSDRAM2 #undef MM_USE_EXTSDRAM3 +#undef MM_HAVE_REGION #ifndef CONFIG_LPC43_BOOT_SRAM @@ -305,6 +306,14 @@ # define MM_EXTSDRAM3_SIZE CONFIG_LPC43_EXTSDRAM3_SIZE #endif /* CONFIG_LPC43_EXTSDRAM3_SIZE */ +#if CONFIG_MM_REGIONS > 1 && \ + (defined(MM_USE_LOCSRAM_BANK1) || defined(MM_USE_AHBSRAM_BANK0) || \ + defined(MM_USE_AHBSRAM_BANK1) || defined(MM_USE_AHBSRAM_BANK2) || \ + defined(MM_USE_EXTSDRAM0) || defined(MM_USE_EXTSDRAM1) || \ + defined(MM_USE_EXTSDRAM2) || defined(MM_USE_EXTSDRAM3)) +# define MM_HAVE_REGION 1 +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -324,13 +333,16 @@ */ const uint32_t g_idle_topstack = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; + +#ifdef MM_HAVE_REGION static uint32_t g_mem_region_next = 0; +#endif /**************************************************************************** * Private Functions ****************************************************************************/ -#if CONFIG_MM_REGIONS > 1 +#ifdef MM_HAVE_REGION static void mem_addregion(FAR void *region_start, size_t region_size) { if (g_mem_region_next <= CONFIG_MM_REGIONS) @@ -381,6 +393,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { +#ifdef MM_HAVE_REGION /* start from second region */ g_mem_region_next = 2; @@ -416,5 +429,6 @@ void up_addregion(void) # ifdef MM_USE_EXTSDRAM3 mem_addregion((FAR void *)MM_EXTSDRAM3_REGION, MM_EXTSDRAM3_SIZE); # endif +#endif } #endif From 369c942605058106fdb84df6e145fb0311f48f7f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Jul 2016 15:18:27 -0600 Subject: [PATCH 121/152] uint8_t is big enough for global. Range of values only 2-10 --- arch/arm/src/lpc43xx/lpc43_allocateheap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/arch/arm/src/lpc43xx/lpc43_allocateheap.c index beeb851f706..b7a947b668f 100644 --- a/arch/arm/src/lpc43xx/lpc43_allocateheap.c +++ b/arch/arm/src/lpc43xx/lpc43_allocateheap.c @@ -335,7 +335,7 @@ const uint32_t g_idle_topstack = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; #ifdef MM_HAVE_REGION -static uint32_t g_mem_region_next = 0; +static uint8_t g_mem_region_next = 0; #endif /**************************************************************************** From 9a8c3572db864560a473d70f95b9159e57fd8707 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 07:47:59 -0600 Subject: [PATCH 122/152] serial.c: Fix a race condition noted by Stefan Kolb. Between the test if the TX buffer is full and entering a critical section, bytes may be removed from the TX buffer making the wait unnecessary. The unnecessary wait is an inefficiency, but not really a problem. But with USB CDC/ACM it can be a problem because the entire TX buffer may be emptied when we lose the race. If that happens that uart_putxmitchar() can hang waiting for data to be removed from an empty TX buffer. --- drivers/serial/serial.c | 51 ++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index c98867d6ff7..566cf834e6f 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -208,50 +208,75 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock) nexthead = 0; } - /* Loop until we are able to add the character to the TX buffer */ + /* Loop until we are able to add the character to the TX buffer. */ for (; ; ) { + /* Check if the TX buffer is full */ + if (nexthead != dev->xmit.tail) { + /* No.. not full. Add the character to the TX buffer and return. */ + dev->xmit.buffer[dev->xmit.head] = ch; dev->xmit.head = nexthead; return OK; } - /* The buffer is full and no data is available now. Should be block, - * waiting for the hardware to remove some data from the TX - * buffer? + /* The TX buffer is full. Should be block, waiting for the hardware + * to remove some data from the TX buffer? */ else if (oktoblock) { - /* Inform the interrupt level logic that we are waiting. This and - * the following steps must be atomic. + /* The following steps must be atomic with respect to serial + * interrupt handling. */ flags = enter_critical_section(); + /* Check again... In certain race conditions an interrupt may + * have occurred between the test at the top of the loop and + * entering the critical section and the TX buffer may no longer + * be full. + * + * NOTE: On certain devices, such as USB CDC/ACM, the entire TX + * buffer may have been emptied in this race condition. In that + * case, the logic would hang below waiting for space in the TX + * buffer without this test. + */ + + if (nexthead != dev->xmit.tail) + { + ret = OK; + } + #ifdef CONFIG_SERIAL_REMOVABLE /* Check if the removable device is no longer connected while we * have interrupts off. We do not want the transition to occur * as a race condition before we begin the wait. */ - if (dev->disconnected) + else if (dev->disconnected) { ret = -ENOTCONN; } - else #endif + else { - /* Wait for some characters to be sent from the buffer with - * the TX interrupt enabled. When the TX interrupt is - * enabled, uart_xmitchars should execute and remove some - * of the data from the TX buffer. - */ + /* Inform the interrupt level logic that we are waiting. */ dev->xmitwaiting = true; + + /* Wait for some characters to be sent from the buffer with + * the TX interrupt enabled. When the TX interrupt is enabled, + * uart_xmitchars() should execute and remove some of the data + * from the TX buffer. + * + * NOTE that interrupts will be re-enabled while we wait for + * the semaphore. + */ + #ifdef CONFIG_SERIAL_DMA uart_dmatxavail(dev); #endif From fd42f898f6173f8f2a2c44871344c8ca066dd409 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 11:02:51 -0600 Subject: [PATCH 123/152] libc: Add mkfifo() and pipe() to libc CSV file --- libc/libc.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc/libc.csv b/libc/libc.csv index 86bf8d126cb..7fbbf47e0ea 100644 --- a/libc/libc.csv +++ b/libc/libc.csv @@ -71,10 +71,12 @@ "memcpy","string.h","","FAR void","FAR void *","FAR const void *","size_t" "memmove","string.h","","FAR void","FAR void *","FAR const void *","size_t" "memset","string.h","","FAR void","FAR void *","int c","size_t" +"mkfifo","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t" "mktime","time.h","","time_t","const struct tm *" "ntohl","arpa/inet.h","","uint32_t","uint32_t" "ntohs","arpa/inet.h","","uint16_t","uint16_t" "perror","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","void","FAR const char *" +"pipe","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*" "printf","stdio.h","","int","const char *","..." "pthread_attr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *" "pthread_attr_getinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR int *" From 360efe03c1fd456e511aedbc456600c2b895e1cb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:18:30 -0600 Subject: [PATCH 124/152] Rename LP17xx version of CONFIG_GPIO_IRQ to CONFIG_LPC17_GPIOIRQ --- arch/arm/include/lpc17xx/lpc176x_irq.h | 2 +- arch/arm/include/lpc17xx/lpc178x_irq.h | 2 +- arch/arm/src/lpc17xx/Kconfig | 2 +- arch/arm/src/lpc17xx/Make.defs | 2 +- arch/arm/src/lpc17xx/lpc176x_gpio.c | 10 +++++----- arch/arm/src/lpc17xx/lpc178x_gpio.c | 10 +++++----- arch/arm/src/lpc17xx/lpc17_gpio.h | 8 ++++---- arch/arm/src/lpc17xx/lpc17_gpioint.c | 4 ++-- arch/arm/src/lpc17xx/lpc17_irq.c | 6 +++--- configs/lincoln60/include/board.h | 2 +- configs/lincoln60/netnsh/defconfig | 2 +- configs/lincoln60/nsh/defconfig | 2 +- configs/lincoln60/src/lpc17_buttons.c | 4 ++-- configs/lincoln60/thttpd-binfs/defconfig | 2 +- configs/lpcxpresso-lpc1768/dhcpd/defconfig | 2 +- configs/lpcxpresso-lpc1768/nsh/defconfig | 2 +- configs/lpcxpresso-lpc1768/nx/defconfig | 2 +- configs/lpcxpresso-lpc1768/src/lpcxpresso-lpc1768.h | 4 ++-- configs/lpcxpresso-lpc1768/thttpd/defconfig | 2 +- configs/lpcxpresso-lpc1768/usbmsc/defconfig | 2 +- configs/mbed/hidkbd/defconfig | 2 +- configs/mbed/nsh/defconfig | 2 +- configs/olimex-lpc1766stk/ftpc/defconfig | 2 +- configs/olimex-lpc1766stk/hidkbd/defconfig | 2 +- configs/olimex-lpc1766stk/hidmouse/defconfig | 2 +- configs/olimex-lpc1766stk/include/board.h | 2 +- configs/olimex-lpc1766stk/nettest/defconfig | 2 +- configs/olimex-lpc1766stk/nsh/defconfig | 2 +- configs/olimex-lpc1766stk/nx/defconfig | 2 +- configs/olimex-lpc1766stk/slip-httpd/defconfig | 2 +- configs/olimex-lpc1766stk/src/lpc17_buttons.c | 4 ++-- configs/olimex-lpc1766stk/src/lpc17_ssp.c | 4 ++-- configs/olimex-lpc1766stk/thttpd-binfs/defconfig | 2 +- configs/olimex-lpc1766stk/thttpd-nxflat/defconfig | 2 +- configs/olimex-lpc1766stk/usbmsc/defconfig | 2 +- configs/olimex-lpc1766stk/usbserial/defconfig | 2 +- configs/olimex-lpc1766stk/zmodem/defconfig | 2 +- configs/open1788/README.txt | 4 ++-- configs/open1788/include/board.h | 2 +- configs/open1788/knsh/defconfig | 2 +- configs/open1788/nsh/defconfig | 2 +- configs/open1788/nxlines/defconfig | 2 +- configs/open1788/src/lpc17_appinit.c | 2 +- configs/open1788/src/lpc17_buttons.c | 4 ++-- configs/open1788/src/lpc17_touchscreen.c | 4 ++-- configs/u-blox-c027/nsh/defconfig | 2 +- configs/u-blox-c027/src/u-blox-c027.h | 2 +- configs/zkit-arm-1769/hello/defconfig | 2 +- configs/zkit-arm-1769/include/board.h | 2 +- configs/zkit-arm-1769/nsh/defconfig | 2 +- configs/zkit-arm-1769/nxhello/defconfig | 2 +- configs/zkit-arm-1769/src/lpc17_buttons.c | 2 +- configs/zkit-arm-1769/src/zkit-arm-1769.h | 4 ++-- configs/zkit-arm-1769/thttpd/defconfig | 2 +- 54 files changed, 76 insertions(+), 76 deletions(-) diff --git a/arch/arm/include/lpc17xx/lpc176x_irq.h b/arch/arm/include/lpc17xx/lpc176x_irq.h index 248c5c47d66..b844b33d652 100644 --- a/arch/arm/include/lpc17xx/lpc176x_irq.h +++ b/arch/arm/include/lpc17xx/lpc176x_irq.h @@ -147,7 +147,7 @@ * 42 */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define LPC17_VALID_GPIOINT0 (0x7fff8ffful) /* GPIO port 0 interrupt set */ # define LPC17_VALID_GPIOINT2 (0x00003ffful) /* GPIO port 2 interrupt set */ diff --git a/arch/arm/include/lpc17xx/lpc178x_irq.h b/arch/arm/include/lpc17xx/lpc178x_irq.h index 76c74904528..52ed1731a5c 100644 --- a/arch/arm/include/lpc17xx/lpc178x_irq.h +++ b/arch/arm/include/lpc17xx/lpc178x_irq.h @@ -166,7 +166,7 @@ * 42 */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define LPC17_VALID_GPIOINT0 (0xfffffffful) /* GPIO port 0 interrupt set */ # define LPC17_VALID_GPIOINT2 (0xfffffffful) /* GPIO port 2 interrupt set */ diff --git a/arch/arm/src/lpc17xx/Kconfig b/arch/arm/src/lpc17xx/Kconfig index abfd205fedc..5038000d865 100644 --- a/arch/arm/src/lpc17xx/Kconfig +++ b/arch/arm/src/lpc17xx/Kconfig @@ -604,7 +604,7 @@ config LPC17_CAN_REGDEBUG endmenu -config GPIO_IRQ +config LPC17_GPIOIRQ bool "GPIO interrupt support" default n ---help--- diff --git a/arch/arm/src/lpc17xx/Make.defs b/arch/arm/src/lpc17xx/Make.defs index 919f70e7579..f1dd3cde114 100644 --- a/arch/arm/src/lpc17xx/Make.defs +++ b/arch/arm/src/lpc17xx/Make.defs @@ -133,7 +133,7 @@ ifeq ($(CONFIG_LPC17_EMC),y) CHIP_CSRCS += lpc17_emc.c endif -ifeq ($(CONFIG_GPIO_IRQ),y) +ifeq ($(CONFIG_LPC17_GPIOIRQ),y) CHIP_CSRCS += lpc17_gpioint.c endif diff --git a/arch/arm/src/lpc17xx/lpc176x_gpio.c b/arch/arm/src/lpc17xx/lpc176x_gpio.c index 7de2fd04bcc..b2b8e9805ab 100644 --- a/arch/arm/src/lpc17xx/lpc176x_gpio.c +++ b/arch/arm/src/lpc17xx/lpc176x_gpio.c @@ -78,7 +78,7 @@ * actually set up to interrupt until the interrupt is enabled. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ uint64_t g_intedge0; uint64_t g_intedge2; #endif @@ -300,7 +300,7 @@ static int lpc17_pullup(lpc17_pinset_t cfgset, unsigned int port, * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ static void lpc17_setintedge(unsigned int port, unsigned int pin, unsigned int value) { @@ -328,7 +328,7 @@ static void lpc17_setintedge(unsigned int port, unsigned int pin, *intedge &= ~((uint64_t)3 << shift); *intedge |= ((uint64_t)value << shift); } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_LPC17_GPIOIRQ */ /**************************************************************************** * Name: lpc17_setopendrain @@ -412,7 +412,7 @@ static inline int lpc17_configinput(lpc17_pinset_t cfgset, unsigned int port, un /* Forget about any falling/rising edge interrupt enabled */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ lpc17_setintedge(port, pin, 0); #endif } @@ -453,7 +453,7 @@ static inline int lpc17_configinterrupt(lpc17_pinset_t cfgset, unsigned int port /* Then just remember the rising/falling edge interrupt enabled */ DEBUGASSERT(port == 0 || port == 2); -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ lpc17_setintedge(port, pin, (cfgset & GPIO_EDGE_MASK) >> GPIO_EDGE_SHIFT); #endif return OK; diff --git a/arch/arm/src/lpc17xx/lpc178x_gpio.c b/arch/arm/src/lpc17xx/lpc178x_gpio.c index a30b7d42558..a6892d597f6 100644 --- a/arch/arm/src/lpc17xx/lpc178x_gpio.c +++ b/arch/arm/src/lpc17xx/lpc178x_gpio.c @@ -79,7 +79,7 @@ * actually set up to interrupt until the interrupt is enabled. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ uint64_t g_intedge0; uint64_t g_intedge2; #endif @@ -526,7 +526,7 @@ static void lpc17_setpullup(lpc17_pinset_t cfgset, unsigned int port, * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ static void lpc17_setintedge(unsigned int port, unsigned int pin, unsigned int value) { @@ -554,7 +554,7 @@ static void lpc17_setintedge(unsigned int port, unsigned int pin, *intedge &= ~((uint64_t)3 << shift); *intedge |= ((uint64_t)value << shift); } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_LPC17_GPIOIRQ */ /**************************************************************************** * Name: lpc17_configinput @@ -601,7 +601,7 @@ static inline int lpc17_configinput(lpc17_pinset_t cfgset, unsigned int port, /* Forget about any falling/rising edge interrupt enabled */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ lpc17_setintedge(port, pin, 0); #endif } @@ -656,7 +656,7 @@ static inline int lpc17_configinterrupt(lpc17_pinset_t cfgset, unsigned int port /* Then just remember the rising/falling edge interrupt enabled */ DEBUGASSERT(port == 0 || port == 2); -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ lpc17_setintedge(port, pin, (cfgset & GPIO_EDGE_MASK) >> GPIO_EDGE_SHIFT); #endif return OK; diff --git a/arch/arm/src/lpc17xx/lpc17_gpio.h b/arch/arm/src/lpc17xx/lpc17_gpio.h index 1129a26235d..6aab5b9f84c 100644 --- a/arch/arm/src/lpc17xx/lpc17_gpio.h +++ b/arch/arm/src/lpc17xx/lpc17_gpio.h @@ -89,7 +89,7 @@ extern "C" * lpc17_gpioint.c, and lpc17_gpiodbg.c */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ EXTERN uint64_t g_intedge0; EXTERN uint64_t g_intedge2; #endif @@ -109,7 +109,7 @@ EXTERN const uint32_t g_intbase[GPIO_NPORTS]; * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ void lpc17_gpioirqinitialize(void); #else # define lpc17_gpioirqinitialize() @@ -153,7 +153,7 @@ bool lpc17_gpioread(lpc17_pinset_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ void lpc17_gpioirqenable(int irq); #else # define lpc17_gpioirqenable(irq) @@ -167,7 +167,7 @@ void lpc17_gpioirqenable(int irq); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ void lpc17_gpioirqdisable(int irq); #else # define lpc17_gpioirqdisable(irq) diff --git a/arch/arm/src/lpc17xx/lpc17_gpioint.c b/arch/arm/src/lpc17xx/lpc17_gpioint.c index 46acb05e6fa..0c1ca613625 100644 --- a/arch/arm/src/lpc17xx/lpc17_gpioint.c +++ b/arch/arm/src/lpc17xx/lpc17_gpioint.c @@ -51,7 +51,7 @@ #include "chip.h" #include "lpc17_gpio.h" -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ /**************************************************************************** * Pre-processor Definitions @@ -543,4 +543,4 @@ void lpc17_gpioirqdisable(int irq) } } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_LPC17_GPIOIRQ */ diff --git a/arch/arm/src/lpc17xx/lpc17_irq.c b/arch/arm/src/lpc17xx/lpc17_irq.c index 44d149c7342..ac8fb8855cd 100644 --- a/arch/arm/src/lpc17xx/lpc17_irq.c +++ b/arch/arm/src/lpc17xx/lpc17_irq.c @@ -412,7 +412,7 @@ void up_irqinitialize(void) * GPIO pins. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ lpc17_gpioirqinitialize(); #endif @@ -456,7 +456,7 @@ void up_disable_irq(int irq) putreg32(regval, regaddr); } } -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ else if (irq >= LPC17_VALID_FIRST0L) { /* Maybe it is a (derived) GPIO IRQ */ @@ -501,7 +501,7 @@ void up_enable_irq(int irq) putreg32(regval, regaddr); } } -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ else if (irq >= LPC17_VALID_FIRST0L) { /* Maybe it is a (derived) GPIO IRQ */ diff --git a/configs/lincoln60/include/board.h b/configs/lincoln60/include/board.h index 3ac74c0659a..b22aa4de6d3 100644 --- a/configs/lincoln60/include/board.h +++ b/configs/lincoln60/include/board.h @@ -44,7 +44,7 @@ #include #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) # include #endif diff --git a/configs/lincoln60/netnsh/defconfig b/configs/lincoln60/netnsh/defconfig index eb4939104ca..4d5cabba012 100644 --- a/configs/lincoln60/netnsh/defconfig +++ b/configs/lincoln60/netnsh/defconfig @@ -152,7 +152,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lincoln60/nsh/defconfig b/configs/lincoln60/nsh/defconfig index 2b99c9a39e8..4b9b3f2e1bb 100644 --- a/configs/lincoln60/nsh/defconfig +++ b/configs/lincoln60/nsh/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lincoln60/src/lpc17_buttons.c b/configs/lincoln60/src/lpc17_buttons.c index 9018c2ea36c..ebcfc385c67 100644 --- a/configs/lincoln60/src/lpc17_buttons.c +++ b/configs/lincoln60/src/lpc17_buttons.c @@ -73,7 +73,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] = * button events. */ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS]; /* This array provides the mapping from button ID numbers to button IRQ @@ -178,7 +178,7 @@ uint8_t board_buttons(void) * ****************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) xcpt_t board_button_irq(int id, xcpt_t irqhandler) { xcpt_t oldhandler = NULL; diff --git a/configs/lincoln60/thttpd-binfs/defconfig b/configs/lincoln60/thttpd-binfs/defconfig index a7588e40572..babe05b6f3b 100644 --- a/configs/lincoln60/thttpd-binfs/defconfig +++ b/configs/lincoln60/thttpd-binfs/defconfig @@ -152,7 +152,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lpcxpresso-lpc1768/dhcpd/defconfig b/configs/lpcxpresso-lpc1768/dhcpd/defconfig index 5cb3db6d551..1bd6f34549b 100644 --- a/configs/lpcxpresso-lpc1768/dhcpd/defconfig +++ b/configs/lpcxpresso-lpc1768/dhcpd/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lpcxpresso-lpc1768/nsh/defconfig b/configs/lpcxpresso-lpc1768/nsh/defconfig index 873e93ae077..e28399a97a6 100644 --- a/configs/lpcxpresso-lpc1768/nsh/defconfig +++ b/configs/lpcxpresso-lpc1768/nsh/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lpcxpresso-lpc1768/nx/defconfig b/configs/lpcxpresso-lpc1768/nx/defconfig index b1e82a5645b..ad93523748a 100644 --- a/configs/lpcxpresso-lpc1768/nx/defconfig +++ b/configs/lpcxpresso-lpc1768/nx/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lpcxpresso-lpc1768/src/lpcxpresso-lpc1768.h b/configs/lpcxpresso-lpc1768/src/lpcxpresso-lpc1768.h index 6f31162233d..8b853a5df3c 100644 --- a/configs/lpcxpresso-lpc1768/src/lpcxpresso-lpc1768.h +++ b/configs/lpcxpresso-lpc1768/src/lpcxpresso-lpc1768.h @@ -147,7 +147,7 @@ */ #define LPCXPRESSO_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN2) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define LPCXPRESSO_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) #else # define LPCXPRESSO_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) @@ -183,7 +183,7 @@ */ #define LPCXPRESSO_USB_CONNECT (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN21) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define LPCXPRESSO_USB_VBUSSENSE (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN5) #else # define LPCXPRESSO_USB_VBUSSENSE (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN5) diff --git a/configs/lpcxpresso-lpc1768/thttpd/defconfig b/configs/lpcxpresso-lpc1768/thttpd/defconfig index 25372fc67ef..0fbcd2047d9 100644 --- a/configs/lpcxpresso-lpc1768/thttpd/defconfig +++ b/configs/lpcxpresso-lpc1768/thttpd/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/lpcxpresso-lpc1768/usbmsc/defconfig b/configs/lpcxpresso-lpc1768/usbmsc/defconfig index ed1b761bcb6..e553a9db14c 100644 --- a/configs/lpcxpresso-lpc1768/usbmsc/defconfig +++ b/configs/lpcxpresso-lpc1768/usbmsc/defconfig @@ -144,7 +144,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/mbed/hidkbd/defconfig b/configs/mbed/hidkbd/defconfig index 78b35bd634b..a45e4315cbb 100644 --- a/configs/mbed/hidkbd/defconfig +++ b/configs/mbed/hidkbd/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/mbed/nsh/defconfig b/configs/mbed/nsh/defconfig index 617dbe793bd..d5c241c67a8 100644 --- a/configs/mbed/nsh/defconfig +++ b/configs/mbed/nsh/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/ftpc/defconfig b/configs/olimex-lpc1766stk/ftpc/defconfig index 8fc1fe60108..337a9869c49 100644 --- a/configs/olimex-lpc1766stk/ftpc/defconfig +++ b/configs/olimex-lpc1766stk/ftpc/defconfig @@ -144,7 +144,7 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/hidkbd/defconfig b/configs/olimex-lpc1766stk/hidkbd/defconfig index f4dd6913b94..5142080c160 100644 --- a/configs/olimex-lpc1766stk/hidkbd/defconfig +++ b/configs/olimex-lpc1766stk/hidkbd/defconfig @@ -152,7 +152,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/hidmouse/defconfig b/configs/olimex-lpc1766stk/hidmouse/defconfig index 77d8930168f..bf6af4f1bb5 100644 --- a/configs/olimex-lpc1766stk/hidmouse/defconfig +++ b/configs/olimex-lpc1766stk/hidmouse/defconfig @@ -152,7 +152,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/include/board.h b/configs/olimex-lpc1766stk/include/board.h index c522b051dfc..e147bc7377b 100644 --- a/configs/olimex-lpc1766stk/include/board.h +++ b/configs/olimex-lpc1766stk/include/board.h @@ -45,7 +45,7 @@ #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) # include #endif diff --git a/configs/olimex-lpc1766stk/nettest/defconfig b/configs/olimex-lpc1766stk/nettest/defconfig index f53218ac1ca..9f0ac48d3c8 100644 --- a/configs/olimex-lpc1766stk/nettest/defconfig +++ b/configs/olimex-lpc1766stk/nettest/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/nsh/defconfig b/configs/olimex-lpc1766stk/nsh/defconfig index 7b565ed90cc..3138fafdd3a 100644 --- a/configs/olimex-lpc1766stk/nsh/defconfig +++ b/configs/olimex-lpc1766stk/nsh/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/nx/defconfig b/configs/olimex-lpc1766stk/nx/defconfig index f774a4d7cab..500331c8bcf 100644 --- a/configs/olimex-lpc1766stk/nx/defconfig +++ b/configs/olimex-lpc1766stk/nx/defconfig @@ -153,7 +153,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/slip-httpd/defconfig b/configs/olimex-lpc1766stk/slip-httpd/defconfig index 9be7d7c1b45..eaf0a647f7e 100644 --- a/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/src/lpc17_buttons.c b/configs/olimex-lpc1766stk/src/lpc17_buttons.c index b2f2d811ca3..888335f46bc 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_buttons.c +++ b/configs/olimex-lpc1766stk/src/lpc17_buttons.c @@ -74,7 +74,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] = * button events. */ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS]; /* This array provides the mapping from button ID numbers to button IRQ @@ -181,7 +181,7 @@ uint8_t board_buttons(void) * ****************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) xcpt_t board_button_irq(int id, xcpt_t irqhandler) { xcpt_t oldhandler = NULL; diff --git a/configs/olimex-lpc1766stk/src/lpc17_ssp.c b/configs/olimex-lpc1766stk/src/lpc17_ssp.c index 9bb9b563bb9..17df5733e0e 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_ssp.c +++ b/configs/olimex-lpc1766stk/src/lpc17_ssp.c @@ -66,8 +66,8 @@ #undef HAVE_SPI_CALLBACK #ifdef CONFIG_SPI_CALLBACK -# ifndef CONFIG_GPIO_IRQ -# warning "CONFIG_GPIO_IRQ is required to support CONFIG_SPI_CALLBACK" +# ifndef CONFIG_LPC17_GPIOIRQ +# warning "CONFIG_LPC17_GPIOIRQ is required to support CONFIG_SPI_CALLBACK" # else # define HAVE_SPI_CALLBACK 1 # endif diff --git a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig index 75db6d6d1a3..1f91e8ad669 100644 --- a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig @@ -152,7 +152,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig index 5fb4e9d369e..bb5f704d060 100644 --- a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/usbmsc/defconfig b/configs/olimex-lpc1766stk/usbmsc/defconfig index 2ddcb5ccbdf..00bd628aa85 100644 --- a/configs/olimex-lpc1766stk/usbmsc/defconfig +++ b/configs/olimex-lpc1766stk/usbmsc/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/usbserial/defconfig b/configs/olimex-lpc1766stk/usbserial/defconfig index 7010288b625..6ae07cce441 100644 --- a/configs/olimex-lpc1766stk/usbserial/defconfig +++ b/configs/olimex-lpc1766stk/usbserial/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/olimex-lpc1766stk/zmodem/defconfig b/configs/olimex-lpc1766stk/zmodem/defconfig index 3ea8b1c6471..14e768128ba 100644 --- a/configs/olimex-lpc1766stk/zmodem/defconfig +++ b/configs/olimex-lpc1766stk/zmodem/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/open1788/README.txt b/configs/open1788/README.txt index 8edd78ab132..b7419b33aad 100644 --- a/configs/open1788/README.txt +++ b/configs/open1788/README.txt @@ -422,7 +422,7 @@ CONFIGURATION CONFIG_SPI_EXCHANGE=n : exchange() method is not supported System Type: - CONFIG_GPIO_IRQ=y : GPIO interrupt support + CONFIG_LPC17_GPIOIRQ=y : GPIO interrupt support CONFIG_LPC17_SSP1=y : Enable support for SSP1 RTOS Features: @@ -472,7 +472,7 @@ CONFIGURATION information about the button test. System Type: - CONFIG_GPIO_IRQ=y + CONFIG_LPC17_GPIOIRQ=y Board Selection: CONFIG_ARCH_BUTTONS=y diff --git a/configs/open1788/include/board.h b/configs/open1788/include/board.h index c811ad4f660..11f47847cb0 100644 --- a/configs/open1788/include/board.h +++ b/configs/open1788/include/board.h @@ -45,7 +45,7 @@ #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) # include #endif diff --git a/configs/open1788/knsh/defconfig b/configs/open1788/knsh/defconfig index 73ef473d546..6adfc646868 100644 --- a/configs/open1788/knsh/defconfig +++ b/configs/open1788/knsh/defconfig @@ -151,7 +151,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/open1788/nsh/defconfig b/configs/open1788/nsh/defconfig index c7da461f8b2..82536e3b2f8 100644 --- a/configs/open1788/nsh/defconfig +++ b/configs/open1788/nsh/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/open1788/nxlines/defconfig b/configs/open1788/nxlines/defconfig index 3ba4b262f95..55a85e14f88 100644 --- a/configs/open1788/nxlines/defconfig +++ b/configs/open1788/nxlines/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/open1788/src/lpc17_appinit.c b/configs/open1788/src/lpc17_appinit.c index d1ccc94df21..d25f9bc2d18 100644 --- a/configs/open1788/src/lpc17_appinit.c +++ b/configs/open1788/src/lpc17_appinit.c @@ -104,7 +104,7 @@ #ifdef NSH_HAVE_MMCSD # ifdef CONFIG_MMCSD_HAVECARDDETECT # define NSH_HAVE_MMCSD_CD 1 -# ifdef CONFIG_GPIO_IRQ +# ifdef CONFIG_LPC17_GPIOIRQ # define NSH_HAVE_MMCSD_CDINT 1 # endif # endif diff --git a/configs/open1788/src/lpc17_buttons.c b/configs/open1788/src/lpc17_buttons.c index 4509e2fe598..5ad2814f1ac 100644 --- a/configs/open1788/src/lpc17_buttons.c +++ b/configs/open1788/src/lpc17_buttons.c @@ -93,7 +93,7 @@ static const lpc17_pinset_t g_buttoncfg[BOARD_NUM_BUTTONS] = * button events. */ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS]; /* This array provides the mapping from button ID numbers to button IRQ @@ -199,7 +199,7 @@ uint8_t board_buttons(void) * ****************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) xcpt_t board_button_irq(int id, xcpt_t irqhandler) { xcpt_t oldhandler = NULL; diff --git a/configs/open1788/src/lpc17_touchscreen.c b/configs/open1788/src/lpc17_touchscreen.c index 1d1af3ff8bc..008abc0660d 100644 --- a/configs/open1788/src/lpc17_touchscreen.c +++ b/configs/open1788/src/lpc17_touchscreen.c @@ -71,8 +71,8 @@ # error "Touchscreen support requires CONFIG_LPC17_SSP1" #endif -#ifndef CONFIG_GPIO_IRQ -# error "Touchscreen support requires CONFIG_GPIO_IRQ" +#ifndef CONFIG_LPC17_GPIOIRQ +# error "Touchscreen support requires CONFIG_LPC17_GPIOIRQ" #endif #ifndef CONFIG_ADS7843E_FREQUENCY diff --git a/configs/u-blox-c027/nsh/defconfig b/configs/u-blox-c027/nsh/defconfig index 644c1fc7b13..79f246bc6f8 100644 --- a/configs/u-blox-c027/nsh/defconfig +++ b/configs/u-blox-c027/nsh/defconfig @@ -144,7 +144,7 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/u-blox-c027/src/u-blox-c027.h b/configs/u-blox-c027/src/u-blox-c027.h index 577bf417905..6f2b8da990c 100644 --- a/configs/u-blox-c027/src/u-blox-c027.h +++ b/configs/u-blox-c027/src/u-blox-c027.h @@ -50,7 +50,7 @@ #define C027_LED (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT3 | GPIO_PIN25) #define C027_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN2) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define C027_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) #else # define C027_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) diff --git a/configs/zkit-arm-1769/hello/defconfig b/configs/zkit-arm-1769/hello/defconfig index 60e67adb456..a1607725f37 100644 --- a/configs/zkit-arm-1769/hello/defconfig +++ b/configs/zkit-arm-1769/hello/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/zkit-arm-1769/include/board.h b/configs/zkit-arm-1769/include/board.h index 544ce3d133e..5003145d522 100644 --- a/configs/zkit-arm-1769/include/board.h +++ b/configs/zkit-arm-1769/include/board.h @@ -50,7 +50,7 @@ #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ) # include #endif diff --git a/configs/zkit-arm-1769/nsh/defconfig b/configs/zkit-arm-1769/nsh/defconfig index dd6372c82cb..49c46598bbf 100644 --- a/configs/zkit-arm-1769/nsh/defconfig +++ b/configs/zkit-arm-1769/nsh/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/zkit-arm-1769/nxhello/defconfig b/configs/zkit-arm-1769/nxhello/defconfig index 4e3a8d38a1d..9e98eedc88d 100644 --- a/configs/zkit-arm-1769/nxhello/defconfig +++ b/configs/zkit-arm-1769/nxhello/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # diff --git a/configs/zkit-arm-1769/src/lpc17_buttons.c b/configs/zkit-arm-1769/src/lpc17_buttons.c index d33219c98d2..205473b2132 100644 --- a/configs/zkit-arm-1769/src/lpc17_buttons.c +++ b/configs/zkit-arm-1769/src/lpc17_buttons.c @@ -159,7 +159,7 @@ uint8_t board_buttons(void) * ************************************************************************************/ -#if defined CONFIG_ARCH_IRQBUTTONS && CONFIG_GPIO_IRQ +#if defined CONFIG_ARCH_IRQBUTTONS && CONFIG_LPC17_GPIOIRQ xcpt_t board_button_irq(int id, xcpt_t irqhandler) { xcpt_t rethandler = NULL; diff --git a/configs/zkit-arm-1769/src/zkit-arm-1769.h b/configs/zkit-arm-1769/src/zkit-arm-1769.h index 0b51e1f685c..84de2d3cb24 100644 --- a/configs/zkit-arm-1769/src/zkit-arm-1769.h +++ b/configs/zkit-arm-1769/src/zkit-arm-1769.h @@ -160,7 +160,7 @@ */ #define ZKITARM_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN16) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define ZKITARM_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN12) #else # define ZKITARM_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN12) @@ -182,7 +182,7 @@ */ #define ZKITARM_USB_CONNECT (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN9) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC17_GPIOIRQ # define ZKITARM_USB_VBUSSENSE (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN30) #else # define ZKITARM_USB_VBUSSENSE (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN30) diff --git a/configs/zkit-arm-1769/thttpd/defconfig b/configs/zkit-arm-1769/thttpd/defconfig index 3b8d9a613a6..b9829c43fee 100644 --- a/configs/zkit-arm-1769/thttpd/defconfig +++ b/configs/zkit-arm-1769/thttpd/defconfig @@ -145,7 +145,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARMV7M_HAVE_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC17_GPIOIRQ is not set # CONFIG_SERIAL_TERMIOS is not set # From 264578135d021dfc07e1a2edd2ec26a3e07fd742 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:23:31 -0600 Subject: [PATCH 125/152] Rename LP11xx version of CONFIG_GPIO_IRQ to CONFIG_LPC11_GPIOIRQ --- arch/arm/src/lpc11xx/Kconfig | 2 +- arch/arm/src/lpc11xx/Make.defs | 2 +- arch/arm/src/lpc11xx/lpc111x_gpio.c | 10 +++++----- arch/arm/src/lpc11xx/lpc11_gpio.h | 8 ++++---- arch/arm/src/lpc11xx/lpc11_gpioint.c | 4 ++-- arch/arm/src/lpc11xx/lpc11_irq.c | 2 +- configs/lpcxpresso-lpc1115/minnsh/defconfig | 2 +- configs/lpcxpresso-lpc1115/nsh/defconfig | 2 +- configs/lpcxpresso-lpc1115/src/lpcxpresso_lpc1115.h | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/arm/src/lpc11xx/Kconfig b/arch/arm/src/lpc11xx/Kconfig index 31a9711cf07..33ab254958b 100644 --- a/arch/arm/src/lpc11xx/Kconfig +++ b/arch/arm/src/lpc11xx/Kconfig @@ -237,7 +237,7 @@ config CAN_REGDEBUG endmenu -config GPIO_IRQ +config LPC11_GPIOIRQ bool "GPIO interrupt support" default n ---help--- diff --git a/arch/arm/src/lpc11xx/Make.defs b/arch/arm/src/lpc11xx/Make.defs index 041419c2488..a347d99946d 100644 --- a/arch/arm/src/lpc11xx/Make.defs +++ b/arch/arm/src/lpc11xx/Make.defs @@ -84,7 +84,7 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y) CHIP_CSRCS += lpc11_userspace.c endif -ifeq ($(CONFIG_GPIO_IRQ),y) +ifeq ($(CONFIG_LPC11_GPIOIRQ),y) CHIP_CSRCS += lpc11_gpioint.c endif diff --git a/arch/arm/src/lpc11xx/lpc111x_gpio.c b/arch/arm/src/lpc11xx/lpc111x_gpio.c index 6a0718e11d7..cba1ee71734 100644 --- a/arch/arm/src/lpc11xx/lpc111x_gpio.c +++ b/arch/arm/src/lpc11xx/lpc111x_gpio.c @@ -79,7 +79,7 @@ * actually set up to interrupt until the interrupt is enabled. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ uint64_t g_intedge0; uint64_t g_intedge2; #endif @@ -295,7 +295,7 @@ static int lpc11_pullup(lpc11_pinset_t cfgset, unsigned int port, * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ static void lpc11_setintedge(unsigned int port, unsigned int pin, unsigned int value) { @@ -323,7 +323,7 @@ static void lpc11_setintedge(unsigned int port, unsigned int pin, *intedge &= ~((uint64_t)3 << shift); *intedge |= ((uint64_t)value << shift); } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_LPC11_GPIOIRQ */ /**************************************************************************** * Name: lpc11_setopendrain @@ -453,7 +453,7 @@ static inline int lpc11_configinput(lpc11_pinset_t cfgset, unsigned int port, /* Forget about any falling/rising edge interrupt enabled */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ lpc11_setintedge(port, pin, 0); #endif } @@ -495,7 +495,7 @@ static inline int lpc11_configinterrupt(lpc11_pinset_t cfgset, unsigned int port /* Then just remember the rising/falling edge interrupt enabled */ DEBUGASSERT(port == 0 || port == 2); -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ lpc11_setintedge(port, pin, (cfgset & GPIO_EDGE_MASK) >> GPIO_EDGE_SHIFT); #endif return OK; diff --git a/arch/arm/src/lpc11xx/lpc11_gpio.h b/arch/arm/src/lpc11xx/lpc11_gpio.h index a0e1c2d8990..f77b748613e 100644 --- a/arch/arm/src/lpc11xx/lpc11_gpio.h +++ b/arch/arm/src/lpc11xx/lpc11_gpio.h @@ -88,7 +88,7 @@ extern "C" * lpc11_gpioint.c, and lpc11_gpiodbg.c */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ EXTERN uint64_t g_intedge0; EXTERN uint64_t g_intedge2; #endif @@ -108,7 +108,7 @@ EXTERN const uint32_t g_intbase[GPIO_NPORTS]; * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ void lpc11_gpioirqinitialize(void); #else # define lpc11_gpioirqinitialize() @@ -152,7 +152,7 @@ bool lpc11_gpioread(lpc11_pinset_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ void lpc11_gpioirqenable(int irq); #else # define lpc11_gpioirqenable(irq) @@ -166,7 +166,7 @@ void lpc11_gpioirqenable(int irq); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ void lpc11_gpioirqdisable(int irq); #else # define lpc11_gpioirqdisable(irq) diff --git a/arch/arm/src/lpc11xx/lpc11_gpioint.c b/arch/arm/src/lpc11xx/lpc11_gpioint.c index 4ce6b48c9ed..8aaefed1497 100644 --- a/arch/arm/src/lpc11xx/lpc11_gpioint.c +++ b/arch/arm/src/lpc11xx/lpc11_gpioint.c @@ -51,7 +51,7 @@ #include "chip.h" #include "lpc11_gpio.h" -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ /**************************************************************************** * Pre-processor Definitions @@ -543,5 +543,5 @@ void lpc11_gpioirqdisable(int irq) } } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_LPC11_GPIOIRQ */ diff --git a/arch/arm/src/lpc11xx/lpc11_irq.c b/arch/arm/src/lpc11xx/lpc11_irq.c index f861943bc0a..4399c582003 100644 --- a/arch/arm/src/lpc11xx/lpc11_irq.c +++ b/arch/arm/src/lpc11xx/lpc11_irq.c @@ -244,7 +244,7 @@ void up_irqinitialize(void) * configured pin interrupts. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ lpc11_gpioirqinitialize(); #endif diff --git a/configs/lpcxpresso-lpc1115/minnsh/defconfig b/configs/lpcxpresso-lpc1115/minnsh/defconfig index ea60c5f721e..edc83097727 100644 --- a/configs/lpcxpresso-lpc1115/minnsh/defconfig +++ b/configs/lpcxpresso-lpc1115/minnsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC11_GPIOIRQ is not set # # LPC11xx Configuration Options diff --git a/configs/lpcxpresso-lpc1115/nsh/defconfig b/configs/lpcxpresso-lpc1115/nsh/defconfig index 22a4a0c7dc9..c8b7d4b11c3 100644 --- a/configs/lpcxpresso-lpc1115/nsh/defconfig +++ b/configs/lpcxpresso-lpc1115/nsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_LPC11_GPIOIRQ is not set # # LPC11xx Configuration Options diff --git a/configs/lpcxpresso-lpc1115/src/lpcxpresso_lpc1115.h b/configs/lpcxpresso-lpc1115/src/lpcxpresso_lpc1115.h index 5f3db65ba63..4f523e26b29 100644 --- a/configs/lpcxpresso-lpc1115/src/lpcxpresso_lpc1115.h +++ b/configs/lpcxpresso-lpc1115/src/lpcxpresso_lpc1115.h @@ -147,7 +147,7 @@ */ #define LPCXPRESSO_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN2) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ # define LPCXPRESSO_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) #else # define LPCXPRESSO_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) @@ -183,7 +183,7 @@ */ #define LPCXPRESSO_USB_CONNECT (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN21) -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_LPC11_GPIOIRQ # define LPCXPRESSO_USB_VBUSSENSE (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN5) #else # define LPCXPRESSO_USB_VBUSSENSE (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN5) From 5386403476b610113a4478fea77a906951119a20 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:30:37 -0600 Subject: [PATCH 126/152] Rename Kinetis version of CONFIG_GPIO_IRQ to CONFIG_KINETIS_GPIOIRQ --- arch/arm/src/kinetis/Kconfig | 4 ++-- arch/arm/src/kinetis/Make.defs | 2 +- arch/arm/src/kinetis/kinetis.h | 6 +++--- arch/arm/src/kinetis/kinetis_irq.c | 2 +- arch/arm/src/kinetis/kinetis_pinirq.c | 4 ++-- configs/freedom-k64f/README.txt | 6 +++--- configs/freedom-k64f/netnsh/defconfig | 2 +- configs/freedom-k64f/nsh/defconfig | 2 +- configs/freedom-k64f/src/freedom-k64f.h | 4 ++-- configs/kwikstik-k40/README.txt | 2 +- configs/kwikstik-k40/ostest/defconfig | 2 +- configs/kwikstik-k40/src/k40_appinit.c | 4 ++-- configs/teensy-3.x/nsh/defconfig | 2 +- configs/teensy-3.x/usbnsh/defconfig | 2 +- configs/twr-k60n512/README.txt | 4 ++-- configs/twr-k60n512/nsh/defconfig | 2 +- configs/twr-k60n512/src/k60_appinit.c | 4 ++-- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index 4be634107b2..853de44c7db 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -483,12 +483,12 @@ config KINETIS_FTM2_CHANNEL menu "Kinetis GPIO Interrupt Configuration" -config GPIO_IRQ +config KINETIS_GPIOIRQ bool "GPIO pin interrupts" ---help--- Enable support for interrupting GPIO pins -if GPIO_IRQ +if KINETIS_GPIOIRQ config KINETIS_PORTAINTS bool "GPIOA interrupts" diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs index 662dd618737..9d4ea5083ab 100644 --- a/arch/arm/src/kinetis/Make.defs +++ b/arch/arm/src/kinetis/Make.defs @@ -103,7 +103,7 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y) CHIP_CSRCS += kinetis_userspace.c kinetis_mpuinit.c endif -ifeq ($(CONFIG_GPIO_IRQ),y) +ifeq ($(CONFIG_KINETIS_GPIOIRQ),y) CHIP_CSRCS += kinetis_pinirq.c endif diff --git a/arch/arm/src/kinetis/kinetis.h b/arch/arm/src/kinetis/kinetis.h index fccd4b90af7..bb02f01e92c 100644 --- a/arch/arm/src/kinetis/kinetis.h +++ b/arch/arm/src/kinetis/kinetis.h @@ -476,7 +476,7 @@ bool kinetis_gpioread(uint32_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KINETIS_GPIOIRQ void kinetis_pinirqinitialize(void); #else # define kinetis_pinirqinitialize() @@ -514,7 +514,7 @@ xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KINETIS_GPIOIRQ void kinetis_pinirqenable(uint32_t pinset); #else # define kinetis_pinirqenable(pinset) @@ -528,7 +528,7 @@ void kinetis_pinirqenable(uint32_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KINETIS_GPIOIRQ void kinetis_pinirqdisable(uint32_t pinset); #else # define kinetis_pinirqdisable(pinset) diff --git a/arch/arm/src/kinetis/kinetis_irq.c b/arch/arm/src/kinetis/kinetis_irq.c index d2a04de3ae6..a969bbacd7a 100644 --- a/arch/arm/src/kinetis/kinetis_irq.c +++ b/arch/arm/src/kinetis/kinetis_irq.c @@ -439,7 +439,7 @@ void up_irqinitialize(void) * configured pin interrupts. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KINETIS_GPIOIRQ kinetis_pinirqinitialize(); #endif diff --git a/arch/arm/src/kinetis/kinetis_pinirq.c b/arch/arm/src/kinetis/kinetis_pinirq.c index 919d51e67c9..cc5933e715a 100644 --- a/arch/arm/src/kinetis/kinetis_pinirq.c +++ b/arch/arm/src/kinetis/kinetis_pinirq.c @@ -52,7 +52,7 @@ #include "kinetis.h" #include "chip/kinetis_port.h" -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KINETIS_GPIOIRQ /**************************************************************************** * Pre-processor Definitions @@ -450,4 +450,4 @@ void kinetis_pinirqdisable(uint32_t pinset) } #endif /* HAVE_PORTINTS */ } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_KINETIS_GPIOIRQ */ diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index c991cfb7b3d..0b80b603d18 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -445,7 +445,7 @@ SD Card Support CONFIG_KINETIS_SDHC=y : To enable SDHC0 support System Type - CONFIG_GPIO_IRQ=y : GPIO interrupts needed + CONFIG_KINETIS_GPIOIRQ=y : GPIO interrupts needed CONFIG_KINETIS_PORTEINTS=y : Card detect pin is on PTE6 Device Drivers -> MMC/SD Driver Support @@ -784,7 +784,7 @@ Freedom K64F Configuration Options PIN Interrupt Support - CONFIG_GPIO_IRQ -- Enable pin interrupt support. Also needs + CONFIG_KINETIS_GPIOIRQ -- Enable pin interrupt support. Also needs one or more of the following: CONFIG_KINETIS_PORTAINTS -- Support 32 Port A interrupts CONFIG_KINETIS_PORTBINTS -- Support 32 Port B interrupts @@ -973,4 +973,4 @@ Status USB device, however, has not yet been tested. I have not yet looked into 48MHz clocking requirements. - \ No newline at end of file + diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index 03e1ec4e86f..5dc3f9d2d37 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -236,7 +236,7 @@ CONFIG_KINETIS_ENET=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +# CONFIG_KINETIS_GPIOIRQ is not set # # Kinetis Ethernet Configuration diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 9611cee2269..66503cfa66d 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -236,7 +236,7 @@ CONFIG_KINETIS_SDHC=y # # Kinetis GPIO Interrupt Configuration # -CONFIG_GPIO_IRQ=y +CONFIG_KINETIS_GPIOIRQ=y # CONFIG_KINETIS_PORTAINTS is not set # CONFIG_KINETIS_PORTBINTS is not set # CONFIG_KINETIS_PORTCINTS is not set diff --git a/configs/freedom-k64f/src/freedom-k64f.h b/configs/freedom-k64f/src/freedom-k64f.h index aac232930bd..0e0af54f967 100644 --- a/configs/freedom-k64f/src/freedom-k64f.h +++ b/configs/freedom-k64f/src/freedom-k64f.h @@ -100,8 +100,8 @@ /* We expect to receive GPIO interrupts for card insertion events */ -# ifndef CONFIG_GPIO_IRQ -# error "CONFIG_GPIO_IRQ required for card detect interrupt" +# ifndef CONFIG_KINETIS_GPIOIRQ +# error "CONFIG_KINETIS_GPIOIRQ required for card detect interrupt" # endif # ifndef CONFIG_KINETIS_PORTEINTS diff --git a/configs/kwikstik-k40/README.txt b/configs/kwikstik-k40/README.txt index 5d31bb232f5..9586a43c90c 100644 --- a/configs/kwikstik-k40/README.txt +++ b/configs/kwikstik-k40/README.txt @@ -461,7 +461,7 @@ KwikStik-K40-specific Configuration Options PIN Interrupt Support - CONFIG_GPIO_IRQ -- Enable pin interrupt support. Also needs + CONFIG_KINETIS_GPIOIRQ -- Enable pin interrupt support. Also needs one or more of the following: CONFIG_KINETIS_PORTAINTS -- Support 32 Port A interrupts CONFIG_KINETIS_PORTBINTS -- Support 32 Port B interrupts diff --git a/configs/kwikstik-k40/ostest/defconfig b/configs/kwikstik-k40/ostest/defconfig index befa76725dd..2582f887cd3 100644 --- a/configs/kwikstik-k40/ostest/defconfig +++ b/configs/kwikstik-k40/ostest/defconfig @@ -220,7 +220,7 @@ CONFIG_KINETIS_UART5=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +# CONFIG_KINETIS_GPIOIRQ is not set # # Kinetis UART Configuration diff --git a/configs/kwikstik-k40/src/k40_appinit.c b/configs/kwikstik-k40/src/k40_appinit.c index 43694bce935..befe905af92 100644 --- a/configs/kwikstik-k40/src/k40_appinit.c +++ b/configs/kwikstik-k40/src/k40_appinit.c @@ -98,8 +98,8 @@ /* We expect to receive GPIO interrupts for card insertion events */ -#ifndef CONFIG_GPIO_IRQ -# error "CONFIG_GPIO_IRQ required for card detect interrupt" +#ifndef CONFIG_KINETIS_GPIOIRQ +# error "CONFIG_KINETIS_GPIOIRQ required for card detect interrupt" #endif #ifndef CONFIG_KINETIS_PORTEINTS diff --git a/configs/teensy-3.x/nsh/defconfig b/configs/teensy-3.x/nsh/defconfig index 7698ce06960..5fa77642ca7 100644 --- a/configs/teensy-3.x/nsh/defconfig +++ b/configs/teensy-3.x/nsh/defconfig @@ -226,7 +226,7 @@ CONFIG_KINETIS_UART0=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +# CONFIG_KINETIS_GPIOIRQ is not set # # Kinetis UART Configuration diff --git a/configs/teensy-3.x/usbnsh/defconfig b/configs/teensy-3.x/usbnsh/defconfig index d214df33c5b..8918783e5d9 100644 --- a/configs/teensy-3.x/usbnsh/defconfig +++ b/configs/teensy-3.x/usbnsh/defconfig @@ -218,7 +218,7 @@ CONFIG_KINETIS_USBOTG=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +# CONFIG_KINETIS_GPIOIRQ is not set # # Kinetis UART Configuration diff --git a/configs/twr-k60n512/README.txt b/configs/twr-k60n512/README.txt index e3c827f9875..9c64cae46db 100644 --- a/configs/twr-k60n512/README.txt +++ b/configs/twr-k60n512/README.txt @@ -605,7 +605,7 @@ TWR-K60N512-specific Configuration Options PIN Interrupt Support - CONFIG_GPIO_IRQ -- Enable pin interrupt support. Also needs + CONFIG_KINETIS_GPIOIRQ -- Enable pin interrupt support. Also needs one or more of the following: CONFIG_KINETIS_PORTAINTS -- Support 32 Port A interrupts CONFIG_KINETIS_PORTBINTS -- Support 32 Port B interrupts @@ -687,7 +687,7 @@ Where is one of the following: CONFIG_FAT_LFN=y : FAT long file name support CONFIG_FAT_MAXFNAME=32 : Maximum lenght of a long file name - CONFIG_GPIO_IRQ=y : Enable GPIO interrupts + CONFIG_KINETIS_GPIOIRQ=y : Enable GPIO interrupts CONFIG_KINETIS_PORTEINTS=y : Enable PortE GPIO interrupts CONFIG_SCHED_WORKQUEUE=y : Enable the NuttX workqueue diff --git a/configs/twr-k60n512/nsh/defconfig b/configs/twr-k60n512/nsh/defconfig index 7a495c00e60..05df6f831e8 100644 --- a/configs/twr-k60n512/nsh/defconfig +++ b/configs/twr-k60n512/nsh/defconfig @@ -221,7 +221,7 @@ CONFIG_KINETIS_UART3=y # # Kinetis GPIO Interrupt Configuration # -# CONFIG_GPIO_IRQ is not set +# CONFIG_KINETIS_GPIOIRQ is not set # # Kinetis UART Configuration diff --git a/configs/twr-k60n512/src/k60_appinit.c b/configs/twr-k60n512/src/k60_appinit.c index ffcb0b7f9f3..fde0ef30139 100644 --- a/configs/twr-k60n512/src/k60_appinit.c +++ b/configs/twr-k60n512/src/k60_appinit.c @@ -98,8 +98,8 @@ /* We expect to receive GPIO interrupts for card insertion events */ -#ifndef CONFIG_GPIO_IRQ -# error "CONFIG_GPIO_IRQ required for card detect interrupt" +#ifndef CONFIG_KINETIS_GPIOIRQ +# error "CONFIG_KINETIS_GPIOIRQ required for card detect interrupt" #endif #ifndef CONFIG_KINETIS_PORTEINTS From 3aea9b8bf3ad0bda05c6356288f972786d0b0bd8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:34:21 -0600 Subject: [PATCH 127/152] Rename KL version of CONFIG_GPIO_IRQ to CONFIG_KL_GPIOIRQ --- arch/arm/src/kl/Kconfig | 4 ++-- arch/arm/src/kl/Make.defs | 2 +- arch/arm/src/kl/kl_gpio.h | 4 ++-- arch/arm/src/kl/kl_gpioirq.c | 4 ++-- arch/arm/src/kl/kl_irq.c | 2 +- configs/freedom-kl25z/minnsh/defconfig | 2 +- configs/freedom-kl25z/nsh/defconfig | 2 +- configs/freedom-kl26z/minnsh/defconfig | 2 +- configs/freedom-kl26z/nsh/defconfig | 2 +- configs/teensy-lc/nsh/defconfig | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/arm/src/kl/Kconfig b/arch/arm/src/kl/Kconfig index bfa40491538..7dd13a686b9 100644 --- a/arch/arm/src/kl/Kconfig +++ b/arch/arm/src/kl/Kconfig @@ -345,12 +345,12 @@ config KL_TPM2_CHANNEL comment "Kinetis GPIO Interrupt Configuration" -config GPIO_IRQ +config KL_GPIOIRQ bool "GPIO pin interrupts" ---help--- Enable support for interrupting GPIO pins -if GPIO_IRQ +if KL_GPIOIRQ config KL_PORTAINTS bool "GPIOA interrupts" diff --git a/arch/arm/src/kl/Make.defs b/arch/arm/src/kl/Make.defs index 105d267a73a..d7712f0983c 100644 --- a/arch/arm/src/kl/Make.defs +++ b/arch/arm/src/kl/Make.defs @@ -81,7 +81,7 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y) CHIP_CSRCS += kl_userspace.c endif -ifeq ($(CONFIG_GPIO_IRQ),y) +ifeq ($(CONFIG_KL_GPIOIRQ),y) CHIP_CSRCS += kl_gpioirq.c endif diff --git a/arch/arm/src/kl/kl_gpio.h b/arch/arm/src/kl/kl_gpio.h index fc2cd7f37e9..0024e676086 100644 --- a/arch/arm/src/kl/kl_gpio.h +++ b/arch/arm/src/kl/kl_gpio.h @@ -386,7 +386,7 @@ xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KL_GPIOIRQ void kl_gpioirqenable(uint32_t pinset); #else # define kl_gpioirqenable(pinset) @@ -400,7 +400,7 @@ void kl_gpioirqenable(uint32_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KL_GPIOIRQ void kl_gpioirqdisable(uint32_t pinset); #else # define kl_gpioirqdisable(pinset) diff --git a/arch/arm/src/kl/kl_gpioirq.c b/arch/arm/src/kl/kl_gpioirq.c index 2b481bce3a2..61331343ccd 100644 --- a/arch/arm/src/kl/kl_gpioirq.c +++ b/arch/arm/src/kl/kl_gpioirq.c @@ -51,7 +51,7 @@ #include "chip/kl_port.h" #include "kl_gpio.h" -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KL_GPIOIRQ /**************************************************************************** * Pre-processor Definitions @@ -396,4 +396,4 @@ void kl_gpioirqdisable(uint32_t pinset) } #endif /* HAVE_PORTINTS */ } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_KL_GPIOIRQ */ diff --git a/arch/arm/src/kl/kl_irq.c b/arch/arm/src/kl/kl_irq.c index b37f7afe1c9..94628f26bf7 100644 --- a/arch/arm/src/kl/kl_irq.c +++ b/arch/arm/src/kl/kl_irq.c @@ -248,7 +248,7 @@ void up_irqinitialize(void) * configured pin interrupts. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_KL_GPIOIRQ kl_gpioirqinitialize(); #endif diff --git a/configs/freedom-kl25z/minnsh/defconfig b/configs/freedom-kl25z/minnsh/defconfig index 8a7b3f90623..bf20f0e90f5 100644 --- a/configs/freedom-kl25z/minnsh/defconfig +++ b/configs/freedom-kl25z/minnsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_KL_GPIOIRQ is not set # # Kinetis Configuration Options diff --git a/configs/freedom-kl25z/nsh/defconfig b/configs/freedom-kl25z/nsh/defconfig index 639cc13063e..eac5cf65696 100644 --- a/configs/freedom-kl25z/nsh/defconfig +++ b/configs/freedom-kl25z/nsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_KL_GPIOIRQ is not set # # Kinetis Configuration Options diff --git a/configs/freedom-kl26z/minnsh/defconfig b/configs/freedom-kl26z/minnsh/defconfig index 3356a639659..3fba07ddfa9 100644 --- a/configs/freedom-kl26z/minnsh/defconfig +++ b/configs/freedom-kl26z/minnsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_KL_GPIOIRQ is not set # # Kinetis Configuration Options diff --git a/configs/freedom-kl26z/nsh/defconfig b/configs/freedom-kl26z/nsh/defconfig index 4e8d2b0f702..32f0bdf6be2 100644 --- a/configs/freedom-kl26z/nsh/defconfig +++ b/configs/freedom-kl26z/nsh/defconfig @@ -135,7 +135,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_KL_GPIOIRQ is not set # # Kinetis Configuration Options diff --git a/configs/teensy-lc/nsh/defconfig b/configs/teensy-lc/nsh/defconfig index cab0683d92a..a9e30375cf5 100644 --- a/configs/teensy-lc/nsh/defconfig +++ b/configs/teensy-lc/nsh/defconfig @@ -136,7 +136,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y -# CONFIG_GPIO_IRQ is not set +# CONFIG_KL_GPIOIRQ is not set # # Kinetis Configuration Options From e6137ff1291a470fe22cf0b678775f94c7d5c479 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:38:33 -0600 Subject: [PATCH 128/152] Rename SAMD/L version of CONFIG_GPIO_IRQ to CONFIG_SAMDL_GPIOIRQ --- arch/arm/include/samdl/samd20_irq.h | 2 +- arch/arm/include/samdl/samd21_irq.h | 2 +- arch/arm/include/samdl/saml21_irq.h | 2 +- configs/samd20-xplained/include/board.h | 2 +- configs/samd21-xplained/include/board.h | 2 +- configs/saml21-xplained/include/board.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/samdl/samd20_irq.h b/arch/arm/include/samdl/samd20_irq.h index 01361e8e00e..709fddaeac8 100644 --- a/arch/arm/include/samdl/samd20_irq.h +++ b/arch/arm/include/samdl/samd20_irq.h @@ -81,7 +81,7 @@ /* GPIO interrupts. Up to 16 pins may be configured to support interrupts */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_SAMDL_GPIOIRQ # define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */ # define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */ # define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */ diff --git a/arch/arm/include/samdl/samd21_irq.h b/arch/arm/include/samdl/samd21_irq.h index 2ea4db82579..7b5c633ef62 100644 --- a/arch/arm/include/samdl/samd21_irq.h +++ b/arch/arm/include/samdl/samd21_irq.h @@ -88,7 +88,7 @@ /* GPIO interrupts. Up to 16 pins may be configured to support interrupts */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_SAMDL_GPIOIRQ # define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */ # define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */ # define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */ diff --git a/arch/arm/include/samdl/saml21_irq.h b/arch/arm/include/samdl/saml21_irq.h index 9622a032152..24c774dbd0f 100644 --- a/arch/arm/include/samdl/saml21_irq.h +++ b/arch/arm/include/samdl/saml21_irq.h @@ -89,7 +89,7 @@ /* GPIO interrupts. Up to 16 pins may be configured to support interrupts */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_SAMDL_GPIOIRQ # define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */ # define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */ # define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */ diff --git a/configs/samd20-xplained/include/board.h b/configs/samd20-xplained/include/board.h index 0ca6fab1e83..580b5366a24 100644 --- a/configs/samd20-xplained/include/board.h +++ b/configs/samd20-xplained/include/board.h @@ -44,7 +44,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_GPIO_IRQ +# ifdef CONFIG_SAMDL_GPIOIRQ # include # endif #endif diff --git a/configs/samd21-xplained/include/board.h b/configs/samd21-xplained/include/board.h index 7f68514e3d7..40b19e775fc 100644 --- a/configs/samd21-xplained/include/board.h +++ b/configs/samd21-xplained/include/board.h @@ -44,7 +44,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_GPIO_IRQ +# ifdef CONFIG_SAMDL_GPIOIRQ # include # endif #endif diff --git a/configs/saml21-xplained/include/board.h b/configs/saml21-xplained/include/board.h index 7decc79f168..ec93296ec80 100644 --- a/configs/saml21-xplained/include/board.h +++ b/configs/saml21-xplained/include/board.h @@ -44,7 +44,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_GPIO_IRQ +# ifdef CONFIG_SAMDL_GPIOIRQ # include # endif #endif From c00ad931656d33a49074b395252327fcf86f0eb8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:46:54 -0600 Subject: [PATCH 129/152] Rename HC version of CONFIG_GPIO_IRQ to CONFIG_HCS12_GPIOIRQ --- arch/hc/src/m9s12/Kconfig | 7 +++++++ arch/hc/src/m9s12/m9s12.h | 4 ++-- arch/hc/src/m9s12/m9s12_gpioirq.c | 20 ++++++++++---------- arch/hc/src/m9s12/m9s12_irq.c | 2 +- configs/demo9s12ne64/README.txt | 2 +- configs/ne64badge/README.txt | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/hc/src/m9s12/Kconfig b/arch/hc/src/m9s12/Kconfig index 9e05745e49c..80142efeaf0 100644 --- a/arch/hc/src/m9s12/Kconfig +++ b/arch/hc/src/m9s12/Kconfig @@ -40,4 +40,11 @@ config HCS12_NONBANKED in memory. endmenu # HSC12 Build Options + +config HCS12_GPIOIRQ + bool "GPIO interrupt support" + default n + ---help--- + Enable support for GPIO interrupts + endif # ARCH_HSC12 diff --git a/arch/hc/src/m9s12/m9s12.h b/arch/hc/src/m9s12/m9s12.h index 9a1c9711599..50e3a14abe7 100644 --- a/arch/hc/src/m9s12/m9s12.h +++ b/arch/hc/src/m9s12/m9s12.h @@ -266,7 +266,7 @@ bool hcs12_gpioread(uint16_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ void hcs12_gpioirqenable(int irq); #else # define hcs12_gpioirqenable(irq) @@ -280,7 +280,7 @@ void hcs12_gpioirqenable(int irq); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ void hcs12_gpioirqdisable(int irq); #else # define hcs12_gpioirqdisable(irq) diff --git a/arch/hc/src/m9s12/m9s12_gpioirq.c b/arch/hc/src/m9s12/m9s12_gpioirq.c index 4dae0551244..d16c208f4cb 100644 --- a/arch/hc/src/m9s12/m9s12_gpioirq.c +++ b/arch/hc/src/m9s12/m9s12_gpioirq.c @@ -75,7 +75,7 @@ * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ static int hcs12_mapirq(int irq, uint16_t *regaddr, uint8_t *pin) { if (irq >= HCC12_IRQ_PGFIRST) @@ -121,7 +121,7 @@ static int hcs12_mapirq(int irq, uint16_t *regaddr, uint8_t *pin) } return -EINVAL; } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ /**************************************************************************** * Name: up_gpioa/b/cinterrupt @@ -131,7 +131,7 @@ static int hcs12_mapirq(int irq, uint16_t *regaddr, uint8_t *pin) * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ static int hcs12_interrupt(uint16_t base, int irq0, uint8_t valid, void *context) { uint8_t pending; @@ -204,7 +204,7 @@ static int hcs12_pjinterrupt(int irq, void *context) HCS12_IRQ_PJSET, context); } #endif -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ /**************************************************************************** * Public Functions @@ -229,7 +229,7 @@ void hcs12_gpioirqinitialize(void) /* Attach GPIO IRQ interrupt handlers */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ # ifdef CONFIG_HCS12_PORTG_INTS irq_attach(HCS12_IRQ_VPORTG, hcs12_pginterrupt); # endif @@ -239,7 +239,7 @@ void hcs12_gpioirqinitialize(void) # ifdef CONFIG_HCS12_PORTJ_INTS irq_attach(HCS12_IRQ_VPORTJ, hcs12_pjinterrupt); # endif -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ } /**************************************************************************** @@ -250,7 +250,7 @@ void hcs12_gpioirqinitialize(void) * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ void hcs12_gpioirqenable(int irq) { uint16_t regaddr; @@ -265,7 +265,7 @@ void hcs12_gpioirqenable(int irq) leave_critical_section(flags); } } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ /**************************************************************************** * Name: hcs12_gpioirqdisable @@ -275,7 +275,7 @@ void hcs12_gpioirqenable(int irq) * ****************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ void hcs12_gpioirqdisable(int irq) { uint16_t regaddr; @@ -290,5 +290,5 @@ void hcs12_gpioirqdisable(int irq) leave_critical_section(flags); } } -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ diff --git a/arch/hc/src/m9s12/m9s12_irq.c b/arch/hc/src/m9s12/m9s12_irq.c index a91c270f099..4ce19d70e90 100644 --- a/arch/hc/src/m9s12/m9s12_irq.c +++ b/arch/hc/src/m9s12/m9s12_irq.c @@ -75,7 +75,7 @@ void up_irqinitialize(void) * GPIO pins. */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ hcs12_gpioirqinitialize(); #endif diff --git a/configs/demo9s12ne64/README.txt b/configs/demo9s12ne64/README.txt index 7ec1b55471e..48080bed70f 100644 --- a/configs/demo9s12ne64/README.txt +++ b/configs/demo9s12ne64/README.txt @@ -315,7 +315,7 @@ HCS12/DEMO9S12NEC64-specific Configuration Options GPIO Interrupts - CONFIG_GPIO_IRQ - Enable general support for GPIO IRQs + CONFIG_HCS12_GPIOIRQ - Enable general support for GPIO IRQs CONFIG_HCS12_PORTG_INTS - Enable PortG IRQs CONFIG_HCS12_PORTH_INTS - Enable PortH IRQs CONFIG_HCS12_PORTJ_INTS - Enable PortJ IRQs diff --git a/configs/ne64badge/README.txt b/configs/ne64badge/README.txt index fd5933f81aa..5eb2bc7d820 100644 --- a/configs/ne64badge/README.txt +++ b/configs/ne64badge/README.txt @@ -422,7 +422,7 @@ HCS12/NE64BADGE-specific Configuration Options GPIO Interrupts - CONFIG_GPIO_IRQ - Enable general support for GPIO IRQs + CONFIG_HCS12_GPIOIRQ - Enable general support for GPIO IRQs CONFIG_HCS12_PORTG_INTS - Enable PortG IRQs CONFIG_HCS12_PORTH_INTS - Enable PortH IRQs CONFIG_HCS12_PORTJ_INTS - Enable PortJ IRQs From 5a9519d636c36eae29f71f182f7c56ca27a90385 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:53:17 -0600 Subject: [PATCH 130/152] Rename HCS12 version of CONFIG_GPIO_IRQ to CONFIG_HCS12_GPIOIRQ --- arch/hc/src/m9s12/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/hc/src/m9s12/Kconfig b/arch/hc/src/m9s12/Kconfig index 80142efeaf0..37c357c79d7 100644 --- a/arch/hc/src/m9s12/Kconfig +++ b/arch/hc/src/m9s12/Kconfig @@ -44,7 +44,8 @@ endmenu # HSC12 Build Options config HCS12_GPIOIRQ bool "GPIO interrupt support" default n + depends on EXPERIMENTAL ---help--- - Enable support for GPIO interrupts + Enable support for GPIO interrupts (not implemented) endif # ARCH_HSC12 From e897ccb940b200c24e3f0ba260533c8aa9d65321 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:54:00 -0600 Subject: [PATCH 131/152] Rename x86 QEMU version of CONFIG_GPIO_IRQ to CONFIG_QEMU_GPIOIRQ --- arch/x86/src/qemu/Kconfig | 7 +++++++ arch/x86/src/qemu/qemu.h | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/src/qemu/Kconfig b/arch/x86/src/qemu/Kconfig index d4bd2e071ba..79cd889fbfc 100644 --- a/arch/x86/src/qemu/Kconfig +++ b/arch/x86/src/qemu/Kconfig @@ -25,4 +25,11 @@ config QEMU_VGA graphics subsystem. Such a conversion to the standard NuttX framebuffer interface would, however, not be a big job. +config QEMU_GPIOIRQ + bool "GPIO interrupt support" + default n + depends on EXPERIMENTAL + ---help--- + Enable support for GPIO interrupts (not implemented) + endif diff --git a/arch/x86/src/qemu/qemu.h b/arch/x86/src/qemu/qemu.h index 85ea4bde354..a42fd0a3285 100644 --- a/arch/x86/src/qemu/qemu.h +++ b/arch/x86/src/qemu/qemu.h @@ -115,7 +115,7 @@ void i486_lowsetup(void); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_QEMU_GPIOIRQ void i486_gpioirqinitialize(void); #else # define i486_gpioirqinitialize() @@ -159,7 +159,7 @@ bool i486_gpioread(uint16_t pinset); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_QEMU_GPIOIRQ void i486_gpioirqenable(int irq); #else # define i486_gpioirqenable(irq) @@ -173,7 +173,7 @@ void i486_gpioirqenable(int irq); * ************************************************************************************/ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_QEMU_GPIOIRQ void i486_gpioirqdisable(int irq); #else # define i486_gpioirqdisable(irq) From c282e1d4ffd8b94bd975cc5494c5626ce52e6e5a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:54:59 -0600 Subject: [PATCH 132/152] Correct name, not CONFIG_GPIO_IRQ but CONFIG_TIVA_GPIO_IRQS --- configs/cc3200-launchpad/include/board.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/cc3200-launchpad/include/board.h b/configs/cc3200-launchpad/include/board.h index b55819d0b28..53e0a80f399 100644 --- a/configs/cc3200-launchpad/include/board.h +++ b/configs/cc3200-launchpad/include/board.h @@ -242,7 +242,7 @@ uint8_t up_buttons(void); * ************************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIO_IRQS) xcpt_t up_irqbutton(int id, xcpt_t irqhandler); #endif #endif /* CONFIG_ARCH_BUTTONS */ From b750dd5ff707ae27f84e028007af419bd47aef79 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:55:39 -0600 Subject: [PATCH 133/152] Correct name, not CONFIG_GPIO_IRQ but CONFIG_LPC43_GPIO_IRQ --- configs/lpc4330-xplorer/include/board.h | 2 +- configs/lpc4330-xplorer/src/lpc43_buttons.c | 4 ++-- configs/lpc4337-ws/include/board.h | 2 +- configs/lpc4357-evb/include/board.h | 2 +- configs/lpc4357-evb/src/lpc43_buttons.c | 4 ++-- configs/lpc4370-link2/include/board.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/configs/lpc4330-xplorer/include/board.h b/configs/lpc4330-xplorer/include/board.h index 8e4e531b256..0a7c7d5f8c5 100644 --- a/configs/lpc4330-xplorer/include/board.h +++ b/configs/lpc4330-xplorer/include/board.h @@ -43,7 +43,7 @@ #include #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) # include #endif diff --git a/configs/lpc4330-xplorer/src/lpc43_buttons.c b/configs/lpc4330-xplorer/src/lpc43_buttons.c index 03d27d84899..a277bfc8689 100644 --- a/configs/lpc4330-xplorer/src/lpc43_buttons.c +++ b/configs/lpc4330-xplorer/src/lpc43_buttons.c @@ -72,7 +72,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] = * button events. */ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS]; /* This array provides the mapping from button ID numbers to button IRQ @@ -177,7 +177,7 @@ uint8_t board_buttons(void) * ****************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) xcpt_t board_button_irq(int id, xcpt_t irqhandler) { xcpt_t oldhandler = NULL; diff --git a/configs/lpc4337-ws/include/board.h b/configs/lpc4337-ws/include/board.h index 76da5ef7477..0fe485ad71e 100644 --- a/configs/lpc4337-ws/include/board.h +++ b/configs/lpc4337-ws/include/board.h @@ -43,7 +43,7 @@ #include #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) # include #endif diff --git a/configs/lpc4357-evb/include/board.h b/configs/lpc4357-evb/include/board.h index a1667e66dae..91f0e458b4b 100644 --- a/configs/lpc4357-evb/include/board.h +++ b/configs/lpc4357-evb/include/board.h @@ -43,7 +43,7 @@ #include #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) # include #endif diff --git a/configs/lpc4357-evb/src/lpc43_buttons.c b/configs/lpc4357-evb/src/lpc43_buttons.c index df7f32aef66..37ac652cdfc 100644 --- a/configs/lpc4357-evb/src/lpc43_buttons.c +++ b/configs/lpc4357-evb/src/lpc43_buttons.c @@ -72,7 +72,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] = * button events. */ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS]; /* This array provides the mapping from button ID numbers to button IRQ @@ -183,7 +183,7 @@ uint8_t board_buttons(void) * ****************************************************************************/ -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) xcpt_t board_button_irq(int id, xcpt_t irqhandler) { #if 0 /* Not yet implemented */ diff --git a/configs/lpc4370-link2/include/board.h b/configs/lpc4370-link2/include/board.h index 7bbbd861053..c177c6d4616 100644 --- a/configs/lpc4370-link2/include/board.h +++ b/configs/lpc4370-link2/include/board.h @@ -43,7 +43,7 @@ #include #include -#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ) # include #endif From 416aa996209dcbd73090d2a431616d3fbad85c86 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 14:57:30 -0600 Subject: [PATCH 134/152] Correct name, not CONFIG_GPIO_IRQ but CONFIG_SAM34_GPIO_IRQ --- configs/sam4s-xplained/include/board.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/configs/sam4s-xplained/include/board.h b/configs/sam4s-xplained/include/board.h index 7fc97d5ccc6..e3fdda98902 100644 --- a/configs/sam4s-xplained/include/board.h +++ b/configs/sam4s-xplained/include/board.h @@ -44,24 +44,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_SAM34_GPIO_IRQ -# include -# endif -#endif - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include - -#ifndef __ASSEMBLY__ -# include -# ifdef CONFIG_SAM34_GPIO_IRQ +# ifdef CONFIG_SAM34_SAM34_GPIO_IRQ # include # endif #endif From e77872057dfdfae15085a6c1ae4547acefc9ca46 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Jul 2016 15:01:00 -0600 Subject: [PATCH 135/152] Fix up a few remaining incorrect CONFIG_GPIO_IRQ --- arch/hc/include/m9s12/irq.h | 4 ++-- configs/sam4s-xplained-pro/include/board.h | 2 +- configs/sam4s-xplained/include/board.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/hc/include/m9s12/irq.h b/arch/hc/include/m9s12/irq.h index 63ab556b8e4..d70e40de349 100644 --- a/arch/hc/include/m9s12/irq.h +++ b/arch/hc/include/m9s12/irq.h @@ -108,7 +108,7 @@ * Port J: Pins 0-3 and 6-7 */ -#ifdef CONFIG_GPIO_IRQ +#ifdef CONFIG_HCS12_GPIOIRQ /* To conserve space, interrupts must also be configured, port by port */ @@ -156,7 +156,7 @@ # endif #else # define HCS12_IRQ_NIRQS HCS12_IRQ_NVECTORS -#endif /* CONFIG_GPIO_IRQ */ +#endif /* CONFIG_HCS12_GPIOIRQ */ #define HCS12_IRQ_VILLEGAL HCS12_IRQ_NIRQS /* Any reserved vector */ #define NR_IRQS (HCS12_IRQ_NIRQS+1) diff --git a/configs/sam4s-xplained-pro/include/board.h b/configs/sam4s-xplained-pro/include/board.h index 58380480a9d..0ef923c7e3b 100644 --- a/configs/sam4s-xplained-pro/include/board.h +++ b/configs/sam4s-xplained-pro/include/board.h @@ -46,7 +46,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_GPIO_IRQ +# ifdef CONFIG_SAM34_GPIO_IRQ # include # endif #endif diff --git a/configs/sam4s-xplained/include/board.h b/configs/sam4s-xplained/include/board.h index e3fdda98902..3457a08bd78 100644 --- a/configs/sam4s-xplained/include/board.h +++ b/configs/sam4s-xplained/include/board.h @@ -44,7 +44,7 @@ #ifndef __ASSEMBLY__ # include -# ifdef CONFIG_SAM34_SAM34_GPIO_IRQ +# ifdef CONFIG_SAM34_GPIO_IRQ # include # endif #endif From 829c5610daaedf660f2cef9ef49216fbc799cb69 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 07:19:14 -0600 Subject: [PATCH 136/152] STM32 F4 RTC ALARM: Was not enabling interrupts. --- arch/arm/src/stm32/stm32f40xxx_rtcc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index c20024d8b1a..ba2426899cd 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -1026,6 +1026,10 @@ int up_rtc_initialize(void) stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler); rtc_dumpregs("After InitExtiAlarm"); + + /* Enable RTC Alarm interrupts */ + + up_enable_irq(STM32_IRQ_RTCALRM); #else rtc_dumpregs("After Initialization"); #endif From 65ac11692d537c228ac2ad7e5502f05024e38e30 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 07:33:44 -0600 Subject: [PATCH 137/152] STM32L4 RTC is cloned from F4; needs same fix. --- arch/arm/src/stm32l4/stm32l4_rtcc.c | 56 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c index 338d9a54076..7a1498dc076 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtcc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/stm32l4/stm32l4_rtcc.c * - * Copyright (C) 2012-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * dev@ziggurat29.com (adaptations to stm32l4) * @@ -234,31 +234,6 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg) # define rtc_dumptime(tp, msg) #endif -/************************************************************************************ - * Name: rtc_is_inits - * - * Description: - * Returns 'true' if the RTC has been initialized (according to the RTC itself). - * It will be 'false' if the RTC has never been initialized since first time power - * up, and the counters are stopped until it is first initialized. - * - * Input Parameters: - * None - * - * Returned Value: - * bool -- true if the INITS flag is set in the ISR. - * - ************************************************************************************/ - -bool rtc_is_inits(void) -{ - uint32_t regval; - - regval = getreg32(STM32L4_RTC_ISR); - - return (regval & RTC_ISR_INITS) ? true : false; -} - /************************************************************************************ * Name: rtc_wprunlock * @@ -795,6 +770,31 @@ rtchw_set_alrmbr_exit: * Public Functions ************************************************************************************/ +/************************************************************************************ + * Name: rtc_is_inits + * + * Description: + * Returns 'true' if the RTC has been initialized (according to the RTC itself). + * It will be 'false' if the RTC has never been initialized since first time power + * up, and the counters are stopped until it is first initialized. + * + * Input Parameters: + * None + * + * Returned Value: + * bool -- true if the INITS flag is set in the ISR. + * + ************************************************************************************/ + +bool rtc_is_inits(void) +{ + uint32_t regval; + + regval = getreg32(STM32L4_RTC_ISR); + + return (regval & RTC_ISR_INITS) ? true : false; +} + /************************************************************************************ * Name: up_rtc_initialize * @@ -963,6 +963,10 @@ int up_rtc_initialize(void) */ stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler); + + /* Enable RTC Alarm interrupts */ + + up_enable_irq(STM32L4_IRQ_RTCALRM); #endif g_rtc_enabled = true; From 0984fcda449c4f51b4e73cb5340b224b02212bfc Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 07:53:08 -0600 Subject: [PATCH 138/152] Back out last RTC alarm changes. I am mistaken, the interrupts are enabled by stm32[l4]_exti_alarm(). --- arch/arm/src/stm32/stm32f40xxx_rtcc.c | 4 ---- arch/arm/src/stm32l4/stm32l4_rtcc.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index ba2426899cd..c20024d8b1a 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -1026,10 +1026,6 @@ int up_rtc_initialize(void) stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler); rtc_dumpregs("After InitExtiAlarm"); - - /* Enable RTC Alarm interrupts */ - - up_enable_irq(STM32_IRQ_RTCALRM); #else rtc_dumpregs("After Initialization"); #endif diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c index 7a1498dc076..d4c3c6c533a 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtcc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c @@ -963,10 +963,6 @@ int up_rtc_initialize(void) */ stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler); - - /* Enable RTC Alarm interrupts */ - - up_enable_irq(STM32L4_IRQ_RTCALRM); #endif g_rtc_enabled = true; From 14de4b99f8dd9949b62a2d2cc0f19f9c429dd106 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 08:13:25 -0600 Subject: [PATCH 139/152] Simplify some computations --- arch/arm/src/efm32/efm32_irq.c | 14 ++------------ arch/arm/src/lpc43xx/lpc43_irq.c | 14 ++------------ arch/arm/src/stm32/stm32_exti_alarm.c | 8 -------- arch/arm/src/stm32/stm32_irq.c | 10 ++-------- arch/arm/src/stm32l4/stm32l4_irq.c | 15 ++------------- 5 files changed, 8 insertions(+), 53 deletions(-) diff --git a/arch/arm/src/efm32/efm32_irq.c b/arch/arm/src/efm32/efm32_irq.c index 63a82b194ca..db5992dea7b 100644 --- a/arch/arm/src/efm32/efm32_irq.c +++ b/arch/arm/src/efm32/efm32_irq.c @@ -93,10 +93,6 @@ volatile uint32_t *g_current_regs[1]; extern uint32_t _vectors[]; -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -261,15 +257,9 @@ static int efm32_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit, { if (irq < NR_VECTORS) { - n = irq - EFM32_IRQ_INTERRUPTS; + n = irq - EFM32_IRQ_INTERRUPTS; *regaddr = NVIC_IRQ_ENABLE(n) + offset; - - while (n >= 32) - { - n -= 32; - } - - *bit = 1 << n; + *bit = (uint32_t)1 << (n & 0x1f); } else { diff --git a/arch/arm/src/lpc43xx/lpc43_irq.c b/arch/arm/src/lpc43xx/lpc43_irq.c index 26881472c8d..09680bd9e91 100644 --- a/arch/arm/src/lpc43xx/lpc43_irq.c +++ b/arch/arm/src/lpc43xx/lpc43_irq.c @@ -91,10 +91,6 @@ volatile uint32_t *g_current_regs[1]; extern uint32_t _vectors[]; -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -250,15 +246,9 @@ static int lpc43_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit, if (irq >= LPC43_IRQ_EXTINT) { - n = irq - LPC43_IRQ_EXTINT; + n = irq - LPC43_IRQ_EXTINT; *regaddr = NVIC_IRQ_ENABLE(n) + offset; - - while (n >= 32) - { - n -= 32; - } - - *bit = 1 << n; + *bit = (uint32_t)1 << (n & 0x1f); } /* Handle processor exceptions. Only a few can be disabled */ diff --git a/arch/arm/src/stm32/stm32_exti_alarm.c b/arch/arm/src/stm32/stm32_exti_alarm.c index f38574f2523..2e6d582a4aa 100644 --- a/arch/arm/src/stm32/stm32_exti_alarm.c +++ b/arch/arm/src/stm32/stm32_exti_alarm.c @@ -53,10 +53,6 @@ #include "stm32_gpio.h" #include "stm32_exti.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Private Data ****************************************************************************/ @@ -65,10 +61,6 @@ static xcpt_t stm32_exti_callback; -/**************************************************************************** - * Public Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c index ea7c4ddfcbe..ff40bf8d033 100644 --- a/arch/arm/src/stm32/stm32_irq.c +++ b/arch/arm/src/stm32/stm32_irq.c @@ -253,15 +253,9 @@ static int stm32_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit, if (irq >= STM32_IRQ_FIRST) { - n = irq - STM32_IRQ_FIRST; + n = irq - STM32_IRQ_FIRST; *regaddr = NVIC_IRQ_ENABLE(n) + offset; - - while (n >= 32) - { - n -= 32; - } - - *bit = 1 << n; + *bit = (uint32_t)1 << (n & 0x1f); } /* Handle processor exceptions. Only a few can be disabled */ diff --git a/arch/arm/src/stm32l4/stm32l4_irq.c b/arch/arm/src/stm32l4/stm32l4_irq.c index 8e90bf0fa8a..7376b146753 100644 --- a/arch/arm/src/stm32l4/stm32l4_irq.c +++ b/arch/arm/src/stm32l4/stm32l4_irq.c @@ -1,8 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32l4/stm32l4_irq.c - * arch/arm/src/chip/stm32l4_irq.c * - * Copyright (C) 2009-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -90,10 +89,6 @@ volatile uint32_t *g_current_regs[1]; extern uint32_t _vectors[]; -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -254,13 +249,7 @@ static int stm32l4_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit, { n = irq - STM32L4_IRQ_FIRST; *regaddr = NVIC_IRQ_ENABLE(n) + offset; - - while (n >= 32) - { - n -= 32; - } - - *bit = 1 << n; + *bit = (uint32_t)1 << (n & 0x1f); } /* Handle processor exceptions. Only a few can be disabled */ From 5a0f9fcb7d097ffbb5e45f956ed82cff087dddc1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 10:36:06 -0600 Subject: [PATCH 140/152] Fix STM32 RTC Alarm interrupts. They were being enabled BEFORE the interrupt system was being initialized. --- arch/arm/src/armv7-r/arm_doirq.c | 16 ------ arch/arm/src/stm32/stm32f40xxx_rtcc.c | 66 ++++++++++++++++------- arch/arm/src/stm32l4/stm32l4_irq.c | 2 +- arch/arm/src/stm32l4/stm32l4_rtcc.c | 63 ++++++++++++++++------ configs/stm3240g-eval/src/stm32_appinit.c | 17 ++++-- 5 files changed, 106 insertions(+), 58 deletions(-) diff --git a/arch/arm/src/armv7-r/arm_doirq.c b/arch/arm/src/armv7-r/arm_doirq.c index fdf392d3384..5d492f5ddc7 100644 --- a/arch/arm/src/armv7-r/arm_doirq.c +++ b/arch/arm/src/armv7-r/arm_doirq.c @@ -52,22 +52,6 @@ #include "group/group.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index c20024d8b1a..518406bfa1f 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -136,6 +136,7 @@ struct alm_cbinfo_s /* Callback to use when an EXTI is activated */ static struct alm_cbinfo_s g_alarmcb[RTC_ALARM_LAST]; +static bool g_alarm_enabled; /* True: Alarm interrupts are enabled */ #endif /**************************************************************************** @@ -157,6 +158,7 @@ static int rtchw_set_alrmar(rtc_alarmreg_t alarmreg); static int rtchw_check_alrbwf(void); static int rtchw_set_alrmbr(rtc_alarmreg_t alarmreg); #endif +static void alarm_enable(void); #endif /**************************************************************************** @@ -811,6 +813,46 @@ rtchw_set_alrmbr_exit: } #endif +/**************************************************************************** + * Name: alarm_enable + * + * Description: + * Enable ALARM interrupts + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_RTC_ALARM +static void alarm_enable(void) +{ + /* Is the alarm already enabled? */ + + if (!g_alarm_enabled) + { + /* Configure RTC interrupt to catch alarm interrupts. All RTC + * interrupts are connected to the EXTI controller. To enable the + * RTC Alarm interrupt, the following sequence is required: + * + * 1. Configure and enable the EXTI Line 17 RTC ALARM in interrupt + * mode and select the rising edge sensitivity. + * For STM32F4xx + * EXTI line 21 RTC Tamper & Timestamp + * EXTI line 22 RTC Wakeup + * 2. Configure and enable the RTC_Alarm IRQ channel in the NVIC. + * 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B). + */ + + stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler); + g_alarm_enabled = true; + } +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -1010,25 +1052,7 @@ int up_rtc_initialize(void) return -ETIMEDOUT; } -#ifdef CONFIG_RTC_ALARM - /* Configure RTC interrupt to catch alarm interrupts. All RTC interrupts - * are connected to the EXTI controller. To enable the RTC Alarm - * interrupt, the following sequence is required: - * - * 1. Configure and enable the EXTI Line 17 RTC ALARM in interrupt mode - * and select the rising edge sensitivity. - * For STM32F4xx - * EXTI line 21 RTC Tamper & Timestamp - * EXTI line 22 RTC Wakeup - * 2. Configure and enable the RTC_Alarm IRQ channel in the NVIC. - * 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B). - */ - - stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler); - rtc_dumpregs("After InitExtiAlarm"); -#else rtc_dumpregs("After Initialization"); -#endif g_rtc_enabled = true; return OK; @@ -1321,6 +1345,10 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) ASSERT(alminfo != NULL); DEBUGASSERT(RTC_ALARM_LAST > alminfo->as_id); + /* Make sure the the alarm interrupt is enabled at the NVIC */ + + alarm_enable(); + /* REVISIT: Should test that the time is in the future */ rtc_dumptime(&alminfo->as_time, "New alarm time"); @@ -1335,7 +1363,7 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) (rtc_bin2bcd(alminfo->as_time.tm_hour) << RTC_ALRMR_HU_SHIFT) | (rtc_bin2bcd(alminfo->as_time.tm_mday) << RTC_ALRMR_DU_SHIFT); - /* Set the alarm in hardware and enable interrupts */ + /* Set the alarm in hardware and enable interrupts from the RTC */ switch (alminfo->as_id) { diff --git a/arch/arm/src/stm32l4/stm32l4_irq.c b/arch/arm/src/stm32l4/stm32l4_irq.c index 7376b146753..720c05ecc69 100644 --- a/arch/arm/src/stm32l4/stm32l4_irq.c +++ b/arch/arm/src/stm32l4/stm32l4_irq.c @@ -247,7 +247,7 @@ static int stm32l4_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit, if (irq >= STM32L4_IRQ_FIRST) { - n = irq - STM32L4_IRQ_FIRST; + n = irq - STM32L4_IRQ_FIRST; *regaddr = NVIC_IRQ_ENABLE(n) + offset; *bit = (uint32_t)1 << (n & 0x1f); } diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c index d4c3c6c533a..7e20a328af0 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtcc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c @@ -134,6 +134,7 @@ struct alm_cbinfo_s /* Callback to use when an EXTI is activated */ static struct alm_cbinfo_s g_alarmcb[RTC_ALARM_LAST]; +static bool g_alarm_enabled; /* True: Alarm interrupts are enabled */ #endif /************************************************************************************ @@ -153,6 +154,7 @@ static int rtchw_check_alrawf(void); static int rtchw_check_alrbwf(void); static int rtchw_set_alrmar(rtc_alarmreg_t alarmreg); static int rtchw_set_alrmbr(rtc_alarmreg_t alarmreg); +static void alarm_enable(void); #endif /************************************************************************************ @@ -766,6 +768,45 @@ rtchw_set_alrmbr_exit: } #endif +/**************************************************************************** + * Name: alarm_enable + * + * Description: + * Enable ALARM interrupts + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_RTC_ALARM +static void alarm_enable(void) +{ + /* Is the alarm already enabled? */ + + if (!g_alarm_enabled) + { + /* Configure RTC interrupt to catch alarm interrupts. All RTC + * interrupts are connected to the EXTI controller. To enable the + * RTC Alarm interrupt, the following sequence is required: + * + * 1. Configure and enable the EXTI Line 18 in interrupt mode and + * select the rising edge sensitivity. + * EXTI line 19 RTC Tamper or Timestamp or CSS_LSE + * EXTI line 20 RTC Wakeup + * 2. Configure and enable the RTC_Alarm IRQ channel in the NVIC. + * 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B). + */ + + stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler); + g_alarm_enabled = true; + } +} +#endif + /************************************************************************************ * Public Functions ************************************************************************************/ @@ -949,22 +990,6 @@ int up_rtc_initialize(void) (void)stm32l4_pwr_enablebkp(false); } -#ifdef CONFIG_RTC_ALARM - /* Configure RTC interrupt to catch alarm interrupts. All RTC interrupts are - * connected to the EXTI controller. To enable the RTC Alarm interrupt, the - * following sequence is required: - * - * 1. Configure and enable the EXTI Line 18 in interrupt mode and select the - * rising edge sensitivity. - * EXTI line 19 RTC Tamper or Timestamp or CSS_LSE - * EXTI line 20 RTC Wakeup - * 2. Configure and enable the RTC_Alarm IRQ channel in the NVIC. - * 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B). - */ - - stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler); -#endif - g_rtc_enabled = true; rtc_dumpregs("After Initialization"); @@ -1241,6 +1266,10 @@ int stm32l4_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) ASSERT(alminfo != NULL); DEBUGASSERT(RTC_ALARM_LAST > alminfo->as_id); + /* Make sure the the alarm interrupt is enabled at the NVIC */ + + alarm_enable(); + /* REVISIT: Should test that the time is in the future */ rtc_dumptime(&alminfo->as_time, "New alarm time"); @@ -1249,7 +1278,7 @@ int stm32l4_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) alarmreg = rtc_reg_alrmr_bin2bcd(&alminfo->as_time); - /* Set the alarm in hardware and enable interrupts */ + /* Set the alarm in hardware and enable interrupts from the RTC */ switch (alminfo->as_id) { diff --git a/configs/stm3240g-eval/src/stm32_appinit.c b/configs/stm3240g-eval/src/stm32_appinit.c index 58938c9c2e0..7523030be25 100644 --- a/configs/stm3240g-eval/src/stm32_appinit.c +++ b/configs/stm3240g-eval/src/stm32_appinit.c @@ -254,7 +254,8 @@ int board_app_initialize(uintptr_t arg) lower = stm32_rtc_lowerhalf(); if (!lower) { - serr("ERROR: Failed to instantiate the RTC lower-half driver\n"); + syslog(LOG_ERR, + "ERROR: Failed to instantiate the RTC lower-half driver\n"); return -ENOMEM; } else @@ -266,7 +267,9 @@ int board_app_initialize(uintptr_t arg) ret = rtc_initialize(0, lower); if (ret < 0) { - serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret); + syslog(LOG_ERR, + "ERROR: Failed to bind/register the RTC driver: %d\n", + ret); return ret; } } @@ -289,7 +292,8 @@ int board_app_initialize(uintptr_t arg) mtd = m25p_initialize(spi); if (!mtd) { - syslog(LOG_ERR, "ERROR: Failed to bind SPI port 0 to the SPI FLASH driver\n"); + syslog(LOG_ERR, + "ERROR: Failed to bind SPI port 0 to the SPI FLASH driver\n"); return -ENODEV; } #warning "Now what are we going to do with this SPI FLASH driver?" @@ -303,7 +307,8 @@ int board_app_initialize(uintptr_t arg) sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!sdio) { - syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", + syslog(LOG_ERR, + "ERROR: Failed to initialize SDIO slot %d\n", CONFIG_NSH_MMCSDSLOTNO); return -ENODEV; } @@ -313,7 +318,9 @@ int board_app_initialize(uintptr_t arg) ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio); if (ret != OK) { - syslog(LOG_ERR, "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + syslog(LOG_ERR, + "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", + ret); return ret; } From 9b9b721406f8e49f1fe1db492bba0f8ea9613bb1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 12:01:57 -0600 Subject: [PATCH 141/152] Rename alarm_enable to rtc_alarm_enabled; mark inline --- arch/arm/src/stm32/stm32f40xxx_rtcc.c | 8 ++++---- arch/arm/src/stm32l4/stm32l4_rtcc.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index 518406bfa1f..7145243b894 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -158,7 +158,7 @@ static int rtchw_set_alrmar(rtc_alarmreg_t alarmreg); static int rtchw_check_alrbwf(void); static int rtchw_set_alrmbr(rtc_alarmreg_t alarmreg); #endif -static void alarm_enable(void); +static inline void rtc_enable_alarm(void); #endif /**************************************************************************** @@ -814,7 +814,7 @@ rtchw_set_alrmbr_exit: #endif /**************************************************************************** - * Name: alarm_enable + * Name: rtc_enable_alarm * * Description: * Enable ALARM interrupts @@ -828,7 +828,7 @@ rtchw_set_alrmbr_exit: ****************************************************************************/ #ifdef CONFIG_RTC_ALARM -static void alarm_enable(void) +static inline void rtc_enable_alarm(void) { /* Is the alarm already enabled? */ @@ -1347,7 +1347,7 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) /* Make sure the the alarm interrupt is enabled at the NVIC */ - alarm_enable(); + rtc_enable_alarm(); /* REVISIT: Should test that the time is in the future */ diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c index 7e20a328af0..1ee4306080f 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtcc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c @@ -154,7 +154,7 @@ static int rtchw_check_alrawf(void); static int rtchw_check_alrbwf(void); static int rtchw_set_alrmar(rtc_alarmreg_t alarmreg); static int rtchw_set_alrmbr(rtc_alarmreg_t alarmreg); -static void alarm_enable(void); +static inline void rtc_enable_alarm(void); #endif /************************************************************************************ @@ -769,7 +769,7 @@ rtchw_set_alrmbr_exit: #endif /**************************************************************************** - * Name: alarm_enable + * Name: rtc_enable_alarm * * Description: * Enable ALARM interrupts @@ -783,7 +783,7 @@ rtchw_set_alrmbr_exit: ****************************************************************************/ #ifdef CONFIG_RTC_ALARM -static void alarm_enable(void) +static inline void rtc_enable_alarm(void) { /* Is the alarm already enabled? */ @@ -1268,7 +1268,7 @@ int stm32l4_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) /* Make sure the the alarm interrupt is enabled at the NVIC */ - alarm_enable(); + rtc_enable_alarm(); /* REVISIT: Should test that the time is in the future */ From a932578e768abbce40c3d072c8dd211349ef72a2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 13:53:06 -0600 Subject: [PATCH 142/152] GPIO driver: Add support for receiving signals from interrupt pins. --- drivers/ioexpander/gpio.c | 181 ++++++++++++++++++++------------ include/nuttx/ioexpander/gpio.h | 92 ++++++++-------- 2 files changed, 162 insertions(+), 111 deletions(-) diff --git a/drivers/ioexpander/gpio.c b/drivers/ioexpander/gpio.c index 291652eb4df..9c2d46cc20a 100644 --- a/drivers/ioexpander/gpio.c +++ b/drivers/ioexpander/gpio.c @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -53,6 +54,7 @@ * Private Function Prototypes ****************************************************************************/ +static int gpio_handler(FAR struct gpio_dev_s *dev); static int gpio_open(FAR struct file *filep); static int gpio_close(FAR struct file *filep); static ssize_t gpio_read(FAR struct file *filep, FAR char *buffer, @@ -66,23 +68,7 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, * Private Data ****************************************************************************/ -static const struct file_operations g_gpio_input_ops = -{ - gpio_open, /* open */ - gpio_close, /* close */ - gpio_read, /* read */ - NULL, /* write */ - NULL, /* seek */ - gpio_ioctl /* ioctl */ -#ifndef CONFIG_DISABLE_POLL - , NULL /* poll */ -#endif -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ -#endif -}; - -static const struct file_operations g_gpio_output_ops = +static const struct file_operations g_gpio_drvrops = { gpio_open, /* open */ gpio_close, /* close */ @@ -102,6 +88,21 @@ static const struct file_operations g_gpio_output_ops = * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: gpio_handler + * + * Description: + * Standard character driver open method. + * + ****************************************************************************/ + +static int gpio_handler(FAR struct gpio_dev_s *dev) +{ + DEBUGASSERT(dev != NULL); + kill(dev->gp_pid, dev->gp_signo); + return OK; +} + /**************************************************************************** * Name: gpio_open * @@ -167,7 +168,7 @@ static ssize_t gpio_write(FAR struct file *filep, FAR const char *buffer, static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { FAR struct inode *inode; - FAR struct gpio_common_dev_s *dev; + FAR struct gpio_dev_s *dev; int ret; DEBUGASSERT(filep != NULL && filep->f_inode != NULL); @@ -177,20 +178,16 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) switch (cmd) { - /* Command: GPIO_WRITE + /* Command: GPIOC_WRITE * Description: Set the value of an output GPIO * Argument: 0=output a low value; 1=outut a high value */ - case GPIO_WRITE: - if (dev->gp_output) + case GPIOC_WRITE: + if (dev->gp_pintype == GPIO_OUTPUT_PIN) { - FAR struct gpio_output_dev_s *outdev = - (FAR struct gpio_output_dev_s *)dev; - - DEBUGASSERT(outdev->gpout_write != NULL && - ((arg == 0UL) || (arg == 1UL))); - ret = outdev->gpout_write(outdev, (int)arg); + DEBUGASSERT(arg == 0ul || arg == 1ul); + ret = dev->gp_ops->go_write(dev, (int)arg); } else { @@ -198,38 +195,64 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; - /* Command: GPIO_READ + /* Command: GPIOC_READ * Description: Read the value of an input or output GPIO * Argument: A pointer to an integer value to receive the result: * 0=low value; 1=high value. */ - case GPIO_READ: + case GPIOC_READ: { FAR int *ptr = (FAR int *)((uintptr_t)arg); DEBUGASSERT(ptr != NULL); - if (dev->gp_output) - { - FAR struct gpio_output_dev_s *outdev = - (FAR struct gpio_output_dev_s *)dev; - - DEBUGASSERT(outdev->gpout_read != NULL); - ret = outdev->gpout_read(outdev, ptr); - } - else - { - FAR struct gpio_input_dev_s *indev = - (FAR struct gpio_input_dev_s *)dev; - - DEBUGASSERT(indev->gpin_read != NULL); - ret = indev->gpin_read(indev, ptr); - } - + ret = dev->gp_ops->go_read(dev, ptr); DEBUGASSERT(ret < 0 || *ptr == 0 || *ptr == 1); } break; + /* Command: GPIOC_REGISTER + * Description: Register to receive a signal whenever there an + * interrupt is received on an input gpio pin. This + * feature, of course, depends upon interrupt GPIO + * support from the platform. + * Argument: The number of signal to be generated when the + * interrupt occurs. + */ + + case GPIOC_REGISTER: + if (dev->gp_pintype == GPIO_INTERRUPT_PIN) + { + /* Make sure that the pin interrupt is disabled */ + + ret = dev->gp_ops->go_enable(dev, false); + if (ret >= 0) + { + /* Save signal information */ + + DEBUGASSERT(GOOD_SIGNO(arg)); + + dev->gp_pid = getpid(); + dev->gp_signo = (uint8_t)arg; + + /* Register our handler */ + + ret = dev->gp_ops->go_attach(dev, + (pin_interrupt_t)gpio_handler); + if (ret >= 0) + { + /* Enable pin interrupts */ + + ret = dev->gp_ops->go_enable(dev, true); + } + } + } + else + { + ret = -EACCES; + } + break; + /* Unrecognized command */ default: @@ -245,41 +268,63 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ /**************************************************************************** - * Name: gpio_input_register + * Name: gpio_pin_register * * Description: - * Register GPIO input pin device driver. + * Register GPIO pin device driver. * ****************************************************************************/ -int gpio_input_register(FAR struct gpio_input_dev_s *dev, int minor) +int gpio_pin_register(FAR struct gpio_dev_s *dev, int minor) { + FAR const char *fmt; char devname[16]; + int ret; - DEBUGASSERT(dev != NULL && !dev->gpin_output && dev->gpin_read != NULL && - (unsigned int)minor < 100); + DEBUGASSERT(dev != NULL && dev->gp_ops != NULL && (unsigned int)minor < 100); - snprintf(devname, 16, "/dev/gpin%u", (unsigned int)minor); - return register_driver(devname, &g_gpio_input_ops, 0444, dev); -} + switch (dev->gp_pintype) + { + case GPIO_INPUT_PIN: + { + DEBUGASSERT(dev->gp_ops->go_read != NULL); + fmt = "/dev/gpin%u"; + } + break; -/**************************************************************************** - * Name: gpio_output_register - * - * Description: - * Register GPIO output pin device driver. - * - ****************************************************************************/ + case GPIO_OUTPUT_PIN: + { + DEBUGASSERT(dev->gp_ops->go_read != NULL && + dev->gp_ops->go_write != NULL); + fmt = "/dev/gpout%u"; + + } + break; -int gpio_output_register(FAR struct gpio_output_dev_s *dev, int minor) -{ - char devname[16]; + case GPIO_INTERRUPT_PIN: + { + DEBUGASSERT(dev->gp_ops->go_read != NULL && + dev->gp_ops->go_attach != NULL && + dev->gp_ops->go_enable != NULL); - DEBUGASSERT(dev != NULL && dev->gpout_output && dev->gpout_read != NULL && - dev->gpout_write != NULL &&(unsigned int)minor < 100); + /* Make sure that the pin interrupt is disabled */ - snprintf(devname, 16, "/dev/gpout%u", (unsigned int)minor); - return register_driver(devname, &g_gpio_output_ops, 0222, dev); + ret = dev->gp_ops->go_enable(dev, false); + if (ret < 0) + { + return ret; + } + + fmt = "/dev/gpint%u"; + } + break; + + default: + return -EINVAL; + } + + snprintf(devname, 16, fmt, (unsigned int)minor); + return register_driver(devname, &g_gpio_drvrops, 0666, dev); } #endif /* CONFIG_DEV_GPIO */ diff --git a/include/nuttx/ioexpander/gpio.h b/include/nuttx/ioexpander/gpio.h index ce6e13794b7..6436a2d13f6 100644 --- a/include/nuttx/ioexpander/gpio.h +++ b/include/nuttx/ioexpander/gpio.h @@ -47,64 +47,80 @@ * Pre-processor Definitions ****************************************************************************/ -/* Command: GPIO_WRITE +/* Command: GPIOC_WRITE * Description: Set the value of an output GPIO * Argument: 0=output a low value; 1=outut a high value * - * Command: GPIO_READ + * Command: GPIOC_READ * Description: Read the value of an input or output GPIO * Argument: A pointer to an integer value to receive the result: * 0=low value; 1=high value. + * + * Command: GPIOC_REGISTER + * Description: Register to receive a signal whenever there an interrupt + * is received on an input gpio pin. This feature, of course, + * depends upon interrupt GPIO support from the platform. + * Argument: The number of signal to be generated when the interrupt + * occurs. */ -#define GPIO_WRITE _GPIOC(1) -#define GPIO_READ _GPIOC(2) +#define GPIOC_WRITE _GPIOC(1) +#define GPIOC_READ _GPIOC(2) +#define GPIOC_REGISTER _GPIOC(3) /**************************************************************************** * Public Types ****************************************************************************/ -/* Common interface definition. Must be cast-compatible with struct - * gpio_input_dev_s and struct gpio_output_dev_s - */ +/* Identifies the type of the GPIO pin */ -struct gpio_common_dev_s +enum gpio_pintype_e { - bool gp_output; - uint8_t gp_unused[3]; + GPIO_INPUT_PIN = 0, + GPIO_OUTPUT_PIN, + GPIO_INTERRUPT_PIN }; -/* The interface to a GPIO input pin */ +/* Interrupt callback */ -struct gpio_input_dev_s +typedef CODE int (*pin_interrupt_t)(FAR struct gpio_dev_s *dev); + +/* Pin interface definition. */ + +struct gpio_dev_s; +struct gpio_operations_s { - /* Common fields */ + /* Interface methods */ - bool gpin_output; - uint8_t gpin_unused[3]; - - /* Fields unique to input pins */ - - CODE int (*gpin_read)(FAR struct gpio_input_dev_s *dev, FAR int *value); - - /* Lower-half private definitions may follow */ + CODE int (*go_read)(FAR struct gpio_dev_s *dev, FAR int *value); + CODE int (*go_write)(FAR struct gpio_dev_s *dev, int value); + CODE int (*go_attach)(FAR struct gpio_dev_s *dev, + pin_interrupt_t callback); + CODE int (*go_enable)(FAR struct gpio_dev_s *dev, bool enable); }; -/* The interface to a GPIO input pin */ +/* Pin interface definition. */ -struct gpio_output_dev_s +struct gpio_dev_s { - /* Common fields */ + /* Information provided from the lower half driver to the upper half + * driver when gpio_pin_register() is called. + */ - bool gpout_output; - uint8_t gpout_unused[3]; + uint8_t gp_pintype; /* See enum gpio_pintype_e */; - /* Fields unique to output pins */ + /* Writable storage used by the upper half driver */ - CODE int (*gpout_read)(FAR struct gpio_output_dev_s *dev, FAR int *value); - CODE int (*gpout_write)(FAR struct gpio_output_dev_s *dev, int value); + uint8_t gp_signo; /* signo to use when signaling a GPIO interrupt */ + pid_t gp_pid; /* The task to be signalled */ - /* Lower-half private definitions may follow */ + /* Read-only pointer to GPIO device operations (also provided by the + * lower half driver). + */ + + FAR const struct gpio_operations_s *gp_ops; + + /* Device specific information may follow */ }; /**************************************************************************** @@ -120,24 +136,14 @@ extern "C" #endif /**************************************************************************** - * Name: gpio_input_register + * Name: gpio_pin_register * * Description: - * Register GPIO input pin device driver. + * Register GPIO pin device driver. * ****************************************************************************/ -int gpio_input_register(FAR struct gpio_input_dev_s *dev, int minor); - -/**************************************************************************** - * Name: gpio_output_register - * - * Description: - * Register GPIO output pin device driver. - * - ****************************************************************************/ - -int gpio_output_register(FAR struct gpio_output_dev_s *dev, int minor); +int gpio_pin_register(FAR struct gpio_dev_s *dev, int minor); #ifdef __cplusplus } From 2d92bffdccdd270c1a639a5569bbb801bd6f8315 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 23 Jul 2016 13:53:37 -0600 Subject: [PATCH 143/152] Trivial change left in editor --- drivers/ioexpander/gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ioexpander/gpio.c b/drivers/ioexpander/gpio.c index 9c2d46cc20a..9e806c3bee6 100644 --- a/drivers/ioexpander/gpio.c +++ b/drivers/ioexpander/gpio.c @@ -99,7 +99,7 @@ static const struct file_operations g_gpio_drvrops = static int gpio_handler(FAR struct gpio_dev_s *dev) { DEBUGASSERT(dev != NULL); - kill(dev->gp_pid, dev->gp_signo); + (void)kill(dev->gp_pid, dev->gp_signo); return OK; } From f3a6a40f62858b9b1b7e5073f52f7bf7b064f5d4 Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Fri, 15 Jul 2016 18:32:53 -0700 Subject: [PATCH 144/152] SAM3/4 Serial: Fix warning when CONFIG_SUPPRESS_UART_CONFIG is set. --- arch/arm/src/sam34/sam_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/sam34/sam_serial.c b/arch/arm/src/sam34/sam_serial.c index 46df27954a1..36043e9deb8 100644 --- a/arch/arm/src/sam34/sam_serial.c +++ b/arch/arm/src/sam34/sam_serial.c @@ -692,8 +692,8 @@ static void up_disableallints(struct up_dev_s *priv, uint32_t *imr) static int up_setup(struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; #ifndef CONFIG_SUPPRESS_UART_CONFIG + struct up_dev_s *priv = (struct up_dev_s *)dev->priv; uint32_t regval; uint32_t imr; From 81f7758848722cf5d4b0bba1f4b0c60179f87e14 Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 23 Jul 2016 20:10:20 -0700 Subject: [PATCH 145/152] USBMSC: Fix usbtrace() string. --- drivers/usbdev/usbdev_strings.c | 2 +- drivers/usbdev/usbmsc_scsi.c | 2 +- include/nuttx/usb/usbdev_trace.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usbdev/usbdev_strings.c b/drivers/usbdev/usbdev_strings.c index 9dc9afdc407..d8c35189f0a 100644 --- a/drivers/usbdev/usbdev_strings.c +++ b/drivers/usbdev/usbdev_strings.c @@ -177,7 +177,7 @@ const struct trace_msg_t g_usb_trace_strings_clserror[] = TRACE_STR(USBMSC_TRACEERR_CMDREADREADFAIL), TRACE_STR(USBMSC_TRACEERR_CMDREADSUBMIT), TRACE_STR(USBMSC_TRACEERR_CMDREADWRRQEMPTY), - TRACE_STR(USBMSC_TRACEERR_CMDSTATUSRDREQLISTEMPTY), + TRACE_STR(USBMSC_TRACEERR_CMDSTATUSWRREQLISTEMPTY), TRACE_STR(USBMSC_TRACEERR_CMDUNEVIOLATION), TRACE_STR(USBMSC_TRACEERR_CMDWRITERDSUBMIT), TRACE_STR(USBMSC_TRACEERR_CMDWRITERDRQEMPTY), diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index fd9e55cb6b4..33d7eb7629f 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -2537,7 +2537,7 @@ static int usbmsc_cmdstatusstate(FAR struct usbmsc_dev_s *priv) if (!privreq) { - usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_CMDSTATUSRDREQLISTEMPTY), 0); + usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_CMDSTATUSWRREQLISTEMPTY), 0); return -ENOMEM; } diff --git a/include/nuttx/usb/usbdev_trace.h b/include/nuttx/usb/usbdev_trace.h index 4ef4e170e11..55915caee83 100644 --- a/include/nuttx/usb/usbdev_trace.h +++ b/include/nuttx/usb/usbdev_trace.h @@ -295,7 +295,7 @@ #define USBMSC_TRACEERR_CMDREADREADFAIL 0x0094 #define USBMSC_TRACEERR_CMDREADSUBMIT 0x0095 #define USBMSC_TRACEERR_CMDREADWRRQEMPTY 0x0096 -#define USBMSC_TRACEERR_CMDSTATUSRDREQLISTEMPTY 0x0097 +#define USBMSC_TRACEERR_CMDSTATUSWRREQLISTEMPTY 0x0097 #define USBMSC_TRACEERR_CMDUNEVIOLATION 0x0098 #define USBMSC_TRACEERR_CMDWRITERDSUBMIT 0x0099 #define USBMSC_TRACEERR_CMDWRITERDRQEMPTY 0x009a From 2974d2b07edce4e8f2606de219ee62ba9d1e298d Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 23 Jul 2016 20:10:41 -0700 Subject: [PATCH 146/152] USBMSC: Add locks when removing request from queue. --- drivers/usbdev/usbmsc_scsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index 33d7eb7629f..b478eb55621 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -2263,7 +2263,9 @@ static int usbmsc_cmdwritestate(FAR struct usbmsc_dev_s *priv) * data to be written. */ + irqstate_t flags = enter_critical_section(); privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->rdreqlist); + leave_critical_section(flags); /* If there no request data available, then just return an error. * This will cause us to remain in the CMDWRITE state. When a filled request is From 4f83d58b24b6993fc3c4bd70648c25ba5e4d5d12 Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 23 Jul 2016 20:11:00 -0700 Subject: [PATCH 147/152] USBMSC: Fix reversed logic on waiting for SCSI thread start. The scsi thread was waiting for the wrong condition. However, this was masked by the fact that the code creating the scsi thread was also holding usbmsc_scsi_lock(priv) while initializing data, hence this lock synchronized the scsi thread start with init completion. --- drivers/usbdev/usbmsc_scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index b478eb55621..d088312ca94 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -2641,8 +2641,8 @@ int usbmsc_scsi_main(int argc, char *argv[]) uinfo("Waiting to be signalled\n"); usbmsc_scsi_lock(priv); priv->thstate = USBMSC_STATE_STARTED; - while ((priv->theventset & USBMSC_EVENT_READY) != 0 && - (priv->theventset & USBMSC_EVENT_TERMINATEREQUEST) != 0) + while ((priv->theventset & USBMSC_EVENT_READY) == 0 && + (priv->theventset & USBMSC_EVENT_TERMINATEREQUEST) == 0) { usbmsc_scsi_wait(priv); } From cc191a977dc579e256787ab10d99562b431ab81e Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 23 Jul 2016 16:17:20 -0700 Subject: [PATCH 148/152] SAM3/4 UDP: Remove redundant EP state assignment. --- arch/arm/src/sam34/sam_udp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index 6fe76f4f57b..b8fc4f2611a 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -1873,7 +1873,6 @@ static void sam_ep_bankinterrupt(struct sam_usbdev_s *priv, * transferred from the FIFO. */ - privep->epstate = UDP_EPSTATE_IDLE; (void)sam_req_read(priv, privep, pktsize, bank); } From c0fa319f2b729f313347d80138852ef683861264 Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 23 Jul 2016 16:19:05 -0700 Subject: [PATCH 149/152] SAM3/4 UDP: Fix handling of endpoint RX FIFO banks. This fixes a race condition where the HW fills a FIFO bank while the SW is busy, resulting in out of sequence USB packets. --- arch/arm/src/sam34/sam_udp.c | 88 ++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index b8fc4f2611a..ed2016ea518 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -305,6 +305,7 @@ struct sam_ep_s uint8_t zlpneeded:1; /* Zero length packet needed at end of transfer */ uint8_t zlpsent:1; /* Zero length packet has been sent */ uint8_t txbusy:1; /* Write request queue is busy (recursion avoidance kludge) */ + uint8_t lastbank:1; /* Last bank we read data from */ }; struct sam_usbdev_s @@ -1188,9 +1189,14 @@ static int sam_req_read(struct sam_usbdev_s *priv, struct sam_ep_s *privep, /* We get here when an RXDATABK0/1 interrupt occurs. That interrupt * cannot be cleared until all of the data has been taken from the RX - * FIFO. But we can + * FIFO. + * + * Also, we need to remember which bank we read last so the interrupt handler + * can determine the correct bank read sequence for future reads. */ + privep->lastbank = bank; + sam_csr_clrbits(epno, bank ? UDPEP_CSR_RXDATABK1 : UDPEP_CSR_RXDATABK0); /* Complete the transfer immediately and give the data to the class @@ -2019,34 +2025,75 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno) } } - /* OUT packet received in data bank 0 */ - if ((csr & UDPEP_CSR_RXDATABK0) != 0) + /* OUT packet received. + * + * OUT packets are received in two banks. The hardware does not provide + * information about which bank has been filled last. Therefore we need to + * keep track about which bank we read last to figure out which bank(s) we + * need to read next. + * + * When we get here either none, one or both banks can be filled with data. + * Depending on which bank we read last and which bank(s) contain data we + * need to correctly sequence the FIFO reads: + * + * case lastbank bk0 bk1 read sequence + * 1. 0 0 0 No data to read + * 2. 0 1 0 Only read bank 0 + * 3. 0 0 1 Only read bank 1 + * 4. 0 1 1 Read bank 1, then read bank 0 + * + * 5. 1 0 0 No data to read + * 6. 1 1 0 Only read bank 0 + * 7. 1 0 1 Only read bank 1 (should not happen) + * 8. 1 1 1 Read bank 0, then read bank 1 + * + * lastbank will be updated in sam_req_read() after the FIFO has been read + * and clear RXDATABKx. + */ + + bool bk0 = (csr & UDPEP_CSR_RXDATABK0) != 0; + bool bk1 = (csr & UDPEP_CSR_RXDATABK1) != 0; + + /* 2. and 6. - Only read bank 0 */ + if (bk0 && !bk1) { usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); - - /* Handle data received on Bank 0. sam_ep_bankinterrupt will - * clear the RXDATABK0 interrupt once that data has been - * transferred from the FIFO. - */ - sam_ep_bankinterrupt(priv, privep, csr, 0); } - - /* OUT packet received in data bank 1 */ - - else if ((csr & UDPEP_CSR_RXDATABK1) != 0) + /* 3. and 7. - Only read bank 1*/ + else if (!bk0 && bk1) { +#ifdef CONFIG_DEBUG + if (privep->lastbank == 1) + { + ulldbg("Unexpected USB RX case.\n"); + } +#endif usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK1), (uint16_t)csr); - DEBUGASSERT(SAM_UDP_NBANKS(epno) > 1); - - /* Handle data received on Bank 1. sam_ep_bankinterrupt will - * clear the RXDATABK1 interrupt once that data has been - * transferred from the FIFO. - */ - sam_ep_bankinterrupt(priv, privep, csr, 1); } + else if (bk0 && bk1) + { + /* 4. - Read bank 1, then read bank 0 */ + if (privep->lastbank == 0) + { + usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK1), (uint16_t)csr); + sam_ep_bankinterrupt(priv, privep, csr, 1); + + usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); + sam_ep_bankinterrupt(priv, privep, csr, 0); + } + /* 8. - Read bank 0, then read bank 1 */ + else + { + usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); + sam_ep_bankinterrupt(priv, privep, csr, 0); + + usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK1), (uint16_t)csr); + sam_ep_bankinterrupt(priv, privep, csr, 1); + } + } /* STALL sent */ @@ -2509,6 +2556,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) privep->zlpneeded = false; privep->zlpsent = false; privep->txbusy = false; + privep->lastbank = 1; } /**************************************************************************** From fe678cf35192e805644e87852eba41f56719fd64 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 24 Jul 2016 07:39:27 -0600 Subject: [PATCH 150/152] Trivial change to a comment (only committed so that I can merge) --- include/nuttx/ioexpander/gpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nuttx/ioexpander/gpio.h b/include/nuttx/ioexpander/gpio.h index 6436a2d13f6..6cd73816068 100644 --- a/include/nuttx/ioexpander/gpio.h +++ b/include/nuttx/ioexpander/gpio.h @@ -120,7 +120,7 @@ struct gpio_dev_s FAR const struct gpio_operations_s *gp_ops; - /* Device specific information may follow */ + /* Device specific, lower-half information may follow */ }; /**************************************************************************** From e895e19b9f8299ad826796e20d7468e73eda682e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 24 Jul 2016 07:45:46 -0600 Subject: [PATCH 151/152] Minor changes from review of last PR --- arch/arm/src/sam34/sam_udp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index ed2016ea518..96a521d0ba5 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -1964,6 +1964,8 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno) struct sam_ep_s *privep; uintptr_t regaddr; uint32_t csr; + bool bk0; + bool bk1; DEBUGASSERT((unsigned)epno < SAM_UDP_NENDPOINTS); @@ -2052,30 +2054,35 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno) * and clear RXDATABKx. */ - bool bk0 = (csr & UDPEP_CSR_RXDATABK0) != 0; - bool bk1 = (csr & UDPEP_CSR_RXDATABK1) != 0; + bk0 = (csr & UDPEP_CSR_RXDATABK0) != 0; + bk1 = (csr & UDPEP_CSR_RXDATABK1) != 0; /* 2. and 6. - Only read bank 0 */ + if (bk0 && !bk1) { usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); sam_ep_bankinterrupt(priv, privep, csr, 0); } + /* 3. and 7. - Only read bank 1*/ + else if (!bk0 && bk1) { -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_USB_WARN if (privep->lastbank == 1) { - ulldbg("Unexpected USB RX case.\n"); + uwarn("WARNING: Unexpected USB RX case.\n"); } #endif + usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK1), (uint16_t)csr); sam_ep_bankinterrupt(priv, privep, csr, 1); } else if (bk0 && bk1) { /* 4. - Read bank 1, then read bank 0 */ + if (privep->lastbank == 0) { usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK1), (uint16_t)csr); @@ -2084,7 +2091,9 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno) usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); sam_ep_bankinterrupt(priv, privep, csr, 0); } + /* 8. - Read bank 0, then read bank 1 */ + else { usbtrace(TRACE_INTDECODE(SAM_TRACEINTID_RXDATABK0), (uint16_t)csr); From 88cb41a0dc37188d96543040fbd17a3fb2376b1b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 24 Jul 2016 07:52:33 -0600 Subject: [PATCH 152/152] configs/stm32f4discovery/canard: Change version to lastet. Need to match change to apps/libcanard/Kconfig --- configs/stm32f4discovery/canard/defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/stm32f4discovery/canard/defconfig b/configs/stm32f4discovery/canard/defconfig index 0c49de3a101..631e039585e 100644 --- a/configs/stm32f4discovery/canard/defconfig +++ b/configs/stm32f4discovery/canard/defconfig @@ -997,7 +997,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_CANUTILS_CANLIB is not set CONFIG_CANUTILS_LIBCANARD=y CONFIG_LIBCANARD_URL="https://github.com/UAVCAN/libcanard/archive" -CONFIG_LIBCANARD_VERSION="b28bf6ac337e55d49037fd9904d4b951760c4690" +CONFIG_LIBCANARD_VERSION="e4a1d52be862b03e5872add75890e67bf1d9187c" # # Examples