mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-16 13:54:31 +00:00
Move some common code down into LuDeviceBootloader
This is common API shared by the nordic and texas bootloaders.
This commit is contained in:
parent
7be4f138f3
commit
99f33c7414
@ -67,33 +67,10 @@ lu_device_bootloader_nordic_get_fw_version (LuDevice *device, GError **error)
|
|||||||
micro);
|
micro);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
|
||||||
lu_device_bootloader_nordic_get_bl_version (LuDevice *device, GError **error)
|
|
||||||
{
|
|
||||||
guint16 build;
|
|
||||||
|
|
||||||
g_autoptr(LuDeviceBootloaderRequest) req = lu_device_bootloader_request_new ();
|
|
||||||
req->cmd = LU_DEVICE_BOOTLOADER_CMD_GET_BL_VERSION;
|
|
||||||
if (!lu_device_bootloader_request (device, req, error)) {
|
|
||||||
g_prefix_error (error, "failed to get firmware version: ");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BOTxx.yy_Bzzzz
|
|
||||||
* 012345678901234 */
|
|
||||||
build = (guint16) lu_buffer_read_uint8 ((const gchar *) req->data + 10) << 8;
|
|
||||||
build += lu_buffer_read_uint8 ((const gchar *) req->data + 12);
|
|
||||||
return lu_format_version ("BOT",
|
|
||||||
lu_buffer_read_uint8 ((const gchar *) req->data + 3),
|
|
||||||
lu_buffer_read_uint8 ((const gchar *) req->data + 6),
|
|
||||||
build);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
lu_device_bootloader_nordic_probe (LuDevice *device, GError **error)
|
lu_device_bootloader_nordic_probe (LuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
g_autofree gchar *hw_platform_id = NULL;
|
g_autofree gchar *hw_platform_id = NULL;
|
||||||
g_autofree gchar *version_bl = NULL;
|
|
||||||
g_autofree gchar *version_fw = NULL;
|
g_autofree gchar *version_fw = NULL;
|
||||||
g_autoptr(GError) error_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
|
|
||||||
@ -113,11 +90,6 @@ lu_device_bootloader_nordic_probe (LuDevice *device, GError **error)
|
|||||||
lu_device_set_version_fw (device, version_fw);
|
lu_device_set_version_fw (device, version_fw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get bootloader version */
|
|
||||||
version_bl = lu_device_bootloader_nordic_get_bl_version (device, error);
|
|
||||||
if (version_bl == NULL)
|
|
||||||
return FALSE;
|
|
||||||
lu_device_set_version_bl (device, version_bl);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,8 +259,9 @@ static void
|
|||||||
lu_device_bootloader_nordic_class_init (LuDeviceBootloaderNordicClass *klass)
|
lu_device_bootloader_nordic_class_init (LuDeviceBootloaderNordicClass *klass)
|
||||||
{
|
{
|
||||||
LuDeviceClass *klass_device = LU_DEVICE_CLASS (klass);
|
LuDeviceClass *klass_device = LU_DEVICE_CLASS (klass);
|
||||||
|
LuDeviceBootloaderClass *klass_device_bootloader = LU_DEVICE_BOOTLOADER_CLASS (klass);
|
||||||
klass_device->write_firmware = lu_device_bootloader_nordic_write_firmware;
|
klass_device->write_firmware = lu_device_bootloader_nordic_write_firmware;
|
||||||
klass_device->probe = lu_device_bootloader_nordic_probe;
|
klass_device_bootloader->probe = lu_device_bootloader_nordic_probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -226,49 +226,15 @@ lu_device_bootloader_texas_write_firmware (LuDevice *device,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
|
||||||
lu_device_bootloader_texas_get_bl_version (LuDevice *device, GError **error)
|
|
||||||
{
|
|
||||||
guint16 build;
|
|
||||||
|
|
||||||
g_autoptr(LuDeviceBootloaderRequest) req = lu_device_bootloader_request_new ();
|
|
||||||
req->cmd = LU_DEVICE_BOOTLOADER_CMD_GET_BL_VERSION;
|
|
||||||
if (!lu_device_bootloader_request (device, req, error)) {
|
|
||||||
g_prefix_error (error, "failed to get firmware version: ");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BOTxx.yy_Bzzzz
|
|
||||||
* 012345678901234 */
|
|
||||||
build = (guint16) lu_buffer_read_uint8 ((const gchar *) req->data + 10) << 8;
|
|
||||||
build += lu_buffer_read_uint8 ((const gchar *) req->data + 12);
|
|
||||||
return lu_format_version ("BOT",
|
|
||||||
lu_buffer_read_uint8 ((const gchar *) req->data + 3),
|
|
||||||
lu_buffer_read_uint8 ((const gchar *) req->data + 6),
|
|
||||||
build);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
lu_device_bootloader_texas_probe (LuDevice *device, GError **error)
|
|
||||||
{
|
|
||||||
g_autofree gchar *version_bl = NULL;
|
|
||||||
version_bl = lu_device_bootloader_texas_get_bl_version (device, error);
|
|
||||||
if (version_bl == NULL)
|
|
||||||
return FALSE;
|
|
||||||
lu_device_set_version_bl (device, version_bl);
|
|
||||||
lu_device_set_version_fw (device, "RQR24.xx_Bxxxx");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lu_device_bootloader_texas_class_init (LuDeviceBootloaderTexasClass *klass)
|
lu_device_bootloader_texas_class_init (LuDeviceBootloaderTexasClass *klass)
|
||||||
{
|
{
|
||||||
LuDeviceClass *klass_device = LU_DEVICE_CLASS (klass);
|
LuDeviceClass *klass_device = LU_DEVICE_CLASS (klass);
|
||||||
klass_device->write_firmware = lu_device_bootloader_texas_write_firmware;
|
klass_device->write_firmware = lu_device_bootloader_texas_write_firmware;
|
||||||
klass_device->probe = lu_device_bootloader_texas_probe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lu_device_bootloader_texas_init (LuDeviceBootloaderTexas *device)
|
lu_device_bootloader_texas_init (LuDeviceBootloaderTexas *device)
|
||||||
{
|
{
|
||||||
|
lu_device_set_version_fw (LU_DEVICE (device), "RQR24.xx_Bxxxx");
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,46 @@ lu_device_bootloader_open (LuDevice *device, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
lu_device_bootloader_get_bl_version (LuDevice *device, GError **error)
|
||||||
|
{
|
||||||
|
guint16 build;
|
||||||
|
|
||||||
|
g_autoptr(LuDeviceBootloaderRequest) req = lu_device_bootloader_request_new ();
|
||||||
|
req->cmd = LU_DEVICE_BOOTLOADER_CMD_GET_BL_VERSION;
|
||||||
|
if (!lu_device_bootloader_request (device, req, error)) {
|
||||||
|
g_prefix_error (error, "failed to get firmware version: ");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* BOTxx.yy_Bzzzz
|
||||||
|
* 012345678901234 */
|
||||||
|
build = (guint16) lu_buffer_read_uint8 ((const gchar *) req->data + 10) << 8;
|
||||||
|
build += lu_buffer_read_uint8 ((const gchar *) req->data + 12);
|
||||||
|
return lu_format_version ("BOT",
|
||||||
|
lu_buffer_read_uint8 ((const gchar *) req->data + 3),
|
||||||
|
lu_buffer_read_uint8 ((const gchar *) req->data + 6),
|
||||||
|
build);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
lu_device_bootloader_probe (LuDevice *device, GError **error)
|
||||||
|
{
|
||||||
|
LuDeviceBootloaderClass *klass = LU_DEVICE_BOOTLOADER_GET_CLASS (device);
|
||||||
|
g_autofree gchar *version_bl = NULL;
|
||||||
|
|
||||||
|
/* get bootloader version */
|
||||||
|
version_bl = lu_device_bootloader_get_bl_version (device, error);
|
||||||
|
if (version_bl == NULL)
|
||||||
|
return FALSE;
|
||||||
|
lu_device_set_version_bl (device, version_bl);
|
||||||
|
|
||||||
|
/* subclassed further */
|
||||||
|
if (klass->probe != NULL)
|
||||||
|
return klass->probe (device, error);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
lu_device_bootloader_close (LuDevice *device, GError **error)
|
lu_device_bootloader_close (LuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
@ -362,4 +402,5 @@ lu_device_bootloader_class_init (LuDeviceBootloaderClass *klass)
|
|||||||
klass_device->attach = lu_device_bootloader_attach;
|
klass_device->attach = lu_device_bootloader_attach;
|
||||||
klass_device->open = lu_device_bootloader_open;
|
klass_device->open = lu_device_bootloader_open;
|
||||||
klass_device->close = lu_device_bootloader_close;
|
klass_device->close = lu_device_bootloader_close;
|
||||||
|
klass_device->probe = lu_device_bootloader_probe;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ G_DECLARE_DERIVABLE_TYPE (LuDeviceBootloader, lu_device_bootloader, LU, DEVICE_B
|
|||||||
struct _LuDeviceBootloaderClass
|
struct _LuDeviceBootloaderClass
|
||||||
{
|
{
|
||||||
LuDeviceClass parent_class;
|
LuDeviceClass parent_class;
|
||||||
|
gboolean (*probe) (LuDevice *device,
|
||||||
|
GError **error);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user