[U-Boot] [PATCH 1/2] fs: cbfs: make file_cbfs_load_header(..) independent of end-of-rom

Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com --- fs/cbfs/cbfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index 7b2513cb24..c60a8d5dc1 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -162,13 +162,10 @@ static void file_cbfs_fill_cache(u8 *start, u32 size, u32 align) }
/* Get the CBFS header out of the ROM and do endian conversion. */ -static int file_cbfs_load_header(uintptr_t end_of_rom, - struct cbfs_header *header) +static int file_cbfs_load_header(uintptr_t addr, struct cbfs_header *header) { - struct cbfs_header *header_in_rom; - int32_t offset = *(u32 *)(end_of_rom - 3); + struct cbfs_header *header_in_rom = (struct cbfs_header *)addr;
- header_in_rom = (struct cbfs_header *)(end_of_rom + offset + 1); swap_header(header, header_in_rom);
if (header->magic != good_magic || header->offset > @@ -183,8 +180,9 @@ void file_cbfs_init(uintptr_t end_of_rom) { u8 *start_of_rom; initialized = 0; + const int32_t offset = *(u32 *)(end_of_rom - 3);
- if (file_cbfs_load_header(end_of_rom, &cbfs_header)) + if (file_cbfs_load_header(end_of_rom + offset + 1, &cbfs_header)) return;
start_of_rom = (u8 *)(end_of_rom + 1 - cbfs_header.rom_size);

On Intel Apollolake the BIOS region on the flash is mapped right below 4GiB in the address space. However, 256KiB right below 4GiB is decoded by read-only SRAM. For this case we need a new API to handle this case - file_cbfs_init_ext().
This patch only does the groundwork to fix this issue. The caller of this API is responsible to calucalte/determine the correct cbfs addresses.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com --- fs/cbfs/cbfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index c60a8d5dc1..97272ce5e8 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -193,6 +193,19 @@ void file_cbfs_init(uintptr_t end_of_rom) initialized = 1; }
+void file_cbfs_init_ext(uintptr_t header, uintptr_t cbfs_start, u32 cbfs_size) +{ + initialized = 0; + + if (file_cbfs_load_header(header, &cbfs_header)) + return; + + file_cbfs_fill_cache((u8 *)cbfs_start, cbfs_size, cbfs_header.align); + + if (file_cbfs_result == CBFS_SUCCESS) + initialized = 1; +} + const struct cbfs_header *file_cbfs_get_header(void) { if (initialized) {

Am Mi., 17. Apr. 2019 um 15:21 Uhr schrieb Christian Gmeiner christian.gmeiner@gmail.com:
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
I think I will send out a v2 that compiles :/

Hi Christian,
On Wed, Apr 17, 2019 at 11:17 PM Christian Gmeiner christian.gmeiner@gmail.com wrote:
Am Mi., 17. Apr. 2019 um 15:21 Uhr schrieb Christian Gmeiner christian.gmeiner@gmail.com:
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
I think I will send out a v2 that compiles :/
and please add some descriptions in the commit message. Thanks!
Regards, Bin
participants (2)
-
Bin Meng
-
Christian Gmeiner