smashinsts.tcl
3.73 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#
# 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.
#
#
# set:
#
# smashlist: filename with list of 'addr funcname' pairs
# smashcycle: cycle in which to change instruction
# startindex: index into smash list to start search for a smashable inst
# switchdelay: number of periodic's to wait after smashed inst executed
# before switching to Embra
#
# smashtest : 1 -> this run is to filter smashlist by which instrs can be
# smashed. If so need to set
#
set smash_f [open $smashlist r]
for {set skipline 0} {$skipline < $startindex} {incr skipline} {
if {[gets $smash_f ignoreline] < 0} {
console "Premature end-of-file in smash list\n"
exit
}
}
if {$switchdelay < 1} {
console "smashinsts.tcl: ERROR. must set switchdelay to 1 or higher\n"
incr FORCETCLERROR
}
if {$smashtest == 0} {
if {[gets $smash_f smashline] < 0} {
console "Premature end-of-file in smash list\n"
exit
}
set switchtoembra 0
set smashfields [split $smashline]
set smashaddr [lindex $smashfields 2]
set smashcontrol [lindex $smashfields 3]
set smashfunc [lindex $smashfields 4]
log "SMASH will be cyc $smashcycle: [lrange $smashfields 2 end]\n"
annotation set cycle $smashcycle {
set okp [fault inst smash $smashaddr $smashcontrol $smashfunc]
if {$okp != "OK"} {
console "$smashcycle SMASH failed to smash instruction\n"
}
}
annotation set pc $smashaddr {
if {$CYCLES > $smashcycle} {
if {$SIMOS(EmbraPresent) && ($switchtoembra == 0)} {
log "SMASH $CYCLES executed smashed instruction\n"
incr switchtoembra
}
}
}
annotation set simos periodic {
if {$switchtoembra > 0} {
if {$switchtoembra <= $switchdelay} {
incr switchtoembra
if {$switchtoembra > $switchdelay} {
cpuEnter EMBRA_PAGE
}
}
}
}
} else {
annotation set simos enter {
if {$CPU == 0} {
while {! [eof $smash_f]} {
set againp RETRY
set rval [random 0xfff]
while {$againp == "RETRY"} {
if {[gets $smash_f smashline] < 0} {
break
}
set smashpair [split $smashline]
set againp [fault inst test [lindex $smashpair 0] $rval [lindex $smashpair 1]]
}
}
exit
}
}
}
##
## recovery timing
##
annotation set pc kernel::hive_LSET:lset_started {
log "RECOVERY lsetStart cycle=$CYCLES cpu=$CPU\n"
}
annotation set pc kernel::hive_LSET:lset_finished {
log "RECOVERY lsetFinish cycle=$CYCLES cpu=$CPU\n"
}
annotation set pc kernel::hive_RECV:recovery_started {
log "RECOVERY recoveryStart cycle=$CYCLES cpu=$CPU\n"
}
annotation set pc kernel::hive_RECV:recovery_finished {
log "RECOVERY recoveryFinish cycle=$CYCLES cpu=$CPU\n"
}
##
## remote fork
##
annotation set pc kernel:fork.c:procfork_remote:START {
log "REMFORK start cycle=$CYCLES cpu=$CPU to=$a0\n"
}
annotation set pc kernel:fork.c:procfork_remote:END {
log "REMFORK finish cycle=$CYCLES cpu=$CPU\n"
}
proc NewProc {} {
global CPU CYCLES CELL K0BASE u
set procp "(*(struct proc*)[symbol read kernel:user.h:$u.u_procp])"
log "PROCESS cell=$CELL "
log "pid=[symbol read kernel:timer.c:$procp.p_pid] "
log "name=[symbol read kernel:user.h:$u.u_comm] "
log "cycle=$CYCLES \n"
}
annotation set pc kernel::exece:END {
NewProc
}