blob: 09629aea3e4738d812280343756920edd55b0b74 [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 */
12#include <linux/config.h>
13#include <asm/processor.h>
14#include <asm/ppc_asm.h>
15#include <asm/vdso.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020016#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18 .text
19
20/*
21 * Default "generic" version of __kernel_sync_dicache.
22 *
23 * void __kernel_sync_dicache(unsigned long start, unsigned long end)
24 *
25 * Flushes the data cache & invalidate the instruction cache for the
26 * provided range [start, end[
27 *
28 * Note: all CPUs supported by this kernel have a 128 bytes cache
29 * line size so we don't have to peek that info from the datapage
30 */
31V_FUNCTION_BEGIN(__kernel_sync_dicache)
32 .cfi_startproc
33 li r5,127
34 andc r6,r3,r5 /* round low to line bdy */
35 subf r8,r6,r4 /* compute length */
36 add r8,r8,r5 /* ensure we get enough */
37 srwi. r8,r8,7 /* compute line count */
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110038 crclr cr0*4+so
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 beqlr /* nothing to do? */
40 mtctr r8
41 mr r3,r6
421: dcbst 0,r3
43 addi r3,r3,128
44 bdnz 1b
45 sync
46 mtctr r8
471: icbi 0,r6
48 addi r6,r6,128
49 bdnz 1b
50 isync
Benjamin Herrenschmidtbdceb6a2005-04-27 18:04:45 -070051 li r3,0
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 blr
53 .cfi_endproc
54V_FUNCTION_END(__kernel_sync_dicache)
55
56
57/*
58 * POWER5 version of __kernel_sync_dicache
59 */
60V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
61 .cfi_startproc
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110062 crclr cr0*4+so
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 sync
64 isync
Benjamin Herrenschmidtbdceb6a2005-04-27 18:04:45 -070065 li r3,0
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 blr
67 .cfi_endproc
68V_FUNCTION_END(__kernel_sync_dicache_p5)
69