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

Function cbfs_add_component

util/cbfstool/cbfstool.c:908–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906}
907
908static int cbfs_add_component(const char *filename,
909 const char *name,
910 uint32_t headeroffset,
911 convert_buffer_t convert)
912{
913 /*
914 * The steps used to determine the final placement offset in CBFS, in order:
915 *
916 * 1. If --base-address was passed, that value is used. If it was passed in the host
917 * address space, convert it to flash address space. (After that, |*offset| is always
918 * in the flash address space.)
919 *
920 * 2. The convert() function may write a location back to |offset|, usually by calling
921 * do_cbfs_locate(). In this case, it needs to ensure that the location found can fit
922 * the CBFS file in its final form (after any compression and conversion).
923 *
924 * 3. If --align was passed and the offset is still undecided at this point,
925 * do_cbfs_locate() is called to find an appropriately aligned location.
926 *
927 * 4. If |offset| is still 0 at the end, cbfs_add_entry() will find the first available
928 * location that fits.
929 */
930 uint32_t offset = param.baseaddress_assigned ? param.baseaddress : 0;
931 size_t len_align = 0;
932
933 if (param.alignment && param.baseaddress_assigned) {
934 ERROR("Cannot specify both alignment and base address\n");
935 return 1;
936 }
937
938 if (param.stage_xip && param.compression != CBFS_COMPRESS_NONE) {
939 ERROR("Cannot specify compression for XIP.\n");
940 return 1;
941 }
942
943 if (!filename) {
944 ERROR("You need to specify -f/--filename.\n");
945 return 1;
946 }
947
948 if (!name) {
949 ERROR("You need to specify -n/--name.\n");
950 return 1;
951 }
952
953 if (param.type == 0) {
954 ERROR("You need to specify a valid -t/--type.\n");
955 return 1;
956 }
957
958 struct cbfs_image image;
959 if (cbfs_image_from_buffer(&image, param.image_region, headeroffset))
960 return 1;
961
962 if (cbfs_get_entry(&image, name)) {
963 ERROR("'%s' already in ROM image.\n", name);
964 return 1;
965 }

Callers 4

cbfs_addFunction · 0.85
cbfs_add_stageFunction · 0.85
cbfs_add_payloadFunction · 0.85
cbfs_add_flat_binaryFunction · 0.85

Calls 15

cbfs_image_from_bufferFunction · 0.85
cbfs_get_entryFunction · 0.85
buffer_from_fileFunction · 0.85
cbfs_create_file_headerFunction · 0.85
verification_excludeFunction · 0.85
get_mh_cacheFunction · 0.85
add_topswap_bootblockFunction · 0.85
convert_addr_spaceFunction · 0.85
do_cbfs_locateFunction · 0.85
buffer_sizeFunction · 0.85
cbfs_add_file_hashFunction · 0.85
cbfs_add_file_attrFunction · 0.85

Tested by

no test coverage detected