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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librlink/] [RlinkConnect.hpp] - Blame information for rev 15

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 wfjm
// $Id: RlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $
2 10 wfjm
//
3
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 15 wfjm
// 2011-11-28   434   1.1.1  struct LogOpts: use uint32_t for lp64 compatibility
17 12 wfjm
// 2011-04-24   380   1.1    use boost::noncopyable (instead of private dcl's);
18
//                           use boost::(mutex&lock), implement Lockable IF
19
// 2011-04-22   379   1.0.1  add Lock(), Unlock()
20 10 wfjm
// 2011-04-02   375   1.0    Initial version
21
// 2011-01-15   356   0.1    First draft
22
// ---------------------------------------------------------------------------
23
 
24
 
25
/*!
26
  \file
27 15 wfjm
  \version $Id: RlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $
28 10 wfjm
  \brief   Declaration of class \c RlinkConnect.
29
*/
30
 
31
#ifndef included_Retro_RlinkConnect
32
#define included_Retro_RlinkConnect 1
33
 
34
#include <cstdint>
35
#include <string>
36
#include <vector>
37
#include <ostream>
38
 
39 12 wfjm
#include "boost/utility.hpp"
40
#include "boost/thread/recursive_mutex.hpp"
41
 
42 10 wfjm
#include "librtools/RerrMsg.hpp"
43
#include "librtools/Rstats.hpp"
44
#include "librtools/RlogFile.hpp"
45
 
46
#include "RlinkPort.hpp"
47
#include "RlinkCommandList.hpp"
48
#include "RlinkPacketBuf.hpp"
49
#include "RlinkAddrMap.hpp"
50
 
51
namespace Retro {
52
 
53 12 wfjm
  class RlinkConnect : private boost::noncopyable {
54 10 wfjm
    public:
55
      struct LogOpts {
56 15 wfjm
        uint32_t      baseaddr;
57
        uint32_t      basedata;
58
        uint32_t      basestat;
59
        uint32_t      printlevel;           // 0=off,1=err,2=chk,3=all
60
        uint32_t      dumplevel;            // 0=off,1=err,2=chk,3=all
61
        uint32_t      tracelevel;           // 0=off,1=buf,2=char
62 10 wfjm
 
63
                      LogOpts()
64
                        : baseaddr(16), basedata(16), basestat(16),
65
                          printlevel(0), dumplevel(0), tracelevel(0)
66
                      {}
67
      };
68
 
69
                    RlinkConnect();
70
                    ~RlinkConnect();
71
 
72
      bool          Open(const std::string& name, RerrMsg& emsg);
73
      void          Close();
74
      bool          IsOpen() const;
75
      RlinkPort*    Port() const;
76
 
77 12 wfjm
      // provide boost Lockable interface
78
      void          lock();
79
      bool          try_lock();
80
      void          unlock();
81
 
82 10 wfjm
      bool          Exec(RlinkCommandList& clist, RerrMsg& emsg);
83
 
84
      double        WaitAttn(double timeout, RerrMsg& emsg);
85
      bool          SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg);
86
 
87
      bool          AddrMapInsert(const std::string& name, uint16_t addr);
88
      bool          AddrMapErase(const std::string& name);
89
      bool          AddrMapErase(uint16_t addr);
90
      void          AddrMapClear();
91
 
92
      const RlinkAddrMap& AddrMap() const;
93
      const Rstats& Stats() const;
94
 
95
      bool          LogOpen(const std::string& name);
96
      void          LogUseStream(std::ostream* pstr);
97
      void          SetLogOpts(const LogOpts& opts);
98
      const LogOpts&  GetLogOpts() const;
99
      RlogFile&     LogFile() const;
100
 
101
      void          Print(std::ostream& os) const;
102
      void          Dump(std::ostream& os, int ind=0, const char* text=0) const;
103
 
104
    // statistics counter indices
105
      enum stats {
106
        kStatNExec = 0,
107
        kStatNSplitVol,
108
        kStatNExecPart,
109
        kStatNCmd,
110
        kStatNRreg,
111
        kStatNRblk,
112
        kStatNWreg,
113
        kStatNWblk,
114
        kStatNStat,
115
        kStatNAttn,
116
        kStatNInit,
117
        kStatNRblkWord,
118
        kStatNWblkWord,
119
        kStatNTxPktByt,
120
        kStatNTxEsc,
121
        kStatNRxPktByt,
122
        kStatNRxEsc,
123
        kStatNRxAttn,
124
        kStatNRxIdle,
125
        kStatNRxDrop,
126
        kStatNExpData,
127
        kStatNExpStat,
128
        kStatNChkData,
129
        kStatNChkStat,
130
        kStatNSndOob,
131
        kDimStat
132
      };
133
 
134
    protected:
135 12 wfjm
      bool          ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend,
136
                             RerrMsg& emsg);
137
 
138
    protected:
139 10 wfjm
      RlinkPort*    fpPort;                 //!< ptr to port
140
      uint8_t       fSeqNumber[8];          //!< command sequence number
141
      RlinkPacketBuf fTxPkt;                //!< transmit packet buffer
142
      RlinkPacketBuf fRxPkt;                //!< receive packet buffer
143
      RlinkAddrMap  fAddrMap;               //!< name<->address mapping
144
      Rstats        fStats;                 //!< statistics
145
      LogOpts       fLogOpts;               //!< log options
146
      RlogFile      fLogFile;               //!< connection log file
147 12 wfjm
      boost::recursive_mutex fMutexConn;    //!< mutex to lock whole connect
148 10 wfjm
  };
149
 
150
} // end namespace Retro
151
 
152
#if !(defined(Retro_NoInline) || defined(Retro_RlinkConnect_NoInline))
153
#include "RlinkConnect.ipp"
154
#endif
155
 
156
#endif

powered by: WebSVN 2.1.0

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