root/trunk/libffado/src/fireworks/fireworks_firmware.h

Revision 689, 3.1 kB (checked in by ppalmers, 13 years ago)

more echo firmware work

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef FIREWORKS_FIRMWARE_H
25 #define FIREWORKS_FIRMWARE_H
26
27 #include "debugmodule/debugmodule.h"
28
29 #include "efc/efc_cmd.h"
30 #include "efc/efc_cmds_hardware.h"
31 #include "efc/efc_cmds_flash.h"
32
33 #include <string>
34
35 class ConfigRom;
36 class Ieee1394Service;
37
38 namespace FireWorks {
39
40 #define ECHO_FIRMWARE_MAGIC                     "1651 1 0 0 0"
41 #define ECHO_FIRMWARE_MAGIC_LENGTH_BYTES        14
42
43 // the number of quadlets in the file
44 #define ECHO_FIRMWARE_HEADER_LENGTH_QUADLETS    64
45 // note that the dat files are not binary files but have the quadlets
46 // as "0x0ABCDE12\n" lines
47 #define ECHO_FIRMWARE_HEADER_LENGTH_BYTES       ( 12 * ECHO_FIRMWARE_HEADER_LENGTH_QUADLETS )
48
49 #define ECHO_FIRMWARE_FILE_MAX_LENGTH_QUADLETS  ((384 * 1024) / 4)
50 #define ECHO_FIRMWARE_FILE_MAX_LENGTH_BYTES     (ECHO_FIRMWARE_FILE_MAX_LENGTH_QUADLETS * 12 + ECHO_FIRMWARE_HEADER_LENGTH_BYTES)
51
52 class Firmware
53 {
54 public:
55     enum eDatType {
56         eDT_DspCode         = 0,
57         eDT_IceLynxCode     = 1,
58         eDT_Data            = 2,
59         eDT_FPGACode        = 3,
60         eDT_DeviceName      = 4,
61         eDT_Invalid         = 0xFF,
62     };
63     static const char *eDatTypeToString(const enum eDatType target);
64     static const enum eDatType intToeDatType(int type);
65 public:
66     Firmware();
67     virtual ~Firmware();
68
69     virtual bool loadFile(std::string filename);
70
71     virtual void show();
72     virtual void setVerboseLevel(int l)
73         {setDebugLevel(l);};
74
75 protected:
76     // filename
77     std::string         m_filename;
78
79     // header data
80     enum eDatType       m_Type;
81     uint32_t            m_flash_offset_address;
82     uint32_t            m_length_quads;
83     uint32_t            m_CRC32;
84     uint32_t            m_checksum;
85     uint32_t            m_version;
86     bool                m_append_crc; // true to append
87     uint32_t            m_footprint_quads;
88
89     std::string         m_magic;
90     uint32_t            m_header[ECHO_FIRMWARE_HEADER_LENGTH_QUADLETS];
91     uint32_t            *m_data;
92
93 private:
94     DECLARE_DEBUG_MODULE;
95 };
96
97 class FirmwareUtil
98 {
99
100 public:
101     FirmwareUtil(FireWorks::Device& parent);
102     virtual ~FirmwareUtil();
103
104     virtual void show();
105     virtual void setVerboseLevel(int l)
106         {setDebugLevel(l);};
107
108 protected:
109     FireWorks::Device&          m_Parent;
110 private:
111     DECLARE_DEBUG_MODULE;
112 };
113
114 } // namespace FireWorks
115
116 #endif
Note: See TracBrowser for help on using the browser.