summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2016-05-09 11:53:34 -0700
committerFurquan Shaikh <furquan@google.com>2016-05-11 18:38:13 +0200
commit61c1a05c07be4a7805a0595475cba3b9e8386b77 (patch)
tree889ac16488fb8f058cccffb43e86afae3706c0b0 /util
parent03f50720dfe168f5db9cb0324e4963b68ea99204 (diff)
downloadcoreboot-61c1a05c07be4a7805a0595475cba3b9e8386b77.tar.xz
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)
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfstool.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index b1b410f084..744893cdef 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -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"