summaryrefslogtreecommitdiff
path: root/arch/mn10300/mm/cache-dbg-inv-by-tag.S
blob: d8ec821e5f88de27551fec96059e2c99020881cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* MN10300 CPU cache invalidation routines, using direct tag flushing
 *
 * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public Licence
 * as published by the Free Software Foundation; either version
 * 2 of the Licence, or (at your option) any later version.
 */
#include <linux/sys.h>
#include <linux/linkage.h>
#include <asm/smp.h>
#include <asm/page.h>
#include <asm/cache.h>
#include <asm/irqflags.h>
#include <asm/cacheflush.h>
#include "cache.inc"

	.am33_2

	.globl	debugger_local_cache_flushinv_one_icache

###############################################################################
#
# void debugger_local_cache_flushinv_one(u8 *addr)
#
# Invalidate one particular cacheline if it's in the icache
#
###############################################################################
	ALIGN
	.globl	debugger_local_cache_flushinv_one_icache
	.type	debugger_local_cache_flushinv_one_icache,@function
debugger_local_cache_flushinv_one_icache:
	movm	[d3,a2],(sp)

	mov	CHCTR,a2
	movhu	(a2),d0
	btst	CHCTR_ICEN,d0
	beq	debugger_local_cache_flushinv_one_icache_end

	mov	d0,a1
	and	L1_CACHE_TAG_MASK,a1

	# read the tags from the tag RAM, and if they indicate a matching valid
	# cache line then we invalidate that line
	mov	ICACHE_TAG(0,0),a0
	mov	a1,d0
	and	L1_CACHE_TAG_ENTRY,d0
	add	d0,a0				# starting icache tag RAM
						# access address

	and	~(L1_CACHE_DISPARITY-1),a1	# determine comparator base
	or	L1_CACHE_TAG_VALID,a1
	mov	L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_VALID,d1

	LOCAL_CLI_SAVE(d3)

	# disable the icache
	movhu	(a2),d0
	and	~CHCTR_ICEN,d0
	movhu	d0,(a2)

	# and wait for it to calm down
	setlb
	movhu	(a2),d0
	btst	CHCTR_ICBUSY,d0
	lne

	# check all the way tags for this cache entry
	mov	(a0),d0				# read the tag in the way 0 slot
	xor	a1,d0
	and	d1,d0
	beq	debugger_local_icache_kill	# jump if matched

	add	L1_CACHE_WAYDISP,a0
	mov	(a0),d0				# read the tag in the way 1 slot
	xor	a1,d0
	and	d1,d0
	beq	debugger_local_icache_kill	# jump if matched

	add	L1_CACHE_WAYDISP,a0
	mov	(a0),d0				# read the tag in the way 2 slot
	xor	a1,d0
	and	d1,d0
	beq	debugger_local_icache_kill	# jump if matched

	add	L1_CACHE_WAYDISP,a0
	mov	(a0),d0				# read the tag in the way 3 slot
	xor	a1,d0
	and	d1,d0
	bne	debugger_local_icache_finish	# jump if not matched

debugger_local_icache_kill:
	mov	d0,(a0)				# kill the tag (D0 is 0 at this point)

debugger_local_icache_finish:
	# wait for the cache to finish what it's doing
	setlb
	movhu	(a2),d0
	btst	CHCTR_ICBUSY,d0
	lne

	# and reenable it
	or	CHCTR_ICEN,d0
	movhu	d0,(a2)
	movhu	(a2),d0

	# re-enable interrupts
	LOCAL_IRQ_RESTORE(d3)

debugger_local_cache_flushinv_one_icache_end:
	ret	[d3,a2],8
	.size	debugger_local_cache_flushinv_one_icache,.-debugger_local_cache_flushinv_one_icache

#ifdef CONFIG_MN10300_DEBUGGER_CACHE_INV_BY_TAG
	.globl	debugger_local_cache_flushinv_one
	.type	debugger_local_cache_flushinv_one,@function
debugger_local_cache_flushinv_one = debugger_local_cache_flushinv_one_icache
#endif