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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librw11/] [Rw11UnitStream.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: Rw11UnitStream.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: Rw11UnitStream.cpp 515 2013-05-04 17:28:59Z mueller $
23
  \brief   Implemenation of Rw11UnitStream.
24
*/
25
 
26
#include "librtools/Rexception.hpp"
27
 
28
#include "Rw11UnitStream.hpp"
29
 
30
using namespace std;
31
 
32
/*!
33
  \class Retro::Rw11UnitStream
34
  \brief FIXME_docs
35
*/
36
 
37
// all method definitions in namespace Retro
38
namespace Retro {
39
 
40
//------------------------------------------+-----------------------------------
41
//! Constructor
42
 
43
Rw11UnitStream::Rw11UnitStream(Rw11Cntl* pcntl, size_t index)
44
  : Rw11UnitVirt<Rw11VirtStream>(pcntl, index)
45
{
46
  fStats.Define(kStatNPreAttDrop,    "NPreAttDrop",
47
                "output bytes dropped prior attach");
48
  fStats.Define(kStatNPreAttMiss,    "NPreAttMiss",
49
                "input bytes missed prior attach");
50
}
51
 
52
//------------------------------------------+-----------------------------------
53
//! Destructor
54
 
55
Rw11UnitStream::~Rw11UnitStream()
56
{}
57
 
58
//------------------------------------------+-----------------------------------
59
//! FIXME_docs
60
 
61
void Rw11UnitStream::SetPos(int pos)
62
{
63
  if (!Virt())
64
    throw Rexception("Rw11UnitStream::SetPos", "no stream attached");
65
 
66
  RerrMsg emsg;
67
  if (!Virt()->Seek(pos, emsg)) throw Rexception(emsg);
68
  return;
69
}
70
 
71
//------------------------------------------+-----------------------------------
72
//! FIXME_docs
73
 
74
int Rw11UnitStream::Pos() const
75
{
76
  if (!Virt())
77
    throw Rexception("Rw11UnitStream::Pos", "no stream attached");
78
 
79
  RerrMsg emsg;
80
  int irc = Virt()->Tell(emsg);
81
  if (irc < 0) throw Rexception(emsg);
82
  return irc;
83
}
84
 
85
//------------------------------------------+-----------------------------------
86
//! FIXME_docs
87
 
88
int Rw11UnitStream::VirtRead(uint8_t* data, size_t count, RerrMsg& emsg)
89
{
90
  if (!Virt()) {
91
    fStats.Inc(kStatNPreAttMiss);
92
    emsg.Init("Rw11UnitStream::VirtRead", "no stream attached");
93
    return -1;
94
  }
95
  return Virt()->Read(data, count, emsg);
96
}
97
 
98
//------------------------------------------+-----------------------------------
99
//! FIXME_docs
100
 
101
bool Rw11UnitStream::VirtWrite(const uint8_t* data, size_t count, RerrMsg& emsg)
102
{
103
  if (!Virt()) {
104
    fStats.Inc(kStatNPreAttDrop, double(count));
105
    emsg.Init("Rw11UnitStream::VirtWrite", "no stream attached");
106
    return false;
107
  }
108
  return Virt()->Write(data, count, emsg);
109
}
110
 
111
//------------------------------------------+-----------------------------------
112
//! FIXME_docs
113
 
114
bool Rw11UnitStream::VirtFlush(RerrMsg& emsg)
115
{
116
  if (!Virt()) {
117
    emsg.Init("Rw11UnitStream::VirtFlush", "no stream attached");
118
    return false;
119
  }
120
  return Virt()->Flush(emsg);
121
}
122
 
123
//------------------------------------------+-----------------------------------
124
//! FIXME_docs
125
 
126
void Rw11UnitStream::Dump(std::ostream& os, int ind, const char* text) const
127
{
128
  RosFill bl(ind);
129
  os << bl << (text?text:"--") << "Rw11UnitStream @ " << this << endl;
130
  Rw11UnitVirt<Rw11VirtStream>::Dump(os, ind, " ^");
131
  return;
132
}
133
 
134
 
135
} // end namespace Retro

powered by: WebSVN 2.1.0

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