• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libunwind - a platform-independent unwind library
2    Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
3         Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4 
5    Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
6    Modified for s390x by Michael Munday <mike.munday@ibm.com>
7 
8 This file is part of libunwind.
9 
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17 
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
28 
29 #include "config.h"
30 #include "unwind_i.h"
31 #include "dwarf_i.h"
32 
33 HIDDEN define_lock (s390x_lock);
34 HIDDEN atomic_bool tdep_init_done = 0;
35 
36 /* The API register numbers are exactly the same as the .eh_frame
37    registers, for now at least.  */
38 HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] =
39   {
40     UNW_S390X_R0,
41     UNW_S390X_R1,
42     UNW_S390X_R2,
43     UNW_S390X_R3,
44     UNW_S390X_R4,
45     UNW_S390X_R5,
46     UNW_S390X_R6,
47     UNW_S390X_R7,
48     UNW_S390X_R8,
49     UNW_S390X_R9,
50     UNW_S390X_R10,
51     UNW_S390X_R11,
52     UNW_S390X_R12,
53     UNW_S390X_R13,
54     UNW_S390X_R14,
55     UNW_S390X_R15,
56 
57     UNW_S390X_F0,
58     UNW_S390X_F2,
59     UNW_S390X_F4,
60     UNW_S390X_F6,
61     UNW_S390X_F1,
62     UNW_S390X_F3,
63     UNW_S390X_F5,
64     UNW_S390X_F7,
65     UNW_S390X_F8,
66     UNW_S390X_F10,
67     UNW_S390X_F12,
68     UNW_S390X_F14,
69     UNW_S390X_F9,
70     UNW_S390X_F11,
71     UNW_S390X_F13,
72     UNW_S390X_F15,
73   };
74 
75 HIDDEN void
tdep_init(void)76 tdep_init (void)
77 {
78   intrmask_t saved_mask;
79 
80   sigfillset (&unwi_full_mask);
81 
82   lock_acquire (&s390x_lock, saved_mask);
83   {
84     if (atomic_load(&tdep_init_done))
85       /* another thread else beat us to it... */
86       goto out;
87 
88     mi_init ();
89 
90     dwarf_init ();
91 
92 #ifndef UNW_REMOTE_ONLY
93     tdep_init_mem_validate ();
94 
95     s390x_local_addr_space_init ();
96 #endif
97     atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */
98   }
99  out:
100   lock_release (&s390x_lock, saved_mask);
101 }
102