summaryrefslogtreecommitdiffstats
path: root/crypto/x86cpuid.pl
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2004-07-26 22:18:55 +0200
committerAndy Polyakov <appro@openssl.org>2004-07-26 22:18:55 +0200
commit14e21f863a3e3278bb8660ea9844e92e52e1f2f7 (patch)
tree5bcc6cfa9002eb94d2788bc3fa8c72eb5b9f188e /crypto/x86cpuid.pl
parentZero key-length for HMAC is apparently OK. (diff)
downloadopenssl-14e21f863a3e3278bb8660ea9844e92e52e1f2f7.tar.xz
openssl-14e21f863a3e3278bb8660ea9844e92e52e1f2f7.zip
Add framework for yet another assembler module dubbed "cpuid." Idea
is to have a placeholder to small routines, which can be written only in assembler. In IA-32 case this includes processor capability identification and access to Time-Stamp Counter. As discussed earlier OPENSSL_ia32cap is introduced to control recently added SSE2 code pathes (see docs/crypto/OPENSSL_ia32cap.pod). For the moment the code is operational on ELF platforms only. I haven't checked it yet, but I have all reasons to believe that Windows build should fail to link too. I'll be looking into it shortly...
Diffstat (limited to 'crypto/x86cpuid.pl')
-rw-r--r--crypto/x86cpuid.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/crypto/x86cpuid.pl b/crypto/x86cpuid.pl
new file mode 100644
index 0000000000..85fbef7417
--- /dev/null
+++ b/crypto/x86cpuid.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/env perl
+
+push(@INC,"perlasm");
+require "x86asm.pl";
+
+&asm_init($ARGV[0],"x86cpuid");
+
+&function_begin("OPENSSL_ia32_cpuid");
+ &xor ("edx","edx");
+ &pushf ();
+ &pop ("eax");
+ &mov ("ecx","eax");
+ &xor ("eax",1<<21);
+ &push ("eax");
+ &popf ();
+ &pushf ();
+ &pop ("eax");
+ &xor ("ecx","eax");
+ &bt ("ecx",21);
+ &jnc (&label("nocpuid"));
+ &mov ("eax",1);
+ &cpuid ();
+&set_label("nocpuid");
+ &mov ("eax","edx");
+ &mov ("edx","ecx");
+&function_end("OPENSSL_ia32_cpuid");
+
+&external_label("OPENSSL_ia32cap");
+
+&function_begin_B("OPENSSL_rdtsc");
+ &xor ("eax","eax");
+ &xor ("edx","edx");
+ &picmeup("ecx","OPENSSL_ia32cap");
+ &bt (&DWP(0,"ecx"),4);
+ &jnc (&label("notsc"));
+ &rdtsc ();
+&set_label("notsc");
+ &ret ();
+&function_end_B("OPENSSL_rdtsc");
+
+&initseg("OPENSSL_cpuid_setup") if ($main'elf);
+
+&asm_finish();