Line | Count | Source (jump to first uncovered line) |
1 | | /* auto-generated, do not modify */ |
2 | | #include "config.h" |
3 | | |
4 | | #include "fu-ifd-struct.h" |
5 | | #include "fu-byte-array.h" |
6 | | #include "fu-mem-private.h" |
7 | | #include "fu-string.h" |
8 | | |
9 | | #ifdef G_LOG_DOMAIN |
10 | | #undef G_LOG_DOMAIN |
11 | | #endif |
12 | 0 | #define G_LOG_DOMAIN "FuStruct" |
13 | | |
14 | | const gchar * |
15 | | fu_ifd_region_to_string(FuIfdRegion val) |
16 | 9.95k | { |
17 | 9.95k | if (val == FU_IFD_REGION_DESC) |
18 | 1.63k | return "desc"; |
19 | 8.31k | if (val == FU_IFD_REGION_BIOS) |
20 | 1.63k | return "bios"; |
21 | 6.68k | if (val == FU_IFD_REGION_ME) |
22 | 1.32k | return "me"; |
23 | 5.35k | if (val == FU_IFD_REGION_GBE) |
24 | 1.20k | return "gbe"; |
25 | 4.15k | if (val == FU_IFD_REGION_PLATFORM) |
26 | 1.17k | return "platform"; |
27 | 2.97k | if (val == FU_IFD_REGION_DEVEXP) |
28 | 923 | return "devexp"; |
29 | 2.05k | if (val == FU_IFD_REGION_BIOS2) |
30 | 529 | return "bios2"; |
31 | 1.52k | if (val == FU_IFD_REGION_EC) |
32 | 505 | return "ec"; |
33 | 1.01k | if (val == FU_IFD_REGION_IE) |
34 | 0 | return "ie"; |
35 | 1.01k | if (val == FU_IFD_REGION_10GBE) |
36 | 0 | return "10gbe"; |
37 | 1.01k | if (val == FU_IFD_REGION_MAX) |
38 | 0 | return "max"; |
39 | 1.01k | return NULL; |
40 | 1.01k | } |
41 | | |
42 | | gchar * |
43 | | fu_ifd_access_to_string(FuIfdAccess val) |
44 | 0 | { |
45 | 0 | const gchar *data[3] = {0}; |
46 | 0 | guint idx = 0; |
47 | 0 | if (val == FU_IFD_ACCESS_NONE) |
48 | 0 | return g_strdup("none"); |
49 | 0 | if (val & FU_IFD_ACCESS_READ) |
50 | 0 | data[idx++] = "read"; |
51 | 0 | if (val & FU_IFD_ACCESS_WRITE) |
52 | 0 | data[idx++] = "write"; |
53 | 0 | return g_strjoinv(",", (gchar **)data); |
54 | 0 | } |
55 | | /* getters */ |
56 | | /** |
57 | | * fu_struct_ifd_fdbar_get_signature: (skip): |
58 | | **/ |
59 | | static guint32 |
60 | | fu_struct_ifd_fdbar_get_signature(const FuStructIfdFdbar *st) |
61 | 14.5M | { |
62 | 14.5M | g_return_val_if_fail(st != NULL, 0x0); |
63 | 14.5M | return fu_memread_uint32(st->data + 16, G_LITTLE_ENDIAN); |
64 | 14.5M | } |
65 | | /** |
66 | | * fu_struct_ifd_fdbar_get_descriptor_map0: (skip): |
67 | | **/ |
68 | | guint32 |
69 | | fu_struct_ifd_fdbar_get_descriptor_map0(const FuStructIfdFdbar *st) |
70 | 1.64k | { |
71 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
72 | 1.64k | return fu_memread_uint32(st->data + 20, G_LITTLE_ENDIAN); |
73 | 1.64k | } |
74 | | /** |
75 | | * fu_struct_ifd_fdbar_get_descriptor_map1: (skip): |
76 | | **/ |
77 | | guint32 |
78 | | fu_struct_ifd_fdbar_get_descriptor_map1(const FuStructIfdFdbar *st) |
79 | 1.64k | { |
80 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
81 | 1.64k | return fu_memread_uint32(st->data + 24, G_LITTLE_ENDIAN); |
82 | 1.64k | } |
83 | | /** |
84 | | * fu_struct_ifd_fdbar_get_descriptor_map2: (skip): |
85 | | **/ |
86 | | guint32 |
87 | | fu_struct_ifd_fdbar_get_descriptor_map2(const FuStructIfdFdbar *st) |
88 | 1.64k | { |
89 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
90 | 1.64k | return fu_memread_uint32(st->data + 28, G_LITTLE_ENDIAN); |
91 | 1.64k | } |
92 | | |
93 | | /* setters */ |
94 | | /** |
95 | | * fu_struct_ifd_fdbar_set_signature: (skip): |
96 | | **/ |
97 | | static void |
98 | | fu_struct_ifd_fdbar_set_signature(FuStructIfdFdbar *st, guint32 value) |
99 | 647 | { |
100 | 647 | g_return_if_fail(st != NULL); |
101 | 647 | fu_memwrite_uint32(st->data + 16, value, G_LITTLE_ENDIAN); |
102 | 647 | } |
103 | | /** |
104 | | * fu_struct_ifd_fdbar_set_descriptor_map0: (skip): |
105 | | **/ |
106 | | void |
107 | | fu_struct_ifd_fdbar_set_descriptor_map0(FuStructIfdFdbar *st, guint32 value) |
108 | 65 | { |
109 | 65 | g_return_if_fail(st != NULL); |
110 | 65 | fu_memwrite_uint32(st->data + 20, value, G_LITTLE_ENDIAN); |
111 | 65 | } |
112 | | /** |
113 | | * fu_struct_ifd_fdbar_set_descriptor_map1: (skip): |
114 | | **/ |
115 | | void |
116 | | fu_struct_ifd_fdbar_set_descriptor_map1(FuStructIfdFdbar *st, guint32 value) |
117 | 65 | { |
118 | 65 | g_return_if_fail(st != NULL); |
119 | 65 | fu_memwrite_uint32(st->data + 24, value, G_LITTLE_ENDIAN); |
120 | 65 | } |
121 | | /** |
122 | | * fu_struct_ifd_fdbar_set_descriptor_map2: (skip): |
123 | | **/ |
124 | | void |
125 | | fu_struct_ifd_fdbar_set_descriptor_map2(FuStructIfdFdbar *st, guint32 value) |
126 | 65 | { |
127 | 65 | g_return_if_fail(st != NULL); |
128 | 65 | fu_memwrite_uint32(st->data + 28, value, G_LITTLE_ENDIAN); |
129 | 65 | } |
130 | | /** |
131 | | * fu_struct_ifd_fdbar_new: (skip): |
132 | | **/ |
133 | | FuStructIfdFdbar * |
134 | | fu_struct_ifd_fdbar_new(void) |
135 | 647 | { |
136 | 647 | FuStructIfdFdbar *st = g_byte_array_sized_new(32); |
137 | 647 | fu_byte_array_set_size(st, 32, 0x0); |
138 | 647 | memcpy(st->data + 0x0, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 16); /* nocheck:blocked */ |
139 | 647 | fu_struct_ifd_fdbar_set_signature(st, 0x0FF0A55A); |
140 | 647 | return st; |
141 | 647 | } |
142 | | /** |
143 | | * fu_struct_ifd_fdbar_to_string: (skip): |
144 | | **/ |
145 | | static gchar * |
146 | | fu_struct_ifd_fdbar_to_string(const FuStructIfdFdbar *st) |
147 | 0 | { |
148 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfdFdbar:\n"); |
149 | 0 | g_return_val_if_fail(st != NULL, NULL); |
150 | 0 | g_string_append_printf(str, " descriptor_map0: 0x%x\n", |
151 | 0 | (guint) fu_struct_ifd_fdbar_get_descriptor_map0(st)); |
152 | 0 | g_string_append_printf(str, " descriptor_map1: 0x%x\n", |
153 | 0 | (guint) fu_struct_ifd_fdbar_get_descriptor_map1(st)); |
154 | 0 | g_string_append_printf(str, " descriptor_map2: 0x%x\n", |
155 | 0 | (guint) fu_struct_ifd_fdbar_get_descriptor_map2(st)); |
156 | 0 | if (str->len > 0) |
157 | 0 | g_string_set_size(str, str->len - 1); |
158 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
159 | 0 | } |
160 | | static gboolean |
161 | | fu_struct_ifd_fdbar_validate_internal(FuStructIfdFdbar *st, GError **error) |
162 | 7.26M | { |
163 | 7.26M | g_return_val_if_fail(st != NULL, FALSE); |
164 | 7.26M | if (fu_struct_ifd_fdbar_get_signature(st) != 0x0FF0A55A) { |
165 | 7.25M | g_set_error(error, |
166 | 7.25M | FWUPD_ERROR, |
167 | 7.25M | FWUPD_ERROR_INVALID_DATA, |
168 | 7.25M | "constant FuStructIfdFdbar.signature was not valid, " |
169 | 7.25M | "expected 0x%x and got 0x%x", |
170 | 7.25M | (guint) 0x0FF0A55A, |
171 | 7.25M | (guint) fu_struct_ifd_fdbar_get_signature(st)); |
172 | 7.25M | return FALSE; |
173 | 7.25M | } |
174 | 3.35k | return TRUE; |
175 | 7.26M | } |
176 | | /** |
177 | | * fu_struct_ifd_fdbar_validate_stream: (skip): |
178 | | **/ |
179 | | gboolean |
180 | | fu_struct_ifd_fdbar_validate_stream(GInputStream *stream, gsize offset, GError **error) |
181 | 7.26M | { |
182 | 7.26M | g_autoptr(GByteArray) st = NULL; |
183 | 7.26M | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
184 | 7.26M | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
185 | 7.26M | st = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
186 | 7.26M | if (st == NULL) { |
187 | 0 | g_prefix_error(error, "FuStructIfdFdbar failed read of 0x%x: ", (guint) 32); |
188 | 0 | return FALSE; |
189 | 0 | } |
190 | 7.26M | if (st->len != 32) { |
191 | 3.92k | g_set_error(error, |
192 | 3.92k | FWUPD_ERROR, |
193 | 3.92k | FWUPD_ERROR_INVALID_DATA, |
194 | 3.92k | "FuStructIfdFdbar requested 0x%x and got 0x%x", |
195 | 3.92k | (guint) 32, |
196 | 3.92k | (guint) st->len); |
197 | 3.92k | return FALSE; |
198 | 3.92k | } |
199 | 7.25M | return fu_struct_ifd_fdbar_validate_internal(st, error); |
200 | 7.26M | } |
201 | | static gboolean |
202 | | fu_struct_ifd_fdbar_parse_internal(FuStructIfdFdbar *st, GError **error) |
203 | 1.64k | { |
204 | 1.64k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
205 | 0 | g_autofree gchar *str = fu_struct_ifd_fdbar_to_string(st); |
206 | 0 | g_debug("%s", str); |
207 | 0 | } |
208 | 1.64k | if (!fu_struct_ifd_fdbar_validate_internal(st, error)) |
209 | 0 | return FALSE; |
210 | 1.64k | return TRUE; |
211 | 1.64k | } |
212 | | /** |
213 | | * fu_struct_ifd_fdbar_parse_stream: (skip): |
214 | | **/ |
215 | | FuStructIfdFdbar * |
216 | | fu_struct_ifd_fdbar_parse_stream(GInputStream *stream, gsize offset, GError **error) |
217 | 1.64k | { |
218 | 1.64k | g_autoptr(GByteArray) st = NULL; |
219 | 1.64k | st = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
220 | 1.64k | if (st == NULL) { |
221 | 0 | g_prefix_error(error, "FuStructIfdFdbar failed read of 0x%x: ", (guint) 32); |
222 | 0 | return NULL; |
223 | 0 | } |
224 | 1.64k | if (st->len != 32) { |
225 | 0 | g_set_error(error, |
226 | 0 | FWUPD_ERROR, |
227 | 0 | FWUPD_ERROR_INVALID_DATA, |
228 | 0 | "FuStructIfdFdbar requested 0x%x and got 0x%x", |
229 | 0 | (guint) 32, |
230 | 0 | (guint) st->len); |
231 | 0 | return NULL; |
232 | 0 | } |
233 | 1.64k | if (!fu_struct_ifd_fdbar_parse_internal(st, error)) |
234 | 0 | return NULL; |
235 | 1.64k | return g_steal_pointer(&st); |
236 | 1.64k | } |
237 | | /* getters */ |
238 | | /** |
239 | | * fu_struct_ifd_fcba_get_flcomp: (skip): |
240 | | **/ |
241 | | guint32 |
242 | | fu_struct_ifd_fcba_get_flcomp(const FuStructIfdFcba *st) |
243 | 1.64k | { |
244 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
245 | 1.64k | return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN); |
246 | 1.64k | } |
247 | | /** |
248 | | * fu_struct_ifd_fcba_get_flill: (skip): |
249 | | **/ |
250 | | guint32 |
251 | | fu_struct_ifd_fcba_get_flill(const FuStructIfdFcba *st) |
252 | 1.64k | { |
253 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
254 | 1.64k | return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN); |
255 | 1.64k | } |
256 | | /** |
257 | | * fu_struct_ifd_fcba_get_flill1: (skip): |
258 | | **/ |
259 | | guint32 |
260 | | fu_struct_ifd_fcba_get_flill1(const FuStructIfdFcba *st) |
261 | 1.64k | { |
262 | 1.64k | g_return_val_if_fail(st != NULL, 0x0); |
263 | 1.64k | return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN); |
264 | 1.64k | } |
265 | | |
266 | | /* setters */ |
267 | | /** |
268 | | * fu_struct_ifd_fcba_set_flcomp: (skip): |
269 | | **/ |
270 | | void |
271 | | fu_struct_ifd_fcba_set_flcomp(FuStructIfdFcba *st, guint32 value) |
272 | 65 | { |
273 | 65 | g_return_if_fail(st != NULL); |
274 | 65 | fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN); |
275 | 65 | } |
276 | | /** |
277 | | * fu_struct_ifd_fcba_set_flill: (skip): |
278 | | **/ |
279 | | void |
280 | | fu_struct_ifd_fcba_set_flill(FuStructIfdFcba *st, guint32 value) |
281 | 65 | { |
282 | 65 | g_return_if_fail(st != NULL); |
283 | 65 | fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN); |
284 | 65 | } |
285 | | /** |
286 | | * fu_struct_ifd_fcba_set_flill1: (skip): |
287 | | **/ |
288 | | void |
289 | | fu_struct_ifd_fcba_set_flill1(FuStructIfdFcba *st, guint32 value) |
290 | 65 | { |
291 | 65 | g_return_if_fail(st != NULL); |
292 | 65 | fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN); |
293 | 65 | } |
294 | | /** |
295 | | * fu_struct_ifd_fcba_new: (skip): |
296 | | **/ |
297 | | FuStructIfdFcba * |
298 | | fu_struct_ifd_fcba_new(void) |
299 | 647 | { |
300 | 647 | FuStructIfdFcba *st = g_byte_array_sized_new(12); |
301 | 647 | fu_byte_array_set_size(st, 12, 0x0); |
302 | 647 | return st; |
303 | 647 | } |
304 | | /** |
305 | | * fu_struct_ifd_fcba_to_string: (skip): |
306 | | **/ |
307 | | static gchar * |
308 | | fu_struct_ifd_fcba_to_string(const FuStructIfdFcba *st) |
309 | 0 | { |
310 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfdFcba:\n"); |
311 | 0 | g_return_val_if_fail(st != NULL, NULL); |
312 | 0 | g_string_append_printf(str, " flcomp: 0x%x\n", |
313 | 0 | (guint) fu_struct_ifd_fcba_get_flcomp(st)); |
314 | 0 | g_string_append_printf(str, " flill: 0x%x\n", |
315 | 0 | (guint) fu_struct_ifd_fcba_get_flill(st)); |
316 | 0 | g_string_append_printf(str, " flill1: 0x%x\n", |
317 | 0 | (guint) fu_struct_ifd_fcba_get_flill1(st)); |
318 | 0 | if (str->len > 0) |
319 | 0 | g_string_set_size(str, str->len - 1); |
320 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
321 | 0 | } |
322 | | static gboolean |
323 | | fu_struct_ifd_fcba_validate_internal(FuStructIfdFcba *st, GError **error) |
324 | 1.64k | { |
325 | 1.64k | g_return_val_if_fail(st != NULL, FALSE); |
326 | 1.64k | return TRUE; |
327 | 1.64k | } |
328 | | static gboolean |
329 | | fu_struct_ifd_fcba_parse_internal(FuStructIfdFcba *st, GError **error) |
330 | 1.64k | { |
331 | 1.64k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
332 | 0 | g_autofree gchar *str = fu_struct_ifd_fcba_to_string(st); |
333 | 0 | g_debug("%s", str); |
334 | 0 | } |
335 | 1.64k | if (!fu_struct_ifd_fcba_validate_internal(st, error)) |
336 | 0 | return FALSE; |
337 | 1.64k | return TRUE; |
338 | 1.64k | } |
339 | | /** |
340 | | * fu_struct_ifd_fcba_parse_stream: (skip): |
341 | | **/ |
342 | | FuStructIfdFcba * |
343 | | fu_struct_ifd_fcba_parse_stream(GInputStream *stream, gsize offset, GError **error) |
344 | 1.64k | { |
345 | 1.64k | g_autoptr(GByteArray) st = NULL; |
346 | 1.64k | st = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error); |
347 | 1.64k | if (st == NULL) { |
348 | 0 | g_prefix_error(error, "FuStructIfdFcba failed read of 0x%x: ", (guint) 12); |
349 | 0 | return NULL; |
350 | 0 | } |
351 | 1.64k | if (st->len != 12) { |
352 | 0 | g_set_error(error, |
353 | 0 | FWUPD_ERROR, |
354 | 0 | FWUPD_ERROR_INVALID_DATA, |
355 | 0 | "FuStructIfdFcba requested 0x%x and got 0x%x", |
356 | 0 | (guint) 12, |
357 | 0 | (guint) st->len); |
358 | 0 | return NULL; |
359 | 0 | } |
360 | 1.64k | if (!fu_struct_ifd_fcba_parse_internal(st, error)) |
361 | 0 | return NULL; |
362 | 1.64k | return g_steal_pointer(&st); |
363 | 1.64k | } |