Blame sysdeps/powerpc/hwcapinfo.c

Packit 6c4009
/* powerpc HWCAP/HWCAP2 and AT_PLATFORM data pre-processing.
Packit 6c4009
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <unistd.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
#include <dl-procinfo.h>
Packit 6c4009
Packit 6c4009
uint64_t __tcb_hwcap __attribute__ ((visibility ("hidden")));
Packit 6c4009
uint32_t __tcb_platform __attribute__ ((visibility ("hidden")));
Packit 6c4009
Packit 6c4009
/* This function parses the HWCAP/HWCAP2 fields, adding the previous supported
Packit 6c4009
   ISA bits, as well as converting the AT_PLATFORM string to a number.  This
Packit 6c4009
   data is stored in two global variables that can be used later by the
Packit 6c4009
   powerpc-specific code to store it into the TCB.  */
Packit 6c4009
void
Packit 6c4009
__tcb_parse_hwcap_and_convert_at_platform (void)
Packit 6c4009
{
Packit 6c4009
Packit 6c4009
  uint64_t h1, h2;
Packit 6c4009
Packit 6c4009
  /* Read AT_PLATFORM string from auxv and convert it to a number.  */
Packit 6c4009
  __tcb_platform = _dl_string_platform (GLRO (dl_platform));
Packit 6c4009
Packit 6c4009
  /* Read HWCAP and HWCAP2 from auxv.  */
Packit 6c4009
  h1 = GLRO (dl_hwcap);
Packit 6c4009
  h2 = GLRO (dl_hwcap2);
Packit 6c4009
Packit 6c4009
  /* hwcap contains only the latest supported ISA, the code checks which is
Packit 6c4009
     and fills the previous supported ones.  */
Packit 6c4009
Packit 6c4009
  if (h2 & PPC_FEATURE2_ARCH_2_07)
Packit 6c4009
    h1 |= PPC_FEATURE_ARCH_2_06
Packit 6c4009
       | PPC_FEATURE_ARCH_2_05
Packit 6c4009
       | PPC_FEATURE_POWER5_PLUS
Packit 6c4009
       | PPC_FEATURE_POWER5
Packit 6c4009
       | PPC_FEATURE_POWER4;
Packit 6c4009
  else if (h1 & PPC_FEATURE_ARCH_2_06)
Packit 6c4009
    h1 |= PPC_FEATURE_ARCH_2_05
Packit 6c4009
       | PPC_FEATURE_POWER5_PLUS
Packit 6c4009
       | PPC_FEATURE_POWER5
Packit 6c4009
       | PPC_FEATURE_POWER4;
Packit 6c4009
  else if (h1 & PPC_FEATURE_ARCH_2_05)
Packit 6c4009
    h1 |= PPC_FEATURE_POWER5_PLUS
Packit 6c4009
       | PPC_FEATURE_POWER5
Packit 6c4009
       | PPC_FEATURE_POWER4;
Packit 6c4009
  else if (h1 & PPC_FEATURE_POWER5_PLUS)
Packit 6c4009
    h1 |= PPC_FEATURE_POWER5
Packit 6c4009
       | PPC_FEATURE_POWER4;
Packit 6c4009
  else if (h1 & PPC_FEATURE_POWER5)
Packit 6c4009
    h1 |= PPC_FEATURE_POWER4;
Packit 6c4009
Packit 6c4009
  /* Consolidate both HWCAP and HWCAP2 into a single doubleword so that
Packit 6c4009
     we can read both in a single load later.  */
Packit 6c4009
  __tcb_hwcap = h2;
Packit 6c4009
  __tcb_hwcap = (h1 << 32) | __tcb_hwcap;
Packit 6c4009
Packit 6c4009
}
Packit 6c4009
#if IS_IN (rtld)
Packit 6c4009
versioned_symbol (ld, __tcb_parse_hwcap_and_convert_at_platform, \
Packit 6c4009
		  __parse_hwcap_and_convert_at_platform, GLIBC_2_23);
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Export __parse_hwcap_and_convert_at_platform in libc.a.  This is used by
Packit 6c4009
   GCC to make sure that the HWCAP/Platform bits are stored in the TCB when
Packit 6c4009
   using __builtin_cpu_is()/__builtin_cpu_supports() in the static case.  */
Packit 6c4009
#ifndef SHARED
Packit 6c4009
weak_alias (__tcb_parse_hwcap_and_convert_at_platform, \
Packit 6c4009
	    __parse_hwcap_and_convert_at_platform);
Packit 6c4009
#endif