mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
First successful z80 compile & link
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@457 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -57,18 +57,10 @@ AR = sdcclib -a
|
||||
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
|
||||
ASFLAGS =
|
||||
ASFLAGS = -x -a -l -o -s
|
||||
|
||||
SDCCLIBDIR = /usr/local/share/sdcc/lib/z80
|
||||
SDCCPATH = -L$(SDCCLIBDIR)
|
||||
SDCCLIBS = -lz80.lib
|
||||
|
||||
IRAM_SIZE = 0x100
|
||||
DEF_STACK_BASE = 0x24
|
||||
LDFLAGS = --model-large --nostdlib \
|
||||
--data-loc $(DEF_STACK_BASE) --iram-size $(IRAM_SIZE) \
|
||||
--code-loc 0x2100 --code-size 0x5f40 \
|
||||
--xram-loc $(IRAM_SIZE) --xram-size 0x1f00
|
||||
SDCCLIB = z80.lib
|
||||
|
||||
ASMEXT = .asm
|
||||
OBJEXT = .o
|
||||
|
||||
@@ -86,7 +86,7 @@ CONFIG_DRAM_SIZE=65536
|
||||
CONFIG_EXAMPLE=ostest
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_MM_REGIONS=1
|
||||
CONFIG_ARCH_LOWPUTC=y
|
||||
CONFIG_RR_INTERVAL=0
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
CFLAGS += -I$(TOPDIR)/sched
|
||||
CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/arch/z80/src/common -I$(TOPDIR)/arch/z80/src/z80
|
||||
|
||||
ASRCS = z80_lowputc$(ASMEXT)
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT))
|
||||
CSRCS = z80_decodeirq.c z80_irq.c z80_serial.c z80_timerisr.c
|
||||
CSRCS = z80_decodeirq.c z80_irq.c z80_serial.c z80_timerisr.c z80_lowputc.c
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/********************************************************************************
|
||||
* z80/z80_decodeirq.c
|
||||
* board/z80_decodeirq.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -38,12 +38,13 @@
|
||||
********************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
@@ -64,56 +65,37 @@
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
********************************************************************************/
|
||||
|
||||
void up_decodeirq(uint16* regs)
|
||||
FAR chipreg_t *up_decodeirq(FAR chipreg_t *regs)
|
||||
{
|
||||
#ifdef CONFIG_SUPPRESS_INTERRUPTS
|
||||
|
||||
lib_lowprintf("Unexpected IRQ\n");
|
||||
current_regs = regs;
|
||||
PANIC(OSERR_ERREXCEPTION);
|
||||
return NULL; /* Won't get here */
|
||||
|
||||
#else
|
||||
/* Decode the interrupt. First, fetch the interrupt id register. */
|
||||
|
||||
uint16 irqentry = getreg16(DM320_INTC_IRQENTRY0);
|
||||
/* Current regs non-zero indicates that we are processing an interrupt;
|
||||
* current_regs is also used to manage interrupt level context switches.
|
||||
*/
|
||||
|
||||
/* The irqentry value is an offset into a table. Zero means no interrupt. */
|
||||
current_regs = regs;
|
||||
|
||||
if (irqentry != 0)
|
||||
{
|
||||
/* If non-zero, then we can map the table offset into an IRQ number */
|
||||
/* Deliver the IRQ -- the simulation supports only timer interrupts */
|
||||
|
||||
int irq = (irqentry >> 2) - 1;
|
||||
irq_dispatch(Z80_IRQ_SYSTIMER, regs);
|
||||
|
||||
/* Verify that the resulting IRQ number is valie */
|
||||
/* If a context switch occurred, current_regs will hold the new context */
|
||||
|
||||
if ((unsigned)irq < NR_IRQS)
|
||||
{
|
||||
/* Mask and acknowledge the interrupt */
|
||||
regs = current_regs;
|
||||
|
||||
up_maskack_irq(irq);
|
||||
/* Indicate that we are no long in an interrupt handler */
|
||||
|
||||
/* Current regs non-zero indicates that we are processing an interrupt;
|
||||
* current_regs is also used to manage interrupt level context switches.
|
||||
*/
|
||||
|
||||
current_regs = regs;
|
||||
|
||||
/* Deliver the IRQ */
|
||||
|
||||
irq_dispatch(irq, regs);
|
||||
|
||||
/* Indicate that we are no long in an interrupt handler */
|
||||
|
||||
current_regs = NULL;
|
||||
|
||||
/* Unmask the last interrupt (global interrupts are still
|
||||
* disabled.
|
||||
*/
|
||||
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
}
|
||||
current_regs = NULL;
|
||||
return regs;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* z80/z80_irq.c
|
||||
* board/z80_irq.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@@ -38,8 +38,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
@@ -52,8 +54,6 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
uint32 *current_regs;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@@ -63,7 +63,7 @@ uint32 *current_regs;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/********************************************************************************
|
||||
* board/z80_lowputc.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "up_arch.h"
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/********************************************************************************
|
||||
* Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Data
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Data
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Functions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Functions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Name: up_lowputc
|
||||
*
|
||||
* Data sent to port 0xbe are echoed on stdout by the simulation
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
void up_lowputc(char ch) __naked
|
||||
{
|
||||
_asm
|
||||
ld a, #2(sp)
|
||||
out #0xbe, a
|
||||
ret
|
||||
_endasm;
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* Name: up_lowgetc
|
||||
*
|
||||
* Data from stdin can be received on port 0xbe in the simulation
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
char up_lowgetc(void) __naked
|
||||
{
|
||||
_asm
|
||||
in #0xbe, a
|
||||
ld l, a
|
||||
ld h, #0
|
||||
ret
|
||||
_endasm;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* z80/z80_serial.c
|
||||
* board/z80_serial.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -41,7 +41,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
@@ -282,7 +281,7 @@ static boolean up_txfifoempty(struct uart_dev_s *dev)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
* dm320/dm320_timerisr.c
|
||||
/****************************************************************************
|
||||
* board/z80_timerisr.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@@ -31,89 +31,48 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "clock_internal.h"
|
||||
#include "up_internal.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* DM320 Timers
|
||||
*
|
||||
* Each of the general-purpose timers can run in one of two modes: one-
|
||||
* shot mode and free-run mode. In one-shot mode, an interrupt only
|
||||
* occurs once and then the timer must be explicitly reset to begin the
|
||||
* timing operation again. In free-run mode, when the timer generates an
|
||||
* interrupt, the timer counter is automatically reloaded to start the count
|
||||
* operation again. Use the bit field MODE in TMMDx to configure the
|
||||
* timer for one-shot more or free-run mode. The bit field MODE in TMMDx
|
||||
* also allows you to stop the timer.
|
||||
*
|
||||
* Either the ARM clock divided by 2 (CLK_ARM/2) or an external clock
|
||||
* connected to the M27XI pin can be selected as the clock source of the
|
||||
* timer.
|
||||
*
|
||||
* The actual clock frequency used in the timer count operation is the input
|
||||
* clock divided by: 1 plus the value set in the bit field PRSCL of the
|
||||
* register TMPRSCLx (10 bits). The timer expires when it reaches the
|
||||
* value set in the bit field DIV of the register TMDIVx (16 bits) plus 1.
|
||||
* PRSCL+1 is the source clock frequency divide factor and DIV+1 is the
|
||||
* timer count value. The frequency of a timer interrupt is given by the
|
||||
* following equation:
|
||||
*
|
||||
* Interrupt Frequency = (Source Clock Frequency) / (PRSCL+1) / (DIV+1)
|
||||
*/
|
||||
|
||||
/* System Timer
|
||||
*
|
||||
* Timer0 is dedicated as the system timer. The rate of system timer
|
||||
* interrupts is assumed to to 10MS per tick / 100Hz. The following
|
||||
* register settings are used for timer 0
|
||||
*
|
||||
* System clock formula:
|
||||
* Interrupt Frequency = (Source Clock Frequency) / (PRSCL+1) / (DIV+1)
|
||||
* Source Clock Frequency = 27MHz (PLL clock)
|
||||
* DIV = 26,999 (Yields 1Khz timer clock)
|
||||
* PRSCL = 9 (Produces 100Hz interrupts)
|
||||
*/
|
||||
|
||||
#define DM320_TMR0_MODE DM320_TMR_MODE_FREERUN /* Free running */
|
||||
#define DM320_TMR0_DIV 26999 /* (see above) */
|
||||
#define DM320_TMR0_PRSCL 9 /* (see above) */
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Function: up_timerisr
|
||||
*
|
||||
* Description:
|
||||
* The timer ISR will perform a variety of services for
|
||||
* various portions of the systems.
|
||||
* The timer ISR will perform a variety of services for various portions of
|
||||
* the system.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int up_timerisr(int irq, uint32 *regs)
|
||||
int up_timerisr(int irq, FAR chipreg_t *regs)
|
||||
{
|
||||
/* Process timer interrupt */
|
||||
|
||||
@@ -121,33 +80,16 @@ int up_timerisr(int irq, uint32 *regs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Function: up_timerinit
|
||||
*
|
||||
* Description:
|
||||
* This function is called during start-up to initialize
|
||||
* the timer interrupt.
|
||||
* This function is called during start-up to initialize the timer
|
||||
* interrupt.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_timerinit(void)
|
||||
{
|
||||
up_disable_irq(DM320_IRQ_SYSTIMER);
|
||||
|
||||
/* Start timer0 running so that an interrupt is generated at
|
||||
* the rate MSEC_PER_TICK.
|
||||
*/
|
||||
|
||||
putreg16(DM320_TMR0_PRSCL, DM320_TIMER0_TMPRSCL); /* Timer 0 Prescalar */
|
||||
putreg16(DM320_TMR0_DIV, DM320_TIMER0_TMDIV); /* Timer 0 Divisor (count) */
|
||||
|
||||
/* Start the timer */
|
||||
|
||||
putreg16(DM320_TMR0_MODE, DM320_TIMER0_TMMD); /* Timer 0 Mode */
|
||||
|
||||
/* Attach and enable the timer interrupt */
|
||||
|
||||
irq_attach(DM320_IRQ_SYSTIMER, (xcpt_t)up_timerisr);
|
||||
up_enable_irq(DM320_IRQ_SYSTIMER);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user