Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | G_BEGIN_DECLS |
| 15 | |
| 16 | #define FU_TYPE_FIRMWARE (fu_firmware_get_type ()) |
| 17 | G_DECLARE_DERIVABLE_TYPE (FuFirmware, fu_firmware, FU, FIRMWARE, GObject) |
| 18 | |
| 19 | struct _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 Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 30 | void (*to_string) (FuFirmware *self, |
| 31 | GString *str); |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 32 | /*< private >*/ |
Richard Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 33 | gpointer padding[29]; |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | FuFirmware *fu_firmware_new (void); |
| 37 | FuFirmware *fu_firmware_new_from_bytes (GBytes *fw); |
| 38 | gchar *fu_firmware_to_string (FuFirmware *self); |
| 39 | |
| 40 | gboolean fu_firmware_parse (FuFirmware *self, |
| 41 | GBytes *fw, |
| 42 | FwupdInstallFlags flags, |
| 43 | GError **error); |
| 44 | gboolean fu_firmware_parse_full (FuFirmware *self, |
| 45 | GBytes *fw, |
| 46 | guint64 addr_start, |
| 47 | guint64 addr_end, |
| 48 | FwupdInstallFlags flags, |
| 49 | GError **error); |
| 50 | GBytes *fu_firmware_write (FuFirmware *self, |
| 51 | GError **error); |
| 52 | |
| 53 | void fu_firmware_add_image (FuFirmware *self, |
| 54 | FuFirmwareImage *image); |
| 55 | GPtrArray *fu_firmware_get_images (FuFirmware *self); |
| 56 | FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self, |
| 57 | const gchar *id, |
| 58 | GError **error); |
| 59 | GBytes *fu_firmware_get_image_by_id_bytes (FuFirmware *self, |
| 60 | const gchar *id, |
| 61 | GError **error); |
| 62 | FuFirmwareImage *fu_firmware_get_image_by_idx (FuFirmware *self, |
| 63 | guint64 idx, |
| 64 | GError **error); |
| 65 | GBytes *fu_firmware_get_image_by_idx_bytes (FuFirmware *self, |
| 66 | guint64 idx, |
| 67 | GError **error); |
| 68 | FuFirmwareImage *fu_firmware_get_image_default (FuFirmware *self, |
| 69 | GError **error); |
| 70 | GBytes *fu_firmware_get_image_default_bytes (FuFirmware *self, |
| 71 | GError **error); |
| 72 | |
| 73 | G_END_DECLS |