fwupd/plugins/optionrom/fu-rom.h
Richard Hughes fbd8b5d325 Add fu_device_dump_firmware()
Conceptually we were trying to stuff subtly different actions into one vfunc:

 * Read firmware from the device to update the verification checksums

 * Read a firmware blob from the device for debugging

For the first action we might want to mask out the sections of the flash with
serial numbers (so the verification hashes match the ones published on the LVFS)
and for the second we want just a raw ROM file from the hardware with no
pre-processing that we can compare against an external SPI dumper.

Split out ->dump_firmware to get the raw blob, and allow plugins to also
implement ->read_firmware() if they have to mask out specific offsets or remove
specific images from the FuFirmware container.

In the common case when masking is not required, fall back to using a 'binary'
FuFirmware automatically to make most plugins simpler.
2020-09-24 10:54:27 -05:00

53 lines
1.3 KiB
C

/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <gio/gio.h>
#define FU_TYPE_ROM (fu_rom_get_type ())
G_DECLARE_FINAL_TYPE (FuRom, fu_rom, FU, ROM, GObject)
typedef enum {
FU_ROM_KIND_UNKNOWN,
FU_ROM_KIND_ATI,
FU_ROM_KIND_NVIDIA,
FU_ROM_KIND_INTEL,
FU_ROM_KIND_PCI,
FU_ROM_KIND_LAST
} FuRomKind;
typedef enum {
FU_ROM_LOAD_FLAG_NONE,
FU_ROM_LOAD_FLAG_BLANK_PPID = 1,
FU_ROM_LOAD_FLAG_LAST
} FuRomLoadFlags;
FuRom *fu_rom_new (void);
gboolean fu_rom_load_file (FuRom *self,
GFile *file,
FuRomLoadFlags flags,
GCancellable *cancellable,
GError **error);
gboolean fu_rom_load_data (FuRom *self,
GBytes *blob,
FuRomLoadFlags flags,
GCancellable *cancellable,
GError **error);
gboolean fu_rom_extract_all (FuRom *self,
const gchar *path,
GError **error);
FuRomKind fu_rom_get_kind (FuRom *self);
const gchar *fu_rom_get_version (FuRom *self);
GBytes *fu_rom_get_data (FuRom *self);
guint16 fu_rom_get_vendor (FuRom *self);
guint16 fu_rom_get_model (FuRom *self);
const gchar *fu_rom_kind_to_string (FuRomKind kind);
GBytes *fu_rom_dump_firmware (GFile *file,
GCancellable *cancellable,
GError **error);