ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc64 / xmon / setjmp.c
1 /*
2  * Copyright (C) 1996 Paul Mackerras.
3  *
4  *      This program is free software; you can redistribute it and/or
5  *      modify it under the terms of the GNU General Public License
6  *      as published by the Free Software Foundation; either version
7  *      2 of the License, or (at your option) any later version.
8  *
9  * NB this file must be compiled with -O2.
10  */
11
12 int
13 xmon_setjmp(long *buf)  /* NOTE: assert(sizeof(buf) > 184) */
14 {
15         /* XXX should save fp regs as well */
16         asm volatile (
17         "mflr 0; std 0,0(%0)\n\
18          std    1,8(%0)\n\
19          std    2,16(%0)\n\
20          mfcr 0; std 0,24(%0)\n\
21          std    13,32(%0)\n\
22          std    14,40(%0)\n\
23          std    15,48(%0)\n\
24          std    16,56(%0)\n\
25          std    17,64(%0)\n\
26          std    18,72(%0)\n\
27          std    19,80(%0)\n\
28          std    20,88(%0)\n\
29          std    21,96(%0)\n\
30          std    22,104(%0)\n\
31          std    23,112(%0)\n\
32          std    24,120(%0)\n\
33          std    25,128(%0)\n\
34          std    26,136(%0)\n\
35          std    27,144(%0)\n\
36          std    28,152(%0)\n\
37          std    29,160(%0)\n\
38          std    30,168(%0)\n\
39          std    31,176(%0)\n\
40          " : : "r" (buf));
41     return 0;
42 }
43
44 void
45 xmon_longjmp(long *buf, int val)
46 {
47         if (val == 0)
48                 val = 1;
49         asm volatile (
50         "ld     13,32(%0)\n\
51          ld     14,40(%0)\n\
52          ld     15,48(%0)\n\
53          ld     16,56(%0)\n\
54          ld     17,64(%0)\n\
55          ld     18,72(%0)\n\
56          ld     19,80(%0)\n\
57          ld     20,88(%0)\n\
58          ld     21,96(%0)\n\
59          ld     22,104(%0)\n\
60          ld     23,112(%0)\n\
61          ld     24,120(%0)\n\
62          ld     25,128(%0)\n\
63          ld     26,136(%0)\n\
64          ld     27,144(%0)\n\
65          ld     28,152(%0)\n\
66          ld     29,160(%0)\n\
67          ld     30,168(%0)\n\
68          ld     31,176(%0)\n\
69          ld     0,24(%0)\n\
70          mtcrf  0x38,0\n\
71          ld     0,0(%0)\n\
72          ld     1,8(%0)\n\
73          ld     2,16(%0)\n\
74          mtlr   0\n\
75          mr     3,%1\n\
76          " : : "r" (buf), "r" (val));
77 }