root/trunk/libffado/src/bebob/bebob_dl_codes.h

Revision 742, 9.7 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23 #ifndef BEBOB_DL_CODES_H
24 #define BEBOB_DL_CODES_H
25
26 #include "fbtypes.h"
27
28 #include "libutil/cmd_serialize.h"
29
30 namespace BeBoB {
31     enum EBootloaderProtocolVersion {
32         eBPV_Unknown = 0,
33         eBPV_V1 = 1,
34         eBPV_V2 = 2,
35         eBPV_V3 = 3,
36     };
37
38     enum EBootloaderCommandCodes {
39         eCmdC_Halt                       = 0x01,
40         eCmdC_Reset                      = 0x02,
41         eCmdC_ReadImageCRC               = 0x03,
42         eCmdC_DownloadStart              = 0x04,
43         eCmdC_DownloadBlock              = 0x05,
44         eCmdC_DownloadEnd                = 0x06,
45         eCmdC_SwitchTo1394Shell          = 0x07,
46         eCmdC_ReadShellChars             = 0x08,
47         eCmdC_WriteShellChars            = 0x09,
48         eCmdC_ProgramGUID                = 0x0a,
49         eCmdC_ProgramMAC                 = 0x0b,
50         eCmdC_InitPersParams             = 0x0c,
51         eCmdC_InitConfigToFactorySetting = 0x0d,
52         eCmdC_SetDebugGUID               = 0x0f,
53         eCmdC_ProgramHWIdVersion         = 0x10,
54         eCmdC_Go                         = 0x11,
55     };
56
57     /////////////////////////
58
59     class CommandCodes {
60     public:
61         CommandCodes( fb_quadlet_t protocolVersion,
62                       fb_byte_t commandCode,
63                       size_t    msgSize,
64                       fb_byte_t operandSizeRequestField,
65                       fb_byte_t operandSizeResponseField );
66     virtual ~CommandCodes();
67
68         virtual bool serialize( Util::IOSSerialize& se );
69         virtual bool deserialize( Util::IISDeserialize& de );
70
71         virtual size_t getMaxSize();
72
73         EBootloaderCommandCodes getCommandCode() const
74             { return static_cast<EBootloaderCommandCodes>( m_commandCode ); }
75
76     fb_byte_t getProtocolVersion() const
77         { return m_protocolVersion; }
78         size_t getMsgSize() const
79             { return m_msgSize; }
80         fb_byte_t getOperandSizeRequest() const
81             { return m_operandSizeRequest; }
82         fb_byte_t getOperandSizeResponse() const
83             { return m_operandSizeResponse; }
84         unsigned short getCommandId() const
85             { return m_commandId; }
86
87         fb_quadlet_t getRespProtocolVersion() const
88             { return m_resp_protocolVersion; }
89         unsigned short getRespCommandId() const
90             { return m_resp_commandId; }
91         fb_byte_t getRespCommandCode() const
92             { return m_resp_commandCode; }
93         fb_byte_t getRespOperandSize() const
94             { return m_resp_operandSize; }
95         fb_byte_t getRespSizeInQuadlets() const
96             { return 2 + m_operandSizeResponse; }
97
98     protected:
99         static unsigned short m_gCommandId;
100         unsigned short m_commandId;
101         fb_quadlet_t m_protocolVersion;
102         fb_byte_t m_commandCode;
103         size_t    m_msgSize;
104         fb_byte_t m_operandSizeRequest;
105         fb_byte_t m_operandSizeResponse;
106
107         fb_quadlet_t   m_resp_protocolVersion;
108         unsigned short m_resp_commandId;
109         fb_byte_t      m_resp_commandCode;
110         fb_byte_t      m_resp_operandSize;
111     };
112
113     /////////////////////////
114
115     class CommandCodesReset : public CommandCodes {
116     public:
117         enum EStartMode {
118             eSM_Application = 0,
119             eSM_Bootloader,
120             eSM_Debugger,
121         };
122
123         CommandCodesReset( fb_quadlet_t protocolVersion, EStartMode startMode );
124         virtual ~CommandCodesReset();
125
126         virtual bool serialize( Util::IOSSerialize& se );
127         virtual bool deserialize( Util::IISDeserialize& de );
128
129         EStartMode getStartMode() const
130             { return static_cast<EStartMode>( m_startMode ); }
131         bool setStartMode( EStartMode startMode )
132             { m_startMode = startMode; return true; }
133
134     private:
135         fb_byte_t m_startMode;
136     };
137
138     /////////////////////////
139
140     class CommandCodesProgramGUID : public CommandCodes {
141     public:
142         CommandCodesProgramGUID( fb_quadlet_t protocolVersion,
143                            fb_octlet_t guid );
144         virtual ~CommandCodesProgramGUID();
145
146         virtual bool serialize( Util::IOSSerialize& se );
147         virtual bool deserialize( Util::IISDeserialize& de );
148
149         fb_octlet_t getGUID() const
150             { return m_guid; }
151         bool setGUID( fb_octlet_t guid )
152             { m_guid = guid; return true; }
153
154     private:
155         fb_octlet_t m_guid;
156     };
157
158
159     /////////////////////////
160
161     class CommandCodesDownloadStart : public CommandCodes {
162     public:
163         enum EObject {
164             eO_Application    = 0,
165         eO_Config         = 1,
166         eO_Debugger       = 2,
167             eO_Bootloader     = 3,
168         eO_WarpImage      = 4,
169         eO_SerialBootCode = 5,
170         };
171
172         CommandCodesDownloadStart( fb_quadlet_t protocolVersion,
173                      EObject object );
174         virtual ~CommandCodesDownloadStart();
175
176         virtual bool serialize( Util::IOSSerialize& se );
177         virtual bool deserialize( Util::IISDeserialize& de );
178
179         bool setDate( fb_octlet_t date )
180             { m_date = date; return true; }
181         bool setTime( fb_octlet_t time )
182             { m_time = time; return true; }
183         bool setId( fb_quadlet_t id )
184             { m_id = id; return true; }
185         bool setVersion( fb_quadlet_t version )
186             { m_version = version; return true; }
187         bool setBaseAddress( fb_quadlet_t address )
188             { m_address = address; return true; }
189         bool setLength( fb_quadlet_t length )
190             { m_length = length; return true; }
191         bool setCRC( fb_quadlet_t crc )
192             { m_crc = crc; return true; }
193
194         int getMaxBlockSize() const
195             { return m_resp_max_block_size; }
196
197     private:
198         fb_quadlet_t m_object;
199         fb_octlet_t  m_date;
200         fb_octlet_t  m_time;
201         fb_quadlet_t m_id;
202         fb_quadlet_t m_version;
203         fb_quadlet_t m_address;
204         fb_quadlet_t m_length;
205         fb_quadlet_t m_crc;
206
207         int m_resp_max_block_size;
208     };
209
210     /////////////////////////
211
212     class CommandCodesDownloadBlock : public CommandCodes {
213     public:
214         CommandCodesDownloadBlock( fb_quadlet_t protocolVersion );
215         virtual ~CommandCodesDownloadBlock();
216
217         virtual bool serialize( Util::IOSSerialize& se );
218         virtual bool deserialize( Util::IISDeserialize& de );
219
220     bool setSeqNumber( fb_quadlet_t seqNumber )
221         { m_seqNumber = seqNumber; return true; }
222     bool setAddress( fb_quadlet_t address )
223             { m_address = address; return true; }
224         bool setNumberBytes( fb_quadlet_t numByte )
225             { m_numBytes = numByte; return true; }
226         fb_quadlet_t getRespSeqNumber() const
227             { return m_resp_seqNumber; }
228         fb_quadlet_t getRespErrorCode() const
229             { return m_resp_errorCode; }
230     private:
231         fb_quadlet_t m_seqNumber;
232         fb_quadlet_t m_address;
233         fb_quadlet_t m_numBytes;
234
235     fb_quadlet_t m_resp_seqNumber;
236     fb_quadlet_t m_resp_errorCode;
237     };
238
239     /////////////////////////
240
241     class CommandCodesDownloadEnd : public CommandCodes {
242     public:
243         CommandCodesDownloadEnd( fb_quadlet_t protocolVersion );
244         virtual ~CommandCodesDownloadEnd();
245
246         virtual bool serialize( Util::IOSSerialize& se );
247         virtual bool deserialize( Util::IISDeserialize& de );
248
249         fb_quadlet_t getRespCrc32() const
250             { return m_resp_crc32; }
251         bool getRespIsValid() const
252             { return m_resp_valid == 0; }
253
254     private:
255         quadlet_t m_resp_crc32;
256         quadlet_t m_resp_valid;
257     };
258
259
260     /////////////////////////
261
262     class CommandCodesInitializePersParam : public CommandCodes {
263     public:
264         CommandCodesInitializePersParam( fb_quadlet_t protocolVersion );
265         virtual ~CommandCodesInitializePersParam();
266
267         virtual bool serialize( Util::IOSSerialize& se );
268         virtual bool deserialize( Util::IISDeserialize& de );
269     };
270
271     /////////////////////////
272
273     class CommandCodesInitializeConfigToFactorySetting : public CommandCodes {
274     public:
275         CommandCodesInitializeConfigToFactorySetting(
276             fb_quadlet_t protocolVersion );
277         virtual ~CommandCodesInitializeConfigToFactorySetting();
278
279         virtual bool serialize( Util::IOSSerialize& se );
280         virtual bool deserialize( Util::IISDeserialize& de );
281     };
282
283     /////////////////////////
284
285     class CommandCodesGo : public CommandCodes {
286     public:
287         enum EStartMode {
288             eSM_Application = 0,
289         eSM_Debugger = 2,
290         };
291
292         CommandCodesGo( fb_quadlet_t protocolVersion, EStartMode startMode );
293         virtual ~CommandCodesGo();
294
295         virtual bool serialize( Util::IOSSerialize& se );
296         virtual bool deserialize( Util::IISDeserialize& de );
297
298         EStartMode getStartMode() const
299             { return static_cast<EStartMode>( m_startMode ); }
300         bool setStartMode( EStartMode startMode )
301             { m_startMode = startMode; return true; }
302
303         fb_quadlet_t getRespIsValidCRC() const
304             { return m_resp_validCRC; }
305
306     private:
307         fb_quadlet_t m_startMode;
308     fb_quadlet_t m_resp_validCRC;
309     };
310
311
312
313 };
314 #endif
Note: See TracBrowser for help on using the browser.