w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11UnitDisk.cpp
Go to the documentation of this file.
1// $Id: Rw11UnitDisk.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2018-12-19 1090 1.0.4 use RosPrintf(bool)
8// 2018-12-09 1080 1.0.3 use HasVirt(); Virt() returns ref
9// 2017-04-07 868 1.0.2 Dump(): add detail arg
10// 2015-03-21 659 1.0.1 add fEnabled, Enabled()
11// 2013-04-19 507 1.0 Initial version
12// 2013-02-19 490 0.1 First draft
13// ---------------------------------------------------------------------------
14
20#include "librtools/RosFill.hpp"
22
23#include "Rw11UnitDisk.hpp"
24
25using namespace std;
26
32// all method definitions in namespace Retro
33namespace Retro {
34
35//------------------------------------------+-----------------------------------
37
39 : Rw11UnitVirt<Rw11VirtDisk>(pcntl, index),
40 fType(),
41 fEnabled(false),
42 fNCyl(0),
43 fNHead(0),
44 fNSect(0),
45 fBlksize(0),
46 fNBlock(),
47 fWProt(false)
48{}
49
50//------------------------------------------+-----------------------------------
52
54{}
55
56//------------------------------------------+-----------------------------------
58
59void Rw11UnitDisk::SetType(const std::string& /*type*/)
60{
61 throw Rexception("Rw11UnitDisk::SetType",
62 string("Bad args: only type '") + fType + "' supported");
63}
64
65//------------------------------------------+-----------------------------------
67
68bool Rw11UnitDisk::VirtRead(size_t lba, size_t nblk, uint8_t* data,
69 RerrMsg& emsg)
70{
71 if (!HasVirt()) {
72 emsg.Init("Rw11UnitDisk::VirtRead", "no disk attached");
73 return false;
74 }
75 return Virt().Read(lba, nblk, data, emsg);
76}
77
78//------------------------------------------+-----------------------------------
80
81bool Rw11UnitDisk::VirtWrite(size_t lba, size_t nblk, const uint8_t* data,
82 RerrMsg& emsg)
83{
84 if (!HasVirt()) {
85 emsg.Init("Rw11UnitDisk::VirtWrite", "no disk attached");
86 return false;
87 }
88 return Virt().Write(lba, nblk, data, emsg);
89}
90
91//------------------------------------------+-----------------------------------
93
94void Rw11UnitDisk::Dump(std::ostream& os, int ind, const char* text,
95 int detail) const
96{
97 RosFill bl(ind);
98 os << bl << (text?text:"--") << "Rw11UnitDisk @ " << this << endl;
99 os << bl << " fType: " << fType << endl;
100 os << bl << " fEnabled: " << RosPrintf(fEnabled) << endl;
101 os << bl << " fNCyl: " << fNCyl << endl;
102 os << bl << " fNHead: " << fNHead << endl;
103 os << bl << " fNSect: " << fNSect << endl;
104 os << bl << " fBlksize: " << fBlksize << endl;
105 os << bl << " fNBlock: " << fNBlock << endl;
106 os << bl << " fWProt: " << RosPrintf(fWProt) << endl;
107
108 Rw11UnitVirt<Rw11VirtDisk>::Dump(os, ind, " ^", detail);
109 return;
110}
111
112
113} // end namespace Retro
FIXME_docs.
Definition: RerrMsg.hpp:25
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
Definition: RerrMsg.cpp:74
FIXME_docs.
Definition: Rexception.hpp:29
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24
FIXME_docs.
Definition: Rw11Cntl.hpp:42
size_t fBlksize
block size (in bytes)
bool fEnabled
unit enabled
std::string fType
drive type
bool VirtWrite(size_t lba, size_t nblk, const uint8_t *data, RerrMsg &emsg)
FIXME_docs.
virtual void SetType(const std::string &type)
FIXME_docs.
bool fWProt
unit write protected
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Rw11UnitDisk(Rw11Cntl *pcntl, size_t index)
Constructor.
bool VirtRead(size_t lba, size_t nblk, uint8_t *data, RerrMsg &emsg)
FIXME_docs.
~Rw11UnitDisk()
Destructor.
Implemenation (inline) of Rw11UnitVirt.
Rw11VirtDisk & Virt()
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool HasVirt() const
FIXME_docs.
virtual bool Read(size_t lba, size_t nblk, uint8_t *data, RerrMsg &emsg)=0
virtual bool Write(size_t lba, size_t nblk, const uint8_t *data, RerrMsg &emsg)=0
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Definition: RosPrintf.ipp:38
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47