diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 295200ec..f5df0494 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -17,6 +17,10 @@ software or firmware builds or that the documentation is consistent. The full set of tests is only run for tagged releases._ ### Summary +- tcl command handling update + - support now sub-command handling + - support dynamically created commands (like 'virt') + - support command info (via '?' option) - move to Ubuntu 16.04 as development platform - document urjtag build (jtag in Ubuntu 16.04 is broken) - add environment sanity wrappers for acroread,awk,firefox to ensure diff --git a/tools/src/librw11/Makefile b/tools/src/librw11/Makefile index 89f4f0e8..8d876822 100644 --- a/tools/src/librw11/Makefile +++ b/tools/src/librw11/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 733 2016-02-20 12:24:13Z mueller $ +# $Id: Makefile 859 2017-03-11 22:36:45Z mueller $ # # Revision History: # Date Rev Version Comment @@ -37,7 +37,8 @@ OBJ_all += Rw11CntlRHRP.o Rw11UnitRHRP.o OBJ_all += Rw11CntlTM11.o Rw11UnitTM11.o OBJ_all += Rw11Virt.o OBJ_all += Rw11VirtTerm.o Rw11VirtTermPty.o Rw11VirtTermTcp.o -OBJ_all += Rw11VirtDisk.o Rw11VirtDiskFile.o +OBJ_all += Rw11VirtDiskBuffer.o +OBJ_all += Rw11VirtDisk.o Rw11VirtDiskFile.o Rw11VirtDiskOver.o OBJ_all += Rw11VirtTape.o Rw11VirtTapeTap.o OBJ_all += Rw11VirtStream.o OBJ_all += Rw11Rdma.o Rw11RdmaDisk.o diff --git a/tools/src/librw11/Rw11UnitTapeBase.ipp b/tools/src/librw11/Rw11UnitTapeBase.ipp index 6a1f96f0..e6d188bc 100644 --- a/tools/src/librw11/Rw11UnitTapeBase.ipp +++ b/tools/src/librw11/Rw11UnitTapeBase.ipp @@ -1,4 +1,4 @@ -// $Id: Rw11UnitTapeBase.ipp 686 2015-06-04 21:08:08Z mueller $ +// $Id: Rw11UnitTapeBase.ipp 864 2017-04-02 13:20:18Z mueller $ // // Copyright 2015- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: Rw11UnitTapeBase.ipp 686 2015-06-04 21:08:08Z mueller $ + \version $Id: Rw11UnitTapeBase.ipp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation (inline) of Rw11UnitTapeBase. */ @@ -78,8 +78,7 @@ void Rw11UnitTapeBase::Dump(std::ostream& os, int ind, template void Rw11UnitTapeBase::AttachDone() { - // transfer, if defined, wprot and capacity from unit to virt - if (WProt()) Virt()->SetWProt(true); + // transfer, if defined capacity from unit to virt if (Capacity()!=0 && Virt()->Capacity()==0) Virt()->SetCapacity(Capacity()); Cntl().UnitSetup(Index()); return; diff --git a/tools/src/librw11/Rw11Virt.cpp b/tools/src/librw11/Rw11Virt.cpp index 0347aac5..d26fc992 100644 --- a/tools/src/librw11/Rw11Virt.cpp +++ b/tools/src/librw11/Rw11Virt.cpp @@ -1,6 +1,6 @@ -// $Id: Rw11Virt.cpp 495 2013-03-06 17:13:48Z mueller $ +// $Id: Rw11Virt.cpp 864 2017-04-02 13:20:18Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-02 864 1.1 add fWProt,WProt() // 2013-03-06 495 1.0 Initial version // 2013-02-13 488 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rw11Virt.cpp 495 2013-03-06 17:13:48Z mueller $ + \version $Id: Rw11Virt.cpp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation of Rw11Virt. */ @@ -43,6 +44,7 @@ namespace Retro { Rw11Virt::Rw11Virt(Rw11Unit* punit) : fpUnit(punit), fUrl(), + fWProt(false), fStats() {} @@ -55,6 +57,14 @@ Rw11Virt::~Rw11Virt() //------------------------------------------+----------------------------------- //! FIXME_docs +bool Rw11Virt::WProt() const +{ + return fWProt; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + void Rw11Virt::Dump(std::ostream& os, int ind, const char* text) const { RosFill bl(ind); @@ -62,6 +72,7 @@ void Rw11Virt::Dump(std::ostream& os, int ind, const char* text) const os << bl << " fpUnit: " << fpUnit << endl; fUrl.Dump(os, ind+2, "fUrl: "); + os << bl << " fWProt: " << fWProt << endl; fStats.Dump(os, ind+2, "fStats: "); return; } diff --git a/tools/src/librw11/Rw11Virt.hpp b/tools/src/librw11/Rw11Virt.hpp index 7dd188d4..e66f9e6c 100644 --- a/tools/src/librw11/Rw11Virt.hpp +++ b/tools/src/librw11/Rw11Virt.hpp @@ -1,6 +1,6 @@ -// $Id: Rw11Virt.hpp 495 2013-03-06 17:13:48Z mueller $ +// $Id: Rw11Virt.hpp 864 2017-04-02 13:20:18Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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-02 864 1.1 add fWProt,WProt() // 2013-03-06 495 1.0 Initial version // 2013-02-13 488 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: Rw11Virt.hpp 495 2013-03-06 17:13:48Z mueller $ + \version $Id: Rw11Virt.hpp 864 2017-04-02 13:20:18Z mueller $ \brief Declaration of class Rw11Virt. */ @@ -50,6 +51,7 @@ namespace Retro { Rw11& W11() const; RlinkServer& Server() const; RlogFile& LogFile() const; + virtual bool WProt() const; virtual bool Open(const std::string& url, RerrMsg& emsg) = 0; @@ -65,7 +67,8 @@ namespace Retro { protected: Rw11Unit* fpUnit; // +// Copyright 2013-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,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-02 864 1.1 add Rw11VirtDiskOver // 2013-03-03 494 1.0 Initial version // 2013-02-13 488 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rw11VirtDisk.cpp 509 2013-04-21 20:46:20Z mueller $ + \version $Id: Rw11VirtDisk.cpp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation of Rw11VirtDisk. */ #include @@ -27,6 +28,7 @@ #include "librtools/RosFill.hpp" #include "librtools/RparseUrl.hpp" #include "Rw11VirtDiskFile.hpp" +#include "Rw11VirtDiskOver.hpp" #include "Rw11VirtDisk.hpp" @@ -73,6 +75,10 @@ Rw11VirtDisk* Rw11VirtDisk::New(const std::string& url, Rw11Unit* punit, p.reset(new Rw11VirtDiskFile(punit)); if (p->Open(url, emsg)) return p.release(); + } else if (scheme == "over") { // scheme -> over: + p.reset(new Rw11VirtDiskOver(punit)); + if (p->Open(url, emsg)) return p.release(); + } else { // scheme -> no match emsg.Init("Rw11VirtDisk::New", string("Scheme '") + scheme + "' is not supported"); diff --git a/tools/src/librw11/Rw11VirtDisk.hpp b/tools/src/librw11/Rw11VirtDisk.hpp index cf137cf3..16c3c531 100644 --- a/tools/src/librw11/Rw11VirtDisk.hpp +++ b/tools/src/librw11/Rw11VirtDisk.hpp @@ -1,6 +1,6 @@ -// $Id: Rw11VirtDisk.hpp 509 2013-04-21 20:46:20Z mueller $ +// $Id: Rw11VirtDisk.hpp 864 2017-04-02 13:20:18Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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 @@ -20,7 +20,7 @@ /*! \file - \version $Id: Rw11VirtDisk.hpp 509 2013-04-21 20:46:20Z mueller $ + \version $Id: Rw11VirtDisk.hpp 864 2017-04-02 13:20:18Z mueller $ \brief Declaration of class Rw11VirtDisk. */ diff --git a/tools/src/librw11/Rw11VirtDiskBuffer.cpp b/tools/src/librw11/Rw11VirtDiskBuffer.cpp new file mode 100644 index 00000000..4c672a20 --- /dev/null +++ b/tools/src/librw11/Rw11VirtDiskBuffer.cpp @@ -0,0 +1,73 @@ +// $Id: Rw11VirtDiskBuffer.cpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-10 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtDiskBuffer.cpp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation of Rw11VirtDiskBuffer. +*/ + +#include + +#include "Rw11VirtDiskBuffer.hpp" + +using namespace std; + +/*! + \class Retro::Rw11VirtDiskBuffer + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11VirtDiskBuffer::Rw11VirtDiskBuffer(size_t blksize) + : fBuf(blksize, 0), + fNWrite(0) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11VirtDiskBuffer::~Rw11VirtDiskBuffer() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtDiskBuffer::Read(uint8_t* data) +{ + ::memcpy(data, fBuf.data(), fBuf.size()); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtDiskBuffer::Write(const uint8_t* data) +{ + ::memcpy(fBuf.data(), data, fBuf.size()); + fNWrite += 1; + if (fNWrite == 0) fNWrite -= 1; // stop at max + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtDiskBuffer.hpp b/tools/src/librw11/Rw11VirtDiskBuffer.hpp new file mode 100644 index 00000000..3f3fddeb --- /dev/null +++ b/tools/src/librw11/Rw11VirtDiskBuffer.hpp @@ -0,0 +1,57 @@ +// $Id: Rw11VirtDiskBuffer.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-10 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11VirtDiskBuffer.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of class Rw11VirtDiskBuffer. +*/ + +#ifndef included_Retro_Rw11VirtDiskBuffer +#define included_Retro_Rw11VirtDiskBuffer 1 + +#include +#include + +namespace Retro { + + class Rw11VirtDiskBuffer { + public: + + explicit Rw11VirtDiskBuffer(size_t blksize); + ~Rw11VirtDiskBuffer(); + + void Read(uint8_t* data); + void Write(const uint8_t* data); + + size_t BlockSize() const; + uint8_t* Data(); + const uint8_t* Data() const; + uint32_t NWrite() const; + + protected: + std::vector fBuf; + uint32_t fNWrite; + }; + +} // end namespace Retro + +#include "Rw11VirtDiskBuffer.ipp" + +#endif diff --git a/tools/src/librw11/Rw11VirtDiskBuffer.ipp b/tools/src/librw11/Rw11VirtDiskBuffer.ipp new file mode 100644 index 00000000..dadaef71 --- /dev/null +++ b/tools/src/librw11/Rw11VirtDiskBuffer.ipp @@ -0,0 +1,60 @@ +// $Id: Rw11VirtDiskBuffer.ipp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-10 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtDiskBuffer.ipp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation (inline) of Rw11VirtDiskBuffer. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t Rw11VirtDiskBuffer::BlockSize() const +{ + return fBuf.size(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint8_t* Rw11VirtDiskBuffer::Data() +{ + return fBuf.data(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const uint8_t* Rw11VirtDiskBuffer::Data() const +{ + return fBuf.data(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint32_t Rw11VirtDiskBuffer::NWrite() const +{ + return fNWrite; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtDiskFile.cpp b/tools/src/librw11/Rw11VirtDiskFile.cpp index 1da51f5c..2a96a8e6 100644 --- a/tools/src/librw11/Rw11VirtDiskFile.cpp +++ b/tools/src/librw11/Rw11VirtDiskFile.cpp @@ -1,6 +1,6 @@ -// $Id: Rw11VirtDiskFile.cpp 684 2015-05-24 14:10:59Z mueller $ +// $Id: Rw11VirtDiskFile.cpp 859 2017-03-11 22:36:45Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2017-03-11 859 1.1 use fWProt // 2013-04-14 506 1.0 Initial version // 2013-02-13 488 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rw11VirtDiskFile.cpp 684 2015-05-24 14:10:59Z mueller $ + \version $Id: Rw11VirtDiskFile.cpp 859 2017-03-11 22:36:45Z mueller $ \brief Implemenation of Rw11VirtDiskFile. */ @@ -64,10 +65,10 @@ Rw11VirtDiskFile::~Rw11VirtDiskFile() bool Rw11VirtDiskFile::Open(const std::string& url, RerrMsg& emsg) { if (!fUrl.Set(url, "|wpro|", emsg)) return false; - - bool wpro = fUrl.FindOpt("wpro"); - int fd = ::open(fUrl.Path().c_str(), wpro ? O_RDONLY : O_RDWR); + fWProt = fUrl.FindOpt("wpro"); + + int fd = ::open(fUrl.Path().c_str(), fWProt ? O_RDONLY : O_RDWR); if (fd < 0) { emsg.InitErrno("Rw11VirtDiskFile::Open()", string("open() for '") + fUrl.Path() + "' failed: ", errno); @@ -81,6 +82,8 @@ bool Rw11VirtDiskFile::Open(const std::string& url, RerrMsg& emsg) return false; } + if ((sbuf.st_mode & S_IWUSR) == 0) fWProt = true; + fFd = fd; fSize = sbuf.st_size; return true; diff --git a/tools/src/librw11/Rw11VirtDiskFile.hpp b/tools/src/librw11/Rw11VirtDiskFile.hpp index 195005d6..6fa4231a 100644 --- a/tools/src/librw11/Rw11VirtDiskFile.hpp +++ b/tools/src/librw11/Rw11VirtDiskFile.hpp @@ -1,4 +1,4 @@ -// $Id: Rw11VirtDiskFile.hpp 509 2013-04-21 20:46:20Z mueller $ +// $Id: Rw11VirtDiskFile.hpp 859 2017-03-11 22:36:45Z mueller $ // // Copyright 2013- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: Rw11VirtDiskFile.hpp 509 2013-04-21 20:46:20Z mueller $ + \version $Id: Rw11VirtDiskFile.hpp 859 2017-03-11 22:36:45Z mueller $ \brief Declaration of class Rw11VirtDiskFile. */ @@ -46,6 +46,11 @@ namespace Retro { virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + // statistics counter indices (now new) + enum stats { + kDimStat = Rw11VirtDisk::kDimStat + }; + protected: bool Seek(size_t seekpos, RerrMsg& emsg); diff --git a/tools/src/librw11/Rw11VirtDiskOver.cpp b/tools/src/librw11/Rw11VirtDiskOver.cpp new file mode 100644 index 00000000..29b0125d --- /dev/null +++ b/tools/src/librw11/Rw11VirtDiskOver.cpp @@ -0,0 +1,180 @@ +// $Id: Rw11VirtDiskOver.cpp 864 2017-04-02 13:20:18Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-10 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtDiskOver.cpp 864 2017-04-02 13:20:18Z mueller $ + \brief Implemenation of Rw11VirtDiskOver. +*/ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" + +#include "Rw11VirtDiskOver.hpp" + +using namespace std; + +/*! + \class Retro::Rw11VirtDiskOver + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11VirtDiskOver::Rw11VirtDiskOver(Rw11Unit* punit) + : Rw11VirtDiskFile(punit), + fBlkMap() +{ + fStats.Define(kStatNVDReadOver, "NVDReadOver", "Read() calls over"); + fStats.Define(kStatNVDReadBlkOver, "NVDReadBlkOver", "blocks read from over"); + fStats.Define(kStatNVDWriteOver, "NVDWriteOver", "Write() calls over"); + fStats.Define(kStatNVDWriteBlkOver,"NVDWriteBlkOver","blocks written to over"); + fStats.Define(kStatNVDFlushOver, "NVDFlushOver", "Flush() calls"); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11VirtDiskOver::~Rw11VirtDiskOver() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtDiskOver::WProt() const +{ + return false; // from unit always writable !! +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtDiskOver::Open(const std::string& url, RerrMsg& emsg) +{ + // FIXME_code: do we need to handle wpro ? + // FIXME_code: at this point assume that parent ignore proto + return Rw11VirtDiskFile::Open(url, emsg); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtDiskOver::Read(size_t lba, size_t nblk, uint8_t* data, + RerrMsg& emsg) +{ + fStats.Inc(kStatNVDReadOver); + auto it = fBlkMap.lower_bound(lba); + if (it == fBlkMap.end() || it->first >= lba+nblk) { // no match + return Rw11VirtDiskFile::Read(lba, nblk, data, emsg); // one swoop from disk + } else { // match + for (size_t i=0; isecond).Read(data+i*fBlkSize); + fStats.Inc(kStatNVDReadBlkOver); + } + } + } + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtDiskOver::Write(size_t lba, size_t nblk, const uint8_t* data, + RerrMsg& emsg) +{ + fStats.Inc(kStatNVDWriteOver); + fStats.Inc(kStatNVDWriteBlkOver, double(nblk)); + for (size_t i=0; isecond).Write(data+i*fBlkSize); + } + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtDiskOver::Flush(RerrMsg& emsg) +{ + if (fWProt) { + emsg.Init("Rw11VirtDiskOver::Flush()", "file write protected"); + return false; + } + + fStats.Inc(kStatNVDFlushOver); + for (auto& kv: fBlkMap) { + bool rc = Rw11VirtDiskFile::Write(kv.first, 1, kv.second.Data(), emsg); + if (!rc) return rc; + } + fBlkMap.clear(); + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtDiskOver::List(std::ostream& os) const +{ + if (fBlkMap.empty()) return; + + uint32_t lbabeg = fBlkMap.begin()->first; // first lba + uint32_t nwrite = 0; + for (auto it=fBlkMap.begin(); it!=fBlkMap.end(); ) { + auto itnext = next(it); + if (itnext == fBlkMap.end() || itnext->first != (it->first)+1) { + os << RosPrintf(lbabeg,"d",8) + << " .. " << RosPrintf(it->first,"d",8) + << " : nb=" << RosPrintf(it->first-lbabeg+1,"d",8) + << " nw=" << RosPrintf(nwrite,"d",8) << endl; + if (itnext != fBlkMap.end()) lbabeg = itnext->first; + nwrite = 0; + } else { + nwrite += (it->second).NWrite(); + } + it = itnext; + } + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtDiskOver::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11VirtDiskOver @ " << this << endl; + + os << bl << " fBlkMap.size " << fBlkMap.size() << endl; + Rw11VirtDiskFile::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtDiskOver.hpp b/tools/src/librw11/Rw11VirtDiskOver.hpp new file mode 100644 index 00000000..134ec9f7 --- /dev/null +++ b/tools/src/librw11/Rw11VirtDiskOver.hpp @@ -0,0 +1,80 @@ +// $Id: Rw11VirtDiskOver.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-10 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11VirtDiskOver.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of class Rw11VirtDiskOver. +*/ + +#ifndef included_Retro_Rw11VirtDiskOver +#define included_Retro_Rw11VirtDiskOver 1 + +#include + +#include "Rw11VirtDiskBuffer.hpp" + +#include "Rw11VirtDiskFile.hpp" + +namespace Retro { + + class Rw11VirtDiskOver : public Rw11VirtDiskFile { + public: + + typedef std::map bmap_t; + typedef bmap_t::iterator bmap_it_t; + typedef bmap_t::const_iterator bmap_cit_t; + typedef bmap_t::value_type bmap_val_t; + + explicit Rw11VirtDiskOver(Rw11Unit* punit); + ~Rw11VirtDiskOver(); + + virtual bool WProt() const; + + bool Open(const std::string& url, RerrMsg& emsg); + + virtual bool Read(size_t lba, size_t nblk, uint8_t* data, + RerrMsg& emsg); + virtual bool Write(size_t lba, size_t nblk, const uint8_t* data, + RerrMsg& emsg); + + bool Flush(RerrMsg& emsg); + void List(std::ostream& os) const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices (now new) + enum stats { + kStatNVDReadOver = Rw11VirtDiskFile::kDimStat, + kStatNVDReadBlkOver, + kStatNVDWriteOver, + kStatNVDWriteBlkOver, + kStatNVDFlushOver, + kDimStat + }; + + protected: + bmap_t fBlkMap; + }; + +} // end namespace Retro + +//#include "Rw11VirtDiskOver.ipp" + +#endif diff --git a/tools/src/librw11/Rw11VirtStream.cpp b/tools/src/librw11/Rw11VirtStream.cpp index 0a408c7a..ebc75ef2 100644 --- a/tools/src/librw11/Rw11VirtStream.cpp +++ b/tools/src/librw11/Rw11VirtStream.cpp @@ -1,6 +1,6 @@ -// $Id: Rw11VirtStream.cpp 516 2013-05-05 21:24:52Z mueller $ +// $Id: Rw11VirtStream.cpp 864 2017-04-02 13:20:18Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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-02 864 1.0.2 signal for input streams WProt // 2013-05-05 516 1.0.1 Open(): support ?app and ?bck=n options // 2013-05-04 515 1.0 Initial version // 2013-05-01 513 0.1 First draft @@ -20,7 +21,7 @@ /*! \file - \version $Id: Rw11VirtStream.cpp 516 2013-05-05 21:24:52Z mueller $ + \version $Id: Rw11VirtStream.cpp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation of Rw11VirtStream. */ #include @@ -88,6 +89,7 @@ bool Rw11VirtStream::Open(const std::string& url, RerrMsg& emsg) fFile = ::fopen(fUrl.Path().c_str(), fUrl.FindOpt("app") ? "a" : "w"); } else { // handle input streams + fWProt = true; if (!fUrl.Set(url, "", emsg)) return false; fFile = ::fopen(fUrl.Path().c_str(), "r"); } diff --git a/tools/src/librw11/Rw11VirtTape.cpp b/tools/src/librw11/Rw11VirtTape.cpp index 894ee7f9..00a78eb8 100644 --- a/tools/src/librw11/Rw11VirtTape.cpp +++ b/tools/src/librw11/Rw11VirtTape.cpp @@ -1,4 +1,4 @@ -// $Id: Rw11VirtTape.cpp 686 2015-06-04 21:08:08Z mueller $ +// $Id: Rw11VirtTape.cpp 864 2017-04-02 13:20:18Z mueller $ // // Copyright 2015- by Walter F.J. Mueller // @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-02 864 1.1 move fWProt,WProt() to Rw11Virt base // 2015-06-04 686 1.0 Initial version // 2015-05-17 683 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rw11VirtTape.cpp 686 2015-06-04 21:08:08Z mueller $ + \version $Id: Rw11VirtTape.cpp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation of Rw11VirtTape. */ #include @@ -46,7 +47,6 @@ namespace Retro { Rw11VirtTape::Rw11VirtTape(Rw11Unit* punit) : Rw11Virt(punit), - fWProt(false), fCapacity(0), fBot(false), fEot(false), @@ -157,7 +157,6 @@ void Rw11VirtTape::Dump(std::ostream& os, int ind, const char* text) const RosFill bl(ind); os << bl << (text?text:"--") << "Rw11VirtTape @ " << this << endl; - os << bl << " fWProt: " << fWProt << endl; os << bl << " fCapacity: " << fCapacity << endl; os << bl << " fBot: " << fBot << endl; os << bl << " fEot: " << fEot << endl; diff --git a/tools/src/librw11/Rw11VirtTape.hpp b/tools/src/librw11/Rw11VirtTape.hpp index be4774f0..3dc63a5b 100644 --- a/tools/src/librw11/Rw11VirtTape.hpp +++ b/tools/src/librw11/Rw11VirtTape.hpp @@ -1,6 +1,6 @@ -// $Id: Rw11VirtTape.hpp 686 2015-06-04 21:08:08Z mueller $ +// $Id: Rw11VirtTape.hpp 864 2017-04-02 13:20:18Z 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-02 864 1.1 move fWProt,WProt() to Rw11Virt base // 2015-06-04 686 1.0 Initial version // 2015-05-17 683 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: Rw11VirtTape.hpp 686 2015-06-04 21:08:08Z mueller $ + \version $Id: Rw11VirtTape.hpp 864 2017-04-02 13:20:18Z mueller $ \brief Declaration of class Rw11VirtTape. */ @@ -36,9 +37,7 @@ namespace Retro { explicit Rw11VirtTape(Rw11Unit* punit); ~Rw11VirtTape(); - void SetWProt(bool wprot); void SetCapacity(size_t nbyte); - bool WProt() const; size_t Capacity() const; virtual bool ReadRecord(size_t nbyte, uint8_t* data, size_t& ndone, @@ -96,7 +95,6 @@ namespace Retro { }; protected: - bool fWProt; // +// 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,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-02 864 1.1 move fWProt,WProt() to Rw11Virt base // 2015-06-04 686 1.0 Initial version // 2015-05-17 683 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rw11VirtTape.ipp 686 2015-06-04 21:08:08Z mueller $ + \version $Id: Rw11VirtTape.ipp 864 2017-04-02 13:20:18Z mueller $ \brief Implemenation (inline) of Rw11VirtTape. */ @@ -29,15 +30,6 @@ namespace Retro { //------------------------------------------+----------------------------------- //! FIXME_docs -inline void Rw11VirtTape::SetWProt(bool wprot) -{ - fWProt = wprot; - return; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - inline void Rw11VirtTape::SetCapacity(size_t nbyte) { fCapacity = nbyte; @@ -47,14 +39,6 @@ inline void Rw11VirtTape::SetCapacity(size_t nbyte) //------------------------------------------+----------------------------------- //! FIXME_docs -inline bool Rw11VirtTape::WProt() const -{ - return fWProt; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - inline size_t Rw11VirtTape::Capacity() const { return fCapacity; diff --git a/tools/src/librwxxtpp/Makefile b/tools/src/librwxxtpp/Makefile index 9d67c745..de0b54e1 100644 --- a/tools/src/librwxxtpp/Makefile +++ b/tools/src/librwxxtpp/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 733 2016-02-20 12:24:13Z mueller $ +# $Id: Makefile 859 2017-03-11 22:36:45Z mueller $ # # Revision History: # Date Rev Version Comment @@ -40,6 +40,9 @@ OBJ_all += RtclRw11CntlRK11.o RtclRw11UnitRK11.o OBJ_all += RtclRw11CntlRL11.o RtclRw11UnitRL11.o OBJ_all += RtclRw11CntlRHRP.o RtclRw11UnitRHRP.o OBJ_all += RtclRw11CntlTM11.o RtclRw11UnitTM11.o +OBJ_all += RtclRw11Virt.o +OBJ_all += RtclRw11VirtFactory.o +OBJ_all += RtclRw11VirtDiskOver.o # DEP_all = $(OBJ_all:.o=.dep) # diff --git a/tools/src/librwxxtpp/RtclRw11Unit.cpp b/tools/src/librwxxtpp/RtclRw11Unit.cpp index 665c53ac..bd754a17 100644 --- a/tools/src/librwxxtpp/RtclRw11Unit.cpp +++ b/tools/src/librwxxtpp/RtclRw11Unit.cpp @@ -1,6 +1,6 @@ -// $Id: RtclRw11Unit.cpp 504 2013-04-13 15:37:24Z mueller $ +// $Id: RtclRw11Unit.cpp 863 2017-04-02 11:43:15Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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,19 +13,21 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-02 863 1.1 add fpVirt; add DetachCleanup() // 2013-03-03 494 1.0 Initial version // 2013-02-16 488 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclRw11Unit.cpp 504 2013-04-13 15:37:24Z mueller $ + \version $Id: RtclRw11Unit.cpp 863 2017-04-02 11:43:15Z mueller $ \brief Implemenation of RtclRw11Unit. */ #include "boost/thread/locks.hpp" #include "boost/bind.hpp" +#include "librtools/Rexception.hpp" #include "librtcltools/RtclStats.hpp" #include "RtclRw11Unit.hpp" @@ -47,7 +49,8 @@ RtclRw11Unit::RtclRw11Unit(const std::string& type, Rw11Cpu* pcpu) : RtclProxyBase(type), fpCpu(pcpu), fGets(), - fSets() + fSets(), + fpVirt() { AddMeth("get", boost::bind(&RtclRw11Unit::M_get, this, _1)); AddMeth("set", boost::bind(&RtclRw11Unit::M_set, this, _1)); @@ -66,6 +69,17 @@ RtclRw11Unit::~RtclRw11Unit() //------------------------------------------+----------------------------------- //! FIXME_docs +void RtclRw11Unit::DetachCleanup() +{ + if (!fpVirt) return; + DelMeth("virt"); + fpVirt.reset(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + int RtclRw11Unit::M_get(RtclArgs& args) { // synchronize with server thread @@ -96,7 +110,10 @@ int RtclRw11Unit::M_attach(RtclArgs& args) RerrMsg emsg; // synchronize with server thread boost::lock_guard lock(fpCpu->Connect()); + + DetachCleanup(); if (!Obj().Attach(url, emsg)) return args.Quit(emsg); + AttachDone(); return kOK; } @@ -116,6 +133,19 @@ int RtclRw11Unit::M_detach(RtclArgs& args) //------------------------------------------+----------------------------------- //! FIXME_docs +int RtclRw11Unit::M_virt(RtclArgs& args) +{ + if (!fpVirt) throw Rexception("RtclRw11Unit::M_virt:", + "Bad state: fpVirt == nullptr"); + + // synchronize with server thread + boost::lock_guard lock(fpCpu->Connect()); + return fpVirt->DispatchCmd(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + int RtclRw11Unit::M_dump(RtclArgs& args) { if (!args.AllDone()) return kERR; diff --git a/tools/src/librwxxtpp/RtclRw11Unit.hpp b/tools/src/librwxxtpp/RtclRw11Unit.hpp index 842cc64a..c31885da 100644 --- a/tools/src/librwxxtpp/RtclRw11Unit.hpp +++ b/tools/src/librwxxtpp/RtclRw11Unit.hpp @@ -1,6 +1,6 @@ -// $Id: RtclRw11Unit.hpp 504 2013-04-13 15:37:24Z mueller $ +// $Id: RtclRw11Unit.hpp 863 2017-04-02 11:43:15Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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-02 863 1.1 add fpVirt,DetachCleanup(),AttachDone(),M_virt() // 2013-03-03 494 1.0 Initial version // 2013-02-16 488 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RtclRw11Unit.hpp 504 2013-04-13 15:37:24Z mueller $ + \version $Id: RtclRw11Unit.hpp 863 2017-04-02 11:43:15Z mueller $ \brief Declaration of class RtclRw11Unit. */ @@ -30,6 +31,8 @@ #include #include +#include "boost/scoped_ptr.hpp" + #include "librtcltools/RtclProxyBase.hpp" #include "librtcltools/RtclGetList.hpp" #include "librtcltools/RtclSetList.hpp" @@ -37,6 +40,8 @@ #include "librw11/Rw11Cpu.hpp" #include "librw11/Rw11Unit.hpp" +#include "RtclRw11Virt.hpp" + namespace Retro { class RtclRw11Unit : public RtclProxyBase { @@ -50,10 +55,13 @@ namespace Retro { RtclSetList& SetList(); protected: + virtual void AttachDone() = 0; + void DetachCleanup(); int M_get(RtclArgs& args); int M_set(RtclArgs& args); int M_attach(RtclArgs& args); int M_detach(RtclArgs& args); + int M_virt(RtclArgs& args); int M_dump(RtclArgs& args); int M_default(RtclArgs& args); @@ -61,6 +69,7 @@ namespace Retro { Rw11Cpu* fpCpu; RtclGetList fGets; RtclSetList fSets; + boost::scoped_ptr fpVirt; }; } // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Unit.ipp b/tools/src/librwxxtpp/RtclRw11Unit.ipp index b0ee64cc..d53e80c3 100644 --- a/tools/src/librwxxtpp/RtclRw11Unit.ipp +++ b/tools/src/librwxxtpp/RtclRw11Unit.ipp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Unit.ipp 504 2013-04-13 15:37:24Z mueller $ +// $Id: RtclRw11Unit.ipp 863 2017-04-02 11:43:15Z mueller $ // // Copyright 2013- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: RtclRw11Unit.ipp 504 2013-04-13 15:37:24Z mueller $ + \version $Id: RtclRw11Unit.ipp 863 2017-04-02 11:43:15Z mueller $ \brief Implemenation (inline) of RtclRw11Unit. */ diff --git a/tools/src/librwxxtpp/RtclRw11UnitBase.hpp b/tools/src/librwxxtpp/RtclRw11UnitBase.hpp index c13e6861..06c42315 100644 --- a/tools/src/librwxxtpp/RtclRw11UnitBase.hpp +++ b/tools/src/librwxxtpp/RtclRw11UnitBase.hpp @@ -1,6 +1,6 @@ -// $Id: RtclRw11UnitBase.hpp 504 2013-04-13 15:37:24Z mueller $ +// $Id: RtclRw11UnitBase.hpp 863 2017-04-02 11:43:15Z mueller $ // -// Copyright 2013- by Walter F.J. Mueller +// Copyright 2013-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-02 863 1.1 add AttachDone() // 2013-03-06 495 1.0 Initial version // 2013-02-16 488 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RtclRw11UnitBase.hpp 504 2013-04-13 15:37:24Z mueller $ + \version $Id: RtclRw11UnitBase.hpp 863 2017-04-02 11:43:15Z mueller $ \brief Declaration of class RtclRw11UnitBase. */ @@ -44,6 +45,7 @@ namespace Retro { const boost::shared_ptr& ObjSPtr(); protected: + virtual void AttachDone(); int M_stats(RtclArgs& args); protected: diff --git a/tools/src/librwxxtpp/RtclRw11UnitBase.ipp b/tools/src/librwxxtpp/RtclRw11UnitBase.ipp index c6672fd4..5044ea5d 100644 --- a/tools/src/librwxxtpp/RtclRw11UnitBase.ipp +++ b/tools/src/librwxxtpp/RtclRw11UnitBase.ipp @@ -1,6 +1,6 @@ -// $Id: RtclRw11UnitBase.ipp 680 2015-05-14 13:29:46Z mueller $ +// $Id: RtclRw11UnitBase.ipp 863 2017-04-02 11:43:15Z mueller $ // -// Copyright 2013-2015 by Walter F.J. Mueller +// Copyright 2013-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-02 863 1.2 add AttachDone() // 2015-05-14 680 1.1 fGets: add enabled (moved from RtclRw11UnitDisk) // 2013-03-06 495 1.0 Initial version // 2013-02-16 488 0.1 First draft @@ -20,11 +21,12 @@ /*! \file - \version $Id: RtclRw11UnitBase.ipp 680 2015-05-14 13:29:46Z mueller $ + \version $Id: RtclRw11UnitBase.ipp 863 2017-04-02 11:43:15Z mueller $ \brief Implemenation (all inline) of RtclRw11UnitBase. */ #include "librtcltools/RtclStats.hpp" +#include "RtclRw11VirtFactory.hpp" /*! \class Retro::RtclRw11UnitBase @@ -78,6 +80,20 @@ inline const boost::shared_ptr& RtclRw11UnitBase::ObjSPtr() //------------------------------------------+----------------------------------- //! FIXME_docs +template +void RtclRw11UnitBase::AttachDone() +{ + if (!Obj().Virt()) return; + RtclRw11Virt* pvirt=RtclRw11VirtFactory(Obj().Virt()); + if (!pvirt) return; + fpVirt.reset(pvirt); + AddMeth("virt", boost::bind(&RtclRw11Unit::M_virt, this, _1)); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + template int RtclRw11UnitBase::M_stats(RtclArgs& args) { diff --git a/tools/src/librwxxtpp/RtclRw11UnitDisk.cpp b/tools/src/librwxxtpp/RtclRw11UnitDisk.cpp index 98edc5c5..25aa3dea 100644 --- a/tools/src/librwxxtpp/RtclRw11UnitDisk.cpp +++ b/tools/src/librwxxtpp/RtclRw11UnitDisk.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11UnitDisk.cpp 680 2015-05-14 13:29:46Z mueller $ +// $Id: RtclRw11UnitDisk.cpp 863 2017-04-02 11:43:15Z mueller $ // // Copyright 2013-2015 by Walter F.J. Mueller // @@ -21,7 +21,7 @@ /*! \file - \version $Id: RtclRw11UnitDisk.cpp 680 2015-05-14 13:29:46Z mueller $ + \version $Id: RtclRw11UnitDisk.cpp 863 2017-04-02 11:43:15Z mueller $ \brief Implemenation of RtclRw11UnitDisk. */ diff --git a/tools/src/librwxxtpp/RtclRw11UnitDisk.hpp b/tools/src/librwxxtpp/RtclRw11UnitDisk.hpp index ba523862..b2a177af 100644 --- a/tools/src/librwxxtpp/RtclRw11UnitDisk.hpp +++ b/tools/src/librwxxtpp/RtclRw11UnitDisk.hpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11UnitDisk.hpp 509 2013-04-21 20:46:20Z mueller $ +// $Id: RtclRw11UnitDisk.hpp 863 2017-04-02 11:43:15Z mueller $ // // Copyright 2013- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RtclRw11UnitDisk.hpp 509 2013-04-21 20:46:20Z mueller $ + \version $Id: RtclRw11UnitDisk.hpp 863 2017-04-02 11:43:15Z mueller $ \brief Declaration of class RtclRw11UnitDisk. */ diff --git a/tools/src/librwxxtpp/RtclRw11Virt.cpp b/tools/src/librwxxtpp/RtclRw11Virt.cpp new file mode 100644 index 00000000..81335321 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Virt.cpp @@ -0,0 +1,105 @@ +// $Id: RtclRw11Virt.cpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Virt.cpp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation of RtclRw11Virt. +*/ + +#include "librtcltools/RtclStats.hpp" + +#include "RtclRw11Virt.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11Virt + \brief FIXME_docs +*/ + + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11Virt::RtclRw11Virt(Rw11Virt* pvirt) + : RtclCmdBase(), + fpVirt(pvirt), + fGets(), + fSets() +{ + AddMeth("get", boost::bind(&RtclRw11Virt::M_get, this, _1)); + AddMeth("set", boost::bind(&RtclRw11Virt::M_set, this, _1)); + AddMeth("stats", boost::bind(&RtclRw11Virt::M_stats, this, _1)); + AddMeth("dump", boost::bind(&RtclRw11Virt::M_dump, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclRw11Virt::~RtclRw11Virt() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Virt::M_get(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Virt()->Cpu().Connect()); + return fGets.M_get(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Virt::M_set(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Virt()->Cpu().Connect()); + return fSets.M_set(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Virt::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, Virt()->Stats())) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Virt::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + std::ostringstream sos; + Virt()->Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Virt.hpp b/tools/src/librwxxtpp/RtclRw11Virt.hpp new file mode 100644 index 00000000..c59b65e6 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Virt.hpp @@ -0,0 +1,61 @@ +// $Id: RtclRw11Virt.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11Virt.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of class RtclRw11Virt. +*/ + +#ifndef included_Retro_RtclRw11Virt +#define included_Retro_RtclRw11Virt 1 + +#include "librw11/Rw11Virt.hpp" + +#include "librtcltools/RtclGetList.hpp" +#include "librtcltools/RtclSetList.hpp" + +#include "librtcltools/RtclCmdBase.hpp" + +namespace Retro { + + class RtclRw11Virt : public RtclCmdBase { + public: + RtclRw11Virt(Rw11Virt* pvirt); + ~RtclRw11Virt(); + + Rw11Virt* Virt() const; + + protected: + int M_get(RtclArgs& args); + int M_set(RtclArgs& args); + int M_stats(RtclArgs& args); + int M_dump(RtclArgs& args); + + protected: + Rw11Virt* fpVirt; + RtclGetList fGets; + RtclSetList fSets; + }; + +} // end namespace Retro + +#include "RtclRw11Virt.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11Virt.ipp b/tools/src/librwxxtpp/RtclRw11Virt.ipp new file mode 100644 index 00000000..55189c22 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Virt.ipp @@ -0,0 +1,36 @@ +// $Id: RtclRw11Virt.ipp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Virt.ipp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation (inline) of RtclRw11Virt. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Virt* RtclRw11Virt::Virt() const +{ + return fpVirt; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11VirtBase.hpp b/tools/src/librwxxtpp/RtclRw11VirtBase.hpp new file mode 100644 index 00000000..e884b69a --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtBase.hpp @@ -0,0 +1,50 @@ +// $Id: RtclRw11VirtBase.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11VirtBase.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of class RtclRw11VirtBase. +*/ + +#ifndef included_Retro_RtclRw11VirtBase +#define included_Retro_RtclRw11VirtBase 1 + +#include "RtclRw11Virt.hpp" + +namespace Retro { + + template + class RtclRw11VirtBase : public RtclRw11Virt { + public: + RtclRw11VirtBase(TO* pobj); + ~RtclRw11VirtBase(); + + TO& Obj(); + + protected: + TO* fpObj; //!< ptr to object + }; + +} // end namespace Retro + +// implementation is all inline +#include "RtclRw11VirtBase.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11VirtBase.ipp b/tools/src/librwxxtpp/RtclRw11VirtBase.ipp new file mode 100644 index 00000000..7bcbed62 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtBase.ipp @@ -0,0 +1,59 @@ +// $Id: RtclRw11VirtBase.ipp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11VirtBase.ipp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation (all inline) of RtclRw11VirtBase. +*/ + +/*! + \class Retro::RtclRw11VirtBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +inline RtclRw11VirtBase::RtclRw11VirtBase(TO* pobj) + : RtclRw11Virt(pobj), + fpObj(pobj) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclRw11VirtBase::~RtclRw11VirtBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TO& RtclRw11VirtBase::Obj() +{ + return *fpObj; +} + + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp new file mode 100644 index 00000000..cc963b3c --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp @@ -0,0 +1,82 @@ +// $Id: RtclRw11VirtDiskOver.cpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 2013- 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11VirtDiskOver.cpp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation of RtclRw11VirtDiskOver. +*/ + +#include "RtclRw11VirtDiskOver.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11VirtDiskOver + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11VirtDiskOver::RtclRw11VirtDiskOver(Rw11VirtDiskOver* pobj) + : RtclRw11VirtBase(pobj) +{ + AddMeth("flush", boost::bind(&RtclRw11VirtDiskOver::M_flush, this, _1)); + AddMeth("list", boost::bind(&RtclRw11VirtDiskOver::M_list, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11VirtDiskOver::~RtclRw11VirtDiskOver() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11VirtDiskOver::M_flush(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + // synchronize with server thread + boost::lock_guard lock(Obj().Cpu().Connect()); + RerrMsg emsg; + if (!Obj().Flush(emsg)) return args.Quit(emsg); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11VirtDiskOver::M_list(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + + // synchronize with server thread + boost::lock_guard lock(Obj().Cpu().Connect()); + Obj().List(sos); + args.SetResult(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11VirtDiskOver.hpp b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.hpp new file mode 100644 index 00000000..b8da149f --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.hpp @@ -0,0 +1,49 @@ +// $Id: RtclRw11VirtDiskOver.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11VirtDiskOver.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of class RtclRw11VirtDiskOver. +*/ + +#ifndef included_Retro_RtclRw11VirtDiskOver +#define included_Retro_RtclRw11VirtDiskOver 1 + +#include "librw11/Rw11VirtDiskOver.hpp" + +#include "RtclRw11VirtBase.hpp" + +namespace Retro { + + class RtclRw11VirtDiskOver : public RtclRw11VirtBase { + public: + RtclRw11VirtDiskOver(Rw11VirtDiskOver* pobj); + ~RtclRw11VirtDiskOver(); + + protected: + int M_flush(RtclArgs& args); + int M_list(RtclArgs& args); + }; + +} // end namespace Retro + +//#include "RtclRw11VirtDiskOver.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11VirtFactory.cpp b/tools/src/librwxxtpp/RtclRw11VirtFactory.cpp new file mode 100644 index 00000000..c3937ec0 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtFactory.cpp @@ -0,0 +1,51 @@ +// $Id: RtclRw11VirtFactory.cpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 589 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11VirtFactory.cpp 859 2017-03-11 22:36:45Z mueller $ + \brief Implemenation of global function RtclRw11VirtFactory. +*/ + +#include "librw11/Rw11VirtDiskOver.hpp" + +#include "RtclRw11VirtDiskOver.hpp" + +#include "RtclRw11VirtFactory.hpp" + +using namespace std; + +// all method definitions in namespace Retro (avoid using in includes...) +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclRw11Virt* RtclRw11VirtFactory(Rw11Virt* pobj) +{ + // 'factory section', create concrete RtclRw11Virt objects + + Rw11VirtDiskOver* pdiskover = dynamic_cast(pobj); + if (pdiskover) { + return new RtclRw11VirtDiskOver(pdiskover); + } + + return nullptr; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11VirtFactory.hpp b/tools/src/librwxxtpp/RtclRw11VirtFactory.hpp new file mode 100644 index 00000000..26ac590d --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11VirtFactory.hpp @@ -0,0 +1,39 @@ +// $Id: RtclRw11VirtFactory.hpp 859 2017-03-11 22:36:45Z mueller $ +// +// Copyright 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 +// Software Foundation, either version 2, or at your option any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for complete details. +// +// Revision History: +// Date Rev Version Comment +// 2017-03-11 859 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11VirtFactory.hpp 859 2017-03-11 22:36:45Z mueller $ + \brief Declaration of global function RtclRw11VirtFactory. +*/ + +#ifndef included_Retro_RtclRw11VirtFactory +#define included_Retro_RtclRw11VirtFactory 1 + +#include "librw11/Rw11Virt.hpp" + +#include "RtclRw11Virt.hpp" + +namespace Retro { + + RtclRw11Virt* RtclRw11VirtFactory(Rw11Virt* pobj); + +} // end namespace Retro + +#endif