Skip to content

Commit

Permalink
Fixes for z80 compilation with SDCC toolchain. There are still a few …
Browse files Browse the repository at this point in the history
…header file and linker issues

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5149 42af7a65-404d-4744-a932-0658087f49c3
  • Loading branch information
patacongo committed Sep 13, 2012
1 parent 3e7c5c1 commit 3fcb8d9
Show file tree
Hide file tree
Showing 35 changed files with 282 additions and 165 deletions.
2 changes: 1 addition & 1 deletion arch/z80/src/Makefile.sdcc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %$(ASMEXT)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)

# This is a kludge to work around some conflicting symbols in libsdcc.liXqueb
# This is a kludge to work around some conflicting symbols in libsdcc.lib

$(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB)
@cat $(SDCCLIBDIR)/$(SDCCLIB) | \
Expand Down
28 changes: 21 additions & 7 deletions arch/z80/src/z80/z80_io.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/z80/src/z80/z80_io.c
*
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -44,9 +44,23 @@
#include "up_internal.h"

/****************************************************************************
* Private Definitions
* 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
****************************************************************************/
Expand All @@ -69,11 +83,11 @@

void outp(char p, char c)
{
_asm
ASM
ld c, 4(ix) ; port
ld a, 5(ix) ; value
out (c), a
_endasm;
ENDASM;
}


Expand All @@ -85,10 +99,10 @@ void outp(char p, char c)
*
****************************************************************************/

char inp(char p)
char inp(char p) NAKED
{
_asm
ASM
ld c, 4(ix) ;port
in l, (c)
_endasm;
ENDASM;
}
18 changes: 13 additions & 5 deletions arch/z80/src/z80/z80_irq.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/z80/src/z80/z80_irq.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -48,6 +48,14 @@
* Private Definitions
****************************************************************************/

#ifdef CONFIG_SDCC_OLD
# define ASM _asm
# define ENDASM _endasm
#else
# define ASM __asm
# define ENDASM __endasm
#endif

/****************************************************************************
* Public Data
****************************************************************************/
Expand Down Expand Up @@ -80,13 +88,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;
}

/****************************************************************************
Expand All @@ -99,7 +107,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
Expand All @@ -109,5 +117,5 @@ void irqrestore(irqstate_t flags) __naked
push af ; Restore stack
push hl ;
ret ; and return
_endasm;
ENDASM;
}
48 changes: 30 additions & 18 deletions configs/xtrs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ Configuring NuttX
This configuration performs a simple, minimal OS test using
examples/ostest. This can be configurated as follows:

cd tools
./configure.sh xtrs/ostest
cd -
. ./setenv.sh

cd tools
./configure.sh xtrs/ostest
cd -
. ./setenv.sh

nsh
This configuration file builds NSH (examples/nsh). This
Expand All @@ -63,10 +62,10 @@ Configuring NuttX

This configuration can be selected by:

cd tools
./configure.sh xtrs/nsh
cd -
. ./setenv.sh
cd tools
./configure.sh xtrs/nsh
cd -
. ./setenv.sh

pashello
Configures to use examples/pashello for execution from FLASH
Expand All @@ -77,10 +76,10 @@ Configuring NuttX

This configuration can be selected by:

cd tools
./configure.sh xtrs/pashello
cd -
. ./setenv.sh
cd tools
./configure.sh xtrs/pashello
cd -
. ./setenv.sh

Building the SDCC toolchain
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -122,18 +121,21 @@ has some compatibilty problems with the older SDCC compiler. For one, you
will need to change the Z80 assember name and options in the Make.defs
files as follows:

-AS = as-z80
+AS = sdasz80
-AS = as-z80
+AS = sdasz80

- @$(AS) $(ASFLAGS) $2 $1
+ $(AS) $(ASFLAGS) $1
- @$(AS) $(ASFLAGS) $2 $1
+ $(AS) $(ASFLAGS) $1

For another, I had other problems building with that 20091106 that look
like compiler bugs. If you are using UBUNTU 9.10, you may have to either
(1) downgrade your GCC compiler to a version 3.x compiler and use one of
the older stable releases, or (2) wait for the next stable SDCC release
after 2.9.0.

See below: If you wish to continue using the older SDCC toolchain, you
must now also add CONFIG_SDCC_OLD=y to your configuration file.

Newer SDCC Versions
^^^^^^^^^^^^^^^^^^^

Expand All @@ -154,4 +156,14 @@ This is the text of bug 3468951 reported on the SourceForge website:
sdcc-2.6.0-asz80-symlen.patch is unnecessary, and it and the corresponding
section from the README can be removed.

These changes have not yet been incorporated or verified.
These changes *have* been incorporated but only partially verified. In order
to get a successful compilation, I had to copy stdarg.h out of the SDCC source
(at sdcc/device/include/stdarg.h) to include/nuttx/stdarg.h.

There are also some library related issues when you get to the final build
that I have not looked into yet.

If you want to back out these change and continue to use the older toolchain
in your build, simpy define the following in your configuration file:

CONFIG_SDCC_OLD=y
2 changes: 1 addition & 1 deletion configs/xtrs/include/board.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/************************************************************
* board/board.h
* configs/xtrs/include/board.h
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion configs/xtrs/include/trs80-m3.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* board/trs80-m3.h
* configs/xtrs/include/trs80-m3.h
*
* Copyright (C) 2008 Jacques Pelletier. All rights reserved.
* Author: Jacques Pelletier
Expand Down
39 changes: 25 additions & 14 deletions configs/xtrs/nsh/Make.defs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# configs/xtrs/Make.defs
# configs/xtrs/nsh/Make.defs
#
# Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
Expand Down Expand Up @@ -36,27 +36,38 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
CROSSDEV =
CC = sdcc
CPP = sdcpp
AR = sdcclib -a

ifeq ($(CONFIG_SDCC_OLD),y)

LD = link-z80
AS = as-z80
ARCHCPUFLAGS = -mz80 --stack-auto --int-long-reent --float-reent

else

LD = sdldz80
AS = sdasz80
ARCHCPUFLAGS = -mz80

endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = --debug
else
ARCHOPTIMIZATION =
endif

ARCHCPUFLAGS = -mz80 --stack-auto --int-long-reent --float-reent
ARCHPICFLAGS =
ARCHWARNINGS =
ARCHPICFLAGS =
ARCHWARNINGS =
ARCHDEFINES =
ARCHINCLUDES = -I. -I$(TOPDIR)/include

CROSSDEV =
CC = sdcc
CPP = sdcpp
LD = link-z80
AS = as-z80
AR = sdcclib -a
ARCHINCLUDES = -I. -I$(TOPDIR)/include

CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
ASFLAGS = -x -a -l -o -s

Expand Down
2 changes: 1 addition & 1 deletion configs/xtrs/nsh/defconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# sim/xtrs/nsh/defconfig
# configs/xtrs/nsh/defconfig
#
# Copyright (C) 2007-2010, 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion configs/xtrs/nsh/setenv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# xtrs/setenv.sh
# configs/xtrs/nsh/setenv.sh
#
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
Expand Down
39 changes: 25 additions & 14 deletions configs/xtrs/ostest/Make.defs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# configs/xtrs/Make.defs
# configs/xtrs/ostest/Make.defs
#
# Copyright (C) 2008, 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
Expand Down Expand Up @@ -36,27 +36,38 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
CROSSDEV =
CC = sdcc
CPP = sdcpp
AR = sdcclib -a

ifeq ($(CONFIG_SDCC_OLD),y)

LD = link-z80
AS = as-z80
ARCHCPUFLAGS = -mz80 --stack-auto --int-long-reent --float-reent

else

LD = sdldz80
AS = sdasz80
ARCHCPUFLAGS = -mz80

endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = --debug
else
ARCHOPTIMIZATION =
endif

ARCHCPUFLAGS = -mz80 --stack-auto --int-long-reent --float-reent
ARCHPICFLAGS =
ARCHWARNINGS =
ARCHPICFLAGS =
ARCHWARNINGS =
ARCHDEFINES =
ARCHINCLUDES = -I. -I$(TOPDIR)/include

CROSSDEV =
CC = sdcc
CPP = sdcpp
LD = link-z80
AS = as-z80
AR = sdcclib -a
ARCHINCLUDES = -I. -I$(TOPDIR)/include

CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
ASFLAGS = -x -a -l -o -s

Expand Down
2 changes: 1 addition & 1 deletion configs/xtrs/ostest/setenv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# xtrs/setenv.sh
# configs/xtrs/ostest/setenv.sh
#
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
Expand Down
Loading

0 comments on commit 3fcb8d9

Please sign in to comment.