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

Function load_one_segment

src/lib/selfboot.c:56–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static int load_one_segment(uint8_t *dest,
57 uint8_t *src,
58 size_t len,
59 size_t memsz,
60 uint32_t compression,
61 int flags)
62{
63 unsigned char *middle, *end;
64 printk(BIOS_DEBUG, "Loading Segment: addr: %p memsz: 0x%016zx filesz: 0x%016zx\n",
65 dest, memsz, len);
66
67 /* Compute the boundaries of the segment */
68 end = dest + memsz;
69
70 /* Copy data from the initial buffer */
71 switch (compression) {
72 case CBFS_COMPRESS_LZMA: {
73 printk(BIOS_DEBUG, "using LZMA\n");
74 timestamp_add_now(TS_ULZMA_START);
75 len = ulzman(src, len, dest, memsz);
76 timestamp_add_now(TS_ULZMA_END);
77 if (!len) /* Decompression Error. */
78 return 0;
79 break;
80 }
81 case CBFS_COMPRESS_LZ4: {
82 printk(BIOS_DEBUG, "using LZ4\n");
83 timestamp_add_now(TS_ULZ4F_START);
84 len = ulz4fn(src, len, dest, memsz);
85 timestamp_add_now(TS_ULZ4F_END);
86 if (!len) /* Decompression Error. */
87 return 0;
88 break;
89 }
90 case CBFS_COMPRESS_ZSTD: {
91 if (!CONFIG(COMPRESSED_PAYLOAD_ZSTD))
92 return 0;
93
94 printk(BIOS_DEBUG, "using ZSTD\n");
95 timestamp_add_now(TS_UZSTDF_START);
96 len = uzstdn(src, len, dest, memsz);
97 timestamp_add_now(TS_UZSTDF_END);
98 if (!len) /* Decompression Error. */
99 return 0;
100 break;
101 }
102
103 case CBFS_COMPRESS_NONE: {
104 printk(BIOS_DEBUG, "it's not compressed!\n");
105 memcpy(dest, src, len);
106 break;
107 }
108 default:
109 printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", compression);
110 return 0;
111 }
112 /* Calculate middle after any changes to len. */
113 middle = dest + len;

Callers 1

load_payload_segmentsFunction · 0.85

Calls 8

prog_segment_loadedFunction · 0.85
timestamp_add_nowFunction · 0.70
ulzmanFunction · 0.70
memcpyFunction · 0.70
memsetFunction · 0.70
printkFunction · 0.50
ulz4fnFunction · 0.50
uzstdnFunction · 0.50

Tested by

no test coverage detected