1 |
27 |
wfjm |
// $Id: RlinkCommand.hpp 609 2014-12-07 19:35:25Z mueller $
|
2 |
10 |
wfjm |
//
|
3 |
27 |
wfjm |
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
10 |
wfjm |
//
|
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 |
27 |
wfjm |
// 2014-12-06 609 1.2 new rlink v4 iface
|
17 |
19 |
wfjm |
// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<()
|
18 |
10 |
wfjm |
// 2011-03-27 374 1.0 Initial version
|
19 |
|
|
// 2011-01-09 354 0.1 First draft
|
20 |
|
|
// ---------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/*!
|
24 |
|
|
\file
|
25 |
27 |
wfjm |
\version $Id: RlinkCommand.hpp 609 2014-12-07 19:35:25Z mueller $
|
26 |
10 |
wfjm |
\brief Declaration of class RlinkCommand.
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
#ifndef included_Retro_RlinkCommand
|
30 |
|
|
#define included_Retro_RlinkCommand 1
|
31 |
|
|
|
32 |
|
|
#include <cstddef>
|
33 |
|
|
#include <cstdint>
|
34 |
|
|
#include <vector>
|
35 |
|
|
#include <ostream>
|
36 |
|
|
|
37 |
|
|
#include "librtools/Rtools.hpp"
|
38 |
|
|
|
39 |
19 |
wfjm |
#include "RlinkContext.hpp"
|
40 |
|
|
#include "RlinkAddrMap.hpp"
|
41 |
|
|
#include "RlinkCommandExpect.hpp"
|
42 |
|
|
|
43 |
|
|
#include "librtools/Rbits.hpp"
|
44 |
|
|
|
45 |
10 |
wfjm |
namespace Retro {
|
46 |
|
|
|
47 |
19 |
wfjm |
class RlinkCommand : public Rbits {
|
48 |
10 |
wfjm |
public:
|
49 |
|
|
RlinkCommand();
|
50 |
|
|
RlinkCommand(const RlinkCommand& rhs);
|
51 |
27 |
wfjm |
~RlinkCommand();
|
52 |
10 |
wfjm |
|
53 |
|
|
void CmdRreg(uint16_t addr);
|
54 |
|
|
void CmdRblk(uint16_t addr, size_t size);
|
55 |
|
|
void CmdRblk(uint16_t addr, uint16_t* pblock, size_t size);
|
56 |
|
|
void CmdWreg(uint16_t addr, uint16_t data);
|
57 |
|
|
void CmdWblk(uint16_t addr, const std::vector<uint16_t>& block);
|
58 |
|
|
void CmdWblk(uint16_t addr, const uint16_t* pblock, size_t size);
|
59 |
27 |
wfjm |
void CmdLabo();
|
60 |
10 |
wfjm |
void CmdAttn();
|
61 |
|
|
void CmdInit(uint16_t addr, uint16_t data);
|
62 |
|
|
|
63 |
|
|
void SetCommand(uint8_t cmd, uint16_t addr=0, uint16_t data=0);
|
64 |
|
|
void SetSeqNumber(uint8_t snum);
|
65 |
|
|
void SetAddress(uint16_t addr);
|
66 |
|
|
void SetData(uint16_t data);
|
67 |
|
|
void SetBlockWrite(const std::vector<uint16_t>& block);
|
68 |
|
|
void SetBlockRead(size_t size) ;
|
69 |
|
|
void SetBlockExt(uint16_t* pblock, size_t size);
|
70 |
27 |
wfjm |
void SetBlockDone(uint16_t dcnt);
|
71 |
10 |
wfjm |
void SetStatus(uint8_t stat);
|
72 |
|
|
void SetFlagBit(uint32_t mask);
|
73 |
|
|
void ClearFlagBit(uint32_t mask);
|
74 |
|
|
void SetRcvSize(size_t rsize);
|
75 |
|
|
void SetExpect(RlinkCommandExpect* pexp);
|
76 |
|
|
|
77 |
|
|
uint8_t Request() const;
|
78 |
|
|
uint8_t Command() const;
|
79 |
|
|
uint8_t SeqNumber() const;
|
80 |
|
|
uint16_t Address() const;
|
81 |
|
|
uint16_t Data() const;
|
82 |
|
|
const std::vector<uint16_t>& Block() const;
|
83 |
|
|
bool IsBlockExt() const;
|
84 |
|
|
uint16_t* BlockPointer();
|
85 |
|
|
const uint16_t* BlockPointer() const;
|
86 |
|
|
size_t BlockSize() const;
|
87 |
27 |
wfjm |
size_t BlockDone() const;
|
88 |
10 |
wfjm |
uint8_t Status() const;
|
89 |
|
|
uint32_t Flags() const;
|
90 |
|
|
bool TestFlagAny(uint32_t mask) const;
|
91 |
|
|
bool TestFlagAll(uint32_t mask) const;
|
92 |
|
|
size_t RcvSize() const;
|
93 |
|
|
RlinkCommandExpect* Expect() const;
|
94 |
|
|
|
95 |
19 |
wfjm |
void Print(std::ostream& os, const RlinkContext& cntx,
|
96 |
|
|
const RlinkAddrMap* pamap=0, size_t abase=16,
|
97 |
|
|
size_t dbase=16, size_t sbase=16) const;
|
98 |
10 |
wfjm |
void Dump(std::ostream& os, int ind=0, const char* text=0) const;
|
99 |
|
|
|
100 |
|
|
static const char* CommandName(uint8_t cmd);
|
101 |
|
|
static const RflagName* FlagNames();
|
102 |
|
|
|
103 |
|
|
RlinkCommand& operator=(const RlinkCommand& rhs);
|
104 |
|
|
|
105 |
19 |
wfjm |
// some constants (also defined in cpp)
|
106 |
10 |
wfjm |
static const uint8_t kCmdRreg = 0; //!< command code read register
|
107 |
|
|
static const uint8_t kCmdRblk = 1; //!< command code read block
|
108 |
|
|
static const uint8_t kCmdWreg = 2; //!< command code write register
|
109 |
|
|
static const uint8_t kCmdWblk = 3; //!< command code write block
|
110 |
27 |
wfjm |
static const uint8_t kCmdLabo = 4; //!< command code list abort
|
111 |
10 |
wfjm |
static const uint8_t kCmdAttn = 5; //!< command code get attention
|
112 |
|
|
static const uint8_t kCmdInit = 6; //!< command code send initialize
|
113 |
|
|
|
114 |
|
|
static const uint32_t kFlagInit = 1u<<0; //!< cmd,addr,data setup
|
115 |
|
|
static const uint32_t kFlagSend = 1u<<1; //!< command send
|
116 |
|
|
static const uint32_t kFlagDone = 1u<<2; //!< command done
|
117 |
27 |
wfjm |
static const uint32_t kFlagLabo = 1u<<3; //!< command labo'ed
|
118 |
10 |
wfjm |
|
119 |
|
|
static const uint32_t kFlagPktBeg = 1u<<4; //!< command first in packet
|
120 |
|
|
static const uint32_t kFlagPktEnd = 1u<<5; //!< command last in packet
|
121 |
|
|
|
122 |
|
|
static const uint32_t kFlagErrNak = 1u<<8; //!< error: nak abort
|
123 |
27 |
wfjm |
static const uint32_t kFlagErrDec = 1u<<9; //!< error: decode error
|
124 |
10 |
wfjm |
|
125 |
|
|
static const uint32_t kFlagChkStat= 1u<<12; //!< stat expect check failed
|
126 |
|
|
static const uint32_t kFlagChkData= 1u<<13; //!< data expect check failed
|
127 |
|
|
|
128 |
27 |
wfjm |
static const uint8_t kStat_M_Stat = 0xf0; //!< stat: external stat bits
|
129 |
|
|
static const uint8_t kStat_V_Stat = 4;
|
130 |
|
|
static const uint8_t kStat_B_Stat = 0x0f;
|
131 |
|
|
static const uint8_t kStat_M_Attn = kBBit03;//!< stat: attn flags set
|
132 |
19 |
wfjm |
static const uint8_t kStat_M_RbNak = kBBit01;//!< stat: attn flags set
|
133 |
|
|
static const uint8_t kStat_M_RbErr = kBBit00;//!< stat: attn flags set
|
134 |
|
|
|
135 |
10 |
wfjm |
protected:
|
136 |
|
|
void SetCmdSimple(uint8_t cmd, uint16_t addr, uint16_t data);
|
137 |
|
|
|
138 |
|
|
protected:
|
139 |
|
|
uint8_t fRequest; //!< rlink request (cmd+seqnum)
|
140 |
|
|
uint16_t fAddress; //!< rbus address
|
141 |
|
|
uint16_t fData; //!< data
|
142 |
|
|
std::vector<uint16_t> fBlock; //!< data vector for blk commands
|
143 |
|
|
uint16_t* fpBlockExt; //!< external data for blk commands
|
144 |
|
|
size_t fBlockExtSize; //!< transfer size if data external
|
145 |
27 |
wfjm |
size_t fBlockDone; //!< valid transfer count
|
146 |
10 |
wfjm |
uint8_t fStatus; //!< rlink command status
|
147 |
|
|
uint32_t fFlags; //!< state bits
|
148 |
|
|
size_t fRcvSize; //!< receive size for command
|
149 |
|
|
RlinkCommandExpect* fpExpect; //!< pointer to expect container
|
150 |
|
|
};
|
151 |
|
|
|
152 |
|
|
} // end namespace Retro
|
153 |
|
|
|
154 |
|
|
#include "RlinkCommand.ipp"
|
155 |
|
|
|
156 |
|
|
#endif
|