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

Subversion Repositories w11

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

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

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

powered by: WebSVN 2.1.0

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