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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librw11/] [Rw11CntlDL11.cpp] - Blame information for rev 40

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

Line No. Rev Author Line
1 21 wfjm
// $Id: Rw11CntlDL11.cpp 516 2013-05-05 21:24:52Z mueller $
2 19 wfjm
//
3
// Copyright 2013- 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 21 wfjm
// 2013-05-04   516   1.0.2  add RxRlim support (receive interrupt rate limit)
17 20 wfjm
// 2013-04-20   508   1.0.1  add trace support
18 19 wfjm
// 2013-03-06   495   1.0    Initial version
19
// 2013-02-05   483   0.1    First draft
20
// ---------------------------------------------------------------------------
21
 
22
/*!
23
  \file
24 21 wfjm
  \version $Id: Rw11CntlDL11.cpp 516 2013-05-05 21:24:52Z mueller $
25 19 wfjm
  \brief   Implemenation of Rw11CntlDL11.
26
*/
27
 
28
#include "boost/bind.hpp"
29
 
30
#include "librtools/RosFill.hpp"
31 20 wfjm
#include "librtools/RosPrintBvi.hpp"
32
#include "librtools/RosPrintf.hpp"
33 19 wfjm
#include "librtools/Rexception.hpp"
34 20 wfjm
#include "librtools/RlogMsg.hpp"
35 19 wfjm
 
36
#include "Rw11CntlDL11.hpp"
37
 
38
using namespace std;
39
 
40
/*!
41
  \class Retro::Rw11CntlDL11
42
  \brief FIXME_docs
43
*/
44
 
45
// all method definitions in namespace Retro
46
namespace Retro {
47
 
48
//------------------------------------------+-----------------------------------
49
// constants definitions
50
 
51
const uint16_t Rw11CntlDL11::kIbaddr;
52
const int      Rw11CntlDL11::kLam;
53
 
54
const uint16_t Rw11CntlDL11::kRCSR;
55
const uint16_t Rw11CntlDL11::kRBUF;
56
const uint16_t Rw11CntlDL11::kXCSR;
57
const uint16_t Rw11CntlDL11::kXBUF;
58
 
59
const uint16_t Rw11CntlDL11::kProbeOff;
60
const bool     Rw11CntlDL11::kProbeInt;
61
const bool     Rw11CntlDL11::kProbeRem;
62
 
63 21 wfjm
const uint16_t Rw11CntlDL11::kRCSR_M_RXRLIM;
64
const uint16_t Rw11CntlDL11::kRCSR_V_RXRLIM;
65
const uint16_t Rw11CntlDL11::kRCSR_B_RXRLIM;
66 19 wfjm
const uint16_t Rw11CntlDL11::kRCSR_M_RDONE;
67
const uint16_t Rw11CntlDL11::kXCSR_M_XRDY;
68
const uint16_t Rw11CntlDL11::kXBUF_M_RRDY;
69
const uint16_t Rw11CntlDL11::kXBUF_M_XVAL;
70
const uint16_t Rw11CntlDL11::kXBUF_M_XBUF;
71
 
72
//------------------------------------------+-----------------------------------
73
//! Default constructor
74
 
75
Rw11CntlDL11::Rw11CntlDL11()
76
  : Rw11CntlBase<Rw11UnitDL11,1>("dl11"),
77 21 wfjm
    fPC_xbuf(0),
78
    fRxRlim(0)
79 19 wfjm
{
80
  // must here because Unit have a back-pointer (not available at Rw11CntlBase)
81
  for (size_t i=0; i<NUnit(); i++) {
82
    fspUnit[i].reset(new Rw11UnitDL11(this, i));
83
  }
84
}
85
 
86
//------------------------------------------+-----------------------------------
87
//! Destructor
88
 
89
Rw11CntlDL11::~Rw11CntlDL11()
90
{}
91
 
92
//------------------------------------------+-----------------------------------
93
//! FIXME_docs
94
 
95
void Rw11CntlDL11::Config(const std::string& name, uint16_t base, int lam)
96
{
97
  ConfigCntl(name, base, lam, kProbeOff, kProbeInt, kProbeRem);
98
  return;
99
}
100
 
101
//------------------------------------------+-----------------------------------
102
//! FIXME_docs
103
 
104
void Rw11CntlDL11::Start()
105
{
106
  if (fStarted || fLam<0 || !fEnable || !fProbe.Found())
107
    throw Rexception("Rw11CntlDL11::Start",
108
                     "Bad state: started, no lam, not enable, not found");
109
 
110
  // setup primary info clist
111
  fPrimClist.Clear();
112
  Cpu().AddIbrb(fPrimClist, fBase);
113
  fPC_xbuf = Cpu().AddRibr(fPrimClist, fBase+kXBUF);
114
 
115
  // add attn handler
116
  Server().AddAttnHandler(boost::bind(&Rw11CntlDL11::AttnHandler, this, _1),
117
                          uint16_t(1)<<fLam, (void*)this);
118
  fStarted = true;
119
  return;
120
}
121
 
122
//------------------------------------------+-----------------------------------
123
//! FIXME_docs
124
 
125 21 wfjm
void Rw11CntlDL11::UnitSetup(size_t ind)
126
{
127
  Rw11Cpu& cpu  = Cpu();
128
  uint16_t rcsr = (fRxRlim<<kRCSR_V_RXRLIM) & kRCSR_M_RXRLIM;
129
  RlinkCommandList clist;
130
  cpu.AddIbrb(clist, fBase);
131
  cpu.AddWibr(clist, fBase+kRCSR, rcsr);
132
  Server().Exec(clist);
133
  return;
134
}
135
 
136
//------------------------------------------+-----------------------------------
137
//! FIXME_docs
138
 
139 19 wfjm
void Rw11CntlDL11::Wakeup()
140
{
141
  if (!fspUnit[0]->RcvQueueEmpty()) {
142
    RlinkCommandList clist;
143
    Cpu().AddIbrb(clist, fBase);
144
    size_t ircsr = Cpu().AddRibr(clist, fBase+kRCSR);
145
    Server().Exec(clist);
146
    // FIXME_code: handle errors
147
    uint16_t rcsr = clist[ircsr].Data();
148
    if ((rcsr & kRCSR_M_RDONE) == 0) {      // RBUF not full
149
      uint8_t ichr = fspUnit[0]->RcvNext();
150
      clist.Clear();
151
      Cpu().AddWibr(clist, fBase+kRBUF, ichr);
152
      Server().Exec(clist);
153
      // FIXME_code: handle errors
154
    }
155
  }
156
 
157
  return;
158
}
159
 
160
//------------------------------------------+-----------------------------------
161
//! FIXME_docs
162
 
163 21 wfjm
void Rw11CntlDL11::SetRxRlim(uint16_t rlim)
164
{
165
  if (rlim > kRCSR_B_RXRLIM)
166
    throw Rexception("Rw11CntlDL11::SetRxRlim","Bad args: rlim too large");
167
 
168
  fRxRlim = rlim;
169
  UnitSetup(0);
170
  return;
171
}
172
 
173
//------------------------------------------+-----------------------------------
174
//! FIXME_docs
175
 
176
uint16_t Rw11CntlDL11::RxRlim() const
177
{
178
  return fRxRlim;
179
}
180
 
181
//------------------------------------------+-----------------------------------
182
//! FIXME_docs
183
 
184 19 wfjm
void Rw11CntlDL11::Dump(std::ostream& os, int ind, const char* text) const
185
{
186
  RosFill bl(ind);
187
  os << bl << (text?text:"--") << "Rw11CntlDL11 @ " << this << endl;
188 20 wfjm
  os << bl << "  fPC_xbuf:        " << fPC_xbuf << endl;
189 21 wfjm
  os << bl << "  fRxRlim:         " << fRxRlim  << endl;
190 20 wfjm
 
191 19 wfjm
  Rw11CntlBase<Rw11UnitDL11,1>::Dump(os, ind, " ^");
192
  return;
193
}
194
 
195
//------------------------------------------+-----------------------------------
196
//! FIXME_docs
197
 
198
int Rw11CntlDL11::AttnHandler(const RlinkServer::AttnArgs& args)
199
{
200
  RlinkCommandList* pclist;
201
  size_t off;
202
 
203
  GetPrimInfo(args, pclist, off);
204
 
205
  uint16_t xbuf = (*pclist)[off+fPC_xbuf].Data();
206
 
207
  uint8_t ochr = xbuf & kXBUF_M_XBUF;
208
  bool xval = xbuf & kXBUF_M_XVAL;
209
  bool rrdy = xbuf & kXBUF_M_RRDY;
210
 
211 20 wfjm
  if (fTraceLevel>0) {
212
    RlogMsg lmsg(LogFile());
213
    lmsg << "-I DL11." << Name()
214
         << " xbuf=" << RosPrintBvi(xbuf,8)
215
         << " xval=" << xval
216
         << " rrdy=" << rrdy
217
         << " rcvq=" << RosPrintf(fspUnit[0]->RcvQueueSize(),"d",3);
218
    if (xval) {
219
      lmsg << " char=";
220
      if (ochr>=040 && ochr<0177) {
221
        lmsg << "'" << char(ochr) << "'";
222
      } else {
223
        lmsg << RosPrintBvi(ochr,8);
224
        lmsg << " " << ((ochr&0200) ? "|" : " ");
225
        uint8_t ochr7 = ochr & 0177;
226
        if (ochr7 < 040) {
227
          switch (ochr7) {
228
          case 010: lmsg << "BS"; break;
229
          case 011: lmsg << "HT"; break;
230
          case 012: lmsg << "LF"; break;
231
          case 013: lmsg << "VT"; break;
232
          case 014: lmsg << "FF"; break;
233
          case 015: lmsg << "CR"; break;
234
          default:  lmsg << "^" << char('A'+ochr7);
235
          }
236
        } else {
237
          if (ochr7 < 0177) {
238
            lmsg << "'" << char(ochr7) << "'";
239
          } else {
240
            lmsg << "DEL";
241
          }
242
        }
243
      }
244
    }
245
  }
246
 
247 19 wfjm
  if (xval) {
248
    fspUnit[0]->Snd(&ochr, 1);
249
  }
250
 
251
  if (rrdy && !fspUnit[0]->RcvQueueEmpty()) {
252
    uint8_t ichr = fspUnit[0]->RcvNext();
253
    RlinkCommandList clist;
254
    Cpu().AddWibr(clist, fBase+kRBUF, ichr);
255
    Server().Exec(clist);
256
    // FIXME_code: handle errors
257
  }
258
 
259
  return 0;
260
}
261
 
262
} // end namespace Retro

powered by: WebSVN 2.1.0

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