Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Zero a page. |
| 3 | * rdi page |
| 4 | */ |
| 5 | .globl clear_page |
| 6 | .p2align 4 |
| 7 | clear_page: |
| 8 | xorl %eax,%eax |
| 9 | movl $4096/64,%ecx |
| 10 | .p2align 4 |
| 11 | .Lloop: |
| 12 | decl %ecx |
| 13 | #define PUT(x) movq %rax,x*8(%rdi) |
| 14 | movq %rax,(%rdi) |
| 15 | PUT(1) |
| 16 | PUT(2) |
| 17 | PUT(3) |
| 18 | PUT(4) |
| 19 | PUT(5) |
| 20 | PUT(6) |
| 21 | PUT(7) |
| 22 | leaq 64(%rdi),%rdi |
| 23 | jnz .Lloop |
| 24 | nop |
| 25 | ret |
| 26 | clear_page_end: |
| 27 | |
| 28 | /* C stepping K8 run faster using the string instructions. |
| 29 | It is also a lot simpler. Use this when possible */ |
| 30 | |
| 31 | #include <asm/cpufeature.h> |
| 32 | |
| 33 | .section .altinstructions,"a" |
| 34 | .align 8 |
| 35 | .quad clear_page |
| 36 | .quad clear_page_c |
| 37 | .byte X86_FEATURE_K8_C |
| 38 | .byte clear_page_end-clear_page |
| 39 | .byte clear_page_c_end-clear_page_c |
| 40 | .previous |
| 41 | |
| 42 | .section .altinstr_replacement,"ax" |
| 43 | clear_page_c: |
| 44 | movl $4096/8,%ecx |
| 45 | xorl %eax,%eax |
| 46 | rep |
| 47 | stosq |
| 48 | ret |
| 49 | clear_page_c_end: |
| 50 | .previous |