diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-05-11 09:12:54 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-05-19 06:49:44 +0300 |
commit | 2966510eedf03e47e13f3e1a88039bd4199c1085 (patch) | |
tree | 88b86029da3905e19f9fe261cc8a976ecf0a4b86 /lib | |
parent | 63b0f5f71a4d6bf8539a8cbfa27228dc76e7d71a (diff) | |
download | opensbi-2966510eedf03e47e13f3e1a88039bd4199c1085.tar.xz |
lib: sbi: Few cosmetic improvements to HART feature detection
This patch does few cosmetic improvements to HART feature detection:
1. Remove sbi_ perfix from HART feature detection functions
because all local/static functions in sbi_hart.c don't have
sbi_ prefix
2. Remove sbi_hart_set_feature() because it's quite small and
local/static in sbi_hart.c
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbi/sbi_hart.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index c0eb6ca..e62992d 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -308,28 +308,20 @@ done: sbi_strncpy(features_str, "none", nfstr); } -static void sbi_hart_set_feature(struct sbi_scratch *scratch, - unsigned long feature) +static void hart_detect_features(struct sbi_scratch *scratch) { + struct sbi_trap_info trap = {0}; unsigned long *hart_features; + unsigned long csr_val; hart_features = sbi_scratch_offset_ptr(scratch, hart_features_offset); - *hart_features = *hart_features | feature; -} - -static void sbi_hart_detect_features(struct sbi_scratch *scratch) -{ - struct sbi_trap_info trap = {0}; - unsigned long feature = 0; - unsigned long csr_val; - /* Detect if hart supports PMP feature */ csr_val = csr_read_allowed(CSR_PMPCFG0, (unsigned long)&trap); if (!trap.cause) { csr_write_allowed(CSR_PMPCFG0, (unsigned long)&trap, csr_val); if (!trap.cause) - feature |= SBI_HART_HAS_PMP; + *hart_features |= SBI_HART_HAS_PMP; } /* Detect if hart supports SCOUNTEREN feature */ @@ -339,7 +331,7 @@ static void sbi_hart_detect_features(struct sbi_scratch *scratch) csr_write_allowed(CSR_SCOUNTEREN, (unsigned long)&trap, csr_val); if (!trap.cause) - feature |= SBI_HART_HAS_SCOUNTEREN; + *hart_features |= SBI_HART_HAS_SCOUNTEREN; } /* Detect if hart supports MCOUNTEREN feature */ @@ -349,16 +341,14 @@ static void sbi_hart_detect_features(struct sbi_scratch *scratch) csr_write_allowed(CSR_MCOUNTEREN, (unsigned long)&trap, csr_val); if (!trap.cause) - feature |= SBI_HART_HAS_MCOUNTEREN; + *hart_features |= SBI_HART_HAS_MCOUNTEREN; } /* Detect if hart supports time CSR */ trap.cause = 0; csr_read_allowed(CSR_TIME, (unsigned long)&trap); if (!trap.cause) - feature |= SBI_HART_HAS_TIME; - - sbi_hart_set_feature(scratch, feature); + *hart_features |= SBI_HART_HAS_TIME; } int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) @@ -369,16 +359,18 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) if (cold_boot) { if (misa_extension('H')) sbi_hart_expected_trap = &__sbi_expected_trap_hext; + hart_features_offset = sbi_scratch_alloc_offset( - sizeof(hart_features), - "HART_FEATURES"); + sizeof(*hart_features), + "HART_FEATURES"); if (!hart_features_offset) return SBI_ENOMEM; } hart_features = sbi_scratch_offset_ptr(scratch, hart_features_offset); *hart_features = 0; - sbi_hart_detect_features(scratch); + + hart_detect_features(scratch); mstatus_init(scratch, hartid); |