1 |
/* bebob_dl_mgr.h |
---|
2 |
* Copyright (C) 2006 by Daniel Wagner |
---|
3 |
* |
---|
4 |
* This file is part of FreeBoB. |
---|
5 |
* |
---|
6 |
* FreeBoB is free software; you can redistribute it and/or modify |
---|
7 |
* it under the terms of the GNU General Public License as published by |
---|
8 |
* the Free Software Foundation; either version 2 of the License, or |
---|
9 |
* (at your option) any later version. |
---|
10 |
* FreeBoB is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBoB; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
|
---|
21 |
#ifdef ENABLE_BEBOB |
---|
22 |
|
---|
23 |
#ifndef BEBOB_DL_MGR_H |
---|
24 |
#define BEBOB_DL_MGR_H |
---|
25 |
|
---|
26 |
#include "bebob_dl_codes.h" |
---|
27 |
|
---|
28 |
#include "fbtypes.h" |
---|
29 |
#include "threads.h" |
---|
30 |
|
---|
31 |
#include "debugmodule/debugmodule.h" |
---|
32 |
|
---|
33 |
#include <iostream> |
---|
34 |
|
---|
35 |
class Ieee1394Service; |
---|
36 |
class ConfigRom; |
---|
37 |
|
---|
38 |
namespace BeBoB { |
---|
39 |
class BCD; |
---|
40 |
|
---|
41 |
class BootloaderManager { |
---|
42 |
public: |
---|
43 |
BootloaderManager( Ieee1394Service& ieee1349service, |
---|
44 |
fb_nodeid_t nodeId ); |
---|
45 |
~BootloaderManager(); |
---|
46 |
|
---|
47 |
const ConfigRom* const getConfigRom() const |
---|
48 |
{ return m_configRom; } |
---|
49 |
|
---|
50 |
void printInfoRegisters(); |
---|
51 |
|
---|
52 |
bool downloadFirmware( std::string filename ); |
---|
53 |
bool downloadCnE( std::string filename ); |
---|
54 |
bool programGUID( octlet_t guid ); |
---|
55 |
|
---|
56 |
void busresetHandler(); |
---|
57 |
|
---|
58 |
Ieee1394Service* get1394Serivce() const |
---|
59 |
{ return m_ieee1394service; } |
---|
60 |
|
---|
61 |
bool setForceOperations( bool enabled ) |
---|
62 |
{ m_forceEnabled = enabled; return true; } |
---|
63 |
|
---|
64 |
bool setStartBootloader( bool bStartBootloader ) |
---|
65 |
{ m_bStartBootloader = bStartBootloader; return true; } |
---|
66 |
protected: |
---|
67 |
enum EObjectType { |
---|
68 |
eOT_Application, |
---|
69 |
eOT_CnE |
---|
70 |
}; |
---|
71 |
|
---|
72 |
void waitForBusReset(); |
---|
73 |
bool writeRequest( CommandCodes& cmd ); |
---|
74 |
bool readResponse( CommandCodes& writeRequestCmd ); |
---|
75 |
bool downloadObject( BCD& bcd, EObjectType eObject ); |
---|
76 |
|
---|
77 |
bool programGUIDCmd( octlet_t guid ); |
---|
78 |
bool startBootloaderCmd(); |
---|
79 |
bool startApplicationCmd(); |
---|
80 |
bool initializePersParamCmd(); |
---|
81 |
bool initializeConfigToFactorySettingCmd(); |
---|
82 |
bool checkDeviceCompatibility( BCD& bcd ); |
---|
83 |
|
---|
84 |
private: |
---|
85 |
bool cacheInfoRegisters(); |
---|
86 |
bool cacheInfoRegisters( int retries ); |
---|
87 |
|
---|
88 |
struct info_register_t { |
---|
89 |
fb_octlet_t m_manId; |
---|
90 |
fb_quadlet_t m_protocolVersion; |
---|
91 |
fb_quadlet_t m_bootloaderVersion; |
---|
92 |
fb_octlet_t m_guid; |
---|
93 |
fb_quadlet_t m_hardwareModelId; |
---|
94 |
fb_quadlet_t m_hardwareRevision; |
---|
95 |
fb_octlet_t m_softwareDate; |
---|
96 |
fb_octlet_t m_softwareTime; |
---|
97 |
fb_quadlet_t m_softwareId; |
---|
98 |
fb_quadlet_t m_softwareVersion; |
---|
99 |
fb_quadlet_t m_baseAddress; |
---|
100 |
fb_quadlet_t m_maxImageLen; |
---|
101 |
fb_octlet_t m_bootloaderDate; |
---|
102 |
fb_octlet_t m_bootloaderTime; |
---|
103 |
fb_octlet_t m_debuggerDate; |
---|
104 |
fb_octlet_t m_debuggerTime; |
---|
105 |
fb_quadlet_t m_debuggerId; |
---|
106 |
fb_quadlet_t m_debuggerVersion; |
---|
107 |
}; |
---|
108 |
|
---|
109 |
Ieee1394Service* m_ieee1394service; |
---|
110 |
ConfigRom* m_configRom; |
---|
111 |
|
---|
112 |
EBootloaderProtocolVersion m_protocolVersion; |
---|
113 |
bool m_isAppRunning; |
---|
114 |
info_register_t m_cachedInfoRegs; |
---|
115 |
|
---|
116 |
pthread_mutex_t m_mutex; |
---|
117 |
pthread_cond_t m_cond; |
---|
118 |
|
---|
119 |
Functor* m_functor; |
---|
120 |
|
---|
121 |
bool m_forceEnabled; |
---|
122 |
bool m_bStartBootloader; |
---|
123 |
|
---|
124 |
DECLARE_DEBUG_MODULE; |
---|
125 |
}; |
---|
126 |
} |
---|
127 |
|
---|
128 |
#endif |
---|
129 |
|
---|
130 |
#endif //#ifdef ENABLE_BEBOB |
---|