1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-17 17:13:30 +00:00

use Rtime; handle auxilliary devices; ModLalh()

- use Rtime; drop Rtools::TimeOfDayAsDouble()
- probe/setup auxilliary devices: kw11l,kw11p,iist
- librw11/Rw11Cpu: add ModLalh()
This commit is contained in:
Walter F.J. Mueller 2017-02-26 15:06:09 +01:00
parent c3bc722a77
commit d7aa4966bf
16 changed files with 364 additions and 182 deletions

View File

@ -1,6 +1,6 @@
// $Id: RlinkConnect.cpp 758 2016-04-02 18:01:39Z mueller $
// $Id: RlinkConnect.cpp 854 2017-02-25 14:46:03Z mueller $
//
// Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-20 854 2.6 use Rtime, drop TimeOfDayAsDouble
// 2016-04-02 758 2.5 add USR_ACCESS register support (RLUA0/RLUA1)
// 2016-03-20 748 2.4 add fTimeout,(Set)Timeout();
// 2015-05-10 678 2.3.1 WaitAttn(): BUGFIX: return 0. (not -1.) if poll
@ -38,7 +39,7 @@
/*!
\file
\version $Id: RlinkConnect.cpp 758 2016-04-02 18:01:39Z mueller $
\version $Id: RlinkConnect.cpp 854 2017-02-25 14:46:03Z mueller $
\brief Implemenation of RlinkConnect.
*/
@ -116,7 +117,7 @@ RlinkConnect::RlinkConnect()
fspLog(new RlogFile(&cout)),
fConnectMutex(),
fAttnNotiPatt(0),
fTsLastAttnNoti(-1),
fTsLastAttnNoti(),
fSysId(0xffffffff),
fUsrAcc(0x00000000),
fRbufSize(2048)
@ -448,22 +449,23 @@ void RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx)
/*!
First checks whether there are received and not yet harvested notifies.
In that case the cummulative pattern of these pending notifies is returned
in \a apat, and a 0. return value.
in \a apat, and a 0 return value.
If a positive \a timeout is specified the method waits this long for a
valid and non-zero attention notify.
\param timeout maximal time to wait for input in sec. Must be >= 0.
\param timeout maximal time to wait. Must be non-negative.
A zero \a timeout can be used to only harvest pending
notifies without waiting for new ones.
\param[out] twait wait time
\param[out] apat cummulative attention pattern
\param[out] emsg contains error description (mainly from port layer)
\returns wait time, or a negative value indicating an error:
- =0. if there was already a received and not yet harvested notify
- >0 the wait time till the nofity was received
- -1. indicates timeout (\a apat will be 0)
- -2. indicates port IO error (\a emsg will contain information)
\returns >=0 on success or a negative value indicating an error:
- 0 if there was already a received and not yet harvested notify
- 1 finite duration wait
- -1 indicates timeout (\a apat will be 0)
- -2 indicates port IO error (\a emsg will contain information)
\throws Rexception if called outside of an active server
@ -471,13 +473,15 @@ void RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx)
*/
double RlinkConnect::WaitAttn(double timeout, uint16_t& apat, RerrMsg& emsg)
int RlinkConnect::WaitAttn(const Rtime& timeout, Rtime& twait,
uint16_t& apat, RerrMsg& emsg)
{
if (ServerActiveOutside())
throw Rexception("RlinkConnect::WaitAttn()",
"not allowed outside active server");
apat = 0;
twait.Clear();
boost::lock_guard<RlinkConnect> lock(*this);
@ -485,22 +489,22 @@ double RlinkConnect::WaitAttn(double timeout, uint16_t& apat, RerrMsg& emsg)
if (fAttnNotiPatt != 0) {
apat = fAttnNotiPatt;
fAttnNotiPatt = 0;
return 0.;
return 0;
}
// quit if poll only (zero timeout)
if (timeout == 0.) return 0.;
if (!timeout.IsPositive()) return 0;
// wait for new notifier
double tnow = Rtools::TimeOfDayAsDouble();
double tend = tnow + timeout;
double tbeg = tnow;
Rtime tnow(CLOCK_MONOTONIC);
Rtime tend = tnow + timeout;
Rtime tbeg = tnow;
while (tnow < tend) {
int irc = fRcvPkt.ReadData(fpPort.get(), tend-tnow, emsg);
if (irc == RlinkPort::kTout) return -1.;
if (irc == RlinkPort::kErr) return -2.;
tnow = Rtools::TimeOfDayAsDouble();
if (irc == RlinkPort::kTout) return -1;
if (irc == RlinkPort::kErr) return -2;
tnow.GetClock(CLOCK_MONOTONIC);
while (fRcvPkt.ProcessData()) {
int irc = fRcvPkt.PacketState();
if (irc == RlinkPacketBufRcv::kPktPend) break;
@ -509,7 +513,8 @@ double RlinkConnect::WaitAttn(double timeout, uint16_t& apat, RerrMsg& emsg)
if (fAttnNotiPatt != 0) {
apat = fAttnNotiPatt;
fAttnNotiPatt = 0;
return tnow - tbeg;
twait = tnow - tbeg;
return 1;
}
} else {
RlogMsg lmsg(*fspLog, 'E');
@ -609,8 +614,11 @@ void RlinkConnect::SetTraceLevel(uint32_t lvl)
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkConnect::SetTimeout(double timeout)
void RlinkConnect::SetTimeout(const Rtime& timeout)
{
if (!timeout.IsPositive())
throw Rexception("RlinkConnect::SetTimeout()",
"Bad args: timeout <= 0");
fTimeout = timeout;
return;
}
@ -691,8 +699,11 @@ void RlinkConnect::Dump(std::ostream& os, int ind, const char* text) const
os << bl << " fDumpLevel " << fDumpLevel << endl;
os << bl << " fTraceLevel " << fTraceLevel << endl;
fspLog->Dump(os, ind+2, "fspLog: ");
os << bl << " fAttnNotiPatt: " << RosPrintBvi(fAttnNotiPatt,16) << endl;
//FIXME_code: fTsLastAttnNoti not yet in Dump (get formatter...)
os << bl << " fAttnNotiPatt: " << RosPrintBvi(fAttnNotiPatt,16) << endl;
os << bl << " fTsLastAttnNoti: " << fTsLastAttnNoti << endl;
os << bl << " fSysId: " << RosPrintBvi(fSysId,16) << endl;
os << bl << " fUsrAcc: " << RosPrintBvi(fUsrAcc,16) << endl;
os << bl << " fRbufSize: " << RosPrintf(fRbufSize,"d",6) << endl;
return;
}
@ -716,7 +727,7 @@ void RlinkConnect::HandleUnsolicitedData()
boost::lock_guard<RlinkConnect> lock(*this);
RerrMsg emsg;
int irc = fRcvPkt.ReadData(fpPort.get(), 0., emsg);
int irc = fRcvPkt.ReadData(fpPort.get(), Rtime(), emsg);
if (irc == 0) return;
if (irc < 0) {
RlogMsg lmsg(*fspLog, 'E');
@ -1054,10 +1065,10 @@ bool RlinkConnect::DecodeAttnNotify(uint16_t& apat)
\pre a previous response must have been accepted with AcceptResponse().
*/
bool RlinkConnect::ReadResponse(double timeout, RerrMsg& emsg)
bool RlinkConnect::ReadResponse(const Rtime& timeout, RerrMsg& emsg)
{
double tnow = Rtools::TimeOfDayAsDouble();
double tend = tnow + timeout;
Rtime tnow(CLOCK_MONOTONIC);
Rtime tend = tnow + timeout;
while (tnow < tend) {
int irc = fRcvPkt.ReadData(fpPort.get(), tend-tnow, emsg);
@ -1081,7 +1092,7 @@ bool RlinkConnect::ReadResponse(double timeout, RerrMsg& emsg)
}
} //while (fRcvPkt.ProcessData())
tnow = Rtools::TimeOfDayAsDouble();
tnow.GetClock(CLOCK_MONOTONIC);
} // while (tnow < tend)
@ -1176,13 +1187,12 @@ void RlinkConnect::ProcessAttnNotify()
} else {
lmsg << " !NONE!";
}
double now = Rtools::TimeOfDayAsDouble();
if (fTsLastAttnNoti > 0.)
lmsg << " dt=" << RosPrintf(now-fTsLastAttnNoti,"f",8,6);
fTsLastAttnNoti = now;
Rtime tnow(CLOCK_MONOTONIC);
if (fTsLastAttnNoti.IsPositive())
lmsg << " dt=" << RosPrintf(double(tnow-fTsLastAttnNoti),"f",8,6);
fTsLastAttnNoti = tnow;
}
return;
}
} // end namespace Retro

View File

@ -1,6 +1,6 @@
// $Id: RlinkConnect.hpp 758 2016-04-02 18:01:39Z mueller $
// $Id: RlinkConnect.hpp 854 2017-02-25 14:46:03Z mueller $
//
// Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-20 854 2.6 use Rtime, drop TimeOfDayAsDouble
// 2016-04-02 758 2.5 add USR_ACCESS register support (RLUA0/RLUA1)
// 2016-03-20 748 2.4 add fTimeout,(Set)Timeout();
// 2015-04-12 666 2.3 add LinkInit,LinkInitDone; transfer xon
@ -39,7 +40,7 @@
/*!
\file
\version $Id: RlinkConnect.hpp 758 2016-04-02 18:01:39Z mueller $
\version $Id: RlinkConnect.hpp 854 2017-02-25 14:46:03Z mueller $
\brief Declaration of class \c RlinkConnect.
*/
@ -57,6 +58,7 @@
#include "boost/scoped_ptr.hpp"
#include "librtools/RerrMsg.hpp"
#include "librtools/Rtime.hpp"
#include "librtools/Rstats.hpp"
#include "librtools/RlogFile.hpp"
@ -106,7 +108,8 @@ namespace Retro {
void Exec(RlinkCommandList& clist);
void Exec(RlinkCommandList& clist, RlinkContext& cntx);
double WaitAttn(double timeout, uint16_t& apat, RerrMsg& emsg);
int WaitAttn(const Rtime& timeout, Rtime& twait, uint16_t& apat,
RerrMsg& emsg);
bool SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg);
bool SndAttn(RerrMsg& emsg);
@ -132,7 +135,7 @@ namespace Retro {
void SetPrintLevel(uint32_t lvl);
void SetDumpLevel(uint32_t lvl);
void SetTraceLevel(uint32_t lvl);
void SetTimeout(double timeout);
void SetTimeout(const Rtime& timeout);
uint32_t LogBaseAddr() const;
uint32_t LogBaseData() const;
@ -140,7 +143,7 @@ namespace Retro {
uint32_t PrintLevel() const;
uint32_t DumpLevel() const;
uint32_t TraceLevel() const;
double Timeout() const;
const Rtime& Timeout() const;
bool LogOpen(const std::string& name, RerrMsg& emsg);
void LogUseStream(std::ostream* pstr,
@ -221,7 +224,7 @@ namespace Retro {
int DecodeResponse(RlinkCommandList& clist, size_t ibeg,
size_t iend);
bool DecodeAttnNotify(uint16_t& apat);
bool ReadResponse(double timeout, RerrMsg& emsg);
bool ReadResponse(const Rtime& timeout, RerrMsg& emsg);
void AcceptResponse();
void ProcessUnsolicitedData();
void ProcessAttnNotify();
@ -243,11 +246,11 @@ namespace Retro {
uint32_t fPrintLevel; //!< print 0=off,1=err,2=chk,3=all
uint32_t fDumpLevel; //!< dump 0=off,1=err,2=chk,3=all
uint32_t fTraceLevel; //!< trace 0=off,1=buf,2=char
double fTimeout; //!< response timeout
Rtime fTimeout; //!< response timeout
boost::shared_ptr<RlogFile> fspLog; //!< log file ptr
boost::recursive_mutex fConnectMutex; //!< mutex to lock whole connect
uint16_t fAttnNotiPatt; //!< attn notifier pattern
double fTsLastAttnNoti; //!< time stamp last attn notify
Rtime fTsLastAttnNoti; //!< time stamp last attn notify
uint32_t fSysId; //!< SYSID of connected device
uint32_t fUsrAcc; //!< USR_ACCESS of connected device
size_t fRbufSize; //!< Rbuf size (in bytes)

View File

@ -1,4 +1,4 @@
// $Id: RlinkConnect.ipp 758 2016-04-02 18:01:39Z mueller $
// $Id: RlinkConnect.ipp 854 2017-02-25 14:46:03Z mueller $
//
// Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2017-02-20 854 2.5 use Rtime, drop TimeOfDayAsDouble
// 2016-04-02 758 2.4 add USR_ACCESS register support (RLUA0/RLUA1)
// 2016-03-20 748 2.3 add fTimeout,(Set)Timeout();
// 2015-04-12 666 2.2 add LinkInit,LinkInitDone; transfer xon
@ -28,7 +29,7 @@
/*!
\file
\version $Id: RlinkConnect.ipp 758 2016-04-02 18:01:39Z mueller $
\version $Id: RlinkConnect.ipp 854 2017-02-25 14:46:03Z mueller $
\brief Implemenation (inline) of RlinkConnect.
*/
@ -249,7 +250,7 @@ inline uint32_t RlinkConnect::TraceLevel() const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline double RlinkConnect::Timeout() const
inline const Rtime& RlinkConnect::Timeout() const
{
return fTimeout;
}

View File

@ -1,6 +1,6 @@
// $Id: RlinkPacketBufRcv.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkPacketBufRcv.cpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-19 853 1.1 use Rtime
// 2014-12-25 621 1.0.1 Reorganize packet send/revd stats
// 2014-11-30 607 1.0 Initial version
// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkPacketBufRcv.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkPacketBufRcv.cpp 853 2017-02-19 18:54:30Z mueller $
\brief Implemenation of class RlinkPacketBuf.
*/
@ -75,7 +76,8 @@ RlinkPacketBufRcv::~RlinkPacketBufRcv()
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkPacketBufRcv::ReadData(RlinkPort* port, double timeout, RerrMsg& emsg)
int RlinkPacketBufRcv::ReadData(RlinkPort* port, const Rtime& timeout,
RerrMsg& emsg)
{
if (port == nullptr)
throw Rexception("RlinkPacketBufRcv::ReadData()",
@ -89,7 +91,7 @@ int RlinkPacketBufRcv::ReadData(RlinkPort* port, double timeout, RerrMsg& emsg)
int irc = port->Read(fRawBuf, sizeof(fRawBuf), timeout, emsg);
if (timeout == 0 && irc == RlinkPort::kTout) return 0;
if (timeout.IsZero() && irc == RlinkPort::kTout) return 0;
if (irc < 0) {
if (irc == RlinkPort::kTout) {

View File

@ -1,6 +1,6 @@
// $Id: RlinkPacketBufRcv.hpp 621 2014-12-26 21:20:05Z mueller $
// $Id: RlinkPacketBufRcv.hpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-19 853 1.1 use Rtime
// 2014-12-25 621 1.0.1 Reorganize packet send/revd stats
// 2014-11-30 607 1.0 Initial version
// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
@ -21,7 +22,7 @@
/*!
\file
\version $Id: RlinkPacketBufRcv.hpp 621 2014-12-26 21:20:05Z mueller $
\version $Id: RlinkPacketBufRcv.hpp 853 2017-02-19 18:54:30Z mueller $
\brief Declaration of class RlinkPacketBuf.
*/
@ -39,7 +40,8 @@ namespace Retro {
RlinkPacketBufRcv();
~RlinkPacketBufRcv();
int ReadData(RlinkPort* port, double timeout, RerrMsg& emsg);
int ReadData(RlinkPort* port, const Rtime& timeout,
RerrMsg& emsg);
bool ProcessData();
void AcceptPacket();
void FlushRaw();

View File

@ -1,6 +1,6 @@
// $Id: RlinkPort.cpp 666 2015-04-12 21:17:54Z mueller $
// $Id: RlinkPort.cpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-19 853 1.4 use Rtime, drop TimeOfDayAsDouble
// 2015-04-11 666 1.3 add fXon, XonEnable()
// 2014-12-10 611 1.2.4 add time stamps for Read/Write for logs
// 2014-11-29 607 1.2.3 BUGFIX: fix time handling on RawRead()
@ -31,7 +32,7 @@
/*!
\file
\version $Id: RlinkPort.cpp 666 2015-04-12 21:17:54Z mueller $
\version $Id: RlinkPort.cpp 853 2017-02-19 18:54:30Z mueller $
\brief Implemenation of RlinkPort.
*/
@ -78,8 +79,8 @@ RlinkPort::RlinkPort()
fFdWrite(-1),
fspLog(),
fTraceLevel(0),
fTsLastRead(-1.),
fTsLastWrite(-1.),
fTsLastRead(),
fTsLastWrite(),
fStats()
{
fStats.Define(kStatNPortWrite, "NPortWrite", "Port::Write() calls");
@ -118,7 +119,8 @@ void RlinkPort::Close()
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkPort::Read(uint8_t* buf, size_t size, double timeout, RerrMsg& emsg)
int RlinkPort::Read(uint8_t* buf, size_t size, const Rtime& timeout,
RerrMsg& emsg)
{
if (!IsOpen())
throw Rexception("RlinkPort::Read()","Bad state: port not open");
@ -145,11 +147,11 @@ int RlinkPort::Read(uint8_t* buf, size_t size, double timeout, RerrMsg& emsg)
if (fspLog && fTraceLevel>0) {
RlogMsg lmsg(*fspLog, 'I');
lmsg << "port read nchar=" << RosPrintf(irc,"d",4);
double now = Rtools::TimeOfDayAsDouble();
if (fTsLastRead > 0.)
lmsg << " dt_rd=" << RosPrintf(now-fTsLastRead,"f",8,6);
if (fTsLastWrite > 0.)
lmsg << " dt_wr=" << RosPrintf(now-fTsLastWrite,"f",8,6);
Rtime now(CLOCK_MONOTONIC);
if (fTsLastRead.IsPositive())
lmsg << " dt_rd=" << RosPrintf(double(now-fTsLastRead),"f",8,6);
if (fTsLastWrite.IsPositive())
lmsg << " dt_wr=" << RosPrintf(double(now-fTsLastWrite),"f",8,6);
fTsLastRead = now;
if (fTraceLevel>1) {
size_t ncol = (80-5-6)/(2+1);
@ -182,11 +184,11 @@ int RlinkPort::Write(const uint8_t* buf, size_t size, RerrMsg& emsg)
if (fspLog && fTraceLevel>0) {
RlogMsg lmsg(*fspLog, 'I');
lmsg << "port write nchar=" << RosPrintf(size,"d",4);
double now = Rtools::TimeOfDayAsDouble();
if (fTsLastRead > 0.)
lmsg << " dt_rd=" << RosPrintf(now-fTsLastRead,"f",8,6);
if (fTsLastWrite > 0.)
lmsg << " dt_wr=" << RosPrintf(now-fTsLastWrite,"f",8,6);
Rtime now(CLOCK_MONOTONIC);
if (fTsLastRead.IsPositive())
lmsg << " dt_rd=" << RosPrintf(double(now-fTsLastRead),"f",8,6);
if (fTsLastWrite.IsPositive())
lmsg << " dt_wr=" << RosPrintf(double(now-fTsLastWrite),"f",8,6);
fTsLastWrite = now;
if (fTraceLevel>1) {
size_t ncol = (80-5-6)/(2+1);
@ -220,14 +222,14 @@ int RlinkPort::Write(const uint8_t* buf, size_t size, RerrMsg& emsg)
//------------------------------------------+-----------------------------------
//! FIXME_docs
bool RlinkPort::PollRead(double timeout)
bool RlinkPort::PollRead(const Rtime& timeout)
{
if (! IsOpen())
throw Rexception("RlinkPort::PollRead()","Bad state: port not open");
if (timeout < 0.)
if (timeout.IsNegative())
throw Rexception("RlinkPort::PollRead()","Bad args: timeout < 0");
int ito = 1000.*timeout + 0.1;
int ito = timeout.ToMSec();
struct pollfd fds[1] = {{fFdRead, // fd
POLLIN, // events
@ -252,24 +254,24 @@ bool RlinkPort::PollRead(double timeout)
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkPort::RawRead(uint8_t* buf, size_t size, bool exactsize,
double timeout, double& tused, RerrMsg& emsg)
const Rtime& timeout, Rtime& tused, RerrMsg& emsg)
{
if (timeout <= 0.)
if (!timeout.IsPositive())
throw Rexception("RlinkPort::RawRead()", "Bad args: timeout <= 0.");
if (size <= 0)
throw Rexception("RlinkPort::RawRead()", "Bad args: size <= 0");
fStats.Inc(kStatNPortRawRead);
tused = 0.;
tused.Clear();
double tnow = Rtools::TimeOfDayAsDouble();
double tend = tnow + timeout;
double tbeg = tnow;
Rtime tnow(CLOCK_MONOTONIC);
Rtime tend = tnow + timeout;
Rtime tbeg = tnow;
size_t ndone = 0;
while (tnow < tend && ndone<size) {
int irc = Read(buf+ndone, size-ndone, tend-tnow, emsg);
tnow = Rtools::TimeOfDayAsDouble();
tnow.GetClock(CLOCK_MONOTONIC);
tused = tnow - tbeg;
if (irc <= 0) return irc;
if (!exactsize) break;
@ -302,7 +304,8 @@ void RlinkPort::Dump(std::ostream& os, int ind, const char* text) const
os << bl << " fFdWrite: " << fFdWrite << endl;
os << bl << " fspLog: " << fspLog.get() << endl;
os << bl << " fTraceLevel: " << fTraceLevel << endl;
//FIXME_code: fTsLastRead, fTsLastWrite not yet in Dump (get formatter...)
os << bl << " fTsLastRead: " << fTsLastRead << endl;
os << bl << " fTsLastWrite: " << fTsLastWrite << endl;
fStats.Dump(os, ind+2, "fStats: ");
return;
}

View File

@ -1,6 +1,6 @@
// $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
// $Id: RlinkPort.hpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-19 853 1.4 use Rtime, drop TimeOfDayAsDouble
// 2015-04-11 666 1.3 add fXon, XonEnable()
// 2014-12-10 611 1.2.2 add time stamps for Read/Write for logs
// 2013-05-01 513 1.2.1 fTraceLevel now uint32_t
@ -28,7 +29,7 @@
/*!
\file
\version $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
\version $Id: RlinkPort.hpp 853 2017-02-19 18:54:30Z mueller $
\brief Declaration of class RlinkPort.
*/
@ -44,6 +45,7 @@
#include "librtools/RlogFile.hpp"
#include "librtools/Rstats.hpp"
#include "librtools/RparseUrl.hpp"
#include "librtools/Rtime.hpp"
namespace Retro {
@ -55,13 +57,13 @@ namespace Retro {
virtual bool Open(const std::string& url, RerrMsg& emsg) = 0;
virtual void Close();
virtual int Read(uint8_t* buf, size_t size, double timeout,
virtual int Read(uint8_t* buf, size_t size, const Rtime& timeout,
RerrMsg& emsg);
virtual int Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
virtual bool PollRead(double timeout);
virtual bool PollRead(const Rtime& timeout);
int RawRead(uint8_t* buf, size_t size, bool exactsize,
double timeout, double& tused, RerrMsg& emsg);
const Rtime& timeout, Rtime& tused, RerrMsg& emsg);
int RawWrite(const uint8_t* buf, size_t size, RerrMsg& emsg);
bool IsOpen() const;
@ -108,8 +110,8 @@ namespace Retro {
int fFdWrite; //!< fd for write
boost::shared_ptr<RlogFile> fspLog; //!< log file ptr
uint32_t fTraceLevel; //!< trace level
double fTsLastRead; //!< time stamp last write
double fTsLastWrite; //!< time stamp last write
Rtime fTsLastRead; //!< time stamp last write
Rtime fTsLastWrite; //!< time stamp last write
Rstats fStats; //!< statistics
};

View File

@ -1,6 +1,6 @@
// $Id: RtclRlinkConnect.cpp 758 2016-04-02 18:01:39Z mueller $
// $Id: RtclRlinkConnect.cpp 854 2017-02-25 14:46:03Z mueller $
//
// Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-20 854 1.5 use Rtime
// 2016-04-02 758 1.4.6 add USR_ACCESS register support (UsrAcc->usracc)
// 2016-03-20 748 1.4.5 M_get/set: add timeout
// 2015-05-09 676 1.4.3 M_errcnt: add -increment; M_log: add -bare,-info..
@ -40,7 +41,7 @@
/*!
\file
\version $Id: RtclRlinkConnect.cpp 758 2016-04-02 18:01:39Z mueller $
\version $Id: RtclRlinkConnect.cpp 854 2017-02-25 14:46:03Z mueller $
\brief Implemenation of class RtclRlinkConnect.
*/
@ -117,7 +118,7 @@ RtclRlinkConnect::RtclRlinkConnect(Tcl_Interp* interp, const char* name)
boost::bind(&RlinkConnect::DumpLevel, pobj));
fGets.Add<uint32_t> ("tracelevel",
boost::bind(&RlinkConnect::TraceLevel, pobj));
fGets.Add<double> ("timeout",
fGets.Add<const Rtime&> ("timeout",
boost::bind(&RlinkConnect::Timeout, pobj));
fGets.Add<const string&> ("logfile",
boost::bind(&RlinkConnect::LogFileName, pobj));
@ -147,7 +148,7 @@ RtclRlinkConnect::RtclRlinkConnect(Tcl_Interp* interp, const char* name)
boost::bind(&RlinkConnect::SetDumpLevel, pobj, _1));
fSets.Add<uint32_t> ("tracelevel",
boost::bind(&RlinkConnect::SetTraceLevel, pobj, _1));
fSets.Add<double> ("timeout",
fSets.Add<const Rtime&> ("timeout",
boost::bind(&RlinkConnect::SetTimeout, pobj, _1));
fSets.Add<const string&> ("logfile",
boost::bind(&RlinkConnect::SetLogFileName, pobj, _1));
@ -567,31 +568,32 @@ int RtclRlinkConnect::M_errcnt(RtclArgs& args)
int RtclRlinkConnect::M_wtlam(RtclArgs& args)
{
double tout;
double dtout;
string rvn_apat;
if (!args.GetArg("tout", tout, 0.0)) return kERR;
if (!args.GetArg("tout", dtout, 0.0)) return kERR;
if (!args.GetArg("??varApat", rvn_apat)) return kERR;
if (!args.AllDone()) return kERR;
RerrMsg emsg;
uint16_t apat = 0;
Rtime twait;
double twait = Obj().WaitAttn(tout, apat, emsg);
int irc = Obj().WaitAttn(Rtime(dtout), twait, apat, emsg);
if (rvn_apat.length()) {
if(!Rtcl::SetVar(args.Interp(), rvn_apat,
Tcl_NewIntObj((int)apat))) return kERR;
}
if (twait == -2.) { // IO error
if (irc == -2) { // IO error
return args.Quit(emsg);
} else if (twait == -1.) { // timeout
} else if (irc == -1) { // timeout
if (Obj().PrintLevel() >= 1) {
RlogMsg lmsg(Obj().LogFile());
lmsg << "-- wtlam to=" << RosPrintf(tout, "f", 0,3)
lmsg << "-- wtlam to=" << RosPrintf(dtout, "f", 0,3)
<< " FAIL timeout" << endl;
Obj().Context().IncErrorCount();
args.SetResult(tout);
args.SetResult(dtout);
return kOK;
}
}
@ -599,16 +601,16 @@ int RtclRlinkConnect::M_wtlam(RtclArgs& args)
if (Obj().PrintLevel() >= 3) {
RlogMsg lmsg(Obj().LogFile());
lmsg << "-- wtlam apat=" << RosPrintf(apat,"x0",4);
if (tout == 0.) {
if (dtout == 0.) {
lmsg << " to=0 harvest only";
} else {
lmsg << " to=" << RosPrintf(tout, "f", 0,3)
<< " T=" << RosPrintf(twait, "f", 0,3);
lmsg << " to=" << RosPrintf(dtout, "f", 0,3)
<< " T=" << RosPrintf(double(twait), "f", 0,3);
}
lmsg << " OK" << endl;
}
args.SetResult(twait);
args.SetResult(double(twait));
return kOK;
}

View File

@ -1,6 +1,6 @@
// $Id: RtclRlinkPort.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RtclRlinkPort.cpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-19 853 1.1 use Rtime
// 2015-01-09 632 1.0.4 add M_get, M_set, remove M_config
// 2014-08-22 584 1.0.3 use nullptr
// 2013-02-23 492 1.0.2 use RlogFile.Name();
@ -22,7 +23,7 @@
/*!
\file
\version $Id: RtclRlinkPort.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RtclRlinkPort.cpp 853 2017-02-19 18:54:30Z mueller $
\brief Implemenation of class RtclRlinkPort.
*/
@ -322,9 +323,9 @@ int RtclRlinkPort::DoRawio(RtclArgs& args, RlinkPort* pport, size_t& errcnt)
if (mode == 'r') { // handle -rblk ------------------
RerrMsg emsg;
double tused = 0.;
Rtime tused;
rdata.resize(rsize);
int irc = pport->RawRead(rdata.data(), rdata.size(), true, timeout,
int irc = pport->RawRead(rdata.data(), rdata.size(), true, Rtime(timeout),
tused, emsg);
if (irc == RlinkPort::kErr) return args.Quit("-E: timeout on -rblk");
if (irc != (int)rdata.size()) return args.Quit(emsg);
@ -342,7 +343,7 @@ int RtclRlinkPort::DoRawio(RtclArgs& args, RlinkPort* pport, size_t& errcnt)
}
if (nerr) errcnt += 1;
}
args.SetResult(tused);
args.SetResult(double(tused));
} else { // handle -wblk ------------------
RerrMsg emsg;

View File

@ -1,6 +1,6 @@
// $Id: Rtools.cpp 606 2014-11-24 07:08:51Z mueller $
// $Id: Rtools.cpp 852 2017-02-18 12:43:31Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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,7 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2014-11-23 606 1.0.4 add TimeOfDayAsDouble()
// 2017-02-18 852 1.0.7 remove TimeOfDayAsDouble()
// 2014-11-23 606 1.0.6 add TimeOfDayAsDouble()
// 2014-11-08 602 1.0.5 add (int) cast in snprintf to match %d type
// 2014-08-22 584 1.0.4 use nullptr
// 2013-05-04 516 1.0.3 add CreateBackupFile()
@ -24,15 +25,12 @@
/*!
\file
\version $Id: Rtools.cpp 606 2014-11-24 07:08:51Z mueller $
\version $Id: Rtools.cpp 852 2017-02-18 12:43:31Z mueller $
\brief Implemenation of Rtools .
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <iostream>
@ -174,27 +172,5 @@ bool CreateBackupFile(const RparseUrl& purl, RerrMsg& emsg)
return true;
}
//------------------------------------------+-----------------------------------
//! Returns the time-of-day as \c double value
/*!
Calls \c gettimeofday() and returns the current time as a \c double.
This is convenient for calculations with time values.
\returns time is seconds as \a double with micro second resolution.
\throws Rexception in case \c gettimeofday() fails.
*/
double TimeOfDayAsDouble()
{
struct timeval tval;
int irc = ::gettimeofday(&tval, 0);
if (irc < 0) {
throw Rexception("Rtools::TimeOfDayAsDouble()",
"gettimeofday failed with ", errno);
}
return double(tval.tv_sec) + 1.e-6*double(tval.tv_usec);
}
} // end namespace Rtools
} // end namespace Retro

View File

@ -1,6 +1,6 @@
// $Id: Rtools.hpp 611 2014-12-10 23:23:58Z mueller $
// $Id: Rtools.hpp 852 2017-02-18 12:43:31Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2017-02-18 852 1.0.6 remove TimeOfDayAsDouble()
// 2017-02-11 850 1.0.5 add Word2Bytes() and Bytes2Word()
// 2014-11-23 606 1.0.4 add TimeOfDayAsDouble()
// 2013-05-04 516 1.0.3 add CreateBackupFile(), String2Long()
// 2013-02-13 481 1.0.2 remove ThrowLogic(), ThrowRuntime()
@ -22,7 +24,7 @@
/*!
\file
\version $Id: Rtools.hpp 611 2014-12-10 23:23:58Z mueller $
\version $Id: Rtools.hpp 852 2017-02-18 12:43:31Z mueller $
\brief Declaration of class Rtools .
*/
@ -55,11 +57,13 @@ namespace Retro {
RerrMsg& emsg);
bool CreateBackupFile(const RparseUrl& purl, RerrMsg& emsg);
double TimeOfDayAsDouble();
};
void Word2Bytes(uint16_t word, uint16_t& byte0, uint16_t& byte1);
uint16_t Bytes2Word(uint16_t byte0, uint16_t byte1);
} // end namespace Rtools
} // end namespace Retro
//#include "Rtools.ipp"
#include "Rtools.ipp"
#endif

View File

@ -0,0 +1,47 @@
// $Id: Rtools.ipp 850 2017-02-12 22:51:19Z mueller $
//
// Copyright 2017- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-11 850 1.0 Initial version
// ---------------------------------------------------------------------------
/*!
\file
\version $Id: Rtools.ipp 850 2017-02-12 22:51:19Z mueller $
\brief Implemenation (inline) of Rtools.
*/
// all method definitions in namespace Retro
namespace Retro {
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void Rtools::Word2Bytes(uint16_t word, uint16_t& byte0, uint16_t& byte1)
{
byte1 = (word>>8) & 0xff;
byte0 = word & 0xff;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint16_t Rtools::Bytes2Word(uint16_t byte0, uint16_t byte1)
{
return (byte1<<8) | byte0;
}
} // end namespace Retro

View File

@ -1,4 +1,4 @@
// $Id: Rw11Cpu.cpp 848 2017-02-04 14:55:30Z mueller $
// $Id: Rw11Cpu.cpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@ -13,6 +13,9 @@
//
// Revision History:
// Date Rev Version Comment
// 2017-02-19 853 1.2.10 use Rtime
// 2017-02-17 851 1.2.9 probe/setup auxilliary devices: kw11l,kw11p,iist
// 2017-02-10 850 1.2.8 add ModLalh()
// 2017-02-04 848 1.2.7 ProbeCntl: handle probe data
// 2015-12-26 719 1.2.6 BUGFIX: IM* correct register offset definitions
// 2015-07-12 700 1.2.5 use ..CpuAct instead ..CpuGo (new active based lam);
@ -22,7 +25,7 @@
// 2015-05-08 675 1.2.3 w11a start/stop/suspend overhaul
// 2015-04-25 668 1.2.2 add AddRbibr(), AddWbibr()
// 2015-04-03 661 1.2.1 add kStat_M_* defs
// 2015-03-21 659 1.2 add RAddrMap
// 2015-03-21 659 1.2 add RAddrMap()
// 2015-01-01 626 1.1 Adopt for rlink v4 and 4k ibus window
// 2014-12-21 617 1.0.3 use kStat_M_RbTout for rbus timeout
// 2014-08-02 576 1.0.2 adopt rename of LastExpect->SetLastExpect
@ -33,7 +36,7 @@
/*!
\file
\version $Id: Rw11Cpu.cpp 848 2017-02-04 14:55:30Z mueller $
\version $Id: Rw11Cpu.cpp 853 2017-02-19 18:54:30Z mueller $
\brief Implemenation of Rw11Cpu.
*/
#include <stdlib.h>
@ -155,6 +158,15 @@ const uint16_t Rw11Cpu::kIMLOLIM;
const uint16_t Rw11Cpu::kIMADDR;
const uint16_t Rw11Cpu::kIMDATA;
const uint16_t Rw11Cpu::kKWLBASE;
const uint16_t Rw11Cpu::kKWPBASE;
const uint16_t Rw11Cpu::kKWPCSR;
const uint16_t Rw11Cpu::kKWPCSB;
const uint16_t Rw11Cpu::kKWPCTR;
const uint16_t Rw11Cpu::kIISTBASE;
const uint16_t Rw11Cpu::kIISTACR;
const uint16_t Rw11Cpu::kIISTADR;
//------------------------------------------+-----------------------------------
//! Constructor
@ -168,6 +180,9 @@ Rw11Cpu::Rw11Cpu(const std::string& type)
fHasCmon(false),
fHasHbpt(0),
fHasIbmon(false),
fHasKw11l(false),
fHasKw11p(false),
fHasIist(false),
fCpuAct(0),
fCpuStat(0),
fCpuActMutex(),
@ -343,6 +358,33 @@ int Rw11Cpu::AddLalh(RlinkCommandList& clist, uint32_t addr, uint16_t mode)
//------------------------------------------+-----------------------------------
//! FIXME_docs
void Rw11Cpu::ModLalh(RlinkCommandList& clist, size_t ind,
uint32_t addr, uint16_t mode)
{
if (ind + 1 > clist.Size())
throw Rexception("Rw11Cpu::ModLalh","Bad args: ind out of range");
uint16_t al = uint16_t(addr);
uint16_t ah = uint16_t(addr>>16) & kCPAH_M_ADDR;
ah |= mode & (kCPAH_M_22BIT|kCPAH_M_UBMAP);
RlinkCommand& cmdal = clist[ind];
RlinkCommand& cmdah = clist[ind+1];
if (cmdal.Command() != RlinkCommand::kCmdWreg ||
cmdal.Address() != fBase+kCPAL ||
cmdah.Command() != RlinkCommand::kCmdWreg ||
cmdah.Address() != fBase+kCPAH)
throw Rexception("Rw11Cpu::ModLalh","Bad state: not writing cpal/cpah");
cmdal.SetData(al);
cmdah.SetData(ah);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
int Rw11Cpu::AddRMem(RlinkCommandList& clist, uint32_t addr, uint16_t* buf,
size_t size, uint16_t mode, bool singleblk)
{
@ -743,18 +785,24 @@ void Rw11Cpu::SetCpuActDown(uint16_t stat)
//------------------------------------------+-----------------------------------
//! FIXME_docs
double Rw11Cpu::WaitCpuActDown(double tout)
int Rw11Cpu::WaitCpuActDown(const Rtime& tout, Rtime& twait)
{
boost::system_time t0(boost::get_system_time());
Rtime tstart(CLOCK_MONOTONIC);
twait.Clear();
boost::system_time timeout(boost::posix_time::max_date_time);
if (tout > 0.)
timeout = t0 + boost::posix_time::microseconds((long)1E6 * tout);
if (tout.IsPositive())
// Note: boost::posix_time might lack the nanoseconds ctor (if build with
// microsecond precision), thus use microsecond.
timeout = boost::get_system_time() +
boost::posix_time::seconds(tout.Sec()) +
boost::posix_time::microseconds(tout.NSec()/1000);
boost::unique_lock<boost::mutex> lock(fCpuActMutex);
while (fCpuAct) {
if (!fCpuActCond.timed_wait(lock, timeout)) return -1.;
if (!fCpuActCond.timed_wait(lock, timeout)) return -1;
}
boost::posix_time::time_duration dt = boost::get_system_time() - t0;
return double(dt.ticks()) / dt.ticks_per_second();
twait = Rtime(CLOCK_MONOTONIC) - tstart;
return twait.IsPositive();
}
//------------------------------------------+-----------------------------------
@ -911,7 +959,7 @@ void Rw11Cpu::SetupStd()
void Rw11Cpu::SetupOpt()
{
// probe optional components: dmscnt, dmcmon, dmhbpt and ibmon
// probe optional cpu components: dmscnt, dmcmon, dmhbpt and ibmon
RlinkCommandList clist;
int isc = clist.AddRreg(Base()+kSCBASE+kSCCNTL);
@ -928,6 +976,16 @@ void Rw11Cpu::SetupOpt()
int iim = AddRibr(clist, kIMBASE+kIMCNTL);
clist.SetLastExpectStatus(0,0);
// probe auxilliary cpu components: kw11-l, kw11-p, iist
int ikwl= AddRibr(clist, kKWLBASE);
clist.SetLastExpectStatus(0,0);
int ikwp= AddRibr(clist, kKWPBASE + kKWPCSR);
clist.SetLastExpectStatus(0,0);
int iii= AddRibr(clist, kIISTBASE + kIISTACR);
clist.SetLastExpectStatus(0,0);
Connect().Exec(clist);
uint8_t statmsk = RlinkCommand::kStat_M_RbTout |
@ -978,6 +1036,24 @@ void Rw11Cpu::SetupOpt()
AllIAddrMapInsert("im.data", kIMBASE + kIMDATA);
}
fHasKw11l = (clist[ikwl].Status() & statmsk) == 0;
if (fHasKw11l) {
AllIAddrMapInsert("kwl.csr", kKWLBASE);
}
fHasKw11p = (clist[ikwp].Status() & statmsk) == 0;
if (fHasKw11p) {
AllIAddrMapInsert("kwp.csr", kKWPBASE + kKWPCSR);
AllIAddrMapInsert("kwp.csb", kKWPBASE + kKWPCSB);
AllIAddrMapInsert("kwp.ctr", kKWPBASE + kKWPCTR);
}
fHasIist = (clist[iii].Status() & statmsk) == 0;
if (fHasIist) {
AllIAddrMapInsert("iist.acr", kIISTBASE + kIISTACR);
AllIAddrMapInsert("iist.adr", kIISTBASE + kIISTADR);
}
return;
}

View File

@ -1,6 +1,6 @@
// $Id: Rw11Cpu.hpp 721 2015-12-29 17:50:50Z mueller $
// $Id: Rw11Cpu.hpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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,16 @@
//
// Revision History:
// Date Rev Version Comment
// 2017-02-19 853 1.2.8 use Rtime
// 2017-02-17 851 1.2.7 probe/setup auxilliary devices: kw11l,kw11p,iist
// 2017-02-10 850 1.2.6 add ModLalh()
// 2015-12-28 721 1.2.5 BUGFIX: IM* correct register offset definitions
// 2015-07-12 700 1.2.4 use ..CpuAct instead ..CpuGo (new active based lam);
// add probe and map setup for optional cpu components
// 2015-05-08 675 1.2.3 w11a start/stop/suspend overhaul
// 2015-04-25 668 1.2.2 add AddRbibr(), AddWbibr()
// 2015-04-03 661 1.2.1 add kStat_M_* defs
// 2015-03-21 659 1.2 add RAddrMap; add AllRAddrMapInsert();
// 2015-03-21 659 1.2 add RAddrMap(); add AllRAddrMapInsert();
// 2015-01-01 626 1.1 Adopt for rlink v4 and 4k ibus window; add IAddrMap
// 2013-04-14 506 1.0.1 add AddLalh(),AddRMem(),AddWMem()
// 2013-04-12 504 1.0 Initial version
@ -29,7 +32,7 @@
/*!
\file
\version $Id: Rw11Cpu.hpp 721 2015-12-29 17:50:50Z mueller $
\version $Id: Rw11Cpu.hpp 853 2017-02-19 18:54:30Z mueller $
\brief Declaration of class Rw11Cpu.
*/
@ -84,6 +87,9 @@ namespace Retro {
bool HasCmon() const;
uint16_t HasHbpt() const;
bool HasIbmon() const;
bool HasKw11l() const;
bool HasKw11p() const;
bool HasIist() const;
void AddCntl(const boost::shared_ptr<Rw11Cntl>& spcntl);
bool TestCntl(const std::string& name) const;
@ -107,6 +113,9 @@ namespace Retro {
int AddLalh(RlinkCommandList& clist, uint32_t addr,
uint16_t mode=kCPAH_M_22BIT);
void ModLalh(RlinkCommandList& clist, size_t ind, uint32_t addr,
uint16_t mode=kCPAH_M_22BIT);
int AddRMem(RlinkCommandList& clist, uint32_t addr,
uint16_t* buf, size_t size,
uint16_t mode=kCPAH_M_22BIT,
@ -129,7 +138,7 @@ namespace Retro {
void SetCpuActUp();
void SetCpuActDown(uint16_t stat);
double WaitCpuActDown(double tout);
int WaitCpuActDown(const Rtime& tout, Rtime&twait);
bool CpuAct() const;
uint16_t CpuStat() const;
@ -212,7 +221,7 @@ namespace Retro {
static const uint8_t kStat_M_CpuSusp = kBBit05; //!< stat: cpususp flag
static const uint8_t kStat_M_CpuGo = kBBit04; //!< stat: cpugo flag
// defs for optional w11 components
// defs for optional w11 cpu components
static const uint16_t kSCBASE = 0x0040; //!< DMSCNT reg base offset
static const uint16_t kSCCNTL = 0x0000; //!< SC.CNTL reg offset
static const uint16_t kSCADDR = 0x0001; //!< SC.ADDR reg offset
@ -244,6 +253,16 @@ namespace Retro {
static const uint16_t kIMADDR = 0x0008; //!< IM.ADDR reg offset
static const uint16_t kIMDATA = 0x000a; //!< IM.DATA reg offset
// defs for optional w11 aux components
static const uint16_t kKWLBASE = 0177546; //!< KW11-L ibus address
static const uint16_t kKWPBASE = 0172540; //!< KW11-P ibus address
static const uint16_t kKWPCSR = 0x0000; //!< KWP.CSR reg offset
static const uint16_t kKWPCSB = 0x0002; //!< KWP.CSB reg offset
static const uint16_t kKWPCTR = 0x0004; //!< KWP.CTR reg offset
static const uint16_t kIISTBASE= 0177500; //!< IIST ibus address
static const uint16_t kIISTACR = 0x0000; //!< II.ACR reg offset
static const uint16_t kIISTADR = 0x0002; //!< II.ADR reg offset
protected:
void SetupStd();
void SetupOpt();
@ -261,6 +280,9 @@ namespace Retro {
bool fHasCmon; //!< has dmcmon (cpu monitor)
uint16_t fHasHbpt; //!< has dmhbpt (hardware breakpoint)
bool fHasIbmon; //!< has ibmon (ibus monitor)
bool fHasKw11l; //!< has kw11-l (line clock)
bool fHasKw11p; //!< has kw11-l (prog clock)
bool fHasIist; //!< has iist (smp comm)
bool fCpuAct;
uint16_t fCpuStat;
boost::mutex fCpuActMutex;

View File

@ -1,6 +1,6 @@
// $Id: Rw11Cpu.ipp 700 2015-07-12 19:28:31Z mueller $
// $Id: Rw11Cpu.ipp 851 2017-02-18 09:20:40Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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-02-17 851 1.2.2 probe/setup auxilliary devices: kw11l,kw11p,iist
// 2015-07-12 700 1.2.1 use ..CpuAct instead ..CpuGo (new active based lam)
// 2015-03-21 659 1.2 add RAddrMap
// 2014-12-25 621 1.1 Adopt for 4k word ibus window; add IAddrMap
@ -22,7 +23,7 @@
/*!
\file
\version $Id: Rw11Cpu.ipp 700 2015-07-12 19:28:31Z mueller $
\version $Id: Rw11Cpu.ipp 851 2017-02-18 09:20:40Z mueller $
\brief Implemenation (inline) of Rw11Cpu.
*/
@ -128,6 +129,30 @@ inline bool Rw11Cpu::HasIbmon() const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool Rw11Cpu::HasKw11l() const
{
return fHasKw11l;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool Rw11Cpu::HasKw11p() const
{
return fHasKw11p;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool Rw11Cpu::HasIist() const
{
return fHasIist;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint16_t Rw11Cpu::CpuStat() const
{
return fCpuStat;

View File

@ -1,4 +1,4 @@
// $Id: RtclRw11Cpu.cpp 848 2017-02-04 14:55:30Z mueller $
// $Id: RtclRw11Cpu.cpp 853 2017-02-19 18:54:30Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@ -13,6 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2017-02-19 853 1.2.12 use Rtime
// 2017-02-17 851 1.2.11 probe/setup auxilliary devices: kw11l,kw11p,iist
// 2017-02-04 848 1.2.10 M_default: add 'probe ena on' output
// 2016-12-30 834 1.2.9 use 'ssr' instead of 'mmr' for MMU registers
// 2015-12-26 718 1.2.8 use BlockSizeMax() for 'cp -b[rw]m' and 'ldasm'
@ -39,7 +41,7 @@
/*!
\file
\version $Id: RtclRw11Cpu.cpp 848 2017-02-04 14:55:30Z mueller $
\version $Id: RtclRw11Cpu.cpp 853 2017-02-19 18:54:30Z mueller $
\brief Implemenation of RtclRw11Cpu.
*/
@ -777,38 +779,39 @@ int RtclRw11Cpu::M_wtcpu(RtclArgs& args)
string opt;
bool reset = false;
double tout;
double dtout;
while (args.NextOpt(opt, optset)) {
if (opt == "-reset") reset = true;
}
if (!args.GetArg("tout", tout, 0.001)) return kERR;
if (!args.GetArg("tout", dtout, 0.001)) return kERR;
if (!args.AllDone()) return kERR;
double twait = -1;
Rtime twait;
int irc = -1;
if (!Server().IsActive()) { // server is not active
RerrMsg emsg;
uint16_t apat;
// FIXME_code: make apat accessible in tcl
twait = Connect().WaitAttn(tout, apat, emsg);
if (twait == -2.) { // wait failed, quit
irc = Connect().WaitAttn(Rtime(dtout), twait, apat, emsg);
if (irc == -2) { // wait failed, quit
return args.Quit(emsg);
}
if (twait >= 0.) { // wait succeeded
RlinkCommandList clist; // get and discard attn pattern
if (irc >= 0) { // wait succeeded
RlinkCommandList clist; // get and discard attn pattern
clist.AddAttn();
if (!Connect().Exec(clist, emsg)) return args.Quit(emsg);
}
} else { // server is active
twait = Obj().WaitCpuActDown(tout);
irc = Obj().WaitCpuActDown(Rtime(dtout), twait);
}
if (twait < 0.) { // timeout
if (irc < 0) { // timeout
if (Connect().PrintLevel() >= 1) {
RlogMsg lmsg(Connect().LogFile());
lmsg << "-- wtcpu to=" << RosPrintf(tout, "f", 0,3) << " FAIL timeout";
lmsg << "-- wtcpu to=" << RosPrintf(dtout, "f", 0,3) << " FAIL timeout";
}
Connect().Context().IncErrorCount();
if (reset) { // reset requested
@ -821,13 +824,13 @@ int RtclRw11Cpu::M_wtcpu(RtclArgs& args)
} else { // no timeout
if (Connect().PrintLevel() >= 3) {
RlogMsg lmsg(Connect().LogFile());
lmsg << "-- wtcpu to=" << RosPrintf(tout, "f", 0,3)
<< " T=" << RosPrintf(twait, "f", 0,3)
lmsg << "-- wtcpu to=" << RosPrintf(dtout, "f", 0,3)
<< " T=" << RosPrintf(double(twait), "f", 0,3)
<< " OK";
}
}
args.SetResult(twait);
args.SetResult(irc >= 0 ? double(twait) : double(irc));
return kOK;
}
@ -1450,6 +1453,9 @@ void RtclRw11Cpu::SetupGetSet()
fGets.Add<bool> ("hascmon", boost::bind(&Rw11Cpu::HasCmon, pobj));
fGets.Add<uint16_t> ("hashbpt", boost::bind(&Rw11Cpu::HasHbpt, pobj));
fGets.Add<bool> ("hasibmon", boost::bind(&Rw11Cpu::HasIbmon, pobj));
fGets.Add<bool> ("haskw11l", boost::bind(&Rw11Cpu::HasKw11l, pobj));
fGets.Add<bool> ("haskw11p", boost::bind(&Rw11Cpu::HasKw11p, pobj));
fGets.Add<bool> ("hasiist", boost::bind(&Rw11Cpu::HasIist, pobj));
return;
}