1d4e76214Sopenharmony_ci/* libunwind - a platform-independent unwind library
2d4e76214Sopenharmony_ci   Copyright (C) 2008 CodeSourcery
3d4e76214Sopenharmony_ci   Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
4d4e76214Sopenharmony_ci   Copyright (C) 2013 Linaro Limited
5d4e76214Sopenharmony_ci
6d4e76214Sopenharmony_ciThis file is part of libunwind.
7d4e76214Sopenharmony_ci
8d4e76214Sopenharmony_ciPermission is hereby granted, free of charge, to any person obtaining
9d4e76214Sopenharmony_cia copy of this software and associated documentation files (the
10d4e76214Sopenharmony_ci"Software"), to deal in the Software without restriction, including
11d4e76214Sopenharmony_ciwithout limitation the rights to use, copy, modify, merge, publish,
12d4e76214Sopenharmony_cidistribute, sublicense, and/or sell copies of the Software, and to
13d4e76214Sopenharmony_cipermit persons to whom the Software is furnished to do so, subject to
14d4e76214Sopenharmony_cithe following conditions:
15d4e76214Sopenharmony_ci
16d4e76214Sopenharmony_ciThe above copyright notice and this permission notice shall be
17d4e76214Sopenharmony_ciincluded in all copies or substantial portions of the Software.
18d4e76214Sopenharmony_ci
19d4e76214Sopenharmony_ciTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20d4e76214Sopenharmony_ciEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21d4e76214Sopenharmony_ciMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22d4e76214Sopenharmony_ciNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23d4e76214Sopenharmony_ciLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24d4e76214Sopenharmony_ciOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25d4e76214Sopenharmony_ciWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
26d4e76214Sopenharmony_ci
27d4e76214Sopenharmony_ci#include "unwind_i.h"
28d4e76214Sopenharmony_ci#include "dwarf_i.h"
29d4e76214Sopenharmony_ci
30d4e76214Sopenharmony_ciHIDDEN define_lock (aarch64_lock);
31d4e76214Sopenharmony_ciHIDDEN atomic_bool tdep_init_done = 0;
32d4e76214Sopenharmony_ci
33d4e76214Sopenharmony_ciHIDDEN void
34d4e76214Sopenharmony_citdep_init (void)
35d4e76214Sopenharmony_ci{
36d4e76214Sopenharmony_ci  intrmask_t saved_mask;
37d4e76214Sopenharmony_ci
38d4e76214Sopenharmony_ci  sigfillset (&unwi_full_mask);
39d4e76214Sopenharmony_ci
40d4e76214Sopenharmony_ci  lock_acquire (&aarch64_lock, saved_mask);
41d4e76214Sopenharmony_ci  {
42d4e76214Sopenharmony_ci    if (atomic_load(&tdep_init_done))
43d4e76214Sopenharmony_ci      /* another thread else beat us to it... */
44d4e76214Sopenharmony_ci      goto out;
45d4e76214Sopenharmony_ci
46d4e76214Sopenharmony_ci    mi_init ();
47d4e76214Sopenharmony_ci
48d4e76214Sopenharmony_ci    dwarf_init ();
49d4e76214Sopenharmony_ci
50d4e76214Sopenharmony_ci    tdep_init_mem_validate ();
51d4e76214Sopenharmony_ci
52d4e76214Sopenharmony_ci#ifndef UNW_REMOTE_ONLY
53d4e76214Sopenharmony_ci    aarch64_local_addr_space_init ();
54d4e76214Sopenharmony_ci#endif
55d4e76214Sopenharmony_ci    atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */
56d4e76214Sopenharmony_ci  }
57d4e76214Sopenharmony_ci out:
58d4e76214Sopenharmony_ci  lock_release (&aarch64_lock, saved_mask);
59d4e76214Sopenharmony_ci}
60