Richard Hughes | 02c90d8 | 2018-08-09 12:13:03 +0100 | [diff] [blame] | 1 | /* |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 2 | * Copyright (C) 2017 Richard Hughes <richard@hughsie.com> |
| 3 | * |
Mario Limonciello | 51308e6 | 2018-05-28 20:05:46 -0500 | [diff] [blame] | 4 | * SPDX-License-Identifier: LGPL-2.1+ |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Richard Hughes | bfd946e | 2019-02-09 08:21:40 +0000 | [diff] [blame] | 7 | #pragma once |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 8 | |
Richard Hughes | adc9dad | 2017-09-04 13:19:27 +0100 | [diff] [blame] | 9 | #include <gio/gio.h> |
Richard Hughes | 52441f2 | 2021-03-12 21:21:10 +0000 | [diff] [blame] | 10 | #include <xmlb.h> |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 11 | |
Richard Hughes | 8f0b2d1 | 2020-08-12 12:41:53 +0100 | [diff] [blame] | 12 | #include "fu-volume.h" |
| 13 | |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 14 | /** |
| 15 | * FuAppFlags: |
| 16 | * @FU_APP_FLAGS_NONE: No flags set |
| 17 | * @FU_APP_FLAGS_NO_IDLE_SOURCES: Disallow idle sources |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 18 | * |
| 19 | * The flags to use when loading an application. |
| 20 | **/ |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame] | 21 | typedef enum { |
| 22 | FU_APP_FLAGS_NONE = 0, |
| 23 | FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0, |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 24 | /*< private >*/ |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame] | 25 | FU_APP_FLAGS_LAST |
| 26 | } FuAppFlags; |
| 27 | |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 28 | /** |
| 29 | * FuDumpFlags: |
| 30 | * @FU_DUMP_FLAGS_NONE: No flags set |
| 31 | * @FU_DUMP_FLAGS_SHOW_ASCII: Show ASCII in debugging dumps |
| 32 | * @FU_DUMP_FLAGS_SHOW_ADDRESSES: Show addresses in debugging dumps |
| 33 | * |
| 34 | * The flags to use when configuring debugging |
| 35 | **/ |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 36 | typedef enum { |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 37 | FU_DUMP_FLAGS_NONE = 0, |
| 38 | FU_DUMP_FLAGS_SHOW_ASCII = 1 << 0, |
| 39 | FU_DUMP_FLAGS_SHOW_ADDRESSES = 1 << 1, |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 40 | /*< private >*/ |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 41 | FU_DUMP_FLAGS_LAST |
| 42 | } FuDumpFlags; |
| 43 | |
Richard Hughes | 37c6a7b | 2019-08-14 21:57:43 +0100 | [diff] [blame] | 44 | typedef guint FuEndianType; |
| 45 | |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 46 | /** |
| 47 | * FuPathKind: |
| 48 | * @FU_PATH_KIND_CACHEDIR_PKG: The cache directory (IE /var/cache/fwupd) |
| 49 | * @FU_PATH_KIND_DATADIR_PKG: The non-volatile data store (IE /usr/share/fwupd) |
| 50 | * @FU_PATH_KIND_EFIAPPDIR: The location to store EFI apps before install (IE /usr/libexec/fwupd/efi) |
| 51 | * @FU_PATH_KIND_LOCALSTATEDIR: The local state directory (IE /var) |
| 52 | * @FU_PATH_KIND_LOCALSTATEDIR_PKG: The local state directory for the package (IE /var/lib/fwupd) |
| 53 | * @FU_PATH_KIND_PLUGINDIR_PKG: The location to look for plugins for package (IE /usr/lib/[triplet]/fwupd-plugins-3) |
| 54 | * @FU_PATH_KIND_SYSCONFDIR: The configuration location (IE /etc) |
| 55 | * @FU_PATH_KIND_SYSCONFDIR_PKG: The package configuration location (IE /etc/fwupd) |
| 56 | * @FU_PATH_KIND_SYSFSDIR_FW: The sysfs firmware location (IE /sys/firmware) |
| 57 | * @FU_PATH_KIND_SYSFSDIR_DRIVERS: The platform sysfs directory (IE /sys/bus/platform/drivers) |
| 58 | * @FU_PATH_KIND_SYSFSDIR_TPM: The TPM sysfs directory (IE /sys/class/tpm) |
Richard Hughes | c368958 | 2020-05-06 12:35:20 +0100 | [diff] [blame] | 59 | * @FU_PATH_KIND_PROCFS: The procfs location (IE /proc) |
Mario Limonciello | d8af5de | 2019-11-04 09:33:34 -0600 | [diff] [blame] | 60 | * @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/) |
Richard Hughes | afdba37 | 2019-11-23 12:57:35 +0000 | [diff] [blame] | 61 | * @FU_PATH_KIND_OFFLINE_TRIGGER: The file for the offline trigger (IE /system-update) |
Mario Limonciello | 9dce1f7 | 2020-02-04 09:12:52 -0600 | [diff] [blame] | 62 | * @FU_PATH_KIND_SYSFSDIR_SECURITY: The sysfs security location (IE /sys/kernel/security) |
Richard Hughes | a715791 | 2020-05-11 17:14:05 +0100 | [diff] [blame] | 63 | * @FU_PATH_KIND_ACPI_TABLES: The location of the ACPI tables |
Daniel Campello | af56c3b | 2021-05-05 15:04:17 +0000 | [diff] [blame] | 64 | * @FU_PATH_KIND_LOCKDIR: The lock directory (IE /run/lock) |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 65 | * |
| 66 | * Path types to use when dynamically determining a path at runtime |
| 67 | **/ |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 68 | typedef enum { |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 69 | FU_PATH_KIND_CACHEDIR_PKG, |
| 70 | FU_PATH_KIND_DATADIR_PKG, |
Mario Limonciello | e6e2bf9 | 2018-07-10 12:11:25 -0500 | [diff] [blame] | 71 | FU_PATH_KIND_EFIAPPDIR, |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 72 | FU_PATH_KIND_LOCALSTATEDIR, |
| 73 | FU_PATH_KIND_LOCALSTATEDIR_PKG, |
| 74 | FU_PATH_KIND_PLUGINDIR_PKG, |
| 75 | FU_PATH_KIND_SYSCONFDIR, |
| 76 | FU_PATH_KIND_SYSCONFDIR_PKG, |
Richard Hughes | 282b10d | 2018-06-22 14:48:00 +0100 | [diff] [blame] | 77 | FU_PATH_KIND_SYSFSDIR_FW, |
Richard Hughes | 83390f6 | 2018-06-22 20:36:46 +0100 | [diff] [blame] | 78 | FU_PATH_KIND_SYSFSDIR_DRIVERS, |
Richard Hughes | b56015e | 2018-12-12 09:25:32 +0000 | [diff] [blame] | 79 | FU_PATH_KIND_SYSFSDIR_TPM, |
Richard Hughes | c368958 | 2020-05-06 12:35:20 +0100 | [diff] [blame] | 80 | FU_PATH_KIND_PROCFS, |
Mario Limonciello | 057c67a | 2019-05-23 10:44:19 -0500 | [diff] [blame] | 81 | FU_PATH_KIND_POLKIT_ACTIONS, |
Richard Hughes | afdba37 | 2019-11-23 12:57:35 +0000 | [diff] [blame] | 82 | FU_PATH_KIND_OFFLINE_TRIGGER, |
Mario Limonciello | 9dce1f7 | 2020-02-04 09:12:52 -0600 | [diff] [blame] | 83 | FU_PATH_KIND_SYSFSDIR_SECURITY, |
Richard Hughes | a715791 | 2020-05-11 17:14:05 +0100 | [diff] [blame] | 84 | FU_PATH_KIND_ACPI_TABLES, |
Daniel Campello | af56c3b | 2021-05-05 15:04:17 +0000 | [diff] [blame] | 85 | FU_PATH_KIND_LOCKDIR, |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 86 | /*< private >*/ |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 87 | FU_PATH_KIND_LAST |
| 88 | } FuPathKind; |
| 89 | |
Richard Hughes | b63cfa9 | 2021-01-05 22:57:12 +0000 | [diff] [blame] | 90 | /** |
| 91 | * FuCpuVendor: |
| 92 | * @FU_CPU_VENDOR_UNKNOWN: Unknown |
| 93 | * @FU_CPU_VENDOR_INTEL: Intel |
| 94 | * @FU_CPU_VENDOR_AMD: AMD |
| 95 | * |
| 96 | * The CPU vendor. |
| 97 | **/ |
| 98 | typedef enum { |
| 99 | FU_CPU_VENDOR_UNKNOWN, |
| 100 | FU_CPU_VENDOR_INTEL, |
| 101 | FU_CPU_VENDOR_AMD, |
| 102 | /*< private >*/ |
| 103 | FU_CPU_VENDOR_LAST |
| 104 | } FuCpuVendor; |
| 105 | |
Richard Hughes | 4d76d18 | 2021-04-06 13:35:15 +0100 | [diff] [blame] | 106 | /** |
| 107 | * FU_BATTERY_VALUE_INVALID: |
| 108 | * |
| 109 | * This value signifies the battery level is either unset, or the value cannot |
| 110 | * be discovered. |
| 111 | */ |
| 112 | #define FU_BATTERY_VALUE_INVALID 101 |
| 113 | |
| 114 | /** |
| 115 | * FuBatteryState: |
| 116 | * @FU_BATTERY_STATE_UNKNOWN: Unknown |
| 117 | * @FU_BATTERY_STATE_CHARGING: Charging |
| 118 | * @FU_BATTERY_STATE_DISCHARGING: Discharging |
| 119 | * @FU_BATTERY_STATE_EMPTY: Empty |
| 120 | * @FU_BATTERY_STATE_FULLY_CHARGED: Fully charged |
| 121 | * |
| 122 | * The device battery state. |
| 123 | **/ |
| 124 | typedef enum { |
| 125 | FU_BATTERY_STATE_UNKNOWN, |
| 126 | FU_BATTERY_STATE_CHARGING, |
| 127 | FU_BATTERY_STATE_DISCHARGING, |
| 128 | FU_BATTERY_STATE_EMPTY, |
| 129 | FU_BATTERY_STATE_FULLY_CHARGED, |
| 130 | /*< private >*/ |
| 131 | FU_BATTERY_STATE_LAST |
| 132 | } FuBatteryState; |
| 133 | |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 134 | typedef void (*FuOutputHandler) (const gchar *line, |
| 135 | gpointer user_data); |
| 136 | |
| 137 | gboolean fu_common_spawn_sync (const gchar * const *argv, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 138 | FuOutputHandler handler_cb, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 139 | gpointer handler_user_data, |
Richard Hughes | b768e4d | 2019-02-26 13:55:18 +0000 | [diff] [blame] | 140 | guint timeout_ms, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 141 | GCancellable *cancellable, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 142 | GError **error) |
| 143 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 144 | |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 145 | gchar *fu_common_get_path (FuPathKind path_kind); |
Richard Hughes | 484ee29 | 2019-03-22 16:10:50 +0000 | [diff] [blame] | 146 | gchar *fu_common_realpath (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 147 | GError **error) |
| 148 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | a84d7a7 | 2020-05-06 12:11:51 +0100 | [diff] [blame] | 149 | GPtrArray *fu_common_filename_glob (const gchar *directory, |
| 150 | const gchar *pattern, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 151 | GError **error) |
| 152 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 5c508de | 2019-11-22 09:57:34 +0000 | [diff] [blame] | 153 | gboolean fu_common_fnmatch (const gchar *pattern, |
| 154 | const gchar *str); |
Richard Hughes | 954dd9f | 2017-08-08 13:36:25 +0100 | [diff] [blame] | 155 | gboolean fu_common_rmtree (const gchar *directory, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 156 | GError **error) |
| 157 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 89e968b | 2018-03-07 10:01:08 +0000 | [diff] [blame] | 158 | GPtrArray *fu_common_get_files_recursive (const gchar *path, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 159 | GError **error) |
| 160 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 7ee42fe | 2017-08-15 14:06:21 +0100 | [diff] [blame] | 161 | gboolean fu_common_mkdir_parent (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 162 | GError **error) |
| 163 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 164 | gboolean fu_common_set_contents_bytes (const gchar *filename, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 165 | GBytes *bytes, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 166 | GError **error) |
| 167 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | d0d2ae6 | 2017-08-08 12:22:30 +0100 | [diff] [blame] | 168 | GBytes *fu_common_get_contents_bytes (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 169 | GError **error) |
| 170 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 171 | GBytes *fu_common_get_contents_fd (gint fd, |
| 172 | gsize count, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 173 | GError **error) |
| 174 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 94f939a | 2017-08-08 12:21:39 +0100 | [diff] [blame] | 175 | gboolean fu_common_extract_archive (GBytes *blob, |
| 176 | const gchar *dir, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 177 | GError **error) |
| 178 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 41cbe2a | 2017-08-08 14:13:35 +0100 | [diff] [blame] | 179 | GBytes *fu_common_firmware_builder (GBytes *bytes, |
| 180 | const gchar *script_fn, |
| 181 | const gchar *output_fn, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 182 | GError **error) |
| 183 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | e82eef3 | 2018-05-20 10:41:26 +0100 | [diff] [blame] | 184 | GError *fu_common_error_array_get_best (GPtrArray *errors); |
Richard Hughes | 73bf233 | 2018-08-28 09:38:09 +0100 | [diff] [blame] | 185 | guint64 fu_common_strtoull (const gchar *str); |
Richard Hughes | 22367e7 | 2018-08-30 10:24:04 +0100 | [diff] [blame] | 186 | gchar *fu_common_find_program_in_path (const gchar *basename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 187 | GError **error) |
| 188 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | a574a75 | 2018-08-31 13:31:03 +0100 | [diff] [blame] | 189 | gchar *fu_common_strstrip (const gchar *str); |
Richard Hughes | e59cb9a | 2018-12-05 14:37:40 +0000 | [diff] [blame] | 190 | void fu_common_dump_raw (const gchar *log_domain, |
| 191 | const gchar *title, |
| 192 | const guint8 *data, |
| 193 | gsize len); |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 194 | void fu_common_dump_full (const gchar *log_domain, |
| 195 | const gchar *title, |
| 196 | const guint8 *data, |
| 197 | gsize len, |
| 198 | guint columns, |
| 199 | FuDumpFlags flags); |
Richard Hughes | e59cb9a | 2018-12-05 14:37:40 +0000 | [diff] [blame] | 200 | void fu_common_dump_bytes (const gchar *log_domain, |
| 201 | const gchar *title, |
| 202 | GBytes *bytes); |
Richard Hughes | fc90f39 | 2019-01-15 21:21:16 +0000 | [diff] [blame] | 203 | GBytes *fu_common_bytes_align (GBytes *bytes, |
| 204 | gsize blksz, |
| 205 | gchar padval); |
Richard Hughes | 7f6f525 | 2021-04-09 17:09:57 +0100 | [diff] [blame] | 206 | const guint8 *fu_bytes_get_data_safe (GBytes *bytes, |
| 207 | gsize *bufsz, |
| 208 | GError **error); |
Richard Hughes | 3699946 | 2019-03-19 20:23:29 +0000 | [diff] [blame] | 209 | gboolean fu_common_bytes_is_empty (GBytes *bytes); |
Richard Hughes | 2aad104 | 2019-03-21 09:03:32 +0000 | [diff] [blame] | 210 | gboolean fu_common_bytes_compare (GBytes *bytes1, |
| 211 | GBytes *bytes2, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 212 | GError **error) |
| 213 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 38245ff | 2019-09-18 14:46:09 +0100 | [diff] [blame] | 214 | gboolean fu_common_bytes_compare_raw (const guint8 *buf1, |
| 215 | gsize bufsz1, |
| 216 | const guint8 *buf2, |
| 217 | gsize bufsz2, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 218 | GError **error) |
| 219 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 220 | GBytes *fu_common_bytes_pad (GBytes *bytes, |
| 221 | gsize sz); |
Richard Hughes | 05e3377 | 2020-12-08 18:37:02 +0000 | [diff] [blame] | 222 | GBytes *fu_common_bytes_new_offset (GBytes *bytes, |
| 223 | gsize offset, |
| 224 | gsize length, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 225 | GError **error) |
| 226 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | ae96a1f | 2019-09-23 11:16:36 +0100 | [diff] [blame] | 227 | gsize fu_common_strwidth (const gchar *text); |
Richard Hughes | 9b11af9 | 2021-02-04 20:28:49 +0000 | [diff] [blame] | 228 | guint8 *fu_memdup_safe (const guint8 *src, |
| 229 | gsize n, |
| 230 | GError **error) |
| 231 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 5308ea4 | 2019-08-09 12:25:13 +0100 | [diff] [blame] | 232 | gboolean fu_memcpy_safe (guint8 *dst, |
| 233 | gsize dst_sz, |
| 234 | gsize dst_offset, |
| 235 | const guint8 *src, |
| 236 | gsize src_sz, |
| 237 | gsize src_offset, |
| 238 | gsize n, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 239 | GError **error) |
| 240 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | c21a0b9 | 2019-10-24 12:24:37 +0100 | [diff] [blame] | 241 | gboolean fu_common_read_uint8_safe (const guint8 *buf, |
| 242 | gsize bufsz, |
| 243 | gsize offset, |
| 244 | guint8 *value, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 245 | GError **error) |
| 246 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 80768f5 | 2019-10-22 07:19:14 +0100 | [diff] [blame] | 247 | gboolean fu_common_read_uint16_safe (const guint8 *buf, |
| 248 | gsize bufsz, |
| 249 | gsize offset, |
| 250 | guint16 *value, |
| 251 | FuEndianType endian, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 252 | GError **error) |
| 253 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 80768f5 | 2019-10-22 07:19:14 +0100 | [diff] [blame] | 254 | gboolean fu_common_read_uint32_safe (const guint8 *buf, |
| 255 | gsize bufsz, |
| 256 | gsize offset, |
| 257 | guint32 *value, |
| 258 | FuEndianType endian, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 259 | GError **error) |
| 260 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 261 | gboolean fu_common_read_uint64_safe (const guint8 *buf, |
| 262 | gsize bufsz, |
| 263 | gsize offset, |
| 264 | guint64 *value, |
| 265 | FuEndianType endian, |
| 266 | GError **error) |
| 267 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 32ffdb2 | 2021-03-04 17:38:12 +0000 | [diff] [blame] | 268 | gboolean fu_common_write_uint8_safe (guint8 *buf, |
| 269 | gsize bufsz, |
| 270 | gsize offset, |
| 271 | guint8 value, |
| 272 | GError **error) |
| 273 | G_GNUC_WARN_UNUSED_RESULT; |
| 274 | gboolean fu_common_write_uint16_safe (guint8 *buf, |
| 275 | gsize bufsz, |
| 276 | gsize offset, |
| 277 | guint16 value, |
| 278 | FuEndianType endian, |
| 279 | GError **error) |
| 280 | G_GNUC_WARN_UNUSED_RESULT; |
| 281 | gboolean fu_common_write_uint32_safe (guint8 *buf, |
| 282 | gsize bufsz, |
| 283 | gsize offset, |
| 284 | guint32 value, |
| 285 | FuEndianType endian, |
| 286 | GError **error) |
| 287 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 288 | gboolean fu_common_write_uint64_safe (guint8 *buf, |
| 289 | gsize bufsz, |
| 290 | gsize offset, |
| 291 | guint64 value, |
| 292 | FuEndianType endian, |
| 293 | GError **error) |
| 294 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 295 | |
Richard Hughes | a2a8f8e | 2020-10-20 09:27:26 +0100 | [diff] [blame] | 296 | void fu_byte_array_set_size (GByteArray *array, |
| 297 | guint length); |
Richard Hughes | 74db340 | 2021-03-11 13:20:25 +0000 | [diff] [blame] | 298 | void fu_byte_array_set_size_full (GByteArray *array, |
| 299 | guint length, |
| 300 | guint8 data); |
| 301 | void fu_byte_array_align_up (GByteArray *array, |
| 302 | guint8 alignment, |
| 303 | guint8 data); |
Richard Hughes | 37c6a7b | 2019-08-14 21:57:43 +0100 | [diff] [blame] | 304 | void fu_byte_array_append_uint8 (GByteArray *array, |
| 305 | guint8 data); |
| 306 | void fu_byte_array_append_uint16 (GByteArray *array, |
| 307 | guint16 data, |
| 308 | FuEndianType endian); |
| 309 | void fu_byte_array_append_uint32 (GByteArray *array, |
| 310 | guint32 data, |
| 311 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 312 | void fu_byte_array_append_uint64 (GByteArray *array, |
| 313 | guint64 data, |
| 314 | FuEndianType endian); |
Richard Hughes | e9664e8 | 2021-03-10 13:38:06 +0000 | [diff] [blame] | 315 | void fu_byte_array_append_bytes (GByteArray *array, |
| 316 | GBytes *bytes); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 317 | |
| 318 | void fu_common_write_uint16 (guint8 *buf, |
| 319 | guint16 val_native, |
| 320 | FuEndianType endian); |
| 321 | void fu_common_write_uint32 (guint8 *buf, |
| 322 | guint32 val_native, |
| 323 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 324 | void fu_common_write_uint64 (guint8 *buf, |
| 325 | guint64 val_native, |
| 326 | FuEndianType endian); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 327 | guint16 fu_common_read_uint16 (const guint8 *buf, |
| 328 | FuEndianType endian); |
| 329 | guint32 fu_common_read_uint32 (const guint8 *buf, |
| 330 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 331 | guint64 fu_common_read_uint64 (const guint8 *buf, |
| 332 | FuEndianType endian); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 333 | |
Richard Hughes | 83e56c1 | 2018-10-10 20:24:41 +0100 | [diff] [blame] | 334 | guint fu_common_string_replace (GString *string, |
| 335 | const gchar *search, |
| 336 | const gchar *replace); |
Richard Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 337 | void fu_common_string_append_kv (GString *str, |
Richard Hughes | 6e3e62b | 2019-08-14 10:43:08 +0100 | [diff] [blame] | 338 | guint idt, |
Richard Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 339 | const gchar *key, |
| 340 | const gchar *value); |
Richard Hughes | 6e3e62b | 2019-08-14 10:43:08 +0100 | [diff] [blame] | 341 | void fu_common_string_append_ku (GString *str, |
| 342 | guint idt, |
| 343 | const gchar *key, |
| 344 | guint64 value); |
| 345 | void fu_common_string_append_kx (GString *str, |
| 346 | guint idt, |
| 347 | const gchar *key, |
| 348 | guint64 value); |
| 349 | void fu_common_string_append_kb (GString *str, |
| 350 | guint idt, |
| 351 | const gchar *key, |
| 352 | gboolean value); |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 353 | gchar **fu_common_strnsplit (const gchar *str, |
| 354 | gsize sz, |
| 355 | const gchar *delimiter, |
| 356 | gint max_tokens); |
Richard Hughes | 364e268 | 2021-01-05 14:38:15 +0000 | [diff] [blame] | 357 | gchar *fu_common_strsafe (const gchar *str, |
| 358 | gsize maxsz); |
Richard Hughes | e52e1b4 | 2021-01-26 09:59:15 +0000 | [diff] [blame] | 359 | gchar *fu_common_strjoin_array (const gchar *separator, |
| 360 | GPtrArray *array); |
Mario Limonciello | 9dce1f7 | 2020-02-04 09:12:52 -0600 | [diff] [blame] | 361 | gboolean fu_common_kernel_locked_down (void); |
Richard Hughes | bd1dc2a | 2020-08-20 15:35:28 +0100 | [diff] [blame] | 362 | gboolean fu_common_cpuid (guint32 leaf, |
| 363 | guint32 *eax, |
| 364 | guint32 *ebx, |
| 365 | guint32 *ecx, |
| 366 | guint32 *edx, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 367 | GError **error) |
| 368 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | b63cfa9 | 2021-01-05 22:57:12 +0000 | [diff] [blame] | 369 | FuCpuVendor fu_common_get_cpu_vendor (void); |
Richard Hughes | 3611147 | 2020-08-12 15:04:24 +0100 | [diff] [blame] | 370 | gboolean fu_common_is_live_media (void); |
Richard Hughes | 68175e9 | 2021-01-14 09:43:33 +0000 | [diff] [blame] | 371 | guint64 fu_common_get_memory_size (void); |
Richard Hughes | 8f0b2d1 | 2020-08-12 12:41:53 +0100 | [diff] [blame] | 372 | GPtrArray *fu_common_get_volumes_by_kind (const gchar *kind, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 373 | GError **error) |
| 374 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 0bdf561 | 2020-10-30 14:56:22 +0000 | [diff] [blame] | 375 | FuVolume *fu_common_get_volume_by_device (const gchar *device, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 376 | GError **error) |
| 377 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 0bdf561 | 2020-10-30 14:56:22 +0000 | [diff] [blame] | 378 | FuVolume *fu_common_get_volume_by_devnum (guint32 devnum, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 379 | GError **error) |
| 380 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 8f0b2d1 | 2020-08-12 12:41:53 +0100 | [diff] [blame] | 381 | FuVolume *fu_common_get_esp_for_path (const gchar *esp_path, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 382 | GError **error) |
| 383 | G_GNUC_WARN_UNUSED_RESULT; |
| 384 | FuVolume *fu_common_get_esp_default (GError **error) |
| 385 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 6f5e35a | 2020-09-25 14:14:52 +0100 | [diff] [blame] | 386 | |
Richard Hughes | 44ae2a7 | 2020-09-25 18:00:21 +0100 | [diff] [blame] | 387 | guint8 fu_common_crc8 (const guint8 *buf, |
| 388 | gsize bufsz); |
Richard Hughes | 6f5e35a | 2020-09-25 14:14:52 +0100 | [diff] [blame] | 389 | guint16 fu_common_crc16 (const guint8 *buf, |
| 390 | gsize bufsz); |
| 391 | guint32 fu_common_crc32 (const guint8 *buf, |
| 392 | gsize bufsz); |
| 393 | guint32 fu_common_crc32_full (const guint8 *buf, |
| 394 | gsize bufsz, |
| 395 | guint32 crc, |
| 396 | guint32 polynomial); |
Richard Hughes | c754667 | 2021-01-28 10:53:30 +0000 | [diff] [blame] | 397 | gchar *fu_common_uri_get_scheme (const gchar *uri); |
Richard Hughes | 58d52ed | 2021-03-10 13:42:59 +0000 | [diff] [blame] | 398 | gsize fu_common_align_up (gsize value, |
| 399 | guint8 alignment); |
Richard Hughes | 4d76d18 | 2021-04-06 13:35:15 +0100 | [diff] [blame] | 400 | const gchar *fu_battery_state_to_string (FuBatteryState battery_state); |
Richard Hughes | 52441f2 | 2021-03-12 21:21:10 +0000 | [diff] [blame] | 401 | |
| 402 | void fu_xmlb_builder_insert_kv (XbBuilderNode *bn, |
| 403 | const gchar *key, |
| 404 | const gchar *value); |
| 405 | void fu_xmlb_builder_insert_kx (XbBuilderNode *bn, |
| 406 | const gchar *key, |
| 407 | guint64 value); |
| 408 | void fu_xmlb_builder_insert_kb (XbBuilderNode *bn, |
| 409 | const gchar *key, |
| 410 | gboolean value); |