From 240b2d3441ce0711b0eacdc5345b3a4d9b77a716 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Sat, 19 Jan 2008 11:40:59 +0200 Subject: Add support for Geode CPU (rhbz#428979) Patch from Dennis Gilmore --- Makefile.am | 3 ++- installplatform | 6 +++--- lib/rpmrc.c | 28 ++++++++++++++++++++++++++++ lib/rpmts.c | 2 +- macros.in | 2 +- rpmrc.in | 5 +++++ 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 58b7cfba2..c45d54285 100644 --- a/Makefile.am +++ b/Makefile.am @@ -256,7 +256,8 @@ install-data-local: $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/i486 ;\ $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/i586 ;\ $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/i686 ;\ - $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/athlon ;;\ + $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/athlon ;\ + $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/geode ;;\ alpha*) $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/alpha ;\ $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/alphaev6 ;;\ arm*) $(MKDIR_P) $(DESTDIR)$(pkgsrcdir)/RPMS/armv3l ;\ diff --git a/installplatform b/installplatform index 30f661a6c..a51312a7a 100755 --- a/installplatform +++ b/installplatform @@ -20,7 +20,7 @@ E_O_F RPM="./rpm --rcfile=$TEMPRC --macros=$MACROS" -canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_arm[^-]*_arm_;s_\(powerpc\|ppc\)[^-]*_ppc_' +canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_geode_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_arm[^-]*_arm_;s_\(powerpc\|ppc\)[^-]*_ppc_' arch="`$RPM --eval '%{_arch}'|sed -e "$canonarch_sed"`" VENDOR="`$RPM --eval '%{_vendor}'`" OS="`$RPM --eval '%{_os}'`" @@ -29,7 +29,7 @@ target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'|sed - target="`$RPM --eval '%{_target}'|sed -e "$canonarch_sed"`" case "$arch" in - i[3456]86|pentium[34]|athlon) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_' ;; + i[3456]86|pentium[34]|athlon|geode) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_ s_i386_geode_' ;; alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;; arm*) SUBSTS='s_arm_armv3l_ s_arm_armv4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;; sparc*) SUBSTS='s_sparc\(64\|64v\|v9v\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;; @@ -69,7 +69,7 @@ for SUBST in $SUBSTS ; do s390x-linux) LIB=lib64; MULTILIBNO=2 ;; ppc-linux) MULTILIBNO=1 ;; ppc64-linux) LIB=lib64; MULTILIBNO=2 ;; - i?86-linux|pentium?-linux|athlon-linux) MULTILIBNO=1 ;; + i?86-linux|pentium?-linux|athlon-linux|geode-linux) MULTILIBNO=1 ;; x86_64-linux|amd64-linux|ia32e-linux) LIB=lib64; MULTILIBNO=2 ;; esac diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 11ca6e488..c1acb28f5 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -975,6 +975,32 @@ static int is_pentium4() return 0; } +static int is_geode() +{ + unsigned int eax, ebx, ecx, edx, family, model; + char vendor[16]; + /* If you care about space, you can just check ebx, ecx and edx directly + instead of forming a string first and then doing a strcmp */ + memset(vendor, 0, sizeof(vendor)); + + cpuid(0, &eax, &ebx, &ecx, &edx); + memset(vendor, 0, sizeof(vendor)); + *((unsigned int *)&vendor[0]) = ebx; + *((unsigned int *)&vendor[4]) = edx; + *((unsigned int *)&vendor[8]) = ecx; + if (strncmp(vendor, "AuthenticAMD", 12) != 0) + return 0; + cpuid(1, &eax, &ebx, &ecx, &edx); + family = (eax >> 8) & 0x0f; + model = (eax >> 4) & 0x0f; + if (family == 5) + switch (model) + { + case 10: // Geode + return 1; + } + return 0; +} #endif #if defined(__linux__) && defined(__powerpc__) @@ -1216,6 +1242,8 @@ static void defaultMachine(const char ** arch, strcpy(un.machine, "pentium4"); else if (is_pentium3()) strcpy(un.machine, "pentium3"); + else if (is_geode()) + strcpy(un.machine, "geode"); else if (strchr("3456", un.machine[1]) && un.machine[1] != class) un.machine[1] = class; } diff --git a/lib/rpmts.c b/lib/rpmts.c index 876522dd2..80f96c20c 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -153,7 +153,7 @@ static int isArch(const char * arch) { const char ** av; static const char *arches[] = { - "i386", "i486", "i586", "i686", "athlon", "pentium3", "pentium4", "x86_64", "amd64", "ia32e", + "i386", "i486", "i586", "i686", "athlon", "pentium3", "pentium4", "x86_64", "amd64", "ia32e", "geode", "alpha", "alphaev5", "alphaev56", "alphapca56", "alphaev6", "alphaev67", "sparc", "sun4", "sun4m", "sun4c", "sun4d", "sparcv8", "sparcv9", "sparcv9v", "sparc64", "sparc64v", "sun4u", diff --git a/macros.in b/macros.in index 19de05cfe..5155e2100 100644 --- a/macros.in +++ b/macros.in @@ -1203,7 +1203,7 @@ done \ # rpm can use regular expressions against target platforms in macro # conditionals. # -%ix86 i386 i486 i586 i686 pentium3 pentium4 athlon +%ix86 i386 i486 i586 i686 pentium3 pentium4 athlon geode #------------------------------------------------------------------------------ # arch macro for all supported ARM processors diff --git a/rpmrc.in b/rpmrc.in index f9a0c20b9..e3ac84e53 100644 --- a/rpmrc.in +++ b/rpmrc.in @@ -19,6 +19,7 @@ optflags: i686 -O2 -g -march=i686 optflags: pentium3 -O2 -g -march=pentium3 optflags: pentium4 -O2 -g -march=pentium4 optflags: athlon -O2 -g -march=athlon +optflags: geode -Os -g -m32 -march=geode optflags: ia64 -O2 -g optflags: x86_64 -O2 -g optflags: amd64 -O2 -g @@ -80,6 +81,7 @@ optflags: s390x -O2 -g # Canonical arch names and numbers arch_canon: athlon: athlon 1 +arch_canon: geode: geode 1 arch_canon: pentium4: pentium4 1 arch_canon: pentium3: pentium3 1 arch_canon: i686: i686 1 @@ -195,6 +197,7 @@ buildarchtranslate: osfmach3_i486: i386 buildarchtranslate: osfmach3_i386: i386 buildarchtranslate: athlon: i386 +buildarchtranslate: geode: i386 buildarchtranslate: pentium4: i386 buildarchtranslate: pentium3: i386 buildarchtranslate: i686: i386 @@ -264,6 +267,7 @@ arch_compat: alphaev5: alpha arch_compat: alpha: axp noarch arch_compat: athlon: i686 +arch_compat: geode: i586 arch_compat: pentium4: pentium3 arch_compat: pentium3: i686 arch_compat: i686: i586 @@ -368,6 +372,7 @@ os_compat: Darwin: MacOSX buildarch_compat: ia64: noarch buildarch_compat: athlon: i686 +buildarch_compat: geode: i586 buildarch_compat: pentium4: pentium3 buildarch_compat: pentium3: i686 buildarch_compat: i686: i586 -- cgit v1.2.3