1 #!/usr/bin/env perl 2 3 $flavour = shift; 4 5 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; 6 ( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or 7 ( $xlate="${dir}perlasm/ppc-xlate.pl" and -f $xlate) or 8 die "can't locate ppc-xlate.pl"; 9 10 open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; 11 12 if ($flavour=~/64/) { 13 $CMPLI="cmpldi"; 14 $SHRLI="srdi"; 15 $SIGNX="extsw"; 16 } else { 17 $CMPLI="cmplwi"; 18 $SHRLI="srwi"; 19 $SIGNX="mr"; 20 } 21 22 $code=<<___; 23 .machine "any" 24 .text 25 26 .globl .OPENSSL_ppc64_probe 27 .align 4 28 .OPENSSL_ppc64_probe: 29 fcfid f1,f1 30 extrdi r0,r0,32,0 31 blr 32 .long 0 33 .byte 0,12,0x14,0,0,0,0,0 34 35 .globl .OPENSSL_altivec_probe 36 .align 4 37 .OPENSSL_altivec_probe: 38 .long 0x10000484 # vor v0,v0,v0 39 blr 40 .long 0 41 .byte 0,12,0x14,0,0,0,0,0 42 43 .globl .OPENSSL_wipe_cpu 44 .align 4 45 .OPENSSL_wipe_cpu: 46 xor r0,r0,r0 47 fmr f0,f31 48 fmr f1,f31 49 fmr f2,f31 50 mr r3,r1 51 fmr f3,f31 52 xor r4,r4,r4 53 fmr f4,f31 54 xor r5,r5,r5 55 fmr f5,f31 56 xor r6,r6,r6 57 fmr f6,f31 58 xor r7,r7,r7 59 fmr f7,f31 60 xor r8,r8,r8 61 fmr f8,f31 62 xor r9,r9,r9 63 fmr f9,f31 64 xor r10,r10,r10 65 fmr f10,f31 66 xor r11,r11,r11 67 fmr f11,f31 68 xor r12,r12,r12 69 fmr f12,f31 70 fmr f13,f31 71 blr 72 .long 0 73 .byte 0,12,0x14,0,0,0,0,0 74 75 .globl .OPENSSL_atomic_add 76 .align 4 77 .OPENSSL_atomic_add: 78 Ladd: lwarx r5,0,r3 79 add r0,r4,r5 80 stwcx. r0,0,r3 81 bne- Ladd 82 $SIGNX r3,r0 83 blr 84 .long 0 85 .byte 0,12,0x14,0,0,0,2,0 86 .long 0 87 88 .globl .OPENSSL_rdtsc 89 .align 4 90 .OPENSSL_rdtsc: 91 mftb r3 92 mftbu r4 93 blr 94 .long 0 95 .byte 0,12,0x14,0,0,0,0,0 96 97 .globl .OPENSSL_cleanse 98 .align 4 99 .OPENSSL_cleanse: 100 $CMPLI r4,7 101 li r0,0 102 bge Lot 103 $CMPLI r4,0 104 beqlr- 105 Little: mtctr r4 106 stb r0,0(r3) 107 addi r3,r3,1 108 bdnz \$-8 109 blr 110 Lot: andi. r5,r3,3 111 beq Laligned 112 stb r0,0(r3) 113 subi r4,r4,1 114 addi r3,r3,1 115 b Lot 116 Laligned: 117 $SHRLI r5,r4,2 118 mtctr r5 119 stw r0,0(r3) 120 addi r3,r3,4 121 bdnz \$-8 122 andi. r4,r4,3 123 bne Little 124 blr 125 .long 0 126 .byte 0,12,0x14,0,0,0,2,0 127 .long 0 128 ___ 129 130 $code =~ s/\`([^\`]*)\`/eval $1/gem; 131 print $code; 132 close STDOUT; 133