• 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 (ppc32_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_PPC32_R0]=UNW_PPC32_R0,
39 	[UNW_PPC32_R1]=UNW_PPC32_R1,
40 	[UNW_PPC32_R2]=UNW_PPC32_R2,
41 	[UNW_PPC32_R3]=UNW_PPC32_R3,
42 	[UNW_PPC32_R4]=UNW_PPC32_R4,
43 	[UNW_PPC32_R5]=UNW_PPC32_R5,
44 	[UNW_PPC32_R6]=UNW_PPC32_R6,
45 	[UNW_PPC32_R7]=UNW_PPC32_R7,
46 	[UNW_PPC32_R8]=UNW_PPC32_R8,
47 	[UNW_PPC32_R9]=UNW_PPC32_R9,
48 	[UNW_PPC32_R10]=UNW_PPC32_R10,
49 	[UNW_PPC32_R11]=UNW_PPC32_R11,
50 	[UNW_PPC32_R12]=UNW_PPC32_R12,
51 	[UNW_PPC32_R13]=UNW_PPC32_R13,
52 	[UNW_PPC32_R14]=UNW_PPC32_R14,
53 	[UNW_PPC32_R15]=UNW_PPC32_R15,
54 	[UNW_PPC32_R16]=UNW_PPC32_R16,
55 	[UNW_PPC32_R17]=UNW_PPC32_R17,
56 	[UNW_PPC32_R18]=UNW_PPC32_R18,
57 	[UNW_PPC32_R19]=UNW_PPC32_R19,
58 	[UNW_PPC32_R20]=UNW_PPC32_R20,
59 	[UNW_PPC32_R21]=UNW_PPC32_R21,
60 	[UNW_PPC32_R22]=UNW_PPC32_R22,
61 	[UNW_PPC32_R23]=UNW_PPC32_R23,
62 	[UNW_PPC32_R24]=UNW_PPC32_R24,
63 	[UNW_PPC32_R25]=UNW_PPC32_R25,
64 	[UNW_PPC32_R26]=UNW_PPC32_R26,
65 	[UNW_PPC32_R27]=UNW_PPC32_R27,
66 	[UNW_PPC32_R28]=UNW_PPC32_R28,
67 	[UNW_PPC32_R29]=UNW_PPC32_R29,
68 	[UNW_PPC32_R30]=UNW_PPC32_R30,
69 	[UNW_PPC32_R31]=UNW_PPC32_R31,
70 
71 	[UNW_PPC32_CTR]=UNW_PPC32_CTR,
72 	[UNW_PPC32_XER]=UNW_PPC32_XER,
73 	[UNW_PPC32_CCR]=UNW_PPC32_CCR,
74 	[UNW_PPC32_LR]=UNW_PPC32_LR,
75 	[UNW_PPC32_FPSCR]=UNW_PPC32_FPSCR,
76 
77 	[UNW_PPC32_F0]=UNW_PPC32_F0,
78 	[UNW_PPC32_F1]=UNW_PPC32_F1,
79 	[UNW_PPC32_F2]=UNW_PPC32_F2,
80 	[UNW_PPC32_F3]=UNW_PPC32_F3,
81 	[UNW_PPC32_F4]=UNW_PPC32_F4,
82 	[UNW_PPC32_F5]=UNW_PPC32_F5,
83 	[UNW_PPC32_F6]=UNW_PPC32_F6,
84 	[UNW_PPC32_F7]=UNW_PPC32_F7,
85 	[UNW_PPC32_F8]=UNW_PPC32_F8,
86 	[UNW_PPC32_F9]=UNW_PPC32_F9,
87 	[UNW_PPC32_F10]=UNW_PPC32_F10,
88 	[UNW_PPC32_F11]=UNW_PPC32_F11,
89 	[UNW_PPC32_F12]=UNW_PPC32_F12,
90 	[UNW_PPC32_F13]=UNW_PPC32_F13,
91 	[UNW_PPC32_F14]=UNW_PPC32_F14,
92 	[UNW_PPC32_F15]=UNW_PPC32_F15,
93 	[UNW_PPC32_F16]=UNW_PPC32_F16,
94 	[UNW_PPC32_F17]=UNW_PPC32_F17,
95 	[UNW_PPC32_F18]=UNW_PPC32_F18,
96 	[UNW_PPC32_F19]=UNW_PPC32_F19,
97 	[UNW_PPC32_F20]=UNW_PPC32_F20,
98 	[UNW_PPC32_F21]=UNW_PPC32_F21,
99 	[UNW_PPC32_F22]=UNW_PPC32_F22,
100 	[UNW_PPC32_F23]=UNW_PPC32_F23,
101 	[UNW_PPC32_F24]=UNW_PPC32_F24,
102 	[UNW_PPC32_F25]=UNW_PPC32_F25,
103 	[UNW_PPC32_F26]=UNW_PPC32_F26,
104 	[UNW_PPC32_F27]=UNW_PPC32_F27,
105 	[UNW_PPC32_F28]=UNW_PPC32_F28,
106 	[UNW_PPC32_F29]=UNW_PPC32_F29,
107 	[UNW_PPC32_F30]=UNW_PPC32_F30,
108 	[UNW_PPC32_F31]=UNW_PPC32_F31,
109 };
110 
111 HIDDEN void
tdep_init(void)112 tdep_init (void)
113 {
114   intrmask_t saved_mask;
115 
116   sigfillset (&unwi_full_mask);
117 
118   lock_acquire (&ppc32_lock, saved_mask);
119   {
120     if (tdep_init_done)
121       /* another thread else beat us to it... */
122       goto out;
123 
124     mi_init ();
125 
126     dwarf_init ();
127 
128 #ifndef UNW_REMOTE_ONLY
129     ppc32_local_addr_space_init ();
130 #endif
131     tdep_init_done = 1;	/* signal that we're initialized... */
132   }
133  out:
134   lock_release (&ppc32_lock, saved_mask);
135 }
136