os-irix6.2.tcl
7.1 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#
# 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.
#
###
### This file is responsible for raising OS level annotations and tracking
### the current process.
###
###
####
#### init this module
####
annotation type osEvent enum {
startUser endUser
startKernel endKernel
startIdle endIdle
startSync endSync
switchIn switchOut
procstart procexit procexec
}
if [info exists R4000_KERNEL] {
proc inUserMode {} {
global sr
expr !($sr & 0x4) && !($sr &0x2) && (($sr & 0x18) == 0x10)
}
} else {
proc inUserMode {} {
global sr
expr ($sr & 0x02) != 0
}
}
####
#### the annotations
####
##
## process and idle tracking
##
annotation set simos enter {
set PID($CPU) -1
set PROCESS($CPU) ""
if {0} {
# We'll have to fix this later to restore checkpoints
if [catch {symbol read kernel::$private.p_curproc}] {
# booting
set PROCESS($CPU) "boot"
set PID($CPU) boot$CPU
} elseif {(([hex $pc] >= [symbol read kernel::idle:START])
&& ([hex $pc] <= ([symbol read kernel::idle:END] + 4)))
|| ((![catch {symbol read kernel::checkRunq:START}]) &&
([hex $pc] >= [symbol read kernel::checkRunq:START])
&& ([hex $pc] <= ([symbol read kernel::checkRunq:END]
+ 4)))} {
set PROCESS($CPU) "idle"
set PID($CPU) idle$CPU
} elseif {[symbol read kernel::$u.u_procp->p_sonproc] == $MCPU($CPU)} {
set PROCESS($CPU) [symbol read kernel::$u.u_comm]
set PID($CPU) [symbol read kernel::$u.u_procp->p_epid]
} else {
set PROCESS($CPU) "runq"
set PID($CPU) "runq$CPU"
}
}
}
proc newproc {pid process} {
global CPU PROCESS PID
annotation exec osEvent switchOut
log "newproc old ($PID($CPU),$PROCESS($CPU)) new ($pid, $process)\n"
set PROCESS($CPU) $process
set PID($CPU) $pid
annotation exec osEvent switchIn
}
annotation set pc kernel::idle:START {
newproc idle$CPU "idle"
annotation exec osEvent startIdle
}
annotation set pc kernel::idle:END {
if {$PROCESS($CPU) != "idle"} {
# this can happen when we take an interrupt on idle end
console "OS.TCL: ignoring end idle when process != idle $CYCLES\n"
} else {
annotation exec osEvent endIdle
newproc runq$CPU "runq"
}
}
annotation set pc kernel::swtch:START {
log "swtch: "
newproc runq$CPU "runq"
}
annotation set pc kernel::swtch:END {
log "switch end: "
newproc [symbol read kernel::$u.u_procp->p_epid] [symbol read kernel::$u.u_comm]
}
annotation set pc kernel::pswtch:START {
annotation exec osEvent procexit
log "pswtch: "
newproc runq$CPU "runq"
}
annotation set pc kernel:fork.c:procdup:END {
set pid [symbol read kernel::$u.u_procp->p_epid]
if {$pid != $PID($CPU)} {
# child process of the fork
console "procdup\n"
newproc $pid [symbol read kernel::$u.u_comm]
annotation exec osEvent procstart
}
}
annotation set pc kernel::exece:END {
annotation exec osEvent switchOut
set PROCESS($CPU) [symbol read kernel::$u.u_comm]
console "OS.TCL:setting process on exece to $PROCESS($CPU)\n"
annotation exec osEvent procexec
annotation exec osEvent switchIn
}
annotation set pc kernel::resume:END {
log "resume_end: "
newproc [symbol read kernel::$u.u_procp->p_epid] [symbol read kernel::$u.u_comm]
}
annotation set pc kernel::swtch:ann_swtch_resume_same {
log "swtch_resume_same: "
newproc [symbol read kernel::$u.u_procp->p_epid] [symbol read kernel::$u.u_comm]
}
annotation set pc kernel::resumekthread:END {
log "resumekthread: "
set curthread "(*(struct kthread*)[symbol read kernel::$private.p_curproc])"
newproc [symbol read kernel::$curthread.k_pid] [symbol read kernel::$curthread.k_name]
}
if {$detailLevel >= 2} {
##
## kernel - user transitions
##
set MAX_CPUS 256
for {set i 0} {$i < $MAX_CPUS} {incr i} {
set utlb($i) 0
}
annotation set utlb {
set utlb($CPU) 1
if {!($epc & $K0BASE)} {
annotation exec osEvent endUser
}
annotation exec osEvent startKernel
}
annotation set exc {
if {!$utlb($CPU)} {
if {!($epc & $K0BASE)} {
annotation exec osEvent endUser
}
annotation exec osEvent startKernel
}
set utlb($CPU) 0
}
annotation set inst rfe {
set utlb($CPU) 0
annotation exec osEvent endKernel
if [inUserMode] {
annotation exec osEvent startUser
}
}
##
## synchronization stuff
##
if ![catch {symbol read kernel::netisr_init} msg] {
# MP kernel
log "INFO: IRIX is multiprocessor\n"
annotation set pc kernel::io_splock:START {
annotation exec osEvent startSync
}
if [catch {symbol read kernel::io_splock:ann_splock_gotit}] {
annotation set pc kernel::io_splock:END {
annotation exec osEvent endSync
}
} else {
annotation set pc kernel::io_splock:ann_splock_gotit {
annotation exec osEvent endSync
}
}
annotation set pc kernel::spsemahi:START {
annotation exec osEvent startSync
}
annotation set pc kernel::spsemahi:ann_spsemahi_gotit {
annotation exec osEvent endSync
}
annotation set pc kernel::svsema:START {
annotation exec osEvent startSync
}
annotation set pc kernel::svsema:END {
annotation exec osEvent endSync
}
annotation set pc kernel::svsemax:START {
annotation exec osEvent startSync
}
annotation set pc kernel::svsemax:END {
annotation exec osEvent endSync
}
annotation set pc kernel::io_splockspl:START {
annotation exec osEvent startSync
}
annotation set pc kernel::io_splockspl:ann_splockspl_gotit {
annotation exec osEvent endSync
}
annotation set pc kernel::io_spunlockspl:START {
annotation exec osEvent startSync
}
annotation set pc kernel::io_spunlockspl:END {
annotation exec osEvent endSync
}
annotation set pc kernel::_trylock:START {
annotation exec osEvent startSync
}
annotation set pc kernel::_trylock:ann_trylock_gotit {
annotation exec osEvent endSync
}
annotation set pc kernel::spsema:START {
annotation exec osEvent startSync
}
annotation set pc kernel::spsema:END {
annotation exec osEvent endSync
}
} else {
log "INFO: IRIX is uniprocessor\n"
}
}