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

Function __bpdt_reset

util/cbfstool/ifwitool.c:925–951  ·  view source on GitHub ↗

* This function is used by repack to count the number of BPDT and S-BPDT * entries that are present. It frees the current buffers used by the entries * and allocates fresh buffers that can be used for repacking. Returns BPDT * entries which are empty and need to be filled in. */

Source from the content-addressed store, hash-verified

923 * entries which are empty and need to be filled in.
924 */
925static void __bpdt_reset(struct buffer *b, size_t count, size_t size)
926{
927 size_t bpdt_size = BPDT_HEADER_SIZE + count * BPDT_ENTRY_SIZE;
928 assert(size >= bpdt_size);
929
930 /*
931 * If buffer does not have the required size, allocate a fresh buffer.
932 */
933 if (buffer_size(b) != size) {
934 struct buffer temp;
935 alloc_buffer(&temp, size, b->name);
936 memcpy(buffer_get(&temp), buffer_get(b), buffer_size(b));
937 buffer_delete(b);
938 *b = temp;
939 }
940
941 struct bpdt *bpdt = buffer_get(b);
942 uint8_t *ptr = (uint8_t *)&bpdt->e[0];
943 size_t entries_size = BPDT_ENTRY_SIZE * count;
944
945 /* Zero out BPDT entries. */
946 memset(ptr, 0, entries_size);
947 /* Fill any pad-space with FF. */
948 memset(ptr + entries_size, 0xFF, size - bpdt_size);
949
950 bpdt->h.descriptor_count = count;
951}
952
953static void bpdt_reset(void)
954{

Callers 1

bpdt_resetFunction · 0.85

Calls 6

buffer_sizeFunction · 0.85
alloc_bufferFunction · 0.85
buffer_getFunction · 0.85
buffer_deleteFunction · 0.85
memcpyFunction · 0.50
memsetFunction · 0.50

Tested by

no test coverage detected