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

Revision 864, 3.3 kB (checked in by ppalmers, 16 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

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_BCD_H
25 #define BEBOB_DL_BCD_H
26
27 #include "fbtypes.h"
28
29 #include "debugmodule/debugmodule.h"
30
31 #include <string>
32 #include <cstdio>
33
34 namespace BeBoB {
35
36     class BCD {
37     public:
38         BCD( std::string filename );
39         ~BCD();
40
41         bool parse();
42
43         fb_octlet_t getSoftwareDate() const
44             { return m_softwareDate; }
45         fb_octlet_t getSoftwareTime() const
46             { return m_softwareTime; }
47         fb_quadlet_t getSoftwareId() const
48             { return m_softwareId; }
49         fb_quadlet_t getSoftwareVersion() const
50             { return m_softwareVersion; }
51     fb_quadlet_t getHardwareId() const
52         { return m_hardwareId; }
53     fb_quadlet_t getVendorOUI() const
54         { return m_vendorOUI; }
55
56         fb_quadlet_t getImageBaseAddress() const
57             { return m_imageBaseAddress; }
58         fb_quadlet_t getImageOffset() const
59             { return m_imageOffset; }
60         fb_quadlet_t getImageLength() const
61             { return m_imageLength; }
62         fb_quadlet_t getImageCRC() const
63             { return m_imageCRC; }
64
65     fb_quadlet_t getCnEOffset() const
66         { return m_cneOffset; }
67         fb_quadlet_t getCnELength() const
68             { return m_cneLength; }
69     fb_quadlet_t getCnECRC() const
70         { return m_cneCRC; }
71
72         bool read( int addr, fb_quadlet_t* q );
73         bool read( int addr, fb_octlet_t* o );
74     bool read( int addr, unsigned char* b, size_t len );
75
76     void displayInfo();
77
78     protected:
79         unsigned long crc32_table[256];
80     void initCRC32Table();
81     unsigned long reflect(unsigned long ref, char ch);
82     unsigned int getCRC(unsigned char* text, size_t len);
83         bool checkHeaderCRC( unsigned int crcOffset,
84                              unsigned int headerSize );
85         bool readHeaderInfo();
86     protected:
87         std::FILE* m_file;
88         std::string m_filename;
89         fb_quadlet_t m_bcd_version;
90
91         fb_octlet_t  m_softwareDate;
92         fb_octlet_t  m_softwareTime;
93         fb_quadlet_t m_softwareId;
94         fb_quadlet_t m_softwareVersion;
95     fb_quadlet_t m_hardwareId;
96     fb_quadlet_t m_vendorOUI;
97
98
99         fb_quadlet_t m_imageBaseAddress;
100         fb_quadlet_t m_imageLength;
101         fb_quadlet_t m_imageOffset;
102         fb_quadlet_t m_imageCRC;
103
104         fb_quadlet_t m_cneLength;
105     fb_quadlet_t m_cneOffset;
106     fb_quadlet_t m_cneCRC;
107
108
109
110     DECLARE_DEBUG_MODULE;
111     };
112
113     std::string makeString( fb_octlet_t v );
114     std::string makeDate( fb_octlet_t v );
115     std::string makeTime( fb_octlet_t v );
116 };
117
118 #endif
Note: See TracBrowser for help on using the browser.