blob: 2f95f0bda324580715e82b642a84ae6ce2334569 [file] [log] [blame]
Richard Hughes02c90d82018-08-09 12:13:03 +01001/*
Richard Hughes943d2c92017-06-21 09:04:39 +01002 * Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
3 *
Mario Limonciello51308e62018-05-28 20:05:46 -05004 * SPDX-License-Identifier: LGPL-2.1+
Richard Hughes943d2c92017-06-21 09:04:39 +01005 */
6
Richard Hughesbfd946e2019-02-09 08:21:40 +00007#pragma once
Richard Hughes943d2c92017-06-21 09:04:39 +01008
Richard Hughesadc9dad2017-09-04 13:19:27 +01009#include <gio/gio.h>
Richard Hughes52441f22021-03-12 21:21:10 +000010#include <xmlb.h>
Richard Hughes943d2c92017-06-21 09:04:39 +010011
Richard Hughes8f0b2d12020-08-12 12:41:53 +010012#include "fu-volume.h"
13
Mario Limonciello39602652019-04-29 21:08:58 -050014/**
15 * FuAppFlags:
16 * @FU_APP_FLAGS_NONE: No flags set
17 * @FU_APP_FLAGS_NO_IDLE_SOURCES: Disallow idle sources
Mario Limonciello39602652019-04-29 21:08:58 -050018 *
19 * The flags to use when loading an application.
20 **/
Richard Hughes5b5f6552018-05-18 10:22:39 +010021typedef enum {
22 FU_APP_FLAGS_NONE = 0,
23 FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0,
Mario Limonciello39602652019-04-29 21:08:58 -050024 /*< private >*/
Richard Hughes5b5f6552018-05-18 10:22:39 +010025 FU_APP_FLAGS_LAST
26} FuAppFlags;
27
Mario Limonciello39602652019-04-29 21:08:58 -050028/**
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 Hughes4be17d12018-05-30 20:36:29 +010036typedef enum {
Richard Hughes35481862019-01-06 12:01:58 +000037 FU_DUMP_FLAGS_NONE = 0,
38 FU_DUMP_FLAGS_SHOW_ASCII = 1 << 0,
39 FU_DUMP_FLAGS_SHOW_ADDRESSES = 1 << 1,
Mario Limonciello39602652019-04-29 21:08:58 -050040 /*< private >*/
Richard Hughes35481862019-01-06 12:01:58 +000041 FU_DUMP_FLAGS_LAST
42} FuDumpFlags;
43
Richard Hughes37c6a7b2019-08-14 21:57:43 +010044typedef guint FuEndianType;
45
Mario Limonciello39602652019-04-29 21:08:58 -050046/**
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 Hughesc3689582020-05-06 12:35:20 +010059 * @FU_PATH_KIND_PROCFS: The procfs location (IE /proc)
Mario Limonciellod8af5de2019-11-04 09:33:34 -060060 * @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/)
Richard Hughesafdba372019-11-23 12:57:35 +000061 * @FU_PATH_KIND_OFFLINE_TRIGGER: The file for the offline trigger (IE /system-update)
Mario Limonciello9dce1f72020-02-04 09:12:52 -060062 * @FU_PATH_KIND_SYSFSDIR_SECURITY: The sysfs security location (IE /sys/kernel/security)
Richard Hughesa7157912020-05-11 17:14:05 +010063 * @FU_PATH_KIND_ACPI_TABLES: The location of the ACPI tables
Daniel Campelloaf56c3b2021-05-05 15:04:17 +000064 * @FU_PATH_KIND_LOCKDIR: The lock directory (IE /run/lock)
Mario Limonciello39602652019-04-29 21:08:58 -050065 *
66 * Path types to use when dynamically determining a path at runtime
67 **/
Richard Hughes35481862019-01-06 12:01:58 +000068typedef enum {
Richard Hughes4be17d12018-05-30 20:36:29 +010069 FU_PATH_KIND_CACHEDIR_PKG,
70 FU_PATH_KIND_DATADIR_PKG,
Mario Limoncielloe6e2bf92018-07-10 12:11:25 -050071 FU_PATH_KIND_EFIAPPDIR,
Richard Hughes4be17d12018-05-30 20:36:29 +010072 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 Hughes282b10d2018-06-22 14:48:00 +010077 FU_PATH_KIND_SYSFSDIR_FW,
Richard Hughes83390f62018-06-22 20:36:46 +010078 FU_PATH_KIND_SYSFSDIR_DRIVERS,
Richard Hughesb56015e2018-12-12 09:25:32 +000079 FU_PATH_KIND_SYSFSDIR_TPM,
Richard Hughesc3689582020-05-06 12:35:20 +010080 FU_PATH_KIND_PROCFS,
Mario Limonciello057c67a2019-05-23 10:44:19 -050081 FU_PATH_KIND_POLKIT_ACTIONS,
Richard Hughesafdba372019-11-23 12:57:35 +000082 FU_PATH_KIND_OFFLINE_TRIGGER,
Mario Limonciello9dce1f72020-02-04 09:12:52 -060083 FU_PATH_KIND_SYSFSDIR_SECURITY,
Richard Hughesa7157912020-05-11 17:14:05 +010084 FU_PATH_KIND_ACPI_TABLES,
Daniel Campelloaf56c3b2021-05-05 15:04:17 +000085 FU_PATH_KIND_LOCKDIR,
Mario Limonciello39602652019-04-29 21:08:58 -050086 /*< private >*/
Richard Hughes4be17d12018-05-30 20:36:29 +010087 FU_PATH_KIND_LAST
88} FuPathKind;
89
Richard Hughesb63cfa92021-01-05 22:57:12 +000090/**
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 **/
98typedef 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 Hughes4d76d182021-04-06 13:35:15 +0100106/**
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 **/
124typedef 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 Hughes049ccc82017-08-09 15:26:56 +0100134typedef void (*FuOutputHandler) (const gchar *line,
135 gpointer user_data);
136
137gboolean fu_common_spawn_sync (const gchar * const *argv,
Richard Hughes4eada342017-10-03 21:20:32 +0100138 FuOutputHandler handler_cb,
Richard Hughes049ccc82017-08-09 15:26:56 +0100139 gpointer handler_user_data,
Richard Hughesb768e4d2019-02-26 13:55:18 +0000140 guint timeout_ms,
Richard Hughes049ccc82017-08-09 15:26:56 +0100141 GCancellable *cancellable,
Richard Hughesa2abc422020-12-22 09:38:59 +0000142 GError **error)
143 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes049ccc82017-08-09 15:26:56 +0100144
Richard Hughes4be17d12018-05-30 20:36:29 +0100145gchar *fu_common_get_path (FuPathKind path_kind);
Richard Hughes484ee292019-03-22 16:10:50 +0000146gchar *fu_common_realpath (const gchar *filename,
Richard Hughesa2abc422020-12-22 09:38:59 +0000147 GError **error)
148 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesa84d7a72020-05-06 12:11:51 +0100149GPtrArray *fu_common_filename_glob (const gchar *directory,
150 const gchar *pattern,
Richard Hughesa2abc422020-12-22 09:38:59 +0000151 GError **error)
152 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes5c508de2019-11-22 09:57:34 +0000153gboolean fu_common_fnmatch (const gchar *pattern,
154 const gchar *str);
Richard Hughes954dd9f2017-08-08 13:36:25 +0100155gboolean fu_common_rmtree (const gchar *directory,
Richard Hughesa2abc422020-12-22 09:38:59 +0000156 GError **error)
157 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes89e968b2018-03-07 10:01:08 +0000158GPtrArray *fu_common_get_files_recursive (const gchar *path,
Richard Hughesa2abc422020-12-22 09:38:59 +0000159 GError **error)
160 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes7ee42fe2017-08-15 14:06:21 +0100161gboolean fu_common_mkdir_parent (const gchar *filename,
Richard Hughesa2abc422020-12-22 09:38:59 +0000162 GError **error)
163 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes943d2c92017-06-21 09:04:39 +0100164gboolean fu_common_set_contents_bytes (const gchar *filename,
Richard Hughes4eada342017-10-03 21:20:32 +0100165 GBytes *bytes,
Richard Hughesa2abc422020-12-22 09:38:59 +0000166 GError **error)
167 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesd0d2ae62017-08-08 12:22:30 +0100168GBytes *fu_common_get_contents_bytes (const gchar *filename,
Richard Hughesa2abc422020-12-22 09:38:59 +0000169 GError **error)
170 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes943d2c92017-06-21 09:04:39 +0100171GBytes *fu_common_get_contents_fd (gint fd,
172 gsize count,
Richard Hughesa2abc422020-12-22 09:38:59 +0000173 GError **error)
174 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes94f939a2017-08-08 12:21:39 +0100175gboolean fu_common_extract_archive (GBytes *blob,
176 const gchar *dir,
Richard Hughesa2abc422020-12-22 09:38:59 +0000177 GError **error)
178 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes41cbe2a2017-08-08 14:13:35 +0100179GBytes *fu_common_firmware_builder (GBytes *bytes,
180 const gchar *script_fn,
181 const gchar *output_fn,
Richard Hughesa2abc422020-12-22 09:38:59 +0000182 GError **error)
183 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughese82eef32018-05-20 10:41:26 +0100184GError *fu_common_error_array_get_best (GPtrArray *errors);
Richard Hughes73bf2332018-08-28 09:38:09 +0100185guint64 fu_common_strtoull (const gchar *str);
Richard Hughes22367e72018-08-30 10:24:04 +0100186gchar *fu_common_find_program_in_path (const gchar *basename,
Richard Hughesa2abc422020-12-22 09:38:59 +0000187 GError **error)
188 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesa574a752018-08-31 13:31:03 +0100189gchar *fu_common_strstrip (const gchar *str);
Richard Hughese59cb9a2018-12-05 14:37:40 +0000190void fu_common_dump_raw (const gchar *log_domain,
191 const gchar *title,
192 const guint8 *data,
193 gsize len);
Richard Hughes35481862019-01-06 12:01:58 +0000194void 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 Hughese59cb9a2018-12-05 14:37:40 +0000200void fu_common_dump_bytes (const gchar *log_domain,
201 const gchar *title,
202 GBytes *bytes);
Richard Hughesfc90f392019-01-15 21:21:16 +0000203GBytes *fu_common_bytes_align (GBytes *bytes,
204 gsize blksz,
205 gchar padval);
Richard Hughes7f6f5252021-04-09 17:09:57 +0100206const guint8 *fu_bytes_get_data_safe (GBytes *bytes,
207 gsize *bufsz,
208 GError **error);
Richard Hughes36999462019-03-19 20:23:29 +0000209gboolean fu_common_bytes_is_empty (GBytes *bytes);
Richard Hughes2aad1042019-03-21 09:03:32 +0000210gboolean fu_common_bytes_compare (GBytes *bytes1,
211 GBytes *bytes2,
Richard Hughesa2abc422020-12-22 09:38:59 +0000212 GError **error)
213 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes38245ff2019-09-18 14:46:09 +0100214gboolean fu_common_bytes_compare_raw (const guint8 *buf1,
215 gsize bufsz1,
216 const guint8 *buf2,
217 gsize bufsz2,
Richard Hughesa2abc422020-12-22 09:38:59 +0000218 GError **error)
219 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes7afd7cb2019-08-07 11:42:42 +0100220GBytes *fu_common_bytes_pad (GBytes *bytes,
221 gsize sz);
Richard Hughes05e33772020-12-08 18:37:02 +0000222GBytes *fu_common_bytes_new_offset (GBytes *bytes,
223 gsize offset,
224 gsize length,
Richard Hughesa2abc422020-12-22 09:38:59 +0000225 GError **error)
226 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesae96a1f2019-09-23 11:16:36 +0100227gsize fu_common_strwidth (const gchar *text);
Richard Hughes9b11af92021-02-04 20:28:49 +0000228guint8 *fu_memdup_safe (const guint8 *src,
229 gsize n,
230 GError **error)
231 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes5308ea42019-08-09 12:25:13 +0100232gboolean 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 Hughesa2abc422020-12-22 09:38:59 +0000239 GError **error)
240 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesc21a0b92019-10-24 12:24:37 +0100241gboolean fu_common_read_uint8_safe (const guint8 *buf,
242 gsize bufsz,
243 gsize offset,
244 guint8 *value,
Richard Hughesa2abc422020-12-22 09:38:59 +0000245 GError **error)
246 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes80768f52019-10-22 07:19:14 +0100247gboolean fu_common_read_uint16_safe (const guint8 *buf,
248 gsize bufsz,
249 gsize offset,
250 guint16 *value,
251 FuEndianType endian,
Richard Hughesa2abc422020-12-22 09:38:59 +0000252 GError **error)
253 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes80768f52019-10-22 07:19:14 +0100254gboolean fu_common_read_uint32_safe (const guint8 *buf,
255 gsize bufsz,
256 gsize offset,
257 guint32 *value,
258 FuEndianType endian,
Richard Hughesa2abc422020-12-22 09:38:59 +0000259 GError **error)
260 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesf2849d22021-03-05 17:19:17 +0000261gboolean 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 Hughes32ffdb22021-03-04 17:38:12 +0000268gboolean 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;
274gboolean 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;
281gboolean 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 Hughesf2849d22021-03-05 17:19:17 +0000288gboolean 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 Hughes943d2c92017-06-21 09:04:39 +0100295
Richard Hughesa2a8f8e2020-10-20 09:27:26 +0100296void fu_byte_array_set_size (GByteArray *array,
297 guint length);
Richard Hughes74db3402021-03-11 13:20:25 +0000298void fu_byte_array_set_size_full (GByteArray *array,
299 guint length,
300 guint8 data);
301void fu_byte_array_align_up (GByteArray *array,
302 guint8 alignment,
303 guint8 data);
Richard Hughes37c6a7b2019-08-14 21:57:43 +0100304void fu_byte_array_append_uint8 (GByteArray *array,
305 guint8 data);
306void fu_byte_array_append_uint16 (GByteArray *array,
307 guint16 data,
308 FuEndianType endian);
309void fu_byte_array_append_uint32 (GByteArray *array,
310 guint32 data,
311 FuEndianType endian);
Richard Hughesf2849d22021-03-05 17:19:17 +0000312void fu_byte_array_append_uint64 (GByteArray *array,
313 guint64 data,
314 FuEndianType endian);
Richard Hughese9664e82021-03-10 13:38:06 +0000315void fu_byte_array_append_bytes (GByteArray *array,
316 GBytes *bytes);
Richard Hughesae252cd2017-12-08 10:48:15 +0000317
318void fu_common_write_uint16 (guint8 *buf,
319 guint16 val_native,
320 FuEndianType endian);
321void fu_common_write_uint32 (guint8 *buf,
322 guint32 val_native,
323 FuEndianType endian);
Richard Hughesf2849d22021-03-05 17:19:17 +0000324void fu_common_write_uint64 (guint8 *buf,
325 guint64 val_native,
326 FuEndianType endian);
Richard Hughesae252cd2017-12-08 10:48:15 +0000327guint16 fu_common_read_uint16 (const guint8 *buf,
328 FuEndianType endian);
329guint32 fu_common_read_uint32 (const guint8 *buf,
330 FuEndianType endian);
Richard Hughesf2849d22021-03-05 17:19:17 +0000331guint64 fu_common_read_uint64 (const guint8 *buf,
332 FuEndianType endian);
Richard Hughesae252cd2017-12-08 10:48:15 +0000333
Richard Hughes83e56c12018-10-10 20:24:41 +0100334guint fu_common_string_replace (GString *string,
335 const gchar *search,
336 const gchar *replace);
Richard Hughescea28de2019-08-09 11:16:40 +0100337void fu_common_string_append_kv (GString *str,
Richard Hughes6e3e62b2019-08-14 10:43:08 +0100338 guint idt,
Richard Hughescea28de2019-08-09 11:16:40 +0100339 const gchar *key,
340 const gchar *value);
Richard Hughes6e3e62b2019-08-14 10:43:08 +0100341void fu_common_string_append_ku (GString *str,
342 guint idt,
343 const gchar *key,
344 guint64 value);
345void fu_common_string_append_kx (GString *str,
346 guint idt,
347 const gchar *key,
348 guint64 value);
349void fu_common_string_append_kb (GString *str,
350 guint idt,
351 const gchar *key,
352 gboolean value);
Richard Hughes7afd7cb2019-08-07 11:42:42 +0100353gchar **fu_common_strnsplit (const gchar *str,
354 gsize sz,
355 const gchar *delimiter,
356 gint max_tokens);
Richard Hughes364e2682021-01-05 14:38:15 +0000357gchar *fu_common_strsafe (const gchar *str,
358 gsize maxsz);
Richard Hughese52e1b42021-01-26 09:59:15 +0000359gchar *fu_common_strjoin_array (const gchar *separator,
360 GPtrArray *array);
Mario Limonciello9dce1f72020-02-04 09:12:52 -0600361gboolean fu_common_kernel_locked_down (void);
Richard Hughesbd1dc2a2020-08-20 15:35:28 +0100362gboolean fu_common_cpuid (guint32 leaf,
363 guint32 *eax,
364 guint32 *ebx,
365 guint32 *ecx,
366 guint32 *edx,
Richard Hughesa2abc422020-12-22 09:38:59 +0000367 GError **error)
368 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughesb63cfa92021-01-05 22:57:12 +0000369FuCpuVendor fu_common_get_cpu_vendor (void);
Richard Hughes36111472020-08-12 15:04:24 +0100370gboolean fu_common_is_live_media (void);
Richard Hughes68175e92021-01-14 09:43:33 +0000371guint64 fu_common_get_memory_size (void);
Richard Hughes8f0b2d12020-08-12 12:41:53 +0100372GPtrArray *fu_common_get_volumes_by_kind (const gchar *kind,
Richard Hughesa2abc422020-12-22 09:38:59 +0000373 GError **error)
374 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes0bdf5612020-10-30 14:56:22 +0000375FuVolume *fu_common_get_volume_by_device (const gchar *device,
Richard Hughesa2abc422020-12-22 09:38:59 +0000376 GError **error)
377 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes0bdf5612020-10-30 14:56:22 +0000378FuVolume *fu_common_get_volume_by_devnum (guint32 devnum,
Richard Hughesa2abc422020-12-22 09:38:59 +0000379 GError **error)
380 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes8f0b2d12020-08-12 12:41:53 +0100381FuVolume *fu_common_get_esp_for_path (const gchar *esp_path,
Richard Hughesa2abc422020-12-22 09:38:59 +0000382 GError **error)
383 G_GNUC_WARN_UNUSED_RESULT;
384FuVolume *fu_common_get_esp_default (GError **error)
385 G_GNUC_WARN_UNUSED_RESULT;
Richard Hughes6f5e35a2020-09-25 14:14:52 +0100386
Richard Hughes44ae2a72020-09-25 18:00:21 +0100387guint8 fu_common_crc8 (const guint8 *buf,
388 gsize bufsz);
Richard Hughes6f5e35a2020-09-25 14:14:52 +0100389guint16 fu_common_crc16 (const guint8 *buf,
390 gsize bufsz);
391guint32 fu_common_crc32 (const guint8 *buf,
392 gsize bufsz);
393guint32 fu_common_crc32_full (const guint8 *buf,
394 gsize bufsz,
395 guint32 crc,
396 guint32 polynomial);
Richard Hughesc7546672021-01-28 10:53:30 +0000397gchar *fu_common_uri_get_scheme (const gchar *uri);
Richard Hughes58d52ed2021-03-10 13:42:59 +0000398gsize fu_common_align_up (gsize value,
399 guint8 alignment);
Richard Hughes4d76d182021-04-06 13:35:15 +0100400const gchar *fu_battery_state_to_string (FuBatteryState battery_state);
Richard Hughes52441f22021-03-12 21:21:10 +0000401
402void fu_xmlb_builder_insert_kv (XbBuilderNode *bn,
403 const gchar *key,
404 const gchar *value);
405void fu_xmlb_builder_insert_kx (XbBuilderNode *bn,
406 const gchar *key,
407 guint64 value);
408void fu_xmlb_builder_insert_kb (XbBuilderNode *bn,
409 const gchar *key,
410 gboolean value);