os-irix6.4.tcl
7.25 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#
# 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
}
set R4000_KERNEL 1
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
}
}
##
## Useful shortcuts
##
set curprocp "$private.p_curproc"
set current_pid "$curprocp->p_pid"
set current_comm "$curprocp->p_ui.u_comm"
set kthread "$private.p_curkthread"
set sthread "$kthread->k_sthread"
set kthread_id "$kthread.k_id"
set sthread_name "$kthread->k_sthread->st_name"
set ithread_name "$kthread->k_ithread->it_name"
##
## Give simos control on kernel panics
##
annotation set pc kernel::_assfail:START {
debug
}
#
# Called when switching between processes
#
proc NewProc {pid process ktid} {
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
set KTID($CPU) $ktid
annotation exec osEvent switchIn
}
##
## process and idle tracking
##
# Determining starting process
annotation set simos enter {
if {!$SIMOS(RestoringCpt)} {
set PROCESS($CPU) "boot"
set PID($CPU) boot$CPU
set KTID($CPU) boot$CPU
} elseif {(([hex $pc] >= [symbol read kernel::idle:START])
&& ([hex $pc] <= ([symbol read kernel::idle:END] + 4)))
|| ((![catch {symbol read kernel::vmp_find_work:START}]) &&
([hex $pc] >= [symbol read kernel::vmp_find_work:START])
&& ([hex $pc] <= ([symbol read kernel::vmp_find_work:END] + 4)))} {
set PROCESS($CPU) "idle"
set PID($CPU) idle$CPU
set KTID($CPU) idle$CPU
} elseif { [catch {symbol read kernel::$current_comm}] } {
console "OS: Problem getting process info\n"
set PROCESS($CPU) "None"
set PID($CPU) 0
set KTID($CPU) 0
} else {
set PROCESS($CPU) [symbol read kernel::$current_comm]
set PID($CPU) [symbol read kernel::$current_pid]
set KTID($CPU) [symbol read kernel::$kthread_id]
}
console "OS: $CPU starting in $PROCESS($CPU) - $PID($CPU) - $KTID($CPU)\n"
}
##
## TRACKING THREADS
##
#annotation set pc kernel::resumenewthread:START {
# console "$CPU SWITCHING FROM $PROCESS($CPU) $PID($CPU) "
#}
#
#annotation set pc kernel::resumeidle:START {
# console " TO IDLE\n"
#}
#annotation set pc kernel::itresume:START {
# console " TO ITHREAD\n"
#}
#annotation set pc kernel::stresume:START {
# console " TO STHREAD\n"
#}
#annotation set pc kernel::presume:START {
# console " TO USER PROCESS\n"
#}
#
#annotation set pc kernel:fork.c:procdup:START {
# console "PROCDUP called\n"
#}
annotation set pc kernel:fork.c:procdup:END {
console "OS: - PROCDUP\n"
set pid [symbol read kernel::$current_pid]
set ktid [symbol read kernel::$kthread_id]
if {$pid != $PID($CPU)} {
# child process of the fork
NewProc $pid [symbol read kernel::$current_comm] $ktid
annotation exec osEvent procstart
}
}
annotation set pc kernel::exece:END {
annotation exec osEvent switchOut
set PROCESS($CPU) [symbol read kernel::$current_comm]
console "OS: $CPU exece of $PROCESS($CPU) $PID($CPU)\n"
annotation exec osEvent procexec
annotation exec osEvent switchIn
}
# I think all user restores comes through here...
annotation set pc kernel::resume:END {
annotation exec osEvent switchOut
set pid [symbol read kernel::$current_pid]
set name [symbol read kernel::$current_comm]
set ktid [symbol read kernel::$kthread_id]
# console "OS: $CPU Scheduling $name - PID $pid - KTID $ktid\n"
NewProc $pid $name $ktid
annotation exec osEvent switchIn
}
annotation set pc kernel::pexitswtch:START {
annotation exec osEvent procexit
# console "OS: EXIT $CYCLES\n"
NewProc runq$CPU "runq" runq$CPU
}
# Service and Interrupt threads tracking
# The type is determined by null pointers for
annotation set pc kernel::resumethread:END {
annotation exec osEvent switchOut
set st [symbol read kernel::$sthread]
if {$st == 0} {
set type ITHREAD
set name [symbol read kernel::$ithread_name]
} else {
set type STHREAD
set name [symbol read kernel::$sthread_name]
}
set id [symbol read kernel::$kthread_id]
# console "$CPU Scheduling $type - $name $id\n"
NewProc $id $name $id
annotation exec osEvent switchIn
}
annotation set pc kernel::restartithread:END {
annotation exec osEvent switchOut
set type ITHREAD
set id [symbol read kernel::$kthread_id]
set name [symbol read kernel::$ithread_name]
# console "$CPU Scheduling (restart) $type $name $id\n"
NewProc $id $name $id
annotation exec osEvent switchIn
}
annotation set pc kernel::sthread_create:START {
# console "$CPU Scheduling CREATING STHREAD \n"
}
annotation set pc kernel::ithread_create:START {
# console "$CPU Scheduling CREATING ITHREAD \n"
}
##
## IDLE MODE
##
# This is a bit ugly. IRIX 6.4 implements a quick route to get
# back to the idle loop after handling interrupts, and to get the
# modes stuff hooked up, I need to know where resumeidle was being
# called from. I added a symbol to the kernel for this purpose.
# - Steve
set fastIdleRet [expr [symbol read kernel::resumeIdleJump:START] - 8]
set iJump 0
annotation set pc $fastIdleRet {
global iJump
set iJump 1
}
annotation set pc kernel::resumeidle:START {
global iJump
if {$iJump == 1} {
annotation exec osEvent endKernel
set iJump 0
} else {
NewProc idle$CPU "idle" idle$CPU
annotation exec osEvent startIdle
}
# console "$CPU Scheduling Idle\n"
}
annotation set pc kernel::resumeidle:END {
annotation exec osEvent endIdle
}
##
##
##
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
##
# IRIX 6.4 changed locks to mutex_spinlock - fix this
if { 0 } {
}
}