Top | ![]() |
![]() |
![]() |
![]() |
#define | FU_TYPE_FIRMWARE |
struct | FuFirmwareClass |
#define | FU_FIRMWARE_FLAG_NONE |
#define | FU_FIRMWARE_FLAG_DEDUPE_ID |
#define | FU_FIRMWARE_FLAG_DEDUPE_IDX |
#define | FU_FIRMWARE_FLAG_HAS_CHECKSUM |
#define | FU_FIRMWARE_FLAG_HAS_VID_PID |
typedef | FuFirmwareFlags |
FuFirmware |
An object that represents a firmware file. See also: FuDfuFirmware, FuIhexFirmware, FuSrecFirmware
const gchar *
fu_firmware_flag_to_string (FuFirmwareFlags flag
);
Converts a FuFirmwareFlags to a string.
Since: 1.5.0
FuFirmwareFlags
fu_firmware_flag_from_string (const gchar *flag
);
Converts a string to a FuFirmwareFlags.
Since: 1.5.0
FuFirmware *
fu_firmware_new (void
);
Creates an empty firmware object.
Since: 1.3.1
FuFirmware *
fu_firmware_new_from_bytes (GBytes *fw
);
Creates a firmware object with the provided image set as default.
Since: 1.3.1
FuFirmware * fu_firmware_new_from_gtypes (GBytes *fw
,FwupdInstallFlags flags
,GError **error
,...
);
Tries to parse the firmware with each GType in order.
fw |
a GBytes |
|
flags |
a FwupdInstallFlags, e.g. |
|
error |
a GError or |
[nullable] |
... |
An array of GTypes, ending with |
Since: 1.5.6
gchar *
fu_firmware_to_string (FuFirmware *self
);
This allows us to easily print the object.
Since: 1.3.1
const gchar *
fu_firmware_get_version (FuFirmware *self
);
Gets an optional version that represents the firmware.
Since: 1.3.3
void fu_firmware_set_version (FuFirmware *self
,const gchar *version
);
Sets an optional version that represents the firmware.
Since: 1.3.3
guint64
fu_firmware_get_version_raw (FuFirmware *self
);
Gets an raw version that represents the firmware. This is most frequently
used when building firmware with <version_raw>0x123456</version_raw>
in a
firmware.builder.xml
file to avoid string splitting and sanity checks.
Since: 1.5.7
void fu_firmware_set_version_raw (FuFirmware *self
,guint64 version_raw
);
Sets an raw version that represents the firmware.
This is optional, and is typically only used for debugging.
Since: 1.5.7
void fu_firmware_add_flag (FuFirmware *firmware
,FuFirmwareFlags flag
);
Adds a specific firmware flag to the firmware.
Since: 1.5.0
gboolean fu_firmware_has_flag (FuFirmware *firmware
,FuFirmwareFlags flag
);
Finds if the firmware has a specific firmware flag.
Since: 1.5.0
gboolean fu_firmware_tokenize (FuFirmware *self
,GBytes *fw
,FwupdInstallFlags flags
,GError **error
);
Tokenizes a firmware, typically breaking the firmware into records.
Records can be enumerated using subclass-specific functionality, for example
using fu_srec_firmware_get_records()
.
self |
||
fw |
A GBytes |
|
flags |
some FwupdInstallFlags, e.g. |
|
error |
A GError, or |
Since: 1.3.2
gboolean fu_firmware_build (FuFirmware *self
,XbNode *n
,GError **error
);
Builds a firmware from an XML manifest. The manifest would typically have the following form:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?xml version="1.0" encoding="UTF-8"?> <firmware gtype="FuBcm57xxFirmware"> <version>1.2.3</version> <image gtype="FuBcm57xxStage1Image"> <version>7.8.9</version> <id>stage1</id> <idx>0x01</idx> <filename>stage1.bin</filename> </image> <image gtype="FuBcm57xxStage2Image"> <id>stage2</id> <data/> <!-- empty! --> </image> <image gtype="FuBcm57xxDictImage"> <id>ape</id> <addr>0x7</addr> <data>aGVsbG8gd29ybGQ=</data> <!-- base64 --> </image> </firmware> |
This would be used in a build-system to merge images from generated files:
fwupdtool firmware-build fw.builder.xml test.fw
Static binary content can be specified in the <image>/<data>
sections and
is encoded as base64 text if not empty.
Additionally, extra nodes can be included under <image>
and <firmware>
which can be parsed by the subclassed objects. You should verify the
subclassed object FuFirmwareImage->build
vfunc for the specific additional
options supported.
Plugins should manually g_type_ensure()
subclassed image objects if not
constructed as part of the plugin fu_plugin_init()
or fu_plugin_setup()
functions.
Since: 1.5.0
gboolean fu_firmware_parse (FuFirmware *self
,GBytes *fw
,FwupdInstallFlags flags
,GError **error
);
Parses a firmware, typically breaking the firmware into images.
self |
||
fw |
A GBytes |
|
flags |
some FwupdInstallFlags, e.g. |
|
error |
A GError, or |
Since: 1.3.1
gboolean fu_firmware_parse_file (FuFirmware *self
,GFile *file
,FwupdInstallFlags flags
,GError **error
);
Parses a firmware file, typically breaking the firmware into images.
self |
||
file |
A GFile |
|
flags |
some FwupdInstallFlags, e.g. |
|
error |
A GError, or |
Since: 1.3.3
gboolean fu_firmware_parse_full (FuFirmware *self
,GBytes *fw
,guint64 addr_start
,guint64 addr_end
,FwupdInstallFlags flags
,GError **error
);
Parses a firmware, typically breaking the firmware into images.
self |
||
fw |
A GBytes |
|
addr_start |
Start address, useful for ignoring a bootloader |
|
addr_end |
End address, useful for ignoring config bytes |
|
flags |
some FwupdInstallFlags, e.g. |
|
error |
A GError, or |
Since: 1.3.1
GBytes * fu_firmware_write (FuFirmware *self
,GError **error
);
Writes a firmware, typically packing the images into a binary blob.
Since: 1.3.1
gboolean fu_firmware_write_file (FuFirmware *self
,GFile *file
,GError **error
);
Writes a firmware, typically packing the images into a binary blob.
Since: 1.3.3
void fu_firmware_add_image (FuFirmware *self
,FuFirmwareImage *img
);
Adds an image to the firmware.
If FU_FIRMWARE_FLAG_DEDUPE_ID
is set, an image with the same ID is already
present it is replaced.
Since: 1.3.1
gboolean fu_firmware_remove_image (FuFirmware *self
,FuFirmwareImage *img
,GError **error
);
Remove an image from the firmware.
Since: 1.5.0
gboolean fu_firmware_remove_image_by_idx (FuFirmware *self
,guint64 idx
,GError **error
);
Removes the first image from the firmware matching the index.
Since: 1.5.0
gboolean fu_firmware_remove_image_by_id (FuFirmware *self
,const gchar *id
,GError **error
);
Removes the first image from the firmware matching the ID.
Since: 1.5.0
GPtrArray *
fu_firmware_get_images (FuFirmware *self
);
Returns all the images in the firmware.
Since: 1.3.1
FuFirmwareImage * fu_firmware_get_image_by_id (FuFirmware *self
,const gchar *id
,GError **error
);
Gets the firmware image using the image ID.
Since: 1.3.1
GBytes * fu_firmware_get_image_by_id_bytes (FuFirmware *self
,const gchar *id
,GError **error
);
Gets the firmware image bytes using the image ID.
Since: 1.3.1
FuFirmwareImage * fu_firmware_get_image_by_idx (FuFirmware *self
,guint64 idx
,GError **error
);
Gets the firmware image using the image index.
Since: 1.3.1
GBytes * fu_firmware_get_image_by_idx_bytes (FuFirmware *self
,guint64 idx
,GError **error
);
Gets the firmware image bytes using the image index.
Since: 1.3.1
FuFirmwareImage * fu_firmware_get_image_by_checksum (FuFirmware *self
,const gchar *checksum
,GError **error
);
Gets the firmware image using the image checksum. The checksum type is guessed based on the length of the input string.
Since: 1.5.5
FuFirmwareImage * fu_firmware_get_image_default (FuFirmware *self
,GError **error
);
Gets the default firmware image.
NOTE: If the firmware has multiple images included then fu_firmware_get_image_by_id()
or fu_firmware_get_image_by_idx()
must be used rather than this function.
Since: 1.3.1
GBytes * fu_firmware_get_image_default_bytes (FuFirmware *self
,GError **error
);
Gets the default firmware image.
Since: 1.3.1
struct FuFirmwareClass { GObjectClass parent_class; gboolean (*parse) (FuFirmware *self, GBytes *fw, guint64 addr_start, guint64 addr_end, FwupdInstallFlags flags, GError **error); GBytes *(*write) (FuFirmware *self, GError **error); void (*to_string) (FuFirmware *self, guint indent, GString *str); gboolean (*tokenize) (FuFirmware *self, GBytes *fw, FwupdInstallFlags flags, GError **error); gboolean (*build) (FuFirmware *self, XbNode *n, GError **error); };