w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkCommand.ipp
Go to the documentation of this file.
1// $Id: RlinkCommand.ipp 1185 2019-07-12 17:29:12Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2011-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-03-10 1121 1.4.2 add BlockDoneAll()
8// 2018-12-24 1092 1.4.1 rename IsBlockExt -> HasBlockExt
9// 2018-12-01 1076 1.4 use unique_ptr
10// 2015-04-02 661 1.3 expect logic: add stat check, Print() without cntx
11// 2014-11-02 600 1.2 new rlink v4 iface
12// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<()
13// 2011-03-27 374 1.0 Initial version
14// 2011-01-15 355 0.1 First draft
15// ---------------------------------------------------------------------------
16
21// all method definitions in namespace Retro
22namespace Retro {
23
24//------------------------------------------+-----------------------------------
26
27inline void RlinkCommand::CmdRreg(uint16_t addr)
28{
29 SetCommand(kCmdRreg, addr);
30 return;
31}
32
33//------------------------------------------+-----------------------------------
35
36inline void RlinkCommand::CmdWreg(uint16_t addr, uint16_t data)
37{
38 SetCommand(kCmdWreg, addr, data);
39 return;
40}
41
42//------------------------------------------+-----------------------------------
44
46{
48 return;
49}
50
51//------------------------------------------+-----------------------------------
53
55{
57 return;
58}
59
60//------------------------------------------+-----------------------------------
62
63inline void RlinkCommand::CmdInit(uint16_t addr, uint16_t data)
64{
65 SetCommand(kCmdInit, addr, data);
66 return;
67}
68
69//------------------------------------------+-----------------------------------
71
72inline void RlinkCommand::SetSeqNumber(uint8_t snum)
73{
74 fRequest = (snum<<3) | (fRequest&0x07);
75 return;
76}
77
78//------------------------------------------+-----------------------------------
80
81inline void RlinkCommand::SetData(uint16_t data)
82{
83 fData = data;
84 return;
85}
86
87//------------------------------------------+-----------------------------------
89
90inline void RlinkCommand::SetBlockDone(uint16_t dcnt)
91{
92 fBlockDone = dcnt;
93 return;
94}
95
96//------------------------------------------+-----------------------------------
98
99inline void RlinkCommand::SetStatus(uint8_t stat)
100{
101 fStatus = stat;
102 return;
103}
104
105//------------------------------------------+-----------------------------------
107
108inline void RlinkCommand::SetFlagBit(uint32_t mask)
109{
110 fFlags |= mask;
111 return;
112}
113
114//------------------------------------------+-----------------------------------
116
117inline void RlinkCommand::ClearFlagBit(uint32_t mask)
118{
119 fFlags &= ~mask;
120 return;
121}
122
123//------------------------------------------+-----------------------------------
125
126inline void RlinkCommand::SetRcvSize(size_t rsize)
127{
128 fRcvSize = rsize;
129 return;
130}
131
132//------------------------------------------+-----------------------------------
134
136{
137 if (!fupExpect) fupExpect.reset(new RlinkCommandExpect());
138 return *fupExpect;
139}
140
141//------------------------------------------+-----------------------------------
143
144inline void RlinkCommand::SetExpectStatus(uint8_t stat, uint8_t statmsk)
145{
146 fExpectStatusSet = true;
147 fExpectStatusVal = stat;
148 fExpectStatusMsk = statmsk;
149 return;
150}
151
152//------------------------------------------+-----------------------------------
154
155inline void RlinkCommand::SetExpectStatusDefault(uint8_t stat, uint8_t statmsk)
156{
157 fExpectStatusSet = false;
158 fExpectStatusVal = stat;
159 fExpectStatusMsk = statmsk;
160 return;
161}
162
163//------------------------------------------+-----------------------------------
165
166inline uint8_t RlinkCommand::Request() const
167{
168 return fRequest;
169}
170
171//------------------------------------------+-----------------------------------
173
174inline uint8_t RlinkCommand::Command() const
175{
176 return fRequest & 0x07;
177}
178
179//------------------------------------------+-----------------------------------
181
182inline uint8_t RlinkCommand::SeqNumber() const
183{
184 return fRequest>>3;
185}
186
187//------------------------------------------+-----------------------------------
189
190inline uint16_t RlinkCommand::Address() const
191{
192 return fAddress;
193}
194
195//------------------------------------------+-----------------------------------
197
198inline uint16_t RlinkCommand::Data() const
199{
200 return fData;
201}
202
203//------------------------------------------+-----------------------------------
205
206inline const std::vector<uint16_t>& RlinkCommand::Block() const
207{
208 return fBlock;
209}
210
211//------------------------------------------+-----------------------------------
213
214inline bool RlinkCommand::HasBlockExt() const
215{
216 return bool(fpBlockExt);
217}
218
219//------------------------------------------+-----------------------------------
221
223{
224 return HasBlockExt() ? fpBlockExt : (fBlock.size() ? &fBlock[0] : nullptr);
225}
226
227//------------------------------------------+-----------------------------------
229
230inline const uint16_t* RlinkCommand::BlockPointer() const
231{
232 return HasBlockExt() ? fpBlockExt : (fBlock.size() ? &fBlock[0] : nullptr);
233}
234
235//------------------------------------------+-----------------------------------
237
238inline size_t RlinkCommand::BlockSize() const
239{
240 return HasBlockExt() ? fBlockExtSize : fBlock.size();
241}
242
243//------------------------------------------+-----------------------------------
245
246inline size_t RlinkCommand::BlockDone() const
247{
248 return fBlockDone;
249}
250
251//------------------------------------------+-----------------------------------
253
254inline bool RlinkCommand::BlockDoneAll() const
255{
256 return BlockDone() == BlockSize();
257}
258
259//------------------------------------------+-----------------------------------
261
262inline uint8_t RlinkCommand::Status() const
263{
264 return fStatus;
265}
266
267//------------------------------------------+-----------------------------------
269
270inline uint32_t RlinkCommand::Flags() const
271{
272 return fFlags;
273}
274
275//------------------------------------------+-----------------------------------
277
278inline bool RlinkCommand::TestFlagAny(uint32_t mask) const
279{
280 return (fFlags & mask) != 0;
281}
282
283//------------------------------------------+-----------------------------------
285
286inline bool RlinkCommand::TestFlagAll(uint32_t mask) const
287{
288 return (fFlags & mask) == fFlags;
289}
290
291//------------------------------------------+-----------------------------------
293
294inline size_t RlinkCommand::RcvSize() const
295{
296 return fRcvSize;
297}
298
299//------------------------------------------+-----------------------------------
301
302inline bool RlinkCommand::HasExpect() const
303{
304 return bool(fupExpect);
305}
306
307//------------------------------------------+-----------------------------------
309
311{
312 return *fupExpect;
313}
314
315//------------------------------------------+-----------------------------------
317
319{
320 return fExpectStatusVal;
321}
322
323//------------------------------------------+-----------------------------------
325
326inline uint8_t RlinkCommand::ExpectStatusMask() const
327{
328 return fExpectStatusMsk;
329}
330
331//------------------------------------------+-----------------------------------
333
335{
336 return fExpectStatusSet;
337}
338
339//------------------------------------------+-----------------------------------
341
342inline bool RlinkCommand::StatusCheck() const
343{
345}
346
347//------------------------------------------+-----------------------------------
349
351{
352 return fExpectStatusMsk != 0x0;
353}
354
355} // end namespace Retro
356
void SetStatus(uint8_t stat)
FIXME_docs.
void SetCommand(uint8_t cmd, uint16_t addr=0, uint16_t data=0)
FIXME_docs.
static const uint8_t kCmdInit
command code send initialize
uint8_t fExpectStatusVal
status value
void SetFlagBit(uint32_t mask)
FIXME_docs.
uint16_t Data() const
FIXME_docs.
void SetRcvSize(size_t rsize)
FIXME_docs.
uint8_t Request() const
FIXME_docs.
uint8_t fExpectStatusMsk
status mask
bool BlockDoneAll() const
FIXME_docs.
void SetExpectStatusDefault(uint8_t stat=0, uint8_t statmsk=0x0)
FIXME_docs.
uint8_t fStatus
rlink command status
size_t fBlockDone
valid transfer count
uint16_t Address() const
FIXME_docs.
uint8_t ExpectStatusMask() const
FIXME_docs.
size_t RcvSize() const
FIXME_docs.
bool TestFlagAny(uint32_t mask) const
FIXME_docs.
void CmdRreg(uint16_t addr)
FIXME_docs.
uint8_t SeqNumber() const
FIXME_docs.
void CmdAttn()
FIXME_docs.
uint8_t Status() const
FIXME_docs.
size_t fBlockExtSize
transfer size if data external
void CmdWreg(uint16_t addr, uint16_t data)
FIXME_docs.
const std::vector< uint16_t > & Block() const
FIXME_docs.
bool ExpectStatusSet() const
FIXME_docs.
uint8_t fRequest
rlink request (cmd+seqnum)
bool StatusIsChecked() const
FIXME_docs.
bool fExpectStatusSet
stat chk set explicitely
bool StatusCheck() const
FIXME_docs.
uint8_t ExpectStatusValue() const
FIXME_docs.
bool TestFlagAll(uint32_t mask) const
FIXME_docs.
uint16_t fAddress
rbus address
void CmdLabo()
FIXME_docs.
void SetData(uint16_t data)
FIXME_docs.
uint8_t Command() const
FIXME_docs.
uint16_t * fpBlockExt
external data for blk commands
size_t BlockSize() const
FIXME_docs.
static const uint8_t kCmdRreg
command code read register
std::vector< uint16_t > fBlock
data vector for blk commands
uint32_t Flags() const
FIXME_docs.
static const uint8_t kCmdWreg
command code write register
void SetSeqNumber(uint8_t snum)
FIXME_docs.
bool HasBlockExt() const
FIXME_docs.
size_t BlockDone() const
FIXME_docs.
void SetExpectStatus(uint8_t stat, uint8_t statmsk=0xff)
FIXME_docs.
bool HasExpect() const
FIXME_docs.
exp_uptr_t fupExpect
pointer to expect container
void SetBlockDone(uint16_t dcnt)
FIXME_docs.
size_t fRcvSize
receive size for command
void CmdInit(uint16_t addr, uint16_t data)
FIXME_docs.
static const uint8_t kCmdAttn
command code get attention
static const uint8_t kCmdLabo
command code list abort
const RlinkCommandExpect & Expect() const
FIXME_docs.
uint16_t * BlockPointer()
FIXME_docs.
RlinkCommandExpect & EnsureExpect()
FIXME_docs.
void ClearFlagBit(uint32_t mask)
FIXME_docs.
uint32_t fFlags
state bits
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47