aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch/ppc-linux-common.c
blob: 6badd2f7d261731e35ab0099c92c4c4c742b609f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Common target dependent code for GNU/Linux on PPC systems.

   Copyright (C) 2018-2019 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#include "common/common-defs.h"
#include "arch/ppc-linux-common.h"
#include "arch/ppc-linux-tdesc.h"

/* Decimal Floating Point bit in AT_HWCAP.

   This file can be used by a host with another architecture, e.g.
   when debugging core files, which might not provide this constant.  */

#ifndef PPC_FEATURE_HAS_DFP
#define PPC_FEATURE_HAS_DFP	0x00000400
#endif

bool
ppc_linux_has_isa205 (CORE_ADDR hwcap)
{
  /* Power ISA 2.05 (implemented by Power 6 and newer processors)
     increases the FPSCR from 32 bits to 64 bits.  Even though Power 7
     supports this ISA version, it doesn't have PPC_FEATURE_ARCH_2_05
     set, only PPC_FEATURE_ARCH_2_06.  Since for now the only bits
     used in the higher half of the register are for Decimal Floating
     Point, we check if that feature is available to decide the size
     of the FPSCR.  */
  return ((hwcap & PPC_FEATURE_HAS_DFP) != 0);
}

const struct target_desc *
ppc_linux_match_description (struct ppc_linux_features features)
{
  struct target_desc *tdesc = NULL;

  if (features.wordsize == 8)
    {
      if (features.cell)
	tdesc = tdesc_powerpc_cell64l;
      else if (features.vsx)
	tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx64l
		 : features.isa207? tdesc_powerpc_isa207_vsx64l
		 : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l
		 : features.isa205? tdesc_powerpc_isa205_vsx64l
		 : tdesc_powerpc_vsx64l);
      else if (features.altivec)
	tdesc = (features.isa205? tdesc_powerpc_isa205_altivec64l
		 : tdesc_powerpc_altivec64l);
      else
	tdesc = (features.isa205? tdesc_powerpc_isa205_64l
		 : tdesc_powerpc_64l);
    }
  else
    {
      gdb_assert (features.wordsize == 4);

      if (features.cell)
	tdesc = tdesc_powerpc_cell32l;
      else if (features.vsx)
	tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx32l
		 : features.isa207? tdesc_powerpc_isa207_vsx32l
		 : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l
		 : features.isa205? tdesc_powerpc_isa205_vsx32l
		 : tdesc_powerpc_vsx32l);
      else if (features.altivec)
	tdesc = (features.isa205? tdesc_powerpc_isa205_altivec32l
		 : tdesc_powerpc_altivec32l);
      else
	tdesc = (features.isa205? tdesc_powerpc_isa205_32l
		 : tdesc_powerpc_32l);
    }

  gdb_assert (tdesc != NULL);

  return tdesc;
}