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