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 12

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

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

powered by: WebSVN 2.1.0

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