Line | Count | Source |
1 | | /* |
2 | | * This file is auto-generated, do not modify! |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | */ |
6 | | |
7 | | #include "config.h" |
8 | | |
9 | | #include <glib.h> |
10 | | |
11 | | #include "fu-smbios-struct.h" |
12 | | #include "fu-byte-array.h" |
13 | | #include "fu-bytes.h" |
14 | | #include "fu-mem-private.h" |
15 | | #include "fu-string.h" |
16 | | |
17 | | #ifdef G_LOG_DOMAIN |
18 | | #undef G_LOG_DOMAIN |
19 | | #endif |
20 | 0 | #define G_LOG_DOMAIN "FuStruct" |
21 | | |
22 | | /** |
23 | | * fu_smbios_structure_type_to_string: |
24 | | * @val: value, e.g. %FU_SMBIOS_STRUCTURE_TYPE_SYSTEM |
25 | | * |
26 | | * Converts an enumerated value to a string. |
27 | | * |
28 | | * Returns: identifier string |
29 | | **/ |
30 | | static const gchar * |
31 | | fu_smbios_structure_type_to_string(FuSmbiosStructureType val) |
32 | 0 | { |
33 | 0 | if (val == FU_SMBIOS_STRUCTURE_TYPE_BIOS) |
34 | 0 | return "bios"; |
35 | 0 | if (val == FU_SMBIOS_STRUCTURE_TYPE_SYSTEM) |
36 | 0 | return "system"; |
37 | 0 | if (val == FU_SMBIOS_STRUCTURE_TYPE_BASEBOARD) |
38 | 0 | return "baseboard"; |
39 | 0 | if (val == FU_SMBIOS_STRUCTURE_TYPE_CHASSIS) |
40 | 0 | return "chassis"; |
41 | 0 | return NULL; |
42 | 0 | } |
43 | | |
44 | | /** |
45 | | * fu_smbios_chassis_kind_to_string: |
46 | | * @val: value, e.g. %FU_SMBIOS_CHASSIS_KIND_OTHER |
47 | | * |
48 | | * Converts an enumerated value to a string. |
49 | | * |
50 | | * Returns: identifier string |
51 | | **/ |
52 | | const gchar * |
53 | | fu_smbios_chassis_kind_to_string(FuSmbiosChassisKind val) |
54 | 0 | { |
55 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_UNSET) |
56 | 0 | return "unset"; |
57 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_OTHER) |
58 | 0 | return "other"; |
59 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_DESKTOP) |
60 | 0 | return "desktop"; |
61 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_LOW_PROFILE_DESKTOP) |
62 | 0 | return "low-profile-desktop"; |
63 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_PIZZA_BOX) |
64 | 0 | return "pizza-box"; |
65 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_MINI_TOWER) |
66 | 0 | return "mini-tower"; |
67 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_TOWER) |
68 | 0 | return "tower"; |
69 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_PORTABLE) |
70 | 0 | return "portable"; |
71 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_LAPTOP) |
72 | 0 | return "laptop"; |
73 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_NOTEBOOK) |
74 | 0 | return "notebook"; |
75 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_HAND_HELD) |
76 | 0 | return "hand-held"; |
77 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_DOCKING_STATION) |
78 | 0 | return "docking-station"; |
79 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_ALL_IN_ONE) |
80 | 0 | return "all-in-one"; |
81 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_SUB_NOTEBOOK) |
82 | 0 | return "sub-notebook"; |
83 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_SPACE_SAVING) |
84 | 0 | return "space-saving"; |
85 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_LUNCH_BOX) |
86 | 0 | return "lunch-box"; |
87 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_MAIN_SERVER) |
88 | 0 | return "main-server"; |
89 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_EXPANSION) |
90 | 0 | return "expansion"; |
91 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_SUBCHASSIS) |
92 | 0 | return "subchassis"; |
93 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_BUS_EXPANSION) |
94 | 0 | return "bus-expansion"; |
95 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_PERIPHERAL) |
96 | 0 | return "peripheral"; |
97 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_RAID) |
98 | 0 | return "raid"; |
99 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_RACK_MOUNT) |
100 | 0 | return "rack-mount"; |
101 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_SEALED_CASE_PC) |
102 | 0 | return "sealed-case-pc"; |
103 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_MULTI_SYSTEM) |
104 | 0 | return "multi-system"; |
105 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_COMPACT_PCI) |
106 | 0 | return "compact-pci"; |
107 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_ADVANCED_TCA) |
108 | 0 | return "advanced-tca"; |
109 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_BLADE) |
110 | 0 | return "blade"; |
111 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_RESERVED) |
112 | 0 | return "reserved"; |
113 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_TABLET) |
114 | 0 | return "tablet"; |
115 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_CONVERTIBLE) |
116 | 0 | return "convertible"; |
117 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_DETACHABLE) |
118 | 0 | return "detachable"; |
119 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_IOT_GATEWAY) |
120 | 0 | return "iot-gateway"; |
121 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_EMBEDDED_PC) |
122 | 0 | return "embedded-pc"; |
123 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_MINI_PC) |
124 | 0 | return "mini-pc"; |
125 | 0 | if (val == FU_SMBIOS_CHASSIS_KIND_STICK_PC) |
126 | 0 | return "stick-pc"; |
127 | 0 | return NULL; |
128 | 0 | } |
129 | | |
130 | | /** |
131 | | * fu_smbios_bios_characteristics_to_string: |
132 | | * @val: value, e.g. %FU_SMBIOS_BIOS_CHARACTERISTICS___RESERVED |
133 | | * |
134 | | * Converts an enumerated value to a string. |
135 | | * |
136 | | * Returns: identifier string |
137 | | * |
138 | | **/ |
139 | | static gchar * |
140 | | fu_smbios_bios_characteristics_to_string(FuSmbiosBiosCharacteristics val) |
141 | 0 | { |
142 | 0 | const gchar *data[17] = {0}; |
143 | 0 | guint idx = 0; |
144 | 0 | if (val == FU_SMBIOS_BIOS_CHARACTERISTICS___NONE) |
145 | 0 | return g_strdup("--none"); |
146 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS___RESERVED) |
147 | 0 | data[idx++] = "--reserved"; |
148 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS___UNKNOWN) |
149 | 0 | data[idx++] = "--unknown"; |
150 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_BIOS_CHARACTERISTICS_NOT_SUPPORTED) |
151 | 0 | data[idx++] = "bios-characteristics-not-supported"; |
152 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_ISA_SUPPORTED) |
153 | 0 | data[idx++] = "isa-supported"; |
154 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_MCA_SUPPORTED) |
155 | 0 | data[idx++] = "mca-supported"; |
156 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EISA_SUPPORTED) |
157 | 0 | data[idx++] = "eisa-supported"; |
158 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_PCI_SUPPORTED) |
159 | 0 | data[idx++] = "pci-supported"; |
160 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_PCCARD_SUPPORTED) |
161 | 0 | data[idx++] = "pccard-supported"; |
162 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_PLUG_AND_PLAY_SUPPORTED) |
163 | 0 | data[idx++] = "plug-and-play-supported"; |
164 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_APM_SUPPORTED) |
165 | 0 | data[idx++] = "apm-supported"; |
166 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_BIOS_IS_UPGRADEABLE) |
167 | 0 | data[idx++] = "bios-is-upgradeable"; |
168 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_BIOS_SHADOWING_ALLOWED) |
169 | 0 | data[idx++] = "bios-shadowing-allowed"; |
170 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_VLVESA_SUPPORTED) |
171 | 0 | data[idx++] = "vlvesa-supported"; |
172 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_ESCD_SUPPORT_AVAILABLE) |
173 | 0 | data[idx++] = "escd-support-available"; |
174 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_BOOT_FROM_CD_SUPPORTED) |
175 | 0 | data[idx++] = "boot-from-cd-supported"; |
176 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_SELECTABLE_BOOT_SUPPORTED) |
177 | 0 | data[idx++] = "selectable-boot-supported"; |
178 | 0 | return g_strjoinv(",", (gchar **)data); |
179 | 0 | } |
180 | | |
181 | | /** |
182 | | * fu_smbios_bios_characteristics_ext_to_string: |
183 | | * @val: value, e.g. %FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_USB_LEGACY_SUPPORTED |
184 | | * |
185 | | * Converts an enumerated value to a string. |
186 | | * |
187 | | * Returns: identifier string |
188 | | * |
189 | | **/ |
190 | | static gchar * |
191 | | fu_smbios_bios_characteristics_ext_to_string(FuSmbiosBiosCharacteristicsExt val) |
192 | 0 | { |
193 | 0 | const gchar *data[16] = {0}; |
194 | 0 | guint idx = 0; |
195 | 0 | if (val == FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_ACPI_SUPPORTED) |
196 | 0 | return g_strdup("acpi-supported"); |
197 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_USB_LEGACY_SUPPORTED) |
198 | 0 | data[idx++] = "usb-legacy-supported"; |
199 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_AGP_SUPPORTED) |
200 | 0 | data[idx++] = "agp-supported"; |
201 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_I2O_BOOT_SUPPORTED) |
202 | 0 | data[idx++] = "i2o-boot-supported"; |
203 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_LS120_SUPER_DISK_BOOT_SUPPORTED) |
204 | 0 | data[idx++] = "ls120-super-disk-boot-supported"; |
205 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_ATAPI_ZIP_SUPPORTED) |
206 | 0 | data[idx++] = "atapi-zip-supported"; |
207 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_1394_BOOT_SUPPORTED) |
208 | 0 | data[idx++] = "1394-boot-supported"; |
209 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_SMART_BATTERY_SUPPORTED) |
210 | 0 | data[idx++] = "smart-battery-supported"; |
211 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_BIOS_BOOT_SPECIFICATION_SUPPORTED) |
212 | 0 | data[idx++] = "bios-boot-specification-supported"; |
213 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_FUNCTION_KEY_NETWORK_BOOT_SUPPORTED) |
214 | 0 | data[idx++] = "function-key-network-boot-supported"; |
215 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_ENABLE_TARGETED_CONTENT_DISTRIBUTION) |
216 | 0 | data[idx++] = "enable-targeted-content-distribution"; |
217 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_UEFI_SPECIFICATION_SUPPORTED) |
218 | 0 | data[idx++] = "uefi-specification-supported"; |
219 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_IS_VIRTUAL_MACHINE) |
220 | 0 | data[idx++] = "is-virtual-machine"; |
221 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_MANUFACTURING_MODE_SUPPORTED) |
222 | 0 | data[idx++] = "manufacturing-mode-supported"; |
223 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT_MANUFACTURING_MODE_ENABLED) |
224 | 0 | data[idx++] = "manufacturing-mode-enabled"; |
225 | 0 | if (val & FU_SMBIOS_BIOS_CHARACTERISTICS_EXT___RESERVED) |
226 | 0 | data[idx++] = "--reserved"; |
227 | 0 | return g_strjoinv(",", (gchar **)data); |
228 | 0 | } |
229 | | /** |
230 | | * fu_struct_smbios_ep32_ref: (skip): |
231 | | **/ |
232 | | FuStructSmbiosEp32 * |
233 | | fu_struct_smbios_ep32_ref(FuStructSmbiosEp32 *st) |
234 | 0 | { |
235 | 0 | g_return_val_if_fail(st != NULL, NULL); |
236 | 0 | st->refcount++; |
237 | 0 | return st; |
238 | 0 | } |
239 | | /** |
240 | | * fu_struct_smbios_ep32_unref: (skip): |
241 | | **/ |
242 | | void |
243 | | fu_struct_smbios_ep32_unref(FuStructSmbiosEp32 *st) |
244 | 0 | { |
245 | 0 | g_return_if_fail(st != NULL); |
246 | 0 | if (st->refcount == 0) { |
247 | 0 | g_critical("FuStructSmbiosEp32 refcount already zero"); |
248 | 0 | return; |
249 | 0 | } |
250 | 0 | if (--st->refcount > 0) |
251 | 0 | return; |
252 | 0 | if (st->buf != NULL) |
253 | 0 | g_byte_array_unref(st->buf); |
254 | 0 | g_free(st); |
255 | 0 | } |
256 | | /** |
257 | | * fu_struct_smbios_ep32_new_internal: (skip): |
258 | | **/ |
259 | | static FuStructSmbiosEp32 * |
260 | | fu_struct_smbios_ep32_new_internal(void) |
261 | 0 | { |
262 | 0 | FuStructSmbiosEp32 *st = g_new0(FuStructSmbiosEp32, 1); |
263 | 0 | st->refcount = 1; |
264 | 0 | return st; |
265 | 0 | } |
266 | | |
267 | | /* getters */ |
268 | | /** |
269 | | * fu_struct_smbios_ep32_get_anchor_str: (skip): |
270 | | **/ |
271 | | gchar * |
272 | | fu_struct_smbios_ep32_get_anchor_str(const FuStructSmbiosEp32 *st) |
273 | 0 | { |
274 | 0 | g_return_val_if_fail(st != NULL, NULL); |
275 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 4, NULL); |
276 | 0 | } |
277 | | /** |
278 | | * fu_struct_smbios_ep32_get_entry_point_csum: (skip): |
279 | | **/ |
280 | | guint8 |
281 | | fu_struct_smbios_ep32_get_entry_point_csum(const FuStructSmbiosEp32 *st) |
282 | 0 | { |
283 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
284 | 0 | return st->buf->data[4]; |
285 | 0 | } |
286 | | /** |
287 | | * fu_struct_smbios_ep32_get_entry_point_len: (skip): |
288 | | **/ |
289 | | guint8 |
290 | | fu_struct_smbios_ep32_get_entry_point_len(const FuStructSmbiosEp32 *st) |
291 | 0 | { |
292 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
293 | 0 | return st->buf->data[5]; |
294 | 0 | } |
295 | | /** |
296 | | * fu_struct_smbios_ep32_get_smbios_major_ver: (skip): |
297 | | **/ |
298 | | guint8 |
299 | | fu_struct_smbios_ep32_get_smbios_major_ver(const FuStructSmbiosEp32 *st) |
300 | 0 | { |
301 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
302 | 0 | return st->buf->data[6]; |
303 | 0 | } |
304 | | /** |
305 | | * fu_struct_smbios_ep32_get_smbios_minor_ver: (skip): |
306 | | **/ |
307 | | guint8 |
308 | | fu_struct_smbios_ep32_get_smbios_minor_ver(const FuStructSmbiosEp32 *st) |
309 | 0 | { |
310 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
311 | 0 | return st->buf->data[7]; |
312 | 0 | } |
313 | | /** |
314 | | * fu_struct_smbios_ep32_get_max_structure_sz: (skip): |
315 | | **/ |
316 | | guint16 |
317 | | fu_struct_smbios_ep32_get_max_structure_sz(const FuStructSmbiosEp32 *st) |
318 | 0 | { |
319 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
320 | 0 | return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN); |
321 | 0 | } |
322 | | /** |
323 | | * fu_struct_smbios_ep32_get_entry_point_rev: (skip): |
324 | | **/ |
325 | | guint8 |
326 | | fu_struct_smbios_ep32_get_entry_point_rev(const FuStructSmbiosEp32 *st) |
327 | 0 | { |
328 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
329 | 0 | return st->buf->data[10]; |
330 | 0 | } |
331 | | /** |
332 | | * fu_struct_smbios_ep32_get_intermediate_anchor_str: (skip): |
333 | | **/ |
334 | | gchar * |
335 | | fu_struct_smbios_ep32_get_intermediate_anchor_str(const FuStructSmbiosEp32 *st) |
336 | 0 | { |
337 | 0 | g_return_val_if_fail(st != NULL, NULL); |
338 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 16, 5, NULL); |
339 | 0 | } |
340 | | /** |
341 | | * fu_struct_smbios_ep32_get_intermediate_csum: (skip): |
342 | | **/ |
343 | | guint8 |
344 | | fu_struct_smbios_ep32_get_intermediate_csum(const FuStructSmbiosEp32 *st) |
345 | 0 | { |
346 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
347 | 0 | return st->buf->data[21]; |
348 | 0 | } |
349 | | /** |
350 | | * fu_struct_smbios_ep32_get_structure_table_len: (skip): |
351 | | **/ |
352 | | guint16 |
353 | | fu_struct_smbios_ep32_get_structure_table_len(const FuStructSmbiosEp32 *st) |
354 | 0 | { |
355 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
356 | 0 | return fu_memread_uint16(st->buf->data + 22, G_LITTLE_ENDIAN); |
357 | 0 | } |
358 | | /** |
359 | | * fu_struct_smbios_ep32_get_structure_table_addr: (skip): |
360 | | **/ |
361 | | guint32 |
362 | | fu_struct_smbios_ep32_get_structure_table_addr(const FuStructSmbiosEp32 *st) |
363 | 0 | { |
364 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
365 | 0 | return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN); |
366 | 0 | } |
367 | | /** |
368 | | * fu_struct_smbios_ep32_get_number_smbios_structs: (skip): |
369 | | **/ |
370 | | guint16 |
371 | | fu_struct_smbios_ep32_get_number_smbios_structs(const FuStructSmbiosEp32 *st) |
372 | 0 | { |
373 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
374 | 0 | return fu_memread_uint16(st->buf->data + 28, G_LITTLE_ENDIAN); |
375 | 0 | } |
376 | | /** |
377 | | * fu_struct_smbios_ep32_get_smbios_bcd_rev: (skip): |
378 | | **/ |
379 | | guint8 |
380 | | fu_struct_smbios_ep32_get_smbios_bcd_rev(const FuStructSmbiosEp32 *st) |
381 | 0 | { |
382 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
383 | 0 | return st->buf->data[30]; |
384 | 0 | } |
385 | | |
386 | | /* setters */ |
387 | | /** |
388 | | * fu_struct_smbios_ep32_set_anchor_str: (skip): |
389 | | **/ |
390 | | gboolean |
391 | | fu_struct_smbios_ep32_set_anchor_str(FuStructSmbiosEp32 *st, const gchar *value, GError **error) |
392 | 0 | { |
393 | 0 | gsize len; |
394 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
395 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
396 | 0 | if (value == NULL) { |
397 | 0 | memset(st->buf->data + 0, 0x0, 4); |
398 | 0 | return TRUE; |
399 | 0 | } |
400 | 0 | len = strlen(value); |
401 | 0 | if (len > 4) { |
402 | 0 | g_set_error(error, |
403 | 0 | FWUPD_ERROR, |
404 | 0 | FWUPD_ERROR_INVALID_DATA, |
405 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructSmbiosEp32.anchor_str (0x%x bytes)", |
406 | 0 | value, (guint) len, (guint) 4); |
407 | 0 | return FALSE; |
408 | 0 | } |
409 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
410 | 0 | } |
411 | | /** |
412 | | * fu_struct_smbios_ep32_set_entry_point_csum: (skip): |
413 | | **/ |
414 | | void |
415 | | fu_struct_smbios_ep32_set_entry_point_csum(FuStructSmbiosEp32 *st, guint8 value) |
416 | 0 | { |
417 | 0 | g_return_if_fail(st != NULL); |
418 | 0 | st->buf->data[4] = value; |
419 | 0 | } |
420 | | /** |
421 | | * fu_struct_smbios_ep32_set_entry_point_len: (skip): |
422 | | **/ |
423 | | void |
424 | | fu_struct_smbios_ep32_set_entry_point_len(FuStructSmbiosEp32 *st, guint8 value) |
425 | 0 | { |
426 | 0 | g_return_if_fail(st != NULL); |
427 | 0 | st->buf->data[5] = value; |
428 | 0 | } |
429 | | /** |
430 | | * fu_struct_smbios_ep32_set_smbios_major_ver: (skip): |
431 | | **/ |
432 | | void |
433 | | fu_struct_smbios_ep32_set_smbios_major_ver(FuStructSmbiosEp32 *st, guint8 value) |
434 | 0 | { |
435 | 0 | g_return_if_fail(st != NULL); |
436 | 0 | st->buf->data[6] = value; |
437 | 0 | } |
438 | | /** |
439 | | * fu_struct_smbios_ep32_set_smbios_minor_ver: (skip): |
440 | | **/ |
441 | | void |
442 | | fu_struct_smbios_ep32_set_smbios_minor_ver(FuStructSmbiosEp32 *st, guint8 value) |
443 | 0 | { |
444 | 0 | g_return_if_fail(st != NULL); |
445 | 0 | st->buf->data[7] = value; |
446 | 0 | } |
447 | | /** |
448 | | * fu_struct_smbios_ep32_set_max_structure_sz: (skip): |
449 | | **/ |
450 | | void |
451 | | fu_struct_smbios_ep32_set_max_structure_sz(FuStructSmbiosEp32 *st, guint16 value) |
452 | 0 | { |
453 | 0 | g_return_if_fail(st != NULL); |
454 | 0 | fu_memwrite_uint16(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
455 | 0 | } |
456 | | /** |
457 | | * fu_struct_smbios_ep32_set_entry_point_rev: (skip): |
458 | | **/ |
459 | | void |
460 | | fu_struct_smbios_ep32_set_entry_point_rev(FuStructSmbiosEp32 *st, guint8 value) |
461 | 0 | { |
462 | 0 | g_return_if_fail(st != NULL); |
463 | 0 | st->buf->data[10] = value; |
464 | 0 | } |
465 | | /** |
466 | | * fu_struct_smbios_ep32_set_intermediate_anchor_str: (skip): |
467 | | **/ |
468 | | gboolean |
469 | | fu_struct_smbios_ep32_set_intermediate_anchor_str(FuStructSmbiosEp32 *st, const gchar *value, GError **error) |
470 | 0 | { |
471 | 0 | gsize len; |
472 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
473 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
474 | 0 | if (value == NULL) { |
475 | 0 | memset(st->buf->data + 16, 0x0, 5); |
476 | 0 | return TRUE; |
477 | 0 | } |
478 | 0 | len = strlen(value); |
479 | 0 | if (len > 5) { |
480 | 0 | g_set_error(error, |
481 | 0 | FWUPD_ERROR, |
482 | 0 | FWUPD_ERROR_INVALID_DATA, |
483 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructSmbiosEp32.intermediate_anchor_str (0x%x bytes)", |
484 | 0 | value, (guint) len, (guint) 5); |
485 | 0 | return FALSE; |
486 | 0 | } |
487 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 16, (const guint8 *)value, len, 0x0, len, error); |
488 | 0 | } |
489 | | /** |
490 | | * fu_struct_smbios_ep32_set_intermediate_csum: (skip): |
491 | | **/ |
492 | | void |
493 | | fu_struct_smbios_ep32_set_intermediate_csum(FuStructSmbiosEp32 *st, guint8 value) |
494 | 0 | { |
495 | 0 | g_return_if_fail(st != NULL); |
496 | 0 | st->buf->data[21] = value; |
497 | 0 | } |
498 | | /** |
499 | | * fu_struct_smbios_ep32_set_structure_table_len: (skip): |
500 | | **/ |
501 | | void |
502 | | fu_struct_smbios_ep32_set_structure_table_len(FuStructSmbiosEp32 *st, guint16 value) |
503 | 0 | { |
504 | 0 | g_return_if_fail(st != NULL); |
505 | 0 | fu_memwrite_uint16(st->buf->data + 22, value, G_LITTLE_ENDIAN); |
506 | 0 | } |
507 | | /** |
508 | | * fu_struct_smbios_ep32_set_structure_table_addr: (skip): |
509 | | **/ |
510 | | void |
511 | | fu_struct_smbios_ep32_set_structure_table_addr(FuStructSmbiosEp32 *st, guint32 value) |
512 | 0 | { |
513 | 0 | g_return_if_fail(st != NULL); |
514 | 0 | fu_memwrite_uint32(st->buf->data + 24, value, G_LITTLE_ENDIAN); |
515 | 0 | } |
516 | | /** |
517 | | * fu_struct_smbios_ep32_set_number_smbios_structs: (skip): |
518 | | **/ |
519 | | void |
520 | | fu_struct_smbios_ep32_set_number_smbios_structs(FuStructSmbiosEp32 *st, guint16 value) |
521 | 0 | { |
522 | 0 | g_return_if_fail(st != NULL); |
523 | 0 | fu_memwrite_uint16(st->buf->data + 28, value, G_LITTLE_ENDIAN); |
524 | 0 | } |
525 | | /** |
526 | | * fu_struct_smbios_ep32_set_smbios_bcd_rev: (skip): |
527 | | **/ |
528 | | void |
529 | | fu_struct_smbios_ep32_set_smbios_bcd_rev(FuStructSmbiosEp32 *st, guint8 value) |
530 | 0 | { |
531 | 0 | g_return_if_fail(st != NULL); |
532 | 0 | st->buf->data[30] = value; |
533 | 0 | } |
534 | | /** |
535 | | * fu_struct_smbios_ep32_new: (skip): |
536 | | **/ |
537 | | FuStructSmbiosEp32 * |
538 | | fu_struct_smbios_ep32_new(void) |
539 | 0 | { |
540 | 0 | FuStructSmbiosEp32 *st = fu_struct_smbios_ep32_new_internal(); |
541 | 0 | st->buf = g_byte_array_sized_new(31); |
542 | 0 | fu_byte_array_set_size(st->buf, 31, 0x0); |
543 | 0 | return st; |
544 | 0 | } |
545 | | /** |
546 | | * fu_struct_smbios_ep32_to_string: (skip): |
547 | | **/ |
548 | | static gchar * |
549 | | fu_struct_smbios_ep32_to_string(const FuStructSmbiosEp32 *st) |
550 | 0 | { |
551 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosEp32:\n"); |
552 | 0 | g_return_val_if_fail(st != NULL, NULL); |
553 | 0 | { |
554 | 0 | g_autofree gchar *tmp = fu_struct_smbios_ep32_get_anchor_str(st); |
555 | 0 | if (tmp != NULL) |
556 | 0 | g_string_append_printf(str, " anchor_str: %s\n", tmp); |
557 | 0 | } |
558 | 0 | g_string_append_printf(str, " entry_point_csum: 0x%x\n", |
559 | 0 | (guint) fu_struct_smbios_ep32_get_entry_point_csum(st)); |
560 | 0 | g_string_append_printf(str, " entry_point_len: 0x%x\n", |
561 | 0 | (guint) fu_struct_smbios_ep32_get_entry_point_len(st)); |
562 | 0 | g_string_append_printf(str, " smbios_major_ver: 0x%x\n", |
563 | 0 | (guint) fu_struct_smbios_ep32_get_smbios_major_ver(st)); |
564 | 0 | g_string_append_printf(str, " smbios_minor_ver: 0x%x\n", |
565 | 0 | (guint) fu_struct_smbios_ep32_get_smbios_minor_ver(st)); |
566 | 0 | g_string_append_printf(str, " max_structure_sz: 0x%x\n", |
567 | 0 | (guint) fu_struct_smbios_ep32_get_max_structure_sz(st)); |
568 | 0 | g_string_append_printf(str, " entry_point_rev: 0x%x\n", |
569 | 0 | (guint) fu_struct_smbios_ep32_get_entry_point_rev(st)); |
570 | 0 | { |
571 | 0 | g_autofree gchar *tmp = fu_struct_smbios_ep32_get_intermediate_anchor_str(st); |
572 | 0 | if (tmp != NULL) |
573 | 0 | g_string_append_printf(str, " intermediate_anchor_str: %s\n", tmp); |
574 | 0 | } |
575 | 0 | g_string_append_printf(str, " intermediate_csum: 0x%x\n", |
576 | 0 | (guint) fu_struct_smbios_ep32_get_intermediate_csum(st)); |
577 | 0 | g_string_append_printf(str, " structure_table_len: 0x%x\n", |
578 | 0 | (guint) fu_struct_smbios_ep32_get_structure_table_len(st)); |
579 | 0 | g_string_append_printf(str, " structure_table_addr: 0x%x\n", |
580 | 0 | (guint) fu_struct_smbios_ep32_get_structure_table_addr(st)); |
581 | 0 | g_string_append_printf(str, " number_smbios_structs: 0x%x\n", |
582 | 0 | (guint) fu_struct_smbios_ep32_get_number_smbios_structs(st)); |
583 | 0 | g_string_append_printf(str, " smbios_bcd_rev: 0x%x\n", |
584 | 0 | (guint) fu_struct_smbios_ep32_get_smbios_bcd_rev(st)); |
585 | 0 | if (str->len > 0) |
586 | 0 | g_string_set_size(str, str->len - 1); |
587 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
588 | 0 | } |
589 | | static gboolean |
590 | | fu_struct_smbios_ep32_validate_internal(FuStructSmbiosEp32 *st, GError **error) |
591 | 0 | { |
592 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
593 | 0 | return TRUE; |
594 | 0 | } |
595 | | static gboolean |
596 | | fu_struct_smbios_ep32_parse_internal(FuStructSmbiosEp32 *st, GError **error) |
597 | 0 | { |
598 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
599 | 0 | g_autofree gchar *str = fu_struct_smbios_ep32_to_string(st); |
600 | 0 | g_debug("%s", str); |
601 | 0 | } |
602 | 0 | if (!fu_struct_smbios_ep32_validate_internal(st, error)) |
603 | 0 | return FALSE; |
604 | 0 | return TRUE; |
605 | 0 | } |
606 | | |
607 | | /** |
608 | | * fu_struct_smbios_ep32_parse: (skip): |
609 | | **/ |
610 | | FuStructSmbiosEp32 * |
611 | | fu_struct_smbios_ep32_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
612 | 0 | { |
613 | 0 | g_autoptr(FuStructSmbiosEp32) st = fu_struct_smbios_ep32_new_internal(); |
614 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
615 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
616 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
617 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosEp32: "); |
618 | 0 | return NULL; |
619 | 0 | } |
620 | 0 | st->buf = g_byte_array_new(); |
621 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
622 | 0 | if (!fu_struct_smbios_ep32_parse_internal(st, error)) |
623 | 0 | return NULL; |
624 | 0 | return g_steal_pointer(&st); |
625 | 0 | } |
626 | | /** |
627 | | * fu_struct_smbios_ep64_ref: (skip): |
628 | | **/ |
629 | | FuStructSmbiosEp64 * |
630 | | fu_struct_smbios_ep64_ref(FuStructSmbiosEp64 *st) |
631 | 0 | { |
632 | 0 | g_return_val_if_fail(st != NULL, NULL); |
633 | 0 | st->refcount++; |
634 | 0 | return st; |
635 | 0 | } |
636 | | /** |
637 | | * fu_struct_smbios_ep64_unref: (skip): |
638 | | **/ |
639 | | void |
640 | | fu_struct_smbios_ep64_unref(FuStructSmbiosEp64 *st) |
641 | 0 | { |
642 | 0 | g_return_if_fail(st != NULL); |
643 | 0 | if (st->refcount == 0) { |
644 | 0 | g_critical("FuStructSmbiosEp64 refcount already zero"); |
645 | 0 | return; |
646 | 0 | } |
647 | 0 | if (--st->refcount > 0) |
648 | 0 | return; |
649 | 0 | if (st->buf != NULL) |
650 | 0 | g_byte_array_unref(st->buf); |
651 | 0 | g_free(st); |
652 | 0 | } |
653 | | /** |
654 | | * fu_struct_smbios_ep64_new_internal: (skip): |
655 | | **/ |
656 | | static FuStructSmbiosEp64 * |
657 | | fu_struct_smbios_ep64_new_internal(void) |
658 | 0 | { |
659 | 0 | FuStructSmbiosEp64 *st = g_new0(FuStructSmbiosEp64, 1); |
660 | 0 | st->refcount = 1; |
661 | 0 | return st; |
662 | 0 | } |
663 | | |
664 | | /* getters */ |
665 | | /** |
666 | | * fu_struct_smbios_ep64_get_anchor_str: (skip): |
667 | | **/ |
668 | | gchar * |
669 | | fu_struct_smbios_ep64_get_anchor_str(const FuStructSmbiosEp64 *st) |
670 | 0 | { |
671 | 0 | g_return_val_if_fail(st != NULL, NULL); |
672 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 5, NULL); |
673 | 0 | } |
674 | | /** |
675 | | * fu_struct_smbios_ep64_get_entry_point_csum: (skip): |
676 | | **/ |
677 | | guint8 |
678 | | fu_struct_smbios_ep64_get_entry_point_csum(const FuStructSmbiosEp64 *st) |
679 | 0 | { |
680 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
681 | 0 | return st->buf->data[5]; |
682 | 0 | } |
683 | | /** |
684 | | * fu_struct_smbios_ep64_get_entry_point_len: (skip): |
685 | | **/ |
686 | | guint8 |
687 | | fu_struct_smbios_ep64_get_entry_point_len(const FuStructSmbiosEp64 *st) |
688 | 0 | { |
689 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
690 | 0 | return st->buf->data[6]; |
691 | 0 | } |
692 | | /** |
693 | | * fu_struct_smbios_ep64_get_smbios_major_ver: (skip): |
694 | | **/ |
695 | | guint8 |
696 | | fu_struct_smbios_ep64_get_smbios_major_ver(const FuStructSmbiosEp64 *st) |
697 | 0 | { |
698 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
699 | 0 | return st->buf->data[7]; |
700 | 0 | } |
701 | | /** |
702 | | * fu_struct_smbios_ep64_get_smbios_minor_ver: (skip): |
703 | | **/ |
704 | | guint8 |
705 | | fu_struct_smbios_ep64_get_smbios_minor_ver(const FuStructSmbiosEp64 *st) |
706 | 0 | { |
707 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
708 | 0 | return st->buf->data[8]; |
709 | 0 | } |
710 | | /** |
711 | | * fu_struct_smbios_ep64_get_smbios_docrev: (skip): |
712 | | **/ |
713 | | guint8 |
714 | | fu_struct_smbios_ep64_get_smbios_docrev(const FuStructSmbiosEp64 *st) |
715 | 0 | { |
716 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
717 | 0 | return st->buf->data[9]; |
718 | 0 | } |
719 | | /** |
720 | | * fu_struct_smbios_ep64_get_entry_point_rev: (skip): |
721 | | **/ |
722 | | guint8 |
723 | | fu_struct_smbios_ep64_get_entry_point_rev(const FuStructSmbiosEp64 *st) |
724 | 0 | { |
725 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
726 | 0 | return st->buf->data[10]; |
727 | 0 | } |
728 | | /** |
729 | | * fu_struct_smbios_ep64_get_reserved0: (skip): |
730 | | **/ |
731 | | guint8 |
732 | | fu_struct_smbios_ep64_get_reserved0(const FuStructSmbiosEp64 *st) |
733 | 0 | { |
734 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
735 | 0 | return st->buf->data[11]; |
736 | 0 | } |
737 | | /** |
738 | | * fu_struct_smbios_ep64_get_structure_table_len: (skip): |
739 | | **/ |
740 | | guint32 |
741 | | fu_struct_smbios_ep64_get_structure_table_len(const FuStructSmbiosEp64 *st) |
742 | 0 | { |
743 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
744 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
745 | 0 | } |
746 | | /** |
747 | | * fu_struct_smbios_ep64_get_structure_table_addr: (skip): |
748 | | **/ |
749 | | guint64 |
750 | | fu_struct_smbios_ep64_get_structure_table_addr(const FuStructSmbiosEp64 *st) |
751 | 0 | { |
752 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
753 | 0 | return fu_memread_uint64(st->buf->data + 16, G_LITTLE_ENDIAN); |
754 | 0 | } |
755 | | |
756 | | /* setters */ |
757 | | /** |
758 | | * fu_struct_smbios_ep64_set_anchor_str: (skip): |
759 | | **/ |
760 | | gboolean |
761 | | fu_struct_smbios_ep64_set_anchor_str(FuStructSmbiosEp64 *st, const gchar *value, GError **error) |
762 | 0 | { |
763 | 0 | gsize len; |
764 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
765 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
766 | 0 | if (value == NULL) { |
767 | 0 | memset(st->buf->data + 0, 0x0, 5); |
768 | 0 | return TRUE; |
769 | 0 | } |
770 | 0 | len = strlen(value); |
771 | 0 | if (len > 5) { |
772 | 0 | g_set_error(error, |
773 | 0 | FWUPD_ERROR, |
774 | 0 | FWUPD_ERROR_INVALID_DATA, |
775 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructSmbiosEp64.anchor_str (0x%x bytes)", |
776 | 0 | value, (guint) len, (guint) 5); |
777 | 0 | return FALSE; |
778 | 0 | } |
779 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
780 | 0 | } |
781 | | /** |
782 | | * fu_struct_smbios_ep64_set_entry_point_csum: (skip): |
783 | | **/ |
784 | | void |
785 | | fu_struct_smbios_ep64_set_entry_point_csum(FuStructSmbiosEp64 *st, guint8 value) |
786 | 0 | { |
787 | 0 | g_return_if_fail(st != NULL); |
788 | 0 | st->buf->data[5] = value; |
789 | 0 | } |
790 | | /** |
791 | | * fu_struct_smbios_ep64_set_entry_point_len: (skip): |
792 | | **/ |
793 | | void |
794 | | fu_struct_smbios_ep64_set_entry_point_len(FuStructSmbiosEp64 *st, guint8 value) |
795 | 0 | { |
796 | 0 | g_return_if_fail(st != NULL); |
797 | 0 | st->buf->data[6] = value; |
798 | 0 | } |
799 | | /** |
800 | | * fu_struct_smbios_ep64_set_smbios_major_ver: (skip): |
801 | | **/ |
802 | | void |
803 | | fu_struct_smbios_ep64_set_smbios_major_ver(FuStructSmbiosEp64 *st, guint8 value) |
804 | 0 | { |
805 | 0 | g_return_if_fail(st != NULL); |
806 | 0 | st->buf->data[7] = value; |
807 | 0 | } |
808 | | /** |
809 | | * fu_struct_smbios_ep64_set_smbios_minor_ver: (skip): |
810 | | **/ |
811 | | void |
812 | | fu_struct_smbios_ep64_set_smbios_minor_ver(FuStructSmbiosEp64 *st, guint8 value) |
813 | 0 | { |
814 | 0 | g_return_if_fail(st != NULL); |
815 | 0 | st->buf->data[8] = value; |
816 | 0 | } |
817 | | /** |
818 | | * fu_struct_smbios_ep64_set_smbios_docrev: (skip): |
819 | | **/ |
820 | | void |
821 | | fu_struct_smbios_ep64_set_smbios_docrev(FuStructSmbiosEp64 *st, guint8 value) |
822 | 0 | { |
823 | 0 | g_return_if_fail(st != NULL); |
824 | 0 | st->buf->data[9] = value; |
825 | 0 | } |
826 | | /** |
827 | | * fu_struct_smbios_ep64_set_entry_point_rev: (skip): |
828 | | **/ |
829 | | void |
830 | | fu_struct_smbios_ep64_set_entry_point_rev(FuStructSmbiosEp64 *st, guint8 value) |
831 | 0 | { |
832 | 0 | g_return_if_fail(st != NULL); |
833 | 0 | st->buf->data[10] = value; |
834 | 0 | } |
835 | | /** |
836 | | * fu_struct_smbios_ep64_set_reserved0: (skip): |
837 | | **/ |
838 | | void |
839 | | fu_struct_smbios_ep64_set_reserved0(FuStructSmbiosEp64 *st, guint8 value) |
840 | 0 | { |
841 | 0 | g_return_if_fail(st != NULL); |
842 | 0 | st->buf->data[11] = value; |
843 | 0 | } |
844 | | /** |
845 | | * fu_struct_smbios_ep64_set_structure_table_len: (skip): |
846 | | **/ |
847 | | void |
848 | | fu_struct_smbios_ep64_set_structure_table_len(FuStructSmbiosEp64 *st, guint32 value) |
849 | 0 | { |
850 | 0 | g_return_if_fail(st != NULL); |
851 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
852 | 0 | } |
853 | | /** |
854 | | * fu_struct_smbios_ep64_set_structure_table_addr: (skip): |
855 | | **/ |
856 | | void |
857 | | fu_struct_smbios_ep64_set_structure_table_addr(FuStructSmbiosEp64 *st, guint64 value) |
858 | 0 | { |
859 | 0 | g_return_if_fail(st != NULL); |
860 | 0 | fu_memwrite_uint64(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
861 | 0 | } |
862 | | /** |
863 | | * fu_struct_smbios_ep64_new: (skip): |
864 | | **/ |
865 | | FuStructSmbiosEp64 * |
866 | | fu_struct_smbios_ep64_new(void) |
867 | 0 | { |
868 | 0 | FuStructSmbiosEp64 *st = fu_struct_smbios_ep64_new_internal(); |
869 | 0 | st->buf = g_byte_array_sized_new(24); |
870 | 0 | fu_byte_array_set_size(st->buf, 24, 0x0); |
871 | 0 | return st; |
872 | 0 | } |
873 | | /** |
874 | | * fu_struct_smbios_ep64_to_string: (skip): |
875 | | **/ |
876 | | static gchar * |
877 | | fu_struct_smbios_ep64_to_string(const FuStructSmbiosEp64 *st) |
878 | 0 | { |
879 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosEp64:\n"); |
880 | 0 | g_return_val_if_fail(st != NULL, NULL); |
881 | 0 | { |
882 | 0 | g_autofree gchar *tmp = fu_struct_smbios_ep64_get_anchor_str(st); |
883 | 0 | if (tmp != NULL) |
884 | 0 | g_string_append_printf(str, " anchor_str: %s\n", tmp); |
885 | 0 | } |
886 | 0 | g_string_append_printf(str, " entry_point_csum: 0x%x\n", |
887 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_csum(st)); |
888 | 0 | g_string_append_printf(str, " entry_point_len: 0x%x\n", |
889 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_len(st)); |
890 | 0 | g_string_append_printf(str, " smbios_major_ver: 0x%x\n", |
891 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_major_ver(st)); |
892 | 0 | g_string_append_printf(str, " smbios_minor_ver: 0x%x\n", |
893 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_minor_ver(st)); |
894 | 0 | g_string_append_printf(str, " smbios_docrev: 0x%x\n", |
895 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_docrev(st)); |
896 | 0 | g_string_append_printf(str, " entry_point_rev: 0x%x\n", |
897 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_rev(st)); |
898 | 0 | g_string_append_printf(str, " reserved0: 0x%x\n", |
899 | 0 | (guint) fu_struct_smbios_ep64_get_reserved0(st)); |
900 | 0 | g_string_append_printf(str, " structure_table_len: 0x%x\n", |
901 | 0 | (guint) fu_struct_smbios_ep64_get_structure_table_len(st)); |
902 | 0 | g_string_append_printf(str, " structure_table_addr: 0x%x\n", |
903 | 0 | (guint) fu_struct_smbios_ep64_get_structure_table_addr(st)); |
904 | 0 | if (str->len > 0) |
905 | 0 | g_string_set_size(str, str->len - 1); |
906 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
907 | 0 | } |
908 | | static gboolean |
909 | | fu_struct_smbios_ep64_validate_internal(FuStructSmbiosEp64 *st, GError **error) |
910 | 0 | { |
911 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
912 | 0 | return TRUE; |
913 | 0 | } |
914 | | static gboolean |
915 | | fu_struct_smbios_ep64_parse_internal(FuStructSmbiosEp64 *st, GError **error) |
916 | 0 | { |
917 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
918 | 0 | g_autofree gchar *str = fu_struct_smbios_ep64_to_string(st); |
919 | 0 | g_debug("%s", str); |
920 | 0 | } |
921 | 0 | if (!fu_struct_smbios_ep64_validate_internal(st, error)) |
922 | 0 | return FALSE; |
923 | 0 | return TRUE; |
924 | 0 | } |
925 | | |
926 | | /** |
927 | | * fu_struct_smbios_ep64_parse: (skip): |
928 | | **/ |
929 | | FuStructSmbiosEp64 * |
930 | | fu_struct_smbios_ep64_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
931 | 0 | { |
932 | 0 | g_autoptr(FuStructSmbiosEp64) st = fu_struct_smbios_ep64_new_internal(); |
933 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
934 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
935 | 0 | if (!fu_memchk_read(bufsz, offset, 24, error)) { |
936 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosEp64: "); |
937 | 0 | return NULL; |
938 | 0 | } |
939 | 0 | st->buf = g_byte_array_new(); |
940 | 0 | g_byte_array_append(st->buf, buf + offset, 24); |
941 | 0 | if (!fu_struct_smbios_ep64_parse_internal(st, error)) |
942 | 0 | return NULL; |
943 | 0 | return g_steal_pointer(&st); |
944 | 0 | } |
945 | | /** |
946 | | * fu_struct_smbios_structure_ref: (skip): |
947 | | **/ |
948 | | FuStructSmbiosStructure * |
949 | | fu_struct_smbios_structure_ref(FuStructSmbiosStructure *st) |
950 | 0 | { |
951 | 0 | g_return_val_if_fail(st != NULL, NULL); |
952 | 0 | st->refcount++; |
953 | 0 | return st; |
954 | 0 | } |
955 | | /** |
956 | | * fu_struct_smbios_structure_unref: (skip): |
957 | | **/ |
958 | | void |
959 | | fu_struct_smbios_structure_unref(FuStructSmbiosStructure *st) |
960 | 0 | { |
961 | 0 | g_return_if_fail(st != NULL); |
962 | 0 | if (st->refcount == 0) { |
963 | 0 | g_critical("FuStructSmbiosStructure refcount already zero"); |
964 | 0 | return; |
965 | 0 | } |
966 | 0 | if (--st->refcount > 0) |
967 | 0 | return; |
968 | 0 | if (st->buf != NULL) |
969 | 0 | g_byte_array_unref(st->buf); |
970 | 0 | g_free(st); |
971 | 0 | } |
972 | | /** |
973 | | * fu_struct_smbios_structure_new_internal: (skip): |
974 | | **/ |
975 | | static FuStructSmbiosStructure * |
976 | | fu_struct_smbios_structure_new_internal(void) |
977 | 0 | { |
978 | 0 | FuStructSmbiosStructure *st = g_new0(FuStructSmbiosStructure, 1); |
979 | 0 | st->refcount = 1; |
980 | 0 | return st; |
981 | 0 | } |
982 | | |
983 | | /* getters */ |
984 | | /** |
985 | | * fu_struct_smbios_structure_get_type: (skip): |
986 | | **/ |
987 | | guint8 |
988 | | fu_struct_smbios_structure_get_type(const FuStructSmbiosStructure *st) |
989 | 0 | { |
990 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
991 | 0 | return st->buf->data[0]; |
992 | 0 | } |
993 | | /** |
994 | | * fu_struct_smbios_structure_get_length: (skip): |
995 | | **/ |
996 | | guint8 |
997 | | fu_struct_smbios_structure_get_length(const FuStructSmbiosStructure *st) |
998 | 0 | { |
999 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1000 | 0 | return st->buf->data[1]; |
1001 | 0 | } |
1002 | | /** |
1003 | | * fu_struct_smbios_structure_get_handle: (skip): |
1004 | | **/ |
1005 | | guint16 |
1006 | | fu_struct_smbios_structure_get_handle(const FuStructSmbiosStructure *st) |
1007 | 0 | { |
1008 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1009 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
1010 | 0 | } |
1011 | | |
1012 | | /* setters */ |
1013 | | /** |
1014 | | * fu_struct_smbios_structure_set_type: (skip): |
1015 | | **/ |
1016 | | void |
1017 | | fu_struct_smbios_structure_set_type(FuStructSmbiosStructure *st, guint8 value) |
1018 | 0 | { |
1019 | 0 | g_return_if_fail(st != NULL); |
1020 | 0 | st->buf->data[0] = value; |
1021 | 0 | } |
1022 | | /** |
1023 | | * fu_struct_smbios_structure_set_length: (skip): |
1024 | | **/ |
1025 | | void |
1026 | | fu_struct_smbios_structure_set_length(FuStructSmbiosStructure *st, guint8 value) |
1027 | 0 | { |
1028 | 0 | g_return_if_fail(st != NULL); |
1029 | 0 | st->buf->data[1] = value; |
1030 | 0 | } |
1031 | | /** |
1032 | | * fu_struct_smbios_structure_set_handle: (skip): |
1033 | | **/ |
1034 | | void |
1035 | | fu_struct_smbios_structure_set_handle(FuStructSmbiosStructure *st, guint16 value) |
1036 | 0 | { |
1037 | 0 | g_return_if_fail(st != NULL); |
1038 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
1039 | 0 | } |
1040 | | /** |
1041 | | * fu_struct_smbios_structure_new: (skip): |
1042 | | **/ |
1043 | | FuStructSmbiosStructure * |
1044 | | fu_struct_smbios_structure_new(void) |
1045 | 0 | { |
1046 | 0 | FuStructSmbiosStructure *st = fu_struct_smbios_structure_new_internal(); |
1047 | 0 | st->buf = g_byte_array_sized_new(4); |
1048 | 0 | fu_byte_array_set_size(st->buf, 4, 0x0); |
1049 | 0 | return st; |
1050 | 0 | } |
1051 | | /** |
1052 | | * fu_struct_smbios_structure_to_string: (skip): |
1053 | | **/ |
1054 | | static gchar * |
1055 | | fu_struct_smbios_structure_to_string(const FuStructSmbiosStructure *st) |
1056 | 0 | { |
1057 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosStructure:\n"); |
1058 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1059 | 0 | g_string_append_printf(str, " type: 0x%x\n", |
1060 | 0 | (guint) fu_struct_smbios_structure_get_type(st)); |
1061 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
1062 | 0 | (guint) fu_struct_smbios_structure_get_length(st)); |
1063 | 0 | g_string_append_printf(str, " handle: 0x%x\n", |
1064 | 0 | (guint) fu_struct_smbios_structure_get_handle(st)); |
1065 | 0 | if (str->len > 0) |
1066 | 0 | g_string_set_size(str, str->len - 1); |
1067 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1068 | 0 | } |
1069 | | static gboolean |
1070 | | fu_struct_smbios_structure_validate_internal(FuStructSmbiosStructure *st, GError **error) |
1071 | 0 | { |
1072 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1073 | 0 | return TRUE; |
1074 | 0 | } |
1075 | | static gboolean |
1076 | | fu_struct_smbios_structure_parse_internal(FuStructSmbiosStructure *st, GError **error) |
1077 | 0 | { |
1078 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1079 | 0 | g_autofree gchar *str = fu_struct_smbios_structure_to_string(st); |
1080 | 0 | g_debug("%s", str); |
1081 | 0 | } |
1082 | 0 | if (!fu_struct_smbios_structure_validate_internal(st, error)) |
1083 | 0 | return FALSE; |
1084 | 0 | return TRUE; |
1085 | 0 | } |
1086 | | |
1087 | | /** |
1088 | | * fu_struct_smbios_structure_parse: (skip): |
1089 | | **/ |
1090 | | FuStructSmbiosStructure * |
1091 | | fu_struct_smbios_structure_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1092 | 0 | { |
1093 | 0 | g_autoptr(FuStructSmbiosStructure) st = fu_struct_smbios_structure_new_internal(); |
1094 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1095 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1096 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1097 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosStructure: "); |
1098 | 0 | return NULL; |
1099 | 0 | } |
1100 | 0 | st->buf = g_byte_array_new(); |
1101 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1102 | 0 | if (!fu_struct_smbios_structure_parse_internal(st, error)) |
1103 | 0 | return NULL; |
1104 | 0 | return g_steal_pointer(&st); |
1105 | 0 | } |
1106 | | /** |
1107 | | * fu_struct_smbios_structure_parse_bytes: (skip): |
1108 | | **/ |
1109 | | FuStructSmbiosStructure * |
1110 | | fu_struct_smbios_structure_parse_bytes(GBytes *blob, gsize offset, GError **error) |
1111 | 0 | { |
1112 | 0 | gsize bufsz = 0; |
1113 | 0 | const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error); |
1114 | 0 | if (buf == NULL) |
1115 | 0 | return NULL; |
1116 | 0 | return fu_struct_smbios_structure_parse(buf, bufsz, offset, error); |
1117 | 0 | } |
1118 | | /** |
1119 | | * fu_struct_smbios_bios_information_ref: (skip): |
1120 | | **/ |
1121 | | FuStructSmbiosBiosInformation * |
1122 | | fu_struct_smbios_bios_information_ref(FuStructSmbiosBiosInformation *st) |
1123 | 0 | { |
1124 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1125 | 0 | st->refcount++; |
1126 | 0 | return st; |
1127 | 0 | } |
1128 | | /** |
1129 | | * fu_struct_smbios_bios_information_unref: (skip): |
1130 | | **/ |
1131 | | void |
1132 | | fu_struct_smbios_bios_information_unref(FuStructSmbiosBiosInformation *st) |
1133 | 0 | { |
1134 | 0 | g_return_if_fail(st != NULL); |
1135 | 0 | if (st->refcount == 0) { |
1136 | 0 | g_critical("FuStructSmbiosBiosInformation refcount already zero"); |
1137 | 0 | return; |
1138 | 0 | } |
1139 | 0 | if (--st->refcount > 0) |
1140 | 0 | return; |
1141 | 0 | if (st->buf != NULL) |
1142 | 0 | g_byte_array_unref(st->buf); |
1143 | 0 | g_free(st); |
1144 | 0 | } |
1145 | | /** |
1146 | | * fu_struct_smbios_bios_information_new_internal: (skip): |
1147 | | **/ |
1148 | | static FuStructSmbiosBiosInformation * |
1149 | | fu_struct_smbios_bios_information_new_internal(void) |
1150 | 0 | { |
1151 | 0 | FuStructSmbiosBiosInformation *st = g_new0(FuStructSmbiosBiosInformation, 1); |
1152 | 0 | st->refcount = 1; |
1153 | 0 | return st; |
1154 | 0 | } |
1155 | | |
1156 | | /* getters */ |
1157 | | /** |
1158 | | * fu_struct_smbios_bios_information_get_type: (skip): |
1159 | | **/ |
1160 | | static FuSmbiosStructureType |
1161 | | fu_struct_smbios_bios_information_get_type(const FuStructSmbiosBiosInformation *st) |
1162 | 0 | { |
1163 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1164 | 0 | return st->buf->data[0]; |
1165 | 0 | } |
1166 | | /** |
1167 | | * fu_struct_smbios_bios_information_get_length: (skip): |
1168 | | **/ |
1169 | | guint8 |
1170 | | fu_struct_smbios_bios_information_get_length(const FuStructSmbiosBiosInformation *st) |
1171 | 0 | { |
1172 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1173 | 0 | return st->buf->data[1]; |
1174 | 0 | } |
1175 | | /** |
1176 | | * fu_struct_smbios_bios_information_get_handle: (skip): |
1177 | | **/ |
1178 | | guint16 |
1179 | | fu_struct_smbios_bios_information_get_handle(const FuStructSmbiosBiosInformation *st) |
1180 | 0 | { |
1181 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1182 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
1183 | 0 | } |
1184 | | /** |
1185 | | * fu_struct_smbios_bios_information_get_vendor: (skip): |
1186 | | **/ |
1187 | | guint8 |
1188 | | fu_struct_smbios_bios_information_get_vendor(const FuStructSmbiosBiosInformation *st) |
1189 | 0 | { |
1190 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1191 | 0 | return st->buf->data[4]; |
1192 | 0 | } |
1193 | | /** |
1194 | | * fu_struct_smbios_bios_information_get_version: (skip): |
1195 | | **/ |
1196 | | guint8 |
1197 | | fu_struct_smbios_bios_information_get_version(const FuStructSmbiosBiosInformation *st) |
1198 | 0 | { |
1199 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1200 | 0 | return st->buf->data[5]; |
1201 | 0 | } |
1202 | | /** |
1203 | | * fu_struct_smbios_bios_information_get_starting_addr_segment: (skip): |
1204 | | **/ |
1205 | | guint16 |
1206 | | fu_struct_smbios_bios_information_get_starting_addr_segment(const FuStructSmbiosBiosInformation *st) |
1207 | 0 | { |
1208 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1209 | 0 | return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN); |
1210 | 0 | } |
1211 | | /** |
1212 | | * fu_struct_smbios_bios_information_get_release_date: (skip): |
1213 | | **/ |
1214 | | guint8 |
1215 | | fu_struct_smbios_bios_information_get_release_date(const FuStructSmbiosBiosInformation *st) |
1216 | 0 | { |
1217 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1218 | 0 | return st->buf->data[8]; |
1219 | 0 | } |
1220 | | /** |
1221 | | * fu_struct_smbios_bios_information_get_rom_size: (skip): |
1222 | | **/ |
1223 | | guint8 |
1224 | | fu_struct_smbios_bios_information_get_rom_size(const FuStructSmbiosBiosInformation *st) |
1225 | 0 | { |
1226 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1227 | 0 | return st->buf->data[9]; |
1228 | 0 | } |
1229 | | /** |
1230 | | * fu_struct_smbios_bios_information_get_characteristics: (skip): |
1231 | | **/ |
1232 | | FuSmbiosBiosCharacteristics |
1233 | | fu_struct_smbios_bios_information_get_characteristics(const FuStructSmbiosBiosInformation *st) |
1234 | 0 | { |
1235 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1236 | 0 | return fu_memread_uint64(st->buf->data + 10, G_LITTLE_ENDIAN); |
1237 | 0 | } |
1238 | | /** |
1239 | | * fu_struct_smbios_bios_information_get_characteristics_ext: (skip): |
1240 | | **/ |
1241 | | FuSmbiosBiosCharacteristicsExt |
1242 | | fu_struct_smbios_bios_information_get_characteristics_ext(const FuStructSmbiosBiosInformation *st) |
1243 | 0 | { |
1244 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1245 | 0 | return fu_memread_uint16(st->buf->data + 18, G_LITTLE_ENDIAN); |
1246 | 0 | } |
1247 | | |
1248 | | /* setters */ |
1249 | | /** |
1250 | | * fu_struct_smbios_bios_information_to_string: (skip): |
1251 | | **/ |
1252 | | static gchar * |
1253 | | fu_struct_smbios_bios_information_to_string(const FuStructSmbiosBiosInformation *st) |
1254 | 0 | { |
1255 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosBiosInformation:\n"); |
1256 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1257 | 0 | { |
1258 | 0 | const gchar *tmp = fu_smbios_structure_type_to_string(fu_struct_smbios_bios_information_get_type(st)); |
1259 | 0 | if (tmp != NULL) { |
1260 | 0 | g_string_append_printf(str, " type: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_type(st), tmp); |
1261 | 0 | } else { |
1262 | 0 | g_string_append_printf(str, " type: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_type(st)); |
1263 | 0 | } |
1264 | 0 | } |
1265 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
1266 | 0 | (guint) fu_struct_smbios_bios_information_get_length(st)); |
1267 | 0 | g_string_append_printf(str, " handle: 0x%x\n", |
1268 | 0 | (guint) fu_struct_smbios_bios_information_get_handle(st)); |
1269 | 0 | g_string_append_printf(str, " vendor: 0x%x\n", |
1270 | 0 | (guint) fu_struct_smbios_bios_information_get_vendor(st)); |
1271 | 0 | g_string_append_printf(str, " version: 0x%x\n", |
1272 | 0 | (guint) fu_struct_smbios_bios_information_get_version(st)); |
1273 | 0 | g_string_append_printf(str, " starting_addr_segment: 0x%x\n", |
1274 | 0 | (guint) fu_struct_smbios_bios_information_get_starting_addr_segment(st)); |
1275 | 0 | g_string_append_printf(str, " release_date: 0x%x\n", |
1276 | 0 | (guint) fu_struct_smbios_bios_information_get_release_date(st)); |
1277 | 0 | g_string_append_printf(str, " rom_size: 0x%x\n", |
1278 | 0 | (guint) fu_struct_smbios_bios_information_get_rom_size(st)); |
1279 | 0 | { |
1280 | 0 | g_autofree gchar *tmp = fu_smbios_bios_characteristics_to_string(fu_struct_smbios_bios_information_get_characteristics(st)); |
1281 | 0 | if (tmp != NULL) { |
1282 | 0 | g_string_append_printf(str, " characteristics: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_characteristics(st), tmp); |
1283 | 0 | } else { |
1284 | 0 | g_string_append_printf(str, " characteristics: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_characteristics(st)); |
1285 | 0 | } |
1286 | 0 | } |
1287 | 0 | { |
1288 | 0 | g_autofree gchar *tmp = fu_smbios_bios_characteristics_ext_to_string(fu_struct_smbios_bios_information_get_characteristics_ext(st)); |
1289 | 0 | if (tmp != NULL) { |
1290 | 0 | g_string_append_printf(str, " characteristics_ext: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_characteristics_ext(st), tmp); |
1291 | 0 | } else { |
1292 | 0 | g_string_append_printf(str, " characteristics_ext: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_characteristics_ext(st)); |
1293 | 0 | } |
1294 | 0 | } |
1295 | 0 | if (str->len > 0) |
1296 | 0 | g_string_set_size(str, str->len - 1); |
1297 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1298 | 0 | } |
1299 | | static gboolean |
1300 | | fu_struct_smbios_bios_information_validate_internal(FuStructSmbiosBiosInformation *st, GError **error) |
1301 | 0 | { |
1302 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1303 | 0 | if (fu_struct_smbios_bios_information_get_type(st) != FU_SMBIOS_STRUCTURE_TYPE_BIOS) { |
1304 | 0 | g_set_error(error, |
1305 | 0 | FWUPD_ERROR, |
1306 | 0 | FWUPD_ERROR_INVALID_DATA, |
1307 | 0 | "constant FuStructSmbiosBiosInformation.type was not valid, " |
1308 | 0 | "expected 'FU_SMBIOS_STRUCTURE_TYPE_BIOS' and got 0x%x '%s'", |
1309 | 0 | fu_struct_smbios_bios_information_get_type(st), |
1310 | 0 | fu_smbios_structure_type_to_string(fu_struct_smbios_bios_information_get_type(st))); |
1311 | 0 | return FALSE; |
1312 | 0 | } |
1313 | 0 | return TRUE; |
1314 | 0 | } |
1315 | | static gboolean |
1316 | | fu_struct_smbios_bios_information_parse_internal(FuStructSmbiosBiosInformation *st, GError **error) |
1317 | 0 | { |
1318 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1319 | 0 | g_autofree gchar *str = fu_struct_smbios_bios_information_to_string(st); |
1320 | 0 | g_debug("%s", str); |
1321 | 0 | } |
1322 | 0 | if (!fu_struct_smbios_bios_information_validate_internal(st, error)) |
1323 | 0 | return FALSE; |
1324 | 0 | return TRUE; |
1325 | 0 | } |
1326 | | |
1327 | | /** |
1328 | | * fu_struct_smbios_bios_information_parse: (skip): |
1329 | | **/ |
1330 | | static FuStructSmbiosBiosInformation * |
1331 | | fu_struct_smbios_bios_information_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1332 | 0 | { |
1333 | 0 | g_autoptr(FuStructSmbiosBiosInformation) st = fu_struct_smbios_bios_information_new_internal(); |
1334 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1335 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1336 | 0 | if (!fu_memchk_read(bufsz, offset, 20, error)) { |
1337 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosBiosInformation: "); |
1338 | 0 | return NULL; |
1339 | 0 | } |
1340 | 0 | st->buf = g_byte_array_new(); |
1341 | 0 | g_byte_array_append(st->buf, buf + offset, 20); |
1342 | 0 | if (!fu_struct_smbios_bios_information_parse_internal(st, error)) |
1343 | 0 | return NULL; |
1344 | 0 | return g_steal_pointer(&st); |
1345 | 0 | } |
1346 | | /** |
1347 | | * fu_struct_smbios_bios_information_parse_bytes: (skip): |
1348 | | **/ |
1349 | | FuStructSmbiosBiosInformation * |
1350 | | fu_struct_smbios_bios_information_parse_bytes(GBytes *blob, gsize offset, GError **error) |
1351 | 0 | { |
1352 | 0 | gsize bufsz = 0; |
1353 | 0 | const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error); |
1354 | 0 | if (buf == NULL) |
1355 | 0 | return NULL; |
1356 | 0 | return fu_struct_smbios_bios_information_parse(buf, bufsz, offset, error); |
1357 | 0 | } |