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 19

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

Line No. Rev Author Line
1 19 wfjm
// $Id: Rw11CntlDL11.cpp 504 2013-04-13 15:37:24Z 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-03-06   495   1.0    Initial version
17
// 2013-02-05   483   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22
  \version $Id: Rw11CntlDL11.cpp 504 2013-04-13 15:37:24Z mueller $
23
  \brief   Implemenation of Rw11CntlDL11.
24
*/
25
 
26
#include "boost/bind.hpp"
27
 
28
#include "librtools/RosFill.hpp"
29
#include "librtools/Rexception.hpp"
30
 
31
#include "Rw11CntlDL11.hpp"
32
 
33
using namespace std;
34
 
35
/*!
36
  \class Retro::Rw11CntlDL11
37
  \brief FIXME_docs
38
*/
39
 
40
// all method definitions in namespace Retro
41
namespace Retro {
42
 
43
//------------------------------------------+-----------------------------------
44
// constants definitions
45
 
46
const uint16_t Rw11CntlDL11::kIbaddr;
47
const int      Rw11CntlDL11::kLam;
48
 
49
const uint16_t Rw11CntlDL11::kRCSR;
50
const uint16_t Rw11CntlDL11::kRBUF;
51
const uint16_t Rw11CntlDL11::kXCSR;
52
const uint16_t Rw11CntlDL11::kXBUF;
53
 
54
const uint16_t Rw11CntlDL11::kProbeOff;
55
const bool     Rw11CntlDL11::kProbeInt;
56
const bool     Rw11CntlDL11::kProbeRem;
57
 
58
const uint16_t Rw11CntlDL11::kRCSR_M_RDONE;
59
const uint16_t Rw11CntlDL11::kXCSR_M_XRDY;
60
const uint16_t Rw11CntlDL11::kXBUF_M_RRDY;
61
const uint16_t Rw11CntlDL11::kXBUF_M_XVAL;
62
const uint16_t Rw11CntlDL11::kXBUF_M_XBUF;
63
 
64
//------------------------------------------+-----------------------------------
65
//! Default constructor
66
 
67
Rw11CntlDL11::Rw11CntlDL11()
68
  : Rw11CntlBase<Rw11UnitDL11,1>("dl11"),
69
    fPC_xbuf(0)
70
{
71
  // must here because Unit have a back-pointer (not available at Rw11CntlBase)
72
  for (size_t i=0; i<NUnit(); i++) {
73
    fspUnit[i].reset(new Rw11UnitDL11(this, i));
74
  }
75
}
76
 
77
//------------------------------------------+-----------------------------------
78
//! Destructor
79
 
80
Rw11CntlDL11::~Rw11CntlDL11()
81
{}
82
 
83
//------------------------------------------+-----------------------------------
84
//! FIXME_docs
85
 
86
void Rw11CntlDL11::Config(const std::string& name, uint16_t base, int lam)
87
{
88
  ConfigCntl(name, base, lam, kProbeOff, kProbeInt, kProbeRem);
89
  return;
90
}
91
 
92
//------------------------------------------+-----------------------------------
93
//! FIXME_docs
94
 
95
void Rw11CntlDL11::Start()
96
{
97
  if (fStarted || fLam<0 || !fEnable || !fProbe.Found())
98
    throw Rexception("Rw11CntlDL11::Start",
99
                     "Bad state: started, no lam, not enable, not found");
100
 
101
  // setup primary info clist
102
  fPrimClist.Clear();
103
  Cpu().AddIbrb(fPrimClist, fBase);
104
  fPC_xbuf = Cpu().AddRibr(fPrimClist, fBase+kXBUF);
105
 
106
  // add attn handler
107
  Server().AddAttnHandler(boost::bind(&Rw11CntlDL11::AttnHandler, this, _1),
108
                          uint16_t(1)<<fLam, (void*)this);
109
  fStarted = true;
110
  return;
111
}
112
 
113
//------------------------------------------+-----------------------------------
114
//! FIXME_docs
115
 
116
void Rw11CntlDL11::Wakeup()
117
{
118
  if (!fspUnit[0]->RcvQueueEmpty()) {
119
    RlinkCommandList clist;
120
    Cpu().AddIbrb(clist, fBase);
121
    size_t ircsr = Cpu().AddRibr(clist, fBase+kRCSR);
122
    Server().Exec(clist);
123
    // FIXME_code: handle errors
124
    uint16_t rcsr = clist[ircsr].Data();
125
    if ((rcsr & kRCSR_M_RDONE) == 0) {      // RBUF not full
126
      uint8_t ichr = fspUnit[0]->RcvNext();
127
      clist.Clear();
128
      Cpu().AddWibr(clist, fBase+kRBUF, ichr);
129
      Server().Exec(clist);
130
      // FIXME_code: handle errors
131
    }
132
  }
133
 
134
  return;
135
}
136
 
137
//------------------------------------------+-----------------------------------
138
//! FIXME_docs
139
 
140
void Rw11CntlDL11::Dump(std::ostream& os, int ind, const char* text) const
141
{
142
  RosFill bl(ind);
143
  os << bl << (text?text:"--") << "Rw11CntlDL11 @ " << this << endl;
144
  Rw11CntlBase<Rw11UnitDL11,1>::Dump(os, ind, " ^");
145
  return;
146
}
147
 
148
//------------------------------------------+-----------------------------------
149
//! FIXME_docs
150
 
151
int Rw11CntlDL11::AttnHandler(const RlinkServer::AttnArgs& args)
152
{
153
  RlinkCommandList* pclist;
154
  size_t off;
155
 
156
  GetPrimInfo(args, pclist, off);
157
 
158
  uint16_t xbuf = (*pclist)[off+fPC_xbuf].Data();
159
 
160
  uint8_t ochr = xbuf & kXBUF_M_XBUF;
161
  bool xval = xbuf & kXBUF_M_XVAL;
162
  bool rrdy = xbuf & kXBUF_M_RRDY;
163
 
164
  if (xval) {
165
    fspUnit[0]->Snd(&ochr, 1);
166
  }
167
 
168
  if (rrdy && !fspUnit[0]->RcvQueueEmpty()) {
169
    uint8_t ichr = fspUnit[0]->RcvNext();
170
    RlinkCommandList clist;
171
    Cpu().AddWibr(clist, fBase+kRBUF, ichr);
172
    Server().Exec(clist);
173
    // FIXME_code: handle errors
174
  }
175
 
176
  return 0;
177
}
178
 
179
} // end namespace Retro

powered by: WebSVN 2.1.0

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