util/cbfstool: Allow xip/non-xip relocation for FSP component
Currently, convert_fsp assumes that the component is always XIP. This is no longer true with FSP 2.0 and Apollolake platform. Thus, add the option -y|--xip for FSP which will allow the caller to mention whether the FSP component being added is XIP or not. Add this option to Makefiles of current FSP drivers (fsp1_0 and fsp1_1). Change-Id: I1e41d0902bb32afaf116bb457dd9265a5bcd8779 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/14748 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
03f50720df
commit
61c1a05c07
|
@ -30,6 +30,7 @@ cbfs-files-y += fsp.bin
|
|||
fsp.bin-file := $(call strip_quotes,$(CONFIG_FSP_FILE))
|
||||
fsp.bin-position := $(CONFIG_FSP_LOC)
|
||||
fsp.bin-type := fsp
|
||||
fsp.bin-options := --xip
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ENABLE_MRC_CACHE),y)
|
||||
|
|
|
@ -54,6 +54,7 @@ cbfs-files-y += fsp.bin
|
|||
fsp.bin-file := $(call strip_quotes,$(CONFIG_FSP_FILE))
|
||||
fsp.bin-position := $(CONFIG_FSP_LOC)
|
||||
fsp.bin-type := fsp
|
||||
fsp.bin-options := --xip
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
@ -474,10 +474,39 @@ static int cbfstool_convert_fsp(struct buffer *buffer,
|
|||
|
||||
address = *offset;
|
||||
|
||||
/* Ensure the address is a memory mapped one. */
|
||||
if (!IS_TOP_ALIGNED_ADDRESS(address))
|
||||
address = -convert_to_from_absolute_top_aligned(
|
||||
param.image_region, address);
|
||||
/*
|
||||
* If the FSP component is xip, then ensure that the address is a memory
|
||||
* mapped one.
|
||||
* If the FSP component is not xip, then use param.baseaddress that is
|
||||
* passed in by the caller.
|
||||
*
|
||||
*/
|
||||
if (param.stage_xip) {
|
||||
if (!IS_TOP_ALIGNED_ADDRESS(address))
|
||||
address = -convert_to_from_absolute_top_aligned(
|
||||
param.image_region, address);
|
||||
} else {
|
||||
if ((param.baseaddress_assigned == 0) ||
|
||||
(param.baseaddress == 0)) {
|
||||
ERROR("Invalid baseaddress for non-XIP FSP.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
address = param.baseaddress;
|
||||
|
||||
/*
|
||||
* *offset should either be 0 or the value returned by
|
||||
* do_cbfs_locate. do_cbfs_locate should not ever return a value
|
||||
* that is TOP_ALIGNED_ADDRESS. Thus, if *offset contains a top
|
||||
* aligned address, set it to 0.
|
||||
*
|
||||
* The only requirement in this case is that the binary should
|
||||
* be relocated to the base address that is requested. There is
|
||||
* no requirement on where the file ends up in the cbfs.
|
||||
*/
|
||||
if (IS_TOP_ALIGNED_ADDRESS(*offset))
|
||||
*offset = 0;
|
||||
}
|
||||
|
||||
/* Create a copy of the buffer to attempt relocation. */
|
||||
if (buffer_create(&fsp, buffer_size(buffer), "fsp"))
|
||||
|
@ -603,6 +632,9 @@ static int cbfs_add(void)
|
|||
if (!param.baseaddress_assigned)
|
||||
param.alignment = 4*1024;
|
||||
convert = cbfstool_convert_fsp;
|
||||
} else if (param.stage_xip) {
|
||||
ERROR("cbfs add supports xip only for FSP component type\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (param.alignment) {
|
||||
|
@ -1030,7 +1062,7 @@ static int cbfs_compact(void)
|
|||
}
|
||||
|
||||
static const struct command commands[] = {
|
||||
{"add", "H:r:f:n:t:c:b:a:vA:gh?", cbfs_add, true, true},
|
||||
{"add", "H:r:f:n:t:c:b:a:yvA:gh?", cbfs_add, true, true},
|
||||
{"add-flat-binary", "H:r:f:n:l:e:c:b:vA:gh?", cbfs_add_flat_binary,
|
||||
true, true},
|
||||
{"add-payload", "H:r:f:n:t:c:b:C:I:vA:gh?", cbfs_add_payload,
|
||||
|
@ -1153,7 +1185,8 @@ static void usage(char *name)
|
|||
" -h Display this help message\n\n"
|
||||
"COMMANDs:\n"
|
||||
" add [-r image,regions] -f FILE -n NAME -t TYPE [-A hash] \\\n"
|
||||
" [-c compression] [-b base-address | -a alignment] "
|
||||
" [-c compression] [-b base-address | -a alignment] \\\n"
|
||||
" [-y|--xip if TYPE is FSP] "
|
||||
"Add a component\n"
|
||||
" add-payload [-r image,regions] -f FILE -n NAME [-A hash] \\\n"
|
||||
" [-c compression] [-b base-address] \\\n"
|
||||
|
|
Loading…
Reference in New Issue