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