• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* 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 This file is part of libunwind.
8 
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16 
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
27 
28 #include "unwind_i.h"
29 #include "dwarf_i.h"
30 
31 HIDDEN define_lock (ppc64_lock);
32 HIDDEN int tdep_init_done;
33 
34 /* The API register numbers are exactly the same as the .eh_frame
35    registers, for now at least.  */
36 HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH] =
37   {
38 	[UNW_PPC64_R0]=UNW_PPC64_R0,
39 	[UNW_PPC64_R1]=UNW_PPC64_R1,
40 	[UNW_PPC64_R2]=UNW_PPC64_R2,
41 	[UNW_PPC64_R3]=UNW_PPC64_R3,
42 	[UNW_PPC64_R4]=UNW_PPC64_R4,
43 	[UNW_PPC64_R5]=UNW_PPC64_R5,
44 	[UNW_PPC64_R6]=UNW_PPC64_R6,
45 	[UNW_PPC64_R7]=UNW_PPC64_R7,
46 	[UNW_PPC64_R8]=UNW_PPC64_R8,
47 	[UNW_PPC64_R9]=UNW_PPC64_R9,
48 	[UNW_PPC64_R10]=UNW_PPC64_R10,
49 	[UNW_PPC64_R11]=UNW_PPC64_R11,
50 	[UNW_PPC64_R12]=UNW_PPC64_R12,
51 	[UNW_PPC64_R13]=UNW_PPC64_R13,
52 	[UNW_PPC64_R14]=UNW_PPC64_R14,
53 	[UNW_PPC64_R15]=UNW_PPC64_R15,
54 	[UNW_PPC64_R16]=UNW_PPC64_R16,
55 	[UNW_PPC64_R17]=UNW_PPC64_R17,
56 	[UNW_PPC64_R18]=UNW_PPC64_R18,
57 	[UNW_PPC64_R19]=UNW_PPC64_R19,
58 	[UNW_PPC64_R20]=UNW_PPC64_R20,
59 	[UNW_PPC64_R21]=UNW_PPC64_R21,
60 	[UNW_PPC64_R22]=UNW_PPC64_R22,
61 	[UNW_PPC64_R23]=UNW_PPC64_R23,
62 	[UNW_PPC64_R24]=UNW_PPC64_R24,
63 	[UNW_PPC64_R25]=UNW_PPC64_R25,
64 	[UNW_PPC64_R26]=UNW_PPC64_R26,
65 	[UNW_PPC64_R27]=UNW_PPC64_R27,
66 	[UNW_PPC64_R28]=UNW_PPC64_R28,
67 	[UNW_PPC64_R29]=UNW_PPC64_R29,
68 	[UNW_PPC64_R30]=UNW_PPC64_R30,
69 	[UNW_PPC64_R31]=UNW_PPC64_R31,
70 
71 	[UNW_PPC64_F0]=UNW_PPC64_F0,
72 	[UNW_PPC64_F1]=UNW_PPC64_F1,
73 	[UNW_PPC64_F2]=UNW_PPC64_F2,
74 	[UNW_PPC64_F3]=UNW_PPC64_F3,
75 	[UNW_PPC64_F4]=UNW_PPC64_F4,
76 	[UNW_PPC64_F5]=UNW_PPC64_F5,
77 	[UNW_PPC64_F6]=UNW_PPC64_F6,
78 	[UNW_PPC64_F7]=UNW_PPC64_F7,
79 	[UNW_PPC64_F8]=UNW_PPC64_F8,
80 	[UNW_PPC64_F9]=UNW_PPC64_F9,
81 	[UNW_PPC64_F10]=UNW_PPC64_F10,
82 	[UNW_PPC64_F11]=UNW_PPC64_F11,
83 	[UNW_PPC64_F12]=UNW_PPC64_F12,
84 	[UNW_PPC64_F13]=UNW_PPC64_F13,
85 	[UNW_PPC64_F14]=UNW_PPC64_F14,
86 	[UNW_PPC64_F15]=UNW_PPC64_F15,
87 	[UNW_PPC64_F16]=UNW_PPC64_F16,
88 	[UNW_PPC64_F17]=UNW_PPC64_F17,
89 	[UNW_PPC64_F18]=UNW_PPC64_F18,
90 	[UNW_PPC64_F19]=UNW_PPC64_F19,
91 	[UNW_PPC64_F20]=UNW_PPC64_F20,
92 	[UNW_PPC64_F21]=UNW_PPC64_F21,
93 	[UNW_PPC64_F22]=UNW_PPC64_F22,
94 	[UNW_PPC64_F23]=UNW_PPC64_F23,
95 	[UNW_PPC64_F24]=UNW_PPC64_F24,
96 	[UNW_PPC64_F25]=UNW_PPC64_F25,
97 	[UNW_PPC64_F26]=UNW_PPC64_F26,
98 	[UNW_PPC64_F27]=UNW_PPC64_F27,
99 	[UNW_PPC64_F28]=UNW_PPC64_F28,
100 	[UNW_PPC64_F29]=UNW_PPC64_F29,
101 	[UNW_PPC64_F30]=UNW_PPC64_F30,
102 	[UNW_PPC64_F31]=UNW_PPC64_F31,
103 
104 	[UNW_PPC64_LR]=UNW_PPC64_LR,
105 	[UNW_PPC64_CTR]=UNW_PPC64_CTR,
106 	[UNW_PPC64_ARG_POINTER]=UNW_PPC64_ARG_POINTER,
107 
108 	[UNW_PPC64_CR0]=UNW_PPC64_CR0,
109 	[UNW_PPC64_CR1]=UNW_PPC64_CR1,
110 	[UNW_PPC64_CR2]=UNW_PPC64_CR2,
111 	[UNW_PPC64_CR3]=UNW_PPC64_CR3,
112 	[UNW_PPC64_CR4]=UNW_PPC64_CR4,
113 	[UNW_PPC64_CR5]=UNW_PPC64_CR5,
114 	[UNW_PPC64_CR6]=UNW_PPC64_CR6,
115 	[UNW_PPC64_CR7]=UNW_PPC64_CR7,
116 
117 	[UNW_PPC64_XER]=UNW_PPC64_XER,
118 
119 	[UNW_PPC64_V0]=UNW_PPC64_V0,
120 	[UNW_PPC64_V1]=UNW_PPC64_V1,
121 	[UNW_PPC64_V2]=UNW_PPC64_V2,
122 	[UNW_PPC64_V3]=UNW_PPC64_V3,
123 	[UNW_PPC64_V4]=UNW_PPC64_V4,
124 	[UNW_PPC64_V5]=UNW_PPC64_V5,
125 	[UNW_PPC64_V6]=UNW_PPC64_V6,
126 	[UNW_PPC64_V7]=UNW_PPC64_V7,
127 	[UNW_PPC64_V8]=UNW_PPC64_V8,
128 	[UNW_PPC64_V9]=UNW_PPC64_V9,
129 	[UNW_PPC64_V10]=UNW_PPC64_V10,
130 	[UNW_PPC64_V11]=UNW_PPC64_V11,
131 	[UNW_PPC64_V12]=UNW_PPC64_V12,
132 	[UNW_PPC64_V13]=UNW_PPC64_V13,
133 	[UNW_PPC64_V14]=UNW_PPC64_V14,
134 	[UNW_PPC64_V15]=UNW_PPC64_V15,
135 	[UNW_PPC64_V16]=UNW_PPC64_V16,
136 	[UNW_PPC64_V17]=UNW_PPC64_V17,
137 	[UNW_PPC64_V18]=UNW_PPC64_V18,
138 	[UNW_PPC64_V19]=UNW_PPC64_V19,
139 	[UNW_PPC64_V20]=UNW_PPC64_V20,
140 	[UNW_PPC64_V21]=UNW_PPC64_V21,
141 	[UNW_PPC64_V22]=UNW_PPC64_V22,
142 	[UNW_PPC64_V23]=UNW_PPC64_V23,
143 	[UNW_PPC64_V24]=UNW_PPC64_V24,
144 	[UNW_PPC64_V25]=UNW_PPC64_V25,
145 	[UNW_PPC64_V26]=UNW_PPC64_V26,
146 	[UNW_PPC64_V27]=UNW_PPC64_V27,
147 	[UNW_PPC64_V28]=UNW_PPC64_V28,
148 	[UNW_PPC64_V29]=UNW_PPC64_V29,
149 	[UNW_PPC64_V30]=UNW_PPC64_V30,
150 	[UNW_PPC64_V31]=UNW_PPC64_V31,
151 
152 	[UNW_PPC64_VRSAVE]=UNW_PPC64_VRSAVE,
153 	[UNW_PPC64_VSCR]=UNW_PPC64_VSCR,
154 	[UNW_PPC64_SPE_ACC]=UNW_PPC64_SPE_ACC,
155 	[UNW_PPC64_SPEFSCR]=UNW_PPC64_SPEFSCR,
156   };
157 
158 HIDDEN void
tdep_init(void)159 tdep_init (void)
160 {
161   intrmask_t saved_mask;
162 
163   sigfillset (&unwi_full_mask);
164 
165   lock_acquire (&ppc64_lock, saved_mask);
166   {
167     if (tdep_init_done)
168       /* another thread else beat us to it... */
169       goto out;
170 
171     mi_init ();
172 
173     dwarf_init ();
174 
175 #ifndef UNW_REMOTE_ONLY
176     ppc64_local_addr_space_init ();
177 #endif
178     tdep_init_done = 1;	/* signal that we're initialized... */
179   }
180  out:
181   lock_release (&ppc64_lock, saved_mask);
182 }
183