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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [src/] [librw11/] [Rw11Cpu.hpp] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 wfjm
// $Id: Rw11Cpu.hpp 721 2015-12-29 17:50:50Z mueller $
2 19 wfjm
//
3 28 wfjm
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 19 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 34 wfjm
// 2015-12-28   721   1.2.5  BUGFIX: IM* correct register offset definitions
17
// 2015-07-12   700   1.2.4  use ..CpuAct instead ..CpuGo (new active based lam);
18
//                           add probe and map setup for optional cpu components
19 30 wfjm
// 2015-05-08   675   1.2.3  w11a start/stop/suspend overhaul
20
// 2015-04-25   668   1.2.2  add AddRbibr(), AddWbibr()
21
// 2015-04-03   661   1.2.1  add kStat_M_* defs
22
// 2015-03-21   659   1.2    add RAddrMap; add AllRAddrMapInsert();
23 28 wfjm
// 2015-01-01   626   1.1    Adopt for rlink v4 and 4k ibus window; add IAddrMap
24 20 wfjm
// 2013-04-14   506   1.0.1  add AddLalh(),AddRMem(),AddWMem()
25 19 wfjm
// 2013-04-12   504   1.0    Initial version
26
// 2013-01-27   478   0.1    First draft
27
// ---------------------------------------------------------------------------
28
 
29
 
30
/*!
31
  \file
32 34 wfjm
  \version $Id: Rw11Cpu.hpp 721 2015-12-29 17:50:50Z mueller $
33 19 wfjm
  \brief   Declaration of class Rw11Cpu.
34
*/
35
 
36
#ifndef included_Retro_Rw11Cpu
37
#define included_Retro_Rw11Cpu 1
38
 
39
#include <string>
40
#include <vector>
41
 
42
#include "boost/utility.hpp"
43
#include "boost/shared_ptr.hpp"
44
#include "boost/thread/locks.hpp"
45
#include "boost/thread/condition_variable.hpp"
46
 
47
#include "librtools/Rstats.hpp"
48
#include "librtools/RerrMsg.hpp"
49
#include "librlink/RlinkConnect.hpp"
50 28 wfjm
#include "librlink/RlinkAddrMap.hpp"
51 19 wfjm
 
52
#include "Rw11Probe.hpp"
53
 
54
#include "librtools/Rbits.hpp"
55
#include "Rw11.hpp"
56
 
57
namespace Retro {
58
 
59
  class Rw11Cntl;                           // forw decl to avoid circular incl
60
 
61
  class Rw11Cpu : public Rbits, private boost::noncopyable {
62
    public:
63
      typedef std::map<std::string, boost::shared_ptr<Rw11Cntl>> cmap_t;
64
      typedef cmap_t::iterator         cmap_it_t;
65
      typedef cmap_t::const_iterator   cmap_cit_t;
66
      typedef cmap_t::value_type       cmap_val_t;
67
 
68 20 wfjm
 
69 19 wfjm
      explicit      Rw11Cpu(const std::string& type);
70
      virtual      ~Rw11Cpu();
71
 
72
      void          Setup(Rw11* pw11);
73
      Rw11&         W11() const;
74
      RlinkServer&  Server() const;
75
      RlinkConnect& Connect() const;
76
      RlogFile&     LogFile() const;
77
 
78
      const std::string&   Type() const;
79
      size_t        Index() const;
80
      uint16_t      Base() const;
81 28 wfjm
      uint16_t      IBase() const;
82 19 wfjm
 
83 34 wfjm
      bool          HasScnt() const;
84
      bool          HasCmon() const;
85
      uint16_t      HasHbpt() const;
86
      bool          HasIbmon() const;
87
 
88 19 wfjm
      void          AddCntl(const boost::shared_ptr<Rw11Cntl>& spcntl);
89
      bool          TestCntl(const std::string& name) const;
90
      void          ListCntl(std::vector<std::string>& list) const;
91
      Rw11Cntl&     Cntl(const std::string& name) const;
92
 
93
      void          Start();
94
 
95
      std::string   NextCntlName(const std::string& base) const;
96
 
97 28 wfjm
      int           AddMembe(RlinkCommandList& clist, uint16_t be,
98
                             bool stick=false);
99 19 wfjm
      int           AddRibr(RlinkCommandList& clist, uint16_t ibaddr);
100
      int           AddWibr(RlinkCommandList& clist, uint16_t ibaddr,
101
                            uint16_t data);
102
 
103 30 wfjm
      int           AddRbibr(RlinkCommandList& clist, uint16_t ibaddr,
104
                             size_t size);
105
      int           AddWbibr(RlinkCommandList& clist, uint16_t ibaddr,
106
                             std::vector<uint16_t> block);
107
 
108 20 wfjm
      int           AddLalh(RlinkCommandList& clist, uint32_t addr,
109 30 wfjm
                            uint16_t mode=kCPAH_M_22BIT);
110 20 wfjm
      int           AddRMem(RlinkCommandList& clist, uint32_t addr,
111
                            uint16_t* buf, size_t size,
112 30 wfjm
                            uint16_t mode=kCPAH_M_22BIT,
113 28 wfjm
                            bool singleblk=false);
114 20 wfjm
      int           AddWMem(RlinkCommandList& clist, uint32_t addr,
115
                            const uint16_t* buf, size_t size,
116 30 wfjm
                            uint16_t mode=kCPAH_M_22BIT,
117 28 wfjm
                            bool singleblk=false);
118 20 wfjm
 
119 19 wfjm
      bool          MemRead(uint16_t addr, std::vector<uint16_t>& data,
120
                            size_t nword, RerrMsg& emsg);
121
      bool          MemWrite(uint16_t addr, const std::vector<uint16_t>& data,
122
                             RerrMsg& emsg);
123
 
124
      bool          ProbeCntl(Rw11Probe& dsc);
125
 
126
      bool          LoadAbs(const std::string& fname, RerrMsg& emsg,
127
                            bool trace=false);
128
      bool          Boot(const std::string& uname, RerrMsg& emsg);
129
 
130 34 wfjm
      void          SetCpuActUp();
131
      void          SetCpuActDown(uint16_t stat);
132
      double        WaitCpuActDown(double tout);
133
      bool          CpuAct() const;
134 19 wfjm
      uint16_t      CpuStat() const;
135
 
136 28 wfjm
      uint16_t      IbusRemoteAddr(uint16_t ibaddr) const;
137 30 wfjm
      void          AllIAddrMapInsert(const std::string& name, uint16_t ibaddr);
138
      void          AllRAddrMapInsert(const std::string& name, uint16_t rbaddr);
139 28 wfjm
 
140
      bool          IAddrMapInsert(const std::string& name, uint16_t ibaddr);
141
      bool          IAddrMapErase(const std::string& name);
142
      bool          IAddrMapErase(uint16_t ibaddr);
143
      void          IAddrMapClear();
144
      const RlinkAddrMap& IAddrMap() const;
145
 
146 30 wfjm
      bool          RAddrMapInsert(const std::string& name, uint16_t rbaddr);
147
      bool          RAddrMapErase(const std::string& name);
148
      bool          RAddrMapErase(uint16_t rbaddr);
149
      void          RAddrMapClear();
150
      const RlinkAddrMap& RAddrMap() const;
151
 
152 19 wfjm
      void          W11AttnHandler();
153
 
154
      const Rstats& Stats() const;
155
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
156
 
157
    // some constants (also defined in cpp)
158 30 wfjm
      static const uint16_t  kCPCONF  = 0x0000; //!< CPCONF  reg offset
159
      static const uint16_t  kCPCNTL  = 0x0001; //!< CPADDR  reg offset
160
      static const uint16_t  kCPSTAT  = 0x0002; //!< CPSTAT  reg offset
161
      static const uint16_t  kCPPSW   = 0x0003; //!< CPPSW   reg offset
162
      static const uint16_t  kCPAL    = 0x0004; //!< CPAL    reg offset
163
      static const uint16_t  kCPAH    = 0x0005; //!< CPAH    reg offset
164
      static const uint16_t  kCPMEM   = 0x0006; //!< CPMEM   reg offset
165
      static const uint16_t  kCPMEMI  = 0x0007; //!< CPMEMI  reg offset
166
      static const uint16_t  kCPR0    = 0x0008; //!< CPR0    reg offset
167
      static const uint16_t  kCPPC    = 0x000f; //!< CPPC    reg offset
168
      static const uint16_t  kCPMEMBE = 0x0010; //!< CPMEMBE reg offset
169 19 wfjm
 
170 30 wfjm
      static const uint16_t  kCPFUNC_NOOP    = 0x0000; //!< 
171
      static const uint16_t  kCPFUNC_START   = 0x0001; //!< 
172
      static const uint16_t  kCPFUNC_STOP    = 0x0002; //!< 
173
      static const uint16_t  kCPFUNC_STEP    = 0x0003; //!< 
174
      static const uint16_t  kCPFUNC_CRESET  = 0x0004; //!< 
175
      static const uint16_t  kCPFUNC_BRESET  = 0x0005; //!<
176
      static const uint16_t  kCPFUNC_SUSPEND = 0x0006; //!<
177
      static const uint16_t  kCPFUNC_RESUME  = 0x0007; //!<
178 19 wfjm
 
179 30 wfjm
      static const uint16_t  kCPSTAT_M_SuspExt = kWBit09; //!<
180
      static const uint16_t  kCPSTAT_M_SuspInt = kWBit08; //!<
181
      static const uint16_t  kCPSTAT_M_CpuRust = 0x00f0;  //!<
182
      static const uint16_t  kCPSTAT_V_CpuRust = 4;       //!<
183
      static const uint16_t  kCPSTAT_B_CpuRust = 0x000f;  //!<
184
      static const uint16_t  kCPSTAT_M_CpuSusp = kWBit03; //!<
185
      static const uint16_t  kCPSTAT_M_CpuGo   = kWBit02; //!<
186
      static const uint16_t  kCPSTAT_M_CmdMErr = kWBit01; //!<
187
      static const uint16_t  kCPSTAT_M_CmdErr  = kWBit00; //!<
188 19 wfjm
 
189 30 wfjm
      static const uint16_t  kCPURUST_INIT   = 0x0;  //!< cpu in init state
190
      static const uint16_t  kCPURUST_HALT   = 0x1;  //!< cpu executed HALT
191
      static const uint16_t  kCPURUST_RESET  = 0x2;  //!< cpu was reset
192
      static const uint16_t  kCPURUST_STOP   = 0x3;  //!< cpu was stopped
193
      static const uint16_t  kCPURUST_STEP   = 0x4;  //!< cpu was stepped
194
      static const uint16_t  kCPURUST_SUSP   = 0x5;  //!< cpu was suspended
195 34 wfjm
      static const uint16_t  kCPURUST_HBPT   = 0x6;  //!< cpu hardware bpt
196 30 wfjm
      static const uint16_t  kCPURUST_RUNS   = 0x7;  //!< cpu running
197
      static const uint16_t  kCPURUST_VECFET = 0x8;  //!< vector fetch halt
198
      static const uint16_t  kCPURUST_RECRSV = 0x9;  //!< rec red-stack halt
199
      static const uint16_t  kCPURUST_SFAIL  = 0xa;  //!< sequencer failure
200
      static const uint16_t  kCPURUST_VFAIL  = 0xb;  //!< vmbox failure
201 19 wfjm
 
202 30 wfjm
      static const uint16_t  kCPAH_M_ADDR  = 0x003f;  //!< 
203
      static const uint16_t  kCPAH_M_22BIT = kWBit06; //!< 
204
      static const uint16_t  kCPAH_M_UBMAP = kWBit07; //!<
205 20 wfjm
 
206 30 wfjm
      static const uint16_t  kCPMEMBE_M_STICK = kWBit02; //!< 
207
      static const uint16_t  kCPMEMBE_M_BE    = 0x0003;  //!< 
208 28 wfjm
 
209 30 wfjm
    // defs for the four status bits defined by w11 rbus iface
210
      static const uint8_t   kStat_M_CmdErr  = kBBit07; //!< stat: cmderr  flag
211
      static const uint8_t   kStat_M_CmdMErr = kBBit06; //!< stat: cmdmerr flag
212 34 wfjm
      static const uint8_t   kStat_M_CpuSusp = kBBit05; //!< stat: cpususp flag
213 30 wfjm
      static const uint8_t   kStat_M_CpuGo   = kBBit04; //!< stat: cpugo   flag
214
 
215 34 wfjm
    // defs for optional w11 components
216
      static const uint16_t  kSCBASE  = 0x0040;   //!< DMSCNT reg base offset
217
      static const uint16_t  kSCCNTL  = 0x0000;   //!< SC.CNTL  reg offset
218
      static const uint16_t  kSCADDR  = 0x0001;   //!< SC.ADDR  reg offset
219
      static const uint16_t  kSCDATA  = 0x0002;   //!< SC.DATA  reg offset
220
 
221
      static const uint16_t  kCMBASE  = 0x0048;   //!< DMCMON reg base offset
222
      static const uint16_t  kCMCNTL  = 0x0000;   //!< CM.CNTL  reg offset
223
      static const uint16_t  kCMSTAT  = 0x0001;   //!< CM.STAT  reg offset
224
      static const uint16_t  kCMADDR  = 0x0002;   //!< CM.ADDR  reg offset
225
      static const uint16_t  kCMDATA  = 0x0003;   //!< CM.DATA  reg offset
226
      static const uint16_t  kCMIADDR = 0x0004;   //!< CM.IADDR reg offset
227
      static const uint16_t  kCMIPC   = 0x0005;   //!< CM.IPC   reg offset
228
      static const uint16_t  kCMIREG  = 0x0006;   //!< CM.IREG  reg offset
229
      static const uint16_t  kCMIMAL  = 0x0007;   //!< CM.IMAL  reg offset
230
 
231
      static const uint16_t  kHBBASE  = 0x0050;   //!< DMHBPT reg base offset
232
      static const uint16_t  kHBSIZE  = 0x0004;   //!< DMHBPT unit size
233
      static const uint16_t  kHBNMAX  = 0x0004;   //!< DMHBPT max number units
234
      static const uint16_t  kHBCNTL  = 0x0000;   //!< HB.CNTL  reg offset
235
      static const uint16_t  kHBSTAT  = 0x0001;   //!< HB.STAT  reg offset
236
      static const uint16_t  kHBHILIM = 0x0002;   //!< HB.HILIM reg offset
237
      static const uint16_t  kHBLOLIM = 0x0003;   //!< HB.LOLIM reg offset
238
 
239
      static const uint16_t  kIMBASE  = 0160000;  //!< Ibmon ibus address
240
      static const uint16_t  kIMCNTL  = 0x0000;   //!< IM.CNTL  reg offset
241
      static const uint16_t  kIMSTAT  = 0x0002;   //!< IM.STAT  reg offset
242
      static const uint16_t  kIMHILIM = 0x0004;   //!< IM.HILIM reg offset
243
      static const uint16_t  kIMLOLIM = 0x0006;   //!< IM.LOLIM reg offset
244
      static const uint16_t  kIMADDR  = 0x0008;   //!< IM.ADDR  reg offset
245
      static const uint16_t  kIMDATA  = 0x000a;   //!< IM.DATA  reg offset
246
 
247
    protected:
248
      void          SetupStd();
249
      void          SetupOpt();
250
 
251 19 wfjm
    private:
252
                    Rw11Cpu() {}            //!< default ctor blocker
253
 
254
    protected:
255
      Rw11*         fpW11;
256
      std::string   fType;
257
      size_t        fIndex;
258
      uint16_t      fBase;
259 28 wfjm
      uint16_t      fIBase;
260 34 wfjm
      bool          fHasScnt;               //!< has dmscnt (state counter) 
261
      bool          fHasCmon;               //!< has dmcmon (cpu monitor)
262
      uint16_t      fHasHbpt;               //!< has dmhbpt (hardware breakpoint)
263
      bool          fHasIbmon;              //!< has ibmon  (ibus monitor)
264
      bool          fCpuAct;
265 19 wfjm
      uint16_t      fCpuStat;
266 34 wfjm
      boost::mutex               fCpuActMutex;
267
      boost::condition_variable  fCpuActCond;
268 19 wfjm
      cmap_t        fCntlMap;               //!< name->cntl map
269 28 wfjm
      RlinkAddrMap  fIAddrMap;              //!< ibus name<->address mapping
270 30 wfjm
      RlinkAddrMap  fRAddrMap;              //!< rbus name<->address mapping
271 19 wfjm
      Rstats        fStats;                 //!< statistics
272
  };
273
 
274
} // end namespace Retro
275
 
276
#include "Rw11Cpu.ipp"
277
 
278
#endif

powered by: WebSVN 2.1.0

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