blob: b40a84ef16456c9ddbbb56139745aa6f75940715 [file] [log] [blame]
Jose Flavio Aguilar Paulino4499bb22007-09-12 21:52:25 -06001/* libunwind - a platform-independent unwind library
2 Copyright (C) 2006-2007 IBM
3 Contributed by
4 Corey Ashford <cjashfor@us.ibm.com>
5 Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com>
6
7 Copied from libunwind-x86_64.h, modified slightly for building
8 frysk successfully on ppc64, by Wu Zhou <woodzltc@cn.ibm.com>
9 Will be replaced when libunwind is ready on ppc64 platform.
10
11This file is part of libunwind.
12
13Permission is hereby granted, free of charge, to any person obtaining
14a copy of this software and associated documentation files (the
15"Software"), to deal in the Software without restriction, including
16without limitation the rights to use, copy, modify, merge, publish,
17distribute, sublicense, and/or sell copies of the Software, and to
18permit persons to whom the Software is furnished to do so, subject to
19the following conditions:
20
21The above copyright notice and this permission notice shall be
22included in all copies or substantial portions of the Software.
23
24THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
31
32#ifndef LIBUNWIND_H
33#define LIBUNWIND_H
34
35#if defined(__cplusplus) || defined(c_plusplus)
36extern "C" {
37#endif
38
39#include <inttypes.h>
40#include <ucontext.h>
41
42#define UNW_TARGET ppc32
43#define UNW_TARGET_PPC32 1
44
45#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
46
47/*
48 * This needs to be big enough to accommodate "struct cursor", while
49 * leaving some slack for future expansion. Changing this value will
50 * require recompiling all users of this library. Stack allocation is
51 * relatively cheap and unwind-state copying is relatively rare, so we want
52 * to err on making it rather too big than too small.
53 *
54 * To simplify this whole process, we are at least initially taking the
55 * tack that UNW_PPC32_* map straight across to the .eh_frame column register
56 * numbers. These register numbers come from gcc's source in
57 * gcc/config/rs6000/rs6000.h
58 *
59 * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115
60 * elements in the loc array, each sized 2 * unw_word_t, plus the rest of
61 * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's
62 * round that up to 280.
63 */
64
Jose Flavio Aguilar Paulino9ea6af82007-10-08 12:33:18 -060065#define UNW_TDEP_CURSOR_LEN 200
Jose Flavio Aguilar Paulino4499bb22007-09-12 21:52:25 -060066
67#if __WORDSIZE==32
68typedef uint32_t unw_word_t;
69typedef int32_t unw_sword_t;
70#else
71typedef uint64_t unw_word_t;
72typedef int64_t unw_sword_t;
73#endif
74
75typedef long double unw_tdep_fpreg_t;
76
77typedef enum
78 {
79 UNW_PPC32_R0,
80 UNW_PPC32_R1, /* called STACK_POINTER in gcc */
81 UNW_PPC32_R2,
82 UNW_PPC32_R3,
83 UNW_PPC32_R4,
84 UNW_PPC32_R5,
85 UNW_PPC32_R6,
86 UNW_PPC32_R7,
87 UNW_PPC32_R8,
88 UNW_PPC32_R9,
89 UNW_PPC32_R10,
90 UNW_PPC32_R11, /* called STATIC_CHAIN in gcc */
91 UNW_PPC32_R12,
92 UNW_PPC32_R13,
93 UNW_PPC32_R14,
94 UNW_PPC32_R15,
95 UNW_PPC32_R16,
96 UNW_PPC32_R17,
97 UNW_PPC32_R18,
98 UNW_PPC32_R19,
99 UNW_PPC32_R20,
100 UNW_PPC32_R21,
101 UNW_PPC32_R22,
102 UNW_PPC32_R23,
103 UNW_PPC32_R24,
104 UNW_PPC32_R25,
105 UNW_PPC32_R26,
106 UNW_PPC32_R27,
107 UNW_PPC32_R28,
108 UNW_PPC32_R29,
109 UNW_PPC32_R30,
110 UNW_PPC32_R31, /* called HARD_FRAME_POINTER in gcc */
111
Jose Flavio Aguilar Paulino9ea6af82007-10-08 12:33:18 -0600112 /* Count Register */
113 UNW_PPC32_CTR = 32,
114 /* Fixed-Point Status and Control Register */
115 UNW_PPC32_XER = 33,
116 /* Condition Register */
117 UNW_PPC32_CCR = 34,
118 /* Machine State Register */
119 //UNW_PPC32_MSR = 35,
120 /* MQ or SPR0, not part of generic Power, part of MPC601 */
121 //UNW_PPC32_MQ = 36,
122 /* Link Register */
123 UNW_PPC32_LR = 36,
124 /* Floating Pointer Status and Control Register */
125 UNW_PPC32_FPSCR = 37,
126
127 UNW_PPC32_F0 = 48,
Jose Flavio Aguilar Paulino4499bb22007-09-12 21:52:25 -0600128 UNW_PPC32_F1,
129 UNW_PPC32_F2,
130 UNW_PPC32_F3,
131 UNW_PPC32_F4,
132 UNW_PPC32_F5,
133 UNW_PPC32_F6,
134 UNW_PPC32_F7,
135 UNW_PPC32_F8,
136 UNW_PPC32_F9,
137 UNW_PPC32_F10,
138 UNW_PPC32_F11,
139 UNW_PPC32_F12,
140 UNW_PPC32_F13,
141 UNW_PPC32_F14,
142 UNW_PPC32_F15,
143 UNW_PPC32_F16,
144 UNW_PPC32_F17,
145 UNW_PPC32_F18,
146 UNW_PPC32_F19,
147 UNW_PPC32_F20,
148 UNW_PPC32_F21,
149 UNW_PPC32_F22,
150 UNW_PPC32_F23,
151 UNW_PPC32_F24,
152 UNW_PPC32_F25,
153 UNW_PPC32_F26,
154 UNW_PPC32_F27,
155 UNW_PPC32_F28,
156 UNW_PPC32_F29,
157 UNW_PPC32_F30,
158 UNW_PPC32_F31,
159
Jose Flavio Aguilar Paulino9ea6af82007-10-08 12:33:18 -0600160 UNW_TDEP_LAST_REG = UNW_PPC32_F31,
Jose Flavio Aguilar Paulino4499bb22007-09-12 21:52:25 -0600161
Jose Flavio Aguilar Paulino9ea6af82007-10-08 12:33:18 -0600162 UNW_TDEP_IP = UNW_PPC32_LR,
Jose Flavio Aguilar Paulino4499bb22007-09-12 21:52:25 -0600163 UNW_TDEP_SP = UNW_PPC32_R1,
164 UNW_TDEP_EH = UNW_PPC32_R12
165 }
166ppc32_regnum_t;
167
168/*
169 * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for
170 * passing parameters to exception handlers.
171 */
172
173#define UNW_TDEP_NUM_EH_REGS 4
174
175typedef struct unw_tdep_save_loc
176 {
177 /* Additional target-dependent info on a save location. */
178 }
179unw_tdep_save_loc_t;
180
181/* On ppc, we can directly use ucontext_t as the unwind context. */
182typedef ucontext_t unw_tdep_context_t;
183
184/* XXX this is not ideal: an application should not be prevented from
185 using the "getcontext" name just because it's using libunwind. We
186 can't just use __getcontext() either, because that isn't exported
187 by glibc... */
188#define unw_tdep_getcontext(uc) (getcontext (uc), 0)
189
190#include "libunwind-dynamic.h"
191
192typedef struct
193 {
194 /* no ppc32-specific auxiliary proc-info */
195 }
196unw_tdep_proc_info_t;
197
198#include "libunwind-common.h"
199
200#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
201extern int unw_tdep_is_fpreg (int);
202
203#if defined(__cplusplus) || defined(c_plusplus)
204}
205#endif
206
207#endif /* LIBUNWIND_H */