mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 15:51:41 +01:00
lib: sbi: Improve get_feature_str() implementation and usage
We do following improvements for get_feature_str(): 1. We should return "none" from get_feature_str() no features available instead of sbi_boot_prints() explicitly handling failure. 2. We don't need to return failure (just like misa_xlen()) because we are returning "none" for no features and we are truncating output when space is not available. 3. Based on 1 and 2, the sbi_boot_prints() can be further simplified. 4. No need for two char[] in sbi_boot_prints() Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -35,10 +35,8 @@
|
||||
|
||||
static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid)
|
||||
{
|
||||
int xlen, ret;
|
||||
char str[64];
|
||||
int max_fstr_len = 128;
|
||||
char features[128];
|
||||
int xlen;
|
||||
char str[128];
|
||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||
|
||||
#ifdef OPENSBI_VERSION_GIT
|
||||
@@ -56,35 +54,26 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid)
|
||||
sbi_printf("Error %d getting MISA XLEN\n", xlen);
|
||||
sbi_hart_hang();
|
||||
}
|
||||
misa_string(xlen, str, sizeof(str));
|
||||
|
||||
/* Platform details */
|
||||
sbi_printf("Platform Name : %s\n", sbi_platform_name(plat));
|
||||
sbi_printf("Platform HART Count : %u\n",
|
||||
sbi_platform_hart_count(plat));
|
||||
|
||||
sbi_memset(features, 0, max_fstr_len);
|
||||
ret = sbi_platform_get_features_str(plat, features, max_fstr_len);
|
||||
if (!ret)
|
||||
sbi_printf("Platform Features : %s\n", features);
|
||||
else
|
||||
sbi_printf("Platform Features : %s\n", "none");
|
||||
sbi_platform_get_features_str(plat, str, sizeof(str));
|
||||
sbi_printf("Platform Features : %s\n", str);
|
||||
|
||||
/* Boot HART details */
|
||||
sbi_printf("Boot HART ID : %u\n", hartid);
|
||||
misa_string(xlen, str, sizeof(str));
|
||||
sbi_printf("Boot HART ISA : %s\n", str);
|
||||
|
||||
sbi_memset(features, 0, max_fstr_len);
|
||||
ret = sbi_hart_get_features_str(hartid, features, max_fstr_len);
|
||||
if (!ret)
|
||||
sbi_printf("BOOT HART Features : %s\n", features);
|
||||
else
|
||||
sbi_printf("BOOT HART Features : %s\n", "none");
|
||||
sbi_hart_get_features_str(hartid, str, sizeof(str));
|
||||
sbi_printf("BOOT HART Features : %s\n", str);
|
||||
|
||||
/* Firmware details */
|
||||
sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start);
|
||||
sbi_printf("Firmware Size : %d KB\n",
|
||||
(u32)(scratch->fw_size / 1024));
|
||||
|
||||
/* Generic details */
|
||||
sbi_printf("Runtime SBI Version : %d.%d\n",
|
||||
sbi_ecall_version_major(), sbi_ecall_version_minor());
|
||||
|
Reference in New Issue
Block a user