From 509c3719bd9650e2c4b4aad0c7fbf3c042fcd243 Mon Sep 17 00:00:00 2001 From: "Walter F.J. Mueller" Date: Sat, 22 Apr 2017 15:33:04 +0200 Subject: [PATCH] integrate rbus monitor in w11 shell; setup procs idempotent - RlinkConnect: add rbus monitor probe, add HasRbmon() - RtclRlinkConnect: M_amap: -testname opt addr check; add hasrbmon get - RtclRw11Cpu: M_(imap|rmap): -testname optional addr check - ti_rri: setup rbus monitor if detected - rw11/shell.tcl: integrate rbmon: add .rme,.rmd,.rmf,.rml - ibd_ibmon/util.tcl: setup: now idempotent; move out imap_reg2addr - rbmoni/util.tcl: setup: now idempotent; add procs filter,rme,rmf - rlink/util.tcl: add amap_reg2addr - rw11/util.tcl: move in imap_reg2addr; add imap_range2addr - rw11/shell.tcl: integrate rbmon: add .rme,.rmd,.rmf,.rml - rw11/dmhbpt.tcl: hb_set: use imap_range2addr, allow regnam and range - */util.tcl: setup: now idempotent --- doc/CHANGELOG.md | 30 +++- tools/bin/ti_rri | 12 +- tools/src/librlink/RlinkConnect.cpp | 38 +++-- tools/src/librlink/RlinkConnect.hpp | 8 +- tools/src/librlink/RlinkConnect.ipp | 12 +- tools/src/librlinktpp/RtclRlinkConnect.cpp | 16 ++- tools/src/librwxxtpp/RtclRw11Cpu.cpp | 23 +++- tools/tcl/ibd_ibmon/util.tcl | 78 ++++++----- tools/tcl/rbbram/util.tcl | 6 +- tools/tcl/rbemon/util.tcl | 6 +- tools/tcl/rbmoni/test_rbtest.tcl | 153 ++++++++++++++++++++- tools/tcl/rbmoni/test_regs.tcl | 7 +- tools/tcl/rbmoni/util.tcl | 99 +++++++++++-- tools/tcl/rbs3hio/util.tcl | 6 +- tools/tcl/rbtest/util.tcl | 6 +- tools/tcl/rlink/util.tcl | 17 ++- tools/tcl/rw11/dmhbpt.tcl | 12 +- tools/tcl/rw11/shell.tcl | 103 +++++++++++--- tools/tcl/rw11/util.tcl | 39 +++++- tools/tcl/tst_rlink/util.tcl | 12 +- tools/tcl/tst_sram/util.tcl | 6 +- 21 files changed, 559 insertions(+), 130 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index f6fc722a..99e3a280 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -11,12 +11,38 @@ --- ## HEAD -### Proviso -_The HEAD version shows the current development. No guarantees that +### General Proviso +The HEAD version shows the current development. No guarantees that software or firmware builds or that the documentation is consistent. The full set of tests is only run for tagged releases. +### Special Provisos +- DEUNA still with very limited functionality and testing + - no buffer chaining + - no loopback + - no memory access error checking + - works with 211bsd, ping and telnet login tested +- DEUNA and nexys3 shows rlink aborts + - unlikely that it's a DEUNA issue + - more likely this revealed a hidden flaw in the fx2 based transport + - all works fine with nexys4 ! + ### Summary +- integrate rbus monitor in w11 shell + - ti_rri: setup rbus monitor if detected + - rw11/shell.tcl: add .rme,.rmd,.rmf,.rml + - ibd_ibmon/util.tcl: move out imap_reg2addr + - rbmoni/util.tcl: add procs filter,rme,rmf + - rlink/util.tcl: add amap_reg2addr + - rw11/util.tcl: move in imap_reg2addr; add imap_range2addr + - rw11/shell.tcl: integrate rbmon: add .rme,.rmd,.rmf,.rml +- make setup procs idempotent + - RlinkConnect: add rbus monitor probe, add HasRbmon() + - RtclRlinkConnect: M_amap: -testname opt addr check; add hasrbmon get + - RtclRw11Cpu: M_(imap|rmap): -testname optional addr check + - */util.tcl: setup: now idempotent +- w11 shell .bs now support ibus register names and ranges + - rw11/dmhbpt.tcl: hb_set: use imap_range2addr, allow regnam and range - add DEUNA (ethernet) support - add DEUNA device (xu) for ibus - add DEUNA to all sys_w11a systems diff --git a/tools/bin/ti_rri b/tools/bin/ti_rri index de7ce445..36841d65 100755 --- a/tools/bin/ti_rri +++ b/tools/bin/ti_rri @@ -1,6 +1,6 @@ #! /usr/bin/env tclshcpp # -*- tcl -*- -# $Id: ti_rri 843 2017-01-08 18:15:27Z mueller $ +# $Id: ti_rri 883 2017-04-22 11:57:38Z mueller $ # # Copyright 2011-2017 by Walter F.J. Mueller # @@ -15,6 +15,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-04-22 883 1.4.4 setup rbus monitor if detected # 2017-01-08 843 1.4.3 allow --term=USBD for Digilent autodetect # 2015-01-09 776 1.2.2 add --tout option to setup rlc timeout before connect # 2015-01-09 631 1.2.1 use rlc get/set rather config @@ -214,7 +215,6 @@ if { $opts(pack_) ne "" } { } } - # setup logging if { $opts(log_) ne "-" } { rlc set logfile $opts(log_) @@ -369,6 +369,14 @@ foreach cmd $clist { } } +# setup rbus monitor if detected +# must be done after all command line commands are processed to allow +# defered initialization and 'rlc init' hacks. +if {[rlc get hasrbmon]} { + package require rbmoni + rbmoni::setup +} + if { $tcl_interactive && $tirri_interactive } { ::tclreadline::Loop } else { diff --git a/tools/src/librlink/RlinkConnect.cpp b/tools/src/librlink/RlinkConnect.cpp index 6c9e9316..fc3720ae 100644 --- a/tools/src/librlink/RlinkConnect.cpp +++ b/tools/src/librlink/RlinkConnect.cpp @@ -1,4 +1,4 @@ -// $Id: RlinkConnect.cpp 868 2017-04-07 20:09:33Z mueller $ +// $Id: RlinkConnect.cpp 883 2017-04-22 11:57:38Z mueller $ // // Copyright 2011-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-22 883 2.6.2 add rbus monitor probe, add HasRbmon() // 2017-04-07 868 2.6.1 Dump(): add detail arg // 2017-02-20 854 2.6 use Rtime, drop TimeOfDayAsDouble // 2016-04-02 758 2.5 add USR_ACCESS register support (RLUA0/RLUA1) @@ -40,7 +41,7 @@ /*! \file - \version $Id: RlinkConnect.cpp 868 2017-04-07 20:09:33Z mueller $ + \version $Id: RlinkConnect.cpp 883 2017-04-22 11:57:38Z mueller $ \brief Implemenation of RlinkConnect. */ @@ -78,6 +79,7 @@ const uint16_t RlinkConnect::kRbaddr_RLID1; const uint16_t RlinkConnect::kRbaddr_RLID0; const uint16_t RlinkConnect::kRbaddr_RLUA1; const uint16_t RlinkConnect::kRbaddr_RLUA0; +const uint16_t RlinkConnect::kRbaddr_RMBASE; const uint16_t RlinkConnect::kRLCNTL_M_AnEna; const uint16_t RlinkConnect::kRLCNTL_M_AtoEna; @@ -121,7 +123,8 @@ RlinkConnect::RlinkConnect() fTsLastAttnNoti(), fSysId(0xffffffff), fUsrAcc(0x00000000), - fRbufSize(2048) + fRbufSize(2048), + fHasRbmon(false) { for (size_t i=0; i<8; i++) fSeqNumber[i] = 0; @@ -221,14 +224,17 @@ bool RlinkConnect::LinkInit(RerrMsg& emsg) if (fLinkInitDone) return true; RlinkCommandList clist; - clist.AddRreg(kRbaddr_RLSTAT); - clist.AddRreg(kRbaddr_RLID1); - clist.AddRreg(kRbaddr_RLID0); + int ista = clist.AddRreg(kRbaddr_RLSTAT); + int iid1 = clist.AddRreg(kRbaddr_RLID1); + int iid0 = clist.AddRreg(kRbaddr_RLID0); // RLUA0/1 are optional registers, available for 7Series and higher - clist.AddRreg(kRbaddr_RLUA1); + int iua1 = clist.AddRreg(kRbaddr_RLUA1); clist.SetLastExpectStatus(0,0); // disable stat check - clist.AddRreg(kRbaddr_RLUA0); + int iua0 = clist.AddRreg(kRbaddr_RLUA0); + clist.SetLastExpectStatus(0,0); // disable stat check + // probe for rbus monitor + int irbm = clist.AddRreg(kRbaddr_RMBASE); clist.SetLastExpectStatus(0,0); // disable stat check if (!Exec(clist, emsg)) return false; @@ -241,19 +247,19 @@ bool RlinkConnect::LinkInit(RerrMsg& emsg) AddrMapInsert("rl.id1", kRbaddr_RLID1); AddrMapInsert("rl.id0", kRbaddr_RLID0); - uint16_t rlstat = clist[0].Data(); - uint16_t rlid1 = clist[1].Data(); - uint16_t rlid0 = clist[2].Data(); + uint16_t rlstat = clist[ista].Data(); + uint16_t rlid1 = clist[iid1].Data(); + uint16_t rlid0 = clist[iid0].Data(); fRbufSize = size_t(1) << (10 + (rlstat & kRLSTAT_M_RBSize)); fSysId = uint32_t(rlid1)<<16 | uint32_t(rlid0); - // handle rlink optional registers: USR_ACCESS + // handle rlink optional registers: USR_ACCESS and rbus monitor probe const uint8_t staterr = RlinkCommand::kStat_M_RbTout | RlinkCommand::kStat_M_RbNak | RlinkCommand::kStat_M_RbErr; - if ((clist[3].Status() & staterr) == 0 && // RLUA1 ok - (clist[4].Status() & staterr) == 0) { // RLUA0 ok + if ((clist[iua1].Status() & staterr) == 0 && // RLUA1 ok + (clist[iua0].Status() & staterr) == 0) { // RLUA0 ok AddrMapInsert("rl.ua1", kRbaddr_RLUA1); AddrMapInsert("rl.ua0", kRbaddr_RLUA0); @@ -263,6 +269,10 @@ bool RlinkConnect::LinkInit(RerrMsg& emsg) fUsrAcc = uint32_t(rlua1)<<16 | uint32_t(rlua0); } + if ((clist[irbm].Status() & staterr) == 0) { // rbus monitor found + fHasRbmon = true; // just remember + } + return true; } diff --git a/tools/src/librlink/RlinkConnect.hpp b/tools/src/librlink/RlinkConnect.hpp index 031007f7..bdb2b55d 100644 --- a/tools/src/librlink/RlinkConnect.hpp +++ b/tools/src/librlink/RlinkConnect.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkConnect.hpp 871 2017-04-09 15:19:11Z mueller $ +// $Id: RlinkConnect.hpp 883 2017-04-22 11:57:38Z mueller $ // // Copyright 2011-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-22 883 2.6.3 add rbus monitor probe, add HasRbmon() // 2017-04-09 871 2.6.2 LogFileName(): returns now const std::string& // 2017-04-07 868 2.6.1 Dump(): add detail arg // 2017-02-20 854 2.6 use Rtime, drop TimeOfDayAsDouble @@ -42,7 +43,7 @@ /*! \file - \version $Id: RlinkConnect.hpp 871 2017-04-09 15:19:11Z mueller $ + \version $Id: RlinkConnect.hpp 883 2017-04-22 11:57:38Z mueller $ \brief Declaration of class \c RlinkConnect. */ @@ -120,6 +121,7 @@ namespace Retro { size_t RbufSize() const; size_t BlockSizeMax() const; size_t BlockSizePrudent() const; + bool HasRbmon() const; bool AddrMapInsert(const std::string& name, uint16_t addr); bool AddrMapErase(const std::string& name); @@ -169,6 +171,7 @@ namespace Retro { static const uint16_t kRbaddr_RLID0 = 0xfffc; //!< rlink core reg RLID0 static const uint16_t kRbaddr_RLUA1 = 0xfffb; //!< rlink opt. reg RLUA1 static const uint16_t kRbaddr_RLUA0 = 0xfffa; //!< rlink opt. reg RLUA0 + static const uint16_t kRbaddr_RMBASE = 0xffe8; //!< rlink opt. rbd_rbmon static const uint16_t kRLCNTL_M_AnEna = kWBit15;//!< RLCNTL: an enable static const uint16_t kRLCNTL_M_AtoEna= kWBit14;//!< RLCNTL: ato enable @@ -257,6 +260,7 @@ namespace Retro { uint32_t fSysId; //!< SYSID of connected device uint32_t fUsrAcc; //!< USR_ACCESS of connected device size_t fRbufSize; //!< Rbuf size (in bytes) + bool fHasRbmon; //!< has rbd_rbmon (rbus monitor) }; } // end namespace Retro diff --git a/tools/src/librlink/RlinkConnect.ipp b/tools/src/librlink/RlinkConnect.ipp index c2e5e600..6603d315 100644 --- a/tools/src/librlink/RlinkConnect.ipp +++ b/tools/src/librlink/RlinkConnect.ipp @@ -1,4 +1,4 @@ -// $Id: RlinkConnect.ipp 871 2017-04-09 15:19:11Z mueller $ +// $Id: RlinkConnect.ipp 883 2017-04-22 11:57:38Z mueller $ // // Copyright 2011-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-22 883 2.5.2 add rbus monitor probe, add HasRbmon() // 2017-04-09 871 2.5.1 LogFileName(): returns now const std::string& // 2017-02-20 854 2.5 use Rtime, drop TimeOfDayAsDouble // 2016-04-02 758 2.4 add USR_ACCESS register support (RLUA0/RLUA1) @@ -30,7 +31,7 @@ /*! \file - \version $Id: RlinkConnect.ipp 871 2017-04-09 15:19:11Z mueller $ + \version $Id: RlinkConnect.ipp 883 2017-04-22 11:57:38Z mueller $ \brief Implemenation (inline) of RlinkConnect. */ @@ -136,6 +137,13 @@ inline size_t RlinkConnect::BlockSizePrudent() const return (fRbufSize-kRbufPrudentDelta)/2; } +//------------------------------------------+----------------------------------- +//! FIXME_docs +inline bool RlinkConnect::HasRbmon() const +{ + return fHasRbmon; +} + //------------------------------------------+----------------------------------- //! FIXME_docs diff --git a/tools/src/librlinktpp/RtclRlinkConnect.cpp b/tools/src/librlinktpp/RtclRlinkConnect.cpp index dbc311d2..797e1ae4 100644 --- a/tools/src/librlinktpp/RtclRlinkConnect.cpp +++ b/tools/src/librlinktpp/RtclRlinkConnect.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRlinkConnect.cpp 868 2017-04-07 20:09:33Z mueller $ +// $Id: RtclRlinkConnect.cpp 883 2017-04-22 11:57:38Z mueller $ // // Copyright 2011-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-22 883 1.5.2 M_amap: -testname opt addr check; add hasrbmon get // 2017-04-02 865 1.5.1 M_dump: use GetArgsDump and Dump detail // 2017-02-20 854 1.5 use Rtime // 2016-04-02 758 1.4.6 add USR_ACCESS register support (UsrAcc->usracc) @@ -42,7 +43,7 @@ /*! \file - \version $Id: RtclRlinkConnect.cpp 868 2017-04-07 20:09:33Z mueller $ + \version $Id: RtclRlinkConnect.cpp 883 2017-04-22 11:57:38Z mueller $ \brief Implemenation of class RtclRlinkConnect. */ @@ -136,6 +137,8 @@ RtclRlinkConnect::RtclRlinkConnect(Tcl_Interp* interp, const char* name) boost::bind(&RlinkConnect::BlockSizeMax, pobj)); fGets.Add ("bsizeprudent", boost::bind(&RlinkConnect::BlockSizePrudent, pobj)); + fGets.Add ("hasrbmon", + boost::bind(&RlinkConnect::HasRbmon, pobj)); fSets.Add ("baseaddr", boost::bind(&RlinkConnect::SetLogBaseAddr, pobj, _1)); @@ -467,11 +470,16 @@ int RtclRlinkConnect::M_amap(RtclArgs& args) "' not mapped"); } - } else if (opt == "-testname") { // amap -testname name + } else if (opt == "-testname") { // amap -testname name ?addr if (!args.GetArg("name", name)) return kERR; + if (!args.GetArg("?addr", addr)) return kERR; if (!args.AllDone()) return kERR; uint16_t tstaddr; - args.SetResult(int(addrmap.Find(name, tstaddr))); + bool found = addrmap.Find(name, tstaddr); + if (found && args.NOptMiss()==0) { // if specified addr + if (tstaddr != addr) found = false; // verify addr + } + args.SetResult(int(found)); } else if (opt == "-testaddr") { // amap -testaddr addr if (!args.GetArg("addr", addr)) return kERR; diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.cpp b/tools/src/librwxxtpp/RtclRw11Cpu.cpp index e2b51f0e..eeabc31f 100644 --- a/tools/src/librwxxtpp/RtclRw11Cpu.cpp +++ b/tools/src/librwxxtpp/RtclRw11Cpu.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Cpu.cpp 876 2017-04-16 08:01:37Z mueller $ +// $Id: RtclRw11Cpu.cpp 883 2017-04-22 11:57:38Z mueller $ // // Copyright 2013-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-22 883 1.2.17 M_(imap|rmap): -testname optional addr check // 2017-04-15 876 1.2.16 add ControllerCommands() // 2017-04-15 875 1.2.15 M_default: add attached units summary // 2017-04-07 868 1.2.14 M_dump: use GetArgsDump and Dump detail @@ -45,7 +46,7 @@ /*! \file - \version $Id: RtclRw11Cpu.cpp 876 2017-04-16 08:01:37Z mueller $ + \version $Id: RtclRw11Cpu.cpp 883 2017-04-22 11:57:38Z mueller $ \brief Implemenation of RtclRw11Cpu. */ @@ -160,11 +161,16 @@ int RtclRw11Cpu::M_imap(RtclArgs& args) "' not mapped"); } - } else if (opt == "-testname") { // imap -testname name + } else if (opt == "-testname") { // imap -testname name ?addr if (!args.GetArg("name", name)) return kERR; + if (!args.GetArg("?addr", addr)) return kERR; if (!args.AllDone()) return kERR; uint16_t tstaddr; - args.SetResult(int(addrmap.Find(name, tstaddr))); + bool found = addrmap.Find(name, tstaddr); + if (found && args.NOptMiss()==0) { // if specified addr + if (tstaddr != addr) found = false; // verify addr + } + args.SetResult(int(found)); } else if (opt == "-testaddr") { // imap -testaddr addr if (!args.GetArg("addr", addr)) return kERR; @@ -258,11 +264,16 @@ int RtclRw11Cpu::M_rmap(RtclArgs& args) "' not mapped"); } - } else if (opt == "-testname") { // rmap -testname name + } else if (opt == "-testname") { // rmap -testname name ?addr if (!args.GetArg("name", name)) return kERR; + if (!args.GetArg("?addr", addr)) return kERR; if (!args.AllDone()) return kERR; uint16_t tstaddr; - args.SetResult(int(lmap.Find(name, tstaddr))); + bool found = lmap.Find(name, tstaddr); + if (found && args.NOptMiss()==0) { // if specified addr + if (tstaddr != addr) found = false; // verify addr + } + args.SetResult(int(found)); } else if (opt == "-testaddr") { // rmap -testaddr addr if (!args.GetArg("addr", addr)) return kERR; diff --git a/tools/tcl/ibd_ibmon/util.tcl b/tools/tcl/ibd_ibmon/util.tcl index 28d9495f..54e46461 100644 --- a/tools/tcl/ibd_ibmon/util.tcl +++ b/tools/tcl/ibd_ibmon/util.tcl @@ -1,4 +1,4 @@ -# $Id: util.tcl 872 2017-04-09 20:48:05Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # # Copyright 2015-2017 by Walter F.J. Mueller # @@ -13,7 +13,8 @@ # # Revision History: # Date Rev Version Comment -# 2017-04-09 872 2.0 revised interface, add suspend and repeat collect +# 2017-04-22 883 2.0.1 setup: now idempotent; move out imap_reg2addr +# 2017-04-16 880 2.0 revised interface, add suspend and repeat collect # 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 @@ -25,6 +26,7 @@ package provide ibd_ibmon 1.0 package require rutil package require rlink +package require rw11 package require rw11util namespace eval ibd_ibmon { @@ -55,6 +57,7 @@ namespace eval ibd_ibmon { # setup: amap definitions for ibd_ibmon ------------------------------------ # proc setup {{cpu "cpu0"} {base 0160000}} { + if {[$cpu imap -testname im.cntl $base]} {return ""} $cpu imap -insert im.cntl [expr {$base + 000}] $cpu imap -insert im.stat [expr {$base + 002}] $cpu imap -insert im.hilim [expr {$base + 004}] @@ -75,7 +78,13 @@ namespace eval ibd_ibmon { # # start: setup filter window ----------------------------------------------- # - proc filter {{cpu "cpu0"} {lolim 0} {hilim 0177776}} { + proc filter {{cpu "cpu0"} {lolim 0160000} {hilim 0177776}} { + if {$lolim < 0160000 || $hilim < 0160000} { + error "filter-E: bad lolim or hilim, must be >= 0160000" + } + if {$lolim > $hilim} { + error "filter-E: bad lolim.hilim, must be lolim <= hilim" + } $cpu cp -wibr im.lolim $lolim \ -wibr im.hilim $hilim } @@ -100,11 +109,28 @@ namespace eval ibd_ibmon { $cpu cp -wibr im.cntl [regbld ibd_ibmon::CNTL {func "STO"}] } # + # suspend: suspend the ibmon ----------------------------------------------- + # returns 1 if already suspended + # that allows to implement nested suspend/resume properly + # + proc suspend {{cpu "cpu0"}} { + $cpu cp -ribr im.stat rstat \ + -wibr im.cntl [regbld ibd_ibmon::CNTL {func "SUS"}] + return [regget ibd_ibmon::STAT(susp) $rstat] + } + # + # resume: resume the ibmon ------------------------------------------------- + # + proc resume {{cpu "cpu0"}} { + $cpu cp -wibr im.cntl [regbld ibd_ibmon::CNTL {func "RES"}] + } + # # read: read nent last entries (by default all) ---------------------------- # proc read {{cpu "cpu0"} {nent -1}} { # suspend and get address and status - $cpu cp -wibr im.cntl [regbld ibd_ibmon::CNTL {func "SUS"}] \ + $cpu cp -rreg im.stat rstatpre \ + -wibr im.cntl [regbld ibd_ibmon::CNTL {func "SUS"}] \ -ribr im.cntl rcntl \ -ribr im.addr raddr \ -ribr im.stat rstat @@ -180,9 +206,11 @@ namespace eval ibd_ibmon { set nrest [expr {$nrest - ( $nblk >> 2 ) }] } - # resume and restore address + # restore address and resume + # resume only if not already suspended before + set rfu [expr {[regget ibd_ibmon::::STAT(susp) $rstatpre] ? "NOOP" : "RES"}] $cpu cp -wibr im.addr $raddr \ - -wibr im.cntl [regbld ibd_ibmon::CNTL {func "RES"}] + -wibr im.cntl [regbldkv ibd_ibmon::CNTL func $rfu] return $rval } @@ -258,7 +286,11 @@ namespace eval ibd_ibmon { set ename [$cpu imap -name $eaddr] set eam "l${prw}" if {$fracc} { set eam "r${prw}"} - set etext [rw11util::regmap_txt $ename $eam $edata] + # mask out high/low byte for byte writes for regmap_txt + set edatamsk $edata + if {$pwe1 eq "0"} {set edatamsk [expr { $edatamsk & 0x00ff } ]} + if {$pwe0 eq "0"} {set edatamsk [expr { $edatamsk & 0xff00 } ]} + set etext [rw11util::regmap_txt $ename $eam $edatamsk] } set comment "" @@ -356,40 +388,16 @@ namespace eval ibd_ibmon { # imf: ibmon filter -------------------------------------------------------- # proc imf {{cpu "cpu0"} {lo ""} {hi ""}} { - set lolim 0 + set lolim 0160000 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)}] - } + set aran [rw11::imap_range2addr $cpu $lo $hi] + set lolim [lindex $aran 0] + set hilim [lindex $aran 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/rbbram/util.tcl b/tools/tcl/rbbram/util.tcl index 4fcc19fb..b59f6f45 100644 --- a/tools/tcl/rbbram/util.tcl +++ b/tools/tcl/rbbram/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 603 2014-11-09 22:50:26Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2014 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 2.0.1 setup: now idempotent # 2014-11-09 603 2.0 use rlink v4 address layout # 2011-03-19 372 1.0 Initial version # @@ -28,6 +29,7 @@ namespace eval rbbram { # setup: amap definitions for rbd_bram # proc setup {base} { + if {[rlc amap -testname br.cntl $base]} {return ""} rlc amap -insert br.cntl [expr {$base + 0x00}] rlc amap -insert br.data [expr {$base + 0x01}] } diff --git a/tools/tcl/rbemon/util.tcl b/tools/tcl/rbemon/util.tcl index 0c289bb4..ae31e5b8 100644 --- a/tools/tcl/rbemon/util.tcl +++ b/tools/tcl/rbemon/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 643 2015-02-07 17:41:53Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2013 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 1.1.1 setup: now idempotent # 2015-02-07 642 1.1 add print() # 2011-04-17 376 1.0.1 add proc read # 2011-04-02 375 1.0 Initial version @@ -34,6 +35,7 @@ namespace eval rbemon { # setup: amap definitions for rbd_eyemon # proc setup {{base 0xffd0}} { + if {[rlc amap -testname em.cntl $base]} {return ""} rlc amap -insert em.cntl [expr {$base + 0x00}] rlc amap -insert em.rdiv [expr {$base + 0x01}] rlc amap -insert em.addr [expr {$base + 0x02}] diff --git a/tools/tcl/rbmoni/test_rbtest.tcl b/tools/tcl/rbmoni/test_rbtest.tcl index ec780a3f..0b8fdc75 100644 --- a/tools/tcl/rbmoni/test_rbtest.tcl +++ b/tools/tcl/rbmoni/test_rbtest.tcl @@ -1,4 +1,4 @@ -# $Id: test_rbtest.tcl 872 2017-04-09 20:48:05Z mueller $ +# $Id: test_rbtest.tcl 873 2017-04-14 11:56:29Z mueller $ # # Copyright 2011-2017 by Walter F.J. Mueller # @@ -13,7 +13,7 @@ # # Revision History: # Date Rev Version Comment -# 2017-04-09 872 3.0 adopt to revised interface +# 2017-04-14 873 3.0 adopt to revised interface # 2015-04-03 661 2.1 drop estatdef; fix test 5 (wrong regs accessed) # 2014-12-22 619 2.0 adopt to new rbd_rbmon and rlink v4 # 2011-03-27 374 1.0 Initial version @@ -333,10 +333,10 @@ namespace eval rbmoni { # #------------------------------------------------------------------------- - rlc log " test 6: test repeat collapse read with wreg,rreg " + rlc log " test 6: test repeat collapse read with wreg,rreg" #----------------------------------------------------------------- rlc log " test 6a: dry run, no collapse active" - set vteinit [regbld rbtest::INIT cntl] + set vteinit [regbld rbtest::INIT cntl data fifo] # build expect list: list of {eflag eaddr edata enbusy} sublists raw_edata edat emsk \ [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] \ @@ -451,12 +451,72 @@ namespace eval rbmoni { if {$print} {puts [print]} raw_check $edat $emsk + #----------------------------------------------------------------- + rlc log " test 6e: verify non-collapse of alternating write-read same addr" + # build expect list: list of {eflag eaddr edata enbusy} sublists + raw_edata edat emsk \ + [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] \ + [list [regbld rbmoni::FLAGS ack we] $atefifo 0x0001 0] \ + [list [regbld rbmoni::FLAGS ack ] $atefifo 0x0001 0] \ + [list [regbld rbmoni::FLAGS ack we] $atefifo 0x0002 0] \ + [list [regbld rbmoni::FLAGS ack ] $atefifo 0x0002 0] \ + [list [regbld rbmoni::FLAGS ack we] $atefifo 0x0003 0] \ + [list [regbld rbmoni::FLAGS ack ] $atefifo 0x0003 0] \ + [list [regbld rbmoni::FLAGS ack we] $atefifo 0x0004 0] \ + [list [regbld rbmoni::FLAGS ack ] $atefifo 0x0004 0] \ + [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] + # + rbmoni::start rcolw 1 rcolr 1 + rlc exec \ + -init te.cntl $vteinit \ + -wreg te.fifo 0x0001 \ + -rreg te.fifo -edata 0x0001 \ + -wreg te.fifo 0x0002 \ + -rreg te.fifo -edata 0x0002 \ + -wreg te.fifo 0x0003 \ + -rreg te.fifo -edata 0x0003 \ + -wreg te.fifo 0x0004 \ + -rreg te.fifo -edata 0x0004 \ + -init te.cntl $vteinit + rbmoni::stop + if {$print} {puts [print]} + raw_check $edat $emsk + + #----------------------------------------------------------------- + rlc log " test 6f: verify non-collapse of reads to different addr" + # build expect list: list of {eflag eaddr edata enbusy} sublists + raw_edata edat emsk \ + [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] \ + [list [regbld rbmoni::FLAGS ack we] $atedata 0x1230 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedata 0x1230 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x1230 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedata 0x1231 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x1231 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedata 0x1232 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x1232 0] \ + [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] + # + rbmoni::start rcolw 1 rcolr 1 + rlc exec \ + -init te.cntl $vteinit \ + -wreg te.data 0x1230 \ + -rreg te.data -edata 0x1230 \ + -rreg te.dinc -edata 0x1230 \ + -rreg te.data -edata 0x1231 \ + -rreg te.dinc -edata 0x1231 \ + -rreg te.data -edata 0x1232 \ + -rreg te.dinc -edata 0x1232 \ + -init te.cntl $vteinit + rbmoni::stop + if {$print} {puts [print]} + raw_check $edat $emsk + # #------------------------------------------------------------------------- - rlc log " test 7: test repeat collapse read with wblk,rblk " + rlc log " test 7: test repeat collapse read with wblk,rblk" #----------------------------------------------------------------- rlc log " test 7a: dry run, no collapse active" - set vteinit [regbld rbtest::INIT cntl] + set vteinit [regbld rbtest::INIT cntl data fifo] set vtefifo {0x1101 0x2202 0x3303 0x4404} # build expect list: list of {eflag eaddr edata enbusy} sublists raw_edata edat emsk \ @@ -551,6 +611,87 @@ namespace eval rbmoni { if {$print} {puts [print]} raw_check $edat $emsk + #------------------------------------------------------------------------- + rlc log " test 8: test repeat collapse with lolim,hilim " + #----------------------------------------------------------------- + # set window to te.ncyc to te.dinc, thus exclude cntl,stat,attn,fifo,lnak + rlc exec -wreg rm.lolim $atencyc \ + -wreg rm.hilim $atedinc + + #----------------------------------------------------------------- + rlc log " test 8a: read collapse interrupted by out-of-window read" + raw_edata edat emsk \ + [list [regbld rbmoni::FLAGS ack we] $atedata 0x2000 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x2000 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x2003 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x2004 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x2007 0] + # + rbmoni::start rcolw 1 rcolr 1 + rlc exec -wreg te.data 0x2000 \ + -rreg te.dinc -edata 0x2000 \ + -rreg te.dinc -edata 0x2001 \ + -rreg te.dinc -edata 0x2002 \ + -rreg te.dinc -edata 0x2003 \ + -rreg te.stat \ + -rreg te.dinc -edata 0x2004 \ + -rreg te.dinc -edata 0x2005 \ + -rreg te.dinc -edata 0x2006 \ + -rreg te.dinc -edata 0x2007 + rbmoni::stop + if {$print} {puts [print]} + raw_check $edat $emsk + + #----------------------------------------------------------------- + rlc log " test 8b: write collapse interrupted by out-of-window write" + raw_edata edat emsk \ + [list [regbld rbmoni::FLAGS ack we] $atedata 0x3000 0] \ + [list [regbld rbmoni::FLAGS ack we] $atedinc 0x3001 0] \ + [list [regbld rbmoni::FLAGS ack we] $atedinc 0x3003 0] \ + [list [regbld rbmoni::FLAGS ack we] $atedinc 0x3004 0] \ + [list [regbld rbmoni::FLAGS ack we] $atedinc 0x3007 0] + # + rbmoni::start rcolw 1 rcolr 1 + rlc exec -wreg te.data 0x3000 \ + -wreg te.dinc 0x3001 \ + -wreg te.dinc 0x3002 \ + -wreg te.dinc 0x3003 \ + -wreg te.stat 0x0000 \ + -wreg te.dinc 0x3004 \ + -wreg te.dinc 0x3005 \ + -wreg te.dinc 0x3006 \ + -wreg te.dinc 0x3007 + rbmoni::stop + if {$print} {puts [print]} + raw_check $edat $emsk + rbmoni::init + + #----------------------------------------------------------------- + rlc log " test 8c: read collapse interrupted by init (which recorded)" + set vteinit [regbld rbtest::INIT data] + raw_edata edat emsk \ + [list [regbld rbmoni::FLAGS ack we ] $atedata 0x4000 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x4000 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x4003 0] \ + [list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x0000 0] \ + [list [regbld rbmoni::FLAGS ack ] $atedinc 0x0003 0] + # + rbmoni::start rcolw 1 rcolr 1 + rlc exec -wreg te.data 0x4000 \ + -rreg te.dinc -edata 0x4000 \ + -rreg te.dinc -edata 0x4001 \ + -rreg te.dinc -edata 0x4002 \ + -rreg te.dinc -edata 0x4003 \ + -init te.cntl $vteinit \ + -rreg te.dinc -edata 0x0000 \ + -rreg te.dinc -edata 0x0001 \ + -rreg te.dinc -edata 0x0002 \ + -rreg te.dinc -edata 0x0003 + rbmoni::stop + if {$print} {puts [print]} + raw_check $edat $emsk + #------------------------------------------------------------------------- rlc log "rbmoni::test_rbtest - cleanup:" rbtest::init diff --git a/tools/tcl/rbmoni/test_regs.tcl b/tools/tcl/rbmoni/test_regs.tcl index 3a6c2c98..434de8c6 100644 --- a/tools/tcl/rbmoni/test_regs.tcl +++ b/tools/tcl/rbmoni/test_regs.tcl @@ -1,4 +1,4 @@ -# $Id: test_regs.tcl 872 2017-04-09 20:48:05Z mueller $ +# $Id: test_regs.tcl 873 2017-04-14 11:56:29Z mueller $ # # Copyright 2011-2017 by Walter F.J. Mueller # @@ -13,7 +13,7 @@ # # Revision History: # Date Rev Version Comment -# 2017-04-09 872 3.0 adopt to revised interface +# 2017-04-13 873 3.0 adopt to revised interface # 2015-04-03 661 2.1 drop estatdef (stat err check default now) # 2014-12-27 622 2.0 rbd_rbmon reorganized, supports now 16 bit addresses # 2011-03-27 374 1.0 Initial version @@ -80,12 +80,15 @@ namespace eval rbmoni { -rreg rm.stat -edata [regbld rbmoni::STAT susp run] \ -wreg rm.cntl [regbld rbmoni::CNTL {func "STA"}] \ -rreg rm.stat -edata [regbld rbmoni::STAT run] + # test that suspend of a suspended system is a noop # test that stop of a suspended system clears suspend rlc exec \ -wreg rm.cntl [regbld rbmoni::CNTL {func "STA"}] \ -rreg rm.stat -edata [regbld rbmoni::STAT run] \ -wreg rm.cntl [regbld rbmoni::CNTL {func "SUS"}] \ -rreg rm.stat -edata [regbld rbmoni::STAT susp run] \ + -wreg rm.cntl [regbld rbmoni::CNTL {func "SUS"}] \ + -rreg rm.stat -edata [regbld rbmoni::STAT susp run] \ -wreg rm.cntl [regbld rbmoni::CNTL {func "STO"}] \ -rreg rm.stat -edata [regbld rbmoni::STAT] # get amax for later usage diff --git a/tools/tcl/rbmoni/util.tcl b/tools/tcl/rbmoni/util.tcl index e28393a0..c90be6ed 100644 --- a/tools/tcl/rbmoni/util.tcl +++ b/tools/tcl/rbmoni/util.tcl @@ -1,4 +1,4 @@ -# $Id: util.tcl 872 2017-04-09 20:48:05Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # # Copyright 2011-2017 by Walter F.J. Mueller # @@ -13,7 +13,8 @@ # # Revision History: # Date Rev Version Comment -# 2017-04-09 872 4.0 revised interface, add suspend and repeat collect +# 2017-04-22 883 4.0.1 setup: now idempotent; add procs filter,rme,rmf +# 2017-04-13 873 4.0 revised interface, add suspend and repeat collect # 2015-04-03 661 3.1 drop estatdef; invert mask in raw_edata # 2014-12-23 619 3.0 rbd_rbmon reorganized, supports now 16 bit addresses # 2014-11-09 603 2.0 use rlink v4 address layout @@ -44,9 +45,10 @@ namespace eval rbmoni { regdsc FLAGS {bnext 8} {burst 7} {tout 6} {nak 5} {ack 4} \ {busy 3} {err 2} {we 1} {init 0} # - # setup: amap definitions for rbd_rbmon + # setup: amap definitions for rbd_rbmon ------------------------------------ # proc setup {{base 0xffe8}} { + if {[rlc amap -testname rm.cntl $base]} {return ""} rlc amap -insert rm.cntl [expr {$base + 0x00}] rlc amap -insert rm.stat [expr {$base + 0x01}] rlc amap -insert rm.hilim [expr {$base + 0x02}] @@ -55,7 +57,7 @@ namespace eval rbmoni { rlc amap -insert rm.data [expr {$base + 0x05}] } # - # init: reset rbd_rbmon (stop, reset alim) + # init: reset rbd_rbmon (stop, reset alim) --------------------------------- # proc init {} { rlc exec \ @@ -65,7 +67,15 @@ namespace eval rbmoni { -wreg rm.addr 0x0000 } # - # start: start the rbmon + # start: setup filter window ----------------------------------------------- + # + proc filter {{lolim 0160000} {hilim 0177776}} { + rlc exec \ + -wreg rm.lolim $lolim \ + -wreg rm.hilim $hilim + } + # + # start: start the rbmon --------------------------------------------------- # proc start {args} { args2opts opts {rcolw 0 rcolr 0 wstop 0} {*}$args @@ -76,16 +86,33 @@ namespace eval rbmoni { ] } # - # stop: stop the rbmon + # stop: stop the rbmon ----------------------------------------------------- # proc stop {} { rlc exec -wreg rm.cntl [regbld rbmoni::CNTL {func "STO"}] } # - # read: read nent last entries (by default all) + # suspend: suspend the rbmon ----------------------------------------------- + # returns 1 if already suspended + # that allows to implement nested suspend/resume properly + # + proc suspend {} { + rlc exec -rreg rm.stat rstat \ + -wreg rm.cntl [regbld rbmoni::CNTL {func "SUS"}] + return [regget rbmoni::STAT(susp) $rstat] + } + # + # resume: resume the rbmon ------------------------------------------------- + # + proc resume {} { + rlc exec -wreg rm.cntl [regbld rbmoni::CNTL {func "RES"}] + } + # + # read: read nent last entries (by default all) ---------------------------- # proc read {{nent -1}} { - rlc exec -wreg rm.cntl [regbld rbmoni::CNTL {func "SUS"}] \ + rlc exec -rreg rm.stat rstatpre \ + -wreg rm.cntl [regbld rbmoni::CNTL {func "SUS"}] \ -rreg rm.cntl rcntl \ -rreg rm.addr raddr \ -rreg rm.stat rstat @@ -134,9 +161,11 @@ namespace eval rbmoni { set nrest [expr {$nrest - ( $nblk >> 2 ) }] } - # resume and restore address + # restore address and resume + # resume only if not already suspended before + set rfu [expr {[regget rbmoni::STAT(susp) $rstatpre] ? "NOOP" : "RES"}] rlc exec -wreg rm.addr $raddr \ - -wreg rm.cntl [regbld rbmoni::CNTL {func "RES"}] + -wreg rm.cntl [regbldkv rbmoni::CNTL func $rfu] set mbnext [regbld rbmoni::FLAGS bnext] set mburst [regbld rbmoni::FLAGS burst] @@ -152,7 +181,7 @@ namespace eval rbmoni { return $rval } # - # print: print rbmon data (optionally also read them) + # print: print rbmon data (optionally also read them) ----------------------- # proc print {{mondat -1}} { @@ -229,7 +258,7 @@ namespace eval rbmoni { } # - # 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} { @@ -264,7 +293,7 @@ namespace eval rbmoni { } # - # 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 {edat emsk} { @@ -275,5 +304,49 @@ namespace eval rbmoni { -rreg rm.addr -edata [llength $edat] return "" } + # + # === high level procs: compact usage (also by rw11:shell) ================= + # + # rme: rbmon enable -------------------------------------------------------- + # + proc rme {{mode ""}} { + if {![regexp {^[nRW]*$} $mode]} { + error "rme-E: bad mode '$mode', use \[nRW\]*" + } + set wstop [string match *n* $mode] + set rcolr [string match *R* $mode] + set rcolw [string match *W* $mode] + + rbmoni::start wstop $wstop rcolr $rcolr rcolw $rcolw + return "" + } + + # + # rmf: rbmon filter -------------------------------------------------------- + # + proc rmf {{lo ""} {hi ""}} { + set lolim 0 + set hilim 0177773 + + 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 [rlink::amap_reg2addr [lindex $lolist 0]] + set hilim $lolim + if {[llength $lolist] == 2} { + set hilim [expr {$lolim + ([lindex $lolist 1]-1)}] + } + } + + if {$hi ne ""} { + set hilim [rlink::amap_reg2addr $hi] + } + + if {$lolim > $hilim} {error "rmf-E: hilim must be >= lolim"} + + rbmoni::filter $lolim $hilim + } } diff --git a/tools/tcl/rbs3hio/util.tcl b/tools/tcl/rbs3hio/util.tcl index bd8b5885..233dcf52 100644 --- a/tools/tcl/rbs3hio/util.tcl +++ b/tools/tcl/rbs3hio/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 640 2015-02-01 09:56:53Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2015 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 1.1.1 setup: now idempotent # 2015-01-31 640 1.1 adopt to new register layout # 2011-08-14 406 1.0.2 adopt to common register layout # 2011-04-17 376 1.0.1 print: show also switch values; add proc disptest @@ -36,6 +37,7 @@ namespace eval rbs3hio { # setup: amap definitions for s3_humanio_rbus # proc setup {{base 0xfef0}} { + if {[rlc amap -testname hi.stat $base]} {return ""} rlc amap -insert hi.stat [expr {$base + 0x00}] rlc amap -insert hi.cntl [expr {$base + 0x01}] rlc amap -insert hi.btn [expr {$base + 0x02}] diff --git a/tools/tcl/rbtest/util.tcl b/tools/tcl/rbtest/util.tcl index eaf94839..7234381b 100644 --- a/tools/tcl/rbtest/util.tcl +++ b/tools/tcl/rbtest/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 661 2015-04-03 18:28:41Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2014 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 2.0.2 setup: now idempotent # 2014-12-21 617 2.0.1 use rbtout stat bit for timeout # 2014-11-09 603 2.0 use rlink v4 address layout and iface with 8 regs # 2011-03-27 374 1.0 Initial version @@ -35,6 +36,7 @@ namespace eval rbtest { # setup: amap definitions for rbd_tester # proc setup {{base 0xffe0}} { + if {[rlc amap -testname te.cntl $base]} {return ""} rlc amap -insert te.cntl [expr {$base + 0x00}] rlc amap -insert te.stat [expr {$base + 0x01}] rlc amap -insert te.attn [expr {$base + 0x02}] diff --git a/tools/tcl/rlink/util.tcl b/tools/tcl/rlink/util.tcl index 96d4109a..b7ee481a 100644 --- a/tools/tcl/rlink/util.tcl +++ b/tools/tcl/rlink/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 758 2016-04-02 18:01:39Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2016 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 2.1.1 add amap_reg2addr # 2016-04-02 758 2.1 add USR_ACCESS register support (RLUA0/RLUA1) # 2014-12-21 617 2.0.1 add rbtout definition in STAT # 2014-12-07 609 2.0 use new rlink v4 iface; remove SINIT again @@ -127,5 +128,17 @@ namespace eval rlink { return $rval } + # + # amap_reg2addr: convert register to address ------------------------------- + # + proc amap_reg2addr {reg} { + if {[rlc amap -testname $reg]} { + return [rlc amap $reg] + } elseif {[string is integer $reg]} { + return $reg + } else { + error "amap_reg2addr-E: unknown register '$reg'" + } + } } diff --git a/tools/tcl/rw11/dmhbpt.tcl b/tools/tcl/rw11/dmhbpt.tcl index 2016becf..4eaf8ecc 100644 --- a/tools/tcl/rw11/dmhbpt.tcl +++ b/tools/tcl/rw11/dmhbpt.tcl @@ -1,6 +1,6 @@ -# $Id: dmhbpt.tcl 701 2015-07-19 12:58:29Z mueller $ +# $Id: dmhbpt.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2015- 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-04-22 833 1.0.1 hb_set: use imap_range2addr, allow regnam and range # 2015-07-17 701 1.0 Initial version # 2015-07-05 697 0.1 First draft # @@ -32,7 +33,7 @@ namespace eval rw11 { # # hb_set: set breakpoint # - proc hb_set {cpu unit type lolim {hilim 0} } { + proc hb_set {cpu unit type lo {hi ""} } { hb_ucheck $cpu $unit if {![regexp {^[ksu]?[rwi]+$} $type]} { error "hb_set-E: bad type '$type', only ksu and iwr allowed" @@ -44,7 +45,10 @@ namespace eval rw11 { if {[string match *k* $type]} {set mode 0} if {[string match *s* $type]} {set mode 1} if {[string match *u* $type]} {set mode 3} - if {$hilim < $lolim} {set hilim $lolim} + + set aran [rw11::imap_range2addr $cpu $lo $hi] + set lolim [lindex $aran 0] + set hilim [lindex $aran 1] $cpu cp -wreg "hb${unit}.cntl" \ [regbld rw11::HB_CNTL [list mode $mode] \ diff --git a/tools/tcl/rw11/shell.tcl b/tools/tcl/rw11/shell.tcl index 2ff2b7d8..f5c55b96 100644 --- a/tools/tcl/rw11/shell.tcl +++ b/tools/tcl/rw11/shell.tcl @@ -1,4 +1,4 @@ -# $Id: shell.tcl 872 2017-04-09 20:48:05Z mueller $ +# $Id: shell.tcl 883 2017-04-22 11:57:38Z mueller $ # # Copyright 2015-2017 by Walter F.J. Mueller # @@ -13,6 +13,8 @@ # # Revision History: # Date Rev Version Comment +# 2017-04-22 883 2.2.3 integrate rbmon: add .rme,.rmd,.rmf,.rml +# 2017-04-16 879 2.2.2 rename .cres->.crst and .cr->.cres (more intuitive) # 2017-04-09 872 2.2.1 adopt .ime to new interface # 2017-01-02 837 2.2 code re-shuffle; add cpu status in prompt # 2016-12-31 834 2.1 add '@' command @@ -26,6 +28,7 @@ package provide rw11 1.0 package require rlink package require rwxxtpp package require ibd_ibmon +package require rbmoni namespace eval rw11 { @@ -170,10 +173,10 @@ namespace eval rw11 { .c3 {set rval [shell_setcpu $cname]} .cs {set rval [shell_cs {*}$cargs]} - .cr {set rval [shell_cr {*}$cargs]} + .cres {set rval [shell_cres {*}$cargs]} .csus {set rval [shell_csus {*}$cargs]} .csto {set rval [shell_csto {*}$cargs]} - .cres {set rval [shell_cres {*}$cargs]} + .crst {set rval [shell_crst {*}$cargs]} .csta {set rval [shell_csta {*}$cargs]} .bs {set rval [rw11::hb_set $shell_cpu {*}$cargs]} @@ -189,6 +192,11 @@ namespace eval rw11 { .imf {set rval [shell_imf {*}$cargs]} .iml {set rval [shell_iml {*}$cargs]} + .rme {set rval [shell_rme {*}$cargs]} + .rmd {set rval [shell_rmd {*}$cargs]} + .rmf {set rval [shell_rmf {*}$cargs]} + .rml {set rval [shell_rml {*}$cargs]} + . {set rval [shell_cls {*}$cargs]} ? {set rval [shell_clb {*}$cargs]} ?m {set rval [shell_clm {*}$cargs]} @@ -251,9 +259,9 @@ namespace eval rw11 { } # - # shell_cr: cpu resume ----------------------------------------------------- + # shell_cres: cpu resume --------------------------------------------------- # - proc shell_cr {} { + proc shell_cres {} { variable shell_cpu variable shell_cpu_stat @@ -286,9 +294,9 @@ namespace eval rw11 { } # - # shell_cres: cpu reset ---------------------------------------------------- + # shell_crst: cpu reset ---------------------------------------------------- # - proc shell_cres {} { + proc shell_crst {} { variable shell_cpu $shell_cpu cp -stop $shell_cpu cp -creset @@ -340,7 +348,7 @@ namespace eval rw11 { variable shell_cme_pend variable shell_cme_mode - if {![shell_test_device $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "cme" "cm.cntl" "dmcmon"]} {return ""} rw11::cme $shell_cpu $mode set shell_cme_pend 0 @@ -355,7 +363,7 @@ namespace eval rw11 { variable shell_cpu variable shell_cme_pend - if {![shell_test_device $shell_cpu "cmd" "cm.cntl" "dmcmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "cmd" "cm.cntl" "dmcmon"]} {return ""} set shell_cme_pend 0 rw11::cm_stop $shell_cpu @@ -368,7 +376,7 @@ namespace eval rw11 { proc shell_cml {{nent -1}} { variable shell_cpu variable shell_cme_pend - if {![shell_test_device $shell_cpu "cml" "cm.cntl" "dmcmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "cml" "cm.cntl" "dmcmon"]} {return ""} set shell_cme_pend 1 return [rw11::cml $shell_cpu $nent] @@ -379,7 +387,7 @@ namespace eval rw11 { # proc shell_ime {{mode "lrc"}} { variable shell_cpu - if {![shell_test_device $shell_cpu "ime" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "ime" "im.cntl" "ibmon"]} {return ""} ibd_ibmon::ime $shell_cpu $mode return "" @@ -390,7 +398,7 @@ namespace eval rw11 { # proc shell_imd {} { variable shell_cpu - if {![shell_test_device $shell_cpu "imd" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "imd" "im.cntl" "ibmon"]} {return ""} ibd_ibmon::stop $shell_cpu return "" @@ -401,7 +409,7 @@ namespace eval rw11 { # proc shell_imf {{lo ""} {hi ""}} { variable shell_cpu - if {![shell_test_device $shell_cpu "imf" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_cpurmap $shell_cpu "imf" "im.cntl" "ibmon"]} {return ""} ibd_ibmon::imf $shell_cpu $lo $hi return "" @@ -412,12 +420,49 @@ namespace eval rw11 { # proc shell_iml {{nent -1}} { variable shell_cpu - if {![shell_test_device $shell_cpu "iml" "im.cntl" "ibmon"]} {return ""} + if {![shell_test_cpurmap $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] } + # + # shell_rme: rbmon enable -------------------------------------------------- + # + proc shell_rme {{mode ""}} { + if {![shell_test_rlcamap "rme" "rm.cntl" "rbmon"]} {return ""} + rbmoni::rme $mode + return "" + } + + # + # shell_rmd: rbmon diasable ------------------------------------------------- + # + proc shell_rmd {} { + if {![shell_test_rlcamap "rmd" "rm.cntl" "rbmon"]} {return ""} + rbmoni::stop + return "" + } + + # + # shell_rmf: rbmon filter --------------------------------------------------- + # + proc shell_rmf {{lo ""} {hi ""}} { + if {![shell_test_rlcamap "rmf" "rm.cntl" "rbmon"]} {return ""} + rbmoni::rmf $lo $hi + return "" + } + + # + # shell_rml: rbmon list ----------------------------------------------------- + # + proc shell_rml {{nent -1}} { + if {![shell_test_rlcamap "rml" "rm.cntl" "rbmon"]} {return ""} + set mondat [rbmoni::read $nent] + if {![llength $mondat]} {return ""} + return [rbmoni::print $mondat] + } + # # shell_cls: cpu short status ---------------------------------------------- # @@ -541,11 +586,11 @@ namespace eval rw11 { } } append rval "\n .cs ?nstep? ; cpu step" - append rval "\n .cr ; cpu resume" + append rval "\n .cres ; cpu resume" append rval "\n .csus ; cpu suspend" append rval "\n .csto ; cpu stop" - append rval "\n .cres ; cpu reset" append rval "\n .csta ?addr? ; cpu start" + append rval "\n .crst ; cpu reset" append rval "\n . ; short cpu state (pc+psw)" append rval "\n ? ; brief cpu state (all regs)" append rval "\n ?m ; mmu status" @@ -560,19 +605,26 @@ namespace eval rw11 { append rval "\n .bs ind typ lo hi ; set bpt" append rval "\n .br ?ind? ; remove bpt" append rval "\n .bl ; list bpt" - if {[$shell_cpu rmap -testname "cm.cntl"]} { + if {[$shell_cpu get hascmon]} { append rval "\nCPU monitor:" append rval "\n .cme ?mode? ; cmon enable; mode:\[is\]?n?" append rval "\n .cmd ; cmon disable" append rval "\n .cml ?nent? ; cmon list" } - if {[$shell_cpu rmap -testname "im.cntl"]} { + if {[$shell_cpu get hasibmon]} { append rval "\nibus monitor:" append rval "\n .ime ; ibmon enable; mode: \[lrcnRW\]*" append rval "\n .imd ; ibmon disable" append rval "\n .imf ?lo? ?hi? ; ibmon filter" append rval "\n .iml ?nent? ; ibmon list" } + if {[rlc get hasrbmon]} { + append rval "\nrbus monitor:" + append rval "\n .rme ; rbmon enable; mode: \[nRW\]*" + append rval "\n .rmd ; rbmon disable" + append rval "\n .rmf ?lo? ?hi? ; rbmon filter" + append rval "\n .rml ?nent? ; rbmon list" + } append rval "\nconsole (tta0) direct input:" append rval "\n ( ?text? ; tta0 input without cr" append rval "\n < ?text? ; tta0 input with cr" @@ -626,9 +678,9 @@ namespace eval rw11 { } # - # shell_test_device: test whether cpu option available --------------------- + # shell_test_cpurmap: test whether cpu option available --------------------- # - proc shell_test_device {cpu cmd regnam optnam} { + proc shell_test_cpurmap {cpu cmd regnam optnam} { if {[$cpu rmap -testname $regnam]} { return 1; } @@ -636,6 +688,17 @@ namespace eval rw11 { return 0; } + # + # shell_test_rlcamap: test whether rbus option available -------------------- + # + proc shell_test_rlcamap {cmd regnam optnam} { + if {[rlc amap -testname $regnam]} { + return 1; + } + puts "shell-W: '$cmd' command ignored, '$optnam' rbus option not available" + return 0; + } + # # shell_update_cpu_stat ---------------------------------------------------- # diff --git a/tools/tcl/rw11/util.tcl b/tools/tcl/rw11/util.tcl index a5f82f0d..bac3f341 100644 --- a/tools/tcl/rw11/util.tcl +++ b/tools/tcl/rw11/util.tcl @@ -1,4 +1,4 @@ -# $Id: util.tcl 849 2017-02-05 22:30:03Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # # Copyright 2013-2017 by Walter F.J. Mueller # @@ -13,6 +13,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-04-22 83 1.3.8 move in imap_reg2addr; add imap_range2addr # 2017-02-04 848 1.3.7 add DEUNA; setup_cntl: handle not found devices # 2015-12-30 721 1.3.6 BUGFIX: setup_ostr: adopt to use args2opts # 2015-07-25 704 1.3.5 use args2opts @@ -224,4 +225,40 @@ namespace eval rw11 { append p_cc [expr {$ps_c ? "c" : "."}] return "${p_cmode}${p_pmode}${ps_rset}${ps_pri}${p_tflag}${p_cc}" } + + # + # 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'" + } + } + # + # imap_range2addr: convert register range to address range ----------------- + # Note: also used for general address ranges, so no check on >= 0160000 + # + proc imap_range2addr {cpu lo {hi ""}} { + set lolist [split $lo "/"] + if {[llength $lolist] > 2} { + error "imap_range2addr-E: bad lo specifier '$lo', use val or val/len" + } + set lolim [imap_reg2addr $cpu [lindex $lolist 0]] + set hilim $lolim + 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 "imap_range2addr-E: hilim must be >= lolim"} + + return [list $lolim $hilim] + } } diff --git a/tools/tcl/tst_rlink/util.tcl b/tools/tcl/tst_rlink/util.tcl index 0029a3b6..74ff22c0 100644 --- a/tools/tcl/tst_rlink/util.tcl +++ b/tools/tcl/tst_rlink/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 603 2014-11-09 22:50:26Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2014 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 2.0.1 setup: now idempotent # 2014-11-09 603 2.0 use rlink v4 address layout # 2011-04-17 376 1.0.1 add proc scan_baud # 2011-04-02 375 1.0 Initial version @@ -33,14 +34,15 @@ namespace eval tst_rlink { # setup: amap definitions for tst_rlink # proc setup {} { - rlc amap -clear; # clear first to allow re-run rlink::setup; rbtest::setup 0xffe0; rbmoni::setup 0xffe8; rbemon::setup 0xffd0; rbbram::setup 0xfe00; - rlc amap -insert timer.1 0xfe11; - rlc amap -insert timer.0 0xfe10; + if {![rlc amap -testname timer.0]} { + rlc amap -insert timer.1 0xfe11; + rlc amap -insert timer.0 0xfe10; + } rbs3hio::setup 0xfef0; } diff --git a/tools/tcl/tst_sram/util.tcl b/tools/tcl/tst_sram/util.tcl index e04d77d7..dfccb0a1 100644 --- a/tools/tcl/tst_sram/util.tcl +++ b/tools/tcl/tst_sram/util.tcl @@ -1,6 +1,6 @@ -# $Id: util.tcl 785 2016-07-10 12:22:41Z mueller $ +# $Id: util.tcl 883 2017-04-22 11:57:38Z mueller $ # -# Copyright 2011-2016 by Walter F.J. Mueller +# Copyright 2011-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-04-22 883 1.2.1 setup: now idempotent # 2016-07-09 784 1.2 22bit support: mask sstat(wide); add iswide # 2015-04-03 661 1.1 drop estatdef (stat err check default now) # 2014-08-14 582 1.0.1 add srun* procs; add nscmd and tout variables @@ -43,6 +44,7 @@ namespace eval tst_sram { # setup: amap definitions for tst_sram core design ------------------------- # proc setup {{base 0x0000}} { + if {[rlc amap -testname sr.mdih $base]} {return ""} rlc amap -insert sr.mdih [expr {$base + 0x00}] rlc amap -insert sr.mdil [expr {$base + 0x01}] rlc amap -insert sr.mdoh [expr {$base + 0x02}]