ppc-linux-common.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Common target dependent code for GNU/Linux on PPC systems.
  2. Copyright (C) 2018-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "gdbsupport/common-defs.h"
  15. #include "arch/ppc-linux-common.h"
  16. #include "arch/ppc-linux-tdesc.h"
  17. /* Decimal Floating Point bit in AT_HWCAP.
  18. This file can be used by a host with another architecture, e.g.
  19. when debugging core files, which might not provide this constant. */
  20. #ifndef PPC_FEATURE_HAS_DFP
  21. #define PPC_FEATURE_HAS_DFP 0x00000400
  22. #endif
  23. bool
  24. ppc_linux_has_isa205 (CORE_ADDR hwcap)
  25. {
  26. /* Power ISA 2.05 (implemented by Power 6 and newer processors)
  27. increases the FPSCR from 32 bits to 64 bits. Even though Power 7
  28. supports this ISA version, it doesn't have PPC_FEATURE_ARCH_2_05
  29. set, only PPC_FEATURE_ARCH_2_06. Since for now the only bits
  30. used in the higher half of the register are for Decimal Floating
  31. Point, we check if that feature is available to decide the size
  32. of the FPSCR. */
  33. return ((hwcap & PPC_FEATURE_HAS_DFP) != 0);
  34. }
  35. const struct target_desc *
  36. ppc_linux_match_description (struct ppc_linux_features features)
  37. {
  38. struct target_desc *tdesc = NULL;
  39. if (features.wordsize == 8)
  40. {
  41. if (features.vsx)
  42. tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx64l
  43. : features.isa207? tdesc_powerpc_isa207_vsx64l
  44. : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l
  45. : features.isa205? tdesc_powerpc_isa205_vsx64l
  46. : tdesc_powerpc_vsx64l);
  47. else if (features.altivec)
  48. tdesc = (features.isa205? tdesc_powerpc_isa205_altivec64l
  49. : tdesc_powerpc_altivec64l);
  50. else
  51. tdesc = (features.isa205? tdesc_powerpc_isa205_64l
  52. : tdesc_powerpc_64l);
  53. }
  54. else
  55. {
  56. gdb_assert (features.wordsize == 4);
  57. if (features.vsx)
  58. tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx32l
  59. : features.isa207? tdesc_powerpc_isa207_vsx32l
  60. : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l
  61. : features.isa205? tdesc_powerpc_isa205_vsx32l
  62. : tdesc_powerpc_vsx32l);
  63. else if (features.altivec)
  64. tdesc = (features.isa205? tdesc_powerpc_isa205_altivec32l
  65. : tdesc_powerpc_altivec32l);
  66. else
  67. tdesc = (features.isa205? tdesc_powerpc_isa205_32l
  68. : tdesc_powerpc_32l);
  69. }
  70. gdb_assert (tdesc != NULL);
  71. return tdesc;
  72. }