hive.tcl 2.89 KB
#
# 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"