1
0
mirror of https://github.com/google/cpu_features.git synced 2025-07-01 21:31:15 +02:00

powerpc: Add AT_PLATFORM and AT_BASE_PLATFORM

Some PowerPC machines can operate in a mode that appears different
to a process than the actual hardware. AT_PLATFORM indicates the
supported instruction set and AT_BASE_PLATFORM indicates the
actual microarchitecture of the hardware.

Signed-off-by: Rashmica Gupta <rashmica.gupta@au1.ibm.com>
This commit is contained in:
Rashmica Gupta
2018-05-02 14:30:25 +10:00
committed by Rashmica Gupta
parent 1c8bf0ecd8
commit c45e32f812
8 changed files with 52 additions and 1 deletions

View File

@ -168,6 +168,7 @@ PPCPlatformStrings GetPPCPlatformStrings(void) {
PPCPlatformStrings strings = kEmptyPPCPlatformStrings;
FillProcCpuInfoData(&strings);
strings.type = CpuFeatures_GetPlatformType();
return strings;
}

View File

@ -12,9 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "internal/hwcaps.h"
#include <stdlib.h>
#include <string.h>
#include "cpu_features_macros.h"
#include "internal/filesystem.h"
#include "internal/hwcaps.h"
#include "internal/string_view.h"
#if defined(NDEBUG)
#define D(...)
@ -71,6 +75,9 @@ static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) {
#include <dlfcn.h>
#define AT_HWCAP 16
#define AT_HWCAP2 26
#define AT_PLATFORM 15
#define AT_BASE_PLATFORM 24
typedef unsigned long getauxval_func_t(unsigned long);
static uint32_t GetElfHwcapFromGetauxval(uint32_t hwcap_type) {
@ -152,6 +159,21 @@ HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) {
return capabilities;
}
PlatformType kEmptyPlatformType;
PlatformType CpuFeatures_GetPlatformType(void) {
PlatformType type = kEmptyPlatformType;
char *platform = (char *)GetHardwareCapabilitiesFor(AT_PLATFORM);
char *base_platform = (char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM);
if (platform != NULL)
CpuFeatures_StringView_CopyString(str(platform), type.platform,
sizeof(type.platform));
if (base_platform != NULL)
CpuFeatures_StringView_CopyString(str(base_platform), type.base_platform,
sizeof(type.base_platform));
return type;
}
#else // (defined(HWCAPS_SUPPORTED)
////////////////////////////////////////////////////////////////////////////////

View File

@ -198,6 +198,8 @@ static void PrintFeatures(const Printer printer) {
PrintS(printer, "model", strings.model);
PrintS(printer, "machine", strings.machine);
PrintS(printer, "cpu", strings.cpu);
PrintS(printer, "instruction set", strings.type.platform);
PrintS(printer, "microarchitecture", strings.type.base_platform);
PrintFlags(printer, &info.features);
#endif
}