/work/fu-intel-me-struct.c
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-intel-me-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_intel_me_family_to_string: |
23 | | * @val: value, e.g. %FU_INTEL_ME_FAMILY_SPS |
24 | | * |
25 | | * Converts an enumerated value to a string. |
26 | | * |
27 | | * Returns: identifier string |
28 | | **/ |
29 | | const gchar * |
30 | | fu_intel_me_family_to_string(FuIntelMeFamily val) |
31 | 0 | { |
32 | 0 | if (val == FU_INTEL_ME_FAMILY_SPS) |
33 | 0 | return "sps"; |
34 | 0 | if (val == FU_INTEL_ME_FAMILY_TXE) |
35 | 0 | return "txe"; |
36 | 0 | if (val == FU_INTEL_ME_FAMILY_ME) |
37 | 0 | return "me"; |
38 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME11) |
39 | 0 | return "csme11"; |
40 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME16) |
41 | 0 | return "csme16"; |
42 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME18) |
43 | 0 | return "csme18"; |
44 | 0 | return NULL; |
45 | 0 | } |
46 | | |
47 | | /** |
48 | | * fu_intel_me_issue_to_string: |
49 | | * @val: value, e.g. %FU_INTEL_ME_ISSUE_NOT_VULNERABLE |
50 | | * |
51 | | * Converts an enumerated value to a string. |
52 | | * |
53 | | * Returns: identifier string |
54 | | **/ |
55 | | const gchar * |
56 | | fu_intel_me_issue_to_string(FuIntelMeIssue val) |
57 | 0 | { |
58 | 0 | if (val == FU_INTEL_ME_ISSUE_NOT_VULNERABLE) |
59 | 0 | return "not-vulnerable"; |
60 | 0 | if (val == FU_INTEL_ME_ISSUE_VULNERABLE) |
61 | 0 | return "vulnerable"; |
62 | 0 | if (val == FU_INTEL_ME_ISSUE_PATCHED) |
63 | 0 | return "patched"; |
64 | 0 | return NULL; |
65 | 0 | } |
66 | | |
67 | | /** |
68 | | * fu_me_hfs_cws_to_string: |
69 | | * @val: value, e.g. %FU_ME_HFS_CWS_INITIALIZING |
70 | | * |
71 | | * Converts an enumerated value to a string. |
72 | | * |
73 | | * Returns: identifier string |
74 | | **/ |
75 | | const gchar * |
76 | | fu_me_hfs_cws_to_string(FuMeHfsCws val) |
77 | 0 | { |
78 | 0 | if (val == FU_ME_HFS_CWS_RESET) |
79 | 0 | return "reset"; |
80 | 0 | if (val == FU_ME_HFS_CWS_INITIALIZING) |
81 | 0 | return "initializing"; |
82 | 0 | if (val == FU_ME_HFS_CWS_RECOVERY) |
83 | 0 | return "recovery"; |
84 | 0 | if (val == FU_ME_HFS_CWS_TEST) |
85 | 0 | return "test"; |
86 | 0 | if (val == FU_ME_HFS_CWS_DISABLED) |
87 | 0 | return "disabled"; |
88 | 0 | if (val == FU_ME_HFS_CWS_NORMAL) |
89 | 0 | return "normal"; |
90 | 0 | if (val == FU_ME_HFS_CWS_WAIT) |
91 | 0 | return "wait"; |
92 | 0 | if (val == FU_ME_HFS_CWS_TRANSITION) |
93 | 0 | return "transition"; |
94 | 0 | if (val == FU_ME_HFS_CWS_INVALID_CPU) |
95 | 0 | return "invalid-cpu"; |
96 | 0 | if (val == FU_ME_HFS_CWS_HALT) |
97 | 0 | return "halt"; |
98 | 0 | return NULL; |
99 | 0 | } |
100 | | |
101 | | |
102 | | /** |
103 | | * fu_me_hfs_mode_to_string: |
104 | | * @val: value, e.g. %FU_ME_HFS_MODE___RESERVED |
105 | | * |
106 | | * Converts an enumerated value to a string. |
107 | | * |
108 | | * Returns: identifier string |
109 | | **/ |
110 | | static const gchar * |
111 | | fu_me_hfs_mode_to_string(FuMeHfsMode val) |
112 | 0 | { |
113 | 0 | if (val == FU_ME_HFS_MODE_NORMAL) |
114 | 0 | return "normal"; |
115 | 0 | if (val == FU_ME_HFS_MODE___RESERVED) |
116 | 0 | return "--reserved"; |
117 | 0 | if (val == FU_ME_HFS_MODE_DEBUG) |
118 | 0 | return "debug"; |
119 | 0 | if (val == FU_ME_HFS_MODE_DISABLE) |
120 | 0 | return "disable"; |
121 | 0 | if (val == FU_ME_HFS_MODE_OVERRIDE_JUMPER) |
122 | 0 | return "override-jumper"; |
123 | 0 | if (val == FU_ME_HFS_MODE_OVERRIDE_MEI) |
124 | 0 | return "override-mei"; |
125 | 0 | if (val == FU_ME_HFS_MODE_UNKNOWN6) |
126 | 0 | return "unknown6"; |
127 | 0 | if (val == FU_ME_HFS_MODE_ENHANCED_DEBUG) |
128 | 0 | return "enhanced-debug"; |
129 | 0 | return NULL; |
130 | 0 | } |
131 | | |
132 | | |
133 | | /** |
134 | | * fu_me_hfs_enforcement_policy_to_string: |
135 | | * @val: value, e.g. %FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_TO |
136 | | * |
137 | | * Converts an enumerated value to a string. |
138 | | * |
139 | | * Returns: identifier string |
140 | | **/ |
141 | | static const gchar * |
142 | | fu_me_hfs_enforcement_policy_to_string(FuMeHfsEnforcementPolicy val) |
143 | 0 | { |
144 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_NOTHING) |
145 | 0 | return "nothing"; |
146 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_TO) |
147 | 0 | return "shutdown-to"; |
148 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_NOW) |
149 | 0 | return "shutdown-now"; |
150 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_30MINS) |
151 | 0 | return "shutdown-30mins"; |
152 | 0 | return NULL; |
153 | 0 | } |
154 | | |
155 | | |
156 | | /** |
157 | | * fu_struct_intel_me_hfsts_ref: (skip): |
158 | | **/ |
159 | | FuStructIntelMeHfsts * |
160 | | fu_struct_intel_me_hfsts_ref(FuStructIntelMeHfsts *st) |
161 | 0 | { |
162 | 0 | g_return_val_if_fail(st != NULL, NULL); |
163 | 0 | st->refcount++; |
164 | 0 | return st; |
165 | 0 | } |
166 | | /** |
167 | | * fu_struct_intel_me_hfsts_unref: (skip): |
168 | | **/ |
169 | | void |
170 | | fu_struct_intel_me_hfsts_unref(FuStructIntelMeHfsts *st) |
171 | 0 | { |
172 | 0 | g_return_if_fail(st != NULL); |
173 | 0 | if (st->refcount == 0) { |
174 | 0 | g_critical("FuStructIntelMeHfsts refcount already zero"); |
175 | 0 | return; |
176 | 0 | } |
177 | 0 | if (--st->refcount > 0) |
178 | 0 | return; |
179 | 0 | if (st->buf != NULL) |
180 | 0 | g_byte_array_unref(st->buf); |
181 | 0 | g_free(st); |
182 | 0 | } |
183 | | /** |
184 | | * fu_struct_intel_me_hfsts_new_internal: (skip): |
185 | | **/ |
186 | | FuStructIntelMeHfsts * |
187 | | fu_struct_intel_me_hfsts_new_internal(void) |
188 | 0 | { |
189 | 0 | FuStructIntelMeHfsts *st = g_new0(FuStructIntelMeHfsts, 1); |
190 | 0 | st->refcount = 1; |
191 | 0 | return st; |
192 | 0 | } |
193 | | |
194 | | /* getters */ |
195 | | /** |
196 | | * fu_struct_intel_me_hfsts_get_value: (skip): |
197 | | **/ |
198 | | guint32 |
199 | | fu_struct_intel_me_hfsts_get_value(const FuStructIntelMeHfsts *st) |
200 | 0 | { |
201 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
202 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
203 | 0 | } |
204 | | |
205 | | /* setters */ |
206 | | /** |
207 | | * fu_struct_intel_me_hfsts_set_value: (skip): |
208 | | **/ |
209 | | void |
210 | | fu_struct_intel_me_hfsts_set_value(FuStructIntelMeHfsts *st, guint32 value) |
211 | 0 | { |
212 | 0 | g_return_if_fail(st != NULL); |
213 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
214 | 0 | } |
215 | | /** |
216 | | * fu_struct_intel_me_hfsts_new: (skip): |
217 | | **/ |
218 | | FuStructIntelMeHfsts * |
219 | | fu_struct_intel_me_hfsts_new(void) |
220 | 0 | { |
221 | 0 | FuStructIntelMeHfsts *st = fu_struct_intel_me_hfsts_new_internal(); |
222 | 0 | st->buf = g_byte_array_sized_new(4); |
223 | 0 | fu_byte_array_set_size(st->buf, 4, 0x0); |
224 | 0 | return st; |
225 | 0 | } |
226 | | /** |
227 | | * fu_struct_intel_me_hfsts_to_string: (skip): |
228 | | **/ |
229 | | gchar * |
230 | | fu_struct_intel_me_hfsts_to_string(const FuStructIntelMeHfsts *st) |
231 | 0 | { |
232 | 0 | g_autoptr(GString) str = g_string_new("FuStructIntelMeHfsts:\n"); |
233 | 0 | g_return_val_if_fail(st != NULL, NULL); |
234 | 0 | g_string_append_printf(str, " value: 0x%x\n", |
235 | 0 | (guint) fu_struct_intel_me_hfsts_get_value(st)); |
236 | 0 | if (str->len > 0) |
237 | 0 | g_string_set_size(str, str->len - 1); |
238 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
239 | 0 | } |
240 | | gboolean |
241 | | fu_struct_intel_me_hfsts_validate_internal(FuStructIntelMeHfsts *st, GError **error) |
242 | 0 | { |
243 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
244 | 0 | return TRUE; |
245 | 0 | } |
246 | | static gboolean |
247 | | fu_struct_intel_me_hfsts_parse_internal(FuStructIntelMeHfsts *st, GError **error) |
248 | 0 | { |
249 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
250 | 0 | g_autofree gchar *str = fu_struct_intel_me_hfsts_to_string(st); |
251 | 0 | g_debug("%s", str); |
252 | 0 | } |
253 | 0 | if (!fu_struct_intel_me_hfsts_validate_internal(st, error)) |
254 | 0 | return FALSE; |
255 | 0 | return TRUE; |
256 | 0 | } |
257 | | |
258 | | /** |
259 | | * fu_struct_intel_me_hfsts_parse: (skip): |
260 | | **/ |
261 | | FuStructIntelMeHfsts * |
262 | | fu_struct_intel_me_hfsts_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
263 | 0 | { |
264 | 0 | g_autoptr(FuStructIntelMeHfsts) st = fu_struct_intel_me_hfsts_new_internal(); |
265 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
266 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
267 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
268 | 0 | g_prefix_error_literal(error, "invalid struct FuStructIntelMeHfsts: "); |
269 | 0 | return NULL; |
270 | 0 | } |
271 | 0 | st->buf = g_byte_array_new(); |
272 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
273 | 0 | if (!fu_struct_intel_me_hfsts_parse_internal(st, error)) |
274 | 0 | return NULL; |
275 | 0 | return g_steal_pointer(&st); |
276 | 0 | } |
277 | | /** |
278 | | * fu_mei_csme11_hfsts1_ref: (skip): |
279 | | **/ |
280 | | FuMeiCsme11Hfsts1 * |
281 | | fu_mei_csme11_hfsts1_ref(FuMeiCsme11Hfsts1 *st) |
282 | 0 | { |
283 | 0 | g_return_val_if_fail(st != NULL, NULL); |
284 | 0 | st->refcount++; |
285 | 0 | return st; |
286 | 0 | } |
287 | | /** |
288 | | * fu_mei_csme11_hfsts1_unref: (skip): |
289 | | **/ |
290 | | void |
291 | | fu_mei_csme11_hfsts1_unref(FuMeiCsme11Hfsts1 *st) |
292 | 0 | { |
293 | 0 | g_return_if_fail(st != NULL); |
294 | 0 | if (st->refcount == 0) { |
295 | 0 | g_critical("FuMeiCsme11Hfsts1 refcount already zero"); |
296 | 0 | return; |
297 | 0 | } |
298 | 0 | if (--st->refcount > 0) |
299 | 0 | return; |
300 | 0 | if (st->buf != NULL) |
301 | 0 | g_byte_array_unref(st->buf); |
302 | 0 | g_free(st); |
303 | 0 | } |
304 | | /** |
305 | | * fu_mei_csme11_hfsts1_new_internal: (skip): |
306 | | **/ |
307 | | static FuMeiCsme11Hfsts1 * |
308 | | fu_mei_csme11_hfsts1_new_internal(void) |
309 | 0 | { |
310 | 0 | FuMeiCsme11Hfsts1 *st = g_new0(FuMeiCsme11Hfsts1, 1); |
311 | 0 | st->refcount = 1; |
312 | 0 | return st; |
313 | 0 | } |
314 | | |
315 | | /* getters */ |
316 | | /** |
317 | | * fu_mei_csme11_hfsts1_get_working_state: (skip): |
318 | | **/ |
319 | | FuMeHfsCws |
320 | | fu_mei_csme11_hfsts1_get_working_state(const FuMeiCsme11Hfsts1 *st) |
321 | 0 | { |
322 | 0 | guint32 val; |
323 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
324 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsCws), 0x0); |
325 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
326 | 0 | return (val >> 0) & 15; |
327 | 0 | } |
328 | | /** |
329 | | * fu_mei_csme11_hfsts1_get_mfg_mode: (skip): |
330 | | **/ |
331 | | guint32 |
332 | | fu_mei_csme11_hfsts1_get_mfg_mode(const FuMeiCsme11Hfsts1 *st) |
333 | 0 | { |
334 | 0 | guint32 val; |
335 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
336 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
337 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
338 | 0 | return (val >> 4) & 1; |
339 | 0 | } |
340 | | /** |
341 | | * fu_mei_csme11_hfsts1_get_operation_mode: (skip): |
342 | | **/ |
343 | | FuMeHfsMode |
344 | | fu_mei_csme11_hfsts1_get_operation_mode(const FuMeiCsme11Hfsts1 *st) |
345 | 0 | { |
346 | 0 | guint32 val; |
347 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
348 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsMode), 0x0); |
349 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
350 | 0 | return (val >> 16) & 15; |
351 | 0 | } |
352 | | |
353 | | /* setters */ |
354 | | /** |
355 | | * fu_mei_csme11_hfsts1_to_string: (skip): |
356 | | **/ |
357 | | gchar * |
358 | | fu_mei_csme11_hfsts1_to_string(const FuMeiCsme11Hfsts1 *st) |
359 | 0 | { |
360 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme11Hfsts1:\n"); |
361 | 0 | g_return_val_if_fail(st != NULL, NULL); |
362 | 0 | { |
363 | 0 | const gchar *tmp = fu_me_hfs_cws_to_string(fu_mei_csme11_hfsts1_get_working_state(st)); |
364 | 0 | if (tmp != NULL) { |
365 | 0 | g_string_append_printf(str, " working_state: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts1_get_working_state(st), tmp); |
366 | 0 | } else { |
367 | 0 | g_string_append_printf(str, " working_state: 0x%x\n", (guint) fu_mei_csme11_hfsts1_get_working_state(st)); |
368 | 0 | } |
369 | 0 | } |
370 | 0 | g_string_append_printf(str, " mfg_mode: 0x%x\n", |
371 | 0 | (guint) fu_mei_csme11_hfsts1_get_mfg_mode(st)); |
372 | 0 | { |
373 | 0 | const gchar *tmp = fu_me_hfs_mode_to_string(fu_mei_csme11_hfsts1_get_operation_mode(st)); |
374 | 0 | if (tmp != NULL) { |
375 | 0 | g_string_append_printf(str, " operation_mode: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts1_get_operation_mode(st), tmp); |
376 | 0 | } else { |
377 | 0 | g_string_append_printf(str, " operation_mode: 0x%x\n", (guint) fu_mei_csme11_hfsts1_get_operation_mode(st)); |
378 | 0 | } |
379 | 0 | } |
380 | 0 | if (str->len > 0) |
381 | 0 | g_string_set_size(str, str->len - 1); |
382 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
383 | 0 | } |
384 | | static gboolean |
385 | | fu_mei_csme11_hfsts1_validate_internal(FuMeiCsme11Hfsts1 *st, GError **error) |
386 | 0 | { |
387 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
388 | 0 | return TRUE; |
389 | 0 | } |
390 | | static gboolean |
391 | | fu_mei_csme11_hfsts1_parse_internal(FuMeiCsme11Hfsts1 *st, GError **error) |
392 | 0 | { |
393 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
394 | 0 | g_autofree gchar *str = fu_mei_csme11_hfsts1_to_string(st); |
395 | 0 | g_debug("%s", str); |
396 | 0 | } |
397 | 0 | if (!fu_mei_csme11_hfsts1_validate_internal(st, error)) |
398 | 0 | return FALSE; |
399 | 0 | return TRUE; |
400 | 0 | } |
401 | | |
402 | | /** |
403 | | * fu_mei_csme11_hfsts1_parse: (skip): |
404 | | **/ |
405 | | FuMeiCsme11Hfsts1 * |
406 | | fu_mei_csme11_hfsts1_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
407 | 0 | { |
408 | 0 | g_autoptr(FuMeiCsme11Hfsts1) st = fu_mei_csme11_hfsts1_new_internal(); |
409 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
410 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
411 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
412 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme11Hfsts1: "); |
413 | 0 | return NULL; |
414 | 0 | } |
415 | 0 | st->buf = g_byte_array_new(); |
416 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
417 | 0 | if (!fu_mei_csme11_hfsts1_parse_internal(st, error)) |
418 | 0 | return NULL; |
419 | 0 | return g_steal_pointer(&st); |
420 | 0 | } |
421 | | /** |
422 | | * fu_mei_csme11_hfsts2_ref: (skip): |
423 | | **/ |
424 | | FuMeiCsme11Hfsts2 * |
425 | | fu_mei_csme11_hfsts2_ref(FuMeiCsme11Hfsts2 *st) |
426 | 0 | { |
427 | 0 | g_return_val_if_fail(st != NULL, NULL); |
428 | 0 | st->refcount++; |
429 | 0 | return st; |
430 | 0 | } |
431 | | /** |
432 | | * fu_mei_csme11_hfsts2_unref: (skip): |
433 | | **/ |
434 | | void |
435 | | fu_mei_csme11_hfsts2_unref(FuMeiCsme11Hfsts2 *st) |
436 | 0 | { |
437 | 0 | g_return_if_fail(st != NULL); |
438 | 0 | if (st->refcount == 0) { |
439 | 0 | g_critical("FuMeiCsme11Hfsts2 refcount already zero"); |
440 | 0 | return; |
441 | 0 | } |
442 | 0 | if (--st->refcount > 0) |
443 | 0 | return; |
444 | 0 | if (st->buf != NULL) |
445 | 0 | g_byte_array_unref(st->buf); |
446 | 0 | g_free(st); |
447 | 0 | } |
448 | | |
449 | | /* getters */ |
450 | | |
451 | | /* setters */ |
452 | | /** |
453 | | * fu_mei_csme11_hfsts3_ref: (skip): |
454 | | **/ |
455 | | FuMeiCsme11Hfsts3 * |
456 | | fu_mei_csme11_hfsts3_ref(FuMeiCsme11Hfsts3 *st) |
457 | 0 | { |
458 | 0 | g_return_val_if_fail(st != NULL, NULL); |
459 | 0 | st->refcount++; |
460 | 0 | return st; |
461 | 0 | } |
462 | | /** |
463 | | * fu_mei_csme11_hfsts3_unref: (skip): |
464 | | **/ |
465 | | void |
466 | | fu_mei_csme11_hfsts3_unref(FuMeiCsme11Hfsts3 *st) |
467 | 0 | { |
468 | 0 | g_return_if_fail(st != NULL); |
469 | 0 | if (st->refcount == 0) { |
470 | 0 | g_critical("FuMeiCsme11Hfsts3 refcount already zero"); |
471 | 0 | return; |
472 | 0 | } |
473 | 0 | if (--st->refcount > 0) |
474 | 0 | return; |
475 | 0 | if (st->buf != NULL) |
476 | 0 | g_byte_array_unref(st->buf); |
477 | 0 | g_free(st); |
478 | 0 | } |
479 | | |
480 | | /* getters */ |
481 | | |
482 | | /* setters */ |
483 | | /** |
484 | | * fu_mei_csme11_hfsts4_ref: (skip): |
485 | | **/ |
486 | | FuMeiCsme11Hfsts4 * |
487 | | fu_mei_csme11_hfsts4_ref(FuMeiCsme11Hfsts4 *st) |
488 | 0 | { |
489 | 0 | g_return_val_if_fail(st != NULL, NULL); |
490 | 0 | st->refcount++; |
491 | 0 | return st; |
492 | 0 | } |
493 | | /** |
494 | | * fu_mei_csme11_hfsts4_unref: (skip): |
495 | | **/ |
496 | | void |
497 | | fu_mei_csme11_hfsts4_unref(FuMeiCsme11Hfsts4 *st) |
498 | 0 | { |
499 | 0 | g_return_if_fail(st != NULL); |
500 | 0 | if (st->refcount == 0) { |
501 | 0 | g_critical("FuMeiCsme11Hfsts4 refcount already zero"); |
502 | 0 | return; |
503 | 0 | } |
504 | 0 | if (--st->refcount > 0) |
505 | 0 | return; |
506 | 0 | if (st->buf != NULL) |
507 | 0 | g_byte_array_unref(st->buf); |
508 | 0 | g_free(st); |
509 | 0 | } |
510 | | |
511 | | /* getters */ |
512 | | |
513 | | /* setters */ |
514 | | /** |
515 | | * fu_mei_csme11_hfsts5_ref: (skip): |
516 | | **/ |
517 | | FuMeiCsme11Hfsts5 * |
518 | | fu_mei_csme11_hfsts5_ref(FuMeiCsme11Hfsts5 *st) |
519 | 0 | { |
520 | 0 | g_return_val_if_fail(st != NULL, NULL); |
521 | 0 | st->refcount++; |
522 | 0 | return st; |
523 | 0 | } |
524 | | /** |
525 | | * fu_mei_csme11_hfsts5_unref: (skip): |
526 | | **/ |
527 | | void |
528 | | fu_mei_csme11_hfsts5_unref(FuMeiCsme11Hfsts5 *st) |
529 | 0 | { |
530 | 0 | g_return_if_fail(st != NULL); |
531 | 0 | if (st->refcount == 0) { |
532 | 0 | g_critical("FuMeiCsme11Hfsts5 refcount already zero"); |
533 | 0 | return; |
534 | 0 | } |
535 | 0 | if (--st->refcount > 0) |
536 | 0 | return; |
537 | 0 | if (st->buf != NULL) |
538 | 0 | g_byte_array_unref(st->buf); |
539 | 0 | g_free(st); |
540 | 0 | } |
541 | | |
542 | | /* getters */ |
543 | | |
544 | | /* setters */ |
545 | | /** |
546 | | * fu_mei_csme11_hfsts6_ref: (skip): |
547 | | **/ |
548 | | FuMeiCsme11Hfsts6 * |
549 | | fu_mei_csme11_hfsts6_ref(FuMeiCsme11Hfsts6 *st) |
550 | 0 | { |
551 | 0 | g_return_val_if_fail(st != NULL, NULL); |
552 | 0 | st->refcount++; |
553 | 0 | return st; |
554 | 0 | } |
555 | | /** |
556 | | * fu_mei_csme11_hfsts6_unref: (skip): |
557 | | **/ |
558 | | void |
559 | | fu_mei_csme11_hfsts6_unref(FuMeiCsme11Hfsts6 *st) |
560 | 0 | { |
561 | 0 | g_return_if_fail(st != NULL); |
562 | 0 | if (st->refcount == 0) { |
563 | 0 | g_critical("FuMeiCsme11Hfsts6 refcount already zero"); |
564 | 0 | return; |
565 | 0 | } |
566 | 0 | if (--st->refcount > 0) |
567 | 0 | return; |
568 | 0 | if (st->buf != NULL) |
569 | 0 | g_byte_array_unref(st->buf); |
570 | 0 | g_free(st); |
571 | 0 | } |
572 | | /** |
573 | | * fu_mei_csme11_hfsts6_new_internal: (skip): |
574 | | **/ |
575 | | static FuMeiCsme11Hfsts6 * |
576 | | fu_mei_csme11_hfsts6_new_internal(void) |
577 | 0 | { |
578 | 0 | FuMeiCsme11Hfsts6 *st = g_new0(FuMeiCsme11Hfsts6, 1); |
579 | 0 | st->refcount = 1; |
580 | 0 | return st; |
581 | 0 | } |
582 | | |
583 | | /* getters */ |
584 | | /** |
585 | | * fu_mei_csme11_hfsts6_get_force_boot_guard_acm: (skip): |
586 | | **/ |
587 | | guint32 |
588 | | fu_mei_csme11_hfsts6_get_force_boot_guard_acm(const FuMeiCsme11Hfsts6 *st) |
589 | 0 | { |
590 | 0 | guint32 val; |
591 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
592 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
593 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
594 | 0 | return (val >> 0) & 1; |
595 | 0 | } |
596 | | /** |
597 | | * fu_mei_csme11_hfsts6_get_error_enforce_policy: (skip): |
598 | | **/ |
599 | | FuMeHfsEnforcementPolicy |
600 | | fu_mei_csme11_hfsts6_get_error_enforce_policy(const FuMeiCsme11Hfsts6 *st) |
601 | 0 | { |
602 | 0 | guint32 val; |
603 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
604 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsEnforcementPolicy), 0x0); |
605 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
606 | 0 | return (val >> 6) & 3; |
607 | 0 | } |
608 | | /** |
609 | | * fu_mei_csme11_hfsts6_get_verified_boot: (skip): |
610 | | **/ |
611 | | guint32 |
612 | | fu_mei_csme11_hfsts6_get_verified_boot(const FuMeiCsme11Hfsts6 *st) |
613 | 0 | { |
614 | 0 | guint32 val; |
615 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
616 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
617 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
618 | 0 | return (val >> 9) & 1; |
619 | 0 | } |
620 | | /** |
621 | | * fu_mei_csme11_hfsts6_get_boot_guard_disable: (skip): |
622 | | **/ |
623 | | guint32 |
624 | | fu_mei_csme11_hfsts6_get_boot_guard_disable(const FuMeiCsme11Hfsts6 *st) |
625 | 0 | { |
626 | 0 | guint32 val; |
627 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
628 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
629 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
630 | 0 | return (val >> 28) & 1; |
631 | 0 | } |
632 | | /** |
633 | | * fu_mei_csme11_hfsts6_get_fpf_soc_lock: (skip): |
634 | | **/ |
635 | | guint32 |
636 | | fu_mei_csme11_hfsts6_get_fpf_soc_lock(const FuMeiCsme11Hfsts6 *st) |
637 | 0 | { |
638 | 0 | guint32 val; |
639 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
640 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
641 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
642 | 0 | return (val >> 30) & 1; |
643 | 0 | } |
644 | | |
645 | | /* setters */ |
646 | | /** |
647 | | * fu_mei_csme11_hfsts6_to_string: (skip): |
648 | | **/ |
649 | | static gchar * |
650 | | fu_mei_csme11_hfsts6_to_string(const FuMeiCsme11Hfsts6 *st) |
651 | 0 | { |
652 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme11Hfsts6:\n"); |
653 | 0 | g_return_val_if_fail(st != NULL, NULL); |
654 | 0 | g_string_append_printf(str, " force_boot_guard_acm: 0x%x\n", |
655 | 0 | (guint) fu_mei_csme11_hfsts6_get_force_boot_guard_acm(st)); |
656 | 0 | { |
657 | 0 | const gchar *tmp = fu_me_hfs_enforcement_policy_to_string(fu_mei_csme11_hfsts6_get_error_enforce_policy(st)); |
658 | 0 | if (tmp != NULL) { |
659 | 0 | g_string_append_printf(str, " error_enforce_policy: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts6_get_error_enforce_policy(st), tmp); |
660 | 0 | } else { |
661 | 0 | g_string_append_printf(str, " error_enforce_policy: 0x%x\n", (guint) fu_mei_csme11_hfsts6_get_error_enforce_policy(st)); |
662 | 0 | } |
663 | 0 | } |
664 | 0 | g_string_append_printf(str, " verified_boot: 0x%x\n", |
665 | 0 | (guint) fu_mei_csme11_hfsts6_get_verified_boot(st)); |
666 | 0 | g_string_append_printf(str, " boot_guard_disable: 0x%x\n", |
667 | 0 | (guint) fu_mei_csme11_hfsts6_get_boot_guard_disable(st)); |
668 | 0 | g_string_append_printf(str, " fpf_soc_lock: 0x%x\n", |
669 | 0 | (guint) fu_mei_csme11_hfsts6_get_fpf_soc_lock(st)); |
670 | 0 | if (str->len > 0) |
671 | 0 | g_string_set_size(str, str->len - 1); |
672 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
673 | 0 | } |
674 | | static gboolean |
675 | | fu_mei_csme11_hfsts6_validate_internal(FuMeiCsme11Hfsts6 *st, GError **error) |
676 | 0 | { |
677 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
678 | 0 | return TRUE; |
679 | 0 | } |
680 | | static gboolean |
681 | | fu_mei_csme11_hfsts6_parse_internal(FuMeiCsme11Hfsts6 *st, GError **error) |
682 | 0 | { |
683 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
684 | 0 | g_autofree gchar *str = fu_mei_csme11_hfsts6_to_string(st); |
685 | 0 | g_debug("%s", str); |
686 | 0 | } |
687 | 0 | if (!fu_mei_csme11_hfsts6_validate_internal(st, error)) |
688 | 0 | return FALSE; |
689 | 0 | return TRUE; |
690 | 0 | } |
691 | | |
692 | | /** |
693 | | * fu_mei_csme11_hfsts6_parse: (skip): |
694 | | **/ |
695 | | FuMeiCsme11Hfsts6 * |
696 | | fu_mei_csme11_hfsts6_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
697 | 0 | { |
698 | 0 | g_autoptr(FuMeiCsme11Hfsts6) st = fu_mei_csme11_hfsts6_new_internal(); |
699 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
700 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
701 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
702 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme11Hfsts6: "); |
703 | 0 | return NULL; |
704 | 0 | } |
705 | 0 | st->buf = g_byte_array_new(); |
706 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
707 | 0 | if (!fu_mei_csme11_hfsts6_parse_internal(st, error)) |
708 | 0 | return NULL; |
709 | 0 | return g_steal_pointer(&st); |
710 | 0 | } |
711 | | /** |
712 | | * fu_mei_csme18_hfsts1_ref: (skip): |
713 | | **/ |
714 | | FuMeiCsme18Hfsts1 * |
715 | | fu_mei_csme18_hfsts1_ref(FuMeiCsme18Hfsts1 *st) |
716 | 0 | { |
717 | 0 | g_return_val_if_fail(st != NULL, NULL); |
718 | 0 | st->refcount++; |
719 | 0 | return st; |
720 | 0 | } |
721 | | /** |
722 | | * fu_mei_csme18_hfsts1_unref: (skip): |
723 | | **/ |
724 | | void |
725 | | fu_mei_csme18_hfsts1_unref(FuMeiCsme18Hfsts1 *st) |
726 | 0 | { |
727 | 0 | g_return_if_fail(st != NULL); |
728 | 0 | if (st->refcount == 0) { |
729 | 0 | g_critical("FuMeiCsme18Hfsts1 refcount already zero"); |
730 | 0 | return; |
731 | 0 | } |
732 | 0 | if (--st->refcount > 0) |
733 | 0 | return; |
734 | 0 | if (st->buf != NULL) |
735 | 0 | g_byte_array_unref(st->buf); |
736 | 0 | g_free(st); |
737 | 0 | } |
738 | | /** |
739 | | * fu_mei_csme18_hfsts1_new_internal: (skip): |
740 | | **/ |
741 | | static FuMeiCsme18Hfsts1 * |
742 | | fu_mei_csme18_hfsts1_new_internal(void) |
743 | 0 | { |
744 | 0 | FuMeiCsme18Hfsts1 *st = g_new0(FuMeiCsme18Hfsts1, 1); |
745 | 0 | st->refcount = 1; |
746 | 0 | return st; |
747 | 0 | } |
748 | | |
749 | | /* getters */ |
750 | | /** |
751 | | * fu_mei_csme18_hfsts1_get_spi_protection_mode: (skip): |
752 | | **/ |
753 | | guint32 |
754 | | fu_mei_csme18_hfsts1_get_spi_protection_mode(const FuMeiCsme18Hfsts1 *st) |
755 | 0 | { |
756 | 0 | guint32 val; |
757 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
758 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
759 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
760 | 0 | return (val >> 4) & 1; |
761 | 0 | } |
762 | | /** |
763 | | * fu_mei_csme18_hfsts1_get_operation_mode: (skip): |
764 | | **/ |
765 | | FuMeHfsMode |
766 | | fu_mei_csme18_hfsts1_get_operation_mode(const FuMeiCsme18Hfsts1 *st) |
767 | 0 | { |
768 | 0 | guint32 val; |
769 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
770 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsMode), 0x0); |
771 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
772 | 0 | return (val >> 16) & 15; |
773 | 0 | } |
774 | | |
775 | | /* setters */ |
776 | | /** |
777 | | * fu_mei_csme18_hfsts1_to_string: (skip): |
778 | | **/ |
779 | | static gchar * |
780 | | fu_mei_csme18_hfsts1_to_string(const FuMeiCsme18Hfsts1 *st) |
781 | 0 | { |
782 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts1:\n"); |
783 | 0 | g_return_val_if_fail(st != NULL, NULL); |
784 | 0 | g_string_append_printf(str, " spi_protection_mode: 0x%x\n", |
785 | 0 | (guint) fu_mei_csme18_hfsts1_get_spi_protection_mode(st)); |
786 | 0 | { |
787 | 0 | const gchar *tmp = fu_me_hfs_mode_to_string(fu_mei_csme18_hfsts1_get_operation_mode(st)); |
788 | 0 | if (tmp != NULL) { |
789 | 0 | g_string_append_printf(str, " operation_mode: 0x%x [%s]\n", (guint) fu_mei_csme18_hfsts1_get_operation_mode(st), tmp); |
790 | 0 | } else { |
791 | 0 | g_string_append_printf(str, " operation_mode: 0x%x\n", (guint) fu_mei_csme18_hfsts1_get_operation_mode(st)); |
792 | 0 | } |
793 | 0 | } |
794 | 0 | if (str->len > 0) |
795 | 0 | g_string_set_size(str, str->len - 1); |
796 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
797 | 0 | } |
798 | | static gboolean |
799 | | fu_mei_csme18_hfsts1_validate_internal(FuMeiCsme18Hfsts1 *st, GError **error) |
800 | 0 | { |
801 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
802 | 0 | return TRUE; |
803 | 0 | } |
804 | | static gboolean |
805 | | fu_mei_csme18_hfsts1_parse_internal(FuMeiCsme18Hfsts1 *st, GError **error) |
806 | 0 | { |
807 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
808 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts1_to_string(st); |
809 | 0 | g_debug("%s", str); |
810 | 0 | } |
811 | 0 | if (!fu_mei_csme18_hfsts1_validate_internal(st, error)) |
812 | 0 | return FALSE; |
813 | 0 | return TRUE; |
814 | 0 | } |
815 | | |
816 | | /** |
817 | | * fu_mei_csme18_hfsts1_parse: (skip): |
818 | | **/ |
819 | | FuMeiCsme18Hfsts1 * |
820 | | fu_mei_csme18_hfsts1_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
821 | 0 | { |
822 | 0 | g_autoptr(FuMeiCsme18Hfsts1) st = fu_mei_csme18_hfsts1_new_internal(); |
823 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
824 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
825 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
826 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts1: "); |
827 | 0 | return NULL; |
828 | 0 | } |
829 | 0 | st->buf = g_byte_array_new(); |
830 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
831 | 0 | if (!fu_mei_csme18_hfsts1_parse_internal(st, error)) |
832 | 0 | return NULL; |
833 | 0 | return g_steal_pointer(&st); |
834 | 0 | } |
835 | | /** |
836 | | * fu_mei_csme18_hfsts2_ref: (skip): |
837 | | **/ |
838 | | FuMeiCsme18Hfsts2 * |
839 | | fu_mei_csme18_hfsts2_ref(FuMeiCsme18Hfsts2 *st) |
840 | 0 | { |
841 | 0 | g_return_val_if_fail(st != NULL, NULL); |
842 | 0 | st->refcount++; |
843 | 0 | return st; |
844 | 0 | } |
845 | | /** |
846 | | * fu_mei_csme18_hfsts2_unref: (skip): |
847 | | **/ |
848 | | void |
849 | | fu_mei_csme18_hfsts2_unref(FuMeiCsme18Hfsts2 *st) |
850 | 0 | { |
851 | 0 | g_return_if_fail(st != NULL); |
852 | 0 | if (st->refcount == 0) { |
853 | 0 | g_critical("FuMeiCsme18Hfsts2 refcount already zero"); |
854 | 0 | return; |
855 | 0 | } |
856 | 0 | if (--st->refcount > 0) |
857 | 0 | return; |
858 | 0 | if (st->buf != NULL) |
859 | 0 | g_byte_array_unref(st->buf); |
860 | 0 | g_free(st); |
861 | 0 | } |
862 | | |
863 | | /* getters */ |
864 | | |
865 | | /* setters */ |
866 | | /** |
867 | | * fu_mei_csme18_hfsts3_ref: (skip): |
868 | | **/ |
869 | | FuMeiCsme18Hfsts3 * |
870 | | fu_mei_csme18_hfsts3_ref(FuMeiCsme18Hfsts3 *st) |
871 | 0 | { |
872 | 0 | g_return_val_if_fail(st != NULL, NULL); |
873 | 0 | st->refcount++; |
874 | 0 | return st; |
875 | 0 | } |
876 | | /** |
877 | | * fu_mei_csme18_hfsts3_unref: (skip): |
878 | | **/ |
879 | | void |
880 | | fu_mei_csme18_hfsts3_unref(FuMeiCsme18Hfsts3 *st) |
881 | 0 | { |
882 | 0 | g_return_if_fail(st != NULL); |
883 | 0 | if (st->refcount == 0) { |
884 | 0 | g_critical("FuMeiCsme18Hfsts3 refcount already zero"); |
885 | 0 | return; |
886 | 0 | } |
887 | 0 | if (--st->refcount > 0) |
888 | 0 | return; |
889 | 0 | if (st->buf != NULL) |
890 | 0 | g_byte_array_unref(st->buf); |
891 | 0 | g_free(st); |
892 | 0 | } |
893 | | |
894 | | /* getters */ |
895 | | |
896 | | /* setters */ |
897 | | /** |
898 | | * fu_mei_csme18_hfsts4_ref: (skip): |
899 | | **/ |
900 | | FuMeiCsme18Hfsts4 * |
901 | | fu_mei_csme18_hfsts4_ref(FuMeiCsme18Hfsts4 *st) |
902 | 0 | { |
903 | 0 | g_return_val_if_fail(st != NULL, NULL); |
904 | 0 | st->refcount++; |
905 | 0 | return st; |
906 | 0 | } |
907 | | /** |
908 | | * fu_mei_csme18_hfsts4_unref: (skip): |
909 | | **/ |
910 | | void |
911 | | fu_mei_csme18_hfsts4_unref(FuMeiCsme18Hfsts4 *st) |
912 | 0 | { |
913 | 0 | g_return_if_fail(st != NULL); |
914 | 0 | if (st->refcount == 0) { |
915 | 0 | g_critical("FuMeiCsme18Hfsts4 refcount already zero"); |
916 | 0 | return; |
917 | 0 | } |
918 | 0 | if (--st->refcount > 0) |
919 | 0 | return; |
920 | 0 | if (st->buf != NULL) |
921 | 0 | g_byte_array_unref(st->buf); |
922 | 0 | g_free(st); |
923 | 0 | } |
924 | | |
925 | | /* getters */ |
926 | | |
927 | | /* setters */ |
928 | | /** |
929 | | * fu_mei_csme18_hfsts5_ref: (skip): |
930 | | **/ |
931 | | FuMeiCsme18Hfsts5 * |
932 | | fu_mei_csme18_hfsts5_ref(FuMeiCsme18Hfsts5 *st) |
933 | 0 | { |
934 | 0 | g_return_val_if_fail(st != NULL, NULL); |
935 | 0 | st->refcount++; |
936 | 0 | return st; |
937 | 0 | } |
938 | | /** |
939 | | * fu_mei_csme18_hfsts5_unref: (skip): |
940 | | **/ |
941 | | void |
942 | | fu_mei_csme18_hfsts5_unref(FuMeiCsme18Hfsts5 *st) |
943 | 0 | { |
944 | 0 | g_return_if_fail(st != NULL); |
945 | 0 | if (st->refcount == 0) { |
946 | 0 | g_critical("FuMeiCsme18Hfsts5 refcount already zero"); |
947 | 0 | return; |
948 | 0 | } |
949 | 0 | if (--st->refcount > 0) |
950 | 0 | return; |
951 | 0 | if (st->buf != NULL) |
952 | 0 | g_byte_array_unref(st->buf); |
953 | 0 | g_free(st); |
954 | 0 | } |
955 | | /** |
956 | | * fu_mei_csme18_hfsts5_new_internal: (skip): |
957 | | **/ |
958 | | static FuMeiCsme18Hfsts5 * |
959 | | fu_mei_csme18_hfsts5_new_internal(void) |
960 | 0 | { |
961 | 0 | FuMeiCsme18Hfsts5 *st = g_new0(FuMeiCsme18Hfsts5, 1); |
962 | 0 | st->refcount = 1; |
963 | 0 | return st; |
964 | 0 | } |
965 | | |
966 | | /* getters */ |
967 | | /** |
968 | | * fu_mei_csme18_hfsts5_get_btg_acm_active: (skip): |
969 | | **/ |
970 | | guint32 |
971 | | fu_mei_csme18_hfsts5_get_btg_acm_active(const FuMeiCsme18Hfsts5 *st) |
972 | 0 | { |
973 | 0 | guint32 val; |
974 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
975 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
976 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
977 | 0 | return (val >> 0) & 1; |
978 | 0 | } |
979 | | /** |
980 | | * fu_mei_csme18_hfsts5_get_valid: (skip): |
981 | | **/ |
982 | | guint32 |
983 | | fu_mei_csme18_hfsts5_get_valid(const FuMeiCsme18Hfsts5 *st) |
984 | 0 | { |
985 | 0 | guint32 val; |
986 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
987 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
988 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
989 | 0 | return (val >> 1) & 1; |
990 | 0 | } |
991 | | /** |
992 | | * fu_mei_csme18_hfsts5_get_acm_done_sts: (skip): |
993 | | **/ |
994 | | guint32 |
995 | | fu_mei_csme18_hfsts5_get_acm_done_sts(const FuMeiCsme18Hfsts5 *st) |
996 | 0 | { |
997 | 0 | guint32 val; |
998 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
999 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
1000 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1001 | 0 | return (val >> 8) & 1; |
1002 | 0 | } |
1003 | | |
1004 | | /* setters */ |
1005 | | /** |
1006 | | * fu_mei_csme18_hfsts5_to_string: (skip): |
1007 | | **/ |
1008 | | static gchar * |
1009 | | fu_mei_csme18_hfsts5_to_string(const FuMeiCsme18Hfsts5 *st) |
1010 | 0 | { |
1011 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts5:\n"); |
1012 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1013 | 0 | g_string_append_printf(str, " btg_acm_active: 0x%x\n", |
1014 | 0 | (guint) fu_mei_csme18_hfsts5_get_btg_acm_active(st)); |
1015 | 0 | g_string_append_printf(str, " valid: 0x%x\n", |
1016 | 0 | (guint) fu_mei_csme18_hfsts5_get_valid(st)); |
1017 | 0 | g_string_append_printf(str, " acm_done_sts: 0x%x\n", |
1018 | 0 | (guint) fu_mei_csme18_hfsts5_get_acm_done_sts(st)); |
1019 | 0 | if (str->len > 0) |
1020 | 0 | g_string_set_size(str, str->len - 1); |
1021 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1022 | 0 | } |
1023 | | static gboolean |
1024 | | fu_mei_csme18_hfsts5_validate_internal(FuMeiCsme18Hfsts5 *st, GError **error) |
1025 | 0 | { |
1026 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1027 | 0 | return TRUE; |
1028 | 0 | } |
1029 | | static gboolean |
1030 | | fu_mei_csme18_hfsts5_parse_internal(FuMeiCsme18Hfsts5 *st, GError **error) |
1031 | 0 | { |
1032 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1033 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts5_to_string(st); |
1034 | 0 | g_debug("%s", str); |
1035 | 0 | } |
1036 | 0 | if (!fu_mei_csme18_hfsts5_validate_internal(st, error)) |
1037 | 0 | return FALSE; |
1038 | 0 | return TRUE; |
1039 | 0 | } |
1040 | | |
1041 | | /** |
1042 | | * fu_mei_csme18_hfsts5_parse: (skip): |
1043 | | **/ |
1044 | | FuMeiCsme18Hfsts5 * |
1045 | | fu_mei_csme18_hfsts5_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1046 | 0 | { |
1047 | 0 | g_autoptr(FuMeiCsme18Hfsts5) st = fu_mei_csme18_hfsts5_new_internal(); |
1048 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1049 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1050 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1051 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts5: "); |
1052 | 0 | return NULL; |
1053 | 0 | } |
1054 | 0 | st->buf = g_byte_array_new(); |
1055 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1056 | 0 | if (!fu_mei_csme18_hfsts5_parse_internal(st, error)) |
1057 | 0 | return NULL; |
1058 | 0 | return g_steal_pointer(&st); |
1059 | 0 | } |
1060 | | /** |
1061 | | * fu_mei_csme18_hfsts6_ref: (skip): |
1062 | | **/ |
1063 | | FuMeiCsme18Hfsts6 * |
1064 | | fu_mei_csme18_hfsts6_ref(FuMeiCsme18Hfsts6 *st) |
1065 | 0 | { |
1066 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1067 | 0 | st->refcount++; |
1068 | 0 | return st; |
1069 | 0 | } |
1070 | | /** |
1071 | | * fu_mei_csme18_hfsts6_unref: (skip): |
1072 | | **/ |
1073 | | void |
1074 | | fu_mei_csme18_hfsts6_unref(FuMeiCsme18Hfsts6 *st) |
1075 | 0 | { |
1076 | 0 | g_return_if_fail(st != NULL); |
1077 | 0 | if (st->refcount == 0) { |
1078 | 0 | g_critical("FuMeiCsme18Hfsts6 refcount already zero"); |
1079 | 0 | return; |
1080 | 0 | } |
1081 | 0 | if (--st->refcount > 0) |
1082 | 0 | return; |
1083 | 0 | if (st->buf != NULL) |
1084 | 0 | g_byte_array_unref(st->buf); |
1085 | 0 | g_free(st); |
1086 | 0 | } |
1087 | | /** |
1088 | | * fu_mei_csme18_hfsts6_new_internal: (skip): |
1089 | | **/ |
1090 | | static FuMeiCsme18Hfsts6 * |
1091 | | fu_mei_csme18_hfsts6_new_internal(void) |
1092 | 0 | { |
1093 | 0 | FuMeiCsme18Hfsts6 *st = g_new0(FuMeiCsme18Hfsts6, 1); |
1094 | 0 | st->refcount = 1; |
1095 | 0 | return st; |
1096 | 0 | } |
1097 | | |
1098 | | /* getters */ |
1099 | | /** |
1100 | | * fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock: (skip): |
1101 | | **/ |
1102 | | guint32 |
1103 | | fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock(const FuMeiCsme18Hfsts6 *st) |
1104 | 0 | { |
1105 | 0 | guint32 val; |
1106 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1107 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
1108 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1109 | 0 | return (val >> 30) & 1; |
1110 | 0 | } |
1111 | | |
1112 | | /* setters */ |
1113 | | /** |
1114 | | * fu_mei_csme18_hfsts6_to_string: (skip): |
1115 | | **/ |
1116 | | static gchar * |
1117 | | fu_mei_csme18_hfsts6_to_string(const FuMeiCsme18Hfsts6 *st) |
1118 | 0 | { |
1119 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts6:\n"); |
1120 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1121 | 0 | g_string_append_printf(str, " fpf_soc_configuration_lock: 0x%x\n", |
1122 | 0 | (guint) fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock(st)); |
1123 | 0 | if (str->len > 0) |
1124 | 0 | g_string_set_size(str, str->len - 1); |
1125 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1126 | 0 | } |
1127 | | static gboolean |
1128 | | fu_mei_csme18_hfsts6_validate_internal(FuMeiCsme18Hfsts6 *st, GError **error) |
1129 | 0 | { |
1130 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1131 | 0 | return TRUE; |
1132 | 0 | } |
1133 | | static gboolean |
1134 | | fu_mei_csme18_hfsts6_parse_internal(FuMeiCsme18Hfsts6 *st, GError **error) |
1135 | 0 | { |
1136 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1137 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts6_to_string(st); |
1138 | 0 | g_debug("%s", str); |
1139 | 0 | } |
1140 | 0 | if (!fu_mei_csme18_hfsts6_validate_internal(st, error)) |
1141 | 0 | return FALSE; |
1142 | 0 | return TRUE; |
1143 | 0 | } |
1144 | | |
1145 | | /** |
1146 | | * fu_mei_csme18_hfsts6_parse: (skip): |
1147 | | **/ |
1148 | | FuMeiCsme18Hfsts6 * |
1149 | | fu_mei_csme18_hfsts6_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1150 | 0 | { |
1151 | 0 | g_autoptr(FuMeiCsme18Hfsts6) st = fu_mei_csme18_hfsts6_new_internal(); |
1152 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1153 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1154 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1155 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts6: "); |
1156 | 0 | return NULL; |
1157 | 0 | } |
1158 | 0 | st->buf = g_byte_array_new(); |
1159 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1160 | 0 | if (!fu_mei_csme18_hfsts6_parse_internal(st, error)) |
1161 | 0 | return NULL; |
1162 | 0 | return g_steal_pointer(&st); |
1163 | 0 | } |