Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Cache flushing routines. |
| 3 | * |
David Mosberger-Tang | 2074615 | 2005-02-18 19:09:00 -0700 | [diff] [blame] | 4 | * Copyright (C) 1999-2001, 2005 Hewlett-Packard Co |
| 5 | * David Mosberger-Tang <davidm@hpl.hp.com> |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 6 | * |
| 7 | * 05/28/05 Zoltan Menyhart Dynamic stride size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <asm/asmmacro.h> |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | /* |
| 14 | * flush_icache_range(start,end) |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 15 | * |
| 16 | * Make i-cache(s) coherent with d-caches. |
| 17 | * |
| 18 | * Must deal with range from start to end-1 but nothing else (need to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * be careful not to touch addresses that may be unmapped). |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 20 | * |
| 21 | * Note: "in0" and "in1" are preserved for debugging purposes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | */ |
Prasanna S Panchamukhi | 1f7ad57 | 2005-09-06 15:19:30 -0700 | [diff] [blame] | 23 | .section .kprobes.text,"ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | GLOBAL_ENTRY(flush_icache_range) |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | .prologue |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 27 | alloc r2=ar.pfs,2,0,0,0 |
| 28 | movl r3=ia64_i_cache_stride_shift |
| 29 | mov r21=1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | ;; |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 31 | ld8 r20=[r3] // r20: stride shift |
| 32 | sub r22=in1,r0,1 // last byte address |
| 33 | ;; |
| 34 | shr.u r23=in0,r20 // start / (stride size) |
| 35 | shr.u r22=r22,r20 // (last byte address) / (stride size) |
| 36 | shl r21=r21,r20 // r21: stride size of the i-cache(s) |
| 37 | ;; |
| 38 | sub r8=r22,r23 // number of strides - 1 |
| 39 | shl r24=r23,r20 // r24: addresses for "fc.i" = |
| 40 | // "start" rounded down to stride boundary |
| 41 | .save ar.lc,r3 |
| 42 | mov r3=ar.lc // save ar.lc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | ;; |
| 44 | |
| 45 | .body |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 46 | mov ar.lc=r8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | ;; |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 48 | /* |
| 49 | * 32 byte aligned loop, even number of (actually 2) bundles |
| 50 | */ |
| 51 | .Loop: fc.i r24 // issuable on M0 only |
| 52 | add r24=r21,r24 // we flush "stride size" bytes per iteration |
| 53 | nop.i 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | br.cloop.sptk.few .Loop |
| 55 | ;; |
| 56 | sync.i |
| 57 | ;; |
| 58 | srlz.i |
| 59 | ;; |
Zoltan Menyhart | 08357f8 | 2005-06-03 05:36:00 -0700 | [diff] [blame] | 60 | mov ar.lc=r3 // restore ar.lc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | br.ret.sptk.many rp |
| 62 | END(flush_icache_range) |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * clflush_cache_range(start,size) |
| 66 | * |
| 67 | * Flush cache lines from start to start+size-1. |
| 68 | * |
| 69 | * Must deal with range from start to start+size-1 but nothing else |
| 70 | * (need to be careful not to touch addresses that may be |
| 71 | * unmapped). |
| 72 | * |
| 73 | * Note: "in0" and "in1" are preserved for debugging purposes. |
| 74 | */ |
| 75 | .section .kprobes.text,"ax" |
| 76 | GLOBAL_ENTRY(clflush_cache_range) |
| 77 | |
| 78 | .prologue |
| 79 | alloc r2=ar.pfs,2,0,0,0 |
| 80 | movl r3=ia64_cache_stride_shift |
| 81 | mov r21=1 |
| 82 | add r22=in1,in0 |
| 83 | ;; |
| 84 | ld8 r20=[r3] // r20: stride shift |
| 85 | sub r22=r22,r0,1 // last byte address |
| 86 | ;; |
| 87 | shr.u r23=in0,r20 // start / (stride size) |
| 88 | shr.u r22=r22,r20 // (last byte address) / (stride size) |
| 89 | shl r21=r21,r20 // r21: stride size of the i-cache(s) |
| 90 | ;; |
| 91 | sub r8=r22,r23 // number of strides - 1 |
| 92 | shl r24=r23,r20 // r24: addresses for "fc" = |
| 93 | // "start" rounded down to stride |
| 94 | // boundary |
| 95 | .save ar.lc,r3 |
| 96 | mov r3=ar.lc // save ar.lc |
| 97 | ;; |
| 98 | |
| 99 | .body |
| 100 | mov ar.lc=r8 |
| 101 | ;; |
| 102 | /* |
| 103 | * 32 byte aligned loop, even number of (actually 2) bundles |
| 104 | */ |
| 105 | .Loop_fc: |
| 106 | fc r24 // issuable on M0 only |
| 107 | add r24=r21,r24 // we flush "stride size" bytes per iteration |
| 108 | nop.i 0 |
| 109 | br.cloop.sptk.few .Loop_fc |
| 110 | ;; |
| 111 | sync.i |
| 112 | ;; |
| 113 | srlz.i |
| 114 | ;; |
| 115 | mov ar.lc=r3 // restore ar.lc |
| 116 | br.ret.sptk.many rp |
| 117 | END(clflush_cache_range) |