fwupd/plugins/uefi-capsule/fu-uefi-device.h
Richard Hughes aaa77c6f51 Allow adding and removing custom flags on devices
The CustomFlags feature is a bit of a hack where we just join the flags
and store in the device metadata section as a string. This makes it
inefficient to check if just one flag exists as we have to split the
string to a temporary array each time.

Rather than adding to the hack by splitting, appending (if not exists)
then joining again, store the flags in the plugin privdata directly.

This allows us to support negating custom properties (e.g. ~hint) and
also allows quirks to append custom values without duplicating them on
each GUID match, e.g.

[USB\VID_17EF&PID_307F]
Plugin = customflag1
[USB\VID_17EF&PID_307F&HUB_0002]
Flags = customflag2

...would result in customflag1,customflag2 which is the same as you'd
get from an enumerated device flag doing the same thing.
2021-06-23 07:59:15 +01:00

82 lines
2.8 KiB
C

/*
* Copyright (C) 2018 Richard Hughes <richard@hughsie.com>
* Copyright (C) 2015 Peter Jones <pjones@redhat.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <fwupdplugin.h>
#include "fu-uefi-device.h"
#include "fu-uefi-update-info.h"
#define FU_TYPE_UEFI_DEVICE (fu_uefi_device_get_type ())
G_DECLARE_FINAL_TYPE (FuUefiDevice, fu_uefi_device, FU, UEFI_DEVICE, FuDevice)
typedef enum {
FU_UEFI_DEVICE_KIND_UNKNOWN,
FU_UEFI_DEVICE_KIND_SYSTEM_FIRMWARE,
FU_UEFI_DEVICE_KIND_DEVICE_FIRMWARE,
FU_UEFI_DEVICE_KIND_UEFI_DRIVER,
FU_UEFI_DEVICE_KIND_FMP,
FU_UEFI_DEVICE_KIND_DELL_TPM_FIRMWARE,
FU_UEFI_DEVICE_KIND_LAST
} FuUefiDeviceKind;
typedef enum {
FU_UEFI_DEVICE_STATUS_SUCCESS = 0x00,
FU_UEFI_DEVICE_STATUS_ERROR_UNSUCCESSFUL = 0x01,
FU_UEFI_DEVICE_STATUS_ERROR_INSUFFICIENT_RESOURCES = 0x02,
FU_UEFI_DEVICE_STATUS_ERROR_INCORRECT_VERSION = 0x03,
FU_UEFI_DEVICE_STATUS_ERROR_INVALID_FORMAT = 0x04,
FU_UEFI_DEVICE_STATUS_ERROR_AUTH_ERROR = 0x05,
FU_UEFI_DEVICE_STATUS_ERROR_PWR_EVT_AC = 0x06,
FU_UEFI_DEVICE_STATUS_ERROR_PWR_EVT_BATT = 0x07,
FU_UEFI_DEVICE_STATUS_LAST
} FuUefiDeviceStatus;
/**
* FU_UEFI_DEVICE_FLAG_NO_UX_CAPSULE:
*
* No not use the additional UX capsule.
*/
#define FU_UEFI_DEVICE_FLAG_NO_UX_CAPSULE (1 << 0)
/**
* FU_UEFI_DEVICE_FLAG_USE_SHIM_UNIQUE:
*
* Use a unique shim filename to work around a common BIOS bug.
*/
#define FU_UEFI_DEVICE_FLAG_USE_SHIM_UNIQUE (1 << 1)
/**
* FU_UEFI_DEVICE_FLAG_USE_LEGACY_BOOTMGR_DESC:
*
* Use the legacy boot manager description to work around a Lenovo BIOS bug.
*/
#define FU_UEFI_DEVICE_FLAG_USE_LEGACY_BOOTMGR_DESC (1 << 2)
FuUefiDevice *fu_uefi_device_new_from_guid (const gchar *guid);
FuUefiDevice *fu_uefi_device_new_from_dev (FuDevice *dev);
void fu_uefi_device_set_esp (FuUefiDevice *self,
FuVolume *esp);
gboolean fu_uefi_device_clear_status (FuUefiDevice *self,
GError **error);
FuUefiDeviceKind fu_uefi_device_get_kind (FuUefiDevice *self);
const gchar *fu_uefi_device_get_guid (FuUefiDevice *self);
guint32 fu_uefi_device_get_version (FuUefiDevice *self);
guint32 fu_uefi_device_get_version_lowest (FuUefiDevice *self);
guint32 fu_uefi_device_get_version_error (FuUefiDevice *self);
guint32 fu_uefi_device_get_capsule_flags (FuUefiDevice *self);
guint64 fu_uefi_device_get_hardware_instance (FuUefiDevice *self);
FuUefiDeviceStatus fu_uefi_device_get_status (FuUefiDevice *self);
const gchar *fu_uefi_device_kind_to_string (FuUefiDeviceKind kind);
const gchar *fu_uefi_device_status_to_string (FuUefiDeviceStatus status);
FuUefiUpdateInfo *fu_uefi_device_load_update_info (FuUefiDevice *self,
GError **error);
gboolean fu_uefi_device_write_update_info (FuUefiDevice *self,
const gchar *filename,
const gchar *varname,
const gchar *guid,
GError **error);