mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-12-17 04:21:39 +00:00
lib: sbi: Replace sbi_hart_pmp_xyz() and sbi_hart_map/unmap_addr()
The sbi_hart_pmp_xyz() and sbi_hart_map/unmap_addr() functions can now be replaced by various sbi_hart_protection_xyz() functions. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20251209135235.423391-5-apatel@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <sbi/sbi_trap.h>
|
||||
#include <sbi/sbi_dbtr.h>
|
||||
#include <sbi/sbi_heap.h>
|
||||
#include <sbi/sbi_hart_protection.h>
|
||||
#include <sbi/riscv_encoding.h>
|
||||
#include <sbi/riscv_asm.h>
|
||||
|
||||
@@ -558,8 +559,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
|
||||
|
||||
shmem_base = hart_shmem_base(hs);
|
||||
|
||||
sbi_hart_map_saddr((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
sbi_hart_protection_map_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
||||
xmit = &entry->data;
|
||||
trig = INDEX_TO_TRIGGER((_idx + trig_idx_base));
|
||||
@@ -572,7 +573,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
|
||||
xmit->tdata2 = cpu_to_lle(trig->tdata2);
|
||||
xmit->tdata3 = cpu_to_lle(trig->tdata3);
|
||||
}
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
|
||||
return SBI_SUCCESS;
|
||||
}
|
||||
@@ -596,8 +598,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
||||
return SBI_ERR_NO_SHMEM;
|
||||
|
||||
shmem_base = hart_shmem_base(hs);
|
||||
sbi_hart_map_saddr((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
sbi_hart_protection_map_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
|
||||
/* Check requested triggers configuration */
|
||||
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
||||
@@ -606,20 +608,23 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
||||
|
||||
if (!dbtr_trigger_supported(TDATA1_GET_TYPE(ctrl))) {
|
||||
*out = _idx;
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
return SBI_ERR_FAILED;
|
||||
}
|
||||
|
||||
if (!dbtr_trigger_valid(TDATA1_GET_TYPE(ctrl), ctrl)) {
|
||||
*out = _idx;
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
return SBI_ERR_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if (hs->available_trigs < trig_count) {
|
||||
*out = hs->available_trigs;
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
return SBI_ERR_FAILED;
|
||||
}
|
||||
|
||||
@@ -639,7 +644,9 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
||||
xmit->idx = cpu_to_lle(trig->index);
|
||||
|
||||
}
|
||||
sbi_hart_unmap_saddr();
|
||||
|
||||
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
|
||||
trig_count * sizeof(*entry));
|
||||
|
||||
return SBI_SUCCESS;
|
||||
}
|
||||
@@ -712,23 +719,23 @@ int sbi_dbtr_update_trig(unsigned long smode,
|
||||
return SBI_ERR_BAD_RANGE;
|
||||
|
||||
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
||||
sbi_hart_map_saddr((unsigned long)entry, sizeof(*entry));
|
||||
sbi_hart_protection_map_range((unsigned long)entry, sizeof(*entry));
|
||||
trig_idx = entry->id.idx;
|
||||
|
||||
if (trig_idx >= hs->total_trigs) {
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
|
||||
return SBI_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
trig = INDEX_TO_TRIGGER(trig_idx);
|
||||
|
||||
if (!(trig->state & RV_DBTR_BIT_MASK(TS, MAPPED))) {
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
|
||||
return SBI_ERR_FAILED;
|
||||
}
|
||||
|
||||
dbtr_trigger_setup(trig, &entry->data);
|
||||
sbi_hart_unmap_saddr();
|
||||
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
|
||||
dbtr_trigger_enable(trig);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user