diff --git a/arch/z80/include/io.h b/arch/z80/include/io.h new file mode 100644 index 0000000000..ce6a90ab5b --- /dev/null +++ b/arch/z80/include/io.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * arch/z80/include/io.h + * arch/chip/io.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __ARCH_IO_H +#define __ARCH_IO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif +#endif + +#endif /* __ARCH_IO_H */ diff --git a/arch/z80/include/z80/io.h b/arch/z80/include/z80/io.h new file mode 100644 index 0000000000..dc74d047e9 --- /dev/null +++ b/arch/z80/include/z80/io.h @@ -0,0 +1,85 @@ +/**************************************************************************** + * arch/z80/include/z80/io.h + * arch/chip/io.h + * + * 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. + * + ****************************************************************************/ + +/* This file should never be included directed but, rather, only indirectly + * through arch/io.h + */ + +#ifndef __ARCH_Z80_IO_H +#define __ARCH_Z80_IO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN void outp(char p, char c); +EXTERN char inp(char p); + +#undef EXTERN +#ifdef __cplusplus +} +#endif +#endif + +#endif /* __ARCH_Z80_IO_H */ diff --git a/arch/z80/src/Makefile.sdcc b/arch/z80/src/Makefile.sdcc index 89278d894a..51751be851 100644 --- a/arch/z80/src/Makefile.sdcc +++ b/arch/z80/src/Makefile.sdcc @@ -153,8 +153,16 @@ pass1.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboar echo "-l $(TOPDIR)/$$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 +else @echo "-b START=0" >>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 @echo "-i" >>pass1.lnk # Intel hex format @echo "-x" >>pass1.lnk # Hexadecimal @echo "-m" >>pass1.lnk # Generate a map file @@ -178,8 +186,16 @@ nuttx.ihx: up_mem.h asm_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboar echo "-l $(TOPDIR)/$$LIB" >> nuttx.lnk ;\ done @echo "-l myz80.lib" >>nuttx.lnk # Name of SDCC z80 library +ifneq ($(CONFIG_LINKER_START_AREA),) + @echo "-b START=$(CONFIG_LINKER_START_AREA)" >>nuttx.lnk # Start of START area +else @echo "-b START=0" >>nuttx.lnk # Start of START area +endif +ifneq ($(CONFIG_LINKER_CODE_AREA),) + @echo "-b _CODE=$(CONFIG_LINKER_CODE_AREA)" >>nuttx.lnk # Start of _CODE area +else @echo "-b _CODE=256" >>nuttx.lnk # Start of _CODE area +endif @echo "-i" >>nuttx.lnk # Intel hex format @echo "-x" >>nuttx.lnk # Hexadecimal @echo "-m" >>nuttx.lnk # Generate a map file diff --git a/arch/z80/src/z80/Make.defs b/arch/z80/src/z80/Make.defs index fb1be00e20..b48a4660ff 100644 --- a/arch/z80/src/z80/Make.defs +++ b/arch/z80/src/z80/Make.defs @@ -43,7 +43,7 @@ CMN_CSRCS = up_initialize.c up_allocateheap.c up_createstack.c \ up_mdelay.c up_udelay.c up_usestack.c CHIP_ASRCS = z80_saveusercontext.asm z80_restoreusercontext.asm -CHIP_CSRCS = z80_initialstate.c z80_irq.c z80_copystate.c \ +CHIP_CSRCS = z80_initialstate.c z80_io.c z80_irq.c z80_copystate.c \ z80_schedulesigaction.c z80_sigdeliver.c \ z80_registerdump.c diff --git a/arch/z80/src/z80/z80_io.c b/arch/z80/src/z80/z80_io.c new file mode 100644 index 0000000000..fdd72f1255 --- /dev/null +++ b/arch/z80/src/z80/z80_io.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * arch/z80/src/z80/z80_io.c + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +/* #include */ + +#include "up_internal.h" + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: outb + * + * Description: + * Output byte c on port p + * + ****************************************************************************/ + +void outp(char p, char c) +{ + _asm + ld c, 4(ix) ; port + ld a, 5(ix) ; value + out (c), a + _endasm; +} + + +/**************************************************************************** + * Name: inpb + * + * Description: + * Input byte from port p + * + ****************************************************************************/ + +char inp(char p) +{ + _asm + ld c, 4(ix) ;port + in l, (c) + _endasm; +}