coreboot: Remove plugin and instead add metadata to flashrom devices

The coreboot plugin never actually gained the ability to write. As it stands a
coreboot system now adds *two* system-firmware devices (from both flashrom and
coreboot) which isn't ideal.

Just allow flashrom to enumerate quirked devices and add coreboot-specific
metadata as required. If we require some kind of cbfs parsing then we can do
that in FuFlashromDevice->prepare_firmware().
This commit is contained in:
Richard Hughes 2021-01-14 21:00:37 +00:00
parent 5c04b4f4bd
commit 6101067f03
16 changed files with 193 additions and 397 deletions

View File

@ -16,7 +16,6 @@ meson .. \
--bindir=$target \ --bindir=$target \
-Dbuild=standalone \ -Dbuild=standalone \
-Dpolkit=false \ -Dpolkit=false \
-Dplugin_coreboot=false \
-Dplugin_flashrom=false \ -Dplugin_flashrom=false \
-Dplugin_uefi_capsule=false \ -Dplugin_uefi_capsule=false \
-Dplugin_redfish=false \ -Dplugin_redfish=false \

View File

@ -385,7 +385,6 @@ done
%{_libdir}/fwupd-plugins-3/libfu_plugin_bcm57xx.so %{_libdir}/fwupd-plugins-3/libfu_plugin_bcm57xx.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_ccgx.so %{_libdir}/fwupd-plugins-3/libfu_plugin_ccgx.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_colorhug.so %{_libdir}/fwupd-plugins-3/libfu_plugin_colorhug.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_coreboot.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_cros_ec.so %{_libdir}/fwupd-plugins-3/libfu_plugin_cros_ec.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_csr.so %{_libdir}/fwupd-plugins-3/libfu_plugin_csr.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_cpu.so %{_libdir}/fwupd-plugins-3/libfu_plugin_cpu.so

View File

@ -26,7 +26,6 @@ option('plugin_nvme', type : 'boolean', value : true, description : 'enable NVMe
option('plugin_modem_manager', type : 'boolean', value : false, description : 'enable ModemManager support') option('plugin_modem_manager', type : 'boolean', value : false, description : 'enable ModemManager support')
option('plugin_msr', type : 'boolean', value : true, description : 'enable MSR support') option('plugin_msr', type : 'boolean', value : true, description : 'enable MSR support')
option('plugin_flashrom', type : 'boolean', value : false, description : 'enable libflashrom support') option('plugin_flashrom', type : 'boolean', value : false, description : 'enable libflashrom support')
option('plugin_coreboot', type : 'boolean', value : true, description : 'enable coreboot support')
option('plugin_platform_integrity', type : 'boolean', value : false, description : 'enable platform integrity support') option('plugin_platform_integrity', type : 'boolean', value : false, description : 'enable platform integrity support')
option('supported_build', type : 'boolean', value : false, description: 'distribution package with upstream support') option('supported_build', type : 'boolean', value : false, description: 'distribution package with upstream support')
option('systemd', type : 'boolean', value : true, description : 'enable systemd support') option('systemd', type : 'boolean', value : true, description : 'enable systemd support')

View File

@ -1,63 +0,0 @@
coreboot
========
Introduction
------------
Until now only the version detection has been implemented.
System identification
---------------------
coreboot can be detected the following ways:
1. by parsing SMBIOS type 0 vendor string. On coreboot enabled platforms
it's always `coreboot`.
2. by parsing ACPI tables. An ACPI device with the _HID `BOOT0000` exists.
(This HID has been reserved for coreboot enabled platforms)
3. by parsing the devicetree. A node under *firmware/coreboot* with the
compatible id `coreboot` exists.
coreboot version string
-----------------------
The coreboot version string can have an optional prefix (see below).
After the optional prefix the *major*, *minor* string follows and finally
the *build string*, containing the exact commit and repository state, follows.
For example:
> 4.10-989-gc8a4e4b9c5-dirty
**Exception on Lenovo devices:**
The thinkpad_acpi kernel module requires a specific pattern in the DMI version
string. To satisfy those requirements coreboot adds the CBETxxxx prefix to the
DMI version string on all Lenovo devices.
For example:
> CBET4000 4.10-989-gc8a4e4b9c5-dirty
The coreboot DMI version string always starts with `CBET`.
GUID Generation
---------------
These device uses hardware ID values which are derived from SMBIOS.
The following HWIDs are added on coreboot enabled platforms:
* HardwareID-3
* HardwareID-4
* HardwareID-5
* HardwareID-6
* HardwareID-10
They do match the values provided by `fwupdtool hwids` or
the `ComputerHardwareIds.exe` Windows utility.
Vendor ID Security
------------------
The vendor ID is set from the BIOS vendor, in this instance `DMI:coreboot`
External interface access
-------------------------
This plugin does not currently use any external access.

View File

@ -1,2 +0,0 @@
[SmbiosManufacturer=LENOVO]
CorebootVersionQuirks = lenovo-cbet-prefix

View File

@ -1,115 +0,0 @@
/*
* Copyright (C) 2019 9elements Agency GmbH <patrick.rudolph@9elements.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include "fu-plugin-coreboot.h"
/**
* FU_QUIRKS_COREBOOT_VERSION:
* @key: The SMBIOS manufacturer name
* @value: One of the following: "lenovo-cbet-prefix"
*
* "lenovo-cbet-prefix" quirk:
* The thinkpad_acpi kernel module requires a specific pattern
* in the DMI version string. To satisfy those requirements
* coreboot adds the CBETxxxx prefix to the DMI version string
* on all Lenovo devices. The prefix isn't present in the
* version string found in coreboot tables, or on other
* coreboot enabled devices.
*
* Since: 1.3.5
*/
#define FU_QUIRKS_COREBOOT_VERSION "CorebootVersionQuirks"
#define FU_QUIRK_CBET_PREFIX "lenovo-cbet-prefix"
/* Tries to convert the coreboot version string to a triplet string.
* Returns NULL on error. */
gchar *
fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_version,
GError **error)
{
guint cb_major = 0;
guint cb_minor = 0;
guint cb_build = 0;
gint rc;
rc = sscanf (coreboot_version, "%u.%u-%u", &cb_major, &cb_minor, &cb_build);
if (rc < 0) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to parse firmware version");
return NULL;
}
/* Sanity check */
if (cb_major == 0) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Invalid firmware version");
return NULL;
}
return g_strdup_printf ("%u.%u.%u", cb_major, cb_minor, cb_build);
}
/* convert firmware type to user friendly string representation */
gchar *
fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin,
const gchar *vboot_partition)
{
GString *display_name;
if (vboot_partition != NULL) {
display_name = g_string_new (vboot_partition);
g_string_prepend (display_name, ", VBOOT partition ");
} else {
display_name = g_string_new ("");
}
g_string_prepend (display_name, "coreboot System Firmware");
return g_string_free (display_name, FALSE);
}
/* Returns the version string with possible quirks applied */
const gchar *
fu_plugin_coreboot_get_version_string (FuPlugin *plugin)
{
const gchar *version;
const gchar *manufacturer;
const gchar *quirk = NULL;
version = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION);
if (version == NULL)
return NULL;
manufacturer = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_MANUFACTURER);
if (manufacturer != NULL) {
g_autofree gchar *group = NULL;
/* any quirks match */
group = g_strdup_printf ("SmbiosManufacturer=%s", manufacturer);
quirk = fu_plugin_lookup_quirk_by_id (plugin, group,
FU_QUIRKS_COREBOOT_VERSION);
}
if (quirk == NULL)
return version;
if (g_strcmp0(quirk, FU_QUIRK_CBET_PREFIX) == 0) {
if (strlen (version) > 9 && g_str_has_prefix (version, "CBET"))
version += 9;
return version;
}
return version;
}

View File

@ -1,147 +0,0 @@
/*
* Copyright (C) 2019 9elements Agency GmbH <patrick.rudolph@9elements.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "fu-plugin-vfuncs.h"
#include "fu-hash.h"
#include "fu-device-metadata.h"
#include "fu-device-private.h"
#include "fu-plugin-coreboot.h"
void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
}
gboolean
fu_plugin_coldplug (FuPlugin *plugin, GError **error)
{
const gchar *major;
const gchar *minor;
const gchar *version;
GBytes *bios_table;
gboolean updatable = FALSE; /* TODO: Implement update support */
g_autofree gchar *name = NULL;
g_autofree gchar *triplet = NULL;
g_autoptr(FuDevice) dev = NULL;
/* don't include FU_HWIDS_KEY_BIOS_VERSION */
static const gchar *hwids[] = {
"HardwareID-3",
"HardwareID-4",
"HardwareID-5",
"HardwareID-6",
"HardwareID-10",
};
version = fu_plugin_coreboot_get_version_string (plugin);
if (version != NULL)
triplet = fu_plugin_coreboot_version_string_to_triplet (version, error);
if (version == NULL || triplet == NULL) {
major = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_MAJOR_RELEASE);
if (major == NULL) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Missing BIOS major release");
return FALSE;
}
minor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_MINOR_RELEASE);
if (minor == NULL) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Missing BIOS minor release");
return FALSE;
}
triplet = g_strdup_printf ("%s.%s.0", major, minor);
}
if (triplet == NULL) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"No version string found");
return FALSE;
}
dev = fu_device_new ();
fu_device_set_version_format (dev, FWUPD_VERSION_FORMAT_TRIPLET);
fu_device_set_version (dev, triplet);
fu_device_set_summary (dev, "Open Source system boot firmware");
fu_device_set_id (dev, "coreboot");
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_icon (dev, "computer");
name = fu_plugin_coreboot_get_name_for_type (plugin, NULL);
if (name != NULL) {
fu_device_set_name (dev, name);
} else {
fu_device_set_name (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_PRODUCT_NAME));
}
fu_device_set_vendor (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_MANUFACTURER));
fu_device_add_instance_id (dev, "main-system-firmware");
fu_device_add_vendor_id (dev, "DMI:coreboot");
for (guint i = 0; i < G_N_ELEMENTS (hwids); i++) {
char *str;
str = fu_plugin_get_hwid_replace_value (plugin, hwids[i], NULL);
if (str != NULL)
fu_device_add_instance_id (dev, str);
}
bios_table = fu_plugin_get_smbios_data (plugin, FU_SMBIOS_STRUCTURE_TYPE_BIOS);
if (bios_table != NULL) {
guint32 bios_characteristics;
gsize len;
const guint8 *value = g_bytes_get_data (bios_table, &len);
if (len >= 0x9) {
gint firmware_size = (value[0x9] + 1) * 64 * 1024;
fu_device_set_firmware_size_max (dev, firmware_size);
}
if (len >= (0xa + sizeof(guint32))) {
memcpy (&bios_characteristics, &value[0xa], sizeof (guint32));
/* Read the "BIOS is upgradeable (Flash)" flag */
if (!(bios_characteristics & (1 << 11)))
updatable = FALSE;
}
}
if (updatable)
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE);
/* convert instances to GUID */
fu_device_convert_instance_ids (dev);
fu_plugin_device_add (plugin, dev);
return TRUE;
}
gboolean
fu_plugin_startup (FuPlugin *plugin, GError **error)
{
const gchar *vendor;
vendor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VENDOR);
if (g_strcmp0 (vendor, "coreboot") != 0) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_FOUND,
"No coreboot detected on this machine.");
return FALSE;
}
return TRUE;
}

View File

@ -1,16 +0,0 @@
/*
* Copyright (C) 2019 9elements Agency GmbH <patrick.rudolph@9elements.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "fu-plugin.h"
#include "fu-device.h"
gchar *fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_version,
GError **error);
gchar *fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin,
const gchar *vboot_partition);
const gchar *fu_plugin_coreboot_get_version_string (FuPlugin *plugin);

View File

@ -1,30 +0,0 @@
cargs = ['-DG_LOG_DOMAIN="FuPluginCoreboot"']
install_data(['coreboot.quirk'],
install_dir: join_paths(datadir, 'fwupd', 'quirks.d')
)
shared_module('fu_plugin_coreboot',
fu_hash,
sources : [
'fu-plugin-coreboot.c',
'fu-coreboot-common.c',
],
include_directories : [
root_incdir,
fwupd_incdir,
fwupdplugin_incdir,
],
install : true,
install_dir: plugin_dir,
link_with : [
fwupd,
fwupdplugin,
],
c_args : [
cargs,
],
dependencies : [
plugin_deps,
],
)

View File

@ -17,9 +17,36 @@ This plugin supports the following protocol ID:
* org.flashrom * org.flashrom
Coreboot Version String
-----------------------
The coreboot version string can have an optional prefix (see below).
After the optional prefix the *major*, *minor* string follows and finally
the *build string*, containing the exact commit and repository state, follows.
For example `4.10-989-gc8a4e4b9c5-dirty`
**Exception on Lenovo devices:**
The thinkpad_acpi kernel module requires a specific pattern in the DMI version
string. To satisfy those requirements coreboot adds the CBETxxxx prefix to the
DMI version string on all Lenovo devices.
For example `CBET4000 4.10-989-gc8a4e4b9c5-dirty`
The coreboot DMI version string always starts with `CBET`.
GUID Generation GUID Generation
--------------- ---------------
These device uses hardware ID values which are derived from SMBIOS.
* HardwareID-3
* HardwareID-4
* HardwareID-5
* HardwareID-6
* HardwareID-10
These device uses hardware ID values which are derived from SMBIOS. They should These device uses hardware ID values which are derived from SMBIOS. They should
match the values provided by `fwupdtool hwids` or the `ComputerHardwareIds.exe` match the values provided by `fwupdtool hwids` or the `ComputerHardwareIds.exe`
Windows utility. Windows utility.

View File

@ -10,4 +10,7 @@ VersionFormat=quad
# Starlabs LabTop L4 # Starlabs LabTop L4
[HwId=baf1d04e-fd16-5e6a-93cc-1c23d171f879] [HwId=baf1d04e-fd16-5e6a-93cc-1c23d171f879]
DeviceId=StarlabsLabTopL4 DeviceId=StarlabsLabTopL4
VersionFormat=triplet
# Starlabs LabTop L4 (in coreboot)
[Guid=0ee5867c-93f0-5fb4-adf1-9d686ea1183a]
Branch=coreboot

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "config.h"
#include "fu-flashrom-device.h"
struct _FuFlashromDevice {
FuDevice parent_instance;
};
G_DEFINE_TYPE (FuFlashromDevice, fu_flashrom_device, FU_TYPE_DEVICE)
static void
fu_flashrom_device_init (FuFlashromDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "org.flashrom");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_NEEDS_REBOOT);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_REQUIRE_AC);
fu_device_add_instance_id (FU_DEVICE (self), "main-system-firmware");
fu_device_add_internal_flag (FU_DEVICE (self), FU_DEVICE_INTERNAL_FLAG_ENSURE_SEMVER);
fu_device_set_version_format (FU_DEVICE (self), FWUPD_VERSION_FORMAT_TRIPLET);
fu_device_add_icon (FU_DEVICE (self), "computer");
}
static void
fu_flashrom_device_class_init (FuFlashromDeviceClass *klass)
{
}
FuDevice *
fu_flashrom_device_new (void)
{
return FU_DEVICE (g_object_new (FU_TYPE_FLASHROM_DEVICE, NULL));
}

View File

@ -0,0 +1,14 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "fu-plugin.h"
#define FU_TYPE_FLASHROM_DEVICE (fu_flashrom_device_get_type ())
G_DECLARE_FINAL_TYPE (FuFlashromDevice, fu_flashrom_device, FU, FLASHROM_DEVICE, FuDevice)
FuDevice *fu_flashrom_device_new (void);

View File

@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
* *
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com> * Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
* Copyright (C) 2019 9elements Agency GmbH <patrick.rudolph@9elements.com>
* *
* Licensed under the GNU General Public License Version 2 * Licensed under the GNU General Public License Version 2
* *
@ -24,8 +25,10 @@
#include <string.h> #include <string.h>
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-flashrom-device.h"
#include "fu-hash.h" #include "fu-hash.h"
#include "libflashrom.h"
#include <libflashrom.h>
#define SELFCHECK_TRUE 1 #define SELFCHECK_TRUE 1
@ -42,6 +45,7 @@ fu_plugin_init (FuPlugin *plugin)
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); fu_plugin_alloc_data (plugin, sizeof (FuPluginData));
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "linux_lockdown"); fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "linux_lockdown");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_CONFLICTS, "coreboot"); /* obsoleted */
} }
void void
@ -84,6 +88,91 @@ fu_plugin_flashrom_debug_cb (enum flashrom_log_level lvl, const char *fmt, va_li
return 0; return 0;
} }
static void
fu_plugin_flashrom_device_set_version (FuPlugin *plugin, FuDevice *device)
{
const gchar *version;
const gchar *version_major;
const gchar *version_minor;
/* as-is */
version = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION);
if (version != NULL) {
/* some Lenovo hardware requires a specific prefix for the EC,
* so strip it before we use ensure-semver */
if (strlen (version) > 9 && g_str_has_prefix (version, "CBET"))
version += 9;
/* this may not "stick" if there are no numeric chars */
fu_device_set_version (device, version);
if (fu_device_get_version (device) != NULL)
return;
}
/* component parts only */
version_major = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_MAJOR_RELEASE);
version_minor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_MINOR_RELEASE);
if (version_major != NULL && version_minor != NULL) {
g_autofree gchar *tmp = g_strdup_printf ("%s.%s.0",
version_major,
version_minor);
fu_device_set_version (device, tmp);
return;
}
}
static void
fu_plugin_flashrom_device_set_bios_info (FuPlugin *plugin, FuDevice *device)
{
const guint8 *buf;
gsize bufsz;
guint32 bios_char = 0x0;
guint8 bios_sz = 0x0;
g_autoptr(GBytes) bios_table = NULL;
/* get SMBIOS info */
bios_table = fu_plugin_get_smbios_data (plugin, FU_SMBIOS_STRUCTURE_TYPE_BIOS);
if (bios_table == NULL)
return;
/* ROM size */
buf = g_bytes_get_data (bios_table, &bufsz);
if (fu_common_read_uint8_safe (buf, bufsz, 0x9, &bios_sz, NULL)) {
guint64 firmware_size = (bios_sz + 1) * 64 * 1024;
fu_device_set_firmware_size_max (device, firmware_size);
}
/* BIOS characteristics */
if (fu_common_read_uint32_safe (buf, bufsz, 0xa, &bios_char, G_LITTLE_ENDIAN, NULL)) {
if ((bios_char & (1 << 11)) == 0)
fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE);
}
}
static void
fu_plugin_flashrom_device_set_hwids (FuPlugin *plugin, FuDevice *device)
{
static const gchar *hwids[] = {
"HardwareID-3",
"HardwareID-4",
"HardwareID-5",
"HardwareID-6",
"HardwareID-10",
/* a more useful one for coreboot branch detection */
FU_HWIDS_KEY_MANUFACTURER "&"
FU_HWIDS_KEY_FAMILY "&"
FU_HWIDS_KEY_PRODUCT_NAME "&"
FU_HWIDS_KEY_PRODUCT_SKU "&"
FU_HWIDS_KEY_BIOS_VENDOR,
};
/* don't include FU_HWIDS_KEY_BIOS_VERSION */
for (guint i = 0; i < G_N_ELEMENTS (hwids); i++) {
g_autofree gchar *str = NULL;
str = fu_plugin_get_hwid_replace_value (plugin, hwids[i], NULL);
if (str != NULL)
fu_device_add_instance_id (device, str);
}
}
gboolean gboolean
fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_plugin_coldplug (FuPlugin *plugin, GError **error)
{ {
@ -93,7 +182,6 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
gint rc; gint rc;
g_autoptr(GPtrArray) devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); g_autoptr(GPtrArray) devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
dmi_vendor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VENDOR);
for (guint i = 0; i < hwids->len; i++) { for (guint i = 0; i < hwids->len; i++) {
const gchar *guid = g_ptr_array_index (hwids, i); const gchar *guid = g_ptr_array_index (hwids, i);
const gchar *quirk_str; const gchar *quirk_str;
@ -104,23 +192,26 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
"DeviceId"); "DeviceId");
if (quirk_str != NULL) { if (quirk_str != NULL) {
g_autofree gchar *device_id = g_strdup_printf ("flashrom-%s", quirk_str); g_autofree gchar *device_id = g_strdup_printf ("flashrom-%s", quirk_str);
g_autoptr(FuDevice) dev = fu_device_new (); g_autoptr(FuDevice) device = fu_flashrom_device_new ();
fu_device_set_id (dev, device_id); fu_device_set_quirks (device, fu_plugin_get_quirks (plugin));
fu_device_set_quirks (dev, fu_plugin_get_quirks (plugin)); fu_device_set_name (device, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_PRODUCT_NAME));
fu_device_set_protocol (dev, "org.flashrom"); fu_device_set_vendor (device, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_MANUFACTURER));
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); /* use same VendorID logic as with UEFI */
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); dmi_vendor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VENDOR);
fu_device_set_name (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_PRODUCT_NAME));
fu_device_set_vendor (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_MANUFACTURER));
fu_device_add_internal_flag (dev, FU_DEVICE_INTERNAL_FLAG_ENSURE_SEMVER);
fu_device_set_version (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION));
fu_device_add_guid (dev, guid);
if (dmi_vendor != NULL) { if (dmi_vendor != NULL) {
g_autofree gchar *vendor_id = g_strdup_printf ("DMI:%s", dmi_vendor); g_autofree gchar *vendor_id = g_strdup_printf ("DMI:%s", dmi_vendor);
fu_device_add_vendor_id (FU_DEVICE (dev), vendor_id); fu_device_add_vendor_id (FU_DEVICE (device), vendor_id);
} }
g_ptr_array_add (devices, g_steal_pointer (&dev));
fu_device_set_id (device, device_id);
fu_device_add_guid (device, guid);
fu_plugin_flashrom_device_set_version (plugin, device);
fu_plugin_flashrom_device_set_hwids (plugin, device);
fu_plugin_flashrom_device_set_bios_info (plugin, device);
if (!fu_device_setup (device, error))
return FALSE;
g_ptr_array_add (devices, g_steal_pointer (&device));
break; break;
} }
} }

View File

@ -7,6 +7,7 @@ install_data(['flashrom.quirk'],
shared_module('fu_plugin_flashrom', shared_module('fu_plugin_flashrom',
fu_hash, fu_hash,
sources : [ sources : [
'fu-flashrom-device.c',
'fu-plugin-flashrom.c', 'fu-plugin-flashrom.c',
], ],
include_directories : [ include_directories : [

View File

@ -143,10 +143,6 @@ if get_option('plugin_flashrom')
subdir('flashrom') subdir('flashrom')
endif endif
if get_option('plugin_coreboot')
subdir('coreboot')
endif
if get_option('plugin_platform_integrity') if get_option('plugin_platform_integrity')
subdir('platform-integrity') subdir('platform-integrity')
endif endif