hive.tcl
2.89 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
#
# 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.
#
####
#### GLOBALS hive.tcl provides:
####
#### RUNNING_HIVE - defined to 1
#### numCells - the number of cells we are running with
#### cpusPerCell - the number of cpus per cell
#### CELL - the current CELL (just like CPU)
####
#
# This file is smoke-and-mirrors so the rest of standard.tcl
# runs with Hive.
#
# annotation set pc kernel:... {} turns into a loop over
# kernel0, kernel1, ...
# symbol x kernel:... turns into symbol x kernel$CELL
# where CELL is determined as
# $CPU / $cpusPerCell
#
# to directly access annotation and symbol after including
# this file, use annotation_raw and symbol_raw
#
##
## globals
##
set RUNNING_HIVE 1
if { ! [info exists cpusPerCell] } {
set cpusPerCell [expr $PARAM(CPU.Count) / $PARAM(HIVE.NumCells)]
}
for {set cell 0} {$cell<$PARAM(HIVE.NumCells)} {incr cell} {
symbol load kernel$cell [lindex $kernelNames $cell]
}
##
## special annotation command
##
rename annotation annotation_raw
proc annotation {cmdname args} {
global PARAM
if {$cmdname == "exec"} {
if {[llength $args] == 2} {
annotation_raw exec [lindex $args 0] [lindex $args 1]
} else {
annotation_raw exec [lindex $args 0]
}
return
}
if {$cmdname == "set"} {
set cmdarg [lindex $args 0]
if {($cmdarg=="pc") || ($cmdarg=="pre-pc") || ($cmdarg=="post-pc")} {
set symbexpr [split [lindex $args 1] :]
if {[lindex $symbexpr 0] == "kernel"} {
for {set cell 0} {$cell<$PARAM(HIVE.NumCells)} {incr cell} {
set symb "kernel$cell:[join [lrange $symbexpr 1 end] :]"
set args [lreplace $args 1 1 $symb]
eval annotation_raw set $args
}
return
}
}
eval annotation_raw set $args
return
}
eval annotation_raw $cmdname $args
}
##
## special symbol command
##
rename symbol symbol_raw
proc symbol {cmdname args} {
global PARAM CELL
if {($cmdname == "read") || ($cmdname == "set") || ($cmdname == "type")} {
set symb [lindex $args 0]
if {[string range $symb 0 6] == "kernel:"} {
set symb "kernel$CELL:[string range $symb 7 end]"
}
if {$cmdname == "set"} {
return [symbol_raw set $symb [lindex $args 1]]
} else {
return [symbol_raw $cmdname $symb]
}
}
eval symbol_raw $cmdname $args
}
##
## Annotations for booting and resetting slave cells.
##
# temporarily moved to hive2.tcl due to bug in tcl compiler
# which doesn't invalidate previously cached bindings upon rename
source "hive2.tcl"