📄 vectors.s
字号:
##=============================================================================#### vectors.S#### MIPS 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: 1998-02-04## Purpose: MIPS 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/system.h> #include <pkgconf/hal.h>#ifdef CYGPKG_KERNEL# include <pkgconf/kernel.h> #endif #include <cyg/hal/arch.inc> .extern cyg_instrument##-----------------------------------------------------------------------------## Hardware supplied vectors .set noreorder .section ".reset_vector","ax" # Reset vector at 0xBFC00000 FUNC_START(reset_vector)#ifndef CYG_HAL_STARTUP_RAM # Decide whether this is an NMI, cold or warm boot. mfc0 k0,status # get status reg lui k1,0x0008 # isolate NMI bit and k1,k1,k0 beqz k1,1f # skip if zero nop lar k1,__nmi_entry # jump to ROM nmi code jalr k1 nop1: lui k1,0x0010 # isolate soft reset bit and k1,k1,k0 beqz k1,2f # skip if zero nop lar k1,__warm_start # jump to ROM warm_start code jr k1 nop2: la k0,INITIAL_CONFIG0 # Set up config0 register mtc0 k0,config0 # to disable cache#endif lar v0,_start # jump to start jr v0 nop # (delay slot)FUNC_END(reset_vector) .section ".debug_vector","ax" # Debug vector at 0xBFC00200 FUNC_START(debug_vector) la k0,32 la k1,hal_vsr_table # Get VSR table lw k1,32*4(k1) # load debug vector jr k1 # go there nop # (delay slot)FUNC_END(debug_vector) .section ".other_vector","ax" # Common vector at 0x80000080 or 0xBFC00180 FUNC_START(other_vector) mfc0 k0,cause # K0 = exception cause nop andi k0,k0,0x7F # isolate exception code la k1,hal_vsr_table # address of VSR table add k1,k1,k0 # offset of VSR entry lw k1,0(k1) # k1 = pointer to VSR jr k1 # go there nop # (delay slot)FUNC_END(other_vector) .section ".utlb_vector","ax"FUNC_START(utlb_vector) la k0,33 la k1,hal_vsr_table # Get VSR table lw k1,33*4(k1) # load utlb vector jr k1 # go there nop # (delay slot)FUNC_END(utlb_vector)##-----------------------------------------------------------------------------## Startup code .text FUNC_START(_start) # Initialize hardware hal_cpu_init hal_diag_init hal_mmu_init hal_fpu_init hal_memc_init hal_intc_init hal_cache_init hal_timer_init # Load Global Pointer register. la gp,_gp # load initial stack pointer la a0,__interrupt_stack move sp,a0 hal_mon_init #ifdef CYG_HAL_STARTUP_ROM # Copy data from ROM to RAM .extern hal_copy_data jal hal_copy_data nop#endif # Zero BSS .extern hal_zero_bss jal hal_zero_bss nop # Call variant and platform HAL # initialization routines. .extern hal_variant_init jal hal_variant_init nop .extern hal_platform_init jal hal_platform_init nop # Call constructors .extern cyg_hal_invoke_constructors jal cyg_hal_invoke_constructors nop#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) .extern initialize_stub jal initialize_stub nop#endif # Call cyg_start .extern cyg_start j cyg_start lui ra,0 FUNC_END(_start )##----------------------------------------------------------------------------- FUNC_START(__warm_start) ## The following is debug code left in here for now in case it ## proves useful in the near future. #if 0 move s0,t0 move s1,a1 # hal_diag_init hal_diag_writec '$' mfc0 a0,$30 # get ErrorEPC lar k0,hal_diag_ai_write_hex8 jalr k0 nop hal_diag_writec '-' move a0,s0 jalr k0 nop hal_diag_writec '-' move a0,s1 jalr k0 nop1: b 1b nop#endif # At present we treat this like an NMI. b __nmi_entry nop FUNC_END(__warm_start) ##----------------------------------------------------------------------------- FUNC_START(__nmi_entry) # Clear exception state hal_cpu_except_enable # Move the ErrorEPC register to the EPC register so that the # default exception handler saves the right PC value. mfc0 k0,$30 nop; nop; nop; mtc0 k0,epc nop; nop; nop; #if (INITIAL_SR & 0x00400000) == 0 # Taking this exception will have set the BEV bit to 1. # If we normally run with it zero, we must clear it here. mfc0 k0,status la k1,0xFFBFFFFF and k0,k0,k1 mtc0 k0,status#endif la k0,34*4 la k1,hal_vsr_table # Get VSR table lw k1,34*4(k1) # load NMI vector jr k1 # go there nop # (delay slot) FUNC_END(__nmi_entry) ##-----------------------------------------------------------------------------## Default exception VSR.## Saves machine state and calls external handling code. FUNC_START(__default_exception_vsr) # We enter here with all of the CPU state still # in its registers except: # K0 = vector index # K1 = address of this function move k1,sp # K1 = original SP #ifdef CYGSEM_HAL_ROM_MONITOR # Switch to interrupt stack to handle exception la sp,__interrupt_stack#endif addi sp,sp,-mips_exception_decrement # space for registers + safety margin sw k0,mipsreg_vector(sp) # store vector # store GPRs .set noat sgpr 0,sp sgpr 1,sp sgpr 2,sp sgpr 3,sp sgpr 4,sp sgpr 5,sp sgpr 6,sp sgpr 7,sp sgpr 8,sp sgpr 9,sp sgpr 10,sp sgpr 11,sp sgpr 12,sp sgpr 13,sp sgpr 14,sp sgpr 15,sp sgpr 16,sp sgpr 17,sp sgpr 18,sp sgpr 19,sp sgpr 20,sp sgpr 21,sp sgpr 22,sp sgpr 23,sp sgpr 24,sp sgpr 25,sp# sgpr 26,sp # == K0# sgpr 27,sp # == K1 sgpr 28,sp # == GP# sgpr 29,sp # == SP sgpr 30,sp # == FP sgpr 31,sp # == RA .set at mfhi a0 mflo a1 shi a0,sp slo a1,sp # K1 contains original SP ssp k1,sp # store in reg dump # save remaining machine state registers mfc0 t0,cause mfc0 t1,status mfc0 t2,cachectrl mfc0 t3,badvr mfc0 t4,config mfc0 t5,prid mfc0 t6,epc sw t0,mipsreg_cause(sp) sw t1,mipsreg_sr(sp) sw t2,mipsreg_cachectrl(sp) sw t3,mipsreg_badvr(sp) sw t4,mipsreg_config(sp) sw t5,mipsreg_prid(sp) sw t6,mipsreg_pc(sp) hal_fpu_save sp # The machine state is now all saved on the stack. hal_diag_excpt_start # Load Global Pointer register. la gp,_gp move s0,sp # save pointer to saved state addi sp,sp,-mips_stack_frame_size # make a null frame # Need to set up back pointers etc. ??? la ra,restore_state # load return address hal_cpu_except_enable # reenable exceptions .extern cyg_hal_exception_handler j cyg_hal_exception_handler # call C code move a0,s0 # arg0 = register dump (delay slot) # When the exception handler returns, it will # go back to restore_state, below. FUNC_END(__default_exception_vsr)##------------------------------------------------------------------------------## Default interrupt VSR.## Saves machine state and calls appropriate ISR. When done, calls## interrupt_end() to finish up and possibly reschedule. FUNC_START(__default_interrupt_vsr) # We enter here with all of the CPU state still # in its registers except: # K0 = vector index # K1 = address of this function move k1,sp # K1 = original SP addi sp,sp,-mips_exception_decrement # space for registers + safety margin sw k0,mipsreg_vector(sp) # store vector # store GPRs .set noat sgpr 0,sp sgpr 1,sp sgpr 2,sp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -