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

Function fetch_cbmem_entry

util/cbmem/sysfs_drv.c:141–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141static void fetch_cbmem_entry(const uint32_t id, const size_t size, uint8_t **buf_out)
142{
143 char path[PATH_MAX_LEN];
144
145 new_sysfs_path(id, CBMEM_SYSFS_PATH_MEM, path, sizeof(path));
146
147 FILE *mem_file = fopen(path, "rb");
148 if (!mem_file)
149 die("Unable to open mem file for CBMEM entry id: %#" PRIx32
150 " at %s. Error: %s\n",
151 id, path, strerror(errno));
152
153 *buf_out = malloc(size);
154 if (!buf_out)
155 die("Unable to allocate memory for CBMEM entry id: %#" PRIx32
156 " of size: %zuB.\n",
157 id, size);
158
159 if (fread(*buf_out, 1, size, mem_file) != size)
160 die("Unable to correctly read memory of CBMEM entry id: %#" PRIx32
161 " at %s. Error: %s\n",
162 id, path, strerror(errno));
163
164 fclose(mem_file);
165}
166
167bool cbmem_sysfs_get_cbmem_entry(uint32_t id, uint8_t **buf_out, size_t *size_out, uint64_t *addr_out)
168{

Callers 2

Calls 7

new_sysfs_pathFunction · 0.85
fopenFunction · 0.85
strerrorFunction · 0.85
freadFunction · 0.85
fcloseFunction · 0.85
dieFunction · 0.50
mallocFunction · 0.50

Tested by

no test coverage detected