| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * vDSO provided cache flush routines | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), | 
|  | 5 | *                    IBM Corp. | 
|  | 6 | * | 
|  | 7 | * This program is free software; you can redistribute it and/or | 
|  | 8 | * modify it under the terms of the GNU General Public License | 
|  | 9 | * as published by the Free Software Foundation; either version | 
|  | 10 | * 2 of the License, or (at your option) any later version. | 
|  | 11 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/processor.h> | 
|  | 13 | #include <asm/ppc_asm.h> | 
|  | 14 | #include <asm/vdso.h> | 
| Sam Ravnborg | 0013a85 | 2005-09-09 20:57:26 +0200 | [diff] [blame] | 15 | #include <asm/asm-offsets.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 |  | 
|  | 17 | .text | 
|  | 18 |  | 
|  | 19 | /* | 
|  | 20 | * Default "generic" version of __kernel_sync_dicache. | 
|  | 21 | * | 
|  | 22 | * void __kernel_sync_dicache(unsigned long start, unsigned long end) | 
|  | 23 | * | 
|  | 24 | * Flushes the data cache & invalidate the instruction cache for the | 
|  | 25 | * provided range [start, end[ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | */ | 
|  | 27 | V_FUNCTION_BEGIN(__kernel_sync_dicache) | 
|  | 28 | .cfi_startproc | 
| Olof Johansson | fbe4817 | 2007-11-20 12:24:45 +1100 | [diff] [blame] | 29 | mflr	r12 | 
|  | 30 | .cfi_register lr,r12 | 
|  | 31 | mr	r11,r3 | 
|  | 32 | bl	__get_datapage@local | 
|  | 33 | mtlr	r12 | 
|  | 34 | mr	r10,r3 | 
|  | 35 |  | 
|  | 36 | lwz	r7,CFG_DCACHE_BLOCKSZ(r10) | 
|  | 37 | addi	r5,r7,-1 | 
|  | 38 | andc	r6,r11,r5		/* round low to line bdy */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | subf	r8,r6,r4		/* compute length */ | 
|  | 40 | add	r8,r8,r5		/* ensure we get enough */ | 
| Olof Johansson | fbe4817 | 2007-11-20 12:24:45 +1100 | [diff] [blame] | 41 | lwz	r9,CFG_DCACHE_LOGBLOCKSZ(r10) | 
|  | 42 | srw.	r8,r8,r9		/* compute line count */ | 
| Benjamin Herrenschmidt | 5d66da3 | 2005-11-16 13:54:32 +1100 | [diff] [blame] | 43 | crclr	cr0*4+so | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | beqlr				/* nothing to do? */ | 
|  | 45 | mtctr	r8 | 
| Olof Johansson | fbe4817 | 2007-11-20 12:24:45 +1100 | [diff] [blame] | 46 | 1:	dcbst	0,r6 | 
|  | 47 | add	r6,r6,r7 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | bdnz	1b | 
|  | 49 | sync | 
| Olof Johansson | fbe4817 | 2007-11-20 12:24:45 +1100 | [diff] [blame] | 50 |  | 
|  | 51 | /* Now invalidate the instruction cache */ | 
|  | 52 |  | 
|  | 53 | lwz	r7,CFG_ICACHE_BLOCKSZ(r10) | 
|  | 54 | addi	r5,r7,-1 | 
|  | 55 | andc	r6,r11,r5		/* round low to line bdy */ | 
|  | 56 | subf	r8,r6,r4		/* compute length */ | 
|  | 57 | add	r8,r8,r5 | 
|  | 58 | lwz	r9,CFG_ICACHE_LOGBLOCKSZ(r10) | 
|  | 59 | srw.	r8,r8,r9		/* compute line count */ | 
|  | 60 | crclr	cr0*4+so | 
|  | 61 | beqlr				/* nothing to do? */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | mtctr	r8 | 
| Olof Johansson | fbe4817 | 2007-11-20 12:24:45 +1100 | [diff] [blame] | 63 | 2:	icbi	0,r6 | 
|  | 64 | add	r6,r6,r7 | 
|  | 65 | bdnz	2b | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | isync | 
| Benjamin Herrenschmidt | bdceb6a | 2005-04-27 18:04:45 -0700 | [diff] [blame] | 67 | li	r3,0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | blr | 
|  | 69 | .cfi_endproc | 
|  | 70 | V_FUNCTION_END(__kernel_sync_dicache) | 
|  | 71 |  | 
|  | 72 |  | 
|  | 73 | /* | 
|  | 74 | * POWER5 version of __kernel_sync_dicache | 
|  | 75 | */ | 
|  | 76 | V_FUNCTION_BEGIN(__kernel_sync_dicache_p5) | 
|  | 77 | .cfi_startproc | 
| Benjamin Herrenschmidt | 5d66da3 | 2005-11-16 13:54:32 +1100 | [diff] [blame] | 78 | crclr	cr0*4+so | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | sync | 
|  | 80 | isync | 
| Benjamin Herrenschmidt | bdceb6a | 2005-04-27 18:04:45 -0700 | [diff] [blame] | 81 | li	r3,0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | blr | 
|  | 83 | .cfi_endproc | 
|  | 84 | V_FUNCTION_END(__kernel_sync_dicache_p5) | 
|  | 85 |  |