Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 2 | /* |
| 3 | * This file contains miscellaneous low-level functions. |
| 4 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 5 | * |
| 6 | * Largely rewritten by Cort Dougan (cort@cs.nmt.edu) |
| 7 | * and Paul Mackerras. |
| 8 | * |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 9 | * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com) |
| 10 | * |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 11 | * setjmp/longjmp code by Paul Mackerras. |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 12 | */ |
| 13 | #include <asm/ppc_asm.h> |
Stephen Rothwell | 94b146c | 2007-11-28 11:13:02 +1100 | [diff] [blame] | 14 | #include <asm/unistd.h> |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 15 | #include <asm/asm-compat.h> |
| 16 | #include <asm/asm-offsets.h> |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 17 | #include <asm/export.h> |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 18 | |
| 19 | .text |
| 20 | |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 21 | /* |
| 22 | * Returns (address we are running at) - (address we were linked at) |
| 23 | * for use before the text and data are mapped to KERNELBASE. |
Christophe Leroy | 0cc377d | 2018-04-17 13:23:10 +0200 | [diff] [blame] | 24 | |
| 25 | * add_reloc_offset(x) returns x + reloc_offset(). |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | _GLOBAL(reloc_offset) |
Christophe Leroy | 0cc377d | 2018-04-17 13:23:10 +0200 | [diff] [blame] | 29 | li r3, 0 |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 30 | _GLOBAL(add_reloc_offset) |
| 31 | mflr r0 |
| 32 | bl 1f |
| 33 | 1: mflr r5 |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame] | 34 | PPC_LL r4,(2f-1b)(r5) |
Stephen Rothwell | 127efeb | 2006-06-28 11:55:49 +1000 | [diff] [blame] | 35 | subf r5,r4,r5 |
| 36 | add r3,r3,r5 |
| 37 | mtlr r0 |
| 38 | blr |
Stephen Rothwell | 94b146c | 2007-11-28 11:13:02 +1100 | [diff] [blame] | 39 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame] | 40 | .align 3 |
| 41 | 2: PPC_LONG 1b |
| 42 | |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 43 | _GLOBAL(setjmp) |
| 44 | mflr r0 |
| 45 | PPC_STL r0,0(r3) |
| 46 | PPC_STL r1,SZL(r3) |
| 47 | PPC_STL r2,2*SZL(r3) |
Christophe Leroy | a1f3ae3 | 2018-04-17 19:08:18 +0200 | [diff] [blame] | 48 | #ifdef CONFIG_PPC32 |
| 49 | mfcr r12 |
| 50 | stmw r12, 3*SZL(r3) |
| 51 | #else |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 52 | mfcr r0 |
| 53 | PPC_STL r0,3*SZL(r3) |
| 54 | PPC_STL r13,4*SZL(r3) |
| 55 | PPC_STL r14,5*SZL(r3) |
| 56 | PPC_STL r15,6*SZL(r3) |
| 57 | PPC_STL r16,7*SZL(r3) |
| 58 | PPC_STL r17,8*SZL(r3) |
| 59 | PPC_STL r18,9*SZL(r3) |
| 60 | PPC_STL r19,10*SZL(r3) |
| 61 | PPC_STL r20,11*SZL(r3) |
| 62 | PPC_STL r21,12*SZL(r3) |
| 63 | PPC_STL r22,13*SZL(r3) |
| 64 | PPC_STL r23,14*SZL(r3) |
| 65 | PPC_STL r24,15*SZL(r3) |
| 66 | PPC_STL r25,16*SZL(r3) |
| 67 | PPC_STL r26,17*SZL(r3) |
| 68 | PPC_STL r27,18*SZL(r3) |
| 69 | PPC_STL r28,19*SZL(r3) |
| 70 | PPC_STL r29,20*SZL(r3) |
| 71 | PPC_STL r30,21*SZL(r3) |
| 72 | PPC_STL r31,22*SZL(r3) |
Christophe Leroy | a1f3ae3 | 2018-04-17 19:08:18 +0200 | [diff] [blame] | 73 | #endif |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 74 | li r3,0 |
| 75 | blr |
| 76 | |
| 77 | _GLOBAL(longjmp) |
Christophe Leroy | a1f3ae3 | 2018-04-17 19:08:18 +0200 | [diff] [blame] | 78 | #ifdef CONFIG_PPC32 |
| 79 | lmw r12, 3*SZL(r3) |
| 80 | mtcrf 0x38, r12 |
| 81 | #else |
Christophe Leroy | 24c7858 | 2018-04-17 19:08:16 +0200 | [diff] [blame] | 82 | PPC_LL r13,4*SZL(r3) |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 83 | PPC_LL r14,5*SZL(r3) |
| 84 | PPC_LL r15,6*SZL(r3) |
| 85 | PPC_LL r16,7*SZL(r3) |
| 86 | PPC_LL r17,8*SZL(r3) |
| 87 | PPC_LL r18,9*SZL(r3) |
| 88 | PPC_LL r19,10*SZL(r3) |
| 89 | PPC_LL r20,11*SZL(r3) |
| 90 | PPC_LL r21,12*SZL(r3) |
| 91 | PPC_LL r22,13*SZL(r3) |
| 92 | PPC_LL r23,14*SZL(r3) |
| 93 | PPC_LL r24,15*SZL(r3) |
| 94 | PPC_LL r25,16*SZL(r3) |
| 95 | PPC_LL r26,17*SZL(r3) |
| 96 | PPC_LL r27,18*SZL(r3) |
| 97 | PPC_LL r28,19*SZL(r3) |
| 98 | PPC_LL r29,20*SZL(r3) |
| 99 | PPC_LL r30,21*SZL(r3) |
| 100 | PPC_LL r31,22*SZL(r3) |
| 101 | PPC_LL r0,3*SZL(r3) |
| 102 | mtcrf 0x38,r0 |
Christophe Leroy | a1f3ae3 | 2018-04-17 19:08:18 +0200 | [diff] [blame] | 103 | #endif |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 104 | PPC_LL r0,0(r3) |
| 105 | PPC_LL r1,SZL(r3) |
| 106 | PPC_LL r2,2*SZL(r3) |
| 107 | mtlr r0 |
Christophe Leroy | 24c7858 | 2018-04-17 19:08:16 +0200 | [diff] [blame] | 108 | mr. r3, r4 |
| 109 | bnelr |
| 110 | li r3, 1 |
Michael Neuling | c3b75bd | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 111 | blr |
Anton Blanchard | bfe9a2c | 2014-10-13 19:41:38 +1100 | [diff] [blame] | 112 | |
Michael Ellerman | 3d13e83 | 2020-02-20 22:51:37 +1100 | [diff] [blame] | 113 | _GLOBAL(current_stack_frame) |
Anton Blanchard | bfe9a2c | 2014-10-13 19:41:38 +1100 | [diff] [blame] | 114 | PPC_LL r3,0(r1) |
| 115 | blr |
Michael Ellerman | 3d13e83 | 2020-02-20 22:51:37 +1100 | [diff] [blame] | 116 | EXPORT_SYMBOL(current_stack_frame) |