📄 vectors.s
字号:
##==========================================================================#### vectors.S#### PowerPC 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, jskov## Contributors: nickg, jskov## Date: 1999-02-20## Purpose: PowerPC 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> // CYGPKG_KERNEL_INSTRUMENT#endif#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS#include "cyg/hal/ppc_regs.h" #include "cyg/hal/ppc.inc"#define FUNC_START(name) \ .type name,@function; \ .globl name; \name: #=========================================================================== .file "vectors.S" .extern hal_interrupt_handlers .extern hal_interrupt_data .extern hal_interrupt_objects .extern cyg_instrument .extern hal_hardware_init#===========================================================================# MSR initialization value# zero all bits except:# FP = floating point available# ME = machine check enabled# IP = vectors at 0xFFFxxxxx (ROM startup only)# IR = instruction address translation# DR = data address translation# RI = recoverable interrupt#define CYG_MSR_COMMON (MSR_FP | MSR_ME | MSR_IR | MSR_DR | MSR_RI)#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS)#define CYG_MSR (CYG_MSR_COMMON | MSR_IP)#endif#ifdef CYG_HAL_STARTUP_RAM #define CYG_MSR CYG_MSR_COMMON#endif#ifdef CYG_HAL_POWERPC_SIM# When building for SIM, don't enable MMU -- it's not needed since caches# are disabled, and there is a runtime simulation overhead.#undef CYG_MSR#define CYG_MSR (CYG_MSR_COMMON & ~(MSR_IR | MSR_DR))#endif#===========================================================================# If the following option is enabled, we only save registers up to R12.# The PowerPC ABI defines registers 13..31 as callee saved and thus we do# not need to save them when calling C functions.#ifdef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT#define MAX_SAVE_REG 12#else#define MAX_SAVE_REG 31 #endif #===========================================================================# Start by defining the exceptions vectors that must be placed at# locations 0xFFF00000 and 0x00000000. The following code will normally# be located at 0xFFF00000 in the ROM. It may optionally be copied out# to 0x00000000 if we want to use the RAM vectors. For this reason this code# MUST BE POSITION INDEPENDENT. In RAM loaded configurations, this code may# be placed at 0x00000000 during loading. .section ".vectors","ax"#---------------------------------------------------------------------------# Unused first vector.rom_vectors: lwi r3,_start mtlr r3 blr .byte 0x11 .byte 0x22 .byte 0x33 .byte 0x44 #---------------------------------------------------------------------------# Reset vector. .p2align 8 .globl reset_vector reset_vector: lwi r3,_start mtlr r3 blr #---------------------------------------------------------------------------# Macro for generating an exception vector service routine .macro exception_vector name .p2align 8 .globl __exception_\name__exception_\name: mtspr SPRG1,r3 # stash some work registers away mtspr SPRG2,r4 mtspr SPRG3,r5 mfcr r4 # stash CR li r5,__exception_\name@L # load low half of vector address srwi r5,r5,6 # shift right by 6 lwi r3,hal_vsr_table # table base lwzx r3,r3,r5 # address of vsr mflr r5 # save link register mtlr r3 # put vsr address into it li r3,__exception_\name@L # reload low half of vector address blr # go to common code .endm #---------------------------------------------------------------------------# Define the exception vectors. # These are the architecture defined vectors that # are always present. exception_vector machine_check exception_vector data_storage exception_vector instruction_storage exception_vector external exception_vector alignment#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS) \ || defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) exception_vector program#else # Provide a crude hook to the GDB exception handler in ROM. # This allows the testing infrastructure to rely on breakpoints # to terminate tests, even when the tests are compiled without # the GDB stub. # It is _not_ a generic solution to the problem; in particular it # is not possible to continue after a breakpoint is hit. .p2align 8 .globl __exception_program__exception_program: bl _init_CPU # disable caches. lwi r3,0xfff00700 # address of trap handler mtlr r3 # in ROM. blr # jump to it.#endif exception_vector floatingpoint_unavailable exception_vector decrementer exception_vector reserved_00a00 exception_vector reserved_00b00 exception_vector system_call exception_vector trace exception_vector floatingpoint_assist exception_vector reserved_00f00 # There are some additional vectors defined # on various implementations.#ifdef CYG_HAL_POWERPC_MPC8xx # MPC8xx vectors exception_vector software_emu exception_vector instruction_tlb_miss exception_vector data_tlb_miss exception_vector instruction_tlb_error exception_vector data_tlb_error exception_vector reserved_01500 exception_vector reserved_01600 exception_vector reserved_01700 exception_vector reserved_01800 exception_vector reserved_01900 exception_vector reserved_01A00 exception_vector reserved_01B00 exception_vector data_breakpoint exception_vector instruction_breakpoint exception_vector peripheral_breakpoint exception_vector NMI_port#endifrom_vectors_end: #===========================================================================# Real startup code. We jump here from the various reset vectors to set up# the world. .text .globl _start _start: # Initialize CPU bl _init_CPU#ifdef CYG_HAL_POWERPC_MPC8xx # Disable special MPC8xx "development support" which # suppresses trace exceptions. The CPU seems to hang, not # executing from offset 0x1e00(?) as expected. li r3,0 mtspr DER, r3#endif # Set up global offset table lwi r2,_GLOBAL_OFFSET_TABLE_ # set up time base register to zero xor r3,r3,r3 mtspr TBL_W,r3 xor r4,r4,r4 mtspr TBU_W,r4 # Call platform specific hardware initialization # This may include memory controller initialization. It is not # safe to access RAM until after this point. bl hal_hardware_init # set up stack lwi sp,__interrupt_stack mtspr SPRG0,sp # save in sprg0 for later use#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS) # Copy data from ROM to ram lwi r3,__rom_data_start # r3 = rom start lwi r4,__ram_data_start # r4 = ram start lwi r5,__ram_data_end # r5 = ram end cmplw r4,r5 # skip if no data beq 2f 1: lwz r0,0(r3) # get word from ROM stw r0,0(r4) # store in RAM addi r3,r3,4 # increment by 1 word addi r4,r4,4 # increment by 1 word cmplw r4,r5 # compare blt 1b # loop if not yet done2: #ifdef CYG_HAL_POWERPC_COPY_VECTORS # Copy RAM exception vectors from ROM to RAM lwi r3,rom_vectors # r3 = rom start lwi r4,0 # r4 = ram start lwi r5,rom_vectors_end # r5 = rom end cmplw r3,r5 # skip if no vectors beq 2f 1: lwz r0,0(r3) # get word from ROM stw r0,0(r4) # store in RAM addi r3,r3,4 # increment by 1 word addi r4,r4,4 # increment by 1 word cmplw r3,r5 # compare blt 1b # loop if not yet done2:#endif #endif # clear BSS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -