diff --git a/ChangeLog b/ChangeLog
index 7814921b2f..67d641ea67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,6 +87,7 @@
errno; pthread_setscheduler() now returns the correct errno.
* Added pthread_setschedprio().
* Added directories to hold board-specific header files
+ * Added directories to hold board-specific drivers
* Started m68322
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index c970198fce..e609b5287b 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -295,6 +295,8 @@ below and discussed in the following paragraphs:
<board-name>
|-- include/
+ |-- src/
+ | `-- Makefile
|-- Make.defs
|-- defconfig
`-- setenv.sh
@@ -310,6 +312,17 @@ below and discussed in the following paragraphs:
These header file can only be included by files in arch/<arch-name>/include/
and arch/<arch-name>/src/
.
+
+ src/
:
+ This directory contains board specific drivers.
+ This directory will be linked as arch/<arch-name>/src/board at configuration
+ time and will be integrated into the build system.
+
+
+ src/Makefile
:
+ This makefile will be invoked to build the board specific drivers.
+ It must support the following targets: libext$(LIBEXT)
, clean
, and distclean
.
+
Make.defs
: This makefile fragment provides architecture and
tool-specific build options. It will be included by all other
diff --git a/Makefile b/Makefile
index 34cc90910b..69ad07da21 100644
--- a/Makefile
+++ b/Makefile
@@ -80,12 +80,21 @@ include/arch/board: Make.defs include/arch
fi
@ln -s $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
-context: check_context include/nuttx/config.h include/arch include/arch/board
+$(ARCH_SRC)/board: Make.defs
+ @if [ -e $(ARCH_SRC)/board ]; then \
+ if [ -h $(ARCH_SRC)/board ]; then \
+ rm -f $(ARCH_SRC)/board ; \
+ else \
+ echo "$(ARCH_SRC)/board exists but is not a symbolic link" ; \
+ exit 1 ; \
+ fi ; \
+ fi
+ @ln -s $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
+
+context: check_context include/nuttx/config.h include/arch include/arch/board $(ARCH_SRC)/board
clean_context:
- rm -f include/nuttx/config.h
- rm -f include/arch
- rm -f include/arch/board
+ rm -f include/nuttx/config.h include/arch include/arch/board $(ARCH_SRC)/board
check_context:
@if [ ! -e ${TOPDIR}/.config -o ! -e ${TOPDIR}/Make.defs ]; then \
@@ -123,19 +132,26 @@ depend:
$(MAKE) -C $$dir TOPDIR=$(TOPDIR) depend ; \
done
-clean:
+subdir_clean:
@for dir in $(SUBDIRS) ; do \
- $(MAKE) -C $$dir TOPDIR=$(TOPDIR) clean ; \
+ if [ -e $$dir/Makefile ]; then \
+ $(MAKE) -C $$dir TOPDIR=$(TOPDIR) clean ; \
+ fi \
done
$(MAKE) -C tools -f Makefile.mkconfig TOPDIR=$(TOPDIR) clean
$(MAKE) -C mm -f Makefile.test TOPDIR=$(TOPDIR) clean
+
+clean: subdir_clean
rm -f $(BIN) $(BIN).* mm_test *.map *~
-distclean: clean clean_context
+subdir_distclean:
@for dir in $(SUBDIRS) ; do \
- $(MAKE) -C $$dir TOPDIR=$(TOPDIR) distclean ; \
+ if [ -e $$dir/Makefile ]; then \
+ $(MAKE) -C $$dir TOPDIR=$(TOPDIR) distclean ; \
+ fi \
done
- $(MAKE) -C examples/$(CONFIG_EXAMPLE) TOPDIR=$(TOPDIR) distclean
+
+distclean: clean subdir_distclean clean_context
rm -f Make.defs setenv.sh .config
diff --git a/TODO b/TODO
index 9f83c3e42e..c15c8d23b6 100644
--- a/TODO
+++ b/TODO
@@ -27,15 +27,16 @@ o pthreads
- pthread_cancel(): Should implemenent cancellation points and pthread_testcancel()
o Libraries
-- There needs to be some kind of mutual exclusion protection on buffered
- I/O. If two threads try fflush-ing at the same time, there is corruption
- of the output.
-- At present, there is a failure in the examples/ostest POSIX timer
- test when CONFIG_DEBUG is enabled. This is almost certainly yet
- another case where printf (or its kin) are being called from a
- sensitive area in the OS.
-- I am now seeing the same thing with the dm320 barrier test.
- Apparently printf has some thread safety issues.
+- There seems to be some kind of failure in the mutual exclusion logic on
+ buffered, "standard," IO.
+ - If two threads try fflush-ing at the same time, there is corruption
+ of the output.
+ - Yhere is a failure in the examples/ostest POSIX timer
+ test when CONFIG_DEBUG is enabled. This is almost certainly yet
+ another case where printf (or its kin) are being called from a
+ sensitive area in the OS.
+ - I am now seeing the same thing with the dm320 barrier test.
+ Apparently printf has some thread safety issues.
o File system
- Add some concept like mount points to handle mounted "real" filesystems.
@@ -47,6 +48,13 @@ o Documentation
- Document filesystem, library
o Build system
+- Names under arch are incorrect. These should hold processor architectures.
+ c5471 should be arm7
+ dm320 should be arm9
+ pjrc-8051 should be 805x
+- SoC-specific logic should be in subdirectories under arch/.
+ Eg. arm7/include/c5471 should hold c5471 specific header files
+- configs/pjrc-8051 should be configs/pjrc-87c52
o Applications & Tests
diff --git a/arch/c5471/src/Makefile b/arch/c5471/src/Makefile
index b282cbf8df..770c4e3a6b 100644
--- a/arch/c5471/src/Makefile
+++ b/arch/c5471/src/Makefile
@@ -51,7 +51,7 @@ CSRCS = up_initialize.c up_initialstate.c up_idle.c up_doirq.c \
up_exit.c up_assert.c up_blocktask.c up_unblocktask.c \
up_releasepending.c up_reprioritizertr.c up_copystate.c \
up_schedulesigaction.c up_sigdeliver.c up_serial.c \
- up_delay.c up_allocateheap.c up_leds.c up_watchdog.c
+ up_delay.c up_allocateheap.c up_watchdog.c
COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
@@ -65,6 +65,8 @@ LINKLIBS =
LDPATHES = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
+BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board
+
LIBGCC = ${shell $(CC) -print-libgcc-file-name}
all: up_head.o libarch$(LIBEXT)
@@ -81,9 +83,12 @@ libarch$(LIBEXT): $(OBJS)
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; )
-nuttx: $(LINKOBJS)
- $(LD) --entry=__start $(LDFLAGS) $(LDPATHES) -o $(TOPDIR)/$@ $(LINKOBJS) \
- --start-group $(LDLIBS) --end-group $(EXTRA_LIBS) $(LIBGCC)
+board/libboard$(LIBEXT):
+ $(MAKE) -C board TOPDIR=$(TOPDIR) libboard$(LIBEXT)
+
+nuttx: $(LINKOBJS) board/libboard$(LIBEXT)
+ $(LD) --entry=__start $(LDFLAGS) $(LDPATHES) -L$(BOARDDIR) -o $(TOPDIR)/$@ $(LINKOBJS) \
+ --start-group $(LDLIBS) -lboard --end-group $(EXTRA_LIBS) $(LIBGCC)
@$(NM) $(TOPDIR)/$@ | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
@@ -100,15 +105,23 @@ ifeq ($(CONFIG_RRLOAD_BINARY),y)
endif
.depend: Makefile $(SRCS)
+ echo $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ $(MAKE) -C board TOPDIR=$(TOPDIR) depend
touch $@
depend: .depend
clean:
rm -f libarch$(LIBEXT) *.o *~
+ @if [ -e board/Makefile ]; then \
+ $(MAKE) -C board TOPDIR=$(TOPDIR) clean ; \
+ fi
distclean: clean
rm -f Make.dep .depend
+ @if [ -e board/Makefile ]; then \
+ $(MAKE) -C board TOPDIR=$(TOPDIR) distclean ; \
+ fi
-include Make.dep
diff --git a/arch/c5471/src/up_assert.c b/arch/c5471/src/up_assert.c
index 6edc2c4dfe..0dad02f891 100644
--- a/arch/c5471/src/up_assert.c
+++ b/arch/c5471/src/up_assert.c
@@ -79,7 +79,7 @@ static inline uint32 up_getsp(void)
* Name: up_stackdump
************************************************************/
-#ifdef CONFIG_C5471_STACKDUMP
+#ifdef CONFIG_ARCH_STACKDUMP
static void up_stackdump(void)
{
_TCB *rtcb = (_TCB*)g_readytorun.head;
@@ -137,7 +137,7 @@ static void _up_assert(int errorcode) /* __attribute__ ((noreturn)) */
(void)irqsave();
for(;;)
{
-#ifdef CONFIG_C5471_LEDS
+#ifdef CONFIG_ARCH_LEDS
up_ledon(LED_PANIC);
up_delay(250);
up_ledoff(LED_PANIC);
diff --git a/arch/c5471/src/up_head.S b/arch/c5471/src/up_head.S
index 770caddceb..d681a177e2 100644
--- a/arch/c5471/src/up_head.S
+++ b/arch/c5471/src/up_head.S
@@ -117,7 +117,7 @@ __start:
#endif
/* Initialize onboard LEDs */
-#ifdef CONFIG_C5471_LEDS
+#ifdef CONFIG_ARCH_LEDS
bl up_ledinit
#endif
diff --git a/arch/c5471/src/up_internal.h b/arch/c5471/src/up_internal.h
index 60cc252732..fc5f92f7bd 100644
--- a/arch/c5471/src/up_internal.h
+++ b/arch/c5471/src/up_internal.h
@@ -153,7 +153,7 @@ extern void up_maskack_irq(int irq);
/* Defined in up_leds.c */
-#ifdef CONFIG_C5471_LEDS
+#ifdef CONFIG_ARCH_LEDS
extern void up_ledinit(void);
extern void up_ledon(int led);
extern void up_ledoff(int led);
diff --git a/configs/README.txt b/configs/README.txt
index 5962c34a4a..e15c57c36f 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -25,6 +25,8 @@ following characteristics:
|-- include/
+ |-- src/
+ | `-- Makefile
|-- Make.defs
|-- defconfig
`-- setenv.sh
@@ -32,12 +34,20 @@ following characteristics:
Summary of Files
^^^^^^^^^^^^^^^^
-include/ -- This directoy contains board specific header files. This
+include/ -- This directory contains board specific header files. This
directory will be linked as include/arch/board at configuration time and
can be included via '#include '. These header file
can only be included by files in arch/include/ and
arch//src
+src/ -- This directory contains board specific drivers. This
+ directory will be linked as arch//src/board at configuration
+ time and will be integrated into the build system.
+
+src/Makefile -- This makefile will be invoked to build the board specific
+ drivers. It must support the following targets: libext$(LIBEXT), clean,
+ and distclean.
+
Make.defs -- This makefile fragment provides architecture and
tool-specific build options. It will be included by all other
makefiles in the build (once it is installed). This make fragment
diff --git a/configs/c5471evm/defconfig b/configs/c5471evm/defconfig
index a65cdb4358..2971805c51 100644
--- a/configs/c5471evm/defconfig
+++ b/configs/c5471evm/defconfig
@@ -35,15 +35,19 @@
#
# architecture selection
#
-# CONFIG_ARCH - identifies the arch subdirectory
-# CONFIG_ARCH_name - for use in C code
-# CONFIG_BOARD - identifies the configs subdirectory
-# CONFIG_BARD_name - for use in C code
+# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
+# processor architecture.
+# CONFIG_ARCH_name - for use in C code. This identifies the
+# particular chip or SoC that the architecture is implemented
+# in.
+# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# the board that supports the particular chip or SoC.
+# CONFIG_BOARD_name - for use in C code
# CONFIG_ROM_VECTORS - unique to c5471
# CONFIG_DRAM_END - the size of installed DRAM.
# Unique to c5471
-# CONFIG_C5471_LEDS - Use LEDs to show state. Unique to c5471.
-# CONFIG_C5471_STACKDUMP - Do stack dumps after assertions
+# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to c5471.
+# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
#
CONFIG_ARCH=c5471
CONFIG_ARCH_C5471=y
@@ -51,8 +55,8 @@ CONFIG_BOARD=c5471evm
CONFIG_BOARD_C5471EVM=y
CONFIG_ROM_VECTORS=n
CONFIG_DRAM_END=0x11000000
-CONFIG_C5471_LEDS=y
-CONFIG_C5471_STACKDUMP=y
+CONFIG_ARCH_LEDS=y
+CONFIG_ARCH_STACKDUMP=y
#
# C5471 specific device driver settings
diff --git a/configs/m68332evb/defconfig b/configs/m68332evb/defconfig
index 86a7e059a5..c63dc6aa23 100644
--- a/configs/m68332evb/defconfig
+++ b/configs/m68332evb/defconfig
@@ -35,10 +35,14 @@
#
# architecture selection
#
-# CONFIG_ARCH - identifies the arch subdirectory
-# CONFIG_ARCH_name - for use in C code
-# CONFIG_BOARD - identifies the configs subdirectory
-# CONFIG_BARD_name - for use in C code
+# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
+# processor architecture.
+# CONFIG_ARCH_name - for use in C code. This identifies the
+# particular chip or SoC that the architecture is implemented
+# in.
+# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# the board that supports the particular chip or SoC.
+# CONFIG_BOARD_name - for use in C code
# CONFIG_DRAM_SIZE - Describes the installed DRAM.
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
#
diff --git a/configs/ntosd-dm320/defconfig b/configs/ntosd-dm320/defconfig
index 1763fe0f4c..7ea06e2170 100644
--- a/configs/ntosd-dm320/defconfig
+++ b/configs/ntosd-dm320/defconfig
@@ -35,10 +35,14 @@
#
# architecture selection
#
-# CONFIG_ARCH - identifies the arch subdirectory
-# CONFIG_ARCH_name - for use in C code
-# CONFIG_BOARD - identifies the configs subdirectory
-# CONFIG_BARD_name - for use in C code
+# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
+# processor architecture.
+# CONFIG_ARCH_name - for use in C code. This identifies the
+# particular chip or SoC that the architecture is implemented
+# in.
+# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# the board that supports the particular chip or SoC.
+# CONFIG_BOARD_name - for use in C code
# CONFIG_ROM_VECTORS - unique to dm320
# CONFIG_DRAM_SIZE - Describes the installed DRAM.
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
diff --git a/configs/pjrc-8051/defconfig b/configs/pjrc-8051/defconfig
index 316bda2b4b..cc5da93bd7 100644
--- a/configs/pjrc-8051/defconfig
+++ b/configs/pjrc-8051/defconfig
@@ -35,9 +35,13 @@
#
# Architecture selection
#
-# CONFIG_ARCH - identifies the arch subdirectory
+# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
+# processor architecture.
# CONFIG_ARCH_8051 - Set if processor is 8051 family
# CONFIG_ARCH_8052 = Set if processor is 8052 family
+# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# the board that supports the particular chip or SoC.
+# CONFIG_BOARD_name - for use in C code
# CONFIG_BOARD - identifies the configs subdirectory
# CONFIG_BARD_name - for use in C code
#
diff --git a/configs/sim/defconfig b/configs/sim/defconfig
index 13e1030eea..935ca1db25 100644
--- a/configs/sim/defconfig
+++ b/configs/sim/defconfig
@@ -35,10 +35,14 @@
#
# architecture selection
#
-# CONFIG_ARCH - identifies the arch subdirectory
-# CONFIG_ARCH_name - for use in C code
-# CONFIG_BOARD - identifies the configs subdirectory
-# CONFIG_BARD_name - for use in C code
+# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
+# processor architecture.
+# CONFIG_ARCH_name - for use in C code. This identifies the
+# particular chip or SoC that the architecture is implemented
+# in.
+# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# the board that supports the particular chip or SoC.
+# CONFIG_BOARD_name - for use in C code
#
CONFIG_ARCH=sim
CONFIG_ARCH_SIM=y