From d08545fc473e073bc39b132234029abc0ab5308a Mon Sep 17 00:00:00 2001 From: "Walter F.J. Mueller" Date: Sat, 7 Jan 2017 18:28:29 +0100 Subject: [PATCH] re-shuffle rw11::shell code --- tools/tcl/ibd_ibmon/util.tcl | 86 ++++++++++++++++++--- tools/tcl/rw11/dmcmon.tcl | 51 ++++++++++--- tools/tcl/rw11/shell.tcl | 143 +++++++++++++++++------------------ 3 files changed, 183 insertions(+), 97 deletions(-) diff --git a/tools/tcl/ibd_ibmon/util.tcl b/tools/tcl/ibd_ibmon/util.tcl index 9683ef10..a33f4bd2 100644 --- a/tools/tcl/ibd_ibmon/util.tcl +++ b/tools/tcl/ibd_ibmon/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 834 2016-12-30 15:19:09Z mueller $ +# $Id: util.tcl 837 2017-01-02 19:23:34Z mueller $ # -# Copyright 2015-2016 by Walter F.J. Mueller +# Copyright 2015-2017 by Walter F.J. Mueller # # This program is free software; you may redistribute and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-01-02 837 1.1.1 add procs ime,imf # 2016-12-30 833 1.1 add proc filter # 2015-12-28 721 1.0.2 add regmap_add defs; add symbolic register dump # 2015-07-25 704 1.0.1 start: use args and args2opts @@ -46,8 +47,9 @@ namespace eval ibd_ibmon { rw11util::regmap_add ibd_ibmon im.cntl {r? CNTL} rw11util::regmap_add ibd_ibmon im.stat {r? STAT} rw11util::regmap_add ibd_ibmon im.addr {r? ADDR} + # - # setup: amap definitions for ibd_ibmon + # setup: amap definitions for ibd_ibmon ------------------------------------ # proc setup {{cpu "cpu0"} {base 0160000}} { $cpu imap -insert im.cntl [expr {$base + 000}] @@ -58,7 +60,7 @@ namespace eval ibd_ibmon { $cpu imap -insert im.data [expr {$base + 012}] } # - # init: reset ibd_ibmon (stop, reset alim) + # init: reset ibd_ibmon (stop, reset alim) --------------------------------- # proc init {{cpu "cpu0"}} { $cpu cp \ @@ -68,7 +70,7 @@ namespace eval ibd_ibmon { -wibr im.addr 0x0000 } # - # start: start the ibmon + # start: start the ibmon --------------------------------------------------- # proc start {{cpu "cpu0"} args} { args2opts opts { conena 1 remena 1 locena 1 wena 1 } {*}$args @@ -80,7 +82,7 @@ namespace eval ibd_ibmon { ] } # - # start: setup filter window + # start: setup filter window ----------------------------------------------- # proc filter {{cpu "cpu0"} {lolim 0} {hilim 0177776}} { $cpu cp -wibr im.lolim $lolim \ @@ -88,13 +90,13 @@ namespace eval ibd_ibmon { } # - # stop: stop the ibmon + # stop: stop the ibmon ----------------------------------------------------- # proc stop {{cpu "cpu0"}} { $cpu cp -wibr im.cntl [regbld ibd_ibmon::CNTL stop] } # - # read: read nent last entries (by default all) + # read: read nent last entries (by default all) ---------------------------- # proc read {{cpu "cpu0"} {nent -1}} { $cpu cp -ribr im.addr raddr \ @@ -167,7 +169,7 @@ namespace eval ibd_ibmon { return $rval } # - # print: print ibmon data (optionally also read them) + # print: print ibmon data (optionally also read them) ---------------------- # proc print {{cpu "cpu0"} {mondat -1}} { @@ -258,7 +260,7 @@ namespace eval ibd_ibmon { } # - # raw_edata: prepare edata lists for raw data reads in tests + # raw_edata: prepare edata lists for raw data reads in tests --------------- # args is list of {eflag eaddr edata enbusy} sublists proc raw_edata {edat emsk args} { @@ -293,7 +295,7 @@ namespace eval ibd_ibmon { } # - # raw_check: check raw data against expect values prepared by raw_edata + # raw_check: check raw data against expect values prepared by raw_edata ---- # proc raw_check {{cpu "cpu0"} edat emsk} { @@ -304,5 +306,65 @@ namespace eval ibd_ibmon { -ribr im.addr -edata [llength $edat] return "" } - + + # + # === high level procs: compact usage (also by rw11:shell) ================= + # + # ime: ibmon enable -------------------------------------------------------- + # + proc ime {{cpu "cpu0"} {mode "lrc"}} { + if {![regexp {^[crl]+n?$} $mode]} { + error "ime-E: bad mode '$mode', use \[lrc\] and n" + } + set locena [string match *l* $mode] + set remena [string match *r* $mode] + set conena [string match *c* $mode] + set wena 1 + if {[string match *n* $mode]} {set wena 0} + + ibd_ibmon::start $cpu \ + locena $locena remena $remena conena $conena wena $wena + return "" + } + + # + # imf: ibmon filter -------------------------------------------------------- + # + proc imf {{cpu "cpu0"} {lo ""} {hi ""}} { + set lolim 0 + set hilim 0177776 + + if {$lo ne ""} { + set lolist [split $lo "/"] + if {[llength $lolist] > 2} { + error "imf-E: bad lo specifier '$lo', use val or val/len" + } + set lolim [imap_reg2addr $cpu [lindex $lolist 0]] + if {[llength $lolist] == 2} { + set hilim [expr {$lolim + 2*([lindex $lolist 1]-1)}] + } + } + + if {$hi ne ""} { + set hilim [imap_reg2addr $cpu $hi] + } + + if {$lolim > $hilim} {error "imf-E: hilim must be >= lolim"} + + ibd_ibmon::filter $cpu $lolim $hilim + } + + # + # imap_reg2addr: convert register to address ------------------------------- + # + proc imap_reg2addr {cpu reg} { + if {[$cpu imap -testname $reg]} { + return [$cpu imap $reg] + } elseif {[string is integer $reg]} { + return $reg + } else { + error "imap_reg2addr-E: unknown register '$reg'" + } + } + } diff --git a/tools/tcl/rw11/dmcmon.tcl b/tools/tcl/rw11/dmcmon.tcl index a01dce54..d060bb4f 100644 --- a/tools/tcl/rw11/dmcmon.tcl +++ b/tools/tcl/rw11/dmcmon.tcl @@ -1,6 +1,6 @@ -# $Id: dmcmon.tcl 834 2016-12-30 15:19:09Z mueller $ +# $Id: dmcmon.tcl 837 2017-01-02 19:23:34Z mueller $ # -# Copyright 2015-2016 by Walter F.J. Mueller +# Copyright 2015-2017 by Walter F.J. Mueller # # This program is free software; you may redistribute and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-01-02 837 1.0.2 add procs cme,cml # 2016-12-29 833 1.0.1 cm_print: protect against empty lists # 2015-08-05 708 1.0 Initial version # 2015-07-05 697 0.1 First draft @@ -52,7 +53,7 @@ namespace eval rw11 { variable CM_D8_VMERR_RSV 05 # - # cm_start: start the dmcmon + # cm_start: start the dmcmon ----------------------------------------------- # proc cm_start {{cpu "cpu0"} args} { args2opts opts { mwsup 0 imode 0 wena 1 } {*}$args @@ -62,14 +63,14 @@ namespace eval rw11 { } # - # cm_stop: stop the dmcmon + # cm_stop: stop the dmcmon ------------------------------------------------- # proc cm_stop {{cpu "cpu0"}} { $cpu cp -wreg cm.cntl [regbld rw11::CM_CNTL stop] } # - # cm_read: read nent last entries (by default all) + # cm_read: read nent last entries (by default all) ------------------------- # returns a list, 1st entry descriptor, rest 9-tuples in d0,..,d8 order # proc cm_read {{cpu "cpu0"} {nent -1}} { @@ -115,7 +116,7 @@ namespace eval rw11 { } # - # cm_print: convert raw into human readable format + # cm_print: convert raw into human readable format ------------------------- # proc cm_print {cmraw} { if {![llength $cmraw]} {return;} @@ -278,7 +279,7 @@ namespace eval rw11 { } # - # cm_raw2txt: converts raw data list into a storable text format + # cm_raw2txt: converts raw data list into a storable text format ----------- # proc cm_raw2txt {cmraw} { set len [llength $cmraw] @@ -297,7 +298,7 @@ namespace eval rw11 { } # - # cm_txt2raw: converts storable text format back in raw data list + # cm_txt2raw: converts storable text format back in raw data list ---------- # proc cm_txt2raw {text} { set rval {} @@ -325,7 +326,7 @@ namespace eval rw11 { } # - # cm_get_snum2state + # cm_get_snum2state -------------------------------------------------------- # proc cm_get_snum2state {} { set retrobase $::env(RETROBASE) @@ -362,7 +363,7 @@ namespace eval rw11 { } # - # cm_read_lint: read lint (last instruction) context + # cm_read_lint: read lint (last instruction) context ----------------------- # returns list of lists # 1. stat,ipc,ireg # 2. mal list (CM_STAT.malcnt entries) @@ -390,7 +391,7 @@ namespace eval rw11 { } # - # cm_print_lint: print lint (last instruction) context + # cm_print_lint: print lint (last instruction) context --------------------- # proc cm_print_lint {cmlraw} { set stat [lindex $cmlraw 0 0] @@ -460,4 +461,32 @@ namespace eval rw11 { return $rval } + + # + # === high level procs: compact usage (also by rw11:shell) ================= + # + # cme: dmcmon enable ------------------------------------------------------- + # + proc cme {{cpu "cpu0"} {mode "i"}} { + if {![regexp {^[is]?n?$} $mode]} { + error "cme-E: bad mode '$mode', only i,s and n allowed" + } + + set imode [string match *i* $mode] + set mwsup [string match *s* $mode] + set wena 1 + if {[string match *n* $mode]} {set wena 0} + + rw11::cm_start $cpu imode $imode mwsup $mwsup wena $wena + return "" + } + + # + # cml: dmcmon list --------------------------------------------------------- + # + proc cml {{cpu "cpu0"} {nent -1}} { + rw11::cm_stop $cpu + return [rw11::cm_print [rw11::cm_read $cpu $nent]] + } + } diff --git a/tools/tcl/rw11/shell.tcl b/tools/tcl/rw11/shell.tcl index 4df664c3..f5306339 100644 --- a/tools/tcl/rw11/shell.tcl +++ b/tools/tcl/rw11/shell.tcl @@ -1,6 +1,6 @@ -# $Id: shell.tcl 835 2016-12-31 10:00:14Z mueller $ +# $Id: shell.tcl 837 2017-01-02 19:23:34Z mueller $ # -# Copyright 2015-2016 by Walter F.J. Mueller +# Copyright 2015-2017 by Walter F.J. Mueller # # This program is free software; you may redistribute and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-01-02 837 2.2 code re-shuffle; add cpu status in prompt # 2016-12-31 834 2.1 add '@' command # 2016-12-30 833 2.0 major overhaul # 2015-12-23 717 1.1 add e,g,d commands; fix shell_tin @@ -29,6 +30,7 @@ namespace eval rw11 { variable shell_depth 0; # recursion stopper variable shell_cpu "cpu0"; # current cpu command + variable shell_cpu_stat ""; # cpu status variable shell_cme_pend 1; # .cme pending variable shell_cme_mode "i"; # mode for pending .cme variable shell_attnhdl_added 0 @@ -40,7 +42,8 @@ namespace eval rw11 { proc shell_start {} { variable shell_cpu variable shell_attnhdl_added - variable shell_eofchar_save + variable shell_eofchar_save + variable shell_cpu_stat global tirri_interactive # quit if shell already active @@ -64,7 +67,7 @@ namespace eval rw11 { rename ::tclreadline::prompt1 ::rw11::shell_prompt1_save namespace eval ::tclreadline { proc prompt1 {} { - return "${rw11::shell_cpu}> " + return "${rw11::shell_cpu_stat}${rw11::shell_cpu}> " } } # disable ^D (and save old setting) @@ -125,6 +128,7 @@ namespace eval rw11 { proc shell_attncpu {} { puts "CPU attention" puts [cpu0 show -r0ps] + shell_update_cpu_stat puts -nonewline [::tclreadline::prompt1] flush stdout return "" @@ -229,10 +233,8 @@ namespace eval rw11 { # proc shell_cs {{nstep 1}} { variable shell_cpu - variable shell_cme_pend - variable shell_cme_mode - if {$shell_cme_pend} { shell_cme $shell_cme_mode } + shell_cme_ifpend set rval {} for {set i 0} {$i < $nstep} {incr i} { @@ -243,6 +245,7 @@ namespace eval rw11 { $shell_cpu cp -rstat stat if {[regget rw11::CP_STAT(rust) $stat] != $rw11::RUST_STEP} {break} } + shell_update_cpu_stat return $rval } @@ -251,10 +254,10 @@ namespace eval rw11 { # proc shell_cr {} { variable shell_cpu - variable shell_cme_pend - variable shell_cme_mode + variable shell_cpu_stat - if {$shell_cme_pend} { shell_cme $shell_cme_mode } + shell_cme_ifpend + set shell_cpu_stat "g:"; rw11::hb_clear $shell_cpu $shell_cpu cp -resume @@ -267,6 +270,7 @@ namespace eval rw11 { proc shell_csus {} { variable shell_cpu $shell_cpu cp -suspend + shell_update_cpu_stat return "" } @@ -276,6 +280,7 @@ namespace eval rw11 { proc shell_csto {} { variable shell_cpu $shell_cpu cp -stop + shell_update_cpu_stat return "" } @@ -286,6 +291,7 @@ namespace eval rw11 { variable shell_cpu $shell_cpu cp -stop $shell_cpu cp -creset + shell_update_cpu_stat return "" } @@ -294,10 +300,10 @@ namespace eval rw11 { # proc shell_csta {{pc -1}} { variable shell_cpu - variable shell_cme_pend - variable shell_cme_mode + variable shell_cpu_stat - if {$shell_cme_pend} { shell_cme $shell_cme_mode } + shell_cme_ifpend + set shell_cpu_stat "g:"; if {$pc == -1} { $shell_cpu cp -start @@ -307,6 +313,24 @@ namespace eval rw11 { return "" } + # + # shell_cme_ifpend: do cme if pending and cmon available ------------------- + # + proc shell_cme_ifpend {} { + variable shell_cpu + variable shell_cme_pend + variable shell_cme_mode + + if {$shell_cme_pend} { + if {[$shell_cpu rmap -testname "cm.cntl"]} { + shell_cme $shell_cme_mode + } else { + set shell_cme_pend 0 + } + } + return ""; + } + # # shell_cme: cmon enable --------------------------------------------------- # @@ -315,20 +339,11 @@ namespace eval rw11 { variable shell_cme_pend variable shell_cme_mode - if {![shell_test_device $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} - - if {![regexp {^[is]?n?$} $mode]} { - error ".cme-E: bad mode '$mode', only i,s and n allowed" - } + if {![shell_test_device $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} + rw11::cme $shell_cpu $mode set shell_cme_pend 0 set shell_cme_mode $mode - - set imode [string match *i* $mode] - set mwsup [string match *s* $mode] - set wena 1 - if {[string match *n* $mode]} {set wena 0} - rw11::cm_start $shell_cpu imode $imode mwsup $mwsup wena $wena return "" } @@ -339,7 +354,7 @@ namespace eval rw11 { variable shell_cpu variable shell_cme_pend - if {![shell_test_device $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} + if {![shell_test_device $shell_cpu "cmd" "cm.cntl" "dmcmon"]} {return ""} set shell_cme_pend 0 rw11::cm_stop $shell_cpu @@ -352,11 +367,10 @@ namespace eval rw11 { proc shell_cml {{nent -1}} { variable shell_cpu variable shell_cme_pend - if {![shell_test_device $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} + if {![shell_test_device $shell_cpu "cml" "cm.cntl" "dmcmon"]} {return ""} set shell_cme_pend 1 - rw11::cm_stop $shell_cpu - return [rw11::cm_print [rw11::cm_read $shell_cpu $nent]] + return [rw11::cml $shell_cpu $nent] } # @@ -366,17 +380,7 @@ namespace eval rw11 { variable shell_cpu if {![shell_test_device $shell_cpu "ime" "im.cntl" "ibmon"]} {return ""} - if {![regexp {^[crl]+n?$} $mode]} { - error ".ime-E: bad mode '$mode', use \[lrc\] and n" - } - set locena [string match *l* $mode] - set remena [string match *r* $mode] - set conena [string match *c* $mode] - set wena 1 - if {[string match *n* $mode]} {set wena 0} - - ibd_ibmon::start $shell_cpu \ - locena $locena remena $remena conena $conena wena $wena + ibd_ibmon::ime $shell_cpu $mode return "" } @@ -385,7 +389,7 @@ namespace eval rw11 { # proc shell_imd {} { variable shell_cpu - if {![shell_test_device $shell_cpu "ime" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_device $shell_cpu "imd" "im.cntl" "ibmon"]} {return ""} ibd_ibmon::stop $shell_cpu return "" @@ -398,28 +402,7 @@ namespace eval rw11 { variable shell_cpu if {![shell_test_device $shell_cpu "imf" "im.cntl" "ibmon"]} {return ""} - set lolim 0 - set hilim 0177776 - - if {$lo ne ""} { - set lolist [split $lo "/"] - if {[llength $lolist] > 2} { - error ".iml-E: bad lo specifier '$lo', use val or val/len" - } - set lolim [shell_conv_register $shell_cpu [lindex $lolist 0]] - if {[llength $lolist] == 2} { - set hilim [expr {$lolim + 2*([lindex $lolist 1]-1)}] - } - } - - if {$hi ne ""} { - set hilim [shell_conv_register $shell_cpu $hi] - } - - if {$lolim > $hilim} {error ".iml-E: hilim must be >= lolim"} - - ibd_ibmon::filter $shell_cpu $lolim $hilim - + ibd_ibmon::imf $shell_cpu $lo $hi return "" } @@ -428,7 +411,7 @@ namespace eval rw11 { # proc shell_iml {{nent -1}} { variable shell_cpu - if {![shell_test_device $shell_cpu "ime" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_device $shell_cpu "iml" "im.cntl" "ibmon"]} {return ""} set mondat [ibd_ibmon::read $shell_cpu $nent] if {![llength $mondat]} {return ""} return [ibd_ibmon::print $shell_cpu $mondat] @@ -589,7 +572,7 @@ namespace eval rw11 { append rval "\n .imf ?lo? ?hi? ; ibmon filter" append rval "\n .iml ?nent? ; ibmon list" } - append rval "\console (tta0) direct input:" + append rval "\nconsole (tta0) direct input:" append rval "\n ( ?text? ; tta0 input without cr" append rval "\n < ?text? ; tta0 input with cr" append rval "\nmiscellaneous:" @@ -650,17 +633,29 @@ namespace eval rw11 { puts "shell-W: '$cmd' command ignored, '$optnam' CPU option not available" return 0; } + # - # shell_conv_register: convert register to address ------------------------- - # - proc shell_conv_register {cpu reg} { - if {[$cpu imap -testname $reg]} { - return [$cpu imap $reg] - } elseif {[string is integer $reg]} { - return $reg - } else { - error "shell-E: unknown register '$reg'" + # shell_update_cpu_stat ---------------------------------------------------- + # + proc shell_update_cpu_stat {} { + variable shell_cpu_stat + set shell_cpu_stat "" + foreach i {0 1 2 3} { + if {[llength [info commands "cpu${i}"]] > 0} { + cpu${i} cp -rreg "stat" cp_stat + set cpu_rust [regget rw11::CP_STAT(rust) $cp_stat] + if {$cpu_rust == $rw11::RUST_INIT} { set cpu_rcode "I" } \ + elseif {$cpu_rust == $rw11::RUST_HALT} { set cpu_rcode "H" } \ + elseif {$cpu_rust == $rw11::RUST_RESET} { set cpu_rcode "R" } \ + elseif {$cpu_rust == $rw11::RUST_STOP} { set cpu_rcode "S" } \ + elseif {$cpu_rust == $rw11::RUST_STEP} { set cpu_rcode "+" } \ + elseif {$cpu_rust == $rw11::RUST_SUSP} { set cpu_rcode "s" } \ + elseif {$cpu_rust == $rw11::RUST_HBPT} { set cpu_rcode "b" } \ + elseif {$cpu_rust == $rw11::RUST_RUNS} { set cpu_rcode "g" } \ + else { set cpu_rcode "E" } + append shell_cpu_stat $cpu_rcode + } } + append shell_cpu_stat ":" } - }