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_parse_internal(FuStructSmbiosEp32 *st, GError **error) |
591 | 0 | { |
592 | 0 | if (g_log_get_debug_enabled()) { |
593 | 0 | g_autofree gchar *str = fu_struct_smbios_ep32_to_string(st); |
594 | 0 | g_debug("%s", str); |
595 | 0 | } |
596 | 0 | return TRUE; |
597 | 0 | } |
598 | | |
599 | | /** |
600 | | * fu_struct_smbios_ep32_parse: (skip): |
601 | | **/ |
602 | | FuStructSmbiosEp32 * |
603 | | fu_struct_smbios_ep32_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
604 | 0 | { |
605 | 0 | g_autoptr(FuStructSmbiosEp32) st = fu_struct_smbios_ep32_new_internal(); |
606 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
607 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
608 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
609 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosEp32: "); |
610 | 0 | return NULL; |
611 | 0 | } |
612 | 0 | st->buf = g_byte_array_new(); |
613 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
614 | 0 | if (!fu_struct_smbios_ep32_parse_internal(st, error)) |
615 | 0 | return NULL; |
616 | 0 | return g_steal_pointer(&st); |
617 | 0 | } |
618 | | /** |
619 | | * fu_struct_smbios_ep64_ref: (skip): |
620 | | **/ |
621 | | FuStructSmbiosEp64 * |
622 | | fu_struct_smbios_ep64_ref(FuStructSmbiosEp64 *st) |
623 | 0 | { |
624 | 0 | g_return_val_if_fail(st != NULL, NULL); |
625 | 0 | st->refcount++; |
626 | 0 | return st; |
627 | 0 | } |
628 | | /** |
629 | | * fu_struct_smbios_ep64_unref: (skip): |
630 | | **/ |
631 | | void |
632 | | fu_struct_smbios_ep64_unref(FuStructSmbiosEp64 *st) |
633 | 0 | { |
634 | 0 | g_return_if_fail(st != NULL); |
635 | 0 | if (st->refcount == 0) { |
636 | 0 | g_critical("FuStructSmbiosEp64 refcount already zero"); |
637 | 0 | return; |
638 | 0 | } |
639 | 0 | if (--st->refcount > 0) |
640 | 0 | return; |
641 | 0 | if (st->buf != NULL) |
642 | 0 | g_byte_array_unref(st->buf); |
643 | 0 | g_free(st); |
644 | 0 | } |
645 | | /** |
646 | | * fu_struct_smbios_ep64_new_internal: (skip): |
647 | | **/ |
648 | | static FuStructSmbiosEp64 * |
649 | | fu_struct_smbios_ep64_new_internal(void) |
650 | 0 | { |
651 | 0 | FuStructSmbiosEp64 *st = g_new0(FuStructSmbiosEp64, 1); |
652 | 0 | st->refcount = 1; |
653 | 0 | return st; |
654 | 0 | } |
655 | | |
656 | | /* getters */ |
657 | | /** |
658 | | * fu_struct_smbios_ep64_get_anchor_str: (skip): |
659 | | **/ |
660 | | gchar * |
661 | | fu_struct_smbios_ep64_get_anchor_str(const FuStructSmbiosEp64 *st) |
662 | 0 | { |
663 | 0 | g_return_val_if_fail(st != NULL, NULL); |
664 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 5, NULL); |
665 | 0 | } |
666 | | /** |
667 | | * fu_struct_smbios_ep64_get_entry_point_csum: (skip): |
668 | | **/ |
669 | | guint8 |
670 | | fu_struct_smbios_ep64_get_entry_point_csum(const FuStructSmbiosEp64 *st) |
671 | 0 | { |
672 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
673 | 0 | return st->buf->data[5]; |
674 | 0 | } |
675 | | /** |
676 | | * fu_struct_smbios_ep64_get_entry_point_len: (skip): |
677 | | **/ |
678 | | guint8 |
679 | | fu_struct_smbios_ep64_get_entry_point_len(const FuStructSmbiosEp64 *st) |
680 | 0 | { |
681 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
682 | 0 | return st->buf->data[6]; |
683 | 0 | } |
684 | | /** |
685 | | * fu_struct_smbios_ep64_get_smbios_major_ver: (skip): |
686 | | **/ |
687 | | guint8 |
688 | | fu_struct_smbios_ep64_get_smbios_major_ver(const FuStructSmbiosEp64 *st) |
689 | 0 | { |
690 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
691 | 0 | return st->buf->data[7]; |
692 | 0 | } |
693 | | /** |
694 | | * fu_struct_smbios_ep64_get_smbios_minor_ver: (skip): |
695 | | **/ |
696 | | guint8 |
697 | | fu_struct_smbios_ep64_get_smbios_minor_ver(const FuStructSmbiosEp64 *st) |
698 | 0 | { |
699 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
700 | 0 | return st->buf->data[8]; |
701 | 0 | } |
702 | | /** |
703 | | * fu_struct_smbios_ep64_get_smbios_docrev: (skip): |
704 | | **/ |
705 | | guint8 |
706 | | fu_struct_smbios_ep64_get_smbios_docrev(const FuStructSmbiosEp64 *st) |
707 | 0 | { |
708 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
709 | 0 | return st->buf->data[9]; |
710 | 0 | } |
711 | | /** |
712 | | * fu_struct_smbios_ep64_get_entry_point_rev: (skip): |
713 | | **/ |
714 | | guint8 |
715 | | fu_struct_smbios_ep64_get_entry_point_rev(const FuStructSmbiosEp64 *st) |
716 | 0 | { |
717 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
718 | 0 | return st->buf->data[10]; |
719 | 0 | } |
720 | | /** |
721 | | * fu_struct_smbios_ep64_get_reserved0: (skip): |
722 | | **/ |
723 | | guint8 |
724 | | fu_struct_smbios_ep64_get_reserved0(const FuStructSmbiosEp64 *st) |
725 | 0 | { |
726 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
727 | 0 | return st->buf->data[11]; |
728 | 0 | } |
729 | | /** |
730 | | * fu_struct_smbios_ep64_get_structure_table_len: (skip): |
731 | | **/ |
732 | | guint32 |
733 | | fu_struct_smbios_ep64_get_structure_table_len(const FuStructSmbiosEp64 *st) |
734 | 0 | { |
735 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
736 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
737 | 0 | } |
738 | | /** |
739 | | * fu_struct_smbios_ep64_get_structure_table_addr: (skip): |
740 | | **/ |
741 | | guint64 |
742 | | fu_struct_smbios_ep64_get_structure_table_addr(const FuStructSmbiosEp64 *st) |
743 | 0 | { |
744 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
745 | 0 | return fu_memread_uint64(st->buf->data + 16, G_LITTLE_ENDIAN); |
746 | 0 | } |
747 | | |
748 | | /* setters */ |
749 | | /** |
750 | | * fu_struct_smbios_ep64_set_anchor_str: (skip): |
751 | | **/ |
752 | | gboolean |
753 | | fu_struct_smbios_ep64_set_anchor_str(FuStructSmbiosEp64 *st, const gchar *value, GError **error) |
754 | 0 | { |
755 | 0 | gsize len; |
756 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
757 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
758 | 0 | if (value == NULL) { |
759 | 0 | memset(st->buf->data + 0, 0x0, 5); |
760 | 0 | return TRUE; |
761 | 0 | } |
762 | 0 | len = strlen(value); |
763 | 0 | if (len > 5) { |
764 | 0 | g_set_error(error, |
765 | 0 | FWUPD_ERROR, |
766 | 0 | FWUPD_ERROR_INVALID_DATA, |
767 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructSmbiosEp64.anchor_str (0x%x bytes)", |
768 | 0 | value, (guint) len, (guint) 5); |
769 | 0 | return FALSE; |
770 | 0 | } |
771 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
772 | 0 | } |
773 | | /** |
774 | | * fu_struct_smbios_ep64_set_entry_point_csum: (skip): |
775 | | **/ |
776 | | void |
777 | | fu_struct_smbios_ep64_set_entry_point_csum(FuStructSmbiosEp64 *st, guint8 value) |
778 | 0 | { |
779 | 0 | g_return_if_fail(st != NULL); |
780 | 0 | st->buf->data[5] = value; |
781 | 0 | } |
782 | | /** |
783 | | * fu_struct_smbios_ep64_set_entry_point_len: (skip): |
784 | | **/ |
785 | | void |
786 | | fu_struct_smbios_ep64_set_entry_point_len(FuStructSmbiosEp64 *st, guint8 value) |
787 | 0 | { |
788 | 0 | g_return_if_fail(st != NULL); |
789 | 0 | st->buf->data[6] = value; |
790 | 0 | } |
791 | | /** |
792 | | * fu_struct_smbios_ep64_set_smbios_major_ver: (skip): |
793 | | **/ |
794 | | void |
795 | | fu_struct_smbios_ep64_set_smbios_major_ver(FuStructSmbiosEp64 *st, guint8 value) |
796 | 0 | { |
797 | 0 | g_return_if_fail(st != NULL); |
798 | 0 | st->buf->data[7] = value; |
799 | 0 | } |
800 | | /** |
801 | | * fu_struct_smbios_ep64_set_smbios_minor_ver: (skip): |
802 | | **/ |
803 | | void |
804 | | fu_struct_smbios_ep64_set_smbios_minor_ver(FuStructSmbiosEp64 *st, guint8 value) |
805 | 0 | { |
806 | 0 | g_return_if_fail(st != NULL); |
807 | 0 | st->buf->data[8] = value; |
808 | 0 | } |
809 | | /** |
810 | | * fu_struct_smbios_ep64_set_smbios_docrev: (skip): |
811 | | **/ |
812 | | void |
813 | | fu_struct_smbios_ep64_set_smbios_docrev(FuStructSmbiosEp64 *st, guint8 value) |
814 | 0 | { |
815 | 0 | g_return_if_fail(st != NULL); |
816 | 0 | st->buf->data[9] = value; |
817 | 0 | } |
818 | | /** |
819 | | * fu_struct_smbios_ep64_set_entry_point_rev: (skip): |
820 | | **/ |
821 | | void |
822 | | fu_struct_smbios_ep64_set_entry_point_rev(FuStructSmbiosEp64 *st, guint8 value) |
823 | 0 | { |
824 | 0 | g_return_if_fail(st != NULL); |
825 | 0 | st->buf->data[10] = value; |
826 | 0 | } |
827 | | /** |
828 | | * fu_struct_smbios_ep64_set_reserved0: (skip): |
829 | | **/ |
830 | | void |
831 | | fu_struct_smbios_ep64_set_reserved0(FuStructSmbiosEp64 *st, guint8 value) |
832 | 0 | { |
833 | 0 | g_return_if_fail(st != NULL); |
834 | 0 | st->buf->data[11] = value; |
835 | 0 | } |
836 | | /** |
837 | | * fu_struct_smbios_ep64_set_structure_table_len: (skip): |
838 | | **/ |
839 | | void |
840 | | fu_struct_smbios_ep64_set_structure_table_len(FuStructSmbiosEp64 *st, guint32 value) |
841 | 0 | { |
842 | 0 | g_return_if_fail(st != NULL); |
843 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
844 | 0 | } |
845 | | /** |
846 | | * fu_struct_smbios_ep64_set_structure_table_addr: (skip): |
847 | | **/ |
848 | | void |
849 | | fu_struct_smbios_ep64_set_structure_table_addr(FuStructSmbiosEp64 *st, guint64 value) |
850 | 0 | { |
851 | 0 | g_return_if_fail(st != NULL); |
852 | 0 | fu_memwrite_uint64(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
853 | 0 | } |
854 | | /** |
855 | | * fu_struct_smbios_ep64_new: (skip): |
856 | | **/ |
857 | | FuStructSmbiosEp64 * |
858 | | fu_struct_smbios_ep64_new(void) |
859 | 0 | { |
860 | 0 | FuStructSmbiosEp64 *st = fu_struct_smbios_ep64_new_internal(); |
861 | 0 | st->buf = g_byte_array_sized_new(24); |
862 | 0 | fu_byte_array_set_size(st->buf, 24, 0x0); |
863 | 0 | return st; |
864 | 0 | } |
865 | | /** |
866 | | * fu_struct_smbios_ep64_to_string: (skip): |
867 | | **/ |
868 | | static gchar * |
869 | | fu_struct_smbios_ep64_to_string(const FuStructSmbiosEp64 *st) |
870 | 0 | { |
871 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosEp64:\n"); |
872 | 0 | g_return_val_if_fail(st != NULL, NULL); |
873 | 0 | { |
874 | 0 | g_autofree gchar *tmp = fu_struct_smbios_ep64_get_anchor_str(st); |
875 | 0 | if (tmp != NULL) |
876 | 0 | g_string_append_printf(str, " anchor_str: %s\n", tmp); |
877 | 0 | } |
878 | 0 | g_string_append_printf(str, " entry_point_csum: 0x%x\n", |
879 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_csum(st)); |
880 | 0 | g_string_append_printf(str, " entry_point_len: 0x%x\n", |
881 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_len(st)); |
882 | 0 | g_string_append_printf(str, " smbios_major_ver: 0x%x\n", |
883 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_major_ver(st)); |
884 | 0 | g_string_append_printf(str, " smbios_minor_ver: 0x%x\n", |
885 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_minor_ver(st)); |
886 | 0 | g_string_append_printf(str, " smbios_docrev: 0x%x\n", |
887 | 0 | (guint) fu_struct_smbios_ep64_get_smbios_docrev(st)); |
888 | 0 | g_string_append_printf(str, " entry_point_rev: 0x%x\n", |
889 | 0 | (guint) fu_struct_smbios_ep64_get_entry_point_rev(st)); |
890 | 0 | g_string_append_printf(str, " reserved0: 0x%x\n", |
891 | 0 | (guint) fu_struct_smbios_ep64_get_reserved0(st)); |
892 | 0 | g_string_append_printf(str, " structure_table_len: 0x%x\n", |
893 | 0 | (guint) fu_struct_smbios_ep64_get_structure_table_len(st)); |
894 | 0 | g_string_append_printf(str, " structure_table_addr: 0x%x\n", |
895 | 0 | (guint) fu_struct_smbios_ep64_get_structure_table_addr(st)); |
896 | 0 | if (str->len > 0) |
897 | 0 | g_string_set_size(str, str->len - 1); |
898 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
899 | 0 | } |
900 | | static gboolean |
901 | | fu_struct_smbios_ep64_parse_internal(FuStructSmbiosEp64 *st, GError **error) |
902 | 0 | { |
903 | 0 | if (g_log_get_debug_enabled()) { |
904 | 0 | g_autofree gchar *str = fu_struct_smbios_ep64_to_string(st); |
905 | 0 | g_debug("%s", str); |
906 | 0 | } |
907 | 0 | return TRUE; |
908 | 0 | } |
909 | | |
910 | | /** |
911 | | * fu_struct_smbios_ep64_parse: (skip): |
912 | | **/ |
913 | | FuStructSmbiosEp64 * |
914 | | fu_struct_smbios_ep64_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
915 | 0 | { |
916 | 0 | g_autoptr(FuStructSmbiosEp64) st = fu_struct_smbios_ep64_new_internal(); |
917 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
918 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
919 | 0 | if (!fu_memchk_read(bufsz, offset, 24, error)) { |
920 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosEp64: "); |
921 | 0 | return NULL; |
922 | 0 | } |
923 | 0 | st->buf = g_byte_array_new(); |
924 | 0 | g_byte_array_append(st->buf, buf + offset, 24); |
925 | 0 | if (!fu_struct_smbios_ep64_parse_internal(st, error)) |
926 | 0 | return NULL; |
927 | 0 | return g_steal_pointer(&st); |
928 | 0 | } |
929 | | /** |
930 | | * fu_struct_smbios_structure_ref: (skip): |
931 | | **/ |
932 | | FuStructSmbiosStructure * |
933 | | fu_struct_smbios_structure_ref(FuStructSmbiosStructure *st) |
934 | 0 | { |
935 | 0 | g_return_val_if_fail(st != NULL, NULL); |
936 | 0 | st->refcount++; |
937 | 0 | return st; |
938 | 0 | } |
939 | | /** |
940 | | * fu_struct_smbios_structure_unref: (skip): |
941 | | **/ |
942 | | void |
943 | | fu_struct_smbios_structure_unref(FuStructSmbiosStructure *st) |
944 | 0 | { |
945 | 0 | g_return_if_fail(st != NULL); |
946 | 0 | if (st->refcount == 0) { |
947 | 0 | g_critical("FuStructSmbiosStructure refcount already zero"); |
948 | 0 | return; |
949 | 0 | } |
950 | 0 | if (--st->refcount > 0) |
951 | 0 | return; |
952 | 0 | if (st->buf != NULL) |
953 | 0 | g_byte_array_unref(st->buf); |
954 | 0 | g_free(st); |
955 | 0 | } |
956 | | /** |
957 | | * fu_struct_smbios_structure_new_internal: (skip): |
958 | | **/ |
959 | | static FuStructSmbiosStructure * |
960 | | fu_struct_smbios_structure_new_internal(void) |
961 | 0 | { |
962 | 0 | FuStructSmbiosStructure *st = g_new0(FuStructSmbiosStructure, 1); |
963 | 0 | st->refcount = 1; |
964 | 0 | return st; |
965 | 0 | } |
966 | | |
967 | | /* getters */ |
968 | | /** |
969 | | * fu_struct_smbios_structure_get_type: (skip): |
970 | | **/ |
971 | | guint8 |
972 | | fu_struct_smbios_structure_get_type(const FuStructSmbiosStructure *st) |
973 | 0 | { |
974 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
975 | 0 | return st->buf->data[0]; |
976 | 0 | } |
977 | | /** |
978 | | * fu_struct_smbios_structure_get_length: (skip): |
979 | | **/ |
980 | | guint8 |
981 | | fu_struct_smbios_structure_get_length(const FuStructSmbiosStructure *st) |
982 | 0 | { |
983 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
984 | 0 | return st->buf->data[1]; |
985 | 0 | } |
986 | | /** |
987 | | * fu_struct_smbios_structure_get_handle: (skip): |
988 | | **/ |
989 | | guint16 |
990 | | fu_struct_smbios_structure_get_handle(const FuStructSmbiosStructure *st) |
991 | 0 | { |
992 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
993 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
994 | 0 | } |
995 | | |
996 | | /* setters */ |
997 | | /** |
998 | | * fu_struct_smbios_structure_set_type: (skip): |
999 | | **/ |
1000 | | void |
1001 | | fu_struct_smbios_structure_set_type(FuStructSmbiosStructure *st, guint8 value) |
1002 | 0 | { |
1003 | 0 | g_return_if_fail(st != NULL); |
1004 | 0 | st->buf->data[0] = value; |
1005 | 0 | } |
1006 | | /** |
1007 | | * fu_struct_smbios_structure_set_length: (skip): |
1008 | | **/ |
1009 | | void |
1010 | | fu_struct_smbios_structure_set_length(FuStructSmbiosStructure *st, guint8 value) |
1011 | 0 | { |
1012 | 0 | g_return_if_fail(st != NULL); |
1013 | 0 | st->buf->data[1] = value; |
1014 | 0 | } |
1015 | | /** |
1016 | | * fu_struct_smbios_structure_set_handle: (skip): |
1017 | | **/ |
1018 | | void |
1019 | | fu_struct_smbios_structure_set_handle(FuStructSmbiosStructure *st, guint16 value) |
1020 | 0 | { |
1021 | 0 | g_return_if_fail(st != NULL); |
1022 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
1023 | 0 | } |
1024 | | /** |
1025 | | * fu_struct_smbios_structure_new: (skip): |
1026 | | **/ |
1027 | | FuStructSmbiosStructure * |
1028 | | fu_struct_smbios_structure_new(void) |
1029 | 0 | { |
1030 | 0 | FuStructSmbiosStructure *st = fu_struct_smbios_structure_new_internal(); |
1031 | 0 | st->buf = g_byte_array_sized_new(4); |
1032 | 0 | fu_byte_array_set_size(st->buf, 4, 0x0); |
1033 | 0 | return st; |
1034 | 0 | } |
1035 | | /** |
1036 | | * fu_struct_smbios_structure_to_string: (skip): |
1037 | | **/ |
1038 | | static gchar * |
1039 | | fu_struct_smbios_structure_to_string(const FuStructSmbiosStructure *st) |
1040 | 0 | { |
1041 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosStructure:\n"); |
1042 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1043 | 0 | g_string_append_printf(str, " type: 0x%x\n", |
1044 | 0 | (guint) fu_struct_smbios_structure_get_type(st)); |
1045 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
1046 | 0 | (guint) fu_struct_smbios_structure_get_length(st)); |
1047 | 0 | g_string_append_printf(str, " handle: 0x%x\n", |
1048 | 0 | (guint) fu_struct_smbios_structure_get_handle(st)); |
1049 | 0 | if (str->len > 0) |
1050 | 0 | g_string_set_size(str, str->len - 1); |
1051 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1052 | 0 | } |
1053 | | static gboolean |
1054 | | fu_struct_smbios_structure_parse_internal(FuStructSmbiosStructure *st, GError **error) |
1055 | 0 | { |
1056 | 0 | if (g_log_get_debug_enabled()) { |
1057 | 0 | g_autofree gchar *str = fu_struct_smbios_structure_to_string(st); |
1058 | 0 | g_debug("%s", str); |
1059 | 0 | } |
1060 | 0 | return TRUE; |
1061 | 0 | } |
1062 | | |
1063 | | /** |
1064 | | * fu_struct_smbios_structure_parse: (skip): |
1065 | | **/ |
1066 | | FuStructSmbiosStructure * |
1067 | | fu_struct_smbios_structure_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1068 | 0 | { |
1069 | 0 | g_autoptr(FuStructSmbiosStructure) st = fu_struct_smbios_structure_new_internal(); |
1070 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1071 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1072 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1073 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosStructure: "); |
1074 | 0 | return NULL; |
1075 | 0 | } |
1076 | 0 | st->buf = g_byte_array_new(); |
1077 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1078 | 0 | if (!fu_struct_smbios_structure_parse_internal(st, error)) |
1079 | 0 | return NULL; |
1080 | 0 | return g_steal_pointer(&st); |
1081 | 0 | } |
1082 | | /** |
1083 | | * fu_struct_smbios_structure_parse_bytes: (skip): |
1084 | | **/ |
1085 | | FuStructSmbiosStructure * |
1086 | | fu_struct_smbios_structure_parse_bytes(GBytes *blob, gsize offset, GError **error) |
1087 | 0 | { |
1088 | 0 | gsize bufsz = 0; |
1089 | 0 | const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error); |
1090 | 0 | if (buf == NULL) |
1091 | 0 | return NULL; |
1092 | 0 | return fu_struct_smbios_structure_parse(buf, bufsz, offset, error); |
1093 | 0 | } |
1094 | | /** |
1095 | | * fu_struct_smbios_bios_information_ref: (skip): |
1096 | | **/ |
1097 | | FuStructSmbiosBiosInformation * |
1098 | | fu_struct_smbios_bios_information_ref(FuStructSmbiosBiosInformation *st) |
1099 | 0 | { |
1100 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1101 | 0 | st->refcount++; |
1102 | 0 | return st; |
1103 | 0 | } |
1104 | | /** |
1105 | | * fu_struct_smbios_bios_information_unref: (skip): |
1106 | | **/ |
1107 | | void |
1108 | | fu_struct_smbios_bios_information_unref(FuStructSmbiosBiosInformation *st) |
1109 | 0 | { |
1110 | 0 | g_return_if_fail(st != NULL); |
1111 | 0 | if (st->refcount == 0) { |
1112 | 0 | g_critical("FuStructSmbiosBiosInformation refcount already zero"); |
1113 | 0 | return; |
1114 | 0 | } |
1115 | 0 | if (--st->refcount > 0) |
1116 | 0 | return; |
1117 | 0 | if (st->buf != NULL) |
1118 | 0 | g_byte_array_unref(st->buf); |
1119 | 0 | g_free(st); |
1120 | 0 | } |
1121 | | /** |
1122 | | * fu_struct_smbios_bios_information_new_internal: (skip): |
1123 | | **/ |
1124 | | static FuStructSmbiosBiosInformation * |
1125 | | fu_struct_smbios_bios_information_new_internal(void) |
1126 | 0 | { |
1127 | 0 | FuStructSmbiosBiosInformation *st = g_new0(FuStructSmbiosBiosInformation, 1); |
1128 | 0 | st->refcount = 1; |
1129 | 0 | return st; |
1130 | 0 | } |
1131 | | |
1132 | | /* getters */ |
1133 | | /** |
1134 | | * fu_struct_smbios_bios_information_get_type: (skip): |
1135 | | **/ |
1136 | | static FuSmbiosStructureType |
1137 | | fu_struct_smbios_bios_information_get_type(const FuStructSmbiosBiosInformation *st) |
1138 | 0 | { |
1139 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1140 | 0 | return st->buf->data[0]; |
1141 | 0 | } |
1142 | | /** |
1143 | | * fu_struct_smbios_bios_information_get_length: (skip): |
1144 | | **/ |
1145 | | guint8 |
1146 | | fu_struct_smbios_bios_information_get_length(const FuStructSmbiosBiosInformation *st) |
1147 | 0 | { |
1148 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1149 | 0 | return st->buf->data[1]; |
1150 | 0 | } |
1151 | | /** |
1152 | | * fu_struct_smbios_bios_information_get_handle: (skip): |
1153 | | **/ |
1154 | | guint16 |
1155 | | fu_struct_smbios_bios_information_get_handle(const FuStructSmbiosBiosInformation *st) |
1156 | 0 | { |
1157 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1158 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
1159 | 0 | } |
1160 | | /** |
1161 | | * fu_struct_smbios_bios_information_get_vendor: (skip): |
1162 | | **/ |
1163 | | guint8 |
1164 | | fu_struct_smbios_bios_information_get_vendor(const FuStructSmbiosBiosInformation *st) |
1165 | 0 | { |
1166 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1167 | 0 | return st->buf->data[4]; |
1168 | 0 | } |
1169 | | /** |
1170 | | * fu_struct_smbios_bios_information_get_version: (skip): |
1171 | | **/ |
1172 | | guint8 |
1173 | | fu_struct_smbios_bios_information_get_version(const FuStructSmbiosBiosInformation *st) |
1174 | 0 | { |
1175 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1176 | 0 | return st->buf->data[5]; |
1177 | 0 | } |
1178 | | /** |
1179 | | * fu_struct_smbios_bios_information_get_starting_addr_segment: (skip): |
1180 | | **/ |
1181 | | guint16 |
1182 | | fu_struct_smbios_bios_information_get_starting_addr_segment(const FuStructSmbiosBiosInformation *st) |
1183 | 0 | { |
1184 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1185 | 0 | return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN); |
1186 | 0 | } |
1187 | | /** |
1188 | | * fu_struct_smbios_bios_information_get_release_date: (skip): |
1189 | | **/ |
1190 | | guint8 |
1191 | | fu_struct_smbios_bios_information_get_release_date(const FuStructSmbiosBiosInformation *st) |
1192 | 0 | { |
1193 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1194 | 0 | return st->buf->data[8]; |
1195 | 0 | } |
1196 | | /** |
1197 | | * fu_struct_smbios_bios_information_get_rom_size: (skip): |
1198 | | **/ |
1199 | | guint8 |
1200 | | fu_struct_smbios_bios_information_get_rom_size(const FuStructSmbiosBiosInformation *st) |
1201 | 0 | { |
1202 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1203 | 0 | return st->buf->data[9]; |
1204 | 0 | } |
1205 | | /** |
1206 | | * fu_struct_smbios_bios_information_get_characteristics: (skip): |
1207 | | **/ |
1208 | | FuSmbiosBiosCharacteristics |
1209 | | fu_struct_smbios_bios_information_get_characteristics(const FuStructSmbiosBiosInformation *st) |
1210 | 0 | { |
1211 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1212 | 0 | return fu_memread_uint64(st->buf->data + 10, G_LITTLE_ENDIAN); |
1213 | 0 | } |
1214 | | /** |
1215 | | * fu_struct_smbios_bios_information_get_characteristics_ext: (skip): |
1216 | | **/ |
1217 | | FuSmbiosBiosCharacteristicsExt |
1218 | | fu_struct_smbios_bios_information_get_characteristics_ext(const FuStructSmbiosBiosInformation *st) |
1219 | 0 | { |
1220 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1221 | 0 | return fu_memread_uint16(st->buf->data + 18, G_LITTLE_ENDIAN); |
1222 | 0 | } |
1223 | | |
1224 | | /* setters */ |
1225 | | /** |
1226 | | * fu_struct_smbios_bios_information_to_string: (skip): |
1227 | | **/ |
1228 | | static gchar * |
1229 | | fu_struct_smbios_bios_information_to_string(const FuStructSmbiosBiosInformation *st) |
1230 | 0 | { |
1231 | 0 | g_autoptr(GString) str = g_string_new("FuStructSmbiosBiosInformation:\n"); |
1232 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1233 | 0 | { |
1234 | 0 | const gchar *tmp = fu_smbios_structure_type_to_string(fu_struct_smbios_bios_information_get_type(st)); |
1235 | 0 | if (tmp != NULL) { |
1236 | 0 | g_string_append_printf(str, " type: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_type(st), tmp); |
1237 | 0 | } else { |
1238 | 0 | g_string_append_printf(str, " type: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_type(st)); |
1239 | 0 | } |
1240 | 0 | } |
1241 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
1242 | 0 | (guint) fu_struct_smbios_bios_information_get_length(st)); |
1243 | 0 | g_string_append_printf(str, " handle: 0x%x\n", |
1244 | 0 | (guint) fu_struct_smbios_bios_information_get_handle(st)); |
1245 | 0 | g_string_append_printf(str, " vendor: 0x%x\n", |
1246 | 0 | (guint) fu_struct_smbios_bios_information_get_vendor(st)); |
1247 | 0 | g_string_append_printf(str, " version: 0x%x\n", |
1248 | 0 | (guint) fu_struct_smbios_bios_information_get_version(st)); |
1249 | 0 | g_string_append_printf(str, " starting_addr_segment: 0x%x\n", |
1250 | 0 | (guint) fu_struct_smbios_bios_information_get_starting_addr_segment(st)); |
1251 | 0 | g_string_append_printf(str, " release_date: 0x%x\n", |
1252 | 0 | (guint) fu_struct_smbios_bios_information_get_release_date(st)); |
1253 | 0 | g_string_append_printf(str, " rom_size: 0x%x\n", |
1254 | 0 | (guint) fu_struct_smbios_bios_information_get_rom_size(st)); |
1255 | 0 | { |
1256 | 0 | g_autofree gchar *tmp = fu_smbios_bios_characteristics_to_string(fu_struct_smbios_bios_information_get_characteristics(st)); |
1257 | 0 | if (tmp != NULL) { |
1258 | 0 | g_string_append_printf(str, " characteristics: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_characteristics(st), tmp); |
1259 | 0 | } else { |
1260 | 0 | g_string_append_printf(str, " characteristics: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_characteristics(st)); |
1261 | 0 | } |
1262 | 0 | } |
1263 | 0 | { |
1264 | 0 | g_autofree gchar *tmp = fu_smbios_bios_characteristics_ext_to_string(fu_struct_smbios_bios_information_get_characteristics_ext(st)); |
1265 | 0 | if (tmp != NULL) { |
1266 | 0 | g_string_append_printf(str, " characteristics_ext: 0x%x [%s]\n", (guint) fu_struct_smbios_bios_information_get_characteristics_ext(st), tmp); |
1267 | 0 | } else { |
1268 | 0 | g_string_append_printf(str, " characteristics_ext: 0x%x\n", (guint) fu_struct_smbios_bios_information_get_characteristics_ext(st)); |
1269 | 0 | } |
1270 | 0 | } |
1271 | 0 | if (str->len > 0) |
1272 | 0 | g_string_set_size(str, str->len - 1); |
1273 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1274 | 0 | } |
1275 | | static gboolean |
1276 | | fu_struct_smbios_bios_information_validate_internal(FuStructSmbiosBiosInformation *st, GError **error) |
1277 | 0 | { |
1278 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1279 | 0 | if (fu_struct_smbios_bios_information_get_type(st) != FU_SMBIOS_STRUCTURE_TYPE_BIOS) { |
1280 | 0 | g_set_error(error, |
1281 | 0 | FWUPD_ERROR, |
1282 | 0 | FWUPD_ERROR_INVALID_DATA, |
1283 | 0 | "constant FuStructSmbiosBiosInformation.type was not valid, " |
1284 | 0 | "expected 'FU_SMBIOS_STRUCTURE_TYPE_BIOS' and got 0x%x '%s'", |
1285 | 0 | fu_struct_smbios_bios_information_get_type(st), |
1286 | 0 | fu_smbios_structure_type_to_string(fu_struct_smbios_bios_information_get_type(st))); |
1287 | 0 | return FALSE; |
1288 | 0 | } |
1289 | 0 | return TRUE; |
1290 | 0 | } |
1291 | | static gboolean |
1292 | | fu_struct_smbios_bios_information_parse_internal(FuStructSmbiosBiosInformation *st, GError **error) |
1293 | 0 | { |
1294 | 0 | if (g_log_get_debug_enabled()) { |
1295 | 0 | g_autofree gchar *str = fu_struct_smbios_bios_information_to_string(st); |
1296 | 0 | g_debug("%s", str); |
1297 | 0 | } |
1298 | 0 | if (!fu_struct_smbios_bios_information_validate_internal(st, error)) |
1299 | 0 | return FALSE; |
1300 | 0 | return TRUE; |
1301 | 0 | } |
1302 | | |
1303 | | /** |
1304 | | * fu_struct_smbios_bios_information_parse: (skip): |
1305 | | **/ |
1306 | | static FuStructSmbiosBiosInformation * |
1307 | | fu_struct_smbios_bios_information_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1308 | 0 | { |
1309 | 0 | g_autoptr(FuStructSmbiosBiosInformation) st = fu_struct_smbios_bios_information_new_internal(); |
1310 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1311 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1312 | 0 | if (!fu_memchk_read(bufsz, offset, 20, error)) { |
1313 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSmbiosBiosInformation: "); |
1314 | 0 | return NULL; |
1315 | 0 | } |
1316 | 0 | st->buf = g_byte_array_new(); |
1317 | 0 | g_byte_array_append(st->buf, buf + offset, 20); |
1318 | 0 | if (!fu_struct_smbios_bios_information_parse_internal(st, error)) |
1319 | 0 | return NULL; |
1320 | 0 | return g_steal_pointer(&st); |
1321 | 0 | } |
1322 | | /** |
1323 | | * fu_struct_smbios_bios_information_parse_bytes: (skip): |
1324 | | **/ |
1325 | | FuStructSmbiosBiosInformation * |
1326 | | fu_struct_smbios_bios_information_parse_bytes(GBytes *blob, gsize offset, GError **error) |
1327 | 0 | { |
1328 | 0 | gsize bufsz = 0; |
1329 | 0 | const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error); |
1330 | 0 | if (buf == NULL) |
1331 | 0 | return NULL; |
1332 | 0 | return fu_struct_smbios_bios_information_parse(buf, bufsz, offset, error); |
1333 | 0 | } |