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 |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 64 | * |
| 65 | * Path types to use when dynamically determining a path at runtime |
| 66 | **/ |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 67 | typedef enum { |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 68 | FU_PATH_KIND_CACHEDIR_PKG, |
| 69 | FU_PATH_KIND_DATADIR_PKG, |
Mario Limonciello | e6e2bf9 | 2018-07-10 12:11:25 -0500 | [diff] [blame] | 70 | FU_PATH_KIND_EFIAPPDIR, |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 71 | FU_PATH_KIND_LOCALSTATEDIR, |
| 72 | FU_PATH_KIND_LOCALSTATEDIR_PKG, |
| 73 | FU_PATH_KIND_PLUGINDIR_PKG, |
| 74 | FU_PATH_KIND_SYSCONFDIR, |
| 75 | FU_PATH_KIND_SYSCONFDIR_PKG, |
Richard Hughes | 282b10d | 2018-06-22 14:48:00 +0100 | [diff] [blame] | 76 | FU_PATH_KIND_SYSFSDIR_FW, |
Richard Hughes | 83390f6 | 2018-06-22 20:36:46 +0100 | [diff] [blame] | 77 | FU_PATH_KIND_SYSFSDIR_DRIVERS, |
Richard Hughes | b56015e | 2018-12-12 09:25:32 +0000 | [diff] [blame] | 78 | FU_PATH_KIND_SYSFSDIR_TPM, |
Richard Hughes | c368958 | 2020-05-06 12:35:20 +0100 | [diff] [blame] | 79 | FU_PATH_KIND_PROCFS, |
Mario Limonciello | 057c67a | 2019-05-23 10:44:19 -0500 | [diff] [blame] | 80 | FU_PATH_KIND_POLKIT_ACTIONS, |
Richard Hughes | afdba37 | 2019-11-23 12:57:35 +0000 | [diff] [blame] | 81 | FU_PATH_KIND_OFFLINE_TRIGGER, |
Mario Limonciello | 9dce1f7 | 2020-02-04 09:12:52 -0600 | [diff] [blame] | 82 | FU_PATH_KIND_SYSFSDIR_SECURITY, |
Richard Hughes | a715791 | 2020-05-11 17:14:05 +0100 | [diff] [blame] | 83 | FU_PATH_KIND_ACPI_TABLES, |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 84 | /*< private >*/ |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 85 | FU_PATH_KIND_LAST |
| 86 | } FuPathKind; |
| 87 | |
Richard Hughes | b63cfa9 | 2021-01-05 22:57:12 +0000 | [diff] [blame] | 88 | /** |
| 89 | * FuCpuVendor: |
| 90 | * @FU_CPU_VENDOR_UNKNOWN: Unknown |
| 91 | * @FU_CPU_VENDOR_INTEL: Intel |
| 92 | * @FU_CPU_VENDOR_AMD: AMD |
| 93 | * |
| 94 | * The CPU vendor. |
| 95 | **/ |
| 96 | typedef enum { |
| 97 | FU_CPU_VENDOR_UNKNOWN, |
| 98 | FU_CPU_VENDOR_INTEL, |
| 99 | FU_CPU_VENDOR_AMD, |
| 100 | /*< private >*/ |
| 101 | FU_CPU_VENDOR_LAST |
| 102 | } FuCpuVendor; |
| 103 | |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 104 | typedef void (*FuOutputHandler) (const gchar *line, |
| 105 | gpointer user_data); |
| 106 | |
| 107 | gboolean fu_common_spawn_sync (const gchar * const *argv, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 108 | FuOutputHandler handler_cb, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 109 | gpointer handler_user_data, |
Richard Hughes | b768e4d | 2019-02-26 13:55:18 +0000 | [diff] [blame] | 110 | guint timeout_ms, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 111 | GCancellable *cancellable, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 112 | GError **error) |
| 113 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 114 | |
Richard Hughes | 4be17d1 | 2018-05-30 20:36:29 +0100 | [diff] [blame] | 115 | gchar *fu_common_get_path (FuPathKind path_kind); |
Richard Hughes | 484ee29 | 2019-03-22 16:10:50 +0000 | [diff] [blame] | 116 | gchar *fu_common_realpath (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 117 | GError **error) |
| 118 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | a84d7a7 | 2020-05-06 12:11:51 +0100 | [diff] [blame] | 119 | GPtrArray *fu_common_filename_glob (const gchar *directory, |
| 120 | const gchar *pattern, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 121 | GError **error) |
| 122 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 5c508de | 2019-11-22 09:57:34 +0000 | [diff] [blame] | 123 | gboolean fu_common_fnmatch (const gchar *pattern, |
| 124 | const gchar *str); |
Richard Hughes | 954dd9f | 2017-08-08 13:36:25 +0100 | [diff] [blame] | 125 | gboolean fu_common_rmtree (const gchar *directory, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 126 | GError **error) |
| 127 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 89e968b | 2018-03-07 10:01:08 +0000 | [diff] [blame] | 128 | GPtrArray *fu_common_get_files_recursive (const gchar *path, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 129 | GError **error) |
| 130 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 7ee42fe | 2017-08-15 14:06:21 +0100 | [diff] [blame] | 131 | gboolean fu_common_mkdir_parent (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 132 | GError **error) |
| 133 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 134 | gboolean fu_common_set_contents_bytes (const gchar *filename, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 135 | GBytes *bytes, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 136 | GError **error) |
| 137 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | d0d2ae6 | 2017-08-08 12:22:30 +0100 | [diff] [blame] | 138 | GBytes *fu_common_get_contents_bytes (const gchar *filename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 139 | GError **error) |
| 140 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 141 | GBytes *fu_common_get_contents_fd (gint fd, |
| 142 | gsize count, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 143 | GError **error) |
| 144 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 94f939a | 2017-08-08 12:21:39 +0100 | [diff] [blame] | 145 | gboolean fu_common_extract_archive (GBytes *blob, |
| 146 | const gchar *dir, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 147 | GError **error) |
| 148 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 41cbe2a | 2017-08-08 14:13:35 +0100 | [diff] [blame] | 149 | GBytes *fu_common_firmware_builder (GBytes *bytes, |
| 150 | const gchar *script_fn, |
| 151 | const gchar *output_fn, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 152 | GError **error) |
| 153 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | e82eef3 | 2018-05-20 10:41:26 +0100 | [diff] [blame] | 154 | GError *fu_common_error_array_get_best (GPtrArray *errors); |
Richard Hughes | 73bf233 | 2018-08-28 09:38:09 +0100 | [diff] [blame] | 155 | guint64 fu_common_strtoull (const gchar *str); |
Richard Hughes | 22367e7 | 2018-08-30 10:24:04 +0100 | [diff] [blame] | 156 | gchar *fu_common_find_program_in_path (const gchar *basename, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 157 | GError **error) |
| 158 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | a574a75 | 2018-08-31 13:31:03 +0100 | [diff] [blame] | 159 | gchar *fu_common_strstrip (const gchar *str); |
Richard Hughes | e59cb9a | 2018-12-05 14:37:40 +0000 | [diff] [blame] | 160 | void fu_common_dump_raw (const gchar *log_domain, |
| 161 | const gchar *title, |
| 162 | const guint8 *data, |
| 163 | gsize len); |
Richard Hughes | 3548186 | 2019-01-06 12:01:58 +0000 | [diff] [blame] | 164 | void fu_common_dump_full (const gchar *log_domain, |
| 165 | const gchar *title, |
| 166 | const guint8 *data, |
| 167 | gsize len, |
| 168 | guint columns, |
| 169 | FuDumpFlags flags); |
Richard Hughes | e59cb9a | 2018-12-05 14:37:40 +0000 | [diff] [blame] | 170 | void fu_common_dump_bytes (const gchar *log_domain, |
| 171 | const gchar *title, |
| 172 | GBytes *bytes); |
Richard Hughes | fc90f39 | 2019-01-15 21:21:16 +0000 | [diff] [blame] | 173 | GBytes *fu_common_bytes_align (GBytes *bytes, |
| 174 | gsize blksz, |
| 175 | gchar padval); |
Richard Hughes | 3699946 | 2019-03-19 20:23:29 +0000 | [diff] [blame] | 176 | gboolean fu_common_bytes_is_empty (GBytes *bytes); |
Richard Hughes | 2aad104 | 2019-03-21 09:03:32 +0000 | [diff] [blame] | 177 | gboolean fu_common_bytes_compare (GBytes *bytes1, |
| 178 | GBytes *bytes2, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 179 | GError **error) |
| 180 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 38245ff | 2019-09-18 14:46:09 +0100 | [diff] [blame] | 181 | gboolean fu_common_bytes_compare_raw (const guint8 *buf1, |
| 182 | gsize bufsz1, |
| 183 | const guint8 *buf2, |
| 184 | gsize bufsz2, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 185 | GError **error) |
| 186 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 187 | GBytes *fu_common_bytes_pad (GBytes *bytes, |
| 188 | gsize sz); |
Richard Hughes | 05e3377 | 2020-12-08 18:37:02 +0000 | [diff] [blame] | 189 | GBytes *fu_common_bytes_new_offset (GBytes *bytes, |
| 190 | gsize offset, |
| 191 | gsize length, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 192 | GError **error) |
| 193 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | ae96a1f | 2019-09-23 11:16:36 +0100 | [diff] [blame] | 194 | gsize fu_common_strwidth (const gchar *text); |
Richard Hughes | 9b11af9 | 2021-02-04 20:28:49 +0000 | [diff] [blame] | 195 | guint8 *fu_memdup_safe (const guint8 *src, |
| 196 | gsize n, |
| 197 | GError **error) |
| 198 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 5308ea4 | 2019-08-09 12:25:13 +0100 | [diff] [blame] | 199 | gboolean fu_memcpy_safe (guint8 *dst, |
| 200 | gsize dst_sz, |
| 201 | gsize dst_offset, |
| 202 | const guint8 *src, |
| 203 | gsize src_sz, |
| 204 | gsize src_offset, |
| 205 | gsize n, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 206 | GError **error) |
| 207 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | c21a0b9 | 2019-10-24 12:24:37 +0100 | [diff] [blame] | 208 | gboolean fu_common_read_uint8_safe (const guint8 *buf, |
| 209 | gsize bufsz, |
| 210 | gsize offset, |
| 211 | guint8 *value, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 212 | GError **error) |
| 213 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 80768f5 | 2019-10-22 07:19:14 +0100 | [diff] [blame] | 214 | gboolean fu_common_read_uint16_safe (const guint8 *buf, |
| 215 | gsize bufsz, |
| 216 | gsize offset, |
| 217 | guint16 *value, |
| 218 | FuEndianType endian, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 219 | GError **error) |
| 220 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 80768f5 | 2019-10-22 07:19:14 +0100 | [diff] [blame] | 221 | gboolean fu_common_read_uint32_safe (const guint8 *buf, |
| 222 | gsize bufsz, |
| 223 | gsize offset, |
| 224 | guint32 *value, |
| 225 | FuEndianType endian, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 226 | GError **error) |
| 227 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 228 | gboolean fu_common_read_uint64_safe (const guint8 *buf, |
| 229 | gsize bufsz, |
| 230 | gsize offset, |
| 231 | guint64 *value, |
| 232 | FuEndianType endian, |
| 233 | GError **error) |
| 234 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 32ffdb2 | 2021-03-04 17:38:12 +0000 | [diff] [blame] | 235 | gboolean fu_common_write_uint8_safe (guint8 *buf, |
| 236 | gsize bufsz, |
| 237 | gsize offset, |
| 238 | guint8 value, |
| 239 | GError **error) |
| 240 | G_GNUC_WARN_UNUSED_RESULT; |
| 241 | gboolean fu_common_write_uint16_safe (guint8 *buf, |
| 242 | gsize bufsz, |
| 243 | gsize offset, |
| 244 | guint16 value, |
| 245 | FuEndianType endian, |
| 246 | GError **error) |
| 247 | G_GNUC_WARN_UNUSED_RESULT; |
| 248 | gboolean fu_common_write_uint32_safe (guint8 *buf, |
| 249 | gsize bufsz, |
| 250 | gsize offset, |
| 251 | guint32 value, |
| 252 | FuEndianType endian, |
| 253 | GError **error) |
| 254 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 255 | gboolean fu_common_write_uint64_safe (guint8 *buf, |
| 256 | gsize bufsz, |
| 257 | gsize offset, |
| 258 | guint64 value, |
| 259 | FuEndianType endian, |
| 260 | GError **error) |
| 261 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 262 | |
Richard Hughes | a2a8f8e | 2020-10-20 09:27:26 +0100 | [diff] [blame] | 263 | void fu_byte_array_set_size (GByteArray *array, |
| 264 | guint length); |
Richard Hughes | 74db340 | 2021-03-11 13:20:25 +0000 | [diff] [blame] | 265 | void fu_byte_array_set_size_full (GByteArray *array, |
| 266 | guint length, |
| 267 | guint8 data); |
| 268 | void fu_byte_array_align_up (GByteArray *array, |
| 269 | guint8 alignment, |
| 270 | guint8 data); |
Richard Hughes | 37c6a7b | 2019-08-14 21:57:43 +0100 | [diff] [blame] | 271 | void fu_byte_array_append_uint8 (GByteArray *array, |
| 272 | guint8 data); |
| 273 | void fu_byte_array_append_uint16 (GByteArray *array, |
| 274 | guint16 data, |
| 275 | FuEndianType endian); |
| 276 | void fu_byte_array_append_uint32 (GByteArray *array, |
| 277 | guint32 data, |
| 278 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 279 | void fu_byte_array_append_uint64 (GByteArray *array, |
| 280 | guint64 data, |
| 281 | FuEndianType endian); |
Richard Hughes | e9664e8 | 2021-03-10 13:38:06 +0000 | [diff] [blame] | 282 | void fu_byte_array_append_bytes (GByteArray *array, |
| 283 | GBytes *bytes); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 284 | |
| 285 | void fu_common_write_uint16 (guint8 *buf, |
| 286 | guint16 val_native, |
| 287 | FuEndianType endian); |
| 288 | void fu_common_write_uint32 (guint8 *buf, |
| 289 | guint32 val_native, |
| 290 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 291 | void fu_common_write_uint64 (guint8 *buf, |
| 292 | guint64 val_native, |
| 293 | FuEndianType endian); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 294 | guint16 fu_common_read_uint16 (const guint8 *buf, |
| 295 | FuEndianType endian); |
| 296 | guint32 fu_common_read_uint32 (const guint8 *buf, |
| 297 | FuEndianType endian); |
Richard Hughes | f2849d2 | 2021-03-05 17:19:17 +0000 | [diff] [blame] | 298 | guint64 fu_common_read_uint64 (const guint8 *buf, |
| 299 | FuEndianType endian); |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 300 | |
Richard Hughes | 83e56c1 | 2018-10-10 20:24:41 +0100 | [diff] [blame] | 301 | guint fu_common_string_replace (GString *string, |
| 302 | const gchar *search, |
| 303 | const gchar *replace); |
Richard Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 304 | void fu_common_string_append_kv (GString *str, |
Richard Hughes | 6e3e62b | 2019-08-14 10:43:08 +0100 | [diff] [blame] | 305 | guint idt, |
Richard Hughes | cea28de | 2019-08-09 11:16:40 +0100 | [diff] [blame] | 306 | const gchar *key, |
| 307 | const gchar *value); |
Richard Hughes | 6e3e62b | 2019-08-14 10:43:08 +0100 | [diff] [blame] | 308 | void fu_common_string_append_ku (GString *str, |
| 309 | guint idt, |
| 310 | const gchar *key, |
| 311 | guint64 value); |
| 312 | void fu_common_string_append_kx (GString *str, |
| 313 | guint idt, |
| 314 | const gchar *key, |
| 315 | guint64 value); |
| 316 | void fu_common_string_append_kb (GString *str, |
| 317 | guint idt, |
| 318 | const gchar *key, |
| 319 | gboolean value); |
Richard Hughes | 7afd7cb | 2019-08-07 11:42:42 +0100 | [diff] [blame] | 320 | gchar **fu_common_strnsplit (const gchar *str, |
| 321 | gsize sz, |
| 322 | const gchar *delimiter, |
| 323 | gint max_tokens); |
Richard Hughes | 364e268 | 2021-01-05 14:38:15 +0000 | [diff] [blame] | 324 | gchar *fu_common_strsafe (const gchar *str, |
| 325 | gsize maxsz); |
Richard Hughes | e52e1b4 | 2021-01-26 09:59:15 +0000 | [diff] [blame] | 326 | gchar *fu_common_strjoin_array (const gchar *separator, |
| 327 | GPtrArray *array); |
Mario Limonciello | 9dce1f7 | 2020-02-04 09:12:52 -0600 | [diff] [blame] | 328 | gboolean fu_common_kernel_locked_down (void); |
Richard Hughes | bd1dc2a | 2020-08-20 15:35:28 +0100 | [diff] [blame] | 329 | gboolean fu_common_cpuid (guint32 leaf, |
| 330 | guint32 *eax, |
| 331 | guint32 *ebx, |
| 332 | guint32 *ecx, |
| 333 | guint32 *edx, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 334 | GError **error) |
| 335 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | b63cfa9 | 2021-01-05 22:57:12 +0000 | [diff] [blame] | 336 | FuCpuVendor fu_common_get_cpu_vendor (void); |
Richard Hughes | 3611147 | 2020-08-12 15:04:24 +0100 | [diff] [blame] | 337 | gboolean fu_common_is_live_media (void); |
Richard Hughes | 68175e9 | 2021-01-14 09:43:33 +0000 | [diff] [blame] | 338 | guint64 fu_common_get_memory_size (void); |
Richard Hughes | 8f0b2d1 | 2020-08-12 12:41:53 +0100 | [diff] [blame] | 339 | GPtrArray *fu_common_get_volumes_by_kind (const gchar *kind, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 340 | GError **error) |
| 341 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 0bdf561 | 2020-10-30 14:56:22 +0000 | [diff] [blame] | 342 | FuVolume *fu_common_get_volume_by_device (const gchar *device, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 343 | GError **error) |
| 344 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 0bdf561 | 2020-10-30 14:56:22 +0000 | [diff] [blame] | 345 | FuVolume *fu_common_get_volume_by_devnum (guint32 devnum, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 346 | GError **error) |
| 347 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 8f0b2d1 | 2020-08-12 12:41:53 +0100 | [diff] [blame] | 348 | FuVolume *fu_common_get_esp_for_path (const gchar *esp_path, |
Richard Hughes | a2abc42 | 2020-12-22 09:38:59 +0000 | [diff] [blame] | 349 | GError **error) |
| 350 | G_GNUC_WARN_UNUSED_RESULT; |
| 351 | FuVolume *fu_common_get_esp_default (GError **error) |
| 352 | G_GNUC_WARN_UNUSED_RESULT; |
Richard Hughes | 6f5e35a | 2020-09-25 14:14:52 +0100 | [diff] [blame] | 353 | |
Richard Hughes | 44ae2a7 | 2020-09-25 18:00:21 +0100 | [diff] [blame] | 354 | guint8 fu_common_crc8 (const guint8 *buf, |
| 355 | gsize bufsz); |
Richard Hughes | 6f5e35a | 2020-09-25 14:14:52 +0100 | [diff] [blame] | 356 | guint16 fu_common_crc16 (const guint8 *buf, |
| 357 | gsize bufsz); |
| 358 | guint32 fu_common_crc32 (const guint8 *buf, |
| 359 | gsize bufsz); |
| 360 | guint32 fu_common_crc32_full (const guint8 *buf, |
| 361 | gsize bufsz, |
| 362 | guint32 crc, |
| 363 | guint32 polynomial); |
Richard Hughes | c754667 | 2021-01-28 10:53:30 +0000 | [diff] [blame] | 364 | gchar *fu_common_uri_get_scheme (const gchar *uri); |
Richard Hughes | 58d52ed | 2021-03-10 13:42:59 +0000 | [diff] [blame] | 365 | gsize fu_common_align_up (gsize value, |
| 366 | guint8 alignment); |
Richard Hughes | 52441f2 | 2021-03-12 21:21:10 +0000 | [diff] [blame^] | 367 | |
| 368 | void fu_xmlb_builder_insert_kv (XbBuilderNode *bn, |
| 369 | const gchar *key, |
| 370 | const gchar *value); |
| 371 | void fu_xmlb_builder_insert_kx (XbBuilderNode *bn, |
| 372 | const gchar *key, |
| 373 | guint64 value); |
| 374 | void fu_xmlb_builder_insert_kb (XbBuilderNode *bn, |
| 375 | const gchar *key, |
| 376 | gboolean value); |