📄 windv.s
字号:
/* windv.S -- Register Window Overflow/Underflow Handlers * * This code is taken from example code in the Xtensa Microprocessor * Programmer's Guide. * * WARNING: It is highly unlikely that this code works as is on your * particular Xtensa processor configuration. It is hardcoded * for the specific processor configuration used for the * examples in the Xtensa Microprocessor Programmer's Guide. * (The example code did not use the Xtensa HAL to address this * portability issue, for clarity's sake.) Getting it to work * on another processor configuration requires some modifications. *//* * Copyright (c) 2003-2005 by Tensilica Inc. ALL RIGHTS RESERVED. * These coded instructions, statements, and computer programs are the * copyrighted works and confidential proprietary information of Tensilica Inc. * They may not be modified, copied, reproduced, distributed, or disclosed to * third parties in any manner, medium, or form, in whole or in part, without * the prior written consent of Tensilica Inc. */ .section .WindowVectors.text, "ax" .begin literal_prefix .WindowVectors .align 4// Exports.global _WindowOverflow4.global _WindowUnderflow4.global _WindowOverflow8.global _WindowUnderflow8.global _WindowOverflow12.global _WindowUnderflow12// Imports// None// NOTE: The underflow handler for returning from call[i+1] to call[i] must// preserve all the registers from call[i+1]'s window. a0 and a1 must be// preserved because the retw instruction will be reexecuted (and may even// underflow if an intervening exception has flushed call[i]'s registers).// Registers a2 and up may contain return values.// inside call[i] referencing a register that// contains data from call[j]// On entry here: window rotated to call[j] start point; the// registers to be saved are a0-a3; a4-a15 must be preserved// a5 is call[j+1]'s stack pointer .align 64_WindowOverflow4: addi a5, a5, -16 // to make store offsets positive s32i a0, a5, 0 // save a0 to call[j+1]'s stack frame s32i a1, a5, 4 // save a1 to call[j+1]'s stack frame s32i a2, a5, 8 // save a2 to call[j+1]'s stack frame s32i a3, a5, 12 // save a3 to call[j+1]'s stack frame addi a5, a5, 16 // restore a5 rfwo // rotates back to call[i] position// returning from call[i+1] to call[i] where// call[i]'s registers must be reloaded// On entry here: a0-a3 will be reloaded with// call[i].reg[0..3] but initially contain garbage.// a4-a15 are call[i+1].reg[0..11],// (in particular, a5 is call[i+1]'s stack pointer)// and must be preserved .align 64_WindowUnderflow4: addi a3, a5, -16 // to make load offsets positive l32i a0, a3, 0 // restore a0 from call[i+1]'s stack frame l32i a1, a3, 4 // restore a1 from call[i+1]'s stack frame l32i a2, a3, 8 // restore a2 from call[i+1]'s stack frame l32i a3, a3, 12 // restore a3 from call[i+1]'s stack frame rfwu// On entry here: window rotated to call[j]; the registers to be// saved are a0-a7; a8-a15 must be preserved// a9 is call[j+1]'s stack pointer .align 64_WindowOverflow8: addi a9, a9, -16 // to make store offsets positive s32i a0, a9, 0 // save a0 to call[j+1]'s stack frame s32i a1, a9, 4 // save a1 to call[j+1]'s stack frame s32i a2, a9, 8 // save a2 to call[j+1]'s stack frame s32i a3, a9, 12 // save a3 to call[j+1]'s stack frame addi a9, a9, 16 // restore a9 addi a0, a1, -16 // a0 <- call[j-1]'s sp l32i a0, a0, 4 // (used to find end of call[j]'s frame) addi a0, a0, -32 // to make load offsets positive s32i a4, a0, 0 // save a4 to call[j]'s stack frame s32i a5, a0, 4 // save a5 to call[j]'s stack frame s32i a6, a0, 8 // save a6 to call[j]'s stack frame s32i a7, a0, 12 // save a7 to call[j]'s stack frame rfwo // rotates back to call[i] position// On entry here: a0-a7 are call[i].reg[0..7] and initially// contain garbage, a8-a15 are call[i+1].reg[0..7],// (in particular, a9 is call[i+1]'s stack pointer)// and must be preserved .align 64_WindowUnderflow8: addi a9, a9, -16 // to make load offsets positive l32i a0, a9, 0 // restore a0 from call[i+1]'s stack frame l32i a1, a9, 4 // restore a1 from call[i+1]'s stack frame l32i a2, a9, 8 // restore a2 from call[i+1]'s stack frame // don't restore a3 yet because we need it as a temporary addi a3, a1, -16 // a3 <- call[i-1]'s sp l32i a3, a3, 4 // (used to find end of call[i]'s frame) addi a3, a3, -32 // to make load offsets positive l32i a4, a3, 0 // restore a4 from call[i]'s stack frame l32i a5, a3, 4 // restore a5 from call[i]'s stack frame l32i a6, a3, 8 // restore a6 from call[i]'s stack frame l32i a7, a3, 12 // restore a7 from call[i]'s stack frame // we're done with a3 and can restore it now l32i a3, a9, 12 // restore a3 from call[i+1]'s stack frame addi a9, a9, 16 // restore a9 rfwu// On entry here: window rotated to call[j]; the registers to be// saved are a0-a11 ; a12-a15 must be preserved// a13 is call[j+1]'s stack pointer .align 64_WindowOverflow12: addi a13, a13, -16 // to make store offsets positive s32i a0, a13, 0 // save a0 to call[j+1]'s stack frame s32i a1, a13, 4 // save a1 to call[j+1]'s stack frame s32i a2, a13, 8 // save a2 to call[j+1]'s stack frame s32i a3, a13, 12 // save a3 to call[j+1]'s stack frame addi a13, a13, 16 // restore a13 addi a0, a1, -16 // a0 <- call[j-1]'s sp l32i a0, a0, 4 // (used to find end of call[j]'s frame) addi a0, a0, -48 // to make load offsets positive s32i a4, a0, 0 // save a4 to end of call[j]'s stack frame s32i a5, a0, 4 // save a5 to end of call[j]'s stack frame s32i a6, a0, 8 // save a6 to end of call[j]'s stack frame s32i a7, a0, 12 // save a7 to end of call[j]'s stack frame s32i a8, a0, 16 // save a8 to end of call[j]'s stack frame s32i a9, a0, 20 // save a9 to end of call[j]'s stack frame s32i a10, a0, 24 // save a10 to end of call[j]'s stack frame s32i a11, a0, 28 // save a11 to end of call[j]'s stack frame rfwo // rotates back to call[i] position// On entry here:// a0-a11 are call[i].reg[0..11] and initially contain garbage// a12-a15 are call[i+1].reg[0..3], (in particular, a13 is call[i+1]'s stack pointer)// and must be preserved .align 64_WindowUnderflow12: addi a13, a13, -16 // to make load offsets positive l32i a0, a13, 0 // restore a0 from call[i+1]'s stack frame l32i a1, a13, 4 // restore a1 from call[i+1]'s stack frame l32i a2, a13, 8 // restore a2 from call[i+1]'s stack frame // don't restore a3 yet because we need it as a temporary addi a3, a1, -16 // a3 <- call[i-1]'s sp l32i a3, a3, 4 // (used to find end of call[i]'s frame) addi a3, a3, -48 // to make load offsets positive l32i a4, a3, 0 // restore a4 from end of call[i]'s stack frame l32i a5, a3, 4 // restore a5 from end of call[i]'s stack frame l32i a6, a3, 8 // restore a6 from end of call[i]'s stack frame l32i a7, a3, 12 // restore a7 from end of call[i]'s stack frame l32i a8, a3, 16 // restore a8 from end of call[i]'s stack frame l32i a9, a3, 20 // restore a9 from end of call[i]'s stack frame l32i a10, a3, 24 // restore a10 from end of call[i]'s stack frame l32i a11, a3, 28 // restore a11 from end of call[i]'s stack frame // we're done with a3 and can restore it now l32i a3, a13, 12 // restore a3 from call[i+1]'s stack frame addi a13, a13, 16 // restore a13 rfwu// .align 64 .end literal_prefix
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -