From c78095bd8c77fca2619769ff8efb639fd100e373 Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Fri, 25 Jun 2010 17:03:27 -0400 Subject: arch/tile: Split the icache flush code off to a generic header. This code is used in other places in our system than in Linux, so to share it we now implement it as an inline function in our low-level headers, and instantiate it in one file in Linux's arch/tile/lib. The file is now cacheflush.c and is C code rather than the strangely-named and assembler-implemented __invalidate_icache.S. Signed-off-by: Chris Metcalf Acked-by: Arnd Bergmann --- arch/tile/lib/Makefile | 2 +- arch/tile/lib/__invalidate_icache.S | 106 ------------------------------------ arch/tile/lib/cacheflush.c | 23 ++++++++ 3 files changed, 24 insertions(+), 107 deletions(-) delete mode 100644 arch/tile/lib/__invalidate_icache.S create mode 100644 arch/tile/lib/cacheflush.c (limited to 'arch/tile/lib') diff --git a/arch/tile/lib/Makefile b/arch/tile/lib/Makefile index ea9c209d33f..438af38bc9e 100644 --- a/arch/tile/lib/Makefile +++ b/arch/tile/lib/Makefile @@ -2,7 +2,7 @@ # Makefile for TILE-specific library files.. # -lib-y = checksum.o cpumask.o delay.o __invalidate_icache.o \ +lib-y = cacheflush.o checksum.o cpumask.o delay.o \ mb_incoherent.o uaccess.o \ memcpy_$(BITS).o memchr_$(BITS).o memmove_$(BITS).o memset_$(BITS).o \ strchr_$(BITS).o strlen_$(BITS).o diff --git a/arch/tile/lib/__invalidate_icache.S b/arch/tile/lib/__invalidate_icache.S deleted file mode 100644 index 92e70505912..00000000000 --- a/arch/tile/lib/__invalidate_icache.S +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2010 Tilera Corporation. All Rights Reserved. - * - * 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, version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for - * more details. - * A routine for synchronizing the instruction and data caches. - * Useful for self-modifying code. - * - * r0 holds the buffer address - * r1 holds the size in bytes - */ - -#include -#include - -#if defined(__NEWLIB__) || defined(__BME__) -#include -#else -#include -#endif - -#ifdef __tilegx__ -/* Share code among Tile family chips but adjust opcodes appropriately. */ -#define slt cmpltu -#define bbst blbst -#define bnezt bnzt -#endif - -#if defined(__tilegx__) && __SIZEOF_POINTER__ == 4 -/* Force 32-bit ops so pointers wrap around appropriately. */ -#define ADD_PTR addx -#define ADDI_PTR addxi -#else -#define ADD_PTR add -#define ADDI_PTR addi -#endif - - .section .text.__invalidate_icache, "ax" - .global __invalidate_icache - .type __invalidate_icache,@function - .hidden __invalidate_icache - .align 8 -__invalidate_icache: - FEEDBACK_ENTER(__invalidate_icache) - { - ADD_PTR r1, r0, r1 /* end of buffer */ - blez r1, .Lexit /* skip out if size <= 0 */ - } - { - ADDI_PTR r1, r1, -1 /* point to last byte to flush */ - andi r0, r0, -CHIP_L1I_LINE_SIZE() /* align to cache-line size */ - } - { - andi r1, r1, -CHIP_L1I_LINE_SIZE() /* last cache line to flush */ - mf - } -#if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE - { - moveli r4, CHIP_L1I_CACHE_SIZE() / PAGE_SIZE /* loop counter */ - move r2, r0 /* remember starting address */ - } -#endif - drain - { - slt r3, r0, r1 /* set up loop invariant */ -#if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE - moveli r6, PAGE_SIZE -#endif - } -.Lentry: - { - icoh r0 - ADDI_PTR r0, r0, CHIP_L1I_LINE_SIZE() /* advance buffer */ - } - { - slt r3, r0, r1 /* check if buffer < buffer + size */ - bbst r3, .Lentry /* loop if buffer < buffer + size */ - } -#if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE - { - ADD_PTR r2, r2, r6 - ADD_PTR r1, r1, r6 - } - { - move r0, r2 - addi r4, r4, -1 - } - { - slt r3, r0, r1 /* set up loop invariant */ - bnezt r4, .Lentry - } -#endif - drain -.Lexit: - jrp lr - -.Lend___invalidate_icache: - .size __invalidate_icache, \ - .Lend___invalidate_icache - __invalidate_icache diff --git a/arch/tile/lib/cacheflush.c b/arch/tile/lib/cacheflush.c new file mode 100644 index 00000000000..11b6164c209 --- /dev/null +++ b/arch/tile/lib/cacheflush.c @@ -0,0 +1,23 @@ +/* + * Copyright 2010 Tilera Corporation. All Rights Reserved. + * + * 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, version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for + * more details. + */ + +#include +#include +#include + + +void __flush_icache_range(unsigned long start, unsigned long end) +{ + invalidate_icache((const void *)start, end - start, PAGE_SIZE); +} -- cgit v1.2.3-18-g5258