📄 vectors.s
字号:
##=============================================================================#### vectors.S#### MN10300 exception vectors####=============================================================================#####COPYRIGHTBEGIN###### -------------------------------------------# The contents of this file are subject to the Cygnus eCos Public License# Version 1.0 (the "License"); you may not use this file except in# compliance with the License. You may obtain a copy of the License at# http://sourceware.cygnus.com/ecos# # 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 Cygnus Operating System, released# September 30, 1998.# # The Initial Developer of the Original Code is Cygnus. Portions created# by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. 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 .extern _cyg_instrument ##-----------------------------------------------------------------------------## Register addresses and initialization values .equ IOBCTR ,0x32000010 .equ MEMCTR0 ,0x32000020 .equ MEMCTR1 ,0x32000022 .equ MEMCTR2 ,0x32000024 .equ MEMCTR3 ,0x32000026 .equ MEMCTR4 ,0x32000028 .equ MEMCTR5 ,0x3200002a .equ MEMCTR6 ,0x3200002c .equ MEMCTR7 ,0x3200002e .equ DRAMCTR ,0x32000040 .equ REFCNT ,0x32000042#ifdef CYG_HAL_MN10300_STDEVAL1 .equ INIT_MEMCTR0,0x1200 # 2wait .equ INIT_MEMCTR1,0x0120 # 1wait-32bit- .equ INIT_MEMCTR2,0x0065 .equ INIT_DRAMCTR,0x0287 .equ INIT_REFCNT,0x00eb #endif .equ P2OUT ,0x36008004 .equ P2MD ,0x36008024 .equ P2SS ,0x36008044 .equ P2DIR ,0x36008064 .equ INIT_P2MD,0xf0 .equ INIT_P2DIR,0xff##----------------------------------------------------------------------------- .macro led val movm [d2],(sp) mov \val,d2 asl 4,d2 movbu d2,(P2OUT) movm (sp),[d2] .endm ##----------------------------------------------------------------------------- .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 movm [d2,d3,a2,a3,other],(sp) # push all registers mov (_hal_vsr_table+28),a0 jmp (a0)##-----------------------------------------------------------------------------## Trap vector .globl __trap__trap: add -8,sp # space for SP and PSW movm [d2,d3,a2,a3,other],(sp) # 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 movm [d2,d3,a2,a3,other],(sp) # push all registers 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:#if defined(CYG_HAL_MN10300_STDEVAL1) mov INIT_MEMCTR0,d2 movhu d2,(MEMCTR0) mov INIT_MEMCTR1,d2 movhu d2,(MEMCTR1) mov INIT_MEMCTR2,d2 movhu d2,(MEMCTR2) mov INIT_REFCNT,d2 movhu d2,(REFCNT) mov INIT_DRAMCTR,d2 movhu d2,(DRAMCTR) # Set up LED mov INIT_P2MD,d2 movbu d2,(P2MD) mov INIT_P2DIR,d2 movbu d2,(P2DIR)#endif # Set up the PSW mov 0x0700,d0 mov d0,psw # set up stack mov __interrupt_stack,a0 sub 8,a0 mov a0,sp #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: # Install interrupt vectors#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_MN10300_SIM) mov _mn10300_interrupt_vectors,a0 mov __hardware_vector_0,d0 movhu d0,(0,a0) mov __hardware_vector_1,d0 movhu d0,(4,a0) mov __hardware_vector_2,d0 movhu d0,(8,a0) mov __hardware_vector_3,d0 movhu d0,(12,a0) mov __hardware_vector_4,d0 movhu d0,(16,a0) mov __hardware_vector_5,d0 movhu d0,(20,a0) mov __hardware_vector_6,d0 movhu d0,(24,a0)#endif#if defined(CYG_HAL_STARTUP_RAM) && !defined(CYG_HAL_MN10300_SIM) # init vsr table in SRAM where the ROM # vectors the interrupts. mov _hal_vsr_table,a0 mov __default_interrupt_vsr,d0 mov d0,(0,a0) mov d0,(4,a0) mov d0,(8,a0)#ifndef CYG_HAL_USE_ROM_MONITOR_CYGMON # When using Cygmon, leave level 3 for GDB # Ctrl-C interrupts. mov d0,(12,a0) #endif mov d0,(16,a0) mov d0,(20,a0) mov d0,(24,a0) mov __default_nmi_vsr,d0 mov d0,(28,a0) mov __default_trap_vsr,d0 mov d0,(32,a0)#endif # Call constructors .extern _cyg_hal_invoke_constructors call _cyg_hal_invoke_constructors,[],0 .extern _cyg_hal_enable_caches call _cyg_hal_enable_caches,[],0 .extern _cyg_hal_debug_init call _cyg_hal_debug_init,[],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##-----------------------------------------------------------------------------## Debug code to count interrupts on the led. #ifdef CYG_HAL_MN10300_STDEVAL1 .macro show_interrupts mov (led_count),d1 inc d1# cmp 20000,d1# ble 2f mov 0,d1 movbu (led_value),d0 movbu d0,(P2OUT) add 16,d0 cmp 0x90,d0 bne 1f mov 0,d01: movbu d0,(led_value)2: mov d1,(led_count) .endm#else .macro show_interrupts .endm #endif ##-----------------------------------------------------------------------------## 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 ##-----------------------------------------------------------------------------## The following macros are defined depending on whether the Interrupt## system is using isr tables or chaining. #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN#if defined(CYG_HAL_MN10300_MN103000)#define CYG_ISR_TABLE_SIZE 7 # decode the interrupt .macro decode_interrupt dreg,areg,dreg1 mov _mn10300_interrupt_control,\areg movhu (0x100,\areg),\dreg # dreg = IAGR movhu (\dreg,\areg),\dreg1 # dreg1 = IGR[dreg] and 0xf,\dreg1 # dreg1 = ID0..3 mov hal_lsbit_table,\areg # areg = ls bit table movbu (\dreg1,\areg),\dreg1 # dreg1 = ls bit index
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -