summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-31 19:05:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-31 19:05:45 +0000
commite56f12fd3dbddb72e0a3996a1247d27bad227cd5 (patch)
tree7fefabe8952d6636169d83a94d9d545975083bfb /nuttx/arch
parentd63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19 (diff)
downloadpx4-nuttx-e56f12fd3dbddb72e0a3996a1247d27bad227cd5.tar.gz
px4-nuttx-e56f12fd3dbddb72e0a3996a1247d27bad227cd5.tar.bz2
px4-nuttx-e56f12fd3dbddb72e0a3996a1247d27bad227cd5.zip
Add logic to init global data on bootup
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@473 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/z80/src/Makefile27
-rw-r--r--nuttx/arch/z80/src/common/up_head.asm47
-rw-r--r--nuttx/arch/z80/src/common/up_restoreusercontext.asm1
-rw-r--r--nuttx/arch/z80/src/common/up_saveusercontext.asm2
4 files changed, 59 insertions, 18 deletions
diff --git a/nuttx/arch/z80/src/Makefile b/nuttx/arch/z80/src/Makefile
index 8917a4402..a72171e7a 100644
--- a/nuttx/arch/z80/src/Makefile
+++ b/nuttx/arch/z80/src/Makefile
@@ -126,12 +126,8 @@ $(COBJS): %$(OBJEXT): %.c
$(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB)
@cat $(SDCCLIBDIR)/$(SDCCLIB) | \
- grep -v calloc | grep -v malloc | grep -v realloc | \
- grep -v free | grep -v getenv | grep -v vprintf | \
- grep -v sprintf | grep -v _strncpy | grep -v _strchr | \
- grep -v _strlen | grep -v _strcmp | grep -v _strcpy | \
- grep -v _memcmp | grep -v _memcpy | grep -v _memset | \
- grep -v crt0 \
+ grep -v alloc | grep -v free | grep -v printf | \
+ grep -v _str | grep -v _mem | grep -v crt0\.o \
> myz80.lib
@sudo mv -f myz80.lib $(SDCCLIBDIR)/myz80.lib
@@ -149,6 +145,13 @@ up_mem.h:
@echo "#endif /* __ARCH_MEM_H */" >>up_mem.h
asm_mem.h:
+ @echo " UP_COMPILER_OTHER == 0" > asm_mem.h
+ @echo " UP_COMPILER_SDCC == 1" >> asm_mem.h
+ifeq ($(CC),sdcc)
+ @echo " UP_COMPILER == 1" >> asm_mem.h
+else
+ @echo " UP_COMPILER == 0" >> asm_mem.h
+endif
@echo " UP_STACK_END == ($(CONFIG_DRAM_SIZE) - 1)" >> asm_mem.h
@echo " UP_STACK_BASE == (UP_STACK_END - $(CONFIG_PROC_STACK_SIZE))" >> asm_mem.h
@echo " UP_HEAP1_END == (UP_STACK_END - $(CONFIG_PROC_STACK_SIZE) - 1)" >> asm_mem.h
@@ -170,7 +173,8 @@ board/libboard$(LIBEXT):
# This target builds the final executable
pass1.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboard$(LIBEXT)
- @echo "-k $(BOARDDIR)" >pass1.lnk # Path to board library
+ @echo "--" >pass1.lnk # Non-interactive
+ @echo "-k $(BOARDDIR)" >>pass1.lnk # Path to board library
@echo "-k $(SDCCLIBDIR)" >>pass1.lnk # Path to SDCC z80 library
@echo "-l libboard$(LIBEXT)" >>pass1.lnk # Name of board library
@for LIB in $(LINKLIBS); do \
@@ -180,8 +184,9 @@ pass1.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboar
@echo "-b START=0" >>pass1.lnk # Start of START area
@echo "-b _CODE=256" >>pass1.lnk # Start of _CODE area
@echo "-i" >>pass1.lnk # Intel hex format
- @echo "-m" >>pass1.lnk # Generate a map file
- @echo "-j" >>pass1.lnk # Generate a symbol file
+ @echo "-x" >>pass1.lnk # Hexadecimal
+ @echo "-m" >>pass1.lnk # Generate a map file
+ @echo "-j" >>pass1.lnk # Generate a symbol file
@echo "pass1.ihx" >>pass1.lnk # Path to head object
@echo "$(HEAD_AOBJ)" >>pass1.lnk # Path to head object
@echo "-e" >>pass1.lnk # End of script
@@ -192,7 +197,8 @@ pass1.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboar
@$(MAKE) TOPDIR=$(TOPDIR) $(HEAD_AOBJ)
nuttx.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboard$(LIBEXT)
- @echo "-k $(BOARDDIR)" >nuttx.lnk # Path to board library
+ @echo "--" >nuttx.lnk # Non-interactive
+ @echo "-k $(BOARDDIR)" >>nuttx.lnk # Path to board library
@echo "-k $(SDCCLIBDIR)" >>nuttx.lnk # Path to SDCC z80 library
@echo "-l libboard$(LIBEXT)" >>nuttx.lnk # Name of board library
@for LIB in $(LINKLIBS); do \
@@ -202,6 +208,7 @@ nuttx.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboar
@echo "-b START=0" >>nuttx.lnk # Start of START area
@echo "-b _CODE=256" >>nuttx.lnk # Start of _CODE area
@echo "-i" >>nuttx.lnk # Intel hex format
+ @echo "-x" >>nuttx.lnk # Hexadecimal
@echo "-m" >>nuttx.lnk # Generate a map file
@echo "-j" >>nuttx.lnk # Generate a symbol file
@echo "nuttx.ihx" >>nuttx.lnk # Path to head object
diff --git a/nuttx/arch/z80/src/common/up_head.asm b/nuttx/arch/z80/src/common/up_head.asm
index 3ebecda38..b9abf69f7 100644
--- a/nuttx/arch/z80/src/common/up_head.asm
+++ b/nuttx/arch/z80/src/common/up_head.asm
@@ -67,7 +67,7 @@
; Reset entry point
;**************************************************************************
- .area START (ABS)
+ .area _HEADER (ABS)
.org 0x0000
di ; Disable interrupts
@@ -162,17 +162,31 @@
; System start logic
;**************************************************************************
-_up_reset:
+_up_reset::
+ ; Set up the stack pointer at the location determined the Makefile
+ ; and stored in asm_mem.h
+
ld SP, #UP_STACK_END ; Set stack pointer
- jp _os_start ; jump to the OS entry point
-forever:
- jp forever
+
+ ; Performed initialization unique to the SDCC toolchain
+
+ call gsinit ; Initialize the data section
+
+ ; Then start NuttX
+
+ call _os_start ; jump to the OS entry point
+
+ ; NuttX will never return, but just in case...
+
+_up_halt::
+ halt ; We should never get here
+ jp _up_halt
;**************************************************************************
; Common Interrupt handler
;**************************************************************************
-_up_rstcommon:
+_up_rstcommon::
; Create a register frame. SP points to top of frame + 4, pushes
; decrement the stack pointer. Already have
;
@@ -241,10 +255,29 @@ _up_rstcommon:
ex af, af' ; Restore AF (before enabling interrupts)
ei ; yes
reti
-nointenable:
+nointenable::
ex af, af' ; Restore AF
reti
+;**************************************************************************
+; Ordering of segments for the linker (SDCC only)
+;**************************************************************************
+
+ .area _HOME
+ .area _CODE
+ .area _GSINIT
+ .area _GSFINAL
+ .area _DATA
+ .area _BSS
+ .area _HEAP
+
+;**************************************************************************
+; Global data initialization logic (SDCC only)
+;**************************************************************************
+ .area _GSINIT
+gsinit::
+ .area _GSFINAL
+ ret
diff --git a/nuttx/arch/z80/src/common/up_restoreusercontext.asm b/nuttx/arch/z80/src/common/up_restoreusercontext.asm
index 61a8855b4..5d34278c2 100644
--- a/nuttx/arch/z80/src/common/up_restoreusercontext.asm
+++ b/nuttx/arch/z80/src/common/up_restoreusercontext.asm
@@ -49,6 +49,7 @@
; up_restoreusercontext
;**************************************************************************
+ .area _CODE
_up_restoreusercontext:
; On entry, stack contains return address (not used), then address
; of the register save structure
diff --git a/nuttx/arch/z80/src/common/up_saveusercontext.asm b/nuttx/arch/z80/src/common/up_saveusercontext.asm
index b5c0dbb21..bd8f54831 100644
--- a/nuttx/arch/z80/src/common/up_saveusercontext.asm
+++ b/nuttx/arch/z80/src/common/up_saveusercontext.asm
@@ -62,7 +62,7 @@
; Name: up_saveusercontext
;*************************************************************************
-; .area _CODE (ABS,OVR)
+ .area _CODE
_up_saveusercontext:
; Set up a stack frame