]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/powerpc/kernel/misc.S
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6.git] / arch / powerpc / kernel / misc.S
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  * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
9  * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
10  *
11  * setjmp/longjmp code by Paul Mackerras.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version
16  * 2 of the License, or (at your option) any later version.
17  */
18 #include <asm/ppc_asm.h>
19 #include <asm/unistd.h>
20 #include <asm/asm-compat.h>
21 #include <asm/asm-offsets.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
30 _GLOBAL(reloc_offset)
31         mflr    r0
32         bl      1f
33 1:      mflr    r3
34         PPC_LL  r4,(2f-1b)(r3)
35         subf    r3,r4,r3
36         mtlr    r0
37         blr
38
39         .align  3
40 2:      PPC_LONG 1b
41
42 /*
43  * add_reloc_offset(x) returns x + reloc_offset().
44  */
45 _GLOBAL(add_reloc_offset)
46         mflr    r0
47         bl      1f
48 1:      mflr    r5
49         PPC_LL  r4,(2f-1b)(r5)
50         subf    r5,r4,r5
51         add     r3,r3,r5
52         mtlr    r0
53         blr
54
55         .align  3
56 2:      PPC_LONG 1b
57
58 _GLOBAL(kernel_execve)
59         li      r0,__NR_execve
60         sc
61         bnslr
62         neg     r3,r3
63         blr
64
65 _GLOBAL(setjmp)
66         mflr    r0
67         PPC_STL r0,0(r3)
68         PPC_STL r1,SZL(r3)
69         PPC_STL r2,2*SZL(r3)
70         mfcr    r0
71         PPC_STL r0,3*SZL(r3)
72         PPC_STL r13,4*SZL(r3)
73         PPC_STL r14,5*SZL(r3)
74         PPC_STL r15,6*SZL(r3)
75         PPC_STL r16,7*SZL(r3)
76         PPC_STL r17,8*SZL(r3)
77         PPC_STL r18,9*SZL(r3)
78         PPC_STL r19,10*SZL(r3)
79         PPC_STL r20,11*SZL(r3)
80         PPC_STL r21,12*SZL(r3)
81         PPC_STL r22,13*SZL(r3)
82         PPC_STL r23,14*SZL(r3)
83         PPC_STL r24,15*SZL(r3)
84         PPC_STL r25,16*SZL(r3)
85         PPC_STL r26,17*SZL(r3)
86         PPC_STL r27,18*SZL(r3)
87         PPC_STL r28,19*SZL(r3)
88         PPC_STL r29,20*SZL(r3)
89         PPC_STL r30,21*SZL(r3)
90         PPC_STL r31,22*SZL(r3)
91         li      r3,0
92         blr
93
94 _GLOBAL(longjmp)
95         PPC_LCMPI r4,0
96         bne     1f
97         li      r4,1
98 1:      PPC_LL  r13,4*SZL(r3)
99         PPC_LL  r14,5*SZL(r3)
100         PPC_LL  r15,6*SZL(r3)
101         PPC_LL  r16,7*SZL(r3)
102         PPC_LL  r17,8*SZL(r3)
103         PPC_LL  r18,9*SZL(r3)
104         PPC_LL  r19,10*SZL(r3)
105         PPC_LL  r20,11*SZL(r3)
106         PPC_LL  r21,12*SZL(r3)
107         PPC_LL  r22,13*SZL(r3)
108         PPC_LL  r23,14*SZL(r3)
109         PPC_LL  r24,15*SZL(r3)
110         PPC_LL  r25,16*SZL(r3)
111         PPC_LL  r26,17*SZL(r3)
112         PPC_LL  r27,18*SZL(r3)
113         PPC_LL  r28,19*SZL(r3)
114         PPC_LL  r29,20*SZL(r3)
115         PPC_LL  r30,21*SZL(r3)
116         PPC_LL  r31,22*SZL(r3)
117         PPC_LL  r0,3*SZL(r3)
118         mtcrf   0x38,r0
119         PPC_LL  r0,0(r3)
120         PPC_LL  r1,SZL(r3)
121         PPC_LL  r2,2*SZL(r3)
122         mtlr    r0
123         mr      r3,r4
124         blr
125
126 _GLOBAL(__setup_cpu_power7)
127 _GLOBAL(__restore_cpu_power7)
128         /* place holder */
129         blr
130
131 #ifdef CONFIG_EVENT_TRACING
132 /*
133  * Get a minimal set of registers for our caller's nth caller.
134  * r3 = regs pointer, r5 = n.
135  *
136  * We only get R1 (stack pointer), NIP (next instruction pointer)
137  * and LR (link register).  These are all we can get in the
138  * general case without doing complicated stack unwinding, but
139  * fortunately they are enough to do a stack backtrace, which
140  * is all we need them for.
141  */
142 _GLOBAL(perf_arch_fetch_caller_regs)
143         mr      r6,r1
144         cmpwi   r5,0
145         mflr    r4
146         ble     2f
147         mtctr   r5
148 1:      PPC_LL  r6,0(r6)
149         bdnz    1b
150         PPC_LL  r4,PPC_LR_STKOFF(r6)
151 2:      PPC_LL  r7,0(r6)
152         PPC_LL  r7,PPC_LR_STKOFF(r7)
153         PPC_STL r6,GPR1-STACK_FRAME_OVERHEAD(r3)
154         PPC_STL r4,_NIP-STACK_FRAME_OVERHEAD(r3)
155         PPC_STL r7,_LINK-STACK_FRAME_OVERHEAD(r3)
156         blr
157 #endif /* CONFIG_EVENT_TRACING */