diff options
author | Werner Zeh <werner.zeh@siemens.com> | 2019-02-20 06:38:04 +0100 |
---|---|---|
committer | Werner Zeh <werner.zeh@siemens.com> | 2019-02-25 05:39:45 +0000 |
commit | d35a4811dbe6badcc9fabd3c3a7c992039215e02 (patch) | |
tree | ed0bb630d8b1b04d3e92f0dbed8837f176794307 /src/vendorcode/siemens | |
parent | 87abccdd898ea98ede687c17e9177107cb5c7521 (diff) | |
download | coreboot-d35a4811dbe6badcc9fabd3c3a7c992039215e02.tar.xz |
vendorcode/siemens: Cache currently opened hwi file name
On every call of hwilib_find_blocks() the CBFS file will be mapped and
the contents are parsed to get the offsets for every single block. This
is not needed if the CBFS file name is the same for the different calls.
This patch adds a storage for the currently opened CBFS file name in
CAR_GLOBAL and checks on each call if the file to open is already open.
If yes, the file will not be mapped again which saves execution time.
Test=Booted mc_tcu3, mc_bdx1 and mc_apl1 and verified that hwinfo.hex
is only mapped once across several following hwilib_find_blocks() calls.
In addition a test was done to ensure that files with different names
get mapped correctly.
Change-Id: Id69e0f6c914c2b8e4551fd8a4fb7d452d176afb3
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/c/31518
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src/vendorcode/siemens')
-rw-r--r-- | src/vendorcode/siemens/hwilib/hwilib.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c index f15937b7df..75e7cdb745 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -1,7 +1,7 @@ /* * This file is part of the coreboot project. * - * Copyright (C) 2014 Siemens AG + * Copyright (C) 2014-2019 Siemens AG * * 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 @@ -39,6 +39,7 @@ #define EIB_FEATRUE_OFFSET 0x00e #define LEN_MAGIC_NUM 0x007 #define BLOCK_MAGIC "H1W2M3I" +#define HWI_MAX_NAME_LEN 32 /* Define all supported block types. */ enum { @@ -79,6 +80,9 @@ static uint8_t *all_blocks[MAX_BLOCK_NUM] CAR_GLOBAL; */ static uint16_t all_blk_size[MAX_BLOCK_NUM] CAR_GLOBAL; +/* Storage for the cbfs file name of the currently open hwi file. */ +static char current_hwi[HWI_MAX_NAME_LEN] CAR_GLOBAL; + static uint32_t hwilib_read_bytes (const struct param_info *param, uint8_t *dst, uint32_t maxlen); @@ -469,11 +473,21 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename) uint32_t next_offset = 1; uint8_t **blk_ptr = car_get_var_ptr(&all_blocks[0]); uint16_t *all_blk_size_ptr = car_get_var_ptr(&all_blk_size[0]); + char *curr_hwi_name_ptr = car_get_var_ptr(¤t_hwi); size_t filesize = 0; /* Check for a valid parameter */ if (!hwi_filename) return CB_ERR_ARG; + /* Check if this file is already open. If yes, just leave as there is + nothing left to do here. */ + if (curr_hwi_name_ptr && + !strncmp(curr_hwi_name_ptr, hwi_filename, HWI_MAX_NAME_LEN)) { + printk(BIOS_SPEW, "HWILIB: File \"%s\" already open.\n", + hwi_filename); + return CB_SUCCESS; + } + ptr = cbfs_boot_map_with_leak(hwi_filename, CBFS_TYPE_RAW, &filesize); if (!ptr) { printk(BIOS_ERR,"HWILIB: Missing file \"%s\" in cbfs.\n", @@ -533,8 +547,11 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename) } /* We should have found at least one valid block */ if (blk_ptr[BLK_HIB] || blk_ptr[BLK_SIB] || blk_ptr[BLK_EIB] || - blk_ptr[BLK_XIB]) + blk_ptr[BLK_XIB]) { + /* Save currently opened hwi filename. */ + strncpy(curr_hwi_name_ptr, hwi_filename, HWI_MAX_NAME_LEN); return CB_SUCCESS; + } else return CB_ERR; } |