cachetrace.tcl
3.68 KB
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
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
###
### cache_trace.tcl
###
###
### Cache_trace routines (First cut will change in the future)
### Set the variable cacheTraceFileName before sourcing the file
### if you want a name other than the default ./cachetrace
###
### Cache trace format
###
### | 32 bit physical address |
### | 20 bit virtual address | 1 bit kernel/user | 2 bit type of cache miss | 9 lower bits of pid |
### Note!!! currently the user/kernel mode and pid are correct only for the uniprocessor case
###
###
set cachetracePageMask 0xfffff000
set cachetracePidMask 0x000001ff
set cachetraceImiss 0x000
set cachetraceRmiss 0x200
set cachetraceWmiss 0x400
set cachetraceUmiss 0x600
set cachetraceIsKernel 0x800
set cachetraceTick 0xffffffff
if {![info exists cacheTraceFileName]} {
set cacheTraceFileName ./cachetrace
}
set cachetraceFd [binary open $cacheTraceFileName "w"]
annotation set scache instr -tag cachetrace {
if {($PROCESS($ScacheCPU) == "idle") || ($PROCESS($ScacheCPU) == "runq")} {
set tmpPid 0
} else {
set tmpPid $PID($ScacheCPU)
}
set cachetraceVaddr [expr ($ScacheVaddr & $cachetracePageMask) | ($tmpPid & $cachetracePidMask) | $cachetraceImiss]
if {![inUserMode]} {
set cachetraceVaddr [expr $cachetraceVaddr | $cachetraceIsKernel]
}
binary write $cachetraceFd $ScachePaddr $cachetraceVaddr
}
annotation set scache read -tag cachetrace {
if {($PROCESS($ScacheCPU) == "idle") || ($PROCESS($ScacheCPU) == "runq")} {
set tmpPid 0
} else {
set tmpPid $PID($ScacheCPU)
}
set cachetraceVaddr [expr ($ScacheVaddr & $cachetracePageMask) | ($tmpPid & $cachetracePidMask) | $cachetraceRmiss]
if {![inUserMode]} {
set cachetraceVaddr [expr $cachetraceVaddr | $cachetraceIsKernel]
}
binary write $cachetraceFd $ScachePaddr $cachetraceVaddr
}
annotation set scache write -tag cachetrace {
if {($PROCESS($ScacheCPU) == "idle") || ($PROCESS($ScacheCPU) == "runq")} {
set tmpPid 0
} else {
set tmpPid $PID($ScacheCPU)
}
set cachetraceVaddr [expr ($ScacheVaddr & $cachetracePageMask) | ($tmpPid & $cachetracePidMask) | $cachetraceWmiss]
if {![inUserMode]} {
set cachetraceVaddr [expr $cachetraceVaddr | $cachetraceIsKernel]
}
binary write $cachetraceFd $ScachePaddr $cachetraceVaddr
}
annotation set scache upg -tag cachetrace {
if {($PROCESS($ScacheCPU) == "idle") || ($PROCESS($ScacheCPU) == "runq")} {
set tmpPid 0
} else {
set tmpPid $PID($ScacheCPU)
}
set cachetraceVaddr [expr ($ScacheVaddr & $cachetracePageMask) | ($tmpPid & $cachetracePidMask) | $cachetraceUmiss]
if {![inUserMode]} {
set cachetraceVaddr [expr $cachetraceVaddr | $cachetraceIsKernel]
}
binary write $cachetraceFd $ScachePaddr $cachetraceVaddr
}
annotation set scache sc_upg -tag cachetrace {
if {($PROCESS($ScacheCPU) == "idle") || ($PROCESS($ScacheCPU) == "runq")} {
set tmpPid 0
} else {
set tmpPid $PID($ScacheCPU)
}
set cachetraceVaddr [expr ($ScacheVaddr & $cachetracePageMask) | ($tmpPid & $cachetracePidMask) | $cachetraceUmiss]
if {![inUserMode]} {
set cachetraceVaddr [expr $cachetraceVaddr | $cachetraceIsKernel]
}
binary write $cachetraceFd $ScachePaddr $cachetraceVaddr
}
annotation set pc [symbol read kernel::clock:START] -tag cachetrace {
if {$ScacheCPU == 0} {
binary write $cachetraceFd $cachetraceTick $cachetraceTick
}
}
annotation set simos exit -tag cachetrace {
binary close $cachetraceFd
}