diff options
author | Andy Polyakov <appro@openssl.org> | 2007-05-15 20:51:48 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2007-05-15 20:51:48 +0000 |
commit | 9c9c83ccb9a9e76d9861b0da185b1a96fb54395a (patch) | |
tree | 1fea3d74c1a08d7d96ff62d3cdd2fb9d4037adba /crypto | |
parent | 1d42fb5f4aae476e4f917d8a334952c05685f86a (diff) |
Throw in ppccpuid module.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/Makefile | 1 | ||||
-rwxr-xr-x | crypto/ppccpuid.pl | 94 |
2 files changed, 95 insertions, 0 deletions
diff --git a/crypto/Makefile b/crypto/Makefile index 1b8c7c2591..a19f4d9917 100644 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -77,6 +77,7 @@ x86_64cpuid.s: x86_64cpuid.pl $(PERL) x86_64cpuid.pl $@ ia64cpuid.s: ia64cpuid.S $(CC) $(CFLAGS) -E ia64cpuid.S > $@ +ppccpuid_%.s: ppccpuid.pl; $(PERL) $< $@ testapps: [ -z "$(THIS)" ] || ( if echo ${SDIRS} | fgrep ' des '; \ diff --git a/crypto/ppccpuid.pl b/crypto/ppccpuid.pl new file mode 100755 index 0000000000..50d989e193 --- /dev/null +++ b/crypto/ppccpuid.pl @@ -0,0 +1,94 @@ +#!/usr/bin/env perl + +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or +( $xlate="${dir}perlasm/ppc-xlate.pl" and -f $xlate) or +die "can't locate ppc-xlate.pl"; + +( defined shift || open STDOUT,"| $^X $xlate $output" ) || + die "can't call $xlate: $!"; + +if ($output=~/64/) { + $CMPLI="cmpldi"; + $SHRLI="srdi"; + $SIGNX="extsw"; +} else { + $CMPLI="cmplwi"; + $SHRLI="srwi"; + $SIGNX="mr"; +} + +$code=<<___; +.text + +.globl .OPENSSL_cpuid_setup +.align 4 +.OPENSSL_cpuid_setup: + blr + +.globl .OPENSSL_wipe_cpu +.align 4 +.OPENSSL_wipe_cpu: + xor r0,r0,r0 + mr r3,r1 + xor r4,r4,r4 + xor r5,r5,r5 + xor r6,r6,r6 + xor r7,r7,r7 + xor r8,r8,r8 + xor r9,r9,r9 + xor r10,r10,r10 + xor r11,r11,r11 + xor r12,r12,r12 + blr + +.globl .OPENSSL_atomic_add +.align 4 +.OPENSSL_atomic_add: +Loop: lwarx r5,0,r3 + add r0,r4,r5 + stwcx. r0,0,r3 + bne- Loop + $SIGNX r3,r0 + blr + +.globl .OPENSSL_rdtsc +.align 4 +.OPENSSL_rdtsc: + mftb r3 + mftbu r4 + blr + +.globl .OPENSSL_cleanse +.align 4 +.OPENSSL_cleanse: + $CMPLI r4,7 + li r0,0 + bge Lot +Little: mtctr r4 + stb r0,0(r3) + addi r3,r3,1 + bdnz- .-8 + blr +Lot: andi. r5,r3,3 + beq Laligned + stb r0,0(r3) + subi r4,r4,1 + addi r3,r3,1 + b Lot +Laligned: + $SHRLI r5,r4,2 + mtctr r5 + stw r0,0(r3) + addi r3,r3,4 + bdnz- .-8 + andi. r4,r4,3 + bne Little + blr +___ + +$code =~ s/\`([^\`]*)\`/eval $1/gem; +print $code; +close STDOUT; |