📄 vectors.s
字号:
##=============================================================================
##
## vectors.S
##
## H8/300 exception vectors
##
##=============================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
##=============================================================================
#######DESCRIPTIONBEGIN####
##
## Author(s): Yoshinori Sato
## Contributors: Yoshinori Sato
## Date: 2002-02-14
## Purpose: H8/300 exception vectors
## Description: This file defines the code placed into the exception
## vectors. It also contains the first level default VSRs
## that save and restore state for both exceptions and
## interrupts.
##
######DESCRIPTIONEND####
##
##=============================================================================
#include <pkgconf/hal.h>
#ifdef CYGPKG_REDBOOT
#include <pkgconf/redboot.h>
#endif
#ifdef CYGPKG_KERNEL
#include <pkgconf/kernel.h>
#endif
#include <cyg/hal/arch.inc>
#include <cyg/hal/basetype.h>
#include <cyg/hal/variant.inc>
##-----------------------------------------------------------------------------
#ifdef CYGPKG_HAL_H8300_H8300H
.h8300h
.macro shll2 reg
shll.l \reg
shll.l \reg
.endm
.macro shlr2 reg
shlr.l \reg
shlr.l \reg
.endm
#endif
#ifdef CYGPKG_HAL_H8300_H8S
.h8300s
.macro shll2 reg
shll.l #2,\reg
.endm
.macro shlr2 reg
shlr.l #2,\reg
.endm
#endif
#ifdef CYGPKG_CYGMON
##-----------------------------------------------------------------------------
## Macros for Stack handling when running Cygmon
.macro hal_cygmon_switch_app_stack
#ifdef CYGPKG_HAL_H8300_H8300H
; Switch to interrupt stack to handle exception
; First, save some scratch registers
mov.l er0,@-sp
mov.l er1,@-sp
; Copy the exception frame
mov.l #__cygmon_interrupt_stack,er0
mov.l @(8:16,sp),er1
mov.l er1,@-er0
; Save the pre-exception sp in the register image
mov.l sp,@-er0
; Actually switch the stack
mov.l er0,sp
mov.l @sp,er0
adds #4,er0
adds #4,er0
mov.l er0,@sp
; Now, restore the scratch registers
mov.l @(-4:16,er0),er1
mov.l @(-8:16,er0),er0
#endif
#ifdef CYGPKG_HAL_H8300_H8S
; Switch to interrupt stack to handle exception
; First, save some scratch registers
stm.l er0-er1,@-sp
; Copy the exception frame
mov.l #__cygmon_interrupt_stack,er0
mov.l @(10,sp:16),er1
mov.l er1,@-er0
mov.w @(10,sp:16),r1
mov.w r1,@-er0
; Save the pre-exception sp in the register image
mov.l sp,@-er0
; Actually switch the stack
mov.l er0,sp
mov.l @sp,er0
adds #4,er0
adds #4,er0
mov.l er0,@sp
; Now, restore the scratch registers
mov.l @(-4:16,er0),er1
mov.l @(-8:16,er0),er0
#endif
.endm
.macro hal_cygmon_restore_app_stack
// For cygmon we are switching stacks immediately on exception.
// We must wait until the very end before restoring the original stack.
#ifdef CYGPKG_HAL_H8300_H8300H
; Save some scratch registers
subs #4,sp
mov.l er0,@-sp
mov.l er1,@-sp
; We need to restore the application stack pointer, but we also
; need to restore the exception frame.
mov.l @(12:16,sp),er0
mov.l @(16:16,sp),er1
mov.l er1,@er0
mov.l er0,@(8:16,sp)
; Restore the scratch registers
mov.l @sp+,er1
mov.l @sp+,er0
mov.l @sp+,sp // Restore the frame-adjusted SP
#endif
#ifdef CYGPKG_HAL_H8300_H8S
; Save some scratch registers
subs #4,sp
stm.l er0-er1,@-sp
; We need to restore the application stack pointer, but we also
; need to restore the exception frame.
mov.l @(12:16,sp),er0
mov.w @(16:16,sp),r1
mov.w r1,@er0
mov.l @(18:16,sp),er1
mov.l er1,@er0
mov.l er0,@(8:16,sp)
; Restore the scratch registers
ldm.l @sp+,er0-er1
mov.l @sp+,sp // Restore the frame-adjusted SP
#endif
.endm
#endif // CYGPKG_CYGMON
##-----------------------------------------------------------------------------
#if (defined(CYG_HAL_STARTUP_ROM) || \
defined(CYGPKG_HAL_H8300_H8300H_SIM) || \
defined(CYGPKG_HAL_H8300_H8S_SIM))
.section .vectors,"a"
.globl reset_vector
reset_vector:
.long CYG_LABEL_DEFN(_start)
.long CYG_LABEL_DEFN(_start)
vector = 2
.rept CYG_ISR_TABLE_SIZE-2
.long interrupt_redirect_table+vector*4
vector = vector + 1
.endr
#endif
#if !defined(CYGSEM_HAL_H8300_VECTOR_HOOK)
.section .int_hook_table,"ax"
interrupt_redirect_table:
vector = 0
.rept CYG_ISR_TABLE_SIZE
jsr @interrupt_entry
vector = vector + 1
.endr
#else
.section .int_hook_table,"x"
interrupt_redirect_table:
.space 4*CYG_ISR_TABLE_SIZE
#endif
##-----------------------------------------------------------------------------
## Startup code
.text
.globl CYG_LABEL_DEFN(_start)
CYG_LABEL_DEFN(_start):
; set up stack
mov.l #__interrupt_stack,sp
; Initialize hardware
hal_cpu_init
hal_mmu_init
hal_memc_init
hal_diag_init
hal_intc_init
hal_cache_init
hal_timer_init
hal_mon_init
#ifdef CYG_HAL_STARTUP_ROM
; Copy data from ROM to RAM
mov.l #CYG_LABEL_DEFN(__rom_data_start),er5
mov.l #CYG_LABEL_DEFN(__ram_data_start),er6
mov.l #CYG_LABEL_DEFN(__ram_data_end),er4
sub.l er6,er4
shlr2 er4
1:
mov.l @er5+,er0
mov.l er0,@er6
adds #4,er6
dec.l #1,er4
bne 1b
#endif
#if defined(CYGSEM_HAL_H8300_VECTOR_HOOK)
; Setup Interrupt Vector (virtual)
;; check rom table
mov.l #8*4,er0
mov.l @er0+,er1
adds #4,er1
mov.b #3,r3l
1:
mov.l @er0+,er2
cmp.l er1,er2
bne 3f
adds #4,er1
dec.b r3l
bne 1b
;; calculate vector address
mov.l @8*4,er0
and.w #0xff,e0
sub.l #8*4,er0
;; build ram vector
mov.l er0,@__interrupt_table
mov.l #0x5e000000+interrupt_entry,er1
mov.l #save_vector_table,er3
mov.b #0,r2l
2:
;; check saved vector
mov.b @er3+,r2h
cmp.b r2l,r2h
beq 5f
subs #1,er3
mov.l er1,@er0
5:
adds #4,er0
inc.b r2l
cmp.b #CYG_ISR_TABLE_SIZE,r2l
bcs 2b
bra 4f
3:
bra 3b
4:
#else
mov.l #interrupt_redirect_table,er0
mov.l er0,@__interrupt_table
#endif
; Clear BSS
mov.l #CYG_LABEL_DEFN(__bss_start),er5
mov.l #CYG_LABEL_DEFN(__bss_end),er4
sub.l #CYG_LABEL_DEFN(__bss_start),er4
shlr2 er4
sub.l er0,er0
1:
mov.l er0,@er5
adds #4,er5
dec.l #1,er4
bne 1b
; Call variant and platform HAL
; initialization routines.
.extern CYG_LABEL_DEFN(hal_variant_init)
jsr @CYG_LABEL_DEFN(hal_variant_init)
.extern CYG_LABEL_DEFN(hal_platform_init)
jsr @CYG_LABEL_DEFN(hal_platform_init)
; Call constructors
.extern CYG_LABEL_DEFN(cyg_hal_invoke_constructors)
jsr @CYG_LABEL_DEFN(cyg_hal_invoke_constructors)
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
.extern CYG_LABEL_DEFN(initialize_stub)
jsr @CYG_LABEL_DEFN(initialize_stub)
#endif
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) \
|| defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
.extern CYG_LABEL_DEFN(hal_ctrlc_isr_init)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -