Commit Graph

294 Commits

Author SHA1 Message Date
Richard Hughes
ae80ba6d16 Fix SMBIOS struct parsing when there are three NULs in a row
We need to be careful detecting the end of a string section when the struct
ends with NUL NUL NUL.

Fixes https://github.com/fwupd/fwupd/issues/5509
2023-02-10 13:11:25 +00:00
Richard Hughes
99df74f0c2 Add API to wait for a device
This allows us to ignore all the delays when the device is emulated, with the
idea being to do dozens of device emulations in the CI tests.

Also, do not call fu_progress_sleep() when the device is emulated.
2023-02-01 09:42:08 +00:00
Richard Hughes
c1ffebae48 Remove unused API for setting backend tags
It turns out we do not want to know the current phase of the device, and we can
achieve the same thing tagging the GUsbDevice manually and clearing the events
at exactly the correct time.
2023-01-30 13:32:48 +00:00
Richard Hughes
f3f951d3a7 trivial: Add fu_device_has_problem() to be consistent and hide details 2023-01-26 12:35:08 +00:00
Richard Hughes
575871f505 Add fu_device_remove_backend_tag() for future use 2023-01-24 14:54:23 +00:00
Richard Hughes
5d6cb83d1c Add fu_context_remove_flag() for future use 2023-01-22 07:35:48 +00:00
Richard Hughes
2b0f92506b Refactor the hwids functionality
This refactors the code as it was getting very confusing; before FuSmbios was
reading both SMBIOS and the kernel-provided DT -- and various things were
injecting overrides in three different place. To properly support FDT remove
one layer of indirection.

This also lets us use the compatible strings to enable plugins specifying the
flag _REQUIRE_HWID -- which means we only load the plugin if it's got a chance
of working. e.g.

    [aspeed,ast2500]
2023-01-18 07:04:44 +00:00
Richard Hughes
0efc1bebce trivial: Add fu_context_get_hwids() for future use 2023-01-16 17:49:57 +00:00
Richard Hughes
2737b05cf8 trivial: Add fu_context_get_smbios() for future use 2023-01-16 17:49:57 +00:00
Richard Hughes
0e381a8666 trivial: Store the chassis kind in the context 2023-01-16 17:49:57 +00:00
Richard Hughes
8af1943142 trivial: Add FuContextHwidFlags for future usage 2023-01-16 17:49:57 +00:00
Richard Hughes
cf4f34572b Add fu_context_get_fdt() to get the Flat Device Tree
This is needed because multiple plugins will soon be consuming the system FDT,
and we don't want to either parse this multiple times, or duplicate the loading
logic.
2023-01-11 16:25:26 +00:00
Richard Hughes
1ca3cdd4d9 Add a pefile firmware parser
This will eventually allow us to reconstruct a SBoM using a UEFI file volume.

This can be used like this `fwupdtool firmware-parse efi/fwupdx64.efi pefile`
to produce:

    <firmware gtype="FuPefileFirmware">
      <data size="0xef59">MZ.</data>
      <firmware>
        <id>.text</id>
        <offset>0x2d0</offset>
        <size>0x7bab</size>
        <data size="0x7bab">H...QRH.=....H.5</data>
      </firmware>
      ...
      <firmware gtype="FuCoswidFirmware">
        <id>fwupd-efi:fwupdx64</id>
        <idx>0x7</idx>
        <version>1.4</version>
        <offset>0xc4e0</offset>
        <size>0xce</size>
        <data size="0xce">..een-US</data>
        <version_scheme>semver</version_scheme>
        <product>fwupdx64</product>
        <summary>EFI helpers to install system firmware</summary>
        <colloquial_version>1.3-7-g881a508</colloquial_version>
        <link>
          <href>https://spdx.org/licenses/LGPL-2.0.html</href>
          <rel>license</rel>
        </link>
        <entity>
          <name>Richard Hughes</name>
          <regid>hughsie.com</regid>
          <role>maintainer</role>
          <role>tag-creator</role>
        </entity>
      </firmware>
    </firmware>
2023-01-06 17:32:59 +00:00
Richard Hughes
427e5cec7a trivial: Add new convenience API to make plugins simpler 2022-12-20 20:54:12 +00:00
Richard Hughes
069fa56f1a Add fu_archive_firmware_get_image_fnmatch() for future use
It's useful to get images from archives by a specific filename extension.
2022-12-17 07:44:27 +00:00
Richard Hughes
4ef8854618 trivial: Add convenience API for future use 2022-12-13 20:38:49 +00:00
Richard Hughes
a157e3d19d Add fu_version_from_uint24() for future usage 2022-12-11 20:25:52 +00:00
Richard Hughes
b521924b00 Make fu_device_get_release_default() match the parent semantics
In various places the code was checking if a release was set, but this would
always be false as the release was being auto-created. This was masking valid
bugs, and was confusing to have the superclass have different semantics to the
baseclass.
2022-11-29 09:05:16 +00:00
Richard Hughes
1f97275a33 Add fu_mei_device_get_fw_status() for future usage
All MEI devices support these attributes, and this API addition will allow us
to support new Intel GPUs and also modernize other plugins.
2022-11-01 16:19:27 +00:00
Richard Hughes
b50b67107f Add fu_progress_to_string() to make debugging easier 2022-10-27 15:29:32 +01:00
Richard Hughes
ac48c865a0 Add a helper to get a GUsbDevice from a FuUdevDevice 2022-10-26 23:27:50 +01:00
Richard Hughes
2dea742004 Match the MEI UUID in quirk files
This allows us to be more specific when matching devices, and also means we get
more attributes 'for free' from the FuUdevDevice->probe().

This would allow us to have multiple device GTypes handling multiple MEI
interfaces in the same plugin., for instance, PTHI and MKHI.

The slight fly in the ointment is that the kernel does not set the 'dev' for
the mei_me devices, but it's always going to be just /dev/mei0, so hardcode it.
2022-10-12 13:17:42 +01:00
Richard Hughes
423637ef80 Use LVFS::UpdateRequestId to create a translated FwupdRequest 2022-10-06 10:30:31 +01:00
Richard Hughes
fc3cfbad92 Do not check the build hash of modular plugins
We removed the abilty to easily build modular plugins, and so we don't need to
worry so much about random 3rd party modules being loaded.
2022-09-30 14:19:56 +01:00
Richard Hughes
1bd8b5d211 trivial: Speed up the build by about 9%
Only build libfwupdplugin source files once; we were only using one
non-exported symbol and so move that to the exported map so we can just link
the library in the self tests.
2022-09-29 12:42:50 +01:00
Richard Hughes
2a5f7766a4 trivial: Remove the deprecated fu_plugin_set_secure_config_value() 2022-09-28 14:42:04 +01:00
Richard Hughes
3dbf5fa8a4 trivial: Remove the deprecated fu_volume_new_esp_default() 2022-09-28 14:42:04 +01:00
Richard Hughes
99e9e5d523 Allow compiling plugin as built-in GObjects
Allow plugins to be built into libfwupdpluginbuiltin.so and created via GType.
2022-09-28 12:52:00 +01:00
Richard Hughes
24db10ac1c trivial: Add fu_plugin_set_context() for future use 2022-09-26 22:24:41 +01:00
Richard Hughes
5d38e0aeea Move the getting the ESP to the context
We now have two plugins getting the ESP values, and we only allow hardcoding
the ESP in uefi_capsule.conf.

Make all this a lot simpler by moving the ESP+BDP code to `FuContext`, which
also means we can handle the override (via the config file) in the engine,
and the override (in the command line tools) using the same mechanism.

Also, automate the migration of the `OverrideESPMountPoint` -> `EspLocation`
when loading the engine.

Fixes https://github.com/fwupd/fwupd/issues/5042
2022-09-22 14:31:06 +01:00
Richard Hughes
e72ed08b56 Always check the BDP partitions when getting all the possible ESPs
Fixes https://github.com/fwupd/fwupd/issues/5035
2022-09-17 13:41:36 +01:00
Richard Hughes
139188a5b0 Allow adding backend tags to devices
This allows the backend to identify the specific device for a specific phase.

For instance, there might be a pre-update runtime, a bootloader and a
post-update runtime and allowing tags to be saved to the backend object allows
us to identify each version of the same physical device.

This takes us one step closer to emulating a complete byte-perfect end-to-end
update without actual hardware installed.
2022-09-14 16:54:55 +01:00
Richard Hughes
bfebede490 Add support for platform capability descriptors so devices can set quirks
This feature adds support for platform capability BOS descriptors which allows
the device itself to ship quirk data.

Use `sudo fwupdtool get-devices --save-backends=FILENAME` to save fake backend
devices to a file. This allows easy creation of self tests that do not require
physical hardware.
2022-09-13 12:07:35 +01:00
Richard Hughes
1d308b2361 trivial: Export fu_device_set_quirk_kv() for future use
This seems like a useful thing regardless.
2022-09-07 14:43:08 +01:00
Richard Hughes
709af2a269 Add shared functionality to get the parsed kernel cmdline 2022-09-02 14:35:48 +01:00
Richard Hughes
16b463334e Export the generic Intel Thunderbolt firmware format
This is being used for other products, e.g. USB4 docks.

If non-Intel firmware is being used (e.g. ASMedia) then the explicit
calls to `fu_intel_thunderbolt_nvm_new()` can be changed to something
like `fu_firmware_new_from_gtypes()` with all the formats listed.
2022-08-30 14:20:14 +01:00
Richard Hughes
a5397c6836 Add a new vfunc to check if two firmwares are compatible
For future use.
2022-08-25 15:30:07 +01:00
Mario Limonciello
04c2186edc Add support for loading default BIOS settings policy
A user can place a JSON file in /etc/fwupd/bios-settings.d/ with
the default desired policy for the machine.

fwupd will load this policy on startup to ensure BIOS settings
are set as desired by the system administrator.
2022-08-24 12:59:42 -05:00
Mario Limonciello
b7b0ce533d trivial: Unify ambiguity between bios-attrs and bios-settings
These are currently used interchangeably since there was indecisiveness
which to use as the feature was being developed.

As outward facing it will be named with "settings", change all uses
in the code to match this.
2022-08-24 07:20:01 -05:00
Richard Hughes
934002553a Allow loading BIOS attributes for host emulation 2022-08-01 13:32:12 +01:00
Richard Hughes
77006b75eb Set the target value on the security attribute
Semantically it is the desire of the security attribute, not the bios
attribute, i.e. you could imagine that a specific attribute would have
to be *foo or bar or baz* for HSI-1 and *only foo* for HSI-2

Also make it easier to add possible BIOS attribute target values in
plugin code.
2022-08-01 07:12:18 +01:00
Mario Limonciello
7660222240 Add a unique identifier to all BIOSAttr objects
This identifier can be used by plugins or the daemon to disambiguate
behavior between two different drivers.

Set it up so that plugins don't NEED to use it, but optionally can
find attributes by either name or ID
2022-07-29 11:31:50 -05:00
Mario Limonciello
5ded4f44fe Add support for reading and writing firmware attributes
This support is comprehensive:
 * Client library support
 * Daemon support
 * plugin support
 * Client tool support (with new commands)
2022-07-28 17:30:57 -05:00
Richard Hughes
829258401e Allow plugins and backends to print debugging information to the console
This is really useful for debugging.
2022-07-28 16:10:06 +01:00
Richard Hughes
221238b4c0 trivial: Allow each device to specify a different acquiesce delay
Different device classes may need different values, and these may need
modifying by quirks. Also use 50ms to flush out any pending events.
2022-07-21 15:27:04 +01:00
Richard Hughes
a06dedb253 trivial: Add a fu_memread_uint24_safe() to make some code more correct 2022-07-14 11:03:13 +01:00
Richard Hughes
7a224007f2 Add support for Flat Image Tree aka FIT firmware 2022-07-08 14:05:20 +01:00
Richard Hughes
f3755ef708 Add support for Flattened Devicetree aka FDT firmware 2022-07-08 14:05:20 +01:00
Richard Hughes
57a1270bad Add fu_firmware_get_parent() for future use
Some firmware stacks images hierarchically, and it's useful to be able
to get the parent when unrolling them out into a linear format.
2022-07-05 16:47:18 +01:00
Richard Hughes
95f7d23d58 Fix FuCfuOffer XML roundtrip 2022-07-01 13:57:18 +01:00