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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 20 wfjm
// $Id: RlinkConnect.hpp 509 2013-04-21 20:46:20Z mueller $
2 10 wfjm
//
3 19 wfjm
// Copyright 2011-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 wfjm
//
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 20 wfjm
// 2013-04-21   509   1.3.3  add SndAttn() method
17 19 wfjm
// 2013-03-05   495   1.3.2  add Exec() without emsg (will send emsg to LogFile)
18
// 2013-03-01   493   1.3.1  add Server(Active..|SignalAttn)() methods
19
// 2013-02-23   492   1.3    use scoped_ptr for Port; Close allways allowed
20
//                           use RlinkContext, add Context(), Exec(..., cntx)
21
// 2013-02-22   491   1.2    use new RlogFile/RlogMsg interfaces
22
// 2013-02-03   481   1.1.3  add SetServer(),Server()
23
// 2013-01-13   474   1.1.2  add PollAttn() method
24 15 wfjm
// 2011-11-28   434   1.1.1  struct LogOpts: use uint32_t for lp64 compatibility
25 12 wfjm
// 2011-04-24   380   1.1    use boost::noncopyable (instead of private dcl's);
26
//                           use boost::(mutex&lock), implement Lockable IF
27
// 2011-04-22   379   1.0.1  add Lock(), Unlock()
28 10 wfjm
// 2011-04-02   375   1.0    Initial version
29
// 2011-01-15   356   0.1    First draft
30
// ---------------------------------------------------------------------------
31
 
32
/*!
33
  \file
34 20 wfjm
  \version $Id: RlinkConnect.hpp 509 2013-04-21 20:46:20Z mueller $
35 10 wfjm
  \brief   Declaration of class \c RlinkConnect.
36
*/
37
 
38
#ifndef included_Retro_RlinkConnect
39
#define included_Retro_RlinkConnect 1
40
 
41
#include <cstdint>
42
#include <string>
43
#include <vector>
44
#include <ostream>
45
 
46 12 wfjm
#include "boost/utility.hpp"
47
#include "boost/thread/recursive_mutex.hpp"
48 19 wfjm
#include "boost/shared_ptr.hpp"
49
#include "boost/scoped_ptr.hpp"
50 12 wfjm
 
51 10 wfjm
#include "librtools/RerrMsg.hpp"
52
#include "librtools/Rstats.hpp"
53
#include "librtools/RlogFile.hpp"
54
 
55
#include "RlinkPort.hpp"
56
#include "RlinkCommandList.hpp"
57
#include "RlinkPacketBuf.hpp"
58
#include "RlinkAddrMap.hpp"
59 19 wfjm
#include "RlinkContext.hpp"
60 10 wfjm
 
61
namespace Retro {
62
 
63 19 wfjm
  class RlinkServer;                        // forw decl to avoid circular incl
64
 
65 12 wfjm
  class RlinkConnect : private boost::noncopyable {
66 10 wfjm
    public:
67
      struct LogOpts {
68 15 wfjm
        uint32_t      baseaddr;
69
        uint32_t      basedata;
70
        uint32_t      basestat;
71
        uint32_t      printlevel;           // 0=off,1=err,2=chk,3=all
72
        uint32_t      dumplevel;            // 0=off,1=err,2=chk,3=all
73
        uint32_t      tracelevel;           // 0=off,1=buf,2=char
74 10 wfjm
 
75
                      LogOpts()
76
                        : baseaddr(16), basedata(16), basestat(16),
77
                          printlevel(0), dumplevel(0), tracelevel(0)
78
                      {}
79
      };
80
 
81
                    RlinkConnect();
82 19 wfjm
                   ~RlinkConnect();
83 10 wfjm
 
84
      bool          Open(const std::string& name, RerrMsg& emsg);
85
      void          Close();
86
      bool          IsOpen() const;
87
      RlinkPort*    Port() const;
88
 
89 19 wfjm
      RlinkContext& Context();
90
 
91
      void          SetServer(RlinkServer* pserv);
92
      RlinkServer*  Server() const;
93
      bool          ServerActive() const;
94
      bool          ServerActiveInside() const;
95
      bool          ServerActiveOutside() const;
96
      void          ServerSignalAttn();
97
 
98 12 wfjm
      // provide boost Lockable interface
99
      void          lock();
100
      bool          try_lock();
101
      void          unlock();
102
 
103 10 wfjm
      bool          Exec(RlinkCommandList& clist, RerrMsg& emsg);
104 19 wfjm
      bool          Exec(RlinkCommandList& clist, RlinkContext& cntx,
105
                         RerrMsg& emsg);
106
      bool          Exec(RlinkCommandList& clist);
107
      bool          Exec(RlinkCommandList& clist, RlinkContext& cntx);
108 10 wfjm
 
109
      double        WaitAttn(double timeout, RerrMsg& emsg);
110 19 wfjm
      int           PollAttn(RerrMsg& emsg);
111 10 wfjm
      bool          SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg);
112 20 wfjm
      bool          SndAttn(RerrMsg& emsg);
113 10 wfjm
 
114
      bool          AddrMapInsert(const std::string& name, uint16_t addr);
115
      bool          AddrMapErase(const std::string& name);
116
      bool          AddrMapErase(uint16_t addr);
117
      void          AddrMapClear();
118
 
119
      const RlinkAddrMap& AddrMap() const;
120
      const Rstats& Stats() const;
121
 
122
      void          SetLogOpts(const LogOpts& opts);
123
      const LogOpts&  GetLogOpts() const;
124 19 wfjm
 
125
      bool          LogOpen(const std::string& name);
126
      void          LogUseStream(std::ostream* pstr,
127
                                 const std::string& name = "");
128 10 wfjm
      RlogFile&     LogFile() const;
129 19 wfjm
      const boost::shared_ptr<RlogFile>&   LogFileSPtr() const;
130 10 wfjm
 
131
      void          Print(std::ostream& os) const;
132
      void          Dump(std::ostream& os, int ind=0, const char* text=0) const;
133
 
134
    // statistics counter indices
135
      enum stats {
136
        kStatNExec = 0,
137
        kStatNSplitVol,
138
        kStatNExecPart,
139
        kStatNCmd,
140
        kStatNRreg,
141
        kStatNRblk,
142
        kStatNWreg,
143
        kStatNWblk,
144
        kStatNStat,
145
        kStatNAttn,
146
        kStatNInit,
147
        kStatNRblkWord,
148
        kStatNWblkWord,
149
        kStatNTxPktByt,
150
        kStatNTxEsc,
151
        kStatNRxPktByt,
152
        kStatNRxEsc,
153
        kStatNRxAttn,
154
        kStatNRxIdle,
155
        kStatNRxDrop,
156
        kStatNExpData,
157
        kStatNExpStat,
158
        kStatNChkData,
159
        kStatNChkStat,
160
        kStatNSndOob,
161
        kDimStat
162
      };
163
 
164
    protected:
165 12 wfjm
      bool          ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend,
166 19 wfjm
                             RerrMsg& emsg, RlinkContext& cntx);
167 12 wfjm
 
168
    protected:
169 19 wfjm
      boost::scoped_ptr<RlinkPort> fpPort;  //!< ptr to port
170
      RlinkServer*  fpServ;                 //!< ptr to server (optional)
171 10 wfjm
      uint8_t       fSeqNumber[8];          //!< command sequence number
172
      RlinkPacketBuf fTxPkt;                //!< transmit packet buffer
173
      RlinkPacketBuf fRxPkt;                //!< receive packet buffer
174 19 wfjm
      RlinkContext  fContext;               //!< default context
175 10 wfjm
      RlinkAddrMap  fAddrMap;               //!< name<->address mapping
176
      Rstats        fStats;                 //!< statistics
177
      LogOpts       fLogOpts;               //!< log options
178 19 wfjm
      boost::shared_ptr<RlogFile> fspLog;   //!< log file ptr
179
      boost::recursive_mutex fConnectMutex; //!< mutex to lock whole connect
180 10 wfjm
  };
181
 
182
} // end namespace Retro
183
 
184
#include "RlinkConnect.ipp"
185
 
186
#endif

powered by: WebSVN 2.1.0

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