⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bdoor.tcl

📁 一个用在mips体系结构中的操作系统
💻 TCL
字号:
## 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. ####### bdoor command###### Now slightly more complicated than it used to be: index all### variables with the PID of the bdoor process.  This allows### multiple simultaneous running bdoor processes (as happens,### for example, during multiple slave startup of a hive system### with more than two cells)####console "BDOOR.TCL: Setting bdoor ann at [symbol read bdoor::main:START]\n"### hack until BenW's stuff comes along    set bdoor(main)      0x400aac    set bdoor(mainEval)  0x400adc    set bdoor(mainLoop)  0x400ae8    set bdoor(addr)      0x10000070    set bdoor(countAddr) 0x10000000 #    symbol load bdoor $env(SIMOS_DIR)/runtime-files/bdoor#    set bdoor(main)      [symbol read bdoor::main:STARTOPT]    #    set bdoor(mainEval)  [symbol read bdoor::main:eval]#    set bdoor(mainLoop)  [symbol read bdoor::main:loop]             #    set bdoor(addr)      [symbol read bdoor::buf]#    set bdoor(countAddr) [symbol read bdoor::count]set bdoor(streamEnabled) 0annotation set pc $bdoor(main) -tag bdoor {    set pid $PID($CPU)    set machine $M($CPU)    set bdoor($machine,$pid,argc) $a0    set bdoor($machine,$pid,argv) $a1}annotation set pc $bdoor(mainEval) -tag bdoor {    set pid     $PID($CPU)    set machine $M($CPU)    if [info exists bdoor($machine,$pid,argc)] {        # this if test will fail if we are restoring from        # a checkpoint... the 'bdoor doCheckpoint' ran in the        # first execution of simos, setting argc and argv, but        # in the restore we hit the eval annotation first        set argc $bdoor($machine,$pid,argc)        set argv $bdoor($machine,$pid,argv)        if {$argc > 1} {            assert {$PROCESS($CPU) == "bdoor"}            set bdoorString ""            for {set i 1} {$i < $argc} {incr i} {                    set theArg $MEMORY([expr $argv+4*$i])                    set bdoorString "$bdoorString [readString $theArg]"#                  set bdoorString "$bdoorString [symbol read bdoor::((char**)$argv)<$i>]"            }            # console "TCL: $bdoorString\n"            # hack: ensure that stream is only called when this bdoor is            # active and will read the result.  If someone tries something            # fancy the pids won't match and the stream will be a nop.            set bdoor(streamEnabled) 1            set errno [catch { eval $bdoorString } msg]            set bdoor(streamEnabled) 0            if {$errno != 0} {                console "BDOOR ERROR: $msg\n"            }                    }                unset bdoor($machine,$pid,argc) bdoor($machine,$pid,argv)    }}annotation set pc $bdoor(mainLoop) -tag bdoor {    set pid $PID($CPU)    set machine $M($CPU)    if [info exists bdoor($machine,$pid,fid)] {        # this if test will fail if the user is not running        # a stream, or if we are restoring a checkpoint        set fid $bdoor($machine,$pid,fid)        set len $bdoor($machine,$pid,len)        set chunk $bdoor($machine,$pid,chunk)        set sizeLeft [expr $len - ($chunk * 4096)]        set bytes    [expr ($sizeLeft < 4096) ? $sizeLeft : 4096]        if {$bytes > 0} {            set MEMORY($bdoor(countAddr)) $bytes            # symbol set bdoor::count $bytes            binary putmem $fid $bdoor(addr) $bytes            incr bdoor($machine,$pid,chunk)        } else {            set MEMORY($bdoor(countAddr)) 0            #symbol set bdoor::count 0            binary close $fid            unset bdoor($machine,$pid,fid) bdoor($machine,$pid,len) bdoor($machine,$pid,chunk)        }    }}proc stream {hostFileName} {    global bdoor PID CPU M    if {! $bdoor(streamEnabled)} {        console "TCL BDOOR: can't invoke 'stream' if bdoor process is not active\n"    } else {        set pid $PID($CPU)        set machine $M($CPU)        if [file exists $hostFileName] {            set bdoor($machine,$pid,fid)   [binary open $hostFileName r]            set bdoor($machine,$pid,len)   [file size $hostFileName]            set bdoor($machine,$pid,chunk) 0        } else {            console "TCL BDOOR: file $hostFileName does not exist\n"        }    }}proc streamImmediate {streamData} {    global bdoor PID CPU M    if {! $bdoor(streamEnabled)} {        console "TCL BDOOR: can't invoke 'stream' if bdoor process is not active\n"    } else {        set pid $PID($CPU)        set machine $M($CPU)        set bdoor($machine,$pid,fid)   [binary immediate "$streamData"]        set bdoor($machine,$pid,len)   [string length $streamData]        set bdoor($machine,$pid,chunk) 0    }}registerUserAnns bdoor bdoor

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -