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 19

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

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

powered by: WebSVN 2.1.0

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