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

Revision 445, 3.3 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Line 
1 /*
2  * Copyright (C) 2005-2007 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 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 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.