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

Function fmap_lsearch

util/cbfstool/flashmap/fmap.c:75–94  ·  view source on GitHub ↗

brute force linear search */

Source from the content-addressed store, hash-verified

73
74/* brute force linear search */
75static long int fmap_lsearch(const uint8_t *image, size_t len)
76{
77 unsigned long offset;
78 int fmap_found = 0;
79
80 for (offset = 0; offset < len - strlen(FMAP_SIGNATURE); offset++) {
81 if (is_valid_fmap((const struct fmap *)&image[offset])) {
82 fmap_found = 1;
83 break;
84 }
85 }
86
87 if (!fmap_found)
88 return -1;
89
90 if (offset + fmap_size((const struct fmap *)&image[offset]) > len)
91 return -1;
92
93 return offset;
94}
95
96/* if image length is a power of 2, use binary search */
97static long fmap_bsearch(const uint8_t *image, size_t len)

Callers 1

fmap_findFunction · 0.85

Calls 3

strlenFunction · 0.85
is_valid_fmapFunction · 0.85
fmap_sizeFunction · 0.85

Tested by

no test coverage detected