diff options
Diffstat (limited to 'nuttx/arch')
-rw-r--r-- | nuttx/arch/z80/src/Makefile.sdccl | 155 | ||||
-rw-r--r-- | nuttx/arch/z80/src/Makefile.sdccw | 146 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_arch.h | 6 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_internal.h | 6 | ||||
-rwxr-xr-x | nuttx/arch/z80/src/mkhpbase.bat | 45 | ||||
-rwxr-xr-x | nuttx/arch/z80/src/mkhpbase.sh | 109 | ||||
-rw-r--r-- | nuttx/arch/z80/src/z80/up_mem.h | 75 | ||||
-rw-r--r-- | nuttx/arch/z80/src/z80/z80_head.asm | 21 | ||||
-rw-r--r-- | nuttx/arch/z80/src/z80/z80_io.c | 24 | ||||
-rw-r--r-- | nuttx/arch/z80/src/z80/z80_irq.c | 16 |
10 files changed, 196 insertions, 407 deletions
diff --git a/nuttx/arch/z80/src/Makefile.sdccl b/nuttx/arch/z80/src/Makefile.sdccl index 916f85b70..d4cf28a45 100644 --- a/nuttx/arch/z80/src/Makefile.sdccl +++ b/nuttx/arch/z80/src/Makefile.sdccl @@ -75,15 +75,11 @@ VPATH = chip:common:board LIBGCC = ${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name} -# Supports dynamic sizing of HEAP. -# -HEAP_BASE = ${shell ./mkhpbase.sh} - # Targets all: $(HEAD_OBJ) libarch$(LIBEXT) -.PHONY: board/libboard$(LIBEXT) pass1.lnk nuttx.lnk +.PHONY: board/libboard$(LIBEXT) nuttx.lnk $(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %$(ASMEXT) $(call ASSEMBLE, $<, $@) @@ -93,72 +89,46 @@ $(COBJS): %$(OBJEXT): %.c # This is a kludge to work around some conflicting symbols in libsdcc.lib -$(TOPDIR)/lib/myz80.lib: $(SDCC_LIBDIR)/$(SDCCLIB) -ifeq ($(CONFIG_SDCC_OLD),y) - $(Q) cat $(SDCC_LIBDIR)/$(SDCCLIB) | \ - grep -v alloc | grep -v free | grep -v printf | \ - grep -v _str | grep -v _mem | grep -v crt0\.o \ - > $(TOPDIR)/lib/myz80.lib -else - $(Q) cp $(SDCC_LIBDIR)/z80.lib $(TOPDIR)/lib/myz80.lib - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _calloc.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _malloc.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _realloc.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _free.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib printf_large.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib sprintf.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib vprintf.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib strcpy.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib strlen.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strcat.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strchr.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strcmp.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strcspn.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strncat.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strncmp.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strncpy.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strpbrk.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strrchr.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strspn.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strstr.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _strtok.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _memchr.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _memcmp.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _memcpy.rel - $(Q) sdar d $(TOPDIR)/lib/myz80.lib _memset.rel -endif - -# Create a header file that contains addressing information needed by the code - -up_mem.h: - @echo "#ifndef __UP_MEM_H" >up_mem.h - @echo "#define __UP_MEM_H" >>up_mem.h - @echo "" >>up_mem.h - @echo "#include <nuttx/config.h>" >>up_mem.h - @echo "" >>up_mem.h - @echo "#define CONFIG_STACK_END $(CONFIG_DRAM_SIZE)" >> up_mem.h - @echo "#define CONFIG_STACK_BASE (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE))" >> up_mem.h - @echo "#define CONFIG_HEAP1_END CONFIG_STACK_BASE" >> up_mem.h - @echo "#define CONFIG_HEAP1_BASE $(HEAP_BASE)" >> up_mem.h - @echo "" >>up_mem.h - @echo "#endif /* __UP_MEM_H */" >>up_mem.h +$(TOPDIR)/lib/$(SDCCLIB): $(SDCC_LIBDIR)/$(SDCCLIB) + $(Q) cp $(SDCC_LIBDIR)/$(SDCCLIB) $(TOPDIR)/lib/$(SDCCLIB) + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _calloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _malloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _realloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _free.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) printf_large.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) sprintf.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) vprintf.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) strcpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) strlen.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcat.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcspn.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncat.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strpbrk.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strrchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strspn.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strstr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strtok.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memcmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memcpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memset.rel + +# Create a header file that contains addressing information needed by the +# assemlby language start-up code. Locate the IDLE thread stack at the +# end of RAM. The heap then extends from s__HEAP to the bottom of the +# IDLE thread stack asm_mem.h: - @echo " CONFIG_COMPILER_OTHER == 0" > asm_mem.h - @echo " CONFIG_COMPILER_SDCC == 1" >> asm_mem.h -ifeq ($(CC),sdcc) - @echo " CONFIG_COMPILER == 1" >> asm_mem.h -else - @echo " CONFIG_COMPILER == 0" >> asm_mem.h -endif @echo " CONFIG_STACK_END == ($(CONFIG_DRAM_SIZE) - 1)" >> asm_mem.h @echo " CONFIG_STACK_BASE == (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE))" >> asm_mem.h - @echo " CONFIG_HEAP1_END == (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE) - 1)" >> asm_mem.h - @echo " CONFIG_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) +libarch$(LIBEXT): asm_mem.h $(OBJS) $(call ARCHIVE, $@, $(OBJS)) # This builds the libboard library in the board/ subdirectory @@ -168,43 +138,6 @@ board/libboard$(LIBEXT): # This target builds the final executable -pass1.lnk: - @echo "LD: pass1.ihx" - @echo "--" >pass1.lnk # Non-interactive - @echo "-k $(BOARDDIR)" >>pass1.lnk # Path to board library - @echo "-k $(TOPDIR)/lib" >>pass1.lnk # Path to top-level lib-directory - @echo "-l libboard$(LIBEXT)" >>pass1.lnk # Name of board library - $(Q) for LIB in $(LINKLIBS); do \ - echo "-l $(TOPDIR)/lib/$$LIB" >> pass1.lnk ;\ - done - @echo "-l myz80.lib" >>pass1.lnk # Name of SDCC z80 library -ifneq ($(CONFIG_LINKER_START_AREA),) - @echo "-b START=$(CONFIG_LINKER_START_AREA)" >>pass1.lnk # Start of START area -endif -ifneq ($(CONFIG_LINKER_CODE_AREA),) - @echo "-b _CODE=$(CONFIG_LINKER_CODE_AREA)" >>pass1.lnk # Start of _CODE area -else - @echo "-b _CODE=256" >>pass1.lnk # Start of _CODE area -endif -ifneq ($(CONFIG_LINKER_DATA_AREA),) - @echo "-b _CODE=$(CONFIG_LINKER_DATA_AREA)" >>pass1.lnk -endif - @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_OBJ)" >>pass1.lnk # Path to head object - @echo "-e" >>pass1.lnk # End of script - -pass1.ihx: up_mem.h asm_mem.h $(TOPDIR)/lib/myz80.lib $(HEAD_OBJ) board/libboard$(LIBEXT) pass1.lnk - @echo "LD: pass1.ihx" - $(Q) $(LD) -f pass1.lnk - $(Q) rm -f up_mem.h asm_mem.h - $(Q) rm -f up_allocateheap$(OBJEXT) $(HEAD_OBJ) libarch$(LIBEXT) - $(Q) $(MAKE) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) - $(Q) $(MAKE) TOPDIR="$(TOPDIR)" $(HEAD_OBJ) - nuttx.lnk: @echo "--" >nuttx.lnk # Non-interactive @echo "-k $(BOARDDIR)" >>nuttx.lnk # Path to board library @@ -213,7 +146,18 @@ nuttx.lnk: $(Q) for LIB in $(LINKLIBS); do \ echo "-l $(TOPDIR)/lib/$$LIB" >> nuttx.lnk ;\ done - @echo "-l myz80.lib" >>nuttx.lnk # Name of SDCC z80 library + @echo "-l $(SDCCLIB)" >>nuttx.lnk # Name of SDCC z80 library +ifneq ($(CONFIG_LINKER_CODE_AREA),) + @echo "-b _CODE=$(CONFIG_LINKER_CODE_AREA)" >>nuttx.lnk # Start of _CODE area +else + @echo "-b _CODE=0x0200" >>nuttx.lnk # Start of _CODE area +endif +ifneq ($(CONFIG_LINKER_DATA_AREA),) + @echo "-b _CODE=$(CONFIG_LINKER_DATA_AREA)" >>nuttx.lnk +else + @echo "-b _DATA=0x8000" >>nuttx.lnk # Start of _DATA area +endif + ifneq ($(CONFIG_LINKER_START_AREA),) @echo "-b START=$(CONFIG_LINKER_START_AREA)" >>nuttx.lnk # Start of START area endif @@ -233,10 +177,9 @@ endif @echo "$(HEAD_OBJ)" >>nuttx.lnk # Path to head object @echo "-e" >>nuttx.lnk # End of script -nuttx$(EXEEXT): pass1.ihx up_mem.h asm_mem.h $(TOPDIR)/lib/myz80.lib $(HEAD_OBJ) board/libboard$(LIBEXT) nuttx.lnk +nuttx$(EXEEXT): asm_mem.h $(TOPDIR)/lib/$(SDCCLIB) $(HEAD_OBJ) board/libboard$(LIBEXT) nuttx.lnk @echo "LD: nuttx.ihx" $(Q) $(LD) -f nuttx.lnk - $(Q) rm -f pass1.* $(Q) cp -f nuttx.map $(TOPDIR)/. ifeq ($(EXEEXT),.cmd) sed s/:00000001FF/:00520001AD/ nuttx.ihx | \ @@ -257,7 +200,7 @@ export_head: board/libboard$(LIBEXT) $(HEAD_OBJ) # Build dependencies -.depend: Makefile up_mem.h asm_mem.h chip/Make.defs $(DEPSRCS) +.depend: Makefile asm_mem.h chip/Make.defs $(DEPSRCS) $(Q) if [ -e board/Makefile ]; then \ $(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \ fi @@ -270,9 +213,7 @@ clean: $(Q) if [ -e board/Makefile ]; then \ $(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \ fi - $(call DELFILE, up_mem.h) $(call DELFILE, asm_mem.h) - $(call DELFILE, pass1.*) $(call DELFILE, nuttx.*) $(call DELFILE, libarch$(LIBEXT)) $(call CLEAN) diff --git a/nuttx/arch/z80/src/Makefile.sdccw b/nuttx/arch/z80/src/Makefile.sdccw index 4433429bb..0cd7b4757 100644 --- a/nuttx/arch/z80/src/Makefile.sdccw +++ b/nuttx/arch/z80/src/Makefile.sdccw @@ -33,16 +33,13 @@ # ############################################################################ -############################################################################ # 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_OBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT)) @@ -77,16 +74,11 @@ VPATH = chip:common:board LIBGCC = ${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name} -# Supports dynamic sizing of HEAP. -# -HEAP_BASE = ${shell .\mkhpbase.bat} - -############################################################################ # Targets all: $(HEAD_OBJ) libarch$(LIBEXT) -.PHONY: board\libboard$(LIBEXT) pass1.lnk nuttx.lnk +.PHONY: board\libboard$(LIBEXT) nuttx.lnk $(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %$(ASMEXT) $(call ASSEMBLE, $<, $@) @@ -96,69 +88,46 @@ $(COBJS): %$(OBJEXT): %.c # This is a kludge to work around some conflicting symbols in the SDCC libraries -$(TOPDIR)\lib\myz80.lib: $(SDCC_LIBDIR)\$(SDCCLIB) -ifeq ($(CONFIG_SDCC_OLD),y) - $(Q) cat $(SDCC_LIBDIR)\$(SDCCLIB) | \ - grep -v alloc | grep -v free | grep -v printf | \ - grep -v _str | grep -v _mem | grep -v crt0\.o \ - > $(TOPDIR)\lib\myz80.lib -else - $(Q) cp $(SDCC_LIBDIR)\z80.lib $(TOPDIR)\lib\myz80.lib - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _calloc.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _malloc.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _realloc.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _free.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib printf_large.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib sprintf.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib vprintf.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib strcpy.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib strlen.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strcat.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strchr.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strcmp.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strcspn.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strncat.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strncmp.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strncpy.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strpbrk.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strrchr.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strspn.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strstr.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _strtok.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _memchr.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _memcmp.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _memcpy.rel - $(Q) sdar d $(TOPDIR)\lib\myz80.lib _memset.rel -endif - -# Create a header file that contains addressing information needed by the code - -up_mem.h: - @echo #ifndef __UP_MEM_H>up_mem.h - @echo #define __UP_MEM_H>>up_mem.h - @echo #include ^<nuttx/config.h^>>>up_mem.h - @echo #define CONFIG_STACK_END $(CONFIG_DRAM_SIZE)>> up_mem.h - @echo #define CONFIG_STACK_BASE (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE))>> up_mem.h - @echo #define CONFIG_HEAP1_END CONFIG_STACK_BASE>> up_mem.h - @echo #define CONFIG_HEAP1_BASE $(HEAP_BASE)>> up_mem.h - @echo #endif /* __UP_MEM_H */>>up_mem.h +$(TOPDIR)\lib\$(SDCCLIB): $(SDCC_LIBDIR)\$(SDCCLIB) + $(Q) cp $(SDCC_LIBDIR)\$(SDCCLIB) $(TOPDIR)\lib\$(SDCCLIB) + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _calloc.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _malloc.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _realloc.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _free.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) printf_large.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) sprintf.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) vprintf.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) strcpy.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) strlen.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strcat.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strchr.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strcmp.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strcspn.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strncat.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strncmp.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strncpy.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strpbrk.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strrchr.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strspn.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strstr.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _strtok.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _memchr.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _memcmp.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _memcpy.rel + $(Q) sdar d $(TOPDIR)\lib\$(SDCCLIB) _memset.rel + +# Create a header file that contains addressing information needed by the +# assemlby language start-up code. Locate the IDLE thread stack at the +# end of RAM. The heap then extends from s__HEAP to the bottom of the +# IDLE thread stack asm_mem.h: - @echo CONFIG_COMPILER_OTHER == ^0>asm_mem.h - @echo CONFIG_COMPILER_SDCC == ^1>>asm_mem.h -ifeq ($(CC),sdcc) - @echo CONFIG_COMPILER == ^1>>asm_mem.h -else - @echo CONFIG_COMPILER == ^0>>asm_mem.h -endif @echo CONFIG_STACK_END == ($(CONFIG_DRAM_SIZE) - 1)>>asm_mem.h @echo CONFIG_STACK_BASE == (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE))>>asm_mem.h - @echo CONFIG_HEAP1_END == (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE) - 1)>>asm_mem.h - @echo CONFIG_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) +libarch$(LIBEXT): asm_mem.h $(OBJS) $(call ARCHIVE, $@, $(OBJS)) # This builds the libboard library in the board\ subdirectory @@ -168,43 +137,6 @@ board\libboard$(LIBEXT): # This target builds the final executable -pass1.lnk: - @echo LD: pass1.lnk - @echo -->pass1.lnk - @echo -k $(BOARDDIR)>>pass1.lnk - @echo -k $(TOPDIR)\lib>>pass1.lnk - @echo -l libboard$(LIBEXT)>>pass1.lnk - $(Q) for %%G in ($(LINKLIBS)) do ( echo -l $(TOPDIR)\lib\%%G>> pass1.lnk ) - @echo -l myz80.lib>>pass1.lnk -ifneq ($(CONFIG_LINKER_START_AREA),) - @echo -b START=$(CONFIG_LINKER_START_AREA)>>pass1.lnk -else - @echo -b START=0>>pass1.lnk -endif -ifneq ($(CONFIG_LINKER_CODE_AREA),) - @echo -b _CODE=$(CONFIG_LINKER_CODE_AREA)>>pass1.lnk -else - @echo -b _CODE=256>>pass1.lnk -endif -ifneq ($(CONFIG_LINKER_DATA_AREA),) - @echo -b _CODE=$(CONFIG_LINKER_DATA_AREA)>>pass1.lnk -endif - @echo -i>>pass1.lnk - @echo -x>>pass1.lnk - @echo -m>>pass1.lnk - @echo -j>>pass1.lnk - @echo pass1.ihx>>pass1.lnk - @echo $(HEAD_OBJ)>>pass1.lnk - @echo -e>>pass1.lnk - -pass1.ihx: up_mem.h asm_mem.h $(TOPDIR)\lib\myz80.lib $(HEAD_OBJ) board\libboard$(LIBEXT) pass1.lnk - @echo LD: pass1.ihx - $(Q) $(LD) -f pass1.lnk - $(Q) rm -f up_mem.h asm_mem.h - $(Q) rm -f up_allocateheap$(OBJEXT) $(HEAD_OBJ) libarch$(LIBEXT) - $(Q) $(MAKE) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) - $(Q) $(MAKE) TOPDIR="$(TOPDIR)" $(HEAD_OBJ) - nuttx.lnk: @echo LD: nuttx.lnk @echo -->nuttx.lnk @@ -212,7 +144,7 @@ nuttx.lnk: @echo -k $(TOPDIR)\lib>>nuttx.lnk @echo -l libboard$(LIBEXT)>>nuttx.lnk $(Q) for %%G in ($(LINKLIBS)) do ( echo -l $(TOPDIR)\lib\%%G>> nuttx.lnk ) - @echo -l myz80.lib>>nuttx.lnk + @echo -l $(SDCCLIB)>>nuttx.lnk ifneq ($(CONFIG_LINKER_START_AREA),) @echo -b START=$(CONFIG_LINKER_START_AREA)>>nuttx.lnk else @@ -234,10 +166,9 @@ endif @echo $(HEAD_OBJ)>>nuttx.lnk @echo -e>>nuttx.lnk -nuttx$(EXEEXT): pass1.ihx up_mem.h asm_mem.h $(TOPDIR)\lib\myz80.lib $(HEAD_OBJ) board\libboard$(LIBEXT) nuttx.lnk +nuttx$(EXEEXT): asm_mem.h $(TOPDIR)\lib\$(SDCCLIB) $(HEAD_OBJ) board\libboard$(LIBEXT) nuttx.lnk @echo LD: nuttx.ihx $(Q) $(LD) -f nuttx.lnk - $(call DELFILE, pass1.*) $(Q) cp -f nuttx.map $(TOPDIR)\. ifeq ($(EXEEXT),.cmd) sed s/:00000001FF/:00520001AD/ nuttx.ihx | \ @@ -254,7 +185,7 @@ export_head: board\libboard$(LIBEXT) $(HEAD_OBJ) # Build dependencies -.depend: Makefile up_mem.h asm_mem.h chip\Make.defs $(DEPSRCS) +.depend: Makefile asm_mem.h chip\Make.defs $(DEPSRCS) $(Q) if exist board\Makefile ( $(MAKE) -C board TOPDIR="$(TOPDIR)" depend ) $(Q) $(MKDEP) --dep-path chip --dep-path common "$(CC)" -- $(CFLAGS) -- $(DEPSRCS) >Make.dep $(Q) touch $@ @@ -263,14 +194,11 @@ depend: .depend clean: $(Q) if exist board\Makefile ( $(MAKE) -C board TOPDIR="$(TOPDIR)" clean ) - $(call DELFILE, up_mem.h) $(call DELFILE, asm_mem.h) - $(call DELFILE, pass1.*) $(call DELFILE, nuttx.*) $(call DELFILE, libarch$(LIBEXT)) $(call CLEAN) - distclean: clean $(Q) if exist board\Makefile ( $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean ) $(call DELFILE, Make.dep) diff --git a/nuttx/arch/z80/src/common/up_arch.h b/nuttx/arch/z80/src/common/up_arch.h index 99087bb08..43c750e4e 100644 --- a/nuttx/arch/z80/src/common/up_arch.h +++ b/nuttx/arch/z80/src/common/up_arch.h @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef __UP_ARCH_H -#define __UP_ARCH_H +#ifndef __ARCH_Z80_SRC_COMMON_UP_ARCH_H +#define __ARCH_Z80_SRC_COMMON_UP_ARCH_H /************************************************************************************ * Included Files @@ -49,4 +49,4 @@ * Definitions ************************************************************************************/ -#endif /* __UP_ARCH_H */ +#endif /* __ARCH_Z80_SRC_COMMON_UP_ARCH_H */ diff --git a/nuttx/arch/z80/src/common/up_internal.h b/nuttx/arch/z80/src/common/up_internal.h index 960061a80..1989f99d0 100644 --- a/nuttx/arch/z80/src/common/up_internal.h +++ b/nuttx/arch/z80/src/common/up_internal.h @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __UP_INTERNAL_H -#define __UP_INTERNAL_H +#ifndef __ARCH_Z80_SRC_COMMON_UP_INTERNAL_H +#define __ARCH_Z80_SRC_COMMON_UP_INTERNAL_H /**************************************************************************** * Conditional Compilation @@ -209,4 +209,4 @@ EXTERN void up_stackdump(void); #endif #endif -#endif /* __UP_INTERNAL_H */ +#endif /* __ARCH_Z80_SRC_COMMON_UP_INTERNAL_H */ diff --git a/nuttx/arch/z80/src/mkhpbase.bat b/nuttx/arch/z80/src/mkhpbase.bat deleted file mode 100755 index 8792f73a4..000000000 --- a/nuttx/arch/z80/src/mkhpbase.bat +++ /dev/null @@ -1,45 +0,0 @@ -@echo off - -rem arch/z80/src/mkhpbase.bat -rem -rem Copyright (C) 2012 Gregory Nutt. All rights reserved. -rem Author: Gregory Nutt <gnutt@nuttx.org> -rem -rem Redistribution and use in source and binary forms, with or without -rem modification, are permitted provided that the following conditions -rem are met: -rem -rem 1. Redistributions of source code must retain the above copyright -rem notice, this list of conditions and the following disclaimer. -rem 2. Redistributions in binary form must reproduce the above copyright -rem notice, this list of conditions and the following disclaimer in -rem the documentation and/or other materials provided with the -rem distribution. -rem 3. Neither the name NuttX nor the names of its contributors may be -rem used to endorse or promote products derived from this software -rem without specific prior written permission. -rem -rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -rem FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -rem COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -rem BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -rem OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -rem AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -rem LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -rem ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -rem POSSIBILITY OF SUCH DAMAGE. -rem - -rem -rem This script supports dynamic sizing of HEAP when building with the SDCC -rem toolchain. This script adds up the size of each section of the program. -rem This does not account for the alignment of the _CODE area to 0x0100 (hence -rem the fudge factor 196 is added). -rem -rem -- There must be a better way! --- -rem - -echo (CONFIG_HEAP1_END - 8192) diff --git a/nuttx/arch/z80/src/mkhpbase.sh b/nuttx/arch/z80/src/mkhpbase.sh deleted file mode 100755 index 1d7acb7d5..000000000 --- a/nuttx/arch/z80/src/mkhpbase.sh +++ /dev/null @@ -1,109 +0,0 @@ -#/bin/sh -############################################################################ -# arch/z80/src/mkhpbase.sh -# -# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <gnutt@nuttx.org> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ -# -# This script supports dynamic sizing of HEAP when building with the SDCC -# toolchain. This script adds up the size of each section of the program. -# This does not account for the alignment of the _CODE area to 0x0100 (hence -# the fudge factor 196 is added). -# -# -- There must be a better way! --- -# -#set -x - -MAPFILE=pass1.map - -# Verify that pass1.map exists - -if [ -e ${MAPFILE} ]; then - - # The map file exists, get a list of the sizes of each section - # This works for SDCC 2.7.0 - - list=`cat ${MAPFILE} | grep "bytes" | sed -e 's/[ \t][ \t]*/ /g' | cut -d' ' -f3` - - # If this is SDCC version 2.6.0, then the list will be empty - - if [ -z "${list}" ]; then - - # This works for SDCC 2.6.0 - - list=`cat ${MAPFILE} | grep "SIZE" | sed -e 's/[ \t][ \t]*/ /g' | cut -d' ' -f3` - fi - - # Did we successfully create the list of section sizes? - - if [ ! -z "${list}" ]; then - unset result - first=yes - - # Examine each size in the list - - for size in ${list}; do - - # Skip over zero-length sizes - - if [ "${size}" != "0000" ]; then - - # Each hex size must be prefixed with "0x". The - # First size must also include a left parenthesis - - if [ -z "$first" ]; then - result="${result} + 0x${size}" - else - result="(0x${size}" - unset first - fi - fi - done - - # Add a fudge factor to guarantee no overlap between the code and - # the heap and close the expression with a left parenthesis - - echo "${result} + 196)" - else - - # We could not parse the map file. Try to generate some meaningful error - - echo "#\"Makefile: Could not parse map file\"" - exit 1 - fi -else - # pass1.map does not yet exist. In this case, just output a valid, default heap size - - echo "(CONFIG_HEAP1_END - 8192)" -fi - - diff --git a/nuttx/arch/z80/src/z80/up_mem.h b/nuttx/arch/z80/src/z80/up_mem.h new file mode 100644 index 000000000..9273d3f89 --- /dev/null +++ b/nuttx/arch/z80/src/z80/up_mem.h @@ -0,0 +1,75 @@ +/************************************************************************************ + * common/sdcc.h + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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 nuttx.lnk__ARCH_Z80_SRC_COMMON_UP_MEM_H +#define nuttx.lnk__ARCH_Z80_SRC_COMMON_UP_MEM_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Locate the IDLE thread stack at the end of RAM. */ + +#define CONFIG_STACK_END CONFIG_DRAM_SIZE +#define CONFIG_STACK_BASE (CONFIG_STACK_END - CONFIG_IDLETHREAD_STACKSIZE) + +/* The heap then extends from the linker determined beginning of the heap (s__HEAP). + * to the bottom of the IDLE thread stack. NOTE: The symbol s__HEAP is not + * accessible from C because it does not begin with the _ character. g_heapbase + * is defined in z80_head.asm to provide that value to the C code. + */ + +#define CONFIG_HEAP1_END CONFIG_STACK_BASE +#define CONFIG_HEAP1_BASE g_heapbase + +/************************************************************************************ + * Public variables + ************************************************************************************/ + +/* This is the bottom of the heap as provided by the linker symbol s__HEAP. NOTE: + * The symbol s__HEAP is not accessible from C because it does not begin with the _ + * character. g_heapbase is defined in z80_head.asm to provide that value to the C + * code. + */ + +extern const uint16_t g_heapbase; + +#endif /* nuttx.lnk__ARCH_Z80_SRC_COMMON_UP_MEM_H */ diff --git a/nuttx/arch/z80/src/z80/z80_head.asm b/nuttx/arch/z80/src/z80/z80_head.asm index 828a29d77..1bdc6061f 100644 --- a/nuttx/arch/z80/src/z80/z80_head.asm +++ b/nuttx/arch/z80/src/z80/z80_head.asm @@ -265,10 +265,13 @@ nointenable:: .area _HOME .area _CODE + .area _INITIALIZER .area _GSINIT .area _GSFINAL .area _DATA + .area _INITIALIZED + .area _BSEG .area _BSS .area _HEAP @@ -278,6 +281,24 @@ nointenable:: .area _GSINIT gsinit:: + ld bc, #l__INITIALIZER + ld a, b + or a, c + jr Z, gsinit_next + ld de, #s__INITIALIZED + ld hl, #s__INITIALIZER + ldir +gsinit_next: + .area _GSFINAL ret +;************************************************************************** +; The start of the heap (SDCC only). Note that is actually resides in +; the _CODE area (which may be FLASH or ROM) +;************************************************************************** + + .area _CODE +_g_heapbase:: + .dw #s__HEAP + diff --git a/nuttx/arch/z80/src/z80/z80_io.c b/nuttx/arch/z80/src/z80/z80_io.c index bdd55bc6b..1db636d30 100644 --- a/nuttx/arch/z80/src/z80/z80_io.c +++ b/nuttx/arch/z80/src/z80/z80_io.c @@ -47,20 +47,6 @@ * Pre-processor Definitions ****************************************************************************/ -#undef ASM -#undef ENDASM -#undef NAKED - -#ifdef CONFIG_SDCC_OLD -# define ASM _asm -# define ENDASM _endasm -# define NAKED -#else -# define ASM __asm -# define ENDASM __endasm -# define NAKED __naked -#endif - /**************************************************************************** * Private Data ****************************************************************************/ @@ -83,11 +69,11 @@ void outp(char p, char c) { - ASM + __asm ld c, 4(ix) ; port ld a, 5(ix) ; value out (c), a - ENDASM; + __endasm; } @@ -99,10 +85,10 @@ void outp(char p, char c) * ****************************************************************************/ -char inp(char p) NAKED +char inp(char p) __naked { - ASM + __asm ld c, 4(ix) ;port in l, (c) - ENDASM; + __endasm; } diff --git a/nuttx/arch/z80/src/z80/z80_irq.c b/nuttx/arch/z80/src/z80/z80_irq.c index 87ea7063a..be5fba4a9 100644 --- a/nuttx/arch/z80/src/z80/z80_irq.c +++ b/nuttx/arch/z80/src/z80/z80_irq.c @@ -48,14 +48,6 @@ * Private Definitions ****************************************************************************/ -#ifdef CONFIG_SDCC_OLD -# define ASM _asm -# define ENDASM _endasm -#else -# define ASM __asm -# define ENDASM __endasm -#endif - /**************************************************************************** * Public Data ****************************************************************************/ @@ -88,13 +80,13 @@ volatile chipreg_t *current_regs; irqstate_t irqsave(void) __naked { - ASM + __asm ld a, i ; AF Parity bit holds interrupt state di ; Interrupts are disabled push af ; Return AF in HL pop hl ; ret ; - ENDASM; + __endasm; } /**************************************************************************** @@ -107,7 +99,7 @@ irqstate_t irqsave(void) __naked void irqrestore(irqstate_t flags) __naked { - ASM + __asm di ; Assume disabled pop hl ; HL = return address pop af ; AF Parity bit holds interrupt state @@ -117,5 +109,5 @@ statedisable: push af ; Restore stack push hl ; ret ; and return - ENDASM; + __endasm; } |