vectors.s
来自「eCos操作系统源码」· S 代码 · 共 933 行 · 第 1/3 页
S
933 行
##==========================================================================#### vectors.S#### PowerPC exception vectors####==========================================================================#####ECOSGPLCOPYRIGHTBEGIN###### -------------------------------------------## This file is part of eCos, the Embedded Configurable Operating System.## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.## Copyright (C) 2002 Gary Thomas#### 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): 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########==========================================================================#===========================================================================## The PowerPC exception handling has changed as of version 1.3.1.# The primary motivation for rewriting the code was to bring it more# in line with the other HALs, in particular to allow a RAM application# to cleanly take over only a subset of vectors from a running ROM# monitor.## GDB stubs (and CygMon, should it be ported to PPC) copies# exception vector entry handler code to address 0. These vector entry# handlers (defined by the exception_vector macro below) compute# a vector index into the hal_vsr_table, fetch the pointer, and# jump to the HAL vector service routine (VSR).## The hal_vsr_table is located immediately after the vector# handlers (at address 0x3000), allowing RAM applications to# change VSRs as necessary, while still keeping desired ROM# monitor functionality available for debugging.## ROM applications can still be configured to leave the vector entry# handlers at 0xff000000, but there is at the moment no# provision for reclaiming the reserved vector space in RAM to# application usage.## RAM applications can also be configured to provide exception# handlers which are copied to address 0 on startup, thus taking# full control of the target.### Default configuration is for RAM applications to rely on an# existing ROM monitor to provide debugging functionality, and# for ROM applications to copy vectors to address 0.### Unfortunately the new exception scheme is not compatible with the# old scheme. Stubs and applications must be compiled using the same# scheme (i.e., old binaries will not run with new stubs, and new# binaries will not run with old stubs).##===========================================================================#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>#=========================================================================== // .file "vectors.S" .extern hal_interrupt_data .extern hal_interrupt_handlers .extern hal_interrupt_objects .extern hal_vsr_table .extern cyg_hal_invoke_constructors .extern cyg_instrument .extern cyg_start .extern hal_IRQ_init .extern hal_MMU_init .extern hal_enable_caches .extern hal_hardware_init .extern initialize_stub .extern __bss_start .extern __bss_end .extern __sbss_start .extern __sbss_end#===========================================================================# 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_RI)#if (CYGHWR_HAL_POWERPC_VECTOR_BASE == 0xfff00000)# define IP_BIT MSR_IP#else# define IP_BIT 0#endif#ifdef CYGHWR_HAL_POWERPC_ENABLE_MMU# define IR_DR_BITS (MSR_IR | MSR_DR)#else# define IR_DR_BITS 0#endif#define CYG_MSR (CYG_MSR_COMMON | IP_BIT | IR_DR_BITS)# Include variant macros after MSR definition. #include <cyg/hal/arch.inc>#include <cyg/hal/ppc_offsets.inc>#===========================================================================# 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 #if defined(CYGHWR_HAL_POWERPC_NEED_VECTORS)#===========================================================================# Start by defining the exceptions vectors that must be placed at# locations 0xFFF00000 or 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. .section ".vectors","ax"#---------------------------------------------------------------------------# Macros for generating an exception vector service routine# Reset vector macro .macro reset_vector name .p2align 8 .globl __exception_\name__exception_\name:#ifdef CYGSEM_HAL_POWERPC_RESET_USES_JUMP bl _start #else lwi r3,_start mtlr r3 blr#endif .endm # Generic vector macro .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-rom_vectors # load low half of vector addr 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-rom_vectors # reload low half of vector addr blr # go to common code .endm #---------------------------------------------------------------------------# Define the exception vectors.// Some platforms won't let us put the vector code just where we want// This macro introduces some lattitude in vector placement #ifdef CYG_HAL_FUDGE_VECTOR_ALIGNMENT hal_fudge_vector_alignment#endif rom_vectors: # These are the architecture defined vectors that # are always present.#ifdef CYG_HAL_RESERVED_VECTOR_00000 hal_reserved_vector_00000 #else exception_vector reserved_00000#endif reset_vector reset exception_vector machine_check exception_vector data_storage exception_vector instruction_storage exception_vector external exception_vector alignment exception_vector program 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 # Variants may define extra vectors. hal_extra_vectorsrom_vectors_end: #else // CYGHWR_HAL_POWERPC_NEED_VECTORS # When vectors are not included this is the primary entry point. .globl __exception_reset__exception_reset: lwi r3,_start mtlr r3 blr #endif // CYGHWR_HAL_POWERPC_NEED_VECTORS#===========================================================================# Real startup code. We jump here from the various reset vectors to set up# the world. .text .globl _start_start: # Initialize CPU to a post-reset state, ensuring the ground doesn''t # shift under us while we try to set things up. hal_cpu_init # 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 # this is platform dependent .globl _hal_hardware_init_done_hal_hardware_init_done:#if !defined(CYG_HAL_STARTUP_ROM) && defined(CYGSEM_HAL_POWERPC_COPY_VECTORS) lwi r3,rom_vectors-4 lwi r4,((CYGHWR_HAL_POWERPC_VECTOR_BASE)-4) lwi r5,rom_vectors_end-40: lwzu r0,4(r3) stwu r0,4(r4) cmplw r3,r5 bne 0b#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?