MCPcopy Create free account
hub / github.com/coreboot/coreboot / extract

Function extract

src/lib/fit_payload.c:31–85  ·  view source on GitHub ↗

* Extract a node to given regions. * Returns true on error, false on success. */

Source from the content-addressed store, hash-verified

29 * Returns true on error, false on success.
30 */
31static bool extract(struct region *region, struct fit_image_node *node)
32{
33 void *dst = (void *)region->offset;
34 const char *comp_name;
35 size_t true_size = 0;
36
37 if (node->size == 0) {
38 printk(BIOS_ERR, "The %s size is 0\n", node->name);
39 return true;
40 }
41
42 switch (node->compression) {
43 case CBFS_COMPRESS_NONE:
44 comp_name = "Relocating uncompressed";
45 break;
46 case CBFS_COMPRESS_LZMA:
47 comp_name = "Decompressing LZMA";
48 break;
49 case CBFS_COMPRESS_LZ4:
50 comp_name = "Decompressing LZ4";
51 break;
52 default:
53 printk(BIOS_ERR, "Unsupported compression\n");
54 return true;
55 }
56
57 printk(BIOS_INFO, "FIT: %s %s to %p\n", comp_name, node->name, dst);
58
59 switch (node->compression) {
60 case CBFS_COMPRESS_NONE:
61 memcpy(dst, node->data, node->size);
62 true_size = node->size;
63 break;
64 case CBFS_COMPRESS_LZMA:
65 timestamp_add_now(TS_ULZMA_START);
66 true_size = ulzman(node->data, node->size, dst, region->size);
67 timestamp_add_now(TS_ULZMA_END);
68 break;
69 case CBFS_COMPRESS_LZ4:
70 timestamp_add_now(TS_ULZ4F_START);
71 true_size = ulz4fn(node->data, node->size, dst, region->size);
72 timestamp_add_now(TS_ULZ4F_END);
73 break;
74 default:
75 return true;
76 }
77
78 if (!true_size) {
79 printk(BIOS_ERR, "%s decompression failed!\n",
80 comp_name);
81 return true;
82 }
83
84 return false;
85}
86
87static struct device_tree *unpack_fdt(struct fit_image_node *image_node)
88{

Callers 2

unpack_fdtFunction · 0.85
fit_payloadFunction · 0.85

Calls 5

memcpyFunction · 0.70
timestamp_add_nowFunction · 0.70
ulzmanFunction · 0.70
printkFunction · 0.50
ulz4fnFunction · 0.50

Tested by

no test coverage detected