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

Revision 932, 3.8 kB (checked in by ppalmers, 15 years ago)

- implement bus reset handling for the CTR DLL
- move the functor header to libutil

Line 
1 /*
2  * Copyright (C) 2005-2008 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 2 of the License, or
12  * (at your option) version 3 of the License.
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
24 #ifndef BEBOB_DL_MGR_H
25 #define BEBOB_DL_MGR_H
26
27 #include "bebob_dl_codes.h"
28
29 #include "fbtypes.h"
30 #include "libutil/Functors.h"
31
32 #include "debugmodule/debugmodule.h"
33
34 #include <iostream>
35
36 class Ieee1394Service;
37 class ConfigRom;
38
39 using namespace Util;
40
41 namespace BeBoB {
42     class BCD;
43
44     class BootloaderManager {
45     public:
46         BootloaderManager( Ieee1394Service& ieee1349service,
47                            fb_nodeid_t nodeId );
48         ~BootloaderManager();
49
50         const ConfigRom* const getConfigRom() const
51             { return m_configRom; }
52
53         void printInfoRegisters();
54
55         bool downloadFirmware( std::string filename );
56         bool downloadCnE( std::string filename );
57         bool programGUID( octlet_t guid );
58
59         void busresetHandler();
60
61         Ieee1394Service* get1394Serivce() const
62                 { return m_ieee1394service; }
63
64         bool setForceOperations( bool enabled )
65                 { m_forceEnabled = enabled; return true; }
66
67         bool setStartBootloader( bool bStartBootloader )
68             { m_bStartBootloader = bStartBootloader; return true; }
69         protected:
70         enum EObjectType {
71             eOT_Application,
72             eOT_CnE
73         };
74
75         void waitForBusReset();
76         bool writeRequest( CommandCodes& cmd );
77         bool readResponse( CommandCodes& writeRequestCmd );
78         bool downloadObject( BCD& bcd, EObjectType eObject );
79
80         bool programGUIDCmd( octlet_t guid );
81         bool startBootloaderCmd();
82         bool startApplicationCmd();
83         bool initializePersParamCmd();
84         bool initializeConfigToFactorySettingCmd();
85         bool checkDeviceCompatibility( BCD& bcd );
86
87     private:
88         bool cacheInfoRegisters();
89         bool cacheInfoRegisters( int retries );
90
91         struct info_register_t {
92             fb_octlet_t  m_manId;
93             fb_quadlet_t m_protocolVersion;
94             fb_quadlet_t m_bootloaderVersion;
95             fb_octlet_t  m_guid;
96             fb_quadlet_t m_hardwareModelId;
97             fb_quadlet_t m_hardwareRevision;
98             fb_octlet_t  m_softwareDate;
99             fb_octlet_t  m_softwareTime;
100             fb_quadlet_t m_softwareId;
101             fb_quadlet_t m_softwareVersion;
102             fb_quadlet_t m_baseAddress;
103             fb_quadlet_t m_maxImageLen;
104             fb_octlet_t  m_bootloaderDate;
105             fb_octlet_t  m_bootloaderTime;
106             fb_octlet_t  m_debuggerDate;
107             fb_octlet_t  m_debuggerTime;
108             fb_quadlet_t m_debuggerId;
109             fb_quadlet_t m_debuggerVersion;
110         };
111
112         Ieee1394Service*   m_ieee1394service;
113         ConfigRom*         m_configRom;
114
115         EBootloaderProtocolVersion m_protocolVersion;
116         bool               m_isAppRunning;
117         info_register_t    m_cachedInfoRegs;
118
119         pthread_mutex_t m_mutex;
120         pthread_cond_t  m_cond;
121
122         Functor*        m_functor;
123
124             bool            m_forceEnabled;
125         bool            m_bStartBootloader;
126
127         DECLARE_DEBUG_MODULE;
128     };
129 }
130
131 #endif
Note: See TracBrowser for help on using the browser.