cbfstool/fsp: Rename fsp1_1_relocate

FSP 2.0 uses the same relocate logic as FSP 1.1. Thus, rename
fsp1_1_relocate to more generic fsp_component_relocate that can be
used by cbfstool to relocate either FSP 1.1 or FSP 2.0
components. Allow FSP1.1 driver to still call fsp1_1_relocate which
acts as a wrapper for fsp_component_relocate.

Change-Id: I14a6efde4d86a340663422aff5ee82175362d1b0
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/14749
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
Furquan Shaikh 2016-05-09 12:23:01 -07:00
parent 61c1a05c07
commit b0c2fe0554
6 changed files with 21 additions and 12 deletions

View File

@ -11,7 +11,7 @@ ramstage-y += region.c
smm-y += region.c smm-y += region.c
postcar-y += region.c postcar-y += region.c
ramstage-$(CONFIG_PLATFORM_USES_FSP1_1) += fsp1_1_relocate.c ramstage-$(CONFIG_PLATFORM_USES_FSP1_1) += fsp_relocate.c
bootblock-y += cbfs.c bootblock-y += cbfs.c
verstage-y += cbfs.c verstage-y += cbfs.c

View File

@ -15,7 +15,7 @@
#include <console/console.h> #include <console/console.h>
#include <commonlib/endian.h> #include <commonlib/endian.h>
#include <commonlib/fsp1_1.h> #include <commonlib/fsp.h>
/* /*
* Intel's code does not have a handle on changing global packing state. * Intel's code does not have a handle on changing global packing state.
* Therefore, one needs to protect against packing policies that are set * Therefore, one needs to protect against packing policies that are set
@ -482,7 +482,7 @@ static ssize_t relocate_fvh(uintptr_t new_addr, void *fsp, size_t fsp_size,
} }
/* /*
* The entire FSP 1.1 image can be thought of as one * The entire FSP image can be thought of as one
* program with a single link address even though there * program with a single link address even though there
* are multiple TEs linked separately. The reason is * are multiple TEs linked separately. The reason is
* that each TE is linked for XIP. So in order to * that each TE is linked for XIP. So in order to
@ -511,7 +511,7 @@ static ssize_t relocate_fvh(uintptr_t new_addr, void *fsp, size_t fsp_size,
return fv_length; return fv_length;
} }
ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size) ssize_t fsp_component_relocate(uintptr_t new_addr, void *fsp, size_t size)
{ {
size_t offset; size_t offset;
size_t fih_offset; size_t fih_offset;
@ -542,3 +542,8 @@ ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size)
return relocate_remaining_items(fsp, size, new_addr, fih_offset); return relocate_remaining_items(fsp, size, new_addr, fih_offset);
} }
ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size)
{
return fsp_component_relocate(new_addr, fsp, size);
}

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of the coreboot project. * This file is part of the coreboot project.
* *
* Copyright 2015 Google Inc. * Copyright 2016 Google Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -13,8 +13,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#ifndef _COMMONLIB_FSP1_1_H_ #ifndef _COMMONLIB_FSP_H_
#define _COMMONLIB_FSP1_1_H_ #define _COMMONLIB_FSP_H_
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@ -23,6 +23,9 @@
* Relocate FSP held within buffer defined by size to new_addr. Returns < 0 * Relocate FSP held within buffer defined by size to new_addr. Returns < 0
* on error, offset to FSP_INFO_HEADER on success. * on error, offset to FSP_INFO_HEADER on success.
*/ */
ssize_t fsp_component_relocate(uintptr_t new_addr, void *fsp, size_t size);
/* API to relocate fsp 1.1 component. */
ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size); ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size);
#endif #endif

View File

@ -15,7 +15,7 @@
#include <console/console.h> #include <console/console.h>
#include <cbmem.h> #include <cbmem.h>
#include <commonlib/fsp1_1.h> #include <commonlib/fsp.h>
#include <fsp/util.h> #include <fsp/util.h>
int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src) int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src)

View File

@ -12,7 +12,7 @@ cbfsobj += fit.o
cbfsobj += partitioned_file.o cbfsobj += partitioned_file.o
# COMMONLIB # COMMONLIB
cbfsobj += cbfs.o cbfsobj += cbfs.o
cbfsobj += fsp1_1_relocate.o cbfsobj += fsp_relocate.o
cbfsobj += lz4_wrapper.o cbfsobj += lz4_wrapper.o
cbfsobj += mem_pool.o cbfsobj += mem_pool.o
cbfsobj += region.o cbfsobj += region.o

View File

@ -29,7 +29,7 @@
#include "cbfs_sections.h" #include "cbfs_sections.h"
#include "fit.h" #include "fit.h"
#include "partitioned_file.h" #include "partitioned_file.h"
#include <commonlib/fsp1_1.h> #include <commonlib/fsp.h>
#define SECTION_WITH_FIT_TABLE "BOOTBLOCK" #define SECTION_WITH_FIT_TABLE "BOOTBLOCK"
@ -515,12 +515,13 @@ static int cbfstool_convert_fsp(struct buffer *buffer,
memcpy(buffer_get(&fsp), buffer_get(buffer), buffer_size(buffer)); memcpy(buffer_get(&fsp), buffer_get(buffer), buffer_size(buffer));
/* Replace the buffer contents w/ the relocated ones on success. */ /* Replace the buffer contents w/ the relocated ones on success. */
if (fsp1_1_relocate(address, buffer_get(&fsp), buffer_size(&fsp)) > 0) { if (fsp_component_relocate(address, buffer_get(&fsp), buffer_size(&fsp))
> 0) {
buffer_delete(buffer); buffer_delete(buffer);
buffer_clone(buffer, &fsp); buffer_clone(buffer, &fsp);
} else { } else {
buffer_delete(&fsp); buffer_delete(&fsp);
WARN("FSP was not a 1.1 variant.\n"); WARN("Invalid FSP variant.\n");
} }
/* Let the raw path handle all the cbfs metadata logic. */ /* Let the raw path handle all the cbfs metadata logic. */