Commit e324df3b authored by Bernhard Nortmann's avatar Bernhard Nortmann Committed by Siarhei Siamashka
Browse files

fel: implement persistent sram_info information



Information about the SoC-specific memory layout may be required across
several places in the fel utility code. To avoid having to retrieve this
information repeatedly, this patch modifies the aw_fel_get_sram_info()
function to cache its result (via an internal static pointer).

This makes it safe to call aw_fel_get_sram_info() wherever needed, while
avoiding additional aw_fel_get_version() lookups, and potential surplus
"no 'soc_sram_info' data for your SoC" warnings.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
Acked-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 3048ebf8
......@@ -503,18 +503,27 @@ soc_sram_info generic_sram_info = {
soc_sram_info *aw_fel_get_sram_info(libusb_device_handle *usb)
{
int i;
struct aw_fel_version buf;
aw_fel_get_version(usb, &buf);
for (i = 0; soc_sram_info_table[i].swap_buffers; i++)
if (soc_sram_info_table[i].soc_id == buf.soc_id)
return &soc_sram_info_table[i];
/* persistent sram_info, retrieves result pointer once and caches it */
static soc_sram_info *result = NULL;
if (result == NULL) {
int i;
struct aw_fel_version buf;
aw_fel_get_version(usb, &buf);
for (i = 0; soc_sram_info_table[i].swap_buffers; i++)
if (soc_sram_info_table[i].soc_id == buf.soc_id) {
result = &soc_sram_info_table[i];
break;
}
printf("Warning: no 'soc_sram_info' data for your SoC (id=%04X)\n",
buf.soc_id);
return &generic_sram_info;
if (!result) {
printf("Warning: no 'soc_sram_info' data for your SoC (id=%04X)\n",
buf.soc_id);
result = &generic_sram_info;
}
}
return result;
}
static uint32_t fel_to_spl_thunk[] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment