Path: blob/master/arch/microblaze/include/asm/cacheflush.h
26442 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2007-2009 Michal Simek <[email protected]>3* Copyright (C) 2007-2009 PetaLogix4* Copyright (C) 2007 John Williams <[email protected]>5* based on v850 version which was6* Copyright (C) 2001,02,03 NEC Electronics Corporation7* Copyright (C) 2001,02,03 Miles Bader <[email protected]>8*/910#ifndef _ASM_MICROBLAZE_CACHEFLUSH_H11#define _ASM_MICROBLAZE_CACHEFLUSH_H1213/* Somebody depends on this; sigh... */14#include <linux/mm.h>15#include <linux/io.h>1617/* Look at Documentation/core-api/cachetlb.rst */1819/*20* Cache handling functions.21* Microblaze has a write-through data cache, meaning that the data cache22* never needs to be flushed. The only flushing operations that are23* implemented are to invalidate the instruction cache. These are called24* after loading a user application into memory, we must invalidate the25* instruction cache to make sure we don't fetch old, bad code.26*/2728/* struct cache, d=dcache, i=icache, fl = flush, iv = invalidate,29* suffix r = range */30struct scache {31/* icache */32void (*ie)(void); /* enable */33void (*id)(void); /* disable */34void (*ifl)(void); /* flush */35void (*iflr)(unsigned long a, unsigned long b);36void (*iin)(void); /* invalidate */37void (*iinr)(unsigned long a, unsigned long b);38/* dcache */39void (*de)(void); /* enable */40void (*dd)(void); /* disable */41void (*dfl)(void); /* flush */42void (*dflr)(unsigned long a, unsigned long b);43void (*din)(void); /* invalidate */44void (*dinr)(unsigned long a, unsigned long b);45};4647/* microblaze cache */48extern struct scache *mbc;4950void microblaze_cache_init(void);5152#define enable_icache() mbc->ie();53#define disable_icache() mbc->id();54#define flush_icache() mbc->ifl();55#define flush_icache_range(start, end) mbc->iflr(start, end);56#define invalidate_icache() mbc->iin();57#define invalidate_icache_range(start, end) mbc->iinr(start, end);5859#define enable_dcache() mbc->de();60#define disable_dcache() mbc->dd();61/* FIXME for LL-temac driver */62#define invalidate_dcache() mbc->din();63#define invalidate_dcache_range(start, end) mbc->dinr(start, end);64#define flush_dcache() mbc->dfl();65#define flush_dcache_range(start, end) mbc->dflr(start, end);6667#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 168/* MS: We have to implement it because of rootfs-jffs2 issue on WB */69#define flush_dcache_page(page) \70do { \71unsigned long addr = (unsigned long) page_address(page); /* virtual */ \72addr = (u32)virt_to_phys((void *)addr); \73flush_dcache_range((unsigned) (addr), (unsigned) (addr) + PAGE_SIZE); \74} while (0);7576static inline void flush_dcache_folio(struct folio *folio)77{78unsigned long addr = folio_pfn(folio) << PAGE_SHIFT;7980flush_dcache_range(addr, addr + folio_size(folio));81}82#define flush_dcache_folio flush_dcache_folio8384#define flush_cache_page(vma, vmaddr, pfn) \85flush_dcache_range(pfn << PAGE_SHIFT, (pfn << PAGE_SHIFT) + PAGE_SIZE);8687static inline void copy_to_user_page(struct vm_area_struct *vma,88struct page *page, unsigned long vaddr,89void *dst, void *src, int len)90{91u32 addr = virt_to_phys(dst);92memcpy(dst, src, len);93if (vma->vm_flags & VM_EXEC) {94invalidate_icache_range(addr, addr + PAGE_SIZE);95flush_dcache_range(addr, addr + PAGE_SIZE);96}97}98#define copy_to_user_page copy_to_user_page99100#include <asm-generic/cacheflush.h>101102#endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */103104105