[svn] gcry - r1445 - in trunk: . src
svn author wk
cvs at cvs.gnupg.org
Fri Aug 27 10:52:25 CEST 2010
Author: wk
Date: 2010-08-27 10:52:24 +0200 (Fri, 27 Aug 2010)
New Revision: 1445
Modified:
trunk/autogen.sh
trunk/src/ChangeLog
trunk/src/g10lib.h
trunk/src/global.c
trunk/src/hwfeatures.c
Log:
Prepare support of ia32 AES instructions
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2010-08-19 13:57:38 UTC (rev 1444)
+++ trunk/src/ChangeLog 2010-08-27 08:52:24 UTC (rev 1445)
@@ -1,3 +1,9 @@
+2010-08-27 Werner Koch <wk at g10code.com>
+
+ * g10lib.h (HWF_INTEL_AES): New.
+ * global.c (print_config): Print new flag.
+ * hwfeatures.c (detect_ia32_gnuc): Detect this flag.
+
2010-08-16 Werner Koch <wk at g10code.com>
* gcrypt.h.in [!WIN32]: Add INSERT_SYS_SELECT_H autoconf substitute.
Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh 2010-08-19 13:57:38 UTC (rev 1444)
+++ trunk/autogen.sh 2010-08-27 08:52:24 UTC (rev 1445)
@@ -128,7 +128,7 @@
fi
fi
- ./configure --enable-maintainer-mode --prefix=${w32root} \
+ $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \
--host=${host} --build=${build} \
--with-gpg-error-prefix=${w32root}
exit $?
Modified: trunk/src/g10lib.h
===================================================================
--- trunk/src/g10lib.h 2010-08-19 13:57:38 UTC (rev 1444)
+++ trunk/src/g10lib.h 2010-08-27 08:52:24 UTC (rev 1445)
@@ -148,6 +148,9 @@
#define HWF_PADLOCK_SHA 4
#define HWF_PADLOCK_MMUL 8
+#define HWF_INTEL_AES 256
+
+
unsigned int _gcry_get_hw_features (void);
void _gcry_detect_hw_features (void);
Modified: trunk/src/global.c
===================================================================
--- trunk/src/global.c 2010-08-19 13:57:38 UTC (rev 1444)
+++ trunk/src/global.c 2010-08-27 08:52:24 UTC (rev 1445)
@@ -265,6 +265,7 @@
{ HWF_PADLOCK_RNG, "padlock-rng" },
{ HWF_PADLOCK_AES, "padlock-aes" },
{ HWF_PADLOCK_SHA, "padlock-sha" },
+ { HWF_INTEL_AES, "intel-aes" },
{ 0, NULL}
};
int i;
Modified: trunk/src/hwfeatures.c
===================================================================
--- trunk/src/hwfeatures.c 2010-08-19 13:57:38 UTC (rev 1444)
+++ trunk/src/hwfeatures.c 2010-08-27 08:52:24 UTC (rev 1445)
@@ -44,7 +44,6 @@
static void
detect_ia32_gnuc (void)
{
-#ifdef ENABLE_PADLOCK_SUPPORT
/* The code here is only useful for the PadLock engine thus we don't
build it if that support has been disabled. */
int has_cpuid = 0;
@@ -89,10 +88,12 @@
);
vendor_id[12] = 0;
- /* Check whether this is a VIA CPU and what PadLock features we
- have. */
- if (!strcmp (vendor_id, "CentaurHauls"))
+ if (0)
+ ; /* Just to make "else if" and ifdef macros look pretty. */
+#ifdef ENABLE_PADLOCK_SUPPORT
+ else if (!strcmp (vendor_id, "CentaurHauls"))
{
+ /* This is a VIA CPU. Check what PadLock features we have. */
asm volatile
("pushl %%ebx\n\t" /* Save GOT register. */
"movl $0xC0000000, %%eax\n\t" /* Check for extended centaur */
@@ -140,11 +141,33 @@
);
}
#endif /*ENABLE_PADLOCK_SUPPORT*/
+ else if (!strcmp (vendor_id, "GenuineIntel"))
+ {
+ /* This is an Intel CPU. */
+ asm volatile
+ ("pushl %%ebx\n\t" /* Save GOT register. */
+ "movl $1, %%eax\n\t" /* Get CPU info and feature flags. */
+ "cpuid\n"
+ "popl %%ebx\n\t" /* Restore GOT register. */
+ "cmpl $0x02000000, %%ecx\n\t" /* Test bit 25. */
+ "jnz .Lno_aes%=\n\t" /* No AES support. */
+ "orl $256, %0\n" /* Set our HWF_INTEL_AES bit. */
+
+ ".Lno_aes%=:\n"
+ : "+r" (hw_features)
+ :
+ : "%eax", "%ecx", "%edx", "cc"
+ );
+ }
+ else if (!strcmp (vendor_id, "AuthenticAMD"))
+ {
+ /* This is an AMD CPU. */
+
+ }
}
#endif /* __i386__ && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ */
-
/* Detect the available hardware features. This function is called
once right at startup and we assume that no other threads are
running. */
More information about the Gnupg-commits
mailing list