Gglobal.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2002-2005 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #include <assert.h>
  22. #include "unwind_i.h"
  23. HIDDEN struct ia64_global_unwind_state unw =
  24. {
  25. .needs_initialization = 1,
  26. .lock = PTHREAD_MUTEX_INITIALIZER,
  27. .save_order = {
  28. IA64_REG_IP, IA64_REG_PFS, IA64_REG_PSP, IA64_REG_PR,
  29. IA64_REG_UNAT, IA64_REG_LC, IA64_REG_FPSR, IA64_REG_PRI_UNAT_GR
  30. },
  31. #if UNW_DEBUG
  32. .preg_name = {
  33. "pri_unat_gr", "pri_unat_mem", "psp", "bsp", "bspstore",
  34. "ar.pfs", "ar.rnat", "rp",
  35. "r4", "r5", "r6", "r7",
  36. "nat4", "nat5", "nat6", "nat7",
  37. "ar.unat", "pr", "ar.lc", "ar.fpsr",
  38. "b1", "b2", "b3", "b4", "b5",
  39. "f2", "f3", "f4", "f5",
  40. "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
  41. "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"
  42. }
  43. #endif
  44. };
  45. HIDDEN void
  46. tdep_init (void)
  47. {
  48. uint8_t f1_bytes[16] = {
  49. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
  50. 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  51. };
  52. uint8_t nat_val_bytes[16] = {
  53. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe,
  54. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  55. };
  56. uint8_t int_val_bytes[16] = {
  57. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3e,
  58. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  59. };
  60. intrmask_t saved_mask;
  61. uint8_t *lep, *bep;
  62. long i;
  63. sigfillset (&unwi_full_mask);
  64. lock_acquire (&unw.lock, saved_mask);
  65. {
  66. if (!tdep_needs_initialization)
  67. /* another thread else beat us to it... */
  68. goto out;
  69. mi_init ();
  70. mempool_init (&unw.reg_state_pool, sizeof (struct ia64_reg_state), 0);
  71. mempool_init (&unw.labeled_state_pool,
  72. sizeof (struct ia64_labeled_state), 0);
  73. unw.read_only.r0 = 0;
  74. unw.read_only.f0.raw.bits[0] = 0;
  75. unw.read_only.f0.raw.bits[1] = 0;
  76. lep = (uint8_t *) &unw.read_only.f1_le + 16;
  77. bep = (uint8_t *) &unw.read_only.f1_be;
  78. for (i = 0; i < 16; ++i)
  79. {
  80. *--lep = f1_bytes[i];
  81. *bep++ = f1_bytes[i];
  82. }
  83. lep = (uint8_t *) &unw.nat_val_le + 16;
  84. bep = (uint8_t *) &unw.nat_val_be;
  85. for (i = 0; i < 16; ++i)
  86. {
  87. *--lep = nat_val_bytes[i];
  88. *bep++ = nat_val_bytes[i];
  89. }
  90. lep = (uint8_t *) &unw.int_val_le + 16;
  91. bep = (uint8_t *) &unw.int_val_be;
  92. for (i = 0; i < 16; ++i)
  93. {
  94. *--lep = int_val_bytes[i];
  95. *bep++ = int_val_bytes[i];
  96. }
  97. assert (8*sizeof(unw_hash_index_t) >= IA64_LOG_UNW_HASH_SIZE);
  98. #ifndef UNW_REMOTE_ONLY
  99. ia64_local_addr_space_init ();
  100. #endif
  101. tdep_needs_initialization = 0; /* signal that we're initialized... */
  102. }
  103. out:
  104. lock_release (&unw.lock, saved_mask);
  105. }