xref: /openbmc/linux/arch/powerpc/kernel/misc.S (revision e3d786a3)
1/*
2 * This file contains miscellaneous low-level functions.
3 *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
4 *
5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
6 * and Paul Mackerras.
7 *
8 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
9 *
10 * setjmp/longjmp code by Paul Mackerras.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#include <asm/ppc_asm.h>
18#include <asm/unistd.h>
19#include <asm/asm-compat.h>
20#include <asm/asm-offsets.h>
21#include <asm/export.h>
22
23	.text
24
25/*
26 * Returns (address we are running at) - (address we were linked at)
27 * for use before the text and data are mapped to KERNELBASE.
28
29 * add_reloc_offset(x) returns x + reloc_offset().
30 */
31
32_GLOBAL(reloc_offset)
33	li	r3, 0
34_GLOBAL(add_reloc_offset)
35	mflr	r0
36	bl	1f
371:	mflr	r5
38	PPC_LL	r4,(2f-1b)(r5)
39	subf	r5,r4,r5
40	add	r3,r3,r5
41	mtlr	r0
42	blr
43
44	.align	3
452:	PPC_LONG 1b
46
47_GLOBAL(setjmp)
48	mflr	r0
49	PPC_STL	r0,0(r3)
50	PPC_STL	r1,SZL(r3)
51	PPC_STL	r2,2*SZL(r3)
52#ifdef CONFIG_PPC32
53	mfcr	r12
54	stmw	r12, 3*SZL(r3)
55#else
56	mfcr	r0
57	PPC_STL	r0,3*SZL(r3)
58	PPC_STL	r13,4*SZL(r3)
59	PPC_STL	r14,5*SZL(r3)
60	PPC_STL	r15,6*SZL(r3)
61	PPC_STL	r16,7*SZL(r3)
62	PPC_STL	r17,8*SZL(r3)
63	PPC_STL	r18,9*SZL(r3)
64	PPC_STL	r19,10*SZL(r3)
65	PPC_STL	r20,11*SZL(r3)
66	PPC_STL	r21,12*SZL(r3)
67	PPC_STL	r22,13*SZL(r3)
68	PPC_STL	r23,14*SZL(r3)
69	PPC_STL	r24,15*SZL(r3)
70	PPC_STL	r25,16*SZL(r3)
71	PPC_STL	r26,17*SZL(r3)
72	PPC_STL	r27,18*SZL(r3)
73	PPC_STL	r28,19*SZL(r3)
74	PPC_STL	r29,20*SZL(r3)
75	PPC_STL	r30,21*SZL(r3)
76	PPC_STL	r31,22*SZL(r3)
77#endif
78	li	r3,0
79	blr
80
81_GLOBAL(longjmp)
82#ifdef CONFIG_PPC32
83	lmw	r12, 3*SZL(r3)
84	mtcrf	0x38, r12
85#else
86	PPC_LL	r13,4*SZL(r3)
87	PPC_LL	r14,5*SZL(r3)
88	PPC_LL	r15,6*SZL(r3)
89	PPC_LL	r16,7*SZL(r3)
90	PPC_LL	r17,8*SZL(r3)
91	PPC_LL	r18,9*SZL(r3)
92	PPC_LL	r19,10*SZL(r3)
93	PPC_LL	r20,11*SZL(r3)
94	PPC_LL	r21,12*SZL(r3)
95	PPC_LL	r22,13*SZL(r3)
96	PPC_LL	r23,14*SZL(r3)
97	PPC_LL	r24,15*SZL(r3)
98	PPC_LL	r25,16*SZL(r3)
99	PPC_LL	r26,17*SZL(r3)
100	PPC_LL	r27,18*SZL(r3)
101	PPC_LL	r28,19*SZL(r3)
102	PPC_LL	r29,20*SZL(r3)
103	PPC_LL	r30,21*SZL(r3)
104	PPC_LL	r31,22*SZL(r3)
105	PPC_LL	r0,3*SZL(r3)
106	mtcrf	0x38,r0
107#endif
108	PPC_LL	r0,0(r3)
109	PPC_LL	r1,SZL(r3)
110	PPC_LL	r2,2*SZL(r3)
111	mtlr	r0
112	mr.	r3, r4
113	bnelr
114	li	r3, 1
115	blr
116
117_GLOBAL(current_stack_pointer)
118	PPC_LL	r3,0(r1)
119	blr
120EXPORT_SYMBOL(current_stack_pointer)
121