📄 vectors.s
字号:
##=============================================================================#### vectors.S#### MN10300 exception vectors####=============================================================================#####COPYRIGHTBEGIN##### # ------------------------------------------- # The contents of this file are subject to the Red Hat eCos Public License # Version 1.1 (the "License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://www.redhat.com/ # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the # License for the specific language governing rights and limitations under # the License. # # The Original Code is eCos - Embedded Configurable Operating System, # released September 30, 1998. # # The Initial Developer of the Original Code is Red Hat. # Portions created by Red Hat are # Copyright (C) 1998, 1999, 2000 Red Hat, Inc. # All Rights Reserved. # ------------------------------------------- # #####COPYRIGHTEND######=============================================================================#######DESCRIPTIONBEGIN######## Author(s): nickg## Contributors: nickg## Date: 1997-10-16## Purpose: MN10300 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_KERNEL#include <pkgconf/kernel.h> #endif #include <cyg/hal/arch.inc> ##----------------------------------------------------------------------------- .file "vectors.S"##----------------------------------------------------------------------------- .section ".vectors","ax" .globl reset_vector reset_vector: # Reset vector jmp _start .p2align 3 # NMI vector jmp __nmi .p2align 3 # Trap vector jmp __trap##-----------------------------------------------------------------------------## NMI vector .globl __nmi__nmi: add -4,sp # space for SP hal_cpu_save_all # push all registers mov (_hal_vsr_table+28),a0 jmp (a0)##-----------------------------------------------------------------------------## Trap vector .globl __trap__trap: add -8,sp # space for SP and PSW hal_cpu_save_all # push all registers mov (_hal_vsr_table+32),a0 jmp (a0) ##-----------------------------------------------------------------------------## Macro to define a hardware VSR .macro hardware_vector name .globl __hardware_vector_\name__hardware_vector_\name: add -4,sp # space for SP hal_cpu_save_all mov \name,d0 # d0 = vector id mov d0,(0,sp) # save in dummy stack loc mov _hal_vsr_table,a0 # a0 = vsr table add \name<<2,a0 # a0 = &required vsr mov (a0),a0 # a0 = required vsr jmp (a0) # go there .endm ##-----------------------------------------------------------------------------## Hardware Vectors. These are pointed to by the registers in## mn10300_interrupt_vectors and must be in the range 0x4000XXXX. hardware_vector 0 hardware_vector 1 hardware_vector 2 hardware_vector 3 hardware_vector 4 hardware_vector 5 hardware_vector 6 ##-----------------------------------------------------------------------------## Startup code .text .globl _start_start: # set up stack mov __interrupt_stack,a0 sub 8,a0 mov a0,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 __rom_data_start,a0 mov __ram_data_end,a1 mov __ram_data_start,a2 cmp a2,a1 beq 8f1: movbu (a0),d0 movbu d0,(a2) inc a0 inc a2 cmp a2,a1 bne 1b 8: #endif # Clear BSS mov __bss_start,a0 mov __bss_end,a1 cmp a0,a1 beq 8f clr d01: movbu d0,(a0) inc a0 cmp a0,a1 bne 1b 8: # Call variant and platform HAL # initialization routines. .extern _hal_variant_init call _hal_variant_init,[],0 .extern _hal_platform_init call _hal_platform_init,[],0 # Call constructors .extern _cyg_hal_invoke_constructors call _cyg_hal_invoke_constructors,[],0#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS .extern _initialize_stub call _initialize_stub,[],0#endif # Call cyg_start clr d0 mov d0,(4,sp) .extern _cyg_start call _cyg_start,[],09: bra 9b # Loop if we return##-----------------------------------------------------------------------------## The following macros are defined depending on whether the HAL is configured## to support the kernel or not. #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT .extern cyg_scheduler_sched_lock # Increment the scheduler lock .macro increment_sched_lock reg=d0 mov (cyg_scheduler_sched_lock),\reg inc \reg mov \reg,(cyg_scheduler_sched_lock) .endm#else .macro increment_sched_lock reg=d0 .endm#endif ##-----------------------------------------------------------------------------## Default interrupt VSR .text .globl __default_interrupt_vsr__default_interrupt_vsr: # We come here with all the registers pushed # onto the stack. hal_diag_intr_start increment_sched_lock #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK # Increment interrupt nesting counter mov __interrupt_stack,a0 # A0 = interrupt stack top mov sp,a2 # A2 = SP cmp __interrupt_stack_base,a2 # compare with base of stack blt 1f # if lt switch to int stack cmp a0,a2 # compare sp with stack top ble 8f # if le already on istack1: mov a0,sp # switch to new SP8: movm [a2],(sp) # save old SP#else mov sp,a2 # A2 = saved thread state#endif # Here A2 -> saved thread state on the threads own # stack. We will be executing either on the same stack # or on the interrupt stack, depending on config options. hal_intc_decode d3,a3,d0 # Here D3 contains the table byte offset of the vector to # call.#if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR) # Call cyg_instrument to record that this interrupt is being raised. .extern _cyg_instrument add -16,sp # make space for return link + args mov 0x0301,d0 # d0 = type = INTR,RAISE mov (0,a2),d1 # d1 = arg1 = vector mov d3,(12,sp) # (12,sp) = arg2 = table offset calls _cyg_instrument # call instrumentation add 16,sp # pop space #endif #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT .extern _cyg_hal_gdb_isr add -16,sp # make space for return link + args mov (0,a2),d0 # d0 = vector mov (SAVED_CONTEXT_PC_OFFSET,a2),d1 # d1 = pc calls _cyg_hal_gdb_isr # call GDB isr function cmp 0x00,d0 # Call ISR proper? beq 2f # (d0 is 0 when skipping # to avoid DSR call) add 16,sp # pop space#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -