From 3d2d6dfb406717ac8a90761890e512b138f7389c Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 11 Feb 2008 17:11:20 +0000 Subject: Adding Z8Encore\! git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@666 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/ChangeLog | 3 + nuttx/Documentation/NuttX.html | 28 +- nuttx/Documentation/NuttxPortingGuide.html | 40 ++- nuttx/arch/z80/src/Makefile | 186 +------------- nuttx/arch/z80/src/Makefile.sdcc | 219 ++++++++++++++++ nuttx/arch/z80/src/Makefile.zdsii | 126 +++++++++ nuttx/arch/z80/src/common/up_head.asm | 283 --------------------- .../arch/z80/src/common/up_restoreusercontext.asm | 104 -------- nuttx/arch/z80/src/common/up_saveusercontext.asm | 143 ----------- nuttx/arch/z80/src/z80/Make.defs | 12 +- nuttx/arch/z80/src/z80/z80_head.asm | 283 +++++++++++++++++++++ nuttx/arch/z80/src/z80/z80_restoreusercontext.asm | 104 ++++++++ nuttx/arch/z80/src/z80/z80_saveusercontext.asm | 143 +++++++++++ nuttx/configs/README.txt | 5 + nuttx/configs/z16f2800100zcog/ostest/setenv.sh | 4 +- nuttx/configs/z16f2800100zcog/src/z16f_leds.c | 2 +- 16 files changed, 957 insertions(+), 728 deletions(-) create mode 100644 nuttx/arch/z80/src/Makefile.sdcc create mode 100644 nuttx/arch/z80/src/Makefile.zdsii delete mode 100644 nuttx/arch/z80/src/common/up_head.asm delete mode 100644 nuttx/arch/z80/src/common/up_restoreusercontext.asm delete mode 100644 nuttx/arch/z80/src/common/up_saveusercontext.asm create mode 100644 nuttx/arch/z80/src/z80/z80_head.asm create mode 100644 nuttx/arch/z80/src/z80/z80_restoreusercontext.asm create mode 100644 nuttx/arch/z80/src/z80/z80_saveusercontext.asm diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index ae4e90a82..5c840fbe5 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -336,3 +336,6 @@ 0.3.9 2008-xx-xx Gregory Nutt + * Began adding support for the ZiLOG Z8Encore! microcontroller for the Z8Encore000ZCO + development board and the Z8F642 part. + diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index fc1ad062c..c7a455600 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: February 10, 2008

+

Last Updated: February 11, 2008

@@ -600,7 +600,28 @@

STATUS: - The preliminary release of support for the z16f was made available in NuttX version 0.3.7. + The initial release of support for the z16f was made available in NuttX version 0.3.7. +

+ + + + + + Zilog Z8Encore! + + + +
+ +

+ Zilog Z8Encore! Microncontroller. + This port use the Zilog z8encore000zco development kit, Z8F642 part, and the Zilog + ZDS-II Windows command line tools. + The development environment is Cygwin under WinXP. +

+

+ STATUS: + The Z8Encore! port is a work in progress and will be released in a future NuttX version.

@@ -969,6 +990,9 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr>
    nuttx-0.3.9 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + * Began adding support for the ZiLOG Z8Encore! microcontroller for the Z8Encore000ZCO + development board and the Z8F642 part. + pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> buildroot-0.1.1 2007-xx-xx <spudmonkey@racsa.co.cr> diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 0e5963b2a..9a668d86c 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -16,7 +16,7 @@

    by

    Gregory Nutt

    -

    Last Update: February 7, 2008

    +

    Last Update: February 11, 2008

    Table of Contents

    @@ -384,7 +384,7 @@ This directory holds common ARM architectures. At present, this includes the following subdirectories:
      -
    • arch/arm/include and arch/arm/common: +
    • arch/arm/include and arch/arm/src/common: Common ARM logic.
    • @@ -426,13 +426,34 @@
    • arch/z16f: Zilog z16f Microcontroller. This port uses the Zilog z16f2800100zcog Development Kit. - This is a work in progress. + This port was released with nuttx-0.3.7.
    • arch/z80: - Zilog z80 Microcontroller. - This port has been verified using only a z80 instruction simulator. -
    • + This directory holds 8-bit ZiLOG architectures. At present, this includes the + Zilog z80 and z8Encore! Microcontrollers. +
        +
      • arch/z80/include and arch/z80/src/common: + Common logic. +
      • + +
      • arch/z80/include/z80 and arch/z80/src/z80: + The Z80 port was released in nuttx-0.3.6 has been verified using only a + z80 instruction simulator. + The set simulator can be found in the NuttX CVS at + http://nuttx.cvs.sourceforge.net/nuttx/misc/sims/z80sim. + This port also the SDCC toolchain (http://sdcc.sourceforge.net/") + (verified with version 2.6.0 and 2.7.0). +
      • + +
      • arch/z80/include/z8 and arch/z80/src/z8: + The Z8Encore! port use the Zilog z8encore000zco + development kit, Z8F642 part, and the Zilog ZDS-II Windows command line + tools. The development environment is Cygwin under WinXP. + This port is in progress and will be released in a future NuttX release. +
      • +
      +

    @@ -621,6 +642,13 @@ This port use the Zilog z16f2800100zcog development kit and the Zilog ZDS-II Windows command line tools. The development environment is Cygwin under WinXP. + + +

  • configs/z8encore000zco + z8Encore! Microncontroller. This port use the Zilog z8encore000zco + development kit, Z8F642 part, and the Zilog ZDS-II Windows command line + tools. The development environment is Cygwin under WinXP. +
  • configs/z80sim: z80 Microcontroller. This port uses a Z80 instruction set simulator. diff --git a/nuttx/arch/z80/src/Makefile b/nuttx/arch/z80/src/Makefile index c5f77d180..39c569783 100644 --- a/nuttx/arch/z80/src/Makefile +++ b/nuttx/arch/z80/src/Makefile @@ -40,186 +40,10 @@ -include chip/Make.defs ############################################################################ -# Tools -# CFLAGS, CPPFLAGS, ASFLAGS, LDFLAGS are set in $(TOPDIR)/Make.defs - -CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(TOPDIR)/sched -CPPFLAGS += -D__ASSEMBLY__ - -############################################################################ -# Files and directories - -# There should be one head source (.asm file) - -HEAD_AOBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT)) - -# Assembly sources and objects - -ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS) -AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT)) - -# C sources and objects - -CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS) -COBJS = $(CSRCS:.c=$(OBJEXT)) - -# All sources and objcts - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -# Sources that can have dependencies (no .asm files) - -DEPSRCS = $(CSRCS) - -# Directories - -ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src -BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board - -VPATH = chip:common - -# Libraries - -LIBGCC = ${shell $(CC) -print-libgcc-file-name} - -# Supports dynamic sizing of HEAP. -# -HEAP_BASE = ${shell ./mkhpbase.sh} - -############################################################################ -# Targets - -all: $(HEAD_AOBJ) libarch$(LIBEXT) - -$(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT) - $(call ASSEMBLE, $<, $@) - -$(COBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -# This is a kludge to work around some conflicting symbols in libsdcc.liXqueb - -$(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB) - @cat $(SDCCLIBDIR)/$(SDCCLIB) | \ - 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 - -# Create a header file that contains addressing information needed by the code - -up_mem.h: - @echo "#ifndef __ARCH_MEM_H" >up_mem.h - @echo "#define __ARCH_MEM_H" >>up_mem.h - @echo "" >>up_mem.h - @echo "#define UP_STACK_END $(CONFIG_DRAM_SIZE)" >> up_mem.h - @echo "#define UP_STACK_BASE (UP_STACK_END - $(CONFIG_PROC_STACK_SIZE))" >> up_mem.h - @echo "#define UP_HEAP1_END UP_STACK_BASE" >> up_mem.h - @echo "#define UP_HEAP1_BASE $(HEAP_BASE)" >> up_mem.h - @echo "" >>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 +# Compiler-Dependent Make +COMPILER = ${shell basename $(CC)} +ifeq ($(COMPILER),sdcc) +include Makefile.sdcc else - @echo " UP_COMPILER == 0" >> asm_mem.h +include Makefile.zdsii 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 - @echo " UP_HEAP1_BASE == $(HEAP_BASE)" >> asm_mem.h - -# Combine all objects in this directory into a library - -libarch$(LIBEXT): up_mem.h asm_mem.h $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $@, $${obj}); \ - done ; ) - -# This builds the libboard library in the board/ subdirectory - -board/libboard$(LIBEXT): - $(MAKE) -C board TOPDIR="$(TOPDIR)" 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 "LD: pass1.ihx" - @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 \ - echo "-l $(TOPDIR)/$$LIB" >> pass1.lnk ;\ - done - @echo "-l myz80.lib" >>pass1.lnk # Name of SDCC z80 library - @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 "-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 - @$(LD) -f pass1.lnk - @rm -f up_mem.h asm_mem.h - @rm -f up_allocateheap$(OBJEXT) $(HEAD_AOBJ) libarch$(LIBEXT) - @$(MAKE) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) - @$(MAKE) TOPDIR="$(TOPDIR)" $(HEAD_AOBJ) - -nuttx.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboard$(LIBEXT) - @echo "LD: nuttx.ihx" - @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 \ - echo "-l $(TOPDIR)/$$LIB" >> nuttx.lnk ;\ - done - @echo "-l myz80.lib" >>nuttx.lnk # Name of SDCC z80 library - @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 - @echo "$(HEAD_AOBJ)" >>nuttx.lnk # Path to head object - @echo "-e" >>nuttx.lnk # End of script - @$(LD) -f nuttx.lnk - -nuttx$(EXEEXT): pass1.ihx nuttx.ihx - @rm -f pass1.* - @packihx nuttx.ihx > $(TOPDIR)/nuttx$(EXEEXT) - @cp -f nuttx.map $(TOPDIR)/. - -# Build dependencies - -.depend: Makefile up_mem.h asm_mem.h chip/Make.defs $(DEPSRCS) - @if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \ - fi - @$(MKDEP) --dep-path chip --dep-path common $(CC) -- $(CFLAGS) -- $(DEPSRCS) >Make.dep - @touch $@ - -depend: .depend - -clean: - @if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \ - fi - @rm -f libarch$(LIBEXT) up_mem.h asm_mem.h pass1.* nuttx.* *~ .*.swp - $(call CLEAN) - -distclean: clean - @if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean ; \ - fi - rm -f Make.dep .depend - --include Make.dep diff --git a/nuttx/arch/z80/src/Makefile.sdcc b/nuttx/arch/z80/src/Makefile.sdcc new file mode 100644 index 000000000..d45be7f93 --- /dev/null +++ b/nuttx/arch/z80/src/Makefile.sdcc @@ -0,0 +1,219 @@ +############################################################################ +# arch/z80/src/Makefile.sdcc +# +# Copyright (C) 2008 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. +# +############################################################################ + +############################################################################ +# Tools +# CFLAGS, CPPFLAGS, ASFLAGS, LDFLAGS are set in $(TOPDIR)/Make.defs + +CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(TOPDIR)/sched +CPPFLAGS += -D__ASSEMBLY__ + +############################################################################ +# Files and directories + +# There should be one head source (.asm file) + +HEAD_AOBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT)) + +# Assembly sources and objects + +ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS) +AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT)) + +# C sources and objects + +CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +# All sources and objcts + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +# Sources that can have dependencies (no .asm files) + +DEPSRCS = $(CSRCS) + +# Directories + +ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src +BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board + +VPATH = chip:common + +# Libraries + +LIBGCC = ${shell $(CC) -print-libgcc-file-name} + +# Supports dynamic sizing of HEAP. +# +HEAP_BASE = ${shell ./mkhpbase.sh} + +############################################################################ +# Targets + +all: $(HEAD_AOBJ) libarch$(LIBEXT) + +$(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT) + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +# This is a kludge to work around some conflicting symbols in libsdcc.liXqueb + +$(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB) + @cat $(SDCCLIBDIR)/$(SDCCLIB) | \ + 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 + +# Create a header file that contains addressing information needed by the code + +up_mem.h: + @echo "#ifndef __ARCH_MEM_H" >up_mem.h + @echo "#define __ARCH_MEM_H" >>up_mem.h + @echo "" >>up_mem.h + @echo "#define UP_STACK_END $(CONFIG_DRAM_SIZE)" >> up_mem.h + @echo "#define UP_STACK_BASE (UP_STACK_END - $(CONFIG_PROC_STACK_SIZE))" >> up_mem.h + @echo "#define UP_HEAP1_END UP_STACK_BASE" >> up_mem.h + @echo "#define UP_HEAP1_BASE $(HEAP_BASE)" >> up_mem.h + @echo "" >>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 + @echo " UP_HEAP1_BASE == $(HEAP_BASE)" >> asm_mem.h + +# Combine all objects in this directory into a library + +libarch$(LIBEXT): up_mem.h asm_mem.h $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + +# This builds the libboard library in the board/ subdirectory + +board/libboard$(LIBEXT): + $(MAKE) -C board TOPDIR="$(TOPDIR)" 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 "LD: pass1.ihx" + @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 \ + echo "-l $(TOPDIR)/$$LIB" >> pass1.lnk ;\ + done + @echo "-l myz80.lib" >>pass1.lnk # Name of SDCC z80 library + @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 "-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 + @$(LD) -f pass1.lnk + @rm -f up_mem.h asm_mem.h + @rm -f up_allocateheap$(OBJEXT) $(HEAD_AOBJ) libarch$(LIBEXT) + @$(MAKE) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) + @$(MAKE) TOPDIR="$(TOPDIR)" $(HEAD_AOBJ) + +nuttx.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboard$(LIBEXT) + @echo "LD: nuttx.ihx" + @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 \ + echo "-l $(TOPDIR)/$$LIB" >> nuttx.lnk ;\ + done + @echo "-l myz80.lib" >>nuttx.lnk # Name of SDCC z80 library + @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 + @echo "$(HEAD_AOBJ)" >>nuttx.lnk # Path to head object + @echo "-e" >>nuttx.lnk # End of script + @$(LD) -f nuttx.lnk + +nuttx$(EXEEXT): pass1.ihx nuttx.ihx + @rm -f pass1.* + @packihx nuttx.ihx > $(TOPDIR)/nuttx$(EXEEXT) + @cp -f nuttx.map $(TOPDIR)/. + +# Build dependencies + +.depend: Makefile up_mem.h asm_mem.h chip/Make.defs $(DEPSRCS) + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \ + fi + @$(MKDEP) --dep-path chip --dep-path common $(CC) -- $(CFLAGS) -- $(DEPSRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \ + fi + @rm -f libarch$(LIBEXT) up_mem.h asm_mem.h pass1.* nuttx.* *~ .*.swp + $(call CLEAN) + +distclean: clean + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean ; \ + fi + rm -f Make.dep .depend + +-include Make.dep diff --git a/nuttx/arch/z80/src/Makefile.zdsii b/nuttx/arch/z80/src/Makefile.zdsii new file mode 100644 index 000000000..afe32ca90 --- /dev/null +++ b/nuttx/arch/z80/src/Makefile.zdsii @@ -0,0 +1,126 @@ +############################################################################ +# arch/z16/src/Makefile +# +# Copyright (C) 2008 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. +# +############################################################################ + +############################################################################ +# Tools +ARCHSRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src +WARCHSRCDIR = ${shell cygpath -w $(ARCHSRCDIR)} +USRINCLUDES = -usrinc:'.;$(WTOPDIR)\sched;$(WARCHSRCDIR);$(WARCHSRCDIR)\common' +INCLUDES = $(ARCHSTDINCLUDES) $(USRINCLUDES) +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(INCLUDES) $(ARCHDEFINES) +CPPFLAGS += -I$(ARCHSRCDIR) +LDFLAGS = @"${shell cygpath -w $(ARCHSRCDIR)/nuttx.linkcmd}" + +############################################################################ +# Files and directories +HEAD_ASRC = $(HEAD_SSRC:.S=$(ASMEXT)) +HEAD_AOBJ = $(HEAD_SSRC:.S=$(OBJEXT)) + +SSRCS = $(CHIP_SSRCS) $(CMN_SSRCS) +ASRCS = $(SSRCS:.S=$(ASMEXT)) +AOBJS = $(SSRCS:.S=$(OBJEXT)) + +CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +DEPSRCS = $(SSRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board + +VPATH = chip:common + +############################################################################ +# Targets +all: $(HEAD_OBJ) libarch$(LIBEXT) + +$(ASRCS) $(HEAD_ASRC): %$(ASMEXT): %.S + @$(CPP) $(CPPFLAGS) $< -o $@.tmp + @cat $@.tmp | sed -e "s/^#/;/g" > $@ + @rm $@.tmp + +$(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT) + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, `cygpath -w $<`, $@) + +libarch$(LIBEXT): $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + +board/libboard$(LIBEXT): + @$(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) + +nuttx.linkcmd: $(LINKCMDTEMPLATE) + @cp -f $(LINKCMDTEMPLATE) nuttx.linkcmd + @echo "\"${shell cygpath -w $(TOPDIR)/nuttx}\"= \\" >>nuttx.linkcmd + @echo " \"${shell cygpath -w $(ARCHSRCDIR)/$(HEAD_AOBJ)}\", \\" >>nuttx.linkcmd + @( for lib in $(LINKLIBS); do \ + echo " \"`cygpath -w $(TOPDIR)/$${lib}`\", \\" >>nuttx.linkcmd; \ + done ; ) + @echo " \"${shell cygpath -w $(ARCHSRCDIR)/board/libboard$(LIBEXT)}\", \\" >>nuttx.linkcmd + @echo " \"${shell cygpath -w $(ZDSSTDLIBDIR)/chelpld$(LIBEXT)}\", \\" >>nuttx.linkcmd + @echo " \"${shell cygpath -w $(ZDSSTDLIBDIR)/fpld$(LIBEXT)}\"" >>nuttx.linkcmd + +nuttx$(EXEEXT): $(HEAD_AOBJ) board/libboard$(LIBEXT) nuttx.linkcmd + @echo "LD: nuttx.hex" + @$(LD) $(LDFLAGS) + +.depend: Makefile chip/Make.defs $(DEPSRCS) + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \ + fi + @$(MKDEP) --dep-path chip --dep-path common $(CC) -- $(CFLAGS) -- $(DEPSRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \ + fi + @rm -f libarch$(LIBEXT) *~ .*.swp + @rm -f nuttx.linkcmd *.asm *.tmp *.map + $(call CLEAN) + +distclean: clean + @if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean ; \ + fi + @rm -f Make.dep .depend + +-include Make.dep diff --git a/nuttx/arch/z80/src/common/up_head.asm b/nuttx/arch/z80/src/common/up_head.asm deleted file mode 100644 index 6ebbe2ba4..000000000 --- a/nuttx/arch/z80/src/common/up_head.asm +++ /dev/null @@ -1,283 +0,0 @@ -;************************************************************************** -; arch/z80/src/common/up_head.asm -; -; Copyright (C) 2007, 2008 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. -; -;************************************************************************** - - .title NuttX for the Z80 - .module z80_head - -;************************************************************************** -; Constants -;************************************************************************** - - ; Register save area layout - - XCPT_I == 0 ; Offset 0: Saved I w/interrupt state in carry - XCPT_BC == 2 ; Offset 1: Saved BC register - XCPT_DE == 4 ; Offset 2: Saved DE register - XCPT_IX == 6 ; Offset 3: Saved IX register - XCPT_IY == 8 ; Offset 4: Saved IY register - XCPT_SP == 10 ; Offset 5: Offset to SP at time of interrupt - XCPT_HL == 12 ; Offset 6: Saved HL register - XCPT_AF == 14 ; Offset 7: Saved AF register - XCPT_PC == 16 ; Offset 8: Offset to PC at time of interrupt - - ; Default stack base (needs to be fixed) - - .include "asm_mem.h" - -;************************************************************************** -; Global symbols used -;************************************************************************** - - .globl _os_start ; OS entry point - .globl _up_decodeirq ; Interrupt decoding logic - -;************************************************************************** -; Reset entry point -;************************************************************************** - - .area _HEADER (ABS) - .org 0x0000 - - di ; Disable interrupts - im 1 ; Set interrupt mode 1 - jr _up_reset ; And boot the system - -;************************************************************************** -; Other reset handlers -; -; Interrupt mode 1 behavior: -; -; 1. M1 cycle: 7 ticks -; Acknowledge interrupt and decrements SP -; 2. M2 cycle: 3 ticks -; Writes the MS byte of the PC onto the stack and decrements SP -; 3. M3 cycle: 3 ticks -; Writes the LS byte of the PC onto the stack and sets the PC to 0x0038. -; -;************************************************************************** - - .org 0x0008 ; RST 1 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #1 ; 1 = Z80_RST1 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0010 ; RST 2 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #2 ; 2 = Z80_RST2 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0018 ; RST 3 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #3 ; 1 = Z80_RST3 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0020 ; RST 4 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #4 ; 1 = Z80_RST4 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0028 ; RST 5 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #5 ; 1 = Z80_RST5 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0030 ; RST 6 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #6 ; 1 = Z80_RST6 - jr _up_rstcommon ; Remaining RST handling is common - - .org 0x0038 ; Int mode 1 / RST 7 - - ; Save AF on the stack, set the interrupt number and jump to the - ; common reset handling logic. - ; Offset 8: Return PC is already on the stack - push af ; Offset 7: AF (retaining flags) - ld a, #7 ; 7 = Z80_RST7 - jr _up_rstcommon ; Remaining RST handling is common - -;************************************************************************** -; NMI interrupt handler -;************************************************************************** - - .org 0x0066 - retn - -;************************************************************************** -; System start logic -;************************************************************************** - -_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 - - ; 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:: - ; Create a register frame. SP points to top of frame + 4, pushes - ; decrement the stack pointer. Already have - ; - ; Offset 8: Return PC is already on the stack - ; Offset 7: AF (retaining flags) - ; - ; IRQ number is in A - - push hl ; Offset 6: HL - ld hl, #(3*2) ; HL is the value of the stack pointer before - add hl, sp ; the interrupt occurred - push hl ; Offset 5: Stack pointer - push iy ; Offset 4: IY - push ix ; Offset 3: IX - push de ; Offset 2: DE - push bc ; Offset 1: BC - - ld b, a ; Save the reset number in B - ld a, i ; Carry bit holds interrupt state - push af ; Offset 0: I with interrupt state in carry - di - - ; Call the interrupt decode logic. SP points to the beggining of the reg structure - - ld hl, #0 ; Argument #2 is the beginning of the reg structure - add hl, sp ; - push hl ; Place argument #2 at the top of stack - push bc ; Argument #1 is the Reset number - inc sp ; (make byte sized) - call _up_decodeirq ; Decode the IRQ - - ; On return, HL points to the beginning of the reg structure to restore - ; Note that (1) the arguments pushed on the stack are not popped, and (2) the - ; original stack pointer is lost. In the normal case (no context switch), - ; HL will contain the value of the SP before the arguments wer pushed. - - ld sp, hl ; Use the new stack pointer - - ; Restore registers. HL points to the beginning of the reg structure to restore - - ex af, af' ; Select alternate AF - pop af ; Offset 0: AF' = I with interrupt state in carry - ex af, af' ; Restore original AF - pop bc ; Offset 1: BC - pop de ; Offset 2: DE - pop ix ; Offset 3: IX - pop iy ; Offset 4: IY - exx ; Use alternate BC/DE/HL - ld hl, #-2 ; Offset of SP to account for ret addr on stack - pop de ; Offset 5: HL' = Stack pointer after return - add hl, de ; HL = Stack pointer value before return - exx ; Restore original BC/DE/HL - pop hl ; Offset 6: HL - pop af ; Offset 7: AF - - ; Restore the stack pointer - - exx ; Use alternate BC/DE/HL - ld sp, hl ; Set SP = saved stack pointer value before return - exx ; Restore original BC/DE/HL - - ; Restore interrupt state - - ex af, af' ; Recover interrupt state - jr nc, nointenable ; No carry, IFF2=0, means disabled - ex af, af' ; Restore AF (before enabling interrupts) - ei ; yes - reti -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 deleted file mode 100644 index 5d34278c2..000000000 --- a/nuttx/arch/z80/src/common/up_restoreusercontext.asm +++ /dev/null @@ -1,104 +0,0 @@ -;************************************************************************** -; common/up_restoreusercontext.asm -; -; Copyright (C) 2007, 2008 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. -; -;************************************************************************** - - ; Register save area layout - - .globl XCPT_I ; Offset 0: Saved I w/interrupt state in carry - .globl XCPT_BC ; Offset 1: Saved BC register - .globl XCPT_DE ; Offset 2: Saved DE register - .globl XCPT_IX ; Offset 3: Saved IX register - .globl XCPT_IY ; Offset 4: Saved IY register - .globl XCPT_SP ; Offset 5: Offset to SP at time of interrupt - .globl XCPT_HL ; Offset 6: Saved HL register - .globl XCPT_AF ; Offset 7: Saved AF register - .globl XCPT_PC ; Offset 8: Offset to PC at time of interrupt - -;************************************************************************** -; up_restoreusercontext -;************************************************************************** - - .area _CODE -_up_restoreusercontext: - ; On entry, stack contains return address (not used), then address - ; of the register save structure - - ; Discard the return address, we won't be returning - - pop hl - - ; Get the address of the beginning of the state save area. Each - ; pop will increment to the next element of the structure - - pop hl ; BC = Address of save structure - ld sp, hl ; SP points to top of storage area - - ; Disable interrupts while we muck with the alternative registers. The - ; Correct interrupt state will be restore below - - di - - ; Restore registers. HL points to the beginning of the reg structure to restore - - ex af, af' ; Select alternate AF - pop af ; Offset 0: AF' = I with interrupt state in carry - ex af, af' ; Restore original AF - pop bc ; Offset 1: BC - pop de ; Offset 2: DE - pop ix ; Offset 3: IX - pop iy ; Offset 4: IY - exx ; Use alternate BC/DE/HL - pop hl ; Offset 5: HL' = Stack pointer after return - exx ; Restore original BC/DE/HL - pop hl ; Offset 6: HL - pop af ; Offset 7: AF - - ; Restore the stack pointer - - exx ; Use alternate BC/DE/HL - pop de ; DE' = return address - ld sp, hl ; Set SP = saved stack pointer value before return - push de ; Save return address for ret instruction - exx ; Restore original BC/DE/HL - - ; Restore interrupt state - - ex af, af' ; Recover interrupt state - jr nc, noinrestore ; No carry, IFF2=0, means disabled - ex af, af' ; Restore AF (before enabling interrupts) - ei ; yes.. Enable interrupts - ret ; and return -noinrestore: - ex af, af' ; Restore AF - ret ; Return with interrupts disabled diff --git a/nuttx/arch/z80/src/common/up_saveusercontext.asm b/nuttx/arch/z80/src/common/up_saveusercontext.asm deleted file mode 100644 index bd8f54831..000000000 --- a/nuttx/arch/z80/src/common/up_saveusercontext.asm +++ /dev/null @@ -1,143 +0,0 @@ -;************************************************************************* -; common/up_saveusercontext.asm -; -; Copyright (C) 2007 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 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. -; -;************************************************************************* - -;************************************************************************* -; Constants -;************************************************************************* - - ; Register save area layout - - .globl XCPT_I ; Offset 0: Saved I w/interrupt state in carry - .globl XCPT_BC ; Offset 1: Saved BC register - .globl XCPT_DE ; Offset 2: Saved DE register - .globl XCPT_IX ; Offset 3: Saved IX register - .globl XCPT_IY ; Offset 4: Saved IY register - .globl XCPT_SP ; Offset 5: Offset to SP at time of interrupt - .globl XCPT_HL ; Offset 6: Saved HL register - .globl XCPT_AF ; Offset 7: Saved AF register - .globl XCPT_PC ; Offset 8: Offset to PC at time of interrupt - - ; Stack frame - - FRAME_IY == 0 ; Location of IY on the stack - FRAME_IX == 2 ; Location of IX on the stack - FRAME_RET == 4 ; Location of return address on the stack - FRAME_REGS == 6 ; Location of reg save area on stack - - SP_OFFSET == 6 - -;************************************************************************* -; Name: up_saveusercontext -;************************************************************************* - - .area _CODE -_up_saveusercontext: - ; Set up a stack frame - - push ix ; Save IX and IY - push iy - ld ix, #0 - add ix, sp ; IX = stack frame - - ; Fetch the address of the save area - - ld e, FRAME_REGS(ix) ; HL = save area address - ld d, FRAME_REGS+1(ix) ; - ld iy, #0 - add iy, de ; IY = save area address - - ; Then save the registers - - ; Save the current interrupt state at offset 0 - - ld a, i ; Get interrupt state - push af - pop hl - ld XCPT_I(iy), l ; Offset 0: I w/interrupt state in carry - ld XCPT_I+1(iy), h - - ; Save BC at offset 1 - - ld XCPT_BC(iy), c ; Offset 1: BC - ld XCPT_BC+1(iy), b - - ; DE is not preserved (offset 2) - - ; Save IX at offset 3 - - ld l, FRAME_IX(ix) ; HL = Saved alue of IX - ld h, FRAME_IX+1(ix) ; - ld XCPT_IX(iy), l ; Offset 3: IX - ld XCPT_IX+1(iy), h ; - - ; Save IY at offset 4 - - ld l, FRAME_IY(ix) ; HL = Saved value of IY - ld h, FRAME_IY+1(ix) ; - ld XCPT_IY(iy), l ; Offset 4: IY - ld XCPT_IY+1(iy), h - - ; Save that stack pointer as it would be upon return in offset 5 - - ld hl, #SP_OFFSET ; Value of stack pointer on return - add hl, sp - ld XCPT_SP(iy), l ; Offset 5 SP - ld XCPT_SP+1(iy), h - - ; HL is saved as the value 1 at offset 6 - - xor a ; A = 0 - ld XCPT_HL+1(iy), a ; Offset 2: HL on return (=1) - inc a ; A = 1 - ld XCPT_HL(iy), a ; - - ; AF is not preserved (offset 7) - - ; Save the return address in offset 8 - - ld l, FRAME_RET(ix) ; HL = Saved return address - ld h, FRAME_RET+1(ix) ; - ld XCPT_PC(iy), l ; Offset 8: PC - ld XCPT_PC+1(iy), h - - ; Return the value 0 - - xor a ; HL = return value of zero - ld l, a - ld h, a - - pop iy - pop ix - ret diff --git a/nuttx/arch/z80/src/z80/Make.defs b/nuttx/arch/z80/src/z80/Make.defs index 0688d159b..1d4d5c29e 100644 --- a/nuttx/arch/z80/src/z80/Make.defs +++ b/nuttx/arch/z80/src/z80/Make.defs @@ -1,7 +1,7 @@ ############################################################################ -# sdcc/src/z80/Make.defs +# arch/z80/src/z80/Make.defs # -# Copyright (C) 2007 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ # 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 +# 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. # @@ -33,9 +33,9 @@ # ############################################################################ -HEAD_ASRC = up_head.asm +HEAD_ASRC = z80_head.asm -CMN_ASRCS = up_saveusercontext.asm up_restoreusercontext.asm +CMN_ASRCS = CMN_CSRCS = up_initialize.c up_allocateheap.c up_initialstate.c \ up_createstack.c up_releasestack.c up_interruptcontext.c \ up_blocktask.c up_unblocktask.c up_exit.c up_releasepending.c \ @@ -44,6 +44,6 @@ CMN_CSRCS = up_initialize.c up_allocateheap.c up_initialstate.c \ up_schedulesigaction.c up_sigdeliver.c \ up_registerdump.c up_usestack.c -CHIP_ASRCS = +CHIP_ASRCS = z80_saveusercontext.asm z80_restoreusercontext.asm CHIP_CSRCS = diff --git a/nuttx/arch/z80/src/z80/z80_head.asm b/nuttx/arch/z80/src/z80/z80_head.asm new file mode 100644 index 000000000..816cab347 --- /dev/null +++ b/nuttx/arch/z80/src/z80/z80_head.asm @@ -0,0 +1,283 @@ +;************************************************************************** +; arch/z80/src/z80/z80_head.asm +; +; Copyright (C) 2007, 2008 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. +; +;************************************************************************** + + .title NuttX for the Z80 + .module z80_head + +;************************************************************************** +; Constants +;************************************************************************** + + ; Register save area layout + + XCPT_I == 0 ; Offset 0: Saved I w/interrupt state in carry + XCPT_BC == 2 ; Offset 1: Saved BC register + XCPT_DE == 4 ; Offset 2: Saved DE register + XCPT_IX == 6 ; Offset 3: Saved IX register + XCPT_IY == 8 ; Offset 4: Saved IY register + XCPT_SP == 10 ; Offset 5: Offset to SP at time of interrupt + XCPT_HL == 12 ; Offset 6: Saved HL register + XCPT_AF == 14 ; Offset 7: Saved AF register + XCPT_PC == 16 ; Offset 8: Offset to PC at time of interrupt + + ; Default stack base (needs to be fixed) + + .include "asm_mem.h" + +;************************************************************************** +; Global symbols used +;************************************************************************** + + .globl _os_start ; OS entry point + .globl _up_decodeirq ; Interrupt decoding logic + +;************************************************************************** +; Reset entry point +;************************************************************************** + + .area _HEADER (ABS) + .org 0x0000 + + di ; Disable interrupts + im 1 ; Set interrupt mode 1 + jr _up_reset ; And boot the system + +;************************************************************************** +; Other reset handlers +; +; Interrupt mode 1 behavior: +; +; 1. M1 cycle: 7 ticks +; Acknowledge interrupt and decrements SP +; 2. M2 cycle: 3 ticks +; Writes the MS byte of the PC onto the stack and decrements SP +; 3. M3 cycle: 3 ticks +; Writes the LS byte of the PC onto the stack and sets the PC to 0x0038. +; +;************************************************************************** + + .org 0x0008 ; RST 1 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #1 ; 1 = Z80_RST1 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0010 ; RST 2 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #2 ; 2 = Z80_RST2 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0018 ; RST 3 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #3 ; 1 = Z80_RST3 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0020 ; RST 4 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #4 ; 1 = Z80_RST4 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0028 ; RST 5 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #5 ; 1 = Z80_RST5 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0030 ; RST 6 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #6 ; 1 = Z80_RST6 + jr _up_rstcommon ; Remaining RST handling is common + + .org 0x0038 ; Int mode 1 / RST 7 + + ; Save AF on the stack, set the interrupt number and jump to the + ; common reset handling logic. + ; Offset 8: Return PC is already on the stack + push af ; Offset 7: AF (retaining flags) + ld a, #7 ; 7 = Z80_RST7 + jr _up_rstcommon ; Remaining RST handling is common + +;************************************************************************** +; NMI interrupt handler +;************************************************************************** + + .org 0x0066 + retn + +;************************************************************************** +; System start logic +;************************************************************************** + +_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 + + ; 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:: + ; Create a register frame. SP points to top of frame + 4, pushes + ; decrement the stack pointer. Already have + ; + ; Offset 8: Return PC is already on the stack + ; Offset 7: AF (retaining flags) + ; + ; IRQ number is in A + + push hl ; Offset 6: HL + ld hl, #(3*2) ; HL is the value of the stack pointer before + add hl, sp ; the interrupt occurred + push hl ; Offset 5: Stack pointer + push iy ; Offset 4: IY + push ix ; Offset 3: IX + push de ; Offset 2: DE + push bc ; Offset 1: BC + + ld b, a ; Save the reset number in B + ld a, i ; Carry bit holds interrupt state + push af ; Offset 0: I with interrupt state in carry + di + + ; Call the interrupt decode logic. SP points to the beggining of the reg structure + + ld hl, #0 ; Argument #2 is the beginning of the reg structure + add hl, sp ; + push hl ; Place argument #2 at the top of stack + push bc ; Argument #1 is the Reset number + inc sp ; (make byte sized) + call _up_decodeirq ; Decode the IRQ + + ; On return, HL points to the beginning of the reg structure to restore + ; Note that (1) the arguments pushed on the stack are not popped, and (2) the + ; original stack pointer is lost. In the normal case (no context switch), + ; HL will contain the value of the SP before the arguments wer pushed. + + ld sp, hl ; Use the new stack pointer + + ; Restore registers. HL points to the beginning of the reg structure to restore + + ex af, af' ; Select alternate AF + pop af ; Offset 0: AF' = I with interrupt state in carry + ex af, af' ; Restore original AF + pop bc ; Offset 1: BC + pop de ; Offset 2: DE + pop ix ; Offset 3: IX + pop iy ; Offset 4: IY + exx ; Use alternate BC/DE/HL + ld hl, #-2 ; Offset of SP to account for ret addr on stack + pop de ; Offset 5: HL' = Stack pointer after return + add hl, de ; HL = Stack pointer value before return + exx ; Restore original BC/DE/HL + pop hl ; Offset 6: HL + pop af ; Offset 7: AF + + ; Restore the stack pointer + + exx ; Use alternate BC/DE/HL + ld sp, hl ; Set SP = saved stack pointer value before return + exx ; Restore original BC/DE/HL + + ; Restore interrupt state + + ex af, af' ; Recover interrupt state + jr nc, nointenable ; No carry, IFF2=0, means disabled + ex af, af' ; Restore AF (before enabling interrupts) + ei ; yes + reti +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/z80/z80_restoreusercontext.asm b/nuttx/arch/z80/src/z80/z80_restoreusercontext.asm new file mode 100644 index 000000000..5807fa811 --- /dev/null +++ b/nuttx/arch/z80/src/z80/z80_restoreusercontext.asm @@ -0,0 +1,104 @@ +;************************************************************************** +; arch/z80/src/z80/z80_restoreusercontext.asm +; +; Copyright (C) 2007, 2008 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. +; +;************************************************************************** + + ; Register save area layout + + .globl XCPT_I ; Offset 0: Saved I w/interrupt state in carry + .globl XCPT_BC ; Offset 1: Saved BC register + .globl XCPT_DE ; Offset 2: Saved DE register + .globl XCPT_IX ; Offset 3: Saved IX register + .globl XCPT_IY ; Offset 4: Saved IY register + .globl XCPT_SP ; Offset 5: Offset to SP at time of interrupt + .globl XCPT_HL ; Offset 6: Saved HL register + .globl XCPT_AF ; Offset 7: Saved AF register + .globl XCPT_PC ; Offset 8: Offset to PC at time of interrupt + +;************************************************************************** +; up_restoreusercontext +;************************************************************************** + + .area _CODE +_up_restoreusercontext: + ; On entry, stack contains return address (not used), then address + ; of the register save structure + + ; Discard the return address, we won't be returning + + pop hl + + ; Get the address of the beginning of the state save area. Each + ; pop will increment to the next element of the structure + + pop hl ; BC = Address of save structure + ld sp, hl ; SP points to top of storage area + + ; Disable interrupts while we muck with the alternative registers. The + ; Correct interrupt state will be restore below + + di + + ; Restore registers. HL points to the beginning of the reg structure to restore + + ex af, af' ; Select alternate AF + pop af ; Offset 0: AF' = I with interrupt state in carry + ex af, af' ; Restore original AF + pop bc ; Offset 1: BC + pop de ; Offset 2: DE + pop ix ; Offset 3: IX + pop iy ; Offset 4: IY + exx ; Use alternate BC/DE/HL + pop hl ; Offset 5: HL' = Stack pointer after return + exx ; Restore original BC/DE/HL + pop hl ; Offset 6: HL + pop af ; Offset 7: AF + + ; Restore the stack pointer + + exx ; Use alternate BC/DE/HL + pop de ; DE' = return address + ld sp, hl ; Set SP = saved stack pointer value before return + push de ; Save return address for ret instruction + exx ; Restore original BC/DE/HL + + ; Restore interrupt state + + ex af, af' ; Recover interrupt state + jr nc, noinrestore ; No carry, IFF2=0, means disabled + ex af, af' ; Restore AF (before enabling interrupts) + ei ; yes.. Enable interrupts + ret ; and return +noinrestore: + ex af, af' ; Restore AF + ret ; Return with interrupts disabled diff --git a/nuttx/arch/z80/src/z80/z80_saveusercontext.asm b/nuttx/arch/z80/src/z80/z80_saveusercontext.asm new file mode 100644 index 000000000..886872f37 --- /dev/null +++ b/nuttx/arch/z80/src/z80/z80_saveusercontext.asm @@ -0,0 +1,143 @@ +;************************************************************************* +; arch/z80/src/z80/z80_saveusercontext.asm +; +; Copyright (C) 2007, 2008 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. +; +;************************************************************************* + +;************************************************************************* +; Constants +;************************************************************************* + + ; Register save area layout + + .globl XCPT_I ; Offset 0: Saved I w/interrupt state in carry + .globl XCPT_BC ; Offset 1: Saved BC register + .globl XCPT_DE ; Offset 2: Saved DE register + .globl XCPT_IX ; Offset 3: Saved IX register + .globl XCPT_IY ; Offset 4: Saved IY register + .globl XCPT_SP ; Offset 5: Offset to SP at time of interrupt + .globl XCPT_HL ; Offset 6: Saved HL register + .globl XCPT_AF ; Offset 7: Saved AF register + .globl XCPT_PC ; Offset 8: Offset to PC at time of interrupt + + ; Stack frame + + FRAME_IY == 0 ; Location of IY on the stack + FRAME_IX == 2 ; Location of IX on the stack + FRAME_RET == 4 ; Location of return address on the stack + FRAME_REGS == 6 ; Location of reg save area on stack + + SP_OFFSET == 6 + +;************************************************************************* +; Name: up_saveusercontext +;************************************************************************* + + .area _CODE +_up_saveusercontext: + ; Set up a stack frame + + push ix ; Save IX and IY + push iy + ld ix, #0 + add ix, sp ; IX = stack frame + + ; Fetch the address of the save area + + ld e, FRAME_REGS(ix) ; HL = save area address + ld d, FRAME_REGS+1(ix) ; + ld iy, #0 + add iy, de ; IY = save area address + + ; Then save the registers + + ; Save the current interrupt state at offset 0 + + ld a, i ; Get interrupt state + push af + pop hl + ld XCPT_I(iy), l ; Offset 0: I w/interrupt state in carry + ld XCPT_I+1(iy), h + + ; Save BC at offset 1 + + ld XCPT_BC(iy), c ; Offset 1: BC + ld XCPT_BC+1(iy), b + + ; DE is not preserved (offset 2) + + ; Save IX at offset 3 + + ld l, FRAME_IX(ix) ; HL = Saved alue of IX + ld h, FRAME_IX+1(ix) ; + ld XCPT_IX(iy), l ; Offset 3: IX + ld XCPT_IX+1(iy), h ; + + ; Save IY at offset 4 + + ld l, FRAME_IY(ix) ; HL = Saved value of IY + ld h, FRAME_IY+1(ix) ; + ld XCPT_IY(iy), l ; Offset 4: IY + ld XCPT_IY+1(iy), h + + ; Save that stack pointer as it would be upon return in offset 5 + + ld hl, #SP_OFFSET ; Value of stack pointer on return + add hl, sp + ld XCPT_SP(iy), l ; Offset 5 SP + ld XCPT_SP+1(iy), h + + ; HL is saved as the value 1 at offset 6 + + xor a ; A = 0 + ld XCPT_HL+1(iy), a ; Offset 2: HL on return (=1) + inc a ; A = 1 + ld XCPT_HL(iy), a ; + + ; AF is not preserved (offset 7) + + ; Save the return address in offset 8 + + ld l, FRAME_RET(ix) ; HL = Saved return address + ld h, FRAME_RET+1(ix) ; + ld XCPT_PC(iy), l ; Offset 8: PC + ld XCPT_PC+1(iy), h + + ; Return the value 0 + + xor a ; HL = return value of zero + ld l, a + ld h, a + + pop iy + pop ix + ret diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index e7675a947..6646c6964 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -338,6 +338,11 @@ configs/z16f2800100zcog development kit and the Zilog ZDS-II Windows command line tools. The development environment is Cygwin under WinXP. +configs/z8encore000zco + z8Encore! Microncontroller. This port use the Zilog z8encore000zco + development kit, Z8F642 part, and the Zilog ZDS-II Windows command line + tools. The development environment is Cygwin under WinXP. + configs/z80zim z80 Microcontroller. This port uses a Z80 instruction set simulator. That simulator can be found in the NuttX CVS at diff --git a/nuttx/configs/z16f2800100zcog/ostest/setenv.sh b/nuttx/configs/z16f2800100zcog/ostest/setenv.sh index 4a9bf1d3b..9651536bd 100755 --- a/nuttx/configs/z16f2800100zcog/ostest/setenv.sh +++ b/nuttx/configs/z16f2800100zcog/ostest/setenv.sh @@ -1,5 +1,5 @@ #!/bin/sh -# z16f2800100zcog/setenv.sh +# configs/z16f2800100zcog/ostest/setenv.sh # # Copyright (C) 2008 Gregory Nutt. All rights reserved. # Author: Gregory Nutt @@ -48,4 +48,4 @@ ZDSBINDIR="C:/Program\ Files/ZiLOG/ZDSII_ZNEO_4.11.0/bin" alias zneoasm="${ZDSBINDIR}/zneoasm.exe" alias zneocc="${ZDSBINDIR}/zneocc.exe" alias zneolib="${ZDSBINDIR}/zneolib.exe" -alias zneolink="${ZDSBINDIR}/zneolink.exe" \ No newline at end of file +alias zneolink="${ZDSBINDIR}/zneolink.exe" diff --git a/nuttx/configs/z16f2800100zcog/src/z16f_leds.c b/nuttx/configs/z16f2800100zcog/src/z16f_leds.c index 49e47282e..612e7a86b 100644 --- a/nuttx/configs/z16f2800100zcog/src/z16f_leds.c +++ b/nuttx/configs/z16f2800100zcog/src/z16f_leds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * up_leds.c + * configs/z16f2800100zcog/z16f_leds.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt -- cgit v1.2.3