blob: f7814bcc4ceafe3102d2daedbe57b796fdea0e2a [file] [log] [blame]
Richard Hughes7afd7cb2019-08-07 11:42:42 +01001/*
2 * Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1+
5 */
6
7#pragma once
8
9#include <glib-object.h>
10#include <fwupd.h>
11
12#include "fu-firmware-image.h"
13
14G_BEGIN_DECLS
15
16#define FU_TYPE_FIRMWARE (fu_firmware_get_type ())
17G_DECLARE_DERIVABLE_TYPE (FuFirmware, fu_firmware, FU, FIRMWARE, GObject)
18
19struct _FuFirmwareClass
20{
21 GObjectClass parent_class;
22 gboolean (*parse) (FuFirmware *self,
23 GBytes *fw,
24 guint64 addr_start,
25 guint64 addr_end,
26 FwupdInstallFlags flags,
27 GError **error);
28 GBytes *(*write) (FuFirmware *self,
29 GError **error);
Richard Hughescea28de2019-08-09 11:16:40 +010030 void (*to_string) (FuFirmware *self,
31 GString *str);
Richard Hughes7afd7cb2019-08-07 11:42:42 +010032 /*< private >*/
Richard Hughescea28de2019-08-09 11:16:40 +010033 gpointer padding[29];
Richard Hughes7afd7cb2019-08-07 11:42:42 +010034};
35
36FuFirmware *fu_firmware_new (void);
37FuFirmware *fu_firmware_new_from_bytes (GBytes *fw);
38gchar *fu_firmware_to_string (FuFirmware *self);
39
40gboolean fu_firmware_parse (FuFirmware *self,
41 GBytes *fw,
42 FwupdInstallFlags flags,
43 GError **error);
44gboolean fu_firmware_parse_full (FuFirmware *self,
45 GBytes *fw,
46 guint64 addr_start,
47 guint64 addr_end,
48 FwupdInstallFlags flags,
49 GError **error);
50GBytes *fu_firmware_write (FuFirmware *self,
51 GError **error);
52
53void fu_firmware_add_image (FuFirmware *self,
54 FuFirmwareImage *image);
55GPtrArray *fu_firmware_get_images (FuFirmware *self);
56FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self,
57 const gchar *id,
58 GError **error);
59GBytes *fu_firmware_get_image_by_id_bytes (FuFirmware *self,
60 const gchar *id,
61 GError **error);
62FuFirmwareImage *fu_firmware_get_image_by_idx (FuFirmware *self,
63 guint64 idx,
64 GError **error);
65GBytes *fu_firmware_get_image_by_idx_bytes (FuFirmware *self,
66 guint64 idx,
67 GError **error);
68FuFirmwareImage *fu_firmware_get_image_default (FuFirmware *self,
69 GError **error);
70GBytes *fu_firmware_get_image_default_bytes (FuFirmware *self,
71 GError **error);
72
73G_END_DECLS