From ce8536d51f06a57ab96f4507d65c3d00d99be0f4 Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Tue, 12 Feb 2008 20:51:40 +0000
Subject: [PATCH] ZDS-II toolchain does not need up_mem.h

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@674 42af7a65-404d-4744-a932-0658087f49c3
---
 arch/z80/src/Makefile.zdsii           | 28 +++++----------------------
 arch/z80/src/common/up_allocateheap.c | 27 ++++++++++++++++++++++++--
 arch/z80/src/common/up_assert.c       |  1 -
 3 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/arch/z80/src/Makefile.zdsii b/arch/z80/src/Makefile.zdsii
index afb1b07a15..199293ef36 100644
--- a/arch/z80/src/Makefile.zdsii
+++ b/arch/z80/src/Makefile.zdsii
@@ -77,30 +77,12 @@ $(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT)
 $(COBJS): %$(OBJEXT): %.c
 	$(call COMPILE, `cygpath -w $<`, $@)
 
-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 "#ifndef CONFIG_HEAP1_BASE" >>up_mem.h
-	@echo "  extern far unsigned long far_heapbot;" >>up_mem.h
-	@echo "# define CONFIG_HEAP1_BASE ((uint16)&far_heapbot)" >>up_mem.h
-	@echo "#endif" >>up_mem.h
-	@echo "" >>up_mem.h
-	@echo "#ifndef CONFIG_HEAP1_END" >>up_mem.h
-	@echo "  extern far unsigned long far_heaptop;" >>up_mem.h
-	@echo "# define CONFIG_HEAP1_END ((uint16)&far_heaptop)" >>up_mem.h
-	@echo "#endif" >>up_mem.h
-	@echo "" >>up_mem.h
-	@echo "#endif /* __UP_MEM_H */" >>up_mem.h
-
-libarch$(LIBEXT): up_mem.h $(OBJS)
+libarch$(LIBEXT): $(OBJS)
 	@( for obj in $(OBJS) ; do \
 		$(call ARCHIVE, $@, $${obj}); \
 	done ; )
 
-board/libboard$(LIBEXT): up_mem.h
+board/libboard$(LIBEXT):
 	@$(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT)
 
 nuttx.linkcmd: $(LINKCMDTEMPLATE)
@@ -116,11 +98,11 @@ nuttx.linkcmd: $(LINKCMDTEMPLATE)
 	@echo "  \"${shell cygpath -w $(ZDSSTDLIBDIR)/csioLDD$(LIBEXT)}\", \\"  >>nuttx.linkcmd
 	@echo "  \"${shell cygpath -w $(ZDSSTDLIBDIR)/zsldevinitdummy.lib$(LIBEXT)}\" \\"  >>nuttx.linkcmd
  
-nuttx$(EXEEXT): up_mem.h $(HEAD_AOBJ) board/libboard$(LIBEXT) nuttx.linkcmd
+nuttx$(EXEEXT): $(HEAD_AOBJ) board/libboard$(LIBEXT) nuttx.linkcmd
 	@echo "LD:  nuttx.hex"
 	@$(LD) $(LDFLAGS)
 
-.depend: Makefile up_mem.h chip/Make.defs $(DEPSRCS)
+.depend: Makefile chip/Make.defs $(DEPSRCS)
 	@if [ -e board/Makefile ]; then \
 		$(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \
 	fi
@@ -134,7 +116,7 @@ clean:
 		$(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \
 	fi
 	@rm -f libarch$(LIBEXT) *~ .*.swp
-	@rm -f nuttx.linkcmd up_mem.h *.asm *.tmp *.map
+	@rm -f nuttx.linkcmd *.asm *.tmp *.map
 	$(call CLEAN)
 
 distclean: clean
diff --git a/arch/z80/src/common/up_allocateheap.c b/arch/z80/src/common/up_allocateheap.c
index 4b21b575c3..270e3e0d93 100644
--- a/arch/z80/src/common/up_allocateheap.c
+++ b/arch/z80/src/common/up_allocateheap.c
@@ -46,12 +46,35 @@
 
 #include "up_arch.h"
 #include "up_internal.h"
-#include "up_mem.h"
+
+/* For the SDCC toolchain, the arch/z80/src/Makefile will parse the map file
+ * to determin how much memory is available for the heap.  This parsed data
+ * is provided via the auto-generated file up_mem.h
+ */
+
+#ifdef SDCC
+#  include "up_mem.h"
+#endif
 
 /****************************************************************************
- * Private Definitions
+ * Definitions
  ****************************************************************************/
 
+/* For the ZiLOG ZDS-II toolchain(s), the heap will be set using linker-
+ * defined values.
+ */
+
+#ifdef __ZILOG__
+#  ifndef CONFIG_HEAP1_BASE
+     extern far unsigned long far_heapbot;
+#    define CONFIG_HEAP1_BASE ((uint16)&far_heapbot)
+#  endif
+#  ifndef CONFIG_HEAP1_END
+     extern far unsigned long far_heaptop;
+#    define CONFIG_HEAP1_END ((uint16)&far_heaptop)
+#  endif
+#endif
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
diff --git a/arch/z80/src/common/up_assert.c b/arch/z80/src/common/up_assert.c
index b409df425c..d7243e7162 100644
--- a/arch/z80/src/common/up_assert.c
+++ b/arch/z80/src/common/up_assert.c
@@ -51,7 +51,6 @@
 #include "up_arch.h"
 #include "os_internal.h"
 #include "up_internal.h"
-#include "up_mem.h"
 
 /****************************************************************************
  * Definitions
-- 
GitLab