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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 wfjm
// $Id: Rw11CntlLP11.cpp 659 2015-03-22 23:15:51Z mueller $
2 21 wfjm
//
3 28 wfjm
// Copyright 2013-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 21 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 28 wfjm
// 2014-12-30   625   1.2    adopt to Rlink V4 attn logic
17
// 2014-12-25   621   1.1    adopt to 4k word ibus window
18 21 wfjm
// 2013-05-04   515   1.0    Initial version
19
// 2013-05-01   513   0.1    First draft
20
// ---------------------------------------------------------------------------
21
 
22
/*!
23
  \file
24 30 wfjm
  \version $Id: Rw11CntlLP11.cpp 659 2015-03-22 23:15:51Z mueller $
25 21 wfjm
  \brief   Implemenation of Rw11CntlLP11.
26
*/
27
 
28
#include "boost/bind.hpp"
29
 
30
#include "librtools/RosFill.hpp"
31
#include "librtools/RosPrintBvi.hpp"
32
#include "librtools/RosPrintf.hpp"
33
#include "librtools/Rexception.hpp"
34
#include "librtools/RlogMsg.hpp"
35
 
36
#include "Rw11CntlLP11.hpp"
37
 
38
using namespace std;
39
 
40
/*!
41
  \class Retro::Rw11CntlLP11
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 Rw11CntlLP11::kIbaddr;
52
const int      Rw11CntlLP11::kLam;
53
 
54
const uint16_t Rw11CntlLP11::kCSR;
55
const uint16_t Rw11CntlLP11::kBUF;
56
 
57
const uint16_t Rw11CntlLP11::kProbeOff;
58
const bool     Rw11CntlLP11::kProbeInt;
59
const bool     Rw11CntlLP11::kProbeRem;
60
 
61
const uint16_t Rw11CntlLP11::kCSR_M_ERROR;
62
const uint16_t Rw11CntlLP11::kBUF_M_VAL;
63
const uint16_t Rw11CntlLP11::kBUF_M_BUF;
64
 
65
//------------------------------------------+-----------------------------------
66
//! Default constructor
67
 
68
Rw11CntlLP11::Rw11CntlLP11()
69
  : Rw11CntlBase<Rw11UnitLP11,1>("lp11"),
70
    fPC_buf(0)
71
{
72 28 wfjm
  // must be here because Units have a back-ptr (not available at Rw11CntlBase)
73 21 wfjm
  for (size_t i=0; i<NUnit(); i++) {
74
    fspUnit[i].reset(new Rw11UnitLP11(this, i));
75
  }
76
}
77
 
78
//------------------------------------------+-----------------------------------
79
//! Destructor
80
 
81
Rw11CntlLP11::~Rw11CntlLP11()
82
{}
83
 
84
//------------------------------------------+-----------------------------------
85
//! FIXME_docs
86
 
87
void Rw11CntlLP11::Config(const std::string& name, uint16_t base, int lam)
88
{
89
  ConfigCntl(name, base, lam, kProbeOff, kProbeInt, kProbeRem);
90
  return;
91
}
92
 
93
//------------------------------------------+-----------------------------------
94
//! FIXME_docs
95
 
96
void Rw11CntlLP11::Start()
97
{
98
  if (fStarted || fLam<0 || !fEnable || !fProbe.Found())
99
    throw Rexception("Rw11CntlLP11::Start",
100
                     "Bad state: started, no lam, not enable, not found");
101
 
102 28 wfjm
  // add device register address ibus and rbus mappings
103
  // done here because now Cntl bound to Cpu and Cntl probed
104 30 wfjm
  Cpu().AllIAddrMapInsert(Name()+".csr", Base() + kCSR);
105
  Cpu().AllIAddrMapInsert(Name()+".buf", Base() + kBUF);
106 28 wfjm
 
107 21 wfjm
  // setup primary info clist
108
  fPrimClist.Clear();
109 28 wfjm
  fPrimClist.AddAttn();
110 21 wfjm
  fPC_buf = Cpu().AddRibr(fPrimClist, fBase+kBUF);
111
 
112
  // add attn handler
113
  Server().AddAttnHandler(boost::bind(&Rw11CntlLP11::AttnHandler, this, _1),
114
                          uint16_t(1)<<fLam, (void*)this);
115
 
116
  fStarted = true;
117
  return;
118
}
119
 
120
//------------------------------------------+-----------------------------------
121
//! FIXME_docs
122
 
123
void Rw11CntlLP11::UnitSetup(size_t ind)
124
{
125
  Rw11UnitLP11& unit = *fspUnit[ind];
126
  SetOnline(unit.Virt());                   // online if stream attached
127
  return;
128
}
129
 
130
//------------------------------------------+-----------------------------------
131
//! FIXME_docs
132
 
133
void Rw11CntlLP11::Dump(std::ostream& os, int ind, const char* text) const
134
{
135
  RosFill bl(ind);
136
  os << bl << (text?text:"--") << "Rw11CntlLP11 @ " << this << endl;
137
  os << bl << "  fPC_buf:         " << fPC_buf << endl;
138
 
139
  Rw11CntlBase<Rw11UnitLP11,1>::Dump(os, ind, " ^");
140
  return;
141
}
142
 
143
//------------------------------------------+-----------------------------------
144
//! FIXME_docs
145
 
146 28 wfjm
int Rw11CntlLP11::AttnHandler(RlinkServer::AttnArgs& args)
147 21 wfjm
{
148 28 wfjm
  fStats.Inc(kStatNAttnHdl);
149
  Server().GetAttnInfo(args, fPrimClist);
150 21 wfjm
 
151 28 wfjm
  uint16_t buf = fPrimClist[fPC_buf].Data();
152 21 wfjm
  bool val     = buf & kBUF_M_VAL;
153
  uint8_t ochr = buf & kBUF_M_BUF;
154
 
155
  if (fTraceLevel>0) {
156
    RlogMsg lmsg(LogFile());
157
    lmsg << "-I LP11." << Name()
158
         << " buf=" << RosPrintBvi(buf,8)
159
         << " val=" << val;
160
    if (val) {
161
      lmsg << " char=";
162
      if (ochr>=040 && ochr<0177) {
163
        lmsg << "'" << char(ochr) << "'";
164
      } else {
165
        lmsg << RosPrintBvi(ochr,8);
166
      }
167
    }
168
  }
169
 
170
  if (val) {
171
    RerrMsg emsg;
172
    bool rc = fspUnit[0]->VirtWrite(&ochr, 1, emsg);
173
    if (!rc) {
174
      RlogMsg lmsg(LogFile());
175
      lmsg << emsg;
176
      SetOnline(false);
177
    }
178
    if (ochr == 014) {                      // ^L = FF = FormFeed seen ?
179
      rc = fspUnit[0]->VirtFlush(emsg);
180
    }
181
  }
182
 
183
  return 0;
184
}
185
 
186
//------------------------------------------+-----------------------------------
187
//! FIXME_docs
188
 
189
void Rw11CntlLP11::SetOnline(bool online)
190
{
191
  Rw11Cpu& cpu  = Cpu();
192
  uint16_t csr  = online ? 0 : kCSR_M_ERROR;
193
  RlinkCommandList clist;
194
  cpu.AddWibr(clist, fBase+kCSR, csr);
195
  Server().Exec(clist);
196
  return;
197
}
198
 
199
} // end namespace Retro

powered by: WebSVN 2.1.0

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