cacheflush.S 1.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * vDSO provided cache flush routines
 *
 * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
 *                    IBM Corp.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */
#include <asm/processor.h>
#include <asm/ppc_asm.h>
#include <asm/vdso.h>
15
#include <asm/asm-offsets.h>
L
Linus Torvalds 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28

	.text

/*
 * Default "generic" version of __kernel_sync_dicache.
 *
 * void __kernel_sync_dicache(unsigned long start, unsigned long end)
 *
 * Flushes the data cache & invalidate the instruction cache for the
 * provided range [start, end[
 */
V_FUNCTION_BEGIN(__kernel_sync_dicache)
  .cfi_startproc
29 30 31 32 33 34 35 36 37 38
	mflr	r12
  .cfi_register lr,r12
	mr	r11,r3
	bl	V_LOCAL_FUNC(__get_datapage)
	mtlr	r12
	mr	r10,r3

	lwz	r7,CFG_DCACHE_BLOCKSZ(r10)
	addi	r5,r7,-1
	andc	r6,r11,r5		/* round low to line bdy */
L
Linus Torvalds 已提交
39 40
	subf	r8,r6,r4		/* compute length */
	add	r8,r8,r5		/* ensure we get enough */
41 42
	lwz	r9,CFG_DCACHE_LOGBLOCKSZ(r10)
	srw.	r8,r8,r9		/* compute line count */
43
	crclr	cr0*4+so
L
Linus Torvalds 已提交
44 45
	beqlr				/* nothing to do? */
	mtctr	r8
46 47
1:	dcbst	0,r6
	add	r6,r6,r7
L
Linus Torvalds 已提交
48 49
	bdnz	1b
	sync
50 51 52 53 54 55 56 57 58 59 60 61

/* Now invalidate the instruction cache */

	lwz	r7,CFG_ICACHE_BLOCKSZ(r10)
	addi	r5,r7,-1
	andc	r6,r11,r5		/* round low to line bdy */
	subf	r8,r6,r4		/* compute length */
	add	r8,r8,r5
	lwz	r9,CFG_ICACHE_LOGBLOCKSZ(r10)
	srw.	r8,r8,r9		/* compute line count */
	crclr	cr0*4+so
	beqlr				/* nothing to do? */
L
Linus Torvalds 已提交
62
	mtctr	r8
63 64 65
2:	icbi	0,r6
	add	r6,r6,r7
	bdnz	2b
L
Linus Torvalds 已提交
66
	isync
67
	li	r3,0
L
Linus Torvalds 已提交
68 69 70 71 72 73 74 75 76 77
	blr
  .cfi_endproc
V_FUNCTION_END(__kernel_sync_dicache)


/*
 * POWER5 version of __kernel_sync_dicache
 */
V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
  .cfi_startproc
78
	crclr	cr0*4+so
L
Linus Torvalds 已提交
79 80
	sync
	isync
81
	li	r3,0
L
Linus Torvalds 已提交
82 83 84
	blr
  .cfi_endproc
V_FUNCTION_END(__kernel_sync_dicache_p5)