Path: blob/master/arch/mn10300/mm/cache-dbg-flush-by-reg.S
10817 views
/* MN10300 CPU cache invalidation routines, using automatic purge registers1*2* Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public Licence7* as published by the Free Software Foundation; either version8* 2 of the Licence, or (at your option) any later version.9*/10#include <linux/sys.h>11#include <linux/linkage.h>12#include <asm/smp.h>13#include <asm/page.h>14#include <asm/cache.h>15#include <asm/irqflags.h>16#include <asm/cacheflush.h>17#include "cache.inc"1819.am33_22021###############################################################################22#23# void debugger_local_cache_flushinv(void)24# Flush the entire data cache back to RAM and invalidate the icache25#26###############################################################################27ALIGN28.globl debugger_local_cache_flushinv29.type debugger_local_cache_flushinv,@function30debugger_local_cache_flushinv:31#32# firstly flush the dcache33#34movhu (CHCTR),d035btst CHCTR_DCEN|CHCTR_ICEN,d036beq debugger_local_cache_flushinv_end3738mov DCPGCR,a03940mov epsw,d141and ~EPSW_IE,epsw42or EPSW_NMID,epsw43nop4445btst CHCTR_DCEN,d046beq debugger_local_cache_flushinv_no_dcache4748# wait for busy bit of area purge49setlb50mov (a0),d051btst DCPGCR_DCPGBSY,d052lne5354# set mask55clr d056mov d0,(DCPGMR)5758# area purge59#60# DCPGCR = DCPGCR_DCP61#62mov DCPGCR_DCP,d063mov d0,(a0)6465# wait for busy bit of area purge66setlb67mov (a0),d068btst DCPGCR_DCPGBSY,d069lne7071debugger_local_cache_flushinv_no_dcache:72#73# secondly, invalidate the icache if it is enabled74#75mov CHCTR,a076movhu (a0),d077btst CHCTR_ICEN,d078beq debugger_local_cache_flushinv_done7980invalidate_icache 08182debugger_local_cache_flushinv_done:83mov d1,epsw8485debugger_local_cache_flushinv_end:86ret [],087.size debugger_local_cache_flushinv,.-debugger_local_cache_flushinv8889###############################################################################90#91# void debugger_local_cache_flushinv_one(u8 *addr)92#93# Invalidate one particular cacheline if it's in the icache94#95###############################################################################96ALIGN97.globl debugger_local_cache_flushinv_one98.type debugger_local_cache_flushinv_one,@function99debugger_local_cache_flushinv_one:100movhu (CHCTR),d1101btst CHCTR_DCEN|CHCTR_ICEN,d1102beq debugger_local_cache_flushinv_one_end103btst CHCTR_DCEN,d1104beq debugger_local_cache_flushinv_one_no_dcache105106# round cacheline addr down107and L1_CACHE_TAG_MASK,d0108mov d0,a1109mov d0,d1110111# determine the dcache purge control reg address112mov DCACHE_PURGE(0,0),a0113and L1_CACHE_TAG_ENTRY,d0114add d0,a0115116# retain valid entries in the cache117or L1_CACHE_TAG_VALID,d1118119# conditionally purge this line in all ways120mov d1,(L1_CACHE_WAYDISP*0,a0)121122debugger_local_cache_flushinv_one_no_dcache:123#124# now try to flush the icache125#126mov CHCTR,a0127movhu (a0),d0128btst CHCTR_ICEN,d0129beq debugger_local_cache_flushinv_one_end130131LOCAL_CLI_SAVE(d1)132133mov ICIVCR,a0134135# wait for the invalidator to quiesce136setlb137mov (a0),d0138btst ICIVCR_ICIVBSY,d0139lne140141# set the mask142mov L1_CACHE_TAG_MASK,d0143mov d0,(ICIVMR)144145# invalidate the cache line at the given address146or ICIVCR_ICI,a1147mov a1,(a0)148149# wait for the invalidator to quiesce again150setlb151mov (a0),d0152btst ICIVCR_ICIVBSY,d0153lne154155LOCAL_IRQ_RESTORE(d1)156157debugger_local_cache_flushinv_one_end:158ret [],0159.size debugger_local_cache_flushinv_one,.-debugger_local_cache_flushinv_one160161162