blob: 0e2821d343c7da26ae184f186da3b531625dd587 [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,
Richard Hughes6e3e62b2019-08-14 10:43:08 +010031 guint indent,
Richard Hughescea28de2019-08-09 11:16:40 +010032 GString *str);
Richard Hughes7afd7cb2019-08-07 11:42:42 +010033 /*< private >*/
Richard Hughescea28de2019-08-09 11:16:40 +010034 gpointer padding[29];
Richard Hughes7afd7cb2019-08-07 11:42:42 +010035};
36
37FuFirmware *fu_firmware_new (void);
38FuFirmware *fu_firmware_new_from_bytes (GBytes *fw);
39gchar *fu_firmware_to_string (FuFirmware *self);
40
41gboolean fu_firmware_parse (FuFirmware *self,
42 GBytes *fw,
43 FwupdInstallFlags flags,
44 GError **error);
45gboolean fu_firmware_parse_full (FuFirmware *self,
46 GBytes *fw,
47 guint64 addr_start,
48 guint64 addr_end,
49 FwupdInstallFlags flags,
50 GError **error);
51GBytes *fu_firmware_write (FuFirmware *self,
52 GError **error);
53
54void fu_firmware_add_image (FuFirmware *self,
55 FuFirmwareImage *image);
56GPtrArray *fu_firmware_get_images (FuFirmware *self);
57FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self,
58 const gchar *id,
59 GError **error);
60GBytes *fu_firmware_get_image_by_id_bytes (FuFirmware *self,
61 const gchar *id,
62 GError **error);
63FuFirmwareImage *fu_firmware_get_image_by_idx (FuFirmware *self,
64 guint64 idx,
65 GError **error);
66GBytes *fu_firmware_get_image_by_idx_bytes (FuFirmware *self,
67 guint64 idx,
68 GError **error);
69FuFirmwareImage *fu_firmware_get_image_default (FuFirmware *self,
70 GError **error);
71GBytes *fu_firmware_get_image_default_bytes (FuFirmware *self,
72 GError **error);
73
74G_END_DECLS