aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2009-06-30 04:39:09 -0700
committerUlrich Drepper <drepper@redhat.com>2009-06-30 04:39:09 -0700
commit0181291385671286db5eefc5eea9913c647f14d8 (patch)
treec1ab3ccc64a7daaea49f3624c23f02f01448b59b /sysdeps
parent44d20bca52ace85850012b0ead37b360e3ecd96e (diff)
downloadglibc-0181291385671286db5eefc5eea9913c647f14d8.tar
glibc-0181291385671286db5eefc5eea9913c647f14d8.tar.gz
glibc-0181291385671286db5eefc5eea9913c647f14d8.tar.bz2
glibc-0181291385671286db5eefc5eea9913c647f14d8.zip
Determine and store processor family and model on x86-64.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/x86_64/multiarch/ifunc-defines.sym2
-rw-r--r--sysdeps/x86_64/multiarch/init-arch.c37
-rw-r--r--sysdeps/x86_64/multiarch/init-arch.h2
3 files changed, 33 insertions, 8 deletions
diff --git a/sysdeps/x86_64/multiarch/ifunc-defines.sym b/sysdeps/x86_64/multiarch/ifunc-defines.sym
index 48d1287246..e2021cdf87 100644
--- a/sysdeps/x86_64/multiarch/ifunc-defines.sym
+++ b/sysdeps/x86_64/multiarch/ifunc-defines.sym
@@ -11,5 +11,7 @@ CPUID_EAX_OFFSET offsetof (struct cpuid_registers, eax)
CPUID_EBX_OFFSET offsetof (struct cpuid_registers, ebx)
CPUID_ECX_OFFSET offsetof (struct cpuid_registers, ecx)
CPUID_EDX_OFFSET offsetof (struct cpuid_registers, edx)
+FAMILY_OFFSET offsetof (struct cpu_features, family)
+MODEL_OFFSET offsetof (struct cpu_features, model)
COMMON_CPUID_INDEX_1
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
index ec0eb29faf..d559331d70 100644
--- a/sysdeps/x86_64/multiarch/init-arch.c
+++ b/sysdeps/x86_64/multiarch/init-arch.c
@@ -24,6 +24,22 @@
struct cpu_features __cpu_features attribute_hidden;
+static void
+get_common_indeces (void)
+{
+ asm volatile ("cpuid"
+ : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax),
+ "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx),
+ "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx),
+ "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx)
+ : "0" (1));
+
+ unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax;
+ __cpu_features.family = (eax >> 8) & 0x0f;
+ __cpu_features.model = (eax >> 4) & 0x0f;
+}
+
+
void
__init_cpu_features (void)
{
@@ -41,20 +57,25 @@ __init_cpu_features (void)
{
__cpu_features.kind = arch_kind_intel;
- get_common_cpuid:
- asm volatile ("cpuid"
- : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax),
- "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx),
- "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx),
- "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx)
- : "0" (1));
+ get_common_indeces ();
+
+ unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax;
+ unsigned int extended_family = (eax >> 20) & 0xff;
+ unsigned int extended_model = (eax >> 12) & 0xf0;
+ if (family == 0x0f)
+ {
+ __cpu_features.family += extended_family;
+ __cpu_features.model += extended_model;
+ }
+ else if (family == 0x06)
+ __cpu_features.model += extended_model;
}
/* This spells out "AuthenticAMD". */
else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
{
__cpu_features.kind = arch_kind_amd;
- goto get_common_cpuid;
+ get_common_indeces ();
}
else
__cpu_features.kind = arch_kind_other;
diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h
index 5c4892de38..48a2127418 100644
--- a/sysdeps/x86_64/multiarch/init-arch.h
+++ b/sysdeps/x86_64/multiarch/init-arch.h
@@ -42,6 +42,8 @@ extern struct cpu_features
unsigned int ecx;
unsigned int edx;
} cpuid[COMMON_CPUID_INDEX_MAX];
+ unsigned int family;
+ unsigned int model;
} __cpu_features attribute_hidden;