mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 12:38:33 +00:00
Add raw versions for bootloader and lowest
The assumption is that same version format is used for all 3 of these versions.
This commit is contained in:
parent
4a32296f6a
commit
c1776c9ad4
@ -50,6 +50,8 @@ typedef struct {
|
|||||||
gchar *version_bootloader;
|
gchar *version_bootloader;
|
||||||
FwupdVersionFormat version_format;
|
FwupdVersionFormat version_format;
|
||||||
guint64 version_raw;
|
guint64 version_raw;
|
||||||
|
guint64 version_lowest_raw;
|
||||||
|
guint64 version_bootloader_raw;
|
||||||
GPtrArray *checksums;
|
GPtrArray *checksums;
|
||||||
GPtrArray *children;
|
GPtrArray *children;
|
||||||
guint32 flashes_left;
|
guint32 flashes_left;
|
||||||
@ -726,6 +728,41 @@ fwupd_device_set_version_lowest (FwupdDevice *device, const gchar *version_lowes
|
|||||||
priv->version_lowest = g_strdup (version_lowest);
|
priv->version_lowest = g_strdup (version_lowest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_get_version_lowest_raw:
|
||||||
|
* @device: A #FwupdDevice
|
||||||
|
*
|
||||||
|
* Gets the lowest version of firmware the device will accept in raw format.
|
||||||
|
*
|
||||||
|
* Returns: integer version number, or %0 if unset
|
||||||
|
*
|
||||||
|
* Since: 1.3.9
|
||||||
|
**/
|
||||||
|
guint64
|
||||||
|
fwupd_device_get_version_lowest_raw (FwupdDevice *device)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
|
g_return_val_if_fail (FWUPD_IS_DEVICE (device), 0);
|
||||||
|
return priv->version_lowest_raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_set_version_lowest_raw:
|
||||||
|
* @device: A #FwupdDevice
|
||||||
|
* @version_lowest_raw: the raw hardware version
|
||||||
|
*
|
||||||
|
* Sets the raw lowest version number from the hardware before converted to a string.
|
||||||
|
*
|
||||||
|
* Since: 1.3.9
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fwupd_device_set_version_lowest_raw (FwupdDevice *device, guint64 version_lowest_raw)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
|
g_return_if_fail (FWUPD_IS_DEVICE (device));
|
||||||
|
priv->version_lowest_raw = version_lowest_raw;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fwupd_device_get_version_bootloader:
|
* fwupd_device_get_version_bootloader:
|
||||||
* @device: A #FwupdDevice
|
* @device: A #FwupdDevice
|
||||||
@ -762,6 +799,41 @@ fwupd_device_set_version_bootloader (FwupdDevice *device, const gchar *version_b
|
|||||||
priv->version_bootloader = g_strdup (version_bootloader);
|
priv->version_bootloader = g_strdup (version_bootloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_get_version_bootloader_raw:
|
||||||
|
* @device: A #FwupdDevice
|
||||||
|
*
|
||||||
|
* Gets the bootloader version of firmware the device will accept in raw format.
|
||||||
|
*
|
||||||
|
* Returns: integer version number, or %0 if unset
|
||||||
|
*
|
||||||
|
* Since: 1.3.9
|
||||||
|
**/
|
||||||
|
guint64
|
||||||
|
fwupd_device_get_version_bootloader_raw (FwupdDevice *device)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
|
g_return_val_if_fail (FWUPD_IS_DEVICE (device), 0);
|
||||||
|
return priv->version_bootloader_raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_set_version_bootloader_raw:
|
||||||
|
* @device: A #FwupdDevice
|
||||||
|
* @version_bootloader_raw: the raw hardware version
|
||||||
|
*
|
||||||
|
* Sets the raw bootloader version number from the hardware before converted to a string.
|
||||||
|
*
|
||||||
|
* Since: 1.3.9
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fwupd_device_set_version_bootloader_raw (FwupdDevice *device, guint64 version_bootloader_raw)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
|
g_return_if_fail (FWUPD_IS_DEVICE (device));
|
||||||
|
priv->version_bootloader_raw = version_bootloader_raw;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fwupd_device_get_flashes_left:
|
* fwupd_device_get_flashes_left:
|
||||||
* @device: A #FwupdDevice
|
* @device: A #FwupdDevice
|
||||||
@ -1137,6 +1209,10 @@ fwupd_device_incorporate (FwupdDevice *self, FwupdDevice *donor)
|
|||||||
fwupd_device_set_version_format (self, priv_donor->version_format);
|
fwupd_device_set_version_format (self, priv_donor->version_format);
|
||||||
if (priv->version_raw == 0)
|
if (priv->version_raw == 0)
|
||||||
fwupd_device_set_version_raw (self, priv_donor->version_raw);
|
fwupd_device_set_version_raw (self, priv_donor->version_raw);
|
||||||
|
if (priv->version_lowest_raw == 0)
|
||||||
|
fwupd_device_set_version_lowest_raw (self, priv_donor->version_lowest_raw);
|
||||||
|
if (priv->version_bootloader_raw == 0)
|
||||||
|
fwupd_device_set_version_bootloader_raw (self, priv_donor->version_bootloader_raw);
|
||||||
for (guint i = 0; i < priv_donor->guids->len; i++) {
|
for (guint i = 0; i < priv_donor->guids->len; i++) {
|
||||||
const gchar *tmp = g_ptr_array_index (priv_donor->guids, i);
|
const gchar *tmp = g_ptr_array_index (priv_donor->guids, i);
|
||||||
fwupd_device_add_guid (self, tmp);
|
fwupd_device_add_guid (self, tmp);
|
||||||
@ -1286,6 +1362,16 @@ fwupd_device_to_variant_full (FwupdDevice *device, FwupdDeviceFlags flags)
|
|||||||
FWUPD_RESULT_KEY_VERSION_RAW,
|
FWUPD_RESULT_KEY_VERSION_RAW,
|
||||||
g_variant_new_uint64 (priv->version_raw));
|
g_variant_new_uint64 (priv->version_raw));
|
||||||
}
|
}
|
||||||
|
if (priv->version_lowest_raw > 0) {
|
||||||
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
|
FWUPD_RESULT_KEY_VERSION_LOWEST_RAW,
|
||||||
|
g_variant_new_uint64 (priv->version_raw));
|
||||||
|
}
|
||||||
|
if (priv->version_bootloader_raw > 0) {
|
||||||
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
|
FWUPD_RESULT_KEY_VERSION_BOOTLOADER_RAW,
|
||||||
|
g_variant_new_uint64 (priv->version_raw));
|
||||||
|
}
|
||||||
if (priv->flashes_left > 0) {
|
if (priv->flashes_left > 0) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
FWUPD_RESULT_KEY_FLASHES_LEFT,
|
FWUPD_RESULT_KEY_FLASHES_LEFT,
|
||||||
@ -1497,6 +1583,14 @@ fwupd_device_from_key_value (FwupdDevice *device, const gchar *key, GVariant *va
|
|||||||
fwupd_device_set_version_raw (device, g_variant_get_uint64 (value));
|
fwupd_device_set_version_raw (device, g_variant_get_uint64 (value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_VERSION_LOWEST_RAW) == 0) {
|
||||||
|
fwupd_device_set_version_lowest_raw (device, g_variant_get_uint64 (value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_VERSION_BOOTLOADER_RAW) == 0) {
|
||||||
|
fwupd_device_set_version_bootloader_raw (device, g_variant_get_uint64 (value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1880,6 +1974,10 @@ fwupd_device_to_json (FwupdDevice *device, JsonBuilder *builder)
|
|||||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
||||||
if (priv->version_raw > 0)
|
if (priv->version_raw > 0)
|
||||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_VERSION_RAW, priv->version_raw);
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_VERSION_RAW, priv->version_raw);
|
||||||
|
if (priv->version_lowest_raw > 0)
|
||||||
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_VERSION_LOWEST_RAW, priv->version_lowest_raw);
|
||||||
|
if (priv->version_bootloader_raw > 0)
|
||||||
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_VERSION_BOOTLOADER_RAW, priv->version_bootloader_raw);
|
||||||
if (priv->icons->len > 0) {
|
if (priv->icons->len > 0) {
|
||||||
json_builder_set_member_name (builder, "Icons");
|
json_builder_set_member_name (builder, "Icons");
|
||||||
json_builder_begin_array (builder);
|
json_builder_begin_array (builder);
|
||||||
@ -1908,6 +2006,17 @@ fwupd_device_to_json (FwupdDevice *device, JsonBuilder *builder)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
fwupd_device_verstr_raw (guint64 value_raw)
|
||||||
|
{
|
||||||
|
if (value_raw > 0xffffffff) {
|
||||||
|
return g_strdup_printf ("0x%08x%08x",
|
||||||
|
(guint) (value_raw >> 32),
|
||||||
|
(guint) (value_raw & 0xffffffff));
|
||||||
|
}
|
||||||
|
return g_strdup_printf ("0x%08x", (guint) value_raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fwupd_device_to_string:
|
* fwupd_device_to_string:
|
||||||
* @device: A #FwupdDevice
|
* @device: A #FwupdDevice
|
||||||
@ -1980,16 +2089,17 @@ fwupd_device_to_string (FwupdDevice *device)
|
|||||||
if (priv->flashes_left < 2)
|
if (priv->flashes_left < 2)
|
||||||
fwupd_pad_kv_int (str, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
fwupd_pad_kv_int (str, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
||||||
if (priv->version_raw > 0) {
|
if (priv->version_raw > 0) {
|
||||||
g_autofree gchar *tmp = NULL;
|
g_autofree gchar *tmp = fwupd_device_verstr_raw (priv->version_raw);
|
||||||
if (priv->version_raw > 0xffffffff) {
|
|
||||||
tmp = g_strdup_printf ("0x%08x%08x",
|
|
||||||
(guint) (priv->version_raw >> 32),
|
|
||||||
(guint) (priv->version_raw & 0xffffffff));
|
|
||||||
} else {
|
|
||||||
tmp = g_strdup_printf ("0x%08x", (guint) priv->version_raw);
|
|
||||||
}
|
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_VERSION_RAW, tmp);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_VERSION_RAW, tmp);
|
||||||
}
|
}
|
||||||
|
if (priv->version_lowest_raw > 0) {
|
||||||
|
g_autofree gchar *tmp = fwupd_device_verstr_raw (priv->version_lowest_raw);
|
||||||
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_VERSION_LOWEST_RAW, tmp);
|
||||||
|
}
|
||||||
|
if (priv->version_bootloader_raw > 0) {
|
||||||
|
g_autofree gchar *tmp = fwupd_device_verstr_raw (priv->version_bootloader_raw);
|
||||||
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_VERSION_BOOTLOADER_RAW, tmp);
|
||||||
|
}
|
||||||
if (priv->icons->len > 0) {
|
if (priv->icons->len > 0) {
|
||||||
g_autoptr(GString) tmp = g_string_new (NULL);
|
g_autoptr(GString) tmp = g_string_new (NULL);
|
||||||
for (guint i = 0; i < priv->icons->len; i++) {
|
for (guint i = 0; i < priv->icons->len; i++) {
|
||||||
|
@ -60,9 +60,15 @@ void fwupd_device_set_version (FwupdDevice *device,
|
|||||||
const gchar *fwupd_device_get_version_lowest (FwupdDevice *device);
|
const gchar *fwupd_device_get_version_lowest (FwupdDevice *device);
|
||||||
void fwupd_device_set_version_lowest (FwupdDevice *device,
|
void fwupd_device_set_version_lowest (FwupdDevice *device,
|
||||||
const gchar *version_lowest);
|
const gchar *version_lowest);
|
||||||
|
guint64 fwupd_device_get_version_lowest_raw (FwupdDevice *device);
|
||||||
|
void fwupd_device_set_version_lowest_raw (FwupdDevice *device,
|
||||||
|
guint64 version_lowest_raw);
|
||||||
const gchar *fwupd_device_get_version_bootloader (FwupdDevice *device);
|
const gchar *fwupd_device_get_version_bootloader (FwupdDevice *device);
|
||||||
void fwupd_device_set_version_bootloader (FwupdDevice *device,
|
void fwupd_device_set_version_bootloader (FwupdDevice *device,
|
||||||
const gchar *version_bootloader);
|
const gchar *version_bootloader);
|
||||||
|
guint64 fwupd_device_get_version_bootloader_raw (FwupdDevice *device);
|
||||||
|
void fwupd_device_set_version_bootloader_raw (FwupdDevice *device,
|
||||||
|
guint64 version_bootloader_raw);
|
||||||
guint64 fwupd_device_get_version_raw (FwupdDevice *device);
|
guint64 fwupd_device_get_version_raw (FwupdDevice *device);
|
||||||
void fwupd_device_set_version_raw (FwupdDevice *device,
|
void fwupd_device_set_version_raw (FwupdDevice *device,
|
||||||
guint64 version_raw);
|
guint64 version_raw);
|
||||||
|
@ -50,9 +50,11 @@ G_BEGIN_DECLS
|
|||||||
#define FWUPD_RESULT_KEY_VENDOR "Vendor" /* s */
|
#define FWUPD_RESULT_KEY_VENDOR "Vendor" /* s */
|
||||||
#define FWUPD_RESULT_KEY_VENDOR "Vendor" /* s */
|
#define FWUPD_RESULT_KEY_VENDOR "Vendor" /* s */
|
||||||
#define FWUPD_RESULT_KEY_VERSION_BOOTLOADER "VersionBootloader" /* s */
|
#define FWUPD_RESULT_KEY_VERSION_BOOTLOADER "VersionBootloader" /* s */
|
||||||
|
#define FWUPD_RESULT_KEY_VERSION_BOOTLOADER_RAW "VersionBootloaderRaw" /* t */
|
||||||
#define FWUPD_RESULT_KEY_VERSION_FORMAT "VersionFormat" /* u */
|
#define FWUPD_RESULT_KEY_VERSION_FORMAT "VersionFormat" /* u */
|
||||||
#define FWUPD_RESULT_KEY_VERSION_RAW "VersionRaw" /* t */
|
#define FWUPD_RESULT_KEY_VERSION_RAW "VersionRaw" /* t */
|
||||||
#define FWUPD_RESULT_KEY_VERSION_LOWEST "VersionLowest" /* s */
|
#define FWUPD_RESULT_KEY_VERSION_LOWEST "VersionLowest" /* s */
|
||||||
|
#define FWUPD_RESULT_KEY_VERSION_LOWEST_RAW "VersionLowestRaw" /* t */
|
||||||
#define FWUPD_RESULT_KEY_VERSION "Version" /* s */
|
#define FWUPD_RESULT_KEY_VERSION "Version" /* s */
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -421,3 +421,12 @@ LIBFWUPD_1.3.7 {
|
|||||||
fwupd_device_get_children;
|
fwupd_device_get_children;
|
||||||
local: *;
|
local: *;
|
||||||
} LIBFWUPD_1.3.6;
|
} LIBFWUPD_1.3.6;
|
||||||
|
|
||||||
|
LIBFWUPD_1.3.9 {
|
||||||
|
global:
|
||||||
|
fwupd_device_get_version_bootloader_raw;
|
||||||
|
fwupd_device_get_version_lowest_raw;
|
||||||
|
fwupd_device_set_version_bootloader_raw;
|
||||||
|
fwupd_device_set_version_lowest_raw;
|
||||||
|
local: *;
|
||||||
|
} LIBFWUPD_1.3.7;
|
||||||
|
@ -110,6 +110,8 @@ FuDevice *fu_device_new (void);
|
|||||||
#define fu_device_set_version_bootloader(d,v) fwupd_device_set_version_bootloader(FWUPD_DEVICE(d),v)
|
#define fu_device_set_version_bootloader(d,v) fwupd_device_set_version_bootloader(FWUPD_DEVICE(d),v)
|
||||||
#define fu_device_set_version_format(d,v) fwupd_device_set_version_format(FWUPD_DEVICE(d),v)
|
#define fu_device_set_version_format(d,v) fwupd_device_set_version_format(FWUPD_DEVICE(d),v)
|
||||||
#define fu_device_set_version_raw(d,v) fwupd_device_set_version_raw(FWUPD_DEVICE(d),v)
|
#define fu_device_set_version_raw(d,v) fwupd_device_set_version_raw(FWUPD_DEVICE(d),v)
|
||||||
|
#define fu_device_set_version_lowest_raw(d,v) fwupd_device_set_version_lowest_raw(FWUPD_DEVICE(d),v)
|
||||||
|
#define fu_device_set_version_bootloader_raw(d,v) fwupd_device_set_version_bootloader_raw(FWUPD_DEVICE(d),v)
|
||||||
#define fu_device_set_flashes_left(d,v) fwupd_device_set_flashes_left(FWUPD_DEVICE(d),v)
|
#define fu_device_set_flashes_left(d,v) fwupd_device_set_flashes_left(FWUPD_DEVICE(d),v)
|
||||||
#define fu_device_set_install_duration(d,v) fwupd_device_set_install_duration(FWUPD_DEVICE(d),v)
|
#define fu_device_set_install_duration(d,v) fwupd_device_set_install_duration(FWUPD_DEVICE(d),v)
|
||||||
#define fu_device_get_checksums(d) fwupd_device_get_checksums(FWUPD_DEVICE(d))
|
#define fu_device_get_checksums(d) fwupd_device_get_checksums(FWUPD_DEVICE(d))
|
||||||
@ -133,6 +135,8 @@ FuDevice *fu_device_new (void);
|
|||||||
#define fu_device_get_version_bootloader(d) fwupd_device_get_version_bootloader(FWUPD_DEVICE(d))
|
#define fu_device_get_version_bootloader(d) fwupd_device_get_version_bootloader(FWUPD_DEVICE(d))
|
||||||
#define fu_device_get_version_format(d) fwupd_device_get_version_format(FWUPD_DEVICE(d))
|
#define fu_device_get_version_format(d) fwupd_device_get_version_format(FWUPD_DEVICE(d))
|
||||||
#define fu_device_get_version_raw(d) fwupd_device_get_version_raw(FWUPD_DEVICE(d))
|
#define fu_device_get_version_raw(d) fwupd_device_get_version_raw(FWUPD_DEVICE(d))
|
||||||
|
#define fu_device_get_version_lowest_raw(d) fwupd_device_get_version_lowest_raw(FWUPD_DEVICE(d))
|
||||||
|
#define fu_device_get_version_bootloader_raw(d) fwupd_device_get_version_bootloader_raw(FWUPD_DEVICE(d))
|
||||||
#define fu_device_get_vendor_id(d) fwupd_device_get_vendor_id(FWUPD_DEVICE(d))
|
#define fu_device_get_vendor_id(d) fwupd_device_get_vendor_id(FWUPD_DEVICE(d))
|
||||||
#define fu_device_get_flashes_left(d) fwupd_device_get_flashes_left(FWUPD_DEVICE(d))
|
#define fu_device_get_flashes_left(d) fwupd_device_get_flashes_left(FWUPD_DEVICE(d))
|
||||||
#define fu_device_get_install_duration(d) fwupd_device_get_install_duration(FWUPD_DEVICE(d))
|
#define fu_device_get_install_duration(d) fwupd_device_get_install_duration(FWUPD_DEVICE(d))
|
||||||
|
@ -686,6 +686,7 @@ fu_uefi_device_probe (FuDevice *device, GError **error)
|
|||||||
if (self->fw_version_lowest != 0) {
|
if (self->fw_version_lowest != 0) {
|
||||||
version_lowest = fu_common_version_from_uint32 (self->fw_version_lowest,
|
version_lowest = fu_common_version_from_uint32 (self->fw_version_lowest,
|
||||||
version_format);
|
version_format);
|
||||||
|
fu_device_set_version_lowest_raw (device, self->fw_version_lowest);
|
||||||
fu_device_set_version_lowest (device, version_lowest);
|
fu_device_set_version_lowest (device, version_lowest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user