From: Martin Mares Date: Mon, 11 Sep 2006 19:04:48 +0000 (+0200) Subject: Added automatic configuration for Prescott, Nocona, Pentium-M and amd64 CPU's. X-Git-Tag: holmes-import~555^2~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=c982ab2e7563eb425bb198a8aa051d46fcb2895c;p=libucw.git Added automatic configuration for Prescott, Nocona, Pentium-M and amd64 CPU's. --- diff --git a/lib/autoconf.cfg b/lib/autoconf.cfg index 668c83ea..39317a25 100644 --- a/lib/autoconf.cfg +++ b/lib/autoconf.cfg @@ -48,6 +48,22 @@ Test("ARCH", "Checking for machine architecture", sub { } }); +sub parse_cpuinfo() { + IsSet("CONFIG_EXACT_CPU") && IsSet("CONFIG_LINUX") && open X, "/proc/cpuinfo" || undef; + my %pc = (); + while () { + chomp; + /^$/ && last; + /^([^\t]+)\t+:\s*(.*)$/ and $pc{$1}=$2; + } + close X; + + my $vendor = $pc{'vendor_id'} || ""; + my $family = $pc{'cpu family'} || 0; + my $model = $pc{'model'} || 0; + return ($vendor, $family, $model); +} + Test("CPU_ARCH", "Checking for CPU architecture", sub { my $mach = Get("ARCH"); if ($mach eq "i386") { @@ -58,19 +74,8 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub { Set("CPU_ALLOW_UNALIGNED"); Set("CPU_STRUCT_ALIGN" => 4); my $arch = ""; - if (IsSet("CONFIG_EXACT_CPU") && IsSet("CONFIG_LINUX") && open X, "/proc/cpuinfo") { - my %pc = (); - while () { - chomp; - /^$/ && last; - /^([^\t]+)\t+:\s*(.*)$/ and $pc{$1}=$2; - } - close X; - + if (my ($vendor, $family, $model) = parse_cpuinfo()) { # Try to understand CPU vendor, family and model [inspired by MPlayer's configure script] - my $vendor = $pc{'vendor_id'} || ""; - my $family = $pc{'cpu family'} || 0; - my $model = $pc{'model'} || 0; if ($vendor eq "AuthenticAMD") { if ($family >= 6) { if ($model >= 31 && $gccver >= 3004) { $arch = "athlon64"; } @@ -78,10 +83,13 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub { else { $arch = "athlon"; } } } elsif ($vendor eq "GenuineIntel") { - # We don't recognize Prescott and Nocona cores yet (gcc-3.4+) - if ($family >= 15 && $gccver >= 3003) { $arch = "pentium4"; } - elsif ($family >= 6 && $gccver >= 3003) { - if ($model >= 7) { $arch = "pentium3"; } + if ($family >= 15 && $gccver >= 3003) { + if ($model >= 4) { $arch = "nocona"; } + elsif ($model >= 3) { $arch = "prescott"; } + else { $arch = "pentium4"; } + } elsif ($family == 6 && $gccver >= 3003) { + if (($model == 9 || $model == 13) && $gccver >= 3004) { $arch = "pentium-m"; } + elsif ($model >= 7) { $arch = "pentium3"; } elsif ($model >= 3) { $arch = "pentium2"; } } } @@ -94,11 +102,7 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub { $arch = "i${family}86"; } } - if ($arch ne "") { - Log "(using /proc/cpuinfo) "; - } else { - Log "(don't understand /proc/cpuinfo) "; - } + Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) "); } return $arch ? $arch : "i386"; } elsif ($mach eq "amd64") { @@ -108,7 +112,16 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub { UnSet("CPU_BIG_ENDIAN"); Set("CPU_ALLOW_UNALIGNED"); Set("CPU_STRUCT_ALIGN" => 8); - return "x86-64"; + if (my ($vendor, $family, $model) = parse_cpuinfo()) { + # In x86-64 world, the detection is somewhat easier so far... + if ($vendor eq "AuthenticAMD") { + $arch = "athlon64"; + } elsif ($vendor eq "GenuineIntel") { + $arch = "nocona"; + } + Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) "); + } + return $arch ? $arch : "x86-64"; } else { return undef; }