| 1 |
786 |
skrzyp |
##==========================================================================
|
| 2 |
|
|
##
|
| 3 |
|
|
## Vectors.S
|
| 4 |
|
|
##
|
| 5 |
|
|
## OpenRISC exception vectors, interrupt-handling, reset and
|
| 6 |
|
|
## platform-indepent initialization
|
| 7 |
|
|
##
|
| 8 |
|
|
##==========================================================================
|
| 9 |
|
|
## ####ECOSGPLCOPYRIGHTBEGIN####
|
| 10 |
|
|
## -------------------------------------------
|
| 11 |
|
|
## This file is part of eCos, the Embedded Configurable Operating System.
|
| 12 |
|
|
## Copyright (C) 2002 Free Software Foundation, Inc.
|
| 13 |
|
|
##
|
| 14 |
|
|
## eCos is free software; you can redistribute it and/or modify it under
|
| 15 |
|
|
## the terms of the GNU General Public License as published by the Free
|
| 16 |
|
|
## Software Foundation; either version 2 or (at your option) any later
|
| 17 |
|
|
## version.
|
| 18 |
|
|
##
|
| 19 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 20 |
|
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 21 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 22 |
|
|
## for more details.
|
| 23 |
|
|
##
|
| 24 |
|
|
## You should have received a copy of the GNU General Public License
|
| 25 |
|
|
## along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 26 |
|
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 27 |
|
|
##
|
| 28 |
|
|
## As a special exception, if other files instantiate templates or use
|
| 29 |
|
|
## macros or inline functions from this file, or you compile this file
|
| 30 |
|
|
## and link it with other works to produce a work based on this file,
|
| 31 |
|
|
## this file does not by itself cause the resulting work to be covered by
|
| 32 |
|
|
## the GNU General Public License. However the source code for this file
|
| 33 |
|
|
## must still be made available in accordance with section (3) of the GNU
|
| 34 |
|
|
## General Public License v2.
|
| 35 |
|
|
##
|
| 36 |
|
|
## This exception does not invalidate any other reasons why a work based
|
| 37 |
|
|
## on this file might be covered by the GNU General Public License.
|
| 38 |
|
|
## -------------------------------------------
|
| 39 |
|
|
## ####ECOSGPLCOPYRIGHTEND####
|
| 40 |
|
|
##==========================================================================
|
| 41 |
|
|
#######DESCRIPTIONBEGIN####
|
| 42 |
|
|
##
|
| 43 |
|
|
## Author(s): sfurman
|
| 44 |
|
|
## Contributors: Piotr Skrzypek (pskrzypek@antmicro.com)
|
| 45 |
|
|
## Date: 2003-01-20
|
| 46 |
|
|
## Purpose: OpenRISC interrupts, exception vectors and reset
|
| 47 |
|
|
## Description: This file defines the code placed into the exception
|
| 48 |
|
|
## vectors. It also contains the first level default VSRs
|
| 49 |
|
|
## that save and restore state for both exceptions and
|
| 50 |
|
|
## interrupts.
|
| 51 |
|
|
##
|
| 52 |
|
|
######DESCRIPTIONEND####
|
| 53 |
|
|
##
|
| 54 |
|
|
##==========================================================================
|
| 55 |
|
|
|
| 56 |
|
|
#include
|
| 57 |
|
|
|
| 58 |
|
|
#ifdef CYGPKG_KERNEL
|
| 59 |
|
|
#include // CYGPKG_KERNEL_INSTRUMENT
|
| 60 |
|
|
#endif
|
| 61 |
|
|
|
| 62 |
|
|
#include
|
| 63 |
|
|
#include
|
| 64 |
|
|
|
| 65 |
|
|
#===========================================================================
|
| 66 |
|
|
|
| 67 |
|
|
|
| 68 |
|
|
.extern hal_vsr_table
|
| 69 |
|
|
|
| 70 |
|
|
.extern cyg_hal_invoke_constructors
|
| 71 |
|
|
.extern _cyg_instrument
|
| 72 |
|
|
.extern cyg_start
|
| 73 |
|
|
.extern _hal_IRQ_init
|
| 74 |
|
|
.extern hal_platform_init
|
| 75 |
791 |
skrzyp |
.extern initialize_stub
|
| 76 |
786 |
skrzyp |
|
| 77 |
|
|
.extern __bss_start
|
| 78 |
|
|
.extern __bss_end
|
| 79 |
|
|
.extern __sbss_start
|
| 80 |
|
|
.extern __sbss_end
|
| 81 |
|
|
|
| 82 |
|
|
# Include variant macros after MSR definition.
|
| 83 |
|
|
#include
|
| 84 |
|
|
#include
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
#===========================================================================
|
| 88 |
|
|
# Start by defining the exceptions vectors that must be placed in low
|
| 89 |
|
|
# memory, starting at location 0x100.
|
| 90 |
|
|
|
| 91 |
|
|
.section ".vectors","ax"
|
| 92 |
|
|
|
| 93 |
|
|
#---------------------------------------------------------------------------
|
| 94 |
|
|
# Macros for generating an exception vector service routine
|
| 95 |
|
|
|
| 96 |
|
|
# Reset vector macro
|
| 97 |
|
|
|
| 98 |
|
|
.macro reset_vector name org
|
| 99 |
|
|
.p2align 8
|
| 100 |
|
|
.globl __exception_\name
|
| 101 |
|
|
__exception_\name:
|
| 102 |
|
|
load32i r3,start
|
| 103 |
|
|
l.jr r3
|
| 104 |
|
|
l.nop # delay slot
|
| 105 |
|
|
.endm
|
| 106 |
|
|
|
| 107 |
|
|
# Generic vector macro
|
| 108 |
|
|
|
| 109 |
|
|
.macro exception_vector name org
|
| 110 |
|
|
.p2align 8
|
| 111 |
|
|
.globl __exception_\name
|
| 112 |
|
|
__exception_\name:
|
| 113 |
|
|
l.addi sp,sp,-SIZEOF_OR1KREGS-132 # space for registers
|
| 114 |
|
|
|
| 115 |
|
|
# Store General Purpose Registers (GPRs).
|
| 116 |
|
|
|
| 117 |
|
|
l.sw 3 * OR1K_GPRSIZE(sp), r3
|
| 118 |
|
|
l.sw 4 * OR1K_GPRSIZE(sp), r4
|
| 119 |
|
|
l.sw 5 * OR1K_GPRSIZE(sp), r5
|
| 120 |
|
|
l.sw 6 * OR1K_GPRSIZE(sp), r6
|
| 121 |
|
|
l.sw 7 * OR1K_GPRSIZE(sp), r7
|
| 122 |
|
|
l.sw 8 * OR1K_GPRSIZE(sp), r8
|
| 123 |
|
|
l.sw 9 * OR1K_GPRSIZE(sp), r9
|
| 124 |
|
|
l.sw 11 * OR1K_GPRSIZE(sp), r11
|
| 125 |
790 |
skrzyp |
l.sw 12 * OR1K_GPRSIZE(sp), r12
|
| 126 |
786 |
skrzyp |
l.sw 13 * OR1K_GPRSIZE(sp), r13
|
| 127 |
|
|
l.sw 15 * OR1K_GPRSIZE(sp), r15
|
| 128 |
|
|
l.sw 17 * OR1K_GPRSIZE(sp), r17
|
| 129 |
|
|
l.sw 19 * OR1K_GPRSIZE(sp), r19
|
| 130 |
|
|
l.sw 21 * OR1K_GPRSIZE(sp), r21
|
| 131 |
|
|
l.sw 23 * OR1K_GPRSIZE(sp), r23
|
| 132 |
|
|
l.sw 25 * OR1K_GPRSIZE(sp), r25
|
| 133 |
|
|
l.sw 27 * OR1K_GPRSIZE(sp), r27
|
| 134 |
|
|
l.sw 29 * OR1K_GPRSIZE(sp), r29
|
| 135 |
|
|
l.sw 31 * OR1K_GPRSIZE(sp), r31
|
| 136 |
|
|
|
| 137 |
|
|
#ifndef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
|
| 138 |
|
|
|
| 139 |
|
|
# R0 is not typically stored because it is always zero-valued,
|
| 140 |
|
|
# but we store it here for consistency when examining registers
|
| 141 |
|
|
# in the debugger.
|
| 142 |
|
|
l.sw 0 * OR1K_GPRSIZE(sp), r0
|
| 143 |
|
|
|
| 144 |
|
|
# Callee-saved regs don't need to be preserved across a call into
|
| 145 |
|
|
# an ISR, but we can do so to make debugging easier.
|
| 146 |
|
|
l.sw 2 * OR1K_GPRSIZE(sp), r2
|
| 147 |
|
|
l.sw 10 * OR1K_GPRSIZE(sp), r10
|
| 148 |
|
|
l.sw 14 * OR1K_GPRSIZE(sp), r14
|
| 149 |
|
|
l.sw 16 * OR1K_GPRSIZE(sp), r16
|
| 150 |
|
|
l.sw 18 * OR1K_GPRSIZE(sp), r18
|
| 151 |
|
|
l.sw 20 * OR1K_GPRSIZE(sp), r20
|
| 152 |
|
|
l.sw 22 * OR1K_GPRSIZE(sp), r22
|
| 153 |
|
|
l.sw 24 * OR1K_GPRSIZE(sp), r24
|
| 154 |
|
|
l.sw 26 * OR1K_GPRSIZE(sp), r26
|
| 155 |
|
|
l.sw 28 * OR1K_GPRSIZE(sp), r28
|
| 156 |
|
|
l.sw 30 * OR1K_GPRSIZE(sp), r30
|
| 157 |
|
|
|
| 158 |
790 |
skrzyp |
#endif
|
| 159 |
786 |
skrzyp |
# save MAC LO and HI regs
|
| 160 |
|
|
l.mfspr r5,r0,SPR_MACLO
|
| 161 |
|
|
l.sw OR1KREG_MACLO(sp),r5
|
| 162 |
|
|
l.mfspr r5,r0,SPR_MACHI
|
| 163 |
|
|
l.sw OR1KREG_MACHI(sp),r5
|
| 164 |
|
|
|
| 165 |
|
|
# Save SP of interruptee in reg dump
|
| 166 |
|
|
l.addi r5,sp,SIZEOF_OR1KREGS+132
|
| 167 |
|
|
l.sw 1 * OR1K_GPRSIZE(sp),r5
|
| 168 |
|
|
|
| 169 |
|
|
# ...and the PC
|
| 170 |
|
|
l.mfspr r5,r0,SPR_EPCR_BASE
|
| 171 |
|
|
l.sw OR1KREG_PC(sp),r5
|
| 172 |
|
|
|
| 173 |
|
|
# ... and the Supervisor Register
|
| 174 |
|
|
l.mfspr r5,r0,SPR_ESR_BASE
|
| 175 |
|
|
l.sw OR1KREG_SR(sp),r5
|
| 176 |
|
|
|
| 177 |
|
|
# ... and the exception's effective address, if there is one.
|
| 178 |
|
|
# FIXME - don't need to do this for some exceptions
|
| 179 |
|
|
l.mfspr r5,r0,SPR_EEAR_BASE
|
| 180 |
|
|
l.sw OR1KREG_EEAR(sp),r5
|
| 181 |
|
|
|
| 182 |
|
|
# Second arg to VSR is exception number
|
| 183 |
|
|
# First vector is located at 0x100, second at 0x200, etc.
|
| 184 |
|
|
# Shift right to get vector number for address lookup.
|
| 185 |
|
|
l.ori r4,r0,(\org>>8)
|
| 186 |
|
|
l.sw OR1KREG_VECTOR(sp),r4
|
| 187 |
|
|
|
| 188 |
|
|
# Lookup address of VSR in table and jump to it
|
| 189 |
|
|
# Arg 0: Pointer to HAL_SavedRegisters struct
|
| 190 |
|
|
# Arg 1: Vector #
|
| 191 |
|
|
load32i r5,hal_vsr_table+(\org>>6)
|
| 192 |
|
|
l.lwz r5,0(r5)
|
| 193 |
|
|
l.jr r5 # To the VSR, Batman
|
| 194 |
|
|
|
| 195 |
|
|
# First arg to VSR is SP
|
| 196 |
|
|
l.or r3,r0,sp # Delay slot
|
| 197 |
|
|
|
| 198 |
|
|
.endm
|
| 199 |
|
|
|
| 200 |
|
|
#---------------------------------------------------------------------------
|
| 201 |
|
|
# Define the exception vectors.
|
| 202 |
|
|
|
| 203 |
|
|
rom_vectors:
|
| 204 |
|
|
# These are the architecture-defined vectors that
|
| 205 |
|
|
# are always present.
|
| 206 |
|
|
|
| 207 |
|
|
reset_vector reset 0x100
|
| 208 |
|
|
exception_vector bus_error 0x200
|
| 209 |
|
|
exception_vector data_page_fault 0x300
|
| 210 |
|
|
exception_vector instruction_page_fault 0x400
|
| 211 |
|
|
exception_vector tick_timer 0x500
|
| 212 |
|
|
exception_vector unaligned_access 0x600
|
| 213 |
|
|
exception_vector illegal_instruction 0x700
|
| 214 |
|
|
exception_vector external_interrupt 0x800
|
| 215 |
|
|
exception_vector dtlb_miss 0x900
|
| 216 |
|
|
exception_vector itlb_miss 0xa00
|
| 217 |
|
|
exception_vector range 0xb00
|
| 218 |
|
|
exception_vector syscall 0xc00
|
| 219 |
|
|
exception_vector reserved 0xd00
|
| 220 |
|
|
exception_vector trap 0xe00
|
| 221 |
|
|
|
| 222 |
|
|
rom_vectors_end:
|
| 223 |
|
|
|
| 224 |
|
|
|
| 225 |
|
|
#if (defined(CYG_HAL_STARTUP_ROM)) || \
|
| 226 |
|
|
(defined(CYG_HAL_STARTUP_RAM) && !defined(CYGSEM_HAL_USE_ROM_MONITOR)) || \
|
| 227 |
|
|
(defined(CYG_HAL_STARTUP_JTAG) && !defined(CYGSEM_HAL_USE_ROM_MONITOR))
|
| 228 |
|
|
|
| 229 |
|
|
.macro hal_vsr_table_init
|
| 230 |
|
|
|
| 231 |
|
|
# Next initialize the VSR table. This happens whether the
|
| 232 |
|
|
# vectors were copied to RAM or not.
|
| 233 |
|
|
|
| 234 |
|
|
# First fill with exception handlers
|
| 235 |
|
|
load32i r3,cyg_hal_default_exception_vsr
|
| 236 |
|
|
load32i r4,hal_vsr_table+4 # First entry in table is unused
|
| 237 |
|
|
l.ori r5,r0,CYGNUM_HAL_VSR_COUNT
|
| 238 |
|
|
1: l.sw 0(r4),r3
|
| 239 |
|
|
l.addi r5,r5,-1
|
| 240 |
|
|
l.sfgtsi r5,0
|
| 241 |
|
|
l.bf 1b
|
| 242 |
|
|
l.addi r4,r4,4 # delay slot
|
| 243 |
|
|
|
| 244 |
|
|
# Then fill in the interrupt handlers
|
| 245 |
|
|
load32i r4,hal_vsr_table
|
| 246 |
|
|
load32i r3,cyg_hal_default_interrupt_vsr
|
| 247 |
|
|
l.sw CYGNUM_HAL_VECTOR_INTERRUPT*4(r4),r3
|
| 248 |
|
|
l.sw CYGNUM_HAL_VECTOR_TICK_TIMER*4(r4),r3
|
| 249 |
|
|
.endm
|
| 250 |
|
|
|
| 251 |
|
|
#elif (defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)) || \
|
| 252 |
|
|
(defined(CYG_HAL_STARTUP_JTAG) && defined(CYGSEM_HAL_USE_ROM_MONITOR))
|
| 253 |
|
|
|
| 254 |
|
|
# Initialize the VSR table entries
|
| 255 |
|
|
# We only take control of the interrupt vectors,
|
| 256 |
|
|
# the rest are left to the ROM for now...
|
| 257 |
|
|
|
| 258 |
|
|
.macro hal_vsr_table_init
|
| 259 |
|
|
load32i r4,hal_vsr_table
|
| 260 |
|
|
load32i r3,cyg_hal_default_interrupt_vsr
|
| 261 |
|
|
l.sw CYGNUM_HAL_VECTOR_INTERRUPT*4(r4),r3
|
| 262 |
|
|
l.sw CYGNUM_HAL_VECTOR_TICK_TIMER*4(r4),r3
|
| 263 |
|
|
.endm
|
| 264 |
|
|
|
| 265 |
|
|
|
| 266 |
|
|
#else
|
| 267 |
|
|
|
| 268 |
|
|
#error "Need to define hal_vsr_table_init"
|
| 269 |
|
|
|
| 270 |
|
|
#endif
|
| 271 |
|
|
|
| 272 |
|
|
# I-Cache initialization macro
|
| 273 |
|
|
.macro hal_icache_init
|
| 274 |
|
|
/* Disable I-Cache */
|
| 275 |
|
|
l.mfspr r13,r0,SPR_SR
|
| 276 |
|
|
l.addi r11,r0,-1
|
| 277 |
|
|
l.xori r11,r11,SPR_SR_ICE
|
| 278 |
|
|
l.and r11,r13,r11
|
| 279 |
|
|
l.mtspr r0,r11,SPR_SR
|
| 280 |
|
|
|
| 281 |
|
|
/* Invalidate I-Cache */
|
| 282 |
|
|
l.addi r13,r0,0
|
| 283 |
|
|
l.addi r11,r0,HAL_ICACHE_SIZE
|
| 284 |
|
|
1:
|
| 285 |
|
|
l.mtspr r0,r13,SPR_ICBIR
|
| 286 |
|
|
l.sfne r13,r11
|
| 287 |
|
|
l.bf 1b
|
| 288 |
|
|
l.addi r13,r13,HAL_ICACHE_LINE_SIZE
|
| 289 |
|
|
|
| 290 |
|
|
/* Enable I-Cache */
|
| 291 |
|
|
l.mfspr r13,r0,SPR_SR
|
| 292 |
|
|
l.ori r13,r13,SPR_SR_ICE
|
| 293 |
|
|
l.mtspr r0,r13,SPR_SR
|
| 294 |
|
|
|
| 295 |
|
|
/* Flush instructions out of instruction buffer */
|
| 296 |
|
|
l.nop
|
| 297 |
|
|
l.nop
|
| 298 |
|
|
l.nop
|
| 299 |
|
|
l.nop
|
| 300 |
|
|
l.nop
|
| 301 |
|
|
.endm
|
| 302 |
|
|
|
| 303 |
|
|
# D-Cache initialization macro
|
| 304 |
|
|
.macro hal_dcache_init
|
| 305 |
|
|
|
| 306 |
|
|
/* Flush DC */
|
| 307 |
|
|
l.addi r10,r0,0
|
| 308 |
|
|
l.addi r11,r0,HAL_DCACHE_SIZE
|
| 309 |
|
|
1:
|
| 310 |
|
|
l.mtspr r0,r10,SPR_DCBIR
|
| 311 |
|
|
l.sfne r10,r11
|
| 312 |
|
|
l.bf 1b
|
| 313 |
|
|
l.addi r10,r10,HAL_DCACHE_LINE_SIZE
|
| 314 |
|
|
|
| 315 |
|
|
/* Enable DC */
|
| 316 |
|
|
l.mfspr r10,r0,SPR_SR
|
| 317 |
|
|
l.ori r10,r10,SPR_SR_DCE
|
| 318 |
|
|
l.mtspr r0,r10,SPR_SR
|
| 319 |
|
|
.endm
|
| 320 |
|
|
|
| 321 |
|
|
#===========================================================================
|
| 322 |
|
|
# Startup code: We jump here from the reset vector to set up the world.
|
| 323 |
|
|
|
| 324 |
|
|
.text
|
| 325 |
|
|
|
| 326 |
|
|
FUNC_START(start)
|
| 327 |
|
|
|
| 328 |
|
|
# Initialize Supervision Register:
|
| 329 |
|
|
# Supervisor mode on, all interrupts off, caches off
|
| 330 |
|
|
#
|
| 331 |
|
|
# (If we've entered here from a hardware reset, then the SR is already
|
| 332 |
|
|
# set to this value, but we may have jumped here as part of a soft
|
| 333 |
|
|
# system reset.)
|
| 334 |
|
|
l.ori r3,r0,SPR_SR_SM
|
| 335 |
|
|
l.mtspr r0,r3,SPR_SR
|
| 336 |
|
|
|
| 337 |
|
|
# Run platform-specific hardware initialization code.
|
| 338 |
|
|
# This may include memory controller initialization.
|
| 339 |
|
|
# Hence, it is not safe to access RAM until after this point.
|
| 340 |
|
|
#hal_hardware_init
|
| 341 |
|
|
|
| 342 |
791 |
skrzyp |
#if defined(CYGSEM_HAL_ENABLE_ICACHE_ON_STARTUP) && defined(HAL_ICACHE_SIZE)
|
| 343 |
786 |
skrzyp |
# Enable I-Cache
|
| 344 |
|
|
hal_icache_init
|
| 345 |
|
|
#endif
|
| 346 |
|
|
|
| 347 |
791 |
skrzyp |
#if defined(CYGSEM_HAL_ENABLE_DCACHE_ON_STARTUP) && defined(HAL_DCACHE_SIZE)
|
| 348 |
786 |
skrzyp |
# Enable D-Cache
|
| 349 |
|
|
hal_dcache_init
|
| 350 |
|
|
#endif
|
| 351 |
|
|
|
| 352 |
|
|
# Start the tick timer, in case timer polling routine hal_delay_us() is called.
|
| 353 |
|
|
# Initially, no interrupts are generated by the tick timer. Later on, that
|
| 354 |
|
|
# may change when the kernel is initialized.
|
| 355 |
|
|
l.movhi r3, hi(0x40000000|CYGNUM_HAL_RTC_PERIOD)
|
| 356 |
|
|
l.ori r3, r3, lo(CYGNUM_HAL_RTC_PERIOD)
|
| 357 |
|
|
l.mtspr r0,r3, SPR_TTMR
|
| 358 |
|
|
|
| 359 |
|
|
.globl hal_hardware_init_done
|
| 360 |
|
|
hal_hardware_init_done:
|
| 361 |
|
|
|
| 362 |
|
|
# set up stack
|
| 363 |
|
|
load32i sp,__interrupt_stack
|
| 364 |
|
|
|
| 365 |
|
|
# Make a dummy frame on the stack, so that stack backtraces are sane
|
| 366 |
|
|
# for debugging. On return from that function, the restore_state()
|
| 367 |
|
|
# function is called to resume the interrupted thread.
|
| 368 |
|
|
l.addi sp,sp,-8
|
| 369 |
|
|
l.sw 4(sp),r0 # Dummy saved FP
|
| 370 |
|
|
l.sw 0(sp),r0 # Dummy saved LR
|
| 371 |
|
|
|
| 372 |
|
|
# Set up exception handlers and VSR table, taking care not to
|
| 373 |
|
|
# step on any ROM monitor VSRs.
|
| 374 |
|
|
hal_vsr_table_init
|
| 375 |
|
|
|
| 376 |
|
|
#if defined(CYG_HAL_STARTUP_ROM)
|
| 377 |
|
|
# Copy exception/interrupt vectors from ROM to address 0x100
|
| 378 |
|
|
load32i r4,0x100
|
| 379 |
|
|
load32i r3,rom_vectors
|
| 380 |
|
|
load32i r5,rom_vectors_end
|
| 381 |
|
|
1: l.sfeq r3,r5
|
| 382 |
|
|
l.bf 2f
|
| 383 |
|
|
l.lwz r6,0(r3)
|
| 384 |
|
|
l.sw 0(r4),r6
|
| 385 |
|
|
l.addi r3,r3,4
|
| 386 |
|
|
l.j 1b
|
| 387 |
|
|
l.addi r4,r4,4 # delay slot
|
| 388 |
|
|
2:
|
| 389 |
|
|
|
| 390 |
|
|
# Copy .data section into RAM
|
| 391 |
|
|
load32i r3,__rom_data_start
|
| 392 |
|
|
load32i r4,__ram_data_start
|
| 393 |
|
|
load32i r5,__ram_data_end
|
| 394 |
|
|
1: l.sfeq r4,r5
|
| 395 |
|
|
l.bf 2f
|
| 396 |
|
|
l.lwz r6,0(r3)
|
| 397 |
|
|
l.sw 0(r4),r6
|
| 398 |
|
|
l.addi r3,r3,4
|
| 399 |
|
|
l.j 1b
|
| 400 |
|
|
l.addi r4,r4,4 # delay slot
|
| 401 |
|
|
2:
|
| 402 |
|
|
|
| 403 |
|
|
#endif
|
| 404 |
|
|
|
| 405 |
|
|
# clear BSS
|
| 406 |
|
|
load32i r4,__bss_start
|
| 407 |
|
|
load32i r5,__bss_end
|
| 408 |
|
|
1: l.sfeq r4,r5
|
| 409 |
|
|
l.bf 2f
|
| 410 |
|
|
l.nop
|
| 411 |
|
|
l.sw 0(r4),r0
|
| 412 |
|
|
l.j 1b
|
| 413 |
|
|
l.addi r4,r4,4
|
| 414 |
|
|
2:
|
| 415 |
|
|
|
| 416 |
|
|
# Note: no SBSS section to clear with OpenRISC target
|
| 417 |
|
|
|
| 418 |
|
|
# Platform-specific initialization
|
| 419 |
|
|
l.jal hal_platform_init
|
| 420 |
|
|
l.nop # delay slot
|
| 421 |
|
|
|
| 422 |
|
|
# call c++ constructors
|
| 423 |
|
|
l.jal cyg_hal_invoke_constructors
|
| 424 |
|
|
l.nop # delay slot
|
| 425 |
|
|
|
| 426 |
|
|
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
|
| 427 |
791 |
skrzyp |
l.jal initialize_stub
|
| 428 |
786 |
skrzyp |
l.nop # delay slot
|
| 429 |
|
|
#endif
|
| 430 |
|
|
|
| 431 |
|
|
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) \
|
| 432 |
|
|
|| defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
|
| 433 |
|
|
.extern hal_ctrlc_isr_init
|
| 434 |
|
|
l.jal hal_ctrlc_isr_init
|
| 435 |
|
|
l.nop # delay slot
|
| 436 |
|
|
#endif
|
| 437 |
|
|
|
| 438 |
|
|
l.jal cyg_start # call cyg_start()
|
| 439 |
|
|
l.nop # delay slot
|
| 440 |
|
|
9:
|
| 441 |
|
|
l.j 9b # if we return, loop
|
| 442 |
|
|
l.nop # delay slot
|
| 443 |
|
|
|
| 444 |
|
|
FUNC_END(start)
|
| 445 |
|
|
|
| 446 |
|
|
#---------------------------------------------------------------------------
|
| 447 |
|
|
# This code handles the common part of all exception handlers.
|
| 448 |
|
|
# On entry, the machine state is already saved on the stack.
|
| 449 |
|
|
#
|
| 450 |
|
|
# R3 = pointer to HAL_SavedRegisters struct containing saved machine state
|
| 451 |
|
|
# R4 = Vector number
|
| 452 |
|
|
#
|
| 453 |
|
|
# It calls a C routine to do any work, which may result in
|
| 454 |
|
|
# thread switches and changes to the saved state. When we return
|
| 455 |
|
|
# here, the saved state is restored and execution is continued.
|
| 456 |
|
|
|
| 457 |
|
|
.text
|
| 458 |
|
|
|
| 459 |
|
|
FUNC_START(cyg_hal_default_exception_vsr)
|
| 460 |
|
|
|
| 461 |
|
|
.extern cyg_hal_exception_handler
|
| 462 |
|
|
|
| 463 |
|
|
# Call C code
|
| 464 |
|
|
|
| 465 |
|
|
# When cyg_hal_exception_handler() returns, it will jump
|
| 466 |
|
|
# directly to restore_state(), which will resume execution
|
| 467 |
|
|
# at the location of the exception.
|
| 468 |
|
|
l.movhi r9, hi(restore_state)
|
| 469 |
|
|
l.j cyg_hal_exception_handler
|
| 470 |
|
|
l.ori r9,r9,lo(restore_state) #Delay slot
|
| 471 |
|
|
|
| 472 |
|
|
# Control never reaches this point,
|
| 473 |
|
|
|
| 474 |
|
|
FUNC_END(cyg_hal_default_exception_vsr)
|
| 475 |
|
|
|
| 476 |
|
|
#---------------------------------------------------------------------------
|
| 477 |
|
|
# This code handles all interrupts and dispatches to a C ISR function
|
| 478 |
|
|
# On entry, the machine state is already saved on the stack.
|
| 479 |
|
|
#
|
| 480 |
|
|
# R3 = pointer to HAL_SavedRegisters struct containing saved machine state
|
| 481 |
|
|
# R4 = Vector number
|
| 482 |
|
|
#
|
| 483 |
|
|
# After we return here, the saved state is restored and execution is continued.
|
| 484 |
|
|
|
| 485 |
|
|
#ifdef CYGIMP_FORCE_INTERRUPT_HANDLING_CODE_IN_RAM
|
| 486 |
|
|
.section .text.ram,"ax"
|
| 487 |
|
|
#else
|
| 488 |
|
|
.section .text,"ax"
|
| 489 |
|
|
#endif
|
| 490 |
|
|
|
| 491 |
|
|
FUNC_START(cyg_hal_default_interrupt_vsr)
|
| 492 |
|
|
|
| 493 |
|
|
# Stash away pointer to saved regs for later
|
| 494 |
|
|
l.or r31,r3,r3
|
| 495 |
|
|
|
| 496 |
|
|
# Set scheduler lock to prevent thread rescheduling while the ISR runs
|
| 497 |
|
|
#ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
|
| 498 |
|
|
.extern cyg_scheduler_sched_lock
|
| 499 |
|
|
load32i r5, cyg_scheduler_sched_lock
|
| 500 |
|
|
l.lwz r6,0(r5)
|
| 501 |
|
|
l.addi r6,r6,1
|
| 502 |
|
|
l.sw 0(r5),r6
|
| 503 |
|
|
#endif
|
| 504 |
|
|
|
| 505 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
|
| 506 |
|
|
# Interrupts execute on their own dedicated stack.
|
| 507 |
|
|
# If we're on a thread stack, switch to the interrupt stack.
|
| 508 |
|
|
# If we're called inside a nested interrupt, do nothing.
|
| 509 |
|
|
l.or r6,sp,sp # Stash SP for later
|
| 510 |
|
|
load32i r7,__interrupt_stack # stack top (highest addr + 1)
|
| 511 |
|
|
load32i r8,__interrupt_stack_base # stack base (lowest addr)
|
| 512 |
|
|
l.sfltu sp,r8 # if (sp < __interrupt_stack_base)
|
| 513 |
|
|
l.bf 1f # switch to interrupt stack
|
| 514 |
|
|
l.sfltu sp,r7 # if (sp < __interrupt_stack_top)
|
| 515 |
|
|
l.bf 2f # already on interrupt stack
|
| 516 |
|
|
l.nop # delay slot
|
| 517 |
|
|
1: l.or sp,r7,r7 # Switch to interrupt stack
|
| 518 |
|
|
2: l.addi sp,sp,-8 # Make space to save old SP...
|
| 519 |
|
|
l.sw 0(sp),r6 # ...and save it on the stack
|
| 520 |
|
|
#endif
|
| 521 |
|
|
|
| 522 |
|
|
# Call C code
|
| 523 |
|
|
|
| 524 |
|
|
#if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR)
|
| 525 |
|
|
# Log the interrupt if kernel tracing is enabled
|
| 526 |
|
|
l.ori r3,r0,0x0301 # arg1 = type = INTR,RAISE
|
| 527 |
|
|
# arg2 = vector number
|
| 528 |
|
|
l.ori r5,r0,r0 # arg3 = 0
|
| 529 |
|
|
l.jal _cyg_instrument # call instrument function
|
| 530 |
|
|
|
| 531 |
|
|
#endif
|
| 532 |
|
|
|
| 533 |
|
|
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) \
|
| 534 |
|
|
|| defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
|
| 535 |
|
|
# If we are supporting Ctrl-C interrupts from GDB, we must squirrel
|
| 536 |
|
|
# away a pointer to the save interrupt state here so that we can
|
| 537 |
|
|
# plant a breakpoint at some later time.
|
| 538 |
|
|
|
| 539 |
|
|
.extern hal_saved_interrupt_state
|
| 540 |
|
|
load32i r8,hal_saved_interrupt_state
|
| 541 |
|
|
l.sw 0(r8),r31
|
| 542 |
|
|
|
| 543 |
|
|
#endif
|
| 544 |
|
|
|
| 545 |
|
|
# In the event of multiple pending interrupts, determine which
|
| 546 |
|
|
# one will be serviced first. By software convention, the lowest
|
| 547 |
|
|
# numbered external interrupt gets priority.
|
| 548 |
|
|
#
|
| 549 |
|
|
# The (internal) tick timer interrupt is serviced only if no
|
| 550 |
|
|
# external interrupts are pending.
|
| 551 |
|
|
|
| 552 |
|
|
# Read the PIC interrupt controller's status register
|
| 553 |
|
|
l.mfspr r9,r0,SPR_PICSR
|
| 554 |
|
|
|
| 555 |
|
|
# Any pending external interrupts ?
|
| 556 |
|
|
l.sfnei r9,0
|
| 557 |
|
|
l.bf check_for_external_interrupts
|
| 558 |
|
|
|
| 559 |
|
|
# Theoretically, the only way we could get here is if the tick timer
|
| 560 |
|
|
# interrupt fired, but we check to be sure that's what happened.
|
| 561 |
|
|
l.sfeqi r4,CYGNUM_HAL_VECTOR_TICK_TIMER
|
| 562 |
|
|
l.bf 3f
|
| 563 |
|
|
l.ori r3,r0,CYGNUM_HAL_INTERRUPT_RTC # delay slot
|
| 564 |
|
|
|
| 565 |
|
|
#ifndef CYGIMP_HAL_COMMON_INTERRUPTS_IGNORE_SPURIOUS
|
| 566 |
|
|
l.jal hal_spurious_IRQ
|
| 567 |
|
|
l.nop
|
| 568 |
|
|
#endif // CYGIMP_HAL_COMMON_INTERRUPTS_IGNORE_SPURIOUS
|
| 569 |
|
|
l.j ignore_spurious_interrupt
|
| 570 |
|
|
|
| 571 |
|
|
# Identify the lowest numbered interrupt bit in the PIC's PSR,
|
| 572 |
|
|
# numbering the MSB as 31 and the LSB as 0
|
| 573 |
|
|
check_for_external_interrupts:
|
| 574 |
|
|
l.ori r3,r0,0
|
| 575 |
|
|
2: l.andi r11,r9,1 # Test low bit
|
| 576 |
|
|
l.sfnei r11,0
|
| 577 |
|
|
l.bf 3f
|
| 578 |
|
|
l.srli r9,r9,1 # Shift right 1 bit
|
| 579 |
|
|
l.j 2b
|
| 580 |
|
|
l.addi r3,r3,1 # Delay slot
|
| 581 |
|
|
3:
|
| 582 |
|
|
|
| 583 |
|
|
# At this point, r3 contains the ISR number, from 0-32
|
| 584 |
|
|
# which will be used to index the table of ISRs
|
| 585 |
|
|
l.slli r15,r3,2
|
| 586 |
|
|
load32i r9, hal_interrupt_handlers # get interrupt handler table
|
| 587 |
|
|
l.add r9,r9,r15
|
| 588 |
|
|
l.lwz r11,0(r9) # load ISR pointer
|
| 589 |
|
|
load32i r9, hal_interrupt_data # get interrupt data table
|
| 590 |
|
|
l.add r9,r9,r15
|
| 591 |
|
|
l.lwz r4,0(r9) # load data arg to ISR
|
| 592 |
|
|
|
| 593 |
|
|
# Call ISR
|
| 594 |
|
|
# arg0 = ISR #
|
| 595 |
|
|
# arg1 = data arg associated with interrupt
|
| 596 |
|
|
l.jalr r11
|
| 597 |
|
|
l.nop
|
| 598 |
|
|
|
| 599 |
|
|
ignore_spurious_interrupt:
|
| 600 |
|
|
|
| 601 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
|
| 602 |
|
|
|
| 603 |
|
|
# If we are returning from the last nested interrupt, move back
|
| 604 |
|
|
# to the thread stack. interrupt_end() must be called on the
|
| 605 |
|
|
# thread stack since it potentially causes a context switch.
|
| 606 |
|
|
# Since we have arranged for the top of stack location to
|
| 607 |
|
|
# contain the sp we need to go back to here, just pop it off
|
| 608 |
|
|
# and put it in SP.
|
| 609 |
|
|
|
| 610 |
|
|
l.lwz sp,0(sp)
|
| 611 |
|
|
#endif
|
| 612 |
|
|
|
| 613 |
|
|
#ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
|
| 614 |
|
|
|
| 615 |
|
|
# We only need to call _interrupt_end() when there is a kernel
|
| 616 |
|
|
# present to do any tidying up.
|
| 617 |
|
|
|
| 618 |
|
|
# on return r11 bit 1 will indicate whether a DSR is
|
| 619 |
|
|
# to be posted. Pass this together with a pointer to
|
| 620 |
|
|
# the interrupt object we have just used to the
|
| 621 |
|
|
# interrupt tidy up routine.
|
| 622 |
|
|
l.or r3,r11,r11
|
| 623 |
|
|
|
| 624 |
|
|
# Get pointer to HAL_SavedRegisters struct, stashed earlier
|
| 625 |
|
|
l.or r5,r31,r31
|
| 626 |
|
|
|
| 627 |
|
|
# Get opaque object associated w/ interrupt vector
|
| 628 |
|
|
load32i r9, hal_interrupt_objects # get interrupt data table
|
| 629 |
|
|
l.add r9,r9,r15
|
| 630 |
|
|
l.lwz r4,0(r9)
|
| 631 |
|
|
|
| 632 |
|
|
# Call interrupt_end() to execute any pending DSRs
|
| 633 |
|
|
# Arg 0 = return value from ISR
|
| 634 |
|
|
# Arg 1 = object associated with interrupt
|
| 635 |
|
|
# Arg 2 = HAL_SavedRegisters struct
|
| 636 |
|
|
|
| 637 |
|
|
.extern interrupt_end
|
| 638 |
|
|
l.jal interrupt_end # call into C to finish off
|
| 639 |
|
|
l.nop
|
| 640 |
|
|
#endif
|
| 641 |
|
|
|
| 642 |
|
|
# Fall through to restore_state...
|
| 643 |
|
|
|
| 644 |
|
|
# Return from either an interrupt or an exception
|
| 645 |
|
|
#
|
| 646 |
|
|
# On entry:
|
| 647 |
|
|
# SP = pointer to (HAL_SavedRegisters struct)
|
| 648 |
|
|
#
|
| 649 |
|
|
restore_state:
|
| 650 |
|
|
|
| 651 |
|
|
# Restore General Purpose Registers (GPRs).
|
| 652 |
|
|
# R0 is not restored because it is always zero-valued.
|
| 653 |
|
|
# R1, R3, and R4 are used as temps, so they are restored a little later
|
| 654 |
|
|
l.lwz r5, 5 * OR1K_GPRSIZE(sp)
|
| 655 |
|
|
l.lwz r6, 6 * OR1K_GPRSIZE(sp)
|
| 656 |
|
|
l.lwz r7, 7 * OR1K_GPRSIZE(sp)
|
| 657 |
|
|
l.lwz r8, 8 * OR1K_GPRSIZE(sp)
|
| 658 |
|
|
l.lwz r9, 9 * OR1K_GPRSIZE(sp)
|
| 659 |
|
|
l.lwz r11, 11 * OR1K_GPRSIZE(sp)
|
| 660 |
790 |
skrzyp |
l.lwz r12, 12 * OR1K_GPRSIZE(sp)
|
| 661 |
786 |
skrzyp |
l.lwz r13, 13 * OR1K_GPRSIZE(sp)
|
| 662 |
|
|
l.lwz r15, 15 * OR1K_GPRSIZE(sp)
|
| 663 |
|
|
l.lwz r17, 17 * OR1K_GPRSIZE(sp)
|
| 664 |
|
|
l.lwz r19, 19 * OR1K_GPRSIZE(sp)
|
| 665 |
|
|
l.lwz r21, 21 * OR1K_GPRSIZE(sp)
|
| 666 |
|
|
l.lwz r23, 23 * OR1K_GPRSIZE(sp)
|
| 667 |
|
|
l.lwz r25, 25 * OR1K_GPRSIZE(sp)
|
| 668 |
|
|
l.lwz r27, 27 * OR1K_GPRSIZE(sp)
|
| 669 |
|
|
l.lwz r29, 29 * OR1K_GPRSIZE(sp)
|
| 670 |
|
|
l.lwz r31, 31 * OR1K_GPRSIZE(sp)
|
| 671 |
|
|
|
| 672 |
|
|
#ifndef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
|
| 673 |
|
|
# Callee-saved regs don't need to be preserved across a call into
|
| 674 |
|
|
# an ISR, but we can do so to make debugging easier.
|
| 675 |
|
|
|
| 676 |
|
|
l.lwz r2, 2 * OR1K_GPRSIZE(sp)
|
| 677 |
|
|
l.lwz r10, 10 * OR1K_GPRSIZE(sp)
|
| 678 |
|
|
l.lwz r14, 14 * OR1K_GPRSIZE(sp)
|
| 679 |
|
|
l.lwz r16, 16 * OR1K_GPRSIZE(sp)
|
| 680 |
|
|
l.lwz r18, 18 * OR1K_GPRSIZE(sp)
|
| 681 |
|
|
l.lwz r20, 20 * OR1K_GPRSIZE(sp)
|
| 682 |
|
|
l.lwz r22, 22 * OR1K_GPRSIZE(sp)
|
| 683 |
|
|
l.lwz r24, 24 * OR1K_GPRSIZE(sp)
|
| 684 |
|
|
l.lwz r26, 26 * OR1K_GPRSIZE(sp)
|
| 685 |
|
|
l.lwz r28, 28 * OR1K_GPRSIZE(sp)
|
| 686 |
|
|
l.lwz r30, 30 * OR1K_GPRSIZE(sp)
|
| 687 |
|
|
|
| 688 |
790 |
skrzyp |
#endif
|
| 689 |
786 |
skrzyp |
# Restore MAC LO and HI regs
|
| 690 |
|
|
l.lwz r4, OR1KREG_MACLO(sp)
|
| 691 |
|
|
l.mtspr r0,r4,SPR_MACLO
|
| 692 |
|
|
l.lwz r4, OR1KREG_MACHI(sp)
|
| 693 |
|
|
l.mtspr r0,r4,SPR_MACHI
|
| 694 |
|
|
|
| 695 |
|
|
# Must disable interrupts, since they could clobber ESR and EPC regs
|
| 696 |
|
|
l.mfspr r3, r0, SPR_SR
|
| 697 |
|
|
load32i r4,~(SPR_SR_TEE|SPR_SR_IEE)
|
| 698 |
|
|
l.and r3, r4, r3
|
| 699 |
|
|
l.mtspr r0, r3, SPR_SR
|
| 700 |
|
|
|
| 701 |
|
|
# At this point we've restored all the pre-interrupt GPRs except for the SP.
|
| 702 |
|
|
# Restore pre-interrupt SR, SP, and PC
|
| 703 |
|
|
l.lwz r4, OR1KREG_SR(sp)
|
| 704 |
|
|
l.mtspr r0, r4, SPR_ESR_BASE
|
| 705 |
|
|
|
| 706 |
|
|
l.lwz r4, OR1KREG_PC(sp)
|
| 707 |
|
|
l.mtspr r0, r4, SPR_EPCR_BASE
|
| 708 |
|
|
|
| 709 |
|
|
l.lwz r4, 4 * OR1K_GPRSIZE(sp)
|
| 710 |
|
|
l.lwz r3, 3 * OR1K_GPRSIZE(sp)
|
| 711 |
|
|
l.lwz sp, 1 * OR1K_GPRSIZE(sp)
|
| 712 |
|
|
|
| 713 |
|
|
# All done, restore CPU state and continue
|
| 714 |
|
|
l.rfe
|
| 715 |
|
|
l.nop # Delay slot
|
| 716 |
|
|
|
| 717 |
|
|
|
| 718 |
|
|
##-----------------------------------------------------------------------------
|
| 719 |
|
|
## Execute pending DSRs on the interrupt stack with interrupts enabled.
|
| 720 |
|
|
## Note: this can only be called from code running on a thread stack
|
| 721 |
|
|
|
| 722 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
|
| 723 |
|
|
.extern cyg_interrupt_call_pending_DSRs
|
| 724 |
|
|
|
| 725 |
|
|
.text
|
| 726 |
|
|
FUNC_START(hal_interrupt_stack_call_pending_DSRs)
|
| 727 |
|
|
# Switch to interrupt stack
|
| 728 |
|
|
l.or r3, sp, sp # Stash entry SP
|
| 729 |
|
|
load32i sp, __interrupt_stack
|
| 730 |
|
|
l.addi sp, sp, -16
|
| 731 |
|
|
l.sw 0(sp), r3 # Save entry SP
|
| 732 |
|
|
l.mfspr r4,r0,SPR_SR
|
| 733 |
|
|
l.sw 4(sp), r4 # Save interrupt state
|
| 734 |
|
|
l.ori r4, r4, SPR_SR_IEE|SPR_SR_TEE
|
| 735 |
|
|
l.sw 8(sp),lr
|
| 736 |
|
|
|
| 737 |
|
|
l.jal cyg_interrupt_call_pending_DSRs
|
| 738 |
|
|
# Enable interrupts before calling DSRs
|
| 739 |
|
|
l.mtspr r0, r4, SPR_SR # Delay slot
|
| 740 |
|
|
|
| 741 |
|
|
l.lwz r4, 4(sp)
|
| 742 |
|
|
l.lwz lr, 8(sp)
|
| 743 |
|
|
l.lwz sp, 0(sp)
|
| 744 |
|
|
|
| 745 |
|
|
# Merge original interrupt state with (possibly altered) SR reg
|
| 746 |
|
|
l.andi r4, r4, SPR_SR_IEE|SPR_SR_TEE
|
| 747 |
|
|
l.mfspr r5, r0, SPR_SR
|
| 748 |
|
|
load32i r6, ~(SPR_SR_IEE|SPR_SR_TEE)
|
| 749 |
|
|
l.and r5, r5, r6
|
| 750 |
|
|
l.or r4, r4, r5
|
| 751 |
|
|
|
| 752 |
|
|
l.jr r9
|
| 753 |
|
|
l.mtspr r0, r4, SPR_SR # Delay slot
|
| 754 |
|
|
|
| 755 |
|
|
FUNC_END(hal_interrupt_stack_call_pending_DSRs)
|
| 756 |
|
|
#endif
|
| 757 |
|
|
|
| 758 |
|
|
##-----------------------------------------------------------------------------
|
| 759 |
|
|
## Switch to a new stack.
|
| 760 |
|
|
## This is used in RedBoot to allow code to execute in a different
|
| 761 |
|
|
## stack context.
|
| 762 |
|
|
|
| 763 |
|
|
FUNC_START(hal_program_new_stack)
|
| 764 |
|
|
# Arguments are:
|
| 765 |
|
|
# r3 = function to call
|
| 766 |
|
|
# r4 = stack pointer to use
|
| 767 |
|
|
|
| 768 |
|
|
# Dummy prologue, so that debugger is fooled into thinking there
|
| 769 |
|
|
# is a stack frame. The debugger will use the offsets in the prologue
|
| 770 |
|
|
# below to read the saved register values out of the *new* stack.
|
| 771 |
|
|
l.addi sp,sp,-8
|
| 772 |
|
|
l.sw 0(sp),fp
|
| 773 |
|
|
l.addi fp,sp,8
|
| 774 |
|
|
l.sw 4(sp),lr
|
| 775 |
|
|
|
| 776 |
|
|
l.or r5,sp,sp # Remember original SP
|
| 777 |
|
|
l.addi r6,fp,-8 # Remember original FP
|
| 778 |
|
|
l.or sp,r4,r4 # Switch to new stack
|
| 779 |
|
|
|
| 780 |
|
|
# "Real prologue" - Offsets here must match dummy prologue above
|
| 781 |
|
|
l.addi sp,sp,-16
|
| 782 |
|
|
l.sw 0(sp),r6 # So debugger can know caller's FP
|
| 783 |
|
|
l.sw 4(sp),lr # So debugger can know caller's PC
|
| 784 |
|
|
l.sw 8(sp),r5 # Save old SP on stack
|
| 785 |
|
|
|
| 786 |
|
|
# Call function
|
| 787 |
|
|
l.jalr r3
|
| 788 |
|
|
l.nop
|
| 789 |
|
|
|
| 790 |
|
|
l.lwz sp, 8(sp) # Restore original SP
|
| 791 |
|
|
l.lwz lr, 4(sp)
|
| 792 |
|
|
l.jr lr # Return to caller
|
| 793 |
|
|
l.addi sp,sp, 8 # Delay slot
|
| 794 |
|
|
|
| 795 |
|
|
FUNC_END(hal_program_new_stack)
|
| 796 |
|
|
|
| 797 |
|
|
#---------------------------------------------------------------------------
|
| 798 |
|
|
## Temporary interrupt stack
|
| 799 |
|
|
|
| 800 |
|
|
.section ".bss"
|
| 801 |
|
|
|
| 802 |
|
|
.balign 16
|
| 803 |
|
|
.global cyg_interrupt_stack_base
|
| 804 |
|
|
cyg_interrupt_stack_base:
|
| 805 |
|
|
__interrupt_stack_base:
|
| 806 |
|
|
.rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
|
| 807 |
|
|
.byte 0
|
| 808 |
|
|
.endr
|
| 809 |
|
|
.balign 16
|
| 810 |
|
|
.global cyg_interrupt_stack
|
| 811 |
|
|
cyg_interrupt_stack:
|
| 812 |
|
|
__interrupt_stack:
|
| 813 |
|
|
|
| 814 |
|
|
.long 0,0,0,0,0,0,0,0
|
| 815 |
|
|
|
| 816 |
|
|
#--------------------------------------
|
| 817 |
|
|
.data
|
| 818 |
|
|
.extern hal_default_isr
|
| 819 |
|
|
|
| 820 |
|
|
.globl hal_interrupt_handlers
|
| 821 |
|
|
hal_interrupt_handlers:
|
| 822 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
| 823 |
|
|
.long hal_default_isr
|
| 824 |
|
|
.endr
|
| 825 |
|
|
|
| 826 |
|
|
.globl hal_interrupt_data
|
| 827 |
|
|
hal_interrupt_data:
|
| 828 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
| 829 |
|
|
.long 0
|
| 830 |
|
|
.endr
|
| 831 |
|
|
|
| 832 |
|
|
.globl hal_interrupt_objects
|
| 833 |
|
|
hal_interrupt_objects:
|
| 834 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
| 835 |
|
|
.long 0
|
| 836 |
|
|
.endr
|
| 837 |
|
|
|
| 838 |
|
|
#---------------------------------------------------------------------------
|
| 839 |
|
|
# end of vectors.S
|