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:
parent
e5cb54d8d5
commit
0a98dad76d
@ -76,7 +76,7 @@ typedef unsigned long uint32;
|
||||
* irqsave()
|
||||
*/
|
||||
|
||||
typedef unsigned char irqstate_t;
|
||||
typedef uint16 irqstate_t;
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
|
@ -77,13 +77,14 @@
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* This is the the type of the register save array */
|
||||
|
||||
typedef uint16 chipreg_t;
|
||||
|
||||
/* This struct defines the way the registers are stored. */
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
struct xcptcontext
|
||||
{
|
||||
/* Register save area */
|
||||
@ -120,8 +121,8 @@ extern "C" {
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN irqstate_t irqsave(void);
|
||||
EXTERN void irqrestore(irqstate_t flags);
|
||||
EXTERN irqstate_t irqsave(void) __naked;
|
||||
EXTERN void irqrestore(irqstate_t flags) __naked;
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
@ -44,13 +44,10 @@
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
# CFLAGS, CPPFLAGS, ASFLAGS, LDFLAGS are set in $(TOPDIR)/Make.defs
|
||||
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(TOPDIR)/sched
|
||||
LDFLAGS = $(ARCHSCRIPT)
|
||||
|
||||
LDPATHES = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
|
||||
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
|
||||
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) -D__ASSEMBLY__
|
||||
CPPFLAGS += -D__ASSEMBLY__
|
||||
|
||||
############################################################################
|
||||
# Files and directories
|
||||
@ -62,7 +59,7 @@ HEAD_AOBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT))
|
||||
# Assembly sources and objects
|
||||
|
||||
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT))
|
||||
|
||||
# C sources and objects
|
||||
|
||||
@ -74,18 +71,9 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
# Sources and objects for the test target (plus HEAD_AOBJ
|
||||
|
||||
TEST_AOBJS = $(TEST_ASRCS:$(ASMEXT)=$(OBJEXT))
|
||||
TEST_COBJS = $(TEST_CSRCS:.c=$(OBJEXT))
|
||||
|
||||
TESTSRCS = up_irqtest.c
|
||||
TESTOBJS = $(TESTSRCS:.c=$(OBJEXT))
|
||||
TESTEXTRAOBJS = up_savecontext$(OBJEXT) up_restorecontext$(OBJEXT)
|
||||
|
||||
# Sources that can have dependencies (no .asm files)
|
||||
|
||||
DEPSRCS = $(SRCS)
|
||||
DEPSRCS = $(CSRCS)
|
||||
|
||||
# Directories
|
||||
|
||||
@ -105,16 +93,7 @@ HEAP_BASE = ${shell \
|
||||
cat pass1.mem | grep "ROM/EPROM/FLASH" | \
|
||||
sed -e "s/[ ][ ]*/ /g" | cut -d' ' -f4 ; \
|
||||
else \
|
||||
echo $(DEF_HEAP_BASE) ; \
|
||||
fi \
|
||||
}
|
||||
|
||||
STACK_BASE = ${shell \
|
||||
if [ -e pass1.mem ]; then \
|
||||
cat pass1.mem | grep "Stack starts" | \
|
||||
cut -d' ' -f4 ; \
|
||||
else \
|
||||
echo $(DEF_STACK_BASE) ; \
|
||||
echo "(UP_HEAP1_END - 8192)" ; \
|
||||
fi \
|
||||
}
|
||||
|
||||
@ -123,12 +102,24 @@ STACK_BASE = ${shell \
|
||||
|
||||
all: $(HEAD_AOBJ) libarch$(LIBEXT)
|
||||
|
||||
$(AOBJS) $(HEAD_AOBJ) $(TEST_AOBJS): %$(OBJEXT): %$(ASMEXT)
|
||||
$(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT)
|
||||
$(AS) $(ASFLAGS) $@ $<
|
||||
|
||||
$(COBJS) $(TEST_COBJS): %$(OBJEXT): %.c
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
# This is a kludge to work around some conflicting symbols in libsdcc.liXqueb
|
||||
|
||||
$(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB)
|
||||
@cat $(SDCCLIBDIR)/$(SDCCLIB) | \
|
||||
grep -v calloc | grep -v malloc | grep -v realloc | \
|
||||
grep -v free | grep -v vprintf | grep -v _strncpy | \
|
||||
grep -v _strchr | grep -v _strlen | grep -v _strcmp | \
|
||||
grep -v _strcpy | grep -v _memcmp | grep -v _memcpy | \
|
||||
grep -v _memset | grep -v crt0 \
|
||||
> myz80.lib
|
||||
@sudo mv -f myz80.lib $(SDCCLIBDIR)/myz80.lib
|
||||
|
||||
# Create a header file that contains addressing information needed by the code
|
||||
|
||||
pass1.mem:
|
||||
@ -137,18 +128,12 @@ up_mem.h: pass1.mem
|
||||
@echo "#ifndef __ARCH_MEM_H" >up_mem.h
|
||||
@echo "#define __ARCH_MEM_H" >>up_mem.h
|
||||
@echo "" >>up_mem.h
|
||||
@echo "#define UP_DEFAULT_STACK_BASE $(DEF_STACK_BASE)" >>up_mem.h
|
||||
@echo "#define UP_DEFAULT_HEAP_BASE $(DEF_HEAP_BASE)" >> up_mem.h
|
||||
@echo "" >>up_mem.h
|
||||
@echo "#define UP_STACK_BASE $(STACK_BASE)" >>up_mem.h
|
||||
@echo "#if UP_STACK_BASE > UP_DEFAULT_STACK_BASE" >>up_mem.h
|
||||
@echo "# error \"Stack overlap: $(DEF_STACK_BASE) < $(STACK_BASE)\"" >>up_mem.h
|
||||
@echo "#elif UP_STACK_BASE < UP_DEFAULT_STACK_BASE" >>up_mem.h
|
||||
@echo "# warning \"Wasted stack: $(DEF_STACK_BASE) > $(STACK_BASE)\"" >>up_mem.h
|
||||
@echo "#endif" >>up_mem.h
|
||||
@echo "" >>up_mem.h
|
||||
@echo "#define UP_HEAP_BASE $(HEAP_BASE)" >> up_mem.h
|
||||
@echo "#define UP_HEAP_END $(CONFIG_DRAM_END)" >> up_mem.h
|
||||
@echo "#define UP_STACK_END $(CONFIG_DRAM_SIZE)" >> up_mem.h
|
||||
@echo "#define UP_STACK_BASE (UP_STACK_END - $(CONFIG_PROC_STACK_SIZE))" >> up_mem.h
|
||||
@echo "#define UP_HEAP1_END UP_STACK_BASE" >> up_mem.h
|
||||
@echo "#define UP_HEAP1_BASE $(HEAP_BASE)" >> up_mem.h
|
||||
@echo "" >>up_mem.h
|
||||
@echo "#endif /* __ARCH_MEM_H */" >>up_mem.h
|
||||
|
||||
@ -167,31 +152,46 @@ board/libboard$(LIBEXT):
|
||||
|
||||
# This target builds the final executable
|
||||
|
||||
pass1.ihx: up_mem.h $(HEAD_AOBJ) board/libboard$(LIBEXT)
|
||||
$(CC) $(LDFLAGS) -L$(BOARDDIR) $(SDCCPATH) $(HEAD_AOBJ) \
|
||||
-llibboard$(LIBEXT) $(SDCCLIBS) -o $@
|
||||
pass1.ihx: up_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ) board/libboard$(LIBEXT)
|
||||
@echo "-k $(BOARDDIR)" >pass1.lnk # Path to board library
|
||||
@echo "-k $(SDCCLIBDIR)" >>pass1.lnk # Path to SDCC z80 library
|
||||
@echo "-l libboard$(LIBEXT)" >>pass1.lnk # Name of board library
|
||||
@for LIB in $(LINKLIBS); do \
|
||||
echo "-l $(TOPDIR)/$$LIB" >> pass1.lnk ;\
|
||||
done
|
||||
@echo "-l myz80.lib" >>pass1.lnk # Name of SDCC z80 library
|
||||
# @echo "-m pass1.map" >>pass1.lnk # Generate a map file
|
||||
# @echo "-j pass1.sym" >>pass1.lnk # Generate a symbol file
|
||||
@echo "-i" >>pass1.lnk # Intel hex format
|
||||
@echo "pass1.ihx" >>pass1.lnk # Path to head object
|
||||
@echo "$(HEAD_AOBJ)" >>pass1.lnk # Path to head object
|
||||
@echo "-e" >>pass1.lnk # End of script
|
||||
$(LD) -f pass1.lnk
|
||||
@rm -f up_mem.h
|
||||
@rm -f up_allocateheap$(OBJEXT) libarch$(LIBEXT)
|
||||
@$(MAKE) TOPDIR=$(TOPDIR) libarch$(LIBEXT)
|
||||
|
||||
nuttx.ihx: up_mem.h $(HEAD_AOBJ)
|
||||
$(CC) $(LDFLAGS) -L$(BOARDDIR) $(SDCCPATH) $(HEAD_AOBJ) \
|
||||
-llibboard$(LIBEXT) $(SDCCLIBS) -o $@
|
||||
nuttx.ihx: up_mem.h $(SDCCLIBDIR)/myz80.lib $(HEAD_AOBJ)
|
||||
@echo "-k $(BOARDDIR)" >nuttx.lnk # Path to board library
|
||||
@echo "-k $(SDCCLIBDIR)" >>nuttx.lnk # Path to SDCC z80 library
|
||||
@echo "-l libboard$(LIBEXT)" >>nuttx.lnk # Name of board library
|
||||
@for LIB in $(LINKLIBS); do \
|
||||
echo "-l $(TOPDIR)/$$LIB" >> nuttx.lnk ;\
|
||||
done
|
||||
@echo "-l myz80.lib" >>nuttx.lnk # Name of SDCC z80 library
|
||||
@echo "-m nuttx.map" >>nuttx.lnk # Generate a map file
|
||||
# @echo "-j nuttx.sym" >>nuttx.lnk # Generate a symbol file
|
||||
@echo "-i" >>nuttx.lnk # Intel hex format
|
||||
@echo "nuttx.ihx" >>nuttx.lnk # Path to head object
|
||||
@echo "$(HEAD_AOBJ)" >>nuttx.lnk # Path to head object
|
||||
@echo "-e" >>nuttx.lnk # End of script
|
||||
$(LD) -f nuttx.lnk
|
||||
|
||||
nuttx$(EXEEXT): pass1.ihx nuttx.ihx
|
||||
@rm -f pass1.*
|
||||
packihx nuttx.ihx > $(TOPDIR)/nuttx$(EXEEXT)
|
||||
@cp -f nuttx.map $(TOPDIR)/.
|
||||
|
||||
# This target builds a test program to verify interrupt context switching. irqtest is
|
||||
# a PHONY target that just sets upt the up_irqtest build correctly
|
||||
|
||||
up_irqtest.ihx: $(TEST_COBJS)
|
||||
$(CC) $(LDFLAGS) -L. $(SDCCPATH) $(HEAD_AOBJ) $(TEST_COBJS) $(TESTEXTRAOBJS) $(SDCCLIBS) -o $@
|
||||
|
||||
irqtest:
|
||||
$(MAKE) TOPDIR=../../.. up_irqtest.ihx
|
||||
|
||||
# Build dependencies
|
||||
|
||||
.depend: Makefile up_mem.h chip/Make.defs $(DEPSRCS)
|
||||
@ -207,7 +207,7 @@ clean:
|
||||
@if [ -e board/Makefile ]; then \
|
||||
$(MAKE) -C board TOPDIR=$(TOPDIR) clean ; \
|
||||
fi
|
||||
rm -f libarch$(LIBEXT) up_mem.h
|
||||
rm -f libarch$(LIBEXT) up_mem.h pass1.lnk nuttx.lnk
|
||||
rm -f *.asm *.rel *.lst *.rst *.sym *.adb *.lnk *.map *.mem *.ihx *.hex *~
|
||||
if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi
|
||||
|
||||
|
@ -38,11 +38,15 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "up_mem.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
@ -64,16 +68,31 @@
|
||||
* Name: up_allocate_heap
|
||||
*
|
||||
* Description:
|
||||
* The heap may be statically allocated by
|
||||
* defining CONFIG_HEAP_BASE and CONFIG_HEAP_SIZE. If these
|
||||
* are not defined, then this function will be called to
|
||||
* dynamically set aside the heap region.
|
||||
* The heap may be statically allocated by defining CONFIG_HEAP_BASE and
|
||||
* CONFIG_HEAP_SIZE. If these are not defined, then this function will be
|
||||
* called to dynamically set aside the heap region.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||
{
|
||||
*heap_start = (FAR void*)UP_HEAP1_BASE;
|
||||
*heap_size = UP_HEAP1_END - UP_HEAP1_BASE;
|
||||
up_ledon(LED_HEAPALLOCATE);
|
||||
*heap_start = (void*)(CONFIG_DRAM_SIZE - CONFIG_HEAP_SIZE);
|
||||
*heap_size = CONFIG_HEAP_SIZE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_addregions
|
||||
*
|
||||
* Description:
|
||||
* Memory may be added in non-contiguous chunks. Additional chunks are
|
||||
* added by calling this function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
void up_addregion(void)
|
||||
{
|
||||
mm_addregion((FAR void*)UP_HEAP2_BASE, UP_HEAP2_END - UP_HEAP2_BASE);
|
||||
}
|
||||
#endif
|
||||
|
@ -57,11 +57,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -58,7 +58,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -63,7 +63,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void up_doirq(int irq, chipreg_t *regs)
|
||||
|
@ -62,7 +62,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@ -125,7 +125,7 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -52,13 +52,16 @@
|
||||
XCPT_BC == 14 ; Saved BC register
|
||||
XCPT_I == 16 ; Saved I w/interrupt state in carry
|
||||
|
||||
; Default stack base (needs to be fixed)
|
||||
|
||||
STACK_BASE == 0xffff
|
||||
|
||||
;**************************************************************************
|
||||
; Global symbols used
|
||||
;**************************************************************************
|
||||
|
||||
.globl _os_start ; OS entry point
|
||||
.globl _idle_stack ; Top of allocated stack region
|
||||
.globl _up_irqdecode ; Interrupt decoding logic
|
||||
.globl _up_decodeirq ; Interrupt decoding logic
|
||||
|
||||
;**************************************************************************
|
||||
; Reset entry point
|
||||
@ -68,10 +71,10 @@
|
||||
.org 0x0000
|
||||
|
||||
.globl _os_start
|
||||
di ; Disable interrupts
|
||||
ld SP, #_idle_stack ; Set stack pointer
|
||||
im 1 ; Set interrupt mode 1
|
||||
jp _os_start ; jump to the OS entry point
|
||||
di ; Disable interrupts
|
||||
ld SP, #STACK_BASE ; Set stack pointer
|
||||
im 1 ; Set interrupt mode 1
|
||||
jp _os_start ; jump to the OS entry point
|
||||
forever:
|
||||
jp forever
|
||||
|
||||
@ -113,7 +116,7 @@ forever:
|
||||
ld hl, #0 ; Argument is the beginning of the reg structure
|
||||
add hl, sp
|
||||
push hl
|
||||
call _up_irqdecode ; Decode the IRQ
|
||||
call _up_decodeirq ; Decode the IRQ
|
||||
|
||||
; Restore registers. HL points to the beginning of the reg structure to restore
|
||||
|
||||
|
@ -57,6 +57,17 @@
|
||||
|
||||
#undef CONFIG_ARCH_CALIBRATION
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* This holds a references to the current interrupt level
|
||||
* register storage structure. If is non-NULL only during
|
||||
* interrupt processing.
|
||||
*/
|
||||
|
||||
uint16 *current_regs;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -55,11 +55,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -110,6 +110,7 @@ extern int up_restoreusercontext(chipreg_t *regs);
|
||||
extern FAR chipreg_t *up_decodeirq(FAR chipreg_t *regs);
|
||||
extern void up_irqinitialize(void);
|
||||
extern int up_timerisr(int irq, FAR chipreg_t *regs);
|
||||
extern void up_lowputc(char ch) __naked;
|
||||
|
||||
/* Defined in up_doirq.c */
|
||||
|
||||
@ -119,12 +120,6 @@ extern void up_doirq(int irq, FAR chipreg_t *regs);
|
||||
|
||||
extern void up_sigdeliver(void);
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
extern void up_lowputc(char ch);
|
||||
#else
|
||||
# define up_lowputc(ch)
|
||||
#endif
|
||||
|
||||
/* Defined in up_allocateheap.c */
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
|
104
arch/z80/src/common/up_irq.c
Normal file
104
arch/z80/src/common/up_irq.c
Normal file
@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
* common/up_irq.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/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: irqsave
|
||||
*
|
||||
* Description:
|
||||
* Disable all interrupts; return previous interrupt state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t irqsave(void) __naked
|
||||
{
|
||||
_asm
|
||||
ld a, i ; AF Carry bit holds interrupt state
|
||||
di ; Interrupts are disabled
|
||||
push af ; Return AF in HL
|
||||
pop hl ;
|
||||
ret ;
|
||||
_endasm;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: irqrestore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous interrupt state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void irqrestore(irqstate_t flags) __naked
|
||||
{
|
||||
_asm
|
||||
pop hl ; HL = return address
|
||||
pop af ; AF Carry bit hold interrupt state
|
||||
jr nc, statedisable
|
||||
ei
|
||||
ret
|
||||
statedisable:
|
||||
di
|
||||
ret
|
||||
_endasm;
|
||||
}
|
@ -58,11 +58,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -58,11 +58,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -1,5 +1,5 @@
|
||||
;**************************************************************************
|
||||
; arch/z80/src/common/up_restoreusercontext.asm
|
||||
; common/up_restoreusercontext.asm
|
||||
;
|
||||
; Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
; Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@ -35,23 +35,22 @@
|
||||
|
||||
; Register save area layout
|
||||
|
||||
XCPT_I == 0 ; Saved I w/interrupt state in carry
|
||||
XCPT_AF == 2 ; Saved AF register
|
||||
XCPT_BC == 4 ; Saved BC register
|
||||
XCPT_DE == 6 ; Saved DE register
|
||||
XCPT_HL == 8 ; Saved HL register
|
||||
XCPT_IX == 10 ; Saved IX register
|
||||
XCPT_IY == 12 ; Saved IY register
|
||||
XCPT_SP == 14 ; Offset to SP at time of interrupt
|
||||
XCPT_PC == 16 ; Offset to PC at time of interrupt
|
||||
.globl XCPT_I ; Saved I w/interrupt state in carry
|
||||
.globl XCPT_AF ; Saved AF register
|
||||
.globl XCPT_BC ; Saved BC register
|
||||
.globl XCPT_DE ; Saved DE register
|
||||
.globl XCPT_HL ; Saved HL register
|
||||
.globl XCPT_IX ; Saved IX register
|
||||
.globl XCPT_IY ; Saved IY register
|
||||
.globl XCPT_SP ; Offset to SP at time of interrupt
|
||||
.globl XCPT_PC ; Offset to PC at time of interrupt
|
||||
|
||||
;**************************************************************************
|
||||
; up_restoreusercontext
|
||||
;**************************************************************************
|
||||
|
||||
.org 0x0038 ; Int mode 1
|
||||
.area TEXT (ABS,OVR)
|
||||
up_restoreusercontext:
|
||||
_up_restoreusercontext:
|
||||
; On entry, stack contains return address (not used), then address
|
||||
; of the register save structure
|
||||
|
||||
@ -90,7 +89,7 @@ up_restoreusercontext:
|
||||
; Restore interrupt state
|
||||
|
||||
ex af, af' ; Recover interrupt state
|
||||
jnc noinrestore ; No carry, IFF2=0, means disabled
|
||||
jr nc, noinrestore ; No carry, IFF2=0, means disabled
|
||||
ex af, af' ; Restore AF (before enabling interrupts)
|
||||
ei ; yes
|
||||
ret
|
||||
|
@ -1,5 +1,5 @@
|
||||
;*************************************************************************
|
||||
; common/up_saveusercontext.S
|
||||
; common/up_saveusercontext.asm
|
||||
;
|
||||
; Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
; Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@ -39,15 +39,15 @@
|
||||
|
||||
; Register save area layout
|
||||
|
||||
XCPT_I == 0 ; Saved I w/interrupt state in carry
|
||||
XCPT_AF == 2 ; Saved AF register
|
||||
XCPT_BC == 4 ; Saved BC register
|
||||
XCPT_DE == 6 ; Saved DE register
|
||||
XCPT_HL == 8 ; Saved HL register
|
||||
XCPT_IX == 10 ; Saved IX register
|
||||
XCPT_IY == 12 ; Saved IY register
|
||||
XCPT_SP == 14 ; Offset to SP at time of interrupt
|
||||
XCPT_PC == 16 ; Offset to PC at time of interrupt
|
||||
.globl XCPT_I ; Saved I w/interrupt state in carry
|
||||
.globl XCPT_AF ; Saved AF register
|
||||
.globl XCPT_BC ; Saved BC register
|
||||
.globl XCPT_DE ; Saved DE register
|
||||
.globl XCPT_HL ; Saved HL register
|
||||
.globl XCPT_IX ; Saved IX register
|
||||
.globl XCPT_IY ; Saved IY register
|
||||
.globl XCPT_SP ; Offset to SP at time of interrupt
|
||||
.globl XCPT_PC ; Offset to PC at time of interrupt
|
||||
|
||||
; Stack frame
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
;*************************************************************************
|
||||
|
||||
.area TEXT (ABS,OVR)
|
||||
up_saveusercontext:
|
||||
_up_saveusercontext:
|
||||
; Set up a stack frame
|
||||
|
||||
push ix ; Save IX and IY
|
||||
@ -73,10 +73,10 @@ up_saveusercontext:
|
||||
|
||||
; Fetch the address of the save area
|
||||
|
||||
ld l, FRAME_REGS(ix) ; HL = save area address
|
||||
ld h, FRAME_REGS+1(ix) ;
|
||||
ld e, FRAME_REGS(ix) ; HL = save area address
|
||||
ld d, FRAME_REGS+1(ix) ;
|
||||
ld iy, #0
|
||||
add iy, hl ; IY = save area address
|
||||
add iy, de ; IY = save area address
|
||||
|
||||
; Then save the registers
|
||||
|
||||
@ -85,13 +85,13 @@ up_saveusercontext:
|
||||
ld a, i ; Get interrupt state
|
||||
push af
|
||||
pop hl
|
||||
ld (iy+XCPT_I), l ; Offset 0: I w/interrupt state in carry
|
||||
ld (iy+XCPT_I+1), h
|
||||
ld XCPT_I(iy), l ; Offset 0: I w/interrupt state in carry
|
||||
ld XCPT_I+1(iy), h
|
||||
|
||||
; Save BC at offset 1
|
||||
|
||||
ld (iy+XCPT_BC), c ; Offset 1: BC
|
||||
ld (iy+XCPT_BC+1), b
|
||||
ld XCPT_BC(iy), c ; Offset 1: BC
|
||||
ld XCPT_BC+1(iy), b
|
||||
|
||||
; DE is not preserved (offset 2)
|
||||
|
||||
@ -99,29 +99,29 @@ up_saveusercontext:
|
||||
|
||||
ld l, FRAME_IX(ix) ; HL = Saved alue of IX
|
||||
ld h, FRAME_IX+1(ix) ;
|
||||
ld (iy+XCPT_IX), l ; Offset 3: IX
|
||||
ld (iy+XCPT_IX+1), h ;
|
||||
ld XCPT_IX(iy), l ; Offset 3: IX
|
||||
ld XCPT_IX+1(iy), h ;
|
||||
|
||||
; Save IY at offset 4
|
||||
|
||||
ld l, FRAME_IY(ix) ; HL = Saved value of IY
|
||||
ld h, FRAME_IY+1(ix) ;
|
||||
ld (iy+XCPT_IY), l ; Offset 4: IY
|
||||
ld (iy+XCPT_IY+1), h
|
||||
ld XCPT_IY(iy), l ; Offset 4: IY
|
||||
ld XCPT_IY+1(iy), h
|
||||
|
||||
; Save that stack pointer as it would be upon return in offset 5
|
||||
|
||||
ld hl, #SP_OFFSET ; Value of stack pointer on return
|
||||
add hl, sp
|
||||
ld (iy+XCPT_SP), l ; Offset 5 SP
|
||||
ld (iy+XCPT_SP+1), h
|
||||
ld XCPT_SP(iy), l ; Offset 5 SP
|
||||
ld XCPT_SP+1(iy), h
|
||||
|
||||
; HL is saved as the value 1 at offset 6
|
||||
|
||||
xor a ; A = 0
|
||||
ld (iy+XCPT_HL+1), a ; Offset 2: HL on return (=1)
|
||||
ld XCPT_HL+1(iy), a ; Offset 2: HL on return (=1)
|
||||
inc a ; A = 1
|
||||
ld (iy+XCPT_HL), a ;
|
||||
ld XCPT_HL(iy), a ;
|
||||
|
||||
; AF is not preserved (offset 7)
|
||||
|
||||
@ -129,8 +129,8 @@ up_saveusercontext:
|
||||
|
||||
ld l, FRAME_RET(ix) ; HL = Saved return address
|
||||
ld h, FRAME_RET+1(ix) ;
|
||||
ld (iy+XCPT_PC), l ; Offset 8: PC
|
||||
ld (iy+XCPT_PC+1), h
|
||||
ld XCPT_PC(iy), l ; Offset 8: PC
|
||||
ld XCPT_PC+1(iy), h
|
||||
|
||||
; Return the value 0
|
||||
|
||||
|
@ -55,11 +55,11 @@
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
|
@ -60,7 +60,7 @@
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
|
@ -59,11 +59,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Funtions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Funtions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -39,7 +39,7 @@ CMN_ASRCS = up_saveusercontext.asm up_restoreusercontext.asm
|
||||
CMN_CSRCS = up_initialize.c up_allocateheap.c up_initialstate.c \
|
||||
up_createstack.c up_releasestack.c up_interruptcontext.c \
|
||||
up_blocktask.c up_unblocktask.c up_exit.c up_releasepending.c \
|
||||
up_reprioritizertr.c up_copystate.c up_idle.c \
|
||||
up_reprioritizertr.c up_copystate.c up_irq.c up_idle.c \
|
||||
up_assert.c up_mdelay.c up_udelay.c \
|
||||
up_registerdump.c up_usestack.c \
|
||||
|
||||
|
@ -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
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
101
configs/z80sim/src/z80_lowputc.c
Normal file
101
configs/z80sim/src/z80_lowputc.c
Normal file
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user