Blame sysdeps/powerpc/hwcapinfo.c

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