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

Function fmap_append_area

util/cbfstool/flashmap/fmap.c:279–309  ·  view source on GitHub ↗

append area to existing structure, return new total size if successful */

Source from the content-addressed store, hash-verified

277
278/* append area to existing structure, return new total size if successful */
279int fmap_append_area(struct fmap **fmap,
280 uint32_t offset, uint32_t size,
281 const uint8_t *name, uint16_t flags)
282{
283 struct fmap_area *area;
284 int orig_size, new_size;
285
286 if ((fmap == NULL || *fmap == NULL) || (name == NULL))
287 return -1;
288
289 /* too many areas */
290 if (le16toh((*fmap)->nareas) >= 0xffff)
291 return -1;
292
293 orig_size = fmap_size(*fmap);
294 new_size = orig_size + sizeof(*area);
295
296 *fmap = realloc(*fmap, new_size);
297 if (*fmap == NULL)
298 return -1;
299
300 area = (struct fmap_area *)((uint8_t *)*fmap + orig_size);
301 memset(area, 0, sizeof(*area));
302 memccpy(&area->name, name, '\0', FMAP_STRLEN);
303 area->offset = htole32(offset);
304 area->size = htole32(size);
305 area->flags = htole16(flags);
306
307 (*fmap)->nareas = htole16(le16toh((*fmap)->nareas) + 1);
308 return new_size;
309}
310
311const struct fmap_area *fmap_find_area(const struct fmap *fmap,
312 const char *name)

Callers 2

fmap_append_area_testFunction · 0.85
fmap_append_fmd_nodeFunction · 0.85

Calls 3

fmap_sizeFunction · 0.85
reallocFunction · 0.85
memsetFunction · 0.50

Tested by 1

fmap_append_area_testFunction · 0.68