blob: 69c5af2b3c96cfd46a85a2c250a9727e585fcabf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/processor.h>
13#include <asm/ppc_asm.h>
14#include <asm/vdso.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020015#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
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 Torvalds1da177e2005-04-16 15:20:36 -070026 */
27V_FUNCTION_BEGIN(__kernel_sync_dicache)
28 .cfi_startproc
Olof Johanssonfbe48172007-11-20 12:24:45 +110029 mflr r12
30 .cfi_register lr,r12
31 mr r11,r3
32 bl V_LOCAL_FUNC(__get_datapage)
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 Torvalds1da177e2005-04-16 15:20:36 -070039 subf r8,r6,r4 /* compute length */
40 add r8,r8,r5 /* ensure we get enough */
Olof Johanssonfbe48172007-11-20 12:24:45 +110041 lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
42 srw. r8,r8,r9 /* compute line count */
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110043 crclr cr0*4+so
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 beqlr /* nothing to do? */
45 mtctr r8
Olof Johanssonfbe48172007-11-20 12:24:45 +1100461: dcbst 0,r6
47 add r6,r6,r7
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 bdnz 1b
49 sync
Olof Johanssonfbe48172007-11-20 12:24:45 +110050
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 Torvalds1da177e2005-04-16 15:20:36 -070062 mtctr r8
Olof Johanssonfbe48172007-11-20 12:24:45 +1100632: icbi 0,r6
64 add r6,r6,r7
65 bdnz 2b
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 isync
Benjamin Herrenschmidtbdceb6a2005-04-27 18:04:45 -070067 li r3,0
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 blr
69 .cfi_endproc
70V_FUNCTION_END(__kernel_sync_dicache)
71
72
73/*
74 * POWER5 version of __kernel_sync_dicache
75 */
76V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
77 .cfi_startproc
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110078 crclr cr0*4+so
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 sync
80 isync
Benjamin Herrenschmidtbdceb6a2005-04-27 18:04:45 -070081 li r3,0
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 blr
83 .cfi_endproc
84V_FUNCTION_END(__kernel_sync_dicache_p5)