1/******************************************************************************* 2 * 3 * Copyright (c) 1993 Intel Corporation 4 * 5 * Intel hereby grants you permission to copy, modify, and distribute this 6 * software and its documentation. Intel grants this permission provided 7 * that the above copyright notice appears in all copies and that both the 8 * copyright notice and this permission notice appear in supporting 9 * documentation. In addition, Intel grants this permission provided that 10 * you prominently mark as "not part of the original" any modifications 11 * made to this software or documentation, and that the name of Intel 12 * Corporation not be used in advertising or publicity pertaining to 13 * distribution of the software or the documentation without specific, 14 * written prior permission. 15 * 16 * Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR 17 * IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY 18 * OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or 19 * representations regarding the use of, or the results of the use of, 20 * the software and documentation in terms of correctness, accuracy, 21 * reliability, currentness, or otherwise; and you rely on the software, 22 * documentation and results solely at your own risk. 23 * 24 * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS, 25 * LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES 26 * OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM 27 * PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER. 28 * 29 ******************************************************************************/ 30 31/******************************************************************************/ 32/* */ 33/* setjmp(), longjmp() */ 34/* */ 35/******************************************************************************/ 36 .file "setjmp.as" 37 .text 38 /* .link_pix */ 39 40 .align 4 41 .globl _setjmp 42_setjmp: 43 flushreg 44 andnot 0xf,pfp,g1 /* get pfp, mask out return status bits */ 45 st g1, 0x58(g0) /* save fp of caller*/ 46 /* save globals not killed by the calling convention */ 47 stq g8, 0x40(g0) /* save g8-g11*/ 48 st g12, 0x50(g0) /* save g12*/ 49 st g14, 0x54(g0) /* save g14*/ 50 /* save previous frame local registers */ 51 ldq (g1), g4 /* get previous frame pfp, sp, rip, r3 */ 52 stq g4, (g0) /* save pfp, sp, rip, r3 */ 53 ldq 0x10(g1), g4 /* get previous frame r4-r7 */ 54 stq g4, 0x10(g0) /* save r4-r7 */ 55 ldq 0x20(g1), g4 /* get previous frame r8-r11 */ 56 stq g4, 0x20(g0) /* save r8-r11 */ 57 ldq 0x30(g1), g4 /* get previous frame r12-r15 */ 58 stq g4, 0x30(g0) /* save r12-r15 */ 59 60 mov 0, g0 /* return 0 */ 61 ret 62 63 /* 64 * fake a return to the place that called the corresponding _setjmp 65 */ 66 .align 4 67 .globl _longjmp 68_longjmp: 69 call 0f /* ensure there is at least one stack frame */ 70 710: 72 flushreg /* do this before swapping stack */ 73 ld 0x58(g0), pfp /* get fp of caller of setjmp */ 74 /* restore local registers 75 * the following code modifies the frame of the function which originally 76 * called setjmp. 77 */ 78 ldq (g0), g4 /* get pfp, sp, rip, r3 */ 79 stq g4, (pfp) /* restore pfp, sp, rip, r3 */ 80 ldq 0x10(g0), g4 /* get r4-r7 */ 81 stq g4, 0x10(pfp) /* restore r4-r7 */ 82 ldq 0x20(g0), g4 /* get r8-r11 */ 83 stq g4, 0x20(pfp) /* restore r8-r11 */ 84 ldq 0x30(g0), g4 /* get r12-r15 */ 85 stq g4, 0x30(pfp) /* restore r12-r15 */ 86 /* restore global registers */ 87 ldq 0x40(g0), g8 /* get old g8-g11 values */ 88 ld 0x50(g0), g12 /* get old g12 value */ 89 ld 0x54(g0), g14 /* get old g14 value */ 90 91 mov g1, g0 /* get return value */ 92 cmpo g0, 0 /* make sure it is not zero */ 93 bne 0f 94 mov 1, g0 /* return 1 by default */ 950: 96 ret /* return to caller of _setjmp */ 97