⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vectors.s

📁 eCos1.31版
💻 S
📖 第 1 页 / 共 3 页
字号:
##==========================================================================####      vectors.S####      PowerPC 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, 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_IR | MSR_DR | MSR_RI)#if defined(CYG_HAL_STARTUP_ROM)# ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS#  define CYG_MSR CYG_MSR_COMMON# else#  define CYG_MSR (CYG_MSR_COMMON | MSR_IP)# endif#elif defined(CYG_HAL_STARTUP_RAM)# define CYG_MSR CYG_MSR_COMMON#endif#ifdef CYGPKG_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# 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(CYG_HAL_STARTUP_ROM)    || \        defined(CYGPKG_HAL_POWERPC_SIM) || \        defined(CYGSEM_HAL_POWERPC_COPY_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:        lwi     r3,_start        mtlr    r3        blr        .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@L       # 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@L       # reload low half of vector addr        blr                                  # go to common code        .endm        #---------------------------------------------------------------------------# Define the exception vectors.rom_vectors:        # These are the architecture defined vectors that        # are always present.        exception_vector        reserved_00000        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 //  CYG_HAL_STARTUP_ROM || CYGSEM_HAL_POWERPC_COPY_VECTORS        # When vectors are not included this is the primary entry point.        .globl  __exception_reset__exception_reset:        lwi     r3,_start        mtlr    r3        blr        #endif //  CYG_HAL_STARTUP_ROM || CYGSEM_HAL_POWERPC_COPY_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#if !defined(CYG_HAL_STARTUP_ROM) && defined(CYGSEM_HAL_POWERPC_COPY_VECTORS)        lwi     r3,rom_vectors-4        lwi     r4,0x0000-4        lwi     r5,rom_vectors_end-40:      lwzu    r0,4(r3)        stwu    r0,4(r4)        cmplw   r3,r5        bne     0b#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	# this is platform dependent

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -