OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [src/] [librlink/] [RlinkCommand.cpp] - Diff between revs 10 and 19

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 10 Rev 19
Line 1... Line 1...
// $Id: RlinkCommand.cpp 375 2011-04-02 07:56:47Z mueller $
// $Id: RlinkCommand.cpp 495 2013-03-06 17:13:48Z mueller $
//
//
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
//
// This program is free software; you may redistribute and/or modify it under
// 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
// 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.
// Software Foundation, either version 2, or at your option any later version.
//
//
Line 11... Line 11...
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for complete details.
// for complete details.
// 
// 
// Revision History: 
// Revision History: 
// Date         Rev Version  Comment
// Date         Rev Version  Comment
 
// 2013-05-06   495   1.0.2  add RlinkContext to Print() args
 
// 2013-02-03   481   1.0.1  use Rexception
// 2011-03-27   374   1.0    Initial version
// 2011-03-27   374   1.0    Initial version
// 2011-01-15   355   0.1    First draft
// 2011-01-15   355   0.1    First draft
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
 
 
/*!
/*!
  \file
  \file
  \version $Id: RlinkCommand.cpp 375 2011-04-02 07:56:47Z mueller $
  \version $Id: RlinkCommand.cpp 495 2013-03-06 17:13:48Z mueller $
  \brief   Implemenation of class RlinkCommand.
  \brief   Implemenation of class RlinkCommand.
 */
 */
 
 
// debug
// debug
#include <iostream>
#include <iostream>
 
 
#include <stdexcept>
 
#include <algorithm>
#include <algorithm>
 
 
#include "RlinkCommand.hpp"
#include "RlinkCommand.hpp"
 
 
#include "librtools/RosFill.hpp"
#include "librtools/RosFill.hpp"
#include "librtools/RosPrintf.hpp"
#include "librtools/RosPrintf.hpp"
#include "librtools/RosPrintBvi.hpp"
#include "librtools/RosPrintBvi.hpp"
 
#include "librtools/Rexception.hpp"
 
 
using namespace std;
using namespace std;
using namespace Retro;
 
 
 
/*!
/*!
  \class Retro::RlinkCommand
  \class Retro::RlinkCommand
  \brief FIXME_docs
  \brief FIXME_docs
*/
*/
 
 
 
// all method definitions in namespace Retro
 
namespace Retro {
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
// constants definitions
// constants definitions
 
 
const uint8_t  RlinkCommand::kCmdRreg;
const uint8_t  RlinkCommand::kCmdRreg;
const uint8_t  RlinkCommand::kCmdRblk;
const uint8_t  RlinkCommand::kCmdRblk;
Line 67... Line 71...
const uint32_t RlinkCommand::kFlagErrCrc;
const uint32_t RlinkCommand::kFlagErrCrc;
const uint32_t RlinkCommand::kFlagChkStat;
const uint32_t RlinkCommand::kFlagChkStat;
const uint32_t RlinkCommand::kFlagChkData;
const uint32_t RlinkCommand::kFlagChkData;
const uint32_t RlinkCommand::kFlagVol;
const uint32_t RlinkCommand::kFlagVol;
 
 
 
const uint8_t RlinkCommand::kStat_M_Stat;
 
const uint8_t RlinkCommand::kStat_V_Stat;
 
const uint8_t RlinkCommand::kStat_B_Stat;
 
const uint8_t RlinkCommand::kStat_M_Attn;
 
const uint8_t RlinkCommand::kStat_M_Cerr;
 
const uint8_t RlinkCommand::kStat_M_Derr;
 
const uint8_t RlinkCommand::kStat_M_RbNak;
 
const uint8_t RlinkCommand::kStat_M_RbErr;
 
 
 
const uint16_t RlinkCommand::kRbaddr_IInt;
 
const uint16_t RlinkCommand::kIInt_M_AnEna;
 
const uint16_t RlinkCommand::kIInt_M_ItoEna;
 
const uint16_t RlinkCommand::kIInt_M_ItoVal;
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! Default constructor
//! Default constructor
 
 
RlinkCommand::RlinkCommand()
RlinkCommand::RlinkCommand()
  : fRequest(0),
  : fRequest(0),
Line 155... Line 173...
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::SetCommand(uint8_t cmd, uint16_t addr, uint16_t data)
void RlinkCommand::SetCommand(uint8_t cmd, uint16_t addr, uint16_t data)
{
{
  if (cmd > kCmdInit)
  if (cmd > kCmdInit)
    throw invalid_argument("RlinkCommand::SetCommand: invalid cmd");
    throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid cmd");
  if (addr > 0xff)
  if (addr > 0xff)
    throw invalid_argument("RlinkCommand::SetCommand: invalid addr");
    throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid addr");
  fRequest = cmd;
  fRequest = cmd;
  fAddress = addr;
  fAddress = addr;
  fData    = data;
  fData    = data;
  fpBlockExt    = 0;
  fpBlockExt    = 0;
  fBlockExtSize = 0;
  fBlockExtSize = 0;
Line 177... Line 195...
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::SetAddress(uint16_t addr)
void RlinkCommand::SetAddress(uint16_t addr)
{
{
  if (addr > 0xff)
  if (addr > 0xff)
    throw invalid_argument("RlinkCommand::SetAddress: invalid addr");
    throw Rexception("RlinkCommand::SetAddress()", "Bad args: invalid addr");
  fAddress = addr;
  fAddress = addr;
  return;
  return;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::SetBlockWrite(const std::vector<uint16_t>& block)
void RlinkCommand::SetBlockWrite(const std::vector<uint16_t>& block)
{
{
  if (block.size() == 0 || block.size() > 256)
  if (block.size() == 0 || block.size() > 256)
    throw invalid_argument("RlinkCommand::SetBlockWrite: invalid block size");
    throw Rexception("RlinkCommand::SetBlockWrite()",
 
                     "Bad args: invalid block size");
  fBlock = block;
  fBlock = block;
  fpBlockExt    = 0;
  fpBlockExt    = 0;
  fBlockExtSize = 0;
  fBlockExtSize = 0;
  return;
  return;
}
}
Line 201... Line 220...
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::SetBlockRead(size_t size)
void RlinkCommand::SetBlockRead(size_t size)
{
{
  if (size == 0 || size > 256)
  if (size == 0 || size > 256)
    throw invalid_argument("RlinkCommand::SetBlockRead: invalid block size");
    throw Rexception("RlinkCommand::SetBlockRead()",
 
                     "Bad args: invalid block size");
  fBlock.clear();
  fBlock.clear();
  fBlock.resize(size);
  fBlock.resize(size);
  fpBlockExt    = 0;
  fpBlockExt    = 0;
  fBlockExtSize = 0;
  fBlockExtSize = 0;
  return;
  return;
Line 215... Line 235...
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::SetBlockExt(uint16_t* pblock, size_t size)
void RlinkCommand::SetBlockExt(uint16_t* pblock, size_t size)
{
{
  if (pblock == 0)
  if (pblock == 0)
    throw invalid_argument("RlinkCommand::SetBlockExt: pblock is null");
    throw Rexception("RlinkCommand::SetBlockExt()",
 
                     "Bad args: pblock is null");
  if (size == 0 || size > 256)
  if (size == 0 || size > 256)
    throw invalid_argument("RlinkCommand::SetBlockExt: invalid block size");
    throw Rexception("RlinkCommand::SetBlockExt()",
 
                     "Bad args: invalid block size");
  fpBlockExt    = pblock;
  fpBlockExt    = pblock;
  fBlockExtSize = size;
  fBlockExtSize = size;
  return;
  return;
}
}
 
 
Line 236... Line 258...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkCommand::Print(std::ostream& os, const RlinkAddrMap* pamap,
void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
                         size_t abase, size_t dbase, size_t sbase) const
                         const RlinkAddrMap* pamap, size_t abase,
 
                         size_t dbase, size_t sbase) const
{
{
  uint8_t ccode = Command();
  uint8_t ccode = Command();
 
 
  // separator + command mnemonic, code and flags
  // separator + command mnemonic, code and flags
  // separator:  ++  first in packet
  // separator:  ++  first in packet
Line 304... Line 327...
    os << " c=" << RosPrintBvi(fStatRequest, 8);
    os << " c=" << RosPrintBvi(fStatRequest, 8);
  }
  }
 
 
  // status field
  // status field
  os << " s=" << RosPrintBvi(fStatus, sbase);
  os << " s=" << RosPrintBvi(fStatus, sbase);
  if (fpExpect) {
  uint8_t scval  = fpExpect ? fpExpect->StatusValue() : cntx.StatusValue();
 
  uint8_t scmsk  = fpExpect ? fpExpect->StatusMask()  : cntx.StatusMask();
    if (TestFlagAny(kFlagChkStat)) {
    if (TestFlagAny(kFlagChkStat)) {
      os << "#";
      os << "#";
      os << " S=" << RosPrintBvi(fpExpect->StatusValue(), sbase);
    os << " S=" << RosPrintBvi(scval, sbase);
      if (fpExpect->StatusMask() != 0x00)  {
    if (scmsk != 0x00) {
        os << "," << RosPrintBvi(fpExpect->StatusMask(), sbase);
      os << "," << RosPrintBvi(scmsk, sbase);
      }
 
    } else if (fpExpect->StatusIsChecked()) {
 
      os << "!";
 
    } else {
 
      os << " ";
 
    }
    }
  } else {
  } else {
    os << " ";
    os << ( scmsk != 0xff ? "!" : " " );
  }
  }
 
 
  if (TestFlagAny(kFlagDone)) {
  if (TestFlagAny(kFlagDone)) {
    if (TestFlagAny(kFlagChkStat|kFlagChkData)) {
    if (TestFlagAny(kFlagChkStat|kFlagChkData)) {
      os << " FAIL: "
      os << " FAIL: "
Line 487... Line 506...
  delete fpExpect;
  delete fpExpect;
  fpExpect      = rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : 0;
  fpExpect      = rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : 0;
  return *this;
  return *this;
}
}
 
 
//------------------------------------------+-----------------------------------
} // end namespace Retro
#if (defined(Retro_NoInline) || defined(Retro_RlinkCommand_NoInline))
 
#define inline
 
#include "RlinkCommand.ipp"
 
#undef  inline
 
#endif
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.