diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-10 18:40:01 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-10 18:40:01 +0000 |
commit | 57cbb33b4853e6a5cc4b035eecc6c691c48eaa7e (patch) | |
tree | b701eebbdf9d2918732ee6fc6a4b57ea3edc3695 /nuttx/arch/z80/include | |
parent | 876a38713e205a601078e587d0b34c456f8b8343 (diff) | |
download | px4-nuttx-57cbb33b4853e6a5cc4b035eecc6c691c48eaa7e.tar.gz px4-nuttx-57cbb33b4853e6a5cc4b035eecc6c691c48eaa7e.tar.bz2 px4-nuttx-57cbb33b4853e6a5cc4b035eecc6c691c48eaa7e.zip |
Add source files for z180
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5426 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z80/include')
-rw-r--r-- | nuttx/arch/z80/include/arch.h | 24 | ||||
-rw-r--r-- | nuttx/arch/z80/include/io.h | 22 | ||||
-rw-r--r-- | nuttx/arch/z80/include/irq.h | 16 | ||||
-rw-r--r-- | nuttx/arch/z80/include/limits.h | 10 | ||||
-rw-r--r-- | nuttx/arch/z80/include/serial.h | 8 | ||||
-rw-r--r-- | nuttx/arch/z80/include/syscall.h | 16 | ||||
-rw-r--r-- | nuttx/arch/z80/include/types.h | 6 | ||||
-rw-r--r-- | nuttx/arch/z80/include/z180/chip.h | 122 | ||||
-rw-r--r-- | nuttx/arch/z80/include/z80/chip.h | 92 |
9 files changed, 190 insertions, 126 deletions
diff --git a/nuttx/arch/z80/include/arch.h b/nuttx/arch/z80/include/arch.h index 112fcde3a..0a0673e03 100644 --- a/nuttx/arch/z80/include/arch.h +++ b/nuttx/arch/z80/include/arch.h @@ -33,12 +33,12 @@ * ****************************************************************************/ -/* This file should never be included directed but, rather, - * only indirectly through nuttx/arch.h +/* This file should never be included directed but, rather, only indirectly + * through nuttx/arch.h */ -#ifndef __ARCH_ARCH_H -#define __ARCH_ARCH_H +#ifndef __ARCH_Z80_INCLUDE_ARCH_H +#define __ARCH_Z80_INCLUDE_ARCH_H /**************************************************************************** * Included Files @@ -47,7 +47,7 @@ #include <arch/chip/arch.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -66,17 +66,5 @@ * Public Function Prototypes ****************************************************************************/ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ARCH_ARCH_H */ +#endif /* __ARCH_Z80_INCLUDE_ARCH_H */ diff --git a/nuttx/arch/z80/include/io.h b/nuttx/arch/z80/include/io.h index dacc0bc5b..e07a071d9 100644 --- a/nuttx/arch/z80/include/io.h +++ b/nuttx/arch/z80/include/io.h @@ -34,8 +34,8 @@ * ****************************************************************************/ -#ifndef __ARCH_IO_H -#define __ARCH_IO_H +#ifndef __ARCH_Z80_INCLUDE_IO_H +#define __ARCH_Z80_INCLUDE_IO_H /**************************************************************************** * Included Files @@ -44,7 +44,7 @@ #include <arch/chip/io.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -59,18 +59,4 @@ * 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 */ +#endif /* __ARCH_Z80_INCLUDE_IO_H */ diff --git a/nuttx/arch/z80/include/irq.h b/nuttx/arch/z80/include/irq.h index a617540a9..7d482df49 100644 --- a/nuttx/arch/z80/include/irq.h +++ b/nuttx/arch/z80/include/irq.h @@ -48,7 +48,7 @@ #include <arch/chip/irq.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -63,19 +63,5 @@ * 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_Z80_INCLUDE_IRQ_H */ diff --git a/nuttx/arch/z80/include/limits.h b/nuttx/arch/z80/include/limits.h index 3cfd65dc6..3013ec8f4 100644 --- a/nuttx/arch/z80/include/limits.h +++ b/nuttx/arch/z80/include/limits.h @@ -33,17 +33,17 @@ * ****************************************************************************/ -#ifndef __ARCH_LIMITS_H -#define __ARCH_LIMITS_H +#ifndef __ARCH_Z80_INCLUDE_LIMITS_H +#define __ARCH_Z80_INCLUDE_LIMITS_H /**************************************************************************** - * Included Files + * Pre-processor Definitions ****************************************************************************/ #include <arch/chip/limits.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ -#endif /* __ARCH_LIMITS_H */ +#endif /* __ARCH_Z80_INCLUDE_LIMITS_H */ diff --git a/nuttx/arch/z80/include/serial.h b/nuttx/arch/z80/include/serial.h index 2688c045f..2997cd4fa 100644 --- a/nuttx/arch/z80/include/serial.h +++ b/nuttx/arch/z80/include/serial.h @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __ARCH_Z80_INCLUDE_SERIAL_TYPES_H -#define __ARCH_Z80_INCLUDE_SERIAL_TYPES_H +#ifndef __ARCH_Z80_INCLUDE_SERIAL_H +#define __ARCH_Z80_INCLUDE_SERIAL_H /**************************************************************************** * Included Files @@ -43,7 +43,7 @@ #include <nuttx/fs/ioctl.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -54,4 +54,4 @@ * Public Functions ****************************************************************************/ -#endif /* __ARCH_Z80_INCLUDE_SERIAL_TYPES_H */ +#endif /* __ARCH_Z80_INCLUDE_SERIAL_H */ diff --git a/nuttx/arch/z80/include/syscall.h b/nuttx/arch/z80/include/syscall.h index b1894ca34..bc9ebbb11 100644 --- a/nuttx/arch/z80/include/syscall.h +++ b/nuttx/arch/z80/include/syscall.h @@ -45,7 +45,7 @@ ****************************************************************************/ /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -64,19 +64,5 @@ * 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_Z80_INCLUDE_SYSCALL_H */ diff --git a/nuttx/arch/z80/include/types.h b/nuttx/arch/z80/include/types.h index 5b2b5ff16..5e6a90342 100644 --- a/nuttx/arch/z80/include/types.h +++ b/nuttx/arch/z80/include/types.h @@ -37,8 +37,8 @@ * through sys/types.h */ -#ifndef __ARCH_TYPES_H -#define __ARCH_TYPES_H +#ifndef __ARCH_Z80_INCLUDE_TYPES_H +#define __ARCH_Z80_INCLUDE_TYPES_H /**************************************************************************** * Included Files @@ -58,4 +58,4 @@ * Global Function Prototypes ****************************************************************************/ -#endif /* __ARCH_TYPES_H */ +#endif /* __ARCH_Z80_INCLUDE_TYPES_H */ diff --git a/nuttx/arch/z80/include/z180/chip.h b/nuttx/arch/z80/include/z180/chip.h index b31c69bcf..f2e140a10 100644 --- a/nuttx/arch/z80/include/z180/chip.h +++ b/nuttx/arch/z80/include/z180/chip.h @@ -41,10 +41,36 @@ * Included Files ****************************************************************************/ +#ifndef __ASSEMBLY__ +# include <stdint.h> +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* Bits in the Z80 FLAGS register ***************************************************/ + +#define Z180_C_FLAG 0x01 /* Bit 0: Carry flag */ +#define Z180_N_FLAG 0x02 /* Bit 1: Add/Subtract flag */ +#define Z180_PV_FLAG 0x04 /* Bit 2: Parity/Overflow flag */ +#define Z180_H_FLAG 0x10 /* Bit 4: Half carry flag */ +#define Z180_Z_FLAG 0x40 /* Bit 5: Zero flag */ +#define Z180_S_FLAG 0x80 /* Bit 7: Sign flag */ + +/* Register access macros ***********************************************************/ + +#ifndef __ASSEMBLY__ + +# define getreg8(a) (*(volatile uint8_t *)(a)) +# define putreg8(v,a) (*(volatile uint8_t *)(a) = (v)) +# define getreg16(a) (*(volatile uint16_t *)(a)) +# define putreg16(v,a) (*(volatile uint16_t *)(a) = (v)) +# define getreg32(a) (*(volatile uint32_t *)(a)) +# define putreg32(v,a) (*(volatile uint32_t *)(a) = (v)) + +#endif + /* Z800180 * * The 8-bit Z80180 MPU provides the benefits of reduced system costs and @@ -71,12 +97,12 @@ * * Enhanced on the Z8S180 and Z8L180 MPUs */ -#if defined(CONFIG_Z180_CHIP_Z8018006VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8018010VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8018008VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8018010FSG) || /* 80-pin QFP (11 pins N/C) */ \ - defined(CONFIG_Z180_CHIP_Z8018008VEG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8018006VEG) /* 68-pin PLCC */ +#if defined(CONFIG_ARCH_CHIP_Z8018006VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8018010VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8018008VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8018010FSG) || /* 80-pin QFP (11 pins N/C) */ \ + defined(CONFIG_ARCH_CHIP_Z8018008VEG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8018006VEG) /* 68-pin PLCC */ # undef HAVE_Z8S180 /* Not Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -93,14 +119,14 @@ # define HAVE_NPAR8 0 /* No 8-bit parallel ports */ # undef HAVE_IEEE1284 /* No bidirectional centronics interface (IEEE 1284) */ -#elif defined(CONFIG_Z180_CHIP_Z8018006PSG) || /* 64-pin DIP 6 MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018008FSG) || /* 80-pin QFP (11 pins N/C) 8MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018010PSG) || /* 64-pin DIP 10MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018006PEG) || /* 64-pin DIP 6MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018010VEG) || /* 68-pin PLCC 10MHz 5V*/ \ - defined(CONFIG_Z180_CHIP_Z8018010PEG) || /* 64-pin DIP 10MHz 5V*/ \ - defined(CONFIG_Z180_CHIP_Z8018008PSG) || /* 64-pin DIP 8MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018006FSG) /* 80-pin QFP (11 pins N/C) 6MHz 5V */ +#elif defined(CONFIG_ARCH_CHIP_Z8018006PSG) || /* 64-pin DIP 6 MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018008FSG) || /* 80-pin QFP (11 pins N/C) 8MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018010PSG) || /* 64-pin DIP 10MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018006PEG) || /* 64-pin DIP 6MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018010VEG) || /* 68-pin PLCC 10MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018010PEG) || /* 64-pin DIP 10MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018008PSG) || /* 64-pin DIP 8MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018006FSG) /* 80-pin QFP (11 pins N/C) 6MHz 5V */ # undef HAVE_Z8S180 /* Not Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -117,10 +143,10 @@ # define HAVE_NPAR8 0 /* No 8-bit parallel ports */ # undef HAVE_IEEE1284 /* No bidirectional centronics interface (IEEE 1284) */ -#elif defined(CONFIG_Z180_CHIP_Z8018000XSO) - defined(CONFIG_Z180_CHIP_Z8018010FEG) - defined(CONFIG_Z180_CHIP_Z8018000WSO) - defined(CONFIG_Z180_CHIP_Z8018008PEG) +#elif defined(CONFIG_ARCH_CHIP_Z8018000XSO) + defined(CONFIG_ARCH_CHIP_Z8018010FEG) + defined(CONFIG_ARCH_CHIP_Z8018000WSO) + defined(CONFIG_ARCH_CHIP_Z8018008PEG) # undef HAVE_Z8S180 /* Not Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -158,7 +184,7 @@ * Emulation Mode */ -#elif defined(CONFIG_Z180_CHIP_Z8018110FEG) /* 100 QFP */ +#elif defined(CONFIG_ARCH_CHIP_Z8018110FEG) /* 100-pin QFP */ # undef HAVE_Z8S180 /* Not Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -199,11 +225,11 @@ * 3.3 V and 5 V Version */ -#elif defined(CONFIG_Z180_CHIP_Z8018233FSG) || /* 100-pin QFP */ \ - defined(CONFIG_Z180_CHIP_Z8018220AEG) || /* 100-pin LQFP 20MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018216FSG) || /* 100-pin QFP 16MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8018216ASG) || /* 100-pin LQFP */ \ - defined(CONFIG_Z180_CHIP_Z8018233ASG) /* 100-pin LQFP 33MHz 5V */ +#elif defined(CONFIG_ARCH_CHIP_Z8018233FSG) || /* 100-pin QFP */ \ + defined(CONFIG_ARCH_CHIP_Z8018220AEG) || /* 100-pin LQFP 20MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018216FSG) || /* 100-pin QFP 16MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8018216ASG) || /* 100-pin LQFP */ \ + defined(CONFIG_ARCH_CHIP_Z8018233ASG) /* 100-pin LQFP 33MHz 5V */ # undef HAVE_Z8S180 /* Not Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -244,8 +270,8 @@ * 7 or 24 Bits of I/O */ -#elif defined(CONFIG_Z180_CHIP_Z8019520FSG) || /* 100-pin QFP 20MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8019533FSG) /* 100-pin QFP 33MHz 5V */ +#elif defined(CONFIG_ARCH_CHIP_Z8019520FSG) || /* 100-pin QFP 20MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8019533FSG) /* 100-pin QFP 33MHz 5V */ # undef HAVE_Z8S180 /* No Z8S180 (5V) or Z8L180 (3.3V) core */ # undef HAVE ROM 0 /* No 32KB on-chip ROM (z80185 only) */ @@ -285,9 +311,9 @@ * * Enhanced on the Z8S180 and Z8L180 MPUs. */ -#elif defined(CONFIG_Z180_CHIP_Z8L18020VSG) || /* 69-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8L18020FSG) || /* 80-pin GFP 20MHz 3.3V */ \ - defined(CONFIG_Z180_CHIP_Z8L18020PSG) +#elif defined(CONFIG_ARCH_CHIP_Z8L18020VSG) || /* 68-pinn PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8L18020FSG) || /* 80-pin GFP 20MHz 3.3V */ \ + defined(CONFIG_ARCH_CHIP_Z8L18020PSG) # define HAVE_Z8S180 1 /* Uses Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -329,9 +355,9 @@ * 3.3 V and 5 V Version */ -#elif defined(CONFIG_Z180_CHIP_Z8L18220ASG) || /* 100-pin LQFP */ \ - defined(CONFIG_Z180_CHIP_Z8L18220FSG) || /* 100-pin QFP 20MHz 3.3V */ \ - defined(CONFIG_Z180_CHIP_Z8L18220AEG) +#elif defined(CONFIG_ARCH_CHIP_Z8L18220ASG) || /* 100-pin LQFP */ \ + defined(CONFIG_ARCH_CHIP_Z8L18220FSG) || /* 100-pin QFP 20MHz 3.3V */ \ + defined(CONFIG_ARCH_CHIP_Z8L18220AEG) # define HAVE_Z8S180 1 /* Uses Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ @@ -373,22 +399,22 @@ * Package - DIP, PLCC, QFP */ -#elif defined(CONFIG_Z180_CHIP_Z8S18020VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18020VSG1960) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18033VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18010FSG) || /* 80-pin QFP */ \ - defined(CONFIG_Z180_CHIP_Z8S18010VEG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18020VEG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18010VSG) || /* 68-pin PLCC */ \ - defined(CONFIG_Z180_CHIP_Z8S18020PSG) || /* 64-pin DIP 10Mhz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18033FSG) || /* 80-pin QFP 33MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18033FEG) || /* 80-pin QFP 33MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18020FSG) || /* 80-pin QFP 20MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18033VEG) || /* 68-pin PLCC 33MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18010PSG) || /* 64-pin DIP 10MHz 5V */ \ - defined(CONFIG_Z180_CHIP_Z8S18020FEG) || \ - defined(CONFIG_Z180_CHIP_Z8S18010PEG) || \ - defined(CONFIG_Z180_CHIP_Z8S18010FEG +#elif defined(CONFIG_ARCH_CHIP_Z8S18020VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18020VSG1960) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18033VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18010FSG) || /* 80-pin QFP */ \ + defined(CONFIG_ARCH_CHIP_Z8S18010VEG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18020VEG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18010VSG) || /* 68-pin PLCC */ \ + defined(CONFIG_ARCH_CHIP_Z8S18020PSG) || /* 64-pin DIP 10Mhz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18033FSG) || /* 80-pin QFP 33MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18033FEG) || /* 80-pin QFP 33MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18020FSG) || /* 80-pin QFP 20MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18033VEG) || /* 68-pin PLCC 33MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18010PSG) || /* 64-pin DIP 10MHz 5V */ \ + defined(CONFIG_ARCH_CHIP_Z8S18020FEG) || \ + defined(CONFIG_ARCH_CHIP_Z8S18010PEG) || \ + defined(CONFIG_ARCH_CHIP_Z8S18010FEG # define HAVE_Z8S180 1 /* Uses Z8S180 (5V) or Z8L180 (3.3V) core */ # define HAVE ROM 0 /* No on-chip ROM */ diff --git a/nuttx/arch/z80/include/z80/chip.h b/nuttx/arch/z80/include/z80/chip.h new file mode 100644 index 000000000..9f77e395c --- /dev/null +++ b/nuttx/arch/z80/include/z80/chip.h @@ -0,0 +1,92 @@ +/************************************************************************************ + * arch/z80/include/z80/chip.h + * arch/z80/include/chip/chip.h + * + * Copyright (C) 2007-2009 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 __ARCH_Z80_SRC_Z80_CHIP_H +#define __ARCH_Z80_SRC_Z80_CHIP_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#ifndef __ASSEMBLY__ +# include <stdint.h> +#endif + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Bits in the Z80 FLAGS register ***************************************************/ + +#define Z80_C_FLAG 0x01 /* Bit 0: Carry flag */ +#define Z80_N_FLAG 0x02 /* Bit 1: Add/Subtract flag */ +#define Z80_PV_FLAG 0x04 /* Bit 2: Parity/Overflow flag */ +#define Z80_H_FLAG 0x10 /* Bit 4: Half carry flag */ +#define Z80_Z_FLAG 0x40 /* Bit 5: Zero flag */ +#define Z80_S_FLAG 0x80 /* Bit 7: Sign flag */ + +/* Register access macros ***********************************************************/ + +#ifndef __ASSEMBLY__ + +# define getreg8(a) (*(volatile uint8_t *)(a)) +# define putreg8(v,a) (*(volatile uint8_t *)(a) = (v)) +# define getreg16(a) (*(volatile uint16_t *)(a)) +# define putreg16(v,a) (*(volatile uint16_t *)(a) = (v)) +# define getreg32(a) (*(volatile uint32_t *)(a)) +# define putreg32(v,a) (*(volatile uint32_t *)(a) = (v)) + +#endif + +/************************************************************************************ + * 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_Z80_SRC_Z80_CHIP_H */ |