Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * This file contains miscellaneous low-level functions.
0004  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
0005  *
0006  * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
0007  * and Paul Mackerras.
0008  *
0009  * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
0010  *
0011  * setjmp/longjmp code by Paul Mackerras.
0012  */
0013 #include <asm/ppc_asm.h>
0014 #include <asm/unistd.h>
0015 #include <asm/asm-compat.h>
0016 #include <asm/asm-offsets.h>
0017 #include <asm/export.h>
0018 
0019     .text
0020 
0021 /*
0022  * Returns (address we are running at) - (address we were linked at)
0023  * for use before the text and data are mapped to KERNELBASE.
0024 
0025  * add_reloc_offset(x) returns x + reloc_offset().
0026  */
0027 
0028 _GLOBAL(reloc_offset)
0029     li  r3, 0
0030 _GLOBAL(add_reloc_offset)
0031     mflr    r0
0032     bcl 20,31,$+4
0033 1:  mflr    r5
0034     PPC_LL  r4,(2f-1b)(r5)
0035     subf    r5,r4,r5
0036     add r3,r3,r5
0037     mtlr    r0
0038     blr
0039 _ASM_NOKPROBE_SYMBOL(reloc_offset)
0040 _ASM_NOKPROBE_SYMBOL(add_reloc_offset)
0041 
0042     .align  3
0043 2:  PPC_LONG 1b
0044 
0045 _GLOBAL(setjmp)
0046     mflr    r0
0047     PPC_STL r0,0(r3)
0048     PPC_STL r1,SZL(r3)
0049     PPC_STL r2,2*SZL(r3)
0050 #ifdef CONFIG_PPC32
0051     mfcr    r12
0052     stmw    r12, 3*SZL(r3)
0053 #else
0054     mfcr    r0
0055     PPC_STL r0,3*SZL(r3)
0056     PPC_STL r13,4*SZL(r3)
0057     PPC_STL r14,5*SZL(r3)
0058     PPC_STL r15,6*SZL(r3)
0059     PPC_STL r16,7*SZL(r3)
0060     PPC_STL r17,8*SZL(r3)
0061     PPC_STL r18,9*SZL(r3)
0062     PPC_STL r19,10*SZL(r3)
0063     PPC_STL r20,11*SZL(r3)
0064     PPC_STL r21,12*SZL(r3)
0065     PPC_STL r22,13*SZL(r3)
0066     PPC_STL r23,14*SZL(r3)
0067     PPC_STL r24,15*SZL(r3)
0068     PPC_STL r25,16*SZL(r3)
0069     PPC_STL r26,17*SZL(r3)
0070     PPC_STL r27,18*SZL(r3)
0071     PPC_STL r28,19*SZL(r3)
0072     PPC_STL r29,20*SZL(r3)
0073     PPC_STL r30,21*SZL(r3)
0074     PPC_STL r31,22*SZL(r3)
0075 #endif
0076     li  r3,0
0077     blr
0078 
0079 _GLOBAL(longjmp)
0080 #ifdef CONFIG_PPC32
0081     lmw r12, 3*SZL(r3)
0082     mtcrf   0x38, r12
0083 #else
0084     PPC_LL  r13,4*SZL(r3)
0085     PPC_LL  r14,5*SZL(r3)
0086     PPC_LL  r15,6*SZL(r3)
0087     PPC_LL  r16,7*SZL(r3)
0088     PPC_LL  r17,8*SZL(r3)
0089     PPC_LL  r18,9*SZL(r3)
0090     PPC_LL  r19,10*SZL(r3)
0091     PPC_LL  r20,11*SZL(r3)
0092     PPC_LL  r21,12*SZL(r3)
0093     PPC_LL  r22,13*SZL(r3)
0094     PPC_LL  r23,14*SZL(r3)
0095     PPC_LL  r24,15*SZL(r3)
0096     PPC_LL  r25,16*SZL(r3)
0097     PPC_LL  r26,17*SZL(r3)
0098     PPC_LL  r27,18*SZL(r3)
0099     PPC_LL  r28,19*SZL(r3)
0100     PPC_LL  r29,20*SZL(r3)
0101     PPC_LL  r30,21*SZL(r3)
0102     PPC_LL  r31,22*SZL(r3)
0103     PPC_LL  r0,3*SZL(r3)
0104     mtcrf   0x38,r0
0105 #endif
0106     PPC_LL  r0,0(r3)
0107     PPC_LL  r1,SZL(r3)
0108     PPC_LL  r2,2*SZL(r3)
0109     mtlr    r0
0110     mr. r3, r4
0111     bnelr
0112     li  r3, 1
0113     blr
0114 
0115 _GLOBAL(current_stack_frame)
0116     PPC_LL  r3,0(r1)
0117     blr
0118 EXPORT_SYMBOL(current_stack_frame)