From c67fdb87f7f731d13050f752acf1c35e51766c05 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 21 Dec 2012 20:09:32 +0000 Subject: Patches from Petteri Aimonen (plus a few other things) git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5448 42af7a65-404d-4744-a932-0658087f49c3 --- apps/NxWidgets/Kconfig | 261 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 238 insertions(+), 23 deletions(-) (limited to 'apps') diff --git a/apps/NxWidgets/Kconfig b/apps/NxWidgets/Kconfig index 59d8856bc..656399199 100644 --- a/apps/NxWidgets/Kconfig +++ b/apps/NxWidgets/Kconfig @@ -13,6 +13,18 @@ config NXWIDGETS if NXWIDGETS comment "NX Server/Device Configuration" +config NXWIDGETS_FLICKERFREE + bool "Enable Flicker Reduction Logic" + default y if NX_LCDDRIVER + default n if !NX_LCDDRIVER + ---help--- + Because of their performance an in the manner in which they are + updated, LCDs may be prone to "flicker" in the displays when Widgets + are updated. Often more complex (and slower) options are availble + to reduce the flicker. Enabling this option will enabled those + lower-performance flicker-reductions measures where-ever thay may + be available. + config NXWIDGETS_DEVNO int "LCD Device Number" default 0 @@ -96,10 +108,20 @@ config NXWIDGETS_SIZEOFCHAR comment "NXWidget Default Values" +config NXWIDGETS_SYSTEM_CUSTOM_FONTID + bool "Use a Custom Default Font" + default n + ---help--- + Set to override the system default font id (NXFONT_DEFAULT). + +if NXWIDGETS_SYSTEM_CUSTOM_FONTID config NXWIDGETS_DEFAULT_FONTID int "Default Font ID" + default 0 ---help--- - Default font ID. Default: NXFONT_DEFAULT + Use this default NxWidgets font ID instead of the system font ID + (NXFONT_DEFAULT). Default: 0 +endif config NXWIDGETS_TNXARRAY_INITIALSIZE int "Initial Size of Dynamic Arrays" @@ -113,53 +135,88 @@ config NXWIDGETS_TNXARRAY_SIZEINCREMENT ---help--- Default dynamic array realloctino increment (in entries). Default: 8 +config NXWIDGETS_CUSTOM_FILLCOLORS + bool "Custom Default Fill Colors" + default n + ---help--- + Select custom default colors for the widget background. If defined, + the hexadecimal values for all filled colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n + +if NXWIDGETS_CUSTOM_FILLCOLORS config NXWIDGETS_DEFAULT_BACKGROUNDCOLOR - hex "Normal Background Color" + hex "Default Normal Background Color" ---help--- Normal background color. Default: RGB(148,189,215) config NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR - hex "Selected Background Color" + hex "Default Selected Background Color" ---help--- Default selected background color. Default: RGB(206,227,241) +config NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR + hex "Default Highlight Color" + ---help--- + Highlight color. Currently this color is only used in clist + boxes, progress bars, and slider grips. Default: RGB(192,192,192) +endif + +config NXWIDGETS_CUSTOM_EDGECOLORS + bool "Custom Default Edge Colors" + default n + ---help--- + Select custom default colors for the widget edges. If defined, + then hexadecimal values for all edge colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n. + +if NXWIDGETS_CUSTOM_EDGECOLORS config NXWIDGETS_DEFAULT_SHINEEDGECOLOR - hex "Shiny Edge Color" + hex "Default Shiny Edge Color" ---help--- Shiny side boarder color. Default: RGB(248,248,248) config NXWIDGETS_DEFAULT_SHADOWEDGECOLOR - hex "Shadow Edge Color" + hex "Default Shadow Edge Color" ---help--- Shadowed side border color. Default: RGB(35,58,73) +endif -config NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR - hex "Highlight Color" +config NXWIDGETS_CUSTOM_TEXTCOLORS + bool "Custom Default Text colors" + default n ---help--- - Highlight color. Default: RGB(192,192,192) + Select custom colors for the widget text. If defined, then + hexadecimal values for all text colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n. +if NXWIDGETS_CUSTOM_TEXTCOLORS config NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR - hex "Disabled Text Color" + hex "Default Disabled Text Color" ---help--- Text color on a disabled widget: Default: RGB(192,192,192) config NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR - hex "Enabled Text Color" + hex "Default Enabled Text Color" ---help--- Text color on a enabled widget. Default: RGB(248,248,248) config NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR - hex "Selected Text Color" + hex "Default Selected Text Color" ---help--- Text color on a selected widget. Default: RGB(0,0,0) config NXWIDGETS_DEFAULT_FONTCOLOR - hex "Default Font Color" + hex "Default Default Font Color" ---help--- Default font color. Default: RGB(255,255,255) +endif config NXWIDGETS_TRANSPARENT_COLOR hex "Transparent Color" + default 0x0 ---help--- Transparent color. Default: RGB(0,0,0) @@ -220,10 +277,20 @@ config NXWM if NXWM comment "General settings" +config NXWM_SYSTEM_CUSTOM_FONTID + bool "Use Custom Default Font" + default n + ---help--- + Set to override the system default font id (NXFONT_DEFAULT). + +if NXWM_SYSTEM_CUSTOM_FONTID config NXWM_DEFAULT_FONTID int "Font ID" + default 0 ---help--- - The NxWM default font ID. Default: NXFONT_DEFAULT + Use this NxWM default font ID instead of the system font ID + (NXFONT_DEFAULT). Default: 0 +endif config NXWM_UNITTEST bool "NxWM Unit Test" @@ -233,6 +300,16 @@ config NXWM_UNITTEST comment "Color configuration" +config NXWM_CUSTOM_FILLCOLORS + bool "Custom Default Fill Colors" + default n + ---help--- + Select custom default colors for the widget background. If defined, + the hexadecimal values for all filled colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n + +if NXWM_CUSTOM_FILLCOLORS config NXWM_DEFAULT_BACKGROUNDCOLOR hex "Background Color" ---help--- @@ -242,7 +319,18 @@ config NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR hex "Normal Background Color" ---help--- Select background color. Default: RGB(206,227,241) +endif +config NXWM_CUSTOM_EDGECOLORS + bool "Custom Default Edge Colors" + default n + ---help--- + Select custom default colors for the widget edges. If defined, + then hexadecimal values for all edge colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n. + +if NXWM_CUSTOM_EDGECOLORS config NXWM_DEFAULT_SHINEEDGECOLOR hex "Shiny Edge Color" ---help--- @@ -252,7 +340,18 @@ config NXWM_DEFAULT_SHADOWEDGECOLOR hex "Shadow Edge Color" ---help--- Color of the shadowed edge of a border. Default: RGB(0,0,0) +endif + +config NXWM_CUSTOM_TEXTCOLORS + bool "Custom Default Text colors" + default n + ---help--- + Select custom colors for the widget text. If defined, then + hexadecimal values for all text colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n. +if NXWM_CUSTOM_TEXTCOLORS config NXWM_DEFAULT_FONTCOLOR hex "Default Font Color" ---help--- @@ -260,8 +359,10 @@ config NXWM_DEFAULT_FONTCOLOR config NXWM_TRANSPARENT_COLOR hex "Transparent Color" + default 0x0 ---help--- The "transparent" color. Default: RGB(0,0,0) +endif comment "Horizontal and vertical spacing of icons in the task bar" @@ -303,27 +404,48 @@ config NXWM_TASKBAR_RIGHT endchoice +config NXWM_CUSTOM_TASKBAR_WIDTH + bool "Use Custom Taskbar width" + default n + ---help--- + Set to override the default taskbar thickness (either vertical or + horizontal). The default depends on the selected horizontal or + vertical spacing. Default: 25 + 2*spacing + +if NXWM_CUSTOM_TASKBAR_WIDTH config NXWM_TASKBAR_WIDTH int "Taskbar Width" + default 29 ---help--- - Task bar thickness (either vertical or horizontal). Default: 25 + 2*spacing + Task bar thickness (either vertical or horizontal). Default: 25 + 2*2 +endif config NXWM_DISABLE_MINIMIZE bool "Disable Minimize Button" default n ---help--- - If the "desktop" is empty, users have no need to minimize any windows. If the buttons - are small, it's easy to hit minimize button accidentally when trying to close an - application. + If the "desktop" is empty, users have no need to minimize any + windows. If the buttons are small, it's easy to hit minimize + button accidentally when trying to close an application. comment "Tool Bar Configuration" +config NXWM_CUSTOM_TOOLBAR_HEIGHT + bool "Use Custom Toolbar Height" + default n + ---help--- + Set to override the default tooldar height The default depends on + the selected horizontal or vertical spacing. Default: 21 + 2*spacing + +if NXWM_CUSTOM_TOOLBAR_HEIGHT config NXWM_TOOLBAR_HEIGHT int "Toolbar Height" + default 25 ---help--- The height of the tool bar in each application window. At present, all icons are 21 pixels in height and, hence, require a task bar of - at least that size. + at least that size. Default: 21 + 2*2 +endif comment "Background Image" @@ -357,10 +479,19 @@ config NXWM_STARTWINDOW_HSPACING ---help--- Horizontal spacing. Default: 4 rows +config NXWM_CUSTOM_STARTWINDOW_ICON + bool "Custom Start Window Icon" + default n + ---help--- + Select to override the default Start Window Icon: NxWM::g_playBitmap + +if NXWM_CUSTOM_STARTWINDOW_ICON config NXWM_STARTWINDOW_ICON string "StartWindow Icon" + default "NxWM::g_playBitmap" ---help--- The glyph to use as the start window icon. Default: NxWM::g_playBitmap +endif config NXWM_STARTWINDOW_MQNAME string "Message Queue Name" @@ -417,6 +548,16 @@ config NXWM_NXCONSOLE_STACKSIZE The stack size to use when starting the NxConsole task. Default: 2048 bytes. +config NXWM_NXCONSOLE_CUSTOM_COLORS + bool "Custom NxConsole Colors" + default n + ---help--- + Select custom default colors for the NxConsole window. If defined, + the hexadecimal values for all NxConsole colors must be provided + (there are no default colors because the hexadecimal representation + of the default colors depend on the pixel depth). Default: n + +if NXWM_NXCONSOLE_CUSTOM_COLORS config NXWM_NXCONSOLE_WCOLOR hex "NxConsole Background Color" ---help--- @@ -428,17 +569,36 @@ config NXWM_NXCONSOLE_FONTCOLOR ---help--- The color of the fonts to use in the NxConsole window. Default: RGB(0,0,0) +endif +config NXWM_NXCONSOLE_CUSTOM_FONTID + bool "Use Custom Default Font" + default n + ---help--- + Set to override the system default font id (NXWM_DEFAULT_FONTID). + +if NXWM_NXCONSOLE_CUSTOM_FONTID config NXWM_NXCONSOLE_FONTID int "NxConsole Font ID" + default 0 ---help--- - The ID of the font to use in the NxConsole window. Default: - NXWM_DEFAULT_FONTID + Use this default font ID in the NxConsole window instead of the + NxWM font ID (NXWM_DEFAULT_FONTID). Default: 0 +endif +config NXWM_CUSTOM_NXCONSOLE_ICON + bool "Custom NxConsole Icon" + default n + ---help--- + Select to override the default NxConsole Window Icon: NxWM::g_cmdBitmap + +if NXWM_CUSTOM_NXCONSOLE_ICON config NXWM_NXCONSOLE_ICON string "NxConsole Icon" + default "NxWM::g_cmdBitmap" ---help--- The glyph to use as the NxConsole icon. Default: NxWM::g_cmdBitmap +endif config NXWM_TOUCHSCREEN bool "Touchscreen Support" @@ -478,6 +638,7 @@ config NXWM_TOUCHSCREEN_LISTENERPRIO config NXWM_TOUCHSCREEN_LISTENERSTACK int "Touchscreen Listener Task Stack Size" + default 1024 ---help--- Touchscreen listener thread stack size. Default 1024 @@ -527,6 +688,17 @@ endif comment "Calibration display settings" +config NXWM_CALIBRATION_CUSTOM_COLORS + bool "Custom Calibration Colors" + default n + ---help--- + Select custom default colors for the calibration window. If + defined, the hexadecimal values for all calibration window + colors must be provided (there are no default colors because + the hexadecimal representation of the default colors depend + on the pixel depth). Default: n + +if NXWM_CALIBRATION_CUSTOM_COLORS config NXWM_CALIBRATION_BACKGROUNDCOLOR hex "Background Color" ---help--- @@ -550,12 +722,23 @@ config NXWM_CALIBRATION_TOUCHEDCOLOR ---help--- The color of the circle in the touchscreen calibration display after the touch is recorder. Default: RGB(255, 255, 96) (very light yellow) +endif + +config NXWM_CUSTOM_CALIBRATION_ICON + bool "Custom Calibration Icon" + default n + ---help--- + Select to override the default Calibration Window Icon: + NxWM::g_calibrationBitmap +if NXWM_CUSTOM_CALIBRATION_ICON config NXWM_CALIBRATION_ICON string "Callibration Icon" + default "NxWM::g_calibrationBitmap" ---help--- The ICON to use for the touchscreen calibration application. Default: NxWM::g_calibrationBitmap +endif config NXWM_CALIBRATION_SIGNO int "Calibration Signal Number" @@ -576,23 +759,55 @@ config NXWM_CALIBRATION_LISTENERSTACK ---help--- Calibration listener thread stack size. Default 2048 -comment "Calibration display settings" +comment "Hex Calculator display settings" +config NXWM_HEXCALCULATOR_CUSTOM_COLORS + bool "Custom Hex Calculator Colors" + default n + ---help--- + Select custom default colors for the Hex Calcualtor window. If + defined, the hexadecimal values for all hex calculator colors + must be provided (there are no default colors because the + hexadecimal representation of the default colors depend on the + pixel depth). Default: n + +if NXWM_HEXCALCULATOR_CUSTOM_COLORS config NXWM_HEXCALCULATOR_BACKGROUNDCOLOR hex "Calculator Background Color" ---help--- The background color of the calculator display. Default: Same as NXWM_DEFAULT_BACKGROUNDCOLOR +endif +config NXWM_CUSTOM_HEXCALCULATOR_ICON + bool "Custom Hex Calculator Icon" + default n + ---help--- + Select to override the default Hex Calculator Window Icon: + NxWM::g_calculatorBitmap + +if NXWM_CUSTOM_HEXCALCULATOR_ICON config NXWM_HEXCALCULATOR_ICON string "Calculator Icon" + default "NxWM::g_calculatorBitmap" ---help--- The ICON to use for the hex calculator application. Default: - NxWM::g_calculatorBitmap + "NxWM::g_calculatorBitmap" +endif +config NXWM_HEXCALCULATOR_CUSTOM_FONTID + bool "Use Custom Default Font" + default n + ---help--- + Set to override the system default font id (NXWM_DEFAULT_FONTID). + +if NXWM_HEXCALCULATOR_CUSTOM_FONTID config NXWM_HEXCALCULATOR_FONTID int "Calculator Font ID" + default 0 ---help--- - The font used with the calculator. Default: NXWM_DEFAULT_FONTID + Use this default font ID in the calculator window instead of the + NxWM font ID (NXWM_DEFAULT_FONTID). Default: 0 +endif endif -- cgit v1.2.3 From edb3871913d4fa7d6ef0f01827a194d6362c3c71 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 23 Dec 2012 17:35:06 +0000 Subject: Remove some dependencies of distclean on clean. This should not be necessary in higher level makefiles and should speed up make distclean git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5453 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 5 +++++ apps/Makefile | 2 +- apps/examples/Makefile | 2 +- apps/interpreters/Makefile | 2 +- apps/netutils/Makefile | 2 +- apps/system/Makefile | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 0695747f8..614538ad5 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -435,3 +435,8 @@ logic to find the absolute path to the program using the PATH variable. 6.25 2013-xx-xx Gregory Nutt + + * Makefiles: Removed dependency of distclean on clean in most top-level + files. It makes sense for 'leaf' Makefiles to have this dependency, + but it does not make sense for upper-level Makefiles. + diff --git a/apps/Makefile b/apps/Makefile index 353894b7f..0973d64b5 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -177,7 +177,7 @@ endif $(call DELFILE, $(BIN)) $(call CLEAN) -distclean: # clean +distclean: ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) for %%G in ($(SUBDIRS)) do ( \ $(MAKE) -C %%G distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \ diff --git a/apps/examples/Makefile b/apps/examples/Makefile index bdbfd4de8..50e9596d7 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -120,7 +120,7 @@ depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend) clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean) -distclean: clean $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) +distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) -include Make.dep diff --git a/apps/interpreters/Makefile b/apps/interpreters/Makefile index 867d45f99..f78528714 100644 --- a/apps/interpreters/Makefile +++ b/apps/interpreters/Makefile @@ -73,4 +73,4 @@ depend: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_depend) clean: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_clean) -distclean: clean $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_distclean) +distclean: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_distclean) diff --git a/apps/netutils/Makefile b/apps/netutils/Makefile index 0879ada4e..781770fc1 100644 --- a/apps/netutils/Makefile +++ b/apps/netutils/Makefile @@ -64,4 +64,4 @@ depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend) clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean) -distclean: clean $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) +distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) diff --git a/apps/system/Makefile b/apps/system/Makefile index 9955a6b2c..057fbcf77 100644 --- a/apps/system/Makefile +++ b/apps/system/Makefile @@ -73,4 +73,4 @@ depend: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_depend) clean: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_clean) -distclean: clean $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_distclean) +distclean: $(foreach SDIR, $(INSTALLED_DIRS), $(SDIR)_distclean) -- cgit v1.2.3 From 5cfde412bb9cbd55db2854939d25c2d8e053aaa5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 23 Dec 2012 20:22:41 +0000 Subject: Rename namedapp as simply builtin git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5454 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 1 + apps/Kconfig | 4 +- apps/Make.defs | 4 +- apps/Makefile | 14 +- apps/README.txt | 30 +- apps/builtin/Kconfig | 15 + apps/builtin/Make.defs | 40 ++ apps/builtin/Makefile | 110 ++++ apps/builtin/binfs.c | 596 +++++++++++++++++++++ apps/builtin/builtin.c | 96 ++++ apps/builtin/builtin.h | 77 +++ apps/builtin/exec_builtin.c | 187 +++++++ apps/include/apps.h | 18 +- apps/namedapp/Kconfig | 15 - apps/namedapp/Make.defs | 40 -- apps/namedapp/Makefile | 110 ---- apps/namedapp/binfs.c | 596 --------------------- apps/namedapp/exec_namedapp.c | 187 ------- apps/namedapp/namedapp.c | 96 ---- apps/namedapp/namedapp.h | 78 --- apps/nshlib/Kconfig | 8 +- apps/nshlib/README.txt | 2 +- apps/nshlib/nsh_apps.c | 6 +- apps/nshlib/nsh_parse.c | 8 +- nuttx/Documentation/NuttShell.html | 79 ++- nuttx/configs/cloudctrl/nsh/defconfig | 2 +- nuttx/configs/ez80f910200kitg/ostest/defconfig | 2 +- nuttx/configs/ez80f910200zco/ostest/defconfig | 2 +- nuttx/configs/fire-stm32v2/nsh/defconfig | 2 +- nuttx/configs/p112/ostest/defconfig | 2 +- nuttx/configs/shenzhou/nsh/defconfig | 2 +- nuttx/configs/shenzhou/nxwm/defconfig | 2 +- nuttx/configs/shenzhou/thttpd/defconfig | 2 +- nuttx/configs/sim/README.txt | 6 +- nuttx/configs/sim/cxxtest/defconfig | 2 +- nuttx/configs/sim/nxwm/defconfig | 2 +- nuttx/configs/sim/ostest/defconfig | 2 +- nuttx/configs/stm3220g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/discover/defconfig | 2 +- nuttx/configs/stm3240g-eval/xmlrpc/defconfig | 2 +- nuttx/configs/stm32f100rc_generic/nsh/defconfig | 2 +- nuttx/configs/stm32f100rc_generic/ostest/defconfig | 2 +- nuttx/configs/stm32f4discovery/cxxtest/defconfig | 2 +- nuttx/configs/stm32f4discovery/elf/defconfig | 2 +- nuttx/configs/stm32f4discovery/nxlines/defconfig | 2 +- nuttx/configs/stm32f4discovery/ostest/defconfig | 2 +- nuttx/configs/stm32f4discovery/winbuild/defconfig | 2 +- nuttx/configs/vsn/src/README.txt | 5 +- nuttx/configs/xtrs/nsh/defconfig | 2 +- nuttx/configs/xtrs/ostest/defconfig | 2 +- nuttx/configs/xtrs/pashello/defconfig | 2 +- nuttx/configs/z16f2800100zcog/ostest/defconfig | 2 +- nuttx/configs/z16f2800100zcog/pashello/defconfig | 2 +- nuttx/configs/z80sim/nsh/defconfig | 2 +- nuttx/configs/z80sim/ostest/defconfig | 2 +- nuttx/configs/z80sim/pashello/defconfig | 2 +- nuttx/configs/z8encore000zco/ostest/defconfig | 2 +- nuttx/configs/z8f64200100kit/ostest/defconfig | 2 +- nuttx/sched/os_bringup.c | 4 +- 59 files changed, 1247 insertions(+), 1247 deletions(-) create mode 100644 apps/builtin/Kconfig create mode 100644 apps/builtin/Make.defs create mode 100644 apps/builtin/Makefile create mode 100644 apps/builtin/binfs.c create mode 100644 apps/builtin/builtin.c create mode 100644 apps/builtin/builtin.h create mode 100644 apps/builtin/exec_builtin.c delete mode 100644 apps/namedapp/Kconfig delete mode 100644 apps/namedapp/Make.defs delete mode 100644 apps/namedapp/Makefile delete mode 100644 apps/namedapp/binfs.c delete mode 100644 apps/namedapp/exec_namedapp.c delete mode 100644 apps/namedapp/namedapp.c delete mode 100644 apps/namedapp/namedapp.h (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 614538ad5..886526b18 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -439,4 +439,5 @@ * Makefiles: Removed dependency of distclean on clean in most top-level files. It makes sense for 'leaf' Makefiles to have this dependency, but it does not make sense for upper-level Makefiles. + * namedapp/: Renamed to builtins in preparation for another change. diff --git a/apps/Kconfig b/apps/Kconfig index ea9bd2d31..68c36f5a5 100644 --- a/apps/Kconfig +++ b/apps/Kconfig @@ -3,8 +3,8 @@ # see misc/tools/kconfig-language.txt. # -menu "Named Applications" -source "$APPSDIR/namedapp/Kconfig" +menu "Built-In Applications" +source "$APPSDIR/builtin/Kconfig" endmenu menu "Examples" diff --git a/apps/Make.defs b/apps/Make.defs index 53ac7f8be..12b351e7f 100644 --- a/apps/Make.defs +++ b/apps/Make.defs @@ -36,6 +36,6 @@ define REGISTER @echo "Register: $1" - @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/namedapp/namedapp_list.h" - @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/namedapp/namedapp_proto.h" + @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h" + @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h" endef diff --git a/apps/Makefile b/apps/Makefile index 0973d64b5..299560195 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -44,11 +44,11 @@ APPDIR = ${shell pwd} # action. It is created by the configured appconfig file (a copy of which # appears in this directory as .config) # SUBDIRS is the list of all directories containing Makefiles. It is used -# only for cleaning. namedapp must always be the first in the list. This +# only for cleaning. builtin must always be the first in the list. This # list can be extended by the .config file as well. CONFIGURED_APPS = -SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system +SUBDIRS = examples graphics interpreters modbus builtin nshlib netutils system # There are two different mechanisms for obtaining the list of configured # directories: @@ -69,9 +69,9 @@ SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system ifeq ($(CONFIG_NUTTX_NEWCONFIG),y) -# namedapp/Make.defs must be included first +# builtin/Make.defs must be included first -include namedapp/Make.defs +include builtin/Make.defs include examples/Make.defs include graphics/Make.defs include interpreters/Make.defs @@ -82,7 +82,7 @@ include system/Make.defs # INSTALLED_APPS is the list of currently available application directories. It # is the same as CONFIGURED_APPS, but filtered to exclude any non-existent -# application directory. namedapp is always in the list of applications to be +# application directory. builtin is always in the list of applications to be # built. INSTALLED_APPS = @@ -94,10 +94,10 @@ else # INSTALLED_APPS is the list of currently available application directories. It # is the same as CONFIGURED_APPS, but filtered to exclude any non-existent -# application directory. namedapp is always in the list of applications to be +# application directory. builtin is always in the list of applications to be # built. -INSTALLED_APPS = namedapp +INSTALLED_APPS = builtin endif # Create the list of available applications (INSTALLED_APPS) diff --git a/apps/README.txt b/apps/README.txt index 7a379254e..4f043dcfa 100644 --- a/apps/README.txt +++ b/apps/README.txt @@ -6,12 +6,12 @@ Contents General Directory Location - Named Applications - Named Startup main() function + Built-In Applications + Built-In Startup main() function NuttShell (NSH) Built-In Commands Synchronous Built-In Commands Application Configuration File - Example Named Application + Example Built-In Application Building NuttX with Board-Specific Pieces Outside the Source Tree General @@ -47,14 +47,14 @@ ways to do that: path to the application directory on the configuration command line like: ./configure.sh -a / -Named Applications ------------------- +Built-In Applications +--------------------- NuttX also supports applications that can be started using a name string. In this case, application entry points with their requirements are gathered together in two files: - - namedapp/namedapp_proto.h Entry points, prototype function - - namedapp/namedapp_list.h Application specific information and requirements + - builtin/builtin_proto.h Entry points, prototype function + - builtin/builtin_list.h Application specific information and requirements The build occurs in several phases as different build targets are executed: (1) context, (2) depend, and (3) default (all). Application information is @@ -62,18 +62,18 @@ collected during the make context build phase. To execute an application function: - exec_namedapp() is defined in the nuttx/include/apps/apps.h + exec_builtin() is defined in the nuttx/include/apps/apps.h NuttShell (NSH) Built-In Commands --------------------------------- -One use of named applications is to provide a way of invoking your custom +One use of builtin applications is to provide a way of invoking your custom application through the NuttShell (NSH) command line. NSH will support a seamless method invoking the applications, when the following option is enabled in the NuttX configuration file: CONFIG_NSH_BUILTIN_APPS=y -Applications registered in the apps/namedapp/namedapp_list.h file will then +Applications registered in the apps/builtin/builtin_list.h file will then be accessible from the NSH command line. If you type 'help' at the NSH prompt, you will see a list of the registered commands. @@ -109,9 +109,9 @@ CONFIGURED_APPS list like: CONFIGURED_APPS += examples/hello system/poweroff -Named Start-Up main() function +Built-In Start-Up main() function ------------------------------ -A named application can even be used as the main, start-up entry point +A builtin application can even be used as the main, start-up entry point into your embedded software. When the user defines this option in the NuttX configuration file: @@ -124,10 +124,10 @@ will call: int hello_main(int argc, char *argv[]) -Example Named Application -------------------------- +Example Built-In Application +---------------------------- An example application skeleton can be found under the examples/hello -sub-directory. This example shows how a named application can be added +sub-directory. This example shows how a builtin application can be added to the project. One must define: 1. create sub-directory as: appname diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig new file mode 100644 index 000000000..8310e6df9 --- /dev/null +++ b/apps/builtin/Kconfig @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config BUILTIN + bool "Support Builtin Applications" + default n + ---help--- + Enable support for builtin applications. This features assigns a string + name to an application. This feature is also the underlying requirement + to support built-in applications in the NuttShell (NSH). + +if BUILTIN +endif diff --git a/apps/builtin/Make.defs b/apps/builtin/Make.defs new file mode 100644 index 000000000..ab6292cc3 --- /dev/null +++ b/apps/builtin/Make.defs @@ -0,0 +1,40 @@ +############################################################################ +# apps/builtin/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 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. +# +############################################################################ + +ifeq ($(CONFIG_BUILTIN),y) +CONFIGURED_APPS += builtin +endif + diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile new file mode 100644 index 000000000..72ba0347f --- /dev/null +++ b/apps/builtin/Makefile @@ -0,0 +1,110 @@ +############################################################################ +# apps/builtin/Makefile +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# NSH Library + +# Source and object files + +ASRCS = +CSRCS = builtin.c exec_builtin.c + +ifeq ($(CONFIG_APPS_BINDIR),y) +CSRCS += binfs.c +endif + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\libapps$(LIBEXT) +else + BIN = ../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . +VPATH = + +# Build Targets + +all: .built +.PHONY: .context context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch .built + +.context: + @echo "/* List of application requirements, generated during make context. */" > builtin_list.h + @echo "/* List of application entry points, generated during make context. */" > builtin_proto.h + $(Q) touch $@ + +context: .context + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, .context) + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, builtin_list.h) + $(call DELFILE, builtin_proto.h) + +-include Make.dep + diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c new file mode 100644 index 000000000..501f0a4b9 --- /dev/null +++ b/apps/builtin/binfs.c @@ -0,0 +1,596 @@ +/**************************************************************************** + * apps/builtin/binfs.c + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "builtin.h" + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_APPS_BINDIR) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This structure represents the overall mountpoint state. An instance of this + * structure is retained as inode private data on each mountpoint that is + * mounted with a fat32 filesystem. + */ + +struct binfs_state_s +{ + sem_t bm_sem; /* Used to assume thread-safe access */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void binfs_semtake(struct binfs_state_s *bm); +static inline void binfs_semgive(struct binfs_state_s *bm); +static int binfs_open(FAR struct file *filep, const char *relpath, + int oflags, mode_t mode); +static int binfs_close(FAR struct file *filep); +static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); +static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); + +static int binfs_opendir(struct inode *mountpt, const char *relpath, + struct fs_dirent_s *dir); +static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); +static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir); + +static int binfs_bind(FAR struct inode *blkdriver, const void *data, + void **handle); +static int binfs_unbind(void *handle, FAR struct inode **blkdriver); +static int binfs_statfs(struct inode *mountpt, struct statfs *buf); + +static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf); + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/* See fs_mount.c -- this structure is explicitly externed there. + * We use the old-fashioned kind of initializers so that this will compile + * with any compiler. + */ + +const struct mountpt_operations binfs_operations = +{ + binfs_open, /* open */ + binfs_close, /* close */ + binfs_read, /* read */ + NULL, /* write */ + NULL, /* seek */ + binfs_ioctl, /* ioctl */ + NULL, /* sync */ + + binfs_opendir, /* opendir */ + NULL, /* closedir */ + binfs_readdir, /* readdir */ + binfs_rewinddir, /* rewinddir */ + + binfs_bind, /* bind */ + binfs_unbind, /* unbind */ + binfs_statfs, /* statfs */ + + NULL, /* unlink */ + NULL, /* mkdir */ + NULL, /* rmdir */ + NULL, /* rename */ + binfs_stat /* stat */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: binfs_semtake + ****************************************************************************/ + +static void binfs_semtake(struct binfs_state_s *bm) +{ + /* Take the semaphore (perhaps waiting) */ + + while (sem_wait(&bm->bm_sem) != 0) + { + /* The only case that an error should occur here is if + * the wait was awakened by a signal. + */ + + ASSERT(errno == EINTR); + } +} + +/**************************************************************************** + * Name: binfs_semgive + ****************************************************************************/ + +static inline void binfs_semgive(struct binfs_state_s *bm) +{ + sem_post(&bm->bm_sem); +} + +/**************************************************************************** + * Name: binfs_open + ****************************************************************************/ + +static int binfs_open(FAR struct file *filep, const char *relpath, + int oflags, mode_t mode) +{ + struct binfs_state_s *bm; + int ret = -ENOSYS; + + fvdbg("Open '%s'\n", relpath); + + /* Sanity checks */ + + DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL); + + /* mountpoint private data from the inode reference from the file + * structure + */ + + bm = (struct binfs_state_s*)filep->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* BINFS is read-only. Any attempt to open with any kind of write + * access is not permitted. + */ + + if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) + { + fdbg("Only O_RDONLY supported\n"); + ret = -EACCES; + } + + /* Save open-specific state in filep->f_priv */ + + /* Opening of elements within the pseudo-file system is not yet supported */ + + return ret; +} + +/**************************************************************************** + * Name: binfs_close + ****************************************************************************/ + +static int binfs_close(FAR struct file *filep) +{ + struct binfs_state_s *bm; + int ret = -ENOSYS; + + fvdbg("Closing\n"); + + /* Sanity checks */ + + DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); + + /* Recover the open file state from the struct file instance */ + /* bf = filep->f_priv; */ + + /* Recover the file system state from the inode */ + + bm = filep->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* Free the open file state */ + /* free(bf); */ + + filep->f_priv = NULL; + + /* Since open() is not yet supported, neither is close(). */ + + return ret; +} + +/**************************************************************************** + * Name: binfs_read + ****************************************************************************/ + +static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) +{ + struct binfs_state_s *bm; + + fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); + + /* Sanity checks */ + + DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); + + /* Recover the open file state data from the struct file instance */ + /* bf = filep->f_priv; */ + + /* Recover the file system state from the inode */ + + bm = filep->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* Since open is not yet supported, neither is reading */ + + return -ENOSYS; +} + +/**************************************************************************** + * Name: binfs_ioctl + ****************************************************************************/ + +static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + struct binfs_state_s *bm; + + fvdbg("cmd: %d arg: %08lx\n", cmd, arg); + + /* Sanity checks */ + + DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); + + /* Recover the open file state from the struct file instance */ + /* bf = filep->f_priv; */ + + /* Recover the file system state from the inode */ + + bm = filep->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* No ioctl commands yet supported */ + + return -ENOTTY; +} + +/**************************************************************************** + * Name: binfs_opendir + * + * Description: + * Open a directory for read access + * + ****************************************************************************/ + +static int binfs_opendir(struct inode *mountpt, const char *relpath, + struct fs_dirent_s *dir) +{ + struct binfs_state_s *bm; + int ret; + + fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL"); + + /* Sanity checks */ + + DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); + + /* Recover the file system state from the inode instance */ + + bm = mountpt->i_private; + binfs_semtake(bm); + + /* The requested directory must be the volume-relative "root" directory */ + + if (relpath && relpath[0] != '\0') + { + ret = -ENOENT; + goto errout_with_semaphore; + } + + /* Set the index to the first entry */ + + dir->u.binfs.fb_index = 0; + ret = OK; + +errout_with_semaphore: + binfs_semgive(bm); + return ret; +} + +/**************************************************************************** + * Name: binfs_readdir + * + * Description: Read the next directory entry + * + ****************************************************************************/ + +static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) +{ + struct binfs_state_s *bm; + unsigned int index; + int ret; + + /* Sanity checks */ + + DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); + + /* Recover the file system state from the inode instance */ + + bm = mountpt->i_private; + binfs_semtake(bm); + + /* Have we reached the end of the directory */ + + index = dir->u.binfs.fb_index; + if (builtins[index].name == NULL) + { + /* We signal the end of the directory by returning the + * special error -ENOENT + */ + + fvdbg("Entry %d: End of directory\n", index); + ret = -ENOENT; + } + else + { + /* Save the filename and file type */ + + fvdbg("Entry %d: \"%s\"\n", index, builtins[index].name); + dir->fd_dir.d_type = DTYPE_FILE; + strncpy(dir->fd_dir.d_name, builtins[index].name, NAME_MAX+1); + + /* The application list is terminated by an entry with a NULL name. + * Therefore, there is at least one more entry in the list. + */ + + index++; + + /* Set up the next directory entry offset. NOTE that we could use the + * standard f_pos instead of our own private fb_index. + */ + + dir->u.binfs.fb_index = index; + ret = OK; + } + + binfs_semgive(bm); + return ret; +} + +/**************************************************************************** + * Name: binfs_rewindir + * + * Description: Reset directory read to the first entry + * + ****************************************************************************/ + +static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) +{ + struct binfs_state_s *bm; + + fvdbg("Entry\n"); + + /* Sanity checks */ + + DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); + + /* Recover the file system state from the inode instance */ + + bm = mountpt->i_private; + binfs_semtake(bm); + + dir->u.binfs.fb_index = 0; + + binfs_semgive(bm); + return OK; +} + +/**************************************************************************** + * Name: binfs_bind + * + * Description: This implements a portion of the mount operation. This + * function allocates and initializes the mountpoint private data and + * binds the blockdriver inode to the filesystem private data. The final + * binding of the private data (containing the blockdriver) to the + * mountpoint is performed by mount(). + * + ****************************************************************************/ + +static int binfs_bind(FAR struct inode *blkdriver, const void *data, + void **handle) +{ + struct binfs_state_s *bm; + + fvdbg("Entry\n"); + + /* Create an instance of the mountpt state structure */ + + bm = (struct binfs_state_s *)zalloc(sizeof(struct binfs_state_s)); + if (!bm) + { + fdbg("Failed to allocate mountpoint structure\n"); + return -ENOMEM; + } + + /* Initialize the allocated mountpt state structure. The filesystem is + * responsible for one reference ont the blkdriver inode and does not + * have to addref() here (but does have to release in ubind(). + */ + + sem_init(&bm->bm_sem, 0, 1); /* Initialize the semaphore that controls access */ + + /* Mounted! */ + + *handle = (void*)bm; + return OK; +} + +/**************************************************************************** + * Name: binfs_unbind + * + * Description: This implements the filesystem portion of the umount + * operation. + * + ****************************************************************************/ + +static int binfs_unbind(void *handle, FAR struct inode **blkdriver) +{ + struct binfs_state_s *bm = (struct binfs_state_s*)handle; + + fvdbg("Entry\n"); + +#ifdef CONFIG_DEBUG + if (!bm) + { + return -EINVAL; + } +#endif + + /* Check if there are sill any files opened on the filesystem. */ + + /* Release the mountpoint private data */ + + sem_destroy(&bm->bm_sem); + return OK; +} + +/**************************************************************************** + * Name: binfs_statfs + * + * Description: Return filesystem statistics + * + ****************************************************************************/ + +static int binfs_statfs(struct inode *mountpt, struct statfs *buf) +{ + struct binfs_state_s *bm; + + fvdbg("Entry\n"); + + /* Sanity checks */ + + DEBUGASSERT(mountpt && mountpt->i_private); + + /* Get the mountpoint private data from the inode structure */ + + bm = mountpt->i_private; + binfs_semtake(bm); + + /* Fill in the statfs info */ + + memset(buf, 0, sizeof(struct statfs)); + buf->f_type = BINFS_MAGIC; + buf->f_bsize = 0; + buf->f_blocks = 0; + buf->f_bfree = 0; + buf->f_bavail = 0; + buf->f_namelen = NAME_MAX; + + binfs_semgive(bm); + return OK; +} + +/**************************************************************************** + * Name: binfs_stat + * + * Description: Return information about a file or directory + * + ****************************************************************************/ + +static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) +{ + struct binfs_state_s *bm; + int ret; + + fvdbg("Entry\n"); + + /* Sanity checks */ + + DEBUGASSERT(mountpt && mountpt->i_private); + + /* Get the mountpoint private data from the inode structure */ + + bm = mountpt->i_private; + binfs_semtake(bm); + + /* The requested directory must be the volume-relative "root" directory */ + + if (relpath && relpath[0] != '\0') + { + /* Check if there is a file with this name. */ + + if (builtin_isavail(relpath) < 0) + { + ret = -ENOENT; + goto errout_with_semaphore; + } + + /* It's a execute-only file name */ + + buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; + } + else + { + /* It's a read/execute-only directory name */ + + buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; + } + + /* File/directory size, access block size */ + + buf->st_size = 0; + buf->st_blksize = 0; + buf->st_blocks = 0; + ret = OK; + +errout_with_semaphore: + binfs_semgive(bm); + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_APPS_BINDIR */ + diff --git a/apps/builtin/builtin.c b/apps/builtin/builtin.c new file mode 100644 index 000000000..a6ed7dd3f --- /dev/null +++ b/apps/builtin/builtin.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * apps/builtin/builtin.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Authors: Uros Platise + * 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 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#include "builtin_proto.h" + +const struct builtin_s builtins[] = +{ +# include "builtin_list.h" + { NULL, 0, 0, 0 } +}; + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int number_builtins(void) +{ + return sizeof(builtins)/sizeof(struct builtin_s) - 1; +} + + diff --git a/apps/builtin/builtin.h b/apps/builtin/builtin.h new file mode 100644 index 000000000..3f7ddd7ce --- /dev/null +++ b/apps/builtin/builtin.h @@ -0,0 +1,77 @@ +/**************************************************************************** + * apps/builtin/builtin.h + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Authors: Uros Platise + * 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 __APPS_BUILTIN_BUILTIN_H +#define __APPS_BUILTIN_BUILTIN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN const struct builtin_s builtins[]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +EXTERN int number_builtins(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __APPS_BUILTIN_BUILTIN_H */ + diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c new file mode 100644 index 000000000..dc3630230 --- /dev/null +++ b/apps/builtin/exec_builtin.c @@ -0,0 +1,187 @@ +/**************************************************************************** + * apps/builtin/exec_builtin.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With updates, modifications, and general maintenance by: + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Auther: 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 "builtin.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_getname + * + * Description: + * Return the name of the application at index in the table of builtin + * applications. + * + ****************************************************************************/ + +const char *builtin_getname(int index) +{ + if (index < 0 || index >= number_builtins()) + { + return NULL; + } + + return builtins[index].name; +} + +/**************************************************************************** + * Name: builtin_isavail + * + * Description: + * Return the index into the table of applications for the applicaiton with + * the name 'appname'. + * + ****************************************************************************/ + +int builtin_isavail(FAR const char *appname) +{ + int i; + + for (i = 0; builtins[i].name; i++) + { + if (!strcmp(builtins[i].name, appname)) + { + return i; + } + } + + set_errno(ENOENT); + return ERROR; +} + +/**************************************************************************** + * Name: builtin_isavail + * + * Description: + * Execute the application with name 'appname', providing the arguments + * in the argv[] array. + * + * Returned Value: + * On success, the task ID of the builtin application is returned. On + * failure, -1 (ERROR) is returned an the errno value is set appropriately. + * + ****************************************************************************/ + +int exec_builtin(FAR const char *appname, FAR const char **argv) +{ + pid_t pid; + int index; + + /* Verify that an application with this name exists */ + + index = builtin_isavail(appname); + if (index >= 0) + { + /* Disable pre-emption. This means that although we start the builtin + * application here, it will not actually run until pre-emption is + * re-enabled below. + */ + + sched_lock(); + + /* Start the builtin application task */ + + pid = TASK_CREATE(builtins[index].name, builtins[index].priority, + builtins[index].stacksize, builtins[index].main, + (argv) ? &argv[1] : (const char **)NULL); + + /* If robin robin scheduling is enabled, then set the scheduling policy + * of the new task to SCHED_RR before it has a chance to run. + */ + +#if CONFIG_RR_INTERVAL > 0 + if (pid > 0) + { + struct sched_param param; + + /* Pre-emption is disabled so the task creation and the + * following operation will be atomic. The priority of the + * new task cannot yet have changed from its initial value. + */ + + param.sched_priority = builtins[index].priority; + sched_setscheduler(pid, SCHED_RR, ¶m); + } +#endif + /* Now let the builtin application run */ + + sched_unlock(); + + /* Return the task ID of the new task if the task was sucessfully + * started. Otherwise, pid will be ERROR (and the errno value will + * be set appropriately). + */ + + return pid; + } + + /* Return ERROR with errno set appropriately */ + + return ERROR; +} diff --git a/apps/include/apps.h b/apps/include/apps.h index 520128203..37599ac5c 100644 --- a/apps/include/apps.h +++ b/apps/include/apps.h @@ -52,7 +52,7 @@ * Public Types ****************************************************************************/ -struct namedapp_s +struct builtin_s { const char *name; /* Invocation name and as seen under /sbin/ */ int priority; /* Use: SCHED_PRIORITY_DEFAULT */ @@ -64,7 +64,7 @@ struct namedapp_s * Public Data ****************************************************************************/ -/* The "bindir" is file system that supports access to the named applications. +/* The "bindir" is file system that supports access to the builtin applications. * It is typically mounted under /bin. */ @@ -86,7 +86,7 @@ extern "C" { #endif /**************************************************************************** - * Name: namedapp_isavail + * Name: builtin_isavail * * Description: * Checks for availabiliy of application registerred during compile time. @@ -101,10 +101,10 @@ extern "C" { * ****************************************************************************/ -EXTERN int namedapp_isavail(FAR const char *appname); +EXTERN int builtin_isavail(FAR const char *appname); /**************************************************************************** - * Name: namedapp_getname + * Name: builtin_getname * * Description: * Returns pointer to a name of built-in application pointed by the @@ -119,13 +119,13 @@ EXTERN int namedapp_isavail(FAR const char *appname); * ****************************************************************************/ -EXTERN const char *namedapp_getname(int index); +EXTERN const char *builtin_getname(int index); /**************************************************************************** - * Name: exec_namedapp + * Name: exec_builtin * * Description: - * Executes builtin named application registered during compile time. + * Executes builtin applications registered during 'make context' time. * New application is run in a separate task context (and thread). * * Input Parameter: @@ -139,7 +139,7 @@ EXTERN const char *namedapp_getname(int index); * ****************************************************************************/ -EXTERN int exec_namedapp(FAR const char *appname, FAR const char **argv); +EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv); #undef EXTERN #if defined(__cplusplus) diff --git a/apps/namedapp/Kconfig b/apps/namedapp/Kconfig deleted file mode 100644 index 8d8f03421..000000000 --- a/apps/namedapp/Kconfig +++ /dev/null @@ -1,15 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config NAMEDAPP - bool "Support named applications" - default n - ---help--- - Enable support for named applications. This features assigns a string - name to an application. This feature is also the underlying requirement - to support built-in applications in the NuttShell (NSH). - -if NAMEDAPP -endif diff --git a/apps/namedapp/Make.defs b/apps/namedapp/Make.defs deleted file mode 100644 index 399fefee8..000000000 --- a/apps/namedapp/Make.defs +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# apps/namedapps/Make.defs -# Adds selected applications to apps/ build -# -# Copyright (C) 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. -# -############################################################################ - -ifeq ($(CONFIG_NAMEDAPP),y) -CONFIGURED_APPS += namedapp -endif - diff --git a/apps/namedapp/Makefile b/apps/namedapp/Makefile deleted file mode 100644 index a88c73567..000000000 --- a/apps/namedapp/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -############################################################################ -# apps/nshlib/Makefile -# -# 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. -# -############################################################################ - --include $(TOPDIR)/.config --include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs - -# NSH Library - -# Source and object files - -ASRCS = -CSRCS = namedapp.c exec_namedapp.c - -ifeq ($(CONFIG_APPS_BINDIR),y) -CSRCS += binfs.c -endif - -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\libapps$(LIBEXT) -else -ifeq ($(WINTOOL),y) - BIN = ..\\libapps$(LIBEXT) -else - BIN = ../libapps$(LIBEXT) -endif -endif - -ROOTDEPPATH = --dep-path . -VPATH = - -# Build Targets - -all: .built -.PHONY: .context context depend clean distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - $(call ARCHIVE, $(BIN), $(OBJS)) - $(Q) touch .built - -.context: - @echo "/* List of application requirements, generated during make context. */" > namedapp_list.h - @echo "/* List of application entry points, generated during make context. */" > namedapp_proto.h - $(Q) touch $@ - -context: .context - -.depend: Makefile $(SRCS) - $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep - $(Q) touch $@ - -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, .context) - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - $(call DELFILE, namedapp_list.h) - $(call DELFILE, namedapp_proto.h) - --include Make.dep - diff --git a/apps/namedapp/binfs.c b/apps/namedapp/binfs.c deleted file mode 100644 index 36e3ace92..000000000 --- a/apps/namedapp/binfs.c +++ /dev/null @@ -1,596 +0,0 @@ -/**************************************************************************** - * apps/namedapps/binfs.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "namedapp.h" - -#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_APPS_BINDIR) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* This structure represents the overall mountpoint state. An instance of this - * structure is retained as inode private data on each mountpoint that is - * mounted with a fat32 filesystem. - */ - -struct binfs_state_s -{ - sem_t bm_sem; /* Used to assume thread-safe access */ -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static void binfs_semtake(struct binfs_state_s *bm); -static inline void binfs_semgive(struct binfs_state_s *bm); -static int binfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode); -static int binfs_close(FAR struct file *filep); -static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); -static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); - -static int binfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir); -static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); -static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir); - -static int binfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle); -static int binfs_unbind(void *handle, FAR struct inode **blkdriver); -static int binfs_statfs(struct inode *mountpt, struct statfs *buf); - -static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf); - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/* See fs_mount.c -- this structure is explicitly externed there. - * We use the old-fashioned kind of initializers so that this will compile - * with any compiler. - */ - -const struct mountpt_operations binfs_operations = -{ - binfs_open, /* open */ - binfs_close, /* close */ - binfs_read, /* read */ - NULL, /* write */ - NULL, /* seek */ - binfs_ioctl, /* ioctl */ - NULL, /* sync */ - - binfs_opendir, /* opendir */ - NULL, /* closedir */ - binfs_readdir, /* readdir */ - binfs_rewinddir, /* rewinddir */ - - binfs_bind, /* bind */ - binfs_unbind, /* unbind */ - binfs_statfs, /* statfs */ - - NULL, /* unlink */ - NULL, /* mkdir */ - NULL, /* rmdir */ - NULL, /* rename */ - binfs_stat /* stat */ -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: binfs_semtake - ****************************************************************************/ - -static void binfs_semtake(struct binfs_state_s *bm) -{ - /* Take the semaphore (perhaps waiting) */ - - while (sem_wait(&bm->bm_sem) != 0) - { - /* The only case that an error should occur here is if - * the wait was awakened by a signal. - */ - - ASSERT(errno == EINTR); - } -} - -/**************************************************************************** - * Name: binfs_semgive - ****************************************************************************/ - -static inline void binfs_semgive(struct binfs_state_s *bm) -{ - sem_post(&bm->bm_sem); -} - -/**************************************************************************** - * Name: binfs_open - ****************************************************************************/ - -static int binfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode) -{ - struct binfs_state_s *bm; - int ret = -ENOSYS; - - fvdbg("Open '%s'\n", relpath); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL); - - /* mountpoint private data from the inode reference from the file - * structure - */ - - bm = (struct binfs_state_s*)filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* BINFS is read-only. Any attempt to open with any kind of write - * access is not permitted. - */ - - if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) - { - fdbg("Only O_RDONLY supported\n"); - ret = -EACCES; - } - - /* Save open-specific state in filep->f_priv */ - - /* Opening of elements within the pseudo-file system is not yet supported */ - - return ret; -} - -/**************************************************************************** - * Name: binfs_close - ****************************************************************************/ - -static int binfs_close(FAR struct file *filep) -{ - struct binfs_state_s *bm; - int ret = -ENOSYS; - - fvdbg("Closing\n"); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state from the struct file instance */ - /* bf = filep->f_priv; */ - - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* Free the open file state */ - /* free(bf); */ - - filep->f_priv = NULL; - - /* Since open() is not yet supported, neither is close(). */ - - return ret; -} - -/**************************************************************************** - * Name: binfs_read - ****************************************************************************/ - -static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) -{ - struct binfs_state_s *bm; - - fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state data from the struct file instance */ - /* bf = filep->f_priv; */ - - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* Since open is not yet supported, neither is reading */ - - return -ENOSYS; -} - -/**************************************************************************** - * Name: binfs_ioctl - ****************************************************************************/ - -static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - struct binfs_state_s *bm; - - fvdbg("cmd: %d arg: %08lx\n", cmd, arg); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state from the struct file instance */ - /* bf = filep->f_priv; */ - - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* No ioctl commands yet supported */ - - return -ENOTTY; -} - -/**************************************************************************** - * Name: binfs_opendir - * - * Description: - * Open a directory for read access - * - ****************************************************************************/ - -static int binfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir) -{ - struct binfs_state_s *bm; - int ret; - - fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL"); - - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - /* The requested directory must be the volume-relative "root" directory */ - - if (relpath && relpath[0] != '\0') - { - ret = -ENOENT; - goto errout_with_semaphore; - } - - /* Set the index to the first entry */ - - dir->u.binfs.fb_index = 0; - ret = OK; - -errout_with_semaphore: - binfs_semgive(bm); - return ret; -} - -/**************************************************************************** - * Name: binfs_readdir - * - * Description: Read the next directory entry - * - ****************************************************************************/ - -static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) -{ - struct binfs_state_s *bm; - unsigned int index; - int ret; - - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - /* Have we reached the end of the directory */ - - index = dir->u.binfs.fb_index; - if (namedapps[index].name == NULL) - { - /* We signal the end of the directory by returning the - * special error -ENOENT - */ - - fvdbg("Entry %d: End of directory\n", index); - ret = -ENOENT; - } - else - { - /* Save the filename and file type */ - - fvdbg("Entry %d: \"%s\"\n", index, namedapps[index].name); - dir->fd_dir.d_type = DTYPE_FILE; - strncpy(dir->fd_dir.d_name, namedapps[index].name, NAME_MAX+1); - - /* The application list is terminated by an entry with a NULL name. - * Therefore, there is at least one more entry in the list. - */ - - index++; - - /* Set up the next directory entry offset. NOTE that we could use the - * standard f_pos instead of our own private fb_index. - */ - - dir->u.binfs.fb_index = index; - ret = OK; - } - - binfs_semgive(bm); - return ret; -} - -/**************************************************************************** - * Name: binfs_rewindir - * - * Description: Reset directory read to the first entry - * - ****************************************************************************/ - -static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) -{ - struct binfs_state_s *bm; - - fvdbg("Entry\n"); - - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - dir->u.binfs.fb_index = 0; - - binfs_semgive(bm); - return OK; -} - -/**************************************************************************** - * Name: binfs_bind - * - * Description: This implements a portion of the mount operation. This - * function allocates and initializes the mountpoint private data and - * binds the blockdriver inode to the filesystem private data. The final - * binding of the private data (containing the blockdriver) to the - * mountpoint is performed by mount(). - * - ****************************************************************************/ - -static int binfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle) -{ - struct binfs_state_s *bm; - - fvdbg("Entry\n"); - - /* Create an instance of the mountpt state structure */ - - bm = (struct binfs_state_s *)zalloc(sizeof(struct binfs_state_s)); - if (!bm) - { - fdbg("Failed to allocate mountpoint structure\n"); - return -ENOMEM; - } - - /* Initialize the allocated mountpt state structure. The filesystem is - * responsible for one reference ont the blkdriver inode and does not - * have to addref() here (but does have to release in ubind(). - */ - - sem_init(&bm->bm_sem, 0, 1); /* Initialize the semaphore that controls access */ - - /* Mounted! */ - - *handle = (void*)bm; - return OK; -} - -/**************************************************************************** - * Name: binfs_unbind - * - * Description: This implements the filesystem portion of the umount - * operation. - * - ****************************************************************************/ - -static int binfs_unbind(void *handle, FAR struct inode **blkdriver) -{ - struct binfs_state_s *bm = (struct binfs_state_s*)handle; - - fvdbg("Entry\n"); - -#ifdef CONFIG_DEBUG - if (!bm) - { - return -EINVAL; - } -#endif - - /* Check if there are sill any files opened on the filesystem. */ - - /* Release the mountpoint private data */ - - sem_destroy(&bm->bm_sem); - return OK; -} - -/**************************************************************************** - * Name: binfs_statfs - * - * Description: Return filesystem statistics - * - ****************************************************************************/ - -static int binfs_statfs(struct inode *mountpt, struct statfs *buf) -{ - struct binfs_state_s *bm; - - fvdbg("Entry\n"); - - /* Sanity checks */ - - DEBUGASSERT(mountpt && mountpt->i_private); - - /* Get the mountpoint private data from the inode structure */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - /* Fill in the statfs info */ - - memset(buf, 0, sizeof(struct statfs)); - buf->f_type = BINFS_MAGIC; - buf->f_bsize = 0; - buf->f_blocks = 0; - buf->f_bfree = 0; - buf->f_bavail = 0; - buf->f_namelen = NAME_MAX; - - binfs_semgive(bm); - return OK; -} - -/**************************************************************************** - * Name: binfs_stat - * - * Description: Return information about a file or directory - * - ****************************************************************************/ - -static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) -{ - struct binfs_state_s *bm; - int ret; - - fvdbg("Entry\n"); - - /* Sanity checks */ - - DEBUGASSERT(mountpt && mountpt->i_private); - - /* Get the mountpoint private data from the inode structure */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - /* The requested directory must be the volume-relative "root" directory */ - - if (relpath && relpath[0] != '\0') - { - /* Check if there is a file with this name. */ - - if (namedapp_isavail(relpath) < 0) - { - ret = -ENOENT; - goto errout_with_semaphore; - } - - /* It's a execute-only file name */ - - buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; - } - else - { - /* It's a read/execute-only directory name */ - - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; - } - - /* File/directory size, access block size */ - - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; - ret = OK; - -errout_with_semaphore: - binfs_semgive(bm); - return ret; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_APPS_BINDIR */ - diff --git a/apps/namedapp/exec_namedapp.c b/apps/namedapp/exec_namedapp.c deleted file mode 100644 index 264fca7b9..000000000 --- a/apps/namedapp/exec_namedapp.c +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** - * apps/namedaps/exec_namedapp.c - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Uros Platise - * - * With updates, modifications, and general maintenance by: - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Auther: 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 "namedapp.h" - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: namedapp_getname - * - * Description: - * Return the name of the application at index in the table of named - * applications. - * - ****************************************************************************/ - -const char *namedapp_getname(int index) -{ - if (index < 0 || index >= number_namedapps()) - { - return NULL; - } - - return namedapps[index].name; -} - -/**************************************************************************** - * Name: namedapp_isavail - * - * Description: - * Return the index into the table of applications for the applicaiton with - * the name 'appname'. - * - ****************************************************************************/ - -int namedapp_isavail(FAR const char *appname) -{ - int i; - - for (i = 0; namedapps[i].name; i++) - { - if (!strcmp(namedapps[i].name, appname)) - { - return i; - } - } - - set_errno(ENOENT); - return ERROR; -} - -/**************************************************************************** - * Name: namedapp_isavail - * - * Description: - * Execute the application with name 'appname', providing the arguments - * in the argv[] array. - * - * Returned Value: - * On success, the task ID of the named application is returned. On - * failure, -1 (ERROR) is returned an the errno value is set appropriately. - * - ****************************************************************************/ - -int exec_namedapp(FAR const char *appname, FAR const char **argv) -{ - pid_t pid; - int index; - - /* Verify that an application with this name exists */ - - index = namedapp_isavail(appname); - if (index >= 0) - { - /* Disable pre-emption. This means that although we start the named - * application here, it will not actually run until pre-emption is - * re-enabled below. - */ - - sched_lock(); - - /* Start the named application task */ - - pid = TASK_CREATE(namedapps[index].name, namedapps[index].priority, - namedapps[index].stacksize, namedapps[index].main, - (argv) ? &argv[1] : (const char **)NULL); - - /* If robin robin scheduling is enabled, then set the scheduling policy - * of the new task to SCHED_RR before it has a chance to run. - */ - -#if CONFIG_RR_INTERVAL > 0 - if (pid > 0) - { - struct sched_param param; - - /* Pre-emption is disabled so the task creation and the - * following operation will be atomic. The priority of the - * new task cannot yet have changed from its initial value. - */ - - param.sched_priority = namedapps[index].priority; - sched_setscheduler(pid, SCHED_RR, ¶m); - } -#endif - /* Now let the named application run */ - - sched_unlock(); - - /* Return the task ID of the new task if the task was sucessfully - * started. Otherwise, pid will be ERROR (and the errno value will - * be set appropriately). - */ - - return pid; - } - - /* Return ERROR with errno set appropriately */ - - return ERROR; -} diff --git a/apps/namedapp/namedapp.c b/apps/namedapp/namedapp.c deleted file mode 100644 index d59ce6e3b..000000000 --- a/apps/namedapp/namedapp.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - * apps/namedaps/namedapp.c - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Authors: Uros Platise - * 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 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -#include "namedapp_proto.h" - -const struct namedapp_s namedapps[] = -{ -# include "namedapp_list.h" - { NULL, 0, 0, 0 } -}; - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int number_namedapps(void) -{ - return sizeof(namedapps)/sizeof(struct namedapp_s) - 1; -} - - diff --git a/apps/namedapp/namedapp.h b/apps/namedapp/namedapp.h deleted file mode 100644 index 7fcdf42dc..000000000 --- a/apps/namedapp/namedapp.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * apps/namedaps/namedapp.h - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Authors: Uros Platise - * 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 __APPS_NAMEDAPP_NAMEDAPP_H -#define __APPS_NAMEDAPP_NAMEDAPP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -EXTERN const struct namedapp_s namedapps[]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -EXTERN int number_namedapps(void); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* __APPS_NAMEDAPP_NAMEDAPP_H */ - diff --git a/apps/nshlib/Kconfig b/apps/nshlib/Kconfig index 17b107b8f..e60e9c480 100644 --- a/apps/nshlib/Kconfig +++ b/apps/nshlib/Kconfig @@ -15,12 +15,12 @@ if NSH_LIBRARY config NSH_BUILTIN_APPS bool "Enable built-in applications" default y - depends on NAMEDAPP + depends on BUILTIN ---help--- - Support external registered, "named" applications that can be + Support external registered, "built-in" applications that can be executed from the NSH command line (see apps/README.txt for - more information). This options requires support for named applications - (NAMEDAPP). + more information). This options requires support for builtin + applications (BUILTIN). menu "Disable Individual commands" diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index bc626e699..006839628 100644 --- a/apps/nshlib/README.txt +++ b/apps/nshlib/README.txt @@ -945,7 +945,7 @@ NSH-Specific Configuration Settings the configs//defconfig file: * CONFIG_NSH_BUILTIN_APPS - Support external registered, "named" applications that can be + Support external registered, "builtin" applications that can be executed from the NSH command line (see apps/README.txt for more information). diff --git a/apps/nshlib/nsh_apps.c b/apps/nshlib/nsh_apps.c index 7dbaf9ba8..ea8791eef 100644 --- a/apps/nshlib/nsh_apps.c +++ b/apps/nshlib/nsh_apps.c @@ -90,7 +90,7 @@ * Attempt to execute the application task whose name is 'cmd' * * Returned Value: - * <0 If exec_namedapp() fails, then the negated errno value + * <0 If exec_builtin() fails, then the negated errno value * is returned. * -1 (ERROR) if the application task corresponding to 'cmd' could not * be started (possibly because it doesn not exist). @@ -119,7 +119,7 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, * applications. */ - ret = exec_namedapp(cmd, (FAR const char **)argv); + ret = exec_builtin(cmd, (FAR const char **)argv); if (ret >= 0) { /* The application was successfully started (but still blocked because @@ -205,7 +205,7 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, sched_unlock(); - /* If exec_namedapp() or waitpid() failed, then return the negated errno + /* If exec_builtin() or waitpid() failed, then return the negated errno * value. */ diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index 27068acff..70fa39f62 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -605,7 +605,7 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl) /* List the set of available built-in commands */ nsh_output(vtbl, "\nBuiltin Apps:\n"); - for (i = 0; (name = namedapp_getname(i)) != NULL; i++) + for (i = 0; (name = builtin_getname(i)) != NULL; i++) { nsh_output(vtbl, " %s\n", name); } @@ -726,7 +726,7 @@ static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * Exectue the command in argv[0] * * Returned Value: - * <0 If exec_namedapp() fails, then the negated errno value + * <0 If exec_builtin() fails, then the negated errno value * is returned. * -1 (ERRROR) if the command was unsuccessful * 0 (OK) if the command was successful @@ -1439,13 +1439,13 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) } /* Handle the case where the command is executed in background. - * However is app is to be started as namedapp new process will + * However is app is to be started as builtin new process will * be created anyway, so skip this step. */ #ifndef CONFIG_NSH_DISABLEBG if (vtbl->np.np_bg #ifdef CONFIG_NSH_BUILTIN_APPS - && namedapp_isavail(argv[0]) < 0 + && builtin_isavail(argv[0]) < 0 #endif ) { diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 0b5f7aa11..cc3f078dd 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -2515,7 +2515,7 @@ nsh> CONFIG_NSH_BUILTIN_APPS - Support external registered, "named" applications that can be + Support external registered, "builtin" applications that can be executed from the NSH command line (see apps/README.txt for more information). @@ -3239,48 +3239,48 @@ Builtin Apps: Note that no detailed help information beyond the name of the built-in application is provided.

-

4.3.1 Named Applications

+

4.3.1 Built-In Applications

Overview. - The underlying logic that supports the NSH built-in applications is called "Named Applications". - The named application logic can be found at apps/namedapp. + The underlying logic that supports the NSH built-in applications is called "Built-In Applications". + The builtin application logic can be found at apps/builtin. This logic simply does the following:

  1. - It supports registration mechanism so that named applications can dynamically register themselves at build time, and + It supports registration mechanism so that builtin applications can dynamically register themselves at build time, and

  2. - Utility functions to look up, list, and execute the named applications. + Utility functions to look up, list, and execute the builtin applications.

- Named Application Utility Functions. - The utility functions exported by the named application logic are prototyped in apps/include/apps.h. + Built-In Application Utility Functions. + The utility functions exported by the builtin application logic are prototyped in apps/include/apps.h. These utility functions include:

  • - int namedapp_isavail(FAR const char *appname); + int builtin_isavail(FAR const char *appname); Checks for availability of application registered as appname during build time.

  • - const char *namedapp_getname(int index); + const char *builtin_getname(int index); Returns a pointer to a name of built-in application pointed by the index. This is the utility function that is used by NSH in order to list the available built-in applications when "nsh> help" is entered.

  • - int exec_namedapp(FAR const char *appname, FAR const char **argv); - Executes built-in named application registered during compile time. + int exec_builtin(FAR const char *appname, FAR const char **argv); + Executes built-in builtin application registered during compile time. This is the utility function used by NSH to execute the built-in application.

@@ -3292,23 +3292,23 @@ Builtin Apps:
  1. - apps/namedapp/namedapp_proto.h: + apps/builtin/builtin_proto.h: Prototypes of application task entry points.

  2. - apps/namedapp/namedapp_list.h: + apps/builtin/builtin_list.h: Application specific information and start-up requirements

- Registration of Named Applications. + Registration of Built-In Applications. The NuttX build occurs in several phases as different build targets are executed: (1) context when the configuration is established, (2) depend when target dependencies are generated, and (3) default (all) when the normal compilation and link operations are performed. - Named application information is collected during the make context build phase. + Built-in application information is collected during the make context build phase.

@@ -3376,7 +3376,7 @@ make apps_distclean

- Logic for the context target in apps/examples/hello/Makefile registers the hello_main() application in the namedapp's namedapp_proto.hand namedapp_list.h files. + Logic for the context target in apps/examples/hello/Makefile registers the hello_main() application in the builtin's builtin_proto.hand builtin_list.h files. That logic that does that in apps/examples/hello/Makefile is abstracted below:

    @@ -3388,13 +3388,13 @@ make apps_distclean include $(APPDIR)/Make.defs

    - This defines a macro called REGISTER that adds data to the namedapp header files: + This defines a macro called REGISTER that adds data to the builtin header files:

       define REGISTER
           @echo "Register: $1"
      -    @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/namedapp/namedapp_list.h"
      -    @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/namedapp/namedapp_proto.h"
      +    @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h"
      +    @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h"
       endef
       

    @@ -3412,7 +3412,7 @@ STACKSIZE = 2048

  1. - And finally, the Makefile invokes the REGISTER macro to added the hello_main() named application. + And finally, the Makefile invokes the REGISTER macro to added the hello_main() builtin application. Then, when the system build completes, the hello command can be executed from the NSH command line. When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2K.

    @@ -3424,16 +3424,16 @@ STACKSIZE = 2048

- Other Uses of Named Application. - The primary purpose of named applications is to support command line execution of applications from NSH. - However, there are two other uses of named applications that should be mentioned. + Other Uses of Built-In Application. + The primary purpose of builtin applications is to support command line execution of applications from NSH. + However, there are two other uses of builtin applications that should be mentioned.

  1. - Named Application Start-Up main() function. - A named application can even be used as the main, start-up entry point into your embedded software. + Built-In Application Start-Up main() function. + A builtin application can even be used as the main, start-up entry point into your embedded software. When the user defines this option in the NuttX configuration file:

      @@ -3451,11 +3451,11 @@ CONFIG_BUILTIN_APP_START=<application name>
       
         
    • binfs. - binfs is a tiny file system located at apps/namedapp/binfs.c. - This provides an alternative what of visualizing installed named applications. - Without binfs, you can see the installed named applications using the NSH help command. + binfs is a tiny file system located at apps/builtin/binfs.c. + This provides an alternative what of visualizing installed builtin applications. + Without binfs, you can see the installed builtin applications using the NSH help command. binfs will create a tiny pseudo-file system mounted at /bin. - Using binfs, you can see the available named applications by listing the contents of /bin directory. + Using binfs, you can see the available builtin applications by listing the contents of /bin directory. This gives some superficial Unix compatibility, but does not really add any new functionality.

@@ -3762,7 +3762,12 @@ mount -t vfat /dev/ram1 /tmp
  • Background command priority
  • binfs
  • Built-In applications
  • +
  • Built-In application start-up main()
  • Built-in variables
  • +
  • builtin_getname()
  • +
  • builtin_isavail()
  • +
  • builtin_list.h
  • +
  • builtin_proto.h
  • base64dec
  • base64enc
  • cat
  • @@ -3827,12 +3832,12 @@ mount -t vfat /dev/ram1 /tmp
  • echo
  • Environment Variables
  • /etc/init.d/rcS + +
  • exec
  • -
  • exec_namedapp()
  • +
  • exec_builtin()
  • exit
  • free
  • - -
  • g_cmdmap
  • genromfs
  • get
  • @@ -3858,12 +3863,6 @@ mount -t vfat /dev/ram1 /tmp
  • mkromfsimg.sh
  • mount
  • mv
  • -
  • Named application start-up main()
  • -
  • Named applications
  • -
  • namedapp_getname()
  • -
  • namedapp_isavail()
  • -
  • namedapp_list.h
  • -
  • namedapp_proto.h
  • nfsmount
  • nice
  • NSH library (nshlib)
  • @@ -3887,7 +3886,7 @@ mount -t vfat /dev/ram1 /tmp
  • PWD
  • rcS.template
  • Re-directed commands
  • -
  • Registration of named applications
  • +
  • Registration of builtin applications
  • rm
  • rmdir
  • ROMFS, Modifying the ROMFS image
  • diff --git a/nuttx/configs/cloudctrl/nsh/defconfig b/nuttx/configs/cloudctrl/nsh/defconfig index fbb5e8c13..99c7eb790 100644 --- a/nuttx/configs/cloudctrl/nsh/defconfig +++ b/nuttx/configs/cloudctrl/nsh/defconfig @@ -505,7 +505,7 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/ez80f910200kitg/ostest/defconfig b/nuttx/configs/ez80f910200kitg/ostest/defconfig index 50efbfdaf..80c9e682e 100644 --- a/nuttx/configs/ez80f910200kitg/ostest/defconfig +++ b/nuttx/configs/ez80f910200kitg/ostest/defconfig @@ -334,7 +334,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/ez80f910200zco/ostest/defconfig b/nuttx/configs/ez80f910200zco/ostest/defconfig index 3a1352333..88c1b7279 100644 --- a/nuttx/configs/ez80f910200zco/ostest/defconfig +++ b/nuttx/configs/ez80f910200zco/ostest/defconfig @@ -342,7 +342,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig index 2fb623a0d..c42bb1569 100644 --- a/nuttx/configs/fire-stm32v2/nsh/defconfig +++ b/nuttx/configs/fire-stm32v2/nsh/defconfig @@ -531,7 +531,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/p112/ostest/defconfig b/nuttx/configs/p112/ostest/defconfig index c30adcf22..3699475c5 100644 --- a/nuttx/configs/p112/ostest/defconfig +++ b/nuttx/configs/p112/ostest/defconfig @@ -370,7 +370,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig index 36f8e40fc..c54d714d0 100644 --- a/nuttx/configs/shenzhou/nsh/defconfig +++ b/nuttx/configs/shenzhou/nsh/defconfig @@ -505,7 +505,7 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/shenzhou/nxwm/defconfig b/nuttx/configs/shenzhou/nxwm/defconfig index 0f100ed5e..975327747 100644 --- a/nuttx/configs/shenzhou/nxwm/defconfig +++ b/nuttx/configs/shenzhou/nxwm/defconfig @@ -630,7 +630,7 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/shenzhou/thttpd/defconfig b/nuttx/configs/shenzhou/thttpd/defconfig index ccbcf9ab2..958ab02ed 100644 --- a/nuttx/configs/shenzhou/thttpd/defconfig +++ b/nuttx/configs/shenzhou/thttpd/defconfig @@ -474,7 +474,7 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index f1dfd0dd2..03f163ea5 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -148,9 +148,9 @@ If you are running X11 applications as NSH add-on programs, then the stack size of the add-on program is controlled in another way. Here are the steps for increasing the stack size in that case: - cd ../apps/namedapps # Go to the namedapps directory - vi namedapps_list.h # Edit this file and increase the stack size of the add-on - rm .built *.o # This will force the namedapps logic to rebuild + cd ../apps/builtin # Go to the builtin apps directory + vi builtin_list.h # Edit this file and increase the stack size of the add-on + rm .built *.o # This will force the builtin apps logic to rebuild Buffered I/O Issues ------------------- diff --git a/nuttx/configs/sim/cxxtest/defconfig b/nuttx/configs/sim/cxxtest/defconfig index 648a92851..6ac45d44d 100644 --- a/nuttx/configs/sim/cxxtest/defconfig +++ b/nuttx/configs/sim/cxxtest/defconfig @@ -298,7 +298,7 @@ CONFIG_UCLIBCXX_HAVE_LIBSUPCXX=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/sim/nxwm/defconfig b/nuttx/configs/sim/nxwm/defconfig index 6a295ef4f..90ee00f50 100644 --- a/nuttx/configs/sim/nxwm/defconfig +++ b/nuttx/configs/sim/nxwm/defconfig @@ -376,7 +376,7 @@ CONFIG_HAVE_CXX=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/sim/ostest/defconfig b/nuttx/configs/sim/ostest/defconfig index beee30639..55687c366 100644 --- a/nuttx/configs/sim/ostest/defconfig +++ b/nuttx/configs/sim/ostest/defconfig @@ -297,7 +297,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm3220g-eval/nxwm/defconfig b/nuttx/configs/stm3220g-eval/nxwm/defconfig index 11e88f764..ab061f07a 100644 --- a/nuttx/configs/stm3220g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3220g-eval/nxwm/defconfig @@ -659,7 +659,7 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm3240g-eval/discover/defconfig b/nuttx/configs/stm3240g-eval/discover/defconfig index 152486d1b..e11d39ce1 100644 --- a/nuttx/configs/stm3240g-eval/discover/defconfig +++ b/nuttx/configs/stm3240g-eval/discover/defconfig @@ -494,7 +494,7 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm3240g-eval/xmlrpc/defconfig b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig index 6b4c9af70..4f621d453 100644 --- a/nuttx/configs/stm3240g-eval/xmlrpc/defconfig +++ b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig @@ -487,7 +487,7 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f100rc_generic/nsh/defconfig b/nuttx/configs/stm32f100rc_generic/nsh/defconfig index a0228a3de..65ac9a73d 100644 --- a/nuttx/configs/stm32f100rc_generic/nsh/defconfig +++ b/nuttx/configs/stm32f100rc_generic/nsh/defconfig @@ -428,7 +428,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -CONFIG_NAMEDAPP=y +CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/stm32f100rc_generic/ostest/defconfig b/nuttx/configs/stm32f100rc_generic/ostest/defconfig index 0041feb50..2d2842c54 100644 --- a/nuttx/configs/stm32f100rc_generic/ostest/defconfig +++ b/nuttx/configs/stm32f100rc_generic/ostest/defconfig @@ -410,7 +410,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f4discovery/cxxtest/defconfig b/nuttx/configs/stm32f4discovery/cxxtest/defconfig index 6487742cf..e7fa49954 100644 --- a/nuttx/configs/stm32f4discovery/cxxtest/defconfig +++ b/nuttx/configs/stm32f4discovery/cxxtest/defconfig @@ -426,7 +426,7 @@ CONFIG_UCLIBCXX_HAVE_LIBSUPCXX=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f4discovery/elf/defconfig b/nuttx/configs/stm32f4discovery/elf/defconfig index 9379c885b..3f5a5d0fc 100644 --- a/nuttx/configs/stm32f4discovery/elf/defconfig +++ b/nuttx/configs/stm32f4discovery/elf/defconfig @@ -460,7 +460,7 @@ CONFIG_HAVE_CXX=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f4discovery/nxlines/defconfig b/nuttx/configs/stm32f4discovery/nxlines/defconfig index 8609993ea..58eebd41f 100644 --- a/nuttx/configs/stm32f4discovery/nxlines/defconfig +++ b/nuttx/configs/stm32f4discovery/nxlines/defconfig @@ -518,7 +518,7 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f4discovery/ostest/defconfig b/nuttx/configs/stm32f4discovery/ostest/defconfig index b29622c8e..5fdd30f57 100644 --- a/nuttx/configs/stm32f4discovery/ostest/defconfig +++ b/nuttx/configs/stm32f4discovery/ostest/defconfig @@ -430,7 +430,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/stm32f4discovery/winbuild/defconfig b/nuttx/configs/stm32f4discovery/winbuild/defconfig index ac8a18c9b..95be14886 100644 --- a/nuttx/configs/stm32f4discovery/winbuild/defconfig +++ b/nuttx/configs/stm32f4discovery/winbuild/defconfig @@ -430,7 +430,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/vsn/src/README.txt b/nuttx/configs/vsn/src/README.txt index 4e2d50e0b..87a538a10 100644 --- a/nuttx/configs/vsn/src/README.txt +++ b/nuttx/configs/vsn/src/README.txt @@ -12,7 +12,7 @@ Execution starts in the following order: is set. It must be set for the VSN board. - boot, performs initial chip and board initialization - - sched/os_bringup.c then calls either user_start or exec_namedapp() + - sched/os_bringup.c then calls either user_start or exec_builtin() with application as set in the .config @@ -55,4 +55,5 @@ Compile notes To link-in the sif_main() utility do, in this folder: - make context TOPDIR= -This will result in registering the application into the namedapp. +This will result in registering the application into the builtin application +registry. diff --git a/nuttx/configs/xtrs/nsh/defconfig b/nuttx/configs/xtrs/nsh/defconfig index 8730ebab7..72b32d9aa 100644 --- a/nuttx/configs/xtrs/nsh/defconfig +++ b/nuttx/configs/xtrs/nsh/defconfig @@ -303,7 +303,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/xtrs/ostest/defconfig b/nuttx/configs/xtrs/ostest/defconfig index a0a100bcf..74a0199df 100644 --- a/nuttx/configs/xtrs/ostest/defconfig +++ b/nuttx/configs/xtrs/ostest/defconfig @@ -302,7 +302,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/xtrs/pashello/defconfig b/nuttx/configs/xtrs/pashello/defconfig index d23c50716..abdaf1f35 100644 --- a/nuttx/configs/xtrs/pashello/defconfig +++ b/nuttx/configs/xtrs/pashello/defconfig @@ -303,7 +303,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z16f2800100zcog/ostest/defconfig b/nuttx/configs/z16f2800100zcog/ostest/defconfig index defd3d5ef..64828738f 100644 --- a/nuttx/configs/z16f2800100zcog/ostest/defconfig +++ b/nuttx/configs/z16f2800100zcog/ostest/defconfig @@ -342,7 +342,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z16f2800100zcog/pashello/defconfig b/nuttx/configs/z16f2800100zcog/pashello/defconfig index f3067a9e7..ba99283d3 100644 --- a/nuttx/configs/z16f2800100zcog/pashello/defconfig +++ b/nuttx/configs/z16f2800100zcog/pashello/defconfig @@ -342,7 +342,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z80sim/nsh/defconfig b/nuttx/configs/z80sim/nsh/defconfig index fb9fac546..d13f0f7f7 100644 --- a/nuttx/configs/z80sim/nsh/defconfig +++ b/nuttx/configs/z80sim/nsh/defconfig @@ -303,7 +303,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z80sim/ostest/defconfig b/nuttx/configs/z80sim/ostest/defconfig index d3410d52d..bd4144821 100644 --- a/nuttx/configs/z80sim/ostest/defconfig +++ b/nuttx/configs/z80sim/ostest/defconfig @@ -302,7 +302,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z80sim/pashello/defconfig b/nuttx/configs/z80sim/pashello/defconfig index e7dee626c..58d609c4b 100644 --- a/nuttx/configs/z80sim/pashello/defconfig +++ b/nuttx/configs/z80sim/pashello/defconfig @@ -302,7 +302,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z8encore000zco/ostest/defconfig b/nuttx/configs/z8encore000zco/ostest/defconfig index 7d9b227f4..7bd512727 100644 --- a/nuttx/configs/z8encore000zco/ostest/defconfig +++ b/nuttx/configs/z8encore000zco/ostest/defconfig @@ -329,7 +329,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/configs/z8f64200100kit/ostest/defconfig b/nuttx/configs/z8f64200100kit/ostest/defconfig index a34952987..e98e41561 100644 --- a/nuttx/configs/z8f64200100kit/ostest/defconfig +++ b/nuttx/configs/z8f64200100kit/ostest/defconfig @@ -329,7 +329,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -# CONFIG_NAMEDAPP is not set +# CONFIG_BUILTIN is not set # # Examples diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c index e0a236bbe..4b5adcae1 100644 --- a/nuttx/sched/os_bringup.c +++ b/nuttx/sched/os_bringup.c @@ -189,11 +189,11 @@ int os_bringup(void) svdbg("Starting init thread\n"); #ifdef CONFIG_BUILTIN_APP_START - /* Start the built-in named application, passing an "init" argument, so that + /* Start the built-in application, passing an "init" argument, so that * application can distinguish different run-levels */ - init_taskid = exec_namedapp(CONFIG_BUILTIN_APP_START, argv); + init_taskid = exec_builtin(CONFIG_BUILTIN_APP_START, argv); #else /* Start the default application at CONFIG_USER_ENTRYPOINT() */ -- cgit v1.2.3 From 3fe53af6be14a28174eec48b5740dbbe7c1f818a Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 23 Dec 2012 22:17:09 +0000 Subject: Remove .context kludge from apps/ directory git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5455 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 4 +++ apps/Make.defs | 9 ++++--- apps/Makefile | 9 +------ apps/builtin/Makefile | 33 ++++++++++++++--------- apps/builtin/registry/Makefile | 54 ++++++++++++++++++++++++++++++++++++++ apps/examples/adc/Makefile | 9 ++++--- apps/examples/buttons/Makefile | 9 ++++--- apps/examples/can/Makefile | 9 ++++--- apps/examples/cdcacm/Makefile | 11 +++++--- apps/examples/composite/Makefile | 11 +++++--- apps/examples/cxxtest/Makefile | 9 ++++--- apps/examples/dhcpd/Makefile | 9 ++++--- apps/examples/discover/Makefile | 9 ++++--- apps/examples/ftpc/Makefile | 10 ++++--- apps/examples/ftpd/Makefile | 11 +++++--- apps/examples/hello/Makefile | 9 ++++--- apps/examples/helloxx/Makefile | 9 ++++--- apps/examples/json/Makefile | 9 ++++--- apps/examples/keypadtest/Makefile | 9 ++++--- apps/examples/lcdrw/Makefile | 9 ++++--- apps/examples/modbus/Makefile | 9 ++++--- apps/examples/nettest/Makefile | 9 ++++--- apps/examples/nx/Makefile | 9 ++++--- apps/examples/nxhello/Makefile | 9 ++++--- apps/examples/nximage/Makefile | 9 ++++--- apps/examples/nxlines/Makefile | 9 ++++--- apps/examples/nxtext/Makefile | 9 ++++--- apps/examples/ostest/Makefile | 9 ++++--- apps/examples/pwm/Makefile | 9 ++++--- apps/examples/qencoder/Makefile | 9 ++++--- apps/examples/relays/Makefile | 9 ++++--- apps/examples/telnetd/Makefile | 9 ++++--- apps/examples/tiff/Makefile | 9 ++++--- apps/examples/touchscreen/Makefile | 9 ++++--- apps/examples/usbstorage/Makefile | 11 +++++--- apps/examples/usbterm/Makefile | 9 ++++--- apps/examples/watchdog/Makefile | 9 ++++--- apps/examples/wgetjson/Makefile | 9 ++++--- apps/examples/xmlrpc/Makefile | 9 ++++--- apps/graphics/tiff/Makefile | 1 - apps/interpreters/ficl/Makefile | 1 - apps/modbus/Makefile | 1 - apps/nshlib/Makefile | 1 - apps/system/free/Makefile | 10 ++++--- apps/system/i2c/Makefile | 12 +++++---- apps/system/install/Makefile | 10 ++++--- apps/system/poweroff/Makefile | 10 ++++--- apps/system/ramtron/Makefile | 10 ++++--- apps/system/readline/Makefile | 1 - apps/system/sdcard/Makefile | 10 ++++--- apps/system/sysinfo/Makefile | 10 ++++--- nuttx/Documentation/NuttShell.html | 9 ++----- nuttx/configs/vsn/src/Makefile | 9 ++++--- 53 files changed, 318 insertions(+), 201 deletions(-) create mode 100644 apps/builtin/registry/Makefile (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 886526b18..8999047ef 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -440,4 +440,8 @@ files. It makes sense for 'leaf' Makefiles to have this dependency, but it does not make sense for upper-level Makefiles. * namedapp/: Renamed to builtins in preparation for another change. + * .context: Removed the .context kludge. This causes lots of problems + when changing configurations because there is no easy way to get the + system to rebuild the context. Now, the context will be rebuilt + whenever there is a change in either .config or the Makefile. diff --git a/apps/Make.defs b/apps/Make.defs index 12b351e7f..217137a29 100644 --- a/apps/Make.defs +++ b/apps/Make.defs @@ -34,8 +34,11 @@ # ############################################################################ +BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry + define REGISTER - @echo "Register: $1" - @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h" - @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h" + $(Q) echo "Register: $1" + $(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$4.bdat" + $(Q) echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$4.pdat" + $(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated" endef diff --git a/apps/Makefile b/apps/Makefile index 299560195..cf6b33cd7 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -132,21 +132,16 @@ $(INSTALLED_APPS): $(BIN): $(INSTALLED_APPS) -.context: +context: ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) for %%G in ($(INSTALLED_APPS)) do ( \ - if exist %%G\.context del /f /q %%G\.context \ $(MAKE) -C %%G TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context \ ) else $(Q) for dir in $(INSTALLED_APPS) ; do \ - rm -f $$dir/.context ; \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context ; \ done endif - $(Q) touch $@ - -context: .context .depend: context Makefile $(SRCS) ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -183,7 +178,6 @@ ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(MAKE) -C %%G distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \ ) $(call DELFILE, .config) - $(call DELFILE, .context) $(call DELFILE, .depend) $(Q) ( if exist external ( \ echo ********************************************************" \ @@ -195,7 +189,6 @@ else $(MAKE) -C $$dir distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ done $(call DELFILE, .config) - $(call DELFILE, .context) $(call DELFILE, .depend) $(Q) ( if [ -e external ]; then \ echo "********************************************************"; \ diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index 72ba0347f..6633146e9 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -33,12 +33,9 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs include $(APPDIR)/Make.defs -# NSH Library - # Source and object files ASRCS = @@ -70,7 +67,7 @@ VPATH = # Build Targets all: .built -.PHONY: .context context depend clean distclean +.PHONY: context depend clean distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -78,16 +75,27 @@ $(AOBJS): %$(OBJEXT): %.S $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) -.built: $(OBJS) +builtin_list.h: registry/.updated + $(call DELFILE, builtin_list.h) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + $(Q) for /f %%G in ('dir /b registry\*.bdat`) do ( type registry\%%G >> builtin_list.h ) +else + $(Q) for file in `ls registry/*.bdat`; do cat $$file >> builtin_list.h; done +endif + +builtin_proto.h: registry/.updated + $(call DELFILE, builtin_proto.h) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + $(Q) for /f %%G in ('dir /b registry\*.pdat`) do ( type registry\%%G >> builtin_proto.h ) +else + $(Q) for file in `ls registry/*.pdat`; do cat $$file >> builtin_proto.h; done +endif + +.built: builtin_list.h builtin_proto.h $(OBJS) $(call ARCHIVE, $(BIN), $(OBJS)) $(Q) touch .built -.context: - @echo "/* List of application requirements, generated during make context. */" > builtin_list.h - @echo "/* List of application entry points, generated during make context. */" > builtin_proto.h - $(Q) touch $@ - -context: .context +context: .depend: Makefile $(SRCS) $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @@ -100,11 +108,10 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) + $(Q) $(MAKE) -C registry distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" $(call DELFILE, Make.dep) $(call DELFILE, .depend) $(call DELFILE, builtin_list.h) $(call DELFILE, builtin_proto.h) -include Make.dep - diff --git a/apps/builtin/registry/Makefile b/apps/builtin/registry/Makefile new file mode 100644 index 000000000..9117f53d6 --- /dev/null +++ b/apps/builtin/registry/Makefile @@ -0,0 +1,54 @@ +############################################################################ +# apps/builtin/registry/Makefile +# +# Copyright (C) 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# NSH Library + +all: +.PHONY: context depend clean distclean + +context: + +depend: + +clean: + $(call CLEAN) + +distclean: clean + $(call DELFILE, *.bdat) + $(call DELFILE, *.pdat) + $(call DELFILE, .updated) diff --git a/apps/examples/adc/Makefile b/apps/examples/adc/Makefile index 69862b383..55bc259e4 100644 --- a/apps/examples/adc/Makefile +++ b/apps/examples/adc/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/buttons/Makefile b/apps/examples/buttons/Makefile index 77c1cd67d..ac1f2f05a 100644 --- a/apps/examples/buttons/Makefile +++ b/apps/examples/buttons/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/can/Makefile b/apps/examples/can/Makefile index 8924797e3..5df96e1e7 100644 --- a/apps/examples/can/Makefile +++ b/apps/examples/can/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/cdcacm/Makefile b/apps/examples/cdcacm/Makefile index e8d03807d..d9e19e906 100644 --- a/apps/examples/cdcacm/Makefile +++ b/apps/examples/cdcacm/Makefile @@ -87,12 +87,17 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) - @touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/composite/Makefile b/apps/examples/composite/Makefile index 016ccbe3e..b1fe49308 100644 --- a/apps/examples/composite/Makefile +++ b/apps/examples/composite/Makefile @@ -87,14 +87,17 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/cxxtest/Makefile b/apps/examples/cxxtest/Makefile index f0764b6e9..cba9f0a4f 100644 --- a/apps/examples/cxxtest/Makefile +++ b/apps/examples/cxxtest/Makefile @@ -100,13 +100,14 @@ $(CXXOBJS): %$(OBJEXT): %.cxx $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/dhcpd/Makefile b/apps/examples/dhcpd/Makefile index a41db5cdd..0522d4cc4 100644 --- a/apps/examples/dhcpd/Makefile +++ b/apps/examples/dhcpd/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/discover/Makefile b/apps/examples/discover/Makefile index 2ce52a18e..b0285fbff 100644 --- a/apps/examples/discover/Makefile +++ b/apps/examples/discover/Makefile @@ -84,13 +84,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/ftpc/Makefile b/apps/examples/ftpc/Makefile index 29960fb94..e09779abd 100644 --- a/apps/examples/ftpc/Makefile +++ b/apps/examples/ftpc/Makefile @@ -83,11 +83,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -102,7 +105,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/examples/ftpd/Makefile b/apps/examples/ftpd/Makefile index 0b43b85a9..dc53bfdea 100644 --- a/apps/examples/ftpd/Makefile +++ b/apps/examples/ftpd/Makefile @@ -78,14 +78,17 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)ftpd_start.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,ftpd_start,SCHED_PRIORITY_DEFAULT,2048,ftpd_start) + +$(BUILTIN_REGISTRY)$(DELIM)ftpd_stop.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,ftpd_stop,SCHED_PRIORITY_DEFAULT,2048,ftpd_stop) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)ftpd_start.bdat $(BUILTIN_REGISTRY)$(DELIM)ftpd_stop.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/hello/Makefile b/apps/examples/hello/Makefile index 560b0da35..c4e6f735a 100644 --- a/apps/examples/hello/Makefile +++ b/apps/examples/hello/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/helloxx/Makefile b/apps/examples/helloxx/Makefile index 062da7d58..df1b360a5 100644 --- a/apps/examples/helloxx/Makefile +++ b/apps/examples/helloxx/Makefile @@ -100,13 +100,14 @@ $(CXXOBJS): %$(OBJEXT): %.cxx $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/json/Makefile b/apps/examples/json/Makefile index c3e9203f9..1e42757b8 100644 --- a/apps/examples/json/Makefile +++ b/apps/examples/json/Makefile @@ -81,13 +81,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/keypadtest/Makefile b/apps/examples/keypadtest/Makefile index 3de0556a2..0c40a5c6c 100644 --- a/apps/examples/keypadtest/Makefile +++ b/apps/examples/keypadtest/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/lcdrw/Makefile b/apps/examples/lcdrw/Makefile index ed612e0be..61d6bcce6 100644 --- a/apps/examples/lcdrw/Makefile +++ b/apps/examples/lcdrw/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/modbus/Makefile b/apps/examples/modbus/Makefile index d6caefe81..da31c3b52 100644 --- a/apps/examples/modbus/Makefile +++ b/apps/examples/modbus/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/nettest/Makefile b/apps/examples/nettest/Makefile index 085b9406d..e6f56e765 100644 --- a/apps/examples/nettest/Makefile +++ b/apps/examples/nettest/Makefile @@ -116,13 +116,14 @@ $(HOST_BIN): $(HOST_OBJS) $(call ARCHIVE, $(BIN), $(TARG_OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(TARG_SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep diff --git a/apps/examples/nx/Makefile b/apps/examples/nx/Makefile index ad2bee84e..4474a58c3 100644 --- a/apps/examples/nx/Makefile +++ b/apps/examples/nx/Makefile @@ -86,13 +86,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_NX_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/nxhello/Makefile b/apps/examples/nxhello/Makefile index b1ac6f116..52ced123d 100644 --- a/apps/examples/nxhello/Makefile +++ b/apps/examples/nxhello/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_NXHELLO_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/nximage/Makefile b/apps/examples/nximage/Makefile index e2e9201e7..98f04c2d5 100644 --- a/apps/examples/nximage/Makefile +++ b/apps/examples/nximage/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/nxlines/Makefile b/apps/examples/nxlines/Makefile index cdda7ad8c..9673a5520 100644 --- a/apps/examples/nxlines/Makefile +++ b/apps/examples/nxlines/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/nxtext/Makefile b/apps/examples/nxtext/Makefile index dffe66ba1..738209754 100644 --- a/apps/examples/nxtext/Makefile +++ b/apps/examples/nxtext/Makefile @@ -87,13 +87,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index 3e78c64e8..dfb500387 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -127,13 +127,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_OSTEST_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/pwm/Makefile b/apps/examples/pwm/Makefile index 3a6f2520a..d33d1c277 100644 --- a/apps/examples/pwm/Makefile +++ b/apps/examples/pwm/Makefile @@ -83,11 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/qencoder/Makefile b/apps/examples/qencoder/Makefile index 7d2427c6b..1caff2ed3 100644 --- a/apps/examples/qencoder/Makefile +++ b/apps/examples/qencoder/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/relays/Makefile b/apps/examples/relays/Makefile index 8e91ab572..17bf7a6a4 100644 --- a/apps/examples/relays/Makefile +++ b/apps/examples/relays/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/telnetd/Makefile b/apps/examples/telnetd/Makefile index 8f5e5b6d2..63876baa0 100644 --- a/apps/examples/telnetd/Makefile +++ b/apps/examples/telnetd/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/tiff/Makefile b/apps/examples/tiff/Makefile index f62209931..853e904a7 100644 --- a/apps/examples/tiff/Makefile +++ b/apps/examples/tiff/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_TIFF_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/touchscreen/Makefile b/apps/examples/touchscreen/Makefile index b3943951e..8761cc5b5 100644 --- a/apps/examples/touchscreen/Makefile +++ b/apps/examples/touchscreen/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/usbstorage/Makefile b/apps/examples/usbstorage/Makefile index 5492e47dc..a1eb77836 100644 --- a/apps/examples/usbstorage/Makefile +++ b/apps/examples/usbstorage/Makefile @@ -87,14 +87,17 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_USBMSC_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/usbterm/Makefile b/apps/examples/usbterm/Makefile index c5fb95331..3b3ca6cd7 100644 --- a/apps/examples/usbterm/Makefile +++ b/apps/examples/usbterm/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_EXAMPLES_USBTERM_BUILTIN),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/watchdog/Makefile b/apps/examples/watchdog/Makefile index 9890959fb..cf947b011 100644 --- a/apps/examples/watchdog/Makefile +++ b/apps/examples/watchdog/Makefile @@ -83,11 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/wgetjson/Makefile b/apps/examples/wgetjson/Makefile index fa8f302c6..38bd8ac04 100644 --- a/apps/examples/wgetjson/Makefile +++ b/apps/examples/wgetjson/Makefile @@ -83,13 +83,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/xmlrpc/Makefile b/apps/examples/xmlrpc/Makefile index 7053f54d3..4756bfabb 100644 --- a/apps/examples/xmlrpc/Makefile +++ b/apps/examples/xmlrpc/Makefile @@ -84,13 +84,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -.context: ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ -endif -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/graphics/tiff/Makefile b/apps/graphics/tiff/Makefile index e42091ad9..b5f6c5b73 100644 --- a/apps/graphics/tiff/Makefile +++ b/apps/graphics/tiff/Makefile @@ -90,7 +90,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/interpreters/ficl/Makefile b/apps/interpreters/ficl/Makefile index 990630fb8..3b2dc7ab9 100644 --- a/apps/interpreters/ficl/Makefile +++ b/apps/interpreters/ficl/Makefile @@ -108,7 +108,6 @@ context: depend: .depend clean: - $(call DELFILE, .context) $(call DELFILE, .built) $(call CLEAN) diff --git a/apps/modbus/Makefile b/apps/modbus/Makefile index d2b148162..27548f3d6 100644 --- a/apps/modbus/Makefile +++ b/apps/modbus/Makefile @@ -111,7 +111,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/nshlib/Makefile b/apps/nshlib/Makefile index 73325e899..7ddbb67bf 100644 --- a/apps/nshlib/Makefile +++ b/apps/nshlib/Makefile @@ -130,7 +130,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/free/Makefile b/apps/system/free/Makefile index dada00d99..4f6424f50 100644 --- a/apps/system/free/Makefile +++ b/apps/system/free/Makefile @@ -92,11 +92,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -111,7 +114,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/i2c/Makefile b/apps/system/i2c/Makefile index 029d2b6fe..7f42801a9 100644 --- a/apps/system/i2c/Makefile +++ b/apps/system/i2c/Makefile @@ -68,7 +68,7 @@ STACKSIZE = 2048 # Build targets all: .built -.PHONY: .context context .depend depend clean distclean +.PHONY: context .depend depend clean distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -80,11 +80,14 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) $(Q) touch .built -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif .depend: Makefile $(SRCS) $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @@ -97,7 +100,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/install/Makefile b/apps/system/install/Makefile index 6a02d859f..aa65e60ed 100644 --- a/apps/system/install/Makefile +++ b/apps/system/install/Makefile @@ -93,11 +93,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -112,7 +115,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/poweroff/Makefile b/apps/system/poweroff/Makefile index bbceccb9e..0067a13ab 100644 --- a/apps/system/poweroff/Makefile +++ b/apps/system/poweroff/Makefile @@ -93,11 +93,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -112,7 +115,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/ramtron/Makefile b/apps/system/ramtron/Makefile index 9f5af1659..1c92398f3 100644 --- a/apps/system/ramtron/Makefile +++ b/apps/system/ramtron/Makefile @@ -93,11 +93,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -112,7 +115,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/readline/Makefile b/apps/system/readline/Makefile index 3a48d324e..040fd2e28 100644 --- a/apps/system/readline/Makefile +++ b/apps/system/readline/Makefile @@ -100,7 +100,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/sdcard/Makefile b/apps/system/sdcard/Makefile index 6d5d12960..6c580ba86 100644 --- a/apps/system/sdcard/Makefile +++ b/apps/system/sdcard/Makefile @@ -93,11 +93,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -112,7 +115,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/apps/system/sysinfo/Makefile b/apps/system/sysinfo/Makefile index fa6aebf71..d233aa3d8 100644 --- a/apps/system/sysinfo/Makefile +++ b/apps/system/sysinfo/Makefile @@ -93,11 +93,14 @@ $(COBJS): %$(OBJEXT): %.c # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies @@ -112,7 +115,6 @@ clean: $(call CLEAN) distclean: clean - $(call DELFILE, .context) $(call DELFILE, Make.dep) $(call DELFILE, .depend) diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index cc3f078dd..7ad96da79 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -3349,11 +3349,7 @@ int hello_main(int argc, char *argv[])

  • - And finally, the apps/examples/Makefilewill execute the context target in all configured examplesub-directores, getting us finally to apps/examples/Makefile (which is covered below).

    -
  • -

    - At the conclusion of the context phase, the apps/Makefile will touch a file called .context in the apps/ directory, preventing any further configurations during any subsequent context phase build attempts. -

    + And finally, the apps/examples/Makefile will execute the context target in all configured examplesub-directores, getting us finally to apps/examples/Makefile which is covered below.

    @@ -3417,9 +3413,8 @@ STACKSIZE = 2048 When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2K.

      -.context:
      +context:
         $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
      -  @touch $@
       
    diff --git a/nuttx/configs/vsn/src/Makefile b/nuttx/configs/vsn/src/Makefile index a71c80c8a..b0eba0a20 100644 --- a/nuttx/configs/vsn/src/Makefile +++ b/nuttx/configs/vsn/src/Makefile @@ -85,11 +85,14 @@ libboard$(LIBEXT): $(OBJS) # Register application -.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - $(Q) touch $@ -context: .context +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif # Create dependencies -- cgit v1.2.3 From 424d1af00f29a81ec98b9b91bc518b70fb8e2013 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 24 Dec 2012 13:15:57 +0000 Subject: Some fixes to apps/builtin/registry need to handle some additional cases git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5456 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 5 ++++- apps/Make.defs | 6 ++++++ apps/builtin/Makefile | 2 ++ apps/builtin/registry/Makefile | 9 ++++++++- apps/examples/adc/Makefile | 2 +- apps/examples/buttons/Makefile | 2 +- apps/examples/can/Makefile | 2 +- apps/examples/cdcacm/Makefile | 4 ++-- apps/examples/composite/Makefile | 4 ++-- apps/examples/cxxtest/Makefile | 2 +- apps/examples/dhcpd/Makefile | 2 +- apps/examples/discover/Makefile | 2 +- apps/examples/ftpc/Makefile | 2 +- apps/examples/ftpd/Makefile | 4 ++-- apps/examples/hello/Makefile | 2 +- apps/examples/helloxx/Makefile | 2 +- apps/examples/json/Makefile | 2 +- apps/examples/keypadtest/Makefile | 2 +- apps/examples/lcdrw/Makefile | 2 +- apps/examples/modbus/Makefile | 2 +- apps/examples/nettest/Makefile | 2 +- apps/examples/nx/Makefile | 2 +- apps/examples/nxhello/Makefile | 2 +- apps/examples/nximage/Makefile | 2 +- apps/examples/nxlines/Makefile | 2 +- apps/examples/nxtext/Makefile | 2 +- apps/examples/ostest/Makefile | 2 +- apps/examples/pwm/Makefile | 2 +- apps/examples/qencoder/Makefile | 2 +- apps/examples/relays/Makefile | 2 +- apps/examples/telnetd/Makefile | 2 +- apps/examples/tiff/Makefile | 2 +- apps/examples/touchscreen/Makefile | 2 +- apps/examples/usbstorage/Makefile | 4 ++-- apps/examples/usbterm/Makefile | 2 +- apps/examples/watchdog/Makefile | 2 +- apps/examples/wgetjson/Makefile | 2 +- apps/examples/xmlrpc/Makefile | 2 +- apps/system/free/Makefile | 2 +- apps/system/i2c/Makefile | 2 +- apps/system/install/Makefile | 2 +- apps/system/poweroff/Makefile | 2 +- apps/system/ramtron/Makefile | 2 +- apps/system/sdcard/Makefile | 2 +- apps/system/sysinfo/Makefile | 2 +- 45 files changed, 65 insertions(+), 47 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 8999047ef..09a4f634d 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -440,8 +440,11 @@ files. It makes sense for 'leaf' Makefiles to have this dependency, but it does not make sense for upper-level Makefiles. * namedapp/: Renamed to builtins in preparation for another change. - * .context: Removed the .context kludge. This causes lots of problems + * .context: Removed the .context kludge. This caused lots of problems when changing configurations because there is no easy way to get the system to rebuild the context. Now, the context will be rebuilt whenever there is a change in either .config or the Makefile. + * builtin/registry: Updated new built-in registration logic to handle + cases where (1) old apps/.config is used, and (2) applications ared + removed, not just added. diff --git a/apps/Make.defs b/apps/Make.defs index 217137a29..c62999804 100644 --- a/apps/Make.defs +++ b/apps/Make.defs @@ -36,6 +36,12 @@ BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry +ifeq ($(CONFIG_NUTTX_NEWCONFIG),y) +DEPCONFIG = $(TOPDIR)/.config +else +DEPCONFIG = $(TOPDIR)/.config $(APPDIR)/.config +endif + define REGISTER $(Q) echo "Register: $1" $(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$4.bdat" diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index 6633146e9..2d8b0193e 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -96,6 +96,7 @@ endif $(Q) touch .built context: + $(Q) $(MAKE) -C registry context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" .depend: Makefile $(SRCS) $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @@ -104,6 +105,7 @@ context: depend: .depend clean: + $(Q) $(MAKE) -C registry clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" $(call DELFILE, .built) $(call CLEAN) diff --git a/apps/builtin/registry/Makefile b/apps/builtin/registry/Makefile index 9117f53d6..4ecd5da9f 100644 --- a/apps/builtin/registry/Makefile +++ b/apps/builtin/registry/Makefile @@ -41,7 +41,14 @@ include $(APPDIR)/Make.defs all: .PHONY: context depend clean distclean -context: +.updated: $(DEPCONFIG) + $(call DELFILE, *.bdat) + $(call DELFILE, *.pdat) + $(Q) touch .updated + +# This must run before any other context target + +context: .updated depend: diff --git a/apps/examples/adc/Makefile b/apps/examples/adc/Makefile index 55bc259e4..3cbe843f6 100644 --- a/apps/examples/adc/Makefile +++ b/apps/examples/adc/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/buttons/Makefile b/apps/examples/buttons/Makefile index ac1f2f05a..a2e8679d4 100644 --- a/apps/examples/buttons/Makefile +++ b/apps/examples/buttons/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/can/Makefile b/apps/examples/can/Makefile index 5df96e1e7..548c6702c 100644 --- a/apps/examples/can/Makefile +++ b/apps/examples/can/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/cdcacm/Makefile b/apps/examples/cdcacm/Makefile index d9e19e906..2cf3a107f 100644 --- a/apps/examples/cdcacm/Makefile +++ b/apps/examples/cdcacm/Makefile @@ -88,10 +88,10 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat diff --git a/apps/examples/composite/Makefile b/apps/examples/composite/Makefile index b1fe49308..1f05d9c64 100644 --- a/apps/examples/composite/Makefile +++ b/apps/examples/composite/Makefile @@ -88,10 +88,10 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat diff --git a/apps/examples/cxxtest/Makefile b/apps/examples/cxxtest/Makefile index cba9f0a4f..97fdb6ede 100644 --- a/apps/examples/cxxtest/Makefile +++ b/apps/examples/cxxtest/Makefile @@ -101,7 +101,7 @@ $(CXXOBJS): %$(OBJEXT): %.cxx @touch .built ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/dhcpd/Makefile b/apps/examples/dhcpd/Makefile index 0522d4cc4..d718d79e1 100644 --- a/apps/examples/dhcpd/Makefile +++ b/apps/examples/dhcpd/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/discover/Makefile b/apps/examples/discover/Makefile index b0285fbff..033ab1131 100644 --- a/apps/examples/discover/Makefile +++ b/apps/examples/discover/Makefile @@ -85,7 +85,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/ftpc/Makefile b/apps/examples/ftpc/Makefile index e09779abd..cc966f8d6 100644 --- a/apps/examples/ftpc/Makefile +++ b/apps/examples/ftpc/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/ftpd/Makefile b/apps/examples/ftpd/Makefile index dc53bfdea..dd18d5043 100644 --- a/apps/examples/ftpd/Makefile +++ b/apps/examples/ftpd/Makefile @@ -79,10 +79,10 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)ftpd_start.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)ftpd_start.bdat: $(DEPCONFIG) Makefile $(call REGISTER,ftpd_start,SCHED_PRIORITY_DEFAULT,2048,ftpd_start) -$(BUILTIN_REGISTRY)$(DELIM)ftpd_stop.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)ftpd_stop.bdat: $(DEPCONFIG) Makefile $(call REGISTER,ftpd_stop,SCHED_PRIORITY_DEFAULT,2048,ftpd_stop) context: $(BUILTIN_REGISTRY)$(DELIM)ftpd_start.bdat $(BUILTIN_REGISTRY)$(DELIM)ftpd_stop.bdat diff --git a/apps/examples/hello/Makefile b/apps/examples/hello/Makefile index c4e6f735a..fc98fa7f4 100644 --- a/apps/examples/hello/Makefile +++ b/apps/examples/hello/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/helloxx/Makefile b/apps/examples/helloxx/Makefile index df1b360a5..44d880658 100644 --- a/apps/examples/helloxx/Makefile +++ b/apps/examples/helloxx/Makefile @@ -101,7 +101,7 @@ $(CXXOBJS): %$(OBJEXT): %.cxx @touch .built ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/json/Makefile b/apps/examples/json/Makefile index 1e42757b8..f6a38fb1a 100644 --- a/apps/examples/json/Makefile +++ b/apps/examples/json/Makefile @@ -82,7 +82,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/keypadtest/Makefile b/apps/examples/keypadtest/Makefile index 0c40a5c6c..e38e66a82 100644 --- a/apps/examples/keypadtest/Makefile +++ b/apps/examples/keypadtest/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/lcdrw/Makefile b/apps/examples/lcdrw/Makefile index 61d6bcce6..aab04acf5 100644 --- a/apps/examples/lcdrw/Makefile +++ b/apps/examples/lcdrw/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/modbus/Makefile b/apps/examples/modbus/Makefile index da31c3b52..b2fba6764 100644 --- a/apps/examples/modbus/Makefile +++ b/apps/examples/modbus/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nettest/Makefile b/apps/examples/nettest/Makefile index e6f56e765..a0308713c 100644 --- a/apps/examples/nettest/Makefile +++ b/apps/examples/nettest/Makefile @@ -117,7 +117,7 @@ $(HOST_BIN): $(HOST_OBJS) @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nx/Makefile b/apps/examples/nx/Makefile index 4474a58c3..13a938821 100644 --- a/apps/examples/nx/Makefile +++ b/apps/examples/nx/Makefile @@ -87,7 +87,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_NX_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nxhello/Makefile b/apps/examples/nxhello/Makefile index 52ced123d..4a72eb8c7 100644 --- a/apps/examples/nxhello/Makefile +++ b/apps/examples/nxhello/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_NXHELLO_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nximage/Makefile b/apps/examples/nximage/Makefile index 98f04c2d5..7bdaa46d2 100644 --- a/apps/examples/nximage/Makefile +++ b/apps/examples/nximage/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nxlines/Makefile b/apps/examples/nxlines/Makefile index 9673a5520..54495b292 100644 --- a/apps/examples/nxlines/Makefile +++ b/apps/examples/nxlines/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/nxtext/Makefile b/apps/examples/nxtext/Makefile index 738209754..dfb165608 100644 --- a/apps/examples/nxtext/Makefile +++ b/apps/examples/nxtext/Makefile @@ -88,7 +88,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index dfb500387..3d19f6a78 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -128,7 +128,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_OSTEST_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/pwm/Makefile b/apps/examples/pwm/Makefile index d33d1c277..ece901a99 100644 --- a/apps/examples/pwm/Makefile +++ b/apps/examples/pwm/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/qencoder/Makefile b/apps/examples/qencoder/Makefile index 1caff2ed3..9668796e6 100644 --- a/apps/examples/qencoder/Makefile +++ b/apps/examples/qencoder/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/relays/Makefile b/apps/examples/relays/Makefile index 17bf7a6a4..1ab4c8716 100644 --- a/apps/examples/relays/Makefile +++ b/apps/examples/relays/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/telnetd/Makefile b/apps/examples/telnetd/Makefile index 63876baa0..4391870c0 100644 --- a/apps/examples/telnetd/Makefile +++ b/apps/examples/telnetd/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/tiff/Makefile b/apps/examples/tiff/Makefile index 853e904a7..17b3bb92c 100644 --- a/apps/examples/tiff/Makefile +++ b/apps/examples/tiff/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_TIFF_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/touchscreen/Makefile b/apps/examples/touchscreen/Makefile index 8761cc5b5..1a65c7282 100644 --- a/apps/examples/touchscreen/Makefile +++ b/apps/examples/touchscreen/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/usbstorage/Makefile b/apps/examples/usbstorage/Makefile index a1eb77836..6c486bf9c 100644 --- a/apps/examples/usbstorage/Makefile +++ b/apps/examples/usbstorage/Makefile @@ -88,10 +88,10 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_USBMSC_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat diff --git a/apps/examples/usbterm/Makefile b/apps/examples/usbterm/Makefile index 3b3ca6cd7..91e80686e 100644 --- a/apps/examples/usbterm/Makefile +++ b/apps/examples/usbterm/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_EXAMPLES_USBTERM_BUILTIN),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/watchdog/Makefile b/apps/examples/watchdog/Makefile index cf947b011..076272fe3 100644 --- a/apps/examples/watchdog/Makefile +++ b/apps/examples/watchdog/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/wgetjson/Makefile b/apps/examples/wgetjson/Makefile index 38bd8ac04..89cb3e11e 100644 --- a/apps/examples/wgetjson/Makefile +++ b/apps/examples/wgetjson/Makefile @@ -84,7 +84,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/examples/xmlrpc/Makefile b/apps/examples/xmlrpc/Makefile index 4756bfabb..b103fd7ed 100644 --- a/apps/examples/xmlrpc/Makefile +++ b/apps/examples/xmlrpc/Makefile @@ -85,7 +85,7 @@ $(COBJS): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/free/Makefile b/apps/system/free/Makefile index 4f6424f50..58ca7956c 100644 --- a/apps/system/free/Makefile +++ b/apps/system/free/Makefile @@ -93,7 +93,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/i2c/Makefile b/apps/system/i2c/Makefile index 7f42801a9..1ed7a2fae 100644 --- a/apps/system/i2c/Makefile +++ b/apps/system/i2c/Makefile @@ -81,7 +81,7 @@ $(COBJS): %$(OBJEXT): %.c $(Q) touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/install/Makefile b/apps/system/install/Makefile index aa65e60ed..07d42887a 100644 --- a/apps/system/install/Makefile +++ b/apps/system/install/Makefile @@ -94,7 +94,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/poweroff/Makefile b/apps/system/poweroff/Makefile index 0067a13ab..eb7518fbc 100644 --- a/apps/system/poweroff/Makefile +++ b/apps/system/poweroff/Makefile @@ -94,7 +94,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/ramtron/Makefile b/apps/system/ramtron/Makefile index 1c92398f3..b47781095 100644 --- a/apps/system/ramtron/Makefile +++ b/apps/system/ramtron/Makefile @@ -94,7 +94,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/sdcard/Makefile b/apps/system/sdcard/Makefile index 6c580ba86..d748b2b04 100644 --- a/apps/system/sdcard/Makefile +++ b/apps/system/sdcard/Makefile @@ -94,7 +94,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat diff --git a/apps/system/sysinfo/Makefile b/apps/system/sysinfo/Makefile index d233aa3d8..eb788b01a 100644 --- a/apps/system/sysinfo/Makefile +++ b/apps/system/sysinfo/Makefile @@ -94,7 +94,7 @@ $(COBJS): %$(OBJEXT): %.c # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(TOPDIR)$(DELIM).config Makefile +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat -- cgit v1.2.3 From 5859e0d35365a89d1b3001f562f89dd81d001302 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 24 Dec 2012 14:31:02 +0000 Subject: Correct round-to-ticks logic in sigtimedwait() git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5457 42af7a65-404d-4744-a932-0658087f49c3 --- apps/README.txt | 114 +++++++++++++++++++++++++++++++++++++------- nuttx/ChangeLog | 3 ++ nuttx/sched/sig_timedwait.c | 22 +++++++-- 3 files changed, 118 insertions(+), 21 deletions(-) (limited to 'apps') diff --git a/apps/README.txt b/apps/README.txt index 4f043dcfa..328126905 100644 --- a/apps/README.txt +++ b/apps/README.txt @@ -17,15 +17,15 @@ Contents General ------- This folder provides various applications found in sub-directories. These -applications are not inherently a part of NuttX but are provided you help +applications are not inherently a part of NuttX but are provided to help you develop your own applications. The apps/ directory is a "break away" -part of the configuration that you may chose to use or not. +part of the configuration that you may choose to use or not. Directory Location ------------------ The default application directory used by the NuttX build should be named apps/ (or apps-x.y/ where x.y is the NuttX version number). This apps/ -directoy should appear in the directory tree at the same level as the +directory should appear in the directory tree at the same level as the NuttX directory. Like: . @@ -54,7 +54,7 @@ In this case, application entry points with their requirements are gathered together in two files: - builtin/builtin_proto.h Entry points, prototype function - - builtin/builtin_list.h Application specific information and requirements + - builtin/builtin_list.h Application specific information and requirements The build occurs in several phases as different build targets are executed: (1) context, (2) depend, and (3) default (all). Application information is @@ -96,11 +96,11 @@ after the NSH command. Application Configuration File ------------------------------ -A special configuration file is used to configure which applications -are to be included in the build. The source for this file is -configs///appconfig. The existence of the appconfig -file in the board configuration directory is sufficient to enable building -of applications. +The old-style NuttX configuration uses a special configuration file is +used to configure which applications are to be included in the build. +The source for this file is configs///appconfig. +The existence of the appconfig file in the board configuration directory\ +is sufficient to enable building of applications. The appconfig file is copied into the apps/ directory as .config when NuttX is configured. .config is included in the toplevel apps/Makefile. @@ -109,6 +109,38 @@ CONFIGURED_APPS list like: CONFIGURED_APPS += examples/hello system/poweroff +The new NuttX configuration uses kconfig-frontends tools and only the +NuttX .config file. The new configuration is indicated by the existence +of the definition CONFIG_NUTTX_NEWCONFIG=y in the NuttX .config file. +If CONFIG_NUTTX_NEWCONFIG is defined, then the Makefile will: + +- Assume that there is no apps/.config file and will instead +- Include Make.defs files from each of the subdirectories. + +When an application is enabled using the kconfig-frontends tool, then +a new definition is added to the NuttX .config file. For example, if +you want to enable apps/examples/hello then the old apps/.config would +have had: + + CONFIGURED_APPS += examples/hello + +But in the new configuration there will be no apps/.config file and, +instead, the NuttX .config will have: + + CONFIG_EXAMPLES_HELLO=y + +This will select the apps/examples/hello in the following way: + +- The top-level make will include examples/Make.defs +- examples/Make.defs will set CONFIGURED_APPS += examples/hello + like this: + + ifeq ($(CONFIG_EXAMPLES_HELLO),y) + CONFIGURED_APPS += examples/hello + endif + +Thus accomplishing the same thing with no apps/.config file. + Built-In Start-Up main() function ------------------------------ A builtin application can even be used as the main, start-up entry point @@ -130,17 +162,63 @@ An example application skeleton can be found under the examples/hello sub-directory. This example shows how a builtin application can be added to the project. One must define: - 1. create sub-directory as: appname - 2. provide entry point: appname_main() - 3. set the requirements in the file: Makefile, specially the lines: +Old configuration method: + + 1. Create sub-directory as: appname + + 2. In this directory there should be: + + - A Makefile, and + - The application source code. + + 3. The application source code should provide the entry point: + appname_main() + + 4. Set the requirements in the file: Makefile, specially the lines: + + APPNAME = appname + PRIORITY = SCHED_PRIORITY_DEFAULT + STACKSIZE = 768 + ASRCS = asm source file list as a.asm b.asm ... + CSRCS = C source file list as foo1.c foo2.c .. + + Look at some of the other Makefiles for examples. Note the + special registration logic needed for the context: target + + 5. Add the to the application to the CONFIGIURED_APPS in the + apps/.config file: + + CONFIGURED_APPS += appname + +New Configuration Method: + + 1. Create sub-directory as: appname + + 2. In this directory there should be: + + - A Make.defs file that would be included by the apps/Makefile + - A Kconfig file that would be used by the configuration tool (see + misc/tools/kconfig-language.txt). This Kconfig file should be + included by the apps/Kconfig file + - A Makefile, and + - The application source code. + + 3. The application source code should provide the entry point: + appname_main() + + 4. Set the requirements in the file: Makefile, specially the lines: + + APPNAME = appname + PRIORITY = SCHED_PRIORITY_DEFAULT + STACKSIZE = 768 + ASRCS = asm source file list as a.asm b.asm ... + CSRCS = C source file list as foo1.c foo2.c .. - APPNAME = appname - PRIORITY = SCHED_PRIORITY_DEFAULT - STACKSIZE = 768 - ASRCS = asm source file list as a.asm b.asm ... - CSRCS = C source file list as foo1.c foo2.c .. + 4b. The Make.defs file should include a line like: - 4. add application in the apps/.config + ifeq ($(CONFIG_APPNAME),y) + CONFIGURED_APPS += appname + endif Building NuttX with Board-Specific Pieces Outside the Source Tree ----------------------------------------------------------------- diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 56edf9487..6c6fd7843 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3812,4 +3812,7 @@ * include/pthread.h: In sys/prctl.h because it is needed by pthread_[set|get]name_np() * tools/kconfig.bat: Kludge to run kconfig-frontends from a DOS shell. + * sched/sig_timedwait.c: Should always move the time up to the next + largest number of system ticks. The logic was rounding. Noted by + Petteri Aimonen. diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index 1b8dfd162..d03611610 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -238,10 +238,25 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, if (timeout) { - /* Convert the timespec to milliseconds */ + /* Convert the timespec to system clock ticks, making sure that + * the resultint delay is greater than or equal to the requested + * time in nanoseconds. + */ - waitticks = MSEC2TICK(timeout->tv_sec * MSEC_PER_SEC - + timeout->tv_nsec / NSEC_PER_MSEC); +#ifdef CONFIG_HAVE_LONG_LONG + uint64_t waitticks64 = (timeout->tv_sec * NSEC_PER_SEC + + timeout->tv_nsec + NSEC_PER_TICK - 1) / + NSEC_PER_TICK; + DEBUGASSERT(waitticks64 <= UINT32_MAX); + waitticks = (uint32_t)waitticks64; +#else + uint32_t waitmsec; + + DEBUGASSERT(timeout->tv_sec < UINT32_MAX / MSEC_PER_SEC); + waitmsec = timeout->tv_sec * MSEC_PER_SEC + + (timeout->tv_nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC; + waitticks = (waitmsec + MSEC_PER_TICK - 1) / MSEC_PER_TICK; +#endif /* Create a watchdog */ @@ -326,6 +341,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, { memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo)); } + irqrestore(saved_state); } -- cgit v1.2.3 From 7c73fe57c659ce9f9a31a247b04f7068a0b62cb1 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 24 Dec 2012 17:49:58 +0000 Subject: Fixes for l3s, USB composite, nfsmount, apps context build problems git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5458 42af7a65-404d-4744-a932-0658087f49c3 --- apps/builtin/Makefile | 16 ++++++++++++++-- apps/nshlib/nsh_mntcmds.c | 3 +++ apps/nshlib/nsh_netcmds.c | 1 + nuttx/configs/ekk-lm3s9b96/nsh/setenv.sh | 12 ++++++++---- nuttx/configs/ekk-lm3s9b96/ostest/setenv.sh | 12 ++++++++---- nuttx/configs/lm3s8962-ek/nsh/appconfig | 2 +- nuttx/configs/lm3s8962-ek/nsh/setenv.sh | 26 +++++++++++++++++++++----- nuttx/configs/lm3s8962-ek/nx/setenv.sh | 26 +++++++++++++++++++++----- nuttx/configs/lm3s8962-ek/ostest/setenv.sh | 26 +++++++++++++++++++++----- nuttx/configs/stm3210e-eval/RIDE/defconfig | 2 +- nuttx/drivers/usbdev/composite.c | 4 ++-- nuttx/include/nuttx/clock.h | 2 +- nuttx/sched/sig_timedwait.c | 5 +++-- 13 files changed, 105 insertions(+), 32 deletions(-) (limited to 'apps') diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index 2d8b0193e..0efb832f8 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -77,18 +77,30 @@ $(COBJS): %$(OBJEXT): %.c builtin_list.h: registry/.updated $(call DELFILE, builtin_list.h) + $(Q) touch builtin_list.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) for /f %%G in ('dir /b registry\*.bdat`) do ( type registry\%%G >> builtin_list.h ) else - $(Q) for file in `ls registry/*.bdat`; do cat $$file >> builtin_list.h; done + $(Q) ( \ + filelist=`ls registry/*.bdat 2>/dev/null || echo ""`; \ + for file in $$filelist; \ + do cat $$file >> builtin_list.h; \ + done; \ + ) endif builtin_proto.h: registry/.updated $(call DELFILE, builtin_proto.h) + $(Q) touch builtin_proto.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) for /f %%G in ('dir /b registry\*.pdat`) do ( type registry\%%G >> builtin_proto.h ) else - $(Q) for file in `ls registry/*.pdat`; do cat $$file >> builtin_proto.h; done + $(Q) ( \ + filelist=`ls registry/*.pdat 2>/dev/null || echo ""`; \ + for file in $$filelist; \ + do cat $$file >> builtin_proto.h; \ + done; \ + ) endif .built: builtin_list.h builtin_proto.h $(OBJS) diff --git a/apps/nshlib/nsh_mntcmds.c b/apps/nshlib/nsh_mntcmds.c index 690d027ca..f6eb26c31 100644 --- a/apps/nshlib/nsh_mntcmds.c +++ b/apps/nshlib/nsh_mntcmds.c @@ -45,10 +45,13 @@ #include #include +#include #include #include #include +#include + #include "nsh.h" #include "nsh_console.h" diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index 371d30460..506950e14 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -67,6 +67,7 @@ #if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \ !defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS) # include +# include #endif #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 diff --git a/nuttx/configs/ekk-lm3s9b96/nsh/setenv.sh b/nuttx/configs/ekk-lm3s9b96/nsh/setenv.sh index 6e591e0dd..bba7595de 100755 --- a/nuttx/configs/ekk-lm3s9b96/nsh/setenv.sh +++ b/nuttx/configs/ekk-lm3s9b96/nsh/setenv.sh @@ -48,12 +48,16 @@ if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}" fi -# TOOLCHAIN_BIN must be defined to the full path to the location where you -# have installed the toolchain of your choice. Modify the following: +# 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" +# This is the Cygwin path to the location where I build the buildroot +# toolchain. export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" -# Andd add the toolchain path to the PATH variable - +# Add the path to the toolchain to the PATH varialble export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + echo "PATH : ${PATH}" diff --git a/nuttx/configs/ekk-lm3s9b96/ostest/setenv.sh b/nuttx/configs/ekk-lm3s9b96/ostest/setenv.sh index d98c6cc40..60dfa3c71 100755 --- a/nuttx/configs/ekk-lm3s9b96/ostest/setenv.sh +++ b/nuttx/configs/ekk-lm3s9b96/ostest/setenv.sh @@ -48,12 +48,16 @@ if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}" fi -# TOOLCHAIN_BIN must be defined to the full path to the location where you -# have installed the toolchain of your choice. Modify the following: +# 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" +# This is the Cygwin path to the location where I build the buildroot +# toolchain. export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" -# Andd add the toolchain path to the PATH variable - +# Add the path to the toolchain to the PATH varialble export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + echo "PATH : ${PATH}" diff --git a/nuttx/configs/lm3s8962-ek/nsh/appconfig b/nuttx/configs/lm3s8962-ek/nsh/appconfig index 5eeb56607..2e2421b67 100644 --- a/nuttx/configs/lm3s8962-ek/nsh/appconfig +++ b/nuttx/configs/lm3s8962-ek/nsh/appconfig @@ -40,7 +40,7 @@ CONFIGURED_APPS += examples/nsh # NSH library CONFIGURED_APPS += system/readline -CONFIGURED_APPS += nshlibO +CONFIGURED_APPS += nshlib # Networking support diff --git a/nuttx/configs/lm3s8962-ek/nsh/setenv.sh b/nuttx/configs/lm3s8962-ek/nsh/setenv.sh index 511552d94..1db7f8ee2 100755 --- a/nuttx/configs/lm3s8962-ek/nsh/setenv.sh +++ b/nuttx/configs/lm3s8962-ek/nsh/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi - WD=`pwd` -export BUILDROOT_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" -export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/lm3s8962-ek/nx/setenv.sh b/nuttx/configs/lm3s8962-ek/nx/setenv.sh index a36725083..c716ddf5e 100755 --- a/nuttx/configs/lm3s8962-ek/nx/setenv.sh +++ b/nuttx/configs/lm3s8962-ek/nx/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi - WD=`pwd` -export BUILDROOT_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" -export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/lm3s8962-ek/ostest/setenv.sh b/nuttx/configs/lm3s8962-ek/ostest/setenv.sh index 6bd49b6fa..91bf1095b 100755 --- a/nuttx/configs/lm3s8962-ek/ostest/setenv.sh +++ b/nuttx/configs/lm3s8962-ek/ostest/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi - WD=`pwd` -export BUILDROOT_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" -export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/stm3210e-eval/RIDE/defconfig b/nuttx/configs/stm3210e-eval/RIDE/defconfig index 64665f47e..e71540c24 100755 --- a/nuttx/configs/stm3210e-eval/RIDE/defconfig +++ b/nuttx/configs/stm3210e-eval/RIDE/defconfig @@ -169,7 +169,7 @@ CONFIG_RAW_BINARY=n # # General OS setup # -#CONFIG_USER_ENTRYPOINT= +CONFIG_USER_ENTRYPOINT="null_main" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n diff --git a/nuttx/drivers/usbdev/composite.c b/nuttx/drivers/usbdev/composite.c index 4cad8af86..530d64416 100644 --- a/nuttx/drivers/usbdev/composite.c +++ b/nuttx/drivers/usbdev/composite.c @@ -523,12 +523,12 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, { /* Save the configuration and inform the constituent classes */ - ret = CLASS_SETUP(priv->dev1, dev, ctrl); + ret = CLASS_SETUP(priv->dev1, dev, ctrl, dataout, outlen); dispatched = true; if (ret >= 0) { - ret = CLASS_SETUP(priv->dev2, dev, ctrl); + ret = CLASS_SETUP(priv->dev2, dev, ctrl, dataout, outlen); if (ret >= 0) { priv->config = value; diff --git a/nuttx/include/nuttx/clock.h b/nuttx/include/nuttx/clock.h index 952e0e5ef..e640ecd2e 100644 --- a/nuttx/include/nuttx/clock.h +++ b/nuttx/include/nuttx/clock.h @@ -113,7 +113,7 @@ #define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */ #define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */ #define DSEC2TICK(dsec) MSEC2TICK((dsec)*MSEC_PER_DSEC) -#define SEC2TICK(sec) MSEC2TICK((sec)*MSEC_PER_SEC) +#define SEC2TICK(sec) MSEC2TICK((sec)*MSEC_PER_SEC) /* Exact */ #define TICK2NSEC(tick) ((tick)*NSEC_PER_TICK) /* Exact */ #define TICK2USEC(tick) ((tick)*USEC_PER_TICK) /* Exact */ diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index d03611610..d7610cd49 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -38,6 +38,7 @@ ****************************************************************************/ #include +#include #include #include @@ -244,8 +245,8 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, */ #ifdef CONFIG_HAVE_LONG_LONG - uint64_t waitticks64 = (timeout->tv_sec * NSEC_PER_SEC + - timeout->tv_nsec + NSEC_PER_TICK - 1) / + uint64_t waitticks64 = ((uint64_t)timeout->tv_sec * NSEC_PER_SEC + + (uint64_t)timeout->tv_nsec + NSEC_PER_TICK - 1) / NSEC_PER_TICK; DEBUGASSERT(waitticks64 <= UINT32_MAX); waitticks = (uint32_t)waitticks64; -- cgit v1.2.3 From 6953365d30f06846a8f3877b73e01ee7d8321db0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 24 Dec 2012 20:22:14 +0000 Subject: Fix several build issues noted by Mike Smith git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5459 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 10 ++++- apps/builtin/Makefile | 5 ++- apps/examples/nettest/Makefile | 57 +++++++++++++++-------------- nuttx/ChangeLog | 3 ++ nuttx/arch/arm/src/arm/up_head.S | 51 +++++++++++++++++++------- nuttx/configs/ntosd-dm320/nettest/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/nsh/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/ostest/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/poll/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/thttpd/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/udp/setenv.sh | 26 ++++++++++--- nuttx/configs/ntosd-dm320/uip/setenv.sh | 26 ++++++++++--- 12 files changed, 228 insertions(+), 80 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 09a4f634d..ea1b247f5 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -439,12 +439,18 @@ * Makefiles: Removed dependency of distclean on clean in most top-level files. It makes sense for 'leaf' Makefiles to have this dependency, but it does not make sense for upper-level Makefiles. - * namedapp/: Renamed to builtins in preparation for another change. + * apps/namedapp/: Renamed to builtins in preparation for another change. * .context: Removed the .context kludge. This caused lots of problems when changing configurations because there is no easy way to get the system to rebuild the context. Now, the context will be rebuilt whenever there is a change in either .config or the Makefile. - * builtin/registry: Updated new built-in registration logic to handle + * apps/builtin/registry: Updated new built-in registration logic to handle cases where (1) old apps/.config is used, and (2) applications ared removed, not just added. + * apps/examples/nettest/Makefile: Fix an error that crept in during + some of the recent, massive build system changes. + * apps/builtin/Makefile: Need to have auto-generated header files + in place early in the dependency generation phase to avoid warnings. + It is not important if they are only stubbed out header files at + this build phase. diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index 0efb832f8..ccb860c88 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -75,6 +75,9 @@ $(AOBJS): %$(OBJEXT): %.S $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) +registry/.updated: + $(V) $(MAKE) -C registry .updated TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + builtin_list.h: registry/.updated $(call DELFILE, builtin_list.h) $(Q) touch builtin_list.h @@ -110,7 +113,7 @@ endif context: $(Q) $(MAKE) -C registry context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -.depend: Makefile $(SRCS) +.depend: Makefile $(SRCS) builtin_list.h builtin_proto.h $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep $(Q) touch $@ diff --git a/apps/examples/nettest/Makefile b/apps/examples/nettest/Makefile index a0308713c..5368bdefc 100644 --- a/apps/examples/nettest/Makefile +++ b/apps/examples/nettest/Makefile @@ -39,64 +39,64 @@ include $(APPDIR)/Make.defs # Basic TCP networking test -TARG_ASRCS = -TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT)) +TARG_ASRCS = +TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT)) -TARG_CSRCS = nettest.c +TARG_CSRCS = nettest.c ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) -TARG_CSRCS += nettest_server.c +TARG_CSRCS += nettest_server.c else -TARG_CSRCS += nettest_client.c +TARG_CSRCS += nettest_client.c endif -TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT)) +TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT)) -TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) -TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS) +TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) +TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS) ifeq ($(CONFIG_WINDOWS_NATIVE),y) - TARG_BIN = ..\..\libapps$(LIBEXT) + TARG_BIN = ..\..\libapps$(LIBEXT) else ifeq ($(WINTOOL),y) - TARG_BIN = ..\\..\\libapps$(LIBEXT) + TARG_BIN = ..\\..\\libapps$(LIBEXT) else - TARG_BIN = ../../libapps$(LIBEXT) + TARG_BIN = ../../libapps$(LIBEXT) endif endif -HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_HOST=1 +HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_HOST=1 ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) -HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 \ - -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)" +HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)" endif ifeq ($(CONFIG_EXAMPLES_NETTEST_PERFORMANCE),y) -HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1 +HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1 endif -HOST_SRCS = host.c +HOST_SRCS = host.c ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) -HOST_SRCS += nettest_client.c +HOST_SRCS += nettest_client.c else -HOST_SRCS += nettest_server.c +HOST_SRCS += nettest_server.c endif -HOST_OBJS = $(HOST_SRCS:.c=.o) -HOST_BIN = host +HOSTOBJEXT ?= .hobj +HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT)) +HOST_BIN = host -ROOTDEPPATH = --dep-path . +ROOTDEPPATH = --dep-path . # NET test built-in application info -APPNAME = nettest -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 2048 +APPNAME = nettest +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 # Common build -VPATH = +VPATH = all: .built $(HOST_BIN) -.PHONY: clean depend distclean +.PHONY: clean depend distclean $(TARG_AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -104,7 +104,7 @@ $(TARG_AOBJS): %$(OBJEXT): %.S $(TARG_COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) -$(HOST_OBJS): %.o: %.c +$(HOST_OBJS): %$(HOSTOBJEXT): %.c @echo "CC: $<" @$(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ @@ -113,7 +113,7 @@ $(HOST_BIN): $(HOST_OBJS) @$(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@ .built: $(TARG_OBJS) - $(call ARCHIVE, $(BIN), $(TARG_OBJS)) + $(call ARCHIVE, $(TARG_BIN), $(TARG_OBJS)) @touch .built ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) @@ -132,6 +132,7 @@ endif depend: .depend clean: + $(call DELFILE, *$(HOSTOBJEXT)) $(call DELFILE, $(HOST_BIN)) $(call DELFILE, .built) $(call CLEAN) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 6c6fd7843..c5cc9b54a 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3815,4 +3815,7 @@ * sched/sig_timedwait.c: Should always move the time up to the next largest number of system ticks. The logic was rounding. Noted by Petteri Aimonen. + * arch/arm/src/up_head.S: Fix backward conditional compilation. NOTE + there is a issue of ARM9 systems with low vectors and large memories + that will have to be addressed in the future. diff --git a/nuttx/arch/arm/src/arm/up_head.S b/nuttx/arch/arm/src/arm/up_head.S index 91d67fd15..46efd8772 100644 --- a/nuttx/arch/arm/src/arm/up_head.S +++ b/nuttx/arch/arm/src/arm/up_head.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/arm/up_head.S + * arch/arm/src/arm/up_pghead.S * * Copyright (C) 2007, 2009-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -78,6 +78,10 @@ * beginning of FLASH. */ +# if !defined(CONFIG_FLASH_START) || !defined(CONFIG_FLASH_VSTART) +# error "CONFIG_FLASH_START or CONFIG_FLASH_VSTART is not defined" +# endif + # if CONFIG_FLASH_START == CONFIG_FLASH_VSTART # define CONFIG_IDENTITY_TEXTMAP 1 # endif @@ -102,6 +106,10 @@ * beginning of FLASH. */ +# if !defined(CONFIG_FLASH_START) || !defined(CONFIG_FLASH_VSTART) +# error "CONFIG_FLASH_START or CONFIG_FLASH_VSTART is not defined" +# endif + # if CONFIG_FLASH_START == CONFIG_FLASH_VSTART # define CONFIG_IDENTITY_TEXTMAP 1 # endif @@ -120,6 +128,10 @@ * beginning of RAM. */ +# if !defined(CONFIG_DRAM_START) || !defined(CONFIG_DRAM_VSTART) +# error "CONFIG_DRAM_START or CONFIG_DRAM_VSTART is not defined" +# endif + # if CONFIG_DRAM_START == CONFIG_DRAM_VSTART # define CONFIG_IDENTITY_TEXTMAP 1 # endif @@ -162,26 +174,37 @@ * Assembly Macros ****************************************************************************/ -/* The ARM9 L1 page table can be placed at the beginning or at the end of the - * RAM space. This decision is based on the placement of the vector area: - * If the vectors are place in low memory at address 0x0000 0000, then the - * page table is placed in high memory; if the vectors are placed in high - * memory at address 0xfff0 0000, then the page table is locating at the - * beginning of RAM. +/* The ARM9 L1 page table can be placed at the beginning or at the end of + * the RAM space. This decision is based on the placement of the vector + * area: If the vectors are place in low memory at address 0x0000 0000, then + * the page table is placed in high memory; if the vectors are placed in + * high memory at address 0xfff0 0000, then the page table is locating at + * the beginning of RAM. * - * For the special case where (1) the program executes out of RAM, and (2) the - * page is located at the beginning of RAM, then the following macro can - * easily find the physical address of the section that includes the first - * part of the text region: Since the page table is closely related to the - * NuttX base address in this case, we can convert the page table base address - * to the base address of the section containing both. + * For the special case where (1) the program executes out of RAM, and (2) + * the page is located at the beginning of RAM (i.e., the high vector case), + * then the following macro can easily find the physical address of the + * section that includes the first part of the text region: Since the page + * table is closely related to the NuttX base address in this case, we can + * convert the page table base address to the base address of the section + * containing both. + */ + +/* REVISIT: This works now of the low vector case only because the RAM + * sizes that we have been dealing with are less then 1MB so that both the + * page table and the vector table are in the same 1MB RAM block. But + * this will certainly break later. Hence, the annoying warning. */ #ifdef CONFIG_ARCH_LOWVECTORS +# warning "REVISIT" +#endif + +//#ifndef CONFIG_ARCH_LOWVECTORS .macro mksection, section, pgtable bic \section, \pgtable, #0x000ff000 .endm -#endif +//#endif /* This macro will modify r0, r1, r2 and r14 */ diff --git a/nuttx/configs/ntosd-dm320/nettest/setenv.sh b/nuttx/configs/ntosd-dm320/nettest/setenv.sh index 6090d4cea..cfb438ce7 100755 --- a/nuttx/configs/ntosd-dm320/nettest/setenv.sh +++ b/nuttx/configs/ntosd-dm320/nettest/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/nsh/setenv.sh b/nuttx/configs/ntosd-dm320/nsh/setenv.sh index a84e68884..005aa8153 100755 --- a/nuttx/configs/ntosd-dm320/nsh/setenv.sh +++ b/nuttx/configs/ntosd-dm320/nsh/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/ostest/setenv.sh b/nuttx/configs/ntosd-dm320/ostest/setenv.sh index a65be2677..75d6f0cd0 100755 --- a/nuttx/configs/ntosd-dm320/ostest/setenv.sh +++ b/nuttx/configs/ntosd-dm320/ostest/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/poll/setenv.sh b/nuttx/configs/ntosd-dm320/poll/setenv.sh index de3b64ea9..427ffe26a 100755 --- a/nuttx/configs/ntosd-dm320/poll/setenv.sh +++ b/nuttx/configs/ntosd-dm320/poll/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/thttpd/setenv.sh b/nuttx/configs/ntosd-dm320/thttpd/setenv.sh index 92ff91700..ea38c09a5 100755 --- a/nuttx/configs/ntosd-dm320/thttpd/setenv.sh +++ b/nuttx/configs/ntosd-dm320/thttpd/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/udp/setenv.sh b/nuttx/configs/ntosd-dm320/udp/setenv.sh index 052413b08..92995bee5 100755 --- a/nuttx/configs/ntosd-dm320/udp/setenv.sh +++ b/nuttx/configs/ntosd-dm320/udp/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/ntosd-dm320/uip/setenv.sh b/nuttx/configs/ntosd-dm320/uip/setenv.sh index 988e0a126..33c252e1e 100755 --- a/nuttx/configs/ntosd-dm320/uip/setenv.sh +++ b/nuttx/configs/ntosd-dm320/uip/setenv.sh @@ -32,15 +32,31 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi - WD=`pwd` -export BUILDROOT_BIN=${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin -export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/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}" echo "PATH : ${PATH}" -- cgit v1.2.3 From 292d4db37a4080585577c43434157db335cd5158 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 25 Dec 2012 17:22:58 +0000 Subject: Add logic to serialize and marshal out-of-band keyboard commands git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5460 42af7a65-404d-4744-a932-0658087f49c3 --- apps/Make.defs | 4 +- apps/builtin/Makefile | 6 +- nuttx/ChangeLog | 4 +- nuttx/include/nuttx/input/kbd_codec.h | 292 ++++++++++++++++++++++++++++++++++ nuttx/include/nuttx/usb/hid.h | 2 +- nuttx/libc/misc/Make.defs | 2 +- nuttx/libc/misc/lib_kbddecode.c | 258 ++++++++++++++++++++++++++++++ nuttx/libc/misc/lib_kbdencode.c | 81 ++++++++++ 8 files changed, 641 insertions(+), 8 deletions(-) create mode 100644 nuttx/include/nuttx/input/kbd_codec.h create mode 100644 nuttx/libc/misc/lib_kbddecode.c create mode 100644 nuttx/libc/misc/lib_kbdencode.c (limited to 'apps') diff --git a/apps/Make.defs b/apps/Make.defs index c62999804..f7e6aa08d 100644 --- a/apps/Make.defs +++ b/apps/Make.defs @@ -37,9 +37,9 @@ BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry ifeq ($(CONFIG_NUTTX_NEWCONFIG),y) -DEPCONFIG = $(TOPDIR)/.config +DEPCONFIG = $(TOPDIR)$(DELIM).config else -DEPCONFIG = $(TOPDIR)/.config $(APPDIR)/.config +DEPCONFIG = $(TOPDIR)$(DELIM).config $(APPDIR)$(DELIM).config endif define REGISTER diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index ccb860c88..8c8928886 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -75,10 +75,10 @@ $(AOBJS): %$(OBJEXT): %.S $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) -registry/.updated: +registry$(DELIM).updated: $(V) $(MAKE) -C registry .updated TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -builtin_list.h: registry/.updated +builtin_list.h: registry$(DELIM).updated $(call DELFILE, builtin_list.h) $(Q) touch builtin_list.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -92,7 +92,7 @@ else ) endif -builtin_proto.h: registry/.updated +builtin_proto.h: registry$(DELIM).updated $(call DELFILE, builtin_proto.h) $(Q) touch builtin_proto.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index c5cc9b54a..80ddb56c6 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3818,4 +3818,6 @@ * arch/arm/src/up_head.S: Fix backward conditional compilation. NOTE there is a issue of ARM9 systems with low vectors and large memories that will have to be addressed in the future. - + * libc/misc/lib_kbdencode.c and lib_kbddecode.c: Add logic to marshal + and serialized "out-of-band" keyboard commands intermixed with normal + ASCII data (not yet hooked into anything). diff --git a/nuttx/include/nuttx/input/kbd_codec.h b/nuttx/include/nuttx/input/kbd_codec.h new file mode 100644 index 000000000..b103d544e --- /dev/null +++ b/nuttx/include/nuttx/input/kbd_codec.h @@ -0,0 +1,292 @@ +/************************************************************************************ + * include/nuttx/input/kbd_codec.h + * Serialize and marshaling out-of-band keyboard data + * + * Copyright (C) 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. + * + ************************************************************************************/ + +#ifndef __INCLUDE_NUTTX_INPUT_KBD_CODEC_H +#define __INCLUDE_NUTTX_INPUT_KBD_CODEC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* These are the special, "out-of-band" keyboard commands recognized by the + * CODEC. + */ + +enum kbd_keycode_e +{ + KEYCODE_NORMAL = 0, /* Not a special keycode */ + + /* Delete and Backspace keycodes (in case they may be different than the + * ASCII BKSP and DEL values. + */ + + KEYCODE_FWDDEL, /* DELete (forward delete) */ + KEYCODE_BACKDEL, /* Backspace (backward delete) */ + + /* Cursor movement */ + + KEYCODE_HOME, /* Home */ + KEYCODE_END, /* End */ + KEYCODE_LEFT, /* Left arrow */ + KEYCODE_RIGHT, /* Right arrow */ + KEYCODE_UP, /* Up arrow */ + KEYCODE_DOWN, /* Down arrow */ + KEYCODE_PAGEUP, /* Page up */ + KEYCODE_PAGEDOWN, /* Page down */ + + /* Edit commands */ + + KEYCODE_INSERT, /* Insert */ + KEYCODE_AGAIN, /* Again */ + KEYCODE_UNDO, /* Undo */ + KEYCODE_REDO, /* Redo */ + KEYCODE_CUT, /* Cut */ + KEYCODE_COPY, /* Copy */ + KEYCODE_PASTE, /* Paste */ + KEYCODE_FIND , /* Find */ + + /* Selection codes */ + + KEYCODE_ENTER, /* Enter */ + KEYCODE_SELECT, /* Select */ + KEYCODE_EXECUTE, /* Execute */ + + /* Keyboard modes */ + + KEYCODE_CAPSLOCK, /* Caps Lock */ + KEYCODE_SCROLLLOCK, /* Scroll Lock */ + KEYCODE_NUMLOCK, /* Keypad Num Lock and Clear */ + KEYCODE_LCAPSLOCK, /* Locking Caps Lock */ + KEYCODE_LNUMLOCK, /* Locking Num Lock */ + KEYCODE_LSCROLLLOCK, /* Locking Scroll Lock */ + + /* Misc control codes */ + + KEYCODE_POWER, /* Power */ + KEYCODE_HELP, /* Help */ + KEYCODE_MENU, /* Menu */ + KEYCODE_STOP, /* Stop */ + KEYCODE_PAUSE, /* Pause */ + KEYCODE_BREAK, /* Break */ + KEYCODE_CANCEL, /* Cancel */ + KEYCODE_PRINTSCN, /* PrintScreen */ + KEYCODE_SYSREQ, /* SysReq/Attention */ + + /* Audio */ + + KEYCODE_MUTE, /* Mute */ + KEYCODE_VOLUP, /* Volume Up */ + KEYCODE_VOLDOWN, /* Volume Down */ + + /* Telephone */ + + KEYCODE_ANSWER, /* Answer (phone) */ + KEYCODE_HANGUP, /* Hang-up (phone) */ + + /* Calculator */ + + KEYCODE_CLEAR, /* Clear */ + KEYCODE_CLEARENTRY, /* Clear entry */ + + KEYCODE_MEMSET, /* Memory set */ + KEYCODE_MEMCLEAR, /* Memory clear */ + KEYCODE_MEMRECALL, /* Memory recall */ + KEYCODE_MEMADD, /* Memory add */ + KEYCODE_MEMSUBTRACT, /* Memory substract */ + KEYCODE_MEMMULTIPY, /* Memory multiply */ + KEYCODE_MEMDIVIDE, /* Memory divide */ + + KEYCODE_BINARY, /* Binary mode */ + KEYCODE_OCTAL, /* Octal mode */ + KEYCODE_DECIMAL, /* Decimal mode */ + KEYCODE_HEXADECIMAL, /* Hexadecimal mode */ + + /* Languages */ + + KEYCODE_LANG1, /* LANG1 */ + KEYCODE_LANG2, /* LANG2 */ + KEYCODE_LANG3, /* LANG3 */ + KEYCODE_LANG4, /* LANG4 */ + KEYCODE_LANG5, /* LANG5 */ + KEYCODE_LANG6, /* LANG6 */ + KEYCODE_LANG7, /* LANG7 */ + KEYCODE_LANG8, /* LANG8 */ + + /* Context-specific function keys */ + + KEYCODE_F1, /* Function key 1 */ + KEYCODE_F2, /* Function key 2 */ + KEYCODE_F3, /* Function key 3 */ + KEYCODE_F4, /* Function key 4 */ + KEYCODE_F5, /* Function key 5 */ + KEYCODE_F6, /* Function key 6 */ + KEYCODE_F7, /* Function key 7 */ + KEYCODE_F8, /* Function key 8 */ + KEYCODE_F9, /* Function key 9 */ + KEYCODE_F10, /* Function key 10 */ + KEYCODE_F11, /* Function key 11 */ + KEYCODE_F12, /* Function key 12 */ + KEYCODE_F13, /* Function key 13 */ + KEYCODE_F14, /* Function key 14 */ + KEYCODE_F15, /* Function key 15 */ + KEYCODE_F16, /* Function key 16 */ + KEYCODE_F17, /* Function key 17 */ + KEYCODE_F18, /* Function key 18 */ + KEYCODE_F19, /* Function key 19 */ + KEYCODE_F20, /* Function key 20 */ + KEYCODE_F21, /* Function key 21 */ + KEYCODE_F22, /* Function key 22 */ + KEYCODE_F23, /* Function key 23 */ + KEYCODE_F24 /* Function key 24 */ +}; + +#define FIRST_KEYCODE KEYCODE_FWDDEL +#define LAST_KEYCODE KEYCODE_F24 + +/* kbd_get return values */ + +#define KBD_NORMAL 0 +#define KBD_SPECIAL 1 +#define KBD_ERROR EOF + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct kget_getstate_s +{ + uint8_t nch; /* Number of characters in the buffer */ + uint8_t ndx; /* Index to next character in the buffer */ + uint8_t buf[4]; /* Buffer of ungotten data */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/**************************************************************************** + * The following functions are intended for use by "producer", keyboard + * or keypad drivers to encode information into driver buffers. + ****************************************************************************/ + +/**************************************************************************** + * Name: kbd_puttext + * + * Description: + * Put one byte of normal, "in-band" ASCII data into the output stream. + * + * Input Parameters: + * ch - The character to be into the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#define kbd_puttext(ch, stream) (stream)->put((stream), (int)(ch)) + +/**************************************************************************** + * Name: kbd_putspecial + * + * Description: + * Put one special, "out-of-band" command into the output stream. + * + * Input Parameters: + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_putspecial(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream); + +/**************************************************************************** + * The following functions are intended for use by "consumer" applications + * to remove and decode information from the driver provided buffer. + ****************************************************************************/ + +/**************************************************************************** + * Name: kbd_get + * + * Description: + * Put one byte of data or special command from the driver provided input + * buffer. + * + * Input Parameters: + * stream - An instance of lib_instream_s to do the low-level get + * operation. + * pch - The location character to save the returned value. This may be + * either a normal, "in-band" ASCII characer or a special, "out-of-band" + * command. + * state - A user provided buffer to support parsing. This structure + * should be cleared the first time that kbd_get is called. + * + * Returned Value: + * 1 - Indicates the successful receipt of a special, "out-of-band" command + * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. + * EOF - An error has getting the next character (reported by the stream). + * Normally indicates the end of file. + * + ****************************************************************************/ + +int kbd_get(FAR struct lib_instream_s *stream, + FAR struct kget_getstate_s *state, FAR uint8_t *pch); + +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_INPUT_KBD_CODEC_H */ + diff --git a/nuttx/include/nuttx/usb/hid.h b/nuttx/include/nuttx/usb/hid.h index 5b83f08fc..877203a9c 100644 --- a/nuttx/include/nuttx/usb/hid.h +++ b/nuttx/include/nuttx/usb/hid.h @@ -619,7 +619,7 @@ #define USBHID_KBDUSE_RCTRL 0xe4 /* Keyboard RightControl */ #define USBHID_KBDUSE_RSHIFT 0xe5 /* Keyboard RightShift */ #define USBHID_KBDUSE_RALT 0xe6 /* Keyboard RightAlt */ -#define USBHID_KBDUSE_RGUI 0xe7 /* Keyboard Right GUI*/ +#define USBHID_KBDUSE_RGUI 0xe7 /* Keyboard Right GUI */ #define USBHID_KBDUSE_MAX 0xe7 diff --git a/nuttx/libc/misc/Make.defs b/nuttx/libc/misc/Make.defs index f4284ac60..c6af5f860 100644 --- a/nuttx/libc/misc/Make.defs +++ b/nuttx/libc/misc/Make.defs @@ -35,7 +35,7 @@ # Add the internal C files to the build -CSRCS += lib_init.c lib_filesem.c +CSRCS += lib_init.c lib_filesem.c lib_kbdencode.c lib_kbddecode.c # Add C files that depend on file OR socket descriptors diff --git a/nuttx/libc/misc/lib_kbddecode.c b/nuttx/libc/misc/lib_kbddecode.c new file mode 100644 index 000000000..046d570f9 --- /dev/null +++ b/nuttx/libc/misc/lib_kbddecode.c @@ -0,0 +1,258 @@ +/******************************************************************************************** + * libc/msic/lib_kbddecode.c + * Decoding side of the Keyboard CODEC + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Authors: 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 + +/******************************************************************************************** + * Pre-Processor Definitions + ********************************************************************************************/ + +#define NDX_ESC 0 +#define NDX_BRACKET 1 +#define NDX_CODE 2 +#define NCX_SEMICOLON 3 + +#define NCH_ESC 1 +#define NCH_BRACKET 2 +#define NCH_CODE 3 +#define NCH_SEMICOLON 4 + +/******************************************************************************************** + * Private Functions + ********************************************************************************************/ + +/**************************************************************************** + * Name: kbd_reget + * + * Description: + * We have unused characters from the last, unsuccessful. Return one of + * these instead of the . + * + * Input Parameters: + * stream - An instance of lib_instream_s to do the low-level get + * operation. + * pch - The location character to save the returned value. This may be + * either a normal, "in-band" ASCII characer or a special, "out-of-band" + * command. + * state - A user provided buffer to support parsing. This structure + * should be cleared the first time that kbd_get is called. + * + * Returned Value: + * 2 - Indicates the successful receipt of a special, "out-of-band" command + * 1 - Indicates the successful receipt of normal, "in-band" ASCII data. + * 0 - Indicates end-of-file or that the stream has been closed + * EOF - An error has getting the next character (reported by the stream). + * + ****************************************************************************/ + +static int kbd_reget(FAR struct kget_getstate_s *state, FAR uint8_t *pch) +{ + /* Return the next character */ + + *pch = state->buf[state->ndx]; + state->ndx++; + state->nch--; + return KBD_NORMAL; +} + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +/**************************************************************************** + * Name: kbd_get + * + * Description: + * Put one byte of data or special command from the driver provided input + * buffer. + * + * Input Parameters: + * stream - An instance of lib_instream_s to do the low-level get + * operation. + * pch - The location character to save the returned value. This may be + * either a normal, "in-band" ASCII characer or a special, "out-of-band" + * command. + * state - A user provided buffer to support parsing. This structure + * should be cleared the first time that kbd_get is called. + * + * Returned Value: + * 1 - Indicates the successful receipt of a special, "out-of-band" command + * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. + * EOF - An error has getting the next character (reported by the stream). + * Normally indicates the end of file. + * + ****************************************************************************/ + +int kbd_get(FAR struct lib_instream_s *stream, + FAR struct kget_getstate_s *state, FAR uint8_t *pch) +{ + int ch; + + DEBUGASSERT(stream && state && pch); + + /* Are their ungotten characters from the last, failed parse? */ + + if (state->nch > 0) + { + /* Yes, return the next ungotten character */ + + return kbd_reget(state, pch); + } + + state->ndx = 0; + + /* No, ungotten characters. Check for the beginning of an esc sequence. */ + + ch = stream->get(stream); + if (ch == EOF) + { + /* End of file/stream */ + + return KBD_ERROR; + } + else + { + state->buf[NDX_ESC] = (uint8_t)ch; + state->nch = NCH_ESC; + + if (ch != ASCII_ESC) + { + /* Not the beginning of an escape sequence. Return the character. */ + + return kbd_reget(state, pch); + } + } + + /* Check for ESC-[ */ + + ch = stream->get(stream); + if (ch == EOF) + { + /* End of file/stream. Return the escape character now. We will + * return the EOF indication next time. + */ + + return kbd_reget(state, pch); + } + else + { + state->buf[NDX_BRACKET] = ch; + state->nch = NCH_BRACKET; + + if (ch != '[') + { + /* Not the beginning of an escape sequence. Return the ESC now, + * return the following character later. + */ + + return kbd_reget(state, pch); + } + } + + /* Get and verify the special, "out-of-band" command code */ + + ch = stream->get(stream); + if (ch == EOF) + { + /* End of file/stream. Unget everything and return the ESC character. + */ + + return kbd_reget(state, pch); + } + else + { + state->buf[NDX_CODE] = (uint8_t)ch; + state->nch = NCH_CODE; + + /* Check for a valid special command code */ + + if (ch < FIRST_KEYCODE || ch > LAST_KEYCODE) + { + /* Not a special command code, return the ESC now and the next two + * characters later. + */ + + return kbd_reget(state, pch); + } + } + + /* Check for the final semicolon */ + + ch = stream->get(stream); + if (ch == EOF) + { + /* End of file/stream. Unget everything and return the ESC character. + */ + + return kbd_reget(state, pch); + } + else + { + state->buf[NCX_SEMICOLON] = (uint8_t)ch; + state->nch = NCH_SEMICOLON; + + /* Check for a valid special command code */ + + if (ch != ';') + { + /* Not a special command code, return the ESC now and the next two + * characters later. + */ + + return kbd_reget(state, pch); + } + } + + /* We have successfully parsed the the entire escape sequence. Return the + * special code in pch and the value 2. + */ + + *pch = state->buf[NDX_CODE]; + state->nch = 0; + return KBD_SPECIAL; +} + diff --git a/nuttx/libc/misc/lib_kbdencode.c b/nuttx/libc/misc/lib_kbdencode.c new file mode 100644 index 000000000..80bf14777 --- /dev/null +++ b/nuttx/libc/misc/lib_kbdencode.c @@ -0,0 +1,81 @@ +/******************************************************************************************** + * libc/msic/lib_kbdencode.c + * Encoding side of the Keyboard CODEC + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Authors: 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 + +/******************************************************************************************** + * Pre-Processor Definitions + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +/**************************************************************************** + * Name: kbd_putspecial + * + * Description: + * Put one special, "out-of-band" command into the output stream. + * + * Input Parameters: + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_putspecial(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream) +{ + DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE); + + stream->put(stream, ASCII_ESC); + stream->put(stream, '['); + stream->put(stream, (int)keycode); + stream->put(stream, ';'); +} + -- cgit v1.2.3 From 373e145e546cc34b6a0000d7b3f71538c05a3b1b Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 26 Dec 2012 18:54:59 +0000 Subject: Implement encoding the usbhost HID keyboard driver; configre olimex-lpc1766stk HID keyboard configuration to use the kconfig-frontends tool git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5461 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/hidkbd/hidkbd_main.c | 4 +- nuttx/ChangeLog | 6 + nuttx/Documentation/NuttxPortingGuide.html | 148 +++- nuttx/configs/olimex-lpc1766stk/README.txt | 20 +- nuttx/configs/olimex-lpc1766stk/hidkbd/appconfig | 39 - nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig | 914 +++++++++++++---------- nuttx/configs/olimex-lpc1766stk/hidkbd/setenv.sh | 4 +- nuttx/drivers/usbhost/Kconfig | 64 +- nuttx/drivers/usbhost/usbhost_hidkbd.c | 375 ++++++++-- nuttx/include/nuttx/input/kbd_codec.h | 26 +- nuttx/libc/misc/lib_kbddecode.c | 10 +- nuttx/libc/misc/lib_kbdencode.c | 3 + 12 files changed, 1080 insertions(+), 533 deletions(-) delete mode 100644 nuttx/configs/olimex-lpc1766stk/hidkbd/appconfig (limited to 'apps') diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index e744a495c..bc1eebed0 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -206,7 +206,7 @@ int hidkbd_main(int argc, char *argv[]) printf("Device %s opened\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME); fflush(stdout); - /* Loop until there is a read failure */ + /* Loop until there is a read failure (or EOF?) */ do { @@ -220,7 +220,7 @@ int hidkbd_main(int argc, char *argv[]) (void)write(1, buffer, nbytes); } } - while (nbytes >= 0); + while (nbytes > 0); printf("Closing device %s: %d\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME, (int)nbytes); fflush(stdout); diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 80ddb56c6..7e1c538d7 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3821,3 +3821,9 @@ * libc/misc/lib_kbdencode.c and lib_kbddecode.c: Add logic to marshal and serialized "out-of-band" keyboard commands intermixed with normal ASCII data (not yet hooked into anything). + * drivers/usbhost/usbhost_hidkbd.c: If CONFIG_HIDKBD_ENCODED is + defined, this driver will now use libc/misc/lib_kbdencode.c to + encode special function keys. + * configs/olimex-lpc1766stk/hidkbd: This configuration has been + converted to use the kconfig-frontends configuration tool. + diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 0408f82ac..ebb3eff4b 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -131,7 +131,8 @@ 6.3.12 PWM Drivers
    6.3.13 CAN Drivers
    6.3.14 Quadrature Encoder Drivers
    - 6.3.15 Watchdog Timer Drivers + 6.3.15 Watchdog Timer Drivers
    + 6.3.16 Keyboard/Keypad Drivers
    6.4 Power Management
      @@ -3620,6 +3621,151 @@ extern void up_ledoff(int led);
    +

    6.3.16 Keyboard/Keypad Drivers

    +

    + "Out-of-Band" Commands. + Keyboards and keypads are the same device for NuttX. + A keypad is thought of as simply a keyboard with fewer keys. + In NuttX, a keyboard/keypad driver is simply a character driver that may have an (optional) encoding/decoding layer on the data returned by the character driver. + A keyboard may return simple text data (alphabetic, numeric, and punctuaction) or control characters (enter, control-C, etc.). + We can think about this the normal "in-band" keyboard data stream. + However, in addition, most keyboards support actions that cannot be represented as text data. + Such actions include things like cursor controls (home, up arrow, page down, etc.), editing functions (insert, delete, etc.), volume controls, (mute, volume up, etc.) and other special functions. + We can think about this as special, "out-of-band" keyboard commands. + In this case, some special encoding may be required to multiplex the in-band text data and out-of-band command streams. +

    +

    + Encoding/Decoding Layer. + An optional encoding/decoding layer can be used with the basic character driver to encode the out-of-band commands into the text data stream. + The function interfaces that comprise that encoding/decoding layer are defined in the header file include/nuttx/input/kbd_code.h. + These functions provide an matched set of (a) driver encoding interfaces, and (b) application decoding interfaces. +

    +
      +
    1. +

      + Driver Encoding Interfaces. +

      +
        +
      • +

        + kbd_puttext() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Put one byte of normal, "in-band" ASCII data into the output stream. +
        +

        Input Pameters:

        +
          +
        • + ch: The character to be added to the output stream. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_putspecial() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Put one special, "out-of-band" command into the output stream. +
        +

        Input Pameters:

        +
          +
        • + keycode: The command to be added to the output stream. + The enumeration enum kbd_keycode_e keycode identifies all commands known to the system. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      +
    2. +
    3. +

      + Application Decoding Interfaces. +

      +
        +
      • +

        + kbd_get() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
          +
        +

        Description:

        +
          + Get one byte of data or special command from the driver provided input buffer. +
        +

        Input Pameters:

        +
          +
        • + stream: An instance of lib_instream_s to perform the actual low-level get operation. +
        • +
        • + pch: The location character to save the returned value. + This may be either a normal, "in-band" ASCII characer or a special, "out-of-band" command (i.e., a value from enum kbd_getstate_s. +
        • +
        • + state: A user provided buffer to support parsing. + This structure should be cleared the first time that kbd_get is called. +
        • +
        +

        Returned Value:

        +
          +
        • + 1: + Indicates the successful receipt of a special, "out-of-band" command. + The returned value in pch is a value from enum kbd_getstate_s. +
        • +
        • + 0: + Indicates the successful receipt of normal, "in-band" ASCII data. + The returned value in pch is a simple byte of text or control data. +
        • +
        • + EOF: + An error has getting the next character (reported by the stream). + Normally indicates the end of file. +
        • +
        +
      • +
      +
    4. +
    +

    + I/O Streams. + Notice the use of the abstract I/O streams in these interfaces. + These stream interfaces are defined in include/nuttx/streams.h. +

    +

    6.4 Power Management

    6.4.1 Overview

    diff --git a/nuttx/configs/olimex-lpc1766stk/README.txt b/nuttx/configs/olimex-lpc1766stk/README.txt index ec7ddd42d..e2c940bac 100644 --- a/nuttx/configs/olimex-lpc1766stk/README.txt +++ b/nuttx/configs/olimex-lpc1766stk/README.txt @@ -899,7 +899,25 @@ Where is one of the following: This configuration directory, performs a simple test of the USB host HID keyboard class driver using the test logic in apps/examples/hidkbd. - nettest: + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the mconf tool. See nuttx/README.txt and + misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Default platform/toolchain: This is how the build is configured by + be default. These options can easily be re-confured, however. + + CONFIG_HOST_WINDOWS=y : Windows + CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows + CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + + nettest: This configuration directory may be used to enable networking using the LPC17xx's Ethernet controller. It uses apps/examples/nettest to excercise the TCP/IP network. diff --git a/nuttx/configs/olimex-lpc1766stk/hidkbd/appconfig b/nuttx/configs/olimex-lpc1766stk/hidkbd/appconfig deleted file mode 100644 index 79a7c50ab..000000000 --- a/nuttx/configs/olimex-lpc1766stk/hidkbd/appconfig +++ /dev/null @@ -1,39 +0,0 @@ -############################################################################ -# configs/olimex-lpc1766stk/hidkbd/appconfig -# -# Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# Path to example in apps/examples containing the user_start entry point - -CONFIGURED_APPS += examples/hidkbd - diff --git a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig index 9a4c37fb4..78e411560 100755 --- a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig @@ -1,506 +1,604 @@ -############################################################################ -# configs/olimex-lpc1766stk/hidkbd/defconfig -# -# 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. -# -############################################################################ -# -# Architecture Selection # -CONFIG_ARCH="arm" +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_HOST_LINUX is not set +# CONFIG_HOST_OSX 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 +# +# CONFIG_APPS_DIR="../apps" +# 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 is not set + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_SYMBOLS is not set + +# +# System Type +# +# CONFIG_ARCH_8051 is not set 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_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_IMX is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_LM3S is not set +CONFIG_ARCH_CHIP_LPC17XX=y +# 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_SAM3U is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STR71X is not set CONFIG_ARCH_CORTEXM3=y +CONFIG_ARCH_FAMILY="armv7-m" CONFIG_ARCH_CHIP="lpc17xx" -CONFIG_ARCH_CHIP_LPC17XX=y -CONFIG_ARCH_CHIP_LPC1766=y -CONFIG_ARCH_BOARD="olimex-lpc1766stk" -CONFIG_ARCH_BOARD_LPC1766STK=y +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARMV7M_MPU is not set CONFIG_BOARD_LOOPSPERMSEC=8111 -CONFIG_DRAM_SIZE=32768 -CONFIG_DRAM_START=0x10000000 -CONFIG_ARCH_IRQPRIO=y -CONFIG_ARCH_INTERRUPTSTACK=0 -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH_BOOTLOADER=n -CONFIG_ARCH_LEDS=y -CONFIG_ARCH_BUTTONS=n -CONFIG_ARCH_CALIBRATION=n -CONFIG_ARCH_DMA=n +# CONFIG_ARCH_CALIBRATION is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set +CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y +# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set +# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI is not set +# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set # -# Identify toolchain and linker options +# LPC17xx Configuration Options # -CONFIG_LPC17_CODESOURCERYW=n -CONFIG_LPC17_CODESOURCERYL=n -CONFIG_LPC17_DEVKITARM=n -CONFIG_LPC17_BUILDROOT=y +# CONFIG_ARCH_CHIP_LPC1751 is not set +# CONFIG_ARCH_CHIP_LPC1752 is not set +# CONFIG_ARCH_CHIP_LPC1754 is not set +# CONFIG_ARCH_CHIP_LPC1756 is not set +# CONFIG_ARCH_CHIP_LPC1758 is not set +# CONFIG_ARCH_CHIP_LPC1759 is not set +# CONFIG_ARCH_CHIP_LPC1764 is not set +# CONFIG_ARCH_CHIP_LPC1765 is not set +CONFIG_ARCH_CHIP_LPC1766=y +# CONFIG_ARCH_CHIP_LPC1767 is not set +# CONFIG_ARCH_CHIP_LPC1768 is not set +# CONFIG_ARCH_CHIP_LPC1769 is not set +CONFIG_ARCH_FAMILY_LPC176X=y # -# Individual subsystems can be enabled: +# LPC17xx Peripheral Support # -CONFIG_LPC17_ETHERNET=n +CONFIG_LPC17_MAINOSC=y +CONFIG_LPC17_PLL0=y +# CONFIG_LPC17_PLL1 is not set +# CONFIG_LPC17_ETHERNET is not set CONFIG_LPC17_USBHOST=y -CONFIG_LPC17_USBOTG=n -CONFIG_LPC17_USBDEV=n +# CONFIG_LPC17_USBDEV is not set CONFIG_LPC17_UART0=y -CONFIG_LPC17_UART1=n -CONFIG_LPC17_UART2=n -CONFIG_LPC17_UART3=n -CONFIG_LPC17_CAN1=n -CONFIG_LPC17_CAN2=n -CONFIG_LPC17_SPI=n -CONFIG_LPC17_SSP0=n -CONFIG_LPC17_SSP1=n -CONFIG_LPC17_I2C0=n -CONFIG_LPC17_I2C1=n -CONFIG_LPC17_I2S=n -CONFIG_LPC17_TMR0=n -CONFIG_LPC17_TMR1=n -CONFIG_LPC17_TMR2=n -CONFIG_LPC17_TMR3=n -CONFIG_LPC17_RIT=n -CONFIG_LPC17_PWM=n -CONFIG_LPC17_MCPWM=n -CONFIG_LPC17_QEI=n -CONFIG_LPC17_RTC=n -CONFIG_LPC17_WDT=n -CONFIG_LPC17_ADC=n -CONFIG_LPC17_DAC=n -CONFIG_LPC17_GPDMA=n - -# -# LPC17xx Button interrupt support -# -CONFIG_GPIO_IRQ=n -CONFIG_ARCH_IRQBUTTONS=n - -# -# LPC17xx specific serial device driver settings +# CONFIG_LPC17_UART1 is not set +# CONFIG_LPC17_UART2 is not set +# CONFIG_LPC17_UART3 is not set +# CONFIG_LPC17_CAN1 is not set +# CONFIG_LPC17_CAN2 is not set +# CONFIG_LPC17_SPI is not set +# CONFIG_LPC17_SSP0 is not set +# CONFIG_LPC17_SSP1 is not set +# CONFIG_LPC17_I2C0 is not set +# CONFIG_LPC17_I2C1 is not set +# CONFIG_LPC17_I2C2 is not set +# CONFIG_LPC17_I2S is not set +# CONFIG_LPC17_TMR0 is not set +# CONFIG_LPC17_TMR1 is not set +# CONFIG_LPC17_TMR2 is not set +# CONFIG_LPC17_TMR3 is not set +# CONFIG_LPC17_RIT is not set +# CONFIG_LPC17_PWM is not set +# CONFIG_LPC17_MCPWM is not set +# CONFIG_LPC17_QEI is not set +# CONFIG_LPC17_RTC is not set +# CONFIG_LPC17_WDT is not set +# CONFIG_LPC17_ADC is not set +# CONFIG_LPC17_DAC is not set +# CONFIG_LPC17_GPDMA is not set +# CONFIG_LPC17_FLASH is not set + # -CONFIG_UART0_SERIAL_CONSOLE=y -CONFIG_UART1_SERIAL_CONSOLE=n -CONFIG_UART2_SERIAL_CONSOLE=n -CONFIG_UART3_SERIAL_CONSOLE=n +# Serial driver options +# +# CONFIG_SERIAL_TERMIOS is not set +# CONFIG_UART0_FLOWCONTROL is not set -CONFIG_UART0_TXBUFSIZE=256 -CONFIG_UART1_TXBUFSIZE=256 -CONFIG_UART2_TXBUFSIZE=256 -CONFIG_UART3_TXBUFSIZE=256 +# +# ADC driver options +# -CONFIG_UART0_RXBUFSIZE=256 -CONFIG_UART1_RXBUFSIZE=256 -CONFIG_UART2_RXBUFSIZE=256 -CONFIG_UART3_RXBUFSIZE=256 +# +# CAN driver options +# +# CONFIG_GPIO_IRQ is not set -CONFIG_UART0_BAUD=57600 -CONFIG_UART2_BAUD=57600 -CONFIG_UART3_BAUD=57600 -CONFIG_UART1_BAUD=57600 +# +# I2C driver options +# -CONFIG_UART0_BITS=8 -CONFIG_UART1_BITS=8 -CONFIG_UART2_BITS=8 -CONFIG_UART3_BITS=8 +# +# Ethernet driver options +# -CONFIG_UART0_PARITY=0 -CONFIG_UART1_PARITY=0 -CONFIG_UART2_PARITY=0 -CONFIG_UART3_PARITY=0 +# +# USB device driver options +# -CONFIG_UART0_2STOP=0 -CONFIG_UART1_2STOP=0 -CONFIG_UART2_2STOP=0 -CONFIG_UART3_2STOP=0 +# +# USB host driver options +# +CONFIG_USBHOST_OHCIRAM_SIZE=1536 +CONFIG_USBHOST_NEDS=2 +CONFIG_USBHOST_NTDS=3 +CONFIG_USBHOST_TDBUFFERS=3 +CONFIG_USBHOST_TDBUFSIZE=128 +CONFIG_USBHOST_IOBUFSIZE=512 +CONFIG_USBHOST_BULK_DISABLE=y +# CONFIG_USBHOST_INT_DISABLE is not set +CONFIG_USBHOST_ISOC_DISABLE=y +# CONFIG_SDIO_DMA is not set +# CONFIG_SDIO_WIDTH_D1_ONLY is not set # -# LPC17xx specific PHY/Ethernet device driver settings +# Architecture Options # -CONFIG_PHY_KS8721=y -CONFIG_PHY_AUTONEG=y -CONFIG_PHY_SPEED100=n -CONFIG_PHY_FDUPLEX=y -CONFIG_NET_EMACRAM_SIZE=8192 -CONFIG_NET_NTXDESC=7 -CONFIG_NET_NRXDESC=7 -CONFIG_NET_REGDEBUG=n +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_IRQPRIO=y +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set # -# General build options +# Board Settings # -CONFIG_RRLOAD_BINARY=n -CONFIG_INTELHEX_BINARY=y -CONFIG_MOTOROLA_SREC=n -CONFIG_RAW_BINARY=n +CONFIG_DRAM_START=0x10000000 +CONFIG_DRAM_SIZE=32768 +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 # -# General OS setup +# Boot options # -CONFIG_USER_ENTRYPOINT="hidkbd_main" -CONFIG_DEBUG=n -CONFIG_DEBUG_VERBOSE=n -CONFIG_DEBUG_SYMBOLS=n -CONFIG_DEBUG_USB=n -CONFIG_MM_REGIONS=2 -CONFIG_ARCH_LOWPUTC=y +# 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 + +# +# Board Selection +# +CONFIG_ARCH_BOARD_LPC1766STK=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="olimex-lpc1766stk" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +# CONFIG_ARCH_BUTTONS is not set +CONFIG_ARCH_HAVE_IRQBUTTONS=y + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 CONFIG_RR_INTERVAL=200 -CONFIG_SCHED_INSTRUMENTATION=n +# CONFIG_SCHED_INSTRUMENTATION is not set CONFIG_TASK_NAME_SIZE=0 +# CONFIG_JULIAN_TIME is not set CONFIG_START_YEAR=2010 CONFIG_START_MONTH=11 CONFIG_START_DAY=10 -CONFIG_GREGORIAN_TIME=n -CONFIG_JULIAN_TIME=n CONFIG_DEV_CONSOLE=y -CONFIG_DEV_LOWCONSOLE=n -CONFIG_MUTEX_TYPES=n -CONFIG_PRIORITY_INHERITANCE=n -CONFIG_SEM_PREALLOCHOLDERS=0 -CONFIG_SEM_NNESTPRIO=0 -CONFIG_FDCLONE_DISABLE=n -CONFIG_FDCLONE_STDIO=n +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set CONFIG_SDCLONE_DISABLE=y -CONFIG_NXFLAT=n CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SIG_SIGWORK=4 +# CONFIG_SCHED_LPWORK is not set +# CONFIG_SCHED_WAITPID is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="hidkbd_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# 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_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set +# CONFIG_DISABLE_POLL is not set + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +CONFIG_MMCSD=y +CONFIG_MMCSD_NSLOTS=1 +# CONFIG_MMCSD_READONLY is not set +# CONFIG_MMCSD_MULTIBLOCK_DISABLE is not set +# CONFIG_MMCSD_MMCSUPPORT is not set +# CONFIG_MMCSD_HAVECARDDETECT is not set +CONFIG_MMCSD_SPI=y +CONFIG_MMCSD_SPICLOCK=12500000 +CONFIG_MMCSD_SDIO=y +# CONFIG_SDIO_MUXBUS is not set +# CONFIG_MTD 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_16550_UART is not set +CONFIG_ARCH_HAVE_UART0=y +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_CONFIG_SERIAL_NPOLLWAITERS=2 +CONFIG_UART0_SERIAL_CONSOLE=y +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART0 Configuration +# +CONFIG_UART0_RXBUFSIZE=256 +CONFIG_UART0_TXBUFSIZE=256 +CONFIG_UART0_BAUD=57600 +CONFIG_UART0_BITS=8 +CONFIG_UART0_PARITY=0 +CONFIG_UART0_2STOP=0 +# CONFIG_USBDEV is not set +CONFIG_USBHOST=y +CONFIG_USBHOST_NPREALLOC=0 +# CONFIG_USBHOST_MSC is not set +CONFIG_USBHOST_HIDKBD=y +CONFIG_HIDKBD_POLLUSEC=100000 +CONFIG_HIDKBD_DEFPRIO=50 +CONFIG_HIDKBD_STACKSIZE=1024 +CONFIG_HIDKBD_BUFSIZE=64 +CONFIG_HIDKBD_NPOLLWAITERS=2 +# CONFIG_HIDKBD_RAWSCANCODES is not set +# CONFIG_HIDKBD_ENCODED is not set +# CONFIG_HIDKBD_ALLSCANCODES is not set +# CONFIG_HIDKBD_NODEBOUNCE is not set +# CONFIG_WIRELESS is not set # -# The following can be used to disable categories of -# APIs supported by the OS. If the compiler supports -# weak functions, then it should not be necessary to -# disable functions unless you want to restrict usage -# of those APIs. +# System Logging Device Options # -# There are certain dependency relationships in these -# features. + # -# o mq_notify logic depends on signals to awaken tasks -# waiting for queues to become full or empty. -# o pthread_condtimedwait() depends on signals to wake -# up waiting tasks. +# System Logging # -CONFIG_DISABLE_CLOCK=n -CONFIG_DISABLE_POSIX_TIMERS=n -CONFIG_DISABLE_PTHREAD=n -CONFIG_DISABLE_SIGNALS=n -CONFIG_DISABLE_MQUEUE=n -CONFIG_DISABLE_MOUNTPOINT=n -CONFIG_DISABLE_ENVIRON=n -CONFIG_DISABLE_POLL=n +# CONFIG_RAMLOG is not set # -# Misc libc settings +# Networking Support # -CONFIG_NOPRINTF_FIELDWIDTH=n +# CONFIG_NET is not set # -# Allow for architecture optimized implementations +# File Systems # -# The architecture can provide optimized versions of the -# following to improve system performance + +# +# File system configuration # -CONFIG_ARCH_MEMCPY=n -CONFIG_ARCH_MEMCMP=n -CONFIG_ARCH_MEMMOVE=n -CONFIG_ARCH_MEMSET=n -CONFIG_ARCH_STRCMP=n -CONFIG_ARCH_STRCPY=n -CONFIG_ARCH_STRNCPY=n -CONFIG_ARCH_STRLEN=n -CONFIG_ARCH_STRNLEN=n -CONFIG_ARCH_BZERO=n +# CONFIG_FS_FAT is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set # -# Sizes of configurable things (0 disables) +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=2 +# CONFIG_GRAN is not set + +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines # -CONFIG_MAX_TASKS=16 -CONFIG_MAX_TASK_ARGS=4 -CONFIG_NPTHREAD_KEYS=4 -CONFIG_NFILE_DESCRIPTORS=8 -CONFIG_NFILE_STREAMS=8 -CONFIG_NAME_MAX=32 CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_STDIO_LINEBUFFER=y CONFIG_NUNGET_CHARS=2 -CONFIG_PREALLOC_MQ_MSGS=4 -CONFIG_MQ_MAXMSGSIZE=32 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_PREALLOC_WDOGS=4 -CONFIG_PREALLOC_TIMERS=4 +CONFIG_LIB_HOMEDIR="/" +# CONFIG_LIBM is not set +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +# 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_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set # -# Filesystem configuration +# Basic CXX Support # -CONFIG_FS_FAT=n -CONFIG_FAT_LCNAMES=n -CONFIG_FAT_LFN=n -CONFIG_FAT_MAXFNAME=32 -CONFIG_FS_NXFFS=n -CONFIG_FS_ROMFS=n +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set # -# Maintain legacy build behavior (revisit) +# Application Configuration # -CONFIG_MMCSD=y -CONFIG_MMCSD_SPI=y -CONFIG_MMCSD_SDIO=y +# +# Built-In Applications +# +# CONFIG_BUILTIN is not set # -# SPI-based MMC/SD driver +# Examples # -CONFIG_MMCSD_NSLOTS=1 -CONFIG_MMCSD_READONLY=n -CONFIG_MMCSD_SPICLOCK=12500000 +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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_JSON is not set +CONFIG_EXAMPLES_HIDKBD=y +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +# CONFIG_EXAMPLES_NSH is not set +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WLAN is not set # -# Block driver buffering +# Interpreters # -CONFIG_FS_READAHEAD=n -CONFIG_FS_WRITEBUFFER=n # -# SDIO-based MMC/SD driver +# Interpreters # -CONFIG_SDIO_DMA=n -CONFIG_MMCSD_MMCSUPPORT=n -CONFIG_MMCSD_HAVECARDDETECT=n +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set # -# TCP/IP and UDP support via uIP +# Network Utilities # -CONFIG_NET=n -CONFIG_NET_IPv6=n -CONFIG_NSOCKET_DESCRIPTORS=8 -CONFIG_NET_SOCKOPTS=y -CONFIG_NET_BUFSIZE=562 -CONFIG_NET_TCP=y -CONFIG_NET_TCP_CONNS=8 -CONFIG_NET_NTCP_READAHEAD_BUFFERS=16 -CONFIG_NET_TCPBACKLOG=n -CONFIG_NET_MAX_LISTENPORTS=8 -CONFIG_NET_UDP=y -CONFIG_NET_UDP_CHECKSUMS=y -#CONFIG_NET_UDP_CONNS=8 -CONFIG_NET_ICMP=y -CONFIG_NET_ICMP_PING=y -#CONFIG_NET_PINGADDRCONF=0 -CONFIG_NET_STATISTICS=y -#CONFIG_NET_RECEIVE_WINDOW= -#CONFIG_NET_ARPTAB_SIZE=8 -CONFIG_NET_BROADCAST=n # -# UIP Network Utilities +# Networking Utilities # -CONFIG_NET_DHCP_LIGHT=n -CONFIG_NET_RESOLV_ENTRIES=4 +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set # -# USB Device Configuration +# ModBus # -CONFIG_USBDEV=n -CONFIG_USBDEV_ISOCHRONOUS=n -CONFIG_USBDEV_DUALSPEED=n -CONFIG_USBDEV_SELFPOWERED=y -CONFIG_USBDEV_REMOTEWAKEUP=n -CONFIG_USBDEV_MAXPOWER=100 -CONFIG_USBDEV_TRACE=n -CONFIG_USBDEV_TRACE_NRECORDS=128 # -# USB Host Configuration +# FreeModbus # -CONFIG_USBHOST=y -CONFIG_USBHOST_NPREALLOC=0 -CONFIG_USBHOST_BULK_DISABLE=y -CONFIG_USBHOST_INT_DISABLE=n -CONFIG_USBHOST_ISOC_DISABLE=y +# CONFIG_MODBUS is not set # -# LPC17xx USB Device Configuration +# NSH Library # -CONFIG_LPC17_USBDEV_FRAME_INTERRUPT=n -CONFIG_LPC17_USBDEV_EPFAST_INTERRUPT=n -CONFIG_LPC17_USBDEV_DMA=n -CONFIG_LPC17_USBDEV_NDMADESCRIPTORS=0 -CONFIG_LPC17_USBDEV_DMAINTMASK=0 +# CONFIG_NSH_LIBRARY is not set # -# LPC17xx USB Host Configuration +# NxWidgets/NxWM # -# OHCI RAM layout: + +# +# System NSH Add-Ons # -CONFIG_USBHOST_OHCIRAM_SIZE=1536 -CONFIG_USBHOST_NEDS=2 -CONFIG_USBHOST_NTDS=3 -CONFIG_USBHOST_TDBUFFERS=3 -CONFIG_USBHOST_TDBUFSIZE=128 -CONFIG_USBHOST_IOBUFSIZE=512 # -# USB Serial Device Configuration -# -CONFIG_PL2303=n -CONFIG_PL2303_EPINTIN=1 -CONFIG_PL2303_EPBULKOUT=2 -CONFIG_PL2303_EPBULKIN=5 -CONFIG_PL2303_NWRREQS=4 -CONFIG_PL2303_NRDREQS=4 -CONFIG_PL2303_VENDORID=0x067b -CONFIG_PL2303_PRODUCTID=0x2303 -CONFIG_PL2303_VENDORSTR="Nuttx" -CONFIG_PL2303_PRODUCTSTR="USBdev Serial" -CONFIG_PL2303_RXBUFSIZE=512 -CONFIG_PL2303_TXBUFSIZE=512 - -# -# USB Storage Device Configuration -# -CONFIG_USBMSC=n -CONFIG_USBMSC_EP0MAXPACKET=64 -CONFIG_USBMSC_EPBULKOUT=2 -CONFIG_USBMSC_EPBULKIN=5 -CONFIG_USBMSC_NRDREQS=2 -CONFIG_USBMSC_NWRREQS=2 -CONFIG_USBMSC_BULKINREQLEN=256 -CONFIG_USBMSC_BULKOUTREQLEN=256 -CONFIG_USBMSC_VENDORID=0x584e -CONFIG_USBMSC_VENDORSTR="NuttX" -CONFIG_USBMSC_PRODUCTID=0x5342 -CONFIG_USBMSC_PRODUCTSTR="USBdev Storage" -CONFIG_USBMSC_VERSIONNO=0x0399 -CONFIG_USBMSC_REMOVABLE=y - -# -# Settings for examples/uip -# -CONFIG_EXAMPLES_UIP_IPADDR=0x0a000002 -CONFIG_EXAMPLES_UIP_DRIPADDR=0x0a000001 -CONFIG_EXAMPLES_UIP_NETMASK=0xffffff00 -CONFIG_EXAMPLES_UIP_DHCPC=n - -# -# Settings for examples/nettest -# -CONFIG_EXAMPLES_NETTEST_SERVER=n -CONFIG_EXAMPLES_NETTEST_PERFORMANCE=n -CONFIG_EXAMPLES_NETTEST_NOMAC=y -CONFIG_EXAMPLES_NETTEST_IPADDR=0x0a000002 -CONFIG_EXAMPLES_NETTEST_DRIPADDR=0x0a000001 -CONFIG_EXAMPLES_NETTEST_NETMASK=0xffffff00 -CONFIG_EXAMPLES_NETTEST_CLIENTIP=0x0a000001 - -# -# Settings for examples/ostest -# -CONFIG_EXAMPLES_OSTEST_LOOPS=1 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 -CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 - -# -# Settings for examples/buttons -# -CONFIG_EXAMPLES_BUTTONS_MIN=0 -CONFIG_EXAMPLES_BUTTONS_MAX=7 -CONFIG_EXAMPLES_IRQBUTTONS_MIN=0 -CONFIG_EXAMPLES_IRQBUTTONS_MAX=7 -CONFIG_EXAMPLES_BUTTONS_NAME0="BUT1" -CONFIG_EXAMPLES_BUTTONS_NAME1="BUT2" -CONFIG_EXAMPLES_BUTTONS_NAME2="WAKE-UP" -CONFIG_EXAMPLES_BUTTONS_NAME3="CENTER" -CONFIG_EXAMPLES_BUTTONS_NAME4="UP" -CONFIG_EXAMPLES_BUTTONS_NAME5="DOWN" -CONFIG_EXAMPLES_BUTTONS_NAME6="LEFT" -CONFIG_EXAMPLES_BUTTONS_NAME7="RIGHT" - -# -# Settings for apps/nshlib -# -CONFIG_NSH_FILEIOSIZE=512 -CONFIG_NSH_STRERROR=n -CONFIG_NSH_LINELEN=64 -CONFIG_NSH_NESTDEPTH=3 -CONFIG_NSH_DISABLESCRIPT=n -CONFIG_NSH_DISABLEBG=n -CONFIG_NSH_ROMFSETC=n -CONFIG_NSH_CONSOLE=y -CONFIG_NSH_TELNET=y -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_IOBUFFER_SIZE=512 -CONFIG_NSH_DHCPC=n -CONFIG_NSH_NOMAC=y -CONFIG_NSH_IPADDR=0x0a000002 -CONFIG_NSH_DRIPADDR=0x0a000001 -CONFIG_NSH_NETMASK=0xffffff00 -CONFIG_NSH_ROMFSMOUNTPT="/etc" -CONFIG_NSH_INITSCRIPT="init.d/rcS" -CONFIG_NSH_ROMFSDEVNO=0 -CONFIG_NSH_ROMFSSECTSIZE=64 -CONFIG_NSH_FATDEVNO=1 -CONFIG_NSH_FATSECTSIZE=512 -CONFIG_NSH_FATNSECTORS=1024 -CONFIG_NSH_FATMOUNTPT="/tmp" - -# -# Architecture-specific NSH options -# -CONFIG_NSH_MMCSDSPIPORTNO=1 -CONFIG_NSH_MMCSDSLOTNO=0 -CONFIG_NSH_MMCSDMINOR=0 - -# -# Settings for examples/usbserial -# -CONFIG_EXAMPLES_USBSERIAL_INONLY=n -CONFIG_EXAMPLES_USBSERIAL_OUTONLY=n -CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=n -CONFIG_EXAMPLES_USBSERIAL_ONLYBIG=n - -CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n -CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n -CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n -CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n -CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set # -# Stack and heap information +# I2C tool # -CONFIG_BOOT_RUNFROMFLASH=n -CONFIG_BOOT_COPYTORAM=n -CONFIG_CUSTOM_STACK=n -CONFIG_IDLETHREAD_STACKSIZE=1024 -CONFIG_USERMAIN_STACKSIZE=2048 -CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=2048 -CONFIG_HEAP_BASE= -CONFIG_HEAP_SIZE= + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +# CONFIG_SYSTEM_READLINE is not set + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/nuttx/configs/olimex-lpc1766stk/hidkbd/setenv.sh b/nuttx/configs/olimex-lpc1766stk/hidkbd/setenv.sh index af4a2589e..6b51c10de 100755 --- a/nuttx/configs/olimex-lpc1766stk/hidkbd/setenv.sh +++ b/nuttx/configs/olimex-lpc1766stk/hidkbd/setenv.sh @@ -50,7 +50,7 @@ fi # 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/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/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 @@ -62,7 +62,7 @@ fi # This is the Cygwin path to the location where I build the buildroot # toolchain. -export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" +# export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" # The Olimex-lpc1766stk/tools directory export LPCTOOL_DIR="${WD}/configs/olimex-lpc1766stk/tools" diff --git a/nuttx/drivers/usbhost/Kconfig b/nuttx/drivers/usbhost/Kconfig index 35695d750..de8469b41 100644 --- a/nuttx/drivers/usbhost/Kconfig +++ b/nuttx/drivers/usbhost/Kconfig @@ -2,6 +2,7 @@ # For a description of the syntax of this configuration file, # see misc/tools/kconfig-language.txt. # + config USBHOST_NPREALLOC int "Number of pre-allocated class instances" default 4 @@ -29,64 +30,85 @@ config USBHOST_ISOC_DISABLE On some architectures, selecting this setting will reduce driver size by disabling isochronous endpoint support +config USBHOST_MSC + bool "Mass Storage Class Support" + default n + depends on !BULK_DISABLE + ---help--- + Enable support for the keyboard class driver. This also depends on + NFILE_DESCRIPTORS > 0 && SCHED_WORKQUEUE=y + config USBHOST_HIDKBD - bool "HID keyboad class support" + bool "HID Keyboard Class Support" default n - depends on !USBHOST_INT_DISABLE && SCHED_WORKQUEUE && !DISABLE_SIGNALS + depends on !INT_DISABLE + ---help--- + Enable support for the keyboard class driver. This also depends on + SCHED_WORKQUEUE && !DISABLE_SIGNALS if USBHOST_HIDKBD config HIDKBD_POLLUSEC - bool "" - default n + int "Keyboard Poll Rate (MSEC)" + default 100000 ---help--- - Device poll rate in microseconds. Default: 100 milliseconds. + Device poll rate in microseconds. Default: 100,000 microseconds. config HIDKBD_DEFPRIO - bool "" - default n + int "Polling Thread Priority" + default 50 ---help--- Priority of the polling thread. Default: 50. config HIDKBD_STACKSIZE - bool "" - default n + int "Polling thread stack size" + default 1024 ---help--- Stack size for polling thread. Default: 1024 config HIDKBD_BUFSIZE - bool "" - default n + int "Scancode Buffer Size" + default 64 ---help--- Scancode buffer size. Default: 64. config HIDKBD_NPOLLWAITERS - bool "" - default n + int "Max Number of Waiters for Poll Event" + default 2 + depends on !DISABLE_POLL ---help--- If the poll() method is enabled, this defines the maximum number of threads that can be waiting for keyboard events. Default: 2. config HIDKBD_RAWSCANCODES - bool "" + bool "Use Raw Scan Codes" + default n + ---help--- + If set to y no conversions will be made on the raw keyboard scan + codes. This option is useful during testing. Default: ASCII conversion. + +config HIDKBD_ENCODED + bool "Enocode Special Keys" default n + depends on !HIDKBD_RAWSCANCODES ---help--- - If set to y no conversion will be made on the raw keyboard scan - codes. Default: ASCII conversion. + Encode special key press events in the user buffer. In this case, + the use end must decode the encoded special key values using the + interfaces defined in include/nuttx/input/kbd_codec.h. These + special keys include such things as up/down arrows, home and end + keys, etc. If this not defined, only 7-bit print-able and control + ASCII characters will be provided to the user. config HIDKBD_ALLSCANCODES - bool "" + bool "Use All Scancodes" default n ---help--- If set to y all 231 possible scancodes will be converted to something. Default: 104 key US keyboard. config HIDKBD_NODEBOUNCE - bool "" + bool "Disable Debounce" default n ---help--- If set to y normal debouncing is disabled. Default: Debounce enabled (No repeat keys). - USB host mass storage class driver. Requires USBHOST=y, - config USBHOST_BULK_DISABLE=n, NFILE_DESCRIPTORS > 0, - and SCHED_WORKQUEUE=y endif diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index e69d68e7b..e0c4680eb 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbhost/usbhost_hidkbd.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,11 @@ #include #include +#ifdef CONFIG_HIDKBD_ENCODED +# include +# include +#endif + /* Don't compile if prerequisites are not met */ #if defined(CONFIG_USBHOST) && !defined(CONFIG_USBHOST_INT_DISABLE) && CONFIG_NFILE_DESCRIPTORS > 0 @@ -126,6 +131,14 @@ # endif #endif +/* If we are using raw scancodes, then we cannot support encoding of + * special characters either. + */ + +#ifdef CONFIG_HIDKBD_RAWSCANCODES +# undef CONFIG_HIDKBD_ENCODED +#endif + /* Driver support ***********************************************************/ /* This format is used to construct the /dev/kbd[n] device driver path. It * defined here so that it will be used consistently in all places. @@ -144,6 +157,23 @@ #define USBHOST_MAX_CREFS 0x7fff +/* Debug ********************************************************************/ +/* Both CONFIG_DEBUG_INPUT and CONFIG_DEBUG_USB could apply to this file. + * We assume here that CONFIG_DEBUG_INPUT might be enabled separately, but + * CONFIG_DEBUG_USB implies both. + */ + +#ifndef CONFIG_DEBUG_INPUT +# undef idbg +# define idbg udbg +# undef illdbg +# define illdbg ulldbg +# undef ivdbg +# define ivdbg uvdbg +# undef illvdbg +# define illvdbg ullvdbg +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -209,6 +239,16 @@ struct usbhost_state_s uint8_t kbdbuffer[CONFIG_HIDKBD_BUFSIZE]; }; +/* This type is used for encoding special characters */ + +#ifdef CONFIG_HIDKBD_ENCODED +struct usbhost_outstream_s +{ + struct lib_outstream_s stream; + FAR struct usbhost_state_s *priv; +}; +#endif + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -240,7 +280,15 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev /* Keyboard polling thread */ static void usbhost_destroy(FAR void *arg); +static void usbhost_putbuffer(FAR struct usbhost_state_s *priv, uint8_t keycode); +#ifdef CONFIG_HIDKBD_ENCODED +static void usbhost_putstream(FAR struct lib_outstream_s *this, int ch); +#endif static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier); +#ifdef CONFIG_HIDKBD_ENCODED +static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, + uint8_t scancode, uint8_t modifier); +#endif static int usbhost_kbdpoll(int argc, char *argv[]); /* Helpers for usbhost_connect() */ @@ -346,6 +394,121 @@ static struct usbhost_state_s *g_priv; /* Data passed to thread */ */ #ifndef CONFIG_HIDKBD_RAWSCANCODES +#ifdef CONFIG_HIDKBD_ENCODED + +/* The first and last scancode values with encode-able values */ + +#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */ +#ifdef CONFIG_HIDKBD_ALLSCANCODES +# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */ +#else +#define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */ +#endif + +#define USBHID_NUMENCODINGS (LAST_ENCODING - FIRST_ENCODING + 1) + +static const uint8_t encoding[USBHID_NUMENCODINGS] = +{ + /* 0x28-0x2f: Enter,escape,del,back-tab,space,_,+,{ */ + + KEYCODE_ENTER, 0, KEYCODE_FWDDEL, KEYCODE_BACKDEL, 0, 0, 0, 0, + + /* 0x30-0x37: },|,Non-US tilde,:,",grave tidle,<,> */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */ + + 0, KEYCODE_CAPSLOCK, KEYCODE_F1, KEYCODE_F2, KEYCODE_F3, KEYCODE_F4, KEYCODE_F5, KEYCODE_F6, + + /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ + + KEYCODE_F7, KEYCODE_F8, KEYCODE_F9, KEYCODE_F10, KEYCODE_F11, KEYCODE_F12, KEYCODE_PRTSCRN, KEYCODE_SCROLLLOCK, + + /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ + + KEYCODE_PAUSE, KEYCODE_INSERT, KEYCODE_HOME, KEYCODE_PAGEUP, KEYCODE_FWDDEL, KEYCODE_END, KEYCODE_PAGEDOWN, KEYCODE_RIGHT, + + /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ + + KEYCODE_LEFT, KEYCODE_DOWN, KEYCODE_UP, KEYCODE_NUMLOCK, 0, 0, 0, 0, + + /* 0x58-0x5f: Enter,1-7 */ + + KEYCODE_ENTER, 0, 0, 0, 0, 0, 0, 0, + + /* 0x60-0x66: 8-9,0,.,Non-US \,Application,Power */ + + 0, 0, 0, 0, 0, 0, KEYCODE_POWER, + +#ifdef CONFIG_HIDKBD_ALLSCANCODES + + 0, /* 0x67 = */ + + /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */ + + KEYCODE_F13, KEYCODE_F14, KEYCODE_F15, KEYCODE_F16, KEYCODE_F17, KEYCODE_F18, KEYCODE_F19, KEYCODE_F20, + + /* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */ + + KEYCODE_F21, KEYCODE_F22, KEYCODE_F23, KEYCODE_F24, KEYCODE_EXECUTE, KEYCODE_HELP, KEYCODE_MENU, KEYCODE_SELECT, + + /* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */ + + KEYCODE_STOP, KEYCODE_AGAIN, KEYCODE_UNDO, KEYCODE_CUT, KEYCODE_COPY, KEYCODE_PASTE, KEYCODE_FIND, KEYCODE_MUTE, + + /* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */ + + KEYCODE_VOLUP, KEYCODE_VOLDOWN, KEYCODE_LCAPSLOCK, KEYCODE_LNUMLOCK, KEYCODE_LSCROLLLOCK, 0, 0, 0, + + /* 0x88-0x8f: International 2-9 */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0x90-0x97: LAN 1-8 */ + + KEYCODE_LANG1, KEYCODE_LANG2, KEYCODE_LANG3, KEYCODE_LANG4, KEYCODE_LANG5, KEYCODE_LANG6, KEYCODE_LANG7, KEYCODE_LANG8, + + /* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */ + + 0, 0, KEYCODE_SYSREQ, KEYCODE_CANCEL, KEYCODE_CLEAR, 0, KEYCODE_ENTER, 0, + + /* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0xa8-0xaf: (reserved) */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0xb8-0xbf: {,},tab,backspace,A-D */ + + 0, 0, 0, KEYCODE_BACKDEL, 0, 0, 0, 0, + + /* 0xc0-0xc7: E-F,XOR,^,%,<,>,& */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0xc8-0xcf: &&,|,||,:,#, ,@,! */ + + 0, 0, 0, 0, 0, 0, 0, 0, + + /* 0xd0-0xd7: Memory Store,Recall,Clear,Add,Subtract,Muliply,Divide,+/- */ + + KEYCODE_MEMSTORE, KEYCODE_MEMRECALL, KEYCODE_MEMCLEAR, KEYCODE_MEMADD, KEYCODE_MEMSUB, KEYCODE_MEMMUL, KEYCODE_MEMDIV, KEYCODE_NEGATE, + + /* 0xd8-0xdd: Clear,ClearEntry,Binary,Octal,Decimal,Hexadecimal */ + + KEYCODE_CLEAR, KEYCODE_CLEARENTRY, KEYCODE_BINARY, KEYCODE_OCTAL, KEYCODE_DECIMAL, KEYCODE_HEXADECIMAL +#endif +}; + +#endif + static const uint8_t ucmap[USBHID_NUMSCANCODES] = { 0, 0, 0, 0, 'A', 'B', 'C', 'D', /* 0x00-0x07: Reserved, errors, A-D */ @@ -356,7 +519,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] = '\n', '\033', '\177', 0, ' ', '_', '+', '{', /* 0x28-0x2f: Enter,escape,del,back-tab,space,_,+,{ */ '}', '|', 0, ':', '"', 0, '<', '>', /* 0x30-0x37: },|,Non-US tilde,:,",grave tidle,<,> */ '?', 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,sScrollLock */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ 0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ '\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */ @@ -368,7 +531,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] = 0, 0, 0, 0, 0, ',', 0, 0, /* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x88-0x8f: International 2-9 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x97: LAN 1-8 */ - 0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Ease,SysReq,Cancel,Clear,Prior,Return,Separator */ + 0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa8-0xaf: (reserved) */ 0, 0, 0, 0, 0, 0, '(', ')', /* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */ @@ -403,7 +566,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] = 0, 0, 0, 0, 0, ',', 0, 0, /* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x88-0x8f: International 2-9 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x97: LAN 1-8 */ - 0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Ease,SysReq,Cancel,Clear,Prior,Return,Separator */ + 0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa8-0xaf: (reserved) */ 0, 0, 0, 0, 0, 0, '(', ')', /* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */ @@ -637,6 +800,88 @@ static void usbhost_destroy(FAR void *arg) usbhost_freeclass(priv); } +/**************************************************************************** + * Name: usbhost_putbuffer + * + * Description: + * Add one character to the user buffer. + * + * Input Parameters: + * priv - Driver internal state + * keycode - The value to add to the user buffer + * + * Returned Values: + * None + * + ****************************************************************************/ + +static void usbhost_putbuffer(FAR struct usbhost_state_s *priv, + uint8_t keycode) +{ + register unsigned int head; + register unsigned int tail; + + /* Copy the next keyboard character into the user buffer. */ + + head = priv->headndx; + priv->kbdbuffer[head] = keycode; + + /* Increment the head index */ + + if (++head >= CONFIG_HIDKBD_BUFSIZE) + { + head = 0; + } + + /* If the buffer is full, then increment the tail index to make space. Is + * it better to lose old keystrokes or new? + */ + + tail = priv->tailndx; + if (tail == head) + { + if (++tail >= CONFIG_HIDKBD_BUFSIZE) + { + tail = 0; + } + + /* Save the updated tail index */ + + priv->tailndx = tail; + } + + /* Save the updated head index */ + + priv->headndx = head; +} + +/**************************************************************************** + * Name: usbhost_putstream + * + * Description: + * A wrapper for usbhost_putc that is compatibile with the lib_outstream_s + * putc methos. + * + * Input Parameters: + * stream - The struct lib_outstream_s reference + * ch - The character to add to the user buffer + * + * Returned Values: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_HIDKBD_ENCODED +static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch) +{ + FAR struct usbhost_outstream_s *privstream = (FAR struct lib_outstream_s *)stream; + + DEBUGASSERT(privstream && privstream->priv); + usbhost_putbuffer(privstream->priv), (uint8_t)ch); + stream->nput++; +} +#endif + /**************************************************************************** * Name: usbhost_mapscancode * @@ -679,6 +924,58 @@ static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier) #endif } +/**************************************************************************** + * Name: usbhost_encodescancode + * + * Description: + * Check if the key has a special function encoding and, if it does, add + * the encoded value to the user buffer. + * + * Input Parameters: + * priv - Driver internal state + * scancode - Scan code to be mapped. + * modifier - Ctrl,Alt,Shift,GUI modifier bits + * + * Returned Values: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_HIDKBD_ENCODED +static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, + uint8_t scancode, uint8_t modifier) +{ + struct usbhost_outstream_s stream; + uint8_t encoded; + + /* Check if the raw scancode is in a valid range */ + + if (scancode >= FIRST_ENCODING && scancode <= LAST_ENCODING) + { + /* Yes the value is within range */ + + encoded = encoding(scancode - FIRST_ENCODING); + ivdbg(" scancode: %02x modifier: %02x encoded: %d\n", + scancode, modifier, encoded); + + if (encoded) + { + struct usbhost_outstream_s usbstream; + + /* And it does correspond to a special function key */ + + usbstream->stream.put = usbhost_putstream; + usbstream->stream.nput = 0; + usbstream->priv = priv; + + /* Add the special function value to the user buffer */ + + kbd_putspecial((enum kbd_keycode_e)encoded, &usbstream); + } + } +} +#endif + /**************************************************************************** * Name: usbhost_kbdpoll * @@ -704,6 +1001,8 @@ static int usbhost_kbdpoll(int argc, char *argv[]) unsigned int npolls = 0; #endif unsigned int nerrors = 0; + bool empty = true; + bool newstate; int ret; uvdbg("Started\n"); @@ -717,13 +1016,13 @@ static int usbhost_kbdpoll(int argc, char *argv[]) * running. */ - priv = g_priv; - DEBUGASSERT(priv != NULL); + priv = g_priv; + DEBUGASSERT(priv != NULL); - priv->polling = true; - priv->crefs++; - usbhost_givesem(&g_syncsem); - sleep(1); + priv->polling = true; + priv->crefs++; + usbhost_givesem(&g_syncsem); + sleep(1); /* Loop here until the device is disconnected */ @@ -784,17 +1083,12 @@ static int usbhost_kbdpoll(int argc, char *argv[]) else if (priv->open) { struct usbhid_kbdreport_s *rpt = (struct usbhid_kbdreport_s *)priv->tbuffer; - unsigned int head; - unsigned int tail; - uint8_t ascii; + uint8_t keycode; int i; /* Add the newly received keystrokes to our internal buffer */ usbhost_takesem(&priv->exclsem); - head = priv->headndx; - tail = priv->tailndx; - for (i = 0; i < 6; i++) { /* Is this key pressed? But not pressed last time? @@ -828,15 +1122,15 @@ static int usbhost_kbdpoll(int argc, char *argv[]) * or cursor controls in this version of the driver. */ - ascii = usbhost_mapscancode(rpt->key[i], rpt->modifier); - uvdbg("Key %d: %02x ASCII:%c modifier: %02x\n", - i, rpt->key[i], ascii ? ascii : ' ', rpt->modifier); + keycode = usbhost_mapscancode(rpt->key[i], rpt->modifier); + ivdbg("Key %d: %02x keycode:%c modifier: %02x\n", + i, rpt->key[i], keycode ? keycode : ' ', rpt->modifier); /* Zero at this point means that the key does not map to a * printable character. */ - if (ascii != 0) + if (keycode != 0) { /* Handle control characters. Zero after this means * a valid, NUL character. @@ -844,36 +1138,28 @@ static int usbhost_kbdpoll(int argc, char *argv[]) if ((rpt->modifier & (USBHID_MODIFER_LCTRL|USBHID_MODIFER_RCTRL)) != 0) { - ascii &= 0x1f; + keycode &= 0x1f; } /* Copy the next keyboard character into the user * buffer. */ - priv->kbdbuffer[head] = ascii; - - /* Increment the head index */ - - if (++head >= CONFIG_HIDKBD_BUFSIZE) - { - head = 0; - } + usbhost_putbuffer(priv, keycode); + } - /* If the buffer is full, then increment the tail - * index to make space. Is it better to lose old - * keystrokes or new? - */ + /* The zero might, however, map to a special keyboard action (such as a + * cursor movement or function key). Attempt to encode the special key. + */ - if (tail == head) - { - if (++tail >= CONFIG_HIDKBD_BUFSIZE) - { - tail = 0; - } - } +#ifdef CONFIG_HIDKBD_ENCODED + else + { + usbhost_encodescancode(priv, rpt->key[i], rpt->modifier)); } +#endif } + /* Save the scancode (or lack thereof) for key debouncing on * next keyboard report. */ @@ -885,7 +1171,8 @@ static int usbhost_kbdpoll(int argc, char *argv[]) /* Did we just transition from no data available to data available? */ - if (head != tail && priv->headndx == priv->tailndx) + newstate = (priv->headndx == priv->tailndx); + if (empty && !newstate) { /* Yes.. Is there a thread waiting for keyboard data now? */ @@ -902,10 +1189,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) usbhost_pollnotify(priv); } - /* Update the head/tail indices */ - - priv->headndx = head; - priv->tailndx = tail; + empty = newstate; usbhost_givesem(&priv->exclsem); } @@ -958,6 +1242,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) usbhost_givesem(&priv->exclsem); } + return 0; } diff --git a/nuttx/include/nuttx/input/kbd_codec.h b/nuttx/include/nuttx/input/kbd_codec.h index b103d544e..d374ed8d3 100644 --- a/nuttx/include/nuttx/input/kbd_codec.h +++ b/nuttx/include/nuttx/input/kbd_codec.h @@ -113,7 +113,7 @@ enum kbd_keycode_e KEYCODE_PAUSE, /* Pause */ KEYCODE_BREAK, /* Break */ KEYCODE_CANCEL, /* Cancel */ - KEYCODE_PRINTSCN, /* PrintScreen */ + KEYCODE_PRTSCRN, /* PrintScreen */ KEYCODE_SYSREQ, /* SysReq/Attention */ /* Audio */ @@ -131,14 +131,15 @@ enum kbd_keycode_e KEYCODE_CLEAR, /* Clear */ KEYCODE_CLEARENTRY, /* Clear entry */ + KEYCODE_NEGATE, /* +/- */ - KEYCODE_MEMSET, /* Memory set */ + KEYCODE_MEMSTORE, /* Memory store */ KEYCODE_MEMCLEAR, /* Memory clear */ KEYCODE_MEMRECALL, /* Memory recall */ KEYCODE_MEMADD, /* Memory add */ - KEYCODE_MEMSUBTRACT, /* Memory substract */ - KEYCODE_MEMMULTIPY, /* Memory multiply */ - KEYCODE_MEMDIVIDE, /* Memory divide */ + KEYCODE_MEMSUB, /* Memory substract */ + KEYCODE_MEMMUL, /* Memory multiply */ + KEYCODE_MEMDIV, /* Memory divide */ KEYCODE_BINARY, /* Binary mode */ KEYCODE_OCTAL, /* Octal mode */ @@ -197,7 +198,7 @@ enum kbd_keycode_e * Public Types ****************************************************************************/ -struct kget_getstate_s +struct kbd_getstate_s { uint8_t nch; /* Number of characters in the buffer */ uint8_t ndx; /* Index to next character in the buffer */ @@ -225,7 +226,7 @@ extern "C" * Put one byte of normal, "in-band" ASCII data into the output stream. * * Input Parameters: - * ch - The character to be into the output stream. + * ch - The character to be added to the output stream. * stream - An instance of lib_outstream_s to do the low-level put * operation. * @@ -243,6 +244,9 @@ extern "C" * Put one special, "out-of-band" command into the output stream. * * Input Parameters: + * keycode - The command to be added to the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. * * Returned Value: * None @@ -261,7 +265,7 @@ void kbd_putspecial(enum kbd_keycode_e keycode, * Name: kbd_get * * Description: - * Put one byte of data or special command from the driver provided input + * Get one byte of data or special command from the driver provided input * buffer. * * Input Parameters: @@ -274,15 +278,17 @@ void kbd_putspecial(enum kbd_keycode_e keycode, * should be cleared the first time that kbd_get is called. * * Returned Value: - * 1 - Indicates the successful receipt of a special, "out-of-band" command + * 1 - Indicates the successful receipt of a special, "out-of-band" command. + * The returned value in pch is a value from enum kbd_getstate_s. * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. + * The returned value in pch is a simple byte of text or control data. * EOF - An error has getting the next character (reported by the stream). * Normally indicates the end of file. * ****************************************************************************/ int kbd_get(FAR struct lib_instream_s *stream, - FAR struct kget_getstate_s *state, FAR uint8_t *pch); + FAR struct kbd_getstate_s *state, FAR uint8_t *pch); #ifdef __cplusplus } diff --git a/nuttx/libc/misc/lib_kbddecode.c b/nuttx/libc/misc/lib_kbddecode.c index 046d570f9..cb57b5215 100644 --- a/nuttx/libc/misc/lib_kbddecode.c +++ b/nuttx/libc/misc/lib_kbddecode.c @@ -89,7 +89,7 @@ * ****************************************************************************/ -static int kbd_reget(FAR struct kget_getstate_s *state, FAR uint8_t *pch) +static int kbd_reget(FAR struct kbd_getstate_s *state, FAR uint8_t *pch) { /* Return the next character */ @@ -107,7 +107,7 @@ static int kbd_reget(FAR struct kget_getstate_s *state, FAR uint8_t *pch) * Name: kbd_get * * Description: - * Put one byte of data or special command from the driver provided input + * Get one byte of data or special command from the driver provided input * buffer. * * Input Parameters: @@ -120,15 +120,17 @@ static int kbd_reget(FAR struct kget_getstate_s *state, FAR uint8_t *pch) * should be cleared the first time that kbd_get is called. * * Returned Value: - * 1 - Indicates the successful receipt of a special, "out-of-band" command + * 1 - Indicates the successful receipt of a special, "out-of-band" command. + * The returned value in pch is a value from enum kbd_getstate_s. * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. + * The returned value in pch is a simple byte of text or control data. * EOF - An error has getting the next character (reported by the stream). * Normally indicates the end of file. * ****************************************************************************/ int kbd_get(FAR struct lib_instream_s *stream, - FAR struct kget_getstate_s *state, FAR uint8_t *pch) + FAR struct kbd_getstate_s *state, FAR uint8_t *pch) { int ch; diff --git a/nuttx/libc/misc/lib_kbdencode.c b/nuttx/libc/misc/lib_kbdencode.c index 80bf14777..40a8805b1 100644 --- a/nuttx/libc/misc/lib_kbdencode.c +++ b/nuttx/libc/misc/lib_kbdencode.c @@ -62,6 +62,9 @@ * Put one special, "out-of-band" command into the output stream. * * Input Parameters: + * keycode - The command to be added to the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. * * Returned Value: * None -- cgit v1.2.3 From 8ed19bb07d00a15e2f2c9893d57b1ef1261b2d23 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 26 Dec 2012 20:04:57 +0000 Subject: Add UG_2965SWEG01 driver from Darcy Gong; fix logic error in how waiters are reawakened in the USB HID keyboard driver git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5462 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/hidkbd/hidkbd_main.c | 1 + nuttx/ChangeLog | 6 + nuttx/configs/stm32f4discovery/README.txt | 2 +- nuttx/configs/stm32f4discovery/src/Makefile | 4 + .../src/stm32f4discovery-internal.h | 4 +- .../stm32f4discovery/src/up_ug2864hsweg01.c | 161 +++ nuttx/drivers/lcd/Make.defs | 4 + nuttx/drivers/lcd/ug-2864hsweg01.c | 1177 ++++++++++++++++++++ nuttx/drivers/usbhost/usbhost_hidkbd.c | 16 +- nuttx/include/nuttx/lcd/ug-2864hsweg01.h | 245 ++++ 10 files changed, 1613 insertions(+), 7 deletions(-) create mode 100644 nuttx/configs/stm32f4discovery/src/up_ug2864hsweg01.c create mode 100644 nuttx/drivers/lcd/ug-2864hsweg01.c create mode 100644 nuttx/include/nuttx/lcd/ug-2864hsweg01.h (limited to 'apps') diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index bc1eebed0..8c9f6fa95 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -227,5 +227,6 @@ int hidkbd_main(int argc, char *argv[]) close(fd); } } + return 0; } diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 7e1c538d7..a7087656a 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3826,4 +3826,10 @@ encode special function keys. * configs/olimex-lpc1766stk/hidkbd: This configuration has been converted to use the kconfig-frontends configuration tool. + * drivers/lcd/ug-2864hsweg01.c and include/nuttx/lcd/ug-2864hsweg01.h: + Driver for UG-2864HSWEG01 OLED contributed by Darcy Gong. + * configs/stm32f4discovery/src/up_ug2864hsweg01.c: Support for the + UG-2864HSWEG01 OLED for the STM32F4Discovery board. + * drivers/usbhost/usbhost_hidkbd.c: Correct a logic error in how + tasks waiting for read data are awakened. diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt index d824668ce..37dae7b9e 100644 --- a/nuttx/configs/stm32f4discovery/README.txt +++ b/nuttx/configs/stm32f4discovery/README.txt @@ -711,7 +711,7 @@ pinout for the UG-2864AMBAG01 is specific to the theO.net display board that I am using: --------------------------+---------------------------------------------- - Connector CON10 J1: | STM32F4Discovery + Connector CON10 J1: | STM32F4Discovery --------------+-----------+---------------------------------------------- CON10 J1: | CON20 J2: | P1/P2: --------------+-----------+---------------------------------------------- diff --git a/nuttx/configs/stm32f4discovery/src/Makefile b/nuttx/configs/stm32f4discovery/src/Makefile index 68419e5d0..7ac27a7d0 100644 --- a/nuttx/configs/stm32f4discovery/src/Makefile +++ b/nuttx/configs/stm32f4discovery/src/Makefile @@ -100,6 +100,10 @@ ifeq ($(CONFIG_LCD_UG2864AMBAG01),y) CSRCS += up_ug2864ambag01.c endif +ifeq ($(CONFIG_LCD_UG2864HSWEG01),y) +CSRCS += up_ug2864hsweg01.c +endif + COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) diff --git a/nuttx/configs/stm32f4discovery/src/stm32f4discovery-internal.h b/nuttx/configs/stm32f4discovery/src/stm32f4discovery-internal.h index 00f17b58e..eae09594c 100644 --- a/nuttx/configs/stm32f4discovery/src/stm32f4discovery-internal.h +++ b/nuttx/configs/stm32f4discovery/src/stm32f4discovery-internal.h @@ -113,7 +113,7 @@ # define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN5) #endif -/* UG-2864AMBAG01 OLED Display: +/* UG-2864AMBAG01 or UG-2864HSWEG01 OLED Display: * * --------------------------+---------------------------------------------- * Connector CON10 J1: | STM32F4Discovery @@ -135,7 +135,7 @@ * ------------------------------------------------------------------------- */ -#ifdef CONFIG_LCD_UG2864AMBAG01 +#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01) # define GPIO_OLED_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN6) # define GPIO_OLED_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ diff --git a/nuttx/configs/stm32f4discovery/src/up_ug2864hsweg01.c b/nuttx/configs/stm32f4discovery/src/up_ug2864hsweg01.c new file mode 100644 index 000000000..4eee077a1 --- /dev/null +++ b/nuttx/configs/stm32f4discovery/src/up_ug2864hsweg01.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * config/stm32f4discovery/src/up_ug2864hsweg01.c + * arch/arm/src/board/up_ug2864hsweg01.c + * + * Copyright (C) 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include + +#include "stm32_gpio.h" +#include "stm32f4discovery-internal.h" + +#ifdef CONFIG_LCD_UG2864HSWEG01 + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ +/* The pin configurations here require that SPI1 is selected */ + +#ifndef CONFIG_STM32_SPI1 +# error "The OLED driver requires CONFIG_STM32_SPI1 in the configuration" +#endif + +#ifndef CONFIG_SPI_CMDDATA +# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration" +#endif + +/* Pin Configuration ********************************************************/ +/* UG-2864AMBAG01 or UG-2864HSWEG01 OLED Display: + * + * --------------------------+---------------------------------------------- + * Connector CON10 J1: | STM32F4Discovery + * --------------+-----------+---------------------------------------------- + * CON10 J1: | CON20 J2: | P1/P2: + * --------------+-----------+---------------------------------------------- + * 1 3v3 | 3,4 3v3 | P2 3V + * 3 /RESET | 8 /RESET | P2 PB6 (Arbitrary selection) + * 5 /CS | 7 /CS | P2 PB7 (Arbitrary selection)(2) + * 7 A0 | 9 A0 | P2 PB8 (Arbitrary selection)(2) + * 9 LED+ (N/C) | ----- | ----- + * 2 5V Vcc | 1,2 Vcc | P2 5V + * 4 DI | 18 D1/SI | P1 PA7 (GPIO_SPI1_MOSI == GPIO_SPI1_MOSI_1 (1)) + * 6 SCLK | 19 D0/SCL | P1 PA5 (GPIO_SPI1_SCK == GPIO_SPI1_SCK_1 (2)) + * 8 LED- (N/C) | ----- | ------ + * 10 GND | 20 GND | P2 GND + * --------------+-----------+---------------------------------------------- + * (1) Required because of on-board MEMS + * (2) Note that the OLED CS and A0 are managed in the up_spi.c file. + * ------------------------------------------------------------------------- + */ + +/* Definitions in stm32f4discovery-internal.h */ + +/* Debug ********************************************************************/ + +#ifdef CONFIG_DEBUG_LCD +# define lcddbg(format, arg...) dbg(format, ##arg) +# define lcdvdbg(format, arg...) vdbg(format, ##arg) +#else +# define lcddbg(x...) +# define lcdvdbg(x...) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_nxdrvinit + * + * Description: + * Called by NX initialization logic to configure the OLED. + * + ****************************************************************************/ + +FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) +{ + FAR struct spi_dev_s *spi; + FAR struct lcd_dev_s *dev; + + /* Configure the OLED GPIOs. This initial configuration is RESET low, + * putting the OLED into reset state. + */ + + (void)stm32_configgpio(GPIO_OLED_RESET); + + /* Wait a bit then release the OLED from the reset state */ + + up_mdelay(20); + stm32_gpiowrite(GPIO_OLED_RESET, true); + + /* Get the SPI1 port interface */ + + spi = up_spiinitialize(1); + if (!spi) + { + lcddbg("Failed to initialize SPI port 1\n"); + } + else + { + /* Bind the SPI port to the OLED */ + + dev = ug2864hsweg01_initialize(spi, devno); + if (!dev) + { + lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno); + } + else + { + lcdvdbg("Bound SPI port 1 to OLED %d\n", devno); + + /* And turn the OLED on */ + + (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); + return dev; + } + } + + return NULL; +} +#endif /* CONFIG_LCD_UG2864AMBAG01 */ diff --git a/nuttx/drivers/lcd/Make.defs b/nuttx/drivers/lcd/Make.defs index 1b445b6a7..067f76f4e 100644 --- a/nuttx/drivers/lcd/Make.defs +++ b/nuttx/drivers/lcd/Make.defs @@ -51,6 +51,10 @@ ifeq ($(CONFIG_LCD_UG2864AMBAG01),y) CSRCS += ug-2864ambag01.c endif +ifeq ($(CONFIG_LCD_UG2864HSWEG01),y) + CSRCS += ug-2864hsweg01.c +endif + ifeq ($(CONFIG_LCD_UG9664HSWAG01),y) CSRCS += ug-9664hswag01.c endif diff --git a/nuttx/drivers/lcd/ug-2864hsweg01.c b/nuttx/drivers/lcd/ug-2864hsweg01.c new file mode 100644 index 000000000..9f9f99906 --- /dev/null +++ b/nuttx/drivers/lcd/ug-2864hsweg01.c @@ -0,0 +1,1177 @@ +/************************************************************************************** + * drivers/lcd/ug-2864hsweg01.c + * Driver for Univision UG-2864HSWEG01 OLED display (wih SSD1306 controller) in SPI + * mode + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * References: + * 1. Product Specification (Preliminary), Part Name: OEL Display Module, Part ID: + * UG-2864HSWEG01, Doc No: SAS1-9046-B, Univision Technology Inc. + * 2. SSD1306, 128 X 64 Dot Matrix OLED/PLED, Preliminary Segment/Common Driver with + * Controller, Solomon Systech + * + * 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. + * + **************************************************************************************/ +/************************************************************************************** + * Device memory organization: + * + * +----------------------------+ + * | Column | + * --------+----+---+---+---+-...-+-----+ + * Page | 0 | 1 | 2 | 3 | ... | 127 | + * --------+----+---+---+---+-...-+-----+ + * Page 0 | D0 | X | | | | | + * | D1 | X | | | | | + * | D2 | X | | | | | + * | D3 | X | | | | | + * | D4 | X | | | | | + * | D5 | X | | | | | + * | D6 | X | | | | | + * | D7 | X | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 1 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 2 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 3 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 4 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 5 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 6 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * Page 7 | | | | | | | + * --------+----+---+---+---+-...-+-----+ + * + * -----------------------------------+--------------------------------------- + * Landscape Display: | Reverse Landscape Display: + * --------+-----------------------+ | --------+---------------------------+ + * | Column | | | Column | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 0 | 0 | 1 | 2 | | 127 | | Page 7 | 127 | 126 | 125 | | 0 | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 1 | V | | Page 6 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 2 | V | | Page 5 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 3 | V | | Page 4 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 4 | V | | Page 3 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 5 | V | | Page 2 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 6 | V | | Page 1 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * Page 7 | V | | Page 0 | ^ | + * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ + * -----------------------------------+--------------------------------------- + * + * -----------------------------------+--------------------------------------- + * Portrait Display: | Reverse Portrait Display: + * -----------+---------------------+ | -----------+---------------------+ + * | Page | | | Page | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * Column 0 | 0 | 1 | 2 | | 7 | | Column 127 | 7 | 6 | 5 | | 0 | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * Column 1 | > > > > > | | Column 126 | | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * Column 2 | | | Column 125 | | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * ... | | | ... | | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * Column 127 | | | Column 0 | < < < < < | + * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ + * -----------------------------------+---------------------------------------- + **************************************************************************************/ + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef CONFIG_LCD_UG2864HSWEG01 + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ +/* Configuration **********************************************************************/ +/* Limitations of the current configuration that I hope to fix someday */ + +#if CONFIG_UG2864HSWEG01_NINTERFACES != 1 +# warning "This implementation supports only a single OLED device" +# undef CONFIG_UG2864HSWEG01_NINTERFACES +# define CONFIG_UG2864HSWEG01_NINTERFACES 1 +#endif + +#if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT) +# warning "No support yet for portrait modes" +# define CONFIG_LCD_LANDSCAPE 1 +# undef CONFIG_LCD_PORTRAIT +# undef CONFIG_LCD_RLANDSCAPE +# undef CONFIG_LCD_RPORTRAIT +#elif defined(CONFIG_LCD_RLANDSCAPE) +# warning "Reverse landscape mode is untested and, hence, probably buggy" +#endif + +/* SSD1306 Commands *******************************************************************/ + +#define SSD1306_SETCOLL(ad) (0x00 | ((ad) & 0x0f)) /* Set Lower Column Address: (00h - 0fh) */ +#define SSD1306_SETCOLH(ad) (0x10 | ((ad) & 0x0f)) /* Set Higher Column Address: (10h - 1fh) */ +#define SSD1306_STARTLINE(ln) (0x40 | ((ln) & 0x3f)) /* Set Display Start Line: (40h - 7fh) */ +#define SSD1306_CONTRAST_MODE (0x81) /* Set Contrast Control Register: (Double Bytes Command) */ +# define SSD1306_CONTRAST(c) (c) +#define SSD1306_SEGREMAP(m) (0xa0 | ((m) & 0x01)) /* Set Segment Re-map: (a0h - a1h) */ +# define SSD1306_REMAPRIGHT SSD1306_SEGREMAP(0) /* Right rotation */ +# define SSD1306_REMAPPLEFT SSD1306_SEGREMAP(1) /* Left rotation */ +#define SSD1306_EDISPOFFON(s) (0xa4 | ((s) & 0x01)) /* Set Entire Display OFF/ON: (a4h - a5h) */ +# define SSD1306_EDISPOFF SSD1306_EDISPOFFON(0) /* Display off */ +# define SSD1306_EDISPON SSD1306_EDISPOFFON(1) /* Display on */ +#define SSD1306_NORMREV(s) (0xa6 | ((s) & 0x01)) /* Set Normal/Reverse Display: (a6h -a7h) */ +# define SSD1306_NORMAL SSD1306_NORMREV(0) /* Normal display */ +# define SSD1306_REVERSE SSD1306_NORMREV(1) /* Reverse display */ +#define SSD1306_MRATIO_MODE (0xa8) /* Set Multiplex Ration: (Double Bytes Command) */ +# define SSD1306_MRATIO(d) ((d) & 0x3f) +#define SSD1306_DCDC_MODE (0xad) /* Set DC-DC OFF/ON: (Double Bytes Command) */ +# define SSD1306_DCDC_OFF (0x8a) +# define SSD1306_DCDC_ON (0x8b) + +#define SSD1306_DISPOFFON(s) (0xae | ((s) & 0x01)) /* Display OFF/ON: (aeh - afh) */ +# define SSD1306_DISPOFF SSD1306_DISPOFFON(0) /* Display off */ +# define SSD1306_DISPON SSD1306_DISPOFFON(1) /* Display on */ +#define SSD1306_PAGEADDR(a) (0xb0 | ((a) & 0x0f)) /* Set Page Address: (b0h - b7h) */ +#define SSD1306_SCANDIR(d) (0xc0 | ((d) & 0x08)) /* Set Common Output Scan Direction: (c0h - c8h) */ +# define SSD1306_SCANFROMCOM0 SSD1306_SCANDIR(0x00) /* Scan from COM[0] to COM[n-1]*/ +# define SSD1306_SCANTOCOM0 SSD1306_SCANDIR(0x08) /* Scan from COM[n-1] to COM[0] */ +#define SSD1306_DISPOFFS_MODE (0xd3) /* Set Display Offset: (Double Bytes Command) */ +# define SSD1306_DISPOFFS(o) ((o) & 0x3f) +#define SSD1306_CLKDIV_SET (0xd5) /* Set Display Clock Divide Ratio/Oscillator Frequency: (Double Bytes Command) */ +# define SSD1306_CLKDIV(f,d) ((((f) & 0x0f) << 4) | ((d) & 0x0f)) +#define SSD1306_CHRGPER_SET (0xd9) /* Set Dis-charge/Pre-charge Period: (Double Bytes Command) */ +# define SSD1306_CHRGPER(d,p) ((((d) & 0x0f) << 4) | ((p) & 0x0f)) +#define SSD1306_CMNPAD_CONFIG (0xda) /* Set Common pads hardware configuration: (Double Bytes Command) */ +# define SSD1306_CMNPAD(c) ((0x02) | ((c) & 0x10)) +#define SSD1306_VCOM_SET (0xdb) /* Set VCOM Deselect Level: (Double Bytes Command) */ +# define SSD1306_VCOM(v) (v) + +#define SSD1306_CHRPUMP_SET (0x8d) /* Charge Pump Setting */ +# define SSD1306_CHRPUMP_ON (0x14) +# define SSD1306_CHRPUMP_OFF (0x10) + +#define SSD1306_RMWSTART (0xe0) /* Read-Modify-Write: (e0h) */ +#define SSD1306_NOP (0xe3) /* NOP: (e3h) */ +#define SSD1306_END (0xee) /* End: (eeh) */ + +#define SSD1306_WRDATA(d) (d) /* Write Display Data */ +#define SSD1306_STATUS_BUSY (0x80) /* Read Status */ +#define SSD1306_STATUS_ONOFF (0x40) +#define SSD1306_RDDATA(d) (d) /* Read Display Data */ + +/* Color Properties *******************************************************************/ +/* Display Resolution + * + * The SSD1306 display controller can handle a resolution of 132x64. The UG-2864HSWEG01 + * on the base board is 128x64. + */ + +#define UG2864HSWEG01_DEV_XRES 128 /* Only 128 of 131 columns used */ +#define UG2864HSWEG01_DEV_YRES 64 /* 8 pages each 8 rows */ +#define UG2864HSWEG01_DEV_XOFFSET 2 /* Offset to logical column 0 */ +#define UG2864HSWEG01_DEV_PAGES 8 /* 8 pages */ + +#if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) +# define UG2864HSWEG01_XRES UG2864HSWEG01_DEV_XRES +# define UG2864HSWEG01_YRES UG2864HSWEG01_DEV_YRES +#else +# define UG2864HSWEG01_XRES UG2864HSWEG01_DEV_YRES +# define UG2864HSWEG01_YRES UG2864HSWEG01_DEV_XRES +#endif + +/* Color depth and format */ + +#define UG2864HSWEG01_BPP 1 +#define UG2864HSWEG01_COLORFMT FB_FMT_Y1 + +/* Bytes per logical row and actual device row */ + +#define UG2864HSWEG01_XSTRIDE (UG2864HSWEG01_XRES >> 3) +#define UG2864HSWEG01_YSTRIDE (UG2864HSWEG01_YRES >> 3) + +/* Default contrast */ + +#define UG2864HSWEG01_CONTRAST (128) + +/* The size of the shadow frame buffer or one row buffer. + * + * Frame buffer size: 128 columns x 64 rows / 8 bits-per-pixel + * Row size: 128 columns x 8 rows-per-page / 8 bits-per-pixel + */ + +#define UG2864HSWEG01_FBSIZE (UG2864HSWEG01_XSTRIDE * UG2864HSWEG01_YRES) +#define UG2864HSWEG01_ROWSIZE (UG2864HSWEG01_XSTRIDE) + +/* Bit helpers */ + +#define LS_BIT (1 << 0) +#define MS_BIT (1 << 7) + +/* Debug ******************************************************************************/ + +#ifdef CONFIG_DEBUG_LCD +# define lcddbg(format, arg...) dbg(format, ##arg) +# define lcdvdbg(format, arg...) vdbg(format, ##arg) +#else +# define lcddbg(x...) +# define lcdvdbg(x...) +#endif + +/************************************************************************************** + * Private Type Definition + **************************************************************************************/ + +/* This structure describes the state of this driver */ + +struct ug2864hsweg01_dev_s +{ + struct lcd_dev_s dev; /* Publically visible device structure */ + + /* Private LCD-specific information follows */ + + FAR struct spi_dev_s *spi; /* Cached SPI device reference */ + uint8_t contrast; /* Current contrast setting */ + bool on; /* true: display is on */ + + + /* The SSD1306 does not support reading from the display memory in SPI mode. + * Since there is 1 BPP and access is byte-by-byte, it is necessary to keep + * a shadow copy of the framebuffer memory. At 128x64, this amounts to 1KB. + */ + + uint8_t fb[UG2864HSWEG01_FBSIZE]; +}; + +/************************************************************************************** + * Private Function Protototypes + **************************************************************************************/ + +/* Low-level SPI helpers */ + +#ifdef CONFIG_SPI_OWNBUS +static inline void ug2864hsweg01_configspi(FAR struct spi_dev_s *spi); +# define ug2864hsweg01_lock(spi) +# define ug2864hsweg01_unlock(spi) +#else +# define ug2864hsweg01_configspi(spi) +static void ug2864hsweg01_lock(FAR struct spi_dev_s *spi); +static void ug2864hsweg01_unlock(FAR struct spi_dev_s *spi); +#endif + +/* LCD Data Transfer Methods */ + +static int ug2864hsweg01_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels); +static int ug2864hsweg01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, + size_t npixels); + +/* LCD Configuration */ + +static int ug2864hsweg01_getvideoinfo(FAR struct lcd_dev_s *dev, + FAR struct fb_videoinfo_s *vinfo); +static int ug2864hsweg01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); + +/* LCD RGB Mapping */ + +#ifdef CONFIG_FB_CMAP +# error "RGB color mapping not supported by this driver" +#endif + +/* Cursor Controls */ + +#ifdef CONFIG_FB_HWCURSOR +# error "Cursor control not supported by this driver" +#endif + +/* LCD Specific Controls */ + +static int ug2864hsweg01_getpower(struct lcd_dev_s *dev); +static int ug2864hsweg01_setpower(struct lcd_dev_s *dev, int power); +static int ug2864hsweg01_getcontrast(struct lcd_dev_s *dev); +static int ug2864hsweg01_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); + +/************************************************************************************** + * Private Data + **************************************************************************************/ + +/* This is working memory allocated by the LCD driver for each LCD device + * and for each color plane. This memory will hold one raster line of data. + * The size of the allocated run buffer must therefore be at least + * (bpp * xres / 8). Actual alignment of the buffer must conform to the + * bitwidth of the underlying pixel type. + * + * If there are multiple planes, they may share the same working buffer + * because different planes will not be operate on concurrently. However, + * if there are multiple LCD devices, they must each have unique run buffers. + */ + +static uint8_t g_runbuffer[UG2864HSWEG01_ROWSIZE]; + +/* This structure describes the overall LCD video controller */ + +static const struct fb_videoinfo_s g_videoinfo = +{ + .fmt = UG2864HSWEG01_COLORFMT, /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */ + .xres = UG2864HSWEG01_XRES, /* Horizontal resolution in pixel columns */ + .yres = UG2864HSWEG01_YRES, /* Vertical resolution in pixel rows */ + .nplanes = 1, /* Number of color planes supported */ +}; + +/* This is the standard, NuttX Plane information object */ + +static const struct lcd_planeinfo_s g_planeinfo = +{ + .putrun = ug2864hsweg01_putrun, /* Put a run into LCD memory */ + .getrun = ug2864hsweg01_getrun, /* Get a run from LCD memory */ + .buffer = (uint8_t*)g_runbuffer, /* Run scratch buffer */ + .bpp = UG2864HSWEG01_BPP, /* Bits-per-pixel */ +}; + +/* This is the OLED driver instance (only a single device is supported for now) */ + +static struct ug2864hsweg01_dev_s g_oleddev = +{ + .dev = + { + /* LCD Configuration */ + + .getvideoinfo = ug2864hsweg01_getvideoinfo, + .getplaneinfo = ug2864hsweg01_getplaneinfo, + + /* LCD RGB Mapping -- Not supported */ + /* Cursor Controls -- Not supported */ + + /* LCD Specific Controls */ + + .getpower = ug2864hsweg01_getpower, + .setpower = ug2864hsweg01_setpower, + .getcontrast = ug2864hsweg01_getcontrast, + .setcontrast = ug2864hsweg01_setcontrast, + }, +}; + +/************************************************************************************** + * Private Functions + **************************************************************************************/ + +/************************************************************************************** + * Name: ug2864hsweg01_configspi + * + * Description: + * Configure the SPI for use with the UG-2864HSWEG01 + * + * Input Parameters: + * spi - Reference to the SPI driver structure + * + * Returned Value: + * None + * + * Assumptions: + * + **************************************************************************************/ + +#ifdef CONFIG_SPI_OWNBUS +static inline void ug2864hsweg01_configspi(FAR struct spi_dev_s *spi) +{ + lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n", + CONFIG_UG2864HSWEG01_SPIMODE, CONFIG_UG2864HSWEG01_FREQUENCY); + + /* Configure SPI for the UG-2864HSWEG01. But only if we own the SPI bus. Otherwise, + * don't bother because it might change. + */ + + SPI_SETMODE(spi, CONFIG_UG2864HSWEG01_SPIMODE); + SPI_SETBITS(spi, 8); + SPI_SETFREQUENCY(spi, CONFIG_UG2864HSWEG01_FREQUENCY) +} +#endif + +/************************************************************************************** + * Name: ug2864hsweg01_lock + * + * Description: + * Select the SPI, locking and re-configuring if necessary + * + * Input Parameters: + * spi - Reference to the SPI driver structure + * + * Returned Value: + * None + * + * Assumptions: + * + **************************************************************************************/ + +#ifndef CONFIG_SPI_OWNBUS +static inline void ug2864hsweg01_lock(FAR struct spi_dev_s *spi) +{ + /* Lock the SPI bus if there are multiple devices competing for the SPI bus. */ + + SPI_LOCK(spi, true); + + /* Now make sure that the SPI bus is configured for the UG-2864HSWEG01 (it + * might have gotten configured for a different device while unlocked) + */ + + SPI_SETMODE(spi, CONFIG_UG2864HSWEG01_SPIMODE); + SPI_SETBITS(spi, 8); + SPI_SETFREQUENCY(spi, CONFIG_UG2864HSWEG01_FREQUENCY); +} +#endif + +/************************************************************************************** + * Name: ug2864hsweg01_unlock + * + * Description: + * De-select the SPI + * + * Input Parameters: + * spi - Reference to the SPI driver structure + * + * Returned Value: + * None + * + * Assumptions: + * + **************************************************************************************/ + +#ifndef CONFIG_SPI_OWNBUS +static inline void ug2864hsweg01_unlock(FAR struct spi_dev_s *spi) +{ + /* De-select UG-2864HSWEG01 chip and relinquish the SPI bus. */ + + SPI_LOCK(spi, false); +} +#endif + +/************************************************************************************** + * Name: ug2864hsweg01_putrun + * + * Description: + * This method can be used to write a partial raster line to the LCD. + * + * Input Parameters: + * row - Starting row to write to (range: 0 <= row < yres) + * col - Starting column to write to (range: 0 <= col <= xres-npixels) + * buffer - The buffer containing the run to be written to the LCD + * npixels - The number of pixels to write to the LCD + * (range: 0 < npixels <= xres-col) + * + **************************************************************************************/ + +#if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) +static int ug2864hsweg01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, + size_t npixels) +{ + /* Because of this line of code, we will only be able to support a single UG device */ + + FAR struct ug2864hsweg01_dev_s *priv = (FAR struct ug2864hsweg01_dev_s *)&g_oleddev; + FAR uint8_t *fbptr; + FAR uint8_t *ptr; + uint8_t devcol; + uint8_t fbmask; + uint8_t page; + uint8_t usrmask; + int pixlen; + uint8_t i; + + lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels); + DEBUGASSERT(buffer); + + /* Clip the run to the display */ + + pixlen = npixels; + if ((unsigned int)col + (unsigned int)pixlen > (unsigned int)UG2864HSWEG01_XRES) + { + pixlen = (int)UG2864HSWEG01_XRES - (int)col; + } + + /* Verify that some portion of the run remains on the display */ + + if (pixlen <= 0 || row > UG2864HSWEG01_YRES) + { + return OK; + } + + /* Perform coordinate conversion for reverse landscape mode */ + +#ifdef CONFIG_LCD_RLANDSCAPE + row = (UG2864HSWEG01_YRES-1) - row; + col = (UG2864HSWEG01_XRES-1) - col; +#endif + + /* Get the page number. The range of 64 lines is divided up into eight + * pages of 8 lines each. + */ + + page = row >> 3; + + /* Update the shadow frame buffer memory. First determine the pixel + * position in the frame buffer memory. Pixels are organized like + * this: + * + * --------+---+---+---+---+-...-+-----+ + * Segment | 0 | 1 | 2 | 3 | ... | 131 | + * --------+---+---+---+---+-...-+-----+ + * D0 | | X | | | | | + * D1 | | X | | | | | + * D2 | | X | | | | | + * D3 | | X | | | | | + * D4 | | X | | | | | + * D5 | | X | | | | | + * D6 | | X | | | | | + * D7 | | X | | | | | + * --------+---+---+---+---+-...-+-----+ + * + * So, in order to draw a white, horizontal line, at row 45. we + * would have to modify all of the bytes in page 45/8 = 5. We + * would have to set bit 45%8 = 5 in every byte in the page. + */ + + fbmask = 1 << (row & 7); + fbptr = &priv->fb[page * UG2864HSWEG01_XRES + col]; +#ifdef CONFIG_LCD_RLANDSCAPE + ptr = fbptr + pixlen - 1; +#else + ptr = fbptr; +#endif +#ifdef CONFIG_NX_PACKEDMSFIRST + usrmask = MS_BIT; +#else + usrmask = LS_BIT; +#endif + + for (i = 0; i < pixlen; i++) + { + /* Set or clear the corresponding bit */ + +#ifdef CONFIG_LCD_RLANDSCAPE + if ((*buffer & usrmask) != 0) + { + *ptr-- |= fbmask; + } + else + { + *ptr-- &= ~fbmask; + } +#else + if ((*buffer & usrmask) != 0) + { + *ptr++ |= fbmask; + } + else + { + *ptr++ &= ~fbmask; + } +#endif + + /* Inc/Decrement to the next source pixel */ + +#ifdef CONFIG_NX_PACKEDMSFIRST + if (usrmask == LS_BIT) + { + buffer++; + usrmask = MS_BIT; + } + else + { + usrmask >>= 1; + } +#else + if (usrmask == MS_BIT) + { + buffer++; + usrmask = LS_BIT; + } + else + { + usrmask <<= 1; + } +#endif + } + + /* Offset the column position to account for smaller horizontal + * display range. + */ + + devcol = col + UG2864HSWEG01_DEV_XOFFSET; + + /* Lock and select device */ + + ug2864hsweg01_lock(priv->spi); + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, true); + + /* Select command transfer */ + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, true); + + /* Set the starting position for the run */ + /* Set the column address to the XOFFSET value */ + + SPI_SEND(priv->spi, SSD1306_SETCOLL(devcol & 0x0f)); + SPI_SEND(priv->spi, SSD1306_SETCOLH(devcol >> 4)); + + /* Set the page address */ + + SPI_SEND(priv->spi, SSD1306_PAGEADDR(page)); + + /* Select data transfer */ + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, false); + + /* Then transfer all of the data */ + + (void)SPI_SNDBLOCK(priv->spi, fbptr, pixlen); + + /* De-select and unlock the device */ + + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, false); + ug2864hsweg01_unlock(priv->spi); + return OK; +} +#else +# error "Configuration not implemented" +#endif + +/************************************************************************************** + * Name: ug2864hsweg01_getrun + * + * Description: + * This method can be used to read a partial raster line from the LCD: + * + * Description: + * This method can be used to write a partial raster line to the LCD. + * + * row - Starting row to read from (range: 0 <= row < yres) + * col - Starting column to read read (range: 0 <= col <= xres-npixels) + * buffer - The buffer in which to return the run read from the LCD + * npixels - The number of pixels to read from the LCD + * (range: 0 < npixels <= xres-col) + * + **************************************************************************************/ + +#if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) +static int ug2864hsweg01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, + size_t npixels) +{ + /* Because of this line of code, we will only be able to support a single UG device */ + + FAR struct ug2864hsweg01_dev_s *priv = &g_oleddev; + FAR uint8_t *fbptr; + uint8_t page; + uint8_t fbmask; + uint8_t usrmask; + int pixlen; + uint8_t i; + + lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels); + DEBUGASSERT(buffer); + + /* Clip the run to the display */ + + pixlen = npixels; + if ((unsigned int)col + (unsigned int)pixlen > (unsigned int)UG2864HSWEG01_XRES) + { + pixlen = (int)UG2864HSWEG01_XRES - (int)col; + } + + /* Verify that some portion of the run is actually the display */ + + if (pixlen <= 0 || row > UG2864HSWEG01_YRES) + { + return -EINVAL; + } + + /* Perform coordinate conversion for reverse landscape mode */ + +#ifdef CONFIG_LCD_RLANDSCAPE + row = (UG2864HSWEG01_YRES-1) - row; + col = (UG2864HSWEG01_XRES-1) - col; +#endif + + /* Then transfer the display data from the shadow frame buffer memory */ + /* Get the page number. The range of 64 lines is divided up into eight + * pages of 8 lines each. + */ + + page = row >> 3; + + /* Update the shadow frame buffer memory. First determine the pixel + * position in the frame buffer memory. Pixels are organized like + * this: + * + * --------+---+---+---+---+-...-+-----+ + * Segment | 0 | 1 | 2 | 3 | ... | 131 | + * --------+---+---+---+---+-...-+-----+ + * D0 | | X | | | | | + * D1 | | X | | | | | + * D2 | | X | | | | | + * D3 | | X | | | | | + * D4 | | X | | | | | + * D5 | | X | | | | | + * D6 | | X | | | | | + * D7 | | X | | | | | + * --------+---+---+---+---+-...-+-----+ + * + * So, in order to draw a white, horizontal line, at row 45. we + * would have to modify all of the bytes in page 45/8 = 5. We + * would have to set bit 45%8 = 5 in every byte in the page. + */ + + fbmask = 1 << (row & 7); +#ifdef CONFIG_LCD_RLANDSCAPE + fbptr = &priv->fb[page * (UG2864HSWEG01_XRES-1) + col + pixlen]; +#else + fbptr = &priv->fb[page * UG2864HSWEG01_XRES + col]; +#endif +#ifdef CONFIG_NX_PACKEDMSFIRST + usrmask = MS_BIT; +#else + usrmask = LS_BIT; +#endif + + *buffer = 0; + for (i = 0; i < pixlen; i++) + { + /* Set or clear the corresponding bit */ + +#ifdef CONFIG_LCD_RLANDSCAPE + uint8_t byte = *fbptr--; +#else + uint8_t byte = *fbptr++; +#endif + if ((byte & fbmask) != 0) + { + *buffer |= usrmask; + } + + /* Inc/Decrement to the next destination pixel. Hmmmm. It looks like + * this logic could write past the end of the user buffer. Revisit + * this! + */ + +#ifdef CONFIG_NX_PACKEDMSFIRST + if (usrmask == LS_BIT) + { + buffer++; + *buffer = 0; + usrmask = MS_BIT; + } + else + { + usrmask >>= 1; + } +#else + if (usrmask == MS_BIT) + { + buffer++; + *buffer = 0; + usrmask = LS_BIT; + } + else + { + usrmask <<= 1; + } +#endif + } + + return OK; +} +#else +# error "Configuration not implemented" +#endif + +/************************************************************************************** + * Name: ug2864hsweg01_getvideoinfo + * + * Description: + * Get information about the LCD video controller configuration. + * + **************************************************************************************/ + +static int ug2864hsweg01_getvideoinfo(FAR struct lcd_dev_s *dev, + FAR struct fb_videoinfo_s *vinfo) +{ + DEBUGASSERT(dev && vinfo); + lcdvdbg("fmt: %d xres: %d yres: %d nplanes: %d\n", + g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); + return OK; +} + +/************************************************************************************** + * Name: ug2864hsweg01_getplaneinfo + * + * Description: + * Get information about the configuration of each LCD color plane. + * + **************************************************************************************/ + +static int ug2864hsweg01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) +{ + DEBUGASSERT(pinfo && planeno == 0); + lcdvdbg("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); + memcpy(pinfo, &g_planeinfo, sizeof(struct lcd_planeinfo_s)); + return OK; +} + +/************************************************************************************** + * Name: ug2864hsweg01_getpower + * + * Description: + * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on. On + * backlit LCDs, this setting may correspond to the backlight setting. + * + **************************************************************************************/ + +static int ug2864hsweg01_getpower(FAR struct lcd_dev_s *dev) +{ + FAR struct ug2864hsweg01_dev_s *priv = (FAR struct ug2864hsweg01_dev_s *)dev; + DEBUGASSERT(priv); + + lcdvdbg("power: %s\n", priv->on ? "ON" : "OFF"); + return priv->on ? CONFIG_LCD_MAXPOWER : 0; +} + +/************************************************************************************** + * Name: ug2864hsweg01_setpower + * + * Description: + * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On + * backlit LCDs, this setting may correspond to the backlight setting. + * + **************************************************************************************/ + +static int ug2864hsweg01_setpower(struct lcd_dev_s *dev, int power) +{ + struct ug2864hsweg01_dev_s *priv = (struct ug2864hsweg01_dev_s *)dev; + DEBUGASSERT(priv && (unsigned)power <= CONFIG_LCD_MAXPOWER && priv->spi); + + lcdvdbg("power: %d [%d]\n", power, priv->on ? CONFIG_LCD_MAXPOWER : 0); + + /* Lock and select device */ + + ug2864hsweg01_lock(priv->spi); + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, true); + + if (power <= 0) + { + /* Turn the display off */ + + (void)SPI_SEND(priv->spi, SSD1306_DISPOFF); + priv->on = false; + } + else + { + /* Turn the display on */ + + (void)SPI_SEND(priv->spi, SSD1306_DISPON); /* Display on, dim mode */ + priv->on = true; + } + + /* De-select and unlock the device */ + + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, false); + ug2864hsweg01_unlock(priv->spi); + return OK; +} + +/************************************************************************************** + * Name: ug2864hsweg01_getcontrast + * + * Description: + * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). + * + **************************************************************************************/ + +static int ug2864hsweg01_getcontrast(struct lcd_dev_s *dev) +{ + struct ug2864hsweg01_dev_s *priv = (struct ug2864hsweg01_dev_s *)dev; + DEBUGASSERT(priv); + + lcdvdbg("contrast: %d\n", priv->contrast); + return priv->contrast; +} + +/************************************************************************************** + * Name: ug2864hsweg01_setcontrast + * + * Description: + * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). + * + **************************************************************************************/ + +static int ug2864hsweg01_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) +{ + struct ug2864hsweg01_dev_s *priv = (struct ug2864hsweg01_dev_s *)dev; + unsigned int scaled; + + lcdvdbg("contrast: %d\n", contrast); + DEBUGASSERT(priv); + + /* Verify the contrast value */ + +#ifdef CONFIG_DEBUG + if (contrast > CONFIG_LCD_MAXCONTRAST) + { + return -EINVAL; + } +#endif + + /* Scale contrast: newcontrast = 255 * contrast / CONFIG_LCD_MAXCONTRAST + * Where contrast is in the range {1,255} + */ + +#if CONFIG_LCD_MAXCONTRAST != 255 + scaled = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST; +#else + scaled = contrast; +#endif + + /* Lock and select device */ + + ug2864hsweg01_lock(priv->spi); + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, true); + + /* Select command transfer */ + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, true); + + /* Set the contrast */ + + (void)SPI_SEND(priv->spi, SSD1306_CONTRAST_MODE); /* Set contrast control register */ + (void)SPI_SEND(priv->spi, SSD1306_CONTRAST(scaled)); /* Data 1: Set 1 of 256 contrast steps */ + priv->contrast = contrast; + + /* De-select and unlock the device */ + + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, false); + ug2864hsweg01_unlock(priv->spi); + return OK; +} + +/************************************************************************************** + * Public Functions + **************************************************************************************/ + +/************************************************************************************** + * Name: ug2864hsweg01_initialize + * + * Description: + * Initialize the UG-2864HSWEG01 video hardware. The initial state of the + * OLED is fully initialized, display memory cleared, and the OLED ready + * to use, but with the power setting at 0 (full off == sleep mode). + * + * Input Parameters: + * + * spi - A reference to the SPI driver instance. + * devno - A value in the range of 0 through CONFIG_UG2864HSWEG01_NINTERFACES-1. + * This allows support for multiple OLED devices. + * + * Returned Value: + * + * On success, this function returns a reference to the LCD object for + * the specified OLED. NULL is returned on any failure. + * + **************************************************************************************/ + +FAR struct lcd_dev_s *ug2864hsweg01_initialize(FAR struct spi_dev_s *spi, unsigned int devno) +{ + FAR struct ug2864hsweg01_dev_s *priv = &g_oleddev; + + lcdvdbg("Initializing\n"); + DEBUGASSERT(spi && devno == 0); + + /* Save the reference to the SPI device */ + + priv->spi = spi; + + /* Configure the SPI */ + + ug2864hsweg01_configspi(spi) + + /* Lock and select device */ + + ug2864hsweg01_lock(priv->spi); + SPI_SELECT(spi, SPIDEV_DISPLAY, true); + + /* Select command transfer */ + + SPI_CMDDATA(spi, SPIDEV_DISPLAY, true); + + /* Configure the device */ + + SPI_SEND(spi, SSD1306_DISPOFF); /* Display off 0xAE*/ + SPI_SEND(spi, SSD1306_SETCOLL(0)); /* Set lower column address 0x00 */ + SPI_SEND(spi, SSD1306_SETCOLH(0)); /* Set higher column address 0x10 */ + SPI_SEND(spi, SSD1306_STARTLINE(0)); /* Set display start line 0x40*/ + SPI_SEND(spi, SSD1306_PAGEADDR(0)); /* Set page address [¿ÉºöÂÔ] */ + SPI_SEND(spi, SSD1306_CONTRAST_MODE); /* Contrast control 0x81*/ + SPI_SEND(spi ,SSD1306_CONTRAST(UG2864HSWEG01_CONTRAST)); /* Default contrast 0xCF */ + SPI_SEND(spi, SSD1306_REMAPPLEFT); /* Set segment remap left 95 to 0 | 0xA1*/ + SPI_SEND(spi, SSD1306_EDISPOFF); /* Normal display :off 0xA4 [¶à³öµÄÒ»ÐÐ] */ + SPI_SEND(spi, SSD1306_NORMAL); /* Normal (un-reversed) display mode 0xA6 */ + SPI_SEND(spi, SSD1306_MRATIO_MODE); /* Multiplex ratio 0xA8*/ + SPI_SEND(spi, SSD1306_MRATIO(0x3f)); /* Duty = 1/64 */ + SPI_SEND(spi, SSD1306_SCANTOCOM0); /* Com scan direction: Scan from COM[n-1] to COM[0] [¿ÉºöÂÔ] */ + SPI_SEND(spi, SSD1306_DISPOFFS_MODE); /* Set display offset 0xD3 */ + SPI_SEND(spi, SSD1306_DISPOFFS(0)); + SPI_SEND(spi, SSD1306_CLKDIV_SET); /* Set clock divider 0xD5*/ + SPI_SEND(spi, SSD1306_CLKDIV(8,0)); /* 0x80 ? ¼ì²é ĬÈÏ0,0*/ + + SPI_SEND(spi, SSD1306_CHRGPER_SET); /* ++Set pre-charge period 0xD9*/ + SPI_SEND(spi, SSD1306_CHRGPER(0x0f,1)); /* 0xf1 or 0x22£¨Ôöǿģʽ£¿£© */ + + SPI_SEND(spi, SSD1306_CMNPAD_CONFIG); /* Set common pads / set com pins hardware configuration 0xDA*/ + SPI_SEND(spi, SSD1306_CMNPAD(0x12)); /* 0x12 ? ¼ì²é ĬÈÏ 0x10 */ + + SPI_SEND(spi, SSD1306_VCOM_SET); /* set vcomh 0xDB*/ + SPI_SEND(spi, SSD1306_VCOM(0x40)); + + SPI_SEND(spi, SSD1306_CHRPUMP_SET); /* ++Set Charge Pump enable/disable 0x8D Ôö¼ÓµÄ*/ + SPI_SEND(spi, SSD1306_CHRPUMP_ON); /* 0x14 */ + + //SPI_SEND(spi, SSD1306_DCDC_MODE); /* DC/DC control mode: on */ + //SPI_SEND(spi, SSD1306_DCDC_ON); + + SPI_SEND(spi, SSD1306_DISPON); /* display ON 0xAF */ + + /* De-select and unlock the device */ + + SPI_SELECT(spi, SPIDEV_DISPLAY, false); + ug2864hsweg01_unlock(priv->spi); + + /* Clear the display */ + + up_mdelay(100); + ug2864hsweg01_fill(&priv->dev, UG_Y1_BLACK); + return &priv->dev; +} + +/************************************************************************************** + * Name: ug2864hsweg01_fill + * + * Description: + * This non-standard method can be used to clear the entire display by writing one + * color to the display. This is much faster than writing a series of runs. + * + * Input Parameters: + * priv - Reference to private driver structure + * + * Assumptions: + * Caller has selected the OLED section. + * + **************************************************************************************/ + +void ug2864hsweg01_fill(FAR struct lcd_dev_s *dev, uint8_t color) +{ + FAR struct ug2864hsweg01_dev_s *priv = &g_oleddev; + unsigned int page; + + /* Make an 8-bit version of the selected color */ + + if (color & 1) + { + color = 0xff; + } + else + { + color = 0; + } + + /* Initialize the framebuffer */ + + memset(priv->fb, color, UG2864HSWEG01_FBSIZE); + + /* Lock and select device */ + + ug2864hsweg01_lock(priv->spi); + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, true); + + /* Visit each page */ + + for (page = 0; page < UG2864HSWEG01_DEV_PAGES; page++) + { + /* Select command transfer */ + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, true); + + /* Set the column address to the XOFFSET value */ + + SPI_SEND(priv->spi, SSD1306_SETCOLL(UG2864HSWEG01_DEV_XOFFSET)); + SPI_SEND(priv->spi, SSD1306_SETCOLH(0)); + + /* Set the page address */ + + SPI_SEND(priv->spi, SSD1306_PAGEADDR(page)); + + /* Select data transfer */ + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, false); + + /* Transfer one page of the selected color */ + + (void)SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864HSWEG01_XRES], + UG2864HSWEG01_XRES); + } + + /* De-select and unlock the device */ + + SPI_SELECT(priv->spi, SPIDEV_DISPLAY, false); + ug2864hsweg01_unlock(priv->spi); +} + +#endif /* CONFIG_LCD_UG2864HSWEG01 */ diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index e0c4680eb..5022793ca 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -1027,6 +1027,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) /* Loop here until the device is disconnected */ uvdbg("Entering poll loop\n"); + while (!priv->disconnected) { /* Make sure that we have exclusive access to the private data @@ -1169,10 +1170,10 @@ static int usbhost_kbdpoll(int argc, char *argv[]) #endif } - /* Did we just transition from no data available to data available? */ + /* Is there data available? */ newstate = (priv->headndx == priv->tailndx); - if (empty && !newstate) + if (!newstate) { /* Yes.. Is there a thread waiting for keyboard data now? */ @@ -1184,9 +1185,15 @@ static int usbhost_kbdpoll(int argc, char *argv[]) priv->waiting = false; } - /* And wake up any threads waiting for the POLLIN event */ + /* Did we just transition from no data available to data + * available? If so, wake up any threads waiting for the + * POLLIN event. + */ - usbhost_pollnotify(priv); + if (empty) + { + usbhost_pollnotify(priv); + } } empty = newstate; @@ -2146,6 +2153,7 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len /* Wait for data to be available */ uvdbg("Waiting...\n"); + priv->waiting = true; usbhost_givesem(&priv->exclsem); usbhost_takesem(&priv->waitsem); diff --git a/nuttx/include/nuttx/lcd/ug-2864hsweg01.h b/nuttx/include/nuttx/lcd/ug-2864hsweg01.h new file mode 100644 index 000000000..bbefd39be --- /dev/null +++ b/nuttx/include/nuttx/lcd/ug-2864hsweg01.h @@ -0,0 +1,245 @@ +/************************************************************************************** + * include/nuttx/lcd/ug-2864hsweg01.h + * Driver for Univision UG-2864HSWEG01 OLED display (wih SSD1306 controller) in SPI + * mode + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * References: + * 1. Product Specification (Preliminary), Part Name: OEL Display Module, Part ID: + * UG-2864HSWEG01, Doc No: SAS1-9046-B, Univision Technology Inc. + * 2. SSD1306, 128 X 64 Dot Matrix OLED/PLED, Preliminary Segment/Common Driver with + * Controller, Solomon Systech + * + * 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_UG_8264HSWEG01_H +#define __INCLUDE_NUTTX_UG_8264HSWEG01_H + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_LCD_UG2864HSWEG01 + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ +/* Configuration **********************************************************************/ +/* UG-2864HSWEG01 Configuration Settings: + * + * CONFIG_UG2864HSWEG01_SPIMODE - Controls the SPI mode + * CONFIG_UG2864HSWEG01_FREQUENCY - Define to use a different bus frequency + * CONFIG_UG2864HSWEG01_NINTERFACES - Specifies the number of physical UG-2864HSWEG01 + * devices that will be supported. + * + * Required LCD driver settings: + * + * CONFIG_LCD_UG28HSWEG01 - Enable UG-2864HSWEG01 support + * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + * CONFIG_LCD_MAXPOWER must be 1 + * + * Option LCD driver settings: + * CONFIG_LCD_LANDSCAPE, CONFIG_LCD_PORTRAIT, CONFIG_LCD_RLANDSCAPE, and + * CONFIG_LCD_RPORTRAIT - Display orientation. + * + * Required SPI driver settings: + * CONFIG_SPI_CMDDATA - Include support for cmd/data selection. + */ + +/* SPI Interface + * + * "The serial interface consists of serial clock SCL, serial data SI, A0 and + * CS . SI is shifted into an 8-bit shift register on every rising edge of + * SCL in the order of D7, D6, … and D0. A0 is sampled on every eighth clock + * and the data byte in the shift register is written to the display data RAM + * or command register in the same clock." + * + * MODE 3: + * Clock polarity: High (CPOL=1) + * Clock phase: Sample on trailing (rising edge) (CPHA 1) + */ + +#ifndef CONFIG_UG2864HSWEG01_SPIMODE +# define CONFIG_UG2864HSWEG01_SPIMODE SPIDEV_MODE3 +#endif + +/* "This module determines whether the input data is interpreted as data or + * command. When A0 = “H”, the inputs at D7 - D0 are interpreted as data and be + * written to display RAM. When A0 = “L”, the inputs at D7 - D0 are interpreted + * as command, they will be decoded and be written to the corresponding command + * registers. + */ + +#ifndef CONFIG_SPI_CMDDATA +# error "CONFIG_SPI_CMDDATA must be defined in your NuttX configuration" +#endif + +/* CONFIG_UG2864HSWEG01_NINTERFACES determines the number of physical interfaces + * that will be supported. + */ + +#ifndef CONFIG_UG2864HSWEG01_NINTERFACES +# define CONFIG_UG2864HSWEG01_NINTERFACES 1 +#endif + +/* Check contrast selection */ + +#if !defined(CONFIG_LCD_MAXCONTRAST) +# define CONFIG_LCD_MAXCONTRAST 255 +#endif + +#if CONFIG_LCD_MAXCONTRAST <= 0|| CONFIG_LCD_MAXCONTRAST > 255 +# error "CONFIG_LCD_MAXCONTRAST exceeds supported maximum" +#endif + +#if CONFIG_LCD_MAXCONTRAST < 255 +# warning "Optimal setting of CONFIG_LCD_MAXCONTRAST is 255" +#endif + +/* Check power setting */ + +#if !defined(CONFIG_LCD_MAXPOWER) +# define CONFIG_LCD_MAXPOWER 1 +#endif + +#if CONFIG_LCD_MAXPOWER != 1 +# warning "CONFIG_LCD_MAXPOWER exceeds supported maximum" +# undef CONFIG_LCD_MAXPOWER +# define CONFIG_LCD_MAXPOWER 1 +#endif + +/* Color is 1bpp monochrome with leftmost column contained in bits 0 */ + +#ifdef CONFIG_NX_DISABLE_1BPP +# warning "1 bit-per-pixel support needed" +#endif + +/* Orientation */ + +#if defined(CONFIG_LCD_LANDSCAPE) +# undef CONFIG_LCD_PORTRAIT +# undef CONFIG_LCD_RLANDSCAPE +# undef CONFIG_LCD_RPORTRAIT +#elif defined(CONFIG_LCD_PORTRAIT) +# undef CONFIG_LCD_LANDSCAPE +# undef CONFIG_LCD_RLANDSCAPE +# undef CONFIG_LCD_RPORTRAIT +#elif defined(CONFIG_LCD_RLANDSCAPE) +# undef CONFIG_LCD_LANDSCAPE +# undef CONFIG_LCD_PORTRAIT +# undef CONFIG_LCD_RPORTRAIT +#elif defined(CONFIG_LCD_RPORTRAIT) +# undef CONFIG_LCD_LANDSCAPE +# undef CONFIG_LCD_PORTRAIT +# undef CONFIG_LCD_RLANDSCAPE +#else +# define CONFIG_LCD_LANDSCAPE 1 +# warning "Assuming landscape orientation" +#endif + +/* Some important "colors" */ + +#define UG_Y1_BLACK 0 +#define UG_Y1_WHITE 1 + +/************************************************************************************** + * Public Types + **************************************************************************************/ + +/************************************************************************************** + * Public Data + **************************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************************************************************************** + * Public Function Prototypes + **************************************************************************************/ + +/************************************************************************************** + * Name: ug2864hsweg01_initialize + * + * Description: + * Initialize the UG-2864HSWEG01 video hardware. The initial state of the + * OLED is fully initialized, display memory cleared, and the OLED ready + * to use, but with the power setting at 0 (full off == sleep mode). + * + * Input Parameters: + * + * spi - A reference to the SPI driver instance. + * devno - A value in the range of 0 through CONFIG_UG2864HSWEG01_NINTERFACES-1. + * This allows support for multiple OLED devices. + * + * Returned Value: + * + * On success, this function returns a reference to the LCD object for + * the specified OLED. NULL is returned on any failure. + * + **************************************************************************************/ + +struct lcd_dev_s; /* See include/nuttx/lcd/lcd.h */ +struct spi_dev_s; /* See include/nuttx/spi.h */ +FAR struct lcd_dev_s *ug2864hsweg01_initialize(FAR struct spi_dev_s *spi, + unsigned int devno); + +/************************************************************************************************ + * Name: ug2864hsweg01_fill + * + * Description: + * This non-standard method can be used to clear the entire display by writing one + * color to the display. This is much faster than writing a series of runs. + * + * Input Parameters: + * priv - Reference to private driver structure + * + * Assumptions: + * Caller has selected the OLED section. + * + **************************************************************************************/ + +void ug2864hsweg01_fill(FAR struct lcd_dev_s *dev, uint8_t color); + +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LCD_UG2864HSWEG01 */ +#endif /* __INCLUDE_NUTTX_UG_8264HSWEG01_H */ -- cgit v1.2.3 From 88bccb641eccf8ca1a91ab0583976a211deb1ed5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 26 Dec 2012 21:37:50 +0000 Subject: Verified USB HID KBD driver encoding of special characters; apps/examples/hidkbd now decodes encoded keyboar characters. git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5463 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 + apps/examples/README.txt | 18 +++- apps/examples/hidkbd/Kconfig | 31 +++++++ apps/examples/hidkbd/hidkbd_main.c | 106 ++++++++++++++++++++++- nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig | 20 ++++- nuttx/drivers/usbhost/Kconfig | 4 +- nuttx/drivers/usbhost/usbhost_hidkbd.c | 34 +++++--- nuttx/include/nuttx/input/kbd_codec.h | 5 +- nuttx/libc/Kconfig | 28 ++++++ nuttx/libc/math/Kconfig | 2 +- nuttx/libc/misc/Make.defs | 8 +- 11 files changed, 234 insertions(+), 24 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index ea1b247f5..d156b1065 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -453,4 +453,6 @@ in place early in the dependency generation phase to avoid warnings. It is not important if they are only stubbed out header files at this build phase. + * apps/examples/hidbkd: Now supports decoding of encoded special keys + if CONFIG_EXAMPLES_HIDKBD_ENCODED is defined. diff --git a/apps/examples/README.txt b/apps/examples/README.txt index e40a63be9..7bfba721a 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -540,9 +540,21 @@ examples/hidkbd This is a simple test to debug/verify the USB host HID keyboard class driver. - CONFIG_EXAMPLES_HIDKBD_DEFPRIO - Priority of "waiter" thread. - CONFIG_EXAMPLES_HIDKBD_STACKSIZE - Stacksize of "waiter" thread. - + CONFIG_EXAMPLES_HIDKBD_DEFPRIO - Priority of "waiter" thread. Default: + 50 + CONFIG_EXAMPLES_HIDKBD_STACKSIZE - Stacksize of "waiter" thread. Default + 1024 + CONFIG_EXAMPLES_HIDKBD_DEVNAME - Name of keyboard device to be used. + Default: "/dev/kbda" + CONFIG_EXAMPLES_HIDKBD_ENCODED - Decode special key press events in the + user buffer. In this case, the example coded will use the interfaces + defined in include/nuttx/input/kbd_codec.h to decode the returned + keyboard data. These special keys include such things as up/down + arrows, home and end keys, etc. If this not defined, only 7-bit print- + able and control ASCII characters will be provided to the user. + Requires CONFIG_HIDKBD_ENCODED && CONFIG_LIB_KBDCODEC + +endif examples/igmp ^^^^^^^^^^^^^ diff --git a/apps/examples/hidkbd/Kconfig b/apps/examples/hidkbd/Kconfig index 503d9d9d9..81f817ef9 100644 --- a/apps/examples/hidkbd/Kconfig +++ b/apps/examples/hidkbd/Kconfig @@ -10,4 +10,35 @@ config EXAMPLES_HIDKBD Enable the USB HID keyboard example if EXAMPLES_HIDKBD + +config EXAMPLES_HIDKBD_DEFPRIO + int "Waiter Thread Priority" + default 50 + ---help--- + Priority of "waiter" thread. Default: 50 + +config EXAMPLES_HIDKBD_STACKSIZE + int "Waiter Thread Stack Size" + default 1024 + ---help--- + Stacksize of "waiter" thread. Default 1024 + +config EXAMPLES_HIDKBD_DEVNAME + string "Keyboard Device Name" + default "/dev/kbda" + ---help--- + Name of keyboard device to be used. Default: "/dev/kbda" + +config EXAMPLES_HIDKBD_ENCODED + bool "Encode Special Keys" + default y + depends on HIDKBD_ENCODED && LIB_KBDCODEC + ---help--- + Decode special key press events in the user buffer. In this case, + the example coded will use the interfaces defined in + include/nuttx/input/kbd_codec.h to decode the returned keyboard + data. These special keys include such things as up/down arrows, + home and end keys, etc. If this not defined, only 7-bit print-able + and control ASCII characters will be provided to the user. + endif diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index 8c9f6fa95..8a632bab7 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -46,10 +46,18 @@ #include #include #include +#include +#include +#include #include #include +#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED +# include +# include +#endif + /**************************************************************************** * Definitions ****************************************************************************/ @@ -83,10 +91,23 @@ # define CONFIG_EXAMPLES_HIDKBD_DEVNAME "/dev/kbda" #endif +#if !defined(CONFIG_HIDKBD_ENCODED) || !defined(CONFIG_LIB_KBDCODEC) +# undef CONFIG_EXAMPLES_HIDKBD_ENCODED +#endif + /**************************************************************************** * Private Types ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED +struct hidbkd_instream_s +{ + struct lib_instream_s stream; + FAR char *buffer; + ssize_t nbytes; +}; +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -98,9 +119,84 @@ static struct usbhost_driver_s *g_drvr; ****************************************************************************/ /**************************************************************************** - * Public Functions + * Name: hidkbd_getstream + * + * Description: + * Get one character from the keyboard. + * ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED +static int hidkbd_getstream(FAR struct lib_instream_s *this) +{ + FAR struct hidbkd_instream_s *kbdstream = (FAR struct hidbkd_instream_s *)this; + + DEBUGASSERT(kbdstream && kbdstream->buffer); + if (kbdstream->nbytes > 0) + { + kbdstream->nbytes--; + kbdstream->stream.nget++; + return (int)*kbdstream->buffer++; + } + + return EOF; +} +#endif + +/**************************************************************************** + * Name: hidkbd_decode + * + * Description: + * Decode encoded keyboard input + * + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED +static void hidkbd_decode(FAR char *buffer, ssize_t nbytes) +{ + struct hidbkd_instream_s kbdstream; + struct kbd_getstate_s state; + uint8_t ch; + int ret; + + /* Initialize */ + + memset(&state, 0, sizeof(struct kbd_getstate_s)); + kbdstream.stream.get = hidkbd_getstream; + kbdstream.stream.nget = 0; + kbdstream.buffer = buffer; + kbdstream.nbytes = nbytes; + + /* Loop until all of the bytes have been consumed. We implicitly assume + * that the the escaped sequences do not cross buffer boundaries. That + * might be true if the read buffer were small or the data rates high. + */ + + for (;;) + { + /* Decode the next thing from the buffer */ + + ret = kbd_get((FAR struct lib_instream_s *)&kbdstream, &state, &ch); + if (ret == KBD_ERROR) + { + break; + } + + /* Normal data? Or special key? */ + + if (ret == KBD_NORMAL) + { + printf("Data: %c [%02x]\n", isprint(ch) ? ch : '.', ch); + } + else + { + DEBUGASSERT(ret == KBD_SPECIAL); + printf("Special: %d\n", ch); + } + } +} +#endif + /**************************************************************************** * Name: hidkbd_waiter * @@ -140,6 +236,10 @@ static int hidkbd_waiter(int argc, char *argv[]) return 0; } +/**************************************************************************** + * Public Functions + ****************************************************************************/ + /**************************************************************************** * Name: hidkbd_main ****************************************************************************/ @@ -217,7 +317,11 @@ int hidkbd_main(int argc, char *argv[]) { /* On success, echo the buffer to stdout */ +#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED + hidkbd_decode(buffer, nbytes); +#else (void)write(1, buffer, nbytes); +#endif } } while (nbytes > 0); diff --git a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig index 78e411560..35a7bfc3d 100755 --- a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig @@ -316,7 +316,10 @@ CONFIG_DEV_NULL=y # CONFIG_WATCHDOG is not set # CONFIG_ANALOG is not set # CONFIG_BCH is not set -# CONFIG_INPUT is not set +CONFIG_INPUT=y +# CONFIG_INPUT_TSC2007 is not set +# CONFIG_INPUT_ADS7843E is not set +# CONFIG_INPUT_STMPE811 is not set # CONFIG_LCD is not set CONFIG_MMCSD=y CONFIG_MMCSD_NSLOTS=1 @@ -364,7 +367,7 @@ CONFIG_HIDKBD_STACKSIZE=1024 CONFIG_HIDKBD_BUFSIZE=64 CONFIG_HIDKBD_NPOLLWAITERS=2 # CONFIG_HIDKBD_RAWSCANCODES is not set -# CONFIG_HIDKBD_ENCODED is not set +CONFIG_HIDKBD_ENCODED=y # CONFIG_HIDKBD_ALLSCANCODES is not set # CONFIG_HIDKBD_NODEBOUNCE is not set # CONFIG_WIRELESS is not set @@ -425,6 +428,10 @@ CONFIG_MM_REGIONS=2 # # Library Routines # + +# +# Standard C Library Options +# CONFIG_STDIO_BUFFER_SIZE=256 CONFIG_STDIO_LINEBUFFER=y CONFIG_NUNGET_CHARS=2 @@ -443,6 +450,11 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_ARCH_ROMGETC is not set # CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set +# +# Non-standard Helper Functions +# +CONFIG_LIB_KBDCODEC=y + # # Basic CXX Support # @@ -473,6 +485,10 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_EXAMPLES_HELLOXX is not set # CONFIG_EXAMPLES_JSON is not set CONFIG_EXAMPLES_HIDKBD=y +CONFIG_EXAMPLES_HIDKBD_DEFPRIO=50 +CONFIG_EXAMPLES_HIDKBD_STACKSIZE=1024 +CONFIG_EXAMPLES_HIDKBD_DEVNAME="/dev/kbda" +CONFIG_EXAMPLES_HIDKBD_ENCODED=y # CONFIG_EXAMPLES_KEYPADTEST is not set # CONFIG_EXAMPLES_IGMP is not set # CONFIG_EXAMPLES_LCDRW is not set diff --git a/nuttx/drivers/usbhost/Kconfig b/nuttx/drivers/usbhost/Kconfig index de8469b41..531e94442 100644 --- a/nuttx/drivers/usbhost/Kconfig +++ b/nuttx/drivers/usbhost/Kconfig @@ -89,10 +89,10 @@ config HIDKBD_RAWSCANCODES config HIDKBD_ENCODED bool "Enocode Special Keys" default n - depends on !HIDKBD_RAWSCANCODES + depends on !HIDKBD_RAWSCANCODES && LIB_KBDCODEC ---help--- Encode special key press events in the user buffer. In this case, - the use end must decode the encoded special key values using the + the user end must decode the encoded special key values using the interfaces defined in include/nuttx/input/kbd_codec.h. These special keys include such things as up/down arrows, home and end keys, etc. If this not defined, only 7-bit print-able and control diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index 5022793ca..917ebfa3f 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -131,6 +131,14 @@ # endif #endif +/* We cant support encoding of special characters of unless the Keyboard + * CODEC is enabled. + */ + +#ifndef CONFIG_LIB_KBDCODEC +# undef CONFIG_HIDKBD_ENCODED +#endif + /* If we are using raw scancodes, then we cannot support encoding of * special characters either. */ @@ -398,11 +406,11 @@ static struct usbhost_state_s *g_priv; /* Data passed to thread */ /* The first and last scancode values with encode-able values */ -#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */ -#ifdef CONFIG_HIDKBD_ALLSCANCODES -# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */ +#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */ +#ifndef CONFIG_HIDKBD_ALLSCANCODES +# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */ #else -#define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */ +# define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */ #endif #define USBHID_NUMENCODINGS (LAST_ENCODING - FIRST_ENCODING + 1) @@ -874,10 +882,10 @@ static void usbhost_putbuffer(FAR struct usbhost_state_s *priv, #ifdef CONFIG_HIDKBD_ENCODED static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch) { - FAR struct usbhost_outstream_s *privstream = (FAR struct lib_outstream_s *)stream; + FAR struct usbhost_outstream_s *privstream = (FAR struct usbhost_outstream_s *)stream; DEBUGASSERT(privstream && privstream->priv); - usbhost_putbuffer(privstream->priv), (uint8_t)ch); + usbhost_putbuffer(privstream->priv, (uint8_t)ch); stream->nput++; } #endif @@ -945,7 +953,6 @@ static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier) static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, uint8_t scancode, uint8_t modifier) { - struct usbhost_outstream_s stream; uint8_t encoded; /* Check if the raw scancode is in a valid range */ @@ -954,7 +961,7 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, { /* Yes the value is within range */ - encoded = encoding(scancode - FIRST_ENCODING); + encoded = encoding[scancode - FIRST_ENCODING]; ivdbg(" scancode: %02x modifier: %02x encoded: %d\n", scancode, modifier, encoded); @@ -964,13 +971,14 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, /* And it does correspond to a special function key */ - usbstream->stream.put = usbhost_putstream; - usbstream->stream.nput = 0; - usbstream->priv = priv; + usbstream.stream.put = usbhost_putstream; + usbstream.stream.nput = 0; + usbstream.priv = priv; /* Add the special function value to the user buffer */ - kbd_putspecial((enum kbd_keycode_e)encoded, &usbstream); + kbd_putspecial((enum kbd_keycode_e)encoded, + (FAR struct lib_outstream_s *)&usbstream); } } } @@ -1156,7 +1164,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) #ifdef CONFIG_HIDKBD_ENCODED else { - usbhost_encodescancode(priv, rpt->key[i], rpt->modifier)); + usbhost_encodescancode(priv, rpt->key[i], rpt->modifier); } #endif } diff --git a/nuttx/include/nuttx/input/kbd_codec.h b/nuttx/include/nuttx/input/kbd_codec.h index d374ed8d3..0a3a54d2d 100644 --- a/nuttx/include/nuttx/input/kbd_codec.h +++ b/nuttx/include/nuttx/input/kbd_codec.h @@ -44,6 +44,8 @@ #include #include +#ifdef CONFIG_LIB_KBDCODEC + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -87,7 +89,7 @@ enum kbd_keycode_e KEYCODE_CUT, /* Cut */ KEYCODE_COPY, /* Copy */ KEYCODE_PASTE, /* Paste */ - KEYCODE_FIND , /* Find */ + KEYCODE_FIND, /* Find */ /* Selection codes */ @@ -294,5 +296,6 @@ int kbd_get(FAR struct lib_instream_s *stream, } #endif +#endif /* CONFIG_LIB_KBDCODEC */ #endif /* __INCLUDE_NUTTX_INPUT_KBD_CODEC_H */ diff --git a/nuttx/libc/Kconfig b/nuttx/libc/Kconfig index bd470be7f..a5ff7fd43 100644 --- a/nuttx/libc/Kconfig +++ b/nuttx/libc/Kconfig @@ -3,6 +3,8 @@ # see misc/tools/kconfig-language.txt. # +comment "Standard C Library Options" + config STDIO_BUFFER_SIZE int "C STDIO buffer size" default 64 @@ -273,3 +275,29 @@ config ARCH_BZERO of bzero(). endif + +comment "Non-standard Helper Functions" + +config LIB_KBDCODEC + bool "Keyboard CODEC" + default y + ---help--- + In NuttX, a keyboard/keypad driver is simply a character driver that + may have an (optional) encoding/decoding layer on the data returned + by the character driver. A keyboard may return simple text data + (alphabetic, numeric, and punctuaction) or control characters + (enter, control-C, etc.). We can think about this the normal + "in-band" keyboard data stream. However, in addition, most + keyboards support actions that cannot be represented as text data. + Such actions include things like cursor controls (home, up arrow, + page down, etc.), editing functions (insert, delete, etc.), volume + controls, (mute, volume up, etc.) and other special functions. We + can think about this as special, "out-of-band" keyboard commands. + In this case, some special encoding may be required to multiplex + the in-band text data and out-of-band command streams. + + This option enables the functions that implement the encoding and + decoding of keyboard data. These are the interfaces prototyped in + include/nuttx/input/kbd_codec.h. While not correctly a part of + the C library, it is included here because the decoding side of this + interface must be accessible by end user programs. diff --git a/nuttx/libc/math/Kconfig b/nuttx/libc/math/Kconfig index c24bfd53f..db9dfae63 100644 --- a/nuttx/libc/math/Kconfig +++ b/nuttx/libc/math/Kconfig @@ -4,7 +4,7 @@ # config LIBM - bool "Math library" + bool "Standard Math library" default n depends on !ARCH_MATH_H ---help--- diff --git a/nuttx/libc/misc/Make.defs b/nuttx/libc/misc/Make.defs index c6af5f860..ad0313346 100644 --- a/nuttx/libc/misc/Make.defs +++ b/nuttx/libc/misc/Make.defs @@ -35,7 +35,7 @@ # Add the internal C files to the build -CSRCS += lib_init.c lib_filesem.c lib_kbdencode.c lib_kbddecode.c +CSRCS += lib_init.c lib_filesem.c # Add C files that depend on file OR socket descriptors @@ -63,6 +63,12 @@ CSRCS += lib_match.c CSRCS += lib_crc32.c CSRCS += lib_dbg.c lib_dumpbuffer.c +# Keyboard driver encoder/decoder + +ifneq ($(CONFIG_LIB_KBDCODEC),0) +CSRCS += lib_kbdencode.c lib_kbddecode.c +endif + # Add the misc directory to the build DEPPATH += --dep-path misc -- cgit v1.2.3 From 954529e8c571cd7c2cc5963259d7eef46f6f5429 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 27 Dec 2012 14:01:59 +0000 Subject: Add support for key release events git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5464 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 5 +- apps/examples/hidkbd/hidkbd_main.c | 33 +++++-- nuttx/ChangeLog | 4 + nuttx/Documentation/NuttxPortingGuide.html | 138 +++++++++++++++++++++++------ nuttx/drivers/usbhost/usbhost_hidkbd.c | 8 +- nuttx/include/nuttx/input/kbd_codec.h | 100 +++++++++++++++------ nuttx/libc/misc/lib_kbddecode.c | 99 +++++++++++---------- nuttx/libc/misc/lib_kbdencode.c | 101 +++++++++++++++++---- 8 files changed, 356 insertions(+), 132 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index d156b1065..d6a2f9d90 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -455,4 +455,7 @@ this build phase. * apps/examples/hidbkd: Now supports decoding of encoded special keys if CONFIG_EXAMPLES_HIDKBD_ENCODED is defined. - + * apps/examples/hidbkd: Add support for decoding key release events + as well. However, the USB HID keyboard drier has not yet been + updated to detect key release events. That is kind of tricky in + the USB HID keyboard report data. diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index 8a632bab7..d7e79b121 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -176,7 +176,7 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes) { /* Decode the next thing from the buffer */ - ret = kbd_get((FAR struct lib_instream_s *)&kbdstream, &state, &ch); + ret = kbd_decode((FAR struct lib_instream_s *)&kbdstream, &state, &ch); if (ret == KBD_ERROR) { break; @@ -184,14 +184,31 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes) /* Normal data? Or special key? */ - if (ret == KBD_NORMAL) + switch (ret) { - printf("Data: %c [%02x]\n", isprint(ch) ? ch : '.', ch); - } - else - { - DEBUGASSERT(ret == KBD_SPECIAL); - printf("Special: %d\n", ch); + case KBD_PRESS: /* Key press event */ + printf("Normal Press: %c [%02x]\n", isprint(ch) ? ch : '.', ch); + break; + + case KBD_RELEASE: /* Key release event */ + printf("Normal Release: %c [%02x]\n", isprint(ch) ? ch : '.', ch); + break; + + case KBD_SPECPRESS: /* Special key press event */ + printf("Special Press: %d\n", ch); + break; + + case KBD_SPECREL: /* Special key release event */ + printf("Special Release: %d\n", ch); + break; + + case KBD_ERROR: /* Error or end-of-file */ + printf("EOF: %d\n", ret); + break; + + default: + printf("Unexpected: %d\n", ret); + break; } } } diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index a7087656a..2e114af8c 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3832,4 +3832,8 @@ UG-2864HSWEG01 OLED for the STM32F4Discovery board. * drivers/usbhost/usbhost_hidkbd.c: Correct a logic error in how tasks waiting for read data are awakened. + * libc/misc/lib_kbdencode.c and lib_kbddecode.c: Now handles keypress + events too. However, the USB HID keyboard drier has not yet been + updated to detect key release events. That is kind of tricky in + the USB HID keyboard report data. diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index ebb3eff4b..e626bf7a5 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -3623,20 +3623,27 @@ extern void up_ledoff(int led);

    6.3.16 Keyboard/Keypad Drivers

    - "Out-of-Band" Commands. - Keyboards and keypads are the same device for NuttX. + Keypads vs. Keyboards + Keyboards and keypads are really the same devices for NuttX. A keypad is thought of as simply a keyboard with fewer keys. +

    +

    + Special Commands. In NuttX, a keyboard/keypad driver is simply a character driver that may have an (optional) encoding/decoding layer on the data returned by the character driver. - A keyboard may return simple text data (alphabetic, numeric, and punctuaction) or control characters (enter, control-C, etc.). - We can think about this the normal "in-band" keyboard data stream. - However, in addition, most keyboards support actions that cannot be represented as text data. + A keyboard may return simple text data (alphabetic, numeric, and punctuaction) or control characters (enter, control-C, etc.) when a key is pressed. + We can think about this the "normal" keyboard data stream. + However, in addition, most keyboards support actions that cannot be represented as text or control data. Such actions include things like cursor controls (home, up arrow, page down, etc.), editing functions (insert, delete, etc.), volume controls, (mute, volume up, etc.) and other special functions. - We can think about this as special, "out-of-band" keyboard commands. - In this case, some special encoding may be required to multiplex the in-band text data and out-of-band command streams. + In this case, some special encoding may be required to multiplex the normal text data and special command key press data streams. +

    +

    + Key Press and Release Events + Sometimes the time that a key is released is needed by applications as well. + Thus, in addition to normal and special key press events, it may also be necessary to encode normal and special key release events.

    Encoding/Decoding Layer. - An optional encoding/decoding layer can be used with the basic character driver to encode the out-of-band commands into the text data stream. + An optional encoding/decoding layer can be used with the basic character driver to encode the keyboard events into the text data stream. The function interfaces that comprise that encoding/decoding layer are defined in the header file include/nuttx/input/kbd_code.h. These functions provide an matched set of (a) driver encoding interfaces, and (b) application decoding interfaces.

    @@ -3644,21 +3651,23 @@ extern void up_ledoff(int led);
  • Driver Encoding Interfaces. + These are interfaces used by the keyboard/keypad driver to encode keyboard events and data.

    • - kbd_puttext() + kbd_press()

      Function Prototype:

         #include <nuttx/streams.h>
         #include <nuttx/input/kbd_codec.h>
        -void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
        +void kbd_press(int ch, FAR struct lib_outstream_s *stream);
         

      Description:

        - Put one byte of normal, "in-band" ASCII data into the output stream. + Indicates a normal key press event. + Put one byte of normal keyboard data into the output stream.

      Input Pameters:

        @@ -3676,18 +3685,77 @@ void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
      • - kbd_putspecial() + kbd_release() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Encode the release of a normal key. +
        +

        Input Pameters:

        +
          +
        • + ch: The character associated with the key that was releared. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        • +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_specpress()

        Function Prototype:

           #include <nuttx/streams.h>
           #include <nuttx/input/kbd_codec.h>
          -void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
          +void kbd_specpress(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
           

        Description:

          - Put one special, "out-of-band" command into the output stream. + Denotes a special key press event. + Put one special keyboard command into the output stream. +
        +

        Input Pameters:

        +
          +
        • + keycode: The command to be added to the output stream. + The enumeration enum kbd_keycode_e keycode identifies all commands known to the system. +
        • +
        • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
        +

        Returned Value:

        +
          + None. +
        +
      • +
      • +

        + kbd_specrel() +

        +

        Function Prototype:

        +
          +#include <nuttx/streams.h>
          +#include <nuttx/input/kbd_codec.h>
          +void kbd_specrel(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
          +
        +

        Description:

        +
          + Denotes a special key release event. + Put one special keyboard command into the output stream. +

        Input Pameters:

        • @@ -3708,17 +3776,18 @@ void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stre
        • Application Decoding Interfaces. -

          + These are user interfaces to decode the values returned by the keyboard/keypad driver. +

          • - kbd_get() + kbd_decode()

            Function Prototype:

               #include <nuttx/streams.h>
               #include <nuttx/input/kbd_codec.h>
              -int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
              +int kbd_decode(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
               

            Description:

              @@ -3730,30 +3799,41 @@ int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, stream: An instance of lib_instream_s to perform the actual low-level get operation.
            • - pch: The location character to save the returned value. - This may be either a normal, "in-band" ASCII characer or a special, "out-of-band" command (i.e., a value from enum kbd_getstate_s. + pch: The location to save the returned value. + This may be either a normal, character code or a special command (i.e., a value from enum kbd_getstate_s.
            • state: A user provided buffer to support parsing. - This structure should be cleared the first time that kbd_get is called. + This structure should be cleared the first time that kbd_decode() is called.

            Returned Value:

            • - 1: - Indicates the successful receipt of a special, "out-of-band" command. - The returned value in pch is a value from enum kbd_getstate_s. + KBD_PRESS (0): + Indicates the successful receipt of normal, keyboard data. + This corresponds to a keypress event. + The returned value in pch is a simple byte of text or control data.
            • - 0: - Indicates the successful receipt of normal, "in-band" ASCII data. - The returned value in pch is a simple byte of text or control data. + KBD_RELEASE (1): + Indicates a key release event. + The returned value in pch is the byte of text or control data corresponding to the released key. +
            • +
            • + KBD_SPECPRESS (2): + Indicates the successful receipt of a special keyboard command. + The returned value in pch is a value from enum kbd_getstate_s. +
            • +
            • + KBD_SPECREL (3): + Indicates a special command key release event. + The returned value in pch is a value from enum kbd_getstate_s.
            • - EOF: - An error has getting the next character (reported by the stream). - Normally indicates the end of file. + KBD_ERROR (EOF): + An error has getting the next character (reported by the stream). + Normally indicates the end of file.
          • diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index 917ebfa3f..0bab89c28 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -530,7 +530,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] = 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ 0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ - '\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */ + '\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */ '8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */ #ifdef CONFIG_HIDKBD_ALLSCANCODES 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */ @@ -565,7 +565,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] = 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ 0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ - '\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */ + '\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */ '8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */ #ifdef CONFIG_HIDKBD_ALLSCANCODES 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */ @@ -977,8 +977,8 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, /* Add the special function value to the user buffer */ - kbd_putspecial((enum kbd_keycode_e)encoded, - (FAR struct lib_outstream_s *)&usbstream); + kbd_specpress((enum kbd_keycode_e)encoded, + (FAR struct lib_outstream_s *)&usbstream); } } } diff --git a/nuttx/include/nuttx/input/kbd_codec.h b/nuttx/include/nuttx/input/kbd_codec.h index 0a3a54d2d..9a7c7c8e6 100644 --- a/nuttx/include/nuttx/input/kbd_codec.h +++ b/nuttx/include/nuttx/input/kbd_codec.h @@ -1,6 +1,6 @@ /************************************************************************************ * include/nuttx/input/kbd_codec.h - * Serialize and marshaling out-of-band keyboard data + * Serialize and marshaling keyboard data and events * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -54,9 +54,7 @@ * Public Types ****************************************************************************/ -/* These are the special, "out-of-band" keyboard commands recognized by the - * CODEC. - */ +/* These are the special keyboard commands recognized by the CODEC. */ enum kbd_keycode_e { @@ -190,11 +188,13 @@ enum kbd_keycode_e #define FIRST_KEYCODE KEYCODE_FWDDEL #define LAST_KEYCODE KEYCODE_F24 -/* kbd_get return values */ +/* kbd_decode() return values */ -#define KBD_NORMAL 0 -#define KBD_SPECIAL 1 -#define KBD_ERROR EOF +#define KBD_PRESS 0 /* Key press event */ +#define KBD_RELEASE 1 /* Key release event */ +#define KBD_SPECPRESS 2 /* Special key press event */ +#define KBD_SPECREL 3 /* Special key release event */ +#define KBD_ERROR EOF /* Error or end-of-file */ /**************************************************************************** * Public Types @@ -222,10 +222,11 @@ extern "C" ****************************************************************************/ /**************************************************************************** - * Name: kbd_puttext + * Name: kbd_press * * Description: - * Put one byte of normal, "in-band" ASCII data into the output stream. + * Indicates a normal key press event. Put one byte of normal keyboard + * data into the output stream. * * Input Parameters: * ch - The character to be added to the output stream. @@ -237,13 +238,52 @@ extern "C" * ****************************************************************************/ -#define kbd_puttext(ch, stream) (stream)->put((stream), (int)(ch)) +#define kbd_press(ch, stream) (stream)->put((stream), (int)(ch)) /**************************************************************************** - * Name: kbd_putspecial + * Name: kbd_release * * Description: - * Put one special, "out-of-band" command into the output stream. + * Encode the release of a normal key. + * + * Input Parameters: + * ch - The character associated with the key that was releared. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream); + +/**************************************************************************** + * Name: kbd_specpress + * + * Description: + * Denotes a special key press event. Put one special keyboard command + * into the output stream. + * + * Input Parameters: + * keycode - The command to be added to the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_specpress(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream); + +/**************************************************************************** + * Name: kbd_specrel + * + * Description: + * Denotes a special key release event. Put one special keyboard + * command into the output stream. * * Input Parameters: * keycode - The command to be added to the output stream. @@ -255,8 +295,8 @@ extern "C" * ****************************************************************************/ -void kbd_putspecial(enum kbd_keycode_e keycode, - FAR struct lib_outstream_s *stream); +void kbd_specrel(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream); /**************************************************************************** * The following functions are intended for use by "consumer" applications @@ -264,7 +304,7 @@ void kbd_putspecial(enum kbd_keycode_e keycode, ****************************************************************************/ /**************************************************************************** - * Name: kbd_get + * Name: kbd_decode * * Description: * Get one byte of data or special command from the driver provided input @@ -273,24 +313,30 @@ void kbd_putspecial(enum kbd_keycode_e keycode, * Input Parameters: * stream - An instance of lib_instream_s to do the low-level get * operation. - * pch - The location character to save the returned value. This may be - * either a normal, "in-band" ASCII characer or a special, "out-of-band" - * command. + * pch - The location to save the returned value. This may be + * either a normal, character code or a special command from enum + * kbd_keycode_e * state - A user provided buffer to support parsing. This structure - * should be cleared the first time that kbd_get is called. + * should be cleared the first time that kbd_decode is called. * * Returned Value: - * 1 - Indicates the successful receipt of a special, "out-of-band" command. - * The returned value in pch is a value from enum kbd_getstate_s. - * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. - * The returned value in pch is a simple byte of text or control data. + * + * KBD_PRESS - Indicates the successful receipt of normal, keyboard data. + * This corresponds to a keypress event. The returned value in pch is a + * simple byte of text or control data corresponding to the pressed key. + * KBD_RELEASE - Indicates a key release event. The returned value in pch + * is the byte of text or control data corresponding to the released key. + * KBD_SPECPRESS - Indicates the successful receipt of a special keyboard + * command. The returned value in pch is a value from enum kbd_getstate_s. + * KBD_SPECREL - Indicates a special key release event. The returned value + * in pch is a value from enum kbd_getstate_s. * EOF - An error has getting the next character (reported by the stream). - * Normally indicates the end of file. + * Normally indicates the end of file. * ****************************************************************************/ -int kbd_get(FAR struct lib_instream_s *stream, - FAR struct kbd_getstate_s *state, FAR uint8_t *pch); +int kbd_decode(FAR struct lib_instream_s *stream, + FAR struct kbd_getstate_s *state, FAR uint8_t *pch); #ifdef __cplusplus } diff --git a/nuttx/libc/misc/lib_kbddecode.c b/nuttx/libc/misc/lib_kbddecode.c index cb57b5215..62554902c 100644 --- a/nuttx/libc/misc/lib_kbddecode.c +++ b/nuttx/libc/misc/lib_kbddecode.c @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * libc/msic/lib_kbddecode.c * Decoding side of the Keyboard CODEC * @@ -32,38 +32,43 @@ * 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 -/******************************************************************************************** +/**************************************************************************** * Pre-Processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -#define NDX_ESC 0 -#define NDX_BRACKET 1 -#define NDX_CODE 2 -#define NCX_SEMICOLON 3 +#define NDX_ESC 0 +#define NDX_BRACKET 1 +#define NDX_CODE 2 +#define NDX_TERMINATOR 3 -#define NCH_ESC 1 -#define NCH_BRACKET 2 -#define NCH_CODE 3 -#define NCH_SEMICOLON 4 +#define NCH_ESC 1 +#define NCH_BRACKET 2 +#define NCH_CODE 3 +#define NCH_TERMINATOR 4 -/******************************************************************************************** +#define TERM_MIN ('a' + KBD_RELEASE) +#define TERM_MAX ('a' + KBD_SPECREL) +#define TERM_RETURN(a) ((a) - 'a') + +/**************************************************************************** * Private Functions - ********************************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Name: kbd_reget @@ -76,16 +81,11 @@ * stream - An instance of lib_instream_s to do the low-level get * operation. * pch - The location character to save the returned value. This may be - * either a normal, "in-band" ASCII characer or a special, "out-of-band" - * command. - * state - A user provided buffer to support parsing. This structure - * should be cleared the first time that kbd_get is called. + * either a normal, character code or a special command from enum + * kbd_keycode_e * * Returned Value: - * 2 - Indicates the successful receipt of a special, "out-of-band" command - * 1 - Indicates the successful receipt of normal, "in-band" ASCII data. - * 0 - Indicates end-of-file or that the stream has been closed - * EOF - An error has getting the next character (reported by the stream). + * KBD_PRESS - Indicates the successful receipt of norma keyboard data. * ****************************************************************************/ @@ -96,15 +96,15 @@ static int kbd_reget(FAR struct kbd_getstate_s *state, FAR uint8_t *pch) *pch = state->buf[state->ndx]; state->ndx++; state->nch--; - return KBD_NORMAL; + return KBD_PRESS; } -/******************************************************************************************** +/**************************************************************************** * Public Functions - ********************************************************************************************/ + ****************************************************************************/ /**************************************************************************** - * Name: kbd_get + * Name: kbd_decode * * Description: * Get one byte of data or special command from the driver provided input @@ -113,24 +113,30 @@ static int kbd_reget(FAR struct kbd_getstate_s *state, FAR uint8_t *pch) * Input Parameters: * stream - An instance of lib_instream_s to do the low-level get * operation. - * pch - The location character to save the returned value. This may be - * either a normal, "in-band" ASCII characer or a special, "out-of-band" - * command. + * pch - The location to save the returned value. This may be + * either a normal, character code or a special command from enum + * kbd_keycode_e * state - A user provided buffer to support parsing. This structure - * should be cleared the first time that kbd_get is called. + * should be cleared the first time that kbd_decode is called. * * Returned Value: - * 1 - Indicates the successful receipt of a special, "out-of-band" command. - * The returned value in pch is a value from enum kbd_getstate_s. - * 0 - Indicates the successful receipt of normal, "in-band" ASCII data. - * The returned value in pch is a simple byte of text or control data. + * + * KBD_PRESS - Indicates the successful receipt of normal, keyboard data. + * This corresponds to a keypress event. The returned value in pch is a + * simple byte of text or control data corresponding to the pressed key. + * KBD_RELEASE - Indicates a key release event. The returned value in pch + * is the byte of text or control data corresponding to the released key. + * KBD_SPECPRESS - Indicates the successful receipt of a special keyboard + * command. The returned value in pch is a value from enum kbd_getstate_s. + * KBD_SPECREL - Indicates a special key release event. The returned value + * in pch is a value from enum kbd_getstate_s. * EOF - An error has getting the next character (reported by the stream). - * Normally indicates the end of file. + * Normally indicates the end of file. * ****************************************************************************/ -int kbd_get(FAR struct lib_instream_s *stream, - FAR struct kbd_getstate_s *state, FAR uint8_t *pch) +int kbd_decode(FAR struct lib_instream_s *stream, + FAR struct kbd_getstate_s *state, FAR uint8_t *pch) { int ch; @@ -147,7 +153,7 @@ int kbd_get(FAR struct lib_instream_s *stream, state->ndx = 0; - /* No, ungotten characters. Check for the beginning of an esc sequence. */ + /* No, ungotten characters. Check for the beginning of an ESC sequence. */ ch = stream->get(stream); if (ch == EOF) @@ -195,7 +201,7 @@ int kbd_get(FAR struct lib_instream_s *stream, } } - /* Get and verify the special, "out-of-band" command code */ + /* Get and verify the special keyboard data to decode */ ch = stream->get(stream); if (ch == EOF) @@ -234,12 +240,12 @@ int kbd_get(FAR struct lib_instream_s *stream, } else { - state->buf[NCX_SEMICOLON] = (uint8_t)ch; - state->nch = NCH_SEMICOLON; + state->buf[NDX_TERMINATOR] = (uint8_t)ch; + state->nch = NCH_TERMINATOR; /* Check for a valid special command code */ - if (ch != ';') + if (ch < TERM_MIN || ch > TERM_MAX) { /* Not a special command code, return the ESC now and the next two * characters later. @@ -250,11 +256,12 @@ int kbd_get(FAR struct lib_instream_s *stream, } /* We have successfully parsed the the entire escape sequence. Return the - * special code in pch and the value 2. + * keyboard value in pch and the value an indication determined by the + * terminating character. */ *pch = state->buf[NDX_CODE]; state->nch = 0; - return KBD_SPECIAL; + return TERM_RETURN(state->buf[NDX_TERMINATOR]); } diff --git a/nuttx/libc/misc/lib_kbdencode.c b/nuttx/libc/misc/lib_kbdencode.c index 40a8805b1..80138ca80 100644 --- a/nuttx/libc/misc/lib_kbdencode.c +++ b/nuttx/libc/misc/lib_kbdencode.c @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * libc/msic/lib_kbdencode.c * Encoding side of the Keyboard CODEC * @@ -32,11 +32,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -47,38 +47,105 @@ #include #include -/******************************************************************************************** +/**************************************************************************** * Pre-Processor Definitions - ********************************************************************************************/ - -/******************************************************************************************** - * Public Functions - ********************************************************************************************/ + ****************************************************************************/ /**************************************************************************** - * Name: kbd_putspecial + * Name: kbd_encode * * Description: - * Put one special, "out-of-band" command into the output stream. + * Encode one special special sequence command into the output stream. * * Input Parameters: * keycode - The command to be added to the output stream. * stream - An instance of lib_outstream_s to do the low-level put * operation. + * terminator - Escape sequence terminating character. * * Returned Value: * None * ****************************************************************************/ -void kbd_putspecial(enum kbd_keycode_e keycode, - FAR struct lib_outstream_s *stream) +static void kbd_encode(uint8_t keycode, FAR struct lib_outstream_s *stream, + uint8_t terminator) { - DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE); - stream->put(stream, ASCII_ESC); stream->put(stream, '['); stream->put(stream, (int)keycode); - stream->put(stream, ';'); + stream->put(stream, terminator); } +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: kbd_release + * + * Description: + * Encode the release of a normal key. + * + * Input Parameters: + * ch - The character associated with the key that was releared. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream) +{ + kbd_encode(ch, stream, ('a' + KBD_RELEASE)); +} + +/**************************************************************************** + * Name: kbd_specpress + * + * Description: + * Denotes a special key press event. Put one special keyboard command + * into the output stream. + * + * Input Parameters: + * keycode - The command to be added to the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_specpress(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream) +{ + DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE); + kbd_encode((uint8_t)keycode, stream, ('a' + KBD_SPECPRESS)); +} + +/**************************************************************************** + * Name: kbd_specrel + * + * Description: + * Denotes a special key release event. Put one special keyboard + * command into the output stream. + * + * Input Parameters: + * keycode - The command to be added to the output stream. + * stream - An instance of lib_outstream_s to do the low-level put + * operation. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void kbd_specrel(enum kbd_keycode_e keycode, + FAR struct lib_outstream_s *stream) +{ + DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE); + kbd_encode((uint8_t)keycode, stream, ('a' + KBD_SPECREL)); +} -- cgit v1.2.3 From e0be95b9a02ebd38cc370b81586371bd93e6ac76 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 28 Dec 2012 23:40:54 +0000 Subject: Add board support at configs/zp214xpa for the The0.net ZP213X/4XPA board with the LPC2148; Add configurations sim/nxlines. convert mcu123-lpc214x/nsh to use the kconfig-frontends. git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5465 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/hidkbd/hidkbd_main.c | 11 +- nuttx/ChangeLog | 6 + nuttx/Documentation/NuttX.html | 5 +- nuttx/arch/arm/src/lpc214x/Kconfig | 134 +++++ nuttx/configs/Kconfig | 14 +- nuttx/configs/README.txt | 5 + nuttx/configs/mcu123-lpc214x/README.txt | 18 +- nuttx/configs/mcu123-lpc214x/nsh/appconfig | 44 -- nuttx/configs/mcu123-lpc214x/nsh/defconfig | 760 ++++++++++++++++--------- nuttx/configs/mcu123-lpc214x/scripts/ld.script | 6 +- nuttx/configs/sim/nxlines/Make.defs | 107 ++++ nuttx/configs/sim/nxlines/defconfig | 591 +++++++++++++++++++ nuttx/configs/sim/nxlines/setenv.sh | 53 ++ nuttx/configs/zp214xpa/Kconfig | 7 + nuttx/configs/zp214xpa/README.txt | 136 +++++ nuttx/configs/zp214xpa/include/board.h | 68 +++ nuttx/configs/zp214xpa/nsh/Make.defs | 128 +++++ nuttx/configs/zp214xpa/nsh/defconfig | 574 +++++++++++++++++++ nuttx/configs/zp214xpa/nsh/setenv.sh | 65 +++ nuttx/configs/zp214xpa/scripts/ld.script | 120 ++++ nuttx/configs/zp214xpa/src/Makefile | 84 +++ nuttx/drivers/mmcsd/Kconfig | 1 + nuttx/drivers/usbhost/usbhost_hidkbd.c | 6 +- 23 files changed, 2626 insertions(+), 317 deletions(-) delete mode 100644 nuttx/configs/mcu123-lpc214x/nsh/appconfig create mode 100644 nuttx/configs/sim/nxlines/Make.defs create mode 100644 nuttx/configs/sim/nxlines/defconfig create mode 100755 nuttx/configs/sim/nxlines/setenv.sh create mode 100644 nuttx/configs/zp214xpa/Kconfig create mode 100644 nuttx/configs/zp214xpa/README.txt create mode 100644 nuttx/configs/zp214xpa/include/board.h create mode 100644 nuttx/configs/zp214xpa/nsh/Make.defs create mode 100644 nuttx/configs/zp214xpa/nsh/defconfig create mode 100755 nuttx/configs/zp214xpa/nsh/setenv.sh create mode 100644 nuttx/configs/zp214xpa/scripts/ld.script create mode 100644 nuttx/configs/zp214xpa/src/Makefile (limited to 'apps') diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index d7e79b121..abc942a44 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -177,12 +177,14 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes) /* Decode the next thing from the buffer */ ret = kbd_decode((FAR struct lib_instream_s *)&kbdstream, &state, &ch); - if (ret == KBD_ERROR) + if (ret == KBD_ERROR) /* Error or end-of-file */ { + /* Break out when all of the data has been processed */ + break; } - /* Normal data? Or special key? */ + /* Normal data? Or special key? Press? Or release? */ switch (ret) { @@ -202,10 +204,7 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes) printf("Special Release: %d\n", ch); break; - case KBD_ERROR: /* Error or end-of-file */ - printf("EOF: %d\n", ret); - break; - + case KBD_ERROR: /* Error or end-of-file, already handled */ default: printf("Unexpected: %d\n", ret); break; diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 2e114af8c..dcabb6c07 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3836,4 +3836,10 @@ events too. However, the USB HID keyboard drier has not yet been updated to detect key release events. That is kind of tricky in the USB HID keyboard report data. + * configs/mcu123-214x/nsh: Converted to use the kconfig-frontends + configuration tool. + * configs/zp214xpa: Add basic support for the The0.net ZP213x/4xPA + board (with the LPC2148 and the UG_2864AMBAG01). + * configs/sim/nxlines: Add an nxlines configuration for the + simulator. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 84f298d3a..dc454c0b6 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

            NuttX RTOS

            -

            Last Updated: December 20, 2012

            +

            Last Updated: December 28, 2012

            @@ -1505,7 +1505,8 @@ svn checkout -r5447 http://svn.code.sf.net/p/nuttx/code/trunk nuttx-code

            NXP LPC214x. Support is provided for the NXP LPC214x family of processors. In particular, - support is provided for the mcu123.com lpc214x evaluation board (LPC2148). + support is provided for (1) the mcu123.com lpc214x evaluation board (LPC2148) + and (1) the The0.net ZPA213X/4XPA development board (with the The0.net UG-2864AMBAG01 OLED) This port also used the GNU arm-nuttx-elf toolchain* under Linux or Cygwin.

              diff --git a/nuttx/arch/arm/src/lpc214x/Kconfig b/nuttx/arch/arm/src/lpc214x/Kconfig index a26483ed9..5d52eb000 100644 --- a/nuttx/arch/arm/src/lpc214x/Kconfig +++ b/nuttx/arch/arm/src/lpc214x/Kconfig @@ -4,3 +4,137 @@ # comment "LPC214x Configuration Options" + +# Fragments of LPC214x chip selection logic. The LPC2148 is the only chip +# supported for now. + +config ARCH_CHIP_LPC2148 + bool + default y + +comment "LPC214x Initialization Options" + +choice + prompt "Memory Execution Mode" + default DEFAULT_MODE + +config EXTMEM_MODE + bool "External Memory Mode" + ---help--- + Code executes from external memory starting at address 0x8000:0000. + +config RAM_MODE + bool "RAM Memory Mode" + ---help--- + Code executes from on-chip RAM at address 0x4000:0000. + +config DEFAULT_MODE + bool "Default Memory Mode" + ---help--- + Executes from 0x0000:0000. In non-default modes, the MEMAP register + is set override the settings of the CPU configuration pins. + +endchoice + +config CODE_BASE + hex "Execuation Base Address" + default 0x00000000 + ---help--- + This must match the expected address for the selected "Memory + Execution Address": + + EXTMEM_MODE: 0x8000:0000 + RAM_MODE: 0x4000:0000 + DEFAULT)MODE: 0x0000:0000 + +config PLL_SETUP + bool "Configure the PLL" + default y + +config MAM_SETUP + bool "Configure the Memory Accelerator Module (MAM)" + default y + +config APBDIV_SETUP + bool "Configure the APB Divider" + default y + +config APBDIV_VALUE + int "APB Divisor" + default 1 + +config EMC_SETUP + bool "Configure EMC" + default n + +config BCFG0_SETUP + bool "Configure BCFG0" + default n + +config BCFG1_SETUP + bool "Configure BCFG1" + default n + +config BCFG2_SETUP + bool "Configure BCFG2" + default n + +config BCFG3_SETUP + bool "Configure BCFG3" + default n + +config ADC_SETUP + bool "Configure ADC" + default y + +menu "LPC214x Peripheral Support" + +config LPC214X_UART0 + bool + default y + select ARCH_HAVE_UART0 + +config LPC214X_UART1 + bool + default y + select ARCH_HAVE_UART1 + +config LPC214X_USBDEV + bool "USB Device" + default y + depends on USBDEV + +endmenu + +config LPC214x_FIO + bool "Fast GPIO" + default n + +if LPC214X_USBDEV +menu "LPC214x USB Device Configuration" + +config LPC214X_USBDEV_DMA + bool "USB Device DMA Support" + default n + +config CONFIG_LPC214X_USBDEV_NDMADESCRIPTORS + int "Number of USB DMA Descriptors" + default 8 + depends on LPC214X_USBDEV_DMA + +config LPC214X_USBDEV_EPFAST_INTERRUPT + bool "USB Device Fast Endpoint Interrupts" + default n + +config LPC214X_USBDEV_FRAME_INTERRUPT + bool "USB Device Frame Interrupts" + default n + +config LPC214X_USBDEV_REGDEBUG + bool "USB Device Register-Level Debug Output" + default n + depends on DEBUG + +endmenu +endif + diff --git a/nuttx/configs/Kconfig b/nuttx/configs/Kconfig index bba1444c4..cda5aa7bc 100644 --- a/nuttx/configs/Kconfig +++ b/nuttx/configs/Kconfig @@ -619,6 +619,14 @@ config ARCH_BOARD_Z8F64200100KIT development kit, Z8F6423 part, and the Zilog ZDS-II Windows command line tools. The development environment is Cygwin under WinXP. +config ARCH_BOARD_ZP214XPA + bool "The0.net LPC2148 Development Board" + depends on ARCH_CHIP_LPC2148 + ---help--- + This port is for the NXP LPC2148 as provided on the The0.net + ZPA213X/4XPA development board. Includes support for the + UG-2864AMBAG01 OLED also from The0.net + config ARCH_BOARD_SIM bool "User mode simulation" depends on ARCH_SIM @@ -700,6 +708,7 @@ config ARCH_BOARD default "z80sim" if ARCH_BOARD_Z80SIM default "z8encore000zco" if ARCH_BOARD_Z8ENCORE000ZCO default "z8f64200100kit" if ARCH_BOARD_Z8F64200100KIT + default "zp214xpa" if ARCH_BOARD_ZP214XPA default "sim" if ARCH_BOARD_SIM default "" if ARCH_BOARD_CUSTOM @@ -709,7 +718,7 @@ config ARCH_HAVE_LEDS bool config ARCH_LEDS - bool "Board LEDs support" + bool "Board LED support" default y depends on ARCH_HAVE_LEDS ---help--- @@ -935,6 +944,9 @@ endif if ARCH_BOARD_Z8F64200100KIT source "configs/z8f64200100kit/Kconfig" endif +if ARCH_BOARD_ZP214XPA +source "configs/zp214xpa/Kconfig" +endif if ARCH_BOARD_SIM source "configs/sim/Kconfig" endif diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 21aace2af..4e9bcca14 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -1936,6 +1936,11 @@ configs/z8f64200100kit development kit, Z8F6423 part, and the Zilog ZDS-II Windows command line tools. The development environment is Cygwin under WinXP. +configs/zp214xpa + This port is for the NXP LPC2148 as provided on the The0.net + ZPA213X/4XPA development board. Includes support for the + UG-2864AMBAG01 OLED also from The0.net + Configuring NuttX ^^^^^^^^^^^^^^^^^ diff --git a/nuttx/configs/mcu123-lpc214x/README.txt b/nuttx/configs/mcu123-lpc214x/README.txt index 435f8647d..4c7c608b7 100644 --- a/nuttx/configs/mcu123-lpc214x/README.txt +++ b/nuttx/configs/mcu123-lpc214x/README.txt @@ -349,8 +349,22 @@ nsh: Configures the NuttShell (nsh) located at examples/nsh. The Configuration enables only the serial NSH interfaces. - Default toolchain: Buildroot - Output format: ELF and binary + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the mconf tool. See nuttx/README.txt and + misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Default platform/toolchain: + + CONFIG_HOST_LINUX=y : Windows + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Buildroot (arm-nuttx-elf-gcc) + CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary ostest: ------- diff --git a/nuttx/configs/mcu123-lpc214x/nsh/appconfig b/nuttx/configs/mcu123-lpc214x/nsh/appconfig deleted file mode 100644 index f8e2d5165..000000000 --- a/nuttx/configs/mcu123-lpc214x/nsh/appconfig +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# configs/mcu123-lpc214x/nsh/appconfig -# -# 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. -# -############################################################################ - -# Path to example in apps/examples containing the user_start entry point - -CONFIGURED_APPS += examples/nsh - -# The NSH library - -CONFIGURED_APPS += system/readline -CONFIGURED_APPS += nshlib - diff --git a/nuttx/configs/mcu123-lpc214x/nsh/defconfig b/nuttx/configs/mcu123-lpc214x/nsh/defconfig index a8a53a340..6ae163386 100644 --- a/nuttx/configs/mcu123-lpc214x/nsh/defconfig +++ b/nuttx/configs/mcu123-lpc214x/nsh/defconfig @@ -1,169 +1,207 @@ -############################################################################ -# configs/mcu123-lpc214x/nsh/defconfig -# -# Copyright (C) 2008-2010, 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. -# -############################################################################ -# -# Architecture selection # -CONFIG_ARCH="arm" +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL 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_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_SYMBOLS is not set + +# +# System Type +# +# CONFIG_ARCH_8051 is not set 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_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_IMX is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_LM3S is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +CONFIG_ARCH_CHIP_LPC214X=y +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_SAM3U is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STR71X is not set CONFIG_ARCH_ARM7TDMI=y +CONFIG_ARCH_FAMILY="arm" CONFIG_ARCH_CHIP="lpc214x" -CONFIG_ARCH_CHIP_LPC2148=y -CONFIG_ARCH_BOARD="mcu123-lpc214x" -CONFIG_ARCH_BOARD_MCU123=y +CONFIG_ARCH_HAVE_LOWVECTORS=y +# CONFIG_ARCH_LOWVECTORS is not set CONFIG_BOARD_LOOPSPERMSEC=3270 -CONFIG_ARCH_LEDS=y -CONFIG_DRAM_SIZE=32768 -CONFIG_DRAM_START=0x40000000 -CONFIG_ARCH_INTERRUPTSTACK=0 -CONFIG_ARCH_STACKDUMP=y +# CONFIG_ARCH_CALIBRATION is not set # -# LPC2148 specific chip initialization +# ARM Configuration Options +# +# CONFIG_ARM_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARM_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARM_TOOLCHAIN_GNU_EABI=y + +# +# LPC214x Configuration Options +# +CONFIG_ARCH_CHIP_LPC2148=y + # -CONFIG_EXTMEM_MODE=n -CONFIG_RAM_MODE=n +# LPC214x Initialization Options +# +# CONFIG_EXTMEM_MODE is not set +# CONFIG_RAM_MODE is not set +CONFIG_DEFAULT_MODE=y CONFIG_CODE_BASE=0x00000000 CONFIG_PLL_SETUP=y CONFIG_MAM_SETUP=y CONFIG_APBDIV_SETUP=y -CONFIG_EMC_SETUP=n -CONFIG_BCFG0_SETUP=n -CONFIG_BCFG1_SETUP=n -CONFIG_BCFG2_SETUP=n -CONFIG_BCFG3_SETUP=n +CONFIG_APBDIV_VALUE=1 +# CONFIG_EMC_SETUP is not set +# CONFIG_BCFG0_SETUP is not set +# CONFIG_BCFG1_SETUP is not set +# CONFIG_BCFG2_SETUP is not set +# CONFIG_BCFG3_SETUP is not set CONFIG_ADC_SETUP=y # -# LPC214X specific device driver settings +# LPC214x Peripheral Support # -CONFIG_UART0_SERIAL_CONSOLE=y -CONFIG_UART1_SERIAL_CONSOLE=n -CONFIG_UART0_TXBUFSIZE=256 -CONFIG_UART1_TXBUFSIZE=256 -CONFIG_UART0_RXBUFSIZE=256 -CONFIG_UART1_RXBUFSIZE=256 -CONFIG_UART0_BAUD=38400 -CONFIG_UART1_BAUD=38400 -CONFIG_UART0_BITS=8 -CONFIG_UART1_BITS=8 -CONFIG_UART0_PARITY=0 -CONFIG_UART1_PARITY=0 -CONFIG_UART0_2STOP=0 -CONFIG_UART1_2STOP=0 +CONFIG_LPC214X_UART0=y +CONFIG_LPC214X_UART1=y +# CONFIG_LPC214x_FIO is not set +# CONFIG_SDIO_DMA is not set +# CONFIG_SDIO_WIDTH_D1_ONLY is not set # -# General build options +# Architecture Options # -CONFIG_RRLOAD_BINARY=n -CONFIG_INTELHEX_BINARY=n -CONFIG_MOTOROLA_SREC=n -CONFIG_RAW_BINARY=y +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_IRQPRIO is not set +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set # -# General OS setup +# Board Settings # -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_DEBUG=n -CONFIG_DEBUG_VERBOSE=n -CONFIG_DEBUG_SYMBOLS=n -CONFIG_MM_REGIONS=1 -CONFIG_ARCH_LOWPUTC=y +CONFIG_DRAM_START=0x40000000 +CONFIG_DRAM_SIZE=32768 +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 + +# +# 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 + +# +# Board Selection +# +CONFIG_ARCH_BOARD_MCU123=y +# CONFIG_ARCH_BOARD_ZP214XPA is not set +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="mcu123-lpc214x" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 +CONFIG_NSH_MMCSDSPIPORTNO=1 + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 CONFIG_RR_INTERVAL=0 -CONFIG_SCHED_INSTRUMENTATION=n +# CONFIG_SCHED_INSTRUMENTATION is not set CONFIG_TASK_NAME_SIZE=0 +# CONFIG_JULIAN_TIME is not set CONFIG_START_YEAR=2008 CONFIG_START_MONTH=10 CONFIG_START_DAY=1 -CONFIG_JULIAN_TIME=n CONFIG_DEV_CONSOLE=y -CONFIG_DEV_LOWCONSOLE=n -CONFIG_MUTEX_TYPES=n -CONFIG_PRIORITY_INHERITANCE=n -CONFIG_SEM_PREALLOCHOLDERS=0 -CONFIG_SEM_NNESTPRIO=0 -CONFIG_FDCLONE_DISABLE=n -CONFIG_FDCLONE_STDIO=n +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set CONFIG_SDCLONE_DISABLE=y -CONFIG_NXFLAT=n - -# -# The following can be used to disable categories of -# APIs supported by the OS. If the compiler supports -# weak functions, then it should not be necessary to -# disable functions unless you want to restrict usage -# of those APIs. -# -# There are certain dependency relationships in these -# features. -# -# o mq_notify logic depends on signals to awaken tasks -# waiting for queues to become full or empty. -# o pthread_condtimedwait() depends on signals to wake -# up waiting tasks. -# -CONFIG_DISABLE_CLOCK=n -CONFIG_DISABLE_POSIX_TIMERS=n -CONFIG_DISABLE_PTHREAD=n -CONFIG_DISABLE_SIGNALS=n -CONFIG_DISABLE_MQUEUE=n -CONFIG_DISABLE_MOUNTPOINT=n -CONFIG_DISABLE_ENVIRON=n +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_WAITPID is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# 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_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set CONFIG_DISABLE_POLL=y -# -# Misc libc settings -# -CONFIG_NOPRINTF_FIELDWIDTH=n - -# -# Allow for architecture optimized implementations -# -# The architecture can provide optimized versions of the -# following to improve system performance -# -CONFIG_ARCH_MEMCPY=n -CONFIG_ARCH_MEMCMP=n -CONFIG_ARCH_MEMMOVE=n -CONFIG_ARCH_MEMSET=n -CONFIG_ARCH_STRCMP=n -CONFIG_ARCH_STRCPY=n -CONFIG_ARCH_STRNCPY=n -CONFIG_ARCH_STRLEN=n -CONFIG_ARCH_STRNLEN=n -CONFIG_ARCH_BZERO=n - # # Sizes of configurable things (0 disables) # @@ -173,8 +211,6 @@ CONFIG_NPTHREAD_KEYS=4 CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 CONFIG_NAME_MAX=32 -CONFIG_STDIO_BUFFER_SIZE=256 -CONFIG_NUNGET_CHARS=2 CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_MQ_MAXMSGSIZE=32 CONFIG_MAX_WDOGPARMS=2 @@ -182,168 +218,380 @@ CONFIG_PREALLOC_WDOGS=4 CONFIG_PREALLOC_TIMERS=4 # -# Filesystem configuration +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +CONFIG_SPI=y +# CONFIG_SPI_OWNBUS is not set +# CONFIG_SPI_EXCHANGE is not set +# CONFIG_SPI_CMDDATA is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +CONFIG_MMCSD=y +CONFIG_MMCSD_NSLOTS=1 +# CONFIG_MMCSD_READONLY is not set +# CONFIG_MMCSD_MULTIBLOCK_DISABLE is not set +CONFIG_MMCSD_MMCSUPPORT=y +CONFIG_MMCSD_HAVECARDDETECT=y +CONFIG_MMCSD_SPI=y +CONFIG_MMCSD_SPICLOCK=20000000 +# CONFIG_MMCSD_SDIO is not set +# CONFIG_SDIO_MUXBUS is not set +# CONFIG_MTD 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_16550_UART is not set +CONFIG_ARCH_HAVE_UART0=y +CONFIG_ARCH_HAVE_UART1=y +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_UART0_SERIAL_CONSOLE=y +# CONFIG_UART1_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART0 Configuration +# +CONFIG_UART0_RXBUFSIZE=256 +CONFIG_UART0_TXBUFSIZE=256 +CONFIG_UART0_BAUD=38400 +CONFIG_UART0_BITS=8 +CONFIG_UART0_PARITY=0 +CONFIG_UART0_2STOP=0 + +# +# UART1 Configuration +# +CONFIG_UART1_RXBUFSIZE=256 +CONFIG_UART1_TXBUFSIZE=256 +CONFIG_UART1_BAUD=38400 +CONFIG_UART1_BITS=8 +CONFIG_UART1_PARITY=0 +CONFIG_UART1_2STOP=0 +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration # CONFIG_FS_FAT=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y CONFIG_FAT_MAXFNAME=32 -CONFIG_FS_NXFFS=n -CONFIG_FS_ROMFS=n +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set # -# Maintain legacy build behavior (revisit) +# System Logging # +# CONFIG_SYSLOG is not set -CONFIG_MMCSD=y -CONFIG_MMCSD_SPI=y -CONFIG_MMCSD_SDIO=y +# +# Graphics Support +# +# CONFIG_NX is not set # -# SPI-based MMC/SD driver +# Memory Management # -CONFIG_MMCSD_NSLOTS=1 -CONFIG_MMCSD_READONLY=n -#CONFIG_MMCSD_SPICLOCK=20000000 +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_GRAN is not set # -# SPI-based MMC/SD driver +# Binary Formats # -CONFIG_MMCSD_NSLOTS=1 -CONFIG_MMCSD_READONLY=n +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set # -# TCP/IP and UDP support via uIP +# Library Routines # -CONFIG_NET=n -CONFIG_NET_IPv6=n -CONFIG_NSOCKET_DESCRIPTORS=0 -CONFIG_NET_SOCKOPTS=y -CONFIG_NET_BUFSIZE=420 -CONFIG_NET_TCP=n -CONFIG_NET_TCP_CONNS=40 -CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_UDP=n -CONFIG_NET_UDP_CHECKSUMS=y -#CONFIG_NET_UDP_CONNS=10 -CONFIG_NET_ICMP=n -CONFIG_NET_ICMP_PING=n -#CONFIG_NET_PINGADDRCONF=0 -CONFIG_NET_STATISTICS=y -#CONFIG_NET_RECEIVE_WINDOW= -#CONFIG_NET_ARPTAB_SIZE=8 -CONFIG_NET_BROADCAST=n # -# UIP Network Utilities +# Standard C Library Options # -CONFIG_NET_DHCP_LIGHT=n -CONFIG_NET_RESOLV_ENTRIES=4 +CONFIG_STDIO_BUFFER_SIZE=256 +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_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_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set # -# USB Device Configuration +# Non-standard Helper Functions # -CONFIG_USBDEV=n -CONFIG_USBDEV_ISOCHRONOUS=n -CONFIG_USBDEV_DUALSPEED=n -CONFIG_USBDEV_SELFPOWERED=y -CONFIG_USBDEV_REMOTEWAKEUP=n -CONFIG_USBDEV_MAXPOWER=100 -CONFIG_USBDEV_TRACE=n -CONFIG_USBDEV_TRACE_NRECORDS=128 +CONFIG_LIB_KBDCODEC=y # -# LPC214X USB Configuration +# Basic CXX Support # -CONFIG_LPC214X_USBDEV_FRAME_INTERRUPT=n -CONFIG_LPC214X_USBDEV_EPFAST_INTERRUPT=n -CONFIG_LPC214X_USBDEV_DMA=n -CONFIG_LPC214X_USBDEV_NDMADESCRIPTORS=0 -CONFIG_LPC214X_USBDEV_DMAINTMASK=0 +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set # -# USB Serial Device Configuration +# Application Configuration # -CONFIG_PL2303=n -CONFIG_PL2303_EPINTIN=1 -CONFIG_PL2303_EPBULKOUT=2 -CONFIG_PL2303_EPBULKIN=5 -CONFIG_PL2303_NWRREQS=4 -CONFIG_PL2303_NRDREQS=4 -CONFIG_PL2303_VENDORID=0x067b -CONFIG_PL2303_PRODUCTID=0x2303 -CONFIG_PL2303_VENDORSTR="Nuttx" -CONFIG_PL2303_PRODUCTSTR="USBdev Serial" -CONFIG_PL2303_RXBUFSIZE=512 -CONFIG_PL2303_TXBUFSIZE=512 # -# USB Storage Device Configuration +# Built-In Applications +# +# CONFIG_BUILTIN is not set + # -CONFIG_USBMSC=n -CONFIG_USBMSC_EP0MAXPACKET=64 -CONFIG_USBMSC_EPBULKOUT=2 -CONFIG_USBMSC_EPBULKIN=5 -CONFIG_USBMSC_NRDREQS=2 -CONFIG_USBMSC_NWRREQS=2 -CONFIG_USBMSC_BULKINREQLEN=256 -CONFIG_USBMSC_BULKOUTREQLEN=256 -CONFIG_USBMSC_VENDORID=0x584e -CONFIG_USBMSC_VENDORSTR="NuttX" -CONFIG_USBMSC_PRODUCTID=0x5342 -CONFIG_USBMSC_PRODUCTSTR="USBdev Storage" -CONFIG_USBMSC_VERSIONNO=0x0399 -CONFIG_USBMSC_REMOVABLE=y +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WLAN is not set # -# Settings for examples/ostest -CONFIG_EXAMPLES_OSTEST_LOOPS=1 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=4096 -CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 +# Interpreters +# # -# Settings for apps/nshlib +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + # +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DD 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_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_LS is not set +# 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 +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSFMOUNT is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING 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_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT 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_CODECS_BUFSIZE=128 CONFIG_NSH_FILEIOSIZE=512 -CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 CONFIG_NSH_NESTDEPTH=3 -CONFIG_NSH_DISABLESCRIPT=n -CONFIG_NSH_DISABLEBG=n -CONFIG_NSH_ROMFSETC=n +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLEBG is not set CONFIG_NSH_CONSOLE=y -CONFIG_NSH_TELNET=n +# CONFIG_NSH_CONDEV is not set CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_IOBUFFER_SIZE=512 -CONFIG_NSH_DHCPC=n -CONFIG_NSH_NOMAC=n -CONFIG_NSH_IPADDR=0x0a000002 -CONFIG_NSH_DRIPADDR=0x0a000001 -CONFIG_NSH_NETMASK=0xffffff00 -CONFIG_NSH_ROMFSMOUNTPT="/etc" -CONFIG_NSH_INITSCRIPT="init.d/rcS" -CONFIG_NSH_ROMFSDEVNO=0 -CONFIG_NSH_ROMFSSECTSIZE=64 -CONFIG_NSH_FATDEVNO=1 -CONFIG_NSH_FATSECTSIZE=512 -CONFIG_NSH_FATNSECTORS=1024 -CONFIG_NSH_FATMOUNTPT="/tmp" - -# -# Architecture-specific NSH options -CONFIG_NSH_MMCSDSPIPORTNO=1 -CONFIG_NSH_MMCSDSLOTNO=0 -CONFIG_NSH_MMCSDMINOR=0 # -# Stack and heap information +# NxWidgets/NxWM # -CONFIG_BOOT_RUNFROMFLASH=n -CONFIG_BOOT_COPYTORAM=n -CONFIG_CUSTOM_STACK=n -CONFIG_IDLETHREAD_STACKSIZE=2048 -CONFIG_USERMAIN_STACKSIZE=2048 -CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=2048 -CONFIG_HEAP_BASE= -CONFIG_HEAP_SIZE= + +# +# System NSH Add-Ons +# + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/nuttx/configs/mcu123-lpc214x/scripts/ld.script b/nuttx/configs/mcu123-lpc214x/scripts/ld.script index 8ce83748f..bc025dfb7 100644 --- a/nuttx/configs/mcu123-lpc214x/scripts/ld.script +++ b/nuttx/configs/mcu123-lpc214x/scripts/ld.script @@ -35,12 +35,12 @@ /* FLASH: * The lpc2148 has 512Kb of non-volatile memory beginning at address - * 0x00000000. The OS entry point is via the reset vector at address - * 0x00000000 (default MEMMAP mode assumed) + * 0x0000:0000. The OS entry point is via the reset vector at address + * 0x0000:0000 (default MEMMAP mode assumed) * * SRAM: * The lpc2148 has 32Kb of on-chip static RAM beginning at address - * 0x40000000. The .data section will be relocated from _eronly + * 0x4000:0000. The .data section will be relocated from _eronly * to _sdata at boot time. */ diff --git a/nuttx/configs/sim/nxlines/Make.defs b/nuttx/configs/sim/nxlines/Make.defs new file mode 100644 index 000000000..18c8bf537 --- /dev/null +++ b/nuttx/configs/sim/nxlines/Make.defs @@ -0,0 +1,107 @@ +############################################################################ +# configs/sim/nxlines/Make.defs +# +# Copyright (C) 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. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk + +HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = -O2 +endif + +ARCHCPUFLAGS = -fno-builtin +ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fno-rtti +ARCHPICFLAGS = -fpic +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = +ARCHINCLUDES = -I. -isystem $(TOPDIR)/include +ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx +ARCHSCRIPT = + +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + +CROSSDEV = +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +OBJEXT = .o +LIBEXT = .a + +ifeq ($(HOSTOS),Cygwin) + EXEEXT = .exe +else + EXEEXT = +endif + +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 +endif + +MKDEP = $(TOPDIR)/tools/mkdeps.sh + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +HOSTLDFLAGS = diff --git a/nuttx/configs/sim/nxlines/defconfig b/nuttx/configs/sim/nxlines/defconfig new file mode 100644 index 000000000..c023af674 --- /dev/null +++ b/nuttx/configs/sim/nxlines/defconfig @@ -0,0 +1,591 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_HOST_LINUX is not set +# CONFIG_HOST_OSX 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 +# +CONFIG_APPS_DIR="../apps" +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +# CONFIG_RAW_BINARY is not set + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set +CONFIG_DEBUG_SYMBOLS=y + +# +# System Type +# +# CONFIG_ARCH_8051 is not set +# CONFIG_ARCH_ARM is not set +# 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=y +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="sim" +CONFIG_BOARD_LOOPSPERMSEC= + +# +# Simulation Configuration Options +# +# CONFIG_SIM_M32 is not set +# CONFIG_SIM_WALLTIME is not set +CONFIG_SIM_FRAMEBUFFER=y +CONFIG_SIM_X11FB=y +# CONFIG_SIM_X11NOSHM is not set +CONFIG_SIM_FBHEIGHT=240 +CONFIG_SIM_FBWIDTH=480 +CONFIG_SIM_FBBPP=32 + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_IRQPRIO is not set +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +# CONFIG_ARCH_STACKDUMP is not set +# CONFIG_ENDIAN_BIG is not set + +# +# Board Settings +# +CONFIG_DRAM_START= +CONFIG_DRAM_SIZE= + +# +# 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 + +# +# Board Selection +# +CONFIG_ARCH_BOARD_SIM=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="sim" + +# +# Common Board Options +# +CONFIG_NSH_MMCSDMINOR=0 + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=0 +# CONFIG_SCHED_INSTRUMENTATION is not set +CONFIG_TASK_NAME_SIZE=32 +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2012 +CONFIG_START_MONTH=5 +CONFIG_START_DAY=1 +CONFIG_DEV_CONSOLE=y +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +CONFIG_SCHED_WAITPID=y +# CONFIG_SCHED_ATEXIT is not set +CONFIG_SCHED_ONEXIT=y +CONFIG_SCHED_ONEXIT_MAX=1 +CONFIG_USER_ENTRYPOINT="nxlines_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +CONFIG_DISABLE_POSIX_TIMERS=y +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set +CONFIG_DISABLE_POLL=y + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=16 +CONFIG_NFILE_STREAMS=16 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=32 +CONFIG_MQ_MAXMSGSIZE=48 +CONFIG_MAX_WDOGPARMS=4 +CONFIG_PREALLOC_WDOGS=32 +CONFIG_PREALLOC_TIMERS=8 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_USERMAIN_STACKSIZE=16384 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=8192 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD 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_16550_UART is not set +# CONFIG_STANDARD_SERIAL is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration +# +CONFIG_FS_FAT=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_NXFFS is not set +CONFIG_FS_ROMFS=y + +# +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Graphics Support +# +CONFIG_NX=y +CONFIG_NX_NPLANES=1 +# CONFIG_NX_WRITEONLY is not set + +# +# Supported Pixel Depths +# +CONFIG_NX_DISABLE_1BPP=y +CONFIG_NX_DISABLE_2BPP=y +CONFIG_NX_DISABLE_4BPP=y +CONFIG_NX_DISABLE_8BPP=y +CONFIG_NX_DISABLE_16BPP=y +CONFIG_NX_DISABLE_24BPP=y +# CONFIG_NX_DISABLE_32BPP is not set +# CONFIG_NX_PACKEDMSFIRST is not set + +# +# Input Devices +# +CONFIG_NX_MOUSE=y +CONFIG_NX_KBD=y + +# +# Framed Window Borders +# +CONFIG_NXTK_BORDERWIDTH=4 +CONFIG_NXTK_BORDERCOLOR1=0x005a96bd +CONFIG_NXTK_BORDERCOLOR2=0x00233a49 +CONFIG_NXTK_BORDERCOLOR3=0x00f8f8f8 +# CONFIG_NXTK_AUTORAISE is not set + +# +# Font Selections +# +CONFIG_NXFONTS_CHARBITS=7 +# CONFIG_NXFONT_SANS17X22 is not set +# CONFIG_NXFONT_SANS20X26 is not set +CONFIG_NXFONT_SANS23X27=y +# CONFIG_NXFONT_SANS22X29 is not set +# CONFIG_NXFONT_SANS28X37 is not set +# CONFIG_NXFONT_SANS39X48 is not set +# CONFIG_NXFONT_SANS17X23B is not set +# CONFIG_NXFONT_SANS20X27B is not set +# CONFIG_NXFONT_SANS22X29B is not set +CONFIG_NXFONT_SANS28X37B=y +# CONFIG_NXFONT_SANS40X49B is not set +# CONFIG_NXFONT_SERIF22X29 is not set +# CONFIG_NXFONT_SERIF29X37 is not set +# CONFIG_NXFONT_SERIF38X48 is not set +# CONFIG_NXFONT_SERIF22X28B is not set +# CONFIG_NXFONT_SERIF27X38B is not set +# CONFIG_NXFONT_SERIF38X49B is not set +# CONFIG_NXCONSOLE is not set + +# +# NX Multi-user only options +# +# CONFIG_NX_MULTIUSER is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_GRAN is not set + +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=256 +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_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_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set + +# +# Non-standard Helper Functions +# +CONFIG_LIB_KBDCODEC=y + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +# CONFIG_HAVE_CXXINITIALIZE is not set +# CONFIG_CXX_NEWLONG is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +# CONFIG_BUILTIN is not set + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +# CONFIG_EXAMPLES_NSH is not set +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +CONFIG_EXAMPLES_NXLINES=y +CONFIG_EXAMPLES_NXLINES_VPLANE=0 +CONFIG_EXAMPLES_NXLINES_DEVNO=0 +CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x00006400 +CONFIG_EXAMPLES_NXLINES_LINEWIDTH=16 +CONFIG_EXAMPLES_NXLINES_LINECOLOR=0x00ffff00 +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=16 +CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0x00ffff00 +CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0x00f5f5dc +CONFIG_EXAMPLES_NXLINES_BPP=32 +# CONFIG_EXAMPLES_NXLINES_EXTERNINIT is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WLAN is not set + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DD 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_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_LS is not set +# 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 +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSFMOUNT is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING 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_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT 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_CODECS_BUFSIZE=128 +CONFIG_NSH_FILEIOSIZE=1024 +CONFIG_NSH_LINELEN=80 +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_ROMFSMOUNTPT="/etc" +CONFIG_NSH_INITSCRIPT="init.d/rcS" +CONFIG_NSH_ROMFSDEVNO=1 +CONFIG_NSH_ROMFSSECTSIZE=64 +CONFIG_NSH_FATDEVNO=2 +CONFIG_NSH_FATSECTSIZE=512 +CONFIG_NSH_FATNSECTORS=1024 +CONFIG_NSH_FATMOUNTPT="/tmp" +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_CONDEV is not set +# CONFIG_NSH_ARCHINIT is not set + +# +# NxWidgets/NxWM +# +# CONFIG_NXWIDGETS is not set + +# +# System NSH Add-Ons +# + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/nuttx/configs/sim/nxlines/setenv.sh b/nuttx/configs/sim/nxlines/setenv.sh new file mode 100755 index 000000000..0722cbc2e --- /dev/null +++ b/nuttx/configs/sim/nxlines/setenv.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# sim/nxlines/setenv.sh +# +# Copyright (C) 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 + +#export NUTTX_BIN= +#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG} + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/zp214xpa/Kconfig b/nuttx/configs/zp214xpa/Kconfig new file mode 100644 index 000000000..d8d04ca5c --- /dev/null +++ b/nuttx/configs/zp214xpa/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +if ARCH_BOARD_ZP214XPA +endif diff --git a/nuttx/configs/zp214xpa/README.txt b/nuttx/configs/zp214xpa/README.txt new file mode 100644 index 000000000..6fd7bfba9 --- /dev/null +++ b/nuttx/configs/zp214xpa/README.txt @@ -0,0 +1,136 @@ +zp214xpa README FILE +==================== + +The ZP213X/4XPA board from the0.net with LPC2148 installed. +Includes support for the UG-2864AMBAG01 OLED from The0.net. + +Contents +======== + + o MCU Connections + o Serial Console + o Configurations + +MCU Connections: +================ + +Module Socket: +-------------- +PIN NAME PIN NAME + 1 VBAT 56 VCC + 2 3V3 55 Vusb + 3 VREF 54 3V3 + 4 P0.0 53 RESET + 5 P0.1 52 P1.31 + 6 P0.2 51 P1.30 + 7 P0.3 50 P1.29 + 8 P0.4 49 P1.28 + 9 P0.5 48 P1.27 +10 P0.6 47 P1.26 +11 P0.7 46 P1.25 +12 P0.8 45 P1.24 +13 P0.9 44 P1.23 +14 P0.10 43 P1.22 +15 P0.11 42 P1.21 +16 P0.12 41 P1.20 +17 P0.13 40 P1.19 +18 P0.14 39 P1.18 +19 P0.15 38 P1.17 +20 P0.16 37 P1.16 +21 P0.17 36 P0.31 +22 P0.18 35 P0.30 +23 P0.19 34 P0.29 +24 P0.20 33 P0.28 +25 P0.21 32 P0.27 +26 P0.22 31 P0.26 +27 P0.23 30 P0.25 +28 GND 29 GND + +JTAG Debug: +----------- +PIN NAME PIN NAME + 1 VCC1 2 3V3 + 3 P1.31 NTRST 4 GND + 5 P1.28 TDI 6 GND + 7 P1.30 TMS 8 GND + 9 P1.29 TCK 10 GND +11 P1.26 RTCK 12 GND +13 P1.27 TDO 14 GND +15 RESET NRTS 16 GND +17 N/C NC0 18 GND +19 N/C NC1 20 GND + +Z28160 Net Module: +------------------ +PIN NAME PIN NAME + 1 P0.7 /CS 10 3V3 VCC + 2 P0.4 SCK 9 P1.24 RST + 3 P0.6 SI 8 N/C CLKOUT + 4 P0.5 SO 7 INT P1.25 + 5 GND 6 N/C WOL + +SPI LCD: +-------- +PIN NAME + 1 3V3 3V3 + 2 VCC 5V + 3 P0.18 RESET(DO) + 4 P0.19 DI + 5 P0.20 CS + 6 P0.17 SCK + 7 P0.23 A0(RESET) + 8 N/C LED- + 9 N/C LED+(BL) +10 GND GND + +USB Interface: +-------------- +Vusb, P0.26, P0.27 + +Serial Console: +=============== + +Both UART0 and UART1 are always enabled. UART0 is configured to be the +serial console in these configurations. + +P0.0/TXD0/PWM1 Module Socket, Pin 4 +P0.1/RxD0/PWM3/EINT0 Module Socket, Pin 5 + +P0.8/TXD1/PWM4/AD1.1 Module Socket, Pin 12 +P0.9/RxD1/PWM6/EINT3 Module Socket, Pin 13 + +Configurations: +=============== + +Each NXP LPC214x configuration is maintained in a sudirectory and +can be selected as follow: + + cd tools + ./configure.sh zp214xpa/ + cd - + . ./setenv.sh + +Where is one of the following: + +nsh: +---- + + Configures the NuttShell (nsh) located at examples/nsh. The + Configuration enables only the serial NSH interfaces. + + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the mconf tool. See nuttx/README.txt and + misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Default platform/toolchain: + + CONFIG_HOST_LINUX=y : Windows + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Buildroot (arm-nuttx-elf-gcc) + CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary diff --git a/nuttx/configs/zp214xpa/include/board.h b/nuttx/configs/zp214xpa/include/board.h new file mode 100644 index 000000000..111d8ad55 --- /dev/null +++ b/nuttx/configs/zp214xpa/include/board.h @@ -0,0 +1,68 @@ +/**************************************************************************** + * configs/zp214xpa/include/board.h + * + * Copyright (C) 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. + * + ****************************************************************************/ + +#ifndef __CONFIGS_ZP214XPA_INCLUDE_BOARD_H +#define __CONFIGS_ZP214XPA_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* Oscillator frequency */ + +#define LPC214X_FOSC 12000000 + +/* PLL0 settings CCLK = PLL_M * FOSC PCLK = CCLK/APBDIV */ + +#define LPC214X_PLL_M 5 +#define LPC214X_PLL_P 2 +#define LPC214X_APB_DIV 1 + +/* USB Pll settings -- 48 MHz needed. FUSB = PLL_M FOSC */ + +#define LPC214X_USBPLL_M 4 +#define LPC214X_USBPLL_P 2 + +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +#endif /* __CONFIGS_ZP214XPA_INCLUDE_BOARD_H */ diff --git a/nuttx/configs/zp214xpa/nsh/Make.defs b/nuttx/configs/zp214xpa/nsh/Make.defs new file mode 100644 index 000000000..f55e766d3 --- /dev/null +++ b/nuttx/configs/zp214xpa/nsh/Make.defs @@ -0,0 +1,128 @@ +############################################################################## +# configs/zp214xpa/nsh/Make.defs +# +# Copyright (C) 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. +# +############################################################################## + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk + +# The default value for CROSSDEV can be overridden from the make command line: +# make -- Will build for the NuttX buildroot toolchain +# make CROSSDEV=arm-eabi- -- Will build for the devkitARM toolchain +# make CROSSDEV=arm-none-eabi- -- Will build for the CodeSourcery toolchain +# make CROSSDEV=arm-nuttx-elf- -- Will build for the NuttX buildroot toolchain + +CROSSDEV = arm-nuttx-elf- +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"} + +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 ($(ARCHCCMAJOR),4) +ifneq ($(HOSTOS),Cygwin) +OBJCOPYARGS = -R .note -R .note.gnu.build-id -R .comment +endif +endif + +ifeq ($(CROSSDEV),arm-nuttx-elf-) + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/ld.script + MAXOPTIMIZATION = -Os +else + WINTOOL = y + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/ld.script}" + MAXOPTIMIZATION = -O2 +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ifeq ($(ARCHCCMAJOR),4) + ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft +else + ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = + +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-gotoff.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +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 -g -pipe +HOSTLDFLAGS = diff --git a/nuttx/configs/zp214xpa/nsh/defconfig b/nuttx/configs/zp214xpa/nsh/defconfig new file mode 100644 index 000000000..7c7d9d06c --- /dev/null +++ b/nuttx/configs/zp214xpa/nsh/defconfig @@ -0,0 +1,574 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL 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_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_SYMBOLS is not set + +# +# System Type +# +# CONFIG_ARCH_8051 is not set +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_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_IMX is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_LM3S is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +CONFIG_ARCH_CHIP_LPC214X=y +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_SAM3U is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STR71X is not set +CONFIG_ARCH_ARM7TDMI=y +CONFIG_ARCH_FAMILY="arm" +CONFIG_ARCH_CHIP="lpc214x" +CONFIG_ARCH_HAVE_LOWVECTORS=y +# CONFIG_ARCH_LOWVECTORS is not set +CONFIG_BOARD_LOOPSPERMSEC=3270 +# CONFIG_ARCH_CALIBRATION is not set + +# +# ARM Configuration Options +# +# CONFIG_ARM_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARM_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARM_TOOLCHAIN_GNU_EABI=y + +# +# LPC214x Configuration Options +# +CONFIG_ARCH_CHIP_LPC2148=y + +# +# LPC214x Initialization Options +# +# CONFIG_EXTMEM_MODE is not set +# CONFIG_RAM_MODE is not set +CONFIG_DEFAULT_MODE=y +CONFIG_CODE_BASE=0x00000000 +CONFIG_PLL_SETUP=y +CONFIG_MAM_SETUP=y +CONFIG_APBDIV_SETUP=y +CONFIG_APBDIV_VALUE=1 +# CONFIG_EMC_SETUP is not set +# CONFIG_BCFG0_SETUP is not set +# CONFIG_BCFG1_SETUP is not set +# CONFIG_BCFG2_SETUP is not set +# CONFIG_BCFG3_SETUP is not set +CONFIG_ADC_SETUP=y + +# +# LPC214x Peripheral Support +# +CONFIG_LPC214X_UART0=y +CONFIG_LPC214X_UART1=y +# CONFIG_LPC214x_FIO is not set + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_IRQPRIO is not set +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set + +# +# Board Settings +# +CONFIG_DRAM_START=0x40000000 +CONFIG_DRAM_SIZE=32768 +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 + +# +# 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 + +# +# Board Selection +# +# CONFIG_ARCH_BOARD_MCU123 is not set +CONFIG_ARCH_BOARD_ZP214XPA=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="zp214xpa" + +# +# Common Board Options +# +CONFIG_NSH_MMCSDMINOR=0 + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=0 +# CONFIG_SCHED_INSTRUMENTATION is not set +CONFIG_TASK_NAME_SIZE=0 +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2008 +CONFIG_START_MONTH=10 +CONFIG_START_DAY=1 +CONFIG_DEV_CONSOLE=y +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_WAITPID is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# 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_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set +CONFIG_DISABLE_POLL=y + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD 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_16550_UART is not set +CONFIG_ARCH_HAVE_UART0=y +CONFIG_ARCH_HAVE_UART1=y +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_UART0_SERIAL_CONSOLE=y +# CONFIG_UART1_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART0 Configuration +# +CONFIG_UART0_RXBUFSIZE=256 +CONFIG_UART0_TXBUFSIZE=256 +CONFIG_UART0_BAUD=38400 +CONFIG_UART0_BITS=8 +CONFIG_UART0_PARITY=0 +CONFIG_UART0_2STOP=0 + +# +# UART1 Configuration +# +CONFIG_UART1_RXBUFSIZE=256 +CONFIG_UART1_TXBUFSIZE=256 +CONFIG_UART1_BAUD=38400 +CONFIG_UART1_BITS=8 +CONFIG_UART1_PARITY=0 +CONFIG_UART1_2STOP=0 +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_FS_FAT is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set + +# +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_GRAN is not set + +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=256 +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_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_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set + +# +# Non-standard Helper Functions +# +CONFIG_LIB_KBDCODEC=y + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +# CONFIG_BUILTIN is not set + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WLAN is not set + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DD 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_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_LS is not set +# 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 +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSFMOUNT is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING 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_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT 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_CODECS_BUFSIZE=128 +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_CONDEV is not set +# CONFIG_NSH_ARCHINIT is not set + +# +# NxWidgets/NxWM +# + +# +# System NSH Add-Ons +# + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/nuttx/configs/zp214xpa/nsh/setenv.sh b/nuttx/configs/zp214xpa/nsh/setenv.sh new file mode 100755 index 000000000..724dab706 --- /dev/null +++ b/nuttx/configs/zp214xpa/nsh/setenv.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# configs/zp214xpa/nsh/setenv.sh +# +# Copyright (C) 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 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" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# The zp214xpa/tools directory +export LPCTOOL_DIR="${WD}/configs/zp214xpa/tools" + +# Add the path to the toolchain and tools directory to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:${LPCTOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/zp214xpa/scripts/ld.script b/nuttx/configs/zp214xpa/scripts/ld.script new file mode 100644 index 000000000..ba6ff8f2c --- /dev/null +++ b/nuttx/configs/zp214xpa/scripts/ld.script @@ -0,0 +1,120 @@ +/**************************************************************************** + * configs/zp214xpa/scripts/ld.script + * + * Copyright (C) 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. + * + ****************************************************************************/ + +/* FLASH: + * The lpc2148 has 512Kb of non-volatile memory beginning at address + * 0x0000:0000. The OS entry point is via the reset vector at address + * 0x0000:0000 (default MEMMAP mode assumed) + * + * SRAM: + * The lpc2148 has 32Kb of on-chip static RAM beginning at address + * 0x4000:0000. The .data section will be relocated from _eronly + * to _sdata at boot time. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00000000, LENGTH = 500K + sram (rw) : ORIGIN = 0x40000000, LENGTH = 32K - 32 +} + +OUTPUT_ARCH(arm) +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/nuttx/configs/zp214xpa/src/Makefile b/nuttx/configs/zp214xpa/src/Makefile new file mode 100644 index 000000000..8f1e1c05d --- /dev/null +++ b/nuttx/configs/zp214xpa/src/Makefile @@ -0,0 +1,84 @@ +############################################################################ +# configs/zp214xpa/src/Makefile +# +# Copyright (C) 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src +ifeq ($(WINTOOL),y) + CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/arm}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/sched}" +else + CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/arm -I$(TOPDIR)/sched +endif + +ASRCS = +AOBJS = $(ASRCS:.S=$(OBJEXT)) +CSRCS = + +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +CFLAGS += -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src + +all: libboard$(LIBEXT) + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +libboard$(LIBEXT): $(OBJS) + $(call ARCHIVE, $@, $(OBJS)) + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, libboard$(LIBEXT)) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/nuttx/drivers/mmcsd/Kconfig b/nuttx/drivers/mmcsd/Kconfig index c224f220a..f3a64be6c 100644 --- a/nuttx/drivers/mmcsd/Kconfig +++ b/nuttx/drivers/mmcsd/Kconfig @@ -2,6 +2,7 @@ # For a description of the syntax of this configuration file, # see misc/tools/kconfig-language.txt. # + config MMCSD_NSLOTS int "Number of MMC/SD slots" default 1 diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index 0bab89c28..d6a9ceda3 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -421,7 +421,7 @@ static const uint8_t encoding[USBHID_NUMENCODINGS] = KEYCODE_ENTER, 0, KEYCODE_FWDDEL, KEYCODE_BACKDEL, 0, 0, 0, 0, - /* 0x30-0x37: },|,Non-US tilde,:,",grave tidle,<,> */ + /* 0x30-0x37: },|,Non-US tilde,:,",grave tilde,<,> */ 0, 0, 0, 0, 0, 0, 0, 0, @@ -525,7 +525,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] = 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', /* 0x18-0x1f: U-Z,!,@ */ '#', '$', '%', '^', '&', '*', '(', ')', /* 0x20-0x27: #,$,%,^,&,*,(,) */ '\n', '\033', '\177', 0, ' ', '_', '+', '{', /* 0x28-0x2f: Enter,escape,del,back-tab,space,_,+,{ */ - '}', '|', 0, ':', '"', 0, '<', '>', /* 0x30-0x37: },|,Non-US tilde,:,",grave tidle,<,> */ + '}', '|', 0, ':', '"', '~', '<', '>', /* 0x30-0x37: },|,Non-US tilde,:,",grave tilde,<,> */ '?', 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ @@ -560,7 +560,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] = 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', /* 0x18-0x1f: u-z,1-2 */ '3', '4', '5', '6', '7', '8', '9', '0', /* 0x20-0x27: 3-9,0 */ '\n', '\033', '\177', '\t', ' ', '-', '=', '[', /* 0x28-0x2f: Enter,escape,del,tab,space,-,=,[ */ - ']', '\\', '\234', ';', '\'', 0, ',', '.', /* 0x30-0x37: ],\,Non-US pound,;,',grave accent,,,. */ + ']', '\\', '\234', ';', '\'', '`', ',', '.', /* 0x30-0x37: ],\,Non-US pound,;,',grave accent,,,. */ '/', 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */ -- cgit v1.2.3 From e88ff3cdfaf26f8dec8f2d634cb3bc4390c6c464 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 30 Dec 2012 21:12:43 +0000 Subject: Fix the nxlines configuration for the zp214xpa board git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5467 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/nxlines/nxlines_main.c | 1 + nuttx/ChangeLog | 6 ++-- nuttx/configs/mcu123-lpc214x/src/up_spi1.c | 26 +++++++--------- nuttx/configs/zp214xpa/README.txt | 2 ++ nuttx/configs/zp214xpa/src/up_spi1.c | 44 ++++++++++++++++++--------- nuttx/configs/zp214xpa/src/up_ug2864ambag01.c | 29 ++++++++++++------ nuttx/drivers/lcd/ug-2864ambag01.c | 4 +-- 7 files changed, 68 insertions(+), 44 deletions(-) (limited to 'apps') diff --git a/apps/examples/nxlines/nxlines_main.c b/apps/examples/nxlines/nxlines_main.c index 331fab631..e4632bb21 100644 --- a/apps/examples/nxlines/nxlines_main.c +++ b/apps/examples/nxlines/nxlines_main.c @@ -191,6 +191,7 @@ static inline int nxlines_initialize(void) g_nxlines.code = NXEXIT_NXOPEN; return ERROR; } + return OK; } diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 56cc5515d..daa1e068c 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3843,6 +3843,6 @@ * configs/sim/nxlines: Add an nxlines configuration for the simulator. * configs/zp214xpa/nxlines: Add an nxlines configuration for the - ZP213x/4xPA (with the LPC2148 and the UG_2864AMBAG01). As of this - writing (2012-12-30), I see only garbage on the display each time - the display is updated. + ZP213x/4xPA (with the LPC2148 and the UG_2864AMBAG01). Working + as of 2012-12-30. + diff --git a/nuttx/configs/mcu123-lpc214x/src/up_spi1.c b/nuttx/configs/mcu123-lpc214x/src/up_spi1.c index 61abee20a..c10144d88 100644 --- a/nuttx/configs/mcu123-lpc214x/src/up_spi1.c +++ b/nuttx/configs/mcu123-lpc214x/src/up_spi1.c @@ -85,20 +85,16 @@ * Definitions ****************************************************************************/ -/* Enables debug output from this file (needs CONFIG_DEBUG too) */ +/* Enables debug output from this file */ -#undef SPI_DEBUG /* Define to enable debug */ -#undef SPI_VERBOSE /* Define to enable verbose debug */ - -#ifdef SPI_DEBUG +#ifdef CONFIG_DEBUG_SPI # define spidbg lldbg -# ifdef SPI_VERBOSE +# ifdef CONFIG_DEBUG_VERBOSE # define spivdbg lldbg # else # define spivdbg(x...) # endif #else -# undef SPI_VERBOSE # define spidbg(x...) # define spivdbg(x...) #endif @@ -125,17 +121,17 @@ ****************************************************************************/ #ifndef CONFIG_SPI_OWNBUS -static int spi_lock(FAR struct spi_dev_s *dev, bool lock); +static int spi_lock(FAR struct spi_dev_s *dev, bool lock); #endif -static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); +static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency); -static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid); +static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid); #ifdef CONFIG_SPI_CMDDATA -static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); +static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); #endif static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t ch); -static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords); -static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords); +static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords); +static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords); /**************************************************************************** * Private Data @@ -224,14 +220,14 @@ static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sel { /* Enable slave select (low enables) */ - spidbg("CD asserted\n"); + spidbg("CS asserted\n"); putreg32(bit, CS_CLR_REGISTER); } else { /* Disable slave select (low enables) */ - spidbg("CD de-asserted\n"); + spidbg("CS de-asserted\n"); putreg32(bit, CS_SET_REGISTER); /* Wait for the TX FIFO not full indication */ diff --git a/nuttx/configs/zp214xpa/README.txt b/nuttx/configs/zp214xpa/README.txt index 9f577b98d..58a2242d0 100644 --- a/nuttx/configs/zp214xpa/README.txt +++ b/nuttx/configs/zp214xpa/README.txt @@ -338,3 +338,5 @@ Configurations: CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Buildroot (arm-nuttx-elf-gcc) CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary + + 3. Verified as of this writing (2012-12-30). diff --git a/nuttx/configs/zp214xpa/src/up_spi1.c b/nuttx/configs/zp214xpa/src/up_spi1.c index 563d63589..1ee1cac32 100644 --- a/nuttx/configs/zp214xpa/src/up_spi1.c +++ b/nuttx/configs/zp214xpa/src/up_spi1.c @@ -86,20 +86,16 @@ * Definitions ****************************************************************************/ -/* Enables debug output from this file (needs CONFIG_DEBUG too) */ +/* Enables debug output from this file */ -#undef SPI_DEBUG /* Define to enable debug */ -#undef SPI_VERBOSE /* Define to enable verbose debug */ - -#ifdef SPI_DEBUG +#ifdef CONFIG_DEBUG_SPI # define spidbg lldbg -# ifdef SPI_VERBOSE +# ifdef CONFIG_DEBUG_VERBOSE # define spivdbg lldbg # else # define spivdbg(x...) # endif #else -# undef SPI_VERBOSE # define spidbg(x...) # define spivdbg(x...) #endif @@ -112,10 +108,12 @@ /* Use either FIO or legacy GPIO */ #ifdef CONFIG_LPC214x_FIO +# define CS_PIN_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_PIN_OFFSET) # define CS_SET_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_SET_OFFSET) # define CS_CLR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_CLR_OFFSET) # define CS_DIR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_DIR_OFFSET) #else +# define CS_PIN_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_PIN_OFFSET) # define CS_SET_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_SET_OFFSET) # define CS_CLR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_CLR_OFFSET) # define CS_DIR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_DIR_OFFSET) @@ -130,7 +128,7 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock); #endif static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency); -static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid); +static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid); #ifdef CONFIG_SPI_CMDDATA static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); #endif @@ -193,7 +191,7 @@ static struct spi_dev_s g_spidev = { &g_spiops }; #ifndef CONFIG_SPI_OWNBUS static int spi_lock(FAR struct spi_dev_s *dev, bool lock) { - /* Not implemented */ + /* Not implemented -- the UG_2864AMBAG01 is the only device on SPI1 */ return -ENOSYS; } @@ -219,25 +217,32 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock) static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { +#ifdef CONFIG_DEBUG_SPI + uint32_t regval; +#endif uint32_t bit = 1 << 20; /* We do not bother to check if devid == SPIDEV_DISPLAY because that is the * only thing on the bus. */ +#ifdef CONFIG_DEBUG_SPI + regval = getreg32(CS_PIN_REGISTER); +#endif + if (selected) { /* Enable slave select (low enables) */ - spidbg("CD asserted\n"); putreg32(bit, CS_CLR_REGISTER); + spidbg("CS asserted: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER)); } else { /* Disable slave select (low enables) */ - spidbg("CD de-asserted\n"); putreg32(bit, CS_SET_REGISTER); + spidbg("CS de-asserted: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER)); /* Wait for the TX FIFO not full indication */ @@ -345,6 +350,9 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) #ifdef CONFIG_SPI_CMDDATA static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { +#ifdef CONFIG_DEBUG_SPI + uint32_t regval; +#endif uint32_t bit = 1 << 23; /* We do not bother to check if devid == SPIDEV_DISPLAY because that is the @@ -358,19 +366,23 @@ static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd * A0 = L: the inputs at D0 to D7 are transferred to the command registers." */ +#ifdef CONFIG_DEBUG_SPI + regval = getreg32(CS_PIN_REGISTER); +#endif + if (cmd) { /* L: the inputs at D0 to D7 are transferred to the command registers */ - spidbg("Command\n"); putreg32(bit, CS_CLR_REGISTER); + spidbg("Command: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER)); } else { /* H: the inputs at D0 to D7 are treated as display data. */ - spidbg("CD de-asserted\n"); putreg32(bit, CS_SET_REGISTER); + spidbg("Data: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER)); } return OK; @@ -606,11 +618,15 @@ FAR struct spi_dev_s *up_spiinitialize(int port) * for commands (also low) */ - regval32 = (1 << 20) || (1 << 23); + regval32 = (1 << 20) | (1 << 23); putreg32(regval32, CS_SET_REGISTER); regval32 |= getreg32(CS_DIR_REGISTER); putreg32(regval32, CS_DIR_REGISTER); + spidbg("CS Pin Config: PINSEL1: %08x PIN: %08x DIR: %08x\n", + getreg32(LPC214X_PINSEL1), getreg32(CS_PIN_REGISTER), + getreg32(CS_DIR_REGISTER)); + /* Enable peripheral clocking to SPI1 */ regval32 = getreg32(LPC214X_PCON_PCONP); diff --git a/nuttx/configs/zp214xpa/src/up_ug2864ambag01.c b/nuttx/configs/zp214xpa/src/up_ug2864ambag01.c index 164518db3..236f9fa41 100644 --- a/nuttx/configs/zp214xpa/src/up_ug2864ambag01.c +++ b/nuttx/configs/zp214xpa/src/up_ug2864ambag01.c @@ -85,13 +85,15 @@ /* Use either FIO or legacy GPIO */ #ifdef CONFIG_LPC214x_FIO -# define CS_SET_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_SET_OFFSET) -# define CS_CLR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_CLR_OFFSET) -# define CS_DIR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_DIR_OFFSET) +# define RESET_PIN_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_PIN_OFFSET) +# define RESET_SET_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_SET_OFFSET) +# define RESET_CLR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_CLR_OFFSET) +# define RESET_DIR_REGISTER (LPC214X_FIO0_BASE+LPC214X_FIO_DIR_OFFSET) #else -# define CS_SET_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_SET_OFFSET) -# define CS_CLR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_CLR_OFFSET) -# define CS_DIR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_DIR_OFFSET) +# define RESET_PIN_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_PIN_OFFSET) +# define RESET_SET_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_SET_OFFSET) +# define RESET_CLR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_CLR_OFFSET) +# define RESET_DIR_REGISTER (LPC214X_GPIO0_BASE+LPC214X_GPIO_DIR_OFFSET) #endif /* Debug ********************************************************************/ @@ -136,14 +138,21 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) /* Set the RESET line low, putting the OLED into the reset state. */ bits32 = (1 << 18); - putreg32(bits32, CS_CLR_REGISTER); - regval32 = getreg32(CS_DIR_REGISTER); - putreg32(regval32 | bits32, CS_DIR_REGISTER); + putreg32(bits32, RESET_CLR_REGISTER); + regval32 = getreg32(RESET_DIR_REGISTER); + putreg32(regval32 | bits32, RESET_DIR_REGISTER); + + lcdvdbg("RESET Pin Config: PINSEL1: %08x PIN: %08x DIR: %08x\n", + getreg32(LPC214X_PINSEL1), getreg32(RESET_PIN_REGISTER), + getreg32(RESET_DIR_REGISTER)); /* Wait a bit then release the OLED from the reset state */ up_mdelay(20); - putreg32(bits32, CS_SET_REGISTER); + putreg32(bits32, RESET_SET_REGISTER); + + lcdvdbg("RESET release: PIN: %08x DIR: %08x\n", + getreg32(RESET_PIN_REGISTER), getreg32(RESET_DIR_REGISTER)); /* Get the SPI1 port interface */ diff --git a/nuttx/drivers/lcd/ug-2864ambag01.c b/nuttx/drivers/lcd/ug-2864ambag01.c index 2a47b38eb..ca1d4c123 100644 --- a/nuttx/drivers/lcd/ug-2864ambag01.c +++ b/nuttx/drivers/lcd/ug-2864ambag01.c @@ -1148,8 +1148,8 @@ void ug2864ambag01_fill(FAR struct lcd_dev_s *dev, uint8_t color) /* Transfer one page of the selected color */ - (void)SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864AMBAG01_XRES], - UG2864AMBAG01_XRES); + (void)SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864AMBAG01_XRES], + UG2864AMBAG01_XRES); } /* De-select and unlock the device */ -- cgit v1.2.3 From 167854a980facb6f611e2610a1754903dfc12ce4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 31 Dec 2012 13:44:36 +0000 Subject: Remove non-functional WLAN examples, configurations git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5468 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 + apps/examples/Kconfig | 1 - apps/examples/Make.defs | 4 - apps/examples/Makefile | 2 +- apps/examples/wlan/Kconfig | 13 - apps/examples/wlan/Makefile | 98 ----- apps/examples/wlan/wlan_main.c | 306 --------------- nuttx/ChangeLog | 6 +- nuttx/configs/olimex-lpc1766stk/wlan/Make.defs | 109 ------ nuttx/configs/olimex-lpc1766stk/wlan/appconfig | 42 --- nuttx/configs/olimex-lpc1766stk/wlan/defconfig | 498 ------------------------- nuttx/configs/olimex-lpc1766stk/wlan/setenv.sh | 73 ---- 12 files changed, 7 insertions(+), 1147 deletions(-) delete mode 100644 apps/examples/wlan/Kconfig delete mode 100644 apps/examples/wlan/Makefile delete mode 100644 apps/examples/wlan/wlan_main.c delete mode 100644 nuttx/configs/olimex-lpc1766stk/wlan/Make.defs delete mode 100644 nuttx/configs/olimex-lpc1766stk/wlan/appconfig delete mode 100755 nuttx/configs/olimex-lpc1766stk/wlan/defconfig delete mode 100755 nuttx/configs/olimex-lpc1766stk/wlan/setenv.sh (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index d6a2f9d90..0464c6198 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -459,3 +459,5 @@ as well. However, the USB HID keyboard drier has not yet been updated to detect key release events. That is kind of tricky in the USB HID keyboard report data. + * apps/examples/wlan: Remove non-functional example. + diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index ae5f0a61a..b0cbd7088 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -58,5 +58,4 @@ source "$APPSDIR/examples/usbterm/Kconfig" source "$APPSDIR/examples/watchdog/Kconfig" source "$APPSDIR/examples/wget/Kconfig" source "$APPSDIR/examples/wgetjson/Kconfig" -source "$APPSDIR/examples/wlan/Kconfig" source "$APPSDIR/examples/xmlrpc/Kconfig" diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index 91f1331df..de2b8939f 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -254,10 +254,6 @@ ifeq ($(CONFIG_EXAMPLES_WGETJSON),y) CONFIGURED_APPS += examples/wgetjson endif -ifeq ($(CONFIG_EXAMPLES_WLAN),y) -CONFIGURED_APPS += examples/wlan -endif - ifeq ($(CONFIG_EXAMPLES_XMLRPC),y) CONFIGURED_APPS += examples/xmlrpc endif diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 50e9596d7..99312af7a 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -42,7 +42,7 @@ SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm qencoder relays SUBDIRS += rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip -SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson wlan +SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson # Sub-directories that might need context setup. Directories may need # context setup for a variety of reasons, but the most common is because diff --git a/apps/examples/wlan/Kconfig b/apps/examples/wlan/Kconfig deleted file mode 100644 index 7f8fb526a..000000000 --- a/apps/examples/wlan/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config EXAMPLES_WLAN - bool "WLAN example" - default n - ---help--- - Enable the WLAN example - -if EXAMPLES_WLAN -endif diff --git a/apps/examples/wlan/Makefile b/apps/examples/wlan/Makefile deleted file mode 100644 index 1da79736f..000000000 --- a/apps/examples/wlan/Makefile +++ /dev/null @@ -1,98 +0,0 @@ -############################################################################ -# apps/examples/wlan/Makefile -# -# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. -# Authors: Gregory Nutt -# Rafael Noronha -# -# 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)/Make.defs -include $(APPDIR)/Make.defs - -# WLAN Test - -ASRCS = -CSRCS = wlan_main.c - -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\..\libapps$(LIBEXT) -else -ifeq ($(WINTOOL),y) - BIN = ..\\..\\libapps$(LIBEXT) -else - BIN = ../../libapps$(LIBEXT) -endif -endif - -ROOTDEPPATH = --dep-path . - -# Common build - -VPATH = - -all: .built -.PHONY: clean depend distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - $(call ARCHIVE, $(BIN), $(OBJS)) - @touch .built - -context: - -.depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep - @touch $@ - -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - --include Make.dep - diff --git a/apps/examples/wlan/wlan_main.c b/apps/examples/wlan/wlan_main.c deleted file mode 100644 index aa48a0238..000000000 --- a/apps/examples/wlan/wlan_main.c +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************** - * examples/wlan/wlan_main.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * Rafael Noronha - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -/* DHCPC may be used in conjunction with any other feature (or not) */ - -#ifdef CONFIG_EXAMPLES_WLAN_DHCPC -# include -# include -# include -#endif - -/**************************************************************************** - * Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -/* Sanity checking */ - -#ifndef CONFIG_USBHOST -# error "CONFIG_USBHOST is not defined" -#endif - -#ifdef CONFIG_USBHOST_BULK_DISABLE -# error "Bulk endpoints are disabled (CONFIG_USBHOST_BULK_DISABLE)" -#endif - -#ifndef CONFIG_NFILE_DESCRIPTORS -# error "CONFIG_NFILE_DESCRIPTORS > 0 needed" -#endif - -/* Provide some default values for other configuration settings */ - -#ifndef CONFIG_EXAMPLES_WLAN_DEFPRIO -# define CONFIG_EXAMPLES_WLAN_DEFPRIO 50 -#endif - -#ifndef CONFIG_EXAMPLES_WLAN_STACKSIZE -# define CONFIG_EXAMPLES_WLAN_STACKSIZE 1024 -#endif - -#ifndef CONFIG_EXAMPLES_WLAN_DEVNAME -# define CONFIG_EXAMPLES_WLAN_DEVNAME "wlan0" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct usbhost_driver_s *g_drvr; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: wlan_bringup - * - * Description: - * Wait for USB devices to be connected. - * - ****************************************************************************/ - -static inline void wlan_bringup(void) -{ -#if defined(CONFIG_EXAMPLES_WLAN_DHCPC) || defined(CONFIG_EXAMPLES_WLAN_NOMAC) - uint8_t mac[IFHWADDRLEN]; -#endif - struct in_addr addr; -#ifdef CONFIG_EXAMPLES_WLAN_DHCPC - void *handle; -#endif - - /* Many embedded network interfaces must have a software assigned - * MAC - */ - -#ifdef CONFIG_EXAMPLES_WLAN_NOMAC - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0xde; - mac[3] = 0xad; - mac[4] = 0xbe; - mac[5] = 0xef; - uip_setmacaddr("eth0", mac); -#endif - - /* Set up the default router address */ - - addr.s_addr = HTONL(CONFIG_EXAMPLES_WLAN_DRIPADDR); - uip_setdraddr("eth0", &addr); - - /* Setup the subnet mask */ - - addr.s_addr = HTONL(CONFIG_EXAMPLES_WLAN_NETMASK); - uip_setnetmask("eth0", &addr); - - /* Set up our host address */ - -#ifdef CONFIG_EXAMPLES_WLAN_DHCPC - addr.s_addr = 0; -#else - addr.s_addr = HTONL(CONFIG_EXAMPLES_WLAN_IPADDR); -#endif - uip_sethostaddr("eth0", &addr); - -#ifdef CONFIG_EXAMPLES_WLAN_DHCPC - /* Set up the resolver */ - - resolv_init(); - - /* Get the MAC address of the NIC */ - - uip_getmacaddr("eth0", mac); - - /* Set up the DHCPC modules */ - - handle = dhcpc_open(&mac, IFHWADDRLEN); - - /* Get an IP address. Note: there is no logic here for renewing - * the address in this example. The address should be renewed in - * ds.lease_time/2 seconds. - */ - - printf("Getting IP address\n"); - if (handle) - { - struct dhcpc_state ds; - (void)dhcpc_request(handle, &ds); - uip_sethostaddr("eth1", &ds.ipaddr); - if (ds.netmask.s_addr != 0) - { - uip_setnetmask("eth0", &ds.netmask); - } - if (ds.default_router.s_addr != 0) - { - uip_setdraddr("eth0", &ds.default_router); - } - if (ds.dnsaddr.s_addr != 0) - { - resolv_conf(&ds.dnsaddr); - } - dhcpc_close(handle); - printf("IP: %s\n", inet_ntoa(ds.ipaddr)); - } -#endif -} - -/**************************************************************************** - * Name: wlan_waiter - * - * Description: - * Wait for USB devices to be connected. - * - ****************************************************************************/ - -static int wlan_waiter(int argc, char *argv[]) -{ - bool connected = false; - int ret; - - printf("wlan_waiter: Running\n"); - for (;;) - { - /* Wait for the device to change state */ - - ret = DRVR_WAIT(g_drvr, connected); - DEBUGASSERT(ret == OK); - - connected = !connected; - printf("wlan_waiter: %s\n", connected ? "connected" : "disconnected"); - - /* Did we just become connected? */ - - if (connected) - { - /* Yes.. enumerate the newly connected device */ - - ret = DRVR_ENUMERATE(g_drvr); - - /* If the enumeration was successful, then bring up the interface */ - - wlan_bringup(); - } - } - - /* Keep the compiler from complaining */ - - return 0; -} - -/**************************************************************************** - * Name: wlan_main - ****************************************************************************/ - -int wlan_main(int argc, char *argv[]) -{ - pid_t pid; - int ret; - - /* First, register all of the USB host Wireless LAN drivers */ - - printf("wlan_main: Register drivers\n"); - ret = usbhost_wlaninit(); - if (ret != OK) - { - printf("wlan_main: Failed to register the WLAN driver\n"); - } - - /* Then get an instance of the USB host interface */ - - printf("wlan_main: Initialize USB host WLAN driver\n"); - g_drvr = usbhost_initialize(0); - if (g_drvr) - { - /* Start a thread to handle device connection. */ - - printf("wlan_main: Start wlan_waiter\n"); - -#ifndef CONFIG_CUSTOM_STACK - pid = task_create("usbhost", CONFIG_EXAMPLES_WLAN_DEFPRIO, - CONFIG_EXAMPLES_WLAN_STACKSIZE, - (main_t)wlan_waiter, (const char **)NULL); -#else - pid = task_create("usbhost", CONFIG_EXAMPLES_WLAN_DEFPRIO, - (main_t)wlan_waiter, (const char **)NULL); -#endif - - /* Now just sleep. Eventually logic here will perform the device test. */ - - for (;;) - { - sleep(5); - printf("usert_start: Still alive\n"); - } - } - return 0; -} diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index daa1e068c..80b4bde1d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1452,7 +1452,7 @@ complex: 'uname -o 2>/dev/null || echo "Other"' * drivers/usbhost/usbhost_enumerate.c: Add logic to get the VID and PID. This is necessary in order to support vendor-specific USB devices. - * examplex/wlan, configs/olimex-lpc1766stk/wlan, drivers/usbhost/usbhost_rtl8187.c, + * examples/wlan, configs/olimex-lpc1766stk/wlan, drivers/usbhost/usbhost_rtl8187.c, Add infrastructure to support RTL18187 wireless USB. * configs/nucleus2g: backed out USB host changes... wrong board. * Renamed arc/hc/include/mc9s12ne64 and src/mc9s12ne64 to m9s12. That name is @@ -1920,7 +1920,7 @@ CONFIG_FAT_LCNAMES is not selected, all filenames are strictly upper case. * configs/stm3210e-eval/nsh2: Console is back on UART1; Added - examplex/nx as an NSH "built-in" command as a demonstration. + examples/nx as an NSH "built-in" command as a demonstration. * fs/fat/fs_fat32dirent.c: Fix an important bug in the directory allocation (fat_allocatedirentry()). I looks like it could be initializing the wrong sectors! NOTE: This function was in @@ -3845,4 +3845,6 @@ * configs/zp214xpa/nxlines: Add an nxlines configuration for the ZP213x/4xPA (with the LPC2148 and the UG_2864AMBAG01). Working as of 2012-12-30. + * config/olimex-lpc1766stk/wlan: Remove non-functional + configuration. diff --git a/nuttx/configs/olimex-lpc1766stk/wlan/Make.defs b/nuttx/configs/olimex-lpc1766stk/wlan/Make.defs deleted file mode 100644 index f99c88f53..000000000 --- a/nuttx/configs/olimex-lpc1766stk/wlan/Make.defs +++ /dev/null @@ -1,109 +0,0 @@ -############################################################################ -# configs/olimex-lpc1766stk/wlan/Make.defs -# -# 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. -# -############################################################################ - -include ${TOPDIR}/.config -include ${TOPDIR}/tools/Config.mk -include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs - -ifeq ($(WINTOOL),y) - # Windows-native toolchains - DIRLINK = $(TOPDIR)/tools/copydir.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mknulldeps.sh - ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" - ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" - ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/ld.script}" - MAXOPTIMIZATION = -O2 -else - # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps.sh - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/ld.script -endif - -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -LD = $(CROSSDEV)ld -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)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 -else - ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-builtin -ARCHCXXFLAGS = -fno-builtin -fno-exceptions -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -ARCHWARNINGSXX = -Wall -Wshadow -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 - -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 -g -pipe -HOSTLDFLAGS = - diff --git a/nuttx/configs/olimex-lpc1766stk/wlan/appconfig b/nuttx/configs/olimex-lpc1766stk/wlan/appconfig deleted file mode 100644 index 7fb2871aa..000000000 --- a/nuttx/configs/olimex-lpc1766stk/wlan/appconfig +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# configs/olimex-lpc1766stk/wlan/appconfig -# -# Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# Path to example in apps/examples containing the user_start entry point - -CONFIGURED_APPS += examples/wlan - -# Networking support - -CONFIGURED_APPS += netutils/uiplib diff --git a/nuttx/configs/olimex-lpc1766stk/wlan/defconfig b/nuttx/configs/olimex-lpc1766stk/wlan/defconfig deleted file mode 100755 index 009191f65..000000000 --- a/nuttx/configs/olimex-lpc1766stk/wlan/defconfig +++ /dev/null @@ -1,498 +0,0 @@ -############################################################################ -# configs/olimex-lpc1766stk/wlan/defconfig -# -# 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. -# -############################################################################ -# -# Architecture Selection -# -CONFIG_ARCH="arm" -CONFIG_ARCH_ARM=y -CONFIG_ARCH_CORTEXM3=y -CONFIG_ARCH_CHIP="lpc17xx" -CONFIG_ARCH_CHIP_LPC17XX=y -CONFIG_ARCH_CHIP_LPC1766=y -CONFIG_ARCH_BOARD="olimex-lpc1766stk" -CONFIG_ARCH_BOARD_LPC1766STK=y -CONFIG_BOARD_LOOPSPERMSEC=8111 -CONFIG_DRAM_SIZE=32768 -CONFIG_DRAM_START=0x10000000 -CONFIG_ARCH_IRQPRIO=y -CONFIG_ARCH_INTERRUPTSTACK=0 -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH_BOOTLOADER=n -CONFIG_ARCH_LEDS=y -CONFIG_ARCH_BUTTONS=n -CONFIG_ARCH_CALIBRATION=n -CONFIG_ARCH_DMA=n - -# -# Identify toolchain and linker options -# -CONFIG_LPC17_CODESOURCERYW=n -CONFIG_LPC17_CODESOURCERYL=n -CONFIG_LPC17_DEVKITARM=n -CONFIG_LPC17_BUILDROOT=y - -# -# Individual subsystems can be enabled: -# -CONFIG_LPC17_ETHERNET=n -CONFIG_LPC17_USBHOST=y -CONFIG_LPC17_USBOTG=n -CONFIG_LPC17_USBDEV=n -CONFIG_LPC17_UART0=y -CONFIG_LPC17_UART1=n -CONFIG_LPC17_UART2=n -CONFIG_LPC17_UART3=n -CONFIG_LPC17_CAN1=n -CONFIG_LPC17_CAN2=n -CONFIG_LPC17_SPI=n -CONFIG_LPC17_SSP0=n -CONFIG_LPC17_SSP1=n -CONFIG_LPC17_I2C0=n -CONFIG_LPC17_I2C1=n -CONFIG_LPC17_I2S=n -CONFIG_LPC17_TMR0=n -CONFIG_LPC17_TMR1=n -CONFIG_LPC17_TMR2=n -CONFIG_LPC17_TMR3=n -CONFIG_LPC17_RIT=n -CONFIG_LPC17_PWM=n -CONFIG_LPC17_MCPWM=n -CONFIG_LPC17_QEI=n -CONFIG_LPC17_RTC=n -CONFIG_LPC17_WDT=n -CONFIG_LPC17_ADC=n -CONFIG_LPC17_DAC=n -CONFIG_LPC17_GPDMA=n - -# -# LPC17xx specific serial device driver settings -# -CONFIG_UART0_SERIAL_CONSOLE=y -CONFIG_UART1_SERIAL_CONSOLE=n -CONFIG_UART2_SERIAL_CONSOLE=n -CONFIG_UART3_SERIAL_CONSOLE=n - -CONFIG_UART0_TXBUFSIZE=256 -CONFIG_UART1_TXBUFSIZE=256 -CONFIG_UART2_TXBUFSIZE=256 -CONFIG_UART3_TXBUFSIZE=256 - -CONFIG_UART0_RXBUFSIZE=256 -CONFIG_UART1_RXBUFSIZE=256 -CONFIG_UART2_RXBUFSIZE=256 -CONFIG_UART3_RXBUFSIZE=256 - -CONFIG_UART0_BAUD=57600 -CONFIG_UART2_BAUD=57600 -CONFIG_UART3_BAUD=57600 -CONFIG_UART1_BAUD=57600 - -CONFIG_UART0_BITS=8 -CONFIG_UART1_BITS=8 -CONFIG_UART2_BITS=8 -CONFIG_UART3_BITS=8 - -CONFIG_UART0_PARITY=0 -CONFIG_UART1_PARITY=0 -CONFIG_UART2_PARITY=0 -CONFIG_UART3_PARITY=0 - -CONFIG_UART0_2STOP=0 -CONFIG_UART1_2STOP=0 -CONFIG_UART2_2STOP=0 -CONFIG_UART3_2STOP=0 - -# -# LPC17xx specific PHY/Ethernet device driver settings -# -CONFIG_PHY_KS8721=y -CONFIG_PHY_AUTONEG=y -CONFIG_PHY_SPEED100=n -CONFIG_PHY_FDUPLEX=y -CONFIG_NET_REGDEBUG=n - -# -# General build options -# -CONFIG_RRLOAD_BINARY=n -CONFIG_INTELHEX_BINARY=y -CONFIG_MOTOROLA_SREC=n -CONFIG_RAW_BINARY=n - -# -# General OS setup -# -CONFIG_USER_ENTRYPOINT="wlan_main" -CONFIG_DEBUG=n -CONFIG_DEBUG_VERBOSE=n -CONFIG_DEBUG_SYMBOLS=n -CONFIG_DEBUG_NET=n -CONFIG_DEBUG_USB=n -CONFIG_MM_REGIONS=2 -CONFIG_ARCH_LOWPUTC=y -CONFIG_RR_INTERVAL=200 -CONFIG_SCHED_INSTRUMENTATION=n -CONFIG_TASK_NAME_SIZE=0 -CONFIG_START_YEAR=2011 -CONFIG_START_MONTH=3 -CONFIG_START_DAY=8 -CONFIG_GREGORIAN_TIME=n -CONFIG_JULIAN_TIME=n -CONFIG_DEV_CONSOLE=y -CONFIG_DEV_LOWCONSOLE=n -CONFIG_MUTEX_TYPES=n -CONFIG_PRIORITY_INHERITANCE=n -CONFIG_SEM_PREALLOCHOLDERS=0 -CONFIG_SEM_NNESTPRIO=0 -CONFIG_FDCLONE_DISABLE=n -CONFIG_FDCLONE_STDIO=n -CONFIG_SDCLONE_DISABLE=y -CONFIG_NXFLAT=n -CONFIG_SCHED_WORKQUEUE=y -CONFIG_SCHED_WORKPRIORITY=192 -CONFIG_SCHED_WORKPERIOD=50000 -CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 - -# -# The following can be used to disable categories of -# APIs supported by the OS. If the compiler supports -# weak functions, then it should not be necessary to -# disable functions unless you want to restrict usage -# of those APIs. -# -# There are certain dependency relationships in these -# features. -# -# o mq_notify logic depends on signals to awaken tasks -# waiting for queues to become full or empty. -# o pthread_condtimedwait() depends on signals to wake -# up waiting tasks. -# -CONFIG_DISABLE_CLOCK=n -CONFIG_DISABLE_POSIX_TIMERS=n -CONFIG_DISABLE_PTHREAD=n -CONFIG_DISABLE_SIGNALS=n -CONFIG_DISABLE_MQUEUE=n -CONFIG_DISABLE_MOUNTPOINT=n -CONFIG_DISABLE_ENVIRON=n -CONFIG_DISABLE_POLL=n - -# -# Misc libc settings -# -CONFIG_NOPRINTF_FIELDWIDTH=n - -# -# Allow for architecture optimized implementations -# -# The architecture can provide optimized versions of the -# following to improve system performance -# -CONFIG_ARCH_MEMCPY=n -CONFIG_ARCH_MEMCMP=n -CONFIG_ARCH_MEMMOVE=n -CONFIG_ARCH_MEMSET=n -CONFIG_ARCH_STRCMP=n -CONFIG_ARCH_STRCPY=n -CONFIG_ARCH_STRNCPY=n -CONFIG_ARCH_STRLEN=n -CONFIG_ARCH_STRNLEN=n -CONFIG_ARCH_BZERO=n - -# -# Sizes of configurable things (0 disables) -# -CONFIG_MAX_TASKS=16 -CONFIG_MAX_TASK_ARGS=4 -CONFIG_NPTHREAD_KEYS=4 -CONFIG_NFILE_DESCRIPTORS=8 -CONFIG_NFILE_STREAMS=8 -CONFIG_NAME_MAX=32 -CONFIG_STDIO_BUFFER_SIZE=256 -CONFIG_NUNGET_CHARS=2 -CONFIG_PREALLOC_MQ_MSGS=4 -CONFIG_MQ_MAXMSGSIZE=32 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_PREALLOC_WDOGS=4 -CONFIG_PREALLOC_TIMERS=4 - -# -# Filesystem configuration -# -CONFIG_FS_FAT=n -CONFIG_FAT_LCNAMES=n -CONFIG_FAT_LFN=n -CONFIG_FAT_MAXFNAME=32 -CONFIG_FS_NXFFS=n -CONFIG_FS_ROMFS=n - -# -# Maintain legacy build behavior (revisit) -# - -CONFIG_MMCSD=y -CONFIG_MMCSD_SPI=y -CONFIG_MMCSD_SDIO=y - -# -# SPI-based MMC/SD driver -# -CONFIG_MMCSD_NSLOTS=1 -CONFIG_MMCSD_READONLY=n -CONFIG_MMCSD_SPICLOCK=12500000 - -# -# Block driver buffering -# -CONFIG_FS_READAHEAD=n -CONFIG_FS_WRITEBUFFER=n - -# -# SDIO-based MMC/SD driver -# -CONFIG_SDIO_DMA=n -CONFIG_MMCSD_MMCSUPPORT=n -CONFIG_MMCSD_HAVECARDDETECT=n - -# -# TCP/IP and UDP support via uIP -# -CONFIG_NET=y -CONFIG_NET_NOINTS=y -CONFIG_NET_MULTIBUFFER=y -CONFIG_NET_IPv6=n -CONFIG_NSOCKET_DESCRIPTORS=2 -CONFIG_NET_SOCKOPTS=y -CONFIG_NET_BUFSIZE=420 -CONFIG_NET_TCP=y -CONFIG_NET_TCP_CONNS=40 -CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_UDP=y -CONFIG_NET_UDP_CHECKSUMS=y -#CONFIG_NET_UDP_CONNS=10 -CONFIG_NET_ICMP=n -CONFIG_NET_ICMP_PING=n -#CONFIG_NET_PINGADDRCONF=0 -CONFIG_NET_STATISTICS=y -#CONFIG_NET_RECEIVE_WINDOW= -#CONFIG_NET_ARPTAB_SIZE=8 -CONFIG_NET_BROADCAST=n -CONFIG_NET_WLAN=y - -# -# UIP Network Utilities -# -CONFIG_NET_DHCP_LIGHT=n -CONFIG_NET_RESOLV_ENTRIES=4 - -# -# USB Device Configuration -# -CONFIG_USBDEV=n -CONFIG_USBDEV_ISOCHRONOUS=n -CONFIG_USBDEV_DUALSPEED=n -CONFIG_USBDEV_SELFPOWERED=y -CONFIG_USBDEV_REMOTEWAKEUP=n -CONFIG_USBDEV_MAXPOWER=100 -CONFIG_USBDEV_TRACE=n -CONFIG_USBDEV_TRACE_NRECORDS=128 - -# -# USB Host Configuration -# -CONFIG_USBHOST=y -CONFIG_USBHOST_NPREALLOC=0 -CONFIG_USBHOST_BULK_DISABLE=n -CONFIG_USBHOST_INT_DISABLE=y -CONFIG_USBHOST_ISOC_DISABLE=y - -# -# LPC17xx USB Device Configuration -# -CONFIG_LPC17_USBDEV_FRAME_INTERRUPT=n -CONFIG_LPC17_USBDEV_EPFAST_INTERRUPT=n -CONFIG_LPC17_USBDEV_DMA=n -CONFIG_LPC17_USBDEV_NDMADESCRIPTORS=0 -CONFIG_LPC17_USBDEV_DMAINTMASK=0 - -# -# LPC17xx USB Host Configuration -# -# OHCI RAM layout: -# -CONFIG_USBHOST_OHCIRAM_SIZE=2048 -CONFIG_USBHOST_NEDS=3 -CONFIG_USBHOST_NTDS=2 -CONFIG_USBHOST_TDBUFFERS=4 -CONFIG_USBHOST_TDBUFSIZE=128 -CONFIG_USBHOST_IOBUFSIZE=448 - -# -# USB Serial Device Configuration -# -CONFIG_PL2303=n -CONFIG_PL2303_EPINTIN=1 -CONFIG_PL2303_EPBULKOUT=2 -CONFIG_PL2303_EPBULKIN=5 -CONFIG_PL2303_NWRREQS=4 -CONFIG_PL2303_NRDREQS=4 -CONFIG_PL2303_VENDORID=0x067b -CONFIG_PL2303_PRODUCTID=0x2303 -CONFIG_PL2303_VENDORSTR="Nuttx" -CONFIG_PL2303_PRODUCTSTR="USBdev Serial" -CONFIG_PL2303_RXBUFSIZE=512 -CONFIG_PL2303_TXBUFSIZE=512 - -# -# USB Storage Device Configuration -# -CONFIG_USBMSC=n -CONFIG_USBMSC_EP0MAXPACKET=64 -CONFIG_USBMSC_EPBULKOUT=2 -CONFIG_USBMSC_EPBULKIN=5 -CONFIG_USBMSC_NRDREQS=2 -CONFIG_USBMSC_NWRREQS=2 -CONFIG_USBMSC_BULKINREQLEN=256 -CONFIG_USBMSC_BULKOUTREQLEN=256 -CONFIG_USBMSC_VENDORID=0x584e -CONFIG_USBMSC_VENDORSTR="NuttX" -CONFIG_USBMSC_PRODUCTID=0x5342 -CONFIG_USBMSC_PRODUCTSTR="USBdev Storage" -CONFIG_USBMSC_VERSIONNO=0x0399 -CONFIG_USBMSC_REMOVABLE=y - -# -# Settings for examples/uip -# -CONFIG_EXAMPLES_UIP_IPADDR=0x0a000002 -CONFIG_EXAMPLES_UIP_DRIPADDR=0x0a000001 -CONFIG_EXAMPLES_UIP_NETMASK=0xffffff00 -CONFIG_EXAMPLES_UIP_DHCPC=n - -# -# Settings for examples/nettest -# -CONFIG_EXAMPLES_NETTEST_SERVER=n -CONFIG_EXAMPLES_NETTEST_PERFORMANCE=n -CONFIG_EXAMPLES_NETTEST_NOMAC=n -CONFIG_EXAMPLES_NETTEST_IPADDR=0x0a000002 -CONFIG_EXAMPLES_NETTEST_DRIPADDR=0x0a000001 -CONFIG_EXAMPLES_NETTEST_NETMASK=0xffffff00 -CONFIG_EXAMPLES_NETTEST_CLIENTIP=0x0a000001 - -# -# Settings for apps/examples/wlan -# -CONFIG_EXAMPLES_WLAN_DHCPC=n -CONFIG_EXAMPLES_WLAN_NOMAC=n -CONFIG_EXAMPLES_WLAN_IPADDR=0xc0a800c9 -CONFIG_EXAMPLES_WLAN_DRIPADDR=0xc0a80001 -CONFIG_EXAMPLES_WLAN_NETMASK=0xffffff00 - -# -# Settings for examples/ostest -# -CONFIG_EXAMPLES_OSTEST_LOOPS=1 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 -CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 - -# -# Settings for apps/nshlib -# -CONFIG_NSH_FILEIOSIZE=512 -CONFIG_NSH_STRERROR=n -CONFIG_NSH_LINELEN=64 -CONFIG_NSH_NESTDEPTH=3 -CONFIG_NSH_DISABLESCRIPT=n -CONFIG_NSH_DISABLEBG=n -CONFIG_NSH_ROMFSETC=n -CONFIG_NSH_CONSOLE=y -CONFIG_NSH_TELNET=n -CONFIG_NSH_ARCHINIT=n -CONFIG_NSH_IOBUFFER_SIZE=512 -CONFIG_NSH_DHCPC=n -CONFIG_NSH_NOMAC=n -CONFIG_NSH_IPADDR=0x0a000002 -CONFIG_NSH_DRIPADDR=0x0a000001 -CONFIG_NSH_NETMASK=0xffffff00 -CONFIG_NSH_ROMFSMOUNTPT="/etc" -CONFIG_NSH_INITSCRIPT="init.d/rcS" -CONFIG_NSH_ROMFSDEVNO=0 -CONFIG_NSH_ROMFSSECTSIZE=64 -CONFIG_NSH_FATDEVNO=1 -CONFIG_NSH_FATSECTSIZE=512 -CONFIG_NSH_FATNSECTORS=1024 -CONFIG_NSH_FATMOUNTPT="/tmp" - -# -# Architecture-specific NSH options -# -CONFIG_NSH_MMCSDSPIPORTNO=0 -CONFIG_NSH_MMCSDSLOTNO=0 -CONFIG_NSH_MMCSDMINOR=0 - -# -# Settings for examples/usbserial -# -CONFIG_EXAMPLES_USBSERIAL_INONLY=n -CONFIG_EXAMPLES_USBSERIAL_OUTONLY=n -CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=n -CONFIG_EXAMPLES_USBSERIAL_ONLYBIG=n - -CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n -CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n -CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n -CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n -CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n - -# -# Stack and heap information -# -CONFIG_BOOT_RUNFROMFLASH=n -CONFIG_BOOT_COPYTORAM=n -CONFIG_CUSTOM_STACK=n -CONFIG_IDLETHREAD_STACKSIZE=1024 -CONFIG_USERMAIN_STACKSIZE=2048 -CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=2048 -CONFIG_HEAP_BASE= -CONFIG_HEAP_SIZE= - -# -# USB WLAN device identification -# -CONFIG_USB_WLAN_VID=0x0bda -CONFIG_USB_WLAN_PID=0x8189 diff --git a/nuttx/configs/olimex-lpc1766stk/wlan/setenv.sh b/nuttx/configs/olimex-lpc1766stk/wlan/setenv.sh deleted file mode 100755 index 767614612..000000000 --- a/nuttx/configs/olimex-lpc1766stk/wlan/setenv.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# configs/olimex-lpc1766stk/wlan/setenv.sh -# -# Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -if [ "$_" = "$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 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" - -# 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}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" - -# The Olimex-lpc1766stk/tools directory -export LPCTOOL_DIR="${WD}/configs/olimex-lpc1766stk/tools" - -# Add the path to the toolchain and tools directory to the PATH varialble -export PATH="${TOOLCHAIN_BIN}:${LPCTOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}" - -echo "PATH : ${PATH}" -- cgit v1.2.3 From 5d6b2017a05d31b6e7bdeab8defa3717fc72be3a Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 1 Jan 2013 16:34:12 +0000 Subject: All lm3s6965-ek configurations converted to use kconfig-frontends git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5471 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/nx/Kconfig | 128 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) (limited to 'apps') diff --git a/apps/examples/nx/Kconfig b/apps/examples/nx/Kconfig index 2081b12dc..f636daf84 100644 --- a/apps/examples/nx/Kconfig +++ b/apps/examples/nx/Kconfig @@ -10,4 +10,132 @@ config EXAMPLES_NX Enable the NX graphics example if EXAMPLES_NX + +config EXAMPLES_NX_BUILTIN + bool "NSH Built-IN" + depends on NSH_BUILTIN_APPS + ---help--- + Build the NX example as a "built-in" that can be executed from the + NSH command line + +config EXAMPLES_NX_VPLANE + int "Video Plane" + default 0 + ---help--- + The plane to select from the framebuffer driver for use in the test. + Default: 0 + +config EXAMPLES_NX_DEVNO + int "Video Device Number" + default 0 + ---help--- + The LCD device to select from the LCD driver for use in the test: + Default: 0 + +config EXAMPLES_NX_DEFAULT_COLORS + bool "Use Default Colors" + default y + +if !EXAMPLES_NX_DEFAULT_COLORS + +config EXAMPLES_NX_BGCOLOR + hex "Background Color" + ---help--- + The color of the background. Default depends on config EXAMPLES_NX_BPP. + +config EXAMPLES_NX_COLOR1 + hex "Color of Window 1" + ---help--- + The color of window 1. Default depends on config EXAMPLES_NX_BPP. + +config EXAMPLES_NX_COLOR2 + hex "Color of Window 2" + ---help--- + The color of window 2. Default depends on config EXAMPLES_NX_BPP. + +config EXAMPLES_NX_TBCOLOR + hex "Toolbar Color" + ---help--- + The color of the toolbar. Default depends on config EXAMPLES_NX_BPP. + +config EXAMPLES_NX_FONTCOLOR + hex "Font Color" + ---help--- + The color of the fonts. Default depends on config EXAMPLES_NX_BPP. + +endif + +config EXAMPLES_NX_DEFAULT_FONT + bool "Use Default Font" + default y + +config EXAMPLES_NX_FONTID + bool "Font ID" + depends on !EXAMPLES_NX_DEFAULT_FONT + ---help--- + Selects the font (see font ID numbers in include/nuttx/nx/nxfonts.h) + +config EXAMPLES_NX_BPP + int "Bits-Per-Pixel" + default 32 + ---help--- + Pixels per pixel to use. Valid options include 2, 4, 8, 16, 24, + and 32. Default is 32. + +config EXAMPLES_NX_RAWWINDOWS + bool "Use Raw Windows" + default n + ---help--- + Use raw windows; Default is to use pretty, framed NXTK windows with + toolbars. + +config EXAMPLES_NX_EXTERNINIT + bool "External Device Initialization" + default n + ---help--- + The driver for the graphics device on this platform requires some + unusual initialization. This is the for, for example, SPI LCD/OLED + devices. If this configuration is selected, then the platform code + must provide an LCD initialization function with a prototype like: + + #ifdef CONFIG_NX_LCDDRIVER + FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno); + #else + FAR struct fb_vtable_s *up_nxdrvinit(unsigned int devno); + #endif + +if NX_MULTIUSER +comment "Multi-User Configuration Options" + +config EXAMPLES_NX_STACKSIZE + int "NX Server Stack Size" + default 2048 + ---help--- + The stacksize to use when creating the NX server. Default 2048 + +config EXAMPLES_NX_CLIENTPRIO + int "Client Priority" + default 100 + ---help--- + The client priority. Default: 100 + +config EXAMPLES_NX_SERVERPRIO + int "Server Priority" + default 120 + ---help--- + The server priority. Default: 120 + +config EXAMPLES_NX_LISTENERPRIO + int "Listener Priority" + default 80 + ---help--- + The priority of the event listener thread. Default 80. + +config EXAMPLES_NX_NOTIFYSIGNO + int "Notify Signal Number" + default 4 + ---help--- + The signal number to use with nx_eventnotify(). Default: 4 + +endif endif -- cgit v1.2.3 From 0d86268de677a844efa345638650dcaa6bf12764 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 6 Jan 2013 17:00:08 +0000 Subject: Remove CONFIG_BUILTIN_APPS_START git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5482 42af7a65-404d-4744-a932-0658087f49c3 --- apps/README.txt | 15 --------------- nuttx/ChangeLog | 5 +++++ nuttx/Documentation/NuttShell.html | 25 +++---------------------- nuttx/sched/os_bringup.c | 22 ++-------------------- 4 files changed, 10 insertions(+), 57 deletions(-) (limited to 'apps') diff --git a/apps/README.txt b/apps/README.txt index 328126905..4a336abdb 100644 --- a/apps/README.txt +++ b/apps/README.txt @@ -141,21 +141,6 @@ This will select the apps/examples/hello in the following way: Thus accomplishing the same thing with no apps/.config file. -Built-In Start-Up main() function ------------------------------- -A builtin application can even be used as the main, start-up entry point -into your embedded software. When the user defines this option in -the NuttX configuration file: - - CONFIG_BUILTIN_APP_START= - -that application shall be invoked immediately after system starts -*instead* of the default "user_start" entry point. -Note that must be provided as: "hello", -will call: - - int hello_main(int argc, char *argv[]) - Example Built-In Application ---------------------------- An example application skeleton can be found under the examples/hello diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index b27800419..f4f697563 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3875,3 +3875,8 @@ definitions (from Rommel Marcelo). * libc/string/lib_strndup.c: strndup() should use strnlen(), not strlen(), to determine the size of the string. + * sched/os_bringup.c: Remove support for CONFIG_BUILTIN_APP_START. + This is not really a useful feature and creates a violation of the + OS layered architecture. + + diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 7ad96da79..95a75b22c 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -3421,29 +3421,10 @@ context:

              Other Uses of Built-In Application. The primary purpose of builtin applications is to support command line execution of applications from NSH. - However, there are two other uses of builtin applications that should be mentioned. + However, there is one other use of builtin applications that should be mentioned.

                -
              1. -

                - Built-In Application Start-Up main() function. - A builtin application can even be used as the main, start-up entry point into your embedded software. - When the user defines this option in the NuttX configuration file: -

                -
                  -CONFIG_BUILTIN_APP_START=<application name>
                  -
                -

                - that application will be invoked immediately after system starts instead of the default CONFIG_USER_ENTRYPOINT() entry point. - Note that <application name> must be provided just as it would have been on the NSH command line. - For example, hello would result in hello_main() being started at power-up. -

                -

                - This option might be useful in some develop environments where you use NSH only during the debug phase, but want to eliminate NSH in the final product. - Setting CONFIG_BUILTIN_APP_START in this way will bypass NSH and execute your application just as if it were entered from the NSH command line. -

                -
              2. binfs. binfs is a tiny file system located at apps/builtin/binfs.c. @@ -3452,7 +3433,8 @@ CONFIG_BUILTIN_APP_START=<application name> binfs will create a tiny pseudo-file system mounted at /bin. Using binfs, you can see the available builtin applications by listing the contents of /bin directory. This gives some superficial Unix compatibility, but does not really add any new functionality. -

                +

                +

              4.3.2 Synchronous Built-In Applications

              @@ -3770,7 +3752,6 @@ mount -t vfat /dev/ram1 /tmp
            • Command summaries
            • Command table
            • Conditional command execution
            • -
            • CONFIG_BUILTIN_APP_START
            • CONFIG_DISABLE_MOUNTPOINT
            • CONFIG_FS_ROMFS
            • CONFIG_NFILE_DESCRIPTORS
            • diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c index 4b5adcae1..610d8515a 100644 --- a/nuttx/sched/os_bringup.c +++ b/nuttx/sched/os_bringup.c @@ -57,9 +57,6 @@ #ifdef CONFIG_SCHED_WORKQUEUE # include "work_internal.h" #endif -#ifdef CONFIG_BUILTIN_APP_START -# include "apps/apps.h" -#endif #ifdef CONFIG_NUTTX_KERNEL # include "arch/board/user_map.h" #endif @@ -112,22 +109,15 @@ * function is to serve as the "bottom half" of device * drivers. * - * And the main application entry point. This may be one of two different + * And the main application entry point: * symbols: * - * - USER_ENTRYPOINT: This is the default entry point used for all of the - * example code in apps/examples. - * - CONFIG_BUILTIN_APP_START: The system can also be configured to start - * custom applications at however CONFIG_BUILTIN_APP_START - * is defined in the NuttX start-up file. + * - USER_ENTRYPOINT: This is the default user application entry point. * ****************************************************************************/ int os_bringup(void) { -#ifdef CONFIG_BUILTIN_APP_START - static const char *argv[3] = {NULL, "init", NULL}; -#endif int init_taskid; /* Setup up the initial environment for the idle task. At present, this @@ -188,19 +178,11 @@ int os_bringup(void) svdbg("Starting init thread\n"); -#ifdef CONFIG_BUILTIN_APP_START - /* Start the built-in application, passing an "init" argument, so that - * application can distinguish different run-levels - */ - - init_taskid = exec_builtin(CONFIG_BUILTIN_APP_START, argv); -#else /* Start the default application at CONFIG_USER_ENTRYPOINT() */ init_taskid = TASK_CREATE("init", SCHED_PRIORITY_DEFAULT, CONFIG_USERMAIN_STACKSIZE, (main_t)CONFIG_USER_ENTRYPOINT, (const char **)NULL); -#endif ASSERT(init_taskid != ERROR); /* We an save a few bytes by discarding the IDLE thread's environment. */ -- cgit v1.2.3 From 66cdd288ab6a4d19c67300a73a26e9ee5a958187 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 7 Jan 2013 21:41:20 +0000 Subject: Add ostest vfork test (does not work yet) git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5488 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/ostest/Makefile | 4 ++ apps/examples/ostest/ostest.h | 6 +++ apps/examples/ostest/ostest_main.c | 6 +++ apps/examples/ostest/vfork.c | 99 ++++++++++++++++++++++++++++++++++++ nuttx/arch/Kconfig | 5 ++ nuttx/arch/arm/src/arm/vfork.S | 10 ++-- nuttx/arch/arm/src/armv7-m/vfork.S | 10 ++-- nuttx/arch/arm/src/common/up_vfork.c | 45 +++++++++++++--- nuttx/sched/sched_addprioritized.c | 2 +- nuttx/sched/sched_addreadytorun.c | 8 +-- nuttx/sched/task_vfork.c | 9 +++- 11 files changed, 182 insertions(+), 22 deletions(-) create mode 100644 apps/examples/ostest/vfork.c (limited to 'apps') diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index 3d19f6a78..b7ba9a9a8 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -84,6 +84,10 @@ ifneq ($(CONFIG_DISABLE_POSIX_TIMERS),y) CSRCS += posixtimer.c endif +ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CSRCS += vfork.c +endif + ifneq ($(CONFIG_DISABLE_SIGNALS),y) ifneq ($(CONFIG_DISABLE_PTHREAD),y) ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) diff --git a/apps/examples/ostest/ostest.h b/apps/examples/ostest/ostest.h index a4af37f05..bc46a3860 100644 --- a/apps/examples/ostest/ostest.h +++ b/apps/examples/ostest/ostest.h @@ -163,6 +163,12 @@ extern void barrier_test(void); extern void priority_inheritance(void); +/* vfork.c ******************************************************************/ + +#ifdef CONFIG_ARCH_HAVE_VFORK +extern int vfork_test(void); +#endif + /* APIs exported (conditionally) by the OS specifically for testing of * priority inheritance */ diff --git a/apps/examples/ostest/ostest_main.c b/apps/examples/ostest/ostest_main.c index 46726d515..ca44353c3 100644 --- a/apps/examples/ostest/ostest_main.c +++ b/apps/examples/ostest/ostest_main.c @@ -409,6 +409,11 @@ static int user_main(int argc, char *argv[]) check_test_memory_usage(); #endif /* CONFIG_PRIORITY_INHERITANCE && !CONFIG_DISABLE_SIGNALS && !CONFIG_DISABLE_PTHREAD */ +#ifdef CONFIG_ARCH_HAVE_VFORK + printf("\nuser_main: vfork() test\n"); + vfork_test(); +#endif + /* Compare memory usage at time ostest_main started until * user_main exits. These should not be identical, but should * be similar enough that we can detect any serious OS memory @@ -428,6 +433,7 @@ static int user_main(int argc, char *argv[]) show_memory_usage(&g_mmbefore, &g_mmafter); #endif } + printf("user_main: Exitting\n"); return 0; } diff --git a/apps/examples/ostest/vfork.c b/apps/examples/ostest/vfork.c new file mode 100644 index 000000000..6c83047e3 --- /dev/null +++ b/apps/examples/ostest/vfork.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * examples/ostest/vfork.c + * + * Copyright (C) 2013 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 "ostest.h" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if defined(CONFIG_ARCH_HAVE_VFORK) && !defined(CONFIG_DISABLE_SIGNALS) +static volatile bool g_vforkchild; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int vfork_test(void) +{ +#if defined(CONFIG_ARCH_HAVE_VFORK) && !defined(CONFIG_DISABLE_SIGNALS) + pid_t pid; + + g_vforkchild = false; + pid = vfork(); + if (pid == 0) + { + /* There is not very much that the child is permitted to do. Perhaps + * it can just set g_vforkchild. + */ + + g_vforkchild = true; + exit(0); + } + else if (pid < 0) + { + printf("vfork_test: vfork() failed: %d\n", errno); + return -1; + } + else + { + sleep(1); + if (g_vforkchild) + { + printf("vfork_test: Child %d ran successfully\n", pid); + } + else + { + printf("vfork_test: ERROR Child %d did not run\n", pid); + return -1; + } + } +#endif + + return 0; +} diff --git a/nuttx/arch/Kconfig b/nuttx/arch/Kconfig index f19228143..7d34b56f4 100644 --- a/nuttx/arch/Kconfig +++ b/nuttx/arch/Kconfig @@ -16,6 +16,7 @@ config ARCH_8051 config ARCH_ARM bool "ARM" select ARCH_HAVE_INTERRUPTSTACK + select ARCH_HAVE_VFORK ---help--- The ARM architectures @@ -124,6 +125,10 @@ config ADDRENV bool default n +config ARCH_HAVE_VFORK + bool + default n + config ARCH_STACKDUMP bool "Dump stack on assertions" default n diff --git a/nuttx/arch/arm/src/arm/vfork.S b/nuttx/arch/arm/src/arm/vfork.S index f0fe17f73..b498fd7f7 100644 --- a/nuttx/arch/arm/src/arm/vfork.S +++ b/nuttx/arch/arm/src/arm/vfork.S @@ -50,7 +50,7 @@ ************************************************************************************/ .file "vfork.S" - .globl task_vfork + .globl up_vfork /************************************************************************************ * Public Functions @@ -66,7 +66,7 @@ * from the function in which vfork() was called, or calls any other function before * successfully calling _exit() or one of the exec family of functions. * - * This thin layer implements vfork by simply calling task_vfork() with the vfork() + * This thin layer implements vfork by simply calling up_vfork() with the vfork() * context as an argument. The overall sequence is: * * 1) User code calls vfork(). vfork() collects context information and @@ -121,12 +121,12 @@ vfork: str r0, [sp, #VFORK_SP_OFFSET] str lr, [sp, #VFORK_LR_OFFSET] - /* Then, call task_vfork(), passing it a pointer to the stack structure */ + /* Then, call up_vfork(), passing it a pointer to the stack structure */ mov r0, sp - bl task_vfork + bl up_vfork - /* Release the stack data and return the value returned by task_vfork */ + /* Release the stack data and return the value returned by up_vfork */ add sp, sp, #VFORK_SIZEOF mov pc, lr diff --git a/nuttx/arch/arm/src/armv7-m/vfork.S b/nuttx/arch/arm/src/armv7-m/vfork.S index aceded400..0d9e144cd 100644 --- a/nuttx/arch/arm/src/armv7-m/vfork.S +++ b/nuttx/arch/arm/src/armv7-m/vfork.S @@ -52,7 +52,7 @@ .syntax unified .thumb .file "vfork.S" - .globl task_vfork + .globl up_vfork /************************************************************************************ * Public Functions @@ -68,7 +68,7 @@ * from the function in which vfork() was called, or calls any other function before * successfully calling _exit() or one of the exec family of functions. * - * This thin layer implements vfork by simply calling task_vfork() with the vfork() + * This thin layer implements vfork by simply calling up_vfork() with the vfork() * context as an argument. The overall sequence is: * * 1) User code calls vfork(). vfork() collects context information and @@ -124,12 +124,12 @@ vfork: str r0, [sp, #VFORK_SP_OFFSET] str lr, [sp, #VFORK_LR_OFFSET] - /* Then, call task_vfork(), passing it a pointer to the stack structure */ + /* Then, call up_vfork(), passing it a pointer to the stack structure */ mov r0, sp - bl task_vfork + bl up_vfork - /* Release the stack data and return the value returned by task_vfork */ + /* Release the stack data and return the value returned by up_vfork */ add sp, sp, #VFORK_SIZEOF bx lr diff --git a/nuttx/arch/arm/src/common/up_vfork.c b/nuttx/arch/arm/src/common/up_vfork.c index 404abd1f8..2e3c2d4a1 100644 --- a/nuttx/arch/arm/src/common/up_vfork.c +++ b/nuttx/arch/arm/src/common/up_vfork.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -129,17 +130,28 @@ pid_t up_vfork(struct vfork_s *context) _TCB *child; size_t stacksize; uint32_t newsp; + uint32_t newfp; uint32_t stackutil; int ret; + svdbg("r4:%08x r5:%08x r6:%08x r7:%08x\n", + context->r4, context->r5, context->r6, context->r7); + svdbg("r8:%08x r9:%08x r10:%08x\n", + context->r8, context->r9, context->r10); + svdbg("fp:%08x sp:%08x lr:%08x\n", + context->fp, context->sp, context->lr); + /* Allocate and initialize a TCB for the child task. */ - child = task_vforksetup((start_t)context->lr); + child = task_vforksetup((start_t)(context->lr & ~1)); if (!child) { + sdbg("task_vforksetup failed\n"); return (pid_t)ERROR; } + svdbg("Parent=%p Child=%p\n", parent, child); + /* Get the size of the parent task's stack. Due to alignment operations, * the adjusted stack size may be smaller than the stack size originally * requrested. @@ -152,15 +164,18 @@ pid_t up_vfork(struct vfork_s *context) ret = up_create_stack(child, stacksize); if (ret != OK) { + sdbg("up_create_stack failed: %d\n", ret); task_vforkabort(child, -ret); return (pid_t)ERROR; } /* How much of the parent's stack was utilized? */ - DEBUGASSERT(parent->adj_stack_ptr > context->sp); + DEBUGASSERT((uint32_t)parent->adj_stack_ptr > context->sp); stackutil = (uint32_t)parent->adj_stack_ptr - context->sp; + svdbg("stacksize:%d stackutil:%d\n", stacksize, stackutil); + /* Make some feeble effort to perserve the stack contents. This is * feeble because the stack surely contains invalid pointer and other * content that will not work in the child context. However, if the @@ -170,8 +185,26 @@ pid_t up_vfork(struct vfork_s *context) newsp = (uint32_t)child->adj_stack_ptr - stackutil; memcpy((void *)newsp, (const void *)context->sp, stackutil); - - /* Update the stack pointer, frame pointer, and voltile registers. When + + /* Was there a frame pointer in place before? */ + + if (context->fp <= (uint32_t)parent->adj_stack_ptr && + context->fp >= (uint32_t)parent->adj_stack_ptr - stacksize) + { + uint32_t frameutil = (uint32_t)parent->adj_stack_ptr - context->fp; + newfp = (uint32_t)child->adj_stack_ptr - frameutil; + } + else + { + newfp = context->fp; + } + + svdbg("Old stack base:%08x SP:%08x FP:%08x\n", + parent->adj_stack_ptr, context->sp, context->fp); + svdbg("New stack base:%08x SP:%08x FP:%08x\n", + child->adj_stack_ptr, newsp, newfp); + + /* Update the stack pointer, frame pointer, and voltile registers. When * the child TCB was initialized, all of the values were set to zero. * up_initial_state() altered a few values, but the return value in R0 * should be cleared to zero, providing the indication to the newly started @@ -185,8 +218,8 @@ pid_t up_vfork(struct vfork_s *context) child->xcp.regs[REG_R8] = context->r8; /* Volatile register r8 */ child->xcp.regs[REG_R9] = context->r9; /* Volatile register r9 */ child->xcp.regs[REG_R10] = context->r10; /* Volatile register r10 */ - child->xcp.regs[REG_FP] = context->fp; /* Frame pointer */ - child->xcp.regs[REG_SP] = context->sp; /* Stack pointer */ + child->xcp.regs[REG_FP] = newfp; /* Frame pointer */ + child->xcp.regs[REG_SP] = newsp; /* Stack pointer */ /* And, finally, start the child task. On a failure, task_vforkstart() * will discard the TCB by calling task_vforkabort(). diff --git a/nuttx/sched/sched_addprioritized.c b/nuttx/sched/sched_addprioritized.c index 8f19a4731..20178fb9c 100644 --- a/nuttx/sched/sched_addprioritized.c +++ b/nuttx/sched/sched_addprioritized.c @@ -114,7 +114,7 @@ bool sched_addprioritized(FAR _TCB *tcb, DSEG dq_queue_t *list) (next && sched_priority <= next->sched_priority); next = next->flink); - /* Add the tcb to the spot found in the list. Check if the tcb + /* Add the tcb to the spot found in the list. Check if the tcb * goes at the end of the list. NOTE: This could only happen if list * is the g_pendingtasks list! */ diff --git a/nuttx/sched/sched_addreadytorun.c b/nuttx/sched/sched_addreadytorun.c index f6117b6ff..1e1829343 100644 --- a/nuttx/sched/sched_addreadytorun.c +++ b/nuttx/sched/sched_addreadytorun.c @@ -84,8 +84,8 @@ * btcb - Points to the blocked TCB that is ready-to-run * * Return Value: - * true if the currently active task (the head of the - * g_readytorun list) has changed. + * true if the currently active task (the head of the g_readytorun list) + * has changed. * * Assumptions: * - The caller has established a critical section before @@ -104,7 +104,7 @@ bool sched_addreadytorun(FAR _TCB *btcb) bool ret; /* Check if pre-emption is disabled for the current running task and if - * the new ready-to-run task would cause the current running task to be + * the new ready-to-run task would cause the current running task to be * preempted. */ @@ -123,7 +123,7 @@ bool sched_addreadytorun(FAR _TCB *btcb) else if (sched_addprioritized(btcb, (FAR dq_queue_t*)&g_readytorun)) { - /* Information the instrumentation logic that we are switching tasks */ + /* Inform the instrumentation logic that we are switching tasks */ sched_note_switch(rtcb, btcb); diff --git a/nuttx/sched/task_vfork.c b/nuttx/sched/task_vfork.c index 93fcb46da..64f6f0636 100644 --- a/nuttx/sched/task_vfork.c +++ b/nuttx/sched/task_vfork.c @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -151,12 +152,14 @@ FAR _TCB *task_vforksetup(start_t retaddr) /* Initialize the task control block. This calls up_initial_state() */ + svdbg("Child priority=%d start=%p\n", priority, retaddr); ret = task_schedsetup(child, priority, retaddr, parent->entry.main); if (ret != OK) { goto errout_with_tcb; } + svdbg("parent=%p, returning child=%p\n", parent, child); return child; errout_with_tcb: @@ -210,10 +213,14 @@ errout_with_tcb: pid_t task_vforkstart(FAR _TCB *child) { +#if CONFIG_TASK_NAME_SIZE > 0 + _TCB *parent = (FAR _TCB *)g_readytorun.head; +#endif FAR const char *name; pid_t pid; int ret; + svdbg("Starting Child TCB=%p, parent=%p\n", child, g_readytorun.head); DEBUGASSERT(child); /* Setup to pass parameters to the new task */ @@ -221,7 +228,7 @@ pid_t task_vforkstart(FAR _TCB *child) #if CONFIG_TASK_NAME_SIZE > 0 name = parent->name; #else - name = ""; + name = NULL; #endif (void)task_argsetup(child, name, (const char **)NULL); -- cgit v1.2.3 From 5a9162f017e457a5415eb0af7c41a7ef49d355c6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 7 Jan 2013 23:09:09 +0000 Subject: Disable the vfork() OS test... it fails git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5489 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/ostest/vfork.c | 10 ++++++++++ nuttx/arch/arm/src/common/up_vfork.c | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/examples/ostest/vfork.c b/apps/examples/ostest/vfork.c index 6c83047e3..8657f0ceb 100644 --- a/apps/examples/ostest/vfork.c +++ b/apps/examples/ostest/vfork.c @@ -47,6 +47,16 @@ #include "ostest.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Disabled this test for now. There are some issues with the vfork + * implementation. +*/ + +#undef CONFIG_ARCH_HAVE_VFORK + /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/nuttx/arch/arm/src/common/up_vfork.c b/nuttx/arch/arm/src/common/up_vfork.c index 2e3c2d4a1..3da602679 100644 --- a/nuttx/arch/arm/src/common/up_vfork.c +++ b/nuttx/arch/arm/src/common/up_vfork.c @@ -169,7 +169,11 @@ pid_t up_vfork(struct vfork_s *context) return (pid_t)ERROR; } - /* How much of the parent's stack was utilized? */ + /* How much of the parent's stack was utilized? The ARM uses + * a push-down stack so that the current stack pointer should + * be lower than the initial, adjusted stack pointer. The + * stack usage should be the difference between those two. + */ DEBUGASSERT((uint32_t)parent->adj_stack_ptr > context->sp); stackutil = (uint32_t)parent->adj_stack_ptr - context->sp; @@ -177,7 +181,7 @@ pid_t up_vfork(struct vfork_s *context) svdbg("stacksize:%d stackutil:%d\n", stacksize, stackutil); /* Make some feeble effort to perserve the stack contents. This is - * feeble because the stack surely contains invalid pointer and other + * feeble because the stack surely contains invalid pointers and other * content that will not work in the child context. However, if the * user follows all of the caveats of vfor() usage, even this feeble * effort is overkill. @@ -204,7 +208,7 @@ pid_t up_vfork(struct vfork_s *context) svdbg("New stack base:%08x SP:%08x FP:%08x\n", child->adj_stack_ptr, newsp, newfp); - /* Update the stack pointer, frame pointer, and voltile registers. When + /* Update the stack pointer, frame pointer, and voltile registers. When * the child TCB was initialized, all of the values were set to zero. * up_initial_state() altered a few values, but the return value in R0 * should be cleared to zero, providing the indication to the newly started -- cgit v1.2.3 From a9f2c6fa8ae6936da9489e4acf2a2d2cd6c0f664 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 7 Jan 2013 23:50:25 +0000 Subject: Fixed ARM vfork; re-enabled vfork OS test git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5490 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/ostest/vfork.c | 6 ------ nuttx/arch/arm/src/arm/vfork.S | 3 ++- nuttx/arch/arm/src/armv7-m/vfork.S | 3 ++- nuttx/arch/arm/src/common/up_vfork.c | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) (limited to 'apps') diff --git a/apps/examples/ostest/vfork.c b/apps/examples/ostest/vfork.c index 8657f0ceb..4e1b8c892 100644 --- a/apps/examples/ostest/vfork.c +++ b/apps/examples/ostest/vfork.c @@ -51,12 +51,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Disabled this test for now. There are some issues with the vfork - * implementation. -*/ - -#undef CONFIG_ARCH_HAVE_VFORK - /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/nuttx/arch/arm/src/arm/vfork.S b/nuttx/arch/arm/src/arm/vfork.S index b498fd7f7..226d9f7de 100644 --- a/nuttx/arch/arm/src/arm/vfork.S +++ b/nuttx/arch/arm/src/arm/vfork.S @@ -102,7 +102,7 @@ vfork: /* Create a stack frame */ - mov r0, sp /* Save the value of the stack frame on entry */ + mov r0, sp /* Save the value of the stack on entry */ sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ /* Save the volatile registers */ @@ -128,6 +128,7 @@ vfork: /* Release the stack data and return the value returned by up_vfork */ + ldr lr, [sp, #VFORK_LR_OFFSET] add sp, sp, #VFORK_SIZEOF mov pc, lr .size vfork, .-vfork diff --git a/nuttx/arch/arm/src/armv7-m/vfork.S b/nuttx/arch/arm/src/armv7-m/vfork.S index 0d9e144cd..386fca33c 100644 --- a/nuttx/arch/arm/src/armv7-m/vfork.S +++ b/nuttx/arch/arm/src/armv7-m/vfork.S @@ -105,7 +105,7 @@ vfork: /* Create a stack frame */ - mov r0, sp /* Save the value of the stack frame on entry */ + mov r0, sp /* Save the value of the stack on entry */ sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ /* Save the volatile registers */ @@ -131,6 +131,7 @@ vfork: /* Release the stack data and return the value returned by up_vfork */ + ldr lr, [sp, #VFORK_LR_OFFSET] add sp, sp, #VFORK_SIZEOF bx lr .size vfork, .-vfork diff --git a/nuttx/arch/arm/src/common/up_vfork.c b/nuttx/arch/arm/src/common/up_vfork.c index 3da602679..5349378bc 100644 --- a/nuttx/arch/arm/src/common/up_vfork.c +++ b/nuttx/arch/arm/src/common/up_vfork.c @@ -124,7 +124,7 @@ * ****************************************************************************/ -pid_t up_vfork(struct vfork_s *context) +pid_t up_vfork(const struct vfork_s *context) { _TCB *parent = (FAR _TCB *)g_readytorun.head; _TCB *child; -- cgit v1.2.3 From 3d160e45b64485aa5f231179bf61cdea8fc5c141 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 8 Jan 2013 00:04:12 +0000 Subject: Documentation update git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5491 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 1 + nuttx/Documentation/NuttX.html | 2 +- nuttx/Documentation/NuttxPortingGuide.html | 2 +- nuttx/Documentation/NuttxUserGuide.html | 39 +++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 0464c6198..cd15b430d 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -460,4 +460,5 @@ updated to detect key release events. That is kind of tricky in the USB HID keyboard report data. * apps/examples/wlan: Remove non-functional example. + * apps/examples/ostest/vfork.c: Added a test of vfork(). diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 876aa2a0a..21f732c97 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

              NuttX RTOS

              -

              Last Updated: January 4, 2012

              +

              Last Updated: January 4, 2013

              diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 24b4852e0..48fafb89f 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@

              NuttX RTOS Porting Guide

              -

              Last Updated: January 4, 2012

              +

              Last Updated: January 4, 2013

              diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html index d9dddf9be..5c76737e5 100644 --- a/nuttx/Documentation/NuttxUserGuide.html +++ b/nuttx/Documentation/NuttxUserGuide.html @@ -13,7 +13,7 @@

              NuttX Operating System

              User's Manual

              by

              Gregory Nutt

              -

              Last Updated: November 20, 2012

              +

              Last Updated: January 7, 2013

              @@ -201,6 +201,7 @@ paragraphs.
            • 2.1.5 exit
            • 2.1.6 task_restart
            • 2.1.7 getpid
            • +
            • 2.1.8 vfork

            2.1.1 task_create

            @@ -613,6 +614,40 @@ level. Compatible with the POSIX interface of the same name.

            +

            2.1.8 vfork

            +

            + Function Prototype: +

            +
              +#include <unistd.h>
              +pid_t vfork(void);
              +
            +

            + Description: + The vfork() function has the same effect as fork(), except that the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions. +

            +

            + NOTE: + vfork() is not an independent NuttX feature, but is implemented in architecture-specific logic (using only helper functions from the NuttX core logic). + As a result, vfork() may not be available on all architectures. +
            +

            + Input Parameters: + None. +

            +

            + Returned Value: + Upon successful completion, vfork() returns 0 to the child process and returns + the process ID of the child process to the parent process. + Otherwise, -1 is returned to the parent, no child process is created, and errno is set to indicate the error. +

            + Assumptions/Limitations: +

            +

            + POSIX Compatibility: + Compatible with the Unix interface of the same name. +

            +
            @@ -6741,6 +6776,7 @@ int telldir(FAR DIR *dirp);
               #include <unistd.h>
               
              +pid_t   vfork(void);
               pid_t   getpid(void);
               void    _exit(int status) noreturn_function;
               unsigned int sleep(unsigned int seconds);
              @@ -8363,6 +8399,7 @@ notify a task when a message is available on a queue.
                 
            • unistd.h, unistd.h
            • unlink
            • +
            • vfork
            • vfprintf
            • vprintf
            • vsprintf
            • -- cgit v1.2.3 From 6f241ed0443cc265d7a079f4bbf8d2d67be939ff Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 10 Jan 2013 20:00:08 +0000 Subject: Add interfaces to dynamically change symbol tables used by posix_spawn, execv, and execl. This is needed for testing. git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5506 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/Make.defs | 4 + apps/examples/Makefile | 4 +- apps/examples/README.txt | 84 +++++++++++++++++++-- nuttx/include/unistd.h | 6 ++ nuttx/libc/spawn/lib_ps.c | 53 +++++++++++-- nuttx/libc/spawn/spawn.h | 2 +- nuttx/libc/unistd/Make.defs | 2 +- nuttx/libc/unistd/lib_execsymtab.c | 147 +++++++++++++++++++++++++++++++++++++ nuttx/libc/unistd/lib_execv.c | 31 ++------ 9 files changed, 292 insertions(+), 41 deletions(-) create mode 100644 nuttx/libc/unistd/lib_execsymtab.c (limited to 'apps') diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index de2b8939f..68d4d4340 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -182,6 +182,10 @@ ifeq ($(CONFIG_EXAMPLES_PWM),y) CONFIGURED_APPS += examples/pwm endif +ifeq ($(CONFIG_EXAMPLES_POSIXSPAWN),y) +CONFIGURED_APPS += examples/posix_spawn +endif + ifeq ($(CONFIG_EXAMPLES_QENCODER),y) CONFIGURED_APPS += examples/qencoder endif diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 99312af7a..a11dbf240 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -40,8 +40,8 @@ SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf ftpc SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage -SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm qencoder relays -SUBDIRS += rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip +SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm posix_spawn qencoder +SUBDIRS += relays rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson # Sub-directories that might need context setup. Directories may need diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 7bfba721a..5c6332ee3 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -329,10 +329,10 @@ examples/elf each program in the ROMFS file system is executed. Requires CONFIG_ELF. Other configuration options: - CONFIG_EXAMPLES_ELF_DEVMINOR - The minor device number of the ROMFS block. - For example, the N in /dev/ramN. Used for registering the RAM block driver - that will hold the ROMFS file system containing the ELF executables to be - tested. Default: 0 + CONFIG_EXAMPLES_ELF_DEVMINOR - The minor device number of the ROMFS block + driver. For example, the N in /dev/ramN. Used for registering the RAM + block driver that will hold the ROMFS file system containing the ELF + executables to be tested. Default: 0 CONFIG_EXAMPLES_ELF_DEVPATH - The path to the ROMFS block driver device. This must match EXAMPLES_ELF_DEVMINOR. Used for registering the RAM block driver @@ -348,7 +348,7 @@ examples/elf Similarly for C++ flags which must be provided in CXXELFFLAGS. - 2. Your top-level nuttx/Make.defs file must alos include an approproate definition, + 2. Your top-level nuttx/Make.defs file must also include an approproate definition, LDELFFLAGS, to generate a relocatable ELF object. With GNU LD, this should include '-r' and '-e main' (or _main on some platforms). @@ -1202,6 +1202,80 @@ examples/poll CONFIGURED_APPS += uiplib +examples/posix_spawn +^^^^^^^^^^^^^^^^^^^^ + + This is a simple test of the posix_spawn() API. The example derives from + examples/elf. As a result, these tests are built using the relocatable + ELF format installed in a ROMFS file system. At run time, the test program + in the ROMFS file system is spawned using posix_spawn(). + + Requires: + + CONFIG_BINFMT_DISABLE=n - Don't disable the binary loader + CONFIG_ELF=y - Enable ELF binary loader + CONFIG_LIBC_EXECFUNCS=y - Enable support for posix_spawn + CONFIG_EXECFUNCS_SYMTAB="exports" - The name of the symbol table + created by the test. + CONFIG_EXECFUNCS_NSYMBOLS=10 - Value does not matter, it will be + corrected at runtime. + CONFIG_POSIX_SPAWN_STACKSIZE=768 - This default setting. + + Test-specific configuration options: + + CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR - The minor device number of the ROMFS + block. driver. For example, the N in /dev/ramN. Used for registering the + RAM block driver that will hold the ROMFS file system containing the ELF + executables to be tested. Default: 0 + + CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH - The path to the ROMFS block driver + device. This must match EXAMPLES_POSIXSPAWN_DEVMINOR. Used for + registering the RAM block driver that will hold the ROMFS file system + containing the ELF executables to be tested. Default: "/dev/ram0" + + NOTES: + + 1. CFLAGS should be provided in CELFFLAGS. RAM and FLASH memory regions + may require long allcs. For ARM, this might be: + + CELFFLAGS = $(CFLAGS) -mlong-calls + + Similarly for C++ flags which must be provided in CXXELFFLAGS. + + 2. Your top-level nuttx/Make.defs file must also include an approproate + definition, LDELFFLAGS, to generate a relocatable ELF object. With GNU + LD, this should include '-r' and '-e main' (or _main on some platforms). + + LDELFFLAGS = -r -e main + + If you use GCC to link, you make also need to include '-nostdlib' or + '-nostartfiles' and '-nodefaultlibs'. + + 3. This example also requires genromfs. genromfs can be build as part of the + nuttx toolchain. Or can built from the genromfs sources that can be found + at misc/tools/genromfs-0.5.2.tar.gz. In any event, the PATH variable must + include the path to the genromfs executable. + + 4. ELF size: The ELF files in this example are, be default, quite large + because they include a lot of "build garbage". You can greatly reduce the + size of the ELF binaries are using the 'objcopy --strip-unneeded' command to + remove un-necessary information from the ELF files. + + 5. Simulator. You cannot use this example with the the NuttX simulator on + Cygwin. That is because the Cygwin GCC does not generate ELF file but + rather some Windows-native binary format. + + If you really want to do this, you can create a NuttX x86 buildroot toolchain + and use that be build the ELF executables for the ROMFS file system. + + 6. Linker scripts. You might also want to use a linker scripts to combine + sections better. An example linker script is at nuttx/binfmt/libelf/gnu-elf.ld. + That example might have to be tuned for your particular linker output to + position additional sections correctly. The GNU LD LDELFFLAGS then might + be: + + LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld + examples/pwm ^^^^^^^^^^^^ diff --git a/nuttx/include/unistd.h b/nuttx/include/unistd.h index d2ace79fa..c5289624b 100644 --- a/nuttx/include/unistd.h +++ b/nuttx/include/unistd.h @@ -165,6 +165,12 @@ EXTERN int rmdir(FAR const char *pathname); #ifdef CONFIG_LIBC_EXECFUNCS EXTERN int execl(FAR const char *path, ...); EXTERN int execv(FAR const char *path, FAR char *const argv[]); + +/* Non-standard functions to manage symbol tables */ + +struct symtab_s; /* See include/nuttx/binfmt/symtab.h */ +EXTERN void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols); +EXTERN void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols); #endif /* Other */ diff --git a/nuttx/libc/spawn/lib_ps.c b/nuttx/libc/spawn/lib_ps.c index b0f6e1b07..7509d6737 100644 --- a/nuttx/libc/spawn/lib_ps.c +++ b/nuttx/libc/spawn/lib_ps.c @@ -157,11 +157,17 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path, FAR char *const argv[]) { struct sched_param param; + FAR struct symtab_s *symtab; + int nsymbols; int pid; int ret = OK; DEBUGASSERT(path); + /* Get the current symbol table selection */ + + exec_getsymtab(&symtab, &nsymbols); + /* Disable pre-emption so that we can modify the task parameters after * we start the new task; the new task will not actually begin execution * until we re-enable pre-emption. @@ -171,13 +177,11 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path, /* Start the task */ - pid = exec(path, (FAR const char **)argv, &CONFIG_EXECFUNCS_SYMTAB, - CONFIG_EXECFUNCS_NSYMBOLS); - + pid = exec(path, (FAR const char **)argv, symtab, nsymbols); if (pid < 0) { ret = errno; - sdbg("exec failed: %d\n", ret); + sdbg("ERROR: exec failed: %d\n", ret); goto errout; } @@ -211,6 +215,9 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path, if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) == 0) { + svdbg("Setting priority=%d for pid=%d\n", + param.sched_priority, pid); + (void)sched_setparam(pid, ¶m); } } @@ -231,6 +238,9 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path, if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) != 0) { + svdbg("Setting policy=%d priority=%d for pid=%d\n", + attr->policy, param.sched_priority, pid); + (void)sched_setscheduler(pid, attr->policy, ¶m); } } @@ -262,18 +272,27 @@ static inline int spawn_close(FAR struct spawn_close_file_action_s *action) { /* The return value from close() is ignored */ + svdbg("Closing fd=%d\n", action->fd); + (void)close(action->fd); return OK; } static inline int spawn_dup2(FAR struct spawn_dup2_file_action_s *action) { + int ret; + /* Perform the dup */ - int ret = dup2(action->fd1, action->fd2); + svdbg("Dup'ing %d->%d\n", action->fd1, action->fd2); + + ret = dup2(action->fd1, action->fd2); if (ret < 0) { - return errno; + int errcode = errno; + + sdbg("ERROR: dup2 failed: %d\n", errcode); + return errcode; } return OK; @@ -286,10 +305,14 @@ static inline int spawn_open(FAR struct spawn_open_file_action_s *action) /* Open the file */ + svdbg("Open'ing path=%s oflags=%04x mode=%04x\n", + action->path, action->oflags, action->mode); + fd = open(action->path, action->oflags, action->mode); if (fd < 0) { ret = errno; + sdbg("ERROR: open failed: %d\n", ret); } /* Does the return file descriptor happen to match the required file @@ -300,12 +323,16 @@ static inline int spawn_open(FAR struct spawn_open_file_action_s *action) { /* No.. dup2 to get the correct file number */ + svdbg("Dup'ing %d->%d\n", fd, action->fd); + ret = dup2(fd, action->fd); if (ret < 0) { ret = errno; + sdbg("ERROR: dup2 failed: %d\n", ret); } + svdbg("Closing fd=%d\n", fd); close(fd); } @@ -379,6 +406,7 @@ static int spawn_proxy(int argc, char *argv[]) case SPAWN_FILE_ACTION_NONE: default: + sdbg("ERROR: Unknown action: %d\n", entry->action); ret = EINVAL; break; } @@ -517,6 +545,9 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, DEBUGASSERT(path); + svdbg("pid=%p path=%s file_actions=%p attr=%p argv=%p\n", + pid, path, file_actions, attr, argv); + /* If there are no file actions to be performed and there is no change to * the signal mask, then start the new child task directly from the parent task. */ @@ -559,8 +590,11 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, ret = sched_getparam(0, ¶m); if (ret < 0) { + int errcode = errno; + + sdbg("ERROR: sched_getparam failed: %d\n", errcode); ps_semgive(&g_ps_parmsem); - return errno; + return errcode; } /* Start the intermediary/proxy task at the same priority as the parent task. */ @@ -570,8 +604,11 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, (const char **)NULL); if (proxy < 0) { + int errcode = errno; + + sdbg("ERROR: Failed to start spawn_proxy: %d\n", errcode); ps_semgive(&g_ps_parmsem); - return errno; + return errcode; } /* Wait for the proxy to complete its job */ diff --git a/nuttx/libc/spawn/spawn.h b/nuttx/libc/spawn/spawn.h index 5d0159ff2..3f4e195cc 100644 --- a/nuttx/libc/spawn/spawn.h +++ b/nuttx/libc/spawn/spawn.h @@ -1,7 +1,7 @@ /**************************************************************************** * libc/spawn/spawn.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/libc/unistd/Make.defs b/nuttx/libc/unistd/Make.defs index 3811673bf..ee3ac0fc9 100644 --- a/nuttx/libc/unistd/Make.defs +++ b/nuttx/libc/unistd/Make.defs @@ -43,7 +43,7 @@ CSRCS += lib_chdir.c lib_getcwd.c endif ifeq ($(CONFIG_LIBC_EXECFUNCS),y) -CSRCS += lib_execl.c lib_execv.c +CSRCS += lib_execl.c lib_execv.c lib_execsymtab.c endif endif diff --git a/nuttx/libc/unistd/lib_execsymtab.c b/nuttx/libc/unistd/lib_execsymtab.c new file mode 100644 index 000000000..e95107d15 --- /dev/null +++ b/nuttx/libc/unistd/lib_execsymtab.c @@ -0,0 +1,147 @@ +/**************************************************************************** + * libc/unistd/lib_execsymtab.c + * + * Copyright (C) 2013 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 + +#ifdef CONFIG_LIBC_EXECFUNCS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* If CONFIG_LIBC_EXECFUNCS is defined in the configuration, then the + * following must also be defined: + */ + +/* Symbol table used by exec[l|v] */ + +#ifndef CONFIG_EXECFUNCS_SYMTAB +# error "CONFIG_EXECFUNCS_SYMTAB must be defined" +#endif + +/* Number of Symbols in the Table */ + +#ifndef CONFIG_EXECFUNCS_NSYMBOLS +# error "CONFIG_EXECFUNCS_NSYMBOLS must be defined" +#endif + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static FAR struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB; +static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: exec_getsymtab + * + * Description: + * Get the current symbol table selection as an atomic operation. + * + * Input Parameters: + * symtab - The location to store the symbol table. + * nsymbols - The location to store the number of symbols in the symbol table. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols) +{ + irqstate_t flags; + + DEBUGASSERT(symtab && nsymbols); + + /* Disable interrupts very briefly so that both the symbol table and its + * size are returned as a single atomic operation. + */ + + flags = irqsave(); + *symtab = g_exec_symtab; + *nsymbols = g_exec_nsymbols; + irqrestore(flags); +} + +/**************************************************************************** + * Name: exec_setsymtab + * + * Description: + * Select a new symbol table selection as an atomic operation. + * + * Input Parameters: + * symtab - The new symbol table. + * nsymbols - The number of symbols in the symbol table. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols) +{ + irqstate_t flags; + + DEBUGASSERT(symtab); + + /* Disable interrupts very briefly so that both the symbol table and its + * size are set as a single atomic operation. + */ + + flags = irqsave(); + g_exec_symtab = symtab; + g_exec_nsymbols = nsymbols; + irqrestore(flags); +} + +#endif /* CONFIG_LIBC_EXECFUNCS */ \ No newline at end of file diff --git a/nuttx/libc/unistd/lib_execv.c b/nuttx/libc/unistd/lib_execv.c index 6d09bf481..e35138be5 100644 --- a/nuttx/libc/unistd/lib_execv.c +++ b/nuttx/libc/unistd/lib_execv.c @@ -51,27 +51,6 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* If CONFIG_LIBC_EXECFUNCS is defined in the configuration, then the - * following must also be defined: - */ - -/* Symbol table used by exec[l|v] */ - -#ifndef CONFIG_EXECFUNCS_SYMTAB -# error "CONFIG_EXECFUNCS_SYMTAB must be defined" -#endif - -/* Number of Symbols in the Table */ - -#ifndef CONFIG_EXECFUNCS_NSYMBOLS -# error "CONFIG_EXECFUNCS_NSYMBOLS must be defined" -#endif - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB; /**************************************************************************** * Private Variables @@ -140,13 +119,17 @@ extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB; int execv(FAR const char *path, FAR char *const argv[]) { + FAR struct symtab_s *symtab; + int nsymbols; int ret; - /* Start the task */ + /* Get the current symbol table selection */ - ret = exec(path, (FAR const char **)argv, - &CONFIG_EXECFUNCS_SYMTAB, CONFIG_EXECFUNCS_NSYMBOLS); + exec_getsymtab(&symtab, &nsymbols); + + /* Start the task */ + ret = exec(path, (FAR const char **)argv, symtab, nsymbols); if (ret < 0) { sdbg("exec failed: %d\n", errno); -- cgit v1.2.3 From f011bd7ef6f91261969ae08655016b8a7b41a796 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 10 Jan 2013 21:39:57 +0000 Subject: Added a test of posix_spawn() git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5507 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 1 + apps/examples/Kconfig | 1 + apps/examples/elf/tests/Makefile | 18 +- apps/examples/elf/tests/mksymtab.sh | 18 +- apps/examples/nxflat/tests/Makefile | 4 +- apps/examples/posix_spawn/Kconfig | 29 + apps/examples/posix_spawn/Makefile | 110 ++++ apps/examples/posix_spawn/filesystem/Makefile | 85 +++ apps/examples/posix_spawn/filesystem/mksymtab.sh | 51 ++ .../posix_spawn/filesystem/program/Makefile | 59 ++ .../posix_spawn/filesystem/program/program.c | 60 ++ apps/examples/posix_spawn/filesystem/testdata.txt | 2 + apps/examples/posix_spawn/spawn_main.c | 356 ++++++++++++ nuttx/ChangeLog | 2 + .../configs/stm32f4discovery/posix_spawn/Make.defs | 130 +++++ .../configs/stm32f4discovery/posix_spawn/defconfig | 625 +++++++++++++++++++++ .../configs/stm32f4discovery/posix_spawn/setenv.sh | 79 +++ nuttx/libc/unistd/lib_execsymtab.c | 6 +- 18 files changed, 1605 insertions(+), 31 deletions(-) create mode 100644 apps/examples/posix_spawn/Kconfig create mode 100644 apps/examples/posix_spawn/Makefile create mode 100644 apps/examples/posix_spawn/filesystem/Makefile create mode 100755 apps/examples/posix_spawn/filesystem/mksymtab.sh create mode 100644 apps/examples/posix_spawn/filesystem/program/Makefile create mode 100644 apps/examples/posix_spawn/filesystem/program/program.c create mode 100644 apps/examples/posix_spawn/filesystem/testdata.txt create mode 100644 apps/examples/posix_spawn/spawn_main.c create mode 100644 nuttx/configs/stm32f4discovery/posix_spawn/Make.defs create mode 100644 nuttx/configs/stm32f4discovery/posix_spawn/defconfig create mode 100755 nuttx/configs/stm32f4discovery/posix_spawn/setenv.sh (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index cd15b430d..6b63527a7 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -461,4 +461,5 @@ the USB HID keyboard report data. * apps/examples/wlan: Remove non-functional example. * apps/examples/ostest/vfork.c: Added a test of vfork(). + * apps/exampes/posix_spawn: Added a test of poxis_spawn(). diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index b0cbd7088..ec0a97dd4 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -39,6 +39,7 @@ source "$APPSDIR/examples/pashello/Kconfig" source "$APPSDIR/examples/pipe/Kconfig" source "$APPSDIR/examples/poll/Kconfig" source "$APPSDIR/examples/pwm/Kconfig" +source "$APPSDIR/examples/posix_spawn/Kconfig" source "$APPSDIR/examples/qencoder/Kconfig" source "$APPSDIR/examples/relays/Kconfig" source "$APPSDIR/examples/rgmp/Kconfig" diff --git a/apps/examples/elf/tests/Makefile b/apps/examples/elf/tests/Makefile index 778dd6480..755199506 100644 --- a/apps/examples/elf/tests/Makefile +++ b/apps/examples/elf/tests/Makefile @@ -66,7 +66,7 @@ SYMTAB_SRC = $(TESTS_DIR)/symtab.c define DIR_template $(1)_$(2): - @$(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV) + $(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV) endef all: $(ROMFS_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC) @@ -87,7 +87,7 @@ install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) # Create the romfs directory $(ROMFS_DIR): - @mkdir $(ROMFS_DIR) + $(Q) mkdir $(ROMFS_DIR) # Populate the romfs directory @@ -96,25 +96,25 @@ populate: $(ROMFS_DIR) build install # Create the romfs.img file from the populated romfs directory $(ROMFS_IMG): populate - @genromfs -f $@ -d $(ROMFS_DIR) -V "ELFTEST" + $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "ELFTEST" # Create the romfs.h header file from the romfs.img file $(ROMFS_HDR) : $(ROMFS_IMG) - @(cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) + $(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) # Create the dirlist.h header file from the romfs directory $(DIRLIST_HDR) : populate - @$(TESTS_DIR)/mkdirlist.sh $(ROMFS_DIR) >$@ + $(Q) $(TESTS_DIR)/mkdirlist.sh $(ROMFS_DIR) >$@ -# Create the exported symbol table list from the derived *-thunk.S files +# Create the exported symbol table $(SYMTAB_SRC): build - @$(TESTS_DIR)/mksymtab.sh -t varlist.tmp $(ROMFS_DIR) >$@ + $(Q) $(TESTS_DIR)/mksymtab.sh $(ROMFS_DIR) >$@ # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) - @rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) varlist.tmp - @rm -rf $(ROMFS_DIR) $(DIRLIST_HDR) + $(Q) rm -f $(ROMFS_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -rf $(ROMFS_DIR) diff --git a/apps/examples/elf/tests/mksymtab.sh b/apps/examples/elf/tests/mksymtab.sh index 56be10f73..51408a89c 100755 --- a/apps/examples/elf/tests/mksymtab.sh +++ b/apps/examples/elf/tests/mksymtab.sh @@ -1,22 +1,6 @@ #!/bin/bash -usage="Usage: $0 [-t ] " - -# Check for the optional tempory file name - -tmpfile=varlist.tmp -if [ "X${1}" = "X-t" ]; then - shift - tmpfile=$1 - shift - - if [ -z "$tmpfile" ]; then - echo "ERROR: Missing " - echo "" - echo $usage - exit 1 - fi -fi +usage="Usage: $0 " # Check for the required ROMFS directory path diff --git a/apps/examples/nxflat/tests/Makefile b/apps/examples/nxflat/tests/Makefile index 4979c7fd4..53e43288f 100644 --- a/apps/examples/nxflat/tests/Makefile +++ b/apps/examples/nxflat/tests/Makefile @@ -97,7 +97,7 @@ $(SYMTAB): build # Clean each subdirectory clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean) - @rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB) - @rm -rf $(ROMFS_DIR) $(ROMFS_DIRLIST) + @rm -f $(ROMFS_HDR) $(ROMFS_DIRLIST) $(ROMFS_IMG) $(SYMTAB) + @rm -rf $(ROMFS_DIR) diff --git a/apps/examples/posix_spawn/Kconfig b/apps/examples/posix_spawn/Kconfig new file mode 100644 index 000000000..508065913 --- /dev/null +++ b/apps/examples/posix_spawn/Kconfig @@ -0,0 +1,29 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_POSIXSPAWN + bool "posix_spawn Unit Test" + default n + ---help--- + Enable the posix_spawn() unit test + +if EXAMPLES_POSIXSPAWN +config EXAMPLES_POSIXSPAWN_DEVMINOR + int "ROMFS Minor Device Number" + default 0 + ---help--- + The minor device number of the ROMFS block. For example, the N in /dev/ramN. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the ELF executables to be tested. Default: 0 + +config EXAMPLES_POSIXSPAWN_DEVPATH + string "ROMFS Devie Path" + default "/dev/ram0" + ---help--- + The path to the ROMFS block driver device. This must match EXAMPLES_POSIXSPAWN_DEVMINOR. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the ELF executables to be tested. Default: "/dev/ram0" + +endif diff --git a/apps/examples/posix_spawn/Makefile b/apps/examples/posix_spawn/Makefile new file mode 100644 index 000000000..d21c8f856 --- /dev/null +++ b/apps/examples/posix_spawn/Makefile @@ -0,0 +1,110 @@ +############################################################################ +# apps/examples/posix_spawn/Makefile +# +# Copyright (C) 2013 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)/Make.defs +include $(APPDIR)/Make.defs + +# ELF Example + +ASRCS = +CSRCS = spawn_main.c symtab.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . --dep-path filesystem + +# Build targets + +VPATH = filesystem + +all: .built +.PHONY: really_build clean_filesystem clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +# This is a little messy. The build is broken into two pieces: (1) the +# filesystem/ subdir build that auto-generates several files, and (2) the real +# build. This is done because we need a fresh build context after auto- +# generating the source files. + +really_build: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +.built: + @$(MAKE) -C filesystem TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) + @$(MAKE) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" really_build + +context: + +# We can't make dependencies in this directory because the required +# header files may not yet exist. + +.depend: + @touch $@ + +depend: .depend + +clean_filesystem: + @$(MAKE) -C filesystem TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) clean + +clean: clean_filesystem + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/apps/examples/posix_spawn/filesystem/Makefile b/apps/examples/posix_spawn/filesystem/Makefile new file mode 100644 index 000000000..19a02bb80 --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/Makefile @@ -0,0 +1,85 @@ +############################################################################ +# apps/examples/posix_spawn/filesystem/Makefile +# +# Copyright (C) 2013 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)/Make.defs +include $(APPDIR)$(DELIM)Make.defs + +SPAWN_DIR = $(APPDIR)$(DELIM)examples$(DELIM)posix_spawn +FILESYSTEM_DIR = $(SPAWN_DIR)$(DELIM)filesystem +ROMFS_DIR = $(FILESYSTEM_DIR)$(DELIM)romfs +ROMFS_IMG = $(FILESYSTEM_DIR)$(DELIM)romfs.img +ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h +SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c + +all: $(ROMFS_HDR) $(SYMTAB_SRC) +.PHONY: all program clean install populate + +# Create the romfs directory + +$(ROMFS_DIR): + $(Q) mkdir $(ROMFS_DIR) + +# Build the test program + +program: $(ROMFS_DIR) + $(Q) $(MAKE) -C program program TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + +# Install the test program in the romfs directory + +install: program testdata.txt + $(Q) $(MAKE) -C program install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + $(Q) install --mode=0644 testdata.txt $(ROMFS_DIR)/testdata.txt + +# Create the romfs.img file from the romfs directory + +$(ROMFS_IMG): install + $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "POSIXSPAWN" + +# Create the romfs.h header file from the romfs.img file + +$(ROMFS_HDR) : $(ROMFS_IMG) + $(Q) (cd $(FILESYSTEM_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) + +# Create the exported symbol table + +$(SYMTAB_SRC): program + $(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@ + +# Clean each subdirectory + +clean: + $(Q) $(MAKE) -C program clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + $(Q) rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -rf $(ROMFS_DIR) diff --git a/apps/examples/posix_spawn/filesystem/mksymtab.sh b/apps/examples/posix_spawn/filesystem/mksymtab.sh new file mode 100755 index 000000000..51408a89c --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/mksymtab.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +usage="Usage: $0 " + +# Check for the required ROMFS directory path + +dir=$1 +if [ -z "$dir" ]; then + echo "ERROR: Missing " + echo "" + echo $usage + exit 1 +fi + +if [ ! -d "$dir" ]; then + echo "ERROR: Directory $dir does not exist" + echo "" + echo $usage + exit 1 +fi + +# Extract all of the undefined symbols from the ELF files and create a +# list of sorted, unique undefined variable names. + +varlist=`find ${dir} -executable -type f | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq` + +# Now output the symbol table as a structure in a C source file. All +# undefined symbols are declared as void* types. If the toolchain does +# any kind of checking for function vs. data objects, then this could +# faile + +echo "#include " +echo "#include " +echo "" + +for var in $varlist; do + echo "extern void *${var};" +done + +echo "" +echo "const struct symtab_s exports[] = " +echo "{" + +for var in $varlist; do + echo " {\"${var}\", &${var}}," +done + +echo "};" +echo "" +echo "const int nexports = sizeof(exports) / sizeof(struct symtab_s);" + diff --git a/apps/examples/posix_spawn/filesystem/program/Makefile b/apps/examples/posix_spawn/filesystem/program/Makefile new file mode 100644 index 000000000..cf55797b2 --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/program/Makefile @@ -0,0 +1,59 @@ +############################################################################ +# examples/posix_spawn/filesystem/program/Makefile +# +# Copyright (C) 2013 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)/Make.defs + +BIN = program + +SRCS = $(BIN).c +OBJS = $(SRCS:.c=.o) + +all: $(BIN) + +$(OBJS): %.o: %.c + @echo "CC: $<" + $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ + +$(BIN): $(OBJS) + @echo "LD: $<" + $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + +clean: + $(call DELFILE, $(BIN)) + $(call CLEAN) + +install: + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install --mode=0755 $(BIN) $(ROMFS_DIR)/$(BIN) diff --git a/apps/examples/posix_spawn/filesystem/program/program.c b/apps/examples/posix_spawn/filesystem/program/program.c new file mode 100644 index 000000000..f63b559c8 --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/program/program.c @@ -0,0 +1,60 @@ +/**************************************************************************** + * examples/posix_spawn/filesystem/program/program.c + * + * Copyright (C) 2013 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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv) +{ + int ch; + + /* stdin should have been redirected to testdata.txt. Read and print until + * we hit the end of file. + */ + + while ((ch = getchar()) != EOF) + { + putchar(ch); + } + + return 0; +} diff --git a/apps/examples/posix_spawn/filesystem/testdata.txt b/apps/examples/posix_spawn/filesystem/testdata.txt new file mode 100644 index 000000000..bb581fbb5 --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/testdata.txt @@ -0,0 +1,2 @@ +Now is the time for all good men to come to the aid of their party. + diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c new file mode 100644 index 000000000..3e3a7b1b1 --- /dev/null +++ b/apps/examples/posix_spawn/spawn_main.c @@ -0,0 +1,356 @@ +/**************************************************************************** + * examples/posix_spawn/spawn_main.c + * + * Copyright (C) 2013 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 +#include + +#include +#include +#include + +#include "filesystem/romfs.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Check configuration. This is not all of the configuration settings that + * are required -- only the more obvious. + */ + +#if CONFIG_NFILE_DESCRIPTORS < 1 +# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file" +#endif + +#ifdef CONFIG_BINFMT_DISABLE +# error "The binary loader is disabled (CONFIG_BINFMT_DISABLE)!" +#endif + +#ifndef CONFIG_ELF +# error "You must select CONFIG_ELF in your configuration file" +#endif + +#ifndef CONFIG_FS_ROMFS +# error "You must select CONFIG_FS_ROMFS in your configuration file" +#endif + +#ifdef CONFIG_DISABLE_MOUNTPOINT +# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" +#endif + +#ifdef CONFIG_BINFMT_DISABLE +# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file" +#endif + +/* Describe the ROMFS file system */ + +#define SECTORSIZE 512 +#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +#define MOUNTPT "/mnt/romfs" + +#ifndef CONFIG_EXAMPLES_ELF_DEVMINOR +# define CONFIG_EXAMPLES_ELF_DEVMINOR 0 +#endif + +#ifndef CONFIG_EXAMPLES_ELF_DEVPATH +# define CONFIG_EXAMPLES_ELF_DEVPATH "/dev/ram0" +#endif + +/* If CONFIG_DEBUG is enabled, use dbg instead of printf so that the + * output will be synchronous with the debug output. + */ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG +# define message(format, arg...) dbg(format, ##arg) +# define err(format, arg...) dbg(format, ##arg) +# else +# define message(format, arg...) printf(format, ##arg) +# define err(format, arg...) fprintf(stderr, format, ##arg) +# endif +#else +# ifdef CONFIG_DEBUG +# define message dbg +# define err dbg +# else +# define message printf +# define err printf +# endif +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static unsigned int g_mminitial; /* Initial memory usage */ +static unsigned int g_mmstep; /* Memory Usage at beginning of test step */ + +static const char delimiter[] = + "****************************************************************************"; +static const char program[] = "program"; +static const char data[] = "testdata.txt"; + +static char fullpath[128]; + +/**************************************************************************** + * Symbols from Auto-Generated Code + ****************************************************************************/ + +extern const struct symtab_s exports[]; +extern const int nexports; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mm_update + ****************************************************************************/ + +static void mm_update(FAR unsigned int *previous, FAR const char *msg) +{ + struct mallinfo mmcurrent; + + /* Get the current memory usage */ + +#ifdef CONFIG_CAN_PASS_STRUCTS + mmcurrent = mallinfo(); +#else + (void)mallinfo(&mmcurrent); +#endif + + /* Show the change from the previous time */ + + printf("\nMemory Usage %s:\n", msg); + printf(" Before: %8u After: %8u Change: %8d\n", + *previous, mmcurrent.uordblks, (int)mmcurrent.uordblks - (int)*previous); + + /* Set up for the next test */ + + *previous = mmcurrent.uordblks; +} + +/**************************************************************************** + * Name: mm_initmonitor + ****************************************************************************/ + +static void mm_initmonitor(void) +{ + struct mallinfo mmcurrent; + +#ifdef CONFIG_CAN_PASS_STRUCTS + mmcurrent = mallinfo(); +#else + (void)mallinfo(&mmcurrent); +#endif + + g_mminitial = mmcurrent.uordblks; + g_mmstep = mmcurrent.uordblks; + + printf("Initial memory usage: %d\n", mmcurrent.uordblks); +} + +/**************************************************************************** + * Name: testheader + ****************************************************************************/ + +static inline void testheader(FAR const char *progname) +{ + message("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: spawn_main + ****************************************************************************/ + +int spawn_main(int argc, char *argv[]) +{ + posix_spawn_file_actions_t file_actions; + posix_spawnattr_t attr; + FAR const char *filepath; + pid_t pid; + int ret; + + /* Initialize the memory monitor */ + + mm_initmonitor(); + + /* Initialize the ELF binary loader */ + + message("Initializing the ELF binary loader\n"); + ret = elf_initialize(); + if (ret < 0) + { + err("ERROR: Initialization of the ELF loader failed: %d\n", ret); + exit(1); + } + + mm_update(&g_mmstep, "after elf_initialize"); + + /* Create a ROM disk for the ROMFS filesystem */ + + message("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_ELF_DEVMINOR); + ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR, (FAR uint8_t *)romfs_img, + NSECTORS(romfs_img_len), SECTORSIZE); + if (ret < 0) + { + err("ERROR: romdisk_register failed: %d\n", ret); + elf_uninitialize(); + exit(1); + } + + mm_update(&g_mmstep, "after romdisk_register"); + + /* Mount the file system */ + + message("Mounting ROMFS filesystem at target=%s with source=%s\n", + MOUNTPT, CONFIG_EXAMPLES_ELF_DEVPATH); + + ret = mount(CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL); + if (ret < 0) + { + err("ERROR: mount(%s,%s,romfs) failed: %s\n", + CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, errno); + elf_uninitialize(); + } + + mm_update(&g_mmstep, "after mount"); + + /* Does the system support the PATH variable? Has the PATH variable + * already been set? If YES and NO, then set the PATH variable to + * the ROMFS mountpoint. + */ + +#if defined(CONFIG_BINFMT_EXEPATH) && !defined(CONFIG_PATH_INITIAL) + (void)setenv("PATH", MOUNTPT, 1); +#endif + + /* Make sure that we are using our symbol take */ + + exec_setsymtab(exports, nexports); + + /* Output a seperated so that we can clearly discriminate the output of + * this program from the others. + */ + + testheader(program); + + /* Initialize the attributes file actions structure */ + + ret = posix_spawn_file_actions_init(&file_actions); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_init failed: %d\n", ret); + } + + ret = posix_spawnattr_init(&attr); + if (ret != 0) + { + err("ERROR: posix_spawnattr_init failed: %d\n", ret); + } + + /* Set up to close stdin (0) and open testdata.txt as the program input */ + + ret = posix_spawn_file_actions_addclose(&file_actions, 0); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_addclose failed: %d\n", ret); + } + + snprintf(fullpath, 128, "%s/%s", MOUNTPT, data); + ret = posix_spawn_file_actions_addopen(&file_actions, 0, fullpath, O_RDONLY, 0644); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_addopen failed: %d\n", ret); + } + + /* If the binary loader does not support the PATH variable, then + * create the full path to the executable program. Otherwise, + * use the relative path so that the binary loader will have to + * search the PATH variable to find the executable. + */ + +#ifdef CONFIG_BINFMT_EXEPATH + filepath = program; +#else + snprintf(fullpath, 128, "%s/%s", MOUNTPT, program); + filepath = fullpath; +#endif + + /* Execute the program */ + + mm_update(&g_mmstep, "before posix_spawn"); + + ret = posix_spawn(&pid, filepath, &file_actions, &attr, NULL, NULL); + if (ret != 0) + { + err("ERROR: posix_spawn failed: %d\n", ret); + } + + sleep(1); + mm_update(&g_mmstep, "after posix_spawn"); + + /* Clean-up */ + + (void)posix_spawn_file_actions_destroy(&file_actions); + (void)posix_spawnattr_destroy(&attr); + elf_uninitialize(); + + mm_update(&g_mmstep, "End-of-Test"); + return 0; +} diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 421b1ca60..7ddc4901e 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3903,4 +3903,6 @@ untested and undocumented. * drivers/usbdev/pl2303.c: Fix typols in the PL2303 driver (from Max Holtzberg). + * configs/stm32f4discovery/posix_spawn: Added a configuration + that can be used for testing posix_spawn(). diff --git a/nuttx/configs/stm32f4discovery/posix_spawn/Make.defs b/nuttx/configs/stm32f4discovery/posix_spawn/Make.defs new file mode 100644 index 000000000..34b9f7feb --- /dev/null +++ b/nuttx/configs/stm32f4discovery/posix_spawn/Make.defs @@ -0,0 +1,130 @@ +############################################################################ +# configs/stm32f4discovery/posix_spawn/Make.defs +# +# 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. +# +############################################################################ + +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/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" + MAXOPTIMIZATION = -O2 +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/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 +else + 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 +ARCHWARNINGSXX = -Wall -Wshadow +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__ + +# NXFLAT module definitions + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs +CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs + +LDELFFLAGS = -r -e main +ifeq ($(WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}" +else + LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld +endif + +# File extensions + +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +# Linker flags + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +# Host tools + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe +HOSTLDFLAGS = + diff --git a/nuttx/configs/stm32f4discovery/posix_spawn/defconfig b/nuttx/configs/stm32f4discovery/posix_spawn/defconfig new file mode 100644 index 000000000..b908393d8 --- /dev/null +++ b/nuttx/configs/stm32f4discovery/posix_spawn/defconfig @@ -0,0 +1,625 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_HOST_LINUX is not set +# CONFIG_HOST_OSX 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 +# +# CONFIG_APPS_DIR="../apps" +# 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 is not set + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_SYMBOLS is not set + +# +# System Type +# +# CONFIG_ARCH_8051 is not set +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_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_IMX is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_LM 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_SAM3U is not set +CONFIG_ARCH_CHIP_STM32=y +# CONFIG_ARCH_CHIP_STR71X is not set +CONFIG_ARCH_CORTEXM4=y +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_HAVE_CMNVECTOR=y +# CONFIG_ARMV7M_CMNVECTOR is not set +# CONFIG_ARCH_FPU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARMV7M_MPU is not set +CONFIG_BOARD_LOOPSPERMSEC=16717 +# CONFIG_ARCH_CALIBRATION is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set +CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y +# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set +# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI is not set +# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set +# CONFIG_SERIAL_TERMIOS is not set + +# +# STM32 Configuration Options +# +# 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_STM32F103RET6 is not set +# CONFIG_ARCH_CHIP_STM32F103VCT6 is not set +# CONFIG_ARCH_CHIP_STM32F103VET6 is not set +# CONFIG_ARCH_CHIP_STM32F103ZET6 is not set +# CONFIG_ARCH_CHIP_STM32F105VBT7 is not set +# CONFIG_ARCH_CHIP_STM32F107VC is not set +# CONFIG_ARCH_CHIP_STM32F207IG 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_STM32_STM32F40XX=y +# CONFIG_STM32_DFU is not set + +# +# STM32 Peripheral Support +# +# 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_IWDG is not set +# CONFIG_STM32_OTGFS is not set +# CONFIG_STM32_OTGHS is not set +# CONFIG_STM32_PWR is not set +# CONFIG_STM32_RNG is not set +# CONFIG_STM32_SDIO is not set +# CONFIG_STM32_SPI1 is not set +# 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 is not set +# CONFIG_STM32_UART4 is not set +# CONFIG_STM32_UART5 is not set +# CONFIG_STM32_USART6 is not set +# CONFIG_STM32_WWDG 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_FORCEPOWER is not set +# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set +CONFIG_STM32_CCMEXCLUDE=y + +# +# U[S]ART Configuration +# +# CONFIG_USART2_RS485 is not set + +# +# USB Host Configuration +# + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_IRQPRIO=y +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +CONFIG_ARCH_HAVE_VFORK=y +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set + +# +# Board Settings +# +CONFIG_DRAM_START=0x20000000 +CONFIG_DRAM_SIZE=114688 +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 + +# +# 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 + +# +# Board Selection +# +CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y +# 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 is not set +CONFIG_ARCH_HAVE_IRQBUTTONS=y + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_INSTRUMENTATION is not set +CONFIG_TASK_NAME_SIZE=0 +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2012 +CONFIG_START_MONTH=10 +CONFIG_START_DAY=26 +CONFIG_DEV_CONSOLE=y +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_WAITPID is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="spawn_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# 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_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set +# CONFIG_DISABLE_POLL is not set + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +CONFIG_ARCH_HAVE_I2CRESET=y +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD 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=y +# CONFIG_16550_UART is not set +CONFIG_ARCH_HAVE_USART2=y +CONFIG_MCU_SERIAL=y +CONFIG_USART2_SERIAL_CONSOLE=y +# 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_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_FS_FAT is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_NXFFS is not set +CONFIG_FS_ROMFS=y + +# +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=2 +# CONFIG_GRAN is not set + +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +CONFIG_BINFMT_EXEPATH=y +CONFIG_PATH_INITIAL="/mnt/romfs" +# CONFIG_NXFLAT is not set +CONFIG_ELF=y +CONFIG_ELF_ALIGN_LOG2=2 +CONFIG_ELF_STACKSIZE=2048 +CONFIG_ELF_BUFFERSIZE=128 +CONFIG_ELF_BUFFERINCR=32 +# CONFIG_PIC is not set +CONFIG_BINFMT_CONSTRUCTORS=y +CONFIG_SYMTAB_ORDEREDBYNAME=y + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=256 +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_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=y +CONFIG_EXECFUNCS_SYMTAB="exports" +CONFIG_EXECFUNCS_NSYMBOLS=10 +CONFIG_POSIX_SPAWN_STACKSIZE=768 +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set + +# +# Non-standard Helper Functions +# +# CONFIG_LIB_KBDCODEC is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +# CONFIG_HAVE_CXXINITIALIZE is not set +# CONFIG_CXX_NEWLONG is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +# CONFIG_BUILTIN is not set + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +# CONFIG_EXAMPLES_NSH is not set +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +CONFIG_EXAMPLES_POSIXSPAWN=y +CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR=0 +CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH="/dev/ram0" +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +# CONFIG_NSH_LIBRARY is not set + +# +# NxWidgets/NxWM +# + +# +# System NSH Add-Ons +# + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +# CONFIG_SYSTEM_READLINE is not set + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/nuttx/configs/stm32f4discovery/posix_spawn/setenv.sh b/nuttx/configs/stm32f4discovery/posix_spawn/setenv.sh new file mode 100755 index 000000000..c06a15c9c --- /dev/null +++ b/nuttx/configs/stm32f4discovery/posix_spawn/setenv.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# configs/stm32f4discovery/posix_spawn/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" + +# 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}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# This the the Cygwin path to the location where I built genromfs. If you use +# the buildroot toolchain, then genromfs can probably be found in TOOLCHAIN_DIR +export GENROMFS_PATH="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:${GENROMFS_PATH}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/libc/unistd/lib_execsymtab.c b/nuttx/libc/unistd/lib_execsymtab.c index e95107d15..7abb2d74e 100644 --- a/nuttx/libc/unistd/lib_execsymtab.c +++ b/nuttx/libc/unistd/lib_execsymtab.c @@ -107,7 +107,7 @@ void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols) * size are returned as a single atomic operation. */ - flags = irqsave(); + flags = irqsave(); *symtab = g_exec_symtab; *nsymbols = g_exec_nsymbols; irqrestore(flags); @@ -138,8 +138,8 @@ void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols) * size are set as a single atomic operation. */ - flags = irqsave(); - g_exec_symtab = symtab; + flags = irqsave(); + g_exec_symtab = symtab; g_exec_nsymbols = nsymbols; irqrestore(flags); } -- cgit v1.2.3 From 7609c9a19206ff0c19ef2e6cba4d6a5207d5cf30 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 10 Jan 2013 23:06:23 +0000 Subject: Fix problem with initialization of file actions git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5508 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/posix_spawn/spawn_main.c | 4 ++++ nuttx/libc/spawn/lib_psfa_init.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c index 3e3a7b1b1..608145232 100644 --- a/apps/examples/posix_spawn/spawn_main.c +++ b/apps/examples/posix_spawn/spawn_main.c @@ -304,6 +304,8 @@ int spawn_main(int argc, char *argv[]) err("ERROR: posix_spawnattr_init failed: %d\n", ret); } + mm_update(&g_mmstep, "after file_action/attr init"); + /* Set up to close stdin (0) and open testdata.txt as the program input */ ret = posix_spawn_file_actions_addclose(&file_actions, 0); @@ -319,6 +321,8 @@ int spawn_main(int argc, char *argv[]) err("ERROR: posix_spawn_file_actions_addopen failed: %d\n", ret); } + mm_update(&g_mmstep, "after adding file_actions"); + /* If the binary loader does not support the PATH variable, then * create the full path to the executable program. Otherwise, * use the relative path so that the binary loader will have to diff --git a/nuttx/libc/spawn/lib_psfa_init.c b/nuttx/libc/spawn/lib_psfa_init.c index cb638d6e7..4e23703ae 100644 --- a/nuttx/libc/spawn/lib_psfa_init.c +++ b/nuttx/libc/spawn/lib_psfa_init.c @@ -65,6 +65,6 @@ int posix_spawn_file_actions_init(FAR posix_spawn_file_actions_t *file_actions) { - file_actions = NULL; + *file_actions = NULL; return OK; } -- cgit v1.2.3 From e7a5090e55f7db78164fda2696af414c3e083806 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 11 Jan 2013 16:53:44 +0000 Subject: Various changes while debugging posix_spawn git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5510 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/elf/tests/hello/hello.c | 12 +- apps/examples/posix_spawn/Makefile | 17 +-- apps/examples/posix_spawn/filesystem/Makefile | 25 ++-- .../examples/posix_spawn/filesystem/hello/Makefile | 59 ++++++++++ apps/examples/posix_spawn/filesystem/hello/hello.c | 78 +++++++++++++ .../posix_spawn/filesystem/program/Makefile | 59 ---------- .../posix_spawn/filesystem/program/program.c | 60 ---------- .../posix_spawn/filesystem/redirect/Makefile | 59 ++++++++++ .../posix_spawn/filesystem/redirect/redirect.c | 63 ++++++++++ apps/examples/posix_spawn/spawn_main.c | 118 +++++++++++++++++-- nuttx/ChangeLog | 2 + nuttx/include/spawn.h | 12 +- nuttx/libc/spawn/Make.defs | 8 ++ nuttx/libc/spawn/lib_ps.c | 13 ++- nuttx/libc/spawn/lib_psa_dump.c | 127 ++++++++++++++++++++ nuttx/libc/spawn/lib_psa_init.c | 3 +- nuttx/libc/spawn/lib_psfa_dump.c | 129 +++++++++++++++++++++ nuttx/sched/task_vfork.c | 61 ++++++++++ 18 files changed, 745 insertions(+), 160 deletions(-) create mode 100644 apps/examples/posix_spawn/filesystem/hello/Makefile create mode 100644 apps/examples/posix_spawn/filesystem/hello/hello.c delete mode 100644 apps/examples/posix_spawn/filesystem/program/Makefile delete mode 100644 apps/examples/posix_spawn/filesystem/program/program.c create mode 100644 apps/examples/posix_spawn/filesystem/redirect/Makefile create mode 100644 apps/examples/posix_spawn/filesystem/redirect/redirect.c create mode 100644 nuttx/libc/spawn/lib_psa_dump.c create mode 100644 nuttx/libc/spawn/lib_psfa_dump.c (limited to 'apps') diff --git a/apps/examples/elf/tests/hello/hello.c b/apps/examples/elf/tests/hello/hello.c index 6b1d079d8..bc4953e12 100644 --- a/apps/examples/elf/tests/hello/hello.c +++ b/apps/examples/elf/tests/hello/hello.c @@ -63,13 +63,13 @@ int main(int argc, char **argv) { printf("argv[%d]\t= ", i); if (argv[i]) - { - printf("(0x%p) \"%s\"\n", argv[i], argv[i]); - } + { + printf("(0x%p) \"%s\"\n", argv[i], argv[i]); + } else - { - printf("NULL?\n"); - } + { + printf("NULL?\n"); + } } printf("argv[%d]\t= 0x%p\n", argc, argv[argc]); diff --git a/apps/examples/posix_spawn/Makefile b/apps/examples/posix_spawn/Makefile index d21c8f856..bda3376d2 100644 --- a/apps/examples/posix_spawn/Makefile +++ b/apps/examples/posix_spawn/Makefile @@ -64,8 +64,8 @@ ROOTDEPPATH = --dep-path . --dep-path filesystem VPATH = filesystem -all: .built -.PHONY: really_build clean_filesystem clean depend distclean +all: build +.PHONY: build clean_filesystem clean depend distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -74,17 +74,16 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) # This is a little messy. The build is broken into two pieces: (1) the -# filesystem/ subdir build that auto-generates several files, and (2) the real +# filesystem/ subdir build that auto-generates several files, and (2) the library # build. This is done because we need a fresh build context after auto- # generating the source files. -really_build: $(OBJS) +build_lib: $(OBJS) $(call ARCHIVE, $(BIN), $(OBJS)) - @touch .built -.built: +build: @$(MAKE) -C filesystem TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) - @$(MAKE) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" really_build + @$(MAKE) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" build_lib context: @@ -100,11 +99,13 @@ clean_filesystem: @$(MAKE) -C filesystem TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) clean clean: clean_filesystem - $(call DELFILE, .built) $(call CLEAN) distclean: clean $(call DELFILE, Make.dep) $(call DELFILE, .depend) +# There are no dependencies in this directory. We should are code some of +# more important dependencies here: + -include Make.dep diff --git a/apps/examples/posix_spawn/filesystem/Makefile b/apps/examples/posix_spawn/filesystem/Makefile index 19a02bb80..2005d060f 100644 --- a/apps/examples/posix_spawn/filesystem/Makefile +++ b/apps/examples/posix_spawn/filesystem/Makefile @@ -44,22 +44,28 @@ ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c all: $(ROMFS_HDR) $(SYMTAB_SRC) -.PHONY: all program clean install populate +.PHONY: all hello redirect clean install populate # Create the romfs directory $(ROMFS_DIR): $(Q) mkdir $(ROMFS_DIR) -# Build the test program +# Build the hello test program -program: $(ROMFS_DIR) - $(Q) $(MAKE) -C program program TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" +hello: $(ROMFS_DIR) + $(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" -# Install the test program in the romfs directory +# Build the redirection test program -install: program testdata.txt - $(Q) $(MAKE) -C program install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" +redirect: $(ROMFS_DIR) + $(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + +# Install the test programs in the romfs directory + +install: hello redirect testdata.txt + $(Q) $(MAKE) -C hello install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + $(Q) $(MAKE) -C redirect install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" $(Q) install --mode=0644 testdata.txt $(ROMFS_DIR)/testdata.txt # Create the romfs.img file from the romfs directory @@ -74,12 +80,13 @@ $(ROMFS_HDR) : $(ROMFS_IMG) # Create the exported symbol table -$(SYMTAB_SRC): program +$(SYMTAB_SRC): hello/hello redirect/redirect testdata.txt $(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@ # Clean each subdirectory clean: - $(Q) $(MAKE) -C program clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + $(Q) $(MAKE) -C hello clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" + $(Q) $(MAKE) -C redirect clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" $(Q) rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(ROMFS_DIR) diff --git a/apps/examples/posix_spawn/filesystem/hello/Makefile b/apps/examples/posix_spawn/filesystem/hello/Makefile new file mode 100644 index 000000000..5cd80411b --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/hello/Makefile @@ -0,0 +1,59 @@ +############################################################################ +# examples/elf/tests/hello/Makefile +# +# Copyright (C) 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +BIN = hello + +SRCS = $(BIN).c +OBJS = $(SRCS:.c=.o) + +all: $(BIN) + +$(OBJS): %.o: %.c + @echo "CC: $<" + $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ + +$(BIN): $(OBJS) + @echo "LD: $<" + $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + +clean: + $(call DELFILE, $(BIN)) + $(call CLEAN) + +install: + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install $(BIN) $(ROMFS_DIR)/$(BIN) diff --git a/apps/examples/posix_spawn/filesystem/hello/hello.c b/apps/examples/posix_spawn/filesystem/hello/hello.c new file mode 100644 index 000000000..1b269d85f --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/hello/hello.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * examples/posix_spawn/filesystem/hello/hello.c + * + * Copyright (C) 2013 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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv) +{ + int i; + + /* Mandatory "Hello, world!" */ + + puts("Getting ready to say \"Hello, world\"\n"); + printf("Hello, world!\n"); + puts("It has been said.\n"); + + /* Print arguments */ + + printf("argc\t= %d\n", argc); + printf("argv\t= 0x%p\n", argv); + + for (i = 0; i < argc; i++) + { + printf("argv[%d]\t= ", i); + if (argv[i]) + { + printf("(0x%p) \"%s\"\n", argv[i], argv[i]); + } + else + { + printf("NULL?\n"); + } + } + + printf("argv[%d]\t= 0x%p\n", argc, argv[argc]); + printf("Goodbye, world!\n"); + return 0; +} diff --git a/apps/examples/posix_spawn/filesystem/program/Makefile b/apps/examples/posix_spawn/filesystem/program/Makefile deleted file mode 100644 index cf55797b2..000000000 --- a/apps/examples/posix_spawn/filesystem/program/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -############################################################################ -# examples/posix_spawn/filesystem/program/Makefile -# -# Copyright (C) 2013 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)/Make.defs - -BIN = program - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=.o) - -all: $(BIN) - -$(OBJS): %.o: %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) - -install: - $(Q) mkdir -p $(ROMFS_DIR) - $(Q) install --mode=0755 $(BIN) $(ROMFS_DIR)/$(BIN) diff --git a/apps/examples/posix_spawn/filesystem/program/program.c b/apps/examples/posix_spawn/filesystem/program/program.c deleted file mode 100644 index f63b559c8..000000000 --- a/apps/examples/posix_spawn/filesystem/program/program.c +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** - * examples/posix_spawn/filesystem/program/program.c - * - * Copyright (C) 2013 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 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - int ch; - - /* stdin should have been redirected to testdata.txt. Read and print until - * we hit the end of file. - */ - - while ((ch = getchar()) != EOF) - { - putchar(ch); - } - - return 0; -} diff --git a/apps/examples/posix_spawn/filesystem/redirect/Makefile b/apps/examples/posix_spawn/filesystem/redirect/Makefile new file mode 100644 index 000000000..421ff014a --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/redirect/Makefile @@ -0,0 +1,59 @@ +############################################################################ +# examples/posix_spawn/filesystem/redirect/Makefile +# +# Copyright (C) 2013 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)/Make.defs + +BIN = redirect + +SRCS = $(BIN).c +OBJS = $(SRCS:.c=.o) + +all: $(BIN) + +$(OBJS): %.o: %.c + @echo "CC: $<" + $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ + +$(BIN): $(OBJS) + @echo "LD: $<" + $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + +clean: + $(call DELFILE, $(BIN)) + $(call CLEAN) + +install: + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install --mode=0755 $(BIN) $(ROMFS_DIR)/$(BIN) diff --git a/apps/examples/posix_spawn/filesystem/redirect/redirect.c b/apps/examples/posix_spawn/filesystem/redirect/redirect.c new file mode 100644 index 000000000..61638df79 --- /dev/null +++ b/apps/examples/posix_spawn/filesystem/redirect/redirect.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * examples/posix_spawn/filesystem/redirect/redirect.c + * + * Copyright (C) 2013 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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv) +{ + int ch; + + printf("Entering the stdin redirection test\n"); + + /* stdin should have been redirected to testdata.txt. Read and print until + * we hit the end of file. + */ + + while ((ch = getchar()) != EOF) + { + putchar(ch); + } + + printf("Exit-ing the stdin redirection test\n"); + return 0; +} diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c index 608145232..6f8859516 100644 --- a/apps/examples/posix_spawn/spawn_main.c +++ b/apps/examples/posix_spawn/spawn_main.c @@ -138,11 +138,15 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */ static const char delimiter[] = "****************************************************************************"; -static const char program[] = "program"; -static const char data[] = "testdata.txt"; +static const char g_redirect[] = "redirect"; +static const char g_hello[] = "hello"; +static const char g_data[] = "testdata.txt"; static char fullpath[128]; +static char * const g_argv[4] = + { "Argument 1", "Argument 2", "Argument 3", NULL }; + /**************************************************************************** * Symbols from Auto-Generated Code ****************************************************************************/ @@ -284,11 +288,87 @@ int spawn_main(int argc, char *argv[]) exec_setsymtab(exports, nexports); + /************************************************************************* + * Case 1: Simple program with arguments + *************************************************************************/ + + /* Output a seperated so that we can clearly discriminate the output of + * this program from the others. + */ + + testheader(g_hello); + + /* Initialize the attributes file actions structure */ + + ret = posix_spawn_file_actions_init(&file_actions); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_init failed: %d\n", ret); + } + posix_spawn_file_actions_dump(&file_actions); + + ret = posix_spawnattr_init(&attr); + if (ret != 0) + { + err("ERROR: posix_spawnattr_init failed: %d\n", ret); + } + posix_spawnattr_dump(&attr); + + mm_update(&g_mmstep, "after file_action/attr init"); + + /* If the binary loader does not support the PATH variable, then + * create the full path to the executable program. Otherwise, + * use the relative path so that the binary loader will have to + * search the PATH variable to find the executable. + */ + +#ifdef CONFIG_BINFMT_EXEPATH + filepath = g_hello; +#else + snprintf(fullpath, 128, "%s/%s", MOUNTPT, g_hello); + filepath = fullpath; +#endif + + /* Execute the program */ + + mm_update(&g_mmstep, "before posix_spawn"); + + ret = posix_spawn(&pid, filepath, &file_actions, &attr, NULL, (FAR char * const*)&g_argv); + if (ret != 0) + { + err("ERROR: posix_spawn failed: %d\n", ret); + } + + sleep(4); + mm_update(&g_mmstep, "after posix_spawn"); + + /* Free attibutes and file actions */ + + ret = posix_spawn_file_actions_destroy(&file_actions); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_destroy failed: %d\n", ret); + } + posix_spawn_file_actions_dump(&file_actions); + + ret = posix_spawnattr_destroy(&attr); + if (ret != 0) + { + err("ERROR: posix_spawnattr_destroy failed: %d\n", ret); + } + posix_spawnattr_dump(&attr); + + mm_update(&g_mmstep, "after file_action/attr destruction"); + + /************************************************************************* + * Case 2: Simple program with redirection of stdin + *************************************************************************/ + /* Output a seperated so that we can clearly discriminate the output of * this program from the others. */ - testheader(program); + testheader(g_redirect); /* Initialize the attributes file actions structure */ @@ -297,12 +377,14 @@ int spawn_main(int argc, char *argv[]) { err("ERROR: posix_spawn_file_actions_init failed: %d\n", ret); } + posix_spawn_file_actions_dump(&file_actions); ret = posix_spawnattr_init(&attr); if (ret != 0) { err("ERROR: posix_spawnattr_init failed: %d\n", ret); } + posix_spawnattr_dump(&attr); mm_update(&g_mmstep, "after file_action/attr init"); @@ -313,13 +395,15 @@ int spawn_main(int argc, char *argv[]) { err("ERROR: posix_spawn_file_actions_addclose failed: %d\n", ret); } + posix_spawn_file_actions_dump(&file_actions); - snprintf(fullpath, 128, "%s/%s", MOUNTPT, data); + snprintf(fullpath, 128, "%s/%s", MOUNTPT, g_data); ret = posix_spawn_file_actions_addopen(&file_actions, 0, fullpath, O_RDONLY, 0644); if (ret != 0) { err("ERROR: posix_spawn_file_actions_addopen failed: %d\n", ret); } + posix_spawn_file_actions_dump(&file_actions); mm_update(&g_mmstep, "after adding file_actions"); @@ -330,9 +414,9 @@ int spawn_main(int argc, char *argv[]) */ #ifdef CONFIG_BINFMT_EXEPATH - filepath = program; + filepath = g_redirect; #else - snprintf(fullpath, 128, "%s/%s", MOUNTPT, program); + snprintf(fullpath, 128, "%s/%s", MOUNTPT, g_redirect); filepath = fullpath; #endif @@ -346,13 +430,29 @@ int spawn_main(int argc, char *argv[]) err("ERROR: posix_spawn failed: %d\n", ret); } - sleep(1); + sleep(2); mm_update(&g_mmstep, "after posix_spawn"); + /* Free attibutes and file actions */ + + ret = posix_spawn_file_actions_destroy(&file_actions); + if (ret != 0) + { + err("ERROR: posix_spawn_file_actions_destroy failed: %d\n", ret); + } + posix_spawn_file_actions_dump(&file_actions); + + ret = posix_spawnattr_destroy(&attr); + if (ret != 0) + { + err("ERROR: posix_spawnattr_destroy failed: %d\n", ret); + } + posix_spawnattr_dump(&attr); + + mm_update(&g_mmstep, "after file_action/attr destruction"); + /* Clean-up */ - (void)posix_spawn_file_actions_destroy(&file_actions); - (void)posix_spawnattr_destroy(&attr); elf_uninitialize(); mm_update(&g_mmstep, "End-of-Test"); diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 7ddc4901e..63aac89f5 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3905,4 +3905,6 @@ (from Max Holtzberg). * configs/stm32f4discovery/posix_spawn: Added a configuration that can be used for testing posix_spawn(). + * arch/arm/src/stm32: Bring F1 support for general DMA and serial + DMA in paricular up to parity with F2/F4 (from Mike Smith). diff --git a/nuttx/include/spawn.h b/nuttx/include/spawn.h index 3978424fb..39ed9be15 100644 --- a/nuttx/include/spawn.h +++ b/nuttx/include/spawn.h @@ -61,7 +61,7 @@ #define POSIX_SPAWN_SETSCHEDPARAM (1 << 2) /* 1: Set task's priority */ #define POSIX_SPAWN_SETSCHEDULER (1 << 3) /* 1: Set task's scheduler policy */ #define POSIX_SPAWN_SETSIGDEF (1 << 4) /* 1: Set default signal actions */ -#define POSIX_SPAWN_SETSIGMASK (1 << 5) /* 1: Set sigmask *./ +#define POSIX_SPAWN_SETSIGMASK (1 << 5) /* 1: Set sigmask */ /**************************************************************************** * Type Definitions @@ -181,6 +181,16 @@ int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr, # define posix_spawnattr_setsigmask(attr,sigmask) (ENOSYS) #endif +/* Non standard debug functions */ + +#ifdef CONFIG_DEBUG +void posix_spawn_file_actions_dump(FAR posix_spawn_file_actions_t *file_actions); +void posix_spawnattr_dump(FAR posix_spawnattr_t *attr); +#else +# define posix_spawn_file_actions_dump(fa) +# define posix_spawnattr_dump(a) +#endif + #ifdef __cplusplus } #endif diff --git a/nuttx/libc/spawn/Make.defs b/nuttx/libc/spawn/Make.defs index 2cf75c410..99ee781ce 100644 --- a/nuttx/libc/spawn/Make.defs +++ b/nuttx/libc/spawn/Make.defs @@ -42,6 +42,10 @@ CSRCS += lib_ps.c CSRCS += lib_psfa_addaction.c lib_psfa_addclose.c lib_psfa_adddup2.c CSRCS += lib_psfa_addopen.c lib_psfa_destroy.c lib_psfa_init.c +ifeq ($(CONFIG_DEBUG),y) +CSRCS += lib_psfa_dump.c +endif + CSRCS += lib_psa_getflags.c lib_psa_getschedparam.c lib_psa_getschedpolicy.c CSRCS += lib_psa_init.c lib_psa_setflags.c lib_psa_setschedparam.c CSRCS += lib_psa_setschedpolicy.c @@ -50,6 +54,10 @@ ifneq ($(CONFIG_DISABLE_SIGNALS),y) CSRCS += lib_psa_getsigmask.c lib_psa_setsigmask.c endif +ifeq ($(CONFIG_DEBUG),y) +CSRCS += lib_psa_dump.c +endif + # Add the spawn directory to the build DEPPATH += --dep-path spawn diff --git a/nuttx/libc/spawn/lib_ps.c b/nuttx/libc/spawn/lib_ps.c index 7509d6737..a6a0590d4 100644 --- a/nuttx/libc/spawn/lib_ps.c +++ b/nuttx/libc/spawn/lib_ps.c @@ -357,7 +357,7 @@ static int spawn_proxy(int argc, char *argv[]) { FAR struct spawn_general_file_action_s *entry; FAR const posix_spawnattr_t *attr = g_ps_parms.attr; - int ret; + int ret = OK; /* Perform file actions and/or set a custom signal mask. We get here only * if the file_actions parameter to posix_spawn[p] was non-NULL and/or the @@ -365,10 +365,10 @@ static int spawn_proxy(int argc, char *argv[]) */ #ifndef CONFIG_DISABLE_SIGNALS - DEBUGASSERT(g_ps_parms.file_actions || + DEBUGASSERT((g_ps_parms.file_actions && *g_ps_parms.file_actions) || (attr && (attr->flags & POSIX_SPAWN_SETSIGMASK) != 0)); #else - DEBUGASSERT(g_ps_parms.file_actions); + DEBUGASSERT(g_ps_parms.file_actions && *g_ps_parms.file_actions); #endif /* Check if we need to change the signal mask */ @@ -553,9 +553,10 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, */ #ifndef CONFIG_DISABLE_SIGNALS - if (!file_actions && (attr->flags & POSIX_SPAWN_SETSIGMASK) == 0) + if ((file_actions == NULL || *file_actions == NULL) && + (attr == NULL || (attr->flags & POSIX_SPAWN_SETSIGMASK) == 0)) #else - if (!file_actions) + if (file_actions == NULL || *file_actions == NULL) #endif { return ps_exec(pid, path, attr, argv); @@ -601,7 +602,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, proxy = TASK_CREATE("spawn_proxy", param.sched_priority, CONFIG_POSIX_SPAWN_STACKSIZE, (main_t)spawn_proxy, - (const char **)NULL); + (FAR const char **)NULL); if (proxy < 0) { int errcode = errno; diff --git a/nuttx/libc/spawn/lib_psa_dump.c b/nuttx/libc/spawn/lib_psa_dump.c new file mode 100644 index 000000000..03770c6ff --- /dev/null +++ b/nuttx/libc/spawn/lib_psa_dump.c @@ -0,0 +1,127 @@ +/**************************************************************************** + * libc/string/lib_psa_dump.c + * + * Copyright (C) 2013 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_DEBUG + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: posix_spawnattr_dump + * + * Description: + * Show the current attributes. + * + * Input Parameters: + * attr - The address of the spawn attributes to be dumped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void posix_spawnattr_dump(posix_spawnattr_t *attr) +{ + dbg("attr[%p]:\n", attr); + dbg(" flags: %04x\n", attr->flags); + if (attr->flags == 0) + { + dbg(" None\n"); + } + else + { + if ((attr->flags & POSIX_SPAWN_RESETIDS) != 0) + { + dbg(" POSIX_SPAWN_RESETIDS\n"); + } + + if ((attr->flags & POSIX_SPAWN_SETPGROUP) != 0) + { + dbg(" POSIX_SPAWN_SETPGROUP\n"); + } + + if ((attr->flags & POSIX_SPAWN_SETSCHEDPARAM) != 0) + { + dbg(" POSIX_SPAWN_SETSCHEDPARAM\n"); + } + + if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) != 0) + { + dbg(" POSIX_SPAWN_SETSCHEDULER\n"); + } + + if ((attr->flags & POSIX_SPAWN_SETSIGDEF) != 0) + { + dbg(" POSIX_SPAWN_SETSIGDEF\n"); + } + + if ((attr->flags & POSIX_SPAWN_SETSIGMASK) != 0) + { + dbg(" POSIX_SPAWN_SETSIGMASK\n"); + } + } + + dbg(" priority: %d\n", attr->priority); + + dbg(" policy: %d\n", attr->policy); + if (attr->policy == SCHED_FIFO) + { + dbg(" SCHED_FIFO\n"); + } + else if (attr->policy == SCHED_RR) + { + dbg(" SCHED_RR\n"); + } + else + { + dbg(" Unrecognized\n"); + } + +#ifndef CONFIG_DISABLE_SIGNALS + dbg(" sigmask: %08x\n", attr->sigmask); +#endif +}; + +#endif /* CONFIG_DEBUG */ \ No newline at end of file diff --git a/nuttx/libc/spawn/lib_psa_init.c b/nuttx/libc/spawn/lib_psa_init.c index 8aabfd090..f76188c52 100644 --- a/nuttx/libc/spawn/lib_psa_init.c +++ b/nuttx/libc/spawn/lib_psa_init.c @@ -43,7 +43,6 @@ #include #include #include -#include /**************************************************************************** * Global Functions @@ -58,7 +57,7 @@ * call to posix_spawn() or posix_spawnp(). * * Input Parameters: - * attr - The address spawn attributes to be initialized. + * attr - The address of the spawn attributes to be initialized. * * Returned Value: * On success, these functions return 0; on failure they return an error diff --git a/nuttx/libc/spawn/lib_psfa_dump.c b/nuttx/libc/spawn/lib_psfa_dump.c new file mode 100644 index 000000000..d7bf1576d --- /dev/null +++ b/nuttx/libc/spawn/lib_psfa_dump.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * libc/string/lib_psfa_dump.c + * + * Copyright (C) 2013 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 "spawn/spawn.h" + +#ifdef CONFIG_DEBUG + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lib_psfa_dump + * + * Description: + * Show the entryent file actions. + * + * Input Parameters: + * file_actions - The address of the file_actions to be dumped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void posix_spawn_file_actions_dump(FAR posix_spawn_file_actions_t *file_actions) +{ + FAR struct spawn_general_file_action_s *entry; + + DEBUGASSERT(file_actions); + + dbg("File Actions[%p->%p]:\n", file_actions, *file_actions); + if (!*file_actions) + { + dbg(" NONE\n"); + return; + } + + /* Destroy each file action, one at a time */ + + for (entry = (FAR struct spawn_general_file_action_s *)*file_actions; + entry; + entry = entry->flink) + { + switch (entry->action) + { + case SPAWN_FILE_ACTION_CLOSE: + { + FAR struct spawn_close_file_action_s *action = + (FAR struct spawn_close_file_action_s *)entry; + + dbg(" CLOSE: fd=%d\n", action->fd); + } + break; + + case SPAWN_FILE_ACTION_DUP2: + { + FAR struct spawn_dup2_file_action_s *action = + (FAR struct spawn_dup2_file_action_s *)entry; + + dbg(" DUP2: %d->%d\n", action->fd1, action->fd2); + } + break; + + case SPAWN_FILE_ACTION_OPEN: + { + FAR struct spawn_open_file_action_s *action = + (FAR struct spawn_open_file_action_s *)entry; + + svdbg(" OPEN: path=%s oflags=%04x mode=%04x fd=%d\n", + action->path, action->oflags, action->mode, action->fd); + } + break; + + case SPAWN_FILE_ACTION_NONE: + default: + dbg(" ERROR: Unknown action: %d\n", entry->action); + break; + } + } +} + +#endif /* CONFIG_DEBUG */ \ No newline at end of file diff --git a/nuttx/sched/task_vfork.c b/nuttx/sched/task_vfork.c index 64f6f0636..0ea09b048 100644 --- a/nuttx/sched/task_vfork.c +++ b/nuttx/sched/task_vfork.c @@ -218,6 +218,9 @@ pid_t task_vforkstart(FAR _TCB *child) #endif FAR const char *name; pid_t pid; +#ifdef CONFIG_SCHED_WAITPID + int rc; +#endif int ret; svdbg("Starting Child TCB=%p, parent=%p\n", child, g_readytorun.head); @@ -246,6 +249,64 @@ pid_t task_vforkstart(FAR _TCB *child) return ERROR; } + /* Since the child task has the same priority as the parent task, it is + * now ready to run, but has not yet ran. It is a requirement that + * the parent enivornment be stable while vfork runs; the child thread + * is still dependent on things in the parent thread... like the pointers + * into parent thread's stack which will still appear in the child's + * registers and environment. + * + * We do not have SIG_CHILD, so we have to do some silly things here. + * The simplest way to make sure that the child thread runs to completion + * is simply to yield here. Since the child can only do exit() or + * execv/l(), that should be all that is needed. + * + * Hmmm.. this is probably not sufficient. What if we are running + * SCHED_RR? What if the child thread is suspeneded and rescheduled + * after the parent thread again? + */ + +#ifdef CONFIG_SCHED_WAITPID + + /* We can also exploit a bug in the execv() implementation: The PID + * of the task exec'ed by the child will not be the same as the PID of + * the child task. Therefore, waitpid() on the child task's PID will + * accomplish what we need to do. + */ + + rc = 0; + +#ifdef CONFIG_DEBUG + ret = waitpid(pid, &rc, 0); + if (ret < 0) + { + sdbg("ERROR: waitpid failed: %d\n", errno); + } +#else + (void)waitpid(pid, &rc, 0); +#endif + +#else + /* Again exploiting that execv() bug: Check if the child thread is + * still running. + */ + + while ((ret = kill(pid, 0)) == OK) + { + /* Yes.. then we can yield to it -- assuming that it has not lowered + * its priority. sleep(0) might be a safer thing to do since it does + * not depend on prioirities: It will halt the parent thread for one + * system clock tick. This will delay the return to the parent thread. + */ + +#ifndef CONFIG_DISABLE_SIGNALS + sleep(0); +#else + sched_yield(); +#endif + } +#endif + return pid; } -- cgit v1.2.3 From 43e22b2b98bacc15438133b5823d545806c8d092 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 11 Jan 2013 19:08:51 +0000 Subject: Fix an error handling bug in the fread logic git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5511 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/posix_spawn/Makefile | 27 +++++++++++++++++++++++---- apps/examples/posix_spawn/filesystem/Makefile | 16 ++++++---------- apps/examples/posix_spawn/spawn_main.c | 16 +++++++++++++++- nuttx/ChangeLog | 5 ++++- nuttx/TODO | 14 ++++++++++++-- nuttx/libc/misc/lib_filesem.c | 16 ++++++++-------- nuttx/libc/misc/lib_streamsem.c | 2 -- nuttx/libc/stdio/lib_libfread.c | 3 ++- 8 files changed, 70 insertions(+), 29 deletions(-) (limited to 'apps') diff --git a/apps/examples/posix_spawn/Makefile b/apps/examples/posix_spawn/Makefile index bda3376d2..0bfa36e55 100644 --- a/apps/examples/posix_spawn/Makefile +++ b/apps/examples/posix_spawn/Makefile @@ -105,7 +105,26 @@ distclean: clean $(call DELFILE, Make.dep) $(call DELFILE, .depend) -# There are no dependencies in this directory. We should are code some of -# more important dependencies here: - --include Make.dep +# There are no dependencies in this directory. Some of more important +# and more obvious dependencies are hard-coded here: + +spawn_main.o: spawn_main.c \ + $(TOPDIR)/include/nuttx/config.h \ + $(TOPDIR)/include/nuttx/compiler.h \ + $(TOPDIR)/include/sys/mount.h \ + $(TOPDIR)/include/stdio.h \ + $(TOPDIR)/include/stdlib.h \ + $(TOPDIR)/include/unistd.h \ + $(TOPDIR)/include/string.h \ + $(TOPDIR)/include/fcntl.h \ + $(TOPDIR)/include/spawn.h \ + $(TOPDIR)/include/debug.h \ + $(TOPDIR)/include/errno.h \ + $(TOPDIR)/include/nuttx/ramdisk.h \ + $(TOPDIR)/include/nuttx/binfmt/elf.h \ + $(TOPDIR)/include/nuttx/binfmt/symtab.h \ + filesystem/romfs.h + +symtab.o: filesystem/symtab.c \ + $(TOPDIR)/include/nuttx/compiler.h \ + $(TOPDIR)/include/nuttx/binfmt/symtab.h diff --git a/apps/examples/posix_spawn/filesystem/Makefile b/apps/examples/posix_spawn/filesystem/Makefile index 2005d060f..26897426c 100644 --- a/apps/examples/posix_spawn/filesystem/Makefile +++ b/apps/examples/posix_spawn/filesystem/Makefile @@ -44,7 +44,7 @@ ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c all: $(ROMFS_HDR) $(SYMTAB_SRC) -.PHONY: all hello redirect clean install populate +.PHONY: all hello/hello redirect/redirect clean populate # Create the romfs directory @@ -53,24 +53,20 @@ $(ROMFS_DIR): # Build the hello test program -hello: $(ROMFS_DIR) +hello/hello: $(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" # Build the redirection test program -redirect: $(ROMFS_DIR) +redirect/redirect: $(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" -# Install the test programs in the romfs directory +# Create the romfs.img file from the romfs directory -install: hello redirect testdata.txt +$(ROMFS_IMG): hello/hello redirect/redirect testdata.txt $(ROMFS_DIR) $(Q) $(MAKE) -C hello install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" $(Q) $(MAKE) -C redirect install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" $(Q) install --mode=0644 testdata.txt $(ROMFS_DIR)/testdata.txt - -# Create the romfs.img file from the romfs directory - -$(ROMFS_IMG): install $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "POSIXSPAWN" # Create the romfs.h header file from the romfs.img file @@ -80,7 +76,7 @@ $(ROMFS_HDR) : $(ROMFS_IMG) # Create the exported symbol table -$(SYMTAB_SRC): hello/hello redirect/redirect testdata.txt +$(SYMTAB_SRC): $(ROMFS_DIR)/hello $(ROMFS_DIR)/redirect $(ROMFS_DIR)/testdata.txt $(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@ # Clean each subdirectory diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c index 6f8859516..1506fe499 100644 --- a/apps/examples/posix_spawn/spawn_main.c +++ b/apps/examples/posix_spawn/spawn_main.c @@ -89,6 +89,15 @@ # error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file" #endif +/* The redirection test does not work. This is because it tries to redirect + * file as stdin. That won't work now because (1) the file descriptors must + * be dup'ed when the new task is created, and (2) there is no support in + * place for dup'ing file descriptors for anything other than sockets and + * character drivers. This is a bug! + */ + +#define FILE_DUP_BUG 1 + /* Describe the ROMFS file system */ #define SECTORSIZE 512 @@ -138,7 +147,9 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */ static const char delimiter[] = "****************************************************************************"; +#ifndef FILE_DUP_BUG static const char g_redirect[] = "redirect"; +#endif static const char g_hello[] = "hello"; static const char g_data[] = "testdata.txt"; @@ -361,9 +372,11 @@ int spawn_main(int argc, char *argv[]) mm_update(&g_mmstep, "after file_action/attr destruction"); /************************************************************************* - * Case 2: Simple program with redirection of stdin + * Case 2: Simple program with redirection of stdin to a file input *************************************************************************/ +#ifndef FILE_DUP_BUG + /* Output a seperated so that we can clearly discriminate the output of * this program from the others. */ @@ -450,6 +463,7 @@ int spawn_main(int argc, char *argv[]) posix_spawnattr_dump(&attr); mm_update(&g_mmstep, "after file_action/attr destruction"); +#endif /* Clean-up */ diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 63aac89f5..40a24d8f1 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3907,4 +3907,7 @@ that can be used for testing posix_spawn(). * arch/arm/src/stm32: Bring F1 support for general DMA and serial DMA in paricular up to parity with F2/F4 (from Mike Smith). - + * libc/stdio/lib_libfread.c: Correct some error handling when + lib_fread() was passed a bad stream. Needed to move the + releasing of a semaphore inside of some conditional logic + (cosmetic). diff --git a/nuttx/TODO b/nuttx/TODO index 9295f6206..e257cef79 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated January 10, 2013) +NuttX TODO List (Last updated January 11, 2013) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -15,7 +15,7 @@ nuttx/ (17) Network (net/, drivers/net) (4) USB (drivers/usbdev, drivers/usbhost) (12) Libraries (libc/, ) - (9) File system/Generic drivers (fs/, drivers/) + (10) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) (1) Documentation (Documentation/) @@ -863,6 +863,16 @@ o File system / Generic drivers (fs/, drivers/) Status: Open Priority: Medium + Title: dup AND dup2 WILL NOT WORK ON FILES IN A MOUNTED VOLUME + Description: The current implementation of dup() and dup2() will only + work with open device drivers and sockets. It will not + work with open files in a file system. + + A limitation that results from this is that you cannot + redirect I/O to an from and file. + Status: Open + Priority: High + o Graphics subystem (graphics/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/libc/misc/lib_filesem.c b/nuttx/libc/misc/lib_filesem.c index 5cc4624ec..f38ff5f23 100644 --- a/nuttx/libc/misc/lib_filesem.c +++ b/nuttx/libc/misc/lib_filesem.c @@ -67,8 +67,8 @@ void lib_sem_initialize(FAR struct file_struct *stream) { - /* Initialize the LIB semaphore to one (to support one-at- - * a-time access to private data sets. + /* Initialize the LIB semaphore to one (to support one-at-a-time access + * to private data sets. */ (void)sem_init(&stream->fs_sem, 0, 1); @@ -98,13 +98,13 @@ void lib_take_semaphore(FAR struct file_struct *stream) /* Take the semaphore (perhaps waiting) */ while (sem_wait(&stream->fs_sem) != 0) - { - /* The only case that an error should occr here is if - * the wait was awakened by a signal. - */ + { + /* The only case that an error should occr here is if the wait + * was awakened by a signal. + */ - ASSERT(get_errno() == EINTR); - } + ASSERT(get_errno() == EINTR); + } /* We have it. Claim the stak and return */ diff --git a/nuttx/libc/misc/lib_streamsem.c b/nuttx/libc/misc/lib_streamsem.c index e38298bdb..3397f9907 100644 --- a/nuttx/libc/misc/lib_streamsem.c +++ b/nuttx/libc/misc/lib_streamsem.c @@ -86,5 +86,3 @@ void stream_semgive(FAR struct streamlist *list) { sem_post(&list->sl_sem); } - - diff --git a/nuttx/libc/stdio/lib_libfread.c b/nuttx/libc/stdio/lib_libfread.c index bc6479037..3e851bf17 100644 --- a/nuttx/libc/stdio/lib_libfread.c +++ b/nuttx/libc/stdio/lib_libfread.c @@ -301,9 +301,10 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream) { stream->fs_flags |= __FS_FLAG_EOF; } + + lib_give_semaphore(stream); } - lib_give_semaphore(stream); return bytes_read; /* Error exits */ -- cgit v1.2.3 From b58281cab8add0af82167282126132b069170dd6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 12 Jan 2013 19:58:45 +0000 Subject: Fix a *critical* bug in the task exit logic. Implements SIGCHILD git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5513 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 + apps/examples/ostest/sighand.c | 58 ++++++++++++++++++ nuttx/ChangeLog | 11 ++++ nuttx/Documentation/NuttxPortingGuide.html | 50 ++++++++++++++-- nuttx/configs/README.txt | 24 +++++++- nuttx/configs/amber/hello/defconfig | 2 +- nuttx/configs/avr32dev1/nsh/defconfig | 2 +- nuttx/configs/avr32dev1/ostest/defconfig | 2 +- nuttx/configs/cloudctrl/nsh/defconfig | 2 +- nuttx/configs/demo9s12ne64/ostest/defconfig | 2 +- nuttx/configs/ea3131/nsh/defconfig | 2 +- nuttx/configs/ea3131/ostest/defconfig | 2 +- nuttx/configs/ea3131/pgnsh/defconfig | 2 +- nuttx/configs/ea3131/usbserial/defconfig | 2 +- nuttx/configs/ea3131/usbstorage/defconfig | 2 +- nuttx/configs/ea3152/ostest/defconfig | 2 +- nuttx/configs/fire-stm32v2/nsh/defconfig | 2 +- nuttx/configs/hymini-stm32v/buttons/defconfig | 2 +- nuttx/configs/hymini-stm32v/nsh/defconfig | 2 +- nuttx/configs/hymini-stm32v/nsh2/defconfig | 2 +- nuttx/configs/hymini-stm32v/nx/defconfig | 2 +- nuttx/configs/hymini-stm32v/nxlines/defconfig | 2 +- nuttx/configs/hymini-stm32v/usbserial/defconfig | 2 +- nuttx/configs/hymini-stm32v/usbstorage/defconfig | 2 +- nuttx/configs/kwikstik-k40/ostest/defconfig | 2 +- nuttx/configs/lincoln60/nsh/defconfig | 2 +- nuttx/configs/lincoln60/ostest/defconfig | 2 +- nuttx/configs/lpc4330-xplorer/nsh/defconfig | 2 +- nuttx/configs/lpc4330-xplorer/ostest/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/nx/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig | 2 +- .../lpcxpresso-lpc1768/usbstorage/defconfig | 2 +- nuttx/configs/mbed/hidkbd/defconfig | 2 +- nuttx/configs/mbed/nsh/defconfig | 2 +- nuttx/configs/micropendous3/hello/defconfig | 2 +- nuttx/configs/mirtoo/nsh/defconfig | 2 +- nuttx/configs/mirtoo/nxffs/defconfig | 2 +- nuttx/configs/mirtoo/ostest/defconfig | 2 +- nuttx/configs/ne64badge/ostest/defconfig | 2 +- nuttx/configs/nucleus2g/nsh/defconfig | 2 +- nuttx/configs/nucleus2g/ostest/defconfig | 2 +- nuttx/configs/nucleus2g/usbserial/defconfig | 2 +- nuttx/configs/nucleus2g/usbstorage/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/ftpc/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nettest/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nsh/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nx/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/ostest/defconfig | 2 +- .../configs/olimex-lpc1766stk/slip-httpd/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/thttpd/defconfig | 2 +- .../configs/olimex-lpc1766stk/usbserial/defconfig | 2 +- .../configs/olimex-lpc1766stk/usbstorage/defconfig | 2 +- nuttx/configs/olimex-stm32-p107/nsh/defconfig | 2 +- nuttx/configs/olimex-stm32-p107/ostest/defconfig | 2 +- nuttx/configs/olimex-strp711/nettest/defconfig | 2 +- nuttx/configs/pcblogic-pic32mx/nsh/defconfig | 2 +- nuttx/configs/pcblogic-pic32mx/ostest/defconfig | 2 +- nuttx/configs/pic32-starterkit/nsh/defconfig | 2 +- nuttx/configs/pic32-starterkit/nsh2/defconfig | 2 +- nuttx/configs/pic32-starterkit/ostest/defconfig | 2 +- nuttx/configs/pic32mx7mmb/nsh/defconfig | 2 +- nuttx/configs/pic32mx7mmb/ostest/defconfig | 2 +- nuttx/configs/sam3u-ek/knsh/defconfig | 2 +- nuttx/configs/sam3u-ek/nsh/defconfig | 2 +- nuttx/configs/sam3u-ek/nx/defconfig | 2 +- nuttx/configs/sam3u-ek/ostest/defconfig | 2 +- nuttx/configs/sam3u-ek/touchscreen/defconfig | 2 +- nuttx/configs/shenzhou/nsh/defconfig | 2 +- nuttx/configs/shenzhou/nxwm/defconfig | 2 +- nuttx/configs/shenzhou/thttpd/defconfig | 2 +- nuttx/configs/sim/nsh/defconfig | 2 +- nuttx/configs/sim/nsh2/defconfig | 2 +- nuttx/configs/sim/ostest/defconfig | 13 +++- nuttx/configs/stm3210e-eval/RIDE/defconfig | 2 +- nuttx/configs/stm3210e-eval/buttons/defconfig | 2 +- nuttx/configs/stm3210e-eval/composite/defconfig | 2 +- nuttx/configs/stm3210e-eval/nsh/defconfig | 2 +- nuttx/configs/stm3210e-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3210e-eval/nx/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxconsole/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxlines/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxtext/defconfig | 2 +- nuttx/configs/stm3210e-eval/ostest/defconfig | 2 +- nuttx/configs/stm3210e-eval/pm/defconfig | 2 +- nuttx/configs/stm3210e-eval/usbserial/defconfig | 2 +- nuttx/configs/stm3210e-eval/usbstorage/defconfig | 2 +- nuttx/configs/stm3220g-eval/dhcpd/defconfig | 2 +- nuttx/configs/stm3220g-eval/nettest/defconfig | 2 +- nuttx/configs/stm3220g-eval/nsh/defconfig | 2 +- nuttx/configs/stm3220g-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3220g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3220g-eval/ostest/defconfig | 2 +- nuttx/configs/stm3220g-eval/telnetd/defconfig | 2 +- nuttx/configs/stm3240g-eval/dhcpd/defconfig | 2 +- nuttx/configs/stm3240g-eval/nettest/defconfig | 2 +- nuttx/configs/stm3240g-eval/nsh/defconfig | 2 +- nuttx/configs/stm3240g-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3240g-eval/nxconsole/defconfig | 2 +- nuttx/configs/stm3240g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/ostest/defconfig | 2 +- nuttx/configs/stm3240g-eval/telnetd/defconfig | 2 +- nuttx/configs/stm3240g-eval/webserver/defconfig | 2 +- nuttx/configs/stm32f100rc_generic/nsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/README.txt | 26 ++++++++ nuttx/configs/stm32f4discovery/nsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/pm/defconfig | 2 +- .../configs/stm32f4discovery/posix_spawn/defconfig | 2 +- nuttx/configs/sure-pic32mx/nsh/defconfig | 2 +- nuttx/configs/sure-pic32mx/ostest/defconfig | 2 +- nuttx/configs/sure-pic32mx/usbnsh/defconfig | 2 +- nuttx/configs/teensy/hello/defconfig | 2 +- nuttx/configs/teensy/nsh/defconfig | 2 +- nuttx/configs/teensy/usbstorage/defconfig | 2 +- nuttx/configs/twr-k60n512/nsh/defconfig | 2 +- nuttx/configs/twr-k60n512/ostest/defconfig | 2 +- nuttx/configs/ubw32/nsh/defconfig | 2 +- nuttx/configs/ubw32/ostest/defconfig | 2 +- nuttx/configs/vsn/nsh/defconfig | 2 +- nuttx/include/nuttx/sched.h | 3 + nuttx/include/nuttx/wqueue.h | 2 +- nuttx/include/signal.h | 68 +++++++++++++-------- nuttx/libc/Kconfig | 5 +- nuttx/sched/Kconfig | 69 +++++++++++++++++++--- nuttx/sched/sched_unlock.c | 1 + nuttx/sched/sig_kill.c | 7 +++ nuttx/sched/sig_mqnotempty.c | 7 +++ nuttx/sched/sig_queue.c | 13 +++- nuttx/sched/sig_timedwait.c | 4 ++ nuttx/sched/task_deletecurrent.c | 16 ++++- nuttx/sched/task_exithook.c | 55 +++++++++++++++++ nuttx/sched/task_setup.c | 36 ++++++++++- nuttx/sched/timer_settime.c | 4 ++ 136 files changed, 540 insertions(+), 164 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 6b63527a7..65d4d6134 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -462,4 +462,6 @@ * apps/examples/wlan: Remove non-functional example. * apps/examples/ostest/vfork.c: Added a test of vfork(). * apps/exampes/posix_spawn: Added a test of poxis_spawn(). + * apps/examples/ostest: Extend signal handler test to catch + death-of-child signals (SIGCHLD). diff --git a/apps/examples/ostest/sighand.c b/apps/examples/ostest/sighand.c index eabfe5646..63d9590d9 100644 --- a/apps/examples/ostest/sighand.c +++ b/apps/examples/ostest/sighand.c @@ -54,12 +54,32 @@ static sem_t sem; static bool sigreceived = false; static bool threadexited = false; +#ifdef CONFIG_SCHED_HAVE_PARENT +static void death_of_child(int signo, siginfo_t *info, void *ucontext) +{ + /* Use of printf in a signal handler is NOT safe! It can cause deadlocks! */ + + if (info) + { + printf("death_of_child: PID %d received signal=%d code=%d pid=%d status=%d\n", + getpid(), signo, info->si_code, info->si_pid, info->si_status); + } + else + { + printf("death_of_child: PID %d received signal=%d (no info?)\n", + getpid(), signo); + } +} +#endif + static void wakeup_action(int signo, siginfo_t *info, void *ucontext) { sigset_t oldset; sigset_t allsigs; int status; + /* Use of printf in a signal handler is NOT safe! It can cause deadlocks! */ + printf("wakeup_action: Received signal %d\n" , signo); sigreceived = true; @@ -186,6 +206,11 @@ static int waiter_main(int argc, char *argv[]) void sighand_test(void) { +#ifdef CONFIG_SCHED_HAVE_PARENT + struct sigaction act; + struct sigaction oact; + sigset_t sigset; +#endif struct sched_param param; union sigval sigvalue; pid_t waiterpid; @@ -195,6 +220,32 @@ void sighand_test(void) printf("sighand_test: Initializing semaphore to 0\n" ); sem_init(&sem, 0, 0); +#ifdef CONFIG_SCHED_HAVE_PARENT + printf("sighand_test: Unmasking SIGCHLD\n"); + + (void)sigemptyset(&sigset); + (void)sigaddset(&sigset, SIGCHLD); + status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); + if (status != OK) + { + printf("sighand_test: ERROR sigprocmask failed, status=%d\n", + status); + } + + printf("sighand_test: Registering SIGCHLD handler\n" ); + act.sa_sigaction = death_of_child; + act.sa_flags = SA_SIGINFO; + + (void)sigfillset(&act.sa_mask); + (void)sigdelset(&act.sa_mask, SIGCHLD); + + status = sigaction(SIGCHLD, &act, &oact); + if (status != OK) + { + printf("waiter_main: ERROR sigaction failed, status=%d\n" , status); + } +#endif + /* Start waiter thread */ printf("sighand_test: Starting waiter task\n" ); @@ -262,6 +313,13 @@ void sighand_test(void) printf("sighand_test: ERROR signal handler did not run\n" ); } + /* Detach the signal handler */ + +#ifdef CONFIG_SCHED_HAVE_PARENT + act.sa_sigaction = SIG_DFL; + status = sigaction(SIGCHLD, &act, &oact); +#endif + printf("sighand_test: done\n" ); FFLUSH(); } diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 40a24d8f1..921b7014b 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3911,3 +3911,14 @@ lib_fread() was passed a bad stream. Needed to move the releasing of a semaphore inside of some conditional logic (cosmetic). + * include/nuttx/sched.h, sched/task_setup.c, and sched/task_exithook.c: + Add support for remembering the parent task and sending + SIGCHLD to the parent when the task exists. + * sched/task_exithook.c: Fixed a *critical* bug. Here is + the scenario: (1) sched_lock() is called increments the lockcount + on the current TCB (i.e., the one at the head of the ready to run + list), (2) sched_mergepending is called which may change the task + at the head of the readytorun list, then (2) sched_lock() is called + which decrements the lockcount on the wrong TCB. The failure case + that I saw was that pre-emption got disabled in the IDLE thread, + locking up the whole system. diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index b1664f3f0..0b67eddb7 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@

              NuttX RTOS Porting Guide

              -

              Last Updated: January 4, 2013

              +

              Last Updated: January 12, 2013

            @@ -4480,6 +4480,11 @@ build task name to save in the TCB. Useful if scheduler instrumentation is selected. Set to zero to disable. +
          • + CONFIG_SCHED_HAVE_PARENT: Remember the ID of the parent thread when a new child thread is created. + This support enables a few minor features (such as SIGCHLD) and slightly increases the size of the Task Control Block (TCB) of every task to hold the ID of the parent thread. + Default: disabled. +
          • CONFIG_SYSTEM_TIME16: The range of system time is, by default, 32-bits. @@ -4582,7 +4587,7 @@ build
          • CONFIG_SIG_SIGWORK: The signal number that will be used to wake-up - the worker thread. Default: 4 + the worker thread. Default: 17
          • CONFIG_SCHED_LPWORK: If CONFIG_SCHED_WORKQUEUE is defined, then a single work queue is created by default. @@ -4624,9 +4629,41 @@ build user_start.
          +

          + Signal Numbers: +

          +
            +
          • + CONFIG_SIG_SIGUSR1: + Value of standard user signal 1 (SIGUSR1). Default: 1 +
          • +
          • + CONFIG_SIG_SIGUSR2: + Value of standard user signal 2 (SIGUSR2). Default: 2 +
          • +
          • + CONFIG_SIG_SIGALARM: + Default the standard signal used with POSIX timers (SIGALRM). Default: 3 +
          • +
          • + CONFIG_SIG_SIGCHLD: + The SIGCHLD signal is sent to the parent of a child process when it exits, is interrupted (stopped), or resumes after being interrupted. + Default: 4 +
          • +
          • + CONFIG_SIG_SIGCONDTIMEDOUT: + This non-standard signal number is used in the implementation of pthread_cond_timedwait(). + Default 16. +
          • +
          • + CONFIG_SIG_SIGWORK: + SIGWORK is a non-standard signal used to wake up the internal NuttX worker thread. + Default: 17. +
          • +

          - Binary Loaders: + Binary Loaders:

          • @@ -4680,7 +4717,7 @@ build

          - System Logging: + System Logging:

          • @@ -4737,7 +4774,7 @@ build

          - Kernel build options: + Kernel build options:

          • @@ -4748,7 +4785,7 @@ build

          - OS setup related to on-demand paging: + OS setup related to on-demand paging:

          • @@ -4906,6 +4943,7 @@ build

          + Disabling OS Features. The following can be used to disable categories of APIs supported by the OS. If the compiler supports weak functions, then it should not be necessary to disable functions unless you want to diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 6e7526ed0..2724cf5a3 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -334,6 +334,11 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_TASK_NAME_SIZE - Specifies that maximum size of a task name to save in the TCB. Useful if scheduler instrumentation is selected. Set to zero to disable. + CONFIG_SCHED_HAVE_PARENT - Remember the ID of the parent thread + when a new child thread is created. This support enables a + few minor features (such as SIGCHLD) and slightly increases + the size of the Task Control Block (TCB) of every task to hold + the ID of the parent thread. Default: disabled. CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY - Used to initialize the internal time logic. CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions. @@ -400,7 +405,7 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up - the worker thread. Default: 4 + the worker thread. Default: 17 CONFIG_SCHED_LPWORK. If CONFIG_SCHED_WORKQUEUE is defined, then a single work queue is created by default. If CONFIG_SCHED_LPWORK is also defined then an additional, lower-priority work queue will also be created. This @@ -426,6 +431,23 @@ defconfig -- This is a configuration file similar to the Linux where 'app' is the application name. If not defined, CONFIG_USER_ENTRYPOINT defaults to user_start. + Signal Numbers: + + CONFIG_SIG_SIGUSR1 - Value of standard user signal 1 (SIGUSR1). + Default: 1 + CONFIG_SIG_SIGUSR2 - Value of standard user signal 2 (SIGUSR2). + Default: 2 + CONFIG_SIG_SIGALARM - Default the standard signal used with POSIX + timers (SIGALRM). Default: 3 + CONFIG_SIG_SIGCHLD - The SIGCHLD signal is sent to the parent of a child + process when it exits, is interrupted (stopped), or resumes after being + interrupted. Default: 4 + + CONFIG_SIG_SIGCONDTIMEDOUT - This non-standard signal number is used in + the implementation of pthread_cond_timedwait(). Default 16. + CONFIG_SIG_SIGWORK - SIGWORK is a non-standard signal used to wake up + the internal NuttX worker thread. Default: 17. + Binary Loaders: CONFIG_BINFMT_DISABLE - By default, support for loadable binary formats is built. diff --git a/nuttx/configs/amber/hello/defconfig b/nuttx/configs/amber/hello/defconfig index 5d028e321..7e3d4ad70 100644 --- a/nuttx/configs/amber/hello/defconfig +++ b/nuttx/configs/amber/hello/defconfig @@ -142,7 +142,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/avr32dev1/nsh/defconfig b/nuttx/configs/avr32dev1/nsh/defconfig index 2b66316c3..acca1fbac 100755 --- a/nuttx/configs/avr32dev1/nsh/defconfig +++ b/nuttx/configs/avr32dev1/nsh/defconfig @@ -168,7 +168,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/avr32dev1/ostest/defconfig b/nuttx/configs/avr32dev1/ostest/defconfig index 9b67be09e..084c66233 100755 --- a/nuttx/configs/avr32dev1/ostest/defconfig +++ b/nuttx/configs/avr32dev1/ostest/defconfig @@ -168,7 +168,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/cloudctrl/nsh/defconfig b/nuttx/configs/cloudctrl/nsh/defconfig index 99c7eb790..8f145d3ab 100644 --- a/nuttx/configs/cloudctrl/nsh/defconfig +++ b/nuttx/configs/cloudctrl/nsh/defconfig @@ -273,7 +273,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/demo9s12ne64/ostest/defconfig b/nuttx/configs/demo9s12ne64/ostest/defconfig index 9c9668aac..79224989f 100755 --- a/nuttx/configs/demo9s12ne64/ostest/defconfig +++ b/nuttx/configs/demo9s12ne64/ostest/defconfig @@ -142,7 +142,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=256 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ea3131/nsh/defconfig b/nuttx/configs/ea3131/nsh/defconfig index 735af431b..8c7b351af 100644 --- a/nuttx/configs/ea3131/nsh/defconfig +++ b/nuttx/configs/ea3131/nsh/defconfig @@ -141,7 +141,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ea3131/ostest/defconfig b/nuttx/configs/ea3131/ostest/defconfig index 2f73ad5c9..19838ceab 100644 --- a/nuttx/configs/ea3131/ostest/defconfig +++ b/nuttx/configs/ea3131/ostest/defconfig @@ -141,7 +141,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ea3131/pgnsh/defconfig b/nuttx/configs/ea3131/pgnsh/defconfig index 32f89c500..1cc2bec7e 100644 --- a/nuttx/configs/ea3131/pgnsh/defconfig +++ b/nuttx/configs/ea3131/pgnsh/defconfig @@ -156,7 +156,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # OS setup related to on-demand paging: diff --git a/nuttx/configs/ea3131/usbserial/defconfig b/nuttx/configs/ea3131/usbserial/defconfig index 3d33a1b67..a82f69877 100644 --- a/nuttx/configs/ea3131/usbserial/defconfig +++ b/nuttx/configs/ea3131/usbserial/defconfig @@ -143,7 +143,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ea3131/usbstorage/defconfig b/nuttx/configs/ea3131/usbstorage/defconfig index 8d9933f55..a957fb3ab 100644 --- a/nuttx/configs/ea3131/usbstorage/defconfig +++ b/nuttx/configs/ea3131/usbstorage/defconfig @@ -144,7 +144,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ea3152/ostest/defconfig b/nuttx/configs/ea3152/ostest/defconfig index d85fd5821..6d0bb63f0 100644 --- a/nuttx/configs/ea3152/ostest/defconfig +++ b/nuttx/configs/ea3152/ostest/defconfig @@ -142,7 +142,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig index c42bb1569..266098496 100644 --- a/nuttx/configs/fire-stm32v2/nsh/defconfig +++ b/nuttx/configs/fire-stm32v2/nsh/defconfig @@ -266,7 +266,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/hymini-stm32v/buttons/defconfig b/nuttx/configs/hymini-stm32v/buttons/defconfig index bbd6c2319..e90ded32a 100644 --- a/nuttx/configs/hymini-stm32v/buttons/defconfig +++ b/nuttx/configs/hymini-stm32v/buttons/defconfig @@ -194,7 +194,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/hymini-stm32v/nsh/defconfig b/nuttx/configs/hymini-stm32v/nsh/defconfig index ca589278a..eeb3b09ff 100755 --- a/nuttx/configs/hymini-stm32v/nsh/defconfig +++ b/nuttx/configs/hymini-stm32v/nsh/defconfig @@ -192,7 +192,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/hymini-stm32v/nsh2/defconfig b/nuttx/configs/hymini-stm32v/nsh2/defconfig index 5a8c0bea2..ecf4c3a3d 100644 --- a/nuttx/configs/hymini-stm32v/nsh2/defconfig +++ b/nuttx/configs/hymini-stm32v/nsh2/defconfig @@ -202,7 +202,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/hymini-stm32v/nx/defconfig b/nuttx/configs/hymini-stm32v/nx/defconfig index 28b08582c..c6e049142 100644 --- a/nuttx/configs/hymini-stm32v/nx/defconfig +++ b/nuttx/configs/hymini-stm32v/nx/defconfig @@ -193,7 +193,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/hymini-stm32v/nxlines/defconfig b/nuttx/configs/hymini-stm32v/nxlines/defconfig index 880efb7d8..fb968c483 100644 --- a/nuttx/configs/hymini-stm32v/nxlines/defconfig +++ b/nuttx/configs/hymini-stm32v/nxlines/defconfig @@ -197,7 +197,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/hymini-stm32v/usbserial/defconfig b/nuttx/configs/hymini-stm32v/usbserial/defconfig index 732c1e8b6..0c7317a00 100755 --- a/nuttx/configs/hymini-stm32v/usbserial/defconfig +++ b/nuttx/configs/hymini-stm32v/usbserial/defconfig @@ -195,7 +195,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/hymini-stm32v/usbstorage/defconfig b/nuttx/configs/hymini-stm32v/usbstorage/defconfig index 7e49de0e8..16f43a1ce 100755 --- a/nuttx/configs/hymini-stm32v/usbstorage/defconfig +++ b/nuttx/configs/hymini-stm32v/usbstorage/defconfig @@ -195,7 +195,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/kwikstik-k40/ostest/defconfig b/nuttx/configs/kwikstik-k40/ostest/defconfig index 759cff20b..5f0291ced 100755 --- a/nuttx/configs/kwikstik-k40/ostest/defconfig +++ b/nuttx/configs/kwikstik-k40/ostest/defconfig @@ -204,7 +204,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/lincoln60/nsh/defconfig b/nuttx/configs/lincoln60/nsh/defconfig index e5009f8d6..908b01e3a 100644 --- a/nuttx/configs/lincoln60/nsh/defconfig +++ b/nuttx/configs/lincoln60/nsh/defconfig @@ -181,7 +181,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/lincoln60/ostest/defconfig b/nuttx/configs/lincoln60/ostest/defconfig index 986f9bf43..ea42f5763 100644 --- a/nuttx/configs/lincoln60/ostest/defconfig +++ b/nuttx/configs/lincoln60/ostest/defconfig @@ -187,7 +187,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/lpc4330-xplorer/nsh/defconfig b/nuttx/configs/lpc4330-xplorer/nsh/defconfig index 0afcbae89..78b9e3f71 100644 --- a/nuttx/configs/lpc4330-xplorer/nsh/defconfig +++ b/nuttx/configs/lpc4330-xplorer/nsh/defconfig @@ -227,7 +227,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/lpc4330-xplorer/ostest/defconfig b/nuttx/configs/lpc4330-xplorer/ostest/defconfig index 76d3f11e9..342fe04a0 100644 --- a/nuttx/configs/lpc4330-xplorer/ostest/defconfig +++ b/nuttx/configs/lpc4330-xplorer/ostest/defconfig @@ -224,7 +224,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig b/nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig index f56dfca1b..2e0d2eea6 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig @@ -186,7 +186,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig b/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig index ef70b5508..23f375a47 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig @@ -189,7 +189,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/lpcxpresso-lpc1768/nx/defconfig b/nuttx/configs/lpcxpresso-lpc1768/nx/defconfig index a0d3cd283..3f8474103 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/nx/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/nx/defconfig @@ -191,7 +191,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig b/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig index 660bd6c8b..10b63eb2d 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig @@ -184,7 +184,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig b/nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig index 755869156..b6ea25948 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig @@ -186,7 +186,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/lpcxpresso-lpc1768/usbstorage/defconfig b/nuttx/configs/lpcxpresso-lpc1768/usbstorage/defconfig index 004d92cb3..9e4bcb15d 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/usbstorage/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/usbstorage/defconfig @@ -187,7 +187,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/mbed/hidkbd/defconfig b/nuttx/configs/mbed/hidkbd/defconfig index ba0af97ca..b4bf00872 100644 --- a/nuttx/configs/mbed/hidkbd/defconfig +++ b/nuttx/configs/mbed/hidkbd/defconfig @@ -186,7 +186,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/mbed/nsh/defconfig b/nuttx/configs/mbed/nsh/defconfig index a1168dd19..2156af80e 100755 --- a/nuttx/configs/mbed/nsh/defconfig +++ b/nuttx/configs/mbed/nsh/defconfig @@ -181,7 +181,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/micropendous3/hello/defconfig b/nuttx/configs/micropendous3/hello/defconfig index ea8faf8f5..ebc755abc 100644 --- a/nuttx/configs/micropendous3/hello/defconfig +++ b/nuttx/configs/micropendous3/hello/defconfig @@ -137,7 +137,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/mirtoo/nsh/defconfig b/nuttx/configs/mirtoo/nsh/defconfig index f2e2b8991..94a6b8b17 100644 --- a/nuttx/configs/mirtoo/nsh/defconfig +++ b/nuttx/configs/mirtoo/nsh/defconfig @@ -200,7 +200,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/mirtoo/nxffs/defconfig b/nuttx/configs/mirtoo/nxffs/defconfig index 29de6f1e7..d633e56d9 100644 --- a/nuttx/configs/mirtoo/nxffs/defconfig +++ b/nuttx/configs/mirtoo/nxffs/defconfig @@ -200,7 +200,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/mirtoo/ostest/defconfig b/nuttx/configs/mirtoo/ostest/defconfig index dfe7a25c5..471dab444 100644 --- a/nuttx/configs/mirtoo/ostest/defconfig +++ b/nuttx/configs/mirtoo/ostest/defconfig @@ -190,7 +190,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/ne64badge/ostest/defconfig b/nuttx/configs/ne64badge/ostest/defconfig index 78e10f87c..e6e0df700 100755 --- a/nuttx/configs/ne64badge/ostest/defconfig +++ b/nuttx/configs/ne64badge/ostest/defconfig @@ -148,7 +148,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=256 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/nucleus2g/nsh/defconfig b/nuttx/configs/nucleus2g/nsh/defconfig index cc747e0c8..2c440bc7f 100755 --- a/nuttx/configs/nucleus2g/nsh/defconfig +++ b/nuttx/configs/nucleus2g/nsh/defconfig @@ -182,7 +182,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/nucleus2g/ostest/defconfig b/nuttx/configs/nucleus2g/ostest/defconfig index 3d777de9c..c32b1e715 100755 --- a/nuttx/configs/nucleus2g/ostest/defconfig +++ b/nuttx/configs/nucleus2g/ostest/defconfig @@ -181,7 +181,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/nucleus2g/usbserial/defconfig b/nuttx/configs/nucleus2g/usbserial/defconfig index e5762e8bc..abe9ac020 100755 --- a/nuttx/configs/nucleus2g/usbserial/defconfig +++ b/nuttx/configs/nucleus2g/usbserial/defconfig @@ -182,7 +182,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/nucleus2g/usbstorage/defconfig b/nuttx/configs/nucleus2g/usbstorage/defconfig index 88c54bccc..adab8f4f0 100755 --- a/nuttx/configs/nucleus2g/usbstorage/defconfig +++ b/nuttx/configs/nucleus2g/usbstorage/defconfig @@ -183,7 +183,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig index 36c5eefc4..8ff0d95aa 100755 --- a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig @@ -192,7 +192,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y # diff --git a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig index 35a7bfc3d..634601187 100755 --- a/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig @@ -262,7 +262,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set # CONFIG_SCHED_WAITPID is not set # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/olimex-lpc1766stk/nettest/defconfig b/nuttx/configs/olimex-lpc1766stk/nettest/defconfig index f89d265b0..4ab823b8c 100755 --- a/nuttx/configs/olimex-lpc1766stk/nettest/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/nettest/defconfig @@ -192,7 +192,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig index 0d82b458b..096f08a8a 100755 --- a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig @@ -194,7 +194,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/olimex-lpc1766stk/nx/defconfig b/nuttx/configs/olimex-lpc1766stk/nx/defconfig index 55c480fe3..28ad229d6 100755 --- a/nuttx/configs/olimex-lpc1766stk/nx/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/nx/defconfig @@ -197,7 +197,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-lpc1766stk/ostest/defconfig b/nuttx/configs/olimex-lpc1766stk/ostest/defconfig index 32e2cacc5..02732e74a 100755 --- a/nuttx/configs/olimex-lpc1766stk/ostest/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/ostest/defconfig @@ -187,7 +187,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig index ff2674c79..9becdee04 100755 --- a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -190,7 +190,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/olimex-lpc1766stk/thttpd/defconfig b/nuttx/configs/olimex-lpc1766stk/thttpd/defconfig index 936dba359..fe42a861f 100755 --- a/nuttx/configs/olimex-lpc1766stk/thttpd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/thttpd/defconfig @@ -188,7 +188,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/olimex-lpc1766stk/usbserial/defconfig b/nuttx/configs/olimex-lpc1766stk/usbserial/defconfig index 603a1562a..995cbad59 100755 --- a/nuttx/configs/olimex-lpc1766stk/usbserial/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/usbserial/defconfig @@ -188,7 +188,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig b/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig index 2c29d2ffd..e11c2c404 100755 --- a/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig @@ -189,7 +189,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig index 7aaae2514..0a831ce9f 100644 --- a/nuttx/configs/olimex-stm32-p107/nsh/defconfig +++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig @@ -234,7 +234,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-stm32-p107/ostest/defconfig b/nuttx/configs/olimex-stm32-p107/ostest/defconfig index d4bba38fb..272832381 100644 --- a/nuttx/configs/olimex-stm32-p107/ostest/defconfig +++ b/nuttx/configs/olimex-stm32-p107/ostest/defconfig @@ -242,7 +242,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/olimex-strp711/nettest/defconfig b/nuttx/configs/olimex-strp711/nettest/defconfig index 4d73540b8..a8767c7be 100755 --- a/nuttx/configs/olimex-strp711/nettest/defconfig +++ b/nuttx/configs/olimex-strp711/nettest/defconfig @@ -160,7 +160,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig index b4bd30ae8..7bce554ac 100644 --- a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig +++ b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig @@ -189,7 +189,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/pcblogic-pic32mx/ostest/defconfig b/nuttx/configs/pcblogic-pic32mx/ostest/defconfig index 08bdccddd..730b8134a 100644 --- a/nuttx/configs/pcblogic-pic32mx/ostest/defconfig +++ b/nuttx/configs/pcblogic-pic32mx/ostest/defconfig @@ -187,7 +187,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/pic32-starterkit/nsh/defconfig b/nuttx/configs/pic32-starterkit/nsh/defconfig index f2cd27560..32220d89b 100644 --- a/nuttx/configs/pic32-starterkit/nsh/defconfig +++ b/nuttx/configs/pic32-starterkit/nsh/defconfig @@ -253,7 +253,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/pic32-starterkit/nsh2/defconfig b/nuttx/configs/pic32-starterkit/nsh2/defconfig index 6f227f638..a7a1ff18a 100644 --- a/nuttx/configs/pic32-starterkit/nsh2/defconfig +++ b/nuttx/configs/pic32-starterkit/nsh2/defconfig @@ -252,7 +252,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/pic32-starterkit/ostest/defconfig b/nuttx/configs/pic32-starterkit/ostest/defconfig index 922cb8901..3a55de491 100644 --- a/nuttx/configs/pic32-starterkit/ostest/defconfig +++ b/nuttx/configs/pic32-starterkit/ostest/defconfig @@ -250,7 +250,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/pic32mx7mmb/nsh/defconfig b/nuttx/configs/pic32mx7mmb/nsh/defconfig index aa7fc23df..d39f8bc40 100644 --- a/nuttx/configs/pic32mx7mmb/nsh/defconfig +++ b/nuttx/configs/pic32mx7mmb/nsh/defconfig @@ -259,7 +259,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/pic32mx7mmb/ostest/defconfig b/nuttx/configs/pic32mx7mmb/ostest/defconfig index 1d656380d..b3cecf98d 100644 --- a/nuttx/configs/pic32mx7mmb/ostest/defconfig +++ b/nuttx/configs/pic32mx7mmb/ostest/defconfig @@ -250,7 +250,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/sam3u-ek/knsh/defconfig b/nuttx/configs/sam3u-ek/knsh/defconfig index e61180407..30f60f0e3 100755 --- a/nuttx/configs/sam3u-ek/knsh/defconfig +++ b/nuttx/configs/sam3u-ek/knsh/defconfig @@ -186,7 +186,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # These NSH commands are (temporarily) disable because more support is needed diff --git a/nuttx/configs/sam3u-ek/nsh/defconfig b/nuttx/configs/sam3u-ek/nsh/defconfig index 288df5957..971598464 100755 --- a/nuttx/configs/sam3u-ek/nsh/defconfig +++ b/nuttx/configs/sam3u-ek/nsh/defconfig @@ -171,7 +171,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/sam3u-ek/nx/defconfig b/nuttx/configs/sam3u-ek/nx/defconfig index 7b56b9d41..dd55d9c93 100755 --- a/nuttx/configs/sam3u-ek/nx/defconfig +++ b/nuttx/configs/sam3u-ek/nx/defconfig @@ -172,7 +172,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/sam3u-ek/ostest/defconfig b/nuttx/configs/sam3u-ek/ostest/defconfig index b2e9a5184..bf15cb1a5 100755 --- a/nuttx/configs/sam3u-ek/ostest/defconfig +++ b/nuttx/configs/sam3u-ek/ostest/defconfig @@ -172,7 +172,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/sam3u-ek/touchscreen/defconfig b/nuttx/configs/sam3u-ek/touchscreen/defconfig index e89db8c4b..414eadb6e 100755 --- a/nuttx/configs/sam3u-ek/touchscreen/defconfig +++ b/nuttx/configs/sam3u-ek/touchscreen/defconfig @@ -180,7 +180,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig index c54d714d0..383522b6f 100644 --- a/nuttx/configs/shenzhou/nsh/defconfig +++ b/nuttx/configs/shenzhou/nsh/defconfig @@ -273,7 +273,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/shenzhou/nxwm/defconfig b/nuttx/configs/shenzhou/nxwm/defconfig index 975327747..b9bf72aeb 100644 --- a/nuttx/configs/shenzhou/nxwm/defconfig +++ b/nuttx/configs/shenzhou/nxwm/defconfig @@ -309,7 +309,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set # CONFIG_SCHED_WAITPID is not set # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/shenzhou/thttpd/defconfig b/nuttx/configs/shenzhou/thttpd/defconfig index 958ab02ed..d7af34821 100644 --- a/nuttx/configs/shenzhou/thttpd/defconfig +++ b/nuttx/configs/shenzhou/thttpd/defconfig @@ -260,7 +260,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig index a60edd4ac..2d627a66d 100644 --- a/nuttx/configs/sim/nsh/defconfig +++ b/nuttx/configs/sim/nsh/defconfig @@ -72,7 +72,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n CONFIG_SCHED_ONEXIT=n diff --git a/nuttx/configs/sim/nsh2/defconfig b/nuttx/configs/sim/nsh2/defconfig index e5dcce322..c9e5b343f 100644 --- a/nuttx/configs/sim/nsh2/defconfig +++ b/nuttx/configs/sim/nsh2/defconfig @@ -91,7 +91,7 @@ CONFIG_PRIORITY_INHERITANCE=n CONFIG_SEM_PREALLOCHOLDERS=0 CONFIG_SEM_NNESTPRIO=0 CONFIG_FDCLONE_DISABLE=n -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_FDCLONE_STDIO=n CONFIG_SDCLONE_DISABLE=y CONFIG_SCHED_WORKQUEUE=n diff --git a/nuttx/configs/sim/ostest/defconfig b/nuttx/configs/sim/ostest/defconfig index 43d78e6a2..5cea9a6d4 100644 --- a/nuttx/configs/sim/ostest/defconfig +++ b/nuttx/configs/sim/ostest/defconfig @@ -57,7 +57,7 @@ CONFIG_DEBUG_VERBOSE=y # # CONFIG_DEBUG_ANALOG is not set # CONFIG_DEBUG_DMA is not set -# CONFIG_DEBUG_SYMBOLS is not set +CONFIG_DEBUG_SYMBOLS=y # # System Type @@ -131,6 +131,7 @@ CONFIG_MSEC_PER_TICK=10 CONFIG_RR_INTERVAL=0 # CONFIG_SCHED_INSTRUMENTATION is not set CONFIG_TASK_NAME_SIZE=32 +CONFIG_SCHED_HAVE_PARENT=y # CONFIG_JULIAN_TIME is not set CONFIG_START_YEAR=2007 CONFIG_START_MONTH=2 @@ -156,6 +157,15 @@ CONFIG_DISABLE_OS_API=y # CONFIG_DISABLE_ENVIRON is not set CONFIG_DISABLE_POLL=y +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCHLD=4 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + # # Sizes of configurable things (0 disables) # @@ -352,6 +362,7 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # CONFIG_EXAMPLES_PASHELLO is not set # CONFIG_EXAMPLES_PIPE is not set # CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set # CONFIG_EXAMPLES_QENCODER is not set # CONFIG_EXAMPLES_RGMP is not set # CONFIG_EXAMPLES_ROMFS is not set diff --git a/nuttx/configs/stm3210e-eval/RIDE/defconfig b/nuttx/configs/stm3210e-eval/RIDE/defconfig index e71540c24..6d84e7c36 100755 --- a/nuttx/configs/stm3210e-eval/RIDE/defconfig +++ b/nuttx/configs/stm3210e-eval/RIDE/defconfig @@ -200,7 +200,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/stm3210e-eval/buttons/defconfig b/nuttx/configs/stm3210e-eval/buttons/defconfig index 0d6882b5d..37e19171f 100644 --- a/nuttx/configs/stm3210e-eval/buttons/defconfig +++ b/nuttx/configs/stm3210e-eval/buttons/defconfig @@ -210,7 +210,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/stm3210e-eval/composite/defconfig b/nuttx/configs/stm3210e-eval/composite/defconfig index 2db58aee5..7fee33794 100755 --- a/nuttx/configs/stm3210e-eval/composite/defconfig +++ b/nuttx/configs/stm3210e-eval/composite/defconfig @@ -210,7 +210,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3210e-eval/nsh/defconfig b/nuttx/configs/stm3210e-eval/nsh/defconfig index 52fdd777f..b5e52e494 100755 --- a/nuttx/configs/stm3210e-eval/nsh/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh/defconfig @@ -208,7 +208,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig index 18e42d539..30a0bb327 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig @@ -255,7 +255,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3210e-eval/nx/defconfig b/nuttx/configs/stm3210e-eval/nx/defconfig index 68a3ad9b5..0ad42dfbe 100644 --- a/nuttx/configs/stm3210e-eval/nx/defconfig +++ b/nuttx/configs/stm3210e-eval/nx/defconfig @@ -209,7 +209,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3210e-eval/nxconsole/defconfig b/nuttx/configs/stm3210e-eval/nxconsole/defconfig index 9cb8689c6..7dd5878bf 100644 --- a/nuttx/configs/stm3210e-eval/nxconsole/defconfig +++ b/nuttx/configs/stm3210e-eval/nxconsole/defconfig @@ -209,7 +209,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3210e-eval/nxlines/defconfig b/nuttx/configs/stm3210e-eval/nxlines/defconfig index ab42612f3..068a17acb 100644 --- a/nuttx/configs/stm3210e-eval/nxlines/defconfig +++ b/nuttx/configs/stm3210e-eval/nxlines/defconfig @@ -209,7 +209,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3210e-eval/nxtext/defconfig b/nuttx/configs/stm3210e-eval/nxtext/defconfig index c00e9b1e8..b6f88a3ca 100644 --- a/nuttx/configs/stm3210e-eval/nxtext/defconfig +++ b/nuttx/configs/stm3210e-eval/nxtext/defconfig @@ -209,7 +209,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3210e-eval/ostest/defconfig b/nuttx/configs/stm3210e-eval/ostest/defconfig index 8ed1795a6..0553b1a98 100755 --- a/nuttx/configs/stm3210e-eval/ostest/defconfig +++ b/nuttx/configs/stm3210e-eval/ostest/defconfig @@ -220,7 +220,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/stm3210e-eval/pm/defconfig b/nuttx/configs/stm3210e-eval/pm/defconfig index 7babce8f6..61bd995c8 100644 --- a/nuttx/configs/stm3210e-eval/pm/defconfig +++ b/nuttx/configs/stm3210e-eval/pm/defconfig @@ -265,7 +265,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3210e-eval/usbserial/defconfig b/nuttx/configs/stm3210e-eval/usbserial/defconfig index b41b41f50..94059c07c 100755 --- a/nuttx/configs/stm3210e-eval/usbserial/defconfig +++ b/nuttx/configs/stm3210e-eval/usbserial/defconfig @@ -210,7 +210,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/stm3210e-eval/usbstorage/defconfig b/nuttx/configs/stm3210e-eval/usbstorage/defconfig index 9f927d7e3..5c1ed5fb2 100755 --- a/nuttx/configs/stm3210e-eval/usbstorage/defconfig +++ b/nuttx/configs/stm3210e-eval/usbstorage/defconfig @@ -210,7 +210,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/stm3220g-eval/dhcpd/defconfig b/nuttx/configs/stm3220g-eval/dhcpd/defconfig index 04f243d71..29baf9af0 100644 --- a/nuttx/configs/stm3220g-eval/dhcpd/defconfig +++ b/nuttx/configs/stm3220g-eval/dhcpd/defconfig @@ -262,7 +262,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3220g-eval/nettest/defconfig b/nuttx/configs/stm3220g-eval/nettest/defconfig index 201df86b0..08e04ad0e 100644 --- a/nuttx/configs/stm3220g-eval/nettest/defconfig +++ b/nuttx/configs/stm3220g-eval/nettest/defconfig @@ -262,7 +262,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3220g-eval/nsh/defconfig b/nuttx/configs/stm3220g-eval/nsh/defconfig index 8baf52f7e..bd9d02860 100644 --- a/nuttx/configs/stm3220g-eval/nsh/defconfig +++ b/nuttx/configs/stm3220g-eval/nsh/defconfig @@ -297,7 +297,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3220g-eval/nsh2/defconfig b/nuttx/configs/stm3220g-eval/nsh2/defconfig index c273ce60f..b5fe843bc 100644 --- a/nuttx/configs/stm3220g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3220g-eval/nsh2/defconfig @@ -296,7 +296,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3220g-eval/nxwm/defconfig b/nuttx/configs/stm3220g-eval/nxwm/defconfig index ab061f07a..145792ddb 100644 --- a/nuttx/configs/stm3220g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3220g-eval/nxwm/defconfig @@ -316,7 +316,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/stm3220g-eval/ostest/defconfig b/nuttx/configs/stm3220g-eval/ostest/defconfig index 2393d0a69..f63f96c9a 100644 --- a/nuttx/configs/stm3220g-eval/ostest/defconfig +++ b/nuttx/configs/stm3220g-eval/ostest/defconfig @@ -261,7 +261,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3220g-eval/telnetd/defconfig b/nuttx/configs/stm3220g-eval/telnetd/defconfig index 1401dc6e7..f529198f1 100644 --- a/nuttx/configs/stm3220g-eval/telnetd/defconfig +++ b/nuttx/configs/stm3220g-eval/telnetd/defconfig @@ -262,7 +262,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/dhcpd/defconfig b/nuttx/configs/stm3240g-eval/dhcpd/defconfig index 80293f66a..5199cf85c 100644 --- a/nuttx/configs/stm3240g-eval/dhcpd/defconfig +++ b/nuttx/configs/stm3240g-eval/dhcpd/defconfig @@ -268,7 +268,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/nettest/defconfig b/nuttx/configs/stm3240g-eval/nettest/defconfig index 81a53bd68..c5e0da795 100644 --- a/nuttx/configs/stm3240g-eval/nettest/defconfig +++ b/nuttx/configs/stm3240g-eval/nettest/defconfig @@ -268,7 +268,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 54eb1d56f..6c19ed531 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -301,7 +301,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n CONFIG_DEV_RANDOM=y diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig index ba6445615..08690ade3 100644 --- a/nuttx/configs/stm3240g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig @@ -302,7 +302,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/nxconsole/defconfig b/nuttx/configs/stm3240g-eval/nxconsole/defconfig index f8a1fb7d5..202fa4378 100644 --- a/nuttx/configs/stm3240g-eval/nxconsole/defconfig +++ b/nuttx/configs/stm3240g-eval/nxconsole/defconfig @@ -301,7 +301,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/nxwm/defconfig b/nuttx/configs/stm3240g-eval/nxwm/defconfig index 5dfdb28fc..a220af2d1 100644 --- a/nuttx/configs/stm3240g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3240g-eval/nxwm/defconfig @@ -302,7 +302,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n CONFIG_SCHED_ONEXIT=y diff --git a/nuttx/configs/stm3240g-eval/ostest/defconfig b/nuttx/configs/stm3240g-eval/ostest/defconfig index 38b51e84b..fcc54aa4b 100644 --- a/nuttx/configs/stm3240g-eval/ostest/defconfig +++ b/nuttx/configs/stm3240g-eval/ostest/defconfig @@ -266,7 +266,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/telnetd/defconfig b/nuttx/configs/stm3240g-eval/telnetd/defconfig index 471845c14..5aef41c27 100644 --- a/nuttx/configs/stm3240g-eval/telnetd/defconfig +++ b/nuttx/configs/stm3240g-eval/telnetd/defconfig @@ -268,7 +268,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm3240g-eval/webserver/defconfig b/nuttx/configs/stm3240g-eval/webserver/defconfig index e9cbbf93d..6d09968e9 100644 --- a/nuttx/configs/stm3240g-eval/webserver/defconfig +++ b/nuttx/configs/stm3240g-eval/webserver/defconfig @@ -302,7 +302,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=2048 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm32f100rc_generic/nsh/defconfig b/nuttx/configs/stm32f100rc_generic/nsh/defconfig index 65ac9a73d..12193e7ed 100644 --- a/nuttx/configs/stm32f100rc_generic/nsh/defconfig +++ b/nuttx/configs/stm32f100rc_generic/nsh/defconfig @@ -249,7 +249,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # CONFIG_SCHED_LPWORK is not set CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt index c1d484279..39fb41d78 100644 --- a/nuttx/configs/stm32f4discovery/README.txt +++ b/nuttx/configs/stm32f4discovery/README.txt @@ -1447,6 +1447,32 @@ Where is one of the following: STANDBY mode. This used of the RTC alarm could conflict with other uses of the RTC alarm in your application. + + posix_spawn: + ------------ + This configuration directory, performs a simple test os the posix_spawn + interface using apps/examples/posix_spawn. + + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + and misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Default toolchain: + + CONFIG_HOST_WINDOWS=y : Builds under windows + CONFIG_WINDOWS_CYGWIN=y : Using Cygwin and + CONFIG_STM32_CODESOURCERYW=y : The native Windows CodeSourcery toolchain + + 3. By default, this project assumes that you are *NOT* using the DFU + bootloader. + winbuild: -------- diff --git a/nuttx/configs/stm32f4discovery/nsh/defconfig b/nuttx/configs/stm32f4discovery/nsh/defconfig index 8967fd01c..98034e22e 100644 --- a/nuttx/configs/stm32f4discovery/nsh/defconfig +++ b/nuttx/configs/stm32f4discovery/nsh/defconfig @@ -282,7 +282,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm32f4discovery/pm/defconfig b/nuttx/configs/stm32f4discovery/pm/defconfig index 105eb4d37..3e24168cd 100644 --- a/nuttx/configs/stm32f4discovery/pm/defconfig +++ b/nuttx/configs/stm32f4discovery/pm/defconfig @@ -283,7 +283,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/stm32f4discovery/posix_spawn/defconfig b/nuttx/configs/stm32f4discovery/posix_spawn/defconfig index b908393d8..9e30ada8a 100644 --- a/nuttx/configs/stm32f4discovery/posix_spawn/defconfig +++ b/nuttx/configs/stm32f4discovery/posix_spawn/defconfig @@ -441,7 +441,7 @@ CONFIG_EOL_IS_EITHER_CRLF=y CONFIG_LIBC_EXECFUNCS=y CONFIG_EXECFUNCS_SYMTAB="exports" CONFIG_EXECFUNCS_NSYMBOLS=10 -CONFIG_POSIX_SPAWN_STACKSIZE=768 +CONFIG_POSIX_SPAWN_STACKSIZE=1024 # CONFIG_LIBC_STRERROR is not set # CONFIG_LIBC_PERROR_STDOUT is not set CONFIG_ARCH_LOWPUTC=y diff --git a/nuttx/configs/sure-pic32mx/nsh/defconfig b/nuttx/configs/sure-pic32mx/nsh/defconfig index 050f30247..60c4dc53d 100644 --- a/nuttx/configs/sure-pic32mx/nsh/defconfig +++ b/nuttx/configs/sure-pic32mx/nsh/defconfig @@ -202,7 +202,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/sure-pic32mx/ostest/defconfig b/nuttx/configs/sure-pic32mx/ostest/defconfig index eb386e232..1bca11c47 100644 --- a/nuttx/configs/sure-pic32mx/ostest/defconfig +++ b/nuttx/configs/sure-pic32mx/ostest/defconfig @@ -188,7 +188,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/sure-pic32mx/usbnsh/defconfig b/nuttx/configs/sure-pic32mx/usbnsh/defconfig index 2b28b94c7..978e16541 100644 --- a/nuttx/configs/sure-pic32mx/usbnsh/defconfig +++ b/nuttx/configs/sure-pic32mx/usbnsh/defconfig @@ -199,7 +199,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/teensy/hello/defconfig b/nuttx/configs/teensy/hello/defconfig index 93376ac57..8fafe1a10 100644 --- a/nuttx/configs/teensy/hello/defconfig +++ b/nuttx/configs/teensy/hello/defconfig @@ -137,7 +137,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for nxflat diff --git a/nuttx/configs/teensy/nsh/defconfig b/nuttx/configs/teensy/nsh/defconfig index ffcd94c1d..faeb0b103 100755 --- a/nuttx/configs/teensy/nsh/defconfig +++ b/nuttx/configs/teensy/nsh/defconfig @@ -137,7 +137,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/teensy/usbstorage/defconfig b/nuttx/configs/teensy/usbstorage/defconfig index dba45073f..1f0186897 100755 --- a/nuttx/configs/teensy/usbstorage/defconfig +++ b/nuttx/configs/teensy/usbstorage/defconfig @@ -138,7 +138,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # Settings for NXFLAT diff --git a/nuttx/configs/twr-k60n512/nsh/defconfig b/nuttx/configs/twr-k60n512/nsh/defconfig index aeb0c5359..7a4bb3b3a 100644 --- a/nuttx/configs/twr-k60n512/nsh/defconfig +++ b/nuttx/configs/twr-k60n512/nsh/defconfig @@ -204,7 +204,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/twr-k60n512/ostest/defconfig b/nuttx/configs/twr-k60n512/ostest/defconfig index 9cf37c763..355e5773b 100644 --- a/nuttx/configs/twr-k60n512/ostest/defconfig +++ b/nuttx/configs/twr-k60n512/ostest/defconfig @@ -203,7 +203,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 # # The following can be used to disable categories of diff --git a/nuttx/configs/ubw32/nsh/defconfig b/nuttx/configs/ubw32/nsh/defconfig index 320b7e266..ad18c12b6 100644 --- a/nuttx/configs/ubw32/nsh/defconfig +++ b/nuttx/configs/ubw32/nsh/defconfig @@ -189,7 +189,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/ubw32/ostest/defconfig b/nuttx/configs/ubw32/ostest/defconfig index 71f286700..60322d4f6 100644 --- a/nuttx/configs/ubw32/ostest/defconfig +++ b/nuttx/configs/ubw32/ostest/defconfig @@ -188,7 +188,7 @@ CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=n CONFIG_SCHED_ATEXIT=n diff --git a/nuttx/configs/vsn/nsh/defconfig b/nuttx/configs/vsn/nsh/defconfig index fa5570596..2b7d8a20c 100755 --- a/nuttx/configs/vsn/nsh/defconfig +++ b/nuttx/configs/vsn/nsh/defconfig @@ -247,7 +247,7 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=4 +CONFIG_SIG_SIGWORK=17 CONFIG_SCHED_WAITPID=y # # The following can be used to disable categories of diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h index 940bf1f1b..6c67e1500 100644 --- a/nuttx/include/nuttx/sched.h +++ b/nuttx/include/nuttx/sched.h @@ -202,6 +202,9 @@ struct _TCB /* Task Management Fields *****************************************************/ pid_t pid; /* This is the ID of the thread */ +#ifdef CONFIG_SCHED_HAVE_PARENT + pid_t parent; /* This is the ID of the parent thread */ +#endif start_t start; /* Thread start function */ entry_t entry; /* Entry Point into the thread */ diff --git a/nuttx/include/nuttx/wqueue.h b/nuttx/include/nuttx/wqueue.h index c509bf197..d56901d89 100644 --- a/nuttx/include/nuttx/wqueue.h +++ b/nuttx/include/nuttx/wqueue.h @@ -68,7 +68,7 @@ * CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker * thread. Default: CONFIG_IDLETHREAD_STACKSIZE. * CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up - * the worker thread. Default: 4 + * the worker thread. Default: 17 * * CONFIG_SCHED_LPWORK. If CONFIG_SCHED_WORKQUEUE is defined, then a single * work queue is created by default. If CONFIG_SCHED_LPWORK is also defined diff --git a/nuttx/include/signal.h b/nuttx/include/signal.h index 02b222343..30726105b 100644 --- a/nuttx/include/signal.h +++ b/nuttx/include/signal.h @@ -66,44 +66,56 @@ /* A few of the real time signals are used within the OS. They have * default values that can be overridden from the configuration file. The - * rest are all user signals: + * rest are all user signals. + * + * These are semi-standard signal definitions: */ #ifndef CONFIG_SIG_SIGUSR1 -#define SIGUSR1 0 /* User signal 1 */ +# define SIGUSR1 1 /* User signal 1 */ #else -#define SIGUSR1 CONFIG_SIG_SIGUSR1 +# define SIGUSR1 CONFIG_SIG_SIGUSR1 #endif #ifndef CONFIG_SIG_SIGUSR2 -#define SIGUSR2 1 /* User signal 2 */ +# define SIGUSR2 2 /* User signal 2 */ #else -#define SIGUSR2 CONFIG_SIG_SIGUSR2 +# define SIGUSR2 CONFIG_SIG_SIGUSR2 #endif #ifndef CONFIG_SIG_SIGALARM -#define SIGALRM 2 /* Default signal used with POSIX timers (used only */ +# define SIGALRM 3 /* Default signal used with POSIX timers (used only */ /* no other signal is provided) */ #else -#define SIGALRM CONFIG_SIG_SIGALARM +# define SIGALRM CONFIG_SIG_SIGALARM #endif -#ifndef CONFIG_DISABLE_PTHREAD -#ifndef CONFIG_SIG_SIGCONDTIMEDOUT -#define SIGCONDTIMEDOUT 3 /* Used in the implementation of pthread_cond_timedwait */ -#else -#define SIGCONDTIMEDOUT CONFIG_SIG_SIGCONDTIMEDOUT +#ifdef CONFIG_SCHED_HAVE_PARENT +# ifndef CONFIG_SIG_SIGCHLD +# define SIGCHLD 4 /* Used by child threads to signal parent thread */ +# else +# define SIGCHLD CONFIG_SIG_SIGCHLD +# endif #endif + +/* The following are non-standard signal definitions */ + +#ifndef CONFIG_DISABLE_PTHREAD +# ifndef CONFIG_SIG_SIGCONDTIMEDOUT +# define SIGCONDTIMEDOUT 16 /* Used in the implementation of pthread_cond_timedwait */ +# else +# define SIGCONDTIMEDOUT CONFIG_SIG_SIGCONDTIMEDOUT +# endif #endif /* SIGWORK is used to wake up various internal, NuttX worker thread */ #if defined(CONFIG_SCHED_WORKQUEUE) || defined(CONFIG_PAGING) -#ifndef CONFIG_SIG_SIGWORK -#define SIGWORK 4 /* Used to wake up the work queue */ -#else -#define SIGWORK CONFIG_SIG_SIGWORK -#endif +# ifndef CONFIG_SIG_SIGWORK +# define SIGWORK 17 /* Used to wake up the work queue */ +# else +# define SIGWORK CONFIG_SIG_SIGWORK +# endif #endif /* sigprocmask() "how" definitions. Only one of the following can be specified: */ @@ -122,12 +134,18 @@ /* These are the possible values of the signfo si_code field */ -#define SI_USER 0 /* Signal sent from kill, raise, or abort */ -#define SI_QUEUE 1 /* Signal sent from sigqueue */ -#define SI_TIMER 2 /* Signal is result of timer expiration */ -#define SI_ASYNCIO 3 /* Signal is the result of asynch IO completion */ -#define SI_MESGQ 4 /* Signal generated by arrival of a message on an */ - /* empty message queue */ +#define SI_USER 0 /* Signal sent from kill, raise, or abort */ +#define SI_QUEUE 1 /* Signal sent from sigqueue */ +#define SI_TIMER 2 /* Signal is result of timer expiration */ +#define SI_ASYNCIO 3 /* Signal is the result of asynch IO completion */ +#define SI_MESGQ 4 /* Signal generated by arrival of a message on an */ + /* empty message queue */ +#define CLD_EXITED 5 /* Child has exited (SIGCHLD only) */ +#define CLD_KILLED 6 /* Child was killed (SIGCHLD only) */ +#define CLD_DUMPED 7 /* Child terminated abnormally (SIGCHLD only) */ +#define CLD_TRAPPED 8 /* Traced child has trapped (SIGCHLD only) */ +#define CLD_STOPPED 9 /* Child has stopped (SIGCHLD only) */ +#define CLD_CONTINUED 10 /* Stopped child had continued (SIGCHLD only) */ /* Values for the sigev_notify field of struct sigevent */ @@ -175,6 +193,10 @@ struct siginfo uint8_t si_signo; /* Identifies signal */ uint8_t si_code; /* Source: SI_USER, SI_QUEUE, SI_TIMER, SI_ASYNCIO, or SI_MESGQ */ union sigval si_value; /* Data passed with signal */ +#ifdef CONFIG_SCHED_HAVE_PARENT + pid_t si_pid; /* Sending task ID */ + int si_status; /* Exit value or signal (SIGCHLD only). */ +#endif }; typedef struct siginfo siginfo_t; diff --git a/nuttx/libc/Kconfig b/nuttx/libc/Kconfig index 2f091f1c7..72a6a5346 100644 --- a/nuttx/libc/Kconfig +++ b/nuttx/libc/Kconfig @@ -123,11 +123,12 @@ config EXECFUNCS_NSYMBOLS config POSIX_SPAWN_STACKSIZE int "posix_spawn Stack Size" - default 768 + default 1024 ---help--- If posix_spawn[p] uses I/O redirection options, then it will require an intermediary/proxy task to muck with the file descriptors. This - configuration item specifies the stack size used for the proxy. + configuration item specifies the stack size used for the proxy. Default: + 1024 bytes. endif diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig index bfaec3b5d..69621a1fa 100644 --- a/nuttx/sched/Kconfig +++ b/nuttx/sched/Kconfig @@ -38,6 +38,16 @@ config TASK_NAME_SIZE Useful if scheduler instrumentation is selected. Set to zero to disable. +config SCHED_HAVE_PARENT + bool "Remember Parent" + default n + ---help--- + Remember the ID of the parent thread when a new child thread is + created. This support enables a few minor features (such as + SIGCHLD) and slightly increases the size of the Task Control Block + (TCB) of every task to hold the ID of the parent thread. Default: + disabled. + config JULIAN_TIME bool "Enables Julian time conversions" default n @@ -127,6 +137,7 @@ config SDCLONE_DISABLE config SCHED_WORKQUEUE bool "Enable worker thread" default n + depends on !DISABLE_SIGNALS ---help--- Create a dedicated "worker" thread to handle delayed processing from interrupt handlers. This feature is required for some drivers but, if there are no @@ -158,14 +169,6 @@ config SCHED_WORKSTACKSIZE ---help--- The stack size allocated for the worker thread. Default: 2K. -config SIG_SIGWORK - int "Worker thread wakeup signal" - default 4 - depends on SCHED_WORKQUEUE - ---help--- - The signal number that will be used to wake-up the worker thread. - Default: 4 - config SCHED_LPWORK bool "Enable a lower priority worker thread" default n @@ -310,6 +313,56 @@ config DISABLE_POLL depends on DISABLE_OS_API default n +if !DISABLE_SIGNALS +comment "Signal Numbers" + +config SIG_SIGUSR1 + int "SIGUSR1" + default 1 + ---help--- + Value of standard user signal 1 (SIGUSR1). Default: 1 + +config SIG_SIGUSR2 + int "SIGUSR2" + default 2 + ---help--- + Value of standard user signal 2 (SIGUSR2). Default: 2 + +config SIG_SIGALARM + int "SIGALRM" + default 3 + ---help--- + Default the signal number used with POSIX timers (SIGALRM). + Default: 3 + +config SIG_SIGCHLD + int "SIGCHLD" + default 4 + depends on SCHED_HAVE_PARENT + ---help--- + The SIGCHLD signal is sent to the parent of a child process when it + exits, is interrupted (stopped), or resumes after being interrupted. + Default: 4 + +config SIG_SIGCONDTIMEDOUT + int "SIGCONDTIMEDOUT" + default 16 + depends on !DISABLE_PTHREAD + ---help--- + This non-standard signal number is used the implementation of + pthread_cond_timedwait(). Default 16. + +config SIG_SIGWORK + int "SIGWORK" + default 17 + depends on SCHED_WORKQUEUE + ---help--- + SIGWORK is a non-standard signal used to wake up the internal NuttX + worker thread. This setting specifies the signal number that will be + used for SIGWORK. Default: 17 + +endif + comment "Sizes of configurable things (0 disables)" config MAX_TASKS diff --git a/nuttx/sched/sched_unlock.c b/nuttx/sched/sched_unlock.c index 9a52e8358..5eafcfc9e 100644 --- a/nuttx/sched/sched_unlock.c +++ b/nuttx/sched/sched_unlock.c @@ -126,5 +126,6 @@ int sched_unlock(void) irqrestore(flags); } + return OK; } diff --git a/nuttx/sched/sig_kill.c b/nuttx/sched/sig_kill.c index 17921015f..b3d74d8a1 100644 --- a/nuttx/sched/sig_kill.c +++ b/nuttx/sched/sig_kill.c @@ -84,6 +84,9 @@ int kill(pid_t pid, int signo) { +#ifdef CONFIG_SCHED_HAVE_PARENT + FAR _TCB *rtcb = (FAR _TCB *)g_readytorun.head; +#endif FAR _TCB *stcb; siginfo_t info; int ret = ERROR; @@ -124,6 +127,10 @@ int kill(pid_t pid, int signo) info.si_signo = signo; info.si_code = SI_USER; info.si_value.sival_ptr = NULL; +#ifdef CONFIG_SCHED_HAVE_PARENT + info.si_pid = rtcb->pid; + info.si_status = OK; +#endif /* Send the signal */ diff --git a/nuttx/sched/sig_mqnotempty.c b/nuttx/sched/sig_mqnotempty.c index 9a1fd7243..f7ae6fd0d 100644 --- a/nuttx/sched/sig_mqnotempty.c +++ b/nuttx/sched/sig_mqnotempty.c @@ -88,6 +88,9 @@ int sig_mqnotempty (int pid, int signo, union sigval value) int sig_mqnotempty (int pid, int signo, void *sival_ptr) #endif { +#ifdef CONFIG_SCHED_HAVE_PARENT + FAR _TCB *rtcb = (FAR _TCB *)g_readytorun.head; +#endif FAR _TCB *stcb; siginfo_t info; int ret = ERROR; @@ -113,6 +116,10 @@ int sig_mqnotempty (int pid, int signo, void *sival_ptr) #else info.si_value.sival_ptr = sival_ptr; #endif +#ifdef CONFIG_SCHED_HAVE_PARENT + info.si_pid = rtcb->pid; + info.si_status = OK; +#endif /* Verify that we can perform the signalling operation */ diff --git a/nuttx/sched/sig_queue.c b/nuttx/sched/sig_queue.c index dee1c798a..db404238e 100644 --- a/nuttx/sched/sig_queue.c +++ b/nuttx/sched/sig_queue.c @@ -111,6 +111,9 @@ int sigqueue (int pid, int signo, union sigval value) int sigqueue(int pid, int signo, void *sival_ptr) #endif { +#ifdef CONFIG_SCHED_HAVE_PARENT + FAR _TCB *rtcb = (FAR _TCB *)g_readytorun.head; +#endif FAR _TCB *stcb; siginfo_t info; int ret = ERROR; @@ -142,13 +145,17 @@ int sigqueue(int pid, int signo, void *sival_ptr) /* Create the siginfo structure */ - info.si_signo = signo; - info.si_code = SI_QUEUE; + info.si_signo = signo; + info.si_code = SI_QUEUE; #ifdef CONFIG_CAN_PASS_STRUCTS - info.si_value = value; + info.si_value = value; #else info.si_value.sival_ptr = sival_ptr; #endif +#ifdef CONFIG_SCHED_HAVE_PARENT + info.si_pid = rtcb->pid; + info.si_status = OK; +#endif /* Send the signal */ diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index d7610cd49..b07b8f2a1 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -120,6 +120,10 @@ static void sig_timeout(int argc, uint32_t itcb) u.wtcb->sigunbinfo.si_signo = SIG_WAIT_TIMEOUT; u.wtcb->sigunbinfo.si_code = SI_TIMER; u.wtcb->sigunbinfo.si_value.sival_int = 0; +#ifdef CONFIG_SCHED_HAVE_PARENT + u.wtcb->sigunbinfo.si_pid = 0; /* Not applicable */ + u.wtcb->sigunbinfo.si_status = OK; +#endif up_unblock_task(u.wtcb); } } diff --git a/nuttx/sched/task_deletecurrent.c b/nuttx/sched/task_deletecurrent.c index 77025f5e0..7ecfb26cc 100644 --- a/nuttx/sched/task_deletecurrent.c +++ b/nuttx/sched/task_deletecurrent.c @@ -90,6 +90,9 @@ * Return Value: * OK on success; or ERROR on failure * + * Assumeptions: + * Interrupts are disabled. + * ****************************************************************************/ int task_deletecurrent(void) @@ -108,7 +111,7 @@ int task_deletecurrent(void) (void)sched_removereadytorun(dtcb); rtcb = (FAR _TCB*)g_readytorun.head; - /* We are not in a bad state -- the head of the ready to run task list + /* We are now in a bad state -- the head of the ready to run task list * does not correspond to the thread that is running. Disabling pre- * emption on this TCB and marking the new ready-to-run task as not * running (see, for example, get_errno_ptr()). @@ -132,9 +135,16 @@ int task_deletecurrent(void) (void)sched_mergepending(); } - /* Now calling sched_unlock() should have no effect */ + /* We can't use sched_unlock() to decrement the lock count because the + * sched_mergepending() call above might have changed the task at the + * head of the ready-to-run list. Furthermore, we should not need to + * perform the unlock action anyway because we know that the pending + * task list is empty. So all we really need to do is to decrement + * the lockcount on rctb. + */ - sched_unlock(); + DEBUGASSERT(rtcb->lockcount > 0); + rtcb->lockcount--; return OK; } diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c index 3bde8fb7a..9ce2e5899 100644 --- a/nuttx/sched/task_exithook.c +++ b/nuttx/sched/task_exithook.c @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -187,6 +188,56 @@ static inline void task_onexit(FAR _TCB *tcb, int status) # define task_onexit(tcb,status) #endif +/**************************************************************************** + * Name: task_sigchild + * + * Description: + * Send the SIGCHILD signal to the parent thread + * + ****************************************************************************/ + +#ifdef CONFIG_SCHED_HAVE_PARENT +static inline void task_sigchild(FAR _TCB *tcb, int status) +{ + FAR _TCB *ptcb; + siginfo_t info; + + /* Keep things stationary through the following */ + + sched_lock(); + + /* Get the TCB of the receiving task */ + + ptcb = sched_gettcb(tcb->parent); + if (!ptcb) + { + /* The parent no longer exists... bail */ + + sched_unlock(); + return; + } + + /* Create the siginfo structure. We don't actually know the cause. That + * is a bug. Let's just say that the child task just exit-ted for now. + */ + + info.si_signo = SIGCHLD; + info.si_code = CLD_EXITED; + info.si_value.sival_ptr = NULL; + info.si_pid = tcb->pid; + info.si_status = status; + + /* Send the signal. We need to use this internal interface so that we can + * provide the correct si_code value with the signal. + */ + + (void)sig_received(ptcb, &info); + sched_unlock(); +} +#else +# define task_sigchild(tcb,status) +#endif + /**************************************************************************** * Name: task_exitwakeup * @@ -259,6 +310,10 @@ void task_exithook(FAR _TCB *tcb, int status) task_atexit(tcb); + /* Send SIGCHLD to the parent of the exiting task */ + + task_sigchild(tcb, status); + /* Call any registered on_exit function(s) */ task_onexit(tcb, status); diff --git a/nuttx/sched/task_setup.c b/nuttx/sched/task_setup.c index 8721b39ec..c5dd8ca3a 100644 --- a/nuttx/sched/task_setup.c +++ b/nuttx/sched/task_setup.c @@ -146,6 +146,34 @@ static int task_assignpid(FAR _TCB *tcb) return ERROR; } +/**************************************************************************** + * Name: task_saveparent + * + * Description: + * Save the task ID of the parent task in the child task's TCB. + * + * Parameters: + * tcb - The TCB of the new, child task. + * + * Returned Value: + * None + * + * Assumptions: + * The parent of the new task is the task at the head of the ready-to-run + * list. + * + ****************************************************************************/ + +#ifdef CONFIG_SCHED_HAVE_PARENT +static inline void task_saveparent(FAR _TCB *tcb) +{ + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + tcb->parent = rtcb->pid; +} +#else +# define task_saveparent(tcb) +#endif + /**************************************************************************** * Name: task_dupdspace * @@ -161,6 +189,8 @@ static int task_assignpid(FAR _TCB *tcb) * None * * Assumptions: + * The parent of the new task is the task at the head of the ready-to-run + * list. * ****************************************************************************/ @@ -231,6 +261,10 @@ int task_schedsetup(FAR _TCB *tcb, int priority, start_t start, main_t main) tcb->start = start; tcb->entry.main = main; + /* Save the task ID of the parent task in the TCB */ + + task_saveparent(tcb); + /* exec(), pthread_create(), task_create(), and vfork() all * inherit the signal mask of the parent thread. */ @@ -243,7 +277,7 @@ int task_schedsetup(FAR _TCB *tcb, int priority, start_t start, main_t main) * until it is activated. */ - tcb->task_state = TSTATE_TASK_INVALID; + tcb->task_state = TSTATE_TASK_INVALID; /* Clone the parent tasks D-Space (if it was running PIC). This * must be done before calling up_initial_state() so that the diff --git a/nuttx/sched/timer_settime.c b/nuttx/sched/timer_settime.c index 1814ba898..f09842ad4 100644 --- a/nuttx/sched/timer_settime.c +++ b/nuttx/sched/timer_settime.c @@ -113,6 +113,10 @@ static void inline timer_sigqueue(FAR struct posix_timer_s *timer) #else info.si_value.sival_ptr = timer->pt_value.sival_ptr; #endif +#ifdef CONFIG_SCHED_HAVE_PARENT + info.si_pid = 0; /* Not applicable */ + info.si_status = OK; +#endif /* Send the signal */ -- cgit v1.2.3 From ffda55b34a9a8a4a84f4cbc1da3836b944baec46 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 13 Jan 2013 00:35:47 +0000 Subject: Cosmetic cleanup from SIGCHLD changes git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5514 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/ostest/sighand.c | 7 ++++++- nuttx/ChangeLog | 2 +- nuttx/sched/task_deletecurrent.c | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/examples/ostest/sighand.c b/apps/examples/ostest/sighand.c index 63d9590d9..32b182c21 100644 --- a/apps/examples/ostest/sighand.c +++ b/apps/examples/ostest/sighand.c @@ -57,7 +57,12 @@ static bool threadexited = false; #ifdef CONFIG_SCHED_HAVE_PARENT static void death_of_child(int signo, siginfo_t *info, void *ucontext) { - /* Use of printf in a signal handler is NOT safe! It can cause deadlocks! */ + /* Use of printf in a signal handler is NOT safe! It can cause deadlocks! + * Also, signals are not queued by NuttX. As a consequence, some + * notifications will get lost (or the info data can be overwrittedn)! + * Because POSIX does not require signals to be queued, I do not think + * that this is a bug (the overwriting is a bug, however). + */ if (info) { diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 921b7014b..7deb9fa94 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3918,7 +3918,7 @@ the scenario: (1) sched_lock() is called increments the lockcount on the current TCB (i.e., the one at the head of the ready to run list), (2) sched_mergepending is called which may change the task - at the head of the readytorun list, then (2) sched_lock() is called + at the head of the readytorun list, then (2) sched_unlock() is called which decrements the lockcount on the wrong TCB. The failure case that I saw was that pre-emption got disabled in the IDLE thread, locking up the whole system. diff --git a/nuttx/sched/task_deletecurrent.c b/nuttx/sched/task_deletecurrent.c index 7ecfb26cc..e1e06acf6 100644 --- a/nuttx/sched/task_deletecurrent.c +++ b/nuttx/sched/task_deletecurrent.c @@ -115,9 +115,12 @@ int task_deletecurrent(void) * does not correspond to the thread that is running. Disabling pre- * emption on this TCB and marking the new ready-to-run task as not * running (see, for example, get_errno_ptr()). + * + * We disable pre-emption here by directly incrementing the lockcount + * (vs. calling sched_lock()). */ - sched_lock(); + rtcb->lockcount++; rtcb->task_state = TSTATE_TASK_READYTORUN; /* Move the TCB to the specified blocked task list and delete it */ @@ -143,7 +146,6 @@ int task_deletecurrent(void) * the lockcount on rctb. */ - DEBUGASSERT(rtcb->lockcount > 0); rtcb->lockcount--; return OK; } -- cgit v1.2.3 From b3f3dd123c181fe851f0a9756bed7acd4ba4ef7d Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 13 Jan 2013 18:53:00 +0000 Subject: Use SIGCHLD with waitpid(); implemented wait() and waitid() git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5515 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 3 +- apps/examples/ostest/Makefile | 4 + apps/examples/ostest/ostest.h | 42 +++-- apps/examples/ostest/ostest_main.c | 8 + apps/examples/ostest/waitpid.c | 269 +++++++++++++++++++++++++++++ nuttx/ChangeLog | 7 + nuttx/Documentation/NuttX.html | 8 +- nuttx/Documentation/NuttxPortingGuide.html | 10 +- nuttx/Documentation/NuttxUserGuide.html | 181 +++++++++++++++++-- nuttx/TODO | 13 +- nuttx/configs/README.txt | 16 +- nuttx/configs/sim/ostest/defconfig | 2 +- nuttx/include/nuttx/sched.h | 5 +- nuttx/include/sys/types.h | 4 +- nuttx/include/sys/wait.h | 10 +- nuttx/sched/Kconfig | 14 +- nuttx/sched/Makefile | 5 +- nuttx/sched/os_internal.h | 6 +- nuttx/sched/sched_wait.c | 90 ++++++++++ nuttx/sched/sched_waitid.c | 256 +++++++++++++++++++++++++++ nuttx/sched/sched_waitpid.c | 192 ++++++++++++++++++-- nuttx/sched/task_exithook.c | 24 ++- nuttx/sched/task_setup.c | 3 + 23 files changed, 1078 insertions(+), 94 deletions(-) create mode 100644 apps/examples/ostest/waitpid.c create mode 100644 nuttx/sched/sched_wait.c create mode 100644 nuttx/sched/sched_waitid.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 65d4d6134..70381a79d 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -464,4 +464,5 @@ * apps/exampes/posix_spawn: Added a test of poxis_spawn(). * apps/examples/ostest: Extend signal handler test to catch death-of-child signals (SIGCHLD). - + * apps/examples/ostest/waitpid.c: Add a test for waitpid(), waitid(), + and wait(). diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index b7ba9a9a8..5a8ff7293 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -52,6 +52,10 @@ ifeq ($(CONFIG_ARCH_FPU),y) CSRCS += fpu.c endif +ifeq ($(CONFIG_SCHED_WAITPID),y) +CSRCS += waitpid.c +endif + ifneq ($(CONFIG_DISABLE_PTHREAD),y) CSRCS += cancel.c cond.c mutex.c sem.c barrier.c ifneq ($(CONFIG_RR_INTERVAL),0) diff --git a/apps/examples/ostest/ostest.h b/apps/examples/ostest/ostest.h index bc46a3860..5217f0a0c 100644 --- a/apps/examples/ostest/ostest.h +++ b/apps/examples/ostest/ostest.h @@ -105,68 +105,74 @@ /* dev_null.c ***************************************************************/ -extern int dev_null(void); +int dev_null(void); /* fpu.c ********************************************************************/ -extern void fpu_test(void); +void fpu_test(void); + +/* waitpid.c ****************************************************************/ + +#ifdef CONFIG_SCHED_WAITPID +int waitpid_test(void); +#endif /* mutex.c ******************************************************************/ -extern void mutex_test(void); +void mutex_test(void); /* rmutex.c ******************************************************************/ -extern void recursive_mutex_test(void); +void recursive_mutex_test(void); /* sem.c ********************************************************************/ -extern void sem_test(void); +void sem_test(void); /* cond.c *******************************************************************/ -extern void cond_test(void); +void cond_test(void); /* mqueue.c *****************************************************************/ -extern void mqueue_test(void); +void mqueue_test(void); /* timedmqueue.c ************************************************************/ -extern void timedmqueue_test(void); +void timedmqueue_test(void); /* cancel.c *****************************************************************/ -extern void cancel_test(void); +void cancel_test(void); /* timedwait.c **************************************************************/ -extern void timedwait_test(void); +void timedwait_test(void); /* sighand.c ****************************************************************/ -extern void sighand_test(void); +void sighand_test(void); /* posixtimers.c ************************************************************/ -extern void timer_test(void); +void timer_test(void); /* roundrobin.c *************************************************************/ -extern void rr_test(void); +void rr_test(void); /* barrier.c ****************************************************************/ -extern void barrier_test(void); +void barrier_test(void); /* prioinherit.c ************************************************************/ -extern void priority_inheritance(void); +void priority_inheritance(void); /* vfork.c ******************************************************************/ #ifdef CONFIG_ARCH_HAVE_VFORK -extern int vfork_test(void); +int vfork_test(void); #endif /* APIs exported (conditionally) by the OS specifically for testing of @@ -174,8 +180,8 @@ extern int vfork_test(void); */ #if defined(CONFIG_DEBUG) && defined(CONFIG_PRIORITY_INHERITANCE) && defined(CONFIG_SEM_PHDEBUG) -extern void sem_enumholders(FAR sem_t *sem); -extern int sem_nfreeholders(void); +void sem_enumholders(FAR sem_t *sem); +int sem_nfreeholders(void); #else # define sem_enumholders(sem) # define sem_nfreeholders() diff --git a/apps/examples/ostest/ostest_main.c b/apps/examples/ostest/ostest_main.c index ca44353c3..aab1ff045 100644 --- a/apps/examples/ostest/ostest_main.c +++ b/apps/examples/ostest/ostest_main.c @@ -301,6 +301,14 @@ static int user_main(int argc, char *argv[]) check_test_memory_usage(); #endif +#ifdef CONFIG_SCHED_WAITPID + /* Check waitpid() and friends */ + + printf("\nuser_main: waitpid test\n"); + waitpid_test(); + check_test_memory_usage(); +#endif + #ifndef CONFIG_DISABLE_PTHREAD /* Verify pthreads and pthread mutex */ diff --git a/apps/examples/ostest/waitpid.c b/apps/examples/ostest/waitpid.c new file mode 100644 index 000000000..e53b49213 --- /dev/null +++ b/apps/examples/ostest/waitpid.c @@ -0,0 +1,269 @@ +/**************************************************************************** + * examples/ostest/waitpid.c + * + * Copyright (C) 2013 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 "ostest.h" + +#ifdef CONFIG_SCHED_WAITPID + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define RETURN_STATUS 14 +#define NCHILDREN 3 +#define PRIORITY 100 + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static int g_waitpids[NCHILDREN]; + +/**************************************************************************** + * Priviate Functions + ****************************************************************************/ + +static int waitpid_main(int argc, char *argv[]) +{ + pid_t me = getpid(); + + printf("waitpid_main: PID %d Started\n", me); + sleep(3); + printf("waitpid_main: PID %d exitting with result=%d\n", me, RETURN_STATUS); + return RETURN_STATUS; +} + +static void waitpid_start_children(void) +{ + int ret; + int i; + + for (i = 0; i < NCHILDREN; i++) + { + ret = TASK_CREATE("waitpid", PRIORITY, STACKSIZE, waitpid_main, NULL); + if (ret < 0) + { + printf("waitpid_start_child: ERROR Failed to start user_main\n"); + } + else + { + printf("waitpid_start_child: Started waitpid_main at PID=%d\n", ret); + } + + g_waitpids[i] = ret; + } +} + +static void waitpid_last(void) +{ + int stat_loc; + int ret; + + printf("waitpid_last: Waiting for PID=%d with waitpid()\n", + g_waitpids[NCHILDREN-1]); + + ret = (int)waitpid(g_waitpids[NCHILDREN-1], &stat_loc, 0); + if (ret < 0) + { + int errcode = errno; + printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n", + g_waitpids[NCHILDREN-1], errcode); + } + else if (stat_loc != RETURN_STATUS) + { + printf("waitpid_last: ERROR: PID %d return status is %d, expected %d\n", + g_waitpids[NCHILDREN-1], stat_loc, RETURN_STATUS); + } + else + { + printf("waitpid_last: PID %d waitpid succeeded with stat_loc=%d\n", + g_waitpids[NCHILDREN-1], stat_loc); + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int waitpid_test(void) +{ +#ifdef CONFIG_SCHED_HAVE_PARENT + siginfo_t info; +#endif + int stat_loc; + int ret; + + /* Start the children and wait for first one to complete */ + + printf("\nTest waitpid()\n"); + waitpid_start_children(); + + printf("waitpid_test: Waiting for PID=%d with waitpid()\n", g_waitpids[0]); + ret = (int)waitpid(g_waitpids[0], &stat_loc, 0); + if (ret < 0) + { + int errcode = errno; + printf("waitpid_test: ERROR: PID %d waitpid failed: %d\n", + g_waitpids[0], errcode); + } + else if (ret != g_waitpids[0]) + { + printf("waitpid_test: ERROR: PID %d wait returned PID %d\n", + g_waitpids[0], ret); + } + else if (stat_loc != RETURN_STATUS) + { + printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n", + g_waitpids[0], stat_loc, RETURN_STATUS); + } + else + { + printf("waitpid_test: PID %d waitpid succeeded with stat_loc=%d\n", + g_waitpids[0], stat_loc); + } + + /* Wait a big to make sure that the other threads complete */ + + waitpid_last(); + sleep(1); + +#ifdef CONFIG_SCHED_HAVE_PARENT + /* Start the children and wait for first one to complete */ + + printf("\nTest waitid(P_PID)\n"); + waitpid_start_children(); + + printf("waitpid_test: Waiting for PID=%d with waitid()\n", g_waitpids[0]); + ret = waitid(P_PID, (id_t)g_waitpids[0], &info, WEXITED); + if (ret < 0) + { + int errcode = errno; + printf("waitpid_test: ERROR: PID %d waitid failed: %d\n", + g_waitpids[0], errcode); + } + else if (info.si_pid != g_waitpids[0]) + { + printf("waitpid_test: ERROR: PID %d waitid returned PID %d\n", + g_waitpids[0], info.si_pid); + } + else if (info.si_status != RETURN_STATUS) + { + printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n", + info.si_pid, info.si_status, RETURN_STATUS); + } + else + { + printf("waitpid_test: waitid PID %d succeeded with si_status=%d\n", + info.si_pid, info.si_status); + } + + /* Wait a big to make sure that the other threads complete */ + + waitpid_last(); + sleep(1); + + /* Start the children and wait for any one to complete */ + + printf("\nTest waitid(P_ALL)\n"); + waitpid_start_children(); + + printf("waitpid_test: Waiting for any child with waitid()\n"); + ret = waitid(P_ALL, 0, &info, WEXITED); + if (ret < 0) + { + int errcode = errno; + printf("waitpid_test: ERROR: waitid failed: %d\n", errcode); + } + else if (info.si_status != RETURN_STATUS) + { + printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n", + info.si_pid, info.si_status, RETURN_STATUS); + } + else + { + printf("waitpid_test: PID %d waitid succeeded with si_status=%d\n", + info.si_pid, info.si_status); + } + + /* Wait a big to make sure that the other threads complete */ + + waitpid_last(); + sleep(1); + + /* Start the children and wait for first one to complete */ + + printf("\nTest wait()\n"); + waitpid_start_children(); + + printf("waitpid_test: Waiting for any child with wait()\n"); + ret = (int)wait(&stat_loc); + if (ret < 0) + { + int errcode = errno; + printf("waitpid_test: ERROR: wait failed: %d\n", errcode); + } + else if (stat_loc != RETURN_STATUS) + { + printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n", + ret, stat_loc, RETURN_STATUS); + } + else + { + printf("waitpid_test: PID %d wait succeeded with stat_loc=%d\n", + ret, stat_loc); + } + + /* Wait a big to make sure that the other threads complete */ + + waitpid_last(); + sleep(1); +#endif + + return 0; +} + +#endif /* CONFIG_SCHED_WAITPID */ diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 7deb9fa94..e8d4f7309 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3922,3 +3922,10 @@ which decrements the lockcount on the wrong TCB. The failure case that I saw was that pre-emption got disabled in the IDLE thread, locking up the whole system. + * sched/sched_waitpid.c: Use SIGCHLD instead of a semaphore. This + is a much more spec-compliant implemenation. However, there are + some issues with overruning signals because NuttX does not support + queueing of signals (POSIX does not require it). I think it may + need to. + * sched/sched_waitid.c and sched_wait.c: Add support for waitid() + and wait(). See issues with waitpid() above. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index f6e9a41ba..22651de79 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -286,7 +286,7 @@

        • Easily extensible to new processor architectures, SoC architecture, or board architectures. - A Porting Guide is available. + A Porting Guide is available.
        • @@ -536,7 +536,7 @@

          -

        • Power management sub-system.
        • +
        • Power management sub-system.
        • @@ -1009,7 +1009,7 @@ This configuration file contains a long list of settings that control what is built into NuttX and what is not. There are hundreds of such settings - (see the NuttX Porting Guide + (see the NuttX Porting Guide for a partial list that excludes platform specific settings). These many, many configuration options allow NuttX to be highly tuned to meet size requirements. @@ -3837,7 +3837,7 @@ pascal-3.0 2011-05-15 Gregory Nutt <gnutt@nuttx.org> - Porting Guide + Porting Guide diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 0b67eddb7..fec7106b0 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@

          NuttX RTOS Porting Guide

          -

          Last Updated: January 12, 2013

          +

          Last Updated: January 13, 2013

          @@ -4482,7 +4482,8 @@ build
        • CONFIG_SCHED_HAVE_PARENT: Remember the ID of the parent thread when a new child thread is created. - This support enables a few minor features (such as SIGCHLD) and slightly increases the size of the Task Control Block (TCB) of every task to hold the ID of the parent thread. + This support enables some additional features (such as SIGCHLD) and modifies the behavior of other interfaces. + For example, it makes waitpid() more standards complete by restricting the waited-for tasks to the children of the caller. Default: disabled.
        • @@ -4601,10 +4602,11 @@ build CONFIG_SCHED_LPWORKPERIOD: How often the lower priority worker thread checks for work in units of microseconds. Default: 50*1000 (50 MS).
        • - CONFIG_SCHED_LPWORKSTACKSIZE - The stack size allocated for the lower priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. + CONFIG_SCHED_LPWORKSTACKSIZE: The stack size allocated for the lower priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
        • - CONFIG_SCHED_WAITPID: Enables the waitpid() API + CONFIG_SCHED_WAITPID: Enables the waitpid() interface in a default, non-standard mode (non-standard in the sense that the waited for PID need not be child of the caller). + If SCHED_HAVE_PARENT is also defined, then this setting will modify the behavior or waitpid() (making more spec compliant) and will enable the waitid() and waitp() interfaces as well.
        • CONFIG_SCHED_ATEXIT: Enables the atexit() API diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html index c6eabd29a..3cfb63f11 100644 --- a/nuttx/Documentation/NuttxUserGuide.html +++ b/nuttx/Documentation/NuttxUserGuide.html @@ -13,7 +13,7 @@

          NuttX Operating System

          User's Manual

          by

          Gregory Nutt

          -

          Last Updated: January 11, 2013

          +

          Last Updated: January 13, 2013

          @@ -1776,8 +1776,10 @@ priority of the calling task is returned.

          Task synchronization interfaces

          2.3.1 sched_lock

          @@ -1886,10 +1888,12 @@ on this thread of execution. Description:

          - The following discussion is a general description of the waitpid() interface. - However, as of this writing, the implementation of waitpid() is fragmentary (but usable). - It simply supports waiting for any task to complete execution. - NuttX does not support any concept of parent/child processes or of process groups nor signals related to child processes (SIGCHLD). + The following discussion is a general description of the waitpid() interface. + However, as of this writing, the implementation of waitpid() is incomplete (but usable). + If CONFIG_SCHED_HAVE_PARENT is defined, waitpid() will be a little more compliant to specifications. + Without CONFIG_SCHED_HAVE_PARENT, waitpid() simply supports waiting for any task to complete execution. + With CONFIG_SCHED_HAVE_PARENT, waitpid() will use SIGCHLD and can, therefore, wait for any child of the parent to complete. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. Nor does NuttX retain the status of exited tasks so if waitpid() is called after a task has exited, then no status will be available. The options argument is currently ignored.
          @@ -2038,7 +2042,158 @@ on this thread of execution. Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed above).

          -

          2.3.5 atexit

          +

          2.3.5 waitid

        • +

          +Function Prototype: +

          +    #include <sys/wait.h>
          +    #ifdef CONFIG_SCHED_HAVE_PARENT
          +    int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options);
          +    #endif
          +
          +

          + Description: +

          +
          + The following discussion is a general description of the waitid() interface. + However, as of this writing, the implementation of waitid() is incomplete (but usable). + If CONFIG_SCHED_HAVE_PARENT is defined, waitid() will be a little more compliant to specifications. + waitpid() simply supports waiting a specific child task (P_PID or for any child task P_ALL to complete execution. + SIGCHLD is used. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. + Nor does NuttX retain the status of exited tasks so if waitpid() is called after a task has exited, then no status will be available. + The options argument is currently ignored. +
          +

          + The waitid() function suspends the calling thread until one child of the process containing the calling thread changes state. + It records the current state of a child in the structure pointed to by info. + If a child process changed state prior to the call to waitid(), waitid() returns immediately. + If more than one thread is suspended in wait() or waitpid() waiting termination of the same process, exactly one thread will return the process status at the time of the target process termination +

          +

          + The idtype and id arguments are used to specify which children waitid() will wait for. +

          +

          +

            +
          • + If idtype is P_PID, waitid() will wait for the child with a process ID equal to (pid_t)id. +
          • +
          • + If idtype is P_PGID, waitid() will wait for any child with a process group ID equal to (pid_t)id. +
          • +
          • + If idtype is P_ALL, waitid() will wait for any children and id is ignored. +
          +

          + The options argument is used to specify which state changes waitid() will will wait for. + It is formed by OR-ing together one or more of the following flags: +

          +
            +
          • + WEXITED: + Wait for processes that have exited. +
          • +
          • + WSTOPPED: + Status will be returned for any child that has stopped upon receipt of a signal. +
          • +
          • + WCONTINUES: + Status will be returned for any child that was stopped and has been continued. +
          • +
          • + WNOHANG: + Return immediately if there are no children to wait for. +
          • +
          • + WNOWAIT: + Keep the process whose status is returned in info in a waitable state. + This will not affect the state of the process; + the process may be waited for again after this call completes. +
          • +
          + The info argument must point to a siginfo_t structure. + If waitid() returns because a child process was found that satisfied the conditions indicated by the arguments idtype and options, then the structure pointed to by info will be filled in by the system with the status of the process. + The si_signo member will always be equal to SIGCHLD. +

          +

          + Input Parameters: + See the description above. +

          +

          + Returned Value: + If waitid() returns due to the change of state of one of its children, 0 is returned. + Otherwise, -1 is returned and errno is set to indicate the error. +

          +

          + The waitid() function will fail if: +

          +
            +
          • + ECHILD: +
          • + The calling process has no existing unwaited-for child processes. +
          • + EINTR: +
          • + The waitid() function was interrupted by a signal. +
          • + EINVAL: + An invalid value was specified for options, or idtype and id specify an invalid set of processes. +
          • +
          +

          + Assumptions/Limitations: +

          + POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description above). +

          + +

          2.3.6 wait

          +

          +Function Prototype: +

          +    #include <sys/wait.h>
          +    #ifdef CONFIG_SCHED_HAVE_PARENT
          +    pid_t wait(FAR int *stat_loc);
          +    #endif
          +
          +

          + Description: +

          +
          + The following discussion is a general description of the wait() interface. + However, as of this writing, the implementation of wait() is incomplete (but usable). + wait() is based on waitpaid(). + See the description of waitpaid() for further information. +
          +

          + The wait() function will suspend execution of the calling thread until status information for one of its terminated child processes is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. + If more than one thread is suspended in wait() awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination. + If status information is available prior to the call towait(), return will be immediate. +

          +

          + The waitpid() function will behave identically to wait(), if its pid argument is (pid_t)-1 and the options argument is 0. + Otherwise, its behavior will be modified by the values of the pid and options arguments. +

          +

          + Input Parameters: +

          +
            +
          • stat_loc. The location to return the exit status
          • +
          +

          + Returned Value: + See the values returned by waitpaid(). +

          +

          + Assumptions/Limitations: +

          + POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description waitpaid()). +

          + +

          2.3.7 atexit

          Function Prototype: @@ -2077,7 +2232,7 @@ on this thread of execution.

        • atexit() functions are not inherited when a new task is created.
        • -

          2.3.6 on_exit

          +

          2.3.8 on_exit

          Function Prototype: @@ -9023,9 +9178,9 @@ notify a task when a message is available on a queue.

        • pipe
        • poll
        • poll.h
        • +
        • posix_spawn
        • -
        • posix_spawn
        • posix_spawn_file_actions_addclose
        • posix_spawn_file_actions_adddup2
        • posix_spawn_file_actions_addopen
        • @@ -9107,10 +9262,10 @@ notify a task when a message is available on a queue.
        • recv
        • recvfrom
        • rename
        • - -
        • rmdir
        • rewinddir
        • + +
        • ROM disk driver
        • ROMFS
        • sched_getparam
        • @@ -9183,6 +9338,8 @@ notify a task when a message is available on a queue.
        • vfprintf
        • vprintf
        • vsprintf
        • +
        • wait
        • +
        • waitid
        • waitpid
        • Watchdog Timer Interfaces
        • wd_cancel
        • diff --git a/nuttx/TODO b/nuttx/TODO index 92b7ab4f5..88324c06b 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -6,7 +6,7 @@ standards, things that could be improved, and ideas for enhancements. nuttx/ - (11) Task/Scheduler (sched/) + (10) Task/Scheduler (sched/) (1) Memory Managment (mm/) (2) Signals (sched/, arch/) (2) pthreads (sched/) @@ -58,17 +58,6 @@ o Task/Scheduler (sched/) Status: Closed. No, this behavior will not be implemented. Priority: Medium, required for good emulation of process/pthread model. - Title: WAIT.H - Description: Implement sys/wait.h and functions. Consider implementing wait, - waitpid, waitid. At present, a parent has no information about - child tasks. - - Update: A simple but usable version of waitpid() has been included. - This version is not compliant with all specifications and can be - enabled with CONFIG_SCHED_WAITPID. - Status: Open, however no further work is planned. - Priority: Low - Title: MISSING ERRNO SETTINGS Description: Several APIs do not set errno. Need to review all APIs. Update: These are being fixed as they are encountered. There is diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 2724cf5a3..4800f02ee 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -335,10 +335,11 @@ defconfig -- This is a configuration file similar to the Linux task name to save in the TCB. Useful if scheduler instrumentation is selected. Set to zero to disable. CONFIG_SCHED_HAVE_PARENT - Remember the ID of the parent thread - when a new child thread is created. This support enables a - few minor features (such as SIGCHLD) and slightly increases - the size of the Task Control Block (TCB) of every task to hold - the ID of the parent thread. Default: disabled. + when a new child thread is created. This support enables some + additional features (such as SIGCHLD) and modifies the behavior + of other interfaces. For example, it makes waitpid() more + standards complete by restricting the waited-for tasks to the + children of the caller. Default: disabled. CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY - Used to initialize the internal time logic. CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions. @@ -417,7 +418,12 @@ defconfig -- This is a configuration file similar to the Linux checks for work in units of microseconds. Default: 50*1000 (50 MS). CONFIG_SCHED_LPWORKSTACKSIZE - The stack size allocated for the lower priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. - CONFIG_SCHED_WAITPID - Enables the waitpid() API + CONFIG_SCHED_WAITPID - Enables the waitpid() interface in a default, + non-standard mode (non-standard in the sense that the waited for + PID need not be child of the caller). If SCHED_HAVE_PARENT is + also defined, then this setting will modify the behavior or + waitpid() (making more spec compliant) and will enable the + waitid() and wait() interfaces as well. CONFIG_SCHED_ATEXIT - Enables the atexit() API CONFIG_SCHED_ATEXIT_MAX - By default if CONFIG_SCHED_ATEXIT is selected, only a single atexit() function is supported. That number diff --git a/nuttx/configs/sim/ostest/defconfig b/nuttx/configs/sim/ostest/defconfig index 5cea9a6d4..c8d5c501d 100644 --- a/nuttx/configs/sim/ostest/defconfig +++ b/nuttx/configs/sim/ostest/defconfig @@ -143,7 +143,7 @@ CONFIG_MUTEX_TYPES=y # CONFIG_FDCLONE_STDIO is not set CONFIG_SDCLONE_DISABLE=y # CONFIG_SCHED_WORKQUEUE is not set -# CONFIG_SCHED_WAITPID is not set +CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_ATEXIT is not set # CONFIG_SCHED_ONEXIT is not set CONFIG_USER_ENTRYPOINT="ostest_main" diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h index 6c67e1500..b2ec1cee4 100644 --- a/nuttx/include/nuttx/sched.h +++ b/nuttx/include/nuttx/sched.h @@ -1,7 +1,7 @@ /******************************************************************************** * include/nuttx/sched.h * - * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -204,6 +204,7 @@ struct _TCB pid_t pid; /* This is the ID of the thread */ #ifdef CONFIG_SCHED_HAVE_PARENT pid_t parent; /* This is the ID of the parent thread */ + uint16_t nchildren; /* This is the number active children */ #endif start_t start; /* Thread start function */ entry_t entry; /* Entry Point into the thread */ @@ -226,7 +227,7 @@ struct _TCB # endif #endif -#ifdef CONFIG_SCHED_WAITPID +#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT) sem_t exitsem; /* Support for waitpid */ int *stat_loc; /* Location to return exit status */ #endif diff --git a/nuttx/include/sys/types.h b/nuttx/include/sys/types.h index 2ae69d4a7..95feee72e 100644 --- a/nuttx/include/sys/types.h +++ b/nuttx/include/sys/types.h @@ -154,7 +154,9 @@ typedef uint16_t dev_t; typedef uint16_t ino_t; -/* pid_t is used for process IDs and process group IDs */ +/* pid_t is used for process IDs and process group IDs. It must be signed because + * negative PID values are used to represent invalid PIDs. + */ typedef int pid_t; diff --git a/nuttx/include/sys/wait.h b/nuttx/include/sys/wait.h index 6af1e971e..2476adef9 100644 --- a/nuttx/include/sys/wait.h +++ b/nuttx/include/sys/wait.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/sys/wait.h * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ #define WTERMSIG(s) (false) /* Return signal number that caused process to terminate */ /* The following symbolic constants are possible values for the options - * argument to waitpi(1) (1) and/or waitid() (2), + * argument to waitpid() (1) and/or waitid() (2), */ #define WCONTINUED (1 << 0) /* Status for child that has been continued (1)(2) */ @@ -104,9 +104,9 @@ extern "C" { #define EXTERN extern #endif -EXTERN pid_t wait(int *stat_loc); -EXTERN int waitid(idtype_t idtype, id_t id, siginfo_t *siginfo, int options); -EXTERN pid_t waitpid(pid_t pid, int *stat_loc, int options); +EXTERN pid_t wait(FAR int *stat_loc); +EXTERN int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options); +EXTERN pid_t waitpid(pid_t pid, FAR int *stat_loc, int options); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig index 69621a1fa..6d53a03aa 100644 --- a/nuttx/sched/Kconfig +++ b/nuttx/sched/Kconfig @@ -43,9 +43,10 @@ config SCHED_HAVE_PARENT default n ---help--- Remember the ID of the parent thread when a new child thread is - created. This support enables a few minor features (such as - SIGCHLD) and slightly increases the size of the Task Control Block - (TCB) of every task to hold the ID of the parent thread. Default: + created. This support enables some additional features (such as + SIGCHLD) and modifies the behavior of other interfaces. For + example, it makes waitpid() more standards complete by restricting + the waited-for tasks to the children of the caller. Default: disabled. config JULIAN_TIME @@ -206,7 +207,12 @@ config SCHED_WAITPID bool "Enable waitpid() API" default n ---help--- - Enables the waitpid() API + Enables the waitpid() interface in a default, non-standard mode + (non-standard in the sense that the waited for PID need not be child + of the caller). If SCHED_HAVE_PARENT is also defined, then this + setting will modify the behavior or waitpid() (making more spec + compliant) and will enable the waitid() and wait() interfaces as + well. config SCHED_ATEXIT bool "Enable atexit() API" diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index 23d1e9938..3d6b58bac 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -1,7 +1,7 @@ ############################################################################ # sched/Makefile # -# Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -69,6 +69,9 @@ endif ifeq ($(CONFIG_SCHED_WAITPID),y) SCHED_SRCS += sched_waitpid.c +ifeq ($(CONFIG_SCHED_HAVE_PARENT),y) +SCHED_SRCS += sched_waitid.c sched_wait.c +endif endif ENV_SRCS = env_getenvironptr.c env_dup.c env_share.c env_release.c \ diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h index 13b8083cf..32d9fb4ac 100644 --- a/nuttx/sched/os_internal.h +++ b/nuttx/sched/os_internal.h @@ -83,10 +83,10 @@ enum os_crash_codes_e OSERR_BADREPRIORITIZESTATE /* Attempt to reprioritize in bad state or priority */ }; -/* Special task IDS */ +/* Special task IDS. Any negative PID is invalid. */ -#define NULL_TASK_PROCESS_ID 0 -#define INVALID_PROCESS_ID 0 +#define NULL_TASK_PROCESS_ID (pid_t)0 +#define INVALID_PROCESS_ID (pid_t)-1 /* Although task IDs can take the (positive, non-zero) * range of pid_t, the number of tasks that will be supported diff --git a/nuttx/sched/sched_wait.c b/nuttx/sched/sched_wait.c new file mode 100644 index 000000000..813d4f842 --- /dev/null +++ b/nuttx/sched/sched_wait.c @@ -0,0 +1,90 @@ +/***************************************************************************** + * sched/sched_wait.c + * + * Copyright (C) 2013 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 "os_internal.h" + +#if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) + +/***************************************************************************** + * Private Functions + *****************************************************************************/ + +/***************************************************************************** + * Public Functions + *****************************************************************************/ + +/***************************************************************************** + * Name: wait + * + * Description: + * The wait() function will suspend execution of the calling thread until + * status information for one of its terminated child processes is + * available, or until delivery of a signal whose action is either to + * execute a signal-catching function or to terminate the process. If more + * than one thread is suspended in wait() or waitpid() awaiting termination + * of the same process, exactly one thread will return the process status + * at the time of the target process termination. If status information is + * available prior to the call to wait(), return will be immediate. + * + * The waitpid() function will behave identically to wait(), if the pid + * argument is (pid_t)-1 and the options argument is 0. Otherwise, its + * behaviour will be modified by the values of the pid and options arguments. + * + * Input Parameters: + * stat_loc - The location to return the exit status + * + * Returned Value: + * See waitpid(); + * + *****************************************************************************/ + +pid_t wait(FAR int *stat_loc) +{ + return waitpid((pid_t)-1, stat_loc, 0); +} + +#endif /* CONFIG_SCHED_WAITPID && CONFIG_SCHED_HAVE_PARENT*/ diff --git a/nuttx/sched/sched_waitid.c b/nuttx/sched/sched_waitid.c new file mode 100644 index 000000000..eabc69afe --- /dev/null +++ b/nuttx/sched/sched_waitid.c @@ -0,0 +1,256 @@ +/***************************************************************************** + * sched/sched_waitid.c + * + * Copyright (C) 2013 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 "os_internal.h" + +#if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) + +/***************************************************************************** + * Private Functions + *****************************************************************************/ + +/***************************************************************************** + * Public Functions + *****************************************************************************/ + +/***************************************************************************** + * Name: waitid + * + * Description: + * The waitid() function suspends the calling thread until one child of + * the process containing the calling thread changes state. It records the + * current state of a child in the structure pointed to by 'info'. If a + * child process changed state prior to the call to waitid(), waitid() + * returns immediately. If more than one thread is suspended in wait() or + * waitpid() waiting termination of the same process, exactly one thread + * will return the process status at the time of the target process + * termination + * + * The idtype and id arguments are used to specify which children waitid() + * will wait for. + * + * If idtype is P_PID, waitid() will wait for the child with a process + * ID equal to (pid_t)id. + * + * If idtype is P_PGID, waitid() will wait for any child with a process + * group ID equal to (pid_t)id. + * + * If idtype is P_ALL, waitid() will wait for any children and id is + * ignored. + * + * The options argument is used to specify which state changes waitid() + * will will wait for. It is formed by OR-ing together one or more of the + * following flags: + * + * WEXITED - Wait for processes that have exited. + * WSTOPPED - Status will be returned for any child that has stopped + * upon receipt of a signal. + * WCONTINUED - Status will be returned for any child that was stopped + * and has been continued. + * WNOHANG - Return immediately if there are no children to wait for. + * WNOWAIT - Keep the process whose status is returned in 'info' in a + * waitable state. This will not affect the state of the process; the + * process may be waited for again after this call completes. + * + * The 'info' argument must point to a siginfo_t structure. If waitid() + * returns because a child process was found that satisfied the conditions + * indicated by the arguments idtype and options, then the structure pointed + * to by 'info' will be filled in by the system with the status of the + * process. The si_signo member will always be equal to SIGCHLD. + * + * Input Parameters: + * See description. + * + * Returned Value: + * If waitid() returns due to the change of state of one of its children, + * 0 is returned. Otherwise, -1 is returned and errno is set to indicate + * the error. + * + * The waitid() function will fail if: + * + * ECHILD - The calling process has no existing unwaited-for child + * processes. + * EINTR - The waitid() function was interrupted by a signal. + * EINVAL - An invalid value was specified for options, or idtype and id + * specify an invalid set of processes. + * + *****************************************************************************/ + +int waitid(idtype_t idtype, id_t id, siginfo_t *info, int options) +{ + FAR _TCB *rtcb = (FAR _TCB *)g_readytorun.head; + sigset_t sigset; + int err; + int ret; + + /* MISSING LOGIC: If WNOHANG is provided in the options, then this function + * should returned immediately. However, there is no mechanism available now + * know if the thread has child: The children remember their parents (if + * CONFIG_SCHED_HAVE_PARENT) but the parents do not remember their children. + */ + + /* None of the options are supported except for WEXITED (which must be + * provided. Currently SIGCHILD always reports CLD_EXITED so we cannot + * distinguish any other events. + */ + +#ifdef CONFIG_DEBUG + if (options != WEXITED) + { + set_errno(ENOSYS); + return ERROR; + } +#endif + + /* Create a signal set that contains only SIGCHLD */ + + (void)sigemptyset(&sigset); + (void)sigaddset(&sigset, SIGCHLD); + + /* Disable pre-emption so that nothing changes while the loop executes */ + + sched_lock(); + + /* Verify that this task actually has children and that the the requeste + * TCB is actually a child of this task. + */ + + if (rtcb->nchildren == 0) + { + err = ECHILD; + goto errout_with_errno; + } + else if (idtype == P_PID) + { + /* Get the TCB corresponding to this PID and make sure it is our child. */ + + FAR _TCB *ctcb = sched_gettcb((pid_t)id); + if (!ctcb || ctcb->parent != rtcb->pid) + { + err = ECHILD; + goto errout_with_errno; + } + } + + /* Loop until the child that we are waiting for dies */ + + for (;;) + { + /* Check if the task has already died. Signals are not queued in + * NuttX. So a possibility is that the child has died and we + * missed the death of child signal (we got some other signal + * instead). + */ + + if (rtcb->nchildren == 0 || + (idtype == P_PID && (ret = kill((pid_t)id, 0)) < 0)) + { + /* We know that the child task was running okay we stared, + * so we must have lost the signal. What can we do? + * Let's claim we were interrupted by a signal. + */ + + err = EINTR; + goto errout_with_errno; + } + + /* Wait for any death-of-child signal */ + + ret = sigwaitinfo(&sigset, info); + if (ret < 0) + { + goto errout; + } + + /* Make there this was SIGCHLD */ + + if (info->si_signo == SIGCHLD) + { + /* Yes.. Are we waiting for the death of a specific child? */ + + if (idtype == P_PID) + { + /* Was this the death of the thread we were waiting for? */ + + if (info->si_pid == (pid_t)id) + { + /* Yes... return success */ + + break; + } + } + + /* Are we waiting for any child to change state? */ + + else if (idtype == P_ALL) + { + /* Return success */ + + break; + } + + /* Other ID types are not supported */ + + else /* if (idtype == P_PGID) */ + { + set_errno(ENOSYS); + goto errout; + } + } + } + + sched_unlock(); + return OK; + +errout_with_errno: + set_errno(err); +errout: + sched_unlock(); + return ERROR; +} + +#endif /* CONFIG_SCHED_WAITPID && CONFIG_SCHED_HAVE_PARENT*/ diff --git a/nuttx/sched/sched_waitpid.c b/nuttx/sched/sched_waitpid.c index 692ef6410..dc715b2e9 100644 --- a/nuttx/sched/sched_waitpid.c +++ b/nuttx/sched/sched_waitpid.c @@ -1,7 +1,7 @@ /***************************************************************************** * sched/sched_waitpid.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,13 +41,14 @@ #include #include +#include #include #include #include "os_internal.h" -#ifdef CONFIG_SCHED_WAITPID /* Experimental */ +#ifdef CONFIG_SCHED_WAITPID /***************************************************************************** * Private Functions @@ -58,7 +59,7 @@ *****************************************************************************/ /***************************************************************************** - * Name: sched_waitpid + * Name: waitpid * * Description: * @@ -172,10 +173,16 @@ * *****************************************************************************/ -/***************************************************************************/ -/* NOTE: This is a partially functional, experimental version of waitpid() */ -/***************************************************************************/ +/*************************************************************************** + * NOTE: This is a partially functional, experimental version of waitpid() + * + * If there is no SIGCHLD signal supported (CONFIG_SCHED_HAVE_PARENT not + * defined), then waitpid() is still available, but does not obey the + * restriction that the pid be a child of the caller. + * + ***************************************************************************/ +#ifndef CONFIG_SCHED_HAVE_PARENT pid_t waitpid(pid_t pid, int *stat_loc, int options) { _TCB *tcb; @@ -183,9 +190,24 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) int err; int ret; + DEBUGASSERT(stat_loc); + + /* None of the options are supported */ + +#ifdef CONFIG_DEBUG + if (options != 0) + { + set_errno(ENOSYS); + return ERROR; + } +#endif + /* Disable pre-emption so that nothing changes in the following tests */ sched_lock(); + + /* Get the TCB corresponding to this PID */ + tcb = sched_gettcb(pid); if (!tcb) { @@ -193,16 +215,6 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) goto errout_with_errno; } - /* None of the options are supported */ - -#ifdef CONFIG_DEBUG - if (options != 0) - { - err = ENOSYS; - goto errout_with_errno; - } -#endif - /* "If more than one thread is suspended in waitpid() awaiting termination of * the same process, exactly one thread will return the process status at the * time of the target process termination." Hmmm.. what do we return to the @@ -245,4 +257,152 @@ errout: return ERROR; } +/*************************************************************************** + * + * If CONFIG_SCHED_HAVE_PARENT is defined, then waitpid will use the SIGHCLD + * signal. It can also handle the pid == (pid_t)-1 arguement. This is + * slightly more spec-compliant. + * + * But then I have to be concerned about the fact that NuttX does not queue + * signals. This means that a flurry of signals can cause signals to be + * lost (or to have the data in the struct siginfo to be overwritten by + * the next signal). + * + ***************************************************************************/ + +#else +pid_t waitpid(pid_t pid, int *stat_loc, int options) +{ + FAR _TCB *rtcb = (FAR _TCB *)g_readytorun.head; + FAR struct siginfo info; + sigset_t sigset; + int err; + int ret; + + DEBUGASSERT(stat_loc); + + /* None of the options are supported */ + +#ifdef CONFIG_DEBUG + if (options != 0) + { + set_errno(ENOSYS); + return ERROR; + } +#endif + + /* Create a signal set that contains only SIGCHLD */ + + (void)sigemptyset(&sigset); + (void)sigaddset(&sigset, SIGCHLD); + + /* Disable pre-emption so that nothing changes while the loop executes */ + + sched_lock(); + + /* Verify that this task actually has children and that the the requeste + * TCB is actually a child of this task. + */ + + if (rtcb->nchildren == 0) + { + err = ECHILD; + goto errout_with_errno; + } + else if (pid != (pid_t)-1) + { + /* Get the TCB corresponding to this PID and make sure it is our child. */ + + FAR _TCB *ctcb = sched_gettcb(pid); + if (!ctcb || ctcb->parent != rtcb->pid) + { + err = ECHILD; + goto errout_with_errno; + } + } + + /* Loop until the child that we are waiting for dies */ + + for (;;) + { + /* Check if the task has already died. Signals are not queued in + * NuttX. So a possibility is that the child has died and we + * missed the death of child signal (we got some other signal + * instead). + */ + + if (pid == (pid_t)-1) + { + /* We are waiting for any child, check if there are still + * chilren. + */ + + if (rtcb->nchildren == 0) + { + /* There were one or more children when we started so they + * must have exit'ed. There are just no bread crumbs left + * behind to tell us the PID(s) of the existed children. + * Reporting ECHLD is about all we can do in this case. + */ + + err = ECHILD; + goto errout_with_errno; + } + } + else + { + /* We are waiting for a specific PID. We can use kill() with + * signal number 0 to determine if that task is still alive. + */ + + ret = kill(pid, 0); + if (ret < 0) + { + /* It is no longer running. We know that the child task was + * running okay when we started, so we must have lost the + * signal. In this case, we know that the task exit'ed, but + * we do not know its exit status. It would be better to + * reported ECHILD that bogus status. + */ + + err = ECHILD; + goto errout_with_errno; + } + } + + /* Wait for any death-of-child signal */ + + ret = sigwaitinfo(&sigset, &info); + if (ret < 0) + { + goto errout_with_lock; + } + + /* Was this the death of the thread we were waiting for? In the of + * pid == (pid_t)-1, we are waiting for any child thread. + */ + + if (info.si_signo == SIGCHLD && + (pid == (pid_t)-1 || info.si_pid == pid)) + { + /* Yes... return the status and PID (in the event it was -1) */ + + *stat_loc = info.si_status; + pid = info.si_pid; + break; + } + } + + sched_unlock(); + return (int)pid; + +errout_with_errno: + set_errno(err); + +errout_with_lock: + sched_unlock(); + return ERROR; +} +#endif /* CONFIG_SCHED_HAVE_PARENT */ + #endif /* CONFIG_SCHED_WAITPID */ diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c index 9ce2e5899..1106f2885 100644 --- a/nuttx/sched/task_exithook.c +++ b/nuttx/sched/task_exithook.c @@ -217,6 +217,20 @@ static inline void task_sigchild(FAR _TCB *tcb, int status) return; } + /* Decrement the number of children from this parent */ + + DEBUGASSERT(ptcb->nchildren > 0); + ptcb->nchildren--; + + /* Set the parent to an impossible PID. We do this because under certain + * conditions, task_exithook() can be called multiple times. If this + * function is called again, sched_gettcb() will fail on the invalid + * parent PID above, nchildren will be decremented once and all will be + * well. + */ + + tcb->parent = INVALID_PROCESS_ID; + /* Create the siginfo structure. We don't actually know the cause. That * is a bug. Let's just say that the child task just exit-ted for now. */ @@ -246,7 +260,7 @@ static inline void task_sigchild(FAR _TCB *tcb, int status) * ****************************************************************************/ -#ifdef CONFIG_SCHED_WAITPID +#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT) static inline void task_exitwakeup(FAR _TCB *tcb, int status) { /* Wakeup any tasks waiting for this task to exit */ @@ -310,14 +324,14 @@ void task_exithook(FAR _TCB *tcb, int status) task_atexit(tcb); - /* Send SIGCHLD to the parent of the exiting task */ - - task_sigchild(tcb, status); - /* Call any registered on_exit function(s) */ task_onexit(tcb, status); + /* Send SIGCHLD to the parent of the exit-ing task */ + + task_sigchild(tcb, status); + /* Wakeup any tasks waiting for this task to exit */ task_exitwakeup(tcb, status); diff --git a/nuttx/sched/task_setup.c b/nuttx/sched/task_setup.c index c5dd8ca3a..92897f0ae 100644 --- a/nuttx/sched/task_setup.c +++ b/nuttx/sched/task_setup.c @@ -168,7 +168,10 @@ static int task_assignpid(FAR _TCB *tcb) static inline void task_saveparent(FAR _TCB *tcb) { FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + + DEBUGASSERT(rtcb->nchildren < UINT16_MAX); tcb->parent = rtcb->pid; + rtcb->nchildren++; } #else # define task_saveparent(tcb) -- cgit v1.2.3 From 930f9a13511a6d9bc2e44fadef42f6345d921667 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 14 Jan 2013 15:42:03 +0000 Subject: Add support for dup2'ing files. Infrastructure and ROMFS done. Still need FAT, BINFS, NXFFS, and NFS git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5516 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 1 + apps/builtin/binfs.c | 4 +- apps/examples/posix_spawn/spawn_main.c | 14 -- nuttx/ChangeLog | 11 ++ nuttx/TODO | 47 +++++-- nuttx/fs/fat/fs_fat32.c | 46 ++++--- nuttx/fs/fs_files.c | 18 +-- nuttx/fs/nfs/nfs_vfsops.c | 2 + nuttx/fs/nxffs/nxffs_initialize.c | 2 + nuttx/fs/romfs/fs_romfs.c | 245 +++++++++++++++++++++++---------- nuttx/fs/romfs/fs_romfs.h | 1 - nuttx/fs/romfs/fs_romfsutil.c | 12 +- nuttx/include/nuttx/fs/fs.h | 1 + nuttx/include/unistd.h | 2 +- nuttx/libc/spawn/lib_ps.c | 4 +- nuttx/libc/unistd/lib_execsymtab.c | 6 +- nuttx/libc/unistd/lib_execv.c | 4 +- 17 files changed, 269 insertions(+), 151 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 70381a79d..bf329a40d 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -466,3 +466,4 @@ death-of-child signals (SIGCHLD). * apps/examples/ostest/waitpid.c: Add a test for waitpid(), waitid(), and wait(). + * builtin/binfs.c: Add hooks for dup() method (not implemented). diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c index 501f0a4b9..4159c9663 100644 --- a/apps/builtin/binfs.c +++ b/apps/builtin/binfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/builtin/binfs.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -118,7 +118,9 @@ const struct mountpt_operations binfs_operations = NULL, /* write */ NULL, /* seek */ binfs_ioctl, /* ioctl */ + NULL, /* sync */ + NULL, /* dup */ binfs_opendir, /* opendir */ NULL, /* closedir */ diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c index 1506fe499..0ca5f9107 100644 --- a/apps/examples/posix_spawn/spawn_main.c +++ b/apps/examples/posix_spawn/spawn_main.c @@ -89,15 +89,6 @@ # error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file" #endif -/* The redirection test does not work. This is because it tries to redirect - * file as stdin. That won't work now because (1) the file descriptors must - * be dup'ed when the new task is created, and (2) there is no support in - * place for dup'ing file descriptors for anything other than sockets and - * character drivers. This is a bug! - */ - -#define FILE_DUP_BUG 1 - /* Describe the ROMFS file system */ #define SECTORSIZE 512 @@ -147,9 +138,7 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */ static const char delimiter[] = "****************************************************************************"; -#ifndef FILE_DUP_BUG static const char g_redirect[] = "redirect"; -#endif static const char g_hello[] = "hello"; static const char g_data[] = "testdata.txt"; @@ -375,8 +364,6 @@ int spawn_main(int argc, char *argv[]) * Case 2: Simple program with redirection of stdin to a file input *************************************************************************/ -#ifndef FILE_DUP_BUG - /* Output a seperated so that we can clearly discriminate the output of * this program from the others. */ @@ -463,7 +450,6 @@ int spawn_main(int argc, char *argv[]) posix_spawnattr_dump(&attr); mm_update(&g_mmstep, "after file_action/attr destruction"); -#endif /* Clean-up */ diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index e8d4f7309..cb0244e20 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3929,3 +3929,14 @@ need to. * sched/sched_waitid.c and sched_wait.c: Add support for waitid() and wait(). See issues with waitpid() above. + * include/nuttx/fs/fs.h and fs/fs_files.c: Add a dup() method to + the struct mountpt_operations. When dup'ing a file that resides + on a mounted volume, let the file system's dup() method do the + work. + * fs/romfs/fs_romfs.c: Implemented the dup() method for the ROMFS + file system. + * fs/fat/fs_fat32.c, fs/nxffs/nxffs_initialize, and + fs/nfs/nfs_vfsops.c: Add hooks for dup() method (not yet + implemented). + * fs/romfs: Remove the rf_open flag. It looks good, but actually + does nothing. diff --git a/nuttx/TODO b/nuttx/TODO index 88324c06b..28a9ce68b 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated January 11, 2013) +NuttX TODO List (Last updated January 13, 2013) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -8,7 +8,7 @@ nuttx/ (10) Task/Scheduler (sched/) (1) Memory Managment (mm/) - (2) Signals (sched/, arch/) + (3) Signals (sched/, arch/) (2) pthreads (sched/) (2) C++ Support (6) Binary loaders (binfmt/) @@ -99,13 +99,6 @@ o Task/Scheduler (sched/) someone gets motivated and drives the change. Priority: Low - Title: posix_spawn() - Description: This would be a good interface to add to NuttX. It is really - just a re-packaging of the existing, non-standard NuttX exec() - function. - Status: Open. There are no plans to implement this capabilitiey now. - Priority: Medium low. - Title: pause() NON-COMPLIANCE Description: In the POSIX description of this function is the pause() function will suspend the calling thread until delivery of a signal whose @@ -178,6 +171,30 @@ o Task/Scheduler (sched/) Status: Open Priority: Medium Low for now + Title: RETAINING TASK EXIT STATUS + Description: When a task exists, its exit status should be retained in + so data structure until it is reaped (via waitpid(), or + similar interface) or until the parent thread exists. + + You would think that this should be a clone of the existing + pthread join logic. Howver there is no need for zombies + in NuttX so, the status if the parent has already exit'ed. + + At present, exit status is not retained. If waitpid() + is called after the child task has exit'ed it simpley + returns with the ECHLD error. That is not too bad, but + does not tell you what the exit status was. + + A work-around is to: + 1) Call sched_lock() to disable pre-emption. + 2) Start the task (it cannot run because pre-emption is + disbled. + 3) Call waitpid(); + 4) Call sched_unlock() to re-enable pre-emption. + + Status: Open + Priority: Low + o Memory Managment (mm/) ^^^^^^^^^^^^^^^^^^^^^^ @@ -249,7 +266,9 @@ o Signals (sched/, arch/) Title: STANDARD SIGNALS Description: 'Standard' signals and signal actions are not supported. - (e.g., SIGINT, SIGCHLD, SIGSEGV, etc). + (e.g., SIGINT, SIGSEGV, etc). + + Update: SIG_CHLD is support if configured. Status: Open. No changes are planned. Priority: Low, required by standards but not so critical for an embedded system. @@ -262,6 +281,14 @@ o Signals (sched/, arch/) are required by the POSIX standard. Priority: Low for now + Title: SIGNAL NUMBERING + Description: In signal.h, the range of valid signals is listed as 0-31. However, + in many interfaces, 0 is not a valid signal number. The valid + signal number should be 1-32. The signal set operations would need + to map bits appropriately. + Status: Open + Priority: Low. Even if there are only 31 usable signals, that is still a lot. + o pthreads (sched/) ^^^^^^^^^^^^^^^^^ diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 0c28cea67..788e6bebc 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -121,28 +121,30 @@ static int fat_stat(struct inode *mountpt, const char *relpath, struct stat const struct mountpt_operations fat_operations = { - fat_open, - fat_close, - fat_read, - fat_write, - fat_seek, - fat_ioctl, - fat_sync, - - fat_opendir, - NULL, - fat_readdir, - fat_rewinddir, - - fat_bind, - fat_unbind, - fat_statfs, - - fat_unlink, - fat_mkdir, - fat_rmdir, - fat_rename, - fat_stat + fat_open, /* open */ + fat_close, /* close */ + fat_read, /* read */ + fat_write, /* write */ + fat_seek, /* seek */ + fat_ioctl, /* ioctl */ + + fat_sync, /* sync */ + NULL, /* dup */ + + fat_opendir, /* opendir */ + NULL, /* closedir */ + fat_readdir, /* readdir */ + fat_rewinddir, /* rewinddir */ + + fat_bind, /* bind */ + fat_unbind, /* unbind */ + fat_statfs, /* statfs */ + + fat_unlink, /* unlinke */ + fat_mkdir, /* mkdir */ + fat_rmdir, /* rmdir */ + fat_rename, /* rename */ + fat_stat /* stat */ }; /**************************************************************************** diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c index 4da2d28a5..06addb1ef 100644 --- a/nuttx/fs/fs_files.c +++ b/nuttx/fs/fs_files.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_files.c * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -284,14 +284,6 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2) goto errout; } -#ifndef CONFIG_DISABLE_MOUNTPOINT - if (INODE_IS_MOUNTPT(filep1->f_inode)) - { - err = ENOSYS; /* Not yet supported */ - goto errout; - } -#endif - list = sched_getfiles(); if (!list) { @@ -331,18 +323,16 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2) if (inode->u.i_ops && inode->u.i_ops->open) { #ifndef CONFIG_DISABLE_MOUNTPOINT -#if 0 /* Not implemented */ if (INODE_IS_MOUNTPT(inode)) { - /* Open a file on the mountpoint */ + /* Dup the open file on the in the new file structure */ - ret = inode->u.i_mops->open(filep2, ?, filep2->f_oflags, ?); + ret = inode->u.i_mops->dup(filep1, filep2); } else -#endif #endif { - /* Open the pseudo file or device driver */ + /* (Re-)open the pseudo file or device driver */ ret = inode->u.i_ops->open(filep2); } diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c index 3cd5a47dc..efb026c7f 100644 --- a/nuttx/fs/nfs/nfs_vfsops.c +++ b/nuttx/fs/nfs/nfs_vfsops.c @@ -166,7 +166,9 @@ const struct mountpt_operations nfs_operations = nfs_write, /* write */ NULL, /* seek */ NULL, /* ioctl */ + NULL, /* sync */ + NULL, /* dup */ nfs_opendir, /* opendir */ NULL, /* closedir */ diff --git a/nuttx/fs/nxffs/nxffs_initialize.c b/nuttx/fs/nxffs/nxffs_initialize.c index 6d93a318a..0aa424869 100644 --- a/nuttx/fs/nxffs/nxffs_initialize.c +++ b/nuttx/fs/nxffs/nxffs_initialize.c @@ -82,7 +82,9 @@ const struct mountpt_operations nxffs_operations = nxffs_write, /* write */ NULL, /* seek -- Use f_pos in struct file */ nxffs_ioctl, /* ioctl */ + NULL, /* sync -- No buffered data */ + NULL, /* dup -- not implemented */ nxffs_opendir, /* opendir */ NULL, /* closedir */ diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c index b95619d75..de87c7fec 100644 --- a/nuttx/fs/romfs/fs_romfs.c +++ b/nuttx/fs/romfs/fs_romfs.c @@ -70,24 +70,33 @@ * Private Function Prototypes ****************************************************************************/ -static int romfs_open(FAR struct file *filep, const char *relpath, +static int romfs_open(FAR struct file *filep, FAR const char *relpath, int oflags, mode_t mode); static int romfs_close(FAR struct file *filep); -static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen); +static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence); -static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static int romfs_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); -static int romfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir); -static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); -static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir); +static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp); -static int romfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle); -static int romfs_unbind(void *handle, FAR struct inode **blkdriver); -static int romfs_statfs(struct inode *mountpt, struct statfs *buf); +static int romfs_opendir(FAR struct inode *mountpt, + FAR const char *relpath, + FAR struct fs_dirent_s *dir); +static int romfs_readdir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); +static int romfs_rewinddir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); -static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf); +static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle); +static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver); +static int romfs_statfs(FAR struct inode *mountpt, + FAR struct statfs *buf); + +static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf); /**************************************************************************** * Private Variables @@ -110,7 +119,9 @@ const struct mountpt_operations romfs_operations = NULL, /* write */ romfs_seek, /* seek */ romfs_ioctl, /* ioctl */ + NULL, /* sync */ + romfs_dup, /* dup */ romfs_opendir, /* opendir */ NULL, /* closedir */ @@ -136,13 +147,13 @@ const struct mountpt_operations romfs_operations = * Name: romfs_open ****************************************************************************/ -static int romfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode) +static int romfs_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode) { - struct romfs_dirinfo_s dirinfo; - struct romfs_mountpt_s *rm; - struct romfs_file_s *rf; - int ret; + struct romfs_dirinfo_s dirinfo; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *rf; + int ret; fvdbg("Open '%s'\n", relpath); @@ -150,11 +161,11 @@ static int romfs_open(FAR struct file *filep, const char *relpath, DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL); - /* mountpoint private data from the inode reference from the file + /* Get mountpoint private data from the inode reference from the file * structure */ - rm = (struct romfs_mountpt_s*)filep->f_inode->i_private; + rm = (FAR struct romfs_mountpt_s*)filep->f_inode->i_private; DEBUGASSERT(rm != NULL); @@ -214,7 +225,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath, * file. */ - rf = (struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s)); + rf = (FAR struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s)); if (!rf) { fdbg("Failed to allocate private data\n", ret); @@ -226,8 +237,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath, * non-zero elements) */ - rf->rf_open = true; - rf->rf_size = dirinfo.rd_size; + rf->rf_size = dirinfo.rd_size; /* Get the start of the file data */ @@ -277,9 +287,9 @@ errout_with_semaphore: static int romfs_close(FAR struct file *filep) { - struct romfs_mountpt_s *rm; - struct romfs_file_s *rf; - int ret = OK; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *rf; + int ret = OK; fvdbg("Closing\n"); @@ -321,19 +331,20 @@ static int romfs_close(FAR struct file *filep) * Name: romfs_read ****************************************************************************/ -static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen) +static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) { - struct romfs_mountpt_s *rm; - struct romfs_file_s *rf; - unsigned int bytesread; - unsigned int readsize; - unsigned int nsectors; - uint32_t offset; - size_t bytesleft; - off_t sector; - uint8_t *userbuffer = (uint8_t*)buffer; - int sectorndx; - int ret; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *rf; + unsigned int bytesread; + unsigned int readsize; + unsigned int nsectors; + uint32_t offset; + size_t bytesleft; + off_t sector; + FAR uint8_t *userbuffer = (FAR uint8_t*)buffer; + int sectorndx; + int ret; fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); @@ -467,10 +478,10 @@ errout_with_semaphore: static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence) { - struct romfs_mountpt_s *rm; - struct romfs_file_s *rf; - off_t position; - int ret; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *rf; + off_t position; + int ret; fvdbg("Seek to offset: %d whence: %d\n", offset, whence); @@ -548,9 +559,9 @@ errout_with_semaphore: static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { - struct romfs_mountpt_s *rm; - struct romfs_file_s *rf; - FAR void **ppv = (FAR void**)arg; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *rf; + FAR void **ppv = (FAR void**)arg; fvdbg("cmd: %d arg: %08lx\n", cmd, arg); @@ -581,6 +592,95 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) return -ENOTTY; } +/**************************************************************************** + * Name: romfs_dup + ****************************************************************************/ + +static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_file_s *oldrf; + FAR struct romfs_file_s *newrf; + int ret; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + + DEBUGASSERT(oldp->f_priv != NULL && + newp->f_priv == NULL && + newp->f_inode != NULL); + + /* Get mountpoint private data from the inode reference from the file + * structure + */ + + rm = (FAR struct romfs_mountpt_s*)newp->f_inode->i_private; + DEBUGASSERT(rm != NULL); + + /* Check if the mount is still healthy */ + + romfs_semtake(rm); + ret = romfs_checkmount(rm); + if (ret != OK) + { + fdbg("romfs_checkmount failed: %d\n", ret); + goto errout_with_semaphore; + } + + /* Recover the old private data from the old struct file instance */ + + oldrf = oldp->f_priv; + + /* Create an new instance of the file private data to describe the new + * dup'ed file. + */ + + newrf = (FAR struct romfs_file_s *)malloc(sizeof(struct romfs_file_s)); + if (!newrf) + { + fdbg("Failed to allocate private data\n", ret); + ret = -ENOMEM; + goto errout_with_semaphore; + } + + /* Copy all file private data (except for the buffer) */ + + newrf->rf_startoffset = oldrf->rf_startoffset; + newrf->rf_size = oldrf->rf_size; + + /* Configure buffering to support access to this file */ + + ret = romfs_fileconfigure(rm, newrf); + if (ret < 0) + { + fdbg("Failed configure buffering: %d\n", ret); + goto errout_with_semaphore; + } + + /* Attach the new private date to the new struct file instance */ + + newp->f_priv = newrf; + + /* Then insert the new instance into the mountpoint structure. + * It needs to be there (1) to handle error conditions that effect + * all files, and (2) to inform the umount logic that we are busy + * (but a simple reference count could have done that). + */ + + newrf->rf_next = rm->rm_head; + rm->rm_head = newrf->rf_next; + + romfs_semgive(rm); + return OK; + + /* Error exits */ + +errout_with_semaphore: + romfs_semgive(rm); + return ret; +} + /**************************************************************************** * Name: romfs_opendir * @@ -589,12 +689,12 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * ****************************************************************************/ -static int romfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir) +static int romfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct fs_dirent_s *dir) { - struct romfs_mountpt_s *rm; - struct romfs_dirinfo_s dirinfo; - int ret; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_dirinfo_s dirinfo; + int ret; fvdbg("relpath: '%s'\n", relpath); @@ -654,14 +754,15 @@ errout_with_semaphore: * ****************************************************************************/ -static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) +static int romfs_readdir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir) { - struct romfs_mountpt_s *rm; - uint32_t linkoffset; - uint32_t next; - uint32_t info; - uint32_t size; - int ret; + FAR struct romfs_mountpt_s *rm; + uint32_t linkoffset; + uint32_t next; + uint32_t info; + uint32_t size; + int ret; fvdbg("Entry\n"); @@ -749,9 +850,10 @@ errout_with_semaphore: * ****************************************************************************/ -static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) +static int romfs_rewinddir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir) { - struct romfs_mountpt_s *rm; + FAR struct romfs_mountpt_s *rm; int ret; fvdbg("Entry\n"); @@ -788,8 +890,8 @@ static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) * ****************************************************************************/ -static int romfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle) +static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle) { struct romfs_mountpt_s *rm; int ret; @@ -813,7 +915,7 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data, /* Create an instance of the mountpt state structure */ - rm = (struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s)); + rm = (FAR struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s)); if (!rm) { fdbg("Failed to allocate mountpoint structure\n"); @@ -874,9 +976,9 @@ errout_with_sem: * ****************************************************************************/ -static int romfs_unbind(void *handle, FAR struct inode **blkdriver) +static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver) { - struct romfs_mountpt_s *rm = (struct romfs_mountpt_s*)handle; + FAR struct romfs_mountpt_s *rm = (FAR struct romfs_mountpt_s*)handle; int ret; fvdbg("Entry\n"); @@ -948,10 +1050,10 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver) * ****************************************************************************/ -static int romfs_statfs(struct inode *mountpt, struct statfs *buf) +static int romfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) { - struct romfs_mountpt_s *rm; - int ret; + FAR struct romfs_mountpt_s *rm; + int ret; fvdbg("Entry\n"); @@ -1004,11 +1106,12 @@ errout_with_semaphore: * ****************************************************************************/ -static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) +static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf) { - struct romfs_mountpt_s *rm; - struct romfs_dirinfo_s dirinfo; - int ret; + FAR struct romfs_mountpt_s *rm; + FAR struct romfs_dirinfo_s dirinfo; + int ret; fvdbg("Entry\n"); diff --git a/nuttx/fs/romfs/fs_romfs.h b/nuttx/fs/romfs/fs_romfs.h index 4081517fb..6a337d2c5 100644 --- a/nuttx/fs/romfs/fs_romfs.h +++ b/nuttx/fs/romfs/fs_romfs.h @@ -159,7 +159,6 @@ struct romfs_mountpt_s struct romfs_file_s { struct romfs_file_s *rf_next; /* Retained in a singly linked list */ - bool rf_open; /* true: The file is (still) open */ uint32_t rf_startoffset; /* Offset to the start of the file data */ uint32_t rf_size; /* Size of the file in bytes */ uint32_t rf_cachesector; /* Current sector in the rf_buffer */ diff --git a/nuttx/fs/romfs/fs_romfsutil.c b/nuttx/fs/romfs/fs_romfsutil.c index 6ea114b5e..4857fb6d3 100644 --- a/nuttx/fs/romfs/fs_romfsutil.c +++ b/nuttx/fs/romfs/fs_romfsutil.c @@ -613,7 +613,7 @@ int romfs_fsconfigure(struct romfs_mountpt_s *rm) } /**************************************************************************** - * Name: romfs_ffileconfigure + * Name: romfs_fileconfigure * * Desciption: * This function is called as part of the ROMFS file open operation It @@ -649,6 +649,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf) return -ENOMEM; } } + return OK; } @@ -663,7 +664,6 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf) int romfs_checkmount(struct romfs_mountpt_s *rm) { - struct romfs_file_s *file; struct inode *inode; struct geometry geo; int ret; @@ -692,14 +692,8 @@ int romfs_checkmount(struct romfs_mountpt_s *rm) /* If we get here, the mount is NOT healthy */ rm->rm_mounted = false; - - /* Make sure that this is flagged in every opened file */ - - for (file = rm->rm_head; file; file = file->rf_next) - { - file->rf_open = false; - } } + return -ENODEV; } diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index 1759310bc..3138a8412 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -161,6 +161,7 @@ struct mountpt_operations */ int (*sync)(FAR struct file *filp); + int (*dup)(FAR const struct file *oldp, FAR struct file *newp); /* Directory operations */ diff --git a/nuttx/include/unistd.h b/nuttx/include/unistd.h index c5289624b..46eb14cdd 100644 --- a/nuttx/include/unistd.h +++ b/nuttx/include/unistd.h @@ -169,7 +169,7 @@ EXTERN int execv(FAR const char *path, FAR char *const argv[]); /* Non-standard functions to manage symbol tables */ struct symtab_s; /* See include/nuttx/binfmt/symtab.h */ -EXTERN void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols); +EXTERN void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols); EXTERN void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols); #endif diff --git a/nuttx/libc/spawn/lib_ps.c b/nuttx/libc/spawn/lib_ps.c index dfe57089e..638b27f87 100644 --- a/nuttx/libc/spawn/lib_ps.c +++ b/nuttx/libc/spawn/lib_ps.c @@ -70,8 +70,6 @@ struct spawn_parms_s * Public Data ****************************************************************************/ -extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB; - /**************************************************************************** * Private Data ****************************************************************************/ @@ -157,7 +155,7 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path, FAR char *const argv[]) { struct sched_param param; - FAR struct symtab_s *symtab; + FAR const struct symtab_s *symtab; int nsymbols; int pid; int ret = OK; diff --git a/nuttx/libc/unistd/lib_execsymtab.c b/nuttx/libc/unistd/lib_execsymtab.c index 7abb2d74e..34b798bb4 100644 --- a/nuttx/libc/unistd/lib_execsymtab.c +++ b/nuttx/libc/unistd/lib_execsymtab.c @@ -69,13 +69,13 @@ * Public Variables ****************************************************************************/ -extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB; +extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB; /**************************************************************************** * Private Data ****************************************************************************/ -static FAR struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB; +static FAR const struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB; static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS; /**************************************************************************** @@ -97,7 +97,7 @@ static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS; * ****************************************************************************/ -void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols) +void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols) { irqstate_t flags; diff --git a/nuttx/libc/unistd/lib_execv.c b/nuttx/libc/unistd/lib_execv.c index e35138be5..48b089913 100644 --- a/nuttx/libc/unistd/lib_execv.c +++ b/nuttx/libc/unistd/lib_execv.c @@ -119,7 +119,7 @@ int execv(FAR const char *path, FAR char *const argv[]) { - FAR struct symtab_s *symtab; + FAR const struct symtab_s *symtab; int nsymbols; int ret; @@ -148,4 +148,4 @@ int execv(FAR const char *path, FAR char *const argv[]) return ERROR; } -#endif /* CONFIG_LIBC_EXECFUNCS */ \ No newline at end of file +#endif /* CONFIG_LIBC_EXECFUNCS */ -- cgit v1.2.3 From cc3614dfe8f67033dca8c7c1f40c3367a0d3ca06 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 14 Jan 2013 19:22:32 +0000 Subject: Finish dup logic for open files; fix bug in sigtimedwait(), would return wrong signo value if the signal was already pending git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5517 42af7a65-404d-4744-a932-0658087f49c3 --- apps/builtin/Kconfig | 15 +++++ apps/builtin/binfs.c | 37 ++++++++++- nuttx/ChangeLog | 9 +++ nuttx/TODO | 24 +------- nuttx/fs/fat/fs_fat32.c | 126 +++++++++++++++++++++++++++++++++++++- nuttx/fs/fat/fs_fat32.h | 1 - nuttx/fs/fat/fs_fat32util.c | 10 +-- nuttx/fs/nfs/nfs_node.h | 3 +- nuttx/fs/nfs/nfs_util.c | 9 +-- nuttx/fs/nfs/nfs_vfsops.c | 106 ++++++++++++++++++++++++++++---- nuttx/fs/nfs/rpc_clnt.c | 28 ++++----- nuttx/fs/nxffs/nxffs.h | 41 +++++++------ nuttx/fs/nxffs/nxffs_initialize.c | 4 +- nuttx/fs/nxffs/nxffs_open.c | 62 ++++++++++++++++++- nuttx/fs/romfs/fs_romfs.c | 2 +- nuttx/include/nuttx/fs/fs.h | 2 +- nuttx/sched/mq_initialize.c | 4 +- nuttx/sched/sig_timedwait.c | 2 +- nuttx/sched/task_vfork.c | 2 +- 19 files changed, 384 insertions(+), 103 deletions(-) (limited to 'apps') diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig index 8310e6df9..5b262734d 100644 --- a/apps/builtin/Kconfig +++ b/apps/builtin/Kconfig @@ -12,4 +12,19 @@ config BUILTIN to support built-in applications in the NuttShell (NSH). if BUILTIN + + config APPS_BINDIR + bool "BINFS File System" + default n + ---help--- + The BINFS file system is current just a toy. The BINFS may, for example, + be mount at /bin. Then all of the built-in applications will appear as + executable file in /bin if you list them from NSH like: + + nsh> ls -l /bin + + At present, the BINFS supports nothing more than that. It is planned, + however, to support execution of the builtin applications from BINFS as + well (via a binfmt/ loader). However, that is down the road. + endif diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c index 4159c9663..365021c7f 100644 --- a/apps/builtin/binfs.c +++ b/apps/builtin/binfs.c @@ -85,6 +85,8 @@ static int binfs_close(FAR struct file *filep); static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp); + static int binfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir); static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); @@ -120,7 +122,7 @@ const struct mountpt_operations binfs_operations = binfs_ioctl, /* ioctl */ NULL, /* sync */ - NULL, /* dup */ + binfs_dup, /* dup */ binfs_opendir, /* opendir */ NULL, /* closedir */ @@ -296,6 +298,39 @@ static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) return -ENOTTY; } +/**************************************************************************** + * Name: binfs_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + struct binfs_state_s *bm; + int ret = -ENOSYS; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + + DEBUGASSERT(oldp->f_priv == NULL && oldp->f_inode != NULL); + + /* mountpoint private data from the inode reference from the file + * structure + */ + + bm = (struct binfs_state_s*)oldp->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* Opening of elements within the pseudo-file system is not yet supported + * and, hence, neither is dup'ing the opened file. + */ + + return ret; +} + /**************************************************************************** * Name: binfs_opendir * diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index cb0244e20..4ba0fe985 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3940,3 +3940,12 @@ implemented). * fs/romfs: Remove the rf_open flag. It looks good, but actually does nothing. + * fs/fat: Remove the ff_open flag. Same story as for the ROMFS + rf_open flag. + * fs/fat/fs_fat32.c, fs/nxffs/nxffs_initialize, and + fs/nfs/nfs_vfsops.c: Completed implementation of the dup() methods. + There is still no good test available. + * sched/sig_timedwait.c: sigtimedwait() would return a bad signal + number if the signal was already pending when the function was + called. + called. diff --git a/nuttx/TODO b/nuttx/TODO index 28a9ce68b..0d02e10e6 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated January 13, 2013) +NuttX TODO List (Last updated January 14, 2013) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -15,7 +15,7 @@ nuttx/ (17) Network (net/, drivers/net) (4) USB (drivers/usbdev, drivers/usbhost) (12) Libraries (libc/, ) - (10) File system/Generic drivers (fs/, drivers/) + (9) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) (1) Documentation (Documentation/) @@ -879,26 +879,6 @@ o File system / Generic drivers (fs/, drivers/) Status: Open Priority: Medium - Title: dup AND dup2 WILL NOT WORK ON FILES IN A MOUNTED VOLUME - Description: The current implementation of dup() and dup2() will only - work with open device drivers and sockets. It will not - work with open files in a file system. Support for dup'ing - open files on a mounted volume has not been implemented yet. - - There is a stubbed out, partial implemenation in fs/fs_files.c. - In would perform the dup2() operation by re-opening the file - and setting the file pointer. The logic, however, would require - that we remember the (relative) path to the file in the mounted - volume for each open file. - - An option might to add a dup() method to the file system - mountpoint interface. - - A limitation that results from this is that you cannot - redirect I/O to an from and file. - Status: Open - Priority: High - o Graphics subystem (graphics/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 788e6bebc..7164a9f8f 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_fat32.c * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -86,7 +86,9 @@ static ssize_t fat_write(FAR struct file *filep, const char *buffer, size_t buflen); static off_t fat_seek(FAR struct file *filep, off_t offset, int whence); static int fat_ioctl(FAR struct file *filep, int cmd, unsigned long arg); + static int fat_sync(FAR struct file *filep); +static int fat_dup(FAR const struct file *oldp, FAR struct file *newp); static int fat_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir); @@ -129,7 +131,7 @@ const struct mountpt_operations fat_operations = fat_ioctl, /* ioctl */ fat_sync, /* sync */ - NULL, /* dup */ + fat_dup, /* dup */ fat_opendir, /* opendir */ NULL, /* closedir */ @@ -313,7 +315,6 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* Initialize the file private data (only need to initialize non-zero elements) */ - ff->ff_open = true; ff->ff_oflags = oflags; /* Save information that can be used later to recover the directory entry */ @@ -898,6 +899,7 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence) DEBUGASSERT(fs != NULL); /* Map the offset according to the whence option */ + switch (whence) { case SEEK_SET: /* The offset is set to offset bytes. */ @@ -971,6 +973,7 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence) ret = cluster; goto errout_with_semaphore; } + ff->ff_startcluster = cluster; } @@ -1232,6 +1235,123 @@ errout_with_semaphore: return ret; } +/**************************************************************************** + * Name: fat_dup + * + * Description: Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int fat_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + FAR struct fat_mountpt_s *fs; + FAR struct fat_file_s *oldff; + FAR struct fat_file_s *newff; + int ret; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + + DEBUGASSERT(oldp->f_priv != NULL && + newp->f_priv == NULL && + newp->f_inode != NULL); + + /* Recover our private data from the struct file instance */ + + fs = (struct fat_mountpt_s *)oldp->f_inode->i_private; + DEBUGASSERT(fs != NULL); + + /* Check if the mount is still healthy */ + + fat_semtake(fs); + ret = fat_checkmount(fs); + if (ret != OK) + { + goto errout_with_semaphore; + } + + /* Recover the old private data from the old struct file instance */ + + oldff = oldp->f_priv; + + /* Create a new instance of the file private date to describe the + * dup'ed file. + */ + + newff = (struct fat_file_s *)kmalloc(sizeof(struct fat_file_s)); + if (!newff) + { + ret = -ENOMEM; + goto errout_with_semaphore; + } + + /* Create a file buffer to support partial sector accesses */ + + newff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); + if (!newff->ff_buffer) + { + ret = -ENOMEM; + goto errout_with_struct; + } + + /* Copy the rest of the open open file state from the old file structure. + * There are some assumptions and potential issues here: + * + * 1) We assume that the higher level logic has copied the elements of + * the file structure, in particular, the file position. + * 2) There is a problem with ff_size if there are multiple opened + * file structures, each believing they know the size of the file. + * If one instance modifies the file length, then the new size of + * the opened file will be unknown to the other. That is a lurking + * bug! + * + * One good solution to this might be to add a refernce count to the + * file structure. Then, instead of dup'ing the whole structure + * as is done here, just increment the reference count on the + * structure. The would have to be integrated with open logic as + * well, however, so that the same file structure is re-used if the + * file is re-opened. + */ + + newff->ff_bflags = 0; + newff->ff_oflags = oldff->ff_oflags; + newff->ff_sectorsincluster = oldff->ff_sectorsincluster; + newff->ff_dirindex = oldff->ff_dirindex; + newff->ff_currentcluster = oldff->ff_currentcluster; + newff->ff_dirsector = oldff->ff_dirsector; + newff->ff_size = oldff->ff_size; + newff->ff_currentsector = 0; + newff->ff_cachesector = 0; + + /* Attach the private date to the struct file instance */ + + newp->f_priv = newff; + + /* Then insert the new instance into the mountpoint structure. + * It needs to be there (1) to handle error conditions that effect + * all files, and (2) to inform the umount logic that we are busy + * (but a simple reference count could have done that). + */ + + newff->ff_next = fs->fs_head; + fs->fs_head = newff->ff_next; + + fat_semgive(fs); + return OK; + + /* Error exits -- goto's are nasty things, but they sure can make error + * handling a lot simpler. + */ + +errout_with_struct: + kfree(newff); + +errout_with_semaphore: + fat_semgive(fs); + return ret; +} + /**************************************************************************** * Name: fat_opendir * diff --git a/nuttx/fs/fat/fs_fat32.h b/nuttx/fs/fat/fs_fat32.h index 71a21333b..81f3f4675 100644 --- a/nuttx/fs/fat/fs_fat32.h +++ b/nuttx/fs/fat/fs_fat32.h @@ -752,7 +752,6 @@ struct fat_mountpt_s struct fat_file_s { struct fat_file_s *ff_next; /* Retained in a singly linked list */ - bool ff_open; /* true: The file is (still) open */ uint8_t ff_bflags; /* The file buffer flags */ uint8_t ff_oflags; /* Flags provided when file was opened */ uint8_t ff_sectorsincluster; /* Sectors remaining in cluster */ diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 7231456d7..9aa1d3992 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -692,8 +692,6 @@ int fat_checkmount(struct fat_mountpt_s *fs) if (fs && fs->fs_mounted) { - struct fat_file_s *file; - /* We still think the mount is healthy. Check an see if this is * still the case */ @@ -715,14 +713,8 @@ int fat_checkmount(struct fat_mountpt_s *fs) /* If we get here, the mount is NOT healthy */ fs->fs_mounted = false; - - /* Make sure that this is flagged in every opened file */ - - for (file = fs->fs_head; file; file = file->ff_next) - { - file->ff_open = false; - } } + return -ENODEV; } diff --git a/nuttx/fs/nfs/nfs_node.h b/nuttx/fs/nfs/nfs_node.h index 4ae9e162c..408bd1993 100644 --- a/nuttx/fs/nfs/nfs_node.h +++ b/nuttx/fs/nfs/nfs_node.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nfs/nfs_node.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved. * Author: Jose Pablo Rojas Vargas * Gregory Nutt @@ -70,6 +70,7 @@ struct nfsnode { struct nfsnode *n_next; /* Retained in a singly linked list. */ + uint8_t n_crefs; /* Reference count (for nfs_dup) */ uint8_t n_type; /* File type */ uint8_t n_fhsize; /* Size in bytes of the file handle */ uint8_t n_flags; /* Node flags */ diff --git a/nuttx/fs/nfs/nfs_util.c b/nuttx/fs/nfs/nfs_util.c index 73fda72a7..e7d28b3d7 100644 --- a/nuttx/fs/nfs/nfs_util.c +++ b/nuttx/fs/nfs/nfs_util.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nfs/nfs_util.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -213,7 +213,6 @@ int nfs_request(struct nfsmount *nmp, int procnum, { struct rpcclnt *clnt = nmp->nm_rpcclnt; struct nfs_reply_header replyh; - int trylater_delay; int error; tryagain: @@ -250,12 +249,6 @@ tryagain: if (error == EAGAIN) { error = 0; - trylater_delay *= NFS_TIMEOUTMUL; - if (trylater_delay > NFS_MAXTIMEO) - { - trylater_delay = NFS_MAXTIMEO; - } - goto tryagain; } diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c index efb026c7f..01e999ac8 100644 --- a/nuttx/fs/nfs/nfs_vfsops.c +++ b/nuttx/fs/nfs/nfs_vfsops.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nfs/nfs_vfsops.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved. * Author: Jose Pablo Rojas Vargas * Gregory Nutt @@ -133,6 +133,7 @@ static int nfs_close(FAR struct file *filep); static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen); static ssize_t nfs_write(FAR struct file *filep, const char *buffer, size_t buflen); +static int nfs_dup(FAR const struct file *oldp, FAR struct file *newp); static int nfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir); static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); @@ -168,7 +169,7 @@ const struct mountpt_operations nfs_operations = NULL, /* ioctl */ NULL, /* sync */ - NULL, /* dup */ + nfs_dup, /* dup */ nfs_opendir, /* opendir */ NULL, /* closedir */ @@ -359,7 +360,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np, /* Save the attributes in the file data structure */ - tmp = *ptr++; /* handle_follows */ + tmp = *ptr; /* handle_follows */ if (!tmp) { fdbg("WARNING: no file attributes\n"); @@ -369,7 +370,6 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np, /* Initialize the file attributes */ nfs_attrupdate(np, (FAR struct nfs_fattr *)ptr); - ptr += uint32_increment(sizeof(struct nfs_fattr)); } /* Any following dir_wcc data is ignored for now */ @@ -412,7 +412,7 @@ static int nfs_filetruncate(FAR struct nfsmount *nmp, struct nfsnode *np) reqlen += (int)np->n_fhsize; ptr += uint32_increment(np->n_fhsize); - /* Copy the variable-length attribtes */ + /* Copy the variable-length attributes */ *ptr++ = nfs_false; /* Don't change mode */ *ptr++ = nfs_false; /* Don't change uid */ @@ -423,7 +423,7 @@ static int nfs_filetruncate(FAR struct nfsmount *nmp, struct nfsnode *np) *ptr++ = HTONL(NFSV3SATTRTIME_TOSERVER); /* Use the server's time */ *ptr++ = HTONL(NFSV3SATTRTIME_TOSERVER); /* Use the server's time */ *ptr++ = nfs_false; /* No guard value */ - reqlen += 9*sizeof(uint32_t) + reqlen += 9 * sizeof(uint32_t); /* Perform the SETATTR RPC */ @@ -553,9 +553,9 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, struct nfsnode *np, static int nfs_open(FAR struct file *filep, FAR const char *relpath, int oflags, mode_t mode) { - struct nfsmount *nmp; - struct nfsnode *np = NULL; - int error; + struct nfsmount *nmp; + struct nfsnode *np; + int error; /* Sanity checks */ @@ -634,6 +634,8 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath, * non-zero elements) */ + np->n_crefs = 1; + /* Attach the private data to the struct file instance */ filep->f_priv = np; @@ -656,6 +658,7 @@ errout_with_semaphore: { kfree(np); } + nfs_semgive(nmp); return -error; } @@ -693,8 +696,22 @@ static int nfs_close(FAR struct file *filep) nfs_semtake(nmp); - /* Find our file structure in the list of file structures containted in the - * mount structure. + /* Decrement the reference count. If the reference count would not + * decrement to zero, then that is all we have to do. + */ + + if (np->n_crefs > 1) + { + np->n_crefs--; + nfs_semgive(nmp); + return OK; + } + + /* There are no more references to the file structure. Now we need to + * free up all resources associated with the open file. + * + * First, find our file structure in the list of file structures + * containted in the mount structure. */ for (prev = NULL, curr = nmp->nm_head; curr; prev = curr, curr = curr->n_next) @@ -759,8 +776,8 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen) /* Recover our private data from the struct file instance */ - nmp = (struct nfsmount*) filep->f_inode->i_private; - np = (struct nfsnode*) filep->f_priv; + nmp = (struct nfsmount*)filep->f_inode->i_private; + np = (struct nfsnode*)filep->f_priv; DEBUGASSERT(nmp != NULL); @@ -1093,6 +1110,66 @@ errout_with_semaphore: return -error; } +/**************************************************************************** + * Name: binfs_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int nfs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + struct nfsmount *nmp; + FAR struct nfsnode *np; + int error; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + + DEBUGASSERT(oldp->f_priv != NULL && oldp->f_inode != NULL); + + /* Recover our private data from the struct file instance */ + + nmp = (struct nfsmount*)oldp->f_inode->i_private; + np = (struct nfsnode*)oldp->f_priv; + + DEBUGASSERT(nmp != NULL); + + /* Check if the mount is still healthy */ + + nfs_semtake(nmp); + error = nfs_checkmount(nmp); + if (error != OK) + { + fdbg("ERROR: nfs_checkmount failed: %d\n", error); + nfs_semgive(nmp); + return -error; + } + + /* Increment the reference count on the NFS node structure */ + + DEBUGASSERT(np->n_crefs < 0xff); + np->n_crefs++; + + /* And save this as the file data for the new node */ + + newp->f_priv = np; + + /* Then insert the new instance at the head of the list in the mountpoint + * tructure. It needs to be there (1) to handle error conditions that effect + * all files, and (2) to inform the umount logic that we are busy. We + * cannot unmount the file system if this list is not empty! + */ + + np->n_next = nmp->nm_head; + nmp->nm_head = np; + + nfs_semgive(nmp); + return OK; +} + /**************************************************************************** * Name: nfs_opendir * @@ -1756,12 +1833,15 @@ bad: { kfree(nmp->nm_so); } + if (nmp->nm_rpcclnt) { kfree(nmp->nm_rpcclnt); } + kfree(nmp); } + return error; } diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c index 0e2a394ba..9c2ada4f2 100644 --- a/nuttx/fs/nfs/rpc_clnt.c +++ b/nuttx/fs/nfs/rpc_clnt.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nfs/rpc_clnt.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved. * Author: Jose Pablo Rojas Vargas * Gregory Nutt @@ -224,8 +224,6 @@ static int rpcclnt_receive(FAR struct rpcclnt *rpc, FAR struct sockaddr *aname, static int rpcclnt_reply(FAR struct rpcclnt *rpc, int procid, int prog, FAR void *reply, size_t resplen) { - FAR struct rpc_reply_header *replyheader; - uint32_t rxid; int error; /* Get the next RPC reply from the socket */ @@ -235,22 +233,22 @@ static int rpcclnt_reply(FAR struct rpcclnt *rpc, int procid, int prog, { fdbg("ERROR: rpcclnt_receive returned: %d\n", error); - /* If we failed because of a timeout, then try sending the CALL - * message again. - */ + /* If we failed because of a timeout, then try sending the CALL + * message again. + */ - if (error == EAGAIN || error == ETIMEDOUT) - { - rpc->rc_timeout = true; - } - } + if (error == EAGAIN || error == ETIMEDOUT) + { + rpc->rc_timeout = true; + } + } /* Get the xid and check that it is an RPC replysvr */ else { - replyheader = (FAR struct rpc_reply_header *)reply; - rxid = replyheader->rp_xid; + FAR struct rpc_reply_header *replyheader = + (FAR struct rpc_reply_header *)reply; if (replyheader->rp_direction != rpc_reply) { @@ -260,7 +258,7 @@ static int rpcclnt_reply(FAR struct rpcclnt *rpc, int procid, int prog, } } - return OK; + return error; } /**************************************************************************** @@ -275,7 +273,6 @@ static uint32_t rpcclnt_newxid(void) { static uint32_t rpcclnt_xid = 0; static uint32_t rpcclnt_xid_touched = 0; - int xidp = 0; srand(time(NULL)); if ((rpcclnt_xid == 0) && (rpcclnt_xid_touched == 0)) @@ -285,6 +282,7 @@ static uint32_t rpcclnt_newxid(void) } else { + int xidp = 0; do { xidp = rand(); diff --git a/nuttx/fs/nxffs/nxffs.h b/nuttx/fs/nxffs/nxffs.h index 616dc7197..083e00fa7 100644 --- a/nuttx/fs/nxffs/nxffs.h +++ b/nuttx/fs/nxffs/nxffs.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nxffs/nxffs.h * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: Linux/Documentation/filesystems/romfs.txt @@ -1044,6 +1044,7 @@ extern int nxffs_pack(FAR struct nxffs_volume_s *volume); * - nxffs_read() is defined in nxffs_read.c * - nxffs_write() is defined in nxffs_write.c * - nxffs_ioctl() is defined in nxffs_ioctl.c + * - nxffs_dup() is defined in nxffs_open.c * - nxffs_opendir(), nxffs_readdir(), and nxffs_rewindir() are defined in * nxffs_dirent.c * - nxffs_bind() and nxffs_unbind() are defined in nxffs_initialize.c @@ -1058,25 +1059,25 @@ struct fs_dirent_s; struct statfs; struct stat; -extern int nxffs_open(FAR struct file *filep, FAR const char *relpath, - int oflags, mode_t mode); -extern int nxffs_close(FAR struct file *filep); -extern ssize_t nxffs_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); -extern ssize_t nxffs_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); -extern int nxffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -extern int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath, - FAR struct fs_dirent_s *dir); -extern int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); -extern int nxffs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); -extern int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data, - FAR void **handle); -extern int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver); -extern int nxffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf); -extern int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath, - FAR struct stat *buf); -extern int nxffs_unlink(FAR struct inode *mountpt, FAR const char *relpath); +int nxffs_open(FAR struct file *filep, FAR const char *relpath, int oflags, + mode_t mode); +int nxffs_close(FAR struct file *filep); +ssize_t nxffs_read(FAR struct file *filep, FAR char *buffer, size_t buflen); +ssize_t nxffs_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +int nxffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +int nxffs_dup(FAR const struct file *oldp, FAR struct file *newp); +int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct fs_dirent_s *dir); +int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); +int nxffs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); +int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle); +int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver); +int nxffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf); +int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf); +int nxffs_unlink(FAR struct inode *mountpt, FAR const char *relpath); #endif /* __FS_NXFFS_NXFFS_H */ diff --git a/nuttx/fs/nxffs/nxffs_initialize.c b/nuttx/fs/nxffs/nxffs_initialize.c index 0aa424869..4e7428c73 100644 --- a/nuttx/fs/nxffs/nxffs_initialize.c +++ b/nuttx/fs/nxffs/nxffs_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nxffs/nxffs_initialize.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: Linux/Documentation/filesystems/romfs.txt @@ -84,7 +84,7 @@ const struct mountpt_operations nxffs_operations = nxffs_ioctl, /* ioctl */ NULL, /* sync -- No buffered data */ - NULL, /* dup -- not implemented */ + nxffs_dup, /* dup */ nxffs_opendir, /* opendir */ NULL, /* closedir */ diff --git a/nuttx/fs/nxffs/nxffs_open.c b/nuttx/fs/nxffs/nxffs_open.c index eb7817c57..b1e99267f 100644 --- a/nuttx/fs/nxffs/nxffs_open.c +++ b/nuttx/fs/nxffs/nxffs_open.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nxffs/nxffs_open.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: Linux/Documentation/filesystems/romfs.txt @@ -1023,7 +1023,7 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath, #endif /* Limitation: A file must be opened for reading or writing, but not both. - * There is no general for extending the size of of a file. Extending the + * There is no general way of extending the size of a file. Extending the * file size of possible if the file to be extended is the last in the * sequence on FLASH, but since that case is not the general case, no file * extension is supported. @@ -1058,6 +1058,64 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath, return ret; } +/**************************************************************************** + * Name: binfs_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +int nxffs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ +#ifdef CONFIG_DEBUG + FAR struct nxffs_volume_s *volume; +#endif + FAR struct nxffs_ofile_s *ofile; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + +#ifdef CONFIG_DEBUG + DEBUGASSERT(oldp->f_priv == NULL && oldp->f_inode != NULL); + + /* Get the mountpoint private data from the NuttX inode reference in the + * file structure + */ + + volume = (FAR struct nxffs_volume_s*)oldp->f_inode->i_private; + DEBUGASSERT(volume != NULL); +#endif + + /* Recover the open file state from the struct file instance */ + + ofile = (FAR struct nxffs_ofile_s *)oldp->f_priv; + + /* I do not think we need exclusive access to the volume to do this. + * The volume exclsem protects the open file list and, hence, would + * assure that the ofile is stable. However, it is assumed that the + * caller holds a value file descriptor associated with this ofile, + * so it should be stable throughout the life of this function. + */ + + /* Limitations: I do not think we have to be concerned about the + * usual NXFFS file limitations here: dup'ing cannot resulting + * in mixed reading and writing to the same file, or multiple + * writer to different file. + * + * I notice that nxffs_wropen will prohibit multiple opens for + * writing. But I do not thing that dup'ing a file already opened + * for writing suffers from any of these issues. + */ + + /* Just increment the reference count on the ofile */ + + ofile->crefs++; + newp->f_priv = (FAR void *)ofile; + return OK; +} + /**************************************************************************** * Name: nxffs_close * diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c index de87c7fec..2814aa49d 100644 --- a/nuttx/fs/romfs/fs_romfs.c +++ b/nuttx/fs/romfs/fs_romfs.c @@ -636,7 +636,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp) * dup'ed file. */ - newrf = (FAR struct romfs_file_s *)malloc(sizeof(struct romfs_file_s)); + newrf = (FAR struct romfs_file_s *)kmalloc(sizeof(struct romfs_file_s)); if (!newrf) { fdbg("Failed to allocate private data\n", ret); diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index 3138a8412..327bf37ca 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fs/fs.h * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/sched/mq_initialize.c b/nuttx/sched/mq_initialize.c index 5b03a1120..dd7c7ed0f 100644 --- a/nuttx/sched/mq_initialize.c +++ b/nuttx/sched/mq_initialize.c @@ -217,11 +217,11 @@ void mq_initialize(void) void mq_desblockalloc(void) { - struct mq_des_block_s *mqdesblock; + FAR struct mq_des_block_s *mqdesblock; /* Allocate a block of message descriptors */ - mqdesblock = (struct mq_des_block_s *)kmalloc(sizeof(struct mq_des_block_s)); + mqdesblock = (FAR struct mq_des_block_s *)kmalloc(sizeof(struct mq_des_block_s)); if (mqdesblock) { int i; diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index b07b8f2a1..f8c619b21 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -228,7 +228,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, /* The return value is the number of the signal that awakened us */ - ret = info->si_signo; + ret = sigpend->info.si_signo; } /* We will have to wait for a signal to be posted to this task. */ diff --git a/nuttx/sched/task_vfork.c b/nuttx/sched/task_vfork.c index 0ea09b048..4b42c7b36 100644 --- a/nuttx/sched/task_vfork.c +++ b/nuttx/sched/task_vfork.c @@ -291,7 +291,7 @@ pid_t task_vforkstart(FAR _TCB *child) * still running. */ - while ((ret = kill(pid, 0)) == OK) + while (kill(pid, 0) == OK) { /* Yes.. then we can yield to it -- assuming that it has not lowered * its priority. sleep(0) might be a safer thing to do since it does -- cgit v1.2.3 From fcb316906d1741c28292e94eb7f09bd4d71ccb48 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 15 Jan 2013 21:01:37 +0000 Subject: Implement redirection of output from NSH builtin commands to a file in a mounted volume git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5521 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 + apps/builtin/Kconfig | 9 + apps/builtin/binfs.c | 6 +- apps/builtin/builtin.c | 4 +- apps/builtin/builtin.h | 2 +- apps/builtin/exec_builtin.c | 397 ++++++++++++-- apps/include/apps.h | 41 +- apps/nshlib/Makefile | 2 +- apps/nshlib/nsh.h | 3 +- apps/nshlib/nsh_apps.c | 220 -------- apps/nshlib/nsh_builtin.c | 226 ++++++++ apps/nshlib/nsh_codeccmd.c | 1076 +++++++++++++++++++------------------- apps/nshlib/nsh_parse.c | 95 ++-- nuttx/configs/sim/nsh/defconfig | 3 +- nuttx/configs/vsn/src/README.txt | 3 +- nuttx/fs/fat/fs_fat32.c | 19 +- nuttx/fs/romfs/fs_romfs.c | 17 +- 17 files changed, 1225 insertions(+), 900 deletions(-) delete mode 100644 apps/nshlib/nsh_apps.c create mode 100644 apps/nshlib/nsh_builtin.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index bf329a40d..ea4fcd07b 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -467,3 +467,5 @@ * apps/examples/ostest/waitpid.c: Add a test for waitpid(), waitid(), and wait(). * builtin/binfs.c: Add hooks for dup() method (not implemented). + * builtin/exec_builtin.c, nshlib/nsh_parse.c, and nshlib/nsh_builtin.c: + NSH now supports re-direction of I/O to files (but still not from). diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig index 5b262734d..1049712aa 100644 --- a/apps/builtin/Kconfig +++ b/apps/builtin/Kconfig @@ -27,4 +27,13 @@ if BUILTIN however, to support execution of the builtin applications from BINFS as well (via a binfmt/ loader). However, that is down the road. +config BUILTIN_PROXY_STACKSIZE + int "Builtin Proxy Stack Size" + default 1024 + ---help--- + If exec_builting uses I/O redirection options, then it will require + an intermediary/proxy task to muck with the file descriptors. This + configuration item specifies the stack size used for the proxy. Default: + 1024 bytes. + endif diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c index 365021c7f..1fc2e7940 100644 --- a/apps/builtin/binfs.c +++ b/apps/builtin/binfs.c @@ -399,7 +399,7 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) /* Have we reached the end of the directory */ index = dir->u.binfs.fb_index; - if (builtins[index].name == NULL) + if (g_builtins[index].name == NULL) { /* We signal the end of the directory by returning the * special error -ENOENT @@ -412,9 +412,9 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) { /* Save the filename and file type */ - fvdbg("Entry %d: \"%s\"\n", index, builtins[index].name); + fvdbg("Entry %d: \"%s\"\n", index, g_builtins[index].name); dir->fd_dir.d_type = DTYPE_FILE; - strncpy(dir->fd_dir.d_name, builtins[index].name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, g_builtins[index].name, NAME_MAX+1); /* The application list is terminated by an entry with a NULL name. * Therefore, there is at least one more entry in the list. diff --git a/apps/builtin/builtin.c b/apps/builtin/builtin.c index a6ed7dd3f..e0ae9888a 100644 --- a/apps/builtin/builtin.c +++ b/apps/builtin/builtin.c @@ -64,7 +64,7 @@ extern "C" { #include "builtin_proto.h" -const struct builtin_s builtins[] = +const struct builtin_s g_builtins[] = { # include "builtin_list.h" { NULL, 0, 0, 0 } @@ -90,7 +90,7 @@ const struct builtin_s builtins[] = int number_builtins(void) { - return sizeof(builtins)/sizeof(struct builtin_s) - 1; + return sizeof(g_builtins)/sizeof(struct builtin_s) - 1; } diff --git a/apps/builtin/builtin.h b/apps/builtin/builtin.h index 3f7ddd7ce..4593809ee 100644 --- a/apps/builtin/builtin.h +++ b/apps/builtin/builtin.h @@ -60,7 +60,7 @@ extern "C" { #define EXTERN extern #endif -EXTERN const struct builtin_s builtins[]; +EXTERN const struct builtin_s g_builtins[]; /**************************************************************************** * Public Functions diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c index dc3630230..a3e79a945 100644 --- a/apps/builtin/exec_builtin.c +++ b/apps/builtin/exec_builtin.c @@ -1,13 +1,15 @@ /**************************************************************************** * apps/builtin/exec_builtin.c * + * Originally by: + * * Copyright (C) 2011 Uros Platise. All rights reserved. * Author: Uros Platise * - * With updates, modifications, and general maintenance by: + * With subsequent updates, modifications, and general maintenance by: * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Auther: Gregory Nutt + * Copyright (C) 2012-2013 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 @@ -43,18 +45,45 @@ ****************************************************************************/ #include -#include -#include +#include #include +#include +#include #include +#include + +#include #include "builtin.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_BUILTIN_PROXY_STACKSIZE +# define CONFIG_BUILTIN_PROXY_STACKSIZE 1024 +#endif + /**************************************************************************** * Private Types ****************************************************************************/ +struct builtin_parms_s +{ + /* Input values */ + + FAR const char *redirfile; + FAR const char **argv; + int oflags; + int index; + + /* Returned values */ + + pid_t result; + int errcode; +}; + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -63,10 +92,276 @@ * Private Data ****************************************************************************/ +static sem_t g_builtin_parmsem = SEM_INITIALIZER(1); +static sem_t g_builtin_execsem = SEM_INITIALIZER(0); +static struct builtin_parms_s g_builtin_parms; + /**************************************************************************** * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: bultin_semtake and builtin_semgive + * + * Description: + * Give and take semaphores + * + * Input Parameters: + * + * sem - The semaphore to act on. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void bultin_semtake(FAR sem_t *sem) +{ + int ret; + + do + { + ret = sem_wait(sem); + ASSERT(ret == 0 || errno == EINTR); + } + while (ret != 0); +} + +#define builtin_semgive(sem) sem_post(sem) + +/**************************************************************************** + * Name: builtin_taskcreate + * + * Description: + * Execute the builtin task + * + * Returned Value: + * On success, the task ID of the builtin task is returned; On failure, -1 + * (ERROR) is returned and the errno is set appropriately. + * + ****************************************************************************/ + +static int builtin_taskcreate(int index, FAR const char **argv) +{ + int ret; + + /* Disable pre-emption. This means that although we start the builtin + * application here, it will not actually run until pre-emption is + * re-enabled below. + */ + + sched_lock(); + + /* Start the builtin application task */ + + ret = TASK_CREATE(g_builtins[index].name, g_builtins[index].priority, + g_builtins[index].stacksize, g_builtins[index].main, + (argv) ? &argv[1] : (FAR const char **)NULL); + + /* If robin robin scheduling is enabled, then set the scheduling policy + * of the new task to SCHED_RR before it has a chance to run. + */ + +#if CONFIG_RR_INTERVAL > 0 + if (ret > 0) + { + struct sched_param param; + + /* Pre-emption is disabled so the task creation and the + * following operation will be atomic. The priority of the + * new task cannot yet have changed from its initial value. + */ + + param.sched_priority = g_builtins[index].priority; + (void)sched_setscheduler(ret, SCHED_RR, ¶m); + } +#endif + + /* Now let the builtin application run */ + + sched_unlock(); + + /* Return the task ID of the new task if the task was sucessfully + * started. Otherwise, ret will be ERROR (and the errno value will + * be set appropriately). + */ + + return ret; +} + +/**************************************************************************** + * Name: builtin_proxy + * + * Description: + * Perform output redirection, then execute the builtin task. + * + * Input Parameters: + * Standard task start-up parameters + * + * Returned Value: + * Standard task return value. + * + ****************************************************************************/ + +static int builtin_proxy(int argc, char *argv[]) +{ + int fd; + int ret = ERROR; + + /* Open the output file for redirection */ + + svdbg("Open'ing redirfile=%s oflags=%04x mode=0644\n", + g_builtin_parms.redirfile, g_builtin_parms.oflags); + + fd = open(g_builtin_parms.redirfile, g_builtin_parms.oflags, 0644); + if (fd < 0) + { + /* Remember the errno value. ret is already set to ERROR */ + + g_builtin_parms.errcode = errno; + sdbg("ERROR: open of %s failed: %d\n", + g_builtin_parms.redirfile, g_builtin_parms.errcode); + } + + /* Does the return file descriptor happen to match the required file + * desciptor number? + */ + + else if (fd != 1) + { + /* No.. dup2 to get the correct file number */ + + svdbg("Dup'ing %d->1\n", fd); + + ret = dup2(fd, 1); + if (ret < 0) + { + g_builtin_parms.errcode = errno; + sdbg("ERROR: dup2 failed: %d\n", g_builtin_parms.errcode); + } + + svdbg("Closing fd=%d\n", fd); + close(fd); + } + + /* Was the setup successful? */ + + if (ret == OK) + { + /* Yes.. Start the task. On success, the task ID of the builtin task + * is returned; On failure, -1 (ERROR) is returned and the errno + * is set appropriately. + */ + + ret = builtin_taskcreate(g_builtin_parms.index, g_builtin_parms.argv); + if (ret < 0) + { + g_builtin_parms.errcode = errno; + sdbg("ERROR: builtin_taskcreate failed: %d\n", + g_builtin_parms.errcode); + } + } + + /* Post the semaphore to inform the parent task that we have completed + * what we need to do. + */ + + g_builtin_parms.result = ret; + builtin_semgive(&g_builtin_execsem); + return 0; +} + +/**************************************************************************** + * Name: builtin_startproxy + * + * Description: + * Perform output redirection, then execute the builtin task. + * + * Input Parameters: + * Standard task start-up parameters + * + * Returned Value: + * On success, the task ID of the builtin task is returned; On failure, -1 + * (ERROR) is returned and the errno is set appropriately. + * + ****************************************************************************/ + +static inline int builtin_startproxy(int index, FAR const char **argv, + FAR const char *redirfile, int oflags) +{ + struct sched_param param; + pid_t proxy; + int errcode; + int ret; + + DEBUGASSERT(path); + + svdbg("index=%d argv=%p redirfile=%s oflags=%04x\n", + index, argv, redirfile, oflags); + + /* We will have to go through an intermediary/proxy task in order to + * perform the I/O redirection. This would be a natural place to fork(). + * However, true fork() behavior requires an MMU and most implementations + * of vfork() are not capable of these operations. + * + * Even without fork(), we can still do the job, but parameter passing is + * messier. Unfortunately, there is no (clean) way to pass binary values + * as a task parameter, so we will use a semaphore-protected global + * structure. + */ + + /* Get exclusive access to the global parameter structure */ + + bultin_semtake(&g_builtin_parmsem); + + /* Populate the parameter structure */ + + g_builtin_parms.redirfile = redirfile; + g_builtin_parms.argv = argv; + g_builtin_parms.result = ERROR; + g_builtin_parms.oflags = oflags; + g_builtin_parms.index = index; + + /* Get the priority of this (parent) task */ + + ret = sched_getparam(0, ¶m); + if (ret < 0) + { + errcode = errno; + sdbg("ERROR: sched_getparam failed: %d\n", errcode); + goto errout; + } + + /* Start the intermediary/proxy task at the same priority as the parent task. */ + + proxy = TASK_CREATE("builtin_proxy", param.sched_priority, + CONFIG_BUILTIN_PROXY_STACKSIZE, (main_t)builtin_proxy, + (FAR const char **)NULL); + if (proxy < 0) + { + errcode = errno; + sdbg("ERROR: Failed to start builtin_proxy: %d\n", errcode); + goto errout; + } + + /* Wait for the proxy to complete its job. We could use waitpid() + * for this. + */ + + bultin_semtake(&g_builtin_execsem); + + /* Get the result and relinquish our access to the parameter structure */ + + set_errno(g_builtin_parms.errcode); + builtin_semgive(&g_builtin_parmsem); + return g_builtin_parms.result; + +errout: + set_errno(errcode); + builtin_semgive(&g_builtin_parmsem); + return ERROR; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -86,10 +381,10 @@ const char *builtin_getname(int index) { return NULL; } - - return builtins[index].name; + + return g_builtins[index].name; } - + /**************************************************************************** * Name: builtin_isavail * @@ -102,10 +397,10 @@ const char *builtin_getname(int index) int builtin_isavail(FAR const char *appname) { int i; - - for (i = 0; builtins[i].name; i++) + + for (i = 0; g_builtins[i].name; i++) { - if (!strcmp(builtins[i].name, appname)) + if (!strcmp(g_builtins[i].name, appname)) { return i; } @@ -114,74 +409,60 @@ int builtin_isavail(FAR const char *appname) set_errno(ENOENT); return ERROR; } - + /**************************************************************************** - * Name: builtin_isavail + * Name: exec_builtin * * Description: - * Execute the application with name 'appname', providing the arguments - * in the argv[] array. + * Executes builtin applications registered during 'make context' time. + * New application is run in a separate task context (and thread). + * + * Input Parameter: + * filename - Name of the linked-in binary to be started. + * argv - Argument list + * redirfile - If output if redirected, this parameter will be non-NULL + * and will provide the full path to the file. + * oflags - If output is redirected, this parameter will provide the + * open flags to use. This will support file replacement + * of appending to an existing file. * * Returned Value: - * On success, the task ID of the builtin application is returned. On - * failure, -1 (ERROR) is returned an the errno value is set appropriately. + * This is an end-user function, so it follows the normal convention: + * Returns the PID of the exec'ed module. On failure, it.returns + * -1 (ERROR) and sets errno appropriately. * ****************************************************************************/ -int exec_builtin(FAR const char *appname, FAR const char **argv) +int exec_builtin(FAR const char *appname, FAR const char **argv, + FAR const char *redirfile, int oflags) { - pid_t pid; int index; + int ret = ERROR; /* Verify that an application with this name exists */ index = builtin_isavail(appname); if (index >= 0) { - /* Disable pre-emption. This means that although we start the builtin - * application here, it will not actually run until pre-emption is - * re-enabled below. - */ - - sched_lock(); - - /* Start the builtin application task */ + /* Is output being redirected? */ - pid = TASK_CREATE(builtins[index].name, builtins[index].priority, - builtins[index].stacksize, builtins[index].main, - (argv) ? &argv[1] : (const char **)NULL); - - /* If robin robin scheduling is enabled, then set the scheduling policy - * of the new task to SCHED_RR before it has a chance to run. - */ - -#if CONFIG_RR_INTERVAL > 0 - if (pid > 0) + if (redirfile) { - struct sched_param param; - - /* Pre-emption is disabled so the task creation and the - * following operation will be atomic. The priority of the - * new task cannot yet have changed from its initial value. - */ - - param.sched_priority = builtins[index].priority; - sched_setscheduler(pid, SCHED_RR, ¶m); + ret = builtin_startproxy(index, argv, redirfile, oflags); } -#endif - /* Now let the builtin application run */ - - sched_unlock(); - - /* Return the task ID of the new task if the task was sucessfully - * started. Otherwise, pid will be ERROR (and the errno value will - * be set appropriately). - */ + else + { + /* Start the builtin application task */ - return pid; + ret = builtin_taskcreate(index, argv); + } } - /* Return ERROR with errno set appropriately */ - return ERROR; + /* Return the task ID of the new task if the task was sucessfully + * started. Otherwise, ret will be ERROR (and the errno value will + * be set appropriately). + */ + + return ret; } diff --git a/apps/include/apps.h b/apps/include/apps.h index 37599ac5c..f806d8aed 100644 --- a/apps/include/apps.h +++ b/apps/include/apps.h @@ -1,9 +1,16 @@ /**************************************************************************** * apps/include/apps.h * - * Copyright(C) 2011 Uros Platise. All rights reserved. + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. * Author: Uros Platise * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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: @@ -64,27 +71,27 @@ struct builtin_s * Public Data ****************************************************************************/ +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + /* The "bindir" is file system that supports access to the builtin applications. * It is typically mounted under /bin. */ #ifdef CONFIG_APPS_BINDIR -struct mountpt_operations; -extern const struct mountpt_operations binfs_operations; +EXTERN mountpt_operations; +EXTERN const struct mountpt_operations binfs_operations; #endif /**************************************************************************** * Public Functions ****************************************************************************/ -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - /**************************************************************************** * Name: builtin_isavail * @@ -129,8 +136,13 @@ EXTERN const char *builtin_getname(int index); * New application is run in a separate task context (and thread). * * Input Parameter: - * filename - Name of the linked-in binary to be started. - * argv - Argument list + * filename - Name of the linked-in binary to be started. + * argv - Argument list + * redirfile - If output if redirected, this parameter will be non-NULL + * and will provide the full path to the file. + * oflags - If output is redirected, this parameter will provide the + * open flags to use. This will support file replacement + * of appending to an existing file. * * Returned Value: * This is an end-user function, so it follows the normal convention: @@ -139,7 +151,8 @@ EXTERN const char *builtin_getname(int index); * ****************************************************************************/ -EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv); +EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv, + FAR const char *redirfile, int oflags); #undef EXTERN #if defined(__cplusplus) diff --git a/apps/nshlib/Makefile b/apps/nshlib/Makefile index 7ddbb67bf..5c5269685 100644 --- a/apps/nshlib/Makefile +++ b/apps/nshlib/Makefile @@ -44,7 +44,7 @@ CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_fscmds.c nsh_ddcmd.c \ nsh_proccmds.c nsh_mmcmds.c nsh_envcmds.c nsh_dbgcmds.c ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -CSRCS += nsh_apps.c +CSRCS += nsh_builtin.c endif ifeq ($(CONFIG_NSH_ROMFSETC),y) diff --git a/apps/nshlib/nsh.h b/apps/nshlib/nsh.h index a046a384f..253a803f8 100644 --- a/apps/nshlib/nsh.h +++ b/apps/nshlib/nsh.h @@ -491,7 +491,8 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline); /* Application interface */ #ifdef CONFIG_NSH_BUILTIN_APPS -int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, FAR char **argv); +int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, + FAR char **argv, FAR const char *redirfile, int oflags); #endif /* Working directory support */ diff --git a/apps/nshlib/nsh_apps.c b/apps/nshlib/nsh_apps.c deleted file mode 100644 index ea8791eef..000000000 --- a/apps/nshlib/nsh_apps.c +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** - * apps/nshlib/nsh_apps.c - * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Uros Platise - * - * 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 - -#ifdef CONFIG_SCHED_WAITPID -# include -#endif - -#include -#include -#include - -#include - -#include "nsh.h" -#include "nsh_console.h" - -#ifdef CONFIG_NSH_BUILTIN_APPS - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nsh_execapp - * - * Description: - * Attempt to execute the application task whose name is 'cmd' - * - * Returned Value: - * <0 If exec_builtin() fails, then the negated errno value - * is returned. - * -1 (ERROR) if the application task corresponding to 'cmd' could not - * be started (possibly because it doesn not exist). - * 0 (OK) if the application task corresponding to 'cmd' was - * and successfully started. If CONFIG_SCHED_WAITPID is - * defined, this return value also indicates that the - * application returned successful status (EXIT_SUCCESS) - * 1 If CONFIG_SCHED_WAITPID is defined, then this return value - * indicates that the application task was spawned successfully - * but returned failure exit status. - * - ****************************************************************************/ - -int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, - FAR char **argv) -{ - int ret = OK; - - /* Lock the scheduler to prevent the application from running until the - * waitpid() has been called. - */ - - sched_lock(); - - /* Try to find and execute the command within the list of builtin - * applications. - */ - - ret = exec_builtin(cmd, (FAR const char **)argv); - if (ret >= 0) - { - /* The application was successfully started (but still blocked because - * the scheduler is locked). If the application was not backgrounded, - * then we need to wait here for the application to exit. These really - * only works works with the following options: - * - * - CONFIG_NSH_DISABLEBG - Do not run commands in background - * - CONFIG_SCHED_WAITPID - Required to run external commands in - * foreground - * - * These concepts do not apply cleanly to the external applications. - */ - -#ifdef CONFIG_SCHED_WAITPID - - /* CONFIG_SCHED_WAITPID is selected, so we may run the command in - * foreground unless we were specifically requested to run the command - * in background (and running commands in background is enabled). - */ - -# ifndef CONFIG_NSH_DISABLEBG - if (vtbl->np.np_bg == false) -# endif /* CONFIG_NSH_DISABLEBG */ - { - int rc = 0; - - /* Wait for the application to exit. Since we have locked the - * scheduler above, we know that the application has not yet - * started and there is no possibility that it has already exited. - * The scheduler will be unlocked while waitpid is waiting and the - * application will be able to run. - */ - - ret = waitpid(ret, &rc, 0); - if (ret >= 0) - { - /* We can't return the exact status (nsh has nowhere to put it) - * so just pass back zero/nonzero in a fashion that doesn't look - * like an error. - */ - - ret = (rc == 0) ? OK : 1; - - /* TODO: Set the environment variable '?' to a string corresponding - * to WEXITSTATUS(rc) so that $? will expand to the exit status of - * the most recently executed task. - */ - } - } -# ifndef CONFIG_NSH_DISABLEBG - else -# endif /* CONFIG_NSH_DISABLEBG */ -#endif /* CONFIG_SCHED_WAITPID */ - - /* We get here if either: - * - * - CONFIG_SCHED_WAITPID is not selected meaning that all commands - * have to be run in background, or - * - CONFIG_SCHED_WAITPID and CONFIG_NSH_DISABLEBG are both selected, but the - * user requested to run the command in background. - * - * NOTE that the case of a) CONFIG_SCHED_WAITPID is not selected and - * b) CONFIG_NSH_DISABLEBG selected cannot be supported. In that event, all - * commands will have to run in background. The waitpid() API must be - * available to support running the command in foreground. - */ - -#if !defined(CONFIG_SCHED_WAITPID) || !defined(CONFIG_NSH_DISABLEBG) - { - struct sched_param param; - sched_getparam(0, ¶m); - nsh_output(vtbl, "%s [%d:%d]\n", cmd, ret, param.sched_priority); - - /* Backgrounded commands always 'succeed' as long as we can start - * them. - */ - - ret = OK; - } -#endif /* !CONFIG_SCHED_WAITPID || !CONFIG_NSH_DISABLEBG */ - } - - sched_unlock(); - - /* If exec_builtin() or waitpid() failed, then return the negated errno - * value. - */ - - if (ret < 0) - { - return -errno; - } - - return ret; -} - -#endif /* CONFIG_NSH_BUILTIN_APPS */ diff --git a/apps/nshlib/nsh_builtin.c b/apps/nshlib/nsh_builtin.c new file mode 100644 index 000000000..16e3e9427 --- /dev/null +++ b/apps/nshlib/nsh_builtin.c @@ -0,0 +1,226 @@ +/**************************************************************************** + * apps/nshlib/nsh_builtin.c + * + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2011-2013 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 + +#ifdef CONFIG_SCHED_WAITPID +# include +#endif + +#include +#include +#include + +#include + +#include "nsh.h" +#include "nsh_console.h" + +#ifdef CONFIG_NSH_BUILTIN_APPS + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nsh_builtin + * + * Description: + * Attempt to execute the application task whose name is 'cmd' + * + * Returned Value: + * <0 If exec_builtin() fails, then the negated errno value + * is returned. + * -1 (ERROR) if the application task corresponding to 'cmd' could not + * be started (possibly because it doesn not exist). + * 0 (OK) if the application task corresponding to 'cmd' was + * and successfully started. If CONFIG_SCHED_WAITPID is + * defined, this return value also indicates that the + * application returned successful status (EXIT_SUCCESS) + * 1 If CONFIG_SCHED_WAITPID is defined, then this return value + * indicates that the application task was spawned successfully + * but returned failure exit status. + * + ****************************************************************************/ + +int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, + FAR char **argv, FAR const char *redirfile, int oflags) +{ + int ret = OK; + + /* Lock the scheduler to prevent the application from running until the + * waitpid() has been called. + */ + + sched_lock(); + + /* Try to find and execute the command within the list of builtin + * applications. + */ + + ret = exec_builtin(cmd, (FAR const char **)argv, redirfile, oflags); + if (ret >= 0) + { + /* The application was successfully started (but still blocked because + * the scheduler is locked). If the application was not backgrounded, + * then we need to wait here for the application to exit. These really + * only works works with the following options: + * + * - CONFIG_NSH_DISABLEBG - Do not run commands in background + * - CONFIG_SCHED_WAITPID - Required to run external commands in + * foreground + * + * These concepts do not apply cleanly to the external applications. + */ + +#ifdef CONFIG_SCHED_WAITPID + + /* CONFIG_SCHED_WAITPID is selected, so we may run the command in + * foreground unless we were specifically requested to run the command + * in background (and running commands in background is enabled). + */ + +# ifndef CONFIG_NSH_DISABLEBG + if (vtbl->np.np_bg == false) +# endif /* CONFIG_NSH_DISABLEBG */ + { + int rc = 0; + + /* Wait for the application to exit. Since we have locked the + * scheduler above, we know that the application has not yet + * started and there is no possibility that it has already exited. + * The scheduler will be unlocked while waitpid is waiting and the + * application will be able to run. + */ + + ret = waitpid(ret, &rc, 0); + if (ret >= 0) + { + /* We can't return the exact status (nsh has nowhere to put it) + * so just pass back zero/nonzero in a fashion that doesn't look + * like an error. + */ + + ret = (rc == 0) ? OK : 1; + + /* TODO: Set the environment variable '?' to a string corresponding + * to WEXITSTATUS(rc) so that $? will expand to the exit status of + * the most recently executed task. + */ + } + } +# ifndef CONFIG_NSH_DISABLEBG + else +# endif /* CONFIG_NSH_DISABLEBG */ +#endif /* CONFIG_SCHED_WAITPID */ + + /* We get here if either: + * + * - CONFIG_SCHED_WAITPID is not selected meaning that all commands + * have to be run in background, or + * - CONFIG_SCHED_WAITPID and CONFIG_NSH_DISABLEBG are both selected, but the + * user requested to run the command in background. + * + * NOTE that the case of a) CONFIG_SCHED_WAITPID is not selected and + * b) CONFIG_NSH_DISABLEBG selected cannot be supported. In that event, all + * commands will have to run in background. The waitpid() API must be + * available to support running the command in foreground. + */ + +#if !defined(CONFIG_SCHED_WAITPID) || !defined(CONFIG_NSH_DISABLEBG) + { + struct sched_param param; + sched_getparam(ret, ¶m); + nsh_output(vtbl, "%s [%d:%d]\n", cmd, ret, param.sched_priority); + + /* Backgrounded commands always 'succeed' as long as we can start + * them. + */ + + ret = OK; + } +#endif /* !CONFIG_SCHED_WAITPID || !CONFIG_NSH_DISABLEBG */ + } + + sched_unlock(); + + /* If exec_builtin() or waitpid() failed, then return -1 (ERROR) with the + * errno value set appropriately. + */ + + if (ret < 0) + { + return ERROR; + } + + return ret; +} + +#endif /* CONFIG_NSH_BUILTIN_APPS */ diff --git a/apps/nshlib/nsh_codeccmd.c b/apps/nshlib/nsh_codeccmd.c index 8c1f5adbd..779fc5ecd 100644 --- a/apps/nshlib/nsh_codeccmd.c +++ b/apps/nshlib/nsh_codeccmd.c @@ -1,538 +1,538 @@ -/**************************************************************************** - * apps/nshlib/nsh_apps.c - * - * This file is part of NuttX, contributed by Darcy Gong - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Darcy Gong 2012-10-30 - * - * 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 -#ifdef CONFIG_NETUTILS_CODECS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_NSH_DISABLE_URLENCODE) && defined(CONFIG_NSH_DISABLE_URLDECODE) -# undef CONFIG_CODECS_URLCODE -#endif - -#ifdef CONFIG_CODECS_URLCODE -#include -#endif - -#if defined(CONFIG_NSH_DISABLE_BASE64ENC) && defined(CONFIG_NSH_DISABLE_BASE64ENC) -# undef CONFIG_CODECS_BASE64 -#endif - -#ifdef CONFIG_CODECS_BASE64 -#include -#endif - -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) -#include -#endif - -#include "nsh.h" -#include "nsh_console.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_NSH_CODECS_BUFSIZE -# define CONFIG_NSH_CODECS_BUFSIZE 128 -#endif - -#define CODEC_MODE_URLENCODE 1 -#define CODEC_MODE_URLDECODE 2 -#define CODEC_MODE_BASE64ENC 3 -#define CODEC_MODE_BASE64DEC 4 -#define CODEC_MODE_HASH_MD5 5 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -typedef void (*codec_callback_t)(FAR char *src_buff, int src_buff_len, - FAR char *dst_buff, FAR int *dst_buff_len, - int mode); - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: urlencode_cb - ****************************************************************************/ - -#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLENCODE) -static void urlencode_cb(FAR char *src_buff, int src_buff_len, - FAR char *dst_buff, FAR int *dst_buff_len, int mode) -{ - urlencode(src_buff,src_buff_len,dst_buff,dst_buff_len); -} -#endif - -/**************************************************************************** - * Name: urldecode_cb - ****************************************************************************/ - -#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) -static void urldecode_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, - FAR int *dst_buff_len, int mode) -{ - urldecode(src_buff,src_buff_len,dst_buff,dst_buff_len); -} -#endif - -/**************************************************************************** - * Name: b64enc_cb - ****************************************************************************/ - -#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) -static void b64enc_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, - FAR int *dst_buff_len, int mode) -{ - if (mode == 0) - { - //dst_buff = - base64_encode((unsigned char *)src_buff, src_buff_len, - (unsigned char *)dst_buff, (size_t *)dst_buff_len); - } - else - { - //dst_buff = - base64w_encode((unsigned char *)src_buff, src_buff_len, - (unsigned char *)dst_buff, (size_t *)dst_buff_len); - } -} -#endif - -/**************************************************************************** - * Name: b64dec_cb - ****************************************************************************/ - -#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64DEC) -static void b64dec_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, - FAR int *dst_buff_len, int mode) -{ - if (mode == 0) - { - //dst_buff = - base64_decode((unsigned char *)src_buff, src_buff_len, - (unsigned char *)dst_buff, (size_t *)dst_buff_len); - } - else - { - //dst_buff = - base64w_decode((unsigned char *)src_buff, src_buff_len, - (unsigned char *)dst_buff,(size_t *)dst_buff_len); - } -} -#endif - -/**************************************************************************** - * Name: md5_cb - ****************************************************************************/ - -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) -static void md5_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, - FAR int *dst_buff_len, int mode) -{ - MD5Update((MD5_CTX *)dst_buff, (unsigned char *)src_buff, src_buff_len); -} -#endif - -/**************************************************************************** - * Name: calc_codec_buffsize - ****************************************************************************/ - -static int calc_codec_buffsize(int src_buffsize, uint8_t mode) -{ - switch (mode) - { - case CODEC_MODE_URLENCODE: - return src_buffsize*3+1; - case CODEC_MODE_URLDECODE: - return src_buffsize+1; - case CODEC_MODE_BASE64ENC: - return ((src_buffsize + 2)/ 3 * 4)+1; - case CODEC_MODE_BASE64DEC: - return (src_buffsize / 4 * 3 + 2)+1; - case CODEC_MODE_HASH_MD5: - return 32+1; - default: - return src_buffsize+1; - } -} - -/**************************************************************************** - * Name: cmd_codecs_proc - ****************************************************************************/ - -static int cmd_codecs_proc(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv, - uint8_t mode, codec_callback_t func) -{ -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) - static const unsigned char hex_chars[] = "0123456789abcdef"; - MD5_CTX ctx; - unsigned char mac[16]; - char *pSrc; - char *pDest; -#endif - - char *localfile = NULL; - char *src_buffer = NULL; - char *buffer = NULL; - char *fullpath = NULL; - const char *fmt; - char *s_data; - bool badarg = false; - bool is_file = false; - bool is_websafe=false; - int option; - int fd = -1; - int buff_len = 0; - int src_buff_len = 0; - int i = 0; - int ret = OK; - - /* Get the command options */ - - while ((option = getopt(argc, argv, ":fw")) != ERROR) - { - switch (option) - { - case 'f': - is_file = true; - break; - -#ifdef CONFIG_CODECS_BASE64 - case 'w': - is_websafe = true; - - if (!(mode == CODEC_MODE_BASE64ENC || mode == CODEC_MODE_BASE64DEC)) - { - badarg = true; - } - break; -#endif - case ':': - nsh_output(vtbl, g_fmtargrequired, argv[0]); - badarg = true; - break; - - case '?': - default: - nsh_output(vtbl, g_fmtarginvalid, argv[0]); - badarg = true; - break; - } - } - - /* If a bad argument was encountered, then return without processing the command */ - - if (badarg) - { - return ERROR; - } - - /* There should be exactly on parameter left on the command-line */ - - if (optind == argc-1) - { - s_data = argv[optind]; - } - else if (optind >= argc) - { - fmt = g_fmttoomanyargs; - goto errout; - } - else - { - fmt = g_fmtargrequired; - goto errout; - } - -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) - if (mode == CODEC_MODE_HASH_MD5) - { - MD5Init(&ctx); - } -#endif - - if (is_file) - { - /* Get the local file name */ - - localfile = s_data; - - /* Get the full path to the local file */ - - fullpath = nsh_getfullpath(vtbl, localfile); - - /* Open the local file for writing */ - - fd = open(fullpath, O_RDONLY|O_TRUNC, 0644); - if (fd < 0) - { - nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO); - ret = ERROR; - goto exit; - } - - src_buffer = malloc(CONFIG_NSH_CODECS_BUFSIZE+2); -#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) - if (mode == CODEC_MODE_BASE64ENC) - { - src_buff_len = CONFIG_NSH_CODECS_BUFSIZE / 3 * 3; - } - else -#endif - { - src_buff_len = CONFIG_NSH_CODECS_BUFSIZE; - } - - buff_len = calc_codec_buffsize(src_buff_len+2, mode); - buffer = malloc(buff_len); - while(true) - { - memset(src_buffer, 0, src_buff_len+2); - ret=read(fd, src_buffer, src_buff_len); - if (ret < 0) - { - nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO); - ret = ERROR; - goto exit; - } - else if(ret==0) - { - break; - } - -#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) - if (mode == CODEC_MODE_URLDECODE) - { - if (src_buffer[src_buff_len-1]=='%') - { - ret += read(fd,&src_buffer[src_buff_len],2); - } - else if (src_buffer[src_buff_len-2]=='%') - { - ret += read(fd,&src_buffer[src_buff_len],1); - } - } -#endif - memset(buffer, 0, buff_len); - if (func) - { -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) - if (mode == CODEC_MODE_HASH_MD5) - { - func(src_buffer, ret, (char *)&ctx, &buff_len,0); - } - else -#endif - { - func(src_buffer, ret, buffer, &buff_len,(is_websafe)?1:0); - nsh_output(vtbl, "%s", buffer); - } - } - - buff_len = calc_codec_buffsize(src_buff_len+2, mode); - } - -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) - if (mode == CODEC_MODE_HASH_MD5) - { - MD5Final(mac, &ctx); - pSrc = (char *)&mac; - pDest = buffer; - for(i=0;i<16;i++,pSrc++) - { - *pDest++ = hex_chars[(*pSrc) >> 4]; - *pDest++ = hex_chars[(*pSrc) & 0x0f]; - } - - *pDest='\0'; - nsh_output(vtbl, "%s\n", buffer); - } -#endif - ret = OK; - goto exit; - } - else - { - src_buffer = s_data; - src_buff_len = strlen(s_data); - buff_len = calc_codec_buffsize(src_buff_len, mode); - buffer = malloc(buff_len); - buffer[0]=0; - if (!buffer) - { - fmt = g_fmtcmdoutofmemory; - goto errout; - } - - memset(buffer, 0, buff_len); - if (func) - { -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) - if (mode == CODEC_MODE_HASH_MD5) - { - func(src_buffer, src_buff_len, (char *)&ctx, &buff_len, 0); - MD5Final(mac, &ctx); - pSrc = (char *)&mac; - pDest = buffer; - for(i=0;i<16;i++,pSrc++) - { - *pDest++ = hex_chars[(*pSrc) >> 4]; - *pDest++ = hex_chars[(*pSrc) & 0x0f]; - } - - *pDest='\0'; - } - else -#endif - { - func(src_buffer, src_buff_len, buffer, &buff_len,(is_websafe)?1:0); - } - } - - nsh_output(vtbl, "%s\n",buffer); - src_buffer = NULL; - goto exit; - } - -exit: - if (fd >= 0) - { - close(fd); - } - - if (fullpath) - { - free(fullpath); - } - - if (src_buffer) - { - free(src_buffer); - } - - if (buffer) - { - free(buffer); - } - - return ret; - -errout: - nsh_output(vtbl, fmt, argv[0]); - ret = ERROR; - goto exit; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: cmd_urlencode - ****************************************************************************/ - -#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLENCODE) -int cmd_urlencode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) -{ - return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_URLENCODE, urlencode_cb); -} -#endif - -/**************************************************************************** - * Name: cmd_urldecode - ****************************************************************************/ - -#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) -int cmd_urldecode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) -{ - return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_URLDECODE, urldecode_cb); -} -#endif - -/**************************************************************************** - * Name: cmd_base64encode - ****************************************************************************/ - -#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) -int cmd_base64encode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) -{ - return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_BASE64ENC, b64enc_cb); -} -#endif - -/**************************************************************************** - * Name: cmd_base64decode - ****************************************************************************/ - -#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64DEC) -int cmd_base64decode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) -{ - return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_BASE64DEC, b64dec_cb); -} -#endif - -/**************************************************************************** - * Name: cmd_md5 - ****************************************************************************/ - -#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) -int cmd_md5(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) -{ - return cmd_codecs_proc(vtbl,argc,argv,CODEC_MODE_HASH_MD5,md5_cb); -} -#endif - -#endif /* CONFIG_NETUTILS_CODECS */ +/**************************************************************************** + * apps/nshlib/nsh_codeccmd.c + * + * This file is part of NuttX, contributed by Darcy Gong + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Darcy Gong 2012-10-30 + * + * 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 +#ifdef CONFIG_NETUTILS_CODECS + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_NSH_DISABLE_URLENCODE) && defined(CONFIG_NSH_DISABLE_URLDECODE) +# undef CONFIG_CODECS_URLCODE +#endif + +#ifdef CONFIG_CODECS_URLCODE +#include +#endif + +#if defined(CONFIG_NSH_DISABLE_BASE64ENC) && defined(CONFIG_NSH_DISABLE_BASE64ENC) +# undef CONFIG_CODECS_BASE64 +#endif + +#ifdef CONFIG_CODECS_BASE64 +#include +#endif + +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) +#include +#endif + +#include "nsh.h" +#include "nsh_console.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_NSH_CODECS_BUFSIZE +# define CONFIG_NSH_CODECS_BUFSIZE 128 +#endif + +#define CODEC_MODE_URLENCODE 1 +#define CODEC_MODE_URLDECODE 2 +#define CODEC_MODE_BASE64ENC 3 +#define CODEC_MODE_BASE64DEC 4 +#define CODEC_MODE_HASH_MD5 5 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +typedef void (*codec_callback_t)(FAR char *src_buff, int src_buff_len, + FAR char *dst_buff, FAR int *dst_buff_len, + int mode); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: urlencode_cb + ****************************************************************************/ + +#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLENCODE) +static void urlencode_cb(FAR char *src_buff, int src_buff_len, + FAR char *dst_buff, FAR int *dst_buff_len, int mode) +{ + urlencode(src_buff,src_buff_len,dst_buff,dst_buff_len); +} +#endif + +/**************************************************************************** + * Name: urldecode_cb + ****************************************************************************/ + +#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) +static void urldecode_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, + FAR int *dst_buff_len, int mode) +{ + urldecode(src_buff,src_buff_len,dst_buff,dst_buff_len); +} +#endif + +/**************************************************************************** + * Name: b64enc_cb + ****************************************************************************/ + +#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) +static void b64enc_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, + FAR int *dst_buff_len, int mode) +{ + if (mode == 0) + { + //dst_buff = + base64_encode((unsigned char *)src_buff, src_buff_len, + (unsigned char *)dst_buff, (size_t *)dst_buff_len); + } + else + { + //dst_buff = + base64w_encode((unsigned char *)src_buff, src_buff_len, + (unsigned char *)dst_buff, (size_t *)dst_buff_len); + } +} +#endif + +/**************************************************************************** + * Name: b64dec_cb + ****************************************************************************/ + +#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64DEC) +static void b64dec_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, + FAR int *dst_buff_len, int mode) +{ + if (mode == 0) + { + //dst_buff = + base64_decode((unsigned char *)src_buff, src_buff_len, + (unsigned char *)dst_buff, (size_t *)dst_buff_len); + } + else + { + //dst_buff = + base64w_decode((unsigned char *)src_buff, src_buff_len, + (unsigned char *)dst_buff,(size_t *)dst_buff_len); + } +} +#endif + +/**************************************************************************** + * Name: md5_cb + ****************************************************************************/ + +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) +static void md5_cb(FAR char *src_buff, int src_buff_len, FAR char *dst_buff, + FAR int *dst_buff_len, int mode) +{ + MD5Update((MD5_CTX *)dst_buff, (unsigned char *)src_buff, src_buff_len); +} +#endif + +/**************************************************************************** + * Name: calc_codec_buffsize + ****************************************************************************/ + +static int calc_codec_buffsize(int src_buffsize, uint8_t mode) +{ + switch (mode) + { + case CODEC_MODE_URLENCODE: + return src_buffsize*3+1; + case CODEC_MODE_URLDECODE: + return src_buffsize+1; + case CODEC_MODE_BASE64ENC: + return ((src_buffsize + 2)/ 3 * 4)+1; + case CODEC_MODE_BASE64DEC: + return (src_buffsize / 4 * 3 + 2)+1; + case CODEC_MODE_HASH_MD5: + return 32+1; + default: + return src_buffsize+1; + } +} + +/**************************************************************************** + * Name: cmd_codecs_proc + ****************************************************************************/ + +static int cmd_codecs_proc(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv, + uint8_t mode, codec_callback_t func) +{ +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) + static const unsigned char hex_chars[] = "0123456789abcdef"; + MD5_CTX ctx; + unsigned char mac[16]; + char *pSrc; + char *pDest; +#endif + + char *localfile = NULL; + char *src_buffer = NULL; + char *buffer = NULL; + char *fullpath = NULL; + const char *fmt; + char *s_data; + bool badarg = false; + bool is_file = false; + bool is_websafe=false; + int option; + int fd = -1; + int buff_len = 0; + int src_buff_len = 0; + int i = 0; + int ret = OK; + + /* Get the command options */ + + while ((option = getopt(argc, argv, ":fw")) != ERROR) + { + switch (option) + { + case 'f': + is_file = true; + break; + +#ifdef CONFIG_CODECS_BASE64 + case 'w': + is_websafe = true; + + if (!(mode == CODEC_MODE_BASE64ENC || mode == CODEC_MODE_BASE64DEC)) + { + badarg = true; + } + break; +#endif + case ':': + nsh_output(vtbl, g_fmtargrequired, argv[0]); + badarg = true; + break; + + case '?': + default: + nsh_output(vtbl, g_fmtarginvalid, argv[0]); + badarg = true; + break; + } + } + + /* If a bad argument was encountered, then return without processing the command */ + + if (badarg) + { + return ERROR; + } + + /* There should be exactly on parameter left on the command-line */ + + if (optind == argc-1) + { + s_data = argv[optind]; + } + else if (optind >= argc) + { + fmt = g_fmttoomanyargs; + goto errout; + } + else + { + fmt = g_fmtargrequired; + goto errout; + } + +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) + if (mode == CODEC_MODE_HASH_MD5) + { + MD5Init(&ctx); + } +#endif + + if (is_file) + { + /* Get the local file name */ + + localfile = s_data; + + /* Get the full path to the local file */ + + fullpath = nsh_getfullpath(vtbl, localfile); + + /* Open the local file for writing */ + + fd = open(fullpath, O_RDONLY|O_TRUNC, 0644); + if (fd < 0) + { + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO); + ret = ERROR; + goto exit; + } + + src_buffer = malloc(CONFIG_NSH_CODECS_BUFSIZE+2); +#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) + if (mode == CODEC_MODE_BASE64ENC) + { + src_buff_len = CONFIG_NSH_CODECS_BUFSIZE / 3 * 3; + } + else +#endif + { + src_buff_len = CONFIG_NSH_CODECS_BUFSIZE; + } + + buff_len = calc_codec_buffsize(src_buff_len+2, mode); + buffer = malloc(buff_len); + while(true) + { + memset(src_buffer, 0, src_buff_len+2); + ret=read(fd, src_buffer, src_buff_len); + if (ret < 0) + { + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO); + ret = ERROR; + goto exit; + } + else if(ret==0) + { + break; + } + +#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) + if (mode == CODEC_MODE_URLDECODE) + { + if (src_buffer[src_buff_len-1]=='%') + { + ret += read(fd,&src_buffer[src_buff_len],2); + } + else if (src_buffer[src_buff_len-2]=='%') + { + ret += read(fd,&src_buffer[src_buff_len],1); + } + } +#endif + memset(buffer, 0, buff_len); + if (func) + { +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) + if (mode == CODEC_MODE_HASH_MD5) + { + func(src_buffer, ret, (char *)&ctx, &buff_len,0); + } + else +#endif + { + func(src_buffer, ret, buffer, &buff_len,(is_websafe)?1:0); + nsh_output(vtbl, "%s", buffer); + } + } + + buff_len = calc_codec_buffsize(src_buff_len+2, mode); + } + +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) + if (mode == CODEC_MODE_HASH_MD5) + { + MD5Final(mac, &ctx); + pSrc = (char *)&mac; + pDest = buffer; + for(i=0;i<16;i++,pSrc++) + { + *pDest++ = hex_chars[(*pSrc) >> 4]; + *pDest++ = hex_chars[(*pSrc) & 0x0f]; + } + + *pDest='\0'; + nsh_output(vtbl, "%s\n", buffer); + } +#endif + ret = OK; + goto exit; + } + else + { + src_buffer = s_data; + src_buff_len = strlen(s_data); + buff_len = calc_codec_buffsize(src_buff_len, mode); + buffer = malloc(buff_len); + buffer[0]=0; + if (!buffer) + { + fmt = g_fmtcmdoutofmemory; + goto errout; + } + + memset(buffer, 0, buff_len); + if (func) + { +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) + if (mode == CODEC_MODE_HASH_MD5) + { + func(src_buffer, src_buff_len, (char *)&ctx, &buff_len, 0); + MD5Final(mac, &ctx); + pSrc = (char *)&mac; + pDest = buffer; + for(i=0;i<16;i++,pSrc++) + { + *pDest++ = hex_chars[(*pSrc) >> 4]; + *pDest++ = hex_chars[(*pSrc) & 0x0f]; + } + + *pDest='\0'; + } + else +#endif + { + func(src_buffer, src_buff_len, buffer, &buff_len,(is_websafe)?1:0); + } + } + + nsh_output(vtbl, "%s\n",buffer); + src_buffer = NULL; + goto exit; + } + +exit: + if (fd >= 0) + { + close(fd); + } + + if (fullpath) + { + free(fullpath); + } + + if (src_buffer) + { + free(src_buffer); + } + + if (buffer) + { + free(buffer); + } + + return ret; + +errout: + nsh_output(vtbl, fmt, argv[0]); + ret = ERROR; + goto exit; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: cmd_urlencode + ****************************************************************************/ + +#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLENCODE) +int cmd_urlencode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_URLENCODE, urlencode_cb); +} +#endif + +/**************************************************************************** + * Name: cmd_urldecode + ****************************************************************************/ + +#if defined(CONFIG_CODECS_URLCODE) && !defined(CONFIG_NSH_DISABLE_URLDECODE) +int cmd_urldecode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_URLDECODE, urldecode_cb); +} +#endif + +/**************************************************************************** + * Name: cmd_base64encode + ****************************************************************************/ + +#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64ENC) +int cmd_base64encode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_BASE64ENC, b64enc_cb); +} +#endif + +/**************************************************************************** + * Name: cmd_base64decode + ****************************************************************************/ + +#if defined(CONFIG_CODECS_BASE64) && !defined(CONFIG_NSH_DISABLE_BASE64DEC) +int cmd_base64decode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + return cmd_codecs_proc(vtbl, argc, argv, CODEC_MODE_BASE64DEC, b64dec_cb); +} +#endif + +/**************************************************************************** + * Name: cmd_md5 + ****************************************************************************/ + +#if defined(CONFIG_CODECS_HASH_MD5) && !defined(CONFIG_NSH_DISABLE_MD5) +int cmd_md5(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + return cmd_codecs_proc(vtbl,argc,argv,CODEC_MODE_HASH_MD5,md5_cb); +} +#endif + +#endif /* CONFIG_NETUTILS_CODECS */ diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index 70fa39f62..15723b497 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/nshlib/nsh_parse.c * - * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ /* Argument list size * - * argv[0]: The command name. + * argv[0]: The command name. * argv[1]: The beginning of argument (up to CONFIG_NSH_MAXARGUMENTS) * argv[argc-3]: Possibly '>' or '>>' * argv[argc-2]: Possibly @@ -226,7 +226,7 @@ static const struct cmdmap_s g_cmdmap[] = { "help", cmd_help, 1, 3, "[-v] []" }, # endif #endif - + #if CONFIG_NFILE_DESCRIPTORS > 0 #ifndef CONFIG_NSH_DISABLE_HEXDUMP { "hexdump", cmd_hexdump, 2, 2, "" }, @@ -723,15 +723,11 @@ static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * Name: nsh_execute * * Description: - * Exectue the command in argv[0] + * Execute the command in argv[0] * * Returned Value: - * <0 If exec_builtin() fails, then the negated errno value - * is returned. * -1 (ERRROR) if the command was unsuccessful * 0 (OK) if the command was successful - * 1 if an application task was spawned successfully, but - * returned failure exit status. * ****************************************************************************/ @@ -751,21 +747,6 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[]) */ cmd = argv[0]; - - /* Try to find a command in the application library. */ - -#ifdef CONFIG_NSH_BUILTIN_APPS - ret = nsh_execapp(vtbl, cmd, argv); - - /* If the built-in application was successfully started, return OK - * or 1 (if the application returned a non-zero exit status). - */ - - if (ret >= 0) - { - return ret; - } -#endif /* See if the command is one that we understand */ @@ -1352,7 +1333,7 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) /* Parse all of the arguments following the command name. The form * of argv is: * - * argv[0]: The command name. + * argv[0]: The command name. * argv[1]: The beginning of argument (up to CONFIG_NSH_MAXARGUMENTS) * argv[argc-3]: Possibly '>' or '>>' * argv[argc-2]: Possibly @@ -1410,6 +1391,47 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) } } + /* Check if the maximum number of arguments was exceeded */ + + if (argc > CONFIG_NSH_MAXARGUMENTS) + { + nsh_output(vtbl, g_fmttoomanyargs, cmd); + } + + /* Does this command correspond to a builtin command? + * nsh_builtin() returns: + * + * -1 (ERROR) if the application task corresponding to 'argv[0]' could not + * be started (possibly because it doesn not exist). + * 0 (OK) if the application task corresponding to 'argv[0]' was + * and successfully started. If CONFIG_SCHED_WAITPID is + * defined, this return value also indicates that the + * application returned successful status (EXIT_SUCCESS) + * 1 If CONFIG_SCHED_WAITPID is defined, then this return value + * indicates that the application task was spawned successfully + * but returned failure exit status. + * + * Note the priority if not effected by nice-ness. + */ + +#ifdef CONFIG_NSH_BUILTIN_APPS + ret = nsh_builtin(vtbl, argv[0], argv, redirfile, oflags); + if (ret >= 0) + { + /* nsh_builtin() returned 0 or 1. This means that the builtin + * command was successfully started (although it may not have ran + * successfully). So certainly it is not an NSH command. + */ + + return nsh_saveresult(vtbl, ret != OK); + } + + /* No, not a built in command (or, at least, we were unable to start a + * builtin command of that name). Treat it like an NSH command. + */ + +#endif + /* Redirected output? */ if (vtbl->np.np_redirect) @@ -1431,23 +1453,13 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) } } - /* Check if the maximum number of arguments was exceeded */ - - if (argc > CONFIG_NSH_MAXARGUMENTS) - { - nsh_output(vtbl, g_fmttoomanyargs, cmd); - } - /* Handle the case where the command is executed in background. * However is app is to be started as builtin new process will - * be created anyway, so skip this step. */ + * be created anyway, so skip this step. + */ #ifndef CONFIG_NSH_DISABLEBG - if (vtbl->np.np_bg -#ifdef CONFIG_NSH_BUILTIN_APPS - && builtin_isavail(argv[0]) < 0 -#endif - ) + if (vtbl->np.np_bg) { struct sched_param param; struct nsh_vtbl_s *bkgvtbl; @@ -1514,6 +1526,7 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) priority = min_priority; } } + param.sched_priority = priority; } @@ -1553,8 +1566,6 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) * * -1 (ERRROR) if the command was unsuccessful * 0 (OK) if the command was successful - * 1 if an application task was spawned successfully, but - * returned failure exit status. */ ret = nsh_execute(vtbl, argc, argv); @@ -1568,11 +1579,11 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline) nsh_undirect(vtbl, save); } - /* Treat both errors and non-zero return codes as "errors" so that - * it is possible to test for non-zero returns in nsh scripts. + /* Mark errors so that it is possible to test for non-zero return values + * in nsh scripts. */ - if (ret != OK) + if (ret < 0) { goto errout; } diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig index 794b3107d..cec10459a 100644 --- a/nuttx/configs/sim/nsh/defconfig +++ b/nuttx/configs/sim/nsh/defconfig @@ -73,7 +73,7 @@ CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=50000 CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SIG_SIGWORK=17 -CONFIG_SCHED_WAITPID=n +CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n CONFIG_SCHED_ONEXIT=n @@ -224,6 +224,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 # # Settings for apps/nshlib # +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=1024 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=80 diff --git a/nuttx/configs/vsn/src/README.txt b/nuttx/configs/vsn/src/README.txt index 87a538a10..732ede5e6 100644 --- a/nuttx/configs/vsn/src/README.txt +++ b/nuttx/configs/vsn/src/README.txt @@ -12,8 +12,7 @@ Execution starts in the following order: is set. It must be set for the VSN board. - boot, performs initial chip and board initialization - - sched/os_bringup.c then calls either user_start or exec_builtin() - with application as set in the .config + - sched/os_bringup.c then calls user entry defined in the .config file. Naming throughout the code diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 7164a9f8f..c10c28a5c 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -1314,15 +1314,16 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp) * file is re-opened. */ - newff->ff_bflags = 0; - newff->ff_oflags = oldff->ff_oflags; - newff->ff_sectorsincluster = oldff->ff_sectorsincluster; - newff->ff_dirindex = oldff->ff_dirindex; - newff->ff_currentcluster = oldff->ff_currentcluster; - newff->ff_dirsector = oldff->ff_dirsector; - newff->ff_size = oldff->ff_size; - newff->ff_currentsector = 0; - newff->ff_cachesector = 0; + newff->ff_bflags = 0; /* File buffer flags */ + newff->ff_oflags = oldff->ff_oflags; /* File open flags */ + newff->ff_sectorsincluster = oldff->ff_sectorsincluster; /* Sectors remaining in cluster */ + newff->ff_dirindex = oldff->ff_dirindex; /* Index to directory entry */ + newff->ff_currentcluster = oldff->ff_currentcluster; /* Current cluster */ + newff->ff_dirsector = oldff->ff_dirsector; /* Sector containing directory entry */ + newff->ff_size = oldff->ff_size; /* Size of the file */ + newff->ff_startcluster = oldff->ff_startcluster; /* Start cluster of file on media */ + newff->ff_currentsector = oldff->ff_currentsector; /* Current sector */ + newff->ff_cachesector = 0; /* Sector in file buffer */ /* Attach the private date to the struct file instance */ diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c index 2814aa49d..6a6fca355 100644 --- a/nuttx/fs/romfs/fs_romfs.c +++ b/nuttx/fs/romfs/fs_romfs.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -225,7 +226,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath, * file. */ - rf = (FAR struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s)); + rf = (FAR struct romfs_file_s *)kzalloc(sizeof(struct romfs_file_s)); if (!rf) { fdbg("Failed to allocate private data\n", ret); @@ -317,12 +318,12 @@ static int romfs_close(FAR struct file *filep) if (!rm->rm_xipbase && rf->rf_buffer) { - free(rf->rf_buffer); + kfree(rf->rf_buffer); } /* Then free the file structure itself. */ - free(rf); + kfree(rf); filep->f_priv = NULL; return ret; } @@ -915,7 +916,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, /* Create an instance of the mountpt state structure */ - rm = (FAR struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s)); + rm = (FAR struct romfs_mountpt_s *)kzalloc(sizeof(struct romfs_mountpt_s)); if (!rm) { fdbg("Failed to allocate mountpoint structure\n"); @@ -959,12 +960,12 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, errout_with_buffer: if (!rm->rm_xipbase) { - free(rm->rm_buffer); + kfree(rm->rm_buffer); } errout_with_sem: sem_destroy(&rm->rm_sem); - free(rm); + kfree(rm); return ret; } @@ -1031,11 +1032,11 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver) if (!rm->rm_xipbase && rm->rm_buffer) { - free(rm->rm_buffer); + kfree(rm->rm_buffer); } sem_destroy(&rm->rm_sem); - free(rm); + kfree(rm); return OK; } -- cgit v1.2.3 From 77efc9f9cdd5828ab724b3355f0f0737bb15b579 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 14:14:14 +0000 Subject: BINFS now supports open, close, and FIOC_FILENAME ioctl git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5522 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 4 + apps/builtin/binfs.c | 331 +++++++++------------------------------ apps/include/apps.h | 3 + nuttx/TODO | 21 ++- nuttx/binfmt/binfmt_execmodule.c | 14 +- nuttx/fs/nfs/nfs_vfsops.c | 61 +++++--- nuttx/fs/nxffs/nxffs_open.c | 3 +- nuttx/include/nuttx/fs/binfs.h | 80 ++++++++++ nuttx/include/nuttx/fs/ioctl.h | 1 + 9 files changed, 216 insertions(+), 302 deletions(-) create mode 100644 nuttx/include/nuttx/fs/binfs.h (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index ea4fcd07b..f91dc318b 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -469,3 +469,7 @@ * builtin/binfs.c: Add hooks for dup() method (not implemented). * builtin/exec_builtin.c, nshlib/nsh_parse.c, and nshlib/nsh_builtin.c: NSH now supports re-direction of I/O to files (but still not from). + * builtin/binfs.c: Greatly simplified (it is going to need to be + very lightweight). Now supports open, close, and a new ioctl to recover + the builtin filename. The latter will be needed to support a binfs + binfmt. diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c index 1fc2e7940..611e2b3bb 100644 --- a/apps/builtin/binfs.c +++ b/apps/builtin/binfs.c @@ -45,7 +45,6 @@ #include #include -#include #include #include #include @@ -53,8 +52,11 @@ #include #include +#include #include +#include + #include "builtin.h" #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_APPS_BINDIR) @@ -63,24 +65,12 @@ * Private Types ****************************************************************************/ -/* This structure represents the overall mountpoint state. An instance of this - * structure is retained as inode private data on each mountpoint that is - * mounted with a fat32 filesystem. - */ - -struct binfs_state_s -{ - sem_t bm_sem; /* Used to assume thread-safe access */ -}; - /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static void binfs_semtake(struct binfs_state_s *bm); -static inline void binfs_semgive(struct binfs_state_s *bm); static int binfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode); + int oflags, mode_t mode); static int binfs_close(FAR struct file *filep); static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); @@ -89,15 +79,19 @@ static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp); static int binfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir); -static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); -static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir); +static int binfs_readdir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); +static int binfs_rewinddir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); -static int binfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle); -static int binfs_unbind(void *handle, FAR struct inode **blkdriver); -static int binfs_statfs(struct inode *mountpt, struct statfs *buf); +static int binfs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle); +static int binfs_unbind(FAR void *handle, FAR struct inode **blkdriver); +static int binfs_statfs(FAR struct inode *mountpt, + FAR struct statfs *buf); -static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf); +static int binfs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf); /**************************************************************************** * Private Variables @@ -144,71 +138,42 @@ const struct mountpt_operations binfs_operations = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: binfs_semtake - ****************************************************************************/ - -static void binfs_semtake(struct binfs_state_s *bm) -{ - /* Take the semaphore (perhaps waiting) */ - - while (sem_wait(&bm->bm_sem) != 0) - { - /* The only case that an error should occur here is if - * the wait was awakened by a signal. - */ - - ASSERT(errno == EINTR); - } -} - -/**************************************************************************** - * Name: binfs_semgive - ****************************************************************************/ - -static inline void binfs_semgive(struct binfs_state_s *bm) -{ - sem_post(&bm->bm_sem); -} - /**************************************************************************** * Name: binfs_open ****************************************************************************/ -static int binfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode) +static int binfs_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode) { - struct binfs_state_s *bm; - int ret = -ENOSYS; + int index; fvdbg("Open '%s'\n", relpath); - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL); - - /* mountpoint private data from the inode reference from the file - * structure - */ - - bm = (struct binfs_state_s*)filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - /* BINFS is read-only. Any attempt to open with any kind of write * access is not permitted. */ if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) { - fdbg("Only O_RDONLY supported\n"); - ret = -EACCES; + fdbg("ERROR: Only O_RDONLY supported\n"); + return -EACCES; } - /* Save open-specific state in filep->f_priv */ + /* Check if the an entry exists with this name in the root directory. + * so the 'relpath' must be the name of the builtin function. + */ - /* Opening of elements within the pseudo-file system is not yet supported */ + index = builtin_isavail(relpath); + if (index < 0) + { + fdbg("ERROR: Builting %s does not exist\n", relpath); + return -ENOENT; + } - return ret; + /* Save the index as the open-specific state in filep->f_priv */ + + filep->f_priv = (FAR void *)index; + return OK; } /**************************************************************************** @@ -217,31 +182,8 @@ static int binfs_open(FAR struct file *filep, const char *relpath, static int binfs_close(FAR struct file *filep) { - struct binfs_state_s *bm; - int ret = -ENOSYS; - fvdbg("Closing\n"); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state from the struct file instance */ - /* bf = filep->f_priv; */ - - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* Free the open file state */ - /* free(bf); */ - - filep->f_priv = NULL; - - /* Since open() is not yet supported, neither is close(). */ - - return ret; + return OK; } /**************************************************************************** @@ -250,25 +192,10 @@ static int binfs_close(FAR struct file *filep) static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) { - struct binfs_state_s *bm; + /* Reading is not supported. Just return end-of-file */ fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); - - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state data from the struct file instance */ - /* bf = filep->f_priv; */ - - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* Since open is not yet supported, neither is reading */ - - return -ENOSYS; + return 0; } /**************************************************************************** @@ -277,25 +204,36 @@ static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { - struct binfs_state_s *bm; + int ret; fvdbg("cmd: %d arg: %08lx\n", cmd, arg); - /* Sanity checks */ - - DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL); - - /* Recover the open file state from the struct file instance */ - /* bf = filep->f_priv; */ + /* Only one IOCTL command is supported */ - /* Recover the file system state from the inode */ - - bm = filep->f_inode->i_private; - DEBUGASSERT(bm != NULL); + if (cmd == FIOC_FILENAME) + { + /* IN: FAR char const ** pointer + * OUT: Pointer to a persistent file name (Guaranteed to persist while + * the file is open). + */ - /* No ioctl commands yet supported */ + FAR const char **ptr = (FAR const char **)((uintptr_t)arg); + if (ptr == NULL) + { + ret = -EINVAL; + } + else + { + *ptr = g_builtins[(int)filep->f_priv].name; + ret = OK; + } + } + else + { + ret = -ENOTTY; + } - return -ENOTTY; + return ret; } /**************************************************************************** @@ -308,27 +246,12 @@ static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) { - struct binfs_state_s *bm; - int ret = -ENOSYS; - fvdbg("Dup %p->%p\n", oldp, newp); - /* Sanity checks */ - - DEBUGASSERT(oldp->f_priv == NULL && oldp->f_inode != NULL); - - /* mountpoint private data from the inode reference from the file - * structure - */ - - bm = (struct binfs_state_s*)oldp->f_inode->i_private; - DEBUGASSERT(bm != NULL); - - /* Opening of elements within the pseudo-file system is not yet supported - * and, hence, neither is dup'ing the opened file. - */ + /* Copy the index from the old to the new file structure */ - return ret; + newp->f_priv = oldp->f_priv; + return OK; } /**************************************************************************** @@ -342,36 +265,19 @@ static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) static int binfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir) { - struct binfs_state_s *bm; - int ret; - fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL"); - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - /* The requested directory must be the volume-relative "root" directory */ if (relpath && relpath[0] != '\0') { - ret = -ENOENT; - goto errout_with_semaphore; + return -ENOENT; } /* Set the index to the first entry */ dir->u.binfs.fb_index = 0; - ret = OK; - -errout_with_semaphore: - binfs_semgive(bm); - return ret; + return OK; } /**************************************************************************** @@ -383,19 +289,9 @@ errout_with_semaphore: static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) { - struct binfs_state_s *bm; unsigned int index; int ret; - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - /* Have we reached the end of the directory */ index = dir->u.binfs.fb_index; @@ -426,11 +322,10 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) * standard f_pos instead of our own private fb_index. */ - dir->u.binfs.fb_index = index; - ret = OK; + dir->u.binfs.fb_index = index; + ret = OK; } - binfs_semgive(bm); return ret; } @@ -443,22 +338,9 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) { - struct binfs_state_s *bm; - fvdbg("Entry\n"); - /* Sanity checks */ - - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); - - /* Recover the file system state from the inode instance */ - - bm = mountpt->i_private; - binfs_semtake(bm); - - dir->u.binfs.fb_index = 0; - - binfs_semgive(bm); + dir->u.binfs.fb_index = 0; return OK; } @@ -476,29 +358,7 @@ static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) static int binfs_bind(FAR struct inode *blkdriver, const void *data, void **handle) { - struct binfs_state_s *bm; - fvdbg("Entry\n"); - - /* Create an instance of the mountpt state structure */ - - bm = (struct binfs_state_s *)zalloc(sizeof(struct binfs_state_s)); - if (!bm) - { - fdbg("Failed to allocate mountpoint structure\n"); - return -ENOMEM; - } - - /* Initialize the allocated mountpt state structure. The filesystem is - * responsible for one reference ont the blkdriver inode and does not - * have to addref() here (but does have to release in ubind(). - */ - - sem_init(&bm->bm_sem, 0, 1); /* Initialize the semaphore that controls access */ - - /* Mounted! */ - - *handle = (void*)bm; return OK; } @@ -512,22 +372,7 @@ static int binfs_bind(FAR struct inode *blkdriver, const void *data, static int binfs_unbind(void *handle, FAR struct inode **blkdriver) { - struct binfs_state_s *bm = (struct binfs_state_s*)handle; - fvdbg("Entry\n"); - -#ifdef CONFIG_DEBUG - if (!bm) - { - return -EINVAL; - } -#endif - - /* Check if there are sill any files opened on the filesystem. */ - - /* Release the mountpoint private data */ - - sem_destroy(&bm->bm_sem); return OK; } @@ -540,19 +385,8 @@ static int binfs_unbind(void *handle, FAR struct inode **blkdriver) static int binfs_statfs(struct inode *mountpt, struct statfs *buf) { - struct binfs_state_s *bm; - fvdbg("Entry\n"); - /* Sanity checks */ - - DEBUGASSERT(mountpt && mountpt->i_private); - - /* Get the mountpoint private data from the inode structure */ - - bm = mountpt->i_private; - binfs_semtake(bm); - /* Fill in the statfs info */ memset(buf, 0, sizeof(struct statfs)); @@ -562,8 +396,6 @@ static int binfs_statfs(struct inode *mountpt, struct statfs *buf) buf->f_bfree = 0; buf->f_bavail = 0; buf->f_namelen = NAME_MAX; - - binfs_semgive(bm); return OK; } @@ -576,20 +408,8 @@ static int binfs_statfs(struct inode *mountpt, struct statfs *buf) static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) { - struct binfs_state_s *bm; - int ret; - fvdbg("Entry\n"); - /* Sanity checks */ - - DEBUGASSERT(mountpt && mountpt->i_private); - - /* Get the mountpoint private data from the inode structure */ - - bm = mountpt->i_private; - binfs_semtake(bm); - /* The requested directory must be the volume-relative "root" directory */ if (relpath && relpath[0] != '\0') @@ -598,8 +418,7 @@ static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *b if (builtin_isavail(relpath) < 0) { - ret = -ENOENT; - goto errout_with_semaphore; + return -ENOENT; } /* It's a execute-only file name */ @@ -615,14 +434,10 @@ static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *b /* File/directory size, access block size */ - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; - ret = OK; - -errout_with_semaphore: - binfs_semgive(bm); - return ret; + buf->st_size = 0; + buf->st_blksize = 0; + buf->st_blocks = 0; + return OK; } /**************************************************************************** diff --git a/apps/include/apps.h b/apps/include/apps.h index f806d8aed..9f1918e57 100644 --- a/apps/include/apps.h +++ b/apps/include/apps.h @@ -48,9 +48,12 @@ ****************************************************************************/ #include + #include #include +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/nuttx/TODO b/nuttx/TODO index 58ca4cc8e..248d2dafa 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -6,7 +6,7 @@ standards, things that could be improved, and ideas for enhancements. nuttx/ - (11) Task/Scheduler (sched/) + (10) Task/Scheduler (sched/) (1) Memory Managment (mm/) (3) Signals (sched/, arch/) (2) pthreads (sched/) @@ -58,16 +58,6 @@ o Task/Scheduler (sched/) Status: Closed. No, this behavior will not be implemented. Priority: Medium, required for good emulation of process/pthread model. - Title: MISSING ERRNO SETTINGS - Description: Several APIs do not set errno. Need to review all APIs. - Update: These are being fixed as they are encountered. There is - no accounting of how many interfaces have this problem. - Status: Open? There has been an effort over the past few years to assure - that all errno settings are in place. What is the current state? - Unknown. - Priority: Medium, required for standard compliance (but makes the - code bigger) - Title: TICKLESS OS Description: On a side note, I have thought about a tick-less timer for the OS for a long time. Basically we could replace the periodic system @@ -178,7 +168,14 @@ o Task/Scheduler (sched/) You would think that this should be a clone of the existing pthread join logic. Howver there is no need for zombies - in NuttX so, the status if the parent has already exit'ed. + in NuttX so no need to keep the status if the parent has + already exit'ed. Other simplifications: + + 1. Keep the array/list of return status in the parent + tasks TCB. + 2. Use a fixed size array of return status (perhaps the + the enire array is allocated so that that is con + penalty for tasks that have no childre. At present, exit status is not retained. If waitpid() is called after the child task has exit'ed it simpley diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c index 400451c40..df8da5343 100644 --- a/nuttx/binfmt/binfmt_execmodule.c +++ b/nuttx/binfmt/binfmt_execmodule.c @@ -1,7 +1,7 @@ /**************************************************************************** * binfmt/binfmt_execmodule.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include #include +#include #include #include "os_internal.h" @@ -167,7 +168,7 @@ int exec_module(FAR const struct binary_s *binp, int priority) /* Allocate a TCB for the new task. */ - tcb = (FAR _TCB*)zalloc(sizeof(_TCB)); + tcb = (FAR _TCB*)kzalloc(sizeof(_TCB)); if (!tcb) { err = ENOMEM; @@ -177,7 +178,7 @@ int exec_module(FAR const struct binary_s *binp, int priority) /* Allocate the stack for the new task */ #ifndef CONFIG_CUSTOM_STACK - stack = (FAR uint32_t*)malloc(binp->stacksize); + stack = (FAR uint32_t*)kmalloc(binp->stacksize); if (!tcb) { err = ENOMEM; @@ -201,6 +202,9 @@ int exec_module(FAR const struct binary_s *binp, int priority) goto errout_with_stack; } + /* Note that tcb->flags are not modified. 0=normal task */ + /* tcb->flags |= TCB_FLAG_TTYPE_TASK; */ + /* Add the D-Space address as the PIC base address. By convention, this * must be the first allocated address space. */ @@ -257,14 +261,14 @@ errout_with_stack: #ifndef CONFIG_CUSTOM_STACK tcb->stack_alloc_ptr = NULL; sched_releasetcb(tcb); - free(stack); + kfree(stack); #else sched_releasetcb(tcb); #endif goto errout; errout_with_tcb: - free(tcb); + kfree(tcb); errout: errno = err; bdbg("returning errno: %d\n", err); diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c index 01e999ac8..2ff4ff9d3 100644 --- a/nuttx/fs/nfs/nfs_vfsops.c +++ b/nuttx/fs/nfs/nfs_vfsops.c @@ -680,6 +680,7 @@ static int nfs_close(FAR struct file *filep) FAR struct nfsnode *np; FAR struct nfsnode *prev; FAR struct nfsnode *curr; + int ret; /* Sanity checks */ @@ -703,8 +704,7 @@ static int nfs_close(FAR struct file *filep) if (np->n_crefs > 1) { np->n_crefs--; - nfs_semgive(nmp); - return OK; + ret = OK; } /* There are no more references to the file structure. Now we need to @@ -714,38 +714,47 @@ static int nfs_close(FAR struct file *filep) * containted in the mount structure. */ - for (prev = NULL, curr = nmp->nm_head; curr; prev = curr, curr = curr->n_next) - { - /* Check if this node is ours */ + else + { + /* Assume file structure will not be found. This should never happen. */ + + ret = -EINVAL; - if (np == curr) - { - /* Yes.. remove it from the list of file structures */ + for (prev = NULL, curr = nmp->nm_head; + curr; + prev = curr, curr = curr->n_next) + { + /* Check if this node is ours */ + + if (np == curr) + { + /* Yes.. remove it from the list of file structures */ - if (prev) - { - /* Remove from mid-list */ + if (prev) + { + /* Remove from mid-list */ - prev->n_next = np->n_next; - } - else - { - /* Remove from the head of the list */ + prev->n_next = np->n_next; + } + else + { + /* Remove from the head of the list */ - nmp->nm_head = np->n_next; - } + nmp->nm_head = np->n_next; + } - /* Then deallocate the file structure and return success */ + /* Then deallocate the file structure and return success */ - kfree(np); - nfs_semgive(nmp); - return OK; - } - } + kfree(np); + ret = OK; + break; + } + } + } - fdbg("ERROR: file structure not found in list: %p\n", np); + filep->f_priv = NULL; nfs_semgive(nmp); - return EINVAL; + return ret; } /**************************************************************************** diff --git a/nuttx/fs/nxffs/nxffs_open.c b/nuttx/fs/nxffs/nxffs_open.c index b1e99267f..9fa4ef2e0 100644 --- a/nuttx/fs/nxffs/nxffs_open.c +++ b/nuttx/fs/nxffs/nxffs_open.c @@ -1188,9 +1188,10 @@ int nxffs_close(FAR struct file *filep) ofile->crefs--; } - filep->f_priv = NULL; + filep->f_priv = NULL; sem_post(&volume->exclsem); + errout: return ret; } diff --git a/nuttx/include/nuttx/fs/binfs.h b/nuttx/include/nuttx/fs/binfs.h new file mode 100644 index 000000000..6125384a9 --- /dev/null +++ b/nuttx/include/nuttx/fs/binfs.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * include/nuttx/fs/binfs.h + * + * Copyright (C) 2013 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_BINFS_H +#define __INCLUDE_NUTTX_FS_BINFS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* This is the BINFS ioctl that can be used to recover the filename + * associated with the builtin task. + */ + +#define FIOC_FILENAME FIOC_USER /* IN: FAR const char ** pointer + * OUT: Pointer to a persistent file name + * (Guaranteed to persist while the file + * is open). + */ + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_FS_BINFS_H */ diff --git a/nuttx/include/nuttx/fs/ioctl.h b/nuttx/include/nuttx/fs/ioctl.h index 19f29b1fb..8f2fdd7d9 100644 --- a/nuttx/include/nuttx/fs/ioctl.h +++ b/nuttx/include/nuttx/fs/ioctl.h @@ -105,6 +105,7 @@ #define FIOC_OPTIMIZE _FIOC(0x0003) /* IN: None * OUT: None */ +#define FIOC_USER _FIOC(0x0004) /* File system-specific */ /* NuttX file system ioctl definitions **************************************/ -- cgit v1.2.3 From 4f7967b4c678bef1a42eda3acf739c8bbefd9a07 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 15:41:27 +0000 Subject: apps/builtin/binfs.c moved to nuttx/fs/binfs/fs_binfs.c git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5523 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 + apps/builtin/Kconfig | 14 -- apps/builtin/Makefile | 4 - apps/builtin/binfs.c | 448 ----------------------------------- apps/builtin/builtin.c | 2 + apps/builtin/builtin.h | 77 ------ apps/builtin/exec_builtin.c | 3 +- apps/include/apps.h | 17 -- apps/nshlib/nsh_mntcmds.c | 2 +- nuttx/ChangeLog | 3 +- nuttx/configs/sim/README.txt | 7 +- nuttx/configs/sim/nsh/appconfig | 3 + nuttx/configs/sim/nsh/defconfig | 12 +- nuttx/configs/vsn/nsh/defconfig | 2 +- nuttx/fs/Kconfig | 3 +- nuttx/fs/Makefile | 15 +- nuttx/fs/binfs/Kconfig | 19 ++ nuttx/fs/binfs/Make.defs | 48 ++++ nuttx/fs/binfs/fs_binfs.c | 447 ++++++++++++++++++++++++++++++++++ nuttx/fs/fat/Make.defs | 9 +- nuttx/fs/fs_mount.c | 13 +- nuttx/fs/mmap/Make.defs | 9 +- nuttx/fs/nfs/Make.defs | 9 +- nuttx/fs/nxffs/Make.defs | 9 +- nuttx/fs/romfs/Make.defs | 9 +- nuttx/include/nuttx/binfmt/builtin.h | 85 +++++++ nuttx/include/nuttx/fs/binfs.h | 16 +- nuttx/include/nuttx/fs/dirent.h | 6 +- nuttx/tools/mkconfig.c | 6 +- 29 files changed, 694 insertions(+), 605 deletions(-) delete mode 100644 apps/builtin/binfs.c delete mode 100644 apps/builtin/builtin.h create mode 100644 nuttx/fs/binfs/Kconfig create mode 100644 nuttx/fs/binfs/Make.defs create mode 100644 nuttx/fs/binfs/fs_binfs.c create mode 100644 nuttx/include/nuttx/binfmt/builtin.h (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index f91dc318b..5bc3b2149 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -473,3 +473,5 @@ very lightweight). Now supports open, close, and a new ioctl to recover the builtin filename. The latter will be needed to support a binfs binfmt. + * builtin/binfs.c: Move apps/builtin/binfs.c to fs/binfs/fs_binfs.c + CONFIG_APPS_BINDIR rename CONFIG_FS_BINFS diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig index 1049712aa..37150e8a9 100644 --- a/apps/builtin/Kconfig +++ b/apps/builtin/Kconfig @@ -13,20 +13,6 @@ config BUILTIN if BUILTIN - config APPS_BINDIR - bool "BINFS File System" - default n - ---help--- - The BINFS file system is current just a toy. The BINFS may, for example, - be mount at /bin. Then all of the built-in applications will appear as - executable file in /bin if you list them from NSH like: - - nsh> ls -l /bin - - At present, the BINFS supports nothing more than that. It is planned, - however, to support execution of the builtin applications from BINFS as - well (via a binfmt/ loader). However, that is down the road. - config BUILTIN_PROXY_STACKSIZE int "Builtin Proxy Stack Size" default 1024 diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile index 8c8928886..d77054f41 100644 --- a/apps/builtin/Makefile +++ b/apps/builtin/Makefile @@ -41,10 +41,6 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = builtin.c exec_builtin.c -ifeq ($(CONFIG_APPS_BINDIR),y) -CSRCS += binfs.c -endif - AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c deleted file mode 100644 index 611e2b3bb..000000000 --- a/apps/builtin/binfs.c +++ /dev/null @@ -1,448 +0,0 @@ -/**************************************************************************** - * apps/builtin/binfs.c - * - * Copyright (C) 2011-2013 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 -#include - -#include -#include -#include - -#include - -#include "builtin.h" - -#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_APPS_BINDIR) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static int binfs_open(FAR struct file *filep, const char *relpath, - int oflags, mode_t mode); -static int binfs_close(FAR struct file *filep); -static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); -static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); - -static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp); - -static int binfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir); -static int binfs_readdir(FAR struct inode *mountpt, - FAR struct fs_dirent_s *dir); -static int binfs_rewinddir(FAR struct inode *mountpt, - FAR struct fs_dirent_s *dir); - -static int binfs_bind(FAR struct inode *blkdriver, FAR const void *data, - FAR void **handle); -static int binfs_unbind(FAR void *handle, FAR struct inode **blkdriver); -static int binfs_statfs(FAR struct inode *mountpt, - FAR struct statfs *buf); - -static int binfs_stat(FAR struct inode *mountpt, FAR const char *relpath, - FAR struct stat *buf); - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/* See fs_mount.c -- this structure is explicitly externed there. - * We use the old-fashioned kind of initializers so that this will compile - * with any compiler. - */ - -const struct mountpt_operations binfs_operations = -{ - binfs_open, /* open */ - binfs_close, /* close */ - binfs_read, /* read */ - NULL, /* write */ - NULL, /* seek */ - binfs_ioctl, /* ioctl */ - - NULL, /* sync */ - binfs_dup, /* dup */ - - binfs_opendir, /* opendir */ - NULL, /* closedir */ - binfs_readdir, /* readdir */ - binfs_rewinddir, /* rewinddir */ - - binfs_bind, /* bind */ - binfs_unbind, /* unbind */ - binfs_statfs, /* statfs */ - - NULL, /* unlink */ - NULL, /* mkdir */ - NULL, /* rmdir */ - NULL, /* rename */ - binfs_stat /* stat */ -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: binfs_open - ****************************************************************************/ - -static int binfs_open(FAR struct file *filep, FAR const char *relpath, - int oflags, mode_t mode) -{ - int index; - - fvdbg("Open '%s'\n", relpath); - - /* BINFS is read-only. Any attempt to open with any kind of write - * access is not permitted. - */ - - if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) - { - fdbg("ERROR: Only O_RDONLY supported\n"); - return -EACCES; - } - - /* Check if the an entry exists with this name in the root directory. - * so the 'relpath' must be the name of the builtin function. - */ - - index = builtin_isavail(relpath); - if (index < 0) - { - fdbg("ERROR: Builting %s does not exist\n", relpath); - return -ENOENT; - } - - /* Save the index as the open-specific state in filep->f_priv */ - - filep->f_priv = (FAR void *)index; - return OK; -} - -/**************************************************************************** - * Name: binfs_close - ****************************************************************************/ - -static int binfs_close(FAR struct file *filep) -{ - fvdbg("Closing\n"); - return OK; -} - -/**************************************************************************** - * Name: binfs_read - ****************************************************************************/ - -static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) -{ - /* Reading is not supported. Just return end-of-file */ - - fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); - return 0; -} - -/**************************************************************************** - * Name: binfs_ioctl - ****************************************************************************/ - -static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret; - - fvdbg("cmd: %d arg: %08lx\n", cmd, arg); - - /* Only one IOCTL command is supported */ - - if (cmd == FIOC_FILENAME) - { - /* IN: FAR char const ** pointer - * OUT: Pointer to a persistent file name (Guaranteed to persist while - * the file is open). - */ - - FAR const char **ptr = (FAR const char **)((uintptr_t)arg); - if (ptr == NULL) - { - ret = -EINVAL; - } - else - { - *ptr = g_builtins[(int)filep->f_priv].name; - ret = OK; - } - } - else - { - ret = -ENOTTY; - } - - return ret; -} - -/**************************************************************************** - * Name: binfs_dup - * - * Description: - * Duplicate open file data in the new file structure. - * - ****************************************************************************/ - -static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) -{ - fvdbg("Dup %p->%p\n", oldp, newp); - - /* Copy the index from the old to the new file structure */ - - newp->f_priv = oldp->f_priv; - return OK; -} - -/**************************************************************************** - * Name: binfs_opendir - * - * Description: - * Open a directory for read access - * - ****************************************************************************/ - -static int binfs_opendir(struct inode *mountpt, const char *relpath, - struct fs_dirent_s *dir) -{ - fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL"); - - /* The requested directory must be the volume-relative "root" directory */ - - if (relpath && relpath[0] != '\0') - { - return -ENOENT; - } - - /* Set the index to the first entry */ - - dir->u.binfs.fb_index = 0; - return OK; -} - -/**************************************************************************** - * Name: binfs_readdir - * - * Description: Read the next directory entry - * - ****************************************************************************/ - -static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) -{ - unsigned int index; - int ret; - - /* Have we reached the end of the directory */ - - index = dir->u.binfs.fb_index; - if (g_builtins[index].name == NULL) - { - /* We signal the end of the directory by returning the - * special error -ENOENT - */ - - fvdbg("Entry %d: End of directory\n", index); - ret = -ENOENT; - } - else - { - /* Save the filename and file type */ - - fvdbg("Entry %d: \"%s\"\n", index, g_builtins[index].name); - dir->fd_dir.d_type = DTYPE_FILE; - strncpy(dir->fd_dir.d_name, g_builtins[index].name, NAME_MAX+1); - - /* The application list is terminated by an entry with a NULL name. - * Therefore, there is at least one more entry in the list. - */ - - index++; - - /* Set up the next directory entry offset. NOTE that we could use the - * standard f_pos instead of our own private fb_index. - */ - - dir->u.binfs.fb_index = index; - ret = OK; - } - - return ret; -} - -/**************************************************************************** - * Name: binfs_rewindir - * - * Description: Reset directory read to the first entry - * - ****************************************************************************/ - -static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) -{ - fvdbg("Entry\n"); - - dir->u.binfs.fb_index = 0; - return OK; -} - -/**************************************************************************** - * Name: binfs_bind - * - * Description: This implements a portion of the mount operation. This - * function allocates and initializes the mountpoint private data and - * binds the blockdriver inode to the filesystem private data. The final - * binding of the private data (containing the blockdriver) to the - * mountpoint is performed by mount(). - * - ****************************************************************************/ - -static int binfs_bind(FAR struct inode *blkdriver, const void *data, - void **handle) -{ - fvdbg("Entry\n"); - return OK; -} - -/**************************************************************************** - * Name: binfs_unbind - * - * Description: This implements the filesystem portion of the umount - * operation. - * - ****************************************************************************/ - -static int binfs_unbind(void *handle, FAR struct inode **blkdriver) -{ - fvdbg("Entry\n"); - return OK; -} - -/**************************************************************************** - * Name: binfs_statfs - * - * Description: Return filesystem statistics - * - ****************************************************************************/ - -static int binfs_statfs(struct inode *mountpt, struct statfs *buf) -{ - fvdbg("Entry\n"); - - /* Fill in the statfs info */ - - memset(buf, 0, sizeof(struct statfs)); - buf->f_type = BINFS_MAGIC; - buf->f_bsize = 0; - buf->f_blocks = 0; - buf->f_bfree = 0; - buf->f_bavail = 0; - buf->f_namelen = NAME_MAX; - return OK; -} - -/**************************************************************************** - * Name: binfs_stat - * - * Description: Return information about a file or directory - * - ****************************************************************************/ - -static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) -{ - fvdbg("Entry\n"); - - /* The requested directory must be the volume-relative "root" directory */ - - if (relpath && relpath[0] != '\0') - { - /* Check if there is a file with this name. */ - - if (builtin_isavail(relpath) < 0) - { - return -ENOENT; - } - - /* It's a execute-only file name */ - - buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; - } - else - { - /* It's a read/execute-only directory name */ - - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; - } - - /* File/directory size, access block size */ - - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; - return OK; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_APPS_BINDIR */ - diff --git a/apps/builtin/builtin.c b/apps/builtin/builtin.c index e0ae9888a..90c0b1353 100644 --- a/apps/builtin/builtin.c +++ b/apps/builtin/builtin.c @@ -40,6 +40,8 @@ ****************************************************************************/ #include + +#include #include /**************************************************************************** diff --git a/apps/builtin/builtin.h b/apps/builtin/builtin.h deleted file mode 100644 index 4593809ee..000000000 --- a/apps/builtin/builtin.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** - * apps/builtin/builtin.h - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Authors: Uros Platise - * 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 __APPS_BUILTIN_BUILTIN_H -#define __APPS_BUILTIN_BUILTIN_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -EXTERN const struct builtin_s g_builtins[]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -EXTERN int number_builtins(void); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* __APPS_BUILTIN_BUILTIN_H */ - diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c index a3e79a945..6868d7ee7 100644 --- a/apps/builtin/exec_builtin.c +++ b/apps/builtin/exec_builtin.c @@ -53,10 +53,9 @@ #include #include +#include #include -#include "builtin.h" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/apps/include/apps.h b/apps/include/apps.h index 9f1918e57..0fb807c14 100644 --- a/apps/include/apps.h +++ b/apps/include/apps.h @@ -62,14 +62,6 @@ * Public Types ****************************************************************************/ -struct builtin_s -{ - const char *name; /* Invocation name and as seen under /sbin/ */ - int priority; /* Use: SCHED_PRIORITY_DEFAULT */ - int stacksize; /* Desired stack size */ - main_t main; /* Entry point: main(int argc, char *argv[]) */ -}; - /**************************************************************************** * Public Data ****************************************************************************/ @@ -82,15 +74,6 @@ extern "C" { #define EXTERN extern #endif -/* The "bindir" is file system that supports access to the builtin applications. - * It is typically mounted under /bin. - */ - -#ifdef CONFIG_APPS_BINDIR -EXTERN mountpt_operations; -EXTERN const struct mountpt_operations binfs_operations; -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/apps/nshlib/nsh_mntcmds.c b/apps/nshlib/nsh_mntcmds.c index f6eb26c31..b16ba8465 100644 --- a/apps/nshlib/nsh_mntcmds.c +++ b/apps/nshlib/nsh_mntcmds.c @@ -131,7 +131,7 @@ static int mount_handler(FAR const char *mountpoint, break; #endif -#ifdef CONFIG_APPS_BINDIR +#ifdef CONFIG_FS_BINFS case BINFS_MAGIC: fstype = "bindir"; break; diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 2d2cd8259..ed85f06e1 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3955,4 +3955,5 @@ * arch/mips/src/mips32/up_vfork.c, up_vfork.h, and vfork.S: Implement vfork() for MIPS32 (no floating point support) * configs/ubw32/ostest: Enable the vfork() test. - + * fs/binfs: Move apps/builtin/binfs.c to fs/binfs/fs_binfs.c + CONFIG_APPS_BINDIR rename CONFIG_FS_BINFS diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 8abfd9c23..165e92b96 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -270,8 +270,9 @@ nsh Description ----------- - Configures to use the NuttShell at apps/examples/nsh. This configuration - may be selected as follows: + Configures to use the NuttShell at apps/examples/nsh. This version has + one builtin function: This configuration: apps/examples/hello. This + configuration may be selected as follows: cd /tools ./configure.sh sim/nsh @@ -281,7 +282,7 @@ nsh2 Description ----------- This is another example that configures to use the NuttShell at apps/examples/nsh. - Unlike nsh, this version uses NSH built-in functions. The nx, nxhello, and + Like nsh, this version uses NSH built-in functions: The nx, nxhello, and nxlines examples are included as built-in functions. X11 Configuration diff --git a/nuttx/configs/sim/nsh/appconfig b/nuttx/configs/sim/nsh/appconfig index 264588e51..3f50f6818 100644 --- a/nuttx/configs/sim/nsh/appconfig +++ b/nuttx/configs/sim/nsh/appconfig @@ -42,3 +42,6 @@ CONFIGURED_APPS += examples/nsh CONFIGURED_APPS += system/readline CONFIGURED_APPS += nshlib +# Example built-in application + +CONFIGURED_APPS += examples/hello diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig index cec10459a..146519aa6 100644 --- a/nuttx/configs/sim/nsh/defconfig +++ b/nuttx/configs/sim/nsh/defconfig @@ -1,7 +1,7 @@ ############################################################################ # sim/nsh/defconfig # -# Copyright (C) 2008-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2008-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -46,7 +46,7 @@ CONFIG_ARCH_BOARD_SIM=y CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n -CONFIG_DEBUG_SYMBOLS=n +CONFIG_DEBUG_SYMBOLS=y CONFIG_HAVE_CXX=n CONFIG_HAVE_CXXINITIALIZE=n @@ -170,6 +170,7 @@ CONFIG_FAT_LFN=n CONFIG_FAT_MAXFNAME=32 CONFIG_FS_NXFFS=n CONFIG_FS_ROMFS=y +CONFIG_FS_BINFS=y # # TCP/IP and UDP support via uIP @@ -193,6 +194,11 @@ CONFIG_NET_STATISTICS=y #CONFIG_NET_ARPTAB_SIZE=8 CONFIG_NET_BROADCAST=n +# +# Settings for examples/hello +# +CONFIG_EXAMPLES_HELLO_BUILTIN=y + # # UIP Network Utilities # @@ -224,7 +230,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 # # Settings for apps/nshlib # -CONFIG_NSH_BUILTIN_APPS=n +CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=1024 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=80 diff --git a/nuttx/configs/vsn/nsh/defconfig b/nuttx/configs/vsn/nsh/defconfig index 5952f4724..5ec7e06eb 100755 --- a/nuttx/configs/vsn/nsh/defconfig +++ b/nuttx/configs/vsn/nsh/defconfig @@ -526,4 +526,4 @@ CONFIG_HEAP_SIZE= CONFIG_APPS_DIR="../apps" # Provide /dev/ramX and then: mount -t binfs /dev/ram0 /bin -CONFIG_APPS_BINDIR=y +CONFIG_FS_BINFS=y diff --git a/nuttx/fs/Kconfig b/nuttx/fs/Kconfig index 1d1046735..dfbfda3fa 100644 --- a/nuttx/fs/Kconfig +++ b/nuttx/fs/Kconfig @@ -5,11 +5,12 @@ comment "File system configuration" -source fs/fat/Kconfig source fs/mmap/Kconfig +source fs/fat/Kconfig source fs/nfs/Kconfig source fs/nxffs/Kconfig source fs/romfs/Kconfig +source fs/binfs/Kconfig comment "System Logging" diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile index 6955c164b..2a1fd75a8 100644 --- a/nuttx/fs/Makefile +++ b/nuttx/fs/Makefile @@ -1,7 +1,7 @@ ############################################################################ # fs/Makefile # -# Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2008, 2011-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -72,6 +72,9 @@ CSRCS += fs_registerdriver.c fs_unregisterdriver.c CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c \ fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c +DEPPATH = +VPATH = . + include mmap/Make.defs # Stream support @@ -91,13 +94,17 @@ endif # Additional files required is mount-able file systems are supported ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) + CSRCS += fs_fsync.c fs_mkdir.c fs_mount.c fs_rename.c fs_rmdir.c \ fs_umount.c fs_unlink.c CSRCS += fs_foreachmountpoint.c + include fat/Make.defs include romfs/Make.defs include nxffs/Make.defs include nfs/Make.defs +include binfs/Make.defs + endif endif @@ -108,8 +115,7 @@ OBJS = $(AOBJS) $(COBJS) BIN = libfs$(LIBEXT) -SUBDIRS = mmap fat romfs nxffs:nfs -VPATH = mmap:fat:romfs:nxffs:nfs +SUBDIRS = mmap fat romfs nxffs nfs binfs all: $(BIN) @@ -123,8 +129,7 @@ $(BIN): $(OBJS) $(call ARCHIVE, $@, $(OBJS)) .depend: Makefile $(SRCS) - $(Q) $(MKDEP) --dep-path . $(MMAPDEPPATH) $(FATDEPPATH) $(ROMFSDEPPATH) $(NXFFSDEPPATH) $(NFSDEPPATH) \ - "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) $(MKDEP) --dep-path . $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep $(Q) touch $@ depend: .depend diff --git a/nuttx/fs/binfs/Kconfig b/nuttx/fs/binfs/Kconfig new file mode 100644 index 000000000..eedbe497d --- /dev/null +++ b/nuttx/fs/binfs/Kconfig @@ -0,0 +1,19 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config FS_BINFS + bool "BINFS File System" + default n + depends on BUILTIN + ---help--- + The BINFS file system is provides access to builtin applications through + the NuttX file system. The BINFS may, for example, be mount at /bin. + Then all of the built-in applications will appear as executable files in + /bin. Then, for example, you list them from NSH like: + + nsh> ls -l /bin + + If the BINFS BINFMT loader is also enabled, then the builtin applications + can be executed through the normal mechanisms (posix_spawn(), exev(), etc.) diff --git a/nuttx/fs/binfs/Make.defs b/nuttx/fs/binfs/Make.defs new file mode 100644 index 000000000..a65b7367f --- /dev/null +++ b/nuttx/fs/binfs/Make.defs @@ -0,0 +1,48 @@ +############################################################################ +# fs/binfs/Make.defs +# +# Copyright (C) 2013 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. +# +############################################################################ + +ifeq ($(CONFIG_FS_BINFS),y) +# Files required for BINFS file system support + +ASRCS += +CSRCS += fs_binfs.c + +# Include BINFS build support + +DEPPATH += --dep-path binfs +VPATH += :binfs +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)binfs} + +endif diff --git a/nuttx/fs/binfs/fs_binfs.c b/nuttx/fs/binfs/fs_binfs.c new file mode 100644 index 000000000..2508719e7 --- /dev/null +++ b/nuttx/fs/binfs/fs_binfs.c @@ -0,0 +1,447 @@ +/**************************************************************************** + * fs/binfs/fs_binfs.c + * + * Copyright (C) 2011-2013 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 +#include + +#include +#include +#include +#include + +#include + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_BINFS) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int binfs_open(FAR struct file *filep, const char *relpath, + int oflags, mode_t mode); +static int binfs_close(FAR struct file *filep); +static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); +static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); + +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp); + +static int binfs_opendir(struct inode *mountpt, const char *relpath, + struct fs_dirent_s *dir); +static int binfs_readdir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); +static int binfs_rewinddir(FAR struct inode *mountpt, + FAR struct fs_dirent_s *dir); + +static int binfs_bind(FAR struct inode *blkdriver, FAR const void *data, + FAR void **handle); +static int binfs_unbind(FAR void *handle, FAR struct inode **blkdriver); +static int binfs_statfs(FAR struct inode *mountpt, + FAR struct statfs *buf); + +static int binfs_stat(FAR struct inode *mountpt, FAR const char *relpath, + FAR struct stat *buf); + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/* See fs_mount.c -- this structure is explicitly externed there. + * We use the old-fashioned kind of initializers so that this will compile + * with any compiler. + */ + +const struct mountpt_operations binfs_operations = +{ + binfs_open, /* open */ + binfs_close, /* close */ + binfs_read, /* read */ + NULL, /* write */ + NULL, /* seek */ + binfs_ioctl, /* ioctl */ + + NULL, /* sync */ + binfs_dup, /* dup */ + + binfs_opendir, /* opendir */ + NULL, /* closedir */ + binfs_readdir, /* readdir */ + binfs_rewinddir, /* rewinddir */ + + binfs_bind, /* bind */ + binfs_unbind, /* unbind */ + binfs_statfs, /* statfs */ + + NULL, /* unlink */ + NULL, /* mkdir */ + NULL, /* rmdir */ + NULL, /* rename */ + binfs_stat /* stat */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: binfs_open + ****************************************************************************/ + +static int binfs_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode) +{ + int index; + + fvdbg("Open '%s'\n", relpath); + + /* BINFS is read-only. Any attempt to open with any kind of write + * access is not permitted. + */ + + if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) + { + fdbg("ERROR: Only O_RDONLY supported\n"); + return -EACCES; + } + + /* Check if the an entry exists with this name in the root directory. + * so the 'relpath' must be the name of the builtin function. + */ + + index = builtin_isavail(relpath); + if (index < 0) + { + fdbg("ERROR: Builting %s does not exist\n", relpath); + return -ENOENT; + } + + /* Save the index as the open-specific state in filep->f_priv */ + + filep->f_priv = (FAR void *)index; + return OK; +} + +/**************************************************************************** + * Name: binfs_close + ****************************************************************************/ + +static int binfs_close(FAR struct file *filep) +{ + fvdbg("Closing\n"); + return OK; +} + +/**************************************************************************** + * Name: binfs_read + ****************************************************************************/ + +static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen) +{ + /* Reading is not supported. Just return end-of-file */ + + fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos); + return 0; +} + +/**************************************************************************** + * Name: binfs_ioctl + ****************************************************************************/ + +static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + int ret; + + fvdbg("cmd: %d arg: %08lx\n", cmd, arg); + + /* Only one IOCTL command is supported */ + + if (cmd == FIOC_FILENAME) + { + /* IN: FAR char const ** pointer + * OUT: Pointer to a persistent file name (Guaranteed to persist while + * the file is open). + */ + + FAR const char **ptr = (FAR const char **)((uintptr_t)arg); + if (ptr == NULL) + { + ret = -EINVAL; + } + else + { + *ptr = g_builtins[(int)filep->f_priv].name; + ret = OK; + } + } + else + { + ret = -ENOTTY; + } + + return ret; +} + +/**************************************************************************** + * Name: binfs_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Copy the index from the old to the new file structure */ + + newp->f_priv = oldp->f_priv; + return OK; +} + +/**************************************************************************** + * Name: binfs_opendir + * + * Description: + * Open a directory for read access + * + ****************************************************************************/ + +static int binfs_opendir(struct inode *mountpt, const char *relpath, + struct fs_dirent_s *dir) +{ + fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL"); + + /* The requested directory must be the volume-relative "root" directory */ + + if (relpath && relpath[0] != '\0') + { + return -ENOENT; + } + + /* Set the index to the first entry */ + + dir->u.binfs.fb_index = 0; + return OK; +} + +/**************************************************************************** + * Name: binfs_readdir + * + * Description: Read the next directory entry + * + ****************************************************************************/ + +static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) +{ + unsigned int index; + int ret; + + /* Have we reached the end of the directory */ + + index = dir->u.binfs.fb_index; + if (g_builtins[index].name == NULL) + { + /* We signal the end of the directory by returning the + * special error -ENOENT + */ + + fvdbg("Entry %d: End of directory\n", index); + ret = -ENOENT; + } + else + { + /* Save the filename and file type */ + + fvdbg("Entry %d: \"%s\"\n", index, g_builtins[index].name); + dir->fd_dir.d_type = DTYPE_FILE; + strncpy(dir->fd_dir.d_name, g_builtins[index].name, NAME_MAX+1); + + /* The application list is terminated by an entry with a NULL name. + * Therefore, there is at least one more entry in the list. + */ + + index++; + + /* Set up the next directory entry offset. NOTE that we could use the + * standard f_pos instead of our own private fb_index. + */ + + dir->u.binfs.fb_index = index; + ret = OK; + } + + return ret; +} + +/**************************************************************************** + * Name: binfs_rewindir + * + * Description: Reset directory read to the first entry + * + ****************************************************************************/ + +static int binfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) +{ + fvdbg("Entry\n"); + + dir->u.binfs.fb_index = 0; + return OK; +} + +/**************************************************************************** + * Name: binfs_bind + * + * Description: This implements a portion of the mount operation. This + * function allocates and initializes the mountpoint private data and + * binds the blockdriver inode to the filesystem private data. The final + * binding of the private data (containing the blockdriver) to the + * mountpoint is performed by mount(). + * + ****************************************************************************/ + +static int binfs_bind(FAR struct inode *blkdriver, const void *data, + void **handle) +{ + fvdbg("Entry\n"); + return OK; +} + +/**************************************************************************** + * Name: binfs_unbind + * + * Description: This implements the filesystem portion of the umount + * operation. + * + ****************************************************************************/ + +static int binfs_unbind(void *handle, FAR struct inode **blkdriver) +{ + fvdbg("Entry\n"); + return OK; +} + +/**************************************************************************** + * Name: binfs_statfs + * + * Description: Return filesystem statistics + * + ****************************************************************************/ + +static int binfs_statfs(struct inode *mountpt, struct statfs *buf) +{ + fvdbg("Entry\n"); + + /* Fill in the statfs info */ + + memset(buf, 0, sizeof(struct statfs)); + buf->f_type = BINFS_MAGIC; + buf->f_bsize = 0; + buf->f_blocks = 0; + buf->f_bfree = 0; + buf->f_bavail = 0; + buf->f_namelen = NAME_MAX; + return OK; +} + +/**************************************************************************** + * Name: binfs_stat + * + * Description: Return information about a file or directory + * + ****************************************************************************/ + +static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf) +{ + fvdbg("Entry\n"); + + /* The requested directory must be the volume-relative "root" directory */ + + if (relpath && relpath[0] != '\0') + { + /* Check if there is a file with this name. */ + + if (builtin_isavail(relpath) < 0) + { + return -ENOENT; + } + + /* It's a execute-only file name */ + + buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; + } + else + { + /* It's a read/execute-only directory name */ + + buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; + } + + /* File/directory size, access block size */ + + buf->st_size = 0; + buf->st_blksize = 0; + buf->st_blocks = 0; + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_BINFS */ + diff --git a/nuttx/fs/fat/Make.defs b/nuttx/fs/fat/Make.defs index 136302b86..2769ab602 100644 --- a/nuttx/fs/fat/Make.defs +++ b/nuttx/fs/fat/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # Make.defs # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011, 2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -44,7 +44,10 @@ CSRCS += fs_fat32.c fs_fat32dirent.c fs_fat32attrib.c fs_fat32util.c ASRCS += CSRCS += fs_mkfatfs.c fs_configfat.c fs_writefat.c -# Argument for dependency checking +# Include FAT build support + +DEPPATH += --dep-path fat +VPATH += :fat +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)fat} -FATDEPPATH = --dep-path fat endif diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c index 228c1fc6e..1b3da8dc3 100644 --- a/nuttx/fs/fs_mount.c +++ b/nuttx/fs/fs_mount.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_mount.c * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,10 +47,6 @@ #include -#ifdef CONFIG_APPS_BINDIR -# include -#endif - #include "fs_internal.h" /* At least one filesystem must be defined, or this file will not compile. @@ -78,7 +74,7 @@ /* These file systems do not require block drivers */ -#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_APPS_BINDIR) || defined(CONFIG_NFS) +#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || defined(CONFIG_NFS) # define NONBDFS_SUPPORT #endif @@ -123,6 +119,9 @@ extern const struct mountpt_operations nxffs_operations; #ifdef CONFIG_NFS extern const struct mountpt_operations nfs_operations; #endif +#ifdef CONFIG_FS_BINFS +extern const struct mountpt_operations binfs_operations; +#endif static const struct fsmap_t g_nonbdfsmap[] = { @@ -132,7 +131,7 @@ static const struct fsmap_t g_nonbdfsmap[] = #ifdef CONFIG_NFS { "nfs", &nfs_operations }, #endif -#ifdef CONFIG_APPS_BINDIR +#ifdef CONFIG_FS_BINFS { "binfs", &binfs_operations }, #endif { NULL, NULL }, diff --git a/nuttx/fs/mmap/Make.defs b/nuttx/fs/mmap/Make.defs index 59857fe9c..b85d9f60f 100644 --- a/nuttx/fs/mmap/Make.defs +++ b/nuttx/fs/mmap/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # fs/mmap/Make.defs # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -40,4 +40,9 @@ ifeq ($(CONFIG_FS_RAMMAP),y) CSRCS += fs_munmap.c fs_rammap.c endif -MMAPDEPPATH = --dep-path mmap +# Include MMAP build support + +DEPPATH += --dep-path mmap +VPATH += :mmap +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)mmap} + diff --git a/nuttx/fs/nfs/Make.defs b/nuttx/fs/nfs/Make.defs index fc4682f85..ec2177fcf 100644 --- a/nuttx/fs/nfs/Make.defs +++ b/nuttx/fs/nfs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # Make.defs # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -44,7 +44,10 @@ CSRCS += ASRCS += CSRCS += rpc_clnt.c nfs_util.c nfs_vfsops.c -# Argument for dependency checking +# Include NFS build support + +DEPPATH += --dep-path nfs +VPATH += :nfs +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)nfs} -NFSDEPPATH = --dep-path nfs endif diff --git a/nuttx/fs/nxffs/Make.defs b/nuttx/fs/nxffs/Make.defs index b67ae4472..ccf1ba661 100644 --- a/nuttx/fs/nxffs/Make.defs +++ b/nuttx/fs/nxffs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # fs/nxffs/Make.defs # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -40,7 +40,10 @@ CSRCS += nxffs_block.c nxffs_blockstats.c nxffs_cache.c nxffs_dirent.c \ nxffs_open.c nxffs_pack.c nxffs_read.c nxffs_reformat.c \ nxffs_stat.c nxffs_unlink.c nxffs_util.c nxffs_write.c -# Argument for dependency checking +# Include NXFFS build support + +DEPPATH += --dep-path nxffs +VPATH += :nxffs +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)nxffs} -NXFFSDEPPATH = --dep-path nxffs endif diff --git a/nuttx/fs/romfs/Make.defs b/nuttx/fs/romfs/Make.defs index 77de93c05..e87cbdf9e 100644 --- a/nuttx/fs/romfs/Make.defs +++ b/nuttx/fs/romfs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # fs/romfs/Make.defs # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011, 2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -39,7 +39,10 @@ ifeq ($(CONFIG_FS_ROMFS),y) ASRCS += CSRCS += fs_romfs.c fs_romfsutil.c -# Argument for dependency checking +# Include ROMFS build support + +DEPPATH += --dep-path romfs +VPATH += :romfs +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)romfs} -ROMFSDEPPATH = --dep-path romfs endif diff --git a/nuttx/include/nuttx/binfmt/builtin.h b/nuttx/include/nuttx/binfmt/builtin.h new file mode 100644 index 000000000..c27605cac --- /dev/null +++ b/nuttx/include/nuttx/binfmt/builtin.h @@ -0,0 +1,85 @@ +/**************************************************************************** + * include/nuttx/binfmt/builtin.h + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Authors: Uros Platise + * 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_BINFMT_BUILTIN_H +#define __INCLUDE_NUTTX_BINFMT_BUILTIN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct builtin_s +{ + const char *name; /* Invocation name and as seen under /sbin/ */ + int priority; /* Use: SCHED_PRIORITY_DEFAULT */ + int stacksize; /* Desired stack size */ + main_t main; /* Entry point: main(int argc, char *argv[]) */ +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN const struct builtin_s g_builtins[]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +EXTERN int number_builtins(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __INCLUDE_NUTTX_BINFMT_BUILTIN_H */ + diff --git a/nuttx/include/nuttx/fs/binfs.h b/nuttx/include/nuttx/fs/binfs.h index 6125384a9..df92375e3 100644 --- a/nuttx/include/nuttx/fs/binfs.h +++ b/nuttx/include/nuttx/fs/binfs.h @@ -44,6 +44,8 @@ #include +#ifdef CONFIG_FS_BINFS + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -62,7 +64,7 @@ ****************************************************************************/ /**************************************************************************** - * Public Function Prototypes + * Public Data ****************************************************************************/ #ifdef __cplusplus @@ -72,9 +74,21 @@ extern "C" { #define EXTERN extern #endif +/* The "bindir" is file system that supports access to the builtin applications. + * It is typically mounted under /bin. + */ + +EXTERN mountpt_operations; +EXTERN const struct mountpt_operations binfs_operations; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + #undef EXTERN #ifdef __cplusplus } #endif +#endif /* CONFIG_FS_BINFS */ #endif /* __INCLUDE_NUTTX_FS_BINFS_H */ diff --git a/nuttx/include/nuttx/fs/dirent.h b/nuttx/include/nuttx/fs/dirent.h index 75867c87a..f8d356850 100644 --- a/nuttx/include/nuttx/fs/dirent.h +++ b/nuttx/include/nuttx/fs/dirent.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fs/dirent.h * - * Copyright (C) 2007, 2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ struct fs_romfsdir_s }; #endif /* CONFIG_FS_ROMFS */ -#ifdef CONFIG_APPS_BINDIR +#ifdef CONFIG_FS_BINFS /* The apps/ pseudo bin/ directory. The state value is simply an index */ struct fs_binfsdir_s @@ -179,7 +179,7 @@ struct fs_dirent_s #ifdef CONFIG_FS_ROMFS struct fs_romfsdir_s romfs; #endif -#ifdef CONFIG_APPS_BINDIR +#ifdef CONFIG_FS_BINFS struct fs_binfsdir_s binfs; #endif #ifdef CONFIG_FS_NXFFS diff --git a/nuttx/tools/mkconfig.c b/nuttx/tools/mkconfig.c index f4a1168c5..fe3e00491 100644 --- a/nuttx/tools/mkconfig.c +++ b/nuttx/tools/mkconfig.c @@ -1,7 +1,7 @@ /**************************************************************************** * tools/mkconfig.c * - * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -213,14 +213,14 @@ int main(int argc, char **argv, char **envp) printf("# undef CONFIG_FS_FAT\n"); printf("# undef CONFIG_FS_ROMFS\n"); printf("# undef CONFIG_FS_NXFFS\n"); - printf("# undef CONFIG_APPS_BINDIR\n"); + printf("# undef CONFIG_FS_BINFS\n"); printf("# undef CONFIG_NFS\n"); printf("#endif\n\n"); printf("/* Check if any readable and writable filesystem (OR USB storage) is supported */\n\n"); printf("#undef CONFIG_FS_READABLE\n"); printf("#undef CONFIG_FS_WRITABLE\n"); printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_FS_ROMFS) || defined(CONFIG_USBMSC) || \\\n"); - printf(" defined(CONFIG_FS_NXFFS) || defined(CONFIG_APPS_BINDIR) || defined(CONFIG_NFS)\n"); + printf(" defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || defined(CONFIG_NFS)\n"); printf("# define CONFIG_FS_READABLE 1\n"); printf("#endif\n\n"); printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_USBMSC) || defined(CONFIG_FS_NXFFS) || \\\n"); -- cgit v1.2.3 From 38efdf0ce37cc3413acee30d966f242aa8a77acd Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 17:05:00 +0000 Subject: Rename apps/include/apps.h to builtin.h. Move parts of apps/builtins/exec_builtin.c to binfmt/libbuiltin/libbuiltin_utils.c git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5524 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 6 ++ apps/README.txt | 3 +- apps/builtin/Kconfig | 10 +- apps/builtin/builtin.c | 1 - apps/builtin/exec_builtin.c | 46 +-------- apps/include/apps.h | 148 ----------------------------- apps/include/builtin.h | 111 ++++++++++++++++++++++ apps/nshlib/Kconfig | 2 +- apps/nshlib/nsh_builtin.c | 3 +- apps/nshlib/nsh_parse.c | 2 +- nuttx/ChangeLog | 5 + nuttx/Documentation/NuttShell.html | 2 +- nuttx/binfmt/Kconfig | 14 +++ nuttx/binfmt/Makefile | 3 +- nuttx/binfmt/libbuiltin/Kconfig | 4 + nuttx/binfmt/libbuiltin/Make.defs | 49 ++++++++++ nuttx/binfmt/libbuiltin/libbuiltin_utils.c | 121 +++++++++++++++++++++++ nuttx/fs/binfs/fs_binfs.c | 3 +- nuttx/include/nuttx/binfmt/builtin.h | 81 +++++++++++++++- nuttx/include/nuttx/fs/binfs.h | 11 --- nuttx/include/nuttx/fs/ioctl.h | 6 +- 21 files changed, 402 insertions(+), 229 deletions(-) delete mode 100644 apps/include/apps.h create mode 100644 apps/include/builtin.h create mode 100644 nuttx/binfmt/libbuiltin/Kconfig create mode 100644 nuttx/binfmt/libbuiltin/Make.defs create mode 100644 nuttx/binfmt/libbuiltin/libbuiltin_utils.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 5bc3b2149..6faac9e4b 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -475,3 +475,9 @@ binfmt. * builtin/binfs.c: Move apps/builtin/binfs.c to fs/binfs/fs_binfs.c CONFIG_APPS_BINDIR rename CONFIG_FS_BINFS + * apps/include/builtin.h: Some of the content of + apps/include/apps.h moved to include/nuttx/binfmt/builtin.h. + apps/include/apps.h renamed builtin.h + * pps/builtin/exec_builtins.c: Move utility builtin + utility functions from apps/builtin/exec_builtins.c to + binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file diff --git a/apps/README.txt b/apps/README.txt index 4a336abdb..55accfcf6 100644 --- a/apps/README.txt +++ b/apps/README.txt @@ -7,7 +7,6 @@ Contents General Directory Location Built-In Applications - Built-In Startup main() function NuttShell (NSH) Built-In Commands Synchronous Built-In Commands Application Configuration File @@ -62,7 +61,7 @@ collected during the make context build phase. To execute an application function: - exec_builtin() is defined in the nuttx/include/apps/apps.h + exec_builtin() is defined in the nuttx/include/apps/builtin.h NuttShell (NSH) Built-In Commands --------------------------------- diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig index 37150e8a9..c3371d708 100644 --- a/apps/builtin/Kconfig +++ b/apps/builtin/Kconfig @@ -3,21 +3,13 @@ # see misc/tools/kconfig-language.txt. # -config BUILTIN - bool "Support Builtin Applications" - default n - ---help--- - Enable support for builtin applications. This features assigns a string - name to an application. This feature is also the underlying requirement - to support built-in applications in the NuttShell (NSH). - if BUILTIN config BUILTIN_PROXY_STACKSIZE int "Builtin Proxy Stack Size" default 1024 ---help--- - If exec_builting uses I/O redirection options, then it will require + If exec_builtin uses I/O redirection options, then it will require an intermediary/proxy task to muck with the file descriptors. This configuration item specifies the stack size used for the proxy. Default: 1024 bytes. diff --git a/apps/builtin/builtin.c b/apps/builtin/builtin.c index 90c0b1353..7655a531d 100644 --- a/apps/builtin/builtin.c +++ b/apps/builtin/builtin.c @@ -42,7 +42,6 @@ #include #include -#include /**************************************************************************** * Private Types diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c index 6868d7ee7..05648590d 100644 --- a/apps/builtin/exec_builtin.c +++ b/apps/builtin/exec_builtin.c @@ -54,7 +54,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions @@ -365,50 +365,6 @@ errout: * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: builtin_getname - * - * Description: - * Return the name of the application at index in the table of builtin - * applications. - * - ****************************************************************************/ - -const char *builtin_getname(int index) -{ - if (index < 0 || index >= number_builtins()) - { - return NULL; - } - - return g_builtins[index].name; -} - -/**************************************************************************** - * Name: builtin_isavail - * - * Description: - * Return the index into the table of applications for the applicaiton with - * the name 'appname'. - * - ****************************************************************************/ - -int builtin_isavail(FAR const char *appname) -{ - int i; - - for (i = 0; g_builtins[i].name; i++) - { - if (!strcmp(g_builtins[i].name, appname)) - { - return i; - } - } - - set_errno(ENOENT); - return ERROR; -} - /**************************************************************************** * Name: exec_builtin * diff --git a/apps/include/apps.h b/apps/include/apps.h deleted file mode 100644 index 0fb807c14..000000000 --- a/apps/include/apps.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** - * apps/include/apps.h - * - * Originally by: - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Uros Platise - * - * With subsequent updates, modifications, and general maintenance by: - * - * Copyright (C) 2012-2013 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 __APPS_INCLUDE_APPS_H -#define __APPS_INCLUDE_APPS_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: builtin_isavail - * - * Description: - * Checks for availabiliy of application registerred during compile time. - * - * Input Parameter: - * filename - Name of the linked-in binary to be started. - * - * Returned Value: - * This is an end-user function, so it follows the normal convention: - * Returns index of builtin application. If it is not found then it - * returns -1 (ERROR) and sets errno appropriately. - * - ****************************************************************************/ - -EXTERN int builtin_isavail(FAR const char *appname); - -/**************************************************************************** - * Name: builtin_getname - * - * Description: - * Returns pointer to a name of built-in application pointed by the - * index. - * - * Input Parameter: - * index, from 0 and on ... - * - * Returned Value: - * Returns valid pointer pointing to the app name if index is valid. - * Otherwise NULL is returned. - * - ****************************************************************************/ - -EXTERN const char *builtin_getname(int index); - -/**************************************************************************** - * Name: exec_builtin - * - * Description: - * Executes builtin applications registered during 'make context' time. - * New application is run in a separate task context (and thread). - * - * Input Parameter: - * filename - Name of the linked-in binary to be started. - * argv - Argument list - * redirfile - If output if redirected, this parameter will be non-NULL - * and will provide the full path to the file. - * oflags - If output is redirected, this parameter will provide the - * open flags to use. This will support file replacement - * of appending to an existing file. - * - * Returned Value: - * This is an end-user function, so it follows the normal convention: - * Returns the PID of the exec'ed module. On failure, it.returns - * -1 (ERROR) and sets errno appropriately. - * - ****************************************************************************/ - -EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv, - FAR const char *redirfile, int oflags); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* __APPS_INCLUDE_APPS_H */ diff --git a/apps/include/builtin.h b/apps/include/builtin.h new file mode 100644 index 000000000..24cf204fa --- /dev/null +++ b/apps/include/builtin.h @@ -0,0 +1,111 @@ +/**************************************************************************** + * apps/include/builtin.h + * + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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 __APPS_INCLUDE_BUILTIN_H +#define __APPS_INCLUDE_BUILTIN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: exec_builtin + * + * Description: + * Executes builtin applications registered during 'make context' time. + * New application is run in a separate task context (and thread). + * + * Input Parameter: + * filename - Name of the linked-in binary to be started. + * argv - Argument list + * redirfile - If output if redirected, this parameter will be non-NULL + * and will provide the full path to the file. + * oflags - If output is redirected, this parameter will provide the + * open flags to use. This will support file replacement + * of appending to an existing file. + * + * Returned Value: + * This is an end-user function, so it follows the normal convention: + * Returns the PID of the exec'ed module. On failure, it.returns + * -1 (ERROR) and sets errno appropriately. + * + ****************************************************************************/ + +EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv, + FAR const char *redirfile, int oflags); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __APPS_INCLUDE_BUILTIN_H */ diff --git a/apps/nshlib/Kconfig b/apps/nshlib/Kconfig index e60e9c480..9cfc020a5 100644 --- a/apps/nshlib/Kconfig +++ b/apps/nshlib/Kconfig @@ -15,7 +15,7 @@ if NSH_LIBRARY config NSH_BUILTIN_APPS bool "Enable built-in applications" default y - depends on BUILTIN + select BUILTIN ---help--- Support external registered, "built-in" applications that can be executed from the NSH command line (see apps/README.txt for diff --git a/apps/nshlib/nsh_builtin.c b/apps/nshlib/nsh_builtin.c index 16e3e9427..ba39e8dfe 100644 --- a/apps/nshlib/nsh_builtin.c +++ b/apps/nshlib/nsh_builtin.c @@ -54,7 +54,8 @@ #include #include -#include +#include +#include #include "nsh.h" #include "nsh_console.h" diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index 15723b497..c36724372 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -59,7 +59,7 @@ #endif #ifdef CONFIG_NSH_BUILTIN_APPS -# include +# include #endif #include diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index ed85f06e1..57925a8b3 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3957,3 +3957,8 @@ * configs/ubw32/ostest: Enable the vfork() test. * fs/binfs: Move apps/builtin/binfs.c to fs/binfs/fs_binfs.c CONFIG_APPS_BINDIR rename CONFIG_FS_BINFS + * include/nuttx/binfmt/builtin.h: Some of the content of + apps/include/apps.h moved to include/nuttx/binfmt/builtin.h + * binfmt/libbuiltin/libbuiltin_utils.c: Move utility builtin + utility functions from apps/builtin/exec_builtins.c to + binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 95a75b22c..273898476 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -3261,7 +3261,7 @@ Builtin Apps:

          Built-In Application Utility Functions. - The utility functions exported by the builtin application logic are prototyped in apps/include/apps.h. + The utility functions exported by the builtin application logic are prototyped in nuttx/include/nuttx/binfmt/builtin.h and apps/include/builtin.h. These utility functions include:

          diff --git a/nuttx/binfmt/Kconfig b/nuttx/binfmt/Kconfig index 495bd050f..8d6c0bb18 100644 --- a/nuttx/binfmt/Kconfig +++ b/nuttx/binfmt/Kconfig @@ -49,6 +49,20 @@ if ELF source binfmt/libelf/Kconfig endif +config BUILTIN + bool "Support Builtin Applications" + default n + ---help--- + Enable support for builtin applications. This features assigns a string + name to an application and in addition if FS_BINFS is defined, retaining + those names in a file system from which they can be executed. This feature + is also the underlying requirement to support built-in applications in the + NuttShell (NSH). + +if BUILTIN +source binfmt/libbuiltin/Kconfig +endif + endif config PIC diff --git a/nuttx/binfmt/Makefile b/nuttx/binfmt/Makefile index 8ec0d877c..49dcd3d32 100644 --- a/nuttx/binfmt/Makefile +++ b/nuttx/binfmt/Makefile @@ -1,7 +1,7 @@ ############################################################################ # nxflat/Makefile # -# Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -65,6 +65,7 @@ DEPPATH = --dep-path . include libnxflat$(DELIM)Make.defs include libelf$(DELIM)Make.defs +include libbuiltin$(DELIM)Make.defs BINFMT_AOBJS = $(BINFMT_ASRCS:.S=$(OBJEXT)) BINFMT_COBJS = $(BINFMT_CSRCS:.c=$(OBJEXT)) diff --git a/nuttx/binfmt/libbuiltin/Kconfig b/nuttx/binfmt/libbuiltin/Kconfig new file mode 100644 index 000000000..ae2bf3130 --- /dev/null +++ b/nuttx/binfmt/libbuiltin/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# diff --git a/nuttx/binfmt/libbuiltin/Make.defs b/nuttx/binfmt/libbuiltin/Make.defs new file mode 100644 index 000000000..1d129294c --- /dev/null +++ b/nuttx/binfmt/libbuiltin/Make.defs @@ -0,0 +1,49 @@ +############################################################################ +# binfmt/libbuiltin/Make.defs +# +# Copyright (C) 2013 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. +# +############################################################################ + +# Legacy configurations don't set CONFIG_BUILTIN +# ifeq ($(CONFIG_BUILTIN),y) + +# Builtin application interfaces + +BINFMT_CSRCS += libbuiltin_utils.c + +# Hook the libelf subdirectory into the build + +VPATH += libbuiltin +SUBDIRS += libbuiltin +DEPPATH += --dep-path libbuiltin + +# endif diff --git a/nuttx/binfmt/libbuiltin/libbuiltin_utils.c b/nuttx/binfmt/libbuiltin/libbuiltin_utils.c new file mode 100644 index 000000000..b53becff9 --- /dev/null +++ b/nuttx/binfmt/libbuiltin/libbuiltin_utils.c @@ -0,0 +1,121 @@ +/**************************************************************************** + * binfmt/libbuiltin/libbuiltin_utils.c + * + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_getname + * + * Description: + * Return the name of the application at index in the table of builtin + * applications. + * + ****************************************************************************/ + +FAR const char *builtin_getname(int index) +{ + if (index < 0 || index >= number_builtins()) + { + return NULL; + } + + return g_builtins[index].name; +} + +/**************************************************************************** + * Name: builtin_isavail + * + * Description: + * Return the index into the table of applications for the applicaiton with + * the name 'appname'. + * + ****************************************************************************/ + +int builtin_isavail(FAR const char *appname) +{ + int i; + + for (i = 0; g_builtins[i].name; i++) + { + if (!strncmp(g_builtins[i].name, appname, NAME_MAX)) + { + return i; + } + } + + set_errno(ENOENT); + return ERROR; +} diff --git a/nuttx/fs/binfs/fs_binfs.c b/nuttx/fs/binfs/fs_binfs.c index 2508719e7..ed6326eba 100644 --- a/nuttx/fs/binfs/fs_binfs.c +++ b/nuttx/fs/binfs/fs_binfs.c @@ -54,10 +54,9 @@ #include #include #include +#include #include -#include - #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_BINFS) /**************************************************************************** diff --git a/nuttx/include/nuttx/binfmt/builtin.h b/nuttx/include/nuttx/binfmt/builtin.h index c27605cac..632f8944d 100644 --- a/nuttx/include/nuttx/binfmt/builtin.h +++ b/nuttx/include/nuttx/binfmt/builtin.h @@ -1,10 +1,15 @@ /**************************************************************************** * include/nuttx/binfmt/builtin.h * + * Originally by: + * * Copyright (C) 2011 Uros Platise. All rights reserved. - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Authors: Uros Platise - * Gregory Nutt + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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 @@ -43,7 +48,7 @@ ****************************************************************************/ #include -#include +#include /**************************************************************************** * Public Types @@ -68,13 +73,79 @@ extern "C" { #define EXTERN extern #endif +/* The g_builtins[] array holds information about each builtin function. If + * support for builtin functions is enabled in the NuttX configuration, then + * this arrary (along with the number_builtins() function) must be provided + * by the application code. + */ + EXTERN const struct builtin_s g_builtins[]; /**************************************************************************** * Public Functions ****************************************************************************/ -EXTERN int number_builtins(void); +/**************************************************************************** + * Utility Functions Provided to Applications by binfmt/libbuiltin + ****************************************************************************/ +/**************************************************************************** + * Name: builtin_isavail + * + * Description: + * Checks for availabiliy of application registerred during compile time. + * + * Input Parameter: + * filename - Name of the linked-in binary to be started. + * + * Returned Value: + * This is an end-user function, so it follows the normal convention: + * Returns index of builtin application. If it is not found then it + * returns -1 (ERROR) and sets errno appropriately. + * + ****************************************************************************/ + +int builtin_isavail(FAR const char *appname); + +/**************************************************************************** + * Name: builtin_getname + * + * Description: + * Returns pointer to a name of built-in application pointed by the + * index. + * + * Input Parameter: + * index, from 0 and on ... + * + * Returned Value: + * Returns valid pointer pointing to the app name if index is valid. + * Otherwise NULL is returned. + * + ****************************************************************************/ + +FAR const char *builtin_getname(int index); + +/**************************************************************************** + * Data Set Access Functions Provided to Applications by binfmt/libbuiltin + ****************************************************************************/ +/**************************************************************************** + * Name: number_builtins + * + * Description: + * Returns the number of builtin functions in the g_builtins[] array. If + * support for builtin functions is enabled in the NuttX configuration, + * then this function (along with g_builtins[]) must be provided by the + * application code. + * + * Input Parameter: + * None + * + * Returned Value: + * The number of entries in the g_builtins[] array. This function does + * not return failures. + * + ****************************************************************************/ + +int number_builtins(void); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/include/nuttx/fs/binfs.h b/nuttx/include/nuttx/fs/binfs.h index df92375e3..d967506d8 100644 --- a/nuttx/include/nuttx/fs/binfs.h +++ b/nuttx/include/nuttx/fs/binfs.h @@ -42,22 +42,11 @@ #include -#include - #ifdef CONFIG_FS_BINFS /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* This is the BINFS ioctl that can be used to recover the filename - * associated with the builtin task. - */ - -#define FIOC_FILENAME FIOC_USER /* IN: FAR const char ** pointer - * OUT: Pointer to a persistent file name - * (Guaranteed to persist while the file - * is open). - */ /**************************************************************************** * Type Definitions diff --git a/nuttx/include/nuttx/fs/ioctl.h b/nuttx/include/nuttx/fs/ioctl.h index 8f2fdd7d9..9cde497a8 100644 --- a/nuttx/include/nuttx/fs/ioctl.h +++ b/nuttx/include/nuttx/fs/ioctl.h @@ -105,7 +105,11 @@ #define FIOC_OPTIMIZE _FIOC(0x0003) /* IN: None * OUT: None */ -#define FIOC_USER _FIOC(0x0004) /* File system-specific */ +#define FIOC_FILENAME _FIOC(0x0004) /* IN: FAR const char ** pointer + * OUT: Pointer to a persistent file name + * (Guaranteed to persist while the file + * is open). + */ /* NuttX file system ioctl definitions **************************************/ -- cgit v1.2.3 From a568e1e63afed4a9a1fb075568eec16ab76c158d Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 19:08:23 +0000 Subject: Add a binary 'loader' so that builtin applications can be executed from the BINFS file system git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5525 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 8 +- apps/nshlib/Kconfig | 2 +- apps/nshlib/nsh_mntcmds.c | 72 ++++++--- apps/nshlib/nsh_parse.c | 2 +- nuttx/ChangeLog | 5 +- nuttx/binfmt/builtin.c | 195 +++++++++++++++++++++++ nuttx/binfmt/elf.c | 2 +- nuttx/binfmt/libbuiltin/Make.defs | 9 +- nuttx/configs/cloudctrl/nsh/defconfig | 2 +- nuttx/configs/compal_e88/nsh_highram/defconfig | 2 + nuttx/configs/compal_e99/nsh_compalram/defconfig | 2 + nuttx/configs/compal_e99/nsh_highram/defconfig | 2 + nuttx/configs/fire-stm32v2/nsh/defconfig | 10 +- nuttx/configs/hymini-stm32v/nsh2/defconfig | 1 + nuttx/configs/mirtoo/ostest/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/ftpc/defconfig | 3 +- nuttx/configs/olimex-lpc1766stk/nsh/defconfig | 1 + nuttx/configs/olimex-stm32-p107/nsh/defconfig | 1 + nuttx/configs/pcblogic-pic32mx/nsh/defconfig | 1 + nuttx/configs/pic32-starterkit/nsh/defconfig | 1 + nuttx/configs/pic32-starterkit/nsh2/defconfig | 1 + nuttx/configs/pic32mx7mmb/nsh/defconfig | 1 + nuttx/configs/sam3u-ek/touchscreen/defconfig | 1 + nuttx/configs/shenzhou/nsh/defconfig | 2 +- nuttx/configs/shenzhou/nxwm/defconfig | 2 +- nuttx/configs/shenzhou/thttpd/defconfig | 2 +- nuttx/configs/sim/nsh/defconfig | 1 + nuttx/configs/sim/nsh2/defconfig | 1 + nuttx/configs/stm3210e-eval/nsh2/defconfig | 1 + nuttx/configs/stm3210e-eval/nxconsole/defconfig | 1 + nuttx/configs/stm3210e-eval/pm/defconfig | 1 + nuttx/configs/stm3220g-eval/nsh/defconfig | 1 + nuttx/configs/stm3220g-eval/nsh2/defconfig | 1 + nuttx/configs/stm3220g-eval/ostest/defconfig | 2 +- nuttx/configs/stm3240g-eval/nsh/defconfig | 1 + nuttx/configs/stm3240g-eval/nsh2/defconfig | 1 + nuttx/configs/stm3240g-eval/nxconsole/defconfig | 1 + nuttx/configs/stm3240g-eval/ostest/defconfig | 2 +- nuttx/configs/stm3240g-eval/webserver/defconfig | 2 +- nuttx/configs/stm32f100rc_generic/nsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/nsh/defconfig | 1 + nuttx/configs/stm32f4discovery/pm/defconfig | 1 + nuttx/configs/sure-pic32mx/nsh/defconfig | 1 + nuttx/configs/sure-pic32mx/usbnsh/defconfig | 1 + nuttx/configs/ubw32/nsh/defconfig | 1 + nuttx/configs/vsn/nsh/defconfig | 1 + nuttx/fs/fs_mount.c | 2 +- 47 files changed, 316 insertions(+), 42 deletions(-) create mode 100644 nuttx/binfmt/builtin.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 6faac9e4b..14eb78950 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -478,6 +478,10 @@ * apps/include/builtin.h: Some of the content of apps/include/apps.h moved to include/nuttx/binfmt/builtin.h. apps/include/apps.h renamed builtin.h - * pps/builtin/exec_builtins.c: Move utility builtin + * apps/builtin/exec_builtins.c: Move utility builtin utility functions from apps/builtin/exec_builtins.c to - binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file + binfmt/libbuiltin/libbuiltin_utils.c + * apps/nshlib/nsh_mountcmds.c: The block driver/source + argument is now optional. Many files systems do not need + a source and it is really stupid to have to enter a bogus + source parameter. diff --git a/apps/nshlib/Kconfig b/apps/nshlib/Kconfig index 9cfc020a5..e60e9c480 100644 --- a/apps/nshlib/Kconfig +++ b/apps/nshlib/Kconfig @@ -15,7 +15,7 @@ if NSH_LIBRARY config NSH_BUILTIN_APPS bool "Enable built-in applications" default y - select BUILTIN + depends on BUILTIN ---help--- Support external registered, "built-in" applications that can be executed from the NSH command line (see apps/README.txt for diff --git a/apps/nshlib/nsh_mntcmds.c b/apps/nshlib/nsh_mntcmds.c index b16ba8465..f8e3a142a 100644 --- a/apps/nshlib/nsh_mntcmds.c +++ b/apps/nshlib/nsh_mntcmds.c @@ -133,7 +133,7 @@ static int mount_handler(FAR const char *mountpoint, #ifdef CONFIG_FS_BINFS case BINFS_MAGIC: - fstype = "bindir"; + fstype = "binfs"; break; #endif @@ -198,9 +198,11 @@ int cmd_df(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT) int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { - FAR char *source; - FAR char *target; - FAR char *filesystem = NULL; + FAR const char *source; + FAR char *fullsource; + FAR const char *target; + FAR char *fulltarget; + FAR const char *filesystem = NULL; bool badarg = false; int option; int ret; @@ -248,19 +250,32 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ERROR; } - /* There are two required arguments after the options: the source and target - * paths. + /* There may be one or two required arguments after the options: the source + * and target paths. Some file systems do not require the source parameter + * so if there is only one parameter left, it must be the target. */ - if (optind + 2 < argc) + if (optind >= argc) { - nsh_output(vtbl, g_fmttoomanyargs, argv[0]); + nsh_output(vtbl, g_fmtargrequired, argv[0]); return ERROR; } - else if (optind + 2 > argc) + + source = NULL; + target = argv[optind]; + optind++; + + if (optind < argc) { - nsh_output(vtbl, g_fmtargrequired, argv[0]); - return ERROR; + source = target; + target = argv[optind]; + optind++; + + if (optind < argc) + { + nsh_output(vtbl, g_fmttoomanyargs, argv[0]); + return ERROR; + } } /* While the above parsing for the -t argument looks nice, the -t argument @@ -277,29 +292,44 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * working directory. */ - source = nsh_getfullpath(vtbl, argv[optind]); - if (!source) + fullsource = NULL; + fulltarget = NULL; + + if (source) { - return ERROR; + fullsource = nsh_getfullpath(vtbl, source); + if (!fullsource) + { + return ERROR; + } } - target = nsh_getfullpath(vtbl, argv[optind+1]); - if (!target) + fulltarget = nsh_getfullpath(vtbl, target); + if (!fulltarget) { - nsh_freefullpath(source); - return ERROR; + ret = ERROR; + goto errout; } /* Perform the mount */ - ret = mount(source, target, filesystem, 0, NULL); + ret = mount(fullsource, fulltarget, filesystem, 0, NULL); if (ret < 0) { nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO); } - nsh_freefullpath(source); - nsh_freefullpath(target); +errout: + if (fullsource) + { + nsh_freefullpath(fullsource); + } + + if (fulltarget) + { + nsh_freefullpath(fulltarget); + } + return ret; } #endif diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index c36724372..ef4125a63 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -301,7 +301,7 @@ static const struct cmdmap_s g_cmdmap[] = #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) # ifndef CONFIG_NSH_DISABLE_MOUNT - { "mount", cmd_mount, 1, 5, "[-t ]" }, + { "mount", cmd_mount, 1, 5, "[-t [] ]" }, # endif #endif diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 57925a8b3..8d6d81363 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3961,4 +3961,7 @@ apps/include/apps.h moved to include/nuttx/binfmt/builtin.h * binfmt/libbuiltin/libbuiltin_utils.c: Move utility builtin utility functions from apps/builtin/exec_builtins.c to - binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file + binfmt/libbuiltin/libbuiltin_utils.c + * binfmt/builtin.c and binfmt/libbuiltin: Add a binary "loader" + that can be used to execute builtin programs from the BINFS + file system. diff --git a/nuttx/binfmt/builtin.c b/nuttx/binfmt/builtin.c new file mode 100644 index 000000000..e591ebea8 --- /dev/null +++ b/nuttx/binfmt/builtin.c @@ -0,0 +1,195 @@ +/**************************************************************************** + * binfmt/builtin.c + * + * Copyright (C) 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef CONFIG_BUILTIN + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int builtin_loadbinary(FAR struct binary_s *binp); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct binfmt_s g_builtin_binfmt = +{ + NULL, /* next */ + builtin_loadbinary, /* load */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_loadbinary + * + * Description: + * Verify that the file is an builtin binary. + * + ****************************************************************************/ + +static int builtin_loadbinary(struct binary_s *binp) +{ + FAR const char *filename; + int fd; + int index; + int ret; + + bvdbg("Loading file: %s\n", binp->filename); + + /* Open the binary file for reading (only) */ + + fd = open(filename, O_RDONLY); + if (fd < 0) + { + int errval = errno; + bdbg("ERROR: Failed to open binary %s: %d\n", filename, errval); + return -errval; + } + + /* If this file is a BINFS file system, then we can recover the name of + * the file using the FIOC_FILENAME ioctl() call. + */ + + ret = ioctl(fd, FIOC_FILENAME, (unsigned long)((uintptr_t)&filename)); + if (ret < 0) + { + int errval = errno; + bdbg("ERROR: FIOC_FILENAME ioctl failed: %d\n", errval); + return -errval; + } + + /* Other file systems may also support FIOC_FILENAME, so the real proof + * is that we can look up the index to this name in g_builtins[]. + */ + + index = builtin_isavail(filename); + if (index < 0) + { + int errval = errno; + bdbg("ERROR: %s is not a builtin application\n", filename); + return -errval; + + } + + /* Return the load information. NOTE: that there is no way to configure + * the priority. That is a bug and needs to be fixed. + */ + + binp->entrypt = g_builtins[index].main; + binp->stacksize = g_builtins[index].stacksize; + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_initialize + * + * Description: + * Builtin support is built unconditionally. However, it order to + * use this binary format, this function must be called during system + * format in order to register the builtin binary format. + * + * Returned Value: + * This is a NuttX internal function so it follows the convention that + * 0 (OK) is returned on success and a negated errno is returned on + * failure. + * + ****************************************************************************/ + +int builtin_initialize(void) +{ + int ret; + + /* Register ourselves as a binfmt loader */ + + bvdbg("Registering Builtin Loader\n"); + + ret = register_binfmt(&g_builtin_binfmt); + if (ret != 0) + { + bdbg("Failed to register binfmt: %d\n", ret); + } + + return ret; +} + +/**************************************************************************** + * Name: builtin_uninitialize + * + * Description: + * Unregister the builtin binary loader + * + * Returned Value: + * None + * + ****************************************************************************/ + +void builtin_uninitialize(void) +{ + unregister_binfmt(&g_builtin_binfmt); +} + +#endif /* CONFIG_BUILTIN */ + diff --git a/nuttx/binfmt/elf.c b/nuttx/binfmt/elf.c index bcebf13ca..9dc59fbdd 100644 --- a/nuttx/binfmt/elf.c +++ b/nuttx/binfmt/elf.c @@ -183,7 +183,7 @@ static int elf_loadbinary(struct binary_s *binp) bvdbg("Loading file: %s\n", binp->filename); - /* Initialize the xflat library to load the program binary. */ + /* Initialize the ELF library to load the program binary. */ ret = elf_init(binp->filename, &loadinfo); elf_dumploadinfo(&loadinfo); diff --git a/nuttx/binfmt/libbuiltin/Make.defs b/nuttx/binfmt/libbuiltin/Make.defs index 1d129294c..96e8b6c37 100644 --- a/nuttx/binfmt/libbuiltin/Make.defs +++ b/nuttx/binfmt/libbuiltin/Make.defs @@ -33,11 +33,14 @@ # ############################################################################ -# Legacy configurations don't set CONFIG_BUILTIN -# ifeq ($(CONFIG_BUILTIN),y) +ifeq ($(CONFIG_BUILTIN),y) # Builtin application interfaces +BINFMT_CSRCS += builtin.c + +# Builtin library interfaces + BINFMT_CSRCS += libbuiltin_utils.c # Hook the libelf subdirectory into the build @@ -46,4 +49,4 @@ VPATH += libbuiltin SUBDIRS += libbuiltin DEPPATH += --dep-path libbuiltin -# endif +endif diff --git a/nuttx/configs/cloudctrl/nsh/defconfig b/nuttx/configs/cloudctrl/nsh/defconfig index 8f145d3ab..009d9bdfa 100644 --- a/nuttx/configs/cloudctrl/nsh/defconfig +++ b/nuttx/configs/cloudctrl/nsh/defconfig @@ -463,6 +463,7 @@ CONFIG_MM_REGIONS=1 # CONFIG_BINFMT_DISABLE is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set +CONFIG_BUILTIN=y # CONFIG_SYMTAB_ORDEREDBYNAME is not set # @@ -505,7 +506,6 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/compal_e88/nsh_highram/defconfig b/nuttx/configs/compal_e88/nsh_highram/defconfig index a6868e869..7715317b7 100644 --- a/nuttx/configs/compal_e88/nsh_highram/defconfig +++ b/nuttx/configs/compal_e88/nsh_highram/defconfig @@ -250,6 +250,8 @@ CONFIG_NSH_NOMAC=y CONFIG_NSH_IPADDR=0x0a000002 CONFIG_NSH_DRIPADDR=0x0a000001 CONFIG_NSH_NETMASK=0xffffff00 + +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y # diff --git a/nuttx/configs/compal_e99/nsh_compalram/defconfig b/nuttx/configs/compal_e99/nsh_compalram/defconfig index 058dc2aa2..8739c6b91 100644 --- a/nuttx/configs/compal_e99/nsh_compalram/defconfig +++ b/nuttx/configs/compal_e99/nsh_compalram/defconfig @@ -256,6 +256,8 @@ CONFIG_NSH_NOMAC=y CONFIG_NSH_IPADDR=0x0a000002 CONFIG_NSH_DRIPADDR=0x0a000001 CONFIG_NSH_NETMASK=0xffffff00 + +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y # diff --git a/nuttx/configs/compal_e99/nsh_highram/defconfig b/nuttx/configs/compal_e99/nsh_highram/defconfig index ee1405ca5..9efcd9a81 100644 --- a/nuttx/configs/compal_e99/nsh_highram/defconfig +++ b/nuttx/configs/compal_e99/nsh_highram/defconfig @@ -254,6 +254,8 @@ CONFIG_NSH_NOMAC=y CONFIG_NSH_IPADDR=0x0a000002 CONFIG_NSH_DRIPADDR=0x0a000001 CONFIG_NSH_NETMASK=0xffffff00 + +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y # diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig index 266098496..7a4bc1bed 100644 --- a/nuttx/configs/fire-stm32v2/nsh/defconfig +++ b/nuttx/configs/fire-stm32v2/nsh/defconfig @@ -501,6 +501,15 @@ CONFIG_FAT_MAXFNAME=32 CONFIG_MM_REGIONS=1 # CONFIG_GRAN is not set +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + # # Library Routines # @@ -531,7 +540,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/hymini-stm32v/nsh2/defconfig b/nuttx/configs/hymini-stm32v/nsh2/defconfig index 7183a8632..61c7fcd69 100644 --- a/nuttx/configs/hymini-stm32v/nsh2/defconfig +++ b/nuttx/configs/hymini-stm32v/nsh2/defconfig @@ -447,6 +447,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/mirtoo/ostest/defconfig b/nuttx/configs/mirtoo/ostest/defconfig index 7c8596dbf..46612d993 100644 --- a/nuttx/configs/mirtoo/ostest/defconfig +++ b/nuttx/configs/mirtoo/ostest/defconfig @@ -401,7 +401,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # -CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 diff --git a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig index 15b26899b..a25be53de 100755 --- a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig @@ -163,7 +163,7 @@ CONFIG_RAW_BINARY=n # # General OS setup # -CONFIG_USER_ENTRYPOINT="ftpc_main" +CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n @@ -489,6 +489,7 @@ CONFIG_EXAMPLES_BUTTONS_NAME7="RIGHT" # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig index 8ed82a3ed..c096cdb0e 100755 --- a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig @@ -470,6 +470,7 @@ CONFIG_EXAMPLES_BUTTONS_NAME7="RIGHT" # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig index 09d447e14..1dcb5123a 100644 --- a/nuttx/configs/olimex-stm32-p107/nsh/defconfig +++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig @@ -476,6 +476,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig index fe24cb886..d59e2b7d2 100644 --- a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig +++ b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig @@ -398,6 +398,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/pic32-starterkit/nsh/defconfig b/nuttx/configs/pic32-starterkit/nsh/defconfig index 8bf0432e2..b50dd77fb 100644 --- a/nuttx/configs/pic32-starterkit/nsh/defconfig +++ b/nuttx/configs/pic32-starterkit/nsh/defconfig @@ -562,6 +562,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/pic32-starterkit/nsh2/defconfig b/nuttx/configs/pic32-starterkit/nsh2/defconfig index fb54a2949..2a1be755d 100644 --- a/nuttx/configs/pic32-starterkit/nsh2/defconfig +++ b/nuttx/configs/pic32-starterkit/nsh2/defconfig @@ -561,6 +561,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/pic32mx7mmb/nsh/defconfig b/nuttx/configs/pic32mx7mmb/nsh/defconfig index 62f524ee2..eb4b64e72 100644 --- a/nuttx/configs/pic32mx7mmb/nsh/defconfig +++ b/nuttx/configs/pic32mx7mmb/nsh/defconfig @@ -608,6 +608,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/sam3u-ek/touchscreen/defconfig b/nuttx/configs/sam3u-ek/touchscreen/defconfig index 278c55478..25f808635 100755 --- a/nuttx/configs/sam3u-ek/touchscreen/defconfig +++ b/nuttx/configs/sam3u-ek/touchscreen/defconfig @@ -443,6 +443,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig index 383522b6f..d23290e86 100644 --- a/nuttx/configs/shenzhou/nsh/defconfig +++ b/nuttx/configs/shenzhou/nsh/defconfig @@ -463,6 +463,7 @@ CONFIG_MM_REGIONS=1 # CONFIG_BINFMT_DISABLE is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set +CONFIG_BUILTIN=y # CONFIG_SYMTAB_ORDEREDBYNAME is not set # @@ -505,7 +506,6 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/shenzhou/nxwm/defconfig b/nuttx/configs/shenzhou/nxwm/defconfig index b9bf72aeb..e13fb72dc 100644 --- a/nuttx/configs/shenzhou/nxwm/defconfig +++ b/nuttx/configs/shenzhou/nxwm/defconfig @@ -586,6 +586,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_PIC is not set # CONFIG_SYMTAB_ORDEREDBYNAME is not set @@ -630,7 +631,6 @@ CONFIG_HAVE_CXXINITIALIZE=y # # Named Applications # -CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/shenzhou/thttpd/defconfig b/nuttx/configs/shenzhou/thttpd/defconfig index d7af34821..05d5fa337 100644 --- a/nuttx/configs/shenzhou/thttpd/defconfig +++ b/nuttx/configs/shenzhou/thttpd/defconfig @@ -474,7 +474,6 @@ CONFIG_HAVE_CXX=y # # Named Applications # -CONFIG_BUILTIN=y # # Examples @@ -835,6 +834,7 @@ CONFIG_NETUTILS_WEBCLIENT=y # NSH Library # CONFIG_NSH_LIBRARY=y +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y # diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig index 146519aa6..3f52dfe69 100644 --- a/nuttx/configs/sim/nsh/defconfig +++ b/nuttx/configs/sim/nsh/defconfig @@ -230,6 +230,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=1024 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/sim/nsh2/defconfig b/nuttx/configs/sim/nsh2/defconfig index b7e31b9e3..bcbe806cc 100644 --- a/nuttx/configs/sim/nsh2/defconfig +++ b/nuttx/configs/sim/nsh2/defconfig @@ -274,6 +274,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=1024 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig index 063307143..2be2dcefd 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig @@ -571,6 +571,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3210e-eval/nxconsole/defconfig b/nuttx/configs/stm3210e-eval/nxconsole/defconfig index 94dbf500f..9e7ed363f 100644 --- a/nuttx/configs/stm3210e-eval/nxconsole/defconfig +++ b/nuttx/configs/stm3210e-eval/nxconsole/defconfig @@ -496,6 +496,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3210e-eval/pm/defconfig b/nuttx/configs/stm3210e-eval/pm/defconfig index c113ddf60..e4a976727 100644 --- a/nuttx/configs/stm3210e-eval/pm/defconfig +++ b/nuttx/configs/stm3210e-eval/pm/defconfig @@ -616,6 +616,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3220g-eval/nsh/defconfig b/nuttx/configs/stm3220g-eval/nsh/defconfig index 8486c4fd6..71a03d212 100644 --- a/nuttx/configs/stm3220g-eval/nsh/defconfig +++ b/nuttx/configs/stm3220g-eval/nsh/defconfig @@ -672,6 +672,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3220g-eval/nsh2/defconfig b/nuttx/configs/stm3220g-eval/nsh2/defconfig index bc641b8be..84950645b 100644 --- a/nuttx/configs/stm3220g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3220g-eval/nsh2/defconfig @@ -659,6 +659,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3220g-eval/ostest/defconfig b/nuttx/configs/stm3220g-eval/ostest/defconfig index 3ec417516..f03f67cbd 100644 --- a/nuttx/configs/stm3220g-eval/ostest/defconfig +++ b/nuttx/configs/stm3220g-eval/ostest/defconfig @@ -562,7 +562,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # -CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 82caf1622..efc60cd2f 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -672,6 +672,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig index 9e7d57ade..122910e4e 100644 --- a/nuttx/configs/stm3240g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig @@ -619,6 +619,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3240g-eval/nxconsole/defconfig b/nuttx/configs/stm3240g-eval/nxconsole/defconfig index 92c3ceb75..bd8be9f5d 100644 --- a/nuttx/configs/stm3240g-eval/nxconsole/defconfig +++ b/nuttx/configs/stm3240g-eval/nxconsole/defconfig @@ -642,6 +642,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm3240g-eval/ostest/defconfig b/nuttx/configs/stm3240g-eval/ostest/defconfig index f9e690a10..f7eb4ef95 100644 --- a/nuttx/configs/stm3240g-eval/ostest/defconfig +++ b/nuttx/configs/stm3240g-eval/ostest/defconfig @@ -574,7 +574,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # -CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 diff --git a/nuttx/configs/stm3240g-eval/webserver/defconfig b/nuttx/configs/stm3240g-eval/webserver/defconfig index 792eafa0a..6b4d47e53 100644 --- a/nuttx/configs/stm3240g-eval/webserver/defconfig +++ b/nuttx/configs/stm3240g-eval/webserver/defconfig @@ -673,7 +673,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # -CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 diff --git a/nuttx/configs/stm32f100rc_generic/nsh/defconfig b/nuttx/configs/stm32f100rc_generic/nsh/defconfig index 12193e7ed..aea79ff3f 100644 --- a/nuttx/configs/stm32f100rc_generic/nsh/defconfig +++ b/nuttx/configs/stm32f100rc_generic/nsh/defconfig @@ -393,6 +393,7 @@ CONFIG_MM_REGIONS=1 # CONFIG_BINFMT_DISABLE is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set +CONFIG_BUILTIN=y CONFIG_SYMTAB_ORDEREDBYNAME=y # @@ -428,7 +429,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # Named Applications # -CONFIG_BUILTIN=y # # Examples diff --git a/nuttx/configs/stm32f4discovery/nsh/defconfig b/nuttx/configs/stm32f4discovery/nsh/defconfig index d9917b3a8..3ec117055 100644 --- a/nuttx/configs/stm32f4discovery/nsh/defconfig +++ b/nuttx/configs/stm32f4discovery/nsh/defconfig @@ -603,6 +603,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/stm32f4discovery/pm/defconfig b/nuttx/configs/stm32f4discovery/pm/defconfig index 1636f6ecb..332235050 100644 --- a/nuttx/configs/stm32f4discovery/pm/defconfig +++ b/nuttx/configs/stm32f4discovery/pm/defconfig @@ -622,6 +622,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/sure-pic32mx/nsh/defconfig b/nuttx/configs/sure-pic32mx/nsh/defconfig index d15bac1f4..a5977733c 100644 --- a/nuttx/configs/sure-pic32mx/nsh/defconfig +++ b/nuttx/configs/sure-pic32mx/nsh/defconfig @@ -434,6 +434,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/sure-pic32mx/usbnsh/defconfig b/nuttx/configs/sure-pic32mx/usbnsh/defconfig index 3ebfde834..3ab4563e9 100644 --- a/nuttx/configs/sure-pic32mx/usbnsh/defconfig +++ b/nuttx/configs/sure-pic32mx/usbnsh/defconfig @@ -431,6 +431,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/ubw32/nsh/defconfig b/nuttx/configs/ubw32/nsh/defconfig index 8769fa677..c9718ca8d 100644 --- a/nuttx/configs/ubw32/nsh/defconfig +++ b/nuttx/configs/ubw32/nsh/defconfig @@ -421,6 +421,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/configs/vsn/nsh/defconfig b/nuttx/configs/vsn/nsh/defconfig index 5ec7e06eb..88d14aba6 100755 --- a/nuttx/configs/vsn/nsh/defconfig +++ b/nuttx/configs/vsn/nsh/defconfig @@ -459,6 +459,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # Settings for apps/nshlib # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c index 1b3da8dc3..a91e7d366 100644 --- a/nuttx/fs/fs_mount.c +++ b/nuttx/fs/fs_mount.c @@ -221,7 +221,7 @@ int mount(FAR const char *source, FAR const char *target, /* Find the specified filesystem. Try the block driver file systems first */ #ifdef BDFS_SUPPORT - if ((mops = mount_findfs(g_bdfsmap, filesystemtype)) != NULL) + if (source && (mops = mount_findfs(g_bdfsmap, filesystemtype)) != NULL) { /* Make sure that a block driver argument was provided */ -- cgit v1.2.3 From e7e1c6aee0e0d84f290995a092c1722878a54044 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 21:38:00 +0000 Subject: convert configs/sim/nsh to use kconfig-frontends git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5526 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/Makefile | 8 +- apps/examples/README.txt | 2 +- apps/examples/hello/Makefile | 2 +- nuttx/ChangeLog | 3 + nuttx/Documentation/NuttShell.html | 18 +- nuttx/configs/compal_e88/nsh_highram/defconfig | 2 +- nuttx/configs/compal_e99/nsh_compalram/defconfig | 2 +- nuttx/configs/compal_e99/nsh_highram/defconfig | 3 +- nuttx/configs/sim/README.txt | 19 +- nuttx/configs/sim/nsh/appconfig | 47 -- nuttx/configs/sim/nsh/defconfig | 627 ++++++++++++++++------- 11 files changed, 479 insertions(+), 254 deletions(-) delete mode 100644 nuttx/configs/sim/nsh/appconfig (limited to 'apps') diff --git a/apps/examples/Makefile b/apps/examples/Makefile index a11dbf240..939748075 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -57,13 +57,11 @@ SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson CNTXTDIRS = pwm ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd json keypadtest -CNTXTDIRS += modbus nettest nxlines relays qencoder telnetd watchdog wgetjson +CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd hello json +CNTXTDIRS += keypadtestmodbus nettest nxlines relays qencoder telnetd watchdog +CNTXTDIRS += wgetjson endif -ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) -CNTXTDIRS += hello -endif ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) CNTXTDIRS += helloxx endif diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 5c6332ee3..5996cbb70 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -491,7 +491,7 @@ examples/hello than examples/null with a single printf statement. Really useful only for bringing up new NuttX architectures. - * CONFIG_EXAMPLES_HELLO_BUILTIN + * CONFIG_NSH_BUILTIN_APPS Build the "Hello, World" example as an NSH built-in application. examples/helloxx diff --git a/apps/examples/hello/Makefile b/apps/examples/hello/Makefile index fc98fa7f4..c3b9744d7 100644 --- a/apps/examples/hello/Makefile +++ b/apps/examples/hello/Makefile @@ -83,7 +83,7 @@ $(COBJS): %$(OBJEXT): %.c $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built -ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 8d6d81363..6bc66ec9d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3965,3 +3965,6 @@ * binfmt/builtin.c and binfmt/libbuiltin: Add a binary "loader" that can be used to execute builtin programs from the BINFS file system. + * configs/sim/nsh: Convert to use kconfig-frontends configuration + tool. + diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 273898476..950428e8a 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -2518,6 +2518,8 @@ nsh> Support external registered, "builtin" applications that can be executed from the NSH command line (see apps/README.txt for more information). + This required CONFIG_BUILTIN to enable NuttX support for + "builtin" applications. @@ -3227,8 +3229,20 @@ struct cmdmap_s

          These applications are built-into NSH in the sense that they can be executed by simply typing the name of the application at the NSH prompt. - Built-in application support is enabled with the configuration option CONFIG_NSH_BUILTIN_APPS. - When this configuration option is set, you will also be able to see the built-in applications if you enter "nsh> help". + Built-in application support is enabled with these configuration option: +

          +
            +
          • + CONFIG_BUILTIN: + Enable NuttX support for builtin applications. +
          • +
          • + CONFIG_NSH_BUILTIN_APPS: + Enable NSH support for builtin applications. +
          • +
          +

          + When these configuration options are set, you will also be able to see the built-in applications if you enter "nsh> help". They will appear at the bottom of the list of NSH commands under:

          diff --git a/nuttx/configs/compal_e88/nsh_highram/defconfig b/nuttx/configs/compal_e88/nsh_highram/defconfig index 7715317b7..9d5c0e3c4 100644 --- a/nuttx/configs/compal_e88/nsh_highram/defconfig +++ b/nuttx/configs/compal_e88/nsh_highram/defconfig @@ -256,7 +256,7 @@ CONFIG_NSH_BUILTIN_APPS=y # # Settings for examples/hello -CONFIG_EXAMPLES_HELLO_BUILTIN=y +# # # Settings for examples/wget diff --git a/nuttx/configs/compal_e99/nsh_compalram/defconfig b/nuttx/configs/compal_e99/nsh_compalram/defconfig index 8739c6b91..79fe93ab5 100644 --- a/nuttx/configs/compal_e99/nsh_compalram/defconfig +++ b/nuttx/configs/compal_e99/nsh_compalram/defconfig @@ -224,7 +224,7 @@ CONFIG_NET_RESOLV_ENTRIES=4 # # Settings for examples/hello -CONFIG_EXAMPLES_HELLO_BUILTIN=y +# # # Settings for examples/uip diff --git a/nuttx/configs/compal_e99/nsh_highram/defconfig b/nuttx/configs/compal_e99/nsh_highram/defconfig index 9efcd9a81..11ee153fa 100644 --- a/nuttx/configs/compal_e99/nsh_highram/defconfig +++ b/nuttx/configs/compal_e99/nsh_highram/defconfig @@ -260,7 +260,8 @@ CONFIG_NSH_BUILTIN_APPS=y # # Settings for examples/hello -CONFIG_EXAMPLES_HELLO_BUILTIN=y +# + CONFIG_EXAMPLES_NXHELLO_BUILTIN=y CONFIG_EXAMPLES_NXTEXT_BUILTIN=y CONFIG_EXAMPLES_NXIMAGE_BUILTIN=y diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 165e92b96..6e124a3a1 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -270,13 +270,26 @@ nsh Description ----------- - Configures to use the NuttShell at apps/examples/nsh. This version has - one builtin function: This configuration: apps/examples/hello. This - configuration may be selected as follows: + Configures to use the NuttShell at apps/examples/nsh. This configuration + may be selected as follows: cd /tools ./configure.sh sim/nsh + NOTES: + ------ + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + and misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. This version has one builtin function: This configuration: + apps/examples/hello. + nsh2 Description diff --git a/nuttx/configs/sim/nsh/appconfig b/nuttx/configs/sim/nsh/appconfig deleted file mode 100644 index 3f50f6818..000000000 --- a/nuttx/configs/sim/nsh/appconfig +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################ -# configs/sim/nsh/appconfig -# -# 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. -# -############################################################################ - -# Path to example in apps/examples containing the user_start entry point - -CONFIGURED_APPS += examples/nsh - -# The NSH Library - -CONFIGURED_APPS += system/readline -CONFIGURED_APPS += nshlib - -# Example built-in application - -CONFIGURED_APPS += examples/hello diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig index 3f52dfe69..8dc5ddcce 100644 --- a/nuttx/configs/sim/nsh/defconfig +++ b/nuttx/configs/sim/nsh/defconfig @@ -1,148 +1,154 @@ -############################################################################ -# sim/nsh/defconfig -# -# Copyright (C) 2008-2013 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ -# -# Architecture selection # -CONFIG_ARCH="sim" -CONFIG_ARCH_SIM=y -CONFIG_ARCH_BOARD="sim" -CONFIG_ARCH_BOARD_SIM=y +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y # -# General OS setup +# Build Setup # -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_DEBUG=n -CONFIG_DEBUG_VERBOSE=n +# CONFIG_EXPERIMENTAL 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_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +# CONFIG_RAW_BINARY is not set + +# +# Customize Header Files +# +# 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 + +# +# Debug Options +# +# CONFIG_DEBUG is not set CONFIG_DEBUG_SYMBOLS=y -CONFIG_HAVE_CXX=n -CONFIG_HAVE_CXXINITIALIZE=n -CONFIG_MM_REGIONS=1 -CONFIG_ARCH_LOWPUTC=y -CONFIG_RR_INTERVAL=0 -CONFIG_SCHED_INSTRUMENTATION=n -CONFIG_TASK_NAME_SIZE=32 -CONFIG_START_YEAR=2008 -CONFIG_START_MONTH=6 -CONFIG_START_DAY=1 -CONFIG_JULIAN_TIME=n -CONFIG_DEV_CONSOLE=y -CONFIG_DEV_LOWCONSOLE=n -CONFIG_MUTEX_TYPES=n -CONFIG_PRIORITY_INHERITANCE=n -CONFIG_SEM_PREALLOCHOLDERS=0 -CONFIG_SEM_NNESTPRIO=0 -CONFIG_FDCLONE_DISABLE=n -CONFIG_FDCLONE_STDIO=n -CONFIG_SDCLONE_DISABLE=y -CONFIG_SCHED_WORKQUEUE=n -CONFIG_SCHED_WORKPRIORITY=192 -CONFIG_SCHED_WORKPERIOD=50000 -CONFIG_SCHED_WORKSTACKSIZE=1024 -CONFIG_SIG_SIGWORK=17 -CONFIG_SCHED_WAITPID=y -CONFIG_SCHED_ATEXIT=n -CONFIG_SCHED_ONEXIT=n +# +# System Type +# +# CONFIG_ARCH_8051 is not set +# CONFIG_ARCH_ARM is not set +# 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=y +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="sim" +CONFIG_BOARD_LOOPSPERMSEC= # -# System Logging +# Simulation Configuration Options # +# CONFIG_SIM_M32 is not set +# CONFIG_SIM_WALLTIME is not set -CONFIG_SYSLOG=n -CONFIG_SYSLOG_DEVPATH="/dev/syslog" -CONFIG_SYSLOG_CHAR=n +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_IRQPRIO is not set +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +# CONFIG_ARCH_HAVE_VFORK is not set +# CONFIG_ARCH_STACKDUMP is not set +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set -CONFIG_RAMLOG=n -CONFIG_RAMLOG_CONSOLE=n -CONFIG_RAMLOG_SYSLOG=y -#CONFIG_RAMLOG_NPOLLWAITERS -#CONFIG_RAMLOG_CONSOLE_BUFSIZE +# +# Board Settings +# +CONFIG_DRAM_START= +CONFIG_DRAM_SIZE= # -# The following can be used to disable categories of -# APIs supported by the OS. If the compiler supports -# weak functions, then it should not be necessary to -# disable functions unless you want to restrict usage -# of those APIs. +# Boot options # -# There are certain dependency relationships in these -# features. +CONFIG_BOOT_RUNFROMEXTSRAM=y +# CONFIG_BOOT_RUNFROMFLASH is not set +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + # -# o mq_notify logic depends on signals to awaken tasks -# waiting for queues to become full or empty. -# o pthread_condtimedwait() depends on signals to wake -# up waiting tasks. +# Board Selection # -CONFIG_DISABLE_CLOCK=n -CONFIG_DISABLE_POSIX_TIMERS=n -CONFIG_DISABLE_PTHREAD=n -CONFIG_DISABLE_SIGNALS=n -CONFIG_DISABLE_MQUEUE=n -CONFIG_DISABLE_MOUNTPOINT=n -CONFIG_DISABLE_ENVIRON=n -CONFIG_DISABLE_POLL=y +CONFIG_ARCH_BOARD_SIM=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="sim" # -# Misc libc settings +# Common Board Options # -CONFIG_NOPRINTF_FIELDWIDTH=n +CONFIG_NSH_MMCSDMINOR=0 # -# Allow for architecture optimized implementations +# Board-Specific Options # -# The architecture can provide optimized versions of the -# following to improve sysem performance + # -CONFIG_ARCH_MEMCPY=n -CONFIG_ARCH_MEMCMP=n -CONFIG_ARCH_MEMMOVE=n -CONFIG_ARCH_MEMSET=n -CONFIG_ARCH_STRCMP=n -CONFIG_ARCH_STRCPY=n -CONFIG_ARCH_STRNCPY=n -CONFIG_ARCH_STRLEN=n -CONFIG_ARCH_STRNLEN=n -CONFIG_ARCH_BZERO=n +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=0 +# CONFIG_SCHED_INSTRUMENTATION is not set +CONFIG_TASK_NAME_SIZE=32 +# CONFIG_SCHED_HAVE_PARENT is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2008 +CONFIG_START_MONTH=6 +CONFIG_START_DAY=1 +CONFIG_DEV_CONSOLE=y +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +CONFIG_SCHED_WAITPID=y +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# 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_MOUNTPOINT is not set +# CONFIG_DISABLE_ENVIRON is not set +CONFIG_DISABLE_POLL=y # -# General build options +# Signal Numbers # -CONFIG_RRLOAD_BINARY=n -CONFIG_INTELHEX_BINARY=n -CONFIG_RAW_BINARY=n +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 # # Sizes of configurable things (0 disables) @@ -153,8 +159,6 @@ CONFIG_NPTHREAD_KEYS=4 CONFIG_NFILE_DESCRIPTORS=32 CONFIG_NFILE_STREAMS=16 CONFIG_NAME_MAX=32 -CONFIG_STDIO_BUFFER_SIZE=1024 -CONFIG_NUNGET_CHARS=2 CONFIG_PREALLOC_MQ_MSGS=32 CONFIG_MQ_MAXMSGSIZE=32 CONFIG_MAX_WDOGPARMS=4 @@ -162,91 +166,299 @@ CONFIG_PREALLOC_WDOGS=32 CONFIG_PREALLOC_TIMERS=8 # -# Filesystem configuration +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=8192 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD 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_16550_UART is not set +# CONFIG_STANDARD_SERIAL is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration # +# CONFIG_FS_RAMMAP is not set CONFIG_FS_FAT=y CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=n +CONFIG_FAT_LFN=y CONFIG_FAT_MAXFNAME=32 -CONFIG_FS_NXFFS=n +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FS_NXFFS is not set CONFIG_FS_ROMFS=y CONFIG_FS_BINFS=y # -# TCP/IP and UDP support via uIP +# System Logging # -CONFIG_NET=n -CONFIG_NET_IPv6=n -CONFIG_NSOCKET_DESCRIPTORS=0 -CONFIG_NET_SOCKOPTS=y -CONFIG_NET_BUFSIZE=420 -CONFIG_NET_TCP=n -CONFIG_NET_TCP_CONNS=40 -CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_UDP=n -CONFIG_NET_UDP_CHECKSUMS=y -#CONFIG_NET_UDP_CONNS=10 -CONFIG_NET_ICMP=n -CONFIG_NET_ICMP_PING=n -#CONFIG_NET_PINGADDRCONF=0 -CONFIG_NET_STATISTICS=y -#CONFIG_NET_RECEIVE_WINDOW= -#CONFIG_NET_ARPTAB_SIZE=8 -CONFIG_NET_BROADCAST=n +# CONFIG_SYSLOG is not set # -# Settings for examples/hello +# Graphics Support # -CONFIG_EXAMPLES_HELLO_BUILTIN=y +# CONFIG_NX is not set # -# UIP Network Utilities +# Memory Management # -CONFIG_NET_DHCP_LIGHT=n -CONFIG_NET_RESOLV_ENTRIES=4 +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_GRAN is not set # -# Settings for examples/uip -CONFIG_EXAMPLES_UIP_IPADDR=0xc0a80080 -CONFIG_EXAMPLES_UIP_DRIPADDR=0xc0a80001 -CONFIG_EXAMPLES_UIP_NETMASK=0xffffff00 -CONFIG_EXAMPLES_UIP_DHCPC=n +# Binary Formats +# +# 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 # -# Settings for examples/nettest -CONFIG_EXAMPLES_NETTEST_SERVER=n -CONFIG_EXAMPLES_NETTEST_PERFORMANCE=n -CONFIG_EXAMPLES_NETTEST_NOMAC=n -CONFIG_EXAMPLES_NETTEST_IPADDR=0xc0a80080 -CONFIG_EXAMPLES_NETTEST_DRIPADDR=0xc0a80001 -CONFIG_EXAMPLES_NETTEST_NETMASK=0xffffff00 -CONFIG_EXAMPLES_NETTEST_CLIENTIP=0xc0a8006a +# Library Routines +# # -# Settings for examples/ostest -CONFIG_EXAMPLES_OSTEST_LOOPS=100 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=1024 +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_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_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set # -# Settings for apps/nshlib +# Non-standard Helper Functions # -CONFIG_BUILTIN=y +# CONFIG_LIB_KBDCODEC is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE 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=y +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_NETTEST is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y CONFIG_NSH_BUILTIN_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DD 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_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_LS is not set +# 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 +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSFMOUNT is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING 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_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT 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_CODECS_BUFSIZE=128 CONFIG_NSH_FILEIOSIZE=1024 -CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=80 CONFIG_NSH_NESTDEPTH=3 -CONFIG_NSH_DISABLESCRIPT=n -CONFIG_NSH_DISABLEBG=n +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLEBG is not set CONFIG_NSH_ROMFSETC=y -CONFIG_NSH_CONSOLE=y -CONFIG_NSH_TELNET=n -CONFIG_NSH_IOBUFFER_SIZE=512 -CONFIG_NSH_DHCPC=n -CONFIG_NSH_NOMAC=n -CONFIG_NSH_IPADDR=0x0a000002 -CONFIG_NSH_DRIPADDR=0x0a000001 -CONFIG_NSH_NETMASK=0xffffff00 CONFIG_NSH_ROMFSMOUNTPT="/etc" CONFIG_NSH_INITSCRIPT="init.d/rcS" CONFIG_NSH_ROMFSDEVNO=1 @@ -255,23 +467,54 @@ CONFIG_NSH_FATDEVNO=2 CONFIG_NSH_FATSECTSIZE=512 CONFIG_NSH_FATNSECTORS=1024 CONFIG_NSH_FATMOUNTPT="/tmp" +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_CONDEV is not set +# CONFIG_NSH_ARCHINIT is not set # -# Settings for examples/mount -CONFIG_EXAMPLES_MOUNT_DEVNAME="/dev/ram0" -#CONFIG_EXAMPLES_MOUNT_NSECTORS=2048 -#CONFIG_EXAMPLES_MOUNT_SECTORSIZE=512 -#CONFIG_EXAMPLES_MOUNT_RAMDEVNO=1 +# NxWidgets/NxWM +# # -# Stack and heap information +# System NSH Add-Ons # -CONFIG_BOOT_RUNFROMFLASH=n -CONFIG_BOOT_COPYTORAM=n -CONFIG_CUSTOM_STACK=n -CONFIG_IDLETHREAD_STACKSIZE=4096 -CONFIG_USERMAIN_STACKSIZE=4096 -CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=8192 -CONFIG_HEAP_BASE= -CONFIG_HEAP_SIZE= + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set -- cgit v1.2.3 From caeef71797019505fd450b1a0ae573ac5e490c6e Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 17 Jan 2013 00:30:12 +0000 Subject: Change the way thread priority is handled in binfmt/ to better match the way that priority is set up for the builtin tasks git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5527 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/elf/elf_main.c | 2 +- apps/examples/nxflat/nxflat_main.c | 2 +- nuttx/Documentation/NuttXBinfmt.html | 26 +++++- nuttx/Documentation/NuttXNxFlat.html | 2 +- nuttx/binfmt/binfmt_exec.c | 18 +--- nuttx/binfmt/binfmt_execmodule.c | 6 +- nuttx/binfmt/binfmt_loadmodule.c | 43 ++++++++++ nuttx/binfmt/builtin.c | 1 + nuttx/binfmt/libbuiltin/Make.defs | 4 +- nuttx/binfmt/libbuiltin/libbuiltin_getname.c | 92 ++++++++++++++++++++ nuttx/binfmt/libbuiltin/libbuiltin_isavail.c | 102 ++++++++++++++++++++++ nuttx/binfmt/libbuiltin/libbuiltin_utils.c | 121 --------------------------- nuttx/configs/sim/README.txt | 10 +++ nuttx/include/nuttx/binfmt/binfmt.h | 11 ++- 14 files changed, 290 insertions(+), 150 deletions(-) create mode 100644 nuttx/binfmt/libbuiltin/libbuiltin_getname.c create mode 100644 nuttx/binfmt/libbuiltin/libbuiltin_isavail.c delete mode 100644 nuttx/binfmt/libbuiltin/libbuiltin_utils.c (limited to 'apps') diff --git a/apps/examples/elf/elf_main.c b/apps/examples/elf/elf_main.c index 66a47592c..2b5c0eb5e 100644 --- a/apps/examples/elf/elf_main.c +++ b/apps/examples/elf/elf_main.c @@ -321,7 +321,7 @@ int elf_main(int argc, char *argv[]) /* Execute the ELF module */ - ret = exec_module(&bin, 50); + ret = exec_module(&bin); mm_update(&g_mmstep, "after exec_module"); diff --git a/apps/examples/nxflat/nxflat_main.c b/apps/examples/nxflat/nxflat_main.c index 536bc1dd8..0c4846a5c 100644 --- a/apps/examples/nxflat/nxflat_main.c +++ b/apps/examples/nxflat/nxflat_main.c @@ -243,7 +243,7 @@ int nxflat_main(int argc, char *argv[]) /* Execute the ELF module */ - ret = exec_module(&bin, 50); + ret = exec_module(&bin); if (ret < 0) { err("ERROR: Failed to execute program '%s'\n", dirlist[i]); diff --git a/nuttx/Documentation/NuttXBinfmt.html b/nuttx/Documentation/NuttXBinfmt.html index 9c9fd3a51..7528b188b 100644 --- a/nuttx/Documentation/NuttXBinfmt.html +++ b/nuttx/Documentation/NuttXBinfmt.html @@ -8,7 +8,7 @@

          NuttX Binary Loader

          -

          Last Updated: December 17, 2012

          +

          Last Updated: January 16, 2013

          @@ -141,7 +141,7 @@ struct binary_s { /* Information provided to the loader to load and bind a module */ - FAR const char *filename; /* Full path to the binary to be loaded1 */ + FAR const char *filename; /* Full path to the binary to be loaded */ FAR const char **argv; /* Argument list */ FAR const struct symtab_s *exports; /* Table of exported symbols */ int nexports; /* The number of symbols in exports[] */ @@ -153,13 +153,33 @@ struct binary_s main_t entrypt; /* Entry point into a program module */ FAR void *mapped; /* Memory-mapped, address space */ FAR void *alloc[BINFMT_NALLOC]; /* Allocated address spaces */ + + /* Constructors/destructors */ + #ifdef CONFIG_BINFMT_CONSTRUCTORS FAR binfmt_ctor_t *ctors; /* Pointer to a list of constructors */ FAR binfmt_dtor_t *dtors; /* Pointer to a list of destructors */ uint16_t nctors; /* Number of constructors in the list */ uint16_t ndtors; /* Number of destructors in the list */ #endif + + /* Address environment. + * + * addrenv - This is the handle created by up_addrenv_create() that can be + * used to manage the tasks address space. + */ + +#ifdef CONFIG_ADDRENV + task_addrenv_t addrenv; /* Task address environment */ +#endif + size_t mapsize; /* Size of the mapped address region (needed for munmap) */ + + /* Start-up information that is provided by the loader, but may be modified + * by the caller between load_module() and exec_module() calls. + */ + + uint8_t priority; /* Task execution priority */ size_t stacksize; /* Size of the stack in bytes (unallocated) */ };
        @@ -291,7 +311,7 @@ This is a NuttX internal function so it follows the convention that 0 (OK<

        Function Prototype:

           #include <:nuttx/binfmt/binfmt.h>
          -int exec_module(FAR const struct binary_s *bin, int priority);
          +int exec_module(FAR const struct binary_s *bin);
           

        Description:

          diff --git a/nuttx/Documentation/NuttXNxFlat.html b/nuttx/Documentation/NuttXNxFlat.html index 3a2ed8046..ed04f7f77 100644 --- a/nuttx/Documentation/NuttXNxFlat.html +++ b/nuttx/Documentation/NuttXNxFlat.html @@ -668,7 +668,7 @@ cat ../syscall/syscall.csv ../libc/lib.csv | sort >tmp.csv

        -

        int exec_module(FAR const struct binary_s *bin, int priority) +

        int exec_module(FAR const struct binary_s *bin)

          Description: Execute a module that has been loaded into memory by load_module(). diff --git a/nuttx/binfmt/binfmt_exec.c b/nuttx/binfmt/binfmt_exec.c index d5e274710..d878c8cc5 100644 --- a/nuttx/binfmt/binfmt_exec.c +++ b/nuttx/binfmt/binfmt_exec.c @@ -40,7 +40,6 @@ #include #include -#include #include #include @@ -75,8 +74,7 @@ * * Description: * This is a convenience function that wraps load_ and exec_module into - * one call. The priority of the executed program is set to be the - * same as the priority of the calling thread. + * one call. * * Input Parameter: * filename - Fulll path to the binary to be loaded @@ -95,18 +93,8 @@ int exec(FAR const char *filename, FAR const char **argv, FAR const struct symtab_s *exports, int nexports) { struct binary_s bin; - struct sched_param param; int ret; - /* Get the priority of this thread */ - - ret = sched_getparam(0, ¶m); - if (ret < 0) - { - bdbg("ERROR: sched_getparam failed: %d\n", errno); - return ERROR; - } - /* Load the module into memory */ memset(&bin, 0, sizeof(struct binary_s)); @@ -121,9 +109,9 @@ int exec(FAR const char *filename, FAR const char **argv, return ERROR; } - /* Then start the module at the priority of this thread */ + /* Then start the module */ - ret = exec_module(&bin, param.sched_priority); + ret = exec_module(&bin); if (ret < 0) { bdbg("ERROR: Failed to execute program '%s'\n", filename); diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c index df8da5343..afa445abb 100644 --- a/nuttx/binfmt/binfmt_execmodule.c +++ b/nuttx/binfmt/binfmt_execmodule.c @@ -144,7 +144,7 @@ static inline int exec_ctors(FAR const struct binary_s *binp) * ****************************************************************************/ -int exec_module(FAR const struct binary_s *binp, int priority) +int exec_module(FAR const struct binary_s *binp) { FAR _TCB *tcb; #ifndef CONFIG_CUSTOM_STACK @@ -187,12 +187,12 @@ int exec_module(FAR const struct binary_s *binp, int priority) /* Initialize the task */ - ret = task_init(tcb, binp->filename, priority, stack, + ret = task_init(tcb, binp->filename, binp->priority, stack, binp->stacksize, binp->entrypt, binp->argv); #else /* Initialize the task */ - ret = task_init(tcb, binp->filename, priority, stack, + ret = task_init(tcb, binp->filename, binp->priority, stack, binp->entrypt, binp->argv); #endif if (ret < 0) diff --git a/nuttx/binfmt/binfmt_loadmodule.c b/nuttx/binfmt/binfmt_loadmodule.c index 112a6b35b..4f3dc6952 100644 --- a/nuttx/binfmt/binfmt_loadmodule.c +++ b/nuttx/binfmt/binfmt_loadmodule.c @@ -66,6 +66,39 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: load_default_priority + * + * Description: + * Set the default priority of the module to be loaded. This may be + * changed (1) by the actions of the binary format's load() method if + * the binary format contains priority informaition, or (2) by the user + * between calls to load_module() and exec_module(). + * + * Returned Value: + * Zero (OK) is returned on success; Otherwise, -1 (ERROR) is returned and + * the errno variable is set appropriately. + * + ****************************************************************************/ + +static int load_default_priority(FAR struct binary_s *bin) +{ + struct sched_param param; + + /* Get the priority of this thread */ + + ret = sched_getparam(0, ¶m); + if (ret < 0) + { + bdbg("ERROR: sched_getparam failed: %d\n", errno); + return ERROR; + } + + /* Save that as the priority of child thread */ + + bin->priority = param.sched_priority; +} + /**************************************************************************** * Name: load_absmodule * @@ -145,6 +178,16 @@ int load_module(FAR struct binary_s *bin) if (bin && bin->filename) #endif { + /* Set the default priority of the new program. */ + + ret = load_default_priority(bin) + if (ret < 0) + { + /* The errno is already set in this case */ + + return ERROR; + } + /* Were we given a relative path? Or an absolute path to the file to * be loaded? Absolute paths start with '/'. */ diff --git a/nuttx/binfmt/builtin.c b/nuttx/binfmt/builtin.c index e591ebea8..d36cb6326 100644 --- a/nuttx/binfmt/builtin.c +++ b/nuttx/binfmt/builtin.c @@ -136,6 +136,7 @@ static int builtin_loadbinary(struct binary_s *binp) binp->entrypt = g_builtins[index].main; binp->stacksize = g_builtins[index].stacksize; + binp->priority = g_builtins[index].priority; return OK; } diff --git a/nuttx/binfmt/libbuiltin/Make.defs b/nuttx/binfmt/libbuiltin/Make.defs index 96e8b6c37..5eec1acde 100644 --- a/nuttx/binfmt/libbuiltin/Make.defs +++ b/nuttx/binfmt/libbuiltin/Make.defs @@ -41,9 +41,9 @@ BINFMT_CSRCS += builtin.c # Builtin library interfaces -BINFMT_CSRCS += libbuiltin_utils.c +BINFMT_CSRCS += libbuiltin_getname.c libbuiltin_isavail.c -# Hook the libelf subdirectory into the build +# Hook the libbuiltin subdirectory into the build VPATH += libbuiltin SUBDIRS += libbuiltin diff --git a/nuttx/binfmt/libbuiltin/libbuiltin_getname.c b/nuttx/binfmt/libbuiltin/libbuiltin_getname.c new file mode 100644 index 000000000..01ac024f7 --- /dev/null +++ b/nuttx/binfmt/libbuiltin/libbuiltin_getname.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * binfmt/libbuiltin/libbuiltin_getname.c + * + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_getname + * + * Description: + * Return the name of the application at index in the table of builtin + * applications. + * + ****************************************************************************/ + +FAR const char *builtin_getname(int index) +{ + if (index < 0 || index >= number_builtins()) + { + return NULL; + } + + return g_builtins[index].name; +} diff --git a/nuttx/binfmt/libbuiltin/libbuiltin_isavail.c b/nuttx/binfmt/libbuiltin/libbuiltin_isavail.c new file mode 100644 index 000000000..f99a4b81d --- /dev/null +++ b/nuttx/binfmt/libbuiltin/libbuiltin_isavail.c @@ -0,0 +1,102 @@ +/**************************************************************************** + * binfmt/libbuiltin/libbuiltin_isavail.c + * + * Originally by: + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * With subsequent updates, modifications, and general maintenance by: + * + * Copyright (C) 2012-2013 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 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: builtin_isavail + * + * Description: + * Return the index into the table of applications for the applicaiton with + * the name 'appname'. + * + ****************************************************************************/ + +int builtin_isavail(FAR const char *appname) +{ + int i; + + for (i = 0; g_builtins[i].name; i++) + { + if (!strncmp(g_builtins[i].name, appname, NAME_MAX)) + { + return i; + } + } + + set_errno(ENOENT); + return ERROR; +} diff --git a/nuttx/binfmt/libbuiltin/libbuiltin_utils.c b/nuttx/binfmt/libbuiltin/libbuiltin_utils.c deleted file mode 100644 index b53becff9..000000000 --- a/nuttx/binfmt/libbuiltin/libbuiltin_utils.c +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** - * binfmt/libbuiltin/libbuiltin_utils.c - * - * Originally by: - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Uros Platise - * - * With subsequent updates, modifications, and general maintenance by: - * - * Copyright (C) 2012-2013 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 - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: builtin_getname - * - * Description: - * Return the name of the application at index in the table of builtin - * applications. - * - ****************************************************************************/ - -FAR const char *builtin_getname(int index) -{ - if (index < 0 || index >= number_builtins()) - { - return NULL; - } - - return g_builtins[index].name; -} - -/**************************************************************************** - * Name: builtin_isavail - * - * Description: - * Return the index into the table of applications for the applicaiton with - * the name 'appname'. - * - ****************************************************************************/ - -int builtin_isavail(FAR const char *appname) -{ - int i; - - for (i = 0; g_builtins[i].name; i++) - { - if (!strncmp(g_builtins[i].name, appname, NAME_MAX)) - { - return i; - } - } - - set_errno(ENOENT); - return ERROR; -} diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 6e124a3a1..67ff73019 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -290,6 +290,16 @@ nsh 2. This version has one builtin function: This configuration: apps/examples/hello. + 3. This configuration has BINFS enabled so that the builtin applications + can be made visible in the file system. For example: + + NuttShell (NSH) NuttX-6.24 + nsh> mount -t binfs /bin + nsh> ls /bin + /bin: + hello + nsh> + nsh2 Description diff --git a/nuttx/include/nuttx/binfmt/binfmt.h b/nuttx/include/nuttx/binfmt/binfmt.h index 480e82c09..c6c7c874a 100644 --- a/nuttx/include/nuttx/binfmt/binfmt.h +++ b/nuttx/include/nuttx/binfmt/binfmt.h @@ -117,6 +117,12 @@ struct binary_s #endif size_t mapsize; /* Size of the mapped address region (needed for munmap) */ + + /* Start-up information that is provided by the loader, but may be modified + * by the caller between load_module() and exec_module() calls. + */ + + uint8_t priority; /* Task execution priority */ size_t stacksize; /* Size of the stack in bytes (unallocated) */ }; @@ -221,15 +227,14 @@ int unload_module(FAR const struct binary_s *bin); * ****************************************************************************/ -int exec_module(FAR const struct binary_s *bin, int priority); +int exec_module(FAR const struct binary_s *bin); /**************************************************************************** * Name: exec * * Description: * This is a convenience function that wraps load_ and exec_module into - * one call. The priority of the executed program is set to be the - * same as the priority of the calling thread. + * one call. * * Input Parameter: * filename - Fulll path to the binary to be loaded -- cgit v1.2.3 From 8685f63c72259d18304fd9a04099e5cfa17829ba Mon Sep 17 00:00:00 2001 From: px4dev Date: Thu, 17 Jan 2013 01:18:18 -0800 Subject: Some gentle massaging to get things building again. --- .gitignore | 8 ++++++-- apps/Makefile | 5 ++++- apps/builtin/exec_builtin.c | 2 +- apps/examples/Makefile | 24 ++++++++++++++-------- apps/namedapp/namedapp_list.h | 42 ++++++++++++++++++++++++++++++++++++++ apps/namedapp/namedapp_proto.h | 42 ++++++++++++++++++++++++++++++++++++++ nuttx/configs/px4fmu/nsh/defconfig | 1 + 7 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 apps/namedapp/namedapp_list.h create mode 100644 apps/namedapp/namedapp_proto.h (limited to 'apps') diff --git a/.gitignore b/.gitignore index ef0ed3c4c..85d846b98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,16 @@ .built *.context +*.bdat +*.pdat .depend +.updated .config +.config-e .version .project .cproject -apps/namedapp/namedapp_list.h -apps/namedapp/namedapp_proto.h +apps/builtin/builtin_list.h +apps/builtin/builtin_proto.h Make.dep *.pyc *.o diff --git a/apps/Makefile b/apps/Makefile index d0cc23a5f..d3078d069 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -49,7 +49,10 @@ APPDIR = ${shell pwd} # list can be extended by the .config file as well. CONFIGURED_APPS = -SUBDIRS = examples graphics interpreters modbus builtin nshlib netutils system + +SUBDIRS = examples interpreters builtin nshlib system + +#SUBDIRS = examples graphics interpreters modbus builtin nshlib netutils system # There are two different mechanisms for obtaining the list of configured # directories: diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c index 05648590d..9fde813d6 100644 --- a/apps/builtin/exec_builtin.c +++ b/apps/builtin/exec_builtin.c @@ -293,7 +293,7 @@ static inline int builtin_startproxy(int index, FAR const char **argv, int errcode; int ret; - DEBUGASSERT(path); +// DEBUGASSERT(path); svdbg("index=%d argv=%p redirfile=%s oflags=%04x\n", index, argv, redirfile, oflags); diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 939748075..201be955b 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -37,12 +37,15 @@ # Sub-directories -SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf ftpc -SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount -SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage -SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm posix_spawn qencoder -SUBDIRS += relays rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip -SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson +SUBDIRS = adc can cdcacm nsh +SUBDIRS += math_demo control_demo kalman_demo px4_deamon_app + +#SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf ftpc +#SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount +#SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage +#SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm posix_spawn qencoder +#SUBDIRS += relays rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip +#SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson # Sub-directories that might need context setup. Directories may need # context setup for a variety of reasons, but the most common is because @@ -57,9 +60,12 @@ SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson CNTXTDIRS = pwm ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd hello json -CNTXTDIRS += keypadtestmodbus nettest nxlines relays qencoder telnetd watchdog -CNTXTDIRS += wgetjson + +CNTXTDIRS += adc can cdcacm + +#CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd hello json +#CNTXTDIRS += keypadtestmodbus nettest nxlines relays qencoder telnetd watchdog +#CNTXTDIRS += wgetjson endif ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) diff --git a/apps/namedapp/namedapp_list.h b/apps/namedapp/namedapp_list.h new file mode 100644 index 000000000..72d1fa52d --- /dev/null +++ b/apps/namedapp/namedapp_list.h @@ -0,0 +1,42 @@ +/* List of application requirements, generated during make context. */ +{ "math_demo", SCHED_PRIORITY_DEFAULT, 8192, math_demo_main }, +{ "control_demo", SCHED_PRIORITY_DEFAULT, 2048, control_demo_main }, +{ "kalman_demo", SCHED_PRIORITY_MAX - 30, 2048, kalman_demo_main }, +{ "reboot", SCHED_PRIORITY_DEFAULT, 2048, reboot_main }, +{ "perf", SCHED_PRIORITY_DEFAULT, 2048, perf_main }, +{ "top", SCHED_PRIORITY_DEFAULT - 10, 3000, top_main }, +{ "boardinfo", SCHED_PRIORITY_DEFAULT, 2048, boardinfo_main }, +{ "mixer", SCHED_PRIORITY_DEFAULT, 4096, mixer_main }, +{ "eeprom", SCHED_PRIORITY_DEFAULT, 4096, eeprom_main }, +{ "param", SCHED_PRIORITY_DEFAULT, 4096, param_main }, +{ "bl_update", SCHED_PRIORITY_DEFAULT, 4096, bl_update_main }, +{ "preflight_check", SCHED_PRIORITY_DEFAULT, 2048, preflight_check_main }, +{ "delay_test", SCHED_PRIORITY_DEFAULT, 2048, delay_test_main }, +{ "uorb", SCHED_PRIORITY_DEFAULT, 4096, uorb_main }, +{ "mavlink", SCHED_PRIORITY_DEFAULT, 2048, mavlink_main }, +{ "mavlink_onboard", SCHED_PRIORITY_DEFAULT, 2048, mavlink_onboard_main }, +{ "gps", SCHED_PRIORITY_DEFAULT, 2048, gps_main }, +{ "commander", SCHED_PRIORITY_MAX - 30, 2048, commander_main }, +{ "sdlog", SCHED_PRIORITY_MAX - 30, 2048, sdlog_main }, +{ "sensors", SCHED_PRIORITY_MAX-5, 4096, sensors_main }, +{ "ardrone_interface", SCHED_PRIORITY_MAX - 15, 2048, ardrone_interface_main }, +{ "multirotor_att_control", SCHED_PRIORITY_MAX - 15, 2048, multirotor_att_control_main }, +{ "multirotor_pos_control", SCHED_PRIORITY_MAX - 25, 2048, multirotor_pos_control_main }, +{ "fixedwing_att_control", SCHED_PRIORITY_MAX - 30, 2048, fixedwing_att_control_main }, +{ "fixedwing_pos_control", SCHED_PRIORITY_MAX - 30, 2048, fixedwing_pos_control_main }, +{ "position_estimator", SCHED_PRIORITY_DEFAULT, 4096, position_estimator_main }, +{ "attitude_estimator_ekf", SCHED_PRIORITY_DEFAULT, 2048, attitude_estimator_ekf_main }, +{ "ms5611", SCHED_PRIORITY_DEFAULT, 2048, ms5611_main }, +{ "hmc5883", SCHED_PRIORITY_DEFAULT, 4096, hmc5883_main }, +{ "mpu6000", SCHED_PRIORITY_DEFAULT, 4096, mpu6000_main }, +{ "bma180", SCHED_PRIORITY_DEFAULT, 2048, bma180_main }, +{ "l3gd20", SCHED_PRIORITY_DEFAULT, 2048, l3gd20_main }, +{ "px4io", SCHED_PRIORITY_DEFAULT, 2048, px4io_main }, +{ "blinkm", SCHED_PRIORITY_DEFAULT, 2048, blinkm_main }, +{ "tone_alarm", SCHED_PRIORITY_DEFAULT, 2048, tone_alarm_main }, +{ "adc", SCHED_PRIORITY_DEFAULT, 2048, adc_main }, +{ "fmu", SCHED_PRIORITY_DEFAULT, 2048, fmu_main }, +{ "hil", SCHED_PRIORITY_DEFAULT, 2048, hil_main }, +{ "tests", SCHED_PRIORITY_DEFAULT, 12000, tests_main }, +{ "sercon", SCHED_PRIORITY_DEFAULT, 2048, sercon_main }, +{ "serdis", SCHED_PRIORITY_DEFAULT, 2048, serdis_main }, diff --git a/apps/namedapp/namedapp_proto.h b/apps/namedapp/namedapp_proto.h new file mode 100644 index 000000000..09f5b4156 --- /dev/null +++ b/apps/namedapp/namedapp_proto.h @@ -0,0 +1,42 @@ +/* List of application entry points, generated during make context. */ +EXTERN int math_demo_main(int argc, char *argv[]); +EXTERN int control_demo_main(int argc, char *argv[]); +EXTERN int kalman_demo_main(int argc, char *argv[]); +EXTERN int reboot_main(int argc, char *argv[]); +EXTERN int perf_main(int argc, char *argv[]); +EXTERN int top_main(int argc, char *argv[]); +EXTERN int boardinfo_main(int argc, char *argv[]); +EXTERN int mixer_main(int argc, char *argv[]); +EXTERN int eeprom_main(int argc, char *argv[]); +EXTERN int param_main(int argc, char *argv[]); +EXTERN int bl_update_main(int argc, char *argv[]); +EXTERN int preflight_check_main(int argc, char *argv[]); +EXTERN int delay_test_main(int argc, char *argv[]); +EXTERN int uorb_main(int argc, char *argv[]); +EXTERN int mavlink_main(int argc, char *argv[]); +EXTERN int mavlink_onboard_main(int argc, char *argv[]); +EXTERN int gps_main(int argc, char *argv[]); +EXTERN int commander_main(int argc, char *argv[]); +EXTERN int sdlog_main(int argc, char *argv[]); +EXTERN int sensors_main(int argc, char *argv[]); +EXTERN int ardrone_interface_main(int argc, char *argv[]); +EXTERN int multirotor_att_control_main(int argc, char *argv[]); +EXTERN int multirotor_pos_control_main(int argc, char *argv[]); +EXTERN int fixedwing_att_control_main(int argc, char *argv[]); +EXTERN int fixedwing_pos_control_main(int argc, char *argv[]); +EXTERN int position_estimator_main(int argc, char *argv[]); +EXTERN int attitude_estimator_ekf_main(int argc, char *argv[]); +EXTERN int ms5611_main(int argc, char *argv[]); +EXTERN int hmc5883_main(int argc, char *argv[]); +EXTERN int mpu6000_main(int argc, char *argv[]); +EXTERN int bma180_main(int argc, char *argv[]); +EXTERN int l3gd20_main(int argc, char *argv[]); +EXTERN int px4io_main(int argc, char *argv[]); +EXTERN int blinkm_main(int argc, char *argv[]); +EXTERN int tone_alarm_main(int argc, char *argv[]); +EXTERN int adc_main(int argc, char *argv[]); +EXTERN int fmu_main(int argc, char *argv[]); +EXTERN int hil_main(int argc, char *argv[]); +EXTERN int tests_main(int argc, char *argv[]); +EXTERN int sercon_main(int argc, char *argv[]); +EXTERN int serdis_main(int argc, char *argv[]); diff --git a/nuttx/configs/px4fmu/nsh/defconfig b/nuttx/configs/px4fmu/nsh/defconfig index 8a76f0e05..c70866d06 100755 --- a/nuttx/configs/px4fmu/nsh/defconfig +++ b/nuttx/configs/px4fmu/nsh/defconfig @@ -940,6 +940,7 @@ CONFIG_CDCACM_PRODUCTSTR="PX4 FMU v1.6" # CONFIG_NSH_FATNSECTORS - FAT FS number of sectors # CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint # +CONFIG_BUILTIN=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=y -- cgit v1.2.3 From f4da4bb8ca29a48e1bf10958cbc45fc9fb10e9f7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Jan 2013 10:00:23 +1100 Subject: perf_counter: added perf_reset() and perf_reset_all() calls useful for watching counters after system reaches stable flight --- apps/systemlib/perf_counter.c | 45 +++++++++++++++++++++++++++++++++++++++++++ apps/systemlib/perf_counter.h | 13 +++++++++++++ 2 files changed, 58 insertions(+) (limited to 'apps') diff --git a/apps/systemlib/perf_counter.c b/apps/systemlib/perf_counter.c index ff15ef479..879f4715a 100644 --- a/apps/systemlib/perf_counter.c +++ b/apps/systemlib/perf_counter.c @@ -218,6 +218,40 @@ perf_end(perf_counter_t handle) } } +void +perf_reset(perf_counter_t handle) +{ + if (handle == NULL) + return; + + switch (handle->type) { + case PC_COUNT: + ((struct perf_ctr_count *)handle)->event_count = 0; + break; + + case PC_ELAPSED: { + struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle; + pce->event_count = 0; + pce->time_start = 0; + pce->time_total = 0; + pce->time_least = 0; + pce->time_most = 0; + break; + } + + case PC_INTERVAL: { + struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle; + pci->event_count = 0; + pci->time_event = 0; + pci->time_first = 0; + pci->time_last = 0; + pci->time_least = 0; + pci->time_most = 0; + break; + } + } +} + void perf_print_counter(perf_counter_t handle) { @@ -270,3 +304,14 @@ perf_print_all(void) handle = (perf_counter_t)sq_next(&handle->link); } } + +void +perf_reset_all(void) +{ + perf_counter_t handle = (perf_counter_t)sq_peek(&perf_counters); + + while (handle != NULL) { + perf_reset(handle); + handle = (perf_counter_t)sq_next(&handle->link); + } +} diff --git a/apps/systemlib/perf_counter.h b/apps/systemlib/perf_counter.h index 6e6c80d5b..5c2cb15b2 100644 --- a/apps/systemlib/perf_counter.h +++ b/apps/systemlib/perf_counter.h @@ -97,6 +97,14 @@ __EXPORT extern void perf_begin(perf_counter_t handle); */ __EXPORT extern void perf_end(perf_counter_t handle); +/** + * Reset a performance event. + * + * This call resets performance counter to initial state + * + * @param handle The handle returned from perf_alloc. + */ +__EXPORT extern void perf_reset(perf_counter_t handle); /** * Print one performance counter. @@ -110,6 +118,11 @@ __EXPORT extern void perf_print_counter(perf_counter_t handle); */ __EXPORT extern void perf_print_all(void); +/** + * Reset all of the performance counters. + */ +__EXPORT extern void perf_reset_all(void); + __END_DECLS #endif -- cgit v1.2.3 From 6e751d26e8011616e10b611df5dedbc24aa188bf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Jan 2013 10:00:49 +1100 Subject: perf: added 'perf reset' command resets all perf counters --- apps/systemcmds/perf/perf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apps') diff --git a/apps/systemcmds/perf/perf.c b/apps/systemcmds/perf/perf.c index ced942fd6..64443d019 100644 --- a/apps/systemcmds/perf/perf.c +++ b/apps/systemcmds/perf/perf.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "systemlib/perf_counter.h" @@ -63,6 +64,15 @@ __EXPORT int perf_main(int argc, char *argv[]); int perf_main(int argc, char *argv[]) { + if (argc > 1) { + if (strcmp(argv[1], "reset") == 0) { + perf_reset_all(); + return 0; + } + printf("Usage: perf \n"); + return -1; + } + perf_print_all(); fflush(stdout); return 0; -- cgit v1.2.3