[BeBoB/MAudio] Add PreSonus::FireboxDevice class to support functionality to switch...
[ffado.git] / libffado / src / bebob / bebob_dl_bcd.h
blob1b1f717dbcc2230142fce79b140ba84dccbb45f3
1 /*
2 * Copyright (C) 2005-2008 by Daniel Wagner
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
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.
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.
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/>.
24 #ifndef BEBOB_DL_BCD_H
25 #define BEBOB_DL_BCD_H
27 #include "fbtypes.h"
29 #include "debugmodule/debugmodule.h"
31 #include <string>
32 #include <cstdio>
34 namespace BeBoB {
36 class BCD {
37 public:
38 BCD( std::string filename );
39 ~BCD();
41 bool parse();
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; }
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; }
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; }
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 );
76 void displayInfo();
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;
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;
99 fb_quadlet_t m_imageBaseAddress;
100 fb_quadlet_t m_imageLength;
101 fb_quadlet_t m_imageOffset;
102 fb_quadlet_t m_imageCRC;
104 fb_quadlet_t m_cneLength;
105 fb_quadlet_t m_cneOffset;
106 fb_quadlet_t m_cneCRC;
110 DECLARE_DEBUG_MODULE;
113 std::string makeString( fb_octlet_t v );
114 std::string makeDate( fb_octlet_t v );
115 std::string makeTime( fb_octlet_t v );
118 #endif