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

Function add_topswap_bootblock

util/cbfstool/cbfstool.c:870–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

868}
869
870static int add_topswap_bootblock(struct buffer *buffer, uint32_t *offset)
871{
872 size_t bb_buf_size = buffer_size(buffer);
873
874 if (bb_buf_size > param.topswap_size) {
875 ERROR("Bootblock bigger than the topswap boundary\n");
876 ERROR("size = %zd, ts = %d\n", bb_buf_size,
877 param.topswap_size);
878 return 1;
879 }
880
881 /*
882 * Allocate topswap_size*2 bytes for bootblock to
883 * accommodate the second bootblock.
884 */
885 struct buffer new_bootblock, bb1, bb2;
886 if (buffer_create(&new_bootblock, 2 * param.topswap_size,
887 buffer->name))
888 return 1;
889
890 buffer_splice(&bb1, &new_bootblock, param.topswap_size - bb_buf_size,
891 bb_buf_size);
892 buffer_splice(&bb2, &new_bootblock,
893 buffer_size(&new_bootblock) - bb_buf_size,
894 bb_buf_size);
895
896 /* Copy to first bootblock */
897 memcpy(buffer_get(&bb1), buffer_get(buffer), bb_buf_size);
898 /* Copy to second bootblock */
899 memcpy(buffer_get(&bb2), buffer_get(buffer), bb_buf_size);
900
901 buffer_delete(buffer);
902 buffer_clone(buffer, &new_bootblock);
903
904 /* Update the location (offset) of bootblock in the region */
905 return convert_region_offset(buffer_size(buffer), offset);
906}
907
908static int cbfs_add_component(const char *filename,
909 const char *name,

Callers 1

cbfs_add_componentFunction · 0.85

Calls 8

buffer_sizeFunction · 0.85
buffer_createFunction · 0.85
buffer_spliceFunction · 0.85
buffer_getFunction · 0.85
buffer_deleteFunction · 0.85
buffer_cloneFunction · 0.85
convert_region_offsetFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected