1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/**
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (C) 2014 Nuand LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HELPERS_VERSION_H_
#define HELPERS_VERSION_H_
#include <libbladeRF.h>
#define BLADERF_VERSION_STR_MAX 32
/**
* Test if two versions are equal. The "describe" field is not checked.
*
* @return true if equal, false otherwise
*/
bool version_equal(const struct bladerf_version *v1,
const struct bladerf_version *v2);
/**
* Check if version v1 is greater than or equal to version v2.
*
* @param[in] v1 First version
* @param[in] v2 Second version
*
* @return true for greater or equal than, false otherwise
*/
bool version_greater_or_equal(const struct bladerf_version *v1,
const struct bladerf_version *v2);
/**
* Check if version v1 is less than version v2.
*
* @param[in] v1 First version
* @param[in] v2 Second version
*
* @return true for less than, false otherwise
*/
bool version_less_than(const struct bladerf_version *v1,
const struct bladerf_version *v2);
/**
* Check if version in the provided structure is greater or equal to
* the version specified by the provided major, minor, and patch values
*
* @param[in] version Version structure to check
* @param[in] major Minor version
* @param[in] minor Minor version
* @param[in] patch Patch version
*
* @return true for greater or equal than, false otherwise
*/
bool version_fields_greater_or_equal(const struct bladerf_version *version,
unsigned int major,
unsigned int minor,
unsigned int patch);
/**
* Check if version in the provided structure is less than
* the version specied by the provided major, minor, and patch values
*
* @param[in] version Version structure to check
* @param[in] major Minor version
* @param[in] minor Minor version
* @param[in] patch Patch version
*
* @return true for less than, false otherwise
*/
bool version_fields_less_than(const struct bladerf_version *version,
unsigned int major,
unsigned int minor,
unsigned int patch);
/* Version compatibility table structure. */
struct version_compat_table {
const struct compat {
struct bladerf_version ver;
struct bladerf_version requires;
} * table;
unsigned int len;
};
/**
* Check if the firmware version is sufficient for the current libbladeRF
* version. If it's not, the user will need to use the bootloader to flash a
* newer version.
*
* @param[in] fw_compat_table Firmware-FPGA version compat. table
* @param[in] fw_version Firmware version
* @param[out] required_fw_version If not-NULL, populated with minimum
* required firmware version
*
* @return 0 if the FW version is sufficient for normal operation,
* BLADERF_ERR_UPDATE_FW if a firmware update is required.
*/
int version_check_fw(const struct version_compat_table *fw_compat_table,
const struct bladerf_version *fw_version,
struct bladerf_version *required_fw_version);
/**
* Check if the firmware and FPGA versions are sufficient and compatible.
*
* @param[in] fw_compat_table Firmware-FPGA version compat. table
* @param[in] fpga_compat_table FPGA-Firmware version compat. table
* @param[in] fw_version Firmware version
* @param[in] fpga_version Firmware version
* @param[out] required_fw_version If not-NULL, populated with minimum
* required firmware version
* @param[out] required_fpga_version If not-NULL, populated with minimum
* required FPGA version
*
* @return 0 if the FPGA version is sufficient for normal operation,
* BLADERF_ERR_UPDATE_FPGA if the firmware requires a newer FPGA,
* BLADERF_ERR_UPDATE_FW if a firmware update is required to support
* the currently loaded FPGA.
*/
int version_check(const struct version_compat_table *fw_compat_table,
const struct version_compat_table *fpga_compat_table,
const struct bladerf_version *fw_version,
const struct bladerf_version *fpga_version,
struct bladerf_version *required_fw_version,
struct bladerf_version *required_fpga_version);
#endif
|