18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Cache flush operations for the Hexagon architecture 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ASM_CACHEFLUSH_H 98c2ecf20Sopenharmony_ci#define _ASM_CACHEFLUSH_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* Cache flushing: 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * - flush_cache_all() flushes entire cache 168c2ecf20Sopenharmony_ci * - flush_cache_mm(mm) flushes the specified mm context's cache lines 178c2ecf20Sopenharmony_ci * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 188c2ecf20Sopenharmony_ci * - flush_cache_range(vma, start, end) flushes a range of pages 198c2ecf20Sopenharmony_ci * - flush_icache_range(start, end) flush a range of instructions 208c2ecf20Sopenharmony_ci * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache 218c2ecf20Sopenharmony_ci * - flush_icache_page(vma, pg) flushes(invalidates) a page for icache 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Need to doublecheck which one is really needed for ptrace stuff to work. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci#define LINESIZE 32 268c2ecf20Sopenharmony_ci#define LINEBITS 5 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* 298c2ecf20Sopenharmony_ci * Flush Dcache range through current map. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ciextern void flush_dcache_range(unsigned long start, unsigned long end); 328c2ecf20Sopenharmony_ci#define flush_dcache_range flush_dcache_range 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * Flush Icache range through current map. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ciextern void flush_icache_range(unsigned long start, unsigned long end); 388c2ecf20Sopenharmony_ci#define flush_icache_range flush_icache_range 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* 418c2ecf20Sopenharmony_ci * Memory-management related flushes are there to ensure in non-physically 428c2ecf20Sopenharmony_ci * indexed cache schemes that stale lines belonging to a given ASID aren't 438c2ecf20Sopenharmony_ci * in the cache to confuse things. The prototype Hexagon Virtual Machine 448c2ecf20Sopenharmony_ci * only uses a single ASID for all user-mode maps, which should 458c2ecf20Sopenharmony_ci * mean that they aren't necessary. A brute-force, flush-everything 468c2ecf20Sopenharmony_ci * implementation, with the name xxxxx_hexagon() is present in 478c2ecf20Sopenharmony_ci * arch/hexagon/mm/cache.c, but let's not wire it up until we know 488c2ecf20Sopenharmony_ci * it is needed. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ciextern void flush_cache_all_hexagon(void); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * This may or may not ever have to be non-null, depending on the 548c2ecf20Sopenharmony_ci * virtual machine MMU. For a native kernel, it's definitiely a no-op 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * This is also the place where deferred cache coherency stuff seems 578c2ecf20Sopenharmony_ci * to happen, classically... but instead we do it like ia64 and 588c2ecf20Sopenharmony_ci * clean the cache when the PTE is set. 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_cistatic inline void update_mmu_cache(struct vm_area_struct *vma, 628c2ecf20Sopenharmony_ci unsigned long address, pte_t *ptep) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci /* generic_ptrace_pokedata doesn't wind up here, does it? */ 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_civoid copy_to_user_page(struct vm_area_struct *vma, struct page *page, 688c2ecf20Sopenharmony_ci unsigned long vaddr, void *dst, void *src, int len); 698c2ecf20Sopenharmony_ci#define copy_to_user_page copy_to_user_page 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 728c2ecf20Sopenharmony_ci memcpy(dst, src, len) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciextern void hexagon_inv_dcache_range(unsigned long start, unsigned long end); 758c2ecf20Sopenharmony_ciextern void hexagon_clean_dcache_range(unsigned long start, unsigned long end); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#include <asm-generic/cacheflush.h> 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#endif 80